akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#pragma GCC optimize("O3")
 
using namespace std;
using namespace __gnu_pbds;
 
template<typename T> using ordered_set = tree <T, null_type, less <T>, rb_tree_tag, tree_order_statistics_node_update>;
template<typename T> using MinPriorityQueue = priority_queue <T, vector <T>, greater <T>>;
 
#ifdef HOME
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template < typename Arg1 >
void __f(const char* name, Arg1&& arg1) {
    cout << name << " : " << arg1 << std :: endl;
}
template < typename Arg1, typename... Args >
void __f(const char* names, Arg1&& arg1, Args&&... args) {
    const char* comma = strchr(names + 1, ',');
    int len = comma - names;
    for (int i = 0; i < len; ++i) {
        cout << names[i];
    }
    cout <<  " : " << arg1 << " | ";
    __f(comma + 1, args...);
}
#else
#define trace(...)
#endif
 
typedef double db;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;
typedef vector<ll> vll;
typedef vector<int> vi;
typedef complex<double> com;
 
#define eb emplace_back
#define pb push_back
#define F first
#define S second
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define unique_sort(x) (sort(x.begin(), x.end()), x.resize(distance(x.begin(), unique(x.begin(), x.end()))))
#define fast_io() ios_base :: sync_with_stdio(0); cin.tie(0); cout.tie(0)
 
const ll LINF = LLONG_MAX, SZ = 1e3, MOD = 1e9 + 7, N = 1e5 + 5, M = 1e3 + 5, LG = 21;
const int INF = INT_MAX;
const db PI = acos(-1), EPS = 1e-6;
mt19937_64 rang(chrono::high_resolution_clock::now().time_since_epoch().count()); 
void test() {
    int h,n;
    cin >> h >> n;
    int a[n],b[n];
    int dp[h+5];
    for(int i = 0; i <= h; i++) dp[i] = INF;
    dp[0] = 0;
    for(int i = 0; i < n; i++)
    {
        cin >> a[i] >> b[i];
        for(int j = 0; j <= h; j++)
        {
            dp[j] = min(dp[j],dp[max(0,j-a[i])]+b[i]); 
        }
    }
    cout << dp[h] << "\n";
}
 
int main() {
    fast_io();
    // #ifndef ONLINE_JUDGE
    //     freopen("input.txt", "r", stdin);
    //     freopen("output.txt", "w", stdout);
    // #endif
    cout << fixed << setprecision(15);
    int t = 1;
    // cin >> t;
    for (int i = 0; i < t; ++i) {
        test();
    }
    #ifdef HOME
        cout << "Time: " << (int)(clock() * 1000. / CLOCKS_PER_SEC) << "ms";
    #endif
    return 0;
}

Measured memory_bytes: 256
from __future__ import division, print_function
from sys import stdin
cards = [True] * 52
suits = {'S': 13*0, 'H': 13*1, 'C': 13*2, 'D': 13*3}
for _ in range(int(stdin.readline())):
    s, i = stdin.readline().split()
    cards[suits[s] + int(i) - 1] = False
