akhauriyash/Code-Regression huggingface dataset:
let split_on_char sep s =
  let open String in
  let r = ref [] in
  let j = ref (length s) in
  for i = length s - 1 downto 0 do
    if get s i = sep then begin
      r := sub s (i + 1) (!j - i - 1) :: !r;
      j := i
    end
  done;
  sub s 0 !j :: !r

let parent i = int_of_float ((float_of_int (i - 1)) /. 2.)

let left i = 2*i + 1

let right i = 2*i + 2

let to_pow_of_2 n =
  let rec doit i =
    if i > n then i
    else doit (i * 2) in
  doit 1

let add s n i x =
  let j = n + i - 1 in
  s.(j) <- x + s.(j);
  let rec doit j =
    if j > 0 then begin
      let j = parent j in
      s.(j) <- s.(left j) + s.(right j);
      doit j
    end in
  doit j

let sum s n a b =
  let rec doit a b k l r =
    if r < a || b < l then 0
    else if a <= l && r <= b then s.(k)
    else doit a b (left k) l ((l + r) / 2) + doit a b (right k) ((l + r) / 2 + 1) r in
  doit a b 0 0 (n - 1)

let solve n q =
  let n = to_pow_of_2 n in
  let s = Array.make (2*n) 0 in
  let rec doit i =
    if i < q then begin
      begin match List.map int_of_string (split_on_char ' ' (read_line ())) with
      | 0 :: x :: y :: _ -> add s n x y
      | 1 :: x :: y :: _ -> Printf.printf "%d\n" (sum s n x y)
      | _ -> ()
      end;
      doit (i + 1)
    end in
  doit 0

let () =
  match List.map int_of_string (split_on_char ' ' (read_line ())) with
  | [n; q] -> solve n q
  | _ -> ()

Measured memory_bytes: 6532
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0, i##_len = (int)(n); i < i##_len; i++)
#define rep1(i, n) for (int i = 1, i##_len = (int)(n); i <= i##_len; i++)
#define rrep(i, n) for (int i = (int)(n)-1; 0 <= i; i--)
#define rrep1(i, n) for (int i = (int)(n); 1 <= i; i--)

#define each(it, c) \
    for (__typeof((c).begin()) it = (c).begin(); it != (c).end(); it++)
#define all(obj) (obj).begin(), (obj).end()

#define pcount __builtin_popcount
#define SZ(x) ((int)(x).size())
#define LEN(x) ((int)(x).length())

#define dump(x) cerr << #x << " = " << (x) << endl;

#define endl "\n"

template <class T>
bool chmax(T &a, const T &b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T &a, const T &b) {
    if (b < a) {
        a = b;
        return 1;
    }
    return 0;
}

typedef long long lint;

using namespace std;
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int d;
    cin >> d;
    vector<int> c(26);
    vector<vector<int>> s(d, vector<int>(26));
    vector<int> last(26, 0);
    rep(i, 26) cin >> c[i];
    rep(i, d) rep(j, 26) cin >> s[i][j];
    rep(i, d) {
        auto a = s[i];
        map<int, int, greater<int>> m;
        rep(j, 26) { m.emplace(a[j] + (d - last[j]) * c[j], j); }
        cout << (*m.begin()).second + 1;
        if(i!=d-1)cout<<endl;
    }
}

Measured memory_bytes: 3612
#include <iostream>
#include<cstdio>
#include<string>
#include<algorithm>
#include<map>
using namespace std;
#define P pair<int,int>
#define mp make_pair


int t[100002];
int x[100002];
int y[100002];
int z[100002];
int n;
int main(){
	cin>>n;
	//for(int i=0;i<=n;i++)t[i]=1;
	for(int i=0;i<n;i++){
		int a,b;
		cin>>a>>b;
			for(int j=a-1;j<b;j++)t[j]++;
			y[a]++;
			z[b]--;
	}
	
	int ans=0;
	//for(int i=0;i<=n;i++)cout<<t[i]<<" ";cout<<endl;
	for(int i=0;i<=n+1;i++)if(t[i]>=i)ans=i;//t[i]??\??????????????°i???????????°
	//if(ans!=0)ans--;
	cout<<ans<<endl;
	return 0;

}

Measured memory_bytes: 4284
a,b,k = map(int, input().split())
l =[]
if a <= b:
    for i in range(1,a + 1):
        if a % i == 0  and b % i == 0:
            l.append(i)
else:
    for i in range(1,b + 1):
        if a % i == 0  and b % i == 0:
            l.append(i)
print(l[len(l)-k])


Measured memory_bytes: 2940
def examB():
    X, Y, Z = LI()
    X -=Z
    ans = X//(Y+Z)
    print(ans)


import sys,copy,bisect,itertools
from heapq import heappop,heappush,heapify
from collections import Counter,defaultdict,deque
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def S(): return sys.stdin.readline().strip()
mod = 10**9 + 7
inf = float('inf')

examB()


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

/*============================ DEBUGGING =============================*/

void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif

/*============================= DEFINES ==============================*/

#define eps 1e-9
#define mod 1000000007
#define pb push_back
#define mp make_pair
#define B begin()
#define E end()
#define F first
#define S second
#define tostr(x) to_string(x)
#define SZ(x) ((int)x.size())
#define ins insert
#define rep(i,x,y) for(int i=x;i<y;i++)
#define per(i,x,y) for(int i=x;i>y;i--)
#define repi(i,x,y) for(int i=x;i<=y;i++)
#define peri(i,x,y) for(int i=x;i>=y;i--)
#define inf (ll)LLONG_MAX
#define ds1(i,x) for(auto i=x.begin();i!=x.end();i++)
#define ds2(i,x) for(auto i:x)
#define fib(n) ceil(pow((1+sqrt(5),n)-pow((1-sqrt(5),n)/(float)(pow(2,n)*sqrt(5)
#define FIO {ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);}
#define dig(n) (int)(log10(n)+1)
#define ss(x,k) substr(x,k)  // x is the start pos and k is the length of substr.
#define set(x,k) memset(x,k,sizeof x)

/*============================== TYPEDEFS ============================*/

typedef long long ll;
typedef long l;
typedef string str;
typedef vector<int> vi;
typedef vector<ll> vlli;
typedef vector<bool> vb;
typedef queue<int> qi;
typedef vector<pair<int,int> > vpii;
typedef pair<int,int> pii;
typedef pair<ll,int> pli;
/*============================ START FROM HERE =======================*/

