akhauriyash/Code-Regression huggingface dataset:
#include <cmath>
#include <cstdio>
#include <vector>
#include <list>
#include <iostream>
#include <algorithm>
#include <sstream>
#include <stack>
#include <fstream>
#include <queue>
#include <iomanip>
#include <iterator>
#include <map>
#include <unordered_map>
#include <set>
#define fast ios_base::sync_with_stdio(false)
#define ll long long int
#define ld long double
#define vi vector<ll>
#define vvi vector<vi >
#define pi pair<ll,ll>
#define vvpi vector<vector<pi > >
#define vpi vector<pi >
#define vppi vector<pair<ll,pi > >
#define vs vector<string>
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define pb push_back
#define eb emplace_back
#define mkp make_pair
#define fs first
#define se second
#define crz(v,n,c) v.clear(),v.resize(n,c)
#define print(v) for(ll it=0;it<v.size();it++) cout<<v[it]<<" ";cout<<endl
#define printp(v) for(ll it=0;it<v.size();it++) cout<<v[it].first<<" "<<v[it].second<<endl
using namespace std;
int main(){
	ll a,b;
  	cin>>a>>b;
  	if(a>9||b>9) cout<<"-1\n";
  	else cout<<a*b<<endl;
}

Measured memory_bytes: 256
#include <algorithm>  
#include <iostream>  
#include <sstream>  
#include <string>  
#include <cstring>
#include <vector>  
#include <queue>  
#include <set>  
#include <map>  
#include <cstdio>  
#include <cstdlib>  
#include <cctype>  
#include <cmath>  
#include <list>  
#include <cassert>
#include <ctime>
#include <climits>
using namespace std;  

#define PB push_back  
#define MP make_pair  
#define SZ(v) ((int)(v).size())  
#define FOR(i,a,b) for(int i=(a);i<(b);++i)  
#define REP(i,n) FOR(i,0,n)  
#define FORE(i,a,b) for(int i=(a);i<=(b);++i)  
#define REPE(i,n) FORE(i,0,n)  
#define FORSZ(i,a,v) FOR(i,a,SZ(v))  
#define REPSZ(i,v) REP(i,SZ(v))  
typedef long long ll;
typedef unsigned long long ull;
ll gcd(ll a,ll b) { return b==0?a:gcd(b,a%b); }

const int MAXN = 100000;

int n;
int a[MAXN], b[MAXN], c[MAXN];

void run() {
	scanf("%d", &n); REP(i, n) scanf("%d", &a[i]); REP(i, n) scanf("%d", &b[i]); REP(i, n) scanf("%d", &c[i]);
	sort(a, a + n); sort(b, b + n); sort(c, c + n);
	ll ret = 0; int ai = 0; /*exclusive */ int ci = 0; /* inclusive */
	REP(i, n) {
		while (ai < n&&a[ai] < b[i]) ++ai;
		while (ci < n&&c[ci] <= b[i]) ++ci;
		ret += (ll)ai*(n - ci);
	}
	printf("%lld\n", ret);
}

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


Measured memory_bytes: 1408
import java.util.*

private fun readStrings() = readLine()!!.split(" ")
private fun readInts() = readStrings().map { it.toInt() }

sealed class Point(val coord: Pair<Int, Int>) {
    class Red(coord: Pair<Int, Int>): Point(coord)
    class Blue(coord: Pair<Int, Int>): Point(coord)
}

fun takeInputs(n: Int) = (1..n).map {
    val (a, b) = readInts()
    a to b
}

fun main(args: Array<String>) {
    val N = readInts()[0]
    val reds = takeInputs(N).map { Point.Red(it) }
    val blues = takeInputs(N).map { Point.Blue(it) }

    val points = (reds + blues).sortedBy { it.coord.first }

    val redCache = HashSet<Point.Red>()
    points.forEach { point ->
        when (point) {
            is Point.Red -> redCache.add(point)
            is Point.Blue -> {
                redCache
                        .filter { it.coord.second < point.coord.second }
                        .maxBy { it.coord.second }
                        ?.let {
                            redCache.remove(it)
                        }
            }
        }
    }

    println(N - redCache.size)
}

Measured memory_bytes: 38028
N = int(input())
p = tuple(map(float, input().split()))

dp = [[0] * (N + 1) for _ in range(N + 1)]
dp[0][0] = 1

for i in range(1, N + 1):
    for j in range(i + 1):
        dp[i][j] = (dp[i - 1][j] * (1 - p[i - 1])) + (dp[i - 1][j - 1] * p[i - 1])