for i, f, in enumerate(cards):
    if f:
        print('SHCD'[i//13], i % 13 + 1)

Measured memory_bytes: 4232
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;
using ll = long long;

int main() {
  ll n;
  cin >> n;
  vector<ll> veca(n), vecb(n), vecc(n);
  for (auto &v : veca) {
    ll tmp;
    cin >> tmp;
    v = - tmp;
  }
  for (auto &v : vecb)
    cin >> v;
  for (auto &v : vecc)
    cin >> v;

  sort(veca.begin(), veca.end());
  sort(vecb.begin(), vecb.end());
  sort(vecc.begin(), vecc.end());

  ll ans = 0;
  for (auto &v : vecb) {
    ll a = vecc.end() - upper_bound(vecc.begin(), vecc.end(), v);
    ll b = veca.end() - upper_bound(veca.begin(), veca.end(), -v);
    ans += a * b;
  }
  cout << ans << endl;
}

Measured memory_bytes: 5632
#include<bits/stdc++.h>
#define llu unsigned long long
#define ll long long
#define INF 0x3f3f3f3f
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define endl "\n"

using namespace std;

int main()
{
	fast
	string s;
	cin>>s;
	if(s[2]==s[3] && s[4]==s[5])
		cout<<"Yes"<<endl;
	else
		cout<<"No"<<endl;
}

Measured memory_bytes: 256
import sys
from itertools import accumulate
input = sys.stdin.readline
def inputs():return [int(x) for x in input().split()]
H,W = inputs()
meiro = [tuple(input()) for i in range(H)]
#print(meiro)
imosw = [[0]*(W) for _ in range(H)]
imosh = [[0]*(H) for _ in range(W)]
for i in range(H):
    cnt=0
    for j in range(W):
        if meiro[i][j]=="#":
            if cnt!=0:
                imosw[i][j]-=cnt
                imosw[i][j-cnt]+=cnt
            cnt = 0
        else:
            cnt+=1
    if cnt!=0:
    	imosw[i][W-1-cnt+1]+=cnt
    imosw[i][:]=list(accumulate(imosw[i]))
for j in range(W):
    cnt= 0
    imos=[0]*H
    for i in range(H):
        if meiro[i][j]=="#":
            if cnt!=0:
                imos[i]-=cnt
                imos[i-cnt]+=cnt
            cnt = 0
        else:
            cnt+=1
    if cnt!=0:
    	imos[H-1-cnt+1]+=cnt
    imosh[j]=list(accumulate(imos))
    #print(imosh[j])
ans = 0
for i in range(H):
  for j in range(W):
    ans = max(ans,imosw[i][j]+imosh[j][i]-1)
print(ans)

Measured memory_bytes: 406236
#include <iostream>
#include <vector>
#include <string>
#include <tuple>

std::vector<std::tuple<std::string, int>> round_robin(std::vector<std::tuple<std::string, int>> ary, int q) {
    int element_num = ary.size();
    int elapsed_time = 0;
    std::vector<std::tuple<std::string, int>> result;
    result.reserve(ary.size());
    while(element_num) {
        int n = element_num;
        element_num = 0;
        for(int i = 0; i < n; i++) {
            int& rest = std::get<1>(ary[i]);
            if(rest) {
                if(rest > q) {
                    rest -= q;
                    elapsed_time += q;
                    ary[element_num++] = std::tuple<std::string, int>(std::get<0>(ary[i]), rest);
                } else {
                    elapsed_time += rest;
                    rest = 0;
                    result.push_back(std::tuple<std::string, int>(std::get<0>(ary[i]), elapsed_time));
                }
            }
        }
    }
    return result;
}


int main(int argc, char const* argv[])
{
    int n, q;
    scanf("%d %d", &n, &q);
    std::vector<std::tuple<std::string, int>> ary(n);
    for(auto& i: ary) {
        std::cin >> std::get<0>(i);
        std::cin >> std::get<1>(i);
    }
    auto result = round_robin(ary, q);
    for(int i = 0; i < result.size() - 1; i++) {
        std::cout << std::get<0>(result[i]) << " ";
        std::cout << std::get<1>(result[i]) << std::endl;
    }
    std::cout << std::get<0>(result[result.size()-1]) << " ";
    std::cout << std::get<1>(result[result.size()-1]) << std::endl;
    return 0;
}

Measured memory_bytes: 7692
while 0 != data = gets.to_i do
	under = Array.new(data+1){0}
	data.times do
		sum = 0
		num = gets.split(" ").map!(&:to_i)
		num.each_with_index do |x,i|
			printf "%5d",x
			sum = sum + x
			under[i] += x
		end
		under[data] += sum
		printf "%5d",sum
		puts ""
	end
	under.each do |x|
		printf "%5d",x
	end
	puts ""
end

Measured memory_bytes: 6128
#include <stdio.h>

static unsigned long int gcd(unsigned int a, unsigned int b) {
    if (a > b) {
        unsigned int temp = a;
        a = b;
        b = temp;
    }

    if (a == 0) {
        return b;
    }

    b = b % a;
    return gcd(b, a);
}

int main(void) {
    unsigned int k;
    scanf("%u", &k);
    unsigned long int sum = 0;
    unsigned int a, b, c;
    for (a = 1; a <= k; a++) {
        for (b = 1; b <= k; b++) {
            for (c = 1; c <= k; c++) {
                sum += gcd(gcd(a, b), c);
            }
        }
    }

    printf("%lu\n", sum);
    return 0;
}

Measured memory_bytes: 1732
import fractions
A, B, C, D = map(int, input().split())
n_C = B // C - (A-1) //C
n_D = B // D - (A-1) //D
n = (C * D) // fractions.gcd(C, D)
n_C_D = B // n - (A-1)// n
print(B-A-n_C-n_D+n_C_D+1)

Measured memory_bytes: 10640
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<n;i++)
using namespace std;
int main(){
    int X,A,B;
    cin>>X>>A>>B;
    if(A>=B)cout<<"delicious"<<endl;
    else if(A+X>=B)cout<<"safe"<<endl;
    else cout<<"dangerous"<<endl;
}

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

# In[15]:


S = list(input())


# In[17]:


if S[0] == S[1]:
    print("Bad")
elif S[1] == S[2]:
    print("Bad")
elif S[2] == S[3]:
    print("Bad")
else:
    print("Good")


# In[ ]:






Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
#define fi first
#define se second
template<typename A, typename B> inline bool chmax(A &a, B b) { if (a<b) { a=b; return 1; } return 0; }
template<typename A, typename B> inline bool chmin(A &a, B b) { if (a>b) { a=b; return 1; } return 0; }
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<int, pii> pip;
typedef pair<pll, pll> P;
const ll INF = 1ll<<29;
const ll MOD = 1000000007;
const double EPS = 1e-9;
const bool debug = 0;
//---------------------------------//

struct LazySegTree {
	vector<ll> node, lazy;
	int n;
	
	LazySegTree(int _n) {
		n = 1;
		while (n < _n) n *= 2;
		
		node.resize(n * 2 - 1, 0);
		lazy.resize(n * 2 - 1, 0);
	}
	
	void eval(int k, int l, int r) {
		if (lazy[k] == 0) return;
		node[k] += lazy[k];
		if (r - l > 1) {
			lazy[k * 2 + 1] += lazy[k];
			lazy[k * 2 + 2] += lazy[k];
		}
		lazy[k] = 0;
	}
	
	void add(int a, int b, ll x, int k = 0, int l = 0, int r = -1) {
		if (r < 0) r = n;
		eval(k, l, r);
		
		if (a >= r || b <= l) return;
		if (a <= l && r <= b) {
			lazy[k] += x;
			eval(k, l, r);
		}
		else {
			add(a, b, x, k * 2 + 1, l, (l + r) / 2);
			add(a, b, x, k * 2 + 2, (l + r) / 2, r);
			node[k] = max(node[k * 2 + 1], node[k * 2 + 2]);
		}
	}
	
	ll query(int a, int b, int k = 0, int l = 0, int r = -1) {
		if (r < 0) r = n;
		eval(k, l, r);
		
		if (a >= r || b <= l) return -1ll<<60;
		if (a <= l && r <= b) return node[k];
		return max( query(a, b, k * 2 + 1, l, (l + r) / 2), query(a, b, k * 2 + 2, (l + r) / 2, r) );
	}
};

int N, M;
int L[212345], R[212345];

int main() {
	cin >> N >> M;
	REP(i, N) scanf("%d %d", L + i, R + i);
	
	vector<pll> v;
	int all = 0;
	
	REP(i, N) {
		if (L[i] + 1 == R[i]) all++;
		else v.push_back(pii(L[i], R[i]));
	}
	sort(ALL(v));
	
	LazySegTree seg(212345);
	REP(i, M + 2) seg.add(i, i + 1, i);
	
	int ans = 0;
	
	REP(i, v.size()) {
		int l = v[i].fi, r = v[i].se;
		
		seg.add(1, r + 1, 1);
		chmax(ans, seg.query(1, M + 2) - (M + 1 + l) );
	}
	
	int c = v.size() - ans; // 座った人数
	ans += max(all - (M - c), 0);
	
	cout << ans << endl;
	
	return 0;
}


Measured memory_bytes: 14188
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#define REP(i, n) for(int i = 0; i < (int)(n); ++i)
using namespace std;
typedef long long ll;

int vs[100000+10];
int inv[100000+10];

int main(void) {
  int n;
  scanf("%d", &n);
  REP(i, n) {
    scanf("%d", &vs[i]);
    inv[vs[i]] = i;
  }
  ll res = 0;
  set<int> ss;
  for(int v = n; v > 0; --v) {
    auto it = ss.lower_bound(inv[v]);
    // 後のでかいの採用
    if(it != ss.end()) {
      ll i1, i2, i3, i4;
      i2 = inv[v];
      i3 = *it;
      if(it == ss.begin()) {
        i1 = -1;
      } else {
        i1 = *--it;
        ++it;
      }
      ++it;
      if(it == ss.end()) {
        i4 = n;
      } else {
        i4 = *it;
      }
      --it;
      // cerr << "R> " << v << ": " << i1 << " " << i2 << " " << i3 << " " << i4 << endl;
      res += (i2-i1) * (i4-i3) * v;
    }
    // 前のでかいの採用
    if(it != ss.begin()) {
      ll i1, i2, i3, i4;
      i3 = inv[v];
      if(it == ss.end()) {
        i4 = n;
      } else {
        i4 = *it;
      }
      i2 = *--it;
      if(it == ss.begin()) {
        i1 = -1;
      } else {
        i1 = *--it;
        ++it;
      }
      // cerr << "L> " << v << ": " << i1 << " " << i2 << " " << i3 << " " << i4 << endl;
      res += (i2-i1) * (i4-i3) * v;
    }
    ss.insert(inv[v]);
  }
  cout << res << endl;
  
  return 0;
}


Measured memory_bytes: 5760
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <vector>
#include <queue>
#include <utility>

using namespace std;
typedef long long ll;
const int LEN = 100000;

struct fastio{
  int it,len;
  char s[LEN + 5];
  fastio(){
    it = len = 0;
  }
  char get(){
    if(it < len) return s[it++];
    it = 0, len = fread(s,1,LEN,stdin);
    return len ? s[it++] : EOF;
  }
  bool notend(){
    char c;
    for(c = get();c == ' ' || c == '\n';c = get());
    if(it) it--;
    return c != EOF;
  }
  void put(char c){
    if(it == LEN) fwrite(s,1,LEN,stdout), it = 0;
    s[it++] = c;
  }
  void flush(){
    fwrite(s,1,it,stdout);
  }
}buff,bufo;
inline int getint(){
  char c; int res = 0, sig = 1;
  for(c = buff.get();c < '0' || c > '9';c = buff.get()) if(c == '-') sig = -1;
  for(;c >= '0' && c <= '9';c = buff.get()) res = res * 10 + (c - '0');
  return sig * res;
}
inline ll getll(){
  char c; ll res = 0, sig = 1;
  for(c = buff.get();c < '0' || c > '9';c = buff.get()) if(c == '-') sig = -1;
  for(;c >= '0' && c <= '9';c = buff.get()) res = res * 10 + (c - '0');
  return sig * res;
}
inline void putint(int x,char suf){
  if(!x) bufo.put('0');
  else{
    if(x < 0) bufo.put('-'), x = -x;
    int k = 0; char s[15];
    while(x){
      s[++k] = x % 10 + '0';
      x /= 10;
    }
    for(;k;k--) bufo.put(s[k]);
  }
  bufo.put(suf);
}
inline void putll(ll x,char suf){
  if(!x) bufo.put('0');
  else{
    if(x < 0) bufo.put('-'), x = -x;
    int k = 0; char s[25];
    while(x){
      s[++k] = x % 10 + '0';
      x /= 10;
    }
    for(;k;k--) bufo.put(s[k]);
  }
  bufo.put(suf);
}
inline char get_char(){
  char c;
  for(c = buff.get();c == ' ' || c == '\n';c = buff.get());
  return c;
}

int main(){
  int h = getint(), n = getint();
  for(int i = 1;i <= n;i++) h -= getint();
  if(h <= 0) puts("Yes");
  else puts("No");
  return 0;
}


Measured memory_bytes: 384
def main():
    n, k = map(int, input().split())
    if (n-1)*(n-2)//2 < k:
        print("-1")
    else:
        ans = []
        buf = (n-1)*(n-2)//2
        for i in range(2, n+1):
            ans.append([1, i])
        for i in range(2, n):
            if buf == k:
                break
            for j in range(i+1, n+1):
                ans.append([i, j])
                buf -= 1
                if buf == k:
                    break
        print(len(ans))
        for v in ans:
            print(v[0], v[1])

if __name__ == "__main__":
    main()

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

using namespace std;
typedef long long ll;


int main()
{
   int n;
   cin >> n;
   vector<ll> v;

   map<ll,ll> mp,ans;

   for(int i = 0; i < n; i++){
        ll a;
        cin >> a;
        v.push_back(a);
        mp[a]++;
   }
   ll sum = 0;
   for(int i = 0; i <= n; i++){
        sum += mp[i]*(mp[i]-1);
   }
   for(int i = 0; i < n; i++){
        if(ans[v[i]]){
            cout << ans[v[i]] <<endl;
            continue;
        }
        ll bla = sum;
        bla -= mp[v[i]]*(mp[v[i]]-1) ;

        bla += (mp[v[i]]-1)*(mp[v[i]]-2);
        bla/=2;
        ans[v[i]] = bla;
        cout << bla << endl;
   }




}


Measured memory_bytes: 23536
x=int(input())

for a in range(-120, 120):
    a5 = a**5
    for b in range(-120, 120):
        if (a5 < x and b >= 0 ) or (a5 > x and b <= 0):
            continue
        if a5 - b**5 == x:
            print(a, b)
            break
    else:
        continue
    break

Measured memory_bytes: 9184
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        Scanner sc = new Scanner(System.in);
        
        int N = sc.nextInt();
        int M = sc.nextInt();
        
        String a = "No";
        
        if(N==M){
            a = "Yes";
        }
        System.out.println(a);
    }
}


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

