akhauriyash/Code-Regression huggingface dataset:
N, x = map(int, input().split())
a = list(map(int, input().split()))
a.sort()
if x == sum(a):
    print(N)
elif x > sum(a):
    print(N-1)
else:
    for i in range(N):
        if sum(a[:i+1]) > x:
            print(i)
            break


Measured memory_bytes: 3060
#include<cstdio>
#include<algorithm>
#include<cstring>

using namespace std;

int m,w;
int bm[13],bw[13];
int dp[13][1<<13];
int main(void){
	while(1){
		scanf("%d%d",&m,&w);
		if(m==0)break;
		memset(dp,-1,sizeof(dp));
		for(int i=0;i<m;i++)scanf("%d",&bm[i]);
		for(int i=0;i<w;i++)scanf("%d",&bw[i]);
		dp[0][0]=0;
		int res=0;
		for(int i=0;i<m;i++){
			for(int j=0;j<(1<<w);j++){
				if(dp[i][j]!=-1){
					dp[i+1][j]=max(dp[i+1][j],dp[i][j]);
					res=max(res,dp[i][j]);
					for(int k=0;k<w;k++){
						if(!((j>>k) & 1)){
							int nj=j|1<<k;
							if(nj>=(1<<w))printf("error\n");
							int z=abs(bm[i]-bw[k]);
							int e=z*(z-30)*(z-30);
							dp[i+1][nj]=max(dp[i+1][nj],dp[i][j]+e);
							res=max(dp[i+1][nj],res);
						}
					}
				}
			}
		}
		printf("%d\n",res);
	}
	return 0;
}

Measured memory_bytes: 1452
#include <stdio.h>

int main(void)
{
    int one, temp;
    int n;
    int i;
    char str[512];
    int score;
    
    while (fgets(str, 512, stdin) != NULL){
        one = score = temp = i = 0;
        while (str[i] != '\0'){
            temp = 0;
            while (str[i] != ' ' && str[i] != '\n'){
                temp = temp * 10 + str[i++] - '0';
            }
            if (temp == 0){
                return (0);
            }
            if (temp != 1){
                if (temp > 10){
                    temp = 10;
                }
                score += temp;
            }
            else {
                one++;
            }
            i++;
        }
        
        score += one;
        if (score > 21){
            printf("0\n");
        }
        else if (one == 0){
            printf("%d\n", score);
        }
        else {
            while (one-- && score + 10 <= 21){
                score += 10;
            }
            printf("%d\n", score);
        }
    }
    
    return (0);
}

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

int main() {
    int a, b;
    cin >> a >> b;
    int A, B;
    if (a%2 != 0) A = a*25/2+1;
    else A = a*25/2;
    B = b*10;
    int ans;
    if (A > B) {
        if (A/10 == b) ans = A;
        else ans = -1;
    } else if (A < B) {
        if (B*2/25 == a) ans = B;
        else ans = -1;
    } else ans = A;
    cout << ans << endl;
    return 0;
}


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

vector<int> a;

int main()
{
    int n;
    cin >> n;
    a = vector<int>(n);
    rep(i, n)
    {
        cin >> a[i];
    }
    ll money = 1000;
    for (int i = 1; i < n; i++)
    {
        if (a[i - 1] < a[i])
        {
            money += ((money / a[i - 1]) * (a[i] - a[i - 1]));
        }
    }
    cout << money << endl;
    return 0;
}


Measured memory_bytes: 3604
a,b,c,d = map(int,input().split())
count = 0
while a > 0 and b > 0:
    if count % 2 == 0:
        c -= b
    elif count % 2 == 1:
        a -= d
    count += 1
if c <= 0:
    print("Yes")
elif a <= 0:
    print("No")

Measured memory_bytes: 9180
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main() {
    int N;
    cin >> N;
    vector<ll> A(N + 1, 0);
    for (int i = 0; i < N; i++) {
        cin >> A[i];
    }
    sort(A.begin(), A.end());
    reverse(A.begin(), A.end());
    ll count = 1;
    stack<ll> st;
    for (int i = 0; i < N; i++) {
        if (A[i] != A[i + 1]) {
            count = 1;
        } else {   //A[i]==A[i+1]
            count++;
            if (count % 2 == 0) {
                st.push(A[i]);
                if (st.size() == 2)break;
            }
        }
    }
    if (st.empty())cout << 0;
    else{
        ll a = st.top();st.pop();
        ll b = st.top();st.pop();
        cout << a * b;
    }
    return 0;
}

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

using namespace std;

int main(void){
  int N;
  cin >>N;
  int h[N],dp[N];
  int l,i;
 
  cin>>h[0];
  cin>>h[1];
  dp[0]=0;
  dp[1]=abs(h[1]-h[0]);
  
  for(i=2;i<N;i++){
    cin>>h[i];
    //cout<<h[i]<<endl;
    dp[i]=min(dp[i-1]+abs(h[i]-h[i-1]),dp[i-2]+abs(h[i]-h[i-2]));
    //cout<<dp[i]<<endl;
  }
  
  cout<<dp[N-1]<<endl;
  
  return 0;
}

Measured memory_bytes: 1024
A,B,M=map(int,input().split())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
c=[min(a)+min(b)]
for i in range(M):
    a1,b1,c1 =map(int,input().split())
    d=a[a1-1]+b[b1-1]-c1
    c.append(d)
print(min(c))


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

// 素数判定
bool isPrime(int p) {
  if(p == 1) return false;
  else if(p == 2) return true;
  else if(p % 2 == 0) return false;
  
  double x = sqrt(p);
  for(int i = 3; i <= x; i += 2){
    if(p % i == 0) return false;
  }
  return true;
}

