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

using namespace std;

using Weight=int;
using DArray=vector<Weight>;
using DMatrix=vector<DArray>;

static const Weight INF=1<<29;

struct Edge {
    size_t src, dst;
    Weight weight;
    Edge() {}
    Edge(size_t src, size_t dst, Weight weight=1):
        src(src), dst(dst), weight(weight)
    {}
};

bool operator<(const Edge &e, const Edge &f) {
    if (e.weight != f.weight) {
        return e.weight > f.weight;
    } else {
        return e.src!=f.src? e.src<f.src : e.dst<f.dst;
    }
}

using Edges=vector<Edge>;
using Vertex=vector<Edge>;
using Graph=vector<Vertex>;

void join(Graph &g, size_t s, size_t d, Weight w=1) {
    // non-directed
    g[s].push_back(Edge(s, d, w));
    g[d].push_back(Edge(d, s, w));
}

void connect(Graph &g, size_t s, size_t d, Weight w=1) {
    // directed
    g[s].push_back(Edge(s, d, w));
}

size_t get_root(const Graph &g) {
    // stores the node type
    size_t V=g.size();
    vector<Weight> indeg(V);
    for (size_t i=0; i<V; ++i)
        for (const Edge &e: g[i])
            indeg[e.dst] += e.weight;

    for (size_t i=0; i<V; ++i)
        if (!indeg[i])
            return i;

    return 0;
}

template <class Functor>
void walk_postorder(const Graph &g, size_t root, Functor F) {
    if (root >= g.size()-1) return;

    for (const Edge &e: g[root])
        walk_postorder(g, e.dst, F);

    F(root);
}

void reconstruct_tree(
    vector<size_t>::iterator first1, vector<size_t>::iterator last1,
    vector<size_t>::iterator first2, vector<size_t>::iterator last2,
    Graph &g
) {
    vector<size_t>::iterator root=find(first2, last2, *first1);
    if (root <= first2) {
        connect(g, *root, g.size()-1);
    } else {
        connect(g, *root, first1[1]);
        reconstruct_tree(first1+1, first1+(root-first2)+1, first2, root, g);
    }

    if (last1-first1 <= root-first2+1) {
        connect(g, *root, g.size()-1);
    } else {
        connect(g, *root, first1[(root-first2)+1]);
        reconstruct_tree(first1+(root-first2)+1, last1, root+1, last2, g);
    }
}

int main() {
    size_t n;
    scanf("%zu", &n);

    vector<size_t> preorder(n);
    for (size_t i=0; i<n; ++i) {
        scanf("%zu", &preorder[i]);
        --preorder[i];
    }

    vector<size_t> inorder(n);
    for (size_t i=0; i<n; ++i){
        scanf("%zu", &inorder[i]);
        --inorder[i];
    }

    Graph g(n+1);
    reconstruct_tree(
        preorder.begin(), preorder.end(), inorder.begin(), inorder.end(), g
    );

    size_t r=get_root(g);

    vector<size_t> postorder;
    auto postpush=[=, &postorder](size_t v)->void {
        if (v < n)
            postorder.push_back(v+1);
    };

    walk_postorder(g, r, postpush);
    for (size_t i=0; i<n; ++i)
        printf("%zu%c", postorder[i], i<n-1? ' ':'\n');

    return 0;
}

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

using namespace std;

#define MAXN 100005
#define INF 0x3f3f3f3f
#define MOD 10007
#define pb push_back

typedef long long ll;
typedef pair <int, int> pii;
typedef vector <int> vi;

int a[MAXN], b[MAXN], c[MAXN];
int dp[MAXN][3];

void solve(int n){
	if(n <= 0) return;

	if(dp[n][0] != -1) return;

	solve(n - 1);

	dp[n][0] = max(dp[n - 1][1], dp[n - 1][2]) + a[n];
	dp[n][1] = max(dp[n - 1][0], dp[n - 1][2]) + b[n];
	dp[n][2] = max(dp[n - 1][0], dp[n - 1][1]) + c[n];
}

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

	int n;
	cin >> n;

	for(int i = 1; i <= n; i++) cin >> a[i] >> b[i] >> c[i];

	memset(dp, -1, sizeof(dp));

	dp[1][0] = a[1], dp[1][1] = b[1], dp[1][2] = c[1];

	solve(n);

	cout << max(dp[n][0], max(dp[n][1], dp[n][2])) << endl;

	return 0;
}

Measured memory_bytes: 5760
#include<stdio.h>
int main(void){
int a,b;
	scanf("%d%d" ,&a,&b);
	if(a>b||a<b){
		if(a>b){
			printf("a > b\n");
		}
		else if(a<b){
			printf("a < b\n");
		}
	}
	else if(a==b){
	printf("a == b\n");
	}
	
	return 0;
}

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

int main() {
	char *weekday[7] = { "Thursday", "Friday", "Saturday", "Sunday", "Monday", "Tuesday", "Wednesday" };
	int monthdays[12] = { 0, 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30 };

	int m, d;
	while (cin >> m >> d, m) {
		int w = d-1;
		for (int i = 1; i < m; i++)
			w += monthdays[i];
		cout << weekday[w%7] << endl;
	}
	
	return 0;
}

Measured memory_bytes: 0
a=input()
A = int(a[0])

for flag in range(2**3):
	op=[]
	temp_a=A
	for i in range(3):
		if (flag>>i)&1==1:
			op.append("+")
			temp_a+=int(a[i+1])
		else:
			op.append("-")
			temp_a-=int(a[i+1])
	if temp_a==7:
		print("{}{}{}{}{}{}{}=7".format(a[0],op[0],a[1],op[1],a[2],op[2],a[3]))
		exit()


Measured memory_bytes: 9120
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;;


