akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
#include <complex>
#include <cmath>

using namespace std;

typedef complex<double> P;

const double INF = 1e77;
const double EPS = 1e-8;

int n, m, ans[10];
P dogs[10];
double dv[10];

double dot(P a, P b){ return real(conj(a) * b); }

void calc(P fp, P fv){
  double time[10];
  for(int i=0;i<n;i++){
    double a = norm(fv) - dv[i] * dv[i];
    double b = -dot(fv, dogs[i] - fp);
    double c = norm(dogs[i] - fp);
    if(abs(a) > EPS){
      time[i] = INF;
      if(b * b > a * c){
        double d1 = (-b + sqrt(b * b - a * c)) / a;
        double d2 = (-b - sqrt(b * b - a * c)) / a;
        if(d1 > -EPS) time[i] = min(time[i], d1);
        if(d2 > -EPS) time[i] = min(time[i], d2);
      }
    }else if(abs(b) > EPS){
      time[i] = -c / (2*b);
      if(time[i] < -EPS) time[i] = INF;
    }else{
      if(c < EPS) time[i] = 0;
      else time[i] = INF;
    }
  }
  int id = min_element(time, time+n) - time;
  if(time[id] > EPS){
    for(int i=0;i<n;i++){
      if(time[i] < INF / 2){
        P v = (fp + fv * time[i]) - dogs[i];
        v /= abs(v);
        dogs[i] += v * dv[i] * time[id];
      }
    }
  }
  ans[id]++;
}

main(){
  while(cin >> n >> m && (n|m)){
    fill(ans, ans+10, 0);
    for(int i=0;i<n;i++) cin >> dogs[i].real() >> dogs[i].imag() >> dv[i];
    for(int i=0;i<m;i++){
      P fp, fv;
      cin >> fp.real() >> fp.imag() >> fv.real() >> fv.imag();
      calc(fp, fv);
    }
    for(int i=0;i<n;i++) cout << ans[i] << (i+1<n ? " " : "\n");
  }
}

Measured memory_bytes: 1256
N, M = map(int, input().split())
L = 0
R = 10**6
for i in range(M):
    l, r = map(int, input().split())
    if l > L:
        L = l
    if r < R:
        R = r
ans = R - L + 1 if R >= L else 0
print(ans)

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

int main() {
    int N;
    cin >> N;
    int k;
    unsigned long f;
    f = 0;
    vector <int> p;
    for(int i = 0; i < N; i++) {
        cin >> k;
        p.push_back(k);
    }
    sort(p.rbegin(),p.rend());
    for(int i  = 0 ; i < N; i++){
        if (i % 2 == 0){
            f = f + p[i];
        }
        else
            f = f -  p[i];
    }
    cout << f << "\n";
}


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

a, b, c = map(int, input().split())

if a+b>c:
    print('No')
    exit()


f1 = 4*a*b - 2*a*b + 2*c*a + 2*b*c
f2 = c**2 + b**2 + a**2

if f1 < f2:
    print('Yes')
else:
    print('No')


Measured memory_bytes: 2940
// AOJ 2230 How to Create a Good Game
// 2018.3.11 bal4u

#include <stdio.h>
#include <string.h>


#define QMAX 2000
typedef struct { int s; int t; } QUE;
QUE que[QMAX]; int qsize;

#define PARENT(i) ((i)>>1)
#define LEFT(i)   ((i)<<1)
#define RIGHT(i)  (((i)<<1)+1)

void min_heapify(int i)
{
	int l, r, min;
	QUE qt;

	l = LEFT(i), r = RIGHT(i);
	if (l < qsize && que[l].t < que[i].t) min = l; else min = i;
	if (r < qsize && que[r].t < que[min].t) min = r;
	if (min != i) {
		qt = que[i], que[i] = que[min], que[min] = qt;
		min_heapify(min);
	}
}

void deq()
{
	que[0] = que[--qsize];
	min_heapify(0);
}

void enq(int s, int t)
{
	int i, min;
	QUE qt;

	i = qsize++;
	que[i].s = s, que[i].t = t;
	while (i > 0 && que[min = PARENT(i)].t > que[i].t) {
		qt = que[i], que[i] = que[min], que[min] = qt;
		i = min;
	}
}

#define INF 0x01010101
#define MAX 105
typedef struct { int to, rev; int cap; int cost; } EDGE;
EDGE edge[MAX][MAX]; int hi[MAX];
int V;				// 頂点数
int potential[MAX], dist[MAX]; prevv[MAX], preve[MAX];

void add_edge(int from, int to, int cap, int cost)
{
	int f, t;
	EDGE *ep;

	f = hi[from]++, t = hi[to]++;
	ep = &edge[from][f], ep->to = to, ep->cap = cap, ep->cost = cost, ep->rev = t; 
	ep = &edge[to][t], ep->to = from, ep->cap = 0, ep->cost = -cost, ep->rev = f;
}

int minCostFlow(int S, int T, int F)
{
	int i, v, nv, d;
	int ret, t, nt;
	EDGE *ep;

	ret = 0;
	for (i = 0; i < V; i++) potential[i] = 0;
  
	while (F > 0) {
		for (i = 0; i < V; i++) dist[i] = INF;
		qsize = 0;
		enq(S, 0), dist[S] = 0;
		while (qsize) {
			v = que[0].s, t = que[0].t, deq();
			if (dist[v] < t) continue;
			for (i = 0; i < hi[v]; i++) {
				ep = &edge[v][i];
				if (ep->cap <= 0) continue;
				nv = ep->to;
				nt = t + ep->cost - potential[nv] + potential[v];
				if(dist[nv] > nt) {
					dist[nv] = nt;
					prevv[nv] = v, preve[nv] = i;
					enq(nv, nt);
				}
			}
		}
		if (dist[T] == INF) return -1;
		for (v = 0; v < V; v++) potential[v] += dist[v];

		d = F;
		for (v = T; v != S; v = prevv[v]) {
			ep = &edge[prevv[v]][preve[v]];
			if (d > ep->cap) d = ep->cap;
		}
		F -= d;

		ret += d * potential[T];
		for (v = T; v != S; v = prevv[v]) {
			ep = &edge[prevv[v]][preve[v]];
			ep->cap -= d;
			edge[v][ep->rev].cap += d;
		}
	}
	return ret;
}

//#define getchar_unlocked()  getchar()
int gint()
{
	int n = 0;
	int c = getchar_unlocked();
	do n = 10*n + (c & 0xf), c = getchar_unlocked();
	while (c >= '0');
	return n;
}

int in[102], out[102];

int main()
{
	int N, M, i, f, sum;
	int source, sink;

	N = gint(), M = gint();
	source = N, sink = source + 1, V = sink + 1;

	sum = 0;
	for (i = 0; i < M; i++) {
		int x = gint(), y = gint(), s = gint();
		in[y]++, out[x]++, sum += s;
		add_edge(x, y, INF, -s);
	}

	f = 0;
	for (i = 0; i < N; i++) {
		if (in[i] > out[i]) add_edge(source, i, in[i]-out[i], 0), f += in[i]-out[i];
		else                add_edge(i, sink, out[i]-in[i], 0);
	}

	minCostFlow(0, N-1, 1);
	add_edge(N-1, 0, INF, -dist[N-1]);
	printf("%d\n", minCostFlow(source, sink, f) - sum);
	return 0;
}


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