ans = 0
for j in range(N // 2 + 1, N + 1):
    ans += dp[N][j]
print(ans)
# print(dp)

Measured memory_bytes: 264200
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const static ll INF = 1e15;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
// __uint128_t
const ll MOD = 1e9+7;

vector<ll> DP(1e6, -1);
vector<ll> POP(1e6, -1);

ll func(ll a){
    ll cnt = 0;
    vector<ll> temp;
    while(a != 0){
        if(DP[a] != -1){
            cnt += DP[a];
            for(int i = 0; i < temp.size(); i++) DP[a] = cnt-i;
            return cnt;
        }
        temp.push_back(a);
        ll S = POP[a];
        a = a % S;
        cnt++;
    }
    for(int i = 0; i < temp.size(); i++) DP[a] = cnt-i;
    return cnt;
}


int main(){
    ll N; cin >> N;
    string S; cin >> S;
    for(int i = 0; i <= N; i++){
        bitset<20> B = i;
        POP[i] = B.count();
    }

    ll BS = 0;
    for(auto ch : S) if(ch == '1') BS++;
    ll MULS = 0;
    ll MULR = 0;
    vector<ll> MODPOWS(1e6, 0), MODPOWR(1e6, 0);

    MODPOWS[0] = 1, MODPOWR[0] = 1;
    for(int i = 1; i < 1e6; i++) {
        MODPOWS[i] = MODPOWS[i-1]*2;
        MODPOWS[i] %= (BS+1);
        MODPOWR[i] = MODPOWR[i-1]*2;
        if(BS > 1) MODPOWR[i] %= (BS-1);
    }


    for(int i = 0; i < N; i++){
        if(S[i] == '1') {
            //MULS += modpow(2, N-i-1, BS+1);
            MULS += MODPOWS[N-i-1];
            MULS %= (BS+1);
            if(1 < BS) {
                //MULR += modpow(2, N-i-1, BS-1);
                MULR += MODPOWR[N-i-1];
                MULR %= (BS-1);
            }
        }
    }
    for(int i = 0; i < N; i++){
        ll MUL;
        if(S[i] == '1'){
            if(BS == 1) {cout << 0 << endl; continue; }
            if(1 < BS)MUL = MULR - MODPOWR[N-i-1];
            if(1 < BS)MUL = (MUL + BS-1) % (BS-1);
        }
        else{
            MUL = MULS + MODPOWS[N-i-1];
            MUL = (MUL + BS+1) % (BS+1);
        }
        cout << func(MUL)+1 << endl;
    }

} 

Measured memory_bytes: 34880
#include<iostream>
#include<algorithm>
#include<vector>
#include<utility>
#include<string>
using namespace std;
typedef pair<int, string> PIS;
typedef vector<PIS> VP;
typedef VP::iterator VPI;

int main()
{
	while (true){
		int n;
		cin >> n;
		if (!n) break;
		VP word;
		VPI p;
		string s = "";
		char sample;
		cin.ignore();
		for (int i = 0; i < n; i++){
			string in;
			getline(cin, in);
			in += ' ';
			s += in;
		}
		cin >> sample;
		string hoge = "";
		for (int i = 0; i < s.size(); i++){
			if (s[i] == ' '){
				if (hoge[0] == sample) word.push_back(make_pair(1, hoge));
				hoge = "";
			}
			else hoge += s[i];
		}
		if (word.empty()){
			cout << "NA" << endl;
			continue;
		}

		sort(word.begin(), word.end());
		
		for (p = word.begin(); p != word.end() - 1;){
			if (p->second == (p + 1)->second){
				p->first++;
				word.erase(p + 1);
			}
			else p++;
		}

		//bsort
		VPI p1, p2;
		for (p1 = word.begin(); p1 != word.end(); p1++){
			for (p2 = word.begin(); p2 != word.end() - 1; p2++){
				if ((p2->first < (p2 + 1)->first) || (p2->first == (p2 + 1)->first && p2->second >(p2 + 1)->second)){
					PIS hoge = *p2;//swap
					*p2 = *(p2 + 1);
					*(p2 + 1) = hoge;
				}
			}
		}

		p = word.begin();
		for (int i = 0; p != word.end() && i < 5; i++, p++){
			cout << p->second;
			if (p == word.end() - 1 || i == 4) cout << endl;
			else cout << " ";
		}
	}
	return 0;
}

Measured memory_bytes: 1252
// g++ -std=c++17 -D LOCAL B.cpp
// Date: 53:03:01 31 05 2020
// Author: bonelord
#include <bits/stdc++.h>
using namespace std;

void solve(){
	int N;
	cin>>N;
	long long res = 1;
	long long arr[N];
	bool hasnull = false;
	for (auto &i : arr){
		cin>>i;
		hasnull |= i == 0;
	}
	if (hasnull){
		cout<<"0\n";
		return;
	}
	for (auto &x : arr){
		long long tmp = res*x;
		if (tmp < res || tmp < x || tmp > 1000000000000000000LL){
			cout<<"-1\n";
			return;
		}
		res = tmp;
	}
	cout<<res<<"\n";
}

main(){
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.setf(ios::fixed);
#ifdef LOCAL
	freopen("in", "r", stdin);
	freopen("err", "w", stderr);
#endif
//	int t; cin>>t; while (t--)
	solve();
}


Measured memory_bytes: 4428
//break_the_bond
//jatt_james_bond
#include <bits/stdc++.h>
// #define int long long
#define endl "\n"
using namespace std;
#define MAX 1000000009
#define IOS std::ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL);
bool comp(pair<int, int> &a, pair<int, int> &b)
{
    return a.first < b.first;
}

void solve()
{
    int n, x, t;
    cin >> n >> x  >> t;
    int ct{1}, tt = x;
    while (x < n)
    {
        x += tt;
        ct++;
    }
    cout << ct * t;
}
int32_t main()
{

    // cout << (-11 / -4);

    IOS int testcases = 1;
    // cin >> testcases;
    while (testcases--)
    {
        solve();
    }
    return 0;
}

Measured memory_bytes: 3608
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
const int maxn = 100005;

char str[maxn];

int main()
{
    while(~scanf("%s", str)){
        int n = strlen(str);
        for(int i = 0; i < n; i += 2){
            putchar(str[i]);
        }
        putchar('\n');
    }
    return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
#define int long long int
#define pb push_back
#define Pii pair<int,int>
#define SS second 
#define F first
#define mod 1000000007
#define ld long double
#define sp fixed<<setprecision(12)
using namespace std;
#define db(...) __f(#__VA_ARGS__, __VA_ARGS__)

template <typename Arg1>
void __f(const char* name, Arg1&& arg1) { cout << name << " : " << arg1 << '\n'; }
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args) {
    const char* comma = strchr(names + 1, ',');
    cout.write(names, comma - names) << " : " << arg1 << " | "; __f(comma + 1, args...);
}



void solve(){
    int n,m;
    cin>>n;
    if(n==1){
        cout<<"0";
        return;
    }
    if(n==2){
        cout<<"2";
        return;
    }
    int ans10=1;
    int ans8=1;
    int ans9=1;
    for(int i=1;i<=n;i++){
        ans10*=10;
        ans10%=mod;
        ans8*=8;
        ans8%=mod;
        ans9*=9;
        ans9%=mod;
    }
    ans9*=2;
    ans9%=mod;
    ans10=(ans10-ans9+ans8+mod)%mod;
    //ans10=(ans10-ans8);
    
    cout<<ans10<<'\n';

}


int32_t main(){

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    #ifndef ONLINE_JUDGE
        freopen("input.txt","r",stdin);
        freopen("output.txt","w",stdout);
    #endif
    //double    pi=3.14159265358979323846;
    //sieve();
    int t=1;
    //cin>>t;
    while(t--){
        solve();
    }
    
    return 0;
    
}//Ardhendu Reja , JGEC

/*
int powmod(int x,int n,int p)
{
    int result=1;
    while(n>0)
    {
        if(n % 2 ==1)
            result=(result * x)%p;
        x=(x*x)%p;
        n=n/2;
    }
    return result;
}


int modmul(int a,int b) {
    return ((a % mod) * (b % mod)) % mod;
}
*/

//const int N=200005;
/*
struct dsu {
    vector<int> par;
    vector<int> rnk;
    vector<int> sz;

    void init(int n){
        par.resize(n+1);
        rnk.resize(n+1);
        sz.resize(n+1);
        for(int i=0;i<=n;i++){
            par[i]=i;
            rnk[i]=0;
            sz[i]=1;
        }
    }

   int findpar(int node ){
        if(node == par[node])
            return node;
        return par[node] = findpar(par[node]);
    }

    void unite(int u ,int v){
        int p1 = findpar(u);
        int p2 = findpar(v);
        if(p1!=p2)
        {
            int r1 = rnk[p1];
            int r2 = rnk[p2];
            if(r1 < r2)
            {
                par[p1] = p2;
                sz[p2]+=sz[p1];
                sz[p1]=0;
                rnk[p2]++;
            }
            else
            {
               par[p2] = p1;
               sz[p1]+=sz[p2];
               sz[p2]=0;
               rnk[p1]++;
            }
        }
    }

} G;
*/

Measured memory_bytes: 3660
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int count=0;
  string s,t;
  while(s.size()==0)
  {
     cin>>s;
  }
  while(t.size()==0)
  {
     cin>>t;
  }
  for(int i=0;i<3;i++)
  {
     if(s[i]==t[i])
       count++;

   }
  cout<<count<<endl;
}


