akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
#include <map>
#include <cstdio>

using namespace std;

typedef pair<int, int> P;

int n, p, q;
char s, t, b;
double dp[16][3][3];
map<char, P> mpp;
int xdir[4] = {0, 1, 0, -1}, ydir[4] = {1, 0, -1, 0};

void init()
{
  for(int i = 0; i < 3; ++i)
    for(int j = 0; j < 3; ++j)
      mpp[(char)('A'+3*i+j)] = P(i, j);

  return ;
}

void solve()
{
  for(;n; --n)
    for(int i = 0; i < 3; ++i)
      for(int j = 0; j < 3; ++j)
	for(int k = 0; k < 4; ++k){
	  int dy = i+ydir[k], dx = j+xdir[k];
	  if(!(0 <= dx && dx <= 2 && 0 <= dy && dy <= 2) 
	     || (dy == p && dx == q)){ dy = i; dx = j;}
	  dp[n-1][dy][dx] += dp[n][i][j]/4.0;
	}
  
  return ;
}

int main()
{
  init();
  while(cin>>n && n){
    cin >> s >> t >> b;
    fill(&dp[0][0][0], &dp[16][0][0], 0.0);
    p = mpp[s].first; q = mpp[s].second;
    dp[n][p][q] = 1.0;
    p = mpp[b].first; q = mpp[b].second;
    solve();
    p = mpp[t].first; q = mpp[t].second;

    printf("%.8lf\n", dp[0][p][q]);
  }

  return 0;
}

