akhauriyash/Code-Regression huggingface dataset:
#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;
use std::io::{BufWriter, Write};
// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

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

macro_rules! read_value {
    ($next:expr, [graph1; $len:expr]) => {{
        let mut g = vec![vec![]; $len];
        let ab = read_value!($next, [(usize1, usize1)]);
        for (a, b) in ab {
            g[a].push(b);
            g[b].push(a);
        }
        g
    }};
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };
    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };
    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };
    ($next:expr, usize1) => (read_value!($next, usize) - 1);
    ($next:expr, [ $t:tt ]) => {{
        let len = read_value!($next, usize);
        read_value!($next, [$t; len])
    }};
    ($next:expr, $t:ty) => ($next().parse::<$t>().expect("Parse error"));
}

#[allow(unused)]
macro_rules! debug {
    ($($format:tt)*) => (write!(std::io::stderr(), $($format)*).unwrap());
}
#[allow(unused)]
macro_rules! debugln {
    ($($format:tt)*) => (writeln!(std::io::stderr(), $($format)*).unwrap());
}

fn solve() {
    let out = std::io::stdout();
    let mut out = BufWriter::new(out.lock());
    macro_rules! puts {
        ($($format:tt)*) => (let _ = write!(out,$($format)*););
    }
    input! { k: usize }
    let mut check = true;
    let mut a = 7;
    //k回でa_iのkの剰余が全て出るので鳩の巣原理より
    if k == 1 || k == 7 {
        puts!("1");
        return;
    }
    for i in 2..k+1 {
        a = a * 10 + 7;
        a = a % k;
        if a == 0 {
            puts!("{}", i);
            check = false;
            break;
        }
    }
    if check {
        puts!("-1");
    }
}

fn main() {
    // In order to avoid potential stack overflow, spawn a new thread.
    let stack_size = 104_857_600; // 100 MB
    let thd = std::thread::Builder::new().stack_size(stack_size);
    thd.spawn(|| solve()).unwrap().join().unwrap();
}


Measured memory_bytes: 2248
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdint.h>
#include <math.h>
#include <time.h>

typedef int32_t i32;
typedef int64_t i64;
typedef double f64;

void *const null=(void *)0;
i64 const llinf=4611686018427387903LL;
i64 const mod=1000000009LL;
f64 const pi=3.141592653589793;
f64 const rad=57.295779513082323;

#define CODE_

i64 const func(i64 n){
    i64 ret=0LL;
    ret+=n/500LL;
    ret+=n%500LL/100LL;
    ret+=n%100LL/50LL;
    ret+=n%50LL/10LL;
    ret+=n%10LL/5LL;
    ret+=n%5LL;
    return ret;
}

i32 main(void){
    i64 n;
    while(1){
        scanf("%lli",&n);
        if(n==0LL) break;
        printf("%lli\n",func(1000LL-n));
    }
    return 0;
}



Measured memory_bytes: 2048
#include<iostream>
#include<algorithm>
using namespace std;
int n,r,l,a[50];
main()
{
	while(cin>>n>>l>>r,n)
	{
		for(int i=0;i<n;i++)cin>>a[i];
		int cnt=0;
		for(int i=l;i<=r;i++)
		{
			bool flag=n%2;
			for(int j=0;j<n;j++)
			{
				if(i%a[j]<1)
				{
					flag=j%2;
					break;
				}
			}
			cnt+=!flag;
		}
		cout<<cnt<<endl;
	}
}



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

int main(){
	string S;
	cin >> S;
	
	vector<bool> exist(26,false);
	
	if(S.size()==26){
		if(S=="zyxwvutsrqponmlkjihgfedcba")cout << "-1" << endl;
		else{
			for(int i=25;i>0;i--){
				exist[S[i]-'a']=true;
				if(S[i-1]<S[i]){
					for(int j=0;;j++){
						if(exist[j] && S[i-1]<'a'+j){
							S[i-1]='a'+j;
							break;
						}
					}
					S.erase(S.begin()+i,S.end());
					break;
				}
			}
			cout << S << endl;
		}
		return 0;
	}
	
	for(int i=0;i<S.size();i++)exist[S[i]-'a']=true;
	char add;
	for(int i=0;;i++){
		if(!exist[i]){
			add='a'+i;
			break;
		}
	}
	cout << S << add << endl;
	return 0;
}

Measured memory_bytes: 256
import heapq

class PriorytyQueue(object):

    def __init__(self, arr, target='min'):
        self.arr = arr
        self.target = target
        self._heapify()
    
    def _heapify(self):
        if self.target == 'max':
            self.arr = list(map(lambda x:x*(-1), self.arr))
        heapq.heapify(self.arr)
    
    def push(self, x):
        if self.target == 'max':
            x *= -1
        heapq.heappush(self.arr, x)

    def pop(self):
        res = heapq.heappop(self.arr)
        if self.target == 'max':
            return res*(-1)
        else:
            return res
    
    def get_arr(self):
        if self.target == 'max':
            return list(map(lambda x:x*(-1), self.arr))
        else:
            return self.arr
    
    def is_empty(self):
        return len(self.arr) == 0

from collections import defaultdict

N, M = map(int, input().split())
jobs = defaultdict(list)
for i in range(N):
    a, b = map(int, input().split())
    if a > M:
        continue
    jobs[a].append(b)

if __name__ == "__main__":

    ans = 0
    pq = PriorytyQueue([], target='max')
    for d in range(1, M+1):
        if d in jobs.keys():
            moneys = jobs[d]
            for money in moneys:
                pq.push(money)
        if not(pq.is_empty()):
            ans += pq.pop()
    print(ans)

Measured memory_bytes: 27620
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define repr(i, a, b) for(int i = a; i >= b; i--)
#define int long long
#define all(a) a.begin(), a.end()
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;
typedef pair<int, int> P;
const int mod = 1000000007;
const int INF = 1e15;

struct S{
    int y, x, ya, xa;
};
int h, w;
int a[510][510];
bool contain(int y, int x){
   return (0 <= y && y < h && 0 <= x && x < w);
}

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cin >> h >> w;
    rep(i, 0, h){
        rep(j, 0, w){
            cin >> a[i][j];
        }
    }
    int now = 0;
    int y = 0, x = 0;
    vector<S> ans;
    rep(i, 0, h){
        rep(j, 0, w){
            int ny = y;
            int nx = x;
            if(i % 2 == 0){
                if(x == w - 1){
                    ny++;
                }else{
                    nx++;
                }
            }else{
                if(x == 0){
                    ny++;
                }else{
                    nx--;
                }
            }
            if(!contain(ny, nx)) continue;
            if((a[y][x] + now) % 2){
                ans.push_back({y, x, ny, nx});
                now = 1;
            }else{
                now = 0;
            }
            y = ny;
            x = nx;
        }
    }
    cout << ans.size() << endl;
    for(int ii = 0; ii < ans.size(); ii++){
        cout << ans[ii].y + 1 << ' ' << ans[ii].x + 1<< ' ' << ans[ii].ya + 1 << ' ' << ans[ii].xa + 1 << endl;
    }
}