using namespace std;
using P = pair<long, long>;

typedef long long int ll;

#define EPS (1e-7)
#define INF (1e18)
#define PI (acos(-1))

#define fillInt(xs)        \
  for (int i = 0; i < (xs).size(); i++) \
    scanf("%d", &xs[i]);
#define fillLong(xs)       \
  for (int i = 0; i < (xs).size(); i++) \
    scanf("%ld", &xs[i]);
#define fillDouble(xs)       \
  for (int i = 0; i < (xs).size(); i++) \
    scanf("%lf", &xs[i]);
#define fillString(xs)       \
  for (int i = 0; i < (xs).size(); i++) \
    cin >> xs[i];
#define sortv(xs) sort(xs.begin(), xs.end())
#define sortvinv(xs) sort(xs.begin(), xs.end(), greater<long>())
#define lbv(xs, x) lower_bound(xs.begin(), xs.end(), x) - xs.begin()
#define ubv(xs, x) upper_bound(xs.begin(), xs.end(), x) - xs.begin()
#define bs(xs, x) binary_search(xs.begin(), xs.end(), x)
#define index_of(as, x) \
  distance(as.begin(), lower_bound(as.begin(), as.end(), x))
#define rad_to_deg(rad) (((rad)/2/M_PI)*360)
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define concat(xs, ys) (xs).insert((xs).end(), (ys).begin(), (ys).end())

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

  long n;
  cin >> n;

  vector<P> p;
  rep(i, n) {
    long x;
    cin >> x;
    p.push_back({x, i});
  }
  sort(p.begin(), p.end(), greater<P>());

  multiset<long> st;
  st.insert(-1);
  st.insert(-1);
  st.insert(n);
  st.insert(n);

  long res = 0;
  rep(i, n) {
    st.insert(p[i].second);
    auto idx = st.find(p[i].second);

    long up = *next(idx);
    long up2 = *next(next(idx));
    long low = *prev(idx);
    long low2 = *prev(prev(idx));

    res += (p[i].second - low) * (up2 - up) * p[i].first;
    res += (up - p[i].second) * (low - low2) * p[i].first;
  }

  cout << res << endl;
}


