akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Collections.Generic;
using System.Linq;
using BitArray = System.Collections.BitArray;
using BigInteger = System.Numerics.BigInteger;
using TextReader = System.IO.TextReader;

namespace AtCoderProject
{
    public class Program
    {
        public object Calc()
        {
            var D = consoleReader.Int;
            var N = consoleReader.Int;

            var x = 1;
            for (int i = 0; i < D; i++)
                x *= 100;
            return N == 100 ? x * 101 : x * N;
        }

        static uint S(BigInteger n) => (uint)n.ToString().Sum(c => c - '0');


        #region いつもの
        private readonly ConsoleReader consoleReader;
        public Program(ConsoleReader consoleReader) { this.consoleReader = consoleReader; }
        static void Main() => Console.WriteLine(new Program(new ConsoleReader(Console.In)).Calc()); static string AllLines<T>(IEnumerable<T> source) => string.Join("\n", source);
        #endregion
    }

#pragma warning disable
    public class ConsoleReader
    {
        private string[] line = Array.Empty<string>();
        private int linePosition;
        private TextReader textReader;
        public ConsoleReader(TextReader tr) { textReader = tr; }
        public int Int => int.Parse(String);
        public long Long => long.Parse(String);
        public double Double => double.Parse(String);
        public string String
        {
            get
            {
                if (linePosition >= line.Length)
                {
                    linePosition = 0;
                    line = textReader.ReadLine().Split();
                }
                return line[linePosition++];
            }
        }
        public class SplitLine
        {
            private string[] splited;
            public SplitLine(ConsoleReader cr) { splited = cr.textReader.ReadLine().Split(); }
            public int[] Int => String.Select(x => int.Parse(x)).ToArray();
            public long[] Long => String.Select(x => long.Parse(x)).ToArray();
            public double[] Double => String.Select(x => double.Parse(x)).ToArray();
            public string[] String => splited;
        }
        public SplitLine Split => new SplitLine(this);
        public class RepeatReader
        {
            ConsoleReader cr; int count;
            public RepeatReader(ConsoleReader cr, int count) { this.cr = cr; this.count = count; }
            public IEnumerable<T> Select<T>(Func<ConsoleReader, T> func) { for (int i = 0; i < count; i++) yield return func(cr); }
            public IEnumerable<string> String { get { for (int i = 0; i < count; i++) yield return cr.String; } }
            public IEnumerable<int> Int { get { for (int i = 0; i < count; i++) yield return cr.Int; } }
            public IEnumerable<double> Double { get { for (int i = 0; i < count; i++) yield return cr.Double; } }
        }
        public RepeatReader Repeat(int count) => new RepeatReader(this, count);
    }
}

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

#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n - 1; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i <= n; i++)
#define FORR(i, m, n) for(int i = m; i >= n; i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define VSORTR(v) sort(v.rbegin(), v.rend());
#define ALL(v) (v).begin(),(v).end()

using namespace std;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<ll, ll>;

const string YES = "Yes";
const string NO = "No";
const ll mod = 1e9+7;


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

    ll n; cin >>n;
    ll idx = 1;
    ll c=0;
    while(idx<=n){
        c++;
        if (to_string(idx+1).size() % 2!=0){
            
            idx++;

        }
        else{
            idx++;
            idx *= 10;
        }
        // cout << idx << endl;
    }
    cout << c;
    return 0;
    
}



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

#define GO ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define int long long int

const int maxr = 1e5 + 5;


int32_t main()
{
	GO;
	string s, t;
	cin >> s >> t;
	int ans = 0;
	for (int i = 0; i < s.length(); i++) {
		if (s[i] == t[i])
			ans++;
	}
	cout << ans << endl;
	return 0;
}

//!

Measured memory_bytes: 3624
#include<iostream>
#include<stdio.h>
#include<string>
#include<algorithm>
#include<math.h>
#include<vector>
#include<map>
using namespace std;
#define INF 999999999
#define lint long long
#define rep(i, n) for(int i = 1; i <= (int)(n); i++)
int gcd(int a,int b){return b?gcd(b,a%b):a;}

int main(){
    lint N;//, b[101];
    vector<lint> vec;vec.push_back(-1);
    cin >> N;
    rep(i, N){
        lint tmp;
        cin >> tmp;//b[i];
        if(tmp > i){
            cout << -1;
            return 0;
        }
        vec.push_back(tmp);
    }
    vector<lint> ans;
    rep(k, N){
        int out, idx;
        rep(i, vec.size()-1){
            if(vec[i] == i) {
                out = vec[i];
                idx = i;
            }
        }
        //cout << out << endl;
        ans.push_back(out);
        vec.erase(vec.begin() + idx);
    }
    for(int i=ans.size()-1; i>=0; --i) cout << ans[i] << endl;
    return 0;
}

Measured memory_bytes: 256
n = gets.to_i
line = readlines.map(&:chomp)

line.push("AC","WA","TLE","RE")
hash = line.tally 

puts "AC x " + ((hash["AC"]) - 1).to_s
puts "WA x " + ((hash["WA"]) - 1).to_s
puts "TLE x " + ((hash["TLE"]) - 1).to_s
puts "RE x " + ((hash["RE"]) - 1).to_s

Measured memory_bytes: 25196
import java.util.Scanner;

public class Main {

    static class UnionFind {
        // 親の番号.
        private int[] parent;

        public UnionFind(int n) {
            parent = new int[n];
            for (int i = 0; i < n; i++) {
                parent[i] = i;
            }
        }

        // xが属する木の根を再帰で得る.
        private int root(int x) {
            if (parent[x] == x) {
                return x;
            }
            return parent[x] = root(parent[x]);
        }

        // 木を結合.
        private void unite(int x, int y) {
            int rx = root(x);
            int ry = root(y);
            if (rx == ry) {
                return;
            }
            parent[rx] = ry;
        }

        // 2つの木が同じかどうか.
        private boolean same(int x, int y) {
            int rx = root(x);
            int ry = root(y);
            return rx == ry;
        }
    }

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int m = sc.nextInt();
        int[] p = new int[n];
        int[] x = new int[m];
        int[] y = new int[m];
        for (int i = 0; i < n; i++) {
            p[i] = sc.nextInt();
        }
        for (int i = 0; i < m; i++) {
            x[i] = sc.nextInt();
            y[i] = sc.nextInt();
        }

        UnionFind uf = new UnionFind(n);
        for (int i = 0; i < m; i++) {
            uf.unite(x[i] - 1, y[i] - 1);
        }

        int ans = 0;
        for (int i = 0; i < n; i++) {
            if (uf.same(i, p[i] - 1)) {
                ans++;
            }
        }
        System.out.println(ans);
    }

}


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

