akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<math.h>
#include <algorithm>
#include<float.h>
#include <limits>
#include <vector> 
#include <numeric>
#include <string.h>

#define rep(i,a,n) for(ll int (i) = (a);(i) < (n);(i)++)
#define urep(i,a,n) for(ll int (i) = (a);(i) > (n);(i)--)
#define MOD 1000000007
#define ll long long

using namespace::std;

int jo(ll int jxo, ll int jyo){
	ll int jhogeo = 1;
	rep(jinto,0,jyo) jhogeo=jhogeo*jxo;
	return jhogeo;
}
char tobig(char toxbig){
  return (toxbig-0x20);
}
char tolow(char toxlow){
  return (toxlow+0x20);
}
  


int main(){
  string s;
  cin>>s;
  int ans=0;
  if(s[0]=='a'||s[1]=='a'||s[2]=='a') ans++;
    if(s[0]=='b'||s[1]=='b'||s[2]=='b') ans++;
      if(s[0]=='c'||s[1]=='c'||s[2]=='c') ans++;

  cout<<(ans==3?"Yes":"No");
}
// int *p = new int[N];

//  vector<int> 変数名(要素数);
//  sort(変数名.begin(),変数名.end());//昇順ソート

// vector<vector<int>> 変数名(左の個数, vector<int>(右の個数));

//


Measured memory_bytes: 256
#!/usr/bin/env python3
import sys, math, fractions, itertools


def solve(D: int, G: int, p: "List[int]", c: "List[int]"):
    mn = 1e5
    for i in range(1 << D):
        score = 0
        count = 0
        for j in range(D):
            if i >> j & 1 == 1:
                score += p[j] * 100 * (j+1) + c[j]
                count += p[j]
        if score >= G:
            mn = min(mn, count)
            continue
        for k in range(D):
            j = D - k - 1
            if i >> j & 1 == 0:
                if score + 100*(j+1)*(p[j]-1) >= G:
                    count += math.ceil((G - score) / (100*(j+1)))
                    score += 100*(j+1)*count
                    break
                else:
                    score += 100*(j+1)*(p[j]-1)
                    count += p[j] - 1
        # print(score, count)
        if score >= G:
            mn = min(mn, count)
    print(mn)
    return


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    D = int(next(tokens))  # type: int
    G = int(next(tokens))  # type: int
    p = [int()] * (D)  # type: "List[int]" 
    c = [int()] * (D)  # type: "List[int]" 
    for i in range(D):
        p[i] = int(next(tokens))
        c[i] = int(next(tokens))
    solve(D, G, p, c)

if __name__ == '__main__':
    main()


Measured memory_bytes: 5084
#include<bits/stdc++.h>
using namespace std;
typedef complex<double> P;
typedef vector<P> vec;

namespace std{
  bool operator < (const P &a,const P &b){
    return (a.imag()==b.imag()?
            a.real()<b.real():
            a.imag()<b.imag());
  }
};

double eps=1e-8;
double PI=acos(-1);

bool eq(double a,double b){return (b-a<eps&&a-b<eps);}
double dot(P a,P b){return real(b*conj(a));}
double cross(P a,P b){return imag(b*conj(a));}
P project(P a,P b,P c){b-=a;c-=a;return a+b*real(c/b);}
P reflect(P a,P b,P c){b-=a;c-=a;return a+conj(c/b)*b;}
int ccw(P a,P b,P c){
  b-=a,c-=a,a=c*conj(b);
  if(a.imag()>eps)return 1;//ccw
  if(a.imag()<-eps)return -1;//cw
  if(a.real()<-eps)return 2;//ob
  if(abs(b)+eps<abs(c))return -2;//of
  return 0;//os
}

//segment ab , point c
double dist(P a,P b,P c){
  if(dot(b-a,c-a)<0)return abs(c-a);
  if(dot(a-b,c-b)<0)return abs(c-b);
  return abs(cross(b-a,c-a))/abs(b-a);
}

bool isintersect(P a,P b,P c,P d){
  return ((ccw(a,b,c)*ccw(a,b,d)<=0)&&(ccw(c,d,a)*ccw(c,d,b)<=0));
}

//segment ab , segment cd
P intersect(P a,P b,P c,P d){
  a-=d;b-=d;c-=d;
  return d+a+(b-a)*imag(a/c)/imag(a/c-b/c);
}

double dist(P a,P b,P c,P d){
  if(isintersect(a,b,c,d))return 0;
  double ab=min(dist(a,b,c),dist(a,b,d));
  double cd=min(dist(c,d,a),dist(c,d,b));
  return min(ab,cd);
}

double calcArea(vec &t){
  double res=0;
  int n=t.size();
  for(int i=0;i<n;i++)res+=cross(t[i],t[(i+1==n?0:i+1)]);
  return abs(res/2.0);
}

double Arg(P a,P b,P c){
  b-=a,c-=a;
  return arg(c*conj(b));
}

int inPolygon(vec &t,P p){
  int n=t.size();
  double sum=0;  
  for(int i=0;i<n;i++){
    P a=t[i],b=t[(i+1==n?0:i+1)];
    if( ccw(a,b,p) == 0 )return 1;// on
    sum+= Arg(p,a,b);
  }
  if( abs(sum) < eps )return 0;//out
  else  return 2;//in
}

typedef pair<double,P> Pair;

vec andrewScan(vec &t){
  int N=t.size(),C=0;
  vec R(N);
  for(int i=0;i<N;i++){
    while(2<=C&&ccw(R[C-2],R[C-1],t[i])==-1)C--;
    R[C++]=t[i];
  }
  vec res(C);
  for(int i=0;i<C;i++)res[i]=R[i];
  return res;
}

vec ConvexHull2(vec &t){
  sort(t.begin(),t.end());
  vec u=andrewScan(t);
  reverse(t.begin(),t.end());
  vec l=andrewScan(t);
  for(int i=1;i+1<(int)l.size();i++)u.push_back(l[i]);
  return u;
}

vec ConvexHull(vec &t){
  vector<Pair> u;
  vec R;
  int N=t.size(),K=0,C=0;
  for(int i=1;i<N;i++)if(t[i]<t[K])K=i;
  for(int i=0;i<N;i++)u.push_back(Pair(arg(t[i]-t[K]),t[i]));
  R.push_back(t[K]),C++;
  sort(u.begin(),u.end());
  for(int i=0;i<N;i++){
    P p=u[i].second;
    if(2<=C&&ccw(R[C-2],R[C-1],p)==0)continue;
    if(2<=C&&ccw(R[C-2],R[C-1],p)==2)continue;
    while(2<=C&&ccw(R[C-2],R[C-1],p)!=1)R.pop_back(),C--;
    R.push_back(p),C++;    
  }
  return R;
}