Measured memory_bytes: 256
fun main(args: Array<String>) {
    val (N, A, B) = kotlin.io.readLine()!!.split(" ").map(String::toInt)


    val a = (1..N).filter {
        sumOfDigits(it) in A..B
    }
    println(a.sum())
}

fun sumOfDigits(n0: Int): Int {
    var n = n0
    var result = 0
    while (n != 0) {
        result += n % 10
        n /= 10
    }
    return result
}

Measured memory_bytes: 38028
#include<iostream>
#include <vector>
#include<list>
#include<algorithm>
#include<map>
#include<functional>
#include<stack>
#include<queue>

namespace graph{
	using namespace std;
	typedef long long LL;
	typedef vector<LL> VLL;
	typedef pair<LL, int> edge;
	typedef vector<list<edge>> ADJ;
#define mp(_x,_y) make_pair(_x,_y)
#define cost(_v) _v.first
#define to(_v) _v.second

	class UnionFind{
	public:
		//n???????´???°
		UnionFind(int n) :par(n), rank(n){
			for (int i = 0; i < n; ++i)
				par[i] = i;
		}

		//x??¨y????±??????????????????????
		void unite(int x, int y){
			x = find(x);
			y = find(y);
			if (x == y)return;
			if (rank[x] < rank[y])
				par[x] = y;
			else{
				par[y] = x;
				if (rank[x] == rank[y])rank[x]++;
			}
		}

		bool same(int x, int y){
			return find(x) == find(y);
		}



	private:
		//???
		vector<int> par;

		//????????±???
		vector<int> rank;

		//??¨??????????±???????
		int find(int x){
			if (par[x] == x)
				return x;
			else
				return par[x] = find(par[x]);
		}
	};

	VLL dijkstra(int s, ADJ& adj){
		int n = (int)adj.size();
		VLL res(n, -1);
		priority_queue<edge, vector<edge>, greater<edge>> que;
		que.push(mp(0ll, s));
		while (que.empty() == false){
			auto tmp = que.top(); que.pop();
			auto c = cost(tmp);
			auto v = to(tmp);
			if (res[v] >= 0)continue;
			res[v] = c;
			for (auto& i : adj[v]){
				auto d = cost(i);
				auto u = to(i);
				if (res[u] >= 0)continue;
				que.push(mp(c + d, u));
			}
		}
		return res;
	}
}


#define input_init stringstream ss; string strtoken, token; istringstream is
#define input_line  getline(cin, strtoken);is.str(strtoken);is.clear(istringstream::goodbit)
#define input_token(num) ss.str(""); ss.clear(stringstream::goodbit); getline(is, token, ','); ss << token; ss >> num
#define mp(_x,_y) make_pair(_x,_y)
using namespace std;
int main(void){
	int V, E,r;
	cin >> V >> E>>r;
	graph::ADJ adj(V);
	for (int i = 0; i < E; i++){
		int s, t;
		graph::LL d;
		cin >> s >> t >> d;
		adj[s].push_back(mp(d, t));
	}
	auto res = graph::dijkstra(r, adj);
	for (auto& i : res){
		if (i >= 0)cout << i << endl;
		else cout << "INF" << endl;
	}
	return(0);
}

Measured memory_bytes: 31692
import statistics as st
olist = []
while True:
    n = int(input())
    if n == 0:
        break
    lst = []
    lst = input().split()
    if n == 1:
        olist.append(0)
    else:
        lst = [int(s) for s in lst]
        olist.append(st.pstdev(lst))
for s in olist:
    print("{:.8f}".format(s))


Measured memory_bytes: 7076
#include<iostream>
using namespace std;
int A,B,C;
int main()
{
// 	system("color a0");
	cin>>A>>B>>C;
	if(B-A==C-B)
	{
		cout<<"YES"<<"\n";
	}
	else
	cout<<"NO"<<"\n";
	return 0;
}

Measured memory_bytes: 256
n, x = [ int(v) for v in input().split() ]
bound_list = [ int(v) for v in input().split() ]
ball_pos_list = [ 0 for i in range(n+1)]
for i in range(n):
    ball_pos_list[i+1] = ball_pos_list[i] + bound_list[i]
ball_pos_list = [ i for i in ball_pos_list if i <= x]
print(len(ball_pos_list))

Measured memory_bytes: 38384
#include <iostream>
#include <map>
#define rep(i, n) for (int i = 0; i < n; ++i)

using namespace std;

int main() {
	int n;
	cin >> n;
	map<string, int> cnt;
	
	rep(i, n) {
		string s;
		cin >> s;
		cnt[s]++;
	}
	
	for (string s : {"AC", "WA", "TLE", "RE"}) {
		cout << s << " x " << cnt[s] << '\n';
	}
	
	return 0;
}

Measured memory_bytes: 3604
#include <bits/stdc++.h>
#define REP(i, n) for (int (i) = 0; (i) < (int)(n); i++) 
#define FOR(i, a, b) for(int (i) = a; (i) < (int)b; i++)
#define RREP(i, n) for(int (i)=((int)(n)-1); (i)>=0; i--)
#define RFOR(i, a, b) for(int (i) =((int)(b)-1); (i)>=0; i--)
#define ALL(v) (v).begin(),(v).end()
#define MOD 1000000007
#define F first
#define S second

using namespace std ;
typedef long long ll;
typedef vector<int> vint;
typedef vector<vint> vvint;
typedef pair<int, int> pint;

int main()
{
  int n ;
  cin >> n ;
  vector<string> mozi(n) ;
  vector<int> count(n,0) ;
  int cou = 0 ;
  
  REP(i,n){
    cin >> mozi.at(i) ;
  }
  
  REP(i,n){
    REP(j,n){
      if(mozi.at(i)==mozi.at(j)){
        count.at(i)++ ;
      }
    }
  }
  sort(ALL(count)) ;
  
  REP(i,n-1){
    if(mozi.at(i).at(mozi.at(i).size()-1)==mozi.at(i+1).at(0)){
      cou++ ;
    }
  }
  //cout << cou <<endl ;
  //cout << count.at(n-1) <<endl ;
  
  if(cou==n-1 && count.at(n-1)==1){
     cout <<"Yes"<<endl ;
    }
    else{
      cout <<"No"<<endl ;
    }
      
  

  return 0 ;
}




