akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define mp       make_pair
#define pb       push_back
#define all(x)   (x).begin(),(x).end()
#define YES() printf("YES\n")
#define NO() printf("NO\n")
#define Yes() printf("Yes\n")
#define No() printf("No\n")
#define in(x,y,h,w) x >= 0 && x < h && y >= 0 && y < w

#define int long long
#define double long double
//typedef    long long          ll;
typedef    vector<bool>       vb;
typedef    vector<int>        vi;
typedef    vector<vb>         vvb;
typedef    vector<vi>         vvi;
typedef    pair<int,int>      P;

template <typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }
 
const int INF=1e+18;
const double EPS=1e-9;
const int MOD=1000000007;

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

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

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

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

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

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

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

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

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

vector<int> G[100000];
int c[100000];

void dfs(int v){
	for(int to : G[v]){
		if(c[to] == -1){
			c[to] = !c[v];
			dfs(to);
		}
	}
}

signed main(){
	int n,m;
	cin >> n >> m;
	for(int i = 0;i < n;i++){
		c[i] = -1;
	}
	c[0] = 0;
	UnionFind<int> uf(n * 2);
	for(int i = 0;i < m;i++){
		int u,v,s;
		cin >> u >> v >> s; u--;v--;
		if(uf.issame(u,v + n)){
			if(uf.diff(u,v + n) != s){
				cout << 0 << endl;
				return 0;
			}
		}
		uf.merge(u,n + v,s);
		uf.merge(v,n + u,s);
		G[u].pb(v);
		G[v].pb(u);
	}
	dfs(0);
	int st = -1;
	for(int i = 0;i < n;i++){
		if(uf.issame(i,i + n)){
			if(uf.diff(i,i + n) <= 0 || uf.diff(i,i + n) % 2){
				st = 1;
				break;
			}else st = 0;
		}
	}
	if(st == 1) cout << 0 << endl;
	else if(!st) cout << 1 << endl;
	else{
		int mi = INF,ma = INF;
		uf.merge(0,n,2);
		for(int i = 0;i < n;i++){
			if(!c[i]) chmin(mi,uf.diff(i,i + n) / 2);
			else chmin(ma,uf.diff(i,i + n) / 2);
		}
		ma -= 1 - mi;
		cout << max(0ll,ma) << endl;
	}
	return 0;
}

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

int main(){
    int N;
    cin>>N;
    vector<int> data(3*N);
    for(int i=0;i<3*N;i++){
        cin>>data[i];
    }
    sort(data.begin(),data.end());
    long int sum=0;
    for(int i=N;i<3*N-1;i+=2){
        sum+=data[i];
    }
    cout<<sum<<endl;
 
}


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

int main(){
  int a,b; cin >> a >> b;
  if (a==1) a=14;
  if( b==1) b=14;
  if(a>b) cout << "Alice" << endl;
  else if(a<b) cout << "Bob" << endl;
  else cout << "Draw" << endl;
}

Measured memory_bytes: 256
#include <float.h>
#include <inttypes.h>
#include <limits.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <unistd.h>
#include <math.h>
#ifdef __cplusplus
#include <bits/stdc++.h>
#endif

char bufr[4400007];
int bufrl;
#define getchar_unlocked() bufr[bufrl++]

void rsort_u32(void *base, const int count){
	uint32_t *a=base;
	uint32_t *b=malloc(count*sizeof(uint32_t));
	int c[0x100];
	memset(c, 0, sizeof(c)); for(int i=0; i<count; i++){ c[(a[i]>>(0<<3))&0xFF]++; } for(int i=1; i<0x100; i++) c[i]+=c[i-1]; for(int i=count-1; i>=0; i--){ b[--c[(a[i]>>(0<<3))&0xFF]]=a[i]; }{void *t=a; a=b; b=t;}
	memset(c, 0, sizeof(c)); for(int i=0; i<count; i++){ c[(a[i]>>(1<<3))&0xFF]++; } for(int i=1; i<0x100; i++) c[i]+=c[i-1]; for(int i=count-1; i>=0; i--){ b[--c[(a[i]>>(1<<3))&0xFF]]=a[i]; }{void *t=a; a=b; b=t;}
	memset(c, 0, sizeof(c)); for(int i=0; i<count; i++){ c[(a[i]>>(2<<3))&0xFF]++; } for(int i=1; i<0x100; i++) c[i]+=c[i-1]; for(int i=count-1; i>=0; i--){ b[--c[(a[i]>>(2<<3))&0xFF]]=a[i]; }{void *t=a; a=b; b=t;}
	memset(c, 0, sizeof(c)); for(int i=0; i<count; i++){ c[(a[i]>>(3<<3))&0xFF]++; } for(int i=1; i<0x100; i++) c[i]+=c[i-1]; for(int i=count-1; i>=0; i--){ b[--c[(a[i]>>(3<<3))&0xFF]]=a[i]; }{void *t=a; a=b; b=t;}
	free(b);
}
int32_t nextint(void){ char c=getchar_unlocked(); while(c!='-'&&(c<'0'||'9'<c)) c=getchar_unlocked(); bool s=false; if(c=='-'){s=true;c=getchar_unlocked();} uint32_t x=0; while('0'<=c && c<='9'){ x=x*10+c-'0'; c=getchar_unlocked(); } return s?-x:x; }
int64_t nextlong(void){ char c=getchar_unlocked(); while(c!='-'&&(c<'0'||'9'<c)) c=getchar_unlocked(); int s=0; if(c=='-'){s=1;c=getchar_unlocked();} uint64_t x=0; while('0'<=c && c<='9'){ x=x*10+c-'0'; c=getchar_unlocked(); } return s?-x:x; }

int a[200000];
int b[200000];
int main(void){
	read(STDIN_FILENO, bufr, sizeof(bufr));
	int n=nextint();
	for(int i=0; i<n; i++){
		a[i]=nextint();
		b[i]=nextint();
	}
	rsort_u32(a, n);
	rsort_u32(b, n);
	int ans;
	if(n&1){
		int A=a[n/2], B=b[n/2];
		ans=B-A+1;
	}else{
		int A=a[n/2]+a[n/2-1], B=b[n/2]+b[n/2-1];
		ans=B-A+1;
	}
	printf("%d\n", ans);
}


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

public class Main {
    
