akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <stack>
#include <algorithm>
#include <iostream>
#include <string>
#include <map>
#include <queue>
#include <stdio.h>
#include <math.h>


using namespace std;

typedef long long ll;

typedef vector<vector<int>> vvi;
typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<vector<string>> vvs;
typedef vector<ll> vll;

typedef pair<int, int> pii;

typedef queue<int> qi;
typedef queue<string> qs;


#define rep(i, n) for(int i=0; i<(n); ++i)
#define repp(i, a, b) for(int i = (a); i <= (b); i++)
#define Rep(i, n) for(int i=n; i >= 0; i--)

#define all(v) v.begin(), v.end()
//sort( all(v) )　などと使える


int main() {
	string t; cin >> t;
	int n = t.size();

	rep(i, n) {
		if (t[i] == '?') {
			t[i] = 'D';
		}
	}

	cout << t << endl;
}

Measured memory_bytes: 3720
import java.util.Scanner;
class Main{
  public static void main(String[] args){
	Scanner scan = new Scanner(System.in);
    long K =scan.nextLong();
    long A = scan.nextLong();
    long B = scan.nextLong();
    if(A>=K){
      System.out.println(1);
      return;
    }
    if(A-B <= 0){
      System.out.println(-1);
      return;
    }
    long sub = A-B;
	long ans = 1 + (1+(K-A-1)/sub)*2;
    System.out.println(ans);
  }
}


Measured memory_bytes: 23124
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>

using namespace std;

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
#define chmin(a,b) if ((a) > (b)) a = (b);
#define INF (1<<29)

int dp[1000][1000][16];
int h, w;
string str[1000];
int cost[1000][1000];

bool check(int x, int y) {
	return x >= 0 && x < w && y >= 0 && y < h;
}

int main() {
	cin >> h >> w;
	REP(i, h) cin >> str[i];
	REP(i, h) REP(j, w) if (str[i][j] != '.') cost[i][j] = str[i][j] - '0';
	
	fill(dp[0][0], dp[h][0], INF);
	
	dp[0][0][0] = 0;
	REP(i, h) REP(j, w) REP(k, 1<<4) {
		if (dp[i][j][k] == INF) continue;
		
		int c[3];
		int nextc, nextk, buy;
		int dx[2] = {0,1}, dy[2] = {1,0};
		
		REP(p, 2) {
			if (p == 0) {
				if (i == h - 1) continue;
				c[0] = check(j + 1, i + 1) ? cost[i + 1][j + 1] : 0; // right
				c[1] = check(j, i + 2)     ? cost[i + 2][j]     : 0; // down
				c[2] = check(j - 1, i + 1) ? cost[i + 1][j - 1] : 0; // left
				
				nextc = dp[i][j][k] + (!(k & 4) ? cost[i + 1][j] : 0);
				nextk = k & 2 ? 1 : 0;
			}
			else {
				if (j == w - 1) continue;
				c[0] = check(j + 2, i)     ? cost[i][j + 2]     : 0; // right
				c[1] = check(j + 1, i + 1) ? cost[i + 1][j + 1] : 0; // down
				c[2] = check(j + 1, i - 1) ? cost[i - 1][j + 1] : 0; // up
				
				nextc = dp[i][j][k] + (!(k & 2) ? cost[i][j + 1] : 0);
				nextk = k & 4 ? 8 : 0;
			}
			
			buy = 7; // ????????????????????? 0, 1, 2
			if (!c[0]) buy -= 1;
			if (!c[1]) buy -= 2;
			if (!c[2] || k & (p == 0 ? 8 : 1)) buy -= 4;
			
			if (buy == 0 || buy == 1 || buy == 2 || buy == 4) {
				chmin(dp[i + dy[p]][j + dx[p]][nextk], nextc);
			}
			else if (buy == 3 || buy == 6 || buy == 5) {
				int tmp[3] = {2,4,0};
				REP(l, 3) if (1 << l & buy)
					chmin(dp[i + dy[p]][j + dx[p]][nextk | tmp[l]], nextc + c[l]);
			}
			else if (buy == 7) {
				chmin(dp[i + dy[p]][j + dx[p]][nextk | 6], nextc + c[0] + c[1]);
				chmin(dp[i + dy[p]][j + dx[p]][nextk | 4], nextc + c[1] + c[2]);
				chmin(dp[i + dy[p]][j + dx[p]][nextk | 2], nextc + c[2] + c[0]);
			}
		}
	}
	
	cout << dp[h - 1][w - 1][0] << endl;
	return 0;
}

Measured memory_bytes: 70492
import java.util.*; 
import java.lang.*; 


public class Main{
	public static void main(String[] args){
		Scanner scan = new Scanner(System.in);
                
                int N = scan.nextInt();
                int K = scan.nextInt();
                int[] d = new int[K+1];
                ArrayList<Integer> arrayList = new ArrayList<Integer>();
                
                for(int i=1; i<=K;i++){
                    d[i] = scan.nextInt();
                        for(int j=1; j<=d[i];j++){
                            int[][] A = new int[K+1][d[i]+1];
                            A[i][j] = scan.nextInt();
                            arrayList.add(A[i][j]);
                        }
                }
                
                ArrayList<Integer> listB = new ArrayList<Integer>(new HashSet<>(arrayList));

                System.out.println(N-listB.size());
      
        }
}

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

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		String line = sc.nextLine();
		String[] string = line.split(" ");
		int[] is = new int[string.length];
		for (int i = 0; i < is.length; i++) {
			is[i] = Integer.parseInt(string[i]);
		}

		Arrays.sort(is);

		System.out.println(is[0] + " " + is[1] + " " + is[2]);

	}

}

Measured memory_bytes: 26160
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <iomanip>
#include <queue>
#include <deque>
#include <map>
#include <unordered_map>
#define rep(i,n) for(int i=0;i<n;i++)
#define repn(i,n) for(int i=1;i<=n;i++)
#define repr(e,x) for(auto& e:x)
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
//ll const INF=1001001001;
//ll const INF=1001001001001001001;
ll const MOD=1000000007;

int N;
int X[100000];
int L[100000];
P rl[100000];

int main(){
    cin>>N;
    rep(i,N) cin>>X[i]>>L[i];

    rep(i,N){
        int l=X[i]-L[i];
        int r=X[i]+L[i];
        rl[i]=P(r,l);
    }

    sort(rl,rl+N);

    int ans=0;
    int pos=-1001001001;
    rep(i,N){
        if(pos<=rl[i].second){
            ans++;
            pos=rl[i].first;
        }
    }

    cout<<ans<<endl;
}

