akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

int main(){
	int n,d;
	cin >> n >> d;
	int ans = 0;
	for(int i = 0 ; i < n ; i++){
		int p;
		cin >> p;
		ans += max(0,p - d);
	}
	if( ans == 0 ){
		cout << "kusoge" << endl;
	}else{
		cout << ans << endl;
	}
}

Measured memory_bytes: 3064
//c++ テンプレ
#include<bits/stdc++.h>
using namespace std;

typedef long long llint;
typedef long double ld;

#define inf 1e18
#define mod 1000000007
#define sort(v) sort(v.begin(),v.end())
#define reverse(v) reverse(v.begin(),v.end())
#define rep(i,a,n) for(int i=a;i<n;i++)



priority_queue<llint,vector<llint>,greater<llint> > que;
priority_queue<llint> Que;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }

void solve(){
    llint k;
    cin >> k;
    llint ans=-1;
    llint x=7%k;
    for(int i=1;i<k+10;i++){
        if(x==0){
            ans=i;
            break;
        }
        x=(10*x+7)%k;
    }
    cout << ans << endl;
}

int main(){
    solve();
    return 0;
}





Measured memory_bytes: 3628
import sys
n,k,q = map(int,input().split())
score = [k-q for i in range(n)]
a_i = [int(input())-1 for i in range(q)]


for i in range(len(a_i)):
    score[a_i[i]] += 1



for i in score:
    if(i > 0):
        print('Yes')
    else:
        print('No')

Measured memory_bytes: 56736
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <array>
#include <queue>
#include <map>
#include <set>
#include <sstream>
#include <stdio.h>
#include <cstdio>
#include <cstring>
#include <math.h>

using namespace std;

#define Rep(i,a,b) for(int i = a; i < b; i++)
#define rep(i,b) Rep(i,0,b)
#define rrep(i,a) for(int i = a; i >= 0; i--)
#define allof(a) (a).begin(), (a).end()

typedef long long ll;
const int inf = 1e9 + 7;
const ll infll = 1ll << 60ll;
const ll mod = 1e9 + 7;
// 0~3までは右左下上 4~7までは斜め
constexpr int dx[] = { 1, 0, -1, 0, 1, 1, -1, -1 };
constexpr int dy[] = { 0, -1, 0, 1, 1, -1, -1, 1 };

/*
// 最大公約数
ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a % b);
}

// 最小公倍数
ll lcm(ll a, ll b) {
	return a * b / gcd(a, b);
}*/

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

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

	typedef map<ll, ll> M; // map<key の型, valueの型>
	M m;

	rep(i, n) {
		m[a[i]]++;
	}

	ll ans = 0;

	for (auto mp : m) {
		if (mp.second % 2) ans++;
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 7296
#!/usr/bin/env python
# -*- coding: utf-8 -*-

import sys

MAX_VALUE = int(1e4 + 1)


def min_cost_sort():
    ans = 0
    for i in range(array_length):
        if check_order[i]:
            continue
        current_index = i
        circle_sum, circle_min, circle_size = 0, MAX_VALUE, 0
        while True:
            check_order[current_index] = True
            circle_size += 1
            current_value = array[current_index]
            circle_min = min(circle_min, current_value)
            circle_sum += current_value
            current_index = value_to_index[current_value]
            if check_order[current_index]:
                break
        ans += min(circle_sum + (circle_size - 2) * circle_min,
                   circle_sum + circle_min + (circle_size + 1) * min_value)
    return ans


if __name__ == '__main__':
    _input = sys.stdin.readlines()
    array_length = int(_input[0])
    array = list(map(int, _input[1].split()))
    # assert len(array) == array_length

    check_order = [False] * array_length
    value_to_index = dict()
    compare_ans = sorted(array)
    min_value = compare_ans[0]
    for j in range(array_length):
        value_to_index[compare_ans[j]] = j
    print(min_cost_sort())

Measured memory_bytes: 7816
"use strict";

const main = arg => {
    arg = arg.trim().split("\n");
    const N = parseInt(arg[0]);
    const names = arg.slice(1, N + 1);
    
    const p = [0, 0, 0, 0, 0, 0, 1, 1, 1, 2];
    const q = [1, 1, 1, 2, 2, 3, 2, 2, 3, 3];
    const r = [2, 3, 4, 3, 4, 4, 3, 4, 4, 4];
    
    let march = [0, 0, 0, 0, 0];
    
    for(let i in names) {
        if(names[i][0] === "M") {
            march[0]++;
        }
        
        if(names[i][0] === "A") {
            march[1]++;
        }
        
        if(names[i][0] === "R") {
            march[2]++;
        }
        
        if(names[i][0] === "C") {
            march[3]++;
        }
        
        if(names[i][0] === "H") {
            march[4]++;
        }
    }
    
    let answer = 0;
    
    for(let i=0; i<10; i++) {
        answer += march[p[i]] * march[q[i]] * march[r[i]];
    }
    
    console.log(answer);
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));


Measured memory_bytes: 20488
def main():
    n = int(input())
    T = tuple(map(int, input()))
    ans = 0
    for i in range(0, 1000):
        a = i // 100
        b = (i // 10) % 10
        c = i % 10
        flag1 = False
        flag2 = False
        flag3 = False
        for t in T:
            if flag2:
                if t == c:
                    flag3 = True
                    break
            if flag1:
                if t == b:
                    flag2 = True
                    continue
            if t == a:
                flag1 = True

        if flag3:
            ans += 1
    print(ans)
if __name__ == "__main__":
    main()

Measured memory_bytes: 75688
n=input()
for i in range(n):
	a,b,c,d,e,f,g,h=map(float,raw_input().split())
#	if a==c and g==e:print "YES"
#	if a==c and g!=e:print "NO"
#	if a!=c and g==e:print "NO"
#	if a!=c and g!=e:
#		if (d-b)/(c-a)==(h-f)/(g-e):print "YES"
#		else:print "NO"
	if -1e-10<(d-b)*(g-e)-(c-a)*(h-f)<1e-10:
		print "YES"
	else:
		print "NO"

Measured memory_bytes: 6284
#include <iostream>

using namespace std;

int main(){
  	long long N;
  	cin >> N;
  	long long max=0;
  	long long count=0;
  	for(long long i=0;i<N;i++){	
      	long long a;
      	cin >> a;
      	if(max <= a) max = a;
      	else count += max - a;
    }
  	cout << count << endl;
}

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

using ll = int64_t;
#define int ll

#define FOR(i, a, b) for (int i = int(a); i < int(b); i++)
#define REP(i, b) FOR(i, 0, b)
#define MP make_pair
#define PB push_back
#define EB emplace_back
#define ALL(x) x.begin(), x.end()

using pi = pair<int, int>;
using vi = vector<int>;
using ld = long double;

template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
  os << "(" << p.first << "," << p.second << ")";
  return os;
}