Measured memory_bytes: 6512
#include<bits/stdc++.h>
#include<vector>
using namespace std;
int main(void){

    vector<bool>   is_Prime(1000001, true);
    is_Prime[0] = false;    is_Prime[1] = false;
    //最初に10^6までの素数を全部出す
    for(int i = 2 ; i <= 500000 ; i++){
        if(is_Prime[i] == true){
            int tmp = 2;
            while(i * tmp <= 1000000)
                is_Prime[i * tmp++] = false;
            
        }
    }

    while(true){
     int a, d, n;        cin >> a >> d >> n;
      if(a == 0 && d == 0 && n == 0)  break;
      int tmp = 0, count = 0;
      while(count < n){
           if(is_Prime[a + d * tmp++] == true) count++;
           if(count == n)  cout << a + d * (tmp - 1) << endl;
      }
    }

    return 0;
}


Measured memory_bytes: 3232
using System;
using System.Collections.Generic;
using System.Text;

class Program
{
	static void Main(string[] args)
	{
		long MOD = 1000000007;
		string[] input = Read();
		int n = int.Parse(input[0]);
		int k = int.Parse(input[1]);
		input = Read();
		long[] friendly = new long[n];
		for(int i=0; i<n; i++) friendly[i] = long.Parse(input[i]);
		Array.Sort(friendly);
		long ans = 1;
		if(k%2==1 && friendly[n-1]<0)
		{
			for(int i=0; i<k; i++) ans = (ans * friendly[n-i-1]) % MOD;
			Write(MOD + ans);
			return;			
		}
		if(k%2==1)
		{
			ans = friendly[n-1];
			n--;
			k--;
		}
		int idxPlus = n-1;
		int idxMinus = 0;
		for(int i=0; i<k/2; i++)
		{
			long plus = friendly[idxPlus] * friendly[idxPlus-1];
			long minus = friendly[idxMinus] * friendly[idxMinus+1];
			if(plus>minus)
			{
				ans = (plus % MOD) * ans % MOD;
				idxPlus -= 2; 
			}
			else
			{
				ans = (minus % MOD) * ans % MOD;
				idxMinus += 2;
			}
		}
		if(ans < 0) ans += MOD;
		Write(ans);
	}

	static string[] Read()
	{
		return Console.ReadLine().Split(' ');
	}

	static void Write(object o)
	{
		Console.WriteLine(o.ToString());
	}
}



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

int main(){
    int X;
    cin >> X;
    int beki;
    int mx = 0;
    for(int i=1; i<100; i++){
        for(int jj=2; jj<10; jj++){
            beki = pow(i,jj);
            if(beki <= X) mx = max(mx,beki);
        }
    }

    cout << mx << endl;
}   

Measured memory_bytes: 640
# お約束
INF = float("inf")
MOD = int(1e9 + 7)
def int1(n):
    return int(n) - 1
def parse(args, *params):
    return tuple(p(v) for p, v in zip(params, next(args).split()))

# 二分探索
def bsr(a, v, lo=0, hi=None):
    if hi == None:
        hi = len(a) - 1
    if hi < lo:
        return lo
    mi = (lo + hi) // 2
    if v < a[mi]:
        return bsr(a, v, lo, mi - 1)
    else:
        return bsr(a, v, mi + 1, hi)

# エントリーポイント
def main(args):
    A, B, Q = parse(args, int, int, int)
    S = list(int(next(args)) for _ in range(A))
    T = list(int(next(args)) for _ in range(B))
    X = tuple(int(next(args)) for _ in range(Q))

    s = [-INF] + S + [INF]
    t = [-INF] + T + [INF]
    for x in X:
        sr = bsr(s, x)
        sl = sr - 1
        tr = bsr(t, x)
        tl = tr - 1
        min_cost = INF
        for st in [s[sl], s[sr]]:
            for tt in [t[tl], t[tr]]:
                min_cost = min(min_cost, abs(st - x) + abs(tt - st))
                min_cost = min(min_cost, abs(tt - x) + abs(tt - st))
        print(min_cost)

import sys
if __name__ == '__main__':
    main(iter(sys.stdin.read().split("\n")))


Measured memory_bytes: 41344
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include <cstdlib>

using namespace std;

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

Measured memory_bytes: 256
int main(){
	char strs[101];
	char strp[101];
	char strss[201];

	scanf("%s",strs);
	scanf("%s",strp);

	/*strs?????????str?????£?????????strss?????????*/
	int i = 0 ;
	int t = strlen(strs);
	for(i=0;i<t;i++){
		strss[i] = strs[i];
		strss[i+t] = strs[i];
	}
	strss[2*t] = '\0';

//	printf("?????????strss???%s\n",strss);

	if( strstr(strss,strp) ){
		printf("Yes\n");
	}
	else{
		printf("No\n");
	}



	return 0;
}

Measured memory_bytes: 524
#include <iostream>
#include <iomanip>
// std::cout << std::setprecision(2) << 3.141; // "3.1"
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
#include <map>

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> plglg;
typedef pair<double, ll> pdlg;
typedef tuple<int, int, int> tiii;
typedef tuple<ll, ll, ll> tlglglg;
typedef tuple<double, double, double> tddd;

static const int giga = pow(10,9);
// double pi = 3.141592653589793238463;

int main(void){
  int r;
  cin >> r;
  cout << 3*r*r << endl;

  return 0;
}

