akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define reu(i,l,u) for(int (i)=(int)(l);(i)<(int)(u);++(i))
#define each(it,o) for(auto it= (o).begin(); it != (o).end(); ++ it)
#define mp(x,y) make_pair((x),(y))
#define mset(m,v) memset(m,v,sizeof(m))
#define inrep int t;cin>>t; while(t--)
#define pb emplace_back
using namespace std;
using namespace __gnu_pbds; 


typedef long long int ll;
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef vector<pii > vpii;
typedef vector<ll> vll;
typedef pair<ll,ll> pll;
typedef vector<pll > vpll; 
typedef vector<string> vs;
typedef long double ld;
const ll MOD = 1e9+7;
template<typename T> istream& operator>> ( istream &in,vector<T> &v ) {

    for ( unsigned   i=0; i<v.size(); i++ )
        in>>v[i];
    return in;
}

ll extended_GCD(ll a , ll b , ll &x , ll &y){
    if(a == 0){
        x = 0;
        y = 1;
        return b;
    }
    ll x1 , y1;
    ll gcd = extended_GCD(b%a , a , x1 , y1);
    x = y1 - (b/a)*x1; 
    y = x1;
    return gcd;
}
ll power(ll a, ll b, ll m = MOD) {
    a %= m;
    ll res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a % m;
        a = a * a % m;
        b >>= 1;
    }
    return res;
}
ll modinv(ll a , ll mod ){
    ll x , y;
    extended_GCD(a , mod , x , y);
    if(x < 0) x += mod;
    return x;
}

ll mul(ll a,ll b,ll m)
{
    return (a%m*b%m)%m;
}
  
 


int main()
{
    
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    
        int a;
        cin>>a;
        cout<<a + a*a + a*a*a<<"\n";
    
    
    return 0;
}

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

int N;
int M;

int main() {
    cin >> N >> M;
    vector<int> A(N);
    int sum=0;
    for (int i = 0; i < N; ++i){
      cin >> A[i];
      sum += A[i];
    }
    sort(A.begin(), A.end());
    if (A[N-M]<(double)sum/4/M){
      cout << "No" << endl;
    }else {
      cout << "Yes" << endl;
    }
}

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

using namespace std;
using int_vec = vector<int>;

const int MAX_NUM = 10000;

void print(const int_vec& v) {
    auto it = v.begin();
    for (; it != v.end()-1; ++it) {
        cout << *it << " ";
    }
    cout << *it << endl;
}

int_vec counting_sort(const int_vec& a) {
    int_vec count(MAX_NUM+1, 0);

    for (auto it = a.begin(); it != a.end(); ++it) {
        ++count[*it];
    }
    for (auto it = count.begin(); it != count.end(); ++it) {
        *it += *(it-1);
    }

    int_vec b(a.size());
    for (auto it = a.rbegin(); it != a.rend(); ++it) {
        b[--count[*it]] = *it;
    }
    return b;
}


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

    int_vec v;
    for (auto i = 0; i < n; ++i) {
        int x;
        cin >> x;
        v.push_back(x);
    }

    auto r = counting_sort(v);
    print(r);

    return 0;
}

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

int main(){
  int n;
  cin >> n;
  vector<int>a(n);
  
  for(int i = 0; i<n; i++)
    cin >> a.at(i);
  
  int res = 0;
  
  while(true){
    bool check = false;
    for(int i = 0; i<n; i++){
      if(a.at(i) % 2 != 0)
        check = true;
    }
    if(check)
      break;
    for(int i = 0; i<n; i++)
      a.at(i) /= 2;
    res++;
  }
  cout << res << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<=b;++i)
#define repd(i,a,b) for(int i=a;i>=b;--i) 
#define per(i,a,b) for(int i=a;i>=b;--i)
#define rvc(i,S) for(int i=0;i<(int)S.size();++i)

#define pb push_back
#define fi first
#define se second
#define debug(...) fprintf(stderr,__VA_ARGS__)
#define maxn 1000020
#define ll long long 
#define int long long
#define N 8000020
using namespace std;

int n,k;
int a[maxn];
int sum[maxn];
int cnt=0;
int num[maxn];
bool tmp[maxn];
bool used[maxn];
signed main()
{ cin>>n>>k;
  rep(i,1,n) {scanf("%lld",&a[i]);sum[i]+=sum[i-1]+a[i];}
  rep(i,1,n) rep(j,i,n) num[++cnt]=sum[j]-sum[i-1];
  ll ans=0;
  rep(i,1,cnt) used[i]=1;
  repd(i,60,0)
  {ll tot=0;
   rep(j,1,cnt)
     {if( (num[j]&(1ll<<i)) &&(used[j]) ) tot++;  
	 }
   if(tot>=k)
     {ans+=(1ll<<i);
      rep(j,1,cnt) if( !(num[j]&(1ll<<i)) ) used[j]=0;  
	 }
  }
  cout<<ans;
return 0;
} 

Measured memory_bytes: 8960
#include<iostream>
#include<vector>
#include<algorithm>
#include<map>
#include<cstring>
#include<math.h>
#include<bitset>
#include<queue>
#include<set>
#include<iomanip>
#include<math.h>
#include<assert.h>
#include<string>
#include<cstdlib>
//#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
constexpr long long INF = 1LL << 40;
const double INFD = 1e100;
const ll mod = 1000000007;
const double PI = 3.1415926535897932384626433832795028841971;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
// ----------------------------------------------------------------------------

