akhauriyash/Code-Regression huggingface dataset:
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long n = Long.parseLong(sc.next());
        long a = Long.parseLong(sc.next());
        long b = Long.parseLong(sc.next());
        if ((b - a) % 2l == 0) {
            System.out.println((b - a) / 2l);
            return;
        }

        long res = n - a;

        res = Math.min(res, b - 1l);
        res = Math.min(res, a + (b - 1l - a) / 2l);
        res = Math.min(res, (n - b + 1l) + (n - a - n + b - 1l) / 2l);

        System.out.println(res);
    }
}


Measured memory_bytes: 23764
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define VV vector
#define pb push_back
#define bitc  __builtin_popcountll
#define m_p make_pair
#define inf 1e18+1
#define eps 0.000000000001
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);
string char_to_str(char c){string tem(1,c);return tem;}
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
template<class T>//usage rand<long long>()
T rand() {
    return uniform_int_distribution<T>()(rng);
}
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
 
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> oset;
// string to integer stoi()
// string to long long stoll()
// string.substr(position,length);
// integer to string to_string();
 
//////////////
auto clk=clock();
#define all(x) x.begin(),x.end()
#define se second
#define fi first
#define sz(x) ((long long)x.size())
#define int long long  
#define f80 __float128
#define pii pair<int,int>
/////////////

signed main()
{
	fastio;
	#ifdef ANIKET_GOYAL
		freopen("inputf.in","r",stdin);
		freopen("outputf.in","w",stdout);
	#endif
	int n,m;
	cin>>n>>m;
	int kk;
	cin>>kk;
	int ans=inf;
	string s[n];
	for(int i=0;i<n;++i)
	{
		cin>>s[i];
	}
	int va[100]={};
	for(int i=0;i<(1<<(n-1));++i)
	{
		// cout<<i<<endl;
		int x=__builtin_popcountll(i);
		memset(va,0,sizeof(va));
		int cu=0;
		int fl1=1;
		for(int k=0;k<m;++k)
		{
			// cout<<k<<endl;
			int r=0;
			int fl=0;
			for(int j=0;j<n;++j)
			{
				if(s[j][k]=='1')
					++va[r];
				// if(x==0)
				// cout<<fl<<" "<<r<<" "<<va[r]<<"\n";
				if(va[r]>kk)
				{
					fl=1;
				}

				// if(x==0)
				// cout<<r<<" "<<va[r]<<"\n";
				if(i&(1<<j))
					++r;
			}
			// cout<<fl<<"\n";
			if(fl)
			{
				// if(x==0)
				// 	cout<<k<<"\n";
				++cu;
				r=0;
				for(int j=0;j<x+1;++j)
					va[j]=0;
				for(int j=0;j<n;++j)
				{
					if(s[j][k]=='1')
						va[r]++;
					if(va[r]>k)
						fl1=0;
					if(i&(1<<j))
						++r;
				}
				fl=0;
			}
		}
		if(fl1)
		ans=min(ans,x+cu);
	}
	cout<<ans;
	#ifdef ANIKET_GOYAL
		cout<<endl<<endl<<endl<<endl<<"Time elapsed: "<<(double)(clock()-clk)/CLOCKS_PER_SEC<<endl;
	#endif
}

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

ll n,c;

ll solve(vector<ll> x,vector<ll> v){
    vector<ll> rt(n+1);
    ll sumV = 0;
    rep(i,n){
        sumV += v[i];
        rt[i+1] = max(rt[i], sumV-x[i]*2);
    }

    sumV = 0;
    ll res = 0;
    for(int i = n-1; i >= 0; i--){
        sumV += v[i];
        res = max((sumV-(c-x[i])) + rt[i], res);
    }

    return res;
}

int main(void){
    cin>>n>>c;
    vector<ll> x(n),v(n);
    rep(i,n) cin>>x[i]>>v[i];
    
    ll res1 = solve(x,v);

    vector<ll> rx = x, rv = v;
    reverse(all(rx));
    reverse(all(rv));
    rep(i,n) rx[i] = c-rx[i];
    ll res2 = solve(rx,rv);

    cout<<max(res1,res2)<<endl;
    return 0;
}


Measured memory_bytes: 5712
#include <vector>
#include <string.h>
#include<iostream>
#include<set>
#include<map>
#include<unordered_map>
#include<string.h>
#include<algorithm>
#include <stdlib.h>
#include<queue>
using namespace std;




int main(){
    int n;
    int before=0,after=0, ambiguous=0;
    cin>>n;
    vector<string>vec(n);
    for(int i=0;i<n;i++){
        cin>>vec[i];
    }
    string name;
    cin>>name;
    priority_queue<int>str_has_q;
    for(int i=0;i<n;i++){
        string s,s2;
        s=vec[i],s2=vec[i];
        s2=s;
        bool q=false;
        for(int j=0;j<s.length();j++){
            if(s[j]=='?'){
                s[j]='a';
                s2[j]='z';
                q=true;
            }
        }
        if(q){
            if(s<name&&s2<name){
                before++;
            } else if(s>name&&s2>name){
                after++;
            } else {
                ambiguous++;
            }
            str_has_q.push(i);
        }
    }
    
    while(str_has_q.size()){
        int to=str_has_q.top();
        str_has_q.pop();
        vec.erase(vec.begin()+to);
    }
    sort(vec.begin(),vec.end());
    bool out=false;
    if(vec[0]>name){
        for(int i=max(0,before-after);i<before;i++)
            cout<<1+i<<" ";
        cout<<1+before<<endl;
        return 0;
    }
    vector<int>ans;
    for(int i=0;i<vec.size();i++){
        if(name==vec[i]){
            ans.push_back(i+1);
            out=true;
        }
        if(i>0&&vec[i]>name&&name>=vec[i-1]){
            ans.push_back(i+1);
            
            set<int>ind;
            for(int i=0;i<=ambiguous;i++){
                for(auto a:ans){
                    ind.insert(before+i+a);
                }
            }
            vector<int>ult;
            for(auto a:ind){
                ult.push_back(a);
            }
            for(int i=0;i<ult.size()-1;i++){
                cout<<ult[i]<<" ";
            }
            cout<<ult[ult.size()-1]<<endl;
            return 0;
        }
    }
    ans.push_back(vec.size()+1);
    set<int>ind;
    for(int i=0;i<=ambiguous;i++){
        for(auto a:ans){
            ind.insert(before+i+a);
        }
    }
    vector<int>ult;
    for(auto a:ind){
        ult.push_back(a);
    }
    for(int i=0;i<ult.size()-1;i++){
        cout<<ult[i]<<" ";
    }
    cout<<ult[ult.size()-1]<<endl;
    //else cout<<endl;
    return 0;
}

