akhauriyash/Code-Regression huggingface dataset:
/* BABA JAGAAAAAA  */  

#include<bits/stdc++.h>
#define pb push_back
#define un unordered_map
#define us unordered_set
#define ll long long
#define PI 3.1415926535897932384626
#define fast ios:: sync_with_stdio(false);cin.tie(NULL)
// #define l long 
using namespace std;
const int  mod= 1e9+7;
const int inf=1e9+3;

 int main()
 {
     fast;  
    string s;
     cin>>s;
      if(s[s.size()-1]=='s')
       s+="es";
      else
      s+="s";
      
       cout<<s;
      
       return 0;
     
 }
  

Measured memory_bytes: 3644
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashSet;
import java.util.List;
import java.util.Set;

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

        try (BufferedReader br = new BufferedReader(new InputStreamReader(System.in));) {
            List<String> inputNumbers = Arrays.asList(br.readLine().split(" "));
            int alicePressSecond = Integer.parseInt(inputNumbers.get(0));
            int aliceReleaseSecond = Integer.parseInt(inputNumbers.get(1));
            int bobPressSecond = Integer.parseInt(inputNumbers.get(2));
            int bobReleaseSecond = Integer.parseInt(inputNumbers.get(3));

            int maxPressSecond = bobPressSecond;
            if (alicePressSecond > bobPressSecond) {
                maxPressSecond = alicePressSecond;
            }
            
            int minReleaseSecond = bobReleaseSecond;
            if (aliceReleaseSecond < bobReleaseSecond) {
                minReleaseSecond = aliceReleaseSecond;
            }

            int ans = 0;
            if (maxPressSecond < minReleaseSecond) {
                ans = minReleaseSecond - maxPressSecond;
            }

            System.out.println(ans);
        } catch (IOException | NumberFormatException e) {
            e.printStackTrace();
            System.exit(0);
        } catch (final Exception e) {
            e.printStackTrace();
            System.exit(0);
        }
    }
}

Measured memory_bytes: 22612
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner s = new Scanner(System.in);
		int a1 = s.nextInt();
		int a2 = s.nextInt();

		String input = Integer.toString(a1) + Integer.toString(a2);
		int iValue = Integer.parseInt(input);
		double sqrt = Math.floor(Math.sqrt(iValue));

		String ret;
		if (iValue == Math.pow(sqrt, 2)) {
			ret = "Yes";
		} else {
			ret = "No";
		}

		System.out.println(ret);
	}

}

Measured memory_bytes: 21716
/*
      author  : nishi5451
      created : 14.08.2020 16:16:29
*/

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


int main(){
    string s,t;
    cin >> s >> t;
    sort(s.begin(),s.end());
    sort(t.rbegin(),t.rend());
    for(int i=0; i<min(s.size(),t.size()); i++){
        if(s[i]>t[i]){
            cout << "No" << endl;
            return 0;
        }
        else if(s[i]<t[i]){
            cout << "Yes" << endl;
            return 0;
        }
    }
    if(s.size() < t.size()) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

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

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

#define FOR(i, n, m) for (ll(i) = (m); (i) < (n); ++(i))
#define REP(i, n) FOR(i, n, 0)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll)1e15;

int main()
{
    int H, W;
    cin >> H >> W;
    pll g;
    REP(i, H)
    {
        REP(j, W)
        {
            string s;
            cin >> s;
            if (s == "snuke")
                g = pll(i, j);
        }
    }
    cout << (char)('A' + g.second) << g.first + 1 << endl;
    return 0;
}

Measured memory_bytes: 256
A,B = [int(i) for i in input().split()]
S = input()

if len(S) != A+B+1 or S[A] != '-':
    print("No")
else:
    try:
        a = int(S[0:A])
        b = int(S[A+1:A+B+1])
        print("Yes")
    except:
        print("No")

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

int main() {
  ll n,sum = 0,ans = 0;
  cin >> n;
  vector<int>a(n);
  vector<int>b(n);
  rep(i,0,n) cin >> a[i];
  rep(i,0,n) cin >> b[i];
  rep(i,0,n){
    a[i] -= b[i];
    sum += a[i];
  }
  if(sum < 0){
    cout << -1 << endl;
    return 0;
  }
  sum = 0;
  sort(a.begin(),a.end());
  rep(i,0,n){
    if(a[i] >= 0) break;
    sum += a[i];
    ans++;
  }
  if(a[0] >= 0){
    cout << 0 << endl;
    return 0;
  }
  reverse(a.begin(),a.end());
  rep(i,0,n){
    ans++;
    sum += a[i];
    if(sum >= 0) break;
  }
  cout << ans << endl;
}

Measured memory_bytes: 1024
#include<iostream>
#include<algorithm>
#include<string>
#include<cstring>
#include<cstdio>
#include<stdio.h>
#include<cmath>
#include<math.h>
#include<vector>
#include<set>
#include<queue>
#include<map>
#include<sstream>
#include<iomanip>
#define forn(i,n) for(int (i)=0;i<(n);i++)
#define pb push_back
#define mp make_pair
using namespace std;
typedef pair<int,int>pii;
typedef long long ll;
typedef pair<ll,ll> pll;
const int MAXN=100005;
const int INF=2147483647;
const ll LINF=9223372036854775807;
const int dx[]={1,-1,0,0},dy[]={0,0,1,-1};
int n;
ll ans;
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		if(i%3!=0&&i%5!=0)ans+=i;
	}
	cout<<ans;
	return 0;
}


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

using namespace std;
 
#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl;
#define DEBUG_MAT(v) cerr<<#v<<endl;for(int i=0;i<v.size();i++){for(int j=0;j<v[i].size();j++) {cerr<<v[i][j]<<" ";}cerr<<endl;}
typedef long long ll;
#define int ll
 