int main(){
  ll N;
  cin >> N;
  ll K;
  cin >> K;
  vector<ll> vec(100005,0);
  for(int i=0; i<N; i++){
    int a,b;
    cin >> a >> b;
    vec[a] += b;
  }
  ll sum=0;
  for(int i=0; i<100005; i++){
    sum += vec[i];
    if(sum >= K){
      cout << i << endl;
      return 0;
    }
  }
  return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <map>
#include <set>
#include <vector>
#include <algorithm>
#include <math.h>
#include <cmath>
#include <deque>
#include <queue>

using namespace std;
typedef long long ll;

const int MAX = 510000;
const int MOD = 1000000007;

ll fac[MAX], finv[MAX], inv[MAX];

void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int main(){
    ll N,K;
    cin >> N >> K;
    ll A[N];
    for(int i = 0; i < N; i++) cin >> A[i];
    sort(A, A+N);
    
    COMinit();

    ll ans = 0;

    for(int i = N-1; i >= K-1; i--){
        ans += (COM(i, K-1) * A[i])%MOD;
        if(ans >= 0)
            ans %= MOD;
        else{
            ans %= MOD;
            ans = (ans+MOD)%MOD;
        }
    }

    for(int i = 0; i < N-K+1; i++){
        ans -= (COM(N-i-1, K-1)*A[i])%MOD;
        if(ans >= 0)
            ans %= MOD;
        else{
            ans %= MOD;
            ans = (ans+MOD)%MOD;
        }
    }
    cout << ans%MOD << endl;
}


Measured memory_bytes: 12928
#include <iostream>
#include <vector>
#include <queue>
#define INF 100000000

using namespace std;
struct edge { int to, cost; };
typedef pair<int, int> P;
int n, m;
int x1, x2, y1, y2;
vector<edge> G[20];
int dijkstra(int, int);
main(){
  while(cin >> n){
    cin >> m;
    for(int i=0;i<m;i++){
      int a, b, c, d;
      scanf("%d,%d,%d,%d", &a, &b, &c, &d);
      edge tmp;
      tmp.to=b-1;
      tmp.cost=c;
      G[a-1].push_back(tmp);
      tmp.to=a-1;
      tmp.cost=d;
      G[b-1].push_back(tmp);
    }
    scanf("%d,%d,%d,%d", &x1, &x2, &y1, &y2);
    x1--;
    x2--;
    cout << y1-dijkstra(x1, x2)-dijkstra(x2, x1)-y2 << endl;
  }
  return 0;
}

int dijkstra(int s, int g){
  int d[20];
  priority_queue<P, vector<P>, greater<P> > que;
  fill(d, d+n, INF);
  d[s]=0;
  que.push(P(0, s));
  while(!que.empty()){
    P p=que.top(); que.pop();
    int v=p.second;
    if(d[v]<p.first) continue;
    for(int i=0;i<G[v].size();i++){
      edge e=G[v][i];
      if(d[e.to]>d[v]+e.cost){
	d[e.to]=d[v]+e.cost;
	que.push(P(d[e.to], e.to));
      }
    }
  }
  return d[g];
}

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

using namespace std;

// http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=DPL_3_B

int LargestRectangleInAHistogram(vector<int> h) {
  assert( h.size() );
  stack<int> stk;
  int n = (int)h.size();
  vector<int> L(n), R(n);
  for(int i=0;i<n;++i) {
    while( !stk.empty() && h[stk.top()] >= h[i] ) stk.pop();
    L[i] = (stk.empty()?0:stk.top()+1);
    stk.push(i);
  }
  while( !stk.empty() ) stk.pop();
  for(int i=n-1;i>=0;--i) {
    while( !stk.empty() && h[stk.top()] >= h[i] ) stk.pop();
    R[i] = (stk.empty()?n:stk.top());
    stk.push(i);
  }
  int maxi = 0;
  for(int i=0;i<n;++i) {
    maxi = max(maxi,h[i]*(R[i]-L[i]));
  }
  return maxi;
}

int LargestRectangle(int H,int W,vector<vector<int> > c) {
  vector<vector<int> > hs(H,vector<int>(W,0));
  for(int i=0;i<H;++i) {
    for(int j=0;j<W;++j) {
      if( c[i][j] ) continue;
      hs[i][j] = ((i-1>=0)?hs[i-1][j]:0) + 1;
    }
  }
  int maxi = 0;
  for(int i=0;i<H;++i) {
    vector<int> h(W);
    for(int j=0;j<W;++j) {
      h[j] = hs[i][j];
    }
    maxi = max(maxi,LargestRectangleInAHistogram(h));
  }
  return maxi;
}

int main() {
  int H,W;
  cin >> H >> W;
  vector<vector<int> > c(H,vector<int>(W));
  for(int i=0;i<H;++i) for(int j=0;j<W;++j) cin >> c[i][j];
  cout << LargestRectangle(H,W,c) << endl;
  return 0;
}

Measured memory_bytes: 24236
n = int(input())

def make_divisors(n):
    lower_divisors , upper_divisors = [], []
    i = 1
    while i*i <= n:
        if n % i == 0:
            lower_divisors.append(i)
            if i != n // i:
                upper_divisors.append(n//i)
        i += 1
    return lower_divisors + upper_divisors[::-1]

sosu = make_divisors(n)
#print(type(sosu))
kumi = []
for i in range(len(sosu)):
  for j in range(len(sosu)):
    #print(type(sosu[i]))
    if sosu[i]*sosu[j] == n:
      kumi.append([str(sosu[i]), str(sosu[j])])
#print(kumi)
top = 10000000000
#iter = 0
#if 
for i in kumi[:int(len(kumi)/2)+2]:
  sums = max(len(i[0]), len(i[1]))
  if top > sums:
    top = sums
    #iter = max(len(kumi[0]), len(kumi[1]))
print(top)
    

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

ans = [0] * N
for i in range(N)[:: -1]:
    a = A[i]
    cnt = 0
    for j in range(i, N, (i + 1)):
        cnt += ans[j]
    if cnt % 2 != a % 2:
        ans[i] = 1

M = sum(ans)
print(M)
if M > 0:
    print(*[i for i, a in enumerate(ans, start=1) if a > 0])


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

long long int gcd(long long int m,long long int n){
   if(n==0){
      return m;
    }
     return gcd(n,m%n);
}
long long int lcm(long long int number1,long long int number2){
	return number1 * number2 / gcd(number1,number2);	
}

ll max2(ll a,ll b){
  if(a>b){
    return a;
  }
  else{
    return b;
  }
}


int main(){
int N;
  cin>>N;
  vector<ll>A(N);
  vector<ll>rig(N);
  vector<ll>lef(N);
  
  cin>>A[0];
  
  ll ans=A[0];
  rig[0]=ans;
  
  for(ll i=1;i<N;i++){
    cin>>A[i];
    ans=gcd(ans,A[i]); 
    rig[i]=ans;
  }  
  lef[0]=A[N-1];
  ans=A[N-1];
  for(ll i=1;i<N;i++){
    ans=gcd(ans,A[N-1-i]);
    lef[i]=ans;
  }
  int max=max2(rig[N-2],lef[N-2]);
  for(ll i=1;i<N-1;i++){
    int t=gcd(rig[i-1],lef[N-2-i]);
    
    if(t>max){
      max=t;
  }
    
  }
  
  cout<<max<<endl;
}
  
  
  

Measured memory_bytes: 2560
n, k = map(int, input().split())
ans = 0
for i in range(1, n + 1):
    digit_number_difference = len(str(bin(k))) - len(str(bin(i)))
    if digit_number_difference < 0:
        ans += 1/n
        continue
    elif k > i * 2 ** digit_number_difference:
        digit_number_difference += 1
    ans += (1/n) * (1/2)**digit_number_difference
print(ans)


Measured memory_bytes: 3060
#include <iostream>
#include <iomanip>
#include <fstream>
#include <sstream>
#include <vector>
#include <algorithm>
#include <math.h>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <bitset>

#define _GLIBCXX_DEBUG
#define rep(i, n) for (int64_t i = 0; i < (int64_t)(n); i++)
using namespace std;
using vi = vector<int64_t>;
using vvi = vector<vi>;

int main(int argc, const char * argv[]) {
    // fasten cin
    cin.tie(0);
    ios::sync_with_stdio(false);
    // implement
    int64_t n,a,b;
    cin >> n >> a >> b;
    int64_t res=0;
    for(int i=0; i<n+1; i++){
        string s = to_string(i);
        int64_t sum = 0;
        for(int j=0; j<s.size(); j++) sum += s.at(j)-48;
        if(a<=sum && sum<=b) res+=i;
    }
    cout << res << endl;
}


Measured memory_bytes: 256
#include<stdio.h>


void solve() {
   printf("ACL");
}


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

   int t;
   scanf("%d", &t);
   while (t--) {
      solve();
   }
   printf("\n");
   return 0;
}  

Measured memory_bytes: 1728
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

public class Program
{
    static void Main()
    {

        string[] lineRecord = Console.ReadLine().Trim().Split(' ');

        int result = 0;
        for (int i = 0; i < lineRecord.Length; i++)
        {
            result += int.Parse(lineRecord[i]);
        }

        if (result >= 22)
        {
            Console.WriteLine("bust");
        }
        else
        {
            Console.WriteLine("win");
        }

    }
}

Measured memory_bytes: 11220
import sys
 
stdin = sys.stdin

mod = 1000000007
inf = 1 << 60
 
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().rstrip()
nas = lambda: stdin.readline().split()

a = [ni() for i in range(5)]
k = ni()

flag = False
for i in range(4):
    for j in range(i + 1, 5):
        if a[j] - a[i] > k:
            flag = True

if flag:
    print(":(")
else:
    print("Yay!")


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

int main(void) {
  string ss;
  bool flag=true;

  cin >> ss;

  for(int i=0;i<ss.length();i++) {
    if(i%2==0 && ss.at(i)=='L') {
      flag = false;
    }
    if(i%2==1 && ss.at(i)=='R') {
      flag = false;
    }
  }

  if(flag) cout << "Yes" << endl;
  else cout << "No" << endl;

  return (0);
}


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


def count_divisors(n):
    cnt = 0
    for i in range(1, n+1):
        if n % i == 0:
            cnt = cnt + 1
    return cnt


ans = 0

for i in range(1, n+1):
    if i % 2 == 1 and count_divisors(i) == 8:
        ans = ans + 1

print(ans)


Measured memory_bytes: 2940
n, m = map(int, input().split())
nums = []
ans = 0
for i in range(n):
    ka = list(map(int, input().split()))
    for i in range(ka[0]):
        nums.append(ka[i+1])

for i in range(m):
    count = nums.count(i+1)
    if count == n :
        ans += 1

print(ans)

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






int W, A, B;
//-----------------------------------------------------------------------------------
int main() {
	cin >> W >> A >> B;
	if (A > B) swap(A, B);

	if (B <= A + W && A + W <= B + W)
		printf("0\n");
	else
		printf("%d\n", B - (A + W));
}

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

using namespace std;

int main()
{
    string str1,str2,str3;
    while(cin>>str1>>str2>>str3)
    {
        string ans;
        ans=toupper(str1[0]);
        ans+=toupper(str2[0]);
        ans+=toupper(str3[0]);
        cout<<ans<<endl;
    }


    return 0;
}


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

int main()
{
	long long N, A, B;
	scanf("%lld %lld %lld", &N, &A, &B);
	
	long long ans = N / (A + B) * A;
	if (N % (A + B) >= A) ans += A;
	else ans += N % (A + B);
	
	printf("%lld\n", ans);
	fflush(stdout);
	return 0;
}

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

// int/long:		-2,147,483,648 - 2,147,483,648 (-2^31 <= int < 2^31)
// long/long long:	-9,223,372,036,854,775,808 - 9,223,372,036,854,775,807 (-2^63 <= long < 2^63)

#define	INF (1<<29)
//536,870,912

// lower_bound(A.begin(), A.end(), N)
// upper_bound(...

// A.erase(unique(A.begin(), A.end()), A.end())

// bit: &/and, |/or, ^/xor, ~/not

// getline(cin, String)

// Graph
// Warshall-Floyd: Distance between each node, N^3
// Dijkstra: Distance from the start node, N^2
// DFS(Depth-First Search)

#define	MOD 1000000007

int	main() {
	string S;
	cin >>S;
	int n=S.size()-1;
	if (1==n%2)
		n--;
	while (true) {
		int nn=n/2;
		bool Found=true;
		for (int i=0; i<nn; i++) {
			if (S.at(i)!=S.at(i+nn)) {
				Found=false;
				break;
			}
		}
		if(Found)
			break;
		n -=2;
	}
	cout <<n <<endl;
	return 0;
}



Measured memory_bytes: 256
import java.util.Scanner;

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

		int a = sc.nextInt();
		int b = sc.nextInt();

		if(a > 8 || b > 8) {
			System.out.println(":(");
		}else {
			System.out.println("Yay!");
		}

		sc.close();

	}

}


