akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#pragma GCC optimize("O3")
#pragma GCC target("avx2")
#pragma optimize("JARU SOSISONI")

using namespace std;

#define int long long
#define fast cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);
#define geometry cout.setf(ios::fixed); cout.precision(15);
#define all(x) (x).begin(), (x).end()
typedef long long ll;
typedef long double ld;

const int INF = 1e18 + 100;
const int MOD1 = 998244353;
const int MOD = 1e9 + 7;
const int N = 10001;
const int nul = 0;
const int SIZE = 1e6 * 3;


signed main() {
#ifdef parasha
    freopen("A.in.txt", "r", stdin);
#endif // parasha
    fast;
    int n, m;
    cin >> n >> m;
    vector<int> smth(n, 0), cnt(n, 1);
    smth[0] = 1;
    for (int i = 0; i < m; i++) {
        int x, y;
        cin >> x >> y;
        x--; y--;
        if (smth[x]) {
            //cout << y << endl;
            smth[y] = 1;
        }
        cnt[x]--; cnt[y]++;
        if (cnt[x] == 0) smth[x] = 0;
    }
    int ans = 0;
    for (int i = 0; i < n; i++) {
        //cout << smth[i] << " ";
        ans += smth[i];
    }
    //cout << endl;
    cout << ans << endl;
}


Measured memory_bytes: 4772
#include "bits/stdc++.h"
using namespace std;
#define MOD 1000000007
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n)  FOR(i,0,n)
#define ITR(itr,mp) for(auto itr = (mp).begin(); itr != (mp).end(); ++itr)
#define dump(x)  cout << #x << " = " << (x) << endl;
#define debug(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
typedef long long ll;
typedef pair<ll,ll> P;
typedef vector<vector<P>> Graph;


int main(){

  int n,k;
  cin >> n >> k;
  
  int ans = 1;
  REP(i,n){
    if(ans < k) ans *= 2;
    else ans += k;
  }
  
  cout << ans << endl;

 return 0;
}

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

void solve()
{
    int n,k;
    cin>>n>>k;
    int a[n];
    for(int i=0; i<n; i++){
        cin>>a[i];
    }
    int dp[k+1];
    dp[0]=0;
    for(int i=1; i<=k; i++){
        dp[i]=0;
        for(int j=0; j<n; j++){
            if(i-a[j]>=0){
                dp[i]=max(dp[i],1-dp[i-a[j]]);
            }
        }
    }
    (dp[k]==1)?cout<<"First":cout<<"Second";
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int t;
    t=1;
    while(t--){
        solve();
        cout<<endl;
    }
}


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

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

