akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
using namespace std;
int main()
{
    int a,b,c;
    cin>>a>>b>>c;
    if(c>a+b)
    {
        cout<<"dangerous"<<endl;
    }
    else if(c<=b)
    {
        cout<<"delicious"<<endl;
    }
    else
    {
        cout<<"safe"<<endl;
    }
    return 0;
}


Measured memory_bytes: 3612
#include<iostream>
#include<math.h>
#include<string>
using namespace std;

int main(){
    int n, a[100005];
    int sum=0;

    a[0]=0;
    cin>>n;
    for(int i=1;i<=n;i++){
        cin>>a[i];
        sum+=abs(a[i-1]-a[i]);
    }
    a[n+1]=0;
    sum+=abs(a[n]);

    for(int i=1;i<=n;i++){
        int ans=sum-abs(a[i]-a[i-1])-abs(a[i]-a[i+1])+abs(a[i+1]-a[i-1]);
        cout<<ans<<endl;
    }
}

Measured memory_bytes: 1664
#include<bits/stdc++.h>
using namespace std;
int n;
int t;
char a[1500][1500];
char p[5][10][10] = {
    {"aabc","ddbc","bcaa","bcdd"},
    {"aabbc","dcc.c","d..cd","c..cd","cbbaa"},
    {"aabcc.","b.b..c","baa..c","cc.aab","..cb.b","..cbaa"},
    {"aabbaa.","cc.dd.a","..c..da","..c..db","cc.dd.b","..c..da","..c..da"}};
void append(int k) {
    if(k==4) {
        for(int i=0;i<t;i++) {
            a[t][i]=a[t+1][i]=a[t+2][i]=a[t+3][i]='.';
        }
        for(int i=t+k;i<n+t;i++) {
            a[t][i]=a[t+1][i]=a[t+2][i]=a[t+3][i]='.';
        }
        for(int i=0;i<k;i++) {
            for(int j=0;j<k;j++) {
                a[t+i][t+j]=p[0][i][j];
            }
        }
    }
    else {
        if(k==5) {
            for(int i=0;i<t;i++) {
                a[t][i]=a[t+1][i]=a[t+2][i]=a[t+3][i]=a[t+4][i]='.';
            }
            for(int i=t+k;i<n+t;i++) {
                a[t][i]=a[t+1][i]=a[t+2][i]=a[t+3][i]=a[t+4][i]='.';
            }
            for(int i=0;i<k;i++) {
                for(int j=0;j<k;j++) {
                    a[t+i][t+j]=p[1][i][j];
                }
            }
        }
        else {
            if(k==6) {
                for(int i=0;i<t;i++) {
                    a[t][i]=a[t+1][i]=a[t+2][i]=a[t+3][i]=a[t+4][i]=a[t+5][i]='.';
                }
                for(int i=t+k;i<n+t;i++) {
                    a[t][i]=a[t+1][i]=a[t+2][i]=a[t+3][i]=a[t+4][i]=a[t+5][i]='.';
                }
                for(int i=0;i<k;i++) {
                    for(int j=0;j<k;j++) {
                        a[t+i][t+j]=p[2][i][j];
                    }
                }
            }
            else {
                for(int i=0;i<t;i++) {
                    a[t][i]=a[t+1][i]=a[t+2][i]=a[t+3][i]=a[t+4][i]=a[t+5][i]=a[t+6][i]='.';
                }
                for(int i=t+k;i<n+t;i++) {
                    a[t][i]=a[t+1][i]=a[t+2][i]=a[t+3][i]=a[t+4][i]=a[t+5][i]=a[t+6][i]='.';
                }
                for(int i=0;i<k;i++) {
                    for(int j=0;j<k;j++) {
                        a[t+i][t+j]=p[3][i][j];
                    }
                }
            }
        }
    }
}
int main() {
    scanf("%d",&n);
    if(n==2) {
        printf("-1");
        return 0;
    }
    if(n==3) {
        printf("cc.\n..c\n..c\n");
        return 0;
    }
    while(n>=8) {
        append(4);
        n-=4;
        t+=4;
    }
    append(n);
    t+=n;
    n-=n;
    for(int i=0;i<t;i++) {
        for(int j=0;j<t;j++) printf("%c",a[i][j]);
        printf("\n");
    }
    return 0;
}


Measured memory_bytes: 2688
#include<bits/stdc++.h>
#define ll long long int
#define ld long double
#define pi pair<int,int>
#define all(x) x.begin(), x.end()
#define allr(x) x.rbegin(), x.rend()
#define sz(x) ((int)x.size())
#define ln(x) ((int)x.length())
#define mp make_pair
#define pb push_back
#define ff first
#define ss second
#define endl '\n'
#define dbg(x) cout<<#x<<" "<<x<<endl
#define clr(x,v) memset(x, v, sizeof(x))
#define FASTIO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using namespace std;
const double eps = 1e-9;
const double PI = acos(-1.0);
const ll mod = 1e9 + 7;
const int MAXN = 1e6 + 5;

void cp()
{
	string s,t;
	cin>>s>>t;
	int op=0;
	for(int i=0;i<ln(s);i++)
	{
		if(s[i] != t[i])
			op++;
	}
	cout<<op;
}

int main()
{
    FASTIO;
    int t;
    t = 1;
    // cin >> t;
    while(t--)
    {
        cp();
    }
    return 0;
}

Measured memory_bytes: 3796
#include<string>
#include<iostream>
#include <algorithm>
#include<vector>
#include<functional>
#include <cstdlib>
#include <iomanip>
#include <cmath>
#include <numeric>
#define ll long long
#define rep(i,n) for(ll i=0;i<(ll)n;i++)
using namespace std;



int main() {
    ll a, b;
    ll ans;
    cin >> a >> b;
    ans = a * b;
    if (ans % 2 == 0) cout << "Even" << endl;
    else cout << "Odd" << endl;
    

    return 0;
}

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

int main()
{
  char s[19]={};
  
  scanf("%s",s);
  
  int i;
  
  for(i=0;i<strlen(s);i++)
  {
    if(i==5||i==13)
    {
      printf(" ");
    }
    else
    {
    printf("%c",s[i]);
    }
  }
  return 0;
}
    

Measured memory_bytes: 128
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <algorithm>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
using namespace std;
 
#define clr(x, y) memset(x, y, sizeof(x))
#define forn(i, n) for(int i = 0; i < n; i++)
#define LL long long
const int mod = 1e9 + 7;
const int inf = 1e9;


int n;
map<string, int> mp;
int main() {
    //freopen("in", "r", stdin);
    scanf("%d", &n); 
    int maxx = 0;
    for(int i = 0; i < n; i++) {
        string s;
        cin >> s;
        mp[s] += 1;
        maxx = max(maxx, mp[s]);
    }
    vector<string> ans;
    for(auto iter: mp) {
        if(iter.second == maxx) {
            ans.push_back(iter.first);
        }
    }
    sort(ans.begin(), ans.end());
    for(auto s: ans) {
        cout << s << endl;
    }
    return 0;
}

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