Measured memory_bytes: 8304
#include <iostream>
#include<string>
#include<time.h>
#include<math.h>
#include<stdlib.h>
#include<map>
using namespace std;

int main() {
	int N,i,j,k,b[15],ans,bingo;
	bingo = 0;
	
	int A[5][5];
	for (i = 1; i <=3; ++i) {
		for (j = 1; j <= 3; ++j) {
			cin >> A[i][j];
		}
	}
	cin >> N;
	for (i = 1; i <= N; ++i) {
			cin >> b[i];
	}

	for (k = 1; k <= N; ++k) {
		for (i = 1; i <= 3; ++i) {
			for (j = 1; j <= 3; ++j) {
				if (b[k] == A[i][j]) {
					A[i][j] = 0;
				}
			}
		}
	
	}

	for (i = 1; i <= 3; ++i) {
		ans = 0;
		for (j = 1; j <= 3; ++j) {
			ans = ans + A[i][j];
		}
		if (ans == 0) {
			bingo = 1;
		}
	}

	for (i = 1; i <= 3; ++i) {
		ans = 0;
		for (j = 1; j <= 3; ++j) {
			ans = ans + A[j][i];
		}
		if (ans == 0) {
			bingo = 1;
		}
	}

	ans = 0;
	for (i = 1; i <= 3; ++i) {
		ans = ans + A[i][i];
	}
	if (ans == 0) {
		bingo = 1;
	}

	ans = 0;
	for (i = 1; i <= 3; ++i) {
		ans = ans + A[i][3-i+1];
	}
	if (ans == 0) {
		bingo = 1;
	}





	if (bingo == 0) {

		cout << "No" << endl;
	}
	else {

		cout << "Yes" << endl;
	}
	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void) {
	int max = -0x80000000, bottom, now, before;
	scanf("%d", &before);
	scanf("%d", &before);
	bottom = before;
	while (scanf("%d", &now) != EOF) {
		if (max < now - bottom) max = now - bottom;
		if (now < before && bottom > now) bottom = now;
		before = now;
	}
	printf("%d\n", max);
}

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

#define int long long
#pragma GCC optimize ("O3")
#define ll long long
#define vi vector <int>
#define vii vector <pair<int,int> >
#define rep(i,a,b) for (int i=a;i<b;i++)
#define repD(i,a,b) for (int i=a;i>b;i--)
#define pb push_back
#define pii pair <int,int>
#define ff first
#define ss second
#define all(a) a.begin(),a.end()
#define MOD 1000000007
#define PI 3.14159265359

/*
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/trie_policy.hpp>

using namespace __gnu_pbds;
typedef tree<pii,null_type,less <pii>,rb_tree_tag,tree_order_statistics_node_update>ind_set;
*/
///*X.find_by_order("index")
///X.order_of_key("key")


#define deb(x) cerr<<#x<< " : " <<x<<"\n";
#ifndef local
	#define deb(x) ;
#endif
///----------------------------------------------------------------------------------

int n,m,L[2005][2005],R[2005][2005],D[2005][2005],U[2005][2005];
string grid[2005];

void solve()
{
	cin>>n>>m;rep(i,0,n)cin>>grid[i];

	rep(i,0,n)
	{
		rep(j,0,m)
		{
			if (grid[i][j]=='#')continue;
			L[i][j]=1;
			if (j)L[i][j]+=L[i][j-1];
		}
		repD(j,m-1,-1)
		{
			if (grid[i][j]=='#')continue;
			R[i][j]=1;
			if (j!=m-1)R[i][j]+=R[i][j+1];
		}
	}

	rep(i,0,m)
	{
		rep(j,0,n)
		{
			if (grid[j][i]=='#')continue;
			D[j][i]=1;
			if (j)D[j][i]+=D[j-1][i];
		}
		repD(j,n-1,-1)
		{
			if (grid[j][i]=='#')continue;
			U[j][i]=1;
			if (j!=n-1)U[j][i]+=U[j+1][i];
		}
	}

	int ans=0;
	rep(i,0,n)
	{
		rep(j,0,m)
		{
			if (grid[i][j]=='#')continue;
			ans=max(ans,-3+L[i][j]+R[i][j]+D[i][j]+U[i][j]);
		}
	}
	cout<<ans<<"\n";

}
signed main()
{
    ios_base::sync_with_stdio(false);cin.tie(NULL);

    #ifdef local
    freopen("input.txt","r",stdin);
    ///freopen("output.txt","w",stdout);
    #endif

    clock_t qwertyuiop = clock();
    int t=1;
    ///cin>>t;
    rep(a,0,t)
    {
        ///    cout<<"Case #"<<a+1<<": ";
        solve();
    }
    {qwertyuiop = clock() - qwertyuiop;double time_taken = ((double)qwertyuiop)/CLOCKS_PER_SEC;cerr<<fixed<<setprecision(5)<<"\n\nTime Taken : "<<time_taken<<" seconds\n";}
}


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

using namespace std;
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define sz(x) ll(x.size())
typedef long long ll;
typedef pair<int, int> P;
//typedef pair<ll, ll> P;
//const double INF = 1e10;
const ll INF = 10e10;
const ll MINF = -10e10;
//const int INF = INT_MAX;
#define mins(x, y) x = min(x, y)
#define maxs(x, y) x = max(x, y)

const int mod = 1000000007;

ll f(ll i) {
    if (i % 2 == 0) {
        return i / 2;
    } else {
        return 3 * i + 1;
    }

}

vector<P> kadan; // <takasa , futosa>


void prt(bool b) {
//    if (b) {
//        cout << "matome ";
//    } else {
//        cout << "       ";
//    }
//    for (int i = 0; i < kadan.size(); i++) {
//        cout << kadan[i].first << ' ';
//    }
//    cout << endl;
}

