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

//#pragma gcc optimize("O3,unroll-loop")
//#pragma gcc target("sse,sse2,sse3,ssse3,sse4,avx,avx2,fma,abm,mmx,popcnt,tune=native")
//#define int long long
//#define double long double

signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);

    int t;
    for (int i = 0; i < 5; i++)
    {
        cin >> t;
        if (t != i + 1)
            cout << i + 1 << '\n', exit(0);
    }

    return 0;
}

//      *   *  *****  *   *  *   *   ****  ****    ****     **    **
//     *   *  *      **  *  *   *  *      *   *  *        * *   * *
//    *****  *****  * * *  *   *  *      ****   *       *  *     *
//   *   *      *  *  **  *   *  *      *  *   *       *****    *
//  *   *  *****  *   *   ***    ****  *   *    ****     *   *****

//      *****  *****  *   *  *      *****  *   *  *****  *****
//        *   *   *  *   *  *        *    **  *    *    *   *
//       *   *   *  *****  *        *    * * *    *    *****
//   *  *   *   *    *    *        *    *  **    *    *
//  ****   *****    *    *****  *****  *   *    *    *


Measured memory_bytes: 3536
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
static class Program{
	const int mod=1000000007;
	static void Main(){
		Sc sc=new Sc();
		long n=sc.L;
		long q=long.MaxValue;
		for(int i = 0;i<5;i++) {q=Math.Min(q,sc.L);}
		Console.WriteLine("{0}",5+(n%q==0?-1:0)+n/q);
	}
}

public class Sc{
	public int I{get{return int.Parse(Console.ReadLine());}}
	public long L{get{return long.Parse(Console.ReadLine());}}
	public double D{get{return double.Parse(Console.ReadLine());}}
	public string S{get{return Console.ReadLine();}}
	public int[] Ia{get{return Array.ConvertAll(Console.ReadLine().Split(),int.Parse);}}
	public int[] Ia2{get{return Array.ConvertAll(("0 "+Console.ReadLine()+" 0").Split(),int.Parse);}}
	public long[] La{get{return Array.ConvertAll(Console.ReadLine().Split(),long.Parse);}}
	public long[] La2{get{return Array.ConvertAll(("0 "+Console.ReadLine()).Split(),long.Parse);}}
	public double[] Da{get{return Array.ConvertAll(Console.ReadLine().Split(),double.Parse);}}
	public string[] Sa{get{return Console.ReadLine().Split();}}
}

Measured memory_bytes: 13140
import java.util.*;
import java.lang.*;

class Counter<T> extends TreeMap<T,Long>{
    public Counter(){
        super();
    }
    public Long count(Object elm){
        return getOrDefault(elm,0L);
    }
    public void add(T elm, long amount){
        if(!this.containsKey(elm)) put(elm, amount);
        else replace(elm, get(elm)+amount);
    }
}

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int C = sc.nextInt();
        int[][] D = new int[C][C];
        for(int x=0; x<C; x++) for(int y=0; y<C; y++) D[x][y]=sc.nextInt();

        int[][] grid = new int[N][N];
        for(int r=0; r<N; r++) for(int c=0; c<N; c++) grid[r][c]=sc.nextInt()-1;

        Counter<Integer>[] colorCount = new Counter[3];
        for(int p=0;p<3;p++) colorCount[p]=new Counter<>();
        for(int r=0; r<N; r++) for(int c=0; c<N; c++) colorCount[(r+c)%3].add(grid[r][c],1);
        
        int ans = Integer.MAX_VALUE;
        for(int c0=0; c0<C; c0++) for(int c1=0; c1<C; c1++) for(int c2=0; c2<C; c2++){
            if(c0!=c1 && c1!=c2 && c2!=c0){
                int wrongness = 0;
                for(int c=0; c<C; c++){
                    wrongness += D[c][c0] * colorCount[0].count(c);
                    wrongness += D[c][c1] * colorCount[1].count(c);
                    wrongness += D[c][c2] * colorCount[2].count(c);
                }
                ans = Math.min(ans, wrongness);
            }
        }
        System.out.println(ans);


    }
}


Measured memory_bytes: 87424
#include <algorithm>
#include <cmath>
#include <ctime>
#include <deque>
#include <fstream>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
using namespace std;
#define REP(i, a, b) for(int i = a; i < b; i++)
#define rep(i, n) REP(i, 0, n)
template<class T>
void printv(vector<T> vec){ for(T e: vec)cout << e << ' '; cout << endl;}
template<class T>
void print2v(vector<vector<T> >v){ for(auto& i: v){ for(auto& j: i) cout<<j<<' '; cout<<endl;}}

 struct TreeNode {
     int val;
     TreeNode *left;
     TreeNode *right;
     TreeNode() : val(0), left(nullptr), right(nullptr) {}
     TreeNode(int x) : val(x), left(nullptr), right(nullptr) {}
     TreeNode(int x, TreeNode *left, TreeNode *right) : val(x), left(left), right(right) {}
};





int main() {
    int N;
    cin >> N;
    int* A = new int[N];
    int* B = new int[N];
    int* C = new int[N];
    rep(i, N) cin >> A[i];
    rep(i, N) cin >> B[i];
    rep(i, N) cin >> C[i];
    sort(A, A + N);
    sort(B, B + N);
    sort(C, C + N);

    long long* upper = new long long[N]();
    long long* lower = new long long[N];
    *lower = N;

    long long res = 0;
    int a = 0, c = 0;
    rep(i, N) {
        if (i) {
            upper[i] = upper[i - 1];
            lower[i] = lower[i - 1];
        }
        for (; a < N && B[i] > A[a]; a++, upper[i]++);
        for (; c < N && B[i] >= C[c]; c++, lower[i]--);
    }

    rep(i, N) res += upper[i] * lower[i];
    cout << res << endl;

	return 0;
}

Measured memory_bytes: 6316
#include<stdio.h>

int main()
{
    char a[10]={0};
    scanf("%s",a);
    if(a[2]!=0)
    {
        a[3]=a[0];
        a[0]=a[2];
        a[2]=a[3];
    }
    int i;
    for(i=0;i<3;i++)
    {
        if(a[i]!=0)printf("%c",a[i]);
    }
}

Measured memory_bytes: 128
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <climits>
#include <bitset>
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<pair<int,int>> vpii;
typedef vector<vector<int>> vvi;
typedef vector<vector<char>> vvc;
typedef vector<vector<string>> vvs;
#define rep(i,n) for(int i=0;i<n;i++)
#define fin(ans) cout<<(ans)<<endl
#define P 1000000007
#define STI(s) atoi(s.c_str())//string to int
#define mp(p,q) make_pair(p,q)
#define Sort(a) sort(a.begin(),a.end())
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 int INF = INT_MAX;
const long long LLINF = 1LL<<60;
//g++ -std=c++1z temp.cpp
//./a.exe
    