int main(){

	int i, j, q, a, b, p[1000];
	char str[10000] = {0}, rgst[10000] = {0};
	
	scanf("%s", str);
	scanf("%d", &q);
	for(i = 0; i < q; i++){
		char order[1000] = {0}, p[1000] = {0};
		scanf("%s", order);
		if(strcmp(order, "replace") == 0){
			scanf("%d %d %s", &a, &b, p);
			for(j = 0; j < b - a + 1; j++){
				str[a + j] = p[j];
			}
		} else if(strcmp(order, "reverse") == 0){
			scanf("%d %d", &a, &b);
			for(j = 0; j < b - a + 1; j++){
				rgst[a + j] = str[a + j];
			}
			for(j = 0; j < b - a + 1; j++){
				str[a + j] = rgst[b - j];
			}
		} else if(strcmp(order, "print") == 0){
			scanf("%d %d", &a, &b);
			for(j = 0; j < b - a + 1; j++){
				printf("%c", str[a + j]);
			}
			printf("\n");
		}





	}

	return 0;
}

Measured memory_bytes: 600
#include<bits/stdc++.h> 
#define ll                 long long                            
#define ra                 return a;                                          
#define pb                 push_back                                                     
#define sti                stack<ll>
#define spi                stack<pair<ll,ll>>
#define S                  second
#define msi                map<string,ll >
#define msi                map<string,ll >
#define mii                map<ll ,ll >
#define dbg(x)             { cerr<<#x<<": "<<x<< endl; }
#define dbg2(x,y)          { cerr<<#x<<": "<<x<<" , "<<#y<<": "<<y<<endl; }
#define dbg3(x,y,z)        { cerr<<#x<<": "<<x<<" , "<<#y<<": "<<y<<" , "<<#z<<": "<<z<<endl; }
#define mis                map<ll , string>
#define rep(i,a,b)         for(ll  i=a;i<b;i++)
#define mpi                map<pair<ll ,ll >,ll >                                                
#define pii                pair<ll ,ll >
#define ppb                pop_back
#define F                  first 
#define vi                 vector<ll >
#define vii                vector<pair<ll , ll >>
#define si                 set <ll>
#define vs                 vector<string>
#define all(a)             (a).begin(),(a).end()
#define sz(x)              (ll )x.size()
#define hell               1000000007
#define bs                 binary_search
#define mp                 make_pair
#define qi                 queue<ll>
#define qs                 queue<string>
#define qpi                queue<pair<ll,ll>>
#define qps                queue<pair<ll,string>> 
#define endl               '\n' 
#define itr(a,it)          for(typeof(a.begin()) it=a.begin();it!=a.end();it++)// This will produce const_iterator for const object and normal iterator for non-const object
#define ss                 set<string>
using namespace std;
#define N  300005
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    ll t=1;
//    cin>>t;
    while(t--)
{
    string s;
    cin>>s;
    ll key=0;
    rep(i,0,3)
    {
    	if(s[i]==s[i+1])key=1;
    }
    if(key)
    {
    	cout<<"Bad";
    }
    else cout<<"Good";
}
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#define MAX 2000000

int size, A[MAX+1];

void maxHeapify(int i){
  int l, r, largest, t;
  l = 2*i;
  r = 2*i+1;
  if ( l <= size && A[l] > A[i] ) largest = l;
  else largest = i;
  if ( r <= size && A[r] > A[largest] ) largest = r;
  if ( largest != i ){
    t = A[i]; A[i] = A[largest]; A[largest] = t;
    maxHeapify(largest);
  }
}

int extract(){
  int maxv;
  if ( size < 1 ) return;
  maxv = A[1];
  A[1] = A[size--];
  maxHeapify(1);
  return maxv;
}

void increaseKey(int i, int key){
  int tmp;
  if ( key < A[i] ) return;
  A[i] = key;
  while ( i > 1 && A[i/2] < A[i] ){
    tmp = A[i];
    A[i] = A[i/2];
    A[i/2] = tmp;
    i = i/2;
  }
}

void insert(int key){
  size++;
  A[size] = -1000000001;
  increaseKey(size, key);
}

main(){
  int key;
  char com[20];
  int a=0;
  a=kansu(a);
  if(a == 0){
  while(1){
    scanf("%s", com);
    if ( com[0] == 'i' ){
      scanf("%d", &key);
      insert(key);
    } else if ( strcmp(com, "extract") == 0  ){
      printf("%d\n", extract());
    } else break;
  }
  
  return 0;
}}
void kansu(int a){
 int b=0,c=1;
 if(b == 0);
  if(c == 1);
   return a;
}


Measured memory_bytes: 5604
from __future__ import (division, absolute_import, print_function,
                        unicode_literals)
from sys import stdin

rectangle = diamond = 0
for line in stdin:
    try:
        a, b, c = (int(s) for s in line.split(','))
    except ValueError:
        break
    diamond += a == b
    rectangle += a ** 2 + b ** 2 == c ** 2
print(rectangle, diamond, sep='\n')

Measured memory_bytes: 4264
#include<cstdio>
#include<vector>
#include<algorithm>
#include<utility>
#include<numeric>
#include<iostream>
#include<array>
#include<string>
#include<sstream>
#include<stack>
#include<queue>
#include<list>
#define _USE_MATH_DEFINES

#include<math.h>
#include<map>

#define SENTINEL 1000000001

#define min(a,b) (a)>(b)?(b):(a)
#define max(a,b) (a)>(b)?(a):(b)

using namespace std;

int G[101][101];
int d[101];
int f[101];
bool checked[101];

void explore(int id, int n,int& t)
{
	if (checked[id])
	{
		return;
	}
	checked[id] = true;
	d[id] = t;
	t++;

	for (int i = 1; i <= n; i++)
	{
		if (G[id][i] == 1)
		{
			explore(i, n,t);
		}
	}

	f[id] = t;
	t++;
}

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

	for (int i = 0; i < n; i++)
	{
		int id, k;
		cin >> id >> k;

		for (int i = 0; i < k; i++)
		{
			int v;
			cin >> v;
			G[id][v] = 1;
		}
	}

	int t = 1;
	for (int i = 1; i <= n; i++)
	{
		if (!checked[i])
		{
			explore(i, n, t);
		}
	}

	for (int i = 1; i <= n; i++)
	{
		printf("%d %d %d\n", i, d[i], f[i]);
	}

	return 0;
}


Measured memory_bytes: 3232
n, k = map(int,input().split())
A = list(map(int,input().split()))

pos = 0
neg = 0

for a in A[:k]:
  if a>0:
    pos += a
  else:
    neg += a
  
wp = pos
wn = neg
ans = float('inf')
for i,a in enumerate(A[k:]):
  if a>0:
    pos += a
    wp += a
  else:
    neg += a
    wn += a
  b = A[i]
  if b>0:
    wp -= b
  else:
    wn -= b
  ans = min(ans, wp, -wn)
print(max(pos - ans, pos+neg, 0))

Measured memory_bytes: 66848
import heapq
N, M = map(int, input().split())
hq = []
for price in map(int, input().split()):
    heapq.heappush(hq, -price)

