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


#define PB push_back
#define PF push_front
#define LB lower_bound
#define UB upper_bound
#define fr(x) freopen(x,"r",stdin)
#define fw(x) freopen(x,"w",stdout)
#define iout(x) printf("%d\n",x)
#define lout(x) printf("%lld\n",x)
#define REP(x,l,u) for(ll x = (l);x<=(u);x++)
#define RREP(x,l,u) for(ll x = (l);x>=(u);x--)
#define mst(x,a) memset(x,a,sizeof(x))
#define PII pair<int,int>
#define PLL pair<ll,ll>
#define MP make_pair
#define se second
#define fi first
#define dbg(x) cout<<#x<<" = "<<(x)<<endl;
#define sz(x) ((int)x.size())
#define cl(x) x.clear()

typedef  long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ld;
using namespace std;

const int maxn = 100010;
const int mod = 1e9+7;
const int MAX = 1000000010;
const double eps = 1e-6;
const double PI = acos(-1);

template<typename T> inline void read(T &x){
x=0;T f=1;char ch;do{ch=getchar();if(ch=='-')f=-1;}while(ch<'0'||ch>'9');do x=x*10+ch-'0',ch=getchar();while(ch<='9'&&ch>='0');x*=f;
}

template<typename A,typename B> inline void read(A&x,B&y){read(x);read(y);}
template<typename A,typename B,typename C> inline void read(A&x,B&y,C&z){read(x);read(y);read(z);}
template<typename A,typename B,typename C,typename D> inline void read(A&x,B&y,C&z,D&w){read(x);read(y);read(z);read(w);}
template<typename A,typename B> inline A fexp(A x,B p){A ans=1;for(;p;p>>=1,x=1LL*x*x%mod)if(p&1)ans=1LL*ans*x%mod;return ans;}
template<typename A,typename B> inline A fexp(A x,B p,A mo){A ans=1;for(;p;p>>=1,x=1LL*x*x%mo)if(p&1)ans=1LL*ans*x%mo;return ans;}

int n;

int A[maxn<<1],B[maxn<<1];

bool check(int M){
	REP(i,1,n*2-1)B[i]=A[i]<=M;
	REP(i,1,n){
		if(B[n-i]==B[n-i+1])return B[n-i];
		if(B[n+i]==B[n+i-1])return B[n+i];
	}
	return B[1];
}

void Work(){
	int l=1,r=n*2-1;
	while(l<r){
		int M=l+r>>1;
		if(check(M))r=M;else l=M+1;
	}
	iout(l);
}

void Init(){
	read(n);
	REP(i,1,n*2-1)read(A[i]);
}

int main(){
	Init();
	Work();
	return 0;
}


Measured memory_bytes: 1792
S = input()

ans = [0] * len(S)

P = "R"
B = 0
L_cnt = 1
R_cnt = 0
cnt = 0

for i in range(1, len(S)):
    if P == "R":
        if S[i] == "R":
            R_cnt += 1
            temp = R_cnt
            R_cnt = L_cnt
            L_cnt = temp

        else:
            B = i
            ans[B - 1] += L_cnt
            ans[B] += R_cnt

            # reset
            L_cnt = 1
            R_cnt = 0
            ans[B] += 1
            P = "L"

    elif P == "L":
        cnt += 1

        if S[i] == "L":
            if cnt % 2 == 1:
                ans[B-1] += 1
            else:
                ans[B] += 1

        else:
            # reset
            cnt = 0
            P = "R"

print(*ans)


Measured memory_bytes: 78828
/******************************************************************************

                            Online Java Compiler.
                Code, Compile, Run and Debug java program online.
Write your code in this editor and press "Run" button to execute it.

*******************************************************************************/
import java.math.*;
import java.util.*;
public class Main
{
	public static void main(String[] args) {
		Scanner scan=new Scanner(System.in);
		BigInteger a=scan.nextBigInteger();
		BigInteger b=scan.nextBigInteger();
		System.out.println(a.divide(b));
	}
}



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

using namespace std;

typedef long long ll;
const int Nmax = 105;
const ll INF = 1e12L + 5;

struct {
    int weight;
    ll cost;
} a[Nmax];

int N,W;
ll sum;

static inline ll Max(ll a, ll b) {
    return (a > b) ? a : b;
}
static inline ll Min(ll a, ll b) {
    return (a > b) ? b : a;
}

int main() {
    cin >> N >> W;
    for(int i = 1; i <= N; ++i) {
        cin >> a[i].weight >> a[i].cost;
        sum += a[i].cost;
    }
    vector<ll> dp(sum + 1,INF);
    dp[0] = 0;
    for(int i = 1; i <= N; ++i)
        for(int j = sum - a[i].cost; j >= 0; --j)
            dp[j + a[i].cost] = Min(dp[j + a[i].cost],dp[j] + a[i].weight);

    ll ans = 0;
    for(ll i = 0; i <= sum; ++i)
        if(dp[i] <= W)
            ans = max(i,ans);
    cout << ans;
    return 0;
}


Measured memory_bytes: 1024
package main

import (
	"fmt"
	"sort"
)

type node struct {
	Key string
	Num int
}

func main() {
	var n int
	fmt.Scan(&n)
	m := make(map[string]int)
	for i := 0; i < n; i++ {
		var s string
		var num int
		fmt.Scan(&s, &num)
		if _, ok := m[s]; !ok {
			m[s] = 0
		}
		m[s] += num
	}
	list := make([]node, 0, len(m))
	for k, v := range m {
		list = append(list, node{Key: k, Num: v})
	}
	sort.Slice(list, func(i, j int) bool {
		if len(list[i].Key) == len(list[j].Key) {
			return list[i].Key < list[j].Key
		} else {
			return len(list[i].Key) < len(list[j].Key)
		}
	})
	for _, v := range list {
		fmt.Println(v.Key, v.Num)
	}
}



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

int main(){
  string S;
  int len, count=0, rest;

  cin >> S;
  len = (int)S.length();
  rest = 15 - len;

  for(int i=0;i<len;i++){
    if(S[i]=='o'){
      count++;
    }
  }

  if((count+rest)>=8){
    cout << "YES" << endl;
  }else{
    cout << "NO" << endl;
  }

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define sz(arr) (int)(arr).size()
#define rng(arr) arr.begin(), arr.end()
#define show(x) cout << #x << " = " << x << endl;
#define rep(i, n) for (int i = 0; i < (n); ++i)

using namespace std;
typedef long long int ll;

void _cin() {}
template <class Head, class... Tail>
void _cin(Head&& head, Tail&&... tail) {
  cin >> head;
  _cin(forward<Tail>(tail)...);
}

#define Cin(T, ...) \
  T __VA_ARGS__;    \
  _cin(__VA_ARGS__)

#define Cins(T, n, xs) \
  vector<T> xs(n);     \
  for (int i = 0; i < n; ++i) cin >> xs[i]

void Main();
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout << fixed << setprecision(15);
  Main();
  return 0;
}

