akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

#define li long long int
#define rep(i, to) for (li i = 0; i < ((li)(to)); i++)
typedef pair<li, li> PI;

PI a[100100];

int main(void)
{
	li n;
	cin >> n;
	rep(i, n) {
		cin >> a[i].first >> a[i].second;
	}
	sort(a, a + n);
	cout << a[n - 1].first + a[n - 1].second << endl;

	return 0;
}

Measured memory_bytes: 1792
#include <iostream>
#include <cstdio>

using namespace std;

int main() {
    int n, k;
    cin >> n >> k;
    int cur = 0;
    bool now;
    int len = 0;
    int *s = new int[n + 1];
    bool *sb = new bool[n + 1];
    char c = getchar();
    while (c != '0' && c != '1')
        c = getchar();
    now = c - '0';
    for (int i = 0; i < n; ++i) {
        c -= '0';
        if ((bool)c == now) {
            ++len;
        }
        else {
            s[cur] = len;
            sb[cur] = now;
            ++cur;
            len = 1;
            now = c;
        }
        c = getchar();
    }
    s[cur] = len;
    sb[cur] = now;
    ++cur;
    int maxlen = 0, tmp = 0, remain, j;
    for (int i = 0; i < cur; ++i) {
        if (sb[i]) {
            tmp = s[i];
            continue;
        }
        remain = k;
        for (j = i; j < cur && remain > 0; ++j) {
            tmp += s[j];
            if (!sb[j])
                --remain;
        }
        if (j < cur)
            tmp += s[j];
        if (maxlen < tmp)
            maxlen = tmp;
    }
    cout << (maxlen > tmp ? maxlen : tmp) << endl;
    return 0;
}


Measured memory_bytes: 768
//#pragma GCC optimize(2)
//#pragma GCC optimize(3)
//#pragma GCC optimize(4)
//#pragma GCC optimize("unroll-loops")
//#pragma comment(linker, "/stack:200000000")
//#pragma GCC optimize("Ofast,no-stack-protector")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include<bits/stdc++.h>
#define fi first
#define se second
#define db double
#define mp make_pair
#define pb push_back
#define pi acos(-1.0)
#define ll long long
#define vi vector<int>
#define mod 1000000007
#define ld long double
//#define C 0.5772156649
#define ls l,m,rt<<1
#define rs m+1,r,rt<<1|1
#define pll pair<ll,ll>
#define pil pair<int,ll>
#define pli pair<ll,int>
#define pii pair<int,int>
#define ull unsigned long long
//#define base 1000000000000000000
#define fin freopen("a.txt","r",stdin)
#define fout freopen("a.txt","w",stdout)
#define fio ios::sync_with_stdio(false);cin.tie(0)
inline ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
inline void sub(ll &a,ll b){a-=b;if(a<0)a+=mod;}
inline void add(ll &a,ll b){a+=b;if(a>=mod)a-=mod;}
inline void add(ll &a,ll b,ll c){a+=b;if(a>=c)a-=c;}
template<typename T>inline T const& MAX(T const &a,T const &b){return a>b?a:b;}
template<typename T>inline T const& MIN(T const &a,T const &b){return a<b?a:b;}
inline ll qp(ll a,ll b){ll ans=1;while(b){if(b&1)ans=ans*a%mod;a=a*a%mod,b>>=1;}return ans;}
inline ll qp(ll a,ll b,ll c){ll ans=1;while(b){if(b&1)ans=ans*a%c;a=a*a%c,b>>=1;}return ans;}
inline ll mul(ll a,ll b,ll c){return (a*b-(ll)((ld)a*b/c)*c+c)%c;}
inline ll qm(ll a,ll b,ll c){ll ans=0;while(b){if(b&1)add(ans,a,c);add(a,a,c);b>>=1;}return ans;}
inline ll qpow(ll a,ll b,ll c){ll ans=1;while(b){if(b&1)ans=mul(ans,a,c);a=mul(a,a,c);b>>=1;}return ans;}

using namespace std;

const ull ba=233;
const db eps=1e-10;
const ll INF=0x3f3f3f3f3f3f3f3f;
const int N=3000+10,maxn=100000+10,inf=0x3f3f3f3f;

ll dp[N][N];
int a[N],n;
int main()
{
    int m;scanf("%d%d",&n,&m);
    for(int i=1;i<=n;i++)scanf("%d",&a[i]);
    ll te=qp(2,m);
    for(int i=1;i<=n;i++)
        for(int j=1;j<=n;j++)
            if(a[i]>a[j])
                dp[i][j]=te;
    ll inv=qp(2,mod-2);
    for(int i=1;i<=m;i++)
    {
        int x,y;scanf("%d%d",&x,&y);
        for(int j=1;j<=n;j++)if(j!=x&&j!=y)
        {
            ll t1=dp[x][j];add(t1,dp[y][j]);t1=t1*inv%mod;
            dp[x][j]=dp[y][j]=t1;
            t1=dp[j][x];add(t1,dp[j][y]);t1=t1*inv%mod;
            dp[j][x]=dp[j][y]=t1;
        }
        ll t1=dp[x][y],t2=dp[y][x];
        add(t1,t2);t1=t1*inv%mod;
        dp[x][y]=dp[y][x]=t1;
    }
    ll ans=0;
    for(int i=1;i<=n;i++)
        for(int j=1+i;j<=n;j++)
            add(ans,dp[i][j]);
    printf("%lld\n",ans);
    return 0;
}
/********************
3 1
1 2 3
1 2
********************/


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

using namespace std;
#define IOS ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define ll long long
#define ld long double
#define endl "\n"

int main()
{
	IOS;
	int n;
	cin >>n;
	int s=1,c=0;
	for(int i=0;i<n;i++)
	{
		int x;
		cin >>x;
		if(x==s)
			s++;
		else
			c++;
	}
	if(c<n)
		cout <<c<<endl;
	else
		cout <<-1<<endl;
}

Measured memory_bytes: 256
N = int(input())
red = sorted([list(map(int, input().split())) for _ in range(N)], key=lambda x:x[1], reverse=True)
blue = sorted([list(map(int, input().split())) for _ in range(N)])

cnt = 0
for i in blue:
    for j in red:
        if i[0] > j[0] and i[1] > j[1]:
            cnt += 1
            red.remove(j)
            break

print(cnt)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vi;
typedef pair<ll,ll> pi;
typedef vector<pi> vpi;
typedef long double ld;
#define pb emplace_back
#define mp make_pair
#define lb lower_bound
#define ub upper_bound
#define ALL(x) x.begin(), x.end()
#define SZ(x) (ll)x.size()
#define f first
#define s second
const ll MOD = 1e9+7;
const ll INF = 1e9;
const ll MAXN = 300100;

ll T,N,a,b,c,d,e,f,K,t,M;
ll A[MAXN];

