akhauriyash/Code-Regression huggingface dataset:
//use itertools::Itertools;
use std::cmp;
use std::collections::BTreeMap;
use std::collections::BTreeSet;
use std::collections::BinaryHeap;
use std::collections::HashMap;
use std::collections::HashSet;
use std::collections::VecDeque;
use std::io::Read;
use std::usize::MAX;

macro_rules! input {(source = $s:expr, $($r:tt)*) => {let mut iter = $s.split_whitespace();let mut next = || { iter.next().unwrap() };input_inner!{next, $($r)*}};($($r:tt)*) => {let stdin = std::io::stdin();let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));let mut next = move || -> String{bytes.by_ref().map(|r|r.unwrap() as char).skip_while(|c|c.is_whitespace()).take_while(|c|!c.is_whitespace()).collect()};input_inner!{next, $($r)*}};}
macro_rules! input_inner {($next:expr) => {};($next:expr, ) => {};($next:expr, $var:ident : $t:tt $($r:tt)*) => {let $var = read_value!($next, $t);input_inner!{$next $($r)*}};}
macro_rules! read_value {($next:expr, ( $($t:tt),* )) => {( $(read_value!($next, $t)),* )};($next:expr, [ $t:tt ; $len:expr ]) => {(0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()};($next:expr, chars) => {read_value!($next, String).chars().collect::<Vec<char>>()};($next:expr, usize1) => {read_value!($next, usize) - 1};($next:expr, [ $t:tt ]) => {{let len = read_value!($next, usize);(0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()}};($next:expr, $t:ty) => {$next().parse::<$t>().expect("Parse error")};}

fn solve() {
    input! {
        n: usize,
        a: [usize;n]
    }

    let mut ans = 0;
    for i in 0..n {
        let m = i + 1;
        if m % 2 == 1 && a[i] % 2 == 1 {
            ans += 1;
        }
    }

    println!("{}", ans);
}

fn main() {
    let thd = std::thread::Builder::new().stack_size(104_857_600);
    thd.spawn(|| solve()).unwrap().join().unwrap();

    /*
    // 入力を一括で読み込む場合
    let mut buf = String::new();
    std::io::stdin().read_to_string(&mut buf).unwrap();
    let mut input = buf.split_whitespace();

    // inputに対しnext()で読み込んでいく
    let q: usize = input.next().unwrap().parse().unwrap();
    */
}

const LARGE_PRIME: u64 = 1_000_000_007;

// @〜でsnippet


Measured memory_bytes: 2204
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LINF = 1e18;
inline ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
inline ll lcm(ll a, ll b) { return a / gcd(a, b)*b; }
template<class S,class T> ostream& operator << (ostream& out,const pair<S,T>& o){ out << "(" << o.first << "," << o.second << ")"; return out; }
template<class T> ostream& operator << (ostream& out,const vector<T> V){ for(int i = 0; i < V.size(); i++){ out << V[i]; if(i!=V.size()-1) out << " ";} return out; }
template<class T> ostream& operator << (ostream& out,const vector<vector<T> > Mat){ for(int i = 0; i < Mat.size(); i++) { if(i != 0) out << endl; out << Mat[i];} return out; }
template<class S,class T> ostream& operator << (ostream& out,const map<S,T> mp){ out << "{ "; for(auto it = mp.begin(); it != mp.end(); it++){ out << it->first << ":" << it->second; if(mp.size()-1 != distance(mp.begin(),it)) out << ", "; } out << " }"; return out; }

/*
 <url:>
 問題文============================================================
 =================================================================
 解説=============================================================
 ================================================================
 */
int main(void) {
    cin.tie(0); ios_base::sync_with_stdio(false);
    int A,B; cin >> A >> B;
    string S; cin >> S;
    if(count(S.begin(),S.end(),'-') != 1) {
        cout << "No" << endl;
        return 0;
    }
    if(S[A] == '-'){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    return 0;
}


Measured memory_bytes: 256
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))
score = 0
order = -1
for i in range(n):
	score += b[i]
	_order = a[i]
	if order+1 == _order:
		score += c[order - 1]
	order = _order
print(score)

Measured memory_bytes: 3064
n,*a=list(map(int,open(0).read().split()))
b,c=max(a),min(a)
if b-c==1:
    d,e=a.count(b),a.count(c)
    if e<b and 2*(b-e)<=d:print("Yes")
    else:print("No")
elif b-c==0:
    if a[0]==n-1 or a[0]*2<=n:print("Yes")
    else:print("No")
else:print("No")

Measured memory_bytes: 13940
N,M,X = map(int,input().split())
book = [0] * N
total = [0] * M
point = [[] for i in range(N)]
ans = 10 ** 9

for i in range(N):
  a = list(map(int,input().split()))
  book[i] = a[0]
  point[i] = a[1:]
  for j in range(M):
    total[j] += point[i][j]

if any([i < X for i in total]):
  print(-1)
else:
  for i in range(2 ** N):
    pattern = [0] * M
    cost = 0
    for j in range(N):
      if (i >> j) & 1:
        pattern = [pattern[t] + point[j][t] for t in range(M)]
        cost += book[j]
    if all([i >= X for i in pattern]):
      ans = min(ans,cost)
  print(ans)

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

#define F first
#define S second

using namespace std;

typedef long long LL;
typedef pair<int, int> PII;

const int N = 2010, M = 1010;

int n, m;
int r[N][N], c[N][N];
char g[N][N];

void solve()
{
	scanf("%d%d", &n, &m);
	for (int i = 1; i <= n; i ++ )
		scanf("%s", g[i] + 1);

	for (int i = 1; i <= n; i ++ )
		for (int j = 1; j <= m; j ++ )
		{
			int k = j, cnt = 0;
			while (k <= m && g[i][k] == '.') cnt ++ , k ++ ;
			r[i][j] += cnt, r[i][k] -= cnt;
			j = k;
		}
	for (int i = 1; i <= m; i ++ )
		for (int j = 1; j <= n; j ++ )
		{
			int k = j, cnt = 0;
			while (k <= n && g[k][i] == '.') cnt ++ , k ++ ;
			c[j][i] += cnt, c[k][i] -= cnt;
			j = k;
		}

	for (int i = 1; i <= n; i ++ )
		for (int j = 1; j <= m; j ++ )
		{
			r[i][j] += r[i][j - 1];
			c[i][j] += c[i - 1][j];
		}

	int res = 0;
	for (int i = 1; i <= n; i ++ )
		for (int j = 1; j <= m; j ++ )
			res = max(res, r[i][j] + c[i][j] - 1);
	printf("%d\n", res);
}

int main()
{
	int T = 1;
	// scanf("%d", &T);
	// cin >> T;
	while (T -- ) solve();
	return 0;
}

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

int main(){
  string s, t;
  cin >> s >> t;
  sort(s.begin(), s.end());
  sort(t.rbegin(), t.rend());
  if(s < t){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
  return 0;
}

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

int main() {
  int A,B,C,K;cin>>A>>B>>C>>K;
  if(A>=K) cout<<K<<endl;
  else if(A+B>=K) cout<<A<<endl;
  else cout<<A+(K-A-B)*(-1)<<endl;
}

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

namespace CP
{
    class Atria
    {
        static void Main(string[] args)
        {
            int n = int.Parse(ReadLine());
            long[] s = ReadLine().Split(' ').Select(long.Parse).ToArray();

            long sum = s.Sum();
            long ans = long.MaxValue;
            long now = 0;
            for (int i = 0; i < n; i++)
            {
                now += s[i];
                if (now >= sum - now)
                {
                    ans = now - (sum - now);
                    break;
                }
            }
            long now2 = 0;
            for (int i = n - 1; i >= 0; i--)
            {
                now2+= s[i];
                if (now2 >= sum - now2)
                {
                    ans = Min(ans, now2 - (sum - now2));
                }
            }
            WriteLine(ans);
        }
    }
}


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

signed main(void)
{
	int n, ans;
	cin >> n;
	ans = 0;
	rep(i, n)
	{
		int a;
		cin >> a;
		ans += a - 1;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
class UNION_FIND(object):
    def __init__(self,n):
        #親の番号を格納する。親だった場合は-(その集合のサイズ)
        #作るときはParentの値を全て-1にする
        #こうすると全てバラバラになる
        self.parent=[-1 for i in range(n)]
        
    def root(self,x):
        #Aがどのグループに属しているか調べる
        if self.parent[x]<0:
            return x
        else:
            self.parent[x]=self.root(self.parent[x])  #親を再帰で探知 再帰は最後に上のifにひっかかる
            return self.parent[x]
 
    def size(self,x):
        #自分のいるグループの頂点数を調べる
        return -self.parent[self.root(x)]   #親をとってきたい
        
    def union(self,x,y):
        #AとBをくっ付ける
        #AとBを直接つなぐのではなく、root(A)にroot(B)をくっつける
        #print(self.parent)
        x=self.root(x)
        y=self.root(y)
        #print(x,y)
        if x==y:   #すでにくっついてるからくっ付けない
            return False
            
        #大きい方(A)に小さいほう(B)をくっ付けたい
        #大小が逆だったらひっくり返しちゃう。
        if self.size(x)<self.size(y):
            x,y=y,x
        self.parent[x]+=self.parent[y]  #Aのサイズを更新する
        self.parent[y]=x   #Bの親をAに変更する
        return True


a,b=map(int,input().split())
*p,=map(int,input().split())
u=UNION_FIND(a)

for i in range(b):
    x,y=map(int,input().split())
    u.union(x-1,y-1)
ans=0
for i in range(a):
    ans+=(u.root(i)==u.root(p[i]-1))
print(ans)


Measured memory_bytes: 13812
# -*- coding: utf-8 -*-
n,k = map(int, input().split())
a = [int(x) for x in input().split()]

acc_a = []
acc_b = []
acc_a.append(0)
acc_b.append(0)

for i in range(n):
    acc_a.append(a[i]+acc_a[-1])
    acc_b.append(max(0,a[i]) + acc_b[-1])

ans = 0
for i in range(n-k+1):
    t = acc_a[i+k] - acc_a[i]
    t += acc_b[i] - acc_b[0]
    t += acc_b[n] - acc_b[i+k]
    ans = max(ans,t)

    t = 0
    t += acc_b[i] - acc_b[0]
    t += acc_b[n] - acc_b[i+k]
    ans = max(ans,t)
print(ans)


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

using namespace std;

using ll = long long;

ll solve(const vector<string>& s, ll& hoge) {
    int H = s.size();
    int W = s.front().size();
    vector< vector<int> > sum(H + W - 1, vector<int>(H + 1, 0));
    for (int i = 0; i < H; i++) {
        for (int j = 0; j < W; j++) {
            sum[i + j][i + 1] = (s[i][j] == '#');
        }
    }

    for (int i = 0; i < H + W - 1; i++) {
        for (int j = 1; j <= H; j++) {
            sum[i][j] += sum[i][j - 1];
        }
    }

    ll res = 0;
    for (int i = 0; i <= H + W - 2; i++) {
        for (int j = 0; j < H; j++) {
            int y1 = j;
            int x1 = i - j;
            if (x1 < 0) break;
            if (x1 >= W) continue;
            if (s[y1][x1] == '.') continue;
            for (int k = j + 1; k < H; k++) {
                int y2 = k;
                int x2 = i - k;
                if (x2 < 0) break;
                if (x2 >= W) continue;
                if (s[y2][x2] == '.') continue;
                int d = abs(y1 - y2) + abs(x1 - x2);
                if (d > i) continue;
                int tmp = sum[i - d][min(i - d, y1) + 1] - sum[i - d][max(i - d - x2, 0)];
                //cout << y1 << " " << x1 << ", " << y2 << " " << x2 << ": " << tmp << endl;
                res += tmp;

                if (x1 >= d) {
                    int y3 = y1, x3 = x1 - d;
                    //int d2 = abs(y2 - y3) + abs(x2 - x3);
                    if (s[y3][x3] == '#') {
                        hoge++;
                    }
                }

                if (y2 >= d) {
                    int y3 = y2 - d, x3 = x2;
                    if (s[y3][x3] == '#') {
                        hoge++;
                    }
                }
            }
        }
    }
    return res;
}

void rot(vector<string>& s) {
    int H = s.size();
    int W = s.front().size();
    vector<string> t(W, string(H, '.'));
    for (int i = 0; i < H; i++) {
        for (int j = 0; j < W; j++) {
            t[W-j-1][i] = s[i][j];
        }
    }
    s = move(t);
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int H, W;
    cin >> H >> W;
    vector<string> s(H);
    for (int i = 0; i < H; i++) {
        cin >> s[i];
    }

    ll hoge = 0, ans = 0;
    ans += solve(s, hoge);

    rot(s);
    ans += solve(s, hoge);

    rot(s);
    ans += solve(s, hoge);

    rot(s);
    ans += solve(s, hoge);
    hoge /= 2;
    ans -= hoge;
    cout << ans << endl;
    return 0;
}

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

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

    int flag = 0;

    
    for(int i = 0; i < n-1; i++){
        if(h[i+1] - h[i] < 0){
            if(flag == 0){
                if(h[i+1] - (h[i]-1) == 0){
                    h[i]--;
                    flag = 1;
                }
                else if(h[i+1] - h[i] <= -2){
                    cout << "No" << endl;
                    return 0;
                }
                //else if()
            }
            else {
                cout << "No" << endl;
                return 0;
            }
        }
        else if(h[i+1] - h[i] == 0){
            if(flag == 0){
                h[i]--;
            }
        }
        else {
            flag = 0;
        }
        
    }
    cout << "Yes" << endl;
    return 0;
    
}

Measured memory_bytes: 640
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,m,n) for(int i=(m);i<(n);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
using ll = long long;
const int INF = 0x3f3f3f3f;
const ll LINF = 0x3f3f3f3f3f3f3f3fLL;
const double EPS = 1e-8;
const int MOD = 1000000007;
// const int MOD = 998244353;
const int dy[] = {1, 0, -1, 0}, dx[] = {0, -1, 0, 1};
const int dy8[] = {1, 1, 0, -1, -1, -1, 0, 1}, dx8[] = {0, -1, -1, -1, 0, 1, 1, 1};
template <typename T, typename U> inline bool chmax(T &a, U b) { return a < b ? (a = b, true) : false; }
template <typename T, typename U> inline bool chmin(T &a, U b) { return a > b ? (a = b, true) : false; }
struct IOSetup {
  IOSetup() {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(20);
  }
} iosetup;

template <size_t char_sz = 26>
struct Trie {
  struct Node {
    char c;
    int nx[char_sz];
    set<int> tails;
    Node(char c) : c(c) { memset(nx, -1, sizeof(nx)); }
  };

  vector<Node> nodes;

  Trie(const char basis = 'a') : basis(basis) { nodes.emplace_back('$'); }

  void add(const string &s, int ch, int pos = 0) {
    for (char c : s) {
      int now = convert(c);
      if (nodes[pos].nx[now] == -1) {
        int nx_pos = nodes.size();
        nodes[pos].nx[now] = nx_pos;
        nodes.emplace_back(c);
        pos = nx_pos;
      } else {
        pos = nodes[pos].nx[now];
      }
    }
    nodes[pos].tails.emplace(ch);
  }

  int find(char c, int pos = 0) const {
    // for (char c : t) {
      int now = convert(c);
      if (nodes[pos].nx[now] == -1) return -1;
      pos = nodes[pos].nx[now];
    // }
    return pos;
  }

  int convert(char c) const { return c - basis; }

private:
  const char basis;
};

int main() {
  int n; cin >> n;
  vector<string> s(n);
  Trie<> trie;
  REP(i, n) {
    cin >> s[i];
    reverse(ALL(s[i]));
    char tail = s[i].back();
    s[i].pop_back();
    trie.add(s[i], tail - 'a');
    s[i] += tail;
  }
  sort(ALL(s), [](string l, string r) { return l.length() < r.length(); });
  ll ans = 0;
  REP(i, n) {
    vector cnt(26, 0);
    for (char c : s[i]) ++cnt[c - 'a'];
    int pos = 0;
    for (int c : trie.nodes[pos].tails) ans += cnt[c] > 0;
    int len = s[i].length();
    REP(j, len - 1) {
      --cnt[s[i][j] - 'a'];
      pos = trie.find(s[i][j], pos);
      assert(pos != -1);
      for (int c : trie.nodes[pos].tails) ans += cnt[c] > 0;
    }
    --ans;
    // cout << s[i] << ' ' << ans << '\n';
  }
  cout << ans << '\n';
  return 0;
}


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

int main() {
  int64_t a, b;
  std::cin >> a >> b;
  if (a == 1 && b == 1) {
    std::cout << 1 << std::endl;
    return 0;
  }
  int64_t count = 0;
  count += std::max<int64_t>(0, a - 2) * std::max<int64_t>(0, b - 2);
  if (a == 1) {
    count += std::max<int64_t>(0, b - 2);
  }
  if (b == 1) {
    count += std::max<int64_t>(0, a - 2);
  }

  std::cout << count << std::endl;
  return 0;
}


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

using namespace std ;

const int N =3e5 + 7 ; 

int  n , m ; 
int occ[N] ; 
vector<long long> v , v2 ; 

long long solve(int x){ 
        long long ret = 0 ; 

        int l = 1 , r = n ; 

        while(l<=r){
                long long mid = (l + r) >> 1 ; 
                long long deli = upper_bound(v.begin() , v.end() , mid ) - v.begin() ;
                long long gaz = (deli ? v2[deli - 1] : 0)  + ((int) v.size() - deli ) * mid ; 
                if(gaz>=mid * x){
                        l = mid+1 ; 
                        ret = mid ; 
                }
                else {
                        r = mid -1 ; 
                }
        }

        return ret ; 
}

int main(){

        ios_base::sync_with_stdio(0) ; 
        cin.tie(0) ; 

        cin >> n ; 

        for(int i = 0 ;i < n;i++){
                int x ;  
                cin >> x; 
                occ[x] ++ ; 
        }   
        for(int i = 0 ;i <= n;i++){
              v.push_back(occ[i]) ; 
              v2.push_back(0) ; 
        }
        sort(v.begin() , v.end()) ; 
        for(int i = 0 ;i <= n;i ++){
              if(i){
                    v2[i] = v2[i-1] ; 
              }
              v2[i] += v[i] ; 
        }
        v2.push_back(v2.back()) ;

       

        for(int i = 1 ;i <= n;i++){      
            cout<< solve(i) <<"\n" ; 
        }

        return 0; 
}

Measured memory_bytes: 10680
n = list(map(int, input()))

daikin = 0
otsuri = 0

cnt = 0
for i in range(len(n)-1, 0, -1):
  if n[i] == 10:
    n[i-1] += 1
    continue

  if n[i] < 5:
    cnt += n[i]
    daikin += n[i]
  elif n[i] == 5:
    if n[i-1] < 5:
      cnt += 5
    else:
      cnt += 5
      n[i-1] += 1
  else:
    cnt += 10 - n[i]
    otsuri
    if i != 0:
      n[i-1] += 1

if n[0] <= 5:
  cnt += n[0]
else:
  cnt += 11 - n[0]

print(cnt)

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


int main(){
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  int n;
  cin>>n;
  map<int,int> m;
  for(int i=1;i<=100;i++){
    for(int j=1;j<=100;j++){
      for(int k=1;k<=100;k++){
         if(i*i+j*j+k*k+i*j+i*k+j*k<=n){
          m[i*i+j*j+k*k+i*j+i*k+j*k]++;
         }
      }
    }
  }
  for(int i=1;i<=n;i++){
    cout<<m[i]<<endl;
  }




}
       
  


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

typedef long long ll;
#define MOD = 1000000007;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define ALL(a) begin(a),end(a)
#define COUNTOF(a) (sizeof(a)/sizeof(a[0]))
template<class T> istream& operator >> (istream& s, vector<T>& v)
{ for (T& x: v) { s >> x; } return s;}
template<class T> void cout_v(const vector<T>& c)
{ for (int i = 0; i < c.size(); i++) cout << c[i] << endl; }
template<class K, class V> void cout_v(map<K, V>& m)
{ for(auto it=m.begin();it!=m.end();it++)cout<<it->first<<":"<<it->second<<endl;}
template<class T> void cout_h(const vector<T>& c)
{ for (int i = 0; i < c.size(); i++) cout << c[i] << (i==c.size()-1?"\n":" "); }
template<class T> inline bool chmin(T& a, T b) {return a>b?a=b,true:false;}
template<class T> inline bool chmax(T& a, T b) {return a<b?a=b,true:false;}
inline int powi(int x,int y) {int p=1; while(y--) p*=x; return p;}
template<class T> inline bool is_overlap(const T& a, const T& b, const T& p, const T& q)
{ return p <=b && a <= q; }
#define SP << " " <<
#define FMT(a) #a<<":"<<a 
#define FMT2(a,b) #a<<":"<<a<<", "<<#b<<":"<<b 
#define FMT3(a,b,c) #a<<":"<<a<<", "<<#b<<":"<<b<<", "<<#c<<":"<<c 
#define FMT4(a,b,c,d) #a<<":"<<a<<", "<<#b<<":"<<b<<", "<<#c<<":"<<c<<", "<<#d<<":"<<d 
#define ANS(a) cout<<a<<endl
void yes(bool f){cout<<(f?"yes":"no")<<endl;}
void Yes(bool f){cout<<(f?"Yes":"No")<<endl;}
void YES(bool f){cout<<(f?"YES":"NO")<<endl;}

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

    ll N, Y; cin >>N>> Y;
    ll x, y, z;
    for (x = min(N, Y/10000); x >= 0; x--) {
        ll rest_Y = Y - 10000 * x;
        ll rest_N = N - x;
        ll tmp = 5000 * rest_N - rest_Y;
        if (tmp % 4000 != 0 || tmp < 0)
            continue;
        z = tmp / 4000;
        y = N - x - z;
        if (y < 0)
            continue;
        cout << x << " " << y << " " << N-x-y << endl;
        return 0;
    }
    cout << "-1 -1 -1" << endl;
    
}


Measured memory_bytes: 256
#coding:UTF-8
def depth(leaf,A,d):
    for i in range(len(A)):
        if A[i][1]==leaf or A[i][2]==leaf:
            return depth(A[i][0],A,d+1)
    return d

def height(n,A,h):
    if n[1]!=-1 or n[2]!=-1:
        return max(height(A[n[1]],A,h+1),height(A[n[2]],A,h+1))
    return h

def BT(A,n):
    for i in range(n):
        p=0
        dep=0
        deg=0
        sib=0
        hei=0
        t=""
        if A[i][1]!=-1 and A[i][2]!=-1:
            deg=2
        elif A[i][1]!=-1 or A[i][2]!=-1:
            deg=1
        else:
            deg=0
        if A[i][1]==-1 and A[i][2]==-1 and n>1:
            t="leaf"
            deg=0
            dep=depth(A[i][0],A,dep)
            hei=height(A[i],A,hei)
            for j in range(len(A)):
                if A[i][0]==A[j][1]:
                    sib=A[j][2]
                    break
                elif A[i][0]==A[j][2]:
                    sib=A[j][1]
                    break
            for j in range(len(A)):
                if A[j][2]==A[i][0] or A[j][1]==A[i][0]:
                    p=A[j][0]
                    break
        else:
            hei=height(A[i],A,hei)
            for j in range(len(A)):
                if A[i][0]==A[j][1]:
                    sib=A[j][2]
                    break
                elif A[i][0]==A[j][2]:
                    sib=A[j][1]
                    break
            dep=depth(A[i][0],A,dep)
            if dep==0:
                sib=-1
                p=-1
                t="root"
            else:
                for j in range(len(A)):
                    if A[j][2]==A[i][0] or A[j][1]==A[i][0]:
                        p=A[j][0]
                        t="internal node"
                        break
        
        print("node "+str(A[i][0])+": parent = "+str(p)+", sibling = "+str(sib)+", degree = "+str(deg)+", depth = "+str(dep)+", height = "+str(hei)+", "+t)

if __name__=="__main__":
    n=int(input())
    A=[]
    for i in range(n):
        A.append(list(map(int,input().split(" "))))
    for i in range(n):
        minj=i
        for j in range(i,n):
            if A[j][0]<A[minj][0]:
                minj=j
        A[i],A[minj]=A[minj],A[i]
    BT(A,n)

Measured memory_bytes: 7948
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.math.BigInteger;
import java.util.StringTokenizer;
import java.io.IOException;
import java.lang.String;
import java.util.ArrayList;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import java.util.Scanner;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
import java.util.StringTokenizer;
import java.util.BitSet;
import java.io.IOException;
import java.util.Arrays;
import java.util.GregorianCalendar;

public class Main {

    static BigInteger modulo = new BigInteger("1000000007");
    static long mod = 1000000007;
//    Nested ststic class FastReaders

    static class FastReader {

        BufferedReader br;
        StringTokenizer st;

        public FastReader() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        public String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException io) {
                    io.printStackTrace();
                }
            }
            return st.nextToken();
        }

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

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

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

        public String nextLine() {
            String s = "";
            try {
                s = br.readLine();
            } catch (IOException io) {
                io.printStackTrace();
            }
            return s;
        }
    }

    static BigInteger exponentialModulo(BigInteger a, BigInteger b) {
        BigInteger previousNumber = BigInteger.ONE;
        while (!(b.equals(BigInteger.valueOf(0)))) {
            if (b.testBit(0)) {
                previousNumber = previousNumber.multiply(a).mod(modulo);
            }
            b = b.shiftRight(1);
            a = a.modPow(BigInteger.valueOf(2), modulo);
        }
        return previousNumber;
    }

    public static int applySearchOfSubstring(String text) {
        int count = 0;
        Pattern p = Pattern.compile("AB");
        Matcher m = p.matcher(text);
        while (m.find()) {
            ++count;
        }

        return count;
    }

    public static void main(String[] args) throws IOException {
        FastReader input = new FastReader();
//        System.out.println(189232688%48695377);
        int a = input.nextInt();
        int p = input.nextInt();
        
        a = a*3;
        a += p;
        System.out.println(a/2);
    }

}