template <class T>
ostream &operator<<(ostream &os, const vector<T> &v) {
  os << "{";
  REP(i, (int)v.size()) {
    if (i) os << ",";
    os << v[i];
  }
  os << "}";
  return os;
}

ll read() {
  ll i;
  scanf("%" SCNd64, &i);
  return i;
}

void printSpace() { printf(" "); }

void printEoln() { printf("\n"); }

void print(ll x, int suc = 1) {
  printf("%" PRId64, x);
  if (suc == 1) printEoln();
  if (suc == 2) printSpace();
}

string readString() {
  static char buf[3341000];
  scanf("%s", buf);
  return string(buf);
}

char *readCharArray() {
  static char buf[3341000];
  static int bufUsed = 0;
  char *ret = buf + bufUsed;
  scanf("%s", ret);
  bufUsed += strlen(ret) + 1;
  return ret;
}

template <class T, class U>
void chmax(T &a, U b) {
  if (a < b) a = b;
}

template <class T, class U>
void chmin(T &a, U b) {
  if (b < a) a = b;
}

template <class T>
T Sq(const T &t) {
  return t * t;
}

const int mod = 1e9 + 7;

signed main() {
  int h, w;
  cin >> h >> w;
  string s[h];
  REP(i, h) { s[i] = readString(); }
  auto isBlack = [&](int k, int l) {
    if (k >= 0 && k < h && l >= 0 && l < w) {
      if (s[k][l] == '#') return true;
    }
    return false;
  };
  auto canPaint = [&](int i, int j) {
    if (s[i][j] == '#') {
      if (isBlack(i - 1, j) || isBlack(i, j - 1) || isBlack(i + 1, j) ||
          isBlack(i, j + 1))
        return true;
    } else {
      return true;
    }
    return false;
  };
  REP(i, h) {
    REP(j, w) {
      if (!canPaint(i, j)) {
        cout << "No" << endl;
        return 0;
      }
    }
  }
  cout << "Yes" << endl;
}


Measured memory_bytes: 2304
//
// Created by yamunaku on 2019/08/30.
//

#include <bits/stdc++.h>

using namespace std;

#define rep(i, n) for(int i = 0; i < (n); i++)
#define repl(i, l, r) for(int i = (l); i < (r); i++)
#define per(i, n) for(int i = ((n)-1); i >= 0; i--)
#define perl(i, l, r) for(int i = ((r)-1); i >= (l); i--)
#define all(x) (x).begin(),(x).end()
#define MOD9 998244353
#define MOD1 1000000007
#define IINF 1000000000
#define LINF 1000000000000000000
#define SP <<" "<<
#define CYES cout<<"Yes"<<endl
#define CNO cout<<"No"<<endl
#define CFS cin.tie(0);ios::sync_with_stdio(false)
#define CST(x) cout<<fixed<<setprecision(x)

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<vector<int>> mti;
typedef vector<ll> vl;
typedef vector<vector<ll>> mtl;

int main(){
    int n,m;
    cin >> n >> m;
    string s;
    cin >> s;
    vi a(n,0),b(n,0);
    mti e(n);
    rep(i,m){
        int u,v;
        cin >> u >> v;
        u--,v--;
        e[u].push_back(v);
        e[v].push_back(u);
        if(s[u]=='A') a[v]++;
        else b[v]++;
        if(s[v]=='A') a[u]++;
        else b[u]++;
    }
    vector<int> ok(n,1);
    queue<int> q;
    int c=n;
    rep(i,n){
        if(a[i]==0||b[i]==0){
            c--;
            q.push(i);
            ok[i]=false;
        }
    }
    while(!q.empty()){
        int now=q.front();
        q.pop();
        for(auto nx:e[now]){
            if(s[now]=='A'){
                a[nx]--;
            }else{
                b[nx]--;
            }
            if(ok[nx]&&(a[nx]==0||b[nx]==0)){
                c--;
                q.push(nx);
                ok[nx]=false;
            }
        }
    }
    if(c==0) CNO;
    else CYES;
    return 0;
}


Measured memory_bytes: 12932
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, acos, atan, asin
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd
def input(): return sys.stdin.readline().strip()
def STR(): return input()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def S_MAP(): return map(str, input().split())
def LIST(): return list(map(int, input().split()))
def S_LIST(): return list(map(str, input().split()))
sys.setrecursionlimit(10 ** 9)
inf = sys.maxsize
mod = 10 ** 9 + 7

n = INT()
a = LIST()
print(sum(a) - n)

Measured memory_bytes: 60140
ARGF.each_line do |line|
  break if line =~ /-1 -1 -1/

  m, f, r = line.split.map(&:to_i)

  if m == -1 || f == -1
    puts 'F'
    next
  end
  grade =
    case [m,f].select{|n| n >= 0}.inject(&:+)
    when 0...30
        'F'
    when 30...50
      if r >= 50
        'C'
      else
        'D'
      end
    when 50...65
      'C'
    when 65...80
      'B'
    when 80..100
      'A'
    end
  puts grade
end

Measured memory_bytes: 6108
#include <iostream>
using namespace std;
const int INF = 1 << 30;

int sumOfDigits(int x) {
    int sum = 0;
    while(x > 0) {
        sum += x % 10;
        x /= 10;
    }
    return sum;
}


int main() {

    int N;
    cin >> N;

    int thresh = N / 2 + 1;
    int sumMin = INF;

    for (int a=1; a<=thresh; ++a) {
        int b = N - a;
        if (b <= 0) continue;

        int suma = sumOfDigits(a);
        int sumb = sumOfDigits(b);
        int sum = suma + sumb;
        if (sum < sumMin) {
            sumMin = sum;
        }
    }
    cout << sumMin << endl;
}


Measured memory_bytes: 3600
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
int N,W,H;
vector<P> t;

bool check(P p,int a){
  if(p.first<p.second)
    return (p.first<=a&&a<=p.second);
  return (p.first<=a||a<=p.second);
}
int calcArg(int x,int y){
  if(x==0)return y;
  if(y==H)return H+x;
  if(x==W)return H+W+H-y;
  return H+W+H+W-x;
}

int calcLU(int x,int y){
  int d=min(x,H-y);
  return calcArg(x-d,y+d);
}
int calcLD(int x,int y){
  int d=min(x,y);
  return calcArg(x-d,y-d);
}
int calcRU(int x,int y){
  int d=min(W-x,H-y);
  return calcArg(x+d,y+d);
}
int calcRD(int x,int y){
  int d=min(W-x,y);
  return calcArg(x+d,y-d);
}

