akhauriyash/Code-Regression huggingface dataset:
// vim: set fdm=marker:
// {{{
#include <cstdio>
#include <iostream>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cassert>
#include <algorithm>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <map>
#include <utility>

using namespace std ;

typedef long long ll ;

// }}}

int a[55];

int main()
{
    int N;
    cin >> N;
    for(int i = 1 ; i <= N ; i++)
        scanf("%d", a+i);
    int mv = 0;
    int amv = 0;
    int mi;
    for(int i = 1 ; i <= N ; i++) {
        int av = abs(a[i]);
        if(av > amv) {
            amv = av;
            mv = a[i];
            mi = i;
        }
    }
    if(amv == 0)
        return 0*puts("0");
    printf("%d\n", N+N-1);
    if(mv < 0) {
        for(int i = 1 ; i <= N ; i++)
            printf("%d %d\n", mi, i);
        for(int i = N ; i-1 >= 1 ; i--)
            printf("%d %d\n", i, i-1);
    }
    else {
        for(int i = 1 ; i <= N ; i++)
            printf("%d %d\n", mi, i);
        for(int i = 1 ; i+1 <= N ; i++)
            printf("%d %d\n", i, i+1);
    }
    return 0;
}



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

int main(void)
{
	int n;
	int i, j1, j2, k, j;
	int sum;
	int su;
	int f;
	char num1[1000];
	char num2[1000];
	char ans[1000];
	
	scanf("%d", &n);
	
	for (i = 0; i < n; i++){
		scanf("%s", num1);
		scanf("%s", num2);
		j1 = strlen(num1);
		j1--;
		j2 = strlen(num2);
		j2--;
		k = 0;
		f = 0;
		su = 0;
		while (1){
			if (j1 < 0 && j2 < 0){
				break;
			}
			else if (j1 < 0){
				sum = (num2[j2] - '0');
			}
			else if (j2 < 0){
				sum = (num1[j1] - '0');
			}
			else {
				sum = (num1[j1] - '0') + (num2[j2] - '0');
			}
			ans[k] = sum;
			if (su == 1){
				ans[k]++;
				su = 0;
			}
			if (ans[k] > 9){
				if (j1 <= 0 && j2 <= 0){
					ans[k + 1] = 1;
					f = 1;
					ans[k] -= 10;
				}
				else {
					su = 1;
					ans[k] -= 10;
				}
			}
			k++;
			j1--;
			j2--;
		}
		
		if (f == 1){
			k++;
		}
		ans[k] = '\0';
		
		for (j = 0; j < k; j++){
			ans[j] += '0';
		}
		
		if (strlen(ans) > 80){
			printf("overflow\n");
		}
		else {
			for (k = strlen(ans) - 1; k >= 0; k--){
				printf("%c", ans[k]);
			}
			printf("\n");
		}
	}
	return (0);
}

Measured memory_bytes: 584
import math
a=input().split(" ")
x=0
for i in range(int(a[0])):
    b=input().split(" ")
    c=int(b[0])**2
    c1=int(b[1])**2
    c2=c+c1
    c2=math.sqrt(c2)
    if c2<=int(a[1]):
        x=x+1
    

print(x)




Measured memory_bytes: 69956
import sys
import numpy as np
read = sys.stdin.read
readline = sys.stdin.readline

N, C = map(int, readline().split())
xv = np.array(read().split(), np.int64).reshape(N, 2)
v = xv[:, 1]
x = xv[:, 0]

ax = C - x[::-1]
cx = x.copy()
cx[1:] = cx[1:] - cx[:-1]
acx = C - x
acx[:-1] = acx[:-1] - acx[1:]

clockwise = np.cumsum(v - cx)
anticlockwise = v - acx
anticlockwise = np.cumsum(anticlockwise[::-1])

con_max = np.maximum.accumulate(clockwise)
anti_max = np.maximum.accumulate(anticlockwise)

answer = [0, con_max[-1], anti_max[-1]]

clockwise = clockwise - x
anti_max = anti_max[::-1]
clockwise[:-1] = clockwise[:-1] + anti_max[1:]
anticlockwise = anticlockwise - ax
con_max = con_max[::-1]
anticlockwise[:-1] = anticlockwise[:-1] + con_max[1:]

answer.append(anticlockwise.max())
answer.append(clockwise.max())

print(max(answer))

Measured memory_bytes: 38964
#include <bits/stdc++.h>
using namespace std;
#define MOD (long long int)(1e9+7)
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define FOR(i,a,b) for(int i=a; i<(int)(b); i++)
#define ALL(x) (x).begin(),(x).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define CLR(a) memset((a), 0 ,sizeof(a))
#define PB push_back
#define MP make_pair
#define SP << " " <<
const int INF = 1001001001;
const ll LINF = 100100100100100100;
#define EPS (1e-10)
const long double PI  = acos(-1.0L);
typedef pair<int,int> PII;
typedef pair<ll,ll> PLL;
typedef pair<double,double> PDD;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VL;
#define chmax(a,b) a = (((a)<(b))?(b):(a))
#define chmin(a,b) a = (((a)>(b))?(b):(a))

__attribute__((constructor))
void initial(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);
}

