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

using namespace std;

#define ALL(x) x.begin(), x.end()

typedef long long int lld;
typedef pair<int, int> pii;

const int maxn = 1e5+5;

int num[maxn][3];
int dp[maxn][3];

int main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.precision(15);
	cout << fixed;

	int n = 0;
	cin >> n;

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

	for (int i = 0; i < n; i++) {
		for (int j = 0; j < 3; j++) {
			if (i == 0)
				dp[i][j] = num[i][j];
			else {
				if (j == 0)
					dp[i][j] = max(dp[i - 1][1], dp[i - 1][2]) + num[i][j];
				else if (j == 1) 
					dp[i][j] = max(dp[i - 1][0], dp[i - 1][2]) + num[i][j];
				else if (j == 2)
					dp[i][j] = max(dp[i - 1][0], dp[i - 1][1]) + num[i][j];
			}
		}
	}

	cout << max(dp[n - 1][0], max(dp[n - 1][1], dp[n - 1][2])) << endl;

	return 0;
}

Measured memory_bytes: 2560
tt, tk, at, ak = map(int,input().split())

flag = 0

while(tt > 0 and at > 0):
  at -= tk
  if(at <= 0):break
  tt -= ak
  if(tt <= 0):
    flag =1

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

Measured memory_bytes: 9184
#include <algorithm>
#include <functional>
#include <iostream>
#include <iomanip>
#include <vector>
#include <map>
#include <set>
#include <unordered_set>
#include <queue>
#include <numeric>
#include <bitset>
#include <cmath>

using namespace std;
using ll = long long;
using ull = unsigned long long;
// const ll mod =  998244353 ;
const ll mod =  1000000007 ;
const ll inf = 1e18;
const int dx[] = {1, -1, 0, 0};
const int dy[] = {0, 0, 1, -1};

#define REP(i, n) for (ll i = 0; i < (n); ++i)
#define REP_FROM(i, j, n) for (ll i = (j); i < (n); ++i)
#define all(x) (x).begin(),(x).end()
#define sz(x) int(x.size())

template<typename T> void print_vec(vector<T> a) {int n = a.size();REP(i, n) {cout >> a[i]; if(i!=n-1) cout << " "; else cout << endl;}}
ll power(ll base, ll exponent){ if(exponent % 2){ return power(base, exponent - 1) * base % mod; }else if(exponent){ ll root_ans = power(base, exponent / 2); return root_ans * root_ans % mod; }else{ return 1; }}
ll inverse(ll x){ return power(x, mod - 2);}
ll gcd(ll a, ll b) {if(a < b) gcd(b, a);ll r;while(r=a%b) {a=b;b=r;}return b;}
template<typename T> ll sum(T begin, T end) {return accumulate(begin, end, 0ll);}
struct combination{ vector<ll> fact, inv; combination(int sz) : fact(sz + 1), inv(sz + 1){ fact[0] = 1; for(int i = 1; i <= sz; i++){ fact[i] = fact[i - 1] * i % mod; } inv[sz] = power(fact[sz], mod - 2); for(int i = sz - 1; i >= 0; i--){ inv[i] = inv[i + 1] * (i + 1) % mod; } } ll C(int p, int q) const{ if(q < 0 || p < q) return 0; return (fact[p] * inv[q] % mod * inv[p - q] % mod); } };

using Pair = pair<ll, ll>;

const char C[] = {'A', 'B', 'X', 'Y'};

signed main() {
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vector<string> s(n);
    REP(i, n) cin >> s[i];
    ll ans = 0;
    REP(x, n) {
        bool ok = true;
        REP(i, n) {
            REP(j, n) {
                if(s[i][j] != s[(j+x) % n][(i-x+n)%n]) {
                    ok = false;
                }
            }
        }
        if(ok) ans += n;
    }
    cout << ans << endl;
    return 0;
}


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

#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define pb push_back

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

typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;

const int inf=1e9;
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};	

int main(){
	char a,b,c;
	cin>>a>>b>>c;

	cout<<(a==b&&b==c?"No":"Yes")<<endl;

	return 0;
}



Measured memory_bytes: 256
s = input()
ch = 0
for i in range(len(s)-1):
    if s[i+1] != "9":
        ch = 1
        break
cnt = 9*(len(s)-1)
if ch == 1:
    print(cnt + int(s[0])-1)
else:
    print(cnt + int(s[0]))

Measured memory_bytes: 61848
import os

def main():
	n = int(input())
	b_list = list(map(int, input().split()))
	result_list = [b_list[0]]*2
	for i in range(len(b_list)):
		if b_list[i] >= max(result_list[i],result_list[i+1]):
			pass
		else:
			result_list[i] = b_list[i]
		if i < len(b_list) - 1: 
			result_list.append(b_list[i+1])
	print(sum(result_list))

if __name__ == "__main__":
	main()


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
bool K=false;

int main(){
    int N;cin>>N;
    for (int i = 1; i < 10; i++)
    {
        for (int j = 1; j < 10; j++)
        {
            if(i*j==N)K=true;
        }
    }
    if(K)cout<<"Yes";
    else cout<<"No";
}

Measured memory_bytes: 256
#include<iostream>
#include<queue>
#include<stack>
#include<vector>
#include<set>
#include<map>
#include<algorithm>
#include<cstring>
#include<string>
#include<cassert>
#include<cmath>
#include<climits>
#include<iomanip>
#include<bitset>
#include<unordered_map>
 
using namespace std;

#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)
#define rep(i,j,n) for(ll (i)=(j);(i)<(n);(i)++)
#define FOR(i,c) for(decltype((c).begin())i=(c).begin();i!=(c).end();++i)
#define ll long long
#define ull unsigned long long
#define all(hoge) (hoge).begin(),(hoge).end()
typedef pair<ll, ll> P;
const long long INF = 1LL << 60;
const long long MOD = 1e9 + 7;
typedef vector<ll> Array;
typedef vector<Array> Matrix;
 
 
template<class T> inline bool chmin(T& a, T b) {
	if (a > b) {
		a = b;
		return true;
	}
	return false;
}
template<class T> inline bool chmax(T& a, T b) {
	if (a < b) {
		a = b;
		return true;
	}
	return false;
}
 
//グラフ関連
struct Edge {//グラフ
	ll to, cap, rev;
	Edge(ll _to, ll _cap, ll _rev) {
		to = _to; cap = _cap; rev = _rev;
	}
};
typedef vector<Edge> Edges;
typedef vector<Edges> Graph;
 