int main() {
  int n, i, count = 0;
  cin >> n;
  
  for(i = 3; i <= 55555; i += 5){
    if(isPrime(i)){
      cout << i << endl;
      count++;
    }
    
    if(count == n) break;
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vs = vector<string>;
using msi = map<string, int>;
using mii = map<int, int>;
using psi = pair<string, int>;
using pii = pair<int, int>;
using vlai = valarray<int>;
#define rep(i,n) for(int i=0;i<n;i++)
#define range(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 fs first
#define sc second
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define INF 1E9
#define EPS 1E-9
#define MOD 1000000007
#define PI 3.1415926535897932384

template <class T>ostream &operator<<(std::ostream &o, const vector<T> &v)
{
	rep(i, v.size()) {
		o << (i > 0 ? " " : "") << v[i];
	}
	return o;
}

int main() {
	int n, in;
	cin >> n;
	vi v(n);
	rep(i, n) {
		cin >> in;
		v[in - 1] = i;
	}
	int count = 1, maxc = 1;;
	rep(i, n-1) {
		if (v[i] < v[i + 1]) {
			count++;
			maxc = max(maxc, count);
		}
		else count = 1;
	}
	cout << n - maxc << endl;
}


Measured memory_bytes: 1152
import Foundation

let n = Int(readLine()!)!
var ans = 1
var count = 0
for i in 1...n {
  var div = i
  var c = 0
  while div % 2 == 0 {
    c += 1
    div /= 2
  }
  if count < c {
    ans = i
    count = c
  }
}
print(ans)

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

int main() {
  string s;
  cin >> s;
  int n = s.size();
  int count=0;
  for(int i=0; i<=(n+n%2)/2-1; i++){
    if(s[i]!=s[n-i-1]){
      count++;
    }
  }
  cout << count << endl;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
#define inputInt(a) int a;cin >> a; 
#define output(answer) cout << answer << endl;
#define f(i,s,e) for(int i=s; i<=e; i++)

int main()
{
    //input
    inputInt(L);
    inputInt(R);
    
    //main
    int ans = 1e9;
    if(R-L > 2019){ans = 0;}
    else f(i,L,R-1) f(j,L+1,R) ans = min(ans,(i%2019)*(j%2019)%2019);
  
    // 出力
    output(ans);
    return 0;
}

Measured memory_bytes: 256
import java.util.*;
import java.io.*;
import java.math.BigInteger;
 
public class Main {
	public static String toFour(int x){
		String S = Integer.toString(x, 4);
		for(int i = S.length(); i <= 7; i++){
			S = "0" + S;
		}
		return S;
	}
	
	public static void main(String[] args) {
	Scanner s = new Scanner(System.in);
	int A = s.nextInt();
	int B = s.nextInt();
	int C = s.nextInt();
	int K = s.nextInt();
	boolean suc = false;
	for(int i = 0; i < Math.pow(4, K); i++){
		int a = A;
		int b = B;
		int c = C;
		for(int j = 0; j < toFour(i).length(); j++){
			if(toFour(i).charAt(j) == '1'){
				a = 2*a;
			}else if(toFour(i).charAt(j) == '2'){
				b = 2*b;
			}else if(toFour(i).charAt(j) == '3'){
				c = 2*c;
			}else{

			}
			if(b > a && c > b){
				suc = true;
				break;
			}
		}
		if(suc) break;
	}
	if(suc){
		System.out.println("Yes");
	}else{
		System.out.println("No");
	}
    
  }
}

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

#define int long long
#define ll long long
#define pb push_back
#define mp make_pair
#define f(i,a,n) for(int i=a ; i<n ; i++)
#define rf(i,n,a) for(int i=n ; i>=a ; i--)
#define F first
#define S second
#define all(c) (c).begin(),(c).end()
#define sz(v) (int)(v).size()
#define fast ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)

typedef long double ld;
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef pair<pii,int> ppi;
typedef vector<pii> vpi;

const int inf = 1e9;
const int inf64 = 1e18;
const int MOD = inf + 7;
const int N = 1e5 + 5;
int fact[N], invfact[N];

int pow(int a, int b, int m)
{
   int ans=1;
   while(b)
   {
      if(b&1)
         ans=(ans*a)%m;
      b/=2;
      a=(a*a)%m;
   }
   return ans;
}

int modinv(int k)
{
   return pow(k, MOD-2, MOD);
}

void precompute()
{
   fact[0]=fact[1]=1;
   for(int i=2;i<N;i++)
   {
      fact[i]=fact[i-1]*i;
      fact[i]%=MOD;
   }
   invfact[N-1]=modinv(fact[N-1]);
   for(int i=N-2;i>=0;i--)
   {
      invfact[i]=invfact[i+1]*(i+1);
      invfact[i]%=MOD;
   }
}

int nCr(int x, int y)
{
   if(y>x)
      return 0;
   int num=fact[x];
   num*=invfact[y];
   num%=MOD;
   num*=invfact[x-y];
   num%=MOD;
   return num;
}

int32_t main(){
   fast;
   precompute();
   int n,m;
   cin >> n >> m;
   int ans = 0;
   if(abs(n-m) <= 1) ans = (fact[n] * fact[m] * ((n == m) + 1))%MOD;
   cout << ans << "\n";
}

Measured memory_bytes: 1792
#include <stdio.h>
 
int cmp(void *a, void *b){
  return *(int*)a - *(int*)b;
}
 
int main(){
  int N, A[200001];
  scanf("%d", &N);
  for(int i=0; i<N; i++){
    scanf("%d", &A[i]);
  }
  
  qsort(A,N,sizeof(int),cmp);
  
  for(int i=0; i<N-1; i++){
    if(A[i]==A[i+1]){
      printf("NO");
      return 0;
    }
  }
  printf("YES");
  return 0;
  
}

Measured memory_bytes: 1788
#include <stdio.h>

int main(void)

{  

    int a,b,d,r;  

    double f; 

    scanf("%d %d",&a,&b);

    d=a/b;  

    r=a%b;

    f=(double)a/(double)b; 

    printf("%d %d %lf",d,r,f); 

   return 0;

}

Measured memory_bytes: 636
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
int main(void) {
    int n, x,m;
    while (1) {
        m = 0;
        scanf("%d%d", &n, &x);
        if (n == 0 && x == 0)break;
        for (int a = 1; a <= n - 2; a++) {
            for (int b = 1; b <= n - 1; b++) {
                if (b <= a)b = a + 1;
                for (int c = 3; c <= n; c++) {
                    if (c <= b)c = b + 1;
                    if (a + b + c == x)m++;
                }
            }
        }
        printf("%d\n", m);
    }
    return 0;
}


Measured memory_bytes: 2120
(n, k) = map(int, input().split())
count_dict = {}
for i in input().split():
    a = int(i)
    if not a in count_dict:
        count_dict[a] = 1
    else:
        count_dict[a] += 1
count = sorted(count_dict.items(), key=lambda x: x[1])
sum = 0
for i in range(len(count) - k):
    sum += count[i][1]
print(sum)

Measured memory_bytes: 41120
#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("O3")
#pragma GCC target("sse4")

typedef double LD;
typedef long long ll;
typedef pair<ll, ll> PII;
typedef pair<LD, LD> PDD;
typedef vector<ll> VI;
typedef vector<PII> VPII;
typedef vector<VI> VVI;
#define MP make_pair
#define	pb push_back
#define x first
#define y second
#define next fake_next

#define FOR(i, a, b) for(ll i = (a); i < (b); ++i)
#define RFOR(i, b, a) for(ll i = (b) - 1; i >= (a); --i)
#define REP(i, t) FOR(i, 0, t)
#define ALL(a) a.begin(), a.end()
#define SZ(a) (ll)((a).size())
#define FILL(a, value) memset(a, value, sizeof(a))
#define count jaskdasbj
const LD PI = acos(-1.0);
const int INF = 1000 * 1000 * 1000;
map<pair<string , string> , int> mask1 , mask2;
int main()
{
	//freopen("input.txt" , "r" , stdin);
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	int N;
	string s;
	cin >> N >> s;
	for(int i = 0; i < (1 << N); i++)
	{

		string s1 , s2;
		for(int j = 0; j < N; j++)
			if(i & (1 << j))
				s1 += s[j];
			else
				s2 += s[j];
		mask1[{s1 , s2}]++;
	}
	for(int i = 0; i < (1 << N); i++)
	{
		string s1 , s2;
		for(int j = 0; j < N; j++)
			if(i & (1 << j))
				s1 += s[j + N];
			else
				s2 += s[j + N];
		reverse(s1.begin() , s1.end());
		reverse(s2.begin() , s2.end());
		mask2[{s1 , s2}]++;
	}
	ll ans = 0;
	for(auto it = mask1.begin(); it != mask1.end(); it++)
	{
		ans += (ll)mask2[it->first] * it->second;
	}
	cout << ans;
	/*int T;
	cin >> T;
	while(T--)
	{
		//cout << "Test: ";
		ll A , B , C , D;
		cin >> A >> B >> C >> D;
	//	cout << A << " " << B << " " << C << " " << D << endl;
		if(A < B)
		{
			cout << "No" << endl;
			continue;
		}
		if(B > D)
		{
			cout << "No" << endl;
			continue;
		}

		ll k = max(0LL , (A - C + B - 1) / B);
		A -= k * B;
		if(A < 0)
		{
			cout << "No" << endl;
			continue;
		}
		ll diff = D - B;
		//cout << A << " " << diff << endl;
		if(!diff)
		{
			cout << "Yes" << endl;
			continue;
		}
		bool bad = false;
		for(int i = 0; i < 1000; i++)
		{
			ll val = (C - A) / diff + 1;
			if(A + val * diff < B)
			{
				bad = true;
			}
			else
				A = A + val * diff - B;
		}
		if(bad)
			cout << "No" << endl;
		else
			cout << "Yes" << endl;
	}
*/

	return 0;
}


Measured memory_bytes: 103424
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000


int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    string N;
    cin >> N;
    if (N[0] == N[1] && N[1] == N[2] || N[1] == N[2] && N[2] == N[3]) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }

    return 0;
}


Measured memory_bytes: 764
#include <bits/stdc++.h>
#define N (long long)(1e9 + 7)

#define MAX 500000
using namespace std;

long long factorial[MAX] = {0}, finverse[MAX] = {0},
          inverse[MAX] = {0};

void smodfact() {
  factorial[0] = factorial[1] = 1;
  finverse[0] = finverse[1] = 1;
  inverse[1] = 1;
  for(int i = 2; i < MAX; ++i) {
    factorial[i] = factorial[i - 1] * i % N;
    inverse[i] = N - (inverse[N % i] * (N / i)) % N;
    finverse[i] = finverse[i - 1] * inverse[i] % N;
  }
}

long long calccomb(long long n, long long k) {
  if(n == k && n == 0) return 1;
  if(n < 0 || k < 0 || n < k) return 0;
  return factorial[n] * finverse[k] % N * finverse[n - k] %
         N;
}

long long n, k;
vector<long long> a, b;

long long solve();

int main() {
  cin >> n >> k;
  a.resize(n);
  for(int i = 0; i < n; ++i) cin >> a[i];

  cout << solve() << endl;
  return 0;
}

long long solve() {
  long long ans = 0;
  b = a;
  smodfact();
  sort(b.begin(), b.end());
  for(int i = 0; i < n; ++i)
    for(int j = i + 1; j < n; ++j)
      if(a[i] > a[j]) {
        long long now = 0;
        now = (k + 1) * k % N * inverse[2] % N;
        ans += now;
        ans %= N;
      }
      else if(a[i] < a[j]) {
        long long now = 0;
        now = k * (k - 1) % N * inverse[2] % N;
        ans += now;
        ans %= N;
      }
  return ans;
}

Measured memory_bytes: 12032
#include<iostream>
using namespace std;
int main(){
  int a,b,c,d,h[1000]={},s=0;
  cin>>a>>b>>c>>d;
  for(int i=a;i<b;i++)h[i]++;
  for(int i=c;i<d;i++)h[i]++;
  for(int i=0;i<=100;i++)
    if(h[i]==2)s++;
  cout<<s;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define sf scanf
#define pf printf
int main()
{
    ll x,y,re(0),z;
    sf("%lld %lld",&x,&y);
    while(x<=y)
    {
        x*=2;
        re++;
    }
    cout<<re<<'\n';
    return 0;
}


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

int main()
{
	int a[5];
	for (int i = 0; i < 5; ++i)
	{
		cin >> a[i];
	}
	
	int final_answer = 1e9;
	vector<int> p = {0, 1, 2, 3, 4};
	do
	{
		int ans = 0;
		for (int i = 0; i < 5; ++i)
		{
			while(ans % 10 != 0)
			{
				ans++;
			}
			
			ans += a[p[i]];
		}
		final_answer = min(final_answer, ans);
		
	} while(next_permutation(p.begin(), p.end()));
	
	cout << final_answer << endl;
	
	return 0;
}


Measured memory_bytes: 256
n = int(input())
a = list(map(int, input().split()))
lcm = a[0]

def gcd(a, b):
    if a > b:
        a, b = b, a
    while b > 0:
        a, b = b, a % b
    return a

for i in range(1, n):
    lcm = lcm * a[i] // gcd(lcm, a[i])
mod = 10**9 + 7
ans = 0
for i in range(n):
    ans += lcm // a[i]
print(ans % mod)

Measured memory_bytes: 4084
N=int(input())
t_List=[int(i) for i in input().split()]
t_Table=[0]
for i in range(N):
  t_Table.append(t_Table[i]+t_List[i])
v_List=[int(i) for i in input().split()]
v_List.append(0)
Class=0
t=0
v=0
L=0
check=0
while t<=t_Table[-1]:
  for i in range(Class+1,N+1):
    if t_Table[i]!=t:
      if (v_List[i]-v)/(t_Table[i]-t)==-1:
        L+=v/2-1/8
        v+=-0.5
        check=-1
        break
  if check!=-1: 
    if v==v_List[Class]:
      L+=v/2
    else:
      L+=v/2+1/8
      v+=0.5
  t+=0.5
  if t_Table[Class+1]==t and Class<=N-2:
    Class+=1
    check=0
print(L)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
const int mod = 998244353;
inline void Add(int &x, int y) { x += y; if (x >= mod) x -= mod; }
char s[305];
int len, n, K, a[305], f[305][305][305];
int main() {
	scanf("%s %d", s + 1, &K);
	len = strlen(s + 1);
	n = 0;
	for (int i = 1, lst = 0; i <= len + 1; i++) {
		if (i == len + 1 || s[i] == '0') {
			a[++n] = i - lst - 1;
			lst = i;
		}
	}
	reverse(a + 1, a + 1 + n);
	f[0][0][0] = 1;
	int ps = 0;
	for (int i = 1; i <= n; i++) {
		for (int j = 0; j <= ps; j++) {
			for (int k = 0; k <= ps; k++) if (f[i - 1][j][k]) {
				for (int l = 0; l <= a[i]; l++) {
					Add(f[i][j + a[i] - l][k + a[i] - l], f[i - 1][j][k]);
				}
			}
		}
		for (int k = 0; k <= ps; k++) {
			int sum = 0;
			for (int j = ps; j >= 0; j--) {
				Add(f[i][j][k], sum);
				Add(sum, f[i - 1][j][k]);
			}
		}
		ps += a[i];
	}
	int ans = 0;
	for (int k = 0; k <= min(K, ps); k++) {
		Add(ans, f[n][0][k]);
	}
	printf("%d\n", ans);
	return 0;
}

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

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

int main()
{
    int N, K;
    cin >> N >> K;
    vector<int> sunuke(N);
    rep(i, K){
        int d;
        cin >> d;
        rep(j, d){
            int A;
            cin >> A;
            sunuke.at(A - 1)++;
        }
    }

    int ans = 0;
    rep(i, sunuke.size()){
        if(sunuke.at(i) == 0){
            ans++;
        }
    }
    cout << ans << endl;
}



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

int main()
{
	int n;
	cin >> n;
	bool t = false;
	for (int i = 0; i <= n / 4 ; i++) {
		for (int k = 0; k <= n / 7 ; k++) {
			if (4 * i + 7 * k == n) {
				t = true;
				break;
			}
		}
	}
	if (t==true) cout << "Yes" << endl;
	else cout << "No" << endl;

	return 0;
}


Measured memory_bytes: 256
N = int(input())
for h in range(1, 3501):
    for n in range(1, 3501):
        b = 4*h*n - N*(n+h)
        a = N*h*n
        #print(a, b)
        if b > 0 and a % b == 0:
            w = a // b
            print(h, n, w)
            exit(0)


Measured memory_bytes: 42268
#include <bits/stdc++.h> //C++の標準ライブラリを一行で一括でインクルードする
#include <math.h> //数学関数と数学定数を利用する
#define rep(i,n) for (int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;
template<class T> void chmax(T &a,T b) { if (a<b) a=b;}
template<class T> void chmin(T &a,T b) { if (a>b) a=b;}

int main(){
  string s; cin >> s;
  
  for(int bit = 0; bit < (1<<3);bit++){
    int sum = s[0]-'0';
    for(int i = 0; i < 3; i++){
      if(bit & (1<<i)) sum += s[i+1]-'0';
      else sum -= s[i+1]-'0';
    }
    if(sum == 7){
      cout << s[0];
      for(int i = 0; i < 3; i++){
        if(bit & (1<<i)) cout << '+' << s[i+1];
        else cout << '-' << s[i+1];
      }
      cout << "=7" << endl;
      break;
    }
  }
  return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
 
#define N 101
#define BLACK 200
#define WHITE 201
#define GRAY 202
void BFS(int);
void Enqueue(int);
int Dequeue();
 
int t =0,num = 0,head =0,tail =0,save=0,change=1000000;
int d[N],color[N],num4[N][N];
int Q[N];
 
int main(){
  int i,j,num2,num3,num5,flag;
  scanf("%d",&num);
  
  for(i=1;i<=num;i++){
    for(j=1;j<=num;j++){
      num4[i][j] = 0;
    }
  }
  
   for(i=1;i<=num;i++){
     scanf("%d",&num5);
     save = num5;
     if(save < change) change = save;
 
     scanf("%d",&num2);
     if(num2 == 0)continue; 
     else{
       for(j=0;j<num2;j++){
     scanf("%d",&num3);
     num4[i][num3] = 1; 
       }
     }   
   }
 
 
   
     BFS(change);  //i=min ????
    
 
 
   for(i=1;i<=num;i++){
     if(d[i]==1000000000){
       d[i] = -1;
}
 
     printf("%d %d\n",i,d[i]);
     }
       
    
   return 0;
}
 
 
void BFS(int s){
  int i,v,Q;
  for(i=1;i<=num;i++){
    color[i]=WHITE;
    d[i]=1000000000;
  }
  color[s] =GRAY;
  d[s] = 0;
   
  Enqueue(s);
   
  while(head !=tail){
    i = Dequeue();
    for(v=1;v<=num;v++){
 
      if(color[v] == WHITE && num4[i][v] == 1){
 
    color[v] = GRAY;
    d[v] =d[i] + 1;
        Enqueue(v);
      }
    }
  
    color[i] = BLACK;
 }
   
}
 
void Enqueue(int x){
 
  Q[tail] = x;
  tail++;
 
}
 
int Dequeue(void){
 
  int x;
 
  x = Q[head];
  head++;
 
  return x;
}

Measured memory_bytes: 636
#include <vector>
#include <algorithm>
#include <iostream>
#include <iomanip>

using namespace std;
using ll = long long;

ll Comb[100][100];

void calc_comb(int N){
    for(int i=0;i<=N;i++){
        for(int j=0;j<=i;j++){
            if(i==0 || j==i){
                Comb[i][j] = 1ll;
            }else{
                Comb[i][j] = Comb[i-1][j-1] + Comb[i-1][j];
            }
        }
    }
}

int main(){
    int N,A,B;
    cin >> N >> A >> B;
    calc_comb(N);
    vector<ll> v(N);

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

    sort(v.begin(), v.end(), greater<ll>());
    double max_avg = 0.0;
    for(int i=0;i<A;i++){
        max_avg += v[i];
    }
    max_avg /= A;

    int num_0 = 0;
    int num_A = 0;

    for(int i=0;i<N;i++){
        if(v[i] == v[A-1]){
            num_0++;
            if(i < A){
                num_A++;
            }
        }
    }

    ll count = 0;
    if(num_A == A){
        for(int i=A;i<=B;i++){
            count += Comb[num_0][i];
        }
    }else{
        count += Comb[num_0][num_A];
    }

    cout << fixed << setprecision(15);
    cout << max_avg << endl;
    cout << count << endl;

    return 0;
}

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

using ll = int64_t;

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, n) for (int i = 1; i <= (n); ++i)
#define drep(i, n) for (int i = (n)-1; i >= 0; --i)
#define ddrep(i, n) for (int i = n; i > 0; --i)
#define srep(i, s, t) for (int i = s; i < t; ++i)

#define rng(a) a.begin(), a.end()
#define pb push_back
#define eb emplace_back
#define fi first
#define se second

#define chmax(x, y) (x = max(x, y))
#define chmin(x, y) (x = min(x, y))

using pi = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vi>;
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;
}

template <typename T, size_t S> void printArray(const T (&array)[S]) {
  for (auto val : array)
    std::cout << val << ", ";
  std::cout << "\n";
}

const int mod = 1e9 + 7;
const int inf = 1e9 + 5;

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

  string s;
  std::cin >> s;
  int len = s.size();
  int diffCnt = 0;
  rep(i, len) {
    diffCnt++;
    while (s[i] == s[i + 1] && i < len)
      i++;
  }
  std::cout << (diffCnt - 1) << "\n";
}