int main() {
  int N;
  cin >> N;
  vector<int> s(N);
  for (int i = 0; i < N; i++) {
    cin >> s.at(i);
  }
  
  int score = 0;
  sort(s.begin(), s.end());
  reverse(s.begin(), s.end());
  for (int i = 0; i < N; i++) {
    if (i % 2 == 0) {
      score = score + s.at(i);
    } else {
      score = score - s.at(i);
    }
  }
  cout << score << endl;
 }


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<array>
#define nguyendz the_best


#define ll long long
#define ld long double
#define pb push_back
#define all(n) n.begin(),n.end()
#define eb emplace_back
#define endl "\n"
#define pll pair<ll,ll>
#define YES cout <<"YES"<<endl;
#define NO cout <<"NO"<<endl;
#define ff first
#define ss second
#define setpre(x) fixed<<setprecision(x)
//do not use "\n" in interactive problem
// ((x|y)-y) (x&(~y))
// __gcd(fibo(x),fibo(y)=fibo(__gcd(x,y))
//so luong tap hop gom d phan tu khac nhau dc tao tu k so phan biet la k mu d
// a+b=(a^b)+2*(a&b)
using namespace std;
const ll maxn=5e5+100;

const ll maxx=1e13;
const ll mod1=1000000007;
const ll mod2=998244353;
priority_queue<pll,vector<pll>,greater<pll>> q;

ll  a[34]= {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()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    //freopen("test.txt","r",stdin);
   //   freopen("PHONGHAU.INP", "r", stdin);
    //   freopen("PHONGHAU.OUT", "w", stdout);
 ll t;
 cin>> t;
 t-- ;
 cout <<a[t];

}


Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <math.h>
#include <stdio.h>
#include <string>
#include <sstream>
#include <vector>
#include <stack>
#include <set>
#include <map>
#include <cmath>
#include <queue>
#include <deque>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
using namespace std;
typedef long long int ll;
int A[12][12];
int C[12];

int main()
{
	int N,M,X;
	cin>>N>>M>>X;
	rep(i,N){
		cin>>C[i];
		rep(j,M){
			cin>>A[i][j];
		}
	}
	ll ans = 10000000000;
	for(int bit = 0; bit < (1<<N); bit++){
		int learnVec[12];
		ll sum = 0;
		rep(j,M) learnVec[j] = 0; 
		for(int i = 0; i < N; i++){
			if( bit & (1<<i)){
				sum += C[i];
				for(int j = 0; j < M; j++){
					learnVec[j] += A[i][j];
				}	
			}
		}
		bool flag = true;
		rep(j,M){
			if( learnVec[j] < X) flag = false;
		}
		if(flag == true){
			ans = min(ans,sum);
		}
	}
	if( ans != 10000000000){
		cout<<ans<<endl;
	}else{
		cout<<-1<<endl;
	}
	return 0;
}



Measured memory_bytes: 3620
#include <bits/stdc++.h>
#define rep(i, n) for(long long int i = 0; i < n; i++)
#define _rep(i, m, n) for(long long int i = m; i < n; i++)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
//const int N = 1000000;
const ll mod = 1000000007;
using Graph = vector<vector<int>>;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
  
ll gcd(ll A, ll B){
    if(B == 0)return A;
    return gcd(B, A % B);
}
ll lcm(ll A, ll B){
    return A * (B / gcd(A, B));
}
  
/*------------------------------------------------------------------*/
int main(){
    ll n, k; cin >> n >> k;
    cout << k * ll(pow(k - 1, n - 1)) << endl;
}


Measured memory_bytes: 384
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef long double ld;
#define REP(i, a, b) for(ll i = ll(a); i <= ll(b); i++)
int main()
{
	ll n,x;
	cin>>n;
	vector<ll> p,q,a;
	REP(i,0,n-1)
	{
		cin>>x;
		p.push_back(x);
	}
	REP(i,0,n-1)
	{
		cin>>x;
		q.push_back(x);
	}
	REP(i,0,n-1)
		a.push_back(i+1);
	map<vector<ll>,ll> mp;
	do
	{
		mp[a]=mp.size();
	}
	while(next_permutation(a.begin(),a.end()));
	ll ans=abs(mp[p]-mp[q]);
	cout<<ans<<endl;	
}

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

int main(){
    int n,m,A[100][100],b[100],c[100];
    cin >> n >> m ;
    for(int i=0;i<n;i++)
        for(int j=0;j<m;j++)cin >> A[i][j] ;
    for(int i=0;i<m;i++)cin >> b[i];
    
    for (int i=0;i<n;i++){
        c[i]=0;
        for(int j=0;j<m;j++){
            c[i] += A[i][j]*b[j];
        }
    
    }
    
    for(int i=0;i<n;i++)cout << c[i] << endl;
    return 0;
}


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

inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> P;
typedef long long ll;

#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define SORT(c) sort((c).begin(),(c).end())
#define REVERSE(c) reverse((c).begin(),(c).end())

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define RFOR(i,a,b) for(int i=(a)-1;i>=(b);--i)
#define RREP(i,n) RFOR(i,n,0)

const double EPS = 1e-10;
const double PI  = acos(-1.0);
const int INT_INF = 2147483647;
const long long LL_INF = 1LL<<60;
const long long MOD = 1000000007;

#define CLR(a) memset((a), 0 ,sizeof(a))

#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

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

struct mint {
    long long x;
    mint(long long x=0):x((x%MOD+MOD)%MOD){}
    mint operator-() const { return mint(-x);}
    mint& operator+=(const mint a) {
        if ((x += a.x) >= MOD) x -= MOD;
        return *this;
    }
    mint& operator-=(const mint a) {
        if ((x += MOD-a.x) >= MOD) x -= MOD;
    	return *this;
    }
    mint& operator*=(const mint a) {
    	(x *= a.x) %= MOD;
    	return *this;
    }
    mint operator+(const mint a) const {
        mint res(*this);
        return res+=a;
    }
    mint operator-(const mint a) const {
        mint res(*this);
        return res-=a;
    }
    mint operator*(const mint a) const {
        mint res(*this);
        return res*=a;
    }
    mint pow(long long t) const {
        if (!t) return 1;
        mint a = pow(t>>1);
        a *= a;
    	if (t&1) a *= *this;
        return a;
    }
    // for prime MOD
    mint inv() const {
        return pow(MOD-2);
    }
    mint& operator/=(const mint a) {
    	return (*this) *= a.inv();
    }
    mint operator/(const mint a) const {
        mint res(*this);
        return res/=a;
    }
};