int main(){
  cin>>N>>T;
  for (int i=1;i<=N;++i){
    cin>>A[i];
    a+=A[i];
  }
  for (int i=1;i<=N;++i){
    if (A[i] * 4 * T >= a)++t;
  }
  if (t>=T)cout<<"Yes";
  else cout<<"No";
}

Measured memory_bytes: 256
// _______  _____  _______  _____  _______ _______ _____ _______ _____ _    _ _______ 
// |       |     | |  |  | |_____] |______    |      |      |      |    \  /  |______ 
// |_____  |_____| |  |  | |       |______    |    __|__    |    __|__   \/   |______ 
//
//  _____   ______  _____   ______  ______ _______ _______ _______ _____ __   _  ______   /
// |_____] |_____/ |     | |  ____ |_____/ |_____| |  |  | |  |  |   |   | \  | |  ____  / 
// |       |    \_ |_____| |_____| |    \_ |     | |  |  | |  |  | __|__ |  \_| |_____| .  
//
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
#define FOR(I,A,B) for(int I = int(A); I < int(B); ++I)
#define FORR(I,A,B) for(int I = int((B)-1); I >= int(A); --I)
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin()) //ai>=v  x is sorted
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin()) //ai>v  x is sorted
ll gcd(ll a,ll b){if(a<b)swap(a,b);if(a%b==0)return b;return gcd(b,a%b);}
ll lcm(ll a,ll b){ll c=gcd(a,b);return ((a/c)*(b/c)*c);}//saisyo kobaisu z
const ll INF=1e18+7;
const ll MOD=1e9+7;

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

	ll N , A , B;
	cin >> N >> A >> B;
	if((A*B<N)||(A+B>N+1)){
		cout << -1 << endl;
		return 0;
	}

	vector<ll> ans;
	FORR(i,1,B+1){
		ans.push_back(i);
	}
	if(A==1){
		FOR(i,0,N){
			if(i!=0)cout << " ";
			cout << ans[i];
		}
		cout << endl;
		return 0;
	}


	ll x = (N-B)/(A-1);
	ll p = (N-B)%(A-1);

	ll nn = B+1;
	FOR(t,0,A-1){
		ll add = x;
		if(p){
			add++;
			p--;
		}
		FORR(i,nn,nn+add){
			ans.push_back(i);
		}
		nn += add;
	}
	FOR(i,0,N){
		if(i!=0)cout << " ";
		cout << ans[i];
	}
	cout << endl;
}

Measured memory_bytes: 6384
M,D=map(int,input().split())
ans = 0
for m in range(1,M+1):
    for d in range(22,D+1):
        d1 = d%10
        d10 = d//10
        if d1 >=2 and d10 >=2 and m == d1*d10: ans += 1
print(ans)

Measured memory_bytes: 3060
#include <cstdio>
#include <algorithm>
#include <queue>
#include <cassert>
using namespace std;

#define iter(i, n) for (int i = 1; i <= n; ++i)


#define NR 2010

typedef pair<int, int> pii;
#define se second

int n, a[NR], ch, in[NR];
bool g[NR][NR], vis[NR], inq[NR];

priority_queue<pii, vector<pii>, greater<pii> > Q;
priority_queue<pii> q;

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


void dfs(int x) {
	vis[x] = true;
	iter(v, n) if (g[x][v]) assert(g[v][x]), g[v][x] = false;
	iter(v, n) if (g[x][v] && !vis[v]) dfs(v);
}

int main() {
	scanf("%d", &n);
	iter(i, n) scanf("%d", &a[i]);
	sort(a + 1, a + n + 1);
	iter(i, n) iter(j, i - 1) if (gcd(a[i], a[j]) != 1) g[i][j] = g[j][i] = true;

	iter(i, n) if (!vis[i]) dfs(i);
	/*iter(i, n) { 
		iter(j, n) printf("%d ", g[i][j]);
		puts("");
	}*/

	iter(x, n) iter(v, n) if (g[x][v]) ++in[v];
	iter(x, n) if (!in[x]) q.push(pii(a[x], x));

	while (!q.empty()) {
		int x = q.top().se; q.pop();
		printf("%d ", a[x]);
		iter(v, n) if (g[x][v]) {
			if (!--in[v]) q.push(pii(a[v], v));
		}
	}

	return 0;
}


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

using ll = long long;
using pii = pair<int, int>;
template <class T>
using V = vector<T>;
template <class T>
using VV = V<V<T>>;

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define rep(i, n) rep2(i, 0, n)
#define rep2(i, m, n) for (int i = m; i < (n); i++)
#define ALL(c) (c).begin(), (c).end()

constexpr ll TEN(int n) { return (n == 0) ? 1 : 10 * TEN(n - 1); }

template <class T, class U>
void chmin(T &t, const U &u) {
    if (t > u) t = u;
}
template <class T, class U>
void chmax(T &t, const U &u) {
    if (t < u) t = u;
}

template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
    os << "(" << p.first << "," << p.second << ")";
    return os;
}

template <class T>
ostream &operator<<(ostream &os, const vector<T> &v) {
    os << "{";
    rep(i, v.size()) {
        if (i) os << ",";
        os << v[i];
    }
    os << "}";
    return os;
}

#ifdef LOCAL
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
    cerr << " " << H;
    debug_out(T...);
}
#define debug(...) \
    cerr << __LINE__ << " [" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#define dump(x) cerr << __LINE__ << " " << #x << " = " << (x) << endl
#else
#define debug(...) (void(0))
#define dump(x) (void(0))
#endif

