akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
using namespace std;

#ifdef LOCAL
	#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
	#define eprintf(...) 42
#endif

typedef long long ll;
typedef pair<int, int> pii;
#define mp make_pair

const int MOD = 998244353;
int add(int x, int y) {
	x += y;
	if (x >= MOD) return x - MOD;
	return x;
}
int sub(int x, int y) {
	x -= y;
	if (x < 0) return x + MOD;
	return x;
}
int mult(int x, int y) {
	return ((ll)x * y) % MOD;
}

const int N = 200100;
int n;
int dp[N][3][3];

void solveSmall(string s) {
	set<string> used;
	vector<string> q;
	q.push_back(s);
	used.insert(s);
	for (int i = 0; i < (int)q.size(); i++) {
		s = q[i];
		string w;
		for (int j = 0; j < (int)s.length() - 1; j++) {
			if (s[j] == s[j + 1]) continue;
			w = s;
			char c = 'a';
			while(c == s[j] || c == s[j + 1]) c++;
			w[j] = w[j + 1] = c;
			if (used.count(w) > 0) continue;
			used.insert(w);
			q.push_back(w);
		}
	}
	printf("%d\n", (int)used.size());
}

int main()
{
//	freopen("input.txt", "r", stdin);
//	freopen("output.txt", "w", stdout);

	string w;
	cin >> w;
	n = w.length();

	bool bad = 1;
	for (int i = 0; i < n; i++)
		bad &= w[0] == w[i];
	if (bad) {
		printf("1\n");
		return 0;
	}

	if (n <= 5) {
		solveSmall(w);
		return 0;
	}

	for (int x = 0; x < 3; x++)
		dp[1][x][x] = 1;
	for (int i = 1; i < n; i++) {
		for (int x = 0; x < 3; x++)
			for (int s = 0; s < 3; s++)
				for (int y = 0; y < 3; y++) {
					if (x == y) continue;
					int ns = (s + y) % 3;
					dp[i + 1][y][ns] = add(dp[i + 1][y][ns], dp[i][x][s]);
				}
	}

	int s = 0;
	for (int i = 0; i < n; i++) {
		s += (int)(w[i] - 'a');
	}
	s %= 3;

	int res = 1;
	for (int i = 1; i < n; i++)
		res = mult(res, 3);
	for (int x = 0; x < 3; x++)
		res = sub(res, dp[n][x][s]);

	bool ok = true;
	for (int i = 0; i < n - 1; i++)
		ok &= w[i] != w[i + 1];
	if (ok) res = add(res, 1);
	printf("%d\n", res);

	return 0;
}


Measured memory_bytes: 7556
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <functional>
#include <map>
#include <queue>
#include <iomanip>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cassert>
#include <complex>

#define ALL(V) (V).begin(),(V).end()

using namespace std;

typedef pair<int,int> ii_t;
typedef complex<double> p_t;

#define MAX 100010
#define RMAX 1000
char is_prime[MAX];
#define PMAX 100000
int prime[PMAX];

int main() {
    int n;
    double x,y;
    double minx=1000,miny=1000,maxx=0,maxy=0;
    cin >> n;
    vector<p_t> data(n);
    for(int i=0;i<n;i++) {
        cin >> x >> y;
        data[i] = p_t(x,y);
        minx = min(minx,x);
        miny = min(miny,y);
        maxx = max(maxx,x);
        maxy = max(maxy,y);
    }

    p_t c(0.5*(maxx-minx), 0.5*(maxy-miny));
    double r = 1000.0;

    for (int k=1;k<1000000;k++) {
        double d = 0.0;
        int index = -1;
        for (int i=0;i<n;i++) {
            double dd = abs(data[i]-c);
            if (dd > d) {
                index = i;
                d = dd;
            }
        }
        // cerr << "d: " << setprecision(16)<< d << endl;
        r = min(r,d);
        c += (1/(double)k) * (data[index] - c);
    }
    
    // cerr << c << endl;
    cout << setprecision(16)
         << r << endl;
    return 0;
}


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

using namespace std;

/*

        Bismillahir Rahmanir Rahim
        Problem :
        Problem Link :
        Topics :
        Solver : Masud Parves
        I Love Code More than Sharks Love Blood <3
*/


#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define SZ(a)           (int)a.size()
#define all(a)  a.begin(), a.end()
#define allr(a)  a.rbegin(), a.rend()


#define sf(a)           scanf("%d",&a)
#define sff(a,b)        scanf("%d %d",&a,&b)
#define sfff(a,b,c)     scanf("%d %d %d",&a,&b,&c)

#define f0(i,b) for(int i=0;i<(b);i++)
#define f1(i,b) for(int i=1;i<=(b);i++)
#define f2(i,a,b) for(int i=(a);i<=(b);i++)
#define fr(i,b,a) for(int i=(b);i>=(a);i--)

#define CIN ios_base::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL);
#define TEST_CASE(t) for(int zz=1 ; zz<=t ; zz++)
#define PRINT_CASE printf("Case %d: ",zz)
#define Debug(x)            cout<<#x " = "<<(x)<<endl
#define NOT_VISITED 0
#define IS_VISITED 1
#define WHITE 0
#define GRAY 1
#define BLACK 2



int fx[4]= {1,-1,0,0};
int fy[4]= {0,0,1,-1};

/*-----------------------Bitmask------------------*/
//int Set(int N,int pos){return N=N  (1<<pos);}
//int Reset(int N,int pos){return N= N & ~(1<<pos);}
//bool Check(int N,int pos){return (bool)(N & (1<<pos));}
/*------------------------------------------------*/


const double PI = acos(-1.0);
const double EPS = 1e-6;
const int MOD = (int)1e9+7;
const int maxn = (int)2e5+5;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef pair<ll, int> plli;
typedef pair<int, ll> pill;


int main() {
    CIN
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);

    ll a, b;
    cin >> a >> b;

    if((a+b)%2) cout <<"IMPOSSIBLE"<< endl;
    else cout << (a+b)/2 << endl;

    return 0;
}



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

long long N, a[300], dp[301][90001], dp2[301][90001], sum, S, ans, mid, All = 1, mod = 998244353;