Measured memory_bytes: 256
//https://atcoder.jp/contests/agc035/tasks/agc035_b
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
//#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }
//---------------------------------------------------------------------------------------------------
template<typename T> using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;
/*---------------------------------------------------------------------------------------------------
　　　　　　　　　　　 ∧＿∧  
　　　　　 ∧＿∧ 　（´<_｀ ）　 Welcome to My Coding Space!
　　　　 （ ´_ゝ`）　/　 ⌒i     @hamayanhamayan
　　　　／　　　＼　 　  |　|     
　　　 /　　 /￣￣￣￣/　　|  
　 ＿_(__ﾆつ/　    ＿/ .| .|＿＿＿＿  
　 　　　＼/＿＿＿＿/　（u　⊃  
---------------------------------------------------------------------------------------------------*/














int N, M;
set<int> E[101010];
int outsz[101010];
//---------------------------------------------------------------------------------------------------
void _main() {
	cin >> N >> M;
	rep(i, 0, M) {
		int a, b; cin >> a >> b;
		a--; b--;
		E[a].insert(b);
		E[b].insert(a);
	}

	if (M % 2 == 1) {
		printf("-1\n");
		return;
	}

	min_priority_queue<pair<int, int>> que;
	vector<pair<int, int>> ans;
	rep(i, 0, N) que.push({ E[i].size(), i });
	while (!que.empty()) {
		auto q = que.top(); que.pop();

		int cu = q.second;
		if (E[cu].size() != q.first) continue;

		int to = *E[cu].begin();
		E[cu].erase(to);
		E[to].erase(cu);

		if (0 < E[cu].size()) que.push({ E[cu].size(), cu });
		if (0 < E[to].size()) que.push({ E[to].size(), to });

		if (outsz[cu] == 1) {
			ans.push_back({ cu, to });
			outsz[cu] = 0;
		}
		else {
			ans.push_back({ to, cu });
			outsz[to] = 1 - outsz[to];
		}
	}

	rep(i, 0, N) if (E[i].size() != 0 or outsz[i] == 1) {
		printf("-1\n");
		return;
	}

	fore(p, ans) printf("%d %d\n", p.first + 1, p.second + 1);
}





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

int power(int n)
{
    int num=1;
    for(int i=0;i<n;i++)num*=10;
    return num;
}
int main()
{
    string str;
    int ans=6174;
    while(cin>>str&&str!="0000"){
        int up[4],down[4];
        if(str!="6174"){
            for(int i=0;i<4;i++)up[i]=str[i]-'0';
            bool kawa=0;
            for(int i=1;!kawa;i++){
                for(int j=0;j<4;j++){
                    for(int k=3;k>j;k--)if(up[k]<up[k-1])swap(up[k],up[k-1]);
                }
                for(int j=0;j<4;j++)down[j]=up[3-j];
                int num[2]={};
                for(int j=0;j<4;j++){
                    num[0]+=down[j]*power(3-j);
                    num[1]+=up[j]*power(3-j);
                }
                num[0]-=num[1];
                if(num[0]==ans||num[0]==0){
                    if(num[0]==0)cout<<"NA\n";
                    else cout<<i<<endl;
                    kawa=1;
                }
                up[0]=num[0]/1000;
                up[1]=num[0]%1000/100;
                up[2]=num[0]%100/10;
                up[3]=num[0]%10;
            }
        }
        else cout<<"0\n";
    }
}

Measured memory_bytes: 1192
#include<bits/stdc++.h>
using namespace std;
int main()
{
long long int a,b,x,t=0;
 cin>>a>>b>>x;
 if(a%x==0) cout<<(b/x)-(a/x)+1<<endl;
 else cout<<(b/x)-(a/x)<<endl;

}


Measured memory_bytes: 3580
//#pragma comment(linker, "/STACK:1024000000,1024000000")
/* vim: set fdm=marker */
//{{{
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const int iinf = 0x7fffffff;
const ll linf = ~(1LL<<63);
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef map<ll, int> mli;
typedef map<ll, ll> mll;
template<typename T>
inline T gcd(T a, T b) {
	if(a < 0) return gcd(-a, b);
	if(b < 0) return gcd( a,-b);
	if(a < b) return gcd(b, a);
	if(b == 0) return a;
	return gcd(b, a%b);
}

ll qpow(ll a, ll n, ll mod) {
	a %= mod;
	ll ans = 1LL;
	while(n) {
		if(n & 1) ans = (ans*a % mod);
		a = (a*a % mod);
		n >>= 1;
	}
	return ans;
}

inline ll rev(ll a, ll p) {
	return qpow(a, p - 2, p);
}

#define all(v) v.begin(), v.end()
#define sz(v) v.size()
#define rep(x, st, en) for(int x = st; x < en; x++)
#define pb push_back
#define mp make_pair
#define dbgm(msg, var) cerr<<#msg<<" "<<#var<<" = "<<var<<endl; 
#define dbg(var) cerr<<#var<<" = "<<var<<endl;
#define X first
#define Y second
#ifdef ALNDBG
namespace alndbg {
	clock_t s, e;
}
#endif

inline void tic() {
#ifdef ALNDBG
	alndbg::s = clock();
#endif
}

inline void toc() {
#ifdef ALNDBG
	alndbg::e = clock();
	cerr<<1000.0 * (alndbg::e - alndbg::s) / CLOCKS_PER_SEC<<" ms"<<endl;
#endif
}

//}}}

// -------------------- Spliters ------------------------
const int maxn = 150500;

char s[maxn];

#define N 'p'
#define Z 'g'

int prefixP[maxn];
int prefixG[maxn];
int delt[maxn];

int main() {
	ios::sync_with_stdio(0);
	cin>>s;
	int p = 0, g = 0;
	int l = strlen(s);
	for(int i = 0; i < l; i++) {
		prefixP[i] = i ? prefixP[i - 1] : 0;
		prefixG[i] = i ? prefixG[i - 1] : 0;
		if(s[i] == 'p') prefixP[i] ++;
		if(s[i] == 'g') prefixG[i] ++;
	}
	int mini = 1e9;
	for(int i = l - 1; i >= 0; i--) {
		if(prefixG[i] - prefixP[i] < mini) {
			mini = prefixG[i] - prefixP[i];
			delt[i] = mini;
		}
		delt[i] = mini;
	}

	int spread = 0;
	int ans = 0;
	for(int i = 0; i < l; i++) {
		if(s[i] == 'g') {
			if(delt[i] - spread >= 2) {
				ans++;
				spread+=2;
			}
		}
	}
	cout<<ans<<endl;

	return 0;
}
// --USE C++11
// *-USE O2


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