int main(void)
{
    int n; cin>>n;
    double ans=2*n*M_PI;
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 3720
#include <iostream>
#include <algorithm>
using namespace std;
int main(){
  int n;

  while(  cin >> n,n ){
  int taro[10000] = {0},hana[10000] = {0},a;    
    for(int i = 0 ; i < n ; i++ ){
      cin >> a;
      taro[a] = a;
    }
    
    for(int i = 1 ; i <= 2*n ; i++){
      if(taro[i] == 0 )hana[i] = i;
    }
    
    sort(taro,taro + (2*n + 1));
    sort(hana,hana + (2*n + 1));
    
    int p = 1,k = 1; 
    for(int i = 1 ; i <= 2*n ; i++){
      if(taro[i] != 0)taro[p++] = taro[i];
      if(hana[i] != 0)hana[k++] = hana[i];
    }
    
    p = 1,k = 1;
    
    int turn = 0;
      
    while(1){
      
      int f1 = 0,f2 = 0;
      
      for(int i = 1 ; i <= n ; i++ ){
	
	if(taro[i] != 0)f1 = 1;
	if(hana[i] != 0)f2 = 1;
	
      }
      
      if(f1 == 0 || f2 == 0)break;
      
      if(turn == 0){
	
	if(k > n){
	  taro[p] = 0;
	  k = 1;
	  p = 1;
	  continue;
	  
	}
	
	if(taro[p] < hana[k] && taro[p] != 0){
	  
	  taro[p] = 0;
	  
	  p++;
	  
	  turn = 1;
	  
	  continue;

	}else k++;
	
	if(taro[p] == 0)p++;

      }else if(turn == 1){
	
	if(p > n){
	  hana[k] = 0;
	  p = 1;
	  k = 1;
	  continue;
	}
	
	if(taro[p] > hana[k] && hana[k] != 0){
	  
	  hana[k] = 0;
	  k++;
	  turn = 0;
	  continue;
	  
	}else p++;
	
	if(hana[k] == 0)k++;
	
      }
    }
    
    int cnt = 0,cnt2 = 0;
    
    for(int i = 1 ; i <= n ; i++ ){
      
      if(taro[i])cnt++;
      if(hana[i])cnt2++;
    }
    
    cout << cnt2 << endl;
    cout << cnt << endl;
    
  }
  return 0;
}

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

#define all(x) (x).begin(), (x).end()
#define pb push_back
#define mp make_pair
#define FILE "file"

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

const int INF = numeric_limits<int>::max();
const ll LLINF = numeric_limits<ll>::max();
const ull ULLINF = numeric_limits<ull>::max();
const double PI = acos(-1.0);

int main()
{
//    freopen(FILE".in", "r", stdin);
//    freopen(FILE".out", "w", stdout);
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int k, s;
    cin >> k >> s;
    int ans = 0;
    for(int i = 0; i <= k; i++)
        for(int j = 0; j <= k; j++)
            if(s - i - j >= 0 && s - i - j <= k)
                ans++;
    cout << ans;
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

    public static int s;
    public static int ans = 0;

    public static void main(String[] args) {

        Scanner scn = new Scanner(System.in);

        while(true){
            int n = scn.nextInt();
            s = scn.nextInt();
            if(n == 0 && s == 0) break;
            solve(0,n,0);
            System.out.println(ans);
            ans = 0;
        }
    }

    static void solve(int num, int n, int sum){
        if(n == 0 && sum == s){
            ans++;
            return;
        }
        if(num == 10) return;
        solve(num + 1, n - 1, sum + num);
        solve(num + 1, n ,sum);
        return;

    }
}


Measured memory_bytes: 26372
// failed to generate code

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef pair<int, P> P1;
typedef pair<P, P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000000000
#define mod 1000000007
#define fi first
#define sc second
#define rep(i, x) for (int i = 0; i < x; i++)
#define repn(i, x) for (int i = 1; i <= x; i++)
#define SORT(x) sort(x.begin(), x.end())
#define ERASE(x) x.erase(unique(x.begin(), x.end()), x.end())
#define POSL(x, v) (lower_bound(x.begin(), x.end(), v) - x.begin())
#define POSU(x, v) (upper_bound(x.begin(), x.end(), v) - x.begin())
vector<pair<string, P> > vec;

int main() {
    ll N, K;
    cin >> N >> K;
    vector<ll> a(N);
    rep(i, N) cin >> a[i];
    ll res = INF;
    rep(i, 1LL << N) {
        ll maxh = 0, now = 0;
        vector<ll> b(N);
        rep(j, N) {
            if ((i & 1LL << j) && maxh >= a[j]) {
                now += max(maxh + 1 - a[j], 0LL);
                b[j] = maxh + 1;
            } else {
                b[j] = a[j];
            }
            maxh = max(maxh, b[j]);
        }
        ll nowk = 0;
        maxh = 0;
        rep(j, N) {
            if (b[j] > maxh) nowk++;
            maxh = max(maxh, b[j]);
        }
        if (nowk >= K) res = min(res, now);
        // if (now == 4) cout << i << endl;
    }
    cout << res << endl;
}


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

H,W = map(int,input().split(" "))

mat = []
bomb = []
for i in range(H):
	S = list(input())

	for val,j in zip(S,range(W)):
		if val == '#':
			bomb.append((i,j))
		else:
			S[j] = 0

	mat.append(S)


def rep (i,j,mat,H,W):
	for k in [i-1,i,i+1]:
		for l in [j-1,j,j+1]:

			if (k < 0) or (k > (H-1)) or (l < 0) or (l > (W-1)):
				continue

			if mat[k][l] == '#':
				continue
			else:
				mat[k][l] += 1

for t in bomb:
	rep(t[0],t[1],mat,H,W)

for i in range(H):
	for j in range(W):
		print(mat[i][j],end="")
	print("")
	

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

#define vec                vector<int>
#define vecll              vector<ll>
#define vecd               vector<double>
#define vecst              vector<string>
#define vecb               vector<bool>
#define vec2(var, n, m)    vector<vector<int>> var(n, vector<int>(m, 0))
#define vecll2(var, n, m)  vector<vector<ll>> var(n, vector<ll>(m, 0))

#define rep(i,n)         for(ll i=(ll)0; i<(ll)n; i++)
#define REP(i,m,n)       for(ll i=(ll)m; i<(ll)n; i++)
#define arr(var, n)      vec var(n); rep(i,n){cin >> var[i];}
#define arrll(var, n)    vecll var(n); rep(i,n){cin >> var[i];}
#define arrst(var, n)    vecst var(n); rep(i,n){cin >> var[i];}
#define all(var)         (var).begin(), (var).end()
#define sortall(var)     sort(all(var))
#define uniqueall(v)     v.erase(unique(v.begin(), v.end()), v.end());
#define f_sum(var)       accumulate(all(var), 0)
#define f_sumll(var)     accumulate(all(var), 0LL)
#define chmin(v1, v2)    v1 = min(v1, v2)
#define chmax(v1, v2)    v1 = max(v1, v2)
#define pb(var)          push_back(var)
#define prt(var)         cout << (var) << "\n"
#define prtd(n, var)     cout << fixed << setprecision(n) << var << "\n"
#define prtfill(n, var)  cout << setw(n) << setfill('0') << var;
#define prt2(v1, v2)     cout << v1 << " " << v2 << "\n"
#define prt3(v1, v2, v3) cout << v1 << " " << v2 << " " << v3 << "\n"
#define prtall(v)        rep(i,v.size()){cout<<v[i]<<(i!=v.size()-1?" ":"\n");}
void prtok(bool ok){prt(ok ? "yes" : "no");}
//----------------------------------------------------------------
#define bitrep(i, n)     for(ll i=0; i<(ll) (1<<(n)); i++)
#define bis(i, j)        i & (1<<j)

int main(void) {
  int n;
  cin >> n;
  arr(p,n);
  arr(q,n);

  vec v;
  rep(i,n){
    v.pb(i+1);
  }
  int now=0;
  int a, b;
  do {
    now++;
    if(v==p){
      a=now;
    }
    if(v==q){
      b=now;
    }
  } while(next_permutation(all(v)));

  prt(abs(a-b));
}


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

long x,a,b;

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

  long judge = b - a;
  if(judge <= 0){
    cout << "delicious" << endl;
  }else if(x >= judge){
    cout << "safe" << endl;
  }else{
    cout << "dangerous" << endl;
  }
}


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


int main() {
    int a, b, c;
    cin >> a >> b >> c;
    int res = 100*a + 10*b + c;
    if(res%4 == 0){
        cout << "YES" << endl;
    }
    else{
        cout << "NO" << endl;
    }
}


Measured memory_bytes: 256
n = gets.chomp.to_i
a = gets.chomp.split(' ').map(&:to_i)
odd = a.select { |item| item % 2 != 0 }.count
even = n - odd
four = a.select { |item| item % 4 == 0}.count

if even - four > 0
  print odd > four ? 'No' : 'Yes'
else
  print odd > (four + 1) ? 'No' : 'Yes'
end

Measured memory_bytes: 10244
#include <algorithm>
#include <cassert>
#include <cstring>
#include <iostream>

using namespace std;

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define TRACE(x) cout << #x << " = " << x << endl
#define _ << " _ " <<

typedef long long llint;