Measured memory_bytes: 22100
using System;
using System.Collections.Generic;
using System.Collections;
using System.Linq;
using System.Text;
class Solution
{
    static void Main(String[] args)
    {

        var s = Console.ReadLine().Split();
        var a = Convert.ToInt32(s[0]);
        var b = Convert.ToInt32(s[1]);
       
       for(int i=1;i<1010;i++){
           if(Math.Floor(i*.08)==a&&Math.Floor(i*.1)==b){
               Console.WriteLine(i);
               return;
           }
       }
               Console.WriteLine(-1);






    }

}

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

template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}
ll n,m;
string s,t;

ll gcd( ll m, ll n )
{
	// 引数に０がある場合は０を返す
	if ( ( 0 == m ) || ( 0 == n ) )
		return 0;
	
	// ユークリッドの方法
	while( m != n )
	{
		if ( m > n ) m = m - n;
		else         n = n - m;
	}
	return m;
}//gcd

int main() {
    std::cin >> n>>m;
    std::cin >> s>>t;
    
    ll l_min =n*m/gcd(n,m);
    
    ll m_d = m/gcd(n,m);
    ll n_d = n/gcd(n,m);
    
    for (ll i = 0; i <= (n-1)*m_d; i+=m_d*n_d) {
        if(s[i/m_d] != t[i/n_d]){
            std::cout << -1 << std::endl;
            return 0;
        }
    }
    std::cout << l_min << std::endl;
}


