akhauriyash/Code-Regression huggingface dataset:
N,K=map(int,input().split())
X, Y, XY = [], [], []
for i in range(N):
  x, y = map(int,input().split())
  X += [x]
  Y += [y]
  XY += [[x,y]]
  
ans = float("inf")

for x1 in range(N):
  for x2 in range(x1+1,N):
    for y1 in range(N):
      for y2 in range(y1+1,N):
        boxed = 0
        for i in range(N):
          if (X[x1] - X[i])*(X[x2]-X[i])<=0 and (Y[y1] - Y[i])*(Y[y2]-Y[i])<=0:
            boxed+= 1
        if boxed >= K: 
          ans = min(ans,abs(X[x1]-X[x2])*abs(Y[y1]-Y[y2]))
          #print(abs(X[x1]-X[x2])*abs(Y[y1]-Y[y2]))
print(ans)

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

int main() {
  int a,b,c,d,e,f;
  cin>>a>>b>>c>>d;
  e=max(a,c);
  f=min(b,d);
  if(f-e>0){
    cout<<f-e<<endl;
  }
  else{
    cout<<0<<endl;
  }
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        int x = sc.nextInt();
        int y = sc.nextInt();
        sc.close();

        for(int i=0; i<=x; i++) {
            for(int j=0; j<=x-i; j++) {
                if(y == 2*i + 4*j && x == i + j) {
                    System.out.println("Yes");
                    System.exit(0);
                }
            }
        }
        System.out.println("No");
    }
}


Measured memory_bytes: 35728
#include<iostream>
#include<algorithm>
#include<string>
#include<cstdlib>
#include<map>
#include<iomanip>
#include<sstream>
#include<vector>
#include<stack>
#include<math.h>
#include<queue>
#include<complex>
#include<random>
#include<ctime>
using namespace std;



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

long long int n,m,d=0;

int main() {
	cout << fixed << setprecision(18);
	cin>>n;
	while(n>=0){
		n-=100;
		d++;
		if(0<=n&&n<=5*d){cout<<1;return 0;}
	}
	cout<<0;
} 


Measured memory_bytes: 256
//   Rishabh Agarwal
#include <bits/stdc++.h>
#define F first
#define S second
#define MAX 10000003
using namespace std;

typedef long long int ll;
const ll mod = 1e9+7;
const ll INF= 1e18;
long double PI=3.1415926;

ll power(ll a,ll b){
    if(b==0){
        return 1;
    }
    ll temp=power(a,b/2)%mod;
    if(b%2==0){
        return (temp*temp)%mod;
    }
    else{
        return ((a*temp)%mod*temp)%mod;
    }
}

ll gcd(ll a, ll b) 
{ 
    if (b == 0) 
        return a; 
    return gcd(b, a % b);  
      
} 

vector<ll>v;
vector<ll>::iterator it;
map<ll,ll>mp;

void primeFactors(ll n)  
{  
    while (n % 2 == 0)  
    {  
        mp[2]++;
        n = n/2;  
    }  
    for (ll i = 3; i <= sqrt(n); i = i + 2)  
    {  
        while (n % i == 0)  
        {  
            mp[i]++;
            n = n/i;  
        }  
    }  
    if (n > 2){ 
        mp[n]++; 
    } 
}  

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    
    #ifndef ONLINE_JUDGE
	freopen("inp.txt", "r", stdin);
	freopen("out.tex", "w", stdout);
    #endif

    ll t;
    //cin>>t;
    t=1;
    //ll c=1;
    while(t--){
        ll k,n;
        cin>>k>>n;
        ll a[n];
        //sort(a,a+n);
        set<ll>s;
        for(ll x=-100; x<=200; x++){
            s.insert(x);
        }
        for(ll x=0; x<n; x++){
            cin>>a[x];
            s.erase(a[x]);
        }
        ll ans=10000000;
        ll h;
        for(auto i:s){
            if(abs(k-i)<ans){
                h=i;
                ans=abs(k-i);
            }
        }
        cout<<h<<"\n";
        //cout<<"No\n";
        mp.clear();  
        v.clear();
        //cout<<"Case #"<<c<<": "<<ans<<"\n";
        //c++;
    }
    return 0;
}

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

#define BR "\n"
#define SP " "

int main() {

  ll N;
  cin >> N;

  for (int i = 1; i <= N; i++) {
    ll x = i;
    if (x % 3 == 0) {
      cout << SP << i;
      continue;
    }
    while(x > 0) {
      if (x % 10 == 3) {
        cout << SP << i;
        break;
      }
      x /= 10;
    }
  }
  cout << BR;

  return 0;
}


Measured memory_bytes: 3072
#include <iostream>
#include <algorithm>

using namespace std;

int solve(int a, int b, int c) {
  int max3 = max(max(a, b), c);
  int sum = a+b+c;

  if((max3 * 3 - sum) % 2 == 0) {
    return (max3 * 3 - sum) / 2;
  } else {
    return ((max3 + 1) * 3 - sum) / 2;
  }
}
  
int main(void) {
  int a, b, c;
  cin >> a >> b >> c;

  cout << solve(a,b,c) << endl;
}


Measured memory_bytes: 256
#!/usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
from bisect import bisect_left, bisect_right
import sys, random, itertools, math
sys.setrecursionlimit(10**5)
input = sys.stdin.readline
sqrt = math.sqrt
def LI(): return list(map(int, input().split()))
def LF(): return list(map(float, input().split()))
def LI_(): return list(map(lambda x: int(x)-1, input().split()))
def II(): return int(input())
def IF(): return float(input())
def LS(): return list(map(list, input().split()))
def S(): return list(input().rstrip())
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007
inf = 1e10

#solve
def solve():
    s = S()
    d = defaultdict(list)
    for i in range(27):
        d[chr(ord("a")+i)].append(-1)
    for i in range(len(s)):
        d[s[i]].append(i)
    for i in range(27):
        d[chr(ord("a") + i)].append(len(s))
    ans = inf
    for key, value in d.items():
        tmp = 0
        for v in range(len(value) - 1):
            tmp = max(tmp, value[v + 1] - value[v]-1)
        ans = min(tmp, ans)
    print(ans)
    return


#main
if __name__ == '__main__':
    solve()


Measured memory_bytes: 38640
if __name__ == '__main__':
    steps = str(input())

    index = 0

    correct = True

    for step in steps:
        # 偶数
        if index % 2 == 0:
            if step == 'L':
                correct = False
        # 奇数
        if index % 2 == 1:
            if step == 'R':
                correct = False
        index += 1

    if correct is True:
        print('Yes')
    else:
        print('No')


