akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define LL long long
#define db double

using namespace std;
const int N=5e5+10,mod=998244353;
int rd()
{
    int x=0,w=1;char ch=0;
    while(ch<'0'||ch>'9'){if(ch=='-') w=-1;ch=getchar();}
    while(ch>='0'&&ch<='9'){x=x*10+(ch^48);ch=getchar();}
    return x*w;
}
void ad(int &x,int y){x+=y,x-=x>=mod?mod:0;}
int fpow(int a,int b){int an=1;while(b){if(b&1) an=1ll*an*a%mod;a=1ll*a*a%mod,b>>=1;}return an;}
int ginv(int a){return fpow(a,mod-2);}
int n,k,fac[N],iac[N];
int C(int a,int b){return b<0||a<b?0:1ll*fac[a]*iac[b]%mod*iac[a-b]%mod;}

int main()
{
/////bslysmznyxxl,qdl
	fac[0]=1;
	for(int i=1;i<=N-5;++i) fac[i]=1ll*fac[i-1]*i%mod;
	iac[N-5]=ginv(fac[N-5]);
	for(int i=N-5;i;--i) iac[i-1]=1ll*iac[i]*i%mod;
	n=rd(),k=rd();
	if(n>k){puts("0");return 0;}
	int ans=0;
	for(int i=n,j=k-n;i<=k;++i,--j)
	{
		if(i>j)
		{
			ad(ans,C(k,j));
			if(i-j<=n) ad(ans,mod-C(k,j-(i-n+1)));
		}
		else if(i==j)
			ad(ans,C(k-1,j-1)),ad(ans,mod-C(k-1,j-1-(i-n+1)));
	}
	printf("%d\n",ans);
	return 0;
}


Measured memory_bytes: 4096
# include <iostream>
# include <cstdio>
using namespace std;
int main(void)
{
	int n,a[100],j;
	scanf("%d",&n);
	for(int i = 0;i < n;i++) scanf("%d",&a[i]);
	for(int i = 0;i < n;i++)
	{
		int tem = a[i];
		for(j = i-1;j >= 0;j--)
		{
			if(tem >= a[j]) break;
			a[j+1] = a[j];
		}
		a[j+1] = tem;
		for(int w = 0;w < n;w++) printf("%d%c",a[w],(w == n-1?'\n':' '));
	}
	return 0;
}


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

import javax.swing.text.DefaultEditorKit.InsertBreakAction;

public class Main {
	static final String INSERT = "insert";
	static final String FIND  = "find";	
	
	static Map<String, Boolean> dictMap = new HashMap<>(1000000);
	
	
	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		int count = scanner.nextInt();
		
		for (int i = 0; i < count; i++) {
			String command = scanner.next();
			if (command.equals(INSERT)) {
				insert(scanner.next());
			}else if (command.equals(FIND)) {
				System.out.println(find(scanner.next()));
			}
		}
	}
	
	static void insert(String string){
		dictMap.put(string, true);
	}

	static String find(String string){
		if(dictMap.get(string) != null)
			return "yes";
		return "no";
	}
}

Measured memory_bytes: 266040
#include<stdio.h>
int main(void)
{
	int n;
	int i,j,k,temp;
	int flg;
	int ba,a;
	int tc[101],hc[101],tn,hn;
	
	scanf("%d",&n);
	while(n!=0){
		for(i=0;i<n;i++){
			scanf("%d",&tc[i]);
		}
		k=0;
		for(i=1;i<=2*n;i++){
			flg=0;
			for(j=0;j<n;j++){
				if(i==tc[j]){
					flg=1;
				}
			}
			if(flg==0){
				hc[k]=i;
				k++;
			}
		}
		ba=0;
		a=1;
		tn=n;
		hn=n;
		for(i=0;i<n-1;i++){
			for(j=i+1;j<n;j++){
				if(tc[i]>tc[j]){
					temp=tc[i];
					tc[i]=tc[j];
					tc[j]=temp;
				}
			}
		}
		while(tn!=0 && hn!=0){
			flg=0;
			if(a%2==1){
				a++;
				for(i=0;i<n;i++){
					if(ba<tc[i]){
						ba=tc[i];
						tc[i]=0;
						tn--;
						flg=1;
						break;
					}
				}
				if(flg==0){
					ba=0;
				}
			}
			else {
				a++;
				for(i=0;i<n;i++){
					if(ba<hc[i]){
						ba=hc[i];
						hc[i]=0;
						hn--;
						flg=1;
						break;
					}
				}
				if(flg==0){
					ba=0;
				}
			}
		}
		printf("%d\n%d\n",hn,tn);
		scanf("%d",&n);
	}
	return 0;
}

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

int main()
{
    string s;
    cin >> s;
    int cnt = 0, res = 0;
    for(auto c : s){
        if(c == 'A' || c == 'T' || c == 'C' || c == 'G'){
            ++cnt;
        }
        else{
            cnt = 0;
        }
        res = max(res, cnt);
    }
    cout << res << endl;
    return 0;
}


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

// lib/detail/ceil_and_floor.hpp
#ifndef DETAIL_CEIL_AND_FLOOR_HPP
#define DETAIL_CEIL_AND_FLOOR_HPP

namespace tools {
  template <typename T>
  constexpr T floor(T lhs, T rhs);

  template <typename T>
  constexpr T ceil(T lhs, T rhs);

  template <typename T>
  constexpr T floor(const T lhs, const T rhs) {
    return
      lhs >= 0 && rhs >= 0 ?
        lhs / rhs :
      lhs < 0 && rhs >= 0 ?
        -ceil<T>(-lhs, rhs) :
      lhs >= 0 && rhs < 0 ?
        -ceil<T>(lhs, -rhs) :
        floor<T>(-lhs, -rhs);
  }

  template <typename T>
  constexpr T ceil(const T lhs, const T rhs) {
    return
      lhs >= 0 && rhs >= 0 ?
        (lhs - 1 + rhs) / rhs :
      lhs < 0 && rhs >= 0 ?
        -floor<T>(-lhs, rhs) :
      lhs >= 0 && rhs < 0 ?
        -floor<T>(lhs, -rhs) :
        ceil<T>(-lhs, -rhs);
  }
}

#endif

// lib/floor.hpp
#ifndef FLOOR_HPP
#define FLOOR_HPP


/*
usage:

tools::floor(5, 3) // => 1 (i.e., floor(5 / 3))
*/

#endif

// lib/ceil.hpp
#ifndef CEIL_HPP
#define CEIL_HPP


/*
usage:

tools::ceil(5, 3) // => 2 (i.e., ceil(5 / 3))
*/

#endif

// main.cpp

