akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;


/* macro */
#define rep(i,a,b) for(int i=a;i<b;i++)
#define revrep(i,a,b) for(int i = a; i > b; i--)
#define int long long
#define exist(s,e) ((s).find(e)!=(s).end())
#define all(v) (v).begin(), (v).end()
#define each(s,itr) for(auto (itr) = s.begin(); (itr) != s.end(); (itr)++)
#define sum(v) accumulate(all(v), (0LL))


/* alias */
typedef vector<int> vi;
typedef pair<int, int> pi;


/* constant */
const int inf = 100100100100100100;
const int mod = 1e9;
int dx[8]={1,0,-1,0,-1,1,-1,1};
int dy[8]={0,1,0,-1,-1,-1,1,1};


/* io_method */
int input(){int tmp;cin >> tmp;return tmp;}
string raw_input(){string tmp;cin >> tmp;return tmp;}
string readline(){string s;getline(cin, s);return s;}
template<class T> void printx(T n){cout << n;}
template<class T, class U> void printx(pair<T, U> p){cout << "(" << p.first << "," << p.second << ")";}
template<class T> void printx(vector<T> v){cout << "{";rep(i,0,v.size()){printx(v[i]);if(i != v.size()-1)printx(",");}cout << "}";}
template<class T> void print(T n){printx(n);cout << endl;}
template<class T> void print(set<T> s){cout << "{";each(s, e){if(e != s.begin()) printx(",");printx(*e);}cout << "}" << endl;}
template<class T, class U> void print(map<T, U> mp){cout << "{";each(mp, e){cout << "(" << e -> first << "," << e -> second << ")";}cout << "}" << endl;}


/* general_method */
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
vector<int> cs(vector<int> arr){vector<int> tmp;if(arr.size() == 0) return tmp;tmp.push_back(arr[0]);rep(i,1,arr.size()){tmp.push_back(tmp.back() + arr[i]);}return tmp;}



/* main */



signed main(){

    cin.tie(0);
    ios::sync_with_stdio(false);


    int n, k; cin >> n >> k;

    vi arr; rep(i,0,n) arr.push_back(input());

    map<int, int> mp;

    for(auto e : arr){
        mp[e]++;
    }

    vector<pi> tmp;
    each(mp, itr){
        tmp.push_back(make_pair(itr -> second, itr -> first));
    }

    

    sort(all(tmp));

    int ans = 0;

    if(tmp.size() <= k){
        print(ans);
        return 0;
    }
    
    rep(i,0,tmp.size() - k){
        ans += tmp[i].first;
    }

    print(ans);
    













}






    










    




    










Measured memory_bytes: 18928
#include <iostream>
#include <string>
#include <map>
#include <vector>
#include <utility>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <numeric>

#define rep(i,j,k) for(int i=(int)j;i<(int)k;i++)
#define itrep(i,x) for(auto i=(x).begin(); i!=(x).end();i++)
#define Sort(x) sort((x).begin(),(x).end())
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define vec vector
#define INF (int)1e9
#define INFL 1e18
#define MOD 1000000007
#define pb push_back
#define MP make_pair
#define PI 3.1415926535
#define fcout cout<<fixed<<setprecision(10)
typedef long long int ll;
typedef std::pair<int,int> P;
int D=1;
int dx[4]={0,1,0,-1},dy[4]={-1,0,1,0};
int day[12]={31,28,31,30,31,30,31,31,30,31,30,31};
//template<typename T>void pp(T x){cout<<x<<endl;}

using namespace std;
template<typename T> void test(vector<T> v){for(int i=0;i<v.size();i++){if(i)cout<<" ";cout<<v[i];}cout<<endl;}

int main(){
    int n;
    while(cin>>n&&n){
        vector<int> t,h,count(2*n,0);
        rep(i,0,n){
            int x; cin>>x;
            count[x-1]=1;
        }
        rep(i,0,2*n){
            if(count[i])t.pb(i+1);
            else h.pb(i+1);
        }
        //test(t);
        //test(h);
        
        Sort(t); Sort(h);
        int ba=0;
        for(int i=0; !t.empty() && !h.empty() ; i++){
            if(i%2==0){ //taro
                if(ba==0){
                    ba=t[0];
                    t.erase(t.begin());
                }else {
                    auto it=upper_bound(all(t),ba);
                    if(it==t.end())ba=0;
                    else {
                        ba=*it;
                        t.erase(it);
                    }
                }
            }else { //hanako
                if(ba==0){
                    ba=h[0];
                    h.erase(h.begin());
                }else {
                    auto it=upper_bound(all(h),ba);
                    if(it==h.end())ba=0;
                    else {
                        ba=*it;
                        h.erase(it);
                    }
                }
            }
            //cout<<"ba: "<<i<<" "<<ba<<endl;
        }
        
        cout<<h.size()<<endl<<t.size()<<endl;
    }


    

    
    return 0;
}


Measured memory_bytes: 3020
#include <iostream>
#define REP(i, n) for (int i = 0; i < (n); i++)
using namespace std;


void solve(long long A, long long B, long long C, long long D){
    if (A + B > C + D) cout << "Left" << '\n';
    else if (A + B < C + D) cout << "Right" << '\n';
    else cout << "Balanced" << '\n';
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    long long A;
    scanf("%lld",&A);
    long long B;
    scanf("%lld",&B);
    long long C;
    scanf("%lld",&C);
    long long D;
    scanf("%lld",&D);
    solve(A, B, C, D);
    return 0;
}


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

using namespace std;

#define MOD (int)(1e9+7)
#define INF 1e9

#define rep(i,n) for(int i=0;i<n;i++)
#define repx(i,x,n) for(int i=x;i<n;i++)
#define repr(i,n) for(int i=n;i>=0;i--)
#define all(a) a.begin(),a.end()

typedef long long ll;

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

	string S; cin >> S;
	string T = S.substr(0, 4);
	if (T == "YAKI")cout << "Yes" << endl;
	else cout << "No" << endl;

    return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <set>
#include <vector>
#include <cstring>
#include <climits>
#include <queue>
#include <map>
#include <sstream>
using namespace std;

#define REP(i,a,n) for(int i=(a); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define EPS 1e-9

class team{
public:
	int I,U,A,P;
	team(int a, int b, int c, int d){
		I=a, U=b, A=c, P=d;
	}
	bool operator<(const team& a)const{
		if( A>a.A ) return true;
		if( A<a.A ) return false;
		if( P<a.P ) return true;
		if( P>a.P ) return false;
		return I<a.I;
	}
};