int main()
{
    int N, M;
    vector < long long > x,y,z;
    cin >> N >> M;
    for(int i = 0; i < N; ++i)
    {
        long long X,Y,Z;
        cin >> X >> Y >> Z;
        x.push_back(X);
        y.push_back(Y);
        z.push_back(Z);
    }
    long long ans = 0;
    for(int i = -1; i<=1; i+=2)
        for(int j=-1; j<=1; j+=2)
            for(int k=-1; k<=1; k+=2)
            {
                vector < long long > c;
                for(int w = 0; w < N; ++w)
                   c.push_back( i * x[w] + j * y[w] + k * z[w]);
                sort(c.begin(), c.end());
 //cout << c.size() << endl;
                long long curans = 0;
                for(int w = 0; w < M; ++w)
                    curans += c[N-1-w];
                ans = max(curans, ans);
            }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define r(i,n) for(int i=0;i<n;i++)
using namespace std;

int w,h,n,A[11][11],ans,cnt;
bitset<100> B[11][11],p;

void dfs(int d,bitset<100> s,int sco){
  if(d==n){
    ans=min(ans,sco);
    return;
  }
  cnt++;
  if(cnt>=19000000)return;
  if(ans<=sco)return;
  if(!A[d/w][d%w])dfs(d+1,s,sco);
  else{
    int y=d/w;
    int x=d%w;
    if((B[y][x]&s).any()){
      p&=0;
      p.set(y*10+x);//(y*100+x);
      if(!(s&p).any())dfs(d+1,s,sco);
      dfs(d+1,(B[y][x]|s)^B[y][x],sco+1);
    }
    else dfs(d+1,s,sco);
  }
}

int main(){
  while(cin>>w>>h,w){
    memset(A,0,sizeof(A));
    r(i,11)r(j,11)B[i][j]&=0;
    n=h*w;
    bitset<100> b;
    r(i,h)r(j,w)cin>>A[i][j];
    r(i,h)r(j,w)if(A[i][j]){
      int sum=1;
      for(;;sum++){
        int f=0;
        for(int y=i;y<i+sum;y++){
          for(int x=j;x<j+sum;x++){
            if(A[y][x]==0)f++;
          }
        }
        if(f){
          sum--;
          break;
        }
      }
      bitset<100>tmp;
      for(int y=i,k=0;k<sum;k++,y++){
        for(int x=j,l=0;l<sum;l++,x++){
          tmp.set(y*10+x);
        }
      }
      b.set(i*10+j);
      B[i][j]=tmp;
    }
    ans=100;
    cnt=0;
    dfs(0,b,0);
    cout<<ans<<endl;
  }
}


Measured memory_bytes: 3076
#include <iostream>
#include <cstdio>
using namespace std;
int a,b;
int main()
{
	scanf("%d%d",&a,&b);
	if(a<=0&&b>=0) printf("Zero");
	else 
	{
		if(a>0) printf("Positive");
		else if((b-a+1)%2==0) printf("Positive");
		else printf("Negative");	
	}
	return 0;
}

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

using namespace std;

#define LOG(...) fprintf(stderr,__VA_ARGS__)
//#define LOG(...)
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort(ALL(c))
#define RSORT(c) sort(RALL(c))
#define SZ(a) ((int)(a).size())
#define BIT(x, i) (((x) >> (i)) & 1)

typedef long long ll;
typedef unsigned long long ull;
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vb> vvb;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

int main() {
    int n, usagi, neko, cards;
    cin >> n >> usagi >> neko >> cards;
    map<int, pii> usagi_p;
    map<int, pii> neko_p;
    REP(i, n) REP(j, n) {
        int c;
        cin >> c;
        usagi_p[c] = {i, j};
    }
    REP(i, n) REP(j, n) {
        int c;
        cin >> c;
        neko_p[c] = {i, j};
    }
    int sum = (n+1) * (n/2);
    if (n % 2 == 1) {
        sum += (n+1) / 2;
    }
    vi usagi_v(n, sum);
    vi usagi_h(n, sum);
    vi usagi_s(2, sum);
    vi neko_v(n, sum);
    vi neko_h(n, sum);
    vi neko_s(2, sum);
    bool finished = false;
    REP(i, cards) {
        int card;
        cin >> card;
        if (finished) continue;

        if (EXIST(usagi_p, card)) {
            pii p = usagi_p[card];
            int x = p.first, y = p.second;
            usagi_v[x] -= y+1;
            usagi_h[y] -= x+1;
            if (x == y) usagi_s[0] -= x+1;
            if (y == n-1-x) usagi_s[1] -= y+1;
        }
        if (EXIST(neko_p, card)) {
            pii p = neko_p[card];
            int x = p.first, y = p.second;
            neko_v[x] -= y+1;
            neko_h[y] -= x+1;
            if (x == y) neko_s[0] -= x+1;
            if (y == n-1-x) neko_s[1] -= y+1;
        }

        int usagi_bingo = 0, neko_bingo = 0;
        REP(i, n) {
            if (usagi_v[i] == 0) usagi_bingo++;
            if (usagi_h[i] == 0) usagi_bingo++;
            if (neko_v[i] == 0) neko_bingo++;
            if (neko_h[i] == 0) neko_bingo++;
        }
        if (usagi_s[0] == 0) usagi_bingo++;
        if (usagi_s[1] == 0) usagi_bingo++;
        if (neko_s[0] == 0) neko_bingo++;
        if (neko_s[1] == 0) neko_bingo++;
        if (n == 1) {
            usagi_bingo = min(1, usagi_bingo);
            neko_bingo = min(1, neko_bingo);
        }
        bool usagi_won = usagi_bingo >= usagi;
        bool neko_won = neko_bingo >= neko;
        if (usagi_won && neko_won) {
            cout << "DRAW" << endl;
            finished = true;
        } else if (usagi_won) {
            cout << "USAGI" << endl;
            finished = true;
        } else if (neko_won) {
            cout << "NEKO" << endl;
            finished = true;
        }
    }
    if (!finished) {
        cout << "DRAW" << endl;
    }
}

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

using namespace std;

int a[4] = {};
int main() {
	int sa = 0;
	int x = 0;
	int ans = 0;
	for (int i = 0; i < 5; i++)
	{
		cin >> a[i];
	}

	for (int i = 0; i < 5; i++)
	{
		if (a[i] % 10 != 0) {
			sa += 10 - (a[i] % 10);
		}
	}

	for (int i = 0; i < 5; i++)
	{
		ans += a[i];
	}
	
	ans += sa;
	
	for (int i = 0; i < 5; i++)
	{
		if (a[i] % 10 != 0) {
			x = max(x, 10 - ((a[i] % 10)));
		}
	}
	
	cout << ans - x << endl;

}


Measured memory_bytes: 256
#include <math.h>
#include <regex>
#include "bits/stdc++.h"
#define FOR(i, s, e) for (int i = int(s); i < int(e); ++i)
#define REP(i, e) FOR(i, 0, e)
#define INF (INT_MAX / 2)
#define EPS (1.0e-8)
#define LINF (LLONG_MAX / 2)
const int MGN = 10;
const int ARY_SZ_MAX = 10000000;
using namespace std;
using ll = long long;
using ull = unsigned long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vb = vector<bool>;
using vvb = vector<vb>;
using vvvb = vector<vvb>;
using vl = vector<ll>;
using vvl = vector<vl>;
using vd = vector<double>;
using vs = vector<string>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using psi = pair<string, int>;


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

  ll N; cin >> N;

  ll ans = LINF;
  for(ll i = 1; i*i<=N; i++) {
    if (N%i == 0) {
      ans = min(ans, i-1+N/i-1);
    }
  }

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 384
import bisect,collections,copy,itertools,math,string
import sys
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split())
def main():
    n, m = LI()
    cnt = [None] + [1 for _ in range(n)]
    exist = [False] + [False for _ in range(n)]
    exist[1] = True

    for _ in range(m):
        x, y = LI()

        cnt[y] += 1
        exist[y] |= exist[x]

        cnt[x] -= 1
        exist[x] &= cnt[x] != 0
    
    ans = sum(exist)
    print(ans)
