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

using namespace std;

#define debug(n) cerr << #n << ':' << n << endl;
#define dline    cerr << __LINE__ << endl;

using ll = long long;
using ull = unsigned long long;
template<class T, class U> using P = pair<T,U>;
template<class T> using Heap = priority_queue<T>;
template<class T> using heaP = priority_queue<T,vector<T>,greater<T>>;
template<class T,class U> using umap = unordered_map<T,U>;
template<class T> using uset = unordered_set<T>;

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

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

template<class T, size_t N, class U>
void Fill(T (&a)[N], const U&v){
    fill((U*)a,(U*)(a+N),v);
}

template<class T>
istream& operator >> (istream&is, vector<T>&v){
  for(auto&e:v)is >> e;
  return is;
}

int main(){
  string s; cin >> s;
  bool f = s[1] == s[2];
  if(f && (s[0] == s[1] || s[2] == s[3])) cout << "Yes" << endl;
  else cout << "No" << endl;
}


Measured memory_bytes: 3604
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; ++i)
#define FOR(i, a, b) for (int i = a; i < b; ++i)
#define ALL(vec) vec.begin(), vec.end()
#define rALL(vec) vec.rbegin(), vec.rend()
using namespace std;
using ll = long long;

int main() {
    int N, K;
    cin >> N >> K;
    cout << N - K + 1 << endl;
    return 0;
}

Measured memory_bytes: 3576
#include <bits/stdc++.h>
using namespace std;
const int maxn=3005;
const int mod=998244353;
int n,s,a[maxn],dp[maxn][maxn][3];
inline void add(int &x,int y) {
    x+=y;
    if (x>=mod) x-=mod;
}
int main()
{
    scanf("%d%d",&n,&s);
    for (int i=1;i<=n;++i) scanf("%d",&a[i]);
    dp[0][0][0]=1;
    for (int i=1;i<=n;++i) for (int j=0;j<=s;++j) {
        add(dp[i][j][0],dp[i-1][j][0]);
        if (j+a[i]<=s) {
            add(dp[i][j+a[i]][1],dp[i-1][j][0]);
            add(dp[i][j+a[i]][1],dp[i-1][j][1]);
        }
        add(dp[i][j][1],dp[i-1][j][0]);
        add(dp[i][j][1],dp[i-1][j][1]);
        add(dp[i][j][2],dp[i][j][1]);
    }
    int res=0;
    for (int i=1;i<=n;++i) add(res,dp[i][s][2]);
    printf("%d\n",res);
    return 0;
}


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

int main() {
  int n;
  cin>>n;
  vector<int> p(n);
  vector<int> s(n);
  for(int i=0;i<n;i++){
    cin>>p[i];
  }
  for(int i=1;i<=n;i++){
    s[i-1]=i;
  }
  int y=0;
  for(int i=0;i<n;i++){
    if(s[i]!=p[i]){
      y++;
    }
  }
  if((y==2)||(y==0)){
    cout<<"YES"<<endl;
  }
  else{
    cout<<"NO"<<endl;
  }
}
  


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
using namespace std;
const int MAX_V = 10010;
const int INF = 1e9;
typedef pair<int, int> P;

struct edge{
    int u, v, d, c;
    bool operator<(const edge &e)const{
        return c < e.c;
    }
};

struct edge2{
    int to, dist, cost, id;
};

int n, m, ans;
vector<edge> es;
vector<edge2> G[MAX_V]; 
int d[MAX_V];
bool used[MAX_V];
int MINcost[MAX_V];

void dijkstra(int s){
    fill(d, d + MAX_V, INF);
    fill(MINcost, MINcost + MAX_V, INF);
    d[s] = 0;
    priority_queue<P, vector<P>, greater<P> > q;
    q.push({0, s});
    while(!q.empty()){
        P p = q.top(); q.pop();
        int from = p.second;
        int dist = p.first;
        rep(i, 0, G[from].size()){
            edge2 e = G[from][i];
            int newDist = dist + e.dist;
            int nxt = e.to;
            if(d[nxt] > newDist){
                d[nxt] = newDist;
                MINcost[nxt] = e.cost;
                q.push({newDist, nxt});
            }else if(d[nxt] == newDist){
                MINcost[nxt] = min(MINcost[nxt], e.cost);
            }
        }
    }
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    while(1){
        cin >> n >> m;
        if(n + m == 0) break;
        es.clear();
        es.resize(m);
        ans = 0;
        rep(i, 0, n) G[i].clear();
        rep(i, 0, m){
            cin >> es[i].u >> es[i].v >> es[i].d >> es[i].c;
            es[i].u--; es[i].v--;
            G[es[i].u].push_back({es[i].v, es[i].d, es[i].c});
            G[es[i].v].push_back({es[i].u, es[i].d, es[i].c});
        }
        sort(es.begin(), es.end());
        dijkstra(0);
        rep(i, 1, n){
            ans += MINcost[i];
        }
        cout << ans << endl;
    }
}


Measured memory_bytes: 5720
#include <bits/stdc++.h>
#define REP(i, n) for(ll i = 0; i < (ll)n; i++)
#define FOR(i, a, b) for(ll i = (a); i < (ll)b; i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define INF 1000000000000000
using namespace std;
typedef long long ll;
typedef double db;
typedef string str;
typedef pair<ll, ll> p;
constexpr int MOD = 1000000007;
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;
}

void print(const std::vector<int> &v) {
    std::for_each(v.begin(), v.end(), [](int x) { std::cout << x << " "; });
    std::cout << std::endl;
}

