akhauriyash/Code-Regression huggingface dataset:
import sys

def I(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LMI(): return list(map(int, sys.stdin.readline().split()))
MOD = 10 ** 9 + 7


# 有向グラフ各辺のコストを集めて最大化する問題だが、全部符号を変えれば最短経路問題にできる

from math import isinf


class Edge(object):

    def __init__(self, src, dst, cost):
        self.src = src
        self.dst = dst
        self.cost = cost


class BellmanFord(object):

    def __init__(self, v_len, edges, start):
        """
        隣接行列を使っていないので、有向グラフにのみ適用可能。
        ベルマンフォード法によって最短経路を求める。
        ダイクストラと違って負の数も扱えるが、O(|V||E|) なのでダイクストラより遅い。

        :param v_len: グラフのノード数 通常は|V|、1-indexedなグラフなら |V| + 1
        :param edges: 辺のリスト
        :param start: 始点 単一視点最短経路問題として解くので必要
        """
        self._dist = [float('inf') for _ in range(v_len)]  # 始点から各頂点までの最短距離
        self._prev = [float('inf') for _ in range(v_len)]  # 最短経路における，その頂点の前の頂点のIDを格納する

        self._solve(edges, start)

    def _solve(self, edges, start):
        self._dist[start] = 0

        cnt = 0
        while True:  # 更新は高々 |V| - 1 回で終わる
            cnt += 1
            updated = False
            for e in edges:
                if self._dist[e.src] + e.cost < self._dist[e.dst]:
                    self._dist[e.dst] = self._dist[e.src] + e.cost
                    self._prev[e.dst] = e.src
                    if cnt >= len(self._dist):
                        self._dist[e.dst] = float('-inf')
                    updated = True
            if not updated:
                break

    def distance(self, goal):
        """
        負の閉路を含む場合は -inf を返す。
        """
        return self._dist[goal]

    def path(self, goal):
        """
        負の閉路を含む場合は計算が終わらない。
        """
        path = list()
        path.append(goal)
        cursor = goal

        while not isinf(self._prev[cursor]):
            path.append(self._prev[cursor])
            cursor = self._prev[cursor]

        return list(reversed(path))


N, M = MI()
edges = list()
for _ in range(M):
    a, b, c = map(int, input().split())
    edges.append(Edge(a, b, -1 * c))
bf = BellmanFord(N + 1, edges, 1)
print(-1 * bf.distance(N))


Measured memory_bytes: 46440
N=int(input())
A=input().split()
A=[int(A[i]) for i in range(0,N)]
max=A[0]
min=A[0]
for i in range(1,N):
    if max<A[i]:
        max=A[i]
    if min>A[i]:
        min=A[i]
dif=max-min
print(dif)

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

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

    long long l[100];
    l[0] = 2;
    l[1] = 1;
    
    for(int i = 2; i <= n; i++)
    {
        l[i] = l[i - 1] + l[i - 2];
    }
    
    cout << l[n] << endl;
    return 0;
}


Measured memory_bytes: 256
N = gets.chomp.to_i
C = gets.chomp.split("")

$WI = 0
$RI = C.size - 1

def wi()
  for i in $WI...C.size do
    return i if C[i] == "W"
  end
  nil
end

def ri()
  $RI.downto(0) do |i|
    return i if C[i] == "R"
  end
  nil
end

cnt = 0
while true do
  wi = wi()
  ri = ri()

  break if wi == nil || ri == nil
  break if wi >= ri
  C[wi] = "R"
  C[ri] = "W"
  $WI = wi
  $RI = ri
  cnt += 1
end
puts cnt

Measured memory_bytes: 31312
#include <stdio.h>

int main(void)
{
	int W,H;
	int x,y,r;

	scanf("%d%d%d%d%d",&W,&H,&x,&y,&r);
	W-=r,H-=r;
	
	if (r<=x && x<=W && r<=y && y<=H){ 
		printf("Yes\n");
	}
	else{
		printf("No\n");
	}
	return 0;
}


Measured memory_bytes: 2140
import math
S = input()
N_s = int((len(S)-1)/2)-1
N_l = int((len(S)+3)/2)

num = N_s
flg = True
num_std = len(S)-1
for k in range(len(S)):
    if S[k] != S[num_std] and k < num_std:
        flg = False
        print("No")
        break
    if k > num_std:
        break
    num_std -= 1
if flg and len(S) == 3:
    flg = False
    print("Yes")
if flg:
    for i in  range(N_s):
        if not flg:
            break
        if(S[i] != S[num]):
            if(num > i):
                print("No")
                break
        if(num == i or num < i):
            num2 = len(S)-1
            for j in range(N_l-1,len(S),1):
                if(S[j] != S[num2]):
                    if(num2 > j):
                        print("No")
                        break
                if(num2 == j or num < j):
                    print("Yes")
                    flg = False
                    break
                num2 -= 1
        num -= 1
        
    



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

const int N = 2e5;
int n, m;
char a[N] = {};

int main() {
	cin >> a + 1;
	n = strlen(a + 1);
	int T = 0, Max = 0, S = 0;
	for (int i = 1; i <= n; i ++) {
		if (a[i] == 'T') T ++;
		if (a[i] == 'S') S ++;
		Max = max(Max, 2 * (T - S)); 
	}
	printf("%d", Max);
}


Measured memory_bytes: 384
#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;

typedef long long int ll;
typedef unsigned long long int ull;
typedef long double ld;
typedef pair <ll, ll> pll;
typedef pair <int, int> pii;

typedef tree <ll, null_type, less <ll>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
// order_of_key(val): returns the number of values less than val
// find_by_order(k): returns an iterator to the kth largest element (0-based)

#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define all(a) a.begin(), a.end()
#define sz(a) (ll)(a.size())
#define endl "\n"

template <class Ch, class Tr, class Container>
basic_ostream <Ch, Tr> & operator << (basic_ostream <Ch, Tr> & os, Container const& x) 
{
    os << "{ ";
    for(auto& y : x) 
    {
        os << y << " ";
    }
    return os << "}";
}

template <class X, class Y>
ostream & operator << (ostream & os, pair <X, Y> const& p) 
{
    return os << "[" << p.ff << ", " << p.ss << "]";
}

ll gcd(ll a, ll b)
{
    if(b==0)
    {
        return a;
    }

    return gcd(b, a%b);
}