main()


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

using namespace std;

const int MOD = 1000000007;

int main() {
    int H,W,K;
    cin>>H>>W>>K;
    char s[H][W];
    for(int i=0;i<H;i++){
        for(int j=0;j<W;j++){
            cin>>s[i][j];
        }
    }
    int now=0;
    int ans[H][W];
    for(int i=0;i<H;i++){
        for(int j=0;j<W;j++){
            ans[i][j]=0;
        }
    }
    for(int i=0;i<H;i++){
       int kount=0;
       for(int j=0;j<W;j++){
           if(s[i][j]=='#'){
           kount++;}
       }
       int tmpsum=0;
       if(kount>0){
           //if(s[i][0]!='#'){
           now++;//;}
           if(kount!=1){
           for(int j=0;j<W;j++){
               if(s[i][j]=='.'){
                    ans[i][j]=now;
               }else{
                   tmpsum++;
                   if(tmpsum!=1){
                    now++;}

                   ans[i][j]=now;

               }
           }}else{
               if(s[i][0]=='#'){
                   //now++;
               }
               for(int j=0;j<W;j++){
                   ans[i][j]=now;
               }

           }
       }
    }
    for(int i=0;i<H;i++){
        for(int j=0;j<W;j++){
            if(i==0){
                if(ans[i][j]==0){
                    ans[i][j]=ans[i+1][j];
                }
            }else{
                if(ans[i][j]==0){
                    ans[i][j]=ans[i-1][j];
                }
            }
        }
    }
    for(int i=H-1;i>=0;i--){
        for(int j=0;j<W;j++){
            if(i==H-1){
                if(ans[i][j]==0){
                    ans[i][j]=ans[i-1][j];
                }
            }else{
                if(ans[i][j]==0){
                    ans[i][j]=ans[i+1][j];
                }
            }
        }
    }

    for(int i=0;i<H;i++){
        for(int j=0;j<W;j++){
            cout<<ans[i][j];
            if(j!=W-1){
            cout<<" ";}else{
                cout<<""<<endl;
            }
        }

    }
}





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

int main()
{
    string s;
    cin.ignore(numeric_limits<streamsize>::max(), ' ');
    cin >> s;

    cout << 'A' << s.at(0) << 'C';
}


Measured memory_bytes: 256
h, w, k = [int(i) for i in input().split()]
h += 1
if w == 1:
    print(1)
    exit()
edge = [0 for i in range(w)]
edge[0] = 1
edge[1] = 2
for i in range(2, w):
    edge[i] = edge[i - 1] + edge[i - 2]
# print("edge:{}".format(edge))

dp = [[0 for j in range(w)] for i in range(h)]
dp[0][0] = 1
dp[0][1] = 0
for i in range(h - 1):
    for j in range(w):
        add = 1
        if 0 <= j - 1 < w:  # 小さい側
            add *= edge[j - 1]
            # print(add)
        if 0 <= w - j - 2 < w:  # 大きい側
            add *= edge[w - j - 2]
            # print(add)
        dp[i + 1][j] += dp[i][j] * add
        # print("h:{} j:{} j:{}".format(i, j, add))
        if j - 1 >= 0:
            add = 1
            if 0 <= j - 2 < w:
                add *= edge[j - 2]
            if 0 <= w - j - 2 < w:
                add *= edge[w - j - 2]
            dp[i + 1][j - 1] += dp[i][j] * add
            # print("h:{} j:{} j-1:{}".format(i, j, add))
        if j + 1 < w:
            add = 1
            if 0 <= j - 1 < w:
                add *= edge[j - 1]
            if 0 <= w - j - 3 < w:
                add *= edge[w - j - 3]
            dp[i + 1][j + 1] += dp[i][j] * add
            # print("h:{} j:{} j+1:{}".format(i, j, add))
        # for i in range(h):
        # print(dp[i])
print(dp[-1][k - 1] % 1000000007)


Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
using namespace std;

int main() {
	int N;
	vector<string> vs;
	cin >> N;
	bool flg = true;
	for (int i=0; i<N; i++) {
		string tmp;
		cin >> tmp;
		if (i>0&&vs[vs.size()-1][vs[vs.size()-1].size()-1]!=tmp[0]) {flg=false;}
		if (find(vs.begin(),vs.end(), tmp)!=vs.end()) {flg=false;}
		vs.push_back(tmp);
	}
	if (flg) cout << "Yes" << endl;
	else cout << "No" << endl; 
	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
int main(){
    int a, b, c;
    scanf ("%d%d%d",&a,&b,&c);
    if(a>b)a+=b,b=a-b,a-=b;
    if(b>c)b+=c,c=b-c,b-=c;
    if(a>b)a+=b,b=a-b,a-=b;
    printf("%d %d %d\n", a, b, c);
}

Measured memory_bytes: 1828
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ii = pair<int, int>;
using iii = pair<int, ii>;
#define vt vector
#define pq priority_queue
#define pb push_back
#define mp make_pair
#define fi first
#define se second
// #define multicase
const int MOD = 1e9 + 7;
const int INF = 2e9;
const int N = 1e4 + 5;

map<string, int> freq;

void solve() {
    int T = 1;
  #ifdef multicase
    cin >> T;
  #endif
    for(int tc = 1, q; tc <= T; tc++) {
        cin >> q;
        while(q--) {
            string s; cin >> s;
            freq[s]++;
        }
        cout << "AC x " << freq["AC"] << "\nWA x " << freq["WA"] << "\n";
        cout << "TLE x " << freq["TLE"] << "\nRE x " << freq["RE"] << "\n";
    }
}

int main() {
 
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    
    solve();
    
}

Measured memory_bytes: 3676
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int arra[6];
    cin>>arra[0]>>arra[1]>>arra[2]>>arra[3]>>arra[4];
    for(int i=0;i<=5;i++) {
        if(arra[i]==0) {
            cout<<i+1<<endl;
            break;
        }
    }

}