int main(){
	cin >> N;
	for(int i=0; i<N; i++){ cin >> a[i]; sum += a[i]; }
	for(int i=0; i<N; i++) All = (All * 3) % mod;
	dp2[0][0] = 1, dp2[0][a[0]] = 1, dp[0][0] = 2, dp[0][a[0]] = 1;
	for(int i=1; i<N; i++){
		for(int j=0; j<=sum; j++){
			if(j >= a[i]){
				dp[i][j] = (2 * dp[i-1][j] + dp[i-1][j-a[i]]) % mod;
				dp2[i][j] = (dp2[i-1][j] + dp2[i-1][j-a[i]]) % mod;
			}else{
				dp[i][j] = 2 * dp[i-1][j] % mod;
				dp2[i][j] = dp2[i-1][j];
			}
		}
	}
	mid = (sum+1)/2;
	for(int i=mid; i<=sum; i++) S = (S + dp[N-1][i]) % mod;
	if(sum % 2 == 0){
		ans = (All + 3 * dp2[N-1][mid] - 3 * S + 10 * mod) % mod;
	}else{
		ans = (All - 3 * S + mod * 10) % mod;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 422144
import java.util.Scanner;

public class Main {

  public static void main(String[] args) {
    Scanner scanner = new Scanner(System.in);
    int s = scanner.nextInt();
    int w = scanner.nextInt();
    
    if(w>=s) {
      System.out.println("unsafe");
    } else {
      System.out.println("safe");
    }

  }
}


Measured memory_bytes: 27080
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		int n = scanner.nextInt();
		scanner.nextLine();
		String s = scanner.nextLine();
		StringBuilder sb = new StringBuilder();
		int cstr = 0;
		for (int i = 0; i < n; i++) {
			char c = s.charAt(i);
			if(c == ')'){
				if(cstr>0){
					cstr--;
					sb.append(c);
				}else{
					sb.insert(0,'(');
					sb.append(c);
				}
			}else{
				cstr++;
				sb.append(c);
			}
		}
		for (int i = 0; i < cstr; i++) {
			sb.append(')');
		}
		System.out.println(sb.toString());
	}
}

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

#define ll long long
#define sd(x) scanf("%d", &(x))
#define pii pair<int, int>
#define F first
#define S second

#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
const int N = 100005;
ll C, x[N], y[N], v[N];
int n;
ll P[N], p[N];
ll Q[N], q[N];
int main(){
	cin >> n >> C;
	long long ans = 0;
	for(int i = 1; i <= n; i++){
		cin >> x[i] >> v[i];
		p[i] = p[i - 1] + v[i] - (x[i] - x[i - 1]);
		y[i] = C - x[i];
		P[i] = max(P[i - 1], p[i]);
		ans = max(ans, p[i]);
	}

	for(int j = n; j >= 1; j--){
		q[j] = q[j + 1] + v[j] - (y[j] - y[j + 1]);
		Q[j] = max(Q[j + 1], q[j]);
		ans = max(ans, Q[j]);
	}

	for(int i = 1; i <= n; i++){
		ans = max(ans, p[i] - x[i] + Q[i + 1]);
		ans = max(ans, q[i] - y[i] + P[i - 1]);
	}
	cout << ans;
}

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

using namespace std;

using ll = long long;
constexpr int mo = 1e9+7;
constexpr int inf = 1<<30;
constexpr ll infl = 1ll<<60;
constexpr ll mo2 = 998244353;

ll mpow(ll a,ll n){
    ll ret = 1;
    while(n){
        if(n&1)(ret *= a)%= mo;
        (a *= a)%=mo;
        n>>=1;
    }
    return ret%mo;
}
int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    
    vector<ll> dp(100005);
    int n,k;
    cin>>n>>k;
    ll ret = 0;
    for(int i=k;i>0;--i){
        dp[i] = mpow(k/i,n);
        for(int j=2*i;j<=k;j+=i)dp[i] -= dp[j];
        dp[i] = (dp[i]%mo+mo)%mo;
        ret += i*dp[i]%mo;
    }
    cout << ret%mo << endl;
    return 0;
}

Measured memory_bytes: 3908
// XXXX  X

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair <int, int> P;

void printVec(std::vector<int> &vec) {
  std::cout << "";
  for (auto it = vec.begin(); it != vec.end(); ++it) {
    std::cout << *it << " ";
  }
  std::cout << std::endl;
}

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

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

  // printVec(a);
  // cout << "---" << endl;
  // printVec(len);
  sort(len.begin(), len.end());
  int ans = 0;
  for(int i = 0; i < n - 1; i++) {
    ans = ans + len[i];
  }
  cout << ans << endl;
  return 0;
}


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

int main(){
  int n;
  cin >> n;
  int a[n];
  for (int i = 0; i < n; i++){
    cin >> a[i];
  }
  sort(a, a + n);
  int ans = 0;
  for (int i = 0; i < n-2; i++){
    for (int j = i+1; j < n-1; j++){
      for (int k = j+1; k < n; k++){
        if (a[i] + a[j] > a[k]){
          ans += 1;
        }
        else{
          break;
        }
      }
    }
  }

  cout << ans << endl;

}


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

int main() {
  int N, Q;
  cin >> N >> Q;
  int head = 0;
  while (Q--) {
    int c, k;
    cin >> c >> k;
    if (c == 0) { // show
      cout << (head + k - 1) % N + 1 << endl;
    } else { // swap
      head = (head + k) % N;
    }
  }
}



Measured memory_bytes: 3092
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <queue>
#include <algorithm>
#include <utility>
#include <cmath>
#include <bitset>
#include <map>
#include <cstring>
#include <cstdlib>

#define INF_LL 9000000000000000000
#define INF 2000000000

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

using namespace std;

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

class Union_find{
private:
	vector<int> par;
	vector<int> rank;
	int n;

public:
	Union_find(int a){
		n = a;
		for(int i = 0;i < n;i++){
			par.push_back(i);
			rank.push_back(0);
		}
	}

	int find(int x){
		if(par[x] == x){
			return x;
		}else{
			return par[x] = find(par[x]);
		}
	}

	void unite(int x, int y){
		x = find(x);
		y = find(y);
		if(x == y) return;

		if(rank[x] < rank[y]){
			par[x] = y;
		}else{
			par[y] = x;
			if(rank[x] == rank[y]) rank[x]++;
		}
	}

	bool same(int x, int y){
		return find(x) == find(y);
	}
};

int main(void){
	int n, m;
	ll d[110][110] = {};
	int d_t[110][110] = {};

	REP(i, 110){
		REP(j, 110){
			d[i][j] = INF;
			d[j][i] = INF;
			d_t[i][j] = INF;
			d_t[j][i] = INF;
		}
	}
	cin >> n >> m;
	REP(i, m){
		int a, b, c;
		cin >> a >> b >> c;
		a--;
		b--;
		d[a][b] = c;
		d[b][a] = c;
		d_t[a][b] = c;
	}
	REP(k, n){
		REP(i, n){
			REP(j, n){
				if(d[i][j] > d[i][k] + d[k][j]){
					d[i][j] = d[i][k] + d[k][j];
				}
			}
		}
	}
	ll res = 0;
	REP(i, n){
		REP(j, n){
			if(d[i][j] != d_t[i][j] && d_t[i][j] != INF){
				res++;
			}
		}
	}
	cout << res << endl;
}