int main(){
	int n;
	while(scanf("%d",&n),n){
		vector<team> v;
		map<int,int> m;
		rep(i,n){
			int a,b,c,d; scanf("%d%d%d%d",&a,&b,&c,&d);
			v.push_back( team(a,b,c,d) );
		}
		sort( v.begin(), v.end() );
		
		int cnt = 0;
		rep(i,v.size()){
			if( cnt<10 ){
				if( m[v[i].U]<3 ){
					printf("%d\n",v[i].I);
					m[v[i].U]++;
					cnt++;
				}
			}else if( cnt<20 ){
				if( m[v[i].U]<2 ){
					printf("%d\n",v[i].I);
					m[v[i].U]++;
					cnt++;
				}
			}else if( cnt<26 ){
				if( m[v[i].U]==0 ){
					printf("%d\n",v[i].I);
					m[v[i].U]++;
					cnt++;
				}
			}
		}
	}
	return 0;
}

Measured memory_bytes: 0
#include <iostream>

int main()
{
    int display = 1;
    int N , K;
    std::cin >> N;
    std::cin >> K;
    for(int i = 0;i < N;i++){
        if(display*2 <= display+K){
            display *= 2;
        }else{
            display += K;
        }
    }
    std::cout << display << std::endl;
    return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000


int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N; cin >> N;
    int A[100010];
    int odd = 0;
    int even = 0;
    rep(i, N) {
        cin >> A[i];
        if(A[i] % 2 == 1) odd++;
        else even++;
    }
    if(odd % 2 == 1) {
        cout << "NO" << endl;
        return 0;
    } else {
        cout << "YES" << endl;
    }



    return 0;
}


Measured memory_bytes: 640
#include<iostream>
#include<cstdio>
#include<vector>
#include<string>
#include<cstring>
#include<functional>
#include<stack>
#include<queue>
#include <iomanip>
#include<map>
#include<limits>
#include<cmath>
#include<algorithm>
#include<bitset>
#include<utility>
#include<complex>
#include<cstdlib>
#include<set>
#include<cctype>

#define DBG cerr << '!' << endl;
#define REP(i,n) for(ll (i) = (0);(i) < (n);++i)
#define rep(i,s,g) for(ll (i) = (s);(i) < (g);++i)
#define rrep(i,s,g) for(ll (i) = (s);i >= (g);--(i))
#define PB push_back
#define MP make_pair
#define FI first
#define SE second
#define SHOW1d(v,n) {for(int W = 0;W < (n);W++)cerr << v[W] << ' ';cerr << endl << endl;}
#define SHOW2d(v,i,j) {for(int aaa = 0;aaa < i;aaa++){for(int bbb = 0;bbb < j;bbb++)cerr << v[aaa][bbb] << ' ';cerr << endl;}cerr << endl;}
#define ALL(v) v.begin(),v.end()
#define Decimal fixed<<setprecision(10)

using namespace std;

typedef long long ll;
typedef vector<int> iv;
typedef vector<iv> iiv;
typedef vector<string> sv;

int ch[30];
int couch[30];
vector<vector<int> > v(30);

#define BITN 262144
int bi[BITN+1];

int sum(int a)
{
	int s = 0;
	while(a > 0)
	{
		s += bi[a];
		a -= a & -a;
	}
	return s;
}

void add(int a,int x)
{
	while(a <= BITN)
	{
		bi[a] += x;
		a += a & -a;
	}
}


int main()
{
	string str;cin >> str;
	
	REP(i,str.size())
	{
		ch[str[i] - 'a']++;
	}
	
	int odd = 0;char oddch;
	REP(i,26)
	{
		if(ch[i] % 2 == 1)
		{
			odd++;
			oddch = i+'a';
		}
	}
	
	if(odd > 1)
	{
		cout << -1 << endl;
		return 0;
	}
	
	string tar = "";
	stack<char> s;
	int cou = 0;
	
	REP(i,str.size())
	{
		if(couch[str[i]-'a'] < (ch[str[i]-'a']/2))
		{
			tar += str[i];
			couch[str[i]-'a']++;
			v[str[i]-'a'].PB(cou);
			s.push(str[i]);
			cou++;
		}
	}
	
	if(odd == 1)
	{
		tar += oddch;
		
		v[oddch-'a'].PB(cou);
		cou++;
	}
	
	while(!s.empty())
	{
		char now = s.top();s.pop();
		tar += now;
		v[now-'a'].PB(cou);
		cou++;
	}
	
	//cout << tar << endl;
	
	REP(i,26)couch[i] = 0;
	
	/*
	REP(i,26)
	{
		SHOW1d(v[i],v[i].size());
	}
	*/
	
	vector<int> lis;
	REP(i,str.size())
	{
		lis.PB(v[str[i]-'a'][couch[str[i]-'a']]+1);
		couch[str[i]-'a']++;
	}
	
	//SHOW1d(lis,lis.size());
	
	ll ret = 0;
	
	REP(i,lis.size())
	{
		ret += i - sum(lis[i]);
		add(lis[i],1);
	}
	
	cout << ret << endl;
	
	
	
	return 0;
}

Measured memory_bytes: 4216
#include <bits/stdc++.h>
using namespace std;
using vi=vector<int>;
using vvi=vector<vi>;
using vs=vector<string>;
using msi=map<string,int>;
using mii=map<int,int>;
using pii=pair<int,int>;
using vlai=valarray<int>;
using ll=long long;
#define rep(i,n) for(int i=0;i<n;i++)
#define range(i,s,n) for(int i=s;i<n;i++)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define fs first
#define sc second
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define INF 1e9
#define EPS 1e-9
 