int main(void){
    ll N; cin >> N;
    vector<ll> A(N); REP(i,N) cin >> A[i];
    vector<vector<ll>> x(N+1);
    x[0] = vector<ll>{0,0,0};
    REP(i,N){
        vector<ll> v(3);
        v[0] = A[i]+1;
        if(x[i][0] == A[i]){
            v[1] = x[i][1];
            v[2] = x[i][2];
        }
        else if(x[i][1] == A[i]){
            v[1] = x[i][0];
            v[2] = x[i][2];
        }
        else{
            v[1] = x[i][0];
            v[2] = x[i][1];
        }
        SORT(v); REVERSE(v);
        x[i+1] = v;
    }

    vector<ll> T(N);
    REP(i,N){
        ll cnt = 0;
        REP(j,3) if(A[i] == x[i][j]) cnt++;
        T[i] = cnt;
    }

    mint ans(1);
    REP(i,N) ans *= T[i];
    
    cout << ans.x << endl;
    return 0;
}

Measured memory_bytes: 7296
import std.stdio, std.string, std.conv;
import std.range, std.algorithm, std.array, std.typecons, std.container;
import std.math, std.numeric, core.bitop;


void main() {
    int n;
    scan(n);

    int[] a = [3, 5, 7];
    long[] nagosan;

    void dfs(int d, int i, long x, int set) {
        if (i == d) {
            if ((set & 1) == 0 || (set & 2) == 0 || (set & 4) == 0) {
                return;
            }
            nagosan ~= x;
            return;
        }
        dfs(d, i + 1, x*10 + 3, set | 1);
        dfs(d, i + 1, x*10 + 5, set | 2);
        dfs(d, i + 1, x*10 + 7, set | 4);
    }

    foreach (d ; 3 .. 10) {
        dfs(d, 0, 0, 0);
    }

    auto ns = nagosan.sort();

    debug {
        writeln(ns);
    }

    int ans = ns.lowerBound(n + 1).length.to!int;

    writeln(ans);
}


























void scan(T...)(ref T args) {
    import std.stdio : readln;
    import std.algorithm : splitter;
    import std.conv : to;
    import std.range.primitives;

    auto line = readln().splitter();
    foreach (ref arg; args) {
        arg = line.front.to!(typeof(arg));
        line.popFront();
    }
    assert(line.empty);
}


void fillAll(R, T)(ref R arr, T value) {
    static if (is(typeof(arr[] = value))) {
        arr[] = value;
    }
    else {
        foreach (ref e; arr) {
            fillAll(e, value);
        }
    }
}

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

int main(){
    int n;
    cin >> n;
    vector<long long> a(n);
    long long ans = 1;
    
    for(int i = 0;i < n;i++){
        cin >> a[i];
        if(a[i] == 0){
            cout << 0 << endl;
            return 0;
        }
    }
    sort(a.begin(),a.end());
    for(int i = 0;i < n;i++){
        if(a[i] > 1000000000000000000 / ans){
            cout << -1 << endl;
            return 0;
        }
        ans *= a[i];
    }
    cout << ans << endl;
}


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

int main(){
  int a,b;
  cin>>a>>b;
  int c=a+b;
  if(c%2!=0){
    cout <<"IMPOSSIBLE"<<endl;
  }
  else{
    cout <<c/2<<endl;
  }
}

Measured memory_bytes: 256
#include<cstdio>
#include<cmath>
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
    string S;
    cin>>S;
    if(S=="SUN")puts("7");
    else if(S=="MON")puts("6");
    else if(S=="TUE")puts("5");
    else if(S=="WED")puts("4");
    else if(S=="THU")puts("3");
    else if(S=="FRI")puts("2");
    else puts("1");
    return 0;
}


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

char s[1024];
bool w[1024];

int main(){
	scanf("%s",s);
	for(int i=0;s[i];++i)w[s[i]]=true;
	if((w['N']^w['S'])||w['E']^w['W'])puts("No");
	else puts("Yes");
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <queue>
using namespace std;

vector<string> ans;
queue<string> q;

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	int k;
	cin >> k;
	if( k <= 9 ) 
	{
		cout << k << '\n';
		return 0;
	} 
	k -= 9;
	for (int i = 1; i <= 9; i++)
	{
		char t = i + '0';
		string a;
		a += t;
		q.push(a); 
	}
	while( k )
	{
		string x = q.front();
		q.pop();
		char t = x[x.length()-1];
		for (int i = -1; i <= 1; i++)
		{
			char z = t + i;
			if( z >= '0' && z <= '9' )
			{
				q.push(x+z);
				k --;
				if( k == 0 )
				{
					cout << x+z << '\n';
					return 0; 
				} 
			}
		}
	}
	return 0;
}


Measured memory_bytes: 4864
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		sc.close();

		if (a <= 0) {
			if (0 <= b) {
				System.out.println("Zero");
			} else {
				int c = b - a;
				if (c % 2 == 0) {
					System.out.println("Negative");
				} else {
					System.out.println("Positive");
				}
			}
		} else {
			System.out.println("Positive");
		}
	}
}


Measured memory_bytes: 21844
#pragma region template 2.4
#include <bits/stdc++.h>
using namespace std;
template <typename T>
using pq_asc = priority_queue<T, vector<T>, greater<T>>;
typedef long long ll;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef pair<ll, ll> ii;
typedef vector<ii> vii;
typedef vector<string> vs;
#define REP(i, n) for (ll i = 0; i < (n); ++i)
#define REP1(i, n) for (ll i = 1; i <= (n); ++i)
#define FOR(i, a) for (auto &i : a)
#define CH(f, x, y) x = f(x, y)
#define IN(T, x) \
    T x;         \
    cin >> x;
#define AIN(T, a, n) \
    vector<T> a(n);  \
    FOR(i, a)        \
    cin >> i;
#define A2IN(T1, a, T2, b, n) \
    vector<T1> a(n);          \
    vector<T2> b(n);          \
    REP(i, n)                 \
    cin >> a[i] >> b[i];
#define OUT(x) cout << (x) << endl;
#define FOUT(x) cout << fixed << setprecision(15) << (x) << endl;
#define ALL(a) (a).begin(), (a).end()
#define SORT(a) sort(ALL(a))
#define RSORT(a) \
    SORT(a);     \
    reverse(ALL(a))
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define DUMPA(a)          \
    cout << #a << " = {"; \
    JOUT(ALL(a), ", ", cout) << "}" << endl;

template <typename T>
ostream &JOUT(T s, T e, string sep = " ", ostream &os = cout)
{
    if (s != e)
    {
        os << *s;
        ++s;
    }
    while (s != e)
    {
        os << sep << *s;
        ++s;
    }
    return os;
}

ostream &YES(bool cond, string yes = "Yes", string no = "No", ostream &os = cout)
{
    if (cond)
    {
        os << yes << endl;
    }
    else
    {
        os << no << endl;
    }
    return os;
}

template <typename T1, typename T2>
ostream &operator<<(ostream &os, const pair<T1, T2> &p)
{
    os << '(' << p.first << ", " << p.second << ')';
    return os;
}

template <typename T>
ostream &operator<<(ostream &os, const vector<T> &v)
{
    os << '[';
    JOUT(ALL(v), ", ", os) << ']';
    return os;
}

