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

using namespace std;
using LL = long long;

int main() {

    LL N, M;
    cin >> N >> M;

    LL ans = 0;

    if (N >= M / 2) {
        ans = M / 2;
    } else {
        ans = N;
        ans += (M - N * 2) / 4;
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,a,b)  for(int i=(a),i##formax=(b);i< i##formax;i++)
#define FORR(i,a,b) for(int i=(a),i##formin=(b);i>=i##formin;i--)
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define pcnt __builtin_popcount
#define sz(x) (int)(x).size()
#define maxs(x,y) x=max((x),(y))
#define mins(x,y) x=min((x),(y))
#define show(x) cout<<#x<<" = "<<(x)<<endl;
#define all(a) ((a).begin()),((a).end())
#define each(i,c) for(__typeof((c).begin()) i=(c).begin();i!=(c).end();i++)
#define bit(n) (1LL<<(n))
typedef long long ll;
typedef __int128_t lll;
template<class T>using V=vector<T>;
template<class T>using VV=V<V<T>>;
template<class T,class Y>using P=pair<T,Y>;
template<class T,class Y>ostream& operator<<(ostream&o,P<T,Y>&p){return o<<"("<<p.fi<<","<<p.se<<")";}
template<class T>ostream& operator<<(ostream&o,V<T>&v){for(T&t:v)o<<t<<",";return o;}
template<class T>void uniq(V<T>&v){sort(all(v));v.erase(unique(all(v)), v.end());}

lll gcd(lll a,lll b,lll&x,lll&y){if(!b){x=1;y=0;return a;}lll d=gcd(b,a%b,y,x);y-=a/b*x;return d;}
ll modInv(ll a,ll m){lll x,y;gcd(a,m,x,y);return(x%m+m)%m;}
ll modPow(lll a,lll n,ll m){lll p=1;for(;n;n>>=1,a=a*a%m)if(n&1)p=p*a%m;return p;}
//V<ll>Fac,Rac;void setF(int n,int mod){Fac=Rac=V<ll>(++n);Fac[0]=1;FOR(i,1,n)Fac[i]=Fac[i-1]*i%mod;Rac[n-1]=modInv(Fac[n-1],mod);FORR(i,n-1,1)Rac[i-1]=Rac[i]*i%mod;}
//ll comb(int a,int b,int m){return a<b||b<0?0:Fac[a]*Rac[b]%m*Rac[a-b]%m;}

const int IINF = 1e9+6;
const ll LINF = 1e18;
const int MOD = 1e9+7; //998244353;
const int N = 1e5;
string s, t;
int a, b;
main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >> s >> s >> a >> b >> t;
  if(s==t) b--;
  else a--;
  cout << a << " " << b << endl;
}

Measured memory_bytes: 256
package main

import (
	"fmt"
)

func main() {
	var s string
	fmt.Scan(&s)
	for i := len(s)/2 - 1; i >= 1; i-- {
		b := true
		for j := 0; j < i; j++ {
			if s[j] != s[i+j] {
				b = false
				break
			}
		}
		if b {
			fmt.Println(i * 2)
			return
		}
	}
}


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

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

    h[0]--;
    for(int i=1;i<n;i++){
        if(h[i-1]<h[i]) h[i]--;
        if(h[i]<h[i-1]){cout << "No" << endl; return 0;}
    }
    cout << "Yes" << endl;
}

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

#define ll long long  
#define endl "\n"

const ll int MOD=1e9+7;

void solve()
{
	ll a; float b;
	cin >> a >> b;
	int c = round(b*100);
	// cout << fixed;
	cout << (a*c)/100<< endl;
}

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

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

int main(){

  int n,T;
  cin >> n>>T;
  int c[n],t[n];
  int min=10000;
  for(int i=0;i<n;i++){
    cin >> c[i] >> t[i];
    if(t[i]<=T&&c[i]<min){
      min = c[i];
    }
  }
  if(min==10000){
    cout << "TLE" << endl;
    return 0;
  }

  cout << min << endl;

}

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

ll sum[3][1000005];
ll combiDM[1000005];

int main() {
    int N;
    cin >> N;
    string S;
    cin >> S;
    int Q;
    cin >> Q;
    vector<int> k(Q);
    rep(i, Q) cin >> k[i];

    rep(j, 3) rep(k, N) sum[j][k] = 0;
    combiDM[0] = 0;

    string T = "DMC";
    rep(i, N) {
        rep(j, 3) {
            if (S[i] == T[j]) ++sum[j][i];
        }
    }

    rep(i, 2) {
        rep(j, N - 1) {
            if (i == 1) {
                combiDM[j + 1] = combiDM[j] + sum[0][j + 1] * sum[1][j + 1];
            }
            sum[i][j + 1] += sum[i][j];
        }
    }

    rep(i, Q) {
        vector<ll> ans(N);
        rep(j, N) {
            if (j < 2) continue;
            ans[j] += ans[j - 1];

            if (sum[2][j] != 1) continue;
            ans[j] += combiDM[j];
            if (j - k[i] < 0) continue;
            ans[j] -= (combiDM[j - k[i]] +
                       sum[0][j - k[i]] * (sum[1][j - 1] - sum[1][j - k[i]]));
        }

        cout << ans[N - 1] << endl;
    }
}

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

int main(){
    int n;
    cin >> n;
    int a[n];
    rep(i,n){
        cin >> a[i];
        a[i]--;
    }
    int ans=0;
    int now=0;
    rep(i,n){
        if (now==1){
            cout << ans << endl;
            return 0;
        }
        now=a[now];
        ans++;
    }
    cout << -1 << endl;
    return 0;
}

Measured memory_bytes: 768
/**
 *    author:  otera    
**/
#include<iostream>
#include<string>
#include<cstdio>
#include<cstring>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<deque>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<cassert>
using namespace std;

//#define int long long
typedef long long ll;
typedef unsigned long long ul;
typedef unsigned int ui;
typedef long double ld;
const int inf=1e9+7;
const ll INF=1LL<<60 ;
const ll mod=1e9+7 ;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<int, int> P;
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;
#define fr first
#define sc second
#define all(c) c.begin(),c.end()
#define pb push_back
#define debug(x)  cerr << #x << " = " << (x) << endl;
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; }

void solve() {
	int n; cin >> n;
    vector<int> a(n);
    rep(i, n) {
        cin >> a[i];
    }
    rep(i, n) {
        if(a[i] % 2 == 0) {
            if(a[i] % 3 != 0 && a[i] % 5 != 0) {
                cout << "DENIED" << endl;
                return;
            }
        }
    }
    cout << "APPROVED" << endl;
}

signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	//cout << fixed << setprecision(10);
	//int t; cin >> t; rep(i, t)solve();
	solve();
    return 0;
}

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

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

long long MOD = 1000000000 + 7;

int main(){
  cout << setprecision(10);
  int a,b;
  cin >> a >> b;
  cout << ((a*b)%2 == 1 ? "Odd" : "Even") << endl;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		new Main().solve(new Scanner(System.in));
	}
	
	public void solve(Scanner sc) {
		int n = Integer.parseInt(sc.next());
		int m = Integer.parseInt(sc.next());
		
		int[] favs = new int[m];
		int answer = 0;
		for(int i=0; i<n; i++) {
			int k = Integer.parseInt(sc.next());
			for(int j=0; j<k; j++) {
				int fav = Integer.parseInt(sc.next());
				favs[fav-1]++;
				if(favs[fav-1] >= n) {
					answer++;
				}
			}
		}
		System.out.println(answer);
	}
}


Measured memory_bytes: 24276
package main

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

func main() {
	A, B := ReadInt(), ReadInt()
	x := A + B
	if x >= 10 {
		fmt.Println("error")
	} else {
		fmt.Println(x)
	}
}

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: 1840
#include <iostream>
using namespace std;

int main(){

  int m, n_min, n_max, gap = 1000000, z;
  int ary[1000001];

  
  while(1){
    cin >> m >> n_min >> n_max;
    if(m == 0 && n_min == 0 && n_max == 0) break;

    for(int i = 1 ; i <= m ; i++){
      cin >> ary[i];
    }

    for(int i = n_min ; i <= n_max ; i++){
      if(gap >= ary[i+1] - ary[i]){
	gap = ary[i+1] - ary[i];
	z = i;
      }
    }
    cout << z << endl;
    gap = 1000000;
    z = 0;
  }

  return 0;
}

Measured memory_bytes: 3116
#include<stdio.h>
#include<string.h>
#include<algorithm>
using namespace std;
const int maxn=1e5+10;
int n,m;
int main(){
	int i,j,t;
		scanf("%d%d",&n,&m);
		printf("%d\n",n-m+1);
	return 0;
}

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

typedef long long ll;

struct Edge {
  int src,dst;
  ll w;
};

struct Data {
  int cur;
  ll w;
  bool operator < ( const Data &data ) const {
    if( w != data.w ) return w < data.w;
    return cur < data.cur;
  }
};

const ll LLINF = LLONG_MAX;
const int MAX_V = 110;
int V,E,Q;
vector<Edge> G[MAX_V];
ll fw[MAX_V][MAX_V];
double dp[MAX_V][2];

void compute(int type,int sp,int ep){
  vector<Data> vec;
  rep(i,V) vec.push_back((Data){i,fw[sp][i]});
  sort(vec.begin(),vec.end());
  rep(i,(int)vec.size()){
    int cur = vec[i].cur;
    rep(j,(int)G[cur].size()){
      int next = G[cur][j].dst;
      if( fw[sp][cur] + G[cur][j].w + fw[next][ep] == fw[sp][ep] ) {
        dp[next][type] += dp[cur][type];
      }
    }
  }
}

int main(){
  while( cin >> V >> E >> Q, V|E|Q ){
    rep(i,V) G[i].clear();
    rep(i,V) rep(j,V) fw[i][j] = ((i==j)?0:LLINF);
    rep(i,E) {
      int src,dst;
      ll w;
      cin >> src >> dst >> w;
      fw[src][dst] = fw[dst][src] = w;
      G[src].push_back((Edge){src,dst,w});
      G[dst].push_back((Edge){dst,src,w});
    }

    rep(k,V) rep(i,V) rep(j,V) if( fw[i][k] != LLINF && fw[k][j] != LLINF ) fw[i][j] = min(fw[i][j],
                                                                                           fw[i][k]+fw[k][j]);
    
    rep(i,MAX_V) rep(j,2) dp[i][j] = 0;
    dp[0][0] = dp[V-1][1] = 1;
    compute(0,0,V-1);
    compute(1,V-1,0);
    rep(i,Q){
      int pos;
      cin >> pos;
      printf("%.10f\n",dp[pos][0]*dp[pos][1]/dp[V-1][0]);
    } puts("");
    
  }
  return 0;
}

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

#define watch(x) cerr << (#x) << ": " << (x) << endl
#define int long long