int main(void) {
  llint K;
  scanf("%lld", &K);

  vector<llint> v(8, 0);
  v[0] = 1;

  vector<llint> val;
  while (true && val.size() < 500) {
    FOR(i, 1, 8) v[i] += v[i-1];
    bool done = false;
    REP(i, 8) done |= v[i] > K;
    if (done) break;
    val.push_back(v.back());
  }

  vector<llint> cnt(val.size());
  for (int i = (int)val.size()-1; i >= 0; --i) {
    cnt[i] = K / val[i];
    K %= val[i];
  }

  string x = "FESTIVA";
  string ans;
  REP(i, (int)val.size()) {
    ans += x;
    REP(j, cnt[i]) ans += "L";
  }

  assert(ans.size() <= 5000);
  puts(ans.c_str());
  
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define SORT(a) sort((a).begin(), (a).end())
#define RSORT(a) reverse((a).begin(), (a).end())
#define rep(i, n) for (int i = 0; i < n; i++)
#define all(a) ((a).bigin(), (a).end())
typedef long long ll;
const long long INF = 1LL << 60;
// const int INF=1010101010;
using Graph = vector<vector<int>>;

int main() {
  int n, h;
  cin >> n >> h;
  vector<ll> a(n);
  vector<ll> b(n);
  rep(i, n) cin >> a[i] >> b[i];
  int maxA = *max_element(a.begin(), a.end());
  SORT(b);
  RSORT(b);
  int cnt = 0;
  rep(i, n) {
    if (b[i] < maxA) break;
    h -= b[i];
    cnt++;
    if (h <= 0) break;
  }
  while (h > 0) {
    h -= maxA;
    cnt++;
  }
  cout << cnt << endl;
}


Measured memory_bytes: 1792
using System;

class Program
{
    const int MAX_DIGIT = 50;
    static void Main(string[] args)
    {
        var nk = Console.ReadLine().Split();
        var n = long.Parse(nk[0]);
        var k = long.Parse(nk[1]);
        var a = Array.ConvertAll(Console.ReadLine().Split(), long.Parse);

        var dp = new long[MAX_DIGIT + 1, 2];
        for (int i = 0; i <= MAX_DIGIT; i++) dp[i, 0] = dp[i, 1] = -1;

        dp[0, 0] = 0;
        for (int i = 0; i < MAX_DIGIT; i++)
        {
            var mask = 1L << (MAX_DIGIT - i - 1);

            var x = 0;
            for (int j = 0; j < a.Length; j++)
            {
                if (0 < (a[j] & mask))
                {
                    x++;
                }
            }

            var cost0 = x * mask;
            var cost1 = (a.Length - x) * mask;

            if (0 <= dp[i, 1])
            {
                dp[i + 1, 1] = dp[i, 1] + Math.Max(cost0, cost1);
            }

            if (0 <= dp[i, 0])
            {
                if (0 < (k & mask))
                {
                    dp[i + 1, 0] = dp[i, 0] + cost1;
                    dp[i + 1, 1] = Math.Max(dp[i + 1, 1], dp[i, 0] + cost0);
                }
                else
                {
                    dp[i + 1, 0] = dp[i, 0] + cost0;
                }
            }
        }

        var ans = Math.Max(dp[MAX_DIGIT, 0], dp[MAX_DIGIT, 1]);
        Console.WriteLine(ans);
    }
}

Measured memory_bytes: 28636
use List::Util 'min';

($a, $b, $k) = split(/ /, <>);

$cnt = 1;
for ($i = min($a, $b); $i >= 1; $i--){
	if((($a % $i) == 0) and (($b % $i) == 0)){
		if($cnt == $k){
			print "$i\n";
			exit;
		}else{
			$cnt++;
		}
	}
}

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

namespace ConsoleApp10
{
    class Program
    {
        static void MainA(string[] args)
        {
            Console.WriteLine(Console.ReadLine().ToCharArray().Zip(Console.ReadLine().ToCharArray(), (x, y) => x == y).Count(x => x));
        }

        static void MainB()
        {
            var arr = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
            var ans = (arr[1] - 1 + arr[0] - 2) / (arr[0] - 1);
            Console.WriteLine(ans);
        }

        static void Main()
        {
            Console.ReadLine();
            var arr = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();

            int cnt = 0;
            int cntmax = 0;
            for (int i = 0; i < arr.Length - cntmax-1; i++)
            {
                cnt = 0;
                for (int j = i + 1; j < arr.Length; j++)
                {
                    if (arr[j - 1] >= arr[j])
                        cnt++;
                    else
                    {

                        break;
                    }
                }
                if (cnt > cntmax)
                    cntmax = cnt;
            }
            Console.WriteLine(cntmax);
        }
    }
}

Measured memory_bytes: 26204
#include <iostream>
#include <vector>
#include <array>
#include <set>
#include <cmath>
#include <string>
#include <queue>
#include <list>
#include <unordered_map>
#include <algorithm>
#include <functional>
#include <iomanip> // std::std::setprecision(X)
#include <limits>  //std::numeric_limits<int>::max(), min()

int main (void) {

  int H, W; std::cin >> H >> W;

  std::vector<std::vector<int>> a(H, std::vector<int>(W,0));
  for(int i=0; i<H; i++) for(int j=0; j<W; j++) std::cin >> a[i][j];


  std::vector<std::pair<int,int>> ans1, ans2;
  bool flag = false;
  for(int i=0; i<H; i++) {
    for(int j=0; j<W; j++) {
      int k = (i%2==0) ? j : W-j-1;
      if ( flag ) {
        ans2.push_back( {i+1, k+1} );
        a[i][k] += 1;
        flag = false;
      }
      if ( a[i][k] % 2 != 0 ) {
        ans1.push_back( {i+1, k+1} );
        flag = true;
      }
    }
  }

  std::cout << ans2.size() << std::endl;
  for(int i=0; i<ans2.size(); i++) std::cout << ans1[i].first << " " << ans1[i].second << " " << ans2[i].first << " " << ans2[i].second << std::endl;



  return 0;
}

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

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define FOR(i, n) for (int i = 0; i < int(n); i++)
#define FOR1(i, m, n) for (int i = int(m); i < int(n); i++)
#define MAX(a, b) ((a) >= (b) ? (a) : (b))
#define MIN(a, b) ((a) <= (b) ? (a) : (b))

ull powULL(ull base, unsigned exp) {
  if (exp == 0)
    return 1;
  else if (exp % 2 == 0)
    return powULL(base * base, exp / 2);
  else
    return base * powULL(base, exp - 1);
}

int nlz(ull a) {
  int i = 64;
  while (a > 0) {
    i--;
    a >>= 1;
  }
  return i;
}

ull dp(ull a, ull b) {
  int i = 0, j = 0;

  i = 63 - nlz(a);
  j = 63 - nlz(b);

  if (a == 0) return powULL(2, j + 1);

  ull tmp1 = powULL(2, j);
  int k = 63 - nlz(b-tmp1);
  ull tmp2 = powULL(2, k+1);
  if (i == j)
    return dp(a - tmp1, b - tmp1);
  else if (a >= tmp2)
    return 2*tmp1 + tmp2 - 2 * a;
  else
    return 2 * tmp1 - a;
}

int main(int argc, char *argv[]) {
  ull A, B;

  cin >> A >> B;
  cout << dp(A, B) << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <iosfwd>
#include <iomanip>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <ctime>
#include <cmath>
#include <cassert>
#include <cctype>
#include <climits>
#include <vector>
#include <bitset>
#include <set>
#include <queue>
#include <math.h>
#include <stack>
#include <map>
#include <deque>
#include <string>
#include <list>
#include <iterator>
#include <sstream>
#include <complex>
#include <fstream>
#include <functional>
#include <numeric>
#include <utility>
#include <algorithm>
#include <assert.h>
#include <unordered_map>
#pragma GCC optimize ("-O3")
using namespace std;
#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); cerr.tie(NULL);
#define tolower(s) transform(s.begin(),s.end(),s.begin(),::tolower);
#define toupper(s) transform(s.begin(),s.end(),s.begin(),::toupper);
#define ll long long int
ll max(ll a, ll b) {  return a > b ? a : b; }
ll gcd(ll a, ll b) { if (a == 0) return b; return b == 0 ? a : gcd(b, a % b);}
#define case(i) cout<<"Case #"<<i<<": ";
#define debug(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) { cerr << "[ " << *it << " = " << a << " ]"; err(++it, args...); }
#define pii pair <ll , ll >
#define pb push_back
#define PRECISION 10
const ll inf = 1e16;
const int MAXN = 100001;
const int LOGN = 22;
const int MAXBIT = 61;
const int DIGITSIZE = 19;
ll mod = 1e9 + 7;
ll MOD = 998244353;
int x4[] = {1, -1, 0, 0};
int y4[] = {0, 0, 1, -1};
bool take_test_cases = false;
bool print_case_no = false;

void getac(int T) {
    int n;
    cin>>n;
    unordered_map < ll , ll > m;

    ll arr[n];
    ll ans=0;
    for(int i=0;i<n;i++){
        cin>>arr[i];
        //cout<<arr[i]+i+1<<' '<<arr[i]-i-1<<'\n';
        ans+=m[i-arr[i]];
        m[i+arr[i]]++;
    }
    cout<<ans<<'\n';

}
int  main()
{

    fastio;
    int t = 1;
    if (take_test_cases) cin >> t;
    int t_t = 1;
    while (t--) {
        if (print_case_no)
        case (t_t);
        getac(t_t);
        t_t++;
    }
    return 0;
}

Measured memory_bytes: 19956
#include <stdio.h>

int main(void)
{
	int a[6];
	int g;
	
	scanf("%d %d %d %d %d %d", &a[0], &a[1], &a[2], &a[3], &a[4], &a[5]);
	
	g = (a[0] * 1) + (a[1] * 5) + (a[2] * 10) + (a[3] * 50) + (a[4] * 100) + (a[5] * 500);
	
	if (g >= 1000){
		printf("1\n");
	}
	else {
		printf("0\n");
	}
	
	return (0);
}

Measured memory_bytes: 584
//
//  main.cpp
//

#include <algorithm>
#include <array>
#include <assert.h>
#include <complex>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <math.h>
#include <memory>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <vector>

using namespace std;

using ll = int64_t;
using ull = uint64_t;
constexpr ll LL_MAX = numeric_limits<ll>::max();
constexpr ull ULL_MAX = numeric_limits<ull>::max();

template<typename T>
vector<T> make_vec_nd(T init, ll size) {
	return vector<T>(size, init);
}
template<typename T, typename... Args>
auto make_vec_nd(T init, ll size, Args... rest) {
	auto inner = make_vec_nd(init, rest...);
	return vector<decltype(inner)>(size, inner);
}

#define rep(i, a, b) for (ll i = (a); i < (b); i++)
#define rrep(i, a, b) for (ll i = (a)-1; i >= (b); i--)

struct P {
    ll x;
    ll y;
    bool operator==(const P& rhs) const { return x == rhs.x && y == rhs.y; }
    P operator+(P rhs) { return {x + rhs.x, y + rhs.y}; }
    P operator-(P rhs) { return {x - rhs.x, y - rhs.y}; }
    P operator-() { return {-x, -y}; }
    ll operator*(P rhs) { return x * rhs.x + y * rhs.y; }
    P operator*(ll k) { return {x * k, y * k}; }
    P operator/(ll k) { return {x / k, y / k}; }
    ll len_sq() { return (*this) * (*this); }
    ll len() { return sqrt(len_sq()); }
};

namespace std {
    template<>
    struct hash<P> {
        size_t operator()(P key) const {
            char buf[16];
            memcpy(buf, &key.x, 8);
            memcpy(buf + 8, &key.y, 8);
            return hash<string>()(buf);
        }
    };
}

int main() {
    ll N;
    cin >> N;
    vector<P> pts(N);
    rep(i,0,N) {
        cin >> pts[i].x >> pts[i].y;
    }
    unordered_map<P, ll> cnt;
    rep(i,0,N) {
        rep(j,0,N) {
            if (i == j) {
                continue;
            }
            P diff = pts[i] - pts[j];
            cnt[diff]++;
        }
    }
    if (N == 1) {
        cout << 1 << endl;
        return 0;
    }
    ll max_cnt = numeric_limits<ll>::min();
    for (auto& kv : cnt) {
        max_cnt = max(max_cnt, kv.second);
    }
    cout << N - max_cnt << endl;
}


Measured memory_bytes: 512
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a=sc.nextInt();
		int b=sc.nextInt();
		int X=sc.nextInt();
		int cat;
		int dog;
		if(a<1 || a>100){
			System.out.println("NO");
			return;
		}
		if(b<1 || b>100){
			System.out.println("NO");
			return;
		}
		if(X<a ||  X>=(a+b)){
			System.out.println("NO");
			return;
		}
		else{
			System.out.println("YES");
		}
	}
}

