akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <string>
#include <cctype>
#include <cmath>
#include <iomanip>
#include <climits>
#include <cfloat>
#include <algorithm>
#define PB push_back
#define ll long long
#define ull unsigned long long
#define uint unsigned
#define PIE (3.14159265358979323846)
#define MOD 1000000007;
using namespace std;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    string s;
    cin >> s;

    bool a {false}, b {false};
    for (auto const &val: s) {
        if (val == 'A') a = true;
        else if (val == 'B') b = true;
    }

    if (a && b) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
	int n;
	cin>>n;
	int d1[n],d2[n];
	for(int i=0;i<n;i++){
		cin>>d1[i]>>d2[i];
	}
	for(int i=0;i<n-2;i++){
		if(d1[i]==d2[i] and d1[i+1]==d2[i+1] and d1[i+2]==d2[i+2]){
			puts("Yes");
			return 0;
		}
	}
	puts("No");
}


Measured memory_bytes: 3628
/*######################################################
#########~~~~~####~~~~###~~##~~##~~##~~##~~##~~#########
#########~~##~~##~~##~~##~~~#~~##~~~#~~##~~##~~#########
#~~~~~~##~~~~~###~~~~~~##~~#~~~##~~#~~~##~~##~~##~~~~~~#
#########~~######~~##~~##~~##~~##~~##~~##~~##~~#########
#########~~######~~##~~##~~##~~##~~##~~###~~~~##########
######################################################*/
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("O3")
#define ll long long
#define str string
#define rtn return
#define endl '\n'
#define F first
#define S second
#define pb push_back
#define db long double
#define MOD 1000000007
#define INF 1e18
#define EPS 1e-15
#define pll pair <ll, ll>
#define vi vector<ll>
#define vpll vector<pll>
#define value_at find_by_order
#define index_of order_of_key
#define fill(a,v) memset(a,v,sizeof(a))
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define rep(i,n) for(ll i=0;i<n;++i)
#define per(i,n) for(ll i=n-1;i>=0;--i)
#define loop1(i, n) for (int i=1;i<=n;++i)
#define loop(i, begin, end) for (__typeof(end) i = (begin)-((begin)>(end));i!=(end)-((begin)>(end));i+=1-2*((begin)>(end)))
#define FAST_IO std::ios_base::sync_with_stdio(false);std::cin.tie(NULL);std::cout.tie(NULL)

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

template<class T> void remin(T &a, T b) {a = min(a, b);}
template<class T> void remax(T &a, T b) {a = max(a, b);}
template <class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

#define N 100005

int n, m;
vi adj[N];

int dp[N];

int solve(int i) {
  if (dp[i] != -1) rtn dp[i];
  dp[i] = 0;
  for (auto j : adj[i]) {
    remax(dp[i], 1 + solve(j));
  }
  rtn dp[i];
}

int main() {
  FAST_IO;
  fill(dp, -1);
  cin >> n >> m;
  rep(i, m) {
    int x, y;
    cin >> x >> y;
    adj[x].pb(y);
  }
  int ans = 0;
  loop(i, 1, n+1) remax(ans, solve(i));
  cout << ans;
  rtn 0;
}


Measured memory_bytes: 7296
#include "bits/stdc++.h"
#define rep(i,b) for(ll i=0;i<b;i++)
#define ll long long
using namespace std;
/*--Input//////////////////////////////////////////////////*/
inline void IN(void){return;}
template <typename First, typename... Rest>
void IN(First& first, Rest&... rest){cin >> first;IN(rest...);return;}
#define SS(T, ...)      T __VA_ARGS__; IN(__VA_ARGS__);
#define SV(type,c,n) vector<type> c(n);for(auto& i:c)cin >> i;
/*--Output/////////////////////////////////////////////////*/
inline int p(void){cout << endl; return 0;}
template<class Head> int p(Head&& head){cout << head;p();return 0;} template<class Head,class... Tail> int p(Head&& head,Tail&&... tail){cout<<head<<" ";p(forward<Tail>(tail)...);return 0;}
struct ProconInit {
    static constexpr bool AUTOFLUSH = false;
    ProconInit() {
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(20);
        if(AUTOFLUSH)
            cout << unitbuf;
    }
} PROCON_INIT;

#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define vl vector<ll>
#define debug(x) cerr<<#x<<" "<<x<<'\n';
#define all(x) (x).begin(),(x).end()
#define bit(n) (1LL<<(n))
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
bool cmp(pair<ll,ll> a, pair<ll,ll> b) { return a.first+a.second > b.first+b.second; }
int a[100001];

signed main() {
  SS(int,n);
  SV(int,a,n);
  int sum=0;
  rep(i,n){
      sum^=a[i];
  }
  rep(i,n){
      cout<<(sum^a[i])<<" ";
  }
  cout<<endl;
  
}

Measured memory_bytes: 3964
# -*- coding: utf-8 -*-
"""
D - 連結 / Connectivity
https://atcoder.jp/contests/abc049/tasks/arc065_b

"""
import sys


class DisjointSet:
    def __init__(self, n):
        self.p = list(range(n))

    def root(self, i):
        if self.p[i] == i:
            return i
        else:
            self.p[i] = self.root(self.p[i])
            return self.p[i]

    def find(self, x, y):
        return self.root(x) == self.root(y)

    def unite(self, i, j):
        i = self.root(i)
        j = self.root(j)
        if j >= i:
            self.p[j] = i
        else:
            self.p[i] = j


from collections import Counter

def solve(N, K, L, PQ, RS):
    r_d = DisjointSet(N+1)
    for p, q in PQ:
        r_d.unite(p, q)
    t_d = DisjointSet(N+1)
    for r, s in RS:
        t_d.unite(r, s)
    for i in range(1, N+1):
        r_d.root(i)
        t_d.root(i)

    connectivity = Counter()
    for i in range(1, N+1):
        connectivity[(r_d.p[i], t_d.p[i])] += 1
    return [connectivity[(r_d.p[i], t_d.p[i])] for i in range(1, N + 1)]


def main(args):
    N, K, L = map(int, input().split())
    PQ = [[int(i) for i in input().split()] for _ in range(K)]
    RS = [[int(i) for i in input().split()] for _ in range(L)]
    ans = solve(N, K, L, PQ, RS)
    print(*ans)