int32_t main() {

    int n, m; cin >> n >> m;
    priority_queue<int> pq;
    for(int i = 0; i < n; ++i) {
        int x; cin >> x;
        pq.push(x);
    }

    priority_queue<pair<int, int>> mpq;
    for(int i = 0; i < m; ++i) {
        int b, c; cin >> b >> c;
        mpq.push({c, b});
    }

    int ans = 0, rem = n;
    while(rem) {
        if(mpq.empty() || pq.top() > mpq.top().first) {
            ans += pq.top();
            pq.pop();
            rem--;
        } else {
            int num = min(rem, mpq.top().second);
            ans += mpq.top().first*num;
            mpq.pop();
            rem -= num;
        }
    }

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


Measured memory_bytes: 3188
#include<bits/stdc++.h>
#define io ios_base::sync_with_stdio(false); cin.tie(NULL);

#define N 100000
#define nl "\n"
#define f first
//#define s second
#define pi acos(-1.0)
#define MOD 1000000007
#define pb push_back

typedef long long ll;
typedef double db;

using namespace std;

int identity(string a,string b)
{
    int cnt=0;
    int lena = a.size();
    for(int i=0; i< lena ; i++)
    {
        if(a[i]!=b[i])
            cnt++;
    }
    return cnt;
}

int main()
{
    io;
    //freopen("in.txt" , "r" , stdin);
    //freopen("out.txt" , "w" , stdout);

    ///Let the showdown begin

    string s1,s2;
    cin >> s1 >> s2;
    int ans=INT_MAX;
    int len = s1.size();
    for(int i=0; i< len; i++)
    {
        string  subS = s1.substr(i,s2.size());
        //cout<<subS<<nl;

        if(subS.size()==s2.size())
            ans = min(ans,identity(subS,s2));

    }
    cout<<ans<<nl;

    ///Happily DONE
    return 0;
}

Measured memory_bytes: 3684
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
//using System.Numerics;
using System.Diagnostics;

class Program
{
    public void Slove()
    {
        int n = int.Parse(Console.ReadLine());
        double[] coins = 
            Console.ReadLine().Split()
            .Select(double.Parse)
            .ToArray();
        double[] dp = new double[n / 2 + 2];
        dp[0] = 1;
        foreach(var coin in coins)
        {
            double coinR = 1 - coin;
            foreach(int i in Enumerable.Range(0, n / 2 + 1).Reverse().SkipWhile(x => dp[x] == 0))
            {
                dp[i + 1] += dp[i] * coin;
                dp[i] = dp[i] * coinR;
            }
        }
        //Console.WriteLine(string.Join(",", dp));
        Console.WriteLine(dp[n / 2 + 1]);
    }
    static void Main(string[] args)
    {
        var p = new Program();
        p.Slove();
    }
}


Measured memory_bytes: 42960
//PseudoName

	#pragma GCC optimize("O3")
	#include <bits/stdc++.h>
	#include <ext/pb_ds/assoc_container.hpp>
	#include <ext/pb_ds/tree_policy.hpp>
	using namespace std;
	using namespace __gnu_pbds;
	template<class T> using oset=tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;


	#define FOR(i,n) for(i=0;i<n;i++)
	#define FOR1(i,n) for(i=1;i<=n;i++)
	#define FOR2(I, A, B) for (int I = (A); I <= (B); ++I)
	#define pb push_back
	#define unique_sort(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
	#define print(v) for(auto it:v)cout<<it<<" ";cout<<endl
	#define fast() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
	#define endl "\n"
	#define min3(a,b,c) min(a,min(b,c))
	#define forr(n) for(int i=0;i<n;i++)
	#define frr(n) for(int i=1;i<=n;i++)
	#define rep(i,a,b) for(int i=a;i<=b;i++)



	typedef long long ll;
	typedef long li;
	typedef vector<int> vi;
	typedef vector<ll> vli;
	typedef vector<vi> vvi;
	typedef vector<vli> vvli;
	typedef pair<int,int> pi;
	typedef pair<ll,ll> pli;
	typedef vector<pi> vpi;
	typedef vector<pli> vpli;



	//const ll MOD=1e9+7;

	/*
	ll fast_exp(ll base, ll exp) {
	    ll res=1;
	    while(exp>0) {
	       if(exp%2==1) res=(res*base)%MOD;
	       base=(base*base)%MOD;
	       exp/=2;
	    }
	    return res%MOD;
	}
	ll imod(ll a)
	{
		return fast_exp(a, MOD-2);
	}
	*/

	const double PI=3.14159265;

	int main() {
	    fast();

	    double r;
        cout<<setprecision(12);
	    cin>>r;
	    cout<<2*PI*r<<endl;



	}


Measured memory_bytes: 3804
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.IOException;
import java.util.Set;
import java.util.HashSet;

public class Main
{
	static StringBuilder sb = new StringBuilder();
	
	public static void main(String[] args)throws IOException
	{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int n = Integer.parseInt(br.readLine());
		String s = br.readLine();
		int i,l , r ;
		addFb(s);
		/*l =  searchLeft(s);
		r = n - l ;
		if(r != l){
			if(l > r)
			{
				sb.append(s);
				for(i = 0 ; i < l - r ; i++)
				{
					sb.append(')');
				}
			}
			else
			{
				for(i = 0 ; i < r - l ; i++)
				{
					sb.append('(');
				}
				sb.append(s);
			}
		}else{
			sb.append(s);
		}
		
		System.out.println(sb);*/
		
	}
	/*public static int searchLeft(String s)
	{
		int ans = 0;
		for(int i = 0 ; i < s.length() ; i++ ) 
		{
			if(s.charAt(i) == '('){
				ans ++;
			}
		
			
		}
		return ans;
	}
	*/
	public static void addFb(String s)
	{
		int lHp = 0 , rHp = 0 ;
		for(int i = 0 ; i < s.length() ; i++ ) 
		{
			if(s.charAt(i) == '('){
				lHp++ ;
			} 
			else
			{
				if(lHp > 0) lHp--;
				else rHp++;
			}	
		}
		for(int i = 0 ; i < rHp ; i++ ) 
		{
			sb.append('(');
		}
		sb.append(s);
		for(int i = 0 ; i < lHp ; i++ ) 
		{
			sb.append(')');
		}
		System.out.println(sb);	
	}
	
}

Measured memory_bytes: 21204
import java.util.Scanner;
 
public class Main {
	public void solve() {
		Scanner in = new Scanner(System.in);
		int N = in.nextInt();
		int[] n = new int[N];
		for (int i=0; i<N; i++) {
			n[i] = in.nextInt();
		}
		in.close();
		
		int tIndex = 0;
		int sIndex = 0;
		
		if (n[0] < n[1]) {
			tIndex = 1;
			sIndex = 0;
		} else {
			tIndex = 0;
			sIndex = 1;
		}
		
		for (int i=2; i<N; i++) {
			if (n[tIndex] < n[i]) {
				sIndex = tIndex;
				tIndex = i;
			} else if (n[sIndex] < n[i]) {
				sIndex = i;
			}
		}
		
		for (int i=0; i<N; i++) {
			if (i==tIndex) {
				System.out.println(n[sIndex]);
			} else {
				System.out.println(n[tIndex]);
			}
		}
	}
	
	public static void main(String[] args) {
		Main main = new Main();
		main.solve();
	}
 
}


Measured memory_bytes: 107504
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define fast  ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define mod 1000000007
int32_t main()
{
    string s;
    cin>>s;
    if(s[2]==s[3] and s[4]==s[5])
    {
        cout<<"Yes";
    }
    else
    {
        cout<<"No";
    }
}       
        

Measured memory_bytes: 256
def main():
    W ,a, b = map(int,input().split(" "))
    if W + a > b and a < b + W:
        print("0")
    elif a < b:
        print(b - (a + W))
    elif a > b:
        print(a - (b + W))
    

if __name__ == '__main__':
    main()

Measured memory_bytes: 3060
// https://atcoder.jp/contests/cf17-final/tasks/cf17_final_b
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep1(i, n) for (int i = 1; i <= (n); i++)
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;

const char wall = '#';
vector<vector<char>> fields;
vector<vector<bool>> used;
vector<vector<ll>> dist;
const int dx[4] = {0, -1, 0, 1};
const int dy[4] = {1, 0, -1, 0};

vector<ll> A;
// vectorのリサイズ
// A.resize(N);

ll gcd(ll a, ll b) { return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return b/gcd(a,b)*b;}

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

  string s;
  cin >> s;
  map<char, ll> mp;
  rep(i, s.size()) {
   mp[s[i]]++;
  }
  if (abs(mp['a']-mp['b']) > 1 || abs(mp['b']-mp['c']) > 1 || abs(mp['a']-mp['c']) > 1) {
    cout << "NO" << endl;
  } else {
    cout << "YES" << endl;
  }
  return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int a,b,count=0;
    cin >> a >>b;
    for(int i=a;i<=b;i++){
        int k = i%10;
        int l = i/10000%10;
        int m = i/10%10;
        int n = i/1000%10;
        if(k==l&&m==n) count++;
    }
    
    cout << count << endl;
    
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define ALL(x) (x).begin(), (x).end()
typedef long long ll;
typedef pair<int, int> pii;
const int INF = 1e9;
const int MOD = 1000000007;
const double PI = acos(-1);
int dx[4] = {0,1,0,-1};
int dy[4] = {1,0,-1,0};

void solve() {
	int n;
	cin >> n;
	string s;
	cin >> s;
	ll ans = 0;
	for (int i = 0; i < 1000; i++) {
		string t = to_string(i);
		while (t.size() < 3) t = '0' + t;
		int it = 0;
		for (int j = 0; j < n; j++) {
			if (it == 3) {
				break;
			}
			if (t[it] == s[j]) it++;
		}
		if (it == 3) ans++;
	}
	cout << ans << endl;
}

int main() {
	solve();
	return 0;
}

Measured memory_bytes: 3724
n = int(input())
a = [int(v) for v in input().split()]

ave = sum(a) / n
ans = 0
diff = abs(a[ans] - ave)
for i in range(1, n):
    if diff > abs(a[i] - ave):
        diff = abs(a[i] - ave)
        ans = i

print(ans)

Measured memory_bytes: 3064
let N =
    stdin.ReadLine()
    |> int
let A =
    stdin.ReadLine().Split()
    |> Array.map int
    |> Array.sort

[|2..N-1|]
|> Array.sumBy (fun x -> int64(A.[N-1-x/2]))
|> fun x -> x+int64(A.[N-1])
|> stdout.WriteLine

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

using namespace std;

const int N=3e5+500;

int q[N];

int main(){
    int a;
    long long r=0;
    cin >> a;
    int mg=0;
    for (int i=0 ; i<a ; i++){
        cin >> q[i];
        if (q[i] > i){
            mg=1;
        }
    }
    if (mg==1){
        cout << -1;
        return 0;
    }
   // cout << '\n';
    if (q[0]>0){
        cout << -1;
        return 0;
    }
    int w=0;
    for (int i=a-1 ; i>0 ; i--){
        int e=q[i];
        if (q[i-1] == e-1){
           if (w==0){
                r+=e;
                w=2;
                //cout << r << " "<< q[i-1]<<"\n";
           }

        }
        else if (q[i-1]==q[i]){
            r+=e;
        }
        else if (q[i-1] > q[i]){
            if (w==0){
               r+=e;
            }
            w=0;
        }
        else{
            cout << -1;
            return 0;
        }
    }
    cout << r;













}




Measured memory_bytes: 1024
import java.util.Scanner;
import java.util.List;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
	String a = sc.next();
    String b = sc.next();
    String c = sc.next();
    System.out.println(a.substring(0,1)+b.substring(1,2)+c.substring(2));
  }
}

