akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstdint>
#include <cstdio>
#include <cstring>
#include <deque>
#include <fstream>
#include <functional>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <vector>
using namespace std;
using ll = long long;
#define fst first
#define snd second

/* clang-format off */
template <class T, size_t D> struct _vec { using type = vector<typename _vec<T, D - 1>::type>; };
template <class T> struct _vec<T, 0> { using type = T; };
template <class T, size_t D> using vec = typename _vec<T, D>::type;
template <class T> vector<T> make_v(size_t size, const T& init) { return vector<T>(size, init); }
template <class... Ts> auto make_v(size_t size, Ts... rest) { return vector<decltype(make_v(rest...))>(size, make_v(rest...)); }
template <class T> inline void chmin(T &a, const T& b) { if (b < a) a = b; }
template <class T> inline void chmax(T &a, const T& b) { if (b > a) a = b; }
/* clang-format on */

const int INF = 1 << 25;

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

using pii = pair<int, int>;

int bfs(const vector<string>& grid, int sy, int sx) {
  int H = grid.size(), W = grid[0].size();
  vec<int, 2> dist = make_v(H, W, INF);
  queue<pii> q;
  q.emplace(sy, sx);
  dist[sy][sx] = 0;
  while (!q.empty()) {
    auto p = q.front();
    q.pop();
    int y = p.fst, x = p.snd;
    for (int k = 0; k < 4; k++) {
      int ny = y + dy[k], nx = x + dx[k];
      if (ny < 0 || ny >= H || nx < 0 || nx >= W) continue;
      if (grid[ny][nx] == '.' && dist[ny][nx] > dist[y][x] + 1) {
        dist[ny][nx] = dist[y][x] + 1;
        q.emplace(ny, nx);
      }
    }
  }
  int res = 0;
  for (int y = 0; y < H; y++) {
    for (int x = 0; x < W; x++) {
      if (grid[y][x] == '.') chmax(res, dist[y][x]);
    }
  }
  return res;
}

int main() {
#ifdef DEBUG
  ifstream ifs("in.txt");
  cin.rdbuf(ifs.rdbuf());
#endif
  int H, W;
  while (cin >> H >> W) {
    vector<string> grid(H);
    for (auto& x : grid) cin >> x;
    int N = H * W;
    int res = 0;
    for (int y = 0; y < H; y++) {
      for (int x = 0; x < W; x++) {
        if (grid[y][x] == '.') chmax(res, bfs(grid, y, x));
      }
    }
    cout << res << endl;
  }
  return 0;
}


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

using namespace std;

int main(){

	long long int n, tmp, su=0, d;
	vector<long long int> v, bo;

	cin>> n;
	v.resize(n);
	bo.resize(n, 0);
	for (int i = 0;i < n;i++) {
		cin >> tmp;
		v[i] = tmp-1;
		bo[tmp-1]++;
	}

	for (int i = 0;i < n;i++) {
		su += bo[i] * (bo[i] - 1) / 2;
	}

	for (int i = 0;i < n;i++) {
		d = bo[v[i]] * (bo[v[i]] - 1) / 2 - (bo[v[i]] - 1) * (bo[v[i]] - 2) / 2;
		cout << su - d << endl;
	}

}


Measured memory_bytes: 5760
o=input()
e=input()
if len(o)==len(e):
    ans=o[0]+e[0]
    for i in range(1,len(o)):
        ans=ans+o[i]+e[i]
    print(ans)
else:
    ans=o[0]
    for i in range(len(e)):
        ans=ans+e[i]+o[i+1]
    print(ans)

Measured memory_bytes: 3060
from bisect import bisect
n, a, b, q = map(int, input().split())

W = [input().split() for i in range(a)]
X = [int(x) for x, c in W]
C = [c for x, c in W]

P = [list(map(int, input().split())) for i in range(b)]
Y = [y for y, h in P] + [n+1]
D = [0]*b

for i in range(b):
    y0, h = P[i]; y1 = Y[i+1]
    D[i] = min(y0 - h, y1 - y0)

idx = 0
S = {}
for i in range(a):
    x = X[i]; c = C[i]
    S[x] = c
    if x < Y[0]:
        continue
    while Y[idx+1] <= x: idx += 1
    i = idx
    while Y[0] <= x:
        while x < Y[i]: i -= 1
        y0, h = P[i]
        if h == 0: break
        x = h + ((x - y0) % D[i])
        S[x] = c
def check(z):
    if z in S:
        return S[z]
    i = bisect(Y, z)-1
    while Y[0] <= z:
        while z < Y[i]: i -= 1
        y0, h = P[i]
        if h == 0: break
        z = h + ((z - y0) % D[i])
        if z in S:
            return S[z]
    return '?'

Z = (int(input()) for i in range(q))
print(*map(check, Z), sep='')

Measured memory_bytes: 89776
import java.util.*;

public class Main {
	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		int X = sc.nextInt();
		int cnt = 1;
		boolean flag = true;
		while(flag) {
			if(X - cnt <= 0) {
				flag = false;
				System.out.println(cnt);
			}
			X -= cnt;
			cnt++;
		}
	}
}


Measured memory_bytes: 22996
#include<iostream>
#include<vector>
#include<algorithm>

int main(void) {
	int N, M;
	std::cin >> N >> M;
	std::vector<int> P, Q;
	for (int i = 0; i < M; i++) {
		int a, b;
		std::cin >> a >> b;
		if (a == 1) P.push_back(b);
		else if (b == N) Q.push_back(a);
	}
	std::sort(P.begin(), P.end());
	std::sort(Q.begin(), Q.end());

	int i = 0, j = 0;
	while (i < P.size() && j < Q.size()) {
		if (P[i] == Q[j]) {
			std::cout << "POSSIBLE" << std::endl;
			system("pause");
			return 0;
		}
		if (P[i] < Q[j]) i++;
		else j++;
	}
	std::cout << "IMPOSSIBLE" << std::endl;
	system("pause");
	return 0;
}

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

using namespace std;

typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<bool> vb;
typedef pair<ll,ll> pll;
typedef vector<pll> vpll;


const ll mod=1e9+7;
const ll inf=1e16; 

#define rep(i,m,n) for(ll i=m;i<n;i++)
#define repr(i,m,n) for(ll i=m;i>=n;i--)


int main(){
   cin.tie(nullptr);
  ios::sync_with_stdio(false);
  
  char c;
  cin >> c;
  cout << char(int(c)+1) << endl;
  
  
}

