akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <algorithm>

int  main(){
	int n, x;
	std::cin >> n >> x;

	std::vector<int> a(n);
	for(int i = 0; i < n; ++i){
		std::cin >> a.at(i);
	}

	std::sort(a.begin(), a.end());
	int nofc;
	for(int i = 0; i < n; ++i){
		if(a.at(i) > x){
			//std::cout << "break at i = " << i << std::endl;
			x -= x;
			nofc = i;
			break;
		}
		x -= a.at(i);
		nofc = i + 1;
	}
	
	if(x > 0 && nofc != 0)--nofc;
	std::cout << nofc << std::endl;

	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
char s[20];
int sum,ans;
int main()
{
	scanf("%s",s);
	int n=strlen(s);
	for(register int i=0;i<n;i++)
		if(s[i]=='A' || s[i]=='C' || s[i]=='G' || s[i]=='T')
			sum++;
		else
		{
			if(sum>ans)
				ans=sum;
			sum=0;
		}
	if(sum>ans)
		ans=sum;
	printf("%d",ans);
	return 0;
}

Measured memory_bytes: 256
/*------------------------------------
........Bismillahir Rahmanir Rahim....
..........created by Abdul Aziz.......
------------------------------------*/
#include <iostream>
#include <algorithm>
#include <stdio.h>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <cstring>
#include <unordered_map>
#include <queue>
#define   mod  998244353
#define   int  long long 
#define   ld   long double
#define   pb   push_back
#define   vi  vector<int> 
#define   dbg(x)  cerr << #x << " = " << x << '\n'
#define   sz(x)  (int)x.size()
#define   all(a) (a.begin(),a.end())
#define   ff   first
#define   ss   second
#define   pii  pair<int,int> 
#define   lcm(a,b) (a*b)/__gcd(a,b) 
using namespace std;

inline void solve(){
    string  s; cin>>s;
    int n=sz(s),ans=0;
    for (int i=0;i<(n/2);i++){
        string l,r;
        l=s.substr(0,i+1);
        r=s.substr(i+1,i+1);
        if (l==r){
            int len=sz(l)+sz(r);
            if (len==n) break;
            ans = len;
        }
    }
    cout << ans << endl;
}

signed main()
{
    int n=1; // cin>>n;
    while (n--) solve();
    return 0;
}


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

int main() {
	int n,k,i;
	cin >> k;
	string s;
	cin >> s;
	if(s.size()<=k){
		cout << s << endl;
	}else{
		for(i=0; i<k; i++){
			cout << s[i];
		}
		cout << "..." << endl;
	}
	return 0;
}

Measured memory_bytes: 3624
import java.util.*;
public class Main{
 public static void main(String[] args){
   Scanner sc = new Scanner(System.in);
 
   int N = sc.nextInt();
   int M = sc.nextInt();
   int X = sc.nextInt();
   Integer[] ch = new Integer[N];
   for(int i=0;i<M;i++) ch[i] = sc.nextInt();
   
   int sum0 = 0 ;
   int sumN = 0 ;
   for(int i=1;i<X;i++)
   {
     if(Arrays.asList(ch).contains(i)) sum0++;
   }
      for(int i=X;i<N;i++)
   {
     if(Arrays.asList(ch).contains(i)) sumN++;
   }
   if(sum0<sumN) System.out.println(sum0);
   else System.out.println(sumN);
 }
}

Measured memory_bytes: 21844
import java.util.*;

class Main{
    public static void main(String[] args){
	Scanner sc = new Scanner(System.in);

	while(sc.hasNext()){
	    long a = sc.nextInt();
	    long b = sc.nextInt();
	    
	    long smaller = a;
	    long larger = b;
	    if(b<smaller){smaller = b; larger = a;}
	    
	    long aa = a;
	    long bb = b;
	    while(bb!=0){
		long tmp = bb;
		bb = aa%bb;
		aa = tmp;
	    }

	    long lcm = (a*b)/aa;
	    
	    System.out.println(aa+" "+lcm);
	}
    }
}

Measured memory_bytes: 12000
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define loop(i,x,n) for(ll i=x;i<n;i++) 
#define S(v) sort(v.begin(),v.end());
const ll mod = 1E9+7;
int main()
{
   map<ll,ll> m;
   loop(x,1,100){
      loop(y,1,100){
         loop(z,1,100){
            ll n = x*x+y*y+z*z+x*y+y*z+x*z;
            m[n]++;
         }
      }
   }
   ll n;
   cin>>n;
   loop(i,1,n+1){
      cout<<m[i]<<endl;
   }
}

Measured memory_bytes: 5860
#include <bits/stdc++.h>
#define rep(i,n) for(ll i=1;i<=n;i++)
using namespace std;
using ll=long long;
using P = pair<int,int>;
int main(){
    ll n;
    cin >> n;
    ll mod = 1000000007;
    ll a=1,b=1,c=1;
    for(ll i=1;i<=n;i++){
        a=(a*10)%mod;
        b=(b*9)%mod;
        c=(c*8)%mod;
    }
    ll ans = a-2*b+c;
    ans = ans %mod;
    ans = (ans+mod)%mod;
    cout << ans << endl;
}

Measured memory_bytes: 3604
#include<cstdio>
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<queue>
#include<stack>
#include<map>
#include<set>
#include <iomanip>
#include<math.h>

#define rep0(i,N) for(int i=0;i<N;i++)
#define rep1(i,a,N) for(int i=0+a;i<N;i++)
#define lint long long int
#define SIZE 100005

using namespace std;

int main(){
	int a;
	cin>>a;
	lint ans=2;
	rep0(i,a){
		ans=ans*2+2;
	}
	cout<<ans;
return 0;
}

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

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
int main(){
  int64_t N, K;
  cin >> N >> K;

  int64_t ans = 0;
  int64_t d = pow(10,9)+7;

  for(int64_t i=K; i<=N+1; i++){
    int64_t min, max;
    min = (i-1)*i/2;
    max = (2*N-i+1)*i/2; 
    ans += max - min + 1;
    if(ans > d) ans = ans%d;
  }

  cout << ans;
}

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

#define lli long long int
#define REP(i,s,n) for(int i=s;i<n;i++)
#define NUM 2520
#define INF (1LL<<50)
#define DEBUG 0
#define mp(a,b) make_pair(a,b)
#define SORT(V) sort(V.begin(),V.end())
#define PI (3.141592653589794)
#define TO_STRING(VariableName) # VariableName
#define LOG(x) if(DEBUG)cout<<TO_STRING(x)<<"="<<x<<" "<<endl;
#define LOG2(x,y) if(DEBUG)cout<<TO_STRING(x)<<"="<<x<<" "<<TO_STRING(y)<<"="<<y<<endl;
#define LOG3(x,y,z) if(DEBUG)cout<<TO_STRING(x)<<"="<<x<<" "<<TO_STRING(y)<<"="<<y<<" "<<TO_STRING(z)<<"="<<z<<endl;
#define LOG4(w,x,y,z) if(DEBUG)cout<<TO_STRING(w)<<"="<<w<<" "<<TO_STRING(x)<<"="<<x<<" "<<TO_STRING(y)<<"="<<y<<" "<<TO_STRING(z)<<"="<<z<<endl;

template<class T>bool chmax(T & a, const T & b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }

void func(long long N, std::vector<long long> A){

    SORT(A);

    lli start = 0;
    lli nowSize = A[0];
    lli now = 1;
    while(now<N){
        if(nowSize*2 < A[now]){
            start = now;
        }
        nowSize += A[now];
        now++;
    }

    cout<<N-start<<endl;


}

int main(){
    // cout << fixed << setprecision(5);

    long long N;
    scanf("%lld",&N);
    std::vector<long long> A(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&A[i]);
    }
    func(N, std::move(A));
    return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <sstream>
#include <string>
#define _repargs(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _repargs(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define mod 1000000007
#define inf 2000000007
#define mp make_pair
#define pb push_back
typedef long long ll;
using namespace std;
template <typename T>
inline void output(T a, int p = 0) {
    if(p) cout << fixed << setprecision(p)  << a << "\n";
    else cout << a << "\n";
}
// end of template

int main() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    // source code
    int A, B, C, D, E, F;
    cin >> A >> B >> C >> D >> E >> F;
    int rw = 100, rs = 0;
    rep(a, 51) rep(b, 51) rep(c, 51) rep(d, 51){
        int w = (a * A + b * B) * 100;
        int s = c * C + d * D;
        if(s * 100 <= w * E){
            if(rs * w <= s * rw && s + w <= F) {
                rw = w, rs = s;
            }
        }
    }
    cout << rw + rs << " " << rs << endl;
    
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int mod=1000000007;
long long inv(long long p){
    long long x=1;
    for(int i=mod-2;i>0;i/=2){
        if(i%2)x=x*p%mod;
        p=p*p%mod;
    }
    return x;
}
int main(){
    long long n,m;
    cin>>n>>m;
    n--;
    long long x=1,N=1;
    for(int i=1;i<=n;i++)N=N*i%mod;
    N=inv(N);
    for(int i=2;i*i<=m;i++){
        int yakusu=0;
        if(m%i==0){
            while(m%i==0){
                yakusu++;
                m/=i;
            }
            for(int i=0;i<n;i++)x=x*(n+yakusu-i)%mod;
            x=x*N%mod;
        }
    }
    if(m>1)x=x*(n+1)%mod;
    cout<<x<<endl;
    return 0;
}

Measured memory_bytes: 3612
#include<bits/stdc++.h>
#define INF 9223372036854775807LL
#define mod 1000000007
#define SYOU(x) setprecision(x+1)
#define abs(x,y) (max(x,y)-min(x,y))
#define lol long long
#define mp make_pair
#define fi first
#define se second
using namespace std;
signed main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  lol n,m,a,b,c,d;
  cin >>n>>m;
  lol ans=0;
  ans+=n*(n-1)/2;
  ans+=m*(m-1)/2;
  cout <<ans<<'\n';
  return (0);
}


