akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace SandboxCSharp
{
    class Solver
    {
        public void Solve()
        {
            var s = io.ScanString();

            var fail = Enumerable.Range('a', 'z').Any((c) => s.Count((e) => c == e)%2 == 1);

            if (fail)
                io.WriteLine("No");
            else
                io.WriteLine("Yes");
        }

        // =================================================
        // =================================================

        Stdio io;
        bool isjdg;
        static void Main()
        {
            var s = new Solver();
            s.Solve();
            s.io.Flush();
        }
        public Solver(Stdio _io = null)
        {
            isjdg = _io == null;
            io = _io == null ? new Stdio() : _io;
        }

        void Exit()
        {
            if (isjdg)
            {
                io.Flush();
                Environment.Exit(0);
            }
            else
                throw new HaltException();
        }
    }
    class Stdio
    {
        protected string[] stack = new string[0];
        protected int stackptr = 0;
        protected StringBuilder outbuff = new StringBuilder();

        public virtual int ScanInt()
        {
            return Check() ? int.Parse(stack[stackptr++]) : 0;
        }
        public virtual long ScanLong()
        {
            return Check() ? long.Parse(stack[stackptr++]) : 0;
        }
        public virtual string ScanString()
        {
            return Check() ? stack[stackptr++] : string.Empty;
        }
        public virtual double ScanDouble()
        {
            return Check() ? double.Parse(stack[stackptr++]) : 0;
        }
        protected virtual bool Check()
        {
            if (stackptr < stack.Length) return true;
            var l = Console.ReadLine();
            if (l == null) return false;
            stack = l.Split(' ').ToArray(); stackptr = 0;
            return Check();
        }
        public Stdio Write(long v) { return Write($"{v}"); }
        public Stdio WriteLine(long v) { return WriteLine($"{v}"); }
        public Stdio Write(string str)
        {
            outbuff.Append(str);
            return this;
        }
        public Stdio WriteLine(string str = "")
        {
            outbuff.AppendLine(str);
            return this;
        }
        public virtual Stdio Flush()
        {
            Console.Write(outbuff.ToString());
            outbuff.Clear();
            return this;
        }
    }
    class HaltException : Exception { }

}


Measured memory_bytes: 13268
#include<map>
#include<set>
#include<cmath>
#include<stack>
#include<queue>
#include<deque>
#include<ctime>
#include<vector>
#include<bitset>
#include<string>
#include<cstdio>
#include<numeric>
#include<utility>
#include<sstream>
#include<cstdlib>
#include<iomanip>
#include<cstring>
#include<iostream>
#include<algorithm>
#include<functional>
#include<unordered_map>
#define _USE_MATH_DEFINES
#define inf 999999999999999999
#define rep(i,n,m) for(lli i=(lli)(n);i<(lli)(m);++i)
#define reep(i,n,m) for(int i=(int)(n);i<=(int)(m);++i)
#define per(i,m,n) for(lli i=(int)(m)-1;i>=(int)(n);--i)
#define st(n) sort(n.begin(), n.end())
#define rev(n) reverse(n.begin(),n.end())
#define ou(S) cout << S << endl
#define pb(n) push_back(n)
#define ue(N) N.erase(unique(N.begin(),N.end()),N.end());
#define nou(S) cout << S
#define hou(S) cout << setprecision(30) << S << endl
#define vec(K,L,N,S) vector<L> K(N,S)
#define dv(K,L,N,M,S) vector<vector<L>> K(N,vector<L>(M,S))
#define tv(K,L,N,M,R,S) vector<vector<vector<L>>> K(N,vector<vector<L>>(M,vector<L>(R,S)))
#define pint pair<lli,lli>
#define paf(L,R) pair<L,R>
#define maxx 5100000
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
#define endl "\n"
typedef long long int lli;
typedef unsigned long long int uli;
const uli mod = 1e9 + 7;
using namespace std;
int main() {
    ios::sync_with_stdio(false);
    cin.tie(NULL);


    for(int i = 0; i < 5; ++i) {
        int a;
        cin >> a;
        if(a == 0) {
            cout << i + 1 << endl;
            return 0;
        }
    }
}

Measured memory_bytes: 3600
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <set>

using namespace std;


int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int h, w;
    cin >> h >> w;
    vector<string> A;
    A.reserve(h);
    for (int i = 0; i < h; ++i) {
        string row;
        cin >> row;
        A.push_back(row);
    }
    queue<pair<int, int>> q;
    for (int i = 0; i < h; ++i) {
        for (int j = 0; j < w; ++j) {
            if (A[i][j] == '#') {
                q.push({i, j});
            }
        }
    }
    int ans = 0;
    const int dx[]{1, 0, -1, 0};
    const int dy[]{0, 1, 0, -1};
    while (1) {
        queue<pair<int, int>> q1;
        while (!q.empty()) {
            auto rc = q.front();
            q.pop();
            for (int d = 0; d < 4; ++d) {
                int nr = rc.first + dx[d];
                int nc = rc.second + dy[d];
                if (0 <= nr && nr < h && 0 <= nc && nc < w && A[nr][nc] == '.') {
                    A[nr][nc] = '#';
                    q1.push({nr, nc});
                }
            }
        }
        if (q1.empty()) {
            break;
        }
        ++ans;
        q = q1;
    }
    cout << ans << endl;
    
    return 0;
}


Measured memory_bytes: 9600
import std.stdio, std.string, std.array, std.conv, std.range, std.algorithm;

void main() {
    int n = readln.chomp.to!int;
    int[] a = new int[n], b = new int[n];
    foreach (i; 0 .. n) {
        int[] tmp = readln.chomp.split.to!(int[]);
        a[i] = tmp[0], b[i] = tmp[1];
    }
    zip(a, b).sort!((t1, t2) => t1 < t2);
    foreach (i; 0 .. n) {
        writeln(a[i], " ", b[i]);
    }
}


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

a,b = input().split()
A = int(a)
B = int(b)

def judge(n):
    J = 0
    s = str(n)
    if s == s[::-1]:
        J = 1
    else:
        pass
    return J

num = 0
for i in range(A,B+1):
    j = 0
    j = judge(i)
    if j == 1:
        num += 1
    else:
        pass

print(num)

Measured memory_bytes: 3064
#include <iostream>
#include <string>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <queue>
#include <vector>
#include <stack>
#include <set>
#include <iterator>

using namespace std;

typedef long long ll;
#define mems(p) memset(p,0,sizeof(p))
#define mp make_pair

void fast()
{ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);}