int main(void){ios::sync_with_stdio(false);cin.tie(0);
//////////////////////////////////////////////////////
    
char c;
cin >> c;
if (c == 'a'||c == 'i'||c == 'u'||c == 'e'||c == 'o')
{
    cout << "vowel" << endl;
}else
{
    cout << "consonant" << endl;
}












  
 
//////////////////////////////////////////////////////
return 0;}

Measured memory_bytes: 256
#include <iostream>
#include <cstdlib>
using namespace std;
int main()
{
int N;
cin >> N;
int hint[N][3],cx,cy,i,j,k,s,H,HH,f,nandaka,hozon,sss;
for(i=0;i<N;i++)cin>>hint[i][0]>>hint[i][1]>>hint[i][2];
if(N==1)
{
cx=hint[0][0];
cy=hint[0][1];
H=hint[0][2];
goto seikai;

}

for(i=0;i<=100;i++)
{
for(j=0;j<=100;j++)
{
  hozon=0;
  sss=0;
  f=0;
  cx=i;
  cy=j;
  for(nandaka=0;nandaka<N;nandaka++)
  {
    if(hint[nandaka][2]!=0){
    hozon=nandaka;
    sss++;}
  }
      if(sss==1)
   {
     cx=hint[hozon][0];
     cy=hint[hozon][1];
     H=hint[hozon][2];
      goto seikai;
   }
 
  H=hint[hozon][2]+abs(cx-hint[hozon][0])+abs(cy-hint[hozon][1]);
  HH=H;
  for(k=0;k<N;k++)
  {
    if(hint[k][2]!=0){
      
    HH=hint[k][2]+abs(cx-hint[k][0])+abs(cy-hint[k][1]);
    }
    if(HH!=H)
    {
      f=1;
      break;
    }
 
  }

  if(f==0)
   {goto seikai;}

}

}


seikai:
cout << cx << " "<<cy << " "<< H << endl;
return 0;
}


Measured memory_bytes: 256
{-# LANGUAGE NamedFieldPuns #-}
import Control.Monad (replicateM)
import Data.Foldable (traverse_)
import Data.Functor ((<$>))
import Data.List ((\\), sort)

data Suit = Spade | Heart | Club | Diamond
  deriving (Eq, Ord, Enum)

instance Show Suit where
  show Spade   = "S"
  show Heart   = "H"
  show Club    = "C"
  show Diamond = "D"

readSuit "S" = Spade
readSuit "H" = Heart
readSuit "C" = Club
readSuit "D" = Diamond

data Card = Card { suit :: Suit, rank :: Int }
  deriving (Eq, Ord)

instance Show Card where
  show (Card{suit, rank}) = show suit ++ " " ++ show rank

readCard str =
  let [s, r] = words str
  in Card { suit = readSuit s, rank = read r }

allCards = do
  ss <- [Spade .. Diamond]
  rs <- [1..13]
  return $ Card { suit = ss, rank = rs }

main = do
  n <- readLn
  cards <- replicateM n (readCard <$> getLine)
  traverse_ print $ sort $ allCards \\ cards



Measured memory_bytes: 4088
#!/usr/bin/env python
from __future__ import division, print_function

import os
import sys
from io import BytesIO, IOBase

if sys.version_info[0] < 3:
    from __builtin__ import xrange as range
    from future_builtins import ascii, filter, hex, map, oct, zip


def main():
    a, b, c = [int(s) for s in input().strip().split()]
    if a + b <= c and 4 * a * b < (c - a - b) ** 2:
        print("Yes")
    else:
        print("No")


# region fastio

BUFSIZE = 8192


class FastIO(IOBase):
    newlines = 0

    def __init__(self, file):
        self._fd = file.fileno()
        self.buffer = BytesIO()
        self.writable = "x" in file.mode or "r" not in file.mode
        self.write = self.buffer.write if self.writable else None

    def read(self):
        while True:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            if not b:
                break
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines = 0
        return self.buffer.read()

    def readline(self):
        while self.newlines == 0:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            self.newlines = b.count(b"\n") + (not b)
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines -= 1
        return self.buffer.readline()

    def flush(self):
        if self.writable:
            os.write(self._fd, self.buffer.getvalue())
            self.buffer.truncate(0), self.buffer.seek(0)


class IOWrapper(IOBase):
    def __init__(self, file):
        self.buffer = FastIO(file)
        self.flush = self.buffer.flush
        self.writable = self.buffer.writable
        self.write = lambda s: self.buffer.write(s.encode("ascii"))
        self.read = lambda: self.buffer.read().decode("ascii")
        self.readline = lambda: self.buffer.readline().decode("ascii")


def print(*args, **kwargs):
    """Prints the values to a stream, or to sys.stdout by default."""
    sep, file = kwargs.pop("sep", " "), kwargs.pop("file", sys.stdout)
    at_start = True
    for x in args:
        if not at_start:
            file.write(sep)
        file.write(str(x))
        at_start = False
    file.write(kwargs.pop("end", "\n"))
    if kwargs.pop("flush", False):
        file.flush()


if sys.version_info[0] < 3:
    sys.stdin, sys.stdout = FastIO(sys.stdin), FastIO(sys.stdout)
else:
    sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)

input = lambda: sys.stdin.readline().rstrip("\r\n")

# endregion

if __name__ == "__main__":
    main()


Measured memory_bytes: 38384
#include <stdlib.h>
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
int main(void){
    int N;
    int a[100000];
    cin >> N;
    for (int i = 0; i < N; i++) {
        cin >> a[i];
    }
    sort(a,a+N);
    int * it1 = upper_bound(a,a+N,a[N-1]/2);
    int index=distance(a, it1);
    if(index==0){
        cout << a[N-1]<< " "<< a[0] << endl;
    }else{
        if(a[N-1]/2.0-a[index-1]<=a[index]-a[N-1]/2.0){
            cout << a[N-1]<< " "<< a[index-1] << endl;
        }else{
            cout << a[N-1]<< " "<< a[index] << endl;
        }
    }
}


Measured memory_bytes: 640
#include<iostream>
#include<vector>
#include<map>
using namespace std;

int main(void){
    vector<vector<vector<int> > > buildings(4, vector<vector<int> >(3, vector<int>(10)));
    
    int n, b, f, r, v;
    cin >> n;
    for(int i = 0; i < n; i++){
        cin >> b >> f >> r >> v;
        b--;f--;r--;
        
        buildings[b][f][r] += v;
    }
    
    for(int i = 0; i < 4; i++){
        for(int j = 0; j < 3; j++){
            for(int k = 0; k < 10; k++){
                cout << " " << buildings[i][j][k];
            }
            cout << endl;
        }
        if(i <= 2){
            cout << "####################" << endl;
        }
    }
    
}