void add_edge(Graph& G, ll from, ll to, ll cap, bool revFlag, ll revCap) {
	G[from].push_back(Edge(to, cap, (ll)G[to].size()));
	if (revFlag)G[to].push_back(Edge(from, revCap, (ll)G[from].size() - 1));
}

//行列演算
Matrix mIdentity(ll n) {
 Matrix A(n, Array(n));
 for (int i = 0; i < n; ++i) A[i][i] = 1;
 return A;
}

Matrix mMul(const Matrix& A, const Matrix& B) {
 Matrix C(A.size(), Array(B[0].size()));
 for (int i = 0; i < C.size(); ++i)
  for (int j = 0; j < C[i].size(); ++j)
   for (int k = 0; k < A[i].size(); ++k)
    (C[i][j] += (A[i][k] % MOD) * (B[k][j] % MOD)) %= MOD;
 return C;
}
// O( n^3 log e )
Matrix mPow(const Matrix& A, ll e) {
 return e == 0 ? mIdentity(A.size()) :
  e % 2 == 0 ? mPow(mMul(A, A), e / 2) : mMul(A, mPow(A, e - 1));
}

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

	ll n,k;
	cin>>n>>k;
	Matrix a(n,Array(n,0));

	REP(i,n) REP(j,n) cin>>a[j][i];

	Matrix dp0(n,Array(1,1));

	Matrix b=mPow(a,k);

	Matrix dp1=mMul(b,dp0);

	ll ans=0;
	for(auto i:dp1){
		(ans+=i[0])%=MOD;
	}

	cout<<ans<<endl;

	return 0;
}


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

int main(){
    int N;
    int x[1000], y[1000], h[1000];
    cin >> N;
    for (int i = 0; i < N; i++){
        cin >> x[i] >> y[i] >> h[i];
    }
    vector<int> CX;
    vector<int> CY;
    vector<int> HH;

    for (int cx = 0; cx <=100; cx++){
        for (int cy = 0; cy <=100; cy++){
            vector<int> H;
            for (int i = 0; i < N; i++){
                if (h[i] != 0){
                    H.push_back(h[i] + abs(x[i] - cx) + abs(y[i] - cy));
                }
            }
            bool flag = true;
            for (auto itr = H.begin(); itr != H.end() - 1; itr++){
                if (*itr != *(itr + 1)) flag = false;
            }
            if (flag == true){
                CX.push_back(cx);
                CY.push_back(cy);
                HH.push_back(H[0]);
            }
        }
    }
    for (int i = 0; i < CX.size(); i++){
        bool flag2 = true;
        for (int j = 0; j < N; j++){
            if (h[j] == 0){
                if (max(HH[i] - abs(x[j] - CX[i]) - abs(y[j] - CY[i]), 0) != 0) flag2 = false;
            }
        }
        if (flag2 == true){
            cout << CX[i] << " " << CY[i] <<" " << HH[i] << endl;
        }
    }
    return 0;
}

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

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

    int t;
    cin>>t;

    while (t--) {
        LL a, b, c, d;
        cin>>a>>b>>c>>d;

        if (a<b)    {
            cout<<"No"<<"\n";
            continue;
        }
        a-=b;
        if (d<b)    {
            cout<<"No"<<"\n";
            continue;
        }

        if (c>=b) {
            cout<<"Yes"<<"\n";
            continue;
        }
        a%=b;
        long long g = __gcd(b, d);
        a%=g;
        long long mx = b-g+a;
        if (mx > c) cout<<"No"<<"\n";
        else        cout<<"Yes"<<"\n";
    }
}


Measured memory_bytes: 256
import sys
from io import StringIO
import unittest


def resolve():
    n = int(input())
    v = list(map(int, input().split()))

    v.sort()

    ans = (v[0] + v[1]) / 2

    for i in range(2, len(v)):
        ans = (ans + v[i]) / 2

    print(ans)

class TestClass(unittest.TestCase):
    def assertIO(self, input, output):
        stdout, stdin = sys.stdout, sys.stdin
        sys.stdout, sys.stdin = StringIO(), StringIO(input)
        resolve()
        sys.stdout.seek(0)
        out = sys.stdout.read()[:-1]
        sys.stdout, sys.stdin = stdout, stdin
        self.assertEqual(out, output)

    def test_入力例_1(self):
        input = """2
3 4"""
        output = """3.5"""
        self.assertIO(input, output)

    def test_入力例_2(self):
        input = """3
500 300 200"""
        output = """375"""
        self.assertIO(input, output)

    def test_入力例_3(self):
        input = """5
138 138 138 138 138"""
        output = """138"""
        self.assertIO(input, output)


if __name__ == "__main__":
    # unittest.main()
    resolve()


Measured memory_bytes: 5796
S = input()

def long_repeat(line):

    max = 0
    cnt = 1

    for i in range(len(line)-1):
        if cnt > 1:
            cnt -= 1
            continue
        for j in range(i+1,len(line)):
            if line[i] == line[j]:
                cnt += 1
            else:
                break
        if max < cnt:
            max = cnt

    return max

if long_repeat(S) >=2:
    print("Bad")
else:
    print("Good")

Measured memory_bytes: 3060
N = int(input())
s_list = []
s_dict = {}
ans = 0

for j in range(N):
    s_list.append("".join(sorted(input())))

for i in range(N):
    if s_list[i] in s_dict.keys():
        ans += s_dict[s_list[i]]
        s_dict[s_list[i]] += 1

    else:
        s_dict[s_list[i]] = 1

print(ans)

Measured memory_bytes: 19404
#include<bits/stdc++.h>
using namespace std;
int main(){
	int a,b,m;cin>>a>>b>>m;
  	vector<int >ref(a,0),mic(b,0);
  for(int i=0;i<a;i++)cin>>ref[i];
  for(int j=0;j<b;j++)cin>>mic[j];
  int mini = 100000000;
  for(int i=0,x,y,c;i<m;i++){
    cin>>x>>y>>c;
  	mini=min(mini,ref[x-1]+mic[y-1]-c);
  }
  sort(ref.begin(),ref.end());
  sort(mic.begin(),mic.end());
  cout<<min(mini,ref[0]+mic[0]);
  
}

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