Measured memory_bytes: 256
n=int(input())
x=input()
val=int(x,2)

cnt=x.count("1")
p_cnt=cnt+1
m_cnt=cnt-1
p_amari,m_amari=0,0

p_amari=val%(cnt+1)
if cnt-1!=0:
  m_amari=val%(cnt-1)
else:
  m_amari=0

for i in range(n):
  ans=0
  if x[i]=="0":
    amari=p_amari+pow(2,n-i-1,p_cnt)
    amari%=p_cnt
  elif x[i]=="1":
    if cnt-1==0:
      print(0)
      continue
    amari=m_amari-pow(2,n-i-1,m_cnt)
    amari%=m_cnt
  ans+=1
  while amari!=0:
    amari%=bin(amari).count("1")
    ans+=1
  print(ans)


Measured memory_bytes: 79412
n = int(input())
A = [input() for _ in range(n)]
A_t = [''] * n
for c in A:
    for i in range(n):
        A_t[i] += c[i]

def checkTable(shift):
    for i in range(n):
        if A_t[(i + shift) % n] != A[i][shift:] + A[i][:shift]:
            return False
    return True

count = 0
for i in range(n):
    if checkTable(i):
        count += 1
print(count * n)

Measured memory_bytes: 3188
n,m = map(int, raw_input().split())
s = [map(int, raw_input().split()) for _ in range(m)]
c = 0
s.sort()
cur = []
for u,v in s:
	if cur == []:
		cur = [u,v]
	if cur[1] <= u:
		cur = [u,v]
		c += 1 
	else:
		cur = [max(u, cur[0]),min(v, cur[1])]
print c + (1 if cur else 0)
"""
---- ------
     4    9
       ---
       5 6
       ------?
       5 

       5 ----- 10
"""

Measured memory_bytes: 89496
#include <iostream>
using namespace std;
int main(void){
  int a, b, c, i, min;
  cin >> a >> b >> c;

  min = 10000*3;
  if (min > a + b) min = a + b;
  if (min > b + c) min = b + c;
  if (min > c + a) min = c + a;

  cout << min << endl;

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=2005,p=1000000007;
int read(){
	int f=1,g=0;
	char ch=getchar();
	for (;!isdigit(ch);ch=getchar()) if (ch=='-') f=-1;
	for (;isdigit(ch);ch=getchar()) g=g*10+ch-'0';
	return f*g;
}
int n,m,a[N][N],ans;
vector<int> e[N];
unordered_set<int> g[N];
void build(int x,int fath,int *a,int val){
	a[x]=val;
	for (auto y : e[x])
	if (y!=fath) build(y,x,a,val);
}
bool chk(int x,int y,int z){
	return a[y][x]!=a[y][z];
}
void add(int u,int v){
	if (u==v) return;
	for (auto z : g[u])
	if (chk(u,z,v)) {add(z,v);return;}
	for (auto z : g[v])
	if (chk(u,z,v)) {add(z,u);return;}
	
	
	g[u].insert(v);
	g[v].insert(u);
	vector<int> f;
	f.clear();
	for (auto z : g[u])
	if ((z!=v)&&chk(u,v,z)) f.push_back(z);
	for (auto z : f)
	if (g[u].count(z)) {
		g[u].erase(z);
		g[z].erase(u);
		add(v,z);
	}
	f.clear();
	for (auto z : g[v])
	if ((z!=u)&&chk(v,u,z)) f.push_back(z);
	for (auto z : f)
	if (g[v].count(z)) {
		g[v].erase(z);
		g[z].erase(v);
		add(u,z);
	}
}
int work(int x,int fr){
	int t=1;
	for (auto y : g[x])
	if (chk(fr,x,y)) t+=work(y,x);
	return t;
}
int main(){
//	freopen("in39.txt","r",stdin);
	n=read();m=read();
	for (int i=1;i<n;i++){
		int u=read(),v=read();
		e[u].push_back(v);
		e[v].push_back(u);
	}
	for (int i=1;i<=n;i++)
	for (auto y : e[i]) build(y,i,a[i],y);
	for (int i=1;i<=m;i++){
		int u=read(),v=read();
		add(u,v);
	}
	for (int i=1;i<=n;i++)
	ans+=work(i,0)-1;
	printf("%d\n",ans/2);
	return 0;
}

Measured memory_bytes: 16640
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <vector>
#include <queue>
#include <numeric>
#include <string>
#include <string.h>
#include <map>
#include <set>
#include <functional>
#include <complex>

using namespace std;

const int INF = (1<<30) - 1;

class Crop{
public:
    string L;
    int P;
    int A, B, C, D, E, F;
    int S;
    int M;
    
    bool operator <(const Crop r) const{
        int tl = A+B+C+(D+E)*M;
        int sl = M*S*F-P;
        int tr = r.A+r.B+r.C+(r.D+r.E)*r.M;
        int sr = r.M*r.S*r.F-r.P;
        
        if(tl*sr == tr*sl){
            return L < r.L;
        }else{
            return sl*tr > sr*tl;
        }
    }
};

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int N;
    while(cin>>N, N){
        vector<Crop> crops(N);
        for(int i=0; i<N; i++){
            Crop &crop = crops[i];
            cin >> crop.L >> crop.P >> crop.A >> crop.B >> crop.C >> crop.D >> crop.E >> crop.F >> crop.S >> crop.M;
        }
        sort(crops.begin(), crops.end());
        for(int i=0; i<N; i++){
            cout << crops[i].L << endl;
        }
        cout << '#' << endl;
    }
    
    return 0;
}

Measured memory_bytes: 1228
#include <iostream>
#include <algorithm>
#include <set>

using namespace std;

int main(){
    int n,q;
    cin>>n>>q;
    set<int> st[n];
    
    for(int i=0;i!=n;++i){
        st[i].insert(i);
    }
    
    
    
    for(int i=0;i!=q;++i){
        int query;
        cin>>query;
    
        switch(query){
            case 0:
                int x0,y0,a,b;
                cin>>x0>>y0;
                a=-1;
                b=-2;
                
                for(int i=0;i!=n;++i){
                    if(st[i].find(x0)!=st[i].end()){
                        a=i;
                        break;
                    }
                }
                for(int i=0;i!=n;++i){
                    if(st[i].find(y0)!=st[i].end()){
                        b=i;
                        break;
                    }
                }
                if(a!=b){
                    for(set<int>::iterator itr=st[b].begin();itr!=st[b].end();++itr){
                        st[a].insert(*itr);
                    }
                    st[b].clear();
                }
                
                
                break;
            case 1:
                int x1,y1;
                cin>>x1>>y1;
                bool jud=false;
                for(int i=0;i!=n;++i){
                    if(st[i].find(x1)!=st[i].end()&&st[i].find(y1)!=st[i].end()){
                        jud=true;
                        break;
                    }
                }
                
                cout<<jud<<endl;
                        
                        
              
                
                
                break;
        }
        
    }
}