if __name__ == '__main__':
    main(sys.argv[1:])

Measured memory_bytes: 80900
package main

import (
	"fmt"
)

func main() {
	ans := 0
	min := 10
	for i, t := 0, 0; i < 5; i++ {
		fmt.Scanln(&t)
		ans += t
		r := t % 10
		if r > 0 {
			ans += 10 - r
		}
		if min > r && r != 0 {
			min = r
		}
	}
	if min == 10 {
		fmt.Println(ans)
	} else {
		fmt.Println(ans - 10 + min)
	}
}


Measured memory_bytes: 512
#define _CRT_SECURE_NO_DEPRECATE
#define _USE_MATH_DEFINES
#include <iostream>
#include <cmath>
#include <string>
#include <vector>
#include <algorithm>
#include <cstdio>
#include <memory.h>
#include <set>
#include <ctime>
#include <map>
#include <cstring>
#include <iterator>
#include <queue>
#include <assert.h>
#include <bitset>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <functional>

//#pragma comment(linker, "/STACK:512000000")

using namespace std;

#define pb emplace_back
#define mp make_pair
#define all(a) (a).begin(), (a).end()
#define forn(i, n) for (int i = 0; i < (n); ++i)
#define forab(i, a, b) for (int i = (a); i < (b); ++i)

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

const int infi = 1e9 + 7;
const ll infl = (ll)1e18 + (ll)7;

const ll mod = 1e9 + 7;
int ar[1010][2];
int t[1000500];

int32_t main() {
    cin.sync_with_stdio(false);
    cin.tie(0);
    //srand(time(NULL));
  //  freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);
    //freopen("customs.in", "r", stdin); freopen("customs.out", "w", stdout);
    int n, m;
    cin >> n >> m;
    forn(i, n)
        cin >> ar[i][0];
    forn(i, m)
        cin >> ar[i][1];
    forn(i, n) {
        int a = ar[i][0];
        t[a] += 1;
    }
    forn(i, m) {
        int a = ar[i][1];
        t[a] += 2;
    }
    if (t[n * m] != 3) {
        cout << 0;
        return 0;
    }
    ll ans = 1;
    int q = 1, w = 1;
    for (int i = n * m - 1; i > 0; --i) {
        if (t[i] == 3) {
            q++, w++;
        } else if (t[i] == 2) {
            ans *= q;
            ans %= mod;
            ++w;
        } else if (t[i] == 1) {
            ans *= w;
            ans %= mod;
            ++q;
        } else {
            ans *= (1LL * w * q - (n * m - i));
            ans %= mod;
        }
    }
    if (q != n || w != m)
        ans = 0;
    cout << ans << '\n';

    return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define ll long long
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define sz(a) int((a).size())
#define all(a) (a).begin(), (a).end()
#define REP(i,n) for(int i=0;i<(n);++i)
#define REPD(i,n) for(int i=(n)-1;i>=0;--i)
#define FOR(i,a,b) for(int i=(a);i<=(b);++i)
#define FORD(i,a,b) for(int i=(a);i>=(b);--i)
const ll MOD = 1E9+7;
const int INF = 1E9;
const double EPS = 1E-9;
const double PI = atan(1.0) * 4.0;
template<class T> T getbit(T s, int i) {return s>>i&1;}
template<class T> void flipbit(T& s, int i) {s^=(1LL<<i);}
constexpr int cntbit(ll x) {return __builtin_popcountll(x);}
constexpr int lg2(ll x) {return __lg(x);} // return int(log2(x))
// mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
mt19937 rng((uint32_t)chrono::steady_clock::now().time_since_epoch().count()); 
ll fpow(ll a,ll p){ll res=1LL;while(p){if(p&1LL) res=res*a%MOD;a=a*a%MOD;p>>=1LL;} return res;}

const int N=2005;
int n,k,q,res,a[N];

int main() {
	ios_base::sync_with_stdio(0);cin.tie(0);
	cin>>n>>k>>q;
	REP(i,n) cin>>a[i];
	a[n]=-INF;
	res=INF;
	REP(i,n){
		int last=0;
		vector<int> v;
		REP(j,n+1)
			if(a[i]>a[j]){
				if(j-last>=k){
					vector<int> tmp;
					FOR(t,last,j-1) tmp.pb(a[t]);
					sort(all(tmp));
					REP(t,sz(tmp)-k+1) v.pb(tmp[t]);
				}
				last=j+1;
			}
		sort(all(v));
		if(sz(v)>=q) res=min(res,v[q-1]-v[0]);
	}
	cout<<res<<'\n';
}



Measured memory_bytes: 3644
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;


int main()
{
	ll a,b,ans=10000;
	cin>>a>>b;
	if(b-a>=2019)cout<<0<<endl;
	else
	{
		for(ll i=a;i<b;i++)
		{
			for(ll j=a+1;j<=b;j++)
			{
				ans=min(ans,((i%2019)*(j%2019))%2019);
				if(ans==0)
				{
					cout<<ans<<endl;
					return 0;
				}
			}
		}
		cout<<ans<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
/* Digit Number */
#include <iostream>
using namespace std;

int main() {
  int a, b;
  while (cin >> a >> b) {
    int n = a + b;
    int i = 0;
    while(n != 0) {
      n /= 10;
      i++;
    }
    cout << i << endl;
  }

  return 0;
}


Measured memory_bytes: 1160
/**
 *  author:   TakeruOkuyama
 *  created:  2020-04-14 20:18:35
**/
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (n); i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;

const int MOD = 1000000007;
const int INF = 999999999;

int main(){
    int N, X;
    cin >> N >> X;
    vector<int> m(N);
    int sum = 0;
    rep(i, N){
        cin >> m[i];
        sum += m[i];
    }
    sort(m.begin(), m.end());
    X = X - sum;
    cout << N + X / m[0] << endl;
return 0;}

/**
 * g++ code.cpp
 * ./a.out
 * shift + ctrl + i
**/ 

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.*;
import java.util.*;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.Collections;

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

        int r = sc.nextInt();
        System.out.println(r * r * 3);
        
        

        






    }
}

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

#define rep(i, n) for (int i = (int)(0); i < (int)(n); ++i)
#define reps(i, n) for (int i = (int)(1); i <= (int)(n); ++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 irep(i, m, n) for (int i = (int)(m); i < (int)(n); ++i)
#define ireps(i, m, n) for (int i = (int)(m); i <= (int)(n); ++i)
#define FOR(e, c) for (auto &e : c)
#define SORT(v, n) sort(v, v + n);
#define vsort(v) sort(v.begin(), v.end());
#define rvisort(v) sort(v.begin(), v.end(), greater<int>());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
#define replace_all(s, b, a) replace(s.begin(),s.end(), b, a);
// #define int long long
#define PI (acos(-1))
#define FILL(v, n, x) fill(v, v + n, x);
#define sz(x) int(x.size())

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using ul = unsigned long;

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; }