Measured memory_bytes: 1024
#!/usr/bin/env python3
import sys

YES = "YES"  # type: str
NO = "NO"  # type: str
    

def solve(N: int, A: "List[int]"):
    ans = True
    prev_a = -1
    A.sort()
    for a in A:
        if a == prev_a:
            ans = False
        prev_a = a

    ans = YES if ans else NO
    print(ans)
    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    A = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(N, A)

if __name__ == '__main__':
    main()


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

using namespace std;
using ll = long long;

int main() {

    int N = 0;
    cin >> N;
    vector<tuple<string,int,int>> A(N);
    for(int i = 0; i < N; i++) {
    cin >> get<0>(A.at(i)) >> get<1>(A.at(i));
    get<1>(A.at(i)) = 100 - get<1>(A.at(i));
    get<2>(A.at(i)) = i; 
    }
    sort(A.begin(),A.end());
    for (size_t i = 0; i < N; i++)
    {
        cout << get<2>(A.at(i)) +1 << endl;
        /* code */
    }
    

    return 0;
}

Measured memory_bytes: 3664
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <typeinfo>
#include <numeric>
#include <functional>
#include <unordered_map>
#include <bitset>
#include <stack>

using namespace std;
using ll = long long;
using ull = unsigned long long;

const ll INF = 1e16;
const ll MOD = 1e9 + 7;

#define REP(i, n) for(ll i = 0; i < n; i++)
#define Yes(condition) if(condition){ cout << "Yes" << '\n'; }else{ cout << "No" << '\n'; }
#define YES(condition) if(condition){ cout << "YES" << '\n'; }else{ cout << "NO" << '\n'; }
#define yes(condition) if(condition){ cout << "yes" << '\n'; }else{ cout << "no" << '\n'; }





