akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define ll long long
using namespace std;
const int mod=1e9+7;
ll m,n,vis[2005],yy[2005],hh[2005]; 

int main()
{
    std::ios::sync_with_stdio(0); std::cin.tie(0);
    cin>>m;
    for(int i=0;i<m;++i)
    {
    	cin>>n;
    	vis[n]++;
	}
	for(int i=1;i<=2000;++i)
	{
		yy[i]=yy[i-1]+min(vis[i],(ll)1);
		hh[i]=hh[i-1]+vis[i];
	}
	ll sum=0;
	for(int i=1;i<=998;++i)
	 {if(!vis[i]) continue;
	 for(int j=i+1;j<=999;++j)
	 {
	 	if(!vis[j]) continue; 
		for(int k=j+1;k<=j+i-1;++k)
		if(vis[k]) sum+=vis[i]*vis[j]*vis[k]; 
	 }} 
	 for(int i=1;i<=1000;++i)
	 {
	 	if(vis[i]==2) sum+=hh[2*i-1]-2;
	 	if(vis[i]>=3) sum+=vis[i]*(vis[i]-1)*(vis[i]-2)/6+(vis[i]*(vis[i]-1)/2)*(hh[2*i-1]-vis[i]);
	 }
	 cout<<sum;
	return 0;
}

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

#define ll long long int
#define ull unsigned long long int
#define forr(i,n) for(int i=0;i<n;i++)
#define f(i,a,b) for(ll i=a;i<b;i++)
#define F first
#define S second
#define pb push_back
#define mp make_pair
#define endl '\n'
#define ce(ele) cout<<ele<<' '
#define cs(ele) cout<<ele<<'\n'
#define CASE(t) int t; cin>>t; while(t--)
#define sor(v) sort(v.begin(),v.end())
#define rev(v) reverse(v.begin(),v.end())
#define vi vector<ll>
const ll md=1e9 +7;const ll M1=998244353;
ll mod(ll n){return ((n%md)+md)%md;}
ll power(ll x,ll y){ll res=1;x=x;while(y>0){if(y&1)res=res*x;x=x*x;y=y>>1;}return res;}

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

    string s;cin>>s;
    if(s.back()=='s')s+="es";
    else s+="s";
    cs(s);
}

Measured memory_bytes: 3652
import java.util.*;

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        
        int n = sc.nextInt();
        
        double res = 0;
        
        for(int i = 1; i <= n; i++){
            if(i % 2 != 0) res++;
        }

        System.out.println(res / ((double)n));
    }
}


class Pair<K, V> extends AbstractMap.SimpleEntry<K, V> {
 
    public Pair(K key, V value) {
        super(key, value);
    }
 
    public Pair<V, K> swap() {
    	return new Pair<V, K>(getValue(), getKey());
    }
}


Measured memory_bytes: 25428
#include <stdio.h>
int main(void){
    int N;
    char s[N];
    scanf("%d", &N);
    for (int i = 0; i < N; i++){
        scanf("%c", &s[i]);
    }

    int tmp = 0;
    for (int i = 0; i < N; i++){
        if (s[i] == 'Y'){
            tmp += 1;
        }
    }
    if (tmp == 0){
        printf("%s\n", "Three");
    }
    else {
        printf("%s\n", "Four");
    }

    return 0;
}


Measured memory_bytes: 128
#include<iostream>
#include<vector>
#include<algorithm>
#include<stdlib.h>
#include<utility>
#include<functional>
#include<cfenv>
#include<cmath>
#include<string>
#include<queue>
#include<stack>
#include<map>
#include<set>

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define vint vector<int>
#define vvint vector<vint>
#define P pair<ll,ll>
#define INT_MAX 2147483647
#define MOD 998244353
#define PI 3.14159265358979323846
#define all(a) (a).begin(),(a).end()
using namespace std;
typedef long long ll;

#define MAX 1000000000000


int main(void) {
	string s, t; cin >> s >> t;
	int cnt = 0;
	rep(i, s.size()) {
		if (s[i] != t[i]) {
			cnt++;
		}
	}
	cout << cnt << endl;
	return 0;
}

Measured memory_bytes: 3916
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, N) for (int i = 0; i < (int)N; i++)
#define all(a) (a).begin(), (a).end()

int K, X;

int main () {
  cin >> K >> X;

  for(int i =  X - K + 1; i < X+K; i++) {
    if(i != X - K + 1) cout << " ";
    cout << i;
  }
  cout << endl;

  return 0;
}


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

// Debug
#define dump(x) cerr<<#x<<" = "<<(x)<<endl
#define debug(x) cerr<<#x<<" = "<<(x)<<" (L"<<__LINE__<<")"<< endl;

#define rep(i,n) for (int i=0, i##_len=(n); i<i##_len; ++i)

#define SZ(x) ((int)(x).size())

#define all(x) begin(x),end(x)


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

// std::vector debug
template<typename T>
ostream& operator<<(ostream& os, const vector<T>& v) {
    os << "[";
    for (auto& e : v) os << e << ", ";
    return os << "]";
}

// std::pair debug
template<typename T, typename U>
ostream& operator<<(ostream& os, const pair<T, U>& p) {
    return os << "(" << p.first << " " << p.second << ")";
}

// infty
template<typename T>
T inf() { return numeric_limits<T>::max(); }

using ll = long long;
using ull = unsigned long long;
using ld = long double;
using P = pair<int,int>;
using vi = vector<int>;
using vll = vector<ll>;
using vvi = vector<vector<int>>;
using vvll = vector<vector<ll>>;

const ll MOD = 1e9+7;
const ld EPS = 1e-9;


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

    for (;;) {
        int n, m, p;
        cin >> n >> m >> p;
        if (n == 0) break;
        --m;
        vi x(n);
        rep (i, n) cin >> x[i];
        if (x[m] == 0) {
            cout << 0 << endl;
            continue;
        }
        double sum = accumulate(all(x), 0);
        int ans = (sum / x[m]) * (100 - p);
        cout << ans << endl;
    }

    return 0;
}



Measured memory_bytes: 3124
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;

namespace AtCoder
{
    class Program
    {
        static void Main()
        {
            //ここから
            var N = IO.ReadLineToInt();
            var A = IO.ReadLineToIntList();
            var list = new List<int[]>();

            for(int i = 0; i < N; i++)
            {
                int[] temp = { i+1, A[i] };
                list.Add(temp);
            }

            string[] ans = list.OrderBy(l => l[1]).Select(a => a[0].ToString()).ToArray();

            IO.WriteCollection(ans);

            //ここまで
            //Console.WriteLine();
            Console.ReadKey();
        }
    }

