akhauriyash/Code-Regression huggingface dataset:
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author tatsumack
 */

#include <iostream>
#include <fstream>

#include <iostream>
#include <limits.h>
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>

#include <list>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <queue>
#include <unordered_map>
#include <unordered_set>

#define int long long
#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define REPS(i, n) for (int i = 1, i##_len = (n); i <= i##_len; ++i)
#define FOR(i, a, b) for (int i = (a), i##_len = (b); i <= i##_len; ++i)
#define REV(i, a, b) for (int i = (a); i >= (b); --i)
#define CLR(a, b) memset((a), (b), sizeof(a))
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define INF 1001001001001001001ll
#define fcout cout << fixed << setprecision(12)

using namespace std;

typedef pair<int, int> P;

class FLaminate {
public:
    static constexpr int kStressIterations = 0;

    static void generateTest(std::ostream& test) {
    }

    void solve(std::istream& cin, std::ostream& cout) {
        int N, K;
        cin >> N >> K;
        vector<int> H(N + 1);
        REP(i, N) cin >> H[i + 1];

        vector<vector<int>> dp(N + 1, vector<int>(N + 1, INF));
        dp[0][0] = 0;
        FOR(i, 1, N) {
            FOR(j, 1, N) {
                int tmp = INF;
                REP(k, i) {
                    tmp = min(tmp, dp[k][j - 1] + max(0LL, H[i] - H[k]));
                }
                dp[i][j] = tmp;
            }
        }

        int res = INF;
        REP(i, N + 1) {
            res = min(res, dp[i][N - K]);
        }
        cout << res << endl;
    }
};


signed main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    std::istream& in(std::cin);
    std::ostream& out(std::cout);

    FLaminate solver;
    solver.solve(in, out);
    return 0;
}


Measured memory_bytes: 1024
import sys
input = sys.stdin.readline

# 組み合わせ　n_C_r
def comb(n,r):
    r = min(r,n-r)
    result = 1
    for i in range(n-r+1,n+1):
        result *= i
    for i in range(1,r+1):
        result //= i
    return result

class Unionfind:

    __slots__ = ['nodes','size']

    def __init__(self, n):
        self.nodes = list(range(n))
        self.size = [1]*n

    def root(self, x):
        if self.nodes[x] == x:
            return x
        else:
            root_x = self.root(self.nodes[x])
            self.nodes[x] = root_x
            return root_x

    def unite(self, x, y):
        x = self.root(x); y = self.root(y)
        if x == y:
            return
        if self.size[x] < self.size[y]:
            x, y = y, x
        self.size[x] += self.size[y]
        self.nodes[y] = x

    def same(self, x, y):
        return self.root(x) == self.root(y)

N,M = map(int,input().split())
info = [[int(e)-1 for e in input().split()] for _ in range(M)]

uf = Unionfind(N)
out = []
ans = comb(N,2)
out.append(ans)
for A,B in info[::-1]:
    if not uf.same(A,B):
        ans -= uf.size[uf.root(A)] * uf.size[uf.root(B)]
    uf.unite(A,B)
    out.append(ans)

for q in out[-2::-1]:
    print(q)

Measured memory_bytes: 28740
#include <bits/stdc++.h>
using namespace std;
#define Int int64_t
#define dump(x) cout << (x) << endl
#define fi first
#define se second
Int mod = 1e9+7;
Int INF = 1e18;
double EPS = 0.00000001;
//Int mod = 1e6+3;

int main() {
    Int n;
    cin >> n;
    vector<Int> c(n);
    for (Int i = 0; i < n; i++) cin >> c[i];
    vector<Int> d;
    d.emplace_back(c[0]);
    for (Int i = 1; i < n; i++) {
        if (d.back() == c[i]) continue;
        d.emplace_back(c[i]);
    }
    Int m = (Int)d.size();
    vector<Int> dp(m + 1, 0);
    dp[0] = 1;
    map<Int, Int> mp;
    for (Int i = 0; i < m; i++) {
        dp[i + 1] += mp[d[i]] + dp[i];
        dp[i + 1] %= mod;
        mp[d[i]] = dp[i + 1];
    }
    dump(dp[m]);
    return 0;
}

Measured memory_bytes: 17392
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
vector<int> edges[210000];
vector<int> redges[210000];
int n;
int p[210000];
int cyc[210000];
int vis[210000];
int t;
void dfs(int a, int st){
	if(vis[a]){
		if(a == st){
			t = st;
		}
		return;
	}
	vis[a] = 1;
	for(int j = 0; j < redges[a].size(); j++){
		dfs(redges[a][j], st);
	}
}

int gr[210000];
void dfs2(int a){
	if(gr[a] != -1) return;
	gr[a] = 0;
	map<int,int> d;
	for(int j = 0; j < redges[a].size(); j++){
		if(cyc[redges[a][j]]) continue;
		dfs2(redges[a][j]);
		d[gr[redges[a][j]]]++;
	}
	while(d[gr[a]]){
		gr[a]++;
	}
}

int ok = 0;

int time0;
void tryval(int a, int g, int st, int init){
	//cout << a << " " << g << endl;
	if(a == st && time0){
		if(g == init) ok = 1;
		return;
	}
	time0 = 1;
	map<int,int> d;
	int pa = p[a];
	for(int j = 0; j < redges[pa].size(); j++){
		if(cyc[redges[pa][j]]) continue;
		d[gr[redges[pa][j]]]++;
	}
	d[g]++;
	int b = 0;
	while(d[b]) b++;
	tryval(p[a], b, st, init);
}

int main(){
	cin >> n;
	for(int i = 0; i < n; i++){
		vis[i] = 0;
		gr[i] = -1;
		cyc[i] = 0;
		int a;
		cin >> a;
		a--;
		p[i] = a;
		edges[i].push_back(a);
		redges[a].push_back(i);
	}

	for(int i = 0; i < n; i++){
		if(!vis[i]) dfs(i, i);
	}
	int s = t;
	int ans = 0;
	while(1){
		cyc[s] = 1;
		s = p[s];
		ans++;
		if(s == t){
			break;
		}
	}

	//cout << ans << endl;
	for(int i = 0; i < n; i++){
		if(cyc[i]) dfs2(i);
	}

	time0 = 0;
	tryval(p[t], gr[p[t]], p[t], gr[p[t]]);
	//cout << "here" << p[t] << " " << gr[p[t]] << endl;
	time0 = 0;
	tryval(t, gr[p[t]], t, gr[p[t]]);
	//cout << "here" << t << " " << gr[p[t]] << endl;

	cout << (ok ? "POSSIBLE" : "IMPOSSIBLE") << endl;
}


Measured memory_bytes: 72192
N,X = gets.split.map(&:to_i)
x = gets.strip.split.map(&:to_i)
a = []