Measured memory_bytes: 512
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>

using namespace std;


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

    long long n;
    cin >> n;
    vector<long long> nums(n);
    long long x;
    for (int i = 0; i < n; ++i) {
        cin >> x;
        nums[i] = x - (i + 1);
    }
    sort(nums.begin(), nums.end());
    long long b = nums[n / 2];
    long long sad = 0;
    for (int i = 0; i < n; ++i) {
        sad += abs(nums[i] - b);
    }
    cout << sad << endl;
    return 0;
}

Measured memory_bytes: 1792
// original submission:https://atcoder.jp/contests/keyence2019/submissions/4004186
// author: ks96neko

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String s = sc.next();

        if (s.startsWith("k") && s.endsWith("eyence")) {
            System.out.println("YES");
        } else if (s.startsWith("ke") && s.endsWith("yence")) {
            System.out.println("YES");
        } else if (s.startsWith("key") && s.endsWith("ence")) {
            System.out.println("YES");
        } else if (s.startsWith("keye") && s.endsWith("nce")) {
            System.out.println("YES");
        } else if (s.startsWith("keyen") && s.endsWith("ce")) {
            System.out.println("YES");
        } else if (s.startsWith("keyenc") && s.endsWith("e")) {
            System.out.println("YES");
        } else if (s.contains("keyence")) {
            System.out.println("YES");
        } else {
            System.out.println("NO");
        }
    }
}


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

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
//const ull mod = 1e9 + 7;
const ll mod = 1e9 + 7;
#define REP(i,n) for(int i=0;i<(int)n;++i)

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

