akhauriyash/Code-Regression huggingface dataset:
import numpy as np
 
def main():
    N, K = map(int, input().split(" "))
    ps = np.array(input().split(" "))
    ps = ps.astype("int64")
 
    ps_means = np.zeros(N)
    maxval = 0
 
    for i in range(N):
        ps_means[i] = ((1 + ps[i]) * ps[i])/ 2
        if i + 1 >= K:
            if i + 1 == K:
                sumval = np.sum(ps_means[i-K+1:i+1] / ps[i-K+1:i+1])
            else:
                sumval -= ps_means[i-K] / ps[i-K]
                sumval += ps_means[i] / ps[i]
            if sumval > maxval:
                maxval = sumval
 
    ans = maxval
    print(ans)
 
if __name__ == '__main__':
    main()

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

#define rng(i, a, b) for (int i = int(a); i < int(b); i++)
#define rep(i, b) rng(i, 0, b)
#define gnr(i, a, b) for (int i = int(b) - 1; i >= int(a); i--)
#define per(i, b) gnr(i, 0, b)

using namespace std;

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

int main() {
  int k;
  cin >> k;
  ll x = 7 % k;
  ll res = -1;
  for (int i = 1; i <= k; i++) {
    if (x % k == 0) {
      res = i;
      break;
    }
    x = (x * 10 + 7) % k;
  }
  cout << res << endl;
  return 0;
}


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

namespace AC {
#define ll long long
#define PLL pair<ll, ll>
#define PDD pair<double, double>
#define PDPLL pair<double, PLL>
#define PLPLL pair<ll, PLL>
#define pb push_back
#define fi first
#define se second
#define ls rt << 1
#define rs rt << 1 | 1

    const ll N = 1e5 + 66;

    ll BUGS = 1;

    inline ll read(){
        ll x = 0;    bool flag = 1;   char ch = getchar();
        while(ch < '0' || ch > '9') { if(ch == '-') flag = 0; ch = getchar(); }
        while(ch >= '0' && ch <= '9') { x = (x << 1) + (x << 3) + ch - '0'; ch = getchar(); }
        if(flag) return x;  return (~(x - 1));
    }

    inline void read(ll arr[], ll s, ll e) { for(ll i = s; i <= e; ++i) arr[i] = read(); }

    inline void write(ll x){
        if(x < 0) { x = ~(x - 1); putchar('-'); }
        if(x > 9) write(x / 10); putchar(x % 10 + '0');
    }

    inline void print(ll x) { write(x); puts(""); }

    inline void print(ll arr[], ll s, ll e) {
        for(ll i = s; i <= e - 1; ++i) write(arr[i]), putchar(' ');
        write(arr[e]); puts("");
    }

    inline ll max3(ll a, ll b, ll c) { return max(a, max(b, c)); }

    inline ll min3(ll a, ll b, ll c) { return min(a, min(b, c)); }

    inline void debugNum(ll num, string ss) { cout << "BUGS" << BUGS++ << " : " << ss << " : " << num << endl; }

    inline void debugArr(ll arr[], ll s, ll e, string ss) {
        cout << "BUGS" << BUGS++ << " : " << ss << " : " << endl;
        for(ll i = s; i <= e; ++i) cout << "i : " << i << " val : " << arr[i] << endl;
    }

    inline void IO() {
        //ios::sync_with_stdio(false), cout.tie(0), cin.tie(0);
        //cout << setiosflags(ios::fixed) << setprecision(1); //保留小数点后1位
        //cout << setprecision(1); //保留1位有效数字
        freopen("in.txt", "r", stdin);
        freopen("out.txt", "w", stdout);
    }
}using namespace AC;

ll n;

int main() {
    //IO();
    while(cin >> n) {
        ll ans = (n % 1000);
        if(ans != 0) ans = 1000 - ans;
        print(ans);
    }
    return 0;
}



Measured memory_bytes: 3596
#include<bits/stdc++.h>
using namespace std;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> ii;
#define ll long long
#define rep(i,a,b) for(ll i=a;i<b;i+=1)
#define rrep(i,a,b) for(ll i=a;i>b;i-=1)
#define vi vector<ll>
#define vii vector<vector<ll> >
#define all(c) (c).begin(),(c).end()
#define pb push_back
#define sz(a) int((a).size())
#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 cpresent(c,x) (find(all(c),x) != (c).end())
#define mp make_pair
#define hell 1000000007
#define F first
#define S second
//debug
#define trace(x)                 cerr << #x << ": " << x << endl;
#define trace2(x, y)             cerr << #x << ": " << x << " | " << #y << ": " << y << endl;
#define trace3(x, y, z)          cerr << #x << ": " << x << " | " << #y << ": " << y << " | " << #z << ": " << z << endl;
ll t=1;
void solve()
{
    int n;
    cin>>n;
    vector<int> v(n);
    int dp[n];
    for(int i=0;i<n;i++)
    {
        cin>>v[i];
    }
    dp[0]=0;
    dp[1]=abs(v[1]-v[0]);
    for(int i=2;i<n;i++)
    {
        dp[i]=min(abs(v[i]-v[i-2])+dp[i-2],abs(v[i]-v[i-1])+dp[i-1]);
    }
    cout<<dp[n-1];
}
int main()
{
    int i;
  	ios_base::sync_with_stdio(false);
	cin.tie(0);
    cout.tie(0);
  	//cin>>t;
  	while(t--)
	solve();
	return 0;
}


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

int main()
{
	bool flag=true;
	int a,b,c;
	cin>>a>>b>>c;
	for(int i=b;i<=c;i++)
	{
		if(i%a==0)
			flag=false;
	}
	if(flag)
		cout<<"NG";
	else
		cout<<"OK";

	return 0;
}

Measured memory_bytes: 3624
#include <iostream>

using namespace std;

const int YOKO = 0;
const int TATE = 1;
const int BLOCK_WIDTH = 4;
const int BLOCK_HEIGHT = 2;

int map[101][101];
int pmap[101][101];
int w, h;
int xs, ys, xg, yg;
bool answer = false;

void init() {
  answer = false;
  for (int i = 0; i < 101; i++) {
    for (int j = 0; j < 101; j++) {
      map[i][j] = 0;
      pmap[i][j] = 0;
    }
  }
}

void set_block(int c, int d, int x, int y) {
  int height, width;
  if (d == YOKO) {
    height = BLOCK_HEIGHT;
    width = BLOCK_WIDTH;
  } else {
    height = BLOCK_WIDTH;
    width = BLOCK_HEIGHT;
  }
  for (int i = 0; i < height; i++) {
    for (int j = 0; j < width; j++) {
      map[y + i][x + j] = c;
    }
  }
}