int solve(int si){
  int res=1,last=t[si].second;
  for(int i=si;i<si+N;i++){
    if(check(t[i],last)) continue;
    res++;
    last=t[i].second;
  }
  return res;
}

int main(){
  cin>>N>>W>>H;
  for(int i=0;i<N;i++){
    int x,y;
    char ch;
    P p;
    cin>>x>>y>>ch;
    if(ch=='N'){
      p.first = calcLU(x,y);
      p.second = calcRU(x,y);
    }
    if(ch=='E'){
      p.first = calcRU(x,y);
      p.second = calcRD(x,y);
    }
    if(ch=='S'){
      p.first = calcRD(x,y);
      p.second = calcLD(x,y);
    }
    if(ch=='W'){
      p.first = calcLD(x,y);
      p.second = calcLU(x,y);
    }
    t.push_back(p);
  }
  for(int i=0;i<N;i++) swap(t[i].first,t[i].second);
  sort(t.begin(),t.end());
  for(int i=0;i<N;i++) t.push_back(t[i]);
  for(int i=0;i<N+N;i++) swap(t[i].first,t[i].second);
  int ans = N;
  for(int i=0;i<N;i++)ans = min(ans,solve(i));
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 3124
#include <bits/stdc++.h>
#define SPEED ios_base::sync_with_stdio(false); cin.tie(NULL)
#define REP(i,a,b) for(int i=a,_b=b;i<=_b;i++)
#define rep(i,n) REP(i,0,n-1)
#define FORD(i,b,a) for(int i=b,_a=a;i>=_a;i--)
#define ford(i,n) FORD(i,n-1,0)
#define sqr(x) ((x)*(x))
#define ll long long
#define pi pair<int,int>
#define vi vector<int>
#define vpi vector<pi>
#define vll vector<ll>
#define fi first
#define se second
#define all(a) a.begin(),a.end()
#define add push_back
#define len(arr) arr.size()
#define print(x) cout<<(x)<<endl
using namespace std;



int main() {
	SPEED;
	//freopen("in.txt", "r", stdin);
	
	int d, n;
	cin >> d >> n;
	
	ll res = n <= 99 ? n * pow(10, d * 2) : 101 * pow(10, d * 2);
	print(res);
	
	return 0;
}


Measured memory_bytes: 256
#ifdef _MSC_VER
#include <__msvc_all_public_headers.hpp>
#undef min
#undef max
#else
#define NDEBUG
#include <bits/stdc++.h>
#endif

using namespace std;
using large = long long;

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

    auto edges_from = vector<vector<pair<int, int>>>(n + 1);

    for (auto i = 1; i <= n - 1; ++i) {
        int u, v, w;
        cin >> u >> v >> w;
        edges_from[u].emplace_back(v, w);
        edges_from[v].emplace_back(u, w);
    }

    auto q = vector<int>(n + 10);
    auto node_colors = vector<char>(n + 1);
    auto push = 0;
    auto pop = 0;

    node_colors[1] = '0';
    q[push++] = 1;
    while (pop < push) {
        auto v = q[pop++];
        assert(node_colors[v]);

        for (auto [u, w] : edges_from[v]) {
            if (node_colors[u])
                continue;

            auto color = node_colors[v] + (w % 2);
            if (color == '2')
                color = '0';
            node_colors[u] = color;
            q[push++] = u;
        }
    }

    for (auto v = 1; v <= n; ++v)
        cout << node_colors[v] << "\n";
    cout << flush;
    return 0;
}


Measured memory_bytes: 9772
#include <cstdio>
#include <cstdlib>

class stack{
  int top;
  int s[100];
public:
  stack():top(0),s(){}
  void push(int x){
    s[++top] = x;
  }
  int pop(){
    return s[top--];
  }
};

int main(){
  int a,b,x;
  char s[100];
  stack st;
  while( scanf("%s", s) != EOF ){
    if ( s[0] == '+' ){
      a = st.pop();
      b = st.pop();
      st.push(a + b);
    }
    else if ( s[0] == '-' ){
      b = st.pop();
      a = st.pop();
      st.push(a - b);
    }
    else if ( s[0] == '*' ){
      a = st.pop();
      b = st.pop();
      st.push(a * b);
    }
    else {
      x = atoi(s);
      st.push(x);
    }
  }

  printf("%d\n", st.pop());

  return 0;
}

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

int bank (int n) {
  if (n<6)
    return n;
  else if (n<9)
    return bank(n-6) + 1;
  else {
    int n6=1, n9=1;
    while (n>=n6*6) {
      n6 *= 6;
    }
    while (n>=n9*9) {
      n9 *= 9;
    }
    return min(bank(n-n6),bank(n-n9))+1;
  }
}

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

  cout << bank(n) << endl;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
import itertools
N,M,Q=map(int,input().split())
abcd=[]
for _ in range(Q):
    abcd.append(tuple(map(int,input().split())))
Abase=[]
for a in range(1,M+1):
    Abase=Abase+[a]
A=set(itertools.combinations_with_replacement(Abase,N))
ans=0
for i in A:
    temp=0
    for j in abcd:
        if i[j[1]-1]-i[j[0]-1]==j[2]:
            temp=temp+j[3]
    if temp>=ans:
        ans=temp
print(ans)

Measured memory_bytes: 25176
#include<stdio.h>
#include<math.h>
int main()
{
	int x,y,i;
	scanf("%d%d",&x,&y);
	i=2;
	if(x%y==0)
	printf("-1\n");
	else
	{
		while((x*i)%y==0)
		{
			i++;
		}
		printf("%d\n",x*i);
	}
	return 0;
 } 

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define vsort(v) sort(v.begin(), v.end())
#define rvsort(v) sort(v.begin(), v.end(), greater<ll>())
#define ll long long
#define rep(i, s, g) for (ll i = (s); i < (g); i++)
#define MOD 1000000007
#define vfind(v, target) find(v.begin(), v.end(), target)
#define notFound(v, target) (vfind(v, target) == v.end())

using namespace std;

int main()
{
  ll X; cin >> X;
  ll Y = 0, yokin = 100;
  while(yokin < X) {
  	yokin *= 1.01;
    Y++;
  }
  cout << Y << endl;
}

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

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n; cin >> n;
    vector<int> p(n);
    for(int i = 0; i < n; i++){
        cin >> p[i];
    }
    vector<int> cnt(n+1, 0);
    for(int i = 0; i < n; i++){
        cnt[p[i]] = cnt[p[i]-1]+1;
    }
    int ans = 0;
    for(int i = 1; i <= n; i++){
        ans = max(ans, cnt[i]);
    }
    ans = n - ans;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1792
#!usr/bin/env python3
from collections import defaultdict, deque, Counter, OrderedDict
from bisect import bisect_left, bisect_right
from functools import reduce, lru_cache
from heapq import heappush, heappop, heapify