template<class S, class T> ostream& operator << (ostream& os, const pair<S, T> v){
  os << "(" << v.first << ", " << v.second << ")"; return os;
}
template<class T> ostream& operator << (ostream& os, const vector<T> v){
  for(int i = 0; i < (int)v.size(); i++){if(i > 0){os << " ";} os << v[i];} return os;
}
template<class T> ostream& operator << (ostream& os, const vector<vector<T>> v){
  for(int i = 0; i < (int)v.size(); i++){if(i > 0){os << endl;} os << v[i];} return os;
}
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }

// conversion number to bit
string num2bit(ll num, ll len){
  string bit = "";
  REP(i, len){
    bit += char('0'+(num>>i & 1));
  }
  return bit;
}

ll x[15][1010];

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

    ll H, W, K;
    cin >> H >> W >> K;

    REP(i, H){
    	string S;
    	cin >> S;
    	REP(j, W){
    		x[i][j] = S[j] - '0';
    	}
    }

    /*
    REP(i, H){
    	REP(j, W){
    		cerr << x[i][j] << " ";
    	}
    	cerr << endl;
    }
    */


    ll res = (1ll<<60);
    REP(mask, 1ll<<(H-1)){
    	vector<ll> cut;
    	cut.push_back(0);
    	REP(i, H-1){
    		if(mask>>i & 1) cut.push_back(i+1);
    	}
    	cut.push_back(H);
    	ll C = (int)cut.size()-1;

    	//dump(num2bit(mask, H-1))

    	ll now = 0;
    	ll tmp = 0;
    	while(now != W){
    		int next = now;
    		vector<ll> cnt(C, 0);
    		while(next != W){
    			bool ok = true;
	    		REP(i, C){
	    			for(int j=cut[i];j<cut[i+1];j++){
	    				cnt[i] += x[j][next];
	    			}
	    			if(cnt[i]>K) ok = false;
	    		}
	    		//cerr << cnt << endl;

	    		if(ok) next++;
	    		else break;
	    	}

	    	if(next == now){
	    		tmp = (1ll<<60);
	    		break;
	    	}

	    	tmp++;
	    	now = next;
    	}

    	chmin(res, tmp-1+C-1);
    }

    cout << res << endl;
    return 0;
}