Measured memory_bytes: 256
n = int(input())
#i　こうひ　j 

def sums(t,i):
    return int(0.5 * (n // i) * (i * 2 + i * ((n // i) -1)))

print(sums(n,1) - sums(n,3) -sums(n,5) + sums(n,15))

Measured memory_bytes: 9176
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >> N;
  vector<int> L(N);
  for (int i = 0; i < N; i++) {
  cin >> L.at(i);
  }
  int Max;
  int notMax;
  Max = 0;
  notMax = 0;
  for (int i = 0; i < N; i++){
    if (Max < L.at(i)){
      notMax += Max;
      Max = L.at(i);
    }
    else{
      notMax += L.at(i);
    }
  }
  if(Max < notMax){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
}

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

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

    int sum = 0;
    vector<int> list(N);

    for (int i = 0; i < N; i++)
    {
        cin >> list[i];
        sum += list[i];
    }
    sort(list.begin(), list.end());

    if (list[N - M] * 4 * M < sum)
        cout << "No";
    else
        cout << "Yes";
}

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

using namespace std;
using ll =long long;
#define For(i, a, b)    for(int i = (a) ; i < (b) ; ++i)
#define rep(i, n)       For(i, 0, n)
#define debug(x)  cerr << #x << " = " << (x) << endl;
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; }
//Write From this Line
ll dp[52][52][2510]; // おそらく初期値は全部0
int main()
{
	int n, a;
	cin >> n >> a; // average を a 円にする！
	vector<int> x(n);
	rep(i,n) cin >> x[i]; 
	// dp[i][j][k] := i 枚目までで j 枚選択して和を k にするときの組み合わせが何通りあるか。 

	rep(i,52){
		rep(j,52){
			rep(k,2510){
				// 任意の i に対して j == 0 , k == 0 は1
				if(j == 0 && k == 0) dp[i][j][k] = 1;
				else dp[i][j][k] = 0;
			}
		}
	}

	/* 遷移は、今見ているカードの数字が X のとき,Xを使うなら X が j 枚目になるから
	   dp[i][j][k] = dp[i-1][j-1][k-X] + dp[i-1][j][k];
	 */

	ll ans = 0;
	for(int i = 1; i <= n; i++){
		int X = x[i-1]; 
		for(int j = 1; j <= n; j++){
			for(int k = 1; k <= 2500; k++){
				if(k <= X - 1){
					// (X - 1　までは、そいつを使うことはできない)
					dp[i][j][k] = dp[i-1][j][k];
				} else {
					dp[i][j][k] = dp[i-1][j-1][k-X] + dp[i-1][j][k];
				}
				// if(j*a==k) ans += dp[i][j][k]とすると、同じカードの選び方のものが何度もたされしまうので、51~53行目で ans を作って行く
			}
		}
	}

	// n 枚目までで j 枚選んだとき j * a になるやつをansに足す
	rep(j,n+1){
		ans += dp[n][j][j*a] ;
	}
	// なぜか1大きい値が出力されるので-1する
	cout << ans - 1<< endl;
	// 原因わかった。j = 0 のときに、和が0となるやつが1通りあって、それが ans にたされているからだ。
}


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

using namespace std;

typedef long long ll;

