akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;
const int N=500005;
int n;
char s[N];
int a[N];
int main()
{
	scanf("%s",s+1);
	n=strlen(s+1);
	for(int i=1,j=1;i<=n;i=j)
	{
		while(j<=n&&s[i]==s[j]) j++;
		if(s[i]=='<')
		{
			int l=-1;
			a[i-1]=max(a[i-1],++l);
			for(int k=i;k<j;k++)
				a[k]=max(a[k],++l);
		}
		else if(s[i]=='>')
		{
			int l=-1;
			for(int k=j-1;k>=i;k--)
				a[k]=max(a[k],++l);
			a[i-1]=max(a[i-1],++l);
		}
	}
	long long ans=0;
	for(int i=0;i<=n;i++)
		ans+=a[i];
	printf("%lld",ans);
	return 0;
}

Measured memory_bytes: 6272
#[test]
fn test_solve() {
   assert_eq!(solve("5 2\n"), "7\n");
   assert_eq!(solve("10 0\n"), "100\n");
   assert_eq!(solve("31415 9265\n"), "287927211\n");
}
fn solve(src: &str) -> String {
    let mut sc = Scanner::from_str(src);

    let n: isize = sc.read();
    let k: isize = sc.read();

    let mut ans = 0;
    for b in 1..n+1 {
        let p = n / b;
        let r = n % b;
        // n = pb + r

        ans += p * std::cmp::max(0, b-k);
        ans += std::cmp::max(0, r-k+1);
    }
    if k == 0 {
        ans -= n;
    }
    format!("{}\n", ans)
}
fn main() {
    let mut buf = String::new();
    use std::io::{Read, Write};
    std::io::stdin().read_to_string(&mut buf).unwrap();
    std::io::stdout().write_all(solve(&buf).as_bytes()).unwrap();
}
struct Scanner<'a>(std::str::SplitWhitespace<'a>);
impl<'a> Scanner<'a> {
    fn from_str(src: &str) -> Scanner {
        Scanner(src.split_whitespace())
    }
    fn get(&mut self) -> &str {
        self.0.next().unwrap()
    }
    fn read<T: std::str::FromStr>(&mut self) -> T {
        self.get().parse().ok().unwrap()
    }
}

Measured memory_bytes: 4352
A,B,C,D=map(int,list(input()))

if A+B+C+D==7:
    print('{}+{}+{}+{}=7'.format(A,B,C,D))
elif A-B+C+D==7:
    print('{}-{}+{}+{}=7'.format(A,B,C,D))
elif A+B-C+D==7:
    print('{}+{}-{}+{}=7'.format(A,B,C,D))
elif A+B+C-D==7:
    print('{}+{}+{}-{}=7'.format(A,B,C,D))
elif A-B-C+D==7:
    print('{}-{}-{}+{}=7'.format(A,B,C,D))
elif A+B-C-D==7:
    print('{}+{}-{}-{}=7'.format(A,B,C,D))
elif A-B+C-D==7:
    print('{}-{}+{}-{}=7'.format(A,B,C,D))
elif A-B-C-D==7:
    print('{}-{}-{}-{}=7'.format(A,B,C,D))

Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define N ()
#define ll long long
#define itn int
#define scafn scanf
#define debug(x) cerr<<#x<<" : "<<x<<endl
#define CM cerr<<(&MOP2-&MOP1)/1024.0/1024.0<<endl
using namespace std;
template <class T> inline T Min(T x, T y){
    return x<y?x:y;
}
template <class T> inline T Max(T x, T y){
    return x>y?x:y;
}
bool MOP1;
int k,x;
bool MOP2;
int main(){
	scanf("%d%d",&k,&x);
	for(int i=Max(-1000000,x-k+1);i<=Min(1000000,x+k-1);i++)printf("%d ",i);
	return 0;
}






Measured memory_bytes: 256
import sys
def line():return sys.stdin.readline().strip()
N = int(line())
a = [[int(i) for i in line().split()] for _ in range(N)]

s = [0] * N
for i in range(3):
    c = [0] * 101
    for j in range(N):
        c[a[j][i]]+=1
    for j in range(N):
        if(c[a[j][i]] == 1):
            s[j]+=a[j][i]
for i in range(N):
    print(s[i])

Measured memory_bytes: 7704
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author aajisaka
 */

#include<bits/stdc++.h>

using namespace std;

void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

#define SPEED ios_base::sync_with_stdio(false);cin.tie(nullptr)
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define all(v) v.begin(), v.end()
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

using ll = long long;
using P = pair<ll, ll>;

constexpr double PI = 3.14159265358979323846;
mt19937_64 engine(chrono::steady_clock::now().time_since_epoch().count());

class DLuckyPIN {
public:
    void solve(istream& cin, ostream& cout) {
      SPEED;
      int n; cin >> n;
      string s; cin >> s;

      vector<bool> dp1(10);
      vector<bool> dp2(100);
      vector<bool> dp3(1000);

      rep(i, n) {
        int p = s[i]-'0';
        rep(j, 100) {
          if (dp2[j]) {
            dp3[j*10+p] = true;
          }
        }
        rep(j, 10) {
          if (dp1[j]) {
            dp2[j*10+p] = true;
          }
        }
        dp1[p] = true;
      }

      int ans = 0;
      for(auto e: dp3) {
        if (e) ans++;
      }
      cout << ans << endl;

    }
};

signed main() {
  DLuckyPIN solver;
  std::istream& in(std::cin);
  std::ostream& out(std::cout);
  solver.solve(in, out);
  return 0;
}

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

typedef long long ll;
typedef long double ld;
typedef vector<vector<int>> Graph;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
#define pi 3.14159265359
#define inf 2147483647
#define INF 9223372036854775807
#define mod 1000000007
#define mod2 998244353

int main() {
	double a, b, h; cin >> a >> b >> h;
	double ans = 0.5 * (a + b) * h;
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3760
import java.util.*;

class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int n=scan.nextInt();
        long[][]a=new long[n][n];
        long[][]b=new long[n][n];
        for(int i=0;i<n;++i)
            for(int j=0;j<n;++j)a[i][j]=b[i][j]=scan.nextInt();
        for(int k=0;k<n;++k)
            for(int i=0;i<n;++i)
                for(int j=0;j<n;++j)
                    b[i][j]=Math.min(b[i][j],b[i][k]+b[k][j]);
        if(!Arrays.deepEquals(a,b)){
            System.out.println(-1);
            return;
        }
        long t=0;
        for(int i=0;i<n;++i)
            for(int j=0;j<n;++j){
                boolean nec=true;
                for(int k=0;k<n;++k)
                    if(i!=k&&j!=k&&a[i][k]+a[k][j]==a[i][j])nec=false;
                if(nec)t+=a[i][j];
            }
        System.out.println(t/2);
    }
}