Measured memory_bytes: 21844
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <numeric>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <cmath>
#include <cassert>
#include <cstdarg>
#include <sys/time.h>
#include <fstream>
//#include "cout.h"

using namespace std;

#define SZ(x) ((int)x.size())
#define MSET(x,a) memset(x, a, (int)sizeof(x))
#define PB push_back
#define VI vector < int >
#define PII pair < int, int >
#define LL long long
#define FOR(i,a,b) for (int i = (a); i < (b); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(), (v).end()
#define FIT(it,v) for (__typeof((v).begin()) it = (v).begin(); it != (v).end(); it++)
#define OUT(A) cout << #A << " = "<< (A) << endl
#define OUT2(A, B) cout << "(" << #A << ", " << #B << ") = (" << (A) << ", "<< (B) << ")" << endl
template<class T> void chmin(T &t, T f) { if (t > f) t = f; }
template<class T> void chmax(T &t, T f) { if (t < f) t = f; }

#define present(c, e) ((c).find((e)) != (c).end())
#define cpresent(c, e) (find(ALL(c), (e)) != (c).end())

int n, m;
int x[100010];

void init() {

}

void input() {
  cin >> n >> m;
  REP(i, m) {
    cin >> x[i];
  }
  sort(x, x+m);
}

void solve() {
  int rem = m-n;

  VI a;
  FOR(i, 0, m-1) {
    a.PB(x[i+1]-x[i]);
  }
  sort(ALL(a));
  LL res = 0;
  REP(i, rem) {
    res += a[i];
  }
  cout << res << endl;

}

int main() {
	init();
	input();
	solve();
	return 0;
}


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

template<typename T>
ostream& operator<<(ostream &os, vector<T> &v){
	string sep = " ";
	if(v.size()) os << v[0];
	for(int i=1; i<v.size(); i++) os << sep << v[i];
	return os;
}

template<typename T>
istream& operator>>(istream &is, vector<T> &v){
	for(int i=0; i<v.size(); i++) is >> v[i];
	return is;
}

#ifdef DBG
void debug_(){ cout << endl; }
template<typename T, typename... Args>
void debug_(T&& x, Args&&... xs){
	cout << x << " "; debug_(forward<Args>(xs)...);
}
#define dbg(...) debug_(__VA_ARGS__)
#else
#define dbg(...)
#endif

int main() {
	ios_base::sync_with_stdio(false);
	cout << setprecision(20) << fixed;

	int h, w, k; cin >> h >> w >> k;
	vector<string> c(h); cin >> c;

	int ans = 0;
	for(int s=0; s<(1<<(h+w)); s++){
		int x = 0;
		for(int i=0; i<h; i++){
			for(int j=0; j<w; j++){
				if((s>>(i+w)&1)|(s>>j&1)) continue;
				if(c[i][j]=='#') x++;
			}
		}
		if(x==k) ans++;
	}
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 3656
#include <cctype>
#include <cstdlib>
#include <iostream>
#include <string>
#include <vector>
using namespace std;

bool large(const string& a, const string& b) {
	if(a.size() != b.size())
		return a.size() > b.size();

	for(int i = 0; i < (int)a.size(); ++i)
		if(a[i] != b[i])
			return a[i] > b[i];

	return false;
}

inline void chmax(string& a, const string& b) { if(large(b, a)) a = b; }

int w, h;
vector<string> mat;
vector<vector<string> > memo;

inline string dfs(int x, int y) {
	if(memo[y][x] != "#")
		return memo[y][x];

	string res;
	if(x < w - 1 && isdigit(mat[y][x + 1]))
		res = dfs(x + 1, y);

	if(y < h - 1 && isdigit(mat[y + 1][x]))
		chmax(res, dfs(x, y + 1));

	return memo[y][x] = mat[y][x] + res;
}

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

	while(cin >> w >> h, w) {
		mat.clear();
		mat.resize(h);
		for(int i = 0; i < h; ++i)
			cin >> mat[i];

		memo.clear();
		memo.resize(h, vector<string>(w, "#"));
		string ans;
		for(int i = 0; i < h; ++i)
			for(int j = 0; j < w; ++j)
				if('1' <= mat[i][j] && mat[i][j] <= '9')
				   chmax(ans, dfs(j, i));

		cout << ans << endl;
	}

	return EXIT_SUCCESS;
}