for i in 0..N-1

    a[i] = (x[i]-X).abs

end

class Array
def gcd
    self.inject{|a,b| a.gcd(b)}
end
end 

puts a.gcd 

Measured memory_bytes: 10316
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<cstring>
#include<vector>
using namespace std;
typedef long long ll;
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define sc(x) scanf("%d",&x);
typedef pair<int, int> P;
int main(){
    int n,t;
    sc(n) sc(t)
    int A[n];
    REP(i, n){
        sc(A[i])
    }
    P minA = P(A[0], 1), maxA = P(A[0], 1), ans = P(0, 1);
    for (int i = 1; i < n; i++){
        if (A[i] < minA.first){
            minA.first = A[i];
            minA.second = 1;
            maxA.first = A[i];
            maxA.second = 0;
        }else if (A[i] == minA.first){
            minA.second += 1;
        }else if (A[i] > maxA.first){
            maxA.first = A[i];
            maxA.second = 1;
            if (maxA.first - minA.first > ans.first){
                ans.first = maxA.first - minA.first;
                ans.second = max(maxA.second, minA.second);
            }else if (maxA.first - minA.first == ans.first){
                ans.second += max(maxA.second, minA.second);
            }
        }else if (A[i] == maxA.first){
            maxA.second += 1;
        }
    }
    cout << ans.second << endl;
    return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
const int MAX = 1e5;

int main(){
    int N, M, a, b;
    cin >> N >> M;
    vector<int> h(MAX), flag(MAX, 0);
    for(int i = 0; i < N; i++) cin >> h[i];
    for (int i = 0; i < M; i++){
        cin >> a >> b;
        if(h[a-1] > h[b-1]) flag[b-1] = 1;
        else if(h[a-1] < h[b-1]) flag[a-1] = 1;
        else{
            flag[a-1] = 1;
            flag[b-1] = 1;
        }
    }
    int count = 0;
    for (int i = 0; i < N; i++){
        if(flag[i] == 0) count++;
    }
    cout << count << endl;
}

Measured memory_bytes: 4060
N, K = map(int, input().split())
H = [int(input()) for i in range(N)]
H.sort()

diff = []
for i in range(N - K + 1):
  h_min = H[i]
  h_max = H[i + K - 1]
  diff.append(h_max - h_min)
print(min(diff))

Measured memory_bytes: 11288
// aribon2-1_b
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
#define debug(x) cout << #x << ": " << (x) << endl
#define REP(i, n) for (int (i) = 0 ; (i) < (int)(n) ; ++(i))
#define REPN(i, m, n) for (int (i) = m ; (i) < (int)(n) ; ++(i))
#define REP_REV(i, n) for (int (i) = (int)(n) - 1 ; (i) >= 0 ; --(i))
#define all(x) x.begin(), x.end()
#define INF ((1 << 16)-1)
#define MOD (1000000007)
#define print(arr, n) REP(i, n) cout << arr[i] << " ";
#define CHAR2INT(c) (c - '0')

struct PreMain {PreMain(){std::cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(20);}} premain;

int main() {
#ifdef LOCAL
    std::ifstream in("../arg.txt");
    std::cin.rdbuf(in.rdbuf());
#endif

    string s;
    cin >> s;

    int N = 1 << (s.size() - 1);
    REP(x, N){
        ll ans = CHAR2INT(s[0]);
        int n = x;
        REPN(i, 1, s.size()) {
            if (n & 1) {
                ans += CHAR2INT(s[i]);
            } else {
                ans -= CHAR2INT(s[i]);
            }
            n >>= 1;
        }

        if (ans == 7){
            n = x;
            cout << s[0];
            REPN(i, 1, s.size()) {
                if (n & 1) {
                    cout << "+" << s[i];
                } else {
                    cout << "-" << s[i];
                }
                n >>= 1;
            }
            cout << "=7" << endl;
            exit(0);
        }
    }
    return 0;
}




Measured memory_bytes: 256
//----------------------------------------------------------------------
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)   FOR(i,0,n)
//----------------------------------------------------------------------

using namespace std;
using ll = long long;
using P = pair<int,int>;
using Graph = vector<vector<int>>;

int main(void) {
    int a, b;
    cin >> a >> b;
    string ans_a="";
    int n = 1;
    for(int i = 0; i <b; ++i) {
        ans_a +=  to_string(a);
    }
    string ans_b="";
    for(int i = 0; i <a; ++i) {
        ans_b += to_string(b);
    }
    cout << (ans_a<= ans_b ? ans_a : ans_b) << endl;
    return 0;
}

Measured memory_bytes: 256
// abc122_b
#include <bits/stdc++.h>
#ifdef LOCAL
#include "../cxx-prettyprint/prettyprint.hpp"
#endif
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;

#define REP(i, n) for (int (i) = 0 ; (i) < (int)(n) ; ++(i))
#define REPN(i, m, n) for (int (i) = m ; (i) < (int)(n) ; ++(i))
#define REP_REV(i, n) for (int (i) = (int)(n) - 1 ; (i) >= 0 ; --(i))
#define REPN_REV(i, m, n) for (int (i) = (int)(n) - 1 ; (i) >= m ; --(i))
#define ALL(x) x.begin(), x.end()

#define INF ((1 << 29)-1)
#define MOD (1000000007)

#define print2D(h, w, arr) REP(i, h) { REP(j, w) cout << arr[i][j] << " "; cout << endl; }
#define print_line(vec, n) {for(int i=0;i<(n-1);i++) cout << (vec)[i] << " "; cout << (vec)[(n)-1] << endl;}
template<class T> void print(const T& x){cout << x << endl;}
template<class T, class... A> void print(const T& first, const A&... rest) { cout << first << " "; print(rest...); }
struct PreMain {PreMain(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(20);}} premain;

int main() {
#ifdef LOCAL
    ifstream in("../arg.txt"); cin.rdbuf(in.rdbuf());
#endif

    string S;
    cin >> S;

    int ans = 0;
    REP(i, S.size()){

        if (S[i] == 'A' || S[i] == 'C' || S[i] == 'G' || S[i] == 'T'){
            int tmp = i;
            while (tmp < S.size() && (S[tmp] == 'A' || S[tmp] == 'C' || S[tmp] == 'G' || S[tmp] == 'T')){
                tmp++;
            }
            ans = max(ans, tmp-i);
            i = tmp;
        }
    }

    print(ans);

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++) //これでiやjを定義しなくていいらしい
using namespace std;

int main(){
  int h1,h2,m1,m2,k;
  cin >> h1 >> m1 >> h2 >> m2 >> k;

  int ans;
  ans = (h2-h1)*60 + (m2-m1) - k;
  cout << ans << endl;

  return 0;
}


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