    static class Func
    {
        static long mod = 1000000007;
        static public void Swap<T>(ref T a, ref T b) { T temp = a; a = b; b = temp; }
        static public long GCD(long a, long b) { return b != 0 ? GCD(b, a % b) : a; }
        static public long LCM(long a, long b) { return (long)a * b / GCD(a, b); }
        static public int Factorial(int a) { return a == 1 ? a : a * Factorial(a - 1); }
        static public int Conbin(int n, int m) { return Factorial(n) / (Factorial(n - m) * Factorial(m)); }

        static public void Factoring(long num, ref long[] vs)
        {
            if (num == 1)
            {
                vs[1]++;
            }
            for (long i = 2; i < (long)Math.Sqrt(num); i++)
            {
                if (num % i == 0)
                {
                    vs[i]++;
                    Factoring(num / i, ref vs);
                }
            }
            vs[1]++;
        }
    }

    static class IO
    {
        static public string ReadLineToString() { return Console.ReadLine(); }
        static public int ReadLineToInt() { return int.Parse(Console.ReadLine()); }
        static public long ReadLineToLong() { return long.Parse(Console.ReadLine()); }
        static public List<string> ReadLineToStringList() { return Console.ReadLine().Split(' ').ToList(); }
        static public List<int> ReadLineToIntList() { return Console.ReadLine().Split(' ').Select(int.Parse).ToList(); }
        static public List<long> ReadLineToLongList() { return Console.ReadLine().Split(' ').Select(long.Parse).ToList(); }

        static public void WriteCollection(object[] strings) { foreach (var o in strings) { Console.Write(o + " "); } }
    }
}

Measured memory_bytes: 37848
k = gets.to_i
ar = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
puts ar[k-1]

Measured memory_bytes: 1788
def c_train_ticket(N):
    A, B, C, D = map(int, N)
    # 各演算子の決定。本問では高々8通りなので愚直にやる
    # オペランド数が増えた場合は、バイナリを演算子の並びとみなせばよい
    operator = ['---', '--+', '-+-', '-++', '+--', '+-+', '++-', '+++']

    ans = ''
    for i, op in enumerate(operator):
        code = 'A {0} B {1} C {2} D'.format(op[0], op[1], op[2])
        if eval(code) == 7:
            ans = '{0}{1}{2}{3}{4}{5}{6}=7'.format(
                A, op[0], B, op[1], C, op[2], D)
            break  # 1つ見つければいい
    return ans

N = input()
print(c_train_ticket(N))

Measured memory_bytes: 38384
Imports System.Collections.Generic
Imports System.Console

Module Program
    Sub Main()
        Dim X As String = ReadLine()
        Dim s_cnt, ans As Integer

        For Each v As Char In X
            Select Case v
                Case "S"c
                    s_cnt += 1
                Case "T"c
                    If s_cnt = 0 Then
                        ans += 1
                    Else
                        s_cnt -= 1
                    End If
            End Select
        Next

        ans += s_cnt
        WriteLine(ans)
    End Sub

    Function NextString() As String
        Dim result As New List(Of Char)
        Do
            Dim tmp As Integer = Read()
            If tmp < 0 Then Exit Do
            Dim nextChar As Char = Chr(tmp)

            If Not Char.IsWhiteSpace(nextChar) Then
                result.Add(nextChar)
            ElseIf nextChar <> vbCr Then
                Exit Do
            End If
        Loop
        Return New String(result.ToArray())
    End Function

End Module


Measured memory_bytes: 15712
import heapq
n=int(input())
a=[int(i) for i in input().split()]
f=a[:n]
l=[-i for i in a[2*n:]]
heapq.heapify(f)
heapq.heapify(l)
fs=[0]*(n+1)
ls=[0]*(n+1)
fs[0]=sum(f)
ls[n]=-sum(l)

for i in range(n):
    c=a[n+i]
    m=heapq.heappushpop(f,c)
    fs[i+1]=fs[i]+c-m

for i in range(n):
    c=a[2*n-1-i]
    m=heapq.heappushpop(l,-c)
    ls[n-i-1]=ls[n-i]+c+m

ans=fs[0]-ls[0]
for k in range(n+1):
    ans=max(ans,fs[k]-ls[k])
print(ans)


Measured memory_bytes: 109888
#include <bits/stdc++.h>
#include <math.h>
#include <cstdlib> //絶対値 abs()
using namespace std;

int main(){
	int n;cin>>n;
	vector<int> a(n);

	int ans = 0;
	int pt = 1;
	for(int i=0; i<n; i++){
		cin >> a[i];
		if(a[i]==pt){
			pt++;
		}
		else{
			ans++;
		}
	}

	if(ans == n){
		ans = -1;
	}

	cout << ans << endl;

}

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

using namespace std;

int in(){ int a; cin >> a; return a; }
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

int main(){
  ios_base::sync_with_stdio(0); cin.tie(nullptr); cout.tie(0); cerr.tie(0);
  int n = in();
  int ans = 0;
  for(int i = 1; i <= n; i++){
    if(i & 1) ans++;
  }
  cout << setprecision(10) << ans / (double)n << endl;
  return 0;
}

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

//const long long INF = 1000000001;
const int INF = 2147483647;

const long long MOD = 1000000009;

typedef long long ll;

const int max = 100000; //配列の最大長

int main(void){
  int N;
  std::cin >> N;

  std::set<int> st;
  for(int i=0; i<N; i++){
    int k;
    std::cin >> k;
    st.insert(k);
  }

  std::cout << st.size() << std::endl;
  return 0;
}


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

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

Measured memory_bytes: 256
import java.io.*;
public class Main {
    public static void main(String[] args) {
        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
        while (true) {
            int i,sum=0;
            try {
                String line = reader.readLine();
                if(line.equals("0")) break;
                for(i=0;i<line.length();i++) {
                    char c = line.charAt(i);
                    sum += Character.getNumericValue(c);
                }
            } catch (IOException e) {
                System.out.println(e);
            }
            System.out.println(sum);
        }


    }
}



Measured memory_bytes: 24424
#include <iostream>
#include <cstdio>
#include <string>
#include <sstream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <queue>
using namespace std;

// 各ノードの座標と深さを保持するための構造体
//struct Node{
//    int y;
//    int x;
//    int depth;
//};