ll GCD(ll a, ll b) { return b ? GCD(b, a%b) : a; }
ll LCM(ll a, ll b) { return a / GCD(a, b)* b; }

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

inline bool inside(int y, int x, int H, int W) {
    return (y >= 0 && x >= 0 && y < H && x < W);
}

const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

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

signed main()
{
  cin.tie( 0 ); ios::sync_with_stdio( false );
  int n,m; cin>>n>>m;
  string s,t; cin>>s>>t;
  int g = gcd(n,m);
  ll ans = (ll)n/g*m;
  bool ok = true;
  rep(i,g){
    if(s[i*n/g]!=t[i*m/g]) ok=false;
  }
  if(!ok) cout<<-1<<endl;
  else cout<<ans<<endl;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0;i<int(N);++i)
using ll = long long;
const int INF = 2147483647;
const ll MOD = 1000000007;
// const ll INF = 1000000000000000000LL;

int main() {
  ll n,k;
  cin >> n >> k;
  ll ans = 0;
  for(ll i=k;i<=n+1;i++){
    ll r = i*(2*n-i+1)/2;
    ll l = i*(i-1)/2;
    ans+=r-l+1;
    ans%=MOD;
  }
  cout << ans << endl;
  return 0;
}


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


int main(){
	string input;
	int x,y;
	
	cin >> input;
	cin >> x >> y;
	
	bool dpx[8001][16001];
	bool dpy[8001][16001];
	for(int i=0;i<8001;i++){
		for(int j=0;j<16001;j++){
			dpx[i][j] = false;
			dpy[i][j] = false;
		}
	}
	
	vector<int> distx,disty;
	vector<int> TF;//0.. 偶数は水平方向 奇数は垂直方向
	int count = 0;
	input += 'T';
	for(int i=0;i<input.size();i++){
		if(input[i] == 'T'){
			TF.push_back(count);
			count = 0;
		}else{
			count ++;
		}
	}
	for(int i=0;i<TF.size();i++){
		if(i%2==0){
			distx.push_back(TF[i]);
		}else{
			disty.push_back(TF[i]);
		}
	}
	
	dpx[1][8000+distx[0]] = true;
	for(int i=1;i<distx.size();i++){
		for(int j=0;j<16001;j++){
			if(dpx[i][j]){
				dpx[i+1][j+distx[i]] = true;
				dpx[i+1][j-distx[i]] = true;
			}
		}
	}
	dpy[0][8000] = true;
	for(int i=0;i<disty.size();i++){
		for(int j=0;j<16001;j++){
			if(dpy[i][j]){
				dpy[i+1][j+disty[i]] = true;
				dpy[i+1][j-disty[i]] = true;
			}
		}
	}
	if(dpy[disty.size()][y+8000] && dpx[distx.size()][x+8000]){
		cout << "Yes" << endl;
	}else{
		cout << "No" << endl;
	}
	
//	for(int k=0;k<4;k++){
//		for(int j=0;j<1000;j++){
//			for(int i=0;i<1000;i++){
//				dp[k][j][i] = false;
//			}
//		}
//	}
	/*
	int now_x=0,now_y=0;
	double angle = 0.0;
	
	
	for(int i=0;i<input.size();i++){
		if(input[i] == 'F'){
			now_x += int(cos(angle));
			now_y += int(sin(angle));
		}else{
			angle += M_PI_2;
		}
	}
	
	if(x == now_x && y == now_y){
		cout << "Yes" << endl;
	}else{
		cout << "No" << endl;
	}*/
	return 0;
}


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

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

typedef long long ll;
using namespace std;
int mod = 1000000007;

int main(void){
    int N; cin >> N;
    N++;
    cout << N/2 << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
typedef long int li;
#define MOD 1000000007
#define df 0
int t(vector<int> const& a);
li kk(vector<int> const& a);

int main(){
  int n;li k; cin >> n >> k;
  vector<int> a(n);
  for(int i=0;i<n;i++){
    cin >> a.at(i);
  }
  li sum=t(a);
  sum=(sum*k)%MOD;
  sort(a.begin(),a.end());
  li sum2=(k*(k-1)/2)%MOD;
  if(df)printf("sum2:%ld (%ld)\n",sum2,k*(k-1));
  sum2*=n*(n-1)/2-kk(a);
  cout << (sum+sum2)%MOD;
}

int t(vector<int> const& a){
  int cnt=0,len=a.size();
  for(int i=0;i<len;i++){
    for(int j=i+1;j<len;j++){
      if(a.at(i)>a.at(j)) cnt++;
    }
  }
  if(df)printf("t:%d\n",cnt);
  return cnt;
}

li kk(vector<int> const& a){
  // a:sorted
  li cnt=0;
  int len=a.size(),temp=1;
  for(int i=1;i<len;i++){
    if(a.at(i)==a.at(i-1))temp++;
    else{
      cnt+= temp*(temp-1)/2;
      temp=1;
    }
  }
  cnt+=temp*(temp-1)/2;
  if(df)printf("kk:%d\n",cnt);
  return cnt%MOD;
}




Measured memory_bytes: 256
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <set>
#include <vector>
#include <numeric>
#include <algorithm>
#include <iostream>
#include <string>
#include <cstring>
#include <sstream>
#include <functional>
#include <queue>
#include <deque>
#include <stack>
#include <cassert>
#include <bitset>
#include <cmath>
#include <iomanip>

using namespace std;

using int64 = long long;

/////////////////////
// Code starts here//
/////////////////////


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

    string S, T;

    cin >> S >> T;
    int N = S.size();
    int M = T.size();

    S = "@" + S;
    T = "@" + T;

    vector<vector<int>> dp (N + 1, vector<int>(M + 1));
    vector<vector<char>> parent (N + 1, vector<char>(M + 1, ' '));

    for (int i = 1; i <= N; i++) {
        for (int j = 1; j <= M; j++) {
            if (S[i] == T[j]) {
                dp[i][j] = dp[i-1][j-1] + 1;
                parent[i][j] = 'X';
            } else if (dp[i-1][j] > dp[i][j-1]) {
                dp[i][j] = dp[i-1][j];
                parent[i][j] = 'U';
            } else {
                dp[i][j] = dp[i][j-1];
                parent[i][j] = 'D';
            }
        }
    }

    string res = "";

    for (int i = N, j = M; i >= 1 && j >= 1; ) {
        if (parent[i][j] == 'X') {
            res += S[i];
            i--;
            j--;
        } else if (parent[i][j] == 'U') {
            i--;
        } else {
            j--;
        }
    }

    reverse(res.begin(), res.end());

    cout << res << "\n";

    return 0;
}