    static int m;
    static int n;
    static ArrayList<Integer>[] next;
    static boolean[] dp;
    static int count;
    public static void main(String[] args) throws IOException {
        BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
        //StringTokenizer st=new StringTokenizer(br.readLine());
        String str=br.readLine();
        int i=0;
        while(str.charAt(i)!='A'){ i++; }
        int j=str.length()-1;
        while(str.charAt(j)!='Z'){ j--; }
        System.out.println(j+1-i);
    }
    
}


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

using namespace std;

typedef long long ll;
typedef vector<ll> Vec;
typedef vector<Vec> Mat;

int main()
{
    int n;
    ll V;
    while(cin>>n>>V)
    {
        Mat mat(4,Vec(n));
        for(int i=0;i<4;i++)
        {
            for(int j=0;j<n;j++)
            {
                cin>>mat[i][j];
            }
        }
        Vec a(n*n);
        for(int i=0;i<n;i++)
        {
            for(int j=0;j<n;j++)
            {
                a[i*n+j]=mat[0][i]+mat[1][j];
            }
        }
        sort(a.begin(),a.end());
        ll ans=0;
        for(int i=0;i<n;i++)
        {
            for(int j=0;j<n;j++)
            {
                ll tmp=V-mat[2][i]-mat[3][j];
                ll cnt=upper_bound(a.begin(),a.end(),tmp)-lower_bound(a.begin(),a.end(),tmp);
                ans+=cnt;
            }
        }
        cout<<ans<<endl;
    }

    return 0;
}



Measured memory_bytes: 10796
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using VI = vector<ll>;
using VV = vector<VI>;
using VS = vector<string>;

// tourist set
template <typename A, typename B>
string to_string(pair<A, B> p);

template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p);

template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p);

string to_string(const string& s) {
  return '"' + s + '"';
}

string to_string(const char* s) {
  return to_string((string) s);
}

string to_string(bool b) {
  return (b ? "true" : "false");
}

string to_string(vector<bool> v) {
  bool first = true;
  string res = "{";
  for (int i = 0; i < static_cast<int>(v.size()); i++) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(v[i]);
  }
  res += "}";
  return res;
}

template <size_t N>
string to_string(bitset<N> v) {
  string res = "";
  for (size_t i = 0; i < N; i++) {
    res += static_cast<char>('0' + v[i]);
  }
  return res;
}

template <typename A>
string to_string(A v) {
  bool first = true;
  string res = "{";
  for (const auto &x : v) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(x);
  }
  res += "}";
  return res;
}

template <typename A, typename B>
string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}

template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p) {
  return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ")";
}

template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p) {
  return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ", " + to_string(get<3>(p)) + ")";
}

void debug_out() { cerr << '\n'; }

template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}

#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif
// tourist set end

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

#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define rep(i,b) FOR(i, 0, b)
#define ALL(v) (v).begin(), (v).end()
#define p(s) cout<<(s)<<'\n'
#define p2(s, t) cout << (s) << " " << (t) << '\n'
#define br() p("")
#define pn(s) cout << (#s) << " " << (s) << '\n'
#define p_yes() p("YES")
#define p_no() p("NO")
#define SZ(x) ((int)(x).size())
#define SORT(A) sort(ALL(A))
#define RSORT(A) sort(ALL(A), greater<ll>())

void no(){p_no(); exit(0);}
void yes(){p_yes(); exit(0);}

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

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

    // input
    ll A, B;
    cin >> A >> B;

    if(2*B>=A){
      p(0);
    }else{
      p(A - 2*B);
    }
    
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <map>
#include <queue>
#include <iomanip>
#include <set>
#include <tuple>
#define mkp make_pair
#define mkt make_tuple
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define all(v) v.begin(),v.end()
using namespace std;
typedef long long ll;
const ll MOD=1e9+7;
template<class T> void chmin(T &a,const T &b){if(a>b) a=b;}
template<class T> void chmax(T &a,const T &b){if(a<b) a=b;}

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

  ll N,X,M;
  cin>>N>>X>>M;

  vector<vector<int>> nxt(M,vector<int> (40));
  vector<vector<ll>> sum(M,vector<ll> (40,0));
  for(ll i=0;i<M;i++){
    nxt[i][0]=(i*i)%M;
    sum[i][0]=i;
  }
  for(int k=1;k<40;k++){
    for(int i=0;i<M;i++){
      nxt[i][k]=nxt[nxt[i][k-1]][k-1];
      sum[i][k]=sum[i][k-1]+sum[nxt[i][k-1]][k-1];
    }
  }

  ll now=X;
  ll ans=0;
  for(ll k=39;k>=0;k--){
    if(N&(1ll<<k)){
      ans+=sum[now][k];
      now=nxt[now][k];
    }
  }
  cout<<ans<<endl;

  return 0;
}


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

