akhauriyash/Code-Regression huggingface dataset:
from collections import Counter
import math
import statistics
import itertools
a=int(input())
# b=input()
# c=[]
# for i in a:
#     c.append(int(i))
# A,B,C= map(int,input().split())
# f = list(map(int,input().split()))
# g = [input() for _ in range(a)]
h = []
for i in range(a):
    h.append(list(map(int,input().split())))
# a = [[0] for _ in range(H)]#nizigen
ans=0
count=0
for i in range(len(h)):
    if sum(h[i])==h[i][0]*2:
        count+=1
    else:
        ans=max(ans,count)
        count=0

if count>=3:
    ans=max(ans,count)

if ans>=3:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 10944
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int64_t i = 0; i < (int64_t)(n); i++)
using vi = vector<int64_t>;
using vvi = vector<vi>;
int64_t INF = 1000000007;

int main() {
    // fasten cin
    cin.tie(0);
    ios::sync_with_stdio(false);
    // implement
    int64_t n,k;
    cin >> n >> k;
    vector<pair<int64_t, int64_t>> p(n);
    int64_t a,b;
    rep(i,n){
        cin >> a >> b;
        p.at(i) = make_pair(a,b);
    }
    sort(p.begin(), p.end());
    int64_t sum = 0;
    int64_t res = 0;
    rep(i,n){
        sum += p.at(i).second;
        if(sum>=k){
            res = p.at(i).first;
            break;
        }
    }
    cout << res << endl;
}

Measured memory_bytes: 1792
#include <stdio.h>
#include <math.h>
#include <string.h>
#include <algorithm>
#include <iostream>
#include <string>
#include <time.h>
#define sf scanf
#define pf printf
#define lf double
#define ll long long
#define p123 printf("123\n");
#define pn printf("\n");
#define pk printf(" ");
#define p(n) printf("%d",n);
#define pln(n) printf("%d\n",n);
#define s(n) scanf("%d",&n);
#define ss(n) scanf("%s",n);
#define ps(n) printf("%s",n);
#define sld(n) scanf("%lld",&n);
#define pld(n) printf("%lld",n);
#define slf(n) scanf("%lf",&n);
#define plf(n) printf("%lf",n);
#define sc(n) scanf("%c",&n);
#define pc(n) printf("%c",n);
#define gc getchar();
#define re(n,a) memset(n,a,sizeof(n));
#define len(a) strlen(a)
#define LL long long
using namespace std;
int main() {
    int n = 0;
    s(n);
    int x,y;
    if(n == 1){
        puts("Hello World");
    }else if(n >= 2){
        s(x) s(y)
        p(x+y) pn
    }
    
    return 0;

}

Measured memory_bytes: 256
import sys
import networkx as nx

input = sys.stdin.buffer.readline

MAX = 10 ** 15
N, M, S, T = map(int, input().split())

G = nx.Graph()
G.add_nodes_from(range(1, N + 1))
for _ in range(M):
    u, v, a, b = map(int, input().split())
    G.add_edge(u, v, yen=a, snuuk=b)

yen_path = nx.single_source_dijkstra_path_length(G, S, weight='yen')
snuuk_path = nx.single_source_dijkstra_path_length(G, T, weight='snuuk')

ans = [MAX] * (N + 1)
for i in range(N, 0, -1):
    ans[i - 1] = min(ans[i], yen_path[i] + snuuk_path[i])
for x in ans[:N]:
    print(MAX - x)


Measured memory_bytes: 184524
package main

import (
	"fmt"
	"strconv"
)

func main() {

	var a []int
	var n int
	count := 0

	fmt.Scan(&n)

	a = make([]int, n)
	for i := 0; i < n; i++ {
		fmt.Scan(&a[i])
	}

	for {
		var flag int

		for k, v := range a {
			if v%2 != 0 {
				flag = 1
				break
			}
			a[k] = v / 2
		}
		if flag == 1 {
			break
		}
		count++
	}

	fmt.Println(strconv.Itoa(count))
}


Measured memory_bytes: 512
#include<cstdio>
#include<cstring>
#include<iostream>
#include<cmath>
#include<algorithm>
using namespace std;
typedef int ll;
const ll maxn=100;
double sum=0.0;
double cnt=1;
ll a[maxn]={0};
ll vis[maxn]={0};
ll pos[maxn][2]={0};
double distance(ll x1,ll y1,ll x2,ll y2){
	return sqrt( ( (x1-x2)*(x1-x2) )+((y1-y2)*(y1-y2) ));
} 
void solve(ll n,ll ct){
		if(ct==n+1){
			for(ll i=1;i<n;i++){
				sum+=distance(pos[a[i]][0],pos[a[i]][1],pos[a[i+1]][0],pos[a[i+1]][1])/cnt;
			}
			return;
		}
		else{
			for(ll i=1;i<=n;i++){
				if(vis[i]==0){
					a[ct]=i;
					vis[i]=1;
					solve(n,ct+1);	
					vis[i]=0;
				}
			}	
	
		}
}
int main(){

	ios::sync_with_stdio(false);
	ll n;
	cin>>n;
	for(int i=1;i<=n;i++)
		cnt*=i;	
	for(ll i=1;i<=n;i++)
		cin>>pos[i][0]>>pos[i][1];
	solve(n,1);
	//cout<<sum<<endl;
	//cout<<cnt<<endl;
	printf("%.10lf\n",sum);
	
	
	
	return 0;
}


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

int main() {
  int a,b,c;
  cin >> a >> b >>c;
  if(a>=b && a>=c)cout<<b*c*0.5<<endl;
  else if(b>=a && b>=c)cout<<a*c*0.5<<endl;
  else if(c>=a && c>=b)cout<<b*a*0.5<<endl;
  }


Measured memory_bytes: 256
/*
░░░░░░░░░░░░░░░░▄▄█▀▀██▄▄░░░░░░░
░░░░░░░░░░░░░▄█▀▀░░░░░░░▀█░░░░░░
░░░░░░░░░░░▄▀░░░░░░░░░░░░░█░░░░░
░░░░░░░░░▄█░░░░░░░░░░░░░░░█░░░░░
░░░░░░░██▀░░░░░░░▄▄▄░░▄░█▄█▄░░░░
░░░░░▄▀░░░░░░░░░░████░█▄██░▀▄░░░
░░░░█▀░░░░░░░░▄▄██▀░░█████░██░░░
░░░█▀░░░░░░░░░▀█░▀█▀█▀▀▄██▄█▀░░░
░░░██░░░░░░░░░░█░░█░█░░▀▀▄█▀░░░░
░░░░█░░░░░█░░░▀█░░░░▄░░░░░▄█░░░░
░░░░▀█░░░░███▄░█░░░░░░▄▄▄▄█▀█▄░░
░░░░░▀██░░█▄▀▀██░░░░░░░░▄▄█░░▀▄░
░░░░░░▀▀█▄░▀▄▄░▄░░░░░░░███▀░░▄██
░░░░░░░░░▀▀▀███▀█▄░░░░░█▀░▀░░░▀█
░░░░░░░░░░░░▄▀░░░▀█▄░░░░░▄▄░░▄█▀
░░░▄▄▄▀▀▀▀▀█▀░░░░░█▄▀▄▄▄▄▄▄█▀▀░░
░▄█░░░▄██▀░░░░░░░░░█▄░░░░░░░░░░░
█▀▀░▄█░░░░░░░░░░░░░░▀▀█▄░░░░░░░░
█░░░█░░░░░░░░░░░░░░░░░░█▄░░░░░░░
*/
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define dbg(x) cout << #x << '=' << x << '\n';
#define ll long long
#define x first
#define y second
#define pi pair <int, int>
#define vi vector <int>
//#define =1e9 =(int)1e9
const ll mod = 1000000007;
const ll nmax=3000001;
#define int ll
int n, a[404], s[404];
int dp[404][404];