void matome() {

    for (int i = 0; i < kadan.size() - 1; i++) {
        if (kadan[i].first == kadan[i + 1].first) {
            kadan[i].second++;
            kadan.erase(kadan.begin() + i + 1);
            i--;
        }
    }
    prt(true);

}


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


    rep(i, n) {
        int h;
        cin >> h;
        P p(h, 1);
        kadan.push_back(p);
    }
    ll ans = 0;
    matome();
    while (kadan.size() > 1) {

        set<int, greater<int>> q;
        for (int i = 0; i < kadan.size(); i++) {
            q.insert(kadan[i].first);
        }
        int max = *q.begin();
        int max2 = *(++q.begin());
        int diff = max - max2;
        for (int i = 0; i < kadan.size(); i++) {
            if (kadan[i].first == max) {
                kadan[i].first = max2;
                ans += diff;
                prt(false);
            }
        }
        matome();
    }
    ans += kadan[0].first;

    cout << ans << endl;

}

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

int main(){
    int N;
    cin >> N;
    int H[100];
    for(int i = 0; i < N; i++){
       cin >> H[i]; 
    }
    int count = 0;
    int max = 0;
    for(int i = 0; i < N; i++){
        if(H[i] > max){
            max = H[i];
        }
        if(max <= H[i]){
            count++;
        }
    }
    cout << count << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#pragma GCC optimize("O3")
using namespace std;
typedef long long ll;
#define rep(i, s, e) for (int i = s; i < e; i++)
#define endl '\n'
int main()
{
    int N;
    cin >> N;
    int A = 0, B = 0, C = 0;
    rep(i, 0, N)
    {
        int tmp;
        cin >> tmp;
        if (tmp % 4 == 0)
            A++;
        else if (tmp % 2 == 0)
            B++;
        else
            C++;
    }
    bool p=B>0;
    bool q=C<=A;
    bool r=C<=A+1;
    if(p){
        if(q){
            cout<<"Yes"<<endl;
        }else{
            cout<<"No"<<endl;
        }
    }else {
        if(r){
            cout<<"Yes"<<endl;
        }else{
            cout<<"No"<<endl;
        }
    }
}

Measured memory_bytes: 3636
#include<iostream>

using namespace std;

const int MAX = 110;
const int INF = (1<<25);
int T[MAX][MAX];
int n,m,s,g1,g2;

void init(){
  for(int i = 0; i < MAX; i++)
    for(int j = 0; j < MAX; j++) T[i][j] = INF;

  for(int i = 0; i < MAX; i++)
    T[i][i] = 0;
}

void input(){
  for(int i = 0; i < m; i++){
    int from, to, cost;
    cin >> from >> to >> cost;
    T[from][to] = cost;
  }
}

void solve(){

  for(int k = 1; k <= n; k++)
    for(int i = 1; i <= n; i++)
      for(int j = 1; j <= n; j++) T[i][j] = min(T[i][j],T[i][k]+T[k][j]);

  int ans = INF;
  for(int i = 1; i <= n; i++) ans = min(ans,T[s][i]+T[i][g1]+T[i][g2]);    
  cout << ans << endl;
}

int main(){


  while(cin >> n >> m >> s >> g1 >> g2 &&n+m+s+g1+g2){
    init();
    input();
    solve();
  }
  return 0;
}

Measured memory_bytes: 1208
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <fstream>
#include <vector>
#include <set>
#include <algorithm>
#include <queue>
#include <string> 
#include <map>
#include <iomanip>
#include <list>
#include <stack>
#include <bitset>
#include <cmath>
using namespace std;


typedef int INT;
#define int long long

const int oo = 1000000000;

INT main()
{
	ios::sync_with_stdio(false);
	cin.tie(NULL); cout.tie(NULL);
	
	int n;
	cin >> n;
	vector <pair <char, int> > v(2 * n);
	vector <pair <int, int> > w(n), b(n);
	for (int i = 0; i < 2 * n; i++)
	{
		cin >> v[i].first >> v[i].second;
		if (v[i].first == 'W')
			w[v[i].second - 1] = { v[i].second - 1, i };
		else
			b[v[i].second - 1] = { v[i].second - 1, i };
	}
	vector <int> ch(n), wh(n);
	for (int i = 0; i < 2*n; i++)
	{
		if (v[i].first == 'W')
			for (int j = i + 1; j < 2 * n; j++)
			{
				if (v[j].first == 'W' && v[j].second < v[i].second)
					wh[v[i].second - 1]++;
			}
		if (v[i].first == 'B')
			for (int j = i + 1; j < 2 * n; j++)
			{
				if (v[j].first == 'B' && v[j].second < v[i].second)
					ch[v[i].second - 1]++;
			}
	}
	vector <vector <int> > costb(n + 1, vector <int>(n + 1)), costw(n + 1, vector <int>(n + 1));
	
	for (int i = 1; i <= n; i++)
	{
		costb[i][0] = ch[i - 1];
		costw[i][0] = wh[i - 1];
		for (int j = 1; j <= n; j++)
		{
			costb[i][j] += costb[i][j - 1];
			if (w[j - 1].second > b[i - 1].second)
				costb[i][j]++;
			costw[i][j] += costw[i][j - 1];
			if (b[j - 1].second > w[i - 1].second)
				costw[i][j]++;
		}
	}
	
	




	vector <vector <int> > dp(n + 1, vector <int>(n + 1, oo));
	dp[0][0] = 0;
	for (int i = 0; i <= n; i++)
	{
		for (int j = 0; j <= n; j++)
		{
			if (i != 0)
				dp[i][j] = min(dp[i][j], dp[i - 1][j] + costw[i][j]);
			if (j != 0)
				dp[i][j] = min(dp[i][j], dp[i][j - 1] + costb[j][i]);
		}
	}
	cout << dp[n][n];
	return 0;
}

Measured memory_bytes: 94464
#include <bits/stdc++.h>
using namespace std;
#define BIT_SIZE 1000000
typedef int BITTYPE;
BITTYPE _prepared_bit_table[BIT_SIZE];
//[1,n],0?????±?????????!
template <typename T>class BIT{
private:
	T* bit;int n;
public:
	BIT(int _n){bit=_prepared_bit_table;fill(bit,bit+BIT_SIZE,0);n=_n;}
	BIT(T* _table,int _sz,int _n){bit=_table;fill(bit,bit+_sz,0);n=_n;}
	int sum(int i){int s=0;while(i>0){s+=bit[i];i-=i&-i;}return s;}
	int sum(int lb,int ub){return sum(ub)-sum(lb-1);}
	void add(int i,int x){while(i<=n){bit[i]+=x;i+=i&-i;}}
	//v[1]+v[2]+...+v[x]>=w??¨??????????°????x????±???????
	int lowerbound(int w){if(w<=0)return 0;int x=0;for(int k = (1<<(31-__builtin_clz(n))); k >0 ; k>>=1)if(x+k<=n&&bit[x+k]<w){w-=bit[x+k];x+=k;}return x+1;}
};
struct INIT{INIT(){ios::sync_with_stdio(false);cin.tie(0);}}init;

int main() {
    int n,q;cin>>n>>q;
    BIT<int> bit(_prepared_bit_table,BIT_SIZE,n);
    for(int i = 0; i < q; i++){
        int t,x,y;cin>>t>>x>>y;
        if(t==0)bit.add(x,y);
        else cout<<bit.sum(x,y)<<endl;
    }
    return 0;
}

Measured memory_bytes: 7076
#include<iostream>
#include<iomanip>
#include<algorithm>
#define _USE_MATH_DEFINES
#include<math.h>
#define EPS (1e-10)
#define equals(a, b) (fabs((a) - (b)) < EPS )
using namespace std;

class Point {
public:
	double x, y;

	Point(double x = 0, double y = 0) :x(x), y(y) {}
	Point operator + (Point p) {
		return Point(x + p.x, y + p.y); 
	}
	Point operator - (Point p) {
		return Point(x - p.x, y - p.y);
	}
	Point operator * (double a) {
		return Point(a * x, a * y);
	}
	Point operator / (double a) {
		return Point(x / a, y / a);
	}

	double abs() {
		return sqrt(norm());
	}
	double norm() {
		return x * x + y * y;
	}

	bool operator < (const Point &p)const {
		return x != p.x ? x < p.x : y < p.y;
	}

	bool operator == (const Point &p)const {
		return fabs(x - p.x) < EPS && fabs(y - p.y) < EPS;
	}
};

typedef Point Vector;

double dot(Vector a, Vector b) {
	return a.x * b.x + a.y * b.y;
}

double cross(Vector a, Vector b) {
	return a.x * b.y - a.y * b.x;
}

double getDistanceSP(Point p, Point p1, Point p2) {
	if (dot(p - p1, p2 - p1) < 0.0)return (p - p1).abs();
	else if (dot(p - p2, p1 - p2) < 0.0)return (p - p2).abs();
	else return  fabs(cross(p2 - p1, p - p1)) / (p2 - p1).abs();
}


double angle(Vector a, Vector b) {
	if (cross(a, b) >= 0.0)return acos(dot(a, b) / a.abs() / b.abs());
	else return (-1) * acos(dot(a, b) / a.abs() / b.abs());
}

bool doIntersect(Point p1, Point p2, Point p3, Point p4) {
	if ((equals(fabs(angle(p2 - p1, p4 - p1)), 0) || equals(fabs(angle(p2 - p1, p4 - p1)), M_PI)) && (equals(fabs(angle(p2 - p1, p3 - p1)), 0) || equals(fabs(angle(p2 - p1, p3 - p1)), M_PI)))return false;
	else if (angle(p3 - p1, p4 - p1) >= angle(p3 - p1, p2 - p1) && angle(p3 - p1, p2 - p1) >= 0.0 && angle(p2 - p3, p1 - p3) >= angle(p2 - p3, p4 - p3) && angle(p2 - p3, p4 - p3) >= 0.0)return true;
	else if (angle(p3 - p2, p4 - p2) >= angle(p3 - p2, p1 - p2) && angle(p3 - p2, p1 - p2) >= 0.0 && angle(p1 - p3, p2 - p3) >= angle(p1 - p3, p4 - p3) && angle(p1 - p3, p4 - p3) >= 0.0)return true;
	else return false;
}

double getDistanceSS(Point p1, Point p2, Point p3, Point p4) {
	if (doIntersect(p1, p2, p3, p4))return 0;
	else return min({ getDistanceSP(p4, p1, p2), getDistanceSP(p3, p1, p2), getDistanceSP(p1, p3, p4), getDistanceSP(p2, p3, p4) });
}

int main() {
    int i, q;
	double x1, x2, x3, x4, y1, y2, y3, y4;
	Point ans;
	cin >> q;
	for (i = 0; i < q; i++) {
		cin >> x1 >> y1 >> x2 >> y2 >> x3 >> y3 >> x4 >> y4;
		Point p1(x1, y1), p2(x2, y2), p3(x3, y3), p4(x4, y4);
		cout << setprecision(15) << getDistanceSS(p1, p2, p3, p4) << endl;
	}
	return 0;
}

Measured memory_bytes: 3628
//code_sm
#include<bits/stdc++.h>
using namespace std;
#define vi vector<int>
#define si set<int>
#define ll long long
#define pb push_back
int main()
{
	int n;
	cin>>n;
	ll sum=0;
for(int i=1;i<=n;i++)
{
	if(i%3!=0&&i%5!=0)
	sum+=(ll)i;
}
cout<<sum;
}


Measured memory_bytes: 3596
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define FOR(i, N) for (long i = 0; i < (N); i++)

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int H, W, K;
    cin >> H >> W >> K;
    vector<string> masu(H);
    string str;
    FOR(h, H) {
        cin >> masu[h];
    }

    int ans = 0;
    FOR(i, (1 << H)) {
        FOR(j, (1 << W)) {
            int count = 0;
            FOR(h, H) {
                FOR(w, W) {
                    if (i >> h & 1)
                        continue;
                    if (j >> w & 1)
                        continue;
                    if (masu[h][w] == '#')
                        count += 1;
                }
            }
            if (count == K) {
                ans += 1;
            }
        }
    }

    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3648
n,y = map(int,input().split())
for i in range(n+1):
    for j in range(n-i+1):
        k = n - i - j
        m = 10000*i + 5000*j + 1000*k
        if m==y:
            print(i,j,k)
            break
    else:
        continue
    break
else:
    print(-1,-1,-1)


Measured memory_bytes: 2940
[n, m, x] = [int(s) for s in input().split()]
caas = [[int(s) for s in input().split()] for _ in range(n)]

l = []

def f(cs, i, a):
    for j in range(n - i - 1):
        cs2 = cs + caas[i + j + 1][0]
        a2 = [y + a[k] for k, y in enumerate(caas[i + j + 1][1:])]
        if min(a2) >= x:
            l.append(cs2)
        else:
            f(cs2, i + j + 1, a2)

f(0, -1, [0 for _ in range(m)])

if len(l) == 0:
    print(-1)
else:
    print(min(l))

Measured memory_bytes: 85376
# -*- coding: utf-8 -*-

H,W = map(int, input().split())
HW = []
for i in range(H):
    instr = input()
    # 残す行を選別
    if instr.find('#') != -1:
        HW.append(list(instr))
    # 残さない時は行数を-1
    else:
        H -= 1

# 残す列の情報を保持する
col = [False] * W
for i in range(H):
    for j in range(W):
        if HW[i][j] == '#':
            # 1回でも#があればその列はTrueになる
            col[j] = True

for i in range(H):
    for j in range(W):
        if col[j]:
            # 1文字ずつ出力
            print(HW[i][j], end='')
    # 行末の改行用
    print()

Measured memory_bytes: 4596
#include <iostream>
#include <string>


int main(void){
  std::string hoge;
  long long int total = 0;
  std::cin >> hoge;
  for(int i=0; i<(1<<(hoge.size()-1)); i++){
    int last = 0;
    for(int j=1; j<=hoge.size(); j++){
      if(i>>(j-1) & 1){
	total += std::stol(hoge.substr(last, j-last));
	last = j;
      }
    }
    total += std::stol(hoge.substr(last, hoge.size()-last));
  }

  std::cout << total << std::endl;
  return 0;
}

Measured memory_bytes: 256
n, x = map(int, input().split())
a = sorted(list(map(int, input().split())))
ans = 0

for i in a:
	x -= i
	if x < 0:
		print(ans)
		exit()
	ans += 1

if ans == 0:
	print(ans)
elif x == 0:
	print(ans)
else:
	print(ans-1)


Measured memory_bytes: 3060
import sys
readline = sys.stdin.readline
sys.setrecursionlimit(10**8)

D = int(readline())
C = list(map(int,readline().split()))
S = [list(map(int,readline().split())) for i in range(D)]
t = [0]*D
for j,s in enumerate(S):
    ansidx = 0
    anssum = 0
    for i,si in enumerate(s,start=1):
        if anssum < si:
            ansidx = i
            anssum = si
    t[j] = ansidx
def score():
    ans = 0
    minus = 0
    last = [0]*26
    for i in range(D):
        ans += S[i][t[i]-1]
        minus = 0
        last[t[i]-1] = i+1
        for j in range(26):
            minus += C[j]*(i-last[j]+1)
        ans -= minus
    return ans
a = score()
import random
for k in range(800):
    d,q = random.randint(1,D),random.randint(1,26)
    told = t[::]
    t[d-1] = q
    b = score()
    if a > b:
        t = told
    else:
        a = b
for ti in t:
    print(ti)


Measured memory_bytes: 84324
while 1:
    try:
        A = input().split()
        B = input().split()
        hit = len([i for i in range(len(A)) if B[i] == A[i]])
        blow = len([i for i in range(len(A)) if B[i] in A]) - hit
        print(str(hit) + " " + str(blow))
    except:
        break


Measured memory_bytes: 5564
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <climits>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <numeric>
#include <sstream>
#include <string>
using namespace std;
#define out(X) cerr << #X << ": " << (X) << endl
#define SZ(X) ((int)(X.size()))
#define REP(I,N) for (int I = 0; I < (N); ++I)
#define FOR(I,L,H) for (int I = (L); I < (H); ++I)
#define MP(X,Y) make_pair((X),(Y))
#define PB push_back
#define ALL(X) X.begin(), X.end()
template <typename T> inline bool checkmin(T &a, const T &b) { return a > b ? a = b, 1 : 0; }
template <typename T> inline bool checkmax(T &a, const T &b) { return a < b ? a = b, 1 : 0; }
typedef long long lint;

double ff[100000 + 100];
double g[10000 + 1000];

int main() {
    memset(ff , 0 , sizeof(ff));
    g[0] = 1.0;
    for(int i = 1 ; i < 10000 + 1000 ; i++)
        g[i] = g[i-1]*0.5;
    ff[1] = 1.0;
    for(int i = 2 ; i <= 100000 ; i++){
        int j = i-2,k = 0;
        for( ; j >= 1 && k < 100 ; j-- , k++){
            ff[i] += g[k*(k+1)/2]*(1.0-g[k+1])*ff[j] + g[(k+1)*(k+2)/2];
        }
        ff[i] += g[(k+1)*(k+2)/2] + 1.0;
    }
    int n;
    while(scanf("%d",&n) , n){
        printf("%.8f\n",ff[n]);
    }
    return 0;
}

Measured memory_bytes: 1624
fn main() {
    let (a, b, n) = input();
    println!("{}", solve(a, b, n));
}

fn input() -> (usize, usize, usize) {
    let mut buf = String::new();
    std::io::stdin().read_line(&mut buf).unwrap();
    buf.pop();
    let mut iter = buf.split_whitespace();
    let a: usize = iter.next().unwrap().parse().unwrap();
    let b: usize = iter.next().unwrap().parse().unwrap();
    let n: usize = iter.next().unwrap().parse().unwrap();
    (a, b, n)
}

fn solve(a: usize, b: usize, n: usize) -> usize {
    if b-1 < n {
        return (a*(b-1))/b - a*((b-1)/b);
    }
    (a*n)/b - a*(n/b)
}

Measured memory_bytes: 2116
#include <iostream>
#include <bits/stdc++.h>
#include <vector>
#include <algorithm>
#include <cctype>
#include <string>

using namespace std;

int main(){

  int N, A;
  cin >> N;
  int ans = 0;
  vector<int> vec(N);

  for (int i = 0; i < N; i++){
    cin >> A;
    vec.at(i) = A;
  }

  bool flag = true;
  while (1){
    for (int i = 0; i < vec.size(); i++) {
      if(vec.at(i) % 2 == 0){
        vec.at(i) = vec.at(i) / 2;
      }else{
        flag = false;
      }
    }
    if(flag == false) break;
    ans++;
  }

  cout << ans << endl;

  return 0;
}

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

#define int long long 
#define ll long long 
#define pb push_back
#define mp make_pair
#define pii pair<ll,ll>
#define ff first
#define ss second
#define vi vector<ll>
#define mod 1000000007
#define MOD 1000000007
#define full(a) a.begin(),a.end()
#define inf INT_MAX
#define minf INT_MIN
#define dd double
#define fori(x,n) for(ll i=x;i<n;i++)


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
    
    ll t;
    cin>>t;
    ll a=0,b=0,c=0,d=0;
    while(t--){
       string s;
       cin>>s;
       
       if(s=="AC")a++;
       if(s=="WA")b++;
       if(s=="TLE")c++;
    if(s=="RE")d++;


    }

    cout<<"AC x "<<a<<"\n";
    cout<<"WA x "<<b<<"\n";
    cout<<"TLE x "<<c<<"\n";
    cout<<"RE x "<<d<<"\n";



    return 0;  
}
    