int main(){
	FIO
	
	int a,b;cin>>a>>b;
	if(2*b>=a)cout<<0;
	else cout<<a-2*b;
	return 0;
}


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

using ll = long long;
using Pi = pair<int, int>;
using Pl = pair<ll, ll>;
using vint = vector<int>;
using vll = vector<ll>;
template<typename T> using uset = unordered_set<T>;
template<typename T1, typename T2> using umap = unordered_map<T1, T2>;

constexpr int INF = (1 << 30) - 1;
constexpr ll LLINF = 1LL << 60;
constexpr int dy[] = {1, 0, -1, 0, 1, -1, -1, 1};
constexpr int dx[] = {0, 1, 0, -1, 1, 1, -1, -1};
constexpr char el = '\n';
constexpr int mod = 1000000007;

template<typename T> T gcd(T a, T b) { return (b ? gcd(b, a % b) : a); }
template<typename T> T lcm(T a, T b) { return (a / gcd(a, b) * b); }
template<typename T1, typename T2> inline void chmin(T1 &a, T2 b) { if (a > b) a = b; }
template<typename T1, typename T2> inline void chmax(T1 &a, T2 b) { if (a < b) a = b; }

int main() {
    int N, M;
    bool flag[100005] = {};
    int cnt[100005] = {};
    cin >> N >> M;
    for (int i = 0; i < M; i++) {
        int v;
        string S;
        cin >> v >> S;
        if (S == "AC") flag[v] = true;
        else if (!flag[v]) cnt[v]++;
    }
    int a = 0, p = 0;
    for (int i = 1; i <= N; i++) {
        if (flag[i]) {
            a++;
            p += cnt[i];
        }
    }
    cout << a << " " << p << endl;
    return (0);
}

Measured memory_bytes: 768
import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        long n = sc.nextLong();
        long k = sc.nextLong();
        sc.close();

        if (k == 0) {
            System.out.print(n);
            return;
        }

        if (n < k)
        {
            long ans = Math.min(n, Math.abs(n - k));
            System.out.print(ans);
            return;
        }

        long count = n / k;//n > k
        long biggerK = k * (count + 1);
        long smallerK = k * (count);
        long ans = Math.min(Math.min(n, Math.abs(n - biggerK)), Math.abs(n - smallerK));
        System.out.print(ans);
    }
}

Measured memory_bytes: 22996
#include <iostream>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <algorithm>
#include <string>
#include <array>

using namespace std;

int main()
{
    int n;
    cin >> n;
    if(n == 25){
        cout << "Christmas" << endl;
    }
    else if(n == 24){
        cout << "Christmas Eve" << endl;
    }
    else if(n == 23){
        cout << "Christmas Eve Eve" << endl;
    }
    else if(n == 22){
        cout << "Christmas Eve Eve Eve" << endl;
    }
    //cout << ans << endl;
}


Measured memory_bytes: 888
import java.util.*;
public class Main {
	public static void main(String[] args) {
	Scanner sc = new Scanner(System.in);
	int n = Integer.parseInt(sc.next());
	long[] listA = new long[n+1];
	long[] listB = new long[n];
	for(int i =0; i<n+1; i++) {
			listA[i] = Integer.parseInt(sc.next());
	}
	for(int i =0; i<n; i++) {
			listB[i] = Integer.parseInt(sc.next());
	}

	long sum =0;
	long power = 0;
	long least = listA[n];
	for(int i=n; i>=1; i--) {
		if(least<listB[i-1]) {
			sum = sum + least;
			power = listB[i-1] - least;
		}else {
			sum = sum + listB[i-1];
			power = 0;
		}

		least = listA[i-1] - power;
		if(least<0) {
			least = 0;
			sum = sum + listA[i-1];
		}else {
			sum = sum + power;
		}
		
	}
	

	System.out.println(sum);
	}
}

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

S = input()
Q = int(input())

A = []
B = []
revFlag = False;

for _ in range(Q):
    q = input().split()

    if q[0] == '1':
        revFlag = not revFlag
        A,B = B,A
    else:
        if q[1] == '1':
            A.append(q[2])
        else:
            B.append(q[2])


if revFlag:
    A,B = B,A
    


S2 = ''.join(reversed(A)) + S + ''.join(B)

if revFlag:
    S2 = ''.join(reversed(S2))

print(S2)
        


Measured memory_bytes: 7292
#include <stdio.h>
#include <stdlib.h>

struct node{
  struct node *right;
  struct node *left;
  struct node *parent;
  int key;
};
typedef struct node * Node;
#define NIL NULL

Node root;

Node treeMinimum(Node x){
  while(x->left != NIL) x = x->left;
  return x;
}

Node treeMaximum(Node x){
  while(x->right != NIL) x = x->right;
  return x;
}

Node treeSearch(Node u, int k){
  while(u != NIL && k != u->key){
    if(k < u->key){
      u = u->left;
    }else{
      u = u->right;
    }
  }
  return u;
}

Node treeSuccessor(Node x){
  if(x->right != NIL) return treeMinimum(x->right);
  Node y = x->parent;
    while(y != NIL && x == y->right){
      x = y;
      y = y->parent;
    }
    return y;
}

void treeDelete(Node z){
  Node y; // node to be deleted
  Node x; // child of y
  if(z->left == NIL || z->right == NIL) y = z;
  else y = treeSuccessor(z);

  if(y->left != NIL){
    x = y->left;
  }else{
    x = y->right;
  }

  if(x != NIL){
    x->parent = y->parent;
  }

  if(y->parent != NIL){
    root = x;
  }else if(y == y->parent->left){
    y->parent->left = x;
  }else{
    y->parent->right = x;
  }

  if(y != z){
    z->key = y->key;
  }
}

void insert(int k){
  Node y = NIL;
  Node x = root;
  Node z;

  z = malloc(sizeof(struct node));
  z->key = k;
  z->left = NIL;
  z->right = NIL;

  while(x != NIL){
    y = x;
    if(z->key < x->key){
      x = x->left;
    }else{
      x = x->right;
    }
  }

  z->parent = y;

  if(y == NIL){
    root = z;
  }else if(z->key < y->key){
    y->left = z;
  }else{
    y->right=z;
  }
}