using namespace std;

int frog1(int N, int a[])
{
    int dp[N+1];
    dp[0] = 0;
    dp[1] = a[0];
    dp[2] = abs(a[1] - a[0]);
    dp[3] = min(dp[2] + abs(a[2]-a[1]) , abs(a[2]-a[0]));
    for( int i = 3; i < N; i++)
    {
        dp[i+1] = min(dp[i] + abs(a[i]-a[i-1]), dp[i-1] + abs(a[i]-a[i-2]));
    }
    return dp[N];
}

int main()
{
    int N;
    cin>>N;
    int a[N];
    for(int i = 0; i < N; i++) cin>>a[i];
    cout << frog1( N, a);
}

Measured memory_bytes: 4380
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < n; i++)
using namespace std;
int main() {
    int N; cin >> N;
    long long res = 0;
    for(int i = 1; i <=N; i++) {
        if(i % 3 != 0 && i % 5 != 0) res += i;
    }
    cout << res << endl;
    return 0;
}


Measured memory_bytes: 3636
#pragma GCC optimize(2)
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, beg, end) for (int i = (beg); i < (end); i++)
const ll PSIZE = 10000000;
 
int ans;
void dfs(int s, ll mark[], ll a[], ll k, ll step, ll n)
{
    if (step  == k)
    {
        ans = s;
        return;
    }
 
    if (mark[s] != 0 || (s == 1 && step != 0))
    {
        ll cir = step - mark[s];
        ll path = (k - mark[s]) % cir;
        ll mark2[n + 1];
        memset(mark2,0,sizeof(mark2));
        dfs(s, mark2, a, path, 0, n);
        return;
    }
 
    mark[s] += step;
    dfs(a[s], mark, a, k, step + 1, n);
}
 