Measured memory_bytes: 512
#include <iostream>
#include <iomanip>
#include <stdio.h>
#include <vector>
#include <tuple>
#include <map>
#include <unordered_map>
#include <set>
#include <algorithm>
#include <math.h>
#include <bitset>
#include <stack>
#include <queue>
#include <complex>
using namespace std;
// #define exp 2.7182818284590452353602874713527
// #define pi 3.1415926535897932384626433832795
// typedef complex<double> comp;
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
// #include <ext/pb_ds/detail/standard_policies.hpp>
// using namespace __gnu_pbds;
// #define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
#define int long long
void solve()
{
    int n, w1;
    scanf("%lld %lld", &n, &w1);
    vector<int> tmp((n*1000)+1, w1+1), tmp1((n*1000)+1), w(n+1), v(n+1);
    for(int i = 1;i <= n;i++)
        scanf("%lld %lld", &w[i], &v[i]);
    tmp[0] = 0;
    for(int i = 1;i <= n;i++)
    {
        for(int j = v[i];j <= (n*1000);j++)
            tmp1[j] = min(tmp[j], tmp[j-v[i]]+w[i]);
        for(int j = v[i];j <= (n*1000);j++)
            tmp[j] = tmp1[j];
    }
    int ans;
    for(int j = 1;j <= (n*1000);j++)
    {
        if(tmp[j] <= w1)
            ans = j;
    }
    printf("%lld", ans);
}
int32_t main()
{
    double t1 = clock();
    int t;
    // cin >> t;
    t = 1;
    while(t--)
        solve();
    cerr << setprecision(10) << (clock()-t1)/CLOCKS_PER_SEC << "\n";
    return 0;
}

Measured memory_bytes: 1792
#include<iostream>
#include<boost/multiprecision/cpp_int.hpp>

using namespace boost::multiprecision;
using namespace std;

int main()
{
  const int size = 100001;
   int n;
   cin >> n;
  
  cpp_int sum = 0;
  cpp_int *ar = new cpp_int[size];
  for (int i=0; i<size; ++i) ar[i] = 0;
  for (int i=0; i<n; ++i){
    int a;
	cin >> a;
    ar[a] += 1;
    sum += a;
  }

   int q;
   cin >> q;
  for (int i=0; i<q; ++i){
    int b, c;
	cin >> b >> c;
    cpp_int t = ar[b];
    sum -= t * b;
    sum += t * c;
    ar[b] = 0;
    ar[c] += t;
    cout << sum << endl;
  }
  
  delete[] ar;
  return 0;
}


Measured memory_bytes: 6072
#include <bits/stdc++.h>
#define int long long
#define pb push_back
#define mp make_pair
using namespace std;
const int inf = 1e18 + 7;
const int N = 1e6 + 7;
const int md = 1e9 + 7;
void sol() {
  int h, a, n, sm = 0;
  cin >> h >> n;
  for(int i=0; i<n; i++) {
    cin >> a;
    sm += a;
  }
  if(sm >= h) {
    cout << "Yes";
  }
  else cout << "No";
}

int32_t main() 
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int T = 1;
  //cin >> T; while(T--) 
  sol();
  return 0;
}


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

using namespace std;

ll n,res;

int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
    cin>>n;
    for (int x=1;x<=9;x++) {
        ll sum,d;
        sum=x; d=x;
       // cout<<d<<endl;
        while (d*10+9<=n) {
            sum+=9;
            d=d*10+9;
          //  cout<<d<<endl;
        }
        if (d>n) sum=n;
        res=max(res,sum);
    }
    cout<<res;
}




Measured memory_bytes: 256
package main

import (
	"fmt"
	"strings"
)

func main() {
	var S string
	fmt.Scan(&S)
	ss := strings.Split(S, "")
	res := 0
	for r := range ss {
		if ss[r] == "+" {
			res++
		} else {
			res--
		}
	}
	fmt.Print(res)
}


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

#define debug(x) cout <<"DEBUG"<<" "<< #x << ":" << x << '\n'

// n回繰り返し
#define rep(i,n) for(int i = 0; i < ((int)(n)); i++)   // 0-indexed昇順
#define rep1(i,n) for(int i = 1; i <= ((int)(n)); i++) // 1-indexed昇順
#define rrep(i,n) for(int i = ((int)(n)-1); i >= 0; i--)  // 0-indexed降順
#define rrep1(i,n) for(int i = ((int)(n)); i >= 1; i--)   // 1-indexed降順
#define all(x) (x).begin(),(x).end()

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<vi> vii;  // 2次元配列
typedef vector<ll> vll;
typedef vector<double> vd;
typedef pair<int, int> PII;

template<typename T>
using vec = vector<T>;
template<class T>
using maxheap = std::priority_queue<T>;
template<class T>
using minheap = std::priority_queue<T, std::vector<T>, std::greater<T>>;

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

const ld Pi = std::acos(-1.0L);
const ll infll = (1LL<<62)-1;
const int inf = (1<<30)-1;
const int mod = 1000000007;
// const int mod = 998244353;


/*FUNCs=================================================*/
//{0,1,...,n-1}のn個の要素数のbit集合から要素数k個の部分集合のみ列挙して探索する
//k = 0ではうまく動かないので例外処理が必要
int next_combination(int sub){
    int x = sub & -sub, y = sub + x;
    return(((sub & ~y) / x) >> 1) | y;
}


/*MAIN==================================================*/
signed main(){
    int _StartTime_ = clock();
    cin.tie(nullptr);
    ios::sync_with_stdio(false);   //cin cout 高速化
    // cout << fixed << setprecision(15);

    int n;
    cin >> n;

    vll head(5);
    string s;
    rep(i,n) {
        cin >> s;
        if(s[0] == 'M') ++head[0];
        if(s[0] == 'A') ++head[1];
        if(s[0] == 'R') ++head[2];
        if(s[0] == 'C') ++head[3];
        if(s[0] == 'H') ++head[4];
    }

    ll ans = 0;
    for(int bit = (1<<3)-1; bit < (1<<5); bit = next_combination(bit)) {
        ll p = 1;
        for(int i = 0; i < 5; ++i) {
            if((bit>>i)&1) p *= head[i];
        }
        ans += p;
    }
    cout << ans << '\n';

    // printf("ExecutionTime: %d /ms\n",1000*(int)((clock()-_StartTime_)/CLOCKS_PER_SEC));
}

Measured memory_bytes: 256
def Grand_Garden(n, hl):

    ans = 0
    maxlen = max(hl)
    for i in range(maxlen):
        for w in range(n):
            if hl[w] == 0:
                continue
            elif w+1 == n:
                ans += 1
                hl[w] -= 1
                continue
            elif hl[w+1] == 0:
                ans += 1
            hl[w] -= 1

    return ans

def main():
    n = int(input())
    hl = list(map(int, input().split()))
    print(Grand_Garden(n, hl))

