akhauriyash/Code-Regression huggingface dataset:
//ABC 174 --> Put in review package later
/*Author: Aayush Khazanchi                                   Date: 02/08/20
 * 
 * 
 * */
import java.io.*;
import java.math.*;
import java.util.*;
public class Main {
	public static void main(String[] args) {  //Ball out dawg
		FastScanner I = new FastScanner(); //Input
		OutPut O = new OutPut(); //Output
		int K = I.nextInt();
		int temp = K;
		long cur = 7;
		int ans = -1;
		int itr = 1;
		while (temp>0) {
			cur%=K;
			if (cur==0) {
				ans=itr;
				break;
			}
			cur*=10;
			cur+=7; //Shift digits to the left through multiplying then add 7 in new right slot
			temp--;
			itr++;
		}
		O.pln(ans);
	}
	public static long min(long a, long b) {return Math.min(a,b);}
	public static int min(int a, int b) {return Math.min(a,b);}
	public static long max(long a, long b) {return Math.max(a,b);}
	public static long abs(long x, long y) {return Math.abs(x-y);}
	public static long ceil(long num, long den) {long ans = num/den; if (num%den!=0) 
	ans++; return ans;}
	public static long GCD(long a, long b) {
		if (a==0||b==0) return max(a,b);
		return GCD(max(a,b),max(a,b)%min(a,b));
	}
	public static long FastExp(long base, long exp, long mod) {
		long ans=1;
		while (exp>0) {
			if (exp%2==1) ans*=base;
			exp/=2;
			base*=base;
			base%=mod;
			ans%=mod;
		}
		return ans;
	}
	public static long ModInv(long num,long mod) {return FastExp(num,mod-2,mod);}
	public static int pop(long x) { //Returns number of bits within a number
		int cnt = 0;
		while (x>0) {
			if (x%2==1) cnt++;
			x/=2;
		}
		return cnt;
	}
	static class FastScanner {
		BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st=new StringTokenizer("");
		String next() {
			while (!st.hasMoreTokens())
				try {
					st=new StringTokenizer(br.readLine());
				} catch (IOException e) {
					e.printStackTrace();
				}
			return st.nextToken();
		}
		int nextInt() {return Integer.parseInt(next());}
		long nextLong() {return Long.parseLong(next());};
		double nextDouble() {return Double.parseDouble(next());}
	}
	static class OutPut{
		PrintWriter w = new PrintWriter(System.out);
		void pln(double x) {w.println(x);w.flush();}
		void pln(boolean x) {w.println(x);w.flush();}
		void pln(int x) {w.println(x);w.flush();}
		void pln(long x) {w.println(x);w.flush();}
		void pln(String x) {w.println(x);w.flush();}
		void pln(char x) {w.println(x);w.flush();}
		void pln(StringBuilder x) {w.println(x);w.flush();}
		void pln(BigInteger x) {w.println(x);w.flush();}
		void p(int x) {w.print(x);w.flush();}
		void p(long x) {w.print(x);w.flush();}
		void p(String x) {w.print(x);w.flush();}
		void p(char x) {w.print(x);w.flush();}
		void p(StringBuilder x) {w.print(x);w.flush();}
		void p(BigInteger x) {w.print(x);w.flush();}
		void p(double x) {w.print(x);w.flush();}
		void p(boolean x) {w.print(x);w.flush();}
	}
}


Measured memory_bytes: 25924
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<functional>
#include<cmath>
#include<map>
using namespace std;
#define int long long
typedef pair<int, int> P;
struct edge { int to, cost; };

int x[114514], y[114514];
char c[114514];
int b[1005][1005], w[1005][1005];

int br(int si, int sj, int gi, int gj) {//1~k
	int ba = b[gi][gj] - b[max(si - 1, 0ll)][gj] - b[gi][max(sj - 1, 0ll)] + b[max(si - 1, 0ll)][max(sj - 1, 0ll)];
	return ba;
}
int wr(int si, int sj, int gi, int gj) {//1~k
	int wa = w[gi][gj] - w[max(si - 1, 0ll)][gj] - w[gi][max(sj - 1, 0ll)] + w[max(si - 1, 0ll)][max(sj - 1, 0ll)];
	return wa;
}

signed main() {
	int n, k;
	cin >> n >> k;
	for (int i = 0; i < n; i++) {
		cin >> x[i] >> y[i] >> c[i];
		x[i] %= 2 * k;
		y[i] %= 2 * k;

		if (x[i] >= k) {
			if (y[i] >= k) {
				x[i] -= k;
				y[i] -= k;
			}
			else {
				x[i] -= k;
				if (c[i] == 'B')c[i] = 'W';
				else c[i] = 'B';
			}
		}
		else {//x[i]<k
			if (y[i] >= k) {
				y[i] -= k;
				if (c[i] == 'B')c[i] = 'W';
				else c[i] = 'B';
			}
		}

		if (c[i] == 'B')b[x[i]+1][y[i]+1]++;
		else w[x[i]+1][y[i]+1]++;
	}

	for (int i = 0; i < k; i++) {
		for (int j = 0; j < k; j++) {
			b[i + 1][j + 1] += b[i + 1][j];
			w[i + 1][j + 1] += w[i + 1][j];
		}
	}
	for (int i = 0; i < k; i++) {
		for (int j = 0; j < k; j++) {
			b[i + 1][j + 1] += b[i][j + 1];
			w[i + 1][j + 1] += w[i][j + 1];
		}
	}
	int ans = 0;
	for (int i = 0; i < k; i++) {
		for (int j = 0; j < k; j++) {
		//マスi,jが黒or白のときのスコア
		
			int as = br(0, 0, i, j) + br(i + 1, j + 1, k, k ) + wr(0, j + 1, i, k) + wr(i + 1, 0, k, j);
			int bs= wr(0, 0, i, j) + wr(i + 1, j + 1, k , k) + br(0, j + 1, i, k ) + br(i + 1, 0, k , j);
			ans = max(ans, max(as, bs));
		}
	}
	cout << ans << endl;

}

Measured memory_bytes: 17664
#include<bits/stdc++.h>
#define rep(i, n) for(int i=0; i<n; i++)
#define repo(i, n) for(int i=1; i<=n; i++)
#define INF 1001001001
#define INFll 100100100100100
// debug用
#define PrintVec(x) for (auto elementPrintVec: x) { cout << elementPrintVec << " "; } cout << endl;

using namespace std;
using ull = unsigned long long;
using ll = long long;
using P = pair<int, int>;
const int mod = 1000000007;

int main(){
  int n;
  cin >> n;
  string s;
  vector<int> a(4);
  rep(i, n){
    cin >> s;
    if(s[0]=='A'){
      a[0]++;
    } else if(s[0]=='W'){
      a[1]++;
    } else if(s[0]=='T'){
      a[2]++;
    } else if(s[0]=='R'){
      a[3]++;
    }
  }
  cout << "AC x " << a[0] << endl;
  cout << "WA x " << a[1] << endl;
  cout << "TLE x " << a[2] << endl;
  cout << "RE x " << a[3] << endl;
  return 0;
}