Measured memory_bytes: 44544
n, m = map(int, input().split())
alst = [int(input()) for _ in range(n)]
for k in range(2, m + 1):
  for j in range(n - 1):
    if alst[j] % k > alst[j + 1] % k:
      alst[j], alst[j + 1] = alst[j + 1], alst[j]

print(*alst, sep="\n")



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

int main (){
  string S, T;
  cin >> S >> T;
  
  int count = 0;
  
  for(int i = 0; i < 3; i++){
    if(S.at(i) == T.at(i)){
      count++;
    }
  }
  
  cout << count << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <utility>
#include <cstring>
#include <iomanip>
#include <numeric>
#include <cmath>
#include <cassert>
using namespace std;
using ll = long long;
const int INF = 1<<30;
const int MOD = 1e9 + 7;
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, a, b, c; cin >> n >> a >> b >> c;
    while(c--)
    {
        a--, b--;
        n--;
    }
    cout << n - a - b << endl;
    return 0;
}




Measured memory_bytes: 3224
n,m = map(int,input().split())
N = [i+1 for i in range(n)]
h = list(map(int,input().split()))
for i in range(m):
  a,b = map(int,input().split())
  if h[a-1] > h[b-1]:
    N[b-1] = 0
  elif h[a-1] < h[b-1]:
    N[a-1] = 0
  else:
    N[a-1] = 0
    N[b-1] = 0
c = 0
for i in N:
  if i == 0:
    c += 1
print(len(N)-c)

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

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

  vector<int> A(N);
  for (int i = 0; i < N; i++) cin >> A.at(i);

  long long XorTot = A.at(0);
  for (int i = 1; i < N; i++) {
    XorTot = (XorTot xor A.at(i));
  }

  for (int i = 0; i < N; i++) {
    cout << (XorTot xor A.at(i));
    if (i != N - 1) cout << ' ';
  }
    cout << endl;
}

Measured memory_bytes: 4052
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <cstdio>
#include <cmath>
#include <tuple>
#include <iomanip>
#include <numeric>
#include <unordered_map>
#include <sstream>   
#include<limits.h>
#include<list>
using namespace std;
#define i64  long long
//  #define int  long long
 
#define I32_MAX 2147483647
#define I64_MAX 9223372036854775807
#define MOD 1000000007


void solve()
{

  int T;
  cin>>T;
  vector<int> vec_T(T,0);
  for (int i = 0; i < T; i++)
  {
    cin>>vec_T[i];
  }
  
  int S;
  cin>>S;
  vector<int> vec_S(S,0);
  for (int i = 0; i < S; i++)
  {
    cin>>vec_S[i];
  }
  int counter = 0;

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

  for (int i = 0; i < S; i++)
  {
    int L = 0 ,R = T;
    while(L < R)
    {
      int mid = (L + R)>>1;
      if(vec_S[i] == vec_T[mid])
      {
        counter++;
        break;
      }
      else if(vec_S[i] > vec_T[mid])
      {
        L = mid + 1;
      }
      else
      {
        R = mid;
      }
    }
  }

  cout<<counter<<endl;
  
  
  
  
  return;
}

int32_t main(int32_t argc, const char *argv[])
{
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);
  solve();
 
  return 0;
}


Measured memory_bytes: 3312
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <math.h>
#include <queue>
#include <set>
#include <map>
#include <stack>
#include <iomanip>
#include <numeric>
 
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;
ll N,K;
ll m;
string S;
ll d;
ll M = 1000000007;
vector<ll> fac(5000001); //n!(mod M)
vector<ll> ifac(5000001); //k!^{M-2} (mod M)
//a,bの範囲的にこれだけ配列を用意していけば十分

//ll mpow(ll x, ll n){ //x^n(mod M) ←普通にpow(x,n)では溢れてしまうため，随時mod計算
//    ll ans = 1;
//    while(n != 0){
//        if(n&1) ans = ans*x % M;
//        x = x*x % M;
//        n = n >> 1;
//    }
//    return ans;
//}
//
//ll comb(ll a, ll b){ //aCbをmod計算
//    if(a == 0 && b == 0)return 1;
//    if(a < b || a < 0)return 0;
//    ll tmp = ifac[a-b]* ifac[b] % M;
//    return tmp * fac[a] % M;
//}
int main() {
    cin >> N;
    cout << N + N*N + N*N*N <<endl;
    }


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

using namespace std;


void solve() {
    int n,m;
    cin >> n >> m;
    vector<pair<int, int>> a(m);
    for (int i = 0; i < m; i++) {
        int x,y;
        cin >> x >> y;
        a[i] = {x,y};
    }
    sort(a.begin(), a.end());
    int res = 0;
    int l = -1e8, r = 1e8;
    for (auto& p: a) {
        int x,y;
        tie(x,y) = p;
        l = max(l, x); r = min(r, y);
        if (l < r) continue;
        res++;
        l = x; r = y;
    }
    res++;
    cout << res;
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    solve();
    cout << endl;
}


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

using namespace std;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int k, s;
    cin >> k >> s;
    int cnt = 0;
    for (int i = 0; i <= k; i++) {
        for (int j = 0; j <= k; j++) {
            if(!(s - i - j >= 0 && s - i - j <= k)) continue;
            if(i + j + (s - i - j) == s) cnt++;
        }
    }
    cout << cnt << '\n';
    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))
