akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
//#include <stack>
//#include <queue>
//#include <cstdio>
#include <cmath>
#include <iterator>
#include <map>
//#include <list>
#include <iomanip>

using namespace std;

#define IOS ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
#define prec std::cout << std::fixed << std::setprecision(15);
#define endl "\n"
#define MOD 1000000007
#define Int int64_t
#define PI 3.14159265358979
#define ssort(z) sort(z.begin(), z.end())
#define rsort(z) sort(z.rbegin(), z.rend())
#define eerase(z) z.erase(unique(z.begin(), z.end()), z.end())
#define ccnt(z, w) count(z.begin(), z.end(), w)
#define rep(i,a,n) for(Int (i)=(a); (i)<(n); (i)++)
#define repq(i,a,n) for(Int (i)=(a); (i)<=(n); (i)++)
const int MAX_N = 1000000;
const Int MAX_N_Int = 1000000000000;



int main() {
    //COMinit();
    IOS;
    prec;
    Int a,b,v,w,c,n,t,m,k,x,y=0,ans=1;
    string str,s="",u;
    cin>>x>>n;
    vector<int>p(n);
    for (int i = 0; i < n; ++i) {
        cin>>p[i];
    }
    rsort(p);
    ans=1000000;
    for (int j =0; j <=1000; ++j) {
        bool ok=true;
        for (int i = 0; i < n; ++i) {
            if(p[i]==j)ok=false;
        }
        if(ok){
            if(abs(x-j)<abs(ans-x))ans=j;
        }
    }
    cout<<ans;




    cout<<endl;
    return 0;
}




Measured memory_bytes: 3640
#include <stdio.h>
#include <queue>
#include <vector>
#include <functional>
#include <algorithm>
#include <map>
 
using namespace std;
 
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define REP(i,b) FOR(i,0,b)
 
typedef long long ll;   
typedef pair<int,int> pii;
typedef pair<ll,int> plli;
#define MP make_pair
     
int main(){
    int m,n,k;
    scanf("%d%d%d",&m,&n,&k);
    map<int,vector<pii>> xi;
    map<int,vector<pii>> yi;
    int si=k*2,gi=k*2+1;
    REP(i,k){
        int x,y;
        scanf("%d%d",&x,&y);
        xi[x].push_back(MP(y,i*2));
        yi[y].push_back(MP(x,i*2+1));
        if(x==1&&y==1)
            si=i*2;
        if(x==m&&y==n)
            gi=i*2;
    }
    if(si==k*2)
        xi[1].push_back(MP(1,si));
    if(gi==k*2+1){
        xi[m].push_back(MP(n,gi));
        yi[n].push_back(MP(m,gi+1));
    }
    static vector<pii> graph[500000];
    for(auto& _xs:xi){
        auto& xs = _xs.second;
        sort(xs.begin(),xs.end());
        REP(i,xs.size()-1){
            graph[xs[i].second].push_back(MP(xs[i+1].first-xs[i].first,xs[i+1].second));
            graph[xs[i+1].second].push_back(MP(xs[i+1].first-xs[i].first,xs[i].second));
        }
    }
    for(auto& _ys:yi){
        auto& ys=_ys.second;
        sort(ys.begin(),ys.end());
        REP(i,ys.size()-1){
            graph[ys[i].second].push_back(MP(ys[i+1].first-ys[i].first,ys[i+1].second));
            graph[ys[i+1].second].push_back(MP(ys[i+1].first-ys[i].first,ys[i].second));
        }
    }
    REP(i,k){
        graph[i*2].push_back(MP(1,i*2+1));
        graph[i*2+1].push_back(MP(1,i*2));
    }
    priority_queue<plli,vector<plli>,greater<plli>> pq;
    pq.push(MP(0,si));
    ll ans=-1;
    static ll nc[500000];
    REP(i,k*2+3)
        nc[i]=1145141919810893LL;
    while(!pq.empty()){
        plli t=pq.top();
        pq.pop();
        if(t.first>nc[t.second])
            continue;
        if(t.second==gi||t.second==gi+1){
            ans=t.first;
            break;
        }
        for(auto c:graph[t.second])
            if(t.first+c.first<nc[c.second]){
                nc[c.second]=t.first+c.first;
                pq.push(MP(t.first+c.first,c.second));
            }
    }
    printf("%lld\n",ans);
}