void find(int c, int x, int y) {
  if (c == map[y][x]) {
    pmap[y][x] = 1;
  }
  if (pmap[yg][xg]) {
    answer = true;
    return;
  }
  if (x - 1 > 0 && c == map[y][x - 1] && !pmap[y][x - 1]) {
    find(c, x - 1, y);
  }
  if (x + 1 < 101 && c == map[y][x + 1] && !pmap[y][x + 1]) {
    find(c, x + 1, y);
  }
  if (y - 1 > 0 && c == map[y - 1][x] && !pmap[y - 1][x]) {
    find(c, x, y - 1);
  }
  if (y + 1 < 101 && c == map[y + 1][x] && !pmap[y + 1][x]) {
    find(c, x, y + 1);
  }
}

int main() {
  int n, c, d, x, y;
  while(cin >> w >> h, w) {
    cin >> xs >> ys;
    cin >> xg >> yg;
    cin >> n;
    init();
    for (int i = 0; i < n; i++) {
      cin >> c >> d >> x >> y;
      set_block(c, d, x, y);
    }
    find(map[ys][xs], xs, ys);
    cout << ((answer) ? "OK" : "NG") << endl;
  }
  return 0;
}

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

int main(){
  int n,m,l;
  cin>>n>>m>>l;
  int a[100][100];
  for(int i=0;i<n;i++){
    for(int j=0;j<m;j++){
      cin>>a[i][j];
    }
  }
  int b[100][100];
  for(int i=0;i<m;i++){
    for(int j=0;j<l;j++){
      cin>>b[i][j];
    }
  }
  long long c[100][100]={};
  for(int i=0;i<n;i++){
    for(int j=0;j<l;j++){
      for(int k=0;k<m;k++){
        c[i][j] +=a[i][k]*b[k][j];
      }
    }
  }
  for(int i=0;i<n;i++){
    for(int j=0;j<l;j++){
      if(j) cout<<" ";
      cout<<c[i][j];
    }
  cout<<endl;
}
  return 0;
}



Measured memory_bytes: 3192
import sys,math,copy
input = sys.stdin.readline

N=int(input().strip())
A=[int(x) for x in input().strip().split()]
def gcd(a,b):
    if b==0:
        return a
    
    return gcd(b,a%b)

ANS=[]
L=[0]
R=[0]
for i in range(len(A)):
    L.append(gcd(A[i],L[-1]))
    R.append(gcd(A[-1-i],R[-1]))

R.reverse()
for i in range(len(L)-1):
    ANS.append(gcd(L[i],R[i+1]))

print(max(ANS))


Measured memory_bytes: 14964
n = int(input())
gifts = []
for i in range(n):
    gift = input().split()
    gifts.append(gift)
ans = 0
for j in range(n):
    if gifts[j][1] == "BTC":
        price = float(gifts[j][0]) * 380000
        ans += price
    elif gifts[j][1] == "JPY":
        price = float(gifts[j][0])
        ans += price
print(ans)

Measured memory_bytes: 3060
#include<iostream>
#include<cstdio>
#include<vector>
#include<algorithm>
#include<set>
#include<map>

using namespace std;

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

#define PRINT(str) printf(#str "\n")
#define yOUT PRINT(Yes)
#define nOUT PRINT(No)
#define YOUT PRINT(YES)
#define NOUT PRINT(NO)
 
#define pb(a) push_back(a)
#define all(x) (x).begin(),(x).end()

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

    sort(all(a));
    REP(i, n) cout << a[i];
    cout << endl;
}


Measured memory_bytes: 256
/* template.cpp {{{ */
#include <bits/stdc++.h>
using namespace std;
#define get_macro(a, b, c, d, name, ...) name
#define rep(...) get_macro(__VA_ARGS__, rep4, rep3, rep2, rep1)(__VA_ARGS__)
#define rrep(...) get_macro(__VA_ARGS__, rrep4, rrep3, rrep2, rrep1)(__VA_ARGS__)
#define rep1(n) rep2(i_, n)
#define rep2(i, n) rep3(i, 0, n)
#define rep3(i, a, b) rep4(i, a, b, 1)
#define rep4(i, a, b, s) for (ll i = (a); i < (ll)(b); i += (ll)(s))
#define rrep1(n) rrep2(i_, n)
#define rrep2(i, n) rrep3(i, 0, n)
#define rrep3(i, a, b) rrep4(i, a, b, 1)
#define rrep4(i, a, b, s) for (ll i = (ll)(b) - 1; i >= (ll)(a); i -= (ll)(s))
#define each(x, c) for (auto &&x : c)
#define fs first
#define sc second
#define all(c) begin(c), end(c)
using ui = unsigned;
using ll = long long;
using ul = unsigned long long;
using ld = long double;
const int inf = 1e9 + 10;
const ll inf_ll = 1e18 + 10;
const ll mod = 1e9 + 7;
const ll mod9 = 1e9 + 9;
const int dx[]{-1, 0, 1, 0, -1, 1, 1, -1};
const int dy[]{0, -1, 0, 1, -1, -1, 1, 1};
template<class T, class U> void chmin(T &x, const U &y){ x = min<T>(x, y); }
template<class T, class U> void chmax(T &x, const U &y){ x = max<T>(x, y); }
struct prepare_ { prepare_(){ cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(12); } } prepare__;
/* }}} */