int main(){
  int n;
  cin>>n;
  vec t;
  double x,y;
  for(int i=0;i<n;i++){
    cin>>x>>y;
    t.push_back(P(x,y));
  }
  vec ans=ConvexHull2(t);
  cout<<ans.size()<<endl;
  for(int i=0;i<(int)ans.size();i++){
    cout<<(int)ans[i].real()<<' '<<(int)ans[i].imag()<<endl;
  }
  return 0;
}

Measured memory_bytes: 6236
sx, sy, tx, ty = [int(coodinate) for coodinate in input().split()]
dx = tx - sx
dy = ty - sy

ans = ('L' + 'U' * (dy + 1) + 'R' * (dx + 1) +
    'D' * (dy + 1) + 'L' * dx + 'U' * dy +
    'R' * (dx + 1) + 'D' * (dy + 1) + 'L' * (dx + 1) +
    'U')    

print(ans)

Measured memory_bytes: 3060
n = int(input())
n += 1
ln0 = 2
ln1 = 1
if n == 0:
    print(ln0)
elif n==1:
    print(ln1)
else:
    for i in range(n-2):
        now = ln1
        ln1 = ln1+ln0
        ln0 = now
    print(ln1)


Measured memory_bytes: 2940
import sys

input = lambda: sys.stdin.readline().rstrip()


def solve():
    A, B = map(int, input().split())

    c = 1
    ans = 0

    while True:
        if c < B:
            c += (A - 1)
            ans += 1
        else:
            break

    print(ans)


if __name__ == '__main__':
    solve()


Measured memory_bytes: 2940
#include <bits/stdc++.h>
#define FOR(i, a, n) for(ll i = (ll)a; i < (ll)n; i++)
#define rep(i, n) FOR(i, 0, n)
#define ALL(x) (x).begin(), (x).end()
using namespace std;
typedef long long ll;

const ll mod = 1e9 + 7;

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

/*-------------------------------------------*/

int n, x, a[200];

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

    cin >> n >> x;
    rep(i, n) cin >> a[i];
    sort(a, a + n);
    ll dp[209][100009];
    rep(i, 100009) dp[0][i] = i;
    rep(i, n) rep(j, 100009) dp[i + 1][j] =
        (dp[i][j % a[i]] + i * dp[i][j]) % mod;
    cout << dp[n][x] << endl;
}

Measured memory_bytes: 159360
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cstdio>
#include <cmath>
#include <tuple>
#include <cassert>
#define rep(i, n) for(i = 0; i < n; i++)
//#define int long long
using namespace std;

signed main() {
	int x;
	cin >> x;
	if (x == 3 || x == 5 || x == 7) cout << "YES" << endl;
	else cout << "NO" << endl;
	return 0;
}

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

int main()
{
    ll N;
    cin >> N;
    vector<double> v(N);
    rep(i, N) cin >> v[i];
    sort(v.begin(), v.end());
    double sum = v[0];
    rep(i, N - 1) sum = (sum + v[i + 1]) / 2;
    cout << sum << endl;

    return 0;
}


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

#define ll long long

int const N = 4e2 + 1;
ll const INF = 1e18 + 1;

int n;
int arr[N];
ll csum[N];

ll dp[N][N];
int vis[N][N];

ll pound(int left, int right)
{
    if (left == right)
        return 0;
    
    if (vis[left][right])
        return dp[left][right];
    
    vis[left][right] = 1;
    
    ll mn = INF;
    for (int i = left; i < right; ++i)
        mn = min(mn, pound(left, i) + pound(i + 1, right) + csum[right + 1] - csum[left]);
    return dp[left][right] = mn;
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    
    cin >> n;
    for (int i = 0; i < n; ++i)
    {
        cin >> arr[i];
        csum[i + 1] += csum[i] + arr[i];
    }
    
    cout << pound(0, n - 1);
    
    return 0;   
}


Measured memory_bytes: 2176
N = int(input())
S = [i for i in input()]
ans = 9999999
cnt = 0
for i in S[1:]:
  if i == 'E':
    cnt += 1
ans = cnt
tmp = cnt
for i in range(N-1):
  if S[i] == 'W':
    tmp += 1
  if S[i+1] =='E':
    tmp -= 1
  if tmp < ans:
    ans = tmp
print(ans)

Measured memory_bytes: 8144
#include <cstdio>

int main()
{
  int n;
  scanf("%d", &n);
  long long l[87] = {2, 1};
  if (n < 2)
  {
    puts("1");
    return 0;
  }
  for (int i = 2; i <= n; ++i)
  {
    l[i] = l[i - 1] + l[i - 2];
  }
  printf("%lld\n", l[n]);
  return 0;
}

Measured memory_bytes: 128
# https://atcoder.jp/contests/abc112/tasks/abc112_c


# ピラミッドの中心は必ず0-100の中にある
# Hは1以上
# 与えられる情報だけで一意に定まる

# 中心座標をa,bと置いたとき、ある点x,yにおける高さは
# h(x,y; a,b)=max(H-|x-a|-|y-b|,0)である。
# ここで、真の高さとの誤差としてe(x,y;a,b)=|h(x,y;a,b) - h(x,y;Cx,Cy)|とすると。
# 任意のx,yでe=0となるa,bが答え。しかしHはわからないので0とする。
# そうすると任意のx,yでe(x,y;a,b)=constとなるa,bが答え。(ただしmaxの扱いが面倒なのでh==0は無視して処理を行う)
# またその定数constはHである

# 座標は10**4点。Nはたかだか100なので 最悪10**6回計算。間に合う。

import numpy as np
from itertools import product

N = int(input())
X, Y, H = [], [], []
for n in range(N):
    x, y, h = list(map(int, input().split()))
    # if h == 0:
    #     continue
    X.append(x)
    Y.append(y)
    H.append(h)

if N == 1:
    print(x, y, h)
    exit()

X = np.array(X)
Y = np.array(Y)
H = np.array(H)


def is_eq_loss(X, Y, H, a, b):
    loss = np.abs(- np.abs(X - a) - np.abs(Y - b) - H)
    mask = (H == 0)  # 高さがない疑いのところは最小値に合わせる
    if np.any(mask):
        loss[mask] = loss.min()
    # print(loss[-1])
    if (loss[-1] == loss).all():
        return True, loss[-1]
    else:
        return False, False


for a, b in product(range(101), range(101)):
    flg, ansH = is_eq_loss(X, Y, H, a, b)
    if flg:
        ans = (a, b, ansH)