int main(){
	fast();
	string s;
	cin>>s;
	int len = s.size();
	if (len<3) {
		cout<<0<<endl;
		return 0;
	}
	ll leadinga=0,ans=0;
	for (int i = 0; i < len-2; ++i)
	{
		if (s[i]=='A') ++leadinga;
		else leadinga=0;
		if (s[i]=='A' && s[i+1]=='B' && s[i+2]=='C'){
			ans+=leadinga;
			if (leadinga==1) {
				leadinga=0;
				s[i+2]='A';
			} else {
				leadinga-=2;
				s[i+1]='A';
				s[i+2]='A';
			}
		}
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 720
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define pb push_back
#define fi first
#define se second
const int N = 3e5+6;
const int mod = 1e9+107;
const ll inf = 1e16;
void solve(){
    string a,b;
    cin>>a>>b;
    int n = b.size();
    a+=b[n-1];
    if(a==b)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}
int main(){
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    int t=1;
//    cin>>t;
    while(t--)solve();
    return 0;
}


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

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

int main() {
    int n, m, l, a[105][105]{},b[105][105]{};
    string s[101];
    cin >> n >> m >> l;
    REP(i,n){
        cin >> s[i];
        REP(j,m){
            if(s[i][j]=='#'){
                a[i][j+1]++;
                b[i+1][j]++;
            }
        }
    }
    REP(i,n+1){
        REP(j,m+1){
            a[i][j+1] += a[i][j];
        }
    }
    REP(j,m+1){
        REP(i,n+1){
            b[i+1][j] += b[i][j];
        }
    }
    int ans = 0;
    REP(i,n-l+1){
        REP(j,m){
            if(b[i+l][j]-b[i][j]==0)
                ans++;
        }
    }
    REP(i,n){
        REP(j,m-l+1){
            if(a[i][j+l]-a[i][j]==0)
                ans++;
        }
    }
    cout << ans << endl;
    return 0;
}



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


void solve(std::string S){
    int a=0;
    if(S=="SUN")a= 7;
    else if(S=="SAT")a= 1;
    else if(S=="FRI")a= 2;
    else if(S=="THU")a= 3;
    else if(S=="WED")a= 4;
    else if(S=="TUE")a= 5;
    else if(S=="MON")a= 6;
    cout<<a<<endl;
}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    std::cout<<std::fixed<<std::setprecision(10);//誤差小数10桁まで
    std::string S;
    std::cin >> S;
    solve(S);
    return 0;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.List;

public class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int N = Integer.parseInt(br.readLine());

		List<Integer> t = new ArrayList<Integer>(0);
		List<Integer> x = new ArrayList<Integer>(0);
		List<Integer> y = new ArrayList<Integer>(0);

		t.add(0);
		x.add(0);
		y.add(0);

		for(int n = 0;n<N;n++){
			String[] str = br.readLine().split(" ");
			t.add(Integer.parseInt(str[0]));
			x.add(Integer.parseInt(str[1]));
			y.add(Integer.parseInt(str[2]));
		}

		for(int i = 1;i<=N;i++){
			int dis = Math.abs(x.get(i)-x.get(i-1)) + Math.abs(y.get(i) - y.get(i-1));
			int time = t.get(i) - t.get(i-1);
			if(time < dis){
				System.out.println("No");
				System.exit(0);
			}

			if(time%2 != dis%2){
				System.out.println("No");
				System.exit(0);
			}

		}
		System.out.println("Yes");

	}
}

Measured memory_bytes: 48504
#include <iostream>
#include <stdio.h>
#include <deque>
using namespace std;

struct node
{
    int x, y, z;
    node(int X = 0, int Y = 0, int Z = 0) : x(X), y(Y), z(Z){};
} n;
int H, W, Ch, Cw, Dh, Dw;
bool vis[2000][2000];
int dx[4] = {0, 0, 1, -1}, dy[4] = {1, -1, 0, 0};
int ans = 0x3f3f3f;
char s[2000][2000];
deque<node> q;
void bfs()
{

    node a(Ch, Cw, 0);
    q.push_back(a);

    while (!q.empty())
    {

        node tmp = q.front();
        q.pop_front();

        int sx = tmp.x;
        int sy = tmp.y;
        int sz = tmp.z;

        if (sx == Dh && sy == Dw)
        {
            ans = sz;
            return;
        }

        if (vis[sx][sy])

            continue;
        vis[sx][sy] = true;

        for (int i = 0; i < 4; i++)
        {
            int tx = sx + dx[i];
            int ty = sy + dy[i];

            if (tx < 1 || tx > H || ty < 1 || ty > W || s[tx][ty] == '#')
                continue;
            q.push_front({tx, ty, sz});
        }
        for (int i = sx - 2; i <= sx + 2; i++)
        {
            for (int j = sy - 2; j <= sy + 2; j++)
            {
                if (i < 1 || i > H || j < 1 || j > W || s[i][j] == '#')
                    continue;
                q.push_back({i, j, sz + 1});
            }
        }
    }
}
int main()
{

    scanf("%d%d %d%d %d%d", &H, &W, &Ch, &Cw, &Dh, &Dw);

    for (int i = 1; i <= H; i++)
    {
        scanf("%s", s[i]+1);
    }

    bfs();

    if (ans == 0x3f3f3f)
        printf("-1\n");
    else
        printf("%d\n", ans);

    return 0;
}

Measured memory_bytes: 9036
#include <iostream>
#include <string>
#include <sstream>
#include <iomanip> 
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <queue>
#include <stack>
#include <vector>
#include <map>
#include <set>
#include <functional>
#include <algorithm>
#include <unordered_map>
#include <unordered_set>
#include <bitset>

using namespace std;



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

	string s;
	cin >> s;
	if (s.substr(0, 4) == "YAKI") cout << "Yes\n";
	else cout << "No\n";

	return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define countof(array) (sizeof(array) / sizeof(array[0]))
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = (n)-1; i >= 0; --i)
#define rep2(i,n) for(int i = 1; i <= (n); ++i)
#define rrep2(i,n) for(int i = (n); i > 0; --i)
#define srep(i,s,n) for(int i = s; i < (n); ++i)
#define rsrep(i,s,n) for(int i = (n)-1; i >= s; --i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define aall(a) (a), (a)+countof(a)//for array sorting
#define raall(a) (a), (a)+countof(a), greater<>()
#define show(x) cout<<#x<<" = "<<(x)<<endl;
#define vfind(v, a) find(all(v), a) != v.end()
#define yn(f) { if (f) puts("YES"); else puts("NO"); }
#define yns(f) { if (f) puts("Yes"); else puts("No"); }
#define show_ary(...) { cout<<#__VA_ARGS__<<" = "; for (const auto& x : (__VA_ARGS__)) { cout<<x<<" "; } cout<<endl; }
#define show_pair(...) cout<<#__VA_ARGS__<<" = "<<endl; for (const auto& x : (__VA_ARGS__)) { cout<<"  "<<x.fi<<" : "<<x.se<<endl; }
#define out_ary(...) { int n = (__VA_ARGS__).size(); rep(i, n) printf("%d%s", (__VA_ARGS__)[i], i != n-1 ? " " : "\n"); }
#define argmax(v) distance((v).begin(), max_element(all(v)))
#define argmin(v) distance((v).begin(), min_element(all(v)))
#define vmax(v) *max_element(all(v))
#define vmin(v) *min_element(all(v))
typedef long long int ll;
typedef pair<int, int> P;
typedef vector<P> vpair;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<double> vdouble;
typedef vector<string> vstr;
typedef vector<bool> vbool;
typedef vector<vint> vvint;
typedef vector<vll> vvll;
typedef vector<vstr> vvstr;
typedef vector<vbool> vvbool;
const ll LINF = 2000000000000000000ll;
const int INF = 1000000100;
const ll MOD = 1e9+7;