Measured memory_bytes: 384
#include<cstdio>
#include<queue>
#include<cstring>
#include<cmath>
using namespace std;
const int B = 300000+10;
const int N = 10000+10;
const int P = 26    +100;
char a[B];

int main()
{
    int num[P];
    while(scanf("%s",a)==1)
    {
        memset(num,0,sizeof num);
        int len=strlen(a);
        for(int i=0;i<len;i++)
        {
            num[a[i]-'a']++;

        }
        int pos=-1;
        for(int i=0;i<26;i++)
        {
            if(num[i]==0)
            {
                pos=i;
                break;
            }
        }

        if(pos==-1)
        {
            printf("None\n");
        }
        else
        {
            printf("%c\n",'a'+pos);
        }

    }
return 0;
}


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

struct edge{
    int to, s;
    edge(int to, int s) : to(to), s(s) {}
};

int n, m;
vector< vector<edge> > edg;
vector< int > psv;

int f(int v){
    if(psv[v] <= 0) return -1;
    for(int i=0;i<edg[v].size();i++){
        int to = edg[v][i].to;
        int s = edg[v][i].s;
        if(psv[to] == -1){
            psv[to] = s - psv[v];
            int tmp = f(to);
            if(tmp != 0) return -tmp;
        }else if(psv[to] < s - psv[v]){
            return -1;
        }else if(psv[to] > s - psv[v]){
            return 1;
        }
    }
    return 0;
}

int main(void){
    cin >> n >> m;
    edg.assign(n, vector<edge>());
    for(int i=0;i<m;i++){
        int u, v, s;
        cin >> u >> v >> s;
        u--; v--;
        edg[u].push_back(edge(v, s));
        edg[v].push_back(edge(u, s));
    }

    int ng, ub, lb;

    ng = 0;
    lb = 1e9;
    while(ng + 1 < lb){
        int mid = (lb + ng) / 2;
        psv.assign(n, -1);
        psv[0] = mid;
        if(f(0) >= 0) lb = mid;
        else ng = mid;
    }

    ng = 1e9;
    ub = 0;
    while(ub + 1 < ng){
        int mid = (ub + ng) / 2;
        psv.assign(n, -1);
        psv[0] = mid;
        if(f(0) <= 0) ub = mid;
        else ng = mid;
    }

    int ans = ub - lb + 1;
    if(ans < 0) ans = 0;
    cout << ans << endl;
}


Measured memory_bytes: 9216
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define rep(i,n); for(long long i = 0;i < (n);i++)
using ll = long long;
using P = pair<long long,long long>;
template <class T> using vec = vector<T>;
template<class T>void sort(vec<T> &v){sort(v.begin(),v.end());}
template<class T>void rsort(vec<T> &v){sort(v.rbegin(),v.rend());}
const ll mod = 1e9+7;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    string s,t; cin >> s >> t;
    bool ok = true;
    rep(i,s.size()){
        if(s[i] != t[i])ok = false;
    }
    cout << (ok ? "Yes" : "No") << endl;

}

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

const ll INF64 = 1LL << 60;
const int INF32 = 1 << 29;
const ll MOD = 1000000007;


int main(){
	int n; cin >>n;
	map<int, int> mp;
	for(int i = 0; i < n; ++i){
		int a; cin >>a;
		++mp[a];
    }
    int ans = 0;
    for(auto it : mp){
    	if(it.second%2!=0){++ans;}
    }
    cout << ans << endl;
    return 0;
}

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

int main(){
	while(true){
		int h, w;
		cin >> h >> w;
		
		if(h == 0) break;
		
		for(int j=0; j<w; j++) cout << "#";
		cout << "\n";
		for(int i=2; i<h; i++){
			cout << "#";
			for(int j=2; j<w; j++) cout << ".";
			cout << "#\n";
		}
		for(int j=0; j<w; j++) cout << "#";
		cout << "\n\n";
	}
	cout << flush;
	
	return 0;
}


Measured memory_bytes: 3076
import core.bitop, std.algorithm, std.ascii, std.bigint, std.conv, std.math,
    std.functional, std.numeric, std.range, std.stdio, std.string, std.random,
    std.typecons, std.container, std.format;
 
// dfmt off
T lread(T = long)(){return readln.chomp.to!T();}
T[] aryread(T = long)(){return readln.split.to!(T[])();}
void scan(TList...)(ref TList Args){auto line = readln.split();
foreach (i, T; TList){T val = line[i].to!(T);Args[i] = val;}}
alias sread = () => readln.chomp();enum MOD = 10 ^^ 9 + 7;
alias PQueue = BinaryHeap!(Array!long, "a<b");
// dfmt on

void main()
{
    long N = lread();
    auto D = aryread();
    auto S = D.dup;
    S ~= 0;
    foreach (i; 0 .. N)
        S[i + 1] += S[i];
    long ans;
    foreach (i; 0 .. N)
    {
        ans += D[i] * (S[$ - 1] - S[i]);
    }
    writeln(ans);
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define repr(i,from,to) for(int (i)=(from);(i)<(to);(i)++)
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
// const bool debug=true;
const bool debug=false;
#define DEBUG if(debug==true)
#define vprint(x) for(auto a:(x)) cout << x << endl;
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const ll MOD = 1000000007;
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) { a = b; return true;}
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) { a = b; return true;}
    return false;
}
int main(void) {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    double t;
    cin >> n >> t;
    vector<vector<int>> dp(3003, vector<int>(3003,0));
    vector<pair<int,int>> ab(n,pair<int,int>(0,0));
    rep(i,n) cin>>ab[i].first>>ab[i].second;
    sort(begin(ab), end(ab));
    rep(i,n) {
        rep(j,t+2) {
            dp[i+1][j] = dp[i][j];
        }
        for(int j=0;j<t;j++) {
            if (j+ab[i].first<=t) {
                chmax(dp[i+1][j+ab[i].first], dp[i][j]+ab[i].second);
            } else {
                chmax(dp[i+1][t+1], dp[i][j]+ab[i].second);
            }
        }
    }
    int res = 0;
    rep(i,t+2) {
        chmax(res, dp[n][i]);
    }
    cout << res << endl;
    return 0;
}


Measured memory_bytes: 35712
import java.util.*;

public class Main{
  public static void main(String[] args){
    Scanner scan = new Scanner(System.in);
    int val1 = scan.nextInt();
    int val2 = scan.nextInt();
    int val3 = scan.nextInt();
    int val4 = scan.nextInt();
    
    //System.out.print(val1);
    
    if (val1*val2 > val3*val4){
      System.out.print(val1*val2);
    }else if (val1*val2 < val3*val4){
      System.out.print(val3*val4);
    }else{
      System.out.print(val1 * val2);
    }
    
  }
}