Measured memory_bytes: 384
import java.util.ArrayList;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		int d = sc.nextInt();
		int e = sc.nextInt();
		Dishes dishes = new Dishes(a, b, c, d, e);
		System.out.println(dishes.getTotalTime());
	}

}

class Dishes {
	ArrayList<Integer> times = new ArrayList<Integer>();
	ArrayList<Integer> losses = new ArrayList<>();

	Dishes(int... times) {
		for (int t : times) {
			this.times.add(t);
			int loss = (10 - t % 10) % 10;
			losses.add(loss);
		}
	}

	int getTotalTime() {
		int totalTime = 0;
		int maxLoss = 0;
		for (int time : times) {
			totalTime += time;
		}
		for (int loss : losses) {
			totalTime += loss;
			if (loss > maxLoss) {
				maxLoss = loss;
			}
		}
		totalTime -= maxLoss;
		return totalTime;
	}
}

Measured memory_bytes: 22612
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> pl;
typedef vector<ll> vl;
const int MN = 112;
const int inf = 1e9;
int n, m, dp[MN][MN];
char s[MN][MN];

int ds (int i, int j) {
  if (dp[i][j] != -1) return dp[i][j];
  int res = inf;
  if (i+1 < n) {
    if (s[i][j] == '#') {
      if (s[i+1][j] == '#') {
        res = min(res, ds(i+1,j));
      } else {
        res = min(res, ds(i+1,j)+1);
      }
    } else {
      res = min(res, ds(i+1,j));
    }
  }
  if (j+1 < m) {
    if (s[i][j] == '#') {
      if (s[i][j+1] == '#') {
        res = min(res, ds(i,j+1));
      } else {
        res = min(res, ds(i,j+1)+1);
      }
    } else {
      res = min(res, ds(i,j+1));
    }
  }
  return dp[i][j] = res;
}

int main (void) {
  ios::sync_with_stdio(false);cin.tie(0);
  cout << fixed << setprecision(15);
  cin >> n >> m;
  for (int i = 0; i < n; i++)
    cin >> s[i];
  memset(dp,-1,sizeof(dp));
  dp[n-1][m-1] = s[n-1][m-1] == '#';
  cout << ds(0,0) << '\n';
  return 0;
}



Measured memory_bytes: 3592
import math
a, b, x = map(int, input().split())
if x >= a*a*b/2:
    t = 2*(b - x/a**2)
    print(math.atan(t/a)*180/math.pi)
else:
    t = 2*x/a/b
    print(math.atan(b/t)*180/math.pi)


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