int main() {
    long long X,Y;
    cin >> X >> Y;
    
    long long ans=0;
    while (X<=Y) {
        X=X*2;
        ans++;
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10**7)
INF = 10 ** 18
MOD = 10 ** 6 + 3
def POW(x, y): return pow(x, y, MOD)
def INV(x, m=MOD): return pow(x, m - 2, m)
def DIV(x, y, m=MOD): return (x * INV(y, m)) % m
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x) - 1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def II(): return int(sys.stdin.readline())
def SI(): return input()

def main():
    Q = II()
    query = []
    for _ in range(Q):
        query.append(LI())
    fact = [1] * MOD
    for i in range(1, MOD):
        fact[i] = fact[i - 1] * i % MOD
    ifact = [1] * MOD
    ifact[MOD - 1] = pow(fact[MOD - 1], MOD - 2, MOD)
    for i in range(MOD - 1, 0, -1):
        ifact[i - 1] = ifact[i] * i % MOD
    for x, d, n in query:
        if d == 0:
            ans = pow(x, n, MOD)
        else:
            x = x * pow(d, MOD - 2, MOD) % MOD
            if x + n > MOD or x == 0:
                ans = 0
            else:
                factor = pow(d, n, MOD)
                perm = fact[x + n - 1] * ifact[x - 1] % MOD
                ans = perm * factor % MOD
        print(ans)
    return

main()

Measured memory_bytes: 104272
# A
N = int(input())
a_list = list(map(int, input().split()))

m = sum(a_list) / N
res = 0
d = 2000
for i in range(N):
    if abs(a_list[i] - m) < d:
        res = i
        d = abs(a_list[i] - m)
print(res)

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

ll dp[100010];

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

    int n;
    cin >> n;

    vector<int> a(n);
    rep(i,n) cin >> a[i];

    memset(dp,0,sizeof(dp));
    dp[0] = 0;
    for(int i = 1; i < n; i++){
        if(i == 1) dp[i] = dp[i-1] + abs(a[i] - a[i-1]);
        else {
            dp[i] = min(dp[i-1] + abs(a[i] - a[i-1]), dp[i-2] + abs(a[i] - a[i-2]));
        }
    }
    cout << dp[n-1] << endl;
}



Measured memory_bytes: 1408
using System;
using System.Text;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using static System.Console;
using static System.Math;

namespace NotFounds
{
    public class Program
    {
        public static void Main(string[] args)
        {
            var sw = new System.IO.StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);
            new Program().Solve(new ConsoleInput(Console.In, ' '));
            Console.Out.Flush();
        }

        public void Solve(ConsoleInput cin)
        {
            checked
            {
                var n = cin.ReadInt;
                var m = cin.ReadInt;
                WriteLine((m + (m / 100)) * Pow(100, n));
            }
        }
    }

    public class Pair
    {
        public long X;
        public long Y;
        public long Z;
        public long S;
        public Pair(long x, long y, long z) { X = x; Y = y; Z = z; S = x + y + z; }
    }

    public class ConsoleInput
    {
        private readonly System.IO.TextReader _stream;
        private char _separator = ' ';
        private Queue<string> inputStream;
        public ConsoleInput(System.IO.TextReader stream, char separator = ' ')
        {
            this._separator = separator;
            this._stream = stream;
            inputStream = new Queue<string>();
        }
        public string Read
        {
            get
            {
                if (inputStream.Count != 0) return inputStream.Dequeue();
                string[] tmp = _stream.ReadLine().Split(_separator);
                for (int i = 0; i < tmp.Length; ++i)
                    inputStream.Enqueue(tmp[i]);
                return inputStream.Dequeue();
            }
        }
        public string ReadLine { get { return _stream.ReadLine(); }}
        public int ReadInt { get { return int.Parse(Read); }}
        public long ReadLong { get { return long.Parse(Read); }}
        public double ReadDouble { get { return double.Parse(Read); }}
        public string[] ReadStrArray(long N) { var ret = new string[N]; for (long i = 0; i < N; ++i) ret[i] = Read; return ret;}
        public int[] ReadIntArray(long N) { var ret = new int[N]; for (long i = 0; i < N; ++i) ret[i] = ReadInt; return ret;}
        public long[] ReadLongArray(long N) { var ret = new long[N]; for (long i = 0; i < N; ++i) ret[i] = ReadLong; return ret;}
        public void ReadIntArrays(long N, out int[] A, out int[] B) { A = new int[N]; B = new int[N]; for (long i = 0; i < N; ++i) { A[i] = ReadInt; B[i] = ReadInt; }}
        public void ReadIntArrays(long N, out int[] A, out int[] B, out int[] C) { A = new int[N]; B = new int[N]; C = new int[N]; for (long i = 0; i < N; ++i) { A[i] = ReadInt; B[i] = ReadInt; C[i] = ReadInt; }}
        public void ReadLongArrays(long N, out long[] A, out long[] B) { A = new long[N]; B = new long[N]; for (long i = 0; i < N; ++i) { A[i] = ReadLong; B[i] = ReadLong; }}
    }
}


Measured memory_bytes: 11220
using System;
using System.Collections.Generic;
using System.Linq;
using System.Numerics;
class Program
{   
    public void Slove()
    {
        int n = int.Parse(Console.ReadLine());
        bool[] testimony = Console.ReadLine().Select(x => x == 'o').ToArray();
        foreach(int first in Enumerable.Range(0, 2))
            foreach(int second in Enumerable.Range(0, 2))
            {
                bool[] isSheep = new bool[n];
                isSheep[0] = first == 0;
                isSheep[1] = second== 0;
                foreach(int i in Enumerable.Range(2, n - 2))
                {
                    isSheep[i] = (isSheep[i - 1] == testimony[i - 1]) ? isSheep[i - 2] : !isSheep[i - 2];
                }
                if(((isSheep[n - 1] == testimony[n - 1]) == (isSheep[0] == isSheep[n - 2])) &&
                    ((isSheep[0] == testimony[0]) == (isSheep[1] == isSheep[n - 1])))
                {
                    System.Console.WriteLine(string.Join("", isSheep.Select(x => x ? 'S' : 'W')));
                    return;
                }
            }
        System.Console.WriteLine(-1);
    }
    
    static void Main(string[] args)
    {
        new Program().Slove();
    }
}


Measured memory_bytes: 15556
#include<bits/stdc++.h>
using namespace std;
 
typedef pair<int,int> P;
 
P merge(P a,P b){
  int l=min(a.first,b.first);
  int r=max(a.second,b.second);
  return P(l,r);
}
 