int main() {
    int A, B;
    cin >> A >> B; //ともに五桁
    int cnt = 0;
    for(int i = A / 10000; i <= B / 10000; i++) {
        for(int j = 0; j < 10; j++) {
            for(int k = 0; k < 10; k++) {
                int tmp = i * 10001 + j * 1010 + k * 100;
                if(tmp >= A and tmp <= B) {
                    cnt++;
                }
            }
        }
    }
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <sstream>
#include <cmath>
#include <queue>

using namespace std;

#define INF (1 << 27)
#define MAX_V 10000

struct edge{
	int to;
	int cost;
};

struct edge2{
	int from;
	int to;
	int cost;
};

typedef pair<int, int> P; // first??????????????¢???second??????????????????

// ?????????O(|E|log|V|)

int d[MAX_V];
vector<edge> G[MAX_V];

void shortest_path(vector<int> v_s, int V){ // V???????????°
	
	priority_queue<P, vector<P>, greater<P> > que;
	
	for(int i = 0; i < V; i++){
		d[i] = INF;
	}
	for(int i = 0; i < v_s.size(); i++){
		d[v_s[i]] = 0;
		que.push(P(0, v_s[i]));
	}
	
	
	while(!que.empty()){
		
		P p = que.top();
		que.pop();
		
		int v = p.second;
		
		if(d[v] < p.first){
			continue;
		}
		
		for(int i = 0; i < G[v].size(); i++){
			edge e = G[v][i];
			if(d[e.to] > e.cost + d[v]){
				d[e.to] = d[v] + e.cost;
				que.push(P(d[e.to], e.to));
			}
		} // ????????????????°???????????????´??°
	}
}

int main(){
	
	int N, M, K;
	
	while(true){
		cin >> N >> M >> K;
		
		if(cin.eof()){
			break;
		}
		
		for(int i = 0; i < MAX_V; i++){
			G[i].erase(G[i].begin(), G[i].end());
		}
		
		vector<edge2> v_edges;
		
		for(int i = 0; i < M; i++){
			int a, b, l;
			cin >> a >> b >> l;
			a--;
			b--;
			edge e1, e2;
			edge2 ee;
			e1.to = b;
			e2.to = a;
			e1.cost = l;
			e2.cost = l;
			G[a].push_back(e1);
			G[b].push_back(e2);
			
			ee.from = a;
			ee.to = b;
			ee.cost = l;
			v_edges.push_back(ee);
			
		}
		
		vector<int> v_start;
		
		for(int i = 0; i < K; i++){
			int st;
			cin >> st;
			st--;
			v_start.push_back(st);
		}
		
		shortest_path(v_start, N);
		
		int ans = 0;
		
		for(int i = 0; i < v_edges.size(); i++){
			edge2 ee = v_edges[i];
			int ref = d[ee.from] + d[ee.to] + ee.cost;
			if(ref % 2 == 1){
				ref++;
			}
			if(ans < ref / 2){
				ans = ref / 2;
			}
		}
		cout << ans << endl;
		
	}
	
	return 0;
}

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

int main() {
    int N;
    cin >> N;
    vector<int> items(N);

    int max = -1, max_pos = -1;
    for (int i=0;i<N;i++)
    {
        cin >> items[i];
        if (items[i] > max)
        {
            max = items[i];
            max_pos = i;
        }
    }

    int sum = 0;
    for (int i=0; i<N;i++)
    {
        if (i != max_pos)

            sum += items[i];
        else
            sum += items[i]/2;
    }

    cout << sum;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>

using namespace std;

int main(void) {

	int size = 0;
	string S;

	cin >> S;

	size = S.size();

	for (int i = 0; i < size; i++) {

		if ((i+1) % 2 == 1)
			cout << S[i];

	}

	cout << endl;

}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) x.begin(),x.end()

int main() {
   int a,b,c,x;
   cin >> a >> b >> c >> x;

   int ans=0;
   for(int i=0;i<=a;i++){
      for(int j=0;j<=b;j++){
         for(int k=0;k<=c;k++){
            if(500*i+100*j+50*k==x)
            ans++;
         }
      }
   }
   cout << ans << endl;
}

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

int main() {
  string s;
  int k;
  cin >> s >> k;

  vector<string> arr;
  map<string, int> m;
  int cnt = 0;
  for (char i = 'a'; i <= 'z'; i++) {
    if (cnt > k) { break; }
    for (int j = 0; j < s.size(); j++) {
      if (s[j] == i) {
        string S = "";
        for (int z = j; z < s.size() && z < j + k; z++) {
          S += s[z];
          if (m[S] == 0) {
            arr.push_back(S);
            cnt++;
            m[S]++;
          }
        }
      }
    }
  }
  sort(arr.begin(), arr.end());
  cout << arr[k - 1] << endl;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp> // Common file
//#include <ext/pb_ds/tree_policy.hpp>
//#include <functional> // for less
#define PI acos(-1.0)
#define eps 1e-9
#define ll long long
#define ull unsigned long long
#define nl printf("\n")
#define sf scanf
#define pf printf
#define INF (ll)1e15
#define mod 1000000007

///#define isValid(n,m,nx,ny)nx>=0&&nx<n&&ny>=0&&ny<m
///int kx[]={1, 1, -1, -1, 2, 2, -2, -2}; //knight moves
///int ky[]={2,-2,  2, -2, 1,-1,  1, -1}; //knight moves
///int dx[]={1,-1,0,0,1,-1,1,-1};//eight direction
///int dy[]={0,0,1,-1,1,-1,-1,1};//eight direction
 
///using namespace __gnu_pbds;
using namespace std;
 
///inline double toRad(double deg){return deg*PI/180;}
///inline double toDeg(double rad){return rad*180/PI;}
///typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> new_data_set;
 
const int S=123456;
int main()
{
    #ifndef ONLINE_JUDGE
    //freopen("input.txt","r",stdin);
    #endif
    string o,e;
    while(cin>>o>>e)
    {
        int sz=o.size()+e.size();
        int j=0,k=0;
        for(int i=0;i<sz;i++)
        {
            if(i%2==0)pf("%c",o[j]),j++;
            else pf("%c",e[k]),k++;
        }
        nl;
    }
    return 0;
}
 









 




























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

using namespace std;

#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define FOR(i, a, b) for(int i=(a);i<(b);i++)
#define REP(i, n) FOR(i, 0, n)
#define RFOR(i, a, b) for(int i=(a);i>=(b);i--)
#define RREP(i, n) RFOR(i, n, 0)
#define MFOR(i, m) for(auto i=(m).begin();i!=(m).end();i++)
#define ALL(a) (a).begin(), (a).end()
#define SZ(x) ((int)(x).size())

typedef long long int ll;
typedef pair<int, int> P;
typedef pair<ll, ll> Pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
typedef vector<vll> vvll;

const double eps = 1e-10;
const int MOD = 1000000007;
const int INF = 1000000000;
const ll LINF = 1 << 30;

template<typename T>
void printv(vector<T> const& s) {
  REP(i, SZ(s)) {
    cout << s[i] << " ";
  }
  cout << endl;
}

int calc[10][10];

int e(int a, int b, int c, int d) {
  return calc[calc[calc[calc[0][a]][b]][c]][d];
}

int check(int a, int b, int c, int d, int digit) {
  return calc[e(a, b, c, d)][digit];
}

int main () {
  cin.tie(0);
  cout << setprecision(10);

  REP(i, 10) {
    REP(j, 10) {
      cin >> calc[i][j];
    }
  }

  int cnt = 0;
  REP(i, 10000) {
    int a[5];
    int tmpi = i;
    a[3] = i % 10; i /= 10;
    a[2] = i % 10; i /= 10;
    a[1] = i % 10; i /= 10;
    a[0] = i % 10;
    a[4] = e(a[0], a[1], a[2], a[3]);
    i = tmpi;
    bool ok = true;
    REP(j, 5) {
      if(!ok) break;
      REP(k, 10) {
        if(a[j] != k) {
          int tmp = a[j];
          a[j] = k;
          int res = check(a[0], a[1], a[2], a[3], a[4]);
          a[j] = tmp;
          if(res == 0) {
            ok = false;
            break;
          }
        }
      }
    }
    if((a[0] != a[1] && check(a[1], a[0], a[2], a[3], a[4]) == 0) ||
        (a[1] != a[2] && check(a[0], a[2], a[1], a[3], a[4]) == 0) ||
        (a[2] != a[3] && check(a[0], a[1], a[3], a[2], a[4]) == 0) ||
        (a[3] != a[4] && check(a[0], a[1], a[2], a[4], a[3]) == 0)) ok = false;

    if(!ok) cnt++;
  }
  cout << cnt << endl;
}



Measured memory_bytes: 3100
#include<iostream>
#include<cstdio>
#include<cstring>

namespace Doubi_Problem
{
	const int N=101000,M=N*2;
	int begin[N],next[M],to[M];
	bool f[N],g[N];
	int n,e;
	void add(int x,int y,bool k=1)
	{
		to[++e]=y;
		next[e]=begin[x];
		begin[x]=e;
		if(k)add(y,x,0);
	}
	void predfs(int p=1,int h=0)
	{
		f[p]=0;g[p]=1;
		for(int i=begin[p],q;i;i=next[i])
			if((q=to[i])!=h)
			{
				predfs(q,p);
				f[p]|=g[q];
				g[p]&=f[q];
			}
	}
	void initialize()
	{
		scanf("%d",&n);
		for(int i=1,u,v;i<n;i++)
			scanf("%d%d",&u,&v),add(u,v);
		predfs();
	}
	bool ans;
	void dfs(int p=1,int h=0)
	{
		int cnt_son=0,cntg=0,cntf=0;
		for(int i=begin[p],q;i;i=next[i])
		{
			q=to[i];
			cntg+=g[q];
			cntf+=f[q];
			cnt_son++;
		}
		if(cntf==cnt_son)ans|=1;//return; why not return ? fuck you

		for(int i=begin[p],q;i;i=next[i])
			if((q=to[i])!=h)
			{
				f[p]=(cntg-g[q]!=0);
				g[p]=(cntf-f[q]==cnt_son-1);
				dfs(q,p);
			}
	}
	void solve()
	{
		initialize();
		dfs();
		printf("%s\n",ans?"First":"Second");
	}
}

int main()
{
	Doubi_Problem::solve();
	return 0;
}


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

int main() {
  string s, t, u;
  int a, b;
  cin >> s >> t >> a >> b >> u;

  if(s == u) cout << a - 1 << " " << b << endl;
  else cout << a << " " << b - 1 << endl;

}



Measured memory_bytes: 256
N = int(input())
A = sorted([int(i) for i in input().split()])
B = [int(i) for i in input().split()]
C = sorted([int(i)-1 for i in input().split()])

def bis(x,y):
    low = 0
    high = N
    while low < high:
        mid = (low + high) // 2
        if x[mid] < y: low = mid + 1
        else: high = mid
    return low

total = 0
for b in B:
    total += bis(A,b) * (N - bis(C,b))

print(total)


Measured memory_bytes: 23616
#include <stdio.h>
#include <string.h>
 int main(){
 char x[1000],y[1000];
 int n,i,j;
 scanf("%d",&n);
 for(i = 0;i < n;i++){
    scanf("%s %s",x, y);
   printf("%d\n",cal(x,y));
 }
 return 0;
}

int cal(char x[], char y[]){

 int i,j;
 int m = strlen(x);
 int n = strlen(y);
 int count[m+1][n+1];

 for(i = 0;i <= m; i++){
  count[i][0] = 0;
  }
 for(j = 0;j <= n; j++){
  count[0][j] = 0;
  }
 for(i = 1;i <= m; i++){
  for(j = 1;j <= n; j++){
    if(x[i-1] == y[j-1])
     count[i][j] = count[i-1][j-1] + 1;
    else if(count[i-1][j] >= count[i][j-1]){
     count[i][j] = count[i-1][j];
  }
    else
     count[i][j] = count[i][j-1];
  }
 }
 return count[m][n];
}

Measured memory_bytes: 4520
#include<bits/stdc++.h>
	using namespace std;
	int main(){
		int a,b,cnt=0,ones,tens;
		cin>>a>>b;
	
 
			for(int j=22;j<=b;j++)
			{
					ones=j%10;
					int c=j;
					c=c/10;
					tens=c%10;
				if(ones*tens<=a&&ones*tens!=0&&ones>=2){
					cnt++;
				}
 
			}
			cout<<cnt;
	}

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

int main(){
  vector<char> d(10);
  for(int i=0;i<10;i++)
    cin >>d.at(i);
  d.at(3)='8';
  for(int i=0;i<10;i++)
    cout<<d.at(i);
  cout <<endl;
}


Measured memory_bytes: 256
#include<algorithm>
#include<string>
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
#define INF 999999999
using namespace std;
typedef pair<int, int> P;
typedef pair<llong, llong> LP;
typedef pair<int, P> PP;
typedef pair<llong, LP> LPP;
 
int dy[]={0, 0, 1, -1, 0};
int dx[]={1, -1, 0, 0, 0};
 
 
int main(){
    
    int N,x;
    cin >> N >> x;
    vector<int> a(N);
    REP(i,N){
        cin >> a[i];
    }

    llong ans=0;
    if(a[0] > x){
        ans += a[0]-x;
        a[0]=x;
        // cout << ans << endl;
    }
    REP(i,N-1){
        if(a[i+1] + a[i] > x){
            ans += a[i+1] - (x-a[i]);
            a[i+1] = x-a[i];
        }
        // cout << ans << endl;
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define min(a,b) ((a)<(b)?(a):(b))
#define max(a,b) ((a)>(b)?(a):(b))
#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,n1,n2) for(int i=n1;i<n2;i++)
#define bFOR(i,n1,n2) for(int i=n1;i>=n2;i--)
#define speed_up    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

typedef long long int ll;
typedef pair<ll,ll> Pi;
const int INF=(ll)(1LL<<30)-1;
const double INFd=100000000000.0;
const ll INFl=(ll)9223372036854775807;
const int MAX=10000;
const ll MOD=(ll)1e9+7;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a, b)*b;}
int dx[4]={0,-1,0,1},dy[4]={-1,0,1,0};
int mdx[4]={0,1,0,-1},mdy[4]={-1,0,1,0};


template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

ll n,m;
int s[2010],t[2010];
ll dp[2010][2010];

ll cong[2010][2010];
int main(){
	cin>>n>>m;
	REP(i,n)cin>>s[i];
	REP(i,m)cin>>t[i];
	dp[0][0]=(s[0]==t[0])?1:0;
	for(int i=1;i<n;i++){
		dp[0][i]=dp[0][i-1]+((t[0]==s[i])?1:0);
	}
	for(int i=1;i<m;i++){
		dp[i][0]=dp[i-1][0]+((t[i]==s[0])?1:0);
	}
	
	for(int i=1;i<m;i++){
		for(int j=1;j<n;j++){
			dp[i][j]=(dp[i-1][j]+dp[i][j-1]-dp[i-1][j-1]+MOD)%MOD;
			if(t[i]==s[j])dp[i][j]=dp[i][j]+dp[i-1][j-1]+1;
			dp[i][j]%=MOD;
		}
	}
	
	cout<<(dp[m-1][n-1]+1)%MOD<<endl;
	return 0;
}

Measured memory_bytes: 32512
X, K, D = map(int, input().split())

X = abs(X)

if K <= int(X/D):
    X -= D*K
    print(abs(X))
else:
    K -= int(X/D)
    X -= D*int(X/D)
    if K % 2 == 0:
        print(abs(X))
    else:
        print(abs(X-D))

Measured memory_bytes: 9176
#pragma region RegionDefs
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0,i##_len=(n);i<i##_len;++i)
#define reps(i,l,r) for(int i=(l),i##_len=(r);i<i##_len;++i)
#define all(x) begin(x),end(x)
using namespace std;
typedef long long ll;
const ll INF = 1e9;
template<class T=ll> using V = vector<T>;
template<class T=ll> using PQ = priority_queue<T>;
template<class T=ll> using PQG = priority_queue<T, V<T>, greater<T>>;
const ll MOD = 1000000007LL;
void in() {}
template<class Head, class... Tail>
void in(Head&& head, Tail&&... tail)
{
    cin >> head;
    in(move(tail)...);
}
#define IN(...) ll __VA_ARGS__; in(__VA_ARGS__)
#define INS(T, ...) T __VA_ARGS__; in(__VA_ARGS__)
#define VIN(T, v, n) V<T> v(n); for(auto& _elem:v)cin>>_elem
template<class T>bool chmax(T &a, const T &b) {if (a<b) {a=b; return 1;} return 0;}
template<class T>bool chmin(T &a, const T &b) {if (a>b) {a=b; return 1;} return 0;}
#define y0 y__0
#define y1 y__1
#define j0 j__0
#define j1 j__1
#define YN(e) cout << ((e) ? "YES" : "NO") << endl
#define yn(e) cout << ((e) ? "Yes" : "No") << endl
#pragma endregion RegionDefs

void solve()
{
    IN(x, n);
    VIN(ll, v, n);
    ll y = INF;
    for(int i = 102; i >= 0; --i) {
        rep(j, n) {
            if (i == v[j]) {
                goto end;
            }
        }
        if (abs(x-y) >= abs(x-i)) {
            y = i;
        }
        end:;
    }
    cout << y << endl;
}

int main()
{
    cin.tie(0); cout.tie(0);
    ios::sync_with_stdio(false);
    cout << setprecision(numeric_limits<double>::max_digits10);

    solve();

    return 0;
}

Measured memory_bytes: 3648
#include <iostream>

using namespace std;

int main(int argc, char *argv[])
{
	long long A, B, C, K;
	cin >> A >> B >> C >> K;

	K -= A;
	if (K > 0) K -= B;
	if (K > 0) A -= K;
	if (K < 0) A += K;
	cout << A << endl;
	return 0;
}


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

int main(){
  string S,W;
  cin >> S;
  W = "aaa";
  W.at(0) = S.at(0);
  W.at(1) = S.at(1);
  W.at(2) = S.at(2);
  cout << W << endl;
}


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

int main() {
    std::string s, t;
    std::cin >> s >> t;

    std::vector<std::vector<int>> v(26);
    for (int i = 0; i < s.size(); i++) {
        v[s[i] - 'a'].push_back(i + 1);
    }

    long long ans = 0;
    int now = 0;
    for (int i = 0; i < t.size(); i++) {
        int k = t[i] - 'a';
        if (v[k].empty()) {
            std::cout << "-1\n";
            return 0;
        }

        auto it = std::upper_bound(v[k].begin(), v[k].end(), now);
        if (it == v[k].end()) {
            ans += s.size();
            now = v[k].front();
        }
        else {
            now = *it;
        }
    }
    ans += now;

    std::cout << ans << "\n";
}

Measured memory_bytes: 1216
#include <bits/stdc++.h>
#define int long long
#define ll long long
using ull = unsigned long long;
using namespace std;
const int INF = 1e10;
const int MOD = 1e9 + 7;
#define dump(x)                             \
    if (dbg) {                              \
        cerr << #x << " = " << (x) << endl; \
    }
#define overload4(_1, _2, _3, _4, name, ...) name
#define FOR1(n) for (ll i = 0; i < (n); ++i)
#define FOR2(i, n) for (ll i = 0; i < (n); ++i)
#define FOR3(i, a, b) for (ll i = (a); i < (b); ++i)
#define FOR4(i, a, b, c) for (ll i = (a); i < (b); i += (c))
#define FOR(...) overload4(__VA_ARGS__, FOR4, FOR3, FOR2, FOR1)(__VA_ARGS__)
#define FORR(i, a, b) for (int i = (a); i <= (b); ++i)
template <class T>
bool chmin(T& a, const T& b) {
    if (a > b) {
        a = b;
        return 1;
    } else
        return 0;
}
template <class T>
bool chmax(T& a, const T& b) {
    if (a < b) {
        a = b;
        return 1;
    } else
        return 0;
}
#define pb push_back
#define mp make_pair
#define lb lower_bound
#define ub upper_bound
#define all(v) (v).begin(), (v).end()
#define SZ(x) ((int)(x).size())
#define P pair<int, int>
#define V vector<int>
//#define S set<int>
#define itn int
bool dbg = false;
int N;
string S[202020];
map<string, int> M;
vector<string> v;

void solve() {
    int MAX = 0;
    FOR(i, 0, N) {
        M[S[i]]++;
        chmax(MAX, M[S[i]]);
    }

    for (auto i = M.begin(); i != M.end(); ++i) {
        if (i->second == MAX) {
            v.pb(i->first);
        }
    }
    sort(all(v));
    for (auto& x : v)
        cout << x << endl;
}

signed main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cin >> N;
    FOR(i, 0, N)
    cin >> S[i];
    solve();
    return 0;
}


Measured memory_bytes: 27196
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
typedef long long ll;

int main() {
  string s;
  cin >> s;
  int len = s.size();
  int ans = 0;
  REP(i, len/2) {
    if (s[i] == s[len-i-1]) continue;
    ans++;
  }
  cout << ans << endl;
}

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

using namespace std;
using ll =long long;
using db = double;
using vll = vector<long long>;

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; }
#define che(a,string) cout<<"//"<<string <<"=="<<(a)<<"//" <<endl;
#define SORT(a) sort((a).begin(),(a).end())
#define rSORT(a) reverse((a).begin(),(a).end())
#define For(i, a, b)    for(int i = (a) ; i < (b) ; ++i)
#define rep(i, n)       For(i, 0, n)
#define leftunique(a) {SORT(a);(a).erase(unique((a).begin(),(a).end()),(a).end());}
//leftuniqueは配列から同じ要素のものを取り除く 例 4 6 2 1 3 4 1 2 なら 1 2 3 4 6 になる
#define debug(x)  cout << #x << " = " << (x) << endl;
bool IsInt(double a){int b = a/1;if(a==b){return true;}else {return false;}}
bool coY() {cout <<"Yes"<<endl;}
bool coN(){cout <<"No"<<endl;}
const int mod = 1e9 + 7;
const ll INF = 1LL << 60;
// a^n mod を計算する
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;
}
//printfを使うときは上を削除
//グラフ用
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};	