import itertools
import math, fractions
import sys, copy

def L(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline().rstrip())
def SL(): return list(sys.stdin.readline().rstrip())
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI1(): return [int(x) - 1 for x in sys.stdin.readline().split()]
def LS(): return [list(x) for x in sys.stdin.readline().split()]
def R(n): return [sys.stdin.readline().strip() for _ in range(n)]
def LR(n): return [L() for _ in range(n)]
def IR(n): return [I() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def LIR1(n): return [LI1() for _ in range(n)]
def SLR(n): return [SL() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]

def perm(n, r): return math.factorial(n) // math.factorial(r)
def comb(n, r): return math.factorial(n) // (math.factorial(r) * math.factorial(n-r))

def make_list(n, *args, default=0): return [make_list(*args, default=default) for _ in range(n)] if args else [default for _ in range(n)]

dire = [[1, 0], [0, 1], [-1, 0], [0, -1]]
dire8 = [[1, 0], [1, 1], [0, 1], [-1, 1], [-1, 0], [-1, -1], [0, -1], [1, -1]]
alphabets = "abcdefghijklmnopqrstuvwxyz"
ALPHABETS = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
MOD = 1000000007
INF = float("inf")

sys.setrecursionlimit(1000000)

def main():
    N = I()
    A, B, C = sorted(LI()), sorted(LI()), sorted(LI())

    ans = 0
    for bi in B:
        left, right = -1, N
        while right - left > 1:
            mid = (right + left) // 2
            if A[mid] < bi: left = mid
            else: right = mid
        tmp = left
        left, right = -1, N
        while right - left > 1:
            mid = (left + right) // 2
            if C[mid] > bi: right = mid
            else: left = mid
        ans += (tmp + 1) * (N - right)

    print(ans)



if __name__ == '__main__':
    main()

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

#define rep(i,n) for(long long int (i)=0;(i)<(int)(n);(i)++)
#define rrep(i,a,b) for(long long int i=(a);i<(b);i++)
#define rrrep(i,a,b) for(long long int i=(a);i>=(b);i--)
#define all(v) (v).begin(), (v).end()
#define pb(q) push_back(q)
#define Size(n) (n).size()
#define Cout(x) cout<<(x)<<endl

typedef long long ll;

using namespace std;

const int INF = 1e9,MOD = 1e9 + 7,ohara = 1e6;
const ll LINF = 1e18;
long long int n,cnt=0,ans=LINF,a,b,c,d,cmp,cmpp,m,h,w,x,y,sum=0,pos;
int dy[]={1,0,-1,0};
int dx[]={0,1,0,-1};
string alph("abcdefghijklmnopqrstuvwxyz"),s;
bool fl;
struct edge{int to,cost;};

//-------------------------↓↓↓↓↓↓------------------------

int main(void){
       cin.tie(0);
    ios::sync_with_stdio(false);
      
      cin>>n>>s;
      rrep(i,1,n)if(s[i]=='E')cnt++;
      rep(i,Size(s)){
        ans=min(ans,cnt);
        //Cout(cnt);
        if(s[i]=='W')cnt++;
        if(s[i+1]=='E')cnt--;
      }
      Cout(ans);
    
       
return 0;
}


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

#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n) for(int i=(s);i<=(n);i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define REPR(i,s,n) for(int i=(s);i>=(n);i--)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define Eunique(v) v.erase(unique(all(v)),v.end())
#define Eback(s) s.erase(s.end()-1,s.end())
#define rev(v) reverse(all(v))
#define pb push_back
#define pf push_front
#define mod 1000000007
#define m_p make_pair
#define DOUBLE fixed << setprecision(15)
#define OK puts("OK")
#define OK1 puts("OK1")
#define OK2 puts("OK2")
#define SIZE(s) (int)s.size()
#define INF ((1LL<<62)-(1LL<<31))

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<ll,ll> pll;
typedef pair<int,int> pii;
typedef vector<pair<int,int>> vpii;
typedef vector<pair<ll,ll>> vpll;
typedef vector<string> vs;
const double pi = acos(-1.0);

template<class A, class B>
ostream& operator<<(ostream& ost, const pair<A, B>&p) {
	ost << "{" << p.first << ", " << p.second << "} ";
	return ost;
}

template<class T>
ostream& operator<<(ostream& ost, const vector<T>&v) {
	ost << "{";
	for (int i = 0; i<(int)v.size(); i++) {
		if (i)ost << " ";
		ost << v[i];
	}
	ost << "} \n";
	return ost;
}

template<class A, class B>
ostream& operator<<(ostream& ost, const map<A, B>&v) {
	ost << "{";
	for (auto p:v) {
		ost << "{" << p.first << ", " << p.second << "} ";
	}
	ost << "} ";
	return ost;
}

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

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

ll gcd(ll x, ll y) {return __gcd(x,y);}
ll lcm(ll x, ll y) {return x/__gcd(x,y)*y;}

int main()
{
	ll h,w,ans=0;
	char c;
	cin >> h >> w;
	vvll v(h,vll(w,-1));
	ll dx[]={0,-1,1,0};
	ll dy[]={-1,0,0,1};
	rep(i,h){
		rep(j,w){
			cin >> c;
			if(c=='#') v[i][j]=-2;
		}
	}
	rep(i,h){
		rep(j,w){
			if(v[i][j]==-2) continue;
			vvll tmp=v;
			queue<pair<ll,ll>> q;
			tmp[i][j]=0;
			q.push(m_p(i,j));
			while(!q.empty()){
				pair<ll,ll> p=q.front();
				q.pop();
				rep(k,4){
					ll cy=p.first+dy[k];
					ll cx=p.second+dx[k];
					if(cy<0||h<=cy||cx<0||w<=cx) continue;
					if(tmp[cy][cx]==-1){
						tmp[cy][cx]=tmp[p.first][p.second]+1;
						q.push(m_p(cy,cx));
					}
				}
			}
			rep(k,h)rep(l,w)chmax(ans,tmp[k][l]);
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
import sys
S = input()


if S.count("C") != 0 and S.count("F") != 0:
    pass
else:
    print("No")
    sys.exit()

ans = 0
for i in range(len(S)):
    if S[i] == "C":
        if S[i:len(S)].count("F") != 0:
            print("Yes")
            sys.exit()

print("No")

Measured memory_bytes: 3060
//inlclude before define 
#define _USE_MATH_DEFINES

//include
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<cmath>
#include<type_traits>
#include<numeric>
#include<deque>
#include<iomanip>
#include<set>
#include<unordered_set>
#include<tuple>
#include<map>
#include<memory>

using namespace std;

//typedef
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<char> VC;
typedef vector<double> VD;
typedef pair<int, int> P1;
typedef long long int ll;

//number
#define INF 1e9
#define NUM 1000000007

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

//repeat
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define REP(i,a,b) for(int i=int(a);i<int(b);i++)
#define RREPS(i,x) for(int i=((int)(x));i>=0;i--)

//max,min
#define chmin(a,b) a=min((a),(b))
#define chmax(a,b) a=max((a),(b))

//function

/*ll gcd(ll a, ll b) {
	if (b == 0) return a;
	else return gcd(b, a%b);
}*/

/*ll lcm(ll a,ll b) {
	ll g = gcd(a, b);
	return a * (b / g);
}*/

/*int dig(int a) {
	int sum = 0;
	while (a) {
		sum += a % 10;
		a /= 10;
	}
	return sum;
}*/

//grid template
int x[] = { -1, 0, 1, 0 };
int y[] = { 0,-1,0,1 };
int xx[] = { -1,-1,1,1 };
int yy[] = { 1,-1,1,-1 };

int main() {
	string s;
	cin >> s;
	int a=0, b=0;
	int cnt = 0;
	int ans = 0;

	rep(i, s.size()) {
		if (s[i] == '1') {
			a++;
		} else {
			b++;
		}

		if (a > 0 && b > 0) {
			a--;
			b--;
			ans++;
		}
	}

	cout << ans*2 << endl;
}




 

Measured memory_bytes: 512
import bisect, collections, copy, heapq, itertools, math, string, sys
input = lambda: sys.stdin.readline().rstrip() 
sys.setrecursionlimit(10**7)
INF = float('inf')
def I(): return int(input())
def F(): return float(input())
def SS(): 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 LSS(): return input().split()

def resolve():
    r, g, b = LI()

    if (r * 100 + g * 10 + b) % 4 == 0:
        print('YES')
    else:
        print('NO')

if __name__ == '__main__':
    resolve()


Measured memory_bytes: 10048
n = int(input())
a = list(map(int, input().split()))
ans = 0
for i in range(n):
    ans ^= a[i]
for i in range(n):
    print(ans^a[i], end=' ')
print()
"""
for i in range(n):
    ans = 0
    for j in range(n):
        if i != j:
            ans ^= a[j]
    print(ans)
""" 

Measured memory_bytes: 31440
#include <bits/stdc++.h>
using namespace std;
template <class T> inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T> inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return 1;
    }
    return 0;
}
void print() { cout << "\n"; }
template <class T> void print(const T &x) { cout << x << "\n"; }
template <class T, class... Args> void print(const T &x, const Args &... args) {
    cout << x << " ";
    print(args...);
}
template <class T> void printVector(const vector<T> &v) {
    for(const T &x : v) {
        cout << x << " ";
    }
    cout << "\n";
}
using ll = long long;

#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
const double EPS = 1e-7;
const int INF = 1 << 30;
const ll LLINF = 1LL << 60;
const double PI = acos(-1);
constexpr int MOD = 1000000007;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

//-------------------------------------

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s;
    cin >> s;
    reverse(ALL(s));
    if(s[0] == '2' || s[0] == '4' || s[0] == '5' || s[0] == '7' ||
       s[0] == '9') {
        print("hon");
    } else if(s[0] == '3') {
        print("bon");
    } else {
        print("pon");
    }
}

Measured memory_bytes: 3648
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		
		try (Scanner sc = new Scanner(System.in);) {
			
			while(true) {
				long H = sc.nextInt();
				long W = sc.nextInt();

				if (H == 0 && W == 0) break;

				StringBuilder sb = new StringBuilder();
				String pattern[] = {"#", "."};

				for (int i = 0; i < H; i++) {
					for (int j = 0; j < W; j++) {
						if(i % 2 == 0) {
							sb.append(pattern[j % 2]);
						} else {
							sb.append(pattern[(j + 1) % 2]);
						}
					}
					sb.append("\n");
				}

				System.out.println(sb.toString());
			}
		}
	}
}