Measured memory_bytes: 23252
#include<bits/stdc++.h>
#define MAX 3010
#define ll long long
#define mod (1000000000+7)
#define Fast ios_base::sync_with_stdio(false); cin.tie(NULL);

using namespace std;

int T[MAX][MAX];

string LCS(string X, string Y, int m, int n)
{
	if (m == 0 || n == 0)
		return string("");
	if (X[m - 1] == Y[n - 1])
	{
		return LCS(X, Y, m - 1, n - 1) + X[m - 1];
	}
	if (T[m - 1][n] > T[m][n - 1])
		return LCS(X, Y, m - 1, n);

	else
		return LCS(X, Y, m, n - 1);
}

int main()
{
    string s , t; cin>>s>>t;
    int l = s.length(); int m = t.length();
    for(int j=0;j<=m;j++)
        T[0][j] = 0;
    for(int i=0;i<=l;i++)
        T[i][0] = 0;
    for(int i=1;i<=l;i++)
    {
        for(int j=1;j<=m;j++)
        {
            if(s[i-1]==t[j-1])
                T[i][j] = T[i-1][j-1] + 1;
            else
                T[i][j] = max(T[i-1][j] , T[i][j-1]);
        }
    }
    cout<<LCS(s,t,l,m);
}


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

int main() {
  int n, m;
  cin >> n >> m;
  int a[m], b[m];
  for (int i = 0; i < m; i++) {
    cin >> a[i] >> b[i];
  }

  int count = 0;
  for (int i = 0; i < m; i++) {
    if (a[i] < n) count += n - a[i];
  }

  int mini = a[0];
  for (int i = 1; i < m; i++) {
    mini = min(a[i], mini);
  }

  if (mini < n) count -= n - mini;

  cout << count << endl;

  return 0;
}