Measured memory_bytes: 3544
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define REPR(i, n) for(int i = (int)(n); i > 0; i--)
#define FOR(i, m, n) for(int i = (int)(m); i < (int)(n); i++)
#define INF 2e9
#define ALL(v) (v).begin(), (v).end()
template <typename Iter> std::string join(Iter begin, Iter end, std::string const& separator){ std::ostringstream result; if (begin != end){ result << *begin++; }; while (begin != end){ result << separator << *begin++; }; return result.str(); }
using namespace std;
typedef long long ll;
void solve() {
  string S, T;
  cin >> S;
  cin >> T;
  ll ans = 0;
  REP(i, 3) {
    if(S[i] == T[i]) ans += 1;
  }
  cout << ans << endl;
}
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  solve();
  return 0;
}


Measured memory_bytes: 256
#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 N;
ll x, A[100005];
ll ans;

int main(void) {
    
    scanf("%d %lld", &N, &x);
    rep(i, 0, N) scanf("%lld", &A[i]);
    
    rep(i, 1, N) {
      ll t = A[i-1]+A[i];
      if (t > x) {
        ll t2 = t - x;
        if (t2 > A[i]) A[i-1] -= t2 - A[i];
        A[i] -= min(t2, A[i]);
        ans += t2;
      }
    }
    
    
    printf("%lld\n", ans);
    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, n) for (int i = (int)(n); i >= 0; i--)