template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }

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

	string s, t;
	cin >> s >> t;

	int n = s.size();
	int m = t.size();

	int ans = m;
	for(int i = 0; i <= n - m; i++){
		int x = 0;
		rep(j, m){
			if(t[j] != s[i+j]) x++;
		}

		chmin(ans, x);
	}

	cout << ans << endl;
}


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

class Main {
	static FastScanner sc = new FastScanner();
	static PrintWriter out = new PrintWriter(System.out);

	public void solve() {
		int N = sc.nextInt();
		int P = sc.nextInt();
		int[] A = new int[N];
		for (int i = 0; i < N; i++) {
			A[i] = sc.nextInt();
		}
		
		if (Arrays.stream(A).anyMatch(i -> i % 2 == 1) ) {
			out.println((long)Math.pow(2, N-1));
		} else {
			if (P == 0) {
				out.println((long)Math.pow(2, N));
			} else {
				out.println(0);
			}
		}
	}

	class Point {
		public int x;
		public int y;
		public int getX() {
			return x;
		}
		public int getY() {
			return y;
		}
	}

	public static void main(String[] args) {
		new Main().solve();
		out.flush();
	}
}

class FastScanner {
	private final InputStream in = System.in;
	private final byte[] buffer = new byte[1024];
	private int ptr = 0;
	private int buflen = 0;

	private boolean hasNextByte() {
		if (ptr < buflen) {
			return true;
		} else {
			ptr = 0;
			try {
				buflen = in.read(buffer);
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (buflen <= 0) {
				return false;
			}
		}
		return true;
	}

	private int readByte() {
		if (hasNextByte())
			return buffer[ptr++];
		else
			return -1;
	}

	private static boolean isPrintableChar(int c) {
		return 33 <= c && c <= 126;
	}

	public boolean hasNext() {
		while (hasNextByte() && !isPrintableChar(buffer[ptr]))
			ptr++;
		return hasNextByte();
	}

	public String next() {
		if (!hasNext())
			throw new NoSuchElementException();
		StringBuilder sb = new StringBuilder();
		int b = readByte();
		while (isPrintableChar(b)) {
			sb.appendCodePoint(b);
			b = readByte();
		}
		return sb.toString();
	}

	public long nextLong() {
		if (!hasNext())
			throw new NoSuchElementException();
		long n = 0;
		boolean minus = false;
		int b = readByte();
		if (b == '-') {
			minus = true;
			b = readByte();
		}
		if (b < '0' || '9' < b) {
			throw new NumberFormatException();
		}
		while (true) {
			if ('0' <= b && b <= '9') {
				n *= 10;
				n += b - '0';
			} else if (b == -1 || !isPrintableChar(b)) {
				return minus ? -n : n;
			} else {
				throw new NumberFormatException();
			}
			b = readByte();
		}
	}

	public int nextInt() {
		long nl = nextLong();
		if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE)
			throw new NumberFormatException();
		return (int) nl;
	}

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


Measured memory_bytes: 28372
ins=input()
l=len(ins)
#print(l)
ans=""
for i in range(l):
    oi = ord(ins[i])
    if oi>=65 and oi<=90:
        oo = oi + 32
    elif oi>=97 and oi<=122:
        oo = oi -32
    else:
        oo = oi
    ans = ans + chr(oo)
print(ans)


Measured memory_bytes: 5560
#include <iostream>

using namespace std;

int main(void) {
    int w, h, x, y, r;
    
    cin >> w >> h >> x >> y >> r;
    
    if (x + r <= w && y + r <= h && x - r >= 0 && y - r >= 0) {
        cout << "Yes\n";
    } else {
        cout << "No\n";
    }
    
    return 0;
}

Measured memory_bytes: 1124
N, X = map(int, input().split())
x = list(map(int, input().split()))
x.sort()
dist = [abs(x[0]-X)]
for i in range(N - 1):
    dist.append(x[i + 1] - x[i])

# dist内の最大公約数を求めればよい
def gcd(a, b):
    if b == 0:
        return a
    else:
        return gcd(b, a % b)
res = dist[0]
for i in range(1, N):
    res = gcd(res, dist[i])

print(res)

Measured memory_bytes: 63768
N = int(input())
P = [int(x) for x in input().split()]
R = [1]*N
for ind,p in enumerate(P):
    R[p-1]+=ind
A = [30000*i for i in range(1,N+1)]
B = [30000*(N-i-1) + R[i] for i in range(N)]
print(*A)
print(*B)

Measured memory_bytes: 7184
#include<bits/stdc++.h>
using namespace std;
string s, s1;

int main()
{
	getline(cin, s);
	s1 = s;
	reverse(s1.begin(), s1.end());
	for (int i = 0; i < s1.size(); i++)
	{
		if (s1.at(i) == 'b') s1.at(i) = 'd';
		else if (s1.at(i) == 'd') s1.at(i) = 'b';
		else if (s1.at(i) == 'p') s1.at(i) = 'q';
		else if (s1.at(i) == 'q') s1.at(i) = 'p';
	}
	if (s1 == s) puts("Yes"); else puts("No");
	return 0;
}


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

#define f_io ios::sync_with_stdio(false);cin.tie(0)
#define ll long long
#define FOR(a,b,c) for(ll a=b;a<c;a++)
#define cases long t;cin>>t;while(t--)


int main(){

        ll n,k,ans;
        cin>>k>>n;
        ans=k*500;
        if(ans>=n){
            cout<< "Yes\n"<<endl;
        }
        else{
            cout<<"No\n" <<endl;
        }

    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
using namespace std;
int main(void){
  int s;
  cin>>s;
  vector<int>result;
  result.push_back(s);
  int c(1),f(0);
  do{
    if(s%2==0)s/=2;
    else s=s*3+1;
    result.push_back(s);
    c++;
    for(int i(0);i<c-1;i++){
      if(s==result[i]){
        cout<<c<<endl;
        f=1;
        break;
      }
    }
  }while(f==0);
  return 0;
}


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

#define int long long

#define ii pair<int,int>
#define fi first
#define sc second

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

signed main() {
#ifdef _DEBUG
  // freopen("in" , "r", stdin );
#endif
  ios::sync_with_stdio(0); cin.tie(0);
  int d, n;
  cin >> d >> n;
  int t = 1;
  for (int i = 1; i <= d; i++) t *= 100;
  if (n == 100) t *= (n + 1);
  else t *= n;
  cout << t << '\n';
}


Measured memory_bytes: 3608
package main

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

type Restaurant struct {
	city         string
	score, index int
}
type Restaurants []Restaurant

// Len is sort.Interface implementation
func (list Restaurants) Len() int { return len(list) }

// Swap is sort.Interface implementation
func (list Restaurants) Swap(i, j int) {
	t := list[i]
	list[i] = list[j]
	list[j] = t
}

// Less is sort.Interface implementation
func (list Restaurants) Less(i, j int) bool {
	a := list[i]
	b := list[j]
	if a.city == b.city {
		return a.score > b.score
	}
	return a.city < b.city
}

func solve(wholeAppleNum, fragmentNum int) int {
	t := wholeAppleNum*3 + fragmentNum
	return t / 2
}

//
func main() {
	scanner.Split(bufio.ScanWords)
	n := scanInt()
	var list Restaurants
	list = make([]Restaurant, n)

	for i := 0; i < n; i++ {
		city := scanString()
		point := scanInt()
		r := Restaurant{city, point, i + 1}
		list[i] = r
	}
	sort.Sort(list)
	for _, r := range list {
		fmt.Println(r.index)
	}
}

// Commen--------------------------
var scanner = bufio.NewScanner(os.Stdin)

func scanInt() int {
	scanner.Scan()
	a, _ := strconv.Atoi(scanner.Text())
	return a
}
func scanString() string {
	scanner.Scan()
	return scanner.Text()
}

// End -------------------------------


Measured memory_bytes: 640
import java.util.Scanner;

public class Main {

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

		if(time<24){
			System.out.println(time);
		}else{
			time = time -24;
			System.out.println(time);
		}

	}

}


Measured memory_bytes: 21716
#include <bits/stdc++.h>
#include <string>
#include <cstring>
#include <algorithm>
#include <math.h>
#include <map>
#include <bitset>
#include <cmath>
#include <set>
#include <utility>

#define INF 1000000000000
#define MOD 1000000007 //10^9+7:合同式の法

using namespace std;
typedef long long ll;

//マクロ
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)