int main(){
  char c;
  cin >> c;
  each(d, "aeiou") if (c == d) cout << "vowel\n", exit(0);
  cout << "consonant\n";
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <stack>
#include <queue>
#include <algorithm>
#include <cmath>
#include <string>
#include <map>
#include <set>
#include <list>

#define ll long long
#define fornum(A,B,C) for(A=B;A<C;A++)

using namespace std;

int i,j,k,l,m;
/////////////////////////////////////////////////////
#define mkp make_pair

char n[101010];
int len;
vector<pair<int,int>> ans;

void errors(){
    printf("-1");
    exit(0);
}

int main(){
    scanf("%s",&n);
    for(len=0;n[len]!='\0';len++);
    if(n[len-1]!='0'||n[0]!='1')
        errors();
    int hlen=(len+1)/2;
    for(i=0;i<hlen;i++){
        if(n[i]!=n[len-2-i])
            errors();
    }

    int a=1;
    for(i=1;i<len;i++){
        ans.push_back(mkp(a,i+1));
        if(n[i-1]=='1'){
            a=i+1;
        }
    }
    for(i=0;i<ans.size();i++){
        printf("%d %d\n",ans[i].first,ans[i].second);
    }

    return 0;
}

Measured memory_bytes: 2420
#include<stdio.h>
int main(void) {
	int h1, h2,hp, k1, k2,kp, a, b, c, d;
	scanf("%d%d", &h1, &h2);
	scanf("%d%d", &k1, &k2);
	scanf("%d%d%d%d", &a, &b, &c, &d);
	hp = h1*a + h2*b + h1 / 10 * c + h2 / 20 * d;
	kp = k1*a + k2*b + k1 / 10 * c + k2 / 20 * d;
	if (hp == kp) {
		printf("even\n");
	}
	else if (hp>kp) {
		printf("hiroshi\n");
	}
	else {
		printf("kenjiro\n");
	}
	return 0;
}


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

int main() {
int n;
cin >> n;
vector<int>vec(n);
for (int i=0;i<n;i++){
    cin>>vec.at(i);
}
int ans=0;
for (int i=0;i<n;i++){
    ans+=vec.at(i);
}
cout << ans - n <<endl;
}


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

using namespace std;

int main(void){
    int n;
    cin >> n;
    vector<int> a(n);
    int maxj = -1;
    for(int i = 0; i < n; i++){
        cin >> a[i];
        if(i == 0){
            a[i] --;
            maxj = a[i];
            continue;
        }
        if(a[i-1] <= a[i] - 1) a[i] --;
        if(a[i] < maxj){
            cout << "No" << endl;
            return 0;
        }
        maxj = a[i];
    }
    cout << "Yes" << endl;
    return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>  //2fat2code a.k.a grandmixer420
#define ll long long
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#define all(a) (a).begin(), (a).end()
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define sz size
#define fr first
#define sc second
#define pb push_back
#define er erase
#define in insert
#define mp make_pair
#define pi pair
#define rc(s) return cout<<s,0
#define int long long
using namespace std;

int n,a[15];

int32_t main(){
    ios_base :: sync_with_stdio(0); cin.tie(); cout.tie();
    cin >> n;
    for(int i=1;i<=n;i++) cin >> a[i];
    sort(a+1,a+n+1);
    int sum=0;
    for(int i=1;i<n;i++){
        sum+=a[i];
    }
    if(sum>a[n]) rc("Yes");
    rc("No");
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int>   II;
typedef vector< II >      VII;
typedef vector<int>     VI;
typedef vector< VI > 	VVI;
typedef long long int 	LL;
typedef vector<LL> 		VL;
typedef unsigned long long int ULL;

#define PB push_back
#define MP make_pair
#define F first
#define S second
#define SZ(a) (int)(a.size())
#define ALL(a) a.begin(),a.end()
#define SET(a,b) memset(a,b,sizeof(a))
#define LET(x,a) __typeof(a) x(a)

#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
//Works for forward as well as backward iteration

#define gu getchar
#define pu putchar
#define si(n) cin>>n
#define dout(n) cout<<n<<"\n"
//# define M_PI           3.14159265358979323846264338327950288

#define DRT() int t; si(t); while(t--)

#define PlUSWRAP(index,n) index = (index+1)%n		//index++; if(index>=n) index=0
#define MINUSWRAP(index,n) index = (index + n -1)%n 	//index--; if(index<0) index=n-1
#define ROUNDOFFINT(d) d = (int)((double)d + 0.5)	//Round off d to nearest integer

#define FLUSHN while(gu()!='\n')
#define FLUSHS while(gu()!=' ')

#define TRACE

#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
	cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
	const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...)
#endif

#define off ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)

// set_name.find_by_order(k) It returns to an iterator to the kth element (counting from zero) in the set in O(logn) time
// set_name.order_of_key(k) It returns to the number of items that are strictly smaller than our item k in O(logn) time.

int main() {
	#ifndef ONLINE_JUDGE
    freopen("../input.txt", "r", stdin);
    freopen("../output.txt", "w", stdout);
	#endif
	srand(chrono::steady_clock::now().time_since_epoch().count());
	off;
	LL n;
	cin>>n;
	VL arr(n);
	rep(i,0,n)
	cin>>arr[i];
	LL x = 0;
	rep(i,0,n){
		x ^= arr[i];
	}
	VL ans(n);
	rep(i,0,n){
		ans[i] = x^arr[i];
	}
	rep(i,0,n){
		cout<<ans[i]<<" ";
	}
  	return 0;
}

Measured memory_bytes: 6328
I=lambda:map(int,input().split())
N=0xfffff
n,q=I()
c=list(I())
Q=[]
R=range
for i in R(q):l,r=I();Q.append(l<<40|r<<20|i)
Q.sort()
A=[[]for i in R(N)]
for i in R(n):A[c[i]].append(i)
B=[0]*N
def P(i,x):
	i+=1
	while i<=n:B[i]+=x;i+=i&-i
def G(i):
	s=0
	while i:s+=B[i];i-=i&-i
	return s
for i in A:
	if i:P(i[0],1);i.reverse()
t=0
o=[0]*q
for x in Q:
	l=x>>40
	r=x>>20&N
	i=x&N
	while t+1<l:
		b=A[c[t]]
		P(b[-1],-1)
		b.pop()
		if b:P(b[-1],1)
		t+=1
	o[i]=G(r)-G(l-1)
for i in o:print(i)

Measured memory_bytes: 248880
#include <iostream>
#include <vector>
#include <cstring>
#include <string>
#include <algorithm>
#include <iomanip>
using namespace std;

const int MAX_V = 300;

int V;
bool G[MAX_V][MAX_V];
int match[MAX_V];
bool used[MAX_V];

bool dfs(int v) {
	used[v] = true;
	for(int i = 0; i < V; i++) {
		if(!G[v][i]) continue;
		int u = i, w = match[u];
		if(w < 0 || (!used[w] && dfs(w))) {
			match[v] = u;
			match[u] = v;
			return true;
		}
	}
	return false;
}

int bipartite_matching() {
	int res = 0;
	memset(match, -1, sizeof(match));
	for(int v = 0; v < V; v++) {
		if(match[v] < 0) {
			memset(used, 0, sizeof(used));
			if(dfs(v)) {
				res++;
			}
		}
	}
	return res;
}

int N, M;
int xa[100], ya[100], xb[100], yb[100], v[100];

bool check(double k) {
	memset(G, 0, sizeof G);
	for(int i = 0; i < N; i++) {
		for(int j = 0; j < M; j++) {
			double d = sqrt((xa[i] - xb[j]) * (xa[i] - xb[j]) + (ya[i] - yb[j]) * (ya[i] - yb[j]));
			G[i][j + N] = G[j + N][i] = d / v[i] <= k;
		}
	}

	return bipartite_matching() == M;
}

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

	while(cin >> N >> M, N) {
		V = N + M;
		for(int i = 0; i < N; i++) {
			cin >> xa[i] >> ya[i] >> v[i];
		}
		for(int i = 0; i < M; i++) {
			cin >> xb[i] >> yb[i];
		}

		double ng = 0, ok = 1e9;
		for(int loop = 0; loop < 100; loop++) {
			double mid = (ng + ok) / 2.0;
			if(check(mid)) ok = mid;
			else ng = mid;
		}
		cout << fixed << setprecision(10) << ok << endl;
	}
}

Measured memory_bytes: 3312
#include <stdio.h>

#define MAX 500000
#define SENTINEL 2000000000

int L[MAX/2+2], R[MAX/2+2];
int cnt;

void merge(int A[],int n,int left, int mid, int right) {
  int i, j, k;
  int n1 = mid -left;
  int n2 = right - mid;
  for(i=0;i<n1;i++) L[i] = A[left + i];
  for(i=0;i<n2;i++) R[i] = A[mid + i];
  L[n1] = R[n2] = SENTINEL;
  i=0, j=0;
  for(k=left; k<right; k++) {
    cnt++;
    if(L[i]<=R[j]) {
      A[k] = L[i++];
    } else {
      A[k] = R[j++];
    }
  }
}

void mergeSort(int A[],int n,int left,int right) {
  int mid;
  if(left+1 < right) {
    mid = (left+right) / 2;
    mergeSort(A,n,left,mid);
    mergeSort(A,n,mid, right);
    merge(A,n,left,mid,right);
  }
}

int main(void) {
  int A[MAX], n, i;
  cnt = 0;

  scanf("%d",&n);
  for(i=0;i<n;i++) scanf("%d",&A[i]);

  mergeSort(A, n, 0, n);
  for(i=0;i<n;i++) {
    if(i) printf(" ");
    printf("%d",A[i]);
  }
  printf("\n%d\n",cnt);

  return 0;
}


Measured memory_bytes: 5764
#include <bits/stdc++.h>
//#include <ext/numeric>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
#define oo 0x3f3f3f3f
#define OO 0x3f3f3f3f3f3f3f3f
#define popcount(n) __builtin_popcount(n)
#define popcountll(n) __builtin_popcountll(n)

using namespace std;
//using namespace __gnu_cxx;
using namespace __gnu_pbds;
template<typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

const double PI = acos(-1.0), EPS = 1e-6;
const long long inf = 2e12 + 12;
const int MAXN = 302, MAXM = 45004, Mod = 998244353 , MAXLog = 20;

int main() {
#ifndef ONLINE_JUDGE
//    freopen("input.txt", "rt", stdin);
//    freopen("output.txt", "w", stdout);
#endif
    ios::sync_with_stdio(false), cin.tie(0), cout.tie(0), cout.precision(10), cout << fixed;

    int a, p;
    cin >> a >> p;


    cout << (a * 3 + p) / 2 << '\n';


    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
  
#define ll long long
#define all(aaa) aaa.begin(), aaa.end()

const int N = 105;
int a[N];

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

    int n;
    cin >> n;

    for (int i = 0; i < n - 1 - i - n % 2; i++) {
        a[i] = a[n - 1 - i - n % 2] = i;
    }

    if (n % 2)
        a[n - 1] = n;


    vector<pair<int, int>> v;

    for (int i = 0; i < n; i++) {
        for (int j = i + 1; j < n; j++) {
            if (a[i] != a[j]) {
                v.push_back({i, j});
            }
        }
    }

    int s[105];
    memset(s, 0, sizeof(s));

    for (auto p : v) {
        s[p.first] += p.second + 1;
        s[p.second] += p.first + 1;
    }

    cout << v.size() << "\n";
    for (auto p : v) {
        cout << p.first + 1 << " " << p.second + 1 << "\n";
    }
    return 0;
};

Measured memory_bytes: 384
#include <iostream>

using namespace std;

int n;
int A[20];

bool ok(int now, int x) {
	if (x == 0) return true;
	if (now == n) return false;
	return (ok(now + 1, x) || ok(now + 1, x - A[now]));
}

int main() {
	cin >> n;
	for (int i = 0; i < n; ++i) cin >> A[i];
	int q; cin >> q;
	while (q--) {
		int m; cin >> m;
		cout << (ok(0, m) ? "yes" : "no") << endl;
	}

	return 0;
}


Measured memory_bytes: 3072
import sys
from collections import deque

input = sys.stdin.readline


def main():
    N = int(input())
    A = [0] * N
    for i in range(N):
        A[i] = int(input())

    A.sort()
    ans = 0
    if N % 2 == 1:
        # center is minimum
        a = deque(A[1:])
        b = deque([A[0]])
        nxt = "r"
        while a:
            if nxt == "r":
                nxt = "l"
                x = a.pop()
                y = a.pop()
                b.appendleft(x)
                b.append(y)
            else:
                nxt = "r"
                x = a.popleft()
                y = a.popleft()
                b.appendleft(x)
                b.append(y)
        diff = sum(abs(b[i + 1] - b[i]) for i in range(N - 1))
        ans = max(ans, diff)
        # center is maximum
        a = deque(A[::-1][1:])
        b = deque([A[-1]])
        nxt = "r"
        while a:
            if nxt == "r":
                nxt = "l"
                x = a.pop()
                y = a.pop()
                b.appendleft(x)
                b.append(y)
            else:
                nxt = "r"
                x = a.popleft()
                y = a.popleft()
                b.appendleft(x)
                b.append(y)
        diff = sum(abs(b[i + 1] - b[i]) for i in range(N - 1))
        ans = max(ans, diff)

    else:
        # center is minimum
        a = deque(A[1:])
        b = deque([A[0]])
        nxt = "r"
        while a:
            if len(a) == 1:
                rem = a.pop()
                break
            if nxt == "r":
                nxt = "l"
                x = a.pop()
                y = a.pop()
                b.appendleft(x)
                b.append(y)
            else:
                nxt = "r"
                x = a.popleft()
                y = a.popleft()
                b.appendleft(x)
                b.append(y)
        diff = sum(abs(b[i + 1] - b[i]) for i in range(N - 2))
        diff += max(abs(rem - b[0]), abs(rem - b[-1]))
        ans = max(ans, diff)

        # center is maximum
        a = deque(A[::-1][1:])
        b = deque([A[-1]])
        nxt = "r"
        while a:
            if len(a) == 1:
                rem = a.pop()
                break
            if nxt == "r":
                nxt = "l"
                x = a.pop()
                y = a.pop()
                b.appendleft(x)
                b.append(y)
            else:
                nxt = "r"
                x = a.popleft()
                y = a.popleft()
                b.appendleft(x)
                b.append(y)
        diff = sum(abs(b[i + 1] - b[i]) for i in range(N - 2))
        diff += max(abs(rem - b[0]), abs(rem - b[-1]))
        ans = max(ans, diff)

    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 15712
[<AutoOpen>]
module Program

open System

let read f = stdin.ReadLine() |> f
let reads f = stdin.ReadLine().Split() |> Array.toList |> List.map f

[<EntryPoint>]
let main _ =
    let n = read int
    List.filter (fun x -> (String.length (string x)) % 2 = 1) [1..n]
    |> List.length
    |> printfn "%i"
    0

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

#define gcd(a,b)		__gcd(a,b)
#define lcm(a,b)		(a*b)/gcd(a,b)
#define ff              first
#define ss              second
#define int             long long
#define float			double
#define pb              emplace_back
#define mp              make_pair
#define pii             pair<int,int>
#define vi              vector<int>
#define vc				vector<char>
#define vb				vector<bool>
#define vf				vector<float>
#define vs				vector<string>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int>>
#define hashmap         unordered_map
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod             1000000007
#define inf             INT64_MAX
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define w(x)            int x; cin>>x; while(x--)
#define all(x)			x.begin(),x.end()
#define digits(x)		floor(log10(x))+1
#define FIO				ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)

template<class T>
void printV(vector<T> a) {for (auto v : a)cout << v << " ";}
template<class T>
void readV(vector<T>& a) {int n = a.size(); for (int i = 0 ; i < n ; i++)cin >> a[i];}
template<class T>
void printA(T* a , int n) {for (int i = 0; i < n  ; i++)cout << a[i] << " ";}
template<class T>
void readA(T* a , int n) {for (int i = 0 ; i < n ; i++)cin >> a[i];}
auto clk = clock();
mt19937_64 rang(chrono::high_resolution_clock::now().time_since_epoch().count());
void run_time() {cout << endl<<"Time elapsed: " << (double)(clock() - clk) / CLOCKS_PER_SEC << endl;}

void aryan_pandeya() {
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
}

int modPower(int x , int y , int p){
	x%=p;
	int res = 1; 
	if(x==0){
		return 0 ;
	}

	while(y>0){
		if(y&1){
			res = (res*x)%p;
		}

		y>>=1;
		x = (x*x)%p;
	}
	return res;
}


int32_t main() {
	aryan_pandeya();
	FIO;

	int n ;
	cin>>n ;

	int a = modPower(10,n,mod);
	int b = modPower(9,n,mod);
	a = (a-b+mod)%mod;
	a = (a-b+mod)%mod;
	int c = modPower(8,n,mod);
	a = (a+c)%mod;
	cout<<a;


	return 0;
}


Measured memory_bytes: 3636
// https://atcoder.jp/contests/abc172/tasks/abc172_e

#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;

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

#define DEBUG 1
#if DEBUG
  #define _GLIBCXX_DEBUG
  #define DUMP(a) REP(_i, a.size()) cout << a[_i] << (_i + 1 == a.size() ? "\n" : " ")
  #define DUMP2D(b) REP(_j, b.size()) DUMP(b[_j]); cout << endl
#else
  #define DUMP(a)
  #define DUMP2D(b)
#endif

//------------------------------------------------------------------------------
int extgcd(int a, int b, int &x, int &y) {
  int ret = a;
  if (b == 0) {
    x = 1;
    y = 0;
  } else {
    ret = extgcd(b, a % b, y, x);
    y -= (a / b) * x;
  }
  return ret;
}

int mod_inverse(int a, int m) {
  int x, y;
  extgcd(a, m, x, y);
  return (m + x % m) % m;
}

//------------------------------------------------------------------------------
const int F_MAX = 5*1e5;

ll fact[F_MAX + 1];
ll fact_inv[F_MAX + 1];

void init_fact(int m) {
  fact[0] = 1;
  FOR(i, 1, F_MAX) fact[i] = fact[i - 1] * i % m;
  fact_inv[F_MAX] = mod_inverse(fact[F_MAX], m);
  FORR(i, F_MAX - 1, 0) fact_inv[i] = fact_inv[i + 1] * (i + 1) % m;
}

ll mod_comb_fast(ll n, ll k, ll mod) {
  if (n < 0 || k < 0 || n < k) return 0;
  ll a = fact[n];
  ll b = fact_inv[k] * fact_inv[n - k] % mod;
  return a * b % mod;
}

ll mod_perm_fast(ll n, ll k, ll mod) {
  if (n < 0 || k < 0 || n < k) return 0;
  return fact[n] * fact_inv[n - k] % mod;
}

//------------------------------------------------------------------------------
const ll MOD = 1e9+7;

ll N, M;

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

  init_fact(MOD);

  ll ans = 0;
  FOR(k, 0, N) {
    ll tmp = mod_comb_fast(N, k, MOD) * mod_perm_fast(M - k, N - k, MOD) % MOD;
    if (k % 2) {
      ans = (ans + MOD - tmp) % MOD;
    } else {
      ans = (ans + tmp) % MOD;
    }
  }
  ans = ans * mod_perm_fast(M, N, MOD) % MOD;
  cout << ans << endl;
}


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