#define each(itr,c) for(__typeof(c.begin()) itr=c.begin(); itr!=c.end(); ++itr)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define fi first
#define se second

typedef pair<int,int> pi;

int main()
{
    int n;
    while(cin >>n,n)
    {
        int max_level=0;

        vector<pi> a(n);
        rep(i,n)
        {
            string s;
            cin >>s;

            int S=s.size();

            int level=S-1;

            int num=s[S-1]-'0';
            if(s[S-1]=='+') num=-1;
            if(s[S-1]=='*') num=-2;

            a[i]=pi(level,num);
            max_level=max(max_level,level);
        }

        for(int i=max_level-1; i>=0; --i)
        {
            vector<pi> nx;

            int now=0;
            int A=a.size();
            while(now<A)
            {
                if(a[now].se<0 && a[now].fi==i)
                {
                    bool add=true;
                    int val=0;
                    if(a[now].se==-2)
                    {
                        add=false;
                        val=1;
                    }

                    ++now;
                    while(now<A && a[now].fi==i+1)
                    {
                        if(add) val+=a[now].se;
                        else val*=a[now].se;
                        ++now;
                    }

                    nx.pb(pi(i,val));
                }
                else nx.pb(a[now++]);
            }

            a=nx;
        }

        cout << a[0].se << endl;
    }
    return 0;
}

Measured memory_bytes: 3068
N =int(input())
A = list(map(int,input().split()))
leaf = sum(A)

v = [[0,a] for a in A]
v[0][0] = 1
MAX = 2
for i in range(1,N+1):
    v[i][0] = min((v[i-1][0]-v[i-1][1])*2,leaf)
    leaf -= v[i][1]
    MAX *= 2
v

if v[N][0] != v[N][1]:
    print('-1')
    exit()

ans = 0

for a,b in v:
    if a <= 0:
        print('-1')
        exit()
    ans += a

print(ans)


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

using namespace std;

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

    int count = 0;

    for(int i = 0; i < N-1; i++)
    {
        if(S.at(i) != S.at(i + 1)) count++;
    }

    count++;

    cout << count << endl;
}

Measured memory_bytes: 512
#include <iostream>
#include <algorithm>
#include <cmath>
#include <stack>
#include <deque>
#include <queue>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <bitset>
#include <random>
#include <vector>
#include <string>
#include <cstring>
#include <cassert>
#include <cstdlib>
#include <cstdio>
#include <complex>
#include <ctime>
#include <numeric>
using namespace std;

#define pb push_back
#define pii pair <int, int>
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define reunique(x) (x).resize(unique(all(x)) - (x).begin())
#define ld long double
#define int long long

void SOLVE() {
	int a, b;
	cin >> a >> b;
	for (int i = 1; i <= 1000000; i++) {
		int x = (int)((ld)i * (ld)0.08);
		int y = (int)((ld)i * (ld)0.1);
		if (x == a && y == b) {
			cout << i << '\n';
			return;
		}
	}
	cout << "-1\n";
}

signed main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	cout << fixed;
	cout.precision(10);
	int Q = 1;
	//cin >> Q;
	while (Q--) {
		SOLVE();
	}

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int A, B, H, M;
long double ans;
int main()
{
	cin >> A >> B >> H >> M;
	int t = abs(60 * H - 11 * M);
	if (t > 360)
	{
		t = 720 - t;
	}
	if (t == 360)
	{
		ans = A + B;
	}
	else if (t == 0)
	{
		ans = abs(A - B);
	}
	else
	{
		ans = sqrt(A * A + B * B - 2 * A * B * cos((long double)t / 2.0 * (acos(-1.0) / 180.0)));
	}
	printf("%.20Lf\n", ans);
	return 0;
}

Measured memory_bytes: 4152
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <utility>
#include <vector>
#include <tuple>

#define DEBUG(x) cout<<#x<<": "<<x<<endl

using namespace std;

int main(){

	unsigned long long N, A, B, C, D, E, S;
	unsigned long long ans;

	cin >> N >> A >> B >> C >> D >> E;

	S = min(A,min(B,min(C,min(D,E))));
	ans = N/S;
	if(N%S != 0) ans++;
	ans +=4;

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
use std::cmp::max;
use std::io;
use std::str;

pub struct Scanner<R> {
    reader: R,
    buffer: Vec<String>,
}

impl<R: io::BufRead> Scanner<R> {
    pub fn new(reader: R) -> Self {
        Self {
            reader,
            buffer: vec![],
        }
    }

    pub fn token<T: str::FromStr>(&mut self) -> T {
        loop {
            if let Some(token) = self.buffer.pop() {
                return token.parse().ok().expect("Failed parse");
            }
            let mut input = String::new();
            self.reader.read_line(&mut input).expect("Failed read");
            self.buffer = input.split_whitespace().rev().map(String::from).collect();
        }
    }

    pub fn tokens<T: str::FromStr>(&mut self) -> Vec<T> {
        assert!(self.buffer.is_empty());
        let mut input = String::new();
        self.reader.read_line(&mut input).expect("Failed read");
        input
            .split_whitespace()
            .map(|x| x.parse().ok().expect("Failed parse"))
            .collect()
    }
}

fn solve<R: io::BufRead, W: io::Write>(scan: &mut Scanner<R>, out: &mut W) {
    let n: usize = scan.token();
    let mut swim = 0;
    let mut bugs = 0;
    let mut hw = 0;
    for i in 0..n {
        let a: i32 = scan.token();
        let b: i32 = scan.token();
        let c: i32 = scan.token();
        let tmp_swim = swim;
        let tmp_bugs = bugs;
        let tmp_hw = hw;
        swim = a + max(tmp_bugs, tmp_hw);
        bugs = b + max(tmp_swim, tmp_hw);
        hw = c + max(tmp_swim, tmp_bugs);
    }
    let ans = swim.max(bugs).max(hw);
    writeln!(out, "{}", ans).ok();
}

fn main() {
    let (stdin, stdout) = (io::stdin(), io::stdout());
    let mut scan = Scanner::new(stdin.lock());
    let mut out = io::BufWriter::new(stdout.lock());
    solve(&mut scan, &mut out);
}


Measured memory_bytes: 2260
n=int(input())
t,a=map(int,input().split())
l=list(map(int,input().split()))
L=[]
for i in range(n):
    L.append(t-l[i]*0.006)
ans=[]
for i in range(n):
    ans.append(abs(a-L[i]))
print(ans.index(min(ans))+1)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0, i##_len = (n); i < i##_len; i++)
#define reps(i, s, n) for(ll i = (s), i##_len = (n); i < i##_len; i++)
#define rrep(i, n) for(ll i = (n) - 1; i >= 0; i--)
#define rreps(i, e, n) for(ll i = (n) - 1; i >= (e); i--)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((ll)(x).size())
#define len(x) ((ll)(x).length())

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    // std::ifstream in("input.txt");
    // std::cin.rdbuf(in.rdbuf());
    ll k, x;
    cin >> k >> x;
    if ((500 * k) >= x) {
        cout << "Yes" << endl;
    }
    else {
        cout << "No" << endl;
    }
    return 0;
}


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