int32_t main(){
    ios_base::sync_with_stdio(0); cin.tie(); cout.tie();
    cin>>n;
    for(int i=1; i<=n; i++) cin>>a[i], s[i]=s[i-1]+a[i];
    for(int i=1; i<=n; i++) dp[i][i]=0;
    for(int d=1; d<=n-1; d++)
        for(int i=1; i+d<=n; i++){{
            dp[i][i+d]=1e18;
            for(int k=i; k<i+d; k++) dp[i][i+d]=min(dp[i][i+d], dp[i][k]+dp[k+1][i+d]+s[i+d]-s[i-1]);
        }
    }
    cout<<dp[1][n];
}


Measured memory_bytes: 1536
import math
a, b, hour, mini = map(int, input().split())
if (hour == 12): 
    hour = 0
if (mini == 60): 
    mini = 0
h = 0.5 * (hour * 60 + mini) 
m = 6 * mini 
angle = abs(h - m)
angle = min(360 - angle, angle)
angle = (angle * (math.pi) / 180)

c = a*a + b*b - (2*a*b*math.cos(angle))
print(math.sqrt(c))

Measured memory_bytes: 9528
#include<stdio.h>
#include<stdlib.h>
#include<stdint.h>
#include<inttypes.h>

typedef int32_t i32;
typedef int64_t i64;

const i32 mod = 1000000007;

i32 comb (i32 n, i32 k) {
  if (!(0 <= k && k <= n)) return 0;
  i32 a = 1;
  i32 b = 1;
  for (i32 i = 1; i <= k; ++i) {
    a = (i64) a * (n + 1 - i) % mod;
    b = (i64) b * i % mod;
  }
  while (b > 1) {
    a = (i64) a * (mod - mod / b) % mod;
    b = mod % b;
  }
  return a;
}

void run (void) {
  i32 n, k;
  scanf ("%" SCNi32 "%" SCNi32, &n, &k);
  i32 ans = comb (n - k + k - 1, k - 1);
  printf ("%" PRIi32 "\n", ans);
}

int main (void) {
  run ();
  return 0;
}


Measured memory_bytes: 2148
# 基本的に重複がない
# n+1Ck − (n+1)-(r-l+1)Ck−1

MOD = 10**9+7
U = 10**5 + 1