Measured memory_bytes: 53744
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <unordered_map>
#include <functional>
#include <utility>
#include <tuple>
#include <cctype>
#include <bitset>
#include <complex>
#include <cmath>
#include <array>
#include <numeric>
using namespace std;
#define INF 0x3f3f3f3f
#define INFLL 0x3f3f3f3f3f3f3f3fLL
//#define mod 998244353
#define MOD 1000000007
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define eb emplace_back
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int, int> pint;
typedef pair<ll,ll> pll;
typedef tuple<int,int,int> tint;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<ull> vull;
typedef vector<pint> vpint;
int dx[8]={0,0,-1,1,1,1,-1,-1};
int dy[8]={-1,1,0,0,1,-1,1,-1};
const int SIZE=200050;
//ここまでテンプレ
//↓座標圧縮：vectorを入れると対応関係をmap[旧座標]=新座標で返す
unordered_map<int,int> comp(vector<int> v){
	unordered_map<int,int> pam;
	int sz=v.size();
	for(int i=0;i<sz;i++){
		pam[v[i]]=0;
	}
	//新座標が1からほしいときはnc=1にする
	int nc=0;
	for(pair<int,int> i:pam){
		pam[i.first]=nc;
		nc++;
	}
	return pam;
}
//↑座標圧縮
int main(){
	int N;
	cin>>N;
	vint A;
	for(int i=0;i<N;i++){
		int a;
		cin>>a;
		A.pb(a);
	}
	sort(A.begin(),A.end(),greater<int>());
	unordered_map<int,int> pam=comp(A);
	int cnt[SIZE]={};
	for(int i:A)
		cnt[pam[i]]++;
	int ans=0;
	for(int i=0;i<N;i++){
		if(cnt[pam[A[i]]]==0)
			continue;
		for(int j=32;j>=0;j--){
			ll bi=(1LL<<j);
			if(pam.find(int(bi-A[i]))!=pam.end() && cnt[pam[int(bi-A[i])]]>0){
				if(bi==A[i]*2 && cnt[pam[A[i]]]==1)
					continue;
				//cout<<int(bi-A[i])<<" "<<A[i]<<endl;
				cnt[pam[int(bi-A[i])]]--;
				cnt[pam[A[i]]]--;
				ans++;
				break;
			}
		}
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 10120
#include <bits/stdc++.h>
    #define Mod 1000000007
    #define INF 1e9
    #define INFL 9e18
    #define EPS 1e-9
    #define pb push_back
    #define mp make_pair
    #define SET(a) memset(a,-1,sizeof(a))
    #define CLR(a) memset(a,0,sizeof(a))
    #define CPY(a,b) memcpy(a,b,sizeof(a))
    #define all(a) (a).begin(),(a).end()
    #define ios ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    #define N 30005
    #define fs first
    #define sc second
    #define UNVISITED 0

    using namespace std;

    typedef  long long int ll;
    typedef pair<ll,ll> ii;
    typedef vector <ii> vii;
    typedef vector <ll> vi;

   


    int main()
    {
    // #ifndef ONLINE_JUDGE
    // freopen("input.txt","r",stdin);
    // freopen("output.txt","w",stdout);
    // #endif
    ios;
  ll a,b;
  cin>>a>>b;
  if(a%b==0)
  {
     cout<<-1;
     return 0;
  }
   
else
{
    cout<<a;
}



    return 0;


    }

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
vector<int>a(5);
for(int i = 0;i<5;i++) cin >> a[i];
for(int i = 0;i<5;i++){
    if(a[i]==0){cout << i+1;break;}
}
return 0;
}

Measured memory_bytes: 3588
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=1505,mod=998244353;
int n,tot,cnt,a[N][N],head[N],nex[N*N<<1],to[N*N<<1];
void add(int u,int v){to[++tot]=v;nex[tot]=head[u];head[u]=tot;}
char s[N][N];
vector<int>v[N][N];
bool vis[N];
int num,c[N][N],vt[N],e[N];
void dfs(int u)
{
    if(vis[u]) return;
    vis[u]=true;num^=vt[u];cnt++;
    for(int i=head[u];i;i=nex[i])
        dfs(to[i]);
}
int main()
{
    scanf("%d",&n);
    for(int i=1;i<n;i++)
        scanf("%s",s[i]+1);
    for(int i=0;i<=n;i++)
    {
        int x=0,y=i,dx=1,dy=1;
        for(int j=1;j<=(i>0&&i<n?2*n:n);j++)
        {
            v[x][y].push_back(i);
            if(x+dx<0||x+dx>n) dx*=-1;
            if(y+dy<0||y+dy>n) dy*=-1;
            x+=dx;y+=dy;
        }
    }
    for(int i=1;i<n;i++)
        for(int j=1;j<n;j++)
        if(s[i][j]=='o') a[i][j]=1;
    else if(s[i][j]=='x') a[i][j]=2;
    for(int i=1;i<n;i++)
        for(int j=1;j<n;j++)
    {
        int x=v[i][j][0],y=v[i][j][1];
        c[x][y]|=a[i][j];
        if(c[x][y]==3){cout<<0<<endl;return 0;}
    }
    for(int i=0;i<=n;i++)
        for(int j=i+2;j<=n;j+=2)
        if(c[i][j]==0) add(i,j),add(j,i),e[i&1]++;
    else vt[i]^=c[i][j]-1,vt[j]^=c[i][j]-1;
    int ans=1;
    for(int d=0;d<2;d++)
    {
        int nt=(n-d)/2+1;
        if(nt&1)
        {
            cnt=0;
            for(int i=d;i<=n;i+=2)
                if(!vis[i])
            {
                cnt--;num=0;
                dfs(i);
                if(num&1){cout<<0<<endl;return 0;}
            }
            for(int i=1;i<=e[d]-cnt;i++)
                ans=(ans<<1)%mod;
        }
        else for(int i=1;i<=e[d];i++) ans=(ans<<1)%mod;
    }
    printf("%d\n",ans);
    return 0;
}


Measured memory_bytes: 157696
/* {{{ Shinobu kawaii */
/*
  ______   __        _                  __                 
.' ____ \ [  |      (_)                [  |                
| (___ \_| | |--.   __   _ .--.   .--.  | |.--.   __   _   
 _.____`.  | .-. | [  | [ `.-. |/ .'`\ \| '/'`\ \[  | | |  
| \____) | | | | |  | |  | | | || \__. ||  \__/ | | \_/ |, 
 \______.'[___]|__][___][___||__]'.__.'[__;.__.'  '.__.'_/ 

*/
/* }}} */

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

// #define int long long

/* cpp template {{{ */

/* short */
#define pb push_back
#define mp make_pair
#define Fi first
#define Se second
#define ALL(v) (v).begin(), (v).end()
#define X real()
#define Y imag()

/* REPmacro */
#define REPS(i, a, n) for (int i = (a); i < (n); ++i)
#define REP(i, n) REPS(i, 0, n)
#define RREP(i, n) REPS(i, 1, n + 1)
#define DEPS(i, a, n) for (int i = (a); i >= n; --i)
#define DEP(i, n) DEPS(i, n, 0)

/* debug */
#define debug(x) cerr << x << " " << "(L:" << __LINE__ << ")" << '\n';

/* typedef */
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<vi> vii;
typedef vector<vii> viii;
typedef pair<int, int> pii;
typedef double D;
typedef complex<D> P;

/* const */
const int INF = 999999999;
const int MOD = 1e9 + 7;
const D EPS = 1e-9;
const int dx[] = {0, 1, 0, -1, 1, -1, 1, -1}, dy[] = {1, 0, -1, 0, 1, -1, -1, 1};

/* func */
inline bool inside(int y, int x, int H, int W) {return y >= 0 && x >= 0 && y < H && x < W;}
inline int in() {int x; std::cin >> x; return x;}
template <typename T> void print(T x) {std::cout << x << '\n';}
template <typename T>
void print(std::vector<T>& v, string s = " ") {
  REP(i, v.size()) {
    if (i != 0) std::cout << s;
    std::cout << v[i];
  }
  std::cout << '\n';
}

/* }}} */

template <typename List>
void split(const std::string& s, const std::string& delim, List& result)
{
  result.clear();

  //using string = std::string;
  string::size_type pos = 0;

  while(pos != string::npos){
    string::size_type p = s.find(delim, pos);

    if(p == string::npos){
      result.push_back(s.substr(pos));
      break;
    }
    else {
      result.push_back(s.substr(pos, p - pos));
    }

    pos = p + delim.size();
  }
}

string s;
set<string> chie;

void dfs(int i, string t)
{
  //if (i == s.size()) return;
  string m = t;
  //cout << t << " " << i << endl;
  chie.insert(t);
  if (t[i] != '+') {
    if (i + 1 > t.size() - 1) return;
    if (t[i + 1] != '+') t.insert(i + 1, "+");
  } else {
    if (i + 2 > t.size() - 1) return;
    t.insert(i + 2, "+");
  }
  dfs(i + 1, t);
  dfs(i + 1, m);
}

signed main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >> s;

  ll ans = 0;
  dfs(0, s);
  for (string r : chie) {
    vector<string> res;
    split(r, "+", res);
    for (string t : res) {
      ans += atol(t.c_str());
    }
  }
  print(ans);

  return 0;
}


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