struct Edge{
    int to,c,h,r;
};
const int INF=1e8;
using Graph=vector<vector<Edge>>;
void cmin(int &lhs,int rhs){
    lhs=min(lhs,rhs);
}
int solve(int n,int m,int h,int k){
    Graph g(n);
    for(int i=0;i<m;i++){
        int a,b,c,h,r;
        cin>>a>>b>>c>>h>>r;
        a--,b--,r--;
        g[a].push_back({b,c,h,r});
        g[b].push_back({a,c,h,r});
    }
    int s,t;
    cin>>s>>t;
    s--,t--;
    int p;
    cin>>p;
    vector<int> pass(1<<k,INF);
    pass[0]=0;
    for(int i=0;i<p;i++){
        int l,d;
        cin>>l>>d;
        int st=0;
        for(int j=0;j<l;j++){
            int v;
            cin>>v;
            v--;
            st|=(1<<v);
        }
        cmin(pass[st],d);
    }
    for(int i=0;i<k;i++){
        for(int j=0;j<(1<<k);j++){
            for(int jj=0;jj<(1<<k);jj++){
                cmin(pass[j|jj],pass[j]+pass[jj]);
            }
        }
    }
    int res=INF;
    for(int bit=0;bit<(1<<k);bit++){
        vector<vector<int>> d(h+1,vector<int>(n,INF));
        d[0][s]=0;
        for(int i=0;i<h;i++){
            for(int v=0;v<n;v++){
                for(auto &e:g[v]){
                    if(i+e.h<=h){
                        int c=e.c;
                        if((bit>>e.r)&1) c=0;
                        cmin(d[i+e.h][e.to],d[i][v]+c);
                    }
                }
            }
        }
        
        for(int i=0;i<=h;i++){
            cmin(res,d[i][t]+pass[bit]);
        }
    }
    return res==INF ? -1 : res;
}
int main(){
    int n,m,h,k;
    while(cin>>n>>m>>h>>k,n){
        cout<<solve(n,m,h,k)<<endl;
    }
    return 0;
}


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

int main(){
	
	string k[256];
	k['1']=".,!? ";
	k['2']="abc";
	k['3']="def";
	k['4']="ghi";
	k['5']="jkl";
	k['6']="mno";
	k['7']="pqrs";
	k['8']="tuv";
	k['9']="wxyz";
	k['0']="";
	
	int n;cin>>n;
	while(n--){
		string s;cin>>s;
		for(int i=0;i<s.size();i++){
			if(i==0 && s[i]=='0')continue;
			int t=-1;
			while(s[i]!='0'){
				t++;
				i++;
			}
			if(s[i-1]=='0')continue;
			cout<<k[s[i-1]][t%k[s[i-1]].size()];
		}
		cout<<endl;
	}
	
	return 0;
}


Measured memory_bytes: 1208
import sys
sys.setrecursionlimit(10**7)
input = sys.stdin.readlines
def main():
    lines = input()

    N = int(lines[0].strip())
    A = list(map(int, lines[1].split()))

    max_ = 0
    total = 0
    for i, x in enumerate(A):
        if x <= max_:
            total += (max_ - x)
        else:
            max_ = x
    print(total)

main()


Measured memory_bytes: 33288
fun pow(a:Int, b:Int):Long{
    var x=1L
    repeat(b){
        x*=a
    }
    return x
}

fun main(args: Array<String>) {
    val n=readLine()!!.toInt()
    var m=n.toLong()
    val s= mutableListOf<Int>()
    for(i in 0..32){
        if(m%pow(2,i+1)!=0L) {
            s+=1
            m -= pow(-2, i)
        }else{
            s+=0
        }

        if(m==0L) break
    }
    s.reversed().forEach {
        print(it)
    }
    println()
}


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

const int SIZE = 10001;

int main()
{
	bool prime[ SIZE ];
	memset( prime, 0, sizeof(prime) );

	prime[ 0 ] = prime[ 1 ] = true;
	for( int i = 2; i < SIZE; ++i ){
		if( prime[ i ] ) continue;
		for( int j = i + i; j < SIZE; j += i ){
			prime[ j ] = true;
		}
	}

	int n;
	while( cin >> n && n ){
		for( int i = ( n % 2 == 0 ? n - 1 : n ); n > 1; i -= 2 ){
			if( !prime[ i ] && !prime[ i - 2 ] ){
				cout << i - 2<< " " << i << endl;
				break;
			}
		}
	}

	return 0;
}

Measured memory_bytes: 1180
def main():
    N = input()
    tmp = 10 ** (len(N) - 1) - 1
    res_ = int(tmp)
    if tmp == 0:
        print(N)
        return

    for i in range(1, 10):
        if int(str(i) + str(tmp)) <= int(N):
            res_ = int(str(i) + str(tmp))

    res = 0
    for x in str(res_):
        res += int(x)
    print(res)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3060
#include <iostream>
#include <string>
#include <algorithm>
#include <math.h>
#include <vector>
#include <map>
#include <queue>
#include <set>
using namespace std;
typedef long long int lo;
#define pb push_back
#define mp make_pair
#define st first
#define nd second
#define inf (lo)1e9;
#define FOR for(lo i = 0 ; i < n ; i++)
#define FORV for(lo i = 0 ; i < (lo)v.size() ; i++)
#define ii pair<lo,lo>
#define iii pair<lo, pair<lo,lo> >
lo a,b,c,d,e,n,m,k,t,h,x,y,a1[100005],a2[100005];
char c1,c2,c3,c4;
string s1,s2,s3,s4;
double d1,d2,d3;
vector <lo> v;
map <lo,lo> mp1;
map <string,lo> mp2;
set <lo> stt;
queue <lo> q;
priority_queue <lo> pq;
lo vis [10000];
lo arr[32] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
int main() {
    // #ifndef ONLINE_JUDGE
    // freopen("gir.gir", "r", stdin);
    // freopen("cik.cik", "w", stdout);
    // #endif
    cin >> n;
    cout << arr[n - 1] << endl;
    return 0;
}

Measured memory_bytes: 256
/* ************************************************************************** */
/*                                                                            */
/*                                                        :::      ::::::::   */
/*   main.cpp                                           :+:      :+:    :+:   */
/*                                                    +:+ +:+         +:+     */
/*   By: monoue <marvin@student.42.fr>              +#+  +:+       +#+        */
/*                                                +#+#+#+#+#+   +#+           */
/*   Created: 2020/04/22 12:30:15 by monoue            #+#    #+#             */
/*   Updated: 2020/04/27 11:20:46 by monoue           ###   ########.fr       */
/*                                                                            */
/* ************************************************************************** */

#include <bits/stdc++.h>