#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
#define pll pair<ll,ll>
template<class S, class T> pair<S, T> operator+(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first + t.first, s.second + t.second); }
template<class S, class T> pair<S, T> operator-(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first - t.first, s.second - t.second); }
template<class S, class T> ostream& operator<<(ostream& os, pair<S, T> p) { os << "(" << p.first << ", " << p.second << ")"; return os; }
#define X first
#define Y second
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define rrep(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define rrep1(i,n) for(int i=(int)(n);i>0;i--)
#define REP(i,a,b) for(int i=a;i<b;i++)
#define in(x, a, b) (a <= x && x < b)
#define all(c) c.begin(),c.end()
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a = b; return 1; } return 0; }
#define UNIQUE(v) v.erase(std::unique(v.begin(), v.end()), v.end());
const ll inf = 1000000001;
const ll INF = (ll)1e18 + 1;
const long double pi = 3.1415926535897932384626433832795028841971L;
#define Sp(p) cout<<setprecision(25)<< fixed<<p<<endl;
// int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
// int dx2[8] = { 1,1,0,-1,-1,-1,0,1 }, dy2[8] = { 0,1,1,1,0,-1,-1,-1 };
vi dx = {1, 0, -1, 0}, dy = {0, 1, 0, -1};
// vi dx2 = { 1,1,0,-1,-1,-1,0,1 }, dy2 = { 0,1,1,1,0,-1,-1,-1 };
#define fio() cin.tie(0); ios::sync_with_stdio(false);
const ll MOD = 1000000007;
// const ll MOD = 998244353;
// #define mp make_pair
//#define endl '\n'


signed main() {
    fio();
    int l, r, d;
    cin >> l >> r >> d;
    int ans = 0;
    for (int i = l; i <= r; i++) {
        if (i % d == 0) {
            ans++;
        }
    }
    cout << ans << endl;
    // int N;
    // cin >> N;
    // vi ans(N + 1);
    // rep1 (x, 100) {
    //     rep1 (y, 100) {
    //         rep1 (z, 100) {
    //             int s = x * x + y * y + z * z + x * y + y * z + z * x;
    //             if (s <= N) {
    //                 ans[s]++;
    //             }
    //         }
    //     }
    // }
    // rep1 (i, N) {
    //     cout << ans[i] << endl;
    // }
}

Measured memory_bytes: 3652
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <complex>
#include <string>
#include <sstream>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <functional>
#include <iostream>
#include <map>
#include <set>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-9
#define INF 200000000
#define sz(x) ((int)(x).size())
#define fi first
#define sec second
#define EQ(a,b) (abs((a)-(b))<EPS)
int cost[101][101];
bool used[101];
int d[101];
int n,k;
void dijkstra(int s)
{
	fill(d,d+101,INF);
	fill(used,used+101,false);
	d[s]=0;
	for(;;)
	{
		int v=-1;
		for(int u=1;u<=n;u++)
		{
			if(!(used[u])&&(v==-1||d[u]<d[v]))
			{
				v=u;
			}
		}
		if(v==-1)break;
		used[v]=true;
		for(int u=1;u<=n;u++)
		{
			d[u]=min(d[u],d[v]+cost[v][u]);
		}
	}
	return ;
}
int main()
{
	while(1)
	{
		for(int i=0;i<101;i++)
		{
			for(int j=0;j<101;j++)
			{
				cost[i][j]=INF;
			}
		}
		cin >> n >> k;
		if(n==0&&k==0)break;
		for(int i=0;i<k;i++)
		{
			int type;
			cin >> type;
			if(type)
			{
				int a,b,co;
				cin >> a >> b >> co;
				cost[a][b]=min(cost[a][b],co);
				cost[b][a]=min(cost[b][a],co);
			}
			else
			{
				int a,b;
				cin >> a >> b;
				dijkstra(a);
				if(d[b]==INF)
				{
					cout << -1 << endl;
				}
				else
				{
					cout << d[b] << endl;
				}
			}
		}
	}
	return 0;
}

Measured memory_bytes: 1200
#include <iostream>
#include <unordered_map>
#include <vector>

int main()
{
    std::string s, t;
    std::cin >> s >> t;

    std::unordered_map<char, std::vector<int>> char_pos;

    for (int i = 0; i < s.length(); i++) {
        char_pos[s[i]].push_back(i);
    }

    for (int i = 0; i < s.length(); i++) {
        char_pos[s[i]].push_back(i + s.length());
    }

    long long ans = 0;
    int ptr = 0;

    for (auto c : t) {
        if (char_pos[c].empty()) {
            std::cout << -1 << std::endl;
            return 0;
        }

        ptr = *lower_bound(char_pos[c].begin(), char_pos[c].end(), ptr) + 1;

        if (ptr >= s.length()) {
            ptr -= s.length();
            ans += s.length();
        }
    }

    ans += ptr;
    std::cout << ans << std::endl;
}


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

#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 main() {
    int n, y;
    cin >> n >> y;
    bool ans = false;
    rep(i, n+1){
        if(2*i + 4*(n-i) == y){
            ans = true;
            break;
        }
    }
    if(ans){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
        }
    return 0;    
}


Measured memory_bytes: 3620
#!/usr/bin/env pypy3


P = 10 ** 9 + 7


