akhauriyash/Code-Regression huggingface dataset:
package main

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

func dummy() {
	math.Abs(1.0)
}

/************I/O***********/

var (
	// ReadString returns a WORD string.
	readString func() string
	stdout     *bufio.Writer
)

func init() {
	readString = newReadString(os.Stdin)
	stdout = bufio.NewWriter(os.Stdout)
}

func newReadString(ior io.Reader) func() string {
	r := bufio.NewScanner(ior)
	r.Buffer(make([]byte, 1024), int(1e+11))
	// Split sets the split function for the Scanner. The default split function is ScanLines.
	// Split panics if it is called after scanning has started.
	r.Split(bufio.ScanWords)

	return func() string {
		if !r.Scan() {
			panic("Scan failed")
		}
		return r.Text()
	}
}

// ReadInt returns an integer.
func readInt() int {
	return int(readInt64())
}

func readInt64() int64 {
	i, err := strconv.ParseInt(readString(), 0, 64)
	if err != nil {
		panic(err.Error())
	}
	return i
}

// ReadIntSlice returns an integer slice that has n integers.
func readIntSlice(n int) []int {
	b := make([]int, n)
	for i := 0; i < n; i++ {
		b[i] = readInt()
	}
	return b
}

// ReadFloat64 returns an float64.
func readFloat64() float64 {
	f, err := strconv.ParseFloat(readString(), 64)
	if err != nil {
		panic(err.Error())
	}
	return f
}

// ReadFloatSlice returns an float64 slice that has n float64.
func readFloat64Slice(n int) []float64 {
	b := make([]float64, n)
	for i := 0; i < n; i++ {
		b[i] = readFloat64()
	}
	return b
}

// ReadRuneSlice returns a rune slice.
func readRuneSlice() []rune {
	return []rune(readString())
}

/*********math********/
func mod(val int, m int) int {
	res := val % m
	if res < 0 {
		res += m
	}
	return res
}

func absInt(a int) int {
	if a < 0 {
		return -a
	}
	return a
}
func minInt(val ...int) int {
	res := val[0]
	for i := 1; i < len(val); i++ {
		if res > val[i] {
			res = val[i]
		}
	}
	return res
}
func maxInt(val ...int) int {
	res := val[0]
	for i := 1; i < len(val); i++ {
		if res < val[i] {
			res = val[i]
		}
	}
	return res
}

const MOD = 1000000007

func c(a int, b int) int {
	if a < 0 || b < 0 {
		return 0
	}

	res := 1
	for i := 0; i < b; i++ {
		res *= a - i
	}
	for i := 0; i < b; i++ {
		res = res / (i + 1)
	}
	return res
}

func main() {

	N := readInt()
	a := make([]int, N+1)
	a[0] = 0
	for i := 0; i < N; i++ {
		a[i+1] = readInt()
	}

	ans := make([]int, N)
	l := 0

	for i := N; i > 0; i-- {
		t := 0
		for j := 1; j <= N/i; j++ {
			if a[j*i] == 1 {
				t = 1 - t
			}
		}
		if t == 1 {
			ans[l] = i
			a[i] = 1
			l++
		} else {
			a[i] = 0
		}

	}
	fmt.Println(l)
	for i := 0; i < l; i++ {
		fmt.Println(ans[i])
	}

}


Measured memory_bytes: 5120
import java.math.BigInteger;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int r1 = scanner.nextInt();
        int c1 = scanner.nextInt();
        int r2 = scanner.nextInt();
        int c2 = scanner.nextInt();
        System.out.println(manyManyPaths(r1, c1, r2, c2));
    }

    public static int manyManyPaths(final int r1, final int c1, final int r2, final int c2){
        final int m = 1_000_000_007;
        final BigInteger bigM = BigInteger.valueOf(m);
        HashSet<Integer> neededFactors = new HashSet<>();
        HashSet<Integer> neededReversedFactors = new HashSet<>();
        HashMap<Integer, BigInteger> calculatedFactors = new HashMap<>();
        HashMap<Integer, BigInteger> calculatedReversedFactors = new HashMap<>();
        neededFactors.add(c1+r1);
        neededFactors.add(c1+r2+1);
        neededFactors.add(c2+r1+1);
        neededFactors.add(c2+r2+2);
        neededReversedFactors.add(c1);
        neededReversedFactors.add(r1);
        neededReversedFactors.add(r2+1);
        neededReversedFactors.add(c2+1);
        calculatedFactors.put(0, BigInteger.ONE);
        calculatedFactors.put(1, BigInteger.ONE);
        calculatedReversedFactors.put(0, BigInteger.ONE);
        calculatedReversedFactors.put(1, BigInteger.ONE);

        long tmp = 1;
        for (int i = 2; i <= c2+r2+2; i++) {
            tmp = tmp*i%m;
            if(neededFactors.contains(i)){
                calculatedFactors.put(i, BigInteger.valueOf(tmp));
            }
            if(neededReversedFactors.contains(i)){
                calculatedReversedFactors.put(i, BigInteger.valueOf(tmp).modInverse(bigM));
            }
        }
        return calculatedFactors.get(c1+r1).multiply(calculatedReversedFactors.get(c1)).multiply(calculatedReversedFactors.get(r1))
                .subtract(calculatedFactors.get(c1+r2+1).multiply(calculatedReversedFactors.get(c1)).multiply(calculatedReversedFactors.get(r2+1)))
                .subtract(calculatedFactors.get(c2+r1+1).multiply(calculatedReversedFactors.get(c2+1)).multiply(calculatedReversedFactors.get(r1)))
                .add(calculatedFactors.get(c2+r2+2).multiply(calculatedReversedFactors.get(c2+1)).multiply(calculatedReversedFactors.get(r2+1)))
                .mod(bigM).intValue();
    }
}


Measured memory_bytes: 50724
/*------------------------------------
........Bismillahir Rahmanir Rahim....
..........created by Abdul Aziz.......
------------------------------------*/
#include <iostream>
#include <algorithm>
#include <stdio.h>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <cstring>
#include <unordered_map>
#include <queue>
#define   mod  998244353
#define   int  long long 
#define   ld   long double
#define   pb   push_back
#define   vi  vector<int> 
#define   dbg(x)  cerr << #x << " = " << x << '\n'
#define   sz(x)  (int)x.size()
#define   ff   first
#define   ss   second
#define   pii  pair<int,int>
using namespace std;