Measured memory_bytes: 4500
n,t = map(int,input().split())
a = list(map(int,input().split()))
md = 0
c = 0
m = a[-1]
for i in range(2,n+1):
  if m-a[-i] > md:
    md = m-a[-i]
    c = 1
  elif m-a[-i] == md:
    c += 1
  m = max(m,a[-i])
print(c)

Measured memory_bytes: 62704
/*
	Author: Ritik Patel
*/


//&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& STL DEBUGGER &&&&&&&&&&&&&&&&&&&&&&&&&&&

// #define _GLIBCXX_DEBUG       // Iterator safety; out-of-bounds access for Containers, etc.
// #pragma GCC optimize "trapv" // abort() on (signed) integer overflow.

//&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& LIBRARIES &&&&&&&&&&&&&&&&&&&&&&&&&&&

#include <bits/stdc++.h>
using namespace std;

/*#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
template<typename T, typename V = __gnu_pbds::null_type>
using ordered_set = __gnu_pbds::tree<T, V, less<T>, __gnu_pbds::rb_tree_tag, __gnu_pbds::tree_order_statistics_node_update>; 
*/
//find_by_order()->returns an iterator to the k-th largest element(0-based indexing)
//order_of_key()->Number of items that are strictly smaller than our item

//&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& DEFINES &&&&&&&&&&&&&&&&&&&&&&&&&&&

#define int long long int
#define all(i) i.begin(), i.end()
#define sz(a) (int)a.size()
 
// #define ld long double
// const ld PI  = 3.141592;
const int dx4[4] = {0, 1, 0, -1};
const int dy4[4] = {-1, 0, 1, 0};
const int dx8[8] = {-1, -1, -1, 0, 1, 1, 1, 0};
const int dy8[8] = {-1, 0, 1, 1, 1, 0, -1, -1};
 
//&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& DEBUG &&&&&&&&&&&&&&&&&&&&&&&&&&&
 
#define XOX
vector<string> vec_splitter(string s) {
    for(char& c: s) c = c == ','?  ' ': c;
    stringstream ss; ss << s;
    vector<string> res;
    for(string z; ss >> z; res.push_back(z));
    return res;
}
 
void debug_out(vector<string> __attribute__ ((unused)) args, __attribute__ ((unused)) int idx) { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(vector<string> args, int idx, Head H, Tail... T) {
    if(idx > 0) cerr << ", ";
    stringstream ss; ss << H;
    cerr << args[idx] << " = " << ss.str();
    debug_out(args, idx + 1, T...);
}
 
#ifdef XOX
#define debug(...) debug_out(vec_splitter(#__VA_ARGS__), 0, __VA_ARGS__)
#else
#define debug(...) 42
#endif
 
 
//&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& CODE &&&&&&&&&&&&&&&&&&&&&&&&&&&

void solve(){
    int N; cin >> N;
    vector<int> A(N);
    for(auto &x: A) 
        cin >> x;
    
    sort(all(A));
    reverse(all(A));

    int comfort = 0;
    multiset<pair<int, int>> s;

    auto add = [&](int a, int b){
        if(a > b)
            swap(a, b);
        s.insert({a, b});
    };

    for(int i = 0; i < N; ++i){
        if(i == 0){
            s.insert({A[0], A[0]});
            continue;
        } 
        auto it = s.rbegin();
        comfort += it->first;
        add(it->first, A[i]);
        add(it->second, A[i]);
        s.erase(s.find(*it));
    }
    cout << comfort << '\n';
}



int32_t main(){
    ios_base::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr); 
    int T = 1; 
    // cin >> T;
    for(int i = 1; i <= T; ++i){
        // brute();
        solve();
    }
    return 0;
}

/*
Sample inp
*/