Measured memory_bytes: 27836
#include<bits/stdc++.h>				//Written by ThiDaiLoc
using namespace std;				//Team Three Wolves
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef vector<ll> vi;
typedef pair<ll,ll> pll;
typedef pair<ll,pll> triple;

#define fu(i,a,b)   for(ll i=a;i<=b;i++)
#define f1(i,n)     for(ll i=1;i<=n;i++)
#define fs(i,s)     for(ll i=0;i+1<=s.length();i++)
#define fd(i,b,a)   for(ll i=b;i>=a;i--)
#define fuv(i,a)    for(ll i=0;i<a.size();i++)
#define fdv(i,a)    for(ll i=(ll)a.size()-1;i>=0;i--)
#define ms(a,x)     memset(a, x, sizeof a)
#define prec(n)     fixed<<setprecision(n)
#define uni(a)      (a).erase(unique(all(a)), (a).end())
#define pb(i)       push_back(i)
#define popb()      pop_back()
#define sc(a)       cin>>a
#define sc2(a,b)    cin>>a>>b
#define pr(a)       cout<<a<<endl
#define pr2(a,b)    cout<<a<<" "<<b<<endl
#define rpr(a)      return cout<<a<<endl,0
#define prY         cout<<"YES"<<endl
#define prN         cout<<"NO"<<endl
#define bit(n,i)    (((n)>>(i))&1)
#define lowb(a,n,x) lower_bound(a,a+n,x) -a
#define lowb2(a,x)  lower_bound(all(a),x) -a.begin()
#define all(x)      (x).begin(), (x).end()
#define sz(a)       (ll)a.size()
#define le(s)       (ll)s.length()		
#define ast(x,a,b)  assert(x>=a and x<=b)				
#define re          return 	
#define	mp(a,b)     make_pair(a,b)
#define se          second
#define fi          first 
#define debug(x)    cerr << #x << " = " << x << endl
#define INPUT       freopen("locin.txt", "r", stdin)
#define OUTPUT      freopen("locout.txt", "w", stdout)
inline ll isqrt(ll k) {ll r = sqrt(k) + 1; while (r * r > k) r--; return r;}
inline ll icbrt(ll k) {ll r = cbrt(k) + 1; while (r * r * r > k) r--; return r;}
inline ll mnz(ll& a,ll b){return a=(a>b?b:a);}
inline ll mxz(ll& a,ll b){return a=(a<b?b:a);}
inline string toString(ll n) {stringstream ss; ss << n;return ss.str();}
double const eps = 1e-6;
ll const Base=1e9+7,oo=1e17,MAXN=1e6;


ll A[MAXN+5];

ll Solves(){
	
	ll n,m,k,cnt=0,ans=0,x,y,q,c,sum=0,v,t;
	// PROCESS IN HERE
	sc(n);
	pr(3*n*n);

	re 0;
	// Hack it if you can :)
}