inline void solve(){
    ld n,res; cin>>n; 
    cout.precision(10);
    res = floor(n/1.08) ; 
    if (floor(res*1.08)==n ) cout << res <<endl;
    else if (floor((res+1)*1.08)==n) cout << res+1 << endl;
    else cout << ":(" << endl; 
}

signed main()
{
    int n=1; // cin>>n;
    while (n--) solve();
    return 0;
}


Measured memory_bytes: 3796
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define fi first
#define se second
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repp(i, a, b) for (int i = a; i <= (b); ++i)
#define repr(i, a, b) for (int i = a; i >= (b); --i)
#define bit(n) (1LL << (n))
#define len(x) ((ll)(x).size())
#define debug(var) cout << "[" << #var << "]\n" << var << endl
#define int long long
typedef long long ll;
const int INF = 1001001001;
const ll LINF = 1001001001001001001ll;
const int MOD = 1000000007;
const double EPS = 1e-9;

template <typename T>
ostream& operator<<(ostream& s, const vector<T>& v) {
  int len = v.size();
  for (int i = 0; i < len; ++i) {
    s << v[i];
    if (i < len - 1)
      s << ' ';
  }
  return s;
}

template <typename T>
ostream& operator<<(ostream& s, const vector<vector<T>>& vv) {
  int len = vv.size();
  for (int i = 0; i < len; ++i) {
    s << vv[i];
    if (i != len - 1)
      s << '\n';
  }
  return s;
}

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

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

__attribute__((constructor)) void initial() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(15);
}
template <class T>
T find_max(T l, T r, bool f(T)) {
  T c;
  while (r - l > 1) {
    c = (r + l) / 2;
    if (f(c)) {
      l = c;
    } else {
      r = c;
    }
  }

  return l;
}


