akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <math.h>
#include <vector>
using namespace std;

vector<long long> enum_div(long long n)//nの約数を列挙
{
	vector<long long> ret;
	for(long long i=1 ; i*i<=n ; ++i)
	{
		if(n%i == 0)
		{
			ret.push_back(i);
			if(i!=1 && i*i!=n)
			{
				ret.push_back(n/i);
			}
		}
	}
	return ret;
}

int main()
{
  long long N;
  long long M;
  cin >> N >> M;
	vector<long long> r = enum_div(M);
  r.push_back(M);
  sort(r.begin(), r.end());
  for(int i=0;i<r.size();i++){
    if(r[i] >= N){
      long long result = M/r[i];
      cout << result << "\n";
      break;
    }
  }
	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main() {
  int i, j, n, count = 0;
  int number[1000000] = {0};

  number[0] = 1;
  number[1] = 1;

  while ( scanf("%d", &n) != EOF) {
    count = 0;
    for(i = 2; i <= n; i++) {
      if(number[i] == 1) continue;;
      for(j = i+i; j <= n; j += i) {
	number[j] = 1;
      }
    }
    
    for(i = 0; i <= n; i++) {
      if(number[i] == 0) count++;
    }
    
    printf("%d\n", count);
  }
  
  return 0;
}

Measured memory_bytes: 4508
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

public class MainClass
{
	public const long Giri = 1000000007;

	public static void Main(string[] args)
	{
		var n = Console.ReadLine().ToLong();
		
		var divisor = new List<long>();
		for(long i = 1; i * i <= n; i++)
		{
			if(n % i == 0)
			{
				divisor.Add(i);
				if(i * i != n)
					divisor.Add(n/i);
			}
		}

		
		long min = 9999999999999;
		for(int i = 0; i < divisor.Count; i++)
		{
			for(int j = 0; j < divisor.Count; j++)
			{
				if(divisor[i] * divisor[j] == n)
				{
					min = Math.Min(min, Math.Abs(divisor[i] - 1) + Math.Abs(divisor[j] - 1));
				}
			}
		}
		Console.WriteLine(min);
	}
	

	static long GCD(long a, long b)
	{
		var v = new[] { a, b };
		while (v[1] != 0) { v = new[] { v[1], v[0] % v[1] }; }
		return v[0];
	}
	public static string[] Input() { return Console.ReadLine().Split(' '); }
	public static int Clamp(int val, int max, int min = 0) { return Math.Min(max, Math.Max(min, val)); }
}

public static class Smarter
{
	public static int ToInt(this string str) { return int.Parse(str); }
	public static long ToLong(this string str) { return long.Parse(str); }
	public static int[] ToInt(this string[] str)
	{
		var r = new int[str.Length];
		for(int i = 0; i < str.Length; i++) r[i] = str[i].ToInt();
		return r;
	 }
}



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

const int mod = 1e9+7;
const int INF = 2000000;

int main() {
    int N,M;
    cin >> N >> M;
    vector<int> A(M);
    rep(i,M) cin >> A[i];
    ll ac = accumulate(A.begin(), A.end(), 0);
    if(ac > N) cout << -1 << endl;
    else cout << N - ac << endl;
    
}


Measured memory_bytes: 3632
#インポート
import sys

#入力用
def ILI(): return list(map(int, sys.stdin.readline().rstrip().split()))
def ISI(): return map(int, sys.stdin.readline().rstrip().split())
def II(): return int(sys.stdin.readline().rstrip())
def ISS(): return sys.stdin.readline().rstrip().split()
def IS(): return sys.stdin.readline().rstrip()

N = II()
K = II()
num = 1
for i in range(N):
    if num < K:
        num *= 2
    else:
        num += K
print(num)

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

int mp[2][603][603];
int n,d1,d2;
std::vector<std::pair<int,int> > all;
int mpi;
void dfs(int i,int j)
{
	for(int k = 0;k < all.size();++k) {
		int a = all[k].first, b = all[k].second;
		if(i-a>=0 && j-b>=0 && mp[mpi][i-a][j-b]==0) {
			mp[mpi][i-a][j-b] = 3-mp[mpi][i][j];
			dfs(i-a,j-b);
		}
		if(i+a<2*n && j-b>=0 && mp[mpi][i+a][j-b]==0) {
			mp[mpi][i+a][j-b] = 3-mp[mpi][i][j];
			dfs(i+a,j-b);
		}
		if(i-a>=0 && j+b<2*n && mp[mpi][i-a][j+b]==0) {
			mp[mpi][i-a][j+b] = 3-mp[mpi][i][j];
			dfs(i-a,j+b);
		}
		if(i+a<2*n && j+b<2*n && mp[mpi][i+a][j+b]==0) {
			mp[mpi][i+a][j+b] = 3-mp[mpi][i][j];
			dfs(i+a,j+b);
		}
	}
}
void work(int cmpi,int d)
{
	mpi = cmpi;
	all.clear();
	for(int i = 0;i * i <= d;++i) {
		int j = d-i*i, k = sqrt(j);
		if(k*k==j) all.emplace_back(i,k);
	}
	for(int i = 0;i < 2*n;++i) {
		for(int j = 0;j < 2*n;++j) {
			if(mp[mpi][i][j]==0) {
				mp[mpi][i][j] = 1;
				dfs(i,j);
			}
		}
	}
}
std::vector<std::pair<int,int> > v[4];
int main()
{
	scanf("%d%d%d",&n,&d1,&d2);
	work(0,d1);
	work(1,d2);
	for(int i = 0;i < 2*n;++i) {
		for(int j = 0;j < 2*n;++j) {
			int k = mp[0][i][j]*2+mp[1][i][j]-3;
			v[k].emplace_back(i,j);
		}
	}
	for(int k = 0;k < 4;++k) if(v[k].size() >= n*n) {
		for(int i = 0;i < n*n;++i) printf("%d %d\n", v[k][i].first, v[k][i].second);
		/*
		for(int a = 0;a < n*n;++a) {
			for(int b = 0;b < n*n;++b) {
				auto p1 = v[k][a], p2 = v[k][b];
				int dist = (p1.first-p2.first)*(p1.first-p2.first)+(p1.second-p2.second)*(p1.second-p2.second);
				if(dist == d1 || dist == d2) {
					printf("%d %d-%d %d\n", p1.first, p1.second, p2.first, p2.second);
				}
			}
		}
		*/
		break;
	}
}


Measured memory_bytes: 40436
#include<iostream>
#include<queue>
#include<cstdio>
#define rep(i,j) for(int (i)=0;(i)<(j);(i)++)

using namespace std;

struct state{
  int prev,now,v;
  double time;
  bool operator <(const state &s)const{
    return time>s.time;
  }
};

const double INFd=1e9;
int n,m;
int s,g;
struct edge{
  int to,d,c;
};

vector< vector<edge> > G; 

double solve(){

  priority_queue<state> que;

  double dist[31][31][31];
  rep(i,31)rep(j,31)rep(k,31)dist[i][j][k]=INFd;
  
  que.push((state){s,s,0,0});
  dist[s][s][0]=0;
  
  while(!que.empty()){
    state now=que.top();que.pop();
    //cout<<"now"<<endl;
    //printf("%d %d %d %f\n",now.prev,now.now,now.v,now.time);
    
    rep(i,G[now.now].size()){
      edge &e=G[now.now][i];
      if(e.to!=now.prev){
        rep(j,3){
          int nv=now.v+j-1;
          double ntime=now.time+e.d/(double)nv;
          if(nv<=e.c && nv>0){
            state nxt=(state){now.now,e.to,nv,ntime};

            if(dist[now.now][e.to][nv]>ntime){
              dist[now.now][e.to][nv]=ntime;
              que.push(nxt);
            }
          }
        }
      }
    }
  }

  double ans=INFd;
  rep(i,31){
    ans=min(dist[i][g][1],ans);
  }
  
  return ans;
}


int main(){
  while(true){
    cin>>n>>m;
    if(n==0 and m==0)break;
    cin>>s>>g;
    s--;
    g--;
    G.clear();
    G.resize(n);
    rep(i,m){
      int x,y,d,c;
      cin>>x>>y>>d>>c;
      x--;
      y--;
      G[x].push_back((edge){y,d,c});
      G[y].push_back((edge){x,d,c});
    }
    double ans=solve();
    if(ans!=INFd)
      printf("%.9f\n",solve());
    else
      printf("unreachable\n");
    
  }

  
}

Measured memory_bytes: 1976
import java.util.*;

class Main {

    static int gcd(int a, int b) {
        return b > 0 ? gcd(b, a % b) : a;
    }

    static int lcm(int a, int b) {
        return a * b / gcd(a, b);
    }

    public static void main(String[] args) {

        long res = 0;
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int k = sc.nextInt();
        int[] p = new int[n + 1];

        for (int i = 0; i < k; i++) {
            int jmax = sc.nextInt();
            for (int j = 0; j < jmax; j++) {
                int tmp = sc.nextInt();
                p[tmp]++;
            }
        }
        for (int i = 1; i <= n; i++) {
            if (p[i] == 0) {
                res++;
            }
        }

        System.out.println(res);
        sc.close();
    }
}


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

bool chk(string str){
	string tmp =str;
	reverse(str.begin(), str.end());
	if(tmp==str)	return true;
	else{
		return false;
	}
}

int main() {
	cin>>s;
	int n = s.length();
	int mid = (s.length()-1)/2;
	string sub1 = s.substr(0,mid);
	string sub2 = s.substr(mid+1,s.length());
	if(chk(s)&&chk(sub1)&&chk(sub2))	cout<<"Yes";
	else{
		cout<<"No";
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define GET_REP(_1, _2, _3, NAME, ...) NAME
#define rep(...) GET_REP(__VA_ARGS__, irep, _rep)(__VA_ARGS__)
#define rep1(...) GET_REP(__VA_ARGS__, irep1, _rep1)(__VA_ARGS__)
#define _rep(i, n) irep (i, 0, n)
#define _rep1(i, n) irep1(i, 1, n)
#define irep(i, a, n) for (int i = a; i < (int)(n); ++i)
#define irep1(i, a, n) for (int i = a; i <= (int)(n); ++i)
#define rrep(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define rrep1(i, n) for (int i = (int)(n); i >= 1; --i)
#define allrep(X, x) for (auto &&X : x)
#define all(x) (x).begin(), (x).end()
#ifdef LOCAL
  #include "../../Lib/cout_container.hpp"
  #define debug(x) cerr << #x " => " << x << endl
#else
  #define debug(x) 0
#endif
using lint = long long;
constexpr int    INF  = 1 << 30;
constexpr lint   INFL = 1LL << 62;
constexpr int    MOD  = (int)1e9 + 7;
constexpr double EPS  = 1e-9;
using namespace std;
namespace { struct INIT { INIT() { cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(15); } } INIT; }

int main(void) {
  int n;
  cin >> n;
  vector<int> a(n + 1), ans(n + 1, -1);
  rep1 (i, n) cin >> a[i];
  rrep1 (i, n) {
    bool sum = false;
    for (int j = 2; j <= n / i; ++j) sum ^= ans[i * j];
    ans[i] = a[i] ^ sum;
  }
  cout << count(all(ans), 1) << endl;
  bool b = true;
  rep1 (i, n) {
    if (ans[i] == 1) {
      cout << (b ? "" : " ") << i;
      b = false;
    }
  }
  return 0;
}

Measured memory_bytes: 2560
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		int n = scanner.nextInt();
		int ten = 0;
		int out = 0;
		List<Integer> list = new ArrayList<Integer>();
		while (true) {
			if (n == 0)
				break;
			String line = scanner.next();
			if (line.equals("HIT")) {
				if (list.size() == 3) {
					ten++;
				} else {
					list.add(0);
				}
			} else if (line.equals("HOMERUN")) {
				ten += list.size() + 1;
				list.clear();
			} else {
				out++;
				if (out == 3) {
					out = 0;
					System.out.println(ten);
					ten = 0;
					list.clear();
					n--;
				}
			}

		}

	}
}

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

#define pb push_back
#define For(i, j, k) for(int i = j; i <= k; i++)

using namespace std;

const int N = 1e5 + 10;

int n, deg[N];
vector<int> G[N];

bool check(const vector<int>& A, int x, int m){
	int l = 0, r = int(A.size()) - 1;
	while(l < r){
		if(l == x) ++l;
		if(r == x) --r;
		if(A[l] + A[r] > m) return false;
		++l, --r;
	}
	return true;
}

int dp[N];

bool DFS(int o, int f, int lim){

	vector<int> val;
	
	int ch = 0;
	for(int v : G[o]){
		if(v == f) continue;
		++ch;
		if(!DFS(v, o, lim)) return false;
		val.pb(dp[v]);
	}

	if(ch % 2 == 0) val.pb(0);
	sort(val.begin(), val.end());

	int L = 0, R = int(val.size()) - 1;
	if(!check(val, R, lim)) return false;

	while(L < R){
		int mid = (L + R) >> 1;
		if(check(val, mid, lim)) R = mid;
		else L = mid + 1;
	}
	dp[o] = val[L] + 1;

	return true;
}

int main(){
	
	scanf("%d", &n);
	For(i, 2, n){
		int u, v;
		scanf("%d%d", &u, &v);
		G[u].pb(v), G[v].pb(u);
		deg[u]++, deg[v]++;
	}

	int root = 0, a = 0;
	For(i, 1, n) if(deg[i] == 1){
		root = i;
		break;
	}
	For(i, 1, n) if(deg[i] & 1) ++a;

	int L = 1, R = n - 1;
	while(L < R){
		int mid = (L + R) >> 1;
		if(DFS(root, 0, mid) && dp[root] <= mid + 1) R = mid;
		else L = mid + 1;
	}

	printf("%d %d\n", a / 2, L);

	return 0;
}

Measured memory_bytes: 18944
//Practice
#include <bits/stdc++.h>
#define ll long long
using namespace std;
const ll N = 51;
const double E = 1e-9;

//------------------------------------------------------------------------------

int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    /*ifstream cin("input.txt");
    ofstream cout("output.txt");*/
    int n, k;
    cin >> n >> k;
    int a[n];
    for (int i = 0; i < n; i++)
        cin >> a[i];
    for (int i = k; i < n; i++)
    {
        if (a[i] > a[i - k])
            cout << "Yes\n";
        else
            cout << "No\n";
    }
    return 0;
}
//Date: ###### Sun Jul 26 09:54:02 IST 2020
//------------------------------------------------------------------------------