print(*ans)


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


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int x[20][20];
bool check(int a,int b){
    ll sum=0;
    for(int i=0;i<20;i++) sum+=(x[a][i]-x[b][i])*(x[a][i]-x[b][i]);
    int tmp=sqrt(sum);
    if(tmp*tmp==sum) return 1;
    else return 0;
}
int main(){
    int n,d;cin>>n>>d;
    for(int i=1;i<=n;i++)
        for(int j=1;j<=d;j++) cin>>x[i][j];
    int ans=0;
    for(int i=2;i<=n;i++) for(int j=1;j<i;j++) if(check(i,j)) ans++;
    cout<<ans<<endl;
    return 0;
}


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

using namespace std;
typedef long long int ll;

int n, l, t, sh = 0;
vector <int> p;

int main()
{
	ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	cin >> n >> l >> t;
	for(int i = 0; i < n; i++){
		int x, ty;
		cin >> x >> ty;
		if(ty == 1){
			p.push_back((x + t) % l);
			sh += ((x + t) / l);
		//	cout << "+" << ((x + t) / l) << '\n';
		}
		else{
			p.push_back((((x - t) % l) + l) % l);
			x = l - x;
			sh -= ((x + t - 1) / l);
		//	cout << "-" <<  ((x + t - 1) / l) << '\n';
		}
		//cout << "sh:" << sh << '\n';
	}
	sort(p.begin(), p.end());
	sh %= n; sh += n; sh %= n;
	for(int i = sh; i < n; i++)
		cout << p[i] << endl;
	for(int i = 0; i < sh; i++)
		cout << p[i] << endl;
	//cout << "sh: " << sh << endl;
	return 0; 
}


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

int main() {
  int N,M;
  cin >> N >> M;
  vector<int> L(M);
  vector<int> R(M);
  for (int i=0;i<M;i++){
  cin >> L.at(i) >> R.at(i);
  }
  sort (L.begin(),L.end());
  sort (R.begin(),R.end());
  
  if (L.at(M-1)>R.at(0)){
  cout << 0 << endl;
  }
  else {
  cout << R.at(0)-L.at(M-1)+1 <<endl;
  }
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
 
#define INF 0x3f3f3f3f
#define MOD 1000000007
#define si(x) scanf("%d",&x)
#define sii(x,y) scanf("%d%d",&x,&y)
#define siii(x,y,z) scanf("%d%d%d",&x,&y,&z)
#define sl(x) scanf("%lld",&x)
#define sll(x,y) scanf("%lld%lld",&x,&y)
#define slll(x,y,z) scanf("%lld%lld%lld",&x,&y,&z)
 
#define ll long long
#define mp make_pair
#define pb push_back
#define nl printf("\n");
#define pf printf
#define rep(i,n) for(ll i=0;i<n;i++)
#define repi(i,a,b) for(ll i=a;i<b;i++)
#define vint vector<int>
#define tci int t;scanf("%d",&t);while(t--)
const int maxn=10e6+4;

int main()
{
    ifstream myFile("task.in");
    if(!myFile.fail())
    {
        assert(freopen("task.in", "r", stdin));
    }
    
    int n;
    si(n);
    int x=0,y=0,t=0;
    rep(i,n)
    {
        int ct,cx,cy;
        siii(ct,cx,cy);
        t=ct-t;
        int l=abs(x-cx)+abs(y-cy);

        if(l>t)
        {
            cout<<"No";
            return 0;
        }
        if(l%2==0)
        {
            if(t%2!=0)
            {
                cout<<"No";
                return 0;
            }
        }
        if(l%2==1)
        {
            if(t%2!=1)
            {
                cout<<"No";
                return 0;
            }

        }
        x=cx;y=cy;t=ct;
        
    }
    cout<<"Yes";
    
    return 0;
}

Measured memory_bytes: 256
N = int(input())
A = [int(a) for a in input().split()]

L = []
for i in range(N):
    L.append(A[i]-1)
    L.append(A[i])
    L.append(A[i]+1)
    
L.sort()
num = L[0]
cnt = 0
ans = 0
for i in range(len(L)+1):
    if i < len(L) and num == L[i]:
        cnt += 1
    else:
        ans = max(ans, cnt)
        cnt = 1
        num = L[min(i, len(L)-1)]
        
print(ans)

Measured memory_bytes: 17764
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int n;
int a[1005];
int k;
int main(void){
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>a[i];
		if(a[i]!=i+1) k++;
	}
	if(k==2||k==0){
		cout<<"YES"<<endl;
	}else{
		cout<<"NO"<<endl;
	}
    
}


Measured memory_bytes: 256
/*
гонфлад
*/
#pragma ARCENIY_KIRILLOV_UVIDEL_KROKODILOV
//#pragma comment(linker, "/stack:200000000")
//#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//#pragma GCC optimize("no-stack-protector")
//#pragma GCC push_options
//#pragma GCC optimize ("unroll-loops")
//#pragma GCC pop_options
#include<bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define rng(a) a.begin(), a.end()
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
using namespace std;
typedef long long ll;



main(){
    int n, a, b, c, d;
    cin >> n >> a >> b >> c >> d;
    string s;
    cin >> s;
    for (int i = 0; i < n - 1; i++){
        if (s[i] == '#' && s[i+1] == '#'){
            if( (a < i + 1 && i + 1 < c) || (b < i + 1 && i + 1 < d) ){
                cout << "No";
                return 0;
            }
        }
    }
    if (c > d){
        for (int i = b - 2; i < d - 1; i++){
            if (s[i] == '.' && s[i+1] == '.' && s[i+2] == '.'){
                cout << "Yes";
                return 0;
            }
        }
        cout << "No";
        return 0;
    }
    cout << "Yes";
    return 0;



}


Measured memory_bytes: 640
import java.util.*;

public class Main {
    public static void main(String args[]){
        Scanner scanner = new Scanner(System.in);
        String a = scanner.nextLine();
        boolean t = true;

        for(int i = 0;i < a.length()-1;i++){
            if (a.charAt(i) == a.charAt(i + 1)) {
                t = false;
                break;
            }
        }
        
        if (t) {
            System.out.println("Good");
        }else{
            System.out.println("Bad");
        }
    }
}

Measured memory_bytes: 21972
use std::io;
//use std::collections::HashMap;
//use std::collections::BinaryHeap;
//use std::collections::HashSet;
//use std::mem; // mem::swap(&mut x,&mut y);
use std::cmp; // cmp::max,cmp::min

// Rust memo: https://hackmd.io/i0lQY1OKTDW1t66TECOmiw?both

#[allow(dead_code)]
fn read_line() -> String {
    let mut s = String::new();
    io::stdin().read_line(&mut s).unwrap();
    s.trim().to_string()
}

#[allow(dead_code)]
fn read_charvec() -> Vec<char> {
    read_line().chars().collect()
}

#[allow(dead_code)]
fn read_ints() -> Vec<i64> {
    let s = read_line();
    let split: Vec<&str> = s.split(" ").collect();
    split
        .iter()
        .map(|&x| x.to_string().parse().unwrap())
        .collect()
}