const ll INF = 1e18;
const ll MOD = 1e9 + 7;
#pragma endregion template

int main()
{
    IN(ll, N);
    IN(ll, K);
    AIN(ll, p, N);
    double s = 0;
    REP(i, K)
    {
        s += (1 + p[i]) / 2.0;
    }
    double ans = s;
    for (ll i = K; i < N; ++i)
    {
        s += (1 + p[i]) / 2.0 - (1 + p[i - K]) / 2.0;
        CH(max, ans, s);
    }
    FOUT(ans);
}

Measured memory_bytes: 4844
N = int(input())
p = list(map(int, input().split()))

a=0
for i in range(N-2):
    if((p[i]<p[i+1] and p[i+1]<p[i+2]) or (p[i]>p[i+1] and p[i+1]>p[i+2])):
        a=a+1
print(a)

Measured memory_bytes: 3060
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();

        sc.close();

        if (a * b % 2 == 0) {
            System.out.println("No");
        } else {
            System.out.println("Yes");
        }
    }
}

Measured memory_bytes: 22228
#include<bits/stdc++.h>
using namespace std;
int main(){
	long long N,K,Ans=1;
	cin>>N>>K;
	if(N==1){
		cout<<K<<endl;
		return 0;
	}
	for(int i=2;i<=sqrt(K);i++){
		int Cnt=0;
		long long Tmp=i;
		while(K%Tmp==0){
			Cnt++;
			K/=Tmp;
		}
		Cnt/=N;
		for(int j=0;j<Cnt;j++)
			Ans*=Tmp; 
	}
	cout<<Ans<<endl;
	return 0;
}

Measured memory_bytes: 256
inpt = map(int, raw_input().split())

for i in range(inpt[0], inpt[0]+inpt[2]):
	if i > inpt[1]: break
	print i
for i in range(inpt[1]-inpt[2]+1, inpt[1]+1):
	if i >= inpt[0]+inpt[2]:
		print i


Measured memory_bytes: 2568
def solve():
    N,Y=map(int,input().split())
    for x in range(N+1):
        for y in range(N-x+1):
            z = N - x - y
            if Y == x * 10000 + y * 5000 + z * 1000:
                return [x,y,z]
    return [-1,-1,-1]

print(' '.join(map(str,solve())))


Measured memory_bytes: 39152
#include <cstdio>
#include <algorithm>
#include <complex>

using namespace std;

typedef long double ldb;
typedef complex<ldb> P;
struct L {
  P a,b;
  L(){}
  L(P a,P b):a(a),b(b){}
  ldb len(){return abs(a-b);}
  P vec(){return b-a;}
};

const ldb eps = 1e-8;
const ldb pi = acos(-1);
int sig(ldb a) {return (a<-eps)?-1:(a>eps)?1:0;}
bool eq(ldb a,ldb b){return abs(a-b)<eps;}
ldb dot(P a, P b) {
  return (a.real() * b.real() + a.imag() * b.imag());
}
ldb cross(P a, P b) {
  return (a.real() * b.imag() - a.imag() * b.real());
}
enum CCW{FRONT = 1, RIGHT = 2, BACK = 4, LEFT = 8, ON = 16};
int ccw(L s, P p) {
  P a = s.vec();
  p -= s.a;
  ldb cr = cross(a, p);
  if (eq(cr, 0)) {
    if (sig(dot(a, p)) < 0) return BACK;
    if (sig(norm(a) - norm(p)) < 0) return FRONT;
    return ON;
  }
  return (cr > 0) ? LEFT : RIGHT;
}

int main(void)
{
  ldb x,y;
  P a,b;
  L l;
  scanf("%Lf%Lf",&x,&y); a = P(x,y);
  scanf("%Lf%Lf",&x,&y); b = P(x,y);
  l = L(a,b);
  int q; scanf("%d",&q);
  for( int i = 0; i < q; i++ ) {
    scanf("%Lf%Lf",&x,&y);
    int c = ccw(l,P(x,y));
    if( c == LEFT ) {
      puts("COUNTER_CLOCKWISE");
    }
    if( c == RIGHT ) {
      puts("CLOCKWISE");
    }
    if( c == ON ) {
      puts("ON_SEGMENT");
    }
    if( c == FRONT ) {
      puts("ONLINE_FRONT");
    }
    if( c == BACK ) {
      puts("ONLINE_BACK");
    }
  }
  return 0;
}

Measured memory_bytes: 1068
n,k = map(int,input().split())
a = list(map(int,input().split()))
dict = {}
sum = 0

for i in a:
  if i not in dict:
    dict[i] = 1
  else:
    dict[i] += 1

kind = len(dict)-k
if kind <=0:
  print(0)
  exit()

dic= sorted(dict.items(), key=lambda x:x[1])

for i in range(kind):
  sum += dic[i][1]
  
print(sum)

Measured memory_bytes: 39932
#include <iostream>
#include <tuple>
#include <queue>
#include <map>

using Point = std::tuple<int, int, int>;
using roll_func = Point (*)(const Point &p, int N);

constexpr int INF   = (1 << 29);
constexpr int LIMIT = 10;

Point roll_x(const Point &p, int N)
{
    int x, y, z;
    std::tie(x, y, z) = p;
    return Point{N - y - 1, x, z};
}

Point roll_y(const Point &p, int N)
{
    int x, y, z;
    std::tie(x, y, z) = p;
    return Point{x, N - z - 1, y};
}

Point roll_z(const Point &p, int N)
{
    int x, y, z;
    std::tie(x, y, z) = p;
    return Point{N - z - 1, y, x};
}

Point roll_n(const Point &p, int n, int N, roll_func func)
{
    Point ret = p;
    for (int i = 0; i < n; i++) {
        ret = func(ret, N);
    }
    return ret;
}

Point operator + (const Point &a, const Point &b)
{
    int ax, ay, az, bx, by, bz;

    std::tie(ax, ay, az) = a;
    std::tie(bx, by, bz) = b;

    return Point{ax + bx, ay + by, az + bz};
}

int manhattan_distance(const Point &a, const Point &b)
{
    int ax, ay, az, bx, by, bz;

    std::tie(ax, ay, az) = a;
    std::tie(bx, by, bz) = b;

    return abs(ax - bx) + abs(ay - by) + abs(az - bz);
}