Measured memory_bytes: 3588
// https://atcoder.jp/contests/abc153/tasks/abc153_a

#include "algorithm"
#include "bitset"
#include "cmath"
#include "functional"
#include "iomanip"
#include "iostream"
#include "map"
#include "numeric"
#include "queue"
#include "set"
#include "string"
#include "vector"
#define rep(i, to) for (ll i = 0; i < (to); ++i)
#define rep1(i, to) for (ll i = 1; i <= (to); ++i)
#define repf(i, from, to) for (ll i = from; i < (to); ++i)
#define repr(i, from) for (ll i = from - 1; i >= 0; --i)
#define all(vec) vec.begin(), vec.end()
#define unless(cond) if (!(cond))
#define fi first
#define se second
using namespace std;
typedef long long ll;
typedef long double ld;
template <typename T>
using V = vector<T>;
using VL = V<ll>;
using VVL = V<VL>;
template <typename T, typename U>
using P = pair<T, U>;
using PL = P<ll, ll>;
using VPL = V<PL>;
template <typename T>
inline bool chmax(T& a, T b);
template <typename T>
inline bool chmin(T& a, T b);
void print_ints(vector<ll> v);
template <typename T>
void drop(T a);

const ll INF = 1e18;

void solve() {
  ll H, A;
  cin >> H >> A;

  ll ct = 0;
  while (H > 0) {
    H -= A;
    ct++;
  }

  cout << ct << endl;
}

struct exit_exception : public std::exception {
  const char* what() const throw() { return "Exited"; }
};

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

  try {
    solve();
  } catch (exit_exception& e) {
  }

  return 0;
}
#endif

template <typename T>
inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}

template <typename T>
inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}

void print_ints(vector<ll> v) {
  rep(i, v.size()) {
    if (i > 0) {
      cout << " ";
    }

    cout << v[i];
  }

  cout << endl;
}

template <typename T>
void drop(T res) {
  cout << res << endl;
  throw exit_exception();
}


Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <cmath>  
#include <cstdlib>
#include <ctime>
#include <algorithm>
#include <numeric>
#include <functional>
#include <string> 
#include <vector>
#include <bitset>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <deque>

using namespace std;
using ll = long long;

template<class T> using V = vector<T>;
template<class T, class U> using P = pair<T, U>;

#define REP(i,n) for(int i = 0; i < int(n); i++)
#define FOR(i, m, n) for(int i = int(m);i < int(n);i++)
#define ALL(obj) (obj).begin(),(obj).end()

const ll MOD = (ll)1e9 + 7;
const ll HINF = (ll)1e18;
const ll LINF = (ll)1e9;
const long double PI = 3.1415926535897932384626433;

vector<int> dy = { 0,0,1,-1 };
vector<int> dx = { 1,-1,0,0 };

template<class T> void corner(bool flg, T hoge) {
	if (flg) {
		cout << hoge << endl;
		exit(0);
	}
	else return;
}

template <class T, class U>ostream &operator<<(ostream &o, const map<T, U>&obj) {
	o << "{"; for (auto &x : obj) o << " {" << x.first << " : " << x.second << "}" << ","; o << " }"; return o;
}

template <class T>ostream &operator<<(ostream &o, const set<T>&obj) {
	o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr) o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;
}

template <class T>ostream &operator<<(ostream &o, const vector<T>&obj) {
	o << "{"; for (int i = 0; i < (int)obj.size(); ++i)o << (i > 0 ? ", " : "") << obj[i]; o << "}"; return o;
}

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

template <template <class tmp>  class T, class U> ostream &operator<<(ostream &o, const T<U> &obj) {
	o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr)o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;
}

void print(void) {
	cout << endl;
}

template <class Head> void print(Head&& head) {
	cout << head;
	print();
}

template <class Head, class... Tail> void print(Head&& head, Tail&&... tail) {
	cout << head << " ";
	print(forward<Tail>(tail)...);
}

void YN(bool flg) {
	cout << ((flg) ? "YES" : "NO") << endl;
}

void Yn(bool flg) {
	cout << ((flg) ? "Yes" : "No") << endl;
}

void yn(bool flg) {
	cout << ((flg) ? "yes" : "no") << endl;
}

int main() {
	int N; cin >> N;
	V<int> p(N+1,0); FOR(i,1,N+1) cin >> p[i];
	int cnt = 0;
	FOR(i,1,N){
		if(i == p[i]){
			swap(p[i], p[i + 1]);
			cnt++;
		}
	}
	if (N == p[N]) cnt++;
	cout << cnt << endl;
	

	return 0;
}



Measured memory_bytes: 640
w, a, b = map(int, input().split())
aw = a + w
bw = b + w
if a == b:
    print(0)
elif b < aw:
    if bw < a:
        print(a - bw)
    else:
        print(0)
elif a < bw:
    if aw < b:
        print(b - aw)
    else:
        print(0)


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