int n,m;
vector< int > G[100001];
P t[200000];
 
int main(){
  cin>>n>>m;
  for(int i=0;i<n;i++){
    t[i]=P(i,i);
  }
  for(int i=0;i<m;i++){
    int x,y;
    cin>>x>>y;
    G[x].push_back(y);
  }
  for(int i=0;i<100001;i++){
    for(int j=0;j<(int)G[i].size();j++){
      int y=G[i][j];
      t[y-1]=t[y]=merge(t[y-1],t[y]);
    }
  }
  for(int i=0;i<n;i++){
    if(i)cout<<' ';
    cout<<t[i].second-t[i].first+1;
  }
  cout<<endl;
  return 0;
}

Measured memory_bytes: 10120
#include<iostream>

using namespace std;

int main(){
  int n,i,j,a,c=0;
  
  cin>>n;
  j=n;
  while(j>0){
    a=j%10;
    c+=a;
    j=j/10;
  }
  cout<<(n%c==0?"Yes":"No")<<endl;
  return 0;
}

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

namespace ConsoleApp
{
    class Program
    {
        static List<string> perms = new List<string>();

        static void Main(string[] args)
        {
            var N = int.Parse(Console.ReadLine());

            var dic = new Dictionary<string, int>();
            var w = Console.ReadLine();
            dic.Add(w, 0);
            bool shiritori = true;
            for (int i = 1; i < N; i++)
            {
                var prevW = w;
                w = Console.ReadLine();

                if (!shiritori) continue;

                if (dic.ContainsKey(w))
                {
                    shiritori = false;
                    continue;
                }

                if (prevW[prevW.Length - 1] != w[0])
                {
                    shiritori = false;
                    continue;
                }

                dic.Add(w, 0);
            }

            if (shiritori)
                Console.WriteLine("Yes");
            else
                Console.WriteLine("No");
        }
    }
}


Measured memory_bytes: 13152
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <map>
#include <algorithm>
#include <iomanip>
#include <queue>
#include <utility>
#include <set>
#include <unordered_set>
#include <stack>
#include <iterator>
#include <random>
#include <fstream>
#include <chrono>
#include <math.h>
using namespace std;
#define int long long
#define forn(i, n) for (int i = 0; i < n; ++i)

double dp[301][301][301];

int32_t main()
{
    int n;
    cin >> n;
    for (int c3 = 0; c3 <= n; c3++) {
        for (int c2 = 0; c2 + c3 <= n; c2++) {
            for (int c1 = 0; c3 + c2 + c1 <= n; c1++) {
                if (c1 == 0 && c2 == 0 && c3 == 0) {
                    continue;
                }
                double sum = n;
                if (c1 > 0) {
                    sum += c1 * dp[c1 - 1][c2][c3];
                }
                if (c2 > 0) {
                    sum += c2 * dp[c1 + 1][c2 - 1][c3];
                }
                if (c3 > 0) {
                    sum += c3 * dp[c1][c2 + 1][c3 - 1];
                }
                dp[c1][c2][c3] = sum / (c1 + c2 + c3);
            }
        }
    }
    int c1, c2, c3;
    c1=c2=c3=0;
    forn(i,n) {
        int x;
        cin >> x;
        if (x == 1) {
            c1++;
        } else if (x == 2) {
            c2++;
        } else {
            c3++;
        }
    }
    cout.precision(16);
    cout << fixed << dp[c1][c2][c3] << endl;
    return 0;
}

Measured memory_bytes: 213248
#include <iostream>
#include <string>
#include <vector>
#include <climits>
#include <algorithm>
#include <set>

using namespace std;

int N, M;
bool A[800][800];
int color[800];
int numgraph=1;
int numcolor[800][2];
bool dp[800][2];

bool dfs(int v, int c) {
  color[v] = c;
  for (int i = 1; i <= N; i++) {
    if (v == i) {
      continue;
    }
    if (!A[v][i]) {
      if (color[i] == c) {
        return false;
      }
      if (color[i] == 0 && !dfs(i, c*(-1))) {
        return false;
      }
    }
  }
  return true;
}

int func(int n) {
  int l = n;
  int r = N-n;
  return l*(l-1)/2 + r*(r-1)/2;
}