namespace atc
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] p = Console.ReadLine().Split(' ').Select(i => int.Parse(i)).ToArray();
            if(p[0] - p[1] * p[2] <= 0)
            {
                Console.WriteLine("Yes");
            }
            else
            {
                Console.WriteLine("No");
            }
        }
    }
}


Measured memory_bytes: 28172
#include <algorithm>
#include <climits>
#include <iostream>
#include <string>
#include<cstdio>
#include <vector>
#include<queue>
#include<limits.h>
#include<string.h>
#include<functional>
using namespace std;

signed main() {
	int a, b; 
	while (cin >> a >> b, a | b) {
		for (int c = 0; c < a; c++) {
			for (int d = 0; d < b; d++) {
				if (c == 0 || c == a - 1 || d == 0 || d == b - 1) {
					cout << '#';
				}
				else cout << '.';
			}
			cout << endl;
		}
		puts("");
	}
}

Measured memory_bytes: 3088
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, begin, end) for (ll i = (begin); i < (end); i++)
#define REP(i, n) FOR(i, 0, n)
#define IFOR(i, begin, end) for (ll i = (begin)-1; i >= (end); i--)
#define IREP(i, n) IFOR(i, n, 0)
#define SORT(a) sort(a.begin(), a.end())
#define ISORT(a) sort(a.begin(), a.end(), greater<ll>())
#define REVERSE(a) reverse(a.begin(), a.end())
#define debug(x) cout << #x << "=" << x << endl;
#define vdebug(v)                                                              \
  cout << #v << "=(" << v[0];                                                  \
  FOR(i_debug, 1, v.size()) { cout << "," << v[i_debug]; }                     \
  cout << ")" << endl;
#define mdebug(m)                                                              \
  cout << #m << "=" << endl;                                                   \
  REP(i_debug, m.size()) {                                                     \
    REP(j_debug, m[i_debug].size()) { cout << m[i_debug][j_debug] << ","; }    \
    cout << endl;                                                              \
  }
#define Lower_bound(v, x)                                                      \
  distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x)                                                      \
  distance(v.begin(), upper_bound(v.begin(), v.end(), x))
#define Max(a, b) a = max(a, b)
#define Min(a, b) a = min(a, b)

#define ll long long
#define ld long double
// #define f first
// #define s second
#define mp make_pair
#define pb push_back
#define INF 1000000000000000000

using vec = vector<ll>;
using mat = vector<vec>;
using Pii = pair<ll, ll>;
using PiP = pair<ll, Pii>;
using PPi = pair<Pii, ll>;
using bvec = vector<bool>;
using Pvec = vector<Pii>;

template <typename T> void readv(vector<T> &a) { REP(i, a.size()) cin >> a[i]; }
void readv_m1(vector<int> &a) {
  REP(i, a.size()) {
    cin >> a[i];
    a[i]--;
  }
}

ll mod = 1000000007;

int main() {
  ll N, K;
  cin >> N >> K;

  vec num_snack(N, 0);

  ll d;
  REP(i, K) {
    cin >> d;
    // vec A(d);
    ll A;
    REP(j, d) {
      cin >> A;
      A--;
      num_snack[A]++;
    }
  }

  ll ans = 0;
  REP(i, N) {
    if (num_snack[i] == 0)
      ans++;
  }

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 3628
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);i++)
#define ALL(v) (v).begin(),(v).end()
#define int long long
using namespace std;
typedef vector<int>   vint;
typedef pair<int,int> pint;

signed main()
{   
    string s; cin>>s;
    int K; cin>>K;
    
    if(K>s.size()){
        REP(i,s.size()){
            if(s[i]!='1'){
                cout<<s[i]<<endl;
                return 0;
            }
        }
    }
    else{
        REP(i,K){
            if(s[i]!='1'){
                cout<<s[i]<<endl;
                return 0;
            }
        }
        cout<<'1'<<endl;
    }
 
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <vector>
#include <utility>
#include <numeric>
#include <string>
#include <set>
#include <map>
#include <tuple>
#include <queue>
#include <stack>
#include <deque>
#define rep(i, a, n) for(int (i) = (int)(a);(i) < (int)(n);++(i))
#define repe(i, a, n) for(int (i) = (int)(a);(i) <= (int)(n);++(i))
#define repif(i, a, x) for(int (i) = (int)(a);(x);++(i))
#define repr(i, a, n) for(int (i) = (int)(a);(i) > (int)(n);--(i))
#define reper(i, a, n) for(int (i) = (int)(a);(i) >= (int)(n);--(i))
#define chmax(a, b) a = max(a, b)
#define chmin(a, b) a = min(a, b)
#define SIZE(x) ((int)(x).size())
#define ALL(x) (x).begin(), (x).end()
#define RNG(x, a, n) &((x)[a]), &((x)[n])
#define ADD(a, b) ((((a)%MOD)+((b)%MOD))%MOD)
#define MUL(a, b) ((((a)%MOD)*((b)%MOD))%MOD)
#define CEIL(x) ((int)ceil(((double)x)))
#define UNIQUE(x) (x).erase(unique(ALL((x))), (x).end())
#define YES cout << "YES" << endl
#define NO cout << "NO" << endl
#define Yes cout << "Yes" << endl
#define No cout << "No" << endl
#define yes cout << "yes" << endl;
#define no cout << "no" << endl;
#define fcout cout << fixed << setprecision(10)
#define pb push_back
#define pf push_front
#define mp make_pair
#define mt make_tuple
#define lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#define EPS (1e-20)
#define INF 2147483647
#define MOD 1000000007
using llint = long long;
using VI = std::vector<int>;
using PII = std::pair<int, int>;
using SI = std::set<int>;
using MII = std::map<int, int>;
using TIII = std::tuple<int, int, int>;
using VLL = std::vector<llint>;
using MCI = std::map<char, int>;
using namespace std;



string S;
int mem;


bool judge1(){
	rep(i, 2, SIZE(S)-1)
		if(S[i] == 'C') return mem = i, true;
	return false;
}


bool judge2(){
	if(S[1] < 'a' || 'z' < S[1]) return false;
	if(S.back() < 'a' || 'z' < S.back()) return false;
	return true;
}


bool judge3(){
	rep(i, 2, SIZE(S)-1)
		if(mem != i && (S[i] < 'a' || 'z' < S[i])) return false;
	return true;
}


bool solve(){
	if(S[0] != 'A') return false;
	if(!judge1()) return false;
	if(!judge2()) return false;
	if(!judge3()) return false;
	return true;
}


signed main(){
	cin >> S;

	if(solve()) cout << "AC" << endl;
	else cout << "WA" << endl;

	return 0;
}

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

using namespace std;

int main()
{
    int a,b,k;
    scanf("%d %d %d",&a,&b,&k);
    int i;
    if(k*2>b-a)
        for(i=a;i<=b;i++)
            printf("%d\n",i);
    else
    {
     for(i=0;i<k;i++)
        printf("%d\n",a+i);
     for(i=k-1;i>=0;i--)
        printf("%d\n",b-i);
    }


    return 0;
}


Measured memory_bytes: 256
import java.util.*;
import java.util.ArrayList;
import java.util.Collections;
 
class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
 
        String s = sc.next();
        int K = sc.nextInt();
        ArrayList<String> list = new ArrayList<String>();

        for(int i=1; i<=K; i++){
            if(i>s.length()){
                break;
            }
            for(int j=0; j<=s.length()-i; j++){
                if(j<s.length()-i && !list.contains(s.substring(j, j+i))){
                    list.add(s.substring(j, j + i));
                }
                else if(j==s.length()-i && !list.contains(s.substring(j))){
                    list.add(s.substring(j));
                }
            }
        }

        Collections.sort(list);

        System.out.println(list.get(K - 1));
    }
}