Measured memory_bytes: 64852
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>	
#include<map>
#include<set>
#include<utility>
#include<cmath>
#include<cstring>
#include<queue>
#include<stack>
#include<cstdio>
#include<sstream>
#include<iomanip>
#include<assert.h>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
//#define mt make_tuple
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
using namespace std;
//kaewasuretyuui
typedef long long ll;
typedef int Def;
typedef pair<Def,Def> pii;
typedef vector<Def> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
//typedef tuple<int,int,int> tp;
//typedef vector<tp> vt;
typedef vector<vd> vvd;
typedef pair<Def,pii> pip;
typedef vector<pip>vip;
const double PI=acos(-1);
const double EPS=1e-7;
const int inf=1e9;
const ll INF=2e18;
int dx[]={0,1,0,-1};
int dy[]={1,0,-1,0};
int main(){
	string s,t;
	cin>>s>>t;
	string in[2]={"",""};
	rep(i,s.size())in[i%2]+=s[i];
	bool h=false;
	rep(i,2){
		int q=0;
		rep(j,t.size())if(q<in[i].size()&&in[i][q]==t[j])q++;
		if(q==in[i].size())h=true;
	}
	if(h)cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
}

Measured memory_bytes: 3204
#include <bits/stdc++.h>
#define INF (1<<30)
#define MOD 1000000007
#define l_ength size
using ll = long long;
using namespace std;

struct item{
	int a;
	int b;
	int cost;
};

int dp[50][410][410];

int main(){
	int n, ma, mb;
	cin >> n >> ma >> mb;
	
	item d[n];
	for( int i = 0; i < n; ++i ){
		int x, y, z; cin >> x >> y >> z;
		d[i].a = x;
		d[i].b = y;
		d[i].cost = z;
	}
	
	for( int i = 0; i < 50; ++i ){
		for( int j = 0; j < 410; ++j ){
			for( int k = 0; k < 410; ++k ){
				dp[i][j][k] = INF;
			}
		}
	}
	for( int i = 0; i < 40; ++i ){
		dp[i][0][0] = 0;
	}
	
	for( int i = 0; i < n; ++i ){
		for( int j = 0; j < 410; ++j ){
			for( int k = 0; k < 410; ++k ){
				if( j >= d[i].a && k >= d[i].b ){
					dp[i+1][j][k] = min( dp[i][j-d[i].a][k-d[i].b] + d[i].cost, dp[i][j][k] );
				} else {
					dp[i+1][j][k] = dp[i][j][k];
				}
			}
		}
	}
	
	int ans = INF;
	for( int i = 1; i <= n; ++i ){
		for( int j = 1; j < 410; ++j ){
			for( int k = 1; k < 410; ++k ){
				if( ma * k == mb * j ){
					ans = min(ans, dp[i][j][k]);
				}
			}
		}
	}

	/*
	for( int i = 0; i <= n; ++i ){
		for( int j = 1; j < 7; ++j ){
			for( int k = 1; k < 7; ++k ){
				if( dp[i][j][k] == INF ){
					cout << "∞";
				} else {
					cout << dp[i][j][k];
				}
				cout << " ";
			}
			cout << endl;
		}
		cout << endl;
	}
	*/
	
	if( ans == INF ) cout << -1 << endl;
	else cout << ans << endl;
	return 0;
}

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

#define each(i, c) for (auto& i : c)
#define unless(cond) if (!(cond))

using namespace std;

typedef long long int lli;
typedef unsigned long long ull;
typedef complex<double> point;

template<typename P, typename Q> ostream& operator << (ostream& os, pair<P, Q> p) { os << "(" << p.first << "," << p.second << ")"; return os; }
template<typename P, typename Q> istream& operator >> (istream& is, pair<P, Q>& p) { is >> p.first >> p.second; return is; }
template<typename T> ostream& operator << (ostream& os, vector<T> v) { os << "("; each (i, v) os << i << ","; os << ")"; return os; }
template<typename T> istream& operator >> (istream& is, vector<T>& v) { each (i, v) is >> i; return is; }

template<typename T> inline T setmax(T& a, T b) { return a = std::max(a, b); }
template<typename T> inline T setmin(T& a, T b) { return a = std::min(a, b); }

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

  int n;
  while (cin >> n) {
    vector<int> a(n);
    cin >> a;

    map<int, int> cnt;
    each (i, a) ++cnt[i];


    priority_queue<pair<int, int>> q;
    each (i, cnt) {
      q.push(make_pair(i.second, i.first));
    }

    while (2 <= q.size() && 1 < q.top().first) {
      auto x = q.top();
      q.pop();
      auto y = q.top();
      q.pop();
      
      x.first -= 1;
      y.first -= 1;
      if (x.first) q.push(x);
      if (y.first) q.push(y);
    }

    cout << q.size() << endl;
  }
  
  return 0;
}


Measured memory_bytes: 6524
// AtCoder165 C

#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <math.h>
#include <assert.h>
#include <string.h>
#include <memory.h>
#include <malloc.h>
#include <stdlib.h>

// qsortで用いる比較用関数．*a<*bならaが先になる．
int compare(const void* a, const void* b) {
    return *(int*)a - *(int*)b;
}

int revcompare(const void* a, const void* b) {
    return *(int*)b- *(int*)a;
}

struct node_t{
    int value;
    struct node_t* left;
    struct node_t* right;
};

struct node_t* mallocNode(int adds) {
    struct node_t* add;

    add = (struct node_t*)malloc(sizeof(struct node_t));
    if (add == NULL) {
        return NULL;
    }

    add->left = NULL;
    add->right = NULL;
    add->value =  adds;

    return add;
}

int addNode(struct node_t* root, int tmps) {
    struct node_t* node;
    if (root == NULL) {
        root = mallocNode(tmps);
        return 0;
    }

    node = root;
    while (1) {
        if (tmps < node->value) {
            if (node->left == NULL) {
                node->left = mallocNode(tmps);
                return 0;
            }
            node = node->left;
        }
        else if (tmps > node->value) {
            if (node->right == NULL) {
                node->right = mallocNode(tmps);
                return 0;
            }
            node = node->right;
        }
        else {
            return 1; // 重複のときのみ1を返す
        }
    }

}