int main() {
    ll N, K;
    cin >> N >> K;
    ll ans = 0;
    if (K == 0) {
        ans = N * N;
    } else {
        for (int b = 1; b <= N; ++b)
            if (b > K) {
                ll u = (N / b) * (b - K) + max<ll>(N % b - K + 1, 0);
                ans += u;
            }
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using uint = unsigned int;
#define rep(i,n) for(int i=0;i<int(n);i++)
#define rep1(i,n) for(int i=1;i<=int(n);i++)
#define per(i,n) for(int i=int(n)-1;i>=0;i--)
#define per1(i,n) for(int i=int(n);i>0;i--)
#define all(c) c.begin(),c.end()
#define si(x) int(x.size())
#define pb emplace_back
#define fs first
#define sc second
template<class T> using V = vector<T>;
template<class T> using VV = vector<vector<T>>;
template<class T,class U> void chmax(T& x, U y){if(x<y) x=y;}
template<class T,class U> void chmin(T& x, U y){if(y<x) x=y;}
template<class T> void mkuni(V<T>& v){sort(all(v));v.erase(unique(all(v)),v.end());}
template<class S,class T> ostream& operator<<(ostream& o,const pair<S,T> &p){
	return o<<"("<<p.fs<<","<<p.sc<<")";
}
template<class T> ostream& operator<<(ostream& o,const vector<T> &vc){
	o<<"{";
	for(const T& v:vc) o<<v<<",";
	o<<"}";
	return o;
}
constexpr ll TEN(int n) { return (n == 0) ? 1 : 10 * TEN(n-1); }

#ifdef LOCAL
#define show(x) cerr << "LINE" << __LINE__ << " : " << #x << " = " << (x) << endl
void dmpr(ostream& os){os<<endl;}
template<class T,class... Args>
void dmpr(ostream&os,const T&t,const Args&... args){
	os<<t<<" ~ ";
	dmpr(os,args...);
}
#define shows(...) cerr << "LINE" << __LINE__ << " : ";dmpr(cerr,##__VA_ARGS__)
#define dump(x) cerr << "LINE" << __LINE__ << " : " << #x << " = {";  \
	for(auto v: x) cerr << v << ","; cerr << "}" << endl;
#else
#define show(x) void(0)
#define dump(x) void(0)
#define shows(...) void(0)
#endif

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);		//DON'T USE scanf/printf/puts !!
	cout << fixed << setprecision(20);

	int N,K; cin >> N >> K;
	V<int> a(N); rep(i,N) cin >> a[i];
	while(K--){
		auto nxt = [&](V<int> a){
			V<int> b(N+1);
			rep(i,N){
				b[max(i-a[i],0)]++;
				b[min(i+a[i]+1,N)]--;
			}
			rep(i,N) b[i+1] += b[i];
			b.pop_back();
			return b;
		};
		a = nxt(a);
//		show(a);
		if(a == V<int>(N,N)){
			break;
		}
	}
	rep(i,N) cout << a[i] << " ";
	cout << endl;
}


Measured memory_bytes: 5552
import sys

x, n = map(int, input().split())
if n == 0:
  print(x)
  sys.exit()
li = list(map(int, input().split()))

if x not in li:
  print(x)
  sys.exit()

i = 1
while i <= 100:
  if x - i not in li:
    print(x - i)
    break
  elif x + i not in li:
    print(x + i)
    break
  else:
    i += 1

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

// types
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pdd;
typedef vector<ll> vll;

// macros
#define ALL(a) a.begin(),a.end()
#define SZ(a) ((int)a.size())
#define FI first
#define SE second
#define REP(i,n) for(int i=0;i<((int)n);i++)
#define REP1(i,n) for(int i=1;i<((int)n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define PB push_back
#define EB emplace_back
#define MP(a,b) make_pair(a,b)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL

// constants
const int inf = 1e9;
const ll linf = 1LL << 50;
const double eps = 1e-10;
const int MOD = 1e9 + 7;
const int dx[4] = {-1, 0, 1, 0};
const int dy[4] = {0, -1, 0, 1};

int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);

  ll n,k;
  cin >> n >> k;

  vector<char> a(n);
  ll change_counter = 1;

  cin >> a[0];
  REP1(i, n){
    cin >> a[i];
    if(a[i] != a[i-1])
      change_counter++;
  }

  ll ans = n - change_counter + k*2;
  if(ans >= n)
    ans = n-1;

  cout << ans << endl;



  
  
}


Measured memory_bytes: 384
#include <iostream>
#include <set>
#include <string>
#include <map>
#include <algorithm>

using namespace std;


int main() {

  string word;
  int page;

  map<string, set<int> > index;
  

  index.clear();

  while(cin >> word >> page) {

    index[word].insert(page);
    /*
     for(map<string, set<int> >::iterator it=index.begin();it!=index.end();it++) {

      cout << (*it).first << endl;

      for(set<int>::iterator it2=(*it).second.begin();it2!=(*it).second.end();it2++) {

	if(it2==(*it).second.begin()) cout << *it2;

	else cout << " " << *it2;

      }
      
      cout << endl;
    
      }
    */
  }

  for(map<string, set<int> >::iterator it=index.begin();it!=index.end();it++) {

      cout << (*it).first << endl;

      for(set<int>::iterator it2=(*it).second.begin();it2!=(*it).second.end();it2++) {

	if(it2==(*it).second.begin()) cout << *it2;

	else cout << " " << *it2;

      }
      
      cout << endl;

  }

  return 0;

}

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

int IsPrime(int n)
{
	if(n == 2)
	{
		return 1;
	}
	
	if(n % 2 == 0 || n < 2)
	{
		return 0;
	}
	
	for(int i = 3; i * i <= n; i += 2)
	{
		if(n % i == 0)
		{
			return 0;
		}
	}
	
	return 1;
}

int main()
{
	int N, P, ans = 0;
	cin >> N;
	for(int i = 0; i < N; ++i)
	{
		cin >> P;
		ans += IsPrime(P);
	}
	
	cout << ans << endl;

    return 0;
}



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

#define ll long long
#define vvi vector<vector<int>>
#define vec vector
#define pq priority_queue
#define all(v) (v).begin(), (v).end()
#define uniqueV(x) sort(x.begin(), x.end()); x.erase(unique(x.begin(), x.end()), x.end());
#define rep(i, n) for (int (i) = (0); (i) < (n); ++(i))
#define repp(i, m, n) for (int (i) = (m); (i) < (n); ++(i))
#define debug(x) cerr << #x << ": " << x << endl;
#define debug2(x, y) cerr<<"("<<#x<<", "<<#y<<") = "<<"("<<x<<", "<<y<<")"<<endl;
#define debug3(x, y, z) cerr<<"("<<#x<<", "<<#y<<", "<<#z<<") = "<<"("<<x<<", "<<y<<", "<<z<<")"<<endl;
#define debugB(value, size) cerr<<#value<<": "<<bitset<size>(value) << endl;
#define line() cerr << "---------------" << endl;

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

template<typename T>
void printA(vector<T> &printArray, char between = ' ') {
   int paSize = printArray.size();
   for (int i = 0; i < paSize; i++) { cerr << printArray[i] << between;}
   if (between != '\n') {cerr << endl;}
}

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

int n;
list<int> s;

int main() {
   cin >> n;
   rep (i, n) {
      ll a;
      cin >> a;
      if (i % 2 == 0) {
         s.push_back(a);
      } else {
         s.push_front(a);
      }
   }

   if (n&1) {
      reverse(all(s));
   }

   vec<int> ans;
   for (int c : s) {
      ans.push_back(c);
   }

   rep (i, n-1) {
      cout << ans[i] << " ";
   }
   cout << ans[n-1] << endl;

   return 0;
}