#define REP(i, m, n) for (int i = (int)(m); i < (int)(n); i++)
#define INF 1e9
#define all(v) v.begin(), v.end()
typedef long long ll;

ll f1(string s){
  ll n = s.size();
  if(n <= 0) return 0;
  return (s[0]-'0') + (n-1)*9;
}

ll f2(string s){
  ll n = s.size();
  if(n <= 1) return 0;
  ll p1 = ((n-1)*(n-2)*9*9)/2;
  ll p2 = (s[0]-'1') * (n-1) * 9;
  string t = s;
  do{
    t.erase(t.begin());
  }while(t[0] == '0');
  ll p3 = f1(t);
  
  return p1+p2+p3;
}

ll f3(string s){
  ll n = s.size();
  if(n <= 2) return 0;
  ll p1 = ((n-1)*(n-2)*(n-3)*9*9*9)/6;
  ll p2 = (s[0]-'1') * ((n-1)*(n-2)*9*9)/2;
  string t = s;
  do{
    t.erase(t.begin());
  }while(t[0] == '0');
  ll p3 = f2(t);

  return p1+p2+p3;
}

int main(){
  string st;
  int k;
  cin >> st >> k;
  
  ll ans;
  if(k==1) ans = f1(st);
  if(k==2) ans = f2(st);
  if(k==3) ans = f3(st);

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string.h>
#include <bits/stdc++.h>
#include<algorithm> 
using namespace std;
// main() is where program execution begins.



int main() {
long long X, K, D, rmv, rm, mn, ans;
cin >> X >> K >> D;
X = abs(X);

mn = X%D;
rm = X/D;

if(rm >= K){
  ans = X - K*D; 
}else{

  if((K - rm)%2 == 0){
    ans = mn;
  } else{
    ans = abs(mn - D);
  }
}

cout << ans << endl;

}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define rep(i, n) FOR(i, 0, n)
#define whole(x) (x).begin(),(x).end()
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
using ll = long long;
using P = pair<int, int>;
const int mod = 1000000007;


int main(){
    ll n;
    cin >> n;
    ll ans = 0;
    ll x = 5;
    if (n%2) {
        cout << "0" << endl;
        return 0;
    }
    while(n>x) {
        ans += (n/x)/2;
        x *= 5;
    }
    
    
    
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <limits.h>
#include <queue>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
#define REP(i, n) for(int i=0; i<n; i++)

//ll P[100100];
vector<pair<ll, int> > V[100100];
ll P[100100];
ll ans[100100];
int main(){
    int N,M;
    cin >> N >> M;
    REP(i,M){
        ll p,y;
        cin >> p >> y;
        p--;
        V[p].push_back(make_pair(y,i));
        P[i] = p;
    }

    REP(i,N){
        sort(V[i].begin(), V[i].end());
    }

    REP(i,N){
        for(int k = 0; k < V[i].size(); k++){
            pair<ll, int> x = V[i][k];
            ans[x.second] = k+1;
        }
    }

    REP(i,M){
        char str[100];
        sprintf(str, "%06lld%06lld", P[i]+1, ans[i]);
        printf("%s\n", str);
    }
    return 0;
}


Measured memory_bytes: 8576
#include <bits/stdc++.h>
using namespace std;
typedef long double ld;
typedef long long ll;
typedef pair<double, double> pdd;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<int, int> pii;
typedef vector<pii> vii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
//const int mod = ;

vvi rot(vvi a) {
  int n = a.size(), m = a[0].size();
  vvi b(m, vi(n));
  for (int i = 0; i < n; ++i) for (int j = 0; j < m; ++j) {
    b[j][n-1-i] = a[i][j];
  }
  return b;
}

ll f(const vvi& a) {
  int n = a.size(), m = a[0].size();
  int res = 0;
  for (int i = 0; i < n; ++i) {
    for (int l = 0; l < m; ++l) if (a[i][l]) {
      for (int r = l + 2; r < m; r += 2) if (a[i][r]) {
        int x = (l + r) / 2;
        int d = (r - l) / 2;
        if (i >= d && a[i-d][x]) ++res;
        if (i + d < n && a[i+d][x]) ++res;
      }
    }
  }
  cerr << "f: " << res << endl;
  return res;
}

ll g(const vvi& a) {
  int n = a.size(), m = a[0].size();
  ll res = 0;
  vvi s(n + 1, vi(m + 1));
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < m; ++j) {
      s[i + 1][j + 1] = s[i][j] + a[i][j];
    }
  }
  for (int i = 0; i < n; ++i) {
    for (int l = 0; l < m; ++l) if (a[i][l]) {
      for (int d = 1; d < min(n - i, m - l); ++d) if (a[i + d][l + d]) {
        int i1 = i - d, j1 = l + d;
        int i2 = i, j2 = l + 2 * d;
//        cerr << i << ' ' << l << ' ' << d << ' ' << i1 << ' ' << j1 << ' ' << i2 << ' ' << j2 << endl;
        if (i1 < 0) {
          j1 -= i1;
          i1 = 0;
        }
        if (j2 >= m) {
          i2 -= j2 - m + 1;
          j2 = m - 1;
        }
        if (i1 <= i2) {
          res += s[i2+1][j2+1] - s[i1][j1];
//          cerr << i << ' ' << l << ' ' << d << ' ' << i1 << ' ' << j1 << ' ' << i2 << ' ' << j2 << endl;
        }
        i1 = i + d, j1 = l - d;
        i2 = i + 2 * d, j2 = l;
        if (j1 < 0) {
          i1 -= j1;
          j1 = 0;
        }
        if (i2 >= n) {
          j2 -= i2 - n + 1;
          i2 = n - 1;
        }
        if (i1 <= i2) {
          res += s[i2+1][j2+1] - s[i1][j1];
        }
      }
    }
  }
  cerr << "g: " << res << endl;
  return res;
}