/* #include <boost/multi_array.hpp> */
/* #include <boost/optional.hpp> */
/* #include <boost/range/irange.hpp> */
/* #include <boost/range/algorithm.hpp> */
/* #include <boost/range/adaptors.hpp> */
/* #include <boost/multiprecision/cpp_int.hpp> */
/* #include <boost/algorithm/string/classification.hpp> // is_any_of */
/* #include <boost/algorithm/string/split.hpp> */
/* #include <boost/algorithm/string/join.hpp> */
/* #include <boost/algorithm/string/replace.hpp> */
/* #include <boost/math/tools/minima.hpp> */
/* namespace adaptor = boost::adaptors; */
/* using boost::math::tools::brent_find_minima; */
/* using boost::irange; */
/* using boost::algorithm::join; */
/* using boost::algorithm::split; */
/* using boost::algorithm::replace_all; */
/* using boost::multiprecision::cpp_int; */

#define MOD 1e9+7;
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, n) for (int i = (n); i >= 0; --i)

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

// TOP
void	Main()
{
	vector<int>	V(200001);
	int		n, k;
	ll		r, s, p;
	string	str;
	cin >> n >> k >> s >> p >> r >> str;

	ll	sum;
	sum = 0;
	rep(i, n)
	{
		if (str.at(i) == 'r' && (i < k || V.at(i - k) != 1))
		{
			sum += r;
			V.at(i) = 1;
		}
		if (str.at(i) == 's' && (i < k || V.at(i - k) != 2))
		{
			sum += s;
			V.at(i) = 2;
		}
		if (str.at(i) == 'p' && (i < k || V.at(i - k) != 3))
		{
			sum += p;
			V.at(i) = 3;
		}
	}
	cout << sum << endl;
}
// END

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


Measured memory_bytes: 1280
//
//  AT3879 [ABC087A] Buying Sweets.cpp
//  Algorithm
//
//  Created by SkyGao on 2020/2/13.
//  Copyright © 2020 skygao. All rights reserved.
//

#include <stdio.h>
#include <cstdlib>
#include <cstring>
#include <string>
#include <algorithm>
#include <iostream>
#define re regsiter
using namespace std;
int main()
{
    int x,a,b;
    scanf("%d%d%d",&x,&a,&b);
    printf("%d",(x-a)%b);
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
using ll = long long;
char a[100][100], b[102] [102];
int main(){
    int H, W;
    cin >> H >> W;
    for(int i=0; i<H; i++) cin >> a[i];

    for(int i=0; i<H+2; i++)
        for(int j=0; j<W+2; j++)
            b[i][j] = '#';
    
    for(int i=0; i<H; i++)
        for(int j=0; j<W; j++)
            b[i+1][j+1] = a[i][j];

    for(int i=0; i<H+2; i++){
        for(int j=0; j<W+2; j++){
            cout << b[i][j];
        }
        cout << endl;
    }
    return 0;
}

Measured memory_bytes: 256
A,B=map(int,input().split())
Aset=set([int(i) for i in range(1,1010) if int(i*0.08)==A])
Bset=set([int(i) for i in range(1,1010) if int(i*0.1)==B])
if Aset&Bset :
    print(min(Aset&Bset))
else:
    print(-1)


Measured memory_bytes: 3060
#include <iostream>
#include <map>
#include <string>
#include <sstream>

using namespace std;

int main(int argc, char *argv[]) {
  map<string, int> words;
  string tmp, line;

  getline(cin, line);
  stringstream ss(line);
  while (ss >> tmp)
    if (words.count(tmp) == 0)
      words.insert(pair<string, int>(tmp, 1));
    else
      words[tmp]++;

  map<string, int>::iterator itr = words.begin();
  string longest = (*itr).first;
  map<string, int>::iterator freq = itr;
  while (itr != words.end()) {
    if (longest.size() < (*itr).first.size())
      longest = (*itr).first;
    if ((*freq).second < (*itr).second)
      freq = itr;
    itr++;
  }

  cout << (*freq).first << ' ' << longest << endl;
  return 0;
}

Measured memory_bytes: 1200
#include <iostream>
#include <algorithm>
#include <cstdlib>
#include <cstring>
#include <cstdio>
#include <string>
#include <math.h>
#include <map>
#include <set>
#define sc scanf
#define pr printf
using namespace std;
typedef long long ll;
const int N = 100000+100;
bool ans[N];
char str[N];
bool hander_ans(int n);
bool is_right(int check_index , int rh , int lh);
int main()
{
    int i,j,n;
    while(~sc("%d",&n))
    {
        sc(" %s",str);

        ans[0] = 0 , ans[1] = 0;
        if(hander_ans(n)) continue;

        ans[0] = 0 , ans[1] = 1;
        if(hander_ans(n)) continue;

        ans[0] = 1 , ans[1] = 0;
        if(hander_ans(n)) continue;

        ans[0] = 1 , ans[1] = 1;
        if(hander_ans(n)) continue;

        pr("-1\n");
    }
    return 0;
}
bool is_right(int check_index , int rh , int lh)
{
    if(ans[check_index] == 0)
    {
        if(str[check_index] == 'o' ) return ans[rh] == ans[lh];
        if(str[check_index] == 'x' ) return ans[rh] != ans[lh];
    }
    else
    {
        if(str[check_index] == 'o' ) return ans[rh] != ans[lh];
        if(str[check_index] == 'x' ) return ans[rh] == ans[lh];
    }
    return 0;
}
bool hander_ans(int n)
{
    int i,j,flag = 0;
    for(i=2; i<n; i++)
    {
        if(ans[i-1] == 0)
        {
            if(str[i-1] == 'o')
                ans[i] = ans[i-2];
            else
                ans[i] = !ans[i-2];
        }
        else
        {
            if(str[i-1] == 'o')
                ans[i] = !ans[i-2];
            else
                ans[i] = ans[i-2];
        }
    }
    if(is_right(n-1,0,n-2) && is_right(0,1,n-1))
    {
        for(i=0; i<n; i++)
        {
            if(ans[i])
                  pr("W");
            else
                pr("S");
        }
        pr("\n");
        return 1;
    }
    return 0;
}


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

int main()
{
	for (int i = 1; i < 10; ++i)
	{
		for (int j = 1; j < 10; ++j)
		{
			cout << i << "x" << j << "=" << i*j << endl;
		}
	}
	return 0;
}


Measured memory_bytes: 3036
#include<bits/stdc++.h>
using namespace std;
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int n;
	cin >> n;
	int a[n];
	int b[n];
	int c[n];
	for(int i = 0; i<n; i++)
	{
		cin >> a[i] >> b[i] >> c[i];
	}
	int dp[n][3];
	dp[0][0] = a[0];
	dp[0][1] = b[0];
	dp[0][2] = c[0];
	for(int i = 1; i<n; i++)
	{
		dp[i][0] = a[i] + max(dp[i-1][1], dp[i-1][2]);
		dp[i][1] = b[i] + max(dp[i-1][0], dp[i-1][2]);
		dp[i][2] = c[i] + max(dp[i-1][0], dp[i-1][1]);
	}
	cout << max({dp[n-1][0], dp[n-1][1], dp[n-1][2]});
}