int main(){
	//INPUT;
	ll JUDGE_ONLINE = 1;
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	ll test=1;
//	sc(test);
	fu(T,1,test){
//		cout<<"Case #"<<T<<": ";
		Solves();
	}
	if (!JUDGE_ONLINE) cout << "\nTime elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << "ms\n";  
		
}

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

int main(){

    int n,k;
    cin >> n >> k;

    int cnt = 0;

    for(int i = 0; i < n; ++i){
        int h;
        cin >> h;
        if(k <= h)++cnt;
    }

    cout << cnt << endl;

}

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

#define ll long long
#define pb push_back
#define vi vector<int>
#define FOR(i, a, b) for(int i = a; i < b; i++)
#define sizeOf(A) (sizeof(A))/(sizeof(A[0]))
#define odd(x) ((x) % (2))
#define fastio ios_base::sync_with_stdio(false), cin.tie(0);
const ll MOD = 1e9 + 7;

int main() {
    fastio;

    int n;
    cin >> n;
    ll answer;
    cin >> answer;
    FOR(i, 1, n) {
        ll x;
        cin >> x;
        answer = answer/(__gcd(answer, x));
        answer *= x;
    }
    cout << answer << "\n";
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <list>

#define ll long long int
#define ld long double
using namespace std;

int main(){
  list<int> v;
  int n;
  scanf("%d",&n);
  for(int i=0; i<n; i++){
    char str[20];
    int num;
    scanf("%s",str);
    if(str[0] == 'i'){
      scanf("%d",&num);
      v.push_front(num);
    }
    else if(str[6] == 'F'){
      v.pop_front();
    }
    else if(str[6] == 'L'){
      v.pop_back();
    }
    else if(str[0] == 'd'){
      scanf("%d",&num);
      for(list<int>::iterator it = v.begin(); it != v.end(); it++){
        if(*it == num){
          v.erase(it);
          break;
        }
      }
    }
  }
  int i=0;
  for(list<int>::iterator it = v.begin(); it != v.end(); it++){
    if(i++) printf(" ");
    printf("%d", *it);
  }
  cout << endl;
  return 0;
}



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

using VS = vector<string>;    using LL = long long;
using VI = vector<int>;       using VVI = vector<VI>;
using PII = pair<int, int>;   using PLL = pair<LL, LL>;
using VL = vector<LL>;        using VVL = vector<VL>;

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))
#define FOR(i, s, e) for (int(i) = (s); (i) < (e); (i)++)
#define FORR(i, s, e) for (int(i) = (s); (i) > (e); (i)--)
#define debug(x) cerr << #x << ": " << x << endl
const int INF = 1e9;                          const LL LINF = 1e16;
const LL MOD = 1000000007;                    const double PI = acos(-1.0);
int DX[8] = { 0, 0, 1, -1, 1, 1, -1, -1 };    int DY[8] = { 1, -1, 0, 0, 1, -1, 1, -1 };

/* -----  __MAKE_TIME__  Problem: __PROBLEM__ / Link: __CONTEST_URL__  ----- */
/* ------問題------


-----問題ここまで----- */
/* -----解説等-----


----解説ここまで---- */

LL N;

LL ans = 0LL;

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

	LL A, B, X; cin >> A >> B >> X;
	ans = LINF;;;
	FOR(i, 0, 22) {
		FOR(j, 0, 42) {
			LL sum = i * 1000 + j * 500;
			if (sum >= X) {
				ans = min(ans, A*i + B * j);
			}
		}
	}
	cout << ans << "\n";

	return 0;
}


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

using namespace std;

int n;

deque<int> deq;

int main() {
  scanf("%d", &n);
  for(int i = 0; i < n; i++) {
    int x; scanf("%d", &x);
    if(i % 2 == 0) {
      deq.push_back(x);
    }else {
      deq.push_front(x);
    }
  }

  if(n % 2 == 1) {
    reverse(deq.begin(), deq.end());
  }

  for(int x : deq) {
    printf("%d ", x);
  }
  return 0;
}

Measured memory_bytes: 2944
import sys
import math
import string
import fractions
import random
from operator import itemgetter
import itertools
from collections import deque
import copy
import heapq
import bisect

MOD = 10 ** 9 + 7
INF = float('inf')
input = lambda: sys.stdin.readline().strip()


def minimum_spanning_tree(n, info):
    """
    頂点の数:nと辺の情報i:infoから最小全域木([[辺の始点の頂点,辺の終点の頂点, 重み], ...])を返す。
    info:[[辺の始点の頂点,辺の終点の頂点, 重み], ...](bellman_ford()の入力形式)
    """
    ans = []
    info.sort(key=itemgetter(2))

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

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

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

            if x == y:
                return

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

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

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

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

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

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

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

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

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

    uf = UnionFind(n)
    for i in info:
        if not uf.same(i[0], i[1]):
            ans.append(i)
            uf.union(i[0], i[1])
    return ans


V, E = map(int, input().split())
stw = [list(map(int, input().split())) for _ in range(E)]
print(sum([i[2] for i in minimum_spanning_tree(V, stw)]))



Measured memory_bytes: 31484
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int X = sc.nextInt();
        int Y = sc.nextInt();
        int A = sc.nextInt();
        int B = sc.nextInt();
        int C = sc.nextInt();
        int[] p = new int[A];
        int[] q = new int[B];
        int[] r = new int[C];
        for (int i = 0; i < A; i++) {
            p[i] = sc.nextInt();
        }
        for (int i = 0; i < B; i++) {
            q[i] = sc.nextInt();
        }
        for (int i = 0; i < C; i++) {
            r[i] = sc.nextInt();
        }

        Arrays.sort(p);
        Arrays.sort(q);
        Arrays.sort(r);

        List<Integer> list = new ArrayList<>();
        for (int i = A-1; i >= A-X; i--) {
            list.add(p[i]);
        }
        for (int i = B-1; i >= B-Y; i--) {
            list.add(q[i]);
        }
        for (int i = 0; i < C; i++) {
            list.add(r[i]);
        }
        Collections.sort(list, Collections.reverseOrder());
        long ans = 0;
        for (int i = 0; i < X+Y; i++) {
            ans += list.get(i);
        }

        System.out.println(ans);
    }
}



Measured memory_bytes: 95832
#include<bits/stdc++.h>
#define white '.'
#define never 1e9
using namespace std;
struct pr{int y,x,cost;};