//宣言だけしとく
int N,M,H,W,K,A,B;
string S;
//ここから書き始める

ll combination(ll n, ll i){
	ll count = 0;
	ll multi = 1;
	ll div =1;
	int limit = i;
	while(count < limit){
		multi *= n;
		n--;
		multi/= count+1;
		count ++ ;
	}
	return multi / div;
}

int main()
{
	cout << setprecision(10);
	int n ; 
	string s;
	cin >> n >> s; 

	//A から Z のループ
	rep(i,s.size()){
		int ban = s[i]-'A' + n;
		ban %= 26;

		char newban = 'A'+ ban;
		cout <<  newban ;
	}
	cout << endl;

}


Measured memory_bytes: 256
#pragma GCC optimize ("O3")
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <cmath>
#include <numeric>
#include <vector>
#include <set>
#include <map>
#include <cstring>
#include <stack>
#include <unordered_map>
#define lld long long int
#define dbg1(vari1) cerr<<#vari1<<" = "<<(vari1)<<endl;
#define dbg2(vari1,vari2) cerr<<#vari1<<" = "<<(vari1)<<" "<<#vari2<<" = "<<(vari2)<<endl;
#define dbg3(vari1,vari2,vari3) cerr<<#vari1<<" = "<<(vari1)<<" "<<#vari2<<" = "<<(vari2)<<" "<<#vari3<<" = "<<(vari3)<<endl;
using namespace std;
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int n,k;
	cin >> n >> k;
	int r,s,p;
	cin >> r >> s >> p;
	string move;
	cin >> move;
	int ans=0;
	string sans="";
	map <char,int> ma;
	ma['r']=r;
	ma['s']=s;
	ma['p']=p;
	for(int i=0;i<n;i++)
	{
		if(move[i]=='r')
		{
			sans+='p';
		}
		else if(move[i]=='s')
		{
			sans+='r';
		}
		else if(move[i]=='p')
		{
			sans+='s';
		}
	}
	// cout << sans;
	for(int i=0;i<k;i++)
	{
		if(sans[i]=='r')
				ans+=r;
			else if(sans[i]=='p')
				ans+=p;
			else if(sans[i]=='s')
				ans+=s;
	}
	for(int i=k;i<n;i++)
	{
		if(sans[i]==sans[i-k])
		{
			if(i+k<n&&sans[i+k]==move[i])
			{
				sans[i]='*';
			}
			else
				sans[i]=move[i];
		}
		else
		{
			if(sans[i]=='r')
				ans+=r;
			else if(sans[i]=='p')
				ans+=p;
			else if(sans[i]=='s')
				ans+=s;
		}
	}
	cout << ans;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define F first