void Main() {
  Cin(ll, x, y);
  ll i = x;
  ll ans = 0;
  while (true) {
    if (!(x <= i && i <= y)) break;
    ans++;
    i *= 2;
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
using namespace std;
int main()
{
  long long int n;
  int l, h;
  char x, tmp;
  cin >> n;
  string s = "";
  
  while(n)
  {
      if(n % 26 == 0)
      {
          s.push_back('z');
          n = (n / 26) - 1;
      }
      else
      {
          x = ((n % 26) + 96);
          s.push_back(x);
          n /= 26;
      }
  }
  /*
  l = 0;
  h = s.length() - 1;
  while(l < h)
  {
      tmp = s[l];
      s[l] = s[h];
      s[h] = tmp;
      l++;
      h--;
  }
  cout << s << "\n";
  */
  while(!s.empty())
  {
      cout << s.back();
      s.pop_back();
  }
  cout << endl;
  return 0;
}

Measured memory_bytes: 3600
#include <bits/stdc++.h>
using namespace std;
 
bool IsPrime(int num)
{
    if (num < 2) return false;
    else if (num == 2) return true;
    else if (num % 2 == 0) return false;
 
    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            return false;
        }
    }
 
    return true;
}
 
int main()
{
  int x, ans;
  
  cin >> x;
  
  
  while(1){
    if(IsPrime(x)){
      ans = x;
      break;
    }
  	x++;
  }
  
  cout << ans << endl;
 
  return 0;
}

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

typedef long long int LLI;

const LLI MOD = 1e9+7;

LLI N;
LLI M;
LLI xs[114514];
LLI ys[114514];
LLI myws[114514];
LLI hs[114514];

int main() {
  scanf("%lld%lld", &N, &M);
  for (LLI i=0; i<N; i++) scanf("%lld", &xs[i]);
  for (LLI i=0; i<M; i++) scanf("%lld", &ys[i]);

  for (LLI i=1; i<N; i++) {
    hs[i] = xs[i] - xs[i-1];
  }

  for (LLI i=1; i<M; i++) {
    myws[i] = ys[i] - ys[i-1];
  }

  LLI msum = 0;
  for (LLI j=1; j<M; j++) {
    msum += j*(M-j)%MOD * myws[j];
    msum %= MOD;
  }

  LLI ans = 0;
  for (LLI i=1; i<N; i++) {
    ans += i*(N-i)%MOD * hs[i]%MOD * msum;
    ans %= MOD;
  }
  printf("%lld\n", ans);
}


Measured memory_bytes: 3328
let N = Int(readLine()!)!
var A = readLine()!.characters.split(" ").map{Int(String($0))!}
let B = readLine()!.characters.split(" ").map{Int(String($0))!}
var ans = 0
for i in 0..<N {
    let a = min(A[i], B[i])
    let b = min(A[i+1], B[i]-a)
    A[i+1] -= b
    ans += a+b
}
print(ans)

Measured memory_bytes: 9072
#include<iostream>
using namespace std;
int main(void) {
    int S;
    cin >> S;
    int h = S / (60 * 60);
    int m =  (S - (h * 60 * 60)) / 60;
    int s = (S - (h * 60 * 60) - (m * 60));
    cout << h << ':' << m << ':' << s << endl;
    return 0;
}

Measured memory_bytes: 3080
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<cmath>
#include<algorithm>
//deque/functional/iterator/list/map/memory/numeric/queue/set/stack/utility/vector
//#include<bits/stdc++.h>
#define ll long long
using namespace std;

int main()
{
	ios::sync_with_stdio(false);
	int n;
	cin>>n;
	int d,x;
	cin>>d>>x;
	int s=0,a;
	for(int i=0;i<n;i++){
		cin>>a;
		if(d%a==0)
			s+=d/a;
		else{
			s+=d/a+1;
		}
	}
	cout<<s+x<<endl;
return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>
 
//#define getchar_unlocked()  getchar()
int in()
{
    int n = 0, c = getchar_unlocked();
    do n = 10*n + (c & 0xf), c = getchar_unlocked(); while (c >= '0');
    return n;
}
 
int main()
{
    int N, i, a, r, ans;
 
    N = in();
    ans = 0;
    while (N--) {
        a = in();
        if (a == 2) ans++;
        else if (a&1) {
            r = (int)sqrt(a);
            for (i = 3; ; i+=2) {
                if (i > r) { ans++; break; }
                if (a%i == 0) break;
            }
        }
    }
    printf("%d\n", ans);
    return 0;
}


Measured memory_bytes: 2120
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

public class Main {

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

        long S = 0;
        long A[] = new long[N];
        Map<Long, Long> p = new HashMap();

        for (int i = 0; i < N; i++) {
            A[i] = scan.nextLong();
            if (p.containsKey(A[i])) {
                p.put(A[i], p.get(A[i]) + 1);
            } else {
                p.put(A[i], (long)1);
            }

            S = S + A[i];
        }

        int Q = scan.nextInt();
        long B[] = new long[Q];
        long C[] = new long[Q];

        for (int i = 0; i < Q; i++) {
            B[i] = scan.nextLong();
            C[i] = scan.nextLong();

        }
        for (int i = 0; i < Q; i++) {
            if (p.containsKey(B[i])) {
                S = S + ( C[i]-B[i]) * p.get(B[i]);
              if(p.containsKey(C[i])) { p.put(C[i],p.get(C[i])+p.get(B[i]));}
              else{p.put(C[i],p.get(B[i]));}
              p.put(B[i],(long)0);
            }
            System.out.println(S);
        }
    }


}

Measured memory_bytes: 63452
#include <iostream>
#include <cstdio>
#include <cstring>
#include <sstream>
#include <algorithm>
#include <math.h>
#include <map>
#include <functional>
#include <iomanip>
#include <vector>
#include <queue>
#include <stack>
#include <set>
#include <typeinfo>
#define PI 3.14159265359
#define INF 99999999;
#define rep(i, n) for(int i=0; i<n; i++)
#define REP(n) rep(i, n)
#define EPS 1e-10
typedef long long ll;
using namespace std;
typedef pair<int, int> P;

double distanceAB(double xa, double ya, double xb, double yb);
void trace(int A[], int N);

/*
class Target
{
public:
	vector <string> draw(int n)
	{

	}
};
*/


static const int N = 1000;
int c[N + 1][N + 1];

int lcs(string X, string Y)
{
	int m = X.size();
	int n = Y.size();
	int maxl = 0;
	X = ' ' + X;
	Y = ' ' + Y;
	for (int i=1; i<=m; i++) c[i][0] = 0;
	for (int j=1; j<=n; j++) c[0][j] = 0;
	
	for (int i=1; i<=m; i++)
	{
		for (int j=1; j<=n; j++)
		{
			if (X[i] == Y[j])
			{
				c[i][j] = c[i - 1][j - 1] + 1;
			} else {
				c[i][j] = max(c[i - 1][j], c[i][j - 1]);
			}
			maxl = max(maxl, c[i][j]);
		}
	}
	
	return maxl;
}