int main()
{
    ll n, k;
    cin >> n >> k;
    ll a[n];
    rep(i, 1, n + 1)
    {
        cin >> a[i];
    }
    ll mark[n + 1];
    memset(mark,0,sizeof(mark));
    dfs(1, mark, a, k, 0, n);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 8316
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<utility>
#include<vector>
#include<queue>
#include<functional>
#include<map>
#include<set>
#include<cstring>
#include<string>
#include<stack>
#include<stdlib.h>
#include<math.h>
using namespace std;
#define int long long
typedef pair<int, int> pii;
typedef pair<int, char> pic;
typedef priority_queue<pii, vector<pii>, greater<pii> > RPQ;
#define mk make_pair
#define INF (1ll << 30ll)
#define INFL (1ll << 60ll)
#define mod 1000000007

int N;
pii xy[2020][2];
vector<int> xx, yy;
int imos[4040][4040];

signed main(){
    cin >> N;
    for(int i = 0; i < N; i++){
        int a, b, c, d;
        cin >> a >> b >> c >> d;
        xy[i][0] = mk(a, b);
        xy[i][1] = mk(c, d);
        xx.push_back(a);
        xx.push_back(c);
        yy.push_back(b);
        yy.push_back(d);
    }
    sort(xx.begin(), xx.end());
    sort(yy.begin(), yy.end());
    xx.erase(unique(xx.begin(), xx.end()), xx.end());
    yy.erase(unique(yy.begin(), yy.end()), yy.end());
    for(int i = 0; i < N; i++){
        pii x = mk(xy[i][0].first, xy[i][1].first);
        pii y = mk(xy[i][0].second, xy[i][1].second);
        int a = lower_bound(xx.begin(), xx.end(), x.first) - xx.begin();
        int b = lower_bound(yy.begin(), yy.end(), y.first) - yy.begin();
        int c = lower_bound(xx.begin(), xx.end(), x.second) - xx.begin();
        int d = lower_bound(yy.begin(), yy.end(), y.second) - yy.begin();
        imos[a][b]++;
        imos[c][d]++;
        imos[a][d]--;
        imos[c][b]--;
    }
    for(int i = 0; i < (int)xx.size(); i++){
        for(int j = 0; j < (int)yy.size(); j++){
            imos[i][j + 1] += imos[i][j];
        }
    }
    for(int i = 0; i < (int)yy.size(); i++){
        for(int j = 0; j < (int)xx.size(); j++){
            imos[j + 1][i] += imos[j][i];
        }
    }
    
    int ans = 0;
    for(int i = 0; i < (int)xx.size() - 1; i++){
        for(int j = 0; j < (int)yy.size() - 1; j++){
            if(imos[i][j]){
                ans += (xx[i + 1] - xx[i]) * (yy[j + 1] - yy[j]);
            }
        }
    }
    cout << ans << endl;

    /*for(int i = 0; i < (int)xx.size(); i++){
        for(int j = 0; j < (int)yy.size(); j++){
            cout << imos[i][j] << " ";
        }
        cout << endl;
    }*/

    

    return 0;
}

/*


*/


Measured memory_bytes: 129600
n = int(input())
list_s = [input() for x in range(0, n)]
list_count = [0, 0, 0, 0]

for si in list_s:
    if si == 'AC': list_count[0] += 1
    elif si == 'WA': list_count[1] += 1
    elif si == 'TLE': list_count[2] += 1
    else: list_count[3] += 1

print('AC x ' + str(list_count[0]))
print('WA x ' + str(list_count[1]))
print('TLE x ' + str(list_count[2]))
print('RE x ' + str(list_count[3]))

Measured memory_bytes: 16340
#include<iostream>
#include<map>

using namespace std;

int main(){
	int n, m, ans = 0;
	cin >> n >> m;
    map<int, int> mp;
    for(int i = 0; i < m; i++){
        int x, y;
        cin >> x >> y;
        if(x == 1) mp[y]++;
        if(y == n) mp[x]++;
    }
    for(auto&& i : mp){
        if(i.second == 2){
            cout << "POSSIBLE" << endl;
            return 0;
        }
    }
	cout << "IMPOSSIBLE" << endl;
	return 0;
}


Measured memory_bytes: 9600
def main():
    N = int(input())
    A = [int(n) for n in input().split()]
    
    accum = A[0]
    xor = A[0]
    r = 1
    res = 0
    for l in range(N):
        while r < N and accum + A[r] == xor ^ A[r]:
            # print(l, r)
            accum += A[r]
            xor ^= A[r]
            r += 1
        res += r - l
        accum -= A[l]
        xor ^= A[l]
        if l == r:
            r+=1
    print(res)

if __name__ == "__main__":
    main()

Measured memory_bytes: 23560
#include "bits/stdc++.h"

using namespace std;
int main() {
	long long  N;
	string str = "";
	cin >> N;
	long long tmp = 1;
	long long sum = 0;
	int count = 0;//桁数
	while (sum < N) {
		count++;
		tmp *= 26;
		sum += tmp;
	}
	sum -= tmp;
	N -= sum;
	N--;
	//count 桁の　N番目を求めるといい。
	//cout << count << "_"<< N << endl;
	for (int m = 0;m < count;++m) {
		long long n = N % 26;
		N /= 26;
		switch (n) {
		case 0:
			str += "a";
			break;
		case 1:
			str += "b";
			break;
		case 2:
			str += "c";
			break;
		case 3:
			str += "d";
			break;
		case 4:
			str += "e";
			break;
		case 5:
			str += "f";
			break;
		case 6:
			str += "g";
			break;
		case 7:
			str += "h";
			break;
		case 8:
			str += "i";
			break;
		case 9:
			str += "j";
			break;
		case 10:
			str += "k";
			break;
		case 11:
			str += "l";
			break;
		case 12:
			str += "m";
			break;
		case 13:
			str += "n";
			break;
		case 14:
			str += "o";
			break;
		case 15:
			str += "p";
			break;
		case 16:
			str += "q";
			break;
		case 17:
			str += "r";
			break;
		case 18:
			str += "s";
			break;
		case 19:
			str += "t";
			break;
		case 20:
			str += "u";
			break;
		case 21:
			str += "v";
			break;
		case 22:
			str += "w";
			break;
		case 23:
			str += "x";
			break;
		case 24:
			str += "y";
			break;
		case 25:
			str += "z";
			break;
		default:
			break;
		}
	}

	std::reverse(str.begin(), str.end());
	cout << str << endl;
	return 0;
}



Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
int main(void){
  int n,m,x,y,i,gx,gy,mx=-100,my=100;
  bool p=false;
  cin >> n >> m >> x >> y;
  for (i=0;i<n;i++){
    cin >> gx;
    mx=max(mx,gx);
  }
  for (i=0;i<m;i++){
    cin >> gy;
    my=min(my,gy);
  }
  for (i=x+1;i<=y && !p;i++) if (i>mx && i<=my) p=true;
  if (p) cout << "No War" << endl;
  else cout << "War" << endl;
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
typedef long long ll;
typedef unsigned long long ull;
using namespace std;
#define pb push_back
int dy[]={0, 0, 1, -1, 0};
int dx[]={1, -1, 0, 0, 0};
 
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)

ll n,m;
ll pro[200000];
ll cou[200000];

int main() {
    cin >> n >> m;
    REP(i,n)
        cou[i] = 1;

    pro[0] = true;
    REP(i,m) {
        ll x,y;
        cin >> x >> y;
        x--;y--;

        if(pro[x])pro[y] = true;

        cou[x]--;cou[y]++;
        if(cou[x] == 0)
            pro[x] = 0;
    }
    ll ans = 0;
    REP(i,n)
        if(pro[i])
            ans ++ ;
    cout << ans << endl;
    return 0;
}


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

typedef long long ll;
typedef long long llong;
typedef long double ld;
typedef unsigned long long ull;

using namespace std;

/*
ll pw(ll a, ll b) {
	ll ans = 1; while (b) {
		while (!(b & 1)) b >>= 1, a = (a * a) % MOD;
		ans = (ans * a) % MOD, --b;
	} return ans;
}
*/

int n;
int q;
vector<ll> vv;
ll dp[120000];
ll dp2[120000];

int main() {
	scanf("%d%d", &n, &q);
	vv.push_back(n);
	for (int i = 0; i < q; ++i) {
		ll x;
		scanf("%lld", &x);
		while (!vv.empty() && vv.back() >= x)
			vv.pop_back();
		vv.push_back(x);
	}
	dp[vv.size() - 1] = 1;
	for (int i = vv.size() - 1; i >= 0; --i) {
		ll b = vv[i];
		while (true) {
			int x = lower_bound(vv.begin(), vv.end(), b) - vv.begin();
			if (x == 0) {
				dp2[b] += dp[i];
				break;
			}
			--x;
			ll a = b / vv[x];
			b = b % vv[x];
			dp[x] += a * dp[i];
		}
	}
	for (int i = n; i > 0; --i)
		dp2[i - 1] += dp2[i];
	for (int i = 1; i <= n; ++i) {
		printf("%lld\n", dp2[i]);
	}
	return 0;
}




Measured memory_bytes: 4212
#include <stdio.h>
#include <string.h>
#include <limits.h>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <queue>

typedef unsigned long long ULLONG;
typedef long long LLONG;
static const LLONG MOD_NUM = 1000000007;

template<class _T> static void getint(_T& a) {
	const char* fmt = " %d";
	if (sizeof(_T) == sizeof(long long)) {
		fmt = " %lld";
	}

	if (scanf(fmt, &a) < 0) {
		printf("g1int Error\n");
	}
}
template<class _T> static void getint(_T& a, _T& b) {
	const char* fmt = " %d %d";
	if (sizeof(_T) == sizeof(long long)) {
		fmt = " %lld %lld";
	}

	if (scanf(fmt, &a, &b) < 0) {
		printf("g2int Error\n");
	}
}
template<class _T> static void getint(_T& a, _T& b, _T& c) {
	const char* fmt = " %d %d %d";
	if (sizeof(_T) == sizeof(long long)) {
		fmt = " %lld %lld %lld";
	}

	if (scanf(fmt, &a, &b, &c) < 0) {
		printf("g3int Error\n");
	}
}

static void AGC011B();

#if 1
int main()
{
	AGC011B();
	fflush(stdout);
	return 0;
}
#endif

static void AGC011B()
{
	int N;
	getint(N);

	std::vector<LLONG> ai(N, 0);
	for (int i = 0; i < N; i++) {
		getint<LLONG>(ai[i]);
	}

	std::sort(ai.begin(), ai.end());

	int ngCount = 0;
	LLONG sum = 0;
	for (int i = 0; i < N - 1; i++) {
		sum += ai[i];
		if ((sum * 2) < ai[i + 1]) {
			ngCount = i + 1;
		}
	}
	printf("%d\n", N - ngCount);
}


Measured memory_bytes: 1024
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<math.h>
using namespace std;
typedef long long ll;
#define int long long
typedef vector<int> VI;
typedef pair<int, int> pii;
typedef priority_queue<int> PQ;
#define fore(i,a) for(auto &i:a)
#define REP(i,n) for(int i=0;i<n;i++)
#define eREP(i,n) for(int i=0;i<=n;i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define eFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define SORT(c) sort((c).begin(),(c).end())
#define rSORT(c) sort((c).rbegin(),(c).rend())
#define LB(x,a) lower_bound((x).begin(),(x).end(),(a))
#define UB(x,a) upper_bound((x).begin(),(x).end(),(a))
#define INF 1000000000
#define LLINF 9223372036854775807
#define mod 1000000007
//vector<vector<int> > dp;
//vector<vector<vector<int> > > vvvi;
//dp=vector<vector<int> >(N, vector<int>(M,0));
//vector<pair<int,int> > v;
//v.push_back(make_pair(x,y));
//priority_queue<int,vector<int>, greater<int> > q2;

#define MAX_V 100000
struct edge { int to, cost; };
typedef pair<int, int> P; //firstは距離、secondは頂点の番号

int V; //頂点数
vector<edge> G[MAX_V]; //添字がfrom
int d[MAX_V]; //最短コスト
int prim() {
	priority_queue<P, vector<P>, greater<P> > que;
	fill(d, d + V, INF);
	int res = 0;
	que.push(P(0, 0));
	while (!que.empty()) {
		P p = que.top();
		que.pop();
		int v = p.second;
		if (d[v] != INF)continue;
		res += p.first;
		d[v] = p.first;
		for (int i = 0; i < G[v].size(); i++) {
			edge e = G[v][i];
			if (d[e.to] == INF)que.push(P(e.cost, e.to));
		}
	}
	return res;
}
signed main(){
cin.tie(0);
ios::sync_with_stdio(false);

	cin >> V;
	vector<pii> X,Y;
	map<pii, int> mp;
	REP(i, V) {
		int x, y;
		cin >> x >> y;
		X.push_back(pii(x, i));
		Y.push_back(pii(y, i));
	}
	SORT(X);
	SORT(Y);
	REP(i, V - 1) {
		edge e;
		e.to = X[i + 1].second;
		e.cost = X[i + 1].first - X[i].first;

		mp[pii(X[i].second, X[i + 1].second)] = e.cost;

		G[X[i].second].push_back(e);
		e.to = X[i].second;
		G[X[i + 1].second].push_back(e);
		//cout << X[i + 1].first << endl;
	}
	REP(i, V - 1) {
		edge e;
		e.to = Y[i + 1].second;
		e.cost = Y[i + 1].first - Y[i].first;
		if (mp[pii(Y[i].second, Y[i + 1].second)] != 0)
			e.cost = min(e.cost, mp[pii(Y[i].second, Y[i + 1].second)]);
		G[Y[i].second].push_back(e);
		e.to = Y[i].second;
		G[Y[i + 1].second].push_back(e);
	}
	/*REP(i, V) {
		REP(j, G[i].size()) {
			cout << i << " " << G[i][j].to << endl;
		}
	}*/
	cout << prim() << endl;
	return 0;
}



Measured memory_bytes: 36068
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
//template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

/* attention
    long longのシフト演算には気をつけよう
    タイポした時のデバッグが死ぬほどきつくなるので変数名は最低3字くらい使った方がいいかも
*/

class UnionFind{
public:
    //親の番号を格納する。親だった場合はー（その集合のサイズ）
    vector<int> parents;

    //作る時はparentsを-1で初期化する
    //こうすることで全部ばらばらになる
    UnionFind(int n){
        parents = vector<int>(n, -1);
    }

    //Aがどのグループにいるか調べる
    int root(int A){
        if(parents[A]<0) return A;
        return parents[A] = root(parents[A]);
    }

    //自分のいるグループの大きさを調べる
    int size(int A){
        return -parents[root(A)];
    }

    //AとBをくっつける
    bool connect(int A, int B){
        //AとBを直接ではなく親同士をくっつける
        A=root(A);
        B=root(B);
        if(A==B){
            return false;
        }

        //大きい方（A)に小さい方（B)をくっつけたい
        if(size(A)<size(B)) swap(A, B);

        parents[A] += parents[B];
        parents[B] = A;

        return true;
    }
};

int main(){
    int N, M; cin >> N >> M;
    UnionFind uni(N+M);

    for(int i=0; i<N; i++){
        int k; cin >> k;
        for(int j=0; j<k; j++){
            int l; cin >> l;
            uni.connect(i, l-1+N);
        }
    }

    for(int i=1; i<N; i++){
        if(uni.root(0) != uni.root(i)){
            cout << "NO" << endl;
            return 0;
        }
    }

    cout << "YES" << endl;
    return 0;
}

Measured memory_bytes: 1024
def get_i() #空白区切の入力を数値(整数)の配列で返す
  return gets.chomp.split(" ").map(&:to_i)
end
def get_f() #空白区切の入力を数値(実数)の配列で返す
  return gets.chomp.split(" ").map(&:to_f)
end
def get() #空白区切の入力を文字列の配列で返す
  return gets.chomp.split(" ")
end
def get_nsp() #入力されたものを一文字ずつに区切った文字列の配列で返す
  return gets.chomp.split("")
end
def yn_judge(bool,y="Yes",n="No") #boolに真偽を投げることで、trueならy、falseならnの値を出力する
  return bool ? y : n 
end
def array(size,n=1,init=nil) #nに配列の次元数、sizeに配列の大きさ、initに初期値を投げることでその配列を返す
  if n==1
    return Array.new(size){init}
  else
    return Array.new(n).map{Array.new(size){init}}
  end
end

n=gets.to_i
puts n*800-(n/15)*200

Measured memory_bytes: 1788
#include <iostream>

using namespace std;

int join(int a, int b) {
  int msk = 1;
  while (msk<=b)msk*=10;
  return a*msk+b;
}

bool isSquare(int x) {
  int l = 0, r = 1919;
  while (r - l > 1) {
    int m = (l + r) / 2;
    if (m * m > x) r = m; else l = m;
  }
  return l * l == x;
}

int main() {
  int a,b;
  cin>>a>>b;
  puts(isSquare(join(a,b))?"Yes":"No");
}


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

using namespace std;

using i64 = int64_t;
using P = pair<i64, i64>;

struct edge {
    i64 from, to, cost;
    edge(i64 from, i64 to) : from(from), to(to), cost(1) {}
    edge(i64 from, i64 to, i64 cost) : from(from), to(to), cost(cost) {}
};
using Graph = vector<vector<edge>>;

constexpr i64 INF = std::numeric_limits<i64>::max();
constexpr i64 SINF = std::numeric_limits<i64>::max() / 10;
const i64 dx[4] = { 0,1,0,-1 }, dy[4] = { -1,0,1,0 };
//const i64 dx[5] = {-1,0,0,0,1}, dy[5] = {0,-1,0,1,0};
//const i64 dx[8] = {-1,0,1,1,1,0,-1,-1}, dy[8] = {1,1,1,0,-1,-1,-1,0};
//const i64 dx[9] = {-1,0,1,1,1,0,-1,-1,0}, dy[9] = {1,1,1,0,-1,-1,-1,0,0};

#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__)

// http://beet-aizu.hatenablog.com/entry/2018/04/08/145516
template<typename T>
vector<T> make_v(size_t a) { return vector<T>(a); }

template<typename T, typename... Ts>
auto make_v(size_t a, Ts... ts) {
    return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...));
}