int main(){
    int N;
    cin >> N;
    vector<int> A(N);

    for(int i = 0;i < N;i++)
        cin >> A.at(i);

    double ans = 0,goukei = 0;

    for(int i = 0;i < N;i++){
        goukei += 1 / (double)A.at(i);
    }

    ans = 1 / goukei;

    printf("%.12f\n",ans);


}

Measured memory_bytes: 3652
#include<iostream>
#include<algorithm>
#include<limits.h>
using namespace std;
int main(){
    int n;
    cin>>n;
    int a[3][100005];
    // int b[10000];
    // int c[10000];
    int dp[3][100005];
    //int pd[100000];
    for(int i=0;i<n;i++){
        cin>>a[0][i]>>a[1][i]>>a[2][i];
        dp[0][i]=0;
        dp[1][i]=0;
        dp[2][i]=0;
    }
    // dp[0][0]=a[0][0];
    // dp[1][0]=a[1][0];
    // dp[2][0]=a[2][0];
    // int pre = -1;
    // int ans = 0;
    // int happy=0;
    for(int p=1;p<=n;p++){
        dp[0][p]=max(dp[1][p-1],dp[2][p-1])+a[0][p-1];
        dp[1][p]=max(dp[0][p-1],dp[2][p-1])+a[1][p-1];
        dp[2][p]=max(dp[0][p-1],dp[1][p-1])+a[2][p-1];
    }
    int ans=max(dp[0][n],max(dp[1][n],dp[2][n]));
    cout<<ans<<endl;
}

Measured memory_bytes: 2560
#include<stdio.h>
int main()
{
    int a,b,sum,mul,subs,arr[3];
    while(scanf("%d%d",&a,&b)==2)
    {
        sum=a+b;
        subs=a-b;
        mul=a*b;

        if(sum>=subs&&sum>=mul)
            printf("%d\n",sum);
        else if(subs>=sum&&subs>=mul)
            printf("%d\n",subs);
        else
            printf("%d\n",mul);
    }
    return 0;
}


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

# define x first    
# define y second
# define mp make_pair
// everything go according to my plan      
# define pb push_back
# define sz(a) (int)(a.size())
# define vec vector         
// shimkenttin kyzdary, dzyn, dzyn, dzyn...
# define y1    Y_U_NO_y1
# define left  Y_U_NO_left
# define right Y_U_NO_right  

using namespace std;

typedef pair <int, int> pii; 
typedef long long ll;
typedef long double ld;

const int Mod = (int)1e9 + 7;
const int MX = 1073741822;
const ll MXLL = 4e18;
const int Sz = 1110111;
// a pinch of soul
inline void Read_rap () {
  ios_base :: sync_with_stdio(0);
  cin.tie(0); cout.tie(0);
}
inline void randomizer3000 () {
  unsigned int seed;
  asm ("rdtsc" : "=A"(seed));
  srand (seed);
}
void files (string problem) {   
  if (fopen ((problem + ".in").c_str(),"r")) {
    freopen ((problem + ".in").c_str(),"r",stdin);
    freopen ((problem + ".out").c_str(),"w",stdout);
  }
}
void localInput(const char in[] = "s") { 
  if (fopen (in, "r")) {
    freopen (in, "r", stdin);
  }
  else
    cerr << "Warning: Input file not found" << endl;
}
int n;

int a[Sz];
                    
int main()
{
  # ifdef Local
    //localInput();
  # endif
  Read_rap();
  cin >> n;                   
                
  map <ll, int> cnt;   
  ll pref = 0;
  ll ans = 0;
  for (int i = 1; i <= n; i++) {
    int x; cin >> x;
    cnt[pref]++;
    pref += x;
    ans += cnt[pref];
  }
  cout << ans;



  return 0;
}






// Coded by Z..



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

using namespace std;

#define mod 1000000007
#define inf 1e18
#define ll long long
#define PI 3.1415926536

int main()
{
  ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
  int n;
  cin >> n;
  int arr[n];
  int xoring = 0;
  for (int i = 0; i < n; i++) {
    cin >> arr[i];
    xoring = xoring ^ arr[i];
  }

  for (int i = 0; i < n; i++) {
    cout << (xoring ^ arr[i] ) << " ";
  }
  return 0;
}

Measured memory_bytes: 4384
#include <stdio.h>
#include <string.h>
#include <limits.h>

#define MAX_N 100
#define INF INT_MAX/2
#define min(a,b) (a < b ? a : b)

void dijkstra(int,int[MAX_N][MAX_N]);

int main(){
  int n,i,j,a[MAX_N][MAX_N];
  int u,k,v,c;
  memset(a,-1,sizeof(a));
  scanf("%d",&n);
  for(i = 0 ; i < n ; i++){
    scanf("%d%d",&u,&k);
    for(j = 0 ; j < k ; j++){
      scanf("%d%d",&v,&c);
      a[u][v] = c;
    }
  }
  dijkstra(n,a);
  return 0;
}