int main(void) {
    ll N,M; cin >> N >> M;
    ll sum = 0;
    rep(i,M) {
        ll a; cin >> a;
        sum += a;
    }
    if(N-sum<0) cout << -1 << endl;
    else cout << N-sum << endl;
}

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

#define show(x) cerr << #x << " = " << x << endl ;
#define input_from_file freopen("input.txt","r",stdin)
#define output_to_file freopen("output.txt" , "w",stdout)
#define fastio ios_base::sync_with_stdio(0)
#define endl '\n'


int main()
{
	 #ifdef LOCAL
        input_from_file;
        output_to_file;
    #endif
	fastio;cin.tie(0);cout.tie(0);
	int n  , k , x , ans = 0; cin >> n >> k ;
	for(int i = 0 ; i < n ; ++i)
	{
		cin >> x ; 
		if(x >= k) ++ans ;
	}
	cout << ans;


	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int N = 1e5+1;
std::vector<int> edge[N];
int mi = 1e9;
pair<int,int> nd;
pair<int,int> cend_1;
int par[N];

int main(){
  int x;
  cin >> x;
  cout << !x<<endl;
  return 0;
}


Measured memory_bytes: 5964
#include <iostream>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <map>
#include <queue>

static const int INF = 1000000007;
using ll = long long;
using u32 = unsigned;
using namespace std;

int main() {
    int x1, y1, x2, y2;
    cin >> x1 >> y1 >> x2 >> y2;
    int dx = x2-x1, dy = y2-y1;
    cout << x2-dy << " " << y2+dx << " " << x2-dy-dx << " " << y2+dx-dy << "\n";
    return 0;
}


Measured memory_bytes: 256
import bisect
def main():

    n,h=map(int,input().split())
    a=[]
    b=[]
    for _ in range(n):
        a_,b_=map(int,input().split())
        a.append(a_)
        b.append(b_)
    sumb=sum(b)
    a.sort()
    b.sort()
    cnt=0
    # temp=h-sumb
    low=0
    high=n-1
    mid=0
    temp=h
    #a_max以上のbを探す（２分探索）
    # while low!=high:
    #     mid=(low+high)//2
    #     if b[mid]<a[-1]:
    #         low=mid+1
    #     else:
    #         high=mid
    idx=bisect.bisect_left(b,a[-1])
    mid=idx
    # print(b[mid])
    if n != 1:
        if mid != n:
            for i in range(n-1,mid-1,-1):
                # temp-=b[i]
                h-=b[i]
                cnt+=1
                if h<= 0:
                    print(cnt)
                    return
    else:
        cnt=1
        h-=b[0]
        if h<=0:
            print(cnt)
            return

    # print(h)
    cnt+=-(-h//a[-1])
    print(cnt)
    return
    #
    # h-=a[-1]*cnt
    # else:
    #     cnt=0
    # print(h)
    # print(cnt)
    # print('aaa')
    # for i in range(0,n):
    #     cnt+=1
    #     h-=b[-(i+1)]
    #     print(b[-(i+1)])
    #     if h <= 0 :
    #         print(cnt)
    #         return

    # for j in range(0,h+1):
    #     if sumb >= h:
    #         for i in range(0,n):
    #             cnt+=1
    #             h-=b[-(i+1)]
    #             if h <= 0:
    #                 print(cnt)
    #                 return
    #     h-=a[-1]
    #     cnt+=1

if __name__=='__main__':
    main()


Measured memory_bytes: 59480
import std.stdio, std.string, std.conv, std.algorithm;
import std.range, std.array, std.math, std.typecons, std.container, core.bitop;

immutable inf = 1<<30;

void main() {
    int n, k;
    scan(n);
    scan(k);

    int ans = inf;

    void dfs(int i, int val) {
        if (i == n) {
            ans = min(ans, val);
            return;
        }

        dfs(i + 1, val + k);
        dfs(i + 1, val * 2);
    }

    dfs(0, 1);

    writeln(ans);
}


void scan(T...)(ref T args) {
    string[] line = readln.split;
    foreach (ref arg; args) {
        arg = line.front.to!(typeof(arg));
        line.popFront();
    }
    assert(line.empty);
}



void fillAll(R, T)(ref R arr, T value) {
    static if (is(typeof(arr[] = value))) {
        arr[] = value;
    }
    else {
        foreach (ref e; arr) {
            fillAll(e, value);
        }
    }
}

Measured memory_bytes: 256
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Numerics;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using static System.Math;

public static class P
{
    public static void Main()
    {
        var nq = Console.ReadLine().Split().Select(int.Parse).ToArray();
        var n = nq[0];
        var q = nq[1];
        Queue<Tuple<string, int>> queue = new Queue<Tuple<string, int>>();
        for (int i = 0; i < n; i++)
        {
            var data = Console.ReadLine().Split();
            queue.Enqueue(new Tuple<string, int>(data[0], int.Parse(data[1])));
        }
        int elapsed = 0;
        while (0 < queue.Count)
        {
            var elem = queue.Dequeue();
            var time = Min(elem.Item2, q);
            elapsed += time;
            if (time == elem.Item2)
            {
                Console.WriteLine($"{elem.Item1} {elapsed}");
            }
            else
            {
                queue.Enqueue(new Tuple<string, int>(elem.Item1, elem.Item2 -  time));
            }
        }
    }
}



Measured memory_bytes: 25508
#include <bits/stdc++.h>
using namespace std;
#define mp(a, b) make_pair(a, b)
typedef long long ll;
typedef pair<int, int> pii;
const int maxn = 2e5 + 10;
int n, m, ans;
int fa[maxn], siz[maxn];
int getfa(int x) { return x == fa[x] ? x : fa[x] = getfa(fa[x]);}
int main()
{
	scanf("%d%d", &n, &m);
	for(int i = 1; i <= n; ++i) fa[i] = i, siz[i] = 1;
	for(int i = 1; i <= m; ++i)
	{
		int u, v;
		scanf("%d%d", &u, &v);
		u = getfa(u), v = getfa(v);
		if(u == v) continue;
		fa[u] = v;
		siz[v] += siz[u];
	}
	for(int i = 1; i <= n; ++i) if(getfa(i) == i) ans = max(ans, siz[i]);
	cout << ans << endl;	
	return 0;
}

Measured memory_bytes: 11416
/**
       **********    ************
	  Author : Avi J Patel
	  University : DA-IICT
       **********    ************
**/
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define pb push_back
#define pf push_front
#define mp make_pair 
#define mt make_tuple
#define ff first
#define ss second
#define si size()
#define MOD 1000000007
#define Mod 998244353
#define N 200001
#define large 10000000000000001
#define For(i,m,n) for(long long i=m;i<n;i++)
#define st(x) sort(x.begin(),x.end())
#define re(x,i) reverse(x.begin()+i,x.end())
#define FAST ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);srand(time(NULL));
bool sortbysec(const pair<int,int> &a, 
              const pair<int,int> &b) 
{ 
    if(a.second < b.second) return true; 
    else if(a.ss==b.ss) return a.ff<b.ff;
	else return false;
}
bool sortbyboth(const pair<int,int> &a, const pair<int,int> &b)
{
	if(a.first<b.first) return true;
	else if(a.first==b.first) return a.second<b.second;
	else return false;
}
int main()
{
	int n;
	cin>>n;
	string s;
	cin>>s;
	int cnt=0;
	for(int i=0;i<n-1;i++)
	{
		if(s[i]!=s[i+1])
		cnt++;
	}
	cout<<cnt+1;
	return 0;
}















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

using namespace std;

void output(vector<int> v) {
  int n = v.size();

  for (int i = 0; i < n; i++) {
    if (i)
      cout << " ";
    cout << v[i];
  }
  cout << endl;
}

vector<int>::reverse_iterator next_element(int ref, vector<int>::reverse_iterator begin,
                                           vector<int>::reverse_iterator end) {
  int min=1000000;
  auto next_itr = begin;
  for (auto itr = begin; itr != end; itr++) {
    if (*itr > ref && *itr < min) {
      min = *itr;
      next_itr = itr;
    }
  }
  return next_itr;
}

vector<int>::reverse_iterator prev_element(int ref, vector<int>::reverse_iterator begin,
                                           vector<int>::reverse_iterator end) {
  int max = 0;
  auto prev_itr = begin;
  for (auto itr = begin; itr != end; itr++) {
    if (*itr<ref&& * itr> max) {
      max = *itr;
      prev_itr = itr;
    }
  }
  return prev_itr;
}

bool next_permutation(vector<int>& pv) {
  for (auto itr = pv.rbegin(); next(itr, 1) != pv.rend(); itr++) {
    if (*next(itr, 1) < *itr) {
      iter_swap(next_element(*next(itr), pv.rbegin(), next(itr)), next(itr, 1));
      sort(pv.rbegin(), next(itr), greater<int>());
      return 1;
    }
  }
  return 0;
}

bool prev_permutation(vector<int>& pv) {
  for (auto itr = pv.rbegin(); next(itr, 1) != pv.rend(); itr++) {
    if (*next(itr, 1) > *itr) {
      iter_swap(prev_element(*next(itr), pv.rbegin(), next(itr)), next(itr, 1));
      sort(pv.rbegin(), next(itr), less<int>());
      return 1;
    }
  }
  return 0;
}

int main() {
  ios::sync_with_stdio(false);

  int n;
  cin >> n;

  vector<int> pv(n), v(n), nv(n);

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

  pv = v;
  if (prev_permutation(pv) == true) {
    output(pv);
  }

  output(v);
  nv = v;
  if (next_permutation(nv) == true) {
    output(nv);
  }

  return 0;
}



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

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

    static class BTimeLimitExceeded {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int n = in.nextInt();
            int maxT = in.nextInt();

            int answer = Integer.MAX_VALUE;
            for (int i = 0; i < n; i++) {
                int c = in.nextInt(), t = in.nextInt();
                if (t <= maxT) {
                    answer = Math.min(c, answer);
                }
            }

            if (answer == Integer.MAX_VALUE)
                out.println("TLE");
            else
                out.println(answer);
        }

    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

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

    }
}



