akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <queue>
using namespace std;

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


int main(int argc, char* argv[]) {
	int n;
	string s;
	cin >> n >> s;

	set<int> r;
	set<int> g;
	set<int> b;

	for (int i = 0; i < n; i++) {
		switch (s[i])
		{
		case 'R':
			r.insert(i);
			break;
		case 'G':
			g.insert(i);
			break;
		case 'B':
			b.insert(i);
			break;

		default:
			break;
		}
	}

	ll cnt = 0;

	if (b.size() == 0) {
		cout << 0 << endl;
		return 0;
	}

	

	for (int ri : r) {
		for (int gi : g) {

			int c = b.size();
			int i = min(ri, gi);
			int j = max(ri, gi);
			
			
			if (b.find(2 * j -i) != b.end()) {
				c--;
			}

			if (b.find(2 * i - j) != b.end()) {
				c--;
			}

			if ((i + j) % 2 == 0 && b.find((i + j) / 2) != b.end()) {
				c--;
			}

			cnt += c;
			
		}
	}

	cout << cnt << endl;


}

Measured memory_bytes: 3668
#include <bits/stdc++.h>
#include <boost/range/algorithm.hpp>
#include <boost/range/numeric.hpp>
#include <boost/range/irange.hpp>
#include <boost/range/adaptor/indexed.hpp>

using namespace std;
using namespace boost::adaptors;
using namespace std::string_literals;
using ll = int64_t;
using vecint = vector<int>;
using vecll = vector<ll>;
using boost::irange;

int main()
{
  string s;
  cin>>s;
  int n=s.size();
  int hi = 1;
  int lo = 0;
  for(auto&& i:irange(0,n)) {
    int num = s[i] - '0';
    int nhi = min(hi + 9 - num, lo + num + 1);
    int nlo = min(hi + 10 - num, lo + num);
    hi = nhi;
    lo = nlo;
  }
  cout<<lo<<endl;
  return 0;
}


Measured memory_bytes: 1412
import std.stdio, std.string, std.conv, std.regex, std.algorithm, std.array;

immutable int L = 0;
immutable int U = 1;
immutable int D = 2;

int parseType( string type ) {
  switch( type ) {
  case "L": return L;
  case "U": return U;
  case "D": return D;
  default: return -1;
  }
}

int judgeType( string str ) {
  if ( count( "ABCDEFGHIJKLMNOPQRSTUVWXYZ", str[ 0..1 ] ) > 0 ) {
	return U;
  } else if ( count( str, "_" ) > 0 ) {
	return D;
  } else {
	return L;
  }
}

string convertTypeToD( string input, int type ) {
  switch( type ){
  case L:
	return toLower( replace( input, regex( "([A-Z])", "g" ), "_$1" ) );
  case U:
	return toLower( replace( input, regex( "([A-Z])", "g" ), "_$1" )[ 1..$ ] );
  default:
	return input;
  }
}

string frontUpper( string input ) {
  return toUpper( input[ 0..1 ] ) ~ input[ 1..$ ];
}

string convertTypeFromD( string input, int type ) {
  switch( type ) {
  case U:
	return join( array( map!( frontUpper )( std.string.split( input, "_" ) ) ), "" );
  case L:
	auto tokens = std.string.split( input, "_" );
	return tokens[ 0 ] ~ join( array( map!( frontUpper )( tokens[ 1..$ ] ) ), "" );
  default:
	return input;
  }
}

void main()
{
  while ( true ) {
	string[] input = std.string.split( strip( readln ) );
	if ( input[ 0 ] == "EndOfInput" && input[ 1 ] == "X" ) {
	  break;
	}
	immutable int typeTo = parseType( input[ 1 ] );
	immutable int type = judgeType( input[ 0 ] );
	
	if ( typeTo == type ) {
	  writeln( input[ 0 ] );
	} else {
	  string origin = convertTypeToD( input[ 0 ], type );
	  writeln( convertTypeFromD( origin, typeTo ) );
	}
  }
}

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

typedef long long ll;

vector<ll> score(int D, vector<ll> c, vector<ll> t, vector<vector<ll>> s) {
    vector<vector<ll>> last(D + 1, vector<ll>(26, 0));
    vector<ll> ret(D);
    ll p = 0;
    rep(d, D) {
        p += s[d][t[d] - 1];
        rep(i, 26) last[d + 1][i] = last[d][i];
        last[d + 1][t[d] - 1] = d + 1;
        rep(i, 26) {
            p -= c[i] * (d + 1 - last[d + 1][i]);
        }
        ret[d] = p;
    }
    return ret;
}

int main() {
    int D;
    cin >> D;
    vector<ll> c(26), t(D);
    rep(i, 26) cin >> c[i];
    vector<vector<ll>> s(D, vector<ll>(26)), last(D + 1, vector<ll>(26, 0));
    rep(i, D) rep(j, 26) cin >> s[i][j];
    ll p = 0;
    rep(d, D) {
        ll q, r = 0, maxq = -1e18;
        rep(j, 26) {
            q = s[d][j];
            rep(i, 26) last[d + 1][i] = last[d][i];
            last[d + 1][j] = d + 1;
            rep(i, 26) {
                q -= c[i] * (d + 1 - last[d + 1][i]);
            }
            if (q > maxq) {
                maxq = q;
                r = j;
            }
        }
        t[d] = r + 1;
        p += maxq;
        rep(i, 26) last[d + 1][i] = last[d][i];
        last[d + 1][r] = d + 1;
    }
    auto ans = score(D, c, t, s);
    ll maxs = ans.back();
    //cout << maxs << "\n";
    rep(i, D - 1) {
        swap(t[i], t[i + 1]);
        ans = score(D, c, t, s);
        if (ans.back() > maxs) {
            maxs = ans.back();
        } else {
            swap(t[i], t[i + 1]);
        }
    }
    rep(i, D) cout << t[i] << "\n";
}

Measured memory_bytes: 3996
#include <bits/stdc++.h>
#define rep(i,n)for(int i=0;i<(n);i++)
#define MOD 1000000007
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3f
#define EPS (1e-10)
using namespace std;
typedef long long ll;
typedef pair<int,int>P;

int h[200000];
signed main(){
	int n,k;cin>>n>>k;
	rep(i,n)scanf("%d",&h[i]);
	sort(h,h+n);
	int Min=INT_MAX;
	rep(i,n-k+1){
		Min=min(Min,h[i+k-1]-h[i]);
	}
	cout<<Min<<endl;
}

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

const ll INF=(1LL<<60);
const int mod=1000000007;

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

    cout << min(c,b/a) << endl;
}

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

int main() {
  string s, p;
  getline(cin, s);
  getline(cin, p);

  string flg = "No";
  rep(i, s.length()) {
    rep(j, p.length()) {
      if(s[(i + j) % s.length()] != p[j]) break;
      if(j == p.length() - 1) flg = "Yes";
    }
    if(flg == "Yes") break;
  }

  cout << flg << endl;
  return 0;
}