const long long N = 3e6 + 17;
ll a[N], b[N], cnt = 1, ans, lnt, n, m, r1, r0, l1, l0, sum, mx, h, c[N], t[N], mn = N, x, y, k;
pair<ll,ll>pr[N];
vector<ll>v,v2;
map<ll,ll>mp;
bool used[N];
char ch[N];
ll prime[N] = {2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53};

int main()
{
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    cin >> x;
    if(x == 3 or x == 5 or x == 7)
    {
        cout <<"YES";
        return 0;
    }
    cout << "NO";
}

Measured memory_bytes: 4352
#include <stdio.h>
#include <stdlib.h>
#include <limits.h>



int main()
{
	int point[50][2];
	int check[50][2];
	int N,M;
	int i, j;
	int minditance;
	int distance;
	int minnum = 0;

	scanf("%d%d",&N,&M);
	for (i = 0; i < N; i++) {
		scanf("%d%d", &point[i][0], &point[i][1]);
	}
	for (i = 0; i < M; i++) {
		scanf("%d%d", &check[i][0], &check[i][1]);
	}

	for (i = 0; i < N; i++) {
		minditance = INT_MAX;
		for (j = 0; j < M; j++) {
			distance = abs(point[i][0] - check[j][0]) + abs(point[i][1] - check[j][1]);
			if (minditance > distance) {
				minditance = distance;
				minnum = j;
			}
		}
		printf("%d\n", minnum + 1);
	}


    return 0;
}


Measured memory_bytes: 128
from collections import deque
K = int(input())

cost = [None] * K
Q = deque()
Q.append((1, 1))
while Q:
    currentCost, currentNode = Q.popleft()
    if cost[currentNode] == None:
        cost[currentNode] = currentCost
        Q.append((currentCost + 1, (currentNode + 1) % K))
        Q.appendleft((currentCost, (currentNode * 10) % K))
print(cost[0])

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

using namespace std;
template <typename T> void print(T vec) {for(auto d: vec) cout<<d<<' ';cout<<'\n';}
template<typename T> void print2D(T mat) {for(auto vec:mat) print(vec);}

#define MOD 1e9 + 7

typedef long long int ll;

int H, W;

void add(ll &x, ll y) {
    if((x += y) >= MOD) {
        x -= MOD;
    }
}

void count(vector<string> &Grid, vector<vector<ll>> &dp) {
    for(int i = 1; i <= H; i++) {
        for(int j = 1; j <= W; j++) {
            if(i == 1 && j == 1) dp[i][j] = 1;
            else if(Grid[i][j] == '#') dp[i][j] = 0;
            else{
                add(dp[i][j], dp[i - 1][j]);
                add(dp[i][j], dp[i][j - 1]);
            }
        }
    }
}


int main() {
    
    cin>>H>>W;
    vector<string> A(H + 1);
    A[0] = string(W + 1, '#');
    for(int i = 1; i<= H; i++) {
        cin>>A[i];
        A[i] = '#' + A[i];
    }
    vector<vector<ll>> dp(H + 1, vector<ll>(W + 1));
    count(A, dp);
    // print2D(dp);
    cout<<dp[H][W]<<'\n';
    return 0;
}

Measured memory_bytes: 9088
counts = gets.to_i
cards = Array.new(4){Array.new(13,false)}
lines = readlines.map(&:chomp).map{|line| line.split}
lines
pattern = ["S", "H", "C", "D"]
lines.each do |line|
    ptn = line[0]
    rank = line[1].to_i
    cards[pattern.index(ptn)][rank-1] = true
end
cards.each_with_index do |card, i|
    card.each_with_index do |x, j|
        unless x then
            puts "#{pattern[i]} #{j+1}"
        end
    end
end


Measured memory_bytes: 6876
#include<stdio.h>
int main()
{
   int A,B,c,d,e;
   scanf("%d %d",&A,&B);
   c=A+B;
   d=A-B;
   e=A*B;

   if(c>=d&&c>=e)
   {
       printf("%d",c);
   }
    else if(d>=c&&d>=e)
   {
       printf("%d",d);
   }
    else if(e>=d&&e>=c)
   {
       printf("%d",e);
   }




}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define rt "\n"
#define sp " "
#define test(n) cout << "test" << n << endl;
#define fixsp(n) fixed << setprecision(n)
#define defsp(n) defaultfloat << setprecision(n)
#define kyopro ios::sync_with_stdio(false);cin.tie(NULL)
#define MOD 1000000007
#define iikae auto&
#define vector3D(K, N, M, DP) vector<vector<vector<ll>>> DP(K, vector<vector<ll>>(N, vector<ll>(M)));
#define vector4D(K, N, M, O, DP) vector<vector<vector<vector<ll>>>> DP(K, vector<vector<vector<ll>>>(N, vector<vector<ll>>(M, vector<ll>(O))));
#define zenbu(a) a.begin(), a.end()
#define rzenbu(a) a.rbegin(), a.rend()
#define rep(i, s, N) for(ll i{s}; i < N; i++)
#define rem(i, N, s) for(ll i{N}; i > s; i--)
using namespace std;using ll = long long;using ld = long double;using P = pair<ll,ll>;/* 最大公約数 */template<typename T> T gcd(T a, T b){return b != 0 ? gcd(b, a % b) : a;}/* UnionFind */template<typename T> struct UnionFind{vector<T> par;UnionFind(T n) : par(n, -1){}void init(T n){par.assign(n, -1);}T root(T x){if (par[x] < 0) return x;else return par[x] = root(par[x]);}bool issame(T x, T y){return root(x) == root(y);}bool merge(T x, T y){x = root(x); y = root(y);if(x == y) return false;if(par[x] > par[y]) swap(x, y);par[x] += par[y];par[y] = x;return true;}int size(int x) {return -par[root(x)];}};/* コンビネーション */template<typename T> ll combpm(T N_, T C_) {const int NUM_=400001;static ll fact[NUM_+1],factr[NUM_+1],inv[NUM_+1];if (fact[0]==0) {inv[1]=fact[0]=factr[0]=1;for (int i=2;i<=NUM_;++i) inv[i] = inv[MOD % i] * (MOD - MOD / i) % MOD;for (int i=1;i<=NUM_;++i) fact[i]=fact[i-1]*i%MOD, factr[i]=factr[i-1]*inv[i]%MOD;}if(C_<0 || C_>N_) return 0;return factr[C_]*fact[N_]%MOD*factr[N_-C_]%MOD;}
/* ここからコード開始 */

int main(){
  kyopro;
  ll A, B;
  cin >> A >> B;
  if(B%A) cout << B-A << rt;
  else cout << A+B << rt;
}