public class Main {

  public static void main(String[] args) {
    // TODO 自動生成されたメソッド・スタブ
    Scanner sc = new Scanner(System.in);
    int idx = sc.nextInt();

    List<Integer> iArray = new ArrayList<Integer>();

    for (int i = 0; i < idx; i++) {
      iArray.add(sc.nextInt());
    }

    int count = 0;
    int maxCount = 0;
    for (int i = iArray.size() - 1; i > 0; i--) {
      if (iArray.get(i) <= iArray.get(i - 1)) {
        count++;
      } else {
        if (maxCount < count) {
          maxCount = count;
        }
        count = 0;
      }
    }
    if (maxCount < count) {
      maxCount = count;
    }

    System.out.println(maxCount);
  }
}


Measured memory_bytes: 57984
#include<stdio.h>
int main(){
  int p,q,r;
  scanf("%d%d%d",&p,&q,&r);
  if(p<=q && r<=q)
    printf("%d\n",p+r);
  else if(p<=r && q<=r)
    printf("%d\n",p+q);
  else
    printf("%d\n",q+r);
  return 0;
}


Measured memory_bytes: 128
#define _CRT_SECURE_NO_WARNINGS
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <vector>
#include <algorithm>
#include <functional>
#include <ccomplex>
#include <unordered_map>
#include <cstring>
#include <iostream>
#include <numeric>
#include <sstream>
#include <set>
#include <tuple>
#include <iomanip>