int main() {
  std::uint_fast64_t a, b;
  std::cin >> a >> b;

  std::uint_fast64_t answer = 0;
  if (a / 4 == b / 4) {
    for (std::uint_fast64_t i = a; i <= b; ++i) {
      answer ^= i;
    }
  } else {
    if (a % 4 > 0) {
      for (std::uint_fast64_t i = a; i < tools::ceil<std::uint_fast64_t>(a, 4) * 4; ++i) {
        answer ^= i;
      }
    }
    if (b % 4 < 3) {
      for (std::uint_fast64_t i = tools::floor<std::uint_fast64_t>(b, 4) * 4; i <= b; ++i) {
        answer ^= i;
      }
    }
  }

  std::cout << answer << std::endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define rep(X,N) for(ll X = 0; X < (N); X++)
#define PI (acos(-1.0))
#define pback push_back
#define mpair make_pair
#define divceil(A, B) ((A + (B - 1)) / B)
#define MODN 1000000007
#define ALL(V) (V).begin(),(V).end()
#define CERR if(false) cerr

using namespace std;

int main(){

    int n;
    cin >> n;

    vector<ll> v;

    v.pback(2);
    v.pback(1);

    for(int i = 2; i <= n; i++){
        v.pback(v[i - 2] + v[i - 1]);
    }

    cout << v[n] << endl;


    return 0;
}

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

#define FOR(i,l,r) for(int i = (l);i < (r);i++)
#define ALL(x) (x).begin(),(x).end()
template<typename T> bool chmax(T& a,const T& b){return a < b ? (a = b,true) : false;}
template<typename T> bool chmin(T& a,const T& b){return b < a ? (a = b,true) : false;}
typedef long long ll;

int N;

int main()
{
	scanf("%d",&N);
	vector<ll> A(N);
	ll xor_all = 0;
	set<ll> right_most;
	FOR(i,0,N){
		scanf("%lld",&A [i]);
		xor_all ^= A [i];
		right_most.insert(A [i] & -A [i]);
	}
	if(xor_all == 0){
		printf("0\n");
		return 0;
	}

	ll ans = 0;
	for(ll i = 31;i >= 0;i--) if(xor_all >> i & 1){
		if(right_most.count(1ll << i)){
			xor_all ^= (1ll << (i + 1)) - 1;
			ans++;
		}
		else{
			printf("-1\n");
			return 0;
		}
	}

	printf("%lld\n",ans);

	return 0;
}


Measured memory_bytes: 1024
#include<iostream>
#include<algorithm>
#include<math.h>
#include<vector>
#include<map>

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

using namespace std;
using ll = long long;
using ull = unsigned long long;
using P = pair<int, int>;

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

    map<string, int> mp;

    rep(i, N) {
        string s; cin >> s;
        mp[s]++;
    }

    int M; cin >> M;
    
    rep(i, M) {
        string t; cin >> t;
        mp[t]--;
    }
    
    int ans = -100;
    for (auto iter = mp.begin(); iter != mp.end(); iter++) {
        ans = max(ans, iter -> second);
    }

    ans = max(ans, 0);

    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
N = int(input())
A = [int(input()) for _ in range(N)]

mp = {}
for i, j in enumerate(A):
	mp[j] = i % 2
	
A.sort()

ans = 0
for i, j in enumerate(A):
	if i % 2 != mp[j]: ans += 1

print(ans // 2)

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

int main() {
    int N,D;
    cin >> N >> D;
    int first = D+1;
    int last = first + D;
    int lastind = first;
    int count = 1;
    while(last < N){
        lastind += 2*D+1;
      	last = lastind + D;
        count += 1;
    }
    cout << count << endl;
}

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

int main()
{
	int n;
	cin>>n;
	int a[n],s=0;
	for(int i=0;i<n;i++){
		cin>>a[i];
		s=s+a[i];
	}
	int m;
	cin>>m;
	int b[m],t[m],r[m];
	for(int i=0;i<m;i++)
	{
		cin>>b[i]>>t[i];
		r[i]=s-a[b[i]-1]+t[i];
		
	}
	for(int i=0;i<m;i++)
	{
		cout<<r[i]<<endl;
	}
}

	
	


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <iomanip>
#include <stack>
#include <queue>
#include <numeric>
#include <map>
#include <unordered_map>
#include <set>
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define pb push_back
#define mod 1000000007
using ll = long long;
using namespace std;

int main(){
  int H, W; cin >> H >> W;
  vector<vector<int>> a(H,vector<int>(W));
  vector<vector<bool>> used(H,vector<bool>(W,false));
  vector<pair<int,int>> ans_from;
  vector<pair<int,int>> ans_to;
  rep(y,H) rep(x,W) cin >> a[y][x];
  rep(y,H) rep(x,W){
    if(a[y][x]%2==1){
      if(y!=0 && (!used[y-1][x])){
        ans_from.pb({y+1,x+1});
        ans_to.pb({y-1+1,x+1});
        a[y][x]--;
        a[y-1][x]++;
      }
      else if(x!=0 && (!used[y][x-1])){
        ans_from.pb({y+1,x+1});
        ans_to.pb({y+1,x-1+1});
        a[y][x]--;
        a[y][x-1]++;
      }
      else if(x!=W-1){
        ans_from.pb({y+1,x+1});
        ans_to.pb({y+1,x+1+1});
        a[y][x]--;
        a[y][x+1]++;
      }
      else if(y!=H-1){
        ans_from.pb({y+1,x+1});
        ans_to.pb({y+1+1,x+1});
        a[y][x]--;
        a[y+1][x]++;
      }
    }
    used[y][x] = true;
  }
  int N = (int)ans_from.size();
  cout << N << endl;
  rep(i,N){
    cout << ans_from[i].first << " " << ans_from[i].second << " " << ans_to[i].first << " " << ans_to[i].second << endl;
  }
  return 0;
}


Measured memory_bytes: 5356
# include <iostream>
# include <algorithm>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <utility>
# include <stack>
# include <queue>
# include <list>
using namespace std;
using LL = long long;
constexpr long long MOD = 1000000000 + 7;
constexpr long long INF = 1000000000;
const double PI = acos(-1);

int main() {
	int a;
	char c;
	cin >> a;
	int ans = a;

	while (cin >> c) {
		if (c == '=') {
			cout << ans << endl;
			break;
		}
		else cin >> a;
		if (c == '+')ans += a;
		if (c == '-')ans -= a;
		if (c == '*')ans *= a;
		if (c == '/')ans /= a;
	}
}

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

long long mod(long long val, long long m) {
  long long res = val % m;
  if (res < 0) res += m;
  return res;
}

bool is_prime(long long N) {
    if (N == 1) return false;
    for (long long i = 2; i * i <= N; ++i) {
        if (N % i == 0) return false;
    }
    return true;
}

int main() {
  string S,ans;
  cin >>  S;
  
  if(S[S.size()-1]=='s') ans = S + "es";
  else ans = S + "s";
  cout << ans << endl;
  
  return 0;
}


Measured memory_bytes: 3596
N = int(input())
P = list(map(int,input().split(' ')))
num = 0
for i in range(1,N-1):
  if min(P[i-1],P[i+1]) < P[i]  and P[i] <max(P[i-1],P[i+1]):
    num += 1
print(num)


Measured memory_bytes: 2940
#include <iostream>
#include <string>
#include <algorithm>
#include <utility>
#include <iomanip>
#include <functional>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <vector>
#include <cmath>
#include <cctype>
#include <cstdio>
#include <bitset>
#include <complex>
#define ll long long
#define INF 1000000000000000001
#define MOD 1000000007
using namespace std;

int main(){
    ll k;
    cin >> k;
    
    ll temp = 7;
    
    temp %=k;
    for(ll i=0; i<=k*10; i++){
        if(temp == 0){
            cout<<i+1<<endl;
            return 0;
        }
        temp *= 10;
        temp += 7;
        temp%=k;
    }
    cout<<-1<<endl;
    return 0;
}


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

using ll = long long;
using ull = unsigned long long;

#define MOD 1000000007

int main(void) {
    string S;
    string prev;
    ll count = 0;
    cin >> S;
    for(ll i = 0;i < S.size();i++) {
        for(ll j = i + 1;j < S.size() + 1;j++) {
            string temp = string(S.begin() + i, S.begin() + j);
            if(prev != temp) {
                count++;
                i = j - 1;
                prev = temp;
                break;
            }
        }
    }
    cout << count << endl;
    return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <iomanip>
#include <map>
using namespace std;

void solve(){
  int n, q; cin >> n >> q;
  string s; cin >> s;
  int l[q], r[q], ans[q];
  for(int i = 0; i < q; i++) cin >> l[i] >> r[i];
  int a[n + 1];
  int sum = 0;
  for(int i = 0; i < n; i++){
    a[i + 1] = sum;
    if(s[i] == 'A' && s[i + 1] == 'C') sum++;
  }
  for(int i = 0; i < q; i++){
    ans[i] = a[r[i]] - a[l[i]];
  }
  for(int i = 0; i < q; i++) cout << ans[i] << endl;
}

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


Measured memory_bytes: 2560
#include<stdio.h>
#include<math.h>

int main(){
    int i;
    double n, x[10000], y[10000], d1 = 0, d2 = 0, d3 = 0, dinf = 0, tmp = 0;
    scanf("%lf", &n);
    for(i = 0; i < n; i++) scanf("%lf", &x[i]);
    for(i = 0; i < n; i++) scanf("%lf", &y[i]);

    for(i = 0; i < n; i++) d1 += fabs(x[i] - y[i]);
    for(i = 0; i < n; i++) d2 += pow(x[i] - y[i], 2);
    d2 = sqrt(d2);
    for(i = 0; i < n; i++) d3 += pow(fabs(x[i] - y[i]), 3);
    d3 = cbrt(d3);
    tmp = fabs(x[0] - y[0]);
    for(i = 0; i < n; i++){
        if(tmp < fabs(x[i] - y[i])) tmp = fabs(x[i] - y[i]);
    }
    dinf = tmp;
    printf("%lf\n%lf\n%lf\n%lf\n", d1, d2, d3, dinf);
    return 0;
}


Measured memory_bytes: 2104
#include <iostream>
#include <algorithm>
#include <cstdlib>
using namespace std;

int main(){
  int N;
  int w[110];
  
  cin >> N;
  int sum = 0;
  for(int i = 0; i < N; i++){
    cin >> w[i];
    sum += w[i];
  }
  
  int min = 10e9;
  for(int i = 0; i < N; i++){
    int front = 0;
    int back = 0;
    for(int k = 0; k <= i; k++) front += w[k];
    back = sum - front;
    int temp_min = abs(front - back);
    if(min > temp_min) min = temp_min;
  } 
  cout << min << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;++i)
#define all(x) (x).begin(),(x).end()
using namespace std;
const int INF=1145141919,MOD=1e9+7;
const int64_t LINF=8931145141919364364,LMOD=998244353;
// const int dy[]={0,-1,0,1,1,-1,-1,1};
// const int dx[]={1,0,-1,0,1,1,-1,-1};

int n, k;
int a[200010];

bool f(int val) {
	int64_t sum = 0;
	for(int i = 0; i < n; ++i) {
		sum += (a[i] - 1) / val;
	}
	return sum <= k;
}

int main() {
	cin >> n >> k;
	rep(i,n) cin >> a[i];
	int ok = INF, ng = 0;
	while(abs(ok - ng) > 1) {
		int mid = (ok + ng) / 2;
		if(f(mid)) {
			ok = mid;
		} else {
			ng = mid;
		}
	}
	cout << ok << '\n';
	return 0;
}

Measured memory_bytes: 4300
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner s = new Scanner(System.in);
		int H = s.nextInt();
		int W = s.nextInt();
		String sl = null;
		String[] sa = new String[W];
		String[][] sda = new String[H][W];

		boolean b = true;

		for (int i = 0; i < H; i++) {
			sl = s.next();
			sa = sl.split("");
			for (int j = 0; j < W; j++) {
				sda[i][j] = sa[j];
			}
		}

		/**/
		for (int h = 0; h < H; h++) {
			for (int w = 0; w < W; w++) {
				if (b) {
					if (sda[h][w].equals("#")) {
						/*100
						000
						000*/
						if (h == 0 && w == 0) {
							if (sda[h][w + 1].equals("#") ||
									sda[h + 1][w].equals("#")) {
							} else {
								b = false;
								break;
							}
						}
						/*001
						000
						000*/
						else if (h == 0 && w == W - 1) {
							if (sda[h][w - 1].equals("#") ||
									sda[h + 1][w].equals("#")) {
							} else {
								b = false;
								break;
							}
						}
						/*000
						000
						100*/
						else if (h == H - 1 && w == 0) {
							if (sda[h - 1][w].equals("#") ||
									sda[h][w + 1].equals("#")) {
							} else {
								b = false;
								break;
							}
						}
						/*000
						000
						001*/
						else if (h == H - 1 && w == W - 1) {
							if (sda[h][w - 1].equals("#") ||
									sda[h - 1][w].equals("#")) {
							} else {
								b = false;
								break;
							}
						}
						/*010
						000
						000*/
						else if (h == 0) {
							if (sda[h][w - 1].equals("#") ||
									sda[h][w + 1].equals("#") ||
									sda[h + 1][w].equals("#")) {
							} else {
								b = false;
								break;
							}
						}
						/*000
						000
						010*/
						else if (h == H - 1) {
							if (sda[h][w - 1].equals("#") ||
									sda[h - 1][w].equals("#") ||
									sda[h][w + 1].equals("#")) {
							} else {
								b = false;
								break;
							}
						}
						/*000
						100
						000*/
						else if (w == 0) {
							if (sda[h - 1][w].equals("#") ||
									sda[h][w + 1].equals("#") ||
									sda[h + 1][w].equals("#")) {
							} else {
								b = false;
								break;
							}
						}
						/*000
						001
						000*/
						else if (w == W - 1) {
							if (sda[h][w - 1].equals("#") ||
									sda[h - 1][w].equals("#") ||
									sda[h + 1][w].equals("#")) {
							} else {
								b = false;
								break;
							}
						}
						/*000
						010
						000*/
						else {
							if (sda[h][w - 1].equals("#") ||
									sda[h - 1][w].equals("#") ||
									sda[h][w + 1].equals("#") ||
									sda[h + 1][w].equals("#")) {
							} else {
								b = false;
								break;
							}
						}
					}
				}
			}
		}
		String ans = b ? "Yes" : "No";
		System.out.println(ans);
	}

}


Measured memory_bytes: 21972
#include <algorithm>
#include<iostream>
#include<vector>
#include<map>
#include<set>
#include<string>

#include<stdlib.h>
#include<string.h>
#include<math.h>
#include<limits.h>
using ll = long long;
using ull = unsigned long long;
using namespace std;
int main(){
  string s;
  cin >> s;
  int ret[26];
  int ii;
  memset(ret,0,sizeof(int)*26);

  for(ii=0;ii<4;ii++){
    ret['Z'-s[ii]]++;
  }
  
  int len=0;
  for(ii=0;ii<26;ii++){
    //cout << "ii:" << ii << "ret:" << ret[ii] << endl;
    if(ret[ii] == 2){
      len++;
    }
  }
  if(len == 2){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
  return 0;
}


Measured memory_bytes: 256
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        C solver = new C();
        solver.solve(1, in, out);
        out.close();
    }

    static class C {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int N = Integer.parseInt(in.next());
            int preT = 0;
            int preX = 0;
            int preY = 0;

            for (int i = 0; i < N; i++) {
                int postT = Integer.parseInt(in.next());
                int postX = Integer.parseInt(in.next());
                int postY = Integer.parseInt(in.next());

                int dt = postT - preT;
                int dist = Math.abs(postX - preX) + Math.abs(postY - preY);
                if ((dt < dist) || ((dist - dt) % 2 != 0)) {
                    out.println("No");
                    return;
                }

                preT = postT;
                preX = postX;
                preY = postY;
            }

            out.println("Yes");
        }

    }
}