def count_perms(n, xs, mod=P):
    if n % 2 == 0:
        std = sorted(list(range(1, n, 2)) * 2)
    else:
        std = sorted([0] + list(range(2, n, 2)) * 2)
    if sorted(xs) != std:
        return 0
    elif n % 2 == 0:
        return pow(2, (n - 2) // 2 + 1, mod)
    else:
        return pow(2, (n - 1) // 2, mod)


def main():
    n = int(input())
    xs = [int(x) for x in input().split()]
    print(count_perms(n, xs))


if __name__ == '__main__':
    main()


Measured memory_bytes: 53480
H,W=map(int,input().split())
L=[]
for i in range(H):
    a=[]
    b=list(input())
    for j in range(W):
        if b[j]=="#":
            a.append(j)
    if a==[]:
        print("Impossible")
        exit()
    L.append([min(a),max(a)])
#print(L)
for i in range(1,H):
    if L[i][0]==L[i-1][1]:
        pass
    else:
        print("Impossible")
        exit()
print("Possible")

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

int main(){
    int a, b;
    cin >> a >> b;

    int ans = 0;
    for(int i = a; i <= b; i++){
        if(i/10000 == i%10 && (i/1000)%10 == (i%100)/10) ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
// Problem : A - Trapezoids
// Contest : AtCoder - AtCoder Beginner Contest 045
// URL : https://atcoder.jp/contests/abc045/tasks/abc045_a
// Memory Limit : 256 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include <bits/stdc++.h>

#define spc ' '
#define endl '\n'

using namespace std;


int main(){
	ios_base :: sync_with_stdio(0); cin.tie(0); cout.tie(0);
	int a,b,h;
	cin>>a>>b>>h;
	cout<<(a+b)/2.0*h;
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;
import java.util.Arrays;

public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int[] v = new int[n];
    for(int i=0; i<n; ++i) v[i] = sc.nextInt();
    Arrays.sort(v);
    double pot = v[0];
    for(int i=1; i<n; ++i) {
      pot = (v[i] + pot)/2;
    }
    System.out.println(pot);
  }
}

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

class Program
{
    static void Main(string[] args)
    {
        string N = Console.ReadLine();
        List<int> a = Console.ReadLine().Split(' ').Select(int.Parse).ToList();

        int val = a.Sum() - a.Count;
        Console.WriteLine(val);
    }
}



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

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

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

  if(400<=x&&x<=599) cout << 8;
  else if(600<=x&&x<=799) cout << 7;
  else if(800<=x&&x<=999) cout << 6;
  else if(1000<=x&&x<=1199) cout << 5;
  else if(1200<=x&&x<=1399) cout << 4;
  else if(1400<=x&&x<=1599) cout << 3;
  else if(1600<=x&&x<=1799) cout << 2;
  else if(1800<=x&&x<=1999) cout << 1;
  
}

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

using namespace std;

#define int long long
#define ll long long
typedef pair<int, int> P;
#define mod 1000000007
#define INF (1LL<<60)

#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl

int dp[411][411][41];

signed main(){

	int N, Ma, Mb;
	cin >> N >> Ma >> Mb;
	int a[40], b[40], c[40];

	rep(i, N) cin >> a[i] >> b[i] >> c[i];

	for (int n = 0; n <= N; n++){
		for (int i = 0; i <= 400; i++){
			for (int j = 0; j <= 400; j++){
				dp[i][j][n] = INF;
			}
		}
	}

	dp[0][0][0] = 0;
	for (int n = 0; n < N; n++){
		for (int i = 0; i <= 400; i++){
			for (int j = 0; j <= 400; j++){
				if (dp[i][j][n] == INF) continue;
				dp[i][j][n + 1] = min(dp[i][j][n + 1],dp[i][j][n]);
				dp[i + a[n]][j + b[n]][n + 1] = min(dp[i + a[n]][j + b[n]][n + 1]
													, dp[i][j][n] + c[n]);
			}
		}
	}

	int ans = INF;
	for (int i = 1; i <= 400; i++){
		for (int j = 1; j <= 400; j++){
			if (i*Mb == j*Ma) ans = min(ans, dp[i][j][N]);
		}
	}
	if (ans == INF) cout << -1 << endl;
	else cout << ans << endl;


	return 0;
}

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

#define vi vector<int>
#define vl vector<long long>
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define REPD(i, n) for (int i = (int)(n-1); i >= 0; i--)
#define FOR(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define FORD(i, a, b) for (int i = (int)(a); i >= (int)(b); i--)
#define INF 1e18
#define MOD 1e9+7;

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

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

struct edge {int u, v; double cost;};
struct cell {double x, y, z, r;};
const int MAX_N = 1e5+10;
edge es[MAX_N];
cell cells[MAX_N];
struct UnionFind {
    vector<int> par;
    vector<int> rank;
    UnionFind(int N) : par(N), rank(N) { 
        for(int i = 0; i < N; i++) {
            par[i] = i;
            rank[i] = 0;
        }
    }

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

    void unite(int x, int y) { 
        x = find(x); 
        y = find(y); 
        if (rank[x] > rank[y]) {
            par[y] = x;
        } else {
            par[x] = y;
            if (rank[x] == rank[y]) rank[y]++;
        }
    }

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

bool comp(const edge& e1, const edge& e2) {
    return e1.cost < e2.cost;
}

double kruskal(int n, int m) {
    UnionFind uf(n);
    sort(es, es+m, comp);
    double res = 0;
    REP(i, m) {
        if (!uf.same(es[i].u, es[i].v)) {
            uf.unite(es[i].u, es[i].v);
            res += es[i].cost;
        }
    }
    return res;
}

int main() {
    while (1) {
    	int n;
    	cin >> n;
        if (n == 0) break;
    	REP(i, n) {
        	double a, b, c, d;
        	cin >> a >> b >> c >> d;
        	cells[i] = {a, b, c, d};
    	}
    	int pos = 0;
    	FOR(i, 0, n) {
        	FOR(j, i+1, n) {
            	double cnt_d = sqrt(pow(cells[i].x-cells[j].x, 2)+pow(cells[i].y-cells[j].y, 2)+pow(cells[i].z-cells[j].z, 2));
            	double dist = cnt_d-cells[i].r-cells[j].r;
            	if (dist < 0) es[pos] = {i, j, 0};
            	else es[pos] = {i, j, dist};
            	++pos;
        	}
    	}
    	cout << fixed << setprecision(3) << kruskal(n, pos) << endl;
    }
    return 0;
}


Measured memory_bytes: 3308
#include<bits/stdc++.h>
#include<bitset>
#include<random>
#include<time.h>

using namespace std;

#define M 1000000007
#define pb push_back
#define f first
#define s second
#define rep(i, st, ed) for(int i=st; i<ed; i++)
#define repn(i, st, ed) for(int i=st; i<=ed; i++)
#define repb(i, ed, st) for(int i=ed; i>=st; i--)

typedef long long ll;
typedef unsigned long long int llt;
typedef long double ld;

const long double PI  =3.141592653589793238463;
const int N = 5e5 + 10;
const ll INF = 1LL << 60;

template<class T> void chmax(T &a,T b) { if (a<b) a=b;}
template<class T> void chmin(T &a,T b) { if (a>b) a=b;}



// Main Code

int main()
{
  char a, b;
  cin>>a>>b;
  if(a < b) puts("<");
  else if(a > b) puts(">");
  else puts("=");
}


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

int main() {
	int n,k,i;
	cin>>n>>k;
	char a[n];
	for(i=0;i<n;i++)
	{
	    cin>>a[i];
	    if(i==k-1)
	    {
	      a[i]=tolower(a[i]);  
	    }
	    cout<<a[i];
	}
	cout<<endl;
	return 0;
}

Measured memory_bytes: 256
/*

*/

#include <iostream>
#include <cstring>
#include <string>
#include <string.h>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iomanip>
using namespace std;

int main()
{
 	ios::sync_with_stdio(false);
	string N;
	int i,j,k;
	while(cin>>N)
	{
		int flag=0;
		int n=N.size();
		int C=0;
		if(n<=3)
			cout<<"WA"<<endl;
		
		else
		{
		
		int y=N[0]-'A';
		if(y!=0)
		{
			flag=1;
			
		}
		else
			for(i=1;i<n;i++)
			{
				j=N[i]-'a';
				if(j<0&&C==1)
				{
					flag=2;
					break;
				}

				if(i>=2&&i<=n-2&&C==0)
				{
					int m=N[i]-'C';
					//cout<<N[i]<<i<<endl;
					//cout<<m<<endl;
					if(m==0)
						C=1; 
				}
				if(i>n-2&&j<0)
				{
					flag=3;
					break;
				}
				if(i==1&&j<0)
				{
					flag=4;
					break;
				}
			}
		
		if(flag==0&&C==1)
			cout<<"AC"<<endl;
		else
			cout<<"WA"<<endl;
		}
		
		
		
		
	}
	
	
	
	
	
	
	return 0;
}


Measured memory_bytes: 256
#拡張ダイクストラ 
#weight,point
N,M,S=map(int,input().split())
graph={(i,j):[] for i in range(1,51) for j in range(2501)}
for _ in range(M):
    u,v,a,b=map(int,input().split())
    for i in range(a,2501):
        graph[(u,i)].append((b,(v,i-a)))
        graph[(v,i)].append((b,(u,i-a)))
for i in range(N):
    c,d=map(int,input().split())
    for j in range(2501):
        graph[(i+1,j)].append((d,(i+1,min(2500,j+c))))

dist={(i,j):float("inf")  for i in range(1,51) for j in range(2501)}

dist[(1,min(2500,S))]=0
pq=[]
import heapq
heapq.heapify(pq)
heapq.heappush(pq,(0,(1,min(2500,S))))
while pq:
    mini_dis,node=heapq.heappop(pq)
    if dist[node]<mini_dis: continue
    for w,point in graph[node]:
        if dist[point]<w:continue
        newlen=dist[node]+w
        if newlen<dist[point]:
            heapq.heappush(pq,(newlen,point))
            dist[point]=newlen
for i in range(2,N+1):
    ans=10**20
    for j in range(2501):
        ans=min(ans,dist[(i,j)])
    print(ans)

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

using namespace std;

int n, a, b;

void solve(int mask, int a, int b, vector<int>& x) {
  assert(__builtin_parity(a ^ b) == 1);
  if (__builtin_popcount(mask) == 1) {
    x.push_back(a);
    x.push_back(b);
    return;
  }
  int d = (a ^ b) & mask;
  vector<int> ones;
  vector<int> zeros;
  for (int i = 0; i < n; i++) {
    if (mask & 1 << i) {
      if (d & 1 << i) {
        ones.push_back(1 << i);
      } else {
        zeros.push_back(1 << i);
      }
    }
  }
  int u = ones[0];
  int v = (ones.size() < 2 ? zeros[0] : ones[1]);
  solve(mask ^ u, a, b ^ u ^ v, x);
  solve(mask ^ u, b ^ v, b, x);
}

int main() {
  scanf("%d %d %d", &n, &a, &b);
  if (__builtin_parity(a ^ b) == 0) {
    puts("NO");
  } else {
    puts("YES");
    vector<int> res;
    solve((1 << n) - 1, a, b, res);
    for (int i = 0; i < (int)res.size(); i++) {
      if (i > 0) {
        putchar(' ');
      }
      printf("%d", res[i]);
    }
    printf("\n");
  }
  return 0;
}

Measured memory_bytes: 1660
#include<iostream>
#include<vector>
#include<string>
#include<cstring>
#include<cmath>
#include<set>
#include<map>
#include<algorithm>
using namespace std;
int main()
{
	int a,b;
	cin>>a>>b;
	if(a>b)
		swap(a,b);
	if(a<=0&&b>=0)
	{
		cout<<"Zero"<<endl;
		return 0;
	}
	else if(a<0&&b<0)
	{
		if(abs(a-b)%2==0)
			cout<<"Negative"<<endl;
		else
			cout<<"Positive"<<endl;
	}
	else if(a>0&&b>0)
	{
		cout<<"Positive"<<endl;
	}
	else if(a==0||b==0)
		cout<<"Zero"<<endl;
	return 0;
}

Measured memory_bytes: 256
#coding:utf-8
# https://reiyw.com/post/union-find-tree-in-python/
import collections
import itertools
import operator
class UnionFind:
    def __init__(self, elems=None):
        class KeyDict(dict):
            def __missing__(self, key):
                self[key] = key
                return key

        self.parent = KeyDict()
        self.rank = collections.defaultdict(int)

        if elems is not None:
            for elem in elems:
                _, _ = self.parent[elem], self.rank[elem]

    def find(self, x):
        if self.parent[x] == x:
            return x
        else:
            self.parent[x] = self.find(self.parent[x])
            return self.parent[x]

    def unite(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if self.rank[x] < self.rank[y]:
            self.parent[x] = y
        else:
            self.parent[y] = x
        if self.rank[x] == self.rank[y]:
            self.rank[x] += 1

    def are_same(self, x, y):
        return self.find(x) == self.find(y)

    def grouper(self):
        roots = [(x, self.find(x_par)) for x, x_par in self.parent.items()]
        root = operator.itemgetter(1)
        for _, group in itertools.groupby(sorted(roots, key=root), root):
            yield [x for x, _ in group]

N,M=map(int,raw_input().split())
uf=UnionFind(range(1,N+1))
for i in range(M):
    x,y,z=map(int,raw_input().split())
    uf.unite(x,y)

from collections import defaultdict
F=set()
for i in range(1,N+1):
    F.add(uf.find(i))
print(len(F))    

Measured memory_bytes: 75164
import std.stdio, std.conv, std.string;
import std.algorithm, std.array, std.container, std.typecons;
import std.numeric, std.math;
import core.bitop;

T RD(T = string)() { static string[] ss; while(!ss.length) ss = readln.chomp.split; string res = ss[0]; ss.popFront; return res.to!T; }
string RDR()() { return readln.chomp; }
T[] ARR(T)(in string str) { return str.split.to!(T[]); }
size_t[] MAKE_IDX(alias less = "a < b", Range)(Range range) { auto idx = new size_t[](range.length); makeIndex!(less)(range, idx); return idx;}
size_t MIN_POS(alias less = "a < b", Range)(Range range) { auto r = minPos!(less)(range); return range.length - r.length; }

bool INSIDE(T)(T x, T b, T e) { return x >= b && x < e; }

long mod = pow(10, 9) + 7;
void moda(ref long x, long y) { x = (x + y) % mod; }
void mods(ref long x, long y) { x = ((x + mod) - (y % mod)) % mod; }
void modm(ref long x, long y) { x = (x * y) % mod; }

struct UnionFind
{
	void init(long n) { par = new long[](n); foreach (i; 0..n) par[i] = i; }
	long root(long i) { return par[i] == i ? i : (par[i] = root(par[i])); }
	bool same(long i, long j) { return root(i) == root(j); }
	void unite(long i, long j) { i = root(i); j = root(j); if (i == j) return; par[i] = j; }
	long[] par;
}

void main()
{
	auto N = RD!long;
	auto K = RD!long;
	long[] x, y;
	foreach (i; 0..N)
	{
		x ~= RD!long;
		y ~= RD!long;
	}
	long[] ans;
	foreach (i; 0..N)
	{
		foreach (j; i..N)
		{
			foreach (k; j..N)
			{
				foreach (l; k..N)
				{
					auto xb = min(min(min(x[i], x[j]), x[k]), x[l]);
					auto xe = max(max(max(x[i], x[j]), x[k]), x[l]);
					auto yb = min(min(min(y[i], y[j]), y[k]), y[l]);
					auto ye = max(max(max(y[i], y[j]), y[k]), y[l]);
					long cnt;
					foreach (n; 0..N)
					{
						if (INSIDE(x[n], xb, xe+1) && INSIDE(y[n], yb, ye+1))
							++cnt;
					}
					if (cnt >= K) ans ~= (xe - xb) * (ye - yb);
				}
			}
		}
	}
	ans.sort();
	
	writeln(ans[0]);
	stdout.flush();
}

Measured memory_bytes: 3324
using System;

namespace ABC174
{
    class Program
    {

        static bool Judge(long x, long y, int d)
        {
            if (Math.Sqrt(x * x + y * y) <= d)
            {
                return true;
            }
            else
            {
                return false;
            }
        }

        static void Main(string[] args)
        {
            //int a = int.Parse(Console.ReadLine());
            //string str = Console.ReadLine();
            string[] stra = Console.ReadLine().Split(' ');//2つ以上のスペース区切り入力の取得
            int n = int.Parse(stra[0]);
            int d = int.Parse(stra[1]);
            int count = 0;
            for (int i = 0; i < n; i++)
            {
                string[] strb = Console.ReadLine().Split(' ');//2つ以上のスペース区切り入力の取得
                long x = long.Parse(strb[0]);
                long y = long.Parse(strb[1]);
                if (Judge(x, y, d))
                {
                    count++;
                }
            }
            Console.WriteLine(count);
        }
    }
}


Measured memory_bytes: 40612
#include <iostream>
#include <vector>
#include <algorithm>
#include <cstdio>

using namespace std;

int main() {
  int N, M;
  cin >> N >> M;
  vector<int> P(M), Y(M);
  vector<vector<int>> data(N + 1);
  for(int i = 0; i < M; i++) cin >> P[i] >> Y[i];
  for(int i = 0; i < M; i++) {
  	data[P[i]].push_back(Y[i]);
  }
  for(int i = 0; i < N + 1; i++) {
    sort(data[i].begin(), data[i].end());
  }
  for(int i = 0; i < M; i++) {
  	int k = lower_bound(data[P[i]].begin(), data[P[i]].end(), Y[i]) - data[P[i]].begin();
    printf("%06d%06d\n", P[i], k + 1);
  }
  return 0;
}


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

bool PrimeEvaluation(int n){
	if(n==2)
		return true;
	if(n%2 == 0)
		return false;
	for(int i=2; i<=sqrt(n); i++){
		if(n%i==0)
			return false;
	}
	return true;
}

int main(){
	int N; cin >> N;
	int cnt; cnt = 0;
	for(int i=0; i<N; i++){
		int n; cin >> n;
		bool flag = PrimeEvaluation(n);
		if(flag == true) cnt ++;
	}
	cout << cnt << endl;
	return 0;
}

Measured memory_bytes: 3092
#include <bits/stdc++.h>
using namespace std;
const int mod = 1000000007;

int main() {
	int N,ans=0;
	cin >> N;
	ans += N / 500;
	N -= ans * 500;

	//cout << N << endl;
	ans *= 1000;
	ans += (N / 5)*5;
	cout << ans;
}

Measured memory_bytes: 256
#include <bits/stdc++.h> 
#define FOR(i,a,b) for(int i=(a);i<=(b);++i) 
#define RFOR(i,a,b) for(int i=(a);i>=(b);--i) 
#define REP(i,n) for(int i=0;i<(n);++i)
#define RREP(i,n) for(int i=(n);i>0;--i)
#define CI cin>> 
#define CO cout<<
#define EN <<endl 
#define all(x) (x).begin(),(x).end() 
#define asn ans
using namespace std;
template <typename T> istream& operator >> (istream& is, vector<T>& vec) { for (T& x : vec) is >> x; 	return is; }
using ll = long long;

int main() {
	int a, b; CI a >> b;
	if (a*b % 2)CO "Odd" EN;
	else CO "Even" EN;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define pii pair <int, int>
#define pll pair <ll, ll>
#define vll vector <pll>
#pragma 03
using namespace std;
ll INF = 1e18;
ll a[100005];
ll dp[100005];
int main(){
	for (int i = 0; i<100005; i++) dp[i] = INF;
	ll n, k;
	cin >> n >> k;
	for (int i = 0; i<n; i++) cin >> a[i];
	dp[0] = 0;
	dp[1] = abs(a[1] - a[0]);
	for (ll i = 2; i<n; i++){
		for (ll j = 1; j<=min(i, k); j++) dp[i] = min(dp[i], dp[i-j] + (abs(a[i] - a[i-j])));
	}
	cout << dp[n-1] << endl;
	return 0;
}
 


Measured memory_bytes: 1792
#include<stdio.h>
int main()
{
	int a,b;
	scanf("%d %d",&a,&b);
	if(a==1){
		if(b==2) printf("3\n");
		else printf("2\n");
	}
	else if(a==2){
		if(b==1) printf("3\n");
		else printf("1\n");
	}
	else{
		if(b==1) printf("2\n");
		else printf("1\n");
	}
	return 0;
}


Measured memory_bytes: 128
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include<set>
#include<map>
using namespace std;


int main() {
    int n, k;
    cin >> n >> k;
    string s;
    cin >> s;
    for(int i = 0; i < n; i++){
        if(i == k-1){
            cout << char(s[k-1] + 32); 
        }
        else{
            cout << char(s[i]);
        }
    }    
    cout << endl;
}


Measured memory_bytes: 256
#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 k, n, ans = 0;
  cin >> k >> n;
  vector<ll> d(n), a(n);
  rep(i, n) cin >> a[i];
  rep(i, n - 1) d[i] = a[i + 1] - a[i];
  d[n - 1] = k - a[n - 1] + a[0];
  sort(d.rbegin(), d.rend());

  cout << k - d[0] << endl;
  return 0;
}


Measured memory_bytes: 3328
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner s = new Scanner(System.in);
		Stack<Integer> st = new Stack<Integer>();
		while (s.hasNext()) {
			int n = s.nextInt();
			if (n == 0) {
				System.out.println(st.pop());
			} else {
				st.push(n);
			}
		}
	}
}


Measured memory_bytes: 25920
// ----- In the name of ALLAH, the Most Gracious, the Most Merciful -----

#include<bits/stdc++.h>
using namespace std;

#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define deb(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

#define memo(a,val) memset(a,val,sizeof(a))
#define NINJA ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define all(a) a.begin(),a.end()
#define fo(i,n) for(int i=0;i<n;i++)
#define Fo(i,k,n) for(int i=k;i<n;i++)
#define for1(i,n) for(int i=1;i<=n;i++)
#define dloop(i,n) for(int i=n-1;i>=0;i--)
#define iii tuple<int,int,int>
#define vi vector<int>
#define ii pair<int,int>
#define vii vector<ii>
#define int long long
#define ld long double
#define pb push_back
#define endl "\n"
#define setbits __builtin_popcountll
#define mp map<int,int>
#define F first
#define S second
#define sz(v) (int)v.size()
#define mod 1000000007
#define inf (int)1e18

const int mxn = 300004;
int cnth[mxn],cntw[mxn];
map<int,bool> h[mxn];

int32_t main(){
	NINJA;

	int r,c,m; cin >> r >> c >> m;
	fo(i,m){
		int x,y; cin >>x >> y;
		h[x][y] = 1;
		cnth[x]++;
		cntw[y]++;
	}

	int mxh=0,mxw=0;
	fo(i,mxn){
		mxh = max(mxh,cnth[i]);
		mxw = max(mxw,cntw[i]);
	}

	vi hc,wc;
	fo(i,mxn){
		if(mxh==cnth[i]) hc.pb(i);
		if(mxw==cntw[i]) wc.pb(i);
	}


	int cnt = 0;
	int mx = 0;
	fo(i,sz(hc)){
		fo(j,sz(wc)){
			cnt++;
			if(cnt>mxn*2) break;
			mx = max(mx,mxw+mxh-h[hc[i]][wc[j]]);
		}
		if(cnt>mxn*2) break;
	}

	cout << mx << endl;

	
	return 0;
}

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

int main()
{
    int i, ans;
    string s;
    cin >> s;

    int x = 0;
    for(i = 0; i < s.size(); i++)
    {
        if(i&1)
            x += s[i] == '0';
        else
            x += s[i] == '1';
    }

    ans = x;
    x = 0;
    for(i = 0; i < s.size(); i++)
    {
        if(i&1)
            x += s[i] == '1';
        else
            x += s[i] == '0';
    }

    cout << min(x, ans);
}


Measured memory_bytes: 3716
#include <stdio.h>
int main(){
	long long l, r;
	long long ans = 2019;
	scanf("%lld %lld", &l, &r);
	if(r - l + 1 >= 673) printf("0\n");
	else{
		for(long long i = l; i <= r; i++){
			for(long long j = i + 1; j <= r; j++){
				if(i * j % 2019 < ans){
					ans = i * j % 2019;
				}
			}
		}
		printf("%lld\n", ans);
	}
	return 0;
}

Measured memory_bytes: 128
n=int(input())
p=[int(i) for i in input().split()]

count=0
for i in range(1, n-1):
    a=p[i-1]
    b=p[i]
    c=p[i+1]
    p_list=[a,b,c]
    #print(p_list)
    p_list.sort()
    
    if p[i]==p_list[1]:
        count+=1
        #print(p_list)
        
print(count)

Measured memory_bytes: 8944
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <fstream>
#include <cassert>
#include <cstring>
#include <numeric>
#include <ctime>
#include <complex>
#include <bitset>
#include <random>

using namespace std;

typedef long long ll;
typedef long double ld;

//#define int ll
#define double ld
#define loop(i, n) for(int i = 0; i < (int)n; ++i)
#define loop1(i, n) for(int i = 1; i <= (int)n; ++i)
#define F first
#define S second
#define pb push_back
#define pi pair <int, int>
#define all(x) begin(x), end(x)
#define ti tuple <int, int, int>
#define Point Vect
#define mkt make_tuple
#define no {cout << "-1\n"; return;}

void solve() {
    int n; cin >> n;
    double d = ((n + 1) / 2) * 1.0 / n;
    cout << fixed << setprecision(7) << d;
}

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    solve();
    return 0;
}

Measured memory_bytes: 3792
import random
import time

def down_score(d, c, last_d, score):
    sum = 0
    for i in range(26):
        sum = sum + c[i]*(d-last_d[i])
        
    return int(score - sum)


def main():
    D = int(input())

    c = list(map(int, input().split()))

    s = [list(map(int, input().split())) for i in range(D)]

    start = time.time()
    
    last_d = [0 for i in range(26)]
    
    ans = []
    
    score1 = 0
    
    for i in range(D):
        max = 0
        idx = 0
        for j in range(26):
            if max < (s[i][j] + c[j] * (i-last_d[j])*(i-last_d[j]+1)/2) and c[j] != 0:
                max = s[i][j] + c[j] * (i-last_d[j])*(i-last_d[j]+1)/2
                idx = j
            elif max == (s[i][j] + c[j] * (i-last_d[j])*(i-last_d[j]+1)/2) and c[j] * (i-last_d[j])*(i-last_d[j]+1)/2 > c[idx]* (i-last_d[idx])*(i-last_d[idx]+1)/2 and c[j] != 0:
                idx = j
            
        last_d[idx] = i+1
        score1 += s[i][j]
        score1 = down_score(i+1,c,last_d,score1)
        
        ans.append(idx)

    random.seed(20)
    while time.time() - start < 1.9:
        idx = random.randint(0,25)
        d = random.randint(0,D-1)
        if c[idx] == 0 or ans[d-1] == idx:
            continue
        tmp = ans[d]
        ans[d] = idx
        last_d = [0 for i in range(26)]
        score2 = 0    
        for i in range(D):
            score2 += s[i][ans[i]-1]
            last_d[ans[i]-1] = i+1
            score2 = down_score(i+1, c, last_d, score2)
        
        if score1 > score2:
            ans[d] = tmp
    
    for i in range(D):
        print(ans[i]+1)  

if __name__ == "__main__":
    main()


Measured memory_bytes: 9792
using System;
using System.Collections.Generic;
using System.Linq;

namespace C
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] inputs = Console.ReadLine().Trim().ToCharArray().Select(x => int.Parse(x.ToString())).ToArray();
            List<int> l = new List<int>(inputs);
            int ans = 0;
            for (int i = 0; i < l.Count - 1; i++)
            {
                if (l.ElementAt(i) != l.ElementAt(i + 1))
                {
                    l.RemoveAt(i);
                    l.RemoveAt(i);
                    i = i < 1 ? -1 : i - 2;
                    ans += 2;
                }
            }

            Console.WriteLine(ans);