Measured memory_bytes: 21588
#include<bits/stdc++.h>
using namespace std;
int a[10005],N,ans1,ans;
bool qh;
int main()
{
	cin>>N;
	for(int i=1;i<=N;i++)cin>>a[i];
	sort(a+1,a+N+1);
	for(int i=N+1;i>0;i--)
	{
		
		if(qh==0){ans1+=a[i];qh=1;}
		else {ans+=a[i];qh=0;}
	}
	cout<<ans-ans1<<endl;

    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

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

		int a = stdIn.nextInt();
		int b = stdIn.nextInt();

		if (a > 9 || b > 9) {
			System.out.println("-1");
			return;
		}

		System.out.println(a * b);
		return;
	}
}

Measured memory_bytes: 22996
package main

import (
	"fmt"
	"math"
	"strconv"
)

func solve(a, b int) string {
	m := math.Abs(float64((a - b) % 2))
	if m > 0 {
		return "IMPOSSIBLE"

	}
	ans := ((a - b) / 2) + b
	return strconv.Itoa(ans)
}

func main() {
	var a, b int
	fmt.Scan(&a, &b)

	fmt.Println(solve(a, b))
}


Measured memory_bytes: 512
object Main {
  def main(args: Array[String]): Unit = {
    val lines = io.Source.stdin.getLines().toArray
    println(D.solve(lines))
  }
}

object D {
  val ACGT = List('A', 'C', 'G', 'T')
  val modulus = 1000 * 1000 * 1000 + 7


  def solve(input: Array[String]) = {
    var memo = initMemo()
    val N = input(0).toInt
    (3 to N).foreach { n =>
      memo  = memo ++ Array(forward(memo(n-1)))
    }
    memo(N).values.reduce { (src, dst) =>
      (src + dst) % modulus
    }
  }

  def initMemo() = {
    var memo: Array[Map[String, Int]] = Array(Map.empty, Map.empty, Map.empty)
    //memo(2) = ACGT.combinations(2).flatMap { cs =>
    //  Map(cs.mkString("") -> 1, cs.reverse.mkString("") -> 1)
    //}.toMap
    memo(2) = ACGT.flatMap { c1 =>
      ACGT.map { c2 =>
        f"$c1$c2" -> 1
      }
    }.toMap
    memo
  }


  def forward(currentMemo: Map[String, Int]) = {
    var nextMemo = Map[String, Int]().withDefaultValue(0)
    currentMemo.keys.foreach { last =>
      ACGT.foreach { c =>
        if (isOK(last + c)) {
          val nextLast = last.takeRight(3) + c
          val added = (nextMemo(nextLast) + currentMemo(last)) % modulus
          val newItem = (nextLast) -> added
          nextMemo += newItem
        } else {
          //println(s"out!${last + c}")
        }
      }
    }
    nextMemo
  }