if __name__ == '__main__':
    main()

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef unsigned long long int Ull;
typedef pair<int ,int> PII;
template <typename T>
inline T  read()
{
    char c=getchar();
    T x=0,f=1;
    while(!isdigit(c)){if(c=='-')f=-1;c=getchar();}
    while(isdigit(c))x=(x<<3)+(x<<1)+(c^48),c=getchar();
    return x*f;
}
template <typename T>
inline void write(T x) 
{
    if(x < 0) x = (~x) + 1, putchar('-');
    if(x / 10) write(x / 10);
    putchar(x % 10 | 48);
}
const int INF = 0x3f3f3f3f;
const int N = 1e5+10;
int main(){
    //ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
    int n = read<int>();
    int ans = 0;
    for(int i = 1; i <= n; i++){
        int x = read<int>();
        if(i&1 && x&1) ans++;
    }
    cout<<ans<<endl;
} 



Measured memory_bytes: 3572
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
const double eps = 1e-10;
const int MOD = 1000000007;
const int INF = 1000000000;
const ll LINF = 1ll<<50;
template<typename T>
void printv(const vector<T>& s) {
  for(int i=0;i<(int)(s.size());++i) {
    cout << s[i];
    if(i == (int)(s.size())-1) cout << endl;
    else cout << " ";
  }
}
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  while(1) {
    int m, n1, n2; cin >> m >> n1 >> n2;
    if(m == 0) break;
    vi a(m);
    for(int i=0;i<m;++i) {
      cin >> a[i];
    }
    sort(a.rbegin(), a.rend());
    n1--;
    n2--;
    int ma = 0;
    int argma = 0;
    for(int i=n1;i<=n2;++i) {
      if(ma <= a[i] - a[i+1]) {
        ma = a[i] - a[i+1];
        argma = i+1;
      }
    }
    cout << argma << endl;
  }
}



Measured memory_bytes: 3172
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <list>
#include <vector>
#include <queue>
#include <algorithm>
#include <climits>
#include <cstring>
#include <cmath>
#include <stack>
#include <iomanip>
#include <tuple>
#include <functional>

#define int long long
#define CONTAINS(v,n) (find((v).begin(), (v).end(), (n)) != (v).end())
#define SORT(v) sort((v).begin(), (v).end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
#define ARY_SORT(a, size) sort((a), (a)+(size))
#define MAX(a,b) (((a) > (b)) ? (a) : (b))
#define MIN(a,b) (((a) < (b)) ? (a) : (b))
#define REMOVE(v,a) v.erase(remove(v.begin(), v.end(), a), v.end())
#define REP(i, n) for (int (i) = 0; (i) < (n); (i)++)
using namespace std;

struct Tree
{
	int index;
	int a, b;
	vector<Tree*> childlen;
};

int N;
Tree tree[1000];
int X[1000];

int dp[1000][5001];

vector<Tree*>* current;
int currentX;

int func(int n, int sum)
{
	if (sum < 0)
	{
		return INT_MAX;
	}

	if (dp[n][sum] >= 0)
	{
		return dp[n][sum];
	}

	int a = (*current)[n]->a;
	int b = (*current)[n]->b;

	if (n == 0)
	{
		if (sum == b) return a;
		if (sum == a) return b;
		return INT_MAX;
	}

	int n1 = func(n - 1, sum - a) + b;
	int n2 = func(n - 1, sum - b) + a;
	int m = min(n1, n2);
	dp[n][sum] = m;
	return m;
}

void dfs(Tree& tree)
{
	if (tree.childlen.empty())
	{
		tree.a = X[tree.index];
		tree.b = 0;
		return;
	}

	for (Tree* c : tree.childlen)
	{
		dfs(*c);
	}

	//memset(dp, -1L, sizeof(dp));

	current = &tree.childlen;
	currentX = X[tree.index];

	for (int i = 0; i <= currentX; i++)
	{
		for (int j = 0; j < tree.childlen.size(); j++)
		{
			dp[j][i] = -1;
		}
	}

	int min = INT_MAX;
	for (int i = 0; i <= currentX; i++)
	{
		min = MIN(min, func(tree.childlen.size() - 1, i));
	}

	if (min == INT_MAX)
	{
		cout << "IMPOSSIBLE" << endl;
		exit(0);
	}

	tree.a = currentX;
	tree.b = min;
}

signed main()
{
	cin >> N;
	REP(i, N - 1)
	{
		int p;
		cin >> p;
		tree[p - 1].childlen.push_back(&tree[i + 1]);
		tree[i + 1].index = i + 1;
	}
	REP(i, N) cin >> X[i];
	dfs(tree[0]);
	cout << "POSSIBLE" << endl;
}

Measured memory_bytes: 37504
import sys
import numpy as np

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

N = ir()
X = np.array(lr())

def F(z):
    return ((X-z) ** 2).sum()
left = 0
right = 100
while right > left + 1:
    left_mid = (2*left + right) / 3
    right_mid = (left + 2*right) / 3
    if F(left_mid) < F(right_mid):
        right = right_mid
    else:
        left = left_mid

answer = min(F(int(left)), F(int(left)+1), F(int(left)+2))
print(answer)


Measured memory_bytes: 21080
#include<stdio.h>

int main(){

    char base;
    scanf("%c", &base);

    if(base == 'A'){
        printf("T");
    }else if(base == 'T'){
        printf("A");
    }else if(base == 'G'){
        printf("C");
    }else if(base == 'C'){
        printf("G");
    }

    return 0;
}

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

using namespace std;

#define ll long long
#define ld long double
#define EPS 0.0000000001
#define INF 1e9
#define MOD 1000000007
#define rep(i,n) for(i=0;i<n;i++)
#define loop(i,a,n) for(i=a;i<n;i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)

typedef vector<int> vi;
typedef pair<int,int> pii;

int main(void) {
  int i,j;
  int n,q;
  cin>>n>>q;
  vi y(n);
  vector<string> s(n);
  rep(i,n)cin>>y[i]>>s[i];
  string ans="kogakubu10gokan";
  rep(i,n)if(y[i]<=q)ans=s[i];
  cout<<ans<<endl;
}

Measured memory_bytes: 3232
package main

import "fmt"

func digits(n int) int {
	sum := 0
	for n != 0 {
		sum += n % 10
		n /= 10
	}
	return sum
}