signed main(){
	ll n,a,b; cin>>n>>a>>b;
	ll q[3]; CLR(q);
	rep(i,n){
		ll p; cin>>p;
		if(p<=a) q[0]++;
		else if(p>=b+1) q[2]++;
		else q[1]++;
	}
	int ans=n;
	rep(i,3) chmin(ans,q[i]);
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<stdint.h>
#include<inttypes.h>
#include<string.h>

typedef int32_t i32;

int cmp (const void *a, const void *b) {
  i32 d = *(i32 *)a - *(i32 *)b;
  return d == 0 ? 0 : d < 0 ? -1 : 1;
}

void run (void) {
  i32 n, k;
  scanf ("%" SCNi32 "%" SCNi32, &n, &k);
  i32 *a = (i32 *) calloc (n, sizeof (i32));
  for (i32 i = 0; i < n; ++i) {
    scanf ("%" SCNi32, a + i);
  }
  qsort (a, n, sizeof (i32), cmp);
  uint8_t *dp = (uint8_t *) calloc (k, sizeof (uint8_t));
  i32 l = -1;
  i32 r = n;
  while (r - l > 1) {
    i32 m = (l + r) / 2;
    memset (dp, 0, sizeof (uint8_t) * k);
    dp[0] = 1;
    for (i32 i = 0; i < n; ++i) {
      if (i == m) continue;
      for (i32 j = k - 1; j >= a[i]; --j) {
	dp[j] |= dp[j - a[i]];
      }
    }
    i32 i = k - 1;
    for (; !dp[i]; --i);
    if (i + a[m] >= k) {
      r = m;
    } else {
      l = m;
    }
  }
  printf ("%" PRIi32 "\n", r);
}

int main (void) {
  run();
  return 0;
}


Measured memory_bytes: 252
#include<cstdio>
#include<algorithm>
using namespace std;
struct Horizontal{int h, p, q;};
static const int MAX_N = 100;
static const int MAX_M = 1000;

int n, m, a;
Horizontal l[MAX_M];
int num[MAX_N];

bool comp(const Horizontal &a, const Horizontal &b){
	return a.h > b.h;
}

int main(){
	for(;;){
		scanf("%d %d %d", &n, &m, &a);
		if(n == 0 && m == 0 && a == 0) break;
		a--;
		for(int i = 0; i < n; i++) num[i] = i;
		for(int i = 0; i < m; i++){
			scanf("%d %d %d", &l[i].h, &l[i].p, &l[i].q);
			l[i].p--; l[i].q--;
		}
		sort(l, l + m, comp);
		for(int i = 0; i < m; i++) swap(num[l[i].p], num[l[i].q]);
		for(int i = 0; i < n; i++){
			if(num[i] == a){
				printf("%d\n", i + 1);
				break;
			}
		}
	}
	return 0;
}


Measured memory_bytes: 2808
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound, __gcd, count, find, next_permutation
#include <bitset>    // bitset
#include <deque>     // deque
#include <iomanip>   // setprecsion
#include <iostream>  // cout, endl, cin
#include <map>       // map
#include <queue>     // queue, priority_queue
#include <set>       // set
#include <stack>     // stack
#include <string>    // string, to_string, stoi
#include <tuple>     // tuple, make_tuple
#include <utility>   // pair, make_pair
#include <vector>    // vector

#include <cassert> // assert
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <cmath>  // abs, sin, cos, tan
#include <ctime> // clock

// __builtin_popcountll

using namespace std;
using Graph = vector<vector<int>>;

#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define rrep(i, n) for (ll i = (n - 1); i >= 0; --i)
#define blank(ans) cout << (ans) << " ";
#define mp(p, q) make_pair(p, q)
#define mt(p, q, r) make_tuple(p, q, r)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef string str;

typedef vector<ll> vll;
typedef vector<ld> vd;
typedef vector<bool> vb;
typedef vector<char> vc;
typedef vector<str> vs;
typedef vector<vector<ll>> vvll;
typedef vector<vector<ld>> vvd;
typedef vector<vector<bool>> vvb;
typedef vector<vector<char>> vvc;
typedef vector<vector<str>> vvs;
typedef vector<pair<ll, ll>> vpll;
typedef vector<tuple<ld, ll, ll>> vtll;

const ld PI = acos(-1.0);
const ll MAX = 9000000000000000000;
const ll MIN = -9000000000000000000;
const ld DMAX = 4500;
const ld DMIN = -4500;
const ll MOD = 1000000007;

template <typename T>
void fin(T a)
{
  cout << a << endl;
  exit(0);
}

ll GetDigit(ll num)
{
  return log10(num) + 1;
}

vll key;

//素因数分解
map<ll, ll> prime_factor(ll n)
{
  map<ll, ll> ret;
  for (ll i = 2; i * i <= n; i++)
  {
    while (n % i == 0)
    {
      //含まれる素数を使用する際
      if (!ret.count(i)) key.pb(i);
      ret[i]++;
      n /= i;
    }
  }
  if (n != 1)
  {
    //含まれる素数を使用する際
    if (!ret.count(n)) key.pb(n);
    ret[n] = 1;
  }
  return ret;
}

void Main()
{
  ll n; cin >> n;
  vll a(n); rep(i, n) cin >> a[i];
  sort(all(a));
  ll tmp = 1;
  if(a[0] == 0) fin(0);
  else
  {
    rep(i, n)
    {
      ll A, B;
      A = ((tmp % MOD) * (a[i] % MOD)) % MOD;
      tmp *= a[i];
      if(A != (tmp % MOD)) fin(-1);
    }
    if(tmp > 1000000000000000000) fin(-1);
    fin(tmp);
  }
  return;
}

//前処理
int main()
{
  //int ti = clock();
  //srand((unsigned)time(NULL));
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout << fixed << setprecision(20); //高精度少数表示
  //cout << setfill('0') << internal << setw(4); //0埋め４桁
  Main();
  //cout << 1.0 * (clock() - ti) / CLOCKS_PER_SEC << endl; // 実行時間計測
  return 0;
}

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

const int MOD = 1000000007;
struct modint {
  long long val;
  modint(long long val=0) : val((val % MOD + MOD) % MOD){}
  modint operator-() const { return modint(-val); }
  modint& operator+=(const modint a) { if ((val += a.val)     >= MOD) val -= MOD; return *this; }
  modint& operator-=(const modint a) { if ((val += MOD-a.val) >= MOD) val -= MOD; return *this; }
  modint& operator*=(const modint a) { (val *= a.val) %= MOD; return *this; }
  modint operator+(const modint a) const { return (modint)*this += a; }
  modint operator-(const modint a) const { return (modint)*this -= a; }
  modint operator*(const modint a) const { return (modint)*this *= a; }
  modint pow(long long n) const { modint r(1), m(val); while (n > 0) { if (n & 1) {r *= m;} m *= m; n >>= 1; } return r; }
  modint inv() const { return pow(MOD-2); }
  modint& operator/=(const modint a) { return (*this) *= a.inv(); }
  modint operator/(const modint a) const { return (modint)*this /= a; }
  bool operator==(const modint &p) const { return val == p.val; }
  bool operator!=(const modint &p) const { return val != p.val; }
  friend ostream &operator<<(ostream &os, const modint &p) { return os << p.val; }
  friend istream &operator>>(istream &is, modint &a) { long long t; is >> t; a = modint(t); return (is); }
};

struct mod_combination {
  /* initialize: O(n) */
  /* choose    : O(1) */
  vector<modint> fact, fact_inv, inv;
  mod_combination(int n) : fact(n, 1), fact_inv(n, 1), inv(n, 1) {
    for (int i = 2; i < n; i++) {
      fact[i] = fact[i - 1] * i;
      inv[i] = -inv[MOD % i] * (MOD / i);
      fact_inv[i] = fact_inv[i - 1] * inv[i];
    }
  }
  modint choose(int n, int k) { return fact[n] * fact_inv[k] * fact_inv[n - k]; }
};

int N,K;
int A[100000];

signed main() {
  cin >> N >> K;
  for(int i=0; i<N; i++) cin >> A[i];
  sort(A, A+N);
  mod_combination mc(N);

  modint ans = 0;

  // 0    1    2   3   4  5
  //         2C2 3C2 4C2 5C2
  // 0    0    1   3   6  10
  // 10   6    3   1   0   0
  // 5C2 4C2 3C2 2C2
  for(int i=0; i<N; i++) {
    if(i     >= K-1) ans += modint(A[i]) * mc.choose(i, K-1);
    if(N-1-i >= K-1) ans -= modint(A[i]) * mc.choose(N-1-i, K-1);
  }
  cout << ans << endl;

}


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

using namespace std;

#define DUMP(x) std::cerr << (#x) << " = " << (x) << "\n"
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define REP(i, k, n) for (int i = (k); i < (int)(n); ++i)
#define ALL(r) r.begin(), r.end()
#define YES puts("YES")
#define Yes puts("Yes")
#define NO puts("NO")
#define No puts("No")
#define IMP puts("IMPOSSIBLE")
#define Imp puts("Impossible")
#define imp puts("impossible")
#define M1 puts("-1")
#define pb push_back

template <typename T>
ostream &operator<<(ostream &os, vector<T> &v)
{
    os << "{";
    rep(i, v.size()) os << v[i] << (i == (int)v.size() - 1 ? "" : ", ");
    os << "}";
    return os;
}
template <typename T>
T dup(T x, T y)
{
    return (x + y - 1) / y;
};
template <typename A, size_t N, typename T>
inline void arrayFill(A (&array)[N], const T &val) { std::fill((T *)array, (T *)(array + N), val); }

using ll = int64_t;
using vint = vector<int32_t>;
using vvint = vector<vint>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vstr = vector<string>;
using pint = pair<int32_t, int32_t>;
using pll = pair<ll, ll>;
using setint = set<int32_t>;
using setstr = set<string>;
using qint = queue<int32_t>;
using qpint = queue<pint>;

constexpr std::int32_t INF = 1001001001;
constexpr std::int64_t LINF = 1001001001001001001;

template <typename T>
vector<pair<T, ll>> rle(vector<T> v)
{
    vector<pair<T, ll>> ret;
    ret.reserve(v.size() / 2);
    for (const auto x : v)
    {
        if (ret.empty() || ret.back().first != x)
        {
            ret.emplace_back(x, 1);
        }
        else
        {
            ++ret.back().second;
        }
    }
    return ret;
}
vector<pair<char, ll>> rle(string s)
{
    vector<pair<char, ll>> ret;
    ret.reserve(s.size() / 2);
    for (const auto c : s)
    {
        if (ret.empty() || ret.back().first != c)
        {
            ret.emplace_back(c, 1);
        }
        else
        {
            ++ret.back().second;
        }
    }
    return ret;
}

void Main()
{
    int n;
    cin >> n;
    vint a(n);
    rep(i, n) cin >> a[i];
    sort(ALL(a));
    auto v = rle(a);
    int cnt = 0;
    rep(i, v.size())
    {
        if (v[i].first <= v[i].second)
        {
            cnt += v[i].first;
        }
    }
    cout << a.size() - cnt << endl;
}

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


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

int main() {
  long long A,B,K;
  cin >> A >> B >> K;
  if(A+B <= K){
    cout << "0 0" << endl;
    return 0;
  }
  else if(K<A){
    cout << A-K << " " << B << endl;
    return 0;
  }
  else{
    cout << 0 << " " << B-(K-A) << endl;
    return 0;
  }
}

Measured memory_bytes: 3624
#include <iostream>
#include <string>
#include <algorithm>

using namespace std;

int main() {
    string s;
    cin >> s;
    string s2(s);
    reverse(s.begin(), s.end());
    if (s2 == s) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}


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

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; }