int main()
{
	string s1, s2;
	int n;
	
	cin >> n;
	REP(n)
	{
		cin >> s1 >> s2;
		cout << lcs(s1, s2) << endl;
	}
	
	return 0;
}


void trace(int A[], int N)
{
	REP(N)
	{
		if (i > 0) cout << " ";
		cout << A[i];
	}
	cout << endl;
}


double distanceAB(double xa, double ya, double xb, double yb)
{
	return sqrt((xb-xa)*(xb-xa) + (yb-ya)*(yb-ya));
}

Measured memory_bytes: 5128
n = int(input())
h = list(map(int,input().split()))
dp = [0 for _ in range(n)]

dp[1] = abs(h[1]-h[0])
for i in range(2,n):
    dp[i] = min(dp[i-1]+abs(h[i]-h[i-1]),dp[i-2]+abs(h[i]-h[i-2]))

print(dp[n-1])

Measured memory_bytes: 13928
#include <bits/stdc++.h>
#define INF (1<<30)
#define MOD 1000000007
#define l_ength size
using ll = long long;
using ld = long double;
using namespace std;

ll memo[70][70];
ll comb( int x, int y ){
	if( memo[x][y] ) return memo[x][y];
	if( y == 0 || y == x ) return memo[x][y] = 1;
	return memo[x][y] = comb(x-1, y)+comb(x-1, y-1);
} 

int main(){
	int n, a, b; cin >> n >> a >> b;
	vector<ll> v(n);
	for( auto &i : v ) cin >> i;
	sort( v.begin(), v.end(), greater<ll>() );
	ll sum = 0;
	for( int i = 0; i < a; ++i ) sum += v[i];
	ld avr = (ld)sum/(ld)a;
	cout << fixed << setprecision(6) << avr << endl;
	ll target = v[a-1];
	if( v[0] != target ){
		int x = 0, y = 0;
		for( int i = 0; i < n; ++i ) if( v[i] == target ) ++x;
		for( int i = 0; i < a; ++i ) if( v[i] == target ) ++y;
		cout << comb(x, y) << endl;
	} else {
		int x = 0;
		ll ans = 0;
		for( int i = 0; i < n; ++i ) if( v[i] == target ) ++x;
		for( int i = a; i <= min(b, x); ++i ) ans += comb(x, i);
		cout << ans << endl;
	}
	return 0;
}



Measured memory_bytes: 256
package main

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

func main() {
	///標準入力を受け取る//////////////////////|
	scanner := bufio.NewScanner(os.Stdin)
	i := 0
	var array []int
	for scanner.Scan() {
		n, _ := strconv.Atoi(scanner.Text())
		array = append(array, n)
		if i++; i == array[0]+1 {
			break
		}
	}
	///アルゴリズム本体////////////////////////|
	// array[0]はN個受け取ることを表す
	min := array[1]
	max := array[2] - min
	// array[0]を除外, array[1]はminに格納
	for a := 2; a < array[0]+1; a++ {
		// minとarray[a]の差を格納
		if max < array[a]-min {
			max = array[a] - min
		}
		// minのほうが大きければminを更新
		if min > array[a] {
			min = array[a]
		}
	}
	///標準出力//////////////////////////////|
	fmt.Println(max)
}


Measured memory_bytes: 9504
import sys
import collections

input_methods=['clipboard','file','key']
using_method=0
input_method=input_methods[using_method]

tin=lambda : map(int, input().split())
lin=lambda : list(tin())
mod=1000000007

#+++++

def main():
	#a = int(input())
	n, m = tin()
	#s = input()
	is_open=[-1]*n
	graph = [[] for _ in range(n)]
	for _ in range(m):
		x, y, _ = tin()
		graph[x-1].append(y-1)
		graph[y-1].append(x-1)
		
	ret = 0
	for i in range(n):
		if is_open[i] > 0:
			continue
		ret += 1
		q=collections.deque()
		q.append(i)
		is_open[i] = 1
		while q:
			pos = q.pop()
			for t in graph[pos]:
				if is_open[t] > 0:
					continue
				is_open[t] = 1
				q.append(t)
	return ret
		
	
	
#+++++
isTest=False

def pa(v):
	if isTest:
		print(v)
		
def input_clipboard():
	import clipboard
	input_text=clipboard.get()
	input_l=input_text.splitlines()
	for l in input_l:
		yield l

if __name__ == "__main__":
	if sys.platform =='ios':
		if input_method==input_methods[0]:
			ic=input_clipboard()
			input = lambda : ic.__next__()
		elif input_method==input_methods[1]:
			sys.stdin=open('inputFile.txt')
		else:
			pass
		isTest=True
	else:
		pass
		#input = sys.stdin.readline
			
	ret = main()
	if ret is not None:
		print(ret)

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

#define F first
#define S second
#define prev azaza
#define MP make_pair
#define PB push_back

using namespace std;
typedef long long ll;
typedef long double ld;

const int max_n = 1, inf = 1000111222;

int main()
{
    //freopen("input.txt", "r", stdin);
    int n, a, b;
    cin >> n >> a >> b;
    int mn;
    if (a + b <= n) {
        mn = 0;
    } else {
        mn = a + b - n;
    }
    cout << min(a, b) << " " << mn << endl;

    return 0;
}




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

using namespace std;

struct UF {
  int n_;
  vector<int> s_;

  UF(int n) : n_(n), s_(n_, 0) {
    for (int i = 0; i < n_; i++)
      s_[i] = i;
  }

  void U(int x, int y) {
    int px = F(x);
    int py = F(y);
    if (px == py) return;
    s_[py] = px;
  }

  int F(int x) {
    if (s_[x] == x) return x;
    return s_[x] = F(s_[x]);
  }
};

map<pair<int, int>, int> t;
int n, k, l;

int main() {
  cin >> n >> k >> l;
  UF u1(n), u2(n);
  for (int i = 1, p, q; i <= k; i++) {
    cin >> p >> q;
    p--; q--;
    u1.U(p, q);
  }
  for (int i = 1, p, q; i <= l; i++) {
    cin >> p >> q;
    p--; q--;
    u2.U(p, q);
  }

  for (int i = 0; i < n; i++) {
    t[make_pair(u1.F(i), u2.F(i))]++;
  }

  for (int i = 0; i < n; i++) {
    printf("%d%c", t[make_pair(u1.F(i), u2.F(i))],
      i == n - 1 ? '\n' : ' ');
  }

  return 0;
}


Measured memory_bytes: 13568
n = int(input())
h = list(map(int, input().split()))

out = 0
tmp = 0
for i in range(len(h)-1):
  if h[i] >= h[i+1]:
    tmp += 1
  else:
    out = max(out, tmp)
    tmp = 0
out = max(out, tmp)
print(out)

Measured memory_bytes: 14252
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
#define INF 999999999
using namespace std;
typedef pair<int, int> P;
typedef pair<llong, llong> LP;
typedef pair<int, P> PP;
typedef pair<llong, LP> LPP;

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

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

  int N,A,B;
  cin >> N >> A >> B;
  N==1 ? cout << "Hello World" : cout << A+B;
}


Measured memory_bytes: 256
N = int(input())