void dijkstra(int n,int a[MAX_N][MAX_N]){
  int used[MAX_N],d[MAX_N],i,v;
  for(i = 0 ; i < n ; i++){
    d[i] = INF;
    used[i] = 0;
  }

  d[0] = 0;
  while(1){
    v = -1;
    for(i = 0 ; i < n ; i++){
      if(!used[i] && (v == -1 || d[i] < d[v])){
        v = i;
      }
    }
    if(v == -1){ break; }
    used[v] = 1;
    for(i = 0 ; i < n ; i++){
      if(a[v][i] == -1){ continue; }
      d[i] = min(d[i],d[v] + a[v][i]);
    }
  }
  
  for(i = 0 ; i < n ; i++){
    printf("%d %d\n",i, d[i]);
  }
}

Measured memory_bytes: 648
#include<bits/stdc++.h>
   using namespace std;
   int main()
   {
   ios::sync_with_stdio(0);
   cin.tie(0);
   int n,k;
   cin>>n>>k;
   int arr[n];
   for(int i=0;i<n;i++)
   cin>>arr[i];
   sort(arr,arr+n);
   int sum=0;
   for(int i=0;i<k;i++)
   sum+=arr[i];
   cout<<sum;
   return 0;
   }

Measured memory_bytes: 3656
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
	ll w,h,x,y;cin>>w>>h>>x>>y;
	printf("%.10lf ",double(w*h)/2.0);
	if(2*x==w&&2*y==h) puts("1");
	else puts("0");
 } 

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using pvi = pair< vector <int> , int> ;
int main(){
    int n;
    cin>>n;
    vector<int> ze = {0};
    pvi start = make_pair(ze, 0);
    queue<pvi> q;
    int c;
    q.push(start);
    while( c < n-1){
        queue<pvi> qtm;
        while(!q.empty()){
            pvi tmp;
            tmp = q.front();
            for(int i=0 ; i<tmp.second+2 ; i++){
                pvi neu = tmp;
                neu.first.push_back(i);
                if(i == tmp.second+1) neu.second++;
                qtm.push(neu);
            }
            q.pop();
        }
        q = qtm;
        c++;
    }
    set<vector<int>> s;
    while( !q.empty()){
        s.insert(q.front().first);
        q.pop();
    }
    while(!s.empty()){
        vector<int> ans = *begin(s);
        for(int i =0; i<n ; i++){
            printf("%c", ('a'+ans.at(i))); 
        }
        cout<<endl;
        s.erase(ans);
    }

}


Measured memory_bytes: 19904
#include<stdio.h>

int main(){
	int n,k,m,r;
	int a, b;
	int ta, tb;
	int i,j;
	int result[10050];
	scanf("%d %d %d %d",&n,&k,&m,&r);
	while(n&&k&&r){
		for(i=0;i<10050;i++){
			result[i] = 0;
		}
		if(m==0){
			b = 1;
			for(i=0;i<r;i++){
				result[i] = (b*10)/n;
				b = (b*10)%n;
			}
		}else{
			b = 1;
			for(i=0;i<10050;i++){
				b *= 10;
				result[i] = b/n;
				b = b%n;
			}
			for(i=1;i<n;i++){
				b = 1;
				a = i*n;
				for(j=0;j<10050;j++){
					b *= 10;
					result[j] += b/a;
					b = b%a;
				}
			}
			for(i=10049;i>=0;i--){
				if(result[i] > 9){
					result[i-1] += result[i]/10;
					result[i] %= 10;
				}
			}
		}
		if(m==1&&n==2){
			printf("1.");
			for(i=0;i<r;i++){
				printf("0");
			}
		}else{
			printf("0.");
			for(i=0;i<r;i++){
				printf("%d",result[i]);
			}
		}
		printf("\n");
		scanf("%d %d %d %d",&n,&k,&m,&r);
	}
	return 0;
}

Measured memory_bytes: 452
import java.util.*;
public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        sc.useDelimiter("");
        int x = 111;
        int d3 = sc.nextInt();
        int d2 = sc.nextInt();
        int d1 = sc.nextInt();
        if(d3<d2){
            x = (d3+1)*111;
        }else if(d3>d2){
            x = d3*111;
        }else{
            if(d1<=d2) x=d3*111;
            else x= (d3+1)*111;
        }
        System.out.println(x);
    }
}

Measured memory_bytes: 21844
#include<iostream>
using namespace std;
int main()
{
	int a,b;
	cin>>a>>b;
	b=b*2;
	if(a>b)
	{
		cout<<a-b<<endl;
	}
	if(a<=b)
	{
		cout<<"0"<<endl;
	}
	
}
 

Measured memory_bytes: 256
//submitted by HimJ
#include<bits/stdc++.h>
#define ll long long
#define mod 1000000007
#define pb push_back
#define fi first
#define se second
#define fr(i,s,e) for(i=s;i<e;i++)
#define ms(arr,val) memset(arr,val,sizeof(arr))
using namespace std;
const int mxn=1e5+1;
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
  ll t=1;
  //cin>>t;
    while(t--){
            double n,m,d;
    cin>>n>>m>>d;
    double ans;
    if(d)
    ans=((m-1)*2*(n-d))/(n*n);
    else
        ans=(m-1)/n;
    cout<<fixed<<setprecision(10)<<ans;

    }
  return 0;
  }



Measured memory_bytes: 256
#![allow(non_snake_case)]

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

// Module
#[allow(unused_imports)]
use std::cmp::{min,max};

// Main
fn main(){
    input!{
        n: u64,
    }
    println!("{}",n*(n+1)/2);
}


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

#define int long long
#define ct(n) cout << n << endl;
#define cts(n) cout << n << " ";
#define cte cout << endl;
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define repo(i,o,n) for(int i=o;i<n;i++)
#define repm(i,n) for(int i=n-1;i>=0;i--)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define sperase(v,n) (v).erase(remove(all(v), n), (v).end());
#define vdelete(v) (v).erase(unique(all(v)), (v).end());
#define vcopy(v1,v2) copy((v1).begin(), (v1).end(), back_inserter((v2)));
#define pb(n) push_back(n);

int n,m,Q,l,r,p,q,memo[501][501],ans[100000];

main() {
    cin >> n >> m >> Q;
    rep(i,m) {
        cin >> l >> r;
        memo[l][r]++;
    }
    rep1(i,n) rep1(j,n) memo[i][j] += memo[i][j-1];
    rep1(j,n) rep1(i,n) memo[i][j] += memo[i-1][j];


    rep(i,Q) {
        cin >> p >> q;
        int mx=max(p,q),mi=min(p,q);
        ans[i] = memo[mx][mx] - (memo[mi-1][mx] + memo[mx][mi-1]) + memo[mi-1][mi-1];
    }
    rep(i,Q) ct(ans[i])

}