using vd=vector<double>;
using vvd=vector<vd>;
 
 
int main(){
    int h,w;
    cin>>h>>w;
    vvi f(h+2,vi(w+2,1));
    vvi walk(h+2,vi(w+2,0));
    int gy,gx,y=0,x=0,v=0;
    range(i,1,h+1)range(j,1,w+1){
        char c;
        cin>>c;
        switch(c){
            case 'G': gy=i,gx=j,f[i][j]=0; break;
            case '.': f[i][j]=0;break;
            case '#': break;
            case '^': y=i,x=j,v=0,f[i][j]=0; break;
            case '>': y=i,x=j,v=1,f[i][j]=0; break;
            case 'v': y=i,x=j,v=2,f[i][j]=0; break;
            case '<': y=i,x=j,v=3,f[i][j]=0; break;
        }
    }
    walk[y][x]=1;
    rep(loop,2750){
        vvi vec={{-1,0},{0,1},{1,0},{0,-1}};
        if(f[y+vec[(v+1)%4][0]][x+vec[(v+1)%4][1]]==0){ //右手が道なら右に曲がって前に進む
            //cout<<"hoge";
            v=(v+1)%4;
            y+=vec[v][0], x+=vec[v][1];
            walk[y][x]=1;
        }else if(f[y+vec[v][0]][x+vec[v][1]]==1){ //（右が壁で、）正面が壁なら左に回る
            //cout<<"fuga";
            v=(v+3)%4;
        }else{ //そうでないならまえに進む
            //cout<<"zako";
            y+=vec[v][0],x+=vec[v][1];
            walk[y][x]=1;
        }
        if(y==gy&&x==gx){
            break;
        }
        // cout<<y<<","<<x<<","<<v<<endl;
        // rep(i,h+2){
        //     rep(j,w+2){
        //         if(i==y&&j==x){
        //             cout<<"^>v<"[v];
        //         }else{
        //             cout<<".#"[f[i][j]];
        //         }
        //     }
        //     cout<<endl;
        // }
    }
    if(y==gy&&x==gx){
        int ans=0;
        rep(i,h+2)rep(j,w+2)ans+=walk[i][j];
        cout<<ans<<endl;
    }else cout<<-1<<endl;
    return 0;
}


Measured memory_bytes: 3192
// By Debajit Chakraborty
#include<bits/stdc++.h>
using namespace std;
 
#define SPEED ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define MP make_pair
#define pb push_back
#define ff first
#define ss second
#define sz(x) x.size()
#define all(c) c.begin(),c.end()
#define int long long
#define fr(i,j,x) for(int i=j;i<x;i++)
#define rep(i,j,x) for(int i=j;i<=x;i++)
#define rev(i,j,x) for(int i=j;i>=x;i--)
#define mem(x,val) memset(x,val,sizeof(x))
#define endl '\n'
#define vi vector<int>
#define pii pair<int,int>
 
const int mod=1e9+7;
const int MAX=5e5+10;
const int INF=1e8;

struct Query 
{ 
    int l, r, idx; 
}; 
  
// cmp function to sort queries according to r 
bool cmp(Query x, Query y) 
{ 
    return x.r < y.r; 
} 
  
// updating the bit array 
void update(int idx, int val, int bit[], int n) 
{ 
    for (; idx <= n; idx += idx&-idx) 
        bit[idx] += val; 
} 
  
// querying the bit array 
int query(int idx, int bit[], int n) 
{ 
    int sum = 0; 
    for (; idx>0; idx-=idx&-idx) 
        sum += bit[idx]; 
    return sum; 
} 
  
    #ifndef ONLINE_JUDGE
        freopen("inputf.in", "r", stdin);
        //freopen("outputf.in", "w", stdout);
    #endif
void answeringQueries(int arr[], int n, Query queries[], int q) 
{ 
    // initializing bit array 
    int bit[n+1]; 
    memset(bit, 0, sizeof(bit)); 
  
    // holds the rightmost index of any number 
    // as numbers of a[i] are less than or equal to 10^6 
    int last_visit[MAX]; 
    memset(last_visit, -1, sizeof(last_visit)); 
  
    // answer for each query 
    int ans[q]; 
    int query_counter = 0; 
    for (int i=0; i<n; i++) 
    { 
        // If last visit is not -1 update -1 at the 
        // idx equal to last_visit[arr[i]] 
        if (last_visit[arr[i]] !=-1) 
            update (last_visit[arr[i]] + 1, -1, bit, n); 
  
        // Setting last_visit[arr[i]] as i and updating 
        // the bit array accordingly 
        last_visit[arr[i]] = i; 
        update(i + 1, 1, bit, n); 
  
        // If i is equal to r of any query  store answer 
        // for that query in ans[] 
        while (query_counter < q && queries[query_counter].r == i) 
        { 
            ans[queries[query_counter].idx] = 
                     query(queries[query_counter].r + 1, bit, n)- 
                     query(queries[query_counter].l, bit, n); 
            query_counter++; 
        } 
    } 
  
    // print answer for each query 
    for (int i=0; i<q; i++) 
        cout << ans[i] << endl; 
} 

void solve(){
    int n,q,l,r;
    cin>>n>>q;
    int a[n];
    rep(i,0,n-1){
        cin>>a[i];
    }
    Query queries[q+1];
    for(int i=0;i<q;i++){
        cin>>l>>r;
        queries[i].idx=i;
        queries[i].l=l-1;
        queries[i].r=r-1;
    }
    sort(queries,queries+q,cmp);
    answeringQueries(a,n,queries,q);
}


int32_t main()
{
    SPEED;
    int T=1;
    //cin>>T;
    int t1=1;
    while(true)
    {  
        //cout<<"Case #"<<t1<<": ";
        //cout<<endl;
        solve();
        t1++;
        if(t1>T)
            break;
    }
}   


Measured memory_bytes: 31088
import java.util.Scanner;
import java.util.TreeSet;

public class Main{
	static boolean ip(long x) {
		if(x == 1) return false;
		for(long i = 2; i * i <= x; i++) if(x % i == 0) return false;
		return true;
	}
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		long A = sc.nextLong(), B = sc.nextLong();
		long max = Math.max(A, B), min = Math.min(A, B);
		long ans = 0;

		TreeSet<Long> divisor = new TreeSet<Long>();
		for(long i = 1; i * i <= max; i++) {
			if(max % i == 0) {
				if(i * i == max) divisor.add(i);
				else {
					divisor.add(i);
					divisor.add(max / i);
				}
			}
		}

		for(long a : divisor) {
			if(a == 1 || (min % a == 0) && ip(a)) ans++;
		}

		System.out.println(ans);
	}
}

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

int main() {
  int N;
  cin >> N;
  string s;
  cin >> s;
  
  int count = 0;
  for (int i = 0; i < N; i++) {
    if (s[i] == 'R') {
      count++;
      if (count > N/2) {
        cout << "Yes" << endl;
        return 0;
      }
    }
  }
  
  cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
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; }
typedef long long int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define MOD (1000000007)
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1}; // 移動方向

int h, w, a, b;

void input(){
    cin >> h >> w >> a >> b;
}

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    input();
    int cnt1 = (h / a) * (w / b);
    int ans = h*w - (a*b*cnt1);
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3184
#include <bits/stdc++.h>
using namespace std;
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; }