int main() {
    int i,j;
    int n;
    int s;
    struct node_t* root;
    root = NULL;
    int isDuplicate = 0;

    scanf("%d", &s);
    root = mallocNode(s);

    // 100000は問題の条件より
    for(i=2;isDuplicate != 1 && i<1000000;i++){
        if(s%2 == 0){
            s = s/2;
        }else{
            s = (3 * s) + 1;
        }
        isDuplicate = addNode(root, s);
        //isDuplicate = 1;
    }

    printf("%d", i-1);

    return 0;

}

Measured memory_bytes: 128
import Control.Monad
import Data.List

main=do
    [m,n]<-map read.words<$>getLine::IO[Int]
    print $ case abs (m-n) of
        0 -> ((((pm n) * (pm m))`mod` 1000000007) * 2) `mod` 1000000007
        1 -> ((pm n) * (pm m)) `mod` 1000000007
        _ -> 0

pm n = foldl1 (\a x -> (a*x)`mod`1000000007) [1..n] 

Measured memory_bytes: 892
package main

import "fmt"

func main() {
	// Code for B - ∵∴∵
	var O, E string
	fmt.Scanf("%s\n%s", &O, &E)

	for i := 0; i < len(E); i++ {
		fmt.Printf("%c%c", O[i], E[i])
	}

	if len(O) != len(E) {
		fmt.Printf("%c", O[len(O)-1])
	}
	fmt.Printf("\n")
}


Measured memory_bytes: 1836
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin>>n;
  int m=n;
  int d=0;
  while(m>0){
    d++;
    m/=10;
  }
  int c=0;
  for(int i=0;i<d/2;i++){
    int p=1;
    for(int j=0;j<i;j++)
      p*=100;
    c+=p*9;
  }
  if(d%2!=0){
    int p=1;
    for(int i=0;i<d-1;i++)
      p*=10;
    c+=n-p+1;
  }
  cout<<c<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,a,n)  for (int i=(int)(a); i<=(int)(n); ++i)
#define rrep(i,a,n) for (int i=(int)(a); i>=(int)(n); --i)
#define debug(x) cerr << #x << " = " << x << "\n"
#define debugv(x) rep(f, 0, (x.size()-1)) cerr << x[f] << (f == (x.size() - 1) ? "\n" : " ")
#define all(x) x.begin(),x.end()
#define int long long
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int INF = ((1LL << 30) + (1LL << 29));
const int MOD = 1000000007;

//=============================
int N,M,K,X,Y;
int a,b,c,d;
string S,T;
vector<int> A,B;
//=============================
void input()
{
    cin>>N;
}
//=============================
int func(int x){
    int ret=0;
    while(x){
        ret += x%10;
        x /= 10;
    }
    return ret;
}
/*
 - 樹形図をかく
*/
//=============================
void solve()
{
    cout<<(N%func(N) ? "No" : "Yes")<<endl;

}
//=============================
signed main()
{
    input();
    solve();
    return 0;
}


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

using VI = vector<int>;
using VVI = vector<VI>;
using PII = pair<int, int>;
using LL = long long;
using VL = vector<LL>;
using VVL = vector<VL>;
using PLL = pair<LL, LL>;
using VS = vector<string>;

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))

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

#define FF first
#define SS second
template<class S, class T>
istream& operator>>(istream& is, pair<S,T>& p){
  return is >> p.FF >> p.SS;
}
template<class S, class T>
ostream& operator<<(ostream& os, const pair<S,T>& p){
  return os << p.FF << " " << p.SS;
}
template<class T>
void maxi(T& x, T y){
  if(x < y) x = y;
}
template<class T>
void mini(T& x, T y){
  if(x > y) x = y;
}


const double EPS = 1e-10;
const double PI  = acos(-1.0);
const LL MOD = 1e9+7;

int N, M, K;
int ds[16];
int isd[101];
int memo[1<<16];
int solve(const VVI& G, int b){
  if(b == 0) return 0;
  if(memo[b] >= 0) return memo[b];

  int& res = memo[b];
  res = 1e6;
  REP(k,K){
	int nb = 0;
	REP(i,M){
	  if((b>>i&1)){
		int to = G[ds[i]][k];
		if(isd[to] >= 0)
		  nb |= 1 << isd[to];
	  }
	}
	mini(res, solve(G, nb) + 1);
  }

  return res;
}

int main(){
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  fill(memo, memo+(1<<16), -1);
  fill(isd, isd+101, -1);

  cin >> N >> M >> K;
  REP(i,M){
	cin >> ds[i];
	isd[ds[i]] = i;
  }

  VVI G(N+1, VI(K));
  REP(i,N) REP(k,K) cin >> G[i+1][k];

  cout << solve(G, (1<<M)-1) << endl;  

  return 0;
}

Measured memory_bytes: 4768
//Littleboy123 Template 1.2

#include <bits/stdc++.h>
using namespace std;

//pragmas
/*
#pragma comment(linker, "/stack:200000000")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
*/

typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef long long int ll;
typedef unsigned long long int ull;
typedef long double ld;

#define FOR(a,b,c) for(ll (a)=(b);(a)<(c);++(a))
#define FORE(a,b,c) for(ll (a)=(b);(a)<=(c);++(a))
#define FORN(a,b,c) for(ll (a)=(b);(a)>(c);--(a))
#define FORNE(a,b,c) for(ll (a)=(b);(a)>=(c);--(a))
#define COUT(a) cout << (a) << '\n'
#define MEM(a,b) memset((a), (b), sizeof((a)))
#define MAX(a,b) (a) = max((a), (b))
#define MIN(a,b) (a) = min((a), (b))
#define nl '\n'
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define pi acos(-1.0)

void init(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
}

void infile(){
	ifstream in("input.in");
	streambuf *cinbuf = std::cin.rdbuf();
	cin.rdbuf(in.rdbuf());
}

void outfile(){
	ofstream out("out.txt");
	streambuf *coutbuf = std::cout.rdbuf();
	cout.rdbuf(out.rdbuf());
}

//End of template