Measured memory_bytes: 2940
#include <iostream>
#include <vector>
#include <string>
#include <unordered_map>
#include <math.h>
#include <algorithm>
#include <deque>
#include <queue>
#include <climits>
#include <set>
using namespace std;
#define ll long long
#define ull unsigned long long
#define ve vector
#define umap unordered_map
#define iter iterator
string ar[50];
int h,w;
void solve() {
    cin>>h>>w;
	for(int i=0; i<h; i++) cin>>ar[i];
	for(int i=0; i<h; i++) {
		for(int j=0; j<w; j++) {
			if(ar[i][j]=='#') cout<<'#';
			else {
				int cnt = 0;
				for(int k=-1; k<=1; k++) {
					for(int l=-1; l<=1; l++) {
						int tx = i+k, ty = j+l;
						if(0 <= tx && tx < h && 0 <= ty && ty < w && ar[tx][ty] == '#')
							cnt++;
					}
				}
				cout << cnt;
			}
        }
		cout << endl;
	}
}

int main() {
    solve();
    return 0;
}

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

int main(){
   
    int K,N,maxv;
    cin >> K >> N;
    int data[N];
    
    for(int i=0;i<N;i++) cin >> data[i];
    
    for(int i=0;i<N;i++){
        if(i==0) maxv = data[i+1] - data[i];
        else if(i!= N-1 && maxv < data[i+1] - data[i]) maxv = data[i+1] - data[i];
        else if(i == N-1 && ((K-data[i]) + data[0]) > maxv) maxv = K - data[i] + data[0];
    }
    
    cout << K - maxv << endl;
}

Measured memory_bytes: 4392
#define _USE_MATH_DEFINES
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <complex>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
#include <iterator>
using namespace std;

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

    int ans = 0;
    for(int i=0; i<n; ++i){
        int l, r;
        cin >> l >> r;
        ans += r - l + 1;
    }
    cout << ans << endl;

    return 0;
}


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

using namespace std;

int main() {
  int n;
  cin >> n;
  vector<int> a(n),b(n),c(n-1);
  for(int i=0;i<n;i++){
    cin >> a.at(i);
  }
  for(int i=0;i<n;i++){
    cin >> b.at(i);
  }
  for(int i=0;i<n-1;i++){
    cin >> c.at(i);
  }
  int ans=0;
  for(int i=0;i<n;i++){
    ans += b.at(a.at(i)-1);
  }
  for(int i=0;i<n-1;i++){
    if(a.at(i)+1 == a.at(i+1)){
      ans += c.at(a.at(i)-1);
    }
  }
  cout << ans << endl;
  
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<vector>
#include<string>
#include<cstring>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<cstdlib>
#include<climits>
#include<fstream>

#define MOD (1000000007)

using namespace std;

typedef long long int Int;

Int N,M;
Int dp[100000+10];
set<int> A;

Int solve(void) {
    dp[0] = 1;
    for(int i = 1;i <= N;i++) {
        if(A.find(i) == A.end()) {
            if(i >= 2)
                dp[i] = (dp[i-1]+dp[i-2]) % MOD;
            else
                dp[i] = (dp[i-1])%MOD;
        } else {
            dp[i] = 0;
        }
    }

    return dp[N];
}


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

    for(int i = 0;i < M;i++) {
        int a;
        cin>>a;
        A.insert(a);
    }

    cout<<solve()<<endl;

    return 0;
}




Measured memory_bytes: 5760
L, R = map(int, input().split())
if R >= L + 2019:
    R = R + 2019

ans = 2020
for i in range(L, R+1):
    for j in range(i+1, R+1):
        daaam = i * j % 2019
        if daaam == 0:
            print(daaam)
            exit()
        ans = min(daaam, ans)
print(ans)

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

int N;
long long zenhanSum = 0, kouhanSum = 0;
vector<long long> A(3 * 1000000);
vector<long long> zenhanVec, kouhanVec;
priority_queue<int, vector<int>, greater<int>> zenhan;
priority_queue<int> kouhan;

void solve1(){  
  cin >> N;
  for(int i = 0; i < 3 * N; i++){  
    int a;
    cin >> a;
    A[i] = a;
  }
  for(int i = 0; i < N; i++){  
    zenhan.push(A[i]);
    zenhanSum += A[i];
  }
  //*
  zenhanVec.push_back(zenhanSum);
  for(int i = 0; i < N; i++){
    int x = zenhan.top();
    if(x < A[N + i]){  
      zenhanSum -= x; 
      zenhanSum += A[N + i];
      zenhan.pop();
      zenhan.push(A[N + i]);
    }
    zenhanVec.push_back(zenhanSum);
  }
  for(int i = 0; i < N; i++){  
    kouhan.push(A[3 * N - 1 - i]);
    kouhanSum += A[3 * N - 1 - i];
  }
  kouhanVec.push_back(kouhanSum);
  for(int i = 0; i < N; i++){
    int x = kouhan.top();
    if(x > A[2 * N - 1 - i]){  
      kouhanSum -= x; 
      kouhanSum += A[2 * N - 1 - i];
      kouhan.pop();
      kouhan.push(A[2 * N - 1 - i]);
    }
    kouhanVec.push_back(kouhanSum);
  }
  long long maxx = -99999999999999999;
  for(int i = 0; i <= N; i++){  
    //cout << zenhanVec[i] << " " << kouhanVec[N - i] <<endl;
    maxx = max(maxx, zenhanVec[i] - kouhanVec[N - i]); 
  }
  cout << maxx <<endl;
  //*/
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout << setprecision(20) << fixed;
  solve1();
}


Measured memory_bytes: 29884
#define _CRT_SECURE_NO_WARNINGS
#include "bits/stdc++.h"

#define PB push_back
#define PF push_front
#define LB lower_bound
#define UB upper_bound
#define fr(x) freopen(x,"r",stdin)
#define fw(x) freopen(x,"w",stdout)
#define iout(x) printf("%d\n",x)
#define lout(x) printf("%lld\n",x)
#define REP(x,l,u) for(ll x = l;x<u;x++)
#define RREP(x,l,u) for(ll x = l;x>=u;x--)
#define complete_unique(a) a.erase(unique(a.begin(),a.end()),a.end())
#define mst(x,a) memset(x,a,sizeof(x))
#define all(a) a.begin(),a.end()
#define PII pair<int,int>
#define PLL pair<ll,ll>
#define MP make_pair
#define sqr(x) ((x)*(x))
#define lowbit(x) ((x)&(-(x)))
#define lson (ind<<1)
#define rson (ind<<1|1)
#define se second
#define fi first
#define sz(x) ((int)x.size())
#define EX0 exit(0);

typedef  long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ld;
using namespace std;
typedef vector<ll> VLL;
typedef vector<int> VI;
const int block_size = 320;
typedef complex<ll> point;
const ll mod = 1e9 + 7;
const ll inf = 1e9 + 7;
const ld eps = 1e-9;
const db PI = atan(1) * 4;

template<typename T, typename S>inline bool upmin(T&a, const S&b) { return a > b ? a = b, 1 : 0; }
template<typename T, typename S>inline bool upmax(T&a, const S&b) { return a < b ? a = b, 1 : 0; }