using namespace std;
 
#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl;
#define DEBUG_MAT(v) cerr<<#v<<endl;for(int i=0;i<v.size();i++){for(int j=0;j<v[i].size();j++) {cerr<<v[i][j]<<" ";}cerr<<endl;}
typedef long long ll;
#define int ll
 
#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
#define pll pair<ll,ll>
template<class S, class T> pair<S, T> operator+(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first + t.first, s.second + t.second); }
template<class S, class T> pair<S, T> operator-(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first - t.first, s.second - t.second); }
template<class S, class T> ostream& operator<<(ostream& os, pair<S, T> p) { os << "(" << p.first << ", " << p.second << ")"; return os; }
#define X first
#define Y second
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define rrep(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define rrep1(i,n) for(int i=(int)(n);i>0;i--)
#define REP(i,a,b) for(int i=a;i<b;i++)
#define in(x, a, b) (a <= x && x < b)
#define all(c) c.begin(),c.end()
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a = b; return 1; } return 0; }
#define UNIQUE(v) v.erase(std::unique(v.begin(), v.end()), v.end());
const ll inf = 1000000001;
const ll INF = (ll)1e18 + 1;
const long double pi = 3.1415926535897932384626433832795028841971L;
#define Sp(p) cout<<setprecision(25)<< fixed<<p<<endl;
// int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
// int dx2[8] = { 1,1,0,-1,-1,-1,0,1 }, dy2[8] = { 0,1,1,1,0,-1,-1,-1 };
// vi dx = {1, 0, -1, 0}, dy = {0, 1, 0, -1};
// vi dx2 = { 1,1,0,-1,-1,-1,0,1 }, dy2 = { 0,1,1,1,0,-1,-1,-1 };
#define fio() cin.tie(0); ios::sync_with_stdio(false);
// const ll MOD = 1000000007;
const ll MOD = 998244353;
// #define mp make_pair
//#define endl '\n'


signed main() {
    fio();
    int n, m, k;
    cin >> n >> m >> k;
    vl a(n), b(m);
    rep (i, n) cin >> a[i];
    rep (i, m) cin >> b[i];

    ll sum = 0;
    rep (i, m) sum += b[i];
    int last = m - 1;
    ll ans = 0;
    ll now = 0;
    while (sum > k) {
        sum -= b[last];
        last--;
    }
    ans = last + 1;
    rep (i, n) {
        now += a[i];
        while (now + sum > k) {
            if (last == -1) break;
            sum -= b[last];
            last--;
        }
        if (now + sum <= k) {
            chmax(ans, i + 1 + last + 1);
        }
    }
    cout << ans << endl;
}

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

#ifdef NON_SUBMIT
#define TEST(n) (n)
#define tout cerr
#else
#define TEST(n) ((void)0)
#define tout cin
#endif

using namespace std;

const int MOD=1e9+7;
vector<int> adj[200000];
int F[200001], Finv[200001], D[200000], W[200000];

int mul(int a, int b)
{
	return 1LL*a*b%MOD;
}

int nCr(int n, int r)
{
	return mul(F[n],mul(Finv[r],Finv[n-r]));
}

int nCrinv(int n, int r)
{
	return mul(Finv[n],mul(F[r],F[n-r]));
}

void dfs(int c)
{
	W[c]=D[c]=1;
	for(auto n: adj[c]) if(W[n]==0) {
		dfs(n);
		D[c]=mul(nCr((W[c]+=W[n])-1,W[n]),mul(D[c],D[n]));
	}
}

void dfs2(int c)
{
	for(auto n: adj[c]) if(W[n]<W[c]) {
		D[n]=mul(mul(D[c],nCrinv(W[0]-1,W[n])),nCr(W[0]-1,W[0]-W[n]));
		dfs2(n);
	}
}

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(NULL); cout.tie(NULL);
	TEST(freopen("input.txt","r",stdin));
	TEST(freopen("output.txt","w",stdout));
	TEST(freopen("debug.txt","w",stderr));
	int N;
	cin>>N;
	F[0]=Finv[0]=1;
	for(int i=1;i<=200000;i++) F[i]=mul(F[i-1],i);
	Finv[200000]=750007460;
	for(int i=200000;--i;) Finv[i]=mul(Finv[i+1],i+1);
	for(int i=1;i<N;i++) {
		int a, b;
		cin>>a>>b;
		adj[--a].push_back(--b);
		adj[b].push_back(a);
	}
	dfs(0); dfs2(0);
	for(int i=0;i<N;i++) cout<<D[i]<<'\n';
	return 0;
}