#if DEBUG
            Console.ReadKey();
#endif
        }
    }
}


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

#define rep for(int i = 0;i<n;i++)
const int MOD = 1000000007;

int main(){
       int n;cin >> n;
       string k[n];
       long long ans = 0;
       map<string,int>m;
       rep{
               string a;cin >> a;
               sort(a.begin(),a.end());
               if( m.count(a)){
                       ans += m[a];
                       m[a]++;
               }else m.insert({a,1});
               
       }
       cout << ans << endl;
}


Measured memory_bytes: 11904
using System;
using System.Collections.Generic;
using System.Linq;

namespace ConsoleApp11
{
    class Class22
    {
        static void Main()
        {
            var S = Console.ReadLine().ToArray();
            int B = 0;
            long R = 0;

            for(int i = 0; i < S.Count(); i++)
            {
                if (S[i] == 'B')
                    B += 1;
                else
                    R += B;
            }
            Console.WriteLine(R);
        }
    }
}


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

int partition(int *,int,int);

int main(){
  int n,i,index,r;
  int *a;

  scanf("%d",&n);
  a=(int *)malloc(sizeof(int)*n);

  for(i=0;i<n;i++) scanf("%d",&a[i]);
  r=n-1;
  index=partition(a,0,r);

  for(i=0;i<n;i++){
    if(i==index){
      printf("[%d]",a[i]);
    }
    else{
      printf("%d",a[i]);
    }
    if(!(i==n-1)){
	printf(" ");
    }
  }
  printf("\n");
  return 0;
}