ll gcd(ll a, ll b) { return b == 0 ? a : gcd(b, a%b); }
ll pow(ll a, ll b) {
	if (b == 0) {
		return 1;
	}
	if (b == 1) {
		return a;
	}
	ll ans = pow(a, b / 2);
	ans *= ans;
	ans *= b % 2 == 1 ? a : 1;
	return ans;
}

namespace SOLVE {
	struct edge {
		ll from, to, weight;
	};

	struct vertex {
		ll distance = 1e15, no;
	};

	struct compareVertex {
		bool operator() (vertex const& p1, vertex const& p2) {
			return p1.distance > p2.distance;
		}
	};



	void main() {
		ll V, E, s, t1, t2, t3;
		cin >> V >> E >> s;

		vector<edge> edges;
		REP(i, 0, E) {
			cin >> t1 >> t2 >> t3;
			edge e;
			e.from = t1;
			e.to = t2;
			e.weight = t3;
			edges.push_back(e);
		}

		VLL ans(V, 1e15);
		VLL component(V);
		ans[s] = 0;
		component[s] = 1;

		
		REP(i, 0, V) {
			for (edge e : edges) {
				if (component[e.from] == 1) {
					component[e.to] = 1;
					if (ans[e.to] > ans[e.from] + e.weight) {
						ans[e.to] = ans[e.from] + e.weight;
					}
				}
			}
		}


		for (edge e : edges) {
			if (component[e.from]) {
				if (ans[e.to] > ans[e.from] + e.weight) {
					cout << "NEGATIVE CYCLE" << endl;
					return;
				}
			}
		}

		REP(i, 0, V) {
			if (component[i] == 0) {
				cout << "INF\n";
			}
			else {
				cout << ans[i] << endl;
			}
		}




	}
}


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

	int t;
	//    in(t);
	t = 1;
	while (t--) {
		SOLVE::main();

	}

	return 0;
}


Measured memory_bytes: 3264
from collections import deque
h, w = map(int, input().split())
ch, cw = map(int, input().split())
dh, dw = map(int, input().split())
maze = [[9]*(w+4)]
maze.append([9]*(w+4))
for i in range(h):
  s = input()
  tmp = [9,9]
  for i in s:
    if i == "#":
      tmp.append(9)
    else:
      tmp.append(0)
  tmp.append(9)
  tmp.append(9)
  maze.append(tmp)
maze.append([9]*(w+4))
maze.append([9]*(w+4))
#print(maze)

pos = deque()
pos.append([ch+1,cw+1,0])
while len(pos)>0:
  x, y, hop = pos.popleft()
  #print(pos)
  #print[x,y,hop)
  if (x,y) == (dh+1,dw+1):
    print(hop)
    break
  maze[x][y] = 3
  
  if maze[x-1][y] <3:
    pos.appendleft([x-1,y,hop])
    maze[x-1][y] = 3  
    
  if maze[x+1][y] <3:
    pos.appendleft([x+1,y,hop])
    maze[x+1][y] = 3
    
  if maze[x][y-1] <3:
    pos.appendleft([x,y-1,hop])
    maze[x][y-1] = 3
    
  if maze[x][y+1] <3:
    pos.appendleft([x,y+1,hop])
    maze[x][y+1] = 3

  #move =[(-2,0),(-2,1),(-2,2),(-2,-1),(-2,-2),(2,0),(2,1),(2,2),(2,-1),(2,-2),(0,-2),(-1,-2),(1,-2),(0,2),(-1,2),(1,2),(-1,1),(-1,-1),(1,1),(1,-1)]
  move = [(i,j) for i in range(-2,3) for j in range(-2,3)]
  for dx,dy in move:
    if maze[x+dx][y+dy] <2:
      pos.append([x+dx,y+dy,hop+1])
      maze[x+dx][y+dy] = 2
  
else:
  print(-1)

Measured memory_bytes: 122956
import math


class RMQ:
    def __init__(self, n):
        k = 1
        while k < n:
            k *= 2
        self.N = k
        self.node = [float("inf")] * (int(2 * self.N - 1))

    def update(self, i, x):
        i += self.N - 1
        self.node[i] = x
        while i > 0:
            i = (i - 1) // 2
            self.node[i] = min(self.node[2 * i + 1], self.node[2 * i + 2])

    def _find(self, a, b, i, l, r):
        if r <= a or b <= l:
            return float("inf")
        elif a <= l and r <= b:
            return self.node[i]

        else:
            mid = (l + r) // 2
            return min(self._find(a, b, 2 * i + 1, l, mid), self._find(a, b, 2 * i + 2, mid, r))

    def find(self, a, b):
        return self._find(a, b, 0, 0, self.N)


n, q = map(int, input().split())
rmq = RMQ(n)
inf = 2147483647
for j in range(q):
    c, x, y = map(int, input().split())
    if c == 0:
        rmq.update(x, y)
    else:
        m = rmq.find(x, y + 1)
        if m == float("inf"):
            print(inf)
        else:
            print(m)


Measured memory_bytes: 8756
from itertools import permutations
from math import sqrt
N = int(input())
Ps = [list(map(int, input().split())) for _ in range(N)]
ans = 0
for L in permutations(Ps):
    for i in range(1, N):
        ans += sqrt(pow(L[i][0]-L[i-1][0],2) + pow(L[i][1]-L[i-1][1],2))

factorial = 1
for i in range(1,N+1):
    factorial *= i
print(ans / factorial)

Measured memory_bytes: 3188
using System;
using System.Collections.Generic;
class Program{
	static void Main(){
		int n=int.Parse(Console.ReadLine());
		long[] s=Array.ConvertAll(Console.ReadLine().Split(),long.Parse);
		string ans="-1";
		long a=2,b=3;
		bool d=false;
		if(s[n-1]==2){
			for(int i=n-2;i>=0;i--){
				if(s[i]>b){d=true;break;}
				else if(a%s[i]!=0){a=a+(s[i]-(a%s[i]));}
				b+=(s[i]-(b%s[i])-1);
				if(a>b){d=true;break;}
			}
			if(!d){ans=a.ToString()+" "+b.ToString();}
		}
		Console.WriteLine("{0}",ans);
	}
}

Measured memory_bytes: 29532
#include <iostream>
#include <set>