Measured memory_bytes: 35852
#include <iostream>
#include <cmath>
#include <iomanip>
typedef long long ll;
void dump(int a[],int n)
{
  for (int codeTest = 0; codeTest < n; ++codeTest) {
    if (codeTest!=0)std::cout << " ";
    std::cout << a[codeTest];
  }
  std::cout << '\n';
}
int gx[6]={1,0,-1,-1,0,1},gy[6]={0,1,1,0,-1,-1};
const double root3=std::pow(3,0.5);
void f(int x,int y,int r,int n,int m){
  if (m==n){
    double tx,ty;
    tx=2*x+y;
    ty=y*root3;
    tx*=50;
    tx/=std::pow(3,n);
    ty*=50;
    ty/=std::pow(3,n);
    std::cout <<std::fixed;
    std::cout << std::setprecision(8)<<tx<<' '<<ty<< '\n';
    //std::cout << x<<' '<<y << '\n';
  }else{
    ++m;
    f(x*3,y*3,r,n,m);
    f(x*3+gx[r],y*3+gy[r],(r+1)%6,n,m);
    f(x*3+gx[r]+gx[(r+1)%6],y*3+gy[r]+gy[(r+1)%6],(r+5)%6,n,m);
    f(x*3+2*gx[r],y*3+2*gy[r],r,n,m);
  }
}
int main(){
  int n;
  std::cin >> n;
  f(0,0,0,n,0);
  std::cout <<std::fixed;
  std::cout <<std::setprecision(8)<< 100.0<<' '<<0.0 << '\n';
}



Measured memory_bytes: 3424
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int n;
  cin >> n;
  vector<int> button(n);
  vector<int> flag(n);

  int loc = 1;
  int count = 0;
  for (int i = 0;i < n;i++) cin >> button.at(i);
  
  while(true){
    flag.at(loc-1) = 1;
    loc = button.at(loc-1);
    count++;
    
    if (flag.at(loc-1) == 1){
      cout << -1 << endl;
      break;
    }
    
    if (loc == 2){
      cout << count << endl;
      break;
    }
  }
}

Measured memory_bytes: 1024
import sys
A = sys.stdin.read().lower()
Dir = {
'a' : 0,
'b' : 0,
'c' : 0,
'd' : 0,
'e' : 0,
'f' : 0,
'g' : 0,
'h' : 0,
'i' : 0,
'j' : 0,
'k' : 0,
'l' : 0,
'm' : 0,
'n' : 0,
'o' : 0,
'p' : 0,
'q' : 0,
'r' : 0,
's' : 0,
't' : 0,
'u' : 0,
'v' : 0,
'w' : 0,
'x' : 0,
'y' : 0,
'z' : 0
}
for a in A:
	if a in Dir:
		Dir[a] += 1
for i in Dir:
	print(i,':',Dir[i])


Measured memory_bytes: 5580
#include <iostream>
#include <string>
#include <iomanip>
using namespace std;

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

	int a[n];
	double ans = 0.0;

	for (int i = 0; i < n; i++) {
		int tmp;
		cin >> tmp;
		ans += 1.0 / (double) tmp;
	}
	cout << fixed << setprecision(7) << 1.0 / ans << endl;


	return 0;
}

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

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;
	cin >> n;
	n = n % 10;
	if(n == 2 || n == 4 || n == 5 || n == 7 || n == 9){
		printf("hon\n");
	}else if(n == 0 || n == 1 || n == 6 || n == 8){
		printf("pon\n");
	}else{
		printf("bon\n");
	}
	return 0;
}


Measured memory_bytes: 3600
#include <iostream>
#include <vector>
#include <tuple>
#include <algorithm>

typedef std::tuple<int, int, int, int> A;
typedef std::tuple<int, int, int> S;
int main()
{
	while(true){
		int M, T, P, R;
		std::cin >> M >> T >> P >> R;
		if ( M == 0 && T == 0 && P == 0 && R == 0 ) break;

		std::vector<A> data;
		for ( int i = 0;i < R; ++i ) {
			int m, t, p, j;
			std::cin >> m >> t >> p >> j;
			data.push_back(A(m, t, p, j));
		}

		std::vector<S> team(T);

		for ( int i = 0; i < team.size(); ++i ) {
			int ans = 0;
			int min = 0;
			int tn = i + 1;

			std::vector<bool> pro(P, false);

			for ( int j = data.size()-1; j >= 0; j-- ) {
				if ( std::get<1>(data[j]) != tn ) continue;
				if ( std::get<3>( data[j] ) == 0 && pro[std::get<2>( data[j] )] == false ) {
					ans++;
					min += std::get<0>(data[j]);
					pro[std::get<2>( data[j] )] = true;
				}

				if ( std::get<3>( data[j] ) != 0 && pro[std::get<2>( data[j] )] == true ) {
					min += 20;
				}
			}
			std::get<0>(team[i]) = ans;
			std::get<1>(team[i]) = min;
			std::get<2>(team[i]) = tn;
		}

		std::sort(team.begin(), team.end(), [](const S& l, const S& r){ return std::get<2>(l) > std::get<2>(r); });
		std::stable_sort(team.begin(), team.end(), [](const S& l, const S& r){ return std::get<1>(l) < std::get<1>(r); });
		std::stable_sort(team.begin(), team.end(), [](const S& l, const S& r){ return std::get<0>(l) > std::get<0>(r); });
		std::cout << std::get<2>(team[0]);
		for ( int i  = 1; i < team.size(); ++i ) {
			if ( std::get<0>(team[i-1]) == std::get<0>(team[i]) && std::get<1>(team[i-1]) == std::get<1>(team[i]) ) {
				std::cout << "=";
			} else {
				std::cout << ",";
			}
			std::cout << std::get<2>(team[i]);
		}
		std::cout << std::endl;
	}


	return 0;
}

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

int main(){
    int N=0,count=0;
    cin >> N;
    char S[N]={};
    for(int i=0;i<N;i++){
        cin >> S[i];
    }
    for(int i=0;i<N-2;i++){
        if(S[i]=='A'){
            if(S[i+1]=='B'){
                if(S[i+2]=='C'){
                    count++;
                }
            }
        }
    }
    cout << count << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)   FOR(i,0,n)
#define pb emplace_back
#define mp make_pair
typedef long long ll;
typedef pair<int,int> pint;