def power_mod(a,n):
  if n == 0:
    return 1
  x = (power_mod(a,n//2)**2)%MOD
  return x if n%2 == 0 else (a*x)%MOD

def make_fact(fact,fact_inv):
  for i in range(1,U+1):
    fact[i] = (fact[i-1]*i)%MOD
  fact_inv[U] = power_mod(fact[U],MOD-2)
  for i in range(U,0,-1):
    fact_inv[i-1] = (fact_inv[i]*i)%MOD

def comb(n,k):
  if k < 0 or k > n:
    return 0
  x = fact[n]
  x *= fact_inv[k]
  x %= MOD
  x *= fact_inv[n-k]
  x %= MOD
  return x

fact = [1]*(U+1)
fact_inv = [1]*(U+1)
make_fact(fact,fact_inv)

# 重複の起きる場所の間隔だけが問題
n = int(input())
A = [int(x) for x in input().split()]

memo = dict()
d = 0
for i,x in enumerate(A):
  if x in memo:
    d = i - memo[x]
    break
  memo[x] = i

rest = n-d

for k in range(1,n+2):
  ans = comb(n+1,k) - comb(rest,k-1)
  ans %= MOD
  print(ans)


Measured memory_bytes: 28640
#include<bits/stdc++.h>
using namespace std;
#define fastIO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define ll long long int
#define fi first
#define pb push_back
#define all(v) (v).begin(), (v).end()
#define rep(i, l, r) for(int i=(int)(l);i<(int)(r);i++)
#define repd(i, l, r) for (int i=(int)(l);i>=(int)(r);i--)
const int MAX = 1000001; 
  
// array to store prime factors 
int factor[MAX] = { 0 }; 
  
// function to generate all prime factors 
// of numbers from 1 to 10^6 
void generatePrimeFactors() 
{ 
    factor[1] = 1; 
  
    // Initializes all the positions with their value. 
    for (int i = 2; i < MAX; i++) 
        factor[i] = i; 
  
    // Initializes all multiples of 2 with 2 
    for (int i = 4; i < MAX; i += 2) 
        factor[i] = 2; 
  
    // A modified version of Sieve of Eratosthenes to 
    // store the smallest prime factor that divides 
    // every number. 
    for (int i = 3; i * i < MAX; i++) { 
        // check if it has no prime factor. 
        if (factor[i] == i) { 
            // Initializes of j starting from i*i 
            for (int j = i * i; j < MAX; j += i) { 
                // if it has no prime factor before, then 
                // stores the smallest prime divisor 
                if (factor[j] == j) 
                    factor[j] = i; 
            } 
        } 
    } 
}  
int calculateNoOFactors(int n) 
{ 
    if (n == 1) 
        return 1; 
  
    int ans = 1; 
  
    // stores the smallest prime number 
    // that divides n 
    int dup = factor[n]; 
  
    // stores the count of number of times 
    // a prime number divides n. 
    int c = 1; 
  
    // reduces to the next number after prime 
    // factorization of n 
    int j = n / factor[n]; 
  
    // false when prime factorization is done 
    while (j != 1) { 
        // if the same prime number is dividing n, 
        // then we increase the count 
        if (factor[j] == dup) 
            c += 1; 
  
        /* if its a new prime factor that is factorizing n,  
           then we again set c=1 and change dup to the new  
           prime factor, and apply the formula explained  
           above. */
        else { 
            dup = factor[j]; 
            ans = ans * (c + 1); 
            c = 1; 
        } 
   
        j = j / factor[j]; 
    } 
   
    ans = ans * (c + 1); 
  
    return ans; 
} 

int32_t main() 
{
    #ifndef ONLINE_JUDGE
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif
	fastIO;
	ll t,n,i,j,a,c,d,k,q,l,r,x,y;
	//cin>>t;
	t=1;
	while(t--)
	{
		generatePrimeFactors(); 
		cin>>n;
		ll cnt=0;
		for(i=1;i<n;i++)
		{
			ll num=n-i;
			cnt+=calculateNoOFactors(num);
		}
		cout<<cnt;
	}
	
	return 0;
}

Measured memory_bytes: 7552
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<string>
#include<cmath>
#include<map>
#include<queue>
#include<set>
#include<vector>
#include<cstdio>

using namespace std;
/*
int find(int x, vector<int> &p) {
if (p[x] == x)return x;
return p[x] = find(p[x], p);
}

void uni(int x, int y, vector<int> &p) {
x = find(x, p);
y = find(y, p);
p[x] = y;
}

int same(int x, int y, vector<int> p) {
if (find(x, p) == find(y, p))return 1;
return 0;
}
*/

//long long a[1002];


int main()
{
	long long N, K, cnt = 0, tmp, ans = 0;
	cin >> N >> K;

	if (N >= 2*K -1) {
		cout << "YES";
	}
	else {
		cout << "NO";
	}



	char qq;
	cin >> qq;
	return 0;
}

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

int main(void){
    int N, M, sum_T=0;
    std::cin >> N;
    std::vector<int> T(N);
    for (int i=0; i<N; ++i){
        std::cin >> T.at(i);
        sum_T += T.at(i);
    }

    std::cin >> M;

    for (int i=0; i<M; ++i){
        int p, x;
        std::cin >> p >> x;
        std::cout << sum_T - T.at(p - 1) + x << std::endl;
    }

    return 0;
}


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

int64_t dp[60][2000010];
int main() {
	const int64_t INF = 1e18 / 3;
	int64_t n, k; cin >> n >> k;
	int a[n]; for(int i = 0; i < n; ++i) cin >> a[i];
	int pre[200010]; for(int i = 0; i < 200010; ++i) pre[i] = -1;
	// dp[j][i] := iから2^j回遷移したときの消費回数
	for(int i = 0; i < 2 * n; ++i) {
		if(pre[a[i % n]] != -1) {
			dp[0][pre[a[i % n]]] = (i + 1) - pre[a[i % n]];
		}
		pre[a[i % n]] = i;
	}
	for(int j = 1; j < 60; ++j) {
		for(int i = 0; i < n; ++i) {
			dp[j][i] = min(dp[j - 1][i] + dp[j - 1][(i + dp[j - 1][i]) % n], INF);
		}
	}
	int64_t goal = n * k;
	int64_t now = 0;
	while(true) {
		bool flg = true;
		for(int j = 59; j >= 0; --j) {
			if(dp[j][now % n] == INF) continue;
			if(now + dp[j][now % n] < goal) {
				now += dp[j][now % n];
				flg = false;
				break;
			}
		}
		if(flg) break;
	}
	deque<int> ans;
	bool used[200010] = {};
	cerr << now % n << endl;
	for(int i = now % n; i < n; ++i) {
		if(used[a[i]]) {
			while(ans.size()) {
				int t = ans.back();
				ans.pop_back();
				used[t] = false;
				if(t == a[i]) break;
			}
		} else {
			ans.push_back(a[i]);
			used[a[i]] = true;
		}
	}
	for(int i : ans) {
		cout << i << " ";
	}
	cout << "\n";
	return 0;
}

Measured memory_bytes: 221184
#include<bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i, n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
template<class T> istream& operator >> (istream& s, vector<T>& v)
{ for (T& x: v) { s >> x; } return s;}
void yes(){ cout << "Yes" << endl; }
void no(){ cout << "No" << endl; }
int SIZE(string s){ return (int)s.size(); }

int main(){
    cout << setprecision(16);
    int n; cin >> n;
    vector<int> a(n);
    rep(i,n) cin >> a[i];
    ll x = 0, y = 0;
    sort(a.rbegin(), a.rend());
    rep(i,n-1){
        if(a[i] == a[i+1]){
            if(x == 0){
                x = a[i];
                i++;
            } else {
                y = a[i];
                i++;
                break;
            }
        }
    }
    cout << x*y << endl;
    return 0;
}


Measured memory_bytes: 640
import sys

input = sys.stdin.readline
n = int(input())
b_list = list(map(int, input().split()))
ans_list = []
for i in range(n):
    flag = 0
    tmp = 0
    for j in range(n-i):
        if j == b_list[j]-1:
            tmp = j
            flag = 1
    if flag == 0:
        ans_list.append(-1)
        break
    else:
        num = b_list.pop(tmp)
        ans_list.append(num)
if ans_list[-1] == -1:
    print(-1)
else:
    for a in ans_list[::-1]:
        print(a)


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

int main(){
    int n;
    cin >> n ;
    int a[22], b[22], c[22];
    rep(i, n){
        int t;
        cin >> t;
        a[i] = t-1;}
    rep(i, n){
        int t;
        cin >> t;
        b[i] = t;}
    rep(i, n-1){
        int t;
        cin >> t;
        c[i] = t;}
    int ans = 0;

    rep(i, n){
        ans += b[a[i]];
        // cout << b[a[i]] << endl;
        if(i!=n-1&&a[i]-a[i+1]==-1) ans += c[a[i]];
    }

    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define el "\n"
#define rep(i, a, n) for(int i=a; i<n; ++i)

int main() {
    int l, r, d;
    cin >> l >> r >> d;
    int ans = 0;
    rep(i, l, r+1) {
        if (i % d == 0)
            ans ++;
    }
    cout << ans << el;

    return 0;
}



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

#define INF 1e18

using ll = long long;

int p[5010],c[5010];

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

    int n,k;cin>>n>>k;
    for(int i=0;i<n;i++){cin>>p[i];p[i]--;}
    for(int i=0;i<n;i++)cin>>c[i];

    ll ans=-INF;
    for(int i=0;i<n;i++)
    {
        int pos=i;
        vector<ll> sum;
        sum.push_back(0);
        for(;;)
        {
            pos=p[pos];
            sum.push_back(sum[sum.size()-1]+c[pos]);
            if(pos==i)break;
        }

        int cnt=sum.size()-1;

        ll score=0;
        int ik=min(k,cnt);
        if(sum[cnt]>0)
        {
            score+=((k-1)/cnt)*sum[cnt];
            ik=(k-1)%cnt+1;
        }

        ll smax=-INF;
        for(int j=1;j<=ik;j++)smax=max(smax,sum[j]);
        score+=smax;

        ans=max(ans,score);
    }

    cout<<ans<<"\n";

    return 0;
}


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

const double EPS = 1e-10;
const double PI = acos(-1.0);

int sign(double x) {  //???????????°???????°???????????¢?
    return abs(x) < EPS ? 0 : x < 0 ? -1 : 1;
}

struct Point { //????????????
    double x, y;
    Point(double x=0.0, double y=0.0) : x(x), y(y) {}
    Point operator + (const Point &rhs) const {  //????????????
        return Point(x + rhs.x, y + rhs.y);
    }
    Point operator - (const Point &rhs) const {  //????????????
        return Point(x - rhs.x, y - rhs.y);
    }
    Point operator * (double p) const {  //???????????\??????
        return Point(x * p, y * p);
    }
    Point operator / (double p) const {  //???????????\??????
        return Point(x / p, y / p);
    }
    bool operator < (const Point &rhs) const {  //??????????????????
        return x < rhs.x || (x == rhs.x && y < rhs.y);
    }
    bool operator == (const Point &rhs) const {  //??????????????????
        return sign(x - rhs.x) == 0 && sign(y - rhs.y) == 0;
    }
    void read() {
        scanf("%lf%lf", &x, &y);
    }
    void print() {
        printf("(%.2f, %.2f)\n", x, y);
    }
};
typedef Point Vector;  //???????????????

double dot(Vector A, Vector B) {  //??????????§???????????????????????§??????????????§??????????????????????????????????????§????
    return A.x * B.x + A.y * B.y;
}
double cross(Vector A, Vector B) {  //??????????§??????????????????????????§???¢???????????¢?§????????????????????????????????????????
    return A.x * B.y - A.y * B.x;
}
double polar_angle(Vector A) {  //??????????§?
    return atan2(A.y, A.x);
}
double length(Vector A) {  //???????????????????§?
    return sqrt(dot(A, A));
}
double angle(Vector A, Vector B) {  //????????¬?§?????????¶??????????§?
    return acos(dot(A, B)/length(A)/length(B));
}
Vector rotate(Vector A, double rad) {  //???????????¬????????¶???
    return Vector(A.x*cos(rad)-A.y*sin(rad), A.x*sin(rad)+A.y*cos(rad));
    //????????´?????¬????????¶????????????????????¢??¬??????x'=xcos(theta)+ysin(theta), y'=ycos(theta)-xsin(theta)
}
Vector normal(Vector A) {  //?????????????????????????????????A????????¶??????
    double len = length(A);
    return Vector(-A.y/len, A.x/len);
}

Point point_line_proj(Point p, Point a, Point b) {  //?????¨??´??????????????±????????????
    Vector V = b - a;
    return a + V * (dot (V, p-a)/dot(V, V));  //???p??°??´???ab????????±
}


int main() {
    Point p1, p2;
    p1.read();
    p2.read();
    int q; scanf("%d", &q);
    while(q --) {
        Point x; 
        x.read();
        Point ans = point_line_proj(x, p1, p2);
        printf("%.9f %.9f\n", ans.x, ans.y);
    }
}

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

int main()
{
  int n ,c=0,cnt=0;
  cin >> n ;
  int b[101]= {};
  for(int i=0;i<n;i++)
    {
      cin >> c;
      b[c]++;
    }
  sort(b ,b+101,greater<int>());

  for(int i=0;b[i]>0;i++)
    {
      cnt++;
    }
  cout << cnt  << endl;

  return 0;
}


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

#define rep(i,n) for(int i=0;i<n;i++)
#define pa pair<int,int>
#define F first
#define S second
#define maxlen 99999
#define mod 1e9+7
typedef long long ll;

int main()
{
    string s[3]={"Sunny","Cloudy","Rainy"};
    string t;
    cin>>t;
    for(int i=0;i<3;i++)
    {
        if(t[0]==s[i][0])
            cout<<s[(i+1)%3];
    }
    return 0;
}


Measured memory_bytes: 256
#pragma GCC target("avx2")
#pragma GCC optimize("03")
#pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>
using namespace std; typedef long double ld; typedef long long ll;
typedef unsigned long long ull;
#define endl "\n"
#define FOR(i,a,b) for(int i=(a);i<=(b);i++)
#define rep(i,n) for(int i=0;i<(n);i++)
#define PII pair<int, int>
#define PLL pair<ll, ll>
#define ALL(x) (x).begin(), (x).end()
constexpr int INF=1<<30; constexpr ll LINF=1LL<<60; constexpr ll mod=1e9+7; constexpr int NIL = -1;
template<class T>vector<T> vec(int len, T elem) { return vector<T>(len, elem); } // auto dp = vec(52, vec(103, vec(103, INF)));
template<class T>inline bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T>inline bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }
template<class T>inline int popcount(T a) {return __builtin_popcount(a);}
template<class T>inline T emod(T a, T p) { return (a%p + p) % p;}
//-------------------
int main() {
    cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(15);
    string s; cin >> s;
    ll sm = 0;
    for(auto c: s) {
        sm = (sm + (c - '0')) % 9; 
    }
    if(sm%9 == 0) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}


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

unsigned GetDigit(long long num){
    unsigned digit=0;
    while(num!=0){
        num /= 10;
        digit++;
    }
    return digit;
}
int GetFirst(unsigned num, long long first) {
  long long ans = 1;
  while ((num-1)> 0) {
    ans *= 10;
    num--;
  }
  first /= ans;
  return first;
}
int main(void) {
  int n; long long ans = 1;
  cin >> n;
  vector<long long> tmp(n);
  for (int i = 0; i < n; i++) {
    cin >> tmp.at(i);
      //if (ans > 1000000000000000000) {
        //ans = -1; break;
    }
  sort(tmp.begin(), tmp.end());
    if (tmp.at(0) == 0) ans = 0;
    else {
            reverse(tmp.begin(), tmp.end());
      for (int i = 0; i < n; i++) {
        int ans_ = GetDigit(ans);
        int tmp_ = GetDigit(tmp.at(i));
        int ans__ = GetFirst(ans_, ans);
        int tmp__ = GetFirst(tmp_, tmp.at(i));
        int first, sisuu;
        if (ans__ * tmp__ >= 10) {sisuu = (ans_-1+tmp_-1+1); first = (ans__*tmp__)/10; }
        else {sisuu = (ans_-1+tmp_-1); first = ans__*tmp__; }
        if (sisuu > 18 || (sisuu == 18 && first != 1)) {ans = -1; break;}
        ans *= tmp.at(i);
        if (ans > 1000000000000000000) { ans = -1; break;}
      }
    }

  cout << ans << endl;
}

Measured memory_bytes: 4020
using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;
using System.IO;
using System.Linq;
using System.Diagnostics;
using System.Globalization;
using static System.Console;
using static System.Math;


namespace abc95_a
{
    class Program
    {
        static void Main(string[] args)
        {
            string str = Console.ReadLine();
            int count=0;
            if(str.Substring(0,1) == "o") count++;
            if(str.Substring(1,1) == "o") count++;
            if(str.Substring(2,1) == "o") count++;
            int sum = 700+count*100;
            WriteLine(sum);
        }
    }
}

Measured memory_bytes: 11220
import java.util.Scanner;

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

        String s = sc.next();
        String s1 = "";
        String s2 = "";

        for(int i = 0 ; i < s.length()  ; i++ ){
            char c = s.charAt(i);
            if( i % 2 == 0){
                s1 += c;
            }else{
                s2 += c;
            }
        }

        if(s1.contains("L")){
            System.out.println("No");
        }else if(s2.contains("R")){
            System.out.println("No");
        }else{
            System.out.println("Yes");
        }
    }
}