Measured memory_bytes: 3148
def main(str)
  splits = str.split("\n")
  s, _q = splits[0..1]
  qs = splits[2..-1].map { |x| x.split(" ") }
  s0, s1 = "", ""
  flip = false
  qs.each do |x|
    case x[0]
    when "1"
      flip = !flip
    when "2"
      c = x[2]
      case x[1]
      when "1"
        if flip
          s1 << c
        else
          s0 << c
        end
      when "2"
        if flip
          s0 << c
        else
          s1 << c
        end
      else
        raise
      end
    else
      raise
    end
  end
  res = s0.reverse + s + s1
  flip ? res.reverse : res
end

puts main($stdin.read.chomp)

Measured memory_bytes: 50436
#include<iostream>
#include<cstdio>
#include<algorithm>
#define N 100003 
using namespace std;
struct data{
	int x,id;
}a[N];
bool cmp(data a,data b)
{
	return a.x<b.x;
}
int main()
{
	
	int n;
	scanf("%d",&n);
	for (int i=1;i<=n;i++) {
		scanf("%d",&a[i].x);
		a[i].id=i;
	}
	sort(a+1,a+n+1,cmp);
	for (int i=1;i<=n;i++) printf("%d ",a[i].id);
	printf("\n");
	return 0;
 } 

Measured memory_bytes: 1536
str = input()

if len(str)%2 == 1:
    print('No')
else:
    for i in range(0,len(str),2):
        moji = str[i:i+2]
        # print(moji)
        if moji != 'hi':
            ans = 1
            break
        else:
            ans = 0
    if ans==1:
        print('No')
    else:
        print('Yes')

Measured memory_bytes: 9016
import sys
for l in sys.stdin:
	s=0
	d=[[100,500,0,0,0,5,1,10,0,50,1000,0,0,0][(n-67)%14]for n in map(ord,l)]
	for i,j in zip(d,d[1:]+[0]):s+=-i if i<j else i
	print s

Measured memory_bytes: 4212
#include<bits/stdc++.h>
using namespace std;
const long long mod=1000000007,inf=1000000007;
inline long long qpow(long long a,long long b){
	long long res=1;
	while(b){
		if(b&1)(res*=a)%=mod;
		(a*=a)%=mod;
		b>>=1;
	}
	return res;
}
long long n,k,ans=0;
inline long long inv(long long a) {return qpow(a,mod-2);}
long long f[200005];
long long c[200005];
int main(){
	cin>>n>>k;
	k=min(n,k);
	c[0]=f[0]=1;
	for(int i=1;i<=n;++i)f[i]=f[i-1]*(n-i)%mod*inv(i)%mod;
	for(int i=1;i<=n;++i)c[i]=c[i-1]*(n-i+1)%mod*inv(i)%mod;
	for(int i=0;i<=k;++i)(ans+=c[i]*f[i])%=mod;
	cout<<ans;
	return 0;
}

Measured memory_bytes: 3328
#include<algorithm>
#include<complex>
#include<ctype.h>
#include<iomanip>
#include<iostream>
#include<map>
#include<math.h>
#include<numeric>
#include<queue>
#include<set>
#include<stack>
#include<stdio.h>
#include<string>
#include<string>
#include<vector>

using namespace std;
typedef long long ll;

#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define ALL(v) (v).begin(), (v).end()
#define p(s) cout<<(s)<<endl
#define p2(s, t) cout << (s) << " " << (t) << endl
#define br() p("")
#define pn(s) cout << (#s) << " " << (s) << endl
#define p_yes() p("YES")
#define p_no() p("NO")

template < typename T >
void vprint(T &V){
	for(auto v : V){
    	cout << v << " ";
	}
	cout << endl;
}

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

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

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

    // input
    ll a, b;
    cin >> a >> b;

    if(a<=b){
        p(a);
    }else{
        p(a-1);
    }
    
    return 0;
}

Measured memory_bytes: 256
a,b,c=map(int,input().split())
if (a>b):
    n=a
    a=b
    b=n
if (b>c):
    n=b
    b=c
    c=n
if (a>b):
    n=a
    a=b
    b=n
print (str(a)+" "+str(b)+" "+str(c))


Measured memory_bytes: 5596
#include<bits/stdc++.h>
#include<iostream>
#include<string>
#include<cmath>
#include<cstdio>
#include<cctype>
#include<cstring>
#include<iomanip>
#include<cstdlib>
#include<ctime>
#include<set>
#include<map>
#include<utility>
#include<queue>
#include<vector>
#include<stack>
#include<sstream>
#include<algorithm>
/************************************************/
#define rep(i,n) for(int i=0;i<n;i++)
#define m_p make_pair
#define pb push_back
#define fr first
#define se second
#define forn(i,a,n) for(int i=a;i<n;i++)
#define foreach(i,c) for(__typeof(c.begin())i=(c.begin());i!=(c).end();i++)
#define pii pair<int,int>
#define vi vector<int>
#define ll long long
#define sz(s) s.size()
#define all(s) s.begin(),s.end()
#define zero(x) memset(x,0,sizeof(x))
#define vii vector<pair<int,int> >
#define mpis map<int,string>
#define mpii map<int,int>
#define mpsi map<string,int>
#define re return
#define mod 1000000007
/************************************************/
using namespace std;

long long get(){
	char c=getchar();
	long long x=0LL;
	while(c<'0'||c>'9')
	c=getchar();
	while(c>='0'&&c<='9'){
		x*=10LL;
		x+=(c-'0');
		c=getchar();
	}
	return x;
}
int n,a[200001];
ll k;
int d[200001];
int main(){
	ios::sync_with_stdio(0);
	cin>>n>>k;
	memset(d,-1,sizeof(d));
	rep(i,n){
		cin>>a[i];
		a[i]--;
	}
	if(k<=n){
		int now=0;
		while(k--){
			now=a[now];
		}
		cout<<now+1;
	}
	else{
		int nn=0,now=0;
		while(d[now]==-1){
			d[now]=nn++;
			now=a[now];
		}
		k-=d[now];
		nn-=d[now];
		k%=nn;
		while(k--){
			now=a[now];
		}
		cout<<now+1;
	}
	re 0;
}


Measured memory_bytes: 5200
package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func scanInt() int {
	sc.Scan()
	i, err := strconv.Atoi(sc.Text())
	if err != nil {
		panic(err)
	}
	return i
}

func intMax(x, y int) int {
	return int(math.Max(float64(x), float64(y)))
}

func main() {
	sc.Split(bufio.ScanWords)

	N := scanInt()
	A, B := make([]int, N+1), make([]int, N)
	for i := 0; i <= N; i++ {
		A[i] = scanInt()
	}
	for i := 0; i < N; i++ {
		B[i] = scanInt()
	}

	ans := 0
	for i := 0; i < N; i++ {
		if A[i]+A[i+1] >= B[i] {
			ans += B[i]
			A[i+1] -= intMax(B[i]-A[i], 0)
		} else {
			ans += (A[i] + A[i+1])
			A[i+1] = 0
		}
	}
	fmt.Println(ans)
}