using ll = long long;

const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int INF = 1<<30;
const ll mod = 1000000007LL;

int main() {
  int N,K;
  cin>>N>>K;
  vector<int> v(N);
  for(int i = 0; i < N; i++) cin>>v[i];
  vector<int> ans = v;
  vector<int> X(N,0);
  for(int i = 0; i < K; i++){
    vector<int> w(N,0);
    vector<int> Y(N,0);
    for(int j = 0; j < N; j++){
      w[max(0,j-ans[j])]++;
      if(j+ans[j]+1<N) w[j+ans[j]+1]--;
    }
    for(int j = 0; j < N; j++){
      Y[max(0,j-X[j])]++;
      if(j+X[j]+1<N) Y[j+X[j]+1]--;
    }
    for(int j = 0; j < N; j++) {
      if(j!=0)w[j]=w[j]+w[j-1];
    }
    for(int j = 0; j < N; j++) {
      if(j!=0)Y[j]=Y[j]+Y[j-1];
    }
    ans = w;
    X=Y;
    if(X[0]==N) break;
  }
  for(auto x:ans) cout<<x<<" ";
  cout<<endl;
}

Measured memory_bytes: 7120
#include <iostream>
#include <stdio.h>
#include <string>

using namespace std;

int main() {
  string str;
  char *numStr;
  int num;
  cin >> num;

  str = to_string(num).c_str();

  char c1 = str[0];
  char c2 = str[1];
  char c3 = str[2];

  if(c1=='7' || c2=='7' || c3=='7'){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
  
  return 0;
}

Measured memory_bytes: 3696
package main

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

var scanner = bufio.NewScanner(os.Stdin)

func main() {
	two := make([]float64, 12)
	flag := make([]int, 12)
	for i := 0; i < 12; i++ {
		two[i] = math.Pow(2.0, 7.0-float64(i))
	}
	for scanner.Scan() {
		n, _ := strconv.ParseFloat(scanner.Text(), 64)
		if n < 0 {
			break
		}
		for i := 0; i < 12; i++ {
			flag[i] = 0
			if n >= two[i] {
				n -= two[i]
				flag[i] = 1
			}
		}
		if n < 10e-10 {
			i := 0
			for i < 12 {
				fmt.Printf("%d", flag[i])
				if i == 7 {
					fmt.Printf(".")
				}
				i++
			}
			fmt.Printf("\n")
		} else {
			fmt.Println("NA")
		}
	}
}


Measured memory_bytes: 1112
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <cassert>
using namespace std;
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
typedef vector<int> VI;
typedef long long ll;
typedef pair<int,int> PII;
const ll mod=998244353;
ll powmod(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;}
// head

const int N=101000;
char s[N];
ll fac[N*5],fnv[N*5],fl[N],fr[N];
VI u,d,l,r;
int n,m,val[N],az=1;
VI readv(int n) {
	scanf("%s",s);
	VI x;
	rep(i,0,n) {
		x.pb(s[i]-'0');
		if (s[i]!='0') az=0;
	}
	return x;
}
ll comb(int x,int y) {
	assert(y>=0&&x>=y);
	return fac[x]*fnv[x-y]%mod*fnv[y]%mod;
}
ll gao(VI u,VI d,VI l,VI r) {
	bool emp=1;
	n=SZ(u); m=SZ(l);
	rep(i,0,n) {
		if (u[i]!=0||d[i]!=0) emp=0;
	}
	if (emp) return 0;
	int sl=0,sr=0;
	rep(i,0,m) {
		if (l[i]) sl++;
		if (r[i]) sr++;
	}
	rep(pl,0,n) val[pl]=u[pl]+d[pl];
	ll ret=0;
	int lu=0,ld=0;
	rep(k,0,n) {
		if (sl==0) { if (lu+ld!=0) fl[k]=0; else fl[k]=1; }
		else fl[k]=comb(lu+ld+sl-1,sl-1);
		lu+=u[k], ld+=d[k];
	}
	int ru=0,rd=0;
	per(k,0,n) {
		if (sr==0) { if (ru+rd!=0) fr[k]=0; else fr[k]=1; }
		else fr[k]=comb(ru+rd+sr-1,sr-1);
		ru+=u[k], rd+=d[k];
	}
	ll tmpl=0;
	rep(pl,0,n) if (val[pl]>=1) {
		tmpl=(tmpl+fl[pl])%mod;
		if (val[pl]==2) tmpl=tmpl*2%mod;
		ret=(ret+tmpl*fr[pl])%mod;
	}
/*	rep(pl,0,n) rep(pr,pl,n) if (val[pl]>=1&&val[pr]>=1) {
		ll pw=0;
		rep(k,pl,pr+1) pw+=max(val[k]-1,0);
		pw=powmod(2,pw);
		printf("%d %d %lld\n",pl,pr,pw*fl[pl]*fr[pr]);
		ret=(ret+pw*fl[pl]%mod*fr[pr])%mod;
	}*/
	return ret;
}
int main() {
	fac[0]=fnv[0]=1;
	scanf("%d%d",&n,&m);
	rep(i,1,500001) {
		fac[i]=fac[i-1]*i%mod;
		fnv[i]=powmod(fac[i],mod-2);
	}
	u=readv(n);
	d=readv(n);
	l=readv(m);
	r=readv(m);
	if (az) { puts("1"); return 0;}
	printf("%lld\n",(gao(u,d,l,r)+gao(l,r,u,d))%mod);
}


Measured memory_bytes: 14968
#include <bits/stdc++.h>
#define fort(i,n) for (int i = 1; i <= n; ++i)
#define ll long long
#define pi pair<int,int>
#define sz size()
#define er erase
#define fr first
#define sc second
using namespace std;

int x,y;

int main()
{
    cin >> x >> y;
    cout << x+y/2;
}


Measured memory_bytes: 256
/*総当たり*/
#include<bits/stdc++.h>
using namespace std;

vector<int> n_A(20);
int n=0;

int solve(int i,int m){
	if(m == 0) return 1;
	if(i >= n) return 0;
	
	int res = solve(i+1,m) || solve(i+1,m - n_A.at(i));
	return res;
	
}

int recComb(vector<int> &a,int b){
		//cout << a.at(1) << endl;
		int i=0,j=0;
		for(i=0;i<n;i++){
			if(solve(0,b)) return 1;
			else return 0;
		}
		
}


int main(){
	vector<int> m_i(200);
	int q;
	cin >> n;
	for(int i=0;i<n;i++)cin >> n_A.at(i);
	cin >> q;
	for(int i=0;i<q;i++)cin >> m_i.at(i);
	
	int i=0;
	while(i<q){
 	  if(recComb(n_A,m_i.at(i)))cout << "yes" << endl;
	  else cout << "no" << endl;
	  i++;
	}
}



Measured memory_bytes: 3116
import java.io.IOException;
import java.io.InputStream;
import java.util.NoSuchElementException;
import java.lang.Math;

public class Main {
	public static void main(String[] args) {
		FS reader = new FS();
		// write reader
		int K = reader.nextInt();
		int X = reader.nextInt();
		solver(K, X);
	}
	
	public static void solver(int K, int X) {
		// write logic
		for (int i=X-K+1; i<X+K; i++) {
		    System.out.print(i);
		    if (i != i-K-1) System.out.print(" ");
		}
	}
	
	// Read Class
	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: 21204
using System;
using System.Linq;

namespace arc079_a
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] x = Console.ReadLine().Split().Select(int.Parse).ToArray();
            x[0]++;
            bool[,] d = new bool[x[0], 2];
            for (int i = 0; i < x[1]; i++)
            {
                int[] a = Console.ReadLine().Split().Select(int.Parse).ToArray();
                Array.Sort(a);
                if (a[0] == 1) d[a[1], 0] = true;
                if (a[1] == x[0] - 1) d[a[0], 1] = true;
            }
            bool ret = false;
            for (int i = 0; i < x[0]; i++)
            {
                if (d[i, 0] && d[i, 1]) ret = true;
            }
            Console.WriteLine(ret ? "POSSIBLE" : "IMPOSSIBLE");
        }
    }
}