Measured memory_bytes: 21844
#include <iostream>
#include <map>
#include <string>
#include <vector>

using namespace std;

class Dice {
public:
    explicit Dice() {
        for (int i = 0; i < 6; ++i) {
            face[i] = i;
            f2i[i] = i;
        }
    }

    explicit Dice(int a[]) {
        for (int i = 0; i < 6; ++i) {
            face[i] = a[i];
            f2i[a[i]] = i;
        }
    }

    void rotate(char dir);
    void loop_swap(int a[]);

    bool same(const Dice& dice) const;

    static int rotate_itr[6][4];
    static map<char, int> c2i;
    map<char, int> f2i;
    int face[6];
};

/* ----- member funcs of Dice class ----- */

void Dice::rotate(char dir) {
    loop_swap(rotate_itr[c2i[dir]]);
}

int Dice::rotate_itr[6][4] = {
    {0, 1, 5, 4},  // N
    {0, 3, 5, 2},  // E
    {0, 2, 5, 3},  // W
    {0, 4, 5, 1},  // S
    {1, 2, 4, 3},  // L
    {1, 3, 4, 2},  // R
};

map<char, int> Dice::c2i = {{'N', 0}, {'E', 1}, {'W', 2}, {'S', 3}, {'L', 4}, {'R', 5}};