for i in range(M):
    p = -heapq.heappop(hq)
    p /= 2
    heapq.heappush(hq, -p)

result = -sum([int(p) for p in hq])
print(result)


Measured memory_bytes: 20392
N = int(input())
S=[]

for n in range(N):
    s=input()
    S.append(s)
S_set=set(S)

ans='Yes'
if len(S_set) != N:
    ans='No'

for n in range(N-1):
    n_ = n+1
    s_0=S[n][-1]
    s_1=S[n_][0]
    
    if s_0 != s_1:
        ans='No'
print(ans)

Measured memory_bytes: 62484
#include <iostream>
#include <string>
#include <vector>
#include <utility>
#include <algorithm>

using namespace std;
typedef long long ll;

typedef pair<pair<string, int>, int> T;

bool mycomp(T l, T r)
{
    if (l.first.first == r.first.first) {
        return l.first.second > r.first.second;
    }
    return l.first.first < r.first.first;
}

int main()
{
    int n;
    cin >> n;
    vector<T> shops(n);

    for (int i = 0; i < n; i++) {
        cin >> shops[i].first.first;
        cin >> shops[i].first.second;
        shops[i].second = i + 1;        
    }

    sort(shops.begin(), shops.end(), mycomp);

    for (int i = 0; i < n; i++) {
        cout << shops[i].second << endl;
    }

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long int ld;
int main()
{
    int n,i,j;
    cin>>n;
    ld dp[n],h[n];
    for(i=0;i<n;i++)
        cin>>h[i];
    dp[0]=0;
    dp[1]=abs(h[1]-h[0]);
    for(i=2;i<n;i++)
    {
        if((dp[i-2]+abs(h[i]-h[i-2]))<(dp[i-1]+abs(h[i]-h[i-1])))
            dp[i]=dp[i-2]+abs(h[i]-h[i-2]);
        else
            dp[i]=dp[i-1]+abs(h[i]-h[i-1]);
    }
    cout<<dp[n-1];
    return 0;
}

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

int main(void) {
    char a[17]="CODEFESTIVAL2016",b[17];
    scanf("%s",b);
    int i,ans=0;
    for(i=0;i<=16;i++){
        if(a[i]!=b[i]){
            ans+=1;
        }
    }
    printf("%d",ans);
    
    
    return 0;
    
}


Measured memory_bytes: 128
#include  <bits/stdc++.h>
using namespace std;
static int fast_io = []() { std::ios::sync_with_stdio(false); cin.tie(nullptr); return 0; }();
int main(){
  unordered_map<string,int> map;
  int a;
  string tmp;
  cin>>a;
  for(int i = 0;i<a;i++){
    cin>>tmp;
    map[tmp]++;
  }
  cout<<map.size()<<"\n";  
  return 0;
}

Measured memory_bytes: 17624
#include <bits/stdc++.h>
#define  rep(i,n) for(li i = 0; i < (n); ++i)
#define  red(i,n) for(li i = (n)-1; i >= 0; --i)
#define  all(a)   begin(a),end(a)
#define  pb(a)    push_back(a) 
using namespace std;
using li = long long;
using ul = unsigned long long;
using vi = vector<li>;
using vs = vector<string>;
inline ul gcd(ul a,ul b) { return b?gcd(b,a%b):a; }
const int INF=1000000009;


int main()
{
    int a,b;
    cin>>a>>b;
    char c;
    rep(i,a){
        cin>>c;
        if(c>='0'&&c<='9');else cout<<"No\n",exit(0);
    }
    cin>>c;
    if(c!='-') cout<<"No\n",exit(0);
    rep(i,b){
        cin>>c;
        if(c>='0'&&c<='9');else cout<<"No\n",exit(0);
    }
    cout<<"Yes\n";
    return 0;
}



Measured memory_bytes: 256
from collections import Counter, deque, defaultdict
from operator import itemgetter, xor, mul

import sys
#input = sys.stdin.readline
from sys import setrecursionlimit
setrecursionlimit(10**9)

def inpl(): return list(map(int, input().split()))
g0 = itemgetter(0)
N = int(input())
X, Y = [0]*N, [0]*N
P = []
for i in range(N):
    P.append(inpl())
P = sorted(P)
for i in range(N):
    X[i], Y[i] = P[i]

U = [(X[i]-X[j], Y[i] - Y[j])for i in range(N) for j in range(N) if i != j]
D = defaultdict(int)
for i in range(N):
    D[(X[i], Y[i])] = i+1

ans = N
for ux, uy in U:
    if ux < 0:
        continue
    tmp = 0
    searched = [0]*(N)
    for i in range(N):
        if not searched[i]:
            tmp += 1
            searched[i] = 1
        j = D[(X[i]+ux), (Y[i]+uy)]
        if j:
            searched[j-1] = 1
    ans = min(tmp, ans)
print(ans)


Measured memory_bytes: 10476
#include <iostream>
using namespace std;
int main(){
    long long n;
    cin >> n;
    long long a[n+1];
    for (int i=0; i<n; i++){
        cin >> a[i];
    }
    a[n]=a[0];
    long long d[n];
    for (int i=0; i<n; i++){
        d[i]=a[i+1]-a[i];
    }
    long long k=(n*(n+1))/2;
    long long j=0;
    for (int i=0; i<n; i++){
        j+=a[i];
    }
    if (j%k){
        cout <<"NO" << endl;
        exit(0);
    }
    long long l=j/k;
    for (int i=0; i<n; i++){
        if (d[i]>l || (l-d[i])%n!=0){
            cout << "NO" << endl;
            exit(0);
        }
    }
    cout << "YES" << endl;
}

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

/* 0-indexed, [0, n) */
template<typename Monoid, typename Effect> class SegmentTree {
public:
  typedef function<Monoid (Monoid, Monoid)> Operator;
  typedef function<Monoid (Monoid, Effect)> Apply;

private:
  vector<Monoid> dat;
  ll n;        // size of elements (2^x alignment)
  Monoid e;    // identity of monoid
  Operator op; // binary operator of monoid
  Apply apply; // apply effect to monoid

public:
  SegmentTree(ll _n, Monoid e, Operator op, Apply apply): e(e), op(op), apply(apply) {
    for(n = 1; n < _n; n *= 2);
    dat.resize(n * 2 - 1, e);
  }

  // query for [a, b)
  Monoid query(ll a, ll b) { return query(a, b, 0, 0, n); }
  Monoid query(ll a, ll b, ll k, ll l, ll r) {
    if(r <= a || b <= l) return e;
    if(a <= l && r <= b) return dat[k];
    Monoid vl = query(a, b, k * 2 + 1, l, (l + r) / 2);
    Monoid vr = query(a, b, k * 2 + 2, (l + r) / 2, r);
    return op(vl, vr);
  }

  // update value at k
  void update(ll k, Effect x) {
    k += n - 1;
    dat[k] = apply(dat[k], x);
    while(k > 0) {
      k = (k - 1) / 2;
      dat[k] = op(dat[k * 2 + 1], dat[k * 2 + 2]);
    }
  }

  friend ostream& operator<<(ostream& os, const SegmentTree& segtree) {
    os << "SegmentTree: size = " << segtree.n << endl;
    function<void (ll, ll)> dfs = [&](ll k, ll d) {
      if(k >= segtree.dat.size()) return;
      dfs(k * 2 + 1, d + 1);
      REP(i, 0, d) os << "  ";
      os << segtree.dat[k];
      if(k >= segtree.n - 1) os << " : #" << (k - (segtree.n - 1));
      if(k + 1 != segtree.dat.size()) os << endl;
      dfs(k * 2 + 2, d + 1);
    };
    dfs(0, 0);
    return os;
  }
};

int main(void) {
  const ll INF = 2147483647;

  ll N, Q;
  cin >> N >> Q;
  vector<ll> C(Q), X(Q), Y(Q);
  REP(i, 0, Q) cin >> C[i] >> X[i] >> Y[i];

  SegmentTree<ll, ll>::Operator op = [](ll a, ll b) { return min(a, b); };
  SegmentTree<ll, ll>::Apply apply = [](ll a, ll x) { return x; };
  SegmentTree<ll, ll> segtree(N, INF, op, apply);

  REP(i, 0, Q) {
    if(C[i] == 0) segtree.update(X[i], Y[i]);
    if(C[i] == 1) cout << segtree.query(X[i], Y[i] + 1) << endl;
  }

  // segtree.update(0, 5);
  // segtree.update(1, 7);
  // segtree.update(2, 3);
  // segtree.update(3, 8);
  // assert(segtree.query(0, 4) == 3);
  // assert(segtree.query(3, 4) == 8);
  // assert(segtree.query(2, 4) == 3);
  // assert(segtree.query(0, 2) == 5);
  // assert(segtree.query(1, 2) == 7);
  // segtree.update(2, 4);
  // assert(segtree.query(0, 4) == 4);
  //
  // cout << segtree << endl;
}



Measured memory_bytes: 7348
n,m = gets.chomp.split().map(&:to_i)
a = gets.chomp.split().map(&:to_i)
a.sort!

bc = []
m.times do
  bc.push gets.chomp.split().map(&:to_i)
end

bc.sort_by!{|b,c| -c}
ans = []
a.each do |e|
  if bc.empty?
    ans.push e
  else
    b, c = bc[0]
    if c <= e
      bc = []
      ans.push e
    else
      ans.push c
      b -= 1
      if b == 0
        bc.shift
      else
        bc[0] = [b, c]
      end
    end
  end
end

puts ans.inject(:+)


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

#ifdef LOCAL
#include <debug.hpp>
#else
#define debug(...) void()
#endif

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int h, w;
  cin >> h >> w;
  vector<string> a(h);
  for (auto&& e : a) {
    cin >> e;
  }
  int dy[] = {1, -1, 0, 0}, dx[] = {0, 0, 1, -1};
  int ans = 0;
  for (int sy = 0; sy < h; sy++) {
    for (int sx = 0; sx < w; sx++) {
      if (a[sy][sx] == '#') continue;
      vector<vector<int>> c(h, vector<int>(w, -1));
      c[sy][sx] = 0;
      queue<pair<int, int>> q;
      q.push({sy, sx});
      while (!q.empty()) {
        auto p = q.front();
        q.pop();
        int y = p.first, x = p.second;
        for (int i = 0; i < 4; i++) {
          int ny = y + dy[i];
          int nx = x + dx[i];
          if (ny < 0 || ny >= h || nx < 0 || nx >= w) continue;
          if (c[ny][nx] == -1 && a[ny][nx] == '.') {
            q.push({ny, nx});
            c[ny][nx] = c[y][x] + 1;
          }
        }
      }
      for (int i = 0; i < h; i++) {
        for (int j = 0; j < w; j++) {
          ans = max(ans, c[i][j]);
        }
      }
    }
  }
  cout << ans << '\n';
  return 0;
}