vector<pint> vp[101];
vector<int> pe(101,-1);
set<pint> sp;
int d[101];
int inf=1000100010;
int v;
int dijkstra(int st){
    priority_queue<pint,vector<pint>,greater<pint> > pq;
    rep(i,v) d[i]=inf;
    d[st]=0;
    pq.push(make_pair(0,st));
    while(!pq.empty()){
        pint pi=pq.top();pq.pop();
        int t=pi.second;
        if(d[t]<pi.first) continue;
        for(vector<pint>::iterator it=vp[t].begin();it!=vp[t].end();++it){
            if(d[it->second]>d[t]+it->first){
                d[it->second]=d[t]+it->first;
                pe[it->second]=t;
                pq.push(make_pair(d[it->second],it->second));
            }
        }
    }
}
int main(){
    int e,s,t,ds;
    cin>>v>>e;
    rep(i,e){
        cin>>s>>t>>ds;
        vp[s-1].pb(mp(ds,t-1));
        vp[t-1].pb(mp(ds,s-1));
    }
    rep(i,v){
        pe.assign(v,-1);
        dijkstra(i);
        rep(j,v){
            if(i!=j){
                int t=j;
                for(;t!=-1;t=pe[t]){
                    if(pe[t]!=-1)sp.insert(mp(min(t,pe[t]),max(t,pe[t])));
                }
            }
        }
    }
    cout<<e-sp.size()<<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; i < (int)N; ++i)
#define all(a) (a).begin(), (a).end()

string S;
set<char> s;

int main() {
  cin >> S;

  for (char c = 'a'; c <= 'z'; c += 1) {
    s.insert(c);
  }

  for (char c : S) {
    s.erase(c);
  }

  if (s.size() == 0) {
    cout << "None";
  } else {
    cout << (*s.begin());
  }
  cout << endl;

  return 0;
}


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

using namespace std;


#define int long long


main(){

	const int INF = 1e17;

	int n, m, L; cin >> n >> m >> L;


	vector <int> a(m), b(m), c(m);


	vector < vector <int> > g(n, vector <int>(n, INF));

	for(int i = 0; i < m; i++){
		cin >> a[i] >> b[i] >> c[i];
		a[i]--; b[i]--;
		g[a[i]][b[i]] = c[i];
		g[b[i]][a[i]] = c[i];
	}


	vector < vector <int> > d(n, vector <int> (n, INF));

	for(int i = 0; i < n; i++){
		for(int j = 0; j < n; j++){
			d[i][j] = g[i][j];
		}
	}

	for(int i = 0; i < n; i++){
		for(int j = 0; j < n; j++){
			for(int k = 0; k < n; k++){
				d[j][k] = min(d[j][k], d[j][i] + d[i][k]);
			}
		}
	}


	vector < vector <int> > dp(n, vector <int> (n));


	for(int i = 0; i < n; i++){
		for(int j = 0; j < n; j++){
			if(d[i][j] <= L){
				dp[i][j] = 1;
			}else{
				dp[i][j] = INF;
			}
		}
	}


	for(int i = 0; i < n; i++){
		for(int j = 0; j < n; j++){
			for(int k = 0; k < n; k++){
				dp[j][k] = min(dp[j][k], dp[j][i] + dp[i][k]);
			}
		}
	}

	int q; cin >> q;

	int s, t;
	for(int i = 0; i < q; i++){
		cin >> s >> t;
		s--; t--;
		cout << (dp[s][t] == INF ? -1 : dp[s][t] - 1) << endl;
	}
	

	return 0;
}

Measured memory_bytes: 3584
#include <algorithm>
#include <cassert>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <utility>
#include <vector>

using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
void print() { std::cout << std::endl; }
template <typename T, typename... A> void print(const T& first, const A&... rest) { cout << sizeof...(rest) << endl; std::cout << first; if (sizeof...(rest)) std::cout << " "; print(rest...); }
template <typename... A> void print(const A&... rest) { print(rest...); }
template <typename A> void print(const std::vector<A>& v) { std::for_each(v.begin(), v.end(), [](A x) { std::cout << x << " "; }); std::cout << std::endl; }

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vector<int> a(n);
    rep(i, n) cin >> a[i];
    rep(i, n) --a[i];
    vector<int> idx(n);
    rep(i, n) idx[a[i]] = i;
    ll ans = 0;
    set<int> s{-1, n};
    for (int x = 0; x < n; ++x) {
        int i = idx[x];
        auto itr = s.lower_bound(i);
        --itr;
        ll l = *itr;
        ++itr;
        ll r = *itr;
        ans += (i - l) * (x + 1) * (r - i);
        s.insert(i);
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 11264
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
typedef unsigned long long ull;
typedef double dd;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int, int> ii;
typedef pair<ll, int> li;
typedef pair<int, ll> il;
typedef pair<ll , ll> lli;
typedef vector<ii> vii;
typedef vector<il> vil;
typedef vector<li> vli;
typedef vector<lli> vlli;
 
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define in insert
#define f0(b) for(int i=0;i<(b);i++)
#define f00(b) for(int j=0;j<(b);j++)
#define f1(b) for(int i=1;i<=(b);i++)
#define f11(b) for(int j=1;j<=(b);j++)
#define f2(a,b) for(int i=(a);i<=(b);i++)
#define f22(a,b) for(int j=(a);j<=(b);j++)
#define sf(a) scanf("%lld",&a)
#define sff(a,b) scanf("%lld %lld", &a , &b)
#define pf(a) printf("%lld\n",a)
#define pff(a,b) printf("%lld %lld\n", a , b)
#define PI 3.14159265359
#define bug printf("**!\n")
#define mem(a , b) memset(a, b ,sizeof(a))
#define front_zero(n) __builtin_clzll(n)
#define back_zero(n) __builtin_ctzll(n)
#define total_one(n) __builtin_popcountll(n)

const ll mod = (ll)998244353;
const ll maxn = (ll)2e5+5;
const int nnn = 1048590;
const int inf = numeric_limits<int>::max()-1;
//const ll INF = numeric_limits<ll>::max()-1;
const ll INF = 1e18;

ll dx[]={0,1,0,-1};
ll dy[]={1,0,-1,0};
ll dxx[]={0,1,0,-1,1,1,-1,-1};
ll dyy[]={1,0,-1,0,1,-1,1,-1};


void solve(){
	
	ll n = 5;
	ll a;
	ll ans;
	f1(n){
		cin >> a;
		if(a == 0) ans = i;
	}
	cout << ans;
	return;
}


int main() {
   
    ios_base::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL);
    ll T;
    T=1;
    //cin >> T;
    //scanf("%lld",&T);
    ll CT = 0;
    //work();
    while(T--){
    	//cout << "Case " << ++CT <<": " ;
    	//printf("Case %lld: ",++CT);
		solve();
	}
    
    return 0;
}


Measured memory_bytes: 3596
#include "bits/stdc++.h"
using namespace std;

#define ASC(vec) vec.begin(), vec.end()		// 昇順ソート 例：sort(ASC(vec));
#define DESC(vec) vec.rbegin(), vec.rend()	// 降順ソート 例:sort(DESC(vec));
#define rep(i, n) for(int i = 0; i < n; i++)
#define Rep(i, n) for(int i = 1; i < n; i++)
#define Ans(s) cout << s << endl