int partition(int *a,int p,int r){
  int i=0,j;
  int temp;

  for(j=p;j<=r;j++){
    if(!(a[j]>a[r])){
      temp=a[i];
      a[i]=a[j];
      a[j]=temp;
      i++;
    }
  }
  return i-1;
}

Measured memory_bytes: 992
// AtCoder template
// sabaより胡蝶しのぶさんの方が可愛いのではないか？
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i = 0; i < n; ++i)

vector<string> ans;
int n;
void dfs(string now, int cnt, int depth){
    if(depth == n){
        ans.push_back(now);
        return;
    }
    rep(i,cnt){
        if(i+1 == cnt) dfs(now + char('a'+i), cnt+1, depth+1);
        else dfs(now + char('a'+i), cnt, depth+1);
    }
}

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

    cin >> n;
    dfs("", 1, 0);
    rep(i,ans.size()) cout << ans[i] << "\n";
}

Measured memory_bytes: 7796
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc=new Scanner(System.in);
    int k=sc.nextInt();
    int s=sc.nextInt();
    int cnt=0;
    sc.close();
    for(int i=Math.max(0,s-2*k);i<=Math.min(k,s);i++){
      for(int j=Math.max(0,s-i-k);j<=Math.min(k,s-i);j++){
        int tmp=s-i-j;
        if(tmp>=0&&tmp<=k){
          cnt++;
        }
      }
    }
    System.out.println(cnt);
  }
}

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