Measured memory_bytes: 3672
// ref.
// + https://tubo28.me/compprog/algorithm/minball/
// + http://judge.u-aizu.ac.jp/onlinejudge/review.jsp?rid=2060826#1

#include <algorithm>
#include <cassert>
#include <cmath>
#include <complex>
#include <cstdio>
#include <random>
#include <utility>
#include <vector>

using ld = double;
using P = std::complex<ld>;
using G = std::vector<P>;
const ld pi = acos(-1);
const ld eps = 1e-10;
const ld inf = 1e12;

ld cross(const P& a, const P& b) { return a.real()*b.imag() - a.imag()*b.real(); }
ld dot(const P& a, const P& b) { return a.real()*b.real() + a.imag()*b.imag(); }

using C = std::pair<ld, P>;
#define rad first
#define pnt second

template <class iter>
std::pair<P, ld> min_ball(iter left, iter right, int seed = 1333) {
    const int n = right - left;

    assert(n >= 1);
    if (n == 1) {
        return {*left, ld(0)};
    }

    std::mt19937 mt(seed);
    std::shuffle(left, right, mt);
    // std::random_shuffle(left, right); // simple but deprecated

    iter ps = left;
    using circle = std::pair<P, ld>;

    auto make_circle_3 = [](const P &a, const P &b, const P &c) -> circle {
        ld A = std::norm(b - c), B = std::norm(c - a), C = std::norm(a - b),
           S = cross(b - a, c - a);
        P p = (A * (B + C - A) * a + B * (C + A - B) * b + C * (A + B - C) * c) / (4 * S * S);
        ld r2 = std::norm(p - a);
        return {p, r2};
    };

    auto make_circle_2 = [](const P &a, const P &b) -> circle {
        P c = (a + b) / (ld)2;
        ld r2 = std::norm(a - c);
        return {c, r2};
    };

    auto in_circle = [](const P &a, const circle &c) -> bool {
        return std::norm(a - c.first) <= c.second + eps;
    };

    circle c = make_circle_2(ps[0], ps[1]);

    // MiniDisc
    for (int i = 2; i < n; ++i) {
        if (!in_circle(ps[i], c)) {
            // MiniDiscWithPoint
            c = make_circle_2(ps[0], ps[i]);
            for (int j = 1; j < i; ++j) {
                if (!in_circle(ps[j], c)) {
                    // MiniDiscWith2Points
                    c = make_circle_2(ps[i], ps[j]);
                    for (int k = 0; k < j; ++k) {
                        if (!in_circle(ps[k], c)) {
                            c = make_circle_3(ps[i], ps[j], ps[k]);
                        }
                    }
                }
            }
        }
    }
    return c;
}

int main() {
    size_t n;
    scanf("%zu", &n);
    std::vector<std::complex<double>> p(n);
    for (size_t i = 0; i < n; ++i) {
        double x, y;
        scanf("%lf %lf", &x, &y);
        p[i].real(x);
        p[i].imag(y);
    }

    double r = min_ball(p.begin(), p.end()).second;
    printf("%.18f\n", std::sqrt(r));
}

Measured memory_bytes: 256
#include <cstdio>
#include <iostream> 
#include <string>
#include <vector>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <typeinfo>
#include <numeric>
#include <functional>
 