Measured memory_bytes: 3604
#include <bits/stdc++.h>
#define inf 2e18
using namespace std;
typedef long long ll;
typedef pair<ll,ll>p;
ll a[100005],b[100005];
int main()
{
    //freopen("in.txt", "r", stdin);
    ll n;
    cin>>n;
    if(n&1){
        cout<<n/2<<endl;
    }
    else{
        cout<<n/2-1<<endl;
    }
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
 
int main(){
  int d,n;
  cin>>d>>n;
  if(n==100){
    if(d==0){
    cout<<n+1<<endl;
  }else if(d==1){
    cout<<100*n+100<<endl;
  }else{
    cout<<100*100*n+10000<<endl;
  }
  } else{
  if(d==0){
    cout<<n<<endl;
  }else if(d==1){
    cout<<100*n<<endl;
  }else{
    cout<<100*100*n<<endl;
  }
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <functional>
#include <climits>
#include <cmath>
#include <utility>
#include <iomanip>

using namespace std;



int main(int argc, char *argv[])
{
	int n;

	//input
	cin >> n;

	vector< pair<int, int> > ba;
	for (int i = 0; i < n; i++){
		int a, b;
		cin >> a >> b;

		pair<int, int> p = make_pair(b, a);
		ba.push_back(p);
	}
	sort(ba.begin(), ba.end());


	//calc
	int sum = 0;
	string ans = "Yes";
	for (int i = 0; i < n; i++){
		int a, b;
		b = ba[i].first;
		a = ba[i].second;

		sum += a;
		if (b < sum){
			ans = "No";
		}
	}


	//ans
	cout << ans << endl;



	return 0;
}


Measured memory_bytes: 2420
#include <iostream>
#include <iomanip>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <cstdio>
#include <utility>
#include <string>
#include <cmath>
#include <cstdlib>
#include <cstring>

using namespace std;

typedef uint64_t u64;
typedef int64_t s64;
typedef uint32_t u32;
typedef int32_t s32;
typedef vector<s32> vs32;
typedef vector<u32> vu32;
typedef vector<s64> vs64;
typedef vector<u64> vu64;

const double PI=3.14159265358979323846;

#define MAX(x, y) ((x) < (y) ? (y) : (x))
#define MIN(x, y) ((x) > (y) ? (y) : (x))

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

#define CEIL(x, y) (((x) + (y) - 1) / (y))
#define MOD 1000000007ULL

#define IN(l, r, x) ((l) <= (x) && (x) < (r))

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

    int h, w;
    cin >> h >> w;
    vector< string > field(h);
    rep (i, h) cin >> field[i];

    queue< pair<int, int> > q;
    rep (i, h)
    {
        rep (j, w)
        {
            if (field[i][j] == '#')
            {
                q.push(pair<int, int>{i, j});
            }
        }
    }

    int ans = -1;
    int dy[] = {-1, 0, 1, 0};
    int dx[] = {0, -1, 0, 1};
    while (!q.empty())
    {
        ++ans;
        int s = q.size();
        rep (j, s)
        {
            pair<int, int> p = q.front(); q.pop();
            int y = p.first;
            int x = p.second;
            rep (i, 4)
            {
                int ny = y + dy[i];
                int nx = x + dx[i];
                if (IN(0, h, ny) && IN(0, w, nx) && field[ny][nx] != '#')
                {
                    q.push(pair<int, int>{ny, nx});
                    field[ny][nx] = '#';
                }
            }
        }
    }

    cout << ans << "\n";
    return 0;
}



Measured memory_bytes: 9488
#include<iostream>
#include<vector>

using namespace std;
int main(){
  int i,j,n,a,b,c=0;
  int u,w,x,y,z;
  vector <int> v;
  
  cin>>n>>a>>b;
  for(i=1;i<=n;i++){
    u=i%10;
    w=(i/10)%10;
    x=(i/100)%10;
    y=(i/1000)%10;
    z=(i/10000)%10;
    j=u+w+x+y+z;
    if(j>=a&&j<=b)
      v.push_back(i);
  }
  for(i=0;i<v.size();i++)
    c+=v[i];
  cout<<c<<endl;
  return 0;
}


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

int main() {
  int n,k;
  cin >> n >> k;
  vector<int> dp(n), h(n);
  for(int i = 0; i < n; i++){
    cin >> h[i];
    dp[i] = 2000000000;
  }
  dp[0] = 0;
  for(int i = 0; i < n; i++){//今の足場
    for(int j = 1; j <= k; j++){//どこまで飛べるか
      if(i + j > n) break;
      dp[i+j] = min(dp[i+j], dp[i] + abs(h[i] - h[i+j]));
    }
  }
  cout << dp[n-1] << endl;
  return 0;
}

Measured memory_bytes: 1024
#include<iostream> 
#include<vector> 
#include<algorithm> 
#include<iomanip> 
#include<stack> 
#include<unordered_map>
#include<queue> 
#include<map> 
#include<climits>
#include<set> 
#include<string> 
//#include<time.h>
//#include<bits/stdc++.h> 
using namespace std; 
#define lld long long int 
#define eb emplace_back
//to insert pair use eb
#define mp make_pair
#define fi first
#define se second
#define pb push_back

#define X 1000000007
#define Y 998244353
#define E4 10000
#define E5 100000
#define E6 1000000
#define inf 1001001001
#define longinf 2001001001001001001
#define pi 3.1415926535

# define rec2(i,a,b) for(lld i=a;i<b;i++) 
#define rec(i,n) for(lld i=0;i<n;i++)
#define rev(i,a,b) for(lld i=b-1;i>=a;i--)
#define all(v) (v).begin(), (v).end()
#define large(v)  *max_element(all(v))
#define small(v)  *min_element(all(v)) 
#define v vector
const double EPS = 1e-6;

void google(int i)
{  cout<<"Case #"<<i<<":"; }

//prime sieve if needed 
//prime factors of number
lld prime[E6+1]; 
void sieve(lld n) 
{ rec(i,n+1) 
    prime[i]=1; 
   for(lld i=2;i*i<=n;i++) 
     { if(prime[i]!=1) 
          continue; 
         for(lld j=i*i;j<=n;j=j+i) 
          if(prime[i]==1)
           prime[j]=i; 
      }
}

lld gcd(lld a,lld b)
{
    if(a==0)
     return b; 
    return gcd(b%a,a); 
}

//fermat a^(m-2)%mod
lld binarymul(lld a,lld n,lld m)
{  lld res=1; 
 while(n) 
  { if(n%2) 
      { res=(res*a)%m; 
         n--; 
      } 
     a=(a*a)%m; 
     n/=2; 
  }
  return res; 
}
/*
void complexity(time_t end,time_t start)
{ 
  double taken = double(end - start); 
    cout<<"Time : "; 
    cout<<fixed<<taken<<setprecision(8);         cout<<" sec "<<endl;
}
*/
void contest(); 
int main()
{   
    /*
    time_t start, end; 
    time(&start); 
    */
   ios_base::sync_with_stdio(false); 
   cin.tie(0);
     #ifdef PUNEET_GOEL
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    #endif
   //sieve(E6); 
    lld t=1; 
    rec(i,t) 
    {
     //google(i+1); 
      contest(); 
      cout<<endl; 
    }
    /*
     time(&end); 
    complexity(end,start);
    */
	return 0;
}

void contest()
{ 
  lld n; 
  cin>>n; 
  lld a[n]; 
  rec(i,n) 
  cin>>a[i]; 
  lld ans=0; 
  rec(i,n-2) 
  {  
   for(lld j=i+1;j<(n-1);j++) 
   {  
    for(lld k=j+1;k<(n);k++) 
    {  
      if(a[i]==a[j] || a[j]==a[k] || a[i]==a[k])
       continue; 
      if((a[i]+a[j])<=a[k]) 
       continue; 
      if((a[j]+a[k])<=a[i]) 
      continue; 
     if((a[i]+a[k])<=a[j]) 
     continue; 
     ans++; 
    }
   }
  }
  cout<<ans; 
}

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

const ll MAXN = 200000;
const ll INF = 1001001001;

ll N, ans=0, tmp=0;
vector<ll> A;

signed main(){
    cin >> N;
    for(int i=0;i<N;i++) {
        ll a;
        cin >> a;
        A.push_back(a);
        ans = ans^a;
    }
    for(int i=0;i<N;i++) {
        tmp = ans^A[i];
        cout << tmp << endl;
    }
    return 0;
}

Measured memory_bytes: 5264
#include <iostream>
#include <cstring>
#include <cstdio>
#include<utility>
#include<algorithm>
#include<vector>
#include<cmath>
#include<map>
using namespace std;
typedef long long ll;
typedef pair<int,int>P;
typedef pair<double,double>P_D;
#define PI 3.1415926535897932384626433832795
#define rep(i, n) for (int i = 0; i < (int)n; i++)
#define reprev(i, n) for (int i = (int)n - 1; i >= 0; i--)
#define ALL(a)  (a).begin(),(a).end()
#define MAX 100100
#define MAX_N 200100
#define SENTINEL 2000000000
#define NIL -1
const int MOD = 1e9+7;
const int INF = 1 << 29;

int main(){
    int n;cin>>n;
    string s[n];
    rep(i,n){
        cin>>s[i];
        }
    int num[n][27];
    memset(num,0,sizeof(num));
    rep(i,n){
        rep(j,26){
            rep(k,s[i].length()){
                if(s[i][k]-'a'==j){
                    num[i][j]++;
                }
            }
        }
    }
    int mins[27];
    rep(i,27)mins[i]=INF;
    rep(i,27){
        rep(j,n){
            if(mins[i]>num[j][i])mins[i]=num[j][i];
        }
    }
    rep(i,26){
        rep(j,mins[i]){
            char s=i+'a';
            cout<<s;
        }
    }
    cout<<endl;
    return 0;
}

Measured memory_bytes: 256
from collections import OrderedDict

cards = OrderedDict()
cards['S'] = set()
cards['H'] = set()
cards['C'] = set()
cards['D'] = set()

n = int(input())
for _ in range(n):
    suit, num = input().split()
    num = int(num)
    cards[suit].add(num)

for suit, nums in cards.items():
    for num in range(1,14):
        if num not in nums:
            print(suit, num)

Measured memory_bytes: 7984
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <cfloat>
#include <ctime>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <numeric>
#include <list>

using namespace std;

#ifdef _MSC_VER
#define __typeof__ decltype
template <class T> int __builtin_popcount(T n) { return n ? 1 + __builtin_popcount(n & (n - 1)) : 0; }
#endif

#define foreach(it, c) for (__typeof__((c).begin()) it=(c).begin(); it != (c).end(); ++it)
#define all(c) (c).begin(), (c).end()
#define rall(c) (c).rbegin(), (c).rend()
#define popcount __builtin_popcount

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

template <class T> void max_swap(T& a, const T& b) { a = max(a, b); }
template <class T> void min_swap(T& a, const T& b) { a = min(a, b); }

typedef long long ll;
typedef pair<int, int> pint;


const int MAX = 1000000;
bool is_prime[MAX + 10];
//int key(int n)
//{
//	vector<int> p;
//	for (int i = 2; i <= n; ++i)
//		if (is_prime[i] && n % i == 0)
//			p.push_back(i);
//	return 2 * p.back() - accumulate(all(p), 0);
//}
int memo[MAX + 10];
int key(int n)
{
	if (~memo[n])
		return memo[n];

	int sum = 0, last;
	for (int i = 2; i <= n; ++i)
	{
		if (is_prime[i] && n % i == 0)
		{
			sum += i, last = i;
			while (n % i == 0)
				n /= i;
		}
	}
	return memo[n] = 2*last - sum;
}
int main()
{
	fill_n(is_prime, MAX, true);
	for (int i = 2; i*i <= MAX; ++i)
		if (is_prime[i])
			for (int j = 2*i; j <= MAX; j += i)
				is_prime[j] = false;

	fill_n(memo, MAX, -1);
	int a, b;
	while (scanf("%d%d", &a, &b), a | b)
		puts(key(a) > key(b) ? "a" : "b");
}

Measured memory_bytes: 5720
using System;

namespace AOJ0057
{
    class Program
    {
        static void Main(string[] args)
        {
            while (true)
            {
                string input = Console.ReadLine();
                if (string.IsNullOrEmpty(input)) break;

                int N = int.Parse(input);
                decimal sum = 1;

                for (int i = 1; i <= N; i++)
                {
                    sum += i;
                }
                Console.WriteLine(sum);
            }
        }
    }
}

Measured memory_bytes: 9184
import sys

w1 = sys.stdin.readline().strip()
w2 = sys.stdin.readline().strip()

for i in range(len(w1)):
    if w1 == w2:
        sys.stdout.write("Yes")
        exit(0)
    w1 = w1[1:] + w1[0]

sys.stdout.write("No")

Measured memory_bytes: 2940
N = int(input())
V = list(map(int, input().split()))

hoge = [1,1]
for i in range(1,N-1):
    hoge.append(2**i)

V.sort()
ans = 0
for i in range(len(hoge)):
    ans += hoge[i] * V[i]
print(ans/2**(N-1))

Measured memory_bytes: 3064
package main

import (
	"fmt"
	"math"
	"strconv"
)

func main() {
	var n int
	fmt.Scan(&n)

	min := math.MaxInt8
	for i := 1; i <= int(math.Sqrt(float64(n))); i++ {
		if n%i != 0 {
			continue
		}

		a := f(i, n/i)
		if a < min {
			min = a
		}
	}

	fmt.Println(min)
}

func f(a, b int) int {
	return max(digits(a), digits(b))
}

func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

func digits(n int) int {
	s := strconv.Itoa(n)
	return len(s)
}


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

int main() {
    int N, A[110];
    cin >> N;
    for (int i = 0; i < N; i++) cin >> A[i];

    bool ans = true;
    for (int i = 0; i < N; i++) {
        if (A[i] % 2 == 0 && (A[i] % 3 != 0 && A[i] % 5 != 0)) {
            ans = false;
            break;
        }
    }

    cout << (ans ? "APPROVED" : "DENIED") << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <fstream>
#include <sstream>
#include <string>
#include <cmath>
#include <cstdio>
#include <cctype>
#include <ctime>
#include <cstdlib>
#include <cstring>
#include <cassert>
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <complex>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cwchar>
#include <cwctype>
#include <exception>
#include <locale>
#include <numeric>
#include <new>
#include <stdexcept>
#include <limits>
#include <valarray>
#include <set>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <list>
#include <utility>
#include <bitset>
#include <algorithm>
#include <functional>
using namespace std;
int s[3010][3010];
int a[2][1010][1010];
int main()
{
	int n,k;
	cin>>n>>k;
	for(int i=0;i<n;i++)
	{
		int x,y;
		char c;
		cin>>x>>y>>c;
		if(c=='B')
		{
			y+=k;
		}
		x%=2*k;
		y%=2*k;
		s[x][y]++;
		s[x+k][y+k]++;
		s[x][y+k]--;
		s[x+k][y]--;
	}
	for(int i=0;i<3*k;i++)
	{
		for(int j=0;j<3*k;j++)
		{
			s[i][j+1]+=s[i][j];
		}
	}
	for(int i=0;i<3*k;i++)
	{
		for(int j=0;j<3*k;j++)
		{
			s[i+1][j]+=s[i][j];
		}
	}
	int ans=0;
	for(int i=0;i<3*k;i++)
	{
		for(int j=0;j<3*k;j++)
		{
			int p=(i/k+j/k)%2;
			a[p][i%k][j%k]+=s[i][j];
		}
	}
	for(int p=0;p<2;p++)
	{
		for(int i=0;i<k;i++)
		{
			for(int j=0;j<k;j++)
			{
				ans=max(ans,a[p][i][j]);
			}
		}
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 43520
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
#define x first
#define y second
#define mp make_pair
#define pb push_back
template <typename TYPE> inline void chkmax(TYPE &x,TYPE y){x<y?x=y:0;}
template <typename TYPE> inline void chkmin(TYPE &x,TYPE y){y<x?x=y:0;}
template <typename TYPE> void readint(TYPE &x)
{
    x=0;int f=1;char c;
    for(c=getchar();!isdigit(c);c=getchar())if(c=='-')f=-1;
    for(;isdigit(c);c=getchar())x=x*10+c-'0';
    x*=f;
}
const int MAXN=200005,INF=0x3f3f3f3f;

int n,a[MAXN];
int lazy[MAXN<<2|1];
void pushdown(int id)
{
	if(lazy[id]==INF)return;
	lazy[id<<1]=lazy[id<<1|1]=lazy[id];
	lazy[id]=INF;
}
void modify(int id,int l,int r,int ql,int qr,int c)
{
	if(l==ql && r==qr){lazy[id]=c;return;}
	pushdown(id);
	int mid=(l+r)>>1;
	if(qr<=mid)modify(id<<1,l,mid,ql,qr,c);
	else if(ql>mid)modify(id<<1|1,mid+1,r,ql,qr,c);
	else modify(id<<1,l,mid,ql,mid,c),modify(id<<1|1,mid+1,r,mid+1,qr,c);
}
int query(int id,int l,int r,int x)
{
	if(l==r)return lazy[id]+x;
	pushdown(id);
	int mid=(l+r)>>1;
	if(x<=mid)return query(id<<1,l,mid,x);
	return query(id<<1|1,mid+1,r,x);
}

int main()
{
	#ifndef ONLINE_JUDGE
//	freopen("code.in","r",stdin);
//	freopen("code.out","w",stdout);
	#endif
	readint(n);
	for(int i=1;i<=n;++i)readint(a[i]);
	if(a[1])return 0*printf("-1\n");
	for(int i=2;i<=n;++i)
		if(a[i]>a[i-1]+1)return 0*printf("-1\n");
	memset(lazy,0x3f,sizeof(lazy));
	for(int i=1;i<=n;++i)modify(1,1,n,i,i,-i);
	ll ans=0;
	for(int i=n;i>1;--i)
	{
		int t=query(1,1,n,i);
		if(a[i]==t)continue;
		ans+=a[i];
		modify(1,1,n,i-a[i]+1,i,a[i]-i);
	}
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 4224
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		int x = sc.next().charAt(0);
		int y = sc.next().charAt(0);

		System.out.println((x < y) ? '<' : (x == y) ? '=' : '>');

		sc.close();


	}

}




Measured memory_bytes: 21588
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;
using System.Text;
using System.IO;
using static System.Math;
namespace AtCoder
{
    class Program
    {
        static public long[] Sarray() { return ReadLine().Split().Select(long.Parse).ToArray(); }
        static public List<long> Slist() { return ReadLine().Split().Select(long.Parse).ToList(); }

        static long Mod = (long)1e9 + 7;
        static void Main(string[] args)
        {
            //SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });            var N = Sarray()[0];
            var S = ReadLine();
            var dct = new bool[26];
            foreach (var s in S)
                dct[s - 'a'] = true;
            if (S.Length != 26)
            {
                for (var i = 0; i < dct.Length; ++i)
                {
                    if (!dct[i])
                    {
                        WriteLine($"{S}{(char)(i + 'a')}");
                        return;
                    }
                }
            }
            for (var i = S.Length - 1; 0 <= i; --i)
            {
                for (var j = S[i] - 'a'; j < 26; ++j) 
                {
                    if (!dct[j])
                    {
                        WriteLine($"{S.Substring(0, i)}{(char)(j + 'a')}");
                        return;
                    }
                }
                dct[S[i] - 'a'] = false;
            }
            WriteLine(-1);
            //Out.Flush();
        }
        public class lb : IComparer<long>
        {
            public int Compare(long x, long y)
            { return 0 <= x.CompareTo(y) ? 1 : -1; }
        }
    }
}

Measured memory_bytes: 13140
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <queue>
#include <fstream>
 
using namespace std;
 
#define INF 100000000
#define EPS 1e-9
#define PI acos(-1)
 
typedef long long ll;
typedef pair<double, string> PP;

#define MAX_N 50

int N;

vector<string> ans_list;

int main(){

  while(true){
    
    cin >> N;
    if(N == 0)
      break;

    vector<pair<double, string> > ans;

    for(int i = 0; i < N; i++){
      
      string L;
      int P, A, B, C, D, E, F, S, M;

      cin >> L >> P >> A >> B >> C >> D >> E >> F >> S >> M;

      int sum = A+B+C + (D+E)*M;
      int count = F*M;

      ans.push_back(PP((double)(count*S - P)/sum,L));

    }

    int M = ans.size();

    for(int i = 0; i < M; i++){
      for(int j = i+1; j < M; j++){
	if(ans[i].first < ans[j].first){
	  swap(ans[i], ans[j]);
	}
	else if(ans[i].first == ans[j].first 
		&& ans[i].second > ans[j].second){
	  swap(ans[i], ans[j]);
	}
      }
    }

    for(int i = 0; i < ans.size(); i++){
      ans_list.push_back(ans[i].second);
    }

    ans_list.push_back("#");
     
  }

  for(int i = 0; i < ans_list.size(); i++){
    cout << ans_list[i] << endl;
  }

  return 0;

}

Measured memory_bytes: 1332
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <queue>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <fstream>
#include <stdio.h>
#include <complex>

using namespace std;

//conversion
//------------------------------------------
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
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<int, PII> TIII;
typedef long long LL;
typedef vector<LL> VLL;

//container util

//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define MT(a,b,c) MP(a, MP(b, c))
#define T1 first
#define T2 second.first
#define T3 second.second

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

double x[111], y[111], z[111], r[111];
double d[111][111];
int visit[111];

int main(){
	int n;
	while(cin>>n, n){
		memset(visit, 0, sizeof(visit));
		REP(i,n)cin>>x[i]>>y[i]>>z[i]>>r[i];
		REP(i,n)FOR(j,i+1,n)d[i][j] = d[j][i] = max(sqrt(pow(x[i]-x[j], 2.0)+pow(y[i]-y[j], 2.0)+pow(z[i]-z[j], 2.0))-r[i]-r[j], 0.0);
		priority_queue<pair<double, PII>, vector<pair<double,PII> >, greater<pair<double,PII> > > q;
		visit[0]=1;
		FOR(i,1,n)q.push(MP(d[0][i], MP(0, i)));
		double ret = 0.0;
		while(!q.empty()){
			pair<double, PII> tmp;
			tmp = q.top();
			q.pop();
			if(visit[tmp.second.second])continue;
			ret += tmp.first;
			visit[tmp.second.second] = 1;
			REP(i,n)if(i!=tmp.second.second)q.push(MP(d[tmp.second.second][i], MP(tmp.second.second, i)));
		}
		printf("%.3f\n", ret);
	}
	return 0;
}

Measured memory_bytes: 1728
/*
「God Is In His Heaven,
		All's Right With The World.」
*/
#include<bits/stdc++.h>
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define rep(i, a, b) for(int i=(a); i<(b); i++)
#define per(i, a, b) for(int i=(a)-1; i>=(b); i--)
#define each(i, q) for(auto i : q)
#define sz(a) (int)a.size()
#define de(a) cout<<#a<<" = "<<a<<endl
#define dd(a) cout<<#a<<" = "<<a<<" "
#define lowbit(x) x&(-x)
#define all(x) x.begin(),x.end()
#define ffs __builtin_ffs //idxOf(1<-) 
#define clz __builtin_clz //numOf(->0) 
#define ctz __builtin_ctz //numOf(0<-)
#define popcount __builtin_popcount //numOf1
#define parity __builtin_parity //(numOf1)%2
using namespace std;
typedef long long ll;
typedef double ld;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vector<int> > vvi;
typedef vector<pair<int, int> > vpii;
template <typename T> inline void read(T& x) {
	int f = 0, c = getchar(); x = 0;
	while (!isdigit(c)) f |= c == '-', c = getchar();
	while (isdigit(c)) x = x * 10 + c - 48, c = getchar();
	if (f) x = -x;
}
template <typename T, typename... Args>
inline void read(T& x, Args& ... args) {
	read(x); read(args...);
}
template <typename T> void write(T x) {
	if (x < 0) x = -x, putchar('-');
	if (x > 9) write(x / 10);
	putchar(x % 10 + 48);
}
template <typename T> void writes(T x) { write(x); putchar(' '); }
template <typename T> void writeln(T x) { write(x); puts(""); }
template <typename T> inline bool chkmin(T& x, const T& y) { return y < x ? (x = y, true) : false; }
template <typename T> inline bool chkmax(T& x, const T& y) { return x < y ? (x = y, true) : false; }
const int maxn = (int)3e5 + 10;
const ll inf = (ll)1e18;
const int mod = (int)1e9 + 7;
/*
	——ASUKA STRIKES!
*/
int n, a[maxn], b[maxn];
ll ans;
int main() {
	read(n);
	rep(i, 1, n + 2) {
		read(a[i]), ans += a[i];
	}
	rep(i, 1, n + 1) {
		read(b[i]);
	}
	rep(i, 1, n + 1) {
		if (b[i] > a[i]) {
			b[i] -= a[i];
			ans += a[i];
			a[i + 1] -= b[i];
			a[i + 1] = max(0, a[i + 1]);
		}
		else {
			a[i] -= b[i];
		}
	}
	ll res = 0;
	rep(i, 1, n + 2) {
		res += a[i];
	}
	writeln(ans - res);
}

Measured memory_bytes: 1024
use std::io;

fn main() {
    loop {
        let mut buf = String::new();
        io::stdin().read_line(&mut buf).unwrap();
        let mut v: Vec<i64> = buf.split_whitespace().into_iter().map(|el| el.parse().unwrap()).collect();
        if v[0] == 0 && v[1] == 0 {
            break;
        }
        v.sort();
        println!("{} {}", v[0], v[1]);
    }
}


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

int main(){
    //入力
    int N,K;
    cin >> N >> K;

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

    //処理
    sort(l.begin(),l.end());

    int ans=0;
    for(int i=0;i<K;i++){
        ans+=l.at(N-i-1);
    }

    //出力
    cout << ans << endl;

}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <time.h>

typedef struct {
	int N;
	int *u;
	int *u_size;
}union_find;

union_find *make_union_find(int N){
	int i;
	union_find *uf = (union_find *)malloc(sizeof(union_find));
	uf->N = N;
	uf->u = (int *)malloc(sizeof(int) * N);
	uf->u_size = (int *)malloc(sizeof(int) * N);
	for(i = 0; i < N; i++){
		uf->u[i] = i;
		uf->u_size[i] = 1;
	}
	return uf;
}

int root_uf(int x, union_find *uf){
	int *u = uf->u;
	if(u[x] == x){
		return x;
	}
	else{
		u[x] = root_uf(u[x], uf);
		return u[x];
	}
}

void combine_uf(int x, int y, union_find *uf){
	int x_root = root_uf(x, uf);
	int y_root = root_uf(y, uf);
	int *u = uf->u;
	int *u_size = uf->u_size;
	if(x_root == y_root){
		return;
	}
	else if(u_size[x_root] < u_size[y_root]){
		u[x_root] = y_root;
		u_size[y_root] += u_size[x_root];
		u_size[x_root] = 0;
	}
	else{
		u[y_root] = x_root;
		u_size[x_root] += u_size[y_root];
		u_size[y_root] = 0;
	}
}

//xとyが同じ集合に属していれば1を,そうでなければ0を返す
int is_same_union_uf(int x, int y, union_find *uf){
	if(root_uf(x, uf) == root_uf(y, uf)){
		return 1;
	}
	else{
		return 0;
	}
}

//xが属する集合の要素数を返す
int size_uf(int x, union_find *uf){
	return uf->u_size[root_uf(x, uf)];
}

int main(){
	int N, M, i, j, k;
	scanf("%d%d", &N, &M);
	int *num = (int *)malloc(sizeof(int) * N);
	for(i = 0; i < N; i++){
		num[i] = 0;
	}
	int *a = (int *)malloc(sizeof(int) * M);
	int *b = (int *)malloc(sizeof(int) * M);
	for(i = 0; i < M; i++){
		scanf("%d%d", &a[i], &b[i]);
		a[i]--;
		b[i]--;
		num[a[i]]++;
		num[b[i]]++;
	}
	int count = 0;
	for(i = 0; i < N; i++){
		if(num[i] % 2 == 1){
			printf("No\n");
			return 0;
		}
	}
	for(i = 0; i < N; i++){
		if(num[i] >= 6){
			printf("Yes\n");
			return 0;
		}
		if(num[i] == 4){
			count++;
		}
	}
	if(count >= 3){
		printf("Yes\n");
		return 0;
	}
	if(count < 2){
		printf("No\n");
		return 0;
	}
	int **es = (int **)malloc(sizeof(int *) * N);
	int *now = (int *)malloc(sizeof(int) * N);
	for(i = 0; i < N; i++){
		es[i] = (int *)malloc(sizeof(int) * 4);
		now[i] = 0;
	}
	for(i = 0; i < M; i++){
		es[a[i]][now[a[i]]] = b[i];
		now[a[i]]++;
		es[b[i]][now[b[i]]] = a[i];
		now[b[i]]++;
	}

	union_find *uf = make_union_find(N);
	for(i = 0; i < M; i++){
		if(num[a[i]] < 4 && num[b[i]] < 4){
			combine_uf(a[i], b[i], uf);
		}
	}
	for(i = 0; i < N; i++){
		if(num[i] == 4){
			for(j = 0; j < 4; j++){
				for(k = j + 1; k < 4; k++){
					if(is_same_union_uf(es[i][j], es[i][k], uf) == 1){
						printf("Yes\n");
						return 0;
					}
				}
			}
		}
	}
	printf("No\n");

/*	srand(time(NULL));
	if(rand() % 2 == 0){
		printf("Yes\n");
	}
	else{
		printf("No\n");
	}
*/	return 0;
}

Measured memory_bytes: 6400
#include <iostream>

using namespace std;

int main () {
  int K;
  cin >> K;
    
  int half_k = K / 2;
    
  int ret;
  if (K % 2 == 0) {
      ret = half_k * half_k;
  } else {
      ret = half_k * (half_k + 1);
  }
    
  std::cout << ret << "\n";
  
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
signed main(){
  char a[100],b[100],c[100];
  char d;
  cin>>a>>b>>c;
  d='A'-'a';
  a[0]+=d;
  b[0]+=d;
  c[0]+=d;
  cout<<a[0]<<b[0]<<c[0]<<endl;
 
  return(0);
}


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

int main(){
  int N, T;
  cin >> N >> T;
  vector<int> t(N);
  for(int i=0; i<N; i++) cin >> t.at(i);
  long long ans=T;
  for(int i=1; i<N; i++){
    ans+=min(T, t.at(i)-t.at(i-1));
  }
  cout << ans << endl;
}

Measured memory_bytes: 1024
/**
 * 
 * @param {string} input 
 */
function main(input) {
  var inputList = input.split("\n");
  var nm = inputList[0].split(" ");
  var n = Number(nm[0]);
  var m = Number(nm[1]);
  var tmpList = inputList[1].split(" ");

  var xList = [];
  for(i=0; i<tmpList.length; i++){
    xList.push(Number(tmpList[i]));
  }

  // 座標ソート
  xList.sort(up);
  // 間の差
  var subList = [];
  for(i=0; i<xList.length-1; i++){
    var sub = Number(xList[i+1]) - Number(xList[i]);
    subList.push(sub);
  }

  // 差のソート昇順
  subList.sort(up);
  var sum = 0;
  for(i=0; i<subList.length-(n-1); i++){
    sum += subList[i];
  }
  
  console.log(sum);
}

function up(a, b){
  if(a<b){
    return -1;
  }else if(b<a){
    return 1;
  }else{
    return 0;
  }
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'));


Measured memory_bytes: 27552
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (ll i = 0; i < n; i++)
#define repl(i, l, r) for (ll i = (l); i < (r); i++)
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()
#define CST(x) cout << fixed << setprecision(x)
using ll = long long;
const ll MOD = 1000000007;
const int inf = 1e9 + 10;
const ll INF = 4e18;
const int dx[9] = {1, 0, -1, 0, 1, -1, -1, 1, 0};
const int dy[9] = {0, 1, 0, -1, 1, 1, -1, -1, 0};
int main() {
	cin.tie(0);
	cout.tie(0);
	ios::sync_with_stdio(false);

	int h, w;
	cin >> h >> w;
	int a[h][w];
	rep(i, h) rep(j, w) cin >> a[i][j];
	vector<int> p, q, r, s;
	rep(i, h) {
		rep(j, w) {
			if (i == h - 1 and j == w - 1) {
				break;
			} else if (i == h - 1) {
				if (a[i][j] % 2) {
					a[i][j] -= 1;
					a[i][j + 1] += 1;
					p.push_back(i + 1), q.push_back(j + 1), r.push_back(i + 1), s.push_back(j + 2);
				}
			} else {
				if (a[i][j] % 2) {
					a[i][j] -= 1;
					a[i + 1][j] += 1;
					p.push_back(i + 1), q.push_back(j + 1), r.push_back(i + 2), s.push_back(j + 1);
				}
			}
		}
	}
	int n = p.size();
	cout << n << endl;
	rep(i, n) cout << p[i] << " " << q[i] << " " << r[i] << " " << s[i] << endl;
	return 0;
}

Measured memory_bytes: 5220
import numpy as np
n,p = map(int,input().split())

def factorize(N):
    up = int(np.sqrt(N))+2
    out = {}

    for i in range(2,up):
        if N%i == 0:
            temp = N
            count = 0
            while(True):
                N = N//i
                count += 1
                if N%i != 0:
                    break
            out[i] = count
        else:
            continue
    if N != 1:
        out[N] = 1
    return out

d = factorize(p)
# print(d)
# print(d)

if len(d) == 0:
    print(1)
else:
    ans = 1
    for k in d:
        ans *= k**(d[k]//n)
    print(ans)


Measured memory_bytes: 12488
package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
	"strconv"
)

func main() {
	H := nextInt()
	W := nextInt()

	s1 := calc(H, W)
	s2 := calc(W, H)
	fmt.Println(min(s1, s2))
}

func calc(x, y int) int {
	ans := math.MaxInt64
	for i := 1; i < x; i++ {
		a := y * i
		b := (y / 2) * (x - i)
		c := x*y - a - b
		ans = min(ans, max(a, max(b, c))-min(a, min(b, c)))
	}

	for i := 1; i < x; i++ {
		a := y * i
		b := (x - i) / 2 * y
		c := x*y - a - b
		ans = min(ans, max(a, max(b, c))-min(a, min(b, c)))
	}

	return ans
}

// Input. ----------

var sc = bufio.NewScanner(os.Stdin)

func init() {
	sc.Buffer([]byte{}, math.MaxInt64)
	sc.Split(bufio.ScanWords)
}

func nextInt() int {
	sc.Scan()
	i, err := strconv.Atoi(sc.Text())
	if err != nil {
		panic(err)
	}

	return i
}

func nextString() string {
	sc.Scan()
	if err := sc.Err(); err != nil {
		panic(err)
	}

	return sc.Text()
}

// ---------- Input.

// Util. ----------

func min(x, y int) int {
	return int(math.Min(float64(x), float64(y)))
}

func max(x, y int) int {
	return int(math.Max(float64(x), float64(y)))
}

// ---------- Util.


Measured memory_bytes: 640
/*
problem's name:
statue:
writer:Chris
*/
#include <iostream>
#include <map>
#include <vector>
#include <cstring>
#include <utility>
#include <algorithm>
#include <cstdio>
#include <queue>
#include <string>
#include <stack>
#include <set>
#include <deque>
#include <cctype>
#include <sstream>
#include <math.h>
#include <stdio.h>
#include <time.h>
#define mp make_pair
#define P pair<ll,ll>
#define MP(a,b) make_pair(a,b)
typedef long long ll;
using namespace std;
const ll INF=1e9;
/*------------main part------------*/
bool vis[1000005];
ll n,m,dis[1000005],head,tail,t,h[1000005];
ll cost;
priority_queue<P> q;
set<ll> in[1000005];
struct E
{
	ll v,c,next;
}g[1000005];
inline void ins(ll u,ll v,ll c)
{
	g[++t].v=v;
	g[t].c=c;
	g[t].next=h[u];
	h[u]=t;
}
inline ll read()
{
    ll x=0,f=1;char ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
    while(ch>='0'&&ch<='9'){x=(x<<3)+(x<<1)+ch-'0';ch=getchar();}
    return x*f;
}
int main()
{
	while(cin>>n>>m)
	{
		memset(dis,0x3f,sizeof(dis));
		memset(vis,0,sizeof(vis));
		memset(g,0,sizeof(g));
		memset(h,0,sizeof(h));
		tail=0;
		head=0;
		cost=0;
		t=0;
		for(register ll i=0;i<=n;i++)
		{
			in[i].clear();
		}
		for(register ll i=1;i<=m;++i)
		{
			ll u,v,c;
			u=read(),v=read(),c=read();
			ins(u,v,c);
			ins(v,u,c);
		}
		q.push(mp(0,1));
		dis[1]=0;
		while(!q.empty())
		{
			ll u=q.top().second;
			cost=-q.top().first;
			q.pop();
			vis[u]=1;
			if(cost>dis[u]) continue;
			for(register ll j=h[u];j;j=g[j].next)
			{
				if(vis[g[j].v])
				{
					continue;
				}
				ll v=g[j].v,c=g[j].c,d=dis[u]+(!in[u].count(c));
				if(d>dis[v])
				{
					continue;
				}
				if(d<dis[v])
				{
					q.push(MP(-d,v));
					dis[v]=d;
					in[v].clear();
				}
				in[v].insert(c);
			}
		}
		printf("%d\n",(int)dis[n]==1061109567?-1:dis[n]);
	}
}


Measured memory_bytes: 97268
#include<bits/stdc++.h>
#define ll long long
using namespace std;
ll quickpow(int a,int b)    
{
    long long res = 1, t = a;
    while(b)
    {
        if(b&1) res=res*t;
        t=t*t;
        b>>=1;
    }
	return res;
}
int main()
{
	int x;scanf("%d",&x);
	for(int i=0;i<120;++i)
	{ll a=quickpow(i,5);
		for(int j=-64;j<130;++j)
		{
			if(a-quickpow(j,5)==x)
			{
				cout<<i<<' '<<j;return 0;
			}
		}
	}
 } 

Measured memory_bytes: 3692
#include<iostream>
#include<algorithm>
#include<vector>

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

using namespace std;

const int INF = 10000;

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

	vector<int> V;
	for (int i = 0; i < N; i++) {
		int t;
		cin >> t;
		V.push_back(t);
	}

	for (int i = N - 1; i >= 0; i--) {
		cout << V[i];

		if (i != 0) {
			cout << " ";
		}
	}
	cout << endl;

	return 0;
}



Measured memory_bytes: 3168
#include<bits/stdc++.h>
using namespace std;
int main(){
  string s;
  cin>>s;
  int n=s.size();
  for(int i=0;i<n;i++){
    for(int j=0;j<n;j++){
      string t="";
      for(int k=0;k<i;k++){
	t+=s[k];
      }
      for(int k=j+1;k<n;k++){
	t+=s[k];
      }
      if(t=="keyence"){
	cout<<"YES"<<endl;
	return(0);
      }
    }
  }
  cout<<"NO"<<endl;	
  return(0);
}


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

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;

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

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG2(x,y) cout<<#x<<": "<<x<<" "<<#y<<": "<<y<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define DEBUG_ARR(v,n) cout<<#v<<":";REP(i,n)cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

const ll MOD = 1000000007ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

int n,s;
int main() {
    ios::sync_with_stdio(false); cin.tie(0);
    cin>>n;
    int p[200010];
    //int mx=-1;
    REP(i,n) {
        cin>>p[i];
    }
    int mn = p[0];
    int ans = 1;
    FOR(i,1,n){   
        if(mn>p[i]) {
            ans++;
            mn = p[i];
        }
    }

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

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
 
#define INF ( 1<<29 )
 
typedef pair<int,int> P;
 
int H,W;
char fie[51][51];
 
int dx[]={0,1,0,-1};
int dy[]={-1,0,1,0};
 
int dx2[]={0,2,0,-1};
int dy2[]={-1,0,2,0};
int dx3[]={1,2,1,-1};
int dy3[]={-1,1,2,1};
 
int bmem[51][51];
 
 
struct state{
  int x,y,d,c;
  bool operator<(const state &a) const {
    return c > a.c;
  }
};
 
bool check(int x,int y,int kx,int ky){
  if( x < 0 || y < 0 || x >= W || y >= H ) return false;
  if( kx <= x && x <= kx + 1 && ky <= y && y <= ky + 1 ) return false; 
  if( fie[x][y] == '*' ) return false;
  if( bmem[x][y] > -1 ) return false;
  return true;
}
 
int bfs(int sx,int sy,int tx,int ty,int kx,int ky){
  memset(bmem,-1,sizeof(bmem));
  queue<P> q;
  q.push( P(sx,sy) );
  bmem[sx][sy] = 0;
  while( !q.empty() ){
    P p = q.front(); q.pop();
    int x = p.first, y = p.second;
    if( x == tx && y == ty ) return bmem[x][y];
    for(int i=0;i<4;i++){
      int nx = x + dx[i], ny = y + dy[i];
      if( check( nx, ny, kx, ky ) ) {
    q.push( P(nx,ny) );
    bmem[nx][ny] = bmem[x][y] + 1;
      }
    }
  }
  return INF;   
}
 
int dmem[51][51][5];
 
int solve(int x1,int y1,int x2,int y2,int kx,int ky){
  priority_queue<state> q;
  for(int i=0;i<H;i++)
    for(int j=0;j<W;j++)
      for(int k=0;k<4;k++) dmem[j][i][k] = INF;
 
  for(int i=0;i<4;i++){
    int px1 = kx + dx2[i], py1 = ky + dy2[i];
    int px2 = kx + dx3[i], py2 = ky + dy3[i];
     
    int sca1 = bfs(x1,y1,px1,py1,kx,ky);
    int sca2 = bfs(x1,y1,px2,py2,kx,ky);
    int scb1 = bfs(x2,y2,px1,py1,kx,ky);
    int scb2 = bfs(x2,y2,px2,py2,kx,ky);
 
    int sc =  min( sca1 + scb2, sca2 + scb1 );
    if( sc >= INF ) continue;
    dmem[kx][ky][i] = sc;
    q.push( (state){kx,ky,i,sc} );
  }
 
  while( !q.empty() ){
    state p = q.top(); q.pop();
    kx = p.x, ky = p.y;
    int d = p.d, c = p.c;
     
    x1 = kx + dx2[d], y1 = ky + dy2[d];
    x2 = kx + dx3[d], y2 = ky + dy3[d];
    if( c > dmem[kx][ky][d] ) continue;
    if( kx == 0 && ky == 0 ) return c;
    for(int i=0;i<4;i++){
      int nx = kx + dx[i], ny = ky + dy[i];
      int px1 = kx + dx2[i], py1 = ky + dy2[i];
      int px2 = kx + dx3[i], py2 = ky + dy3[i];
       
      int sca1 = bfs(x1,y1,px1,py1,kx,ky);
      int sca2 = bfs(x1,y1,px2,py2,kx,ky);
      int scb1 = bfs(x2,y2,px1,py1,kx,ky);
      int scb2 = bfs(x2,y2,px2,py2,kx,ky);
 
      int sc =  min( sca1 + scb2, sca2 + scb1 ) + 1;      
      if( sc >= INF ) continue;
      int nd = (i+2)%4;
      if( sc + c < dmem[nx][ny][nd] ){
    q.push( (state){nx,ny,nd,sc+c} );
    dmem[nx][ny][nd] = sc + c;
      }      
    }
  }
  return -1;
}
 
 
int main(){
  while( cin >> H >> W && (H||W) ){
    int x1, y1,x2,y2, kx, ky;
    bool f1 = false,f2 = false;
    for(int i=0;i<H;i++){
      for(int j=0;j<W;j++){
    cin >> fie[j][i];
    if( fie[j][i] == '.' ){
      if( !f1 ){
        x1 = j; y1 = i;  f1 = true;
      } else {
        x2 = j; y2 = i;
      }
    } else if ( fie[j][i] == 'X' && !f2) {
      kx = j; ky = i; f2 = true;
    }
      }
    }
 
    if( kx == 0 && ky == 0 ) cout << 0 << endl;
    else cout << solve(x1,y1,x2,y2,kx,ky) << endl;;
     
  }
}

Measured memory_bytes: 1280
#include <stdio.h>
#include <string.h>


int main(void){

  int i, j;
  int ans=0;
  int t;
  int M, D;
  int d10, d1;

  scanf("%d %d",&M, &D);

  d10=D/10;//d10のくらいの最大値
  d1=D%10;

  for(i=2; i<=d10-1; i++){
    for(j=2; j<=9; j++){
      if(M>=i*j){
        // printf("i=%d j=%d\n", i, j);
        ans++;
      }else{
        break;
      }
    }
  }
  //D=45だったら39までを上で調査

  for(i=2; i<=d1; i++){
    //d10*2,... ,d10*d1が該当するかを見る
    if(M>=d10*i){
      ans++;
    }else{
      break;
    }
  }

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

  return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#define rep(i, z, n) for(int i = z; i < n; i++)
#define all(v) v.begin(), v.end()
typedef long long ll;
//const int INF = 1<<29;
//const int MODINF = 1000000007;
using namespace std;

int main(){
    int N, K;
    cin >> N >> K;
    set<int> B;
    rep(i, 0, K){
        int d;
        cin >> d;
        vector<int> A(d);
        rep(j, 0, d){
            int x;
            cin >> x;
            B.insert(x);
        }
    }
    cout << N - B.size() << endl;
}


Measured memory_bytes: 3632
#include<bits/stdc++.h>
#define pb push_back
#define boostup ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
typedef long long int ll;
ll power(ll a, ll n) {ll p = 1;while (n > 0) {if(n%2) {p = p * a;} n >>= 1; a *= a;} return p;}
ll power(ll a, ll n, ll mod) {ll p = 1;while (n > 0) {if(n%2) {p = p * a; p %= mod;} n >>= 1; a *= a; a %= mod;} return p % mod;}
using namespace std;

int main()
{
    ll x;
    cin>>x;
    ll i,j;
    ll d,d1;
    for(i=-2000;i<=2000;i++)
    {
        d=i*i*i*i*i;
        for(j=-2000;j<=2000;j++)
        {
            d1=j*j*j*j*j;
            if(d-d1==x)
            {
                cout<<i<<" "<<j<<endl;
                return 0;
            }
        }
    }
}

Measured memory_bytes: 3584
#include <bits/stdc++.h>
#define be(v) (v).begin(),(v).end()
#define pb(q) push_back(q)
typedef long long ll;
using namespace std;
const ll mod=1000000007;
#define doublecout(a) cout<<fixed<<setprecision(10)<<a<<endl;

int main() {
    cin.tie(0);
    cout.tie(0);
    ios::sync_with_stdio(false);
    string s,t;
    cin>>s>>t;
    int n=s.length();
    int m=t.length();
    vector<int> v;
    for(int i=0;i<=n-m;i++){
    	if(t==s.substr(i,m))v.pb(i);
    }
    for(auto& i:v)cout << i<<endl;
    return 0;
}



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

int main(void){
    int a,b,c,d,n;
    int count;
    while(cin>>n){
        count=0;
        for(a=0; a<=9; a++){
            for(b=0; b<=9; b++){
                for(c=0; c<=9; c++){
                    for(d=0; d<=9; d++){
                        if((a+b+c+d)==n) count++;
                    }
                }
            }
        }
        cout<<count<<endl;
    }
    return 0;
}


Measured memory_bytes: 3072
#include <stdio.h>
 
int main(){
    int co[256] = {0};
    char ch;
 
    while((ch = getchar()) != EOF){
                co[ch]++;
    }
    for(int i = 97; i <=122;i++){
      printf("%c : %d\n",i,co[i]+co[i-32]);
    }
    }




Measured memory_bytes: 2120
import scala.annotation.tailrec
import scala.io.StdIn._
object Main extends App {

  solve()
  @tailrec def solve(): Unit = {
    val Array(m, n) = readLine.trim.split(' ').map(_.toInt)
    if (m == 0 && n == 0) return
    val memo = Array.fill(7368792){false}
    var current = m
    for (_ ← 0 until n) {
      while (memo(current)) {
        current += 1
      }
      for (j ← current until memo.length by current) {
        memo(j) = true
      }
    }
    while (memo(current)) {
      current += 1
    }
    println(current)
    solve()
  }
}


Measured memory_bytes: 413312