Measured memory_bytes: 5164
#include<bits/stdc++.h>
#define mo 1000000007
using namespace std;
long long n,m,i,j,a[3005],b[3005],k,f[2005][2005],sum[2005][2005];
long long ksm(long long u,long long v){
	long long o=1;
	while(v){
		if(v&1)
			o=o*u%mo;
		u=u*u%mo;
		v>>=1;
	}
	return o;
}
int main(){
	cin>>n>>m;
	for(i=1;i<=n;i++)
		cin>>a[i];
	for(i=1;i<=m;i++)
		cin>>b[i];
	f[0][0]=1;
	sum[0][0]=1;
	for(i=1;i<=n;i++)
		sum[i][0]=sum[i-1][0];
	for(i=1;i<=m;i++)
		sum[0][i]=sum[0][i-1];
	for(i=1;i<=n;i++)
		for(j=1;j<=m;j++){
			if(a[i]==b[j])
		    	f[i][j]=sum[i-1][j-1]%mo;
			sum[i][j]=(sum[i-1][j]+sum[i][j-1]-sum[i-1][j-1]+f[i][j]+mo)%mo; 
		}
	cout<<sum[n][m]<<endl;
    return 0;
}

Measured memory_bytes: 62848
#include <stdio.h>
#include <vector>
#include <iostream>
#include <math.h>
#include <algorithm>
#include <cstring>
#include <string>
using namespace std;
typedef long long ll;
using vi = vector<int>;

string str;
string stra;
int id = 0;

void pt(vector<int> v){
  for(int r=0;r<v.size();r++){
    cout << v[r];
  }
  cout << endl;
}

vi number(){
  vi res;
  for (;'0'<=stra[id]&&stra[id]<='9'; id++) {
    res.push_back(stra[id] - '0');
  }
  reverse(res.begin(),res.end());
  return res;
}
int solve(){
  stra = str;
  for (int i = 9; i >= 0; i--) {
    id = 0;
    for (int j = 0; j <(int)str.size(); j++) {
      if (str[j] == 'X') {
        stra[j] = i + '0';
      }
    }
    vi a = number();
    if (stra[id] == '+' ) {
      id++;
    }
    vi b = number();

    a.resize(max(b.size() + 1,a.size()+1),0);

    for (int j = 0; j < (int)b.size(); j++) {
      a[j] += b[j];
      if (a[j]>=10) {
        a[j] -= 10;
        a[j+1]++;
      }
    }
    for (int j = b.size(); j < (int)(a.size()-1); j++) {
      if (a[j] >= 10) {
        a[j] -= 10;
        a[j+1]++;
      }
    }


    if(a[a.size()-1]==0){
      a.pop_back();
    }


    if (stra[id] == '=') {
      id++;
    }

    vi c = number();
    if (a.size() != c.size()) {
      continue;
    }
    int flag = 0;
    for (int j = 0; j < (int)a.size(); j++) {
      if (a[j] == c[j]) {
        flag++;
      }
    }
    if (flag ==(int)a.size()) {
      return i;
    }

  }
  return -1;
}
int main(){
  cin >> str;
  while(str.size()){
  int ans = solve();
  if (ans >= 0) {
    cout << ans << endl;
  } else {
    cout << "NA" << endl;
  }
  str="";
  cin >> str;
}
  return 0;
}



Measured memory_bytes: 3064
#include<cstdio>
#include<cstdlib>
#include<string>
#include<iostream>
using namespace std;


struct Node {
  int key;
  Node *right,*parent,*left;
};

  Node *root,*Nil;

Node * find(Node *x,int k){
  while(x!=Nil && k!=x->key){
    if(k< x->key)x=x->left;
    else x=x->right;
  }return x;
}

void insert(int a){
  Node *x=root,*y=Nil,*z;

  z=(struct Node *)malloc(sizeof( Node));
  z->key=a;
  z->left=Nil;
  z->right=Nil;

  while(x!=Nil){
    y=x;
    if(z->key < x->key){x = x->left;}
    else {x = x->right;}
  }
 z->parent=y;

 if(y==Nil){root=z;}
 else {
   if(z->key < y->key){y->left=z;}
   else {y->right=z;}
 }
}

void inorder(Node *x){
   if(x==Nil)return;
  inorder(x->left);
  printf(" %d",x->key);
  inorder(x->right);
}

void preorder(Node *x){
  if(x==Nil)return;
  printf(" %d",x->key);
  preorder(x->left);
  preorder(x->right);
}

int main(){
  int n,i,a;
  string co;

  scanf("%d",&n);

for(i=0;i<n;i++){
    cin >> co;
    if(co[0]=='f'){
      scanf("%d",&a);
      Node *b=find(root,a);
      if(b!=Nil)printf("yes\n");
      else printf("no\n");
    }
    else if(co=="insert"){
      scanf("%d",&a);
      insert(a);
    }
    else if(co=="print"){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    }
  }

  return 0;
}



Measured memory_bytes: 22032
A,B = map(int,input().split())
S = input()

ans = True
for i in range(len(S)):
    if i == A:
        if S[i] != "-":
            ans = False
    else:
        if not (48 <= ord(S[i]) <= 57):
            ans = False

if ans:
    print("Yes")
else:
    print("No")


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

const int mod = 1e9+7;
int main(){
    int h,w; cin>>h>>w;
    char a[h][w];
    for(int i=0; i<h; ++i){
        for(int j=0; j<w; ++j){
            cin>>a[i][j];
        }
    }
    vector<vector<int>> dp(h, vector<int>(w));
    dp[0][0] = 1;
    for(int row=0; row<h; ++row){
        for(int col=0; col<w; ++col){
            for(int r: {row, row+1}){
                int c = col;
                if(r==row){
                    c = col+1;
                }
                if(r<h && c<w && a[r][c]=='.'){
                    dp[r][c] += dp[row][col];
                    if(dp[r][c]>=mod){
                        dp[r][c] -= mod;
                    }
                }
            }
        }
    }
    cout<<dp[h-1][w-1];

    return 0;
}

Measured memory_bytes: 5120
#include <algorithm>
#include <array>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <sstream>
#include <unordered_map>
#include <vector>


#define INF 4000000000000000000LL
#define MOD 1000000007
#define ALL(x) std::begin(x), std::end(x)


int main(int argc, char** argv)
{
  std::cin.tie(0);
  std::ios_base::sync_with_stdio(0);

  std::cout << std::fixed << std::setprecision(6);

  std::string s;

  std::cin >> s;

  int a[4];

  for (int i = 0; i < 4; i ++)
    a[i] = s[i] - '0';

  for (int i = 0; i < 8; i ++) {
    int S = a[0];

    for (int j = 0, b = 1; j < 3; j ++, b <<= 1)
      S += (i & b) ? a[j + 1] : - a[j + 1];

    if (S == 7) {
      std::cout <<
        a[0] << ((i & 1) ? '+' : '-') <<
        a[1] << ((i & 2) ? '+' : '-') <<
        a[2] << ((i & 4) ? '+' : '-') <<
        a[3] << "=7" << std::endl;
      
      break;
    }
  }
    
  return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        long[] a = new long[n];
        for (int i=0; i<n; i++) {
            a[i] = sc.nextInt();
        }
        long[] dp = new long[n*n];
        for (int i = 0; i < n; i++) {
            dp[i * n + i] = a[i];
        }
        for (int i = n - 2; i >= 0; i--) {
            for (int j = i + 1; j < n; j++) {
                dp[i*n + j] = Math.max(a[i] - dp[(i+1)*n + j], a[j] - dp[i*n + j - 1]);
            }
        }
        System.out.println(dp[n - 1]);
    }
}