Measured memory_bytes: 1352
#include<bits/stdc++.h>
#define mod 1000000007
#define ll long long int
#define ar array
#define mp make_pair
using namespace std;

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	string s;
	cin>>s;
	if(s[0]==s[2])
		cout<<"Yes"<<endl;
	else
		cout<<"No"<<endl;
	return 0;
}

Measured memory_bytes: 764
#include <stdio.h>
#include <string.h>

int main(){
  char a,b;
  scanf("%c %c",&a,&b);
  if(a=='H'){
    if(b=='H')printf("H");
    else printf("D");
  }
  else{
    if(b=='H') printf("D");
    else printf("H");
  }
  return 0;
}

Measured memory_bytes: 128
extern crate core;

use std::io::{self, Read};

#[macro_export]
macro_rules! input {
  ($s:expr=>$($t:tt)*) => {
    let mut lines=$s.split("\n");
    $(
        line_parse!(lines,$t);
    )*
  };
}

macro_rules! line_parse {
  ($lines:expr,($($name:ident:$t:tt)*)) => {
    let mut line=$lines.next().unwrap().split_whitespace();
    $(value_def!(line,$name,$t);)*
  };

  //複数行
  ($lines:expr,{$n:expr;$name:ident:$t:tt}) => {
    values_def!($lines,$n,$name,$t);
  };
}

macro_rules! value_def {
    ($line:expr, $name:ident, $t:tt) => {
        let $name = value!($line, $t);
    };
}

macro_rules! values_def {
    ($lines:expr, $n:expr, $name:ident, $t:tt) => {
        let $name = {
            let mut vec = Vec::new();
            for i in 0..$n {
                let mut next = $lines.next().unwrap().split_whitespace();
                vec.push(value!(next, $t));
            }
            vec
        };
    };
}

macro_rules! value {
  //配列
  ($line:expr,[$t:tt]) => {
    $line.map(|x|{
      let mut iter=::std::iter::once(x);
      value!(iter,$t)
    }).collect::<Vec<_>>()
  };
  //タプル
  ($line:expr,($($t:tt),*)) => {
    ($(value!($line,$t),)*)
  };
  //文字列
  ($line:expr,#) => {
    $line.next().unwrap()
  };
  //インデックス(-1)
  ($line:expr,@) => {
    $line.next().unwrap().parse::<usize>().unwrap()-1
  };
  //単一値
  ($line:expr,$t:ty) => {
    $line.next().unwrap().parse::<$t>().unwrap()
  };
}

fn main() {
    let mut input = String::new();
    io::stdin().read_to_string(&mut input).unwrap();
    let output = solve(input.trim().to_string());
    println!("{}", output);
}

fn solve(input: String) -> String {
    input!(input=>(a:i64 b:i64 c:i64));
    (if c - a - b >= 0 && (c - a - b) * (c - a - b) > 4 * a * b {
        "Yes"
    } else {
        "No"
    })
    .to_string()
}

macro_rules! tests {
    ($($name:ident: $input:expr=>$output:expr,)*) => {
        mod tests {
            $(
                #[test]
                fn $name() {
                    assert_eq!($output.trim().to_string(),super::solve($input.trim().to_string()));
                }
            )*
        }
    }
}
tests! {
    test1: "2 3 9\n" => "No\n",
    test2: "2 3 10\n" => "Yes\n",
}


Measured memory_bytes: 4352
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <random>
#include <iterator>

using namespace std;

#define SORT(c) sort((c).begin(),(c).end())
#define REVERSE(v) reverse((v).begin(),(v).end())
#define ANS(ans) cout<<(ans)<<endl;
#define UNIQUE(v) (v).erase(unique((v).begin(), (v).end()), (v).end());
typedef vector<int> VI;
typedef pair<int, int> P;

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n)  for (int i = 0; i < (n); ++i)


int main() {
	int n, k;
	cin >> n >> k;
	double ans = 0;
	FOR(i, 1, n) {
		int t = ceil(log2(k*1.0 / i));
		t = max(0, t);
		ans += 1.0 / n * pow(0.5, t);
	}
	cout << setprecision(12) << ans << endl;
	
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
vector<int> A[100000];

int solve(int i) {
    int res = 0;
    vector<int> V;
    for(int v : A[i]) V.push_back(solve(v));
    sort(V.begin(), V.end());
    for(int i=0; i<V.size(); ++i) res = max(res + 1, V[i]);
    return res + 1;
}

int main() {
    int N;
    cin >> N;
    for(int i=1; i<N; ++i) {
        int a;
        cin >> a;
        A[a-1].push_back(i);
    }

    cout << solve(0) - 1 << endl;
}

Measured memory_bytes: 13568
import std.stdio;
import std.string;

char[8][8] ch;

void main(){
	foreach (i; 0..8) ch[i] = chomp(readln());
	for (int i = 1; i <= 3; i++) {
		rotate();
		writeln(i*90);
		print();
	}
}

void rotate(){
	char[8][8] tmp;
	foreach (i; 0..8)
		foreach (j; 0..8)
			tmp[i][j] = ch[7-j][i];
	foreach (i; 0..8)
		foreach (j; 0..8)
			ch[i][j] = tmp[i][j];
}

void print(){
	foreach (i; 0..8) {
		foreach (j; 0..8) {
			write(ch[i][j]);
		}
		writeln();
	}
}

Measured memory_bytes: 960
def main():
    N, D, A = (int(i) for i in input().split())
    P = [[int(i) for i in input().split()] for j in range(N)]
    P.sort()
    X = [x[0] for x in P]
    H = [h[1] for h in P]
    diff = [H[0]] + [H[i+1] - H[i] for i in range(N-1)]
    BIT = [0] * (N+1)

    def BIT_query(idx):
        """ A1 ~ Aiまでの和(1-index) """
        res_sum = 0
        while idx > 0:
            res_sum += BIT[idx]
            idx -= idx & -idx
        return res_sum

    def BIT_update(idx, x):
        """ Aiにxを加算(1-index) """
        while idx <= N:
            BIT[idx] += x
            idx += idx & -idx
        return

    def BIT_init(A):
        for i, e in enumerate(A):
            BIT_update(i+1, e)

    BIT_init(diff)
    ans = 0
    right = 0
    for left in range(N):
        x = X[left]
        h = BIT_query(left+1)
        while right < N and X[right] <= x + 2*D:
            right += 1
        if h > 0:
            cur = (h + A - 1) // A
            damage = cur * A
            BIT_update(left+1, -damage)
            BIT_update(right+1, damage)
            ans += cur
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 100772
#include<bits/stdc++.h>
#define INF 1e9
#define llINF 1e18
#define MOD 1000000007
#define pb push_back
#define mp make_pair 
#define F first
#define S second
#define ll long long
#define ull unsigned long long
#define vi vector<ll>
#define vvi vector<vi>
#define BITLE(n) (1LL<<((ll)n))
#define BITCNT(n) (__builtin_popcountll(n))
#define SUBS(s,f,t) ((s).substr((f)-1,(t)-(f)+1))
#define ALL(a) (a).begin(),(a).end()
using namespace std;
ll op[111111];
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll n,h,w;
  cin>>n>>h>>w;
  for(int i=0;i<n;i++){
    ll x;cin>>x;
    if(i%2 == 0){
      for(int j=i*w+x;j<(i+1)*w+x;j++)
	op[j] = 1;
    }else{
      for(int j=i*w-x;j<(i+1)*w-x;j++)
	op[j] = 1;
    }
  }
  ll ans=0;
  for(int i=0;i<n*w;i++){
    if(op[i] == 0)
      ans += h;
  }
  cout<<ans<<endl;
  return 0;
}



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