int main() {
  cin >> N >> M;
  while (M > 0) {
    int i, j;
    cin >> i >> j;
    A[i][j] = true;
    A[j][i] = true;
    M--;
  }
  for (int i=1; i<=N; i++) {
    if (color[i] == 0) {
      if (!dfs(i, numgraph)) {
        cout << -1 << endl;
        return 0;
      }
      numgraph++;
    }
  }
  numgraph--;
  for (int i=1; i<=N; i++) {
    if (color[i] > 0) {
      numcolor[color[i]][0]++;
    } else {
      numcolor[color[i]*(-1)][1]++;
    }
  }
  /**
  for (int i=1; i<=numgraph; i++) {
    cout << "numcolor[" << i << "][" << 0 << "] = " << numcolor[i][0] << endl;
    cout << "numcolor[" << i << "][" << 1 << "] = " << numcolor[i][1] << endl;
  }
  */

  dp[0][0] = true;
  for (int i=1; i<=numgraph; i++) {
    // cout << "processing graph " << i << endl;
    for (int j=0; j<=N; j++) {
      if (j-numcolor[i][0] >= 0) {
        dp[j][1] = dp[j - numcolor[i][0]][0];
      }
      if (j-numcolor[i][1] >= 0) {
        dp[j][1] = dp[j][1] || dp[j - numcolor[i][1]][0];
      }
    }
    for (int j=0; j<=N; j++) {
      // cout << "dp[" << j << "]: " << dp[j][1] << endl;
      dp[j][0] = dp[j][1];
      dp[j][1] = false;
    }
  }

  int mn = N;
  int ans = N*N;
  for (int j=1; j<N; j++) {
    if (dp[j][0]) {
      // cout << "j: " << j << endl;
      ans = min(ans, func(j));
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 896
#include<stdio.h>
int main(void){
  int n,m,c,a,b[20],i,j,ans=0,s;
  scanf("%d%d%d",&n,&m,&c);
  for(i=0;i<m;i++) scanf("%d",&b[i]);
  for(j=0;j<n;j++){
    s=c;
    for(i=0;i<m;i++){
      scanf("%d",&a);
      s+=a*b[i];
    }
    if(s>0)ans++;
  }
  printf("%d",ans);
  return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<math.h>
#include<algorithm>
#include<stdlib.h>
#include<stack>
#include<set>
#include<string.h>
#include<map>
#include<vector>
#define pb push_back
#define eb emplace_back
#define ins insert 
#define mp make_pair
#define ll long long 
#define max3(a,b,c) max(c,max(a,b))
#define min3(a,b,c) min(c,min(a,b))
#define M 10000007
using namespace std;
void solve(){
	ll n;
	cin>>n;
	ll a[n][3],dp[n+1][3];
	for (int i = 0; i < n; ++i)
	{
		cin>>a[i][0]>>a[i][1]>>a[i][2];
		dp[i][0]=0;
		dp[i][1]=0;
		dp[i][2]=0;
	}
	dp[0][0]=a[0][0];
	dp[0][2]=a[0][2];
	dp[0][1]=a[0][1];
	for (int i = 1; i < n; ++i)
	{
		dp[i][0]=a[i][0]+max(dp[i-1][1],dp[i-1][2]);
		dp[i][1]=a[i][1]+max(dp[i-1][2],dp[i-1][0]);
		dp[i][2]=a[i][2]+max(dp[i-1][0],dp[i-1][1]);
	}
	cout<<max3(dp[n-1][0],dp[n-1][1],dp[n-1][2]);
}
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll t=1;
    //cin>>t;
    while(t--){
        solve();
    }
    return 0 ;
}


Measured memory_bytes: 4992
#include<iostream> 
#include<string>
#include<algorithm>
using namespace std;
int s[100], top=0;
char n[100];

void push(int num) {
	s[top++] = num;
}

int pop() {
	return (s[--top]);
}

int main()
{
	while (cin >> n) {
		if (n[0] == '+') {
			int a = pop();
			int b = pop();
			push(a + b);
		}
		else if (n[0] == '-') {
			int a = pop();
			int b = pop();
			push(b-a);
		}
		else if (n[0] == '*') {
			int a = pop();
			int b = pop();
			push(a * b);
		}
		else {
			push(atoi(n));
		}
	}
	cout << pop() << endl;
}


Measured memory_bytes: 3100
import java.util.Scanner;
public class Main{
	public static void main(String[]args){
    Scanner sc=new Scanner(System.in);
      String S=sc.next();
      char m0=S.charAt(0);
      char m1=S.charAt(1);
      char m2=S.charAt(2);
      char m3=S.charAt(3);
      if(m0==m1){
      	if(m2==m3){
        	if(m0==m2){
            	System.out.println("No");
            }else{
            	System.out.println("Yes");
            }
        }
        else{
        	System.out.println("No");
        }
      }else if(m0==m2){
      	if(m1==m3){
        	if(m0==m1){
            	System.out.println("No");
            }else{
            	System.out.println("Yes");
            }
        }
        else{
        	System.out.println("No");
        }
      }else if(m0==m3){
      	if(m1==m2){
        	if(m0==m1){
            	System.out.println("No");
            }else{
            	System.out.println("Yes");
            }
        }
        else{
        	System.out.println("No");
        }
      }else{
      	System.out.println("No");
      }
    }
}

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

using namespace std;

#define IO ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define ll long long int
#define ull unsigned long long int

const int INF = 1e9 + 7;
const int N = 1e5+5;


int main() {

	IO;

	int n;
	cin >> n;
	
	ll ans = 0;
	
	//for (int c = 1; c <=n; ++c) {
		for (int a = 1; a <= n; ++a) {
			for (int b = 1; b <=n / a; ++b) {
					if (a*b < n) {
						++ans;
					}
				}
			}
		//}
		
	cout << ans;
}




Measured memory_bytes: 3688
#include <bits/stdc++.h>
using namespace std;
const int MN=100000;

int main()
{
  int n;
  long long S;
  scanf("%d%lld",&n,&S);
  static long long X[MN],P[MN];
  for(int i=0;i<n;i++){
    scanf("%lld%lld",X+i,P+i);
  }
  int s=lower_bound(X,X+n,S)-X;
  long long ans=0ll;
  for(int i=0,j=n-1;;){
    //printf("%d %d\n",i,j);
    if(i==s){
      ans+=X[j]-S;
      break;
    }
    if(j==s-1){
      ans+=S-X[i];
      break;
    }
    if(P[i]>=P[j]){
      ans+=X[j]-X[i];
      while(j>=s&&P[i]>=P[j]){
	P[i]+=P[j];
	j--;
      }
    }
    else{
      ans+=X[j]-X[i];
      while(i<s&&P[i]<P[j]){
	P[j]+=P[i];
	i++;
      }
    }
  }
  printf("%lld\n",ans);
  return 0;
}


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

namespace D2019PC
{
    class C
    {
        static void Main(string[] args)
        {

            long N = long.Parse(Console.ReadLine());

            List<long> list = new List<long>();
            for (long i = 1; i < Math.Sqrt(N); i++)
            {
                if (N % i == 0)
                {
                    list.Add((N / i) - 1);
                }
            }

            long count = 0;
            foreach (var i in list)
            {
                if (N % i != 0) count += i;
            }
            Console.WriteLine(count);
        }
    }
}


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

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int N;
  string S;
  cin >> N >> S;
  vector<vector<int>> L(N + 1, vector<int>(10, 0)),
      R(N + 1, vector<int>(10, 0));
  for (int i = 0; i < N; i++) {
    L[i][S[i] - '0']++;
    for (int j = 0; j < 10; j++) {
      L[i + 1][j] += L[i][j];
    }
  }
  for (int i = N; i > 0; i--) {
    R[i][S[i - 1] - '0']++;
    for (int j = 0; j < 10; j++) {
      R[i - 1][j] += R[i][j];
    }
  }
  int res = 0;
  for (int a = 0; a < 10; a++) {
    for (int b = 0; b < 10; b++) {
      for (int c = 0; c < 10; c++) {
        for (int i = 1; i < N - 1; i++) {
          if (L[i - 1][a] > 0 && S[i] - '0' == b && R[i + 2][c] > 0) {
            res++;
            break;
          }
        }
      }
    }
  }
  cout << res << '\n';
  return 0;
}


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

#define ran 101101

int n, m;
int a[ran];
pair<int, int> v[ran];

int main() {
	scanf("%d%d", &n, &m);
	long long ans=0;
	for(int i=0;i<n;i++) { scanf("%d", &a[i]); ans+=a[i]; }
	sort(a, a+n);
	
	for(int i=0;i<m;i++)
		scanf("%d%d", &v[i].second, &v[i].first);
	sort(v, v+m);
	
	int it = m-1;
	for(int i=0;i<n && it>=0 && a[i] < v[it].first; i++) {
		if(v[it].second <= 0) it--;
		if(it<0) break;
		
		if(a[i]<v[it].first) {
			ans+=v[it].first - a[i];
			v[it].second--;
		} else break;
	}
	printf("%lld\n", ans);
	
	return 0;
}

Measured memory_bytes: 1280
#include<stdio.h>
#include<string.h>
int n,i,a,c[3];
int main(){
    scanf("%d",&n);
    for(i=0;i<n;i++){
        scanf("%d",&a);
        if(a%4==0) c[2]++;
        else if(a%2==0) c[1]++;
        else c[0]++;
    }
    if(c[2]>=c[0] || c[2]==c[0]-1 && c[1]==0) printf("Yes\n"); else printf("No\n");
}


Measured memory_bytes: 128
from fractions import gcd

def calc_half(n):
    return n//2

def lcm(L):
    ret=1
    for i in range(len(L)):
        ret=(ret*L[i])//gcd(ret,L[i])
    return ret

def f(n):
    ret=0
    while n%2==0:
        ret+=1
        n=n//2
    return ret

def g(L):
    l=[]
    for i in L:
        l.append(f(i))
    if len(set(l))==1:
        return False
    else:
        return True

n,m=map(int,input().split())
A=list(map(int,input().split()))
Auniq=list(set(A))
Ahalf=list(map(calc_half,Auniq))
lcm_ori=lcm(Auniq)
lcm_half=lcm(Ahalf)

if m<lcm_half or g(Auniq):
    print("0")
else:
    print(1+(m-lcm_half)//lcm_ori)

Measured memory_bytes: 16348
use std::fmt::Debug;
use std::str::FromStr;

pub struct TokenReader {
    reader: std::io::Stdin,
    tokens: Vec<String>,
    index: usize,
}

impl TokenReader {
    pub fn new() -> Self {
        Self {
            reader: std::io::stdin(),
            tokens: Vec::new(),
            index: 0,
        }
    }

    pub fn next<T>(&mut self) -> T
    where
        T: FromStr,
        T::Err: Debug,
    {
        if self.index >= self.tokens.len() {
            self.load_next_line();
        }
        self.index += 1;
        self.tokens[self.index - 1].parse().unwrap()
    }

    pub fn vector<T>(&mut self) -> Vec<T>
    where
        T: FromStr,
        T::Err: Debug,
    {
        if self.index >= self.tokens.len() {
            self.load_next_line();
        }
        self.index = self.tokens.len();
        self.tokens.iter().map(|tok| tok.parse().unwrap()).collect()
    }

    pub fn load_next_line(&mut self) {
        let mut line = String::new();
        self.reader.read_line(&mut line).unwrap();

        self.tokens = line
            .split_whitespace()
            .map(String::from)
            .collect();
        self.index = 0;
    }
}

fn main() {
    let mut reader = TokenReader::new();
    let n = reader.next::<usize>();

    let mut vec = reader.vector::<i64>();
    vec.sort();
    vec.reverse();

    let mut res = vec[0];
    let mut index = 1;

    for i in 2..n {
        res += vec[index];
        if i % 2 == 1 {
            index += 1;
        }
    }
    println!("{}", res);
}


Measured memory_bytes: 15148
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MAX = 100;
int len(string s){
    int count = 0;
    for(int i = 0; i < MAX; i++){
        if(s[i] != '\0' && s[i] != '\n') count++;
        else break;
    }
    return count;
}

int main(){
   string s; cin >> s;
   int l = len(s);
   int ans = 0;
   for(int i = 0; i < l; i++){
       if(s[i] != s[l-1-i]){
           s[i] = s[l-1-i];
           ans++;
       }
   }
   cout << ans << endl;
}

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

void Main() {
  int n, a[200000];
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  int cnt = 0;
  int now = 1;
  for (int i = 0; i < n; i++) {
    if (a[i] == now) now++;
    else cnt++;
  }

  if (n - cnt) cout << cnt << endl;
  else cout << -1 << endl;
}

int main() {
  std::cin.tie(nullptr);
  std::ios_base::sync_with_stdio(false);
  std::cout << std::fixed << std::setprecision(15);
  Main();
  return 0;
}


Measured memory_bytes: 1024
N = int(input())
A = list(map(int,input().split()))
flag = True
ans = 0
while(flag):
  for i in range(N):
    if A[i]%2 != 0:
      flag = False
      break
    else:
      A[i] = int(A[i]/2)
  else:
    ans+=1
print(ans)

Measured memory_bytes: 3060
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		int n;
		int y;
		try (Scanner scanner = new Scanner(System.in)) {
			n = scanner.nextInt();
			y = scanner.nextInt();
		}

		int a = -1;
		int b = -1;
		int c = -1;

		for (int i = 0; i <= n; i++) {
			for (int j = 0; i + j <= n; j++) {
				int k = n - i - j;

				if (y == i * 10000 + j * 5000 + k * 1000) {
					a = i;
					b = j;
					c = k;
				}
			}
		}

		System.out.println(a + " " + b + " " + c);
	}
}

Measured memory_bytes: 23124
#include<iostream>
#include <algorithm>
using namespace std;
int main(){
    long long int n,a,ans1=1000000,ans2=-1000000,ans3=0;
    cin >> n;
    for(int i=0; i<n; i++){
        cin >> a;
        ans1 =min(ans1,a);
        ans2 =max(ans2,a);
        ans3 += a;
    }
    cout << ans1 << " " << ans2 << " " << ans3 << endl;
    return 0;
}

Measured memory_bytes: 3124
package main
import (
  "bufio"
  "os"
  "strconv"
  "strings"
  "fmt"
)

const p = 998244353

func Solve() {
  var N, S int
  NextInt(&N, &S)
  var A []int
  NextIntVec(&A)
  DP := make([][]int, N + 1)
  for i := range DP { DP[i] = make([]int, S + 1) }
  DP[0][0] = 1
  for i, a := range A {
    for j := S; 0 <= j; j-- {
      DP[i + 1][j] = (DP[i + 1][j] + 2 * DP[i][j]) % p
      if a + j > S { continue }
      DP[i + 1][a + j] = (DP[i + 1][a + j] + DP[i][j]) % p
    }
  }
  Write(DP[N][S])
}

func main() {
  Solve()
  Output()
}

var reader = bufio.NewReaderSize(os.Stdin, 1000000)
var writer = bufio.NewWriter(os.Stdout)
func NextLine() string {
  buffer := make([]byte, 0)
  for true {
    line, isPrefix, err := reader.ReadLine()
    if err != nil { panic(err) }
    buffer = append(buffer, line...)
    if !isPrefix { break }
  }
  return string(buffer)
}
func NextInt(A ...*int) {
  L := strings.Split(NextLine(), " ")
  for i, a := range A {
    *a, _ = strconv.Atoi(L[i])
  }
}
func NextIntVec(A *[]int) {
  L := strings.Split(NextLine(), " ")
  (*A) = make([]int, len(L))
  for i, l := range L {
    (*A)[i], _ = strconv.Atoi(l)
  }
}
func NextFloat(A ...*float64) {
  L := strings.Split(NextLine(), " ")
  for i, a := range A {
    *a, _ = strconv.ParseFloat(L[i], 64)
  }
}
func NextFloatVec(A *[]float64) {
  L := strings.Split(NextLine(), " ")
  (*A) = make([]float64, len(L))
  for i, l := range L {
    (*A)[i], _ = strconv.ParseFloat(l, 64)
  }
}
func Write(s interface{}) {
  fmt.Fprintln(writer, s)
}
func WriteIntVec(A []int) {
  S := make([]string, len(A))
  for i, a := range A {
    S[i] = strconv.Itoa(a)
  }
  Write(strings.Join(S, " "))
}
func Output() {
  _ = writer.Flush()
}
func MaxInt(A ...int) int {
  max := A[0]
  for _, a := range A {
    if max < a { max = a }
  }
  return max
}
func MinInt(A ...int) int {
  min := A[0]
  for _, a := range A {
    if a < min { min = a }
  }
  return min
}
func SumInt(A ...int) int {
  sum := 0
  for _, a := range A {
    sum += a
  }
  return sum
}
func AbsInt(x int) int {
  if x < 0 { x = -x }
  return x
}

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

int main(){
	int a,b;
	int s[5002],t[5002];
	scanf("%d%d",&a,&b);
	for(int i=0;i<a;i++){
		scanf("%d",&s[i]);
	}
	for(int i=0;i<b;i++){
		scanf("%d",&t[i]);
	}

	int ret=0;
	for(int i=0;i<b-ret;i++){
		int p=0,q=i;
		int cnt=0;
		while(1){
			if(s[p]==t[q]){
				cnt++;
				p++;
				q++;
			}
			else {
				p++;
			}
			if(p==a)break;
		}
		ret=max(ret,cnt);
	}

	printf("%d\n",ret);
}

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

int main() {
	int N;
	long long W;
	const long long INF = 1000000000000000;
	cin >> N >> W;
	long long w[N];
	int v[N];
	for (int i = 0; i < N; i++) cin >> w[i] >> v[i];
	long long dp[N + 1][100010];
	for (int i = 0; i < N + 1; i++) {
		for (int j = 0; j < 100010; j++) {
			dp[i][j] = INF;
		}
	}
	dp[0][0] = 0;
	for (int i = 0; i < N; i++) {
		for (int j = 0; j < 100010; j++) {
			if (j >= v[i]) {
				dp[i + 1][j] = min(dp[i][j], dp[i][j - v[i]] + w[i]);
			}
			else {
				dp[i + 1][j] = min(dp[i + 1][j], dp[i][j]);
			}
		}
	}
	int ans;
	for (int i = 100000; i >= 0; i--) {
		if (dp[N][i] <= W) {
			ans = i;
			break;
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 79104
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);

		int h = sc.nextInt();
		int w = sc.nextInt();
		String s[][] = new String[h][w];
		for (int i = 0; i < h; i++) {
			String sh = sc.next();
			for (int j = 0; j < w; j++) {
				s[i][j] = sh.substring(j, j + 1);
				//				System.out.print(s[i][j]);
			}
			//			System.out.println("");
		}

		for (int i = 0; i < h; i++) {
			for (int j = 0; j < w; j++) {
				//Mineはスルー
				if (s[i][j].equals("#")) {
					continue;
				}

				//処理
				int cnt = 0;
				try {
					if (s[i - 1][j - 1].equals("#"))
						cnt++;
				} catch (Exception e) {
				}
				try {
					if (s[i - 1][j].equals("#"))
						cnt++;
				} catch (Exception e) {
				}
				try {
					if (s[i - 1][j + 1].equals("#"))
						cnt++;
				} catch (Exception e) {
				}
				try {
					if (s[i][j - 1].equals("#"))
						cnt++;
				} catch (Exception e) {
				}
				try {
					if (s[i][j].equals("#"))
						cnt++;
				} catch (Exception e) {
				}
				try {
					if (s[i][j + 1].equals("#"))
						cnt++;
				} catch (Exception e) {
				}
				try {
					if (s[i + 1][j - 1].equals("#"))
						cnt++;
				} catch (Exception e) {
				}
				try {
					if (s[i + 1][j].equals("#"))
						cnt++;
				} catch (Exception e) {
				}
				try {
					if (s[i + 1][j + 1].equals("#"))
						cnt++;
				} catch (Exception e) {
				}
				s[i][j] = Integer.toString(cnt);
			}
		}

		//ans部分
		for (int i = 0; i < h; i++) {
			for (int j = 0; j < w; j++) {
				System.out.print(s[i][j]);
			}
			System.out.println("");
		}

	}

}


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

#define whole(f,x,...) ([&](decltype((x)) whole) { return (f)(begin(whole), end(whole), ## __VA_ARGS__); })(x)

using ll = long long;
ll cnt[100001];
int main() {
  ll n, k; cin >> n >> k;
  int a, b;
  REP(i,n) {
    cin >> a >> b;
    cnt[a] += b;
  }
  REP(i,100001) {
    if (k <= cnt[i]) {
      cout << i << endl;
      return 0;
    }
    k-=cnt[i];
  }
  return 0;
}


Measured memory_bytes: 1024
import java.util.Scanner;

public class Main {

  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int keirosu = sc.nextInt();
    int limit = sc.nextInt();
    int[] cost = new int[keirosu];
    int[] time = new int[keirosu];
    for (int i = 0; i < keirosu; i++) {
      cost[i] = sc.nextInt();
      time[i] = sc.nextInt();
    }
    int min = Integer.MAX_VALUE;
    boolean tle = false;
    for (int i = 0; i < keirosu; i++) {
      if (time[i] <= limit && cost[i] < min) {
        min = cost[i];
        tle = true;
      }
    }
    System.out.println(tle ? min : "TLE");
  }

}