void inorder(Node u){
  if(u == NIL) return;
  inorder(u->left);
  printf(" %d",u->key);
  inorder(u->right);
}
void preorder(Node u){
  if(u == NIL) return;
  printf(" %d",u->key);
  preorder(u->left);
  preorder(u->right);
}


int main(){
  int n, i, x;
  char com[20];
  scanf("%d", &n);

  for ( i = 0; i < n; i++ ){
    scanf("%s", com);
    if ( com[0] == 'f' ){
      scanf("%d", &x);
      Node t = treeSearch(root, x);
      if ( t != NIL ) printf("yes\n");
      else printf("no\n");
    } else if ( com[0] == 'i' ){
      scanf("%d", &x);
      insert(x);
    } else if ( com[0] == 'p' ){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    } else if ( com[0] == 'd' ){
      scanf("%d", &x);
      treeDelete(treeSearch(root, x));
    }
  }

  return 0;
}



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

const int maxn = 300010;
struct Segment {
  int n, t[maxn * 2];
  void build(int n) {
    this-> n = n;
    memset(t, 0, sizeof t);
  }
  void modify(int p, int v) {
    if (t[p + n] >= v) return;
    for (t[p += n] = v; p > 1; p >>= 1)
      t[p >> 1] = max(t[p], t[p ^ 1]);
  }
  int query(int l, int r) {
    int ret = 0;
    for (l += n, r += n; l < r; l >>= 1, r >>= 1) {
      if (l&1) ret = max(ret, t[l++]);
      if (r&1) ret = max(ret, t[--r]);
    }
    return ret;
  }
};

int main() {
  ios::sync_with_stdio(false);
  Segment seg;
  seg.build(maxn);
  int n, k;
  cin >> n >> k;
  for (int i = 0; i < n; ++i) {
    int x;
    cin >> x;
    int l = max(0, x - k);
    int r = min(300000, x + k) + 1;
    seg.modify(x, seg.query(l, r) + 1);
  }
  cout << seg.query(0, 300000 + 1) << endl;
  return 0;
}



Measured memory_bytes: 6000
#include "bits/stdc++.h"
#include <regex>
#define _USE_MATH_DEFINES
#include <math.h>

using namespace std;

#ifndef _DEBUG
#define main_ main
#endif
#define FOR(i,s,e) for (int i = int(s); i != int(e); i++)
#define INF (INT_MAX/2)
#define EPS (1.0e-8)
#define LINF (LONG_MAX/2)

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<bool> vb;
typedef vector<string> vs;

template <typename T>
using keyVal = pair<string, T>;
template<typename T>
bool val_greater(const keyVal<T>& left, const keyVal<T>& right) {
	return left.second > right.second;
}

void init_global() {}

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

	ll N;  cin >> N;
	ll R = sqrt(N);
	ll ans = INF;
	FOR(i, 1, R + 1) {
		if (N%i == 0) {
			ll b = N / i;
			ll d = 0;
			while (b > 0) {
				b /= 10;
				d++;
			}
			ans = min(ans, d);
		}
	}

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


Measured memory_bytes: 256
X, Y = input().split()
X = int(X)
Y = int(Y)
if X >= 4 and Y >= 4:
    print(0)
elif X == 1 and Y == 1:
    print(1000000)
elif X <= 3:
    if Y >= 4:
        print(400000-X*100000)
    else:
        print((400000-X*100000)+(400000-Y*100000))
else:
    print(400000-Y*100000)

Measured memory_bytes: 38256
#include<iostream>
#include<map>
#include<vector>
#include<string>
using namespace std;

map<string,int> num;
vector<string> ans;

int main(void)
{
    int n; cin>>n;
    int maxn = 0;
    while(n--){
        string s; cin>>s;
        ++num[s];
        if(num[s] > maxn) maxn = num[s];
    }
    for(map<string,int>::iterator it = num.begin();it!=num.end();++it){
        if(it->second == maxn){
            ans.push_back(it->first);
        }
    }
    int len = ans.size();
    for(int i=0;i<len;++i) cout<<ans[i]<<"\n";
    return 0;
}