Measured memory_bytes: 3096
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;

int DigitSum(LL n) {
	int res = 0;
	while(n > 0) {
		res += n % 10;
		n /= 10;
	}
	return res;
}
int main(void) {
	LL n, temp;
	cin >> n;
	int ans = DigitSum(n);
	temp = n;
	LL cnt = 1;
	while(temp > 0) {
		temp /= 10;
		cnt *= 10;
	}
	cnt /= 10;
	ans = max(ans, DigitSum(n / cnt * cnt - 1));
	cout  << ans << endl;
	return 0;
}

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

using namespace std;
using ll = long long;

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

    int n, m, q, l, r; cin >> n >> m >> q;

    int part[505][505];
    memset(part, 0, sizeof part);

    for(int i=0; i<m; i++)
        cin >> l >> r, part[l][r]++;

    for(int i=1; i<n+1; i++)
        for(int j=1; j<n+1; j++)
            part[i][j] += part[i][j-1];

     for(int i=1; i<n+1; i++)
        for(int j=1; j<n+1; j++)
            part[i][j] += part[i-1][j];

    while(q--){
        cin >> l >> r, l--;
        cout << (part[r][r]+part[l][l]) - (part[l][r]+part[r][l]) << '\n';
    }

    return 0;
}


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

using namespace std;
#define ll long long
const int N=3005,mod=998244353;
int dp[N][N],a[N];
int n;
int solve(int idx,int s)
{
    if(s==0) return n-idx+1;
    if(s<0||idx==n) return 0;

    int &ret=dp[idx][s];
    if(~ret) return ret;
    ret=solve(idx+1,s);
    ret=(ret+solve(idx+1,s-a[idx]))%mod;
    return ret;
}
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);cout.tie(0);
    int s;
    cin>>n>>s;
    for(int i=0;i<n;i++)
        cin>>a[i];
    int ans=0;
    memset(dp,-1,sizeof dp);
    for(int i=0;i<n;i++)
        ans=(ans+1ll*(i+1)*solve(i+1,s-a[i])%mod)%mod;
    cout<<ans<<endl;
    return 0;
}


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