#[allow(dead_code)]
fn read_int() -> i64 {
    read_ints()[0]
}

#[allow(dead_code)]
fn reverse(s: &String) -> String {
    s.chars().rev().collect::<String>()
}

#[allow(dead_code)]
fn read_lines(n: i64) -> Vec<String> {
    let mut xs = Vec::new();

    for _i in 0..n {
        xs.push(read_line());
    }

    xs
}

#[allow(dead_code)]
fn read_ints2(n: i64) -> Vec<i64> {
    read_lines(n).iter().map(|x| x.parse().unwrap()).collect()
}

#[allow(dead_code)]
fn arange(start: i64, end: i64, step: i64) -> Vec<i64> {
    let mut ret = Vec::new();
    let mut i = start;

    while i < end {
        ret.push(i);
        i += step;
    }

    ret
}

#[allow(dead_code)]
const DXS: [i64; 4] = [0, 0, 1, -1];
#[allow(dead_code)]
const DYS: [i64; 4] = [1, -1, 0, 0];
#[allow(dead_code)]
const INF: i64 = 999999999;
#[allow(dead_code)]
const N_PRIME: i64 = 1000000007;

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

fn main() {
    let h = read_int();
    let w = read_int();
    let n = read_int();
    let v = cmp::max(h, w);

    println!("{}", (n - 1 + v) / v);
}


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

int main(){
  int W, a, b;
  cin >> W >> a >> b;
  if(b >= a+W){
    cout << b - (a+W) << endl;
  }
  else if(a >= b+W){
    cout << a - (b+W) << endl;
  }
  else{
    cout << 0 << endl;
  }
}

    
    
    

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < (int)n; i++)
#define REPvec(itr, mp) for(auto itr = mp.begin();itr != mp.end(); itr ++)
#define all(x) x.begin(), x.end()
#define MOD 1000000007//1e9+7
using namespace std;
typedef long long ll;
typedef vector<int >    vecint;
typedef vector<string > vecstr;
int main()
{
  int n;
  cin >> n;
  vecint x(n,0);
  int sum = 0;
  REP(i,n){
    cin >> x[i];
    sum += x[i];
  }
  int p1 = sum/n;
  int p2 = sum/n + 1;
  int sum1, sum2;
  sum1 = sum2 = 0;
  REP(i,n){
    sum1 += (x[i] - p1)*(x[i] - p1);
    sum2 += (x[i] - p2)*(x[i] - p2);
  }
  cout << min(sum1, sum2) << endl;
}


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

template<class Abel> struct UnionFind {
    vector<int> par;
    vector<int> rank;
    vector<Abel> diff_weight;

    UnionFind(int n, Abel SUM_UNITY) {
        init(n, SUM_UNITY);
    }

    void init(int n, Abel SUM_UNITY) {
        par.resize(n+1); rank.resize(n+1); diff_weight.resize(n+1);
        for (int i = 0; i <= n; ++i) par[i] = i, rank[i] = 0, diff_weight[i] = SUM_UNITY;
    }

    int root(int x) {
        if (par[x] == x) {
            return x;
        }
        else {
            int r = root(par[x]);
            diff_weight[x] += diff_weight[par[x]];
            return par[x] = r;
        }
    }

    Abel weight(int x) {
        root(x);
        return diff_weight[x];
    }

    bool issame(int x, int y) {
        return root(x) == root(y);
    }

    bool merge(int x, int y, Abel w) {
        w += weight(x); w -= weight(y);
        x = root(x); y = root(y);
        if (x == y) return false;
        if (rank[x] < rank[y]) swap(x, y), w = -w;
        if (rank[x] == rank[y]) ++rank[x];
        par[y] = x;
        diff_weight[y] = w;
        return true;
    }

    Abel diff(int x, int y) {
        return weight(y) - weight(x);
    }
};

int main(){
    int n,q;
    cin >> n >> q;
    UnionFind<int> uf(n,(long long)0);
    int i;
    int w,x,y,z;
    for(i=0; i<q; i++){
        cin >> w;
        if(w==0){
            cin >> x >> y >> z;
            uf.merge(x,y,z);
        }else{
            cin >> x >> y;
            if(uf.issame(x,y)){
                cout << uf.diff(x,y) << endl;
            }else{
                cout << '?' << endl;
            }
        }
    }
    return 0;
}


Measured memory_bytes: 3912
#input
N = int(input())
S = str(input())

#output
from collections import Counter
answer = 0
if N > 3:
    for i in range(1, N-1):
        if S[i] == "R":
            a = Counter(S[:i])["G"]
            b = Counter(S[i+1:])["B"]
            c = Counter(S[:i])["B"]
            d = Counter(S[i+1:])["G"]
            answer += a*b + c*d
            for j in range(1, min(i+1, N-i)):
                if S[i-j] != "R" and S[i+j] != "R" and S[i-j] != S[i+j]:
                    answer -= 1
        elif S[i] == "B":
            a = Counter(S[:i])["R"]
            b = Counter(S[i+1:])["G"]
            c = Counter(S[:i])["G"]
            d = Counter(S[i+1:])["R"]
            answer += a*b + c*d
            for j in range(1, min(i+1, N-i)):
                if S[i-j] != "B" and S[i+j] != "B" and S[i-j] != S[i+j]:
                    answer -= 1
        elif S[i] == "G":
            a = Counter(S[:i])["R"]
            b = Counter(S[i+1:])["B"]
            c = Counter(S[:i])["B"]
            d = Counter(S[i+1:])["R"]
            answer += a*b + c*d
            for j in range(1, min(i+1, N-i)):
                if S[i-j] != "G" and S[i+j] != "G" and S[i-j] != S[i+j]:
                    answer -= 1

print(answer)

Measured memory_bytes: 76652
import sys

read = sys.stdin.read
readline = sys.stdin.buffer.readline
sys.setrecursionlimit(10 ** 8)
INF = float('inf')
MOD = 10 ** 9 + 7


def main():
    W, a, b = map(int, readline().split())
    print(max(max(a,b)-(min(a,b)+W),0))


if __name__ == '__main__':
    main()


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