ans = ''
for i in range(1, 99):
    if N <= 26 ** i:
        N -= 1
        for j in range(i):
            ans += chr(ord('a') + N % 26)
            N //= 26
        break
    else :
        N -= 26 ** i
        
print(ans[::-1])

Measured memory_bytes: 9080
#include<bits/stdc++.h>
#define F first
#define S second
#define MP make_pair
#define pb push_back
#define endl '\n'

using namespace std;

typedef long long LL;
typedef pair< int, int > P;
typedef pair< LL, LL > LP;
typedef pair< int, P > iP;
typedef pair< P, P > PP;

static const int INF = INT_MAX;
static const LL LINF = LLONG_MAX;
static const int MIN = INT_MIN;
static const LL LMIN = LLONG_MIN;
static const int MOD = 1000000007;

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

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
     
    int a[3];
    cin >> a[0] >> a[1] >> a[2];
    sort( a, a + 3 );
    if( a[0] == a[1] ) cout << a[2];
    else cout << a[0];
    cout << endl;
    return 0;
}



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

int main()
{
    int N;
    cin >> N;
    while(N > 0) {
        int digit = N%10;
        if(digit == 9) { cout << "Yes" << endl; return 0;}
        N /= 10;
    }
    cout << "No" << endl;
    return 0;
}

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


int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int a, b;
	cin >> a >> b;
	cout << a * b - a - b + 1 << endl;
	return 0;
}

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

for i in range(N):
    A[i] = A[i] - (i + 1)