int main(){
 long long int N,a=0,t=0;
 cin >>N; long long int M[N],L[N];
 for(long long int i=0;i<N;i++){
 cin >> M[i];
 L[i]=0;
 if(i!=0&&M[i-1]>=M[i])L[i]=1;
 }
    
 for(long long int i=0;i<N;i++){
     if(L[i]==1){
         t++;
         continue;
     }else {
         a=max(a,t);
         t=0;
     }
    
 }
   a=max(a,t);
 cout <<a;
}



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

bool all753(long long k){
    bool a[10];
    for(int i=0; i<10; i++){
        a[i]=false;
    }
    while(k>0){
        a[k%10] =true;
        k =k/10;
    }
    return a[3] && a[5] && a[7];
}

int main(){
    long long N;
    cin >> N;
    queue<long long> que;
    int cnt=0;
    que.push(3); que.push(5); que.push(7);
    while(!que.empty()){
        long long l = que.front();
        if(l <= N){
            que.push(10*l+3);
            que.push(10*l+5);
            que.push(10*l+7);
            if(all753(l)) cnt++;
        }
        que.pop();
    }
    cout << cnt << endl;
}

Measured memory_bytes: 768
#include<bits/stdc++.h>
using namespace std;
int main()
{
    //g h ; " string
    string st;
    cin>>st;
    bool b=false;
    for(int i=0;i<st.size();i++)
    {
        if(st[i]-'0'==7)
        {
            b=true;
        }
    }
    if(b)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;


     //Alhamdulilla..

}