int main() {
  std::ios::sync_with_stdio(false); std::cin.tie(0);
  int n, m;
  cin >> n >> m;
  vs s(n);
  vvi a(n, vi(m));
  for (int i = 0; i < n; ++i) {
    cin >> s[i];
    for (int j = 0; j < m; ++j) {
      a[i][j] = s[i][j] == '#';
    }
  }
  ll res = g(a) - f(a);
  auto b = rot(a);
  res += g(b) - f(b);
  cout << res << endl;
  return 0;
}

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

typedef long long ll;

int n;
ll k;
int a[200005];
ll pos[200005];
ll neg[200005];
ll pc,nc,zc;

void find_in_neg(){
    reverse(pos+1,pos+1+pc);
    ll lb=-1e18,rb=-1,m,res;
    while(lb<=rb){
        m=(lb+rb)>>1;
        ll cnt=0;
        for(int l=1,r=1;l<=nc;l++){
            while(r<=pc&&neg[l]*pos[r]<=m)r++;
            cnt+=r-1;
        }
        if(cnt>=k){
            rb=m-1;
            res=m;
        }else{
            lb=m+1;
        }
    }
    cout<<res<<endl;
}

void find_in_pos(){
    k-=zc*(zc-1)/2+zc*(nc+pc)+pc*nc;
    ll lb=1,rb=1e18,m,res;
    while(lb<=rb){
        m=(lb+rb)>>1;
        ll cnt=0;
        for(int l=nc,r=1;l>0;l--){
            while(r<l&&neg[l]*neg[r]<=m)r++;
            cnt+=min(l,r)-1;
        }
        for(int l=pc,r=1;l>0;l--){
            while(r<l&&pos[l]*pos[r]<=m)r++;
            cnt+=min(l,r)-1;
        }
        if(cnt>=k){
            rb=m-1;
            res=m;
        }else{
            lb=m+1;
        }
    }
    cout<<res<<endl;
}