#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
template<class T> ostream& operator << (ostream &s, set<T> P)
{ for(auto it : P) { s << "<" << it << "> "; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P)
{ for(auto it : P) { s << "<" << it.first << "->" << it.second << "> "; } return s << endl; }


int main() {
    long long N, M;
    cin >> N >> M;
    for (int i = 0; i < M; ++i) {
        long long A; cin >> A;
        N -= A;
    }
    cout << (N >= 0 ? N : -1) << endl;
}



Measured memory_bytes: 3604
#include<stdio.h>

int main()
{
 int N;
 int T;
 int c[105];
 int t[105];
 int i;
 int mincost=1005;

 scanf("%d %d",&N,&T);
 for(i=0;i<N;i++) 
 {
  scanf("%d %d",&c[i],&t[i]);
  if((c[i]<mincost)&(t[i]<=T)) mincost=c[i];
 }
 if(mincost==1005)
 {
  printf("TLE\n");
 }else{
  printf("%d\n",mincost);
 }
 return 0;
}


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

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  int n;
  cin >> n;
  int ma = -1e9;
  map<string, int> mp;
  for(int i = 0; i < n; i++) {
    string s;
    cin >> s;
    mp[s] += 1;
  }
  for(auto itr = mp.begin(); itr != mp.end(); itr++) {
    ma = max(ma, itr -> second);
  }
  for(auto itr = mp.begin(); itr != mp.end(); itr++) {
    if(itr -> second == ma) {
      cout << itr -> first << endl;
    }
  }
}
  

Measured memory_bytes: 23808
#include <bits/stdc++.h>
#define f first
#define s second
#define fore(i,a,b) for(int i = (a), ThxMK = (b); i < ThxMK; ++i)
#define pb push_back
#define all(s) begin(s), end(s)
#define _ ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define sz(s) int(s.size())
#define ENDL '\n'
using namespace std;
typedef long double ld;
typedef long long lli;
typedef pair<int,int> ii;
typedef vector<int> vi;
typedef vector<lli> vl;
typedef vector<ii> vii;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
#define deb(x) cout << #x": " << (x) << endl;

const int N = 2e4;
const lli INF = 1e18+10;
const lli MOD = 1e9+7;
const ld EPS = 1e-9;


// ---- コーディングはここから！ ('-')7




int main(){_
	int k; cin>>k; string s; cin>>s;
	if(sz(s)<=k)cout<<s<<ENDL;
	else{
		string a=""; fore(i,0,k)a+=s[i];
		cout<<a;
		cout<<"..."<<ENDL;
	}

}


Measured memory_bytes: 3624
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <assert.h>
#include <complex>
#include <utility>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <tuple>
#include <cmath>
#include <bitset>
#include <cctype>
#include <set>
#include <map>
#include <unordered_map>
#include <numeric>
#include <functional>
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(ll i=ll(a);i<ll(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define rrep(i,a) for(ll i=ll(a-1);i>=0;--i)
#define all(x) (x).begin(),(x).end()
#define PRINT(V) cout << V << "\n"
#define SORT(V) sort((V).begin(),(V).end())
#define RSORT(V) sort((V).rbegin(), (V).rend())
using namespace std;
using ll = long long;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
inline void Yes(bool condition){ if(condition) PRINT("Yes"); else PRINT("No"); }
template<class itr> void cins(itr first,itr last){
    for (auto i = first;i != last;i++){
        cin >> (*i);
    }
}
template<class itr> void array_output(itr start,itr goal){
    string ans = "",k = " ";
    for (auto i = start;i != goal;i++) ans += to_string(*i)+k;
    if (!ans.empty()) ans.pop_back();
    PRINT(ans);
}
ll gcd(ll a, ll b) {
    return a ? gcd(b%a,a) : b;
}

const ll INF = 1e10;
const ll MOD = 1000000007;
const ll MOD2 = 998244353;
const ll EPS = 1e-10;
int sgn(const double a){
    return (a < -EPS ? -1 : (a > EPS ? +1 : 0));
}
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> tri;
typedef pair<double,double> point;
typedef complex<double> Point;
const ll MAX = 30000;
constexpr ll nx[8] = {1,0,-1,0,1,-1,1,-1};
constexpr ll ny[8] = {0,1,0,-1,1,1,-1,-1};
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n;
    cin >> n;
    vector<ll> x(n);
    cins(all(x));
    ll ans = INF;
    rep(i,0,101){
        ll cnt = 0;
        rep(j,n){
            cnt += (x[j]-i)*(x[j]-i);
        }
        chmin(ans,cnt);
    }
    PRINT(ans);
}



Measured memory_bytes: 3624
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main()
{
    vector<int> A;
    int n;
    cin >> n;
    for (int i = 0; i < n; i++)
    {
        int a;
        cin >> a;
        A.push_back(a);
    }
    int q;
    cin >> q;
    for (int i = 0; i < q; i++)
    {
        int b, e, k;
        cin >> b >> e >> k;
        cout << count(A.begin() + b, A.begin() + e, k) << endl;
    }
}


Measured memory_bytes: 3152
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
#define rep(i,n) for(int i=0;i<(n);i++)
ll kaijou(ll n)
{
    if(n==1) return 1;
    else return n*kaijou(n-1);
}

int main()
{
    ll n;
    double ans=0;
    cin>>n;
    vector<double> x(n),y(n);
    vector<ll> data(n);
    rep(i,n) cin>>x[i]>>y[i];
    rep(i,n) data[i]=i;
    auto solve=[&](int a,int b)
    {
        double xdef=x[a]-x[b];
        double ydef=y[a]-y[b];
        return sqrt(xdef*xdef+ydef*ydef);
    };
    do{
        rep(i,n-1)
        {
            ans+=solve(data[i],data[i+1]);
        }
    }while(next_permutation(data.begin(),data.end()));
    ans/=kaijou(n);
    printf("%.10f",ans);
}

Measured memory_bytes: 3816
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
template<class T> using vt = vector<T>;
template<class T> using vvt = vector<vt<T>>;
template<class T> using ttt = tuple<T,T>;
using tii = tuple<int,int>;
using vi = vector<int>;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define pb push_back
#define mt make_tuple
#define ALL(a) (a).begin(),(a).end()
#define FST first
#define SEC second
#define DEB cerr<<"!"<<endl
#define SHOW(a,b) cerr<<(a)<<" "<<(b)<<endl
#define DIV int(1e9+7)
const int INF = (INT_MAX/2);
const ll LLINF = (LLONG_MAX/2);
const double eps = 1e-8;
//const double PI = M_PI;
inline ll pow(ll x,ll n,ll m){ll r=1;while(n>0){if((n&1)==1)r=r*x%m;x=x*x%m;n>>=1;}return r%m;}
inline ll lcm(ll d1, ll d2){return d1 / __gcd(d1, d2) * d2;}
#define chmax(a,b) a=max(a,b)

/*Coding Space*/
int main(){
  string in; cin >> in;
  rep(i,in.size()){
    if(in[i] == in[i+1]){
      cout << "Bad" << endl;
      return 0;
    }
  }
  cout << "Good" << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define fastIO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define int long long int
#define fi first
#define se second
#define pub push_back
#define mkp make_pair
#define pi pair<int,int>
#define push push
#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--)
#define clrg(i, l, r) for(int i=(int)(l);i<(int)(n);i++)vis[i]=0,v[i].clear();
int power(int x, unsigned int y){int res = 1;while (y > 0){ if (y & 1){res = res*x;} y = y>>1;x = x*x;}return res;}
int gcd(int a, int b){if (b == 0)return a; return gcd(b, a % b);}
int powermod(int x, unsigned int y, int p){int res = 1;x = x % p;while (y > 0){if (y & 1){res = (res*x) % p;}y = y>>1; x = (x*x) % p;}return res;}
#define print2d(mat,n,m){for(int i=0;i<(int)(n);i++){for(int j=0;j<(m);j++){cout<<mat[i][j]<<" ";}cout<< endl;}}
#define print1d(mat,n){for(int i=0;i<(int)(n);i++)cout<<mat[i]<<" ";cout<<endl;}
#define clr(a,x) memset(a,x,sizeof(a))
#define rr(v) for(auto &val:v)
#define mpt(m)  for(auto it=m.begin();it!=m.end();it++)
#define print(v) for (const auto itr : v){cout<<itr<<' ';}cout<<endl;
#define init(v,x) for (auto &itr:v){itr=x;}
#define ln length()
#define sz size()
#define inf 1e18;
#define mod 1000000007
#define elif else if
int32_t main(){
   int a,b;
   cin>>a>>b;
   cout<<a*b<<"\n";
    return 0;
}

Measured memory_bytes: 3632
import java.util.Scanner;

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

	int n;

	do
	    {
		n = In.nextInt();
	    }while(n <= 2 && n >= 200000);

	int []a = new int[n];

	for(int i = 0; i < n; i++)
	    {
		do	    
		    {
			a[i] = In.nextInt();
		    }while(1 >= a[i] && a[i] >= Math.pow(10,9));
	    }

	int minv = a[0];
	int maxv = a[1] - a[0];

	for(int j = 1; j <= n-1; j++)
	    {
		maxv = maxv > (a[j] - minv) ? maxv : (a[j] - minv);
		minv = minv < a[j] ? minv : a[j];
	    }
	System.out.println(maxv);
    }
}