template<typename T, typename V>
typename enable_if<is_class<T>::value == 0>::type
fill_v(T& t, const V& v) { t = v; }

template<typename T, typename V>
typename enable_if<is_class<T>::value != 0>::type
fill_v(T& t, const V& v) {
    for (auto& e : t) fill_v(e, v);
}

struct IoSetup {
    IoSetup() {
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(10);
        cerr << fixed << setprecision(10);
    }
} iosetup;

void solve(i64 n, vector<i64> h){
    rep(i, n + 1){
        bool flag = true;
        i64 d = h[1] - h[0];
        if(i == 0 || i == 1) d = h[3] - h[2]; 
        rep(j, n){
            if(j == i) continue;
            if(j == i - 1 && i == n) continue;
            if(j == i - 1) flag = flag && h[j + 2] - h[j] == d;
            else flag = flag && h[j + 1] - h[j] == d;
        }
        if(flag){
            cout << h[i] << endl;
            break;
        }
    }
}

int main(){
    while(true){
        i64 n;
        cin >> n;
        if(n == 0) break;
        vector<i64> k(n + 1);
        rep(i, n + 1) cin >> k[i];
        solve(n, k);
    }
}


Measured memory_bytes: 3140
#include<algorithm>
#include<complex>
#include<ctype.h>
#include<iomanip>
#include<iostream>
#include<map>
#include<math.h>
#include<numeric>
#include<queue>
#include<set>
#include<stack>
#include<stdio.h>
#include<string>
#include<string>
#include<vector>