ll modexp(ll a, ll b, ll c)
{   
    a%=c;

    ll ans = 1;

    while(b)
    {
        if(b&1)
        {
            ans = (ans*a)%c;
        }

        a = (a*a)%c;
        b >>= 1;
    }

    return ans;
}

ll nxt()
{
    ll x;
    cin >> x;
    return x;
}

const ll L = 1e5+5;

bool can(ll index, basic_string <ll> a, ll n, ll m, ll v, ll p)
{
    if(v < p)
    {
        if(a[index] + m >= a[n-p])
        {
            return true;
        }

        return false;
    }

    ll voted = m;

    for(ll i=0; i<n; i++)
    {
        if(i == index)
        {
            continue;
        }

        if(i > n - p)
        {
            voted += m;
        }

        else if(a[i] > a[index] + m)
        {
            return false;
        }

        else
        {
            voted += max(0LL, min(m, a[index] + m - a[i]));
        }
    }

    return (voted >= m*v);
}

void solve()
{
    ll n = nxt(), m = nxt(), v = nxt(), p = nxt();
    basic_string <ll> a(n, 0);
    generate(all(a), nxt);
    sort(all(a));

    ll low = 0, high = n;
    ll ans = -1;

    while(low <= high)
    {
        ll mid = low + (high - low)/2;

        if(can(mid, a, n, m, v, p))
        {
            ans = mid;
            high = mid-1;
        }

        else
        {
            low = mid + 1;
        }
    }

    assert(ans != -1);

    cout << n - ans << endl;
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    
    ll T = 1;
    // T = nxt();

    while(T--)
    {
        solve();
    }

    return 0;
}

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

int main(){
	int N,a[100001]={0},index=0;;
	int check;
	scanf("%d",&N);
	for(int i=0;i<N;i++){
		scanf("%d",&check);
		if(check>100000)index++;
		else a[check]++;
	}
	for(int i=0;i<100000;i++){
		if(i>a[i]){
			index+=a[i];
		}else if(i<a[i]){
			index+=a[i]-i;
		}
	}
	printf("%d\n",index);
	return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
int n,a[50];
int main(){
    n=10;
    for(int i=1;i<=n;i++) cin>>a[i];
    sort(a+1,a+1+n);
    for(int i=n;i>=n-2;i--){
        cout<<a[i]<<endl;
    }
}

Measured memory_bytes: 3084
MOD=10**9+7
N,A,B,C=map(int,input().split())

def invmod(a):
  return pow(a,MOD-2,MOD)

A,B=100*A*invmod(A+B),100*B*invmod(A+B)

Apow_list=[]
Bpow_list=[]
Apow=Bpow=1
for _ in range(N+1):
  Apow_list.append(Apow)
  Bpow_list.append(Bpow)
  Apow=(Apow*A)%MOD
  Bpow=(Bpow*B)%MOD

# nCr=n!/r!(n-r)!で計算する関数（計算量n*logMOD）…n,rを変えつつ何度も実行する場合
# 各x!および逆元はテーブルで持っておく
fact_list=[1]
fact_inv_list=[1]
for i in range(1,2*N+1):
  fact_mod=(fact_list[-1]*i)%MOD
  fact_list.append(fact_mod)
  fact_inv_list.append(invmod(fact_mod))
def comb_mod_table(n,r):
  if 0<=r<=n:
    return fact_list[n]*fact_inv_list[r]*fact_inv_list[n-r]
  else:
    return 0
  
answer=0
for M in range(N,2*N):
  bunshi=comb_mod_table(M-1,N-1)
  bunshi*=(Apow_list[N]*Bpow_list[M-N]+Apow_list[M-N]*Bpow_list[N])*M
  bunshi%=MOD  
  bumbo=pow(100,M-1,MOD)*(100-C)%MOD
  term=(bunshi*invmod(bumbo))%MOD
  
  #print(M,term,bunshi,bumbo)
  answer=(answer+term)%MOD
  
print(answer)

Measured memory_bytes: 32628
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define FOR(i,start,end) for(int i=start;i<=end;i++)
const int INF = 1001001001;
using namespace std;
typedef long long ll;

int main()
{
  char S[11];
  int res=0;
  cin >> S;

  int head=0;
  char O[11];
  rep(i,strlen(S)){
    if(S[i]=='0') O[head++]='0';
    if(S[i]=='1') O[head++]='1';
    if(S[i]=='B') {
      if(head>0) head--;
    }
  }

  rep(i,head) cout << O[i];
  cout << endl;

}

Measured memory_bytes: 256
n, _ = gets.to_s.split.map{|t|t.to_i}
h    = [0] + gets.to_s.split.map{|t|t.to_i}

ans = [1] * (n+1)
ans[0] = 0

$<.each do |line|
  
  a, b = line.to_s.split
  a, b = a.to_i, b.to_i
  
  if h[a] < h[b]
    ans[a] = 0
  elsif h[a] > h[b]
    ans[b] = 0
  else
    ans[a] = ans[b] = 0
  end
end

puts ans.sum

Measured memory_bytes: 23272
#pragma region
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define double long double
#define vi vector<int>
#define vd vector<double>
#define vs vector<string>
#define repi(i, m, n) for(int i=(int)(m);i<(int)(n);i++)
#define rep(i, n) repi(i, 0, n)
#define revi(i, m, n) for(int i=(int)(m-1);i>=(int)(n);i--)
#define rev(i, n) revi(i, n, 0)
#define each(i, n) for(auto&& i: n)
#define sz(v) ((int)(v).size()) 
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define uniq(v) (v).erase(unique((v).begin(), (v).end()), (v).end());
#define dump(x) cerr << #x << " = " << x << endl
#define gcd __gcd
int lcm(int a, int b){return a / gcd(a, b) * b;}
const int INF = 1e18;
const int MOD = 1e9 + 7;
const double EPS = 1e-15;
const double PI = acos(-1);
int dig(int n){return (int)(log10(n) + 1);}
int abc(char x){return (int)(x)-(int)('a');} // 0~25
char abc(int x){return (char)(x+(int)('a'));} 
int ABC(char x){return (int)(x)-(int)('A');}
char ABC(int x){return (char)(x+(int)('A'));}
void solve();
signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(20);
	solve();
}
#pragma endregion

void solve() {
	int N; string S, T;
	cin >> N >> S >> T;
	rep(i, N) {
		cout << S[i] << T[i];
	}
	cout << endl;
}

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

using namespace std;