Measured memory_bytes: 256
/*input
3
5 6
5 6 10
*/
/*

  ####   #    #    ##    #####    ####           #    #
 #       #    #   #  #   #    #  #    #          #    #
  ####   ######  #    #  #    #  #    #          #    #
      #  #    #  ######  #    #  #    #          # ## #
 #    #  #    #  #    #  #    #  #    #          ##  ##
  ####   #    #  #    #  #####    ####  #######  #    #

*/
#include<bits/stdc++.h>
#define lld          long long int
#define pb          push_back
#define ppb         pop_back
#define	endl		'\n'
#define mii         map<lld,lld>
#define msi         map<string,lld>
#define mis         map<lld, string>
#define mpi         map<pair<lld ,lld >,lld >
#define pii         pair<lld,lld>
#define vi          vector<lld>
#define vpi 		vector<pii>
#define vs          vector<string>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (lld)x.size()
#define hell        1000000007
#define rep(i,m,n)	for(lld i=m;i<n;i++)
#define lbnd        lower_bound
#define ubnd        upper_bound
#define bs          binary_search
#define mp          make_pair
#define what_is(x)  cerr << #x << " is " << x << endl;
#define pr(x) 		cout<< x << " ";
#define pre(x)		cout<< x << endl ;
using namespace std;
#define N  1000005
inline void solve()
{
	lld n,a,b;
	cin >> n >> a >> b;
	lld ways=0;
	lld A[n];
	lld cnt1=0,cnt2=0,cnt3=0;
	rep(i,0,n)
	{
		cin >> A[i];
		if(A[i]<=a)
		{
			cnt1++;
		}
		else if(A[i]>a && A[i]<=b)
		{
			cnt2++;
		}
		else
		{
			cnt3++;
		}
	}
	cout << min(min(cnt1,cnt2),cnt3) << endl;
}
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int tests=1;
	//cin>>tests;
	while(tests--)
	{
		solve();
	}
}

Measured memory_bytes: 256
#include <algorithm>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <iostream>
#include <sstream>
#include <functional>
#include <map>
#include <string>
#include <cstring>
#include <vector>
#include <queue>
#include <stack>
#include <deque>
#include <set>
#include <list>
#include <numeric>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,ll> P;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const ll INF = 1LL<<29;
const ll mod = 1e9+7;
#define rep(i,n) for(int (i)=0;(i)<(ll)(n);++(i))
#define repd(i,n,d) for(ll (i)=0;(i)<(ll)(n);(i)+=(d))
#define all(v) (v).begin(), (v).end()
#define pb(x) push_back(x)
#define mp(x,y) make_pair((x),(y))
#define mset(m,v) memset((m),(v),sizeof(m))
#define chmin(X,Y) ((X)>(Y)?X=(Y),true:false)
#define chmax(X,Y) ((X)<(Y)?X=(Y),true:false)
#define fst first
#define snd second
#define UNIQUE(x) (x).erase(unique(all(x)),(x).end())
template<class T> ostream &operator<<(ostream &os, const vector<T> &v){int n=v.size();rep(i,n)os<<v[i]<<(i==n-1?"":" ");return os;}
#define N 20010
ll a[N], b[N], c[N];