vint t;
vint edge[200005];
vbool c;
void dfs(int v, int p) {
    c[v] = false;
    for (int u : edge[v]) {
        if (c[u]) {
            t[u] += p;
            c[u] = false;
            dfs(u, t[u]);
        }
    }
}

int main() {
    int n, q;
    cin >> n >> q;
    t.resize(n, 0);
    c.resize(n, true);
    rep(i, n-1) {
        int a, b;
        cin >> a >> b;
        --a;
        --b;
        edge[a].push_back(b);
        edge[b].push_back(a);
    }
    rep(i, q) {
        int p, x;
        cin >> p >> x;
        --p;
        t[p] += x;
    }
    dfs(0, t[0]);

    rep(i, n) printf("%d%s", t[i], i != n-1 ? " " : "\n");
    return 0;
}

Measured memory_bytes: 23552
def main():
    s = input()
    k = int(input())

    li = []
    same_str_num = 1
    for i in range(1, len(s)):
        if s[i] == s[i-1]:
            same_str_num += 1
        else:
            li.append(same_str_num)
            same_str_num = 1
    li.append(same_str_num)

    if len(li) == 1:
        print(li[0]*k//2)
        return

    if s[0] == s[-1]:
        ans = li[0]//2 + li[-1]//2
        ans += ((li.pop(0) + li.pop())//2) * (k-1)
    else:
        ans = 0
    for i in li:
        ans += (i//2)*k
    print(ans)






if __name__ == '__main__':
    main()


Measured memory_bytes: 38256
#include <bits/stdc++.h>
#include <iostream>
#include <functional>
#include <vector>
#include <stdio.h>
#include <queue>
#include <string.h>
#include <math.h>
using namespace std;
#define rep(i,a,n) for (int i=a;i<=n;i++)
#define rep1(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=a;i>=n;i--)
#define per1(i,a,n) for (int i=a;i>n;i--)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
#define endl "\n"
#define pi 3.14159265358979323846264338327950288419716939937510
#define IOS cin.sync_with_stdio(false);cin.tie(0);cout.tie(0);
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const ll mod=1000000007;
const int inf=0x3f3f3f3f;
const ll INF=0x3f3f3f3f3f3f3f3f;
ll qpow(ll a,ll b){ll s=1;while(b>0){if(b%2==1){s=s*a;}a=a*a;b=b>>1;}return s;}
ll qpowmod(ll a, ll b, ll c){ll res, t;res=1;t=a%c;while(b){if(b & 1){res=res*t%c;}t=t*t%c;b>>=1;}return res;}
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
inline long long read(){long long k=0,f=1;char ch=getchar();while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}while(ch>='0'&&ch<='9'){k=k*10+ch-'0';ch=getchar();}return k*f;}
inline void write(long long x){if(x<0)x=-x,putchar('-');if(x>9)write(x/10);putchar(x%10+'0');}
// head
ll q,t,f,flag,len,l,r;
char c;
string s;
struct nod
{
    ll pos;
    char c;
}node[400005];
bool cmp(nod a,nod b)
{
    return a.pos<b.pos;
}
int main()
{
    //IOS;
    cin>>s>>q;
    len=s.length();
    for(int i=0;i<=len-1;i++)
    {
        node[i].pos=i;
        node[i].c=s[i];
    }
    l=-1;r=len;
    while(q--)
    {
        cin>>t;
        if(t==1)
        {
            flag++;
        }
        else
        {
            cin>>f>>c;
            if((f+flag)%2==1)
            {
                node[len].pos=l;
                node[len].c=c;
                len++;
                l--;
            }
            else
            {
                node[len].pos=r;
                node[len].c=c;
                len++;
                r++;
            }
        }
    }
    sort(node,node+len,cmp);
    if(flag%2==0)
    {
        for(int i=0; i<=len-1; i++)
        {
            cout<<node[i].c;
        }
    }
    else
    {
        for(int i=len-1; i>=0; i--)
        {
            cout<<node[i].c;
        }
    }
    return 0;
}
/*

*/


Measured memory_bytes: 6912
#include <iostream> 
#include <string> 
#include <vector> 
#include <cmath> 
#include <algorithm> 
#include <cstdlib> 
#include <ctime> 
#include <cstdio> 
#include <functional> 
#include <set> 
#include <sstream> 
#include <cctype>
#include <stack>
#include <queue>
#include <cstring>
#include <map>
 
using namespace std;

int main(){

	long long n;
	cin>>n;

	vector<long long> a(n);
	long long sum=0;
	for(int i=0;i<n;i++){
		cin>>a[i];
		sum+=a[i];
	}

	
	long long sunuke=a[0],arai=sum-a[0];
	long long res=abs(sunuke-arai);
	for(int i=1;i<n-1;i++){
		res=min(res,abs(sunuke-arai));
		sunuke+=a[i];
		arai-=a[i];
	}
	cout<<res<<endl;

	return 0;
}


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

int main() {
    int w, h, x, y, r;
    cin >> w >> h >> x >> y >> r;
    if(x - r < 0 || y - r < 0 || x + r > w || y + r > h) {
        cout << "No" << '\n';
    } else {
        cout << "Yes" << '\n';
    }
}



Measured memory_bytes: 3084
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<set>
#include<map>
#include<iterator>
#include<stack>
#include<queue>
#include<utility>
#include<functional>
#include<bitset>
#include<numeric>
#include<cstring>
#include<tuple>
using namespace std;

const int N = 1e5 + 5;
int n, k, q, player;
vector< int > arr( N ), cnt( N, 0 );

int main( void )
{
	ios :: sync_with_stdio( 0 );
	cin.tie( 0 );
	
	cin >> n >> k >> q;
	fill( arr.begin() + 1, arr.begin() + n + 1, k );
	for( int i = 1; i <= q; ++i )
	{
		cin >> player;
		++cnt[ player ];
	}
	for( int i = 1; i <= n; ++i )
	{
		arr[ i ] -= ( q - cnt[ i ] );		
	}
	for( int i = 1; i <= n; ++i )
	{
		cout << ( arr[ i ] > 0 ? "Yes" : "No" ) << "\n";		
	}
	return 0;
}

Measured memory_bytes: 1408
#include<stdio.h>

int search(int A[], int n, int key)
{
	int i = 0;
	A[n] = key;
	while (A[i] != key) i++;
	return i != n;
}

int main(void)
{
	int i, n, A[10000+1], q, key, sum = 0;
	
	scanf("%d", &n);
	for (i = 0; i < n; i++) scanf("%d", &A[i]);
	
	scanf("%d", &q);
	for (i = 0; i < q; i++) 
	{
		scanf("%d", &key);
		if(search(A, n, key))sum++;
	}
	printf("%d\n", sum);
	
	return 0;
}




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

#define REP(i,n) for(ll i=0;i<n;++i)
#define RREP(i,n) for(ll i=n-1;i>=0;--i)
#define FOR(i,m,n) for(ll i=m;i<n;++i)
#define RFOR(i,m,n) for(ll i=n-1;i>=m;--i)
#define ALL(v) (v).begin(),(v).end()
#define PB(a) push_back(a)
#define UNIQUE(v) v.erase(unique(ALL(v)),v.end());
#define DUMP(v) REP(aa, (v).size()) { cout << v[a]; if (a != v.size() - 1)cout << " "; else cout << endl; }
#define INF 1000000001ll
#define MOD 1000000007ll
#define EPS 1e-9

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


using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
ll max(ll a, int b) { return max(a, ll(b)); }
ll max(int a, ll b) { return max(ll(a), b); }
ll min(ll a, int b) { return min(a, ll(b)); }
ll min(int a, ll b) { return min(ll(a), b); }
///(?´????????`)(?´????????`)(?´????????`)(?´????????`)(?´????????`)(?´????????`)///
int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n, m;
	cin >> n >> m;
	vector<double> l(n), a(n), b(n);
	REP(i, n) {
		cin >> l[i] >> a[i] >> b[i];
	}
	double ans = 0;
	REP(i, 1 << n){
		set<int> s;
		REP(j, n) {
			if((1 << j)&i)s.insert(j);
		}
		if (s.size() != m)continue;
		double tmp = 0;
		for (auto x : s) {
			for (auto y : s) {
				
				if (x == y)continue;
				tmp += (l[x] - l[y])*(l[x] - l[y]) + (a[x] - a[y])*(a[x] - a[y]) + (b[x] - b[y])*(b[x] - b[y]);
			}
		}
		ans = max(ans, tmp);
	}
	cout << fixed << setprecision(12) << ans/2 << endl;
	return 0;
}

Measured memory_bytes: 3288
from sys import stdin, stdout
import heapq
import cProfile
from collections import Counter, defaultdict, deque
from functools import reduce
import math
from bisect import bisect,bisect_right,bisect_left

def get_int():
    return int(stdin.readline().strip())


def get_tuple():
    return map(int, stdin.readline().split())


def get_list():
    return list(map(int, stdin.readline().split()))

n = get_int()
x = math.ceil(n/1000)
print(x*1000-n)

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

int main() {
  int N, M;
  map<int, vector<int>> B;
  cin >> N >> M;
  for (int n = 0; n < N; n++) {
    int a, b;
    cin >> a >> b;
    B[a].push_back(b);
  }
  ll ans = 0;
  priority_queue<int> pq;
  for (int m = 1; m <= M; m++) {
    for (int i = 0, len = B[m].size(); i < len; i++) {
      pq.push(B[m][i]);
    }
    if (!pq.empty()) {
      ans += pq.top();
      pq.pop();
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 10880
#include <iostream>
#include <algorithm>
#include <string>
#include <cstring>
#include <cmath>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#define fi first
#define se second
#define pb push_back
#define endl "\n"
#define fastio ios_base::sync_with_stdio(false); cin.tie(nullptr);
#define all(x) x.begin(),x.end()
#define y1 omg
#define INF 987654321
using namespace std;
typedef long long ll;
typedef pair<int, int> ii;
typedef pair<int, ii> iii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef vector<vi> vvi;
typedef vector<ll> vl;

int m, n, t;

int main() {
	cin >> n >> m;
	for (int i = 0; i < m; i++) {
		cin >> t;
		n -= t;
	}
	if (n < 0) cout << -1;
	else cout << n;
}

Measured memory_bytes: 3588
n=int(input())
s=input()

ans=s.count("R")*s.count("B")*s.count("G")
for i in range(n):
    for j in range(i,n):
        k=2*j-i
        if k>=n:break
        if s[i]!=s[j] and s[j]!=s[k] and s[i]!=s[k]:
            ans -=1

print(ans)

Measured memory_bytes: 73572
#include<iostream>                          
#include<vector>                    
 #include<bits/stdc++.h>

#define mod 1000000009
#define pi 3.14159265358979
#define  PRE(x,p) cout<<setprecision(x)<<p; 
#define pb push_back
#define mp make_pair
#define f first
#define s second
#define endl "\n"
#define high INT_MAX
#define low INT_MIN
#define ll long long int
using namespace std;
 
void solve() 
{ 
   ll n;
  cin>>n;
  if(n%1000 ==0)
    cout<<0;
  else
    cout<<1000- n%1000;
}
 
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
ll t=1;
//cin>>t;
while(t--)
solve();
 
return 0;
}

Measured memory_bytes: 3604
n, m, l = map(int, input().split())
A = [ list(map(int, input().split())) for _ in range(n) ] 
B = [ list(map(int, input().split())) for _ in range(m) ] 
multiply = [[0] * l for _ in range(n)]

for i in range(n):
    for j in range(l):
        for k in range(m):
            multiply[i][j] += B[k][j] * A[i][k]

for line in multiply:
    print(' '.join(map(str, line)))


Measured memory_bytes: 6900
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
import copy

def main():
    N = int(input())
    T = list(map(int, input().split()))
    M = int(input())
    for _ in range(M):
        P, X = map(int, input().split())
        result = T.copy()
        result[P - 1] = X
        print(sum(result))


if __name__ == "__main__":
    main()


Measured memory_bytes: 3444
#include <cstdio>
#include <vector>
#include <algorithm>
#include <cstring>
#include <string>
#include <cctype>
#include <sstream>
#include <cmath>
#include <climits>
#include <set>
#include <iostream>
#include <map>
#include <functional>
#include <cstdlib>
#include <numeric>
#include <queue>
#include <complex>

using namespace std;

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

typedef vector<int> vi;
typedef pair<int, int> pii;
typedef complex<double> Point;

int main()
{
	char str[128];
	while(scanf("%s", str) != EOF){
		rep(i, strlen(str)){
			if(str[i] == '@'){
				rep(j, str[i+1]-'0')
					putchar(str[i+2]);
				i += 2;
			}else
				putchar(str[i]);
		}
		puts("");
	}

	return 0;
}

Measured memory_bytes: 0
#include <stdio.h>
#include <math.h>

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

	int min = pow(10, 6);
	for(int i = 0; i < n; i++){
		int clock, counter, tmp;
		if(i == 0){
			clock = a[i+1] - a[i];
			counter = a[i] + (k - a[n-1]);
		}else if(i == n-1){
			clock = a[0] + (k - a[i]);
			counter = a[i] - a[i-1];
		}else{
			clock = a[i+1] - a[i];
			counter = a[i] - a[i-1];
		}
		tmp = k - fmax(clock, counter);
		if(tmp < min){
			min = tmp;
		}
	}
	printf("%d\n", min);
}


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

using namespace std;

bool center3(const pair<long double, long double>& p1,
             const pair<long double, long double>& p2,
             const pair<long double, long double>& p3,
             pair<long double, long double>& center,
             long double& r2) {
  auto ax = (p1.first + p2.first) / 2;
  auto ay = (p1.second + p2.second) / 2;

  auto ux = (p1.second - p2.second);

  auto uy = (p2.first - p1.first);

  auto bx = (p2.first + p3.first) / 2;
  auto by = (p2.second + p3.second) / 2;

  auto vx = (p2.second - p3.second);
  auto vy = (p3.first - p2.first);
  auto dx = ax - bx;
  auto dy = ay - by;
  auto vu = vx * uy - vy * ux;
  if (!vu)
    return false;
  auto g = (dx * uy - dy * ux) / vu;
  center = {
      bx + g * vx,
      by + g * vy,
  };
  auto ddx = p1.first - center.first;
  auto ddy = p1.second - center.second;
  r2 = ddx * ddx + ddy * ddy;
  return true;
}

vector<pair<long double, long double>> points;

bool contains_all(const pair<long double, long double>& c, long double r2) {
  for (auto&& p : points) {
    auto dx = p.first - c.first;
    auto dy = p.second - c.second;
    if (dx * dx + dy * dy - r2 > 0.0001) {
      return false;
    }
  }
  return true;
}

void solve() {
  int n;
  cin >> n;
  points.reserve(n);
  for (int i = 0; i < n; ++i) {
    int x, y;
    cin >> x >> y;
    points.emplace_back(x, y);
  }
  long double min_r2 = (long double)INT_MAX;

  for (size_t i = 0; i + 1 < points.size(); ++i) {
    for (size_t j = i + 1; j < points.size(); ++j) {
      auto cx = (points[i].first + points[j].first) / 2.;
      auto cy = (points[i].second + points[j].second) / 2.;
      auto dx = points[i].first - cx;
      auto dy = points[i].second - cy;
      auto r2 = dx * dx + dy * dy;
      if (0 <= r2 && r2 < min_r2 && contains_all({cx, cy}, r2)) {
        min_r2 = r2;
      }
    }
  }

  for (size_t i = 0; i + 2 < points.size(); ++i) {
    for (size_t j = i + 1; j + 1 < points.size(); ++j) {
      for (size_t k = j + 1; k < points.size(); ++k) {
        pair<long double, long double> c;
        long double r2;
        if (center3(points[i], points[j], points[k], c, r2) && 0 <= r2 &&
            r2 < min_r2 && contains_all(c, r2)) {
          min_r2 = r2;
        }
      }
    }
  }

  cout << setprecision(15) << sqrt(min_r2) << endl;
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  solve();
}



Measured memory_bytes: 256
#include <algorithm>
#include <complex>
#include <cstdlib>
#include <ctime>
#include <time.h>
#include <iomanip>
#include <iostream>
#include <map>
#include <math.h>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>

using namespace std;
#define SAY_YES cout << "YES" << endl;
#define SAY_Yes cout << "Yes" << endl;
#define SAY_NO cout << "NO" << endl;
#define SAY_No cout << "No" << endl;
#define IFYES(TRUE_OR_FALSE)   \
    if (TRUE_OR_FALSE)         \
    {                          \
        cout << "YES" << endl; \
    }                          \
    else                       \
    {                          \
        cout << "NO" << endl;  \
    }
#define IFYes(TRUE_OR_FALSE)   \
    if (TRUE_OR_FALSE)         \
    {                          \
        cout << "Yes" << endl; \
    }                          \
    else                       \
    {                          \
        cout << "No" << endl;  \
    }
#define IFyes(TRUE_OR_FALSE)   \
    if (TRUE_OR_FALSE)         \
    {                          \
        cout << "yes" << endl; \
    }                          \
    else                       \
    {                          \
        cout << "no" << endl;  \
    }
#define DEBUG_OUTPUT_ARRAY(XXX, ONE)                            \
    for (int i = 0; i < (ONE); i++)                             \
    {                                                           \
        cout << "DEBUG: i = " << i << " -> " << XXX[i] << endl; \
    }
#define DEBUG_OUTPUT_ARRAY2(XXX, ONE, TWO)                             \
    for (int i = 0; i < (ONE); i++)                                    \
    {                                                                  \
        cout << "<<< i = " << i << " >>>" << endl;                     \
        for (int j = 0; j < (TWO); j++)                                \
        {                                                              \
            cout << "DEBUG: j = " << j << " -> " << XXX[i][j] << endl; \
        }                                                              \
    }
#define DEBUG_OUTPUT_ARRAY2_BOX(XXX, ONE, TWO) \
    for (int i = 0; i < (ONE); i++)            \
    {                                          \
        cout << i << "  ";                     \
        for (int j = 0; j < (TWO); j++)        \
        {                                      \
            cout << XXX[i][j] << " ";          \
        }                                      \
        cout << endl;                          \
    }

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


const long long int mod = 1000000007;
const long long int INF = 99999999999999999;

long long int N,M;

int main()
{
    cout << fixed << setprecision(18);
    cin>>N;
    cout<<N*(N+1)/2<<endl;
}


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

int main(){
    int n, m, l;
    cin >> n >> m >> l;
    long long a[n][m], b[m][l], c[n][l]={};   //intだと足りないのでlonglong
    for (int i=0; i<n; i++){
        for (int j=0; j<m; j++){
            cin >> a[i][j];
        }
    }
    for (int i=0; i<m; i++){
        for (int j=0; j<l; j++){
            cin >> b[i][j];
        }
    }
    for (int i=0; i<n; i++){
        for (int k=0; k<l; k++){
            for (int j=0; j<m; j++){
                c[i][k] += a[i][j] * b[j][k];
            }
        }
    }
    for (int i=0; i<n; i++){
        for (int k=0; k<l; k++){
            cout << c[i][k];
            if (k<l-1) cout << " ";
        }
        cout << endl;
    }
    return 0;
}


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

typedef long long ll;

int main() {
	ll n;
	cin >> n;
	vector<pair<int, int>> a;
	for (ll i = 2; i * i <= n; ++i) {
		if (n % i == 0) {
			int cnt = 0;
			while (n % i == 0) {
				n /= i;
				cnt++;
			}
			a.push_back({i, cnt});
		}
	} 
	if (n > 1)
		a.push_back({n, 1});
	int res = 0;
	for (auto& [p, k] : a) {
		int cnt = 0, sum = 0;
		for (int i = 1; sum + i <= k; ++i) {
			sum += i;
			cnt++;
		}
		res += cnt;
	}
	cout << res << '\n';
}

Measured memory_bytes: 3628
import sys
def input(): return sys.stdin.readline().rstrip()
import fractions
def lcm(a,b):
    f=a*b//fractions.gcd(a,b)
    return f
def main():
    a,b=map(int,input().split())
    print(lcm(a,b))

if __name__=='__main__':
    main()

Measured memory_bytes: 5052
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cassert>
#include <cstring>
#include <string>
#include <vector>
#include <random>
#include <bitset>
#include <queue>
#include <cmath>
#include <unordered_map>
#include <set>
#include <map>
#define INCANT cin.tie(0), cout.tie(0), ios::sync_with_stdio(0), cout << fixed << setprecision(20);
#define rep(i,n) for (int i=0; i<n;++i)
#define ALL(a)  (a).begin(),(a).end()
#define PI 3.14159265358979
typedef long long ll;
using namespace std;
const ll MOD = 1e9+7LL;
const int INF = 2e9;
int H, W, K;
ll DP[101][10]; // 残りn本の段階でiにいる場合の数
ll Memo[9]; // 本数がidxのときに何通りあるか 

void calc() {
  rep(i, H+1) {
    if (i==0) continue;
    rep(j, W) {
      DP[i][j] += DP[i-1][j]*Memo[j]*Memo[W-j-1]; // 左右に棒を置かない
      if (j>0) DP[i][j] += DP[i-1][j-1]*Memo[W-j-1]*Memo[j-1]; // 左に棒を置く
      if (j<W-1) DP[i][j] += DP[i-1][j+1]*Memo[W-j-2]*Memo[j]; // 右に棒を置く
      DP[i][j]%=MOD;
    }
  }
}

int main() {
  INCANT;
  cin >> H >> W >> K;
  if (W==1) {
    cout << 1 << endl;
    return 0;
  }
  Memo[0] = 1;
  Memo[1] = 1;
  rep(i, W) Memo[i+2] = Memo[i]+Memo[i+1];
  DP[0][0] = 1ll;
  calc();
  cout << DP[H][K-1] << "\n";
  return 0;
}


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

using namespace std;

#define all(x) (x).begin(),(x).end()
#define I(x, a) for(auto x : (a))
#define ins insert
#define F(i, l, r) for(auto i = (l); i < (r); i++)
#define DF(i, l, r) for(auto i = (l); i >= (r); i--)
#define E(i, l, r) for(auto i = (l); i <= (r); i++)
#define pb push_back
#define X first
#define Y second
#define mp make_pair
#define ret return
#define brk break
#define cont continue
#define move fjgjgjgjghd

typedef long long ll;
typedef unsigned long long ull;
typedef long double dbl;
typedef pair<int, int> pii;

const int N = (int)1e5 + 5;

int dp[N];
int h[N];
int n;

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cin >> n;
	F(i, 0, n)cin >> h[i];
	fill(dp, dp + n, N * (int)1e4);
	dp[0] = 0;
	F(i, 0, n - 1){
		dp[i + 1] = min(dp[i + 1], dp[i] + abs(h[i] - h[i + 1]));
		dp[i + 2] = min(dp[i + 2], dp[i] + abs(h[i] - h[i + 2]));
	}
	cout << dp[n - 1] << endl;
	return 0;
}


Measured memory_bytes: 1024
arr = Array.new(6, 0)

gets.to_i.times do
  case gets.to_f
  when 0...165
    arr[0] += 1
  when 165...170
    arr[1] += 1
  when 170...175
    arr[2] += 1
  when 175...180
    arr[3] += 1
  when 180...185
    arr[4] += 1
  else
    arr[5] += 1
  end
    
end

6.times do |i|
 puts "#{i + 1}:" + "*" * arr[i] 
end

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

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

    bool ok = true;
    string t = s;
    reverse(t.begin(), t.end());
    if (s != t)
        ok = false;

    int n = s.size();
    t = s.substr(0, (n - 1) / 2);
    string r = t;
    reverse(r.begin(), r.end());
    if (t != r)
        ok = false;

    t = s.substr((n + 3) / 2 - 1);
    r = t;
    reverse(r.begin(), r.end());
    if (t != r)
        ok = false;

    if (ok)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;

    return 0;
}