Measured memory_bytes: 2560
#include <bits/stdc++.h>
    using namespace std;
     
    int main() {
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
     
        long a, b, c, x, y;
        cin >> a >> b >> c >> x >> y;
     
        long min_num = min(x, y);
        long sum = 0;
        if (a + b < c * 2) {
            sum += (a + b) * min_num;
        } else {
            sum += c * 2 * min_num;
        }
     
        if (x > y) {
            if (a < c * 2) {
                sum += a * (x - min_num);
            } else {
                sum += c * 2 * (x - min_num);
            }
        } else {
            if (b < c * 2) {
                sum += b * (y - min_num);
            } else {
                sum += c * 2 * (y - min_num);
            }
        }
     
     
        cout << sum << '\n';
     
        return 0;
    }

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

const int maxn = 2e5+5;
string s;
int n;
int label[maxn];

int bit[maxn];
void add(int i, int x) {
    for (; i <= n; i += i & (-i))
        bit[i] += x;
}

int sum(int i) {
    int r = 0;
    for (; i; i -= i & (-i)) {
        r += bit[i];
    }
    return r;
}

ll dist(string u, string v) {
    map<pair<char,int>,int> mp;    
    map<char,int> occ;
    for (int i = 0; i < u.size(); i++) {
        char c = u[i];
        occ[c]++;
        mp[make_pair(c,occ[c])] = i+1;
    }
    occ.clear();
    ll ret = 0;
    for (char c: v) {
        occ[c]++;
        int m = mp[make_pair(c,occ[c])];
        ret += sum(n) - sum(m);
        add(m,1);
    }
    return ret;
}

int main() {
    ios_base::sync_with_stdio(false); cin.tie(NULL);
    cin >> s;
    n = s.size();
    map<char,int> mp;
    for (char c: s) {
        mp[c]++;
    }
    int odd = 0;
    for (auto p: mp) {
        if (p.second&1) odd++;
    }
    if (n % 2 == 0 && odd > 0) {
        cout << -1 << '\n';
        return 0;
    }
    else if (n % 2 == 1 && odd > 1) {
        cout << -1 << '\n';
        return 0;
    }
    for (auto p: mp) {
        int cnt = 0;
        if (p.second % 2 == 1) {
            for (int i = 0; i < n; i++) {
                if (s[i] == p.first) {
                    if (cnt < p.second/2) label[i] = 1;
                    else if (cnt == p.second/2) label[i] = 2;
                    else label[i] = 3;
                    cnt++;
                }
            }
        }
        else {
            for (int i = 0; i < n; i++) {
                if (s[i] == p.first) {
                    if (cnt < p.second/2) label[i] = 1;
                    else label[i] = 3;
                    cnt++;
                }
            }
        }
    }
    ll swaps = 0;
    vector<int> cnt(4,0);
    for (int i = 0; i < n; i++) {
        for (int j = label[i]+1; j <= 3; j++) {
            swaps += cnt[j];
        }
        cnt[label[i]]++;
    }
    string u, v;
    for (int i = 0; i < n; i++) {
        if (label[i] == 1) u += s[i];
        else if (label[i] == 3) v += s[i];
    }
    reverse(v.begin(),v.end());
    swaps += dist(u,v);
    cout << swaps << '\n';
}



Measured memory_bytes: 8340
import java.io.*;
import java.util.*;


// æ­Ôá¤Æ±ëB
// âè¶É¢ÄÈ­ÄàâèZbgÍ¡Åæªª0ÅI¹Å éB
// âèZbgÌJèÔµÉú»Rê

// 2011/10/18

//@0100 Sale Result
public class Main {

	
	// C return falseÅ¨µÜ¢
	boolean main() throws IOException {

		int N = readIntArray()[0];
		if (N == 0)
			return false; /* ¨µÜ¢ */

		List<Integer> banList = new ArrayList<Integer>(); // ÐõÔXg 
		List<Long> sumList = new ArrayList<Long>(); // èã°v 
		
		for(int i = 0; i < N; i++) {
			int[] ir = readIntArray();
			int ban = ir[0];
			long tan = ir[1];
			long su = ir[2];
			
			int idx = banList.indexOf(ban);
			if (idx < 0) {
				banList.add(ban);
				sumList.add(tan * su);
			}
			else {
				sumList.set(idx, sumList.get(idx) + tan * su);
			}
		}

		int cnt = 0;
		for(int i = 0; i < banList.size(); i++) {
			if (sumList.get(i) >= 1000000L) {
				System.out.printf("%d\n", banList.get(i));
				cnt++;
			}
		}

		if (cnt == 0)
			System.out.printf("NA\n");
		
		return true; /* ³íI¹ Ö */
	}
	

//	private final static boolean DEBUG = true;  // debug
	private final static boolean DEBUG = false; // release

	public static void main(String[] args) throws IOException {

		if (DEBUG) {
			log = System.out;
			
			String inputStr = "4\n0 0 10 0 10 10 0 10\n10\n12\n0 5\n9 5\n0\n"; // 108.0
//			String inputStr = "4\n0 0 10 0 10 10 0 10\n10\n12\n0 0\n9 1\n0\n"; // 96.63324958071081
//			String inputStr = "4\n0 0 10 0 10 10 0 10\n10\n12\n0 1\n9 1\n0\n"; // 103.2664991614216
//			String inputStr = "8\n2 0 4 0 6 2 6 4 4 6 2 6 0 4 0 2\n10\n12\n3 0\n3 5\n0\n"; // 60.0

			reader = new BufferedReader(new StringReader(inputStr)); 

		}
		else {
			log = new PrintStream(new OutputStream() { public void write(int b) {} } ); // «ÌÄ
			reader = new BufferedReader(new InputStreamReader(System.in)); // R\[©ç
		}

		for(int loop = 0;; loop++) {
			boolean b = new Main().main();
			if (!b)
				break;
		}		
		
		reader.close();
	}

	
	static PrintStream log;
	static BufferedReader reader;
	

	// WüÍæè@1sªÌXy[XæØèÌ®lðÇÞ
	private int[] readIntArray() throws IOException {
		
		String s = reader.readLine();
		String[] sp = s.split(" ");
		int[] a = new int[sp.length];
		for(int i = 0; i < sp.length; i++) {
			a[i] = Integer.parseInt(sp[i]);
		}
		return a;
	}
		
}

Measured memory_bytes: 13000
L, R = map(int, input().split())
d = R - L
if d > 2019:
  print(0)
else:
  ans = R*L
  for i in range(L, R+1):
    for j in range(i+1,R+1):
      check = (i*j)%2019
      if check < ans:
        ans = check
  print(ans)