Measured memory_bytes: 22740
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double

struct unionfind{
    vector<int> parent;
    vector<int> rank;
    vector<int> size;

    unionfind (int N) {
        parent = vector<int>(N);
        iota(parent.begin(), parent.end(), 0);
        rank = vector<int>(N, 0);
        size = vector<int>(N, 1);
    }
    int root(int x) {
        if (parent[x] == x) return x;
        parent[x] = root(parent[x]);
        return parent[x];
    }
    
    bool same(int x, int y){
        return root(x) == root(y);
    }
    
    void unite(int x, int y){
        x = root(x);
        y = root(y);
        if (x == y) return;
        if (rank[x] > rank[y]) {
            parent[y] = x;
            size[x] += size[y];
        }
        else {
            parent[x] = y;
            size[y] += size[x];
            if (rank[x] == rank[y]) rank[y] += 1;
        }
    }
    
    int getsize(int x) {
        return size[root(x)];
    }
};

int main() {
    int N;
    cin >> N;
    unionfind uf(N);
    vector<pair<pair<int, int>, int>> town(N);
    for (int i = 0; i < N; i++) {
        int x, y;
        cin >> x >> y;
        town[i] = {{x, y}, i};
    }
    sort(town.begin(), town.end());
    set<pair<int, int>> st;
    for (int i = 0; i < N; i++) {
        pair<int, int> pii = {town[i].first.second, town[i].second};
        auto it = st.lower_bound(pii);
        if (it == st.begin()) {
            st.insert(pii);
        }else {
            auto it2 = st.begin();
            uf.unite((*it2).second, pii.second);
            it2++;
            while (it2 != st.end() && (*it2).first < town[i].first.second) {
                uf.unite((*it2).second, pii.second);
                it2 = st.erase(it2);
            }
        }
    }
    
    for (int i = 0; i < N; i++) {
        cout << uf.getsize(i) << endl;
    }
    
    return 0;
}