Measured memory_bytes: 57756
#pragma GCC optimize(2)
#include<bits/stdc++.h>
#define ll long long
#define maxn 1000005
#define inf 1e9
#define pb push_back
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define per(i,a,b) for(int i=a;i>=b;i--)
using namespace std;

inline ll read()
{
	ll x=0,w=1; char c=getchar();
	while(c<'0'||c>'9') {if(c=='-') w=-1; c=getchar();}
	while(c<='9'&&c>='0') {x=(x<<1)+(x<<3)+c-'0'; c=getchar();}
	return w==1?x:-x;
}

ll a[maxn],n,x[maxn],suf[maxn];

int main()
{
	n=read();
	rep(i,0,n) a[i]=read(); x[n]=a[n];
	if(n==0)
	{
		if(a[0]==1) puts("1");
		else puts("-1"); return 0;
	}
	for(int i=n-1;i>=1;i--) suf[i]=suf[i+1]+a[i];
	if(a[0]!=0) return puts("-1"),0;
	ll nw=1,ans=1;
	for(int i=1;i<n;i++)
	{
		nw=nw*2;
		if(nw<a[i]) {return puts("-1"),0;}
		if(nw-suf[i]>a[n]) nw=a[n]+suf[i];
		ans+=nw; nw-=a[i];
	}
	if(nw<=a[n]&&2*nw>=a[n]) cout<<ans+a[n]<<endl;
	else puts("-1");
	return 0;
}