signed main() {
  int N;
  cin >> N;
  vector<int> D(N);
  vector<int> cnt(13);
  rep(i, N) {
    cin >> D[i];
    cnt[D[i]]++;
  }

  if (cnt[0] > 0) {
    cout << 0 << endl;
    return 0;
  }


  vector<int> det;
  vector<int> cand;

  repp(i, 1, 12) {
    if (cnt[i] >= 3) {
      cout << 0 << endl;
      return 0;
    } else if (cnt[i] == 2) {
      det.pb(i);
      det.pb(24 - i);
    } else if (cnt[i] == 1) {
      cand.pb(i);
    }
  }
  int M = len(cand);
  int ans = 0;
  /* 2bit */
  rep(b, bit(M)) {
    vector<int> temp = det;
    rep(i, M) {
      if ((b >> i) & 1)
        temp.pb(cand[i]);
      else
        temp.pb(24 - cand[i]);
    }


    int mn = INF;
    int L = len(temp);
    rep(i, L) {
      chmin(mn, temp[i]);
      chmin(mn, 24 - temp[i]);
    }
    rep(i, L) {
      repp(j, i + 1, L - 1) {
        chmin(mn, abs(temp[i] - temp[j]));
        chmin(mn, 24 - abs(temp[i] - temp[j]));
      }
    }
    chmax(ans, mn);
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
package main

import (
	"fmt"
)

func main() {
	var a, b, c, k int
	fmt.Scan(&a, &b, &c, &k)

	if k <= a {
		fmt.Println(k)
	} else if k <= a+b {
		fmt.Println(a)
	} else {
		fmt.Println(a*2 + b - k)
	}
}


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

using namespace std;

class nck {
    vector<long long> inv;
    vector<long long> frac;
    vector<long long> frac_inv;
    int mod;

public:
    nck(int n, int m) {
        inv = vector<long long>(n + 1, 0);
        frac = vector<long long>(n + 1, 0);
        frac_inv = vector<long long>(n + 1, 0);
        mod = m;

        inv[1] = 1;
        frac[0] = frac[1] = 1;
        frac_inv[0] = frac_inv[1] = 1;
        for (int i = 2; i <= n; i++) {
            inv[i] = mod - (inv[mod % i] * (mod / i)) % mod;
            frac[i] = (frac[i - 1] * i) % mod;
            frac_inv[i] = (frac_inv[i - 1] * inv[i]) % mod;
        }
    }

    int calc(int n, int k) {
        return (frac[n] * frac_inv[k] % mod) * frac_inv[n - k] % mod;
    }
};

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

    int l = 0, r = 0;
    vector<int> p(n, -1);
    for (int i = 0; i < n + 1; i++) {
        int a;
        cin >> a;

        if (p[a - 1] == -1) {
            p[a - 1] = i;
        } else {
            l = p[a - 1];
            r = i;
        }
    }

    long long mod = 1000000007;
    nck nck(n + 2, mod);

    for (int i = 1; i <= n + 1; i++) {
        if (n + l - r >= i - 1) {
            cout << (nck.calc(n + 1, i) - nck.calc(n + l - r, i - 1) + mod) % mod << endl;
        } else {
            cout << nck.calc(n + 1, i) << endl;
        }
    }
}


Measured memory_bytes: 3968
import sys
# input = sys.stdin.buffer.readline
def getN():
    return int(input())
def getNM():
    return map(int, input().split())
def getlist():
    return list(map(int, input().split()))
import math
import heapq
from collections import defaultdict, Counter, deque
MOD = 10**9 + 7
INF = 10**15

def main():
    n = getN()
    nums = getlist()
    hst = 0
    ans = 0
    for num in nums:
        if num >= hst:
            ans += 1
        hst = max(hst, num)

    print(ans)
if __name__ == '__main__':
    main()

"""
9999
3

2916
"""

Measured memory_bytes: 38384
W, H, x, y = map(int, input().split())

if W - 2*x == 0:
    if H - 2*y == 0:
        high = H/2
    else:
        high = 0
else:
    high = (H*W - W*y - H*x) / (W - 2*x)     # 縦に2分割する時の、Wのy座標

if H - 2*y == 0:
    if W - 2*x == 0:
        width = W/2
    else:
        width = 0
else:
    width =  (H*W - W*y - H*x) / (H - 2*y)   # 横に2分割する時の、Hのx座標

if (high > 0 and high < H) and (width > 0 and width < W):
    ans = 1
else:
    ans = 0
    
print(W*H/2, ans)


Measured memory_bytes: 3064
#include <set>
#include <map>
#include <list>
#include <queue>
#include <stack>
#include <cmath>
#include <ctime>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <numeric>
#include <complex>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <iostream>
#include <iterator>
#include <algorithm>

using namespace std;
using ll = long long;

#define INF 1000000007
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define ALL(x) (x).begin(),(x).end()
#define SIZE(x) ((int)(x).size())
#define MSG(a) cout << #a << " " << a << endl;

int main()
{
    ll n, k;
    cin >> n >> k;
    ll ans1 = n % k;
    ll ans2 = k - ans1;
    ll ans = min(ans1, ans2);
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 512
#include <stdio.h>
int main (){
	int a, b, c, count = 0;
	scanf("%d %d %d", &a,&b,&c);
	while(1){
		if(c % a == 0)
		count++;
			if(a == b) break;
			a++;
}
	printf("%d\n", count);
	
	return 0;
}

Measured memory_bytes: 596
/*
 
@author
_      _          _                 _      _
\\    // /\    | | \  |     |    /\ \\    //     
 \\  // /__\   | |_/  |_____|   /__\ \\  //
  \\// /    \  | | \  |     |  /    \ \\//
   \/ /      \ | |_/  |     | /      \ \/
@ Indian Institute of Technology Bhilai

With practice comes perfection,
with knowledge comes wisdom.
Incorporate wisdom in you, practice will harvest better results.
Always learn from others, your method is good but someone's even better.
Results take time, run for wisdom, for innovation, for getting better.
Points are mere objects, either you solve first or you solve better.
Seek for betterment, for quality, pace is important but cannot outstand
the quality you persist.
Times are bad just as now but it'll improve, this is my passion and I promise 
I won't let it go. I'll build myself again like a fighter gets back up after 
being thrown to the ground.
I'll learn. I bet that. I promise that.
*/
 
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ul;
#define rep(i,n) for(ll i=0; i<n; i++)
#define rep1(i,n) for(ll i=1; i<=n; i++)
#define pb push_back
#define fi first
#define se second
#define all(v) v.begin(), v.end()
#define alla(arr,n) arr, arr+n
#define yes cout<<"YES\n"
#define no cout<<"NO\n"
#define fsync ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
const ll maxx =  1e9+7;

bool compare(const pair<ll,ll> &a, const pair<ll,ll> &b){
    return a.fi>b.fi;
}

ll inline power(ll a, ll b, ll p){
    a %= p;
    ll ans = 1;
    while(b>0){
        if(b & 1)
            ans = (ans*a)%p;
        a = (a*a)%p;
        b >>= 1;
    }
    return ans;
}

ll inv(ll n, ll p){
    return power(n,p-2, p);
}

bool inline isPrime(ll n) { 
    if (n <= 1)  return false; 
    if (n <= 3)  return true; 
    if (n%2 == 0 || n%3 == 0) return false; 
    for (ll i=5; i*i<=n; i=i+6) 
        if (n%i == 0 || n%(i+2) == 0) 
           return false; 
    return true; 
}

template<class T>
void printv(T &v, ll n){
    if(n==-1)
        n = v.size();
    rep(i,n)
        cout << v[i] << " ";
    cout << "\n";
}

void solve(){
    ll n,k,x=1,l,r;
    cin>>n>>k;
    vector<ll> a(n+1);
    rep1(i,n)
        cin>>a[i];
    vector<ll> v;
    v.pb(1);
    rep1(i,n){
        x = a[x];
        v.pb(x);
    }
    vector<ll> o(n+1,-1);
    rep(i,n+1){
        if(o[v[i]] != -1){
            l = o[v[i]];
            r=i;
            break;
        }
        o[v[i]]=i;
    }
    if(k<=l){
        cout << v[k]<<"\n";
        return;
    }
    k-=l;
    cout << v[l+(k%(r-l))]<<"\n";
}

int main(){
    fsync
    ll test=1;
    // cin >> test;
    while(test--){
        solve();
    }
}

Measured memory_bytes: 7936
#include<string>
#include<vector>
#include<iostream>
#include<sstream>
#include<cstdio>
#include<cstdlib>
#include<functional>
#include<algorithm>
#include<stack>
#include<queue>
#include<deque>
#include<set>
#include<map>
#include<utility>
#include<cmath>
#include<ctime>
#include<complex>

using namespace std;

#define REP(i,s,e) for(int i=int(s);i<=int(e);i++)
#define rep(i,n) for(int i=0;i<int(n);i++)


int main(){


	while(true){
		int n,k,s;
		cin >> n >> k;
		if(n==0 && k==0) break;

	    vector<int>a;
        int sum=0; int m;
		rep(i,k){
		cin >> s;
		a.push_back(s);
		sum+=a[i];
		}

		m=sum;

		REP(i,k,n-1){
		cin >> s;
		a.push_back(s);
		sum+=a[i]-a[i-k];
		if(m<=sum) m=sum;

		}

		cout << m << endl;

		a.clear();

	}

	return 0;
}

Measured memory_bytes: 1724
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())

N,M = map(int,input().split())
check = UnionFind(N)
for i in range(M):
    a,b = map(int,input().split())
    check.union(a-1,b-1)
print(check.group_count()-1)

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

using namespace std;

#define ll long long
#define pb push_back
#define vi vector<int>
#define bn(n) (n).begin(), (n).end()
#define FOR(n) for(int i = 0; i < (int)n; i++)


void solve() {
    string a, b, c;
    cin >> a >> b >> c;
    string ans;
    ans += toupper(a[0]);
    ans += toupper(b[0]);
    ans += toupper(c[0]);
    cout << ans << "\n";
}

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

    int t = 1, i = 1;
    //cin >> t;
    while(t--) {
        //cout << "Case #" << i << ": ";
        solve();
        //i++;
    }
    return 0;
}


Measured memory_bytes: 3596
N, M = [int(x) for x in input().split()]

PY = []

Px = [0] * (N+1)
for i in range(M):
    p, y = [int(x) for x in input().split()]
    PY.append((i, p, y))

PY.sort(key=lambda x:x[2])
result = [None]*M
for i, p, y in PY:
    Px[p]+=1
    result[i] = "%06d%06d" % (p, Px[p])

for x in result:
    print(x)

# 2 3
# 1 32
# 2 63
# 1 12

# 000001000002
# 000002000001
# 000001000001


Measured memory_bytes: 29796
using System;
using System.Collections.Generic;

class Program
{
    static void Main(string[] args)
    {


		//long[] a = new long[n];




		int n = int.Parse(Console.ReadLine());
        string[] s = Console.ReadLine().Split(' ');
        int[] a = new int[n];
        //char[] c = s.ToCharArray();

        for (int i = 0; i < s.Length;i++)
        {
            a[i] = int.Parse(s[i]);
        }

        int re1 = 1;
        int re2 = 1;

		for (int i = 0; i < s.Length; i++)
		{
            re1 *= 3;
            if(a[i] %2==0)
            {
                re2 *= 2;
            }
		}

        Console.WriteLine("{0}",re1 - re2);

        return;
		//Console.WriteLine("");

	}
}