void Dice::loop_swap(int a[]) {
    int tmp = face[a[0]];
    for (int i = 0; i < 3; ++i) {
        face[a[i]] = face[a[i + 1]];
    }
    face[a[3]] = tmp;
}

bool Dice::same(const Dice& dice) const {
    for (int i = 0; i < 6; ++i) {
        if (face[i] != dice.face[i]) return false;
    }
    return true;
};

/* ----- main func ----- */

const string ope = "NRRRRNRRRRNRRRRNRRRRWRRRRWRRRRWRRRRWRRRRW";

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

    Dice dice[N];

    for (int i = 0; i < N; ++i) {
        int a[6];
        for (int j = 0; j < 6; ++j) {
            cin >> a[j];
        }
        Dice tmp(a);
        dice[i] = tmp;
    }

    for (int i = 0; i < N; ++i) {
        for (int j = i + 1; j < N; ++j) {
            for (char c : ope) {
                dice[j].rotate(c);

                if (dice[i].same(dice[j])) {
                    cout << "No" << endl;
                    return 0;
                }
            }
        }
    }

    cout << "Yes" << endl;
    return 0;
}



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

#define MAX(a,b) ((a)>(b)?(a):(b))
#define MIN(a,b) ((a)<(b)?(a):(b))
#define ABS(a) ((a)>(0)?(a):-(a))

void run(void){
  char *s=(char *)calloc(200000+1,sizeof(char));
  scanf("%s",s);
  int n=strlen(s);
  int *dp=(int *)calloc(1<<26,sizeof(int));
  int i;
  for(i=1;i<(1<<26);i++) dp[i]=n+1;
  dp[0]=0;
  int hash=0;
  for(i=1;i<=n;i++){
    hash^=1<<(s[i-1]-'a');
    int local=dp[hash]+1;
    int j;
    for(j=0;j<26;j++) local=MIN(local,dp[hash^(1<<j)]+1);
    dp[hash]=MIN(local,dp[hash]);
  }
  printf("%d\n",dp[hash]==0?1:dp[hash]);
}

int main(void){
  run();
  return 0;
}


Measured memory_bytes: 262656
using namespace std;
#include<bits/stdc++.h>
#define BEGIN ios_base::sync_with_stdio(0);cin.tie(0);
#define END return EXIT_SUCCESS;
#define FOR(I,A,B) for((I)=(A);(I)<(B);(I)++)
#define REP(I,N) FOR((I),0,(N))
#define UP(I,A,B) for((I)=(A);(I)<=(B);(I)++)
#define DW(I,A,B) for((I)=(A);(I)>=(B);(I)--)
#define IN(P) cin>>(P)
#define IN2(P1,P2) cin>>(P1)>>(P2)
#define IN3(P1,P2,P3) cin>>(P1)>>(P2)>>(P3)
#define INS(I,N,V) REP((I),(N)) cin>>(V[I])
#define INS2(I,N,V1,V2) REP((I),(N)) cin>>(V1[I])>>(V2[I]);
#define INS3(I,N,V1,V2,V3) REP((I),(N)) cin>>(V1[I])>>(V2[I])>>(V3[I]);
#define OUT(P) cout<<(P)<<endl
#define OUT2(P1,P2) cout<<(P1)<<" "<<(P2)<<endl
#define OUT3(P1,P2,P3) cout<<(P1)<<" "<<(P2)<<" "<<(P3)<<endl
#define OUTS(I,N,V) REP((I),(N)) cout<<(V[i])<<endl
#define ALL(C) (C).begin(),(C).end()
#define RALL(C) (C).rbegin(),(C).rend()
#define mp make_pair
#define pb push_back
#define lb lower_bound
#define ub upper_bound
template<class T>inline bool chmax(T& a,T b){if(a<b){a=b;return true;}return false;}
template<class T>inline bool chmin(T& a,T b){if(a>b){a=b;return true;}return false;}

string S;
inline void solve(){
  IN(S);
  S[3]='8';
  OUT(S);
}

int main(int argc,char**argv){
  BEGIN
  solve();
  END
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
//#include <ext/numeric>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
#define oo 0x3f3f3f3f
#define OO 0x3f3f3f3f3f3f3f3f
#define popcount(n) __builtin_popcount(n)
#define popcountll(n) __builtin_popcountll(n)

using namespace std;
//using namespace __gnu_cxx;
using namespace __gnu_pbds;
template<typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

const double PI = acos(-1.0), EPS = 1e-6;
const long long inf = 2e12 + 12;
const int MAXN = 100005, MAXM = 1003, Mod = 1000000007 , MAXLog = 20;

long long f(vector<int> &arr, int b) {
    long long ret = 0;
    for (int i = 0; i < arr.size(); ++i) {
        ret += abs(arr[i] - (b + i + 1));
    }
    return ret;
}

int main() {
#ifndef ONLINE_JUDGE
//    freopen("input.txt", "rt", stdin);
//    freopen("output.txt", "w", stdout);
#endif
    ios::sync_with_stdio(false), cin.tie(0), cout.tie(0), cout.precision(9), cout << fixed;

    int n, m;
    cin >> n >> m;
    vector<pair<int, int>> arr(m);
    for (int i = 0; i < m; ++i) {
        cin >> arr[i].second >> arr[i].first;
    }
    sort(arr.begin(), arr.end());
    int ans = 0;
    int mx = 0;
    for (int i = 0; i< m; ++i) {
        if (arr[i].second < mx)
            continue;
        mx = arr[i].first;
        ++ans;
    }
    cout << ans << '\n';


    return 0;
}

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

using namespace std;

int main(){
	ios::sync_with_stdio(false);
	long long int n , m, res;
	cin >> n >> m;
	if(n == 1 && m == 1) res = 1;
	else if(n == 1) res = m-2;
	else if(m == 1) res = n-2;
	else res = n*m - ((n*2 + m*2)) + 4;
	cout << res << endl;
}
		

Measured memory_bytes: 256
#include <iostream>
#include <cstring>

using namespace std;

int n;
int a[105];
long long memo[105][22];

long long solve(int i, int j) {
    long long result = 0;
    if (memo[i][j] != -1) {
        return memo[i][j];
    }
    if (i == 0) {
        result = j == a[0] ? 1 : 0;
    } else {
        if (j + a[i] <= 20) {
            result += solve(i - 1, j + a[i]);
        }
        if (j - a[i] >= 0) {
            result += solve(i - 1, j - a[i]);
        }
    }
    memo[i][j] = result;
    return result;
}

int main() {
    memset(memo, -1, sizeof(memo));
    cin >> n;
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }

    cout << solve(n - 2, a[n - 1]) << endl;
}