using namespace std;
#define MAX 1LL << 60

typedef long long ll;

#define rep(i, s, e) for(ll i = s; i < e; i++)
#define repR(i, s, e) for(ll i = s; i > e; i--)
#define reft0(i, j) setfill('0') << setw(i) << j

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

int main(){
	ll N;
	cin >> N;
	ll sum = 0;
	ll temp = N;
	while (N != 0){
		sum += N - ((N / 10) * 10);
		N = N / 10;
	}
	if (0 == temp % sum){
		cout << "Yes" << endl;
	}
	else{
		cout << "No" << endl;
	}
	return 0;
}


Measured memory_bytes: 764
//  Created by ZJYelizaveta on 2017年09月23日 星期六 19时52分40秒
//  Copyright (c) 2017年 ZJYelizaveta. All rights reserved.

#include <bits/stdc++.h>
using namespace std;

const int MAX_N = 10 + 3;
const int INF = 0x3f3f3f3f;
char str[MAX_N];

int main()
{
	scanf("%s", str);
	bool flag = false;
	if (str[0] == 'Y' && str[1] == 'A' && str[2] == 'K' && str[3] == 'I') flag = true;
	if (flag) printf("Yes\n");
	else printf("No\n");
	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main()
{
	int n;
	int ai[10000];
	int cnt = 0;

	scanf("%d", &n);
	for(int i = 0; i < n; ++i) scanf("%d", ai + i);

	for(int i = 0; i < n; ++i){
	 while(1){
	 	 if(ai[i]%2 == 0){
		 ++cnt;
		 ai[i] >>= 1;
		 }
		 else {
			 break;
		 }
	 }
	}

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

	return 0;
}

Measured memory_bytes: 256
def lcs(s, t):
    ls = len(s)
    lt = len(t)
    d = [[0] * (lt + 1) for _ in range(ls + 1)]

    for i in range(1, ls + 1):
        for j in range(1, lt + 1):
            if s[i - 1] == t[j - 1]:
                d[i][j] = d[i - 1][j - 1] + 1
            else:
                d[i][j] = max(d[i - 1][j], d[i][j - 1])

    res = ""
    i, j = ls, lt
    while i > 0 < j:
        if s[i - 1] == t[j - 1]:
            i -= 1
            j -= 1
            res += s[i]
        elif d[i - 1][j] > d[i][j - 1]:
            i -= 1
        else:
            j -= 1
    return res[::-1]


def main():
    s = input()
    t = input()
    return lcs(s, t)


print(main())


Measured memory_bytes: 111708
#include <bits/stdc++.h>
#include <iostream>
#include<math.h>
using namespace std;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
int main()
{
    int X;
    cin >> X;
    if (X >= 30) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 3592
n=int(input())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
c=list(map(int,input().split()))

a.sort()
b.sort()
c.sort()
from bisect import bisect_left
from bisect import bisect_right
count = 0
for bi in range(n):
  c_right = bisect_right(c, b[bi])
  a_left = bisect_left(a, b[bi])
  count += (n-c_right) * a_left
print(count)

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

using namespace std;

typedef long long ll;
typedef pair<int,int> pii;
typedef double ld;

typedef pair<string,int> si;
#define fi first
#define se second
#define mp make_pair
#define fastIO ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define TEST freopen("in.txt","r",stdin);
#define ab(a) ((a < 0) ? (-(a)) : (a))

int cnt[26];

int main(){
	fastIO;
	string s;
	cin >> s;
	for(auto x : s)cnt[x-97]++;
	for(int i = 0;i<26;i++){
		if(cnt[i] == 0){
			cout << s + char(i + 97);
			return 0;
		}
	}
	string ans = "zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz";
	string cur;
	int l;
	for(int i = 0;i<26;i++){
		for(int j = i+1;j<26;j++){
			cur = s;
			if(cur[j] < cur[i])
				continue;
			swap(cur[i],cur[j]);
			l = 26-i-1;
			cur.erase(i+1,l);
			ans = min(ans,cur);
		}
	}
	if(ans.size() > 26)
		cout << -1;
	else
		cout << ans;
	return 0;
}

Measured memory_bytes: 256
import sys
from collections import defaultdict
 
N,M = list(map(int, sys.stdin.readline().strip().split()))
counter = {"WA":0, "AC":0}
solv = defaultdict(list)
for i in range(M):
  p, s = sys.stdin.readline().strip().split()
  if len(solv[p])==0:
    solv[p].append(0)
    solv[p].append(0)
  if solv[p][1]==1: continue
  elif s=="WA":
    solv[p][0] += 1
  elif s=="AC" and solv[p][1]==0:
    solv[p][1] = 1
    counter["WA"] += solv[p][0]
    counter["AC"] += solv[p][1]

print(counter["AC"], counter["WA"])

Measured memory_bytes: 27004
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		
		int s = scan.nextInt();
		int w = scan.nextInt();
		
		if(s <= w) {
			System.out.println("unsafe");
		}else {
			System.out.println("safe");
		}
	}
}