Measured memory_bytes: 3216
#include <cassert>
#include <cstdio>
#include <cmath>
#include <iostream>
#include <iomanip>
#include <sstream>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <numeric>
#include <algorithm>

using namespace std;
using lint = long long;
constexpr int MOD = 1000000007, INF = 1010101010;
constexpr lint LINF = 1LL << 60;

template <class T>
ostream &operator<<(ostream &os, const vector<T> &vec) {
	for (const auto &e : vec) os << e << (&e == &vec.back() ? "\n" : " ");
	return os;
}

#ifdef _DEBUG
template <class T>
void dump(const char* str, T &&h) { cerr << str << " = " << h << "\n"; };
template <class Head, class... Tail>
void dump(const char* str, Head &&h, Tail &&... t) {
	while (*str != ',') cerr << *str++; cerr << " = " << h << "\n";
	dump(str + (*(str + 1) == ' ' ? 2 : 1), t...);
}
#define DMP(...) dump(#__VA_ARGS__, __VA_ARGS__)
#else 
#define DMP(...) ((void)0)
#endif

int main() {

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

	int N;
	cin >> N;
	
	vector<int> A(N);
	for (int i = 0; i < N; i++) cin >> A[i];

	map<int, lint> mp;
	for (const auto &e : A) mp[e]++;

	lint sum = 0;
	for (const auto &e : mp) sum += e.second * (e.second - 1) / 2;

	for (int i = 0; i < N; i++) {
		int tmp = mp[A[i]];
		cout << sum - tmp * (tmp - 1) / 2 + (tmp -1)*(tmp-2)/2<< "\n";
	}

	return 0;
}

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

int main() {
  //リュカ数を作成する、配列でいいか
  //リュカの最初の２つは事前に入れておく
  //Nが入ってきたら、そこまで回す　N > > 2の場合、
  //
  int N;
  cin >> N;
  vector<long long> data(N+1);
  data.at(0) = 2;
  if (N == 1){
    data.at(1) = 1;
  }  
  else if (N >= 2){
	for(int i = 2; i <= N; i++){
      data.at(1) = 1;
      data.at(i) = data.at(i-1) + data.at(i-2);
      //cout << data.at(i) << endl;
    }  
  }
  cout << data.at(N) << endl;
  //printf("%ld", data.at(N));
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n - 1; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i <= n; i++)
#define FORR(i, m, n) for(int i = m; i >= n; i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define VSORTR(v) sort(v.rbegin(), v.rend());
#define ALL(v) (v).begin(),(v).end()
 
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<ll, ll>;

template<typename T> using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;
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; }

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

