akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <map>
#include <set>

#define MIN_INT -2147483648
#define MAX_INT 2147483647
#define MIN_LONG -9223372036854775808L
#define MAX_LONG 9223372036854775807L
#define PI 3.141592653589793238462643383279502884L

#define long long long int

using std::vector;
using std::map;
using std::set;
using std::string;
using std::pair;
using std::cin;
using std::cout;
using std::cerr;

// @author: pashka

int main() {
    std::ios::sync_with_stdio(false);

    string s;
    cin >> s;
    int n = s.size();

    map<int, int> last;
    int c = 0;

    vector<int> d(n + 1);
    last[0] = 1;

    for (int i = 0; i < n; i++) {
        c ^= (1 << (s[i] - 'a'));
        d[i + 1] = d[i] + 1;
        if (last[c] > 0) {
            d[i + 1] = std::min(d[i + 1], last[c]);
        }
        for (int j = 0; j < 26; j++) {
            int x = last[c ^ (1 << j)];
            if (x > 0) {
                d[i + 1] = std::min(d[i + 1], x);
            }
        }
        if (last[c] == 0 || last[c] > d[i + 1] + 1)
            last[c] = d[i + 1] + 1;
    }

    cout << d[n] << "\n";

    return 0;
}

Measured memory_bytes: 205076
import scala.math

object Main extends App {
  def divisors(n: Int): List[Int] =
    for (i <- (1 to n).toList if n % i == 0) yield i
  val sc = new java.util.Scanner(System.in)
  var d = sc.nextInt()
  var s = List.fill(26)(sc.nextInt())
  var c = Array.ofDim[Int](d,26)
  for (i <- 0 until d){
    c(i) = Array.fill(26)(sc.nextInt())
  }
  for(i <- 0 until d){
    println( c(i).indexOf(c(i).max) + 1)
  }
}


Measured memory_bytes: 57972
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,ans,q,num;
  while(cin>>n,n){
    double a=0,w,e,y,x;
    cin>>y;
    for(int i=0;i<n;i++){
      cin>>num>>w>>q;
      if(q==2)x=pow((1+(w/100)),y);
      else x=1+y*(w/100);
      if(a<x){
        ans=num;
        a=x;
      }
    }
    cout<<ans<<endl;
  }
}

Measured memory_bytes: 3476
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>

using namespace std;

class Team {
public:
  int id;
  int score;
  Team(int id, int score) : id(id), score(score) {}
  bool operator < (const Team &t) const {
    return score > t.score;
  }
};
int main() {
  vector<Team> v;

  while(1) {
    int a, b;
    scanf("%d,%d", &a, &b);
    if(a == 0 && b == 0) break;
    v.push_back(Team(a, b));
  }
  sort(v.begin(), v.end());

  int id;
  while(cin >> id) {
    int before = -1, rank = 0;
    for(int i = 0; i < v.size(); i++) {
      if(before != v[i].score) rank++;
      if(v[i].id == id) {
	cout << rank << endl;
	break;
      }
      before = v[i].score;
    }
  }
  return 0;
}

Measured memory_bytes: 0
#from collections import deque,defaultdict
printn = lambda x: print(x,end='')
inn = lambda : int(input())
inl   = lambda: list(map(int, input().split()))
inm   = lambda:      map(int, input().split())
ins = lambda : input().strip()
DBG = True # and False
BIG = 10**18
R = 10**9 + 7
#R = 998244353

def ddprint(x):
  if DBG:
    print(x)

n,k = inm()
k2 = k*2
#ddprint(f"{n=} {k=} {k2=}")
a = [[0]*k2 for i in range(k2)]
for i in range(n):
    x,y,c = input().split()
    xx = int(x)%k2
    yy = (int(y)+(k if c=='B' else 0))%k2
    #ddprint(f"{x=} {y=} {c=} {xx=} {yy=}")
    a[xx][yy] += 1

#ddprint("loc1")
racc = [[0]*k2 for i in range(k2)]
rx = [[0]*k2 for i in range(k2)]
for i in range(k2):
    #if i%100==0:
    #    ddprint(i)
    for j in range(k2):
        racc[i][j] = (0 if j==0 else racc[i][j-1])+a[i][j]
    rsum = sum(a[i])
    for j in range(k):
        rx[i][j] = racc[i][j+k-1]-(0 if j==0 else racc[i][j-1])
    for j in range(k,k2):
        rx[i][j] = rsum-rx[i][j-k]

cacc = [[0]*k2 for i in range(k2)]
cx = [[0]*k2 for i in range(k2)]
for i in range(k2):
    #if i%100==0:
    #    ddprint(i)
    for j in range(k2):
        cacc[j][i] = (0 if j==0 else cacc[j-1][i])+rx[j][i]
if False and DBG:
    for i in range(k2):
        ddprint(a[i])
    ddprint('')
    for i in range(k2):
        ddprint(rx[i])
    ddprint('')
    for i in range(k2):
        ddprint(cacc[i])

mx = 0
for i in range(k2):
    #if i%100==0:
    #    ddprint(i)
    for j in range(k2):
        ii = (i+k)%k2
        if j<k:
            v1 = cacc[j+k-1][i]-(0 if j==0 else cacc[j-1][i])
            v2 = cacc[k2-1][ii] - (cacc[j+k-1][ii]- \
                   (0 if j==0 else cacc[j-1][ii]))
        else:
            jj = j-k
            v1 = cacc[k2-1][i] - (cacc[jj+k-1][i]- \
                   (0 if jj==0 else cacc[jj-1][i]))
            v2 = cacc[jj+k-1][ii]- \
                   (0 if jj==0 else cacc[jj-1][ii])
        mx = max(mx,v1+v2)
print(mx)


Measured memory_bytes: 234440
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.*;
import java.util.Calendar.Builder;



public class Main {
	static int INF = 2 << 27;
	static int N;
	static int M;
	static int A;
	static int B;
	static int C;
	static int T;
	static long[][] dp;
	public static void main(String[] args) {	
		//FastScanner sc = new FastScanner();
		Scanner sc = new Scanner(System.in);
		PrintWriter out = new PrintWriter(System.out);
		while(true) {
			int a = sc.nextInt();
			int b = sc.nextInt();
			int d = sc.nextInt();
			if(a == 0 && b == 0 && d == 0) break;
			int minWeight = INF;
			int minNumber = INF;
			int ansX = -1;
			int ansY = -1;
			for(int i = 0; i <= 50000; i++) {
				for(int j = 0; j < 50000; j++) {
					if(i + j > minNumber) break;
					if(a * i + b * j > minWeight) break;
					if(Math.abs(a * i - b * j) == d || (a * i + b * j) == d) {
						minWeight = a * i + b * j;
						minNumber = i + j;
						ansX = i;
						ansY = j;
					}
				}
			}
			System.out.println(ansX + " " + ansY);
		}
	}
}

Measured memory_bytes: 27736
import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int h1 = sc.nextInt();
        int m1 = sc.nextInt();
        int h2 = sc.nextInt();
        int m2 = sc.nextInt();
        int k = sc.nextInt();
        int answer = (h2 - h1) * 60 + (m2 - m1) - k;
        System.out.println(answer);
    }
}

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