Measured memory_bytes: 24788
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define FOR(I,A,B) for(int I = (A); I < (B); ++I)
#define CLR(mat) memset(mat, 0, sizeof(mat))
const ll N=100000;
const ll R = 1000000007;
 
int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	ll n,a[N],k,ans=1;
	CLR(a);
	cin >> n;
	FOR(i,0,n){
		cin >> k;
		a[k]++;
	}
	for(int i=0;i<n/2;i++){
		ans*=2;
		ans%=R;
	}
	if(n&1){
		if(a[0]!=1){
			ans=0;
			cout << ans << endl;
			return 0;
		}
		for(int i=2;i<n;i+=2){
			if(a[i]!=2){
				ans=0;
				cout << ans << endl;
				return 0;
			}
		}
		
	}else{
		for(int i=1;i<n;i+=2){
			if(a[i]!=2){
				ans=0;
				cout << ans << endl;
				return 0;
			}
		}
	}
	cout << ans << endl;
	return 0;
}

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

#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for(int i = int(a); i < int(b); i++)
#define REP(...) _overload3(__VA_ARGS__, repi, _rep,)(__VA_ARGS__)
typedef long long int ll;
const int MOD=(int)1e9+7;

ll gcd(ll a,ll b){
    if(b==0)return a;
    return gcd(b,a%b);
}
ll lcm(ll a,ll b){
    ll g=gcd(a,b);
    return a/g*b;
}
ll digitsum(ll a){
    ll x=0;
    while(a>0){
        x+=a%10;
        a/=10;
    }
    return x;
}

int main(){
    int d;
    cin>>d;
    if(d==25)cout<<"Christmas"<<endl;
    if(d==24)cout<<"Christmas Eve"<<endl;
    if(d==23)cout<<"Christmas Eve Eve"<<endl;
    if(d==22)cout<<"Christmas Eve Eve Eve"<<endl;
}

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

int main()
{
    char a[10],b[10];
    scanf("%s %s",a,b);

    strcat(a,b);
    int ab = atoi(a);

    int i;
    for (i = 0; i * i <= ab; i++)
    {
        if(i * i == ab)break;
    }
    
    if(i * i == ab)printf("Yes");
    else printf("No");
}

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

typedef long long ll;
typedef pair<int, int> ii;

const int N = 1e5 + 5;
int n, u, v, w;
int res[N];
vector<ii> e[N];

void dfs(int uu, int c, int par) {
    res[uu] = c;
    for (auto &p : e[uu]) {
        int vv = p.first;
        int ww = p.second;
        if (vv == par) continue;
        if (ww & 1) {
            dfs(vv, 1 - c, uu);
        } else {
            dfs(vv, c, uu);
        }
    }
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin >> n;
    for (int i = 0; i < n - 1; ++i) {
        cin >> u >> v >> w;
        e[u].push_back({v, w});
        e[v].push_back({u, w});
    }
    dfs(1, 0, 0);
    for (int i = 1; i <= n; ++i) {
        cout << res[i] << endl;
    }

    return 0;
}



Measured memory_bytes: 9216
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>	
#include<map>
#include<set>
#include<utility>
#include<cmath>
#include<cstring>
#include<queue>
#include<cstdio>
#include<sstream>
#include<iomanip>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define mp make_pair
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
using namespace std;
//kaewasuretyuui
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef pair<int,pii> pip;
typedef vector<pip>vip;
const double PI=acos(-1);
const double EPS=1e-8;
const int inf=1e8;
ll gcd(ll a,ll b){
	return (b==0?a:gcd(b,a%b));
}
int main(){
	ll n;
	cin>>n;
	while(n--){
		ll a,b;
		cin>>a>>b;
		if(a==b)cout<<"1 0"<<endl;
		else if(a%2==0||b%2==0)cout<<"1 1"<<endl;
		else{
			ll t=gcd(a,b);
			a/=t;
			b/=t;
			cout<<a*b/2+1<<" "<<a*b/2<<endl;
		}
	}
}

Measured memory_bytes: 3076
from math import floor
A, B, N = map(int, input().split())
# print('A, B, N', A, B, N)


def f(x):
    return floor((A * x) / B) - A * floor(x / B)


if B - 1 <= N:
    ans = f(B - 1)
else:
    ans = f(N)
print(ans)


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

map<string,int> m;
long long nb(long long);

long long v[500005];

int main()
{
	int a;
	cin >> a;
    for(int i = 0; i < a; i++){
    	string str;
    	cin >> str;
    	sort(str.begin(),str.end());
    	m[str]++;
//    	cout << m[str];
	}
//	cout << m[str];
	long long b = 0;
	map<string,int>::iterator it;
    for(it = m.begin(); it != m.end(); it++){
    	b += nb(it->second);
	}
	cout << b;
	return 0;
}
long long nb(long long n)
{
//	cout <<  n;
	if(!v[n]) {
		long long t = n * (n - 1) / 2;
		v[n] = t;
		return t;
	}else{
		return v[n];
	}

}

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


/* エイリアス */
#define ll long long
#define ld long double
#define vi vector<int>
#define vll vector<ll>
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vpi vector<pii>
#define vpll vector<pll>
#define endl '\n'

#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define em emplace
#define mp make_pair


