akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
using P = pair<int, int>;
const int M = 1000000007;

int main() {
    while (1) {
        int n;
        cin >> n;
        if (!n) return 0;

        vector<int> a(n);
        for (int i = 0; i < n; ++i) {
            cin >> a[i];
        }
        sort(a.begin(), a.end());
        int sum = 0;
        for (int i = 1; i < n - 1; ++i) {
            sum += a[i];
        }
        cout << sum / (n - 2) << "\n";
    }
}



Measured memory_bytes: 3068
import java.util.*;
import java.io.*;
import static java.lang.Math.*;
public class Main {
    public static void main(String[] $) {
        int n=sc.nextInt(),k=sc.nextInt();
        double ans=0;
        for (int i = 1; i <= n; i++) {
            int t=(i-1+k)/i;
            int l=Integer.toString(t,2).length();
            int tail=Integer.numberOfTrailingZeros(t);
            int c=tail==l-1?tail:l;
            ans+=pow(0.5,c);
        }
        out.println(ans/n);
        out.close();
    }

    static PrintWriter out = new PrintWriter(System.out);

    static class sc {
        static Scanner s = new Scanner(System.in);

        static String next() {
            return s.next();
        }

        static String nextLine() {
            return s.nextLine();
        }

        static int nextInt() {
            return Integer.parseInt(s.next());
        }

        static long nextLong() {
            return Long.parseLong(s.next());
        }

        static double nextDouble() {
            return Double.parseDouble(s.next());
        }

        static boolean hasNext() {
            return s.hasNext();
        }
    }
}

Measured memory_bytes: 35668
#include <bits/stdc++.h>
#define ALL(v) v.begin(), v.end()
#define MOD 1000000007
#define INF 1000000007
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define req(i, j, n) for(int i = j; i <= (int)(n); i++)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;

int main() {
int h,a;
  cin>>h>>a;
cout<<(h+a-1)/a<<endl;
}

Measured memory_bytes: 256
//#include<bits/stdc++.h>
#include<iostream>
#include<iomanip>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<string>
#include<numeric>
#include<vector>
#include<set>
#include<map>
#include<unordered_map>
#include<stack>
#include<queue>
#include<list>
using namespace std;

typedef long long ll;

#define MOD 1000000007
ll fac[1000000];
ll finv[1000000];
ll inv[1000000];

void comb_init(){
  fac[0] = 1;
  for(int i=1;i<1000000;i++){
    fac[i] = i*fac[i-1];
    fac[i] %= MOD;
  }
  inv[1] = 1;
  for(int i=2;i<1000000;i++){
    inv[i] = MOD-inv[MOD%i]*(MOD/i)%MOD;
  }
  finv[0] = 1;
  for(int i=1;i<1000000;i++){
    finv[i] = inv[i]*finv[i-1];
    finv[i] %= MOD;
  }
}

ll comb(ll n,ll k){
  ll c = fac[n];
  c *= finv[k];c %= MOD;
  c *= finv[n-k];c %= MOD;
  return c;
}
int main(){
  ll m;
  cin >> m;
  ll d[m],c[m];
  ll count[10];
  ll last[10];
  for(int i=0;i<m;i++){
    cin >> d[i] >> c[i];
  }
  ll ans = 0;
  for(int i=0;i<10;i++){
    count[i] = 0;
    last[i] = -1;
  }
  for(int i=0;i<m;i++){
    count[d[i]] += c[i];
  }
  ll temp;
  for(int i=0;i<10;i++){
    if(count[i] == 0) continue;
    ans += count[i]-1;
    ans += i*count[i]/10;
    if(i == 0) last[i] = 0;
    else{
      temp = count[i]*i;
      temp -= (i*count[i]/10)*9;
      last[i] = temp;
    }
  }

  temp = 0;
  ans -= 1;
  for(int i=0;i<10;i++){
    if(last[i] == -1) continue;
    ans += 1;
    temp += last[i];
  }
  if(temp > 9){
    ans += temp/9;
    if(temp%9 == 0) ans-=1;
  }
  cout << ans << endl;


  return 0;
}


Measured memory_bytes: 3328
#include <bits/stdc++.h>
#define ull unsigned long long int
#define ll long long
#define int long long
#define ld long double
#define endl '\n'
const int mod= 1e9+7;
#define F first
#define S second
#define pb push_back
#define mp make_pair
#define trace(x) cerr << #x << " is " << x << endl;
#define all(x) x.begin(),x.end()
#define reset(x,val) memset(x,val,sizeof(x))
#define flush fflush(stdout)
#define sz(a) a.size()
#define pii pair<int,int>
using namespace std;
const int N=3005;
int dp[N][N],n,m;

int32_t main() {
    ios_base::sync_with_stdio(false);cin.tie(NULL);
    string s,t;
    cin>>s>>t;
    n=sz(s);
    m=sz(t);
    string ans="";
    for(int i=1;i<=n;i++)
    {
     for(int j=1;j<=m;j++)
     {
      if(s[i-1]==t[j-1])
      {
       dp[i][j]=dp[i-1][j-1]+1;
      }
      else
      dp[i][j]=max(dp[i-1][j],dp[i][j-1]);
     }
    }
   
    int i=n,j=m;
    while(i>0 && j>0)
    {
     //trace(ans);
     if(s[i-1]==t[j-1])
     {
      ans=s[i-1]+ans;
      i--;j--;
     }
     else
     {
      if(dp[i-1][j]==dp[i][j])
      i--;
      else j--;
     }
    }
    cout<<ans<<endl;    
    return 0;
}