Measured memory_bytes: 98320
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
int main ()
{
    long long int n,a,b,i,r;
    while (scanf ("%lld %lld",&a,&b)!=EOF)
    {
        i=a+b;
        r=log10(i)+1;
        printf ("%lld\n",r);
    }
    return 0;
}


Measured memory_bytes: 3488
#include<iostream>
#include<vector>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);++i)
using ll = long long;
using P = pair<int, int>;
#include<algorithm>
#include<map>

int main() {
	map<int, int>mp;
	int n;
	cin >> n;
	rep(i, n) {
		int x;
		cin >> x;
		mp[x]++;
	}
	for (auto p : mp)
		if (p.second == 2) {
			cout << "NO";
			return 0;
		}
	cout << "YES";
	return 0;
}

Measured memory_bytes: 9600
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG //これつけるとA[N]でもいいらしい
//for文のマクロ
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define big 1000000007
#define all(a) sort((a).begin(),(a).end()) //ソートのマクロ
#define Re(a) reverse((a).begin(),(a).end())
#define YN(a) if(a){cout<<"Yes"<<endl;}else cout<<"No"<<endl;//条件によってYes、Noを出力する
const int MOD=1000000007;
const double pi = 3.141592653589793;
int main(){
    int x,n;
    cin>>x>>n;
    if(n==0){
        cout<<x<<endl;
        return 0;
    }
    map<int,int> p;
    rep(i,n){
        int k;
        cin>>k;
        p[k]++;
    }
    int ans;
    for(int sa=0;sa<500;sa++){
        if(p[x+sa]==0 || p[x-sa]==0){
            if(p[x-sa]!=0 && p[x+sa]==0){
                ans=x+sa;
            }
            else{
                ans = x-sa;
            }
            break;
        }
    }
    cout<<ans<<endl;

}

Measured memory_bytes: 3640
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int main() {
	int n;
	cin >> n;
 	vector<double> value;
 	double v;
	for( int i = 0; i < n; i++) {
		cin >> v;
		value.push_back(v);
	}
	sort(value.begin(), value.end());
	v = value[0];
	for( int i = 1; i < n; i++) {
		v = (v + value[i])/2;
	}
	printf("%.5lf", v);
}

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

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

    int min = 10;

    if (a % 10 != 0 && min > a % 10)
        min = a % 10;
    if (b % 10 != 0 && min > b % 10)
        min = b % 10;
    if (c % 10 != 0 && min > c % 10)
        min = c % 10;
    if (d % 10 != 0 && min > d % 10)
        min = d % 10;
    if (e % 10 != 0 && min > e % 10)
        min = e % 10;

    if (a % 10 != 0)
        a = ((a / 10) + 1) * 10;
    if (b % 10 != 0)
        b = ((b / 10) + 1) * 10;
    if (c % 10 != 0)
        c = ((c / 10) + 1) * 10;
    if (d % 10 != 0)
        d = ((d / 10) + 1) * 10;
    if (e % 10 != 0)
        e = ((e / 10) + 1) * 10;

    cout << a + b + c + d + e - (10 - min) << endl;

    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
#include<string>
#include<vector>
#include<map>
#include<tuple>
#include<algorithm>
#include<cmath>
#include<limits>
#include<set>
#include<queue>
using namespace std;
//#define int long  long int
#define ll long long
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a / gcd(a, b) * b; }

signed main(){
	int N, T;
	cin >> N >> T;
	int ans = 1e5;
	rep(i, N) {
		int c, t;
		cin >> c >> t;
		if (t <= T)ans = min(ans, c);
	}
	if (ans == 1e5)cout << "TLE";
	else cout << ans;
}

Measured memory_bytes: 256
#[allow(unused_imports)]
use std::cmp::Reverse;

#[allow(unused_imports)]
use proconio::{fastout, input, marker::Chars};

#[allow(unused_imports)]
use itertools::Itertools;

#[fastout]
pub fn main() {
    input! {
        n: usize,
        h: [i64; n],
    }

    let mut dp = vec![0; n];
    dp[1] = (h[1] - h[0]).abs();
    for i in 2..n {
        dp[i] = (dp[i - 1] + (h[i] - h[i - 1]).abs()).min(dp[i - 2] + (h[i] - h[i - 2]).abs());
    }
    println!("{}", dp[n - 1]);
}


Measured memory_bytes: 3960
var lines = [];

var readline = require('readline');

var rl = readline.createInterface({
    input: process.stdin,
    output: process.stdout,
});

rl.on('line', function (x) {
    lines.push(x);
});

rl.on('close', function () {
    var N = Number(lines[0]);
    var A = lines[1].split(" ").map(i => Number(i));

    var Alice = 0, Bob = 0;

    A.sort((a, b) => b - a);

    for (var i = 0; i < N; i++) {
        if (i % 2 === 0) { Alice += A[i] }
        else { Bob += A[i] }
    }
    console.log(Alice - Bob)

});


Measured memory_bytes: 7756
#include <algorithm>
#include <cassert>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <deque>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>

#define FOR(i,k,n) for (int (i)=(k); (i)<(n); ++(i))
#define rep(i,n) FOR(i,0,n)
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fst first
#define snd second
#define all(v) begin(v), end(v)
#define debug(x) cerr<< #x <<": "<<x<<endl
#define debug2(x,y) cerr<< #x <<": "<< x <<", "<< #y <<": "<< y <<endl

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vector<int> > vvi;
typedef vector<ll> vll;
typedef vector<vector<ll> > vvll;
template<class T> using vv=vector<vector< T > >;

int main() {
  ll xs, ys, xg, yg;
  scanf("%lld %lld %lld %lld", &xs, &ys, &xg, &yg);
  int n;
  scanf("%d", &n);
  vv<double> d(n+2, vector<double>(n+2, 0));
  vll x(n+2), y(n+2), r(n+2);
  x[0] = xs;
  y[0] = ys;
  r[0] = 0;
  FOR (i, 1, n+1) {
    scanf("%lld %lld %lld", &x[i], &y[i], &r[i]);
  }
  x[n+1] = xg;
  y[n+1] = yg;
  r[n+1] = 0;
  rep (i, n+2) {
    FOR (j, i+1, n+2) {
      ll dx = x[i] - x[j];
      ll dy = y[i] - y[j];
      double c = sqrt(dx*dx + dy*dy) - r[i] - r[j];
      c = max(c, 0.0);
      d[i][j] = d[j][i] = c;
    }
  }
  rep (k, n+2) {
    rep (i, n+2) {
      rep (j, n+2) {
        d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
      }
    }
  }
  printf("%.12f\n", d[0][n+1]);
  return 0;
}