Measured memory_bytes: 41196
#include<iostream>
#include<set>
#include<vector>
#include<cmath>
#include<complex>

using namespace std;

#define rep(i,n) for(int i=0;i<n;i++)
#define pb push_back

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<vi> vvi;


int main(void)
{
    int n;

    cin >> n;
    cout << 48-n << '\n';

    return 0;
}

Measured memory_bytes: 256
a, b, k = map(int, input().split())

if k<a:
  a -= k
  print("%d %d"%(a, b))
  exit(0)
else:
  k-=a
  a=0
  
if k<b:
  b -= k
  print("%d %d"%(a, b))
  exit(0) 
else:
  k-=b
  b=0
  
print("%d %d"%(a, b))
  

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

int main() {
	int a,b;
	cin>>a>>b;
	string s1 = "";
	string s2 = "";
	for(int i=0;i<b;i++){
		s1+=to_string(a);
	}
	for(int i=0;i<a;i++){
		s2+=to_string(b);
	}
	// cout<<s1<<endl;
	// cout<<s2<<endl;
	if(s1<=s2)
		cout<<s1<<endl;
	else
		cout<<s2<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <functional>
#include <string>
#include <cmath>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <cstdio>
#include <numeric>
using namespace std;
using ll = long long;
int main() {
  int n, x, t;
  cin >> n >> x >> t;
  cout << ((n + x - 1) / x) * t << endl;
  return 0;
}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define F first
#define S second
#define pii pair<int, int>
#define eb emplace_back
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep3(i, l, n) for (int i = l; i < (n); ++i)
#define sz(v) (int)v.size()
#define inf (int)(1e9+7)
template<typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { if (a < b) { a = b; return 1; } return 0; }
template<typename T> T gcd(T a, T b) { if (b == 0) return a; return gcd(b, a % b); }



vector<vector<int> > x(10, vector<int>(10));
int f(int a, int b, int c, int d) {
    return x[x[x[x[0][a]][b]][c]][d];
}
int error(int a, int b, int c, int d, int e) {
    if (x[x[x[x[x[0][a]][b]][c]][d]][e] == 0) return 1;
    return 0;
}
int all_correct(vector<int> a) {
    // 1文字置き換え
    rep(i, 5) {
        vector<int> b = a;
        rep(j, 10) {
            if (a[i] == j) continue;
            b[i] = j;
            /*
            if (a[0] == 2 && a[1] == 0 && a[2] == 1 && a[3] == 6 && a[4] == 6) {
                cout << error(b[0], b[1], b[2], b[3], b[4]) << endl;
            }
             */
            if (error(b[0], b[1], b[2], b[3], b[4])) return 0;
        }
    }
    // 2文字swap // 隣接だけやった
    rep(i, 4) {
        int j = i + 1;
        vector<int> b = a;
        if (b[i] == b[j]) continue;
        swap(b[i], b[j]);
        /*
        if (a[0] == 2 && a[1] == 0 && a[2] == 1 && a[3] == 6 && a[4] == 6) {
            cout << i << " " << j << " " << error(b[0], b[1], b[2], b[3], b[4]) << endl;
        }
        */
        if (error(b[0], b[1], b[2], b[3], b[4])) return 0;
    }
    return 1;
}
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    
    rep(i, 10) rep(j, 10) cin >> x[i][j];
    
    int ans = 0;
    rep(i, 10) rep(j, 10) rep(k, 10) rep(l, 10) {
        int e = f(i, j, k, l);
        vector<int> a(5);
        a[0] = i; a[1] = j; a[2] = k; a[3] = l; a[4] = e;
        // rep(_, 5) cout << a[_] << " "; cout << endl;
        if (all_correct(a) == 0) ans++;
        // cout << ans << endl;
    }
    cout << ans << endl;
}



Measured memory_bytes: 3216
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define Rep(i,s,n) for(int i=s;i<n;i++)
#define fi first
#define se second
#define all(c) c.begin(),c.end()
typedef long long int ll;
typedef pair<int, int> P;
typedef long double ld;
void Ans(bool x){if(x) cout<<"Yes"<<endl;else cout<<"No"<<endl;}

const ll INF=1001001001;
const ll mod=1000000007;

int main(){
  cout<<fixed<<setprecision(15);
  int n;
  cin>>n;
  ld x[n],y[n];
  rep(i,n) cin>>x[i]>>y[i];
  vector<int> v(n);
  rep(i,n) v[i]=i;
  ld sum=0;
  do{
    rep(i,n-1){
      ld dx=x[v[i]]-x[v[i+1]];
      ld dy=y[v[i]]-y[v[i+1]];
      sum+=pow(dx*dx+dy*dy,0.5);
    }
  }while(next_permutation(all(v)));
  
  ld u=1;
  rep(i,n) u*=(i+1);
  cout<<sum/u<<endl;
}
         



Measured memory_bytes: 256
N, X, M = map(int, input().split())

s = 0
mt = []
def f(x):
    return x**2 % M
i = 0
while True:
    i += 1
    mt.append(X)
    a = f(X)
    if i == N:
        f = 1
        break
    elif a in mt:
        f = 0
        break
    else:
        X = a

if f == 1:
    print(sum(mt))
else:
    e = mt.index(a)
    s1 = mt[:e]
    s2 = mt[e:]
    l = i - e
    c, d = divmod(N - e, l)
    print(sum(s1) + sum(s2) * c + sum(s2[:d]))

Measured memory_bytes: 69004
#include <iostream>
#include <ccomplex>
#include <vector>
#include <cassert>
#include <utility>
#include <algorithm>
#include <string>
#include <deque>
#include <queue>
#include <functional>
#include <cmath>
#include <iomanip>
#include <map>
#include <numeric>
#include <list>
#include <assert.h>
#include <math.h>
#include <valarray>
#include <stdio.h>
#include <algorithm>
#include <set>
#include <complex>
#include <list>
#include <time.h>
#include <stack>
#include <locale>
#include <clocale>
#include <ctype.h>
#include <wchar.h>

using namespace std;
typedef long long int LL;
typedef pair<long long int, long long int> pii;
typedef pair<double, double> pdd;

#define SORT(c) sort((c).begin(),(c).end())
#define BACKSORT(c) sort((c).begin(),(c).end(),std::greater<LL>())
#define FOR(i,a,b) for(LL i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

int xcomp(vector<LL>& a, vector<LL>& b) {
	return a[0] < b[0];
}

#define XSORT(c) sort((c).begin(),(c).end(),xcomp)

#define ALL(x) (x).begin(),(x).end()
LL mod = 1000000007;

LL pow2(LL x) {
	if (x == 0) {
		return 1;
	}
	else {
		return pow2(x - 1) * 2;
	}
}