A.sort()
# print(A)
# print(N // 2)
b = A[N // 2]

sum = 0
for i in range(N):
    sum = sum + max(A[i] - b, -A[i] + b)

print(sum)


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

int main() {
  int n;
  int sum_sq = 0, sq_sum = 0;
  cin >> n;
  for (int i = 0; i < n; ++i) {
    int d;
    cin >> d;
    sq_sum += d * d;
    sum_sq += d;
  }
  cout << (sum_sq * sum_sq - sq_sum) / 2 << "\n";
  return 0;
}


Measured memory_bytes: 256
def solve(maze,H, W, S):
    next_set = set()
    next_set.add(S)
    seen = [[False]*W for _ in range(H)]
    n = 0
    while next_set:
        n += 1
        curr_ = list(next_set)
        next_set = set()
        for h, w in curr_:
            if seen[h][w]:
                continue
            seen[h][w] = True
            for nh, nw in maze[h][w]:
                if seen[nh][nw] == False:
                    next_set.add((nh, nw))
    return n-1

# 入力
H, W = list(map(int, input().split()))
maze = [[[] for _ in range(W)] for _ in range(H)]
for h in range(H):
    row = input()
    for w in range(W):
        if row[w] == '#':
            maze[h][w] = False


# mazeに移動可能移動可能なマスを記録
for h in range(H):
    for w in range(W):
        if maze[h][w] == False:
            continue
        for nh, nw in [(h+1, w), (h, w+1), (h-1, w), (h, w-1)]:
            if 0 <= nh < H and 0<= nw < W:
                if maze[nh][nw] != False:
                    maze[h][w].append((nh, nw))
        # print(maze)
# print(maze)
ans = 0
for i in range(H*W-1):
        h = i//W
        w = i%W
        if maze[h][w]:
            ans = max(ans, solve(maze, H, W, (h, w)))

print(ans)

Measured memory_bytes: 74168
import sys
sys.setrecursionlimit(10**7) #再帰関数の上限,10**5以上の場合python
import math
from copy import copy, deepcopy
from copy import deepcopy as dcp
from operator import itemgetter
from bisect import bisect_left, bisect, bisect_right#2分探索
#bisect_left(l,x), bisect(l,x)#aはソート済みである必要あり。aの中からx未満の要素数を返す。rightだと以下
from collections import deque, defaultdict
#deque(l), pop(), append(x), popleft(), appendleft(x)
#q.rotate(n)で → にn回ローテート
from collections import Counter#文字列を個数カウント辞書に、
#S=Counter(l),S.most_common(x),S.keys(),S.values(),S.items()
from itertools import accumulate,combinations,permutations,product#累積和
#list(accumulate(l))
from heapq import heapify,heappop,heappush
#heapify(q),heappush(q,a),heappop(q) #q=heapify(q)としないこと、返り値はNone
#import fractions#古いatcoderコンテストの場合GCDなどはここからimportする
from functools import reduce,lru_cache#pypyでもうごく
#@lru_cache(maxsize = None)#maxsizeは保存するデータ数の最大値、2**nが最も高効率
from decimal import Decimal

def input(): 
    x=sys.stdin.readline()
    return x[:-1] if x[-1]=="\n" else x
def printe(*x):print("## ",*x,file=sys.stderr)
def printl(li): _=print(*li, sep="\n") if li else None
def argsort(s, return_sorted=False): 
    inds=sorted(range(len(s)), key=lambda k: s[k])
    if return_sorted: return inds, [s[i] for i in inds]
    return inds
def alp2num(c,cap=False): return ord(c)-97 if not cap else ord(c)-65
def num2alp(i,cap=False): return chr(i+97) if not cap else chr(i+65)
def matmat(A,B):
    K,N,M=len(B),len(A),len(B[0])
    return [[sum([(A[i][k]*B[k][j]) for k in range(K)]) for j in range(M)] for i in range(N)]
def matvec(M,v):
    N,size=len(v),len(M)
    return [sum([M[i][j]*v[j] for j in range(N)]) for i in range(size)]
def T(M):
    n,m=len(M),len(M[0])
    return [[M[j][i] for j in range(n)] for i in range(m)]
def main():
    mod = 1000000007
    #w.sort(key=itemgetter(1),reverse=True)  #二個目の要素で降順並び替え

    #N = int(input())
    N, K = map(int, input().split())
    #A = tuple(map(int, input().split())) #1行ベクトル
    #L = tuple(int(input()) for i in range(N)) #改行ベクトル
    #S = tuple(tuple(map(int, input().split())) for i in range(N)) #改行行列
    if K>(N-2)*(N-1)//2:
        print(-1)
        return 
    s=set()
    cur=0
    f=0
    for i in range(1,N):
        for j in range(i+1,N):
            if cur<K:
                s.add((i,j))
                cur+=1
            else:
                f=1
            if f:
                break
        if f:
            break
    print(N*(N-1)//2-K)
    for i in range(0,N):
        for j in range(i+1,N):
            if (i,j) not in s:
                print(i+1,j+1)





if __name__ == "__main__":
    main()

Measured memory_bytes: 79328
#include <stdio.h>

int main(){
	int i,pi,pm,pe,ps,pt[2];
	for(i=0;i<2;i++){
		scanf("%d %d %d %d",&pi,&pm,&pe,&ps);
		pt[i] = pi + pm + pe + ps;
	}
	if(pt[0] == pt[1]) printf("%d\n",pt[0]);
	else if(pt[0] > pt[1]) printf("%d\n",pt[0]);
	else printf("%d\n",pt[1]);

	return 0;
}

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

const long M = 1046527;
const long NIL = -1;
const long L = 14;

string H[M];

long getKey(string str){
	long sum = 0, p = 1, digit = 0;
	for (long i = 0; i < str.size(); i++){
		if (str[i] == 'A') digit = 1;
		else if (str[i] == 'C') digit = 2;
		else if (str[i] == 'G') digit = 3;
		else if (str[i] == 'T') digit = 4;
		else digit = 0;
		sum += p * digit;
		p *= 5;
	}
	return sum;
}

long h1(long key){return key % M;}
long h2(long key){return 1 + (key % (M - 1));}

long find(string str){
	long key, h;
	key = getKey(str);
	for (long i = 0; ; i++){
		h = (h1(key) + i * h2(key)) % M;
		if (H[h] == str) return 1;
		else if (H[h].size() == 0) return 0;
	}
	return 0;
}

long insert(string str){
	long key, h;
	key = getKey(str);
	for (long i = 0; ; i++){
		h = (h1(key) + i * h2(key)) % M;
		if (H[h] == str) return 1;
		else if (H[h].size() == 0){
			H[h] = str;
			return 0;
		}
	}
}

int main(){
	long n;
	string str, com;
	cin >> n;
	for (long i = 0; i < n; i++){
		cin >> com >> str;
		if (com[0] == 'i') insert(str);
		else {
			if (find(str)) cout << "yes" << endl;
			else cout << "no" << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 25872
import java.util.*;

public class Main{
	public static void main(String[] args){
    	Scanner input = new Scanner (System.in);
      	int A1 , A2 , A3;
      	A1 = input.nextInt();
      	A2 = input.nextInt();
      	A3 = input.nextInt();
      	if ( A1 + A2 + A3 >= 22){
        	System.out.println("bust");
        }
      	else{
        	System.out.println("win");
        }
    }
}

Measured memory_bytes: 21844
#include<iostream>

using namespace std;

int main(){
  string str;
  cin >> str;
  int n = str.length();
  int a = 0, b = 0;

  for(int i = 0; i< n;i++){
    if(i%2 == 0){
      if(str[i] == '0') a++;
    }else{
      if(str[i] == '1') a++;
    }
  }

  for(int i = 0; i< n;i++){
    if(i%2 == 0){
      if(str[i] == '1') b++;
    }else{
      if(str[i] == '0') b++;
    }
  }

  cout << min(a, b) << endl;
}

Measured memory_bytes: 512
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <set>
#include <queue>
#include <cmath>
#include <map>

using namespace std;
long long po(int n) {
	long long ans = 1;
	for (int i = 0;i < n;i++) {
		ans *= 2;
	}
	return ans;
}

long long bac(vector<bool> ju) {
	long long ans = 0;
	long long di = 1;
	for (int i = 0;i < ju.size();i++) {
		if (ju[i]) {
			ans += di;
		}
		di *= 2;
	}
	return ans;
}

void ch(long long n, vector<bool> &ju) {
	for (int i = 0;i < ju.size();i++) {
		ju[i] = n % 2;
		n /= 2;
	}
}

void deb(vector<long long> ar) {
	for (int i = 0;i < ar.size();i++) {
		cout << i << ' ' << ar[i] << endl;
	}
}

int main() {
	int n;
	cin >> n;
	vector<vector<int> > da(n, vector<int>(n));
	for (int i = 0;i < n;i++) {
		for (int j = 0;j < n;j++) {
			cin >> da[i][j];
		}
	}
	vector<long long> mo(n);
	mo[0] = 1;
	for (int i = 0;i < n - 1;i++) {
		mo[i + 1] = mo[i] * 2;
	}
	int x = po(n);
	vector<long long> dp(x, 0);
	dp[0] = 1;
	for (long long i = 1;i < x;i++) {
		vector<bool> ju(n);
		ch(i, ju);
		int co = -1;
		long long me = 0, gg = 0;
		for (int j = 0;j < n;j++) {
			if (ju[j]) {
				gg += mo[j];
				co++;
			}
		}
		for (int j = 0;j < n;j++) {
			if (ju[j] & da[co][j]) {
				me += dp[gg-mo[j]];
			}
		}
		dp[i] = me % 1000000007;
	}
	cout << dp[x - 1] << endl;
	//deb(dp);
}

Measured memory_bytes: 16640
import math

mod = 10**9+7
N = int(input())
A = list(map(int, input().split()))
ans = 1
lcm = A[0]
for i in range(1, N):
    a = A[i]
    b = lcm
    gcd = math.gcd(a, b)
    lcm = (a*b)//gcd
    ans *= lcm//b
    ans += lcm//a
    ans %= mod
    
print(ans)

Measured memory_bytes: 10168
N,M=map(int,input().split())
g=1
for i in range(1,int(M**(1/2))+1):
  if M%i==0:
    if i>=N:
      g=M/i
      print(int(g))
      exit()
    elif i<=M/N:
      g=i
print(int(g))

Measured memory_bytes: 3060
using System;
using System.IO;
using System.Collections;
using System.Collections.Generic;
using System.Linq;

class Solver
{
    public static void Main()
    {
        string s = Console.ReadLine().Trim();
        var cs = s.ToCharArray();
        Dictionary<char, long> dic = new Dictionary<char, long>(cs.Length);
        long tmp;
        foreach(var c in cs)
        {
            dic.TryGetValue(c, out tmp);
            dic[c] = 1 + tmp;
        }

        long result = long.MaxValue;
        foreach(var kvp in dic)
        {
            tmp = s.Split(kvp.Key).Max(x => x.Length);
            result = tmp < result ? tmp : result;
        }

        Console.WriteLine(result);
    }
}


Measured memory_bytes: 13280
/**
 *    author:  FromDihPout
 *    created: 2020-06-18
**/

#include <bits/stdc++.h>
using namespace std;


int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int n, k;
    cin >> n >> k;
    set<int> bad;
    for (int i = 0; i < k; i++) {
        int x;
        cin >> x;
        bad.insert(x);
    }
    int amt = n;
    while (1) {
        int copy = amt;
        bool ok = 1;
        while (copy > 0) {
            int digit = copy % 10;
            if (bad.count(digit)) {
                ok = 0;
                break;
            }
            copy /= 10;
        }
        if (ok) {
            cout << amt << endl;
            break;
        }
        amt++;
    }
    return 0;
}

Measured memory_bytes: 3648
#include <iostream>
#include <string>
int main() {
	int N;
	double x;
	std::string u;
	double r{};
	std::cin >> N;
	for (int i = 0; i < N; ++i) {
		std::cin >> x >> u;
		if (u == "BTC")
			r += x * 380000.0;
		else
			r += x;
	}
	std::cout << r << std::endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    int a,b,c,x = 0;
    while(1){
        cin>>a>>b>>c; 
       if(a == -1 &&b == -1&& c == -1) break;
         if(a+b >=80)x = 1;
         if(a+ b>=65 && a+b <80)x = 2;
        
         if(a + b>=30&&a+b<50)x =4;
         if(a + b >=50 && a+b<65||c >=50)x = 3;
          if(a == -1 ||b == -1||a+b <30 )x = 5;
      
        if(x == 1)cout<<'A'<<endl;
        if(x == 2)cout<<'B'<<endl;
        if(x == 3)cout<<'C'<<endl;
        if(x == 4)cout<<'D'<<endl;
        if(x == 5)cout<<'F'<<endl;
         
        x = 0;
    }
    return 0;
}



Measured memory_bytes: 3076
#include <iostream>
#include <vector>
#include <algorithm>
#define rep(i,N) for(ll i=0;i<N;i++)
typedef long long int ll;
using namespace std;
using vl=vector<ll>;

int main(){
    ll N;
    vl acc(5);
    cin>>N;
    rep(i,5){
        cin>>acc[i];
    }
    
    ll m=0;
    ll f=0;
    rep(i,5){
        if(m<N/acc[i]){
            m=N/acc[i];
            if(N%acc[i]==0){
                f=1;
            }
            else{
                f=0;
            }
        }
    }
    
    cout<<5+m-f<<endl;
    
    return 0;
}


Measured memory_bytes: 256
from collections import defaultdict
import math
def factorial_memo(n, p):
  F = [1] * (n + 1)
  for i in range(n):
    F[i + 1] = F[i] * (i + 1) % p
  return F

def inverse(F, p):
  Finv = [x for x in F]
  Finv[-1] = pow(Finv[-1], p - 2, p)
  for i in range(len(F) - 2, 0, -1):
    Finv[i] = Finv[i + 1] * (i + 1) % p
  return Finv

def comb(*A):
  f = F[sum(A)]
  for a in A:
    f *= Finv[a]
  return f % p

def eratosthenes(limit):
  E = [1] * (limit + 1)
  E[0], E[1] = 0, 0
  prime_table = []
  for i, e in enumerate(E):
    if e:
      prime_table.append(i)
      for j in range(i, limit + 1, i):
        E[j] = 0
  return prime_table

N, M = map(int, input().split())
p = 10 ** 9 + 7
limit = int(math.sqrt(M)) + 1
prime_table = eratosthenes(limit)
primes = defaultdict(int)
primes[1] = 0
for prime in prime_table:
  if prime > M:
    break
  while M % prime == 0:
    primes[prime] += 1
    M //= prime
if M > 1:
  primes[M] += 1
F = factorial_memo(max(primes.values()) + N, p)
Finv = inverse(F, p)
cnt = 1
for c in primes.values():
  cnt *= comb(c, N - 1)
print(cnt % p)

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

int main() {
  int X;
  cin >> X;
  int ans=1;
  int exp;
  
  for(int i=2; i*i<=X; i++){
    exp=i*i;
    while(exp<=X){
      if(exp>ans)ans=exp;
      exp*=i;
    }
  }
  
  cout << ans << endl;
}

Measured memory_bytes: 3620
#include<bits/stdc++.h>
using namespace std;
string to_string(const string& s) {
	return '"' + s + '"';
}
string to_string(const bool b) {
	return (b ? "true" : "false");
}
string to_string(const char* s) {
	return to_string((string)s);
}
string to_string(const char c) {
	string s = "'";
	s += c;
	s += "'";
	return s;
}
template<class T, class U>
string to_string(const pair<T, U>& p) {
	string s = "(";
	s += to_string(p.first);
	s += ", ";
	s += to_string(p.second);
	s += ")";
	return s;
}
template<class T>
string to_string(const T& a) {
	bool first = true;
	string s = "{";
	for (const auto& x : a) {
		if(!first){
			s += ", ";
		}
		first = false;
		s += to_string(x);
	}
	s += "}";
	return s;
}
void debug_out() {cerr << '\n';}
template<class Head, class... Tail>
void debug_out(Head head, Tail... tail) {
	cerr << ' ' << to_string(head);
	debug_out(tail...);
}
#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "] = ", debug_out(__VA_ARGS__)
#else
#define debug(...)
#endif
using ll = long long;
using ld = long double;
const int mod = 1e9 + 7;
const int inf = 1e9 + 100;
const ll inf64 = 7e18l;
int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout << fixed << setprecision(20);
	int n;
	cin >> n;
	string s, t;
	cin >> s >> t;
	for (int i = 0; i < n; ++i) {
		cout << s[i] << t[i];
	}
	cout << '\n';
	return 0;
}


Measured memory_bytes: 256
object Main extends App {
  val sc = new java.util.Scanner(System.in)
  val n, m = sc.nextInt()
  val matrix = List.fill(n, m)(sc.nextInt())
  val vector = List.fill(m)(sc.nextInt())
 
  println(matrix.map(e => multiply(e, vector)).map(e => e.sum).mkString("\n"))
 
  def multiply(row: Seq[Int], vector: Seq[Int]): Seq[Int] = (0 to row.size - 1).map(i => row(i) * vector(i))
}

Measured memory_bytes: 58808
using System;

namespace Getting_Started
{
    class Watch
    {
        static void Main(string[] args)
        {
            var S = int.Parse(Console.ReadLine());
            var h = (int)(S / 3600);
            var m = (int)(S / 60) % 60;
            var s = (int)(S % 3600) % 60;
            Console.WriteLine("{0}:{1}:{2}", h, m, s);
        }
    }
}

Measured memory_bytes: 9144
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define loop(i,n) rep(i,0,n)
using namespace std;
using ll = long long;
ll sum_a[100001],sum_aplus[100001];
int main(){
    int n,k;
    cin >> n >> k;
    sum_a[0]=0;
    sum_aplus[0]=0;
    loop(i,n){
        ll a;
        scanf("%lld",&a);
        sum_a[i+1]=sum_a[i]+a;
        sum_aplus[i+1]=sum_aplus[i]+max(a,0LL);
    }
    ll ans=0;
    loop(i,n-k+1){
        //i,i+1,...,i+k-1は同じ色で塗る
        ll tmp1=max(0LL,sum_a[i+k]-sum_a[i]);
        //0,...,i-1とi+k,...,n-1は任意の色で塗る
        ll tmp2=sum_aplus[i]+sum_aplus[n]-sum_aplus[i+k];
        ans=max(ans,tmp1+tmp2);
    }
    cout << ans << endl;
    return 0;
}

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

// in-short-use macros

#define ll long long int
#define ld long double
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define mod 1000000007

//container-use 

typedef vector< ll > vl;
typedef vector< vl > vvl;
typedef pair< ll,ll > pll;
typedef vector<pair<ll,ll > > vpl;
#define all(c) (c).begin(),(c).end()
#define tr(c,i) for(typeof((c).begin() i = (c).begin(); i != (c).end(); i++)
#define present(c,x) ((c).find(x) != (c).end())
#define rep(i,a,b) for (int i = a; i <= b; i++)

//main function here

ll n,k;
ll a[200000+5],f[200000+5];
bool check(ll m)
{
    ll sum=0;          // count of a[i]'s needed to be wwasted by k
    for(ll i=0;i<n;i++)
    {
        if(m/f[i]==0)
        {
            sum+=a[i];
        }
        else
        {
            if(a[i]>=m/f[i])
            {
                sum+=a[i]-m/f[i];
            }
        }
    }
    return sum>k;
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cin>>n>>k;
    for(ll i=0;i<n;i++)
        cin>>a[i];
    for(ll i=0;i<n;i++)
        cin>>f[i];
    sort(a,a+n);
    sort(f,f+n,greater<ll>());
    ll l=0,r=(ll)(1e18),mid,d;
    while(l<=r)
    {
        mid=(l+r)/2;
        if(check(mid))
            l=mid+1;
        else
        {
            d=mid;
            r=mid-1;
        }
    }
    cout<<d<<"\n";
  return 0;
 }

Measured memory_bytes: 3328
#include<stdio.h>
int main()
{
  char a,b;
  int c,d;
  scanf("%c %c",&a,&b);
    // 出力
  c = a-'0';
  d = b-'0';
  
  if (c > d)printf(">");
  else if(c==d)printf("=");
  else printf("<");
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
#define mod 1000000007
using namespace std;
int main()
{
    #ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("outp.txt","w",stdout);
    #endif
    ll n,k,d,x;
    map<ll,ll> m;
    cin>>n>>k;
    for(ll i=1;i<=k;i++)
    {
        cin>>d;
        for(ll it=0;it<d;it++)
        {
            cin>>x;
            m[x]=1;
        }
    }
    cout<<n-m.size();
}

    


Measured memory_bytes: 3640
import sys
input = sys.stdin.readline

n = int(input())
s = input().rstrip()

def z_algo(S):
    N = len(S)
    A = [0]*N
    i = 1; j = 0
    A[0] = l = len(S)
    while i < l:
        while i+j < l and S[j] == S[i+j]:
            j += 1
        if not j:
            i += 1
            continue
        A[i] = j
        k = 1
        while l-i > k < j - A[k]:
            A[i+k] = A[k]
            k += 1
        i += k; j -= k
    return A

ans = 0

for i in range(n):
    s_ = s[i:]
    z_s = z_algo(s_)
    for j in range(len(z_s)):
        ans = max(ans, min(j, z_s[j]))

print(ans)

Measured memory_bytes: 49500
#include<stdio.h>

int main(){
	int i, j, k,  n, b, f, r, v, a[4][3][10] = {0};


	scanf("%d", &n);

	

	for(i = 0; i < n; i++){
		scanf("%d %d %d %d", &b, &f, &r, &v);
		a[b - 1][f - 1][r - 1] += v;
	}

	for(i = 0; i < 4; i++){
		for(j = 0; j < 3; j++){
			for(k = 0; k < 10; k++){
				printf(" %d", a[i][j][k]);
			}
			printf("\n");
		}

		if(i != 3){
			for(k = 0; k < 20; k++){
				printf("#");
			}
			printf("\n");
		}

		
	}

	return 0;
}

Measured memory_bytes: 600
// 2020-07-05 21:19:53
#include<bits/stdc++.h>
#ifdef LOCAL
#include "lib/debug.hpp"
#else
#define debug(...) 1
#endif
#define ALL(a) (a).begin(), (a).end()
#define rep(i, n) REP(i, 0, (n))
#define repc(i, n) REPC(i, 0, (n))
#define REP(i, n, m) for (int i = (int)(n); i < (int)(m); i++)
#define REPC(i, n, m) for (int i = (int)(n); i <= (int)(m); i++)
#define REPCM(i, n, m) for (int i = (int)(n); i >= (int)(m); i--)
using namespace std;
using ll = long long;
using ld = long double;
using pr = pair<ll, ll>;
using vll = vector<ll>;
using vpr = vector<pr>;
template<class T> inline bool chmin(T& a, const T& b) { if (a > b) { a = b; return true; } else return false; }
template<class T> inline bool chmax(T& a, const T& b) { if (a < b) { a = b; return true; } else return false; }

void answer() {
  int n;
  cin >> n;
  vector<ll> a(n);
  rep(i, n) cin >> a[i];
  sort(ALL(a), greater<ll>());
  priority_queue<pr> que;
  que.emplace(a[0], a[0]);
  ll ans = 0;
  REP(i, 1, n) {
    auto u = que.top(); que.pop();
    ans += u.first;
    que.emplace(a[i], u.first);
    que.emplace(a[i], u.second);
  }
  cout << ans << '\n';
}
int main() {
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);
  answer();
  return 0;
}

Measured memory_bytes: 8984
// C++ program to count the Minimum number of 
// increasing subsequences 
#include <bits/stdc++.h> 
using namespace std; 
  
int MinimumNumIncreasingSubsequences(int arr[], int n) 
{ 
    multiset<int> last; 
  
    // last element in each  increasing subsequence  
    // found so far 
    for (int i = 0; i < n; i++) { 
  
        // here our current element is arr[i] 
        multiset<int>::iterator it = last.lower_bound(arr[i]); 
  
        // iterator to the first element larger  
        // than or equal to arr[i] 
        if (it == last.begin()) 
  
            // if all the elements in last larger 
            // than or to arr[i] then insert it into last 
            last.insert(arr[i]); 
  
        else { 
            it--; 
  
            // the largest element smaller than arr[i] is the number 
            // before *it which is it-- 
            last.erase(it); // erase the largest element smaller than arr[i] 
            last.insert(arr[i]); // and replace it with arr[i] 
        } 
    } 
    return last.size(); // our answer is the size of last 
} 
  
// Driver program 

int arr[100005], n;
int main() 
{ 
   cin >> n;
  for(int i = 0; i < n; i++ ) cin >> arr[i];
    cout 
         << MinimumNumIncreasingSubsequences(arr, n); 
    return 0; 
} 


Measured memory_bytes: 5376
n,k = list(map(int, input().split()))
a = sorted(list(map(int, input().split())), reverse=True)

# 作れない数字
# ・最大値より大きい数字
# ・GCDの倍数でない数字

if k > a[0]:
    print('IMPOSSIBLE')
    exit()

import math

gcd = a[0]
for i in a:
    gcd = math.gcd(gcd, i)
    if k%gcd == 0:
        print('POSSIBLE')
        exit()
    
print('IMPOSSIBLE')


Measured memory_bytes: 19920
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <map>
#include <stack>
#include <queue>
using namespace std;
using ll = long long;
using P = pair<int, ll>;

int main()
{
    ll h;
    cin >> h;
    ll p = 2;
    while(h > 1)
    {
        h /= 2;
        p *= 2;
    }
    ll ans = p - 1;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i, n) FOR(i, 0, n)
#define FOR(i, a, b) for (ll i = a; i < b; i++)
#define UM unordered_map
#define ALL(a) (a).begin(), (a).end()
typedef vector<ll> vi;
typedef vector<vector<ll>> vvi;
typedef pair<ll, ll> pii;
const long long INF = 1LL << 58;
struct Edge
{
    ll s, t, d;
};
typedef vector<vector<Edge>> Graph;
typedef vector<pii> vpii;
template <class T>
inline bool chmax(T &a, T b)
{
    if (a < b)
    {
        a = b;
        return true;
    }
    return false;
}
template <class T>
inline bool chmin(T &a, T b)
{
    if (a > b)
    {
        a = b;
        return true;
    }
    return false;
}

int lst[500][500];
signed main()
{
    int N;
    cin >> N;

    ll tmp = -1;
    FOR(i, 1, 500)
    {
        if (i * (i + 1) == 2 * N)
            tmp = i + 1;
    }
    if (tmp == -1)
    {
        cout << "No" << endl;
        return 0;
    }
    N = tmp;
    cout << "Yes" << endl;
    cout << N << endl;
    tmp = 1;
    REP(i, N)
    {
        FOR(j, 1, N - i)
        {
            lst[i][i + j - 1] = tmp;
            lst[i + j][i] = tmp;
            tmp++;
        }
    }
    REP(i, N)
    {
        cout << N - 1;
        REP(j, N - 1)
        {
            cout << " " << lst[i][j];
        }
        cout << endl;
    }
    // system("pause");
}


Measured memory_bytes: 2304
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> P;
typedef pair<int,int> Pi;
#define rep(i,n) for(ll i=0;i<n;i++)
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define fi first
#define se second
#define endl "\n"

template<typename T> inline bool chmax(T &a, T b){if(a<b){a=b;return true;}return false;}
template<typename T> inline bool chmin(T &a, T b){if(a>b){a=b;return true;}return false;}
template<typename T> ostream& operator<<(ostream& s,const complex<T>& d) {return s<<"("<<d.real()<<", "<<d.imag()<< ")";}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const pair<T1,T2>& d) {return s<<"("<<d.first<<", "<<d.second<<")";}
template<typename T> ostream& operator<<(ostream& s, const vector<T>& d){int len=d.size();rep(i,len){s<<d[i];if(i<len-1) s<<" ";}return s;}
template<typename T> ostream& operator<<(ostream& s,const vector<vector<T>>& d){int len=d.size();rep(i,len){s<<d[i]<<endl;}return s;}
template<typename T> ostream& operator<<(ostream& s,const set<T>& v){s<<"{ ";for(auto itr=v.begin();itr!=v.end();++itr) {if (itr!=v.begin()) {s<< ", ";}s<<(*itr);}s<<" }";return s;}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const map<T1,T2>& m){s<<"{"<<endl;for(auto itr=m.begin();itr!=m.end();++itr){s<<" "<<(*itr).first<<" : "<<(*itr).second<<endl;}s<<"}"<<endl;return s;}

const ll mod=1e9+7;
const ll inf=1e17;
const int INF=1e9;
const double PI=acos(-1);
const double EPS=1e-10;

struct mint{
	ll x;
	mint(ll x=0):x((x%mod+mod)%mod){}
	friend ostream &operator<<(ostream& os,const mint& a){
		return os<<a.x;
	}
	friend istream &operator>>(istream& is,mint& a){
		ll t;
		is>>t;
		a=mint(t);
		return (is);
	}
	mint& operator+=(const mint a){
		if((x+=a.x)>=mod) x-=mod;
		return *this;
	}
	mint& operator-=(const mint a){
		if((x+=mod-a.x)>=mod)x-=mod;
		return *this;
	}
	mint& operator*=(const mint a){
		(x*=a.x)%=mod;
		return *this;
	}
	mint operator+(const mint a) const{
		mint res(*this);
		return res+=a;
	}
	mint operator-(const mint a) const{
		mint res(*this);
		return res-=a;
	}
	mint operator*(const mint a) const{
		mint res(*this);
		return res*=a;
	}
	mint pow(ll t) const{
		if (!t) return 1;
		mint a=pow(t>>1);
		a*=a;
		if(t&1) a*=*this;
		return a;
	}
	// for prime mod
	mint inv() const{
		return pow(mod-2);
	}
	mint& operator/=(const mint a){
		return (*this)*=a.inv();
	}
	mint operator/(const mint a) const{
		mint res(*this);
		return res/=a;
	}
};

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

int main(){
	cin.tie(0);ios::sync_with_stdio(false);
	int n;
	cin>>n;
	vector<ll> c(n);
	rep(i,n){
		cin>>c[i];
	}
	sort(begin(c),end(c));
	mint ans=0;
	rep(i,n){
		ans+=(n-i+1)*c[i];
	}
	ans*=mint(4).pow(n-1);
	cout<<ans<<endl;
}

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

using namespace std;

#define PROBLEM "B"
#define TESTC ""

#define USE_CPPIO() ios_base::sync_with_stdio(0); cin.tie(0)
typedef pair<int, int> P;
#define F first
#define S second
#define INF 0x3f3f3f3f
#define MP make_pair
#define PB push_back
#define MAXN 1000005

bool arr[MAXN];

int main()
{
	#ifdef DBG
	freopen(PROBLEM TESTC ".in", "r", stdin);
	freopen(PROBLEM ".out", "w", stdout);
	#endif

	int num;
	
	while(~scanf("%d",&num))
	{
		memset(arr,0,sizeof(arr));

		int cnt = 1;
		while(1)
		{
			arr[num] = true;
			if (num % 2 == 0)
			{
				num /= 2;
			}
			else
			{
				num = num*3+1;
			}
			cnt++;
			if(arr[num])
			{
				break;
			}	
		}

		printf("%d\n",cnt);
		
	}
	
	return 0;
}

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

using namespace std;

int n, k;
int a[200001];
int idx;
int cnt = 0;
int main( ) {
	scanf("%d %d", &n, &k);
	for (int i = 1; i <= n; i ++) {
		scanf("%d", &a[i]);
		if (a[i] == 1) idx = i;
	}
	if (k == n) printf("1\n");
	else {
		idx = min(idx, n - idx + 1);
		
		printf("%d\n", (n - 2) / (k - 1) + 1);
		
		}
	return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <string>
#include <algorithm>
#include <map>
#include <cmath>
#include <iomanip>
#include <vector>
#include <queue>
#include <functional>
#include <random>
#include <ctime>

using namespace std;
typedef long long int ll;
typedef pair<ll, ll> P;

int main() {
    int n;
    cin >> n;
    cout << (n < 1000 ? "ABC" : "ABD");
    return 0;
}



Measured memory_bytes: 256
x=int(input())
ans=0

if x>=400 and x<600:
    ans=8
elif x>=600 and x<800:
    ans=7
elif x>=800 and x<1000:
    ans=6
elif x>=1000 and x<1200:
    ans=5
elif x>=1200 and x<1400:
    ans=4
elif x>=1400 and x<1600:
    ans=3
elif x>=1600 and x<1800:
    ans=2
else:
    ans=1
print(ans)

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

int main(){
  string s;
  cin >> s;
  if(s=="RRR"){
    cout << 3 << endl;
  }else if(s=="RRS" || s=="SRR"){
    cout << 2 << endl;
  }else if(s=="SSS"){
    cout << 0 << endl;
  }else{
    cout << 1 << endl;
  }
}


Measured memory_bytes: 3628