Measured memory_bytes: 0
// Author : Mohamed Sameh
#include <bits/stdc++.h>
#define pb push_back
#define f first
#define s second
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define SZ(a) (int)a.size()
#define Flush fflush(stdout);
typedef long long ll ;
using namespace std ;
int main()
{
    int l;
    scanf("%d" , &l ); 
   printf ("%.9f\n" , pow(l*1.0/3 , 3));
  
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define sf scanf
#define pf printf
#define pb push_back
#define llu unsigned long long
#define U unsigned int
#define SIZE 100005
#define pie 3.14159265358979323
#define minuss 1e-6
#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define BIG 100000000
#define N 10000
int main()
{
    ll k,n;
    cin>>k>>n;
    ll str[n+4];
    for(int i=0; i<n; i++)
        cin>>str[i];


    ll sum=0;
    for(int i=0;i<n-1;i++)
    {
       sum=max(sum,str[i+1]-str[i]);
    }
    sum=max(sum,str[0]+(k-str[n-1]));
    cout<<k-sum<<endl;
}


Measured memory_bytes: 1792
#include<stdio.h>

int rc[1000][1000];

int main(void)
{

  int r,c;
  int i,j;

  scanf("%d %d",&r,&c);

  for(i = 0; i < r; i++)
    {
      for(j = 0; j < c; j++)
	{
	  scanf("%d",&rc[i][j]);
	}
    }

  for(i = 0; i < r; i++)
    {
      for(j = 0; j < c; j++)
	{
	  rc[i][c] += rc[i][j];
	  rc[r][j] += rc[i][j];
	  rc[r][c] += rc[i][j];
	}
    }

  for(i = 0; i <= r; i++)
    {
      for(j = 0; j <= c; j++)
	{
	  printf("%d",rc[i][j]);
	  j == c ? putchar('\n'):putchar(' ');
	}
    }

	  return 0;
}


Measured memory_bytes: 3088
#include <stdio.h>

#define abs(x, y) ((x) > (y) ? (x) - (y) : (y) - (x))

int main(){
  long long int n, i, best;
  double h, w, bmi,diff, min;
  while(scanf("%lld", &n) && n){
    best = 10000000;
    min = 10000;
    while(n--){
      scanf("%lld%lf%lf", &i, &h, &w);
      h /= 100.0;
      diff = abs(w / (h * h), 22);
      if(min > diff || min == diff && best > i){
	best = i; min = diff;
      }
    }
    printf("%lld\n", best);
  }
  return 0;
}

Measured memory_bytes: 628
#include <bits/stdc++.h>
using namespace std;
long long a,b;
char c;
int main(){
ios_base::sync_with_stdio(0);
cin.tie(0);cout.tie(0);
cin>>a>>c>>b;
if(c=='+')cout<<a+b;
else cout<<a-b;

return 0;}



Measured memory_bytes: 3580
#pragma GCC optimize(2)
#pragma GCC optimize(3)
#pragma GCC optimize("Ofast")
#pragma GCC optimize("inline")
#pragma GCC optimize("-fgcse")
#pragma GCC optimize("-fgcse-lm")
#pragma GCC optimize("-fipa-sra")
#pragma GCC optimize("-ftree-pre")
#pragma GCC optimize("-ftree-vrp")
#pragma GCC optimize("-fpeephole2")
#pragma GCC optimize("-ffast-math")
#pragma GCC optimize("-fsched-spec")
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize("-falign-jumps")
#pragma GCC optimize("-falign-loops")
#pragma GCC optimize("-falign-labels")
#pragma GCC optimize("-fdevirtualize")
#pragma GCC optimize("-fcaller-saves")
#pragma GCC optimize("-fcrossjumping")
#pragma GCC optimize("-fthread-jumps")
#pragma GCC optimize("-funroll-loops")
#pragma GCC optimize("-fwhole-program")
#pragma GCC optimize("-freorder-blocks")
#pragma GCC optimize("-fschedule-insns")
#pragma GCC optimize("inline-functions")
#pragma GCC optimize("-ftree-tail-merge")
#pragma GCC optimize("-fschedule-insns2")
#pragma GCC optimize("-fstrict-aliasing")
#pragma GCC optimize("-fstrict-overflow")
#pragma GCC optimize("-falign-functions")
#pragma GCC optimize("-fcse-skip-blocks")
#pragma GCC optimize("-fcse-follow-jumps")
#pragma GCC optimize("-fsched-interblock")
#pragma GCC optimize("-fpartial-inlining")
#pragma GCC optimize("no-stack-protector")
#pragma GCC optimize("-freorder-functions")
#pragma GCC optimize("-findirect-inlining")
#pragma GCC optimize("-fhoist-adjacent-loads")
#pragma GCC optimize("-frerun-cse-after-loop")
#pragma GCC optimize("inline-small-functions")
#pragma GCC optimize("-finline-small-functions")
#pragma GCC optimize("-ftree-switch-conversion")
#pragma GCC optimize("-foptimize-sibling-calls")
#pragma GCC optimize("-fexpensive-optimizations")
#pragma GCC optimize("-funsafe-loop-optimizations")
#pragma GCC optimize("inline-functions-called-once")
#pragma GCC optimize("-fdelete-null-pointer-checks")
#include <bits/stdc++.h>
using namespace std;
inline int read()
{
   int s=0,w=1;
   char ch=getchar();
   while(ch<'0'||ch>'9'){if(ch=='-')w=-1;ch=getchar();}
   while(ch>='0'&&ch<='9') s=s*10+ch-'0',ch=getchar();
   return s*w;
}
inline void write(int x)
{
    if(x<0)
	{
    	putchar('-');
		x=-x;
	}
    if(x>9)
		write(x/10);
    putchar(x%10+'0');
}
int min2(int a,int b)
{
	if(a<b) return a;
	return b;
}
int min3(int a,int b,int c)
{
	return min2(a,min2(b,c));
}
int main()
{
	ios::sync_with_stdio(false);
	string s="Impossible";
	int a,b,c,l=0;
	a=read();
	b=read();
	c=a+b;
	if(min3(a%3,b%3,c%3)==0) s="Possible";
	while(l<s.size())
	{
		putchar(s[l]);
		l++;
	}
	puts("");
	return 0;
}


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

using ll=long long;
#define int ll

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

int read(){
	int i;
	scanf("%lld",&i);
	return i;
}

signed main(){
	int g1[]={1,3,5,7,8,10,12},g2[]={4,6,9,11,0,0,0},g3[]={2,0,0,0,0,0,0};
	int x=read(),y=read();
	int gx,gy;
	for(int i=0;i<7;i++){
		if(x==g1[i]){
			gx=1;
			break;
		}
		else if(x==g2[i]){
			gx=2;
			break;
		}
		else if(x==g3[i]){
			gx=3;
			break;
		}
	}
	for(int i=0;i<7;i++){
		if(y==g1[i]){
			gy=1;
			break;
		}
		else if(y==g2[i]){
			gy=2;
			break;
		}
		else if(y==g3[i]){
			gy=3;
			break;
		}
	}
	if(gx==gy) cout<<"Yes";
	else cout << "No";
	
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define rep(i, n) FOR(i, 0, n)
#define whole(x) (x).begin(),(x).end()
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
using P = pair<int, int>;
#define debug(var) cerr << "[" << #var << "] " << var << endl
#define chmin(x, y) x = min(x, y)
const ll mod = 1000000007;
const int dx[] = {-1,0,1,0};
const int dy[] = {0,-1,0,1};
const int INF = 1001001001;


int main(){
    int n, a, b, c;
    cin >> n >> a >> b >> c;
    vector<int> z(4);
    z[1] = a; z[2] = b; z[3] = c;
    vector<int> l(n);
    rep(i, n) cin >> l[i];
    int ans = INF;
    rep(i, 1<<(2*n)) {
        vector<int> v(n);
        rep(j, n) {
            v[j] = (i>>(2*j))&3;
        }
        vector<int> x[4];
        rep(j, n) {
            x[v[j]].push_back(l[j]);
        }
        bool ok = true;
        for (int j=1; j<=3; j++) {
            if (x[j].size()==0) ok = false;
        }
        if (!ok) continue;
        int mp = 0;
        for (int j=1; j<=3; j++) {
            int res = 10*(x[j].size()-1);
            int sum = 0;
            for (int y: x[j]) sum += y;
            res += abs(sum-z[j]);
            mp += res;
        }
        ans = min(ans, mp);
    }
    
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <sstream>

#include <string>
#include <vector>
#include <map>
#include <set>
#include <list>
#include <deque>
#include <queue>
#include <stack>

#include <algorithm>
#include <utility>
#include <numeric>
#include <functional>

#include <chrono>
#include <random>

using namespace std;
using i64 = int_fast64_t;
using ui64 = uint_fast64_t;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<i64>;
using vvl = vector<vl>;
using vd = vector<double>;
using vvd = vector<vd>;
using vb = vector<bool>;
using vvb = vector<vb>;
using pii = pair<int, int>;
using pll = pair<i64, i64>;

//////////////////////////////////////////////////

int main(){
    int n;
    cin >> n;
    vector<pair<i64, i64>> a(n);
    for(auto&& x:a)cin >> x.second >> x.first;
    sort(a.begin(), a.end());
    for(int i=0;i<n-1;i++){
      a[i+1].second += a[i].second;
    }
    bool f = true;
    for(auto&& x:a){
      if(x.first < x.second)f = false;
    }
    cout << (f ? "Yes" : "No") << endl;
    return 0;
}


Measured memory_bytes: 3328
#include <bits/stdc++.h>
//#define inf 0x3f3f3f3f3f3f3f3f
#define inf 0x3f3f3f3f
#define debug(...) fprintf(stderr, __VA_ARGS__)
#define inv(x) Power(x, mod - 2)
#define fi first
#define se second
#define MP make_pair
#define PB push_back

using namespace std;
typedef pair<int,int> Pair;
typedef long double ld;
typedef long long ll;

const int mod = 998244353, MAX = 1e5, N = 200005;
//template{{{
const long double Pi = 3.14159265358979323846l;
inline int add(int x, int y) { x += y; return x >= mod ? x - mod : x; };
inline void inc(int &x, int y) { x += y; x -= (x >= mod ? mod : 0); }
inline int mul(int x, int y) { return 1ll * x * y % mod; }
inline int Power(int x, int y) {
	int ans = 1;
	while (y) {
		if (y & 1) ans = mul(ans, x);
		x = mul(x, x), y >>= 1;
	} return ans;
}

/*char buf[1<<23],obuf[1<<23],*p1=buf,*p2=buf, *O = obuf;
#define getchar() (p1==p2&&(p2=(p1=buf)+fread(buf,1,1<<21,stdin),p1==p2)?EOF:*p1++)
void print(int x) {
    if(x > 9) print(x / 10);
    *O++=x%10+'0';
} */

template <class T> inline T	input() {
	T x; char ch; bool flag = false;
	while (!isdigit(ch = getchar())) flag |= ch == '-';
	for (x = ch ^ 48; isdigit(ch = getchar()); x = x * 10 + (ch ^ 48));
	return flag ? -x : x;
}

template <class T> inline bool chkmin(T &x, T y) { x = x < y ? x : y; return x == y; }
template <class T> inline bool chkmax(T &x, T y) { x = x > y ? x : y; return x == y; }
template <class T> inline T gcd(T x, T y) { return !y ? x : gcd(y, x % y); }
template <class T> inline T sqrm(T x) { return (ll) x * x % mod; }
template <class T> inline T sqr(T x) { return x * x; }

struct {
	inline operator int () { return input<int>(); }
	inline operator long long () { return input<long long>(); }
	template <class T> inline void operator () (T &x) { x = *this; }
	template<class T, class ...A> inline void operator () (T &x, A &...a)
	{ x = *this; this -> operator ()(a...); }
} read; //}}}

int n, m;
int a[N], b[N];
vector<int> G[N];
int pre[N];

int main() {
#ifdef local
	freopen("in", "r", stdin);
	freopen("out", "w", stdout);
	freopen("log", "w", stderr);
#endif

	read(n, m);
	for (int i = 1; i <= m; ++i) {
		int x = read, y = read;
		G[x].push_back(y);
		G[y].push_back(x);
	}

	pre[1] = 0x3f3f3f3f;
	queue<int> que;
	que.push(1);

	while (!que.empty()) {
		int u = que.front(); que.pop();
		for (int v : G[u]) {
			if (!pre[v]) {
				pre[v] = u;
				que.push(v);
			}
		}
	}

	for (int i = 1; i <= n; ++i)
		if (!pre[i]) {
			puts("No");
			return 0;
		}

	puts("Yes");
	for (int i = 2; i <= n; ++i)
		printf("%d\n", pre[i]);
	return 0;
}


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

const int N = 233;
const int INF = 1e9;

struct Edge {
    int to, rev, cap;
};

int nv, sv, tv;
vector<Edge> g[N];
int dist[N], ptr[N];

void add_edge(int a, int b, int c) {
    g[a].push_back(Edge{b, int(g[b].size()), c});
    g[b].push_back(Edge{a, int(g[a].size()) - 1, 0});
    assert(max(a, b) < nv);
}

bool augment() {
    fill_n(dist, nv, -1);
    dist[sv] = 0;

    vector<int> que;
    que.push_back(sv);
    for (int i = 0; i < int(que.size()); i++) {
        int v = que[i];
        for (auto e: g[v]) {
            if (dist[e.to] != -1 || e.cap == 0) {
                continue;
            }
            dist[e.to] = dist[v] + 1;
            if (e.to == tv) {
                return true;
            }
            que.push_back(e.to);
        }
    }

    return false;
}

int dfs(int v, int r) {
    if (v == tv) {
        return r;
    }
    for (int& i = ptr[v]; i < int(g[v].size()); i++) {
        auto& e = g[v][i];
        if (dist[e.to] <= dist[v] || e.cap == 0) {
            continue;
        }
        int d = dfs(e.to, min(r, e.cap));
        if (d == 0) {
            continue;
        }
        e.cap -= d;
        g[e.to][e.rev].cap += d;
        return d;
    }
    return 0;
}

int exec() {
    int res = 0;
    while (augment()) {
        fill_n(ptr, nv, 0);
        while (true) {
            int d = dfs(sv, INF);
            if (d == 0) {
                break;
            }
            res += d;
        }
    }
    return res;
}

const int M = int(1e7 + 10);

int n;
bool isp[M];

void precalc() {
    fill(isp + 2, isp + M, true);
    for (int i = 2; i * i < M; i++) {
        if (!isp[i]) {
            continue;
        }
        for (int j = i * i; j < M; j += i) {
            isp[j] = false;
        }
    }
}

int main() {
    precalc();

    scanf("%d", &n);

    set<int> a;
    auto add = [&](int x) {
        auto it = a.find(x);
        if (it != a.end()) {
            a.erase(it);
        } else {
            a.insert(x);
        }
    };

    for (int i = 0; i < n; i++) {
        int x;
        scanf("%d", &x);
        add(x);
        add(x + 1);
    }

    vector<vector<int>> v(2);
    for (int x: a) {
        v[x % 2].push_back(x);
    }
    int v0s = v[0].size(), v1s = v[1].size();

    sv = 0;
    tv = 1;
    nv = v0s + v1s + 2;
    for (int i = 0; i < v0s; i++) {
        add_edge(sv, 2 + i, 1);
    }
    for (int i = 0; i < v1s; i++) {
        add_edge(2 + v0s + i, tv, 1);
    }
    for (int i = 0; i < v0s; i++) {
        for (int j = 0; j < v1s; j++) {
            int d = abs(v[0][i] - v[1][j]);
            if (d > 2 && isp[d]) {
                add_edge(2 + i, 2 + v0s + j, 1);
            }
        }
    }

    int used = exec();
    int ans = used;
    ans += 2 * ((v0s - used) / 2);
    ans += 2 * ((v1s - used) / 2);
    if ((v0s - used) % 2 == 1) {
        ans += 3;
    }

    printf("%d\n", ans);
}


Measured memory_bytes: 10240
#include <iostream>
#include <vector>
#include <utility>
#include<algorithm>
using namespace std;
#define MAX 100000


int solve(int N, unsigned long long K, int a[],int b[])
{

	vector<pair<int, int>> ab;
	for (int i = 0; i < N; ++i)
	{
		pair<int, int> temp;
		temp.first = a[i];
		temp.second = b[i];
		ab.push_back(temp);
	}
	sort(ab.begin(), ab.end());
	int  ans = (ab.end() - 1)->first;
	unsigned long long sum = 0;
	for (auto itr = ab.begin(); itr != ab.end(); ++itr)
	{
		
		sum += itr->second;
		if (sum >= K)
		{
			ans = itr->first;
			break;
		}
	}



	return ans;
}

int main(int argc, char* argv[]) {

	int N;
	unsigned long long K;
	cin >> N >> K;
	static int a[MAX], b[MAX];
	for (int i = 0; i < N; ++i) {
		cin >> a[i] >> b[i];
	}
	cout<<solve(N, K, a, b);

	return 0;
}


Measured memory_bytes: 2168
//package AtCoder.Panasonic2020;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;

public class Main {

    static int maxlen;

    static void func(StringBuilder ps, int len) {
        if (len == maxlen) {
            out.println(ps.toString());
            return;
        }
        int maxpos = -1;
        for (int i=0;i<ps.length();i++) {
            maxpos = Integer.max(maxpos, (ps.charAt(i)-'a'));
        }
        StringBuilder nps = new StringBuilder(ps);
        maxpos++;
        for (int i=0;i<=maxpos;i++) {
            if (nps.length() < len+1 ) {
                nps.append((char)('a'+i));
            } else {
                nps.setCharAt(len, (char) ('a' + i));
            }
            func(nps, len+1);
        }
    }

    public static void main(String[] args) {
        int len = in.NI();
        maxlen = len;
        StringBuilder ps = new StringBuilder();
        func(ps, 0);
        out.close();
    }


    static InputStream inputStream = System.in;
    static OutputStream outputStream = System.out;
    static InputReader in = new InputReader(inputStream);
    static PrintWriter out = new PrintWriter(outputStream);

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

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

        public int NI() {
            return Integer.parseInt(next());
        }

        public long NL() {
            return Long.parseLong(next());
        }

    }
}

Measured memory_bytes: 36448
#include<bits/stdc++.h>
using namespace std;
int main(){
  
  int N;cin>>N;
  vector<int>A(N);for(int i=0;i<N;i++)cin>>A[i];
  long ans=1;
  long odd=1;
  for(int i=0;i<N;i++){
    ans*=3;odd*=(2-A[i]%2);
  }
  cout<<ans-odd;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define itn int
#define REP(i, n) for (ll i = 0; i < n; i++)
#define IREP(i, n) for (ll i = n - 1; i >= 0; i--)
#define FOR(i,a, b) for (ll i = a; i < b + 1; i++)
#define all(v) v.begin(), v.end()
#define SENTINEL 2000000000
#define NIL -1
using namespace std;
typedef long long ll;

const ll INF = 1LL << 60;
const ll 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;}


int main()
{
    int n;
    cin >> n;
    vector<int> a(n,0);
    REP(i,n-1){
        int b;
        cin >> b;
        b--;
        a[b]++;
    }
    REP(i,n){
        cout << a[i] << endl;
    }
}


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

#define int long long
#define ll long long
#define pb push_back
#define mp make_pair
#define f(i,a,n) for(int i=a ; i<(int)n ; i++)
#define rf(i,n,a) for(int i=n ; i>=a ; i--)
#define F first
#define S second
#define all(c) (c).begin(),(c).end()
#define sz(v) (int)(v).size()
#define fill(a,v) memset(a,v,sizeof(a))
#define d1(a) cout << a << "\n"
#define d2(a,b) cout << a << " " << b << "\n"
#define d3(a,b,c) cout << a << " " << b << " " << c << "\n"
#define d4(a,b,c,d) cout << a << " " << b << " " << c << " " << d << "\n"
#define fast ios:: sync_with_stdio(false),cin.tie(nullptr);

typedef long double ld;
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef pair<pii,int> ppi;
typedef vector<pii> vpi;

const int inf = 1e9;
const int inf64 = 1e18;
const int MOD = inf + 7;

int32_t main(){
	fast;
	ld a,b,c;
	cin >> a >> b >> c;
	int ok = 1;
	ld x = c - a - b;
	
	if(x < 0.0) ok = 0;
	
	x = x*x;

	ld y = 4*a*b;
	
	if(x <= y)  ok = 0;
	
	cout << (ok ? "Yes" : "No");
}


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

int main(){
    int N;
    cin >> N;
    int a[N];
    for(int i=0;i<N;i++) cin >> a[i];
    int ans[N];
    vector<vector<int>> s(N,vector<int>());
    for(int i=1;i<=N;i++){
        for(int j=i;j<=N;j+=i){
            s[j-1].push_back(i-1);
        }
    }
    for(int i=N;i>=1;i--){
        ans[i-1] = a[i-1];
        for(int j : s[i-1]){
            if(ans[i-1]) a[j]^=1;
        }
    }


    int cnt = 0;
    for(int i=0;i<N;i++){
        cnt += ans[i];
    }
    cout << cnt << endl;
    if(cnt > 0){
        for(int i=0;i<N;i++){
            if(ans[i]) cout << i+1 << ' ';
        }
        cout << endl;
    }
}


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

#define rep(i, n) for(int i = 0; i<(n); i++)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;
typedef long long ll;

int main() {
    int N;
    cin >> N;
    vector<int> p(N);
    rep(i, N) cin >> p[i], p[i]--;

    vector<int> c;

    int i = 0;
    int cnt = 0;
    while (i < N) {
        if (p[i] == i) {
            cnt++;
        } else {
            if (cnt > 0) {
                c.push_back(cnt);
                cnt = 0;
            }
        }
        i++;
    }
    if (cnt) c.push_back(cnt);

    int ans = 0;
    rep(i, c.size()) ans += (c[i] + 1) / 2;
    cout << ans << endl;
}

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

const int N = 110;

char str[N];
int cut1,cut2,n;

int main()
{
    cin>>n;
    for(int i=1;i<=n;i++)
        cin>>str[i];
    for(int i=1;i<=n;i++)
    {
        if(str[i]=='(') cut1++;
        if(str[i]==')')
        {
            cut1--;
            if(cut1<0) cut2++,cut1 = 0;
        }
    }
    for(int i=1;i<=cut2;i++)
        cout<<"(";
    for(int i=1;i<=n;i++)
        cout<<str[i];
    for(int i=1;i<=cut1;i++)
        cout<<")";
    cout<<"\n";
}

Measured memory_bytes: 256
#![allow(unused_imports)]

use text_io::*;
use proconio::*;
use std::collections::*;
use std::process::exit;
use std::cmp::*;
use itertools::Itertools;

fn main() {
    input! {
    a:isize,
    b:isize,
    c:isize,
    }
    println!("{}",(a-b)%c)
}

Measured memory_bytes: 2136
#include <bits/stdc++.h>
#define all(x) begin(x), end(x)
#define dbg(x) cerr << #x << " = " << x << endl
#define _ << ' ' <<
using namespace std;
using ll = long long;
using vi = vector<int>;

int a[100001];

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    for (int i = 0; i < n; ++i)
    {
        int x;
        cin >> x;
        a[x]++;
    }
    int sol = 0, d = 0;
    for (int i = 1; i <= 100000; ++i)
    {
        if (!a[i]) continue;
        if (a[i] % 2) sol += (a[i] - 1) / 2;
        else sol += (a[i] - 2) / 2, d++;
    }
    if (d % 2)
        sol += (d - 1) / 2 + 1;
    else
        sol += (d - 2) / 2 + 1;
    cout << n - sol * 2;
}


Measured memory_bytes: 640
N = int(input())
result_list = [''] * N
for i in range(N):
    result_list[i] = input()
print('AC x {}'.format(result_list.count('AC')))
print('WA x {}'.format(result_list.count('WA')))
print('TLE x {}'.format(result_list.count('TLE')))
print('RE x {}'.format(result_list.count('RE')))

Measured memory_bytes: 16180
using System;
class Program{
	static void Main(){
		int[] b=new int[100001];
		int[] h=new int[100001];
		for(int i=2;i<100001;i++){
			b[i]=1;
			for(int j=2;j<=i/2;j++){
				if(i%j==0){b[i]=0;break;}
			}
			h[i]=(b[i]&b[(i+1)/2])+h[i-1];
		}
		int n=int.Parse(Console.ReadLine());
		for(int i=0;i<n;i++){
			int[] q=Array.ConvertAll(Console.ReadLine().Split(),int.Parse);
			Console.WriteLine("{0}",h[q[1]]-h[q[0]-1]);
		}
	}

}

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

using namespace std;

#define fastio cin.tie(NULL); cout.tie(NULL); ios_base::sync_with_stdio(0)
typedef long long ll;
//#define int ll
#define swap(x, y)((x)^=(y)^=(x)^=(y))
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vector<int>> matrix;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define all(c) c.begin(),c.end()
#define mp make_pair
#define pb push_back
#define f first
#define tcase int _; cin>> _; for( ; _; --_)
#define s second
#define endl '\n'
const int MAX = 1e6+1;
const int INF = 0x3f3f3f3f;
const double PI = acos(-1);
const double DEG = 180/PI;
const int MOD = 1e9+7;
int mod(int x, int m){ if(x >= 0) return x % m; if(-x < m) return m-(-x); return mod(x%m, m);}
int gcd (int a, int b) {while(b){a = mod(a, b); swap(a, b);} return a;}
int lcm (int a, int b) {return a / gcd(a, b) * b;}
int fexp(int base, int exp, int m){
	int total = 1;
	while(exp > 0){
		if(exp % 2 == 1){
			total = mod(((mod(total, m)) * (mod(base, m))), m);
			exp--;
		}
		base= mod((mod(base, m) * mod(base, m)), m);
		exp /= 2;
	}
	return mod(total, m);
}

int n;

void solve(){
    int m;
    cin>> n>> m;
    vi a(n);
    int tot = 0;
    for(int &i: a){
        cin>> i;
        tot += i;
    }
    int flag = 0;
    for(int i: a) if(i * 4 * m >= tot) flag++;
    cout<< (flag >=m ? "Yes\n": "No\n");
}

int32_t main(){
	fastio;
	solve();
	return 0;
}



Measured memory_bytes: 3656
#include <bits/stdc++.h>
#define Int int64_t

using namespace std;

int c2i(char c) {
	if (c == 'R') { return 0; }
	if (c == 'G') { return 1; }
	return 2;
}

int main() {
	const Int MOD = 998244353;
	Int N;
	cin >> N;
	string s;
	cin >> s;

	// 0:R, 1:G, 2:B, 3:**(R), 4:**(G), 5:**(B)
	vector<Int> dp(6, 0);
	Int ans = 1;
	for (int i = 0; i < s.size(); ++i) {
		int idx = c2i(s[i]);
		if (dp[idx + 3] > 0) {
			(ans *= dp[idx + 3]) %= MOD;
			--dp[idx + 3];
			continue;
		}
		for (int j = 0; j < 3; ++j) {
			if (idx < 0 ||j == idx || dp[j] <= 0) { continue; }
			(ans *= dp[j]) %= MOD;
			--dp[j];
			++dp[6 - (idx + j)];
			idx = -1;
		}
		if (idx >= 0) { ++dp[idx]; }
	}
	while (N > 0) {
		(ans *= N--) %= MOD;
	}
	cout << ans % MOD << endl;

	return 0;
}


Measured memory_bytes: 900
n = int(input())
b = list(map(int, input().split()))

a = list();
a.append(b[0])
for i in range(n - 2):
    if b[i] <= b[i + 1]:
        a.append(b[i])
    else: 
        a.append(b[i + 1])

a.append(b[n - 2])
print(sum(a))

Measured memory_bytes: 3060
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <cassert>
#include <string.h>
//#include <unordered_set>
//#include <unordered_map>
//#include <bits/stdc++.h>

#define MP(A,B) make_pair(A,B)
#define PB(A) push_back(A)
#define SIZE(A) ((int)A.size())
#define LEN(A) ((int)A.length())
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define fi first
#define se second

using namespace std;

template<typename T>inline bool upmin(T &x,T y) { return y<x?x=y,1:0; }
template<typename T>inline bool upmax(T &x,T y) { return x<y?x=y,1:0; }

typedef long long ll;
typedef unsigned long long ull;
typedef long double lod;
typedef pair<int,int> PR;
typedef vector<int> VI;

const lod eps=1e-11;
const lod pi=acos(-1);
const int oo=1<<30;
const ll loo=1ll<<62;
const int mods=998244353;
const int MAXN=600005;
const int INF=0x3f3f3f3f;//1061109567
/*--------------------------------------------------------------------*/
inline int read()
{
	int f=1,x=0; char c=getchar();
	while (c<'0'||c>'9') { if (c=='-') f=-1; c=getchar(); }
	while (c>='0'&&c<='9') { x=(x<<3)+(x<<1)+(c^48); c=getchar(); }
	return x*f;
}
char st[MAXN];
vector<int> e[MAXN];
int f[MAXN],s[MAXN],sz[MAXN];

void tree_dp(int x,int father)
{
	for (auto v:e[x]) 
		if (v!=father) tree_dp(v,x);

	sz[x]=st[x]-'0',f[x]=s[x]=0;
	int id=0;
	for (auto v:e[x])
		if (v!=father) 
		{
			s[v]+=sz[v],s[x]+=s[v],sz[x]+=sz[v];
			if (s[v]>s[id]) id=v;
		}
	if (s[id]<=s[x]-s[id]) f[x]=s[x]/2;
	else f[x]=s[x]-s[id]+min(f[id],(s[id]*2-s[x])/2);
}
int main()
{
	int n=read(),ans=INF;
	scanf("%s",st+1);
	for (int i=1;i<n;i++)
	{
		int u=read(),v=read();
		e[u].PB(v),e[v].PB(u);
	}
	for (int i=1;i<=n;i++)
	{
		tree_dp(i,0);
		if (f[i]*2==s[i]) upmin(ans,f[i]);
	}
	if (ans==INF) puts("-1");
	else printf("%d\n",ans);
	return 0;
}


Measured memory_bytes: 19584
#!/usr/bin/perl

while (<>) {
    chomp;
    @s = split //, $_;
    last;
}

foreach $i (1 .. 2 ** $#s) {
    $bi = unpack("b10",  pack("Q", $i));
    @bi = split //, $bi;
    $n = $s[0];
    foreach $i (0 .. $#s - 1) {
        if ($bi[$i] == 1) {
            $total += $n;
            $n = $s[$i + 1];
        } else {
            $n = "$n$s[$i + 1]";
        }
        if ($i == $#s - 1) {
            $total += $n;
        }
    }
}

if ($total eq '') {
    print "$s[0]\n";
} else {
    print "$total\n";
}


Measured memory_bytes: 640
/*===================*\
|ID : harryPotter_421  |
|      LANG: C++       |
\*====================*/
#include <iostream>
#include<bits/stdc++.h>
#define lli long long int
#define ld long double
#define pb push_back
#define f(j,m,n) for(lli j=m;j<n;j++)
#define harry ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using namespace std;

int main()
   {harry
    lli n,w;
    cin>>n>>w;
    lli arr[n+1][2];//first refer weight second refer value
    for(int i=1;i<=n;i++)
        cin>>arr[i][1]>>arr[i][2];
    lli dp[n+1][w+1];
    memset(dp,0,sizeof(dp));

    lli maxi=0;
    for(lli i=1;i<=n;i++)
        {for(lli j=1;j<=w;j++)
           {dp[i][j]=dp[i-1][j];
            if(j-arr[i][1]>=0)
             dp[i][j]=max(dp[i][j],dp[i-1][j-arr[i][1]]+arr[i][2]);
            maxi=max(maxi,dp[i][j]);
            //cout<<dp[i][j]<<" ";
           }
          //cout<<endl;
        }
      cout<<maxi;



   }

















Measured memory_bytes: 79232
//***********************
//*** writer : Alan Hu **
//***********************
#include<iostream>
#include<vector>
#include<string>
#include<set>
#include<map>
#include<algorithm>
#include<queue>
#include<list>
#include<stack>
#include<cstdio>
#include<fstream>
#include<numeric>
#include<functional>
#include<utility>
#include<memory>
#include<cstring>
#include<cmath>
using namespace std;
     
#define CLEAN(a,b) memset(a,b,sizeof(a))
#define mp make_pair
#define pb push_back
#define sz(a) a.size()
#define rept(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
     
typedef long long ll;
typedef pair<int, int> pii;

int w;
string s;

int main()
{
	cin>>s>>w;
	for (int i=0;i<s.size();i+=w)
	{
		cout<<s[i];
	}
    return 0;
}

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

using namespace std;

#define ll long long
#define mod 1e9 + 7
#define endl '\n'

void solve(){
    ll n;
    cin>>n;
    ll ans = 1e12;
    for(ll i = 1;i*i<=n;i++){
        if(n % i == 0){
            ans = min(ans,i+n/i-2);
        }
    }
    cout<<ans;
}

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int t = 1;
    while(t--)
        solve();
    return 0;
}



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