Measured memory_bytes: 3712
def solve(n, k, q, a):
    v = [k] * n
    for a_i in a:
        v[a_i-1] += 1
    for v_i in v:
        if v_i > q:
            print("Yes")
        else:
            print("No")

n, k, q = map(int, input().split())
a = [int(input()) for i in range(q)]
solve(n, k, q, a)

Measured memory_bytes: 10472
#include<cstdio>
#include<vector>
#include<algorithm>
using namespace std;
int main(){
    int n,x1,y1,x2,y2,z1,z2,w1,w2;
    while(scanf("%d",&n),n){
        while(n--){
            scanf("%d%d%d%d%d%d%d%d",&x1,&y1,&z1,&w1,&x2,&y2,&z2,&w2);
            int x3=x1*x2-y1*y2-z1*z2-w1*w2;
            int y3=x1*y2+x2*y1-w1*z2+z1*w2;
            int z3=z1*x2+w1*y2+x1*z2-y1*w2;
            int w3=w1*x2-z1*y2+y1*z2+x1*w2;
            printf("%d %d %d %d\n",x3,y3,z3,w3);
        }
    }
    return 0;
}

Measured memory_bytes: 1028
#include<iostream>

using namespace std;

int main(){
    int a,b,c,d;
    cin >> a >> b >> c >> d;

    while(1){
        c = c - b;
        //cout << c;
        if(c <= 0) {cout << "Yes" << endl; break;}

        a = a - d;
        //cout << " " << a << endl;
        if(a <= 0) {cout << "No" << endl; break;}
    }

    return 0;
}

Measured memory_bytes: 3636
#include<queue>
#include<cstdio>
#include<vector>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
struct Node
{
	int a,b,c;
}a[101010];
bool operator < (Node x,Node y)
{
	return x.a>y.a;
}
priority_queue<int>q,q2;
long long g[101010];
int main()
{
	int x,y,z,i,num,n;
	long long sum,summ,ans=0;
	scanf("%d%d%d",&x,&y,&z);
	n=x+y+z,summ=0;
	for(i=1;i<=n;i++)
	{
		scanf("%d%d%d",&a[i].a,&a[i].b,&a[i].c);
		a[i].a-=a[i].c,a[i].b-=a[i].c;
		summ+=a[i].c+a[i].b;
	}
	sort(a+1,a+n+1);
	sum=0,num=0;
	for(i=n;i>=1;i--)
	{
		if(num>=z)
		{
			if(a[i].b<=q.top())
			{
				sum-=-q.top()+a[i].b;
				q.pop();
				q.push(a[i].b);
			}
		}
		else
		{
			num++;
			sum-=a[i].b;
			q.push(a[i].b);
		}
		if(num==z)
			g[i]=sum;
	}
	num=0;
	for(i=1;i<=n;i++)
	{
		if(num<x)
		{
			num++;
			summ+=a[i].a-a[i].b;
			q2.push(-(a[i].a-a[i].b));
		}
		else
		{
			if(a[i].a-a[i].b>=-q2.top())
			{
				summ+=q2.top()+a[i].a-a[i].b;
				q2.pop();
				q2.push(-(a[i].a-a[i].b));
			}
		}
		if(num==x&&n-i>=z)
			ans=max(ans,summ+g[i+1]);
	}
	printf("%lld\n",ans);
	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);
 	return 0;
}


Measured memory_bytes: 2880
import std.stdio, std.conv, std.string, std.array, std.range, std.algorithm, std.container;
import std.math, std.random, std.bigint, std.datetime, std.format;
void main(string[] args){ if(args.length > 1) if(args[1] == "-debug") DEBUG = 1; solve(); }
void log()(){ writeln(""); } void log(T, A ...)(T t, lazy A a){ if(DEBUG) write(t, " "), log(a); } bool DEBUG = 0; 
string read(){ static string[] ss; while(!ss.length) ss = readln.chomp.split; string res = ss[0]; ss.popFront; return res; }
// ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- //

void solve(){
	char[] s = readln.chomp.to!(char[]);
	
	int status = 0;
	long count = 0;
	long ans = 0;
	foreach(c; s){
		if(c == 'A'){
			if(status == 1) count += 1;
			else count = 1, status = 1;
		}
		else if(c == 'B'){
			if(status == 1) status = 2;
			else count = 0, status = 0;
		}
		else if(c == 'C'){
			if(status == 2){
				ans += count;
				status = 1;
			}
			else count = 0, status = 0;
		}
		log(c, "count:", count, "status:", status, "ans:", ans);
	}
	
	ans.writeln;
}

/*
頭から見ていく

頭から見ていって損になることはない
なぜなら「あえてやらない」＝「ABCの形のまま残す」だが
BC... あるいは C... の形が役に立つケースはないので

A
	カウンタを＋１する
　現在位置は「A」
B
	現在位置が「A」なら現在位置は「AB」
	それ以外ならカウンタを０にして現在位置は「」
C
	現在位置が「AB」なら
		答えを＋１する
		カウンタが正ならカウンタを−１して答えを＋１する
		現在位置は「A」
	それ以外ならカウンタを０にして現在位置は「」



*/


Measured memory_bytes: 2744
s = input()
k = int(input())
l = len(s)
s = s * 3
dp = [0,0]
check = []
for i in range(3*l-1):
  if s[i+1] != s[i]:
    dp.append(dp[-1])
  else:
    dp.append(dp[-2]+1)
  if (i+2) % l == 0:
    check.append(dp[-1])
if l == 1:
  ans =  k // 2
elif k % 2 == 0:
  ans = check[1] + (k-2) // 2 * (check[2]-check[0])
else:
  ans = check[0] + (k-1) // 2 * (check[2]-check[0])
print(ans)

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

#define fastio ios_base::sync_with_stdio(0);cin.tie(0)
#define fp(i,a,b) for(int i=a ; i<b ; i++)
#define fn(i,a,b) for(int i=a ; i>=b ; i--)
#define pb push_back
#define mk make_pair
#define ff first
#define ss second
#define all(x) x.begin(),x.end()

typedef long long ll;
typedef pair<int,int> ii;
typedef vector<ii> vii;
typedef vector<int> vi;
typedef vector<ll> vll;

const int M1=105;
const int M2=1e5+5;
const ll INF=1e18;
const int MOD=1e9+5;