Measured memory_bytes: 5164
O = input()
E = input()
l = min(len(O),len(E))
s = ""
for i in range(l):
  s = s+O[i]+E[i]
  
if s[2*(l-1)] == O[len(O)-1]:
  print(s)
else:
  print(s+O[len(O)-1])

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int m,g,t=0,k=0,h;cin>>m;
    if(m==1)cout<<1;
    else {
    for(int i=2;i<=m;i++){
            h=i;
        while(h>0&&h%2==0){
                h/=2;
                t++;
        }
        if(t>k){
            k=t;
            g=i;
        }
        t=0;
    }
    cout<<g<<endl;
    }
   return 0;
   }

Measured memory_bytes: 3596
#include<iostream>
#include<cstdio>
using namespace std;
long long n,m,h;
int main()
{
	cin>>n>>m;
	h=min(n,m/2);
	m=m-n*2;n=0;
	m=max(m,n);
	cout<<h+m/4;
	return 0;
} 

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define fi first
#define se second
#define pb push_back
#define mp make_pair
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; }
const int INF = 1<<30;
const ll LINF = 1LL<<58;
const ll mod = 1000000007;

int main(){
    int n, h, w;
    cin >> n >> h >> w;
    cout << (n-h+1) * (n-w+1) << endl;
    return 0;
}



Measured memory_bytes: 256
from bisect import *
from collections import *

N = int(input())
A = list(map(int, input().split()))
C = defaultdict(int)
C[A[0]] = 1
ans = 0
for i in range(1, N):
    ans += C[i-A[i]]
    C[i+A[i]] += 1
print(ans)

Measured memory_bytes: 133016
#include<iostream>
	#include<vector>
	#include<algorithm>
	#include<string>
	#include<cmath>
	#include<map>
	#include<cstdio>
	#include<stack>
	#include<queue>
	#include<fstream>
	#include<cstdio>
	#include<deque>
	#include<iomanip>
	#include <numeric>
	//#include<bits/stdc++.h>

	using namespace std;
	#define ok1 printf("ok1\n");
	#define ok2 printf("ok2\n");
	#define M 1000000000000000000LL
	#define rep(i,n) for(int i=0;i<n;i++)
	#define REP(i,s,n) for(int i=(s);i<(n);i++)
	#define repr(i,n) for(int i=n-1;i>=0;i--)
	#define REPR(i,s,n) for(int i=(s);i>=(n);(i)--)
	#define all(a) (a).begin(),(a).end()
	#define reall(a) (a).rbegin(),(a).rend()
	#define pb push_back
	#define pf push_front
	#define MIN(a,b) a=min((a),(b))
	#define MAX(a,b) a=max((a),(b))
	#define SIZE(v) (int)v.size()
	const double pi = acos(-1.0);

	typedef vector<int> vi;
	typedef vector<string> vs;
	typedef long long ll;
	typedef vector<ll> vll;
	typedef vector<vi> vvi;
	typedef vector<vll> vvll;
	typedef deque<ll> dll;
	typedef pair<ll, ll> P;
	const ll mod = 1e9 + 7;
	ll dx[4] = {1,0,-1,0};
	ll dy[4] = {0,1,0,-1};


	int main() {
		cin.tie(0);
		ios::sync_with_stdio(false);
		
		string s;
		cin >> s;
		string ans="";
		rep(i, s.size()) {
			if (s[i] == 'B') {
				if (ans.size()) ans.pop_back();
			}
			else ans.push_back(s[i]);
		}
		cout << ans << endl;
		return 0;
	}	
	