using namespace std;
typedef long long ll;

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define ALL(v) (v).begin(), (v).end()
#define p(s) cout<<(s)<<endl
#define p2(s, t) cout << (s) << " " << (t) << endl
#define pn(s) cout << (#s) << " " << (s) << endl

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

class Point{
    public:
    Point(int a, int b){
        x = a;
        y = b;
    }
    int x;
    int y;

    bool operator<(const Point &another) const
    {
        return x < another.x;
    };

    bool operator==(const Point &another) const{
        return x==another.x && y==another.y;
    }

    static bool sortByY(Point a, Point b){
        if(a.y == b.y){
            return a.x < a.y;
        }else{
            return a.y < b.y;
        }
    }
};

void PrintPointVector(vector<Point> P){
    p("[vector]");
    if(P.size()==0){
        p("nothing");
    }
    for(auto p : P){
        cout << p.x << " " << p.y << endl;
    }
}


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

    // input
    int N;
    cin >> N;

    vector<Point> R;
    FOR(i, 0, N){
        int x, y;
        cin >> x >> y;
        R.push_back(Point(x, y));
    }

    vector<Point> B;
    FOR(i, 0, N){
        int x, y;
        cin >> x >> y;
        B.push_back(Point(x, y));
    }

    // Bをxの小さい順に並べる
    sort(ALL(B));

    int pairNum = 0;

    for(auto blue : B){
        // blue.xよりxが小さいものだけ集める
        vector<Point> temp;
        for(auto red : R){
            if(red.x < blue.x && red.y < blue.y){
                temp.push_back(red);
            }
        }

        if(temp.size() > 0){
            // yの小さい方からソート
            sort(ALL(temp), Point::sortByY);

            // yが最大の点をペアに選ぶ
            auto selectedRed = temp[temp.size()-1];

            // それをRから消す
            auto it = find(ALL(R), selectedRed);
            R.erase(it);
            pairNum++;
        }
    }

    p(pairNum);
    
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using P = pair<int, int>;