int main()
{
    int K,A,B;
    cin>>K>>A>>B;
    string ans="NG";
    for(int i=A;i<=B;i++){
        if(i%K==0){
            ans="OK";
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n)  for(long long i=0;i<(long long)(n);i++)
#define REP(i,k,n) for(long long i=k;i<(long long)(n);i++)
#define all(a) a.begin(),a.end()
#define pb push_back
#define eb emplace_back
#define lb(v,k) (lower_bound(all(v),k)-v.begin())
#define ub(v,k) (upper_bound(all(v),k)-v.begin())
#define fi first
#define se second
#define pi M_PI
#define PQ(T) priority_queue<T>
#define SPQ(T) priority_queue<T,vector<T>,greater<T>>
#define dame(a) {out(a);return 0;}
#define decimal cout<<fixed<<setprecision(15);
typedef long long ll;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> PP;
typedef tuple<ll,ll,ll,ll> PPP;
typedef multiset<ll> S;
using vi=vector<ll>;
using vvi=vector<vi>;
using vvvi=vector<vvi>;
using vp=vector<P>;
using vvp=vector<vp>;
using vb=vector<bool>;
using vvb=vector<vb>;
const ll inf=1001001001001001;
const int INF=1001001001;
const int mod=1000000007;
const double eps=1e-10;
template<class T> bool chmin(T&a,T b){if(a>b){a=b;return true;}return false;}
template<class T> bool chmax(T&a,T b){if(a<b){a=b;return true;}return false;}
template<class T> void out(T a){if((ll)(a)==inf)cout<<"inf"<<'\n';else if((ll)(a)==-inf)cout<<"-inf"<<'\n';else cout<<a<<'\n';}
template<class T,class U> void outs(T a,U b){if((ll)(a)>=inf-100||(ll)(a)<=-inf+100)out(b);else out(a);}
template<class T> void outp(T a){cout<<'('<<a.fi<<','<<a.se<<')'<<'\n';}
template<class T> void outvp(T v){rep(i,v.size())cout<<'('<<v[i].fi<<','<<v[i].se<<')';cout<<'\n';}
template<class T> void outvvp(T v){rep(i,v.size())outvp(v[i]);}
template<class T> void outv(T v){rep(i,v.size()){if(i)cout<<' ';if((ll)(v[i])==inf)cout<<"inf";else if((ll)(v[i])==-inf)cout<<"-inf";else cout<<(ll)(v[i]);}cout<<'\n';}
template<class T> void outvv(T v){rep(i,v.size())outv(v[i]);}
template<class T> bool isin(T x,T l,T r){return (l)<=(x)&&(x)<=(r);}
template<class T> void yesno(T b){if(b)out("yes");else out("no");}
template<class T> void YesNo(T b){if(b)out("Yes");else out("No");}
template<class T> void YESNO(T b){if(b)out("YES");else out("NO");}
template<class T> void noyes(T b){if(b)out("no");else out("yes");}
template<class T> void NoYes(T b){if(b)out("No");else out("Yes");}
template<class T> void NOYES(T b){if(b)out("NO");else out("YES");}
ll gcd(ll a,ll b){if(b==0)return a;return gcd(b,a%b);}
ll modpow(ll a,ll b){a%=mod;if(b==0)return 1;if(b&1)return a*modpow(a,b-1)%mod;ll k=modpow(a,b/2);return k*k%mod;}
ll solve(ll i){
    ll res=0;
    while(i){
        i/=2;
        res+=i;
    }
    return res;
}
int main(){
    ll n;cin>>n;
    string s;cin>>s;
    bool b=false;
    vi v(n-1);
    rep(i,n-1)v[i]=abs(s[i+1]-s[i])%2;
    rep(i,n)if(s[i]=='2')b=true;
    ll sum=0;
    rep(i,n-1){
        if(v[i])sum^=1-(bool)(solve(n-2)-solve(i)-solve(n-2-i));
    }
    if(sum)dame(1);
    if(b)dame(0);
    rep(i,n-1)v[i]=abs(s[i+1]-s[i])/2;
    rep(i,n-1){
        if(v[i])sum^=1-(bool)(solve(n-2)-solve(i)-solve(n-2-i));
    }
    if(sum)out(2);
    else out(0);
}

Measured memory_bytes: 9220
import math

N,M = map(int,input().split())



def combinations_count(n, r):
    if n <= 1:
        return 0
    else:
        return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

n = combinations_count(N, 2)
m = combinations_count(M, 2)

print(n+m)

Measured memory_bytes: 3060
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp11
{
    class Class8
    {
        static void Main()
        {
            var v = Console.ReadLine().Split().Select(x => int.Parse(x)).ToArray();
            int A = v[0];
            int B = v[1];
            int count = 0;
            int R = 0;
            while (true)
            {
                count = 1 + R * (A - 1);
                if (count < B)
                    R += 1;
                else
                    break;
                
            }
            Console.WriteLine(R);
        }
    }
}

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

int main(){
    int n;
    cin >> n;
    vector<int> a(n);
    int cnt = 0;
    int mina = 1000000007;
    bool zero = false;
    rep(i,n){
        cin >> a[i];
        mina = min(mina, abs(a[i]));
        if(a[i]<0){
            cnt++;
        }
        if(a[i] == 0)zero = true;
    }

    ll res = 0;
    if(cnt%2 == 0 || zero){
        for(auto e : a){
            res += abs(e);
        }
    }else{
        for(auto e : a){
            res += abs(e);
        }
        res -= 2*mina;
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 640
fn main() {
    let (mut m, mut f, mut r): (isize, isize, isize) =
        (read::<isize>(), read::<isize>(), read::<isize>());
    while m != -1 || f != -1 || r != -1 {
        if m == -1 || f == -1 {
            println!("{}", "F");
        } else if m + f < 30 {
            println!("{}", "F");
        } else if m + f < 50 {
            if r >= 50 {
                println!("{}", "C");
            } else {
                println!("{}", "D");
            }
        } else if m + f < 65 {
            println!("{}", "C");
        } else if m + f < 80 {
            println!("{}", "B");
        } else {
            println!("{}", "A");
        }
        m = read();
        f = read();
        r = read();
    }
}

// =========
#[allow(unused_imports)]
use std::cmp::{max, min};
#[allow(unused_imports)]
use std::collections::{HashMap, HashSet};
#[allow(unused_imports)]
use std::process::exit;

#[allow(dead_code)]
const MOD: isize = 1000000007;

fn read<T: std::str::FromStr>() -> T {
    use std::io::Read;
    let stdin = std::io::stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

// =========



Measured memory_bytes: 5028
K = int(input())
num = list(range(1, 10))
for i in range(K):
  a = num[i]
  b = 10 * a + a % 10
  if a % 10 != 0:
    num.append(b - 1)
  num.append(b)
  if a % 10 != 9:
    num.append(b + 1)
  if len(num) == K:
    break
print(num[K - 1])

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

using namespace std;

#define inf 1<<30
#define llong long long
#define usd unsigned
#define pqueue priority_queue
#define mp make_pair
#define pb push_back
#define fn fill_n
typedef pair<int, int> P;
typedef struct data{
	int now;
	int cost;
}data;
int nw[9] = {0, 1, 0, -1, -1, 1, 1, -1, 0};
int nh[9] = {1, 0, -1, 0, 1, 1, -1, -1, 0};

int n, K;


int main(){
	cin >> n >> K;
	usd llong int ko[200001];
	ko[0] = n/K;
	for(int i = 1; i < K; i++){
		ko[i] = n/K + (n%K>=i);
	}
	usd llong int ans = ko[0] * ko[0] * ko[0];
	// cout << ko[0] << endl;
	if((K%2) == 0){
		ans += ko[K/2]*ko[K/2]*ko[K/2];
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 1792
//by shubham_bitsg

#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
//using namespace __gnu_pbds;
 
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef pair<int,int> pi;
typedef vector <string> vs;

//#define oset tree<int, nuint_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
#define forl(i,a,b) for (int i = a; i < b; i++)
#define rfor(i,b,a) for (int i = b; i >= a; i--)
#define f first
#define s second
#define pb push_back
#define mp make_pair
#define srt(x) sort(x.begin(), x.end())
#define sumup(x) accumulate(x.begin(), x.end(), 0)
#define PI 3.141592653589793238
#define MOD 1000000007

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n; cin>>n;
    vector <int> divs(n+1,0);
    divs[1] = 0;
    for(int i=2; i<=n; i++) {
        for(int j=i; j<=n; j+=i)
            divs[j]++;
    }
    ll sum = 0;
    forl(i,1,n+1) {
        sum += i*((ll)divs[i]+1);
    }
    cout<<sum<<"\n";
}

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

int x[55], y[55];
int ck[55];
int n;

int dfs(int u, int xx, int yy)
{
    if(ck[u]) return 0;
    ck[u]=1;

    int m=0;
    for(int i=0; i<n; i++)
    {
        if(i==u) continue;
        if((x[u]-x[i]==xx && y[u]-y[i]==yy) || (x[u]-x[i]==-xx && y[u]-y[i]==-yy))
            m+=dfs(i, xx, yy);
    }
    return m;
}

int check(int xx, int yy)
{
    for(int i=0; i<n; i++) ck[i]=0;

    int m=0;
    for(int i=0; i<n; i++)
        if(!ck[i]) m+=dfs(i, xx, yy)+1;

    return m;
}

int main()
{
    //freopen("input.txt", "r", stdin);

    int m,i,j,k;

    cin>>n;

    for(i=0; i<n; i++)
        cin>>x[i]>>y[i];

    m=n;
    for(i=0; i<n; i++)
    {
        for(j=i+1; j<n; j++)
        {
            int k= check(x[i]-x[j], y[i]-y[j]);
            m= min(m, k);
        }
    }

    cout<<m<<endl;


    return 0;
}


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;

struct node{int to,cost;};

int d[810],p[810];
int degree[810];

vector<node> graph[810];

void add_edge(int f,int t,int c){
	node in;
	in.cost=c;
	in.to=t,graph[f].pb(in);
	in.to=f,graph[t].pb(in);
	return;
}

int dist[810];

void dfs(int v,int p,int cost){
	dist[v]=cost;
	for(auto &e:graph[v]){
		if(e.to!=p){
			cost+=e.cost;
			dfs(e.to,v,cost);
			cost-=e.cost;
		}
	}
	return;
}

int main(void){
	int n;
	while(cin >> n){
		if(n==0) break;
		rep(i,810) graph[i].clear(),degree[i]=0;

		for(int i=1;i<n;++i){
			cin >> p[i];
			p[i]--;
			degree[i]++,degree[p[i]]++;
		}
		for(int i=1;i<n;++i) cin >> d[i];

		int ans=0;
		int cmax=0,index=-1;

		for(int i=1;i<n;++i){
			ans+=d[i];
			if(degree[p[i]]!=1&&degree[i]!=1){
				index=i;
				ans+=2*d[i];
				add_edge(i,p[i],d[i]);
			}
		}

		if(index!=-1){
			rep(i,n) dist[i]=0;
			dfs(index,-1,0);

			cmax=0,index=-1;
			rep(i,n) if(dist[i]>cmax) cmax=dist[i],index=i;
			rep(i,n) dist[i]=0;
			dfs(index,-1,0);

			cmax=0,index=-1;
			rep(i,n) if(dist[i]>cmax) cmax=dist[i],index=i;
		}
		cout << ans-cmax << endl;
	}
	return 0;
}

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

class Program
{
    static int max = 0;
    static void Main(string[] args)
    {
        int n = int.Parse(Console.ReadLine());
        var list = new List<string>();
        for (int i = 1; i <= n; i++) list.Add(Console.ReadLine());
        IEnumerable<string> distinctList = list.Distinct();
        Console.WriteLine(distinctList.Count());


    }


}



Measured memory_bytes: 41196
#include <iostream>
#include <vector>
using namespace std;
#define MAX 300001

bool check[MAX];

void print(int n){
    cout << n << ": ";
}

void init(){
    fill(check,check+MAX,false);
}

int main(){
    int n;
    
    while(cin >> n , n != 1){
        vector<int> v;
        init();
        print(n);
        
        for(int i = 2 ; i <= n ; i++){
            if(n%i==0&&(i%7==1||i%7==6)){
                    for(int j = 2*i ; j <= n ; j+=i) check[j] = true;
                    if(!check[i]) v.push_back(i);
            }
        }
        for(int i = 0 ; i < v.size() ; i++){
            if(!i) cout << v[i];
            else cout << ' ' << v[i];
        }
        cout << endl;
    }
    
    return 0;
}

Measured memory_bytes: 1508
#include <iostream>
#include <algorithm>

using namespace std;

int main()
{
    int n, a, b, c, d[100], ans=0, cur;
    cin>>n>>a>>b>>c;
    for (int i=0; i<n; i++) cin>>d[i];
    sort(d, d+n);
    reverse(d, d+n);
    for (int i=0; i<n; i++)
    {
        cur=c;
        for (int j=0; j<i; j++) cur+=d[j];
        cur/=(a+b*i);
        ans=max(ans, cur);
    }
    cout<<ans<<'\n';
    return 0;
}



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

#define fst(t) std::get<0>(t)
#define snd(t) std::get<1>(t)
#define thd(t) std::get<2>(t)
#define unless(p) if(!(p))
#define until(p) while(!(p))

using ll = std::int64_t;
using P = std::tuple<int,int>;

int N;
std::string S;
constexpr ll MOD = 1'000'000'007;

ll f(){
    int n = 0;
    ll res = 1;

    for(int i=0;i<2*N;++i){
        if(S[i] == 'W' && n % 2 == 0){
            if(n == 0){
                return 0;
            }
            
            res = res * n % MOD;
            n -= 1;
        }else if(S[i] == 'W'){
            n += 1;
        }else if(S[i] == 'B' && n % 2 == 0){
            n += 1;
        }else{
            if(n == 0){
                return 0;
            }
            
            res = res * n % MOD;
            n -= 1;
        }
        
        // std::cout << i << ", " << n << ", " << res << std::endl;
    }

    if(n > 0){
        return 0;
    }

    for(int i=2;i<=N;++i){
        res = res * i % MOD;
    }
    
    return res;
}

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

  std::cin >> N >> S;

  ll res = f();
  std::cout << res << std::endl;
}


Measured memory_bytes: 720
A,B,C,K = map(int, input().split())
ans = 0

for i in range(1,4):
    if i == 1:
#AとKを比較して得点を加算する
#KとAを比較してAよりもKが多ければそのまま加算する
        if A <= K:
            ans += A
            K -= A
        #KとAを比較してAよりもKが少なければK個分加算する
        else:
            ans += K
            break
        #print(K)
        
    elif i == 2:
        #BとKを比較してKを減らす
        #BとKを比較してBよりもKが多ければそのまま減算する
        if B <= K:
            K -= B
        #BとKを比較してBよりもKが少なればKをゼロにして処理を終了する
        else:
            K = 0
            break
        #print(K)

    elif i == 3:
        #CとKを比較して得点を減算する
        #KとCを比較してCよりもKが多ければそのまま加算する
        if C <= K:
            ans -= C
        #KとCを比較してCよりもKが少なければK個分加算する
        else:
            ans -= K
        #print(K)

#答えを表示する
print(ans)


Measured memory_bytes: 9136
#include <bits/stdc++.h>
#define SZ(x) ((int)(x).size())
typedef long long ll;
typedef long double ld;
using namespace std;

int main() {
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); cout.setf(ios::fixed); cout.precision(20);
    int n; cin >> n;
    vector<int> cnt((int) 1e5 + 10, 0), a(n);
    int res = 1;
    for (int &x : a) {
        cin >> x;
        cnt[x]++;
    }
    for (int &x : a) {
        cnt[x]--;
        for (int dx = -1; dx <= 1; dx++) {
            int X = x + dx;
            if (X < 0) {
                continue;
            }
            int tot = cnt[X] + cnt[X + 1] + 1;
            if (X > 0) {
                tot += cnt[X - 1];
            }
            res = max(res, tot);
        }
        cnt[x]++;
    }
    cout << res << "\n";
}


Measured memory_bytes: 1024
/*+lmake
 * STD = c++14
 * DEFINE += WAAUTOMATON
 */
#include <bits/stdc++.h>
using namespace std;
using LL=long long;
using ULL=unsigned long long;
#ifdef WAAUTOMATON
#define debug(args...)                                                                             \
    {                                                                                              \
        dbg, args;                                                                                 \
        cerr << endl;                                                                              \
    }
#define massert(x) assert(x)
#else
#define debug(args...) // Just strip off all debug tokens
#define massert(x)
#endif
struct debugger
{
    template<typename T> debugger& operator , (const T& v)
    {    
        cerr<<v<<" ";    
        return *this;    
    }
} dbg;
struct Data
{
	int x,y,t;
};
const int con[4][2]={{0,1},{0,-1},{-1,0},{1,0}};
bool vis[810][810];
void solve(int h, int w, long long k, vector<string> a){
	memset(vis,true,sizeof(vis));
	int x=0,y=0;
	for(int i=0; i<h; ++i) {
		for(int j=0; j<w; ++j) {
			if (a[i][j]=='S') {
				x=i;
				y=j;
				a[i][j]='.';
				break;
			}
		}
	}
	debug(x,y);
	queue<Data> q;
	q.push({x+1,y+1,0});
	vis[x+1][y+1]=false;
	int mn=INT_MAX;
	while(!q.empty()) {
		Data now=q.front(); q.pop();
		int t=min(now.x-1,min(now.y-1,min(h-now.x,w-now.y)));
		mn=min(mn,t);
		if (now.t>=k) continue;
		int x=now.x,y=now.y;
		for(int i=0; i<4; ++i) {
			int nx=x+con[i][0],ny=y+con[i][1];
			if (nx>=1 && nx<=h && ny>=1 && ny<=w && vis[nx][ny] && a[nx-1][ny-1]=='.') {
				vis[nx][ny]=false;
				q.push({nx,ny,now.t+1});
			}
		}
	}
	debug(mn);
	cout<<int(mn/double(k)+0.999999)+1<<endl;
}

int main(){	
#ifdef WAAUTOMATON
	freopen("./in.txt","r",stdin);
#endif
	long long H;
	long long K;
	long long W;
	scanf("%lld",&H);
	vector<string> A(H-1+1);
	scanf("%lld",&W);
	scanf("%lld",&K);
	for(int i = 0 ; i <= H-1 ; i++){
		cin >> A[i];
	}
	solve(H, W, K, A);
	return 0;
}



Measured memory_bytes: 2432
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll mod = 1000000007;
const ll INF = (ll)1000000007 * 1000000007;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef long double ld;
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<ll, ll> LP;

struct uf {
private:
    vector<int> par, ran;
public:
    void init(int n) {
        par.resize(n, 0);
        ran.resize(n, 0);
        rep(i, n) {
            par[i] = i;
        }
    }
    int find(int x) {
        if (par[x] == x)return x;
        else return par[x] = find(par[x]);
    }
    void unite(int x, int y) {
        x = find(x), y = find(y);
        if (x == y)return;
        if (ran[x] < ran[y]) {
            par[x] = y;
        }
        else {
            par[y] = x;
            if (ran[x] == ran[y])ran[x]++;
        }
    }
    bool same(int x, int y) {
        return find(x) == find(y);
    }
};

int n,m;

int main(){
    cin >> n >> m;
    uf u;u.init(n+1);
    rep(i,m){
        int a,b,c;
        cin >> a >> b >> c;
        u.unite(a-1,b-1);
    }
    int ans=0;
    rep(i,n){
        if(!u.same(i,n)){
            ans+=1;
            u.unite(i,n);
        }
    }
    cout << ans << endl;
}

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

#define rep(i,n) for(signed i=0;i<n;++i)
#define int long long
#define str string
#define debg(a) cout<<#a<<":"<<a<<endl;
#define vint vector<signed>
#define all(a) a.begin(),a.end()
#define pb(a) push_back(a)
#define yn(a) cout<<((a)?"Yes":"No")<<endl;
#define YN(a) cout<<((a)?"YES":"NO")<<endl;
#define call(a) for(auto i:(a))cout<<i<<" ";cout<<endl;
#define ENDL printf("\n");
signed main(){
  int n,m;
  cin>>n>>m;
  m/=1000;
  for(int x=0;x<=m/10+1;++x){
    for(int y=0;y<=m/5+1;++y){
      int z=n-(x+y);
      if(z<0)break;
      if(10*x+5*y+z==m){
        printf("%lld %lld %lld\n",x,y,z);
        return 0;
      }
    }
  }
  cout<<"-1 -1 -1"<<endl;

  return 0;
}


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

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int k = sc.nextInt();
        int h = -10;
        int result = 0;
        for(int i = 0;i<n;i++){
            h = sc.nextInt();
            if(h>=k){
                result++;
            }
        }
        System.out.println(result);
        sc.close();
    }
}

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

int main(){
  int X,n,w;
  cin >> X >> n;
  if(n == 0){
    cout << X << endl;
    return 0;
  }
  int a[105];
 
  map<int,int> mp;
   rep(i,105){
    mp[i] = 0;
  }
  rep(i,n){
    cin >> w;
    mp[w] = 1;
  }
  
  int ans = 100;
  int ansi = 0;
  rep(i,200){
    if(mp[i] == 0){
      if(ans > abs(X - i)){
        ansi = i;
        ans = abs(X - i);
      }
    }
  }
  cout << ansi << endl;
  return 0;
}
      

Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
int main(){
int N,M;
  cin>>N>>M;
  set<int>S;
  for(int i=0;i<M;i++){
  int x;
    cin>>x;
    S.insert(x);
  }int ans=0;
  int ans1=1;
  for(int i=1;i<=N;i++){
      int x=ans1;
    if(S.count(i))
    ans1=0;
    else
      ans1=(ans1+ans)%1000000007;
    ans=x;
  
  }cout<<ans1<<endl;
  
  
  
  
  
  
   return 0;
}

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

#define rep(i, n) for (int i = 0; i < n; ++i)
#define ALL(a) (a).begin(), (a).end()
#define rALL(a) (a).rbegin(), (a).rend()
#define SZ(x) ((int)(x).size())
using ll = long long;
using ull = unsigned long long;
using P = pair<int, int>;
using llP = pair<ll, ll>;
using DoP = pair<double, double>;
const int di[] = {0, 1, 0, -1, 1, 1, -1, -1};
const int dj[] = {1, 0, -1, 0, 1, -1, 1, -1};
const int INF = 1 << 28;
const ll INF64 = 1ll << 55;
const int mod = 1000000007;
//const int mod = 998244353;

template <class T>inline bool chmin(T &a, const T b)
{
  if (a > b)
  {
    a = b;
    return true;
  }
  return false;
}
template <class T>inline bool chmax(T &a, const T b)
{
  if (a < b)
  {
    a = b;
    return true;
  }
  return false;
}
template <class T>inline void line_out(const vector<T> vec) {
  int n = SZ(vec);
  rep(i, n) {
    cout << vec[i];
    if(i < n-1) cout << " ";
  }
  cout << endl;
  return;
}

struct mint
{
  ll x; // typedef long long ll;
  mint(ll x = 0) : x((x % mod + mod) % mod) {}
  mint operator-() const { return mint(-x); }
  mint &operator+=(const mint a)
  {
    if ((x += a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator-=(const mint a)
  {
    if ((x += mod - a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator*=(const mint a)
  {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const
  {
    mint res(*this);
    return res += a;
  }
  mint operator-(const mint a) const
  {
    mint res(*this);
    return res -= a;
  }
  mint &operator++()
  {
    if ((x += 1) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator--()
  {
    if ((x += mod - 1) >= mod)
      x -= mod;
    return *this;
  }
  mint operator*(const mint a) const
  {
    mint res(*this);
    return res *= a;
  }
  mint pow(ll t) const
  {
    if (!t)
      return 1;
    mint a = pow(t >> 1);
    a *= a;
    if (t & 1)
      a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const
  {
    return pow(mod - 2);
  }
  mint &operator/=(const mint a)
  {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const
  {
    mint res(*this);
    return res /= a;
  }
};


int main()
{
  int h, w; cin >> h >> w;
  vector<string> s(h);
  rep(i, h) cin >> s[i];
  
  vector<vector<int>> dist(h, vector<int>(w));
  queue<P> q;
  auto update = [&](P now) {
    int i = now.first, j = now.second;
    rep(k, 4) {
      int ni=i+di[k], nj=j+dj[k];
      if(ni < 0 || ni >= h || nj < 0 || nj >= w) continue;

      if(s[ni][nj] == '.' && dist[ni][nj] == INF) {
        dist[ni][nj] = dist[i][j]+1;
        q.push(P(ni, nj));
      } 
    }
  };


  int ans = 0;
  for(int i = 0; i < h; ++i) {
    for(int j = 0; j < w; ++j) {
      if(s[i][j] == '#') continue;
      dist.assign(h, vector<int>(w, INF));
      q.push(P(i, j));
      dist[i][j] = 0;
      while(!q.empty()) {
        P now = q.front(); q.pop();
        update(now);
      }

      rep(ii, h) rep(jj, w) if(s[ii][jj] == '.') chmax(ans, dist[ii][jj]);
    }
  }
  cout << ans << endl;
}

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

#define nax 3009
#define FOR(i,n,m) for(int i =(n);i<(m);i++)
#define REP(i,n) FOR(i,0,n)
#define pb push_back
#define all(v) v.begin(),v.end()
#define sz(v) int(v.size())

int main(){
	string s1,s2; cin>>s1>>s2;
	int dp[nax][nax];
	memset(dp,0,sizeof dp);
	FOR(i,1,sz(s1)+1){
		FOR(j,1,sz(s2)+1){
			dp[i][j] = max(dp[i-1][j],dp[i][j-1]);
			if(s1[i-1]==s2[j-1]){
				dp[i][j] = max(dp[i][j],dp[i-1][j-1]+1);
			}
		}
	}

	string ans;
	int i =sz(s1), j = sz(s2);
	while(i>0 && j>0){
		if(dp[i][j]==dp[i-1][j-1]+1 && s1[i-1]==s2[j-1]){
			ans += s1[i-1];
			i--; j--;
		}else{
			if(dp[i][j]==dp[i-1][j]){
				i--;
			}else{
				j--;
			}
		}
	}

	reverse(all(ans));
	cout<<ans;

	return 0;
}

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

int main() {
    std::string s;
    std::cin >> s;
    int n = s.size();
    int cnt = std::count_if(s.begin(), s.end(), [](auto c) { return c == 'p'; });
    std::cout << n / 2 - cnt << std::endl;
    return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define rep(i,k, n) for (int i = k; i < (int)(n); i++)
 
 
int main(){
  while(true){
  int n,x,ans=0;cin>>n>>x;
    if(n==0&&x==0)break;
    rep(i,1,n){
      rep(j,i+1,n){
        rep(k,j+1,n+1){
          if(j+k+i==x)ans++;
        }
      }
    }
  cout<<ans<<endl;
  }
}


Measured memory_bytes: 3076
#include <stdio.h>

int main(void){
   int vacation,hw,i,total=0,tmp;
   scanf("%d%d",&vacation,&hw);

   for(i=0;i<hw;i++){
      scanf("%d",&tmp);
      total+=tmp;
   }

   tmp=vacation-total;
   if(tmp<0) tmp=-1;
   printf("%d\n",tmp);
   return 0;
}

Measured memory_bytes: 1728
#include <stdio.h>
#include <string.h>
#include <iostream>
#include <algorithm>
using namespace std;  
const int N = 2e5+5;

int tot,n,m,point[N],nxt[N],v[N];  

void add(int x,int y) {  
	tot++; nxt[tot]=point[x]; point[x]=tot; v[tot]=y;  
	tot++; nxt[tot]=point[y]; point[y]=tot; v[tot]=x;  
}  

int dfs(int x,int fa) {  
	int sg=0;  
	for (int i=point[x];i;i=nxt[i])  
		if (v[i]!=fa)   
	  		sg^=(dfs(v[i],x)+1);  
	return sg;  
}  

int main() {  
	scanf("%d",&n);  
	for (int i=1;i<n;i++){  
		int x,y; scanf("%d%d",&x,&y);  
		add(x,y);  
	}  
	int ans=dfs(1,0);  
	if (ans) printf("Alice\n");  
	else printf("Bob\n");  
}


Measured memory_bytes: 6912
n = gets.chomp.to_i
a = gets.chomp.split(' ').map(&:to_i)
arr = []
i = 1
while i <= n
  arr << [i,a[i-1]]
  i += 1
end
# p arr

# count
c = 0
i = 0
while i < n
  if (arr[i][0]%2 != 0) && (arr[i][1]%2 !=0)
    # p "a[][]:#{a[i]}"
    c += 1
  end
  i += 1
end

puts c

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

#define ll long long

#define all(a) a.begin(),a.end()
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define Rep(i,n,m) for(int i=(int)(n);i<(int)(m);i++)
#define RepS(i,n,m) for(int i=(int)(n);i<=(int)(m);i++)
#define output_s(a) printf("%s\n",(a).c_str())

//library----------------------------------------------


int main(){
    int n,k; cin>>n>>k;
    string s; cin>>s;
    if(s[k-1]=='A') s[k-1]='a';
    else if(s[k-1]=='B') s[k-1]='b';
    else if(s[k-1]=='C') s[k-1]='c';
    output_s(s);
    
    return 0;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define mod 1000000007
#define f(i,a,b) for(ll i=a;i<b;i++)
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ii pair<ll,ll>
#define vii vector<ii>
#define F first
#define S second
#define pb push_back
#define mp make_pair
#define MAX 1e9

ll modpow(ll base, ll exp, ll modulus) {base %= modulus;ll result = 1;while (exp > 0) {if (exp & 1) result = (result * base) % modulus;base = (base * base) % modulus;exp >>= 1;}return result;}
const ld pi=acos(-1);

int main(){
    IOS;
    ll a,b;cin>>a>>b;
    if(a==b)cout<<0;
    else {
        if((a+b)%2)cout<<"IMPOSSIBLE";
        else cout<<(a+b)/2;
    }
    return 0;  
}


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

    for v in &s {
        print!("{}", v);
    }
    if s[s.len() - 1] == 's' {
        println!("es");
    } else {
        println!("s");
    }
}


Measured memory_bytes: 2196
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#define rep(i,N) for(int i=0;i<(int)N;i++)
#pragma GCC optimize("O3")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
static inline void PUT(char c)
{
  static char buf[1<<15],*ptr=buf;
  if(ptr==buf+strlen(buf)||c==0){fwrite(buf,1,ptr-buf,stdout),ptr=buf;}*ptr++=c;
}
static inline int IN(void)
{
  int x=0,f=0,c=getchar();while(c<48||c>57){f^=c==45,c=getchar();}
  while(c>47&&c<58){x=x*10+c-48,c=getchar();}return f?-x:x;
}
static inline void OUT(int a)
{
  if(a<0)PUT('-'),a=-a;
  int d[40],i=0;do{d[i++]=a%10;}while(a/=10);
  while(i--){PUT(d[i]+48);}PUT('\n');
}
static inline int Max(int x,int y){return x>y?x:y;}
int main(void)
{
  int H=IN(),W=IN(),M=IN(),row[H]={0},col[W]={0},bombY[M],bombX[M],
      idh=0,idw=0,hmax=0,wmax=0,obj=0;
  rep(i,M)
  {
    bombY[i]=IN()-1,bombX[i]=IN()-1;
    row[bombY[i]]++;col[bombX[i]]++;
    hmax=Max(hmax,row[bombY[i]]);wmax=Max(wmax,col[bombX[i]]);
  }
  rep(i,H){if(hmax==row[i]){idh++;}}rep(j,W){if(wmax==col[j]){idw++;}}
  rep(i,M){obj+=(row[bombY[i]]==hmax&&col[bombX[i]]==wmax);}
  return OUT(hmax+wmax-(1l*obj==1l*idh*idw)),0;
}

Measured memory_bytes: 6220
#include <iostream>
#include <cmath>
#define PI (6*asin( 0.5 ))
using namespace std;

int main() {
	double x=0,y=0,a=90;
	int step,angle;
	while(true)
	{
		scanf("%d,%d",&step,&angle);
		if (step==0) break;
		x+= cos(a*PI/180)*step;
		y+= sin(a*PI/180)*step;
		a-= angle;
	}
	x>0 ? x=floor(x) : x=floor(x+1);
	y>0 ? y=floor(y) : y=floor(y+1);
	cout << x << endl << y << endl;
}

Measured memory_bytes: 0
n = int(input())
a = [list(map(int, input().split())) for _ in range(n)]

l = [i for i in range(n)]
pos = [0] * n
res = 0
cnt = 0
while True:
    res += 1
    flag = True
    tmp = l.copy()
    l = []
    used = [False] * n
    for v in tmp:
        if used[v] or pos[v] == n - 1:
            continue

        opp = a[v][pos[v]] - 1

        if used[opp] or pos[opp] == n - 1:
            continue

        if a[opp][pos[opp]] - 1 == v:
            pos[v] += 1
            pos[opp] += 1
            l.append(v)
            l.append(opp)
            used[v] = True
            used[opp] = True
            flag = False
            if pos[v] == n - 1:
                cnt += 1
            if pos[opp] == n - 1:
                cnt += 1

    if flag:
        print(-1)
        break

    if cnt == n:
        print(res)
        break

Measured memory_bytes: 87352
#include <iostream>
#include <stdio.h>
#include <cstring>
#include <cstdlib>
#include <string>
#include <algorithm>
#include <vector>
#include <math.h>
#include <map>
#include <iomanip>
#include <limits>
#define rep(i, n) for(int i = 0; i < n; i++)
typedef long long ll;
using namespace std;

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

//最大公約数
ll gcd(ll x, ll y) {
	return y ? gcd(y, x % y) : x;
}

//素因数分解
vector<pair<ll, int>> factorize(ll n) {
	vector<pair<ll, int>> res;
	for (ll i = 2; i * i <= n; i++) {
		if (n % i) continue;
		res.emplace_back(i, 0);
		while (n % i == 0) {
			n /= i;
			res.back().second++;
		}
	}
	if (n != 1) res.emplace_back(n, 1);
	return res;
}

int main()
{
	int n, ans = 0;
	cin >> n;
	char s[100050];
	rep(i, n) {
		cin >> s[i];
		if (i != 0 && s[i] != s[i - 1]) ans++;
	}
	cout << ans+1 << endl;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
///////////////////////////////////////////
const long long int INF = 1LL<<60;
const long long int Mod = 1000000007;
using ll = long long int; using ci = const int;
using vi = vector<int>;  using Vi = vector<long long int>;
using P = pair<int, int>;  using PLL = pair<ll, ll>;
using matrix = vector<vector<ll>>;
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
#define all(x) (x).begin(),(x).end()
#define rp(i,N) for(ll i = 0; i < (ll)N; i++)
#define repi(i,a,b) for(ll i = ll(a); i < ll(b); ++i)
template<class T>bool chmax(T &former, const T &b) { if (former<b) { former=b; return true; } return false; }
template<class T>bool chmin(T &former, const T &b) { if (b<former) { former=b; return true; } return false; }
template<class T>T sqar(T x){ return x*x; }//sqrt(x)は平方根;
#define Sort(v) std::sort(v.begin(), v.end(), std::greater<decltype(v[0])>()) //降順でVをソート
#define p_queue(v) priority_queue<v, vector<v>, greater<v> >
template<class T> inline void princ(T x){cout<<x<<" ";}; 
template<class T> inline void print(T x){cout<<x<<"\n";};
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T> inline void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
///////////////////////////////////////////////////////////////////////////////////

void solve(){
    int a,b,x;
    cin >> a >>  b >> x;
    YES(a<=x&&x<=a+b);
    return;
}
int main(){
    cin.tie(0);ios::sync_with_stdio(false);
    std::cout<<std::fixed<<std::setprecision(30);
    solve();
    return 0;
}

Measured memory_bytes: 256
import java.io.*;
import java.math.*;
import java.util.*;
import java.lang.*;

// import java.text.DecimalFormat; 
// import java.text.DecimalFormatSymbols; 
 
 
// Warning: Printing unwanted or ill-formatted data to output will cause the test cases to fail
 
public class Main {
    
    public static BufferedReader br;
    public static StringTokenizer sto;
    
    public static void main(String args[] ) throws Exception {
        StringBuffer str = new StringBuffer();
        PrintWriter pw=new PrintWriter(System.out);
        br = new BufferedReader(new InputStreamReader(System.in));
    
        int[] in = arrayInt(2);
        int n = in[0];
        long d = in[1];
        int ans=0;
        while(n-->0){
            long[] p = arrayLong(2);
            long di = p[0]*p[0]+p[1]*p[1];
            if(di<=d*d){
                ans++;
            }
        }
        str.append(ans);
        
        pw.println(str.toString());
        
        pw.close();
    }
     
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
    public static int[] arrayInt(int n) throws Exception{
       sto = new StringTokenizer(br.readLine());
       int[] newarray = new int[n];
       for(int i=0;i<n;i++){
           newarray[i] = Integer.parseInt(sto.nextToken());
       }
       return newarray;
    }
    
    public static long[] arrayLong(int n) throws Exception{
       sto = new StringTokenizer(br.readLine());
       long[] newarray = new long[n];
       for(int i=0;i<n;i++){
           newarray[i] = Long.parseLong(sto.nextToken());
       }
       return newarray;
    }
   
   
   public static double nextDouble() throws Exception{
       return Double.parseDouble(br.readLine());
   }
   
   public static long nextLong() throws Exception{
       return Long.parseLong(br.readLine());
   }
   
   
   public static int nextInt() throws Exception{
       return Integer.parseInt(br.readLine());
   }
   
}

Measured memory_bytes: 55956