#define S second
#define pii pair<int, int>
#define eb emplace_back
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < n; ++i)
#define rep3(i, l, n) for (int i = l; i < n; ++i)
#define max(a, b) (a > b ? a : b)
#define min(a, b) (a < b ? a : b)
#define chmax(a, b) a = (a >= b ? a : b)
#define chmin(a, b) a = (a <= b ? a : b)
#define out(a) cout << a << endl
#define outa(a, n) { rep(_, n) cout << a[_] << " "; cout << endl; }
#define outp(a, n) { cout << endl; rep(_, n) cout << a[_].F << " " << a[_].S << endl; }
#define SZ(v) (int)v.size()
#define inf (int)(1e9+7)
#define abs(x) (x >= 0 ? x : -(x))
#define ceil(a, b) a / b + !!(a % b)
#define FIX(a) fixed << setprecision(a)
#define LB(v, n) (int)(lower_bound(all(v), n) - v.begin())
#define UB(v, n) (int)(upper_bound(all(v), n) - v.begin())

ll n, m;
const int MAX_N = 100010;
vector<ll> g[MAX_N];
ll color[MAX_N];

// ある点のcolorが0でないからといってcontinueできない
// その先の頂点は別
// v, dのpairでメモ化
bool fin[MAX_N][11];

void dfs(ll v, ll d, ll c) {
    if (fin[v][d]) return;
    fin[v][d] = 1;
    if (d == 0) {
        color[v] = c;
        return;
    }
    dfs(v, d - 1, c);
    for (auto nxt : g[v]) {
        dfs(nxt, d - 1, c);
    }
}
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    
    cin >> n >> m;
    rep(i, m) {
        ll a, b;
        cin >> a >> b;
        a--; b--;
        g[a].eb(b);
        g[b].eb(a);
    }
    
    ll q;
    cin >> q;
    
    vector<ll> v(q), d(q), c(q);
    rep(i, q) cin >> v[q - 1 - i] >> d[q - 1 - i] >> c[q - 1 - i];
    
    // rep(i, q) cout << v[i] << " " << d[i] << " " << c[i] << endl;
    
    rep(i, q) {
        dfs(v[i] - 1, d[i], c[i]);
    }
    
    rep(i, n) out(color[i]);
}