int main(){
	cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);

    ll n;
    cin >> n;
    ll a, res = 0;
    REP(i, n) {
        cin >> a;
        if (i % 2 == 0 && a % 2 == 1) res++;
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 3672
S = input()
K = int(input())
prev = S[0]
compressed = [[prev, 1]]
for c in S[1:]:
    if c == compressed[-1][0]:
        compressed[-1][1] += 1
    else:
        compressed.append([c, 1])
if len(compressed) == 1:
    print(len(S) * K // 2)
else:
    ans = sum(cnt // 2 for _, cnt in compressed) * K
    if S[0] == S[-1]:
        tmp = (compressed[0][1] + compressed[-1][1]) // 2
        tmp -= compressed[0][1] // 2
        tmp -= compressed[-1][1] // 2
        ans += tmp * (K - 1)
    print(ans)


Measured memory_bytes: 3064
#include<iostream>
#include<algorithm>
#include<vector>
#include<cstring>
#include<cmath>
#define ll long long

using namespace std;


int main()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
 ll int a,b,max,c,d,p;
 cin>>a>>b;
 p=a*b;
 c=a+b;
 d=a-b;
 if(p>c && p>d)
 {
     max=p;
 }
 else if(c>p && c>d)
 {
     max=c;
 }
 else
 {
     max=d;
 }
 cout<<max<<endl;
     return 0;
}

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

using namespace std;

int main(){
    int n,m;
    cin>>n>>m;
    
    int c1=0;
    int c2=0;
    
    if(n+m==2)
        cout<<0<<endl;
    else{
        if(n>=2)
            c1=n*(n-1)/2;
        if(m>=2)
            c2=m*(m-1)/2;
        cout<<c1+c2<<endl;
    }
}

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

#define MAXN 2000
int N,X;
int Cost[MAXN+5],Change[MAXN+5][MAXN+5];

int main(){
    scanf("%d%d",&N,&X);
    for(int i=1;i<=N;i++)
        scanf("%d",Cost+i);
    long long Ans=1ll<<60,tot=0;
    for(int i=1;i<=N;i++)
        tot+=Change[i][0]=Cost[i];
    Ans=min(Ans,tot);
    for(int k=1;k<N;k++){
        tot=0;
        for(int i=1;i<=N;i++)
            tot+=Change[i][k]=min(Change[i][k-1],Cost[i-k<1?N+i-k:i-k]);
        Ans=min(Ans,1ll*k*X+tot);
    }
    printf("%lld",Ans);
}


Measured memory_bytes: 15872
#include <cstdlib>
#include <iostream>
#include <numeric>
#include <vector>
using namespace std;

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

	for(int n, m; cin >> n >> m, n;) {
		vector<int> taro(n), hanako(m);
		for(int i = 0; i < n; ++i)
			cin >> taro[i];

		for(int i = 0; i < m; ++i)
			cin >> hanako[i];

		const int taro_sum = accumulate(taro.begin(), taro.end(), 0);
		const int hanako_sum = accumulate(hanako.begin(), hanako.end(), 0);
		const int dif = taro_sum - hanako_sum;

		int a = -1, b, mn = 200;
		for(int i = 0; i < n; ++i) {
			for(int j = 0; j < m; ++j) {
				if(mn > taro[i] + hanako[j] && dif == (taro[i] - hanako[j]) * 2) {
					a = taro[i];
					b = hanako[j];
					mn = a + b;
				}
			}
		}

		if(a == -1)
			cout << -1 << endl;
		else
			cout << a << " " << b << endl;
	}

	return EXIT_SUCCESS;
}

Measured memory_bytes: 1196
import Data.Array.ST
import Data.Array.Unboxed
import Data.Array.IArray
import Control.Monad
import Control.Monad.ST
main = interact $ unlines.map (show.countPrimeUnder.read).words

prime = sieve 999999

sieve :: Int -> UArray Int Bool
sieve n = runSTUArray $ do
    t <- newArray (0,n) True
    writeArray t 0 False
    writeArray t 1 False
    sequence_ [writeArray t i False | i <- [4,6..n]]
    let sqn = (floor.sqrt.fromIntegral) (n::Int)
    sequence_ (actions t sqn n)
    return t

actions :: STUArray s Int Bool -> Int -> Int -> [ST s ()]
actions t k m = [readArray t i >>= (flip when) (writeArray t j False) | i <- [3,5..k],j <- [i*i,i*(i+2)..m]]

countPrimeUnder :: Int -> Int
countPrimeUnder n = countUp n 0 0 prime

countUp :: Int -> Int -> Int -> UArray Int Bool -> Int
countUp n i acc arr = if i > n then acc
                               else if arr ! i == True then countUp n (i+1) (acc+1) arr
                                                       else countUp n (i+1) acc     arr

Measured memory_bytes: 10288
#include<stdio.h>

int a[30];
int n;

int solve(int p, int b)
{
    if (p == n)
        if (b == 0) return 1;
        else return 0;
    if (solve(p+1, b-a[p]) || solve(p+1, b)) return 1;
    else return 0;
}

int main()
{
    int q;
    int m;
    scanf("%d", &n);
    for (int i = 0; i < n; i++) scanf("%d", a+i);
    scanf("%d", &q);
    for (int i = 0; i < q; i++) 
        if (solve(0, (scanf("%d", &m), m))) printf("yes\n");
        else printf("no\n");
    return 0;
}



Measured memory_bytes: 2124
h, w = gets.chomp.split(" ").map(&:to_i)
n = gets.chomp.to_i
a = gets.chomp.split(" ").map(&:to_i)

ans = Array.new(h).map{Array.new(w)}
ptr_h = 0
ptr_w = 0

a.each_with_index do |color_num, i|
    color_num.times do
        ans[ptr_h][ptr_w] = i+1
        if ptr_h % 2 == 0 then
            ptr_w += 1
        else
            ptr_w -= 1
        end
        if w <= ptr_w then
            ptr_h += 1
            ptr_w -= 1
        end
        if 0 > ptr_w then
            ptr_h += 1
            ptr_w += 1
        end
    end
end

ans.each do |res|
    puts res.join(" ")
end

Measured memory_bytes: 2428
#include <vector>
#include <iostream>
#include <algorithm>
#include <functional>
#include <string>
#include <limits.h>
#include <cmath>
#include <queue>
#include <map>
#include <iomanip>
#include <random>
#include <fstream>
#include <cassert>
#define rep(i, n) for (int i = 0; i < n; i++)
#define PI 3.14159265358979323846
#define MOD 1000000007
#define vi vector<int>
using namespace std;
using ll = long long;

// ----ここから下は以前競プロをやっていた時に使っていたものです----　

const int MAX = 1000000;

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

// テーブルを作る前処理
void COMinit() {
  fac[0] = fac[1] = 1;
  finv[0] = finv[1] = 1;
  inv[1] = 1;
  for (int i = 2; i < MAX; i++){
    fac[i] = fac[i - 1] * i % MOD;
    inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
    finv[i] = finv[i - 1] * inv[i] % MOD;
  }
}

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

ll gcd(ll a, ll b)
{
  ll r;
  while ((r = a % b))
  {
    a = b;
    b = r;
  }
  return b;
}

template <class T> struct cord{
  T x,y;
};

template <class T> double dist(cord<T> a, cord<T> b){
  T dx=a.x-b.x;
  T dy=a.y-b.y;
  return sqrt(dx*dx+dy*dy);
}

struct s{
  int p,i,r;
};

//比較関数（降順）
bool cmpP(const s &a, const s &b){
  return a.p > b.p;
}

//比較関数（昇順）
bool cmpI(const s &a, const s &b){
  return a.i < b.i;
}

// ----本問について----
// 問題：0-1ナップサック問題
// 問題文URL：https://onlinejudge.u-aizu.ac.jp/problems/DPL_1_B
// 所要時間：
// 学んだこと：
// ------------------

// ----ここから本問のソースコード----

// グローバル変数（入力）
ll N,W,v[110],w[110],V[110][10010];

ll solve(ll i, ll c) {
  if (V[i][c]!=-1){ return V[i][c]; }

  if (i==0 || c==0) {V[i][c]=0;}
  else if (c-w[i]<0) {V[i][c]=solve(i-1,c);}
  else {V[i][c]=max(v[i]+solve(i-1,c-w[i]), solve(i-1, c));}

  return V[i][c];
}

int main()
{
  //cout << fixed << setprecision(10);
  cin >> N >> W;
  rep(i,N){
    cin >> v[i+1] >> w[i+1];
  }
  rep(i,110){
    rep(j,10010){
      V[i][j]=-1;
    }
  }
  cout << solve(N,W) << endl;

  return 0;
}



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

using namespace std;

int main(int argc, char *argv[]){
  char c[27];
  for (int i = 0; i < 26; i++) {
    c[i] = 'A' + i;
  }
  string s;
  cin >> s;
  for (int i = 0; i < s.length(); i++) {
    std::cout << c[(s[i] - 'A' + 23) % 26];
  }
  std::cout << std::endl;
  return 0;
}

Measured memory_bytes: 1176
#include<bits/stdc++.h>
using namespace std;
#define ALL(x) x.begin(),x.end()
#define rep(i,n) for(int i=0;i<n;i++)
#define debug(v) cout<<#v<<":";for(auto x:v){cout<<x<<' ';}cout<<endl; 
#define INF 1000000000
#define mod 1000000007
typedef long long ll;
const ll LINF = 1001002003004005006ll;
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
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; }


ll dp[100100][13];
signed main(){
    cin.tie(0);
    ios::sync_with_stdio(0);
    
    string s;
    cin>>s;
    ll n=(ll)s.size();
    dp[0][0]=1;
    for(int i=0;i<n;i++){
        if(s[i]!='?'){
            int num=s[i]-'0';
            for(int j=0;j<13;j++){
                dp[i+1][(10*j+num)%13]+=dp[i][j];
                dp[i+1][(10*j+num)%13]%=mod;
            }
        }
        else{
            for(int num=0;num<10;num++)for(int j=0;j<13;j++){
                dp[i+1][(10*j+num)%13]+=dp[i][j];
                dp[i+1][(10*j+num)%13]%=mod;
            }
        }
    }
    cout<<dp[n][5]<<endl;
    return 0;
}


Measured memory_bytes: 10704
#include<iomanip>
#include<limits>
#include<thread>
#include<utility>
#include<iostream>
#include<string>
#include<algorithm>
#include<set>
#include<map>
#include<vector>
#include<stack>
#include<queue>
#include<cmath>
#include<numeric>
#include<cassert>
#include<random>
#include<deque>
using namespace std;
typedef unsigned long long int ull;
typedef long long int ll;
const int error=1e9+7;
#define F first
#define S second
#define MK make_pair

typedef vector<ll> cake;