Measured memory_bytes: 8192
#include <vector>
#include <iostream>
#include <utility>
#include <algorithm>
#include <string>
#include <deque>
#include <queue>
#include <tuple>
#include <queue>
#include <functional>
#include <cmath>
#include <iomanip>
#include <map>
#include <set>
#include <numeric>
#include <unordered_map>
#include <unordered_set>
#include <complex>
#include <iterator>
#include <array>
#include <memory>
#include <stack>
#define vi vector<int>
#define vvi vector<vector<int> >
#define ll long long int
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vb vector<bool>
#define vc vector<char>
#define vs vector<string>
#define ld long double
#define INF 1e9
#define EPS 0.0000000001
#define rep(i,n) for(int i=0;i<n;i++)
#define loop(i,s,n) for(int i=s;i<n;i++)
#define all(in) in.begin(), in.end()
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
#define MAX 9999999
using namespace std;
typedef pair<int, int> pii;
typedef pair<double,double>pdd;
typedef pair<ll,ll>pll;
int main(){
    int n,m;
    while(cin>>m>>n,n+m){
        int tiya=0;
        vi array(7368791+10,0);
        vb flag(7368791+10,true);
        for(int i=m; i<array.size()-9; i++){
            if(flag[i]==false)continue;
             if(n==0){tiya=i; break;}
            else{
                for(int j=1; i*j<=7368791+1;j++)
                    flag[i*j]=false;
            }
            --n;
        }
        cout<<tiya<<endl;
    }
}

Measured memory_bytes: 32764
#include <iostream>
//#include <math.h>
#include <string>


using namespace std;

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

    if(s[2]==s[3] && s[4]==s[5]) cout << "Yes" << endl;
    else cout << "No" << endl;
    
    return 0;
}

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

//typedef
//------------------------------------------
typedef long long LL;
typedef vector<LL> VL;
typedef vector<VL> VVL;
typedef vector<string> VS;
typedef pair<LL, LL> PLL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
const int MOD = 1000000007;

// grid
//--------------------------------------------
VL dx = {0, 1, 0, -1};
VL dy = {1, 0, -1, 0};
VL dx2 = {-1, 0, 1, -1, 1, -1, 0, 1};
VL dy2 = {-1, -1, -1, 0, 0, 1, 1, 1};

//debug
//--------------------------------------------
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

//IO accelerate
//--------------------------------------------
struct InitIO {
    InitIO() {
        cin.tie(nullptr);
        ios_base::sync_with_stdio(false);
        cout << fixed << setprecision(30);
    }
} init_io;

//template
//--------------------------------------------
template<typename T>
istream& operator >>(istream& is, vector<T>& vec) {
  for(T& x: vec) is >> x;
  return is;
}
template<typename T>
ostream& operator <<(ostream& os, const vector<T>& vec) {
  for(int i=0; i<vec.size(); i++){
    os << vec[i] << ( i+1 == vec.size() ? "" : "\t" );
  }
  return os;
}
template<typename T>
ostream& operator <<(ostream& s, const vector<vector<T>>& vv) {
	for (int i = 0; i < vv.size(); ++i) {
		s << vv[i] << endl;
	}
	return s;
}

// 多重vector
// auto dp=make_v<int>(4,h,w) みたいに使える
template<typename T>
vector<T> make_v(size_t a){return vector<T>(a);}

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

// 多重vectorのためのfill
// fill_v(dp,0) みたいに使える
template<typename T,typename V>
typename enable_if<is_class<T>::value==0>::type
fill_v(T &t,const V &v){t=v;}

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

//main code

int main(int argc, char *argv[])
{
	int n;
	cin >> n;
	VL a(n);
	cin >> a;
	deque<LL> b;
	for (int i = 0; i < n; i++) {
		if (i%2) {
			b.push_front(a[i]);
		} else {
			b.push_back(a[i]);
		}
	}
	if (n%2) {
		reverse(ALL(b));
	}
	for (auto i : b) {
		cout << i << " ";
	}
	cout << endl;
	return 0;
}


Measured memory_bytes: 5376
#include "bits/stdc++.h"
using namespace std;
int main(){
	int sum=0,tmp=0;
	int arr[3][3];
	for(int i=0;i<3;i++){
		for(int j=0;j<3;j++){
			cin>>arr[i][j];
			sum += arr[i][j];
			if(i==j) tmp += arr[i][j];
		}
	}

	if(sum == 3*tmp) cout<< "Yes" <<endl;
	else cout<< "No" <<endl;

	return 0;
}

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

int main(){
  int n;
  cin>>n;
  int ans=0;
  for(int i=0;i<n;i++){
    int a,b;
    cin>>a>>b;
    if(a==b){
      ans++;
    }
    else{
      ans=0;
    }
    if(ans==3){
      cout<<"Yes"<<endl;
      return 0;
    }
  }
  cout<<"No"<<endl;
}


Measured memory_bytes: 3604
#include<bits/stdc++.h>
using namespace std;
int main(){
string s;
 cin>>s;
int l=s.size();
for(int i=0;i<l;i++){
if(s[i]=='C') {
for(int j=i+1;j<l;j++){
if(s[j]=='F') {
cout<<"Yes"<<endl;
 return 0;
}
}
}
}
cout<<"No"<<endl;
return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main() {


	int a1, a2, a3;


	cin >> a1 >> a2 >> a3;


	if (a1 + a2 + a3 >= 22) {

		std::cout << "bust" << endl;
	}
	else {
		std::cout << "win" << endl;
	}

	return 0;
}






Measured memory_bytes: 256
// https://atcoder.jp/contests/abc159/tasks/abc159_b

#include <iostream>
#include <string>
#include <cmath>
using namespace std;

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

    int length = s.length();

    for (int i = 0; i < length; ++i) {
        if (!(s[i] == s[length - 1 - i])) {
            cout << "No" << endl;
            return 0;
        }
    }

    for (int i = 0; i < (length - 1) / 2; ++i) {
        if (!(s[i] == s[(length - 1) / 2 - 1 - i])) {
            cout << "No" << endl;
            return 0;
        }
    }

    for (int i = (length + 3) / 2 - 1; i < (length - 1) / 2; ++i) {
        if (!(s[(length + 3) / 2 - 1 + i] == s[length - 1 - i])) {
            cout << "No" << endl;
            return 0;
        }
    }

    cout << "Yes" << endl;
    return 0;
}

Measured memory_bytes: 256
/******

AUTHOR : RUDRANSH TRIPATHI, IIIT NAGPUR, CCID(rt24) & CFID(rsgt24)

MOTTO : Use criticism as fuel and you will never run out of energy.
        AIM : TO BECOME A BETTER CODER
        INTROSPECT + COURSE CORRECTIONS = CATALYST FOR SUCCESS
        Every moment is an opportunity to better yourself

*******/