Measured memory_bytes: 17012
#include<bits/stdc++.h>
using namespace std;
int count(int x){
	int ss=0;
	while(x){
		ss++;
		x-=x&-x;
	}
	return ss;
}
int f[12][1010],g[12],sum[12];
int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);cout.tie(0);
	int h,w,shu,sans=2e9;
	cin>>h>>w>>shu;
	for(int i=1;i<=h;i++)
	for(int j=1;j<=w;j++){
		char ch;
		cin>>ch;
		f[i][j]=f[i-1][j]+(ch=='1');
	}
	for(int i=0;i<(1<<h-1);i++){
		int ans=0,tot=0;
		for(int j=0;j<h;j++)
		if(i>>j&1||j==h-1)g[++tot]=j+1;
		memset(sum,0,sizeof(sum));
		for(int j=1;j<=w;j++){
			for(int k=1;k<=tot;k++)
			sum[k]+=f[g[k]][j]-f[g[k-1]][j];
			int s=0;
			for(int k=1;k<=tot;k++)
			s=max(s,sum[k]);
			if(s>shu){
				for(int k=1;k<=tot;k++)
				sum[k]=f[g[k]][j]-f[g[k-1]][j];
				s=0;
			    for(int k=1;k<=tot;k++)
			    s=max(s,sum[k]);
			    if(s>shu){
			    	ans=2e9;
			    	break;
				}
				ans++;
			}
		}
		sans=min(sans,ans+count(i));
	}
	cout<<sans<<"\n";
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,N) for(int i=0;i<(N);i++)
#define rrep(i, n) for (int i = (int)n-1; i >= 0; --i)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
using namespace std;
const long long MOD = 1e9 + 7;
const long long INF = 1e12;
const int inf = 1e9;
const int mod = 1e9+7;
typedef long long ll;
typedef pair<ll,int> P;
typedef set<int> S;

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; }

__attribute__ ((constructor))
void init() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(10);
}