Measured memory_bytes: 17200
#!usr/bin/env python3
from collections import defaultdict
from collections import deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
def LI(): return list(map(int, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
def LS():return list(map(list, sys.stdin.readline().split()))
def S(): return list(sys.stdin.readline())[:-1]
def IR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = I()
    return l
def LIR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = LI()
    return l
def SR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = S()
    return l
def LSR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = SR()
    return l
mod = 1000000007

#A

#B

#C
n = I()
d = defaultdict(int)
for i in range(n):
    a = I()
    d[a] ^= 1
d = list(d.values())
print(sum(d))
#D

#E

#F

#G

#H

#I

#J

#K

#L

#M

#N

#O

#P

#Q

#R

#S

#T


Measured memory_bytes: 53212
n,k = map(int,input().split())
print(((-(2*(n+1)**3+3*(n+1)**2+n+1)//6)+(n*(n+1)**2+n*(n+1))//2+((n+1)**2+n+1)//2-((k-1)*n+(k-1)**2*n)//2+n+(k+2*(k-1)**3+3*(k-1)**2-1)//6-(k+(k-1)**2-1)//2-k+2)%(10**9+7))


Measured memory_bytes: 61920
N=int(input())
S=input()

if N==1 or N%2!=0:
    print('No')
    exit(0)

S_pre = S[:int(N/2)]
S_aft = S[int(N/2):]

flg=0
for i in range(len(S_pre)):
    if S_pre[i] != S_aft[i]:
        flg+=1

if flg==0:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 3064
import sys
# input = sys.stdin.buffer.readline
def getN():
    return int(input())
def getNM():
    return map(int, input().split())
def getlist():
    return list(map(int, input().split()))
import heapq
import bisect
import copy
# import math
def warshall_floyd(d, N):
    for k in range(N):
        for i in range(N):
            for j in range(N):
                d[i * N +j] = min(d[i * N +j], d[i * N + k] + d[k * N + j])
    return d

MOD = 10**9 + 7

def main():
    n = getN()
    kosuu = n // 100
    if n % 100 <= kosuu * 5:
        print(1)
    else:
        print(0)

if __name__ == '__main__':
    main()



Measured memory_bytes: 38484
#!/usr/bin/env python3
import sys, math, itertools, collections, bisect, heapq
input = lambda: sys.stdin.buffer.readline().rstrip().decode('utf-8')
inf = float('inf') ;mod = 10**9+7
mans = inf ;ans = 0 ;count = 0 ;pro = 1
n,q=map(int,input().split())
STX=[tuple(map(int,input().split())) for i in range(n)]
D=[int(input()) for i in range(q)]
event=[]
for si,ti,xi in STX:
  event.append((si-xi,0,xi))
  event.append((ti-xi,-1,xi))
for di in D:
  event.append((di,1,di))
event.sort()
hq=[]; S=set()
for time, query, number in event:
  if query == 0:
    heapq.heappush(hq,number)
    S.add(number)
  elif query == -1:
    S.remove(number)
  else:
    while hq and hq[0] not in S:
      heapq.heappop(hq)
    if not hq:
      print(-1)
    else:
      print(hq[0])

Measured memory_bytes: 120112
Imports System.Collections.Generic
Imports System.Console

Module Program
    Sub Main()
        Dim s As String = NextString()
        Dim t(s.Length - 1) As Char
        For i As Integer = 0 To UBound(t)
            t(i) = s(i)
        Next

        For v As Integer = Asc("a"c) To Asc("z"c)
            If Not s.Contains(Chr(v) & "") Then
                WriteLine(s & Chr(v))
                Return
            End If
        Next

        If Not NexstPermutation(t) Then
            WriteLine(-1)
        Else
            Dim i As Integer = 0
            Do While s(i) = t(i)
                Write(s(i))
                i += 1
            Loop
            WriteLine(t(i))
        End If

    End Sub

    Function NexstPermutation(t As Char()) As Boolean
        Dim n As Integer = Len(t)
        Dim i As Integer = n - 2

        Do While i >= 0 AndAlso t(i) >= t(i + 1)
            i -= 1
        Loop
        If i < 0 Then Return False

        Dim j As Integer = i + 1
        Do While j < n AndAlso t(j) > t(i)
            j += 1
        Loop
        j -= 1
        Dim tmp As Char = t(i)
        t(i) = t(j)
        t(j) = tmp

        Dim left As Integer = i + 1
        Dim right As Integer = n - 1

        Do While left < right
            tmp = t(left)
            t(left) = t(right)
            t(right) = tmp

            left += 1
            right -= 1
        Loop

        Return True
    End Function

    Function NextString() As String
        Dim result As New List(Of Char)
        Do
            Dim tmp As Integer = Read()
            If tmp < 0 Then Exit Do
            Dim nextChar As Char = Chr(tmp)

            If Not Char.IsWhiteSpace(nextChar) Then
                result.Add(nextChar)
            ElseIf nextChar <> vbCr Then
                Exit Do
            End If
        Loop
        Return New String(result.ToArray())
    End Function
End Module


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

int main(){
    int N;
    cin>>N;
    int x=0;
    int y=0;
    int z=0;
    vector<int> a(N);
    for(int i=0;i<N;i++){
      cin>>a[i];
    }
    for(int i=0;i<N;i++){
      if(a[i]%4==0){
          x++;
          a[i]/=4;
      }
      else if(a[i]%2==0){
        y++;
      }
    }
      if((x*2+y)>=(N/2)*2){
        cout<<"Yes"<<endl;
      }
      else{
        cout<<"No"<<endl;
      }
    return 0;
}




Measured memory_bytes: 3632
#include <bits/stdc++.h>
#define PI 3.1415926535897
using namespace std;
typedef long long ll;
const int INF = 1000000000;
const ll LINF = 1000000000000000000; //1e18
const double EPS = 1e-10;

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

    deque<int> b;
    int a;
    for (int i = 1; i <= n; i++)
    {
        cin >> a;
        if (i % 2 != 0)
        {
            b.push_back(a);
        }
        else
        {
            b.push_front(a);
        }
    }

    if (n % 2 != 0)
    {
        for (int i = n - 1; i >= 0; i--)
        {
            printf("%d", b[i]);
            if (i != 0)
            {
                printf(" ");
            }
            else
            {
                printf("\n");
            }
        }
    }
    else
    {
        for (int i = 0; i < n; i++)
        {
            printf("%d", b[i]);
            if (i != n - 1)
            {
                printf(" ");
            }
            else
            {
                printf("\n");
            }
        }
    }

    return (0);
}

Measured memory_bytes: 2944
N,T = map(int,input().split())

ct = [list(map(int,input().split())) for i in range(N)]

c = []
t = []

for i in range(N):
    c.append(ct[i][0])
    t.append(ct[i][1])

minc = 10000

for i in range(len(c)):
    if t[i] <= T and c[i] < minc:
        minc = c[i]

if minc == 10000:
    print("TLE")
else:
    print(minc)

Measured memory_bytes: 3064
#include "bits/stdc++.h"

#define REP(i,num) for(int i=0;i<(num);++i)
#define LOOP(i) while(i--)
#define ALL(c) c.begin(),c.end()
#define PRINTALL(c) for(auto pitr=c.begin();pitr!=c.end();++pitr){cout<<*pitr;if(next(pitr,1)!=c.end())cout<<' ';}cout<<endl;
#define PAIRCOMP(c,comp) [](const pair<ll,ll>& lhs,const pair<ll,ll>& rhs){return lhs.c comp rhs.c;}

using namespace std;
using ll = long long;

constexpr ll atcoder_mod = 1e9+7;

template<typename T=int>
T in(){T x; cin >> x; return (x);}
template<typename T=int,typename C=vector<T>>
C vecin(int N){C x(N);REP(i,N){x[i]=in<T>();}return move(x);}

void vout(){cout << endl;}
template<typename Head,typename... Tail>
void vout(Head&& h,Tail&&... t){cout << ' ' << h;vout(forward<Tail>(t)...);}
void out(){cout << endl;}
template<typename Head,typename... Tail>
void out(Head&& h,Tail&&... t){cout << h;vout(forward<Tail>(t)...);}

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

	string S=in<string>();
	int K=in();
	int N=S.size();
	vector<string> V;
	REP(i,K){
		REP(j,N-i){
			V.emplace_back(S.substr(j,i+1));
		}
	}
	sort(ALL(V));
	V.erase(unique(ALL(V)),V.end());
	out(V[K-1]);
	return 0;
}


Measured memory_bytes: 1660
#include <iostream>
#define LL long long
using namespace std;

int main(int argc, char const *argv[])
{
	LL health;
	cin >> health;
	LL res = 0;
	int i = 0;
	while (health)
	{
		res += (1ll << (LL) i);
		health >>= 1;
		i ++;
	}
	cout << res;
	return 0;
}

Measured memory_bytes: 380
#include<bits/stdc++.h>
#include <algorithm>
#include <cctype>
#include <iostream>
#include <string>
using namespace std;
#define ll long long

int main(){
    int N, K;
    cin >> N >> K;
    double res = 0.0;
    double tmp;
    int val;
    for(int n=1; n<N+1; n++){
        val = n;
        tmp = 1.0/double(N);
        while( val < K ){
            val *= 2;
            tmp *= 1.0/2.0;
        }
        res += tmp;
    }

    cout << setprecision(20) << res << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
/*#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
/*template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
*/typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<ll,ll> pl;
typedef pair<int,int> pii;

#define int ll
#define LOCAL 0
#define dbg(x) cout << #x << " is " << x << "\n"
#define gll(x) scanf("%d",&x)
#define gll2(x,y) scanf("%d%d",&x,&y)
#define gll3(x,y,z) scanf("%d%d%d",&x,&y,&z)
#define gllarr(arr,n) f(i,n) gll(arr[i]);
#define sz(x) ((int)x.size())
#define s(x) sort(x.begin(),x.end())
#define all(v) v.begin(),v.end()
#define rs(v) { s(v) ; r(v) ; }
#define r(v) {reverse(all(v));}
#define pb push_back
#define f(i,n) for(int i=0;i<n;i++)
#define fr(i,n) for(int i=n-1;i>=0;i--)
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define repr(i,a,b) for(int i=a;i>=b;i--)

const ll mod = (ll)1e9 + 7;
const ll inf = (ll)1e16;
const ld eps = 1e-12;
const ll N = (int)1e5 + 5;
const ll LOGN = 19;
const ld PI = 3.14159265358979323846;
inline ll mul(ll a, ll b, ll m = mod) { return (ll)(a * b) % m;}
inline ll add(ll a, ll b, ll m = mod) { a += b; if(a >= m) a -= m; if(a < 0) a += m; return a;}
inline ll power(ll a, ll b, ll m = mod) { if(b == 0) return 1; if(b == 1) return (a % m); ll x = power(a, b / 2, m); x = mul(x, x, m); if(b % 2) x = mul(x, a, m); return x;}

int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    if (LOCAL) {
        freopen("C:\\Users\\Dishant\\Desktop\\Collection-DEV c++\\input.txt", "r", stdin);
        freopen("C:\\Users\\Dishant\\Desktop\\Collection-DEV c++\\output.txt", "w", stdout);
    }
    int n, m;
    cin>>n>>m;
    if(n == m) cout<<"Yes";
    else cout<<"No";
    return 0;
}


Measured memory_bytes: 256
a,b = map(int, input().split())
c = []
c.append(1)

for i in range(1,1000):
  c.append(0)
for i in range(1,1000):
  c[i] = c[i-1] + i + 1 
  
  if b - a == i + 1 :
    print(c[i-1]-a)

Measured memory_bytes: 3060
using System;class P{static void Main(string[] args){bool a=false;int b,c,d,e;int[] f,g=new int[4],h=new int[4],i=new int[]{10,50,100,500};while(true){b=int.Parse(Console.ReadLine());if(b==0){break;}if(!a){a=!a;}else{Console.WriteLine();}c=0;f=Array.ConvertAll(Console.ReadLine().Split(' '),int.Parse);for(e=3;e>=0;e--){c+=f[e]*i[e];}d=c-b;for(e=3;e>=0;e--){g[e]=d/i[e];d-=g[e]*i[e];h[e]=Math.Max(0,f[e]-g[e]);}for(e=0;e<4;e++){if(h[e]!=0){Console.WriteLine("{0} {1}",i[e],h[e]);}}}}}


Measured memory_bytes: 9448
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
#define rep(i,s,e) for(i64 (i) = (s);(i) < (e);(i)++)
#define all(x) x.begin(),x.end()
#define let auto const

int main() {
  i64 n, m;
  while(cin >> n >> m, n) {
    vector<i64> a(n);
    rep(i,0,n) cin >> a[i];
    sort(all(a));
    i64 ans = 0;
    for(auto iter = begin(a); iter != end(a); ++iter) {
      auto ui = upper_bound(all(a), m - *iter);
      if(ui == begin(a)) continue;
      --ui;
      if(ui == iter) {
        if(ui == begin(a)) continue;
        --ui;
      }

      ans = max(ans, *ui + *iter);
    }
    if(ans == 0) {
      cout << "NONE" << endl;
    }
    else {
      cout << ans << endl;
    }
  }
}



Measured memory_bytes: 3092
#include<iostream>
#include<string>
using namespace std;
int main(){
  int n;
  string str;
  cin>>n;
  cin>>str;
  
  long long r,g,b;
  r=g=b=0;
  for(int i=0;i<n;i++){
    if(str[i]=='R'){
      r++;
    }else if(str[i]=='G'){
      g++;
    }else{
      b++;
    }
  }
  
  long long cnt=0;
  for(int i=0;i<n-2;i++){
    for(int j=i+2;j<n;j+=2){
      if(str[i]!=str[j]&&str[j]!=str[(i+j)/2]&&str[(i+j)/2]!=str[i]){
	cnt++;
      }
    }
  }
  
  cout<<r*b*g-cnt<<endl;
  return(0);
}

Measured memory_bytes: 3636
#include<cstdio>
#include<iostream>
#include<string>
using namespace std;
int main ()
{
    string str;
    getline(cin,str);
    for(int i=0;i<str.length();i++){
        if(str[i]>96&&str[i]<123){
            str[i]-=32;
        }
    }
    cout<<str<<endl;
    return 0;
}

Measured memory_bytes: 1176
import java.io.IOException;
import java.io.InputStream;
import java.util.*;
public class Main{
    public static void main(String[] args)throws Exception{
        FastScanner sc = new FastScanner();

        int n = sc.nextInt();
        int w = sc.nextInt();

        int[][] item = new int[n+1][2];

        for(int i = 1;i <= n;i++){
            item[i][0] = sc.nextInt();
            item[i][1] = sc.nextInt();
        }

        long[][] dp = new long[n+1][w+1];

        for(int i = 1;i <= n;i ++){
            for(int j = 1;j <= w;j ++){

                if(item[i][0] > j){
                    dp[i][j] = dp[i-1][j];
                }else{
                    dp[i][j] = Math.max(dp[i-1][j],dp[i-1][j - item[i][0]] + item[i][1]);
                }

//                System.out.print(dp[i][j] + " ");

            }
            System.out.println();
        }

        System.out.println(dp[n][w]);
    }
}

class FastScanner {
    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;
    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        }else{
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }
    private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;}
    private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}
    public boolean hasNext() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++; return hasNextByte();}
    public String next() {
        if (!hasNext()) throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while(isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }
    public long nextLong() {
        if (!hasNext()) throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while(true){
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            }else if(b == -1 || !isPrintableChar(b)){
                return minus ? -n : n;
            }else{
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }
    public int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();
        return (int) nl;
    }
    public double nextDouble() { return Double.parseDouble(next());}
}