int main(){
    long long N, K;
    cin >> N >> K;

    long long a = N/K;
    long long ans = a*a*a;
    if(K%2==0){
        long long b = (N+K/2)/K;
        ans += b*b*b;
    }
    cout << ans << endl;
    return 0;
}

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

using namespace std;

#define mp             make_pair
#define pb             push_back
#define fi             first
#define se             second
#define ll long long
#define ull unsigned ll
#define sz(x)          (int)((x).size())

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


typedef pair<int, int> pii;
#define inf 10e9
const int N = (int) 2e5 + 7;


int main()
{
    map<char, char> m = {{'A', 'T'}, {'T', 'A'}, {'C', 'G'}, {'G', 'C'}};
    char ch;
    cin >> ch;
    cout << m[ch] << endl;

}


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

int main()
{
	int N;
	cin >> N;
	vector<int> H( N );
	for( int i = 0; i < N; i++ ) {
		cin >> H[i];
	}

	string ans = "Yes";
	for( int i = N - 1; i > 0; i-- ) {
		if( H[i - 1] > H[i] ) {
			H[i - 1]--;
			if( H[i - 1] > H[i] ) {
				ans = "No";
				break;
			}
		}
	}

	cout << ans << endl;
}


Measured memory_bytes: 640
#define _CRT_SECURE_NO_WARNINGS

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

/* define */
#define Yes(X) puts ( X ? "Yes" : "No")
#define YES(X) puts ( X ? "YES" : "NO")
#define FOR(i, a, b) for ( int i = a; i < b ; i++)
#define REP(i, n) for ( int i = 0; i < n ; i++)
#define max(a, b) (((a) > (b)) ? (a) : (b))
#define min(a, b) (((a) < (b)) ? (a) : (b))
#define max3(a, b, c) ((max((a), (b)) > (c)) ? max((a), (b)) : (c))
#define min3(a, b, c) ((min((a), (b)) < (c)) ? min((a), (b)) : (c))

/* const */
const int MOD = (int)1e9 + 7;

/* alias */
typedef long long ll;
typedef unsigned  u;

/* function */
int cmp(const void *a, const void *b) {
	return *(int*)a - *(int*)b;
}
int cmp2(const void *a, const void *b) {
	return *(int*)b - *(int*)a;
}
int gcd(int a, int b) {
	if (b != 0)return gcd(b, a % b);
	return a;
}
ll Lgcd(ll a, ll b) {
	if (b != 0) return Lgcd(b, a % b); 
	return a;
}
int lcm(int a, int b) {
	return a / gcd(a, b) * b;
}
ll Llcm(ll a, ll b) {
	return a / Lgcd(a, b) * b;
}

/* main */

int main() {
	int N, L, a = 1e9, s = 0;
	scanf("%d%d", &N, &L);
	FOR(i, 1, N + 1) {
		s += L + i - 1;
		if (abs(a) > abs(L + i - 1))a = L +i -1;
	}
	printf("%d", s - a);
	return 0;
}

Measured memory_bytes: 128
#include <algorithm>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <numeric>
#include <string>
#include <vector>
#include <utility>
using namespace std;

int main()
{
    string s;
    cin >> s;
    int ans = 999;
    for(unsigned int i = 0; i < s.size() - 2; ++i){
        string ss = s.substr(i,3);
        auto num = stoi(ss);
        ans = min(ans, abs(num - 753));
    }
    cout << ans;
    return 0;
}

Measured memory_bytes: 256
#include <iomanip>
#include <iostream>
using namespace std;
int main(void) {
  for(; true;) {
    int n, x;
    cin >> n >> x;
    if(n == 0 && x == 0)
      break;
    int ans = 0;
    for(int a = 1; a < n + 1; a++) {
      for(int b = a + 1; b < n + 1; b++) {
        int m = x - a - b;
        if(n >= m && m > b)
          ans++;
      }
    }
    cout << ans << endl;
  }

  return 0;
}



Measured memory_bytes: 3084
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		String s = sc.next();
		int[] a = new int[n];
		for (int i=0;i<n;i++) {
			a[i]=s.charAt(i)-'0';
		}
/*		
		//bruteforce
		for (int i=1;i<n;i++) {
			ArrayList<Integer> list = new ArrayList<>();
			for (int j=0;j<n-i;j++) {
				a[j]=Math.abs(a[j]-a[j+1]);
				list.add(a[j]);
			}
			System.out.println(list);
		}
*/		
		
		for (int j=0;j<n-1;j++) {
			a[j]=Math.abs(a[j]-a[j+1]);
		}
		
		
		boolean all02 = true;
		for (int j=0;j<n-1;j++) {
			if (a[j]==1) {
				all02=false;
			}
		}
		int[] b=new int[n-1]; //n-2Ci
		b[0]=0;
		for (int i=1;i<n-1;i++) {
			b[i]=b[i-1];
			int j=i;
			int k=n-1-i;
			while(k%2==0) {
				k>>=1;
				b[i]++;
			}
			while(j%2==0) {
				j>>=1;
				b[i]--;
			}
		}

			int ans = 0;
			for (int j=0;j<n-1;j++) {
				if (b[j]==0) {
					ans^=a[j];
				}
			}

			System.out.println(all02 ? ans : ans%2);

	}


}


Measured memory_bytes: 44008
K, N = map(int, input().split())
A = list(map(int, input().split()))

span = []

for i in range(N):
    if i==N-1:
        span.append(K-(A[N-1]-A[0]))
    else:
        span.append(A[i+1]-A[i])

print(K-max(span))

Measured memory_bytes: 25840
#include <iostream>
#include <cmath>
#include <string>
#include <algorithm>
#include <set>
#include <vector>
#include <map>
#include <list>
#include <stack>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <queue>
#define mkp(a, b) make_pair(a, b)
#define pb(t) push_back(t)
#define ft first
#define sc second
#define pt(num) cout << num << "\n"
#define moC(a, s, b) (a)=((a)s(b)+MOD)%MOD
#define max(a, b) ((a)>(b) ? (a):(b))
#define min(a, b) ((a)<(b) ? (a):(b))
#define chmax(a, b) (a<b ? a=b : 0)
#define chmin(a, b) (a>b ? a=b : 0)
#define INF 1000000000000000000
#define MOD 1000000007LL
#define MAX 101010
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef map<ll, ll> Map;




int main(void) {
    string s;
    cin >> s;
    ll cnt[3]={};
    ll i;
    ll f=3;
    
    for(i=0; i<s.size(); i++) {
        cnt[s[i]-'a']++;
    }
    
    for(i=0; i<3; i++) if(cnt[i]==0) f--;
    
    if(f==1) {
        if(s.size()<2) pt("YES");
        if(s.size()>=2) pt("NO");
    }else if(f==2) {
        if(s.size()<3) pt("YES");
        if(s.size()>=3) pt("NO");
    }else if(f==3) {
        ll max=max(cnt[0], max(cnt[1], cnt[2]));
        ll min=min(cnt[0], min(cnt[1], cnt[2]));
        if(max<=min+1) pt("YES");
        else pt("NO");
    }
    
}