Measured memory_bytes: 256
#include <algorithm>
#include <cstring>
#include <iostream>
#include <cstdio>
using namespace std;
int a[10005];
int main()
{
    int k,t;
    int maxx=0;
    scanf("%d%d",&k,&t);
    for(int i=0;i<t;i++)
    {
        scanf("%d",&a[i]);
        maxx=max(maxx,a[i]);
    }
    if(maxx<=k-maxx+1) puts("0");
    else printf("%d\n",maxx-(k-maxx+1)) ;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
//ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
//clock_t start=clock();clock_t end=clock();cout<<(double)(end-start)/CLOCKS_PER_SEC<<endl;
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int ui;
typedef pair<int,int> pii;
typedef pair<pii,int> ppii;
typedef pair<int,pii> pipi;
typedef pair<ll,ll> pll;
typedef pair<pll,ll> ppll;
typedef pair<ll,pll> plpl;
typedef pair<pii,pii> P;
typedef tuple<ll,ll,ll> tl;
typedef pair<double,double> pdd;
typedef vector<vector<ll>> mat;
ll mod=1000000007;
ll mod2=998244353;
ll mod3=1000003;
ll mod4=998244853;
ll mod5=1000000009;
ll inf=1LL<<62;
double pi=3.141592653589793238462643383279L;
double eps=1e-14;
#define rep(i,m,n) for(int i=m;i<n;i++)
#define rrep(i,n,m) for(ll i=n;i>=m;i--)
#define srep(itr,st) for(auto itr=st.begin();itr!=st.end();itr++)
#define mrep(itr,mp) for(auto& itr:mp)
#define Max(a,b) a=max(a,b)
#define Min(a,b) a=min(a,b)
int dh[4]={1,-1,0,0};
int dw[4]={0,0,1,-1};
int ddh[8]={-1,-1,-1,0,0,1,1,1};
int ddw[8]={-1,0,1,-1,1,-1,0,1};
struct custom_hash {
    static uint64_t splitmix64(uint64_t x) {
        // http://xorshift.di.unimi.it/splitmix64.c
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }

    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};
#define umh unordered_map<ll,ll,custom_hash>
ll gcd(ll a,ll b){
    if(a<b)swap(a,b);
    if(b==0)return a;
    if(a%b==0)return b;
    return gcd(b,a%b);
}
ll lcm(ll a,ll b){
    ll c=gcd(a,b);
    return a*b/c;
}
ll Pow(ll n,ll k){
    ll ret=1;
    ll now=n;
    while(k>0){
        if(k&1)ret*=now;
        now*=now;
        k/=2;
    }
    return ret;
}
ll beki(ll n,ll k,ll md){
  ll ret=1;
  ll now=n;
    now%=md;
  while(k>0){
    if(k%2==1){
      ret*=now;
      ret%=md;
    }
    now*=now;
    now%=md;
    k/=2;
  }
  return ret;
}
ll gyaku(ll n,ll md){
  return beki(n,md-2,md);
}
ll popcount(ll n){
    ll ret=0;
    ll u=n;
    while(u>0){
        ret+=u%2;
        u/=2;
        
    }
    return ret;
}
int n,m,q;
int a[50],b[50],c[50],d[50];
int ans=0;
void dfs(int now,vector<int> v){
    if(v.size()==n){
        int sum=0;
        rep(i,0,q){
            if(v[b[i]]-v[a[i]]==c[i])sum+=d[i];
        }
        Max(ans,sum);
        return;
    }vector<int> vv=v;
    rep(i,now,m+1){
        vv.push_back(i);
        dfs(i,vv);
        vv.pop_back();
    }
}
int main(){
    ios::sync_with_stdio(false);cin.tie(0);
    cin>>n>>m>>q;
    rep(i,0,q){
        cin>>a[i]>>b[i]>>c[i]>>d[i];
        a[i]--;
        b[i]--;
    }
    vector<int> v={};
    dfs(1,v);
    cout<<ans<<endl;
}


Measured memory_bytes: 3664
#include <iostream>
#include <stack>
#include <algorithm>
#include <vector>
#include <math.h>
#include <stdio.h>
#include <functional>
#include <string>
#include <cstdlib>
#include <numeric>
#include <cstdbool>
#include <map> 
#include<set>
#include<queue>

typedef long long ll;


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

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

const long long INF = 1000000000000000;
const ll inf = -1e18;
typedef pair<int, int> P;
ll ma = 1000000000 + 7;
ll h, w, n,k,m; string s,t;
char maze[60][60];
int dis[101][101]; int graph[52][52]; bool vis[52];
int dx[4] = { 1, 0, -1, 0 };
int dy[4] = { 0, 1, 0, -1 };
ll gcd(ll x, ll y) {
	if (x % y == 0) return y;
	return gcd(y, x % y);

}
ll lcm(ll a,ll b) {
	ll g = gcd(a, b);
	return a / g * b;
}

int main() {
	cin >> s;
	vector<char> op = { '+','-' };
	for (int bit = 0; bit < (1 << 3); bit++) {
		ll sum = s[0] - '0';
		for (int i = 0; i < 3; i++) {
			if (bit & 1 << i) {
				sum -= s[i + 1] - '0';
			}
			else {
				sum += s[i + 1] - '0';
			}
		}
		if (sum == 7) {
			cout << s[0];
			for (int j = 0; j < 3; j++) {
				cout << op[(bit >> j) & 1] << s[j + 1];
				if (j == 2) {
					cout << "=7" << endl;
					return 0;
				}
			}
		}
	}
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main() {
	string s;
	bool a=false, b=false;

	cin >> s;
	
	if (s[0] == 48) {
		if (s[1]==48) {
			a = false;
		}else {
			a = true;
		}
	}
	else if (s[0] == 49) {
		if (s[1] < 51) {
			a = true;
		}else {
			a = false;
		}
	}
	else {
		a = false;
	}

	if (s[2] == 48) {
		if (s[3] == 48) {
			b = false;
		}
		else {
			b = true;
		}
	}
	else if (s[2] == 49) {
		if (s[3] < 51) {
			b = true;
		}
		else {
			b = false;
		}
	}
	else {
		b = false;
	}

	if (a && b) {
		cout << "AMBIGUOUS";
	}
	else if (a) {
		cout << "MMYY";
	}
	else if (b) {
		cout << "YYMM";
	}
	else {
		cout << "NA";
	}

	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<functional>
#include<map>
#include<cstdlib>
#include<complex>
#include<numeric>

using namespace std;
using Int = long long;
Int INF = 1LL << 60;


int main() {

	cin.tie(nullptr);
	ios::sync_with_stdio(false);

	string s;
	cin >> s;

	int len = s.size();

	//s[0]='0'にする時
	Int count1 = 0;
	for (int i = 0; i < len; i++) {
		if (i & 1) {
			if (s[i] == '0')count1++;
		}
		else{
			if(s[i]== '1') count1++;
		}
	}

	//s[0]='1'にする時
	Int count2 = 0;
	for (int i = 0; i < len; i++) {
		if (i & 1) {
			if (s[i] == '1')count2++;
		}
		else {
			if (s[i] == '0') count2++;
		}
	}

	cout << min(count1, count2);
}


Measured memory_bytes: 512
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <string>
#include <numeric>
#include <algorithm>
#include <tuple>
#include <math.h>
#include <iomanip>

typedef long long ll;
using namespace std;

int main(){
    int n;
    cin >> n;
    vector<ll> a(n),b(n);
    for(int i=0; i<n; ++i){
        cin >> a[i] >> b[i];
    }
    vector<pair<int, ll> > bpair;
    for(int i=0; i<n; ++i){
        bpair.push_back(make_pair(i, b[i]));
    }
    sort(bpair.begin(), bpair.end(), [](auto xx, auto yy){return xx.second < yy.second;});
    ll time = 0;
    string ret = "Yes";
    for (int i=0; i<n; ++i){
        int j = bpair[i].first;
        time += a[j];
        if(time > b[j]){
            ret = "No";
            break;
        }
    }
    cout << ret << endl;
    return 0;
}


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

int main()
{
	ll ans = 0;
	ll n;
	cin>>n;
	while(n>0)
	{
		n = n/2;
		ans++;
	}
	
	cout<< (1ll << ans) - 1 <<endl;
}


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

#define F first
#define S second
#define MP make_pair
#define pb push_back
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define LCM(a, b) (a) / __gcd((a), (b)) * (b)
#define CEIL(a, b) (a)/(b)+(((a)%(b))?1:0)
#define ln '\n'

using namespace std;

typedef long long LL;
typedef long double ldouble;
typedef pair<int, int> P;
typedef pair<LL, LL> LP;

static const int INF = INT_MAX;
static const LL LINF = LLONG_MAX;
static const int MIN = INT_MIN;
static const LL LMIN = LLONG_MIN;
static const int MOD = 1e9 + 7;
static const int SIZE = 200005;

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

vector<LL> Div(LL n) {
    vector<LL> ret;
    for(LL i = 1; i * i <= n; ++i) {
        if(n % i == 0) {
            ret.pb(i);
            if(i * i != n) ret.pb(n / i);
        }
    }
    sort(all(ret));
    return ret;
}

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

    int n, m;
    cin >> n >> m;
    int imos[SIZE] = {};
    for(int i = 0; i < m; ++i) {
        int l, r;
        cin >> l >> r;
        imos[l]++;
        imos[r + 1]--;

    }

    int s = 0;
    int c = 0;
    for(int i = 1; i <= 100005; ++i) {
        s += imos[i];
        if(s == m) ++c;

    }
    cout << c << endl;
    return 0;
}



Measured memory_bytes: 1024
#include <iostream>
using namespace std;
int main(void){
    while(true){
        int n,x;
        cin >> n >> x;
        if(n == 0 && x == 0)break;
        
        int cnt=0;
        for(int i=1;i<=n;i++)
        for(int j=i+1;j<=n;j++)
        for(int k=j+1;k<=n;k++)
        {
            if(i+j+k == x){
                cnt++;
                //cout << i << " + " << j << " + " << k << " = " << x << endl;
            }
        }
        cout << cnt << endl;
    }
}

Measured memory_bytes: 1160
n=int(input())
l=list(map(int,input().split()))
l.sort()
ans=0
for i in range(n-2):
  a=l[i]
  k=i
  for j in range(i+1,n-1):
    b=l[j]
    
    while k<n and l[k]<a+b:
      k+=1
    ans+=k-j-1
print(ans)




Measured memory_bytes: 3188
#include <iostream>
#include <string>
 
using namespace std;
 
int ABC_168_B()
{
 
    int k; 
    string s;
    string s_r;
    cin >> k;
    cin >> s;
 
    if (s.size() <= k) { cout << s << endl; }
    else {
        s_r = s.erase(k);
        cout << s_r << "..." << endl;
    }
    return 0;
 
}
 
int main()
{
    ABC_168_B();
 
    return 0;
}

Measured memory_bytes: 3592
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using u32 = uint32_t;
using vi = vector<int>;    using vvi = vector<vi>;
using vb = vector<bool>;   using vvb = vector<vb>;
using vl = vector<ll>;     using vvl = vector<vl>;
using vd = vector<double>; using vvd = vector<vd>;

#define MAXC(c, x) (c = max(c, x))
#define MINC(c, x) (c = min(c, x))

#define REP(i,n) for(auto i = 0 * (n), i##_len = (n); i < i##_len; ++i)
#define ALL(c) (c).begin(), (c).end()
#define FOR(i,s,n) for(ll i=s, i##_len=(ll)(n); i<i##_len; ++i)
#define TEN(x) ((ll)1e##x)
const ll mod = TEN(9) + 7;

const ll INF = 1e9;

int main() {
	#ifdef INPUT_FROM_FILE
	ifstream cin("sample.in");
	ofstream cout("sample.out");
	#endif
	cin.tie(0);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(50);
	ll n; cin >> n;

	ll state = 0, prev = -1, cnt = 1;
	REP(i, n) {
		ll a; cin >> a;
		if (prev == -1) {
			prev = a;
		} else if (prev != a) {
			if (state == 0) {
				state = prev < a ? 1 : -1;
			} else {
				if ((prev < a && state == -1) || (prev > a && state == 1)) {
					cnt++;
					state = 0;
				}
			}
			prev = a;
		}
	}
	cout << cnt << endl;
}


Measured memory_bytes: 256
#include <iostream>
//#include <numeric>
#include <vector>
	#include<math.h>
#include <algorithm>
	#include <functional>
	#include <numeric>
	//#include<cmath>
//#include <stdio.h> 
#include <cstdint>
	#include <string>
	//#include <cstdlib>
	//#define pi 3.14159265359
#include <iomanip>
#include <map>
#include <cmath>

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


int main() {
	int a , b, c, d, e, f, g, h, i;
	cin >> a >> b >> c >> d >> e >> f >> g >> h >> i;
	int n;
	int k;
	cin >> n;
	for (int j = 0; j < n; j++) {
		cin >> k;
		//cout << i << endl;
		if (k == a) {
			a = 0;
		}
		else if (k == b) {
			b = 0;
		}
		else if (k == c) {
			c = 0;
		}
		else if (k == d) {
			d = 0;
		}
		else if (k == e) {
			e = 0;
		}
		else if (k == f) {
			f = 0;
		}
		else if (k == g) {
			g = 0;
		}
		else if (k == h) {
			h = 0;
		}
		else if (k == i) {
			i = 0;
		}

	}
	//cout << a << b << c << d << e << f << g << h << i;

	if (a + b + c == 0) {
		cout << "Yes";
	}
	else if (d + e + f == 0) {
		cout << "Yes";
	}
	else if (g + h + i == 0) {
		cout << "Yes";
	}
	else if (a + d + g == 0) {
		cout << "Yes";
	}
	else if (b + e + h == 0) {
		cout << "Yes";
	}
	else if (c + f + i == 0) {
		cout << "Yes";
	}
	else if (a + e + i == 0) {
		cout << "Yes";
	}
	else if (c + e + g == 0) {
		cout << "Yes";
	}
	else {
		cout << "No";
	}

	return 0;

}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <functional>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
typedef vector<vector<P>> vvP;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll mod = 1000000007;
const ll INF = 1e16;
const ll MAX_N = 100010;

int main() {
    ll h, n;
    cin >> h >> n;

    ll sum = 0;
    rep(i, n) {
        ll a;
        cin >> a;
        sum += a;
    }

    if(h <= sum) {
        out("Yes");
    }
    else {
        out("No");
    }

    re0;
}

Measured memory_bytes: 256
import java.io.PrintWriter;
import java.util.* ;

class Main {

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        PrintWriter pw = new PrintWriter(System.out);
        int K = in.nextInt();
        int X = in.nextInt();
        int start = X - K + 1;
        int end = X + K - 1;
        int pointer = start;
        while(pointer <= end) {
            pw.print(pointer+" ");
            pointer++ ;
        }
        pw.close();
    }
}

Measured memory_bytes: 23124
from collections import deque

INF = 10 ** 12

class BFS:
    def __init__(self, H, W, S, C, D):
        self.H = H
        self.W = W
        self.S = S
        # 魔法使いの場所
        self.C = C
        # 目的地
        self.D = D

        # 盤面上のセルの状態
        # -1: 未到達
        # 0 : 魔法0回で到達
        # 1 : 魔法1回で到達
        # 2 : 魔法2回で到達, and so on...
        self.board_states = [[INF] * W for i in range(H)]
        self.board_states[C[0]][C[1]] = 0
        self.queue = deque([C])

    def is_legal_move(self, move):
        h = move[0]
        w = move[1]

        if h < 0 or h >= self.H or w < 0 or w >= self.W:
            return False
        return self.S[h][w] == "."

    def walk(self):
        while len(self.queue) > 0:
            move = self.queue.popleft()
            step_count = self.get_boart_states(move)

            if move == self.D:
                return

            up = (move[0]-1, move[1])
            down = (move[0]+1, move[1])
            left = (move[0], move[1]-1)
            right = (move[0], move[1]+1)

            next_moves = list(filter(self.is_legal_move, [up, down, left, right]))

            for next_move in next_moves:
                if self.get_boart_states(next_move) > step_count:
                    # self.queue.append(next_move)
                    self.queue.appendleft(next_move)
                    self.set_boart_states(next_move, step_count)

            for i in range(-2, 3):
                for j in range(-2, 3):
                    next_move = (move[0]+i, move[1]+j)
                    if not self.is_legal_move(next_move):
                        continue

                    if self.get_boart_states(next_move) > step_count + 1:
                        self.queue.append(next_move)
                        self.set_boart_states(next_move, step_count + 1)

    def set_boart_states(self, move, value):
        self.board_states[move[0]][move[1]] = value

    def get_boart_states(self, move):
        return self.board_states[move[0]][move[1]]

    def print_board_states(self):
        for l in self.board_states:
            print(l)

H, W = map(int, input().split())
C_h, C_w = map(int, input().split())
C_h -= 1
C_w -= 1
D_h, D_w = map(int, input().split())
D_h -= 1
D_w -= 1

S = [ [None] * W for i in range(H) ]
for i in range(H):
    l = input()
    for j, s in enumerate(l):
        S[i][j] = s

bfs = BFS(H, W, S, (C_h, C_w), (D_h, D_w))
bfs.walk()
goal_state = bfs.get_boart_states((D_h, D_w))
print(goal_state if goal_state != INF else -1)



Measured memory_bytes: 167104
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,flag=1,ans=0,a[100009];
    scanf("%d",&n);
    for(int i=1; i<=n; i++)
    {
        scanf("%d",&a[i]);
        if(flag)
            ans+=a[i];
        else
            ans-=a[i];
        flag=!flag;
    }
    ans/=2;
    printf("%d ",ans*2);
    for(int i=1; i<n; i++)
    {
        ans=a[i]-ans;
        printf("%d ",ans*2);
    }
    return 0;
}