int main() {
    ll n, p;
    cin >> n >> p;
    map<ll, ll> mp;
    ll cnt = 0;
    ll m = p;
    for(ll i = 2; i <= sqrt(p); i++){
        while(m % i == 0){
            mp[i]++;
            m /= i;
            cnt++;
            // cout << i << endl;
        }
    }
    if(m != 1){
        mp[m]++;
    }
    
    ll ans = 1;
    for(auto x : mp){
        if(x.second >= n){
            ans *= pow(x.first, (x.second / n));
            // cout << x.first << ' ' << x.second << endl;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
import java.io.IOException;

public class Main {

	public static void main(String[] args) {
		int N = nextInt();
		int count = 0;
		while (N > 1) {
			N = (int) Math.ceil((double) N / 3);
			count++;
		}
		System.out.println(count);
	}

	static int nextInt() {
		int c;
		try {
			c = System.in.read();
			while (c != '-' && (c < '0' || c > '9'))
				c = System.in.read();
			if (c == '-')
				return -nextInt();
			int res = 0;
			while (c >= '0' && c <= '9') {
				res = res * 10 + c - '0';
				c = System.in.read();
			}
			return res;
		} catch (IOException e) {
			e.printStackTrace();
		}
		return -1;
	}

	static char nextChar() {
		try {
			int b = System.in.read();
			while (b != -1 && (b == ' ' || b == '\r' || b == '\n'))
				;
			if (b == -1)
				return 0;
			return (char) b;
		} catch (IOException e) {
		}
		return 0;
	}

}

Measured memory_bytes: 16992
#include <bits/stdc++.h>
const long long MOD = 1000000007;
const int INF = INT_MAX / 2;
const long double PI = 3.1415926;
#define FOR(i, r, n) for(int i=(ll)(r); i<(ll)(n); i++) 
#define REP(i, n) FOR(i, (0), n)
#define ALL(r) r.begin(), r.end()
#define ll long long int
using namespace std;
vector<ll> v;
vector<string> vs;
vector<pair<ll, ll>> vp;
vector<vector<ll>> vv(110, vector<ll>(50, 0));
vector<tuple<ll, ll, ll>> vt;
map<ll, ll> mp;

typedef int Weight;
struct Edge
{
	int from, to; Weight cost;
	bool operator < (const Edge& e) const { return cost < e.cost; }
	bool operator > (const Edge& e) const { return cost > e.cost; }
};
typedef vector<Edge> Edges;
typedef vector<Edges> Graph;
void add_edge(Graph &g, int from, int to, Weight cost)
{
	g[from].push_back(Edge{ from, to, cost });
}

int main()
{
	char a, b;
	cin >> a >> b;
	cout << (a^b ? "D" : "H") << endl;
}

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

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
using ll = long long;
string char_to_string(char val) {
  return string(1, val);
}
int char_to_int(char val) {
  return val - '0';
}
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;
}
int vector_finder(std::vector<ll> vec, int number) {
  auto itr = std::find(vec.begin(), vec.end(), number);
  size_t index = std::distance( vec.begin(), itr );
  if (index != vec.size()) { // 発見できたとき
    return 1;
  }
  else { // 発見できなかったとき
    return 0;
  }
}

int main() {
  string T; cin >> T;
  if(T.size() == 1) {
    if(T == "?") {
      cout << "D" << endl;
      return 0;
    }
  }
  for(int i = T.size() - 1; i >= 0; --i) {
    if(i == 0) {
      if(T[i] == '?') {
        if(T[i + 1] == 'P') {
          T[i] = 'D';
        } else if(T[i + 1] == 'D') {
          T[i] = 'D';
        }
      }
    }
    if(T[i] == '?') {
      if(T[i - 1] == 'P' || T[i - 1] == '?') {
        T[i] = 'D';
      } else if(T[i - 1] == 'D') {
        T[i] = 'D';
      }
    }
  }
  cout << T << endl;
}

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

int main()
{
	string A, B, C;

	cin >> A >> B >> C;

	if( A[A.size() - 1] == B[0] && B[B.size() - 1] == C[0] ) {
		cout << "YES" << endl;
	}
	else {
		cout << "NO" << endl;
	}

	return 0;
}


Measured memory_bytes: 256
loop do
    n = gets.to_i
    break if n == 0
    a = gets.split.map(&:to_i)
    k = a.inject(:+)
    n = 1
    n += 1 until n * (n + 1) / 2 >= k
    if k != n * (n + 1) / 2
        puts -1
        next
    end
    goal = (1..n).to_a
    k = 0
    loop do
        break if a == goal
        b = []
        s = a.size
        until a.empty?
            x = a.shift
            b << x - 1 if x > 1
        end
        b << s
        a = b
        k += 1
        if k == 10000
            k = -1
            break
        end
    end
    puts k
end


Measured memory_bytes: 92148
alphabet = "abcdefghijklmnopqrstuvwxyz"
indmap = {}
for i, c in enumerate(alphabet):
    indmap[c] = i

MOD = 10**9 + 7

def main():
    n = int(input())
    s = input()

    counts = [0]*26
    for c in s:
        counts[indmap[c]] += 1

    #print(counts)
    total = 1
    for k in counts:
        total *= (k+1)

    print((total-1) % MOD)

if __name__ == "__main__":
    main()


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

template<typename T> ostream& operator<<(ostream &os, const vector<T> &v) { os << '{'; string sep; for (const auto &x : v) os << sep << x, sep = ", "; return os << '}'; }
template<typename T, size_t size> ostream& operator<<(ostream &os, const array<T, size> &arr) { os << '{'; string sep; for (const auto &x : arr) os << sep << x, sep = ", "; return os << '}'; }
template<typename A, typename B> ostream& operator<<(ostream &os, const pair<A, B> &p) { return os << '(' << p.first << ", " << p.second << ')'; }

void dbg_out() { cerr << endl; }
template<typename Head, typename... Tail> void dbg_out(Head H, Tail... T) { cerr << ' ' << H; dbg_out(T...); }

#ifdef NEAL_DEBUG
#define dbg(...) cerr << "(" << #__VA_ARGS__ << "):", dbg_out(__VA_ARGS__)
#else
#define dbg(...)
#endif


const int BITS = 18;

int N, K, S, T;
int64_t ALL;
vector<int> A;
array<array<int64_t, 2>, BITS> fail;
vector<vector<int64_t>> choose;
vector<int64_t> up_to_K;
int64_t answer;

void recurse(int index, int sign, int64_t mask) {
    if (mask == 0)
        return;

    if (index == BITS) {
        answer += sign * up_to_K[__builtin_popcountll(mask)];
        return;
    }

    recurse(index + 1, sign, mask);
    recurse(index + 1, -sign, mask & fail[index][0]);
    recurse(index + 1, -sign, mask & fail[index][1]);
}

int main() {
    cin >> N >> K >> S >> T;

    if ((S | T) != T) {
        cout << 0 << '\n';
        return 0;
    }

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

        if ((a & S) != S || (a | T) != T)
            continue;

        A.push_back(a);
    }

    N = int(A.size());
    K = min(K, N);

    choose.assign(N + 1, vector<int64_t>(N + 1, 0));

    for (int i = 1; i <= N; i++) {
        choose[i][0] = choose[i][i] = 1;

        for (int j = 1; j < i; j++)
            choose[i][j] = choose[i - 1][j] + choose[i - 1][j - 1];
    }

    up_to_K.assign(N + 1, 0);

    for (int i = 1; i <= N; i++)
        for (int j = 1; j <= K; j++)
            up_to_K[i] += choose[i][j];

    ALL = (1LL << N) - 1;

    for (int bit = 0; bit < BITS; bit++) {
        fail[bit] = {0, 0};

        if ((S >> bit & 1) == 0) {
            for (int i = 0; i < N; i++)
                if (A[i] >> bit & 1)
                    fail[bit][0] |= 1LL << i;
        }

        if ((T >> bit & 1) == 1) {
            for (int i = 0; i < N; i++)
                if ((A[i] >> bit & 1) == 0)
                    fail[bit][1] |= 1LL << i;
        }
    }

    answer = 0;
    recurse(0, 1, ALL);
    cout << answer << '\n';
}


Measured memory_bytes: 3664
#define _USE_MATH_DEFINES
#include <iostream>
#include <sstream>
#include <string>
#include <list>
#include <vector>
#include <queue>
#include <algorithm>
#include <climits>
#include <cstring>
#include <cmath>
#include <stack>
#include <iomanip>
#include <tuple>
#include <functional>
#include <cfloat>
#include <map>
#include <set>
#include <array>
#include <stdio.h>
#include <string.h>
#include <random>
using ll = long long;
using ull = unsigned long long;
using namespace std;
#define int long long
#define CONTAINS_VEC(v,n) (find((v).begin(), (v).end(), (n)) != (v).end())
#define SORT(v) sort((v).begin(), (v).end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
#define ARY_SORT(a, size) sort((a), (a)+(size))
#define REMOVE(v,a) (v.erase(remove((v).begin(), (v).end(), (a)), (v).end()))
#define REVERSE(v) (reverse((v).begin(), (v).end()))
#define ARY_REVERSE(v,a) (reverse((v), (v)+(a)))
#define REP(i, n) for (int (i)=0; (i) < (n); (i)++)
#define REPE(i, n) for (int (i)=0; (i) <= (n); (i)++)
#define CONTAINS_MAP(m, a) (m).find((a)) != m.end()
#define CONTAINS_SET(m, a) (m).find((a)) != m.end()
void YesNo(bool b) { cout << (b ? "Yes" : "No") << endl; }
void YESNO(bool b) { cout << (b ? "YES" : "NO") << endl; }






signed main()
{
	string a, b;
	cin >> a >> b;
	string s = a + b;
	int n = atoi(s.c_str());
	REPE(i, 1000)
	{
		if (i * i == n)
		{
			cout << "Yes" << endl;
			return 0;
		}
	}
	cout << "No" << endl;
}




Measured memory_bytes: 3636
import Control.Monad
import Data.Maybe
import qualified Data.ByteString.Char8 as BS
import qualified Data.Map.Strict as M

main :: IO [()]
main = abc159d

abc159d = do
    [n] <- getIntList
    a <- getIntList
    let dict = genDict M.empty a
    mapM (\x -> print $ sumComb dict - (M.!) dict x + 1) a

genDict :: (Integral a) => M.Map a a -> [a] -> M.Map a a
genDict m [] = m
genDict m (a:as) = if M.member a m
                   then genDict (M.update (\x -> Just (x+1)) a m) as
                   else genDict (M.insert a 1 m) as

sumComb :: M.Map Integer Integer -> Integer
sumComb dict = sum $ map comb $ M.elems dict

comb :: Integer -> Integer
comb k
    | k < 2 = 0
    | otherwise = div (k * (fromIntegral k - 1)) 2

readInt = fst . fromJust . BS.readInteger
readIntList = map readInt . BS.words
getIntList = readIntList <$> BS.getLine

Measured memory_bytes: 49788
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<cmath>
#include<iostream>
#include<algorithm>
#define ll long long

using namespace std;
ll t[120];
ll gcd(ll m , ll n){
    ll r = 0 ;
    while(n){
        r = m%n;
        m = n;
        n = r;
    }
    return m;
}
int main()
{
    int n;
    scanf("%d",&n);
    for(int i=0;i<n;i++)
    {
        cin>>t[i];
    }
    ll ans;
    if(t[0]<t[1]) swap(t[0],t[1]);
    ll x=gcd(t[0],t[1]);
    ans=(t[0]/x)*t[1];
    for(int i=2;i<n;i++)
    {
        if(t[i]>ans)
        x=gcd(t[i],ans);
        else x=gcd(ans,t[i]);
        ans=(t[i]/x)*ans;
    }
    if(n==1) ans=t[0];
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>

using namespace std;

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

  int D, N;
  cin >> D >> N;

  if (N == 100) N = 101;
  for (int i = 0; i < D; ++i) {
    N *= 100;
  }

  cout << N << endl;

  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
//#include <boost/multiprecision/cpp_int.hpp>
//using multiInt = boost::multiprecision::cpp_int;

using ll = long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
template <typename Q_type>
using smaller_queue = priority_queue<Q_type, vector<Q_type>, greater<Q_type>>;

const int MOD_TYPE = 1;
const ll MOD = (MOD_TYPE == 1 ? (ll)(1e9 + 7) : 998244353);
const int INF = (int)1e9;
const ll LINF = (ll)4e18;
const double PI = acos(-1.0);

#define REP(i, m, n) for (ll i = m; i < (ll)(n); ++i)
#define rep(i, n) REP(i, 0, n)
#define MP make_pair
#define MT make_tuple
#define YES(n) cout << ((n) ? "YES" : "NO") << endl
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible") << endl
#define possible(n) cout << ((n) ? "possible" : "impossible") << endl
#define Yay(n) cout << ((n) ? "Yay!" : ":(") << endl
#define all(v) v.begin(), v.end()
#define NP(v) next_permutation(all(v))
#define dbg(x) cerr << #x << ":" << x << endl;

vector<int> Dx = {0, 0, -1, 1, -1, 1, -1, 1, 0};
vector<int> Dy = {1, -1, 0, 0, -1, -1, 1, 1, 0};

int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << setprecision(50) << setiosflags(ios::fixed);
  int n;
  cin >> n;
  vector<pii> v(n);
  rep(i, n)
  {
    cin >> v[i].first >> v[i].second;
  }
  sort(all(v));
  for (auto p : v)
  {
    cout << p.first << " " << p.second << endl;
  }
  return 0;
}



Measured memory_bytes: 3676
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
typedef long int li;
#define df 0


typedef struct{
  int i;
  int pref;
  int year;
  int no;
}data;

bool operator<(const data& x,const data& y){
  if(x.pref==y.pref)return x.year<y.year;
  return x.pref<y.pref;
}



int main(){
  int n,m; cin >> n >> m;
  vector<data> city(m);
  for(int i=0;i<m;i++){
    int p,y;  cin >> p >> y;
    city.at(i).i=i;
    city.at(i).pref=p;
    city.at(i).year=y;
  }
  sort(city.begin(),city.end());
  if(df){
    for(int i=0;i<m;i++){
      cout << city.at(i).pref << city.at(i).year << endl;
    }
  }
  int temp=1,prev=0;
  for(int i=0;i<m;i++){
    if(prev!=city.at(i).pref){
      temp=1;prev=city.at(i).pref;
    }else temp++;
    city.at(i).no=temp;
  }
  
  sort(city.begin(), city.end(), 
       [](const data& x,const data& y) {
	 return ( x.i < y.i );
       } );
  if(df){
    for(int i=0;i<m;i++){
      cout << city.at(i).i << city.at(i).year << endl;
    }
    cout << endl;
  }
  for(int i=0;i<m;i++){
    printf("%06d%06d\n",city.at(i).pref,city.at(i).no);
  }
}


Measured memory_bytes: 3072
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <cmath>
#include <memory.h>
#include <cassert>

using namespace std;


#define all(c) ((c).begin()), ((c).end())
#define debug(c) cerr << "> " << #c << " = " << (c) << endl;
#define iter(c) __typeof((c).begin())
#define present(c, e) ((c).find((e)) != (c).end())
#define cpresent(c, e) (find(all(c), (e)) != (c).end())
#define tr(i, c) for (iter(c) i = (c).begin(); i != (c).end(); i++)
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i, a, b) for (int i = (int)(a); i <= (int)(b); i++)