Measured memory_bytes: 256
package main

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

var nextReader func() string

func newScanner() func() string {
	sc := bufio.NewScanner(os.Stdin)
	sc.Buffer(make([]byte, 1024), int(1e11))
	sc.Split(bufio.ScanWords)
	return func() string {
		sc.Scan()
		return sc.Text()
	}
}

func nextString() string { return nextReader() }

func nextInt() int { n, _ := strconv.Atoi(nextReader()); return n }


func f(H int) int {
	if H > 1 {
		return 2*f(H/2) + 1
	}
	return 1
}

func main() {
	nextReader = newScanner()
	H := nextInt()
	fmt.Println(f(H))
}

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

#define ll long long
#define ld long double
#define db double
#define str string
#define pb push_back
#define nl '\n'
#define X first
#define Y second
#define nimble ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define all(v) (v).begin(),(v).end()
#define rall(v) rbegin(v),rend(v)
#define selp(a) for(auto i:a)cout<<i<<" ";cout<<nl;
#define mod(x,m) ((((x)%(m))+(m))%(m))
#define _sz(x) (int)x.size()
#define rep(i,a,b) for(int i=a;i<b;i++)
#define repv(v) for(int i=0;i<_sz(v);i++)
#define rep1(i,b,a) for(int i=b;i>=a;i--)
#define preci(x) fixed<<setprecision(x)

#define TRACE
#ifdef TRACE
#define see(...) __f(#__VA_ARGS__,__VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
	cerr<<name<<" : "<<arg1<<nl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma=strchr(names+1,',');cerr.write(names,comma-names)<<" : "<<arg1<<" | ";__f(comma+1, args...);
}
#else
#endif

int inf=0x3f3f3f3f;
ll infl=0x3f3f3f3f3f3f3f3fLL;
ld infd=1.0/0.0;
const ll MOD=1e9+7;// 998244353 // = (119<<23)+1
const db pi=2*acos(0.0);