Measured memory_bytes: 11124
#include<iostream>
#include<map>
#include<vector>
#include<cmath>
#include<string>
#include<cstring>
#include<algorithm> 
#include<climits>
#include<stack>
#include<queue>
#include<set>
#include<cctype>
#include<bitset> 
#include<type_traits>
#include<numeric>
#include<array>
using namespace std;

# define REP(i,n) for (int i=0;i<(n);++i)
# define rep(i,a,b) for(int i=a;i<(b);++i)
# define p(s) std::cout << s ;
# define pl(s)  std::cout << s << endl;
# define printIf(j,s1,s2) cout << (j ? s1 : s2) << endl;
# define YES(j) cout << (j ? "YES" : "NO") << endl;
# define Yes(j) std::cout << (j ? "Yes" : "No") << endl;
# define yes(j) std::cout << (j ? "yes" : "no") << endl;
# define all(v) v.begin(),v.end()
# define showVector(v) REP(i,v.size()){p(v[i]);p(" ")} pl("")
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;}
typedef long long int ll;
typedef pair<int,int> P_ii;
typedef pair<double,double> P_dd;

template<class T>
vector<T> make_vec(size_t a){
    return vector<T>(a);
}

template<class T, class... Ts>
auto make_vec(size_t a, Ts... ts){
  return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}