const int mod = 1000000007;
const int inf = (int)1e9 + 7;
const long long INF = 1LL << 60;

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

int GCD(int a, int b) { return b ? GCD(b, a % b) : a; }
int round_int(int a, int b) { return (a + (b - 1)) / b; }

typedef long long ll;
typedef vector<int> inv;

// 4,8方向に探索する際に用いる配列
//int dx[4] = { 0,  0, 1, -1 };
//int dy[4] = { 1, -1, 0,  0 };
//int dx[8] = { 1, 0, -1,  0, 1, -1, -1,  1 };
//int dy[8] = { 0, 1,  0, -1, 1,  1, -1, -1 };

constexpr auto MAX = 100010;

// ────────────────────────────────────────────────────

int main()
{
	string s;
	int k;

	cin >> s >> k;

	vector<string> hoge;

	rep(i, s.size())
	{
		Rep(j, 6)
		{
			hoge.push_back(s.substr(i, j));
		}
	}

	sort(ASC(hoge));
	hoge.erase(std::unique(hoge.begin(), hoge.end()), hoge.end());

	cout << hoge[k - 1] << endl;
}

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

#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;
const int INF = 1e9;

int main() {
  ll x, i = 0, now = 100;
  cin >> x;

  while (now < x) {
    now *= 1.01;
    i++;
  }

  cout << i << endl;
  return 0;
}


Measured memory_bytes: 3612
#include<iostream>
#include<cstdio>
#include<string>
#include<algorithm>

using namespace std;



int main(){
    string comp;
    cin >> comp;
    string s;
    std::transform(comp.begin(), comp.end(), comp.begin(), ::toupper);
    int count= 0;
    while (1) {
        cin >> s;
        if (s == "END_OF_TEXT") break;
        std::transform(s.begin(), s.end(), s.begin(), ::toupper);
        if (comp == s) {
            count++;
        }
    }
    cout << count << endl;
    return 0;
}

Measured memory_bytes: 1188
#! /usr/bin/env python3
# -*- coding: utf-8 -*-


def swap(A, i, j):
    tmp = A[i]
    A[i] = A[j]
    A[j] = tmp


def heap_size(A):
    return len(A) - 1


def parent_node(k):
    return k // 2


def left_node(k):
    return 2 * k


def right_node(k):
    return 2 * k + 1


def max_heapify(A, i):
    l = left_node(i)
    r = right_node(i)

    if l <= heap_size(A) and A[l] > A[i]:
        largest = l
    else:
        largest = i
    if r <= heap_size(A) and A[r] > A[largest]:
        largest = r

    if largest != i:
        swap(A, i, largest)
        max_heapify(A, largest)