Measured memory_bytes: 17632
N,M = [int(i) for i in input().split()]

K = [[int(i) for i in input().split()] for i in range(N)]

sekishugo = set(range(1,M+1))
for k in range(N):
  new_set = set(K[k][1:])
  sekishugo = sekishugo & new_set
  
print(len(sekishugo))

Measured memory_bytes: 3060
package main

import (
	"fmt"
	"sort"
)

type DirRange []uint

func (a DirRange) Len() int           { return len(a) }
func (a DirRange) Swap(i, j int)      { a[i], a[j] = a[j], a[i] }
func (a DirRange) Less(i, j int) bool { return a[i] < a[j] }

func main() {
	var N, M uint
	fmt.Scanf("%d%d", &N, &M)
	hash := make([]uint, M)
	for i := uint(0); i < M; i++ {
		var Pi, Yi uint
		fmt.Scanf("%d%d", &Pi, &Yi)
		hash[i] = Pi*100000*1000000000 + (Yi-1)*100000 + i
	}
	sort.Sort(DirRange(hash))
	Pl := uint(0)
	count := uint(0)
	for i := uint(0); i < M; i++ {
		Pi := hash[i] / 100000 / 1000000000
		j := hash[i] % 100000
		if Pi > Pl {
			Pl = Pi
			count = 0
		}
		hash[i] = j*1000000*1000000 + Pi*1000000 + count + 1
		count++
	}
	sort.Sort(DirRange(hash))
	for i := uint(0); i < M; i++ {
		fmt.Printf("%012d\n", hash[i]%1000000000000)
	}
	return
}


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