int main(){
    vector<cake> c[2][2][2];
    int n,m;
    cin>>n>>m;
    for(int i=0;i<n;i++){
        ll x,y,z;
        cin>>x>>y>>z;
        c[1][1][1].push_back({x+y+z,x,y,z});
        c[0][0][0].push_back({-(x+y+z),x,y,z});
        c[0][1][1].push_back({-x+y+z,x,y,z});
        c[1][0][1].push_back({x-y+z,x,y,z});
        c[1][1][0].push_back({x+y-z,x,y,z});
        c[0][0][1].push_back({-x-y+z,x,y,z});
        c[1][0][0].push_back({x-y-z,x,y,z});
        c[0][1][0].push_back({-x+y-z,x,y,z});
    }
    ll mx=0;
    for(int i=0;i<2;i++){
        for(int t=0;t<2;t++){
            for(int h=0;h<2;h++){
                ll a[4]={};
                sort(c[i][t][h].begin(),c[i][t][h].end());
                reverse(c[i][t][h].begin(),c[i][t][h].end());
                for(int l=0;l<m && l<n;l++){
                    for(int k=1;k<4;k++){
                        a[k]+=c[i][t][h][l][k];
                    }
                }
                ll M=0;
                for(int k=1;k<4;k++){
                    M+=abs(a[k]);
                }
                mx=max(mx,M);
            }
        }
    }
    cout<<mx<<endl;
    
    return 0;
}

Measured memory_bytes: 768
#include<bits/stdc++.h>
using namespace std;
#define all(a)  (a).begin(),(a).end()
typedef long long ll;
ll mod=1000000007;

int main() {
  int a,b;cin >> a >>b;
  if(a>=13){
    cout << b << endl;
  } else if(a>=6){
    cout << b/2 << endl;
  } else {
    cout << 0 << endl;
  }
  return 0;
}


Measured memory_bytes: 256
let _ = readLine()
let inputs: Array<Int> = readInts()
let nums = Dictionary<Int, Int> { dic in
    // O(n^2)
    for i in inputs {
        dic[i] = inputs.filter({ $0 == i }).count
    }
}
let ls = Array(nums.keys).sorted()


var result = 0

for ai in ls.indices.reversed() {
    let a = ls[ai]
    let ac = nums[a]
    for bi in ls[..<ai].indices.reversed() {
        let b = ls[bi]
        let bc = nums[b]
        for ci in ls[..<bi].indices.reversed() {
            let c = ls[ci]
            let cc = nums[c]
            
            if b + c > a {
                result += ac! * bc! * cc!
            }
        }
    }
}

print(result)



// MARK: -----------------------------------------------------------------------


func readInt() -> Int {
    Int(readLine()!)!
}

func readInts() -> [Int] {
    readLine()!.split(separator: " ").map { Int($0)! }
}

extension Collection {
    func mapToTuple() -> (Element, Element) {
        var i = makeIterator()
        return (i.next()!, i.next()!)
    }
    func mapToTuple() -> (Element, Element, Element) {
        var i = makeIterator()
        return (i.next()!, i.next()!, i.next()!)
    }
    func mapToTuple() -> (Element, Element, Element, Element) {
        var i = makeIterator()
        return (i.next()!, i.next()!, i.next()!, i.next()!)
    }
    
    func safe(at index: Index) -> Element? {
        self.indices.contains(index) ? self[index] : nil
    }
}

struct DP<Argument: Hashable, Element> {
    var dictionary = [Argument: Element]()
    
    var expression: (Argument, (Argument) -> Element) -> Element
    
    init(expression: @escaping (_ argument: Argument, _ note: (Argument) -> Element) -> Element) {
        self.expression = expression
    }
    
    subscript(_ argument: Argument) -> Element {
        mutating _read {
            if let note = dictionary[argument] {
                yield note
            } else {
                let result = expression(argument) { self[$0] }
                dictionary[argument] = result
                yield result
            }
        }
    }
}

extension Dictionary {
    init(_ initialize: (inout Self) -> ()) {
        var dictionary = Self()
        initialize(&dictionary)
        self = dictionary
    }
}


Measured memory_bytes: 8480
#include<stab.h>

int selectionSort(int A[], int N) {
    int i, j, t, sw = 0, minj;
    for (i = 0; i < N - 1; i++) {
        minj = i;
        for (j = i; j < N; j++) {
            if (A[j] < A[minj]) minj = j;
        } 
        t = A[i]; A[i] = A[minj]; A[minj] = t;
        if (i != minj) sw++;
    }
    return sw;
}

int main() {
    int A[100], N, i, sw;

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

    sw = selectionSort(A, N);

    for (i = 0; i < N; i++) {
        if (i > 0) printf(" ");
        printf("%d", A[i]);
    }
    printf("\n");
    printf("%d\n", sw);

    return 0;
}


Measured memory_bytes: 2128
n,x=map(int,input().split())
*a,=map(int,input().split())

v=[i if i<x else x for i in a]

for i in range(n-1):
    if v[i]+v[i+1]>x:
        v[i+1]=x-v[i]

print(sum(a)-sum(v))

Measured memory_bytes: 14540
#include<bits/stdc++.h>
using namespace std;
#define rep(i,j,n) for(int i=(int)(j);i<(int)(n);i++)
#define REP(i,j,n) for(int i=(int)(j);i<=(int)(n);i++)
#define MOD 1000000007
#define int long long
#define ALL(a) (a).begin(),(a).end()
#define vi vector<int>
#define vii vector<vi>
#define pii pair<int,int>
#define priq priority_queue<int>
#define disup(A,key) distance(A.begin(),upper_bound(ALL(A),(int)(key)))
#define dislow(A,key) distance(A.begin(),lower_bound(ALL(A),(int)(key)))
#define tii tuple<int,int,int>
signed main(){
  int N,M; cin>>N>>M;
  vii A(N);
  string ans="IMPOSSIBLE";
  rep(i,0,M){
    int X,Y; cin>>X>>Y;
    A[X-1].push_back(Y-1);
  }
  queue<int> Q;
  vector<bool> C(N,1);
  C[0]=0;
  Q.push(0);
  Q.push(-1);
  int count=0;
  while(1){
    int K=Q.front();
    Q.pop();
    if(K==N-1){
      ans="POSSIBLE";
      break;
    }
    if(K==-1){
      count++;
      if(count==3)
        break;
      Q.push(-1);
    }
    else{
      rep(i,0,A[K].size()){
        Q.push(A[K][i]);
        C[A[K][i]]=0;
      }
    }
    if(Q.size()==0)
      break;
  }
  cout<<ans<<endl;
  }




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

int main()
{
	int n;
	cin >> n;
	vector<long long> a(n);
	for (auto i = 0; i < n; ++i)
	{
		cin >> a[i];
	}

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

	auto left = *a.rbegin();
	auto mid = (double)left / 2;
	auto right = -1ll;
	auto m = 1e9;
	for (auto i = 0; i < a.size() - 1; ++i)
	{
		auto temp = a[i];
		auto diff = abs(temp - mid);
		if (diff < m)
		{
			right = temp;
			m = diff;
		}
	}

	cout << left << " " << right << endl;

	return 0;
}


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

using namespace std;

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

typedef long long ll;
typedef long double ld;