Measured memory_bytes: 5120
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define MOD 1000000007
#define MAX 100010
#define aout(a) REP(i,sizeof(a)) cout << a[i] << " "; cout << endl;
#define vout(v) REP(i,v,size()) cout << v[i] << " "; cout << endl;
using namespace std;
using ll = long long;
using P = pair<int,int>;
using Graph = vector<vector<int>>;

struct UnionFind {
  vector<int> par;

  UnionFind(int n) : par(n, -1) { }

  int root(int x) {
    if (par[x] < 0) return x;
    else return par[x] = root(par[x]);
  }

  bool issame(int x, int y) {
    return root(x) == root(y);
  }

  bool merge(int x, int y) {
    x = root(x); y = root(y);
    if (x == y) return false;
    if (par[x] > par[y]) swap(x, y); // merge technique
    par[x] += par[y];
    par[y] = x;
    return true;
  }

  int size(int x) {
    return -par[root(x)];
  }
};

using pint = pair<int,int>;
int main(){
  int N,M; cin>>N>>M;
  //vector<int> A(M),B(M);
  //REP(i,M) cin>>A[i]>>B[i];

  vector<set<int> > dame(N);
  UnionFind uf(N);
  for (int i = 0; i < M; ++i) {
    int a, b; cin >> a >> b; --a, --b;
    dame[a].insert(b);
    dame[b].insert(a);
    uf.merge(a, b);
  }
  int ans = 0;
  REP(i,N){
    ans = max(ans, uf.size(i));
  }
  cout << ans;
}

Measured memory_bytes: 32244
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		// 自分の得意な言語で
		// Let's チャレンジ！！

		Scanner sc = new Scanner(System.in);

		// モンスター数
		int n = sc.nextInt();
		// 必殺技使用限度数
		int k = sc.nextInt();
		// モンスター一覧
		List<Long> longList = new ArrayList<>();
		for (int i = 0; i < n; i++) {
			longList.add(sc.nextLong());
		}
		Collections.sort(longList);
		if (k >= n) {
			k = n;
		}
		int cnt = 0;
		for (int j = longList.size()-1 ; cnt < k ; j--) {
			longList.remove(j);
			cnt++;
		}
		long result = 0;
		for (long a : longList) {
			result = result + a;
		}

		System.out.println(result);

	}

}

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

using ll = long long;
using vertex = struct vertex {ll to,cost;vertex(ll to,ll cost):to(to),cost(cost){}};
using AdjList = vector<vector<vertex>>;
using edge = struct edge{ll from,to,cost;edge(ll from,ll to,ll cost):from(from),to(to),cost(cost){}};
using Edges = vector<edge>;
#define rep(i,n) for(ll i=0;i<(n);++i)
template<class T>inline bool chmin(T &a,const T &b){if(a>b){a=b;return true;}return false;}

vector<ll> Dijkstra(AdjList&adj,ll N,ll S){
  vector<ll> dist(N,(1LL<<60));
  priority_queue<pair<ll,ll>,vector<pair<ll,ll>> ,greater<>> que;
  dist[S]=0LL;
  que.emplace(dist[S],S);
  while(!que.empty()){
    ll cost,from;
    tie(cost,from) = que.top();
    que.pop();
    if(dist[from]<cost)continue;
    for(const auto& v:adj[from]){
      if( chmin(dist[v.to],dist[from]+v.cost) )
        que.emplace(dist[v.to],v.to);
    }
  }
  return dist;
}

main(){

  ll n,m,s,t;
  cin>>n>>m>>s>>t;
  s--;t--;
  AdjList A(n),B(n);
  rep(i,m){
    ll u,v,a,b;
    cin>>u>>v>>a>>b;
    u--;v--;
    A[u].emplace_back(v,a);
    A[v].emplace_back(u,a);
    B[u].emplace_back(v,b);
    B[v].emplace_back(u,b);
  }

  auto fromS=Dijkstra(A,n,s);
  auto fromT=Dijkstra(B,n,t);

  vector<ll> cost(n);
  rep(i,n){
    cost[i]=fromS[i]+fromT[i];
  }
  for(ll i=n-2;i>=0;--i){
    chmin(cost[i],cost[i+1]);
  }

  for(const auto& ans:cost){
    cout<<(ll)((1e15)-ans)<<endl;
  }

}

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

#include <vector>

int main(){
    int n;cin >> n;
    vector<int> a(n),b(n);
    int count = 0;
    for(int i=0;i<n;i++) cin >> a[i] >> b[i];
    for(int i=0;i<n;i++){
        if(a[i]==b[i]){
            count++;
            if(count==3){
                cout << "Yes" << endl;
                return 0;
            }
        } else count = 0;
    }
    cout << "No" << endl;
}

Measured memory_bytes: 3624
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <tuple>
#include <numeric>
#include <functional>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll mod = 1000000007;
const ll INF = 1e16;
const ll MAX_N = 100010;

int main() {
    ll n, m;
    cin >> n >> m;    
    
    vvl G(n);
    rep(i, m) {
        ll a, b;
        cin >> a >> b;
        a--;  b--;
        G[a].pb(b);
        G[b].pb(a);
    }
    
    rep(i, n) {
        out(G[i].size());
    }

    re0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
	string s;
	cin>>s;
	if(s=="Sunny")
	{
		cout<<"Cloudy";
	}
	if(s=="Cloudy")
	{
		cout<<"Rainy";
	}
	if(s=="Rainy")
	{
		cout<<"Sunny";
	}
    return 0;	
} 	

Measured memory_bytes: 256
#define _USE_MATH_DEFINES

#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <functional>
#include <climits>
#include <cmath>
#include <utility>
#include <iomanip>
//#include <boost/multiprecision/cpp_int.hpp>

using namespace std;
using ll = long long int;
//// 任意長整数型
//namespace mp = boost::multiprecision;
//using Bint = mp::cpp_int;







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

	map<int, int> l;
	for (int i = 0; i < n; i++){
		int li;
		cin >> li;
		l[li]++;
	}


	//calc
	int ans = 0;
	for (auto a = l.begin(); a != l.end(); ++a){
		for (auto b = a; b != l.end(); ++b){
			if (b == a){
				continue;
			}
			for (auto c = b; c != l.end(); ++c){
				if (c == b){
					continue;
				}
				if (c->first < a->first + b->first){
					ans += a->second * b->second * c->second;
				}
			}
		}
	}


	//ans
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 3556
#include<stdio.h>
#include<algorithm>
#define MAXN 100005
using namespace std;
const int mod=1e9+7;
int t[MAXN],a[MAXN],n;
int mul(int x,int y) 
{
    return 1LL * x * y % mod;
}
int main() 
{
    scanf("%d",&n);
    for(int i=1;i<=n;++i) scanf("%d",&t[i]);
    for(int i=1;i<=n;++i) scanf("%d",&a[i]);
    int ans=1;
    for(int i=1;i<=n;++i) 
	{
	    if(t[i]!=t[i-1]||a[i]!=a[i + 1]) 
		{
	        int x=-1,y=-1;
	        if(t[i]!=t[i-1]) x=t[i];
	        if(a[i]!=a[i+1]) y=a[i];
	        if(x!=-1&&y!=-1) 
		        if(x!=y) 
		        {
		        	printf("0");
					return 0;
				}		
	        if(y>t[i]) 
			{
				printf("0");
				return 0;
			}
	        if(x>a[i]) 
			{
				printf("0");;
				return 0;
			}
	    }
	    else 
	        ans=mul(ans,min(a[i],t[i]));
    }
    printf("%d",ans);
    return 0;
}