Measured memory_bytes: 3628
n,q = map(int,input().split())
s = input()
lr = [list(map(int,input().split())) for _ in range(q)]

acli = [0]*n
for i in range(1,n):
    if s[i] == "C" and s[i-1] == "A":
        acli[i] = acli[i-1] + 1
    else:
        acli[i] = acli[i-1]

for x in lr:
    print(acli[x[1]-1]-acli[x[0]-1])

Measured memory_bytes: 29864
#!/usr/bin/perl

$line = 0;
while (<>) {
    chomp;
    if($line == 0) {
        $n = $_;
    } else {
        @{$a->[$line - 1]} = split //, $_;
    }
    $line++;
}

foreach (0 .. $#{$a->[0]}) {
    $c = $a->[0]->[$_];
    $h->[0]->{$c}++;
}

foreach $i (1 .. $n - 1) {
    foreach $j (0 .. $#{$a->[$i]}) {
        $c = $a->[$i]->[$j];
        if(defined $h->[$i - 1]->{$c}) {
            if($h->[$i - 1]->{$c} <= 1) {
                undef $h->[$i - 1]->{$c}
            } else {
                $h->[$i - 1]->{$c}--;
            }
            $h->[$i]->{$c}++;
        }
    }
}

foreach $c (sort keys %{$h->[$n - 1]}) {
    foreach (1 .. $h->[$n - 1]->{$c}) {
        print "$c";
    }
}
print "\n";