Measured memory_bytes: 9336
import java.util.Arrays;
import java.util.Scanner;
public class Main {
	static Scanner scan=new Scanner(System.in);
	static int gcd (int a, int b) {return b>0?gcd(b,a%b):a;}
	static long lcm (int a, int b) {return a*b/gcd(a,b);}
	static int max(int a,int b) {return a>b?a:b;}
	static int min(int a,int b) {return a<b?a:b;}
	static long factorial(int i) {return i==1?1:i*factorial(i-1);}
	static int lower_bound(int a[],int key) {
		int low=0,high=a.length;
		while(low<high) {
			int mid=((high-low)/2)+low;
			if(a[mid]<=key)low=mid+1;
			else high=mid;
		}
		return high;
		}
	static int upper_bound(int a[],int key) {
		int low=0,high=a.length;
		while(low<high) {
			int mid=((high-low)/2)+low;
			if(a[mid]<key)low=mid+1;
			else high=mid;
		}
		return high;
		}
	static boolean isPrime (int n) {
		if (n==2) return true;
		if (n<2 || n%2==0) return false;
		double d = Math.sqrt(n);
		for (int i=3; i<=d; i+=2)if(n%i==0){return false;}
		return true;
	}
	static int upper_division(int a,int b) {
		if(a%b==0) {
			return a/b;
		}
		else {
			return a/b+1;
		}
	}
	static long lupper_division(long a,long b) {
		if(a%b==0) {
			return a/b;
		}
		else {
			return a/b+1;
		}
	}
	static long lmax(long a,long b) {return Math.max(a, b);}
	static long lmin(long a,long b) {return Math.min(a, b);}
	static int[] setArray(int a) {
		int b[]=new int[a];
		for(int i=0;i<a;i++) {
			b[i]=scan.nextInt();
		}
		return b;
	}
	static String reverce(String str) {
		String strr="";
		for(int i=str.length()-1;i>=0;i--) {
			strr+=str.charAt(i);
		}
		return strr;
	}
	public static void main(String[] args) {
		int a=scan.nextInt();
		int b[][]=new int[a][2];
		for(int i=0;i<a;i++) {
			b[i][0]=scan.nextInt();
			b[i][1]=i;
		}
		Arrays.sort(b,(x,y)->Integer.compare(x[0], y[0]));
		for(int i=0;i<a;i++) {
			System.out.print(b[i][1]+1+" ");
		}
		System.out.println();
	}
}

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

int main(){
    int x,n,A,iter=0;
    cin >> x >> n;
    vector<int> p(100,0);
    rep(i,n)  {cin >> A; p[A]++;}
    // rep(i,100) cout <<i<<" "<< p[i] << endl;
    while(1){
        if(p[x-iter] == 0){
            cout<<x-iter<<endl;
            break;
        }
        if(p[x+iter] == 0) {cout<<x+iter<<endl;break;}
        iter++;
    }

}

Measured memory_bytes: 3632
n = gets.to_i
hash = Hash.new(0)

for i in 1..n
  hash[gets.chomp] += 1
end

m = gets.to_i

for i in 1..m
  hash[gets.chomp] -= 1
end

hash = hash.sort_by{|_, v| -v}

if hash[0][1] < 0
  print "0"
else
  print hash[0][1]
end

Measured memory_bytes: 1788
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define fast ios_base::sync_with_stdio(false),cin.tie(0);
void solve(){
  int n,x,t;
  cin>>n>>x>>t;
  if(n%x==0)cout<<(n/x)*t;
  else{
    cout<<(n/x+1)*t;
  }

}
int main(){
 fast;
  int t;
  t=1;
  //cin>>t;
  while(t--){
    solve();
  }
}

Measured memory_bytes: 3612
#include<iostream>
#include<algorithm>
#include<cmath>
using namespace std;
int main() {
  int k,x,m,M;
  cin >> k >> x;
  m=max(-1000000,x-k+1);
  M=min(1000000,x+k-1);
  for(int i=m; i<M; i++) {
    cout << i << " ";
  }
  cout << M << endl;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
	int a,b,c;
	scanf("%d%d%d",&a,&b,&c);
	
	if(a < b && b < c){
		printf("%d %d %d\n",a,b,c);
	}
	if(a < c && c < b){
		printf("%d %d %d\n",a,c,b);
	}
	if(b < a && a < c){
		printf("%d %d %d\n",b,a,c);
	}
	if(b < c && c < a){
		printf("%d %d %d\n",b,c,a);
	}
	if(c < a && a < b){
		printf("%d %d %d\n",c,a,b);
	}
	if(c < b && b < a){
		printf("%d %d %d\n",c,b,a);
	}
	if(a < b && b == c){
		printf("%d %d %d\n",a,b,c);
	}
	if(b < a && a == c){
		printf("%d %d %d\n",b,a,c);
	}
	if(c < a && a == b){
		printf("%d %d %d\n",c,a,b);
	}
	if(a == b && b < c){
		printf("%d %d %d\n",a,b,c);
	}
	if(a == c && c < b){
		printf("%d %d %d\n",a,c,b);
	}
	if(b == c && c < a){
		printf("%d %d %d\n",b,c,a);
	}
	return 0;
}

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

using namespace std;

using ll =  long long;
using Pll = pair<ll, ll>;
using Pii = pair<int, int>;

constexpr ll MOD = 1000000007;
constexpr ll INF = 1LL << 60;
constexpr long double EPS = 1e-10;
constexpr int dyx[4][2] = {
    { 0, 1}, {-1, 0}, {0,-1}, {1, 0}
};

int main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
    int n;
    cin >> n;
    for(int i=1;i<=9;++i) {
        if(n % i == 0 && n/i <= 9 && 1 <= n/i) {
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define reps(i,s,n) for(int i=(s); i<(n); i++)
#define all(v) v.begin(),v.end()
#define res(n) resize(n)
#define rev(v) reverse(v.begin(),v.end())
#define sor(v) sort(v.begin(),v.end())
#define outve(v) for(auto i : v) cout << i << " ";cout << endl
#define in(n,v) for(int i=0; i<(n); i++){cin >> v[i];}
#define out(n) cout << (n) << endl
#define fi first
#define se second
#define ve vector
#define pq priority_queue
#define vi vector<int>
#define vl vector<long long>
#define vii vector<vector<int>>
using namespace std;
typedef long long ll;
typedef long double ld;
const ll mod = 1000000007;

const int INF = 1000000020;

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 main()
{
    int n;
    cin >> n;
    vi a(n),b(n);
    
    in(n,a);
    in(n,b);
    
    ve<ve<int>> dp((1<<(n+1)),vi(51,INF));
    
       dp[0][0] = 0;
    
       for(int bit = 0; bit < (1 << n); bit++) {
          
           
           int np = __builtin_popcount(bit);
           for(int k = 0; k <= 50; k++) {
               if(dp[bit][k] == INF) continue;
               
               int cost = 0;
               
               
               for(int i = 0; i < n; i++) {
                   
                   if(bit & (1 << i)) continue;
                   
                   
                   int next = (abs(i - np) % 2 == 0 ? a[i] : b[i]);
                  
                   if(next >= k) {
                       chmin(dp[bit | (1 << i)][next], dp[bit][k] + cost);
                   }
                   cost++;
               }
           }
       }
       int ans = INF;
       for(int i = 0; i <= 50; i++) chmin(ans, dp[(1 << n) - 1][i]);
       
       cout << (ans == INF ? -1 : ans) << endl;
    
    
    


    return 0;
}


Measured memory_bytes: 127360
#include<algorithm>//sort,二分探索,など
#include<bitset>//固定長bit集合
#include<stdio.h>
#include<cmath>//pow,logなど
#include<complex>//複素数
#include<deque>//両端アクセスのキュー
#include<functional>//sortのgreater
#include<iomanip>//setprecision(浮動小数点の出力の誤差)
#include<iostream>//入出力
#include<map>//map(辞書)
#include<numeric>//iota(整数列の生成),gcdとlcm(c++17)
#include<queue>//キュー
#include<set>//集合
#include<stack>//スタック
#include<string>//文字列
#include<unordered_map>//イテレータあるけど順序保持しないmap
#include<unordered_set>//イテレータあるけど順序保持しないset
#include<utility>//pair
#include<vector>//可変長配列

using namespace std;
typedef long long ll;

//マクロ
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=(a);i<=(b);i++)
#define FORD(i,a,b) for(ll i=(a);i>=(b);i--)
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x))
#define INF 1000000000000 //10^12
#define MOD 10000007 //10^9+7
#define PB push_back
#define MP make_pair