int main(){
	init();
	//infile();
	//outfile();
	
	string s, t;
	cin >> s >> t;
	int len = s.length();
	int cnt = 0;
	FOR(i, 0, len){
		if(s[i] == t[i]){
			cnt++;
		}
	}
	cout << cnt << nl;
	return 0;
}

Measured memory_bytes: 256
/*
for (int i = 0; i < N; ++i){}

// 各桁の和を計算する関数
int findSumOfDigits(int n) {
  int sum = 0;
  while (n > 0) { // n が 0 になるまで
    sum += n % 10;
    n /= 10;
  }
  return sum;
}

sort(a, a + N, greater<int>());  // a[0:N] を大きい順にソート

int num[110] = {0};  // バケット
for (int i = 0; i < N; ++i) {
    num[d[i]]++;  // d[i] が 1 個増える
}

map<string, int> mp; // 連想配列 map<キー型, 値型> オブジェクト名
for (int i = 0; i < N; ++i) {
    auto itr = mp.find(s[i]);        // s[i] が設定されているか？
    if(itr != mp.end() ) {
         mp[s[i]] += 1;
    }
    else {
         mp[s[i]] += 1 ;
    }
}
stack<int> s;	//intをデータとするスタックを用意
s.push(1);		//{} -> {1}
printf("%d\n", s.top());	// 3
s.pop();

queue<int> que;	//intをデータとするキューを用意
que.push(1);		//{} -> {1}
printf("%d\n", que.front());	// 1
que.pop();
*/
#include <iostream>
#include <set>
#include <map>
#include <string>
#include <math.h>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <bitset>

using namespace std;

// #define for(i,a,b) for (int i=(a);i<(b);++i)
typedef long long ll;
typedef pair<ll,ll> P;
#define REP(i,n) for(long long i = 0; i < (long long)(n); i++)
#define pb push_back // vectorに要素追加
#define INF (ll)1e18
// int 
// // 各桁の和を計算する関数
// int findSumOfDigits(int n) {
//   int amari = 0;
//   int keta = 0;
//   while (n > 0) { // n が 0 になるまで
//     amari += n % 2;
//     if (keta%2==0)
//     n /= 10;
//   }
//   return sum;
// }
 
 

int main() {
	// 入力
	ll M;
	cin >> M;
 
	// 解法
	ll ans = 24+24-M;
	//出力
	cout << ans << endl;
}


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

using namespace std;

inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
template<class T> inline T sqr(T x) {return x*x;}

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

#define all(a)  (a).begin(),(a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define pb push_back
#define mp make_pair
#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 range(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)  range(i,0,n)
#define clr(a,b) memset((a), (b) ,sizeof(a))
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

const double eps = 1e-10;
const double pi  = acos(-1.0);
const ll INF =1LL << 62;
const int inf =1 << 29;

set<string> s;

int main(void){
	int n,m;
	cin >> n;
	rep(i,n){
		string in;
		cin >> in;
		s.insert(in);
	}
	bool locked=true;
	cin >> m;
	rep(i,m){
		string in;
		cin >> in;
		if(exist(s,in)){
			if(locked)
				cout << "Opened by " << in << endl;
			else
				cout << "Closed by " << in << endl;
			locked^=true;
		}else{
			cout << "Unknown " << in << endl;
		}
	}
	return 0;
}

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

using namespace std;
typedef long long ll;
#define REP(i,n) for (ll i = 0; i < (n); ++i)