int main() {
  int n;
  cin>>n;
  int a[n];
  rep(i,0,n) cin>>a[i];
  int ans=1;
  int cur=a[0];
  rep(i,0,n-1){
    if(cur>a[i+1]){
      ans++;
      cur=a[i+1];
    }
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
vector<pair<ll,ll> > factorize(long long n)
{
    vector<pair<ll,ll> >v;
    int count = 0;

    // count the number of times 2 divides
    while (!(n % 2)) {
        n >>= 1; // equivalent to n=n/2;
        count++;
    }

    // if 2 divides it
    v.push_back({2LL,count});

    // check for all the possible numbers that can
    // divide it
    for (long long i = 3; i <= sqrt(n); i += 2) {
        count = 0;
        while (n % i == 0) {
            count++;
            n = n / i;
        }
        v.push_back({i,count});
    }

    // if n at the end is a prime number.
    if (n > 2)
        v.push_back({n,1});
    return v;
}
main()
{
    ll n,p;
    cin>>n>>p;
    vector<pair<ll,ll> >v=factorize(p);
    ll ans=1;
    for(int i=0;i<v.size();i++)
    {
        if(v[i].second>=n)
        {
            ll temp=v[i].second/n;
            while(temp--)
            {
                ans*=v[i].first;
            }
        }
    }
    cout<<ans<<endl;

}


Measured memory_bytes: 4848
#include"bits/stdc++.h"
using namespace std;

typedef long long ll;
#define FOR(i, a, n) for (ll i=(ll)a;i<(ll)n;i++)
#define REP(i, n) FOR(i, 0, n)

#define INF (ll)1e18

/*
int bisect_right(vector<ll> a, ll x){
    int ii = 0;
    int high, low, mid;
    low = 0;
    high = a.size()-1;

    while (low<=high){
        mid = low+(high-low)/2;
        if (a[mid]==x){
            return mid;
        }
        else if (a[mid] < x){
            low =   mid + 1;
            ii = mid + 1;
        }
        else{
            high = mid - 1;
            ii = mid;
        }
    }
    return ii;
}
*/

int main(){
    int a, b, q; cin >> a >> b >> q;
    vector<ll> s; s.resize(a+2);
    vector<ll> t; t.resize(b+2);
    vector<ll> x; x.resize(q);

    s[0] = -INF; s[a+1] = INF;
    REP(i, a){cin >> s[i+1];}
    t[0] = -INF; t[b+1] = INF;
    REP(i, b){cin >> t[i+1];}

    REP(i, q){
        cin >> x[i];
        ll res = INF;
        decltype(s)::iterator itb = lower_bound(s.begin(), s.end(), x[i]);
        decltype(t)::iterator itd = lower_bound(t.begin(), t.end(), x[i]); 
        size_t b = distance(s.begin(), itb);
        size_t d = distance(t.begin(), itd);

        REP(j, 2){
            REP(k, 2){
                ll S = s[b-j];
                ll T = t[d-k];

                ll d1 = abs(T-x[i]) + abs(S-T);
                ll d2 = abs(S-x[i]) + abs(T-S);

                res = min(res, min(d1,d2));
            }
        }
        cout << res << endl;
    }    
}

Measured memory_bytes: 3712
#include <cstdio>
#include <vector>
#include <utility>
using namespace std;

int grid[100][100];

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

    int n;
    scanf("%d", &n);

    vector<int> a;
    for (int i = 0; i < n; i++) {
        int num_a;
        scanf("%d", &num_a);
        a.push_back(num_a);
    }

    // initialize grid
    int grid[h+2][w+2];
    for (int hi = 0; hi < h + 2; hi++) {
        for (int wi = 0; wi < w + 2; wi++) {
            if (hi == 0 || hi == h + 1 || wi == 0 || wi == w + 1) {
                grid[hi][wi] = -1;
            } else {
                grid[hi][wi] = 0;
            }
        }
    }

    int hi = 1, wi = 1;

    // paint in uzumaki-shape
    vector<pair<int, int>> dir;
    dir.push_back(make_pair(1, 0));
    dir.push_back(make_pair(0, 1));
    dir.push_back(make_pair(-1, 0));
    dir.push_back(make_pair(0, -1));
    int di = 0;

    for (int ai = 0; ai < n; ai++) {
        for (int j = 0; j < a[ai]; j++) {
            grid[hi][wi] = ai + 1;
            if (grid[hi+dir[di].first][wi+dir[di].second] != 0) {
                di = (di + 1) % 4;
            }
            hi += dir[di].first;
            wi += dir[di].second;
        }
    }

    for (int hi = 1; hi < h + 1; hi++) {
        for (int wi = 1; wi < w + 1; wi++) {
            if (wi > 1) { printf(" "); }
            printf("%d", grid[hi][wi]);
        }
        printf("\n");
    }

    return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
typedef long long ll;
#define rep(i,n) for(ll i = 0; i < (n); ++i )
#define rep_rev(n,i) for(ll i = n; i >= 0; --i )
using namespace std;
using P = pair<int, int>;
const long long INF = 1LL << 60;

int main(){
  ll N,K,ans = 0; cin >> N >> K;
  ll r = N % K;
  if(r == 0) ans = 0;
  else ans = min(r,abs(r-K));
  cout << ans << endl;
  return 0;
}


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

int a[500009] ;

int main()
{
	int n ; 
	cin>>n;
	
	for(int i=0;i<3*n;i++)
	cin>>a[i] ;
	
	sort(a,a+3*n) ;
	
	long long sum1= 0; 
	
	int start =0 , end =3*n -2 ;
	
	while(start<=end)
	{
		sum1+=a[end] ;
		//cout<<a[end]<<"\n" ;
		end-=2 ;
		start++ ;
	}
	
	cout<<sum1<<"\n" ;
	return 0 ; 
	
}

Measured memory_bytes: 1408
s = str(input())

res = ''

slist = []

for i in range(len(s)):
    if s[i] == 'B':
        if slist != []:
            slist = slist[:-1]
    else:
        slist.append(s[i])

for i in range(len(slist)):
    res += slist[i]

print(res)

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

int main(void){
	ll H, W;
	cin >> H >> W;
	ll ans;
	if (H == 1 || W == 1) ans = 1;
	else ans = (H*W+1)/2;
	cout << ans << endl;

	return 0;
}


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

int main ()
{
	int ret;
	int n;

	cin >> n ;

	ret = n % 10;

	switch (ret) {
	case 2:
	case 4:
	case 5:
	case 7:
	case 9:
		cout << "hon" << endl;
		break;
	case 0:
	case 1:
	case 6:
	case 8:
		cout << "pon" << endl;
		break;
	case 3:
	default:
		cout << "bon" << endl;
		break;
	}

	return 0;
}


Measured memory_bytes: 3624
<?php


    $shiki = fgets(STDIN);

    $shiki_list = explode(" ",$shiki);

    $a = $shiki_list[0];
    $b = $shiki_list[1];
    $c = $shiki_list[2];


    if(4*$a*$b<(($c-$a-$b)**2) && ($c-$a-$b)>0){
        echo "Yes";
    }else{
        echo "No";
    }





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

public class Main {
	
	static int N;
	static double[] p;
	static double [][] dp;
	static int INF = Integer.MAX_VALUE / 2;
	static int MOD = 1000000007;
		
	public static void main(String[] args) throws IOException {
		FastScanner sc = new FastScanner(System.in);
		
		N = sc.nextInt();
		p = new double[N+1];
		
		for(int i = 1; i <= N; i++){
			p[i] = sc.nextDouble();
		}
		
		dp = new double[N+1][N+1];
		dp[0][0] = 1;
		
		for(int i = 0; i < N; i++){
			for(int j = 0; j < N; j++){
				dp[i+1][j+1] += dp[i][j] * p[i+1];
				dp[i+1][j] += dp[i][j] * (1 - p[i+1]);
			}
		}
		
		double sum = 0;
		for(int i = (N + 1) / 2; i <= N; i++)
			sum += dp[N][i];
		System.out.println(sum);
		
	}//end main
	
	
}//end Main

class FastScanner {
    private InputStream in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;
    public FastScanner(InputStream in) {
		this.in = in;
	}
    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        }else{
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }
    private int readByte() {
    	if (hasNextByte()) return buffer[ptr++];
    	else return -1;
    }
    private static boolean isPrintableChar(int c){
    	return 33 <= c && c <= 126;
    }
    public boolean hasNext() {
    	while(hasNextByte() && !isPrintableChar(buffer[ptr]))
    		ptr++; return hasNextByte();
    }
    public String next() {
        if (!hasNext()) throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while(isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }
    public long nextLong() {
        if (!hasNext()) throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while(true){
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            }else if(b == -1 || !isPrintableChar(b)){
                return minus ? -n : n;
            }else{
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }
    public int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();
        return (int) nl;
    }
    public double nextDouble() {
    	return Double.parseDouble(next());
    }
}


Measured memory_bytes: 131920
#include <bits/stdc++.h>
using namespace std;
int n, a[15], ji; long long tot = 1, mor = 1;
int main(){
	scanf( "%d", &n );
	for( int i = 1; i <= n; i++ ){
		tot *= 3, scanf( "%d", &a[i] );
		if( ( a[i] & 1) == 0 ) mor *= 2;
	}
	cout<<tot-mor<<endl;
}

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

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define FORR(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define RANGE(i,a,b) for(int i=(a);i<=(b);i++)
#define RANGER(i,a,b) for(int i=(b);i>=(a);i++)
#define REP(i,n) FOR(i,0,n)
#define REPR(i,n) FORR(i,0,n)
using ll=long long int;
using vi=vector<int>;
using vii=vector<vi>;
using pi=pair<int,int>;
constexpr int INF=1<<30;
constexpr ll INTL=1ll<<60;
int main(){
  int n,x;
  vi l;
  cin>>n>>x;
  l.push_back(0);
  REP(i,n){
    int xx;
    cin>>xx;
    l.push_back(xx);
  }
  int result=0;
  int suml=0;
  for(auto& xx:l){
    suml+=xx;
    if(suml>x)break;
    result++;
  }
  cout<<result<<endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
	ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);

	int t = 1;
	//cin >> t;
	while(t--){
		int a;
		cin >> a;
		cout << a + (a * a) + (a * a * a) << endl;
	}
	return 0;
}

Measured memory_bytes: 3644
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
#define rep(i,n) for(int i=0, i##_len=(int)(n); i<i##_len; i++)
#define reps(i,n) for(int i=1 , i##_len=(int)(n);i<=i##_len;i++)
#define rrep(i,n) for(int i=((int)(n)-1);i>=0;i--)
#define rreps(i,n) for(int i=((int)(n));i>0;i--)
#define repi(i,x) for(auto i=(x).begin(),i##_fin=(x).end();i!=i##_fin;i++)
#define all(x) (x).begin(), (x).end()
#define F first
#define S second
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define eb emplace_back
string solve(bool a) { return ((a) ? "Yes" : "No"); }
typedef vector<int> Vi;
typedef vector<Vi> VVi;
typedef pair<int , int> Pi;
typedef vector<Pi> VPi;
typedef vector<long long> V;
typedef vector<V> VV;
typedef pair<long long , long long> P;
typedef vector<P> VP;
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;}
template <class T, class U>ostream& operator<<(ostream& os, const pair<T, U>& p) {
	os << "(" << p.first << "," << p.second << ")";
	return os;
}
template <class T>ostream& operator<<(ostream& os, const vector<T>& v) {
	os << "{";
	rep(i, v.size()) {
		if (i) os << ",";
		os << v[i];
	}
	os << "}";
	return os;
}
template <class T, class U>istream& operator>>(istream& is, pair<T, U>& p) {
	is >> p.first >>p.second ;
	return is;
}
template <class T>istream& operator>>(istream& is,  vector<T>& v) {
	rep(i, v.size()) {
		is >> v[i];
	}
	return is;
}
const long long INFLL = 1LL<<60;
const int INF = 1<<30;
const double PI=acos(-1);
int main(){
	string a;
	int ans=0;
	cin >>a;
	int cnt = 0;
	rep(bit,1<<3){
		cnt = a[0]-'0';
		rep(i,3){
			if(bit&(1<<i)){
				cnt += (a[i+1] - '0');
			}else{
				cnt-= (a[i+1] - '0');
			}
		}
	//	clog << cnt << endl;
		if(cnt==7){
			rep(i, 3) { cout << a[i] << (bit & (1 << i) ? '+' : '-'); }
			cout << a[3] << "=7" << endl;
			return 0;
		}
	
	}
}

Measured memory_bytes: 3624
# 都市の情報を格納するクラス
class ipy:
    def __init__(self, i, p, y):
        # 都市番号(全体)
        self.i = i
        # 県番号
        self.p = p
        # 誕生年
        self.y = y


N, M = map(int, input().split())
# 都市の情報を格納するipyのリスト
list_ipy = []
# 入力を受け取り、list_ipyの格納
for i in range(M):
    p, y = map(int, input().split())
    list_ipy.append(ipy(i, p, y))
# 都市を誕生年順にソート
list_ipy.sort(key=lambda x: x.y)
# 県の都市の数をカウントする辞書
p_count = {}
# 出力するidの２つの整数を格納する辞書
out = {}
# すべての都市xについてループ
for x in list_ipy:
    # 県の都市のカウントを増やす
    if x.p in p_count:
        p_count[x.p] += 1
    else:
        p_count[x.p] = 1
    # 全体のx.i番目の都市はx.p県のx.p番目の都市
    out[x.i] = [x.p, p_count[x.p]]
# idを出力する
for k in out:
    print('{0:06d}{1:06d}'.format(out[k][0], out[k][1]))


Measured memory_bytes: 53412
import java.util.*;

class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String S = sc.next();
        sc.close();

        for (int i=0; i<Math.pow(2,S.length()-1); i++) {
            int sum = Integer.parseInt(S.substring(0, 1));
            StringBuilder sb = new StringBuilder();
            sb.append(S.substring(0, 1));
            String b = zeroP(Integer.toBinaryString(i), S.length()-1);
            for (int j=1; j<S.length(); j++) {
                if ("1".equals(b.substring(j-1, j))) {
                        sum += Integer.parseInt(S.substring(j, j+1));
                        sb.append("+" + S.substring(j, j+1));
                } else {
                    sum -= Integer.parseInt(S.substring(j, j+1));
                    sb.append("-" + S.substring(j, j+1));
                }
            }
            if (sum==7) {
                System.out.println(sb + "=7");
                break;
            }
        }
    }

    public static String zeroP(String S, int a) {
        while (S.length()<a) {
            S = "0" + S;
        }
        return S;
    }
}

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