Measured memory_bytes: 128336
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

#include <bits/stdc++.h>
#define int long long
#define endl '\n'
#define null nullptr
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(), x.rend()
#define pb push_back
#define mp make_pair
#define test int t; cin>>t; while(t--)
#define FAST                          \
    ios_base::sync_with_stdio(false); \
    cin.tie(NULL);                    \
    cout.tie(NULL)

using namespace std;

typedef vector<int> vi;
typedef vector<pair<int,int>> vii;
typedef pair<int,int> pii;
typedef unordered_map<int,int> mp;

const int mod = 1e9+7;
const int inf = 1e17+21;


int32_t main(){
    FAST;

    string s,t; cin>> s>> t;

    sort(all(s));
    sort(rall(t));

    if(s < t){
        cout << "Yes";
    }else cout << "No"; 

    return 0;
}


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

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

  double d = ceil(a/b);
  
  cout << int(d * c) << endl;
}

Measured memory_bytes: 3716
#!/usr/bin/env python3
# Generated by https://github.com/kyuridenamida/atcoder-tools
from typing import *
import collections
import functools
import itertools
import math
import sys

INF = float('inf')
YES = "Yes"  # type: str
NO = "No"  # type: str


def solve(S: str):
    return [YES, NO][S[0] == S[1] == S[2]]