int main(){
    string s;
    cin >> s;
    ll ans = 0;
    REP(i, s.size() - 1){
        ans += s.at(i) != s.at(i + 1);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 512
{-# LANGUAGE BangPatterns #-}
import           Control.Exception           (assert)
import           Control.Monad
import           Control.Monad.Primitive
import qualified Control.Monad.ST            as ST
import qualified Data.Array.IO               as IO
import qualified Data.Array.ST               as ST
import qualified Data.Array.Unboxed          as A
import           Data.Bits
import qualified Data.ByteString.Char8       as BS
import           Data.Char
import           Data.Foldable
import           Data.List
import qualified Data.Map.Strict             as Map
import           Data.Maybe
import qualified Data.Sequence               as Seq
import qualified Data.Set                    as Set
import qualified Data.Vector                 as VB
import qualified Data.Vector.Mutable         as VBM
import qualified Data.Vector.Unboxed         as V
import qualified Data.Vector.Unboxed.Mutable as VM
import           Debug.Trace

readInt = fst . fromJust . BS.readInt
readIntList = map readInt . BS.words
getInt = readInt <$> BS.getLine
getIntList = readIntList <$> BS.getLine
getIntVec n = V.unfoldrN n (BS.readInt . BS.dropWhile isSpace) <$> BS.getLine

readInteger = fst . fromJust . BS.readInteger
readIntegerList = map readInteger . BS.words
getInteger = readInteger <$> BS.getLine
getIntegerList = readIntegerList <$> BS.getLine

inf :: Int
inf = 10^18

main = do
  n <- getInt
  a <- getInt
  let ans = n*n - a
  print ans


Measured memory_bytes: 380
#include<iostream>
#include<vector>
#include<iomanip>
using namespace std;
int main()
{
    int n,i,j;
    cin>>n;
    vector<double>p(n+1);
    for(i=1;i<=n;i++) cin>>p[i];
    vector<double>tmp(n+1,0);
    vector<vector<double> >dp(n+1,tmp);
    for(i=0;i<n;i++)
        dp[i][0]=0;
    dp[0][0]=1.0;
    for(j=1;j<=n;j++)
    {
        dp[0][j]=dp[0][j-1]*(1-p[j]);
        for(i=1;i<=n;i++)
        {
            dp[i][j]=dp[i][j-1]*(1.0-p[j])+dp[i-1][j-1]*p[j];
        }
    }
    double ans=0;
    for(i=n/2+1;i<=n;i++) ans+=dp[i][n];
    cout<<fixed<<setprecision(15)<<ans;
}


Measured memory_bytes: 72448
# K回の操作
# N = 50とする
# 0,1,2,3,4...N - 1の数列に対して左からi番目にNを足し、それ以外から1を引く操作
# K // N回の操作をすると、1回あたり全項目に1が足される。

import sys
readline = sys.stdin.readline

K = int(readline())
N = 50

A = [i for i in range(N)]
A = list(map(lambda x:x + (K // N),A))
rest = K % N
for i in range(rest):
  A[i] += N
  for j in range(N):
    if i != j:
      A[j] -= 1

print(N)
print(*A)

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

int main() {
  long long w, h, x, y;
  scanf("%lld %lld %lld %lld", &w, &h, &x, &y);
  printf("%lld", w * h / 2);
  if (w * h % 2) printf(".5");
  printf(" %d\n", (w % 2 == 0 && x == w / 2) && (h % 2 == 0 && y == h / 2));
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int findsomedigits(int n){
    int sum=0;
    while(n>0){
        sum+=n%10;
        n/=10;
    }
    return sum;
}

int main(){
    int n,a,b;
    cin>>n>>a>>b;
    int total=0;
    for(int i=1;i<=n;i++){
        int k;
        k=findsomedigits(i);
        if(k>=a && k<=b){
            total+=i;
        }
    }
    cout<<total<<endl;

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const long long M =1e6+10,MOD=1000000007;
typedef long long ll;
 
int main()
{
     ios::sync_with_stdio(false);
     cin.tie(0);
     string s;
     cin>>s;
    for(int i=0;i<s.size();i++)if(s[i]=='7'){cout<<"Yes\n";return 0;}
     
     cout<<"No\n";
    return 0;
}

Measured memory_bytes: 3652
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplication3
{
    class Program
    {
        static void Main(string[] args)
        {
            var n = int.Parse(Console.ReadLine());
            int[, ,] R;
            R = new int[4,3,10];
            foreach (var i in Enumerable.Range(0, 4))
            {
                foreach (var j in Enumerable.Range(0, 3))
                {
                    foreach (var k in Enumerable.Range(0, 10))
                    {
                        R[i, j, k] = 0;
                    }
                }
            }
            foreach (var i in Enumerable.Range(0,n))
            {
                var x = Console.ReadLine().Split().Select(int.Parse).ToArray();
                var b = x[0];
                var f = x[1];
                var r = x[2];
                var v = x[3];
                R[b - 1, f - 1, r - 1] = R[b - 1, f - 1, r - 1] + v;
            }
            foreach(var i in Enumerable.Range(0,4))
            {
                foreach(var j in Enumerable.Range(0,3))
                {
                    foreach(var k in Enumerable.Range(0,9))
                    {
                        Console.Write(" {0}",R[i,j,k]);
                    }
                    Console.WriteLine(" {0}",R[i,j,9]);
                }
                if(i!=3)
                {
                Console.WriteLine("####################");
                }
            }
        }
    }
}

Measured memory_bytes: 9716
while True:

     a, op, b = input().split()

     a = int(a)
     b = int(b)

     if op == '?':
         break
     if op == '+':
         print(a + b)
     if op == '-':
         print(a - b)
     if op == '*':
         print(a * b)
     if op == '/':
         print(a // b)

Measured memory_bytes: 7648
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define mod 1000000007ll
#define mod1 998244353ll
#define endl '\n'
#define inf (ll)1e18+1
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define ordered_set tree<ll,null_type,less_equal<ll>,rb_tree_tag,tree_order_statistics_node_update>
#define deb(x) cout<<"-->  "<<#x<<" :  "<<x<<endl;
#define deba(x) {cout<<"-->  "<<#x<<" :  "; for(auto ele:(x)) cout<<ele<<"  "; cout<<endl; }


int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    ll n;
    cin>>n;
    ll ar[n];
    for(int x=0;x<n;x++){
        cin>>ar[x];
    }
    ll ans=0;
    map<ll,ll> mp;
    mp[(n-1)-ar[n-1]]++;
    for(int x=n-2;x>=0;x--){
        ll val=x+ar[x];
        ans+=mp[val];
        mp[x-ar[x]]++;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 27916
#include<bits/stdc++.h>
using namespace std;
int main(){
        int a, b, c, d;
        cin>>a>>b>>c>>d;
        long long d1=c/b;
        if(c%b>0){
                d1++;
        }long long d2=a/d;
        if(a%d>0){
                d2++;
        }if(d1<=d2){
                cout<<"Yes"<<endl;
        }else{
                cout<<"No"<<endl;
        }
        return 0;
}

Measured memory_bytes: 3632
#define _USE_MATH_DEFIMES
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cctype>
#include <climits>
#include <clocale>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <regex>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

const int MOD = 1'000'000'007;
const int INF = 1'000'000'000; //1e9
const int NIL = -1;
const long long LINF = 1'000'000'000'000'000'000; // 1e18
const long double EPS = 1E-10;

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








int main(){
    int N; std::cin >> N;
    std::map<long long, int> cnt;
    long long sum(0);
    {
        int A;
        for(int i(0); i < N; ++i){
            std::cin >> A;
            sum += A;
            ++cnt[A];
        }
    }
    int Q; std::cin >> Q;
    {
        int B, C;
        for(int i(0); i < Q; ++i){
            std::cin >> B >> C;
            int c(cnt[B]);
            sum += c * ((long long)C - B);
            cnt[B] -= c;
            cnt[C] += c;
            std::cout << sum << std::endl;
        }
    }
    return 0;
}


Measured memory_bytes: 9364
#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <algorithm>
#include <math.h>
#include <climits>
using namespace std;

int main()
{
    int N, K;
    vector<int> fruits;

    cin >> N >> K;

    for(int i = 0; i < N; i++)
    {
        int a;
        cin >> a;
        fruits.push_back(a);
    }

    sort(fruits.begin(),fruits.end());

    int sum = 0;

    for(int i = 0; i < K; i++)
    {
        sum += fruits[i];
    }

    cout << sum << "\n";
}

Measured memory_bytes: 3592
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#ifdef ENABLE_DEBUG
#define dump(a) cerr<<#a<<"="<<(a)<<endl
#define dumparr(a,n) cerr<<#a<<"["<<n<<"]="<<a[n]<<endl
#else
#define dump(a) 
#define dumparr(a,n) 
#endif
#define FOR(i, a, b) for(ll i = a;i < b;i++)
#define For(i, a) FOR(i, 0, a)
#define REV(i, a, b) for(ll i = b-1;i >= a;i--)
#define Rev(i, a) REV(i, 0, a)
#define REP(a) For(i, a)
#define SIGN(a) (a==0?0:(a>0?1:-1))

typedef long long int ll;
typedef unsigned long long ull;
typedef unsigned int uint;
typedef pair<ll, ll> pll;
typedef pair<ll,pll> ppll;
typedef vector<ll> vll;
typedef long double ld;
typedef pair<ld,ld> pdd;

const ll INF=(1LL<<50);
#if __cplusplus<201700L
ll gcd(ll a, ll b) {
  if(a < b) return gcd(b, a);
  ll r;
  while ((r=a%b)) {
    a = b;
    b = r;
  }
  return b;
}
#endif

template<class S,class T>
std::ostream& operator<<(std::ostream& os,pair<S,T> a){
  os << "(" << a.first << "," << a.second << ")";
  return os;
}
template<class T>
std::ostream& operator<<(std::ostream& os,vector<T> a){
  os << "[ ";
  REP(a.size()){
    os<< a[i] << " ";
  }
  os<< " ]";
  return os;
}


void solve(long long N, std::vector<long long> A, std::vector<long long> B){
  dump(N);
  dump(1LL<<N);
  ll ans=-1;
  REP((1<<N)){
    if(__builtin_popcountll(i)%2){
      continue;
    }
    dump(bitset<18>(i));
    auto flags=[&](ll j){
      return (1<<j)&i?B[j]:A[j];
    };
    map<ll,vector<ll>> cards;
    auto inc_m=[&](ll i,ll idx){
      cards[i].push_back(idx);
    };
    For(j,N){
      inc_m(flags(j),j);
    }
    bool f=true;
    vector<ll> sh;
    for (auto &&card : cards)
    {
      //dump(card);
      vector<ll> gk[2];
      ll cur=sh.size();
      for (auto &&idx : card.second)
      {
        gk[(idx+((1<<idx)&i?1:0))%2].push_back(idx);
      }
      if(gk[cur%2].size()!=card.second.size()/2+card.second.size()%2||gk[1^(cur%2)].size()!=card.second.size()/2){
        f=false;
        break;
      }
      For(z,card.second.size()){
        sh.push_back(gk[sh.size()%2][(sh.size()-cur)/2]);
      }
    }
    if(f==false){
      continue;
    }
    dump(sh);
    ll hanten=0;
    tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> tr;
    For(z,sh.size()){
      hanten+=tr.size()-tr.order_of_key(sh[z]);
      tr.insert(sh[z]);
    }
    if(ans==-1){
      ans=hanten;
    }else{
      ans=min(ans,hanten);
    }
  }
  cout<<ans<<endl;
}

int main(){
  cout<<setprecision(1000);
  cin.tie(0);
  ios::sync_with_stdio(false);
    long long N;
    scanf("%lld",&N);
    std::vector<long long> A(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&A[i]);
    }
    std::vector<long long> B(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&B[i]);
    }
    solve(N, std::move(A), std::move(B));
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
int main(void){
    int n,i;
    long ans=0;
    scanf("%d",&n);
    int a[n+1],b[n];
    for(i=0;i<n+1;i++) scanf("%d",&a[i]);
    for(i=0;i<n;i++) scanf("%d",&b[i]);
    for(i=0;i<n;i++){
        if(a[i]>b[i]) ans+=b[i];
        else if(a[i]+a[i+1]>b[i]){
            ans+=b[i];
            a[i+1]=a[i+1]-(b[i]-a[i]);
        }
        else{
            ans+=a[i]+a[i+1];
            a[i+1]=0;
        }
    }
    printf("%ld",ans);
    return 0;
}

Measured memory_bytes: 896
#include<iostream>
#include<cstdio>
#include<queue>
#include<cmath>
#include<cstring>
#include<cstdlib>
#include<map>
#include<set>
#define LL long long
#define For(i,n) for(int i=1;i<=n;i++)

using namespace std;
int n,m,t;

int main()
{
	char a[10],b[10];
	while(cin>>a>>b){
	
		if(a[0]=='H')
		{
			if(b[0]=='H')
			{
				cout<<"H";
			}
			else cout<<"D";
			
		}
		else if(a[0]=='D')
		{
			if(b[0]=='H')
			{
				cout<<"D";
			}
			else cout<<"H";
		}
		cout<<endl;
	}
	
	return 0;
}


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

using namespace std;

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

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

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

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

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

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

struct UFT{
  int * p;
  
  UFT(int N):p(new int[N]){fill(p,p+N,-1);}  
  ~UFT(){delete[] p;}  
  int par(int a)   { if( p[a] >= 0 ){ p[a] = par( p[a] ); return p[a]; } return a;  }
  int size(int a)  { return -p[par(a)]; }
  bool	same(int a, int b) { return par(a) == par(b); }
  void unite(int a, int b){
    a = par(a);  b = par(b);
    if( a == b ) return;
    if( size(a) < size(b) )a^=b^=a^=b;
    p[a] -= size(b);
    p[b] = a;
  }
};


int main(){
  UFT uft(200001);
  int n,m; cin >> n >> m;
  for(int i = 0; i < m; ++i){
    int a,b; cin >> a >> b;
    if(a == 1 || b == 1)uft.unite(a,b);
    if(a == n || b == n)uft.unite(a,b);
  }
  cout << (uft.same(1,n) ? "POSSIBLE" : "IMPOSSIBLE") << endl;
  return 0;
}


Measured memory_bytes: 3800
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n)    for(int i=0; i<(n); ++i)
#define REP(i, d, n) for(int i=(d); i<(n); ++i)
#define rrep(i, n)   for(int i=(n-1); i>=0; --i)
#define all(v)       v.begin(), v.end()
#define rall(v)      v.rbegin(), v.rend()
#define int          long long
template<typename T>
using vv  = vector<vector<T>>;
using vi  = vector<int>;
using vvi = vector<vector<int>>;
using P   = pair<int, int>;
using ll  = long long;
constexpr ll INF = 1LL << 60;

signed main(){

    int n, k;
    cin >> n >> k;
    vector<int> p(n);
    rep(i, n){
        cin >> p[i];
    }
    sort(all(p));

    int sum = 0;
    rep(i, k){
        sum += p[i];
    }
    cout << sum << endl;

    return 0;
}



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

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP0(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define RREP0(i, n) for (int i = (n)-1; i >= 0; --i)
#define REP1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; ++i)
#define RREP1(i, n) for (int i = (n); i >= 1; --i)
#define pow10(n) int(1e##n + n)

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

const int INTINF = int(1e9) + 1;
const LL LLINF = LL(1e18) + 1;
long double eps = 1.0E-14;

int isvacant(int i)
{
    std::cout << i << endl;
    fflush(stdout);
    string s;
    cin >> s;
    if (s[0] == 'V')
    {
        exit(0);
    }
    else if (s[0] == 'F')
    {
        return 0;
    }
    else
    {
        return 1;
    }
}

void solve()
{
    int N;
    cin >> N;
    int l = 0, r = N - 1;

    int sl = isvacant(l);
    int sr = isvacant(r);

    while (true)
    {
        int m = (l + r) >> 1;
        int sm = isvacant(m);
        if ((sm == sl) != (l % 2 == m % 2))
        {
            r = m;
            sr = sm;
        }
        else
        {
            l = m;
            sl = sm;
        }
    }
}

int main(int argc, char const *argv[])
{
    // cin.tie(0);
    // ios::sync_with_stdio(false);
    // std::cout << std::fixed << std::setprecision(20);
    solve();
    return 0;
}


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

using namespace std;

int main() {
	long long n;
	vector<char> v;

	cin >> n;

	long long a,b;
	a = n;
	while (n > 0) {
		a = (n - 1) / 26;
		b = (n - 1) % 26;
		v.emplace_back(b + 97);
		n = a;
	}
	
	for (int i = v.size()-1;i >=0;i--) {
		cout << v[i];
	}
	cout << "\n";

	return 0;
}

Measured memory_bytes: 3596
#include <string>
#include <vector>
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<stack>
#include<queue>
#include<cmath>
#include<algorithm>
#include<functional>
#include<list>
#include<deque>
#include<bitset>
#include<set>
#include<map>
#include<unordered_map>
#include<unordered_set>
#include<cstring>
#include<sstream>
#include<complex>
#include<iomanip>
#include<numeric>
#include<cassert>
#define X first
#define Y second
#define pb push_back
#define rep(X,Y) for (int (X) = 0;(X) < (Y);++(X))
#define reps(X,S,Y) for (int (X) = S;(X) < (Y);++(X))
#define rrep(X,Y) for (int (X) = (Y)-1;(X) >=0;--(X))
#define rreps(X,S,Y) for (int (X) = (Y)-1;(X) >= (S);--(X))
#define repe(X,Y) for ((X) = 0;(X) < (Y);++(X))
#define peat(X,Y) for (;(X) < (Y);++(X))
#define all(X) (X).begin(),(X).end()
#define rall(X) (X).rbegin(),(X).rend()
#define eb emplace_back
#define UNIQUE(X) (X).erase(unique(all(X)),(X).end())
#define Endl endl

using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
template<class T> using vv=vector<vector<T>>;
template<class T> ostream& operator<<(ostream &os, const vector<T> &t) {
os<<"{"; rep(i,t.size()) {os<<t[i]<<",";} os<<"}"<<endl; return os;}
template<class S, class T> ostream& operator<<(ostream &os, const pair<S,T> &t) { return os<<"("<<t.first<<","<<t.second<<")";}
template<class T> inline bool MX(T &l,const T &r){return l<r?l=r,1:0;}
template<class T> inline bool MN(T &l,const T &r){return l>r?l=r,1:0;}
#define out(args...){vector<string> a_r_g_s=s_p_l_i_t(#args, ','); e_r_r(a_r_g_s.begin(), args); }
vector<string> s_p_l_i_t(const string &s, char c){vector<string> v;int d=0,f=0;string t;for(char c:s){if(!d&&c==',')v.pb(t),t="";else t+=c;if(c=='\"'||c=='\'')f^=1;if(!f&&c=='(')++d;if(!f&&c==')')--d;}v.pb(t);return move(v);}
void e_r_r(vector<string>::iterator it) {}
template<typename T, typename... Args> void e_r_r(vector<string>::iterator it, T a, Args... args){ if(*it==" 1"||*it=="1") cerr<<endl; else cerr << it -> substr((*it)[0] == ' ', it -> length()) << " = " << a << ", "; e_r_r(++it, args...);}
const ll MOD=1e9+7;

int main(){
  ios_base::sync_with_stdio(false);
  cout<<fixed<<setprecision(0);
  ll n,t;
  cin>>n>>t;
  vector<ll> ts(n);
  rep(i,n) cin>>ts[i];
  ll re=0,l=0;
  for(ll x:ts){
    re-=max(0ll,x-l);
    l=x+t;
  }
  cout<<l+re<<endl;
  return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
#include <string>
#include <vector>
#include <algorithm>
#define rep(i,w) for (int i = 0;i < (w); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;
int INF = 1e9;
 
int main(){
  int n,u,v;cin >> n >> u >> v;
  --u;--v;
  vector<vector<int>> G(n);
  rep(i,n-1){
    int a,b;cin >> a >> b;
    --a;--b;
    G[a].push_back(b);
    G[b].push_back(a);
  }

  vector<int> tdist(n,-1),adist(n,-1);
  queue<int> q;
  q.push(u);
  tdist[u] = 0;
  while(!q.empty()){
    int ver = q.front();q.pop();
    //cout << ver << endl;
    for(auto nver:G[ver]){
      if(tdist[nver] != -1) continue;
      tdist[nver] = tdist[ver] + 1;
      q.push(nver);
    }
  }
  q.push(v);
  adist[v] = 0;
  while(!q.empty()){
    int ver = q.front();q.pop();
    for(auto nver:G[ver]){
      if(adist[nver] != -1) continue;
      adist[nver] = adist[ver] + 1;
      q.push(nver);
    }
  }
  int ans = 0;
  rep(i,n){
    if(adist[i] > tdist[i]){
      ans = max(ans,adist[i]-1);
    }
  }
  cout << ans << endl;
  
}

Measured memory_bytes: 9540
#include <stdio.h>
#include <algorithm>
#include <assert.h>
#include <bitset>
#include <cmath>
#include <complex>
#include <deque>
#include <functional>
#include <iostream>
#include <limits.h>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <time.h>
#include <unordered_map>
#include <unordered_set>
#include <vector>

#pragma warning(disable:4996)
#pragma comment(linker, "/STACK:1048576")
using namespace std;

#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define ldb ldouble
#define rf(x) (x)=0;while(*p<48)p++;while(47<*p)(x)=((x)<<3)+((x)<<1)+(*p++&15);

typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ldb;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef pair <ll, int> pli;
typedef pair <db, db> pdd;
typedef tuple <int, int, int> t3;

int IT_MAX = 1 << 12;
const ll MOD = 1000000009;
const int INF = 0x3f3f3f3f;
const ll LL_INF = 1234567890123456789ll;
const db PI = acos(-1);
const db ERR = 1e-10;
#define szz(x) (int)(x).size()
#define rep(i, n) for(int i=0;i<(n);i++)

int main() {
	int N;
	scanf("%d", &N);
	if (N % 10 == N / 100) printf("Yes\n");
	else printf("No\n");
	return 0;
}

Measured memory_bytes: 256
from itertools import accumulate, permutations, combinations, product, combinations_with_replacement
from math import floor, ceil, sqrt, factorial, log
from bisect import bisect_left, bisect_right
from collections import Counter, defaultdict
from heapq import heappop, heappush, heappushpop
from itertools import product
import sys
stdin = sys.stdin
mod = 10**9 + 7


def ns(): return stdin.readline().rstrip()


def ni(): return int(ns())


def na(): return list(map(int, stdin.readline().split()))


a, b = na()
print(max(0, a - 2 * b))


Measured memory_bytes: 3316
#include<iostream>
#include <algorithm>
#include <vector>
#include <deque>
#include <queue>
#include <set>

using namespace std;

int main()
{
    // 整数の入力
    long long  N,K,i,a_i,result;
    cin >> N >> K;
    long long* numberCount = new long long[N+1];
    priority_queue<long long, vector<long long>, greater<long long>> countMins;

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

    for(i=0;i<N;i++){
        cin >> a_i;;
        numberCount[a_i]++;
    }

    for(i=0;i<=N;i++){
        countMins.push(numberCount[i]);
    }

    result = 0;
    for(i=0;i<=N-K;i++){
        result += countMins.top();
        countMins.pop();
    }

    cout << result << endl;

    return 0;
}

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

int main(){
    int n, i;
    string s;
    cin >> n;
    cin >> s;
    int count = 0;
    for(i = 0; i < n - 2; i++){
        if(s.substr(i, 3) == "ABC") count++;
    }
    cout << count << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
typedef long long ll;
int main() {
    // ifstream in("data1.txt");
    // cin.rdbuf(in.rdbuf());
    int N, T, A;
    cin >> N >> T >> A;
    int m = 1e9;
    int ans = 0;
    for(int i = 1; i <= N; i++) {
        int c;
        cin >> c;
        int d = (T * 1000 - c * 6) - A * 1000;
        if(d < 0)
            d = -d;
        if(m > d) {
            m = abs(A - d);
            ans = i;
            // cout << m << endl;
        }
    }

    cout << ans << endl;
}


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

const long INF = 1e+18;


int main()
{
    int A, B, Q;
    cin >> A >> B >> Q;

    long s[100002], t[100002], x[100002];
    s[0] = t[0] = - INF;
    for( int i = 1; i <= A; ++i ) cin >> s[i];
    for( int i = 1; i <= B; ++i ) cin >> t[i];
    for( int i = 0; i <  Q; ++i ) cin >> x[i];
    s[A+1] = t[B+1] = INF;


    for( int i = 0; i < Q; ++i )
    {
        long ans = INF;
        
        // lower_bound は二分探索, 探索する配列がソートされている必要あり
        // x[i] <= s[Aa], x[i] <= t[Ba] となる最小の Aa, Ba を探す
        int Aa = (int)(lower_bound(s, s+A+2, x[i]) - s);
        int Ba = (int)(lower_bound(t, t+B+2, x[i]) - t);
        
        // 8通りの全通りを探索して最小値を求める
        for( int j = Aa-1; j <= Aa; ++j ){
            for( int k = Ba-1; k <= Ba; ++k ){
                long d1 = abs(s[j] - x[i]) + abs(t[k] - s[j]);
                long d2 = abs(t[k] - x[i]) + abs(s[j] - t[k]);
                d1 = min( d1, d2 );
                ans = min( ans, d1 );
            }
        }
        cout << ans << endl;
    }

    return 0;
}

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

//repetition
#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)

//container util
#define all(x) (x).begin(),(x).end()

//typedef
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VLL;
typedef vector<VLL> VVLL;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;

//const value
//const ll MOD = 1e9 + 7;
//const int dx[] = {0,1,0,-1};//{0,0,1,1,1,-1,-1,-1};
//const int dy[] = {1,0,-1,0};//{1,-1,0,1,-1,0,1,-1};

//conversion
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
inline ll toLL(string s) {ll v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}


int main(){

  double w,h,x,y;
  cin >> w >> h;
  cin >> x >> y;
  double a[2];
  double b[2];

  printf("%0.10lf",h*w/2);
  if((int)h % 2 == 0 && (int)w % 2 == 0){
    if(h/2 == y && w/2 == x){
      cout << ' ' << 1 << endl;
      return 0;
    }
  }
  cout << ' ' << 0 << endl;
  return 0;

}


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

int main(){
  string c;
  cin >> c;
  
  if(c == "a") cout << "b";
  else if(c == "b") cout << "c";
  else if(c == "c") cout << "d";
  else if(c == "d") cout << "e";
  else if(c == "e") cout << "f";
  else if(c == "f") cout << "g";
  else if(c == "g") cout << "h";
  else if(c == "h") cout << "i";
  else if(c == "i") cout << "j";
  else if(c == "j") cout << "k";
  else if(c == "k") cout << "l";
  else if(c == "l") cout << "m";
  else if(c == "m") cout << "n";
  else if(c == "n") cout << "o";
  else if(c == "o") cout << "p";
  else if(c == "p") cout << "q";
  else if(c == "q") cout << "r";
  else if(c == "r") cout << "s";
  else if(c == "s") cout << "t";
  else if(c == "t") cout << "u";
  else if(c == "u") cout << "v";
  else if(c == "v") cout << "w";
  else if(c == "w") cout << "x";
  else if(c == "x") cout << "y";
  else if(c == "y") cout << "z";
  return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<functional>
#include<algorithm>
#include<cstring>
using namespace std;
void func(int);
int main(void)
{
	int n,i,cnt;
	char s[100001];
	scanf("%d",&n);
	scanf("%s",s);
	cnt=0;
	i=0;
	while(i<n-1)	{
		if(s[i]!=s[i+1])	{
			cnt++;
			i+=2;
		}
		else i++;
	}
	printf("%d\n",cnt);	
	return 0;
}


Measured memory_bytes: 2856