int N;
int a[1000000];
int b[1000000];
int c[1000000];
int dp[1000000][3];

int rec(int d,int act){
    int ans = 0;
    if(dp[d][act]>=0){
        ans = dp[d][act];
    }else if(d == N-1){
        ans = 0;
    }else{
        if(act == 0){
            ans=max(rec(d+1,1)+b[d+1],rec(d+1,2)+c[d+1]);
        }
        if(act == 1){
            ans=max(rec(d+1,0)+a[d+1],rec(d+1,2)+c[d+1]);
        }
        if(act == 2){
            ans=max(rec(d+1,0)+a[d+1],rec(d+1,1)+b[d+1]);
        }
    }
    dp[d][act] = ans;
    return ans;
    
    
}

int solve(){
    int P;
    scanf("%d",&N);
    REP(i,N){
        cin >> a[i] >> b[i] >> c[i];
        dp[i][0]= -1;
        dp[i][1]= -1;
        dp[i][2]= -1;

    }
    P = rec(0,0)+a[0];
    if(P<rec(0,1)+b[0]){
        P = rec(0,1)+b[0];
    }
    if(P<rec(0,2)+c[0]){
        P = rec(0,2)+c[0];
    }
    printf("%d",P);
    return 0;
}

int main(){
    solve();
}

Measured memory_bytes: 12288
#include <iostream>
#include <algorithm>
#include <cmath>
#include <cstdio>
using namespace std;
int main()
{
    int N,n;
    while(~scanf("%d",&N))
    {
        int a[9]={0},i;
        int cnt=0;
        for(i=0;i<N;i++){
            scanf("%d",&n);
            if(n<=399){
                a[0]=1;
            }else if(n<=799){
                a[1]=1;
            }else if(n<=1199){
                a[2]=1;
            }else if(n<=1599){
                a[3]=1;
            }else if(n<=1999){
                a[4]=1;
            }else if(n<=2399){
                a[5]=1;
            }else if(n<=2799){
                a[6]=1;
            }else if(n<=3199){
                a[7]=1;
            }else{
                a[8]++;
            }
        }
        for(i=0;i<8;i++){
            if(a[i]) cnt++;
        }
        int cou=cnt+a[8];
        if(cnt==0 && a[8]) cnt=1;
        printf("%d %d\n",cnt,cou);


    }
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <map>

#define reps(i,s,n) for(int (i) = (s); (i) < (n); (i)++)
#define rep(i,n) reps(i,0,n)
using namespace std;
using ll = long long;

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

    int ans = 0;
    int cnt = 0;
    
    reps(i,0,n-1){
        if(h[i] >= h[i+1]){ 
            cnt++;
        }else {
            //cout << cnt << endl;
            ans = max(ans,cnt);
            cnt = 0;
        }
    }
    cout << max(cnt,ans) << endl;
    return 0;
}

Measured memory_bytes: 3780
#include<iostream>
#include<algorithm>
#include<math.h>
#include<queue>
#include<string>
#include<vector>
#include<stack>
#include<iomanip>
#include<map>
using namespace std;
//def lib
#define rep(i,n) for(int i=0;i<((int)n);i++)
#define drep(i,n) for(int i=((int)n)-1;i>-1;i--)
#define Rep(i,n0,n) for(int i=n0;i<((int)n);i++)
#define dRep(i,n0,n) for(int i=((int)n)-1;i>n0-1;i--)
#define Com(i,j,n) for(int i=0;i<n-1;i++)for(int j=i+1;j<((int)n);j++)
#define W(x) cout<<x<<endl;
#define print(x) cout<<x<<endl;
#define Debug(x) cout<<"#DEBUG "<<x<<endl;
#define INF (1<<29)
#define INF2 (long long)8*(long long)INF*(long long)INF
#define mod 1000000007
//def end
typedef long long ll;
// lib
int min(int x,int y){if(y<x)return y;else return x;}
int max(int x,int y){if(y>x)return y;else return x;}
int fact(int x){int i=1;rep(j,x){i*=(j+1);} return i;}
int mfact(int x){int i=1;rep(j,x){i*=(j+1);} return i%mod;}
int modulo(int x){return x%mod;}
long long fact(long long x){long long i=1;rep(j,x){i*=(j+1);} return i;}
long long mfact(long long x){long long i=1;rep(j,x){i*=(j+1);} return i%mod;}
long long modulo(long long x){return x%mod;}
int gcd(int x, int y){if(x%y==0)return y;else if(y%x==0)return x;else return gcd(x%y,y%x);}
ll gcd(ll x, ll y){if(x%y==0)return y;else if(y%x==0)return x;else return gcd(x%y,y%x);}
void say(bool x){if(x){cout<<"Yes"<<endl;}else {cout<<"No"<<endl;}return;}
//lib end
int dx[8] = { 1, 0, -1, 0, 1, -1, -1, 1};
int dy[8] = { 0, 1, 0, -1, 1, 1, -1, -1};
int main()
{
    int n;
    cin >> n;
    ll a[n];
    rep(i,n){
        cin >> a[i];
    }
    sort(a, a+n);
    int left=1, right=n-1;
    ll sum=0, l=a[0], r=a[0];
    rep(i,n-1){
        ll w,x,y,z;
        w = abs(a[left]-l);
        x = abs(a[left]-r);
        y = abs(a[right]-l);
        z = abs(a[right]-r);
        if((w>=x&&w>=y)&&w>=z){
            sum+=w;
            l = a[left];
            left++;
        }
        else if((x>=w&&x>=y)&&x>=z){
            sum+=x;
            r = a[left];
            left++;
        }
        else if((y>=x&&y>=x)&&y>=z){
            sum+=y;
            l = a[right];
            right--;
        }
        else if((z>=w&&z>=x)&&z>=y){
            sum+=z;
            r = a[right];
            right--;
        }
    }
    W(sum)
    return 0;
}