Measured memory_bytes: 35736
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define REPR(i, n) for(int i = (int)(n); i >= 0; i--)
#define FOR(i, s, n) for (int i = (s); i < (int)(n); i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;

int main() {
    int N;
    cin >> N;
    cout << N*N*N << endl; 
    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);i++)
#define ALL(a)  (a).begin(),(a).end()
#define SORT(c) sort((c).begin(),(c).end())
#define REV(c) reverse((c).begin(),(c).end())

using namespace std;

// 最大公約数
int64_t gcd(int64_t a, int64_t b) {
  return b != 0 ? gcd(b, a % b) : a;
}

// 最小公倍数
int64_t lcm(int64_t a, int64_t b) {
  return a * b / gcd(a, b);
}

int ctoi(char c){
  return c - '0';
}

struct UnionFind {
  vector< int > data;
 
  UnionFind(int sz) {
    data.assign(sz, -1);
  }
 
  bool unite(int x, int y) {
    x = find(x), y = find(y);
    if(x == y) return (false);
    if(data[x] > data[y]) swap(x, y);
    data[x] += data[y];
    data[y] = x;
    return (true);
  }
 
  int find(int k) {
    if(data[k] < 0) return (k);
    return (data[k] = find(data[k]));
  }
 
  int size(int k) {
    return (-data[find(k)]);
  }
};

int main(){
  int64_t n;
  cin >> n;
  vector<int> d(n);
  REP(i,n){
    cin >> d.at(i);
  }
  SORT(d);
  int small = n/2 - 1;
  int large = n/2;
  if (d.at(small) == d.at(large)){
    cout << 0 << endl;
  }else{
    cout << d.at(large) - d.at(small) << endl;
  }
  return 0;
}



Measured memory_bytes: 640
import java.util.*;

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

        int W = sc.nextInt();
        int a = sc.nextInt();
        int b = sc.nextInt();

        if(a<=b){
            if(a+W<b){
                System.out.println(b - a - W);
            }
            else{
                System.out.println(0);
            }
        }
        else{
            if(b+W<a){
                System.out.println(a - b - W);
            }
            else{
                System.out.println(0);
            }
        }
    }
}