int main() {
	char c[2][3];
	for (int i = 0; i < 2; i++)
		for (int j = 0; j < 3; j++)
			cin >> c[i][j];
	if (c[0][0] == c[1][2] && c[0][1] == c[1][1] && c[0][2] == c[1][0])
		cout << "YES" << endl;
	else
		cout << "NO" << endl;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>'
using namespace std;
int main()
{
  int n;
  cin>>n;
  int d[n],i;
  for(i=0;i<=n-1;i++)
    cin>>d[i];
  int j;
  int s=0;
  for(i=0;i<=n-2;i++)
  {
    for(j=i+1;j<=n-1;j++)
    {
      s=s+d[i]*d[j];
    }
  }
  cout<<s;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#define N 100005
using namespace std;
int n, m, a[N], b[N], q, v, d, c[N], x[15][N];

int main() {
	int i, j;
	scanf("%d%d", &n, &m);
	for(i=1; i<=m; i++) scanf("%d%d", a+i, b+i);
	scanf("%d", &q);
	for(i=1; i<=q; i++) {
		scanf("%d%d%d", &v, &d, c+i);
		x[d][v] = i;
	}
	for(i=9; i>=0; i--) {
		for(j=1; j<=n; j++) x[i][j] = max(x[i][j], x[i+1][j]);
		for(j=1; j<=m; j++) {
			x[i][a[j]] = max(x[i][a[j]], x[i+1][b[j]]);
			x[i][b[j]] = max(x[i][b[j]], x[i+1][a[j]]);
		}
	}
	for(i=1; i<=n; i++) printf("%d\n", c[x[0][i]]);
	return 0;
}

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

ll D, G;

int main(){
    cin >> D >> G;
    vector<pair<ll, ll>> pc(D);
    rep(i, 0, D) cin >> pc[i].first >> pc[i].second;

    rep(d, 1, 1001){
        for(ll bit = 0; bit < (1<<D); bit++){
            ll tmp_d = 0;
            ll tmp_g = 0;
            priority_queue<ll> que;
            que.push(-1);
            rep(i, 0, D){
                if(bit & (1 << i)){
                    tmp_d += pc[i].first;
                    tmp_g += (100*(i+1)*pc[i].first + pc[i].second);
                }else{
                    que.push(i);
                }
            }
            if(tmp_d > d) continue;
            ll mxid = que.top();
            if(mxid == -1 && tmp_g < G) continue;
            if(G-tmp_g > 100*min(d-tmp_d, pc[mxid].first-1)*(mxid+1)) continue;
            cout << d << endl;
            return 0;
        }
    }

    return 0;
}

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

#define MX_N 100000
#define MX   1000000000

int n,k;
int tab[MX_N+5];
long long dp[MX_N+5];

int main( )
{
    cin>>n>>k;
    for( int i=0; i<n; i++ )
        cin>>tab[i];

    for( int i=2; i<n; i++ )
        dp[i]=MX;

    dp[1]=abs(tab[0]-tab[1]);
    for( int i=2; i<n; i++ )
    {
        //cout<<i<<": ";
        for( int j=max(0,i-k); j<i; j++ )
        {
            //cout<<j<<" ";
            dp[i]=min( dp[j]+abs(tab[j]-tab[i]), dp[i] );
        }
        //cout<<dp[i]<<"\n";
        //cout<<"\n";
    }
    cout<<dp[n-1]<<"\n";

}


Measured memory_bytes: 1408
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#ifdef _DEBUG
#include "dump.hpp"
#else
#define dump(...)
#endif

//#define int long long
#define DBG 1
#define rep(i, a, b) for (int i = (a); i < (b); i++)
#define rrep(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define loop(n) rep(loop, (0), (n))
#define all(c) begin(c), end(c)
const int INF =
    sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9) + 7;
const double PI = acos(-1);
const double EPS = 1e-9;
template <class T> bool chmax(T &a, const T &b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
template <class T> bool chmin(T &a, const T &b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
void tsort(vector<vector<int>> &g, vector<int> &visited, vector<int> &result,
           int x) {
  if (visited[x])
    return;
  visited[x] = 1;

  rep(i, 0, g[x].size()) { tsort(g, visited, result, g[x][i]); }
  result.push_back(x);
}
signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);

  int N, M;
  cin >> N >> M;
  vector<vector<int>> g(N);
  rep(i, 0, M) {
    int a, b;
    cin >> a >> b;
    a--, b--;
    g[a].push_back(b);
  }
  vector<int> visited(N, 0), t1;
  rep(i, 0, N) {
    if (visited[i])
      continue;
    tsort(g, visited, t1, i);
  }
  reverse(all(t1));

  rep(i, 0, N) { cout << t1[i] + 1 << endl; }

  rep(i, 1, N) {
    bool f = true;
    int x = t1[i - 1], y = t1[i];
    rep(j, 0, g[x].size()) {
      if (g[x][j] == y)
        f = false;
    }
    if (f) {
      cout << 1 << endl;
      return 0;
    }
  }
  cout << 0 << endl;
  return 0;
}



Measured memory_bytes: 4192
#include <bits/stdc++.h>
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <string>
using namespace std;
typedef long long int ll;
#define rep(i, n) for (int(i) = 0; (i) < (n); (i)++)

int main(){
    int A[5][5];

    for(int i=0; i<3; i++){
        for(int j=0; j<3; j++){
            cin >>A[i][j];
        }
    }
    int n; cin >> n;
    vector<int>b(n);
    rep(i,n)cin >>b[i];

    int x[5][5]={0};
    int cnt=0;
 for(int k=0; k<n; k++){
    for(int i=0; i<3; i++){
        for(int j=0; j<3; j++){          
            if(b[k]==A[i][j]){
                x[i][j]=1;
               // cnt++;
            }
        }
    }
 }   

    if(x[0][0]==1 && x[0][1]==1 && x[0][2]==1){
        cout << "Yes" <<endl;
        return 0;
    }else if(x[1][0]==1 && x[1][1]==1 && x[1][2]==1){
        cout << "Yes" <<endl;
        return 0;
    }else if(x[2][0]==1 && x[2][1]==1 && x[2][2]==1){
        cout << "Yes" <<endl;
        return 0;
    }else if(x[0][0]==1 && x[1][0]==1 && x[2][0]==1){
        cout << "Yes" <<endl;
        return 0;
    }else if(x[0][1]==1 && x[1][1]==1 && x[2][1]==1){ 
        cout << "Yes" <<endl;
        return 0;
    }else if(x[0][2]==1 && x[1][2]==1 && x[2][2]==1){ 
        cout << "Yes" <<endl;
        return 0;
    }else if(x[0][0]==1 && x[1][1]==1 && x[2][2]==1){ 
        cout << "Yes" <<endl;
        return 0;
    }else if(x[0][2]==1 && x[1][1]==1 && x[2][0]==1){ 
        cout << "Yes" <<endl;
        return 0;
    }
    cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <iomanip>
#include <iostream>
#include <map>
#include <string>
#include <vector>
using namespace std;

#define FOR(i, a, b) for (int i = a; i < b; ++i)
#define REP(i, n) for (int i = 0; i < n; ++i)
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;

ull powmod(ull a, ull b, ull mod) {
  ull res = 1;
  for (; b; b >>= 1) {
    if (b & 1) {
      res = res * a % mod;
    }
    a = a * a % mod;
  }
  return res;
}

int main() {
  int d, t, s;
  cin >> d >> t >> s;
  if (d <= t * s) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}


Measured memory_bytes: 3628
#include <stdio.h>

int main(){
	float a, MAX, min;
	scanf("%f", &a);
	MAX=a;
	min=a;
	while(scanf("%f", &a)!=EOF)
	{
		if(a>MAX)
		{
			MAX=a;
		}
		if(a<min)
		{
			min=a;
		}
	}
	printf("%f\n", MAX-min);
	return 0;
}

Measured memory_bytes: 1076
import java.util.*;
public class Main{
public static void main(String[]args){
Scanner sc=new Scanner(System.in);

int M1=sc.nextInt();
int D1=sc.nextInt();
int M2=sc.nextInt();
int D2=sc.nextInt();

if(M1!=12){
if(M1+1==M2&&D2==1){
System.out.println("1");
}else if(M1+1!=M2&&D2!=1){
System.out.println("0");
}
}

if(M1==12){
if(M2==1&&D2==1){
System.out.println("1");
}else if(M2!=1&&D2!=1){
System.out.println("0");
}
}
}
}



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

int main(){
  int n,y;
  cin>>n>>y;
  bool a=false;
  for (int i=0;i<=n;i++){
    for (int j=0;i+j<=n;j++){
      int k=n-i-j;
      if (1000*i+5000*j+10000*k==y){
        cout<<k<<" "<<j<<" "<<i<<endl;
        a=true;
        break;
      }
    }
    if (a) break;
  }
  if (!a) cout<<"-1 -1 -1"<<endl;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

struct Input
{
    int n;
    int k;
};

static Input read_input()
{
    Input input{};
    cin >> input.n >> input.k;
    return input;
}

static void solve(const Input& input)
{
    int num = 0;
    for (auto i = 0; i < input.n; ++i) {
        int h;
        cin >> h;

        if (h >= input.k) {
            num += 1;
        }
    }

    cout << num << endl;
}

int main(int argc, char** argv)
{
    ios::sync_with_stdio(false);
    cin.tie(0);

    const auto input = read_input();
    solve(input);
    return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
	int a, b;
	char op;

	while (1){

		cin >> a >> op >> b;

		if (op == '+')
			cout << a + b << endl;
		else if (op == '-')
			cout << a - b << endl;
		else if (op == '*')
			cout << a * b << endl;
		else if (op == '/')
			cout << a / b << endl;
		else if (op == '?')
			break;
	}
	return 0;
}

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

int main() {
	int m, f, r;
	while (1) {
		scanf("%d %d %d", &m, &f, &r);
		if (m == -1 && f == -1 && r == -1) {
			break;
		}
		if (m == -1 || f == -1) {
			printf("F\n");
		}
		else if (m + f >= 80) {
			printf("A\n");
		}
		else if (m + f >= 65) {
			printf("B\n");
		}
		else if (m + f >= 50) {
			printf("C\n");
		}
		else if (m + f >= 30) {
			if (r >= 50) {
				printf("C\n");
			}
			else {
				printf("D\n");
			}
		}
		else {
			printf("F\n");
		}
	}
	
	
}



Measured memory_bytes: 2076
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cassert>
#include <cctype>
using namespace std;
typedef long long lint;
#define cout cerr
#define ni (next_num<int>())
template<class T>inline T next_num(){
	T i=0;char c;
	while(!isdigit(c=getchar())&&c!='-');
	bool flag=c=='-';
	flag?c=getchar():0;
	while(i=i*10-'0'+c,isdigit(c=getchar()));
	return flag?-i:i;
}
template<class T1,class T2>inline void apmax(T1 &a,const T2 &b){if(a<b)a=b;}
template<class T1,class T2>inline void apmin(T1 &a,const T2 &b){if(b<a)a=b;}
const int N=110,INF=0x7f7f7f7f;
namespace G{
	const int N=110*2,E=110*110*2*2;
	int to[E],bro[E],cap[E],head[N],e=0,s,t;
	inline void init(){
		memset(head,-1,sizeof(head));
	}
	inline void ae(int u,int v,int c){
		to[e]=v,bro[e]=head[u],cap[e]=c,head[u]=e++;
	}
	inline void add(int u,int v,int c){
		ae(u,v,c),ae(v,u,0);
	}
	int dis[N],que[N];
	inline void bfs(){
		memset(dis,-1,t<<2);
		int qh=0,qt=0;
		dis[que[qt++]=t]=0;
		while(qh<qt){
			int x=que[qh++];
			for(int i=head[x],v;~i;i=bro[i]){
				if(cap[i^1]&&dis[v=to[i]]==-1){
					dis[que[qt++]=v]=dis[x]+1;
				}
			}
		}
	}
	int aug(int x,int a){
		if(x==t)return a;
		int r=a,d;
		for(int i=head[x],v;~i;i=bro[i]){
			if(cap[i]&&dis[v=to[i]]==dis[x]-1){
				d=aug(v,min(r,cap[i]));
				cap[i]-=d,cap[i^1]+=d,r-=d;
			}
		}
		return r?dis[x]=-1,a-r:a;
	}
	inline int dinic(){
		int flow=0;
		for(;bfs(),~dis[s];flow+=aug(s,INF));
		return flow;
	}
}
char s[N];
inline int Main(){
	int n=ni,m=ni;
	int sx,sy,tx,ty;
	G::init();
	G::s=n+m+1,G::t=n+m+2;
	for(int i=1;i<=n;i++){
		scanf("%s",s+1);
		for(int j=1;j<=m;j++){
			if(s[j]=='S'){
				sx=i,sy=j;
				G::add(G::s,i,INF);
				G::add(G::s,j+n,INF);
			}else if(s[j]=='T'){
				tx=i,ty=j;
				G::add(i,G::t,INF);
				G::add(j+n,G::t,INF);
			}else if(s[j]=='o'){
				G::add(i,j+n,1);
				G::add(j+n,i,1);
			}
		}
	}
	return sx==tx||sy==ty?-1:G::dinic();
}
int main(){
	printf("%d\n",Main());
	return 0;
}

Measured memory_bytes: 768
N, P = map(int, input().split())
S = input()
ans = 0

if P == 2 or P == 5:
  for i, s in enumerate(S):
    if int(s) % P == 0:
      ans += i + 1
else:
  l = [0] * P 
  l[0] = 1
  Sum = 0
  digits = 1
  
  for c in S[::-1]:
    Sum += int(c) * digits % P
    Sum %= P
    l[Sum] += 1
    digits = digits * 10 % P
  
  for i in range(len(l)):
    ans += l[i] * (l[i] - 1) // 2
  
print(ans)

Measured memory_bytes: 3500
#include <iostream>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>
#include <numeric>
#include <functional>
#include <map>
#include <set>
#define Rep(i, n) for(int i=0;i<n;++i)
#define rep(i, n) for(int i=1;i<=n;++i)
#define ll long long
#define INF 100000000
#define MOD 1000000007
#define PI 3.14159265359
#define All(a) (a).begin(), (a).end()

using namespace std;
using P = pair<ll int, ll int>;
 
int dx[4] = {0, 1, 0, -1};
int dy[4] = {1, 0, -1, 0};

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

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

int H, W;
char maze[2100][2100];

int tate[2100][2100];
int yoko[2100][2100];


int main () {
  cin >> H >> W;

  Rep(i, H) {
    Rep(j, W) {
      cin >> maze[i][j];
    }
  }

  Rep(j, W) {
    int tmp = 0;
    Rep(i, H) {
      if (maze[i][j] == '#') {
        for (int k=1;k<=tmp;++k) {
          tate[i-k][j] = tmp;
        } 
        tmp = 0;
      } else {
        ++tmp;
      }
    }
    for (int k=1;k<=tmp;++k) {
      tate[H-k][j] = tmp;
    } 
  }

  Rep(i, H) {
    int tmp = 0;
    Rep(j, W) {
      if (maze[i][j] == '#') {
        for (int k=1;k<=tmp;++k) {
          yoko[i][j-k] = tmp;
        }
        tmp = 0;
      } else {
        ++tmp;
      }
    }
    for (int k=1;k<=tmp;++k) {
      yoko[i][W-k] = tmp;
    } 
  }

  int ans = 0;

  Rep(i, H) {
    Rep(j, W) {
      ans = max(ans, tate[i][j] + yoko[i][j] - 1);
    }
  }

  cout << ans << "\n";
}

Measured memory_bytes: 38784
function main(input) {
const a = input.split(" ").map(Number);
  console.log(a[0]==a[1]?"Draw"
		    :(a[0]==1||(a[1]!=1&&a[0]>a[1]))?"Alice"
			:"Bob");
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 29584
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader input =new BufferedReader (new InputStreamReader (System.in));
		String str = input.readLine( );
		String[] start = {"keyenc", "keyen", "keye", "key", "ke", "k"};
		String[] end = {"e", "ce", "nce", "ence", "yence", "eyence"};

		if(str.startsWith("keyence") || str.endsWith("keyence")) {
			System.out.println("YES");
		}else {
			for(int i=0; i<6; i++) {
				if(str.startsWith(start[i]) && str.endsWith(end[i])) {
					System.out.println("YES");
					break;
				}
				if(i==5) {
					System.out.println("NO");
				}
			}

		}
	}

}


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

using namespace std;

#define pb push_back

const int maxi = 1e6+10;
string s;
vector<int> v[maxi];
int n;
long long a[maxi];


void dfs(int x, int pred)
{
    a[x]+=a[pred];

    for (int i:v[x])
        if (i!=pred) dfs(i,x);
}
int main()
{
     int q;
     cin>>n>>q;

     for (int i=1;i<n;i++)
     {
         int x,y;
         scanf("%d%d",&x,&y);
         v[x].pb(y);
         v[y].pb(x);
     }

     while(q--)
     {
         int x,y;
         scanf("%d%d",&x,&y);
         a[x]+=y;
     }

     dfs(1,0);

     for (int i=1;i<=n;i++)
        printf("%lld ",a[i]);

     printf("\n");

    return 0;
}
//pisacu joj pisma duga
//iz Zagore iz Drnisa
//razglednice tople s juga
//z Banata poslije Nisa

//ti si sunce moga neba
//tebi mogu reci
//ti si jedina od svih
//koja tajne moje cuva
//ti si moja ljubav prva <3


Measured memory_bytes: 44672
#include <bits//stdc++.h>
using namespace std;
int in(void){int x;cin>>x;return x;}
#define rep(i,a,b) for(int i=int(a);i<int(b);i++)
long long int dx[4]={1,0,-1,0};
long long int dy[4]={0,1,0,-1};

/*-----------------------------------------------------*/
int main() {
	string s,p;
	cin>>s>>p;
	if(s.size()<p.size()||p.size()==0)goto error;
	else if(s.size()==p.size()&&s==p){
		cout<<s<<endl;
	}
	int where;
	for(int i=s.size()-p.size();i>=0;i--){
		for(int j=0;j<p.size();j++){
			if(s[i+j]!=p[j]&&s[i+j]!='?'){
				goto next_i;
			}
		}
		where=i;
		goto ANS;
		next_i:
		if(i==0)goto error;
	}
	ANS:
	for(int i=0;i<s.size();i++){
		if(i>=where&&i<where+p.size()){
			cout<<p[i-where];
			continue;
		}
		if(s[i]=='?')cout<<'a';
		else cout<<s[i];
	}
	cout<<endl;
	return 0;
	error:
	cout<<"UNRESTORABLE"<<endl;
	return 0;
}


Measured memory_bytes: 256
import java.io.*;
class Main {
  public static void main (String[] args) throws Exception {
    BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
    String s;
    while(null != (s = in.readLine())){
      String[] arr = s.split(",",0);
      print(Long.parseLong(arr[0]),Double.parseDouble(arr[1]),Double.parseDouble(arr[2]));
    }
  }
  private static void print(long id,double  w,double h){
    double BMI = w/Math.pow(h,2);
    if(BMI >=25)
      System.out.println(id);
  }
}

Measured memory_bytes: 16932
import java.util.*;

 
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int x = sc.nextInt();
		int t = sc.nextInt();

		if(n % x != 0){
			System.out.println((n/x + 1) * t);
		}else{
			System.out.println(n/x * t);
		}

	}
}