#define mp make_pair
#define fst first
#define snd second
#define pb push_back


const double EPS = 1e-10;


typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef complex<double> P;


template<class T> void pv(T a, T b) { for (T i = a; i != b; ++i) cout << *i << " "; cout << endl; } 
template<class T> void pvp(T a, T b) { for (T i = a; i != b; ++i) cout << "(" << i->first << ", " << i->second << ") "; cout << endl; } 



int main() {
	for(string s; cin >> s; ) {
		rep(i, s.size()) {
			if (s[i] == '@') {
				rep(j, s[i + 1] - '0') cout << s[i + 2];
				i += 2;
			}
			else {
				cout << s[i];
			}
		}
		cout << endl;
	}
	
	return 0;
}

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

int main() {
	int N;
	cin>>N;
	if(N>999){return 0;}
	int p=N%10;
	if(p==3){cout<<"bon"<<endl;}
	else if(p==0||p==1||p==6||p==8){cout<<"pon"<<endl;}
	else{cout<<"hon"<<endl;}
	
	return 0;
}

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

int n,ans;
vector<int> V;

int change(char ch){
  if('0'<=ch&&ch<='9')return ch-'0';
  if('A'<=ch&&ch<='Z')return 10+ch-'A';
  return 36+ch-'a';
}

int main(){
  cin>>n;
  for(int i=0;i<n;i++){
    int p,num=0;
    string m;
    cin>>p>>m;
    for(int i=0;i<(int)m.size();i++)
      num=num*p+change(m[i]);
    ans^=num;
    V.push_back(num);
  }
  if(n==1 && V[0]==5){
    assert(0);
  }
  if(ans)cout<<"win"<<endl;
  else cout<<"lose"<<endl;
  return 0;
}

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

int main(void){
    int n;
    cin >> n;
    int64_t a, max = 0, sum = 0;
    for(int i=0; i<n; i++){
        cin >> a;
        if(a >= max) max = a;
        else sum += max - a;
    }
    cout << sum << '\n';
    return 0;
}

Measured memory_bytes: 3620
# -*- coding: utf-8 -*-
"""
Created on Sat Oct  5 21:16:35 2019

@author: 23374
"""