Measured memory_bytes: 12084
use proconio::{fastout, input};

#[fastout]
fn main() {
    input! {
        (x,y): (usize, usize),
    };

    for i in 0..=100 {
        for j in 0..=100 {
            if i + j == x && 2 * i + 4 * j == y {
                println!("Yes");
                return;
            }
        }
    }

    println!("No");
}


Measured memory_bytes: 2136
//#pragma GCC optimize(3)

#include<bits/stdc++.h>
#define MST(a,b) memset(a,b,sizeof(a))
#define pb push_back
#define eb emplace_back
#define rep(i,a,b) for(int i = a ; i < b ; ++i)
#define per(i,a,b) for(int i = a ; i > b ; --i)
#define ALL(v) v.begin(),v.end()
#define ft first
#define sd second
using namespace std;
namespace fast_IO{
    const int maxbuff = 1<<17;
    char ibuff[maxbuff],obuff[maxbuff];
    inline char Getchar(){
        static char *p1=ibuff,*p2=ibuff;
        if(p1 == p2) {
            p1 = ibuff;
            p2 = ibuff+fread(ibuff,1,maxbuff,stdin);
            if(p1 == p2) return -1;
        }
        return *p1++;
    }

    int optr = 0;
    inline void Putchar(char c) {
        if(optr == maxbuff) {fwrite(obuff,1,optr,stdout);optr = 0;}
        obuff[optr++] = c;
    }

    inline void Flush() {
        fwrite(obuff,1,optr,stdout);
    }

    template<class T>
    inline int read(T &x) {
        x = 0;
        char c = Getchar();
        if(c == EOF) return -1;
        for( ; (c < '0' || c > '9') && c != EOF ; c = Getchar());
        if(c == EOF) return -1;
        for( ; c >= '0' && c <= '9' ; c = Getchar()) x = x*10+c-'0';
        return 0;
    }

    template<class T>
    inline void write(const T &x,int tag = 0) {
        if(!x) {
            if(!tag) Putchar(x+'0');
            return ;
        }
        write(x/10,1);
        Putchar(x%10+'0');
    }

    template<class T>
    inline void writeln(const T &x) {
        write(x);Putchar('\n');
    }

    template<class T>
    inline void writesp(const T &x) {
        write(x);Putchar(' ');
    }
}
template<class T> void show(T *x,int len,int s = 0) {for(int i = s ; i < s+len-1 ; ++i) cerr << x[i] << ' ';cerr << x[s+len-1] << endl;}
void debug() {cerr << endl;}
template <typename T, typename... Args> void debug(T x,Args... args) {cerr << x << ' ';debug(args...);}
typedef long long LL;
typedef unsigned long long ULL;
typedef pair<int,int> pii;
#include <ext/pb_ds/priority_queue.hpp>
using namespace __gnu_pbds;
typedef __gnu_pbds::priority_queue<pii,greater<>,pairing_heap_tag> heap;
typedef heap::point_iterator iter;

template<class T>
inline void cmin(T &A,const T &B) {A = (A<B?A:B);}
template<class T>
inline void cmax(T &A,const T &B) {A = (A>B?A:B);}

void solve() {
    int mx = 1e9+7;
    int n;
    cin >> n;
    int ans = 0;
    for(int i = 1; i <= n ; ++i) {
        int x;
        cin >> x;
        if(x <= mx) ++ans;
        mx = min(x,mx);
    }
    cout << ans << endl;
}
signed main() {
#ifdef LOCAL
    //freopen("input","r",stdin);
    //freopen("output","w",stdout);
#endif
    srand((int)time(0));
    ios::sync_with_stdio(0);
    int T = 1;
    //cin >> T;
    while(T--) solve();
}

Measured memory_bytes: 256
d[999],f,l,i,T;main(t,w){for(;i=~scanf("%as",&w)?:!printf("%s %s\n",d[f],d[l]);t>T?T=t,l=i:0){for(;d[i+=2]&&strcmp(d[i],w););t=strlen(d[i]=w);++d[i+1]>d[f+1]?f=i:0;}}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < n; i++)
#define vi vector<int>
#define vvi vector<vi>
#define pii pair<int, int>
#define mod 1000000007
using ll = long long;
using namespace std;
int main(){
  string s;
  cin >> s;
  if(s == "ABC") cout << "ARC" << endl;
  else cout << "ABC" << endl;
}

Measured memory_bytes: 3624
#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
string s;
int main()
{
    //IOS;
    cin>>s;
    if(s=="ABC")
    {
        cout<<"ARC";
    }
    else
    {
        cout<<"ABC";
    }
    return 0;
}
/*

*/


Measured memory_bytes: 3592
use std::str::FromStr;
use std::fmt::Debug;
use std::cmp;

// 標準入力
fn read_line<T>() -> Vec<T>
where T: FromStr, <T as FromStr>::Err : Debug {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().split_whitespace().map(|c| T::from_str(c).unwrap()).collect()
}

fn main() {
    let vec: Vec<usize> = read_line();
    let n = vec[0];
    let mut abcs: Vec<Vec<i32>> = Vec::new();
    let mut dp: Vec<Vec<i32>> = Vec::new();
    for _ in 0..n {
        let abc: Vec<i32> = read_line();
        abcs.push(abc);
        dp.push(Vec::new());
    }

    // calc
    dp[0] = abcs[0].clone();
    for i in 1..n {
        for j in 0..3 {
            let mut indices: Vec<usize> = vec![0, 1, 2];
            indices.remove(j);
            let score = cmp::max(
                dp[i - 1][indices[0]] + abcs[i][j],
                dp[i - 1][indices[1]] + abcs[i][j]
            );
            dp[i].push(score);
        }
    }

    let ans = [
        dp[n - 1][0],
        dp[n - 1][1],
        dp[n - 1][2],
    ];
    println!("{}", ans.into_iter().max().unwrap());
}


Measured memory_bytes: 14260
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
 