Measured memory_bytes: 1664
#include <bits/stdc++.h>
#include<algorithm>
#define int long long
using namespace std;
typedef pair<int,int> P;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define INF 1000000000000

int MOD=1000000007;
int modpow(int a,int x){
  if(a<0)a+=MOD;
  int ans=1;
  while(x>0){
    if(x&1) ans=ans*a%MOD;
      a=a*a%MOD;
      x>>=1;
  }
  return ans;
}

int gyaku(int n){
    return modpow(n,MOD-2);
}
signed main() {
  int a;
  cin>>a;
  cout<<a+a*a+a*a*a;
}


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

 
typedef pair<int,int>P;
 
int sosu[]={2,3,5,7,11,13,17,19,23,29,31,37},so=12;
 
int con(int n,string s){
  int res=0;
  for(int i=0;i<s.size();i++){
 
    res*=n;
     
    if(isalpha(s[i])){
      res+=(s[i]-'A')+10;
    }
    else{
      res+=(s[i]-'0');
    }
 
  }
  return res;
}
 
vector<int> bunkai(int n){
  vector<int>v;
  r(i,so){
    while(n%sosu[i]==0){
      n/=sosu[i];
      v.push_back(sosu[i]);
    }
  }
  return v;
}
 
signed main(){
 int N;
  string s;
  while( cin>>N>>s , N ){
    int n=N;
    int p=con(n,s);//cout<<p<<endl;
 
    vector<int>v=bunkai(n);
     
    vector<P>vec,vel;
 
    r(i,v.size()){
      int res=0;
      __int128 x=1;
      if(i&&v[i-1]==v[i])continue;
      __int128 pp=p;
      for(int j=1;;j++){
     
        x*=v[i];
 
        if(x>pp)break;
     
        res+=p/x;
      }
      vec.push_back(P(res,v[i]));
    }
     
    r(i,so){
      int res=0;
      r(j,v.size()){
        if(sosu[i]==v[j])res++;
      }
      if(res==0)continue;
      //cout<<sosu[i]<<' '<<res<<endl;
      //cout<<p/sosu[i]<<endl;
      vel.push_back(P(res,sosu[i]));
    }
 
    unsigned long long ans=ULLONG_MAX;
    r(i,vec.size()){
      ans=min(ans,(unsigned long long)(vec[i].first/vel[i].first));
    }
 
    cout<<ans<<endl;
  }
}