Measured memory_bytes: 3592
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  long long m,k;cin >> m >> k;
  long long a=1;
  for (int i=0;i<m;i++) a*=2;
  if (m==0) {if (k==0) cout << "0 0" << endl; else cout << -1 << endl;}
  else if (m==1) {if (k==0) cout << "0 0 1 1" << endl; else cout << -1 << endl;}
  else {
    if (a<=k) cout << -1 << endl;
	else {
	  for (long long i=0;i<a;i++) if (i!=k) cout << i << " ";
	  cout << k << " ";
	  for (long long i=a-1;i>=0;i--) if (i!=k) cout << i << " ";
	  cout << k << endl;
	}
  }
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define rep2(i, a, n) for(ll i = a; i < (ll)(n); i++)
#define memi cout << endl
#define kono(n) cout << fixed << setprecision(n)
#define all(c) (c).begin(), (c).end()
#define pb push_back
#define hina cout << ' '
#define in(n) cin >> n
#define in2(n, m) cin >> n >> m
#define in3(n, m, l) cin >> n >> m >> l
#define out(n) cout << n
const ll mei = (ll)1e9 + 7;

int main(){
  ll a, b, c, n;
  a = b = 0;
  in(n);
  string s;
  in(s);
  rep2(i, 1, n){
    if(s[i] == 'E')
      b++;
  }
  vector<ll> t(n);
  rep(i, n - 1){
    if(s[i] == 'W')
      c++;
  }
  t[0] = b;
  t[n - 1] = c;
  rep2(i, 1, n - 1){
    if(s[i - 1] == 'W'){
      if(s[i] == 'W'){
        t[i] = t[i - 1] + 1;
      }
      else
        t[i] = t[i - 1];
    }
    else{
      if(s[i] == 'W')
        t[i] = t[i - 1];
      else
        t[i] = t[i - 1] - 1;
    }
  }
  b = 1000000;
  rep(i, n)
    b = min(b, t[i]);
  out(b);
  memi;
}

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