from math import *
P = 998244353

n = int(input())
num = int(input(),2) + 1

a = []

for i in range(2,int(sqrt(2*n))+1):
    if 2*n%i==0 :
        a.append(i)

b = a.copy()
b.reverse()
for x in b:
    if(x*x!=2*n):
        a.append(2*n//x)

def expgcd(x,x1,y,y1):
    if x<y :
        x, x1, y, y1 = y, y1, x, x1
    if y==0 :
        return (x,x1) if y1==-1 else (0,0)
    if y1==-1:
        return expgcd(x%y,x1,y,y1)
    else:
        c = -x1 if (x // y) % 2 == 1 else x1
        return expgcd(x%y,c,y,y1)

f = []
for k in a:
    x = expgcd(k,-1,n,1)
    f.append(0 if x == (0,0) else 2**x[0] + x[1])

Mnum = num % P
ans = Mnum * 2*n % P
g = [0] * len(a)
for i in range(len(a)):
    if (f[i]==0): continue
    x, y = a[i], num // ( (2**n+1) // f[i])
    for j in range(i):
        if (a[i]%a[j]==0) :
            y -= g[j]
    g[i] = y
    ans = (ans - y * (2*n - a[i]) ) % P

print( (ans+P) % P )

Measured memory_bytes: 3700
#include <queue>
#include <cstdio>
#include <algorithm>

#define MAX_H 1000
#define MAX_DIS 1000000

using namespace std;

typedef pair<int,int> P;

int H,W,N;
char board[MAX_H][MAX_H];
int dis[MAX_H][MAX_H];

int si,sj,gv;

int vx[4] = {1,-1,0,0};
int vy[4] = {0,0,1,-1};

void solve(){
	queue<P> que;
	int sum=0,n=1,value=0;
	
	while(n<=N){
	
		que.push(P(si,sj));
		for(int i=0;i<H;i++){
			for(int j=0;j<W;j++){
				dis[i][j] = MAX_DIS;
			}
		}
		dis[si][sj] = value;
		
		
		int qx,qy;
		while(1){
			P v = que.front(); que.pop();
			qx = v.first;
			qy = v.second;
			
			if(board[qx][qy] == '0'+(char)n) break;
			for(int i=0;i<4;i++){
				int pi,pj;
				pi = qx+vx[i];
				pj = qy+vy[i];
				if(-1<pi&&pi<H&&-1<pj&&pj<W&&board[pi][pj]!='X'&&dis[qx][qy]+1<dis[pi][pj]){
					dis[pi][pj] = dis[qx][qy]+1;
					que.push(P(pi,pj));
				}
			}
		}
		si = qx; sj = qy;
		value = dis[qx][qy];
		while(!que.empty()) que.pop();
		n++;
	}
	
	printf("%d\n",value);
}
	


int main(){
	scanf("%d %d %d",&H,&W,&N);
	
	for(int i=0;i<H;i++){
		for(int j=0;j<W;j++){
			char c;
			scanf(" %c",&c);
			board[i][j] = c;
			if(c=='S'){
				si = i; sj = j;
			}
		}
	}
	
	solve();
	
	return 0;
}

Measured memory_bytes: 5928
#include <bits/stdc++.h>
#define ll long long

using namespace std;

int main()
{
        ll h, n;
        cin>>h>>n;
        ll attack;
        while (n--) {
                cin>>attack;
                h-=attack;
        }

        if (h > 0) {
                cout<<"No"<<endl;
        } else {
                cout<<"Yes"<<endl;
        }

        return 0;
}


Measured memory_bytes: 256
//Catchharsh
#include<bits/stdc++.h>
#define ll long long int 
#define ld long double
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define F first
#define S second
#define sz(x) x.size()
#define all(x) x.begin(),x.end()
#define pb push_back
#define endl '\n'
#define see(x) cout<<#x<<" = "<<x<<endl
const ll MOD = 1e9+7;
const ll INF = 1011111111;
const ll LLINF = 1000111000111000111LL;
const ld EPS = 1e-10;
const ld PI = 3.14159265358979323;
using namespace std;
// #include <ext/pb_ds/assoc_container.hpp> 
// #include <ext/pb_ds/tree_policy.hpp> 
// using namespace __gnu_pbds; 
// #define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update> 
inline ll add(ll a,ll b){a+=b;if(a>=MOD)a-=MOD;return a;}
inline ll sub(ll a,ll b){a-=b;if(a<0)a+=MOD;return a;}
inline ll mul(ll a,ll b){return (a*1ll*b)%MOD;}
ll power (ll base,ll exponent)
{
    ll ans=1;
    //base%=MOD;
    //exponent%=(MOD-1);
    while(exponent!=0)
    {
      if(exponent&1) ans=(1LL*ans*base);
      base=(1LL*base*base);
      exponent>>=1;
    }
    return ans;
}
ll f[105];
int32_t main()
{   
     IOS;
     
     ll n,m,i,j,k;
     cin>>n>>k;
     while(k--)
     {
       ll sz;
       cin>>sz;
       for(i=0;i<sz;i++)
       {
        ll y;
        cin>>y;
        f[y]++;
       }
     }
     ll cnt=0;
     for(i=1;i<=n;i++) if(!f[i]) cnt++;
     cout<<cnt;

     
     cerr <<endl<< "Time elapsed : " << clock() * 1000.0 / CLOCKS_PER_SEC << " ms" << '\n';             
}

Measured memory_bytes: 3784
#include <stdio.h>
#define MAX 100000
int linearSearch(int,int);

int S[MAX],T[MAX];

int main(){
  int n,q,i,j,k,count=0;

  scanf("%d",&n);
  for(i = 0; i < n; i++){
    scanf("%d",&S[i]);
  }

  scanf("%d",&q);
  for(i = 0; i < q; i++){
    scanf("%d",&T[i]);
  }

  for(i = 0; i < q; i++){
    count = count + linearSearch(T[i],n);
    /*printf("%d\n",count);*/
  }
  
  printf("%d\n",count);

  return 0;
}

int linearSearch(int key,int n){
  int i;
  for(i = 0; i < n; i++){
    if(S[i] == key){
      return 1;
    }
  }
  return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <iomanip>
#include <sstream>
#include <vector>
#include <string>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>
#include <functional>
#include <iterator>
#include <limits>
#include <numeric>
#include <utility>
#include <type_traits>
#include <cmath>
#include <cassert>
#include <cstdio>

using namespace std;
using namespace placeholders;

using LL = long long;
using ULL = unsigned long long;
using VI = vector< int >;
using VVI = vector< vector< int > >;
using VS = vector< string >;
using ISS = istringstream;
using OSS = ostringstream;
using PII = pair< int, int >;
using VPII = vector< pair< int, int > >;
template < typename T = int > using VT = vector< T >;
template < typename T = int > using VVT = vector< vector< T > >;
template < typename T = int > using LIM = numeric_limits< T >;

template < typename T > inline istream& operator>>( istream &s, vector< T > &v ){ for ( T &t : v ) { s >> t; } return s; }
template < typename T > inline ostream& operator<<( ostream &s, const vector< T > &v ){ for ( int i = 0; i < int( v.size() ); ++i ){ s << ( " " + !i ) << v[i]; } return s; }

void in_impl(){};
template < typename T, typename... TS > void in_impl( T &head, TS &... tail ){ cin >> head; in_impl( tail ... ); }
#define IN( T, ... ) T __VA_ARGS__; in_impl( __VA_ARGS__ );

template < typename T > inline T fromString( const string &s ) { T res; istringstream iss( s ); iss >> res; return res; }
template < typename T > inline string toString( const T &a ) { ostringstream oss; oss << a; return oss.str(); }

#define NUMBERED( name, number ) NUMBERED2( name, number )
#define NUMBERED2( name, number ) name ## _ ## number
#define REP1( n ) REP2( NUMBERED( REP_COUNTER, __LINE__ ), n )
#define REP2( i, n ) REP3( i, 0, n )
#define REP3( i, m, n ) for ( int i = ( int )( m ); i < ( int )( n ); ++i )
#define GET_REP( a, b, c, F, ... ) F
#define REP( ... ) GET_REP( __VA_ARGS__, REP3, REP2, REP1 )( __VA_ARGS__ )
#define FOR( e, c ) for ( auto &&e : c )
#define ALL( c ) begin( c ), end( c )
#define AALL( a ) ( remove_all_extents< decltype( a ) >::type * )a, ( remove_all_extents< decltype( a ) >::type * )a + sizeof( a ) / sizeof( remove_all_extents< decltype( a ) >::type )

#define SZ( v ) ( (int)( v ).size() )
#define EXISTS( c, e ) ( ( c ).find( e ) != ( c ).end() )

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


#define PB push_back
#define EM emplace
#define EB emplace_back
#define BI back_inserter

#define MP make_pair
#define fst first
#define snd second

#define DUMP( x ) cerr << #x << " = " << ( x ) << endl

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

	IN( int, N );

	map< PII, int > counts;
	REP( i, 1, N + 1 )
	{
		const string s = toString( i );
		++counts[ MP( s[0], s.back() ) ];
	}

	LL res = 0;
	REP( i, 1, N + 1 )
	{
		const string s = toString( i );
		res += counts[ MP( s.back(), s[0] ) ];
	}
	cout << res << endl;

	return 0;
}

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

using namespace std;
typedef long long ll;


int main(){
    vector<string> startB;
    vector<string> endA;
    vector<string> both;
    vector<string> none;
    int n;
    cin >> n;
    string str;
    for(int i=0;i<n;++i){
        cin >> str;
        bool a=false,b=false;
        if(str[0]=='B') b = true;
        if(str[str.size()-1]=='A') a= true;
        if(a and b) both.push_back(str);
        else if(a and !b) endA.push_back(str);
        else if(!a and b) startB.push_back(str);
        else none.push_back(str);
    }
    string ans = "";
    for(int i=0;i<both.size();++i) ans = ans + both[i];
    bool A = false;
    if(endA.size()>0){
        ans = endA[0] + ans;
    }
    if(startB.size()>0){
        ans = ans + startB[0];
    }
    int i;
    for(i = 1;i<min(endA.size(),startB.size());++i){
        ans = ans + endA[i];
        ans = ans + startB[i];
    }
    for(int j = i;j<endA.size();++j) ans = ans + endA[j];
    for(int j = i;j<startB.size();++j) ans = ans + startB[j];
    for(i =0;i<none.size();++i) ans = ans + none[i];
    int count = 0;
    for(i = 0;i<ans.size()-1;++i){
        if(ans[i]=='A' and ans[i+1]=='B') count++;
    }
    cout << count << endl;
}

Measured memory_bytes: 1068
// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        a: usize, b: usize, c: usize, d: usize
    }
    let left = a + b;
    let right = c + d;
    let ans = if left > right {
        "Left"
    } else if left == right {
        "Balanced"
    } else {
        "Right"
    };
    println!("{}", ans);
}