constexpr int inf = 1e9;
constexpr ll linf = 1e18;

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

    int n; cin >> n;
    vector<int> cnt(100001, 0);
    for (int i = 0; i < n; i++) {
        int a; cin >> a;
        cnt[a]++;
    }

    int ans = 0;
    for (int i = 0; i <= 99998; i++) {
        ans = max(ans, cnt[i] + cnt[i + 1] + cnt[i + 2]);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 640
import java.util.*;

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

    long c = b*10;
    for (long j=c;j<c+10;j++){
      double gg = j*0.08;
      String t = gg+"";
      String p = a+"";
      boolean found = false;
      for (int l = 0; l<p.length();l++){
        if (t.charAt(l) == p.charAt(l)){
          found = true;
        }
        else{
          found = false;
          break;
        }
      }
      if (found == true){
        System.out.println(j);
        return;
      }
    }
    System.out.println(-1);
  }
}


Measured memory_bytes: 39112
#include <iostream>

using namespace std;


int main(){
  int a,b;
  cin >> a >> b;
  
  if(a >= 13){
    cout << b << endl;
  }else if(a >= 6){
    cout << b/2 << endl;
  }else{
    cout << 0 << endl;
  }
  return 0;
}

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

using namespace std;

#define int long long
#define ll long long
typedef pair<int, int> P;
#define mod 998244353
#define INF (1LL<<60)