int main(void)
{
    int a, b, c;
    std::cin >> a >> b >> c;
    std::set<int> s;
    s.insert(a);
    s.insert(b);
    s.insert(c);
    std::cout << s.size() << std::endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<stdio.h>
#include<string.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<vector>
#include<set>
#include<iostream>
#define pb push_back
#define fi first
#define se second
#define sz(x)  x.size()
#define cl(x)  x.clear()
#define all(x)  x.begin() , x.end()
#define r(x)  scanf("%d", &x)
#define rr(x , y)  scanf("%d%d" , &x , &y)
#define rst(s)  scanf("%s" , s)
#define rl(x)  scanf("%lld" , &x)
#define rrl(x , y)  scanf("%lld%lld" , &x , &y)
#define w(x)  printf("%d" , x)
#define ww(x , y)  printf("%d %d" , x , y)
#define wl(x)  printf("%lld" , x)
#define wwl(x , y)  printf("%lld %lld" , x , y)
#define sp()  printf(" ")
#define en()  puts("")
#define rep(i , x , n)  for(int i = x ; i <= n ; i ++)
#define per(i , n , x)  for(int i = n ; i >= x ; i --)
#define mem0(x)  memset(x , 0 , sizeof(x))
#define mem_1(x)  memset(x , -1 , sizeof(x))
#define mem_inf(x)  memset(x , inf , sizeof(x))
#define mem__inf(x)  memset(x , -inf , sizeof(x))
#define p_queue priority_queue
#define debug(x)  cout << '*' << x << '\n'
#define ddebug(x , y)  cout << '*' << x << ' ' << y << '\n'
#define ios std::ios::sync_with_stdio(false) , cin.tie(0)
using namespace std ;
//mt19937  rnd(chrono::high_resolution_clock::now().time_since_epoch().count()) ;
typedef long long ll ;
typedef unsigned long long ull ;
typedef pair<int , int> pii ;
typedef pair<ll , ll> pll ;
typedef pair<int , ll> pil ;
typedef pair<ll , int> pli ;
typedef pair<double , double> pdd ;
const int inf = 0x3f3f3f3f ;
const ll mod = 998244353 ;
const int maxn = 1e5 + 5 ;
const int maxm = 30 ;
const double eps = 1e-6 ;
const double pi = acos(-1.0) ;
int main()
{
	ll x ;
	rl(x) ;
	ll now = 100 ;
	int ans = 0 ;
	while(now < x)
	{
		now += now / 100 ;
		ans ++ ;
	} 
	w(ans) , en() ;
	return 0 ;
} 

Measured memory_bytes: 3828
#include<cstdio>
using namespace std;
int n,a[101],p[101],cnt;
int main()
{
	scanf("%d",&n);p[1]=1;
	for(int i=1;i<=n;++i) {scanf("%d",&a[i]);if(a[i]!=a[i-1]) p[++cnt]=i;}p[++cnt]=n+1;int ans=0;
	for(int i=2;i<=cnt;++i) ans+=(p[i]-p[i-1])/2;printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 128
def calc(a,b,c,d,e,f):
	A=2*(c-a)
	B=2*(d-b)
	C=a*a-c*c+b*b-d*d
	D=2*(e-a)
	E=2*(f-b)
	F=a*a-e*e+b*b-f*f
	N=(A*E-D*B)
	X=(B*F-E*C)/N
	Y=(C*D-F*A)/N
	return tuple(map(round,[X,Y,((X-a)**2+(Y-b)**2)**0.5],[3]*3))
l=[map(float,raw_input().split())for i in range(input())]
for k in l:print"%.3f %.3f %.3f"%(calc(*k))

Measured memory_bytes: 4332
import std.algorithm, std.container, std.conv, std.math, std.range, std.typecons, std.stdio, std.string;

auto rdsp(){return readln.splitter;}
void pick(R,T)(ref R r,ref T t){t=r.front.to!T;r.popFront;}
void readV(T...)(ref T t){auto r=rdsp;foreach(ref v;t)pick(r,v);}
void readC(T...)(size_t n,ref T t){foreach(ref v;t)v=new typeof(v)(n);foreach(i;0..n){auto r=rdsp;foreach(ref v;t)pick(r,v[i]);}}

void main()
{
  int n, a, b; readV(n, a, b); --a; --b;
  long[] x, y; readC(n, x, y);

  auto d = (x[a]-x[b]).abs + (y[a]-y[b]).abs;

  auto p = new P[](n);
  foreach (i; 0..n) p[i] = P(x[i], y[i], i);

  auto bufr = BufR();
  foreach (i, pi; p)
    if (i != a && i != b)
      bufr.add(pi);

  auto q = DList!int(a, b), vt = new bool[](n);
  vt[a] = vt[b] = true;

  auto operate(R)(R b, long v, long vl, long vr)
  {
    if (v in b) {
      auto r = b[v].upperBound(P(vl-1, 0, 0));
      P[] removed;
      foreach (p; r) {
        if (p.x >= vr) break;
        vt[p.i] = true;
        removed ~= p;
        q.insertBack(p.i);
      }
      foreach (ri; removed) bufr.remove(ri);
    }
  }

  while (!q.empty) {
    auto ui = q.front; q.removeFront;
    auto u = p[ui], ux = u.x, uy = u.y, up = ux+uy, um = ux-uy;

    operate(bufr.pb, up+d, ux, ux+d);
    operate(bufr.mb, um+d, ux+1, ux+d+1);
    operate(bufr.pb, up-d, ux-d+1, ux+1);
    operate(bufr.mb, um-d, ux-d, ux);
  }

  auto count(R)(R b, long v, long vl, long vr)
  {
    if (v !in b) return 0L;
    return b[v].assumeSorted.upperBound(P(vl-1, 0, 0)).lowerBound(P(vr, 0, 0)).length;
  }

  auto bufh = BufH();
  foreach (pi; p) bufh.add(pi);
  bufh.sort();

  auto ans = 0L;
  foreach (i; 0..n)
    if (vt[i]) {
      auto u = p[i], ux = u.x, uy = u.y, up = ux+uy, um = ux-uy;
      ans += count(bufh.pb, up+d, ux, ux+d);
      ans += count(bufh.mb, um+d, ux+1, ux+d+1);
      ans += count(bufh.pb, up-d, ux-d+1, ux+1);
      ans += count(bufh.mb, um-d, ux-d, ux);
    }

  writeln(ans/2);
}

struct P
{
  long x, y;
  int i;

  auto opCmp(P a) const { return x - a.x; }
}

struct BufR
{
  alias RBT = RedBlackTree!P;
  RBT[long] pb, mb;

  auto add(const P p)
  {
    auto vp = p.x+p.y, vm = p.x-p.y;
    if (vp in pb) pb[vp].insert(p);
    else          pb[vp] = new RBT(p);
    if (vm in mb) mb[vm].insert(p);
    else          mb[vm] = new RBT(p);
  }

  auto remove(const P p)
  {
    auto vp = p.x+p.y, vm = p.x-p.y;
    pb[vp].removeKey(p);
    mb[vm].removeKey(p);
  }
}

struct BufH
{
  P[][long] pb, mb;

  auto add(const P p)
  {
    auto vp = p.x+p.y, vm = p.x-p.y;
    pb[vp] ~= p;
    mb[vm] ~= p;
  }

  auto sort()
  {
    foreach (v; pb.byKey) pb[v].sort();
    foreach (v; mb.byKey) mb[v].sort();
  }
}


Measured memory_bytes: 75900
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        CRectangleCutting solver = new CRectangleCutting();
        solver.solve(1, in, out);
        out.close();
    }

    static class CRectangleCutting {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int w = in.nextInt();
            int h = in.nextInt();
            int x = in.nextInt();
            int y = in.nextInt();
            double area = (double) h * w / 2;
            out.println(area + " " + ((x * 2 == w && y * 2 == h) ? 1 : 0));
        }

    }
}