Measured memory_bytes: 4352
#include<bits/stdc++.h>
#include<unordered_map>
using namespace std;
#define ll long long
#define all(x) (x).begin(),(x).end()
#define rep(i, n) for(ll i = 0; i < n; i++)
const ll INF = 100100100100100100;//10^17
const ll MOD = 1000000007;


ll combination(ll n, ll r){
    if(n < r) return 0;
    if(r == 0||r == n) return 1;
    else if(r == 1) return n;
    return (combination(n - 1, r - 1) + combination(n - 1, r));
}

bool checkKaibun(string str){
    string checkStr = str;
    reverse(checkStr.begin(), checkStr.end());
    if(str == checkStr) return true;
    else return false;
}




int main(){
    int N;
    cin >> N;
    string S;
    cin >> S;
    ll r = 0, g = 0, b = 0;
    rep(i, N){
        if(S[i] == 'R')r++;
        if(S[i] == 'G')g++;
        if(S[i] == 'B')b++;
    }

    ll ans = r * b * g;
    for(int i = 0; i < N; i++){
        for(int j = i + 1; j < N; j++){
            if(2 * j - i < N){
                if((S[i] != S[j]) && (S[j] != S[2 * j - i]) && (S[i] != S[2 * j - i]))ans--;
            }
        }
    }
    cout << ans << endl;
}



Measured memory_bytes: 3616
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <iostream>
#include <vector>
#include <string>
#include <sstream>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <functional>

using namespace std;

#define fst first
#define scd second
#define PB push_back
#define MP make_pair
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define omajinai ios::sync_with_stdio(false);cin.tie(0)
#define rep(i,x) for(int i=0;i<(int)(x);++i)
#define rep1(i,x) for(int i=1;i<=(int)(x);++i)

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

template<typename T>T& max(T&a,T&b){if(a>=b)return a;return b;}
template<typename T>T& min(T&a,T&b){if(a<b)return a;return b;}
template<typename T>bool chmax(T&a,T b){if(a<b){a=b;return true;}return false;}
template<typename T>bool chmin(T&a,T b){if(a>b){a=b;return true;}return false;}
template<typename T>T get(){T a;cin>>a;return a;}
template<typename T>T rev(T a){reverse(all(a));return a;}
template<typename T>vector<T>&sort(vector<T>&a){sort(all(a));return a;}