int main(){

    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    cin>>n>>k;
    for(int i=1;i<=n;i++){
        cin>>a[i];
        if(a[i]<0)neg[++nc]=a[i];
        else if(a[i]==0)zc++;
        else pos[++pc]=a[i];
    }
    sort(neg+1,neg+1+nc);
    reverse(neg+1,neg+1+nc);
    sort(pos+1,pos+1+pc);
    if(pc*nc>=k){
        find_in_neg();
    }else if(zc*(zc-1)/2+zc*(nc+pc)+pc*nc>=k){
        cout<<0<<endl;
    }else find_in_pos();

    return 0;
}

Measured memory_bytes: 2432
import scala.io.StdIn.{readInt,readLine}

object Main {
  def euclid(m:Int,n:Int):Int = if(n==0) m else euclid(n,m%n)

  def main(args:Array[String]) = {
    val n = readInt
    val nums = readLine.split(" ").map(_.toInt)
    var gcm = nums(0)
    for(i <- 1 until n) {
      gcm = euclid(gcm,nums(i))
    }
    for(i<-1 to gcm if gcm%i==0)
      println(i)
  }
}

Measured memory_bytes: 45320
#include<stdio.h>
#include<math.h>
#define N 6

typedef struct{
  double x;
  double y;
}XY;

void koch(int,XY,XY);

int main()
{
  int n,i;

  XY p1 = {0.0,0.0},p2 = {100.0,0.0};
  scanf("%d",&n);
  printf("%.8f %.8f\n",p1.x,p1.y);
  koch(n,p1,p2);
  printf("%.8f %.8f\n",p2.x,p2.y);

  return 0;
}

void koch(int n,XY p1,XY p2)
{
  XY s,t,u;

  if(n == 0) return;

  s.x = (2 * p1.x + 1 * p2.x) / 3;
  s.y = (2 * p1.y + 1 * p2.y) / 3;
  t.x = (1 * p1.x + 2 * p2.x) / 3;
  t.y = (1 * p1.y + 2 * p2.y) / 3;
  u.x = (t.x - s.x) * 1 / 2 - (t.y - s.y) * sqrt(3) / 2 + s.x;
  u.y = (t.x - s.x) * sqrt(3) / 2 + (t.y - s.y) * 1 / 2 + s.y;

  koch(n-1,p1,s);
  printf("%.8f %.8f\n",s.x,s.y);

  koch(n-1,s,u);
  printf("%.8f %.8f\n",u.x,u.y);

  koch(n-1,u,t);
  printf("%.8f %.8f\n",t.x,t.y);

  koch(n-1,t,p2);
}

Measured memory_bytes: 640
#include<stdio.h>
#define MAX 100001
main(){
  int H, i;
  int A[MAX];
  scanf("%d",&H);
  for(i=1;i<=H;i++){
    scanf("%d",&A[i]);
  }
  
  for(i=1;i<=H;i++){
    printf("node %d: key = %d, ",i,A[i]);
    if(i/2 >= 1)printf("parent key = %d, ",A[i/2]);
    if(i*2 <= H)printf("left key = %d, ",A[i*2]);
    if(i*2+1 <= H)printf("right key = %d, ",A[i*2+1]);
    printf("\n");
  }
  
  return 0;
}


Measured memory_bytes: 2108
#include <stdio.h>

int main(void){
  int a,b,c;
  int x;
  int count = 0;
  scanf("%d %d %d %d",&a,&b,&c,&x);
  
  for(int i = 0;i <= a;i++){
    for(int j = 0;j <= b;j++){
      for(int k = 0;k <= c;k++){
        if(x == 500 * i + 100 * j + 50 * k){
          count++;
        }
      }
    }
  }
  printf("%d\n",count);
  return 0;
}


Measured memory_bytes: 128
import sys
from functools import lru_cache, cmp_to_key
from heapq import merge, heapify, heappop, heappush, nlargest, nsmallest
from math import ceil, floor, gcd, fabs, factorial, fmod, sqrt, inf, log
from collections import defaultdict as dd, deque, Counter as C
from itertools import combinations as comb, permutations as perm
from bisect import bisect_left as bl, bisect_right as br, bisect
from time import perf_counter
from fractions import Fraction
# sys.setrecursionlimit(pow(10, 6))
# sys.stdin = open("input.txt", "r")
# sys.stdout = open("output.txt", "w")
mod = pow(10, 9) + 7
mod2 = 998244353
def data(): return sys.stdin.readline().strip()
def out(*var, end="\n"): sys.stdout.write(" ".join(map(str, var))+end)
def l(): return list(sp())
def sl(): return list(ssp())
def sp(): return map(int, data().split())
def ssp(): return map(str, data().split())
def l1d(n, val=0): return [val for i in range(n)]
def l2d(n, m, val=0): return [l1d(n, val) for j in range(m)]