Measured memory_bytes: 70784
def nexttrain(x, c, s, f):
    return c + max(s, -(-x//f)*f)
def inpl(): return [int(i) for i in input().split()]

N = int(input())
st = 0
CSF = []
for _ in range(N-1):
    CSF.append(inpl())
for j in range(N-1):
    for i in range(N-1-j):
        c, s, f = CSF[i+j]
        st = nexttrain(st, c, s, f)
    print(st)
    st = 0
print(0)

Measured memory_bytes: 3188
H, W = gets.split.map(&:to_i)
Ss = readlines.map(&:chomp)

a = Array.new(H + 1){Array.new(W + 1, 0)}
[*0 ... H].product([*0 ... W]).each do |i, j|
  [-1, 0, 1].repeated_permutation(2){|di, dj| a[i + di][j + dj] += 1} if Ss[i][j] == '#'
end
(0 ... H).each do |i|
  (0 ... W).each{|j| print Ss[i][j] == '#' ? '#' : a[i][j]}
  puts
end

Measured memory_bytes: 2172
#include <stdio.h>
typedef long long ll;

int main(void) {
  int i, j, k, sa = 1, h, w;
  scanf("%d%d", &h, &w);
  char s[h][w + 10];
  for(i = 0; i < h; ++i) scanf("%s", s[i]);
  for(i = 0; i < h; ++i) {
    for(j = 0; j < w; ++j) if(s[i][j] == '#') {
      int tmp = 1;
      if(i && s[i - 1][j] == '#') tmp = 0;
      if(j && s[i][j - 1] == '#') tmp = 0;
      if(i != h - 1 && s[i + 1][j] == '#') tmp = 0;
      if(j != w - 1 && s[i][j + 1] == '#') tmp = 0;
      if(tmp) sa = 0;
    }
    if(!sa) break;
  }
  if(sa) printf("Yes");
  else printf("No");
  return 0;
}

Measured memory_bytes: 128
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;
using System.Text;
using System.IO;
using static System.Math;
namespace AtCoder
{
    class Program
    {
        static public long[] Sarray() { return ReadLine().Split().Select(long.Parse).ToArray(); }
        static public List<long> Slist() { return ReadLine().Split().Select(long.Parse).ToList(); }

        static long Mod = (long)1e9 + 7;
        static void Main(string[] args)
        {
            //SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
            var NM = Sarray();
            var N = NM[0];
            var M = NM[1];
            var Ai = Sarray();
            var pq = new priority_queue<long>((l, r) => (int)(l - r));
            foreach (var a in Ai)
                pq.insert(a);
            for(var i=0;i<M;++i)
                pq.insert(pq.extract() / 2);
            var ans = 0L;
            while (pq.num != 0)
                ans += pq.extract();
            WriteLine(ans);
            //Out.Flush();
        }
        class priority_queue<T>
        {
            Comparison<T> cmp;
            T[] A = new T[2000000];
            public priority_queue(Comparison<T> c)
            {
                cmp = c;
            }
            public int num { get; private set; } = 0;
            public void insert(T v)
            {
                A[num] = v;
                ++num;
                increaseKey(num);
            }
            void increaseKey(int i)
            {
                while (1 < i && 0 < cmp(A[i - 1], A[i / 2 - 1]))
                {
                    var t = A[i - 1];
                    A[i - 1] = A[i / 2 - 1];
                    A[i / 2 - 1] = t;
                    i = i / 2;
                }
            }
            public T extract()
            {
                if (num < 1) return default(T);
                var max = A[0];
                A[0] = A[num - 1];
                --num;
                maxHeapify(1);
                return max;
            }
            void maxHeapify(int i)
            {
                var H = num;
                var l = left(i);
                var r = right(i);
                var largest = 0;
                if (l <= H && 0 < cmp(A[l - 1], A[i - 1]))
                { largest = l; }
                else
                { largest = i; }
                if (r <= H && 0 < cmp(A[r - 1], A[largest - 1]))
                { largest = r; }
                if (largest != i)
                {
                    var t = A[i - 1];
                    A[i - 1] = A[largest - 1];
                    A[largest - 1] = t;
                    maxHeapify(largest);
                }
            }
            int left(int l) => l * 2;
            int right(int r) => r * 2 + 1;
        }

    }
}

Measured memory_bytes: 29404
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using P = pair<int, int>;
#define PI acos(-1)
#define Mod (int)1000000007
#define Rep(i, n) for (int i = 0; i < (int)(n); i++)
#define BitRep(i, n) for (int i = 0; i < (int)(1 << n); i++)
#define All(vec) vec.begin(), vec.end()
#define Sum(vec) accumulate(vec.begin(), vec.end(), 0)
#define Sort(vec) sort(vec.begin(), vec.end())
#define Reverse(vec) reverse(vec.begin(), vec.end())
#define Count(vec, x) count(vec.begin(), vec.end(), x)
#define Next_permutation(vec) next_permutation(vec.begin(), vec.end())
#define Find(S, s) S.find(s) != string::npos

int main() {
    string s, t;
    cin >> s >> t;
    int n = s.size(), m = t.size();
    vector<vector<int>> dp(n + 1, vector<int>(m + 1));
    for (int i = 1; i <= n; i++) {
        for (int j = 1; j <= m; j++) {
            if (s[i - 1] == t[j - 1]) dp[i][j] = dp[i - 1][j - 1] + 1;
            else if (dp[i - 1][j] >= dp[i][j - 1]) dp[i][j] = dp[i - 1][j];
            else dp[i][j] = dp[i][j - 1];
        }
    }
    string ans = "";
    while (n > 0 && m > 0) {
        if (dp[n][m] == dp[n - 1][m]) n--;
        else if (dp[n][m] == dp[n][m - 1]) m--;
        else {
            ans = s[n - 1] + ans;
            n--, m--;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 38840
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <set>
#define rep(i, n) for(int i = 0; i < n; i++)
#define REP(i, m, n) for(int i = m; i < n; i++)
#define ALL(v) v.begin(),v.end()
#define RALL(v) v.rbegin(),v.rend()
#define INF 1e9
typedef long long ll;
using namespace std;

int main() {
    ll a,b,c,ans; cin >> a >> b >> c;
    ans = b/c-a/c;
    if(a%c==0){
        ans += 1;
    }
    cout << ans << endl;
    
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<list>
#include<vector>
#include<algorithm>
#include<string>
#include<stdio.h>
#include<math.h>
#include<unordered_map>
#include<map>

using namespace std;
using ll = long long;
using vec = vector<ll>;
using mat = vector<vec>;
using lst = list<ll>;

ll MOD = 1000000007;



int main()
{
	string s, t;
	cin >> s >> t;

	map<int, int> mp[26];

	for(int i=0;i<s.length();++i)
	{
		mp[s[i] - 'a'][i] = 1;
	}

	

	ll ans = 0;
	int index = -1;
	
	for (int i = 0; i < t.length(); ++i)
	{
		int ic = index;
		if (mp[t[i] - 'a'].empty())
		{
			cout << -1 << endl; return 0;
		}

		bool flag = mp[t[i] - 'a'].count(index);
		mp[t[i] - 'a'][index] = 0;
		auto itr = mp[t[i] - 'a'].find(index);
		itr++;

		if(itr == mp[t[i] - 'a'].end())
		{
			//cout << "#" << s.length() << endl;
			ans += s.length();
			ans -= index;
			ans += mp[t[i] - 'a'].begin()->first;
			index = mp[t[i] - 'a'].begin()->first;
		}
		else
		{
			ans += itr->first - index;
			index = itr->first;
		}
		if(!flag)mp[t[i] - 'a'].erase(ic);

		//cout << index << " " << ans << endl;
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 5120
N, M = map(int, input().split())
A = [0] * (N + 2)
MOD = 10 ** 9 + 7
dp = [0] * (N + 2)
for i in range(M):
    a = int(input())
    A[a] = 1


dp[0] = 1
for i in range(N):
    if A[i + 1] != 1:
        dp[i + 1] += dp[i]
        dp[i + 1] %= MOD
    if A[i + 2] != 1:
        dp[i + 2] += dp[i]
        dp[i + 2] %= MOD

print(dp[N])

Measured memory_bytes: 45528
import java.util.*;

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

        for (int a=0; a<=N; a++) {
            for (int b=0; b<=N-a; b++) {
                int c = N - a - b;
                int total = a * 10000 + b * 5000 + c * 1000;
                if (total == Y) {
                    System.out.println(a + " " + b + " " + c);
                    return;
                }
            }
        }

        System.out.println("-1 -1 -1");
    }
}

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

using namespace std;

#define ll long long

int main() {
    deque<ll> deq;
    int t, a, b;
    ll x;
    cin >> t;
    while (t--) {
        cin >> a;
        if (a == 0) {
            cin >> b >> x;
            if (b == 0) deq.push_front(x);
            else deq.push_back(x);
        } else if (a == 1) {
            cin >> x;
            cout << deq[x] << endl;
        } else if (a == 2) {
            cin >> b;
            if (b == 0) deq.pop_front();
            else deq.pop_back();
        }
    }

    return 0;
}


Measured memory_bytes: 6304
k = int(input())
a = [1,2,3,4,5,6,7,8,9] #一桁目を入れる。
kosu = [0,1,1,1,1,1,1,1,1,1]
total = sum(kosu)
i = 0 #これが1桁に相当.
tempk = k*1
while k > total:
  b = a.copy() #aのコピーを作ってbを参照して新しいaを作る。
  tempk = k - total
  i += 1
  a = [] #ここでaをリセット
  kosub = kosu.copy() #各々の数で終わる個数を記録
  kosu = []
  for i in range(10):
    if i == 0:
      kosu.append(kosub[i]+kosub[i+1])
    elif i == 9:
      kosu.append(kosub[i-1]+kosub[i])
    else:
      kosu.append(kosub[i-1]+kosub[i]+kosub[i+1])
  total += sum(kosu)
  for i in range(len(b)):
    if b[i]%10 == 0:
      a.append(b[i]*10)
      a.append(b[i]*10+1)
    elif b[i]%10 == 9:
      a.append(b[i]*10+8)
      a.append(b[i]*10+9)
    else:
      a.append(b[i]*10+b[i]%10-1)
      a.append(b[i]*10+b[i]%10)      
      a.append(b[i]*10+b[i]%10+1)
  #print(a)
  #print(kosu)
  #print(total)
#print(tempk,total,len(a))
print(a[tempk-1])

Measured memory_bytes: 11028
import sys
input = lambda: sys.stdin.readline().rstrip() 
sys.setrecursionlimit(10**7)
INF = 10**20
def I(): return int(input())
def F(): return float(input())
def S(): return input()
def LI(): return [int(x) for x in input().split()]
def LI_(): return [int(x)-1 for x in input().split()]
def LF(): return [float(x) for x in input().split()]
def LS(): return input().split()

def resolve():
    ABCD = S()
    A = ABCD[0]
    BCD = ABCD[1:]

    ans = [A, '', BCD[0], '', BCD[1], '', BCD[2], '=', '7']
    for i in range(2 ** 3):
        tmp = int(A)
        for j in range(3):
            if i >> j & 1:
                tmp += int(BCD[j])
                ans[j*2+1] = '+'
            else:
                tmp -= int(BCD[j])
                ans[j*2+1] = '-'
        if tmp == 7:
            print(''.join(ans))
            break

if __name__ == '__main__':
    resolve()


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

using namespace std;
const int N = 2e5 + 10;
typedef long long ll;
typedef pair<int,int> PII;

int a[N];
int n;
int p[N];
ll c(int n)
{
    return 1ll * n * (n - 1) / 2;
}

int main()
{
    int n;
    cin >> n;
    for(int i = 0;i < n;i++)
    {
        scanf("%d",a + i);
        p[a[i]]++;
    }
    ll ans = 0;
    for(int i = 0;i <= N;i++)
    {
        ans += c(p[i]);
    }
    for(int i = 0;i < n;i++)
    {
        ll t = ans;
        int k = p[a[i]];
        if(p[a[i]] < 1)
        {
            cout << 0 <<"\n";
            continue;
        }
        t -= c(k);
        t += c(p[a[i]] - 1);
        printf("%lld\n",t);
    }
    return 0;
}

Measured memory_bytes: 3712
#include<bits/stdc++.h>
using namespace std;
int main()
{
    string s;
    int c=0,b=0;
    cin>>s;
    for(int i=0;i<s.size();i++)
    {
        if(s[i]=='A')
        {
            c++;
        }
        else if(s[i]=='B')
        {
            b++;
        }
    }
    if(c >=1 && b>=1)
    {
        cout<<"Yes"<<endl;
    }
    else
    {
        cout<<"No"<<endl;
    }
    return 0;

}


Measured memory_bytes: 256
from collections import Counter
N = int(input())
S = [input() for i in range(N)]
M = int(input())
T = [input() for i in range(M)]

cs = Counter(S)
ct = Counter(T)
ans = 0
for k,v in cs.items():
    ans = max(ans, v - ct[k])
print(ans)

Measured memory_bytes: 3316
#include <iostream>
#include <sstream>
#include <fstream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <utility>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstdio>
#include <memory.h>
using namespace std;

const int Maxn=100005;

int n,x;
bool a[Maxn];

int main(){
	scanf("%d",&n);
	for(int i=1;i<=n;i++){
		scanf("%d",&x);
		if(x==i) a[i]=true;
	}
	int id=1,ans=0;
	while(id<=n){
		if(id<n){
			if(a[id]&&a[id+1]){
				ans++;
				id+=2;
			}
			else if(a[id]&&!a[id+1]){
				ans++;
				id+=2;
			}
			else if(!a[id]) id++;
		}
		if(id==n){
			if(a[id]) ans++;
			id++;
		}
	}
	printf("%d\n",ans);
return 0;
}

Measured memory_bytes: 384
MAX_V = 10**9

N = int(input())
TS = []
for i in range(N):
    X, L = map(int, input().split())
    TS.append((X + L, X - L))
TS = sorted(TS)
cur = -MAX_V
ans = 0
for i in range(N):
    if cur <= TS[i][1]:
        ans += 1
        cur = TS[i][0]
print(ans)

Measured memory_bytes: 17756
#include <bits/stdc++.h>
using namespace std;
#define lld long long int
// #define M 1000000007
#define fors(i,n) for(int i=0;i<n;++i)
#define fore(i,a,b) for(int i=a;i<=b;++i)
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define vv std::vector<int>
#define endl "\n"
#define test(i) cout<<i<<endl
#define tests(i) cout<<"i: "<<i<<endl;
#define itrt int t; cin>>t; fors(i,t)
#define itr1 int t; cin>>t;
#define ff first
#define ss second
#define pb push_back
#define vmp make_pair
#define ppb pop_back
#define sorta(a,n) sort(arr,arr+n)
#define sortv(x) sort(x.begin(),x.end())
void file(){
    #ifdef LOCAL
    freopen("demo.in","r",stdin);
    freopen("demo.out","w",stdout);
    #endif
}

#define N 1000005

void test_case(){
    vector<int> h(N);
    vector<int> adj[N];
    int n,m;
    cin>>n>>m;
    fors(i,n){
        cin>>h[i];
    }
    fors(i,m){
        int x,y;
        cin>>x>>y;
        x--;
        y--;
        adj[x].push_back(y);
        adj[y].push_back(x);
    }
    int res=0;
    for(int i=0;i<n;++i){
        int flag=1;
        for(auto x:adj[i]){
            if(h[x]>=h[i]){
                flag=0;
                break;
            }
        }
        res+=flag;
    }
    cout<<res;
}

int main(){
    fastio;
    file();
    // int T=1;
    // int T;
    // cin>>T;
    // for(int nr=1;nr<=T;++nr) {
        // cout<<"Case #"<<nr<<": ";
		test_case();
		return 0;
    // }
}

Measured memory_bytes: 33268
// AtCoderを信じる！！

#include <bits/stdc++.h>

using namespace std;

using int64 = long long;

int N, M;
vector< int > g[100000];
bool in[100000];
vector< int > ord;
bool used[100000];
int pos[100000];
int par[100000];

void dfs(int idx) {
  if(used[idx]) return;
  used[idx] = true;
  for(auto to : g[idx]) dfs(to);
  ord.emplace_back(idx);
}

void dfs2(int idx, int p) {
  if(used[idx]) return;
  used[idx] = true;
  par[idx] = p;
  vector< pair< int, int > > reach;
  for(auto to : g[idx]) {
    reach.emplace_back(pos[to], to);
  }
  sort(begin(reach), end(reach));
  for(auto q : reach) {
    dfs2(q.second, idx);
  }
}


int main() {

  cin >> N >> M;
  for(int i = 0; i < N + M - 1; i++) {
    int x, y;
    cin >> x >> y;
    --x, --y;
    g[x].emplace_back(y);
    in[y] = true;
  }

  int root = -1;
  for(int i = 0; i < N; i++) {
    if(!in[i]) root = i;
  }

  dfs(root);
  reverse(begin(ord), end(ord));
  for(int i = 0; i < N; i++) {
    pos[ord[i]] = i;
  }

  memset(used, false, sizeof(used));
  dfs2(root, -1);
  for(int i = 0; i < N; i++) cout << par[i] + 1 << endl;

}



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

using namespace std;

int main(){
	ios_base::sync_with_stdio (false);
	cout << fixed;
	cout.precision(10);
	if(fopen("joke.in", "r")){
		freopen ("joke.in","r",stdin);
		freopen ("joke.out","w",stdout);
	}

	int n;
	cin >> n;
	vector<vector<int>> h(n, vector<int>(3));
	for(int i = 0; i < n; ++i){
		for(int j = 0; j < 3; ++j){
			cin >> h[i][j];
		}
	}

	vector<vector<int>> dp(n, vector<int>(3, 2e9 + 7));
	dp[0][0] = h[0][0];
	dp[0][1] = h[0][1];
	dp[0][2] = h[0][2];

	for(int i = 1; i < n; ++i){
		dp[i][0] = max(dp[i - 1][1] + h[i][0], dp[i - 1][2] + h[i][0]);
		dp[i][1] = max(dp[i - 1][0] + h[i][1], dp[i - 1][2] + h[i][1]);
		dp[i][2] = max(dp[i - 1][0] + h[i][2], dp[i - 1][1] + h[i][2]);
	}

	cout << max({dp[n - 1][0], dp[n - 1][1], dp[n - 1][2]});
    return 0;
}

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

int main() {
    int N;
    cin >> N;
    string A[N];
    for (int i=0; i<N; i++) {
        cin >> A[i];
    }

    int m=0;
    for (int i=1; i<N; i++) {
        int siz = A[i-1].size(); 
        if (A[i-1].at(siz-1) == A[i].at(0)) {
        } else {
            cout << "No" << endl;
            m=1;
            break;
        }

        for (int j=0; j<i-1; j++) {
            if (A[j]==A[i]) {
                cout << "No" << endl;
                m=1;
                break;
            }
        }
        if (m==1) {
            break;
        }
    }
    if (m==0) {
        cout << "Yes" << endl;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
vector<int> vec(3);
cin>>vec.at(0)>>vec.at(1)>>vec.at(2);
  sort(vec.begin(),vec.end());
  if(vec.at(2)==vec.at(1)+vec.at(0)){
cout<<"Yes"<<endl;
  }
else {
cout<<"No"<<endl;
}
  return 0;
}


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

using Comment = tuple<string, vector<int>>;

void print(int depth, int idx, vector<Comment> const & v) {
  for (int i = 0; i < depth; ++i) {
    cout << '.';
  }
  cout << get<0>(v[idx]) << endl;
  for (int ch : get<1>(v[idx])) {
    print(depth + 1, ch, v);
  }
}

int main() {
  int N;
  cin >> N;
  vector<Comment> v;
  for (int i = 0; i < N; ++i) {
    int K;
    string S;
    cin >> K >> S;
    v.emplace_back(S, vector<int>());
    if (--K >= 0) {
      get<1>(v[K]).push_back(i);
    }
  }
  print(0, 0, v);
}

Measured memory_bytes: 3412
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
const long long MOD=1e9+7;

int main() {
    int k,a,b;
    cin>>k>>a>>b;
    int exist=0;
    for(int i=k;i<=b;i+=k)
        if(i>=a) exist++;
    if(exist>0) cout<<"OK"<<endl;
    else cout<<"NG"<<endl;
    return 0;
}


Measured memory_bytes: 3632
s=int(input())
import math
sq=math.ceil(math.sqrt(s))

big=sq**2
sma=big-s

for i in range(math.floor(math.sqrt(big)),big+1):
    if big%i==0:
        big1=i
        big2=big//i
        break

#print(big1,big2)


if sma!= 0:
    
    for i in range(math.floor(math.sqrt(sma)),0,-1):
        if sma%i==0:
            sma1=i
            sma2=sma//i
            break
else:
    sma1=0
    sma2=0
#print(sma1,sma2)

x1=big1
y1=sma1
x2=sma2
y2=big2
x3=0
y3=0

print(x1,y1,x2,y2,x3,y3)

Measured memory_bytes: 3064
#include <iostream>
using namespace std;
int main() {
	int l,a,b,c,d,e;
	cin>>l>>a>>b>>c>>d;
	if(a/c<b/d){
		e=b/d;
		if(b%d>0)
			e=e+1;
	}
	else{
		e=a/c;
		if(a%c>0)
			e=e+1;
	}
	cout<<l-e<<endl;
	return 0;
}

Measured memory_bytes: 1160
import java.util.*;
import static java.lang.Integer.*;
//import static java.lang.Long.*;
//import static java.lang.Math.*;
import static java.lang.System.*;

import java.io.PrintWriter;

public class Main {
	static int[] ans;
	static ArrayList<ArrayList<Integer>> ab;
	static HashMap<Integer, Integer> px = new HashMap<>(); 

	public static void main(String[] args) {
		int i,j;
		Scanner sc = new Scanner(in);
		int n = parseInt(sc.next());
		int q = parseInt(sc.next());
//		int[] a = new int[n];
//		int[] b = new int[n];
		ab = new ArrayList<ArrayList<Integer>>(n+1);
		for(i=0;i<=n;i++) {
			ab.add(new ArrayList<Integer>());
		}
		int a,b;
		for(i=0;i<n-1;i++) {
			a = parseInt(sc.next());
			b = parseInt(sc.next());
			ab.get(a).add(b);
		}
//		int[] p = new int[q];
//		int[] x = new int[q];
		int x,p;
		for(i=0;i<q;i++) {
			p = parseInt(sc.next());
			x = parseInt(sc.next());
			if(!px.containsKey(p)) {
				px.put(p, x);
			} else {
				px.put(p, px.get(p)+x);
			}
		}
		sc.close();
		ans = new int[n];
//		for(Integer ii : px.keySet()) {
			add(1, 0);
//		}
		PrintWriter pw = new PrintWriter(out);
		for(i = 0; i < n; i++) {
			pw.print(ans[i]);
			pw.print(" ");
		}
		pw.flush();
	}
	static void add(int p, int x) {
		if(px.containsKey(p)) {
			x += px.get(p);
		}
		ans[p-1] += x;
		for(Integer i : ab.get(p)) {
			add(i, x);
		}
	}
}


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

#define MOD 1000000007

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

  cout << (n == m ? "Yes" : "No") << endl;
}


Measured memory_bytes: 256
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.io.PrintStream;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;
import java.io.BufferedReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author Eric
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        FastReader in = new FastReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        CStep solver = new CStep();
        solver.solve(1, in, out);
        out.close();
    }

    static class CStep {
        public void solve(int testNumber, FastReader in, PrintWriter out) {
            long res = 0;
            int n = in.nextInt();
            long[] a = in.nextArrLong(n);
            long last = 0;
            for (int i = 0; i < n; i++) {
                if (a[i] < last) {
                    res += last - a[i];
                } else {
                    last = a[i];
                }
            }
            out.print(res);
            //out.print("Case #"+ testNumber + ": ");
        }

    }

    static class FastReader {
        public BufferedReader br;
        public StringTokenizer st;
        String context = null;

        public FastReader(InputStream in) {
            this(new InputStreamReader(in));
        }

        public FastReader(InputStreamReader input) {
            br = new BufferedReader(input);
        }

        public String next() {
            if (context != null) {
                System.err.print("[" + context + "] Wait for input ...");
            }
            while (st == null || !st.hasMoreElements()) {
                try {
                    String s = br.readLine();
                    if (s == null)
                        return null;
                    st = new StringTokenizer(s);
                } catch (IOException e) {
                    e.printStackTrace();
                    throw new RuntimeException("Could not read");
                }
            }
            String res = st.nextToken();
            if (context != null) {
                System.err.println("[" + context + "] ... received : " + res);
            }
            return res;
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

        public long nextLong() {
            return Long.parseLong(next());
        }

        public long[] nextArrLong(int n) {
            long[] a = new long[n];
            for (int i = 0; i < a.length; i++)
                a[i] = nextLong();
            return a;
        }

    }
}



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

// 小数点以下桁数
// fixed << setprecision(i)

int gcd(int a,int b){return (a%b==0?b:gcd(b, a%b));}
int lcm(int a,int b){return a*b/gcd(a, b);}

int main()
{
  int n, k, q, a;
  vector<int> p(100000, 0);

  cin >> n >> k >> q;
  for (int i = 0; i < q; i++)
  {
    cin >> a;
    p[a - 1]++;
  }
  for (int i = 0; i < n; i++)
      cout << (k <= q - p[i] ? "No" : "Yes") << endl;
}

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

bool compare_by_first(pair<int, int> a, pair<int, int> b){
    if (a.first != b.first){
        return a.first < b.first;
    }else{
        return a.second < b.second;
    }
}

int main()
{
    ios::sync_with_stdio(false);
    int N, p = 1000000000;
    cin >> N;
    vector<pair<int, int> > LR;
    REP(i, N){
        int l, r;
        cin >> l >> r;
        LR.push_back(make_pair(l,r));
    }
    int L = LR.size();
    sort(LR.begin(), LR.end(), compare_by_first);
    // REP(i, L) cout << LR[i].first << ' ' <<LR[i].second << endl;
    int R1[110000], L1[110000],R2[110000],L2[110000];
    REP(i,N) {
        R1[i]=R2[i]=0;
        L1[i]=L2[i]=p;
    }
    L1[0] = LR[0].first;
    R1[0] = LR[0].second;
    L2[N-1] = LR[N-1].first;
    R2[N-1] = LR[N-1].second;
    for (int i=1; i<N; ++i){
        L1[i] = max(L1[i-1], LR[i].first);
        R1[i] = min(R1[i-1], LR[i].second);
        R2[N-1-i] = min(R2[N-i], LR[N-1-i].second);
        L2[N-1-i] = max(L2[N-i], LR[N-1-i].first);
    }
    // REP(i,N) cout << L1[i] << ' ' <<  R1[i] << ' ' << L2[i] << ' '<< R2[i] << endl; 
    int cur = 0, ans = 0;
    REP(i,N-1){
        cur = max(0, R1[i] - L1[i] + 1) + max(0, R2[i+1] - L2[i+1] + 1);
        if (ans < cur) ans = cur;
    }
    cur = LR[0].second - LR[0].first + 1 + max(0, R2[1]-L2[1]+1);
    if (ans < cur) ans = cur;
    cur = LR[N-1].second - LR[N-1].first + 1 + max(0, R1[N-2]-L1[N-2]+1);
    if (ans < cur) ans = cur;
    for(int i = 1; i < N-1; ++i){
        int r = min(R1[i-1], R2[i+1]);
        int l = max(L1[i-1], L2[i+1]);
        cur = LR[i].second - LR[i].first + 1 + max(0, r-l+1);
        if (ans < cur) ans = cur;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 2804
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
 
#define int long long
#define endl "\n"
#define deb(x) cout << #x << " -> " << x << endl;
#define print(x)                         \
    for (auto x_ : x) cout << x_ << " "; \
    cout << endl;
#define pb push_back
#define all(x) x.begin(), x.end()
#define mod 1000000007  // 1e9 + 7
#define prec(x, y) fixed << setprecision(y) << x
 
void solve() {
    int n;
    cin >> n;
    int sum = 0;
    int prefix[n] = {};
    int a[n];
    for (auto &x : a) cin >> x, sum += x;
    prefix[0] = a[0];
    for (int i = 1; i < n; ++i) prefix[i] = ((prefix[i - 1] + a[i]) % mod);
    int res = 0;
    for (int i = 0; i < n; ++i) {
        int t = (a[i] * (prefix[n - 1] - prefix[i])) % mod;
        res = (t + res) % mod;
    }
    res = (res + mod)%mod;
    cout << (res % mod) << endl;
}
 
int32_t main() {
    ios::sync_with_stdio(0);
    cout.tie(0);
    cin.tie(0);
 
    int tc = 1;
    // cin >> tc;
    while (tc--) {
        solve();
    }
}

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

using namespace std;


typedef long long ll;
ll mod=1e9+0LL;
ll MOD=1e18+0LL;
ll md=1000000007;

const double PI=acos(-1);

typedef vector<int> vi;
typedef pair<int,int> pii;

#define     sz(v)       ((int)((v).size()))
#define     all(v)      ((v).begin()),((v).end())
#define     pb           push_back
#define     ff           first
#define     ss           second
#define     line         printf("\n")
#define     gap          ' '
#define     ctn          continue;
ll poW(ll a ,ll n)
{
    if(n==0) return 1;
    if(n%2==0)
    {
        ll b=poW(a,n/2);
        return (b*b)%md;
    }
    return (poW(a,n-1)*a)%md;
}
bool cmp(const pii &a,const pii &b)     { return (a.ff*b.ss) < (a.ss*b.ff);}
bool isOdd(int n)       { return (n%2)!=0; }
template <class T>
void printVector(vector <T> &v,string s="")
{
    cout<<s;
    for(int i=0;i<sz(v);i++)
    {
        cout<<v[i]<<gap;
    }
    line;
}

int toInt(string str) {
	int num;
	istringstream iss(str);
	iss>>num; return num;
}

template <class T> string toStr(T par) {
	ostringstream oss;
	oss<<par;
	return oss.str();
}

void sieve(vector<int>&v)
{
    int i,j;
    v.pb(1);
    bool visit[1002];
    memset(visit,0,sizeof(visit));
    for(i=2;i<=1001;i++)
    {
        if(!visit[i])
        {
            for(j=i*i;j<=1001;j+=i)
            {
                visit[j]=1;
            }
            v.pb(i);
            //cout<<i<<gap<<v.back();line;
        }
    }
}
bool isPrime(int x) {
	if (x < 2) return false;
	for (int y = 2; y * y <= x; y++)
		if (x % y == 0)
			return false;
	return true;
}


int main()
{
    int cs=1;
    //scanf("%d",&cs);
    while(cs--)
    {
        int a;
        cin>>a;
        cout<<a*(1+a+(a*a));
    }
}


Measured memory_bytes: 3624
#include<bits/stdc++.h>
typedef long long ll;
using namespace std;
typedef vector<ll>vi;
typedef pair<ll,ll>pi;
#define pb push_back
#define mp make_pair
#define all(v) v.begin(),v.end()
#define ff first
#define ss second
//#define pi 3.1415926535897932384626433832795028841
ll max(ll a,ll b){return (a>b?a:b);}
ll min(ll a,ll b){return (a<b?a:b);}
ll gcd(ll a,ll b)
{return (b?gcd(b,a%b):a);
}

void algo()
{
    ll a,b,h,m;
    cin>>a>>b>>h>>m;
    double r=11.0/2*m-30*h;
    //cout<<r<<" ";
    //cout<<cos(r*acos(-1)/180.0)<<" ";
    double ans=a*a+b*b-2*a*b*cos(r*acos(-1)/180.0);
    cout<<sqrt(ans);
}
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout<<setprecision(20);
    ll t=1;//cin>>t;
    while(t--)
    {
        algo();
	cout<<endl;
    }
    return 0;
}


Measured memory_bytes: 4144
import java.util.*;
import java.math.BigInteger;
 
public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    //与えられた整数N
    long n = sc.nextLong();
    
    long a = 0;
    long b = 0;
    for (long i = 1; i * i <= n; i++) {
      if (n % i == 0) {
        a = i;
        b = n / i;
      }
    }
    System.out.println(a + b - 2);
  }
}

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

int main() {
  int n;

  const int INF = 1e9;
  const int N_MAX = 1e6;

  vector<int> dp(N_MAX, INF), dpo(N_MAX, INF);
  dp[0] = 0;
  dpo[0] = 0;

  for (int i = 1, t = 1; t < N_MAX; ++i, t = i * (i + 1) * (i + 2) / 6) {
    for (int j = 0; j < (int)(N_MAX); ++j) {
      int nj = j + t;
      if (nj < N_MAX) chmin(dp[nj], dp[j] + 1);
      if (nj < N_MAX && t % 2 == 1) chmin(dpo[nj], dpo[j] + 1);
    }
  }

  while (true) {
    cin >> n;
    if (n == 0) return 0;
    cout << dp[n] << " " << dpo[n] << endl;
  }
}



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

#define ALL(a)  (a).begin(),(a).end()
#define ALLR(a)  (a).rbegin(),(a).rend()
#define spa << " " <<
#define test cout<<"test"<<endl;
#define fi first
#define se second
#define rep(i,n,m) for(ll i = n; i < (ll)(m); i++)
#define rrep(i,n,m) for(ll i = n - 1; i >= (ll)(m); i--)
typedef long long ll;
typedef long double ld;
const ll MOD = 1e9+7;
//const ll MOD = 998244353;
const ll INF = 1e18;
using P = pair<ll, ll>;
template<typename T>
void chmin(T &a,T b){if(a>b)a=b;}
template<typename T>
void chmax(T &a,T b){if(a<b)a=b;}
void pmod(ll &a,ll b){a=(a+b)%MOD;}
void pmod(ll &a,ll b,ll c){a=(b+c)%MOD;}
void qmod(ll &a,ll b){a=(a*b)%MOD;}
void qmod(ll &a,ll b,ll c){a=(b*c)%MOD;}
ll median(ll a,ll b, ll c){return a+b+c-max({a,b,c})-min({a,b,c});}
void ans1(bool x){if(x) cout<<"Yes"<<endl;else cout<<"No"<<endl;}
void ans2(bool x){if(x) cout<<"YES"<<endl;else cout<<"NO"<<endl;}
void ans3(bool x){if(x) cout<<"Yay!"<<endl;else cout<<":("<<endl;}
template<typename T1,typename T2>
void ans(bool x,T1 y,T2 z){if(x)cout<<y<<endl;else cout<<z<<endl;}  
void debug(vector<vector<ll>>v,ll h,ll w){for(ll i=0;i<h;i++)
{cout<<v[i][0];for(ll j=1;j<w;j++)cout spa v[i][j];cout<<endl;}};
void debug(vector<string>v,ll h,ll w){for(ll i=0;i<h;i++)
{for(ll j=0;j<w;j++)cout<<v[i][j];cout<<endl;}};
void debug(vector<ll>v,ll n){cout<<v[0];
for(ll i=1;i<n;i++)cout spa v[i];cout<<endl;};
vector<vector<ll>>vec(ll x, ll y, ll w){
  vector<vector<ll>>v(x,vector<ll>(y,w));return v;}
ll gcd(ll x,ll y){ll r;while((r=x%y)!=0){x=y;y=r;}return y;}
//m.emplace(x,0).fi->se++;

int main(){
  cin.tie(NULL);
  ios_base::sync_with_stdio(false);
  ll res=0,res1=INF,res2=-INF,buf=0;
  bool judge = true;
  ll k,x;cin>>k>>x;
  vector<ll>ret;
  rep(i,-1000000,1000001){
    if(abs(i-x)<=k-1)ret.push_back(i);
  }
  debug(ret,ret.size());
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>

int main()
{
  long long int i,j,k;
  long long int x,y;
  long long int seki;
  
  scanf("%lld %lld",&x,&y);
  if(x<y){
    i = x;
    x = y;
    y = i;
  }
  
  seki = x*y;

  i = 0;
  i = x%y;
  while( i != 0 ){
    x = y;
    y = i;
    i = x%y;
  }
  
  printf("%lld\n",seki/y);
  
  return 0;
}

Measured memory_bytes: 128
#include<iostream>
using namespace std;
#define inf 0x3f3f3f3f
int main()
{
    int n,T;
    ios::sync_with_stdio(false);
    bool flag;
    int c,t;
    int ans;
    while(cin>>n>>T)
    {
        ans=inf;
        flag=false;
        for(int i=1;i<=n;i++)
        {
            cin>>c>>t;
            if(t<=T) 
            {
                flag=true;
                ans=min(ans,c);
            }
        }
        if(flag) cout<<ans<<endl;
        else cout<<"TLE"<<endl;
    }
}

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

vector<ll> lunlun;

int digit(ll x) {
  int res = 0;
  while (x) {
    x /= 10;
    ++res;
  }
  return res;
}

void rec(int d, ll lun) {
  if (digit(lun) == d) {
    lunlun.push_back(lun);
    return;
  }
  int lst = lun % 10;
  if (lst > 0) rec(d, 10*lun + lst-1);
  rec(d, 10*lun + lst);
  if (lst < 9) rec(d, 10*lun + lst+1);
  return;
}

int main() {
  int k;
  cin >> k;
  int d = 1;
  while (lunlun.size() < k) {
    for (ll lun = 1; lun <= 9; ++lun) rec(d, lun);
    ++d;
  }
  cout << lunlun[k-1] << endl;
  return 0;
}

Measured memory_bytes: 5356
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    scanf("%d",&n);
    int i;
    int s=n;
    for(i=0; s>0; i++)
    {
        s/=10;
    }
    if(i%2==0)
    {
        if(i==2)printf("9");
        else if(i==4)printf("909");
        else if(i==6)printf("90909");
    }
    else
    {
        if(i==1)printf("%d",n);
        else if(i==3)printf("%d",909-999+n);
        else if(i==5)printf("%d",90909+-99999+n);
    }
    return 0;
}



Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
int main()
{
		int a,b;
		 scanf("%d %d", &a,&b);
		if((a>0 && a<10) && (b>0 && b<10)){
						printf("%d\n", a*b);
		}else{
				printf("-1\n");
		}
		}

Measured memory_bytes: 128
import sys
import numpy as np
input = lambda: sys.stdin.readline().rstrip()

def main():
    h, w, k = map(int, input().split())
    c = []
    ans = 0
    for _ in range(h):
        c.append(list(input()))
    grid = np.array(c)
    for i in range(2**(w+h)):
        tmp = grid.copy()
        row, col = [], []
        for j in range(w+h):
            if (i >> j) & 1:
                if j < w:
                    col.append(j)
                else:
                    row.append(j-w)
        tmp = np.delete(tmp, row, 0)
        tmp = np.delete(tmp, col, 1)
        if np.sum(tmp == '#') == k:
            ans += 1
    print(ans)
    
if __name__ == '__main__':
    main()

Measured memory_bytes: 27236
#include<bits/stdc++.h>
using namespace std;
#define mod 1000000007
// #define ll long long
#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
long long  mx(long long n,long long  k)
{
	long long  ans1=(n*(n-1))/2;
	long long   ans2=((n-k)*(n-k-1))/2;
	return (ans1-ans2);
}
	 
int main()
{
	fastio;
	long long n,k;
	cin>>n>>k;
	n+=1;
	long long sum=0;
	for(long long i=k;i<=n;i++)
	{
		sum=(sum+mx(n,i)-((i*(i-1))/2)+1)%mod;
	}
	cout<<sum<<endl;	
	
	
	return 0;
	
	
}

Measured memory_bytes: 3676
#include<stdio.h>
int main()
{
    int height,temp1=0,temp2,temp3,i;
    for(i=0;i<10;i++)
    {
        scanf("%d",&height);
        if(height>temp1)
        {
            temp3=temp2;
            temp2=temp1;
            temp1=height;
        }
        else if(height>temp2)
        {
            temp3=temp2;
            temp2=height;
        }
        else if(height>temp3)
        {
            temp3=height;
        }

    }
    printf("%d\n%d\n%d\n",temp1,temp2,temp3);
    return 0;
}

Measured memory_bytes: 600
import sys
from collections import deque
import bisect
import copy
import heapq
import itertools
import math
input = sys.stdin.readline
sys.setrecursionlimit(1000000)
mod = 10 ** 9 + 7

def read_values(): return map(int, input().split())
def read_index(): return map(lambda x: int(x) - 1, input().split())
def read_list(): return list(read_values())
def read_lists(N): return [read_list() for n in range(N)]


class BIT:
    def __init__(self, N):
        self.N = N
        self.T = [0] * (N + 1)

    def add(self, i, x):
        i += 1
        while i <= self.N:
            self.T[i] += x
            i += i & -i

    def _sum(self, i):
        s = 0
        i += 1
        while i > 0:
            s += self.T[i]
            i -= i & -i
        return s

    def sum(self, i, j):
        si = self._sum(i - 1)
        sj = self._sum(j)
        return sj - si
    

def main():
    N, M = read_values()
    C = read_list()
    Q = []
    for i in range(M):
        l, r = read_index()
        Q.append((l, r, i))
    Q.sort(key=lambda a: a[1])

    ans = [0] * M
    T = [-1] * M
    bit = BIT(N)
    q = 0
    # print(Q)
    for i in range(N):
        c = C[i] - 1
        t = T[c]
        if t != -1:
            bit.add(t, -1)
        T[c] = i
        bit.add(i, 1)

        # print(i, T, bit.T)
        while q < len(Q) and i == Q[q][1]:
            l, r, k = Q[q]
            ans[k] = bit.sum(l, r)
            q += 1

    print("\n".join(map(str, ans))) 

  
if __name__ == "__main__":
    main()


Measured memory_bytes: 221556
import math
s = list(input())
n = len(s)
s1 = s[ : (n-1) // 2]
s2 = s[(n+3) // 2 - 1 : n]
flag = 1

for i in range(len(s) // 2):
    if s[i] != s[- i - 1]:
        flag = 0

for i in range(len(s1) // 2):
    if s1[i] != s1[- i - 1]:
        flag = 0

for i in range(len(s2) // 2):
    if s2[i] != s2[- i - 1]:
        flag = 0

print('Yes' if flag == 1  else 'No')


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

void solve(std::string S)
{
    int cnt = 0;
    char hoge[4] = {'A', 'T', 'G', 'C'};
    int ans = 0;
    for (int i = 0; i < S.length(); ++i)
    {
        int bobo = 0;
        for (int q = 0; q < 4; ++q)
        {
            if (S[i] == hoge[q])
                bobo = 1;
        }
        if (bobo == 0)
        {
            cnt = 0;
        }
        else
        {
            cnt++;
            ans = max(ans, cnt);
        }
    }
    cout << ans << endl;
    return;
}

// Generated by 1.1.3 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main()
{
    std::string S;
    std::cin >> S;
    solve(S);
    return 0;
}


Measured memory_bytes: 256
n = gets.to_i
numbers = gets.split(" ").map(&:to_i)
cumulative_zeros = []
n.times do
  cumulative_zeros.push(0)
end
answers = []
count = 0
changed = true
while cumulative_zeros.length > count && changed == true do
  numbers.each_with_index.reverse_each do |number, index|
    changed = false
    # puts numbers
    # puts ""
    if number <= cumulative_zeros[index] && number != 0
      puts "-1"
      exit
    elsif number - 1 == cumulative_zeros[index]
      answers.push(number)
      numbers[index] = 0
      if index < cumulative_zeros.length - 1
        cumulative_zeros[index + 1..cumulative_zeros.length - 1].each_with_index do |zero, index2|
          cumulative_zeros[index2 + index + 1] += 1
        end
      end
      count += 1
      changed = true
      # puts "cumulative#{cumulative_zeros}"
      # puts ""
      break
    end
  end
end

if answers.length == cumulative_zeros.length
  puts answers
else
  puts "-1"
end

Measured memory_bytes: 1916
const SieveOfEratosthenes = (n) => {
    let flg = (new Array(n)).fill(0)/* set flg[i] to true when it is seived */
    let primes = []/* list of prime numbers */
    for(let i=2; i*i<=n; i++) {
        if(!flg[i]) {
            primes.push(i)
            for(let j=i; j*j<=n; j+=i) {
                flg[j] = 1
            }
        }
    }
    return primes
}

const factorizationBySoE = (n, primes) => {
    //const primes = SieveOfEratosthenes(n)
    let factors = {}
    primes.some(p => {
        if(n < p) return true
        while(n%p===0) {
            if(!factors[p])factors[p]=1
            else factors[p]++
            n/=p
        }
    })
    if(n>1)factors[n]=1
    return factors
}


const getGCD = (a,b) => {
    if(b===0)return a
    else if(a===0)return b
    return getGCD(b, a%b)
}

const main = (arg) => {
    const N = Number(arg.split("\n")[0])
    const a = arg.split("\n")[1].split(" ").map(Number)
    
    const MAX_A = 10**6+1
  //  const A = Math.max(...a)
    
    //  check if p is in {a} (paircoprime)
    //const primes = SieveOfEratosthenes(A)
//    return
    let set = [...new Array(MAX_A)].fill(0)
    isPairCoprime = true
  /*
    for(let i=0; i<N; i++) {
        const factors = Object.keys(factorizationBySoE(a[i], primes))
        for(let j=0; j<factors.length; j++ ) {
            // console.log(`i=${i}, j=${j}, ${factors[j]}`)
            // console.log(factors)
            if(set[factors[j]] === 1) {
                isPairCoprime = false
            }
            set[factors[j]] = 1
        }
    }
*/
//  return
    for(let i=0; i<N; i++) {
        set[a[i]]++
    }
//  return
    for(let i=2; i<MAX_A; i++) {
         let cnt=0
         for(let j=i; j<MAX_A; j+=i) {
             cnt+=set[j]
         }
        if(cnt>1) {
             isPairCoprime = false
         }
     }
    
    if(isPairCoprime) {
        console.log("pairwise coprime")
        return
    }
     // return
    // setcoprime
    // let gcd = getGCD(a[0], a[1])
    let gcd = 0
    for(let i=0; i<a.length; i++) {
        gcd = getGCD(gcd, a[i])
        // console.log(gcd)
    }
    
    if(gcd===1) {
        console.log("setwise coprime")
        return
    }
    
    console.log("not coprime")
}

main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 109708
#include <queue>
#include <cstdio>
#include <iostream>
#include <math.h>
#include <set>
#include <map>
#include <string>
#include <vector>
#include <sstream>
#include <algorithm>
#include <iomanip>
#include <stack>
using namespace std;
typedef long long int ll;

#define EPS (1e-9)
#define INF (1e9)
#define PI (acos(-1))
#define REP(i,n) for(int i=0;i<n;i++)
const int MOD = 1000000007;

int gcd(int a, int b) {
	if (a < b) swap(a, b);
	if (b == 0) return a;
	return gcd(b, a % b);
}


ll beki(ll a, ll b) {
	ll tmp = 1;
	REP(i, b) tmp *= a;
	return tmp;
}

int N;
int x[100010];

int main() {
	cin >> N;
	REP(i, N + 1) cin >> x[i];
	sort(x, x + N + 1);
	int ans = x[1] - x[0];
	REP(i, N - 1) {
		ans = gcd(ans, x[i + 2] - x[i + 1]);
	}
	cout << ans << endl;
}

Measured memory_bytes: 640
#include<stdio.h>
#include<iostream>
using namespace std;
int main(){
	int a = 0, b = 0;
	int v;
	int i = 0;
	while (scanf("%d %d",&a,&b)!= EOF){
		int c = a + b;
		if (a + b < 10){
			cout << "1" << endl;
		}
		else if (a + b < 100){
			cout << "2" << endl;
		}
		else if (a + b < 1000){
			cout << "3" << endl;
		}
		else if (a + b < 10000){
			cout << "4" << endl;
		}
		else if (a + b < 100000){
			cout << "5" << endl;
		}
		else if (a + b < 1000000){
			cout << "6" << endl;
		}
		else{
			cout << "7" << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 3184