Measured memory_bytes: 3108
N, M = map(int, input().split())
shop = []
for i in range(N):
    shop.append(list(map(int, input().split())))

shop.sort()

total = 0
for i in range(len(shop)):
    if shop[i][1] == M:
        total += shop[i][0] * shop[i][1]
        break
    elif shop[i][1] > M:
        total += shop[i][0] * M
        break
    else:
        total += shop[i][0] * shop[i][1]
        M -= shop[i][1]
print(total)

Measured memory_bytes: 27760
import sys, bisect, math, itertools, string, queue, copy
# import numpy as np
# import scipy
from collections import Counter,defaultdict,deque
from itertools import permutations, combinations
from heapq import heappop, heappush
from fractions import gcd
# input = sys.stdin.readline
sys.setrecursionlimit(10**8)
mod = 10**9+7
def inp(): return int(input())
def inpm(): return map(int,input().split())
def inpl(): return list(map(int, input().split()))
def inpls(): return list(input().split())
def inplm(n): return list(int(input()) for _ in range(n))
def inplL(n): return [list(input()) for _ in range(n)]
def inplT(n): return [tuple(input()) for _ in range(n)]
def inpll(n): return [list(map(int, input().split())) for _ in range(n)]
def inplls(n): return sorted([list(map(int, input().split())) for _ in range(n)])

def main():
    k = inp()
    ans = 0
    for i in range(k):
        for j in range(k):
            for w in range(k):
                ans += math.gcd(math.gcd(i+1,j+1),w+1)
    print(ans)
    
if __name__ == "__main__":
    main()

Measured memory_bytes: 73224
#include <iostream>
#include <stdio.h>
#include <vector>

using namespace std;

int main(){

    double n, k, inp, total = 0, count_ = 0;
    vector<double> nums;

    cin >> n >> k;

    for(double i=0; i<n; i++){
        cin >> inp;
        nums.push_back(inp);
        total += inp;
    }

    for(double i=0; i<n; i++){

        if(nums[i] >= (total / (4 * k)))
            count_++;

        if(count_ == k)
            break;

    }

    if(count_ >= k)
        cout << "Yes";
    else
        cout << "No";
    


    return 0;

}

Measured memory_bytes: 256
import java.util.Scanner;

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

            int result = 1;

            int tmp = N;
            while (tmp / K > 0) {
                result++;
                tmp /= K;
            }

            System.out.println(result);

        }
    }

}

Measured memory_bytes: 23124
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <map>
#include <deque>
#include <set>
using namespace std;

#define REP(i,n) for(int i = 0; i < n; i++)
#define ALL(v) v.begin(),v.end()
typedef long long ll;
typedef pair<int,int> pi;
typedef pair<ll,ll> pll;
typedef pair<string,string> pss;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pi> vpi;
typedef vector<ll> vll;
typedef vector<vll> vvll;

double EPS = 1e-9;
int INFi = 1000000005;
long long INFll = 1000000000000000005ll;
double PI = acos(-1);
int dirx[8] = {-1,0,0,1,-1,-1,1,1};
int diry[8] = {0,1,-1,0,-1,1,-1,1};
ll MOD = 1000000007;

#define MAX_N 100000