func main() {
	var n int
	fmt.Scan(&n)
	if n%digits(n) == 0 {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
long long sum(long long n){return n*(n+1)/2;}

int main(){
    ll n;
    cin>>n;
    ll ans=sum(n)-sum(n/3)*3-sum(n/5)*5+sum(n/15)*15;
    cout<<ans<<endl;
}

Measured memory_bytes: 3568
import std.stdio;
import std.conv, std.array, std.algorithm, std.string;
import std.math, std.random, std.range, std.datetime;
import std.bigint;

void main(){
	string s = readln.chomp;
	
	int ans;
	char x = 'a';
	foreach(c; s){
		if(x != 'a') if(x != c) ans += 1;
		x = c;
		}
	
	ans.writeln;
	}

Measured memory_bytes: 508
// Problem : A - The Number of Even Pairs
// Contest : AtCoder Beginner Contest 159
// URL : https://atcoder.jp/contests/abc159/tasks/abc159_a
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include <bits/stdc++.h>

using namespace std;

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

	vector<int> nums;
	
	for(int i = 0; i < n; i++){
		nums.push_back(2);
	}
	
	for(int i = 0; i < m; i++){
		nums.push_back(1);
	}


	int ans = 0;
	for(int i = 0; i < nums.size() - 1; i++)
		for(int j = i + 1; j < nums.size(); j++)
			if ((nums[i] + nums[j]) % 2 == 0){
				ans++;
			}
	cout << ans << endl;
	return 0;	
}


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

#pragma GCC optimize("unroll-loops")
#pragma GCC optimize("Ofast")

using namespace std;

typedef long long ll;
typedef long double ld;


void solve() {
    ll maxi = 1e18;
    int n;
    cin >> n;
    vector<ll> a(n);
    ld res = 1;
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
        res *= a[i];
        if (res > maxi)  {
            res = maxi + 1;
        }
    }
    if (res == maxi + 1) cout << -1 << "\n";
    else cout << (ll) res << "\n";
   // cout << (ll) res << "\n";
}

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    solve();
    return 0;
}

Measured memory_bytes: 3996
import java.util.Scanner;
import java.util.Stack;

public class Main {

    public static void main(String[] args) {
        Scanner Input = new Scanner(System.in);
        int N = Input.nextInt();
        int M = Input.nextInt();
        int A[][] = new int[N][N];
        for (int I = 0; I < M; I++) {
            int X = Input.nextInt();
            int Y = Input.nextInt();
            A[X-1][Y-1]++;
            A[Y-1][X-1]++;           
        }

        for (int R = 0; R < A.length; R++) {
            int Ko=0;
            for (int C = 0; C < A[0].length; C++) {
                Ko+=A[R][C];
            }
            System.out.println(Ko);
        }

    }
}

//Learn Before You Earn


Measured memory_bytes: 23252
//header{{{
#include<bits/stdc++.h>
  
using namespace std;
 
#define rep(i,n) for(int i=0;i<(n);++i)
#define reps(i,n) for(int i=1;i<=(n);++i)
#define all(x) (x).begin(),(x).end()
#define setout(n,x) setw(n) << setfill(x)
#define Fixed fixed << setprecision(10)
#define int long long
using pii = pair<int,int>;
constexpr int INF  = 0x3f3f3f3f;
constexpr long long LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr int mod = 1e9+7; 
 
int gcd(int a,int b){ return b ? gcd(b,a % b) : a;}
int lcm(int a,int b){ return a / gcd(a,b) * b;}
//}}}

signed main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;
	cin >> n;
	int alice = 0,bob = 0;
	vector<int> a(n);
	rep(i,n){
		cin >> a[i];
	}
	sort(a.rbegin(),a.rend());
	rep(i,n){
		if(i % 2 == 0) alice += a[i];
		else bob += a[i];
	}
	cout << alice - bob << '\n';
	return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main() {
    int N;
    cin >> N;
    bool flag = false;
    for(int i = 0; i <= N/4; i++) {
        for(int j = 0; j <= N/7; j++) {
            if(N == i*4 + j*7) flag = true;
        }
    }
    if(flag) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cctype>
#include <utility>
#include <vector>
#include <algorithm>
using namespace std;

#define gcu getchar_unlocked
#define pcu putchar_unlocked
#define _T template <typename T>
#define _HT template <typename H, typename... T>
#define _il inline
#define _in _il int in
#define _sc _il bool scan
_T T in(int c){T n=0;bool m=false;while(isspace(c)){c=gcu();}if(c=='-')m=true,c=gcu();
	do{n=10*n+(c-'0'),c=gcu();}while(c>='0'&&c<='9');return m?-n:n;}
_in() {return in<int>(gcu());}
_T T scan(T &n){int c=gcu();return c==EOF?false:(n=in<T>(c),true);}
_sc(char &c){c=gcu();gcu();return c!=EOF;}
#ifdef _GLIBCXX_STRING
_sc(string &s){int c;s="";
	for(;;){c=gcu();if(c=='\n'||c==' ')return true;else if(c==EOF)return false;s+=c;}}
#endif
_HT _sc(H &h, T&&... t){return scan(h)&&scan(t...);}
#define _vo _il void out
#define _vl _il void outl
_vo(bool b) {pcu('0'+b);}
_vo(const char *s){while(*s)pcu(*s++);}
_vo(char c){pcu(c);}
#ifdef _GLIBCXX_STRING
_vo(string s){for(char c:s)pcu(c);}
#endif
_T _vo(T n){static char buf[20];char *p=buf;
	if(n<0)pcu('-'),n*=-1;if(!n)*p++='0';else while(n)*p++=n%10+'0',n/=10;
	while (p!=buf)pcu(*--p);}
_vl(){out('\n');}
#ifdef _GLIBCXX_VECTOR
_T _vo(vector<T> &v){for(T &x:v)out(&x == &v[0]?"":" "),out(x);outl();}
#endif
_HT _vo(H&& h, T&&... t){out(h);out(move(t)...);}
template <typename... T> _vl(T&&... t){out(move(t)...);outl();}

int main() {
	for (int N, K; N = in(), K = in();) {
		vector<int> f(K);
		for (int &x: f)
			x = in();
		while (N--)
			for (int &x: f)
				x -= in();
		outl(all_of(f.begin(), f.end(), [](int x){return x >= 0;}) ? "Yes": "No");
	}
}


Measured memory_bytes: 2428
# include <bits/stdc++.h>
# define sz(x) (int)((x).size())
# define F first
# define S second
# define pb push_back
# define ub upper_bound
# define lb lower_bound
# define all(x) x.begin(), x.end()
# define pqueue priority_queue
# define mset multiset
# define umap unordered_map
# define Speed() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
# define rep(i,n) for(int i=0;i<n;++i)
# define forn(i,n) for(int i=1;i<=n;++i)
# define lr(i,l,r) for(int i=l;(l>r?i>=r:i<=r);(l>r?--i:++i))

using namespace std;

template<class T> void umin(T &a,T b){a=min(a,b);}
template<class T> void umax(T &a,T b){a=max(a,b);}

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

const int dx[]={1,0,-1,0,-1,-1,1,1},dy[]={0,1,0,-1,-1,1,-1,1}; 
const int mod = 1e9+7;
const ll N = 2e5+5;

void solve(){
	int n,k;
	cin>>n>>k;
	bool ok=0;
	vector<int>v;
	rep(i,n){
		int x;
		cin>>x;
		v.pb(x);
		if(!x)ok=1;
	}
	if(ok)k--;
	else v.pb(0),sort(all(v));
	int ans=1e9;
	int pos=lb(all(v),0)-v.begin();
	for(int i=0;i<=k;++i){
		if(pos+i<sz(v) && pos-(k-i)>=0){
			umin(ans,v[pos+i]+abs(0-v[pos-k+i])+min(v[pos+i],abs(0-v[pos-k+i])));
		}
	}
	cout<<ans;
}

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

Measured memory_bytes: 3896
using System;

namespace Exponential {
    class ConsoleInput {
        private string[] currentLine = null;
        private int currentCursor = 0;

        public string Get() {
            if (currentLine == null || currentCursor >= currentLine.Length) {
                currentLine = Console.ReadLine().Split(' ');
                currentCursor = 0;
            }
            var res = currentLine[currentCursor];
            currentCursor++;
            return res;
        }

        public int GetInt() {
            return int.Parse(Get());
        }
    }

    class Program {
        static ConsoleInput input = new ConsoleInput();

        static void Main(string[] args) {
            var x = input.GetInt();

            int maxA = 1;
            for(int a = 31; a >= 2; a--) {
                var tmp = a * a;
                while(tmp <= x) {
                    if(maxA < tmp) {
                        maxA = tmp;
                    }
                    tmp *= a;
                }
            }

            Console.WriteLine(maxA);
        }
    }
}


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

using namespace std;

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

    vector<int> dp(n, INT_MAX);
    dp[0] = 0;

    for(int i = 1; i < n; i++){
        int b = 1;
        while(b <= k && (i-b) >= 0){
            //cout << dp[i-b] + abs(h[i] - h[i-b]) << " " << dp[i] << " ";
            dp[i] = min(dp[i-b] + abs(h[i] - h[i-b]), dp[i]);
            b++;
        }
        //cout << "\n";
    }
    cout << dp[n-1];
}


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