Measured memory_bytes: 896
#include<stdio.h>

#define MAX 100

int main(void){
  int i,j;
  int M[MAX][MAX];
  int n,m;
  int u,v;

  scanf("%d",&n);
  for(i = 0;i < n;i++){
    for(j = 0;j < n;j++){
      M[i][j] = 0;
    }
  }

  for(i = 0;i < n;i++){
    scanf("%d %d",&u,&m);
    u--;
    
    for(j = 0;j < m;j++){
      scanf("%d",&v);
      v--;
      M[u][v] = 1;
    }
  }
  

  for(i = 0;i < n;i++){
    for(j = 0;j < n;j++){
      if(j > 0){
	printf(" ");
      }
      printf("%d",M[i][j]);
    }
    puts("");
  }

  return 0;
}
	  



Measured memory_bytes: 2048
#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<ll,ll>;
const int mod = 1e9 + 7;
//const int mod = 998244353;
const ll infll = (1LL << 62) - 1;
const int inf = (1 << 30) - 1;
void YesNo(bool j){cout << (j ? "Yes" : "No") << endl; return;}
void yesno(bool j){cout << (j ? "yes" : "no") << endl; return;}
template<class Head> void pt(Head&& head){cout << head << endl; return;}

int d[200001];

int main() {
    int n;
    cin >> n;
    vector<int> a(n);
    rep(i,n) cin >> a[i];
    int q;
    cin >> q;
    ll res=0;
    rep(i,n) {
        res+=a[i];
        d[a[i]]++;
    }
    rep(i,q) {
        int b,c;
        cin >> b >> c;
        if(b!=c) {
        res+=(c-b)*d[b];
        d[c]+=d[b];
        d[b]=0;
        }
        pt(res);
    }


    return 0;
}


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

int main(){
    Int N;
    cin >> N;
    vector<Int> a(N);
    rep(i,N) cin >> a[i];

    Int S = a[0];
    rep1(i,N-1) {
        S = S ^ a[i];
    }

    vector<Int> b(N);
    rep(i,N) b[i] = S ^ a[i];

    rep(i,N-1) cout << b[i] << " ";
    cout << b[N-1] << endl;

}

Measured memory_bytes: 6184
#include <iostream>
#include <algorithm>
#define MAX 500
using namespace std;
int h, w;
char m[MAX][MAX];

int solve() {
  int data[MAX][MAX];
  for(int i = 0; i < h; i++) {
    for(int j = 0; j < w; j++) {
      if(m[i][j] == '*') data[i][j] = 0;
      else if(i == 0)    data[i][j] = 1;
      else               data[i][j] = data[i-1][j] + 1;
    }
  }

  int ans = 0;
  for(int i = 0; i < h; i++) {
    for(int l = 0; l < w; l++) {
      if(data[i][l] == 0) continue;
      int mini = data[i][l];
      for(int r = l; r < w; r++) {
	if(data[i][r] == 0) break;
	mini = min(mini, data[i][r]);
	ans = max(ans, mini*(r-l+1));
      }
    }
  }

  return ans;
}

int main() {
  while(1) {
    cin >> h >> w;
    if(h == 0 && w == 0) break;
    for(int i = 0; i < h; i++) {
      for(int j = 0; j < w; j++) {
	cin >> m[i][j];
      }
    }
    cout << solve() << endl;
  }
  return 0;
}

Measured memory_bytes: 2084
#include<bits/stdc++.h>
using namespace std;
#define ll long long
ll n,k;
ll a,b;
vector<pair<ll,ll> > num;
vector<pair<ll,ll> > ::iterator iter;
int main(){
	
    cin>>n>>k;
    for(int i=1;i<=n;i++)  
    {
	    cin>>a>>b;
	   num.push_back(make_pair(a,b));
	}
	sort(num.begin(),num.end());
  ll sum=0;
  for(iter=num.begin();iter!=num.end();iter++)
      {
      	 sum+=iter->second;
      	 if(sum>=k)
      	   return 0*printf("%d\n",iter->first);
      }
  
	return 0;
}

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

int main(){
    int N,D;
    cin >> N >> D;
    long long x,y; //ここをlong longにしないと不正解になる
    long c=0;
    rep(i,N){
        cin >> x >> y;
        if(sqrt(x*x+y*y)<=D) c++;
    }
    cout << c << endl;;
}


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

int main(){
    int n;
    cin>>n;
    int i=1;
    while(1000*i<n){
        i++;
    }
    cout<<1000*i-n<<"\n";
    return 0;
}

Measured memory_bytes: 3632
#ifdef LOCAL
#define _GLIBCXX_DEBUG
#endif
#include<bits/stdc++.h>
using namespace std;
#define rep(i,s,t) for(ll i = (ll)(s); i < (ll)(t); i++)
#define rrep(i,s,t) for(ll i = (ll)(s-1);(ll)(t) <= i; i--)
#define all(x) (x).begin(), (x).end()
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> Pll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<vvl> vvvl;
constexpr ll INF = numeric_limits<ll>::max()/4;
constexpr ll n_max = 2e5+10;
#define int ll

template <typename A, typename B>
string to_string(pair<A, B> p);
string to_string(const string &s) {return '"' + s + '"';}
string to_string(const char *c) {return to_string((string) c);}
string to_string(bool b) {return (b ? "true" : "false");}
template <size_t N>
string to_string(bitset<N> v){
    string res = "";
    for(size_t i = 0; i < N; i++) res += static_cast<char>('0' + v[i]);
    return res;
}
template <typename A>
string to_string(A v) {
    bool first = true;
    string res = "{";
    for(const auto &x : v) {
        if(!first) res += ", ";
        first = false;
        res += to_string(x);
    }
    res += "}";
    return res;
}
template <typename A, typename B>
string to_string(pair<A, B> p){return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";}

void debug_out() {cerr << endl;}
template<typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
    cerr << " " << to_string(H);
    debug_out(T...);
}

#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