Measured memory_bytes: 22612
program Bingo
    implicit none
    integer(4):: bng(3,3), num
    integer(4):: i,j,k, n
    logical:: is_open(3,3) = .false.

    do i=1, 3
        read*, bng(:,i)
    end do

    read*, n

    do i=1, n
        read*, num

        do j=1,3
            do k=1,3
                if (bng(k,j) == num) is_open(k,j) = .true.  
            end do
        end do
    end do

    if (check_bingo(is_open)) then
        print*, 'Yes'
    else
        print*, 'No'
    end if

    contains
    function check_bingo(is_open) result(is_bingo)
        integer(4):: i,j
        logical:: is_open(3,3), is_bingo

        is_bingo = .false.

        do i=1, 3
            if (is_open(1,i) .and. is_open(2,i) .and. is_open(3,i)) is_bingo = .true.
            if (is_open(i,1) .and. is_open(i,2) .and. is_open(i,3)) is_bingo = .true.
        end do

        if (is_open(1,1) .and. is_open(2,2) .and. is_open(3,3)) is_bingo = .true.
        if (is_open(1,3) .and. is_open(2,2) .and. is_open(3,1)) is_bingo = .true.
        
    end function
end program Bingo

Measured memory_bytes: 256
# -*- coding: utf-8 -*-