dp = dd(int)
for i in range(501):
    dp[i] = pow(i, 5)
    dp[-i] = pow(-i, 5)
n = int(data())
for i in dp.keys():
    for j in dp.keys():
        if dp[i] - dp[j] == n:
            out(i, j)
            exit()


Measured memory_bytes: 73112
#include <stdio.h>
int a[7], b[7];
int dp[1000];
void solve(int N) {
	int i, j, k;
	for(i = 0; i < 1000; ++ i) dp[i] = 0;
	dp[0] = 1;
	for(i = 0; i < N; ++ i) {
		for(j = 999; j > -1 ; -- j) {
			for(k = 1; k <= b[i]; ++ k) {
				if(j - a[i] * k > -1) {
					dp[j] += dp[j - a[i] * k];
				}
			}
		}
	}
}
int main() {
	int N, M, I, g;
	while(1) {
		scanf("%d", &N);
		if(N == 0) break;
		for(I = 0; I < N; ++ I) scanf("%d %d", &a[I], &b[I]);
		solve(N);
		scanf("%d", &M);
		for(I = 0; I < M; ++ I) {
			scanf("%d", &g);
			printf("%d\n", dp[g]);
		}
	}
	return 0;
}

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

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

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

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

ll mod = 1000000007;

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

  while (N > 0) {
    if (N % 10 == 7) {
      cout << "Yes" << endl;
      return 0;
    } else
      N /= 10;
  }
  cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 3640
#include<iostream>
#include<vector>
#include<string>
#include<set>
#include<algorithm>
#include<cstring>
#include<cmath>
#include<functional>
#include<numeric>
#include<random>
 
using namespace std;

int partition(vector<int>::iterator b, vector<int>::iterator e) {
	int i{ 1 };
	int j{ e - b - 1 };
	int x = *b;
	while (true) {
		while (b[i] <= x && i<j) i++;
		while (b[j] > x) j--;
		if (j <= i) break;
		swap(b[i], b[j]);
	}
	swap(b[0], b[j]);
	return j;
}


int select(vector<int>::iterator b, vector<int>::iterator e,int i) {
	sort(b, e);
	return b[i];
/*
    int mine = *min_element(b, e);
	int maxe = *max_element(b, e);
	if (i == 0||mine== maxe) return mine;
	if (i == e - b - 1) return maxe;
	int j = partition(b, e);
	if (i == j) return b[j];
	if (i < j) return select(b, b + j, i);
	else return select(b + j + 1, e, i - j - 1);
	*/
}




int main() { 
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;
	cin >> n;
	vector<int> a(n);
	int k;
	for (int i = 1; i <= n; i++) {
		cin >> k;
		a[i - 1] = k - i;
	}
	mt19937 get_rand_mt;
    shuffle( a.begin(), a.end(), get_rand_mt );
	int med = select(a.begin(), a.end(), n / 2);
	long long ans{ 0 };
	for (auto e : a) {
		ans += abs(e - med);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1024
#include <algorithm>
#include <iostream>
#include <vector>
#include <string>
#include <bitset>
#include <tuple>
#include <cmath>
#include <map>

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

using namespace std;

using ll = long long;
using ull = unsigned long long;

using Pll  = pair<ll, ll>;
using Pull = pair<ull, ull>;

#define eb emplace_back
#define pb push_back
#define mp( a, b ) make_pair( a, b )
#define mt( ... ) make_tuple( __VA_ARGS__ )

#define rep( i, n ) for ( int i = 0; i < (int)( n ); ++i )
#define reps( i, n ) for ( int i = 1; i <= (int)( n ); ++i )
#define rrep( i, n ) for ( int i = (int)( ( n ) - 1 ); i >= 0; --i )
#define rreps( i, n ) for ( int i = (int)( ( n ) ); i > 0; --i )

#define ALL( c ) ( c ).begin(), ( c ).end()
#define RALL( c ) ( c ).rbegin(), ( c ).rend()

#define MOD ( 1e9 + 7 )

#define INF  ( 1e12 )
#define MINF ( -1e12 )

int main()
{
	int A, B, Q;
	cin >> A >> B >> Q;

	vector<ll> vS( A + 2 );
	rep( i, A )
	{
		cin >> vS[i];
	}

	vector<ll> vT( B + 2 );
	rep( i, B )
	{
		cin >> vT[i];
	}

	vector<ll> vX( Q );
	rep( i, Q )
	{
		cin >> vX[i];
	}

	// vS, vT に正負の無限遠の点を入れておく
	vS[A] = MINF; vS[A + 1] = INF;
	vT[B] = MINF; vT[B + 1] = INF;

	sort( ALL( vS ) ); sort( ALL( vT ) );

	for ( auto &&it : vX )
	{
		// 問itに対して、一番近い左右の寺2社2を求める
		auto AB = upper_bound( ALL( vS ), it );
		ll sB = *AB;
		ll sA = *prev( AB );

		auto CD = upper_bound( ALL( vT ), it );
		ll tD = *CD;
		ll tC = *prev( CD );

		/* 上記4箇所の訪れ方の最小値を求める */
		// 1. A -> C
		ll ac = abs( sA - it ) + abs( tC - sA );

		// 2. A -> D
		ll ad = abs( sA - it ) + abs( tD - sA );

		// 3. C -> A
		ll ca = abs( tC - it ) + abs( sA - tC );

		// 4. D -> A
		ll da = abs( tD - it ) + abs( sA - tD );

		// 5. B -> C
		ll bc = abs( sB - it ) + abs( tC - sB );

		// 6. B -> D
		ll bd = abs( sB - it ) + abs( tD - sB );

		// 7. C -> B
		ll cb = abs( tC - it ) + abs( sB - tC );

		// 8. D -> B
		ll db = abs( tD - it ) + abs( sB - tD );

		cout << min( { ac, ad, ca, da, bc, bd, cb, db } ) << endl;
	}

	return ( 0 );
}


Measured memory_bytes: 3712
#include <iostream>
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n,m;
    cin>>n>>m;
    if(n<m)
    {
        for(int i=0;i<m;i++)
        {
            cout<<n;
        }
    }
    else 
    {
        for(int i=0;i<n;i++)
        {
            cout<<m;
        }
    }
    
	// your code goes here
	return 0;
}


Measured memory_bytes: 3504