template<class T>
bool chmax(T &a, T b){if(a < b){a = b; return true;} return false;}
template<class T>
bool chmin(T &a, T b){if(a > b){a = b; return true;} return false;}

signed main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    ll n,m,x; cin >> n >> m >> x;
    vector<ll> a(m);
    for(int i = 0; i < m; i++) cin >> a[i];
    vector<ll> cnt(n+1);
    for(auto i : a){
        cnt[i] = 1;
    }
    debug(cnt);
    rep(i,0,x-1) cnt[i+1] += cnt[i];
    rrep(i,n,x+2) cnt[i-1] += cnt[i];
    debug(cnt);
    cout << min(cnt[x-1], cnt[x+1]) << endl;
}

Measured memory_bytes: 3660
#include <string>
#include <vector>
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<stack>
#include<queue>
#include<cmath>
#include<algorithm>
#include<functional>
#include<list>
#include<deque>
#include<bitset>
#include<set>
#include<map>
#include<unordered_map>
#include<cstring>
#include<sstream>
#include<complex>
#include<iomanip>
#include<numeric>
#include<cassert>
#define X first
#define Y second
#define pb push_back
#define rep(X,Y) for (int (X) = 0;(X) < (Y);++(X))
#define reps(X,S,Y) for (int (X) = S;(X) < (Y);++(X))
#define rrep(X,Y) for (int (X) = (Y)-1;(X) >=0;--(X))
#define repe(X,Y) for ((X) = 0;(X) < (Y);++(X))
#define peat(X,Y) for (;(X) < (Y);++(X))
#define all(X) (X).begin(),(X).end()
#define rall(X) (X).rbegin(),(X).rend()
#define eb emplace_back
#define UNIQUE(X) (X).erase(unique(all(X)),(X).end())

using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
template<class T> using vv=vector<vector<T>>;
template<class T> ostream& operator<<(ostream &os, const vector<T> &t) {
os<<"{"; rep(i,t.size()) {os<<t[i]<<",";} os<<"}"<<endl; return os;}
template<class S, class T> ostream& operator<<(ostream &os, const pair<S,T> &t) { return os<<"("<<t.first<<","<<t.second<<")";}
template<class T> inline bool MX(T &l,const T &r){return l<r?l=r,1:0;}
template<class T> inline bool MN(T &l,const T &r){return l>r?l=r,1:0;}
const ll MOD=1e9+7;