Measured memory_bytes: 4416
import java.util.ArrayDeque;
import java.util.BitSet;
import java.util.Deque;
import java.util.Scanner;
import java.io.IOException;
import java.io.InputStream;
import java.util.NoSuchElementException;

public class Main {
    public static void main(String[] args) {
        StringBuilder sb = new StringBuilder();
        FS fs = new FS();
        int n = fs.nextInt();
        BitSet bitSet = new BitSet(2000);
        int o = 0;
        for (int i = 0; i < n; i++) {
            Integer m = fs.nextInt();
           for(int j=2000-m;0<j;j--){
               if (bitSet.get(j)){
                   bitSet.set(j+m);
               }
           }
           bitSet.set(m);
        }
        int q = fs.nextInt();
        for (int i = 0; i < q; i++) {
            sb.append(bitSet.get(fs.nextInt()) ? "yes\n" : "no\n");
        }
        System.out.print(sb.toString());
    }
static  class FS {
    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;

    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        } else {
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }

    private int readByte() {
        return hasNextByte() ? buffer[ptr++] : -1;
    }

    private boolean isPrintableChar(int c) {
        return 33 <= c && c <= 126;
    }

    private void skipUnprintable() {
        while (hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++;
    }

    public boolean hasNext() {
        skipUnprintable();
        return hasNextByte();
    }

    public String next() {
        if (!hasNext()) throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while (isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }

    public int nextInt() {
        return (int) nextLong();
    }

    public long nextLong() {
        if (!hasNext()) throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while (true) {
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            } else if (b == -1 || !isPrintableChar(b)) {
                return minus ? -n : n;
            } else {
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }
}
}



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

#define int long long
#define fi first
#define se second
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define rep1(i,n) for(int i=1;i<=(int)(n);++i)
#define rep11(i,n) for(int i=1;i<(int)(n);++i)
#define repo(i,o,n) for(int i=o;i<(int)(n);++i)
#define repm(i,n) for(int i=(int)(n)-1;i>=0;--i)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define sperase(v,n) (v).erase(remove(all(v), n), (v).end())
#define vdelete(v) (v).erase(unique(all(v)), (v).end())
#define pb(n) push_back(n)
#define mp make_pair
#define MOD 1000000007
#define INF LONG_LONG_MAX

int n,a,ans;
vector<pair<int,int>> v;

signed main() {
    cin >> n;
    rep(i,n) cin >> a, v.pb(mp(a,i));
    sort(all(v));
    rep(i,n) if ((i+v[i].se)%2) ans++;
    cout << ans/2 << endl;
}



Measured memory_bytes: 2420
#include <bits/stdc++.h>
#define rep(i,n) for (int i=0; i<(n); ++i)
using namespace std;
using ll=long long;
int main(){
    int n;
    cin>>n;
    vector<string>s(n);
    string ma="MARCH";
    int a[5]={0};
    rep(i,n){
        cin>>s[i];
        rep(j,5){
            if(s[i][0]==ma[j])a[j]++;
        }
    }
    ll ans=0;
    for(int i=0; i<5; ++i){
        for(int j=i+1; j<5; ++j){
            for(int k=j+1; k<5; ++k){
                ans+=(ll)a[i]*a[j]*a[k];
            }
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 6144
#include <bits/stdc++.h>
#define ll long long
using namespace std;
int i,j,k,n,m;
void read(int &x){
	char c;x=0;do c=getchar();while(c>57||c<48);
	do x=x*10+c-48,c=getchar();while(c<=57&&c>=48);
}
void read(ll &x){
	char c;x=0;do c=getchar();while(c>57||c<48);
	do x=x*10+c-48,c=getchar();while(c<=57&&c>=48);
}
int s[100010];
int main() {
    cin>>n;
	for(i=1;i<=n;i++){
		cin>>s[i];
		if(s[i]>s[i-1])s[i]--;
		if(s[i]<s[i-1]){
			cout<<"No"<<endl;
			return 0;	
		}
	}
	cout<<"Yes"<<endl;
	return 0;
}

Measured memory_bytes: 640
//  Suraj Saste

#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb push_back
#define pi pair<ll,ll>
#define mkp make_pair
#define in insert
#define fe first
#define se second
#define ms(x,i) memset(x,i,sizeof(x))
#define prec(x) cout<<std::setprecision(x)
#define mod 1000000007
#define all(x) x.begin(),x.end()
#define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
ll fpow(ll n, ll k, ll p=mod) {ll r=1; n=n%p; while(k>0){ if(k&1){ r=(r*n)%p; } k=k>>1; n=(n*n)%p; } return r;}
bool isPrime(ll n){ if(n<=1)return false;if(n<=3)return true;if(n%2==0 || n%3==0)return false;for(ll i=5;i*i<=n;i+=6){if(n%i==0||n%(i+2)==0)return false;}return true;}

ll dp[3005][3005];

int main()
{
	fast;
	ll n;cin>>n;
	ll a[n];
	for(ll i=0;i<n;i++)cin>>a[i];
	for(ll l=n-1;l>=0;l--)
	{
		for(ll r=l;r<n;r++)
		{
			if(l==r)
				dp[l][r]=a[l];
			else
			{
				dp[l][r]=max(a[l]-dp[l+1][r],a[r]-dp[l][r-1]);
			}
		}
	}
	// for(ll i=0;i<n;i++)
	// {
	// 	for(ll j=0;j<n;j++)cout<<dp[i][j]<<" ";
	// 	cout<<"\n";
	// }
	cout<<dp[0][n-1];
	return 0;
}


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

char m[55][55];
int h, w;

int main() {
    cin >> h >> w;
    for (int i = 0; i < h;i++) {
        for (int j = 0; j < w; j++) cin >> m[i][j];
    }
    for (int i = 0; i < h; i++) {
        for (int j = 0; j < w; j++) {
            if (m[i][j] == '#') {
                if (i + 1 < h && (m[i + 1][j] == '#' || m[i + 1][j] == 'b')) m[i][j] = 'b';
                else if (i - 1 >= 0 && (m[i - 1][j] == '#' || m[i - 1][j] == 'b')) m[i][j] = 'b';
                else if (j + 1 < w && (m[i][j + 1] == '#' || m[i][j + 1] == 'b')) m[i][j] = 'b';
                else if (j - 1 >= 0 && (m[i][j - 1] == '#' || m[i][j - 1] == 'b')) m[i][j] = 'b';
                else {
                    cout << "No" << endl;
                    return 0;
                }
            }
        }
    }
    cout << "Yes" << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdlib>
#include <vector>

using namespace std;

int main()
{
    long long ans = 0;
    long long tmp;
    long long n;
    cin >> n;
    for (int i = 0; i < n; ++i){
        cin >> tmp;
        ans += tmp;
    }
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 3092
import java.util.*;

class Main {
  public static void main (String[] args) {
    Map<String, String> map = new HashMap<String, String>();
    map.put("11", "a");
    map.put("12", "b");
    map.put("13", "c");
    map.put("14", "d");
    map.put("15", "e");
    map.put("21", "f");
    map.put("22", "g");
    map.put("23", "h");
    map.put("24", "i");
    map.put("25", "j");
    map.put("31", "k");
    map.put("32", "l");
    map.put("33", "m");
    map.put("34", "n");
    map.put("35", "o");
    map.put("41", "p");
    map.put("42", "q");
    map.put("43", "r");
    map.put("44", "s");
    map.put("45", "t");
    map.put("51", "u");
    map.put("52", "v");
    map.put("53", "w");
    map.put("54", "x");
    map.put("55", "y");
    map.put("61", "z");
    map.put("62", ".");
    map.put("63", "?");
    map.put("64", "!");
    map.put("65", " ");
    Scanner scanner = new Scanner(System.in);
    String out = "";
    while (scanner.hasNext()) {
      String line = scanner.nextLine();
      if (line.length() % 2 == 1) {
        out += "NA\n";
        continue;
      }
      String work = "";
      for (int ii = 0; ii < line.length(); ii += 2) {
        String p = line.substring(ii, ii + 2);
        Character pc1 = p.charAt(0);
        Character pc2 = p.charAt(1);
        if (Character.isDigit(pc1) == false || Character.isDigit(pc2) == false) {
          out += "NA";
          work = "";
          break;
        }
        int p1 = Integer.parseInt(p.substring(0, 1));
        int p2 = Integer.parseInt(p.substring(1));
        if (p1 < 1 || 6 < p1 || p2 < 1 || 5 < p2) {
          out += "NA";
          work = "";
          break;
        }
        work += map.get(p);
      }
      out += work + "\n";
    }
    System.out.print(out);
  }
}

Measured memory_bytes: 19172
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>

typedef long long ll;

int max(int a, int b){
  if(a > b) return a;
  else return b;
}
int min(int a, int b){
  if(a < b) return a;
  else return b;
}

int sort(const void *a ,const void *b){
  return *(int*)a - *(int*)b;
}

int f(int a){
  int count = 0;
  int flag = 0;
  for(int i = 1; i <= pow(a,0.5); ++i){
    if(a % i == 0) count ++;
    if(i*i == a)flag = 1;
  }
  count *= 2;
  if(flag == 1) --count;
  return count;
}


int main(){

  int a,b;
  scanf("%d%d",&a,&b);

  printf("%d %d\n",a*b, 2*(a+b));

  return 0;
}



Measured memory_bytes: 2036
#include<bits/stdc++.h>
using namespace std;
main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

    long long i,j,k,l,m,n,o,p,q;
    while(cin>>m>>n>>o>>p)
    {
        if(m+n>o+p)
            cout<<"Left"<<endl;
        else if(m+n<o+p)
            cout<<"Right"<<endl;
        else
            cout<<"Balanced"<<endl;
    }
    return 0;
}

Measured memory_bytes: 3568
#include<iostream>
#include<vector>
#include<algorithm>
#include<tuple>
#include<queue>
#define INFTY 1000000000 
using namespace std;
 
int main() {
    int N, M, L;
    int a,b;
    int now,dist;
    int tmp;
    cin >> N >> M >> L;
    for(;N!=0;){
        vector<vector<bool>> graph(N,vector<bool>(N,false));
        vector<vector<int>> distance(N,vector<int>(N)),evect(N,vector<int>(N));
        vector<vector<int>> dp(N,vector<int>(L+1,INFTY));
        priority_queue<pair<int,int>,vector<pair<int,int>>,greater<pair<int,int>>> q;
        for(int i=0; i< M; i++){
            cin >> a >> b;
            a--;b--;
            graph[a][b] = true; graph[b][a] = true;
            cin >> distance[a][b] >> evect[a][b];
            distance[b][a] = distance[a][b];
            evect[b][a] = evect[a][b];
        }
        for(int j=L; j>=0 ; j--){
            q.push(pair<int,int>(0,0));
            vector<bool> used(N,false);
            for(;!q.empty();){
                tie(dist,now) = q.top();
                q.pop();
                if(used[now]) continue;
                used[now] = true;
                dp[now][j] = dist;
                for(int i=0; i< N; i++){
                    if(graph[now][i]){
                        if(j+distance[now][i]<=L){
                            tmp = min(dist+evect[now][i],dp[now][j+distance[now][i]]);
                        }else{ 
                            tmp = dist+evect[now][i];
                        }
                        if(dp[i][j] <= tmp) continue;
                        q.push(pair<int,int>(tmp,i)); 
                    }
                }
            }
        }

        int ans=dp[N-1][L];
        for(int i=0; i<L ; i++){
            ans=min(ans,dp[N-1][i]);
        }
        cout << ans << endl;
 
        cin >> N >> M >> L;
    }
 
    return 0;
}



Measured memory_bytes: 3232
#include <iostream>

using namespace std;

int main(int argc, char *argv[]) {
	int X;
	cin >> X;

	int s = 0;
	int t = 0;
	while (s < X) {
		s += t;
		t++;
	}
	cout << t - 1 << endl;
	return 0;
}

Measured memory_bytes: 256
n,q = map(int,input().split())

class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

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

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return_list = [list() for i in range(n)]
        for i in range(n):
          return_list[self.find(i)].append(i)
        return return_list

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())

uf = UnionFind(n)

for _ in range(q):
    t,u,v = map(int,input().split())
    if t == 0:
        uf.union(u, v)
    else:
        print(int(uf.same(u, v)))


Measured memory_bytes: 82892
#include <iostream>
#include <algorithm>
using namespace std;
int main(void){
    int n;
    cin>>n;
    int a[n];
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    sort(a,a+n);
    cout<<a[n-1]-a[0];
}


Measured memory_bytes: 3624
Imports System


Module Program
    Dim a As Integer
    Sub Main(args As String())
        a = Console.ReadLine

        If -40 <= a And a <= 40 Then
            If 30 <= a Then
                Console.WriteLine("Yes")
            ElseIf a <= 29 Then
                Console.WriteLine("No")

            End If
        End If

    End Sub
End Module

Measured memory_bytes: 28316
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <math.h>
#include <map>
#include <queue>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int MOD = 1000000007;
const int iINF = 1001001001;
const long long llINF = 1LL << 60;
map<int, int> mp;
int main()
{
	int n, k;
	cin >> n >> k;
	vector<int> x(n);
	rep(i, n)	cin >> x[i];
	int lower, upper;
	lower = 0;
	upper = k - 1;
	int ans = iINF, tmpans = iINF;
	while (upper < n) {
		tmpans = iINF;
		if (x[lower] <= 0 && x[upper] <= 0)			tmpans = abs(x[lower]);
		else if (0 <= x[lower] && 0 <= x[upper])	tmpans = x[upper];
		else {
			tmpans = 2 * min(abs(x[lower]), abs(x[upper]));
			tmpans += max(abs(x[lower]), abs(x[upper]));
		}
		if (tmpans < ans)	ans = tmpans;
		lower++;
		upper++;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 3760
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
int main()
{
	fast;
	string name;
	ll k;
	cin>>k;
	cin>>name;
	if(name.length()<=k)
		cout<<name;
	else{
		for(ll i=0;i<k;i++)
			cout<<name[i];
		cout<<"...";
	}
	return 0;
}










Measured memory_bytes: 3612
#!/usr/bin/perl
use Data::Dumper;

my ($x) = map {$_ - 0} split(/\s+/o,<STDIN>);

if( $x <= 3 ){
  print "1\n";
  exit(0);
}

my $sx = int(sqrt($x) + 1);

my $mx = 1;
for(my $i=2;$i<$sx;$i++){
  for(my $j=2;$j<=10;$j++){
    my $v = $i ** $j;
    last if $v > $x;
    $mx = $v if $v > $mx;
  }
}

print "$mx\n";
exit(0);



Measured memory_bytes: 1920
#include<iostream>
#include<string>
#include<cstring>
using namespace std;
  
string S,R;
char T[5]="ACGT";
int U,a,q;
  
int power[12]={1,4,16,64,256,1024,4096,16384,65536,262144,1048576,4194304};
  
bool V;
  
bool x1[4];
bool x2[16];
bool x3[64];
bool x4[256];
bool x5[1024];
bool x6[4096];
bool x7[16384];
bool x8[65536];
bool x9[262144];
bool x10[1048576];
bool x11[4194304];
bool x12[16777216];
  
void insert(){
    U=0;
    for(int i=0;i<S.size();i++){
        for(int j=0;j<4;j++){
            if(T[j]==S[i]){
                U += power[i]*j;
            }
        }
    }
    a=S.size();
    if(a==1){
        x1[U]=true;
    }
    if(a==2){
        x2[U]=true;
    }
    if(a==3){
        x3[U]=true;
    }
    if(a==4){
        x4[U]=true;
    }
    if(a==5){
        x5[U]=true;
    }
    if(a==6){
        x6[U]=true;
    }
    if(a==7){
        x7[U]=true;
    }
    if(a==8){
        x8[U]=true;
    }
    if(a==9){
        x9[U]=true;
    }
    if(a==10){
        x10[U]=true;
    }
    if(a==11){
        x11[U]=true;
    }
    if(a==12){
        x12[U]=true;
    }
}
  
void find(){
    U=0;
    V=false;
    for(int i=0;i<S.size();i++){
        for(int j=0;j<4;j++){
            if(T[j]==S[i]){
                U += power[i]*j;
            }
        }
    }
    a=S.size();
    if(a==1 && x1[U]==true){
        V=true;
    }
    if(a==2 && x2[U]==true){
        V=true;
    }
    if(a==3 && x3[U]==true){
        V=true;
    }
    if(a==4 && x4[U]==true){
        V=true;
    }
    if(a==5 && x5[U]==true){
        V=true;
    }
    if(a==6 && x6[U]==true){
        V=true;
    }
    if(a==7 && x7[U]==true){
        V=true;
    }
    if(a==8 && x8[U]==true){
        V=true;
    }
    if(a==9 && x9[U]==true){
        V=true;
    }
    if(a==10 && x10[U]==true){
        V=true;
    }
    if(a==11 && x11[U]==true){
        V=true;
    }
    if(a==12 && x12[U]==true){
        V=true;
    }
    if(V==true){
        cout<<"yes"<<endl;
    }
    else{
        cout<<"no"<<endl;
    }
}
  
int main(){
    cin>>q;
    for(int i=0;i<q;i++){
        cin>>R>>S;
        if(R=="insert"){
            insert();
        }
        if(R=="find"){
            find();
        }
    }
    return 0;
}

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

int main() {

  double PI = 3.141592653589793;

  double A, B, H, M;
  cin >> A >> B >> H >> M;

  double angleH = 360 * H / 12;
  double angleM = 360 * M / 60;

  angleH += 30 * M / 60;

  double angle = 0;

  if (0 <= angleH && angleH < 90) {
    
    if (0 <= angleM && angleM < 90) {
      angle = max(angleH - angleM, angleM - angleH);
    } else if (90 <= angleM && angleM < 180) {
      angle = angleM - angleH;
    } else if (180 <= angleM && angleM < 270) {
      angle = min(angleH + (360 - angleM), angleM - angleH);
    } else {
      angle = angleH + (360 - angleM);
    }

  } else if (90 <= angleH && angleH < 180) {

    if (0 <= angleM && angleM < 90) {
      angle = angleH - angleM;
    } else if (90 <= angleM && angleM < 180) {
      angle = max(angleM - angleH, angleH - angleM);
    } else if (180 <= angleM && angleM < 270) {
      angle = angleM - angleH;
    } else {
      angle = min(angleH + (360 - angleM), angleM - angleH);
    }
    
  } else if (180 <= angleH && angleH < 270) {

    if (0 <= angleM && angleM < 90) {
      angle = min(angleM + (360 - angleH), abs(angleH - angleM));
    } else if (90 <= angleM && angleM < 180) {
      angle = angleH - angleM;
    } else if (180 <= angleM && angleM < 270) {
      angle = max(angleM - angleH, angleH - angleM);
    } else {
      angle = angleM - angleH;
    }

  } else {

    if (0 <= angleM && angleM < 90) {
      angle = angleM + (360 - angleH);
    } else if (90 <= angleM && angleM < 180) {
      angle = min(angleM + (360 - angleH), angleH - angleM);
    } else if (180 <= angleM && angleM < 270) {
      angle = angleH - angleM;
    } else {
      angle = max(angleM - angleH, angleH - angleM);
    }
    
  }

  double radian =(double) angle * PI / 180.0;
  double answer =(double) A * A + B * B - ((double)2 * A * B * cos(radian));

  printf("%.20f\n", sqrt(answer));

  return 0;

}

Measured memory_bytes: 4228
#include <iostream>
#include <algorithm>
#include <tuple>
#include <vector>
#include <string>
#include <queue>
#include <cmath>
#include <set>
#include <map>
#include <cassert>

using namespace std;
using ll = long long;

int main()
{
    string n;
    cin >> n;
    ll sum = 0;
    for(int i = 0; i < n.length(); i++){
        sum += n[i]-'0';
    }
    //cout << sum << endl;
    if(sum % 9 == 0){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    return 0;
}

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

int main(){
 string wea;
 cin >> wea;
 if (wea == "Sunny"){
     cout << "Cloudy" << endl;
 }
 else if( wea == "Cloudy"){
     cout << "Rainy" <<endl;
 }
 else{
     cout << "Sunny" << endl;
 } 
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp> 
// #include <ext/pb_ds/tree_policy.hpp> 
// #include <ext/pb_ds/detail/standard_policies.hpp>
// using namespace __gnu_pdbs;
using namespace std;

// typedef tree<int, null_type, less<int>, rb_tree_tag,  
//             tree_order_statistics_node_update>  
//     ordered_set;

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define mt make_tuple
#define eb emplace_back
#define sf(x) sizeof(x)
#define len(x) x.length()
#define sz(x) x.size()
#define fastio() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)

#define LB(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define UB(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
typedef long long ll;
typedef pair<ll,ll> ii;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef unsigned long long ull;
typedef long double ld; 
typedef tuple<int,int,int> State;

ll mod = 1e9 + 7;

#define citc(tc) int tc; cin>>tc; while(tc--) 
#define each(a,x) for( auto &a:(x))
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define repr(i, n) for (ll i = (n) - 1; i >= 0; i--)
#define rep2(i, l, r) for (ll i = (l); i < (r); i++)
#define rep2r(i, l, r) for (ll i = (r) - 1; i >= (l); i--)
#define range(a) a.begin(), a.end()
#define deb(x) cout<<#x<<" "<<x<<endl;
#define cini(i) int i; cin>>i;
#define cinll(l) ll l; cin>>l;
#define cinll2(l, z) ll l, z; cin>>l>>z;
#define cinll3(l, z, x) ll l, z, x; cin>>l>>z>>x;
#define cinai(a, n) vi a(n); rep(i, n) { cin>>a[i]; }
#define cinal(a, n) vl a(n); rep(i, n) { cin>>a[i]; }
#define coutai(a, n) rep(i, n) { cout<<a[i]<<" "; } ent;
#define coutal(a, n) rep(i, n) { cout<<a[i]<<" "; } ent;
#define ent cout<<endl;

ll powm(ll a, ll b, ll mod) {
	ll res=1;
	while(b) {
		if(b&1)
			res=(res*a)%mod;
		a=(a*a)%mod;
		b>>=1;
	}
	return res;
}

void solve()
{
	ll n, k;
	cin>>n>>k;
	cout<<min((n%k), k - (n%k))<<endl;
}
int main()
{
	fastio();
	// citc(tc)
		solve();
}


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

string board[60];
int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};

int main(){
  int X,Y;
  cin >> X >> Y;
  for (int i=0;i<X;++i) cin >> board[i];
  
  for (int i=0;i<X;++i){
    for (int j=0;j<Y;++j){
      if (board[i][j]=='.'){
        int cnt=0;
        for (int k=0;k<8;++k){
          int x=i+dx[k];
          int y=j+dy[k];
          if (x>=0&&x<X&&y>=0&&y<Y&&board[x][y]=='#'){
            cnt++;
          }
        }
            board[i][j]='0'+cnt;//数字の1から文字の1になる
      }
    }
  }
  for (int i=0;i<X;++i) cout << board[i] << endl;
}
          


Measured memory_bytes: 256
import java.io.*;
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.NoSuchElementException;
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		FastScanner sc = new FastScanner();
		PrintWriter out = new PrintWriter(System.out);
		while(sc.hasNext()) {
			int n = (int)sc.nextLong();
			out.println((n*n+n+2)/2);
		}
		out.flush();
	}
}
	
//------------------------------//
//-----------//
class FastScanner {
    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;
    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        }else{
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }
    private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;}
    private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}
    private void skipUnprintable() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++;}
    public boolean hasNext() { skipUnprintable(); return hasNextByte();}
    public String next() {
        if (!hasNext()) throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while(isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }
    public long nextLong() {
        if (!hasNext()) throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while(true){
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            }else if(b == -1 || !isPrintableChar(b)){
                return minus ? -n : n;
            }else{
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }
}

Measured memory_bytes: 16860
#include <cstdio>
#include <algorithm>
#define inf 1001001001
using namespace std;
int n, a, dp[100000];
int main() {
	scanf("%d", &n);
	fill(dp, dp+n, inf);
	for (int i=0; i<n; i++) {
		scanf("%d", &a);
		*lower_bound(dp, dp+n, a) = a;
	}
	printf("%ld\n", (lower_bound(dp, dp+n, inf) - dp));
}

Measured memory_bytes: 3056
#include "bits/stdc++.h"
#define _CRT_SECURE_NO_WARNINGS
#define rep(i,n) for(int i = 0;i < n;i++)
#define REP(i,n,k) for(int i = n;i < k;i++)
#define P(p) cout << (p) << endl;
#define sP(p) cout << setprecision(15) << fixed << p << endl;
#define vi vector<int>
#define printv(v) for(int i = 0;i < v.size();i++)P(v[i]);
#define printt(a,b) cout << a << " " << b << endl; 
#define mp(a,b) make_pair(a,b)
#define pb(a) push_back(a)

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
int dx[] = { 1, -1 , 0 , 0};
int dy[] = { 0,  0,  1, -1};
int MOD = 1e9 + 7;

void solve() {
  ll n,a,b;
  cin >> n >> a >> b;
  if(n == 1){
    if(a == b){
      P(1);
    }else{
      P(0);
    }
  }else{
    if(a > b){
      P(0);
    }else{
      ll maxi = b*(n-1) + a;
      ll mini = a*(n-1) + b;
      ll ans  = maxi - mini + 1;
      P(ans);
    }
  }
}

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


Measured memory_bytes: 256
toInt :: Char -> Int
toInt 'I' = 1
toInt 'V' = 5
toInt 'X' = 10
toInt 'L' = 50
toInt 'C' = 100
toInt 'D' = 500
toInt 'M' = 1000
toInt _ = undefined

plus :: Int -> (Int , Int) -> (Int , Int)
plus c (p,n)
    | c < p = (c , n - c)
    | otherwise = (c , n + c)

solve :: [Char] -> IO ()
solve = print . snd . foldr plus (0 , 0) . map toInt

main :: IO ()
main = getContents
    >>= mapM_ solve . lines

Measured memory_bytes: 3672
from typing import List


def stack_push(elems: List[int], value: int) -> None:
    elems.append(value)


def stack_pop(elems: List[int]) -> int:
    value = elems.pop()
    return value


def exec_operation(elems: List[int], operation: str) -> None:
    value2 = elems.pop()
    value1 = elems.pop()
    if ("+" == operation):
        elems.append(value1 + value2)
    elif ("-" == operation):
        elems.append(value1 - value2)
    elif ("*" == operation):
        elems.append(value1 * value2)


if __name__ == "__main__":
    stack: List[int] = []
    input_commands = input().split(" ")

    for command in input_commands:
        if (str.isdecimal(command)):
            stack_push(stack, int(command))
        else:
            exec_operation(stack, command)

    print(f"{stack_pop(stack)}")



Measured memory_bytes: 7164
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

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

        List<Integer> dist = new ArrayList<>();
        for (int i = 0; i < N; i++) {
            int Xi = sc.nextInt();
            int d = Math.abs(X - Xi);
            dist.add(d);
        }
        int g = dist.get(0);
        for (int i = 1; i < dist.size(); i++) {
            g = gcd(g, dist.get(i));
        }
        System.out.println(g);
    }

    public static int gcd(int a, int b) {
        while (b != 0) {
            int temp = a % b;
            a = b;
            b = temp;
        }
        return Math.abs(a);
    }
}

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

// def
#define debug(x) cout << #x << ": " << x << endl
#define out(x) cout << x << endl
#define repeat(i, a, b) for (int i = (a); i < (b); i++)
#define revrepeat(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define revrep(i, n) for (int i = (n)-1; i >= 0; i--)
#define all(x) (x).begin(), (x).end()
typedef long long ll;
typedef long double ld;
typedef pair<int, int> P;
typedef complex<ld> Point;
typedef vector<vector<int>> Graph;
const int MOD = 1e9 + 7;
const int INF = 1e9;
const int MAX_V = 1e5 + 5;
const int MAX_N = 1e5 + 5;
const double PI = acos(-1);

int main() {
    char a, b;
    cin >> a >> b;
    string sa = "", sb = "";
    rep(i, b - '0') sa += a;
    rep(i, a - '0') sb += b;
    if (sa < sb)
        out(sa);
    else
        out(sb);
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
int main()
{
  int n,K[100000],i,j;
  char S[100000];
  while(1){
    scanf("%d",&n);
    if(n==0)break;
    for(i=0;i<n;i++){
      scanf("%d",&K[i]);
    }
    scanf("%s",S);

    for(i=0;i<strlen(S);i++){
      for(j=0;j<K[i%n];j++){
        if(S[i]=='a')S[i]='Z';
        else if(S[i]=='A')S[i]='z';
        else S[i]-=1;
      }
    }
    printf("%s\n",S);
  }
  return 0;
}

Measured memory_bytes: 604
#include <vector>
#include <math.h>
#include <iostream>
#include <string>
#include <algorithm>
#include <queue>
#include <iomanip>
#include <deque>
#include <cctype>
#include <unordered_map>

using namespace std;
using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;
using pll = pair<long, long>;
template <class T> using V = vector<T>;
template <class T> using VV = V<V<T>>;
#define rep(i, n) for(int i = 0; i<n; i++)
#define rep_s(i, start, n) for(int i= start;  i<n; i++)
#define rep_down(i, n) for(int i = n-1; i>=0; i--)
#define rep_down_s(i, n, start) for(int i = n-1; i>=start; i--)
#define ALL(a) (a).begin(), (a).end()
#define ALL_str(a) (a).cbegin(), (a).cend()

string alphabet_upper = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
string alphabet_lower  = "abcdefghijklmnopqrstuvwxyz";
string numbers = "0123456789";

/*
using edge = struct {int to; ll cost;};
vector<edge> tree[limit];
ll depth[limit];

void dfs(int v, int p, ll d){
  depth[v] = d;
  //cout <<"v: " << v << endl;
  for (auto &e: tree[v]){
    //cout << "e.to: " << e.to << endl;
    if (e.to == p) continue;
    dfs(e.to, v, d+e.cost);
  }
}
*/
int keta_sum(int num){
  int dig, sum = 0;
  while(num){
    dig = num % 10;
    sum = sum + dig;
    num = num / 10;
  }
  return sum;
}

ll binary_search(ll left_key, ll border, ll low, ll high) {
     // 配列 a の左端と右端
    ll mid = (low+high)/2;
    while (high > low+1) {
       mid = (low+high)/2;
        if (left_key*mid>border) high = mid;
        else if (left_key*mid<border) low = mid;
        else {
          mid =mid-1;
          break;
        }
    }
    return mid;
}

bool IsPrime(ll a){
  ll b = sqrt(a);
  b++;
  while(b-->=2){
    if (a%b==0) return false;
  }
  return true;
}

struct UnionFind {
    vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2

    UnionFind(int N) : par(N) { //最初は全てが根であるとして初期化
        for(int i = 0; i < N; i++) par[i] = i;
    }

    int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }

    void unite(int x, int y) { // xとyの木を併合
        int rx = root(x); //xの根をrx
        int ry = root(y); //yの根をry
        if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
        par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
    }

    bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
};

int main(void){
  ll N, M, A, B, C, D, K,W, H, Q, X, Y;
  ll ans;
  string S, T;
  cin >> S;
  cin >> K;
  ll count = 0;
  while (S[count] == '1' && count<S.length()){
    count++;
  }
  //cout << count << endl;
  if (K<= count) cout << 1 << endl;
  else cout <<S[count]<<endl;
  ans = 0;
  
  
}


Measured memory_bytes: 256
while True:
  h, w = map(int, input().split())
  if h == 0 and w == 0:
    break
  for i in range(h):
    for j in range(w):
      if (i+j)%2 == 0:
        print("#", end = "")
      else:
        print(".", end = "")
    print()
  print()


Measured memory_bytes: 7000
#include <stdio.h>

void merge_sort(int x[], int n)
{
	static int y[100001] = {};
	if (n == 1) return;
	merge_sort(&(x[0]), n/2);
	merge_sort(&(x[n/2]), (n+1)/2);
	
	int i, p, q;
	for (i = 0, p = 0, q = n/2; i < n; i++) {
		if (p >= n/2) y[i] = x[q++];
		else if (q >= n) y[i] = x[p++];
		else y[i] = (x[p] < x[q])? x[p++]: x[q++];
	}
	for (i = 0; i < n; i++) x[i] = y[i];
}

int gcd(int a, int b)
{
	if (a > b) {
		a += b;
		b = a - b;
		a -= b;
	}
	if (b % a == 0) return a;
	else return gcd(b % a, a);
}

int main()
{
	int i, N, X, x[100001];
	scanf("%d %d", &N, &X);
	for (i = 1; i <= N; i++) scanf("%d", &(x[i]));
	
	x[0] = X;
	merge_sort(x, N + 1);
	int g = x[1] - x[0];
	for (i = 1; i < N; i++) g = gcd(g, x[i+1] - x[i]);
	
	printf("%d\n", g);
	fflush(stdout);
	return 0;
}

Measured memory_bytes: 896
import math
h,w = map(int,input().split())
if h*w%3 == 0:
    print(0)
    exit()
mi = 10**18

hi = h
wi = w
s = [wi*(hi//3),0,0]
hi = h-h//3
s[1],s[2] = wi*(hi//2),wi*math.ceil(hi/2)
mi = min(mi,max(s)-min(s))
s[1],s[2] = hi*(wi//2),hi*math.ceil(wi/2)
mi = min(mi,max(s)-min(s))

hi = h
wi = w
s = [wi*math.ceil(hi/3),0,0]
hi = h-math.ceil(h/3)
s[1],s[2] = wi*(hi//2),wi*math.ceil(hi/2)
mi = min(mi,max(s)-min(s))
s[1],s[2] = hi*(wi//2),hi*math.ceil(wi/2)
mi = min(mi,max(s)-min(s))

hi = h
wi = w
s = [hi*(wi//3),0,0]
wi = w-w//3
s[1],s[2] = wi*(hi//2),wi*math.ceil(hi/2)
mi = min(mi,max(s)-min(s))
s[1],s[2] = hi*(wi//2),hi*math.ceil(wi/2)
mi = min(mi,max(s)-min(s))

hi = h
wi = w
s = [hi*math.ceil(wi/3),0,0]
wi = w-math.ceil(w/3)
s[1],s[2] = wi*(hi//2),wi*math.ceil(hi/2)
mi = min(mi,max(s)-min(s))
s[1],s[2] = hi*(wi//2),hi*math.ceil(wi/2)
mi = min(mi,max(s)-min(s))

print(mi)


Measured memory_bytes: 3316
#include <iostream>
#include <bits/stdc++.h>
#include <iomanip>
#include<math.h>
using namespace std;
#define ll long long int
#define ull unsigned long long int
int  main(){
  ios_base::sync_with_stdio(0);
  	cin.tie(0);
  	cout.tie(0);
    double a,b,h,m;
    cin>>a>>b>>h>>m;
    double x,y;
    x=h*30+m/2;
    y=m*6;
    double z=abs(x-y);
    //cout<<z<<endl;
    z=(z*M_PI)/180;
    //cout<<cos(z)<<endl;
    double d;
    d=a*a+b*b-2*a*b*cos(z);
    d=sqrt(d);
    cout<<fixed<<setprecision(20)<<d<<endl;
  }


Measured memory_bytes: 4276
import itertools
from collections import Counter
N = int(input())
src = [input() for i in range(N)]
ctr = Counter([s[0] for s in src])

ans = 0
for ptn in itertools.combinations('MARCH',3):
    ans += ctr[ptn[0]]*ctr[ptn[1]]*ctr[ptn[2]]
print(ans)


Measured memory_bytes: 11008