Measured memory_bytes: 101536
#include <iostream>
#include <vector>
#include <string>
#define FIN freopen("inputs.txt", "r", stdin)
using namespace std;
typedef pair<int, int> P;
int m ,  n;
int main(){
//FIN;
    cin>>n>>m;
    if(m>=n) cout<<"Yes\n";
    else  cout<<"No\n";
    return 0;
}

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

int main(){

    long long n, x; cin >> n >> x;
    vector<long long> a(n);
    long long sum = 0LL;
    for(int i = 0; i < n; i++){
        cin >> a[i];
        sum += a[i];
    }

    if(sum == x){
        cout << n << endl;
        return 0;
    }

    sort(a.begin(), a.end());
    long long ans = 0LL;
    for(int i = 0; i < n; i++){
        if(x >= a[i]){
            ans++;
            x -= a[i];
        }else{
            break;
        }
    }

    cout << min(ans, n - 1) << endl;

    return 0;    
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define pi pair<int, int>
#define pll pair<ll, ll>
#define pb push_back
#define mod 1000000007
// #define mod 998244353
using namespace std;

int main()
{
	ios::sync_with_stdio(false);
	ll a;
	cin >> a;
	string s;
	cin >> s;
	ll b = (s[0] - '0') * 100 + (s[2] - '0') * 10 + (s[3] - '0');
	a *= b;
	cout << a / 100 << endl;
	return 0;
}

Measured memory_bytes: 3576
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, s, e) for (int i = (int)(s); i <= (int)(e); i++)
#define printYesNo(is_ok) puts(is_ok ? "Yes" : "No");
#define SORT(v) sort(v.begin(), v.end());
#define RSORT(v) sort(v.rbegin(), v.rend());
#define REVERSE(v) reverse(v.begin(), v.end());

template <typename T>
void printlnVector(T v)
{
  rep(i, v.size())
  {
    cout << v[i] << endl;
  }
}

template <typename T>
void printVector(T v)
{
  rep(i, v.size())
  {
    cout << v[i] << " ";
  }
  cout << endl;
}

int main()
{
  int N;
  string S;
  cin >> N >> S;
  vector<int> alphabet_count(26, 0);
  long long mod = 1e9 + 7;
  long long ans = 0;
  rep(i, S.size())
  {
    long long temp = 1;
    rep(j, 26)
    {
      int c = S[i] - 'a';
      if (alphabet_count[j] == 0 || c == j)
        continue;
      temp *= alphabet_count[j] + 1;
      temp %= mod;
    }
    ans += temp;
    ans %= mod;
    alphabet_count[S[i] - 'a']++;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 512
#include <cstdio>
#include <queue>
#include <iostream>
#include <bits/stdc++.h>
#include<stdio.h>
#include<string.h>
#include<fstream>

#define F first
#define S second
#define R cin>>
#define Z class
#define ll long long
#define ln cout<<'\n'
#define in(a) insert(a)
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define all(c) (c).begin(),(c).end()
#define iter(c) __typeof((c).begin())
#define rrep(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define rep(i,n) REP(i,0,n)
#define tr(it,c) for(iter(c) it=(c).begin();it!=(c).end();it++)
using namespace std;

int main() {
    cin.tie(0);
   	ios::sync_with_stdio(false);
       
    ll i,j,k,x,y,z,p,q;
    ll n,m,tmp;
    string s[200000];
    string str;
    ll sum=0;
    ll strr[200005];
    cin>>i>>j>>k>>x;
    if(i!=k) cout<<1<<endl;
    else cout<<0<<endl;


    return 0;
}

Measured memory_bytes: 1920
#include <stdio.h>
#define REP(i, n) for(i = 0; i < n; ++i)
#define FOR(i, a, b) for(i = a; i < b; ++i)
#define BORDER 400

int cnt = 0;

typedef struct{
    char node[8];
}list;

void search(int nownode, list visited, int N, char matrix[N][N]){
    int i;
    char finish = 1;

    REP(i, N){
        if(visited.node[i] != 1){
            finish = 0;
            break;
        }
    }

    if(finish){
        cnt++;
        return;
    }

    REP(i, N){
        if(matrix[nownode][i] && visited.node[i] != 1){
            visited.node[i] = 1;
            search(i, visited, N, matrix);
            visited.node[i] = 0;
        }
    }
    return;
}

int main(){
    int i, j;
    int a, b;
    int N = 0, M = 0;

    scanf("%d %d", &N, &M);
    char matrix[N][N];
    list visited;

    REP(i, N){
        visited.node[i] = (i == 0 ? 1 : 0);
        REP(j, N){
            matrix[i][j] = (i == j)? 1 : 0;
        }

    }

    REP(i, M){
        scanf("%d %d", &a, &b);
        matrix[a - 1][b - 1] = 1;
        matrix[b - 1][a - 1] = 1;
    }
    search(0, visited, N, matrix);
    printf("%d\n", cnt);
    return 0;
}

Measured memory_bytes: 128
#include <cstdio>
#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <cstring>
#include <queue>
#include <stack>
#include <functional>
#include <set>
#include <map>
#include <deque>
#include <cmath>
#define WMAX 10000
#define HMAX 10000

//コメントアウトするとdebug()を実行しない
#define DEBUG

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 );
}

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