Measured memory_bytes: 1024
import bisect
X,Y,A,B,C=map(int,input().split())

AList=list(map(int,input().split()))
BList=list(map(int,input().split()))
CList=list(map(int,input().split()))

AList.sort(reverse=True)
BList.sort(reverse=True)
CList.sort(reverse=True)

alist = AList[0:X] + BList[0:Y]
clist = CList
alist.sort()
ans = sum(alist)
cnt = 0

for i in range(C):
  a = clist[i]
  b = bisect.bisect_left(alist,a)
  if i < b:
    ans += a
    cnt += 1



aa = sum(alist[:cnt])

print(int(ans -aa))

Measured memory_bytes: 105708
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int n, a, b;
  cin >> n >> a >> b;
  
  if ((n*a) >= b){
    cout << b << endl;
  }
  
  else if ((n*a) < b){
    cout << n*a << endl;
  }
}

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

/**
 * 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;
        FastScanner in = new FastScanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskA solver = new TaskA();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskA {
        public void solve(int testNumber, FastScanner in, PrintWriter out) {
            int n = in.nextInt();
            int a = in.nextInt();
            int b = in.nextInt();
            out.printf("%d %d\n", Math.min(a, b), Math.max(0, a + b - n));
        }

    }

    static class FastScanner {
        private InputStream in;
        private byte[] buffer = new byte[1024];
        private int bufPointer;
        private int bufLength;

        public FastScanner(InputStream in) {
            this.in = in;
        }

        private int readByte() {
            if (bufPointer >= bufLength) {
                if (bufLength == -1)
                    throw new InputMismatchException();

                bufPointer = 0;
                try {
                    bufLength = in.read(buffer);
                } catch (IOException e) {
                    throw new InputMismatchException();
                }

                if (bufLength <= 0)
                    return -1;
            }
            return buffer[bufPointer++];
        }

        private static boolean isSpaceChar(int c) {
            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }

        public long nextLong() {
            long n = 0;

            int b = readByte();
            while (isSpaceChar(b))
                b = readByte();

            boolean minus = (b == '-');
            if (minus)
                b = readByte();

            while (b >= '0' && b <= '9') {
                n *= 10;
                n += b - '0';
                b = readByte();
            }

            if (!isSpaceChar(b))
                throw new NumberFormatException();

            return minus ? -n : n;
        }

        public int nextInt() {
            long n = nextLong();

            if (n < Integer.MIN_VALUE || n > Integer.MAX_VALUE)
                throw new NumberFormatException();

            return (int) n;
        }

    }
}



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

using namespace std;

int main(void)
{
	long long num = 1, wari = 1000000007;
	int a;

	cin >> a;
	for (int i = 1; i <= a; i++) {
		num = i * num % wari;
	}
	cout << num << endl;
}

Measured memory_bytes: 256
#include <cstdio>
using namespace std;
typedef long long int LLI;

LLI gcd(LLI a, LLI b) {
  int c, d, t;
  c = a;
  d = b;
  while (1) {
    t = c % d;
    if (!t) break;
    c = d;
    d = t;
  }
  return d;
}

LLI lcm(int a, int b) {
  int c = gcd(a, b);
  return (LLI) a * b / c;
}

int main() {
  LLI a[3], m[3], b[3];
  LLI c, s, x;
  while (1) {
    scanf("%lld %lld %lld %lld %lld %lld", &a[0], &m[0], &a[1], &m[1], &a[2], &m[2]);
    if (!a[0] && !m[0] && !a[1] && !m[1] && !a[2] && !m[2]) break;
    for (int i=0; i<3; i++) {
      s = 1;
      c = 0;
      do {
        s *= a[i];
        s %= m[i];
        ++c;
      } while (s!=1);
      b[i] = c;
    }
    x = lcm(b[0], b[1]);
    x = lcm(b[2], x);
    printf("%lld\n", x);
  }
  return 0;
}

Measured memory_bytes: 1028
#include<stdio.h>
int main(){
	int A,B,C,D;
	scanf("%d%d%d%d",&A,&B,&C,&D);
	if (A > B){
		if (C > D){
			printf("%d", B + D);
		}
		else{ printf("%d", B + C); }
	}
	else{
		if (C > D){
			printf("%d", A + D);
		}
		else{
			printf("%d", A + C);
		}
	}
	return 0;
}

Measured memory_bytes: 128
//url:
//problem name:

#include <bits/stdc++.h>
#define REP(i,n) for (int i = 0; i < (n); ++i)
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;}
using namespace std;
using ll = long long;
using P = pair<int,int>;
using Pl = pair<long,long>;
using veci = vector<int>;
using vecl = vector<long>;
using vecveci = vector<vector<int>>;
using vecvecl = vector<vector<long long>>;

int main() {
    int N;
    cin >> N;
    int k = 1;
    while(k*(k+1)/2 < N) k++;
    while(k > 0 && N > 0) {
        if(N-k >= 0) {
            cout << k << endl;
            N -= k;
        }
        k--;
    }
}



Measured memory_bytes: 256
#include "bits/stdc++.h"
#define rep(i,a,b) for(int i=int(a);i<int(b);i++)
using ll = long long;
using namespace std;

ll GCD(ll a, ll b) {
	return b ? GCD(b, a%b) : a;
}

//sort(a, a + N, greater<int>())   // descend
//sort(a, a+N)                    //  ascend

int main() {
	ll n;
	cin >> n;
	ll a[110000];
	ll b[110000];
	ll c[110000];
	ll d[110000];
	rep(i, 0, n) cin >> a[i];
	b[0] = 0;
	c[n] = 0;
	rep(i, 0, n) b[i + 1] = GCD(b[i], a[i]);
	for (int i = n - 1; i >= 0; i--) c[i] = GCD(c[i + 1], a[i]);
	ll ans = 0;
	rep(i, 0, n) {
		d[i] = GCD(b[i], c[i+1]);
		ans = max(ans, d[i]);
	}
	cout << ans;
}

Measured memory_bytes: 2816
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ll long long
#define FOR(i,a,b) for(int i=(a); i<=(b); i++)
#define rep(i,n) for(int i = 0; i < (n); i++)
#define loop(k) rep(author_is_masa,k)
#define chmin(a,b) if((a)>(b)) (a)=(b);
#define chmax(a,b) if((a)<(b)) (a)=(b);
#define vi vector<int>
#define pii pair<int,int>
#define all(v) (v).begin(),(v).end()
#define allr(v) (v).rbegin(),(v).rend()
#define pb push_back
#define pf push_front
int gcd(int a,int b){/*a>=0,b>=0,￢(a=b=0)*/
  while(min(a,b)>0){if(a<b)swap(a,b);a%=b;}return max(a,b);
}
int dx[]={1,0,-1,0,1,-1,-1,1};
int dy[]={0,1,0,-1,1,1,-1,-1};
const int MOD = 1e9+7;
const long long INF = 1e18+10;