int main(){
    nimble;
    int tt=1;//cin>>tt;
    while(tt--){
        ll l;
        cin>>l;
        double x=l/3.0;
        x=x*x*x;
        cout<<preci(10)<<x<<nl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
using ll = long long;
int main(){
    string s;
    cin >> s;
    int cnt=0, n=s.size();
    for(int i=0; i<n/2; i++){
        if(s.at(i) != s.at(n-1-i)) cnt++;
    }
    cout << cnt << endl;
}

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

using namespace std;

template<typename T>
class RangeAddQuery {
public:
    explicit RangeAddQuery(int n) : N(calcN_(n)) {
        mVal.assign(2*N+1, 0);
    }
    void update(int l, int r, T value){
        l = max(0, l);
        r = min(N, r);
        int offset = N;
        while(offset > 0){
            if(l >= r) break;
            if(l&1){ update_(mVal[offset+l-1], value); l++; }
            if(r&1){ update_(mVal[offset+r-2], value); }
            l /= 2;
            r /= 2;
            offset /= 2;
        }
    }
    T get(int idx){
        int i = N + idx - 1;
        auto res = mVal[i];
        while(i > 0){
            i = (i-1)/2;
            update_(res, mVal[i]);
        }
        return res;
    }
private:
    int calcN_(int n){
        int res = 1;
        while(res < n) res *= 2;
        return res;
    }
    inline void update_(T& data, T val) { data += val; }
    const int N;
    vector<T> mVal;
};


int main(){
    int n, q;
    while(cin >> n >> q){
        RangeAddQuery<int> raq(n+1);
        for(int i=0;i<q;i++){
            int c; cin >> c;
            if(c == 0){
                int s, t, x; cin >> s >> t >> x;
                raq.update(s, t+1, x);
            } else {
                int p; cin >> p;
                cout << raq.get(p) << endl;
            }
        }
    }
}



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

int main() {
  string S, T;
  cin >> S;
  cin >> T;

  //cout << S.substr(0, T.length()) << endl;
  int max = 0;
  for(int i = 0; i+T.length() <= S.length(); i++){
    int icchi = 0;
    for(int j = 0; j < T.length(); j++){
      if(T[j] == S[i+j]){
        icchi++;
      }
    }
    if(icchi > max){
      max = icchi;
    }
  }

  cout << T.length()-max << endl;

  /*int N = 3;
  vector<int> vec(N);
  for (int i = 0; i < N; i++) {
    cin >> vec.at(i);
  }*/

  /*for (int i = 0; i < vec.size(); i ++){
    cout << vec.at(i) << endl;
  }

  for (int i = 0; i < vec.size()-1; i ++){
    cout << vec.at(i) << " ";
  }
  cout << vec.at(vec.size() - 1) << endl;*/
}


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

#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define repk(i,m,n) for(int i=m;i<n;i++)
typedef long long ll;
using namespace std;
int main()
{
    ll n,m,x;
    ll cnt=0;
    cin>>n>>m;
    priority_queue<ll> p;
    rep(i,n)
    {
        ll temp;
        cin>>temp;
        p.push(temp);
        x+=temp;
    }
    while(m--)
    {
        ll k=p.top();
        if(!k)
        {
            cout<<0;
            return 0;
        }
        p.pop();
        p.push(k/2);
        x-=k-k/2;
    }
    cout<<x;
}


Measured memory_bytes: 1400
s=input()
newstring=''.join(list(reversed(s)))

while len(newstring)>0:
    if newstring[:5]=="maerd":
        newstring=newstring[5:]

    elif newstring[:7]=="remaerd":
        newstring=newstring[7:]

    elif newstring[:5]=="esare":
        newstring=newstring[5:]

    elif newstring[:6]=="resare":
        newstring=newstring[6:]

    else:
        print("NO")
        exit()

print("YES")

Measured memory_bytes: 3956
#include<bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
int main(){
    #ifndef ONLINE_JUDGE
        freopen("input.txt","r",stdin);
        freopen("output.txt","w",stdout);
    #endif
    int n;
    cin>>n;
    cout<<2*n/gcd(2,n);
  	return 0;
}

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


/*
    LCM : Least Common multiple
*/


template<typename T> T LCM(T a, T b) {
    if (a > b) swap(a, b);
    T r = a%b, c = a, d = b;
    while (r != 0) {a = b; b = r; r = a%b; }
    return c/b*d;
}


int main() {
    int N, ans = 1;
    cin >> N;
    
    for (int i = 0; i < N; i++) {
        int a;
        cin >> a;
        ans = LCM(ans, a);
    }
    
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3116
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <utility>
#include <algorithm>
#include <cstdio>
#include <iomanip>
#include <queue>
#include <deque>
#include <stack>
#include <fstream>
#include <cmath>

#define ll int64_t
#define Rep(i, n) for (ll i = 0; i < n; i++)
using namespace std;
typedef vector<ll> vec;
typedef vector<vec> mat;

template<class T> inline void chmin(T& a, T b) {
    if (a > b) {
        a = b;
    }
}
template<class T> inline void chmax(T& a, T b) {
    if (a < b) {
        a = b;
    }
}

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

    ll N, C;
    cin >> N >> C;
    vector<pair<ll, ll>> sushi(N+2);
    sushi[0].first = 0;
    sushi[0].second = 0;
    sushi[N+1] = make_pair(C, 0);
    Rep (i, N) {
        cin >> sushi[i+1].first >> sushi[i+1].second;
    }

    vec s(N+3, 0), f(N+3, 0), g(N+3, 0), sr(N+3, 0), fr(N+3, 0), gr(N+3, 0);
    ll ans = 0;
    Rep (i, N+2) {
        s[i+1] = s[i] + sushi[i].second;
        f[i+1] = s[i+1] - sushi[i].first;
        g[i+1] = max(g[i], f[i+1]);
    }

    for (ll i = N+2; i > 0; i--) {
        sr[i-1] = sr[i] + sushi[i-1].second;
        fr[i-1] = sr[i-1] - (C - sushi[i-1].first);
        gr[i-1] = max(gr[i], fr[i-1]);
    }

    ll tmp = 0;
    for (ll i = N+1; i >= 0; i--) {
        tmp += sushi[i].second;
        chmax(ans, tmp - 2 * (C-sushi[i].first) + g[i]);
    }

    tmp = 0;
    for (ll i = 0; i <= N+1; i++) {
        tmp += sushi[i].second;
        chmax(ans, tmp - 2 * sushi[i].first + gr[i+1]);
    }

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

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

int main() {
	int n;
	while (cin >> n) {
		if (n == 0)
			break;
		double sum1 = 0;
		double sum2 = 0;
		vector<double>V(n);
		for (int i = 0; i < n; i++) {
			cin >> V[i];
			sum1 += V[i];
		}
		double m = sum1 / n;

		for (int i = 0; i < n; i++) {
			sum2 += (V[i] - m) * (V[i] - m);
		}
		printf("%.10f\n", sqrt(sum2 / n));
	}
}



Measured memory_bytes: 3188
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner s = new Scanner(System.in);
		int n = s.nextInt();
		String b = s.next();
		int sum = 0;
		int max = 0;

		int i = 0;

		String ary[] = new String[n];

		for (i = 0; i < n; i++) {
			ary[i] = b.charAt(i) + "";

		}

		i = 0;
		for (i = 0; i < b.length(); i++) {
			if (ary[i].equals("I")) {
				sum = sum + 1;
			} else if (ary[i].equals("D")) {
				sum = sum - 1;
			}

			if (max > sum) {
				max = max;
			} else if (max <= sum) {
				max = sum;
			}

		}
		System.out.println(max);

	}

}

Measured memory_bytes: 21844
using System;

public class hello
{
    public static void Main()
    {
        var n = long.Parse(Console.ReadLine().Trim());
        var ans = new long[4];
        ans[0] = n;
        ans[1] = ~n;
        ans[2] = n << 1;
        ans[3] = n >> 1;
        for (int i = 0; i < 4; i++)
        {
            var a = Convert.ToString(ans[i], 2);
            Console.WriteLine(format(a));
        }
    }
    public static string format(string s)
    {
        var sL = s.Length;
        string ans;
        if (sL < 32) ans = new string('0', 32 - sL) + s;
        else ans = s.Substring(sL - 32);
        return ans;
    }
}


Measured memory_bytes: 16016
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=1e5+5;

#define endl "\n"

int l,r,L,R;

int main(){
	ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
	int n,m,flag;
	cin>>n>>m;
	cin>>L>>R;
	m--;
	flag=1;
	while(m--){
		cin>>l>>r;
		if(flag){
			if(l>R||r<L) flag=0;
			else {
				L=max(L,l);
				R=min(R,r);
			}
		}
	}
	if(L>R) flag=0;
	if(flag) cout<<R-L+1<<endl;
	else cout<<0<<endl;
	return 0;
}

Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int max = 0;
		int sum=0;
		for (;max<100000;max++) {
			sum = max *(max+1)/2;
			if (sum >=N) {
				break;
			}
		}
		int now = max ;
		List<Integer> list = new ArrayList<Integer>();
		while (N >now) {
			list.add(now);
			N -=now;
			now--;
		}
		if (N >0) {
			list.add(N);
		}
		Collections.sort(list);
		for (int i=0;i<list.size();i++) {
			System.out.println(list.get(i));
		}
	}
}

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

int n,h[101];
int ans[500],cor = 0;
int main(){
	int i,j;
	while(cin >> n){
		if(n == 0)
			break;
		n++;
		for(i = 0;i < n;i++)
			cin >> h[i];
		//雑草を抜いたら等差数列になるかも…
		int before,now,d;
		bool flag;
		for(i = 0;i < n;i++){
			flag = false;
			for(j = 0;j < n;j++){
				if(i == j)
					continue;
				if(flag == false){
					flag = true;
					before = h[j];
					if(i != j+1)
						d = h[j+1]-h[j];
					else
						d = h[j+2]-h[j];
				}
				else{
					now = h[j];
					if(now-before != d)
						break;
					before = now;
				}
			}
			if(j == n){
				ans[cor] = h[i];
				break;
			}
		}
		cor++;
	}
	for(i = 0;i < cor;i++)
		cout << ans[i] << endl;
	return 0;
}

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

int main(){

int N;
cin >> N;
if(N < 2) {
    cout << 1 << endl;
    return 0;
}

int num = 2;
int ans;
while(N >= num){
    ans = num;
    num *= 2;
}
cout << ans << endl; 
}

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

using namespace std;


int main(){
  int n;
  cin >> n;

  vector<int> a(n);
  vector<vector<long long>> ball_type_num(2*pow(10,5), vector<long long>(2,0));

  for (int i=0; i<n; i++) {
    cin >> a[i];
    ball_type_num[a[i]][0]++;
  }

  long long total = 0;

  for (int i=0; i<ball_type_num.size(); i++) {
    if (ball_type_num[i][0]==0) {
      ball_type_num[i][1] = 0;
    } else {
      ball_type_num[i][1] = ball_type_num[i][0] - 1;
    }
    total += ball_type_num[i][0] * (ball_type_num[i][0] - 1) / 2;
    //cout << ball_type_num[i][0] << " " << ball_type_num[i][1] << endl;
  }
  //cout << "total " << total << endl;

  for (int i=0; i<n; i++) {
    cout << total-ball_type_num[a[i]][1] << endl; 
  }

  return 0;
}

