akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

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


int main() {
    long long N;
    while (cin >> N) {
        if (N == 1) {
            cout << "a" << endl;
            return 0;
        }
        --N;

        vector<long long> res;
        while (true) {
            res.push_back(N % 26);
            N /= 26;
            if (N == 0) break;
            --N;
        }
        reverse(res.begin(), res.end());

        string ans = "";
        for (int i = 0; i < res.size(); ++i) ans += (char)(res[i] + 'a');
        cout << ans << endl;

        /*
        for (int i = 0; i + 1 < res.size(); ++i) --res[i];
        cout << res << endl;
        */
    }
}

















Measured memory_bytes: 3628
// Sakhiya07 - Yagnik Sakhiya
 
#include <bits/stdc++.h>
using namespace std;
 
#define ll long long int
#define ld long double

#define pll pair<ll,ll>
#define ff first
#define ss second

#define pb push_back
#define all(x) x.begin(),x.end()

#define MOD  1000000007
const int N = 100005; 

#define FAST ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);srand(time(NULL));

vector<ll> v[N];
ll dp[N][2];

void dfs(ll id,ll p)
{
    ll black = 1,white = 1;
    for(auto X:v[id])
    {
        if(X!=p)
        {
            dfs(X,id);
            white = (white * (dp[X][0] + dp[X][1])%MOD)%MOD;
            black = (black * (dp[X][1]))%MOD;
        }
    }
    dp[id][0] = black;
    dp[id][1] = white;
}

void solve()
{
    ll n;
    cin >> n;
    for(ll i=0,x,y;i<n-1;i++)
    {
        cin >> x >> y;
        v[x].pb(y);
        v[y].pb(x);    
    } 
    dfs(1,0);
    ll ans = dp[1][0] + dp[1][1];
    ans %= MOD;
    cout<<ans;
}

int main()
{
    FAST;
    int t = 1;
 // cin >> t;
    for(int i=1;i<=t;i++)
    {
        solve();
    }
}

Measured memory_bytes: 18940
n = int(input())
A = []
B = []
for i in range(n):
    x = [int(i) for i in input().split()]
    A.append(x[0])
    B.append(x[1])