int main(){
    long long int first, last, judge;
    cin >> first >> last >> judge;

    long long int count = 0;
    
    if(first-1 < 0){
        count = last / judge + 1;
    }
    else {
        count = last / judge - (first-1) / judge;
    }
    
    cout << count << endl;   
}

Measured memory_bytes: 256
import java.util.Scanner;
 
public class Main {  
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    long X = Long.parseLong(sc.next());
    long d =0, t =0;
    while (d < X) {
      t++;
      d += t;
    }
    System.out.println(t);
  }
}

Measured memory_bytes: 21204
#include <bits/stdc++.h>
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define FORR(i,a,b) for (int i=(a);i>=(b);i--)
#define pb push_back
#define pcnt __builtin_popcount
#define show(x) cout<<#x<<" = "<<x<<endl;
#define maxs(x,y) x = max(x,y)
#define mins(x,y) x = min(x,y)
#define fi first
#define se second
#define rng(a) (a.begin()),(a.end())
#define each(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)
#define sz(x) (int)(x).size()
#define mp make_pair

using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vpii;
typedef set<int> si;
typedef pair<ll,ll> pll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<pll> vpll;
typedef set<ll> sl;
typedef __int128_t lll;
typedef pair<lll,lll> plll;
typedef vector<lll> vlll;
template<typename T>string join(vector<T>&v)
{stringstream s;FOR(i,0,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template<typename A, size_t N, typename T>void Fill(A (&array)[N], const T&v)
{fill((T*)array,(T*)(array+N),v);}
template<typename T> T gcd(T a,T b){if(a>b)swap(a,b);for(;a>0;b%=a,swap(a,b));return b;}
ll modpow(lll a,lll n,ll m){if(a==0)return a;lll p=1;for(;n>0;n/=2,a=a*a%m)if(n&1)p=p*a%m;return(ll)p;}
void dout(double d){printf("%.12f\n",d);}

const int iinf = 1e9;
const ll linf = 1e18;
const int mod = 1e9+7;
const double pi = acos(-1);
const double eps = 1e-10;
int h, w, v[5] = {0, 1, 0, -1, 0};
string S[50];
set<pii> s;
queue<pii> q, q2;
main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >> h >> w;
  FOR(i, 0, h) cin >> S[i];
  int su = 0;
  FOR(i, 0, h) FOR(j, 0, w) if(S[i][j] == '.') su++;
  q.push(pii(0, 0));
  s.insert(pii(0, 0));
  int d = 0;
  while(!q.empty()){
    while(!q.empty()){
      pii t = q.front();
      if(t.fi == h-1 && t.se == w-1){
        cout << su - d - 1 << endl;
        return 0;
      }
      q.pop();
      FOR(i, 0, 4){
        int _h = t.fi + v[i], _w = t.se + v[i+1];
        if(0 > _h || _h >= h || 0 > _w || _w >= w || S[_h][_w] == '#') continue;
        pii p = pii(_h, _w);
        if(s.find(pii(_h, _w)) != s.end()) continue;
        s.insert(p);
        q2.push(p);
      }
    }
    d++;
    swap(q, q2);
  }
  cout << -1 << endl;
  return 0;
}

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

back = [(0,0)]*(N+1)
# (a,b): b is # of a
def heapsort(lst):
    h = []
    for value in lst:
        heappush(h,value)
    return [heappop(h) for i in range(len(h))]

for i in range(N, 0, -1):
    if A[i-1] > back[i][0]:
        back[i-1] = (A[i-1], 1)
    elif A[i-1] == back[i][0]:
        back[i-1] = (A[i-1], back[i][1] + 1)
    else:
        back[i-1] = back[i]

anslst = []
from heapq import heappush, heappop

for i in range(N):
    heappush(anslst, (- (back[i][0] - A[i]), back[i][1]) )
anslst = heapsort(anslst)


val = - anslst[0][0]

ans = 0
for i in range(N):
    if val != - anslst[i][0]:
        break
    ans += anslst[i][1] 
print(ans)



Measured memory_bytes: 78596
#include<stdio.h>
#include<string.h>
main(){
  char str[85];
  int l,i;
  while(fgets(str,81,stdin)!=NULL){
    l=strlen(str);
    while(1){
      if(strstr(str,"the ")!='\0'||strstr(str,"this ")!='\0'||strstr(str,"that ")!='\0'){
	break;
      } else {
	for(i=0;i<l;i++){
	  if(str[i]>='a'&&str[i]<='y')str[i]+=1;
	  else if(str[i]=='z') str[i]='a';
	}
      }
    }
    printf("%s",str);
  }
  return 0;
}

Measured memory_bytes: 524
R, G, B, N = map(int, input().split())

ans = 0
for r in range(N//R+1):
    tmp_N = N - r*R
    for g in range(tmp_N//G+1):
        tmp_tmp_N = tmp_N - g*G
        if tmp_tmp_N%B == 0:
            ans += 1
print(ans)



Measured memory_bytes: 40556
#include<bits/stdc++.h>
using namespace std;
#define x first
#define y second
#define mp make_pair
#define pb push_back
#define db double
#define ll long long
bool good(string s, int tet){
    for (int i=0; i < s.size(); i++){
        if (s[i] - 'a' != tet) return false;
    }
    return true;
}
main(){  
    ios_base::sync_with_stdio(0); cin.tie(0);
    string s;
    cin >> s;
    int ans = 1e9;
    for (int symbol = 0; symbol < 26; symbol++){
        string t = s;
        int cur=0;
        while (!good(t, symbol)){
            t.pop_back();
            for (int i=0; i < ((int) (t.size()))-1;i++){
                if (t[i+1] - 'a' == symbol) t[i] = (char) ('a' + symbol);
            }
            cur++;
        }
        ans = min(ans, cur);
    }
    cout << ans;
}

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

signed main(){
  int n, K; cin >> n >> K;
  std::vector<int> a(n);
  for(int i = 0; i < n; i++) scanf("%d", &a[i]);
  int low = 0, high = 1e9+1;
  while(high - low > 1){
    int mid = (high + low) / 2;
    int cnt = 0;
    for(int i = 0; i < n; i++){
      cnt += (a[i] - 1) / mid;
    }
    if(cnt <= K) high = mid;
    else low = mid;
  }
  printf("%d\n", high);
}

Measured memory_bytes: 4000
import Control.Applicative
import Control.Monad.State

data SegTree a = Leaf a | Seg Int (SegTree a) a (SegTree a) deriving (Show)
type Query = StateT (SegTree Int) IO ()

main = do
    [n,q] <- map read.words<$>getLine
    let initTree = fromList $ replicate n 0
    evalStateT (rsq q) initTree

rsq :: Int -> Query
rsq 0 = return ()
rsq q = do
    getQuery
    rsq (q-1)

getQuery :: Query
getQuery = do
    [c,x,y] <- liftIO $ map read.words<$>getLine
    case c of
      0 -> add x y
      1 -> getSum x y
      2 -> (get >>= \seg -> lift $ print seg)

add :: Int -> Int -> Query
add i x = modify $ addSeg i x

getSum :: Int -> Int -> Query
getSum s t = get >>= (\seg -> lift . print . getSumSeg (s,t) $ seg)

val :: SegTree a -> a
val (Leaf x) = x
val (Seg _ _ x _) = x

size :: SegTree a -> Int
size (Leaf x) = 1
size (Seg s _ _ _) = s

fromList :: Num a => [a] -> SegTree a
fromList xs = fl n xs
    where n = length xs

fl :: Num a => Int -> [a] -> SegTree a
fl _ [x] = Leaf x
fl n xs = Seg s l v r
    where
        n' = n `div` 2
        (xsL, xsR) = splitAt n' xs
        l = fl n' xsL
        r = fl (n-n') xsR
        v = val l + val r
        s = size l + size r

addSeg :: Num a => Int -> a -> SegTree a -> SegTree a
addSeg _ x (Leaf v) = Leaf (v+x)
addSeg i x (Seg n l v r)
  | i <= n' = Seg n left (val left + val r) r
  | otherwise = Seg n l (val l + val right) right
  where
      n' = n `div` 2
      left = addSeg i x l
      right = addSeg (i - n') x r

getSumSeg :: Num a => (Int, Int) -> SegTree a -> a
getSumSeg _ (Leaf x) = x
getSumSeg (s,t) (Seg n l v r)
  | s == 1 && t == n = v
  | t <= n' = getSumSeg (s,t) l
  | s > n' = getSumSeg (s - n', t - n') r
  | s <= n' && t > n' = lsum + rsum
  where n' = n `div` 2
        lsum = getSumSeg (s,n') l
        rsum = getSumSeg (1,t - n') r


Measured memory_bytes: 60768
N,M,C=map(int,input().split())
B=list(map(int,input().split()))
A=[list(map(int,input().split())) for i in range(N)]
count=0
for j in A:
    ans=C
    for i in range(M):
        ans+=B[i]*j[i]
    if ans >0:
        count+=1
print(count)

Measured memory_bytes: 3060
# ABC145 - Virtual
# A
if True: print(int(input())**2)

# B
# C
if False:
    import itertools

    def fact(n,mod):
        ret=1
        for i in range(2,n+1):
            ret=(ret*i)%mod
        return ret

    N=int(input())
    X=[tuple(map(int,input().split())) for _ in range(N)]
    ans=0
    for p in itertools.permutations(X):
        # print(p)
        sx,sy=p[0]
        for x,y in p:
            ans+=((sx-x)**2+(sy-y)**2)**0.5
            sx,sy=x,y
        # print(ans)
    ans/=fact(N,10**9+7)
    print(ans)

# D
# E

Measured memory_bytes: 3064
#include <stdio.h>
#include <iostream>
using namespace std;
int main()
{
  int n = 0, count = 0;
  char s[100001];
  int i;
  scanf("%s", s);
  for(i = 0; s[i] ; i++)
  {
    n++;
    if((s[i] == '0') ^ (i % 2 == 0))
    {
      count++;
    }
  }
  if(count > n - count)
  {
    count = n-count;
  }
  cout << count << endl;
  return 0;
}


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

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

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

  string ans = "Yes";
  rep(i, s.size()){
    if(s.at(i) != t.at(i)) ans = "No";
  }

  cout << ans;
}

Measured memory_bytes: 3596
# util functions

# debug
$debugFlag = ( ARGV[0] != nil )
p "==== DEBUG MODE ====" if $debugFlag

def pd(str)
  p str if $debugFlag
end

def printd(str)
  print str if $debugFlag
end

# input
arr = []
lc = 0
while l = $stdin.gets do
  if lc == 0
    lmt = l.chomp.split(" ").map(&:to_i)[1]
  else
    tmp = l.chomp.split(" ").map(&:to_i)
    arr << tmp if tmp[1] <= lmt
  end
  lc += 1
end

arr.sort_by! {|a| a[0] }

# body
if $debugFlag
  p lmt
  p arr
end

if arr != []
  puts arr[0][0]
else
  puts "TLE"
end


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

int main(void) {
  int a, b, n;

  while (cin >> a >> b >> n) {
    int ans = 0;
    
    for (int i = 0; i < n; i++) {
      a = 10 * (a % b);
      ans += a / b;
    }

    cout << ans << endl;
  }

  return 0;
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ll long long
#define fi first
#define se second
#define pb push_back
#define rep(i, s, n) for (int i = s; i < n; i++)
#define rrep(i, s, n) for (int i = (n)-1; i >= (s); i--)
#define all(a) a.begin(),a.end()
typedef pair<int,int>pint;
typedef vector<int>vint;
typedef vector<pint>vpint;
const long long MOD = 1000000007, INF = 1e18;
 
#define endl '\n'
#define IOS() ios_base::sync_with_stdio(0);cin.tie(0)
 
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;}

template<typename T>vector<T>
make_v(size_t a){return vector<T>(a);}
template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
	return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}

template<typename T,typename V>
typename enable_if<is_class<T>::value==0>::type
fill_v(T &t,const V &v){t=v;}

template<typename T,typename V>
typename enable_if<is_class<T>::value!=0>::type
fill_v(T &t,const V &v){
	for(auto &e:t) fill_v(e,v);
}

void pv(vector<int>&v){
	for(int i = 0;i<v.size();i++){
		if(i)cout<<' ';
		cout<<v[i];
	}
	cout<<endl;
}

const int MAX = 510000;
long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

long long H(int n,int k){
    return COM(n+k-1,k);
}

void add(int& a, int b){
	a = (a+b) % MOD;
}
void mul(int& a, int b){
	a = (a*b) % MOD;
}
int mod_pow(int x, int n) {
	int res = 1;
	while (n > 0) {
		if (n & 1) res = res * x % MOD;
		x = x * x % MOD;
		n >>= 1;
	}
	return res;
}
int mod_inv(int x)
{
	return mod_pow(x, MOD - 2);
}
//割り算はmod_inv!

signed main(){
	IOS();
	COMinit();
	int N,A,B,C;
	cin>>N>>A>>B>>C;
	int ans = 0,t = 0;
	int pa = A * mod_inv(A+B)%MOD;
	int pb = B * mod_inv(A+B)%MOD;
	//cout<<pa<<" "<<pb<<endl;
	rep(i,0,N){
		t += COM(N-1+i,N-1)*mod_pow(pa,N)%MOD*mod_pow(pb,i)%MOD*(N+i)%MOD;
		t %= MOD;
		t += COM(N-1+i,N-1)*mod_pow(pb,N)%MOD*mod_pow(pa,i)%MOD*(N+i)%MOD;
		t %= MOD;
	}
	cout<<t*100ll%MOD*mod_inv(100ll-C)%MOD<<endl;
}


Measured memory_bytes: 12160
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
using namespace std;
using namespace __gnu_pbds;
using ll = long long;
using _TYPE = int;
typedef tree< _TYPE, null_type, less< _TYPE >, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
#define IO ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)

int h, w;
const int MAX = 1002;
const int MOD = (int) 1e9 + 7;
char grid[MAX][MAX];
int memo[MAX][MAX];

int dp(int r, int c) {
	if((r >= h) || (c >= w) || (grid[r][c] == '#'))
		return 0;
	if(r == h - 1 && c == w - 1)
		return 1;
	int &rt = memo[r][c];
	if(rt != -1)
		return (rt % MOD);
	rt = dp(r + 1, c) % MOD;
	rt += dp(r, c + 1) % MOD;
	return (rt % MOD);
}

int main() {
    IO;
    cin >> h >> w;
    for(int i = 0; i < h; i++) {
    	for(int j = 0; j < w; j++)
    		cin >> grid[i][j];
    }
    memset(memo, -1, sizeof memo);
    cout << dp(0, 0) % MOD;
    return 0;
}


Measured memory_bytes: 8576
#include<iostream>
#include<algorithm>
#include<math.h>
#include<queue>
#include<vector>
#include<climits>
#include<map>
#include<string>
#include<functional>
#include<iomanip>
#include<deque>
#include<random>

using namespace std;
typedef long long ll;
typedef double lldo;
#define mp make_pair
#define pub push_back
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define sz(x) int(x.size())
ll gcd(ll a, ll b) { if (a % b == 0) { return b; } else  return gcd(b, a % b); }
ll lcm(ll a, ll b) { if (a == 0) { return b; }return a / gcd(a, b) * b; }
template<class T>ll LBI(vector<T>& ar, T in) { return lower_bound(ar.begin(), ar.end(), in) - ar.begin(); }
template<class T>ll UBI(vector<T>& ar, T in) { return upper_bound(ar.begin(), ar.end(), in) - ar.begin(); }

ll N, K, ans = 0;
string S;

int main() {
	cin >> N >> K;
	cin >> S;
	rep(i, sz(S)) {
		if ((i > 0 && S[i] == 'L' && S[i - 1] == 'L') || (i < N - 1 && S[i] == 'R' && S[i + 1] == 'R'))ans++;
	}
	cout << min(ans + K * 2, N - 1) << endl;
	return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i=0; i<(int)(n); i++)
 
int main(){
int n;
  cin >> n;
  int k=1;
  //if(n==1)cout << 1 << endl;
  for(;;){
    if(n<(int)(pow(2,k))){cout << (int)(pow(2,k-1)) << endl;return 0;}
    k++;
  }
 
	return 0;
}

Measured memory_bytes: 256
/*
不要爆零！不要爆零！不要爆零！ 
AuThOr Gwj
*/
#include<bits/stdc++.h>
#define rb(a,b,c) for(int a=b;a<=c;++a)
#define rl(a,b,c) for(int a=b;a>=c;--a)
#define LL long long
#define IT iterator
#define PB push_back
#define II(a,b) make_pair(a,b)
#define FIR first
#define SEC second
#define FREO freopen("check.out","w",stdout)
#define rep(a,b) for(int a=0;a<b;++a)
#define KEEP while(1)
#define SRAND mt19937 rng(chrono::steady_clock::now().time_since_epoch().count())
#define random(a) rng()%a
#define ALL(a) a.begin(),a.end()
#define POB pop_back
#define ff fflush(stdout)
#define fastio ios::sync_with_stdio(false)
#define debug_pair(A) cerr<<A.FIR<<" "<<A.SEC<<endl;
using namespace std;
const int INF=0x3f3f3f3f;
typedef pair<int,int> mp;
typedef pair<mp,mp> superpair;
int a,b,c,d;
LL dp[3003][3003];
const int MOD=998244353;
int main(){
	fastio;
	cin>>a>>b>>c>>d;
	dp[a][b]=1;
	rb(i,a,c){
		rb(j,b,d){
			if(i==a&&j==b) continue;
			dp[i][j]=dp[i-1][j]*j%MOD+dp[i][j-1]*i%MOD;
			dp[i][j]%=MOD;
			dp[i][j]-=dp[i-1][j-1]*(i-1)%MOD*(j-1)%MOD;
			dp[i][j]+=MOD;
			dp[i][j]%=MOD;
		}
	}
	cout<<dp[c][d]<<endl;
	return 0;
}


Measured memory_bytes: 73968
#include <cstdio>

int main()
{
	int N;
	scanf("%d", &N);
	int A[20];
	int B[20];
	int C[19];

	for (int i = 0; i < N; ++i)
	{
		scanf("%d", A + i);
		--A[i];
	}
	for (int i = 0; i < N; ++i)
	{
		scanf("%d", B + i);
	}
	for (int i = 0; i < N - 1; ++i)
	{
		scanf("%d", C + i);
	}

	int ans = B[A[0]];;
	for (int i = 1; i < N; ++i)
	{
		ans += B[A[i]];
		if (A[i] - A[i - 1] == 1)
		{
			ans += C[A[i - 1]];
		}
	}

	printf("%d\n", ans);
	return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds;   
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
#define ld long double
#define dd double
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define all(a) a.begin(),a.end()
#define sz(a) (ll)(a.size())
typedef long long ll;
typedef unsigned long long ull;
typedef pair <ll, ll> pll;
typedef pair <int, int> pii;
typedef vector<pll> vplll;
ll mod = 1e9+7;
const ld PI = 2 * acos(0.0);
const vector<ll> dx = {1, -1, 0, 0};
const vector<ll> dy = {0, 0, 1, -1};
#define round(x, y) ((x + y - 1) / y)
#define ce(x, y) ((x + y - 1) / y)
#define amax(x, y) \
    if (y > x)     \
        x = y;
#define amin(x, y) \
    if (y < x)     \
        x = y;
#define lcm(x, y) ((x) * (y) / __gcd(x, y))
#define len(x) (ll) x.length()
#define sq(x) ((x) * (x))
#define cb(x) ((x) * (x) * (x))
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll a,b,c,t,n,m,k,q; 
    t = 1;
    // cin>>t;
    while(t--)
    {
    	cin>>c;
    	for(ll i=1;i<=3981;i++)
    	{
    		n = pow(i,5);
    		n -= c;
    		ll l = -3981, r = 3981;
    		while(l<=r)
    		{
    			ll mid = (l+r)/2;
    			m = pow(mid,5);
    			if(m<n)
    				l = mid+1;
    			else
    				r = mid-1;
    		}
    		// cout<<i<<" "<<l<<endl;
    		k = pow(l,5);
    		if(k==n)
    		{
    			cout<<i<<" "<<l<<endl;
    			break;
    		}
    	}
    }
    return 0;
}

Measured memory_bytes: 4080