Measured memory_bytes: 15104
#[allow(unused_imports)]
use proconio::marker::{Bytes, Chars, Usize1};
use proconio::{fastout, input};
#[fastout]
fn main() {
    input! {
        s: Chars,
    }

    let mut count = 0;
    // let mut prev_colour = s[0];
    for i in 0..s.len() - 1 {
        if s[i] != s[i + 1] {
            count += 1;
            // prev_colour = s[i + 1];
        }
    }
    println!("{}", count);
}


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

int main() {
    int n, x;
    cin >> n >> x;

    int dx[n];
    for (int i = 0; i < n; i++) {
        cin >> dx[i];
        dx[i] = abs(dx[i] - x);
    }

    sort(dx, dx + n);

    int ans;
    int ii = 1;

    while (ans = dx[0] / ii) {
        if (dx[0] % ii) {
            ii++;
            continue;
        }

        bool exit = true;
        for (int i = 1; i < n; i++) {
            if (dx[i] % ans) {
                exit = false;
            }
        }

        if (exit) {
            break;
        }

        ii++;
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 640
#include <iostream> 
#include <math.h>  
using namespace std; 
  

void findNumberOfDigits(long n, int base) 
{ 
    int dig = (int)(floor( log(n) /  
                         log(base)) + 1);  
      

    cout<<dig;
} 
int main()
{
    long n1;int b1;
    cin>>n1>>b1;
    findNumberOfDigits(n1,b1);
    return 0;
}

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

#define ll long long
#define vvi vector<vector<int>>
#define vec vector
#define pq priority_queue
#define all(v) (v).begin(), (v).end()
#define rep(i, n) for (int (i) = (0); (i) < (n); ++(i))
#define repp(i, m, n) for (int (i) = (m); (i) < (n); ++(i))
#define debug(x) cerr << #x << ": " << x << endl;
#define debug2(x, y) cerr<<"("<<#x<<", "<<#y<<") = "<<"("<<x<<", "<<y<<")"<<endl;
#define debug3(x, y, z) cerr<<"("<<#x<<", "<<#y<<", "<<#z<<") = "<<"("<<x<<", "<<y<<", "<<z<<")"<<endl;
#define debugB(x, y) cerr<<#x<<": "<<bitset<y>(x) << endl;
#define line() cerr << "---------------" << endl;

const int dx[] = {1, -1, 0, 0};
const int dy[] = {0, 0, -1, 1};

template<typename T>
void printA(vector<T> &printArray, char between = ' ') {
   int paSize = printArray.size();
   for (int i = 0; i < paSize; i++) { cerr << printArray[i] << between;}
   if (between != '\n') {cerr << endl;}
}

// ------------------------------------------------------------------------------------------

int px[90001], py[90001];
int d[90001];

int main() {
   int H, W, D;
   cin >> H >> W >> D;
   rep (i, H) {
      rep (j, W) {
         int A;
         cin >> A;
         px[A] = i, py[A] = j;
      }
   }

   for (int i = D+1; i <= H*W; i++) {
      d[i] = abs(px[i] - px[i-D]) + abs(py[i] - py[i-D]);
   }

   for (int i = D+1; i <= H*W; i++) {
      d[i] += d[i-D];
   }


   int Q;
   cin >> Q;
   while (Q--) {
      int L, R;
      cin >> L >> R;
      cout << d[R] - d[L] << endl;
   }

}

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

int main(){
    int R;
    
    scanf("%d", &R);

    if(R<1200) {
        printf("ABC\n");
    }
    else if(R<2800){
        printf("ARC\n");
    }
    else {
        printf("AGC\n");
    }

    return 0;
}


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

#define pb push_back
#define F first
#define S second
#define all(x) x.begin(), x.end()
#define mp make_pair
#ifndef MY
    #define endl '\n'
#endif
//#define int long long
#define sz(x) (int)x.size()

typedef long long ll;
typedef long double db;
typedef long double ldb;
typedef pair < int, int > pii;

ostream & operator << (ostream & out, vector < int > & lst) {
    for (auto a : lst)
        out << a << ' ';
    out << endl;
    return out;
}

const int inf = 1e9 + 7;
const int N = 1e5 + 5;
int dist[N];
int par[N];
vector < int > gr[N];

void bfs(int n) {
    fill(dist + 1, dist + n, inf);
    queue < int > q;
    q.push(0);
    int cnt = 0;
    while (sz(q)) {
        cnt++;
        int v = q.front();
        q.pop();
        for (auto u : gr[v]) {
            if (dist[u] == inf) {
                par[u] = v;
                dist[u] = dist[v] + 1;
                q.push(u);
            }
        }
    }
    if (cnt != n) {
        cout << "No";
        exit(0);
    }
}

signed main() {
#ifdef MY
    freopen("f.in", "r", stdin);
    //freopen("f.out", "w", stdout);
#endif // MY
    ios_base::sync_with_stdio(0);
    cin.tie(0), cout.tie(0);
    int n, m;
    cin >> n >> m;
    for (int i = 0; i < m; i++) {
        int v, u;
        cin >> v >> u;
        v--, u--;
        gr[v].pb(u);
        gr[u].pb(v);
    }
    bfs(n);
    cout << "Yes" << endl;
    for (int i = 1; i < n; i++) {
        cout << par[i] + 1 << endl;
    }
    return 0;
}


Measured memory_bytes: 10924
def min_mp(bls, A, B, C, a_used=False, b_used=False, c_used=False):
    if sum([a_used, b_used, c_used]) == 3:
        return 0
    else:
        min_val = 10**9  # large number
        non_used_num = 3 - sum([a_used, b_used, c_used])
        if len(bls) - 1 >= non_used_num:
            min_val = min([
                min_val,
                min_mp(bls[1:], A, B, C, a_used, b_used, c_used)
            ])
        if len(bls) > 0:
            if not a_used:
                min_val = min([
                    min_val,
                    abs(bls[0] - A) + min_mp(bls[1:], A, B, C, not a_used, b_used, c_used),
                    10 + min_mp(bls[1:], A - bls[0], B, C, a_used, b_used, c_used)
                ])
            if not b_used:
                min_val = min([
                    min_val,
                    abs(bls[0] - B) + min_mp(bls[1:], A, B, C, a_used, not b_used, c_used),
                    10 + min_mp(bls[1:], A, B - bls[0], C, a_used, b_used, c_used)
                ])
            if not c_used:
                min_val = min([
                    min_val,
                    abs(bls[0] - C) + min_mp(bls[1:], A, B, C, a_used, b_used, not c_used),
                    10 + min_mp(bls[1:], A, B, C - bls[0], a_used, b_used, c_used)
                ])
        return min_val


def main():
    N, A, B, C = list(map(int, input().split(' ')))
    bls = [int(input()) for _ in range(N)]  # bamboo length
    print(min_mp(bls, A, B, C))


if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#define MOD 1000000007
using namespace std;

typedef pair<int, int> P;
typedef pair<long long, long long> LLP;

long long solve(string S, string now_top, long long sum) {
    if (S.length() == 1) {
        return (sum + stoll(now_top + S));
    }
    else return solve(S.substr(1), "", sum + stoll(now_top + S.substr(0, 1))) + solve(S.substr(1), now_top + S.substr(0, 1), sum);
}

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

    cout << solve(S, "", 0) << endl;

    return 0;
}

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

using namespace std;

#define MOD 1000000007

int main(void) {
	int N;
	string s[2];

	cin >> N;
	cin >> s[0] >> s[1];

	//cout << s[0] << s[1];

	long long ans = 1;

	int i;
	if (s[0][0] != s[1][0]) {
		ans = 6;
		i = 2;
	}
	else {
		ans = 3;
		i = 1;
	}

	for (; i < N; ) {
		if (s[0][i - 1] == s[1][i - 1]) {
			if (s[0][i] == s[1][i]) {
				ans *= 2;
				ans %= MOD;
				i += 1;
			}
			else {
				ans *= 2;
				ans %= MOD;
				i += 2;
			}
		}
		else {
			if (s[0][i] == s[1][i]) {
				i += 1;
			}
			else {
				ans *= 3;
				ans %= MOD;
				i += 2;
			}
		}
	}

	cout << ans << endl;

	system("pause");
	return 0;
}

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

void small (int a[10][10],int x,int y)
{
	a[x][y]++;
	int d[2]={1,-1};
	int nx,ny;
	for(int i=0;i<2;i++){
		nx=x+d[i];
		if(nx>=0 && nx<10 && y>=0 && y<10)
			a[nx][y]++;
	}
	for(int i=0;i<2;i++){
		ny=y+d[i];
		if(x>=0 && x<10 && ny>=0 && ny<10)
			a[x][ny]++;
	}
}

void middle(int a[10][10],int x,int y)
{
	int nx,ny;
	for(int i=-1;i<=1;i++)
		for(int j=-1;j<=1;j++){
			nx=x+i;
			ny=y+j;
			if(nx>=0 && nx<10 && ny>=0 && ny<10)
			a[nx][ny]++;
		}
}

void large (int a[10][10],int x,int y)
{
	int nx,ny;
	for(int i=-1;i<=1;i++)
		for(int j=-1;j<=1;j++){
			nx=x+i;
			ny=y+j;
			if(nx>=0 && nx<10 && ny>=0 && ny<10)
			a[nx][ny]++;
		}
		int d[2]={2,-2};
	for(int i=0;i<2;i++){
		nx=x+d[i];
		if(nx>=0 && nx<10 && y>=0 && y<10)
			a[nx][y]++;
	}
	for(int i=0;i<2;i++){
		ny=y+d[i];
		if(x>=0 && x<10 && ny>=0 && ny<10)
			a[x][ny]++;
	}
}

int main()
{
	int a[10][10]={0};
	int x,y,size;
	int brank=0,c=0;

	while(scanf("%d,%d,%d",&x,&y,&size)!=EOF){
		switch(size){
		case 1:
			small(a,x,y);
			break;
		case 2:
			middle(a,x,y);
			break;
		case 3:
			large(a,x,y);
			break;
		}
	}

	for(int i=0;i<10;i++)
		for(int j=0;j<10;j++){
			if(a[i][j]==0)
				brank++;
			else if(c<a[i][j])
				c=a[i][j];
		}
		cout<<brank<<endl;
		cout<<c<<endl;
}

Measured memory_bytes: 1208
from collections import deque

N = int(input())
lines = [[] for _ in range(N+1)]
for _ in range(N-1):
    u, v, w = map(int, input().split())
    lines[u].append([v, w%2])
    lines[v].append([u, w%2])
q = deque([1])
color = [0]*(N+1)
d = [0]*(N+1)
parent = [0]*(N+1)
while q:
    x = q.popleft()
    dis = d[x]
    for y, w in lines[x]:
        if y == parent[x]:
            continue
        if (dis+w)%2 == 1:
            color[y] = 1
        parent[y] = x
        d[y] = (dis+w)%2
        q.append(y)
for i in range(1, N+1):
    print (color[i])

Measured memory_bytes: 43812
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        Scanner sc = new Scanner(System.in);
        int a=sc.nextInt();
        int b=sc.nextInt();
    if(a<b){
        System.out.println("a < b");
    }else if(a>b){
        System.out.println("a > b");
    }else{
        System.out.println("a == b");
    }
  }
}



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