using namespace std;
int n;
string s;
int dp[4005][3];
//0r 1g 2b
int main() {
	cin>>n>>s;
	for(int i=s.size()-1; i>=0; i--) {
		for(int j=0; j<3; j++)
			dp[i][j]=dp[i+1][j];
		if(s[i]=='R') dp[i][0]++;
		if(s[i]=='G') dp[i][1]++;
		if(s[i]=='B') dp[i][2]++;
	}
	long long ans=0;
	for(int i=0; i<n; i++)
		for(int j=i+1; j<n; j++) {
			if(s[i]=='R'&&s[j]=='G') {
				ans+=dp[j+1][2];
				if(j+j-i>=n) continue;
				if(s[j+(j-i)]=='B')
					ans--;
			}
			if(s[i]=='R'&&s[j]=='B') {
				ans+=dp[j+1][1];
				if(j+j-i>=n) continue;
				if(s[j+(j-i)]=='G')
					ans--;
			}
			if(s[i]=='B'&&s[j]=='R') {
				ans+=dp[j+1][1];
				if(j+j-i>=n) continue;
				if(s[j+(j-i)]=='G')
					ans--;
			}
			if(s[i]=='B'&&s[j]=='G') {
				ans+=dp[j+1][0];
				if(j+j-i>=n) continue;
				if(s[j+(j-i)]=='R')
					ans--;
			}
			if(s[i]=='G'&&s[j]=='B') {
				ans+=dp[j+1][0];
				if(j+j-i>=n) continue;
				if(s[j+(j-i)]=='R')
					ans--;
			}
			if(s[i]=='G'&&s[j]=='R') {
				ans+=dp[j+1][2];
				if(j+j-i>=n) continue;
				if(s[j+(j-i)]=='B')
					ans--;
			}
		}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 3636
n = int(input())
r = [list(map(int, input().split())) for i in range(n)]
b = [list(map(int, input().split())) for i in range(n)]
r.sort(key=lambda x: x[1], reverse=True)
b.sort(key=lambda x: x[0])
ans = 0
for i, bb in enumerate(b):
    c, d = bb
    for j, rr in enumerate(r):
        a, b = rr
        if c > a and d > b:
            ans += 1
            del r[j]
            break
print(ans)


Measured memory_bytes: 38896
#include<stdio.h>

int main()
{
    int n, i, j, data[10], a_index=0, b_index=0, check=0;
    int tube_a[10]={}, tube_b[10]={};
    scanf("%d", &n);
    for(i = 0; i < n; i++, check = 0, a_index=1, b_index=0){
        for(j = 0; j < 10; j++){
            scanf("%d", &data[j]);
        }
        tube_a[0] = data[0];
        for(j = 1; j < 10; j++){
            if(data[j] < tube_a[a_index - 1]){
                if(b_index == 0){
                    tube_b[b_index++] = data[j];
                }else if(tube_b[b_index - 1] < data[j]){
                    tube_b[b_index++] = data[j];
                }else{
                    printf("NO\n");
                    check = 1;
                    break;
                }
            }else{
                tube_a[a_index++] = data[j];
            }
        }
        if(check == 0) puts("YES");
    }
    return 0;
}

Measured memory_bytes: 1668
#include<stdio.h>
int main()
{
	int a,b,c,d,x=0;
	scanf("%d %d %d %d",&a,&b,&c,&d);
 if(a<b) x+=a;
 else x+=b;
 if(c<d) x+=c;
 else x+=d;
 printf("%d\n",x);
}

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

int main() {
    int a[5];
    cin >> a[0] >> a[1] >> a[2];
    sort(a, a + 3);
    cout << a[0] + a[1] << endl;

    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner c = new Scanner(System.in);

        String[] str1 = c.nextLine().split(" ");
        String[] str2 = c.nextLine().split(" ");
        String str3 = c.nextLine();

        long firstPositionA = Long.parseLong(str1[0]);
        long firstPositionB = Long.parseLong(str2[0]);
        long v = Long.parseLong(str1[1]);
        long w = Long.parseLong(str2[1]);
        long t = Long.parseLong(str3);

        if (v <= w) {
            System.out.println("NO");
            return;
        }

        if (Math.abs(firstPositionB - firstPositionA) <= Math.abs((w - v) * t)) {
            System.out.println("YES");
        } else {
            System.out.println("NO");
        }

    }

}


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

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

int add_tax(int x, int p) {
    return p * (100+x) / 100;
}

int main() {
    while (true) {
        int x,y,s;
        cin >> x >> y >> s;
        if (x == 0 && y == 0 && s == 0) break;
        int ans = 0;
        rep(a,1,s+1) {
            rep(b,1,s+1) {
                if (add_tax(x,a) + add_tax(x,b) == s) {
                    int res = add_tax(y,a) + add_tax(y,b);
                    ans = max(ans, res);
                }
            }
        }
        cout << ans << endl;
    }
}


Measured memory_bytes: 3124
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <cmath>
#include <iomanip>

using namespace std;
using ll = long long;
using pii = pair<int, int>;
using vi = vector<int>;
template<class T>using vv = vector<vector<T>>;

// #define rep(i,n) for(int i=0;i<(n);++i)
#define all(f,c,...) (([&](decltype((c)) cccc) { return (f)(begin(cccc), end(cccc), ## __VA_ARGS__); })(c))
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) for(int i=0;i<(n);++i)
#define repi(i,a,b) for(int i=(a);i<(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)

#define rrep(i,n) for(int i=(n);i>=0;--i)
const int dx[4]={1,0,-1,0}, dy[4]={0,1,0,-1};
template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return 1;}return 0;}
template<class T>bool chmin(T &a,const T &b){if(b<a){a=b;return 1;}return 0;}

// debug
template<class T>ostream& operator<<(ostream& os,const vector<T>& vec){os<<"{";for(int i=0;i<vec.size();++i)os<<(i?", ":"")<<vec[i];os<<"}";return os;}
template<class T1,class T2>ostream& operator<<(ostream& os,const pair<T1,T2>& rhs){os<<"("<<rhs.first<<", "<<rhs.second<<")";return os;}

#ifdef LOCAL
void debug() {cerr << "\n";}
template<class First> void debug(const First& first) {cerr<<first<<"\n";}
template<class First, class... Rest> void debug(const First& first, const Rest&... rest) {cerr<<first<<",";debug(rest...);}
#else
#define debug(...) 42
#endif


int main() {
  int X, Y; cin >> X >> Y;
  int A, B, C; cin >> A >> B >> C;

  vi P(A), Q(B), R(C);
  rep(i, A) cin >> P[i];
  rep(i, B) cin >> Q[i];
  rep(i, C) cin >> R[i];
  all(sort, P); all(reverse, P);
  all(sort, Q); all(reverse, Q);
  all(sort, R);

  ll sum = 0;
  priority_queue<int, vi, greater<int>> q;
  rep(i, min(X, A)) {
    sum += P[i];
    q.push(P[i]);
  }
  if (X < A) {
    rep(i, X - A) {
      sum += R.back();
      q.push(R.back());
      R.pop_back();
    }
  }
  rep(i, min(Y, B)) {
    sum += Q[i];
    q.push(Q[i]);
  }
  if (Y < B) {
    rep(i, Y - B) {
      sum += R.back();
      q.push(R.back());
      R.pop_back();
    }
  }
  while (!q.empty() && !R.empty()) {
    int p = q.top(); q.pop();
    if (p >= R.back())
      break;
    sum -= p;
    sum += R.back();
    R.pop_back();
  }
  cout << sum << endl;



  return 0;
}


Measured memory_bytes: 2552
h, w = map(int, input().split())
s_list = [input() for i in range(h)]
ans_list = []
for i in range(h):
    ans_line = []
    for j in range(w):
        ans_line.append('#')
    for j in range(w):
        count = 0
        if s_list[i][j] == '#':
            continue
        for dy in range(-1, 2):
            for dx in range(-1, 2):
                if dy == 0 and dx == 0:
                    continue
                ny = dy + i
                nx = dx + j
                if ny < 0 or nx < 0 or ny >= h or nx >= w:
                    continue
                if s_list[ny][nx] == '#':
                    count += 1
        ans_line[j] = count
    ans_list.append(ans_line)