Measured memory_bytes: 13268
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n;
    cin >> n;
    string s;
    cin >> s;
    long r = 0;
    long g = 0;
    long b = 0;
    for(int i=0;i<s.length();i++){
        if(s[i] == 'R')r++;
        else if(s[i]=='G')g++;
        else b++;
    }
    long tmp = r*g*b;
    int maxLen = s.length();
    for(int i=1;i<4000;i++){
        for(int j=0;j<maxLen;j++){
            if(j+i+i >= maxLen)break;

            if(s[j] != s[j+i] && s[j] != s[j+i+i] && s[j+i] != s[j+i+i])tmp--;
        }
    }
    cout << tmp << endl;
}

Measured memory_bytes: 3608
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
#define f(i, l, r) for (int i = l; i <= r; i++)
#define rf(i, r, l) for (int i = r; i >= l; i--)
#define all(x) (x).begin(), (x).end()
#define sf(a) scanf("%d",&a)
#define llsf(a) scanf("%lld", &a)
#define l l
#define r r
#define lch (o << 1)
#define rch (o << 1 | 1)
#define mid ((l + r) >> 1)
#define mem(x, y) memset(x, y, sizeof(x))

const int inf = 2e9 + 7;
const ll INF = INT64_MAX;
double eps = 1e-6;
int mod = 1e9 + 7;
const int N = 1e6 + 10;
const double pi = acos(-1.0);

int main() {
#ifdef local
	freopen("in.txt", "r", stdin);
#endif
	int n; sf(n);
	int a[200];
	int mx = 0, mi = 1e9 + 10;
	f(i, 1, n)sf(a[i]), mx = max(mx, a[i]), mi = min(mi, a[i]);
	cout << mx - mi;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
import sys
# sys.setrecursionlimit(10**6)
# buff_readline = sys.stdin.buffer.readline
buff_readline = sys.stdin.readline
readline = sys.stdin.readline

INF = 2**62-1


def read_int():
    return int(buff_readline())


def read_int_n():
    return list(map(int, buff_readline().split()))


def read_float():
    return float(buff_readline())


def read_float_n():
    return list(map(float, buff_readline().split()))


def read_str():
    return readline().strip()


def read_str_n():
    return readline().strip().split()


def error_print(*args):
    print(*args, file=sys.stderr)


def mt(f):
    import time

    def wrap(*args, **kwargs):
        s = time.time()
        ret = f(*args, **kwargs)
        e = time.time()

        error_print(e - s, 'sec')
        return ret

    return wrap


class SegmentTree:
    def __init__(self, array, operator, identity_element):
        _len = len(array)
        self.__op = operator
        self.__size = 1 << (_len - 1).bit_length()
        self.__tree = [identity_element] * self.__size + \
            array + [identity_element] * (self.__size - _len)
        self.__ie = identity_element

        for i in range(self.__size - 1, 0, -1):
            self.__tree[i] = operator(
                self.__tree[i * 2], self.__tree[i * 2 + 1])

    def update(self, i, v):
        i += self.__size
        self.__tree[i] = v
        while i:
            i //= 2
            self.__tree[i] = self.__op(
                self.__tree[i * 2], self.__tree[i * 2 + 1])

    def query(self, l, r):
        """[l, r)
        """
        l += self.__size
        r += self.__size
        ret = self.__ie
        while l < r:
            if l & 1:
                ret = self.__op(ret, self.__tree[l])
                l += 1
            if r & 1:
                r -= 1
                ret = self.__op(ret, self.__tree[r])
            l //= 2
            r //= 2
        return ret


@mt
def slv(N, P):
    pi = [(p, i) for i, p in enumerate(P)]
    pi.sort()
    p, i = pi.pop()
    lst = SegmentTree([-1]*N, max, -1)
    rst = SegmentTree([N]*N, min, N)
    lst.update(i, i)
    rst.update(i, i)

    ans = 0
    while pi:
        p, i = pi.pop()
        li = lst.query(0, i)
        lli = lst.query(0, li)
        ri = rst.query(i, N)
        rri = rst.query(ri+1, N)
        lst.update(i, i)
        rst.update(i, i)
        ln = (li-lli) * (ri-i)
        rn = (rri-ri) * (i-li)
        ans += (ln + rn) * p
    return ans


def main():
    N = read_int()
    P = read_int_n()
    print(slv(N, P))


if __name__ == '__main__':
    main()


Measured memory_bytes: 117752
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int N = scan.nextInt();
		int D = scan.nextInt();
		scan.close();

		int res = N/(2*D+1);
		
		if(N%(2*D+1)>0) {
			res++;
		}
		System.out.println(res);
	}

}

Measured memory_bytes: 22356
#include<stdio.h>
int main(){
   int a,b,c,k;
   scanf("%d%d%d%d",&a,&b,&c,&k);
   if(k<=a){
      printf("%d",k);
   }else if(k<=a+b){
      printf("%d",a);
   }else{
      printf("%d",2*a+b-k);
      return 0;
   }
}


Measured memory_bytes: 2156
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int N=1<<19;
ll Mi[2222222],Ma[2222222],A[2222222];
class StarrySkyTree{
public:
  void init(){fill(Mi,Mi+2222222,0);fill(Ma,Ma+2222222,0);fill(A,A+2222222,0);}
  void add(int a,int b,int x,int k=0,int l=0,int r=N) {
    if(r<=a||b<=l) return;
    if(a<=l&&r<=b){
      A[k]+=x;
      while(k){
        k=(k-1)/2;
        Mi[k]=min(Mi[k*2+1]+A[k*2+1],Mi[k*2+2]+A[k*2+2]);
        Ma[k]=max(Ma[k*2+1]+A[k*2+1],Ma[k*2+2]+A[k*2+2]);
      }
      return;
    }
    add(a,b,x,k*2+1,l,(l+r)/2);
    add(a,b,x,k*2+2,(l+r)/2,r);
  }
  ll getMin(int a,int b,int k=0,int l=0,int r=N) {
    if(r<=a||b<=l)return LLONG_MAX;if(a<=l&&r<=b)return Mi[k]+A[k];
    ll left=getMin(a,b,k*2+1,l,(l+r)/2),right=getMin(a,b,k*2+2,(l+r)/2,r);
    return min(left,right)+A[k];
  }
  ll getMax(int a,int b,int k=0,int l=0,int r=N) {
    if(r<=a||b<=l)return -LLONG_MAX;if(a<=l&&r<=b)return Ma[k]+A[k];
    ll left=getMax(a,b,k*2+1,l,(l+r)/2),right=getMax(a,b,k*2+2,(l+r)/2,r);
    return max(left,right)+A[k];
  }
};