Measured memory_bytes: 26868
#include <iostream>
#include <string>
#include <map>
#include <vector>
#include <set>
#include <iterator>
#include <math.h>
#include <bits/stdc++.h>
#define ll long long int
#define ull unsigned long long int
#define pb push_back
#define mp make_pair
#include <algorithm>
#include <cmath>
using namespace std;
pair<ll,ll> norm(ll a,ll b)
{
  if(a<0)
  {
    a*=-1;
    b*=-1;
  }
  else if ((a==0)&&(b<0))
  {
    b*=-1;
  }
  ll d=__gcd(abs(a),abs(b));
  a=(ll)(a/d);
  b=(ll)(b/d);
  pair <ll,ll> p=mp(a,b);
  return p;
}
bool decreasing(pair<ll,ll> a,pair<ll,ll> b) 
{ 
       if(a.first>b.first)
       return true;
       else if(a.first==b.first)
       {
        if(a.second<b.second)
        return false;
        else
        return true;
       } 
       else
       return false;
} 
ll expo(ll x,ll y) 
{ 
    ll res = 1;  
    while(y>0) 
    {  
        if(y&1) 
        res=(res*x)%1000000007;  
        y=y>>1;
        x=(x*x)%1000000007; 
    } 
    return res; 
}
int main()
{
    // ios_base::sync_with_stdio(false);
    // cin.tie(NULL);
    // int T,p;
    // cin>>T;
    // for(p=1;p<=T;p++)
    // { 
        string s;
        cin>>s;
        if(s.at(s.length()-1)=='s')
        cout<<s<<"es";
        else
        cout<<s<<"s";
      return 0;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
int main(){
	ios::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
	int N; cin >> N; 
	long long K; cin >> K; 
	long long A[200010] = {}; 
	for(int i = 0; i < N; i++) cin >> A[i]; 
	long long ng = 0; long long ok = 1145141919810364364; 
	while(ok - ng > 1){
		long long mid = (ok + ng) / 2; 
		long long cnt = 0; 
		for(int i = 0; i < N; i++){
			cnt += (A[i] + mid - 1) / mid - 1; 
		}
		if(cnt <= K) ok = mid; 
		else ng = mid; 
	}
	cout << ok << "\n"; 
}

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

ll cor_round(double x){
  x += 0.5;
  return (ll)x;
}

int main(){
  ll a; double b; cin >> a >> b;
  cout << a*cor_round(100*b)/100 << endl;
}

Measured memory_bytes: 3688
#include <cstdio>
#include <cmath>
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <map>
#include <queue>
#include <algorithm>

#ifdef _DEBUG
#define DMP(x) cerr << #x << ": " << x << "\n"
#else
#define DMP(x) ((void)0)
#endif

const int MOD = 1000000007, INF = 1111111111; 
using namespace std;
using lint = long long;

int main() {

	cin.tie(nullptr);
	ios::sync_with_stdio(false);

	int A, B;
	cin >> A >> B;

	string S;
	cin >> S;

	bool flag = true;
	for (int i = 0; i < S.size(); i++) {
		if (i == A) {
			if (S[i] != '-') flag = false;
		}
		else {
			if (S[i] < '0' || '9' < S[i]) flag = false;
		}
	}

	if (flag) cout << "Yes" << "\n";
	else cout << "No" << "\n";

	return 0;
}

Measured memory_bytes: 256
//Dragon_warrior7(IITK)
//#pragma GCC optimize("O0") 
//#pragma GCC optimize ("Ofast")
//#pragma GCC target ("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//#pragma GCC optimize ("-ffloat-store")
#include <bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
using namespace std;
//using namespace __gnu_pbds;
#define umap unordered_map
#define uset unordered_set
#define ll long long
//#define lll long long
#define pb push_back
#define nl cout << '\n'
#define sor(x) sort(x.begin(), x.end())
#define rev(v) reverse(v.begin(), v.end())
#define lb(v, temp) lower_bound(v.begin(), v.end(), temp)
#define ub(v, temp) upper_bound(v.begin(), v.end(), temp)
#define fi first
#define se second
#define llmax 1000000000000000000
#define pll pair<ll, ll> 
//#define ull unsigned ll
#define vll vector<ll>
#define vpll vector<pll> 
#define rub cerr << "\n------------------------------------\n"
#define deb(x) cerr<<#x<<' '<<'='<<' '<<x<<'\n'
#define fo(i,a,b) for(int i=a;i<b;i++)
#define Lets_be_precise cout<<fixed<<setprecision(10)
//typedef  tree < int ,  null_type ,  greater<int> ,  rb_tree_tag ,  tree_order_statistics_node_update > oset;
// const int mod=1e9+7;
// ll power(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
// ll modInverse(ll a){return power(a,mod-2);}
ll n,m,a,b,c,k,temp,x,y;
const int MAXN=100000+11;
void read(vector<ll> &v)
{for (int i = 0; i < v.size(); i++)cin>>v[i];}
inline ll max(ll a,ll b)
{return ((a>b)?a:b);}
inline ll min(ll a,ll b)
{return ((a>b)?b:a);}
inline ll int gcd(ll int a ,ll int b)
{if(b==0) return a;a%=b;return gcd(b,a);}
void storepowers(int n,vector<int> &a);
ll pow5(ll a)
{
    temp=a;
    for(int i=2;i<=5;i++)
    temp*=a;
    return temp;
}
//#define cerr if(false)cerr//uncomment to remove cerr from program...
void solveforthiscase(const int & test)
{//deb(test);
cin>>x;
for(ll i=-300;i<=300;i++)
{
    for(ll j=-300;j<=300;j++)
    {
        ll calc=pow5(i)-pow5(j);
        if(calc==x)
        {
            cout<<i<<' '<<j;
            return ;
        }
    }
}
return ;
}
int main()
{
	ios_base::sync_with_stdio(false);
	Lets_be_precise;
	cin.tie(NULL);
	cout.tie(NULL);
	int test=1;
// 	cin>>test;
    for(int i=1;i<=test;i++)
    {
        solveforthiscase(i);
    }
}
void storepowers(int n,vector<int> &a)
{
    a.resize(n+1);
    a[0]=1;
    for(int i=1;i<=n;i++)
    a[i]=a[i-1]*2;
    return ;
}


Measured memory_bytes: 3608
#include<bits/stdc++.h>
using namespace std;
int dp[999],a[999],l[999],r[999],m[999],N,Q,i,j,k,OK;
main(){
	cin>>N;
	for(i=0;i<N;i++)cin>>l[i]>>r[i]>>m[i];
	for(i=0;i<N;i++){
		for(j=0;j<400;j++){
			for(k=l[i];k<=r[i];k++){
				dp[j+k]=max(dp[j+k],dp[j]+m[i]);
			}
		}
	}
	cin>>Q;
	for(i=0;i<Q;i++){
		cin>>a[i]; 
		if(!dp[a[i]])OK=1;
	}
	if(OK)cout<<"-1"<<endl;
	else{for(i=0;i<Q;i++)cout<<dp[a[i]]<<endl;}
}

Measured memory_bytes: 1176
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int A, B;
  cin >> A >> B;
  
  int price;
  
  if (A >= 13) {
    cout << B << endl;
  }
 
  else if (A >= 6 && A <=12) {
    cout << B/2 << endl;
  }
 
 else{
    cout << 0 << endl;
  }
}

Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10 ** 8)

def Z(): return int(input())
def ZZ(): return [int(_) for _ in input().split()]

def main():
    A, V = ZZ()
    B, W = ZZ()
    T = Z()
    print('YES' if abs(A-B) <= T * (V - W) else 'NO')

    return

if __name__ == '__main__':
    main()


Measured memory_bytes: 9176
#include<stdio.h>

#define N 100000
#define Q 50000

int S[N];
int T[Q];

int search(int *,int,int);

int main(){
  int i;
  int n,q;
  int C=0;

  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&S[i]);
  }
  scanf("%d",&q);
  for(i=0;i<q;i++){
    scanf("%d",&T[i]);
  }

  for(i=0;i<q;i++){
    if(search(S,n,T[i])==1) C++;
  }

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

  return 0;
}

int search(int *S,int n,int t){
  int i;
  int middle,left=0,right=n;

  while(left<right){
    middle=(left+right)/2;
    if(S[middle]==t) return 1;
    else if(t<S[middle]) right=middle;
    else if(t>S[middle]) left=middle+1;
  }
  return 0;
}



Measured memory_bytes: 2304
#include <iostream>

using namespace std;
long long N, W;
long long w[1005];
long long v[1005];
long long F[1005][100005];