Measured memory_bytes: 23764
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
using pi = pair<int, int>;
using pl = pair<ll, ll>;
#define all(x) x.begin(),x.end()
#define rep(i,j,n) for (int i = j; i < (int)(n); i++)
#define _GLIBCXX_DEBUG
#define n_p(v) next_permutation(v.begin(),v.end())
#define to_ll(b) stoll(b)
#define MOD 1000000007
//name[i][j]-> vvl name(i,vl(j))
//map<int,int>mp
//余りを切り上げる =>  (a + b - 1) / b 

signed main(){
	int a,b,c,d; cin>>a>>b>>c>>d;
	cout<<max(a*b,c*d);
	
	return 0;
}

Measured memory_bytes: 256
ri = lambda: int(input())
rl = lambda: list(map(int,input().split()))
rr = lambda N: [ri() for _ in range(N)]
YN = lambda b: print('YES') if b else print('NO')
INF = 10**18

N,T=rl()
ans = INF
for _ in range(N):
    c,t = rl()
    if T >= t and ans > c:
        ans = c

print(ans if ans != INF else 'TLE')

Measured memory_bytes: 3064
import sys
import math

input = sys.stdin.readline


def main():
    n, k = map(int, input().split())
    bule = k
    red = n-k
    for i in range(1, k+1):
        if i == 1:
            print(c(red+1, i))
        elif i <= red+1:
            print((c(red+1, i)*(c(bule-1, i-1))) % 1000000007)
        else:
            print(0)


def c(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))


if __name__ == "__main__":
    main()


Measured memory_bytes: 3444
n,m = tuple(map(int,input().split()))

r = [[0]*n for _ in [0]*n]

for _ in range(m):
  a,b = tuple(map(int,input().split()))
  r[a-1][b-1] += 1
  r[b-1][a-1] += 1

for r_i in r:
  print(sum(r_i))


Measured memory_bytes: 3060
object Main extends App {
  val sc = new java.util.Scanner(System.in)
  val n, m = sc.nextInt()
  val e = Array.fill(n, n)(false)
  for (_ <- 0 until m) {
    val a, b = sc.nextInt()-1
    e(a)(b) = true
    e(b)(a) = true
  }
  val ans = (1 until n).permutations.count(p => (0 +: p).sliding(2).forall{
    case IndexedSeq(a, b) => e(a)(b)
  })
  println(ans)
}


Measured memory_bytes: 61316
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;

class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        Task solver = new Task();
        solver.solve(in, out);
        out.close();
    }

    static class Task {
        void solve(InputReader in, PrintWriter out) {
            // write your code here
            int N = in.nextInt(), i = in.nextInt();
            out.println(N - i + 1);
        }
    }

    static class InputReader {
        BufferedReader reader;
        StringTokenizer tokenizer;

        InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream));
            tokenizer = null;
        }

        String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }
    }
}


Measured memory_bytes: 21716
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

/**
 * Created by kennzya on 2017/09/30.
 */
public class Main {
    public Main() {
    }

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int result = 0;
        String[] input = sc.next().split("");
        for(int i = 0;i < 6;i++){
            if(input[i].equals("1")){
                result++;
            }
        }
        System.out.println(result);
    }
}


Measured memory_bytes: 22356
use std::io;
use std::collections::HashMap;

fn read_line() -> String {
    let mut line = String::new();

    io::stdin().read_line(&mut line)
        .expect("Failed to read line");
    return line;
}
fn to_i(s: &str) -> i64 {
    return s.trim().parse()
        .expect("Please type a number!");
}
fn read_nums() -> Vec<i64>
{
    let line = read_line();
    let items: Vec<&str> = line.split(' ').collect();

    let mut nums: Vec<i64> = Vec::new();

    for item in items {
        nums.push(to_i(item));
    }
    return nums;
}


fn main() {
    //println!("start");
    let l = read_line();
    let n = to_i(&l);

    //let mut m = HashMap::new();
    let mut v = Vec::new();

    for i in 0..n {
        let line = read_line();
        let items: Vec<&str> = line.split(' ').collect();

        let s = items[0].to_string();
        let p = to_i(items[1]);
        /*
        if !m.contains_key(s) {
            let v Vec<i64> = Vec::new();
            m.insert(s, v);
        } 
        m[s].push(p);
        */
        v.push((i,s,p));
    }
/*
    let c = |a, b| {
        if a.1 == b.1 {
            a.2.cmp(b.2)
        } else {
            a.1.cmp(b.1)
        }
};
    v.sort_by(c);
    */
    v.sort_by(|a, b| {
        if a.1 == b.1 {
            let x = -a.2;
            let y = -b.2;
            x.cmp(&y)
        } else {
            a.1.cmp(&b.1)
        }
    });

    for item in &v {
        let i = item.0;
        println!("{}", i+1);
        //println!("{} {} {} ", i+1, item.1, item.2);
    }
    
    
}   

Measured memory_bytes: 4352
package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
	"strconv"
)

type Tuple struct {
	a int
	b int
}

func main() {
	sc := NewScanner()
	_, M := sc.NextInt(), sc.NextInt()
	T := make(SortInterFace, M)
	for i := 0; i < M; i++ {
		T[i].a, T[i].b = sc.NextInt(), sc.NextInt()
	}
	sort.Sort(T)
	c := 0
	count := 0
	for i := 0; i < M; i++ {
		if T[i].a < c {
			continue
		}
		c = T[i].b
		count++
	}
	fmt.Println(count)
}

type SortInterFace []Tuple

func (s SortInterFace) Len() int {
	return len(s)
}
func (s SortInterFace) Less(i, j int) bool {
	return s[i].b < s[j].b
}
func (s SortInterFace) Swap(i, j int) {
	s[i], s[j] = s[j], s[i]
}

type Scanner struct {
	r   *bufio.Reader
	buf []byte
	p   int
}

func NewScanner() *Scanner {
	rdr := bufio.NewReaderSize(os.Stdin, 1000)
	return &Scanner{r: rdr}
}
func (s *Scanner) Next() string {
	s.pre()
	start := s.p
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			break
		}
	}
	result := string(s.buf[start:s.p])
	s.p++
	return result
}
func (s *Scanner) NextLine() string {
	s.pre()
	start := s.p
	s.p = len(s.buf)
	return string(s.buf[start:])
}
func (s *Scanner) NextInt() int {
	v, _ := strconv.Atoi(s.Next())
	return v
}
func (s *Scanner) NextInt64() int64 {
	v, _ := strconv.ParseInt(s.Next(), 10, 64)
	return v
}