int main() {
  int n;
  cin >> n;
  ll a[n];
  for(int i=0; i<n; i++) cin >> a[i];
  StarrySkyTree b;
  b.init();
  for(int i=0; i<n/2; i++) b.add(i,i+1,a[i]-a[n-1-i]);
  int m;
  cin >> m;
  while(m--) {
    int x,y,z;
    cin >> x >> y >> z;
    x--,y--;
    if(y<n/2) b.add(x,y+1,z);
    else if(n/2<=x) {
      x=n-x-1;
      y=n-y-1;
      b.add(y,x+1,-z);
    } else {
      y=n-y-1;
      b.add(x,n/2+1,z);
      b.add(y,n/2+1,-z);
    }
    ll mi=b.getMin(0,n/2+1);
    ll ma=b.getMax(0,n/2+1);
    if(!mi&&!ma) cout << 1 << endl;
    else cout << 0 << endl;
  }
  return 0;
}


Measured memory_bytes: 59084
import sys
sys.setrecursionlimit(10**7)
from collections import deque
from heapq import heappush, heappop
def solve():
    H,W = map(int, input().split())
    A = [ list(input()) for _ in range(H)]
    HMANY = [ [10**9] * W for _ in range(H)]
    
    for h in range(H):
        for w in range(W):
            if A[h][w] == "#" :
                HMANY[h][w] = 0
    for w in range(W):
        for h in range(H-1):
            if HMANY[h][w]+1 < HMANY[h+1][w]:
                HMANY[h+1][w] = HMANY[h][w] + 1
        for h in range(H-1, 0, -1):
            if HMANY[h][w]+1 < HMANY[h-1][w]:
                HMANY[h-1][w] = HMANY[h][w] + 1
    
    for h in range(H):
        for w in range(W-1):
            if HMANY[h][w]+1 < HMANY[h][w+1]:
                HMANY[h][w+1] = HMANY[h][w] + 1
        for w in range(W-1, 0, -1):
            if HMANY[h][w]+1 < HMANY[h][w-1]:
                HMANY[h][w-1] = HMANY[h][w] + 1        

    ans = 0
    for h in range(H):
        ans = max(ans, max(HMANY[h]))
    # print(ans-1)
    print(ans)

if __name__ == "__main__":
    solve()

Measured memory_bytes: 50876
#include<cstdio>

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

Measured memory_bytes: 2636
// #include <iostream>
// #include <string>
// #include <vector>
// #include <algorithm>
// #include <utility>

// #define NMAX 200002

// using namespace std;

// typedef pair<string,int> P;

// int main(){
// 	int N,now = 1,count[NMAX] = {},m = 0;
// 	// string S[NMAX];
// 	std::vector<string> v;
// 	std::vector<P> S;
// 	cin >> N;
// 	for (int i = 0; i < N; ++i)
// 	{
// 		string s;
// 		cin >> s;
// 		if(i == 0){
// 			S.push_back(P(s,1));
// 			// S[0] = s;
// 			// count[0]++;
// 		}else{
// 			// for (int j = 0; j < now; ++j)
// 			// {
// 			// 	if(S[j] == s){
// 			// 		count[j]++;
// 			// 		break;
// 			// 	}
// 			// 	if(j == now-1){
// 			// 		S[now] = s;
// 			// 		now++;
// 			// 	}
// 			// }
// 			vector<P>:: iterator it = find_if(S.begin(), S.end(),[=](P a){return a.first == s;});
// 			if(it != S.end()){
// 				it->second++;
// 			}else{
// 				S.push_back(P(s,1));
// 				now++;
// 			}
// 		}
// 	}
// 	for (int i = 0; i < now; ++i)
// 	{
// 		m = max(m,S[i].second);
// 	}
// 	for (int i = 0; i < now; ++i)
// 	{
// 		if(S[i].second == m){
// 			v.push_back(S[i].first);
// 		}
// 	}
// 	sort(v.begin(), v.end());
// 	for (int i = 0; i < v.size(); ++i)
// 	{
// 		cout << v[i] << endl;
// 	}
// 	return 0;
// }

#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <map>

#define NMAX 200002

using namespace std;

typedef pair<string,int> P;

int main(){
	int N,now = 1,count[NMAX] = {},m = 0;
	// string S[NMAX];
	std::map<string,int> S;
	std::vector<string> v;
	cin >> N;
	for (int i = 0; i < N; ++i)
	{
		string s;
		cin >> s;
		S[s]++;
	}
	for(const auto& x:S){
		int i = x.second;
		m = max(m,i);
	}
	for (const auto& x:S)
	{
		if(x.second == m){
			cout << x.first << endl;
		}
		// if(S[i].second == m){
		// 	v.push_back(S[i].first);
		// }
	}
	// sort(v.begin(), v.end());
	// for (int i = 0; i < v.size(); ++i)
	// {
	// 	cout << v[i] << endl;
	// }
	return 0;
}

Measured memory_bytes: 25216
package main

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

func main() {
	sc := bufio.NewScanner(os.Stdin)
	sc.Scan()
	a, _ := strconv.Atoi(sc.Text())
	if a >= 3200 {
		sc.Scan()
		fmt.Println(sc.Text())
	} else {
		fmt.Println("red")
	}
}


Measured memory_bytes: 640
def main():
  MINF = -10 ** 20
  
  n, m = map(int, input().split())
  xlst = []
  ylst = []
  zlst = []
  for _ in range(n):
    x, y, z = map(int, input().split())
    xlst.append(x)
    ylst.append(y)
    zlst.append(z)
  """
  dp[a] ... 使用数aでの最大スコア
  """
  
  def func(xf, yf, zf):
    dp = [MINF for _ in range(m + 1)]
    dp[0] = 0
    for i in range(n):
      scorei = xlst[i] * xf + ylst[i] * yf + zlst[i] * zf
      for j in range(m, 0, -1):
        dpj = dp[j]
        dpj1 = dp[j - 1] + scorei
        if dpj < dpj1:
          dp[j] = dpj1
    return dp[m]
  
  ans = 0
  for xf in (-1, 1):
    for yf in (-1, 1):
      for zf in (-1, 1):
        ans = max(ans, func(xf, yf, zf))
  print(ans)

main()