Measured memory_bytes: 21844
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = int;
#define INF 0x6fffffff
#define INFL 0x6fffffffffffffffLL

//蟻本のコード

vector<ll> par(100001);	//要素の親
vector<ll> rnk(100001); //木の高さ(併合時に使う)

ll find(ll x) {			//親ノードを求める
	if (par[x] == x) {
		return x;
	} else {
		return par[x] = find(par[x]);	//辺の縮約(rnkは変えない)
	}
}

void unite(ll x , ll y) {	//ノードを併合
	x = find(x);
	y = find(y);
	if (x == y) return;
	else if (rnk[x] < rnk[y]) {
		par[x] = y;
	} else {
		par[y] = x;
		if (rnk[x] == rnk[y]) rnk[x]++;
	}
}

bool same(ll x, ll y) {
	return find(x) == find(y);
}

int main() {
	ll		a,b,i,j,m,n,k;
	ll		ans;
	map<ll,ll> cnt;

	cin >> n >> m >> k;
	vector<vector<ll>> blk(n+1);
	vector<ll> frd(n+1);

	//初期化
	for(i=1;i<=n;i++) {
		par[i] = i;
		rnk[i] = 0;
	}

	for(i=0;i<m;i++) {
		cin >> a >> b;
		unite(a , b);
		frd[a]++;
		frd[b]++;
	}

	for(i=0;i<k;i++) {
		cin >> a >> b;
		blk[a].push_back(b);
		blk[b].push_back(a);
	}

	//グループ数、親ノードを算出
	for(i=1;i<=n;i++) {
		cnt[find(i)]++;
	}

	for(i=1;i<=n;i++) {
		ll nd = find(i);
		ans = cnt[nd]-frd[i]-1;
		for(j=0;j<blk[i].size();j++) {
			if (find(blk[i][j]) == nd) ans--;
		}
		cout << ans << " ";
	}
	cout << endl;
	/*
	for(i=1;i<=n;i++) {
		cout << i << ":" << par[i] << endl;
	}
	cout << "Group_cnt:" << cnt.size() << endl;		//グループ数
	for(auto p : cnt) {
		cout << "node:" << p.first << " count:" << p.second << endl;
	}
	*/

	return 0;
}


Measured memory_bytes: 12760
#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 - 1)
typedef long long ll;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }


void solve(long long X, long long Y, long long Z){
    printf("%ld %ld %ld\n", Z, X, Y);
}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long X;
    cin >> X;
    long long Y;
    cin >> Y;
    long long Z;
    cin >> Z;
    solve(X, Y, Z);
}


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


using namespace std;
typedef long long ll;
#define REP(i,n) for(int i=0; i<int(n); i++)
#define FOR(i,m,n) for(int i=int(m); i<int(n); i++)
#define ALL(obj) (obj).begin(),(obj).end()
#define VI vector<int>
#define VLL vector<long long>
#define VVI vector<vector<int>>
#define VVLL vector<vector<long long>>
#define VC vector<char>
#define VS vector<string>
#define VVC vector<vector<char>>
#define fore(i,a) for(auto &i:a)

typedef pair <int, int> P;
template<class T> bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; }
const int  INF = 1 << 30;
const ll INFL = 1LL<<60;
const ll mod = 1000000007;		








int main() {

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

	string s, t;
	cin >> s >> t;
	
	int n = s.size(), m = t.size();

	VVI dp(n + 1, VI(m + 1, 0));

	REP(i, n) {
		REP(j, m) {
			if (s[i] == t[j])dp[i + 1][j + 1] = dp[i][j] + 1;
			else dp[i + 1][j + 1] = max(dp[i + 1][j], dp[i][j + 1]);
		}
	}

	string ans = "";

	while (n&&m) {
		if (dp[n][m] == dp[n - 1][m])n--;
		else if (dp[n][m] == dp[n][m - 1])m--;
		else {
			n--; m--;
			ans += s[n];
		}
	}

	reverse(ALL(ans));

	cout << ans << endl;


}

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

typedef long long ll;

ll ret = -1;
ll x;
int n, c;

bool isPrime(ll tmp){
    for(ll i = 2; i*i <= tmp; i++){
        if(tmp%i == 0)    return false;
    }
    return tmp!=1;
}

ll apow(int s){
    ll ret = 1;
    while(s-- > 0)  ret *= 10;
    return ret;
}

void dfs(int p){
    if(isPrime(x))  ret = max(ret, x);
    if(p == 0)  return;

    for(int i = 0; i <= 9; i++){
        if(p == 1 && i == 0)    continue;
        x *= 10;
        x += i;
        x += apow(2*(n-p+1)) * i;
        dfs(p-1);
        x -= apow(2*(n-p+1)) * i;
        x /= 10;
    }
}

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

    if(c < 0){
        if(n == 1)  cout << 11 << endl;
        else{
            for(int i = 0; i < 2*n; i++)    cout << "9";
            cout << endl;
        }
    }else{
        x = c;
        dfs(n);
        cout << ret << endl;
    }

    return 0;
}


Measured memory_bytes: 3088
#include <iostream>
#include <vector>
using namespace std;
 
int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  vector<int> b(n);
  vector<int> c(n);
  for (int i = 0; i < n; ++i) {
    cin >> a[i];
    cin >> b[i];
    cin >> c[i];
  }
  vector<vector<int>> dp(n);
  for (int i = 0; i < n; ++i) dp[i].resize(3, 0);
  dp[0][0] = a[0];
  dp[0][1] = b[0];
  dp[0][2] = c[0];
  for (int i = 1; i < n; ++i) {
    dp[i][0] = max(a[i] + dp[i-1][1], a[i] + dp[i-1][2]);
    dp[i][1] = max(b[i] + dp[i-1][0], b[i] + dp[i-1][2]);
    dp[i][2] = max(c[i] + dp[i-1][0], c[i] + dp[i-1][1]);
  }
  cout << max(dp[n-1][0], max(dp[n-1][1], dp[n-1][2]));
}

Measured memory_bytes: 6912
import java.util.Scanner;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;

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

        int sum = 0;
        for(int i=1; i<=n; i++) {
            sum += i;
        }

        System.out.println(sum);

        in.close();
    }
}


Measured memory_bytes: 10064
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=(a);i<=(b);i++)
#define per(i,a,b) for(int i=(a);i>=(b);i--)
#define ms(s,x) memset(s,x,sizeof(s))
#define pb push_back
#define inf 0x3f3f3f3f
#define IOS ios::sync_with_stdio(false)
typedef long long ll;
using namespace std;

const double PI = acos(-1.0);
const double eps = 1e-8;
const int MAXN = 1e6+5;
const ll MOD = 1e9+7;