int main(){
  string s;
  cin >> s;
  if( s == "zyxwvutsrqponmlkjihgfedcba"){
    cout << "-1" << endl;
    return 0;
  }
  if(s.size() == 26){
    REP(k,25){
      REP(i,k+1){
        if(s[24-k] < s[25 - i]){
          REP(j, 24 - k){
            cout << s[j];
          }
          cout << s[25 - i] << endl;
          return 0;
        }
      }
    }
  }else{
    bool alpha[26];
    REP(i,26)alpha[i] = false;
    REP(i,s.size()){
      alpha[s[i]-'a'] = true;
    }
    char c = 'a';
    REP(i,26){
      if(!alpha[i]){
        c += i;
        cout << s + c << endl;
        return 0;
      }
    }
  }

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define inf 1001001001
#define mod 1000000007
#define pi 3.141592653589793
ll gcd(ll a,ll b){
    if(b>a) swap(a,b);
    if(b==0) return a;
    return gcd(b,a%b);
}
ll lcm(ll a,ll b){
    ll g=gcd(a,b);
    return a/g*b;
}
ll rep_jijo(ll n,ll x){
    if(x==0) return 1;
    if(x%2==0){
        ll t=rep_jijo(n,x/2);
        return t*t%mod;
    }
    return n*rep_jijo(n,x-1)%mod;
}
ll com(ll n,ll r){
    ll x=1,y=1;
    ll tmp=n;
    while(tmp>=n-r+1){
        x=x*tmp%mod;
        tmp--;
    }
    while(r>0){
        y=y*r%mod;
        r--;
    }
    return x*rep_jijo(y,mod-2)%mod;
}

int main (){
    ll x;
    ll sum=0;
    ll i=1;
    cin >> x;
    while(true){
        sum+=i;
        if(sum>=x) break;
        i++;
    }
    cout << i << endl;

    return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int A1,A2,A3;
  cin >> A1 >> A2 >> A3;
  if(A1+A2+A3>=22){
    cout << "bust" << endl;
  }
  else{
      cout << "win" << endl;
    }
  
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text.RegularExpressions;
using Library;
using static Library.Input;

namespace AtCoderTemplate
{
    class ProgramA
    {
        static void Main()
        {
            int n = NextInt, k = NextInt;
            var s = Line.ToCharArray();
            s[k - 1] = s[k - 1].ToString().ToLower()[0];
            System.Console.WriteLine(string.Join("", s));
        }
    }
}

namespace Library
{
    class Input
    {
        static IEnumerator<string> enumerator = new string[] { }.AsEnumerable().GetEnumerator();

        public static string Line => Console.ReadLine();

        public static string[] StrArr => Line.Split(' ');

        public static int NextInt => int.Parse(NextWord());

        public static long NextLong => long.Parse(NextWord());

        public static List<int> IntList => StrArr.Select(int.Parse).ToList();

        public static List<long> LongList => StrArr.Select(long.Parse).ToList();

        public static IEnumerable<long[]> TakeLine(int N)
        {
            return Enumerable.Repeat(0, N).Select(_ => Console.ReadLine().Split(' ').Select(long.Parse).ToArray());
        }

        public static string NextWord()
        {
            while (!enumerator.MoveNext())
            {
                enumerator = StrArr.AsEnumerable().GetEnumerator();
            }
            return enumerator.Current;
        }
    }
}


Measured memory_bytes: 13524
// {{{ Boilerplate Code <--------------------------------------------------
// vim:filetype=cpp:foldmethod=marker:foldmarker={{{,}}}

#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <utility>
#include <vector>

#define FOR(I,A,B) for(int I = (A); I < (B); ++I)
#define ALL(A)     (A).begin(), (A).end()

using namespace std;

// }}}
int imos[1001][1001];
int imosx[1001][1001];
int happiness[1001][1001];

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

        FOR(i,0,K)FOR(j,0,K)imos[i][j]=0;

        FOR(i,0,N) {
                int x,y;
                char c;
                cin>>x>>y>>c;

                if(c=='W'){
                        x+=K;
                }

                x%=2*K;
                y%=2*K;

                if (x>=K){
                        x-=K;
                        y=(y+K)%(2*K);
                }

                if (y<K) {
                        imos[0][0]++;
                        imos[x][0]--;
                        imos[0][y]--;
                        imos[x][y]++;
                        imos[x][y]++;
                        //cerr<<"add "<<x<<" "<<y<<endl;
                }
                int finy=(y+K)%(2*K);
                if(finy<K){
                        //cerr<<"ADD "<<x<<" "<<finy<<endl;
                        imos[0][finy]++;
                        imos[x][finy]--;
                        imos[x][0]++;
                        imos[x][finy]--;
                }
        }

        FOR(i,0,K)FOR(j,0,K)imosx[i][j]=0;

        FOR(i,0,K) {
                FOR(j,0,K) {
                        //cerr<<imos[i][j]<<"  ";
                        int prev=(i==0)?0:imosx[i-1][j];
                        imosx[i][j]=prev+imos[i][j];
                }
                //cerr<<endl;
        }
                //cerr<<endl;


        FOR(i,0,K)FOR(j,0,K)happiness[i][j]=0;

        FOR(i,0,K) {
                FOR(j,0,K) {
                        int prev=(j==0)?0:happiness[i][j-1];
                        happiness[i][j]=prev+imosx[i][j];
                        //cerr<<imosx[i][j]<<"  ";
                }
                //cerr<<endl;
        }
                //cerr<<endl;

        int ret = 0;

        FOR(i,0,K) {
                FOR(j,0,K) {
                        //cerr<<happiness[i][j]<<"  ";
                        ret = max(ret, happiness[i][j]);
                        ret = max(ret, N - happiness[i][j]);
                }
                //cerr<<endl;
        }

        cout << ret << endl;
}


Measured memory_bytes: 12032
#include<iostream>
using namespace std;
  
typedef long long hyper;
  
hyper fib(int n)
{
    if(n < 2) return 1;
    if(n == 2) return 2;
    if(n == 3) return 3;
    return 3 * fib(n - 2) - fib(n - 4);
}
   
int main()
{
    int n;
    cin >> n;
    cout << fib(n) << endl;
    return 0;
}

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

#ifdef _DEBUG
#define debug(x) cerr << "line: " << __LINE__ << ", func: " << __func__ << " ->  " << #x << " = " << x << endl
#else
#define debug(x)
#endif

#define all(s) begin(s), end(s)
#define rall(s) rbegin(s), rend(s)
#define rep(i, a, b) for (int i = (a); i < (b); i++)
#define rrep(i, a, b) for (int i = ((a)-1); i >= (b); i--)
#define pb push_back
#define sz(a) int((a).size())
#define put(a) ((cout) << (a) << (endl))
#define putf(a, n) ((cout) << (fixed) << (setprecision(n)) << (a) << (endl))

using namespace std;

using ll = long long;
using ull = unsigned long long;
using i_i = pair<int, int>;
using ll_ll = pair<ll, ll>;
using d_ll = pair<double, ll>;
using ll_d = pair<ll, double>;
using d_d = pair<double, double>;

static constexpr ll LL_INF = 1LL << 60;
static constexpr int I_INF = 1 << 28;
static constexpr double PI = static_cast<double>(3.14159265358979323846264338327950288);
static constexpr double EPS = numeric_limits<double>::epsilon();

static map<type_index, const char* const> scanType = {
    {typeid(int), "%d"}, {typeid(ll), "%lld"}, {typeid(double), "%lf"}, {typeid(char), "%c"}};

template <class T> static void scan(vector<T>& v);
[[maybe_unused]] static void scan(vector<string>& v, bool isWord = true);
template <class T> static inline bool chmax(T& a, T b);
template <class T> static inline bool chmin(T& a, T b);
template <class T> static inline T gcd(T a, T b);
template <class T> static inline T lcm(T a, T b);
template <class A, size_t N, class T> static void Fill(A (&arr)[N], const T& val);

int main(int argc, char* argv[]) {
  ll n;
  cin >> n;
  vector<ll> l(n);
  scan(l);
  sort(all(l));

  ll ans = 0;
  rep(i, 0, n - 1) rep(j, i + 1, n) {
    ll add = l[i] + l[j];
    ll sub = abs(l[i] - l[j]);

    int lower = upper_bound(all(l), sub) - begin(l);
    int upper = lower_bound(all(l), add) - begin(l);
    int count = upper - lower;

    if (lower <= i && i < upper) count--;
    if (lower <= j && j < upper) count--;
    ans += count;
  }

  put(ans / 3);
  return 0;
}

template <class T> static void scan(vector<T>& v) {
  auto tFormat = scanType[typeid(T)];
  for (T& n : v) {
    scanf(tFormat, &n);
  }
}

static void scan(vector<string>& v, bool isWord) {
  if (isWord) {
    for (auto& n : v) {
      cin >> n;
    }
    return;
  }

  int i = 0, size = v.size();
  string s;
  getline(cin, s);

  if (s.size() != 0) {
    i++;
    v[0] = s;
  }

  for (; i < size; ++i) {
    getline(cin, v[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;
}

template <class T> inline T gcd(T a, T b) { return __gcd(a, b); }

template <class T> inline T lcm(T a, T b) { return (a * b) / gcd(a, b); }

template <class A, size_t N, class T> void Fill(A (&arr)[N], const T& val) {
  std::fill((T*)arr, (T*)(arr + N), val);
}


Measured memory_bytes: 256
import java.util.*;
import static java.util.Arrays.*;
import static java.lang.Math.*;

public class Main {

	static Scanner sc = new Scanner(System.in);
	static int N, M;
	static int[] C = new int[300], V = new int[300], D = new int[300], L = new int[300];
	static boolean read() {
		if (!sc.hasNextInt()) return false;
		N = sc.nextInt();
		M = sc.nextInt();
		for (int i = 0; i < N; i++) {
			String str;
			do {
				str = sc.next();
			} while (!Character.isDigit(str.charAt(0)));
			C[i] = Integer.parseInt(str);
			V[i] = sc.nextInt();
			D[i] = sc.nextInt();	
			L[i] = sc.nextInt();
		}
		return true;
	}
	
	static int[][] dp_V = new int[301][301], dp_D = new int[301][301], dp_L = new int[301][301];
	static void solve() {
		for (int i = 0; i < N; i++) {
			fill(dp_V[i], 0);
			fill(dp_D[i], 0);
			fill(dp_L[i], 0);
		}
		
		for (int i = 1; i <= N; i++) {
			for (int j = 0; j <= M; j++) {
				if (j >= C[i - 1]) {
					dp_V[i][j] = max(dp_V[i - 1][j], dp_V[i][j - C[i - 1]] + V[i - 1]);
					dp_D[i][j] = max(dp_D[i - 1][j], dp_D[i][j - C[i - 1]] + D[i - 1]);
					dp_L[i][j] = max(dp_L[i - 1][j], dp_L[i][j - C[i - 1]] + L[i - 1]);
				} else {
					dp_V[i][j] = dp_V[i - 1][j];
					dp_D[i][j] = dp_D[i - 1][j];
					dp_L[i][j] = dp_L[i - 1][j];
				}
			}
		}
		
		System.out.println(max(dp_V[N][M], max(dp_D[N][M], dp_L[N][M])));
	}
	
	public static void main(String[] args) {
		while (read())
			solve();
	}
}

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

int main(){
  int n; cin>>n;
  vector<int> h(n);
  int max_h=0;
  rep(i,n){
    cin>>h[i];
    max_h=max(max_h,h[i]);
  }
  int cnt=0;
  for(int mark=1; mark<=max_h; mark++){
    bool renzoku=0;
    rep(i,n){
      if(!renzoku && h[i]>=mark)cnt++;
      if(h[i]<mark){
        renzoku=0;
      }
      else if(h[i]>=mark)renzoku=1;
    }
  }
  cout<<cnt<<endl;
}



Measured memory_bytes: 3612
def main():
    s = input()
    n = len(s)
    ans = 0
    for j in range(n):
        t = s
        cnt = 0
        for c in t:
            if c == s[j]:
                cnt += 1
        while len(t) != cnt:
            t2 = ''
            for i in range(len(t) - 1):
                t2 += (s[j] if s[j] == t[i] or s[j] == t[i + 1] else t[i])
            t = t2
            cnt = 0
            for c in t:
                if c == s[j]:
                    cnt += 1
        ans = max(ans, len(t))

    print(n - ans)



if __name__ == '__main__':
    main()


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

using namespace std;

int main(){
  int a[5],i,j,min,min_n;

  for(i=0;i<5;i++)
    scanf("%d",&a[i]);

  for(i=0;i<5;i++){
    min=a[i]; min_n=i;
    for(j=i+1;j<5;j++){
      if(min<a[j]){
        min=a[j]; min_n=j;
      }
    }
  swap(a[i],a[min_n]);
  printf( i<4 ? "%d " : "%d\n",a[i]);
  }
  return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
const int N = 100009;
int n,m;
vector<vector<int> > g;
bool vis[N];

void dfs(int u){
    vis[u] = true;
    for(int i=0;i<g[u].size();i++)
        if(!vis[g[u][i]])
            dfs(g[u][i]);
}
int main(){

    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    cin>>n>>m;
    g.resize(n);
    for(int a,b,i=0;i<m;i++){
        cin>>a>>b;
        a--;b--;
        g[a].push_back(b);
        g[b].push_back(a);
    }
    int ans = 0;
    for(int i=0;i<n;i++)
        if(!vis[i]){
            dfs(i);
            ans++;
        }

    cout<<ans-1<<endl;

    return 0;
}


Measured memory_bytes: 9708
#include <stdio.h>
#include <math.h>
#include <stdlib.h>
#include <iostream>
static const int NMAX=100000;
static const int QMAX=50000;
int A[NMAX+1];
int n;
int binarySearch(int key){
	int left=0;
	int right=n;
	int mid=0;
	// std::cout << "key = " << key << std::endl;
	// std::cout << "n = " << n << std::endl;
	
	while(left < right){
		mid = (left + right) / 2;
		// std::cout << "left = " << left << std::endl;
		// std::cout << "right = " << right << std::endl;
		// std::cout << "mid = " << mid << std::endl;
		if(key == A[mid]){
			return 1;
		}
		if(key < A[mid]){
			right = mid;
		}else if(key > A[mid]){
			left = mid+1;
		}
	}
	return 0;
}
int main(int argc, char const* argv[])
{
	
	// int i,j,k;
	int q;
	// int *S,*T;
	// int S[NMAX+1];
	// int T[QMAX+1];
	int T;
	int c=0;
	// S = (int*)malloc(sizeof(int)*n);
	// T = (int*)malloc(sizeof(int)*q);
	std::cin >> n;
	// std::cout << n << std::endl;
	for(int i = 0;i < n;i++) scanf("%d",&A[i]);
	// for(int i = 0;i < n;i++) std::cout << A[i] << std::endl;
	std::cin >> q;
	// std::cout << q << std::endl;
	for(int i = 0;i < q;i++){
		scanf("%d",&T);
		// std::cout << T << std::endl;
		if(binarySearch(T))c++;
	}
	std::cout << c << std::endl;
	return 0;
}

Measured memory_bytes: 3540
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> lpair;
const ll MOD = 1e9 + 7;
const ll INF = 1e18;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define rREP(i,m,n) for(ll i = (m); i >= (n); i--)
#define print(x) cout << (x) << endl;
#define printa(x,n) for(ll i = 0; i < n; i++){ cout << (x[i]) << " ";} cout<<endl;
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int n,k;
    cin >> n >> k;
    int ary[n];
    rep(i,n) cin >> ary[i];
    sort(ary, ary+n, greater<int>());

    int ret=0;
    rep(i,k) ret += ary[i];
    cout << ret << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<functional>
#include<cmath>
#include<string>
#include<vector>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<deque>
using namespace std;
#define ll long long
const int mod = 1000000007;
const ll INF = 1000000000000000000;

int main()
{
	int N, K;
	cin >> N >> K;
	int A[1100];
	for (int i = 0; i < N; i++) cin >> A[i];
	sort(A, A + N);
	int ans = 0;
	for (int i = 0; i < K; i++)ans += A[i];
	cout << ans << endl;
}

Measured memory_bytes: 3640
#include<iostream>
#include<vector>
#include<numeric>
#include<cmath>
#include<algorithm>
using namespace std;

int main() {
  string s;
  cin >> s;
  
  for (int i=0; i<s.size(); i++) {
    if (i % 2 == 0) cout << s.at(i);
  }
  cout << endl;
}

Measured memory_bytes: 512