  def isOK(last: String) = {
    unContainsAGC(last) &&
      (0 until last.length-1).forall { i =>
        unContainsAGC(swapAdjacent(last, i))
      }
  }

  def unContainsAGC(s: String) = {
    !s.contains("AGC")
  }

  def swapAdjacent(last: String, idx: Int) = {
    val sArray = last.toArray
    val tmp = sArray(idx)
    sArray.update(idx, sArray(idx+1))
    sArray.update(idx+1, tmp)
    sArray.mkString("")
  }
}

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

using namespace std;

struct Trade {
    int taro, hanako;
    bool operator<(const Trade &r) const {
        return taro + hanako < r.taro + r.hanako;
    }
};

int main() {

    int n, m;

    while(cin >> n >> m, n | m) {

        int taro[n + 1], hanako[m + 1];
        taro[n] = hanako[m] = 0;

        vector<Trade> trade;

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

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

        for(int i = 0; i < n; ++i) {
            for(int j = 0; j < m; ++j) {
                if(taro[n] - taro[i] + hanako[j] == hanako[m] - hanako[j] + taro[i]) {
                    trade.push_back((Trade){taro[i], hanako[j]});
                }
            }
        }

        if(trade.size() > 0) {
            sort(trade.begin(), trade.end());
            cout << trade[0].taro << " " << trade[0].hanako << endl;
        } else {
            cout << -1 << endl;
        }


    }

}

Measured memory_bytes: 1348
#include <iostream>
#include <iomanip>
#include <cmath>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <numeric>
#include <random>
#include <algorithm>
#include <functional>

using namespace std;
typedef long long ll;

const int INF = (1 << 30) - 1;
const ll INFLL= (1LL << 61) - 1;
const int MOD = 1000000007;
#define ALL(a) (a).begin(),(a).end()
#define rALL(a) (a).rbegin(),(a).rend()
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)

int main(){
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  int N;
  cin>>N;
  bool flag=false;
  REP(i,10){
    REP(j,10){
      if(i*j==N){
        flag=true;
      }
    }
  }
  if(flag){
    cout<<"Yes"<<endl;
  }else{
    cout<<"No"<<endl;
  }
}


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

int main(){
  int n,a[9],b,count=0;
  r(i,9)a[i]=0;
  cin >> n;
  r(i,n){
    cin >> b;
    if(b<3200)a[b/400]++;
    else a[8]++;
  }
  r(i,8)if(a[i]>0)count++;
  cout << max(count,1) << " " << count+a[8]<<endl;
}

Measured memory_bytes: 256
def solve():
  N, K = map(int, input().split())
  H = [int(input()) for _ in range(N)]
  H.sort()
  ans = float('inf')
  for i in range(N):
    if i+K>N:
      break
    ans = min(H[i+K-1]-H[i],ans)
  return ans
print(solve())

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

int main() {
	int n,t;
	cin>>n>>t;
	struct st{
		int num;
		int c;
		int ti;
	};
	st st[n],tmp;
	for(int i=0;i<n;i++){
		cin>>st[i].c>>st[i].ti;
		st[i].num=i+1;
	}
	int min=100000;
	for(int i=0;i<n;i++){
		for(int j=i+1;j<n;j++){
			if(st[i].c>st[j].c){
				tmp=st[i];
				st[i]=st[j];
				st[j]=tmp;
			}
		}
	}
	for(int i=0;i<n;i++){
		if(st[i].ti<=t){
			cout<<st[i].c<<'\n';
		return 0;
		}
	}
	cout<<"TLE"<<'\n';
	return 0;
}

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

const ll INF64 = 1LL << 60;
const int INF32 = 1 << 29;
const int MOD = 1000000007;

// Lib
//