#include<bits/stdc++.h>
using namespace std;
const int M = 1e9 + 7;
const int MAX = 1e5 + 5;
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);
#define int long long int
#define pb push_back
#define d(x) cout<<x<<"\n"
#define time_passed	1.0 * clock() / CLOCKS_PER_SEC

//basic mathematics
int gcd(int a, int b)
{
	if (a == 0)
		return b;
	return gcd(b % a, a);
}
int lcm(int a, int b)
{
	return (a * b) / gcd(a, b);
}

//modular arithmetic
int powermod(int x, int y, int p)
{
	int res = 1;

	x = x % p;

	if (x == 0) return 0;

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

//Prime numbers till n precomputation - range query
int prefix[MAX + 1];

void buildPrefix()
{
	bool prime[MAX + 1];
	memset(prime, true, sizeof(prime));

	for (int p = 2; p * p <= MAX; p++) {
		if (prime[p] == true) {
			for (int i = p * 2; i <= MAX; i += p)
				prime[i] = false;
		}
	}
	prefix[0] = prefix[1] = 0;
	for (int p = 2; p <= MAX; p++) {
		prefix[p] = prefix[p - 1];
		if (prime[p])
			prefix[p]++;
	}
}

int query(int L, int R)
{
	return prefix[R] - prefix[L - 1];
}


//Find all paths from a to b in an undirected graph
vector<int> g[MAX];
int visited[MAX];
//count of all the paths from 1 to n;

void dfs(int visited[MAX], int u, int v, vector<int> path)
{
	visited[u] = 1;
	if (u == v)
	{
		for (int i = 0; i < path.size(); i++)
		{
			cout << path[i] << " ";
		}
		cout << "\n";
	}
	else
	{
		for (int i = 0; i < g[u].size(); i++)
		{
			int y = g[u][i];

			if (visited[y] == 0)
			{
				visited[y] = 1;
				path.pb(y);
				dfs(visited, y, v, path);
				path.pop_back();
			}

		}
	}

	visited[u] = 0;

}

vector<int> graph[MAX];
int vis[MAX];

void dfs(int v)
{
	vis[v] = 1;
	
	for(auto x: graph[v]){
	    
		if(vis[x] == 0)
		{
		    dfs(x);
		}
		
	}
}

int dp[20001];

void pre()
{
    dp[1] = 0;
    dp[2] = 0;
    dp[3] = 1;
    
    for(int i = 4; i <= 2000; i++)
    {
        dp[i] = (dp[i - 1] % M + dp[i - 3] % M) % M;
    }
}

void solve()
{
	int n;
	cin >> n;
	cout << dp[n] % M << "\n";
	
	
		
		
	//for (int i = 0; i < n; i++)
	//	cout << ar[i];
}

int32_t main(void)
{
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
    pre();
	fastio
	int t = 1;
	//cin >> t;
	while (t--)
	{
		solve();
	}
	//cerr << "\n" << "Time elapsed : " << time_passed << "\n";
	return 0;
}

Measured memory_bytes: 8360
N, M, K = map(int, input().split())
ok = False
for i in range(N + 1):
    for j in range(M + 1):
        now = M * i
        now -= j * i
        now += j * (N - i)
        if now == K:
            ok = True
if ok:
    print("Yes")
else:
    print("No")

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

using Graph = vector<vector<int>>;

void dfs(const Graph &G, int v, int p, int d, vector<int> &depth)
{
  depth[v] = d;
  for (auto next_v : G[v])
  {
    if (next_v == p)
      continue;
    dfs(G, next_v, v, d + 1, depth);
  }
}

int main()
{
  int N, u, v;
  cin >> N >> u >> v;
  Graph G(N);
  rep(i, N - 1)
  {
    int a, b;
    cin >> a >> b;
    G[a - 1].push_back(b - 1);
    G[b - 1].push_back(a - 1);
  }
  vector<int> u_depth = vector<int>(N, 0), v_depth = vector<int>(N, 0);
  dfs(G, u - 1, -1, 0, u_depth);
  dfs(G, v - 1, -1, 0, v_depth);

  int ans = 0;
  rep(i, N) if (u_depth[i] < v_depth[i]) ans = max(ans, v_depth[i]);
  cout << ans - 1 << endl;
}


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

#define real() cout<<"\n";

#define debug(arguments...) {string pri=#arguments;replace(pri.begin(),pri.end(),',',' ');stringstream prii(pri);istream_iterator<string> _iterat(prii);error(_iterat,arguments);}
void error(istream_iterator<string> _iterat) {}
template<typename T,typename...args>
void error(istream_iterator<string> _iterat,T a,args...arguments)
{
    cerr<<*_iterat<<"="<<a<<"\n";
    error(++_iterat,arguments...);
}

#define debugmp(z) {string pri=#z;error(pri,z);}
template<typename T,typename V>
void error(string pri,const pair<T,V> &z)
{
    cerr<<pri<<"="<<"{"<<z.first<<","<<z.second<<"}"<<"\n";
}
template<typename T,typename V>
void error(string pri,const map<T,V> &z)
{
    cerr<<pri<<" is={";
    for(auto it=z.begin();it!=z.end();++it)
    {
        cerr<<it->first<<":"<<it->second;
        auto _it=z.end();
        _it--;
        if(it!=_it) cerr<<",";
    }
    cerr<<"}";
    cerr<<"\n";
}

#define debugc(z,st,ed) {string pri=#z;error(pri,z,st,ed);}
template<typename T>
void error(string pri,const vector<T> &z,long long st,long long ed)
{
    cerr<<pri<<" in range["<<st<<","<<ed<<")=[";
    for(long long i=st;i<ed;++i)
    {
        cerr<<z[i];
        if(i!=ed-1) cerr<<" ";
    }
    cerr<<"]";
    cerr<<"\n";
}
template<typename T>
void error(string pri,const set<T> &z,long long st,long long ed)
{
    cerr<<pri<<" in range["<<st<<","<<ed<<")=[";
    long long tempcount=0;
    for(auto it=z.begin();it!=z.end();++it)
    {
        if(tempcount>=st and tempcount<ed)
        {
            cerr<<*it;
            if(tempcount!=ed-1) cerr<<" ";
        }
        tempcount++;
    }
    cerr<<"]";
    cerr<<"\n";
}
template<typename T>
void error(string pri,const T z[],long long st,long long ed)
{
    cerr<<pri<<" in range["<<st<<","<<ed<<")=[";
    for(long long i=st;i<ed;++i)
    {
        cerr<<z[i];
        if(i!=ed-1) cerr<<" ";
    }
    cerr<<"]";
    cerr<<"\n";
}

void logic()
{
    int n;
    cin>>n;
    long long arr[n];
    for(int i=0;i<n;++i)
    {
        cin>>arr[i];
    }
    for(int i=0;i<n;++i)
    {
        arr[i]=arr[i]-i-1;
    }
    sort(arr,arr+n);
    int median=0;
    if(n%2==0) median=arr[(n/2)-1];
    else median=arr[(n/2)];
    long long sum=0;
    for(int i=0;i<n;++i)
    {
        sum=sum+abs(arr[i]-median);
    }
    cout<<sum;
    cout<<"\n";
    //incase of wrong answer...stress test your code...do not stress test yourself
    //overflow,bounds,size,constraints
    //sample tests,corner case/special case(n==0 or n==1 or negative numbers...),some hand written tests
    //read statement carefully
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    long long t;
    //cin>>t;
    //while(t--)
    {
        logic();
    }
}

Measured memory_bytes: 5220
#include <stdio.h>
#define getchar() (p1 == p2 && (p2 = (p1 = buf) + fread(buf, 1, 3, stdin), p1 == p2) ? EOF : *p1++)
char buf[3], *p1 = buf, *p2 = buf;
inline int read() {
    char c = getchar(); int x = 0, f = 1;
    while(c < '0' || c > '9') {if(c == '-') f = -1; c = getchar();}
    while(c >= '0' && c <= '9') x = x * 10 + c - '0', c = getchar();
    return x * f;
}
int ab[100001];
int main(int argc, char *argv[])
{
	int i;
	int n = read(),m = read();
	for (i = 0; i < m; ++i) {
		int a = read(),b = read();
		if (*(ab+b) < a) {*(ab+b) = a;}
	}
	int ans = 0;
	int k = 1;
	for (i = 1; i <= n; ++i) {
		if (k <= *(ab+i)) {
			k = i;
			++ans;
		}
	}
	printf("%d\n", ans);
	return 0;
}


Measured memory_bytes: 512
#include <iostream>
#include <cstdio>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <algorithm>
#include <cstring>
#include <functional>
#include <cmath>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);++i)
#define rep1(i,n) for(int i=1;i<=(n);++i)
#define all(c) (c).begin(),(c).end()
#define fs first
#define sc second
#define pb push_back
#define show(x) cout << #x << " " << x << endl
int H,W,dx[4]={-1,0,1,0},dy[4]={0,1,0,-1};//NESW
string s[30],ord;
struct dice{char t,b,n,s,e,w;};
struct State{
	dice d;
	int x,y;
	bool operator <(const State& st) const{
		if(x!=st.x) return x<st.x;
		if(y!=st.y) return y<st.y;
		if(d.t!=st.d.t) return d.t<st.d.t;
		return d.n<st.d.n;
	}
};
map<State,int> dist,mp,nmp;
void swaap(char &a,char &b,char &c,char &d){
	char dd=d;
	d=c;
	c=b;
	b=a;
	a=dd;
}
dice rotate(dice a,int di){
	if(di==0) swaap(a.t,a.n,a.b,a.s);
	if(di==1) swaap(a.t,a.e,a.b,a.w);
	if(di==2) swaap(a.t,a.s,a.b,a.n);
	if(di==3) swaap(a.t,a.w,a.b,a.e);
	return a;
}
bool is(int x,int y){
	return 0<=x&&x<H&&0<=y&&y<W&&s[x][y]!='k';
}
void bfs(State sst,int gx,int gy){
	dist.clear();
	queue<State> que;
	que.push(sst);
	dist[sst]=0;
	while(!que.empty()){
		State st=que.front();
		que.pop();
		int x=st.x,y=st.y;
		dice d=st.d;
/*		show(x);
		show(y);
		show(d.t);
		show(d.n);
		puts("");*/
		if(x==gx&&y==gy){
			if(nmp.count(st)){
				nmp[st]=min(nmp[st],mp[sst]+dist[st]);
			}else nmp[st]=mp[sst]+dist[st];
		}
		rep(di,4){
			dice nd=rotate(d,di);
			int nx=x+dx[di],ny=y+dy[di];
			if(!is(nx,ny)) continue;
			State ns={nd,nx,ny};
			if(dist.count(ns)) continue;
			if(s[nx][ny]!='w') if(s[nx][ny]!=s[gx][gy]||nd.t!=s[nx][ny]) continue;
			dist[ns]=dist[st]+1;
			que.push(ns);
		}
	}
}
int main(){
	while(true){
		cin>>W>>H;
		if(W==0) break;
		rep(i,H) cin>>s[i];
		cin>>ord;
		dice be={'r','c','g','m','b','y'};
		int sx,sy,gx[6],gy[6];
		rep(i,H) rep(j,W){
			if(s[i][j]=='#') sx=i,sy=j,s[i][j]='w';
			else if(s[i][j]!='k'){
				rep(k,6) if(ord[k]==s[i][j]) gx[k]=i,gy[k]=j;
			}
		}
		mp.clear();
		mp[State{be,sx,sy}]=0;
		rep(i,6){
			nmp.clear();
			for(auto p:mp){
				bfs(p.fs,gx[i],gy[i]);
			}
			mp=nmp;
		}
		int ans=1e9;
		for(auto p:mp){
			ans=min(ans,p.sc);
		}
		if(ans==1e9) puts("unreachable");
		else cout<<ans<<endl;
	}
}

Measured memory_bytes: 1944
#include<stdio.h>
int main(void)
{
	int n,x,y,b,p,g,i,h;
	scanf("%d",&n);
	for(i=1;i<=n;i++)
	{
		scanf("%d%d%d%d",&x,&y,&b,&p);
		if(b>=5&&p>=2)
		{
			g=(x*b+y*p)*0.8;
			printf("%d\n",g);
		}
		else
		{
			g=x*b+y*p;
			if(b<5) b=5;
			if(p<2) p=2;
			h=(x*b+y*p)*0.8;
			if(g>h){
				printf("%d\n",h);
			}
			else{
				printf("%d\n",g);
			}
		}
	}
	return 0;
}

Measured memory_bytes: 600
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
    	Scanner sc = new Scanner(System.in);
    	int S = sc.nextInt();
    	
    	int h = S / 3600;
    	int m = (S % 3600) / 60;
    	int s = S % 60;
    	
    	String answer = h + ":" + m + ":" + s;
    	
    	System.out.println(answer);
	}
}