int DeQuy(long long k, long long i)
{
    long long a;
    if(i==0) a=1; else a=0;
    for(long long j=1; j<=W; j++)
    {
        if(j>=w[k])
        F[i][j]=max(F[a][j],F[a][j-w[k]]+v[k]);
        else F[i][j]=F[a][j];
    }
    if(k!=N)
    DeQuy(k+1, a);
}

int main()
{
    cin>>N>>W;
    for(long long i=1; i<=N; i++)
    {
        cin>>w[i]>>v[i];
    }
    DeQuy(1, 0);
    if(F[1][W]>F[0][W]) cout<<F[1][W]; else cout<<F[0][W];
    return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define ll long long

using namespace std;

int main(){
    ll l,r;
    ll ans=2019;
    ll i,j;
    cin >> l >> r;
    for(i=l;i<=r;i++){
        if(i%2019==0){
            cout << 0 << endl;
            return 0;
        }
    }
    l%=2019;
    r%=2019;
    if(r<=l){
        r+=2019;
    }
    for(i=l;i<=r;i++){
        for(j=i+1;j<=r;j++){
            if((i*j)%2019<ans){
                //cout << i << " " << j << endl;
                //cout << i*j << endl;
                ans=(i*j)%2019;
                //cout << 111111111111111 << endl;
            }
        }
    }
    cout << ans << endl;
    
    return 0;
}


Measured memory_bytes: 256
import collections


n = int(input())
A = input().split()
d = collections.defaultdict(int)
for a in A:
    d[a] += 1
if n == 1:
    print(1)
    exit()
if n % 2 != 0:
    if '0' not in d or d['0'] != 1:
        print(0)
        exit()
    for i in range(2, n, 2):
        if str(i) not in d or d[str(i)] != 2:
            print(0)
            exit()
else:
    if '0' in d:
        print(0)
        exit()
    for i in range(1, n, 2):
        if str(i) not in d or d[str(i)] != 2:
            print(0)
            exit()
print(2**(n//2) % (10**9+7))



Measured memory_bytes: 15216
#include <bits/stdc++.h>
using namespace std;
#define REP(i, s, n) for (int i = s; i < n; ++i)
#define rep(i, n) REP(i, 0, n)
#define SORT(c) sort((c).begin(), (c).end())
#define SORT_INV(c) sort((c).begin(), (c).end(), greater<int>())
#define IINF INT_MAX
#define LLINF LLONG_MAX
#define DEBUG false
#define LL long long
#define STEP 0.0005
// sort(a.begin(), a.end(), std::greater<int>());

int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
int main()
{
  int a,b,c,d;
  cin>>a>>b>>c>>d;
  cout<<min(a,b)+min(c,d)<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define H ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define ll long long
#define ld long double
using namespace std;
const ll  mod = 998244353;

    int frq[200001];

int main()
{
    H
    int n, k;
    cin >> n >> k;
    int x;
   for (int i = 0; i < n; i++){
        cin >> x;
        frq[x]++;
    }
    priority_queue<int> pq;
    for (int i = 1; i <= n; i++){
        if (frq[i]) {
            pq.push(-frq[i]);
        }

    }
    int ans = 0;
    while (pq.size() > k){
        ans += -pq.top();
        pq.pop();
    }
    cout << ans;
    return 0 ;
}


Measured memory_bytes: 2168
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <queue>
#include <map>
#include <numeric>
#include <unordered_map>
#include <iomanip>
#include <functional>
#include <bitset>
#include <complex>

#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define repi(i,a,b) for(ll i=ll(a);i<ll(b);i++)
#define all(x) (x).begin(),(x).end()

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

typedef long long ll;

using namespace std;


int  main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll n,s;
  cin>>n>>s;
  ll t=abs(n-s);
  ll l=sqrt(t);
  auto dsum=[&](ll a,ll b){ll res=0;while(a>0){res+=a%b;a/=b;}return res;};
  ll res=1e12;
  if(s==n){cout<<s+1<<endl;return 0;}
  repi(i,1,l+1)
  {
    if(t%i==0)
    {
      if(dsum(n,i+1)==s)
      {
        cout<<i+1<<endl;
        return 0;
      }
      if(dsum(n,(t/i)+1)==s)
      {
        chmin(res,(t/i)+1);
      }
    }
  }
  if(res==(ll)1e12)cout<<-1<<endl;
  else cout<<res<<endl;

  return 0;

}


Measured memory_bytes: 256
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        BStringPalindrome solver = new BStringPalindrome();
        solver.solve(1, in, out);
        out.close();
    }

    static class BStringPalindrome {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            String s = in.next();
            String[] s1 = s.split("");
            String[] s2 = s.substring(0, (int) ((s.length() - 1) / 2)).split("");
            String[] s3 = s.substring((int) ((s.length() + 3) / 2) - 1, s.length()).split("");
            if (check(s1) && check(s2) && check(s3)) {
                out.println("Yes");
            } else {
                out.println("No");
            }
        }

        public boolean check(String[] arr) {
            for (int i = 0; i < arr.length / 2; i++) {
                if (!arr[i].equals(arr[arr.length - 1 - i])) {
                    return false;
                }
            }
            return true;
        }

    }
}



Measured memory_bytes: 23764
function kock(n, p1, p2){
    if(n < 1) return;

    const s = {
        x: (2 * p1.x + 1 * p2.x)  / 3,
        y: (2 * p1.y + 1 * p2.y)  / 3,
    };

    const t = {
        x: (1 * p1.x + 2 * p2.x)  / 3,
        y: (1 * p1.y + 2 * p2.y)  / 3,
    };

    const u = {
        x: (t.x - s.x) * Math.cos(60 * (Math.PI / 180))  - (t.y - s.y) * Math.sin(60 * (Math.PI / 180)) + s.x,
        y: (t.x - s.x) * Math.sin(60 * (Math.PI / 180)) + (t.y - s.y) * Math.cos(60 * (Math.PI / 180)) + s.y
    };

    kock(n-1, p1, s);
    console.log(s.x, s.y);
    kock(n-1, s, u);
    console.log(u.x, u.y);
    kock(n-1, u, t);
    console.log(t.x, t.y);
    kock(n-1, t, p2);
}

function main(stdin){
    const n = stdin.split('\n').shift();
    const p1 = {x: 0, y: 0};
    const p2 = {x: 100, y: 0};

    console.log(p1.x, p1.y);
    kock(n, p1, p2);
    console.log(p2.x, p2.y);
}


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