int main() {
    int n;
    cin >> n;
    string s;
    cin >> s;
    int ans = s.size();
    rep(i,n-1) {
        if (s[i] == s[i+1]) ans--;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3728
<?php
list($K) = ints();
$sum6 = 0;
for($i = 1; $i <= $K; ++$i)
for($j = 1; $j <= $K; ++$j)
$memo[$i][$j] = $memo[$j][$i] = (int)gmp_gcd($i, $j);

for($i = 1; $i <= $K; ++$i)
for($j = $i+1; $j <= $K; ++$j){
    $mij = $memo[$memo[$i][$j]];
    for($k = $j+1; $k <= $K; ++$k)
        $sum6+=$mij[$k];
}

for($i = 1; $i <= $K; ++$i){
  $mi = $memo[$i];
  for($j = $i+1; $j <= $K; ++$j)
    $sum6+=$mi[$j];
}

echo $sum6*6+$K*($K+1)/2;

function str(){return trim(fgets(STDIN));}
function ints(){return array_map('intval',explode(' ',trim(fgets(STDIN))));}
function int(){return intval(trim(fgets(STDIN)));}
function chmax(&$a,$b){if($a<$b){$a=$b;return 1;}return 0;}
function chmin(&$a,$b){if($a>$b){$a=$b;return 1;}return 0;}
function popcount($x){$c=0;while($x){$x&=$x-1;++$c;}return$c;}
function o(...$val){
    if(count($val)==1)$val=array_shift($val);
    echo debug_backtrace()[0]['line'].")";
    if(is_array($val)){
        if(count($val) == 0)echo "empty array";
        elseif(!is_array(current($val)))echo "array: ",implode(" ", addIndex($val)),"\n";
        else{
            echo "array:array\n";
            if(isCleanArray($val))foreach($val as $row)echo implode(" ", addIndex($row)),"\n";
            else foreach($val as $i => $row)echo "[".$i."] ".implode(" ", addIndex($row)),"\n";
        }
    }else echo $val."\n";
}
function addIndex($val){if(!isCleanArray($val)){$val = array_map(function($k, $v){return $k.":".$v;}, array_keys($val), $val);}return $val;}
function isCleanArray($array){$clean=true;$i = 0;foreach($array as $k=>$v){if($k != $i++)$clean = false;}return $clean;}
// 座圧対象の配列 -> [圧縮された配列,復元用のMap,圧縮用のMap]
function atsu($array){$a = array_flip($array);$fuku=array_flip($a);sort($fuku);$atsu = array_flip($fuku);foreach($array as $i=>$val)$array[$i]=$atsu[$val];return [$array, $fuku, $atsu];}
function gcdAll($array){$gcd=$array[0];for($i=1,$I=count($array);$i<$I;++$i){$gcd=gcd($gcd,$array[$i]);}return $gcd;}
function gcd($m, $n){if(!$n)return $m;return gcd($n, $m % $n);}
function lcmAll($array){$lcm=$array[0];for($i=1,$I=count($array);$i<$I;++$i){$lcm=lcm($lcm,$array[$i]);}return $lcm;}
function lcm($a, $b) {return $a / gcd($a, $b) * $b;}

function dfs($current, $from = -1, $d = 0){
  global $G, $distance;
  $distance[$current] = $d;
  foreach($G[$current] as $to){
    if($from != $to){
      dfs($to, $current, $d + 1);
    }
  }
}

function loadTree($N = false){
  if($N === false)$N = $GLOBALS['N'];
  return loadGraph($N, $N-1);
}
function loadGraph($N = false, $M = false, $both = true){
  if($N === false)$N = $GLOBALS['N'];
  if($M === false)$N = $GLOBALS['M'];
  $G = array_fill(1, $N, []);
  for($i = 0; $i < $M; $i++){
    $values = ints();
    if(count($values) == 2){
      list($a, $b) = $values;
      $G[$a][] = $b;
      if($both)$G[$b][] = $a;
    }else{
      list($a, $b, $d) = $values;
      $G[$a][] = [$b, $d];
      if($both)$G[$b][] = [$a, $d];
    }
  }
  return $G;
}


Measured memory_bytes: 18960
N, M = map(int, input().split())
ab = [list(map(int, input().split())) for _ in range(M)]

# グラフ組み立て
g = [["#" for _ in range(N)] for _ in range(N)]
for p in ab:
    g[p[0]-1][p[1]-1] = "-"
    g[p[1]-1][p[0]-1] = "-"

import itertools

# 頂点集合
n = [i for i in range(N)]

# 全ての組み合わせを調べる
ans = 0
for p in itertools.permutations(n, len(n)):
    flag = 1
    if p[0] != 0: # 頂点が合わない場合
        continue
    for i in range(N-1):
        if g[p[i]][p[i+1]] != "-":
            flag = 0
            break
    if flag:
        ans += 1
print(ans)
    

Measured memory_bytes: 3064
N=int(input())
T0,X0,Y0=0,0,0
for i in range(N):
  T,X,Y=map(int,input().split())
  tmp=T-T0
  if abs(X-X0)+abs(Y-Y0)>tmp:
    print('No')
    exit()
  else:
    Par=tmp%2
    if Par==1:
      if (abs(X-X0)+abs(Y-Y0))%2==0:
        print('No')
        exit()        
    else:
      if (abs(X-X0)+abs(Y-Y0))%2==1:
        print('No')
        exit()
  T0,X0,Y0=T,X,Y
print('Yes')

Measured memory_bytes: 9216
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<cmath>
#include<tuple>
#include<string>
typedef unsigned long long ll;
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define F first
#define S second
using namespace std;
const ll INF = 1e12;

int main() {
	int n;
	cin >> n;
	tuple<string, int, int> s[111];
	rep(i, 0, n) {
		string a;
		int b, c;
		cin >> a >> b;
		s[i] = make_tuple(a, -b, i);
	}
	sort(s, s + n);
	rep(i, 0, n)cout<<get<2>(s[i])+1 << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
const ll INF = 1LL << 60;

int main(){
    int n, r;
    cin >> n >> r;
    if(n>=10){
        cout << r << endl;
    }
    else{
        cout << r + 1000 - 100*n << endl;
    }
}

Measured memory_bytes: 3568
use proconio::input;

#[proconio::fastout]
pub fn main() {
    input! {
    s:String,
    t:String,
    }
    let s = s.as_bytes();
    let t = t.as_bytes();
    let ans = s
        .windows(t.len())
        .map(|ss| {
            let mut cnt = 0;
            for i in 0..ss.len() {
                if ss[i] != t[i] {
                    cnt += 1;
                }
            }
            cnt
        })
        .min().unwrap();
    println!("{:}", ans);
}


Measured memory_bytes: 2208
#include<bits/stdc++.h>
using namespace std;
 
int main(){
int N;
  cin>>N;
  vector<long long> L(N+1);
  L[0]=2;
  L[1]=1;
  for(int i=2; i<=N; i++){
   L[i]=L[i-1]+L[i-2];
  }
cout<<L[N]<<endl;  
}

Measured memory_bytes: 384
N = int(input())
S = str(input())
r = 0
g = 0
b = 0
#S[i],S[j],S[k]が違うものはr*g*b通り
for i in range(N):
  if S[i] == 'R':
    r += 1
  elif S[i] == 'G':
    g += 1
  else:
    b += 1
tot = r*g*b
#S[i],S[j],S[k]が違うかつj-i=k-jを満たすものは引く
minus = 0
for i in range(N-2):
  for j in range(i+1,N-1):
    if 2*j-i < N:
      
      if S[i] != S[j] and S[j] != S[2*j-i] and S[i] != S[2*j-i]:
        minus += 1
print(tot - minus)

Measured memory_bytes: 9160
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

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

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };
    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };
    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };
    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };
    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        n: usize,
        s: [String;n]
    }
    let mut s = s;
    s.sort();
    s.dedup();
    if s.len() == 3 {
        println!("Three");
    } else {
        println!("Four");
    }
}


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

#define N 101

void BreadthFirstSearch();

class queue{
public:
    int array[100];
    int head = -1;
    int tail = -1;
    