struct edge{
  int to,cost;
};

int A,B,C,N,W,H,ans,dp[HMAX][WMAX];
string S;
static const int dx[8] = {0,1,1,1,0,-1,-1,-1},
					dy[8] = {1,1,0,-1,-1,-1,0,1};

void solve(){
	if(A == B){
		cout << C << "\n";
	}else if(C == B){
		cout << A << "\n";
	}else{
		cout << B << "\n";
	}
}

void debug(){

}

void answer(){
	cout << ans << "\n";
}

int main(){
	cin >> A >> B >> C;
	solve();
	#ifdef DEBUG
	debug();
	#endif
	// answer();

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep2(i, a, n) for (int i = (a); i < (n); i++)
#define repb(i, n) for (int i = (n - 1); i >= 0; i--)
#define repb2(i, a, n) for (int i = (n - 1); i >= (a); i--)
#define all(x) x.begin(), x.end()
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
inline void fastio() { ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0); }

int main() {
    fastio();

    int N;
    cin >> N;

    int ans;
    cin >> ans;
    rep(i, N - 1) {
        int a;
        cin >> a;
        ans = __gcd(a, ans);
    }
    co(ans);
}

Measured memory_bytes: 256
package main

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

func main() {
	N := ReadInt()
	a := ReadInts(N)
	min, max := Min(a...), Max(a...)
	fmt.Println(max - min)
}

func Min(xs ...int) int {
	min := xs[0]
	for _, x := range xs[1:] {
		if min > x {
			min = x
		}
	}
	return min
}

func Max(xs ...int) int {
	max := xs[0]
	for _, x := range xs[1:] {
		if max < x {
			max = x
		}
	}
	return max
}

var reader = bufio.NewReader(os.Stdin)

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


Measured memory_bytes: 1844
#include<bits/stdc++.h>
using namespace std;
typedef pair<int,int>pii;
typedef long long ll;
typedef pair<ll,ll>pll;
typedef __int128 lll;
const ll mod=1e9+7;
const int mn=1e5+10;
unordered_map<ll,ll>dp;
ll a,b,c,d;
ll inf=0x3f3f3f3f3f3f3f3f;
ll solve(ll x){
    if(x==0)return 0;
    if(x==1)return d;
    auto it=dp.find(x);
    if(it!=dp.end())return it->second;
    ll ans=LLONG_MAX;
    if(LLONG_MAX/d>=x)ans=d*x;
    if(x%2==0)ans=min(ans,solve(x/2)+a);
    else ans=min(ans,min(solve(x/2)+a+d,solve(x/2+1)+a+d));
    int m=x%3;
    if(!m)ans=min(ans,solve(x/3)+b);
    else ans=min(ans,min(solve(x/3)+b+d*m,solve(x/3+1)+b+d*(3-m)));
    m=x%5;
    if(!m)ans=min(ans,solve(x/5)+c);
    else ans=min(ans,min(solve(x/5)+c+d*m,solve(x/5+1)+c+d*(5-m)));
    return dp[x]=ans;
}
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int tcc;
    cin>>tcc;
    while(tcc--){
        dp.clear();
        ll n;
        cin>>n>>a>>b>>c>>d;
        printf("%lld\n",solve(n));
    }
}

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


class Program {

	static long mod = 998244353;
	static int[] ans;
	static void Main(string[] args) {

		char[] cs = new char[] { ' ' };
		//char[] cs = new char[] { ' ', ',' };

		//int n = int.Parse(Console.ReadLine());
		//int val = int.Parse(Console.ReadLine());
		//int[] vals = parseAry(Console.ReadLine().Split(cs));
		//string str = Console.ReadLine();
		//string[] strs = Console.ReadLine().Split(cs);

		int res = 0;
		int n = int.Parse(Console.ReadLine());

		int[] vals = parseAry(Console.ReadLine().Split(cs));

		for ( int i = 0; i < n - 2; i++ ) {
			int mid = vals[i + 1];
			int[] nums = new int[3] { vals[i], vals[i+1],vals[i+2] };
			Array.Sort(nums);
			if ( nums[1] == mid ) { res++; }
		}


			Console.WriteLine(res);
				return;

	}



	//	文字列strをindex番目からdで上書き
	static string strOverWrite(string str, int i, string s) {
		return str.Remove(i, s.Length).Insert(i, s);
	}

	//　String[]  ----->  int[]
	static int[] parseAry(string[] str) {
		int[] nums = new int[str.Length];
		for ( int i = 0; i < str.Length; i++ ) { nums[i] = int.Parse(str[i]); }
		return nums;
	}
	//　String[]  ----->  long[]
	static long[] parseAryL(string[] str) {
		long[] nums = new long[str.Length];
		for ( int i = 0; i < str.Length; i++ ) { nums[i] = long.Parse(str[i]); }
		return nums;
	}

	//文字列を1文字ずつString[]に入れる
	static string[] strAry(String str) {
		string[] re = new string[str.Length];
		for ( int i = 0; i < str.Length; i++ ) { re[i] = str[i].ToString(); }
		return re;
	}


}

Measured memory_bytes: 11220
#include <bits/stdc++.h>
#define ll        long long
#define endl      "\n"
#define loop(n)   for(int i=0;i<n;i++)