int main() {
  string s;
  cin >> s;
  if (s == "SUN") {
    cout << 7 << endl;
    return 0;
  }
  if (s == "MON") {
    cout << 6 << endl;
    return 0;
  }
  if (s == "TUE") {
    cout << 5 << endl;
    return 0;
  }
  if (s == "WED") {
    cout << 4 << endl;
    return 0;
  }
  if (s == "THU") {
    cout << 3 << endl;
    return 0;
  }
  if (s == "FRI") {
    cout << 2 << endl;
    return 0;
  }
  if (s == "SAT") {
    cout << 1 << endl;
    return 0;
  }
}

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

namespace AtCoder2 {
	class Program {
		static void Main(string[] args) {
			var inputArray = retreiveLongArray();
			var inputCount = 1;

			// 不正な入力は処理しない
			if (inputArray.Length != inputCount) {
				Console.WriteLine("invalid input");
				return;
			}
			var N = inputArray[0];

			var aiArray= retreiveLongArray();

			long target = 1;
			long breakCount = 0;

			for (int i = 0; i < N; i++) {
				if (aiArray[i]==target) {
					target++;
				}
				else {
					breakCount++;
				}

			}

			//答えの出力
			var ans = target == 1 ? -1 : breakCount;
			Console.WriteLine(ans);

		}

		/// <summary>
		/// スペースで区切られた文字列配列の入力を受け取る
		/// </summary>
		/// <returns></returns>
		private static string[] retreiveStringArray() {
			var inputArray = Console.ReadLine().Split(' ');
			return inputArray;
		}

		/// <summary>
		/// スペースで区切られた整数配列の入力を受け取る
		/// </summary>
		/// <returns></returns>
		private static long[] retreiveLongArray() {
			var inputArray = Console.ReadLine().Split(' ');
			var longArray = inputArray.Select(s => long.Parse(s));
			return longArray.ToArray();
		}
	}
}

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

bool dp[5000][5000];

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);

    
    ll n;
    cin>>n;
    ll x[n],l[n];
    array<ll,2> a[n];
    for(int i=0;i<n;i++){
        cin>>x[i]>>l[i];
        a[i] = {x[i]+l[i], x[i] - l[i]};
    }
    sort(a,a+n);
    ll ans = n;
    ll now = -1e18;
    for(int i=0;i<n;i++){
        if(now > a[i][1]) ans--;
        else {
            now = a[i][0];
        }
    }
    
    cout << ans << endl;

}


Measured memory_bytes: 3328
import java.util.Arrays;
import java.util.Scanner;

public class Main {
    public static void main(String[] args){
        Scanner scan = new Scanner(System.in);
        int kusi = scan.nextInt()*2;
        int[] niku = new int[kusi];
        for (int i = 0; i < kusi; i++){
            niku[i] = scan.nextInt();
        }

        //sort
        Arrays.sort(niku);
        //2つのうち小さいほうにそろえる
        int sum = 0;
        for (int i = 0; i < kusi; i+=2){
            sum += niku[i];
        }

        System.out.println(sum);
    }
}

Measured memory_bytes: 9684
import java.util.*;

public class Main{
	static public void main(String[] args){
		Scanner sc=new Scanner(System.in);
		int a=sc.nextInt(),b=sc.nextInt(),c=sc.nextInt();
		
		if(a==b){
			System.out.println(c);
			return;
		}else if(a==c){
			System.out.println(b);
			return;
		}else{
			System.out.println(a);
		}
		sc.close();
		return;
	}
}

Measured memory_bytes: 35800
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		long power = 1;
		for(int i = 1; i <= N; i++){
			power = (power * i) % 1000000007; 
		}
		System.out.println(power);
	} 
}

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



int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n;
    cin >> n;
    ll arr[n];
    for(ll i=0;i<n;i++){
        cin >> arr[i];
    }
    ll dp[n];
    dp[0]=0;
    dp[1] = abs(arr[1]-arr[0]);
   // cout << dp[0] << " " << dp[1] << endl;
    for(ll i=2;i<n;i++){
        dp[i] = min(dp[i-1]+abs(arr[i]-arr[i-1]),dp[i-2]+abs(arr[i]-arr[i-2]));
      //  cout << i << " = " << dp[i] << endl;
    }
    cout << dp[n-1];

    return 0;
}


Measured memory_bytes: 1792
n = int(input())

T = []
for _ in range(n):
    t = list(map(int, input().split()))
    T.append(t)

class Tree:
    def __init__(self, n):
        # n : ノード数
        self.nodes = {node: {'parent': None, 'children': [], 'depth': None} for node in range(n)}
        
    def add_node_with_child(self, node, childlen):
        for c in childlen:
            self.nodes[node]['children'].append(c)
            self.nodes[c]['parent'] = node
    
    def get_parent(self, node):
        return self.nodes[node]['parent']
    
    def get_children(self, node):
        return self.nodes[node]['children']
        
    def get_depth(self, node):
        if self.nodes[node]['depth'] != None:
            return self.nodes[node]['depth']
        elif self.nodes[node]['parent'] == None:
            self.nodes[node]['depth'] = 0
            return 0
        else:
            depth = self.get_depth(self.nodes[node]['parent']) + 1
            self.nodes[node]['depth'] = depth
            return depth

            
RootedTree = Tree(n)
for t in T:
    if t[1] == 0:
        continue
        
    node = t[0]
    childlen = t[2:]
    RootedTree.add_node_with_child(node, childlen)
    
#print(RootedTree.nodes)

for node in range(n):
    parent = RootedTree.get_parent(node)
    if parent == None:
        parent = -1
    depth = RootedTree.get_depth(node)
    childlen = RootedTree.get_children(node)
    childlen = ', '.join(list(map(str, childlen)))
    
    if parent == -1:
        node_type = 'root'
    elif childlen == '':
        node_type = 'leaf'
    else:
        node_type = 'internal node'
    
    print('node {}: parent = {}, depth = {}, {}, [{}]'.format(node, parent, depth, node_type, childlen))



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

using namespace std;