/* 関数マクロ */
#define rep(i, n) for (ll i = 0; i < n; ++i)
#define rep2(i, n, m) for (ll i = n; i <= m; ++i)
#define rep3(i, n, m) for (ll i = n; i >= m; --i)
#define all(v) v.begin(), v.end()
#define si(v) int(v.size())
#define UNIQUE(v) sort(all(v)), v.erase(unique(all(v)),v.end())


/* 定数 */
const ll mod = 1e9 + 7;
const ll infll = (1LL << 62) - 1;
const ll inf = (1LL << 30) - 1;


/* その他 */
template<class S, class T> inline bool chmax(S &a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class S, class T> inline bool chmin(S &a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T> using pq = priority_queue<T>;
template<class T> using pqg = priority_queue<T, vector<T>, greater<T>>;


signed main() {
  ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  cout << fixed << setprecision(15);

  string s, t; cin >> s >> t;
  
  sort(all(s));
  sort(all(t));

  reverse(all(t));
  if (s < t) cout << "Yes" << endl;
  else cout << "No" << endl;
}


Measured memory_bytes: 3640
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

const mod = 1000000007

// 1MB
const ioBufferSize = 1 * 1024 * 1024
var sc = func() *bufio.Scanner {
	sc := bufio.NewScanner(os.Stdin)
	sc.Buffer(make([]byte, ioBufferSize), ioBufferSize)
	sc.Split(bufio.ScanWords)
	return sc
}()

func next() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func main() {
	n := nextInt()
	x := make([]int, n)
	for i := 0; i < n; i++ {
		x[i] = nextInt()
	}

	m := 1 << 63 - 1
	for p := 1; p <= 100; p++ {
		s := 0
		for j := 0; j < n; j++ {
			s += (x[j] - p) * (x[j] - p)
		}

		if m > s {
			m = s
		}
	}

	fmt.Println(m)
}

Measured memory_bytes: 640
#include <iostream>
#include <iomanip>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <algorithm>
#include <sstream>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <numeric>
#include <cmath>
#include <climits>
#include <limits>
#include <cfloat>
#include <fstream>
using namespace std;

void cut (vector <int> & card, int k )
{
	int size = card.size();

	vector <int> t;
	t.push_back(0);

	int i;

	for (i = k + 1; i < size; ++i){
		t.push_back (card[i] );
	} // end for
	for (i = 1; i <= k; ++i){
		t.push_back (card[i] );
	} // end for
	
	card = t;
}

void shuffle (vector <int> & card )
{
	int size = card.size(); // size = 2*n + 1
	
	vector <int> t;
	t.push_back(0);

	for (int i = 1; i <= size/2; ++i){
		t.push_back(card[i]);
		t.push_back(card[size/2 + i]);
	} // end for

	card = t;
}

int main()
{
//	cut here before submit 
//	freopen ("testcase.shufflecard2", "r", stdin );
	string str = "";
	int n,m;

	getline (cin, str );
	stringstream ssn(str);
	ssn >> n;

	vector <int> card (2*n + 1, 0 );
	int i;

	for (i = 1; i <= 2*n; ++i){
		card[i] = i;
	} // end for

	getline (cin, str );
	stringstream ssm(str);
	ssm >> m;


	for (i = 0; i < m; ++i){
		int k;
		getline (cin, str );
		stringstream ss (str );
		ss >> k;

		if (k != 0 ){ // cut
			cut (card, k );
		}else{		// shuffle
			shuffle (card );
		} // end for
	} // end for
	
	for (i = 1; i < card.size(); ++i){
		cout << card[i] << endl;
	} // end for

	return 0;
}

Measured memory_bytes: 0
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		//Input
		Scanner scanner = new Scanner(System.in);
		int total_element = scanner.nextInt();
		int[] data_array = new int[total_element];
		for (int i = 0; i < total_element; i++) {
			data_array[i] = scanner.nextInt();
		}
		
		
		for (int i = 0; i < total_element - 1; i++) {
			System.out.print(data_array[i] + " ");
		}
		System.out.println(data_array[total_element - 1]);
		//insertionSort
		int sorted_element = 0;
		for (int target = 1; target < total_element; target++) {
			int judge_target_low = target - 1;
			int judge_target_high = target;


			while(judge_target_low >= 0) {
				if(data_array[judge_target_low] > data_array[judge_target_high]){
					int bf = data_array[judge_target_low];
					data_array[judge_target_low] = data_array[judge_target_high];
					data_array[judge_target_high] = bf;
					judge_target_high--;
					judge_target_low--;
				} else {
					break;
				}
			}
			sorted_element = target;


			for (int i = 0; i < total_element - 1; i++) {
				System.out.print(data_array[i] + " ");
			}
			System.out.println(data_array[total_element - 1]);
		}



	}
}



Measured memory_bytes: 29824
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int n = scan.nextInt();
        int d = scan.nextInt();

        Map<Integer,Integer> squares = new HashMap<>();

        for (int i = 1; i <= 200; i++) {
            squares.putIfAbsent(i*i,i);
        }

        int[][] dp = new int[n][d];
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < d; j++) {
                dp[i][j] = scan.nextInt();
            }
        }

        int counter = 0;

        for (int i = 0; i < n; i++) {
            for (int j = i+1; j < n; j++) {
                int x = 0;
                for (int k = 0; k < d; k++) {
                    x+=Math.pow(dp[i][k] - dp[j][k],2);
                }
                if(squares.containsKey(x)){
                    counter++;
                }
            }
        }

        System.out.println(counter);
    }
}

Measured memory_bytes: 23636
#include<bits/stdc++.h>
using namespace std;
#define int long long 

int a[1010];

signed main(void){
  int n,m; cin >> n >> m;
  int sum = 0;
  for(int i = 0; i < n; i++){ cin >> a[i]; sum += a[i];}
  
  sum = (sum+4*m-1)/(4*m);
  int cnt = 0;
  for(int i = 0; i < n; i++){ 
    if( a[i] >= sum ){ cnt++;}
  }
  if( cnt >= m ){ cout << "Yes" << endl;}
  else{ cout << "No" << endl;}

  return 0;
} 
    

Measured memory_bytes: 256
N=int(input())
As=list(map(int,input().split()))
As=[i for i in As if i%2==0]
def check(i):
    if i%3==0 or i%5==0:
        return True
    else:
        return False
new_As=[i for i in As if check(i)]
if len(As)==len(new_As):
    print("APPROVED")
else:
    print("DENIED")


Measured memory_bytes: 3060