#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define YES puts("YES\n")
#define Yes puts("Yes\n")
#define NO  puts("NO\n")
#define No  puts("No\n")
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }



signed main() {

	int N, x;
	cin >> N >> x;
	vector<int> a(N);
	rep(i, N) cin >> a[i];

	int ans = 0;
	rep(i, N) {
		if (i == 0) {
			if (a[i] > x) {
				ans += a[i] - x;
				a[i] = x;
			}
			continue;
		}


		if (a[i - 1] + a[i] > x) {
			ans += a[i - 1] + a[i] - x;
			a[i] = x - a[i - 1];
		}
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 1024
N, M = gets.split.map(&:to_i)
list = Array.new(N + 1) { -1 }

M.times do
  p, s = gets.split
  p = p.to_i

  if s == 'WA'
    list[p] -= 1 if list[p] < 0
  else
    list[p] *= -1 if list[p] < 0
  end
end

list.select! {|l| l > 0 }.map! {|e| e - 1 }

puts "#{list.count {|l| l}} #{list.inject(0, :+)}"

Measured memory_bytes: 2556
import sys
input = sys.stdin.readline
N, L = map(int, input().split())
a = list(map(int, input().split()))
res = []
for i in range(N - 1):
  if a[i] + a[i + 1] >= L:
    res.append(i)
    break
else:
  print("Impossible")
  exit(0)
for i in range(res[0] - 1, -1, -1): res.append(i)
for i in range(res[0] + 1, N - 1): res.append(i)
res.reverse()
print("Possible")
for r in res: print(r + 1)

Measured memory_bytes: 91940
direcs = [[0, -1], [1, 0], [0, 1], [-1, 0]]
dnames = %w(U R D L)

### main

pl = []
horizontal = true
ln = 0

while (line =gets)
  nums = line.chop.split("").map{|s| s.to_i}

  if (horizontal)
    if pl[ln].nil?
      pl.push (nums.length + 1).times.map{[0, 0, 0, 0]}
    end

    for i in (0...nums.length)
      pl[ln][i][1] = pl[ln][i + 1][3] = nums[i]
    end
  else
    pl.push nums.length.times.map{[0, 0, 0, 0]}

    for i in (0...nums.length)
      pl[ln][i][2] = pl[ln + 1][i][0] = nums[i]
    end

    ln += 1
  end

  horizontal = ! horizontal
end

x = y = 0
dir = 1
rt = ""

while true
  dir = (dir + 3) % 4
  while pl[y][x][dir] == 0
    dir = (dir + 1) % 4
  end

  rt += dnames[dir]
  x += direcs[dir][0]
  y += direcs[dir][1]

  if x == 0 && y == 0
    break
  end
end

puts rt

Measured memory_bytes: 6132
#include<stdio.h>
int main(void){
  int i;
  char a[5];
  scanf("%s",a);
  for(i=0;i<3;i++){
    if(a[i]==a[i+1]){
      printf("Bad\n");
      return(0);
    }
  }
  printf("Good\n");
  return(0);
}


Measured memory_bytes: 128
import java.util.Scanner;

public class Main {
  public static void main(String[] args) {
    Scanner scanner = new Scanner(System.in);
    int N = scanner.nextInt();
    int[] p = new int[N];
    for (int i = 0; i < N; i++) p[i] = scanner.nextInt();

    int total = 0;
    for (int i = 0; i < N; i++) {
      if (p[i] == i + 1) total++;
    }
    for (int i = 1; i < N; i++) {
      if (p[i] == i + 1 && p[i - 1] == i) {
        total--;
        i++;
      }
    }
    System.out.println(total);
  }
}


Measured memory_bytes: 50820
#include <iostream>

using namespace std;
#define int long long

int N, C;
int x[100100], v[100100];
int le[100100], ri[100100];
int maxle[100100], maxri[100100];

signed main() {
    cin >> N >> C;
    for (int i = 0; i < N; ++i) {
        cin >> x[i] >> v[i];
    }
    int ans = 0;
    le[0] = v[0] - x[0];
    ans = max(ans, le[0]);
    maxle[0] = ans;
    for (int i = 1; i < N; ++i) {
        le[i] = le[i - 1] + v[i] - (x[i] - x[i - 1]);
        ans = max(ans, le[i]);
        maxle[i] = max(maxle[i - 1], le[i]);
    }
    ri[N - 1] = v[N - 1] - (C - x[N - 1]);
    ans = max(ans, ri[N - 1]);
    maxri[N - 1] = max(0ll, ri[N - 1]);
    for (int i = N - 2; i >= 0; --i) {
        ri[i] = ri[i + 1] + v[i] - (x[i + 1] - x[i]);
        ans = max(ans, ri[i]);
        maxri[i] = max(maxri[i + 1], ri[i]);
    }

    for (int i = 0; i < N; ++i) {
        ans = max(ans, le[i] + maxri[i + 1] - x[i]);
    }
    for (int i = N - 1; i >= 0; --i) {
        ans = max(ans, ri[i] + maxle[i - 1] - (C - x[i]));
    }
    cout << ans << endl;
}

Measured memory_bytes: 4992
#include <iostream>
#include <vector>
#include <utility>
#include <string>
#include <cmath>
#include <algorithm>
#include <string>
#include <iomanip>

using namespace std;
using ll = long long;
using ull = unsigned long long;


#define rep(i,a,b) for(ll i=a;i<b;i++)
#define rrep(i,a,b) for(ll i=a-1;i>=b;i--)

auto sumdig(ll num) {
	ll dig, sum;
	sum = 0;
	while (num) {
		dig = num % 10;
		sum = sum + dig;
		num = num / 10;
	}
	return sum;
}




int main() {
	ll x;
	vector<pair<ll, ll>> pattern;
	pattern.reserve(10000000);
	cin >> x;


	rep(i, -120, 120) {
		rep(j, -120, 120) {
			pattern.push_back(make_pair(i, j)); 
		}
	}
	int ans;
	rep(i, 0, pattern.size()) {
		if ((pow(pattern[i].first, 5) - pow(pattern[i].second, 5)) == x) {
			cout << pattern[i].first  << " " << pattern[i].second << endl;
			return 0;
		}
	}

	return 0;
}


Measured memory_bytes: 4524
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

public class Main {
    public static final String YES = "Yes";
    public static final String NO = "No";

    public static String process(TestCase testCase) {
        final String S = testCase.S;
        final String T = testCase.T;

        Map<Character, Integer> sCharFreq = countCharFrequencies(S);
        Map<Character, Integer> tCharFreq = countCharFrequencies(T);

        Map<Integer, Integer> sFreqMap = toFreqMap(sCharFreq);
        Map<Integer, Integer> tFreqMap = toFreqMap(tCharFreq);

        return sFreqMap.equals(tFreqMap) ? YES : NO;
    }

    private static Map<Character, Integer> countCharFrequencies(String str) {
        Map<Character, Integer> map = new HashMap<>();
        str.chars().mapToObj(i -> (char) i).forEach(c -> {
            if (map.containsKey(c)) {
                map.put(c, map.get(c) + 1);
            } else {
                map.put(c, 1);
            }
        });
        return map;
    }

    private static Map<Integer, Integer> toFreqMap(Map<Character, Integer> charFreq) {
        Map<Integer, Integer> map = new HashMap<>();
        charFreq.values().forEach(c -> {
            if (map.containsKey(c)) {
                map.put(c, map.get(c) + 1);
            } else {
                map.put(c, 1);
            }
        });
        return map;
    }

    // Util func

    public static void main(String[] args) {
        TestCase testCase = readFromInput();

        final String result = process(testCase);

        output(result);
    }

    private static TestCase readFromInput() {
        Scanner sc = new Scanner(System.in);

        String S = sc.next();
        String T = sc.next();

        return new TestCase(S, T);
    }

    private static void output(String result) {
        System.out.println(result);
    }

    public static class TestCase {
        final String S;
        final String T;

        public TestCase(String S, String T) {
            this.S = S;
            this.T = T;
        }
    }
}


Measured memory_bytes: 37372
n = gets.chomp.to_i
a = gets.chomp.split.map(&:to_i)

s = [0]
for i in 0..(n-1)
    s[i+1] = a[i] + s[i]
end

h = Hash.new(0)

s.each do |v|
    h[v] += 1
end

ans = 0
h.each do |k, v|
    next if v == 1
    ans += v * (v-1) / 2
end
puts ans

Measured memory_bytes: 32588
#include<iostream>
#include<cmath>
#include<string>
#include<iomanip>
#include<algorithm>
#include<vector> 
#include <functional>
#define fx(x) fixed<<setprecision(x)
#define ll long long
using namespace std;
void fast() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
}
int main() {
	fast();
	int n,c;
	cin >> n;
	c = pow(n, 1) + pow(n, 2) + pow(n, 3);
	cout << c;
	return 0;
}

Measured memory_bytes: 4008
import java.io.*;
import java.util.*;

public class Main {
  private static int solve(int n, int[] as) {
    boolean[] visited = new boolean[n];
    int index = 0;
    int count = 0;
    while (true) {
      visited[index] = true;
      count++;
      index = as[index] - 1;
      if (visited[index]) {
        return -1;
      }
      if (index == 1) {
        return count;
      }
    }
  }
  
  private static void execute(ContestReader reader, PrintWriter out) {
    int n = reader.nextInt();
    int[] as = reader.nextInt(n);
    out.println(solve(n, as));
  }
  
  public static void main(String[] args) {
    ContestReader reader = new ContestReader(System.in);
    PrintWriter out = new PrintWriter(System.out);
    execute(reader, out);
    out.flush();
  }
}

class ContestReader {
  private BufferedReader reader;
  private StringTokenizer tokenizer;
  
  ContestReader(InputStream in) {
    reader = new BufferedReader(new InputStreamReader(in));
  }
  
  public String next() {
    while (tokenizer == null || !tokenizer.hasMoreTokens()) {
      try {
        tokenizer = new java.util.StringTokenizer(reader.readLine());
      } catch (Exception e) {
        throw new RuntimeException(e);
      }
    }
    return tokenizer.nextToken();
  }
  
  public int nextInt() {
    return Integer.parseInt(next());
  }
  
  public long nextLong() {
    return Long.parseLong(next());
  }
  
  public double nextDouble() {
    return Double.parseDouble(next());
  }
  
  public String[] next(int n) {
    String[] array = new String[n];
    for (int i = 0; i < n; i++) {
      array[i] = next();
    }
    return array;
  }
  
  public int[] nextInt(int n) {
    int[] array = new int[n];
    for (int i = 0; i < n; i++) {
      array[i] = nextInt();
    }
    return array;
  }
  
  public long[] nextLong(int n) {
    long[] array = new long[n];
    for (int i = 0; i < n; i++) {
      array[i] = nextLong();
    }
    return array;
  }
  
  public double[] nextDouble(int n) {
    double[] array = new double[n];
    for (int i = 0; i < n; i++) {
      array[i] = nextDouble();
    }
    return array;
  }
  
  public char[] nextCharArray() {
    return next().toCharArray();
  }
  
  public int[][] nextInt(int n, int m) {
    int[][] matrix = new int[n][m];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        matrix[i][j] = nextInt();
      }
    }
    return matrix;
  }
  
  public long[][] nextLong(int n, int m) {
    long[][] matrix = new long[n][m];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        matrix[i][j] = nextLong();
      }
    }
    return matrix;
  }
  
  public double[][] nextDouble(int n, int m) {
    double[][] matrix = new double[n][m];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        matrix[i][j] = nextDouble();
      }
    }
    return matrix;
  }
  
  public char[][] nextCharArray(int n) {
    char[][] matrix = new char[n][];
    for (int i = 0; i < n; i++) {
      matrix[i] = next().toCharArray();
    }
    return matrix;
  }
}