typedef long long ll;

const int INF = 1e9;
const int MOD = 1e9+7;
const ll LLINF = 1e18;

#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define FORR(i,a,b) for(int i=(a);i>=(b);i--)

#define ALL(obj) (obj).begin(),(obj).end()

#define pii pair<int,int>

#define pb(a) push_back(a)
#define mp make_pair

int main()
{
	ll n;
	cin >> n;
	ll a = sqrt(n);
	for(; a >= 1; a--){
		if(n % a == 0)break;
	}
	ll b = n / a;
	cout << floorl(log10(b))+1 << "\n";
	return 0;
}


Measured memory_bytes: 512
#include <iostream>
#include <algorithm>
using namespace std;
typedef long long ll;

int main(void)
{
    ll n,l[2100];
    ll i,j,k;
    ll ab;
    ll cnt = 0;
    cin >> n;
    for(i = 0; i < n; i++) {
        cin >> l[i];
    }
    sort(l,l+n);
    for(i = 0; i < n-2; i++) {
        for(j = i+1; j < n - 1; j++) {
          ab = l[i]+l[j];
          for(k = j+1; k < n; k++) {
              if(ab>l[k]) {
//                  cout << l[i] << " " << l[j] << " " << l[k] << endl;
                  cnt ++;
              }
          }
        }
    }
    cout << cnt << endl;
}



Measured memory_bytes: 256
import sys
from collections import defaultdict
from queue import deque
readline = sys.stdin.buffer.readline
sys.setrecursionlimit(10**8)


def geta(fn=lambda s: s.decode()):
    return map(fn, readline().split())


def gete(fn=lambda s: s.decode()):
    return fn(readline().rstrip())


import math


def arg(x, y):
    c = x / math.sqrt(x * x + y * y)
    t = math.acos(c)

    if y < 0:
        t = 2 * math.pi - t

    return t


def dist2(x, y):
    return x * x + y * y


def main():
    N = gete(int)
    E = []
    for _ in range(N):
        x, y = geta(int)
        if x != 0 or y != 0:
            E.append((arg(x, y), x, y))

    E.sort()
    N = len(E)

    ans2 = 0
    for i in range(N):
        j = i
        px, py = (0, 0)
        _, qx, qy = E[i]
        c = 0
        while c < N and dist2(px, py) <= dist2(qx, qy):
            j += 1
            c += 1
            px, py = qx, qy
            _, ex, ey = E[j % N]
            qx, qy = px + ex, py + ey

        tmp = dist2(px, py)

        if ans2 < tmp:
            ans2 = tmp

    print(math.sqrt(ans2))

    ans = 0


if __name__ == "__main__":
    main()

Measured memory_bytes: 3940
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii =  pair<int, int>;
using pll =  pair<long long, long long>;
constexpr char ln =  '\n';
constexpr long long MOD = 1000000007LL;
constexpr long long INF = 1000000009LL;
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define fo(i,j,n) for (int i=(j); i < (n); i++)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int res = INF;
int n, a, b, c;
vector<int> take;

void dfs(vector<vector<int>> list, int cnt, int cost){
    if(cnt == n){
        if(list[0].size()==0 || list[1].size()==0 || list[2].size()== 0) return;
        int len[3] = {0, 0, 0};
        rep(i, 3){
            rep(j, list[i].size()){
                len[i] += take[list[i][j]];
            }
        }
        int sum = abs(len[0]-a)+abs(len[1]-b)+abs(len[2]-c);
        chmin(res, sum + cost);

    }else{
        dfs(list, cnt + 1, cost);
        rep(i, 3){
            list[i].push_back(cnt);
            dfs(list, cnt + 1, cost + 10);
            list[i].pop_back();
        }
    }
}

int main() {
    cin >> n >> a >> b >> c;
    take.resize(n);
    rep(i, n) cin >> take[i];
    vector<vector<int>> list(3, vector<int>());

    dfs(list, 0, -30);
    
    cout << res << ln;
}

Measured memory_bytes: 256
fn main(){
	loop {
		let v = read_vec::<i32>();
		if v[0] == 0 && v[1] == 0 {
			break;
		} else {
	        let (x, y) = if v[0] < v [1] { (v[0], v[1]) } else { (v[1], v[0]) };
	        println!("{} {}", x, y)
	    }
	}
}
 
fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().split_whitespace()
        .map(|e| e.parse().ok().unwrap()).collect()
}