Measured memory_bytes: 22080
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <math.h>
using namespace std;

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

	vector<int> vec(N);
	
	for (int i = 0; i < N; i++) {
		cin >> vec[i];
	}
;	sort(vec.begin(), vec.end());
	reverse(vec.begin(), vec.end());

	cout << vec[0] - vec[N - 1] << endl;

}



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

using namespace std;


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

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

const long long INF = 1LL << 60;
const int MAX_N = 1e6;


int main() {
  int N;
  cin >> N;
 
  vector<int64_t> dp(MAX_N);
  for (int i = 0; i < MAX_N; ++i) dp.at(i) = INF;

  vector<int> h(N+2);
  for (int i=0; i<N; i++) {
    cin >> h.at(i);
  }
  dp.at(0) = 0;
  for (int i=0; i<N; i++) {
    chmin(dp.at(i+1), dp.at(i) + abs(h.at(i) - h.at(i+1)));
    chmin(dp.at(i+2), dp.at(i) + abs(h.at(i) - h.at(i+2)));
  }
  cout << dp.at(N-1) << endl;
}

Measured memory_bytes: 8448
n, x = map(int, input().split())

# 高さをa, パティ枚数をpとする
a , p = [1], [1]
for i in range(n):
    a.append(a[i]*2 + 3)
    p.append(p[i] * 2 + 1)

def f(n,x):
    if n==0:
        return 0 if x <= 0 else 1
    elif x <= 1 + a[n-1]:
        return f(n-1,x-1)
    else:
        return p[n-1] + 1 + f(n-1, x-a[n-1]-2)

print(f(n,x))

Measured memory_bytes: 3064
#include "bits/stdc++.h"
#include <random>
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int D;

int c[27];
int s[366][27];
int last[27];

vector<int> ans;
ll ans_score;

ll calcScore(){
    rep(i,27) last[i] = 0;
    ll score = 0;
    for(int d = 1; d <= D; ++d){
        int t = ans[d];
        score += s[d][t];
        last[t] = d;
        for(int i = 1; i <= 26; ++i){
            score -= c[i] * (d - last[i]);
        }
    }
    return score;
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> D;
    for(int i = 1; i <= 26; ++i) cin >> c[i];
    for(int i = 1; i <= D; ++i){
        for(int j = 1; j <= 26; ++j){
            cin >> s[i][j];
        }
    }
    ans.resize(D, 1);
    ans_score = calcScore();
    //local search
    std::random_device rnd;
    std:: mt19937 mt(rnd());
    std::uniform_int_distribution<> randD(1,D);
    rep(_,8000){
        int d = randD(mt);
        for(int q = 1; q <= 26; ++q){
            int old = ans[d];
            ans[d] = q;
            ll score = calcScore();
            if(ans_score > score) ans[d] = old;
            else ans_score = score;
        }
    }
    rep(i,D) cout << ans[i] << endl;
    return 0;
}


Measured memory_bytes: 3632
#include <iostream>

using namespace std;

int main()
    {
    ios_base :: sync_with_stdio(false);
    cin.tie(NULL);
    string S,T;
    int c=0;
    cin>>S;
    cin>>T;
    for(int i=0; S[i]!='\0'; i++)
        {
        if(S[i] != T[i] )
            c++;
        }
    cout << c << endl;
    return 0;
    }


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

#define REP(i, x, n) for (int i = x; i < (int)(n); ++i)
#define RREP(i, x, n) for (int i = x - 1; i >= (int)(n); --i)
#define rep(i, n) REP(i, 0, n)
#define rrep(i, n) RREP(i, n, 0)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define MAX 1e9 + 7

using namespace std;

int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a * b / gcd(a, b); }

int main(void)
{
    int n, a;
    cin >> n >> a;
    ((n % 500 <= a) ? puts("Yes") : puts("No"));
    return 0;
}

Measured memory_bytes: 256
#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, INF=mod*mod*3LL;
#define doublecout(a) cout<<fixed<<setprecision(10)<<a<<endl;

ll n, m, x, y, sum, mx, a[100005], s[200005];
int main() {
	cin >> n >> m;
	for(int i=1; i<=n; i++) cin >> a[i];
	for(int i=1; i<n; i++) {
		x = a[i]; y = a[i+1];
		if(x > y) y += m;
		sum += y-x;
		if(y-x <= 1) continue;
		s[x+2]++;
		s[y+1] -= y-x;
		s[y+2] += y-x-1;
	}
	for(int i=1; i<=2*m; i++) s[i] += s[i-1];
	for(int i=1; i<=2*m; i++) s[i] += s[i-1];
	for(int i=1; i<=m; i++) mx = max(mx, s[i] + s[i+m]);
	cout << sum - mx << endl;
	return 0;
}


Measured memory_bytes: 2560
using System;
using System.Collections.Generic;
using System.Linq;

namespace AtCoder
{
    class Program
    {
        private const int M = 1000000007;
        private static string Read() { return Console.ReadLine(); }
        private static int ReadInt() { return int.Parse(Read()); }
        private static long ReadLong() { return long.Parse(Read()); }
        private static double ReadDouble() { return double.Parse(Read()); }
        private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
        private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
        private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }

        static IEnumerable<int> Solve(int n, int[] a)
        {
            int[] b = new int[n];
            for (int i = 0; i < n; ++i)
            {
                int j = (i % 2 == 0) ? i / 2 : n - 1 - i / 2;
                b[j] = a[n - 1 - i];
            }
            return b;
        }
        static void Main(string[] args)
        {
            int n = ReadInt();
            int[] a = ReadInts();
            Console.WriteLine(string.Join(" ", Solve(n, a)));
        }
    }
}


Measured memory_bytes: 48056
n, k = map(int, input().split())

MOD = 10 ** 9 + 7

ans = 0
num = 0

for i in range(1, n + 2):
  num += (i - 1)
  if i >= k:
    # print(num, i, i * n - 2 * num + 1)
    ans += max(i * n - 2 * num + 1, 1) 
    ans = ans % MOD

print(ans)