const ll Inf = 1e18;
const double EPS = 1e-9;
const int MOD = 1e9 + 7;

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(0);
    int n, cnt = 0;;
    cin >> n;
    double res = 0;
    vector<int> x(n), y(n), num(n);
    rep (i, n) {
        cin >> x[i] >> y[i];
        num[i] = i;
    }
    do {
        cnt++;
        double dist = 0;
        rep (i, n - 1) {
            double dx = x[num[i]] - x[num[i + 1]], dy = y[num[i]] - y[num[i + 1]];
            dist += sqrt(dx * dx + dy * dy);
        }
        res += dist;
    } while (next_permutation(num.begin(), num.end()));
    cout << fixed << setprecision(7);
    cout << res / cnt << endl;
    
    return 0;
}



Measured memory_bytes: 256
from functools import reduce

def gcd(a, b):
    while b:
        a, b = b, a % b
    return a

def lcm(x, y):
    # saisyou koubaisuu
    return (x * y) // gcd(x, y)

def lcm_list(numbers):
    return reduce(lcm, numbers)

n = int(input())
a = list(map(int, input().split()))

print(lcm_list(a))


Measured memory_bytes: 6280
import java.util.Scanner;

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

        int N = sc.nextInt();
        int M = sc.nextInt();
        int[] L = new int[M];
        int[] R = new int[M];

        for(int i = 0; i < M; i++){
            L[i] = sc.nextInt();
            R[i] = sc.nextInt();
        }

        int maxL = L[0];
        int minR = R[0];

        for(int i = 0; i < M; i++){
            if(maxL < L[i])
                maxL = L[i];
            if(minR > R[i])
                minR = R[i];
        }
        
        if(minR - maxL + 1 > N){
            System.out.println(N);
        }else if(minR - maxL + 1 <= 0){
            System.out.println("0");
        }else{
            System.out.println(minR - maxL + 1);
        }


    }
}

Measured memory_bytes: 64864
#include <bits/stdc++.h>
#define ll long long int
#define yorn(f) cout<<((f)?"Yes":"No")<<endl;
#define YORN(f) cout<<((f)?"YES":"NO")<<endl;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repi(i, n) for (int i = 1; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define put(x) cout << x << endl;
#define println(x) cout << x << endl;
using namespace std;
int main()
{
    string s;
    cin >> s;
    unordered_set<char> us;
    rep(i, s.size()) us.emplace(s[i]);
    for (int ch = 'a'; ch <= 'z'; ch++) {
        if (us.count(ch) <= 0) {
            put((char)ch)
            return 0;
        }
    }
    
    put("None")
    return 0;
}

Measured memory_bytes: 3704
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <iostream>
#include <map>
#include <queue>
#include <deque>
#include <string>
#include <stack>
#include <vector>
#include <set>
#include <tuple>
#include <utility>
#include <functional>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef tuple<int,int,int> T;
const int INF = 1000000000;
const int MOD = 1000000007;
int main(){
	ll x,y;
	cin >> x >> y;
	ll ans = 1e18;
	if(y > x)ans = min(ans,y-x);
	ans = min(ans,abs(y+x)+1LL);
	ans = min(ans,abs(x-y)+2LL);

	cout << ans << endl;
}


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

#define dump(n) cout<<"# "<<#n<<'='<<(n)<<endl
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define peri(i,a,b) for(int i=int(b);i-->int(a);)
#define rep(i,n) repi(i,0,n)
#define per(i,n) peri(i,0,n)
#define all(c) begin(c),end(c)
#define mp make_pair
#define mt make_tuple

typedef unsigned int uint;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<string> vs;

const int INF=1e9;
const int MOD=1e9+7;
const double EPS=1e-9;

template<typename T1,typename T2>
ostream& operator<<(ostream& os,const pair<T1,T2>& p){
	return os<<'('<<p.first<<','<<p.second<<')';
}
template<typename T>
ostream& operator<<(ostream& os,const vector<T>& a){
	os<<'[';
	rep(i,a.size()) os<<(i?" ":"")<<a[i];
	return os<<']';
}

inline bool ok(int w,const vi& sum,int sp)
{
	int n=sum.size()-1;
	
	vi dp(n+1); dp[0]=1;
	int l=0,r=0,cnt=0;
	rep(i,n){
		for(;l<i;cnt-=!!dp[l++]) if(sum[i+1]-sum[l]+(i-l)<=w) break;
		for(;r<i;cnt+=!!dp[r++]) if(sum[i+1]-sum[r]+(i-r)*sp<w) break;
		dp[i+1]=!!cnt;
	}
	
	int res=dp[n];
	for(int i=n;i--;){
		if(sum[n]-sum[i]+(n-i-1)>w) break;
		res|=dp[i];
	}
	return res;
}

int main()
{
	for(int w,n;~scanf("%d%d",&w,&n) && w|n;){
		vi xs(n);
		rep(i,n) scanf("%d",&xs[i]);
		
		vi sum(n+1);
		rep(i,n) sum[i+1]=sum[i]+xs[i];
		
		int lo=1,hi=w;
		while(lo<hi){
			int mi=(lo+hi)/2;
			if(ok(w,sum,mi))
				hi=mi;
			else
				lo=mi+1;
		}
		printf("%d\n",lo);
	}
}

Measured memory_bytes: 1736
def main():
	k,a,b = map(int, input().split())
	ans = a
	if a + 1 < b:
		if k < a + 1:
			print(k+1)
			return
		k = k-a+1
		ans += (b-a)*int(k/2)
		print(ans + k%2)
		return
	else:
		print(k+1)

main()




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

using namespace std;

#include <vector>
#include <list>
#include <cstring>
#include <cmath>
#define scan(x) scanf("%d", &x)
#define scanl(x) scanf("%lld", &x)
#define PI 3.14159265358979323846

void printarray(int* arr, int n){
	for(int i=0;i<n;i++){
		printf("%d ", arr[i]);
	}
	printf("\n");
}

void printvector(vector <int> A){
	for(auto i=A.begin();i!=A.end();i++){
		cout<<*i<<" ";
	}
	cout<<endl;
}

int main(){

	#ifndef ONLINE_JUDGE
    	freopen("D:/Programming/input.txt", "r", stdin);
    	freopen("D:/Programming/output.txt", "w", stdout);
	#endif

	string S,T;
	cin>>S>>T;
	T.pop_back();
	if(S==T)cout<<"Yes";
	else cout<<"No";

	return 0;
}

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

using namespace std;

int main() {
    string s1, s2, s3, res;
    cin >> s1 >> s2 >> s3;
    res += s1[0];
    res += s2[0];
    res += s3[0];
    for (int i = 0; i < res.length(); i++) {
        res[i] = (char) (toupper(res[i]));
    }
    cout << res << endl;
    return 0;
}

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

using namespace std;

int a,b,ans,p,q;

int main(){
  cin>>a>>b;
  for(int i=b;i>=10;i++){
    i/=10;
    p++;
  }
  for(int i=0;i<=p;i++){
    a*=10;
  }
  ans=a+b;

  for(int i=1;i*i<=ans;i++){
    if(i*i==ans){
      cout<<"Yes"<<endl;
      return 0;
    }
  }
  cout<<"No"<<endl;
}


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

using namespace std;