Measured memory_bytes: 5032
import sys
from itertools import accumulate
import heapq
x, y, a, b, c = [int(i) for i in sys.stdin.readline().split()]
ps = [int(i) for i in sys.stdin.readline().split()]
qs = [int(i) for i in sys.stdin.readline().split()]
rs = [int(i) for i in sys.stdin.readline().split()]
ls = []
for p in ps:
    heapq.heappush(ls, (-p, 0))
for q in qs:
    heapq.heappush(ls, (-q, 1))
for r in rs:
    heapq.heappush(ls, (-r, 2))
ans = 0
cnt = 0
x_cnt = 0
y_cnt = 0
while cnt < x + y:
    item = heapq.heappop(ls)
    if item[1] == 2:
        ans -= item[0]
        cnt += 1
    elif item[1] == 0:
        if x_cnt >= x:
            continue
        else:
            x_cnt += 1
            cnt += 1
            ans -= item[0]
    else:
        if y_cnt >= y:
            continue
        else:
            y_cnt += 1
            cnt += 1
            ans -= item[0]
print(ans)

Measured memory_bytes: 123944
import java.util.Scanner;

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

		int x = Integer.parseInt(sc.next());

		for (long t = 0; t <= x; t++) {
			if (t * (t - 1) / 2 < x && t * (t + 1) / 2 >= x) {
				System.out.println(t);
			}
		}

		sc.close();
	}
}

Measured memory_bytes: 21844
#include <bits/stdc++.h>
#define rep(i,N) for (int i = 0; i < (N); ++i)
#define all(v) v.begin(), v.end()
using namespace std;
using ll = long long;
using P = pair<int, int>;
int main(void){
  ll A, B, K;
  cin >> A >> B >> K;

  ll eat = min(A + B, K);  //高橋君が食べたクッキーの枚数
  if (eat <= A){
    cout << A - eat << " " << B << endl;
  }else{
    cout << 0 << " " <<  A + B - eat << endl;
  }
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
const long double PI = (acos(-1));
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
int ctoi(char c)
{
    switch (c)
    {
    case '0':
        return 0;
    case '1':
        return 1;
    case '2':
        return 2;
    case '3':
        return 3;
    case '4':
        return 4;
    case '5':
        return 5;
    case '6':
        return 6;
    case '7':
        return 7;
    case '8':
        return 8;
    case '9':
        return 9;
    default:
        return 0;
    }
}
int main()
{
    int n, l;
    cin >> n >> l;
    vector<string> vec(n);
    rep(i, n)
    {
        cin >> vec[i];
    }
    sort(vec.begin(), vec.end());
    rep(i, n)
    {
        cout << vec[i];
    }
    cout << endl;
}

Measured memory_bytes: 256
n, d, a = map(int, input().split())
lst = []
for i in range(n):
    xi, hi = map(int, input().split())
    if hi % a == 0:
        hi = hi // a
    else:
        hi = hi // a + 1
    lst.append([xi, hi])
lst.sort(key=lambda x: x[0])
x, h = [], []
for i in range(n):
    x.append(lst[i][0])
    h.append(lst[i][1])

x.append(10**11)
h.append(0)

# 攻撃に巻き込めるインデックスを求める
left = 0 # 可能
right = n # 不可能
while left+1 < right:
    mid = (left + right) // 2
    if x[mid] - x[0] <= 2*d:
        left = mid
    else:
        right = mid
makikomi = [left]
right = left
for i in range(1, n):
    while x[right] - x[i] <= 2*d:
        right += 1
    right -= 1
    makikomi.append(right)

cnt = [0 for i in range(n)]
left = 0
already = 0
for i in range(n):
    while x[makikomi[left]] < x[i]:
        already -= cnt[left]
        left += 1
    cnt[i] = max(h[i] - already, 0)
    already += cnt[i]

print(sum(cnt))

Measured memory_bytes: 110040
#include<stdio.h>

#define MAX 101

int max(int a,int b,int c)
{
	int M;
	M=a;
	if(M < b) M=b;
	if(M < c) M=c;
	return M;
}

int main(void)
{
	int i,j,N,W,v[MAX],w[MAX],dp[MAX][10001];
	
	scanf("%d%d",&N,&W);
	v[0]=0;
	w[0]=0;
	for(i=1;i<=N;i++)
	{
		scanf("%d%d",&v[i],&w[i]);
	}
	for(i=0;i<=W;i++)
	{
		dp[0][i]=0;
	}
	for(i=1;i<=N;i++)
	{
		for(j=0;j<=W;j++)
		{
			if(w[i]<=j)
			{
				dp[i][j]=max(dp[i-1][j],dp[i-1][j-w[i]]+v[i],dp[i][j-w[i]]+v[i]);
			}
			else
			{
				dp[i][j]=dp[i-1][j];
			}
		}
	}
	printf("%d\n",dp[N][W]);
	return 0;
}

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

int main() {
	char S[4];
	string T;
	int a = 0;
	int A = 0;
	int b = 0;
	int B = 0;
	int c = 0;
	int C = 0;
	int q, w, z;
	int n = 0;
	int x = 0;
	int y = 0;
	int ans = 0;
	cin >> a >> b >> c;
	ans = 3;
	if (a == b&&a==c) {
		ans = 1;;
	}
	else {
		if (a == b) {
			ans--;
		}
		if (a == c) {
			ans--;
		}
		if (b == c) {
			ans--;
		}
	}

	cout << ans;
}

Measured memory_bytes: 256
#include <iostream>
#include<algorithm>
#include<vector> //動的配列
#include<string> 
#include <list> //双方向リスト
#include <map> //連想配列
#include <set> //集合
#include <stack>
#include <queue>
#include <deque>
#include <cmath>
#include <bitset>



//小さい順から取り出すヒープ
//priority_queue<ll, vector<ll>, greater<ll> > pque1;

typedef long long ll;


using namespace std;

typedef pair<int, int> P;

template <class T>ostream &operator<<(ostream &o,const vector<T>&v)
{o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}

ll a,b;
int la[40],lb[40];

int main(){
    cin>>a>>b;
    ll dif=a-1;
    ll cnt=1;
    if (b%4==1 || b%4==2) lb[0]=1;
    if (dif%4==1 || dif%4==2) la[0]=1;
    for (int i=1;i<40;i++){
        cnt*=2;
        if  ( b%(cnt*2)>=cnt && (b%(cnt*2))%2==0) lb[i]=1;
        if (dif%(cnt*2)>=cnt && (dif% (cnt*2))%2==0) la[i]=1;
    }
    cnt=1;
    ll ans=0;
    for (int i=0;i<40;i++){
        //cout<<la[i]<<lb[i]<<endl;
       if (la[i]!=lb[i]) ans+=cnt;
       cnt*=2;
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 256