int main(){

	fastio;
	ll n,W; cin >> n >> W;
	ll v[M1],w[M1],dp[M2]; fp(i,0,M2) dp[i] = INF;
	fp(i,0,n) cin >> w[i] >> v[i];	

	fp(i,0,n){
		ll DP[M2]; fp(i,0,M2) DP[i] = INF;
		DP[v[i]] = w[i];

		fp(j,1,M2){
			DP[j] = min(DP[j],dp[j]);
			if (dp[j] < INF && v[i] + j < M2) DP[v[i] + j] = min(DP[v[i] + j] , dp[j] + w[i]);
		}
		fp(j,1,M2) dp[j] = DP[j];
	}

	int maxv=0;
	fp(i,1,M2)
		if (dp[i] <= W) maxv = i;
	cout << maxv << "\n";

	return 0;
}


Measured memory_bytes: 5228
#include <iostream>
#include <queue>
#include <vector>
#include <tuple>

template <class T>
using MinHeap = std::priority_queue<T, std::vector<T>, std::greater<T>>;
template <class T>
std::vector<T> vec(int len, T elem) { return std::vector<T>(len, elem); }

constexpr int INF = 1 << 30;

const std::vector<std::pair<int, int>>
    dxys{{0, -1}, {0, 1}, {-1, 0}, {1, 0}};

bool solve() {
    int r;
    std::cin >> r;
    if (r == 0) return false;

    std::vector<std::vector<int>> levss(2);
    for (auto& levs : levss) {
        int h, w, sx, sy;
        std::cin >> w >> h >> sy >> sx;
        --sx, --sy;

        auto grid = vec(h, vec(w, 0));
        for (auto& v : grid) {
            for (auto& x : v) std::cin >> x;
        }

        auto visited = vec(h, vec(w, false));
        visited[sx][sy] = 1;

        MinHeap<std::tuple<int, int, int>> heap;
        heap.emplace(grid[sx][sy], sx, sy);

        levs.resize(h * w + 1, 0);
        int cnt = 0, lmax = 0;

        while (!heap.empty()) {
            int l, x, y;
            std::tie(l, x, y) = heap.top();
            heap.pop();

            lmax = std::max(lmax, l);
            levs[++cnt] = lmax;

            for (auto dxy : dxys) {
                int dx, dy;
                std::tie(dx, dy) = dxy;

                int nx = x + dx,
                    ny = y + dy;
                if (nx < 0 || h <= nx ||
                    ny < 0 || w <= ny ||
                    visited[nx][ny]) continue;

                visited[nx][ny] = true;
                heap.emplace(grid[nx][ny], nx, ny);
            }
        }

        levs.resize(r + 1, INF);
    }

    int ans = INF;
    for (int i = 0; i <= r; ++i) {
        ans = std::min(ans, levss[0][i] + levss[1][r - i]);
    }

    std::cout << ans << "\n";
    return true;
}

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

    while (solve()) {}

    return 0;
}



Measured memory_bytes: 6488
#include <stdio.h>
#include <stdlib.h>

int main(){
    int n;
    int *as;

    scanf("%d\n", &n);
    as = malloc(sizeof(int) * n);
    for(int i = 0; i < n; i++){
        scanf("%d[ \n]", &as[i]);
    }
    for(int i = 0; i < n; i++){
        if(as[i] % 2 == 1){
            continue;
        }
        if(as[i] % 3 == 0 || as[i] % 5 == 0){
            continue;
        }else{
            printf("DENIED\n");
            return 0;
        }
    }
    printf("APPROVED\n");
    return 0;
}


Measured memory_bytes: 128
def solve():
    n = int(input())
    al = [int(i) for i in input().split()]
    memos = [0]*n
    for i in range(n):
        memos[i] = i - (al[i] - 1)
    # print(memos)
    ans = 0
    for idx in range(n):
        if memos[idx] == 0:
            if idx != n - 1:
                memos[idx+1], memos[idx] = memos[idx+1]-1, memos[idx]+1
            else:
                memos[idx], memos[idx-1] = memos[idx-1]+1, memos[idx]-1
            ans += 1
        # print(memos)
    print(ans)

if __name__=="__main__":
    solve()

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

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

typedef long long ll;

const int INF = 1 << 30;
const ll LLINF = 1LL << 62;

int mod = 1000000007;

int main(void){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    char c; cin >> c;
    c++;
    printf("%c\n",c);
    return 0;
}

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

int main(){
    ll N,L,total=0;
    cin >> N;
    vector<ll> nagasa(2001,0);
    vector<ll> nagasa2(2001,0);
    for(ll i=1;i<N+1;i++){
        cin >> L;
        nagasa[L]++;
    }
    nagasa2[1] = nagasa[1];
    for(ll i=2;i<2001;i++){
        nagasa2[i] = nagasa[i]+nagasa2[i-1];
    }
    
    for(ll i=1;i<1001;i++){
        for(ll j=i;j<1001;j++){
            if(i==j){
                if(nagasa[i]<=1) continue;
                else{
                    total+=nagasa[i]*(nagasa[i]-1)*(nagasa2[2*i-1]-nagasa2[i])/2;
                }
                if(nagasa[i]>=3){
                    total+=nagasa[i]*(nagasa[i]-1)*(nagasa[i]-2)/6;
                }
            }else{
                if(nagasa[j]==0) continue;
                if(nagasa[i]==0) continue;
                total+=nagasa[i]*nagasa[j]*(nagasa2[i+j-1]-nagasa2[j]);
                if(nagasa[j] >= 2) total+=nagasa[i]*nagasa[j]*(nagasa[j]-1)/2;
            }
        }
    }
    
    cout << total << endl;
    
    return 0;
}

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

using namespace std;

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

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

  if (a > b) swap(a, b);
  if (b > c) swap(b, c);
  if (a > b) swap(a, b);

  cout << a + b << endl;
  return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define Would
#define you
#define please

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


	string S;
	cin >> S;

	rep1(i, S.size() / 2) {
		int kari = S.size() / 2 - i;
		string S1 = S.substr(0, kari);
		string S2 = S.substr(kari, kari);

		if (S1 == S2) {
			co(kari * 2);
			return 0;
		}
	}

	Would you please return 0;
}

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

int main() {
 string A;
 cin >> A;
 char a,b,c,d;
 a = A.at(0);
 b = A.at(1);
 c = A.at(2);
 d = A.at(3);

 if(a == b){
   if(c == d && d != a){
     cout << "Yes" <<endl;
   }
   else{
     cout << "No" <<endl;
   }
 }
  else if(a == c){
  if(b == d && b != a){
    cout << "Yes" <<endl;
  }
  else{
    cout << "No" <<endl;
  }
}
  else if(a == d){
    if(b == c && b != a){
      cout << "Yes" <<endl;
    }
    else{
      cout << "No" <<endl;
    }
 }
 else{
   cout << "No" <<endl;
 }
}