Measured memory_bytes: 35640
#define _GLIBCXX_DEBUG
#include<algorithm>
#include<cmath>
#include<cstring>
#include<cstdio>
#include<iostream>
#include<vector>
#include<queue>
#include<deque>
#include<stack>
#include<set>
#include<map>
#include<string>
#include<bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)n; i++)
#define rep2(i,s,n) for(int i=s;i< (int)n; i++)
#define ll long long 
#define all(v) v.begin(),v.end()
using namespace std;
int main(){
  int n; cin>>n;
  vector<int> vec(n);
  set<ll> S;
  rep(i,n){
    int a;
    cin >>a;
    S.insert(a);
  }
  if(S.size()==n) cout <<"YES"<<endl;
  else cout <<"NO"<<endl;
}
  

Measured memory_bytes: 12032
#include<iostream>
using namespace std;
#include<string.h>
#include<stdio.h>
int main()
{
	char b, mark[]={"SHCD"};
	int a,i,m[4][14]={0},n,j;
	cin>>a;
	for(i=0;i<a;i++)
	{
		cin>>b>>n;
		if(b=='S')
		{
			m[0][n]=1;
		}
		if(b=='H')
		{
			m[1][n]=1;
		}
		if(b=='C')
		{
			m[2][n]=1;
		}
		if(b=='D')
		{
			m[3][n]=1;
		}
	}
	for(i=0;i<4;i++)
	{
		for(j=1;j<14;j++)
		{
			if(m[i][j]==0)
			{
				cout<<mark[i] <<" "<<j<<endl;
			}
		}
	}		
	return 0;
}