Measured memory_bytes: 768
//#include <bits/stdc++.h>
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
#define endl '\n'



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

	int s, w;
	cin >> s >> w;
	if (s <= w)
		cout << "unsafe" << endl;
	else
		cout << "safe" << endl;

	//system("pause");
	return 0;
}

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

using namespace std;

#define x first
#define y second
#define mp make_pair
#define pb push_back
#define sqr(a) ((a) * (a))
#define sz(a) int(a.size())
#define all(a) a.begin(), a.end()
#define forn(i, n) for(int i = 0; i < int(n); i++) 
#define fore(i, l, r) for(int i = int(l); i < int(r); i++)

typedef long long li;
typedef long double ld;
typedef pair<int, int> pt;

template <class A, class B> ostream& operator << (ostream& out, const pair<A, B> &a) {
	return out << "(" << a.x << ", " << a.y << ")";
}

template <class A> ostream& operator << (ostream& out, const vector<A> &v) {
	out << "[";
	forn(i, sz(v)) {
		if(i) out << ", ";
		out << v[i];
	}
	return out << "]";
}

mt19937 rnd(time(NULL));

const int INF = int(1e9);
const li INF64 = li(1e18);
const int MOD = int(1e9) + 7;
const ld EPS = 1e-9;
const ld PI = acos(-1.0);