int main(){
  double r;
  cin >> r;

  printf("%.6lf %.6lf\n", r*r*M_PI, 2*r*M_PI);

  return 0;
}



Measured memory_bytes: 3284
import sys
N = int(input())
base = ['AC','WA','TLE','RE']
array = [ input() for a in range(N) ]

if not ( 1 <= N <= 10**5 ): sys.exit()
for I in array:
    if I not in base: sys.exit()

for I in base:
    print(I+' x '+str(array.count(I)))

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

using ll=long long;
#define int ll

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

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

signed main(){
	int N=read(),M=read();
	int town[N]={0};
	REP(i,M){
		REP(j,2){
		int tmp = read()-1;
		town[tmp]++;
		}
	}
	
	REP(i,N) cout << town[i] << endl;
}

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

#define rep(i,n) for(ll (i)=0;(i)<(ll)(n);(i)++)
#define all(x) (x).begin(),(x).end()
#define MOD 1000000007LL
#define INF (1LL<<60LL)
#define int long long
typedef long long ll;

using namespace std;



signed main() {
	string s1, s2; cin >> s2 >> s1;
	cout << s1 << s2 << endl;
}

Measured memory_bytes: 256
n, t, s = gets.split.map(&:to_i)
arr = n.times.map{ gets.split.map(&:to_i) }
dp = 2.times.map{ [0]*(t+1) }
ret = 0
n.times do |i|
  (t-arr[i][1]+1).times do |j|
    dp[1][j + arr[i][1]] = [dp[1][j + arr[i][1]], dp[0][j] + arr[i][0]].max if !(j + arr[i][1] > s && s > j)
    ret = [ret, dp[1][j + arr[i][1]]].max
  end
  dp[0] = dp[1].dup