Measured memory_bytes: 3092
k = int(input())
val = 7
if k%2 == 0:
    ans = -1
elif k%5 == 0:
    ans = -1
else:
    for i in range(1,10**12+1):
        if val >= k:
            sub = val % k
            if sub == 0:
                  ans = i
                  break
            else:
                  val = 10 * sub + 7
        else:
            val = 10 * val + 7
print(ans)

Measured memory_bytes: 9064
import java.util.*;
import java.io.*;
import java.lang.*;



class Main
{
  public static void main(String[] args) {

  Scanner s=new Scanner(System.in);
  String a;
  a=s.next();
  int n=a.length();

  if(a.charAt(0)=='R' && a.charAt(1)=='R' && a.charAt(2)=='R')
  {
    System.out.print(3);
  }
  else if(a.charAt(0)=='R' && a.charAt(1)=='R' && a.charAt(2)=='S')
  {
    System.out.print(2);
  }
  else if(a.charAt(0)=='R' && a.charAt(1)=='S' && a.charAt(2)=='R')
  {
    System.out.print(1);
  }
  else if(a.charAt(0)=='S' && a.charAt(1)=='R' && a.charAt(2)=='R')
  {
    System.out.print(2);
  }
  else if(a.charAt(0)=='R' && a.charAt(1)=='S' && a.charAt(2)=='S')
  {
    System.out.print(1);
  }
  else if(a.charAt(0)=='S' && a.charAt(1)=='R' && a.charAt(2)=='S')
  {
    System.out.print(1);
  }
  else if(a.charAt(0)=='S' && a.charAt(1)=='S' && a.charAt(2)=='R')
  {
    System.out.print(1);
  }
  else
  {
    System.out.print(0);
  }












  }
}


Measured memory_bytes: 35564
#include <iostream>
#include <vector>
#include <cstdlib>
#include <math.h>

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

const long long INF = 1LL << 60;

#define MOD 1000000007



int N;

long long h[100010];

long long dp[100010];

int main(){

    int N; cin >> N;

    for(int i = 0; i < 100010; ++i) dp[i] = INF;

    dp[0] = 0;

    for(int i = 0; i < N; i++){
        
        chmin(dp[i+1], dp[i] + 1);

        int n6 = 1;
        int n6_num = pow(6, n6);

        while((i + n6_num) <= N){
            chmin(dp[i+n6_num], dp[i]+1);
            n6+=1;
            n6_num = pow(6, n6);
        }

        int n9 = 1;
        int n9_num = pow(9, n9);

        while((i + n9_num) <= N){
            chmin(dp[i+n9_num], dp[i]+1);
            n9+=1;
            n9_num = pow(9, n9);
        }
    }

    cout << dp[N] << endl;

}

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

public class Main {
    public static PrintWriter out;
    public static FastScanner in;

    private void solve(){
        int n = in.nextInt();
        long a = in.nextLong();
        long b = in.nextLong();
        long[] s = new long[n+1];

        for(int i=0;i<n;i++){
            s[i] = in.nextLong();
        }

        long st = s[0],cost = 0;
        for(int i=1;i<n;i++){
            if((s[i]- st)*a <= b){
                cost+= (s[i]-st)*a;
            }else{
                cost+=b;
            }
            st= s[i];
        }
        out.print(cost);

    }

    private void runIO() {
        in = new FastScanner();
        out = new PrintWriter(new BufferedOutputStream(System.out));
        solve();
        out.close();
    }
    private static class FastScanner {
        BufferedReader bufferedReader;
        StringTokenizer stringTokenizer;

        private FastScanner() {
            bufferedReader = new BufferedReader(new InputStreamReader(System.in));
        }

        private String next() {
            if (stringTokenizer == null || !stringTokenizer.hasMoreElements()) {
                try {
                    stringTokenizer = new StringTokenizer(bufferedReader.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return stringTokenizer.nextToken();
        }

        private int nextInt() {
            return Integer.parseInt(next());
        }

        private long nextLong() {
            return Long.parseLong(next());
        }

        private String nextLine() {
            String ret = "";
            try {
                ret = bufferedReader.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return ret;
        }
    }

    public static void main(String[] args) {
        new Main().runIO();
    }
}


Measured memory_bytes: 37716