import numpy as np

N = int(input())

A = np.array(list(map(int, input().split())))

if 0 in A:
    print(0)
    exit(0)

mul = A[0]

for i in A[1:]:
    if 1000000000000000000 / i < mul:
        print(-1)
        exit(0)
    mul *= i

if mul > 1000000000000000000:
    print(-1)
    exit(0)

print(mul)


Measured memory_bytes: 39820
a = int(input())
b = [int(input()) for _ in range(a)]
c = [0] * a
c[0] = b[0]
c[1] = max(b[1], c[0])
d = [0] * a
d[0] = b[-1]
d[1] = max(b[-2], d[0])
for i in range(2, len(b)):
    c[i] = max(c[i-1], b[i])
    d[i] = max(d[i-1], b[-i-1])
c.insert(0, 0)
d.insert(0, 0)
for i in range(len(c)-1):
    print(max(c[i], d[-i-2]))


Measured memory_bytes: 15732
s = input()

a = []
b = []

flag = 0

for i in range(len(s)):
    if i % 2 == 1:
        a.append(s[i])
    else:
        b.append(s[i])
        
for j in a:
    if j == 'R':
        flag += 1
        break
for k in b:
    if k == 'L':
        flag += 1
        break

if flag == 0:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 3064
#include <iomanip>
#include <random>
#include <time.h>
#include <vector>
#include <queue>
#include <functional>
#include <map>
#include <string>
#include <cstdlib>
#include <typeinfo>
#include <math.h>
#include <algorithm>
#include <iostream>
using namespace std;
int main() {
	long long int n, t, a, T, A, x, y;
	cin >> n;
	for (int i = 1; i <= n; i++) {
		cin >> t >> a;
		if (i == 1)T = t, A = a;
		else {
			x = (T + t - 1) / t;
			y = (A + a - 1) / a;
			x = max(x, y);
			t *= x, a *= x;
			T = t, A = a;
		}
	}
	cout << T + A << endl;
	return 0;
}