int main(){
    ll a, b, x;
    cin >> a >> b >> x;

    ll low, up;
    if(a%x == 0){
        low = a/x;
    }else{
        low = a/x + 1;
    }
    up = b/x;

    cout << up - low + 1 << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define FOR(i,l,r) for(i=l;i<r;i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(x) x.begin(),x.end()
#define P pair<ll,ll>
#define F first
#define S second
signed main(){
  ll i;
  REP(i,365)cout<<(365-i)%26+1<<endl;
  return 0;
}

Measured memory_bytes: 3616
n,d=map(int,input().split())
c=0
for i in range(n):
  import math
  
  x,y=map(int,input().split())
  #print(math.sqrt(x*x+y*y))
  if math.sqrt(x*x+y*y)<=d:
    c+=1
print(c)
    


Measured memory_bytes: 72968
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, srt, end) for (long long i = (srt); i < (long long)(end); i++)
#define VL vector<ll>
#define VS vector<string>
#define VB vector<bool>
#define VP vector<pair<ll,ll>>
#define VVL vector<vector<ll>>
#define VVP vector<vector<pair<ll,ll>>>
#define PL pair<ll,ll>
#define ALL(v) (v).begin(), (v).end()
ll d1[4] = {1, -1, 0, 0};
ll d2[4] = {0, 0, 1, -1};

int main(){
    ll N;
    cin >> N;
    VL t(N+1), x(N+1), y(N+1);
    x[0] = 0; y[0] = 0; t[0] = 0;
    rep(i, 1, N+1) cin >> t[i] >> x[i] >> y[i];
    rep(i, 0, N){ // ?
        ll diff = abs(x[i+1] - x[i]) + abs(y[i+1] - y[i]);
        if(diff > t[i+1] - t[i] || diff % 2 != (t[i+1] - t[i]) % 2){
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
    return 0;
}


Measured memory_bytes: 2560
#include <stdio.h>
#include <string.h>

#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <vector>

#define REP(i, n) for(int i = 0; (i) < (n); ++(i))
#define FOR(i, n) for(int i = 1; (i) <= (n); ++(i))
#define dump(x) cout << #x << " = " << (x) << endl;
#define pb push_back
#define int long long

const int INF = 1e18;
const int MOD = 1e9 + 7;
// const lint LINF = 1e18;
const double eps = 0.000000001;  //もとの値の10^(-16)まで

using namespace std;

// typedef pair<int, int> P;
// priority_queue< P, vector<P>, greater<P> > q;//ダイクストラの時、greaterで小さい順
// cout << fixed << setprecision(10) << ans << endl;
// int gcd(int a,int b){return b?gcd(b,a%b):a;}





/*
lower_boundnのtips
探索したいkey以上のイテレータを返す
vector<int> a = {1, 4, 4, 7, 7, 8, 8, 11, 13, 19};

    //イテレータを返す
    auto Iter1 = lower_bound(ALL(a), 4);
    auto Iter2 = lower_bound(ALL(a), 6);
    auto Iter3 = lower_bound(ALL(a), 7);
    auto Iter4 = lower_bound(ALL(a), 19);
    auto Iter5 = lower_bound(ALL(a), 20);

    //値の表示
    cout << "----------value----------" << endl;
    cout << "Iter1 = " << *Iter1 << endl; //Iter1 = 4
    cout << "Iter2 = " << *Iter2 << endl; //Iter2 = 7
    cout << "Iter3 = " << *Iter3 << endl; //Iter3 = 7
    cout << "Iter4 = " << *Iter4 << endl; //Iter4 = 19
    cout << "Iter5 = " << *Iter5 << endl; //Iter5 = 1326115891

    //先頭からの距離
    cout << "----------from----------" << endl;
    cout << "Iter1 = " << Iter1 - a.begin() << endl; //Iter1 = 1
    cout << "Iter2 = " << Iter2 - a.begin() << endl; //Iter2 = 3
    cout << "Iter3 = " << Iter3 - a.begin() << endl; //Iter3 = 3
    cout << "Iter4 = " << Iter4 - a.begin() << endl; //Iter4 = 9
    cout << "Iter5 = " << Iter5 - a.begin() << endl; //Iter5 = 10

    //末尾までの距離
    cout << "----------to----------" << endl;
    cout << "Iter1 = " << a.end() - Iter1 << endl; //Iter1 = 9 
    cout << "Iter2 = " << a.end() - Iter2 << endl; //Iter2 = 7
    cout << "Iter3 = " << a.end() - Iter3 << endl; //Iter3 = 7
    cout << "Iter4 = " << a.end() - Iter4 << endl; //Iter4 = 1
    cout << "Iter5 = " << a.end() - Iter5 << endl; //Iter5 = 0

    return 0;

*/

string a[3000000];

int ban[3000000][30];

signed main() {
  int n;
  cin >> n;
  REP(i, n) {
    cin >> a[i];
    reverse(a[i].begin(), a[i].end());
  }

  sort(a, a + n);

  REP(i, n) {
    REP(j, a[i].size()) {
      ban[i][a[i][j] - 'a']++;
    }
  }

  int ans = 0;

  REP(i, n) {
    string now = a[i];
    string now1 = now.substr(0,now.size()-1);
    
    char now2 = now[now.size() - 1];

    int basyo = lower_bound(a,a+n, now1 + '{') - a;

    int basyo2 = lower_bound(a,a+n, now1 + '`') - a;
    

    for(int j = basyo2;j<basyo;j++){
        if(ban[j][(now2-'a')]- ban[i][(now2-'a')] >= 0) ans++;
    }
  }
  cout <<ans-n << endl;

  return 0;
}

Measured memory_bytes: 144080
import numpy as np
N,M = map(int, input().split())
AB = []
for i in range(N):
  tmp = list(map(int, input().split()))
  AB.append(tmp)
AB.sort()

count = 0
total_price = 0
i = 0
while count < M:
  total_price += AB[i][0]*AB[i][1]
  count += AB[i][1]
  i += 1
  if i == N:
    break

if count == M:
  print(int(total_price))
else:
  print(int(total_price-(count-M)*AB[i-1][0]))
  
  


Measured memory_bytes: 45428
# input
N = int(input())
X = list(map(int, input().split()))

# process
L = min(X)
R = max(X)

ans = float('inf')
for i in range(L, R+1):
    cost = 0
    for x in X:
        cost += (x-i)**2
    
    if cost < ans:
        ans = cost

# output
print(int(ans))


Measured memory_bytes: 3060
#include<stdio.h>

int main(void)
{
   int a, b, i, j, t[5], tmp, sum=0;
   scanf("%d%d",&a,&b);
   for(i=a;i<=b;i++){
      tmp=i;
      t[0]=tmp%10;
      t[1]=(tmp-t[0])%100/10;
      t[2]=(tmp-t[0]-t[1])%1000/100;
      t[3]=(tmp-t[0]-t[1]-t[2])%10000/1000;
      t[4]=(tmp-t[0]-t[1]-t[2]-t[3])%100000/10000;

      if(t[0]==t[4]&&t[1]==t[3]) sum++;
   }
   printf("%d",sum);
   return 0;
}

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

#define REP(i, x, n) for (int i = x; i < (int)(n); i++)
#define rep(i, n) REP (i, 0, n)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) (int)(x.size())
#define popcount(x) __builtin_popcount(x)
#define popcountll(x) __builtin_popcountll(x)
#define uniq(x) x.erase(unique(x.begin(), x.end()), x.end())
#define F first
#define S second
#define mp make_pair
#define eb emplace_back

using namespace std;

typedef long long ll;

// const int INF = 1 << 30;
// const ll INF = 1LL << 60;
// const int MOD = 1000000007;

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

  vector<int> a(n);
  rep (i, n) cin >> a[i];

  sort(all(a));

  int idx = 0;
  rep (i, n - 1) {
    if (min(a[idx], a[n - 1] - a[idx]) < min(a[i], a[n - 1] - a[i])) idx = i;
  }

  cout << a[n - 1] << ' ' << a[idx] << endl;
}


Measured memory_bytes: 640
# Acceptance of input
import sys

file_input = sys.stdin

n = file_input.readline()

EP = []

for line in file_input:
    x1, y1, x2, y2 = (map(int, line.split()))
    # point[2] corresponds to the position of the end point.
    # 1 is left, 2 is lower, 3 is upper and 4 is right.
    if y1 < y2:
        p1 = (x1, y1, 2)
        p2 = (x2, y2, 3)
    elif y1 > y2:
        p1 = (x1, y1, 3)
        p2 = (x2, y2, 2)
    elif x1 < x2:
        p1 = (x1, y1, 1)
        p2 = (x2, y2, 4)
    else:
        p1 = (x1, y1, 4)
        p2 = (x2, y2, 1)
    EP += [p1, p2]

# Sweep function
import bisect

def manhattan_intersection(point_list):
    point_list.sort(key = lambda p: (p[1], p[0], p[2]))
    T = []
    cnt = 0
    flag = False
    for p in point_list:
        position = p[2]
        if position == 3:
            i = bisect.bisect_left(T, p[0])
            T.pop(i)
            if flag:
                cnt += 1
        elif position == 2:
            bisect.insort(T, p[0])
        elif position == 4:
            cnt += bisect.bisect(T, p[0]) - left_end
            flag = False
        else:
            left_end = bisect.bisect_left(T, p[0])
            flag = True
    print(cnt)

# Output
manhattan_intersection(EP)

Measured memory_bytes: 48412
#include <set>
#include <map>
#include <list>
#include <queue>
#include <stack>
#include <cmath>
#include <ctype.h>
#include <ctime>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <numeric>
#include <complex>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <iostream>
#include <iterator>
#include <algorithm>

using namespace std;

#define EPS 1e-10
#define equals(a,b) (fabs((a)-(b)) < EPS)
//???
class Point{
	public:	
		double x,y;
		Point(double x = 0,double y = 0):x(x),y(y){}
		//?????????
		Point operator + (Point p) { return Point(x + p.x,y + p.y);}
		Point operator - (Point p) { return Point(x - p.x,y - p.y);}
		Point operator * (double a) { return Point(x*a,y*a);}
		Point operator / (double a) { return Point(x/a,y/a);}
		//???????????¨??§??????
		double abs() {return sqrt(norm());}
		double norm() {return x*x+y*y;}

		bool operator < (const Point &p) const{
			return x != p.x ? x < p.x : y < p.y;
		}
		bool operator == (const Point &p) const{
			return fabs(x - p.x) < EPS && fabs(y - p.y) < EPS;
		}
};
//??????
struct Segment{Point p1,p2;};
//????????????
typedef Point Vector;
//??´???
typedef Segment Line;
//???
class Circle{
	public:
		Point c;
		double r;
		Circle(Point c = Point(),double r = 0.0): c(c),r(r){}
};
//????§???¢
//typedef Vector<Point> Polygon;
//????????¨??????
double dot(Vector a,Vector b){
	return a.x*b.x + a.y*b.y;
}
double cross(Vector a,Vector b){
	return a.x*b.y - a.y*b.x;
}

Point crosspoint(Point p0,Point p1,Point p2,Point p3){
	double d1,d2;
	Vector base(p1-p0);
	Vector hypo1(p2-p0);
	Vector hypo2(p3-p0);
	d1 = abs(cross(base,hypo1));
	d2 = abs(cross(base,hypo2));
	double t = d1 / (d1+d2);
	Vector v(p3-p2);
	return p2 + v*t;
}

int main(){
	int n;
	cin >> n;
	Point p0,p1,p2,p3;
	for(int i = 0;i < n;i++){
		cin >> p0.x >> p0.y >> p1.x >> p1.y >> p2.x >> p2.y >> p3.x >> p3.y;
		Point p = crosspoint(p0,p1,p2,p3);
		printf("%.10f %.10f",p.x,p.y);
		cout << endl;
	}
	return 0;
}

Measured memory_bytes: 1280
#include <algorithm>
#include <cstdio>
#include <queue>
const int MAXN = 1e5+5;
std::priority_queue<int> heap;
int M, N;

struct Pair {
  int A, B;

  bool operator < (const Pair& o) const {
    return A < o.A;
  }
} P[MAXN];

int main() {
  scanf(" %d%d", &N, &M);
  for (int i = 0; i < N; ++i) {
    scanf(" %d%d", &P[i].A, &P[i].B);
  }
  std::sort(P, P + N);
  int sum = 0;
  for (int i = 1, j = 0; i <= M; ++i) {
    while ((j < N) && (P[j].A == i)) {
      heap.push(P[j].B);
      ++j;
    }
    if (!heap.empty()) {
      sum += heap.top();
      heap.pop();
    }
  }
  printf("%d\n", sum);
  return 0;
}

Measured memory_bytes: 1660
package main

import (
	"fmt"
)

func main() {
	var x int
	fmt.Scan(&x)

	for a := 0; a < 10000; a++ {
		for b := 0; b < 10000; b++ {
			if a*a*a*a*a-b*b*b*b*b == x {
				fmt.Println(a, b)
				return
			}
			c := -b
			if a*a*a*a*a-c*c*c*c*c == x {
				fmt.Println(a, c)
				return
			}
		}
	}
}


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

int main() {
  int N, K;
  cin >> N >> K;
  double ans = 0;
  for (int i = 1; i <= N; i++) {
    double tmp = 1.0 / N;
    int j = i;
    while (j < K) j *= 2, tmp /= 2;
    ans += tmp;
  }
  cout << fixed << setprecision(9) << ans << "\n";
}

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

using namespace std;

using ll = long long;

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

    const ll MD = 1e9 + 7;
    int n, m; cin >> n >> m;
    set<int> a;
    for (int i = 0; i < m; i++) {
        int x; cin >> x;
        a.insert(x);
    }

    vector<ll> dp(n + 2, 0);
    dp[0] = 0;
    dp[1] = 1;
    for (int i = 1; i <= n; i++) {
        if (a.find(i) != a.end()) {
            dp[i + 1] = 0;
        } else {
            dp[i + 1] = (dp[i] + dp[i - 1]) % MD;
        }
    }
    cout << dp[n + 1] << endl;

    return 0;
}


Measured memory_bytes: 5760
#include <iostream>
#include <string>
#include <algorithm>
#include <utility>
#include <vector>
using namespace std;
 
int N, Q;
 
int falldir(int i, string &str, vector<pair<char,char>> &spells){
  for(auto s : spells){
    char t = s.first; char d = s.second;
    if(t==str[i]){
      // hit
      i += (d=='L'?-1:1);
      if(i<0){ return -1; }
      else if(i>=N){ return 1; }
    }
  }
  return 0;
}
 
int main(){
  cin>>N>>Q;
  string s;
  cin>>s;
  
  vector<pair<char,char>> spells;
  
  for(int h=1;h<=Q;h++){
    char t,d; cin>>t>>d;
    spells.push_back(make_pair(t,d));
  }
  
  int l=0, u=N;
  while(u-l>1){
    int m = (u+l)/2;
    if(falldir(m,s,spells)<0) l=m;
    else u=m;
  }
  int lower = l;
  
  l=0; u=N;
  while(u-l>1){
    int m = (u+l)/2;
    if(falldir(m,s,spells)>0) u = m;
    else l=m;
  }
  int upper = u;
  int ans = upper-lower-1;
  
  cout<<max(ans,0)<<endl;
}

Measured memory_bytes: 1024
use io::*;
use std::f64::consts::PI;
use std::*;
fn solve(R: i32) {
    println!("{}", f64::from(2) * PI * f64::from(R));
}

// 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)
fn main() {
    let con = read_string();
    let mut scanner = Scanner::new(&con);
    let mut R: i32;
    R = scanner.next();
    // In order to avoid potential stack overflow, spawn a new thread.
    let stack_size = 104_857_600; // 100 MB
    let thd = std::thread::Builder::new().stack_size(stack_size);
    thd.spawn(move || solve(R)).unwrap().join().unwrap();
}

pub mod io {
    use std;
    use std::str::FromStr;

    pub struct Scanner<'a> {
        iter: std::str::SplitWhitespace<'a>,
    }

    impl<'a> Scanner<'a> {
        pub fn new(s: &'a str) -> Scanner<'a> {
            Scanner {
                iter: s.split_whitespace(),
            }
        }

        pub fn next<T: FromStr>(&mut self) -> T {
            let s = self.iter.next().unwrap();
            if let Ok(v) = s.parse::<T>() {
                v
            } else {
                panic!("Parse error")
            }
        }

        pub fn next_vec_len<T: FromStr>(&mut self) -> Vec<T> {
            let n: usize = self.next();
            self.next_vec(n)
        }

        pub fn next_vec<T: FromStr>(&mut self, n: usize) -> Vec<T> {
            (0..n).map(|_| self.next()).collect()
        }
    }

    pub fn read_string() -> String {
        use std::io::Read;

        let mut s = String::new();
        std::io::stdin().read_to_string(&mut s).unwrap();
        s
    }

    pub fn read_line() -> String {
        let mut s = String::new();
        std::io::stdin().read_line(&mut s).unwrap();
        s.trim_right().to_owned()
    }
}


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

#define ARG4(_1, _2, _3, _4, ...) _4
#define rep(...) ARG4(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define REP(i, a) FOR(i, 0, a)
#define FOR(i, a, b) for (int i = (a); i < (int)(b); ++i)
#define rrep(...) ARG4(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)
#define RREP(i, a) RFOR(i, 0, a)
#define RFOR(i, a, b) for (int i = (b)-1; i >= (int)(a); --i)
#define ALL(c) (c).begin(), (c).end()
#define TEN(n) ((ll)(1e##n))
#define pb emplace_back
#define mp make_pair
#define fi first
#define se second
#define let const auto
#define USE_T template <typename T>
#define USE_Ti template <typename T = int>
#define USE_TU template <typename T, typename U>

USE_Ti using duo = std::pair<T, T>;
USE_Ti using vec = std::vector<T>;
using ll = long long;
// clang-format off
USE_TU inline bool chmax(T&x,U a){return x<a&&(x=a,1);}
USE_TU inline bool chmin(T&x,U a){return a<x&&(x=a,1);}
USE_Ti inline T in(){T x;std::cin>>x;return x;}
USE_Ti inline vec<T> in(int n){vec<T> v;v.reserve(n);rep(i,n)v.pb(in<T>());return v;}
USE_T inline void in(T*x,int n){rep(i,n)x[i]=in<T>();}
// clang-format on
// }}}
using namespace std;
const int inf = 1001001001;
const ll infll = 1001001001001001001ll;
const int dd[] = {0, 1, 0, -1, 0};

signed main() {
  set<int> times;
  int N = in();
  REP(i, N) {
    int h = in(), m = in();
    times.insert(h * 60 + m);
  }
  int M = in();
  REP(i, M) {
    int h = in(), m = in();
    times.insert(h * 60 + m);
  }
  int sz = 0;
  for (int t : times) {
    if (sz++) printf(" ");
    printf("%d:%02d", t / 60, t % 60);
  }
  puts("");
  return 0;
}

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

using namespace std;

int len,cnt,hd,tl,ans;
char c[100005],a[100005];

int main() {
	scanf("%s",c); tl = len = strlen(c); tl--;
	for(int i = 0; i < len; i++) if(c[i] != 'x') a[cnt++] = c[i];
	for(int i = 0; i < (cnt>>1); i++) if(a[i] != a[cnt-i-1]) { printf("-1"); return 0; }
	while(hd < tl) {
		if(c[hd] == 'x' && c[tl] != 'x') ans++, hd++;
		else if(c[hd] != 'x' && c[tl] == 'x') ans++, tl--;
		else hd++, tl--;
	}
	cout << ans; 
    return 0;
}


Measured memory_bytes: 384
import java.util.Scanner;
import java.util.Arrays;;
 
public class Main {
	
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        while(true) {
        	int n = sc.nextInt();
        	if(n==0) {
        		break;
        	}
        	int[] a = new int[n];
        	for(int i=0; i<n; i++) {
        		a[i] = sc.nextInt();
        	}
        	Arrays.sort(a);
        	int ans = 1000000;
        	for(int i=0; i<n-1; i++) {
        		ans = Math.min(ans, a[i+1]-a[i]);
        	}
        	System.out.println(ans);
        }
    }
}


Measured memory_bytes: 46616