const int inf = 1e9;
const ll linf = 3e18;
const double eps = 1e-9;

signed main()
{
    int s = 0;
    int a;
    cin >> a;
    s += a;
    cin >> a;
    s += a * 5;
    cin >> a;
    s += a * 10;
    cin >> a;
    s += a * 50;
    cin >> a;
    s += a * 100;
    cin >> a;
    s += a * 500;
    cout << (s >= 1000) << endl;
}

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

const double PI = 3.14159265358979323846;
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
#define rep(i, n) for (int i = 0; i < (n); ++i)
//typedef pair<ll, ll> P;
typedef pair<ll, int> P;
const ll INF = 1e15;
#define cmin(x, y) x = min(x, y)
#define cmax(x, y) x = max(x, y)
#define ret() return 0;

std::istream &operator>>(std::istream &in, set<int> &o) {
    ll a;
    in >> a;
    o.insert(a);
    return in;
}

std::istream &operator>>(std::istream &in, queue<int> &o) {
    ll a;
    in >> a;
    o.push(a);
    return in;
}

bool contain(set<int> &s, int a) { return s.find(a) != s.end(); }

//ifstream myfile("C:\\Users\\riku\\Downloads\\0_00.txt");
//ofstream outfile("log.txt");
//outfile << setw(6) << setfill('0') << prefecture << setw(6) << setfill('0') << rank << endl;
// std::cout << std::bitset<8>(9);
const int mod = 1000000007;
//const ll mod = 1e10;
typedef priority_queue<string, vector<string>, greater<string> > PQ_ASK;


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

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

    ll ans = INF;
    {
        ll sum = 0;
        // +-+-
        vector<ll> tos(n, 0);
        rep(i, n) {
            if (i % 2 == 0) {
                if (sum + numbers[i] >= 1) {
                    tos[i] = numbers[i];
                    sum += numbers[i];
                } else {
                    ll to = 1 - sum;
                    assert(sum + to == 1);
                    tos[i] = to;
                    sum += to;
                }
            } else {
                if (sum + numbers[i] <= -1) {
                    tos[i] = numbers[i];
                    sum += numbers[i];
                } else {
                    ll to = -1 - sum;
                    assert(sum + to == -1);
                    tos[i] = to;
                    sum += to;
                }
            }
        }

        ll diff = 0;
        rep(i, n) diff += abs(numbers[i] - tos[i]);
        cmin(ans, diff);
    }
    {
        ll sum = 0;
        // -+-+
        vector<ll> tos(n, 0);
        rep(i, n) {
            if (i % 2 == 1) {
                if (sum + numbers[i] >= 1) {
                    tos[i] = numbers[i];
                    sum += numbers[i];
                } else {
                    ll to = 1 - sum;
                    assert(sum + to == 1);
                    tos[i] = to;
                    sum += to;
                }
            } else {
                if (sum + numbers[i] <= -1) {
                    tos[i] = numbers[i];
                    sum += numbers[i];
                } else {
                    ll to = -1 - sum;
                    assert(sum + to == -1);
                    tos[i] = to;
                    sum += to;
                }
            }
        }

        ll diff = 0;
        rep(i, n) diff += abs(numbers[i] - tos[i]);
        cmin(ans, diff);
    }
    cout << ans << endl;
}


Measured memory_bytes: 1804
#include<bits/stdc++.h>
using namespace std;
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
typedef long long int ll;
#define forn(i,p,n); for(long long i=p;i<n;++i)
#define rofn(i,p,n); for(long long i=p;i>n;--i)
#define pb push_back
#define pi pair
#define vi vector
#define ump unordered_map
void solve(){
	ll n;
	cin >> n;
	if(n) cout<<0;
	else cout<<1;
}
int main()
{
	fast;
	// int test;
	// cin >> test;
	// while(test--){
		solve();
	// 	cout<<"\n";
	// }
}

Measured memory_bytes: 3636
k = gets.to_i
gcds = Array.new(k+1).map{Array.new(k+1,0)}

for i in 1..k
  for j in 1..k
    gcds[i][j] = gcds[j][i] = i.gcd(j)
  end
end

sum = 0
for i in 1..k
  for j in i..k
    for k in j..k
      cs = 6
      if i == j
        cs = 3
        if j == k
          cs = 1
        end
      elsif j == k
        cs = 3
      end
      sum += gcds[gcds[i][j]][k] * cs
    end
  end
end
puts sum


Measured memory_bytes: 14664
def isu(X, Y, Z):
	#X > n * Y + (n+1) * Z = (X - Z) / (Y + Z) > n
	n_people = int((X - Z) / (Y + Z))
	print(n_people)

C = list(map(int,input().split()))
isu(C[0], C[1], C[2])

Measured memory_bytes: 2940
//05
#include<iostream>
#include<algorithm>

using namespace std;

int main(){
  bool ns=false;
  for(int n;cin>>n,n;){
    int c[4];
    cin>>c[3]>>c[2]>>c[1]>>c[0];
    int a[]={500,100,50,10};
    int ch=-n;
    for(int i=0;i<4;i++){
      ch+=a[i]*c[i];
    }
    int cc[4]={};
    for(int i=0;i<4;i++){
      cc[i]=ch/a[i];
      ch%=a[i];
    }
    if(ns){
      cout<<endl;
    }
    ns=true;
    for(int i=3;i>=0;i--){
      int s=max(0,c[i]-cc[i]);
      if(s){
	cout<<a[i]<<' '<<s<<endl;
      }
    }
  }
  return 0;
}

Measured memory_bytes: 1156
#include <iostream>
#include <set>
#include <algorithm>
using namespace std;
set<string>q;
int main() {
    string s,ss;
    int k;
    cin>>s>>k;
    int t=int(s.size());
    for(int i=0;i<t;i++){
        ss="";
        for(int j=i;j<min(t, i+5);j++){
            ss+=s[j];
            q.insert(ss);
        }
    }
    set<string>::iterator it=q.begin();
    k--;
    while(k--)
        it++;
    cout<<*it<<endl;
    return 0;
}


Measured memory_bytes: 1664
h,w=map(int,input().split())
box=[list(input()) for i in range(h)]
box_y=[]
for i in range(h):
    if "#" in box[i]:box_y.append(box[i])