int match[1001], v;
bool vis[1001];
vector<int> graph[1001];

bool dfs(int x){
	vis[x] = true;
	for (int i = 0; i < graph[x].size(); ++i){
		int u = graph[x][i], w = match[u];
		if (w < 0 || !vis[w] && dfs(w)){
			match[x] = u;
			match[u] = x;
			return true;
		}
	}
	return false;
}

int bipmatch(){
	int res = 0;
	memset(match, -1, sizeof(match));
	for (int i = 0; i < v; ++i){
		//该点仍未匹配
		if (match[i] < 0){
			memset(vis, 0, sizeof(vis));
			if (dfs(i))++res;
		}
	}
	return res;
}

int main()
{
	int a, b, x, y, e;
	scanf("%d%d%d", &x, &y, &e);
	for (int i = 0; i < e; ++i){
		scanf("%d%d", &a, &b);
		graph[a].push_back(x + b);
		graph[x + b].push_back(a);
	}
	v = x + y;
	printf("%d\n", bipmatch());
	return 0;
}


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

int main()
{
	string ans;
	int N, K;
	int d[9];

	cin >> N >> K;

	for (int i = 0; i < K; i++) {
		cin >> d[i];
	}

	bool flag = true;
	for (int i = N; ; i++) {
		ans = to_string(i);
		flag = true;
		for (int j = 0; j < K; j++) {
			if (ans.find(to_string(d[j])) != -1) {
				flag = false;
				break;
			}
		}

		if (flag == true) {
			cout << i << endl;
			break;
		}
	}

	return 0;
}

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

int main() {
  int N;
  cin >> N;
  vector<double> A(N);
  vector<double> B(N);
  double S = 0;
  for (int i = 0; i < N; i++)
  {
      cin >> A.at(i);
      B.at(i) = 1/A.at(i);
      S += B.at(i);
  }
  cout << 1/S << endl;
  
  }

Measured memory_bytes: 256
use proconio::*;

fn run() {
    input! {
        x: i64,
    }
    let w = 1000i64;
    for a in (-w)..=w {
        for b in (-w)..=w {
            if a.pow(5) - b.pow(5) == x {
                println!("{} {}", a, b);
                return;
            }
        }
    }
}

fn main() {
    run();
}

Measured memory_bytes: 2084
// I SELL YOU...! 
#include<iostream>
#include<vector>
#include<algorithm>
#include<functional>
#include<queue>
#include<chrono>
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
signed main(){
  string s;
  cin >> s;
  for(char c:s){
    if(c==',') cout <<" ";
    else cout <<c;
  }
  cout << endl;
}


Measured memory_bytes: 256
import java.util.*;

public class  Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        a+=b;
        if(a%2==0){
            System.out.println(a/2);
        }else{
            a/=2;
            System.out.println(a+1);
        }
    }
}

Measured memory_bytes: 21716
#include<iostream>
using namespace std;
int main(){
  int n;
  cin>>n;
  int a=n%10;
  if(a==3)
    cout<<"bon";
  else{
  if(a==0||a==1||a==6||a==8)
    cout<<"pon";
   else
     cout<<"hon";
  }
  return 0;
}

Measured memory_bytes: 3580
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;

class Main{
    public static void main(String[] args) throws IOException{
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String[] input = br.readLine().split(" ");
        int m = Integer.parseInt(input[0]);
        int d = Integer.parseInt(input[1]);

        int ans = m;
        if(d < m)   ans--;
        System.out.println(ans);
    }
}

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

int INFp=1000000007;
const string minusinf ="-";
int cost[10]={0,
    2
    ,
    5
    ,
    5
    ,
    4
    ,
    5
    ,
    6
    ,
    3
    ,
    7
    ,
    6
};
void chmax(string &a,string b){
    if(a == minusinf) a=b;
    else if(a.size()<b.size()) a=b;
    else if(a.size()==b.size()){
        if(a<b) a=b;
    }
}
int main(){
    int n,m;
    int a[15];
    cin>>n>>m;
    for(int i=0;i<m;i++) cin>>a[i];
    
    string dp[10050];
    
    for(int i=0;i<10010;i++){
        dp[i]=minusinf;
    }
    dp[0]="";
    
    for(int i=0;i<10010;i++){
        for(int j=0;j<m;j++){
            if(dp[i]==minusinf) continue;
            
            int ii=i+cost[a[j]];
            
            chmax(dp[ii],dp[i]+(char)('0'+a[j]));
        }
    }
    cout<<dp[n]<<endl;
    return 0;
}


Measured memory_bytes: 45312
s, t = 'd'+input(), 'd'+input()
n, m = len(s)-1, len(t)-1

# 1-indexed

memo = [[0]*(m+1) for i in range(n+1)]
memo[0][0] = 0

for i in range(n):
    for j in range(m):
        if s[i+1] == t[j+1]:
            memo[i+1][j+1] = memo[i][j] + 1
        else:
            memo[i+1][j+1] = max(memo[i+1][j], memo[i][j+1])

ans = ""
i, j = n, m
while i != 0 and j != 0:
    if s[i] == t[j] and memo[i][j]-1 == memo[i-1][j-1]:
        ans += s[i]
        i -= 1
        j -= 1
    elif memo[i][j] == memo[i-1][j]:
        i -= 1
    elif memo[i][j] == memo[i][j-1]:
        j -= 1