#define int long long

#define sqr(x) ((x) * (x))

using namespace std;

int32_t main() {
    ios_base::sync_with_stdio(0);
    int n, c;
    cin >> n >> c;
    vector<int> x(n);
    for (int i = 0; i < n; i++) {
        cin >> x[i];
    }
    vector<int> d(n);
    d[0] = 0;
    vector<pair<int, int>> a;
    a.push_back({0, 0});
    for (int i = 1; i < n; i++) {
        int ind = upper_bound(a.begin(), a.end(), make_pair(x[i], (int)(2e18))) - a.begin() - 1;
        int j = a[ind].second;
        d[i] = d[j] + sqr(x[i] - x[j]) + c;
        while (a.size() && 
                            d[i] + sqr(x[i] - a.back().first) + c <= 
                            d[a.back().second] + sqr(x[a.back().second] - a.back().first) + c) {
            a.pop_back();
        }
        if (a.size() == 0) {
            a.push_back({0, i});
        } else {
            int inter = (d[i] + sqr(x[i]) - d[a.back().second] - sqr(x[a.back().second]) + 2 * x[i] - 2 * x[a.back().second] - 1)
                                                                                        / (2 * x[i] - 2 * x[a.back().second]);
            a.push_back({inter, i});
        }
    }
    cout << d.back() << endl;
}


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