#define MIN(a,b) ((a)<(b)?(a):(b))
#define INF (100000000000000000LL)

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

    vector<long long> ti;

    ti.push_back(0);
    for(int i=0; i<N-1; ++i) {
        int temp;
        cin >> temp;
        ti.push_back(temp);
    }
    ti.push_back(0);
    
    long long dp[2][N+1];
    dp[0][0]=0;

    for(int i=1; i<=N/2; ++i) {
        for(int j=0; j<=2*i; ++j) {
            if(j-2>=0) {
                dp[i%2][j]=MIN(dp[(i-1)%2][j-2],dp[(i-1)%2][2*(i-1)-(j-2)]+ti[2*(i-1)]);
            } else {
                dp[i%2][j]=INF;
            }
            if(j-1>=0) {
                dp[i%2][j]=MIN(dp[i%2][j],dp[(i-1)%2][j-1]+ti[2*(i-1)]+ti[2*i-1]);
                dp[i%2][j]=MIN(dp[i%2][j],dp[(i-1)%2][2*(i-1)-(j-1)]+ti[2*i-1]);
            }
            if(j==0) dp[i%2][j]=ti[2*i];
       }
    }

    cout << dp[(N/2)%2][N/2] << endl;

    return 0;
}


Measured memory_bytes: 3420
import java.util.*;

public class Main {

	public static void main(String[] args) {

		// 入力
		Scanner sc = new Scanner(System.in);
		long n = Long.parseLong(sc.next());
		long a[];
		a = new long[5];
		a[0] = Long.parseLong(sc.next());
		a[1] = Long.parseLong(sc.next());
		a[2] = Long.parseLong(sc.next());
		a[3] = Long.parseLong(sc.next());
		a[4] = Long.parseLong(sc.next());

		// 最も輸送人数の少ない乗り物の、輸送人数をminとする
		long min = a[0];
		for (int i = 1; i <= 4; i++) {
			if (a[i] < min) {
				min = a[i];
			}
		}

		// min人ずつ流すので
		System.out.println((long) ((n - 0.1) / min) + 5);

	}
}


Measured memory_bytes: 35572
#include<cstdio>  
#include<cmath>  
#include<iostream>  
#include<cstring>  
#include<iostream>  
#include<cstdlib>  
#include<string>  
using namespace std;  
#define LL long long   
const int MaxN = 1e5 + 7;  
LL a[MaxN], b[MaxN];    
LL x[MaxN], v[MaxN];  
  
int main()  
{  
    LL n, c;  
    scanf("%lld %lld", &n, &c);  
    for(int i = 1; i <= n; i++)   
        scanf("%lld %lld", &x[i], &v[i]);  
      
    for(LL i = 1; i <= n; i++)   
        a[i] = a[i - 1] + v[i] - (x[i] - x[i - 1]);  // 顺时针走到i点时的能量  
    x[n + 1] = c;  
    for(LL i = n; i >= 1; i--)   
        b[i] = b[i + 1] + v[i] - (x[i+1] - x[i]);  // 逆时针走到i点时的能量  
  
    for(LL i = 2; i <= n; i++)   
        a[i] = max(a[i-1], a[i]);  //走或者不走（和走之前的值进行比较）  
    for(LL i = n-1; i >= 1; i--)   
        b[i] = max(b[i], b[i + 1]);  
  
    LL ans = 0;  
    for(LL i = 1; i <= n; i++) {  
        ans = max(ans, a[i] - x[i] + b[i + 1]);  // 顺时针走后并返回一次的值  
        ans = max(ans, b[i] - (c - x[i]) + a[i - 1]);  // 逆时针走后返回一次的值  
        ans = max(ans, a[i]);  // 顺时针的最大值  
        ans = max(ans, b[i]); //逆时针的最大值  
    }  
  
    printf("%lld\n", ans);  
} 

Measured memory_bytes: 3456
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		int N;
		long M;
		Scanner sc = new Scanner(System.in);
		N = sc.nextInt();
		M = sc.nextInt();
		long[] a = new long[(int) N];
		double check = 0;
		for (int i = 0; i < N; i++) {
			a[i] = sc.nextLong();
			check += a[i];
		}
		;
		check = check / 4f / M;
		int count = 0;
		while (N - 1 >= 0) {
			count += (a[N - 1] >= check) ? 1 : 0;
			N--;
		}
		System.out.println(count >= M ? "Yes" : "No");
	}
}

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

#define debug(x) cout << '>' << #x << ':' << x << endl;
#define loop0(i,n) for(int i=0; i<(n); i++)
#define loop1(i,n) for(int i=1; i<=(n); i++)
#define fori(a,b,i) for(int i=(a); i<=(b); i++)
#define ford(a,b,i) for(int i=(a); i>=(b); i--)
#define fast_io ios_base::sync_with_stdio(false), cin.tie(NULL)
#define ign cin.ignore(numeric_limits<streamsize>::max(),'\n')

#define INF 0x3f3f3f3f
#define PI 3.1415926535897932384626433832795
#define MOD 1000000007
#define endl "\n"
#define fir first
#define sec second
#define pb push_back
#define mp make_pair

typedef long long int ll;
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<vector<int>> MAT;
typedef vector<ll> VL;
typedef vector<string> VS;
typedef vector<PII> VII;
typedef vector<VI> VVI;
typedef map<int,int> MII;
typedef map<int,int> MCI;
typedef unordered_map<int,int> UMII;
typedef unordered_map<ll,ll> UMLL;
typedef unordered_map<char,int> UMCI;
typedef set<int> SI;
typedef unordered_set<int> USI;

// Display Map
//~for (auto const& pair: m) {
//~std::cout << "{" << pair.first << ": " << pair.second << "}\n";
//~}

// Extract word(w) from sentence(s)
//~stringstream str(s);
//~string w;
//~while(str >> w){
//~// w is your word
//~}

//Memset Syntax
// memset(array, value,sizeof(array)) val is 0,-1 or bool only

// To get accurate precision
//~cout.precision(20);

// Concatinate Vectors
//~

//~Vector of size n*m with zero
//~vector<vector<int> > vec( n , vector<int> (m, 0));



int main() {
    fast_io;
    int n;
    cin >> n;
    VI v(101);
    int f = 0;
    for(int i = 0; i < n; i++) {
        int a,b;
        cin >> a >> b;
        v[i] = a-b;
    }
    //~for(auto &i: v) cout << i << " ";
    //~cout << endl;
    for(int i = 0; i < n-2; i++) {
        if(v[i] == 0 and v[i+1] == 0 and v[i+2] == 0) {
            cout << "Yes" << endl;
            f = 1;
            break;
        }

    }
    if(!f) cout << "No" << endl;
}



Measured memory_bytes: 3652
use proconio::input;

#[allow(unused_imports)]
use std::collections::HashSet;

use std::cmp;


fn main() {
    input! {
        n: usize,
        k: usize,
    }
    solve(n, k);
}