int n, k, w[MAXN];

bool check(ll p)
{
    int x = 0;
    rep(i, 1, k)
    {
        ll sum = 0;
        while (sum + w[x] <= p)
        {
            sum += w[x++];
            if (x == n)
                return true;
        }
    }
    return false;
}

int main()
{
    IOS;
    ll l = 0, r = 0;
    cin >> n >> k;
    rep(i, 0, n-1){
        cin >> w[i];
        r += w[i];
        if (w[i] > l)
            l = w[i];
    }
    while (l < r)
    {
        ll mid = (l+r)>>1;
        if (check(mid))
            r = mid;
        else
            l = mid+1;
    }
    cout << l << endl;

    return 0;
}



Measured memory_bytes: 3564
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define REP2(i, n) for (int i = 1; i <= (int)(n); i++)
#define FOR(i, m, n) for (int i = m; i<n; i++)
#define SORT(x) sort(x.begin(), x.end())
#define REVE(x) reverse(x.begin(), x.end())
#define ALL(x) (x).begin(), (x).end()
#define SUM(x) accumulate(x.begin(), x.end(),0);
#define vint(v,n) vector<int> v(n); REP(i,n) scanf("%lld", &v[i]);
#define vstr(v,n) vector<string> v(n); REP(i,n) scanf("%lld", &v[i]);
int k=0,n=0, m=0, l=0,r=0,a=0, b=0, c=0, d=0,e=0,ans=0,ans2=0,x=0,y=0;
string s,t,S;
signed main() {
  ios_base::sync_with_stdio(false);
    cin >> n>>s;
    REP(i,n){
        if(s[i]=='I'){
          x++;
        }else{
          x--;
        }
    ans=max(ans,x);
    }
    cout << ans<<endl;
}
              


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

public class Main {

    void run() {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int w = sc.nextInt();
        int[] vArr = new int[n];
        int[] wArr = new int[n];

        for (int i = 0; i < n; i++) {
            vArr[i] = sc.nextInt();
            wArr[i] = sc.nextInt();
        }

        // dp[i][j] ... i番目までの品物で重さwをこえないような最大の価値
        // => 答えはdp[n][w]

        int[][] dp = new int[n + 1][w + 1];
        for (int i = 0; i < n; i++) {
            for (int j = 0; j <= w; j++) {
//                debug(i, j ,dp);
                if (wArr[i] > j) {
                    dp[i + 1][j] = dp[i][j];
                } else {
                    dp[i + 1][j] = Math.max(dp[i][j], dp[i][j - wArr[i]] + vArr[i]);
                }
            }
        }
        System.out.println(dp[n][w]);

    }

    void debug(Object... os) {
        System.err.println(Arrays.deepToString(os));
    }

    public static void main(String[] args) {
        new Main().run();
    }
}



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

int main(void)
{
    long int H, ans = 1;
    int i;
    scanf("%ld", &H);

    for(i=0; i<50; i++)
    {
        if(ans > H)
        {
            printf("%ld", ans - 1);
            break;
        }
        ans *= 2;
    }
    return 0;    
}

Measured memory_bytes: 128
#include<stdio.h>
int main(){
  int i,j,frag = 1,n,A[100],tmp,count = 0;
  scanf("%d",&n);
  for(i = 0 ; i < n ; i++){
    scanf("%d",&A[i]);
  }
  while(frag != 0){
    frag = 0;
    for(j = n - 1 ; j > 0 ; j--){
      if(A[j] < A[j - 1]){
	tmp = A[j];
	A[j] = A[j - 1];
	A[j - 1] = tmp;
	frag = 1;
	count += 1;
      }
    }
  }
  for(i = 0 ; i < n ; i++){
    if(i == n - 1)printf("%d",A[i]);
    else printf("%d ",A[i]);
  }
  printf("\n");
  printf("%d\n",count);
  return 0;
}



Measured memory_bytes: 2068
class Node
    attr_accessor :parent, :rank, :size
  
    def initialize(n)
        @parent = n
        @rank = 0
        @size = 1
    end
end
  
class UnionFindTree
    def initialize(n)
        @nodes = (0..n).to_a.map { |i| Node.new(i) }
    end
  
    def find(x)
        return x if @nodes[x].parent == x
  
        return @nodes[x].parent = find(@nodes[x].parent)
    end
  
    def unite(a, b)
        a = find(a)
        b = find(b)
        return if a == b

        if @nodes[a].rank < @nodes[b].rank
            @nodes[a].parent = b
            @nodes[b].size += @nodes[a].size
        else
            @nodes[b].parent = a
            @nodes[a].size += @nodes[b].size
            @nodes[a].rank += 1 if @nodes[a].rank == @nodes[b].rank
        end
    end
  
    def same?(a, b)
        find(a) == find(b)
    end

    def parents
        @nodes.map(&:parent)
    end

    def size(a)
        @nodes[a].size
    end

    def sizes
        @nodes.map(&:size)
    end
end
n, m = gets.split.map(&:to_i)
brgs = m.times.map{ gets.split.map(&:to_i) }.map{ |a, b| [a-1, b-1] }.reverse
tree = UnionFindTree.new(n)
ans = [n * (n-1) / 2]

brgs[0,m-1].each do |a, b|
    aa = tree.find(a)
    bb = tree.find(b)
    if aa == bb
        ans << ans[-1]
    else
        ans << ans[-1] - tree.size(aa) * tree.size(bb)
        tree.unite(a, b)
    end
end

puts ans.reverse.join("\n")

Measured memory_bytes: 21724
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using static System.Math;

class Program{
    static void Main(){
        string[] input = Console.ReadLine().Split();
        int a,b,t;
        a = int.Parse(input[0]);
        b = int.Parse(input[1]);
        t = int.Parse(input[2]);
        Console.WriteLine(b * (t / a));
    }
}

Measured memory_bytes: 13140
#include <iostream>

#define VARIABLE(x) cerr << #x << "=" << x << endl
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define REP(i,m,n) for (int i=m;i<(int)(n);i++)

const int INF = 10000000;
using namespace std;
typedef long long  ll;

/** Problem0139 : Snakes **/
int main()
{
	int n;
	string s;
	cin >> n;
	rep(k, n) {
		cin >> s;
		REP(i, 1, 100) {
			string a=">'", b=">^";

			rep(j, i) {
				a+='=';
				b+="Q=";
			}
			a+='#';
			rep(j, i)
				a+='=';
			a+='~';
			b+="~~";
			if (s == a) {
				cout << "A" << endl;
				goto end;
			} else if (s == b) {
				cout << "B" << endl;
				goto end;
			}
		}
		cout << "NA" << endl;
	end:;
	}
	return 0;
}

Measured memory_bytes: 1216