Measured memory_bytes: 3188
#include <iostream>
#include <algorithm>
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string>
#include <vector>
#include <cctype>
#include <cstdio>
#include <iomanip>
 
using namespace std;
 
string in, t;
double a, b, c, d;
 
 
int main(){
    cin >> a >> c >> b >> d;
    cout << fixed << setprecision(5) << sqrt(fabs(a - b)*fabs(a - b)*1.0 + fabs(c - d)*fabs(c - d)*1.0) << endl;
}

Measured memory_bytes: 1284
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ull;
typedef long long int ll;
#define ll long long
#define dd double
#define MOD 1000000007
#define nl cout<<endl
#define rt ll Q[100005]={0}
#define mp make_pair
#define test() ull t;cin>>t;while(t--)
#define pb push_back
#define ff first    
#define ss second
#define all(v) v.begin(),v.end()
#define s(ar,n) sort(ar,ar+n)
#define rs(ar,n) sort(ar, ar+n, greater<ll>()) 
#define oa(a,n) for(ll i=0;i<n;i++)cout<<a[i]<<" ";nl
#define cn(a,n) for(ll i=0;i<n;i++)cin>>a[i];
#define ov(a,n) for(ll i=0;i<n;i++)cout<<a[i]<<" ";nl
#define ovp(a,n) for(ll i=0;i<n;i++)cout<<a[i].ff<<" "<<a[i].ss<<endl;
#define maxa(ar,N) *max_element(ar,ar+N)
#define mina(ar,N) *min_element(ar,ar+N)
#define fastio() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
typedef pair<int,int> pii;
ll powe(ll n,ll m){if(m==0)return 1;ll t=powe(n,m/2);if(m%2==0)return (t*t);return (((t*t))*n);}
ll mpowe(ll n,ll m){if(m==0)return 1;ll t=powe(n,m/2);t%=MOD;if(m%2==0)return (t*t)%MOD;return (((t*t)%MOD)*n)%MOD;}
ll logtwo(ll n){if(n==1)return 0;return logtwo(n/2)+1;}

int main()
{
    fastio();
    ll h,c,n,sum=0;
    cin >> h  >> n;
    ll a[n];
    for(c=0;c<n;c++)
    {
        cin >> a[c];
        sum=sum+a[c];
    }
    
    if(sum>=h)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
    
}

Measured memory_bytes: 1024
#!/usr/bin/env python
import os
import operator
import sys
from io import BytesIO, IOBase

def inar():
    return [int(k) for k in input().split()]
def main():
    s=input()
    t=input()
    dp=[]
    arrow=[]
    for i in range(len(t)+1):
        lis=[0 for k in range(len(s)+1)]
        lis1=["" for l in range(len(s)+1)]
        dp.append(lis)
        arrow.append(lis1)
    for i in range(1,len(t)+1):
        for j in range(1,len(s)+1):
            if t[i-1]==s[j-1]:
                dp[i][j]=dp[i-1][j-1]+1
                arrow[i][j]="C"
            else:
                if dp[i][j-1]>dp[i-1][j]:
                    dp[i][j]=dp[i][j-1]
                    arrow[i][j]="L"
                else:
                    dp[i][j]=dp[i-1][j]
                    arrow[i][j]="U"
    res=""
    i=len(t)
    j=len(s)
    # for i in range(len(t)+1):
    #     print(*arrow[i])
    while 1:
        if i==0 or j==0:
            break
        if arrow[i][j]=="C":
            res+=s[j-1]
            i-=1
            j-=1
        elif arrow[i][j]=="U":
            i-=1
        else:
            j-=1
    print(res[::-1])



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")


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

if __name__ == "__main__":
    main()

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

bool check(int t,int x,int y) {
  if(x+y > t) {
      return false;
  }
  int d = (t-(x+y)) % 2;
  if(d != 0) {
    return false;
  }
  return true;
}
  