fn prepare(m: usize, k: usize, p :u64) -> Vec<Vec<u64>> {
    let mut v : Vec<Vec<u64>> = Vec::<Vec<u64>>::with_capacity(m + 1);
    let v0 : Vec<u64> = vec![1; 1];
    v.push(v0);
    for i in 1..m+1 {
        let jmax = cmp::min(i, k);
        let mut vi : Vec<u64> = vec![0; jmax+1];
        for j in 0..jmax+1 {
            vi[j] = 
            if j == 0 || j==i {
                1
            } else {
                (v[i-1][j-1] + v[i-1][j]) % p
            };
            if i-j <= jmax {
                vi[i-j] = vi[j];
            }
        }
        v.push(vi);
    }
    return v;
}

fn solve(n: usize, k: usize) {
    let p : u64 = (10u32.pow(9u32) + 7) as u64;

    // 1. Calculate values of combinations
    let m = cmp::max(k-1, n-k+1);
    let c = prepare(m, k, p);

    // 2. Calculate possible ways
    for i in 1..k+1 {
        let b = c[k-1][i-1];
        let r = if i > n-k+1 { 
            0
        } else {
            c[n-k+1][i]
        };
        let t = b * r % p;
        println!("{}", t);
    }
}


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

typedef long long ll;

int main() {
    int N;
    int ans, cost;
    string S;
    int count=0;
    vector<int>left;
    vector<int>right;

    cin >> N;
    cin >> S;

    for (int i = 0; i < N; i++) {
        left.push_back(count);
        if (S[i] == 'W') {
            count++;
        }
    }
    count = 0;
    for (int i = N-1; i >= 0; i--) {
        right.push_back(count);
        if (S[i] == 'E') {
            count++;
        }
    }

    ans = N;
    for (int i = 0; i < N; i++) {
        cost = left[i]+right[N-i-1];
        ans = min(ans, cost);
    }
    cout << ans << endl;
}


Measured memory_bytes: 4728
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector< int > vi;
typedef vector< vi > vvi;
typedef pair< int,int > pi;
typedef pair< ll,ll > pll;
typedef vector <pi> vii;
typedef vector < ll > vll;
typedef vector< vll > vvll;
#define sz(a) int((a).size())
#define pb push_back
#define all(c) (c).begin(),(c).end()
#define tr(c,i) for(auto i = (c).begin(); i != (c).end(); i++)
#define present(c,x) (c.find(x) != c.end())
#define cpresent(c,x) (find(all(c),x) != c.end())
#define REP(i,a,b) for(int i =a;i<b;i++)


int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	map <string , ll > votes;
	string a;
	int size;
	cin >> size;
	ll ans =0;
	REP(i,0,size){
		cin >> a;
		auto it = votes.find(a);
		if(it != votes.end()){
			votes[a]++;
		}
		else{
			votes[a]=1;
		}
		
	}
	tr(votes,it){
		ans=max(ans,(*it).second);
	}
	tr(votes,it){
		if(ans==(*it).second){
			cout << (*it).first << "\n";
			}
	}
	
	
	
	return 0;
}


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

int main()
{
    int minute,zi1, hun1, zi2, hun2, naga;
    cin >> zi1 >> hun1 >> zi2 >> hun2 >> naga;

    minute = zi2*60 + hun2 - (zi1 * 60 + hun1);
    cout << minute - naga << endl;
}


Measured memory_bytes: 3636
import string
import bisect
s=input()
t=input()
S=[[] for _ in range(26)]
a=string.ascii_lowercase
now=-1
ans=-1
count=0
for i in range(len(s)):
    for j in range(26):
        if s[i]==a[j]:
            S[j].append(i)
            break
for i in range(len(t)):
    for j in range(26):
        if t[i]==a[j]:
            break
    if len(S[j])==0:
        break
    nex=bisect.bisect_right(S[j],now)
    if nex==len(S[j]) or now>=S[j][nex]:
        count+=1
        now=S[j][0]
    else:
        now=S[j][nex]
    if i==len(t)-1:
        ans=count*(len(s))+now+1
print(ans)

Measured memory_bytes: 14264
var input = require('fs').readFileSync('/dev/stdin', 'utf8');
var arr= input.trim().split("\n");
var str = arr[1];
var max=1;
str.replace(/ /g,"").replace(/1+/g,function(s){
   max=Math.max(s.length+1,max);
});
console.log(max);


Measured memory_bytes: 19216
x, k, d = [int(i) for i in input().split(' ')]

x = abs(x)
if k <= int(x / d):
    print(x - (k*d))
else:
    t = (k - int(x / d)) % 2
    if t == 0:
        print(x - int(x / d)*d)
    else:
        print(abs(x - int(x / d)*d - d))
    
    

Measured memory_bytes: 9176
//agrawal117
//chahatagrawal117
#include<bits/stdc++.h>
#define endl '\n'
#define mod 1000000007
typedef long long int ll;
using namespace std;
#define MAX 100005
const int oo=1000000007;
const int dx[]={1,0,0,-1};
const int dy[]={0,1,-1,0};
deque<pair<int,int>> dq;
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int n,m,k; cin>>n>>m>>k;
    
    int  dist[n+3][m+3];
    int vis[n+3][m+3];
    for(int i=0;i<=n;i++) for(int j=0;j<=m;j++) dist[i][j]=oo, vis[i][j]=0;
    int x1,y1,x2,y2; cin>>x1>>y1>>x2>>y2;
   
    char arr[n+4][m+4];
    for(int i=1;i<=n;i++){
        for(int j=1;j<=m;j++) cin>>arr[i][j];
    }
    dist[x1][y1]=0;
    vis[x1][y1]=1;
    
    dq.push_back({x1,y1});
    while(!dq.empty())
    {
        int x=dq[0].first; int y=dq[0].second;
        dq.pop_front();
        // cout<<x<<" "<<y<<" "<<dist[x][y]<<endl;
        for(int i=0;i<4;i++){
            for(int j=1;j<=k;j++){
                int xx=x+dx[i]*j ; int yy= y+ (dy[i]*j) ;
                if(xx<1 || xx>n || yy<1 || yy>m) break;
                if(arr[xx][yy]=='@') break;
                // cout<<xx<<" C "<<yy<<endl;
                if(vis[xx][yy]==0)
                {
                    dist[xx][yy]=dist[x][y]+1;
                    vis[xx][yy]=1;
                    dq.push_back({xx,yy});
                }
                else {
                    if(dist[xx][yy]<=dist[x][y]) {
                        break;
                    }
                }
            }
        }
    }
    
    ll ans=dist[x2][y2];
    if(ans==oo) ans=-1;
    cout<<ans<<endl;
    
}

Measured memory_bytes: 20168
#include <iostream>
#include <algorithm>
#include <string>
#include <cstring>
using namespace std;
typedef long long ll;
const int maxn = 1e6+10;

ll a,b;
int main(){
    cin>>a>>b;
    ll ans = 2e9;
    for(ll p = 1;p<=10000;p++){
        if((int)(p*0.08) == a && (int)(p*0.1)==b)
            ans = min(ans,p);
    }
    if(ans == 2e9) cout<<-1<<endl;
    else cout<<ans<<endl;
    return 0;
}

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