signed main(){
    string s, t;
    cin >> s >> t;
    int ans = t.size();
    rep(i, s.size()) {
        int index_j = 0;
        int copy_i = i;
        int cnt = 0;
        while(copy_i < s.size()){
            if(s[copy_i] != t[index_j]){
                cnt++;
            }
            if(index_j == t.size() - 1) break;
            copy_i++;
            if(copy_i == s.size()) break;
            index_j++;
        }
        if(index_j == t.size() - 1)ans = min(ans, cnt);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3568
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <string>

using ll = long long;

using namespace std;

#define MAX_N 310
#define INF 1000000000000000

using P = pair<long, long>;
#define fi first
#define se second

long L;
int n, m;

// 全対全の距離を求める N^3
long d[MAX_N][MAX_N]; // i->jのコスト あらかじめINF初期化してから入力を反映させる
void warshall_floyd() { 
    for (int k=0; k<n; k++)
        for (int i=0; i<n; i++)
            for (int j=0; j<n; j++)
                d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
}

int main() {
    cin >> n >> m >> L;
    fill(d[0], d[n], INF);
    for (int i=0, a, b; i<m; i++) {
        long c;
        cin >> a >> b >> c;
        a--; b--;
        d[a][b] = d[b][a] = c;
    }
    warshall_floyd();
    for (int i=0; i<n; i++) {
        for (int j=0; j<n; j++) {
            d[i][j] = (d[i][j] > L ? INF : 1);
        }
    }
    warshall_floyd();
    int q; cin >> q;
    for (int i=0, s, t; i<q; i++) {
        cin >> s >> t;
        s--; t--;
        cout << (d[s][t] < INF ? d[s][t] - 1 : -1) << '\n';
    }
    return 0;
}


Measured memory_bytes: 1280
#include<bits/stdc++.h>
using namespace std;
#define int ll
#define ll long long

#define I32_MAX 2147483647
#define I64_MAX 9223372036854775807LL
#define I64_MAX2 1223372036854775807LL
#define INF I64_MAX2
// #define MOD 1000000007
#define MOD 998244353 
#define MEM_SIZE 101010
#define DEBUG_OUT true

#define ALL(x) (x).begin(), (x).end()


template<typename T> void DEBUG(T e){if(DEBUG_OUT == false)return; std::cout << e <<" ";}
template<typename T> void DEBUG(const std::vector<T>& v){if(DEBUG_OUT == false)return;for(const auto& e : v){std::cout<< e << " "; } std::cout << std::endl;}
template<typename T> void DEBUG(const std::vector<std::vector<T> >& vv){if(DEBUG_OUT == false)return;for(const auto& v : vv){ DEBUG(v); } }
template<class T,class... Ts> void DEBUG(T d, Ts... e){if(DEBUG_OUT == false)return;DEBUG(d);DEBUG(e...);}
template <class T> void corner(bool flg, T hoge) {if (flg) {cout << hoge << endl; abort();}}
template< typename T1, typename T2 > inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template< typename T1, typename T2 > inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }

void solve(void)
{
  int h, w, k;
  cin >> h >> w >> k;
  int sx, sy, gx, gy;
  cin >> sx >> sy >> gx >> gy;
  sx--;
  sy--;
  gx--;
  gy--;
  vector<string> mat(h);
  for (int i = 0; i < h; i++)
  {
    cin >> mat[i];
  }
  auto toid = [&](int i, int j, int v) {
    return (i * w + j) * 4 + v;
  };

  vector<int> dist(h * w * 4, INF);
  priority_queue<pair<int, int>, vector<pair<int, int>>, greater<pair<int, int>>> q;
  int di[] = {-1, 0, 1, 0};
  int dj[] = {0, -1, 0, 1};
  auto push = [&](int i, int j, int v, int x) {
    int id = toid(i, j, v);
    if (dist[id] <= x)
      return;
    dist[id] = x;
    q.emplace(x, id);
  };
  for (int v = 0; v < 4; v++)
  {
    push(sx, sy, v, 0);
  }
  auto modCeil = [&](int x) {
    return (x + k - 1) / k * k;
  };
  while (!q.empty())
  {
    int d = q.top().first;
    int id = q.top().second;
    q.pop();
    if (dist[id] != d)
      continue;
    int i = id / w / 4;
    int j = id / 4 % w;
    int v = id % 4;
    for (int nv = 0; nv < 4; nv++)
    {
      push(i, j, nv, modCeil(d));
    }
    int ni = i + di[v];
    int nj = j + dj[v];
    if (0 <= ni and ni < h and 0 <= nj and nj < w)
    {
      if (mat[ni][nj] == '.')
      {
        push(ni, nj, v, d + 1);
      }
    }
  }

  int ans = INF;
  for (int i = 0; i < 4; i++)
  {
    chmin(ans, dist[toid(gx, gy, i)]);
  }
  // DEBUG(dist);
  if (ans == INF)
  {
    cout << -1 << endl;
  }
  else
  {
    ans = modCeil(ans) / k;
    cout << ans << endl;
  }

  return;
}

int32_t main(int32_t argc, const char *argv[])
{
  // std::ios::sync_with_stdio(false);
  // std::cin.tie(0);

  std::cout << std::fixed;
  std::cout << std::setprecision(11);
  solve();

  return 0;
}


Measured memory_bytes: 44096
let () = Scanf.scanf "%d %d %d %d %d %d %d" @@ fun ai ao at aj al as_ az ->
  Printf.printf "%d\n" @@ ao +
    if (ai land 1) + (aj land 1) + (al land 1) < 2 || ai <= 0 || aj <= 0 || al <= 0 then
      ((ai land (-2)) + (aj land (-2)) + (al land (-2)))
    else
      ((ai - 1) land (-2)) + ((aj - 1) land (-2)) + ((al - 1) land (-2)) + 3


Measured memory_bytes: 384
/*
    * * * * *       *        * * * * * * * * * * * * * * * * * * * * * * * *     * * * * * * *               * *               * * * * * * * * * *
    * * * * *      * *       * * * * * * * * * * * * * * * * * * * * * *    *    * * * * * * *              * * *             * ** * * * * * * * * *
    * *           * * *            * *     * *     * *      * *          * * *   * * *       *             * * * *           * * * *       * *    * *
    * * * * *    * * * *           * *     * *     * *       * * * * * * *  * *  * * * * * * *            * * * * *         * *  * *       * * * * *
    * * * * *   * * * * *          * *     * *     * *        * * * * ** *   * * * * * * * * *           * * * * * *       * *   * * * *   * * * *
          * *  * * * * * *   * *   * *     * *     * *       * * * * * * *    * ** *     * * *          * * * * * * *     * *    * * * *   * *  * *
          * * * *       * *  * *   * *     * *     * *      * *          *     * * *     * * *         * *       * * *   * *     * *       * *   * *
    * * * * ** *         * * * * * * * * * * * * * * * * * * * * * * * * *      *  * * * * * * * * * ** *         * * * * *      * * * * * * *    * *
    * * * * * *           * ** * * * * * * * * * * * * * * * * * * * * * *       * * * * * * * * * * * *           * * * *       * * * * * * *     * *
*/

#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <set>
#define ll long long
using namespace std;

int main(void)
{
    int n,d;
    cin>>n>>d;
    ll x[n],y[n],cnt=0;
    double a=0,b=0;
    for(int i=0;i<n;i++)
    {
        cin>>x[i]>>y[i];
    }
    for(int i=0;i<n;i++)
    {
        b= pow(x[i],2)+pow(y[i],2);
        a=sqrt(b);
        if(a<=d)
        {
            cnt++;
        }
    }
    cout<<cnt<<endl;
    return 0;
}


Measured memory_bytes: 6308
package main

import "fmt"

func main() {
	var n int

	fmt.Scanf("%d", &n)

	var a, b, c int
	for i := 0; i < n; i++ {
		var isTriangle bool
		fmt.Scanf("%d %d %d", &a, &b, &c)

		if a*a == b*b+c*c || b*b == a*a+c*c || c*c == b*b+a*a {
			isTriangle = true
		}

		if isTriangle == true {
			fmt.Println("YES")
		} else {
			fmt.Println("NO")
		}
	}
}



Measured memory_bytes: 1132
#include <bits/stdc++.h>
#define WHOLE(v) (v).begin(), (v).end()
#define REV_WHOLE(v) (v).rbegin(), (v).rend()
using i64 = int64_t;
using namespace std;
template<size_t I,class H,class...T>struct TupleReaderWriter{static tuple<H,T...> r(istream&i){H v;i>>v;return tuple_cat(tuple<H>(v),TupleReaderWriter<sizeof...(T)-1,T...>::r(i));}static void w(ostream&o,tuple<H,T...>&t,string d){TupleReaderWriter<I-1,H,T...>::w(o,t,d);o<<d<<get<I>(t);}};
template<class H,class...T>struct TupleReaderWriter<0,H,T...>{static tuple<H,T...> r(istream&i){H v;i>>v;return tuple<H>(v);}static void w(ostream&o,tuple<H,T...>&t,string d){o<<get<0>(t);}};
template<class...T>istream&operator>>(istream&i,tuple<T...>&t){t=TupleReaderWriter<sizeof...(T),T...>::r(i);return i;}
template<class...T>ostream&operator<<(ostream&o,tuple<T...>&t){string delim=" ";TupleReaderWriter<sizeof...(T)-1,T...>::w(o,t,delim);return o;}
template<class T>istream&operator>>(istream&i,vector<T>&v){for(auto&x:v)i>>x;return i;}
template<class T>ostream&operator<<(ostream&o,vector<T>&v){string delim="";for(auto&x:v)o<<delim<<x,delim=" ";return o;}
template<class T>using rev_priority_queue=priority_queue<T,vector<T>,greater<T>>;
template<class T>using vector2d=vector<vector<T>>;
struct fixprec{int x;fixprec(int d):x(d){}};
ostream&operator<<(ostream&o,fixprec f){return o<<fixed<<setprecision(f.x);}
void R_YESNO(bool p) { cout << (p ? "YES" : "NO") << endl; }
void R_YesNo(bool p) { cout << (p ? "Yes" : "No") << endl; }
int main() {
    int N;
    cin >> N;
    for(int i = 1; i < 100000; i++) {
        if(N == int(double(i) * 1.08)) {
            cout << i << endl;
            return 0;
        }
    }
    cout << ":(" << endl;
    return 0;
}



Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		try (Scanner sc = new Scanner(System.in)) {
			String s = sc.next();
			if ("Sunny".equals(s)) {
				System.out.println("Cloudy");
			} else if ("Cloudy".equals(s)) {
				System.out.println("Rainy");
			} else {
				System.out.println("Sunny");

			}
		}
	}
}


Measured memory_bytes: 21844
def insertionSort(R, n):
    for i in range(1, n):
        Now = R[i]
        j = i - 1
        while j >= 0 and R[j] > Now:
            R[j + 1] = R[j]
            j = j - 1
        R[j + 1] = Now
        trace(R, n)

def trace(R, n):
    for i in range(n):
        print R[i],
    print

n = input()
R = map(int, raw_input().split())

trace(R, n)
insertionSort(R, n)

Measured memory_bytes: 6332