int main(){
#ifdef MYLOCAL
    ifstream in("input.txt");
    cin.rdbuf(in.rdbuf());
#endif
    ll x, y; cin >> x >> y;
    ll res = 1LL<<60;

    if (x <= y) res = min(res, y-x);
    if (-x <= y) res = min(res, y+x+1);
    if (x <= -y) res = min(res, -y-x+1);
    if (-x <= -y) res = min(res, -y+x+2);

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


Measured memory_bytes: 256
#include<bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define HUGE_NUM 99999999999999999
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;


struct Point{

	double x,y;
};

struct Info{

	Point point;
	double length;
};

int N;
Info info[12];


double calc(double X,double Y){

	double ret = BIG_NUM;

	for(int i = 0; i < N; i++){

		ret = min(ret,info[i].length*info[i].length-
				((X-info[i].point.x)*(X-info[i].point.x)+
						(Y-info[i].point.y)*(Y-info[i].point.y)));
	}

	return ret;

}

double thirds_searchY(double X){

	double L = -101,R = 101;

	for(int loop = 0; loop < 100; loop++){

		double mid1 = (2.0*L+R)/3.0;
		double mid2 = (1.0*L+2.0*R)/3.0;

		if(calc(X,mid1) > calc(X,mid2)){

			R = mid2;
		}else{

			L = mid1;
		}
	}

	return calc(X,(L+R)/2);
}

double thirds_searchX(){

	double L = -101,R = 101;

	for(int loop = 0; loop < 100; loop++){

		double mid1 = (2.0*L+R)/3.0;
		double mid2 = (1.0*L+2.0*R)/3.0;

		if(thirds_searchY(mid1) > thirds_searchY(mid2)){

			R = mid2;
		}else{

			L = mid1;
		}
	}

	return thirds_searchY((L+R)/2);
}

void func(){

	for(int i = 0; i < N; i++){

		scanf("%lf %lf %lf",&info[i].point.x,&info[i].point.y,&info[i].length);
	}

	printf("%.10lf\n",sqrt(thirds_searchX()));
}

int main(){

	while(true){

		scanf("%d",&N);
		if(N == 0)break;

		func();

	}

	return 0;
}



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

int main(){
  string s,t;
  cin >> s >> t;
  if(s[0] == t[2] && s[1] == t[1] && s[2] == t[0]){
    cout << "YES";
  }else{
    cout << "NO";
  }
}

Measured memory_bytes: 3612
import java.util.Scanner;

//Cubic Eight-Puzzle
public class Main{

	int[] top = {0, 0, 1, 1, 2, 2, 3};
	int[][] d = {{-1,0},{0,1},{1,0},{0,-1}};
	int[][] adj = {
			{2, 5, 2, 5},
			{4, 3, 4, 3},
			{0, 4, 0, 4},
			{5, 1, 5, 1},
			{1, 2, 1, 2},
			{3, 0, 3, 0}
	};

	int[][] goal, state;
	boolean dfs(int ei, int ej, int depth, int limit, int pre){
		int dif = 0;
		for(int i=0;i<3;i++)for(int j=0;j<3;j++)dif+=top[state[i][j]]!=goal[i][j]?1:0;
		if(dif==0)return true;
		if(limit<depth)return false;
		if(limit<depth+dif-1)return false;
		for(int k=0;k<4;k++){
			if(pre==(k+2)%4)continue;
			int ni = ei+d[k][0], nj = ej+d[k][1];
			if(0<=ni&&ni<3&&0<=nj&&nj<3){
				state[ei][ej] = adj[state[ni][nj]][k]; state[ni][nj] = 6;
				if(dfs(ni, nj, depth+1, limit, k))return true;
				state[ni][nj] = adj[state[ei][ej]][k]; state[ei][ej] = 6;
			}
		}
		return false;
	}

	void run(){
		Scanner sc = new Scanner(System.in);
		for(;;){
			int x = sc.nextInt(), y = sc.nextInt();
			if((x|y)==0)break;
			goal = new int[3][3];
			for(int i=0;i<3;i++)for(int j=0;j<3;j++){
				char c = sc.next().charAt(0);
				goal[i][j] = c=='W'?0:c=='R'?1:c=='B'?2:3;
			}
			state = new int[3][3];
			state[y-1][x-1] = 6;
			int res = -1;
			for(int L=0;L<=30;L++){
				if(dfs(y-1, x-1, 0, L, -1)){
					res = L; break;
				}
			}
			System.out.println(res);
		}
	}

	public static void main(String[] args) {
		new Main().run();
	}
}

Measured memory_bytes: 0
using System;
using System.Linq;

namespace _018_SortingFiveNumbers
{
	class Program
	{
		static void Main ( string[] args )
		{
			int[] inputArray = Console.ReadLine ().Split (' ').Select (str => int.Parse (str)).ToArray ();

			Array.Sort (inputArray, ( item, item2 ) => item2 - item);

			Console.Write (inputArray[0] + " ");
			Console.Write (inputArray[1] + " ");
			Console.Write (inputArray[2] + " ");
			Console.Write (inputArray[3] + " ");
			Console.WriteLine (inputArray[4]);
		}
	}
}

Measured memory_bytes: 9556
#include <stdio.h>
#include <unistd.h>
#include <stdlib.h>
#include <string.h>
#include <stdarg.h>
#include <fcntl.h>

int main()
{
	int n;
	int a;
	int ans;
	
	scanf("%d", &n);
	n -= 1;
	a = 1;
	ans = 0;
	while (n >= a)
	{
		ans += n / a;
		a++;
	}
	printf("%d\n", ans);
	return (0);
}

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

struct UnionFind {
    vector<int> par;

    UnionFind(int N) : par(N) {
        for(int i = 0; i < N; i++) par[i] = i;
    }

    int root(int x) {
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }

    void unite(int x, int y) {
        int rx = root(x);
        int ry = root(y);
        if (rx == ry) return;
        par[rx] = ry; 
    }

    bool same(int x, int y) {
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
};

int main(){
	int N, M; cin >> N >> M;

    UnionFind tree(N);
	
	int X, Y, Z;
	while(cin >> X >> Y >> Z){
		tree.unite( X-1, Y-1 );
	}
	
	set<int> ans;
	
	for( int i = 0; i < N; i++ ){
		ans.insert(tree.root(i));
	}
	
	cout << ans.size() << endl;
}

Measured memory_bytes: 5376
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <cmath>
#include <cstring>
#include <iomanip>
#include <random>
#include <chrono>
#include <queue>
using namespace std;
typedef long long ll;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;
#define INF 1000000000
#define MOD 1000000007

int main(){
    ll N, W; cin >> N >> W;
    vector<ll> c(N);
    vector<ll> v(N);
    for(int i=0; i<N; i++)
        cin >> c[i] >> v[i];
    vector<vector<ll>> dp(N+1, vector<ll>(W+1));
    
    for(int i=0; i<N; i++){
        for(int j=0; j<W+1; j++){
            if(j-c[i]>=0) dp[i+1][j] = max(dp[i][j-c[i]] + v[i], dp[i][j]);
            else dp[i+1][j] = dp[i][j];
        }
    }
    cout << dp[N][W] << endl;
    return 0;
}


Measured memory_bytes: 80256
package main

import (
	"fmt"
)

func isMultiplicationTable(x int) string {
	multiplicationTableNumbers := make(map[int]bool)

	for i := 1; i < 10; i++ {
		for j := 1; j < 10; j++ {
			if !multiplicationTableNumbers[i*j] {
				multiplicationTableNumbers[i*j] = true
			}
		}
	}
	if multiplicationTableNumbers[x] {
		return "Yes"
	}
	return "No"
}

func main() {
	var a int
	fmt.Scan(&a)
	fmt.Println(isMultiplicationTable(a))
}


Measured memory_bytes: 512
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long; 
using pii =  pair<int, int>;
using pll =  pair<long long, long long>;
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()
constexpr char ln =  '\n';
constexpr long long MOD = 1000000007LL;
//constexpr long long MOD = 998244353LL;
template<class T, class U> inline bool chmax(T &a, U b) { if (a < b) { a = b; return true;} return false; }
template<class T, class U> inline bool chmin(T &a, U b) { if (a > b) { a = b; return true;} return false; }
////////////////////////////////////////////////////////////////////////////////////////////////////////////

int main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
    int A,B,K; cin >> K >> A >> B;
    for (int i = A; i <= B; i++) {
        if (i%K==0) {
            cout << "OK" << ln;
            return 0;
        }
    }

    cout << "NG" << ln;
}

Measured memory_bytes: 3640
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

    public static void main(String[] args) throws IOException {
        MyReader reader = new MyReader();
        int k = reader.readInt();
        int[] ab = reader.readInts(" ");
        System.out.println(problem165a(k, ab[0], ab[1]));
    }

    private static String problem165a(int k, int a, int b) {
        for (int i = a; i <= b; i++) {
            if (i % k == 0) return "OK";
        }
        return "NG";
    }

    private static class MyReader {
        private final BufferedReader br;
        private MyReader() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        private String readString() throws IOException {
            return br.readLine();
        }

        private int readInt() throws IOException {
            return Integer.parseInt(readString());
        }

        private String[] readStrings(String regex) throws IOException {
            return readString().split(regex);
        }

        private int[] readInts(String regex) throws IOException {
            String[] strings = readStrings(regex);
            int[] ints = new int[strings.length];
            for (int i = 0; i < ints.length; i++) {
                ints[i] = Integer.parseInt(strings[i]);
            }
            return ints;
        }
    }
}