#define dump(x)  cerr << #x << " = " << (x) << endl;
#define PB push_back
#define MP make_pair
#define ll long long

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

int main(){
    std::ios::sync_with_stdio(false);
    int a,b,h,m;
    cin >> a >> b >> h >> m;

    double hour = (60 * h + m) * 0.5;
    double minutes = 6 * m;
    double large=0;
    double small=0;
    large=max(hour,minutes);
    small=min(hour,minutes);

    double ret = sqrt(a*a + b*b - 2 * a * b * cos((large - small) / 180 * M_PI));

    printf("%.12f\n", ret);
}

Measured memory_bytes: 4184
n = int(input())
cats = list(map(int, input().split()))

hole = []
p = "OK"

for i in range(n):
    if cats[i] < 0:
        if len(hole)==0 or cats[i] != -1*hole[-1]:
            p = str(i+1)
            break
        else:
            hole.pop()
    else:
        if cats[i] in hole:
            p = str(i+1)
            break
        else:
            hole.append(cats[i])

print(p)


Measured memory_bytes: 5616
#include "bits/stdc++.h"

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

#define rep(i,n) for (ll i = 0; i < (n); i++)
#define ru(a,b) (((a)+((b)-1)) / (b))   //切り上げ(a/b)
#define dump(x)  cout << #x << " = " << (x) << endl;

int main()
{
	ll n;
	cin >> n;

	vector<ll> x;
	for (ll i = 0; i < n; i++)
	{
		ll xx;
		cin >> xx;
		x.push_back(xx);
	}

	// 座標の小さい順にソート
	sort(x.begin(), x.end());

	// 消費の和
	vector<ll> s;

	// 全ての整数値座標において、消費数の和を計算
	for (ll p = x.front(); p <= x.back(); p++)
	{
		ll ss=0;
		// n人分の消費計算
		rep(i, n)
		{
			ss += (ll)(pow(x[i] - p, 2.0));
		}
		s.push_back(ss);
	}

	// 消費の小さい順にソート
	sort(s.begin(), s.end());



	cout << s.front() << endl;

	return 0;
}



Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<stdio.h>
#include<algorithm>
#include<math.h>
#include<numeric>
#include<iomanip>
#include<deque>
#include<tuple>
#include<queue>
#include<map>
#include<cstdint>
#include<unordered_map>
#include<boost/multiprecision/cpp_int.hpp>


#define rep(i, n) for(int i = 0; i < ( int)(n); i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define vi vector<int>
#define all(x) (x).begin(),(x).end()
#define F first
#define S second

namespace mp = boost::multiprecision;

using cpp_int = mp::cpp_int;
using ll = long long;
using namespace std;
int even(int &n) {
	int count = 0;
	while (n > 0) {
		if (n % 2 == 0) {
			count++;
			n /= 2;
		}
		else {
			break;
		}
		//cout << n << endl;
	}
	return count;
}

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

	int mini = min_element(all(a)) - a.begin();
	//cout <<"mini"<< mini << endl;
	//cout <<"mia"<< a[mini] << endl;
	int i = mini;
	int j = mini;
	int rest = 0;
	int count = 0;
	while (j <= n - 2) {
		if (a[j] == a[j + 1]) {
			j++;
		}
		else {
			break;
		}
	}

	if (mini + k - 1 - (n - 1) > 0 && j != n - 1) {
		i = max(mini - (mini + k - 1 - n + 1), 0);
		j = n - 1;
		count++;
	}
	else if (k - mini - 1 > 0 && i != 0) {
		i = 0;
		int tmpj = min(mini + k - mini - 1, n - 1);
		j = max(j, tmpj);
		count++;
	}

	while (i != 0) {
		if (a[max(i - 1, 0)] == a[mini]) {
			i--;
		}
		else {
			if (i - k + 1 <= 0) {
				rest += abs(i - k + 1);
				count++;
				break;
			}
			i = max(0, i - k + 1);
			count++;
		}
	}
	//cout <<"c"<< count << endl;
	while (j != n - 1) {
		if (a[j+1] == a[mini]) {
			j++;
		}
		else {
			if (j + k - 1 >=n - 1) {
				rest+= j + k - 1 - n + 1 ;
				count++;
				break;
			}
			j = min(n - 1, j + k - 1);
			count++;
			
			
		}
	}
	if (rest >= k-1) {
		count--;
	}
	cout << count << endl;

}

Measured memory_bytes: 640
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <vector>
#include <queue>
#include <iostream>
#include <set>
#include <map>
#include <string>
#include <algorithm>

using namespace std;

typedef long long int ll;
typedef pair<int, int> Pii;
typedef pair<int, double> Pid;
typedef pair<double, int> Pdi;
typedef pair<double, double> Pdd;
typedef pair<ll, ll> P;
typedef pair<P, ll> PP;

const ll mod = 1e9+7;
const int INF = 2e9;
const double epsilon = 1e-7;
const double PI = 3.1415926535;

ll mi(ll x, ll y){
    if(x<y)return x;
    return y;
}
double x[10][10];
int main(void){
    int n, d; cin >> n >> d; ll ans = 0;
    for(int i = 0;i < n;i++)for(int j = 0;j < d;j++)scanf("%lf", &x[i][j]);
    for(int i = 0;i < n-1;i++)for(int j = i + 1;j < n;j++){
        double dist = 0;
        for(int k = 0;k < d;k++)dist += (x[i][k] - x[j][k])*(x[i][k] - x[j][k]);
        dist = pow(dist, 0.5);
        int dd = floor(dist);
        if(dist - dd < 0.001 || dd + 1 - dist < 0.001)ans++;
    }
    cout << ans << endl;
	return 0;
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
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; }
//---------------------------------------------------------------------------------------------------
/*---------------------------------------------------------------------------------------------------
　　　　　　　　　　　 ∧＿∧  
　　　　　 ∧＿∧ 　（´<_｀ ）　 Welcome to My Coding Space!
　　　　 （ ´_ゝ`）　/　 ⌒i     
　　　　／　　　＼　 　 |　|     
　　　 /　　 /￣￣￣￣/　　|  
　 ＿_(__ﾆつ/　    ＿/ .| .|＿＿＿＿  
　 　　　＼/＿＿＿＿/　（u　⊃  
---------------------------------------------------------------------------------------------------*/



const double PI = 2 * acos(0.0);
double A, B;
//---------------------------------------------------------------------------------------------------
void _main() {
    cin >> A >> B;

    double r = max(A, B);
    double ans = 4.0 * PI * r * r * r / 3;

    printf("%.10f\n", ans);
}