template<typename T,typename V>
typename enable_if<is_class<T>::value==0>::type
fill_v(T &t,const V &v){t=v;}

template<typename T,typename V>
typename enable_if<is_class<T>::value!=0>::type
fill_v(T &t,const V &v){
  for(auto &e:t) fill_v(e,v);
}

const int mod = 1000000007;
const int MOD = 1000000007;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;

void addM(long long &a, long long b) {
    a += b;
    if (a >= MOD) a -= MOD;
}

void mulM(long long &a, long long b) {
    a = ((a%MOD)*(b%MOD))%MOD ;
}

// a^b mod M
long myPow(long a,long b,int M) {
    long ret = 1;
    long tmp = a;
    while(b>0) {
        if((b&1)==1) ret = (ret * tmp) % M;
        tmp = (tmp * tmp) % M;
        b = b>>1;
    }
    return ret;
}

 // nCk mod M
int nCk(int n,int k,int M) {
    long ret = 1;
    int mi = min(k, n-k);
    for(int i=1;i<=mi;i++) {
        ret = (ret * myPow(i,M-2,M)) % M;
    }
    for(int i=n-mi+1;i<=n;i++) {
        ret = (ret * i) % M;
    }
    return (int)ret;
}

int N,M;
auto g = make_vec<int>(100001,0); 
auto dp = make_vec<ll>(100001); 

ll solve(int v){
    if(dp[v]>0) return dp[v];

    ll ret = 0;
    for(auto t:g[v]){
        chmax(ret,solve(t)+1);
    }

    return dp[v]=ret;
}


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

    REP(i,M) {
        int x,y;cin >> x >> y;
        x--;y--;
        g[x].push_back(y);
    }
    fill_v(dp,-1);

    ll ans=0;
    REP(i,N) chmax(ans,solve(i));

    pl(ans)

    return 0;
}

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

bool check(int a, int b, int c) {
    if(a>b) {
        return a > c && c > b;
    } else {
        return a < c && c < b;
    }
}

int main(void){
    // Your code here!
    int a, b, c;
    cin >> a >> b >> c;
   if(check(a, b, c)) cout << "Yes" << endl;
   else cout << "No" << endl;
   return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<queue>
#include<algorithm>
#include<string>
#include<cmath>

using namespace std;
using ll  = long long;
template <typename T> T In() {
    T t;
    cin >> t;
    return t;
}
template <typename T> vector<vector<T>> Vec2(int i, int j, T ini = 0) {
    vector<vector<T>> vec(i, vector<T>(i, ini));
    return move(vec);
}
template <typename T> vector<vector<vector<T>>> Vec3(int i, int j, int k, T ini = 0) {
    vector<vector<vector<T>>> vec(i, vector<vector<T>>(j, vector<T>(k, ini)));
    return move(vec);
}

int main() { 
    int N = In<int>();
    double ans = 0;
    for(int i = 0; i < N; i++) {
        ans += 1.0 / In<int>();
    }
    cout << 1/ans << endl;
}


Measured memory_bytes: 256
<?php
fscanf(STDIN, "%d %d %d %d", $A, $B, $C, $D);

if ($A + $B === $C + $D) {
    echo "Balanced" . "\n";
} elseif ($A + $B > $C + $D) {
    echo "Left" . "\n";
} else {
    echo "Right" . "\n";
}

Measured memory_bytes: 4604
N = int(input())
A = list(map(int, input().split()))
A.sort()
ans = 0
now = A[0]
start_idx = 0
while now <= A[-1] + 1:
    tmp_max = 0
    flag = True
    for i in range(start_idx, N):
        if flag and now - 1 == A[i]:
            flag = False
            start_idx = i
        if now - 1 <= A[i] <= now + 1:
            tmp_max += 1
        if now + 1 < A[i]:
            break
    ans = max(tmp_max, ans)
    now += 1
print(ans)

Measured memory_bytes: 84396
// #include <bits/stdc++.h>
#include <iostream>
#include <map>
#include <cmath>
#include <ios>
#include <iomanip>
#include <algorithm>
#include <queue>
#include <stack>
#include <numeric>
// #include <windows.h>
using namespace std;
template<class T> using V = vector<T>;
template<class T> using VV = V<V<T>>;
template<class T> using VVV = V<VV<T>>;
template<class T1, class T2> using P = pair<T1, T2>;
using I = int;
using D = double;
using B = bool;
using C = char;
using S = string;
using LL = long long;
using LD = long double;
using ULL = unsigned long long;
using PII = P<I, I>;
using VPII = V<PII>;
using PLL = P<LL, LL>;
using VPLL = V<PLL>;
using VI = V<I>;
using VVI = VV<I>;
using VLL = V<LL>;
using VVLL = VV<LL>;
using VC = V<C>;
using VVC = VV<C>;
using VS = V<S>;
using VVS = VV<S>;
using VB = V<B>;
using VVB = VV<B>;
#define REP(type, i, n) for (type i = 0; i < (type)(n); ++i)
#define REP2(type, i, m, n) for (type i = (m); i < (type)(n); ++i)
#define REPR(type, i, n) for (type i = (n)-1; i >= 0; --i)
#define REPR2(type, i, m, n) for (type i = (n)-1; i >= (m); --i)
#define REPx(x, a) for(auto x : a)
#define ALL(a) a.begin(), a.end()
#define SORT(a) sort(ALL(a))
#define SORTR(a, type) sort(ALL(a), greater<type>())
#define SORTF(a, comp) sort(ALL(a), comp)
#define REVERSE(a) reverse(ALL(a))
#define SIZE(a, type) ((type)(a).size())
#define bit_search(bit, n) REP(LL, bit, 1LL<<(n))
#define bit_check(bit, i) ((bit>>(i)) & 1)
#define setpre(n) fixed << setprecision((n))
#define UNIQUE(a) do {SORT(a); (a).erase(unique(ALL(a)), (a).end());} while(0)
#define MAX(a) *max_element(ALL(a))
#define MIN(a) *min_element(ALL(a))
#define bisect_left(a, x) (lower_bound(ALL(a), (x)) - a.begin())
#define bisect_right(a, x) (upper_bound(ALL(a), (x)) - a.begin())
#define INPUT(a) REPx(&x, a) cin >> x;
#define INPUT2(a) REPx(&x, a) INPUT(x);
#define INPUTP(a) REPx(&x, a) cin >> x.first >> x.second;
#define ENDL cout << endl;

// const int INF = 2e9;
const LL INF = 9e18;
const LL MOD = 1e9+7;

template<class T> using PRIORITY_QUEUE = priority_queue< T, V<T>, greater<T> >;
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;}
template<class T> inline void debug1(V<T> A){REP(int, i, SIZE(A, int)){if (A[i] == INF) cout << "I ";else cout << A[i] << " ";}ENDL}
template<class T> inline void debug2(VV<T> A){REP(int, i, SIZE(A, int)){REP(int, j, SIZE(A[i], int)){if (A[i][j] == INF) cout << "I "; else cout << A[i][j] << " ";}ENDL}}