int main() {
  uint32_t a, b;
  std::cin >> a >> b;
  uint32_t count = 0;
  for (uint32_t i = 1; i <= 9; i++) {
    for (uint32_t j = 0; j <= 9; j++) {
      for (uint32_t k = 0; k <= 9; k++) {
        uint32_t n = i;
        n *= 10;
        n += j;
        n *= 10;
        n += k;
        n *= 10;
        n += j;
        n *= 10;
        n += i;
        if (a <= n && n <= b) {
          count++;
        }
      }
    }
  }

  std::cout << count << std::endl;
  return 0;
}

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

int main(){
  while(1){
    int n;
    int sum = 0;
    int flag = 0;
    int p = 0;
    string ud[100];

    cin >> n;
    if (n == 0)
      return 0;
    for(int i = 0; i < n; i++){
      cin >> ud[i];
      if(ud[i] == "ru" || ud[i] == "lu"){
        p++;
      }
      if(ud[i] == "rd" || ud[i] == "ld"){
        p--;
      }
      if(p % 2 == 0 && p != flag){
        flag = p;
        sum++;
      }
    }
    cout << sum << "\n";
  }
}



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

#define rep(i, n) for (int i = 0; i < n; ++i)
#define all(x) (x).begin(),(x).end()
#define endl "\n"