using namespace std;
int main(){
    int n,dilam,ans;
    cin>>n;
    /*for(int i=1000; ;){
        i+=1000;
        if(i>=n){dilam=i;break;}
    }*/
    if(n%1000>0)cout<<1000-(n%1000)<<endl;
    else cout<<n%1000<<endl;
}

Measured memory_bytes: 3628
#include<bits/stdc++.h>
#define MAX 1000001
using namespace std;
int main () {
    ios_base::sync_with_stdio(false);
    bool fb[MAX] = {false};
    long long ans = 0;
    int N;
    cin>>N;
    ans = 0;
    for(int i=1;i*3<=N;i++) {
        fb[i*3] = true;
    }
    for(int i=1;i*5<=N;i++) {
        fb[i*5] = true;
    }
    for(int i=1;i<=N;i++) {
        if(!fb[i]) ans+=i;
    }
    cout<<ans<<"\n";
    return 0;
}

Measured memory_bytes: 4632
local n, m, q = io.read("*n", "*n", "*n")

local t = {}
for i = 1, n * n do t[i] = 0 end

for i = 1, m do
  local l, r = io.read("*n", "*n")
  local idx = (r - 1) * n + l
  t[idx] = t[idx] + 1
end

for l = 1, n do
  for r = 2, n do
    local src = (r - 2) * n + l
    local dst = (r - 1) * n + l
    t[dst] = t[dst] + t[src]
  end
end
for r = 1, n do
  for l = n - 1, 1, -1 do
    local src = (r - 1) * n + l + 1
    local dst = (r - 1) * n + l
    t[dst] = t[dst] + t[src]
  end
end

for i = 1, q do
  local a, b = io.read("*n", "*n")
  local idx = (b - 1) * n + a
  print(t[idx])
end


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

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

    int n, t;
    cin >> n >> t;

    vector<int> A(t + 1, 0);
    REP(i, n){
        int l, r;
        cin >> l >> r;
        A[l]++;
        A[r]--;
    }

    for(int i = 1; i <= t + 1; i++){
        A[i] += A[i - 1];
    }

    sort(A.begin(), A.end());

    cout << A[A.size() - 1] << endl;

    /*
    for(auto x : A){
        cout << x << "";
    }
    cout << endl;
    */

    return 0;
}


Measured memory_bytes: 3360
import os

import itertools
import sys

if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")

sys.setrecursionlimit(2147483647)
INF = float("inf")
IINF = 10 ** 18
MOD = 10 ** 9 + 7


def solve(H, W):
    C = [list(map(int, sys.stdin.readline().split())) for _ in range(H)]

    def ok(h, w):
        return 0 <= h < H and 0 <= w < W

    def dfs(h, w):
        C[h][w] = 0
        for dh, dw in itertools.product([-1, 0, 1], repeat=2):
            if ok(h + dh, w + dw) and C[h + dh][w + dw] == 1:
                dfs(h + dh, w + dw)

    ans = 0
    for i in range(H):
        for j in range(W):
            if C[i][j] == 1:
                dfs(i, j)
                ans += 1
    return ans


while True:
    W, H = list(map(int, sys.stdin.readline().split()))
    if W == H == 0:
        break
    print(solve(H, W))



Measured memory_bytes: 9212
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees#, log2, log
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left, insort, insort_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
from decimal import Decimal
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10**9 + 7
from decimal import *

N = INT()
L = LIST()

L.sort()

ans = 0
for i in range(N-2):
	a = L[i]
	for j in range(i+1, N-1):
		b = L[j]
		idx = bisect_left(L, a+b) - 1
		if j < idx:
			ans += idx - j

print(ans)


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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

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

#define DEBUG(x) cout<<#x<<": "<<x<<'\n'
#define DEBUG_VEC(v) cout<<#v<<":";REP(i, v.size())cout<<' '<<v[i];cout<<'\n'
#define ALL(a) (a).begin(), (a).end()

#define CHMIN(a, b) a=min((a), (b))
#define CHMAX(a, b) a=max((a), (b))

const ll MOD=1000000007ll;
// const ll MOD=998244353ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

const double EPS=1e-11;
#define EQ0(x) (abs((x))<EPS)
#define EQ(a, b) (abs((a)-(b))<EPS)

int num1[114514], num2[114514];

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n, v;
	cin>>n;
	REP(i, n){
		cin>>v;
		if(i&1){
			++num1[v];
		}
		else{
			++num2[v];
		}
	}
	int ma1=0, ma2=0, ma3=0, ma4=0, a, b;
	REP(i, 114514){
		if(ma1<num1[i]){
			a=i;
			ma3=ma1;
			ma1=num1[i];
		}
		else{
			ma3=max(ma3, num1[i]);
		}
		if(ma2<num2[i]){
			b=i;
			ma4=ma2;
			ma2=num2[i];
		}
		else{
			ma4=max(ma4, num2[i]);
		}
	}
	if(a!=b){
		cout<<n-ma1-ma2<<'\n';
	}
	else{
		cout<<min(n-ma1-ma4, n-ma3-ma2)<<'\n';
	}
	return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <stdio.h>
using namespace std;

int main(void)
{
	bool card[4][13] = { false }; //0 = S, 1 = H, 2 = C, 3 = D
	int num, n; char mark;

	cin >> n;
	for (int i = 0; i < n; i++)
	{
		cin >> mark >> num;
		switch (mark)
		{
		case 'S':
			card[0][num-1] = true;
			break;
		case 'H':
			card[1][num-1] = true;
			break;
		case 'C':
			card[2][num - 1] = true;
			break;
		case 'D':
			card[3][num - 1] = true;
			break;
		}
	}
	for (int i = 0; i < 4; i++)
	{
		for (int j = 0; j < 13; j++)
		{
			
			if (card[i][j] == false)
			{
				if (i == 0) cout << "S " << j + 1 << endl;
				else if (i == 1) cout << "H " << j + 1 << endl;
				else if (i == 2) cout << "C " << j + 1 << endl;
				else cout << "D " << j + 1 << endl;
			}
		}
	}
	return 0;
}


Measured memory_bytes: 3108
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin >> n;
    int arr[n];
    for(int i=0;i<n;i++){
    	cin >> arr[i];
	}
	int dp[n];
	dp[0]=0;
	dp[1]=abs(arr[1]-arr[0]);
	for(int i=2;i<n;i++){
		dp[i] = min(dp[i-1]+abs(arr[i]-arr[i-1]), dp[i-2]+abs(arr[i]-arr[i-2]));
	}
	cout << dp[n-1] << "\n";
    return 0;
}

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