Measured memory_bytes: 512
#include <iostream>
#include <algorithm>
#include <math.h>
#include <vector>
#define lli long long int
#define endl "\n"
#define whats(x) cout<<#x<<" is: "<<x<<endl;
using namespace std;
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int a, b;
    cin>>a>>b;
    //floor(0.08*x)=a
    //floor(0.1*x)=b
    bool flag=false;
    for(int i=0; i<=1010; ++i){
        if(floor(0.08*i)==a&&floor(0.1*i)==b){
            flag=true;
            cout<<i<<endl;
            break;
        }
    }
    if(!flag){
        cout<<-1<<endl;
    }
    return 0;
}


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

typedef long long ll;
#define REP(i,n) for(int i=0,_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;}
ll nextLong() { ll x; scanf("%lld", &x); return x;}

const int MAX_N = 212345;
int A[MAX_N];

ll S1[MAX_N];
ll S2[MAX_N];

ll get1(int a, int b) {
  return S1[b] - S1[a];
}
ll get2(int a, int b) {
  return S2[b] ^ S2[a];
}

int main2() {
  int N = nextInt();
  REP(i, N) A[i] = nextInt();

  S1[0] = 0;
  for (int i = 0; i < N; i++) S1[i+1] = S1[i] + A[i];
  S2[0] = 0;
  for (int i = 0; i < N; i++) S2[i+1] = S2[i] ^ A[i];

  ll ans = 0;
  for (int i = 0; i < N; i++) {
    int lo = i;
    int hi = N;
    while (hi - lo > 1) {
      int mi = (hi + lo) / 2;
      if (get1(i, mi + 1) == get2(i, mi + 1)) lo = mi; else hi = mi;
    }
    ans += (hi - i);
  }
  cout << ans << endl;
  return 0;
}

int main() {

#ifdef LOCAL
  for (;!cin.eof();cin>>ws)
#endif
    main2();
  return 0;
}

Measured memory_bytes: 4224
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		long sum = 0;
		long[] a = new long[n];
		a[0] = sc.nextLong();
		for (int i = 1; i < n; i++) {
			a[i] = sc.nextLong()+a[i-1];
		}
		long min = Long.MAX_VALUE;
		for (int i = 0; i < n-1; i++) {
			min = Math.min(min, Math.abs(a[i]-(a[n-1]-a[i])));
		}
		System.out.println(min);
		sc.close();
	}
}

Measured memory_bytes: 88244
from operator import mul
from functools import reduce

def cmb(n,r):
    r = min(n-r,r)
    if r == 0: return 1
    over = reduce(mul, range(n, n - r, -1))
    under = reduce(mul, range(1,r + 1))
    return over // under
mod=10**9+7
s=int(input())
a=s//3
ans=0
for i in range(1,a+1):
    t=s-3*i
    ans+=cmb(t+i-1,i-1)%mod
print(ans%mod)
    

Measured memory_bytes: 9488
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define REP(i,m,n) for(int i=(int)(m); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define rrep(i,n) RREP(i,n-1,0)
#define all(v) v.begin(), v.end()
#define endk '\n'
const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;
const ld eps = 1e-10;

ll toll(string s) {
  int n = s.size();
  ll ret = 0;
  ll pw = 1;
  rrep(i, n) {
    ret += (s[i]-'0') * pw;
    pw *= 10;
  }
  return ret;
}
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n; cin >> n;
  vector<ll> A(n);
  ll pw = 1;
  rep(i, 9) pw *= 10;
  rep(i, n) {
    string s; cin >> s;
    int m = s.size();
    int j = 0;
    while(j<m && s[j]!='.') j++;
    if(j == m) {
      A[i] = toll(s) * pw;
    } else {
      string t(9, '0');
      REP(k, j+1, m) t[k-j-1] = s[k];
      A[i] += toll(s.substr(0, j)) * pw;
      A[i] += toll(t);
    }
  }
  vector<pair<int, int>> cnt(n);
  int mx = 60;
  vector<vector<ll>> sum(mx, vector<ll>(mx));
  rep(i, n) {
    int cnt2 = 0, cnt5 = 0;
    ll a = A[i];
    while(a % 2 == 0) {
      cnt2++;
      a /= 2;
    }
    while(a % 5 == 0) {
      cnt5++;
      a /= 5;
    }
    sum[cnt2][cnt5]++;
    cnt[i].first = cnt2;
    cnt[i].second = cnt5;
  }
  rep(i, mx) rep(j, mx-1) sum[i][j+1] += sum[i][j];
  rep(j, mx) rep(i, mx-1) sum[i+1][j] += sum[i][j];
  assert(sum[mx-1][mx-1]==n);
  ll ans = 0;
  rep(i, n) {
    if(cnt[i].first >= 18 && cnt[i].second >= 18) {
      ans += sum[mx-1][mx-1];
    } else if(cnt[i].first >= 18) {
      ans += sum[mx-1][mx-1] - sum[mx-1][18-cnt[i].second-1];
    } else if(cnt[i].second >= 18) {
      ans += sum[mx-1][mx-1] - sum[18-cnt[i].first-1][mx-1];
    } else {
      ans += sum[mx-1][mx-1] - sum[18-cnt[i].first-1][mx-1] - sum[mx-1][18-cnt[i].second-1] + sum[18-cnt[i].first-1][18-cnt[i].second-1];
    }
    if(A[i]%1000000000LL==0) ans--;
  }
  assert(ans%2==0);
  cout << ans/2 << endk;
  return 0;
}


Measured memory_bytes: 6280
#include <stdio.h>
#include <stack>
#include <utility>
using namespace std;
typedef pair<int,int> pi;
#define F first
#define S second
#define MP make_pair
int main(){
    int n,temp;
    long long int ans=0;
    pi last;
    stack<pi> s;
    scanf("%d",&n);
    for(int i=0;i<n;i++){
        scanf("%d",&temp);
        while(!s.empty()){
            if(s.top().F>=temp){
                last=s.top();
                s.pop();
                if(s.empty())ans=max(ans,(long long int)i*last.F);
                else ans=max(ans,(long long int)last.F*(i-s.top().S-1));
            }
            else break;
        }
        s.push(MP(temp,i));
    }
    while(!s.empty()){
        last=s.top();
        s.pop();
        if(s.empty())ans=max(ans,(long long int)n*last.F);
        else ans=max(ans,(long long int)last.F*(n-s.top().S-1));
    }
    printf("%lld\n",ans);
}


Measured memory_bytes: 3308
#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <algorithm>
#include <sstream>
#include <cmath>
#include <set>
#include <iomanip>
#include <deque>
#include <stdio.h>
using namespace std;

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

typedef long long ll;

struct ConvexHull {
    
    struct Point {
        double x,y;
        Point () {}
        Point (double _x, double _y) : x(_x), y(_y) {}
        bool operator < (const Point &a) const {
            return (x == a.x) ? (y < a.y) : (x < a.x);
        }
    };
    