Measured memory_bytes: 26368
//(UNCOMMENT WHEN SUBMITTING)
//#pragma GCC optimize("O3")

//(UNCOMMENT WHEN HAVING LOTS OF RECURSIONS)
// #pragma comment(linker, "/stack:200000000")
//(UNCOMMENT WHEN NEEDED)
// #pragma GCC optimize("Ofast,unroll-loops,no-stack-protector,fast-math")
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

#include <bits/stdc++.h>

// clang-format off
#define range(i) for (int _ = 0; _ < i; _++)
#define vprnt(v) for (auto vi : v) cout << vi << " "; cout << endl;
#define fastio() ios::sync_with_stdio(false); cin.tie(0)
#define ll long long
#define all(x) (x).begin(), (x).end()
using namespace ::std;
int nxt() {int x;cin >> x;return x;}
ll nxtll() {ll x;cin >> x;return x;}
// clang-format on

int main() {
    fastio();
    int N = nxt();
    vector<int> L(N);
    generate(all(L), nxt);

    int ans = 0;
    for (int i = 0; i < N; i++) {
        for (int j = i + 1; j < N; j++) {
            for (int k = j + 1; k < N; k++) {
                vector<int> list = {L[i], L[j], L[k]};
                sort(all(list));
                if (list[0] == list[1] || list[1] == list[2])
                    continue;
                if (list[0] + list[1] <= list[2]) {
                } else {
                    ans++;
                }
            }
        }
    }

    cout << ans << endl;

    return 0;
}


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