Measured memory_bytes: 256
/*
Cerberus97
Hanit Banga
*/

#include <iostream>
#include <iomanip>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>

using namespace std;

#define pb push_back
#define fast_cin() ios_base::sync_with_stdio(false)

typedef long long ll;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;

const int N = 1e5 + 5;

int main()
{
	int n; ll a, b, c, d;
	cin >> n >> a >> b >> c >> d;
	b -= a;
	for (int x = 0; x <= n - 1; ++x)
	{
		int y = n - 1 - x;
		if (x * c - y * d <= b and b <= x * d - y * c)
		{
			cout << "YES";
			return 0;
		}
	}

	cout << "NO";
}

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

// #define DEBUG

using namespace std;

const int N = 1e6+7;
const int INF = 0x3f3f3f3f;
const int MOD = 1e9+7;
const double eps = 1e-11;
typedef pair<int, int> pii;

int n;
int dp[N][2];
string s;

inline void solve()
{
    cin >> s;
    n = s.size();
    dp[n][0] = 0; dp[n][1] = INF;
    for (int i = n-1, x; i >= 0; --i) {
        // dp[i][?] whether pay s[i] make difference to s[i-1]
        x = s[i]-'0';
        dp[i][0] = x+min(dp[i+1][0], dp[i+1][1]);
        dp[i][1] = 1+min({dp[i+1][0]+10-x, dp[i+1][1]+8-x});
        #ifdef DEBUG
        cout << dp[i][0] << " " << dp[i][1] << endl;
        #endif
    }
    cout << min(dp[0][0], dp[0][1]) << endl;
}

int main()
{
    ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
    int T = 1;
    while (T--) {
        solve();
    }
    return 0;
}

Measured memory_bytes: 9116
#include <stdio.h>
#include <stdlib.h>

int main() {
  // your code here...
  long N = 0, M = 0;
  scanf("%ld %ld", &N, &M);

  long A_ALL = 0;
  for (long a, i = 0; i < M; i++) {
    scanf("%ld", &a);
    A_ALL += a;
  }

  if (A_ALL > N) {
    printf("-1\n");
    return 0;
  }

  printf("%ld\n", N-A_ALL);
  return 0;
}


Measured memory_bytes: 1724
#include<iostream>
#include<string.h>
#include<string>
#include<stdio.h>
#include<algorithm>
#include<vector>
#include<bitset>
#include<math.h>
#include<stack>
#include<queue>
#include<set>
#include<map>
using namespace std;
typedef long long ll;
typedef long double db;
typedef vector<int> vi;
typedef pair<int,int> pii;
const int N=200000+100;
const db pi=acos(-1.0);
#define lowbit(x) ((x)&(-x))
#define sqr(x) (x)*(x)
#define rep(i,a,b) for (register int i=a;i<=b;i++)
#define per(i,a,b) for (register int i=a;i>=b;i--)
#define go(u,i) for (register int i=head[u],v=sq[i].to;i;i=sq[i].nxt,v=sq[i].to)
#define fir first
#define sec second
#define mkp make_pair
#define pb push_back
#define maxd 998244353
#define eps 1e-8
inline int read()
{
    int x=0,f=1;char ch=getchar();
    while ((ch<'0') || (ch>'9')) {if (ch=='-') f=-1;ch=getchar();}
    while ((ch>='0') && (ch<='9')) {x=x*10+(ch-'0');ch=getchar();}
    return x*f;
}

inline ll readll()
{
    ll x=0;int f=1;char ch=getchar();
    while ((ch<'0') || (ch>'9')) {if (ch=='-') f=-1;ch=getchar();}
    while ((ch>='0') && (ch<='9')) {x=x*10+(ch-'0');ch=getchar();}
    return x*f;
}

struct node{int to,nxt;}sq[N<<1];
int all=0,head[N];
void addedge(int u,int v)
{
    all++;sq[all].to=v;sq[all].nxt=head[u];head[u]=all;
}

int n,m,ans,a[N],d[N][2];
queue<int> q;
bool vis[N];
char s[N];

int main()
{
    n=read();m=read();
    scanf("%s",s+1);
    rep(i,1,n) a[i]=(s[i]=='B');
    rep(i,1,m)
    {
        int u=read(),v=read();
        addedge(u,v);addedge(v,u);
        d[u][a[v]]++;d[v][a[u]]++;
    }
    rep(i,1,n)
    {
        if ((!d[i][0]) || (!d[i][1]))
        {
            vis[i]=1;q.push(i);
        }
    }
    while (!q.empty())
    {
        int u=q.front();q.pop();
        go(u,i)
        {
            d[v][a[u]]--;
            if (((!d[v][0]) || (!d[v][1])) && (!vis[v])) {q.push(v);vis[v]=1;}
        }
    }
    rep(i,1,n) if (!vis[i]) {puts("Yes");return 0;}
    puts("No");return 0;
}

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

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
//typedef vector<vector<ll>> Graph;

const ll mod = 1e9 + 7;
//const ll mod = 998244353;

#define REP(i,n) for(ll i=0;i<(ll)n;i++)
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define spa << " " <<
#define fi first
#define se second

template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }

template<class S, class T> ostream& operator << (ostream& os, const pair<S, T> v){
os << "(" << v.first << ", " << v.second << ")"; return os;
}
template<class T> ostream& operator << (ostream& os, const vector<T> v){
for(int i = 0; i < (int)v.size(); i++){if(i > 0){os << " ";} os << v[i];} return os;
}
template<class T> ostream& operator << (ostream& os, const vector<vector<T>> v){
for(int i = 0; i < (int)v.size(); i++){if(i > 0){os << endl;} os << v[i];} return os;
}

template<typename T> void debug(vector<vector<T>>&v,ll h,ll w){for(ll i=0;i<h;i++)
{cerr<<v[i][0];for(ll j=1;j<w;j++)cerr spa v[i][j];cerr<<endl;}};
template<typename T> void debug(vector<T>&v,ll n){if(n!=0)cerr<<v[0];
for(ll i=1;i<n;i++)cerr spa v[i];
cerr<<endl;};

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

    ll N;
    cin >> N;
    vector<ll> A(N);
    REP(i, N) cin >> A[i];

    vector<ll> dp(N, 0);
    dp[0] = 1000;
    REP(i, N){
        REP(j, N){
            if(i<j){
                ll q = dp[i]/A[i];
                ll val = dp[i] + q*(A[j]-A[i]);
                chmax(dp[j], val);
            }
        }
        if(i<N-1)chmax(dp[i+1], dp[i]);
    }
    cout << dp[N-1] << endl;
    return 0;
}

Measured memory_bytes: 3652