    double dot(Point a, Point b) { return a.x * b.x + a.y * b.y; }
    double cross(Point a, Point b) { return a.x * b.y - a.y * b.x; }
    double norm(Point a) { return sqrt(dot(a, a) * dot(a, a)); }
    Point sub(Point a, Point b) { return Point(a.x - b.x, a.y - b.y); }
    
    vector< Point > Pos;
    vector< Point > CHPos;
    
    int counter_clockwise(Point p0, Point p1, Point p2) {
        Point a = sub(p1, p0);
        Point b = sub(p2, p0);
        if (cross(a,b) > 1.0e-8) return 1;
        if (cross(a,b) < -1.0e-8) return -1;
        if (dot(a,b) < -1.0e-8) return 2;
        if (norm(a) < norm(b)) return 2;
        return 0;
    }
    
    void add_point(double x, double y) {
        Pos.push_back(Point(x, y));
    }
    
    void build() {
        int n = (int) Pos.size(), k = 0;
        sort(Pos.begin(),Pos.end());
        vector< Point > ch(2 * n);
        for (int i = 0; i < n; ch[k++] = Pos[i++]) {
            while (k >= 2 && counter_clockwise(ch[k-2], ch[k-1], Pos[i]) <= 0) --k;
        }
        for (int i = n - 2, t = k + 1; i >= 0; ch[k++] = Pos[i--]) {
            while (k >= t && counter_clockwise(ch[k-2], ch[k-1], Pos[i]) <= 0) --k;
        }
        copy(ch.begin(), ch.begin() + k - 1, back_inserter(CHPos));
    }
    
    double diameter() {
        int n = (int) CHPos.size();
        int is = 0, js = 0;
        for (int i = 1; i < n; i++) {
            if (CHPos[i].y > CHPos[is].y) is = i;
            if (CHPos[i].y < CHPos[js].y) js = i;
        }
        double maxd = norm(sub(CHPos[is], CHPos[js]));
        int i = is, maxi = is;
        int j = js, maxj = js;
        do{
            if (cross(sub(CHPos[(i + 1) % n], CHPos[i]), sub(CHPos[(j + 1) % n], CHPos[j])) >= 0) {
                j = (j + 1) % n;
            } else {
                i = (i + 1) % n;
            }
            if(norm(sub(CHPos[i], CHPos[j])) > maxd) {
                maxd = norm(sub(CHPos[i], CHPos[j]));
                maxi = i, maxj = j;
            }
        } while (i != is || j != js);
        return sqrt(maxd);
    }
    
    int size() {
        return (int) CHPos.size();
    }
    
    Point operator [] (int n) {
        return CHPos[n];
    }
    
};

int main(){
    
    int n; cin >> n;
    
    ConvexHull inst;
    REP(i,n) {
        double x,y; cin >> x >> y;
        inst.add_point(x, y);
    }
    
    inst.build();
    
    cout << fixed << setprecision(10) << inst.diameter() << endl;
    
    return 0;
}

Measured memory_bytes: 8356
import fractions

N, M = list(map(int, input().split()))
S = input()
T = input()

def lcm(a, b):
	return a * b // fractions.gcd (a, b)

ans = lcm(N, M)

width = fractions.gcd(N, M)

for i in range(width):
    if S[int(N/width) * i] != T[int(M/width) * i]:
        ans = -1
        break

print(ans)


Measured memory_bytes: 5436
/****************************************************
*   Template for coding contests                    *
*   Author    :    Sanjeev Sharma                   *
*   Email     :    thedevelopersanjeev@gmail.com    *
*****************************************************/
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")

#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>

using namespace std;

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int r;
    cin >>r;
    cout <<r*r;
    return 0;
}


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

const int N = 2e5;

int d[N], p[N],  w[N];
vector<int> g[N];

void dfs(int v, int par) {
    p[v] = par;
    for (int to : g[v]) {
        if (to != par) {
            d[to] = d[v] + 1;
            dfs(to, v);
        }
    }
    w[v] = 1;
    for (int to : g[v]) {
        if (to != par) {
            w[v] += w[to];
        }
    }
}

int main() {
    ios::sync_with_stdio(0);
    cin.tie(nullptr);
    int n;
    cin >> n;
    for (int i = 0; i < n - 1; ++i) {
        int x, y;
        cin >> x >> y;
        --x;
        --y;
        g[x].push_back(y);
        g[y].push_back(x);
    }
    dfs(0, 0);
    int cnt = d[n - 1] - 1;
    cnt /= 2;
    int v = n - 1;
    while (cnt--) {
        v = p[v];
    }
    int k2 = w[v];
    int k1 = n - k2;
    if (k1 > k2) {
        cout << "Fennec\n";
    } else {
        cout << "Snuke\n";
    }
}







Measured memory_bytes: 17792
use std::io::prelude::*;

fn input<T>() -> T
where
    T: std::str::FromStr,
{
    let stdin = std::io::stdin();
    let token = stdin
        .lock()
        .bytes()
        .map(|c| c.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect::<String>();
    token.parse().ok().unwrap()
}

fn main() {
    let n = input::<i64>();

    let mut ans = 0;
    for i in (1..n + 1).filter(|&i| i % 2 == 1) {
        let pf = prime_factorize(i);
        let cnt = pf.iter().map(|&(_, p)| p + 1).product::<i64>();
        if cnt == 8 {
            ans += 1;
        }
    }
    println!("{}", ans);
}

fn is_prime(n: i64) -> bool {
    let mut p = true;
    for i in 2..n {
        if i * i > n {
            break;
        }
        if n % i == 0 {
            p = false;
            break;
        }
    }
    p
}

fn prime_factorize(n: i64) -> Vec<(i64, i64)> {
    let mut n = n;
    let mut pf = vec![];
    for i in (2..n + 1).filter(|&n| is_prime(n)) {
        if n % i == 0 {
            let mut pow = 0;
            while n % i == 0 {
                pow += 1;
                n /= i;
            }
            pf.push((i, pow));
        }
    }
    pf
}


Measured memory_bytes: 4352
N, Q = map(int, input().split())
S = input()
t = [0] * N

for i in range(1, N):
    t[i] = t[i-1]
    if S[i-1:i+1] == 'AC': t[i] += 1
    
for i in range(Q):
    l, r = map(int, input().split())
    print(t[r-1] - t[l-1])

Measured memory_bytes: 6140
#include<stdio.h>
int main()
{
    int a[100][100]={0},b[100]={0},c[100]={0};
	int m,n;
	scanf("%d %d",&n,&m);
	for(int i=0;i<n;i++)
	{
		for(int j=0;j<m;j++)
		{
			scanf("%d",&a[i][j]);
		}
	}
	for(int i=0;i<m;i++)
	{
		scanf("%d",&b[i]);
	}
	
    for(int i=0;i<n;i++)
	{
		for(int j=0;j<m;j++)
		{
			c[i]=c[i]+a[i][j]*b[j];	
		}
	}
	
	for (int i=0;i<n;i++) 
    {
        printf("%d\n",c[i]);
    }
  return 0;

}

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

        for(int i=0; i<N; i++) {
            a[i]=sc.nextInt();
            if((i+1)%2==1){
                if(a[i]%2==1){
                    ans++;
                }
            }
        }
        System.out.println(ans);
    }
}

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