print(ans[::-1])


Measured memory_bytes: 112476
x=input()
l=len(x)
if len(x)==1:
    print(x)
elif x[1:]=='9'*~-l:
    print(int(x[0])+9*~-l)
elif x[0]=='1':
    print(9*~-l)
else:
    print(int(x[0])-1+9*~-l)

Measured memory_bytes: 3060
#include <iostream>
#include <vector>
#include <string>
#include <set>

using namespace std;

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

int main(){
	while(true){
		int w, h;
		cin >> h >> w;
		if(h == 0 && w == 0){ break; }
		vector<string> v(h);
		for(int i = 0; i < h; ++i){ cin >> v[i]; }
		set<string> found;
		string answer;
		for(int i = 0; i < h; ++i){
			for(int j = 0; j < w; ++j){
				for(int d = 0; d < 8; ++d){
					int y = i, x = j;
					string s;
					do {
						s += v[y][x];
						if(found.find(s) == found.end()){
							found.insert(s);
						}else{
							if(answer.size() < s.size()){
								answer = s;
							}else if(answer.size() == s.size() && s < answer){
								answer = s;
							}
						}
						y = (y + dy[d] + h) % h;
						x = (x + dx[d] + w) % w;
					} while(y != i || x != j);
				}
			}
		}
		if(answer.size() <= 1){ answer = "0"; }
		cout << answer << endl;
	}
	return 0;
}

Measured memory_bytes: 33764
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <cmath>
#include <cassert>

using namespace std;


#define all(c) ((c).begin()), ((c).end())
#define debug(c) cerr << "> " << #c << " = " << (c) << endl;
#define iter(c) __typeof((c).begin())
#define present(c, e) ((c).find((e)) != (c).end())
#define cpresent(c, e) (find(all(c), (e)) != (c).end())
#define tr(i, c) for (iter(c) i = (c).begin(); i != (c).end(); i++)
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i, a, b) for (int i = (int)(a); i <= (int)(b); i++)

#define mp make_pair
#define fst first
#define snd second
#define pb push_back


const double EPS = 1e-10;


typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef complex<double> P;