end
p ret

Measured memory_bytes: 28176
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
#include<set>
#include<string>
#include<stdio.h>
#include<cmath>
#include<map>
#include<bitset>

using namespace std;

#define rep(i, n) for(int i = 0; i < n; i++)
#define repn(i, n) for(int i = 1; i <= n; i++)
#define repr(i, n) for(int i = n-1; i >= 0; i--)
#define all(x) (x).begin(), (x).end()
#define lint long long


int main(){
    int n; cin >> n;
    int u, v; cin >> u >> v; u--; v--;
    vector<int> to[100001];
    rep(i, n-1){
        int a, b; cin >> a >> b; a--; b--;
        to[a].push_back(b);
        to[b].push_back(a);
    }

    queue<int> bfs;
    vector<int> dist_u(100001); fill(all(dist_u), -1);
    bfs.push(u);
    dist_u[u] = 0;
    while(!bfs.empty()){
        int x = bfs.front(); bfs.pop();
        for(int& y : to[x]){
            if(dist_u[y] != -1) continue;
            dist_u[y] = dist_u[x] + 1;
            bfs.push(y);
        }
    }

    vector<int> dist_v(100001); fill(all(dist_v), -1);
    bfs.push(v);
    dist_v[v] = 0;
    while(!bfs.empty()){
        int x = bfs.front(); bfs.pop();
        for(int& y : to[x]){
            if(dist_v[y] != -1) continue;
            dist_v[y] = dist_v[x] + 1;
            bfs.push(y);
        }
    }

    vector<bool> seen(100001); fill(all(seen), false);
    bfs.push(u);
    int ans = 0;
    while(!bfs.empty()){
        int x = bfs.front(); bfs.pop();
        for(int& y : to[x]){
            if(seen[y]) continue;
            if(dist_u[y] < dist_v[y]){
                bfs.push(y);
            }
            if(to[y].size() != 1){
                ans = max(ans, dist_v[y]);
            }
            seen[y] = true;
        }
    }
    cout << ans << endl;

}

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

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

using namespace std;

template <class T>
using vec = std::vector<T>;
typedef long long ll;
template <class T>
inline bool chmin(T &a, T b)
{
    if (a > b)
    {
        a = b;
        return true;
    }
    return false;
}
template <class T>
inline bool chmax(T &a, T b)
{
    if (a < b)
    {
        a = b;
        return true;
    }
    return false;
}

const long long INF = 1LL << 60;

const double PI = acos(-1.0);

// long long積のオーバーフロー検出
bool detect_mul_overflow(ll a, ll b)
{
    return a >= LONG_MAX / b;
}

int lcm(int a, int b)
{
    //最小公倍数
    return a / __gcd(a, b) * b;
}

struct edge
{
    int from, to, cost;
};

// int型の2次元配列(3×4要素の)の宣言
// vector<vector<int>> data(3, vector<int>(4));
int x;

int main()
{
    cin>>x;
    if(x>=30){
        cout<<"Yes"<<endl;
    }else{
        cout<<"No"<<endl;
    }
    return 0;
}


Measured memory_bytes: 3620
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO ?????????????????????????????????????????????
		Scanner sc = new Scanner(System.in);
		String line1 = sc.nextLine();
		int n = Integer.parseInt(line1);
		String[] cards = new String[n];
		for (int i = 0; i < n; i++) {
			cards[i] = sc.nextLine();
		}
		
		int Tpoint = 0;
		int Hpoint = 0;
		
		for (int i = 0; i < n; i++) {
			String[] kari = cards[i].split(" ");
			if (kari[0].compareTo(kari[1]) > 0) {
				Tpoint += 3;
			} else if (kari[0].compareTo(kari[1]) == 0) {
				Tpoint++;
				Hpoint++;
			} else if (kari[0].compareTo(kari[1]) < 0) {
				Hpoint += 3;
			}
		}
		
		System.out.print(Tpoint);
		System.out.print(" ");
		System.out.println(Hpoint);
	}

}

Measured memory_bytes: 31364
const int LG = 21;
const int FN = 400005;
const long long MOD = 1e9 + 7;
const long long INF = 1e9;
const long long INFLL = 1e18;

#include <bits/stdc++.h>