func (s *Scanner) NextIntArray() []int {
	s.pre()
	start := s.p
	result := []int{}
	for ; s.p < len(s.buf)+1; s.p++ {
		if s.p == len(s.buf) || s.buf[s.p] == ' ' {
			v, _ := strconv.ParseInt(string(s.buf[start:s.p]), 10, 0)
			result = append(result, int(v))
			start = s.p + 1
		}
	}

	return result
}
func (s *Scanner) NextInt64Array() []int64 {
	s.pre()
	start := s.p
	result := []int64{}
	for ; s.p < len(s.buf)+1; s.p++ {
		if s.p == len(s.buf) || s.buf[s.p] == ' ' {
			v, _ := strconv.ParseInt(string(s.buf[start:s.p]), 10, 64)
			result = append(result, v)
			start = s.p + 1
		}
	}
	return result
}

func (s *Scanner) NextMap() map[int]bool {
	s.pre()
	start := s.p
	mp := map[int]bool{}
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			v, _ := strconv.Atoi(string(s.buf[start:s.p]))
			mp[v] = true
			start = s.p + 1
		}
	}
	v, _ := strconv.Atoi(string(s.buf[start:s.p]))
	mp[v] = true

	return mp
}

func (s *Scanner) pre() {
	if s.p >= len(s.buf) {
		s.readLine()
		s.p = 0
	}
}
func (s *Scanner) readLine() {
	s.buf = make([]byte, 0)
	for {
		l, p, e := s.r.ReadLine()
		if e != nil {
			panic(e)
		}
		s.buf = append(s.buf, l...)
		if !p {
			break
		}
	}
}


Measured memory_bytes: 4992
#include<iostream>
#include<algorithm>
#include<cmath>
#include<string>
#include<vector>
using namespace std;
int main() {
  int x,y;
  cin >> x >> y;
  if(x%y==0) {
    cout << -1 << endl;
  }
  else {
    cout << x << endl;
  }
}


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

#define REP(i, n) for(decltype(n) i = 0; i < (n); i++)
#define REP2(i, x, n) for(decltype(x) i = (x); i < (n); i++)
#define REP3(i, x, n) for(decltype(x) i = (x); i <= (n); i++)
#define RREP(i, n) for (decltype(n) i = (n) - 1;i >= 0; i--)

#define ALL(a) (a).begin(),(a).end()
#define SORT(c) sort((c).begin(),(c).end())
#define DESCSORT(c) sort(c.begin(), c.end(), greater<int>())

#define LL long long int
#define LD long double

#define INF 1000000000
#define PI 3.14159265358979323846

#define _CRT_SECURE_NO_WARNINGS

using namespace std;

// N, E, S, W
const int dx[4] = { -1, 0,  1,  0 };
const int dy[4] = { 0, 1,  0, -1 };

typedef pair<int, int> pii;
typedef pair<LL, LL> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<LL> vll;
//==============================================

int partition(vi &A, int p, int r) {
	int x = A[r];
	int i = p - 1;

	REP2(j, p, r) {
		if (A[j] <= x) {
			i++;
			swap(A[i], A[j]);
		}
	}

	swap(A[i + 1], A[r]);
	return i + 1;
}

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

	int n;
	cin >> n;

	vi A(n);
	REP(i, n) cin >> A[i];

	int q = partition(A, 0, n - 1);

	REP(i, n) {
		if (i) cout << " ";
		if (i == q) {
			cout << "[" << A[i] << "]";
		} else {
			cout << A[i];
		}
	}
	cout << "\n";
	return 0;
}

Measured memory_bytes: 3228
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define pb push_back
#define all(x) begin(x), end(x)
#define SZ(x) (int)(x).size()
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

const int n0 = 1e6 + 123;
int n, leaf[n0], dp[n0][26], t[26][n0], s[n0], sz;
vector <array <int, 2>> tv[n0];
array <int, 2> arr;

void add(string s) {
	int v = 0;
	for (int i = 0; i < SZ(s); i++) {
		int c = (s[i] - 'a');
		if (!t[c][v]) {
			t[c][v] = ++sz;
			arr[0] = c, arr[1] = sz;
			tv[v].pb(arr);
		}
		v = t[c][v];
	}
	leaf[v] = 1;
}

void dfs(int v) {
	s[v] = leaf[v];
	for (auto i : tv[v]) {
		int c = i[0], to = i[1];
		dfs(to);
		for (int j = 0; j < 26; j++) {
			if (c == j)
				dp[v][j] += s[to];
			else
				dp[v][j] += dp[to][j];
		}
		s[v] += s[to];
	}
}

ll ans;

void go(int v, int p, int ch) {
	if (leaf[v]) {
		ans += dp[p][ch] - 1;
	}
	for (auto i : tv[v]) {
		int c = i[0], to = i[1];
		go(to, v, c);
	}
}

int main() {
	ios_base::sync_with_stdio(false), cin.tie(NULL);
	cin >> n;
	while (n--) {
		string s;
		cin >> s;
		reverse(all(s));
		add(s);
	}
	dfs(0);
	go(0, -1, -1);
	cout << ans;
}


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

int main() { 
    ios_base::sync_with_stdio(0); 
    cin.tie(0);
    int n, m;
    cin >> n >> m;
    vector<int> a;
    for (int i = 0; i < n; i++) {
        int x;
        cin >> x;
        a.push_back(x);
    }
    vector<pair<int, int>> op(m);
    for (int i = 0; i < m; i++) {
        cin >> op[i].first >> op[i].second;
    }
    sort(op.begin(), op.end(), [&](auto x, auto y) {
        return x.second > y.second;
    });
    sort(a.rbegin(), a.rend());
    long long sum = 0;
    for (int i = 0; i < m; i++) {
        while (op[i].first--) {
            if (!a.empty() and a.back() < op[i].second) {
                sum += 1LL * op[i].second;
                a.pop_back();
            } else break;
        }
    }
    for (int x : a) sum += 1LL * x;
    cout << sum << '\n';
}

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

#define MAXN 100
int n, timecount = 1;
int ans[MAXN][MAXN];
int d[MAXN], f[MAXN]; // d[i]はdを最初に発見した時刻,f[i]は調べ終わった時刻
bool is_reach[MAXN];

int dfs(int p);

int main(void) {
    cin >> n;
    for (int i = 0; i < n; i++) {
        d[i] = -1;
        f[i] = -1;
        is_reach[i] = false;
    }
    for (int i = 0; i < n; i++)
        for (int j = 0; j < n; j++)
            ans[i][j] = 0;
    for (int i = 0; i < n; i++) {
        int u, k;
        cin >> u >> k;
        for (int j = 0; j < k; j++) {
            int tmp;
            cin >> tmp;
            ans[u-1][tmp-1] = 1;
        }
    }
//    for (int i = 0; i < n; i++) {
//        for (int j = 0; j < n; j++) {
//            if (j == n-1) cout << ans[i][j];
//            else cout << ans[i][j] << " ";
//        }
//        cout << endl;
//    }
    int start = 0;
    while (1) {
        dfs(start);
        int i;
//        printf("%d search end\n", start);
        for (i = 0; i < n; i++) {
            if (f[i] == -1) {
                start = i;
                break;
            }
        }
        if (i == n) break;
//        printf("next: %d\n", start);
    }
    for (int i = 0; i < n; i++) {
        printf("%d %d %d\n", i+1, d[i], f[i]);
    }
    return 0;
}