for ans_y in ans_list:
    for ans_x in ans_y:
        print(ans_x, end='')
    print()


Measured memory_bytes: 3444
#include<stdio.h>
#include<string.h>

int main(){
    int a,b,total=0;
	scanf("%d %d",&a,&b);
	
    char s[a+b+2];
    scanf("%s", &s);
    
    for(int i=0; i<a+b+1 ;i++){
        if(i!=a){
            if(s[i]>=48 && s[i]<=57){
                total++;
            } 
        } 
		else {
            if(s[i] == '-'){
                total++;
            }
        }
    }
    
    if (total==a+b+1){
    	printf("Yes");
	}
	else {
		printf("No");
	}
    
    return 0;
}

Measured memory_bytes: 3180
use std::io;

fn main() {
    let mut buf = String::new();
    let stdin = io::stdin();
    stdin.read_line(&mut buf).unwrap();
    let (N, D): (usize, i64) = {
        let mut split = buf.split_whitespace();
        (
            split.next().unwrap().parse().unwrap(),
            split.next().unwrap().parse().unwrap(),
        )
    };
    let ans = (0..N)
        .map(|_| {
            buf.clear();
            stdin.read_line(&mut buf).unwrap();
            let mut split = buf.split_whitespace();
            let x: i64 = split.next().unwrap().parse().unwrap();
            let y: i64 = split.next().unwrap().parse().unwrap();
            x * x + y * y
        })
        .filter(|&x| x <= D * D)
        .count();
    println!("{}", ans);
}


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

using namespace std;

void lcs(string a, string b){
    int n = a.size(), m = b.size();

    int lcs[n+1][m+1], i, j;


     for(i = 0;i <= m;i++){
         lcs[0][i] = 0;
     }  
     for(i = 0;i <= n;i++)
          lcs[i][0] = 0;

    for(i = 1;i <= n;i++){
          for(j = 1;j <= m;j++){
              if(a[i-1] == b[j-1]){
                  lcs[i][j] = 1 + lcs[i-1][j-1]; 
              }
              else{
                  lcs[i][j] = max(lcs[i-1][j], lcs[i][j-1]);
              }
          }
    }
    int posr = n, posc = m;
    string res ="";
    // for(i = 1;i <= n;i++){
    //      for(j = 0;j <= m;j++){
    //          cout<<lcs[i][j]<<" ";
    //      }
    //      cout<<"\n";
    // }

    while(posr > 0 && posc > 0){
        if(a[posr-1] == b[posc-1]){
            res += a[posr-1];
            posr--;
            posc--;
        }
        else{
            if(lcs[posr-1][posc] > lcs[posr][posc-1]){
                posr--;
            }
            else{
                posc--;
            }
        }
    }
    
    reverse(res.begin(), res.end());
   cout<<res<<"\n";
    
}

int main(){
    string a, b;

    int i, j;

    cin>>a>>b;

    lcs(a, b);
}


Measured memory_bytes: 35456
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
#define REP(i, n) for(ll (i) = 0; (i) < (n); (i)++)
#define REPR(i, n) for(ll (i) = (n); (i) >= 0; (i)--)
#define FOR(i, m, n) for(ll (i) = (m); (i) < (n); (i)++)
#define INF 1e9
#define ALL(v) v.begin(), v.end()
#define _GLIBCXX_DEBUG

template <uint MD> struct ModInt {
    using M = ModInt;
    const static M G;
    uint v;
    ModInt(ll _v = 0) { set_v(uint(_v % MD + MD)); }
    M& set_v(uint _v) {
        v = (_v < MD) ? _v : _v - MD;
        return *this;
    }
    explicit operator bool() const { return v != 0; }
    M operator-() const { return M() - *this; }
    M operator+(const M& r) const { return M().set_v(v + r.v); }
    M operator-(const M& r) const { return M().set_v(v + MD - r.v); }
    M operator*(const M& r) const { return M().set_v(uint(ull(v) * r.v % MD)); }
    M operator/(const M& r) const { return *this * r.inv(); }
    M& operator+=(const M& r) { return *this = *this + r; }
    M& operator-=(const M& r) { return *this = *this - r; }
    M& operator*=(const M& r) { return *this = *this * r; }
    M& operator/=(const M& r) { return *this = *this / r; }
    bool operator==(const M& r) const { return v == r.v; }
    M pow(ll n) const {
        M x = *this, r = 1;
        while (n) {
            if (n & 1) r *= x;
            x *= x;
            n >>= 1;
        }
        return r;
    }
    M inv() const { return pow(MD - 2); }
    friend ostream& operator<<(ostream& os, const M& r) { return os << r.v; }
};
using Mint = ModInt<1000000007>;

const double PI = 3.14159265358979323846;

bool compare_by_b(pair<int, int> a, pair<int, int> b) {
    if(a.second != b.second){
        return a.second < b.second;
    }else{
        return a.first < b.first;
    }
}

ll gcd(ll a, ll b) {
    return b != 0 ? gcd(b, a % b) : a;
}

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

int main()
{	    
    int a;
    cin >> a;
    cout << a+a*a+a*a*a << endl;
}


Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
int main () {
	int a,b,c;
	cin >> a >> b >> c;
	int n5 = ((a==5)?1:0) + ((b==5)?1:0) + ((c==5)?1:0);
	int n7 = ((a==7)?1:0) + ((b==7)?1:0) + ((c==7)?1:0);
	cout << ((n5==2) && (n7==1)?"YES":"NO");
	return 0;
}

Measured memory_bytes: 3640
#include<bits/stdc++.h>
using namespace std;
signed main(){
  string a; 
  cin>>a;
  int b=0,c=1;
  for(int i=0;i<a.size();i++){
    if(a[i]=='A'){ 
      if(a[i+1]=='C'){
        cout<<"Yes";
        c=0;
        break;
      }
    }
  }
  if(c) cout<<"No";
  cout<<"\n";
}

Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
#define null -1
using namespace std;
int a[15], b[15], c[15];