ll Ceil(ll a, ll b) {
	ll r = a/b;
	if(a%b) r++;
	return r;
}
int main() {
	int n;
	ll A[1005], B[1005];
	cin>>n;
	for(int i=0;i<n;++i) {
		cin>>A[i]>>B[i];
	}
	ll a = A[0], b = B[0];
	for(int i=1;i<n;++i) {
		ll mul = max(Ceil(a, A[i]), Ceil(b, B[i]));

		a = mul * A[i];
		b = mul * B[i];
	}
	cout<<a+b<<endl;

	return 0;
}

Measured memory_bytes: 256
original_s = list(input())
s = list(map(lambda x:ord(x)-97-26, original_s))
K = int(input())

ans = original_s
for i in range(len(s)):
    if abs(s[i]) <= K and s[i] != -26:
        ans[i] = "a"
        K += s[i]

ans[-1] = chr(((ord(ans[-1]) + K) - 97) % 26 + 97)

print("".join(ans))

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

using namespace std;

int main()
{
    int number[3], c = 0;

    for (int i = 0; i < 3; i++)
    {
        scanf("%d", &number[i]);

        if (number[i] == number[i - 1] && i != 0)
            c++;
    }

    if (c != 2 && (number[0] == number[1] || number[0] == number[2]))
        printf("Yes\n");
    else if (c != 2 && number[1] == number[2])
        printf("Yes\n");
    else
        printf("No\n");

    return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;

namespace test
{
    class Program
    {
        static void Main(string[] args)
        {
            var N = ReadInt();
            var A = ReadArrayInt();
            for (int i = N - 1; i >= 0; i -= 2) Console.Write(A[i] + " ");
            if (N % 2 == 0) for (int i = 0; i < N - 1; i += 2) Console.Write(A[i] + " ");
            else for (int i = 1; i < N - 1; i += 2) Console.Write(A[i] + " ");

            Console.WriteLine();
            Console.ReadLine();
        }

        static string Read() { return Console.ReadLine(); }
        static int ReadInt() { return int.Parse(Read()); }
        static long ReadLong() { return long.Parse(Read()); }
        static int[] ReadArrayInt() { return Read().Split(' ').Select(s => int.Parse(s)).ToArray(); }
        static long[] ReadArrayLong() { return Read().Split(' ').Select(s => long.Parse(s)).ToArray(); }
    }
}

Measured memory_bytes: 37928
#include <bits/stdc++.h>
#define endl "\n"
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
using ll = long long;
const int INF = 0x3f3f3f3f;
using namespace std;

int n, m, a, b;
vector<int> adj[100001];
int dist[100001], in[100001];

void bfs(int src) {
    queue<int> q;
    q.push(src);
    while (!q.empty()) {
        int p = q.front();
        q.pop();
        for (auto ch : adj[p]) {
            in[ch]--;
            if (dist[p]+1 > dist[ch]) {
                dist[ch] = dist[p]+1;


            }
            if (in[ch]==0) {
                q.push(ch);
            }
        }
    }
}
int main()
{
    //IOS
    scanf("%d %d", &n, &m);
    for (int i = 0; i < m; ++i) {
        scanf("%d %d", &a, &b);
        a--;
        b--;
        in[b]++;
        adj[a].push_back(b);
    }
    for (int i = 0; i < n; ++i) {
        if (dist[i]==0 && in[i]==0) {
            bfs(i);
        }
    }
    int mx = 0;
    for (int i = 0; i < n; ++i) {
        mx = max(mx, dist[i]);
    }
    printf("%d\n", mx);



    return 0;
}


Measured memory_bytes: 6528
#include <stdio.h>

int main(void) {
	int a,b,c;
	scanf("%d",&a);
	scanf("%d",&b);
	scanf("%d",&c);
	
	if((a <= c) && (c <= b)) printf("Yes\n");
	else if((b <= c) && (c <= a)) printf("Yes\n");
	else printf("No\n");
	
	return 0;
}


Measured memory_bytes: 128
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<set>
#include<stack>
#include<cmath>
using namespace std;
typedef long long ll;
ll mod = 1e9+7;
#define rep(i,n) for(int i = 0; i < (n); ++i)
int main(){
    string s;
    cin >> s;
    bool ok = true;
    if ( s.length() % 2 == 1 ) {
        cout << "No" << endl;
        return 0;
    }
    rep(i, s.length()) {
        if ( i % 2 == 0 ) {
            if ( s[i] != 'h' ) {
                ok = false;
                break;
            }
        }
        else {
            if ( s[i] != 'i' ) {
                ok = false;
                break;
            }
        }
    }
    if ( ok ) cout << "Yes" << endl;
    else      cout << "No" << endl;
    return 0;
}

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

using namespace std;
using ll = long long;
using pii = pair<int, int>;

int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) {
    string s;
    int ans = 0, out = 0;
    int p[3] = {};
    while (out < 3) {
      cin >> s;
      if (s == "HIT") {
        ans += p[2];
        p[2] = p[1];
        p[1] = p[0];
        p[0] = 1;
      } else if (s == "HOMERUN") {
        ans += p[0] + p[1] + p[2] + 1;
        p[0] = p[1] = p[2] = 0;
      } else {
        out++;
      }
    }
    cout << ans << endl;
  }

  return 0;
}


Measured memory_bytes: 3160
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
typedef long long ll;
int main(){
    int n,l,A[200001];
    cin>>n>>l;
    rep(i,n) cin>>A[i];
    int z=0;
    rep(i,n-1) if(A[i]+A[i+1]>=l) z=i+1;
    if(!z){
        cout<<"Impossible";
        return 0;
    }
    cout<<"Possible"<<endl;
    rep(i,n-1) if(i+1<z) cout<<i+1<<endl;
    rep(i,n-1) if(n-i-1>z) cout<<n-1-i<<endl;
    cout<<z;
}

Measured memory_bytes: 1280
def main():
    # N! を　10^9+7 で割ったあまりを求めよ
    # N!そのものは非常に値が大きくなるから64bit符号付き整数ではオーバーフローによって正しく値が求めれない
    # 多倍長整数の乗算計算は時間が掛かって実行時間制限内に計算を終えることが難しくなる
    # x = i * mod 10^9 + 7として更新していけば64bit符合付整数で収まる

    N = int(input())
    res = 1
    for i in range(1, N+1):
        res = i * res % 1000000007
    print(res)




if __name__ == "__main__":
    main()

Measured memory_bytes: 2940