int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n, ct = 0;
  cin >> n;
  VI b(n), ans(n, -1);
  INPUT(b);
  int l = n;
  REPR(int, i, n)
  {
    int ct = 0;
    bool flg = true;
    REPR(int, j, n)
    {
      if (b[j] == -1) continue;
      if (l-ct++ == b[j])
      {
        ans[i] = b[j];
        b[j] = -1;
        flg = false;
        break;
      }
    }
    if (flg)
    {
      cout << -1 << endl;
      return 0;
    }
    --l;
  }
  REP(int, i, n) cout << ans[i] << endl;

  return 0;
}


Measured memory_bytes: 3608
package main

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

func out(x ...interface{}) {
	fmt.Println(x...)
}

var sc = bufio.NewScanner(os.Stdin)

func getInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func getString() string {
	sc.Scan()
	return sc.Text()
}

// min, max, asub, absなど基本関数
func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func asub(a, b int) int {
	if a > b {
		return a - b
	}
	return b - a
}

func abs(a int) int {
	if a >= 0 {
		return a
	}
	return -a
}

func lowerBound(a []int, x int) int {
	idx := sort.Search(len(a), func(i int) bool {
		return a[i] >= x
	})
	return idx
}

func upperBound(a []int, x int) int {
	idx := sort.Search(len(a), func(i int) bool {
		return a[i] > x
	})
	return idx
}

// Priority Queue
// Item :
type Item struct {
	priority, value, index int
}

// PQ :
type PQ []*Item

func (pq PQ) Len() int {
	return len(pq)
}

func (pq PQ) Less(i, j int) bool {
	return pq[i].priority > pq[j].priority
}

func (pq PQ) Swap(i, j int) {
	pq[i], pq[j] = pq[j], pq[i]
	pq[i].index = i
	pq[j].index = j
}

// Push :
func (pq *PQ) Push(x interface{}) {
	n := len(*pq)
	item := x.(*Item)
	item.index = n
	*pq = append(*pq, item)
}

// Pop :
func (pq *PQ) Pop() interface{} {
	old := *pq
	n := len(old)
	item := old[n-1]
	item.index = -1
	*pq = old[0 : n-1]
	return item
}

// End Priority Queue

func dfs(n, p int, node [][]int, c []int) int {
	ret := 0
	for _, v := range node[n] {
		if v == p {
			continue
		}
		ret += dfs(v, n, node, c) + min(c[n], c[v])
	}
	return ret
}

func main() {
	sc.Split(bufio.ScanWords)
	N := getInt()
	node := make([][]int, N)
	edge := make([][2]int, N-1)
	for i := 0; i < N-1; i++ {
		f, t := getInt()-1, getInt()-1
		node[f] = append(node[f], t)
		node[t] = append(node[t], f)
		edge[i] = [2]int{f, t}
	}
	c := make([]int, N)
	for i := 0; i < N; i++ {
		c[i] = getInt()
	}
	sort.Ints(c)

	idx := N - 1
	n := make([]int, N)
	m := make([]int, N-1)
	m[0] = c[idx-1]
	n[edge[0][0]] = c[idx]
	idx--
	n[edge[0][1]] = c[idx]
	idx--
	// out(n, m)
	for idx >= 0 {
		for i := 0; i < N-1; i++ {
			if m[i] != 0 {
				continue
			}
			if n[edge[i][0]] != 0 {
				m[i] = c[idx]
				n[edge[i][1]] = c[idx]
				idx--
			} else if n[edge[i][1]] != 0 {
				m[i] = c[idx]
				n[edge[i][0]] = c[idx]
				idx--
			}
		}
	}
	// out(idx)
	// out(n)

	ans := dfs(0, -1, node, n)

	w := bufio.NewWriter(os.Stdout)
	defer w.Flush()

	fmt.Fprintln(w, ans)
	for i := 0; i < N; i++ {
		fmt.Fprint(w, n[i], " ")
	}
	fmt.Fprintln(w)
}