LL ketasu(LL x) {
	if (x == 1) {
		return 1;
	}else
		if (x == 0) {
			return 0;
		}
		else {
			return ketasu(x / 2) + 1;
		}
}

int main() {
	LL N;
	cin >> N;
	LL vv = 0;
	vector<LL> v(N, 0);
	vector<LL> h(N, 0);
	vector<LL> ni(30, 0);
	REP(i, N) {
		cin >> v[i];
		h[i] = v[i] ^ (v[i] - 1); 
		ni[ketasu(h[i])] = 1;
		vv = vv^v[i];
	}
	LL sum=0;
	while (true) {
		if (vv == 0) {
			cout<< sum<<endl;
			break;
		}
		if (ni[ketasu(vv)] == 1) {
			vv = vv ^ (pow2(ketasu(vv)) - 1);
			sum++;
		}
		else {
			cout << -1 << endl;
			break;
		}
	}
}

Measured memory_bytes: 1792
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <set>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <cstdio>
#include <cstring>
#include <iterator>
#include <bitset>
#include <unordered_set>
#include <unordered_map>
#include <fstream>
#include <iomanip>
//#include <utility>
//#include <memory>
//#include <functional>
//#include <deque>
//#include <cctype>
//#include <ctime>
//#include <numeric>
//#include <list>
//#include <iomanip>

//#if __cplusplus >= 201103L
//#include <array>
//#include <tuple>
//#include <initializer_list>
//#include <forward_list>
//
//#define cauto const auto&
//#else

//#endif

using namespace std;


typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;

#define VV(T) vector<vector< T > >

template <class T>
void initvv(vector<vector<T> > &v, int a, int b, const T &t = T()){
    v.assign(a, vector<T>(b, t));
}

template <class F, class T>
void convert(const F &f, T &t){
    stringstream ss;
    ss << f;
    ss >> t;
}

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define reep(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) reep((i),0,(n))
#define ALL(v) (v).begin(),(v).end()
#define PB push_back
#define F first
#define S second
#define mkp make_pair
#define RALL(v) (v).rbegin(),(v).rend()
#define DEBUG
#ifdef DEBUG
#define dump(x)  cout << #x << " = " << (x) << endl;
#define debug(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
#else
#define dump(x) 
#define debug(x) 
#endif
#define LDcout(x,n) fixed<<setprecision(n)<<x

#define MOD 1000000007LL
#define EPS 1e-8
static const int INF=1<<24;

void mainmain(){
	int n;
	while(cin>>n,n){
		vvll vv;
		initvv(vv,n,n,0LL);
		vvll a=vv,b=vv;
		rep(i,n) rep(j,n) cin>>vv[i][j];
		rep(i,n){
			ll t=LLONG_MAX;
			rep(j,n){
				t=min(t,vv[i][j]);
			}
			rep(j,n) if(vv[i][j]==t) b[i][j]=1;
			t=0;
			rep(j,n){
				t=max(t,vv[j][i]);
			}
			rep(j,n) if(vv[j][i]==t) a[j][i]=1;
		}
		bool f=false;
		ll ans=-10000000;
		rep(i,n){
			rep(j,n){
				if(!f&&a[i][j]&&b[i][j]){
					cout<<vv[i][j]<<endl;
					f=true;
				}
			}
		}
		if(!f){
			cout<<0<<endl;
		}
		else{
			// cout<<ans<<endl;
		}
	}
}


signed main() {
	ios_base::sync_with_stdio(false);
  	cout<<fixed<<setprecision(0);
    mainmain();
}

Measured memory_bytes: 1220
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define FOR(i,start,end) for(int i=start;i<=end;i++)
const int INF = 1001001001;
typedef long long ll;
const ll MOD=1000000007;
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T>auto MAX(const T& a) { return *max_element(a.begin(),a.end()); }
template<class T>auto MIN(const T& a) { return *min_element(a.begin(),a.end()); }
template<class T, class U>U SUM(const T& a, const U& v) { return accumulate(a.begin(),a.end(), v); }
template<class T, class U>U COUNT(const T& a, const U& v) { return count(a.begin(),a.end(), v); }
template<class T, class U>int LOWER(const T& a, const U& v) { return lower_bound(a.begin(),a.end(), v) - a.begin(); }
template<class T, class U>int UPPER(const T& a, const U& v) { return upper_bound(a.begin(),a.end(), v) - a.begin(); }
int GCD(int a, int b) { return b ? GCD(b, a%b) : a; }
int LCM(int a, int b) { int g = GCD(a, b); return a / g * b; }

int main(void){
    // Your code here!
    int x,n; cin >> x >> n;
    if (n == 0) {
        cout << x << endl;
        return 0;
    }
    vector<int> p(n);
    rep(i,n) cin >> p[i];
    int ans = INF;
    int num ;
    for(int i = -10000; i < 10000 ;i++) {
        bool res = false;
        rep(j,n) {
            if (p[j] == i) res = true;
        }
        if(!res) {
            if (ans > abs(i-x)) {
                ans = abs(i-x);
                num = i;
            }
            ans = min(ans,abs(i-x));
        }
    }
    cout << num << endl;
}


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

#define rep(i, n) for (int i = 0; i < n; ++i)
#define all(x) (x).begin(),(x).end()
#define endl "\n"

using ll = long long;
using P = pair<int,int>;
using mp =  map<int,int>;

const int MOD = 1e9 + 7;