Measured memory_bytes: 25344
#include<stdio.h>
#include<stdlib.h>
#include<stdint.h>
#include<inttypes.h>

typedef int32_t i32;
typedef uint64_t u64;
typedef uint32_t u32;

void run (void) {
  i32 n;
  scanf ("%" SCNi32, &n);
  i32 *a = (i32 *) calloc (n, sizeof (i32));
  i32 sum = 0;
  for (i32 i = 0; i < n; ++i) {
    scanf ("%" SCNi32, a + i);
    sum += a[i];
  }
  const u32 b = sizeof (u64) * 8;
  const i32 len = (sum + b - 1) / b;
  u64 *dp = (u64 *) calloc (len + 1, sizeof (u64));
  dp[0] = 1;
  for (i32 i = 0; i < n; ++i) {
    const u32 v = a[i];
    u32 p = v / b;
    u32 q = v % b;
    if (q == 0) {
      for (i32 j = len - 1 - p; j >= 0; --j) {
        dp[j + p] |= dp[j];
      }
    } else {
      for (i32 j = len - 1 - p; j >= 0; --j) {
        u64 y = dp[j];
        dp[j + p] |= y << q;
        dp[j + p + 1] |= y >> (b - q);
      }
    }
  }
  i32 m = (sum + 1)/ 2;
  while (((dp[m / b] >> (m % b)) & 1) == 0) m++;
  printf ("%" PRIi32 "\n", m);
}

int main (void) {
  run ();
  return 0;
}


Measured memory_bytes: 640
#include <iostream>

int main() {
	char ch;
	int counter[26] = { 0 };
	while (std::cin >> ch) {
		if (static_cast<bool>(isupper(ch))) {
			ch = static_cast<int>(tolower(ch));
		}
		int num = ch - 'a';
		counter[num]++;
	}
	for (int i = 0; i < 26; i++) {
		char word = i + 'a';
		std::cout << word << " " << ":" << " " << counter[i] << std::endl;
	}
}

Measured memory_bytes: 3092
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#include <set>
#include <math.h>
#define pai 3.14159265358979323846264338327950288;
#define keta(n) cout << fixed << setprecision((n));
using ll = long long;
int main()
{
  string s;
  cin>>s;
  for(int i=0;i<s.size();i=i+2){
    cout<<s[i];
  }
 
}

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

int n;
long long p, q;
long long c[500000];

int main()
{
	scanf("%d %lld %lld", &n, &p, &q);
	for (int i = 0; i < n; i++){
		scanf("%lld", c + i);
	}
	
	long long add = 0;
	for (int i = 0; i < n; i++){
		c[i] += i * p;
		add += i * p;
	}
	
	sort(c, c + n);
	
	long long sum = 0;
	for (int i = 0; i < n; i++){
		sum += c[i];
	}
	
	long long res = sum;
	for (int i = 0; i < n; i++){
		sum -= c[i];
		sum += (q + i * 2) * p;
		res = max(res, sum);
	}
	
	printf("%lld\n", res - add);
	
	return 0;
}

Measured memory_bytes: 5108
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <cstring>
#include <cstdlib>
#include <math.h>
#include <vector>
#include <queue>
#include <stack>
#include <set>
#include <time.h>
#define ll long long
#define ull unsigned long long
#define rep( i, a, n ) for( int i = a; i < n; i++ )
#define per( i, a, n ) for( int i = n - 1; i >= a; i-- )
#define mem( f, x ) memset( f, x, sizeof( f ) )
#define pii pair<int, int>
#define pll pair<ll, ll>
#define fi first
#define se second
#define MOD 9901
#define INF 0x3f3f3f3f
#define e 2.71828
using namespace std;
const int N = 26;
const int M = 2*1e5 + 10;
const int MAX = 4*1e6 + 10;
const ull inv = 500000004;
const double g = 9.80;
const double PI = acos( -1.0 );
vector<int> v[26];
int cnt[N];
char s1[M], s2[M];