box_t=[[] for _ in range(len(box_y))]
for i in range(w):
    if any(["#"==box_y[j][i] for j in range(len(box_y))]):
        for j in range(len(box_y)):
            box_t[j].append(box_y[j][i])

for i in box_t:
    print("".join(i))

Measured memory_bytes: 39408
#include <stdio.h>
#include <stdlib.h>
#include <math.h>

double dabs(double x) {
    if(x >= 0) return x;
    else return (-1)*x;
}

int main(void) {

    int A, B, H, M; scanf("%d %d %d %d", &A, &B, &H, &M);

    double thetam = M_PI*M/30.0;
    double thetah = (H/6.00 + M/360.00)*M_PI;

    printf("%.16f\n", sqrt(A*A+B*B-2*A*B*cos(dabs(thetam-thetah))));

    return 0;
}

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

int top,S[1000];

void push(int x){
  S[++top]=x;
}

int pop(){
  top--;
  return S[top+1];
}

int main(){
  int a,b;
  top=0;
  char s[100];

  while(scanf("%s",s)!=EOF){
    if(s[0]=='+'){
      a=pop();
      b=pop();
      push(a+b);
    }else if(s[0]=='-'){
      b=pop();
      a=pop();
      push(a-b);
    }else if(s[0]=='*'){
      a=pop();
      b=pop();
      push(a*b);
    }else{
      push(atoi(s));
    }
  }

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

  return 0;
}



Measured memory_bytes: 2108
'use strict';
(function(stdin) {
    var inputs = stdin
        .toString()     // ?????????????????????
        .trim()         // ????????¨????????????????????????????????????
        .split('\n');   // ???????????????

    var sorted = inputs
         .map(Number)            //  ??°??????
         .sort(function(a,b) {   //  ????????????????????????
             return b - a; 
         })
         .slice(0,3)             // ????????????3????????????
         .join('\n');            // ????????§??????
    console.log(sorted);
}(require('fs').readFileSync('/dev/stdin', 'utf8')));

Measured memory_bytes: 7640
sx,sy,tx,ty=map(int,input().split())
ans = "R"*(tx-sx)+"U"*(ty-sy)+"L"*(tx-sx)+"D"*(ty-sy+1)+"R"*(tx-sx+1)+"U"*(ty-sy+1)+"L"+"U"+"L"*(tx-sx+1)+"D"*(ty-sy+1)+"R"
print(ans)

Measured memory_bytes: 3060
#include <iostream>

using namespace std;

int main()
{
    long long x,digits=0,first;
    cin>>x;
    x++;
    while (x>0){
        first = x%10;
        digits++;
        x = (x-x%10)/10;
    }

    cout<<first-1+9*(digits-1)<<endl;



    return 0;
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-
 
a,b = map(int,raw_input().split())
s = raw_input()
flg = True

for i in range(0,a):
    if(not('0'<=s[i] and s[i]<='9')):flg = False
if(s[a] != '-'):flg = False
for i in range(a+1,a+b+1):
    if(not('0'<=s[i] and s[i]<='9')):flg = False
print('Yes' if flg else 'No')

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

using namespace std;
typedef long long ll;

#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep2(i, a, b) for (int i = (a); i < (b); ++i)
#define all(a) (a).begin(), (a).end()
#define all2(a, b) (a).begin(), (a).begin() + (b)
#define debug(vari) cerr << #vari << " = " << (vari) << endl;

char *demangle(const char *demangle)
{
    int status;
    return abi::__cxa_demangle(demangle, 0, 0, &status);
}
int n, m;
vector<int> A(20 + 10);
vector<int> Q(200 + 10);

int main()
{
    cin >> n;
    int total = 0;
    rep(i, n)
    {
        cin >> A[i];
        total += A[i];
    }
    cin >> m;
    rep(i, m) cin >> Q[i];

    rep(i, m)
    {
        if(total<Q[i])
        {
            puts("no");
            continue;
        }
        bool ok = false;
        for (int bit = 0; bit < (1 << n); bit++)
        {
            int res = 0;
            for (int j = 0; j < n; j++)
            {
                if (bit & (1 << j))
                {
                    res += A[j];
                    if(res>Q[i]){
                        break;
                    }
                }
                
            }
            if (res == Q[i])
            {
                ok = true;
                break;
            }
        }
        puts(ok ? "yes" : "no");
    }

    return 0;
}



Measured memory_bytes: 3096
#include <iostream>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <vector>
#include <set>
#include <queue>
#include <map>
#include <string>

#define rep(i, a, b) for ( int i = (a); i < (b); i++ )
#define per(i, a, b) for ( int i = (b)-1; i >= (a); i--)
#define pb push_back
#define mp make_pair
#define bg begin()
#define en end()


using namespace std;

typedef long long ll;

static const long long MOD = 1000000007;

int ans;


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

  
    printf("%d\n", (N+1)/2);

	return 0;
}


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

const int N = 100005, P = 1000000007;
int fac[2 * N], ifac[2 * N], E[2 * N];

int power(int a, int x) {
	int ans = 1;
	for (; x; x >>= 1, a = 1LL * a * a % P)
		if (x & 1) ans = 1LL * ans * a % P;
	return ans;
}

int binom(int n, int m) {
	return 1LL * fac[n] * ifac[m] % P * ifac[n - m] % P;
}

int solve(int n, int a, int b, int c) {
	int x = 1LL * a * power((a + b) % P, P - 2) % P, y = 1LL * b * power((a + b) % P, P - 2) % P;
	int ans = 0;
	for (int i = 0; i < n; ++i)
		ans = (ans + 1LL * binom(n - 1 + i, i) * power(x, n) % P * power(y, i) % P * E[n + i]) % P;
	return ans;
}

int main() {
	int n, a, b, c;
	scanf("%d%d%d%d", &n, &a, &b, &c);
	a = 1LL * a * power(100, P - 2) % P;
	b = 1LL * b * power(100, P - 2) % P;
	c = 1LL * c * power(100, P - 2) % P;
	int tmp = power(P + 1 - c, P - 2);
	for (int i = 1; i <= n + n; ++i)
		E[i] = (tmp + E[i - 1]) % P;
	for (int i = fac[0] = 1; i <= 2 * n; ++i) fac[i] = 1LL * fac[i - 1] * i % P;
	ifac[2 * n] = power(fac[2 * n], P - 2);
	for (int i = 2 * n; i; --i) ifac[i - 1] = 1LL * ifac[i] * i % P;
	int ans = (solve(n, a, b, c) + solve(n, b, a, c)) % P;
	printf("%d\n", ans);
	return 0;
}


Measured memory_bytes: 2560