def main():

    sys.setrecursionlimit(10 ** 6)

    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    S = next(tokens)  # type: str
    print(f'{solve(S)}')


if __name__ == '__main__':
    main()


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

int main() {
  string O, E;
  cin >> O >> E;

  for (int i = 0; i < min(O.size(), E.size()); i++) {
    cout << O[i] << E[i];
  }
  if (O.size() < E.size()) {
    cout << E[E.size() - 1] << endl;
  } else if (O.size() > E.size()) {
    cout << O[O.size() - 1] << endl;
  } else {
    cout << endl;
  }
}


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

int hui(string x)
{
    int i=0,j=x.length()-1;
    for(i=0;i<j;i++,j--)
        if(x[i]!=x[j])
            return 0;
    return 1;
}

int main()
{
    string a;
    while(cin>>a)
    {
        int n=a.length()/2;
        string qian=a.substr(0,n);
        if(hui(a)&&hui(qian))
            cout<<"Yes"<<endl;
        else
            cout<<"No"<<endl;
    }
    return 0;
}

Measured memory_bytes: 256
N, D = map(int,input().split())
x = [[0]*D]*N
for i in range(N):
  x[i] = list(map(int,input().split()))

count = 0
for i in range(N-1):
  for j in range(i+1,N):
    dist = 0
    for m in range(D):
      dist += (x[i][m] - x[j][m]) **2
    if (dist ** 0.5) % 1 == 0: #squr dが整数値か判定
      count += 1
print(count)

Measured memory_bytes: 3188
#include <iostream>
#include <numeric>
#include <stdio.h>
#include <iomanip>
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
using namespace std;
using ll = long long;
#define rep(i, n) for (long long i = 0; i < (long long)(n); i++)
int Max(int(a), int(b), int(c)) {
	return max(max(a, b), c);
}
int Min(int(a), int(b), int(c)) {
	return min(min(a, b), c);
}





int main() {

	ll N,K,M;
	cin >> N>>K>>M;
	string s = "No";
	if ((N - M) * (K - M) < 0) {
		s = "Yes";
	}
	cout << s << endl;


}

Measured memory_bytes: 256
#include<stdio.h>
int main(){
    int a[1000][1000],b[1000],c[1000]={0},i,j,m,n;
    scanf("%d %d\n",&n,&m);
    for(i=1;i<=n;i+=1){
        for(j=1;j<=m;j+=1){
            scanf("%d",&a[i][j]);
        }
    }
    for(j=1;j<=m;j+=1){
        scanf("%d",&b[j]);
    }
    for(i=1;i<=n;i+=1){
        for(j=1;j<=m;j+=1){
            c[i]=c[i]+a[i][j]*b[j];
        }
    }
    for(i=1;i<=n;i+=1){
        printf("%d\n",c[i]);
    }
    return 0;
}

Measured memory_bytes: 1000
#include <stdio.h>
#include <stdlib.h>

void swap(int *,int *);

int main()
{
  int i,j,n,count=0;
  int *num;

  scanf("%d",&n);
  num=(int *)malloc(n*sizeof(int));

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

  for(i=0; i<n-1; i++)
    {
      for(j=n-1; j>i; j--)
	{
	  if(num[j-1]>num[j])
	    {
	      swap(&num[j],&num[j-1]);
	      count++;
	    }
	}
    }

  for(i=0; i<n; i++)
    {
      if(i>0)
	{
	  printf(" ");
	}
      printf("%d",num[i]);
    }
  printf("\n%d\n",count);

  return 0;
}

void swap(int *j,int *j_1)
{
  int temp;
  temp=*j;
  *j=*j_1;
  *j_1=temp;
}



Measured memory_bytes: 2144
#include <bits/stdc++.h>
using namespace std;
#define modulo 998244353
#define mod(mod_x) ((((long long)mod_x+modulo))%modulo)
#define Inf 100000000


int main(){
	
	int N,W;
	cin>>N>>W;
	
	vector<int> w(N),v(N);
	
	for(int i=0;i<N;i++){
		cin>>w[i]>>v[i];
	}
	
	int w0 = w[0];
	
	for(int i=0;i<N;i++){
		w[i]-=w0;
	}
	
	int maxi = 3000;
	
	vector<vector<vector<int>>> dp(N+1,vector<vector<int>> (N+1,vector<int>(301,-1)));
	
	dp[0][0][0]=0;
	
	for(int i=0;i<=N;i++){
		for(int j=0;j<=N;j++){
			for(int k=0;k<=300;k++){
				if(dp[i][j][k]==-1)continue;
				if(i!=N)dp[i+1][j][k]=max(dp[i][j][k],dp[i+1][j][k]);
				if(j!=N)dp[i][j+1][k]=max(dp[i][j][k],dp[i][j+1][k]);
				if(k!=300){
					dp[i][j][k+1] = max(dp[i][j][k],dp[i][j][k+1]);
				}
				int new_w = k+w[i];
				if(new_w>300||i==N||j==N)continue;
				dp[i+1][j+1][new_w] = max(dp[i][j][k] + v[i],dp[i+1][j+1][new_w]);
			}
		}
	}
	
	int ans = 0;
	
	for(int i=0;i<=N;i++){
		long long K = (long long)W - (long long)w0 * i;
		if(K<0)continue;
		if(K>300)K=300;
		ans = max(ans,dp[N][i][K]);
	}
	
	cout<<ans<<endl;
	
	
	
	
    return 0;
}



Measured memory_bytes: 12672