int bfs(int N, const Point &s, const Point &t)
{
    std::queue<Point> Q;
    Q.push(s);

    std::map<Point, int> min_times;
    min_times[s] = 0;

    int ret = INF;
    
    while (!Q.empty()) {
        Point curr = Q.front(); Q.pop();
        int curr_time = min_times[curr];

        ret = std::min(ret, curr_time + manhattan_distance(curr, t));
        
        if (curr_time == LIMIT) {
            continue;
        }

        constexpr Point dp[] = {Point{1, 0, 0}, Point{0, 1, 0}, Point{0, 0, 1}};
        for (int i = 0; i < 3; i++) {
            Point np = curr + dp[i];
            if (min_times.count(np) == 0) {
                min_times[np] = curr_time + 1;
                Q.push(np);
            }
        }
        
        for (int n : {1, 3}) {
            auto get = [](const Point &p, int k) -> int {
                switch (k) {
                    case 0: return std::get<0>(p);
                    case 1: return std::get<1>(p);
                    case 2: return std::get<2>(p);
                }
            };

            int coord = 2;
            for (roll_func func : {roll_x, roll_y, roll_z}) {                
                if (get(curr, coord) !=  get(t, coord)) {
                    Point np = roll_n(curr, n, N, func);
                    if (min_times.count(np) == 0) {
                        min_times[np] = curr_time + 1;
                        Q.push(np);
                    }
                }

                coord = (coord + 1) % 3;
            }
        }
    }

    return ret;
}

int main()
{
    int N;
    int sx, sy, sz, tx, ty, tz;

    std::cin >> N >> sx >> sy >> sz >> tx >> ty >> tz;

    Point s{sx, sy, sz}, t{tx, ty, tz};    
    std::cout << bfs(N, s, t) << std::endl;
    
    return 0;
}

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

const int P=1e9+7;
const int N=305;

int n,m;
vector< pair<int,int> >a[N];

long long f[N][N][N];

int check(int i,int j,int k)
{
	int r=max(i,max(j,k));
	int len=a[r].size();
	for(int ii=0;ii<len;ii++)
	{
		int l=a[r][ii].first;
		int res=0;
		if(i>=l) res++;
		if(j>=l) res++;
		if(k>=l) res++;
		if(res!=a[r][ii].second) return 0;
	}
	return 1;
}

void Mod(long long &x)
{
	if(x>=P) x-=P;
}


int main()
{
	scanf("%d%d",&n,&m);
	for(int i=1;i<=m;i++)
	{
		int l,r,x;
		scanf("%d%d%d",&l,&r,&x);
		if(l>r) swap(l,r);
		a[r].push_back(make_pair(l,x));
	}
	f[0][0][0]=1;
	long long Ans=0;
	for(int i=0;i<=n;i++)
		for(int j=0;j<=n;j++)
			for(int k=0;k<=n;k++)
			{
				if(!f[i][j][k]) continue;
				if(!check(i,j,k)) continue;
				int r=max(i,max(j,k))+1;
				if(r==n+1)
				{
					Ans+=f[i][j][k];
					Mod(Ans);
					continue;
				}
				f[r][j][k]+=f[i][j][k],Mod(f[r][j][k]);
				f[i][r][k]+=f[i][j][k],Mod(f[i][r][k]);
				f[i][j][r]+=f[i][j][k],Mod(f[i][j][r]);
			}
	cout<<Ans<<endl;
	return 0;
}
				
				

Measured memory_bytes: 219392
#include<bits/stdc++.h>
using namespace std;
typedef pair<int, int> pii;
#define INF (1 << 30)
#define INFL (1ll << 60ll);
#define pb push_back
#define mk make_pair
typedef long long ll;

int N, pos[2020][2];
int bit[4040];
int dp[2020][2020];

int sum(int i)
{
    int s = 0;
    while(i > 0){
        s += bit[i];
        i -= i & -i;
    }
    return s;
}

void add(int i, int x)
{
    while(i <= 2 * N){
        bit[i] += x;
        i += i & -i;
    }
}

int dfs(int w, int b)
{
    if(~dp[w][b])return dp[w][b];
    if(w == N && b == N){
        return dp[w][b] = 0;
    }
    int ret = INF;
    if(w < N){
        int id = pos[w + 1][0];
        add(id, 1);
        int cost = id - sum(id);
        int res = dfs(w + 1, b) + cost;
        add(id, -1);
        ret = min(ret, res);
    }
    if(b < N){
        int id = pos[b + 1][1];
        add(id, 1);
        int cost = id - sum(id);
        int res = dfs(w, b + 1) + cost;
        add(id, -1);
        ret = min(ret, res);
    }
    return dp[w][b] = ret;
}

signed main()
{
    cin >> N;
    for(int i = 0; i < 2 * N; i++){
        int a;
        char b;
        cin >> b >> a;
        if(b == 'W'){
            pos[a][0] = i + 1;
        }
        else {
            pos[a][1] = i + 1;
        }
    }
    memset(dp, -1, sizeof(dp));
    cout << dfs(0, 0) << endl;


    return 0;
}


Measured memory_bytes: 16384
import java.util.Scanner

fun main(args: Array<String>) {
    val sc = Scanner(System.`in`)
    val a = sc.nextInt()
    val b = sc.nextInt()
    val c = sc.nextInt()
    val d = sc.nextInt()
    val e = sc.nextInt()
    val cookings = listOf(e, d, c, b, a).sortedDescending()
    val result = cooking(cookings, 0)
    println(result)
}


private fun cooking(list: List<Int>, time: Int): Int {
    val cook = list.maxBy {
        val a = (it % 10)
        return@maxBy if (a == 0) {
            10
        } else a
    }?: return time
    val (list1, list2) = list.partition { it == cook }
    val newList = choiceList(list1, list2)
    if (newList.isEmpty()) {
        return time + cook
    } else {
        val calc = if (cook % 10 == 0) 0 else 10 - (cook % 10)
        return cooking(newList, time + cook + calc)
    }
}

private fun choiceList(list1: List<Int>, list2: List<Int>): List<Int> {
    return if (list2.isEmpty()) {
        list1.take(list1.size - 1)
    } else {
        list2
    }
}

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

const int MAX = 510000;
const int MOD = 1000000007;

long long int fac[MAX], finv[MAX], inv[MAX];

void comInit(){
  fac[0] = fac[1] = 1;
  finv[0] = finv[1] = 1;
  inv[1] = 1;
  for(int i=2; i<MAX; i++){
    fac[i] = fac[i-1] * i % MOD;
    inv[i] = MOD - inv[MOD%i] * (MOD/i) % MOD;
    finv[i] = finv[i-1] * inv[i] % MOD;
  }
}