def build_max_heap(A):
    for i in reversed(range(1, heap_size(A) // 2 + 1)):
        max_heapify(A, i)


def print_heap(A):
    for i in range(1, heap_size(A) + 1):
        print(" {}".format(A[i]), end="")
    print()


def main():
    _ = int(input())
    A = [None] + [int(x) for x in input().split()]

    build_max_heap(A)
    print_heap(A)


main()



Measured memory_bytes: 63976
#include<bits/stdc++.h>
int n,s[100000],q,t,c,i,j;
main(){
  for(scanf("%d",&n);i<n;scanf("%d",&s[i++]));
  for(scanf("%d",&q);j++<q;scanf("%d",&t),std::binary_search(s,s+n,t)&&c++);
  printf("%d\n",c);
}

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

int main() {
  string s;
  cin >> s;
  int black = 0;
  for(int i=0;i<s.size();i++) {
    if(s[i] == 'B') black++;
  }

  int index = 0;
  long long int ans = 0;
  for(int i=0;i<s.size();i++) {
    if(s[i] == 'B') {
      ans += s.size() - black + index - i;
      index++;
    }
  }

  cout << ans << endl;
}

Measured memory_bytes: 640
s = input()
if (s[0] == "0" and s[1] != "0") or (s[0] == "1" and s[1] == "0") or (s[0] == "1" and s[1] == "1") or (s[0] == "1" and s[1] == "2"):
  if (s[2] == "0" and s[3] != "0") or (s[2] == "1" and s[3] == "0") or (s[2] == "1" and s[3] == "1") or (s[2] == "1" and s[3] == "2"):
    print("AMBIGUOUS")
  else:
    print("MMYY")
else:
  if (s[2] == "0" and s[3] != "0") or (s[2] == "1" and s[3] == "0") or (s[2] == "1" and s[3] == "1") or (s[2] == "1" and s[3] == "2"):
    print("YYMM")
  else:
    print("NA")

Measured memory_bytes: 3064
n = int(input())
words = [list(input())[::-1] for _ in range(n)]
a = ord("a")
words.sort(key=lambda x: len(x))
paths = [[] for _ in range(n)]
child = [[0] * (26) for _ in range(10 ** 6 + 10)]
is_end = [False] * (10 ** 6 + 10)
nxt = 1

# trie作成パート
# nodeはnode番号を表す
# pathに各々の単語に相当するnodeの列を格納
# childはそのノードの次に行くノードを記録していく
# is_endでそのnodeで終わるものが有るかどうかをcheck
# 最終的にはもう一度見直してis_endがtrue担っている場所を数えて
# 元々、その単語自体がそこで終わっているのがn通り有るので減算して提出
for i in range(n):
    word = words[i]
    nagasa = len(word)
    node = 0
    for j in range(nagasa):
        num = ord(word[j]) - a
        paths[i].append(node)
        if child[node][num] == 0:
            child[node][num] = nxt
            nxt += 1
        node = child[node][num]
    is_end[node] = True

ans = 0
for i in range(n):
    word = words[i]
    kouho = set()
    nagasa = len(word)
    for j in range(nagasa - 1, -1, -1):
        kouho.add(word[j])
        node = paths[i][j]
        for s in kouho:
            num = ord(s) - a
            ans += is_end[child[node][num]]
print(ans - n)


Measured memory_bytes: 515884
# -*- coding: utf-8 -*-
"""
Created on Sat Apr 13 20:57:38 2019

@author: Yamazaki Kenichi
"""

N = int(input())
H = list(map(int,input().split()))

ans = 0
h0 = H[0]
for h in H:
    if h0 <= h:
        ans += 1
        h0 = h

print(ans)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
long long n,k,a[200003],f[200003];
bool check(long long ti){
	long long cnt=0;
	for(int i=0;i<n;i++)
		if(a[i]*f[i]>ti)
			cnt=cnt+(a[i]*f[i]-ti-1)/f[i]+1;
	return(cnt<=k);
}
int main(){
	cin>>n>>k;
	for(int i=0;i<n;i++)cin>>a[i];
	for(int i=0;i<n;i++)cin>>f[i];
	sort(a,a+n);
	sort(f,f+n);
	for(int i=0;i<n/2;i++)swap(f[i],f[n-i-1]);
	long long l=0,r=100000000000003;
	while(l!=r){
		long long mid=(l+r)/2;
		if(check(mid))
			r=mid;
		else
			l=mid+1;
	}
	cout<<l;
}

Measured memory_bytes: 3328
#include <iostream>
#include <string>
#include <queue>
#include <stack>
#include <algorithm>
#include <list>
#include <vector>
#include <complex>
#include <utility>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <bitset>
#include <ctime>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <cassert>
#include <cstddef>
#include <iomanip>
#include <numeric>
#include <tuple>
#include <sstream>
#include <fstream>
#include <functional>

using namespace std;
#define REP(i, n) for (int (i) = 0; (i) < (n); (i)++)
#define FOR(i, a, b) for (int (i) = (a); (i) < (b); (i)++)
#define RREP(i, a) for(int (i) = (a) - 1; (i) >= 0; (i)--)
#define FORR(i, a, b) for(int (i) = (a) - 1; (i) >= (b); (i)--)
#define DEBUG(C) cerr << #C << " = " << C << endl;
using LL = long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VL = vector<LL>;
using VVL = vector<VL>;
using VD = vector<double>;
using VVD = vector<VD>;
using PII = pair<int, int>;
using PDD = pair<double, double>;
using PLL = pair<LL, LL>;
using VPII = vector<PII>;
template<typename T> using VT = vector<T>;
#define ALL(a) begin((a)), end((a))
#define RALL(a) rbegin((a)), rend((a))
#define SORT(a) sort(ALL((a)))
#define RSORT(a) sort(RALL((a)))
#define REVERSE(a) reverse(ALL((a)))
#define MP make_pair
#define FORE(a, b) for (auto &&a : (b))
#define FIND(s, e) ((s).find(e) != (s).end())
#define EB emplace_back
template<typename T> inline bool chmax(T &a, T b){if (a < b){a = b;return true;}return false;}
template<typename T> inline bool chmin(T &a, T b){if (a > b){a = b;return true;}return false;}

const int INF = 1e9;
const int MOD = INF + 7;
const LL LLINF = 1e18;

int N, K;
LL a[1111];
VL se;

int main(void) {
    cin >> N >> K;
    REP(i, N) cin >> a[i];
    REP(i, N) {
        LL sum = 0;
        FOR(j, i, N) {
            sum += a[j];
            se.EB(sum);
        }
    }
    LL ans = 0;
    RREP(i, 62) {
        VL nse;
        FORE(e, se) {
            if (e & (1LL << i)) {
                nse.EB(e);
            }
        }
        if (nse.size() >= K) {
            se = nse;
            ans |= (1LL << i);
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 6384
#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <vector>
#include <string>
#include <queue>
#include <algorithm>
#include <math.h>
#include <utility>
#include <set>
#include <map>
#include <cstring>
#include <cstdio>
#include <stack>
#define INF 1000000000
#define rep(i,n) for(int i =0;i<n;i++)
using namespace std;
typedef long long int ll;


double ans = 0.0;
vector<int> hoge(21,0);
double g[21][21];
int n,m;

void dfs(int i, int num){
    if (num==m) {
        double piyo = 0.0;
        for (int j=0; j<n; j++) {
            for (int k=0; k<j; k++) {
                if (hoge[j]==1 and hoge[k]==1) {
                    piyo += g[j][k];
                }
            }
        }
        ans = max(ans,piyo);
        return;
    }
    for (int j=i+1;j<n ;j++) {
        if (hoge[j]==0) {
            hoge[j]=1;
            dfs(j, num + 1);
            hoge[j]=0;
        }
    }
}


int main(){
    cin >> n>>m;
    vector<pair<double, pair<double, double> > > cl(n);
    rep(i,n){
        double a,b,c;
        cin >> a >> b >> c;
        cl[i]={a,{b,c}};
    }
    for (int i=0; i<n; i++) {
        for(int j=0; j<n ; j++){
            g[i][j]=(cl[i].first-cl[j].first)*(cl[i].first-cl[j].first)+(cl[i].second.first-cl[j].second.first)*(cl[i].second.first-cl[j].second.first)+(cl[i].second.second-cl[j].second.second)*(cl[i].second.second-cl[j].second.second);
        }
    }
    for (int i=0; i<n; i++) {
        hoge[i]=1;
        dfs(i, 1);
        hoge[i]=0;
    }
    printf("%.5lf\n",ans);
}

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

int H, W;
char s[2020][2020];

int ch[2020][2020], cw[2020][2020];

signed main() {
  cin >> H >> W;
  for (int i = 1; i <= H; i++) {
    for (int j = 1; j <= W; j++) {
      cin >> s[i][j];
    }
  }

  for (int i = 1; i <= H; i++) {
    for (int j = 1; j <= W; j++) {
      if (s[i][j] == '#') {
        cw[i][j] = 0;
      } else {
        cw[i][j] += cw[i][j - 1] + 1;
      }
    }
    for (int j = W; j >= 1; j--) {
      if (s[i][j] == '#') {
        continue;
      } else {
        cw[i][j] = max(cw[i][j], cw[i][j + 1]);
      }
    }
  }

  for (int j = 1; j <= W; j++) {
    for (int i = 1; i <= H; i++) {
      if (s[i][j] == '#') {
        ch[i][j] = 0;
      } else {
        ch[i][j] += ch[i - 1][j] + 1;
      }
    }
    for (int i = H; i >= 1; i--) {
      if (s[i][j] == '#') {
        continue;
      } else {
        ch[i][j] = max(ch[i][j], ch[i + 1][j]);
      }
    }
  }

  int ans = 0;
  for (int i = 1; i <= H; i++) {
    for (int j = 1; j <= W; j++) {
      ans = max(ans, cw[i][j] + ch[i][j] - 1);
    }
  }

  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 67968
import itertools
n, m , q = map(int, input().split())

l = []
for i in range(q):
  a,b,c,d = map(int, input().split())
  l.append((a,b,c,d))
  
comb = itertools.combinations_with_replacement(range(1,m+1), n)

max_score = 0
for e in comb:
  score = 0
  for j in l:
    if e[j[1]-1]-e[j[0]-1]==j[2]:
      
      score += j[3]
  if score > max_score:
    max_score = score
print(max_score)

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


int main(){
    int a , b, c ,d ,e ;
    cin >> a >> b >> c >> d >>e ;
    if(a == 0 ){
        cout << 1 << endl;
        return 0 ;
    }
    if(b == 0 ){
        cout << 2 << endl;
        return 0 ;
    }
    if(c == 0 ){
        cout << 3 << endl;
        return 0 ;
    }
    if(d == 0 ){
        cout << 4 << endl;
        return 0 ;
    }
    if(e == 0 ){
        cout << 5 << endl;
        return 0 ;
    }
}

Measured memory_bytes: 3652
# coding: utf-8

a_to_x = ord('X') - ord('A')

char = raw_input()
ans = ""
for i in range(len(char)):
	if char[i] == 'A' or char[i] == 'B' or char[i] == 'C':
		conv = chr(ord(char[i]) + a_to_x)
	else:
		conv = chr(ord(char[i]) - 3)
	ans += conv
print(ans) 

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

#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define rep1(i, n) for (ll i = 1; i <= (ll)(n); i++)
#define INF 10000000000
#define MOD 1000000007
using ll = long long;
using Graph = vector<vector<int>>;

int main(){
    int H,W,K; cin>>H>>W>>K;
    vector<string> S(H);
    rep(i,H)cin>>S.at(i);

    ll res = (H-1)*(W-1);
    //横
    for(int bit = 0; bit < (1<<(H-1)); bit++){
        
        //横をグループ化
        set<vector<int>> G;
        vector<int> tmp;
        for(int i = 0; i < H; i++){
            tmp.push_back(i);
            if(bit&(1<<i)){
                //new;
                G.insert(tmp);
                tmp = {};
            }
        }
        G.insert(tmp);
        int num = G.size();//groupの数
        ll ans = num-1;
        vector<vector<int>> C(num,vector<int> (W,0));

        for(int w = 0; w < W; w++){
            int tmp2 = 0;
            for(auto g: G){
                for(auto i: g){
                    C.at(tmp2).at(w) += (int)(S.at(i).at(w)-'0');   
                }
                tmp2++;
            }
        }
        int flag = 0;
        vector<int> tmp1(num,0);
        for(int w = 0; w < W; w++){
            int flag2 = 0;
            for(int g = 0; g < num; g++){
                if(C.at(g).at(w)>K){
                    flag = 1;
                    break;
                }
                ll sumtmp = tmp1.at(g) + C.at(g).at(w);
                // cout<<w<<" "<<g<<" "<<sumtmp<<endl;
                if(sumtmp>K){
                    //チョコレートをわる。
                    flag2=1;
                    break;
                }
            }
            //cout<<num<<endl;
            if(flag)break;
            if(flag2)ans++;
            for(int g = 0; g < num; g++){
                if(flag2){
                    tmp1.at(g) = C.at(g).at(w);
                }else{
                    tmp1.at(g) += C.at(g).at(w);
                }
            }
        }
        if(flag)continue;
        // cout<<num<<" "<<ans<<endl;
        res = min(res,ans);
    }
    cout<<res<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <tuple>
#include <cstring>
#include <functional>
using namespace std;
typedef long long ll;
typedef pair<long long, long long> P;
#define rep(i, n) for(long long i=0; i<n; i++)
#define reps(i, s, e) for(long long i=s; i<e; i++)
#define repr(i, n) for(long long i=n-1; i>=0; i--)
#define reprs(i, s, e) for(long long i=e-1; i>=s; i--)


template<typename T>
T gcd(T n, T m){

    if(m > n)  swap(n, m);

    if(m == 0) return n;

    T r = n % m;
    if(r == 0) return m;
    else       return gcd(m, r);
}


int main(){

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

    ll n, k; cin >> n >> k;
    ll a[n];
    rep(i, n){
        cin >> a[i];
    }

    if(n == 1){
        if(k == a[0]){
            cout << "POSSIBLE" << endl;
        }
        else{
            cout << "IMPOSSIBLE" << endl;
        }
        return 0;
    }

    ll g = a[0];
    reps(i, 1, n){
        g = gcd(g, a[i]);
    }

    if(k % g == 0 && k <= *max_element(a, a+n)){
        cout << "POSSIBLE" << endl;
    }
    else{
        cout << "IMPOSSIBLE" << endl;
    }

    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define P pair<int,int>
using ll=int64_t;
using namespace std;
#define ketasuu(n) fixed<<setprecision(n)
#define btoe(p) p.begin(),p.end()
#define etob(p) p.rbegin(),p.rend()




int main(){
    int n; cin>>n;
    vector<int> p(n);
    rep(i,n){
        cin>>p[i]; p[i]--;
    }
    bool ok=false;
    int now=0,ans;
    rep(i,n+5){
        if(now==1){
            ok=true;
            ans=i;
            break;
        }
        now=p[now];
    }
    if(ok) cout<<ans<<endl;
    else cout<<-1<<endl;
}

Measured memory_bytes: 640
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>

#define pb push_back
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define ll long long



using namespace std;

void file(){
	#ifndef ONLINE_JUDGE
    	freopen("in.txt", "r", stdin);
	#endif
}
int tc;
const int N=5e5+5,M=2e6+5,MOD=1e9+7,OO=1e9;

int main(){
	ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	//file();	
	int n,m,k;
	scanf("%d %d %d",&n,&m,&k);

	std::vector<int> a(n);
	std::vector<int> b(m);
	

	for(auto &x:a)scanf("%d",&x);
	for(auto &x:b)scanf("%d",&x);
	int ans = 1e9;
	for(int i=0;i<k;i++){
		int x,y,c;
		scanf("%d %d %d",&x,&y,&c);

		ans = min(ans,a[x-1]+b[y-1]-c);
	}

	sort(all(a));
	sort(all(b));

	ans = min(ans,a[0]+b[0]);

	printf("%d\n",ans );

}		


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

#define each(i, c) for (auto& i : c)
#define unless(cond) if (!(cond))

using namespace std;

typedef long long int lli;
typedef unsigned long long ull;
typedef complex<double> point;

template<typename P, typename Q>
ostream& operator << (ostream& os, pair<P, Q> p)
{
  os << "(" << p.first << "," << p.second << ")";
  return os;
}

int main(int argc, char *argv[])
{
  int n, k;
  while (cin >> n >> k) {
    map<char, int> cnt;
    for (int i = 0; i < n; ++i) {
      string s;
      cin >> s;
      ++cnt[s[0]];
    }
    
    priority_queue<pair<int, char>> q;
    each (i, cnt) q.push(make_pair(i.second, i.first));
    
    int res = 0;
    while (k <= q.size()) {
      vector<pair<int, char>> v;
      for (int i = 0; i < k; ++i) {
        pair<int, char> p = q.top();
        q.pop();
        --p.first;
        if (p.first) v.push_back(p);
        // cout << p.second << ' ';
      }
      // cout << endl;
      each (i, v) q.push(i);
      ++res;
    }
    cout << res << endl;
  }
  return 0;
}


Measured memory_bytes: 256