const int BITS = 30;

char flip(char dir) {
    if (dir == 'L' || dir == 'R')
        return 'L' + 'R' - dir;

    return 'U' + 'D' - dir;
}

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

    int N;
    cin >> N;
    vector<long long> X(N), Y(N);

    for (int i = 0; i < N; i++) {
        cin >> X[i] >> Y[i];

        if (abs(X[i] + Y[i]) % 2 != abs(X[0] + Y[0]) % 2) {
            cout << -1 << '\n';
            return 0;
        }
    }

    vector<long long> D;

    for (int p = BITS; p >= 0; p--)
        D.push_back(1LL << p);

    if (abs(X[0] + Y[0]) % 2 == 0)
        D.push_back(1);

    int M = D.size();
    cout << M << '\n';

    for (int i = 0; i < M; i++)
        cout << D[i] << (i < M - 1 ? ' ' : '\n');

    for (int i = 0; i < N; i++) {
        long long x = X[i], y = Y[i];

        for (long long d : D) {
            long long best_sum = abs(x - d) + abs(y);
            char best_dir = 'L';

            long long current = abs(x + d) + abs(y);
            if (current < best_sum) {
                best_sum = current;
                best_dir = 'R';
            }

            current = abs(x) + abs(y - d);
            if (current < best_sum) {
                best_sum = current;
                best_dir = 'D';
            }

            current = abs(x) + abs(y + d);
            if (current < best_sum) {
                best_sum = current;
                best_dir = 'U';
            }

            cout << flip(best_dir);

            if (best_dir == 'L')
                x -= d;
            else if (best_dir == 'R')
                x += d;
            else if (best_dir == 'D')
                y -= d;
            else if (best_dir == 'U')
                y += d;
            else
                assert(false);
        }

        assert(x == 0 && y == 0);
        cout << '\n';
    }
}


Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;
public class Main
{
	public static void main(String[] args) 
	{
		Scanner in=new Scanner(System.in);
		int M=100000;
		for(;;)
		{
			int n=in.nextInt();
			int a[][]=new int[11][11];
			int ans[]=new int[11];
			int A=M;
			int Ai=-1;
			Arrays.fill(ans, 0);
			for(int i=0;i<11;i++)
				Arrays.fill(a[i], M);
			if(n==0)
				return;
			for(int i=0;i<n;i++)
			{
				int s=in.nextInt();
				int t=in.nextInt();
				int d=in.nextInt();
				a[s][t]=d;
				a[t][s]=d;
			}
			for(int I=0;I<11;I++)
			{
				int p=0;
				int leng[]=new int[11];// minimum distance
				int v[] = new int[11];// decision flag
				int start =I;
				for(int k=0;k<11;k++)
				{
					leng[k]=M;
					v[k]=0;
				}
				leng[start]=0;
				for(int j=0;j<11;j++)
				{
					int min=M;//最小の節点を探す
					for(int k=0;k<11;k++)
					{
						if(v[k]==0&&leng[k]<min)
						{
							p=k;
							min=leng[k];
						}
					}
					v[p]=1;//確定フラグ
					for(int k=0;k<11;k++)
					{
						if((leng[p]+a[p][k])<leng[k])
						{
							leng[k]=leng[p]+a[p][k];
						}
					}
				}
				for(int i=0;i<11;i++)
				{
					if(leng[i]<M)
					{
						ans[start]+=leng[i];
					}
				}
				if(ans[start]<A&&ans[start]!=0)
				{
					A=ans[start];
					Ai=I;
				}
			}
			System.out.println(Ai+" "+A);
		}
	}
}

Measured memory_bytes: 12000
import java.util.*;
public class Main{

	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		String ans;
		if(a < b) ans = "a < b";
		else if(a == b) ans = "a == b";
		else ans = "a > b";
		System.out.println(ans);
	}
}



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

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int l,r,d,cnt=0;
    cin >> l >> r >> d;
    for(int i=l;i<=r;++i){
        if(i%d==0) ++cnt;
    }
    cout << cnt << "\n";
    return 0;
}