Measured memory_bytes: 5760
macro_rules! get {
      ($t:ty) => {
          {
              let mut line: String = String::new();
              std::io::stdin().read_line(&mut line).unwrap();
              line.trim().parse::<$t>().unwrap()
          }
      };
      ($($t:ty),*) => {
          {
              let mut line: String = String::new();
              std::io::stdin().read_line(&mut line).unwrap();
              let mut iter = line.split_whitespace();
              (
                  $(iter.next().unwrap().parse::<$t>().unwrap(),)*
              )
          }
      };
      ($t:ty; $n:expr) => {
          (0..$n).map(|_|
              get!($t)
          ).collect::<Vec<_>>()
      };
      ($($t:ty),*; $n:expr) => {
          (0..$n).map(|_|
              get!($($t),*)
          ).collect::<Vec<_>>()
      };
      ($t:ty ;;) => {
          {
              let mut line: String = String::new();
              std::io::stdin().read_line(&mut line).unwrap();
              line.split_whitespace()
                  .map(|t| t.parse::<$t>().unwrap())
                  .collect::<Vec<_>>()
          }
      };
      ($t:ty ;; $n:expr) => {
          (0..$n).map(|_| get!($t ;;)).collect::<Vec<_>>()
      };
}

fn main() {
    // 入力
    let (N, P) = get!(i64, i64);

    let mut ans = 1;
    let mut p = P;

    for i in 2..1000001 {
        let mut k = 0;
        while p % i == 0 {
            k += 1;
            p /= i;
        }
        while k / N > 0 {
            ans *= i;
            k -= N;
        }
    }

    if N == 1 {
        ans = P;
    }

    // 出力
    println!("{}", ans);
}

Measured memory_bytes: 4476
#define  _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <math.h>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <math.h>
#include <iostream> 
#include <random>
#include<map>
#include <iomanip>
#include <time.h>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <cassert>
#include<fstream>
#include <unordered_map>  
using namespace std;
#define Ma_PI 3.141592653589793
#define eps 0.00000000000000000000000001
#define LONG_INF 10000000000000000
#define GOLD 1.61803398874989484820458
#define MAX_MOD 1000000007
#define REP(i,n) for(long long i = 0;i < n;++i)
int main() {
	while (true) {
		int n;
		cin >> n;
		if (n == 0) return 0;
		int ans = 0;
		for (int i = n + 1; i <= 2 * n; ++i) {
			int ok = 1;
			for (int q = 2; q <= sqrt(i); ++q) {
				if (i % q == 0) ok = 0;
			}
			ans += ok;
		}
		cout << ans << endl;
	}
}



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

int main(){
 int a,b,c; cin >> a >> b >>c;
 int d = a * 10 + b + c;
 int e = b * 10 + c + a;
 int f = c * 10 + a + b;
 cout << max(max(d,f),e);
}


Measured memory_bytes: 3596
#include <iostream>
#include <fstream>
#include <vector>
#include <algorithm>
#include <string>
#include <limits>
#include <map>
#include <numeric>
#include <cmath>
#include <unordered_map>
#include <unordered_set>
#include <deque>
#include <stack>

typedef long long li;
using namespace std;

li max(li a, li b) {
    return a > b ? a : b;
}

li max(li a, li b, li c) {
    return max(a, max(b, c));
}

li max(li a, li b, li c, li d) {
    return max(a, max(b, max(c, d)));
}

li max(li a, li b, li c, li d, li e) {
    return max(a, max(b, max(c, max(d, e))));
}


li pow_mod(li n, li e, li mod)
{
    li r = 1;
    
    while(e > 0)
    {
        if(e & 1)
            r *= n;
            r %= mod;
        
        n *= n;
        n %= mod;
        e >>= 1;
    }
    
    return r;
}


int main() {
    li n, d, a, x, h;
    vector<vector<li>> v;
    deque<vector<li>> dq;
    cin >> n >> d >> a;
    
    for (int i = 0; i < n; i++) {
        cin >> x >> h;
        v.push_back({x, h});
    }
    
    sort(v.begin(), v.end(), [](const vector<li> & a, const vector<li> & b) {
        return a[0] < b[0];
    });
    
    
    li i = 0, sub = 0, cnt = 0, add = 0;
    
    while(i < v.size()) {
        while(!dq.empty() && dq.front()[0] < v[i][0]) {
            sub += dq.front()[1];
            dq.pop_front();
        }
        
        add = 0;
        
        if (v[i][1] > sub) {
            li num = v[i][1] - sub;
            sub += (num / a) * a;
            add -= (num / a) * a;
            if (num % a) {
                cnt++;
                sub += a;
                add -= a;
            }
            
            cnt += num / a;
            dq.push_back({v[i][0] + 2 * d, add});
        }
        
        i++;
    }
    
    cout << cnt << endl;
    
    
    return 0;
}


Measured memory_bytes: 17964
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
map<ll, int> M;
ll sum, ans;
int main()
{
	int n;
	scanf("%d", &n);
	M[sum] = 1;
	for(int i = 1; i <= n; ++i)
	{
		int val;
		scanf("%d", &val);
		sum += val;
		ans += M[sum];
		++M[sum];
	}
	printf("%lld\n", ans);
	return 0;
}
		
	 

Measured memory_bytes: 16188
import sys, math
import io, os
#data = io.BytesIO(os.read(0,os.fstat(0).st_size)).readline
from bisect import bisect_left as bl, bisect_right as br, insort
from heapq import heapify, heappush, heappop
from collections import defaultdict as dd, deque, Counter
#from itertools import permutations,combinations
def data(): return sys.stdin.readline().strip()
def mdata(): return list(map(int, data().split()))
def outl(var) : sys.stdout.write('\n'.join(map(str, var))+'\n')
def out(var) : sys.stdout.write(str(var)+'\n')
#from decimal import Decimal
from fractions import Fraction
#sys.setrecursionlimit(100000)
INF = float('inf')
mod = int(1e9)+7



x=int(data())
ans=8-(x-399)//200
if (x-399)%200==0:
    ans+=1
out(ans)



Measured memory_bytes: 72804
#![allow(non_snake_case, unused)]
use std::cmp::*;
use std::collections::*;
use std::f64::consts::*;

macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input!{
        i: [i32; 3],
        k: u32,
    }
    println!(
        "{}",
        i.iter().sum::<i32>() + i.iter().max().unwrap() * ((2i32.pow(k)) - 1)
    );
}


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

namespace prac
{
    class Program
    {
        static void Main(string[] args)
        {
            var arr = ReadLib.ReadAsIntArray();
            var n = arr[0];
            var k = arr[1];

            long score = (long)(k * Math.Pow(k - 1, n - 1));

            Console.WriteLine(score);
        }
    }
}


static class ReadLib
{
    public static long ReadAsLong()
    {
        return long.Parse(Console.ReadLine());
    }

    public static int ReadAsInt()
    {
        return int.Parse(Console.ReadLine());
    }

    public static int[] ReadAsIntArray()
    {
        return Console.ReadLine().Split(' ').Select(s => int.Parse(s)).ToArray();
    }

}


Measured memory_bytes: 13396