    void push(int v) {
        tail = (tail + 1) % N;
        array[tail] = v;
        return;
    }
    
    int pop() {
        head = (head + 1) % N;
        return array[head];
    }
    
    int show() {
        return array[head];
    }
    
    bool empty() {
        if(head == tail) return true;
        else return false;
    }
};

int n;
int d;
int a[N][N];
queue q;
int list[N];

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    cin>>n;
    int u, k, v;
    for(int i = 0; i < n; i++) {
        cin>>u>>k;
        
        int c = 0;
        for(int j = 0; j < k; j++) {
            cin>>v;
            a[u][c] = v;
            c++;
        }
    }
    
    for(int i = 1; i <= n; i++) list[i] = -1;
    
    q.push(1);
    list[1] = 0;
    while(!q.empty()) {
        d++;
        BreadthFirstSearch();
    }
    
    for(int i = 1; i <= n; i++) {
        cout<<i<<' '<<list[i]<<endl;
    }
    
    return 0;
}

void BreadthFirstSearch() {
    int u = q.pop();
    int i = 0;
    
    while(a[u][i] != 0) {
        if(list[ a[u][i] ] != -1) {
            i++;
            continue;
        }
        q.push(a[u][i]);
        list[ a[u][i] ] = list[u] + 1;
        i++;
    }
}



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

int main() {
  int N;
  cin >> N;
  vector<int> yen(N);
  vector<int> cost(N);
  for(int i=0; i<N; i++) cin >> yen.at(i);
  for(int i=0; i<N; i++) cin >> cost.at(i);
  
  int ans=0;
  for(int i=0; i<N;i++) {
    if(yen.at(i)-cost.at(i)>0) ans+=yen.at(i)-cost.at(i);
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int MOD = 1e9 + 7;
const long long INF = 1e15;

#include <math.h>
#define PI 3.14159265358979323846264338327950L

int mxN = 500000;
vector<int> cnt(mxN + 1);

int main() {
    int r, D, y;
    cin >> r >> D >> y;
    vector<int> x(11);
    x[0] = y;
    for (int i = 1; i < 11; i++) {
        x[i] = r * x[i - 1] - D;
        cout << x[i] << "\n";
    }

    return 0;
}

Measured memory_bytes: 4884
#include<iostream>
#include<string>
#include<set>
using namespace std;
int main(){
  string str;
  string command;
  set<string>st;
  int n;
  cin>>n;
  for(int i=0;i<n;i++){
    cin>>command;
    cin>>str;
    if(command=="insert"){
      st.insert(str);
    }else if(command=="find"){
      if(st.find(str)==st.end()){
	cout<<"no"<<endl;
      }else{
	cout<<"yes"<<endl;
      }
    }
  }
  return(0);
}

Measured memory_bytes: 32632
import sys
from itertools import accumulate

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007


def main():
    N, *L = map(int, read().split())

    L.sort()

    max_L = max(L)

    C = [0] * (max_L + 1)
    for l in L:
        C[l] += 1
    C = list(accumulate(C))

    ans = 0
    for i, a in enumerate(L):
        for j, b in enumerate(L[i + 1 :], i + 1):
            if a + b > max_L:
                ans += N - j - 1
            else:
                ans += C[a + b - 1] - j - 1

    print(ans)
    return


if __name__ == '__main__':
    main()


Measured memory_bytes: 74008
from itertools import product
n, m, x = list(map(int, input().split()))
cl = [0] * n
al = [[]*m for _ in range(n)]
for i in range(n):
    tmp = list(map(int, input().split()))
    cl[i] = tmp[0]
    al[i] = tmp[1:]


def dfs(status, book):
    for i in range(m):
        status[i] += book[i]
    return status


ans = 10**10
for bit in product([0, 1], repeat=n):
    # print(bit)
    status = [0]*m
    money = 0
    for i, b in enumerate(list(bit)):
        if b == 1:
            status = dfs(status, al[i])
            money += cl[i]
    flag = True
    for i in range(m):
        if status[i] >= x:
            continue
        else:
            flag = False
    if flag:
        ans = min(ans, money)
if ans == 10**10:
    print(-1)
    exit()
print(ans)


Measured memory_bytes: 74356
#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 - 1; 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 VSORTR(v) sort(v.rbegin(), v.rend());
#define ALL(v) (v).begin(),(v).end()
 
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<ll, ll>;

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

	ll n, c;
	cin >> n >> c;
	vvll d(c, vll(c)), a(n, vll(n));
	REP(i, c){
		REP(j, c) cin >> d[i][j];
	}

	// cnt : (i + j) % 3 = 0, 1, 2 に対しどの色でいくつ塗られているか.
	vvll cnt(c, vll(3));
	REP(i, n){
		REP(j, n){
			cin >> a[i][j];
			a[i][j]--;
			cnt[a[i][j]][(i + j) % 3]++;
		}
	}
	ll res = 1e18;
	// l : (i + j) % 3 = 0, 1, 2 に対しどの色に塗り替えるか.
	REP(l0, c){
		REP(l1, c){
			REP(l2, c){
				if(l0 == l1 || l1 == l2 || l2 == l0) continue;
				vll l = {l0, l1, l2};
				// tmp : 配色 l に対する目的関数値
				ll tmp = 0;
				// 全色に対し color -> l[mod] による色の変更コストを足す
				// mod に対応する座標の元の色が color でなければ cnt == 0 なのでコストは発生しない
				REP(color, c){
					REP(mod, 3){
						tmp += cnt[color][mod] * d[color][l[mod]];
					}
				}
				res = min(res, tmp);
			}
		}
	}
	cout << res << endl;
    return 0;
}

Measured memory_bytes: 2432
#include <bits/stdc++.h>
using namespace std;
#define N_PRIME 1000000007
#define ll int64_t


int main(void){
    
    while(true){
        int n;
        int max_v = INT_MIN;
        int min_v = INT_MAX;
        int sum = 0;
        cin >> n;
        
        if( n == 0 )return 0;
        
        for(int i = 0 ; i < n ; i++ ){
            int temp;
            cin >> temp;
            sum += temp;
            max_v = max(max_v,temp);
            min_v = min(min_v,temp);
        }
        
        sum -= max_v;
        sum -= min_v;
        
        cout << sum / (n-2) << endl;
    }
    
    return 0;
}

Measured memory_bytes: 3072
a, b, c, x, y = gets.strip.split.map{|num| num.to_i}
if a + b <= c*2
  puts a*x + b*y
else
  if a >= c*2 && b >= c*2
    if x >= y
        puts c*x*2
    else
        puts c*y*2
    end
  elsif a >= c*2 && b < c*2
    if x >= y
        puts c*x*2
    else
        puts c*x*2 + (y-x)*b
    end
  elsif a < c*2 && b >= c*2
    if x >= y
        puts c*y*2 + (x-y)*a
    else
        puts c*y*2
    end
  elsif a < c*2 && b < c*2
    if x >= y
        puts c*y*2 + (x-y)*a
    else
        puts c*x*2 + (y-x)*b
    end
  end
end

Measured memory_bytes: 1788
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
typedef double db;
typedef long long ll;
typedef pair<int,int> PII;
typedef vector<int> VI;

const int N=233333;
char buf[N];
bool vl[N],vr[N];

int main() {
	int n,k,c; scanf("%d%d%d",&n,&k,&c);
	scanf("%s",buf+1);
	VI ps;
	rep(i,1,n+1) if (buf[i]=='o') ps.pb(i);
	int lst=0,cnt=0; 
	for (auto p:ps) if (!lst||lst+c+1<=p) vl[p]=1,++cnt,lst=p;
	if (cnt!=k) return 0;
	lst=0;
	per(i,0,SZ(ps)) if (!lst||ps[i]+c+1<=lst) vr[ps[i]]=1,lst=ps[i];
	rep(i,1,n+1) if (vl[i]&&vr[i]) printf("%d\n",i);
	return 0;
}

Measured memory_bytes: 2932
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <climits>
#include <string>
#include <bitset>
#include <cfloat>
#include <unordered_set>
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<ll> > vvll;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n) - 1; i >= 0; --i)
#define fin(ans) cout<<(ans)<<endl
#define STI(s) atoi(s.c_str())
#define mp(p,q) make_pair(p, q)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define Sort(a) sort(a.begin(), a.end())
#define Rort(a) sort(a.rbegin(), a.rend())
#define MATHPI acos(-1)
#define itn int
template <class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template <class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
struct io{io(){ios::sync_with_stdio(false);cin.tie(0);};};
const ll MOD = 1000000007;
const int INF = INT_MAX;
const ll LLINF = 1LL<<62;