int main() {
  int n;
  cin >> n;
  int t0, x0, y0;
  cin >> t0 >> x0 >> y0;
  if(!check(t0, abs(x0), abs(y0))) {
    cout << "No" << endl;
    return 0;
  }
  for(int i=1; i<n; i++) {
    int t, x, y;
    cin >> t >> x >> y;
    if(!check(t-t0, abs(x-x0), abs(y-y0))) {
      cout << "No" << endl;
      return 0;
    }
    t0 = t;
    x0 = x;
    y0 = y;
  }
  cout << "Yes" << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <stack>
#include <queue>
#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
ll mod = 1000000007;
 
int main() {
    int n, k;
    cin >> n >> k;

    vector<ll> a(n), b(n);
    rep(i, n) {
        cin >> a[i];
        b[i] = max(0LL, a[i]);
    }

    vector<ll> ruiA(n+1), ruiB(n+1);  // ruiA[i+1] : a[i]までの累積和
    rep(i, n) {
        ruiA[i+1] = ruiA[i] + a[i];
        ruiB[i+1] = ruiB[i] + b[i];
    }

    ll ans = 0;
    rep(i, n-k+1) {  // a[i]から始まる長さkの区間(a[i] ～ a[i+(k-1)])を塗る
        rep(color, 2) {  // 上記の長さkの区間を、0のとき白、1のとき黒に塗る

            ll now = (ruiB[i] - ruiB[0]) + (ruiB[n] - ruiB[i+k]);
            
            if(color) {
                now += ruiA[i+k] - ruiA[i];
            }
            
            ans = max(ans, now);
        }
    }
    
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3328
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<math.h>
#include<stack>
#include<queue>
#include<vector>
#include<algorithm>
#include<string>
#include<iostream>
#include<set>
#include<map>
#include<bitset>

using namespace std;
typedef long long ll;
#define i_7 1000000007
#define i_5 1000000005

ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    else return c+i_7;
}
typedef pair<int,int> i_i;
typedef pair<ll,ll> l_l;
#define inf 100000000/*10^8*/
#define rep(i,l,r) for(int i=l;i<=r;i++)
const double EPS=1E-8;

////////////////////////////////////////
#define MAX_V 400//調節！！！！！！！！！！！！！！！！！！！！！！！！！！！！！！！
//辺を表す構造体{行き先、容量、逆辺}
struct edge{int to,cap,rev;};
vector<edge> G[MAX_V];
bool used[MAX_V];//dfsですでに調べたかのフラグ
//fromからtoへの流量capの辺をグラフに追加
void add_edge(int from,int to,int cap){
    G[from].push_back((edge){to,cap,static_cast<int>(G[to].size())});
    G[to].push_back((edge){from,0,static_cast<int>(G[from].size()-1)});
}
//増加パスをdfsで探す
int dfs(int v,int t,int f){
    if(v==t)return f;
    used[v]=true;
    for(int i=0;i<G[v].size();i++){
        edge &e=G[v][i];
        if(!used[e.to]&&e.cap>0){
            int d=dfs(e.to,t,min(f,e.cap));
            if(d>0){
                e.cap-=d;
                G[e.to][e.rev].cap+=d;
                return d;
            }
        }
    }
    return 0;
}
int max_flow(int s,int t){
    int flow=0;
    while(1){
        memset(used,0,sizeof(used));
        int f=dfs(s,t,inf);
        if(f==0)return flow;
        flow+=f;
    }
}
/////////////////////////////////////////////
int main(){
    int n;cin>>n;
    i_i a[n],b[n];
    rep(i,0,n-1)cin>>a[i].first>>a[i].second;
    rep(i,0,n-1)cin>>b[i].first>>b[i].second;
    rep(i,0,n-1){
        rep(j,0,n-1){
            if(a[i].first<b[j].first&&a[i].second<b[j].second){
                add_edge(1+i,n+j+ 1,1);
            }
        }
    }
    rep(i,1,n){
        add_edge(0,i,1);
        add_edge(n+i,2*n+1,1);
    }
    cout<<max_flow(0,2*n+1)<<endl;
    
    return 0;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
#define _USE_MATH_DEFINES
using namespace std;
    
#define ll long long int
#define pb push_back
#define rep(i , j , n) for(ll i = j ; i < n ; i++)
#define pre(i , j , n) for(ll i = j ; i >= n ; i--)
#define all(x) x.begin(), x.end()
typedef pair<int, int>	pii;
typedef pair<ll, ll>	pl;
typedef vector<int>		vi;
typedef vector<ll>		vll;
typedef vector<char>	vc;
typedef vector<bool>	vb;
typedef pair<ll,ll> 	pll;
#define br "\n"
#define ff first
#define ss second
ll MAX =  (ll)1000005;
ll mod =  1e9 + 7;

vector<set<ll>> grid;
vector<bool> vis;

ll dfs(ll u){
    ll c=0;
    vis[u] = true;
    for(auto v:grid[u]){
        if(!vis[v]){
            c += dfs(v);
        }
    }
    c++;
    return c;
    
}

void solve(){
    ll n,m;
    cin >> n >> m;
    grid.resize(n + 1);
    vis.assign(n + 1,false);
    rep(i,0,m){
        ll a,b;
        cin >> a >> b;
        grid[a].insert(b);
        grid[b].insert(a);
    }
    ll ans = 0;
    rep(i,1,n + 1){
        if(!vis[i]) ans = max(ans,dfs(i));
    }
    cout << ans;

}
	

int main(){
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif  

	ll t = 1;
	// cin >> t;
	rep(i,0,t){
		solve();
	}
 
}	

Measured memory_bytes: 40596
#include <iostream>
using namespace std;
int main(void){
    string S,T;
    int a;
    a = 0;
    int i;
    cin >> S >> T;
    for(i = 0; i < S.size(); i++){
        if(S[i] != T[i]){
            a++;
        }
    }
    cout << a << endl;
    return 0;
}


Measured memory_bytes: 3784
#include <bits/stdc++.h>
#define all(a) a.begin(), a.end()
#define db(a) cout << fixed << #a << " = " << a << endl;

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
const int MAXN = 3000 + 5;
const ll MOD = 998244353;
ll dp[MAXN][MAXN];
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	ll A, B, C, D;
	cin >> A >> B >> C >> D;
	dp[A][B] = 1;
	for (ll i = A + 1; i <= C; i++) dp[i][B] = (dp[i - 1][B] * B) % MOD;
	for (ll i = B + 1; i <= D; i++) dp[A][i] = (dp[A][i - 1] * A) % MOD;
	for (ll i = A + 1; i <= C; i++) {
		for (ll j = B + 1; j <= D; j++) {
			dp[i][j] = dp[i - 1][j] * j + dp[i][j - 1] * i - dp[i - 1][j - 1] * (j - 1) * (i - 1);
			//dp[i][j] = dp[i - 1][j - 1] * ( i * j - 1);
			dp[i][j] %= MOD;
		}
	}
	
	cout << (dp[C][D] + MOD) % MOD  << endl;
}



Measured memory_bytes: 73996
#include<bits/stdc++.h>
using namespace std;
#define ar array
#define endl '\n'
#define ll long long
#define in insert
#define pb push_back
#define vt vector
#define P_Q(x) priority_queue<x>
#define p_q(x) priority_queue<x, vector<x>, greater<x>>
#define Rep(i,a,b) for(int i=a;i<=b;i++)
#define Rev(i,a,b) for(ll i=a;i>=b;i--)
#define FOR(m) Rep(i,1,m)
#define For(m) Rep(i,0,m-1)
#define Rbl(x,a) for(auto &x : a)
#define FIO ios::sync_with_stdio(0);   cin.tie(0);
#define F first
#define S second
#define pii pair<int,int>
#define pll pair<ll,ll>
#define mp make_pair
#define vpii vector<pii>
#define vpll vector<pll>
#define all(x) (x).begin(),(x).end()
#define sz(x) (int) (x).size()
const ll INF = 0x3f3f3f3f3f3f3f3fll;
#define mod 1000000007
 
const int mxN = 2e5 + 1;
//ll a[mxN];
ll n;
 
 
int main()
{
FIO
 
    cin >> n;
    string c[4] = {"AC", "WA", "TLE", "RE"};
    string s;
    map<string, int> m;
    For(n)
    {
        cin >> s;
        m[s]++;
    }
    For(4)
    {
        cout << c[i] << " x " << m[c[i]] << endl;
    }

     
    return 0;
}

Measured memory_bytes: 3664
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<map>
#include<set>
#include<cstdio>
#include<cmath>
#include<numeric>
#include<queue>
#include<stack>
#include<cstring>
#include<limits>
#include<functional>
#include<unordered_set>
#include<iomanip>
#include<cassert>
#define rep(i,a) for(int i=(int)0;i<(int)a;++i)
#define pb push_back
#define eb emplace_back
using ll=long long;
constexpr ll mod = 1e9 + 7;
constexpr ll INF = 1LL << 50;
 
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
using namespace std;

double dp[305][305][305];
int n;

double rec(int i,int j,int k){
    if(dp[i][j][k]>=0)return dp[i][j][k];
    if(i==0&&j==0&&k==0)return 0.0;
    double res=0.0;
    if(i>0)res+=rec(i-1,j,k)*((double)i/(double)n);
    if(j>0)res+=rec(i+1,j-1,k)*((double)j/(double)n);
    if(k>0)res+=rec(i,j+1,k-1)*((double)k/(double)n);
    return dp[i][j][k]=(double(n)/(double)(i+j+k))*(res+1.0);
}

void solve(){
    cin>>n;
    vector<double>a(n);
    memset(dp,-1,sizeof(dp));
    int one=0,two=0,three=0;
    rep(i,n){
        cin>>a[i];
        if(a[i]==1)++one;
        else if(a[i]==2)++two;
        else ++three;
    }
    cout<<rec(one,two,three)<<"\n";
}
 
signed main(){
	ios::sync_with_stdio(false);
    cin.tie(0);
	cout<<fixed<<setprecision(15);
	solve();
	return 0;
}

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

namespace id_0589cs
{
    class OriginalComparer : IComparer<string>
    {
        public int Compare(string x, string y)
        {
            if (x.Length > y.Length) return 1;
            if (x.Length < y.Length) return -1;
            return StringComparer.CurrentCulture.Compare(x, y);
        }
    }
    class Program
    {
        static void Main(string[] args)
        {
            var n = int.Parse(Console.ReadLine());
            var productionDictionary = new SortedDictionary<string, int>(new OriginalComparer());
            foreach (var i in Enumerable.Range(0, n))
            {
                var vs = Console.ReadLine().Split(' ').ToArray();
                if (productionDictionary.ContainsKey(vs[0]))
                {
                    var valNow = productionDictionary[vs[0]];
                    productionDictionary[vs[0]] = valNow + int.Parse(vs[1]);
                }
                else
                {
                    productionDictionary[vs[0]] = int.Parse(vs[1]);
                }
            }
            foreach (KeyValuePair<string, int> pair in productionDictionary)
            {
                Console.WriteLine("{0} {1}", pair.Key, pair.Value);
            }
        }
    }
}



Measured memory_bytes: 21856
X = int(input())


if (400 <= X) and (X <= 599):
    print(8)

if (600 <= X) and (X <= 799):
    print(7)

if (800 <= X) and (X <= 999):
    print(6)

if (1000 <= X) and (X <= 1199):
    print(5)

if (1200 <= X) and (X <= 1399):
    print(4)

if (1400 <= X) and (X <= 1599):
    print(3)

if (1600 <= X) and (X <= 1799):
    print(2)

if (1800 <= X) and (X <= 1999):
    print(1)






Measured memory_bytes: 9204
#include<stdio.h>

int main()
{
    long long n,k,x,y,ans;
    scanf("%lld %lld %lld %lld",&n,&k,&x,&y);

    if(n<=k)
    {
        ans = n*x;
    }

    else if(n>k)
    {
        ans = (k*x)+((n-k)*y);
    }

    printf("%lld\n",ans);
    return 0;
}


Measured memory_bytes: 128
#include<algorithm>
#include<cassert>
#include<climits>
#include<cmath>
#include<cstring>
#include<deque>
#include<functional>
#include<iomanip>
#include<iostream>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<unordered_map>
#include<unordered_set>
#include<utility>
#include<vector>

using namespace std;

using lint = long long;
using P = pair<int, int>;
using LLP = pair<long long, long long>;

#define REP(i, x, n) for(int i = (x), i##_len = int(n) ; i < i##_len ; ++i)
#define rep(i, n) for(int i = 0, i##_len = int(n) ; i < i##_len ; ++i)
#define reps(i, n) for(int i = 1, i##_len = int(n) ; i <= i##_len ; ++i)
#define rrep(i, n) for(int i = int(n) - 1 ; i >= 0 ; --i)
#define rreps(i, n) for(int i = int(n) ; i > 0 ; --i)
#define SORT(x) sort((x).begin(), (x).end())
#define SORT_INV(x) sort((x).rbegin(), (x).rend())
#define TWINS(x) cout << ((x) ? "Yay!" : ":(") << endl

constexpr int IINF = (1 << 30) - 1;
constexpr long long LLINF = 1LL << 61;
constexpr double EPS = 1e-8;

const int dx4[] = {1, 0, -1, 0}, dy4[] = {0, 1, 0, -1};
const int dx8[] = {1, 1, 0, -1, -1, -1, 0, 1}, dy8[] = {0, -1, -1, -1, 0, 1, 1, 1};

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

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

int query(int u, int v){
    cout << "? " << u << " " << v << endl;
    int res;
    cin >> res;
    return res;
}

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

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

    int cost = query(s, t);

    vector<int> a(n + 1, 0), b(n + 1, 0);
    a[t] = cost;
    b[s] = cost;
    map< int, vector<int> > mp;
    reps(i, n){
        if(i == s || i == t){
            continue;
        }
        a[i] = query(s, i);
        b[i] = query(i, t);
        if(a[i] + b[i] == cost){
            mp[a[i]].emplace_back(i);
        }
    }
    mp[cost].emplace_back(t);

    vector<int> ans = {s};
    for(auto it = mp.begin() ; it != mp.end() ; ++it){
        for(auto x : (*it).second){
            int q = query(ans.back(), x);
            if(q == a[x] - a[ans.back()]){
                ans.emplace_back(x);
                break;
            }
        }
    }

    cout << '!';
    rep(i, ans.size()){
        cout << ' ' << ans[i];
    }
    cout << endl;

    return 0;
}


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

char incrementChar(char x){
    return static_cast<char>(x + 1);
}

int weekToInt(string x){
    int num;
    if(x == "SUN"){
        num = 1;
    }else if(x == "MON"){
        num = 2;
    }else if(x == "TUE"){
        num = 3;
    }else if(x == "WED"){
        num = 4;
    }else if(x == "THU"){
        num = 5;
    }else if(x == "FRI"){
        num = 6;
    }else if(x == "SAT"){
        num = 7;
    }else{
        num = 0;
    }

    return num;
}

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

    cout << 8 - weekToInt(S) << endl;

    return 0;
}


Measured memory_bytes: 256
S = input()

count = 0

if len(S) != 3:
    for i in range(len(S)//2):
        if S[i] == S[len(S)-i-1]:
            count += 1
else:
    if S[0] == S[2]:
        count = 1

if count == len(S)//2:
    if S[0:len(S)//2] == S[(len(S)//2)+1:len(S)]:
        print('Yes')
    else:
        print('No')
else:
    print('No')



Measured memory_bytes: 3064