using namespace std;
using ll = long long;
using ull = unsigned long long;
 
const ll INF = 1e9;
const ll MOD = 1e9 + 7;

#define REP(i, n) for(int i = 0; i < n; i++)
#define RREP(i, n) for(int i = n - 1; i >= 0; i--)
#define REP2(i, n, k) for(int i = 0; i < n; i += k)


int main()
{
    int n, z, w, a[2000];

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

	if(n > 1){
		cout << max(abs(a[n - 2] - a[n - 1]), abs(a[n - 1] - w)) << endl;
	}
	else{
		cout << abs(a[0] - w) << endl;
	}
}

Measured memory_bytes: 256
X = int(input())
ans = 0
if X <= 599:
    ans = 8
elif X <= 799:
    ans = 7
elif X <= 999:
    ans = 6
elif X <= 1199:
    ans = 5
elif X <= 1399:
    ans = 4
elif X <= 1599:
    ans = 3
elif X <= 1799:
    ans = 2
elif X <= 1999:
    ans = 1
print(ans)


Measured memory_bytes: 9176
#include<algorithm>
#include <iostream>
#include<cstdio>
#include<cmath>
#include<iomanip>
#include<string>
using namespace std;
int main() {

	int x;
	cin >> x ;

	if (x == 7 || x == 5 || x == 3) {
		cout << "YES" << endl;
	}
	else {
		cout << "NO" << endl;
	}


	return 0;
}


Measured memory_bytes: 256
<?php
$n = trim(fgets(STDIN));
$str = trim(fgets(STDIN));
$p = trim(fgets(STDIN));
for($i = 0; $i < $n; $i++){
    if($str[$i] == $str[$p-1]){
        echo $str[$i];
    }else{
        echo "*";
    }
}

Measured memory_bytes: 4728
#include<iostream>
 #include<cmath>
 #define LIMIT 50000
 using namespace std;
 int a, b , d, mx, my;
 
 void update( int x, int y, int &mx, int &my ){
     if ( y < 0 ) return;
     if ( x + y == mx + my && a*x + b*y < a*mx + b*my ){
         mx = x; my = y;
     } else if ( x + y < mx + my ){
         mx = x; my = y;
     }
 }

 main(){
     while( cin >> a >> b >> d, (a || b || d) ){
         mx = my = LIMIT;
         for ( int y, x = 0; x <=  50000; x++ ){
             if ( (a*x - d)%b == 0 ){
                 y = (a*x - d)/b; update( x, y, mx, my );
             }
             if ( (a*x + d)%b == 0 ){
                 y = (a*x + d)/b; update( x, y, mx, my );
             }
             if ( (d - a*x)%b == 0 ){
                 y = (d - a*x)/b; update( x, y, mx, my );
             }
         }
         cout << mx << " " << my << endl;
     }
 }

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

#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define RFOR(i, a, b) for (int i = (a); i >= (b); i--)
#define rep(i,n) for(int i=0; i<n; i++)
#define all(x) (x).begin(),(x).end()

typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> P;
typedef map<int,int> mp;

const int MOD = 1e9 + 7;


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

    string s;
    cin >> s;

    cout << ++s[0] << endl;

    return 0;
}



Measured memory_bytes: 256
n=int(input())
s = [input() for i in range(n)]
m = int(input())
t = [input() for i in range(m)]
l = [0]*n
for i in range(n):
    ans = 0
    for j in range(n):
        if s[i] == s[j]:
            ans += 1
    for k in range(m):
        if s[i] == t[k]:
            ans -= 1
    l[i] = ans
print(max(max(l), 0))

Measured memory_bytes: 39408
#define __USE_MINGW_ANSI_STDIO 0
#include <bits/stdc++.h>
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl '\n'
#define rep(i, a, b) for (int i = a; i < b; i++)
#define ff first
#define pii pair<int, int>
#define vii vector< pair<int,int> >
#define vi vector<int>
#define vvi vector< vector< int> >
#define ss second
#define mod 998244353
#define pb push_back
#define mp make_pair
#define int long long
#define all(a) a.begin(), a.end()
#define inf (1LL<<61)
#define ull unsigned long long
#define trace1(x)                cout<<#x<<": "<<x<<endl
#define trace2(x, y)             cout<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace4(x, y, z, d)          cout<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<" | "<<#d<<": "<<d<<endl

#define trace3(x, y, z)          cout<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define debug1(x) cerr << #x << ": " << x <<'\n'
#define debug2(x, y) cerr << #x << ": " << x << '\t' << #y << ": " << y <<'\n'
#define debug3(x, y, z) cerr << #x << ": " << x << '\t' << #y << ": " << y << '\t' << #z << ": " << z <<'\n'
using namespace std;
//int dx[]={1,0,-1, 0};int dy[]={0,1,0, -1}; //4 Direction
//int dx[]={1,1,0,-1,-1,-1,0,1};int dy[]={0,1,1,1,0,-1,-1,-1};//8 direction
bool compare(const pair<int,int> &a, 
              const pair<int,int> &b) 
{   
    if(a.ff == b.ff){
        return (b.ss < a.ss);
    }
    return (a.ff<b.ff); 
}

int32_t main()
{
    IOS;
    // #ifndef ONLINE_JUDGE
    // freopen("input.txt","r",stdin); 
    // freopen("output.txt","w",stdout);
    // #endif
    /********************* From here ***********************/
    int n;
    cin >> n;
    vi v;
    rep(i, 0, n){
        int a;
        cin >> a ;
        v.pb(a);
    }
    int cnt = 0;
    for(int i=1;i<n;i++){
        bool fg = true;
        for(int j=0;j<i;j++){
            if(v[j] > v[i]){
                fg = false;
                break;

            }
        }
        if(fg){
            cnt++;
        }

    }
    cout << cnt+1;

}


Measured memory_bytes: 256
#include<stdio.h>
#define N 100
#define WHITE 0
#define GRAY 1
#define BLACK 2

int tt;
int d[N];
int f[N];
int M[N][N];
int color[N];
int n;

void dfs_visit(int u){
    
    color[u] = GRAY;
    d[u] = ++tt;
    for(int v = 0; v < n; v++){
        if(M[u][v] == 0) continue;
        else if(color[v]== WHITE){
            dfs_visit(v);
        }
    }
    color[u] = BLACK;

    f[u] = ++tt;
}



int main(){
    int u;
    int v;
    int k;



    scanf("%d",&n);

    for(int i=0; i<n; i++){
        color[i] = WHITE;
        for (int j=0; j<n ;j++) M[i][j] =0;
    }


    for(int i=0; i<n; i++){
        scanf("%d",&u);
        scanf("%d",&k);
        for(int j=0; j<k; j++){
            scanf("%d",&v);

            M[u-1][--v] = 1;
        }
        
    }

    tt = 0;

    for(int i=0; i<n;i++) {
        if(color[i] == WHITE) dfs_visit(i);
    }

    for(int i=0; i<n; i++){
        printf("%d %d %d\n",i+1,d[i],f[i]);
    }

    return 0;

}