/*--------------------------------------------------------------------*/
int modpow(int x,int n){
	int res=1;
	while(n>0){
		if(n&1) res=(res*x)%MOD;
		 x=(x*x)%MOD;
		 n>>=1;
	 }
	 return res;
}
int ncr(int n,int r){
	int res=1,fact=1;
	FOR(i,1,r) fact=(fact*i)%MOD;
	rep(i,r) res=(res*(n-i))%MOD;
	res=(res*modpow(fact,MOD-2))%MOD;
	return res;
}
signed main(){
	int n,k;
	cin>>n>>k;
	for(int i=1;i<=k;i++){
		if(n-k-i+1<0){
			cout<<0<<endl;
			continue;
		}

		cout<<ncr(n-k+1,i)*ncr(k-1,i-1)%MOD<<endl;
	}

	return 0;
}



Measured memory_bytes: 3608
#include <bits/stdc++.h>
 
using namespace std;
 
const int S = 500, SSS = S * S * S, N = 1e5 + 5, mod = 998244353;
 
long long powmod(long long b, long long p) {
  long long r = 1;
  for (; p; p >>= 1, b = b * b % mod)
    if (p & 1)
      r = r * b % mod;
  return r;
}
 
const int base = powmod(10, 18);
 
vector<int> g[N];
 
vector<pair<int, int>> independent(int n, vector<pair<int ,int>> & edges) {
  for (int i = 0; i < n; ++i)
    g[i].clear();
  for (auto e : edges) {
    g[e.first].push_back(e.second);
    g[e.second].push_back(e.first);
  }
  vector<bool> done(n, false), mark(n);
  int cnt = 0;
  vector<pair<int, int>> res;
  while (cnt < n) {
    mark = done;
    int hig = -1, sum = 0;
    for (int v = n-1; v >= 0; --v) {
      if (mark[v]) continue;
      ++cnt;
      done[v] = 1;
      hig = max(hig, v+1);
      sum = (sum + powmod(base, v+1)) % mod;
      for (int u : g[v]) {
        mark[u] = 1;
      }
    }
    res.emplace_back(hig, sum);
  }
  return res;
}
 
vector<pair<int, int>> read_edges() {
  int m;
  scanf("%d", &m);
  vector<pair<int, int>> edges(m);
  for (int i = 0; i < m; ++i) {
    scanf("%d %d", &edges[i].first, &edges[i].second);
    --edges[i].first;
    --edges[i].second;
  }
  return edges;
}
 
int main() {
  int n;
  scanf("%d", &n);
  vector<pair<int, int>> ex = read_edges();
  vector<pair<int, int>> ey = read_edges();
  vector<pair<int, int>> ez = read_edges();
  vector<pair<int, int>> rx = independent(n, ex);
  vector<pair<int, int>> ry = independent(n, ey);
  vector<pair<int, int>> rz = independent(n, ez);
  assert(rx.size() < S);
  assert(ry.size() < S);
  assert(rz.size() < S);
  long long ans = 0;
  for (int i = 0; i < (int)rx.size(); ++i) {
    for (int j = 0; j < (int)ry.size(); ++j) {
      int k = i^j;
      if (k < (int)rz.size()) {
        long long cur = rx[i].second * (long long)ry[j].second % mod;
        ans = (ans + cur * rz[k].second) % mod;
      }
    }
  }
  printf("%lld\n", ans);
  return 0;
}

Measured memory_bytes: 8448
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    while(cin >> n)
    {
        if(n<3)cout << 0 << endl;
        else if(n<6)cout << 1 << endl;
        else {
           cout << n/3 << endl; 
        }
    }
    return 0;
}


Measured memory_bytes: 3628
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.List;
import java.util.StringTokenizer;
import java.util.stream.Collectors;
import java.util.stream.IntStream;

public class Main {
    public static void main(final String[] args) {
        final FastScanner scanner = new FastScanner(System.in);
        final int n = scanner.nextInt();
        final List<Integer> list = IntStream.range(0, n)
                .mapToObj(i -> scanner.nextInt())
                .collect(Collectors.toList());

        final int[] aArray = new int[n];
        final int[] bArray = new int[n];
        for (int i = 0; i < n; i++) {
            aArray[i] = i * 50_000 + 1;
            bArray[n - i - 1] = i * 50_000 + 1;
        }

        for (int i = 0; i < list.size(); i++) {
            final int index = list.get(i) - 1;
            bArray[index] += i;
        }

        final String answer = Arrays.stream(aArray)
                .mapToObj(Integer::toString)
                .collect(Collectors.joining(" "))
                + "\n"
                + Arrays.stream(bArray)
                .mapToObj(Integer::toString)
                .collect(Collectors.joining(" "));
        System.out.println(answer);
    }

    private static class FastScanner {
        private final BufferedReader reader;
        private StringTokenizer tokenizer;

        FastScanner(final InputStream in) {
            reader = new BufferedReader(new InputStreamReader(in));
        }