int main(){
  ios_base::sync_with_stdio(false);
  cout<<fixed<<setprecision(0);
  string s;
  cin>>s;
  cout<<s.substr(0,4)<<" "<<s.substr(4)<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <map>
#include <cmath>
#include <queue>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
using namespace std;
#pragma warning (disable: 4996)

int N;
vector<string> vec;

int main() {
	cin >> N;
	for (int i = 0; i < N; i++) {
		string S;
		cin >> S;
		vec.push_back(S);
	}
	sort(vec.begin(), vec.end());
	vec.erase(unique(vec.begin(), vec.end()), vec.end());
	cout << vec.size() << endl;
	return 0;
}

Measured memory_bytes: 11612
#[allow(unused_imports)]
use itertools::Itertools;
#[allow(unused_imports)]
use num::*;
use proconio::input;
#[allow(unused_imports)]
use proconio::marker::*;
#[allow(unused_imports)]
use std::collections::*;

pub struct UnionFind {
    n: usize,
    root: Vec<usize>,
    rank: Vec<usize>,
    size: Vec<usize>,
}
impl UnionFind {
    pub fn new(n: usize) -> Self {
        let root = (0..n).collect();
        let rank = vec![0; n];
        let size = vec![1; n];
        Self {
            n,
            root,
            rank,
            size,
        }
    }
    pub fn find(&mut self, x: usize) -> usize {
        if x >= self.n {
            panic!();
        }
        if self.root[x] == x {
            x
        } else {
            let root = self.find(self.root[x]);
            self.root[x] = root;
            root
        }
    }
    pub fn unite(&mut self, x: usize, y: usize) {
        if x >= self.n || y >= self.n {
            panic!();
        }
        let x_root = self.find(x);
        let y_root = self.find(y);
        if x_root == y_root {
            return;
        }
        if self.rank[x_root] < self.rank[y_root] {
            self.root[x_root] = y_root;
            self.size[y_root] += self.size[x_root];
        } else {
            self.root[y_root] = x_root;
            self.size[x_root] += self.size[y_root];
            if self.rank[x_root] == self.rank[y_root] {
                self.rank[x_root] += 1;
            }
        }
    }
    pub fn size(&mut self, x: usize) -> usize {
        if x >= self.n {
            panic!();
        }
        let x_root = self.find(x);
        self.size[x_root]
    }
    pub fn is_same(&mut self, x: usize, y: usize) -> bool {
        if x >= self.n || y >= self.n {
            panic!();
        }
        self.find(x) == self.find(y)
    }
}

fn solve() {
    input! {
        n: usize, m: usize,
        edges: [(Usize1, Usize1); m]
    };

    let mut uf = UnionFind::new(n);
    for (u, v) in edges {
        uf.unite(u, v);
    }
    let mut set = HashSet::new();
    for i in 0..n {
        set.insert(uf.find(i));
    }
    let res = set.len() - 1;
    println!("{}", res);
}

fn main() {
    std::thread::Builder::new()
        .name("big stack size".into())
        .stack_size(256 * 1024 * 1024)
        .spawn(|| {
            solve();
        })
        .unwrap()
        .join()
        .unwrap();
}


Measured memory_bytes: 6052
#include <iostream>
#include <cmath>
using namespace std;
int main(){
  int n, k;
  cin >> n >> k;
  int i;
  for(i = 0; pow(k, i) <= n; i++);
  if(n>1)cout << i << endl;
  else cout << 1 << endl;
  return 0;
}

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

int main(){
    string S,T,U;
    int A,B;
    cin >> S >> T;
    cin >> A >> B;
    cin >> U;
    if( U==S ){
        A = A-1;
    }else if( U==T ){
        B = B-1;
    }
    
    cout << A << " " << B << endl;

    return 0;
}

Measured memory_bytes: 256
def primes(n):
    is_prime = [True] * (n + 1)
    is_prime[0] = False
    is_prime[1] = False
    for i in range(2, int(n**0.5) + 1):
        if not is_prime[i]:
            continue
        for j in range(i * 2, n + 1, i):
            is_prime[j] = False
    return [i for i in range(n + 1) if is_prime[i]]

answer = primes(10**5+3)

from bisect import bisect_left

print(answer[bisect_left(answer,int(input()))])

Measured memory_bytes: 4172
#![allow(unused_imports)]

use text_io::*;
use proconio::*;
use std::collections::*;
use std::process::exit;
use std::cmp::*;
use itertools::Itertools;

fn main() {
    input! {
    a:isize,
    }
    println!("{}",a*800-(a/15*200))
}

Measured memory_bytes: 2084
#include<iostream>
using namespace std;
int main()
{
	int a[] = { 6000, 4000, 3000, 2000 };
	for (int i = 0; i < 4; i++){
		int x, y;
		cin >> x >> y;
		cout << a[x - 1] * y << endl;
	}
}

Measured memory_bytes: 1160
#include<stdio.h>
#define Z 2000001
int a[Z],b[Z],c[Z];
main()
 {
  int i,j,k,l=0;
  scanf("%d", &k);
  for(i = 0; i < k; i++)
    {
      scanf("%d", &a[i]);
      c[a[i]] += 1; 
      if(a[i] > l)
        {
      l = a[i];
        }
    } 
  for(i = 1; i <= l; i++)
    {
      c[i] = c[i] + c[i-1];
    }
 
  for(j = k-1;j >= 0; j--)
    {
      b[c[a[j]]] = a[j];
      c[a[j]]--;
    }
 
  for(i = 1; i <= k; i++)
    {
      printf("%d", b[i]);
      if(i == k) printf("\n");
      else printf(" ");
    }
  return 0;
 }

Measured memory_bytes: 17892
// #define DEBUGGING
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define ALL(V) (V).begin(), (V).end()
#define ALLR(V) (V).rbegin(), (V).rend()

template <typename T> using V = vector<T>;
template <typename T> using VV = V<V<T>>;
template <typename T, typename U> using P = pair<T, U>;
using ll = int64_t;
using PLL = P<ll, ll>;

template <typename T> const T& var_min(const T &t) { return t; }
template <typename T> const T& var_max(const T &t) { return t; }
template <typename T, typename... Tail> const T& var_min(const T &t, const Tail&... tail) { return min(t, var_min(tail...)); }
template <typename T, typename... Tail> const T& var_max(const T &t, const Tail&... tail) { return max(t, var_max(tail...)); }
template <typename T, typename... Tail> void chmin(T &t, const Tail&... tail) { t = var_min(t, tail...); }
template <typename T, typename... Tail> void chmax(T &t, const Tail&... tail) { t = var_max(t, tail...); }
template <typename T> const T& clamp(const T &t, const T &low, const T &high) { return max(low, min(high, t)); }
template <typename T> void chclamp(T &t, const T &low, const T &high) { t = clamp(t, low, high); }

namespace __init {

struct InitIO {
    InitIO() {
        cin.tie(nullptr);
        ios_base::sync_with_stdio(false);
        cout << fixed << setprecision(30);
    }
} init_io;

}

#ifdef DEBUGGING
#include "../debug.cpp"
#else
#define DEBUG(...) 0
#define DEBUG_SEPARATOR_LINE 0
#endif

template <typename T>
T make_v(T init) { return init; }

template <typename T, typename... Tail>
auto make_v(T init, size_t s, Tail... tail) {
#define rec make_v(init, tail...)
    return V<decltype(rec)>(s, rec);
#undef rec
}

bool judge_y(string s) {
    ll m = stoll(s);
    return 1 <= m && m <= 12;
}

int main() {
    string S;
    cin >> S;

    bool yymm = judge_y(S.substr(2));
    bool mmyy = judge_y(S.substr(0, 2));

    if(yymm && mmyy) cout << "AMBIGUOUS";
    else if(yymm) cout << "YYMM";
    else if(mmyy) cout << "MMYY";
    else cout << "NA";
    cout << endl;
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

int main(){
  int n,i,A[10000],q,j,cnt=0;

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

  scanf("%d",&q);
  for(j=0; j<q; j++){
    //linearSearch
    i=0;
    scanf("%d",&A[n]);
    while(A[i]!=A[n])i++;
    if(i<n)cnt++;
  }

  printf("%d\n",cnt);

  return 0;
}



Measured memory_bytes: 2104
open System

// prelude
let readStr () = stdin.ReadLine()

let readInt () = stdin.ReadLine() |> int
let readInts () = stdin.ReadLine().Split() |> Array.map int

let pair = function
| [|a; b|] -> (a, b)
| _ -> failwith "owatta"

let triple = function
| [|a; b; c|] -> (a, b, c)
| _ -> failwith "owatta"

let inc n = n + 1
let dec n = n - 1

let inline flip f a b = f b a
let rec fix f = fun x -> (f (fix f)) x

module Option =
  let getOr defaultValue = function
  | Some x -> x
  | None -> defaultValue

module Array =
  let modify (arr: _ []) i f =
    arr.[i] <- f arr.[i]

module Array2D =
  let modify (arr: _ [,]) i j f =
    arr.[i, j] <- f arr.[i, j]

// start
let N =readInt()
let S=readStr().ToCharArray()

let color = function
  | 'R' -> 0
  | 'G' -> 1
  | 'B' -> 2
  | _ -> failwith "arienq"

let count =
  let res=Array.zeroCreate N
  for i in 0..(N-1) do
    let c=[|for _ in 1..3 -> Array.create 4000 0|]
    for j in (1+i)..(N-1) do
      Array.modify c.[color S.[j]] (j-i) inc
    let s=c |> Array.map (Array.sum)
    res.[i] <- (s,c)
  seq {
    for i in 0..(N-1) do
      let ci=color S.[i]
      for j in (1+i)..(N-1) do
        let cj=color S.[j]
        if ci<>cj then
          let ck=3-ci-cj
          let (s,c)=res.[j]
          yield (s.[ck]-c.[ck].[j-i])
  }
  |> Seq.sumBy int64

printfn "%d" count

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

int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  int sum = 0;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    sum += a[i];
  }
  cout << sum - n << endl;
} 

Measured memory_bytes: 3584
// d.go
package main

import (
	"fmt"
)

func groupBy(s string, headingzero, tailingzero bool) []int {
	var ret []int
	if headingzero {
		ret = append(ret, 0)
	}
	sum := 0
	for i, cur := 0, s[0]; i < len(s); i++ {
		if cur == s[i] {
			sum++
		} else {
			ret = append(ret, sum)
			cur = s[i]
			sum = 1
		}
	}
	ret = append(ret, sum)
	if tailingzero {
		ret = append(ret, 0)
	}
	return ret
}

func main() {
	var (
		n, k int
		s    string
	)
	fmt.Scanln(&n, &k)
	fmt.Scanln(&s)
	g := groupBy(s, s[0] == '0', s[len(s)-1] == '0')
	zeroClusterNum := len(g) / 2
	if zeroClusterNum <= k {
		fmt.Println(n)
		return
	}
	sum := 0
	for i := 0; i < 2*k+1; i++ {
		sum += g[i]
	}
	ans := sum
	for i := 0; i < zeroClusterNum-k; i++ {
		j := k + i + 1
		sum += g[2*j]
		sum += g[2*j-1]
		sum -= g[2*i+1]
		sum -= g[2*i]
		if sum > ans {
			ans = sum
		}
	}
	fmt.Println(ans)
}


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