Measured memory_bytes: 2752
package main

import (
	"fmt"
	"strconv"
)

func main() {
	var S string
	fmt.Scanf("%s", &S)

	pre, _ := strconv.Atoi(S[0:2])
	suf, _ := strconv.Atoi(S[2:4])

	var f1, f2 bool
	if 0 < pre && pre <= 12 {
		f1 = true
	}

	if 0 < suf && suf <= 12 {
		f2 = true
	}

	if f1 && !f2 {
		fmt.Println("MMYY")
	} else if !f1 && f2 {
		fmt.Println("YYMM")
	} else if f1 && f2 {
		fmt.Println("AMBIGUOUS")
	} else {
		fmt.Println("NA")
	}

}


Measured memory_bytes: 512
N,M,C = map(int,input().split())
Als = []
Bls = []

B = input().split(" ")

for b in B:
  Bls.append(int(b))

for n in range(0,N):
  app = []
  A = input().split(" ")
  for a in A:
    app.append(int(a))

  Als.append(app)


count = 0

for a in Als:
  sm = 0
  for m in range(0,M):
    sm += int(a[m])*int(Bls[m])
  sm += C

  if sm>0:
    count += 1

print(count)


Measured memory_bytes: 3064
N=int(input())
t=0
x=0
y=0
for i in range(N):
    t_next,x_next,y_next=map(int,input().split())
    zikan=t_next - t
    kyori=abs(x_next-x)+abs(y_next-y)
    if kyori>zikan or (zikan-kyori)%2==1:
        print('No')
        exit(0)
    t,x,y=t_next,x_next,y_next
print('Yes')

Measured memory_bytes: 3064
#include <iostream>
#include <string>

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

using namespace std;

string origin;
bool ok(string s, int pos, int d) {
    int i = 0;
    // cout << s << ", " << pos << ", " << d << endl;
    while (1) {
        if (i == origin.size()) return true;
        if (pos < s.size()) {
            if (origin[i] != s[pos]) return false;
        } else {
            return false;
        }
        i++;
        pos += d;
    }
    return true;
}
bool ok(string s) {
    rep(i, s.size()) rep(j, s.size()) if (i < j) {
        if (s[i] == origin[0] && s[j] == origin[1]) {
            int d = j - i;
            if (ok(s, i, d)) return true;
        }
    }
    return false;
}