int main(){
    int n,m; cin >> n >> m;
    vector<vector<int>>vec(m);
    
    for(int i=0;i<m;i++){
        int k;cin >> k;
        for(int j = 0;j<k;j++){
            int s;cin >> s;s--;
            vec[i].push_back(s);
        }
    }
    
    vector<int>p(m);
    for(int i=0;i<m;i++) cin >> p[i];
    
    /*for(int i=0;i<m;i++){
        for(int j = 0;j < vec[i].size() ;j++) cout << vec[i][j] <<" ";
        cout << endl;
    }*/

    //bit探索
    // すべての選び方を試して、総和がKになるものがあるかを調べる

    int ans = 0;
    for (int tmp = 0; tmp < (1 << n); tmp++) {//←ビットを固定
        bitset<10> s(tmp);  
        int on = 0;//onの数

        for(int i=0;i<m;i++){//各電球について、
            int sum = 0;
            for(int k=0;k<vec[i].size();k++){//関連するスイッチを全部見て
                if(s.test(vec[i][k])) sum++;//onなら加える　
            }
            //cout << sum << endl;
            if(sum%2 == p[i]) on++;
        }
        if(on == m)ans++;
    }

    cout << ans << endl;

}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
   int k, x, low, high;

   cin >> k >> x;

   low = x - (k - 1);
   high = x + (k - 1);

   for(int i = low; i <= high; i++){
      cout << i << " ";
   }

   return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cmath>
#include<vector>
#include<string>
#include<queue>
#include<set>
#include<map>
using namespace std;
typedef long long int ll;
typedef vector<pair<ll,ll> > Q;
typedef pair<int,int> P;
#define rep(i,n) for(int i=0;i<(int)(n);i++)

int par[1000000];//親
int ran[200000]; //木の深さ

struct unionfind
{
unionfind(int n) //初期化
{
  rep(i,n)
  {
    par[i]=i;
    ran[i]=0;
  }
}

int root(int x) //木の根を求める
{
  if(par[x]==x) return x;
  else return par[x]=root(par[x]);
}

void unite(int x,int y) //xとyの属する集合を併合
{
  x=root(x);
  y=root(y);
  if(x==y) return;

  if(ran[x]<ran[y]) par[x]=y;
  else
  {
    par[y]=x;
    if(ran[x]==ran[y]) ran[x]++;
  }
}

bool same(int x,int y) //xとyが同じ集合に属するのか
{
    return root(x)==root(y);
}
};



int main()
{
  ll n,m;
  cin>>n>>m;
  ll a[m],b[m];

  rep(i,m) cin>>a[i]>>b[i];

  int cnt=0;
  rep(k,m)
  {
    //kの橋を取り除いて島かどうかを判別する
    unionfind tree(n);
    bool flag=true;
    rep(i,m)
    {
      if(i==k) continue;
      else
      {
        tree.unite(a[i]-1,b[i]-1);
      }
    }

    int tmp=tree.root(0);
    rep(i,n)
    {
      if(tree.root(i)!=tmp)
      {
        cnt++;
        break;
      }
    }
  }

  cout<<cnt<<endl;

}

Measured memory_bytes: 256
use std::io;
use std::io::{BufRead, Write};

fn gcd(a: usize, b: usize) -> usize {
    if b == 0 {
        a
    } else {
        gcd(b, a % b)
    }
}

fn solve<R: BufRead, W: Write>(mut input: R, mut output: W) {
    let mut buf = String::new();
    input.read_line(&mut buf).unwrap();
    let n: usize = buf.trim_right().parse().unwrap();
    for _ in 0..n {
        buf.clear();
        input.read_line(&mut buf).unwrap();
        let mut split = buf.split_whitespace();
        let (a, b, c, d): (usize, usize, usize, usize) = (
            split.next().unwrap().parse().unwrap(),
            split.next().unwrap().parse().unwrap(),
            split.next().unwrap().parse().unwrap(),
            split.next().unwrap().parse().unwrap(),
        );
        let possible = if a < b {
            false
        } else if d < b {
            false
        } else if c >= b {
            true
        } else {
            let initial = a % b;
            let grow = d % b;
            if c < initial {
                false
            } else if grow == 0 {
                true
            } else {
                let gcd = gcd(b, grow);
                let virt_initial = initial % gcd;
                if (b - virt_initial - 1) / gcd > (c - virt_initial) / gcd {
                    false
                } else {
                    true
                }
            }
        };
        writeln!(output, "{}", if possible { "Yes" } else { "No" }).unwrap();
    }
}

fn main() {
    let stdin = io::stdin();
    let stdout = io::stdout();
    solve(stdin.lock(), stdout.lock());
}

#[cfg(test)]
mod tests {
    fn test(input: &str, output: &str) {
        let mut v: Vec<u8> = Vec::new();
        ::solve(input.as_bytes(), &mut v);
        assert_eq!(String::from_utf8(v).unwrap(), output);
    }

    #[test]
    fn case1() {
        test(
            "14
9 7 5 9
9 7 6 9
14 10 7 12
14 10 8 12
14 10 9 12
14 10 7 11
14 10 8 11
14 10 9 11
9 10 5 10
10 10 5 10
11 10 5 10
16 10 5 10
1000000000000000000 17 14 999999999999999985
1000000000000000000 17 15 999999999999999985
",
            "No
Yes
No
Yes
Yes
No
No
Yes
No
Yes
Yes
No
No
Yes
",
        );
    }

    #[test]
    fn case2() {
        test(
            "24
1 2 3 4
1 2 4 3
1 3 2 4
1 3 4 2
1 4 2 3
1 4 3 2
2 1 3 4
2 1 4 3
2 3 1 4
2 3 4 1
2 4 1 3
2 4 3 1
3 1 2 4
3 1 4 2
3 2 1 4
3 2 4 1
3 4 1 2
3 4 2 1
4 1 2 3
4 1 3 2
4 2 1 3
4 2 3 1
4 3 1 2
4 3 2 1
",
            "No
No
No
No
No
No
Yes
Yes
No
No
No
No
Yes
Yes
Yes
No
No
No
Yes
Yes
Yes
No
No
No
",
        );
    }

    #[test]
    fn case3() {
        test(
            "1
20 17 15 19
",
            "No
",
        );
    }
}


Measured memory_bytes: 4352
#include <cassert>
#include <cctype>
#include <climits>
#include <cmath>
#include <cstdio>
#include <ctime>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <vector>
#include <iostream>
#include <algorithm>
#include <functional>
#include <numeric>
#include <string>