int dfs(int p)
{
    int ret = 0, count = 1;
    is_reach[p] = true;
    if (d[p] == -1) d[p] = timecount++;
    for (int i = 0; i < n; i++) {
        if (ans[p][i] == 1 && is_reach[i] == false && p != i) {
            dfs(i);
        }
    }
    if (f[p] == -1) f[p] = timecount;
    timecount++;
    return 0;
}

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

const int N = 2e5;
int tab[N + 7];
int n;
int wyn[N + 7];

int main() {
  ios_base::sync_with_stdio(0);
  cin >> n;
  for (int i = 1; i <= n; ++i) cin >> tab[i];
  
  bool ok = 1;
  
  long long wynik = 0;
  
  for (int i = 1; i <= n; ++i) {
    int x = i - tab[i];
    if (x < 1) ok = 0;
    else {
      wyn[x] = max(wyn[x], tab[i]);
    } 
  }
  
  if (ok) {
    int maxi = 0;
    for (int i = 1; i <= n; ++i) {
      if (tab[i] == 0 && maxi > i) ok = 0;
      if (wyn[i] > 0) {
        if (maxi > i + wyn[i]) ok = 0;
        maxi = max(maxi, i + wyn[i]);
      }
    }
  }
  
  if (!ok) cout << "-1" << endl;
  else {
    for (int i = 1; i <= n; ++i) wynik += wyn[i];
    cout << wynik << endl;
  }
  
  return 0;
} 

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#include <boost/range/algorithm.hpp>
#include <boost/range/numeric.hpp>
#include <boost/integer/common_factor.hpp>
#include <boost/integer/common_factor_rt.hpp>
#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/multiprecision/cpp_int.hpp>

using std::string;
using std::vector;
using std::set;
using std::multiset;
using std::unordered_set;
using std::map;
using std::multimap;
using std::unordered_map;
using std::pair;
using std::cin;
using std::cout;

using boost::multiprecision::cpp_int;
using cpp_dec_float_1000 = boost::multiprecision::number<boost::multiprecision::cpp_dec_float<1000, boost::int128_type>>;

typedef uintmax_t    ull;
typedef intmax_t     ll;
typedef uint64_t     ul;
typedef uint32_t     ui;
typedef uint8_t      uc;

constexpr char CRLF  = '\n';
constexpr char SPACE = ' ';
constexpr char VECTOR_COUT_SEPARATOR = SPACE;
constexpr ll INF = 1000'000'007;
constexpr int MOD = 1000'000'007;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> std::ostream& operator<< (std::ostream& os, const std::vector<T>& vc) { for(auto it = vc.begin(); it != vc.end(); ++it) { if (std::next(it) == vc.end()) os << *it; else os << *it << VECTOR_COUT_SEPARATOR; } return os; }
template<class T1, class T2> inline std::ostream & operator<< (std::ostream & os, const std::pair<T1, T2> & p) { return os << p.first << ' ' << p.second; }
template<class T> T modinv(T a, T m) { T b = m, u = 1, v = 0; while (b) { T t = a / b; a -= t * b; boost::swap(a, b); u -= t * v; boost::swap(u, v); } u %= m; if (u < 0) u += m; return u; }
template<class T> inline bool isSosuu(const T& n) { if (n == T(1)) { return false; } for (T i = 2; i*i <= n; ++i) { if (n % i == 0) { return false; } } return true; }
template<class T> vector<vector<T>> split (const vector<T>& S, T delim) { vector<vector<T>> ret{}; vector<T> buff{}; for (auto c : S) { if (c == delim) { if (!buff.empty()) ret.push_back(buff); buff.clear(); } else { buff.push_back(c); } } if (!buff.empty()) ret.push_back(buff); return ret; }
template<class T> inline void printYesNo(const T& t) { cout << (t ? "Yes" : "No") << CRLF; }
template<class T = int64_t> T modpow(T N, T P, T M) { T ret{1}; N %= M; while (P) { if (P & 0x01) { ret *= N; ret %= M; } P >>= 1; N *= N; N %= M; } return ret; }

/** code for assert debug begin */
int gErr = 0;
#define ASSERT(p) if(!(p)){ gErr = 1; }else{ ; }
/** code for assert debug end */

struct Tmp
{
public:
  int N;
  Tmp(int N)
  : N(N)
  {}
};

void solve(void)
{
  ll N, M; cin >> N >> M;

  ll a = 1;
  ll b = N / 2 - (N % 2 ? 0 : 1);
  ll c = N / 2 + 1;
  ll d = N;
  for (int i = 0; i < M; ++i) {
    if (a < b) {
      cout << a << SPACE << b << CRLF;
      ++a; --b;
    } else if (c < d) {
      cout << c << SPACE << d << CRLF;
      ++c; --d;
    } else {
      abort();
    }
  }
  return;
}

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

  solve();

  return 0;
}


Measured memory_bytes: 3628
#include<stdio.h>
#include<iostream>
using namespace std;
int main(){
	int H, W = 0;
	int h, w;
	
	while (1){
		cin >> H >> W;
		if (H == 0 && W == 0){
			break;
		}
		for (h = 0; H > h; h++){
			for (w = 0; W > w; w++){
				if (h == 0 || h == H-1 || w == 0 || w == W-1){
					cout << "#";
				}
				else{
					cout << ".";
				}
			}
			cout << endl;
		}
		cout << endl;
	}
	return 0;
}

Measured memory_bytes: 3076
import java.util.Scanner;
 
public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        long N = scanner.nextLong();
        long A = scanner.nextLong();
        long B = scanner.nextLong();
        long res = N / (A + B) * A;
        long m = N % (A + B);
        if(m>=A) res+=A;
        else res+=m;
        System.out.println(res);
    }
}

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

using ll = long long;
#define ld long double
#define ull unsigned long long int

#define rep(i, n) for (int i = 0; i < (int)(n); i++)  // (i, 10) i=0～i=9まで
#define repr(i, n) for (int i = n; i >= 0; i--)   // (i, 10) i=10～i=0まで
#define FOR(i, m, n) for (int i = m; i < n; i++)  // (i, 3, 10) i=3～i=9まで
#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) ((int)(x).size())
#define pb push_back
#define ret return

typedef pair<int, int>    pii;
typedef vector<int>       vi;
typedef vector<vi>        vii;
typedef vector<long long> vl;

// 総数を1000000007で割った余り
const long long mod = 1e9 + 7;
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