using ll = long long;
using P = pair<int,int>;
using mp =  map<int,int>;

const int MOD = 1e9 + 7;

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

    int a, b, x;
    cin >> a >> b >> x;

    x -= a;
    if(x >= 0 && x <= b) {
        cout << "YES" << endl;
    }else{
        cout << "NO" << endl;
    }

    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cmath>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<queue>
#include<stack>
#include<iomanip>

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

using namespace std;

#define debug(x) cout<<(#x)<<"="<<(x)<<", ";
#define debug1(x) debug(x) cout<<'\n';
#define debug2(x1, x2) debug(x1) debug(x2) cout<<'\n';
#define debug3(x1, x2, x3) debug(x1) debug(x2) debug(x3) cout<<'\n';
#define debug4(x1, x2, x3, x4) debug(x1) debug(x2) debug(x3) debug(x4) cout<<'\n';
#define debug5(x1, x2, x3, x4, x5) debug(x1) debug(x2) debug(x3) debug(x4) debug(x5) cout<<'\n';

#define fcout cout<<fixed<<setprecision(15)
#define repp(i,j,k) for(int i=j; i<k; ++i)
#define rep(i,j) repp(i,0,j)
#define rrep(i,j,k) for(int i=j; i>=k; --i)
#define all(x) (x).begin(), (x).end()
#define sort(x) sort(x.begin(), x.end())
#define lb(x,val) lower_bound(x.begin(), x.end(), val)
#define ub(x,val) upper_bound(x.begin(), x.end(), val)
#define pb(x) emplace_back(x);

typedef long long int lli;
typedef pair<int,int> pii;
typedef pair<lli,lli> pll;
typedef vector<int> vi;
typedef vector<lli> vl;
typedef tuple<int, int, lli> tiil;

//const lli M=998244353ll;
const lli M=1000000007ll;
const double D=1.0;

int main(){
fast_io
string s; cin>>s;
//sort(s);
if((s[0]==s[1] and s[1]==s[2]) or (s[1]==s[2] and s[2]==s[3])) cout<<"Yes";
else cout<<"No";
return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<cctype>
using namespace std;
#define rep(i,n) for (int i=0;i<(n);i++)
#define all(v) (v).begin(),(v).end()
typedef long long int ll;
#define pi 3.1415926535897932384
#define E9 1000000000
#define eps 1e-4
#define pii pair<int,int>

int main(){
  string a[3]; rep(i,3) cin >> a[i];

  int turn = 0;
  while (1){
    if (a[turn].size()==0) break;


    char c = a[turn][0];
    a[turn].erase(0,1);
    if (c=='a') turn = 0;
    else if (c=='b') turn = 1;
    else turn = 2;
    
    
  }
  
  string ABC = "ABC";
  cout << ABC[turn] << endl;
  

  // cout << fixed << setprecision(10);
  
  return 0;
}



Measured memory_bytes: 3608
#include <stdio.h>
#include <iostream>
#include <cstring>
#include <cmath>
#include <algorithm>
typedef long long ll;
ll n;
using namespace std;

int c(ll x)
{
	int tmp=0;
	while (x) x/=10,tmp++;
	return tmp;
}
int main()
{
	#ifdef Kay
		freopen ("code.in","r",stdin);
		freopen ("code.out","w",stdout);
	#endif
	cin>>n;
	ll i;int ans=1000;
	for (i=1;i*i<=n;i++)
	if (n%i==0) ans=min(ans,max(c(i),c(n/i)));
	cout<<ans;
	return 0;
}


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

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int j, k;
  string s;
  cin >> s;
  for (int i = 0; i < s.size(); i++) {
    if (s[i] == 'Z') {
      k = i + 1;
    }
  }
  for (int i = s.size() - 1; i >= 0; i--) {
    if (s[i] == 'A') {
      j = i;
    }
  }                 
  cout << k - j << '\n';
  return 0;
}

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

using namespace std;

int main(int argc, const char* argv[]) {
  int R;

  cin >> R;

  cout << (R * R * M_PI) / (1.0 * M_PI) << endl;

  return 0;
}


Measured memory_bytes: 888
#include<iostream>
using namespace std;
int main()
{
  int a,b,ans=0;
  cin>>a>>b;
  if(a==1) ans+=300000;
  if(b==1) ans+=300000;
  if(a==2) ans+=200000;
  if(b==2) ans+=200000;
  if(a==3) ans+=100000;
  if(b==3) ans+=100000;
  if(a==1&&b==1) ans+=400000;
  cout<<ans;
}

Measured memory_bytes: 3536