int main() {
    ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);

    int n;
    cin >> n;

    int ans = 0;
    for (int i = 1; i < 1001; ++i) {
        int tmp = i;
        for (int j = 1; j < 1001; ++j) {
            tmp *= i;
            if(tmp > n){
                break;
            }else{
                ans = max(ans, tmp);
            }
        }        
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
import sys
INF = 1 << 60
MOD = 10**9 + 7 # 998244353
sys.setrecursionlimit(2147483647)
input = lambda:sys.stdin.readline().rstrip()
from math import gcd
from functools import reduce
def resolve():
    n = int(input())
    A = list(map(int, input().split()))

    if reduce(gcd, A) != 1:
        print("not coprime")
        return

    M = max(A)
    dist = [0] * (M + 1)
    for a in A:
        dist[a] += 1

    for d in range(2, M + 1):
        c = sum(dist[i] for i in range(d, M + 1, d))
        if c >= 2:
            print("setwise coprime")
            return

    print("pairwise coprime")
resolve()

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

int main(){
    int i,n,k,x,sum=0;
    cin >> n >> k;
    for(i=0;i<n;i++){
        cin >> x;
        if(x<abs(k-x))
            sum+=2*x;
        else
            sum+=2*abs(k-x);
    }
    cout << sum << endl;
}

Measured memory_bytes: 256
n = int(input())
a = list(map(int, input().split()))
a.sort(reverse=True)
dif = 1000000000
best = a[0] // 2
ans = 0
for i in range(1, n):
    new_dif = abs(best - a[i])
    if dif <= new_dif:
        ans = a[i - 1]
        break
    dif = new_dif
else:
    print(a[0], a[1])
    exit()
print(a[0], ans)



Measured memory_bytes: 85164
#pragma target("avx")
#include<bits/stdc++.h>
using ll = int_fast64_t;
using P = std::pair<ll,ll>;
using V = std::vector<ll>;
template<typename T> using pq = std::priority_queue<T>;
template<typename T> using rpq = std::priority_queue<T, std::vector<T>, std::greater<T>>;

#define REP(i,b,e) for(ll i=b; i<e; i++)
#define ALL(vec) vec.begin(),vec.end()
#define PRINT(vec) printf("[ ");for(auto &i:vec)printf("%ld ",i);puts("]");
#define SCAN(vec) for(auto &i:vec)scanf("%ld",&i)
#define fi first
#define se second

const int MOD = 1e9+7;
const ll INF = 1e18;
int dx[] = {0, 1, 0, -1, 1, 1, -1, -1}, dy[] = {1, 0, -1, 0, 1, -1, -1, 1};

int main(){
	std::string s;
	std::cin >> s;
	std::reverse(ALL(s));
	ll n = s.size();

	ll digi = 1, dp[1+n][13] = {};
	dp[0][0] = 1;
	REP(i, 0, n){
		if(s[i]=='?'){
			REP(x, 0, 10){
				ll rem = x * digi % 13;
				REP(j, 0, 13){
					dp[i+1][(j+rem)%13] += dp[i][j];
					dp[i+1][(j+rem)%13] %= MOD;
			
				}
			}
		}else{
			REP(j, 0, 13){
				ll rem = (s[i]-'0') * digi % 13;
				dp[i+1][(j+rem)%13] += dp[i][j];
				dp[i+1][(j+rem)%13] %= MOD;
			}
		}
		digi = digi * 10 % 13;
	}
	printf("%ld\n", dp[n][5]);
	return 0;
}


Measured memory_bytes: 10624
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define pp pair<int,int>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ld long double
#define al(a) (a).begin(),(a).end()
#define mk make_pair
#define check cout<<"?"<<endl;

ll MOD=1000000007;
ll mod=998244353;
int inf=1000001000;
ll INF=1e18+5;

int main() {
    int n,m,ans=0,l,r; cin>>n>>m;
    vector<pp> k(m);
    rep(i,m){
        int a,b; cin>>a>>b;
        a--; b--;
        k[i]=mk(b,a);
    }
    sort(al(k));
    int pos=-1;
    rep(i,m){
        tie(r,l)=k[i];
        if(pos<=l){
            ans++; pos=r;
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
#define all(a)  (a).begin(),(a).end()
typedef long long ll;
const ll mod=1000000007;
#define repi(i,a,b) for(ll i=ll(a);i<ll(b);++i)
 
int main() {
	int n;cin>>n;
	cout << n/2+n%2 << endl;
  return 0;
}

Measured memory_bytes: 3636
#include <iostream>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <bitset>
using namespace std;
typedef long long ll;
typedef unsigned long long int ull;
#define rep(i,a,n) for(ll i = (a);i < (n);i++)
#define per(i,a,n) for(ll i = (a);i > (n);i--)
#define lep(i,a,n) for(ll i = (a);i <= (n);i++)
#define pel(i,a,n) for(ll i = (a);i >= (n);i--)
#define all(v) (v).begin(),(v).end()
#define clr(a,b) memset((a),(b),sizeof(a))
#define sz size()
#define pb push_back
#define print(x) cout << x << endl

int main(){
  int n;
  int a,b,c=0;
  vector<int> vec;
  cin >> n;
  rep(i,0,n){
    cin >> a;
    vec.pb(a);
  }
  rep(i,0,n){
    if(vec[i] != i+1)continue;
    if(vec[i+1] != i)swap(vec[i],vec[i+1]);
    c++;
  }
  print(c);
  return 0;
}


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

using namespace std;

#define rep(i, n) for(int i = 0; i < n; i++)

int main(){
    string s;
    cin >> s;
    int a[3] = {0, 0, 0};
    rep(i, 3){
        int idx = s[i] - 'a';
        if (a[idx] != 0){
            cout << "No" << endl;
            return 0;
        }
        a[idx]++;
    }
cout << "Yes" << endl;
}

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

int main(){
    int n;
    cin >> n;
    vector<int> p(n),q(n);
    for(int i=0;i<n;i++){
        cin >> p.at(i);
    }
    for(int i=0;i<n;i++){
        cin >> q.at(i);
    }
    vector<int> a(n);
    for(int i=0;i<n;i++){
        a.at(i) = i+1; //1234…の順列
    }

    int A,B;
    int cnt = 0;
    do{
        cnt++;
        if(a==p) A = cnt; 
        if(a==q) B = cnt;
    }while(next_permutation(a.begin(),a.end()));

    cout << abs(A-B) << endl;
}

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

int main() {
  int x, a;
  int num = 0;
  cin >> x >> a;
  if  (x < a) {
    num = 0;
  }
  else {
    num = 10;   
  }
  cout << num << endl;
    return 0;
}

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

#define endl '\n'
#define ll long long
#define rint register int

#define re register
#define pb(x) push_back(x);
#define ce(x) cout << x << '\n';

using db = long double;
using pll = pair < ll, ll >;
#define scan(a, n) 		for(int i = 0; i < n; i++)cin >> a[i];

#define rep(i,x,n,inc) for(i=x ; i<n ; i+=inc)
#define repr(i,x,n,inc) for( i=x ; i>n ; i+=inc)
#define all(a)      (a).begin(),(a).end()
#define unique_sort(x) sort(all(x)), x.resize(distance(x.begin(), unique(all(x))))

#define mp(a,b) make_pair(a,b)
#define ff first
#define ss second
#define hell 1000000007
#define infl LLONG_MAX

#define Foxen(i,s) for (i=s.begin(); i!=s.end(); i++)
#define Fill(s,v) memset(s,v,sizeof(s))
#define cout_p(x, p) cout << fixed << setprecision((p)) << x << endl     //print with precision

#define tc(tt) \
    ll tt;    \
    cin >> tt; \
    for (ll _tt = 0; _tt < tt; _tt++) // testcase 

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

#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif

	ll t, i, x, j, y, sx, sy,	z, k, n;
	string s;
	cin >> x >> sx >> y >> sy >> t;

	if (y > x) {
		x += sx * t;
		y += sy * t;


		if (x >= y) {
			ce("YES")
		}
		else ce("NO");
	} else {
		x -= sx * t;
		y -= sy * t;


		if (x <= y) {
			ce("YES")
		}
		else ce("NO");
	}

}


Measured memory_bytes: 3648