Measured memory_bytes: 9192
#include <bits/stdc++.h>
using namespace std;
char x[1001][1001];
int main()
{
	int a,b;
	cin>>a>>b;
	for(int i=1;i<=a;i++)
		for(int j=1;j<=b;j++)
			cin>>x[i][j];
	for(int i=1;i<=a;i++)
	{
		for(int j=1;j<=b;j++)
		{
			int cnt=0;
			if(x[i+1][j+1]=='#')cnt++;
			if(x[i+1][j-1]=='#')cnt++;
			if(x[i+1][j]=='#')cnt++;
			if(x[i][j+1]=='#')cnt++;
			if(x[i][j-1]=='#')cnt++;
			if(x[i-1][j+1]=='#')cnt++;
			if(x[i-1][j]=='#')cnt++;
			if(x[i-1][j-1]=='#')cnt++;
			if(x[i][j]=='#'){cout<<'#';continue;}
			cout<<cnt;
			cnt=0;
		}
		cout<<'\n';
	}
	return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define FOR(i,a,b) for(int i =(a);i<(b);i++)
#define REP(i,n) for(int i=0;i<(n);i++)
#define REPm(i,n) for(int i=(n)-1;i>=0;i--)
#define REP1(i,n) for(int i=1;i<=(n);i++)
#define mp make_pair
typedef long long ll;
int main(){
    int A,B,C;
    cin >> A >> B >> C;
    if(A <= C && C <= B) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <climits>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <fstream>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <cassert>
#include <functional>

using namespace std;

#define LOG(...) printf(__VA_ARGS__)
//#define LOG(...)
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define RSORT(c) sort((c).rbegin(),(c).rend())
#define CLR(a) memset((a), 0 ,sizeof(a))

typedef long long ll;
typedef unsigned long long ull;
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vb> vvb;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

const int dx[] = { -1, 0, 1, 0 }; const int dy[] = { 0, 1, 0, -1 };

int main() {
	int n;
	string ns;
	getline(cin, ns);
	n = atoi(ns.c_str());
	while (n--){
		string s;
		getline(cin, s);
		for (int i = 1; i < 26; i += 2){
			if (i == 13)
				continue;
			REP(j, 26){
				string s2 = s;
				REP(k, s.length()){
					if ('a' <= s2[k] && s2[k] <= 'z'){
						s2[k] = 'a' + ((s2[k]-'a') * i + j) % 26;
					}
				}
				if (s2.find("that") != string::npos || s2.find("this") != string::npos){
					s = s2;
					i = j = 26;
				}
			}
		}
		cout << s << endl;
	}
}

Measured memory_bytes: 3172
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
	int N;
	cin >> N;
	vector<int> a(N+1, 1);
	for (int i = 2; i <= N; ++ i) {
		for (int j = i; j <= N; j += i) {
			++ a[j];
		}
	}
	ll res = 0;
	for (ll i = 1; i <= N; ++ i) res += i * a[i];
	cout << res << endl;
}


Measured memory_bytes: 42324
#include <bits/stdc++.h>
using namespace std;
#pragma GCC diagnostic ignored "-Wmissing-declarations"

#define FINAL_OUT(x) {cout << (x) << '\n'; exit(0);}

#define SHOW(x) std::cout << #x << " = " << x << std::endl;


int main()
{
//    freopen("in.txt", "r", stdin);
    //freopen("out.txt", "w", stdout);
    ios_base::sync_with_stdio(false);

    int n,m;
    cin >> n >> m;

    vector<vector<int> > a(n, vector<int>(m));
    for(auto& vec : a)
    for(int& x : vec)
        cin >> x, --x;

    int best = n;

    vector<int> mask(m);
    for(int t = 0; t < m; ++t)
    {
        vector<int> cnt(m);
        for(const auto& vec : a)
        for(int i = 0; i < m; ++i)
            if (mask[vec[i]] == 0)
            {
                ++cnt[vec[i]];
                break;
            }
        best = min(best, *max_element(begin(cnt), end(cnt)));
        mask[max_element(begin(cnt), end(cnt)) - begin(cnt)] = 1;
    }
    cout << best << endl;
}


Measured memory_bytes: 640
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace DubiousDocument2 {
    class Program {
        static void Main(string[] args) {
            var s = Console.ReadLine();
            var t = Console.ReadLine();
            var ssize = s.Length;
            var tsize = t.Length;
            var ANS = s.ToCharArray();
            var test1 = "ZZZZZZZZZZZZZZZZZZZZZZZ";
            var test2 = test1;
            for (int i = 0; i < ssize - tsize + 1; i++) {
                bool flag = true;
                for (int j = 0; j < tsize; j++) {
                    if (s[i + j] != t[j] && s[i + j] != '?') {
                        flag = false;
                        break;
                    }

                }
                if (flag) {
                    StringBuilder ans = new StringBuilder(s);
                    for (int j = 0; j < tsize; j++) {
                        ans[i + j] = t[j];
                    }
                    for (int j = 0; j < ssize; j++) {
                        if (ans[j] == '?') {
                            ans[j] = 'a';
                        }
                    }
                    var test3 = ans.ToString();
                    if (test2.CompareTo(test3) > 0) {
                        test2 = test3;
                    }
                }
            }
            if (test2 == test1) {
                Console.WriteLine("UNRESTORABLE");
            } else {
                Console.WriteLine(test2);
            }
        }
    }
}


Measured memory_bytes: 13140
#include<iostream>
#include<algorithm>
#include<map>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)

int n,m,a[1000];

map<int,int> c;

int main() {
    while(true) {
        cin >> n >> m;
        if(n == 0)break;
        rep(i,n){
            cin >> a[i];
            c[a[i]] = 0;
        }
        rep(i,n) {
            c[a[i]]++;
        }
        sort(a,a+n);

        int ans = -1;
        rep(i,n) {
            auto itr = upper_bound(a,a+n,m - a[i]);
            if(itr - a == 0) {
                continue;
            }
            itr--;
            if(*itr == a[i] && c[a[i]] < 2) {
                auto itr2 = lower_bound(a,a+n,a[i]);
                if(itr2 - a == 0) {
                    continue;
                }
                ans = max(ans,*(itr2 - 1) + a[i]);
                continue;
            }
            ans = max(ans,*itr + a[i]);
        }
        if(ans == -1)cout << "NONE" << endl;
        else cout << ans << endl;
    }

    return 0;
}


Measured memory_bytes: 3692
#include<iostream>
#include<cstdio>
#include<vector>
#include<map>
#include<string>
#include<algorithm>
#include<math.h>
#include<numeric>
#include<iomanip>

using namespace std;

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

const ll INF = 1e9;
const ll MOD = 1e9 + 7;

int main(){
	string s;
	cin >> s;
	if (s.length() == 2){
		if (s[0] == s[1]){
			cout << 1 << " " << 2 << endl;
		}
		else{
			cout << -1 << " " << -1 << endl;
		}
		return 0;
	}
	for (int i = 0; i < s.length() - 2; i++){
		if (s[i] == s[i + 1] || s[i] == s[i + 2] || s[i + 1] == s[i + 2]){
			cout << i + 1 << " " << i + 3 << endl;
			return 0;
		}
	}
	cout << -1 << " " << -1 << endl;
	return 0;
}


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

using namespace std;

int n;
int h[100010];
int dp[100010];

int main() {
    cin >> n;
    
    for (int i = 0; i < n; ++i) {
        cin >> h[i];
        dp[i] = 1e9;
    }
    
    dp[0] = 0;
    dp[1] = abs(h[0] - h[1]);
    for (int i = 0; i < n; ++i) {
        if(i) dp[i] = min(dp[i], dp[i - 1] + abs(h[i - 1] - h[i]));
        if(i - 2 >= 0) dp[i] = min(dp[i], dp[i - 2] + abs(h[i - 2] - h[i]));
    }
    cout << dp[n - 1] << "\n";
    return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (n); i++)
using ll = long long;
using ull = unsigned long long;
using P = pair<int,int>;
using PP = pair<int,pair<int,int>>;
using T = tuple<string,int,int>;
const ll INF = 1LL<<60;

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

  vector<int> m(n);
  int ans = n;
  for(int i = 0; i < n; i++){
    cin >> m[i];
    x -= m[i];
  }
  sort(m.begin(), m.end());
  ans += x / m[0];
  cout << ans << endl;
  return 0;
}


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