int main(void) {

    ld n;
    cin>>n;
    ld a=1,b=1;
    rep(i,n){
        ld T,A;
        ld next_a,next_b;
        cin>>T>>A;
        ld N;
        N=max(ceil((ld)a/(ld)T),ceil((ld)b/(ld)A));
        if(a<=T && b<=A){
            next_a=T;
            next_b=A;
        } else{
            next_a = N*T;
            next_b = N*A;
        }
        a=next_a;
        b=next_b;
        // cout<<endl<<a<<" "<<b<<endl;
    }
    fin(ll(a+b));
    
}

Measured memory_bytes: 256
#include<stdio.h>
int main()
{
  int a,b,d,r;
  double f;
  scanf("%d%d",&a,&b);
 
  d=a/b;
  r=a%b;
  f=(double)a/b;
 
  printf("%d %d %f\n",d,r,f);
 
  return 0;
 
}


Measured memory_bytes: 2108
const config = {
    input: '/dev/stdin',
    newline: '\n'
};

const line = require('fs').readFileSync(config.input, 'utf-8').split(config.newline);

const solve = (arr1, arr2) => arr2.filter(x => arr1.some(y => x == y)).length;

const data1 = line[1].split(' ').map(x => parseInt(x));
const data2 = line[3].split(' ').map(x => parseInt(x));

console.log(solve(data1, data2));



Measured memory_bytes: 17936
use std::io::prelude::*;
use std::str::FromStr;
pub struct Scanner<R: Read>(R);
impl<R: Read> Scanner<R> {
    pub fn new(reader: R) -> Self {
        Self(reader)
    }
    pub fn read<T: FromStr>(&mut self) -> T {
        let token = self
            .0
            .by_ref()
            .bytes()
            .map(|b| b.unwrap())
            .skip_while(|&b| (b as char).is_whitespace())
            .take_while(|&b| !(b as char).is_whitespace())
            .collect::<Vec<u8>>();
        unsafe { std::str::from_utf8_unchecked(token.as_slice()) }
            .parse()
            .ok()
            .expect("Can't parse it.")
    }
    pub fn vec<T: FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read()).collect()
    }
    pub fn chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
}
fn main() {
    let (stdin, stdout) = (std::io::stdin(), std::io::stdout());
    let mut sc = Scanner::new(stdin.lock());
    let mut out = std::io::BufWriter::new(stdout.lock());
    solve(&mut sc, &mut out);
    out.flush().ok().unwrap();
}
fn solve(sc: &mut Scanner<std::io::StdinLock>, out: &mut std::io::BufWriter<std::io::StdoutLock>) {
    let k: u32 = sc.read();

    use std::collections::VecDeque;
    let mut d = VecDeque::new();
    for i in 1..10 {
        d.push_back(i.to_string());
    }

    for _ in 1..k {
        let num = d.pop_front().unwrap();
        let c = num.chars().last().unwrap();

        if c != '0' {
            d.push_back(num.clone() + ((c as u8 - 1) as char).to_string().as_str());
        }
        d.push_back(num.clone() + ((c as u8) as char).to_string().as_str());
        if c != '9' {
            d.push_back(num.clone() + ((c as u8 + 1) as char).to_string().as_str());
        }
    }

    println!("{}", d.pop_front().unwrap());
}


Measured memory_bytes: 13980
#include <cstdio>
#include <algorithm>
#include <limits>
#include <numeric>
#include <type_traits>
#include <iostream>

typedef long long ll;
typedef long long int lli;

#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)

template<class T>bool umax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool umin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

using namespace std;

int v[200000],a[200000]={0},b[200000]={0};
int main() {
    int X,Y;
    cin >> X >> Y;
    printf("%d", X + Y/2);
    return 0;


}


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

int main()
{
	int n, m, l, r;
	cin >> n;
	cin >> m;
	l = 1;
	r = n;
	for (int i=0; i<m; i++) {
		int nl, nr;
		cin >> nl;
		cin >> nr;
		if (l < nl) {
			l = nl;
		}
		if (r > nr) {
			r = nr;
		}
	}
	if (r < l) {
		cout << 0 << endl;
	} else {
		cout << r - l + 1 << endl;
	}
	return 0;
}

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

int N, M;
vector<int> par(N), siz(N);

int find(int x) {
  if (par.at(x) == x) return x;
  else return par.at(x) = find(par.at(x));
}