int main(){
	cin.tie(0),ios::sync_with_stdio(false);
	int h,w; cin>>h>>w;
	vector<string>s(h); for(auto&i:s)cin>>i;
	vector<vector<int>>mp(h,vector<int>(w,1e9)); mp.front().front()=0;
	vector<int>gy={0,-1,0,1},gx={1,0,-1,0};
	queue<pr>q; q.push({0,0,0});
	while(q.size()){
		pr rec=q.front(); q.pop();
		int nwy=rec.y,nwx=rec.x,nwcost=rec.cost;
		for(int i=0;i<4;++i){
			int nxy=nwy+gy.at(i),nxx=nwx+gx.at(i);
			if(nxy<0||nxy>=h||nxx<0||nxx>=w)continue;
			int nxcost=nwcost+1,&mncost=mp.at(nxy).at(nxx);
			char nxcolor=s.at(nxy).at(nxx);
			if(nxcost>=mncost||nxcolor!=white)continue;
			mncost=nxcost;
			q.push({nxy,nxx,nxcost});
		}
	}
	int whitecnt=-1;
	for(auto&i:s)whitecnt+=count(i.begin(),i.end(),'.');
	int goal=mp.at(h-1).at(w-1);
	cout<<(goal!=never?whitecnt-goal:-1)<<"\n"s;
}

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

int main(){
	int p;
	cin>>p;
	int arr[p+1];
	int has[p+1];
	for(int i=1;i<p+1;i++){
		cin>>arr[i];
		has[arr[i]]=i;
	}
	int count = 0;
	bool flag = false;
	for(int i=1;i<p+1;i++){
		if(has[i]!=i){
			if(has[has[i]]!=i){
				flag=true;
				break;
			}
			else{
				has[has[i]]=has[i];
				count++;
			}
			if(count>1){
				flag=true;
				break;
			}
		}
	}
	if(!flag)
		cout<<"YES"<<endl;
	else
		cout<<"NO"<<endl;
}

Measured memory_bytes: 256
using System;

namespace ConsoleApplication3
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] input = Console.ReadLine().Split(' ');
            int a = int.Parse(input[0]);
            int b = int.Parse(input[1]);
            int c = int.Parse(input[2]);
            if (a < b && b < c)
            {
                Console.WriteLine("Yes");
            }
            else
            {
                Console.WriteLine("No");
            }
        }
    }
}

Measured memory_bytes: 8712
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <cmath>
#include <complex>
#include <map>
#include <set>
#include <vector>
#include <stack>
#include <queue>
#include <bitset>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cassert>
#include <iomanip>
using namespace std;

#define Rep(b, e, i) for(int i = b; i <= e; i++)
#define Repr(e, b, i) for(int i = e; i >= b; i--)
#define rep(n, i) Rep(0, n-1, i)
#define repr(n, i) Repr(n-1, 0, i)
#define all(v) (v).begin(), (v).end()
#define pb(v) push_back(v)
#define uniq(v) (v).erase(unique(all(v)),(v).end())
#define bitcnt(x) __builtin_popcount(x)
#define fst first
#define snd second
#define Pqaz(T) priority_queue<T,vector<T>,greater<T>>
#define Pqza(T) priority_queue<T>
#define put(x) cout << x;
#define putsp(x) cout << x << ' ';
#define putbd cout << "---------------------------------------------" << endl;
#define putln(x) cout << x << endl;
#define debug(x) cerr << #x << "=" << x << endl;
#define ENJYU std::ios::sync_with_stdio(false);std::cin.tie(0);

typedef long long ll;
typedef pair<ll, ll> llP;
typedef pair<int, int> intP;
typedef complex<double> comp;
typedef vector <int> vec;
typedef vector <ll> vecll;
typedef vector <double> vecd;
typedef vector <vec> mat;
typedef vector <vecll> matll;
typedef vector <vecd> matd;

//vector の中身を出力
template <class T>ostream &operator<<(ostream &o,const vector<T>&v)
{o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}

const int MAX = 200020;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const int INF = 1<<29;
const ll INFL = 1e18;
const ll MOD = 1e9+7;

const int dx[]={1,0,-1,0},dy[]={0,1,0,-1};
//const int dx[]={-1,-1,-1,0,1,1,1,0},dy[]={-1,0,1,1,1,0,-1,-1};

//********************************template END****************************************//

void solve(void){

	int N, T, ans = INF;
	cin >> N >> T;

	while(N--)
	{
		int c, t;
		cin >> c >> t;
		if (t <= T)
		{
			ans = min(ans, c);
		}
	}

	if (ans == INF)
	{
		cout << "TLE" << endl;
	}
	else
	{
		cout << ans << endl;
	}

}

int main(void){
	solve();
	//cout << "yui(*-v・)yui" << endl;
	return 0;
}


Measured memory_bytes: 256
def list2d(a, b, c): return [[c] * b for i in range(a)]
mod =10**9+7
H, W = map(int, input().split())

grid = []

for _ in range(H):
    grid.append(list(input()))

dp = list2d(H, W, 0)
for i in range(H-1, -1, -1):
    if(grid[i][W-1] == '#'):
        break
    dp[i][W-1] = 1

for j in range(W-1, -1, -1):
    if(grid[H-1][j]=='#'):
        break
    dp[H-1][j] = 1

for row in range(H-2, -1, -1):
    for col in range(W-2, -1, -1):
        if(grid[row][col] == '.'):
            dp[row][col] = (dp[row][col+1] + dp[row+1][col])%mod
        else:
            dp[row][col] = 0
print(dp[0][0]%mod)

Measured memory_bytes: 51424
function Main(input) {
  input=input.split("\n");
  const S=input[0].trim();
  
  console.log('A'+S.split(" ")[1][0]+'C');
}

//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));
  
  


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

class vertex{
public:
  vector<vertex*> to;
  int dis1;
  int disn;
  vertex(){
    dis1 = -1;
    disn = -1;
  }
};

void dfs1(vertex*, vertex*);
void dfsn(vertex*, vertex*);

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

  vertex graph[n+1];

  int a, b;
  for(int i=1; i<=n-1; i++){
    cin >> a >> b;
    graph[a].to.push_back(&graph[b]);
    graph[b].to.push_back(&graph[a]);
  }

  //グラフ上で頂点1,nからdfsで距離確定
  graph[1].dis1 = 0;
  graph[n].disn = 0;
  dfs1(graph, &graph[1]);
  dfsn(graph, &graph[n]);

  //各頂点について距離が短い方を選択
  int fe=0, sn=0;
  for(int i=1; i<=n; i++){
    if(graph[i].dis1<=graph[i].disn) fe++;
    else sn++;
  }

  string ans;
  if(fe>sn) ans = "Fennec";
  else ans = "Snuke";

  cout << ans << endl;

  return 0;
}

void dfs1(vertex* graph, vertex* start){
  vertex* now = start;
  for(int i=0; i<now->to.size(); i++){
    if(now->to[i]->dis1==-1){
      now->to[i]->dis1 = now->dis1+1;
      dfs1(graph, now->to[i]);
    }
  }
}