using namespace std;
typedef long long ll;

int gcd(int a, int b) {
    if (!b) return a;
    return gcd(b, a % b);
}

int main() {
    int x;
    cin >> x;
    int ans = 360 / gcd(360, x);
    cout << ans << "\n";
}


Measured memory_bytes: 3672
import Control.Monad
import Data.Maybe
import qualified Data.ByteString.Char8 as BS
import Data.List
import qualified Data.Vector as V
import qualified Data.Vector.Mutable as VM
import qualified Data.Vector.Unboxed as VU
import qualified Data.Vector.Unboxed.Mutable as VUM

readInt = fst . fromJust . BS.readInt
readIntList = map readInt . BS.words
getInt = readInt <$> BS.getLine
getIntList = readIntList <$> BS.getLine

main = do
    [n,k] <- getIntList
    ab <- replicateM (n-1) $ do
        [a,b] <- getIntList
        return (a-1,b-1)
    let edge = V.create $ do
           vec <- VM.replicate n []
           forM_ ab $ \(a,b) -> do
               VM.modify vec (a:) b
               VM.modify vec (b:) a
           return vec
    
    let result = VU.create $ do
            vec <- VUM.replicate n 0
            VUM.write vec 0 k
            let next = edge V.! 0
            forM_ (zip [k-1,k-2..] next) $ \(c,i) -> VUM.write vec i c
            let go [] = return ()
                go ((par,this):qs) = do
                    let children = filter (/= par) $ edge V.! this
                    forM_ (zip [k-2,k-3..] children) $ \(c,i) -> VUM.write vec i c
                    go (map (\i -> (this,i)) children)
                    go qs
            go (map (\i -> (0,i)) next)
            return vec

    let ans = VU.foldl' f 1 result
         where f a b | a >= 0 && b >= 0 = (a * b) `mod` 1000000007
                     | otherwise = 0
    print ans

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

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repr(i, n) for(int i = (int)(n); i >= 0; i--)
#define repm(i, m, n) for(int i = (int)(m); i < (int)(n); i++)
#define repmr(i, m, n) for(int i = (int)(n); i >= (int)(m); i--)
#define all(x) (x).begin(),(x).end()
#define inf 2e9
#define MOD 1000000007

using namespace std;
typedef long long int lli;
typedef long long ll;

int gcd(int x, int y){
  if(y == 0) return x;
  return gcd(y, x % y);
}

int main(){
    int n; cin >> n;
    vector<int> a(n); rep(i,n) cin >> a[i];

    int ans = a.front();
    repm(i,1,n){
        ans = gcd(ans,a[i]);
    }

    cout << ans << endl;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define GET_MACRO(_1, _2, _3, NAME, ...) NAME
#define _repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define _rep(i,n) _repl(i,0,n)
#define rep(...) GET_MACRO(__VA_ARGS__, _repl, _rep)(__VA_ARGS__)
#define mp(a,b) make_pair((a),(b))
#define pb(a) push_back((a))
#define all(x) (x).begin(),(x).end()
#define uniq(x) sort(all(x)),(x).erase(unique(all(x)),end(x))
#define fi first
#define se second
#define dbg(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
void _dbg(string){cout<<endl;}
template<class H,class... T> void _dbg(string s,H h,T... t){int l=s.find(',');cout<<s.substr(0,l)<<" = "<<h<<", ";_dbg(s.substr(l+1),t...);}
template<class T,class U> ostream& operator<<(ostream &o, const pair<T,U> &p){o<<"("<<p.fi<<","<<p.se<<")";return o;}
template<class T> ostream& operator<<(ostream &o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}

#define INF 1120000000

int solve(string &s){
  int n = s.size();

  int mask = 0;
  map<int,int> pos;
  vector<int> dp(n+1, INF);
  pos[0] = 0;
  dp[0] = 0;
  rep(p,n){
    mask = mask ^ (1<<(s[p]-'a'));
    rep(i,26){
      int nm = mask^(1<<i);
      if(pos.count(nm)==0) continue;
      int x = pos[nm];//dbg(p,x,bitset<26>(nm),i);
      dp[p+1] = min(dp[x]+1, dp[p+1]);
    }
    if(pos.count(mask)){
      dp[p+1] = min(dp[pos[mask]], dp[p+1]);
    }
    pos[mask] = p+1;
  }
  // dbg(dp);
  return max(dp[n], 1);
}

int main(){
  string s;
  cin>>s;
  int r = solve(s);
  reverse(all(s));
  cout << min(r, solve(s)) << endl;

  return 0;
}


Measured memory_bytes: 10628