Measured memory_bytes: 3308
#include <iostream>
using namespace std;
int main(void){
    int n, i, j;
    int minv, maxv;
    int R[200001];
    cin >> n;
    for(i = 0; i < n; i++){
        cin >> R[i];
    }
    minv = R[0];
    maxv = R[1] - R[0];
    for(j = 1; j < n; j++){
        maxv = max(maxv, R[j] - minv);
        minv = min(minv, R[j]);
    }
    cout << maxv << endl;
    return 0;
}


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

int main() {
  int card[] = {0, 13, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12};
  int A, B;
  cin >> A >> B;
  if (card[A]  > card[B]) {
    cout << "Alice" << endl;
  } else if (card[A] < card[B]) {
    cout << "Bob" << endl;
  } else {
    cout << "Draw" << endl;
  }
}


Measured memory_bytes: 256
{-# LANGUAGE BangPatterns #-}

import Data.Bifunctor (bimap)
import Data.Function  (on)
import Data.Ratio

import Control.Monad

main :: IO ()
main = do
    n  <- read <$> getLine
    rs <- replicateM n getPair
    print $ solve rs

getPair = (\(x:y:_) -> (x, y)) . fmap read . words <$> getLine

solve :: [(Int, Int)] -> Int
solve = inner (1, 1)
  where
    inner (!a, !b)           []  = a + b
    inner (!a, !b) ((x, y) : rs) = go (a % x) (b % y) (x, y) rs
    go p q = (.) inner $ bimap <*> id $ (on max ceiling p q *)


Measured memory_bytes: 1532
#include <iostream>
#include <string>
#include <vector>
#include <utility>
#include <map>
#include <algorithm>

using namespace std;

bool try5000(int sum, int count, int& n5000, int& n1000)
{
  for (n5000 = 0; n5000 <= count; ++n5000) {
    auto sum5000 = n5000 * 5000;
    if (sum5000 > sum) break;
    n1000 = count - n5000;
    if (sum5000 + n1000 * 1000 == sum) return true;
  }
  return false;
}

bool try10000(int sum, int count, int& n10000, int& n5000, int& n1000)
{
  for (n10000 = 0; n10000 <= count; ++n10000) {
    auto sum10000 = n10000 * 10000;
    if (sum10000 > sum) break;
    if (try5000(sum - sum10000, count - n10000, n5000, n1000)) return true;
  }
  return false;
}

int main()
{
  int X, Y;
  cin >> X >> Y;
  int n10000, n5000, n1000;
  if (try10000(Y, X, n10000, n5000, n1000)) {
    cout << n10000 << " " << n5000 << " " << n1000 << endl;
  } else {
    cout << "-1 -1 -1" << endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <cstdio>
using namespace std;
int main()
{
	string s;
	cin>>s;
	if(s[0]=='Y'&&s[1]=='A'&&s[2]=='K'&&s[3]=='I')
		cout<<"Yes"<<endl;
	else 
		cout<<"No"<<endl;
}

Measured memory_bytes: 256
import numpy as np
H,W=map(int,input().split())
S=[list(input()) for h in range(H)]
S=[[1 if s=='.' else 0 for s in S[h]] for h in range(H)]
S=np.array(S)
L=S.copy()
R=S.copy()
U=S.copy()
D=S.copy()
for w in range(1,W):
    L[:,w]=(L[:,w-1]+1)*S[:,w]
    R[:,-(1+w)]=(R[:,-w]+1)*S[:,-(1+w)]
for h in range(1,H):
    U[h,:]=(U[h-1,:]+1)*S[h,:]
    D[-(1+h),:]=(D[-h,:]+1)*S[-(1+h),:]
print(int((L+R+U+D).max())-3)

Measured memory_bytes: 251044
#include <iostream>
using namespace std;
#define MAX 500021

int main(){
	bool b[MAX];
	fill(b, b+MAX, false);b[0] = b[1] = true;
	for(int i = 2;i < MAX;i++){
		if(!b[i]){
			for(int j = 2;i*j < MAX;j++){
				b[i*j] = true;
			}
		}
	}
	
	int n, x, y;
	while(cin >> n){
		for(x = n-1;b[x];x--);
		for(y = n+1;b[y];y++);
		cout << x << " " << y << endl;
	}
	return 0;
}
/*
1
y eazqyp pnop pngtg ye obmpngt xmybp mr lygw
*/

Measured memory_bytes: 3572
#include<stdio.h>
#include<string.h>
#include<math.h>
#include<ctype.h>



int main()

{
    int n;
    scanf("%d",&n);
    if(n%1000==0)
        printf("0\n");
    else
    {
        printf("%d\n",1000-n%1000);
    }



    return 0;
}

/*
I wish I could be the monster you think I am !!!
*/



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

int main(){
  double R;
  cin >> R;

  cout << 2*R*3.14159265 << endl;



  return 0;
}


Measured memory_bytes: 3788
import sys
sys.setrecursionlimit(1000000)


input = raw_input
N, Q = list(map(int, input().split()))

ab = [list(map(int, input().split())) for _ in range(N - 1)]
px = [list(map(int, input().split())) for _ in range(Q)]


class Tree():
    def __init__(self, v):
        self.parent = None
        self.v = v
        self.x = 0
        self.memo = None

    def add(self, x):
        self.x += x

    def calc(self):
        if self.v == 1:
            return self.x
        if self.memo is not None:
            return self.memo

        tmp = self.parent.calc()
        self.memo = tmp + self.x
        return self.memo



trees = {i: Tree(i) for i in range(1, N + 1)}

for a,b in ab:
    trees[b].parent = trees[a]

for p,x in px:
    trees[p].add(x)


print(" ".join(map(str,[trees[i].calc() for i in range(1,N+1)])))



Measured memory_bytes: 115928
#include <iostream>
#include <algorithm>
using namespace std;
long long sum,ans;
const int maxn=200000+5;
const int mod=1000000007;
int n,a[maxn];
int main(){
    cin>>n;
    for(int i=1;i<=n;i++)
        cin>>a[i];
    for(int i=2;i<=n;i++){
        sum=(sum+a[i-1])%mod;
        ans=(ans+sum*a[i])%mod;
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 3896
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < n; i++)
#define repr(i, n) for(int i = n; i >= 0; i--)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
int main()
{
  string s;
  int k;
  cin >> s >> k;
  set<string> st;
  int n = s.size();
  rep(i, n) {
    string tmp = "";
    for(int j = i; j < min(i+5, n); j++) {
      tmp += s[j];
      st.insert(tmp);
    }
  }
  int cnt = 1;
  for(auto it = st.begin(); it != st.end(); it++) {
    if (cnt == k) {
      cout << *it << endl;
      return 0;
    }
    cnt++;
    
  }

  return 0;
}

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

int main() {
	int n, m; cin >> n >> m;
	int p[m];
	string s[m];
	for (int i = 0; i < m; i++)
	{
		cin >> p[i] >> s[i];
	}
	pair<int, int> d[100100] = {};
	for (int i = 0; i < m; i++)
	{
		if(d[p[i]].second != 0) continue;
		else if(s[i] == "AC") d[p[i]].second = 1;
		else d[p[i]].first++;
	}
	int ac = 0, pena = 0;
	for (int i = 0; i <= n; i++)
	{
		if(d[i].second != 0) {
			ac++;
			pena += d[i].first;
		}
	}
	cout << ac << " " << pena << endl;
	return 0;
}


Measured memory_bytes: 7848
#include <iostream>

using namespace std;

int main(){
    int s;
    cin >> s;
    int hour, min, sec;
    hour = s / 3600;
    s = s % 3600;
    min = s / 60;
    s = s % 60;
    sec = s;
    cout << hour << ":" << min << ":" << sec << endl;
    return 0;
}


Measured memory_bytes: 3072
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define INF 1<<30
#define LINF 1LL<<60

/*
<url:http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0360>
?????????============================================================
 ??°??£????????¶???????????¨?????????????????????????????\???????????¨?????????????????¶????????¨???????\??????§???????????????????????????????§????????¨????????????£???????????????
 ??¨???????????¨??????????´????????????§???????´??????????????§?????????¨???????????????????????????????????????????????°??????????´?????????????????????????????????????
 
 ??°??????????´????????????§????????¨??????????´???????????????¨????????????????????±?????????????????°????????????????????????
 ??????????????????????´??????????????????¨?????\???????´????????§??????????????????´???????????????????????¨??????????????????
 ???????????????????????????????????¨???????????¨????§?????????????????????°??§??????????????????
 
=================================================================

?§£??¬=============================================================
imos??§??????
================================================================
*/
ll imos[1010];
int main(void) {
	cin.tie(0); ios::sync_with_stdio(false);
    ll a,b; cin >> a >> b;
    ll N; cin >> N;
    for(int i = 0; i < N;i++){
        ll s,f; cin >> s >> f;
        imos[s]++; imos[f]--;
    }
    for(int i = 1; i < 1010;i++) imos[i] += imos[i-1];
    for(int i = a; i < b;i++){
        if(imos[i] == 1){
            cout << 1 << endl;
            return 0;
        }
    }
    cout << 0 << endl;
	return 0;
}

Measured memory_bytes: 3160
n,m = gets.split.map(&:to_i)
s = []
m.times do
  a = gets.split.map(&:to_i)
  a.shift
  s << a
end
cond = gets.split.map(&:to_i)
ans = 0

0.upto((1 << n)-1) do |i|
  judge = true
  0.upto(m-1) do |j|
    count = 0
    s[j].each do |k|
      if i & (1 << (k-1)) > 0
        count += 1
      end
    end
    if count%2 != cond[j]
      judge = false
      break
    end
  end
  if judge
    ans += 1
  end
end
puts ans

Measured memory_bytes: 3836
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)   FOR(i,0,n)
#define pb emplace_back
typedef long long ll;
typedef pair<int,int> pint;

int main(){
    int n,m;
    cin>>n>>m;
    int ans=1;
    for(int i=1;i*i<=m;++i){
        if(m%i==0){
            int j=m/i;
            if(j>=n){
                ans=max(ans,i);
            }
            if(i>=n){
                ans=max(ans,j);
            }
        }
    }
    cout<<ans<<endl;
    return 0;
}

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

int main() {
  int h, w;
  cin >> h >> w;
  vector<string> a(h);
  rep (i, h) {
    cin >> a[i];
  }
  for (int i = -1; i <= h ;i++) {
    if (i == -1 || i == h) {
      rep (i, w + 2) {
        cout << "#";
      }
      cout << endl;
    }else{
      cout << "#" << a[i] << "#" << endl;
    }
  }
  return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
using namespace std;

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

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

// Self settings
// clang-format off
#define MAX_N 2999
#define REP(i, N) for (int i = 0; i < (int)(N); ++i)
// clang-format on

int N;
double p[MAX_N];
double dp[MAX_N + 1][MAX_N + 1];

void solve()
{
  memset(dp, 0, sizeof(dp));
  dp[0][0] = 1.0;
  for (int i = 0; i < N; i++) {
    for (int j = 0; j <= N; j++) {
      if (j == 0) {
        dp[i + 1][j] = dp[i][j] * (1.0 - p[i]);
      }
      else {
        dp[i + 1][j] = (dp[i][j - 1] * p[i]) + (dp[i][j] * (1.0 - p[i]));
      }
    }
  }
  int div = ((N + 1) / 2);
  double ans = 0.0;
  for (int i = div; i <= N; i++) ans += dp[N][i];
  printf("%.10f\n", ans);
}

int main(void)
{
  cin >> N;
  REP(i, N) cin >> p[i];
  solve();
  return 0;
}


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

int main()
{
    int H,N,A,sum = 0;

    cin >> H >> N;

    while(N--)
    {
        cin >> A;
        sum = sum + A;
    }

    if(H <= sum)
    {
        cout << "Yes" << endl;
    }

    else
    {
        cout << "No" << endl;
    }

    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
int main (void){
  int a,b,c,d,e,k;
  scanf("%d", &a);
  scanf("%d", &b);
  scanf("%d", &c);
  scanf("%d", &d);
  scanf("%d", &e);
  scanf("%d", &k);
  
  if(e-a>k)
    printf(":(\n");
  else
    printf("Yay!\n");
  return 0;
}

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

ll a[200001];
ll b[200001];
int main() {
    int N, M, K;
    cin >> N >> M >> K;
    a[0] = 0;
    b[0] = 0;
    rep2(i, N) {
        int x;
        cin >> x;
        a[i] = i == 1 ? x : x + a[i - 1];
    }
    rep2(i, M) {
        int x;
        cin >> x;
        b[i] = i == 1 ? x : x + b[i - 1];
    }
    int j = M, ans = 0;
    for (int i = 0; i <= N; i++) {
        if (a[i] > K)
            break;
        while (a[i] + b[j] > K)
            j--;
        ans = max(ans, i + j);
    }

    cout << ans << endl;
}

Measured memory_bytes: 6748