        String next() {
            if (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (final IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }
    }
}
    

Measured memory_bytes: 37460
#include<cstdio>
#include<algorithm>
#include<vector>
#include<queue>
#include<string>
#include<iostream>
#include<cmath>
#include<map>
#include<set>
using namespace std;
typedef vector<string>vs;
typedef vector<int>vi;
typedef vector<vi>vvi;
typedef vector<double>vd;
typedef pair<int,int>pii;
typedef long long ll;
typedef pair<ll,ll>pll;
typedef vector<ll>vl;
#define rrep(i,x,n) for(int i=(x);i<(n);++i)
#define rep(i,x) rrep(i,0,(x))
#define fi first
#define se second
#define each(i,c) for(__typeof((c).begin()) i=(c).begin();i!=(c).end();++i)
#define all(c) (c).begin(),(c).end()
#define rall(c) (c).rbegin(),(c).rend()
#define pb push_back
#define maxs(a,b) (a)=max(a,b)
#define mins(a,b) (a)=min(a,b)

map<char,string>a;
map<string,char>b;

void init(){
    a['A']="00000";
    a['B']="00001";
    a['C']="00010";
    a['D']="00011";
    a['E']="00100";
    a['F']="00101";
    a['G']="00110";
    a['H']="00111";
    a['I']="01000";
    a['J']="01001";
    a['K']="01010";
    a['L']="01011";
    a['M']="01100";
    a['N']="01101";
    a['O']="01110";
    a['P']="01111";
    a['Q']="10000";
    a['R']="10001";
    a['S']="10010";
    a['T']="10011";
    a['U']="10100";
    a['V']="10101";
    a['W']="10110";
    a['X']="10111";
    a['Y']="11000";
    a['Z']="11001";
    a[' ']="11010";
    a['.']="11011";
    a[',']="11100";
    a['-']="11101";
    a['\'']="11110";
    a['?']="11111";

    b["101"]=' ';
    b["000000"]='\'';
    b["000011"]=',';
    b["10010001"]='-';
    b["010001"]='.';
    b["000001"]='?';
    b["100101"]='A';
    b["10011010"]='B';
    b["0101"]='C';
    b["0001"]='D';
    b["110"]='E';
    b["01001"]='F';
    b["10011011"]='G';
    b["010000"]='H';
    b["0111"]='I';
    b["10011000"]='J';
    b["0110"]='K';
    b["00100"]='L';
    b["10011001"]='M';
    b["10011110"]='N';
    b["00101"]='O';
    b["111"]='P';
    b["10011111"]='Q';
    b["1000"]='R';
    b["00110"]='S';
    b["00111"]='T';
    b["10011100"]='U';
    b["10011101"]='V';
    b["000010"]='W';
    b["10010010"]='X';
    b["10010011"]='Y';
    b["10010000"]='Z';
}


int main(){
    init();
    string str;
    while(getline(cin,str)){
        string s;
        rep(i,str.size())s+=a[str[i]];
        int cur=0;
        while(true){
            bool used=false;
            for(int i=1;cur+i<=s.size();i++){

                if(b.find(s.substr(cur,i))==b.end())continue;
                used=true;
                cout<<b[s.substr(cur,i)];
                cur+=i;
                break;
            }
            if(cur==s.size()||used==false)break;
        }
        cout<<endl;
    }
}

Measured memory_bytes: 1208
/*
	0587:Tunnel
*/
#include	<iostream>
#include	<algorithm>

using namespace std;

int main(void) {
	int n, m;
	int maxS = 0;
	bool frag = false;
	
	cin >> n >> m;
	
	int tc = m;
	maxS = tc;
	
	for(int i = 0; i < n; i++) {
		int a, b;
		cin >> a >> b;
		
		tc = tc + a - b;
		if(tc < 0) { frag = true; }
		
		maxS = max(tc, maxS);
	}
	
	if(frag) { maxS = 0; }
	cout << maxS << endl;
	
	return 0;
}

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

const double PI = 3.14159265358979323846;
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
#define rep(i, n) for (int i = 0; i < (n); ++i)
//#define rep(i, n) for (ll i = 0; i < (n); ++i)
//typedef pair<ll, ll> P;
const ll INF = 10e17;
#define cmin(x, y) x = min(x, y)
#define cmax(x, y) x = max(x, y)
#define ret() return 0;

std::istream &operator>>(std::istream &in, set<ll> &o) {
    ll a;
    in >> a;
    o.insert(a);
    return in;
}

std::istream &operator>>(std::istream &in, queue<int> &o) {
    ll a;
    in >> a;
    o.push(a);
    return in;
}

bool contain(set<int> &s, int a) { return s.find(a) != s.end(); }

//ifstream myfile("C:\\Users\\riku\\Downloads\\0_00.txt");
//ofstream outfile("log.txt");
//outfile << setw(6) << setfill('0') << prefecture << setw(6) << setfill('0') << rank << endl;
// std::cout << std::bitset<8>(9);

//const ll mod = 1e10;
//typedef priority_queue<P, vector<P>, greater<P> > PQ_ASK;

struct MP {
    int n;
    vector<int> a;
    vector<int> t;

    MP() {}

    MP(const vector<int> &t) : t(t) {
        n = t.size();
        a = vector<int>(n + 1);
        a[0] = -1;
        int j = -1;
        for (int i = 0; i < n; i++) {
            while (j != -1 && t[j] != t[i]) j = a[j];
            j++;
            a[i + 1] = j;
        }
    }

    int operator[](int i) {
        return a[i];
    }

    vector<int> findAll(const vector<int> &s) {
        vector<int> res;
        int j = 0;
        for (int i = 0; i < s.size(); i++) {
            while (j != -1 && t[j] != s[i]) j = a[j];
            j++;
            if (j == n) {
                res.push_back(i - j + 1);
                j = a[j];
            }
        }
        return res;
    }
};

vector<int> f(vector<int> &a) {
    int n = a.size();
    vector<int> res(n);
    rep(i, n) res[i] = a[i] ^ a[(i + 1) % n];
    return res;
}

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

    vector<int> a(n), b(n);
    rep(i, n) cin >> a[i];
    rep(i, n) cin >> b[i];
    vector<int> xa = f(a);
    vector<int> xb = f(b);
    xb.insert(xb.end(), xb.begin(), xb.end());
    MP mp(xa);
    vector<int> res = mp.findAll(xb);
    vector<int> ks;
    for (int p : res) ks.push_back(n - p);
    sort(ks.begin(), ks.end());
    for (int k : ks) {
        if (k >= n)continue;
        int x = a[k] ^b[0];
        printf("%d %d\n", k, x);
    }


}

Measured memory_bytes: 11724
s=list(map(int,list(input())))
import itertools
ans=0
for i in itertools.product([0,1], repeat=len(s)-1):
    sums=0
    snum=s[0]
    for ii in range(len(i)):
        if i[ii]==0:
            snum=snum*10+s[ii+1] 
#            print(i,ii,snum,sums)           
        else:
            sums=sums+snum
#            print(i,ii,snum,sums)
            snum=s[ii+1]
    sums=sums+snum
#    print(i)
#    print(sums,"---------")
    ans=ans+sums
print(ans)                


Measured memory_bytes: 3188
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define endl 	"\n"

typedef vector< ll > 	vi;
typedef vector< vi > 	vvi;
typedef pair< ll,ll > 	ii;
#define pb 		push_back
#define all(c) 		(c).begin(),(c).end()
#define tr(c,i) 	for(typeof((c).begin() i = (c).begin(); i != (c).end(); i++)
#define present(c,x) 	((c).find(x) != (c).end())

#define MOD 	1000000007
#define INF 	(int)1e9
#define MEM(a, b) memset(a, (b), sizeof(a))

int main()
{	 ios_base::sync_with_stdio(false);
	 cin.tie(NULL);
	
	ll n;
	cin>>n;
	ll a[n],b[n],c[n-1];
	ll sum=0;
	for(ll i=0; i<n; i++)
		cin>>a[i]; 
	for(ll i=0; i<n; i++)
		{ cin>>b[i]; sum+=b[i]; } 
	for(ll i=0; i<n-1; i++)
		cin>>c[i];
	//cout<<sum;
	for(ll i=0; i<n-1; i++)
	{
		if(a[i+1]-a[i] == 1)
			{ //cout<<a[i]<<" "<<a[i+1]<<endl;
				sum+= c[a[i]-1];
				//cout<<sum<<" ";
			}
	}
	cout<<sum;

	return 0;
	
}

Measured memory_bytes: 256