const int N = 200 + 7;
const int LOGN = 62;

int n;
li a[N];
string s;

bool read () {
	if (scanf("%d", &n) != 1)
		return false;
	forn(i, n)
		scanf("%lld", &a[i]);
	static char buf[N];
	scanf("%s", buf);
	s = buf;
	return true;
}

li bas[N];

bool check(li x){
	for (int i = LOGN - 1; i >= 0; --i) if ((x >> i) & 1){
		if (bas[i] == -1)
			return false;
		x ^= bas[i];
	}
	return true;
}

void add(li x){
	for (int i = LOGN - 1; i >= 0; --i) if ((x >> i) & 1){
		if (bas[i] == -1){
			bas[i] = x;
			return;
		}
		x ^= bas[i];
	}
}

void solve() {
	memset(bas, -1, sizeof(bas));
	for (int i = n - 1; i >= 0; --i){
		if (s[i] == '0')
			add(a[i]);
		else if (!check(a[i])){
			puts("1");
			return;
		}
	}
	puts("0");
}

int main() {
#ifdef _DEBUG
	freopen("input.txt", "r", stdin);
//	freopen("output.txt", "w", stdout);
	
	int tt = clock();
#endif
	
	cerr.precision(15);
	cout.precision(15);
	cerr << fixed;
	cout << fixed;

	int tc;
	scanf("%d", &tc);
	while (tc--){
		read();
		solve();
		
#ifdef _DEBUG
	cerr << "TIME = " << clock() - tt << endl;
	tt = clock();
#endif

	}
}

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

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