void unite(int x, int y) {
  x = find(x);
  y = find(y);
  if (x == y) return;
  if (siz.at(x) < siz.at(y)) swap(x, y);
  siz.at(x) += siz.at(y);
  par.at(y) = x;
}

int main() {
  cin >> N >> M;
  par.resize(N);
  siz.resize(N);
  for (int i = 0; i < N; i++) par.at(i) = i;
  for (int i = 0; i < N; i++) siz.at(i) = 1;
  for (int i = 0; i < M; i++) {
    int A, B;
    cin >> A >> B;
    A--;
    B--;
    unite(A, B);
  }
  int ans = 1;
  for (int i = 0; i < N; i++) ans = max(ans, siz.at(i));
  cout << ans << endl;
}

Measured memory_bytes: 4824
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    string s;
    cin>>s;
    int si=s.size();
    int k=0;
    for(int i=0;i<si;i++){
        if(i%2==0){
            if(s[i]=='L'){
                k++;
                //cout<<s[i]<<i<<endl;;
            }
        }
        else if(i%2==1){
            if(s[i]=='R'){
                k++;
                //cout<<s[i]<<i<<endl;;
            }
        }
    }
    if(k!=0)cout<<"No";
    if(k==0)cout<<"Yes";
}


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

using namespace std;
 
const int MAXN = 1e5+10;
vector<int> adj[MAXN];
vector<int> par(MAXN);
vector<int> dis(MAXN);
vector<int> depth(MAXN);
vector<bool> vis(MAXN);

void bfs(int s) {
	queue<int> q;
	q.push(s);
	vis[s] = true;
	while(!q.empty()) {
		s = q.front();
		q.pop();
		for(auto i : adj[s]) {
			if(!vis[i]) {
				vis[i] = true;
				dis[i] = dis[s] + 1;
				par[i] = s;
				q.push(i);
			}
		}
	}
}

void findDepth(int r) {
	if(adj[r].size() == 0) {
		depth[r] = 1;
		return;
	}
	for(auto j : adj[r]) {
		findDepth(j);
		depth[r] = max(depth[r], depth[j]);
	}
	depth[r]++;
}

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

  	int n, u, v;
  	cin >> n >> u >> v;

  	for(int i = 1; i < n; i++) {
  		int x, y;
  		cin >> x >> y;
  		adj[x].push_back(y);
  		adj[y].push_back(x);
  	}

  	bfs(v);
  	for(int i = 1; i <= n; i++) {
  		adj[i].clear();
  	}
  	for(int i = 1; i <= n; i++) {
  		if(i == v) continue;
  		adj[par[i]].push_back(i);
  	}
  	findDepth(v);

  	if(u == v) {
  		cout << 0 << '\n';
  		return 0;
  	}
  	int move = max(0, (dis[u] - 3)/2+1);
  	int temp = dis[u];
  	if(dis[u] < 3) move = 0;
  	for(int i = 0; i < move; i++) {
  		u = par[u];
  	}
  	if(temp & 1) {
  		v = par[u];
  	}
  	else {
  		v = par[par[u]]; 
  	}
  	int ans = move;
  	if(temp  & 1) ans += depth[u]-1;
  	else {
  		ans += depth[u];
  	}
  	cout << ans << '\n';

  	return 0;
}

Measured memory_bytes: 10752
package main

import "fmt"

func main() {
	var n int
	fmt.Scan(&n)
	result := -1
	for i := 0; i < n; i++ {
		var num int
		fmt.Scan(&num)
		result = checkEvenCount(num, result)
	}
	fmt.Println(result)
}

func checkEvenCount(n, maxCnt int) int {
	var divCnt int
	for n%2 == 0 {
		n /= 2
		divCnt++
		if maxCnt >= 0 && divCnt >= maxCnt {
			return maxCnt
		}
	}
	return divCnt
}


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

int top =0, S[1000];

void push(int x){
	S[++top] = x;
}

int pop(void){
	top--;
	return S[top+1];
}
int main(void){
	int a,b;
	top = 0;
	char s[1000];
	while(scanf("%s",s) != EOF){
		if(s[0] == '+'){
			a = pop();
			b = pop();
			push(a+b);
		} else if(s[0] =='-'){
			b = pop();
			a = pop();
			push(a-b);
		}else if(s[0] == '*'){
			a = pop();
			b = pop();
			push(a*b);
		} else{
			push(atoi(s));
		}
	}
	
	printf("%d\n",pop());
	
	return 0;
}


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

/******************** START OF CRAPS ********************/

#define fin             freopen("input/in.txt","r",stdin);
#define fout            freopen("input/out.txt","w",stdout);
#define ri(x)           scanf("%d", &x)
#define r3i(x,y,z)      scanf("%d %d %d", &x, &y, &z)
#define rll(x)          scanf("%lld", &x)
#define r2ll(x,y)       scanf("%lld %lld", &x, &y)
#define imax            INT_MAX
#define imin            INT_MIN
#define pb              push_back
#define mp              make_pair
#define pi              acos(-1.0)
#define newl            "\n"
#define newlChar        '\n'
#define spChar          ' '
#define max3(a,b,c)     max(a,max(b,c))
#define min3(a,b,c)     min(a,min(b,c))
#define pCase(cs,ch)    printf("Case %d:%c", cs,ch)
#define iterAll(x)      x.begin(),x.end()
#define rIterAll(x)     x.rbegin(),x.rend()
#define fastreader      ios_base::sync_with_stdio(false); cin.tie(0)

typedef long long               ll;
typedef unsigned long long      ull;
typedef vector<int>             vi;
typedef vector<ll>              vll;
typedef vector<double>          vd;
typedef vector<string>          vs;
typedef vector<char>            vc;
typedef pair<int,int>           pii;
typedef map<int,int>            mapii;
typedef map<char,int>           mapci;
typedef map<string,int>         mapsi;

/******************** END OF CRAPS ********************/

int main()
{
    //fin; fout;

    int n,a,b,c;

    while(r3i(n,a,b) != EOF)
    {
        int cnt = 0;
        for(int i=1; i<=n; i++)
        {
            ri(c);
            if(c<a || c>=b) cnt++;
        }
        cout << cnt << endl;
    }

    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>

int main()
{
    long long int a,b,c,qian,hou;
    scanf("%lld%lld%lld",&a,&b,&c);
    if(c<(a+b))
    {
        printf("No");

    }
    else
    {
        qian=4*a*b;
        hou=(c-a-b)*(c-a-b);
        if(qian<hou)
        {
            printf("Yes");
        }
        else
        {
            printf("No");
        }
    }


    return 0;
}


Measured memory_bytes: 128