int main() {
    int N, W;
    cin >> N >> W;
    int v[N], w[N];
    for (int i = 0; i < N; ++i) cin >> v[i] >> w[i];
    int dp[110][10100] = {};
    for (int i = 0; i < N; ++i) {
        for (int j = 0; j <= W; ++j) {
            if (j >= w[i]) {
                dp[i + 1][j] = max(dp[i][j - w[i]] + v[i], dp[i][j]);
            } else {
                dp[i + 1][j] = dp[i][j];
            }
        }
    }
    cout << dp[N][W] << endl;

    return 0;
}


Measured memory_bytes: 7464
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (n); i++)
#define ALL(v) (v).begin(),(v).end()
using ll = long long;
using P = pair<int, int>;
const int INF = 1e9;
const long long LINF = 1e18;
const long long MOD = 1e9 + 7;

signed main(){
    int a[3][3];
    rep(i,3){
        rep(j,3){
            cin >> a[i][j];
        }
    }
    int n;
    cin >> n;
    vector<vector<bool>> v(3, vector<bool>(3, false));
    rep(i,n){
        int b;
        cin >> b;
        rep(j,3){
            rep(k,3){
                if(a[j][k] == b){
                    v[j][k] = true;
                }
            }
        }
    }
    rep(i,3){
        rep(j,3){
            if(!v[i][j]) goto ng;
        }
        cout << "Yes" << endl;
        return 0;
        ng:;
    }
    rep(i,3){
        rep(j,3){
            if(!v[j][i]) goto ng2;
        }
        cout << "Yes" << endl;
        return 0;
        ng2:;
    }
    if(v[0][0] && v[1][1] && v[2][2]){
        cout << "Yes" << endl;
        return 0;
    }
    if(v[2][0] && v[1][1] && v[0][2]){
        cout << "Yes" << endl;
        return 0;
    }
    cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256