using namespace std;
using graph=vector<vector<int>>;

pair<int,pair<int,int>> tree_diameter(const graph& T){
	function<pair<int,int>(int,int)> dfs=[&](int u,int p){
		int dep=0,w=u;
		for(int v:T[u]) if(v!=p) {
			auto tmp=dfs(v,u);
			tmp.first++;
			if(tmp.first>dep) tie(dep,w)=tmp;
		}
		return make_pair(dep,w);
	};
	int u=dfs(0,-1).second;
	auto res=dfs(u,-1);
	return {res.first,{u,res.second}};
}

int main(){
	int n; scanf("%d",&n);
	graph T(n);
	rep(i,n-1){
		int u,v; scanf("%d%d",&u,&v); u--; v--;
		T[u].emplace_back(v);
		T[v].emplace_back(u);
	}

	puts(tree_diameter(T).first%3!=1?"First":"Second");

	return 0;
}


Measured memory_bytes: 29952
#!/usr/bin/ruby
cx1,cy1,r1=gets.split.map(&:to_f)
cx2,cy2,r2=gets.split.map(&:to_f)
#(x - cx1)^2 + (y - cy1)^2 - r1^2 = (x - cx2)^2 + (y - cy2)^2 - r2^2
#2(-cx1+cx2)x + 2(-cy1+cy2)y + cx1^2 + cy1^2 - r1^2 - cx2^2 - cy2^2 + r2^2 = 0
X=2*(cx2-cx1)
Y=2*(cy2-cy1)
Z=cx1**2+cy1**2-r1**2-cx2**2-cy2**2+r2**2
x1,y1,x2,y2=if Y==0
	[-Z/X,0,-Z/X,1]
else
	a=-X/Y;b=-Z/Y
	[0,b,1,a+b]
end
#gets.to_i.times{
	if x1==x2
		#(x1 - cx1)^2 + (y - cy1)^2 = r1^2
		#y^2 - 2cy1y + cy1^2 + (x1 - cx1)^2 - r1^2 = 0
		d=cy1**2-(cy1**2+(x1-cx1)**2-r1**2)
		y=[cy1-Math.sqrt(d),cy1+Math.sqrt(d)]
		puts [x1,y[0],x1,y[1]]*' '
	else
		a=(y2-y1)/(x2-x1)
		b=y1-a*x1
		#(x - cx1)^2 + (ax + b-cy1)^2 = r^2
		#x^2 - 2cx1x + cx1^2 + (ax)^2 + 2a(b-cy1)x + (b-cy1)^2 = r1^2
		#(a^2+1)x^2 + (2ab-2acy1-2cx1)x + cx1^2 + (b-cy1)^2 - r1^2 = 0
		s=a**2+1
		t=2*a*b-2*a*cy1-2*cx1
		u=cx1**2+(b-cy1)**2-r1**2
		d=t**2-4*s*u
		x=[(-t-Math.sqrt(d))/2/s,(-t+Math.sqrt(d))/2/s]
		y=x.map{|e|a*e+b}
		puts [x[0],y[0],x[1],y[1]]*' '
	end
#}

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

const long long INF = 1e7 + 1;
const long long MOD = 1000000007;
const long double PI = 3.1415926;

#define FOR(i,r,n) for(ll i = (ll)(r); i < (ll)(n); ++i)
#define RFOR(i,r,n) for(ll i = (ll)(n-1); i >= r; --i)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define ALL(x) x.begin(),x.end()
#define RALL(x) x.rbegin(),x.rend()

using ll = long long int;
using ull = unsigned long long int;
using vi = vector<ll>;
using vp = vector<pair<ll, ll>>;
using vs = vector<string>;
using vc = vector<char>;
using lst = list<ll>;

ll n, m, k, ans = 0, sum = 0, cnt = 0;
string s;
//char c;

/*--------------------template--------------------*/