bool dfs(int amax, int bmax, int index)
{
    bool flag1 = false, flag2 = false;
    if(index >= 10) return true;
    if(a[index] > amax) {
        flag1 = dfs(a[index], bmax, index+1);
    }
    if(!flag1 && a[index] > bmax) {
        flag2 = dfs(amax, a[index], index+1);
    }
    if(flag1 || flag2) {
        return true;
    } else {
        return false;
    }
}

void solve()
{
    bool ok = dfs(-1, -1, 0);
    if(ok) printf("YES\n");
    else printf("NO\n");
}

int main()
{
    int n;
    scanf("%d", &n);
    while(n--) {
        fill(a, a+15, -1);
        for(int i = 0; i < 10; i++) {
            scanf("%d", &a[i]);
        }
        solve();
    }

    return 0;
}



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

int main(){
    string first,last;
    bool flag = false;
    cin >> first >> last;
    for(int i = 0; i < 26; i++){
        if(last == first + char('a' + i)){
            flag = true;
        }
    }
    if(flag) cout << "Yes"<< endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 3600
#include <iostream>
#include <cmath>
#include <cstdio>
using namespace std;

class Point{
public: double x,y;
    
    Point(int xx,int yy){
        x = xx;
        y = yy;
    }
};

double getDistance(Point p1,Point p2){
    return sqrt(pow(p1.x-p2.x,2)+pow(p1.y-p2.y,2));
}

int main(){
    Point p1(0,0),p2(0,0);
    
    cin >> p1.x >> p1.y >> p2.x >> p2.y;
    printf("%.8f\n", getDistance(p1,p2));
    
    return 0;
}

Measured memory_bytes: 1240
import java.util.*;

 class Main
 {
   public static void main(String args[])
   { 
    Scanner sc = new Scanner(System.in);
    
    int a = sc.nextInt();
    
    int b = sc.nextInt();
    
    System.out.printf("%d %d %.5f",a / b,a % b,(double)a / (double)b);
   }
 }
    


Measured memory_bytes: 26540
// I SELL YOU...! 
#include<iostream>
#include<vector>
#include<algorithm>
#include<functional>
#include<queue>
#include<chrono>
#include<iomanip>
#include<map>
#include<set>
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using TP = tuple<ll,ll,ll>;
void init_io(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << setprecision(18);
}
signed main(){
  init_io();
  string s;
  cin >> s;
  bool can =false;
  for(auto c:s){
    if(c=='7') can = true;
  }
  if(can) cout <<"Yes\n";
  else cout <<"No\n";
}


Measured memory_bytes: 3612
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<math.h>
#include<stack>
#include<queue>
#include<vector>
#include<algorithm>
#include<string>
#include<iostream>
using namespace std;
int min(int a,int b){if(a<b)return a;else return b;};

int main() {
    int n;cin>>n;
    int t[n],a[n],h1[n],h2[n];
    for(int i=0;i<=n-1;i++)h1[i]=h2[i]=-1;
    for(int i=0;i<=n-1;i++)scanf("%d",&t[i]);
    for(int i=0;i<=n-1;i++)scanf("%d",&a[i]);
    for(int i=0;i<=n-1;i++)if(i==0||t[i-1]<t[i])h1[i]=t[i];
    for(int i=n-1;i>=0;i--)if(i==n-1||a[i]>a[i+1])h2[i]=a[i];

    int flag=0;
    int an[n];
    for(int i=0;i<=n-1;i++)an[i]=1;
    for(int i=0;i<=n-1;i++){
        if(h1[i]!=-1&&h2[i]!=-1){
            if(h1[i]!=h2[i])flag=1;
        }else if(h1[i]!=-1){
            if(h1[i]>a[i])flag=1;
        }else if(h2[i]!=-1){
            if(h2[i]>t[i])flag=1;
        }else{
            an[i]=min(t[i],a[i]);
        }
    }
    
    if(flag==1)printf("0");
    else {
        long long int ans=1;
        for(int i=0;i<=n-1;i++){
            ans=(ans*an[i])%1000000007;
        }
        printf("%lld",ans);
    }
    return 0;
}


Measured memory_bytes: 2176
#include <iostream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <unordered_map>
#include <stack>
#include <queue>
#include <string>
#include <utility>
#include <algorithm>
#include <functional>
#include <deque>
#define INT_INF 1000000000
#define DOUBLE_INF 1e18
#define MOD 1000000007
#define mod(x) ((x % MOD) + MOD) % MOD

using namespace std;

typedef long long ll;
typedef pair<int,int> P;

int main()
{
  string s;
  cin >> s;

  for (int i = 0; i < s.size(); i++) {
    if (i >= 1 && s[i-1] == s[i]) {
        cout << (i-1)+1 << " " << i+1 << endl;
        return 0;
    }
    if (i >= 2 && s[i-2] == s[i]) {
        cout << (i-2)+1 << " " << i+1 << endl;
        return 0;
    }
  }

  cout << "-1 -1" << endl;

  return 0;
}


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


int main(){
    ll a,b;
    cin >> a >> b;
    if(a<b)swap(a,b);
    ll A = a, B = b, r;
    r = A % B;
    while(r!=0){
        A = B;
        B = r;
        r = A % B;
    }
    cout << a * b / B << endl;
}

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

using namespace std;

int main(){
  int N;
  cin >> N;
  vector<int> p(N);
  int ans=0;
  for(int i=0; i<N; i++){
    cin >> p[i];
    ans+=p[i];
  }
  sort(p.begin(), p.end(), greater<int> ());
  cout << ans-p[0]/2 << endl;
  
  return 0;
}


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

int n, k;
bool alln(vector<int>& v){
  for(int i=0;i<n;++i) if(v[i]!=n) return false;
  return true;
}

void simulate(vector<int>& v){
  int cnt = 0;
  vector<int> tmp(n+1, 0);
  for(int i=0;i<n;++i) {
    tmp[max(0, i-v[i])]++;
    tmp[min(n, i+v[i]+1)]--;
  }
  for(int i=0;i<n;++i){
    cnt += tmp[i];
    v[i] = cnt;
  }
}

int main() {
  scanf("%d %d", &n, &k);
  vector<int> v(n);
  for(int i=0;i<n;++i) scanf("%d", &v[i]);

  while(k--){
    simulate(v);
    if(alln(v)){
      for(int i=0;i<n;++i) cout << n << (i==n-1?'\n':' ');
      return 0;
    }
  }
  for(int i=0;i<n;++i) cout << v[i] << (i==n-1?'\n':' ');
  return 0;
}


Measured memory_bytes: 4560
S = input()
ans = 0
while len(S)>0:
  if S[:9] == 'dreamerer':#dreamer
    S = S[7:]
  elif S[:8] == 'dreamerd':#dreamer
    S = S[7:]
  elif S[:8] == 'dreamera':#dream
    S = S[5:]
  elif S[:6] == 'dreamd':#dream
    S = S[5:]
  elif S[:7] == 'eraserd':#eraser
    S = S[6:]
  elif S[:7] == 'erasere':#eraser
    S = S[6:]
  elif S[:6] == 'erasee':#erase
    S = S[5:]
  elif S[:6] == 'erased':#erase
    S = S[5:]
  elif S[:] == 'dreamer':
    S = S[7:]
  elif S[:] == 'dream':
    S = S[5:]
  elif S[:] == 'eraser':
    S = S[6:]
  elif S[:] == 'erase':
    S = S[5:]
  else:
    ans += 1
    break
if ans == 0:
  print('YES')
else:
  print('NO')


Measured memory_bytes: 3188
#include<stdio.h>
#define INF 10000000
int cost[100][100];
int min(int a,int b){return a<b?a:b;}
int main(){
	while(1){
		int n,m,s,x,y;
		int i,j,k;
		scanf("%d %d %d %d %d",&n,&m,&s,&x,&y);
		s--;x--;y--;
		if(n==0)return 0;
		for(i=0;i<n;i++){
			for(j=0;j<n;j++)cost[i][j]=INF;
			cost[i][i]=0;
		}
		for(i=0;i<m;i++){
			int a,b,c;
			scanf("%d %d %d",&a,&b,&c);
			cost[a-1][b-1]=c;
		}
		for(k=0;k<n;k++){
			for(i=0;i<n;i++){
				for(j=0;j<n;j++)cost[i][j]=min(cost[i][j],cost[i][k]+cost[k][j]);
			}
		}
		int ans=INF;
		for(i=0;i<n;i++)ans=min(ans,cost[s][i]+cost[i][x]+cost[i][y]);
		printf("%d\n",ans);
	}
}

Measured memory_bytes: 1064
#include <iostream>
#include <vector>
#include <cmath>
#include <string>
#include <algorithm>
#include <iomanip>
#include <map>
#include <bitset>
#include <cstdio>
#include <set>
#include <stack>
#include <queue>
//#include <bits/stdc++.h>
#define rep(i,n) Rep(i,0,n)
#define Rep(i,k,n) for(int i=k ; i<n ; i++)
#define rep1(i,n) for(int i=1 ; i<=n ; i++)
#define vi vector<int>
#define vii vector<int,int>
#define Sort(v) sort(v.begin(),v.end())
#define Reverse(v) reverse(v.begin(),v.end())

//const int MOD = 1000000007;
//const int INF = 1<<30;
using namespace std;

string yn(bool x){
    return x ? "Yes" : "No";
}

int calc(int x,int y,string s){
    if(s == "+") return x+y;
    if(s == "-") return x-y;
    if(s == "*") return x*y;
    return 0;
}

int main(){
    queue<pair<string,int>> que;
    int ans = 0;
    int n,q; cin >> n >> q;
    
    string name;int time;
    rep(i,n){
        cin >> name >> time;
        que.push(make_pair(name, time));
    }
    while(!que.empty()){
        pair<string,int> top = que.front();
        que.pop();
        
        if(top.second<=q){
            ans += top.second;
            cout << top.first << " " << ans << endl;
        }else{
            
            ans += q;
            que.push(make_pair(top.first, top.second-q));
        }
    }
    
    
}




Measured memory_bytes: 6216
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <math.h>
using namespace std;
int main(){
    long long n,m,x,y,z,i,j,k,a,b,c;
    scanf("%lld%lld%lld%lld%lld",&a,&b,&c,&x,&y);
    i=a*x+b*y;
    if(x<y)j=2*x*c+b*(y-x);
    if(x>=y)j=2*y*c+a*(x-y);
    k=2*c*max(x,y);
    if(j<i)i=j;
    if(k<i)i=k;
    printf("%lld\n",i);
}

Measured memory_bytes: 256
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
#include <queue>

using namespace std;

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

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

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);

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

  int N, L;
  while(cin>>N>>L, N){
	VI d(N), p(N), gp[2];
	REP(i,N){
	  char ch; cin >> ch >> p[i];
	  d[i] = (ch == 'R'? 1: -1);
	  gp[p[i]%2].PB(i);
	}

	int id[2] = {0,0}, ans_t[2] = {0,0};
	for(int g=0;g<2;++g){
	  bool up = true;
	  for(;up;++ans_t[g]){
		up = false;
		for(int i=SZ(gp[g])-1;i>=0;--i){
		  int idx = gp[g][i];
		  int tx = p[idx] + d[idx];
		  if(tx < 0 || tx > L) continue;
		  if(tx == 0 || tx == L){
			p[idx] = tx;
			id[g] = (idx+1) * d[idx];
			continue;
		  }

		  up = true;
		  if(i > 0){
			int pidx = gp[g][i-1];
			if(p[pidx]+2 == p[idx] && d[pidx] == 1 && d[idx] == -1){
			  p[idx]--; d[idx] *= -1;
			  p[pidx]++; d[pidx] *= -1;
			  --i;
			  continue;
			}
		  }
		  p[idx] = tx;
		}
	  }
	}
	if(ans_t[0] < ans_t[1] || (ans_t[0] == ans_t[1] && id[1] < 0))
	  cout << ans_t[1] << " " << abs(id[1]) << endl;
	else
	  cout << ans_t[0] << " " << abs(id[0]) << endl;
  }
  
  return 0;
}