int main() {
    int N;
    int ans = 0;
    cin >> N >> origin;
    rep(i, N) {
        string s;
        cin >> s;
        if (ok(s)) {
            // cout << "ok: " << s << endl;
            ans++;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3156
#include<bits/stdc++.h>
using namespace std;
#define ios ios_base::sync_with_stdio(0);cin.tie(0)
#define scn(n) scanf("%d",&n)
#define lscn(n) scanf("%lld",&n)
typedef long long ll;
#define pri(n) printf("%d\n",n)
#define lpri(n) printf("%lld\n",n);
#define rep(i,st,ed) for(int i=st;i<ed;i++)
#define var(n) int n; scn(n)
#define F first
#define S second 
#define pb push_back
const int N=1e6+5;
// const ll M = 998244353;
const ll M=1e9+7;
const ll inf=1e18;



int main()
{
	var(n);
	int a[n][3];
	int dp[n][3];
	dp[0][0]=dp[0][1]=dp[0][2]=0;
	rep(i,0,n)
	{
		scn(a[i][0]);
		scn(a[i][1]);
		scn(a[i][2]);
		if(i)
		{
			dp[i][0]=max(dp[i-1][1],dp[i-1][2]) + a[i][0];
			dp[i][1]=max(dp[i-1][0],dp[i-1][2]) + a[i][1];
			dp[i][2]=max(dp[i-1][1],dp[i-1][0]) + a[i][2];
		}
		else
		{
			dp[i][0]=a[i][0];
			dp[i][1]=a[i][1];
			dp[i][2]=a[i][2];
		}
	}
	pri(max({dp[n-1][0],dp[n-1][1],dp[n-1][2]}));

}

Measured memory_bytes: 2560
#include <stdio.h>
#include <algorithm>

using namespace std;

//long long
const long long NN = 120000;
long long n , m;
long long a[NN];
long long b[NN] , c[NN] , d[NN];
long long ans , tmp;
void work () {
	long long i;
	scanf ( "%lld%lld" , &n , &m );
	for ( i = 1 ; i <= n ; i++ ) {
		scanf ( "%lld" , &a[i] );
		if ( i != 1 ) {
			if ( a[i] == a[i-1] ) continue;
			if ( a[i] > a[i-1] ) {
				tmp += a[i] - a[i-1];
				d[a[i-1]+2]++;
				d[a[i]+1]--;
				c[a[i]+1] -= a[i] - a[i-1] - 1;
			}
			else {
				tmp += m - a[i-1];
				tmp += a[i];
				d[a[i-1]+2]++;
				if ( a[i-1] != m ) d[1]++;
				else d[2]++;
				d[a[i]+1]--;
				if ( a[i-1] != m ) c[1] += m - a[i-1] - 1;
				c[a[i]+1] -= m-a[i-1]+a[i]-1;
			}
		}
	}
	for ( i = 1 ; i <= m ; i++ ) {
		d[i] += d[i-1];
		c[i] += c[i-1];
		c[i] += d[i];
		b[i] = c[i];
		ans = min ( ans , -b[i] );
		//printf ( "%lld " , b[i] );
	}
	//printf ( "%lld %lld\n" , ans , tmp );
	printf ( "%lld\n" , ans + tmp );
}
int main () {
	work ();
	return 0;
}

Measured memory_bytes: 3328
#include <limits.h>
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

#define int long long
#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define REPS(i, n) for (int i = 1, i##_len = (n); i <= i##_len; ++i)
#define FOR(i, a, b) for (int i = (a), i##_len = (b); i <= i##_len; ++i)
#define REV(i, a, b) for (int i = (a); i >= (b); --i)
#define CLR(a, b) memset((a), (b), sizeof(a))
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define INF 1001001001001001001ll
#define fcout cout << fixed << setprecision(10)

using namespace std;

typedef pair<int, int> P;

int calc(int n, vector<int> a) {

    int res = 0;
    REP(i, a.size()) {
        res += (n - a[i]) * (n - a[i]);
    }
    return res;
}

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);

    int N;
    cin >> N;

    vector<int> a(N);
    int sum = 0;
    REP(i, N) {
        cin >> a[i];
        sum += a[i];
    }

    int a1 = sum / N;
    int a2 = a1 + 1;
    cout << min(calc(a1, a), calc(a2, a)) << endl;

    return 0;
}


Measured memory_bytes: 256
A ,B= map(float,input().split())
A = int(A)
C = str(B)
if B == 10.0:
  D = 1000
elif B == 0.0:
  D = 0
elif len(C) == 4:
  D = int(C[-1]) + int(C[-2])*10 + int(C[-4])*100
elif len(C) == 3:
  D = int(C[-1])*10 + int(C[-3])*100
  
ans = A*D
ans = ans//100
print(ans)

Measured memory_bytes: 9204
from collections import Counter

N,*A = map(int,open(0).read().split())

L = []
R = []
for i in range(N):
    L.append(i+1 + A[i])
    R.append(i+1 - A[i])
l = Counter(L)
r = Counter(R)
 
cnt = 0
a = []
for i in range(1,N+1):
    if i in l and i in r:
        cnt += l[i] * r[i]
        a.append(i)
print(cnt)

Measured memory_bytes: 150096
#include <bits/stdc++.h>
#include<math.h>
#include <iostream>
#include <vector>
#include <queue>

using namespace std;

int main() {
  int A,B;
  cin>>A>>B; 
  bool a=true;
  
  for(int i=1;i<=12500;i++){
    int e=i*0.08;
    int f=i*0.1;
    if(e==A&&f==B){
      cout<<i<<endl;
      a=false;
      break;
    }
  }
      
 
  if(a){
    cout<<-1<<endl;
  }
 
 
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i,n) for(int i=0,_n=(int)(n);i<_n;++i)
#define ALL(v) (v).begin(),(v).end()
#define CLR(t,v) memset(t,(v),sizeof(t))
template<class T1, class T2>ostream& operator<<(ostream& os, const pair<T1, T2>&a)
{
   return os << "(" << a.first << "," << a.second << ")";
}
template<class T>void pv(T a, T b)
{
   for(T i = a; i != b; ++i)
      cout << (*i) << " ";
   cout << endl;
}
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 nextInt()
{
   int x;
   scanf("%d", &x);
   return x;
}



int main()
{
   int n, k;
   while(cin >> n){
         vector<int> v;
         v.push_back(0);
         REP(i,n){
            int t;
            cin >> t;
             v.push_back(t);
         }
         v.push_back(0);
         long long dis = 0;
         for(int i = 1; i < n + 2; i++){
            dis += abs(v[i] - v[i - 1]);
         }
         for(int i = 1; i < n + 1; i++){
            cout << dis - abs(v[i] - v[i -1]) -abs(v[i] - v[i +1])+abs(v[i+1] - v[i -1]);

               cout << endl;

         }

   }


   return 0;

}


Measured memory_bytes: 1784
#include <vector>
#include <math.h>
#include <iostream>
#include <string>
#include <algorithm>
#include <queue>
#include <iomanip>
#include <deque>
#include <cctype>
#include <unordered_map>

using namespace std;
using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;
using pll = pair<long, long>;
template <class T> using V = vector<T>;
template <class T> using VV = V<V<T>>;
#define rep(i, n) for(int i = 0; i<n; i++)
#define rep_s(i, start, n) for(int i= start;  i<n; i++)
#define rep_down(i, n) for(int i = n-1; i>=0; i--)
#define rep_down_s(i, n, start) for(int i = n-1; i>=start; i--)
#define ALL(a) (a).begin(), (a).end()
#define ALL_str(a) (a).cbegin(), (a).cend()

string alphabet_upper = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
string alphabet_lower  = "abcdefghijklmnopqrstuvwxyz";
string numbers = "0123456789";
/*
for (iterator = hash.begin(); iterator != hash.end(); iterator++)
{
// ここで、要素毎の操作を行います。
std::pair<std::string, CMyClass> element = *iterator;

}
*/
/*
using edge = struct {int to; ll cost;};
vector<edge> tree[limit];
ll depth[limit];

void dfs(int v, int p, ll d){
  depth[v] = d;
  //cout <<"v: " << v << endl;
  for (auto &e: tree[v]){
    //cout << "e.to: " << e.to << endl;
    if (e.to == p) continue;
    dfs(e.to, v, d+e.cost);
  }
}
*/
int keta_sum(int num){
  int dig, sum = 0;
  while(num){
    dig = num % 10;
    sum = sum + dig;
    num = num / 10;
  }
  return sum;
}

ll binary_search(ll left_key, ll border, ll low, ll high) {
     // 配列 a の左端と右端
    ll mid = (low+high)/2;
    while (high > low+1) {
       mid = (low+high)/2;
        if (left_key*mid>border) high = mid;
        else if (left_key*mid<border) low = mid;
        else {
          mid =mid-1;
          break;
        }
    }
    return mid;
}

bool IsPrime(ll a){
  ll b = sqrt(a);
  b++;
  while(b-->=2){
    if (a%b==0) return false;
  }
  return true;
}

ll gcd(ll a, ll b){
  ll tmp;
  if(a<b){
    tmp = a;
    a = b;
    b = tmp;
  }

  ll r = a % b;
  while(r!=0){
    a = b;
    b = r;
    r = a % b;
  }
  return b;
}

struct UnionFind {
    vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2

    UnionFind(int N) : par(N) { //最初は全てが根であるとして初期化
        for(int i = 0; i < N; i++) par[i] = i;
    }

    int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }

    void unite(int x, int y) { // xとyの木を併合
        int rx = root(x); //xの根をrx
        int ry = root(y); //yの根をry
        if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
        par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
    }

    bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
};

int main(void){
  ll N, M, A, B, C, D, E, F, K,L, W, H, P, Q, R, X, Y;
  ll ans;
  string S, T;
  cin >> A>> B >> C;
  ll d[C][C], c[N][N];
  ll min_abc = min(A+B, B+C);
  min_abc = min(min_abc, C+A);
  

  cout <<min_abc << endl;

}



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

namespace ConsoleApplication6
{
    class Program
    {
        static void Main(string[] args)
        {
            bool ret = false;
            UInt64 retint = 0;
            string retstr = string.Empty;
            
            Int64 HP=c2i(Console.ReadLine());
            Int64 currntHP = HP;
            Int64 enemycount = 1;
            Int64 HitCount = 0;
            while (currntHP > 0)
            {
                currntHP = currntHP / 2;
                HitCount += enemycount;
                if (currntHP > 0) enemycount *= 2;

            }

            Console.WriteLine(HitCount);
            //Console.ReadLine();
        }
            
        static Int64 c2i(string c) { return Int64.Parse(c); }
    }
}


Measured memory_bytes: 13140
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define all(x) (x).begin(), (x).end()
#define dbg(x) cerr << #x << ": " << x << endl
int main() {
  string s;
  cin >> s;
  vector<int> cnt(2);
  rep(i, s.size()) {
    if(s[i] == '0')
      cnt[0]++;
    else
      cnt[1]++;
  }
  cout << 2 * min(cnt[0], cnt[1]) << endl;
  return 0;
}

Measured memory_bytes: 512
import sys
for e in sys.stdin:
    a, b, c, d, e, f = map(int, e.split())
    y=(c*d-a*f)/(b*d-a*e)
    x = (c-b*y)/a
    #print (str(round(x, 3))+' '+str(round(y, 3)))#dont int+str
    print("%.3f %.3f"%(x,y))


Measured memory_bytes: 5620
n, m = map(int, input().split())
student = []
checkpoint = []
for i in range(n):
  x, y = map(int, input().split())
  student.append([x, y])
for i in range(m):
  x, y = map(int, input().split())
  checkpoint.append([x, y])