int main(){
	for (string s; getline(cin, s); ) {
		rep (i, 26) {
			rep (j, s.size()) if (isalpha(s[j])) {
				s[j]++;
				if (s[j] > 'z') s[j] = 'a';
			}
			if (s.find("the") != -1 || s.find("this") != -1 || s.find("that") != -1) break;
		}
		cout << s << endl;
	}
	
	return 0;
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
using namespace std;
#define ff first
#define ss second
#define pii pair<int, int>
#define pll pair<long long , long long>
#define pb push_back
#define ll long long
#define ld long double
#define precision(x,d) cout<<fixed<<setprecision(d)<<x
#define fill(a,b) memset((a),(b),sizeof((a)))
#define FAST ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);srand(time(NULL));
ll power(ll x,ll y,ll m){ll r=1;for(;y;y>>=1){if(y&1)r=r*x%m;x=x*x%m;}return r;}
const ll mod = 1e9 + 7;
const ld pi = 3.14159265358979;
    
int run_test(){
	int n;
	cin >> n;
	int arr[n];
	for(int i=0;i <n ;i++){
		cin >> arr[i];
	}
	int ans = 0;
	sort(arr, arr + n);
	for(int i=0;i <n; i++){
		for(int j=i + 1; j<n; j++){
			int sum = arr[i] + arr[j];	
			int high = n, low = 0;
			while(low < high){
				int mid = low + (high - low)/2;
				if(arr[mid] < sum){
					low = mid + 1;
				}
				else{
					high = mid;
				}
			}
			if(low > j){
				ans += low - j - 1;
			}
		}
	}
	cout << ans;
	return 0;
}
    
int main(){
   FAST;
    ll t;
    t = 1;
     
    while(t--){
        run_test();
    }
}

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

int main() {
  char a, b, c, d;
  cin >> a >> b >> c >> d;
  if((a == b && c == d && a != c) || (a == c && b == d && a != b) ||
     (a == d && b == c && a != b)) cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 3604
N, M = map(int, input().split())
*S, = map(int, input().split())
*T, = map(int, input().split())

dp = [[0]*(M+1) for _ in range(N+1)]
accum = [[0]*(M+1) for _ in range(N+1)]
MOD = 10**9+7

for i in range(1, N+1):
    for j in range(1, M+1):
        dp[i][j] = 0 if S[i-1]!=T[j-1] else (1 + accum[i-1][j-1])%MOD
        accum[i][j] = (accum[i-1][j]+accum[i][j-1]-accum[i-1][j-1]+dp[i][j])%MOD     

ans = (sum(map(sum, dp))+1)%MOD
print(ans)


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

int main()
{
	string s, t;
	cin >> s >> t;
	sort(s.begin(), s.end());
	sort(t.begin(), t.end());
	reverse(t.begin(), t.end());
	if (s < t) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
}

Measured memory_bytes: 256
main :: IO()
main = do
    [n] <- map read.words <$> getLine ::IO [Int]
    if n == 1
        then
            putStrLn("Hello World")
        else do
            [a] <- map read.words <$> getLine ::IO [Int]
            [b] <- map read.words <$> getLine ::IO [Int]
            print(a+b)

Measured memory_bytes: 508
module Enumerable
  def cum_sum
    inject([0]) { |a, n| a << (a.last + n) }
  end
end

n = gets.to_i
s = gets.chomp.chars

ws = s.map { |c| c.count 'W' }.cum_sum
es = s.map { |c| c.count 'E' }.cum_sum

p Array.new(n) { |i| ws[i] + es.last - es[i + 1] }.min


Measured memory_bytes: 39300
#include <iostream>

using namespace std;
typedef long long ll;

int A[1000000], G[20];
ll count = 0;

void insertionSort(int a[], int n, int g) {
    for (int i = g; i < n; ++i) {
        int v = a[i];
        int j = i - g;
        while (j >= 0 && a[j] > v) {
            a[j + g] = a[j];
            j -= g;
            count++;
        }
        a[j + g] = v;
    }
}

int shellSort(int a[], int n) {
    int m = 0;
    G[m] = 1;
    while (G[m++] <= n / 2) {
        G[m] = G[m - 1] * 2;
    }

    count = 0;
    for (int i = m - 1; i >= 0; --i) {
        insertionSort(a, n, G[i]);
    }
    return m;
}

int main() {
    int n;
    cin >> n;
    for (int i = 0; i < n; ++i) cin >> A[i];
    int m = shellSort(A, n);
    cout << m << endl;
    for (int i = m - 1; i > 0; --i) cout << G[i] << ' ';
    cout << G[0] << endl;
    cout << count << endl;
    for (int i = 0; i < n; ++i) cout << A[i] << endl;
    return 0;
}



Measured memory_bytes: 6984
import numpy as np
def piyo():
    s = np.array(list(input()),dtype=str)
    a = np.array(list(input()),dtype=str)
    for _ in s:
        s = np.roll(s, 1)
        if (s==a).all():
            print("Yes")
            return
    print("No")
        
if __name__ == '__main__':
    piyo()

Measured memory_bytes: 20740
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const long long INF = 1LL << 60;
const ll C = 1e9+7;

int main() {
    int N;
    cin >> N;
    map<int, int> M;
    for(int i=0; i<N; i++) {
        int x;
        cin >> x;
        M[x]++;
    }

    ll ans = 0;
    ll count = 0;
    for(auto m:M) {
        count += m.first;
        if(m.second > m.first) ans += m.second - m.first;
        if(m.second < m.first) ans += m.second;
    }
    cout << ans << endl;
}

Measured memory_bytes: 8136
#include<iostream>
#include<cstdio>
#define MN 100000
using namespace std;
inline int read()
{
	int x=0,f=1;char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
	return x*f;
}
int n,x[MN+5],pos,S,s,l=1,r;
long long p[MN+5],ans;
inline int Abs(int x){return x<0?-x:x;}
int main()
{
	r=n=read();S=read();
	for(int i=1;i<=n;++i) x[i]=read(),p[i]=read();
	for(int i=n;;--i) if(x[i]<S) {s=i;break;}
	for(int i=1;i<=n;++i)
		if(l<=s&&(r<=s||p[l]<p[r])) 
		{
			if(i>1) ans+=Abs(pos-x[l]);
			pos=x[l];p[r]+=p[l];++l;
		}
		else
		{
			if(i>1) ans+=Abs(pos-x[r]);
			pos=x[r];p[l]+=p[r];--r;
		}
	cout<<ans+Abs(pos-S);
	return 0;
}



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

#define rep(i,n) for(int i=0; i<n ; ++i)
#define REP(i,a,b) for(int i=a; i<b; ++i)
using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<ll>>;

//プロトタイプ宣言
void faster(void);
template <class T>
T gcd(T , T);
template <class T>
T get_digent(T);
template <class T>
T POW(T , T);
template <class T>
T vec_max(auto & , string);
template <class T>
T vec_min(auto & , string);

int n,m,ans,visited_num=0;

int a[100],b[100],visited[100];
int vec[100][100];


void dfs(int now){
  bool flag = true;
  visited[now]=1;
  for(int i=1;i<=n;i++){
    if(!visited[i]) flag = false;
  }
  if(flag){
    ans--;
    return;
  }
  for(int i=1;i<=n;i++){
    if(vec[now][i]){
      if(!visited[i]) dfs(i);
    }
  }
}

int main(){
  faster();
  cin >> n >> m;
  ans=m;
  rep(i,100)rep(j,100){
    vec[i][j]=0;
  }
  rep(i,m){
    cin >> a[i] >> b[i];
    vec[a[i]][b[i]]=1;
    vec[b[i]][a[i]]=1;
  }
  rep(i,m){
    vec[a[i]][b[i]]=0;
    vec[b[i]][a[i]]=0;
    dfs(1);
    rep(i,n+1) visited[i]=0;
    vec[a[i]][b[i]]=1;
    vec[b[i]][a[i]]=1;
  }
  cout << ans << endl;
}



























//同期解除
void faster(void){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
}

//ユークリッドの互除法
template <class T>
T gcd(T a, T b) {
  return (b ? gcd(b, a%b) : a);
} 

//桁数取得
template <class T>
T get_digent(auto x){
  string s;
  s = to_string(x);
  ll digent = s.size();
  return digent;
} 

//べき乗計算
template <class T>
T POW(T x, T y){
  if(y==0) return 1;
  if(y%2 == 1){
    ll temp = POW(x,y-1);
    return (temp*x);
  }
  else{
    ll temp = POW(x,y/2);
    return temp*temp;
  }
} 

//配列内の最大要素の添え字取得or要素取得
template <class T>
T vec_max(auto &v, string s){
  auto itr = max_element(v.begin(),v.end());
  ll element = *itr;
  ll place = itr - v.begin();
  if(s == "element") return element;
  else if(s == "place") return place;
  else return -1;
}

//配列内の最小要素の添え字取得or要素取得
template <class T>
T vec_min(auto &v, string s){
  auto itr = min_element(v.begin(),v.end());
  ll element = *itr;
  ll place = itr - v.begin();
  if(s == "element") return element;
  else if(s == "place") return place;
  else return -1;
}

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

using namespace std;

typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<bool> vb;
typedef pair<ll,ll> pll;
typedef vector<pll> vpll;


const ll mod=1e9+7;
const ll inf=1e16; 

#define rep(i,m,n) for(ll i=m;i<n;i++)
#define repr(i,m,n) for(ll i=m;i>=n;i--)


int main(){
   cin.tie(nullptr);
  ios::sync_with_stdio(false);
  
  ll n;
  cin >> n;
  vll p(n);
  rep(i,0,n) cin >> p[i];
  
  ll res=0;
  ll m=p[0];
  rep(i,0,n) {
    if(p[i]<=m) res++;
    m=min(m,p[i]);
  }

  cout << res << endl;
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
#include <string>
#define M 1e5+5
using namespace std;
int main()
{
int n,t,i=0,ws=0,cs=0;
vector <int> vc(M,0);
map<int, int> mw;
cin>>n>>t;
vector<pair<int, string> >p(t);
while(t--)	
{
	int x;
	string s;
	cin>>x >> s;
	p[i]=make_pair(x,s);
	i++;
}

for(auto it= p.begin();it!=p.end();it++)
{
    
    //cout<<it->first<<" "<<it->second<<endl;
	if(it->second=="AC")
	vc[it->first]++;
	
if(it->second=="WA")
mw[it->first]++;

if(it->second=="AC"&&vc[it->first]==1)
{
	cs++;
	ws+=mw[it->first];
}

}
cout<<cs<<" "<<ws;

	return 0;
}


Measured memory_bytes: 11520
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int k,a,b,i,f=0;
    cin>>k>>a>>b;
    for(i=a;i<=b;i++)
    {
        if(i%k==0)
        {
            f=1;
            break;
        }
    }
    if(f)
        cout<<"OK"<<endl;
    else
        cout<<"NG"<<endl;
}


Measured memory_bytes: 3604