A = sorted(A)
B = sorted(B)
if n % 2:
    med_A = A[n//2]
    med_B = B[n//2]
    print(abs(med_A - med_B) + 1)
else:
    med_A  = A[(n-1)//2]+A[n//2] # this is double of median
    med_B = B[(n-1)//2]+B[n//2]
    print(abs(med_A - med_B) + 1) # we want gap of 1/2

Measured memory_bytes: 27120
#include<stdio.h>                                                              
 
int main(){
	long int taka,aoki,koudou;
	int i;
 	if(scanf("%ld%ld%ld",&taka,&aoki,&koudou)<3) return -1;
 	if(taka<koudou){
		koudou -= taka;
		taka = 0;
     	if(aoki<koudou){
       		koudou -= aoki;
       		aoki = 0;
     	}
    else{
      if(aoki>koudou) aoki-=koudou;
      else aoki = 0;
   		}
 	}
   	else{
     	if(taka>koudou) taka-=koudou;
      else taka = 0;
   	}
   	printf("%ld %ld\n",taka,aoki);
 }          

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
signed main(){
	int n,k,h,ans=0;
  	cin>>n>>k;
  	for(int i=0;i<n;i++){
      	cin>>h;
      	if(h>=k)
          ans++;
    }
  cout<<ans<<endl;
  return(0);
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
typedef long long ll;
struct pt
{
	ll val;
	int id;
	pt(ll val=0,int id=0):val(val),id(id){}
	bool operator<(const pt x) const
	{
		return val>x.val;
	}
}a[100005];
int n,e[100005][2],sz[100005];
ll f[100005];
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
		scanf("%lld",&a[i].val),a[i].id=i;
	for(int i=1;i<=n;i++)
		sz[i]=1;
	sort(a+1,a+n+1);
	for(int i=1;i<n;i++)
	{
		int u=a[i].id,v;
		int nw=lower_bound(a+1,a+n+1,pt(a[i].val-n+2*sz[u]))-a;
		if(a[nw].val!=a[i].val-n+2*sz[u])
		{
			printf("-1");
			return 0;
		}
		v=a[nw].id;
		e[i][0]=u,e[i][1]=v;
		sz[v]+=sz[u],f[v]+=f[u]+sz[u];
	}
	if(f[a[n].id]!=a[n].val)
	{
		printf("-1");
		return 0;
	}
	for(int i=1;i<n;i++)
		printf("%d %d\n",e[i][0],e[i][1]);
	return 0;
}

Measured memory_bytes: 4864
import collections
import itertools
#横にn個入力
n, c = map(int, input().split())
#行列
d = []
for i in range(c):#h:高さ
    d.append([int(m) for m in input().split()])
#行列
e = []
for i in range(n):#h:高さ
    e.append([int(m) for m in input().split()])

li0 = []
li1 = []
li2 = []
for i in range(n):
    for j in range(n):
        if (i + j + 2) % 3 == 0:
            li0.append(e[i][j])
        elif (i + j + 2) % 3 == 1:
            li1.append(e[i][j])
        elif (i + j + 2) % 3 == 2:
            li2.append(e[i][j])

c0 = collections.Counter(li0)
c1 = collections.Counter(li1)
c2 = collections.Counter(li2)

cost0 = {}
cost1 = {}
cost2 = {}
dost0 = []
dost1 = []
dost2 = []
k0 = 0
k1 = 0
k2 = 0
for i in range(c):
    for v0 in c0:
        k0 += d[v0 - 1][i] * c0[v0]
    cost0[i + 1] = k0
    dost0.append([k0, i + 1])
    k0 = 0
    for v1 in c1:
        k1 += d[v1 - 1][i] * c1[v1]
    cost1[i + 1] = k1
    dost1.append([k1, i + 1])
    k1 = 0
    for v2 in c2:
        k2 += d[v2 - 1][i] * c2[v2]
    cost2[i + 1] = k2
    dost2.append([k2, i + 1])
    k2 = 0

dost0.sort()
dost1.sort()
dost2.sort()
w0 = [dost0[0][1], dost0[1][1], dost0[2][1]]
w1 = [dost1[0][1], dost1[1][1], dost1[2][1]]
w2 = [dost2[0][1], dost2[1][1], dost2[2][1]]

ansli = []
for x0 in itertools.permutations(w0, 1):
    for x1 in itertools.permutations(w1, 1):
        for x2 in itertools.permutations(w2, 1):
            if x0[0] != x1[0] and x1[0] != x2[0] and x2[0] != x0[0]:
                ansli.append(cost0[x0[0]] + cost1[x1[0]] + cost2[x2[0]])

print(min(ansli))

Measured memory_bytes: 7924
import kotlin.math.max
import kotlin.math.min

fun main(args: Array<String>) = tokiomarine2020c()

fun tokiomarine2020c() {
    val (n, k) = readLine()!!.split(' ').map { it.toInt() }
    val aList = readLine()!!.split(' ').map { it.toLong() }

    var curr = aList.toLongArray()

    repeat(min(k, 100)) {
        val imos = LongArray(n)

        curr.withIndex().map { (index, value) ->
            val left = max(index - value, 0)
            imos[left.toInt()]++

            val right = index + value + 1
            if (right in imos.indices) imos[right.toInt()]--
        }

        for (i in 0 until n - 1) imos[i + 1] += imos[i]

        curr = imos.copyOf()
    }

    val answer = curr.joinToString(" ")

    println(answer)
}


Measured memory_bytes: 102764
#include <algorithm>
#include <cmath>
#include <cstring>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
using namespace std;
typedef long long int ll;
typedef vector<int> vi;
typedef pair<int, int> P;
struct pos {
  int row;
  int column;
};
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define Sort(a) sort(a.begin(), a.end())
const int INF = 1 << 30;
const ll MOD = 1000000007;
vector<P> dirs = {
    P(0, 1),
    P(1, 0),
    P(0, -1),
    P(-1, 0),
};

int main(void) {
  int d[1002][1002];
  int ROW, COLUMN;
  cin >> ROW >> COLUMN;
  string grid[1002];
  queue<P> keep;

  rep(i, ROW) { cin >> grid[i]; }
  rep(i, ROW) {
    rep(j, COLUMN) { d[i][j] = -1000; }
    rep(j, COLUMN) {
      if (grid[i][j] == '#') {
        d[i][j] = 0;
        keep.push(P(i, j));
      }
    }
  }

  while (keep.size() > 0) {
    P cur = keep.front();
    int row = cur.first;
    int column = cur.second;
    keep.pop();
    for (P dir : dirs) {
      int nR = row + dir.first;
      int nC = column + dir.second;
      if (nR < 0 || nR >= ROW || nC < 0 || nC >= COLUMN ||
          grid[nR][nC] == '#' || d[nR][nC] != -1000)
        continue;
      d[nR][nC] = d[row][column] + 1;
      keep.push(P(nR, nC));
    }
  }

  int maxVal = -1 * INF;
  rep(row, ROW) {
    rep(column, COLUMN) { maxVal = max(maxVal, d[row][column]); }
  }

  cout << maxVal << endl;

  return 0;
}

Measured memory_bytes: 13456
#include<bits/stdc++.h>
using namespace std;
int a[1005] = {0};
int ans = 0;
int main(){
	double n, m, sum;
	scanf("%lf %lf", &n, &m);
	for(int i = 0; i < n; i++){
		int t;
		scanf("%d", &t);
		a[t] = 1;
		sum += t;
	}
	sum /= 4 * m;
	for(int i = 1005; i >= sum; i--){
		if(a[i] == 1) ans++;
	}
	if(ans >= m) printf("Yes");
	else printf("No");
	
	return 0;
}

Measured memory_bytes: 256
#include <cstdlib>
#include <algorithm>
#include <iostream>
#include <limits>
#include <numeric>
#include <vector>


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

  int n;
  std::cin >> n;

  std::vector<int> as(n);
  for (auto&& e : as) {
    std::cin >> e;
  }

  auto amax = std::accumulate(std::cbegin(as), std::cend(as), decltype(as)::value_type{});
  std::cout << (amax - as.size()) << std::endl;

  return EXIT_SUCCESS;
}


Measured memory_bytes: 256
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp>
// using namespace __gnu_pbds;
// gp_hash_table<int, int> mapka;

using namespace std;
#define PB push_back
#define MP make_pair
#define LL long long
#define int LL
#define FOR(i,a,b) for(int i = (a); i <= (b); i++)
#define RE(i,n) FOR(i,1,n)
#define REP(i,n) FOR(i,0,(int)(n)-1)
#define R(i,n) REP(i,n)
#define VI vector<int>
#define PII pair<int,int>
#define LD long double
#define FI first
#define SE second
#define st FI
#define nd SE
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())

template<class C> void mini(C &a4, C b4) { a4 = min(a4, b4); }
template<class C> void maxi(C &a4, C b4) { a4 = max(a4, b4); }

template<class TH> void _dbg(const char *sdbg, TH h){ cerr<<sdbg<<'='<<h<<endl; }
template<class TH, class... TA> void _dbg(const char *sdbg, TH h, TA... a) {
  while(*sdbg!=',')cerr<<*sdbg++;
  cerr<<'='<<h<<','; _dbg(sdbg+1, a...);
}

template<class T> ostream &operator<<(ostream& os, vector<T> V) {
  os << "["; for (auto vv : V) os << vv << ","; return os << "]";
}
template<class L, class R> ostream &operator<<(ostream &os, pair<L,R> P) {
  return os << "(" << P.st << "," << P.nd << ")";
}

#ifdef LOCAL
#define debug(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
#else
#define debug(...) (__VA_ARGS__)
#define cerr if(0)cout
#endif

int32_t main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout << fixed << setprecision(11);
  cerr << fixed << setprecision(6);
  int n;
  cin >> n;
  multiset<int> secik;
  R(i,n){
    int pom;
    cin >> pom;
    secik.insert(pom);
  }
  int p2 = 1 << 30;
  int res = 0;
  while(!secik.empty()){
    int x = *secik.rbegin();
    while(p2 / 2 > x){
      p2 /= 2;
    }
    int y = p2 - x;
    secik.erase(secik.find(x));
    auto yy = secik.find(y);
    if(yy != secik.end()){
      secik.erase(yy);
      res++;
    }
  }
  cout << res << "\n";
}


Measured memory_bytes: 9728
#include "bits/stdc++.h"
using namespace std;
int main(){
    int n;
    string s;
    cin >> n;
    cin >> s;
    int x = 0;
    int memo = 0;
    for(int i = 0; i < n; i++){
        if(s.at(i) == 'I')
        x++;
        else 
        x--;
        memo = max(x, memo);
    }
    cout << memo << endl;
    return 0; 
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define all(x) (x).begin(),(x).end()
using namespace std;
using ll = long long;
using vint = vector<int>;

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

	int n, x;
	int t = 0;
	cin >> n >> x;
	int m[n];
	int d = n;
	REP(i, n){
		cin >> m[i];
		t += m[i];
	}
	int remain = x - t;
	sort(m, m+n);
	cout << n + remain / m[0] << "\n";
	return 0;
}

Measured memory_bytes: 256
#input of int(split by space)
def get_i()
  return gets.chomp.split(" ").map(&:to_i)
end
#input of float(split by space)
def get_f()
  return gets.chomp.split(" ").map(&:to_f)
end
#input of string(split by space)
def get()
  return gets.chomp.split(" ")
end
#input of string(split per one character)
def get_nsp()
  return gets.chomp.split("")
end
#yes or no decision
def yn_judge(bool,y="Yes",n="No")
  return bool ? y : n 
end
#create of array
def array(size1,init=nil,size2=-1)
  if size2==-1
      return Array.new(size1){init}
  else
      return Array.new(size2){Array.new(size1){init}}
  end
end

def max(a,b)
    return a>b ? a : b
end

def min(a,b)
    return a>b ? b : a
end

INF=Float::INFINITY

K=gets.to_i
if (K%5).zero? or K.even?
    puts "-1"
    exit
end
v=7%K
ans=1
until v.zero?
  v*=10
  v+=7
  v%=K
  ans+=1
end
puts ans

Measured memory_bytes: 14404
package main

import (
	"fmt"
)

func min(a, b int) (int) {
	if a < b {
		return a
	}
	return b
}

func main() {
	var n, k int
	fmt.Scanf("%d", &n)
	fmt.Scanf("%d", &k)

	sum := 0
	for i := 0; i < n; i++ {
		var x int
		fmt.Scanf("%d", &x)
		sum += min(x, k - x) * 2
	}

	fmt.Println(sum)
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vvvll = vector<vvll>;
using vs = vector<string>;
using pll = pair<ll, ll>;
using vp = vector<pll>;
#define rep(i, n) for(ll i = 0; i < (n); i++)
#define repr(i, a, b) for(ll i = (a); i < (b); i++)
#define ALL(a) (a).begin(), (a).end()
#define SZ(x) ((ll)(x).size())
const ll MOD = 1000000007;
const ll INF = 100000000000000000LL;
inline ll GCD(ll a, ll b){ return b?GCD(b, a % b):a; }
inline ll LCM(ll a, ll b){ return a/GCD(a, b)*b; }
inline ll powint(ll x, ll y){ ll r=1; while(y){ if(y&1) r*=x; x*=x; y>>=1; } return r; }
inline ll powmod(ll x, ll y, ll m = MOD){ ll r=1; while(y){ if(y&1) r*=x; x*=x; r%=m; x%=m; y>>=1; } return r; }
template<class T>bool chmax(T &a, const T &b){ if(a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b){ if(b<a) { a=b; return 1; } return 0; }
#ifdef OJ_LOCAL
#include "dump.hpp"
#else
#define dump(...) ((void)0)
#endif

int main(){
    cin.tie(0); ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    ll n;
    cin >> n;
    vs s(n);
    map<string, ll> mp;
    rep(i, n){
        cin >> s[i];
        sort(ALL(s[i]));
        mp[s[i]]++;
    }
    //sort(ALL(s));
    ll ans = 0;
    for(auto&& e: mp){
        ans += e.second*(e.second-1)/2;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 16640
#include <cstdio>
#include <cmath>
using namespace std;

int main() {
	while (1) {
		int n, s[1000];
		double ave = 0, pow = 0;
		(void)scanf("%d", &n);
		if (!n) break;
		for (int i = 0; i < n; i++) {
			(void)scanf("%d", &s[i]);
			ave += s[i];
		}
		ave /= n;
		for (int i = 0; i < n; i++) {
			pow += (s[i] - ave) * (s[i] - ave);
		}
		pow /= n;
		printf("%lf\n", sqrt(pow));
	}
}


Measured memory_bytes: 2732
{-# LANGUAGE BangPatterns #-}
{-# LANGUAGE BinaryLiterals #-}
{-# LANGUAGE MultiWayIf #-}
{-# LANGUAGE NumDecimals #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TupleSections #-}

import Control.Applicative
import Control.Arrow
import Control.Monad
import Control.Monad.ST

import Data.Char
import Data.List
import Data.Maybe

import qualified Data.ByteString.Char8 as B

import Data.Array.ST.Safe
import Data.STRef

import Debug.Trace
import Text.Printf

readInt = readLn :: IO Int
readInts = map ( fst . fromJust . B.readInt ) . B.words <$> B.getLine
readNInts = readInt >>= flip replicateM readInt

which a b f = if f then a else b
mp [ a, b ] = ( a, b )

main = do
	n <- readInt
	ws <- readInts
	let
		lefts = scanl1 (+) ws
		rights = tail $ scanr1 (+) ws
	print $ minimum $ map abs $ zipWith (-) lefts rights

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

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

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

    int m, index, t;
    cin >> m;
    for(int i = 0; i < m; i++){
        cin >> index >> t;
        cout << sum + (t-T[index-1]) << endl;
    }

    return 0;
}

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

using namespace std;
typedef long long ll;

int main(void) {
	int num, k, i, ans = 0, p = 0;
	string s;
	cin >> num >> k >> s;
	for (i = 1; i < num; i++) {
		if (s[i - 1] == s[i])
			ans++;
		else if (s[i] != s[0])
			p++;
	}
	ans += min(p, k) << 1;
	if (s[0] != s[num - 1] && p <= k)
		ans--;
	cout << ans << "\n";
	return 0;
}

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

int main()
{
  char a[10]={} ,s[101]={},c[10]={};
  
  scanf("%s",a);
  scanf("%s",s);
  scanf("%s",c);
  
  printf("%c%c%c",a[0],s[0],c[0]);
  
  return 0;
}

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

#define Gene template< class
#define Rics printer& operator,
Gene c> struct rge{c b, e;};
Gene c> rge<c> range(c i, c j){ return {i, j};}
struct printer{
    ~printer(){cerr<<endl;}
    Gene c >Rics(c x){ cerr<<boolalpha<<x; return *this;}
    Rics(string x){cerr<<x;return *this;}
    Gene c, class d >Rics(pair<c, d> x){ return *this,"(",x.first,", ",x.second,")";}
    Gene ... d, Gene ...> class c >Rics(c<d...> x){ return *this, range(begin(x), end(x));}
    Gene c >Rics(rge<c> x){
        *this,"["; for(auto it = x.b; it != x.e; ++it)
            *this,(it==x.b?"":", "),*it; return *this,"]";}
};
#define debug() cerr<<"LINE "<<__LINE__<<" >> ", printer()
#define dbg(x) "[",#x,": ",(x),"] "
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
int my_rand(int l, int r) {
    return uniform_int_distribution<int>(l, r) (rng);
}


int main() {
//    freopen("in.txt", "r", stdin);
    ios::sync_with_stdio(0);
    cin.tie(0);

    int n;
    cin >> n;
    int sum = 0;
    for(int i = 0; i < n; i++) {
        int x;
        cin >> x;
        sum += x;
        sum &= 1;
    }
    if(sum) cout << "NO" << endl;
    else cout << "YES" << endl;
}





Measured memory_bytes: 3668
#include<cstdio>
#define N 405
#define ll long long
int n;
int a[N];
ll dp[N][N];
int vis[N][N];
ll sum[N];
void chk(ll &x,ll y){if(y<x)x=y;}
ll DP(int l,int r){
	if(l>=r)return 0;
	if(vis[l][r])return dp[l][r];
	vis[l][r]=1;
	dp[l][r]=1e18;
	for(int i=l;i<r;++i){
		chk(dp[l][r],DP(l,i)+DP(i+1,r)+sum[r]-(l?sum[l-1]:0));
	}
	return dp[l][r];
}
int main(){
	scanf("%d",&n);
	for(int i=0;i<n;++i)scanf("%d",&a[i]);
	sum[0]=a[0];
	for(int i=1;i<n;++i)sum[i]=sum[i-1]+a[i];
	printf("%lld\n",DP(0,n-1));
	return 0;
}

Measured memory_bytes: 2048
n=int(input())
l=[[0 for i in range(3)]for j in range(n+1)]
for i in range(0,n):
    a,b,c=map(int,input().split())
    if i==0:
        l[i+1][0]=a
        l[i+1][1]=b
        l[i+1][2]=c
    else:
        l[i+1][0]=a+max(l[i][1],l[i][2])
        l[i+1][1]=b+max(l[i][0],l[i][2])
        l[i+1][2]=c+max(l[i][0],l[i][1])
print(max(l[n][0],l[n][1],l[n][2]))        

Measured memory_bytes: 63140
#include <stdio.h>

int rot[24][7]=
{
    { 0,1,2,3,4,5,6 },{ 0,1,3,5,2,4,6 },{ 0,1,4,2,5,3,6 },{ 0,1,5,4,3,2,6 },
    { 0,2,6,3,4,1,5 },{ 0,2,3,1,6,4,5 },{ 0,2,1,4,3,6,5 },{ 0,2,4,6,1,3,5 },
    { 0,3,1,2,5,6,4 },{ 0,3,2,6,1,5,4 },{ 0,3,5,1,6,2,4 },{ 0,3,6,5,2,1,4 },
    { 0,4,1,5,2,6,3 },{ 0,4,2,1,6,5,3 },{ 0,4,5,6,1,2,3 },{ 0,4,6,2,5,1,3 },
    { 0,5,1,3,4,6,2 },{ 0,5,3,6,1,4,2 },{ 0,5,4,1,6,3,2 },{ 0,5,6,4,3,1,2 },
    { 0,6,2,4,3,5,1 },{ 0,6,3,2,5,4,1 },{ 0,6,5,3,4,2,1 },{ 0,6,4,5,2,3,1 }
};
int i, j;
int assign[7];
int b[7],c[7],r,d;


int check_same(int assign[],int a[])
{
    for (j = 0; j < 24; j++)
    {
        for (i = 1; i <= 6; i++)
            b[i] = assign[rot[j][i]];
        for (i = 1; ; i++)
        {
            if (i > 6)
            {
                return 1;
            }
            if (a[i] != b[i])
                break;
        }
    }
    return 0;
}
int main()
{
    int n,k,r=0,a[7]= {0};
    scanf("%d",&n);
    for (i = 1; i < 7; i++)
        scanf("%d", assign+i);
            for(k=0; k<n-1; k++)
                {
                    for (i = 1; i < 7; i++)
                        scanf("%d", a+i);
                    r+=check_same(assign,a);
                }
    if(r)
        printf("No\n");
    if(!r)
        printf("Yes\n");
    //printf("%d\n",r);
    return 0;
}


Measured memory_bytes: 2100
main :: IO ()
main = do
    _  <- getLine
    xs <- fmap read . words <$> getLine
    answer $ solve xs

type Answer = Int
answer :: Answer -> IO ()
answer = print

solve :: [Int] -> Answer
solve = inner 0 0 . head <*> tail
  where
    inner n d p (x : xs)
      | x  <  p   = inner n  d  x xs
      | d' == d   = inner n' d  p xs
      | d' >  d   = inner 1  d' p xs
      | otherwise = inner n  d  p xs
      where
        d' = x - p
        n' = succ n
    inner n _ _ _ = n


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

int main() {
	int N;
	 cin >> N;
	 if (N == 1) {
	 	cout << "a" << endl;
	 	return 0;
	 }
	 queue<string> que;
	 que.push("a");
	 for (int i = 0; i < N - 1; i++) {
	 	int element = que.size();
	 	// cout << element << endl;
	 	for (int j = 0; j < element; j++) {
	 		string tmp = que.front();
	 		// cout << tmp << endl;
	 		map<char, int> ma;
	 		for (int k = 0; k < (int)tmp.size(); k++) {
	 			ma[tmp.at(k)]++;
	 		}
	 		char c;
	 		for (auto x : ma) {
	 			c = x.first;
	 			string s = tmp + c;
	 			que.push(s);
	 		}
	 		c++;
	 		que.push(tmp + c);
	 		que.pop();
	 	}
	 }

	 while (que.size() != 0) {
	 	cout << que.front() << endl;
	 	que.pop();
	 }
}

Measured memory_bytes: 9728
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vll>;
using vc = vector<char>;
using vvc = vector<vc>;
using pll = pair<ll, ll>;
using vpll = vector<pll>;
const ll INF = 1LL << 60;
const ll MOD = 1e9 + 7;
#define rep(i, n) for (ll i = 0; i < (n); i++)
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}
#ifndef ONLINE_JUDGE
    #define debug(x) cerr << #x << ": " << x << endl;
#else
    #define debug(x)
#endif

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

    ll N, M, V, P;
    cin >> N >> M >> V >> P;
    vll A(N);
    rep(i, N) cin >> A[i];
    sort(A.begin(), A.end(), greater<ll>());

    ll sum = A[P-1];
    vector<bool> ok(N, false);
    rep(i, P) ok[i] = true;
    for(ll i = P; i < N; i++) {
        if(A[i] == A[i-1]) {
            ok[i] = ok[i-1];
        }
        else if(A[i]+M >= A[P-1]) {
            ll res = V - (N-1-i+P);
            if((i-P+1)*(A[i]+M)-sum >= M*res) ok[i] = true;
        }
        sum += A[i];
    }
    ll ans = 0;
    rep(i, N) if(ok[i]) ans++;
    cout << ans << endl;
}


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

void solve(){
	string s;
	cin >> s;
	int sm = 0, cnt = 0;
	sm += (s[0] == 'R' ? 1:0);
	cnt = sm;
	for(int i = 1; i <= 2; i++){
		if(s[i] == 'R') cnt++;
		else cnt = 0;
		sm = max(cnt, sm);
	}
	cout << sm << '\n';
}

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

	int t = 1;
	while(t--) solve();
}

Measured memory_bytes: 3608
-- B
local N = io.read("n")
local H = {}
for i=1,N do H[i] = io.read("n") end
local ans = 1
local max = H[1]
for i=2,N do
    if H[i] >= max then
        ans = ans + 1
        max = H[i]
    end
end
print(ans)

Measured memory_bytes: 1132
#include <bits/stdc++.h>
#define ll long long int
#define F first
#define S second
const ll mod = 1e9 + 7;
const ll INF = 10000000000000;
#define pb push_back
#define deb(x) cout << '>' << #x << ':' << x << endl;
#define fastio ios_base::sync_with_stdio(0); cin.tie(0);
using namespace std;
int main()
{
    fastio;
    string s;
    cin>>s;
    bool f=false;
    for(ll i=0;i<2;++i){
        if(s[i]!=s[i+1]) f=true;
    }
    if(f) cout<<"Yes";
    else cout<<"No";
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long N = sc.nextInt();
        long M = sc.nextInt();
        char[] s = sc.next().toCharArray();
        char[] t = sc.next().toCharArray();
        sc.close();
        long lcm = lcm(N, M);
        long n = lcm / N;
        long m = lcm / M;
        boolean success = true;
        for(int i = 0; i < N; i++){
            if((n * i) % m == 0){
                if(s[(int) (i)] != t[(int) (n * i / m)]){
                    success = false;
                    break;
                }
            }
        }

        if(success){
            System.out.println(lcm);
        }else{
            System.out.println(-1);
        }
    }

    private static long gcd(long n, long m){
        if(n < m) return gcd(m, n);
        if(m == 0) return n;
        return gcd(m, n % m);
    }
    private static long lcm(long n, long m){
        return n * m / gcd(n, m);
    }
}


Measured memory_bytes: 26716
object Main extends App {
  val m = 1000000007;
  def pow(a: Long, b: Int): Long = {
    var x: Long = 1;
    var a2: Long = a;
    var b2: Int = b;
    while (b2 > 0) {
      if ((b2 & 1) != 0) {
        x = x * a2 % m;
      }
      a2 = a2 * a2 % m;
      b2 = b2 >> 1;
    }
    x;
  }
  val sc = new java.util.Scanner(System.in);
  val n = sc.nextInt();
  val a1 = pow(10, n); // all
  val a2 = pow(8, n);  // 0も9も存在しない
  val a3 = (pow(9, n) + m - a2) % m;  // 0は存在するけど9は存在しない
  val answer = (a1 + 3L * m - 2L * a3 - a2) % m;
  println(answer);
}

Measured memory_bytes: 55356
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		watch();

	}
	
	public static void watch() {
		
		Scanner sc = new Scanner(System.in);
		int S = sc.nextInt();
		int h, m, s;
		h = S / 3600;
		S = S % 3600;
		m = S / 60;
		s = S % 60;
		
		System.out.println(h + ":" + m + ":" + s);
	}
}


Measured memory_bytes: 26404
#include <bits/stdc++.h>
 
using namespace std;
#define repr(i,a,b) for (int i=a; i<b; i++)
#define rep(i,n) for (int i=0; i<  n; i++)
 
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; }
 
const long long INF = 1LL << 60;
#define PI 3.14159265359 
bool dp[100100];
 
 
int main () {
    int X;
    cin >> X;

    int ans =0;
    ans += 1000*(X/500);
    X %= 500;

    ans += 5*(X/5);

    cout << ans << endl;

}

Measured memory_bytes: 256
N = int(input())
A = list(map(int, input().split()))

ans = 1

if 0 in A:
    ans = 0

else:
    for i in range(len(A)):
        ans = ans * A[i]
        if ans > 10 ** 18:
            error = str(ans)
            ans = '-1'
            break
print(ans)


Measured memory_bytes: 21780
#include <bits/stdc++.h>
using namespace std;
int main(void)
{
	int n,i,j,s[1001],sum=0,p=0;
	cin >> n;
	for(i=0;i<n;i++)cin >> s[i];
	for(i=0;i<n+1;i++){
		sum+=s[i];
		if(s[i]%10==0)s[i]*=100;
	}
	for(i=0;i<n+1;i++){
		for(j=0;j<n+1;j++){
			if(s[i]<s[j]){
				p=s[i];
				s[i]=s[j];
				s[j]=p;
			}
		}
	}
	if(sum%10!=0)cout << sum << endl;
	else if(sum%10==0){
		if(s[1]<=100)cout << sum-s[1] << endl;
		else cout << "0" << endl;
	}
	return 0;
}
			

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


int main(){
  int n; cin>>n;
  vector<int> v(n);
  rep(i,n){cin>>v[i];}
  sort(v.begin(),v.end());
  int i=0;
  while(i<v.size()-1){
    if(v.size()==0){break;}
    if(v[i]==v[i+1]){
      v.erase(v.begin()+i);
      v.erase(v.begin()+i);
    }
    else{i++;}
  }
  cout<<v.size();

}





Measured memory_bytes: 640
#include <iostream>
#include <vector>
#include <algorithm>
#include <bitset>
#include <cmath>

using namespace std;

int main() {
    int D, G;
    cin >> D >> G;
    vector<int> p, c;
    for (size_t i = 0; i < D; i++) {
        int pp, cc;
        cin >> pp >> cc;
        p.push_back(pp);
        c.push_back(cc);
    }

    vector<int> result;

    unsigned get_bounus_flag = 0;

    while(true) {



        int point_sum = 0;
        int solve_num = 0;

        for (size_t i = 0; i < D; i++) {
            if((get_bounus_flag >> i) & 1) {
                point_sum += c.at(i) + p.at(i) * 100*(i+1);
                solve_num += p.at(i);
            }
        }

        if(point_sum < G) {
            for (int i = D-1; i >= 0; i--) {
                if((get_bounus_flag >> i) & 1) {
                    continue;
                }

                int all_point = (p.at(i)-1) * 100*(i+1);
                if( all_point + point_sum >= G ) {
                    int n = (G - point_sum) / (100*(i+1));
                    if( n * 100*(i+1) + point_sum < G) {
                        n += 1;
                    }
                    solve_num += n;
                    point_sum += n * 100*(i+1);
                    break;
                } else {
                    solve_num += p.at(i) - 1;
                    point_sum += all_point;
                }
            }
        }

        if(point_sum >= G) {
            result.push_back(solve_num);
        }


        get_bounus_flag++;
        if(get_bounus_flag / pow(2, D) == 1) {
            break;
        }
    }

    cout << *min_element(result.begin(), result.end()) << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
    int N;
    cin>>N;
    int A[N];
    for(int i=0;i<N;i++){
        cin>>A[i];
    }
    int ans = 0;
    for(int i=0;i<N;i++){
        for(int j=0;j<N;j++){
            ans = max(ans,abs(A[i]-A[j]));
        }
    }
    cout<<ans<<endl;
}

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

/*
2 進法展開や 10 進法展開なら ここ に書いた通りなん。-2 進法になってもそう大差ないん。

基本的には N を -2 で割って、割ったあまりを答えに追加していくような感じです。-2 で割るとはどういうことかもう少し掘り下げてみます:

N=(−2)q+r
としたときに、r が 0 か 1 になるように q を調節するということになります。これ実は、

N が偶数なら r=0
N が奇数なら r=1
とすればよいという感じなので、実は N を単に 2 で割るのと変わらないです。ただし、ここに書いた通り、N が負の数のとき

N % 2 の値は 0 か -1 になってしまうので、-1 になるならそれに 2 を足す
という風にする必要があります。

以上で、N を -2 で割っていくというのがどういうことなのかがわかったので、いつもの 10 進法展開と同じノリでコードにして行くと AC がもらえました。
*/


int main() {
  int N; cin >> N;
  string str = "";
  while (N != 0) {
    /* N を 2 で割ったあまりを求める */
    int r = N % 2;
    if (r < 0) r += 2; // N がマイナスだと r がマイナスになったりするので 2 を足す

    /* N から余りを取り除いて -2 で割る */
    N = (N - r) / (-2);

    /* 答えに追加 */
    str += (char)('0' + r);
  }
  /* 向きが逆なので反転 */
  reverse(str.begin(), str.end());
  if (str == "") str = "0"; // N = 0 のときは空文字列になってしまうので例外処理
  cout << str << endl;
}

//けんちょんさんのコードそのまま

Measured memory_bytes: 256
n = gets.to_i
s = gets.chomp

ans = 0
n.times do |i|
    u = s.chars.uniq
    f = s[0..i].chars.uniq
    l = s[i+1..-1].chars.uniq
    # p [f,l,u]
    t = f.size + l.size - u.size
    ans = t if ans < t
end

p ans

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

using u32 = uint32_t;
using u64 = uint64_t;
using i32 = int32_t;
using i64 = int64_t;

int main()
{
	std::ios_base::sync_with_stdio(0);
	
	long double a, b, x;

	std::cin >> a >> b >> x;

	long double area_water = x/a;
	long double area_bottle = a*b;

	std::clog << "area_water = x/a = " << area_water << "\n";
	std::clog << "area_bottle = a*b = " << area_bottle << "\n";

	long double ratio = area_water/area_bottle;

	std::clog << "ratio = area_water/area_bottle = " << ratio << "\n";

	std::cout << std::setprecision(10) << std::fixed;

	if (ratio <= 0.5f)
	{
		long double h = 2.f * (area_water ) / b;
		std::clog << "h = area_water = " << h << "\n";
		
		long double atan = std::atan2(b, h);
		std::clog << "atan(b/h) = "  << atan << "\n";
		std::clog << "in deg = " << (atan * 180.f / M_PI) << "\n";

		std::cout << (atan * 180.f / M_PI) << "\n";
	}
	else
	{
		long double h = (2 * area_water / a) - b;
		long double atan = std::atan2(b-h, a);
		std::clog << "atan(b/h) = " << atan << "\n";
		std::clog << "in deg = " << (atan * 180.f / M_PI) << "\n";

		std::cout << (atan * 180.f / M_PI) << "\n";
	}
	
	return 0;
}

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

int main(void){
  char c[2][3];
  cin >> c[0][0] >> c[0][1] >> c[0][2] >> c[1][0] >> c[1][1] >> c[1][2];
  if(c[0][0] == c[1][2] && c[0][1] == c[1][1] && c[0][2] == c[1][0]){
    cout << "YES" << '\n';
  }
  else{
    cout << "NO" << '\n';
  }
}


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

public static partial class Program
{
    public static void Main()
    {
        var queue = new List<Queue<char>>();
        for (int i = 0; i < 3; i++)
        {
            queue.Add(new Queue<char>());
        }

        for (int i = 0; i < 3; i++)
        {
            foreach (var s in CRL())
            {
                queue[i].Enqueue(s);
            }
        }

        var turn = 'a';
        while (true)
        {
            if (queue[turn - 'a'].Count == 0)
            {
                CWL(turn.ToString().ToUpper());
                return;
            }
            turn = queue[turn - 'a'].Dequeue();
        }
    }
}

public static partial class Program
{
    //テンプレここから
    public static int ToInt(this double d) => (int) d;
    public static int ToInt(this string str) => int.Parse(str);
    public static long ToLong(this string str) => long.Parse(str);
    public static long[] ToLong(this IEnumerable<string> strs) => strs.Select(x => x.ToLong()).ToArray();
    public static int[] ToInt(this IEnumerable<string> strs) => strs.Select(x => x.ToInt()).ToArray();
    public static long[] ArrayLongs(this string str, char opr = ' ') => str.Split(opr).ToLong();
    public static int[] ArrayInts(this string str, char opr = ' ') => str.Split(opr).ToInt();
    public static string CRL() => Console.ReadLine();
    public static void CWL(object obj) => Console.WriteLine(obj);
    public static long Diff(long a, long b) => Math.Abs(Math.Max(a, b) - Math.Min(a, b));
    public static int Diff(int a, int b) => Math.Abs(Math.Max(a, b) - Math.Min(a, b));
    public static long Sign(this long i) => Math.Sign(i);
    public static bool IsEven(this long i) => i % 2 == 0;
    public static bool IsEven(this int i) => i % 2 == 0;
    public static long[] dx = new long[] {0, -1, 0, 1};
    public static long[] dy = new long[] {-1, 0, 1, 0};
    public static long mod = 1000000007;
    public static string alphabet = "abcdefghijklmnopqrstuvwxyz";
    public static long ToLong(this char c) => c.ToString().ToInt();
    public static long[] Sort(this long[] array) => array.OrderBy(x => x).ToArray();
    public static int[] Sort(this int[] array) => array.OrderBy(x => x).ToArray();
    public static long[] DSort(this long[] array) => array.OrderByDescending(x => x).ToArray();
    public static int[] DSort(this int[] array) => array.OrderByDescending(x => x).ToArray();
    public static string Join(this IEnumerable<string> array, string sep = "") => string.Join(sep, array);
    public static string Join(this IEnumerable<char> array, string sep = "") => string.Join(sep, array);
    public static long GCD(long a, long b) => b == 0 ? a : GCD(b, a % b);

    public static long LCM(long a, long b) => a * b / GCD(a, b);

    //テンプレここまで
}

Measured memory_bytes: 11220
#include<bits/stdc++.h>
using namespace std;
int a;
int main()
{
 cin>>a;
 if(a%10==9)
 {
 	cout<<"Yes";
 	return 0;
 }
 if(a/10==9)
 {
 	cout<<"Yes";
 	return 0;
 }
 cout<<"No";
 
 return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include<algorithm>
#include<cstring>
#include<cmath>
#include<cstdlib>
#include<string.h>
using namespace std;
#define pb push_back
#define all(v) v. begin(),v. end()
#define  rep(i,n,v) for(i=n;i<v;i++)
#define per(i,n,v) for(i=n;i>v;i--)
#define ff first 
#define ss second 
#define pp pair<ll,ll>
#define ll  long long
#define endl '\n'
void solve()
{
  ll n, a,m=0,b=1, c,k=0, i, j,l=1e9+7;
  string s, r, y;
  cin>>s>>r;
  rep(i,0,s.length())
  {
    if(s[i]!=r[i]) k++;
  }
  cout<<k<<endl;
}
int main()
{
 ios_base::sync_with_stdio(false);
  cin. tie(0);cout. tie(0);
    ll t=1;
   //cin>>t;
    while(t--)
    {
      solve();
    }
    return 0;
}

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

int main(){
    int a;
    cin >> a;
    int x = a;
    int cnt = 0;
    while(x >= 100){
        x -= 100;
        cnt++;
    }
    if(cnt*5 >= x)cout << "1" << endl;
    else cout << "0" << endl;
    return 0;
}

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

using namespace std;

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

	int *v;
	v = new int[n];

	for(int i = 0; i < n; i++) cin >> v[i];

	sort(v, v + n);

	double ans = (double)(v[0] + v[1]) / 2.0;

	for(int i = 2; i < n; i++) ans = (ans + (double)v[i]) / 2.0;

	cout << ans;
	
	delete[] v;
	return 0;
}

Measured memory_bytes: 256
n = int(input())
s = list(input())
    
t1 = s[:n//2]
t2 = s[n//2:]

count = 0
for  i in range(n//2):
    if t1[i] == t2[i]:
        count += 1
if count == n//2 and  n%2==0:
    print("Yes")
else:
    print("No")



Measured memory_bytes: 3060
#include <stdio.h>

int main(){
  int n,i,a[100001],odd=0,four=0;
  scanf("%d",&n);
  for(i=0;i<n;i++){
      scanf("%d",&a[i]);
  }
  for(i=0;i<n;i++){
      if(a[i]%2==1){
          odd++;
      }else
          if(a[i]%4==0){
              four++;
          }
  }
  if(odd==0||(odd-1<=four&&n%2==1)||(odd<=four&&n%2==0))
  printf("Yes");
  else printf("No");
  return 0;
}

Measured memory_bytes: 512
import math
from collections import Counter

MAX = 10**6

N = int(input())
A = [int(a) for a in input().split()]

table = [0] * (MAX + 1)
# Aの各要素の倍数を記録する（+1していく）
for a in A:
    # aがまだ記録されてない(table[a]==0)場合に、その倍数をtableに記録すればよい
    # 記録されている場合は、その倍数も既に記録されているので、
    # aが問題の条件を満たさないことを表す「2」以上の数字を記録して次のAの要素に移ればよい

    if table[a] != 0:
        table[a] = 2
        continue
    tmp = a
    while tmp <= MAX:
        table[tmp] += 1
        tmp += a
ans = 0
for a in A:
    if table[a] == 1:
        ans += 1
print(ans)


Measured memory_bytes: 33964
#include <bits/stdc++.h>
using namespace std;
//make_tuple emplace_back next_permutation push_back make_pair second first setprecision

#if MYDEBUG
#include "lib/cp_debug.h"
#else
#define DBG(...) ;
#endif

using LL = long long;
constexpr LL LINF=334ll<<53;
constexpr int INF=15<<26;
constexpr LL  MOD=1E9+7;

struct Problem{
    LL n;
    vector<LL> a,sub,m;
    Problem(LL n):n(n),a(n),sub(n),m(n){};

    void solve(){
        for(int i=0; i<n; ++i){
            cin >> a[i];
        }
        sort(a.begin(),a.end());
        LL sum=0;
        for(int i=1; i<n; ++i){
            sub[i]=(a[i]-a[0])/(n+1);
            sum+=sub[i];
        }
        DBG(sum)
        for(int i=0; i<n; ++i){
            a[i]=a[i]+sum-sub[i]*(n+1);
        }
        DBG(a)
        if(*max_element(a.begin(),a.end())<n){
            cout << sum<<"\n";
            return;
        }
        sort(a.begin(),a.end());
        for(int i=0; i<n; ++i){
            for(int j=0; j<n-1; ++j){
                a[j]++;
            }
            a[n-1]-=n;
            sort(a.begin(),a.end());
            m[(i+1)%n]=a[n-1];
        }
        DBG(m)
        for(int i=0; i<n; ++i){
            m[i]=max(0ll,(m[i]-n+1))*n+(LL)i;
        }
        m[0]+=n;
        DBG(m)
        cout << sum+*min_element(m.begin(),m.end()) <<"\n";
    }
};

int main(){
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    long long n=0;
    cin >> n;
    Problem p(n);
    p.solve();
    return 0;
}



Measured memory_bytes: 256
def lcs(x, y):
    L = []
    for y_k in y:
        si = 0
        for i, cri in enumerate(L):
            chi = x.find(y_k, si) + 1
            if not chi:
                break
            L[i] = min(cri, chi)
            si = cri
        else:
            chi = x.find(y_k, si) + 1
            if chi:
                L.append(chi)
    return len(L)


if __name__ == "__main__":
    N = int(input())
    ans = []
    for _ in range(N):
        X = input()
        Y = input()
        print(lcs(X, Y))


Measured memory_bytes: 5612
n = int(input()) - 1

num = 1
while 26**num <= n:
    n -= 26**num
    num += 1

r = []
while 25 < n:
    r.append(n % 26)
    n //= 26

r.append(n)

if len(r) < num:
    for i in range(num - len(r)):
        r.append(0)

for i in r[::-1]:
    print(chr(97+i), end='')

Measured memory_bytes: 9120
import numpy as np
n=int(input())
ppp=list(map(float,input().split()))
dp=np.array([0.0]*(n+1),dtype=np.float64)
dp[0]=1
for p in ppp:
    ndp=dp*(1-p)
    ndp[1:]+=dp[:-1]*p
    dp=ndp
print(sum(dp[n//2+1:]))

Measured memory_bytes: 12520
#include <algorithm>
#include <iostream>
#include <vector>
#include <cmath>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<string> vs;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<P,int> pip;
typedef vector<pip> vip;
const int inf=1<<30;
const ll INF=1ll<<60;
const double pi=acos(-1);
const double eps=1e-8;
const ll mod=1e9+7;
const int dx[4]={-1,0,1,0},dy[4]={0,-1,0,1};

ll f(ll x){
	return x*(x+1)/2;
}

const int m=26;
int n,q;
vl a;
vvl b;

int main(){
	cin>>n;
	a=vl(m);
	b=vvl(n,vl(m));
	for(int i=0;i<m;i++) cin>>a[i];
	for(int i=0;i<n;i++) for(int j=0;j<m;j++) cin>>b[i][j];
	vvi d(m,vi(n+2));
	vl c(m);
	ll sum=0;
	for(int i=0;i<m;i++) d[i][0]=d[i][n+1]=1;
	for(int i=0;i<n;i++){
		int x;
		cin>>x;
		x--;
		d[x][i+1]++;
		sum+=b[i][x];
	}
	for(int i=0;i<m;i++){
		int t=0;
		for(int j=1;j<n+2;j++){
			if(d[i][j]){
				c[i]+=f(t);
				t=0;
			}
			else t++;
		}
	}
	cin>>q;
	for(int i=0;i<q;i++){
		int x,y;
		cin>>x>>y;
		y--;
		for(int j=0;j<m;j++) if(d[j][x]){
			int l=x-1,r=x+1;
			while(!d[j][l]) l--;
			while(!d[j][r]) r++;
			c[j]-=f(x-l-1)+f(r-x-1);
			c[j]+=f(r-l-1);
			l=x-1,r=x+1;
			while(!d[y][l]) l--;
			while(!d[y][r]) r++;
			c[y]+=f(x-l-1)+f(r-x-1);
			c[y]-=f(r-l-1);
			d[j][x]--;
			d[y][x]++;
			sum-=b[x-1][j];
			sum+=b[x-1][y];
			break;
		}
		ll res=sum;
		for(int j=0;j<m;j++) res-=a[j]*c[j];
		cout<<res<<endl;
	}
}

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

using namespace std;

int main()
{
    int n,l=0,x,lmax=0,c;
    cin>>n;
    cin>>x;
    c=x;
    for(int i=2; i<=n; i++)
    {
        cin>>x;
        if(x>c)
        {
            if(l>lmax)
                lmax=l;
            l=0;

        }
        else
        {
            l++;

        }
        c=x;
    }
    if(l>lmax)
        lmax=l;
    cout<<lmax;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
#define lli long long int
#define ulli unsigned long long int
#define ff first
#define ss second
#define mp make_pair
#define pb push_back
#define pf push_front
#define lb lower_bound
#define ub upper_bound
#define bs binary_search
#define loopl(i,a,b) for(lli i=a;i<b;i++) 
#define loop(i,a,b) for(int i=a;i<b;i++)
#define all(v) v.begin(), v.end()
#define mod 1000000007
#define mod2 1000000006
#define inf 1000000000000000000
#define lld long double
#define pll pair<long long int,long long int>
#define pii pair<int,int>
#define vll vector<lli>
#define vii vector<int>
#define is indexed_set
#define eps 0.000001
#define endl '\n'
#define mo 998244353
#define pi 3.141592653589793
#define FF first
#define SS second
using namespace std ;
 
const lli dx4[] = {-1, 0, 1, 0};
const lli dy4[] = {0, 1, 0, -1};
const lli dx8[] = {-1, 0, 1, 0, -1, -1, 1, 1};
const lli dy8[] = {0, 1, 0, -1, -1, 1, -1, 1};
 
typedef tree<pll,null_type,less<pll>,rb_tree_tag,
tree_order_statistics_node_update> indexed_set;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
mt19937_64 mt(chrono::steady_clock::now().time_since_epoch().count()); // can give negative values too

#define N 1000001

void solve()
{
	lli x,n;
	cin>>x>>n;

	lli ans = inf;

	lli a[102] = {0};
	loopl(i,0,n)
	{
		lli y;
		cin>>y;
		a[y]=1;
	}

	lli id;
	loopl(i,0,102)
	{
		if(a[i] == 0)
		{
			if(abs(x-i) < ans)
			{
				ans = abs(x-i);
				id = i;
			}
		}
	}

	cout<<id;

}

int main()
{
/////////////////////////////////////
    fastio;
/////////////////////////////////////  

    lli t;
    t=1;
    while(t--)
    	solve();
}

Measured memory_bytes: 3644
x,y,u;
p(a,b){for(;b--;)putchar(a+68);}
main(v){
    scanf("%d%d%d%d",&u,&v,&x,&y);
    x-=u;
    y-=v;
    p(17,y++);
    p(14,++x);
    p(0,y);
    p(8,x);
    p(17,1);
    p(8,1);
    p(17,y);
    p(14,x);
    p(0,y);
    p(8,--x);
}

Measured memory_bytes: 1620
import java.util.Scanner;
class Main{
    public static void main(String[] args){
        Scanner scanner = new Scanner(System.in);
        int temp;
        int[] array = new int[3];
        array[0] = scanner.nextInt();
        array[1] = scanner.nextInt();
        array[2] = scanner.nextInt();

        for(int i = 0; i < array.length - 1; i++){
            for(int j = i; j < array.length; j++){
                if(array[i] > array[j]){
                    temp = array[i];
                    array[i] = array[j];
                    array[j] = temp;
                }
            }
        }
        for(int i = 0; i < array.length ; i++){
            if(i != array.length-1)System.out.print(array[i] + " ");
            else System.out.println(array[i]);
        }
    }
}



Measured memory_bytes: 26164
// This amazing code is by Eric Sunli Chen.
#include<bits/stdc++.h>
using namespace std;
template<typename T> bool get_int(T &x)
{
	char t=getchar();
	bool neg=false;
	x=0;
	for(; (t>'9'||t<'0')&&t!='-'&&t!=EOF; t=getchar());
	if(t=='-')neg=true,t=getchar();if(t==EOF)return false;
	for(; t<='9'&&t>='0'; t=getchar())x=x*10+t-'0';
	if(neg)x=-x;return true;
}
template<typename T> void print_int(T x)
{
	if(x<0)putchar('-'),x=-x;
	short a[20]= {},sz=0;
	while(x>0)a[sz++]=x%10,x/=10;
	if(sz==0)putchar('0');
	for(int i=sz-1; i>=0; i--)putchar('0'+a[i]);
}
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define get1(a) get_int(a)
#define get2(a,b) (get1(a)&&get1(b))
#define get3(a,b,c) (get1(a)&&get2(b,c))
#define printendl(a) print_int(a),puts("")
typedef long long LL;
typedef unsigned long long uLL;
typedef pair<int,int> pii;
const int inf=0x3f3f3f3f;
const LL Linf=1ll<<61;
const double pi=acos(-1.0);

int qpow(int x,int y,int mod)
{
	int ret=1;
	while(y)
	{
		if(y&1)ret=(LL)ret*x%mod;
		x=(LL)x*x%mod;
		y>>=1;
	}
	return ret;
}

const int maxn=250111;
const int mod1=998244353;
const int mod2=1e9+7;
const int base=443;
const int inv1=qpow(base,mod1-2,mod1);
const int inv2=qpow(base,mod2-2,mod2);

pii merge1(const pii&a,const pii&b){return mp(1ll*a.ff*b.ff%mod1,(1ll*a.ff*b.ss+a.ss)%mod1);}
pii merge2(const pii&a,const pii&b){return mp(1ll*a.ff*b.ff%mod2,(1ll*a.ff*b.ss+a.ss)%mod2);}
pair<pii,pii> merge(const pair<pii,pii>&a,const pair<pii,pii>&b){return mp(merge1(a.ff,b.ff),merge2(a.ss,b.ss));}
int eval1(const int&a,const pii&b){return ((LL)a*b.ff+b.ss)%mod1;}
int eval2(const int&a,const pii&b){return ((LL)a*b.ff+b.ss)%mod2;}
pii eval(const pii&a,const pair<pii,pii>&b){return mp(eval1(a.ff,b.ff),eval2(a.ss,b.ss));}

int n;
pair<pii,pii> tran[maxn];
char s[maxn];

int main()
{
	scanf("%d%s",&n,s+1);
	
	pii cur=mp(0,0);
	tran[n+1]=mp(mp(1,0),mp(1,0));
	for(int i=n;i>=1;i--)
	{
		if(s[i]=='+')
		{
			tran[i]=merge(tran[i+1],mp(mp(1,1),mp(1,1)));
			cur=eval(cur,mp(mp(1,mod1-1),mp(1,mod2-1)));
		}
		else if(s[i]=='-')
		{
			tran[i]=merge(tran[i+1],mp(mp(1,mod1-1),mp(1,mod2-1)));
			cur=eval(cur,mp(mp(1,1),mp(1,1)));
		}
		else if(s[i]=='<')
		{
			tran[i]=merge(tran[i+1],mp(mp(base,0),mp(base,0)));
			cur=eval(cur,mp(mp(inv1,0),mp(inv2,0)));
		}
		else
		{
			tran[i]=merge(tran[i+1],mp(mp(inv1,0),mp(inv2,0)));
			cur=eval(cur,mp(mp(base,0),mp(base,0)));
		}
	}
	
	LL ans=0;
	map<pii,int> cnt;
	cnt[mp(0,0)]++;
	for(int i=n;i>=1;i--)
	{
		ans+=cnt[eval(cur,tran[i])];
		cnt[mp(tran[i].ff.ss,tran[i].ss.ss)]++;
	}
	printendl(ans);
	return 0;
}

Measured memory_bytes: 35584