int main(){
  int h, w, a, b;
  cin >> h >> w >> a >> b;
  comInit();
  long long int ans=0;
  for(int i=b; i<w; i++){
    long long int ai=(fac[h-a-1+i] * finv[i]) % MOD;
    ai *= finv[h-a-1];
    ai %= MOD;
    ai *= fac[a+w-2-i];
    ai %= MOD;
    ai *= finv[a-1];
    ai %= MOD;
    ai *= finv[w-1-i];
    ai %= MOD;
    ans += ai;
    ans %= MOD;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 12160
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int n, t, a;
    cin >> n >> t >> a;
    vector<int> h(n);
    for(int i = 0; i < n; i++)
    {
        cin >> h[i];
    }

    double ans = 1000;
    int num = 0;
    for(int i = 0; i < n; i++)
    {
        if (ans > abs(a - (t - 0.006 * h[i])) ) 
        {
          ans = abs(a - (t - 0.006 * h[i]));
          num = i;
        }
    }
    cout << num + 1 << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cstring>

using namespace std;

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

	long long K, A, B;
	while (cin >> K >> A >> B) {
		if (B - A <= 2) {
			cout << K+1 << '\n';
			continue;
		}

		K += (B-A-2) * ((K - A + 1) / 2);

		cout << K+1 << '\n';
	}
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rrep(i, n) for (int i = (int)(n - 1); i >= 0; i--)
#define all(x) (x).begin(), (x).end()
#define sz(x) int(x.size())
#define get_unique(x) x.erase(unique(all(x)), x.end());
typedef long long ll;
typedef complex<double> Complex;
const int INF = 1e9;
const ll MOD = 1e9 + 7;
const ll LINF = 1e18;
template <class T>
bool chmax(T& a, const T& b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T& a, const T& b) {
    if (b < a) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
vector<T> make_vec(size_t a) {
    return vector<T>(a);
}
template <class T, class... Ts>
auto make_vec(size_t a, Ts... ts) {
    return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}

int n;
vector<int> w;
auto memo0 = make_vec<int>(330, 330);
int dp0(int l, int r) {
    if (memo0[l][r] != -1) return memo0[l][r];
    if (l + 1 == r) return memo0[l][r] = abs(w[l] - w[r]) <= 1;
    if (l + 1 < r - 1 && dp0(l + 1, r - 1) && abs(w[l] - w[r]) <= 1)
        return memo0[l][r] = 1;
    int ret = 0;
    for (int m = l + 1; m + 1 < r; m++) {
        ret |= (dp0(l, m) && dp0(m + 1, r));
    }
    return memo0[l][r] = ret;
}

auto memo1 = make_vec<int>(330, 330);
int dp1(int l, int r) {
    if (memo1[l][r] != -1) return memo1[l][r];
    if (dp0(l, r)) return memo1[l][r] = r - l + 1;
    int ret = 0;
    for (int m = l; m < r; m++) {
        chmax(ret, dp1(l, m) + dp1(m + 1, r));
    }
    return memo1[l][r] = ret;
}
int main() {
    while (1) {
        cin >> n;
        if (n == 0) break;
        w.resize(n);
        rep(i, n) cin >> w[i];
        rep(i, 330) rep(j, 330) memo0[i][j] = memo1[i][j] = -1;
        // rep(r, n) rep(l, r) cout << l << " " << r << " " << dp1(l, r) <<
        // endl;
        cout << dp1(0, n - 1) << endl;
    }
}


Measured memory_bytes: 3612
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll h[100005];
ll n, a, b;
bool valid (ll k) {
  ll temp = 0;
   for (int i = 0; i < n; i++) {
     if (b * k < h[i]) {
        temp += (h[i] - k * b + a - b - 1) / (a - b);
     }
  }
  return temp <= k;
}
int main() {
  cin >> n >> a >> b;
  for (int i = 0; i < n; i++) {
    cin >> h[i];
  }
  ll lo = 0, hi = 1e9;
  ll mid;
  while (lo < hi - 1) {
     mid = (lo + hi) / 2;
     if (valid(mid)) {
        hi = mid;
     } else {
       lo = mid;
     }
  }
  cout << hi << endl;
  //cout << lo << " " << mid << " " << hi << endl;
  return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#include<math.h>
#define rep(i,n) for (int i = 0; i < (n) ; ++i)
using namespace std;
using ll = long long ;
using P = pair<int, int> ;
#define PI 3.14159265358979323846264338327950


int main () {
    int a, b;
    cin >> a >> b;
    if (a > 9 || b > 9){
        cout << -1 << endl;
    }
    else {
        cout << a * b << endl;
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <unordered_map>
typedef long long ll;
#define rep(i,m,n) for(ll i = (m); i < (n); i++)
#define rrep(i,m,n) for(ll i = (m); i >= (n); i--)
#define print(x) cout << (x) << endl;
#define print2(x,y) cout << (x) << " " << (y) << endl;
#define printa(x,n) for(ll i = 0; i < n; i++){ cout << (x[i]) << " \n"[i == n-1];}
#define printp(x,n) for(ll i = 0; i < n; i++){ cout << "(" << x[i].first << ", " << x[i].second << ") "; } cout << endl;
#define INF (1e18)
using namespace std;
const ll MOD = 1e9 + 7;
typedef pair<ll, ll> lpair;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    char c;
    cin >> c;
    set<char> s;
    s.insert('a');
    s.insert('i');
    s.insert('u');
    s.insert('e');
    s.insert('o');
    if(s.find(c) != s.end()){
        print("vowel");
    }else{
        print("consonant");
    }

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
const ll MOD = 1000000007;
const ld PI = acos(-1);  
const ld EPS = 0.0000000001;
#define REP(i, n) for(ll i=0; i<(ll)(n); i++)
#define REPD(i, n) for(ll i=n-1; 0<=i; i--)
#define FOR(i, a, b) for(ll i=a; i<(ll)(b); i++)
#define FORD(i, a, b) for(ll i=a; (ll)(b)<=i; i--)
#define ALL(x) x.begin(), x.end()
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))


int main(){
    string s;   cin >> s;
    int k;  cin >> k;
    vector<vector<ll>> state(26);
    REP(i, s.size()){
        state[s[i]-'a'].push_back(i);
    }
    map<string, int> mp;
    REP(i, 26){
        for(auto x: state[i])
            REP(j, min((int)s.size(), k)) mp[s.substr(x,j+1)] += 1;
        
        //if(k<=mp.size()) break;
    }
    int cnt=0;
    for(auto x: mp){
        cnt += 1;
        if(cnt<k) continue;
        cout << x.first << endl; return 0;
    }
}

Measured memory_bytes: 1920
#include <iostream>
#include <vector>
#include <map>
#include <cmath>
#include <algorithm>
#include <unordered_map>
#include <set>

#define ll long long
#define ull unsigned long long
#define eps 10e-10
#define MOD 1000000007

using namespace std;

struct Object
{
	ll w;
	ll v;
	bool operator < (const Object& x) const {
		if(w == x.w){
			return v > x.v;
		}
		return w < x.w;
	}
};

class SimpleKnapsack
{
private:
	ll n;
	ll max_w;
	vector<Object> objs;
	unordered_map<ll, vector<ll> > w_imos;
	ll min_w;

public:
	SimpleKnapsack(){
		cin >> n >> max_w;
		for (int i = 0; i < n; ++i)
		{
			Object tmp;
			cin >> tmp.w >> tmp.v;
			objs.push_back(tmp);

		}
		min_w = objs[0].w;
		sort(objs.begin(), objs.end());
	}
	void exec(){
		for (int i = 0; i < n; ++i)
		{
			w_imos[objs[i].w].push_back(objs[i].v);
 		}

 		for (auto itr = w_imos.begin(); itr != w_imos.end(); ++itr)
 		{
 			vector<ll> arr = itr->second;
 			for (int i = 1; i < arr.size(); ++i)
 			{
 				 arr[i] += arr[i-1]; 
 			}
 			for (int i = arr.size(); i <= n; ++i)
 			{
 				 arr.push_back(0); 
 			}
 			arr.insert(arr.begin(), 0);
 			itr->second = arr;
 		}

 		ll ans = 0;

 		int size_i = w_imos.find(min_w) == w_imos.end() ? 0 : w_imos[min_w].size(); 
		int size_j = w_imos.find(min_w + 1) == w_imos.end() ? 0 : w_imos[min_w + 1].size();
		int size_k = w_imos.find(min_w + 2) == w_imos.end() ? 0 : w_imos[min_w + 2].size();
		int size_l = w_imos.find(min_w + 3) == w_imos.end() ? 0 : w_imos[min_w + 3].size();

 		for (int i = 0; i <= size_i; ++i)
 		{
 			for (int j = 0; j <= size_j; ++j)
 			{
 				for (int k = 0; k <= size_k; ++k)
 				{
 					for (int l = 0; l <= size_l; ++l)
 					{
 						if(min_w * i + (min_w + 1) * j + (min_w + 2) * k + (min_w + 3) * l  <= max_w){
 							ll val_i = w_imos.find(min_w) == w_imos.end() ? 0 : w_imos[min_w][i]; 
 							ll val_j = w_imos.find(min_w + 1) == w_imos.end() ? 0 : w_imos[min_w + 1][j];
 							ll val_w = w_imos.find(min_w + 2) == w_imos.end() ? 0 : w_imos[min_w + 2][k];
 							ll val_l = w_imos.find(min_w + 3) == w_imos.end() ? 0 : w_imos[min_w + 3][l];
 							ans = max(ans, val_i + val_j + val_w + val_l);
 						}
 					}
 				}
 			}
 		}
 		cout << ans << endl;
	}
};

int main(){
	SimpleKnapsack sk = SimpleKnapsack();
	sk.exec();
}

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

const long int M = 1000000000000000000;

int keta(long int m) {
    int cnt = 0;
    while(m > 0) {
        m /= 10;
        cnt++;
    }
    
    return cnt;
}

int main() {
    int n;
    cin >> n;
    
    vector<long int> a(n);
    rep(i,n) {
        cin >> a[i];
    }
    
    sort(a.begin(), a.end());
    
    long int ans = a[0];
    for(int i = 1; i < n; i++) {
        if(keta(ans)+keta(a[i]) <= 20 && (ans/2) * (a[i]/2) <= M/4 && ans*a[i] <= M)
            ans *= a[i];
        else {
            ans = -1;
            break;
        }
    }
    
    cout << ans << endl;
    
    return 0;
}


Measured memory_bytes: 4052
import java.util.*;
import java.util.function.*;
import java.math.*;
public class Main {
    public static void main(String[] args){
				Scanner s = new Scanner(System.in);
		int N = s.nextInt();
		int[] H = new int[N];
		for(int i = 0; i < N; i++) {
			H[i] = s.nextInt();
		}
		
		int[] result = new int[N+1];
		result[0] = 0;
		result[1] = Math.abs(H[1] - H[0]);
		for(int i = 2; i < N; i++) {
			result[i] = Math.min(result[i - 1] + Math.abs(H[i] - H[i - 1]), result[i - 2] + Math.abs(H[i] - H[i - 2]));
		}
		System.out.println(result[N-1]);
    }
}

Measured memory_bytes: 51264
/*
                       _oo0oo_
                      o8888888o
                      88" . "88
                      (| -_- |)
                      0\  =  /0
                    ___/`---'\___
                  .' \\|     |// '.
                 / \\|||  :  |||// \
                / _||||| -:- |||||- \
               |   | \\\  -  /// |   |
               | \_|  ''\---/''  |_/ |
               \  .-\__  '-'  ___/-. /
             ___'. .'  /--.--\  `. .'___
          ."" '<  `.___\_<|>_/___.' >' "".
         | | :  `- \`.;`\ _ /`;.`/ - ` : | |
         \  \ `_.   \_ __\ /__ _/   .-` /  /
     =====`-.____`.___ \_____/___.-`___.-'=====
                       `=---='
 
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 
Hemant Malviya

//It’s just pathetic to give up on something before you even give it a shot.
//Knowing you’re different is only the beginning. If you accept these differences 
you’ll be able to get past them and grow even closer.
//You can die anytime, but living takes true courage.
//Every journey begins with a single step. We just have to have patience.
//Life is not a game of luck. If you wanna win, work hard.
//It’s more important to master the cards you’re holding 
than to complain about the ones your opponent was dealt.
//If you just submit yourself to fate, then that’s the end of it.
//Whatever you do, enjoy it to the fullest. That is the secret of life.
//I too will obtain everything that I desire. Not because someone asked me to do it, 
//but because I know in my heart that I have something worth fighting for.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/   
#include<bits/stdc++.h>
 
#define lld long long int 
#define vint vector<int>
#define vlld vector<long long int>
#define vst vector<string>
#define ps push_back
#define pii pair<int,int>
#define mk make_pair
#define le length
#define in insert
#define PI 3.1415926535897932384626433832795
#define MOD 1000000007
#define sv()                  int t; scanf("%d",&t); while(t--)
#define FAST ios_base::sync_with_stdio(false),cin.tie(NULL)
using namespace std;
 
int main()
{
   int a,b,c,d;
   cin>>a>>b>>c>>d;
   bool f= true;
   while(a>=0 && c>=0){
     c -=b;
     if(c <=0){
       f = true;
       break;
     }
     a -= d;
     if(a <=0){
       f = false;
       break;
     }

   }
   if(f)cout<<"Yes";
   else cout<<"No";
 return 0;   
}

Measured memory_bytes: 3592
# https://atcoder.jp/contests/abc145/tasks/abc145_c

from itertools import permutations

n=int(input())
xy=[list(map(int,input().split())) for _ in range(n)]
P=list(permutations(xy))
cnt=0

def dst(x1,x2,y1,y2):
    return pow(pow(x1-x2,2)+pow(y1-y2,2),0.5)


for p in P:
    for i in range(n-1):
        cnt+=dst(p[i][0],p[i+1][0],p[i][1],p[i+1][1])

print(cnt/len(P))

Measured memory_bytes: 8052
#include<bits/stdc++.h>
#include<iostream>
#include<string>
#include<cmath>
#include<cstdio>
#include<cctype>
#include<cstring>
#include<iomanip>
#include<cstdlib>
#include<ctime>
#include<set>
#include<map>
#include<utility>
#include<queue>
#include<vector>
#include<stack>
#include<sstream>
#include<algorithm>
/************************************************/
#define rep(i,n) for(int i=0;i<n;i++)
#define m_p make_pair
#define pb push_back
#define fr first
#define se second
#define forn(i,a,n) for(int i=a;i<n;i++)
#define foreach(i,c) for(__typeof(c.begin())i=(c.begin());i!=(c).end();i++)
#define pii pair<int,int>
#define vi vector<int>
#define ll long long
#define sz(s) s.size()
#define all(s) s.begin(),s.end()
#define zero(x) memset(x,0,sizeof(x))
#define vii vector<pair<int,int> >
#define mpis map<int,string>
#define mpii map<int,int>
#define mpsi map<string,int>
#define re return
#define mod 1000000007
/************************************************/
using namespace std;

long long get(){
	char c=getchar();
	long long x=0LL;
	while(c<'0'||c>'9')
	c=getchar();
	while(c>='0'&&c<='9'){
		x*=10LL;
		x+=(c-'0');
		c=getchar();
	}
	return x;
}
mpsi mp;
int n;
string s[200001];
vector<string> ans;
int main(){
	ios::sync_with_stdio(0);
	cin>>n;
	rep(i,n){
		cin>>s[i];
		mp[s[i]]++;
	}
	int mx=0;
	foreach(it,mp){
		if(it->second>mx)
		mx=it->second;
	}
	foreach(it,mp){
		if(it->second==mx)
		ans.pb(it->first);
	}
	sort(ans.begin(),ans.end());
	rep(i,ans.size()){
		cout<<ans[i]<<"\n";
	} 
	re 0;
}

Measured memory_bytes: 27120
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		int n = sc.nextInt();
		int c = n % 1000 == 0 ? n / 1000 : n / 1000 + 1;

		System.out.println(1000 * c - n);
	}
}

Measured memory_bytes: 35564
#include <iostream>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <string>
using namespace std;
int main() {
	int W,a,b,ans;
	cin >> W >> a >>b;

	if (a < b) {
		ans = b - a - W;
	}
	else {
		ans = a - b - W;
	}
	if (ans < 0) {
		ans = 0;
	}
	cout  << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <stack>
#include <queue>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <cmath>

using namespace std;
#define PI 3.1415926535897932384626433832795
#define MOD (1000000007)
#define EPS (1e-15)
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repc(i, s, n) for (int i = (s); i <= (n); i++)
#define rrep(i, n) for (int i = (n) - 1; i >= 0; i--)
#define rrepc(i, s, n) for (int i = (s); i >= (n); i--)
#define bet(x, a, b) (a) <= (x) && (x) < (b)
typedef long long ll;
typedef unsigned long long ull;

int main()
{
	int N, A, B, P, cnt[3] = { 0, 0, 0 };

	cin >> N >> A >> B;
	rep(i, N) {
		cin >> P;
		if (P <= A) cnt[0]++;
		else if (P <= B) cnt[1]++;
		else cnt[2]++;
	}

	cout << min(cnt[0], min(cnt[1], cnt[2])) << endl;

	return 0;
}


Measured memory_bytes: 256
import sys


def solve():
    readline = sys.stdin.buffer.readline
    mod = 10 ** 9 + 7
    k, n = list(map(int, readline().split()))
    a = list(map(int, readline().split()))
    a = [a[-1] - k] + a + [k + a[0]]
    mt = 10 ** 10
    for i in range(1, len(a) - 1):
        mt = min(mt, k - abs(a[i] - a[i-1]), k - abs(a[i] - a[i+1]))
    print(mt)


if __name__ == '__main__':
    solve()


Measured memory_bytes: 71152
#include <bits/stdc++.h>
using namespace std;
typedef bool boolean;

const int N = 5e5 + 5;

#define ll long long

void exgcd(int a, int b, int& x, int& y) {
	if (!b) {
		x = 1, y = 0;
	} else {
		exgcd(b, a % b, y, x);
		y -= (a / b) * x;
	}
}

int inv(int a, int n) {
	int x, y;
	exgcd(a, n, x, y);
	return (x < 0) ? (x + n) : (x);
}

const int Mod = 998244353;

template <const int Mod = :: Mod>
class Z {
	public:
		int v;

		Z() : v(0) {	}
		Z(int x) : v(x){	}
		Z(ll x) : v(x % Mod) {	}

		friend Z operator + (const Z& a, const Z& b) {
			int x;
			return Z(((x = a.v + b.v) >= Mod) ? (x - Mod) : (x));
		}
		friend Z operator - (const Z& a, const Z& b) {
			int x;
			return Z(((x = a.v - b.v) < 0) ? (x + Mod) : (x));
		}
		friend Z operator * (const Z& a, const Z& b) {
			return Z(a.v * 1ll * b.v);
		}
		friend Z operator ~(const Z& a) {
			return inv(a.v, Mod);
		}
		friend Z operator - (const Z& a) {
			return Z(0) - a;
		}
		Z& operator += (Z b) {
			return *this = *this + b;
		}
		Z& operator -= (Z b) {
			return *this = *this - b;
		}
		Z& operator *= (Z b) {
			return *this = *this * b;
		}
		friend boolean operator == (const Z& a, const Z& b) {
			return a.v == b.v;
		} 
};

Z<> qpow(Z<> a, int p) {
	Z<> rt = Z<>(1), pa = a;
	for ( ; p; p >>= 1, pa = pa * pa) {
		if (p & 1) {
			rt = rt * pa;
		}
	}
	return rt;
}

typedef Z<> Zi;

int n, m;
Zi fac[N], _fac[N];

void init_fac(int n) {
	fac[0] = 1;
	for (int i = 1; i <= n; i++) {
		fac[i] = fac[i - 1] * i;
	}
	_fac[n] = ~fac[n];
	for (int i = n; i; i--) {
		_fac[i - 1] = _fac[i] * i; 
	}
}
Zi comb(int n, int m) {
	return fac[n] * _fac[m] * _fac[n - m];
}

Zi pwn[N], pwm[N];
int main() {
	scanf("%d%d", &n, &m);
	init_fac(max(n, m));
	pwn[0] = 1;
	for (int i = 1; i <= m; i++)
		pwn[i] = pwn[i - 1] * (n + 1);
	pwm[0] = 1;
	for (int i = 1; i <= n; i++)
		pwm[i] = pwm[i - 1] * (m + 1);
	Zi ans = 0;
	for (int i = 0; i <= n && i <= m; i++) {
		Zi tmp = comb(n, i) * comb(m, i) * fac[i] * pwn[m - i] * pwm[n - i];
		if (i & 1) {
			ans -= tmp;
		} else {
			ans += tmp;
		}
	}
	printf("%d\n", ans.v);
	return 0;
}

Measured memory_bytes: 8064