Measured memory_bytes: 36856
#include <stdio.h>
#include<cstdio>
#include<iostream>
#include<string>
#include<algorithm>
#include<complex>
#include<vector>
#include <climits>

using namespace std;


int main(void)
{
    int N,i,top,index,sum;
    sum=0;
    top=INT_MIN;

    scanf("%d",&N);
    vector<int> p(20,0); 

    
    for(i=0;i<N;i++)
    {
        scanf("%d",&p[i]);

        if(p[i]>top){
            top=p[i];
            index=i;
        }
    }

    p[index]=top/2;

    for(i=0;i<N;i++)
    {
        sum+=p[i];
    }


    printf("%d",sum);

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <map>
 
using namespace std;
long long sum,a,N,ans;
 
int main()
{
map<long long,long long>ms;//用于标记部分和出现的次数
ms[0]++;//注意这里0要提前加1
long long i;
sum=0;
ans=0;
scanf("%lld",&N);
for(i=0;i<N;i++){
scanf("%lld",&a);
sum=sum+a;
ans=ans+ms[sum];//如果这个和，在之前出现过，那么说明有存在和为0的子序列（不然怎么重复出现呢）
ms[sum]++;
}
printf("%lld\n",ans);
return 0;
}

Measured memory_bytes: 12800
#[allow(dead_code)]
fn getline() -> String {
    let mut res = String::new();
    std::io::stdin().read_line(&mut res).ok();
    res
}

#[allow(unused_macros)]
macro_rules! readl {
    ($t: ty) => {
        {
            let s = getline();
            s.trim().parse::<$t>().unwrap()
        }
    };
    ($( $t: ty),+ ) => {
        {
            let s = getline();
            let mut iter = s.trim().split(' ');
            ($(iter.next().unwrap().parse::<$t>().unwrap(),)*)
        }
    };
}

#[allow(unused_macros)]
macro_rules! readlvec {
    ($t: ty) => {
        {
            let s = getline();
            let iter = s.trim().split(' ');
            iter.map(|x| x.parse().unwrap()).collect::<Vec<$t>>()
        }
    }
}

#[allow(unused_macros)]
macro_rules! debug { ($x: expr) => { println!("{}: {:?}", stringify!($x), $x) } }
// macro_rules! debug { ($x: expr) => () }

#[allow(dead_code)]
fn show<T>(iter: T) -> String
where
    T: Iterator,
    T::Item: std::fmt::Display
{
    let mut res = iter.fold(String::new(), |sum, e| sum + &format!("{} ", e));
    res.pop();
    res
}

#[allow(unused_imports)]
use std::cmp::{max, min};
#[allow(unused_imports)]
use std::collections::{BTreeMap, BTreeSet, BinaryHeap, HashMap, HashSet, VecDeque};
#[allow(unused_imports)]
use std::collections::btree_map::Entry::{Occupied, Vacant};

fn naive(n: usize, a: Vec<i32>) -> usize {
    let mut ans = 0;
    for l in 0..n {
        let mut sum = 0;
        let mut xor = 0;
        for r in l..n {
            sum += a[r];
            xor ^= a[r];
            if sum == xor {
                ans += 1;
            }
        }
    }
    ans
}

fn main() {
    use std::io::Write;
    let out = std::io::stdout();
    let mut out = std::io::BufWriter::new(out.lock());
    macro_rules! printf { ($($arg:tt)*) => (write!(out, $($arg)*).unwrap()); }
    macro_rules! printfln { () => (writeln!(out).unwrap()); ($($arg:tt)*) => (writeln!(out, $($arg)*).unwrap()); }
    
    let n = readl!(usize);
    let a = readlvec!(i32);
    let mut l = 0;
    let mut r = 0;
    let mut sum = 0;
    let mut xor = 0;
    let mut ans = 0;
    while l < n {
        while r < n && sum+a[r] == xor^a[r] {
            sum += a[r];
            xor ^= a[r];
            r += 1;
        }
        // debug!((l, r));
        ans += r-l;
        
        if l == r {
            l += 1;
            r += 1;
            sum = 0;
            xor = 0;
        } else {
            sum -= a[l];
            xor ^= a[l];
            l += 1;
        }
    }
    printfln!("{}", ans);

}


Measured memory_bytes: 8444
N, K, Q = map(int, input().split())
A = list(int(input()) for i in range(Q))
B = [K-Q]*N 
for i in range(Q):
    B[A[i]-1] += 1

for j in range(N):
    if B[j]>=1:
        print('Yes')
    else:
        print('No')

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

int main(){
    string n;cin>>n;
    for(int i=0;i<3;i++){
        if(n[i]=='1')n[i]='9';
        else if(n[i]=='9')n[i]='1';
    }
    cout<<n<<endl;
    return 0;
}

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

using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
using WGraph = vector<vector<pair<int, ll>>>;

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

constexpr int dx[4] = {-1, 0, 0, 1}, dy[4] = {0, -1, 1, 0};
constexpr int INF = 1e9;
constexpr int MOD = 1e9 + 7;
constexpr long long LINF = 1e18;
constexpr double EPS = 1e-10;
constexpr double PI = M_PI;

long long gcd(long long a, long long b) {
    if (a < b) std::swap(a, b);
    if (b == 0) return a;

    while (b > 0) {
        long long tmp = b;
        b = a%b;
        a = tmp;
    }
    return a;
}

void solve() {
    int T;
    cin >> T;
    vector<bool> res(T);
    for (int i=0; i<T; ++i) {
        ll a, b, c, d;
        cin >> a >> b >> c >> d;
        if (a < b) {
            res[i] = false;
            continue;
        }
        if (d < b) {
            res[i] = false;
            continue;
        }
        if (c >= b) {
            res[i] = true;
            continue;
        }
        ll g = gcd(b, d);
        if (b - g + a%g > c) res[i] = false;
        else res[i] = true;
    }
    for (int i=0; i<T; ++i) cout << (res[i] ? "Yes" : "No") << '\n';
}

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

    solve();

    return 0;
}


Measured memory_bytes: 256