int main(){
  string s1,s2,s3;
  cin >> s1 >> s2 >> s3;
  if(s1[s1.size()-1] == s2[0] && s2[s2.size()-1] == s3[0]){
    cout << "YES" << endl;
  }
  else{
    cout << "NO" << endl;
  }
}

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

using namespace std;

using ll = long long;
using P = pair<double, double>;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define mkp(a, b) make_pair(a, b)




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

	vector<int> ps(n + 1,0);

	for(int i = 2; i <= n; i++) {
		int cur = i;
		for(int j = 2; j * j <= n; j++) {
			while(cur % j == 0) {
				ps[j]++;
				cur /= j;
			}
		}
		if (cur > 1) {
			ps[cur] ++;
		}
	}

	int dp[n + 1][2][3];
	
	dp[1][0][0] = 1;
	dp[1][1][0] = 0;
	dp[1][0][1] = 0;
	dp[1][1][1] = 0;
	dp[1][0][2] = 0;
	dp[1][1][2] = 0;

	for (int i = 2; i <= n; i++) {
		for(int j = 0; j < 3; j++) {
			dp[i][0][j] = dp[i - 1][0][j]; 
			dp[i][1][j] = dp[i - 1][1][j];

		}
		if (ps[i] >= 3 - 1) {
			dp[i][1][0] += dp[i - 1][0][0];
			dp[i][1][1] += dp[i - 1][0][1];
			dp[i][1][2] += dp[i - 1][0][2];
		}

		if (ps[i] >= 5 - 1) {
			dp[i][0][1] += dp[i - 1][0][0];
			dp[i][1][1] += dp[i - 1][1][0];
			dp[i][0][2] += dp[i - 1][0][1];
			dp[i][1][2] += dp[i - 1][1][1];
		}
		if (ps[i] >= 15 - 1) {
			dp[i][1][1] += dp[i - 1][0][0];
			dp[i][1][2] += dp[i - 1][0][1];
		}
		if (ps[i] >= 25 - 1) {
			dp[i][0][2] += dp[i - 1][0][0];
			dp[i][1][2] += dp[i - 1][1][0];
		}
		if (ps[i] >= 75 - 1) {
			dp[i][1][2] += dp[i - 1][0][0];
		}
	}



	cout << dp[n][1][2] << endl;




	return 0;
}


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

int main(){
  int n;
  cin >> n;
  vector<int> a(n+1);
  rep(i,n) cin >> a[i+1];
  vector<int> b(n+1);
  
  for(int i=n;i>=1;i--){
    int sum = 0;
    for(int j=i+i;j<=n;j+=i){
      sum ^= b[j];
    }
    b[i] = sum^a[i];
  }
  
  vector<int> ans;
  
  for(int i=1;i<=n;i++){
    if(b[i]) ans.push_back(i);
  }
  
  cout << ans.size() << endl;
  
  rep(i,ans.size()){
    printf("%d%c",ans[i],i+1==ans.size() ?'\n' : ' ');
  }
}


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

int main() {
    int N, T, ans=0,ng=0;
    cin >> N >> T;
    vector <int> c(N);
    vector <int> t(N);
    vector <int> a;
    
    for(int i = 0; i < N; i++){
        cin >> c.at(i) >> t.at(i);
        if (t.at(i) <= T){
            a.push_back(c.at(i));
        }else{
            ng += 1;
        }
    }
     if(ng == N){
        cout << "TLE" << endl;
    }else{
        ans = *min_element(a.begin(),a.end());
        cout << ans << endl;
    }
}

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
#include<stack>
using namespace std;
stack<int>St;
char str[100010];
int arr[100010];
int main()
{
	int ans=0;
	scanf("%s",str);
	int l=strlen(str);
	for(int i=1;i<=l;i++)
		arr[i]=str[i-1]-'0';
	for(int i=1;i<=l;i++){
		if(St.empty()||arr[i]==St.top())
			St.push(arr[i]);
		if(St.top()^arr[i]){
			while(!St.empty()){
				if(St.top()^arr[i]){
					St.pop();
					ans+=2;
					break;
				}
			}
		}
	}
	printf("%d\n",ans);
	return 0;
 } 

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

typedef long long ll;

bool usedD[200000+10];
bool usedV[200000+10];
int main(void) {
  int n, m;
  cin >> n >> m;
  int right = n;
  for(int left = 1; m > 0; ++left) {
    while(usedV[right] || usedD[right-left] || usedD[left-right+n] || (right - left == left - right + n)) {
      --right;
      if(right < 1) {
        right = n;
      }
    }
    --m;
    printf("%d %d\n", left, right);
    usedV[left] = true;
    usedV[right] = true;
    usedD[right-left] = true;
    usedD[left-right+n] = true;
    --right;
  }
  return 0;
}


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

#define int long long
#define ll long long
#define f1(i,a,b) for(i=a;i<b;i++)
#define f2(i,a,b) for(i=a;i>=b;i--)
#define endl '\n'
#define pb push_back
#define gp " "
#define ff first
#define ss second
#define mp make_pair

const int mod=1000000007;
int i,j;
ll temp;

struct ab{
    int mark;
    string s;
    int num;
};

bool cmp(ab a, ab b)
{
    if(a.s<b.s)
        return true;
    else if(b.s<a.s)
        return false;
    else{
        return a.num>b.num;
    }
}
int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    // #ifndef ONLINE_JUDGE
    //     freopen("in.txt","r",stdin);
    //     freopen("out.txt","w",stdout);
    // #endif
    int n;
    cin>>n;
    ab a[n];
    f1(i,0,n)
    {
        a[i].mark = i+1;
        cin>>a[i].s>>a[i].num;
    }
    sort(a,a+n,cmp);
    f1(i,0,n)
    cout<<a[i].mark<<endl;
    return 0;
}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10000000)

N,Q = map(int,input().split())
to = [[] for _ in range(N+1)]
ans = [0 for _ in range(N+1)]

for _ in range(N-1):
    a,b=map(int,input().split())
    to[a].append(b)
    to[b].append(a)
for _ in range(Q):
    p,x = map(int,input().split())
    ans[p] += x

def dfs(v, p):
    for u in to[v]:
        if u == p:
            continue
        ans[u] += ans[v]
        dfs(u, v)
dfs(1, -1)
print(*ans[1:])


Measured memory_bytes: 230932
#include<bits/stdc++.h>
using namespace std;
int x[4],y[4],a,b;

int main(){
    cin>>x[0]>>y[0]>>x[1]>>y[1];
    a=x[1]-x[0];
    b=y[1]-y[0];
    y[2]=y[1]+a;
    x[2]=x[1]-b;
    x[3]=x[2]-a;
    y[3]=y[2]-b;
    cout<<x[2]<<" "<<y[2]<<" "<<x[3]<<" "<<y[3]<<endl;
}


Measured memory_bytes: 256