Measured memory_bytes: 3008
package main

import "fmt"

func main() {
	a, b, _, k := input()
	if k < a {
		fmt.Println(k)
	} else if k < a+b {
		fmt.Println(a)
	} else {
		t := a + b
		fmt.Println(a - k + t)
	}
}

func input() (int, int, int, int) {
	var a, b, c, k int
	fmt.Scan(&a, &b, &c, &k)
	return a, b, c, k
}


Measured memory_bytes: 1756
#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>;
 
int main(){
	int n;
	cin >> n;
	vector<string> w(n);
	rep(i,n) cin >> w[i];
	for(int i = 0;i < n-1;i++){
		for(int j = i+1;j < n;j++){
			if(w[i] == w[j]){
				cout << "No" << endl;
				return 0;
			}
		}
	}
	rep(i,n-1){
		int ilen = w[i].size()-1;
		if(w[i][ilen] != w[i+1][0]){
			cout << "No" << endl;
			return 0;
		}
	}
	cout << "Yes" << endl;
}

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

using namespace std;
int main()
{
    // 整数の入力
    int N;
    cin >> N;
    
    int ret = 0;
    double retBtc = 0;
    for (int i = 0; i < N; i++){
        double x;
        string u;
        cin >> x;
        cin >> u;
        if (u == "JPY")
            ret += x;
        else
            retBtc += x; 
    }
    
    cout << ret + retBtc * 380000.0 << endl;
    return 0;
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS

#include<iostream>
#include<algorithm>
#include<stdio.h>

using namespace std;

long long m[100010], n, a, b;

int check(long long  times) {
	long long an = 0;
	long long p = times * b;
	long long q = a - b;
	for (int i = n - 1; i >= 0; i--) {
		if (m[i] > p) {
			an += (m[i] - p) / q + ((m[i] - p) % q != 0);
		}
	}
	if (an > times) {
		return 0;
	}
	else {
		return 1;
	}
}

/*int find(long long  left, long long right) {
	//cout << left <<" "<< right << endl;
	if (left >= right) {
		return left;
	}
	int mid = (left + right) >> 1;
	if (check(mid)) {
		find(left, mid);
	}
	else {
		find(mid + 1, right);
	}
}*/

int main() {
	ios::sync_with_stdio(false);
	cout.tie(NULL);
	scanf("%lld%lld%lld", &n, &a, &b);
	long long shp = 0;
	for (int i = 0; i < n; i++) {
		scanf("%d", &m[i]);
		shp += m[i] / b + 1;
	}
	sort(m, m + n);
	long long left = 1, right = shp;
	while (left < right) {
		long long mid = (left + right) >> 1;
		if (check(mid)) {
			right = mid;
		}
		else{
			left = mid + 1;
		}
	}
	cout << left << endl;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ALL(v) (v).begin(), (v).end()
#define coutd(n) cout << fixed << setprecision(n)
#define ll long long int
#define vl vector<ll>
#define vi vector<int>
const int INF = 2147483647;
const ll MOD = 1000000007;

using namespace std;

int main() {
  int n;
  cin >> n;
  vector<pair<int, int>> xl(n);
  REP(i, n) {
    int l, x;
    cin >> x >> l;
    xl[i] = make_pair(x + l, x - l);
  }
  sort(ALL(xl));

  int ans = 1;
  int last = xl[0].first;
  FOR(i, 1, n) {
    if (last <= xl[i].second) {
      ans++;
      last = xl[i].first;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 1024
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int main() {
	int n;
	cin >> n;
	vector<int>a(n);
	for (int i = 0;i < n;i++) {
		cin >> a[i];
	}
	sort(a.begin(), a.end());
	int ans = 0;
	for (int i = 0;i < n - 1;i++) {
		ans += a[i];
	}
	ans += a[n - 1] / 2;
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.Scanner;
public class Main {

	private static int bingocard[][] = new int[3][3];

	public static void main(String[] args) {
		Scanner sc  =new Scanner(System.in);
		ArrayList<Integer> numlist = new ArrayList<Integer>();

		for(int i = 0; i < 3; i++) {

			for(int j = 0; j < 3; j++) {
				bingocard[i][j] = sc.nextInt();
			}
		}

		int n = sc.nextInt();

		for(int i = 0; i < n; i++) {
			int bingonum = sc.nextInt();
			numlist.add(bingonum);
		}

		for(int i = 0; i < 3; i++) {

			for(int j = 0; j < 3; j++) {
				for(int k = 0; k < n; k++) {
					if(numlist.get(k) ==  bingocard[i][j]) {
						bingocard[i][j] = 0;
						break;
					}
				}
			}
		}

		if(IsWin()) {
			System.out.println("Yes");
		}else {
			System.out.println("No");
		}


	}

	private static boolean IsWin() {
		if (bingocard[0][0]==0 && bingocard[0][1]==0 && bingocard[0][2]==0 ){
    		return true;
    	}
    	if (bingocard[1][0]==0 && bingocard[1][1]==0 && bingocard[1][2]==0 ){
    		return true;
    	}
    	if (bingocard[2][0]==0 && bingocard[2][1]==0 && bingocard[2][2]==0 ){
    		return true;
    	}
    	if (bingocard[0][0]==0 && bingocard[1][0]==0 && bingocard[2][0]==0 ){
    		return true;
    	}
    	if (bingocard[0][1]==0 && bingocard[1][1]==0 && bingocard[2][1]==0 ){
    		return true;
    	}
    	if (bingocard[0][2]==0 && bingocard[1][2]==0 && bingocard[2][2]==0 ){
    		return true;
    	}
    	if (bingocard[0][0]==0 && bingocard[1][1]==0 && bingocard[2][2]==0 ){
    		return true;
    	}
    	if (bingocard[2][0]==0 && bingocard[1][1]==0 && bingocard[0][2]==0 ){
    		return true;
    	}

		return false;
	}

}

Measured memory_bytes: 22868
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
template<class T> using vt = vector<T>;
template<class T> using vvt = vector<vt<T>>;
template<class T> using ttt = tuple<T,T>;
using tii = tuple<ll,ll>;
using vi = vector<int>;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define pb push_back
#define mt make_tuple
#define ALL(a) (a).begin(),(a).end()
#define FST first
#define SEC second
#define DEB cerr<<"!"<<endl
#define SHOW(a,b) cerr<<(a)<<" "<<(b)<<endl
#define DIV int(1e9+7)
const int INF = (INT_MAX/2);
const ll LLINF = (LLONG_MAX/2);
const long double eps = 1e-10;
//const double PI = M_PI; 
inline ll pow(ll x,ll n,ll m){ll r=1;while(n>0){if((n&1)==1)r=r*x%m;x=x*x%m;n>>=1;}return r%m;}
inline ll lcm(ll d1, ll d2){return d1 / __gcd(d1, d2) * d2;}

/* Coding Space. */
int main(){
  string s; cin >> s;
  ll ans = 0;
  int b_cnt = 0;
  rep(i,s.size()){
    if(s[i] == 'W'){
      ans += i - b_cnt;
      b_cnt++;
    }
  }
  cout << ans << endl;
  
}


Measured memory_bytes: 640
import java.io.*;
import java.util.ArrayList;
import java.util.NoSuchElementException;
import java.util.Scanner;

public class Main {
   
    static int a[]=new int[1000];
    
    public static void main(String[] args) {

	Scanner sc = new Scanner(System.in);
	
	int N=sc.nextInt();
	
	ArrayList<Integer> ar=new ArrayList();
	//ar.add(1);
	
	  for (int i = 2; i < 1000; i++) {
	      boolean t =true;
	      for (int j = 2;t&& j < i; j++) {
		  if(i%j==0)
		      t=false;
	      }
	      
	      if (t) {
		  ar.add(i);
	      }
	      
	      
	}
 
	  int n=ar.size();
	  int c[]=new int[n];
	  long ans = 0;
	  
	  for (int i = N; i >1; i--) {
	    int q=i;
	  int co=0;
	      boolean tfftf = true;
	      for (int j = 0;tfftf &&j < n; j++) {
		  
		  int aaa=ar.get(j);
		 
		 
		 
		 
		  while(q%aaa==0){
		      q/=aaa;
		      c[j]++;
		  }
		  
		  if(q==1)
		      tfftf=false;
		  
	      }
	}
	  
	  ans=1;
	  for (int i = 0; i < n; i++) {
	    if(c[i]!=0)
	    ans*=c[i]+1;
	    ans%=1000000007;
	}
	  
	  
	  System.out.println(ans);
	
    }
    
}


Measured memory_bytes: 23764
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double db;
#define pb push_back
#define fr(i,n) for(int i=0;i<n;i++)
#define Fr(i,n) for(int i=0;i++<n;)
#define ifr(i,n) for(int i=n-1;i>=0;i--)
#define iFr(i,n) for(int i=n;i>0;i--)

const ll MOD=1e9+7;
ll ad(ll x,ll y=0){
  return (x+y)%MOD;
}

int main(){
  ll n,dp[3010][3010]={},k;
  bool s[3010]={};
  char c;
  cin>>n;
  fr(i,n-1){cin>>c;s[i]=(c=='<');}
  fr(j,n) dp[0][j]=1;
  Fr(i,n-1){
    if(s[i-1]){
      dp[i][0]=dp[i-1][0];
      Fr(j,n-i-1) dp[i][j]=ad(dp[i][j-1],dp[i-1][j]);
    }
    else{
      dp[i][n-i-1]=dp[i-1][n-i];
      ifr(j,n-i-1) dp[i][j]=ad(dp[i][j+1],dp[i-1][j+1]);
    }
  }
  cout<<dp[n-1][0]<<endl;
}

Measured memory_bytes: 71040
a, b = map(int, input().split())
def xor_0(x):
    det = x%4
    if det == 0:
        return x
    elif det == 1:
        return 1
    elif det == 2:
        return x+1
    elif det == 3:
        return 0
print(xor_0(a-1)^xor_0(b))


Measured memory_bytes: 2940
#include <bits/stdc++.h> 
 
using namespace std; 
 
void print_frame(int H, int W);

int main() 
{
	int H=1,W=1;
  
    while(H!=0&&W!=0){
      cin>>H>>W;
      print_frame(H,W);
    }
    return 0;
}

void print_frame(int H, int W){

  if(H==0&&W==0)
    return;
  
  for(int i=0;i<H;i++){
    for(int j=0;j<W;j++){
      if(i==0||i==H-1||j==0||j==W-1)
	    cout<<'#';
      else
        cout<<'.';
    }
    cout<<endl;
  } 
  cout<<endl;
}




Measured memory_bytes: 3092
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n,ans=0,ans2=0;
	scanf("%d",&n);
	for(int i=1;i<=n;i++){
		int Num;
		scanf("%d",&Num);
		if(Num%4==0){
			ans++;
		}
		else{
			if(Num%2==0) ans2++;
		}
	}
	ans+=ans2/2;
	if(ans<n/2) printf("No\n");
	else printf("Yes\n");
	return 0;
} 

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

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pi;
#define nl "\n" 
#define pb push_back
#define sz(a) (int)a.size()

void solve(){
	int n;
	cin >> n;
	int tasks[n][3];
	for(int i=0;i<n;++i){
		for(int j=0;j<3;++j){
		cin >> tasks[i][j];
		}
	}
	int max_day_happiness[n][3];
	for(int i=0;i<3;++i)
		max_day_happiness[0][i]=tasks[0][i];
	for(int i=1;i<n;++i){
		for(int j=0;j<3;++j){
			int now=0;
			for(int k=0;k<3;++k){
				if(j!=k) now=max(now,max_day_happiness[i-1][k]);
			}
			max_day_happiness[i][j]=tasks[i][j]+now;
		}
	}
	int ans=0;
	for(int i=0;i<3;++i){
		ans=max(ans,max_day_happiness[n-1][i]);
	}
	cout << ans << nl;
}
	

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

	solve();
	
	return 0;
}



Measured memory_bytes: 5976
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <list>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <array>
#include <algorithm>
#include <tuple>

int main()
{
	int N;
	std::vector<int> L;
	int MaxL = 0;
	int SumL = 0;

	std::cin >> N;
	L.resize(N);
	for (int i = 0; i < N; ++i) {
		std::cin >> L[i];
		MaxL = std::max(MaxL, L[i]);
		SumL += L[i];
	}

	if (MaxL < (SumL - MaxL))
		std::cout << "Yes\n";
	else
		std::cout << "No\n";
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for(int i = int(a); i < int(b); ++i)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep, )(__VA_ARGS__)
const long long INFLL = 1LL << 60;
const int INFINT = 1 << 30;
const long long MOD = 1e9 + 7;

int dp[101][101] = {0};
int pa[100];
int solve(int i, int j) {
    if(i == j)
        return dp[i][j] = 0;
    else if(dp[i][j] != 0)
        return dp[i][j];
    else {
        int mi = INFINT;
        int lr = pa[i - 1] * pa[j];
        for(int k = 0; k < j - i; k++) {
            mi =
                min(mi, solve(i, i + k) + solve(i + k + 1, j) + lr * pa[i + k]);
        }
        return dp[i][j] = mi;
    }
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, g;
    cin >> n >> pa[0] >> pa[1];
    rep(i, 1, n) cin >> g >> pa[i + 1];

    rep(i, 1, n + 1) rep(j, 1, n + 1) dp[i][j] = 0;
    rep(i, 1, n) dp[i][i + 1] = pa[i - 1] * pa[i] * pa[i + 1];

    cout << solve(1, n) << endl;
}



Measured memory_bytes: 3148
#include<stdio.h>

int main(void)
{
  int w, bi;
  
  while(scanf("%d",&w))
    {
      if(w==-1)
	break;
      else
	{
	  if(w<=10)
	    bi = 1150;
	  else if(w>10 && w<=20)
	    {
	      w = w - 10;
	      bi = 1150 + (125*w);
	    }
	  else if(w>20 && w<=30)
	    {
	      w = w - 20;
	      bi = 1150 + (125*10) + (140*w);
	    }
	  else
	    {
	      w = w - 30;
	      bi = 1150 + (125*10) + (140*10) + (160*w);
	    }

	  printf("%d\n",4280-bi);
	}
    }
  return 0;
}

Measured memory_bytes: 600
//#include <bits/stdc++.h>
#include <iostream>
#include <fstream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <stdio.h>
#include <queue>
#include <deque>
#include <set>
#include <stack>
#include <time.h>
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef pair<int, int> Pii;
typedef pair<int, ll> Pil;
typedef pair<ll, ll> Pll;
typedef pair<ll, int> Pli;

#define fi first
#define se second
#define mp make_pair
 
const ll MOD = 1e9 + 7;
const ll MOD2 = 998244353;
const ll MOD3 = 1812447359;
const ll INF = 1ll << 62;
const double PI = 2 * asin(1);

void yes() {printf("yes\n");}
void no() {printf("no\n");}
void Yes() {printf("Yes\n");}
void No() {printf("No\n");}
void YES() {printf("YES\n");}
void NO() {printf("NO\n");}

string S; int K;
vector <string> ans;

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

  for (int i = 0; i < S.length(); i++){
    string now = "";
    for (int j = 0; j < K; j++){
      if (i + j >= S.length()) break;
      now += S[i + j];
      ans.push_back(now);
    }
  }
  sort(ans.begin(), ans.end());

  if (K == 1){
    cout << ans[0] << endl;
    return 0;
  }

  int cnt = 1;
  for (int i = 1; i < ans.size(); i++){
    if (ans[i] == ans[i - 1]) continue;
    cnt++;
    if (cnt == K){
      cout << ans[i] << endl;
      return 0;
    }
  }

  return 0;
}


Measured memory_bytes: 1660
#include <bits/stdc++.h>
#define lsb(x) (x & (-x))
#define ll long long
#define ull unsigned long long
// 217
// 44

/*
const int MOD = ;

inline void mod(int &x) {
    if(x >= MOD)
        x -= MOD;
}

inline void add(int &x, int y) {
    x += y;
    mod(x);
}

inline void sub(int &x, int y) {
    x += MOD - y;
    mod(x);
}


inline void mul(int &x, int y) {
    x = (1LL * x * y) % MOD;
}
*/

using namespace std;

const int MAXN = (int) 1e5;

vector <int> g[MAXN + 1];
int dp[MAXN + 1][3];

int main() {
    //ifstream cin("A.in");
    //ofstream cout("A.out");
    int i, n, m;
    ios::sync_with_stdio(false);
    cin.tie(0), cout.tie(0);

    cin >> n >> m;

    for(i = 1; i <= m; i++) {
        int x, y;
        cin >> x >> y;
        g[x].push_back(y);
    }

    int s, t;
    cin >> s >> t;

    memset(dp, -1, sizeof(dp));
    queue < pair <int, int> > Q;
    Q.push({s, 0});
    dp[s][0] = 0;

    while(Q.size()) {
        auto cur = Q.front();
        Q.pop();

        for(auto it : g[cur.first]) {
            if(dp[it][(cur.second + 1) % 3] == -1) {
                dp[it][(cur.second + 1) % 3] = dp[cur.first][cur.second] + 1;
                Q.push({it, (cur.second + 1) % 3});
            }
        }
    }

    if(dp[t][0] == -1) {
        cout << -1;
    }
    else {
        cout << dp[t][0] / 3;
    }

    //cin.close();
    //cout.close();
    return 0;
}


Measured memory_bytes: 6912
using System;
using System.Linq;

class C
{
	static void Main()
	{
		var n = int.Parse(Console.ReadLine());
		var ps = new int[n].Select(_ => Console.ReadLine().Split().Select(int.Parse).ToArray()).ToArray();
		Console.WriteLine(ps.SelectMany(p => ps.Select(q => Math.Sqrt(Math.Pow(p[0] - q[0], 2) + Math.Pow(p[1] - q[1], 2)))).Sum() / n);
	}
}


Measured memory_bytes: 13524
#include <bits/stdc++.h> 
using namespace std; 
#include <ext/pb_ds/assoc_container.hpp>  
using namespace __gnu_pbds; 
typedef int tp;
typedef tree<tp,null_type,less<tp>,rb_tree_tag,tree_order_statistics_node_update> oSet; 
#define frt(i, s, t) for (int i = s; i <= t; i++)
#define fr(i, s, t) for (int i = s; i < t; i++)
#define frr(i, s, t) for (int i = s; i >= t; i--)
#define srt(a) sort(a.begin(),a.end());
#define mcp(a,b) memcpy ( a, b, b.size());
#define ll long long
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define pii pair<int,int>
#define pll pair<ll,ll>
#define lb lower_bound
#define ub upper_bound
#define prt(i,ans) cout<<"Case #"<<i<<": "<<ans<<endl
#define ld long double

int solve(int t) 
{
   int l,r,d;
   cin>>l>>r>>d;
   cout<<r/d-(l-1)/d;
   return 0;
} 
int main()
{ 
   ios_base::sync_with_stdio(false);cin.tie(NULL);    
   int t=1; 
   //cin>>t; 
   int p=t;
   while(t--) 
   { 
      solve(p-t); 
   } 
   
   cerr<<"time taken : "<<(float)clock()/CLOCKS_PER_SEC<<" secs"<<endl; 
   return 0; 
} 


Measured memory_bytes: 3772
import java.util.*;
public class Main{
    public static void main(String [] args){
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        //int M = sc.nextInt();
        //int c = sc.nextInt();
        //String s = sc.next();

        //int A[] = new int[M];
        int count = 0;
        int a[] = new int[N];
        //int b[] = new int[N];
        for(int i = 0;i<N-1;i++) {
        a[i] = 0;
        }
        for(int i = 0;i<N-1;i++) {
            count = sc.nextInt();
            a[count-1]++;
        }
/*        if(N%2 != 0){
        for(int i = 1; i <= N; i++){
            for(int j = i; j <= N; j++){
                c = i*j;
                if(c == N){
                    d = i+j-2;
                    if(min == 0 || min > d) min = d;
            }
        }
    }
}*/
//double R = (double)r * Math.PI * 2;
//count = N - count;
//if(count < 0) System.out.println(-1);
//else System.out.println(count);
for(int i = 0;i<N;i++) {
    System.out.println(a[i]);
}
    }
}


Measured memory_bytes: 59792
#include <bits/stdc++.h>
#include <iostream>
#include <map>
#include <vector>
#include <cmath>
#include <ios>
#include <iomanip>
#include <algorithm>
#define REP(i, n) for (int i = 0; i < (int)(n); ++i)
#define REP2(i, m, n) for (int i = (m); i < (int)(n); ++i)
#define REPR(i, n) for (int i = (n)-1; i >= 0; --i)
#define REPR2(i, m, n) for (int i = (n)-1; i >= (m); --i)
#define REPx(x, a) for(auto x : a)
#define ALL(a) a.begin(), a.end()
#define SORT(a) sort(ALL(a))
#define SORTR(a) sort(ALL(a), greater<int>())
#define REVERSE(a) reverse(ALL(a))
#define bit_search(bit, n) REP(bit, 1<<(n))
#define bit_check(bit, i) (bit>>(i)) & 1
#define setpre(n) fixed << setprecision((n))
#define UNIQUE(a) do {SORT(a); (a).erase(unique(ALL(a)), (a).end());} while(0)
#define MAX(a) *max_element(ALL(a))
#define MIN(a) *min_element(ALL(a))
#define bisect_left(a, x) lower_bound(ALL(a), (x)) - a.begin()
#define bisect_right(a, x) upper_bound(ALL(a), (x)) - a.begin()
#define INPUT(a) REP(i, a.size()) cin >> a[i];
#define INPUTP(a) REP(i, a.size()) cin >> a[i].first >> a[i].second;
#define OUTPUT_PERMUTATION(n) do{VI v(n); iota(ALL(v), 1); do{REPx(x, v) cout << x << " "; ENDL} while(next_permutation(ALL(v)));} while(0);
#define MAKE_PERMUTATION(n) do{VVI a(fact(n), VI(n)); int idx = 0; VI v(n); iota(ALL(v), 1); do{REP(i, n) a[idx][i] = v[i]; idx++; PER = a;} while(next_permutation(ALL(v)));} while(0); // int fact(), VVI PERを宣言しておく
#define ENDL cout << endl;
using namespace std;
using LL = long long;
using LD = long double;
using PII = pair<int, int>;
using VPII = vector<PII>;
using PLL = pair<LL, LL>;
using VPLL = vector<PLL>;
using VI = vector<int>;
using VVI = vector<VI>;
using VLL = vector<LL>;
using VVLL = vector<VLL>;
using VC = vector<char>;
using VS = vector<string>;
using VB = vector<bool>;
using VD = vector<double>;
const LL INF = 1e18;
const LL MOD = 1e9 + 7;

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

void END(){cout << 1 << endl; exit(0);}

int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  VI A(n);
  INPUT(A);
  SORT(A);
  REP(i, n-1)
  {
    if (A[i] == A[i+1])
    {
      cout << "NO";
      return 0;
    }
  }
  cout << "YES";

  return 0;
}


Measured memory_bytes: 1024
n=int(input())
an={}
d=[int(i) for i in input().split()]
for i in d:
    try:
        an[i]+=1
    except:
        an[i]=1
m=int(input())
res=True
t=[int(i) for i in input().split()]
for i in t:
    try:
        if an[i]==0:
            res=False
            break
        else:
            an[i]-=1
    except:
        res=False
        break
print("YES" if res else "NO")

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

// TYPEDEF
// ----------------------------------------
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> Pair;
typedef vector<ll> vll;
typedef vector<vector<ll>> Graph;
typedef vector<string> vs;
typedef vector<pair<ll, ll>> Pll;
typedef queue<ll> qll;

// REPEAT
// ----------------------------------------
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define REPA(i,a) for(ll i=0;i<(ll)(a.size());i++);
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
#define COUT(a) cout << (a) << endl;
#define ENDL(a) cout << endl;
#define COUTA(i,a) for(ll i=0;i<(ll)(a.size());i++) {cout << (a)[i] << " ";} cout << endl;

// UTIL
// ----------------------------------------
#define pb push_back
#define paired make_pair
#define ALL(a) (a).begin(),(a).end()
#define SORT(a) sort((a).begin(),(a).end())
#define RSORT(a) sort((a).rbegin(), (a).rend())

// DEBUG
// ----------------------------------------
#ifdef _DEBUG
#define debug(x) cout << "[debug] " << #x << ": " << x << endl
#else
#define debug(x)
#endif

template <typename T>
void debugV(const vector<T> v) {
#ifdef _DEBUG
  rep(i, v.size()) {
    cout << i << ":" << v[i] << " ";
  }
  cout << endl;
#else
  (void)v;
#endif
}

// BIT FLAG
// ----------------------------------------
const unsigned int BIT_FLAG_0 = (1 << 0); // 0000 0000 0000 0001
const unsigned int BIT_FLAG_1 = (1 << 1); // 0000 0000 0000 0010
const unsigned int BIT_FLAG_2 = (1 << 2); // 0000 0000 0000 0100
const unsigned int BIT_FLAG_3 = (1 << 3); // 0000 0000 0000 1000
const unsigned int BIT_FLAG_4 = (1 << 4); // 0000 0000 0001 0000
const unsigned int BIT_FLAG_5 = (1 << 5); // 0000 0000 0010 0000
const unsigned int BIT_FLAG_6 = (1 << 6); // 0000 0000 0100 0000
const unsigned int BIT_FLAG_7 = (1 << 7); // 0000 0000 1000 0000
const unsigned int BIT_FLAG_8 = (1 << 8); // 0000 0001 0000 0000
const unsigned int BIT_FLAG_9 = (1 << 9); // 0000 0010 0000 0000
const unsigned int BIT_FLAG_10 = (1 << 10); // 0000 0100 0000 0000
const unsigned int BIT_FLAG_11 = (1 << 11); // 0000 1000 0000 0000

// CONST
// ----------------------------------------
constexpr ll INF = 0x3f3f3f3f3f3f3f3f;
constexpr double PI=3.14159265358979323846; // or M_PI
constexpr int MOD = 1000000007;


void Main() {
  ll n;
  cin >> n;

  vll a(n);
  vll yama(n, 0);

  REP(i, n) {
    cin >> a[i];
  }

  int fugo = 1;
  REP(i, n) {
    yama[0] += fugo * a[i];
    fugo *= -1;
  }

  FORD(i, n - 1, 1) {
    if (i == n - 1) {
      yama[i] = 2 * a[i] - yama[0];
    }
    else {
      yama[i] = 2 * a[i] - yama[i + 1];
    }
  }

  COUTA(i, yama);

}

int main()
{
	cin.tie(0);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	Main();
}

/*
5 2
3 1 2 5
2 2 3
1 0
*/


Measured memory_bytes: 4772