Measured memory_bytes: 3644
#include <bits/stdc++.h>
using namespace std;
template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
  os << "(" << p.first << "," << p.second << ")";
  return os;
}
#ifdef __LOCAL
#define debug(x) cerr << __LINE__ << ": " << #x << " = " << x << endl
#define debugArray(x, n)                           \
  cerr << __LINE__ << ": " << #x << " = {";        \
  for (long long hoge = 0; (hoge) < (n); ++(hoge)) \
    cerr << ((hoge) ? "," : "") << x[hoge];        \
  cerr << "}" << endl
#else
#define debug(x) (void(0))
#define debugArray(x, n) (void(0))
#endif

signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  string S;
  cin >> S;
  cout << (S[1] == 'B' ? "ARC" : "ABC") << endl;
  return 0;
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
#define WHOLE(v) (v).begin(), (v).end()
#define REV_WHOLE(v) (v).rbegin(), (v).rend()
using i64 = int64_t;
using namespace std;
template<class F>auto recursive(F f){return[f](auto...a){return f(f,a...);};}
template<class I,class V=typename I::value_type>V sum_up(const I&l,const I&r){V v;for(I i=l;i!=r;i++)v=i==l?*i:v+*i;return v;}
template<class I,class T=iterator_traits<I>>I operator+(I it,int n){for(int i=0;i<n;i++)it++;return it;}
template<class I,class T=iterator_traits<I>>I operator-(I it,int n){for(int i=0;i<n;i++)it--;return it;}
template<class T>using rev_priority_queue=priority_queue<T,vector<T>,greater<T>>;
template<class T>using vector2d=vector<vector<T>>;
struct fixprec{int p;fixprec(int p):p(p){}};
ostream&operator<<(ostream&o,fixprec f){return o<<fixed<<setprecision(f.p);}
void R_YESNO(bool p){cout<<(p?"YES":"NO")<<endl;}
void R_YesNo(bool p){cout<<(p?"Yes":"No")<<endl;}
int main() {
    int N;
    cin >> N;
    string S;
    cin >> S;
    map<char, i64> m;
    for(char c : S) m[c]++;
    i64 ans = m['R'] * m['G'] * m['B'];
    for(int i = 0; i < N; i++) {
        for(int j = i + 1; j < N; j++) {
            int k = 2 * j - i;
            if(k >= N) continue;
            char x = S[i], y = S[j], z = S[k];
            if(x != y && y != z && z != x) ans--;
        }
    }
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 3600
#include <bits/stdc++.h>
#define DEBUG if(0)
#define lli long long int
#define ldouble long double
using namespace std;

int main()
{
  int n, m, k;
  while (scanf("%d %d %d", &n, &m, &k) != EOF)
  {
    char mat[n][m + 1], aux[n][m + 1];
    for (int i = 0; i < n; i++)
      scanf(" %s", mat[i]);

    memcpy(aux, mat, sizeof(aux));
    int ans = 0;
    for (int bi = 0; bi < (1 << n); bi++)
      for (int bj = 0; bj < (1 << m); bj++)
      {
        memcpy(mat, aux, sizeof(mat));
        for (int i = 0; i < n; i++)
          if ((1 << i) & bi)
            for (int j = 0; j < m; j++)
              mat[i][j] = 'r';
        for (int j = 0; j < m; j++)
          if ((1 << j) & bj)
            for (int i = 0; i < n; i++)
              mat[i][j] = 'r';

        int a = 0;
        for (int i = 0; i < n; i++)
          for (int j = 0; j < m; j++)
            a += mat[i][j] == '#';
        ans += a == k;
      }
    printf("%d\n", ans);
  }
  return 0;
}

Measured memory_bytes: 3824
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

a, b, c = map(int, readline().split())
k= int(readline())
cnt = 0
while a >= b:
    b *= 2
    cnt += 1
while b >= c:
    c *= 2
    cnt += 1
print('Yes' if cnt <= k else 'No')

Measured memory_bytes: 9236
#include <cstdio>
#include <climits>
#include <cmath>
#include <iostream>
#include <iomanip>
#include <string>
#include <cstdio>
#include <climits>
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <utility>
#include <queue>
#include <cstring>
#include <set>
#define rep(i, n) for (int i = 0; i < int(n); i++)
using namespace std;
long long MOD = 1000000007;
long long INF = 1000000000000000; //10^15
typedef long long ll;
typedef unsigned long long ull;

int main(void) {

  int n;
  cin >> n;

  int c[200100];
  rep(i, n) cin >> c[i];

  int f[200100] = {};
  ll a[200100];
  a[0] = 0; a[1] = 1; f[c[0]] = 1;
  
  for (int i = 2; i <= n; i++) {
    
    if (f[c[i - 1]] != i - 1) {
      a[i] = (a[i - 1] + a[f[c[i - 1]]]) % MOD;
    } else {
      a[i] = a[i - 1];
    }
    //cout << "f(i) = " << f[c[i - 1]] << endl;
    //cout << a[i] << endl;
    f[c[i - 1]] = i;
    
  }

  cout << a[n] << endl;

  return 0;

}
  
    


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

#define mp make_pair
#define fst first
#define snd second
#define forn(i,n) for (int i = 0; i < int(n); i++)
#define forn1(i,n) for (int i = 1; i <= int(n); i++)
#define popcnt __builtin_popcount
#define ffs __builtin_ffs

using namespace std;

using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;
using pli = pair<ll,int>;
using pil = pair<int,ll>;
using pll = pair<ll,ll>;
template <typename T> using vec = vector<T>;
using vi = vec<int>;
using vl = vec<ll>;
template <typename T> using que = queue<T>;
template <typename T> using deq = deque<T>;

template <typename T> T id(T b) {return b;};
template <class It> bool all(It f,It l){return std::all_of(f,l,id<bool>);}
template <class It> bool any(It f,It l){return std::any_of(f,l,id<bool>);}
template <typename T> void chmax(T &x, T y) {if (x < y) x = y;}
template <typename T> void chmin(T &x, T y) {if (x > y) x = y;}
void fastio() { ios_base::sync_with_stdio(false); cin.tie(nullptr); }
constexpr ll TEN(int n) { if (n == 0) return 1LL; else return 10LL*TEN(n-1); }

int n,m;

int main()
{
  fastio();

  cin >> n >> m;
  multiset<int,greater<int>> v;
  forn(i,n) {
    int x; cin >> x;
    v.insert(x);
  }

  forn(i,m) {
    auto it = v.begin();
    int y = *it;
    v.erase(it);
    v.insert(y/2);
  }

  ll ans = 0;
  for (int x : v)
    ans += x;

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 4992
#! /Library/Frameworks/Python.framework/Versions/3.7/bin/python3
K, S = map(int, input().split())
count = 0
for x in range(K+1):
    for y in range(K+1):
        z = S - x - y
        if z <= K and z >= 0:
            count += 1
print(str(count))


Measured memory_bytes: 2940
class Job
   attr_accessor :cost, :time
end
jobs = []
 
n, t = gets.split(" ").map(&:to_i)
n.times do
  job = Job.new
  m = gets.chomp.split(" ").map(&:to_i)
  job.cost = m[0].to_i
  job.time = m[1].to_i
  jobs.push(job)
end
jobs.sort! do |a, b|
  (a.cost <=> b.cost).nonzero? ||
    (a.time <=> b.time)
end
 
for i in 0..n-1 do
  if jobs[i].time <= t
    puts jobs[i].cost
    exit
  end
end
puts "TLE"


Measured memory_bytes: 1788
#include <bits/stdc++.h>
#define FOR(i,bg,ed) for(ll i=(bg);i<(ed);i++)
#define REP(i,n) FOR(i,0,n)
#define MOD 1000000007
#define int long long
using namespace std;
typedef long long ll;
typedef vector<vector<ll>> mat;
const int INF = 1e9;

int N;
int A[101010];
map<int, int> cnt;
int len[101010];

signed main()
{
    cin >> N;
    int j = 0;
    REP(i,N) {
        cin >> A[i];
        cnt[A[i]]++;
        if (cnt[A[i]] == 2 || cnt[A[i]] == 4) {
            len[j++] = A[i];
        }
    }

    sort(len, len + j, greater<int>());

    if (j <= 1) {
        cout << 0 << endl;
    } else {
        cout << len[0] * len[1] << endl;
    }
}


Measured memory_bytes: 7296
#include<stdio.h>
#define MAX 100000
#define NIL -1

struct Node{int p,l,r;};
struct Node T[MAX];
int n,D[MAX];

void print(int u){
  int i,c;
  printf("node %d: ",u);
  printf("parent = %d, ",T[u].p);
  printf("depth = %d,",D[u]);

  if(T[u].p == NIL)printf(" root, ");
  else if(T[u].l == NIL)printf(" leaf, ");
  else printf(" internal node, ");
  printf("[");
  for(i = 0 , c = T[u].l;c != NIL ;i++,c=T[c].r){
    if(i)printf(", ");
    printf("%d",c);
  }
  printf("]\n");
}
int setDepth(int u,int p){
  D[u] = p;
  if(T[u].r != NIL)setDepth(T[u].r,p);
  if(T[u].l != NIL)setDepth(T[u].l,p + 1);
}
int main(){
  int i,j,v,l=0,r,d,c;
  scanf("%d",&n);
  for(i = 0; i < n ; i++ ){
    T[i].p = T[i].l = T[i].r = NIL;
  }
  for(i = 0 ; i < n ; i++ ){
    scanf("%d %d",&v,&d);
    for(j = 0; j < d ; j++){
      scanf("%d",&c);
      if( j == 0 )T[v].l = c;
      else T[l].r = c;
      l=c;
      T[c].p=v;
    }
  }
  for( i = 0 ; i < n ; i++ ){
    if( T[i].p==NIL)r = i;
  }
  setDepth(r,0);
  for( i = 0 ; i < n ; i++ ){
    print(i);
  }
  return 0;
}

Measured memory_bytes: 5296
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define REP(i,m,n) for(int i=(int)(m); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define rrep(i,n) RREP(i,n-1,0)
#define REPL(i,m,n) for(ll i=(ll)(m); i<(ll)(n); i++)
#define repl(i,n) REPL(i,0,n)
#define all(v) v.begin(), v.end()
const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;
#define MAX_N 10000005
ll inv[MAX_N], fac[MAX_N], finv[MAX_N];
void make() {
  fac[0] = fac[1] = 1;
  finv[0] = finv[1] = 1;
  inv[1] = 1;
  for(int i=2; i<MAX_N; i++) {
    inv[i] = mod - inv[mod%i] * (mod/i) % mod;
    fac[i] = fac[i-1] * (ll)i % mod;
    finv[i] = finv[i-1] * inv[i] % mod;
  }
}
ll perm(ll n, ll r) {
  if(n < 0)       return 0;
  else if(n < r)  return 0;
  else            return (fac[n] * finv[n-r]) % mod;
}
ll comb(ll n, ll r) {
  ll ans = 1;
  ans = perm(n, r);
  ans = (ans * finv[r]) % mod;
  return ans;
}
ll fact(ll n) {
  return fac[n];
}
ll h(int r, int c) {
  return (comb(r+c+2, r+1)-1)%mod;
}
int main() {
  make();
  int r1, r2, c1, c2;
  cin >> r1 >> c1 >> r2 >> c2;
  cout << (h(r2, c2) - h(r1-1, c2) - h(r2, c1-1) + h(r1-1, c1-1) + mod) % mod << endl;
  return 0;
}


Measured memory_bytes: 234624
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()
typedef long long lint;
 
int main() {
  int n;
  cin >> n;
  
  vector<int> h(n);
  
  rep(i,n){
    cin >> h[i];
  }
  
  int a=0;
  int ans=0;
  
  rep(i,n-1){
    if(h[i]>=h[i+1])a+=1;
    else{
      ans=max(ans,a);
      a=0;
        }
  }
  ans=max(ans,a);
  cout << ans << endl;
  

}



Measured memory_bytes: 640
#include<stdio.h>
#define rep(i,N) for(int i=0;i<(int)N;i++)
const int INF=0x7f7f7f7f;
int main(void)
{
  int N,M,X,check,C[12]={0},A[12][12]={0},skill[12],pay=INF,sum;
  check=scanf("%d %d %d",&N,&M,&X);
  rep(i,N){check=scanf("%d",&C[i]);rep(j,M)check=scanf("%d",&A[i][j]);}
  rep(bit,(1<<N))
  {
    sum=0;rep(i,M)skill[i]=0;
    rep(i,N)if(bit&(1<<i)){sum+=C[i];rep(j,M)skill[j]+=A[i][j];}
    check=1;rep(i,M)if(skill[i]<X){check=0;break;}
    if(check)pay=(pay<sum)?pay:sum;
  }
  return printf("%d\n",pay==INF?-1:pay),0;
}

Measured memory_bytes: 1692