int main(){
	int n;
	cin>>n;
	rep(i, n){
		a[i] = 1;
		b[i] = 1;
	}
	rep(i, n){
		cin>>c[i];
		c[i]--;
	}
	rep(i, n){
		a[c[i]] += i;
		b[c[i]] += i;
	}
	rep(i, n-1) a[i+1] += a[i];
	rep(i, n-1) b[n-i-2] += b[n-i-1];
	rep(i, n) cout<<a[i]<<" "; cout<<endl;
	rep(i, n) cout<<b[i]<<" "; cout<<endl;
	
	return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
#include<boost/multiprecision/cpp_int.hpp>

template<typename T>
T euclidean_gcd(T a, T b){
    if(a == 0)return b;
    while(a){
        swap(a, b);
        a %= b;
    }
    return b;
}

int main(){
    using namespace std;
    using bigint = boost::multiprecision::cpp_int;
    constexpr unsigned long MOD = 1000000007;
    bigint lcm{1}, b{0}, A{0};
    unsigned long N;
    cin >> N;
    for(unsigned long i{0}; i < N; ++i){
        cin >> A;
        auto t = euclidean_gcd(lcm, A);
        (b *= A /= t) += lcm / t;
        lcm *= A;
    }
    cout << ::boost::multiprecision::integer_modulus(b, MOD) << endl;
    return 0;
}

Measured memory_bytes: 384
class SegmentTree():
    def segfunc(self, x, y):
        if x > y:
            x, y = y, x
        if x == -1:
            return y
        return gcd(x, y) #関数
    
    def __init__(self, a): #a:リスト
        n = len(a)
        self.ide_ele = -1 #単位元
        self.num = 2**((n-1).bit_length()) #num:n以上の最小の2のべき乗
        self.seg = [self.ide_ele]*2*self.num
        
        #set_val
        for i in range(n):
            self.seg[i+self.num-1] = a[i]
        #built
        for i in range(self.num-2,-1,-1):
            self.seg[i] = self.segfunc(self.seg[2*i+1], self.seg[2*i+2])
        
        
    def update(self, k, x):
        k += self.num-1
        self.seg[k] = x
        while k:
            k = (k-1)//2
            self.seg[k] = self.segfunc(self.seg[k*2+1], self.seg[k*2+2])
            
    def query(self, p, q):
        if q <= p:
            return self.ide_ele
        p += self.num-1
        q += self.num-2
        res = self.ide_ele
        while q - p > 1:
            if p&1 == 0:
                res = self.segfunc(res, self.seg[p])
            if q&1 == 1:
                res = self.segfunc(res, self.seg[q])
                q -= 1
            p = p//2
            q = (q-1)//2
        if p == q:
            res = self.segfunc(res,self.seg[p])
        else:
            res = self.segfunc(self.segfunc(res,self.seg[p]),self.seg[q])
        return res
    
from fractions import gcd
    
N = int(input())
A = list(map(int, input().split()))
M = 0
S = SegmentTree(A)
for i in range(N):
    M = max(M, S.segfunc(S.query(0,i), S.query(i+1, N)))
print(M)

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

class Program
{
    static void Main(string[] args)
    {
        var input = Console.ReadLine().Split().Select(long.Parse).ToArray();
        long N = input[0], K = input[1];

        var bigArray = new long[100000 + 1];
        var nums = new List<long>();

        for(var i = 0; i < N; ++i)
        {
            var num_times = Console.ReadLine().Split();
            long num = long.Parse(num_times[0]), times = long.Parse(num_times[1]);
            bigArray[num] += times;
            nums.Add(num);
        }

        var indexes = nums.Distinct().OrderBy(x => x);

        foreach(var num in indexes)
        {
            K -= bigArray[num];
            if (K > 0) continue;
            Console.WriteLine(num);
            return;
        }
    }
}

Measured memory_bytes: 21592
#include<iostream>
#include<cmath>
#include<algorithm>
#include<string>
#include<vector>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define fi first
#define sc second
#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())

const int MAX = 10000000;
const int MOD = 1000003;

long long fac[MAX], finv[MAX], inv[MAX];

long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

int main(){
  vector<ll> ans;
  // 前処理
  COMinit();
  ll Q;cin>>Q;
  ll i,j,k,l;
  rep(i,Q){
    ll x,d,n;cin>>x>>d>>n;
    ll tmp;
    if(d==0){
      tmp=modpow(x,n,MOD);
      ans.pb(tmp);
    }
    else{
      if(n>=MOD){
        ans.pb(0);
      }
      else{
        x = x * inv[d] %MOD;
        tmp = fac[x+n-1] * finv[x-1] %MOD * modpow(d,n,MOD) %MOD;
        ans.pb(tmp);
      }
    }
  }
  rep(i,ans.size()) cout<<ans.at(i)<<endl;
}


Measured memory_bytes: 236148
#include<iostream>
#include<vector>
#include<algorithm>
#include<cmath>

using namespace std;

int main(){
    int n, k, ans = 0;
    cin >> n >> k;
    vector<int> h(n), c(n, 1000000000);
    for(int i = 0; i < n; i++){
        cin >> h[i];
    }
    c[0] = 0;
    for(int i = 0; i < n - 1; i++){
        for(int j = 1; j <= k; j++){
            if(i + j >= n) continue;
            c[i + j] = min(c[i + j], c[i] + abs(h[i] - h[i + j]));
        }
    }
    cout << c[n - 1] << endl;
    return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
using namespace std;
using namespace __gnu_pbds;
typedef tree<
int,
null_type,
less<int>,
rb_tree_tag,
tree_order_statistics_node_update>
ordered_set;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
ll n,m,k,v[5001][5001],dp[5001][5001][5],ans;
vector<ll> w;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cin>>n>>m>>k;
    for(int i=1;i<=k;i++)
    {
        ll x,y,vl;
        cin>>x>>y>>vl;
        v[x][y]=vl;
    }
    int nr=0;
    ll suma=0;
    for(int j=1;j<=m;j++)
    {
        if(v[1][j]!=0)
            w.push_back(v[1][j]);
        sort(w.begin(),w.end());
        reverse(w.begin(),w.end());
        suma=0;
        ll sz=w.size();
        for(int l=0;l<=min(3LL,sz);l++)
        {
            if(l!=0)
                suma+=w[l-1];
            dp[1][j][l]=suma;
        }
    }
    suma=0;
    for(int i=1;i<=n;i++)
    {
        dp[i][1][0]=0;
        dp[i][1][1]=0;
        dp[i][1][2]=0;
        dp[i][1][3]=0;
        dp[i][1][0]=suma;
        suma+=v[i][1];
        if(v[i][1]>0)
            dp[i][1][1]=suma;
    }
    for(int i=2;i<=n;i++)
        for(int j=2;j<=m;j++)
            for(int l=0;l<=3;l++)
            {
                ll val=0;
                for(int t=0;t<=3;t++)
                {
                    if(l==0)
                        val=max(val,dp[i-1][j][t]);
                    if(l==1&&v[i][j]>0)
                        val=max(val,dp[i-1][j][t]+v[i][j]);
                }
                val=max(val,dp[i][j-1][l]);
                if(v[i][j]>0&&l!=0)
                    val=max(val,dp[i][j-1][l-1]+v[i][j]);
                dp[i][j][l]=val;
            }
    for(int l=0;l<=3;l++)
        ans=max(ans,dp[n][m][l]);
    cout<<ans;
    return 0;
}


Measured memory_bytes: 446900
#!/usr/bin/python3
# vim: set fileencoding=utf-8:
import sys
import collections
input = sys.stdin.readline

N, M = [int(ele) for ele in input().split()]
a = [0]*M
b = [0]*M
for i in range(M):
    a[i], b[i] = [int(ele) for ele in input().split()]


def main():
    ctr = collections.Counter(a + b)
    for i in range(1, N+1):
        print(ctr[i])


def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
        if i != n // i:
            divisors.append(n//i)
    return divisors


class Node():

    def __init__(self):
        self.idx = None
        self.left = None
        self.right = None
        self.parent = None
        return

    def pre_order(self):
        global pre_order_str
        pre_order_str += str(self.idx) + " "
        if self.left:
            self.left.pre_order()

        if self.right:
            self.right.pre_order()

    def in_order(self):
        global in_order_str

        if self.left:
            self.left.in_order()

        in_order_str += str(self.idx) + " "

        if self.right:
            self.right.in_order()

    def post_order(self):
        global post_order_str
        if self.left:
            self.left.post_order()

        if self.right:
            self.right.post_order()

        post_order_str += str(self.idx) + " "


class HeapHelper():
    """HeapContrler.
    完全二分木を二分ヒープで表現した配列 A に対して、
    HeapHelper.parent(idx) とするとそのノードの親の添字を返す
    存在しない場合は Falseを返す

    Returns:
        [type] -- [description]
    """

    def __init__(self):
        return

    @staticmethod
    def parent(i):
        if i == 1:
            return False

        return int(i/2)

    @staticmethod
    def left(i):
        l_idx = 2*i
        if H < l_idx:
            return False

        return l_idx

    @staticmethod
    def right(i):
        r_idx = 2*i + 1
        if H < r_idx:
            return False

        return r_idx


if __name__ == "__main__":
    main()


Measured memory_bytes: 3316
// BROWNIE TK

#include <bits/stdc++.h>

typedef long long int lli;
typedef unsigned long long int ulli;
typedef long double ldb;

#define pb push_back
#define popb pop_back
#define pf push_front
#define popf pop_front
#define si size()
#define be begin()
#define en end()
#define all(v) v.be, v.en
#define le length()
#define mp make_pair
#define mt make_tuple
#define F first
#define S second

#define forz(i, n) for (int i = 0; i < n; i++)
#define bui(i, m, n) for (int i = m; i < n; i++)
#define rforz(i, n) for (int i = n - 1; i >= 0; i--)
#define mui(i, m, n) for (int i = n - 1; i >= m; i--)
#define deci(n) fixed << setprecision(n)
#define high(n) __builtin_popcount(n)
#define parity(n) __builtin_parity(n)
#define ctz(n) __builtin_ctz(n)
#define lb lower_bound
#define ub upper_bound
#define er equal_range
#define maxe *max_element
#define mine *min_element
#define mod 1000000007
#define mod2 998244353
#define kira ios::sync_with_stdio(0), cin.tie(0), cout.tie(0)

#define endl "\n"
#define p0(a) cout << a << " "
#define p1(a) cout << a << endl
#define p2(a, b) cout << a << " " << b << endl
#define p3(a, b, c) cout << a << " " << b << " " << c << endl
#define p4(a, b, c, d) cout << a << " " << b << " " << c << " " << d << endl

using namespace std;

/*STD fucntions*/
lli power(lli x,lli y,lli p)
{
	lli res=1;
	x=x%p;
	while(y>0)
	{
		if(y&1)
			res=(res*x)%p;
		//y must be even now
		y=y>>1; //y=y/2
		x=(x*x)%p;
	}
	return res;
}
lli gcd(lli a, lli b)
{
  if (b == 0)
    return a;
  return gcd(b, a % b);
}
lli lcm(lli a, lli b)
{ return a * b / gcd(a, b); }
lli modi(lli a,lli m)
{
// fermat little thm where m is prime
return power(a,m-2,m);
}
/*CODE BEGINS*/
int main()
{
 kira;
 string s,t;
 cin>>s;
 cin>>t;
 lli n=s.si;
 lli m=t.si;
 lli dp[n+1][m+1];
 lli re[n+1][m+1];
 for(int i=0;i<=n;i++)
 {
   for(int j=0;j<=m;j++)
   {
     if(i==0||j==0)
     {dp[i][j]=0;
      re[i][j]=-1;}
     else if(s[i-1]==t[j-1])
     {
       dp[i][j]=dp[i-1][j-1]+1;
       re[i][j]=2;
     }
     else 
     {
       if(dp[i-1][j]>dp[i][j-1])
       {
         dp[i][j]=dp[i-1][j];
         re[i][j]=1;
       }
       else
       {
         dp[i][j]=dp[i][j-1];
         re[i][j]=0;
       }
     }
   }
 }
 int i=n,j=m;
 vector<char>v;
 while(1)
 {
   if(s[i-1]==t[j-1]&&re[i][j]==2)v.pb(s[i-1]);
   if(re[i][j]==2)
   {
     i=i-1;
     j=j-1;
   }
   else if(re[i][j]==1)i--;
   else if(re[i][j]==0)j--;
   else break;
 }
 reverse(all(v));
 for(auto x:v)cout<<x;
 return 0;
}


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

struct block{int w,s;long long v;};
bool cmp(block a,block b){
  return a.w+a.s<b.w+b.s;
}
long long ans,dp[20001];//dp[i]:重さiでの最大価値
/*
重ねる時は相手のwも含めてのsなのでu.s-v.w>v.s-u.w 足して小さい方から積む？
*/
template<typename T>
void chmax(T &a,T b){
  if(a<b)a=b;
}

int main(){
  int n;cin>>n;
  vector<block> a(n);
  for(int i=0;i<n;i++){
    int w,s,v;cin>>w>>s>>v;
    a[i]={w,s,v};
  }
  sort(a.begin(),a.end(),cmp);
  for(int i=0;i<n;i++)
    for(int j=a[i].s;j>=0;j--)chmax(dp[j+a[i].w],dp[j]+a[i].v);
  for(int i=0;i<20001;i++)chmax(ans,dp[i]);
  cout<<ans<<endl;
}


Measured memory_bytes: 384
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>

using namespace std;

#ifdef DEBUG_MODE
	#define DBG(n) n;
#else
	#define DBG(n) ;
#endif

#define REP(i,n) for(ll (i) = (0); (i) < (n); ++i)
#define PB push_back
#define MP make_pair
#define FI first
#define SE second
#define ALL(v) v.begin(),v.end()
#define INF 1100000000
#define LLINF 1000000000000000000LL
#define MOD 1000000007

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


int main()
{
	int N;
	cin >> N;
	vector<ll> Asum(N);
	REP(i, N) {
		ll A;
		cin >> A;
		if(i > 0) Asum[i] = Asum[i - 1] + A;
		else Asum[i] = A;
	}

	/*REP(i, N) cout << Asum[i] << ' ';
	cout << endl;*/

	ll ans = LLINF;
	for(int j = 1; j < N - 2; j++) {
		int l, r;

		l = 0;
		r = j - 1;
		while(r - l > 1) {
			int mid = (l + r) / 2;
			if(2 * Asum[mid] < Asum[j]) l = mid;
			else r = mid;
		}

		int i;
		if(abs(2 * Asum[l] - Asum[j]) > abs(2 * Asum[r] - Asum[j])) i = r;
		else i = l;

		l = j + 1;
		r = N - 2;
		while(r - l > 1) {
			int mid = (l + r) / 2;
			if(2 * (Asum[mid] - Asum[j]) < Asum[N - 1] - Asum[j]) l = mid;
			else r = mid;
		}
		int k;
		if(abs(2 * (Asum[l] - Asum[j]) - (Asum[N - 1] - Asum[j])) > abs(2 * (Asum[r] - Asum[j]) - (Asum[N - 1] - Asum[j]))) k = r;
		else k = l;

		ll P = Asum[i];
		ll Q = Asum[j] - Asum[i];
		ll R = Asum[k] - Asum[j];
		ll S = Asum[N - 1] - Asum[k];
		ll ma = max({P, Q, R, S});
		ll mi = min({P, Q, R, S});
		ans = min(ans, ma - mi);

		/*REP(n, 2) {
			REP(m, 2) {
				//cout << i[n] << ' ' << j << ' ' << k[m] << ' ';
				ll P = Asum[i[n]];
				ll Q = Asum[j] - Asum[i[n]];
				ll R = Asum[k[m]] - Asum[j];
				ll S = Asum[N - 1] - Asum[k[m]];
				//cout << "> " << P << ' ' << Q << ' ' << R << ' ' << S << endl;
				ll ma = max({P, Q, R, S});
				ll mi = min({P, Q, R, S});
				ans = min(ans, ma - mi);
			}
		}*/
	}
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 1792
"use strict";
function main(arg) {
    const inputs = arg.split("\n")
    const N = parseInt(inputs[0])
    const list = inputs.slice(1,N+1).map((x)=>parseInt(x))
    const max = Math.max(...list)
    let i, sum = 0;
    for(i=0; i<N; i++){
        sum += Number(list[i])
    }
    console.log(sum - max / 2)
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 7624
using System;
using System.Linq;

namespace abc175.c
{
    class Program
    {
        static void Main(string[] args)
        {
            long[] paramArray = getLongParams();

            long X = Math.Abs(paramArray[0]);
            long K = paramArray[1];
            long D = paramArray[2];

            long q = X / D;
            long mod = X % D;

            long ret = 0;

            if (q > K)
            {
                ret = X - (K * D);
            }
            else
            {
                K -= q;

                if (K % 2 == 0)
                {
                    ret = mod;
                }
                else
                {
                    ret = Math.Abs(mod - D) < mod + D ? Math.Abs(mod - D) : mod + D;
                }
            }
            Console.WriteLine(ret);
        }
        //↓↓↓ shared function ↓↓↓
        static int getIntParam()
        {
            return int.Parse(Console.ReadLine());
        }
        static int[] getIntParams()
        {
            return Console.ReadLine().Split(' ').Select(i => int.Parse(i)).ToArray();
        }
        static long getLongParam()
        {
            return long.Parse(Console.ReadLine());
        }
        static long[] getLongParams()
        {
            return Console.ReadLine().Split(' ').Select(i => long.Parse(i)).ToArray();
        }
        static string getStringParam()
        {
            return Console.ReadLine();
        }
        static string[] getStringParams()
        {
            return Console.ReadLine().Split(' ');
        }
    }
}


Measured memory_bytes: 28192
from collections import defaultdict
import itertools
import copy

def readInt():
	return int(input())
def readInts():
	return list(map(int, input().split()))
def readChar():
	return input()
def readChars():
	return input().split()

def p(arr):
	for i in arr:
		for j in i:
			print(j, end="")
		print()

def bitArr(n):#ビット全探索
	x = 1
	zero = "0"*n
	ans = []
	ans.append([0]*n)
	for i in range(2**n-1):
		ans.append(list(map(lambda x:int(x),list((zero+bin(x)[2:])[-1*n:]))))
		x+=1
	return ans

def dyeh(arr,b):
	for i in range(len(b)):
		if b[i]==1:
			for j in range(w):
				arr[i][j]="."
	return arr

def dyew(arr,b):
	for i in range(len(b)):
		if b[i]==1:
			for j in range(h):
				arr[j][i]="."

def count(arr):
	ans = 0
	for i in arr:
		for j in i:
			if j=="#":
				ans+=1
	return ans

h,w,k = readInts()
c = [list(input()) for i in range(h)]
ans = 0
for i in bitArr(h):
	d = copy.deepcopy(c)
	dyeh(d,i)

	for j in bitArr(w):
		e = copy.deepcopy(d)
		dyew(e,j)
		if count(e)==k:
			ans+=1

print(ans)

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

using namespace std;

#define rep(i, n) for (int i = 0; i < (int)n; ++i)
#define REP(i, a, b) for (int i = (int)a; i < (int)b; ++i)
#define each(i,c) for(__typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i)
#define all(v) v.begin(), v.end()
#define mset(a, n) memset(a, n, sizeof(a))

typedef long long ll;

const int INF = 1000000000;
const int MOD = 1000000007;

int main(int argc, char *argv[]) {
    // cin.tie(0);
    // ios::sync_with_stdio(false);
    int N; cin >> N;
    ll ans = 0;
    vector<ll> a(N), b(N);
    rep(i, N) cin >> a[i] >> b[i];
    for (int i = N-1; i >= 0; --i) {
        ll tmp = (a[i] + ans) % b[i];
        if (tmp) ans += b[i] - tmp;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
int main(void){
    double n;
    cin>>n;
    double count=0;
    for (int i=1;i<=n;i++) {
        if (i%2==1) {
            count++;
        }
    }
    double ans=count/n;
    printf("%.10f",ans);
    cout<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define each(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)
#define all(obj) (obj).begin(),(obj).end() 
#define dump(x)  cout << #x << " = " << (x) << endl;
typedef long long lint;
using namespace std;
int main(){
	string s;
	cin>>s;
	sort(all(s));
	cout<<(s=="abc"?"Yes":"No")<<endl;
}


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

using namespace std;

typedef long long int li;
typedef long double ld;
typedef vector<li> vi;
typedef pair<li,li> pi;
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define B begin()
#define E end()
#define f(i,l,r) for(li i=l;i<=r;++i)
#define fr(i,l,r) for(li i=l;i>=r;--i)
#define u_map unordered_map
#define endl "\n"
#define debug(x) cout<<#x<<" = "<<x<<endl;

li fastpow(li base,li exp,li M) 
{
    li res=1;
    while(exp>0) {
        if(exp&1)
            res=(res*base)%M;

        base=(base*base)%M;
        exp>>=1;
    }
    return res;
}

const li M=1e9+7;

void solve()
{
    li n;

    cin>>n;

    li a[n][n];

    f(i,0,n-1)
    {
        f(j,0,n-1)
        {
            cin>>a[i][j];
        }
    }

    vi dp(1<<n);

    dp[0]=1;

    f(mask,0,(1<<n)-1)
    {
        li i=__builtin_popcount(mask);

        f(j,0,n-1)
        {
            if(a[i][j] && !(mask&(1<<j)))
            {
                dp[mask^(1<<j)]+=dp[mask];
                dp[mask^(1<<j)]%=M;
            }
        }
    }

    cout<<dp[(1<<n)-1];
}

int main()
{    
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);

    li t=1;

    // cin>>t;  

    while(t--)
    {
        solve();
    }

    return 0;
}

Measured memory_bytes: 19540
#include <bits/stdc++.h>
#include <cmath>
#include <numeric>
using namespace std;
#define rep(i,a,b) for(int64_t i=(a);i<(b);++i) // a ≦ i < b 
#define Rrep(i,a,b) for(int64_t i=(a);i>=(b);--i) // reverse repeat. a から b まで減少．
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend() //逆イテレータ
#define RANGE(a,b,c) (a).begin()+(b),(a).begin()+(c) // [b,c) イテレータ
#define INF 1000000000000000
#define MOD 1000000007
using PII = pair<int64_t, int64_t>;
using VI = vector<int64_t>;
using VVI = vector<VI>;
using VS = vector<string>;
using VP = vector<PII>;
using i64 = int64_t;
template<typename T> void invec(vector<T> &A){for(T& a:A) cin >> a;} 



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

string S; cin >> S;

if (S == "BBB" || S == "AAA")
    cout << "No\n";
else 
    cout << "Yes\n";


return 0;
}
// コンテスト前はtemplate振り返り。
// 書いて考える．場合分け．情報整理．
// 単純に分かる量から．愚直解を実装して研究．
// 境界，出力文字列 チェック．行末にスペース入れない．
// 可読性優先．高速化次点．
// まずは全探索，分割，次にDP(小さい問題から大きな問題)
// 制限を見る．境界に注意．求めたい量の変域．動かせる量．
// 偶奇，逆から，ソート，出現回数，出現位置，DP， 余事象，包除
// データ構造． 問題の特徴量．単調性→二分探索
// 存在判定：構成方法，入力の特徴
// 構築問題。極端解を試す。
// 例外を十分に含む一般化．想像力の限界
// 小さい系から例示
// 代数的処理．前処理によるクエリ高速化．
// 始めは過剰に例示・場合分けしてもいい．各場合を確実に対処．
// 自明な例から処理，除外．
// 小数のときは，精度の設定する．doubel 変数に数値を入力するときは 123. とする．
// コーナーケース。境界値。数表出力プログラム作る
// 実行エラー：vector添え字超え．0割り．



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

namespace codeTester
{
    class Program
    {
        static List<int> values = new List<int>();

        static void Main(string[] args)
        {
            values = IOUtilities.ReadSpaceSeparatedValues();
            Console.WriteLine(logic().ToString());
        }

        static int logic()
        {
            int ans = 0;
            if(values[1] == 1)
            {
                return 0;
            }
            return values[0] - values[1];
        }
    }

    class IOUtilities
    {
        public static List<int> ReadSpaceSeparatedValues()
        {
            List<int> values = new List<int>();
            string[] inputs = Console.ReadLine().Split(' ');
            foreach (string input in inputs)
            {
                values.Add(int.Parse(input));
            }

            return values;
        }

        public static List<int> ReadIndentationSeparatedValues(int num)
        {
            List<int> values = new List<int>();
            for (int i = 0; i < num; i++)
            {
                string input = Console.ReadLine();
                values.Add(int.Parse(input));
            }

            return values;
        }
    }

    class ListUtilities
    {
        /// <summary>
        /// list を index の位置で２つに分割します。
        /// </summary>
        /// <param name="list">分割されるリスト</param>
        /// <param name="index">分割位置（ 0 のとき１つめのリストは空になります）</param>
        /// <returns></returns>
        public static List<int>[] SeparateAt(List<int> list, int index)
        {
            return new[] { list.GetRange(0, index), list.GetRange(index, list.Count) };
        }
    }
}


Measured memory_bytes: 11092
/**
 *    author:  FromDihPout
 *    created: 2020-08-12
**/

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

int n, x, y;
vector<int> paths;

void bfs(int start) {
    int dist = 0;
    queue<int> q;
    vector<bool> seen(n+1);
    q.push(start);
    seen[start] = true;
    
    while (!q.empty()) {
        int len = q.size();
        paths[dist] += len;
        while (len--) {
            int u = q.front();
            q.pop();
            if (!seen[u+1] && u+1 <= n) {
                q.push(u+1);
                seen[u+1] = true;
            }
            if (!seen[u-1] && u-1 >= 1) {
                q.push(u-1);
                seen[u-1] = true;
            }
            if (u == x && !seen[y]) {
                q.push(y);
                seen[y] = true;
            }
            if (u == y && !seen[x]) {
                q.push(x);
                seen[x] = true;
            }
        }
        dist++;
    }
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    cin >> n >> x >> y;
    paths.resize(n);
    for (int i = 1; i <= n; i++) {
        bfs(i);
    }
    
    for (int d = 1; d <= n - 1; d++) {
        cout << paths[d] / 2 << '\n';
    }
    return 0;
}

Measured memory_bytes: 3640
#include <bits/stdc++.h>
#pragma GCC target("avx")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;
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 (b<a) {a=b; return 1;} return 0;}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    ll n;
    cin >> n;
    ll ans = 1e18;
    for (ll i = 1; i*i <= n; ++i) {
        if (n%i) continue;
        ll j = n/i;
        ans = min(ans, i+j-2);
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
)

func main() {
	r := bufio.NewReader(os.Stdin)
	w := bufio.NewWriter(os.Stdout)
	defer w.Flush()

	var n, a, b, c int
	fmt.Fscan(r, &n, &a, &b, &c)
	v := make(map[byte]int)
	v['A'], v['B'], v['C'] = a, b, c
	s := make([]string, n)
	for i := 0; i < n; i++ {
		fmt.Fscan(r, &s[i])
	}

	ans := make([]byte, 0, n)

	choose := func(s string, i int) {
		v[s[i]]++
		v[s[i^1]]--
		ans = append(ans, s[i])
	}

	chooseAny := func(s string) {
		if v[s[0]] == 0 {
			choose(s, 0)
		} else {
			choose(s, 1)
		}
	}

	for i := 0; i < n; i++ {
		if v[s[i][0]] == 0 && v[s[i][1]] == 0 {
			fmt.Fprintln(w, "No")
			return
		}
		if v[s[i][0]] == 0 || v[s[i][1]] == 0 {
			chooseAny(s[i])
		} else if i == n-1 {
			chooseAny(s[i])
		} else if s[i] == s[i+1] {
			chooseAny(s[i])
		} else if v[s[i][0]] == 1 || v[s[i][1]] == 1 {
			if s[i][0] == s[i+1][0] || s[i][0] == s[i+1][1] {
				choose(s[i], 0)
			} else {
				choose(s[i], 1)
			}
		} else {
			chooseAny(s[i])
		}
	}

	fmt.Fprintln(w, "Yes")
	for i := 0; i < n; i++ {
		fmt.Fprintf(w, "%c\n", ans[i])
	}
}


Measured memory_bytes: 3800
#include<stdio.h>
int main()
{
    int array[10];
    int i,j,t;
    for(i=0;i<10;i++)
    {
        scanf("%d",&array[i]);
    }
    for(i=1;i<10;i++)
    {
        j=i-1;
        t=array[i];
        while(j>=0&&array[j]>t)
        {
            array[j+1]=array[j];
            j--;
        }
        array[j+1]=t;
    }
    printf("%d\n%d\n%d\n",array[9],array[8],array[7]);
    return 0;
}

Measured memory_bytes: 600
mod = 10**9 + 7

N_MAX = 10**5+1
fact = [1] * N_MAX
for i in range(1,N_MAX):
  fact[i] = (fact[i-1]*i) % mod
  
def nCr(n,r):  
  if n < r:
    return 0
  return (fact[n] * pow(fact[r]*fact[n-r] ,mod-2,mod))% mod

n,k = map(int,input().split())
A = sorted(list(map(int,input().split())))

mi = 0
ma = 0

for i in range(1,n):
  m = nCr(n-i,k-1)
  mi += A[i-1] * m
  ma += A[-i]  * m
  
print((ma - mi)%mod)

Measured memory_bytes: 18520
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner scan = new Scanner(System.in);
        
        int a = scan.nextInt();
        int b = scan.nextInt();
        
        if (a*b % 2 == 0)  {
            System.out.println("Even");
        }
        
        else {
            System.out.println("Odd");
        }
       
    }
}


Measured memory_bytes: 22100
#include <cstdio>
#include <algorithm> 
using namespace std;
const int N = 128;
const int M = 10024;

struct T {int v, w;};
T a[N];
int dp[M];

int main()
{
	int n, w;
	scanf("%d %d", &n, &w);
	for (int i = 0;i  < n; ++i)
		scanf("%d %d", &a[i].v, &a[i].w);
	
	for (int i = 0; i < n; ++i)
	{
		for (int j = a[i].w; j <= w; ++j)
		{
			dp[j] = max(dp[j], dp[j-a[i].w] + a[i].v);
		}
	}
	printf("%d\n", dp[w]);
	
	return 0;
}


Measured memory_bytes: 2780
#include <stdio.h>

char prime[1000001] = {1, 1};

void SetPrime(int max)
{
	int i, j;
	
	for (i = 4; i <= max; i += 2){
		prime[i] = 1;
	}
	for (i = 3; i * i <= max; i += 2){
		if (prime[i] == 0){
			for (j = i * 2; j <= max; j += i){
				prime[j] = 1;
			}
		}
	}
}

int main(void)
{
	int n;
	
	SetPrime(1000000);
	while (scanf("%d", &n) * n != 0){
		int i;
		int count = 0;
		
		for (i = 2; i <= n / 2; i++){
			if (prime[i] + prime[n - i] == 0){
				count++;
			}
		}
		printf("%d\n", count);
	}
	
	return 0;
}

Measured memory_bytes: 1576