for i in range(n):
  x, y = student[i]
  ans = 999999999
  ansnum = 0
  distance = 0
  for j in range(m):
    xc, yc = checkpoint[j]
    distance = abs(x-xc) + abs(y-yc)
    if ans - distance >0:
      ans = distance
      ansnum = j + 1
  print(ansnum)

Measured memory_bytes: 3064
#include <stdio.h>
int main(void){
    int W,H,x,y,r;
    scanf("%d %d %d %d %d",&W,&H,&x,&y,&r);
    if(W >= x+r && H >= y+r && r <= x && r <= y){
        printf("Yes\n");
    }
    else{
        printf("No\n");
    }
    return 0;
}
    
    

Measured memory_bytes: 584
#include <bits/stdc++.h>
using namespace std;
using ll=long long;

template< typename flow_t >
struct FordFulkerson {
  struct edge {
    int to;
    flow_t cap;
    int rev;
    bool isrev;
    int idx;
  };

  vector< vector< edge > > graph;
  vector< int > used;
  const flow_t INF;
  int timestamp;

  FordFulkerson(int n) : INF(numeric_limits< flow_t >::max()), timestamp(0) {
    graph.resize(n);
    used.assign(n, -1);
  }

  void add_edge(int from, int to, flow_t cap, int idx = -1) {
    graph[from].emplace_back((edge) {to, cap, (int) graph[to].size(), false, idx});
    graph[to].emplace_back((edge) {from, 0, (int) graph[from].size() - 1, true, idx});
  }

  flow_t dfs(int idx, const int t, flow_t flow) {
    if(idx == t) return flow;
    used[idx] = timestamp;
    for(auto &e : graph[idx]) {
      if(e.cap > 0 && used[e.to] != timestamp) {
        flow_t d = dfs(e.to, t, min(flow, e.cap));
        if(d > 0) {
          e.cap -= d;
          graph[e.to][e.rev].cap += d;
          return d;
        }
      }
    }
    return 0;
  }

  flow_t max_flow(int s, int t) {
    flow_t flow = 0;
    for(flow_t f; (f = dfs(s, t, INF)) > 0; timestamp++) {
      flow += f;
    }
    return flow;
  }

  void output() {
    for(int i = 0; i < graph.size(); i++) {
      for(auto &e : graph[i]) {
        if(e.isrev) continue;
        auto &rev_e = graph[e.to][e.rev];
        cout << i << "->" << e.to << " (flow: " << rev_e.cap << "/" << e.cap + rev_e.cap << ")" << endl;
      }
    }
  }
};


int main() {
    ll N;
    cin >> N;
    int s= N*2;int t=s+1;

    FordFulkerson< int > g(t+1);
    vector<pair<int,int>> A;
    vector<pair<int,int>> C;
    for(int i=0;i<N;i++){
        int a,b;
        cin >> a >>b;
        A.emplace_back(a,b);
        g.add_edge(s,i,1);
    }
    for(int i=0;i<N;i++){
        int c,d;
        cin >> c >> d;
        C.emplace_back(c,d);
        g.add_edge(N+i,t,1);
    }
    for(int i=0;i<N;i++){
        for(int j=0;j<N;j++){
            if(A[i].first < C[j].first && A[i].second < C[j].second){
                g.add_edge(i,N+j,1);
            }
        }
    }
    cout << g.max_flow(s,t) << endl;
    return 0;
}

Measured memory_bytes: 384
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = Integer.parseInt(sc.next());
		String S = sc.next();
		sc.close();

		int count = Integer.MIN_VALUE;
		String check = "abcdefghijklmnopqrstuvwxyz";
		for(int i = 1; i < N; i++) {
			int tmpCount = 0;
			String X = S.substring(0, i);
			String Y = S.substring(i, N);
			for(int j = 0; j < check.length(); j++) {
				if(X.contains(check.substring(j, j + 1))) {
					if(Y.contains(check.substring(j, j + 1))){
						tmpCount++;
					}
				}
			}
			count = Math.max(count, tmpCount);
		}
		System.out.println(count);
	}

}


Measured memory_bytes: 23764
#include <stdio.h>

int main(void){
    int H,A;
    

    scanf("%d", &H);
    scanf("%d", &A);

    int i=0;
   int num = H;
    while(num > 0){
		i++;
        num = num -A;
    }

    printf("%d",i);
    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
int main()
{
  int D, N;
  cin >> D >> N;
  if (N == 100)
    N++;
  cout << N;
  for (int i = 0; i < D; i++)
    cout << "00";
  cout << endl;
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<cmath>
#include<algorithm>
#include<functional>
#include<numeric>
#include<queue>
#include<stack>
#include<map>
#include<unordered_map>
#include<set>
#include<bitset>
#include<random>
#pragma region
using namespace std;
#define FOR(i,r,n) for(ll i = (ll)(r); i < (ll)(n); i++)
#define rep(i,n) FOR(i,0LL,n)
#define RFOR(i,r,n) for(ll i=(ll)(n-1);i>=r;i--)
#define rrep(i,n) RFOR(i,0LL,n)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define COUNT(a,y,x) upper_bound(all(a), y) - lower_bound(all(a), x)
#define UNIQUE(a) sort(all(a)); a.erase(unique(all(a)), a.end())
#define pb push_back
typedef long long int ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<ll, ll> pll;
typedef vector<pll> vpll;
typedef vector<string> vs;
typedef map<ll, ll> MAP;
const ll inf = 1LL << 61;
const ll mod = 1000000007LL;
//const ll mod = 998244353LL;

ll n = 0, m = 0, ans = 0, tmp = 0, ma = -inf, mi = inf;
string s;
ll dx[9] = { 0,1,0,-1,0,1,1,-1,-1 }, dy[9] = { 0,0,1,0,-1,1,-1,1,-1 };
#define endl '\n'
#pragma endregion
#define MAX 222222



ll a[MAX];


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



  cin >> n;
  rep(i, n) cin >> a[i];
  unordered_map<ll, ll> mp;
  set<ll> st;
  st.insert(-inf);
  st.insert(inf);
  ma = 1;
  rep(i, n) {
    auto it = st.lower_bound(a[i]);
    it--;
    tmp = *it;
    if (tmp == -inf) {
      st.insert(a[i]);
      mp[a[i]]++;
      ans++;
    }
    else {
      mp[tmp]--;
      ans--;
      if (mp[tmp]==0) {
        st.erase(tmp);
      }
      st.insert(a[i]);
      mp[a[i]]++;
      ans++;
    }
  }
  cout << ans << endl;



  return 0;
}


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

using namespace std;
unordered_map<int,int> Map;
int main ()
{
    int s,i=2;
    cin>>s;
    vector<int> Seq;
    Map[s] = 1;
    while(s<=1000000)
    {
        Seq.push_back(s);
        if(s%2==0) s/=2;
        else s = 3*s + 1;
        if(Map[s])
        {
            cout<<i<<endl;
            return 0;
        }
        else Map[s] = i;
        i++;
    }
    return 0;
}


Measured memory_bytes: 256