using namespace std;

#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
#define pb push_back
#define mp make_pair
#define all(a) (a).begin(),(a).end()
#define debug(x) cout<<#x<<": "<<x<<endl
#define MOD 1000000007

typedef long long ll;
typedef unsigned long long ull;

template <class T, class U> void amax(T& x, U y) {if (x < y) x = y;}
template <class T, class U> void amin(T& x, U y) {if (x > y) x = y;}

int main(void)
{
    const int MAX_N = 100000;
    const int MAX_M = 100000;
    int N, M;
    int balls[MAX_N];
    bool red[MAX_N];
    cin >> N >> M;
    fill(balls, balls + N, 1);
    fill(red, red + N, false);
    red[0] = true;
    REP(i, M) {
        int x, y;
        cin >> x >> y;
        x--;
        y--;
        if (red[x]) {
            if (balls[x] == 1) {
                red[x] = false;
            }
            red[y] = true;
        }
        balls[x]--;
        balls[y]++;
        /*
        debug(i);
        REP(j, N) {
            debug(balls[j]);
        }
        REP(j, N) {
            debug(red[j]);
        }*/
    }
    cout << accumulate(red, red + N, 0) << endl;
    return 0;
}



Measured memory_bytes: 768
#include<iostream>
#include<vector>
#include<algorithm>
#include<cmath>
#include<set>

using namespace std;
using ll = long long;


int main() {
    ll x,y,cnt=0;
    cin >> x >> y;
    if(abs(x)>abs(y)){
        if(x>0) cnt++;
        cnt+=(abs(x)-abs(y));
        if(y>0) cnt++;
    }
    else{
        if(x<0) cnt++;
        cnt+=(abs(y)-abs(x));
        if(y<0) cnt++;
    }
    cout << cnt << endl;
	return 0;
}

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

namespace template
{
    class Program
    {
        static void Main(string[] args)
        {
            new Program().Solve(new ConsoleInput(Console.In, ' '));
        }

        public void Solve(ConsoleInput cin)
        {
            var n = cin.ReadLong;
            var cnt = 0L;

            if (n % 2 == 1)
            {
                Console.WriteLine(0);
                return;
            }

            n /= 2;

            while (n >= 5)
            {
                cnt += n / 5;
                n /= 5;
            }

            Console.WriteLine(cnt);
        }
    }

    public class ConsoleInput
    {
        private readonly System.IO.TextReader _stream;
        private char _separator = ' ';
        private Queue<string> inputStream;
        public ConsoleInput(System.IO.TextReader stream, char separator = ' ')
        {
            this._separator = separator;
            this._stream = stream;
            inputStream = new Queue<string>();
        }
        public string Read
        {
            get
            {
                if (inputStream.Count != 0) 
                {
                    return inputStream.Dequeue();
                }

                string[] tmp = _stream.ReadLine().Split(_separator);
                
                for (int i = 0; i < tmp.Length; ++i)
                {
                    inputStream.Enqueue(tmp[i]);
                }
                return inputStream.Dequeue();
            }
        }
        public string ReadLine { get { return _stream.ReadLine(); }}
        public int ReadInt { get { return int.Parse(Read); }}
        public long ReadLong { get { return long.Parse(Read); }}
        public double ReadDouble { get { return double.Parse(Read); }}
        public string[] ReadStrArray(long N) { var ret = new string[N]; for (long i = 0; i < N; ++i) ret[i] = Read; return ret;}
        public int[] ReadIntArray(long N) { var ret = new int[N]; for (long i = 0; i < N; ++i) ret[i] = ReadInt; return ret;}
        public long[] ReadLongArray(long N) { var ret = new long[N]; for (long i = 0; i < N; ++i) ret[i] = ReadLong; return ret;}
    }
}


Measured memory_bytes: 13268
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define mp make_pair
const int N=3050;
int a[N];
ll dp[N][N];
bool was[N][N];
ll DP(int l, int r)
{
if(was[l][r] || l>r) return dp[l][r];
was[l][r]=1;
dp[l][r]=max(a[l]-DP(l+1,r),a[r]-DP(l,r-1));
return dp[l][r];
}
int main()
{
int n;
scanf("%i",&n);
for(int i=1;i<=n;i++)
scanf("%i",&a[i]);
printf("%lld",DP(1,n));
return 0;
}

Measured memory_bytes: 80384
#include <bits/stdc++.h>
#define int long long
#define double long double
#define INF 1e18
using namespace std;
signed main() {
  int T, D, L;
  while(cin>>T>>D>>L,T+D+L!=0) {
    int ans = 0, elapse = 0;;
    for (int i = 0; i < T; i++) {
      int x; cin >> x;
      if (x >= L) {
        elapse = 1;
        if (i!=T-1) ans++;
      } else {
        if (elapse == D) {
          elapse = 0;
        } else if(elapse != 0) {
          elapse++;
          if (i!=T-1) ans++;
        }
      }
    }  
    cout << ans << endl;
  }
}



Measured memory_bytes: 3064
n = int(input())
h = list(map(int,input().split()))
check = True
h[0] -= 1
for i in range(1,n):
    if h[i]-1 >= h[i-1]:
        h[i] -= 1
    else:
        if h[i] != h[i-1]:
            check = False
if check:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 14396
//  cout << char(i+48) << endl;//なぜかaは47と得る時がある。+48で出力もaにできる。
//  cout << char(97) << endl;//アスキーコードでaを出力
// sort(b.begin(), b.end());//bという配列を小さい方からソート
// reverse(b.begin(), b.end());//bという配列をリターン
// 10桁でdouble出力するパターン１ 
// printf("%.10f\n", ma);
// 10桁でdouble出力するパターン２
//cout << fixed << setprecision(10);
//  cout << ma << endl;

/*01 02 03 12 13 23　と６回見ていくパターン 
for(int i=0;i<n-1;i++){
  for(int j=i+1;j<n;j++){
    }
  }
*///vector<vector<int>> data(3, vector<int>(4));//int型の2次元配列(3×4要素の)の宣言
//int64_t a;
//10のi乗pow(10, i);
/*string s; stringでの文字列を数字型に変える方法
  cin >> s;
  rep(i,s.size()-2) {
  int a= (s.at(i)-'0')*100 + (s.at(i+1)-'0')*10+ s.at(i+2) -'0';
    */
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int main() {
  int a,b,c,d;
  cin >> a >> b >> c >> d;
  vector<int>x(101);
  vector<int>y(101);
  for(int i=a;i<=b;i++){
    x.at(i)++;
  }
  for(int i=c;i<=d;i++){
    y.at(i)++;
  }
  int count = 0;
  for(int i=0;i<=100;i++){
    if(x.at(i) == 1 && y.at(i) ==1)count++;
  }
  if(count >0)cout << count - 1 <<endl;
  else  cout << count << endl;
}


Measured memory_bytes: 256