int main() {
    int n;
    cin >> n;
    cout << 0 << endl;
    string first;
    cin >> first;
    if (first == "Vacant") return 0;

    int l = 0, r = n;
    while (true) {
        int m = (l + r) / 2;
        cout << m << endl;

        string sex;
        cin >> sex;
        if (sex == "Vacant") break;

        if (m % 2 && sex != first || m % 2 == 0 && sex == first)
            l = m + 1;
        else
            r = m;
    }

    return 0;
}


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

int main() {
  int r;
  cin >> r;
  if( r < 1200 ){
    cout << "ABC" << endl;
    return 0;
  }else if( r < 2800 ){
    cout << "ARC" << endl;
  }else{
    cout << "AGC" << endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#ifdef _DEBUG
#define dlog(str) cout << "====" << str << endl;
#else
#define dlog(str)
#endif
#define INF 999999999
#define MOD 1000000007
#define REP(i, n) for(int i = 0, i##_l = (n); i < i##_l; i++)
#define FOR(i, s, e) for(int i = s, i##_l = (e); i < i##_l; i++)
#define LLI long long int
#define _min(a,b) ((a<b)?a:b)
#define _max(a,b) ((a<b)?b:a)
#define chmax(a, b) a = _max(a, b)
#define chmin(a, b) a = _min(a, b)
#define bit(a, shift) ((a>>shift)&1))
#define pm(a) ((a)?1:-1)
#define SORT(v) sort(v.begin(),v.end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
// int 2.14E±9    lli 9.2E±18    double 1.7E±380


int main() {
	cout << fixed << setprecision(10);
	long double L;
	cin >> L;
	cout << pow(L / 3, 3);

	return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#include <unordered_map>
#include <queue>
#define MOD 1000000007
#define REP(i,st,num)for(int i=(st);i<(num);++i)
#define ll long long
using namespace std;

int main() {
    ios::sync_with_stdio(false);
    string S;
    int qCnt=0,n;
    ll aa[100001] = {0,};
    ll ans=0,poww=1, la = 0, lq = 0, rc = 0, rq = 0;
    cin >> S;
    n=S.length();
    aa[0]=1;
    REP(i,0,n){
        rc += S[i]=='C';
        rq += S[i]=='?';
        if(i!=0)aa[i]=(aa[i-1] * 3) % MOD;
    }
    REP(i,0,n){
        rc -= S[i]=='C';
        rq -= S[i]=='?';
        if (S[i]=='B'||S[i]=='?') {
            ll l = ((la * aa[lq]) % MOD) + ((lq * aa[lq - 1]) % MOD);
            ll r = ((rc * aa[rq]) % MOD) + ((rq * aa[rq - 1]) % MOD);
            ans = (ans + (l * r)) % MOD;
        }
        la += S[i]=='A';
        lq += S[i]=='?';
    }
    cout<<ans;
//A??C
//1233
//0122
//0123
//0122

    return 0;
}

Measured memory_bytes: 1280
yen500 = int(input())
yen100 = int(input())
yen50 = int(input())
sum = int(input())
count = 0

for i in range(yen500 + 1):
  for j in range(yen100 + 1):
    for k in range(yen50 + 1):
      if (500 * i + 100 * j + 50 * k) == sum:
        count += 1
        
print(count)

Measured memory_bytes: 3060
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
using namespace std;
#define REP(i, a, n) for(int i=a; i<n; i++)
#define INF 10e9

int main()
{
	int N, M;
	string U[260], T[260];
	cin >> N;
	REP(i, 0, N) cin >> U[i];
	cin >> M;
	REP(i, 0, M) cin >> T[i];
	
	bool open = false;
	REP(i, 0, M) {
		REP(j, 0, N) {
			if (T[i] == U[j] && !open) {
				cout << "Opened by " << T[i] << endl;
				open = true;
				break;
			}
			else if (T[i] == U[j] && open) {
				cout << "Closed by " << T[i] << endl;
				open = false;
				break;
			}

			if (j == N - 1) cout << "Unknown " << T[i] << endl;
		}
	}

	return 0;
}

Measured memory_bytes: 3188
#include <bits/stdc++.h>
#define rep(a,n) for (ll a = 0; a < (n); ++a)
using namespace std;
using ll = long long;
typedef pair<ll,ll> P;
typedef pair<P,ll> PP;
typedef vector<vector<ll> > Graph;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const ll INF = 1e18;


ll n;
int s[220][220];

//UnionFind
struct UnionFind {
    vector<int> par;

    UnionFind(int n) : par(n, -1) { }

    int root(int x) {
        if (par[x] < 0) return x;
        return par[x] = root(par[x]);
    }

    bool merge(int x, int y) {
        x = root(x); y = root(y);
        if (x == y) return false;
        if (par[x] > par[y]) swap(x, y); 
        par[x] += par[y];
        par[y] = x;
        return true;
    }

    int size(int x) {//sizeの取得
        return -par[root(x)];
    }

    bool same(int x, int y) {
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
};


ll dp[220][220];
void warshallfloyd(){
    rep(k,n){
        rep(i,n){
            rep(j,n){
                dp[i][j]=min(dp[i][j],dp[i][k]+dp[k][j]);
            }
        }
    }
}


int main(){
    cin >> n;
    rep(i,n)rep(j,n){
        char c;
        cin >> c;
        s[i][j]=c-'0';
    }
    //二部グラフ判定
    UnionFind u(2*n);
    for(int i=0;i<n;i++){
        for(int j=i+1;j<n;j++){
            if(s[i][j]){
                u.merge(i,j+n);
                u.merge(j,i+n);
            }
        }
    }
    rep(i,n){
        if(u.same(i,i+n)){
            cout << -1 << endl;
            return 0;
        }
    }
    //ワーシャルフロイド
    rep(i,n){
        rep(j,n){
            if(i==j){
                dp[i][j]=0;
                continue;
            }
            if(s[i][j]==1)dp[i][j]=1;
            else dp[i][j]=INF;
        }
    }
    warshallfloyd();

    ll d = 0;
    rep(i,n){
        rep(j,n){
            if(dp[i][j]==INF)continue;
            chmax(d,dp[i][j]);
        }
    }
    cout << d+1 << endl;
    return 0;
}


Measured memory_bytes: 4156
#include<iostream>
#include<vector>
#define ll long long
#define pb push_back
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
int m,n;
vector<int> ed[100005];
ll dp[100005];
ll res[100005];
ll int dfs(int i,int p){
	for(int j:ed[i]){
		if(p==j)continue;
		dp[i]=(dp[i]*(dfs(j,i)+1ll))%m;
	}
	return dp[i];
}
void dfs1(int i,int p,ll pre){
	res[i]=(dp[i]*(pre+1ll))%m;
	//cout<<res[p]<<" "<<dp[i]<<" "<<res[i]<<"\n";
	int l=ed[i].size();
	ll lt[l],rt[l];
	ll int c=1;
	for(int j=0;j<l;j++){
		if(ed[i][j]==p)c=(c*(pre+1ll))%m;
		else c=(c*(dp[ed[i][j]]+1ll))%m;
		lt[j]=c;
	}
	c=1;
	for(int j=l-1;j>=0;j--){
		if(ed[i][j]==p)c=(c*(pre+1ll))%m;
		else c=(c*(dp[ed[i][j]]+1ll))%m;
		rt[j]=c;
	}
	for(int j1=0;j1<l;j1++){
		int j=ed[i][j1];
		if(j==p)continue;
		ll a,b;
		if(j1==0)a=1;
		else a=(lt[j1-1]);
		if(j1==l-1)b=1;
		else b=rt[j1+1];
		ll tmp=(a*b)%m;
		dfs1(j,i,tmp);
	}
}
int main()
{
	cin>>n>>m;
	rep(i,n-1){
		int u,v;
		cin>>u>>v;
		u--,v--;
		ed[u].pb(v);
		ed[v].pb(u);
	}
	rep(i,n)dp[i]=1ll;
	dfs(0,-1);
	dfs1(0,-1,0);
	rep(i,n)cout<<res[i]<<"\n";
}

Measured memory_bytes: 20608
#include <iostream>

using namespace std;
#define MAX 25

template<typename T>
class TreeNode
{
public:
	T data;
	TreeNode* pParent;
	TreeNode* pLeftChild;
	TreeNode* pRightChild;
};

template<typename T>
class BinaryTree
{
public:
	BinaryTree(TreeNode<T>* pRoot) : m_pRoot(pRoot) {}
	
	void PreOrder()
	{
		cout << "Preorder" << endl;
		PreOrder(m_pRoot);
	}

	void InOrder()
	{
		cout << "Inorder" << endl;
		InOrder(m_pRoot);
	}

	void PostOrder()
	{
		cout << "Postorder" << endl;
		PostOrder(m_pRoot);
	}

private:
	void PreOrder(TreeNode<T>* pNode)
	{
		if (!pNode) return;

		cout << " " << pNode->data;
		PreOrder(pNode->pLeftChild);
		PreOrder(pNode->pRightChild);
	}

	void InOrder(TreeNode<T>* pNode)
	{
		if (!pNode) return;

		InOrder(pNode->pLeftChild);
		cout << " " << pNode->data;
		InOrder(pNode->pRightChild);
	}

	void PostOrder(TreeNode<T>* pNode)
	{
		if (!pNode) return;

		PostOrder(pNode->pLeftChild);
		PostOrder(pNode->pRightChild);
		cout << " " << pNode->data;
	}

private:
	TreeNode<T>* m_pRoot;
};

TreeNode<int> Nodes[MAX];

int main()
{
	int n; cin >> n;
	int id, left, right;
	for (int i = 0; i < n; ++i)
	{
		cin >> id >> left >> right;
		Nodes[id].data = id;
		if (left != -1)
		{
			Nodes[id].pLeftChild = &Nodes[left];
			Nodes[left].pParent = &Nodes[id];
		}
		if (right != -1)
		{
			Nodes[id].pRightChild = &Nodes[right];
			Nodes[right].pParent = &Nodes[id];
		}
	}

	BinaryTree<int>* pTree = 0;
	for (int i = 0; i < n; ++i)
	{
		if (!Nodes[i].pParent)
		{
			pTree = new BinaryTree<int>(&Nodes[i]);
			break;
		}
	}

	if (pTree)
	{
		pTree->PreOrder();
		cout << endl;
		pTree->InOrder();
		cout << endl;
		pTree->PostOrder();
		cout << endl;
	}

	return 0;
}


Measured memory_bytes: 3096
# -*- coding:utf-8 -*-

if __name__ == '__main__':

	while True:
		try:
			a, b, c, d, e, f = [float(num) for num in raw_input().split()]
			x = ((e*c)-(b*f))/((e*a)-(b*d))
			y = ((d*c)-(a*f))/((d*b)-(a*e))
		except:
			break

		if(x==-0):
			x=0
		if(y==-0):
			y=0
		
		print '%0.3f %0.3f' % (x , y)

Measured memory_bytes: 4256
/*
 * I'm strong. Stronger than all of you. Extremely strong.
 * I can kill all those Titans there. Even if I'm alone.
 * You're either incompetent or you're spineless cowards.
 * How pathetic.
 * You can sit here and suck on your fingers. Yeah, do that.
 * ~ Mikasa Ackerman
 */

#include <bits/stdc++.h>

using namespace std;

typedef pair<int, int> II;
typedef vector<II> VII;
typedef vector<int> VI;
typedef vector<VI> VVI;

typedef long long int LL;

#define PB push_back
#define MP make_pair
#define F first
#define S second
#define SZ(a) (int)(a.size())
#define ALL(a) a.begin(), a.end()
#define SET(a, b) memset(a, b, sizeof(a))
#define si(n) scanf("%d", &n)
#define dout(n) printf("%d\n", n)
#define sll(n) scanf("%lld", &n)
#define lldout(n) printf("%lld\n", n)

#define TRACE

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

#define fast_io                                                                \
  ios_base::sync_with_stdio(false);                                            \
  cin.tie(NULL)

#define endl '\n'
const int N = 1e5 + 10;
VI x[N], y[N];
int active[32];
int keep[32];
int main() {
  fast_io;
  int n, c;
  cin >> n >> c;
  for (int i = 0; i < n; i++) {
    int s, t, c;
    cin >> s >> t >> c;
    x[s].PB(c);
    y[t].PB(c);
  }
  int arec = 0;
  int maxarec = 0;
  for (int i = 0; i < N; i++) {
    SET(keep, 0);
    for (auto v : x[i]) {
      if (active[v]) {
        keep[v] = 1;
        continue;
      } else {
        active[v] = 1, arec++, maxarec = max(maxarec, arec);
      }
    }
    for (auto v : y[i]) {
      if (!keep[v] && active[v]) {
        arec--;
        active[v] = 0;
      }
    }
  }
  cout << maxarec << endl;
  return 0;
}


Measured memory_bytes: 11264
// inputに入力データ全体が入る
function Main(input) {
	input = input.split("\n"); // 1行目がinput[0], 2行目がinput[1], …に入る
	// ここに処理を書く
    var s0 = input[0].split(" ");
    var n = Number(s0[0]);
    var x = Number(s0[1]);
    var a = input[1].split(" ");
    var sum = 0;
    for (var i = 0; i < n; i++) {
        a[i] = Number(a[i]);
        sum += a[i];
    }
//    console.log(a);
    var ret = 0;
    if (a[0] > x) {
        ret += a[0] - x;
        a[0] = x;
    }
    for (var i = 0; i < n-1; i++) {
        if (a[i] + a[i+1] > x) {
            ret += a[i] + a[i+1] - x;
            a[i+1] -= a[i] + a[i+1] - x;
        }
    }
    console.log(ret);

	// console.logは標準出力に1行出力します (自動的に最後に改行が入ります)
//	console.log(ss[0][0] + ss[1][0] + ss[2][0]);
}
 
// ※この行以降は編集しない (標準入力から一度に読み込みMainを呼び出します)
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

/*
// inputに入力データ全体が入る
function Main(input) {
    console.log(input);
	input = input.split("\n"); // 1行目がinput[0], 2行目がinput[1], …に入る
	// ここに処理を書く
	var result = input[1];
    console.log(result);
	var score = 0;
	for (var i = 0; i < result.length; i++) {
		if (result[i] == "A") score += 4;
		else if (result[i] == "B") score += 3;
		else if (result[i] == "C") score += 2;
		else if (result[i] == "D") score += 1;
	}
	// console.logは標準出力に1行出力します (自動的に最後に改行が入ります)
	console.log(score / result.length);
}
 
// ※この行以降は編集しない (標準入力から一度に読み込みMainを呼び出します)
console.log("test");
Main(require("fs").readFileSync("/dev/stdin", "utf8"));
*/


Measured memory_bytes: 17816
#include<iostream>
#include<cstdio>
using namespace std;
int n;
long long f[400];
int main(){
    cin>>n;
    f[0]=2;
    for(int i=0;i<=n;i++)f[i]=f[i-1]*2+2;
    cout<<f[n]<<endl;
    return 0;
}

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

#define ll long long int
#define vll vector<ll>
#define vllv vector<vector<ll>> 
#define vpii vector<pair<ll,ll>>
#define pll  pair<ll,ll>
#define sz size()
#define pb push_back
#define ff first
#define ss second
#define all(v) v.begin(),v.end()
#define allr(v) v.rbegin(),v.rend()
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
ll MOD=1000000000+7;
ll ceil1(ll n,ll m){if(n%m==0){return n/m;}return n/m +1;}
ll factor(ll n){
    vll ans;
	if(n==2)ans.pb(2);
	else
    {for(ll i=2;i*i<=n;i++){if(n%i==0 && n%i!=i){ans.pb(i);if(n/i!=i)ans.pb(n/i);}}ans.pb(n);}
    return ans.sz+1;
}
ll fact(ll n){ll res = 1;for (ll i = 2; i <= n; i++)res = res * i; 
    return res; } 
  
ll nCr(ll n, ll r){ return fact(n) / (fact(r) * fact(n - r)); } 
  
void dfs(vllv &v,ll k,vll &par,vll &dis,ll p)
{
    par[k]=p;
    dis[k]=dis[p]+1;
    for(ll i=0;i<v[k].sz;i++){
        if(v[k][i]!=p){
            dfs(v,v[k][i],par,dis,k);
        }
    }
}
bool sortbysec(const pair<string,int> &a,const pair<string,int> &b){return (a.second<b.second);} 

ll pow2(ll n,ll k){ll ans=1;
    while(k>0){
        if(k%2==1)ans=ans*n;n=n*n;k/=2;
    }return ans;}
bool prime(int n){
    int i,j;
    for(i=2;i<=sqrt(n);i++){
        if(n%i==0){
            return false;
        }
    }
    return true;
}

void solve()
{
	int x,a,b;
	cin>>x>>a>>b;
	if(b<=a)
		cout<<"delicious";
	else if(x+a>=b)
		cout<<"safe";
	else
		cout<<"dangerous";
}            
int main()
{
	fast;
    ll q;
    q=1;
    // cin>>q;
    while(q--)
    {
        solve();
    }
    return 0;
}


Measured memory_bytes: 3624
#include<stdio.h>
int main()
{
    int a,b,x,c,d;

    do{
        scanf("%d",&x);
    }while(x<1 || x>1000);

    do{
        scanf("%d",&a);
    }while(a<1 || a>1000);

    do{
        scanf("%d",&b);
    }while(b<1 && b>1000);

    if(x<a) c=a-x;
    else c=x-a;

    if(x<b) d=b-x;
    else d=x-b;

    if(c<d) printf("A");
    else if(d<c) printf("B");
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
 
#define PI 3.14159265358979323846264338327950L

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

	for (int ii = 0; ii < M; ii++) {
		int A;
		cin >> A;
		N = N - A;
		if (N < 0) {
			cout << -1 << endl;
			return 0;
		}
	}
	cout << N << endl;
}

Measured memory_bytes: 3652
#include <iostream>

using namespace std;

int main() {
  int n;
  cin >> n;
  for (int i = 1; i <= n; ++i) {
    int x = i;
    if (x % 3 == 0) {
      cout << " " << i;
      continue;
    }

    while (true) {
      if (x % 10 == 3) {
        cout << " " << i;
        break;
      }

      x /= 10;
      if (!x) {
        break;
      }
    }
  }
  cout << endl;
  return 0;
}





Measured memory_bytes: 3108
from collections import Counter
N = int(input())
S = []
for i in range(N):
  S.append(str(input()))

c = Counter(S)
max_value = max(list(c.values()))
ans_list = sorted(list(c.items()))

for i in range(len(ans_list)):
  if ans_list[i][1] == max_value:
    print(ans_list[i][0])

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

long long n, x, dp[200000], dpw[200000];
vector<long long> vec;

long long pw (long long a, long long b)
{
	long long ret=1;
	for (;b;b >>= 1, a=1ll * a * a % 1000000007)
		if (b & 1)
			ret=1ll * ret * a % 1000000007;
	return ret;
}

int main ()
{
	cin>>n>>x;
	long long cur=1;
	for (int i=0;i < n;i++)
	{
		int a;
		cin>>a;
		if (a<=x)
			vec.push_back(a);
		cur=(cur * (i + 1)) % 1000000007;
	}
	sort(vec.begin(), vec.end());
	for (int i=0;i<=n;i++)
		dpw[i]=pw(i, 1000000007 - 2);
	for (int i=0;i<=x;i++)
	{
		int pos=upper_bound(vec.begin(), vec.end(), i) - vec.begin();
		if (pos==0)
			dp[i]=i;
		for (int j=0;j < pos;j++)
			dp[i]=(dp[i] + dpw[pos] * dp[i % vec[j]]) % 1000000007;
	}
	cout << 1ll * dp[x] * cur % 1000000007 << endl;
}

Measured memory_bytes: 1024
#include<iostream>
#include<algorithm>
#include<vector>
#define rep(i,a) for(int i = 0; i < a; i++)
using namespace std;

int main(){
	int n;
	while(cin >> n, n){
		vector<int> score;
		rep(j, n){
			int sum = 0;
			rep(i, 5){
				int t;
				cin >> t;
				sum += t;
			}
		score.push_back(sum);
	}
	sort(score.begin(), score.end());
	cout << score[n-1] << ' ' << score[0] << endl;
	}
	return 0;
}

Measured memory_bytes: 1220
#include<bits/stdc++.h>
using namespace std;
int N,a[100000],m{100000},M;
int main(){
    cin.tie(0),ios_base::sync_with_stdio(0);
    cin>>N;
    for(int i{};i<N;++i){
        cin>>a[i];
        m=min(m,a[i]);
        M=max(M,a[i]);
    }
    if(M-m>1)
        cout<<"No"<<endl;
    else if(M-m){
        int s=count(a,a+N,M-1);
        cout<<((s<M&&(M-s)*2<=count(a,a+N,M))?"Yes":"No")<<endl;
    }
    else
        cout<<((m==N-1||m*2<=N)?"Yes":"No")<<endl;
}


Measured memory_bytes: 640
#include <iostream>

using namespace std;

int main()
{
    int count;
    int num;
    while(cin >> num)
    {
        count = 0;
        for(int a = 0; a < 10 && a <= num; ++a)
            for(int b = 0; b < 10 && a + b <= num; ++b)
                for(int c = 0; c < 10 && a + b + c <= num; ++c)
                    for(int d = 0; d < 10 && a + b + c + d <= num; ++d)
                        if(a + b + c + d == num) count++;
        cout << count << endl;
    }
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using pii = pair<int,int>;
using pll = pair<ll,ll>;
using vpii = vector<pii>;
using vpll = vector<pll>;

#define rep(i, n) for(int i=0;i<(int)n;i++)
#define rep2(i, s, n) for(int i=(s);i<(int)n;i++)
int INF=1e9+7;

int main() {
  int N;
  cin >> N;
  vl A(N);
  rep(i,N) cin >> A[i];
  ll ans;
  
  if(N%2) {
    vvl dp(N/2+1,vl(3));
    rep(i,N/2) {
      dp[i+1][0]=dp[i][0]+A[2*i];
      dp[i+1][1]=max(dp[i][0],dp[i][1])+A[2*i+1];
      dp[i+1][2]=max(dp[i+1][1]-A[2*i+1],dp[i][2])+A[2*i+2];
    }
    ans=max(max(dp[N/2][0],dp[N/2][1]),dp[N/2][2]);
  }
  else {
    vvl dp(N/2+1,vl(2));
    rep(i,N/2) {
      dp[i+1][0]=dp[i][0]+A[2*i];
      dp[i+1][1]=max(dp[i][0],dp[i][1])+A[2*i+1];
    }
    ans=max(dp[N/2][0],dp[N/2][1]);
  }
  
  cout << ans << endl;
}

Measured memory_bytes: 10356
import sys
input = sys.stdin.readline

N, M = (int(i) for i in input().split())
dic = {}
cnt = 0
pos = 0
for i in range(M):
    a, b = map(int, input().split())
    if b not in dic or dic[b] < a:
        dic[b] = a

for j in sorted(dic.keys()):
    if dic[j] >= pos:
        cnt += 1
        pos = j
print(cnt)


Measured memory_bytes: 10848
#include<iostream>
#include<string>
#include<cstdint>
#include<algorithm>
#include<bitset>
using namespace std;
using ll=unsigned long long int;
int main(){
    int n;
    cin>> n;
    ll a[n+1];
    bitset<61> bita,aa[n+1];
    for(int i=1;i<=n;i++){
        cin>>a[i];
        aa[i]=a[i];
    }
    ll count=0;
    ll sep=1000000007;
    for(int j=  0;j< 61;j++){
        ll x=0;
    for(int i=  1;i<=n ;i++){
        if(aa[i][j]==1) ++x;
    }
    ll now=x*(n-x)%sep;
    for(int k=0;k<j;k++){
        now=now*2%sep;
    }
    count += now;
    count %= sep;
    }
    cout<< count;
    return 0;
}

Measured memory_bytes: 4992
#include<iostream>
#include<utility>
#include<queue>

using namespace std;

int main(void){

	std::ios_base::sync_with_stdio();

	int kouka[]={500,100,50,10,5,1};
	int n,cnt;

	while(1){
		cin>>n;
		if(n==0) break;
		n=1000-n;
		cnt=0;
		for(int i=0;i<6;i++){
			cnt+=n/kouka[i];
			n-=(n/kouka[i])*kouka[i];
		}
		cout<<cnt<<endl;
	}

	return 0;
}

Measured memory_bytes: 1160
#include<cstdio>
#include<iostream>
#include<cmath>
#include<vector>
#include<algorithm>
#define EPS 1e-10
#define COUNTER_CLOCKWISE 1
#define CLOCKWISE -1
#define ONLINE_BACK 2
#define ONLINE_FRONT -2
#define ON_SEGMENT 0
#define pb push_back
#define pop pop_back
using namespace std;
typedef pair<double,int> Pos;

struct Point{
  double x,y;
  Point(double x=0,double y=0):x(x),y(y){}
  Point operator + (Point p){return Point(x+p.x,y+p.y);}
  Point operator - (Point p){return Point(x-p.x,y-p.y);}
  Point operator * (Point p){return Point(x*p.x,y*p.y);}
  Point operator / (Point p){return Point(x/p.x,y/p.y);}
  double dot(Point p){
    return x*p.x+y*p.y;
  }
  double cross(Point p){
    return x*p.y-y*p.x;
  }
  double norm(){
    x*x+y*y;
  }
  double abs(){
    return sqrt(norm());
  }
  bool operator < (const Point &p) const{
    return x != p.x ? x<p.x:y<p.y;
  }
  bool operator == (const Point &p) const{
    return fabs(x-p.x) < EPS && fabs(y-p.y) < EPS;
  }
};
int ccw(Point p1,Point p2,Point p3){
  Point a = p2-p1;
  Point b = p3-p1;
  if(a.cross(b) > EPS)return COUNTER_CLOCKWISE;
  if(a.cross(b) < -EPS)return CLOCKWISE;
  if(a.dot(b) < -EPS)return ONLINE_BACK;
  if(a.norm() < b.norm())return ONLINE_FRONT;
  return ON_SEGMENT;
}

bool cmp_x(const Point& p,const Point& q){
  if(p.x!=q.x)return p.x<q.x;
    return p.y<q.y;
}

vector<Point> convex_hull(Point* ps,int n){
  sort(ps,ps+n,cmp_x);
  int k=0;
  vector<Point> qs(n*2);
  for(int i=0;i<n;i++){
    while(k>1 && (qs[k-1]-qs[k-2]).cross(ps[i]-qs[k-1])<=0)k--;
    qs[k++] = ps[i];
  }
  for(int i=n-2,t=k;i>=0;i--){
    while(k>t && (qs[k-1]-qs[k-2]).cross(ps[i]-qs[k-1])<=0)k--;
    qs[k++] = ps[i];
  }  
  qs.resize(k-1);
  return qs;
}

bool isIntersect(Point p1,Point p2,Point p3,Point p4){
  return (ccw(p1,p2,p3)*ccw(p1,p2,p4)<=0 && ccw(p3,p4,p1)*ccw(p3,p4,p2)<=0);
}


int main(){
  Point p1,p2,p3,p4;
  Point poly[5];
  
  while(scanf("%lf,%lf,%lf,%lf,%lf,%lf,%lf,%lf",&p1.x,&p1.y,&p2.x,&p2.y,&p3.x,&p3.y,&p4.x,&p4.y) != EOF){
    double sum=0;    
    poly[0] = p1;poly[1] = p2;poly[2] = p3;poly[3]=p4;poly[4]=p1;
    if(isIntersect(p1,p4,p2,p3)){
      cout << "NO"<< endl;
      continue;
    } 

    vector<Point> pos = convex_hull(poly,4);

    if(pos.size() <= 3)cout << "NO" << endl;
    else cout << "YES" << endl;


  }
  return 0;
} 

Measured memory_bytes: 1228