using namespace std;

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

#define forn(i, n) for (int (i) = 0; (i) != (n); (i)++)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define popcount(x) __builtin_popcount(x)
#define popcountll(x) __builtin_popcountll(x)
#define fi first
#define se second
#define re return
#define pb push_back
#define uniq(x) sort(all(x)); (x).resize(unique(all(x)) - (x).begin())

#ifdef LOCAL
#define dbg(x) cerr << __LINE__ << " " << #x << " " << x << endl
#define ln cerr << __LINE__ << endl
#else
#define dbg(x) void(0)
#define ln void(0)
#endif // LOCAL

int cx[4] = {-1, 0, 1, 0};
int cy[4] = {0, -1, 0, 1};
string Ans[2] = {"No", "Yes"};
string ANS[2] = {"NO", "YES"};

ll inq(ll x, ll y)
{
    if (!y) re 1 % MOD;
    ll l = inq(x, y / 2);
    if (y % 2) re l * l % MOD * x % MOD;
    re l * l % MOD;
}

ll rev(ll x)
{
    return inq(x, MOD - 2);
}

bool __precomputed_combinatorics = 0;
vector<ll> __fact, __ufact, __rev;

void __precompute_combinatorics()
{
    __precomputed_combinatorics = 1;
    __fact.resize(FN);
    __ufact.resize(FN);
    __rev.resize(FN);
    __rev[1] = 1;
    for (int i = 2; i < FN; i++) __rev[i] = MOD - __rev[MOD % i] * (MOD / i) % MOD;
    __fact[0] = 1, __ufact[0] = 1;
    for (int i = 1; i < FN; i++) __fact[i] = __fact[i - 1] * i % MOD, __ufact[i] = __ufact[i - 1] * __rev[i] % MOD;
}

ll fact(int x)
{
    if (!__precomputed_combinatorics) __precompute_combinatorics();
    return __fact[x];
}

ll cnk(int n, int k)
{
    if (k < 0 || k > n) return 0;
    if (!__precomputed_combinatorics) __precompute_combinatorics();
    return __fact[n] * __ufact[n - k] % MOD * __ufact[k] % MOD;
}

int Root(int x, vector<int> &root)
{
    if (x == root[x]) return x;
    return root[x] = Root(root[x], root);
}

void Merge(int v, int u, vector<int> &root, vector<int> &sz)
{
    v = Root(v, root), u = Root(u, root);
    if (v == u) return;
    if (sz[v] < sz[u])
    {
        sz[u] += sz[v];
        root[v] = u;
    }
    else
    {
        sz[v] += sz[u];
        root[u] = v;
    }
}

int ok(int x, int n)
{
    return 0 <= x && x < n;
}

void bfs(int v, vi &dist, vector<vi> &graph)
{
    fill(all(dist), -1);
    dist[v] = 0;
    vi q = {v};
    for (int i = 0; i < q.size(); i++)
    {
        for (auto u : graph[q[i]])
        {
            if (dist[u] == -1)
            {
                dist[u] = dist[q[i]] + 1;
                q.push_back(u);
            }
        }
    }
}


signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int a, b;
    cin >> a >> b;
    cout << max(0, a - 2 * b);

}

/* Note:
Check constants at the beginning of the code.
    N is set to 4e5 but be careful in problems with large constant factor.
    Setting N in every problem is more effective.
Check corner cases.
    N = 1
No def int long long for now.
Add something here.
*/


Measured memory_bytes: 256
#!/usr/bin/env python

import sys

class bigint:
    def __init__(self,n,mod=10**9+7):
        self.n = n % mod
        self.mod = mod
        return
    #
    def __str__(self):
        return str(self.n)
    #
    def __add__(self,other):
        assert self.mod==other.mod, "modulos of the two not match"
        return bigint(self.n+other.n,self.mod)
    #
    def __iadd__(self,other):
        assert self.mod==other.mod, "modulos of the two not match"
        self.n = (self.n + other.n) % self.mod
        return self
    #
    def __sub__(self,other):
        assert self.mod==other.mod, "modulos of the two not match"
        return bigint(self.n-other.n,self.mod)
    #
    def __isub__(self,other):
        assert self.mod==other.mod, "modulos of the two not match"
        self.n = (self.n - other.n) % self.mod
    #
    def __mul__(self,other):
        assert self.mod==other.mod, "modulos of the two not match"
        return bigint(self.n*other.n,self.mod)
    #
    def __imul__(self,other):
        assert self.mod==other.mod, "modulos of the two not match"
        self.n = ( self.n * other.n ) % self.mod
        return self
    #
    def __pow__(self,other):
        assert type(other)==int, "power should be integer"
        #
        if other<0: return self ** ( other % ( self.mod-1 ) )
        elif other==0: return bigint(1,self.mod)
        elif other==1: return self
        elif other%2==0:
            tmp= self ** (other//2)
            return bigint( ( tmp.n**2 ) % self.mod,self.mod )
        else:
            tmp= self ** (other//2)
            return bigint( ( tmp.n**2 * self.n ) % self.mod,self.mod )
    #
    def __truediv__(self,other):
        assert self.mod==other.mod, "modulos of the two not match"
        return self * ( other ** (other.mod-2) )
    #
    def __itruediv__(self,other):
        assert self.mod==other.mod, "modulos of the two not match"
        self*= ( other ** (other.mod-2) )
        return self
#..................................................
fact= list()
def pair(maru,bou):
    global fact
    a= fact[maru+bou]
    b= fact[maru] * fact[bou]
    return a/b
#..................................................
n,k = [ int(x) for x in sys.stdin.readline().split() ]
#
r = n-k
fact.append( bigint(1) )
for i in range(1,n+1): fact.append( fact[i-1]*bigint(i) )

for block in range(1,k+1):
    # blue
    bp = k - block
    tmp = pair(bp,block-1)
    # red
    rp = r - ( block - 1 )
    if rp>=0: tmp *= pair(rp,block)
    else: tmp= 0
    #
    print( tmp )


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

//Function Macros:
#define rep(i, n) for(int(i) = 0; (i) < (n); (i)++)
#define all(v) (v).begin(), (v).end()
#define setpre(n) cout << fixed << setprecision(n)

//Type Definitions:
typedef long long ll;
typedef unsigned long long ull;

//Constants:
const int INF = 2e9;
const int MOD = 1e9 + 7;

//Global Variables:

//Prototype Declarations:
int gcd(int, int);

//================ Main Loop ================
int main() {
    string s;
    cin >> s;
    rep(i, s.size()) {
        cout << "x";
    }
    cout << endl;
    return 0;
}
//===========================================

//Functions:
int gcd(int a, int b) {
    return b ? gcd(b, a % b) : a;
}

Measured memory_bytes: 256