int main(){
    while( scanf( "%s %s", s1, s2 ) != EOF ){
        for( int i = 0; i < N; i++ ) v[i].clear();
        mem( cnt, 0 );
        for( int i = 0; s2[i]; i++ ){
            v[s2[i]-'a'].push_back( i );
            cnt[s1[i]-'a']++;
        }

        /*for( int i = 0; i < N; i++ ){
            if( v[i].size() ){
                printf( "%c:\n", 'a' + i );
                for( int j = 0; j < v[i].size(); j++ )
                    cout << v[i][j] << " ";
                cout << endl;
            }
        }*/
        bool flag = 0;
        for( int i = 0; i < N; i++ ){
            if( flag ) break;
            if( v[i].size() > 0 ){
                int tmp = v[i][0];
                if( cnt[s1[tmp]-'a'] != v[i].size() ){
                    flag = 1;
                    break;
                }
                for( int j = 1; j < v[i].size(); j++ ){
                    if( s1[tmp] != s1[v[i][j]] ){
                        flag = 1;
                        break;
                    }
                }
            }
        }
        if( !flag ) puts( "Yes" );
        else puts( "No" );
    }
    return 0;
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
vector<long long int> st;
vector<long long int> temp;
int main()
{
    long long int n,j,k,ans,curr,rose,now;
    int s,t,q,i,x,y;
    int next,prev;
    scanf("%d %d %d",&s,&t,&q);
    for(i=0;i<s;i++)
    {
        scanf("%lld",&curr);
        st.push_back(curr);
    }
    sort(st.begin(),st.end());
    for(i=0;i<t;i++)
    {
        scanf("%lld",&curr);
        temp.push_back(curr);
    }
    sort(temp.begin(),temp.end());
    int statue = st.size();
    int temple = temp.size();
    while(q--)
    {
        rose = 1e18;
        scanf("%lld",&curr);
        x = upper_bound(st.begin(),st.end(),curr) - st.begin();
        if(x == 0)
            x++;
        next = x;
        ans = 0;
        ans += abs(curr-st[next-1]);
        now = st[next-1];
        y = upper_bound(temp.begin(),temp.end(),now) - temp.begin();
        if(y == 0)
            y++;
        rose = min(rose, ans+abs(now-temp[y-1]));
        if(y != temple)
        {
            rose = min(rose,ans+abs(now-temp[y]));
        }
        if(next != statue)
        {
            next++;
            ans = 0;
            ans += abs(curr-st[next-1]);
            now = st[next-1];
            y = upper_bound(temp.begin(),temp.end(),now) - temp.begin();
            if(y == 0)
                y++;
            rose = min(rose, ans+abs(now-temp[y-1]));
            if(y != temple)
            {
                rose = min(rose,ans+abs(now-temp[y]));
            }
        }

        x = upper_bound(temp.begin(),temp.end(),curr) - temp.begin();
        if(x == 0)
            x++;
        next = x;
        ans = 0;
        ans += abs(curr-temp[next-1]);
        now = temp[next-1];
        y = upper_bound(st.begin(),st.end(),now) - st.begin();
        if(y == 0)
            y++;
        rose = min(rose,ans+abs(now-st[y-1]));
        if(y != statue)
        {
            rose = min(rose,ans+abs(now-st[y]));
        }
        if(next != temple)
        {
            next++;
            ans = 0;
            ans += abs(curr-temp[next-1]);
            now = temp[next-1];
            y = upper_bound(st.begin(),st.end(),now) - st.begin();
            if(y == 0)
                y++;
            rose = min(rose, ans+abs(now-st[y-1]));
            if(y != statue)
            {
                rose = min(rose,ans+abs(now-st[y]));
            }
        }
        printf("%lld\n",rose);
    }
    return 0;
}


Measured memory_bytes: 3060
import java.util.*;

public class Main {
	Scanner sc = new Scanner(System.in);
	void doIt() {
		int n = sc.nextInt();
		int max = 0;
		int sum = 0;
		for(int i = 0; i < n; i++) {
			int p = sc.nextInt();
			sum += p;
			if(max < p) max = p;
		}
		System.out.println(sum - max / 2);
	}
	Main(){doIt();}
	public static void main(String[] args) {
		new Main();
	}

}


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

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

    int a,b;
  	int cnt = 0 , ans = 0 ;
    for ( int i = 1 ; i <= N ; i++ ){
       cnt = 0;
       if ( i%2 == 0 ) continue;
       for ( int j = 1 ; j <= i ; j++ ){
         if ( i % j == 0 ){
        	a = j;
          	b = i/j;
          	if( a < b) cnt++;
         } 
       }
       if ( cnt == 4 ) {
       ans++;
       //cout << i << endl;
	    }  
    }
  	cout << ans << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<cmath>
using namespace std;
int main(){
	int n,k,i,j;
	cin>>n>>k;
	int a[n+1][k+1];
	for(i=1;i<=n;i++){
		for(j=1;j<=k;j++){
			cin>>a[i][j];
		}
	}
	int ans=0;
	double c;
	for(i=1;i<=n;i++){
		for(j=i+1;j<=n;j++){
			c=0;
			for(int kk=1;kk<=k;kk++){
				c+=(a[i][kk]-a[j][kk])*(a[i][kk]-a[j][kk]);
			}
			c=sqrt(c);
			if(int (sqrt(c*c))==c) ans++;
		}
	}
	cout<<ans;
	
	return 0;	
}

Measured memory_bytes: 256
#include<stdio.h>

int main(void)
{
  int n;
  char s[110];
  scanf("%d%s",&n,s);

  int i,j,a,b,ans=0,cnt;
  char c;
  for(i=1;i<n;i++){
    cnt=0;
    for(c='a';c<='z';c++){
      a = 0;  b = 0;
      for(j=0;j<i;j++){
        if(s[j]==c)
          a = 1;
      }
      for(j=i;j<n;j++){
        if(s[j]==c)
          b = 1;
      }
      if((a==1)&&(b==1))
        cnt++;
    }
    if(ans<cnt)
      ans = cnt;
  }

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


Measured memory_bytes: 1720
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools

sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**13
mod = 10**9+7
dd = [(-1,0),(0,1),(1,0),(0,-1)]
ddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)


def main():
    rr = []

    def f(w,h):
        a = ['x'*(w+2)] + ['x' + S() + 'x' for _ in range(h)] + ['x'*(w+2)]
        e = collections.defaultdict(list)
        st = None
        dst = []
        for i in range(1,h+1):
            for j in range(1,w+1):
                if a[i][j] == 'x':
                    continue
                if a[i][j] == 'o':
                    st = (i,j)
                elif a[i][j] == '*':
                    dst.append((i,j))
                for di,dj in dd:
                    if a[i+di][j+dj] == 'x':
                        continue
                    e[(i,j)].append(((i+di,j+dj), 1))

        def search(s):
            d = collections.defaultdict(lambda: inf)
            d[s] = 0
            q = []
            heapq.heappush(q, (0, s))
            v = collections.defaultdict(bool)
            while len(q):
                k, u = heapq.heappop(q)
                if v[u]:
                    continue
                v[u] = True

                for uv, ud in e[u]:
                    if v[uv]:
                        continue
                    vd = k + ud
                    if d[uv] > vd:
                        d[uv] = vd
                        heapq.heappush(q, (vd, uv))

            return d

        sd = search(st)
        for ds in dst:
            if sd[ds] == inf:
                return -1

        dsd = [search(ds) for ds in dst]
        l = len(dst)
        r = inf
        for ta in itertools.permutations(range(l)):
            t = sd[dst[ta[0]]]
            for i in range(l-1):
                t += dsd[ta[i]][dst[ta[i+1]]]
            if r > t:
                r = t

        return r

    while 1:
        n,m = LI()
        if n == 0 and m == 0:
            break
        rr.append(f(n,m))
        # print('rr', rr[-1])

    return '\n'.join(map(str,rr))


print(main())



Measured memory_bytes: 9460