Measured memory_bytes: 1228
# -*- coding: utf-8 -*-
import sys
import math
import os
import itertools
import string
import heapq
import _collections
from collections import Counter
from collections import defaultdict
from collections import deque
from functools import lru_cache
import bisect
import re
import queue
import decimal


class Scanner():
    @staticmethod
    def int():
        return int(sys.stdin.readline().rstrip())

    @staticmethod
    def string():
        return sys.stdin.readline().rstrip()

    @staticmethod
    def map_int():
        return [int(x) for x in Scanner.string().split()]

    @staticmethod
    def string_list(n):
        return [Scanner.string() for i in range(n)]

    @staticmethod
    def int_list_list(n):
        return [Scanner.map_int() for i in range(n)]

    @staticmethod
    def int_cols_list(n):
        return [Scanner.int() for i in range(n)]


class Math():
    @staticmethod
    def gcd(a, b):
        if b == 0:
            return a
        return Math.gcd(b, a % b)

    @staticmethod
    def lcm(a, b):
        return (a * b) // Math.gcd(a, b)

    @staticmethod
    def divisor(n):
        res = []
        i = 1
        for i in range(1, int(n ** 0.5) + 1):
            if n % i == 0:
                res.append(i)
                if i != n // i:
                    res.append(n // i)
        return res

    @staticmethod
    def round_up(a, b):
        return -(-a // b)

    @staticmethod
    def is_prime(n):
        if n < 2:
            return False
        if n == 2:
            return True
        if n % 2 == 0:
            return False
        d = int(n ** 0.5) + 1
        for i in range(3, d + 1, 2):
            if n % i == 0:
                return False
        return True

    @staticmethod
    def fact(N):
        res = {}
        tmp = N
        for i in range(2, int(N ** 0.5 + 1) + 1):
            cnt = 0
            while tmp % i == 0:
                cnt += 1
                tmp //= i
            if cnt > 0:
                res[i] = cnt
        if tmp != 1:
            res[tmp] = 1
        if res == {}:
            res[N] = 1
        return res


def pop_count(x):
    x = x - ((x >> 1) & 0x5555555555555555)
    x = (x & 0x3333333333333333) + ((x >> 2) & 0x3333333333333333)
    x = (x + (x >> 4)) & 0x0f0f0f0f0f0f0f0f
    x = x + (x >> 8)
    x = x + (x >> 16)
    x = x + (x >> 32)
    return x & 0x0000007f


MOD = int(1e09) + 7
INF = int(1e15)


def solve():
    N = Scanner.int()
    A = Scanner.map_int()
    ans = 0
    for i in range(61):
        p = 1
        for _ in range(i):
            p *= 2
            p %= MOD
        x = 0
        for a in A:
            if a >> i & 1:
                x += 1
        t = x * (N - x)
        t %= MOD
        t *= p
        t %= MOD
        ans += t
        ans %= MOD
    print(ans)


def main():
    # sys.stdin = open("sample.txt")
    # T = Scanner.int()
    # for _ in range(T):
    #     solve()
    # print('YNeos'[not solve()::2])
    solve()


if __name__ == "__main__":
    main()


Measured memory_bytes: 52332
#include<iostream>

void insertionSort(int A[],int N){
  int v,j;
  for(int i=1;i<=N-1;i++){
    v=A[i];
    j=i-1;
    while(j>=0 and A[j]>v){
      A[j+1]=A[j];
      j--;
      A[j+1]=v;
    }
  }
}

int main(){
  int N;
  std::cin>>N;
  int a[N]={0};
  for(int i=0;i<N;i++){
    std::cin>>a[i];
  }
  for(int j=1;j<=N;j++){
    insertionSort(a,j);
    for(int k=0;k<N-1;k++){
      std::cout<<a[k]<<" ";
    }
    std::cout<<a[N-1];
    std::cout<<'\n';
  }
  
  return 0;
}


Measured memory_bytes: 3088
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <list>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <numeric>
#include <deque>

#define dump(x) cerr << #x << "=" << (x) << endl;
using namespace std;
using ll = long long;

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define IN(x) int (x); cin >> x
#define INS(x) string (s); cin >> s
#define INL(x) ll (x); cin >> x
#define VINT(a,n) vector<int> a(n)
#define VIN(a,n) VINT(a,n); REP(i,n){cin >> a[i];}
#define ALL(x) (x).begin(),(x).end()

int main () {
  IN(n);
  IN(d);
  vector<vector<int> > x(n);
  int temp;
  REP(i,n){
    REP(j,d){
      cin>>temp;
      x[i].push_back(temp);
    }
  }
  int count = 0;
  int sum;
  REP(i,n){
    REP(j,n-i-1){
      sum=0;
      REP(k,d){
	sum+=(x[i][k]-x[n-j-1][k])*(x[i][k]-x[n-j-1][k]);
      }
      int a = (int)sqrt((double)sum);
      if (a*a == sum){
	count++;
      }
    }
  }
  cout<<count;
}


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

int main() {
  int X,A,B;
  cin>>X>>A>>B;
  if(A>=B)puts("delicious");
  else if(B-A>X)puts("dangerous");
  else puts("safe");
  
  return 0;
}

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

#define ll long long
#define INF 99999999
#define rep(i,n) for(int i=0,temp=(int)(n);i<temp;++i) //vec.size()がnの時等の高速化
#define loop(i,start,end) for(int i=start,temp=(int)(end);i<end;++i)
#define rfor(v,x) for(const auto& x : v) //xは値を表す
#define all(x) (x).begin(),(x).end()
#define SORT(v, n) sort(v, v+n)
#define vsort(v) sort(v.begin(), v.end())
#define vfsort(v,lambda) sort(v.begin(),v.end(),lambda)
#define vint vector<int>
#define vvint vector<vector<int>>
#define vin(v) rep(i,v.size()) {cin >> v[i];}

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int ctoi(char c) {return c-'0';}
//(lambda (x y) (< x y)) => [](int x, int y) -> int { return x<y; }

int main(){
  int h,w;cin >> h >> w;
  vector<vector<char>> a(h);
  rep(i,h) a[i].resize(w);
  rep(i,h)
    rep(j,w) cin >> a[i][j];

  rep(i,h){
    bool flag=true;
    rep(j,w) flag &= a[i][j]=='.';
    if(flag){
      rep(j,w) a[i][j] = '-';
    }
  }

  rep(j,w){
    bool flag=true;
    rep(i,h) flag &= a[i][j]=='.' || a[i][j]=='-' ;
    if(flag){
      rep(i,h) a[i][j] = '-';
    }
  }

  rep(i,h){
    bool p=true;
    rep(j,w){
      if(a[i][j]=='-'){
        p&=true;
        continue;
      }
      p=false;
      cout << a[i][j];
    }
    if(!p) cout << endl;
  }

  return 0;
}


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

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

int main(){
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	cout<<setprecision(32);

	int k; string s;
	cin>>k>>s;
	if(s.size() <= k){
		cout<<s<<endl;
	}else{
		cout<<s.substr(0, k)<<"..."<<endl;
	}

	return 0;
}

Measured memory_bytes: 3640
#include<cstdio>
#include<iostream>
#include<string>
#include<cstring>
#include<vector>
#include<map>
#define INF 100000000
using namespace std;
int main(){
	int n;
	while(cin >> n,n){
		map<string,int> list;
		for(int i = 0; i < n; i++){
            string d;int a;
            cin >> d >> a;
            list[d] = a;
		}
		int m;
		cin >> m;
		for(int i = 0; i < m; i++){
            string d;int a;
            cin >> d >> a;
            int m = 0;
            for(int j = 0; j < a; j++){
                string dm;
                cin >> dm;
                m += list[dm];
            }
            list[d] = min(list[d],m);
		}
		string ans;
		cin >> ans;
		cout << list[ans] << endl;
	}
	return 0;
}

Measured memory_bytes: 1224
#include<cstdio>
using namespace std;
int main(void)
{
	int n,sum,i,j,nn,cnt;
	while(1)	{
		scanf("%d",&n);
		if(n==0)	break;
		cnt=0;
		for(i=1;i<=n/2;i++)	{
			sum=i;
			j=i+1;
			while(sum<n)	{
				sum+=j;
				if(sum==n)	cnt++;
				j++;
			}
		}
		printf("%d\n",cnt);
	}
	return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define FOR(i, a, b) for(int i = (int)a; i <= (int)b; i++)

vector<int> v;
int n, a, b, ans;
bool same = true;

int32_t main() {
	cin >> n;
	FOR(i, 1, n) {
		cin >> a >> b;
		ans += b;
		if (a != b) same = false;
		if (a > b) v.push_back(b);
	}
	if (same) cout << 0;
	else if (v.empty()) cout << ans;
	else cout << ans - (*min_element(v.begin(), v.end()));
}


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

int main(){
  int a,b=0;
  cin >> a;
  b = b + a / 100;
  a = a % 100;
  b = b + a / 10;
  a = a % 10;
  b = b + a;
  cout << b << endl;
}

Measured memory_bytes: 256
x = int(input())

s = []
for i in range(300):
    j = i ** 5
    s.append(j)
    s.append(-1*j)

for a in s:
    for b in s:
        ans = a - b
        if ans == x:
            if a >= 0:
                aa = int(a ** (1/5))
            else:
                aa = int(abs(a) ** (1/5)) * -1
            if b >= 0:
                bb = int(b ** (1/5))
            else:
                bb = int(abs(b) ** (1/5)) * -1
            print(aa,bb)
            exit()


Measured memory_bytes: 9356
#include<iostream>
#include<string>
#include<vector>
#include<cmath>
#include<algorithm>

using namespace std;

int main()
{
    int X,N;
    cin>>X>>N;
    vector<int>p(N);
    int check;
    for(int i=0;i<N;i++){
        cin>>p[i];
    }
    if(N==0){
        cout<<endl;
        cout<<X<<endl;
        exit(0);
    }
    sort(p.begin(),p.end());
    bool ans=true;
    for(int i=0;i<N;i++){
        if(p[i]==X){
            ans=false;
            check=i;
        }
    }
    if(ans){
        cout<<X<<endl;
        exit(0);
    }
    int ans1=X+1,ans2=X-1;
    for(int i=check;i<N-1;i++){
        if(p[i]+1!=p[i+1]){
            ans1=p[i]+1;
            break;
        }
        if(N-2){
            ans1=p[i+1]+1;
        }
    }
    for(int i=check;i>=1;i--){
        if(p[i]!=p[i-1]+1){
            ans2=p[i]-1;
            break;
        }
        if(i==1){
            ans2=p[i-1]-1;
        }
    }
//    cout<<min(abs(X-ans1),abs(X-ans2))<<endl;
    if(abs(X-ans1)>abs(X-ans2)){
        cout<<X-abs(X-ans2)<<endl;
    }else if(abs(X-ans1)<abs(X-ans2)){
         cout<<X+abs(X-ans1)<<endl;
    }else{
        cout<<min(X-abs(X-ans2),X+abs(X-ans1));
    }

}

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

#define INF (LLONG_MAX/2)
#define MAX_N 1001

struct Edge {
    int src;
    int dst;
    long long weight;
};

struct Graph {
    int n;
    vector<vector<Edge> > adjlist;
    vector<long long> dist;

    Graph(int n): n(n), adjlist(vector<vector<Edge> >(n)), dist(vector<long long>(n)) {}

    void add_edge(int a, int b, long long c) {
        this->adjlist[a].push_back( Edge{a,b,c} );
    }
    bool bellman_ford(int s) {
        for (int i=0; i<this->n; i++) this->dist[i] = INF;
        this->dist[s] = 0;

        for (int i=0; i<this->n; i++) {
            for (int v=0; v<this->n; v++) {
                for (const auto e: this->adjlist[v]) {
                    if (this->dist[v] != INF && this->dist[e.dst] > this->dist[v] + e.weight) {
                        this->dist[e.dst] = this->dist[v] + e.weight;
                        if (i == this->n-1 && e.dst == this->n-1) {
                            return true;
                        }
                    }
                }
            }
        }
        return false;
    }
};

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

    Graph g(N);

    for (int i=0; i<M; i++) {
        int a,b,c;
        cin >> a >> b >> c;
        g.add_edge(a-1, b-1, -c);
    }

    bool loop = g.bellman_ford(0);
    
    if (loop) {
        cout << "inf" << endl;
    } else {
        cout << -1 * g.dist[N-1] << endl;
    }

    return 0;
}


Measured memory_bytes: 384
// C.cpp : このファイルには 'main' 関数が含まれています。プログラム実行の開始と終了がそこで行われます。
//

#include <iostream>
#include<algorithm>
using namespace std;

int a[200005], sa[200005];
int main()
{
    int n;

    
    int max=0;
    int prev = 0;
    cin >> n;

    for (int i = 0; i < n; i++) {
        cin >> a[i];
        sa[i] = a[i];
        //if (max <= a[i]) {
        //    prev = max;
        //    max = a[i];
        //}
    }
    sort(sa, sa + n);

    for (int i = 0; i < n; i++) {
        if (a[i] == sa[n-1]) {
            cout << sa[n-2]<< endl;
        }
        else {
            cout << sa[n-1] << endl;
        }
    }

    return 0;
}




Measured memory_bytes: 5188