#define ll long long
#define endl '\n'

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

	vector<ll> arr(n+1), b(n+1);

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

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

	ll ans = 0, cut;

	for(int i = 1;i <= n;i++){
		cut =  min(b[i],(arr[i-1]+arr[i]));
		ans += cut;

		if(arr[i-1] < cut) arr[i] -= (cut - arr[i-1]);
	}

	cout << ans;
}


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

int main()
{
  int n, k;
  cin >> n >> k;
  vector<int> a(n);
  for (int i = 0; i<n; i++)
  	cin >> a[i];
  sort(a.begin(), a.end());
  int sum = 0;
  for (int i = 0; i<k;i++)
  {
    sum+=a[i];
  }
  cout << sum << endl;
}


Measured memory_bytes: 3644
#include <iostream>
#include <map>
#include <vector>
#include <stack>
#include <queue>
#include <cmath>
#include <algorithm>

using namespace std;

int get_frst(int n) {
	while (n / 10 > 0) {
		n /= 10;
	}
	return n;
}


int main() {
	int n;
	cin >> n;
	vector <vector <int> > d(10, vector<int>(10));
	for (int x = 1; x <= n; ++x) {
		int f = get_frst(x);
		int l = x % 10;
		d[f][l] += 1;
	}
	long long ans = 0;
	for (int i = 1; i < 10; ++i) {
		for (int j = 1; j < 10; ++j) {
			ans += d[i][j] * d[j][i];
		}
	}
	cout << ans;
 	return 0;
}


Measured memory_bytes: 256
/********************************************************************************
	
	Code by a weak man who named CYJian, and he hopes the code can get more points.

	Algorithm: 

 ********************************************************************************/

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

//{{{ FAST IO AND SOME FUNCTIONS
const int __SIZE = 1 << 18;
char ibuf[__SIZE], *iS, *iT;

#define ge (iS == iT ? (iT = (iS = ibuf) + fread(ibuf, 1, __SIZE, stdin), (iS == iT ? EOF : *iS++)) : *iS++)
#define ri read_int()
#define rl read_ll()
#define ra read_alpha()
#define FILE(s) freopen(s"in", "r", stdin), freopen(s"out", "w", stdout)

template<typename T>
inline void read(T &x) {
	char ch, t = 0; x = 0;
	while(!isdigit(ch = ge)) t |= ch == '-';
	while(isdigit(ch)) x = x * 10 + (ch ^ 48), ch = ge;
	x = t ? -x : x;
}
inline char read_alpha() { char c = ge; while(!isalpha(c) && c != EOF) c = ge; return c; }
inline int read_int() { int x; return read(x), x; }
inline ll read_ll() { ll x; return read(x), x; }

template<typename T> inline void chkmin(T&a, T b) { a = a < b ? a : b; }
template<typename T> inline void chkmax(T&a, T b) { a = a > b ? a : b; }
//}}}

int nx[510];
int A[510][510];

int main() {
#ifdef LOCAL
	FILE("");
#endif
	int k = ri;
	if(k <= 500) {
		cout << k << endl;
		for(int i = 1; i <= k; i++)
			for(int j = 1; j <= k; j++)
				printf("%d%c", i, " \n"[j == k]);
	} else {
		int n = 500, N = 0;
		for(int i = 1; i <= n; i++) nx[i] = i + 1;
		nx[n] = 1, cout << 500 << endl, k -= n;
		for(int i = 1; i <= n; i++) {
			int a = ++N, b = k ? ++N : N;
			k -= b - a;
			for(int x = 1, y = i; x <= n; x++, y = nx[y])
				A[x][y] = x & 1 ? a : b;
		}
		for(int i = 1; i <= n; i++)
			for(int j = 1; j <= n; j++)
				printf("%d%c", A[i][j], " \n"[j == n]);
	}
	return 0;
}

Measured memory_bytes: 2176
#include<iostream>
using namespace std;
int main(){
  int num,mem[31];
  for(int i=1;i<31;i++){
    mem[i]=0;
  }
  for(int i=0;i<28;i++){
    cin >> num;
    mem[num]=1;
  }
  for(int i=1;i<31;i++){
    if(mem[i]==0){
      cout << i << endl;
    }
  }
  return 0;
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
using namespace std;
template<class t> inline t read(t &x){
	char c=getchar();bool f=0;x=0;
	while(!isdigit(c)) f|=c=='-',c=getchar();
	while(isdigit(c)) x=(x<<1)+(x<<3)+(c^48),c=getchar();
	if(f) x=-x;return x;
}
template<class t> inline void write(t x){
	if(x<0) putchar('-'),write(-x);
	else{if(x>9) write(x/10);putchar('0'+x%10);}
}

#define int long long

const int N=3e5+5;
int n,m,p,q,nm,cnt,ans,come[N],num,choose[N],c;

struct apple{
	int x,k;
	inline bool operator < (const apple &nt) const {
		return x>nt.x;
	}
}a[N];




signed main(){
	read(p);read(q);read(n);read(m);read(nm);
	for(int i=1,x;i<=n;i++) a[++cnt]=(apple){read(x),1};
	for(int i=1,x;i<=m;i++) a[++cnt]=(apple){read(x),2};
	for(int i=1,x;i<=nm;i++) a[++cnt]=(apple){read(x),0};
	sort(a+1,a+1+cnt);
	for(int i=1;(p||q)&&i<=cnt;i++){
		if(a[i].k==1){
			if(p) p--,choose[++c]=a[i].x,ans+=a[i].x;
		}
		if(a[i].k==2){
			if(q) q--,choose[++c]=a[i].x,ans+=a[i].x;
		}
		if(a[i].k==0){
			come[++num]=a[i].x;
		}
	}
	sort(choose+1,choose+1+c);
	sort(come+1,come+1+num,greater<int>());
	for(int i=1;i<=num&&i<=c;i++) if(come[i]>choose[i]) ans+=come[i]-choose[i];
	write(ans);
}

Measured memory_bytes: 8448
/*
ID: learnin7
TASK: test
LANG: C++                 
*/
/* LANG can be C++11 or C++14 for those more recent releases */
#include<bits/stdc++.h>

using namespace std;
typedef long long ll;

int main(){
        
    ios_base::sync_with_stdio(0);
    //ofstream fout ("test.out");
    //ifstream fin ("test.in");
    //fin >> a >> b;
    //fout << a+b << endl;
    string s;
    cin>>s;
    int x[26] = {0};
    for(int i=0;i<s.length();i++)   x[s[i]-'a']++;
    for(int i=0;i<26;i++){
        if(x[i]==0){
            cout<<char(i+'a')<<endl;
            return 0;
        }
    }
    cout<<"None\n";
    return 0;
}



Measured memory_bytes: 512