int main() {
    // cin.tie(0);
    // ios::sync_with_stdio(false);
    // cout << fixed << setprecision(5);

    // 入力
    string s;
    cin >> s;
    int n = s.size();
    for (int i = n / 2 - 1; i >= 0; i--) {
        // cout << s.substr(0, i) << " " << s.substr(i, i) << endl;
        if (s.substr(0, i) == s.substr(i, i)) {
            cout << 2 * i << endl;
            break;
        }
    }

    // 処理
    // 出力

    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>

std::vector<int> a;
int min=101, max=-101;
int N;
int ans = 1 << 30;
int main() {
	std::cin >> N;
	for (int i = 0; i < N; i++) {
		int tmp;
		std::cin >> tmp;
		min = std::min(min, tmp);
		max = std::max(max, tmp);
		a.push_back(tmp);
	}
	min--;
	while (min != max+1) {
		min++;
		int sum = 0;
		for (int i = 0; i < a.size(); i++) {
			sum += (a[i] - min)*(a[i] - min);
		}
		ans = std::min(ans, sum);
	}
	std::cout << ans << std::endl;
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<vector>
using namespace std;
double X1[110];
double X2[110];
double Y1[110];
double Y2[110];
double eps=1e-11;
double ABS(double a){return max(a,-a);}
double dist(pair<double,double>a,pair<double,double>b){
	return sqrt((a.first-b.first)*(a.first-b.first)+(a.second-b.second)*(a.second-b.second));
}
int main(){
	int a;
	while(scanf("%d",&a),a){
		for(int i=0;i<a;i++){
			scanf("%lf%lf%lf%lf",X1+i,Y1+i,X2+i,Y2+i);
		}
		int ret=1;
		for(int i=0;i<a;i++){
			vector<pair<double,double> >v;
			for(int j=0;j<i;j++){
				if(ABS((X2[i]-X1[i])*(Y2[j]-Y1[j])-(X2[j]-X1[j])*(Y2[i]-Y1[i]))<eps)continue;
				double a1=Y2[i]-Y1[i];
				double a2=Y2[j]-Y1[j];
				double b1=X1[i]-X2[i];
				double b2=X1[j]-X2[j];
				double c1=Y1[i]*(X2[i]-X1[i])-X1[i]*(Y2[i]-Y1[i]);
				double c2=Y1[j]*(X2[j]-X1[j])-X1[j]*(Y2[j]-Y1[j]);
				double det=a1*b2-a2*b1;
				double x=-(b1*c2-b2*c1)/det;
				double y=-(a2*c1-a1*c2)/det;
				if(x<-100.0+eps||y<eps-100.0||x>100.0-eps||y>100.0-eps)continue;
				v.push_back(make_pair(x,y));
			}
			ret++;
			//for(int j=0;j<v.size();j++)printf("%f %f\n",v[j].first,v[j].second);
			//printf("\n");
			for(int j=0;j<v.size();j++){
				bool ok=true;
				for(int k=0;k<j;k++){
					if(dist(v[j],v[k])<eps){ok=false;break;}
				}
				if(ok)ret++;
			}
		}
		printf("%d\n",ret);
	}
}

Measured memory_bytes: 1084
#include <stdio.h>

int main(){
  int A[100],N,i,j,tmp,flag=1,cnt=0;

  scanf("%d",&N);
  for(i=0;i<N;i++){
    scanf("%d",&A[i]);
  }

  while(flag == 1){
    flag = 0;
    for(j=N-1;j>0;j--){
      if(A[j]<A[j-1]){
	tmp = A[j];
	A[j] = A[j-1];
	A[j-1] = tmp;
	flag = 1;
	cnt++;
      }
    }
  }

  for(i=0;i<N;i++){
    printf("%d",A[i]);
    if(i+1 == N){
      printf("\n");
      break;
    }
    printf(" ");
  }
  printf("%d\n",cnt);
  
  return 0;
}



Measured memory_bytes: 2084
#include <bits/stdc++.h>
#define F first
#define S second
#define mp make_pair
#define pb push_back
#define ll long long
#define LEFT(a) ((a)<<1)
#define RIGHT(a) (LEFT(a) + 1)
#define MID(a,b) ((a+b)>>1)
#define MAX(a,b) ((a)>(b)?(a):(b))
#define MIN(a,b) ((a)<(b)?(a):(b))
//#define temo

using namespace std;
const ll N = 300000;

int m, n, x[N], a[N];
string s[N];
vector < pair < int, int > > P[N];
int main()
{
    cin>>m>>n;
    for (int i = 1; i <= n; i++){
        cin>>x[i]>>a[i];
        P[x[i]].pb ({a[i], i});
    }
    for (int i = 1; i <= m; i++)
        sort (P[i].begin(), P[i].end());
    for (int i = 1; i <= m; i++)
        for (int j = 0; j < P[i].size(); j++)
            a[P[i][j].S] = j + 1;
    for (int i = 1; i <= n; i++){
        int k;
        if (x[i] < 10)
            k = 5;
        else if (x[i] < 100)
            k = 4;
        else if (x[i] < 1000)
            k = 3;
        else if (x[i] < 10000)
            k = 2;
        else if (x[i] < 100000)
            k = 1;
        else
            k = 0;
        for (int j = 0; j < k; j++)
            cout<<"0";
        cout<<x[i];
        if (a[i] < 10)
            k = 5;
        else if (a[i] < 100)
            k = 4;
        else if (a[i] < 1000)
            k = 3;
        else if (a[i] < 10000)
            k = 2;
        else if (a[i] < 100000)
            k = 1;
        else
            k = 0;
        for (int j = 0; j < k; j++)
            cout<<"0";
        cout<<a[i]<<endl;
    }
    return 0;
}


Measured memory_bytes: 15232
def gcd(a, b) -> int:
  if(a < b):
    tmp = a
    a = b
    b = tmp
  if b == 0:
    return a
  return gcd(a % b, b)

def lcm(a, b) -> int:
  g = gcd(a, b)
  return a * (b // g)

N = int(input())
ans = int(1)
for i in range(N):
  t = int(input())
  ans = lcm(ans, t)
print(ans)

Measured memory_bytes: 3064
n, a, b = gets.split.map(&:to_i)
sa, sb = 0, 0
s = gets.chomp.split(//)
n.times do |i|
  if s[i] == 'a'
    if sa + sb < a + b
      sa += 1
      puts 'Yes'
    else
      puts 'No'
    end
  elsif s[i] == 'b'
    if sa + sb < a + b && sb < b
      sb += 1
      puts 'Yes'
    else
      puts 'No'
    end
  else
    puts 'No'
  end
end




Measured memory_bytes: 9852
#include <iostream>

#define MOD 1000000007

int main(void){
	int N;
  std::cin >> N;
  	int alphabet[26] = {};
  	char tmp;
  	for(int i = 0; i < N; ++i){
    	std::cin >> tmp;	
      	++alphabet[tmp - 'a'];
    }
  	long long result = 1;
  	for(int i = 0; i < 26; ++i){
      result = ( result * (alphabet[i] + 1)) % MOD;
    }
  	result  = (result - 1) % MOD;
  	std::cout << result;
  	return 0;
  	
}

Measured memory_bytes: 256