void dfsn(vertex* graph, vertex* start){
  vertex* now = start;
  for(int i=0; i<now->to.size(); i++){
    if(now->to[i]->disn==-1){
      now->to[i]->disn = now->disn+1;
      dfsn(graph, now->to[i]);
    }
  }
}


Measured memory_bytes: 9600
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < n; i++)
const int    INF = 100000000;
const double EPS = 1e-10;
const int    MOD = 1000000007;
using namespace std;
typedef pair<int,int> P;

struct range{
	int st, en;
} pos[1000];

int n, w, d;
map<int,vector<int> > m;
map<int,vector<int> >::iterator it;
map<int,int> nxt;
vector<int> xx[2000];
bool saw[1000];

int main(){
	cin >> n >> w >> d;
	rep(i,n){
		int x, y; char f;
		cin >> x >> y >> f;
		y = d-y;
		if(f == 'N'){
			if(w-x < y){
				//pos[i].st = P(w,y-w+x);
				pos[i].st = w+d*2-(y-w+x);
			} else{
				//pos[i].st = P(x+y,0);
				pos[i].st = w*2+d*2-(x+y);
			}
			if(x < y){
				//pos[i].en = P(0,y-x);
				pos[i].en = y-x;
			} else{
				//pos[i].en = P(x-y,0);
				pos[i].en = w*2+d*2-(x-y);
			}
		} else if(f == 'E'){
			if(w-x < d-y){
				//pos[i].st = P(w,y+w-x);
				pos[i].st = w+d*2-(y+w-x);
			} else{
				//pos[i].st = P(x+d-y,d);
				pos[i].st = d+x+d-y;
			}
			if(w-x < y){
				//pos[i].en = P(w,y-w+x);
				pos[i].en = w+d*2-(y-w+x);
			} else{
				//pos[i].en = P(x+y,0);
				pos[i].en = w*2+d*2-(x+y);
			}
		} else if(f == 'W'){
			if(x < y){
				//pos[i].en = P(0,y-x);
				pos[i].st = y-x;
			} else{
				//pos[i].en = P(x-y,0);
				pos[i].st = w*2+d*2-(x-y);
			}
			if(x < d-y){
				//pos[i].en = P(0,y+x);
				pos[i].en = y+x;
			} else{
				//pos[i].en = P(x+y-d,d);
				pos[i].en = d+x+y-d;
			}
		} else{
			if(x < d-y){
				//pos[i].en = P(0,y+x);
				pos[i].st = y+x;
			} else{
				//pos[i].en = P(x+y-d,d);
				pos[i].st = d+x+y-d;
			}
			if(w-x < d-y){
				//pos[i].st = P(w,y+w-x);
				pos[i].en = w+d*2-(y+w-x);
			} else{
				//pos[i].st = P(x+d-y,d);
				pos[i].en = d+x+d-y;
			}
		}
		//cout << pos[i].st << " " << pos[i].en  << endl;
		m[pos[i].st].push_back(i);
		m[pos[i].en].push_back(i);
	}
	int cnt = 0;
	for(it = m.begin(); it != m.end(); it++){
		vector<int> v = (*it).second;
		xx[cnt] = v;
		nxt[(*it).first] = cnt;
		cnt++;
	}
	int ans = INF;
	rep(i,cnt){
		int counter = 1;
		rep(j,n) saw[j] = false;
		rep(j,xx[i].size()){
			saw[xx[i][j]] = true;
		}
		map<int,int> tmp;
		for(int j = i+1; j < cnt; j++){
			rep(k,xx[j].size()){
				if(saw[xx[j][k]]) continue;
				if(nxt[pos[xx[j][k]].en] == j){
					if(tmp[xx[j][k]] == 1){
						tmp.clear();
						counter++;
						break;
					}
				} else{
					tmp[xx[j][k]] = 1;
				}
			}
		}
		for(int j = 0; j < i; j++){
			rep(k,xx[j].size()){
				if(saw[xx[j][k]]) continue;
				if(nxt[pos[xx[j][k]].en] == j){
					if(tmp[xx[j][k]] == 1){
						tmp.clear();
						counter++;
						break;
					}
				} else{
					tmp[xx[j][k]] = 1;
				}
			}
		}
		ans = min(ans,counter);
	}
	cout << ans << endl;
}

Measured memory_bytes: 1652
#include<iostream>
#include<algorithm>
#include<cstring>
#include<cstdio>
#include<cmath>
using namespace std;

const int N=100000+10;
const int B=15;
const int S=(1<<B)-1;

int _r;char _c;

int read()
{
	while(!isdigit(_c=getchar()));
	_r=_c-48;
	while(isdigit(_c=getchar()))
		_r=_r*10-48+_c;
	return _r;
}

int n,b[N],ans,fl[B+1];
int sum[S+1],dp[S+1];

int count(int x)
{
	int cnt(1);
	while(!(x&1))
	{
		++cnt;
		x>>=1;
	}
	return cnt;
}

int main()
{
	ans=n=read();
	int i,j,k,x,y,a;
	for(i=1;i<n;++i)
	{
		x=read()+1;y=read()+1;
		a=read();
		b[x]^=a;
		b[y]^=a;
	}
	for(i=1;i<=n;++i)
		++fl[b[i]];
	ans-=fl[0];
	for(i=1;i<=B;++i)
	{
		ans-=fl[i]>>1;
		fl[i]&=1;
	}
	for(i=1;i<=S;++i)
	{
		k=count(j=i&(-i));
		sum[i]=sum[i^j]^k;
	}
	for(i=0;i<=S;++i)
	{
		k=S^i;
		for(j=k;j;(j-=1)&=k)if(!sum[j])
			dp[i^j]=max(dp[i^j],dp[i]+1);
	}
	for(i=1,j=0;i<=B;++i)if(fl[i])
		j^=1<<(i-1);
	printf("%d",ans-dp[j]);
	return 0;
}


Measured memory_bytes: 896
#include <bits/stdc++.h>
using namespace std;
using ll = long long;

int main() {
    int N, D;
    cin >> N >> D;
    int X[N][D];
    for (int i = 0; i < N; ++i) {
        for (int j = 0; j < D; ++j) {
            cin >> X[i][j];
        }
    }
    int ans = 0;
    for (int i = 0; i < N; ++i) {
        for (int j = i+1; j < N; ++j) {
            int dist = 0;
            for (int k = 0; k < D; ++k) {
                dist = dist + (X[i][k] - X[j][k]) * (X[i][k] - X[j][k]);
            }
            for (int k = 0; k < 200; ++k) {
                if(dist == k*k) ans++;
            }
        }
    }
    cout << ans;
    return 0;
}

Measured memory_bytes: 256