Measured memory_bytes: 256
/// kAAzuki Hoshino
/*
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")
*/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define int long long
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>ordered_set;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int,int> pi;
typedef vector<pi> vpi;
#define inf 1000000000
#define mod 1000000007
#define rep(i,a,b) for (int i = a; i <= b; i++)
#define rep1(i, a, b) for(int i =a; i >=b; i--)
#define dmp(x) cerr<<"line "<<__LINE__<<" "<<#x<<":"<<x<<endl
#define fs first
#define sc second
#define pb push_back
#define all(c) (c).begin(),(c).end()
#define mt make_tuple
template<class S,class T> ostream& operator<<(ostream& o,const pair<S,T> &p){
	return o<<"("<<p.fs<<","<<p.sc<<")";
}
template<class T> ostream& operator<<(ostream& o,const vector<T> &vc){
	o<<"{";
	for(const T& v:vc) o<<v<<",";
	o<<"}";
	return o;
}

string s;

signed main(){
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
//freopen("input.txt", "r", stdin);
//freopen("output.txt", "w", stdout);

   cin >> s;
   for(int i=1;i<=3;i++){
      if(s[i]==s[i-1]){
         cout << "Bad" << endl;
         return 0;
      }
   }
   cout << "Good" << endl;


return 0;
}
///....


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
using namespace std;
int n,m,a[105],sum=0;
int main(){
	cin>>n>>m;
	for(int i=1;i<=n;i++){
		cin>>a[i];
		sum += a[i]; 
	}
	sort(a+1,a+n+1,greater<int>());
	double d = sum*1.0/(4*m);
	for(int i=1;i<=m;i++){
		if(a[i]<d){
			return cout<<"No"<<endl,0;
		}
	}
	cout<<"Yes"<<endl;
} 

Measured memory_bytes: 256
#include <iostream>
using namespace std;
#define debug(x) std::cerr << #x << " = " << (x) << std::endl
typedef long long LL;
const int MAXN = 1e5+17;
const int MOD = 1e9+7;
int a[MAXN];
int main(int argc ,char const *argv[])
{
	#ifdef noob
	freopen("Input.txt","r",stdin);freopen("Output.txt","w",stdout);
	#endif	
	int n,k,p=-1;
	cin>>n>>k;
	for (int i = 1; i <= n; ++i)
	{
		cin>>a[i];
		if(a[i]>=k)
			p = i;
	}
	debug(p);
	if(p!=-1)
	{
		cout<<"Possible"<<endl;
		for (int i = 1; i < p; ++i)
		{
			cout<<i<<endl;
		}
		for (int i = n-1; i >= p; --i)
		{
			cout<<i<<endl;
		}
	}
	else
	{
		int pp = -1;
		for (int i = 1; i <= n-1; ++i)
		{
			if(a[i]+a[i+1]>=k)
				pp = i;
		}
		// debug(pp);
		if(pp!=-1)
		{
			cout<<"Possible"<<endl;
			for (int i = 1; i < pp; ++i)
			{
				cout<<i<<endl;
			}
			for (int i = n-1; i > pp; --i)
			{
				cout<<i<<endl;
			}
			cout<<pp<<endl;
		}
		else
			cout<<"Impossible"<<endl;
	}
	return 0;	
}

Measured memory_bytes: 1152