int main() {
    cin >> n;
	ll a[n], b[n], c[n-1];
	REP(i,n) {cin >> a[i];}
	REP(i,n) {cin >> b[i];}
	REP(i,n-1) {cin >> c[i];}
	REP(i,n) {
    	sum += b[i];
    	if (a[i+1]-a[i]==1)
        	sum += c[a[i]-1];
    }
    cout << sum << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <stdlib.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;
typedef vector<double> Vec;
typedef vector<Vec> Mat;
typedef pair<ll,ll> P;
typedef pair<double,ll> Pd;
typedef pair<double,double> PD;
typedef priority_queue<P,vector<P>,greater<P> > P_queue;
typedef priority_queue<Pd,vector<Pd>,greater<Pd> > Pd_queue;

const ll MOD=998244353;
const ll mod=1000000007;
const ll INF=1e15;
const double DEL=1e-6;


#define REP(i,a,b) for(int i=(int)a;i<(int)b;i++)
#define rep(i,n) REP(i,0,n)
#define pb push_back
#define mp make_pair
#define ALL(a) a.begin(),a.end()
#define SORT(a) sort(ALL(a))
#define U_ERASE(V) V.erase(unique(ALL(V)), V.end());
#define ADD(a,b) a=(a+b)%mod
#define MUL(a,b) a=(a*b)%mod

int main(){
    ll N,D; cin>>N>>D;
    D=D*D;
    ll ans=0;
    rep(i,N){
        ll x,y; cin>>x>>y;
        if(x*x+y*y<=D) ans++;
    }
    cout<<ans<<endl;
}

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

using namespace std;

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

  int n, t;
  cin >> n >> t;
  int min_cost = INT_MAX;
  for (int i = 0; i < n; ++i) {
    int cost, time;
    cin >> cost >> time;
    if (time <= t) {
      min_cost = min(min_cost, cost);
    }
  }
  if (min_cost == INT_MAX) {
    cout << "TLE\n";
  } else {
    cout << min_cost << "\n";
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int A[200005] , T[200005];
int main() {
    int N;
    cin >> N;
    ll ans = 0;
    for(int i = 0; i < N; i++){
        cin >> A[i];
        ans+=T[A[i]];
        T[A[i]]++;
    }
    for(int i = 0; i < N; i++){
        cout << ans - T[A[i]] + 1 << endl;
    }
}

Measured memory_bytes: 3712
#include <bits/stdc++.h>
#pragma warning(disable : 4996)
using namespace std;
int main()
{
	long long int floyd[400][400];
	int n; scanf("%d", &n);
	for (int i = 0; i < n; i++) for (int j = 0; j < n; j++) scanf("%lld", &floyd[i][j]);
	for (int k = 0; k < n; k++) for (int i = 0; i < n; i++) for (int j = 0; j < n; j++) if (floyd[i][j] > floyd[i][k] + floyd[k][j]) return !printf("-1");
	long long int cnt = 0;
	for (int i = 0; i < n; i++) for (int j = 0; j < n && j!=i; j++)
	{
		bool flag = false;
		for (int k = 0; k < n; k++)
		{
			if (k == i || k == j) continue;  flag |= (floyd[i][j] == floyd[i][k] + floyd[k][j]);
		}
		if (!flag) cnt += floyd[i][j];
	}
	return !printf("%lld", cnt);
}

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

using namespace std;
typedef long long ll;

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

  ll ans = 0;
  for (int i = 1; i <=n; ++i) {
    ll left = i;
    ll right = n - i + 1;
    ans += left * right;
  }

  for (int i = 0; i < n - 1; ++i) {
    int u, v;
    cin >> u >> v;
    if (u > v) swap(u, v);
    ll right = n - v + 1;
    ans -= u * right;
  }
  cout << ans << '\n';
  return 0;
}



Measured memory_bytes: 3620
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
#define rep(i,N) for(ll (i)=0;(i)<(N);(i)++)
const int mod = 1000000007;

int main(){
  int h, w, d;
  cin >> h >> w >> d;
  vector<int> px(h*w + 1), py(h*w + 1);
  rep(i, h) rep(j, w) {
    int a;
    cin >> a;
    px[a] = i;
    py[a] = j;
  }
  vector<int> sum(h * w + 1);
  for(int i = d + 1; i <= h * w; ++i){
    sum[i] = sum[i - d] + abs(px[i] - px[i - d]) + abs(py[i] - py[i - d]);
  }
  int q;
  cin >> q;
  rep(i, q){
    int l, r;
    ll ans;
    cin >> l >> r;
    ans = sum[r] - sum[l];
    cout << ans << endl;
  }
}

Measured memory_bytes: 2176
#include <bits/stdc++.h>
#define LL long long
using namespace std;
LL N,M;
LL Ans=1ll;
int main()
{
	LL I,J,K;
	cin>>N>>M;
	N=M/N;
	for(I=1ll;I<=N;I++)
	{
		if(Ans>N)break;
		Ans=Ans*2;
	}
	cout<<I-1;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define Maxn 57
using namespace std;
int n;
int a[Maxn],b[Maxn];
bool flag[Maxn][Maxn];
bool check(long long x)
{
	memset(flag,false,sizeof(flag));
	for (int i=0;i<=50;i++)
		flag[i][i]=true;
	for (int i=1;i<=50;i++)
		if (x&(1LL<<(i-1)))
		{
			for (int j=0;j<=50;j++)
				flag[j][j%i]=true;
		}
	for (int k=0;k<=50;k++)
		for (int i=0;i<=50;i++)
			for (int j=0;j<=50;j++)
				flag[i][j]|=flag[i][k]&flag[k][j];
	for (int i=1;i<=n;i++)
		if (!flag[a[i]][b[i]]) return false;
	return true;
}
int main()
{
	scanf("%d",&n);
	for (int i=1;i<=n;i++)
		scanf("%d",&a[i]);
	for (int i=1;i<=n;i++)
		scanf("%d",&b[i]);
	long long ans=0;
	for (int i=50;i;i--)
		if (!check(ans|((1LL<<(i-1))-1))) ans|=(1LL<<(i-1));
	if (check(ans)) printf("%lld\n",2LL*ans); else printf("%d\n",-1);
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
const int N = 1e5 + 10;
long long ans;
int main(){
    ios::sync_with_stdio(0);
    cin.tie(0),cout.tie(0);
    int n,t,cnt = 0;
    cin >> n;
    t = n;
    while(t){
        cnt++;
        t /= 10;
    }
    if(cnt == 1) {
        cout << n;
    }
    else if(cnt == 2){
        cout << 9 ;
    }
    else if(cnt == 3){
        cout << n-100+1+9;
    }
    else if(cnt == 4){
        cout << 900+9;
    }
    else if(cnt == 5){
        cout << n-10000+1+9+900;
    }
    else if(cnt == 6){
        cout << 90000+900+9;
    }
    return 0;
}
// 1-9 9
// 10-99 0
// 100-999 900
// 1000-9999 0
// 10000-99999 90000;
// 100000-99999 0;


Measured memory_bytes: 256