akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

#define INF 1LL << 60
#define MOD 1000000007;
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPP(i, b, e) for (int i = b; i <= e; i++)

const int nMax = 305;

int N;
int a[nMax];
double dp[nMax][nMax][nMax];

double rec(int i, int j, int k) {
    if (dp[i][j][k] > -1) return dp[i][j][k];
    if (i == 0 && j == 0 && k == 0) return 0.0;

    double e = 0.0;
    if (i > 0) e += rec(i-1, j+1, k) * i;
    if (j > 0) e += rec(i, j-1, k+1) * j;
    if (k > 0) e += rec(i, j, k-1) * k;
    e += N;
    e /= i+j+k;
    return dp[i][j][k] = e;
}

double solve() {
    REP(i, nMax) REP(j, nMax) REP(k, nMax) dp[i][j][k] = -1;
    return rec(a[3], a[2], a[1]);
}

int main() {
    cin >> N;
    int tmp;
    REP(i, N) {
        cin >> tmp;
        a[tmp]++;
    }

    cout << setprecision(16) << solve() << endl;
    return 0;
}

Measured memory_bytes: 221952
#include <bits/stdc++.h>
#include <numeric>
using namespace std;
#define ll long long
#define mod 100000007
#define rep(i, n) for (int i = 0; i < n; ++i)
using Graph = vector<vector<int>>;
ll lcm(ll a, ll b)
{
    return a * b / __gcd(a, b);
}

int main()
{
    int A, B;
    cin >> A >> B;
    if(B < 10){
        A *= 10;
    }
    else if(B <100){
        A *= 100;
    }
    else{
        A *= 1000;
    }
    A += B;
    if (sqrt(A) == floor(sqrt(A)))
    {
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }
}

Measured memory_bytes: 256
A,B,C,X,Y = map(int, input().split())
pmin = 10**9
for i in range(max([X,Y])+1):
  x = X-i if X-i>0 else 0
  y = Y-i if Y-i>0 else 0
  p = A*x + B*y + 2*C*i
  pmin = min(pmin,p)
  
print(pmin)

Measured memory_bytes: 9000
#include<cstdio>
using namespace std;
const int maxn=1e5+10, INF=1e9;
long long a[maxn], pre[maxn],t[maxn];
long long num=0,sum = 0; //num统计个数 sum总数 
long long n;
long long  min(long long  a,long long  b){
	if (a<b) return a; return b;
}
long long  max(long long  a,long long  b){
	if (a>b) return a; return b;
}
void cal(int li, int ri) {
    if(li==ri) return ;
    int mid=(li+ri) >> 1;
    cal(li,mid);
    cal(mid+1,ri);
    
    int p=li, q=mid+1, o=li;
    while (p<=mid && q<=ri) {
        if(pre[p]<pre[q]) {
            t[o++]=pre[p++];
        }
        else {
            num+=(p-li);
            t[o++]=pre[q++];
        }
    }
    while (p<=mid) {
        t[o++]=pre[p++];
    }
    while (q<=ri) {
        num+=(p-li);
        t[o++]=pre[q++];
    }
    for(int i=li;i<=ri;i++)
        pre[i]=t[i];
}
bool check(int x) {
    num=0;
    for(int i=1;i<=n;i++)
        pre[i]=(a[i]<=x ? 1:-1);
    for(int i=1;i<=n;i++)
        pre[i]+=pre[i-1];
    cal(0,n);
    return (num>=(sum/2+1));
}

int main() {
    int li=INF, ri=-INF;
    scanf("%d",&n);
    for(int i=1;i<=n;i++) { 
        scanf("%d",&a[i]);
        li=min(li,a[i]);
        ri=max(ri,a[i]);
    }
    sum=(n+1)*n/2;
    while (li<ri) {
        int mid = (li+ri)>>1;
        if(check(mid)) ri=mid;
        else li=mid+1;
    }
    printf("%d\n",ri);
}


Measured memory_bytes: 2560
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String str =  sc.nextLine();
        int day = 0;
        if(str.equals("SUN")){
            day = 7;
        }else if (str.equals("MON")){
            day = 6;
        }else if (str.equals("TUE")){
            day = 5;
        }else if(str.equals("WED")){
            day = 4;
        } else if(str.equals("THU")){
            day = 3;
        } else if (str.equals("FRI")){
            day = 2;
        } else {
            day = 1;
        }
        System.out.println(day);
    }
}


Measured memory_bytes: 23252
#include<bits/stdc++.h>
using namespace std;
#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 clr(a,x) memset(a,x,sizeof(a))
#define SZ(x) ((int)(x).size())
#define lson rt<<1
#define rson rt<<1|1
#define pb push_back
#define fi first
#define se second
#define what_is(x) cerr<<#x<<" "<<x<<endl;
typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef vector<int> vi;
template <typename T>
inline void _read(T& x){
    cin>>x;
}
void R(){}
template <typename T,typename... U>
void R(T&head,U&... tail){
    _read(head);
    R(tail...);
}

template <typename T>
inline void _write(const T& x){
    cout<<x<<' ';
}
void W(){cout<<endl;}
template <typename T,typename... U>
void W(const T&head,const U&... tail){
    _write(head);
    W(tail...);
}
template<typename T>
void debug(vector<T> V){
    for(auto x:V){
        cout<<x<<" ";
    }
    cout<<endl;
}
void go();
int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    //cout<<fixed<<setprecision(8);
    go();
    return 0;
}
/*************************************/
const int MAXN=2e5+10;
pii p[MAXN];
void go(){
    int n;
    R(n);
    rep(i,1,n){
        R(p[i].fi,p[i].se);
    }
    sort(p+1,p+1+n,[](pii x,pii y){return x.se<y.se;});
    ll now=0;
    rep(i,1,n){
        if(p[i].se-p[i].fi<now){
            W("No");
            return;
        }
        now+=p[i].fi;
    }
    W("Yes");
}


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

int main(void)
{
    int H, W;
    cin >> H >> W;
    int c[10][10];
    for (int i = 0; i < 10; i++) {
        for (int j = 0; j < 10; j++) {
            cin >> c[i][j];
        }
    }


    // ある数字から最終的に1にする書き換えに必要な魔力を全ての数字で予め計算
    int intConverter[10];
    for (int i = 0; i < 10; i++) {
        for (int j = 0; j < 10; j++) {
            for (int k = 0; k < 10; k++) {
                c[j][k] = min(c[j][k], c[j][i]+c[i][k]);
            }
        }
    }

    int A;
    int power = 0;
    for (int i = 0; i < H; i++) {
        for (int j = 0; j < W; j++) {
            cin >> A;
            if (A >= 0) {
                power += c[A][1];
            }
        }
    }

    cout << power << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
int main(void)
{
	int i,j,H,W;
	while(scanf("%d %d",&H,&W)!=EOF)
	{
		if(H==0&&W==0)
		{
			break;
		}
		for ( i = 0; i < H; i++ )
		{
			for ( j = 0; j < W; j++ )
			{
				if((j%2==1&&i%2==1)||(j%2==0&&i%2==0))
				{
					printf("#");
				}
				else if((j%2==1&&i%2==0)||(j%2==0&&i%2==1))
				{
					printf(".");
				}
			
			}
		printf("\n");

		}
	printf("\n");
	}
	return(0);
}


Measured memory_bytes: 2084
#include <algorithm>
#include <array>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <sstream>
#include <unordered_map>
#include <vector>


#define INF 4000000000000000000LL
#define MOD 1000000007
#define ALL(x) std::begin(x), std::end(x)


class ncr_t {
public:
  ncr_t() {
    memo_ = std::unique_ptr<std::unique_ptr<long long[]>[]>(new std::unique_ptr<long long[]>[T]);

    for (int i = 0; i < T; i ++) {
      memo_[i] = std::unique_ptr<long long[]>(new long long[T]);

      memo_[i][0] = memo_[i][i] = 1;
    }

    for (int i = 1; i < T; i ++)
      for (int j = 1; j < i; j ++)
        memo_[i][j] = memo_[i - 1][j - 1] + memo_[i - 1][j];
  };

public:
  long long operator()(int n, int r) const {
    assert(0 <= n && n < 67);
    assert(r <= n);

    return memo_[n][r];
  };

private:
  std::unique_ptr<std::unique_ptr<long long[]>[]> memo_;

private:
  static const int T;
};

const int ncr_t::T = 67;


int main(int argc, char** argv)
{
  std::cin.tie(0);
  std::ios_base::sync_with_stdio(0);

  std::cout << std::fixed << std::setprecision(9);
  std::cerr << std::fixed << std::setprecision(6);

  int N, A, B;

  long long v[55];

  std::cin >> N >> A >> B;

  for (int i = 0; i < N; i ++)
    std::cin >> v[i];

  std::sort(v, v + N, std::greater<long long>());

  std::vector<std::pair<long long, int>> a;

  long long sp = 0, np = 1;

  long long s = 0;
  
  for (int i = 1; i <= N; i ++) {
    s += v[i - 1];

    if (A <= i && i <= B) {
      double m = 1. * s / i;

      a.emplace_back(s, i);

      if (s * np > sp * i) {
        sp = s;
        np = i;
      }
    }
  }

  std::cout << 1. * sp / np << std::endl;

  long long C = 0;

  ncr_t ncr;

  for (const auto& pair : a) {
    long long s = pair.first, n = pair.second;

    if (s * np == sp * n) {
      long long target = v[n - 1];
      
      int c1 = std::count(v, v + N, target), c2 = std::count(v, v + n, target);

      C += ncr(c1, c2);
    }
  }

  std::cout << C << std::endl;

  return 0;
}


Measured memory_bytes: 256
n = int(input())
a = []
for _ in range(n):
	x,y = map(int,input().split())
	a+=[[x,y]]
ans  = "No"
for i in range(n):
	if i+2<n:
		if a[i][0] == a[i][1] and a[i+1][0] == a[i+1][1] and a[i+2][0] == a[i+2][1]:
			ans = "Yes"
print(ans)


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

int A[200005];

int main(){
    int N;
    scanf("%d", &N);

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

    if(A[0] != 0){
        printf("-1");
        return 0;
    }

    for(int i = 1; i < N; i ++){
        if(A[i]-A[i-1] > 1){
            printf("-1");
            return 0;
        }
    }

    long long ans = 0;
    for(int i = 1; i < N; i ++){
        if(A[i] == A[i-1]+1){
            ans ++;
        }else{
            ans += A[i];
        }
    }

    printf("%lld\n", ans);
    return 0;
}


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

int main(){
  int d;
  cin>> d;
  if(d==7 || d==5 || d==3) cout << "YES" << endl;
  else cout << "NO" << endl;
  return 0;
}


Measured memory_bytes: 256
#include <cctype>
#include <iostream>

using namespace std;

int main() {
    string s;
    cin >> s;
    for (int i = 0; i < s.length(); i++) {
        if (i && s[i] == s[i - 1]) {
            cout << "Bad";
            return 0;
        }
    }
    cout << "Good";
    return 0;
}


Measured memory_bytes: 3628
def solve():
    n = int(input())
    a = [int(x) for x in input().split()]
    s = list(input())
    basis = []
    for i in range(n-1, -1, -1):
        for v in basis:
            if a[i] > (a[i] ^ v):
                a[i] = a[i] ^ v
        if a[i] > 0:
            if s[i] == '0':
                basis.append(a[i])
            else:
                return 1
    return 0


t = int(input())
for _ in range(t):
    print(solve())


Measured memory_bytes: 68296
N, Q = map(int, input().split())
S = input()
t = [0] * (N + 1)

for i in range(N):
    t[i+1] = t[i] + (1 if S[i : i + 2] == 'AC' else 0)

for i in range(Q):
    l, r = map(int, input().split())
    print(t[r-1] - t[l-1])

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

int A, B, C;

int main () {
	cin >> A >> B >> C;
	if (A<C && C<B)
		cout << "Yes" << endl;
	else if (A>C && C>B)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
	return 0;
}

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

using namespace std;
int main()
{
    long N;
    long K;
    long work;
    long ans;

    cin >> N >> K;

    work = N % K;

    ans = min(work, (K-work));

    cout << ans << endl;

    return 0;
}

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

namespace ABC
{
    class ProgramC2
    {
        static long pow(long n, long p, int mod = (int)1e9 + 7)
        {
            if (p == 0) return 1; // nの0乗は1
            else if (p % 2 == 0)
            {
                var x = pow(n, p / 2, mod);
                return (x * x) % mod;
            }
            else
            {
                return pow(n, p - 1, mod) * n % mod;
            }
        }

        static void Main(string[] args)
        {
            var mod = (int)1e9 + 7;
            var n = int.Parse(Console.ReadLine());
            var result = 0L;
            result = pow(10, n);
            result -= (pow(9, n) * 2) % mod;
            result += pow(8, n);
            Console.WriteLine((result + mod) % mod);
        }
    }
}


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

int main(){
    long x,y,answer;
    cin>>x>>y;
    if(x==y)answer=x;
    if(x>y){
        int m,n,r;
        m=x;
        n=y;
        while(1){
            r=m%n;
            if(r==0){
                answer=n;
                break;
            }else{
              m=n;
              n=r;
            }
        }
    }
    if(x<y){
        int m,n,r;
        m=y;
        n=x;
        while(1){
            r=m%n;
            if(r==0){
                answer=n;
                break;
            }else{
              m=n;
              n=r;
            }
        }
    }
    cout<<answer<<endl;
}



Measured memory_bytes: 3104
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		long a = sc.nextInt();
		long b = sc.nextInt();
		long c = sc.nextInt();
		long d = sc.nextInt();
		long answer = 0;
		if (a * c > answer) {
			answer = a * c;
		}
		if (b * d > answer) {
			answer = b * d;
		}
		if (answer == 0) {
			if (a * d > b * c) {
				answer = a * d;
			} else {
				answer = b * c;
			}
		}
		System.out.println(answer);
	}

}


Measured memory_bytes: 35692
x, n = list(map(int, input().split()))
if n == 0:
  print(x)
  exit()
p = list(map(int, input().split()))
d = 1e9
ans = 0
for e in range(200, -1, -1):
  dd = abs(e - x)
  if e not in p and dd <= d:
    d = dd
    ans = e
print(ans)

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

#ifdef LOCAL
#include "../dump.hpp"
#else
#define dump(...)
#endif

#define rep(i,n) for(ll i=0,i##_cond=(n);i<i##_cond;i++)
#define FOR(i,a,b) for(ll i=(a),i##_cond=(b);i<i##_cond;i++)
#define ROF(i,a,b) for(ll i=(a)-1,i##_cond=(b);i>=i##_cond;i--)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend() //sortで大きい順
#define UNIQUE(v) v.erase(unique(all(v)),v.end())
#define SUM(a) accumulate(all(a),0)
#define sz(x) ((ll)(x).size())
#define pb push_back
#define fst first
#define snd second
#define mp make_pair

typedef long long ll;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<ll,ll> pii;

const ll inf = 1ll<<62;
const ll mod = 1e9+7;

#define int ll

main()
{
  while(1){
    int n,m,a; cin >> n >> m >> a;
    if(n == 0) break;

    vi amida(n+1);
    rep(i,sz(amida)) amida[i] = i;

    vector<pair<int,pii>> bar(m);
    rep(i,m) cin >> bar[i].fst >> bar[i].snd.fst >> bar[i].snd.snd;

    sort(all(bar));

    rep(i,m) swap(amida[bar[i].snd.fst], amida[bar[i].snd.snd]);

    cout << amida[a] << endl;
  }
}


Measured memory_bytes: 3036
#include <iostream>
#include <string>
#include <algorithm>
#include <set>
#include <cmath>
#include <vector>
#include <queue>
#include <unordered_set>

typedef long long ll;
const ll LL_MAX (1LL<<60);

#define rep(i,s,e) for(ll i=(s); i<(e); i++) 

using namespace std;

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

    ll n, tmp;
    cin >>n;
    set<ll> a;
    rep(i,0,n) cin >> tmp, a.insert(tmp);

    ll m;
    cin >> m;
    set<ll> b;
    rep(i,0,m) cin >> tmp, b.insert(tmp);

    //for (auto i:a) cout << i << endl;
    //cout << endl;
    //for (auto i:b) cout << i << endl;
    //cout << endl;

    set<ll> ans;

    set_difference(a.begin(), a.end(),
                   b.begin(), b.end(),
                   inserter(ans, ans.end()));
    
    for(auto i: ans) 
        cout << i << endl;

    return 0;
}



Measured memory_bytes: 31236
#include <algorithm>
#include <bits/stdc++.h>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
using namespace std;

#define rep(X, Y) for (int(X) = 0; (X) < (Y); ++(X))
#define rrep(X, Y) for (int(X) = (Y)-1; (X) >= 0; --(X))
#define itrep(X, Y) for (auto(X) = (Y).begin(); (X) != (Y).end(); (X)++)
#define all(X) (X).begin(), (X).end()
#define pb push_back
#define mp make_pair
#define fi first
#define sc second
#define print(x) cout << x << endl

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};

void solve(long long H, long long W, std::vector<std::string> S) {
  vector<vector<bool>> checked(H, vector<bool>(W));
  ll ans = 0;
  rep(h, H) {
    rep(w, W) {
      queue<pll> que;
      que.push(mp(h, w));

      ll black = 0;
      ll white = 0;
      while (!que.empty()) {
        auto p = que.front();
        que.pop();
        if (checked[p.fi][p.sc]) {
          continue;
        }
        checked[p.fi][p.sc] = true;

        if (S[p.fi][p.sc] == '#') {
          black++;
        } else {
          white++;
        }

        rep(i, 4) {
          ll htmp = p.fi + dx[i];
          ll wtmp = p.sc + dy[i];
          if (0 <= htmp && htmp < H && 0 <= wtmp && wtmp < W) {
            if (S[p.fi][p.sc] != S[htmp][wtmp]) {
              que.push(mp(htmp, wtmp));
            }
          }
        }
      }
      ans += black * white;
    }
  }
  print(ans);
}

int main() {
  long long H;
  scanf("%lld", &H);
  long long W;
  scanf("%lld", &W);
  std::vector<std::string> S(H);
  for (int i = 0; i < H; i++) {
    std::cin >> S[i];
  }
  solve(H, W, std::move(S));
  return 0;
}


Measured memory_bytes: 512
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;
using static System.Convert;
using static System.Math;
//using static System.Globalization.CultureInfo;

class Program
{
    static void Main(string[] args)
    {
        var num = Input.num;
        var tak = Input.ar;
        var ao = Input.ar;
        if (tak.Max() != ao.Max())
        {
            WriteLine(0);
            return;
        }
        var res = 1L;
        for (var i = 0; i < num; i++)
        {
            if (i == 0 && tak[0] != ao[0] && ao[0] != ao[1]) res = 0;
            else if (i!=0&&tak[i] != tak[i - 1] && ao[i] < tak[i]) res = 0;
            if (i == num - 1 && tak[i] != ao[i] && tak[i] != tak[i - 1]) res = 0;
            else if (i!=num-1&&ao[i] != ao[i + 1] && tak[i] < ao[i]) res = 0;
        }
        for(var i = 1; i < num-1; i++)
        {
            if (tak[i] == tak[i - 1] && ao[i] == ao[i + 1])
                res *= Min(tak[i], ao[i]);
            res %= Input.MOD;
        }
        WriteLine(res);
    }
}

public class Input
{
    public static string read => ReadLine();
    public  static int[] ar => Array.ConvertAll(read.Split(' '), int.Parse);
    public  static int num => ToInt32(read);
    public  static long[] arL => Array.ConvertAll(read.Split(' '), long.Parse);
    public  static long numL => ToInt64(read);
    public static int[][] twodim(int num)
        => Enumerable.Repeat(0, num).Select(v => ar).ToArray();
    public static long[][] twodimL(int num)
        => Enumerable.Repeat(0, num).Select(v => arL).ToArray();
    public  const string Alfa = "abcdefghijklmnopqrstuvwxyz";
    public  const int MOD = 1000000007;
}


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

using namespace std;

typedef long long ll;
const ll INF = 1LL<<60;

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

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

ll modpow(ll a, ll n, ll mod) {
  ll res = 1;
  while (n > 0) {
    if (n & 1) res = res * a % mod;
    a = a * a % mod;
    n >>= 1;
  }
  return res;
}

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

  int N;
  cin >> N;
  multiset<int> S;
  S.insert(0);
  S.insert(0);
  S.insert(N+1);
  S.insert(N+1);

  vector<int> P(N+2);
  vector<pair<int, int>> V;
  for(int i = 0; i < N; i++){
    cin >> P[i+1];
    V.push_back({P[i+1], i+1});
  }
  sort(V.begin(), V.end());
  reverse(V.begin(), V.end());

  ll ans = 0;

  for(auto v : V){
    ll num = v.first;
    int id = v.second;
    auto it = S.lower_bound(id);
    int R1 = *it++;
    int R2 = *it--;
    it--;
    int L1 = *it--;
    int L2 = *it;
    ans += num * (R2-R1) * (id-L1);
    ans += num * (L1-L2) * (R1-id);
    S.insert(id);
  }
  cout << ans << endl;


  return 0;
}


Measured memory_bytes: 6132
n = gets.to_i
ball = Array.new(n).map{Array.new(2,0)}
n.times{|i| ball[i] = gets.split.map(&:to_i)}
ball.sort!
ans = 0
for i in 0..n-1
  for j in 0..n-1
    if i != j
      count = 0
      inst0 = ball[j][0]-ball[i][0]
      inst1 = ball[j][1]-ball[i][1]
      for k in 0..n-1
        for l in 0..n-1
          if k != l && ball[l][0]-ball[k][0]==inst0 && ball[l][1]-ball[k][1]==inst1
            count += 1
          end
        end
      end
      if ans < count
        ans = count
      end
    end
  end
end
puts n-ans


Measured memory_bytes: 1788
#include<iostream>
#include<vector>
#include<algorithm>
#include<cctype>
#include<utility>
#include<string>
#include<cmath>
#include<set>

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
#define INF 999999999
using namespace std;
typedef pair<int, int> P;
typedef pair<llong, llong> LP;
typedef pair<int, P> PP;
typedef pair<llong, LP> LPP;

int main(){

    int k;
    string s;
    cin >> s >> k;

    vector<string> substring;
    for(int i = 0;i < s.size();i++){

        for(int j = 1; i+j <= s.size() && j <= k;j++){
            substring.push_back(s.substr(i,j));
        }
    }

    VSORT(substring);
    //set<string> p(substring.begin(),substring.end());
    //vector<string> ans(p.begin(),p.end());
    substring.erase(unique(substring.begin(),substring.end()),substring.end());
    //cout << ans[k-1] << endl;
    cout << substring[k-1] << endl;
    return 0;
}

Measured memory_bytes: 1660
import java.util.*;
 
class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();
      
		if(c>=a&c<=b){
          System.out.print("Yes");
        }else{
           System.out.print("No");
        }
      
    }
}

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

using namespace std;

typedef long long ll;

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

    int N;
    cin >> N;
    int t[N+1], x[N+1], y[N+1];
    t[0] = x[0] = y[0] = 0;
    for (int i = 1; i < N+1; i++) {
        cin >> t[i] >> x[i] >> y[i];
    }

    for (int i = 1; i < N+1; i++) {
        int distance = abs(x[i] - x[i-1]) + abs(y[i] - y[i-1]);
        int time = t[i] - t[i-1];
        if(distance > time || distance % 2 != time % 2) {
            cout << "No" << endl;
            exit(0);
        }
    }
    cout << "Yes" << endl;

}

Measured memory_bytes: 1408
func input2() -> (Int, Int) {
    let s = readLine()!.split(separator: " ")
    return (Int(s[0])!, Int(s[1])!)
}

func input_ints() -> [Int] {
    return readLine()!.split(separator: " ").map{e in Int(e)!}
}

let (N, M) = input2()
let H = input_ints()
var ans = Array(repeating: true, count: N)

for _ in 0..<M {
    var (A, B) = input2()
    A -= 1
    B -= 1
    if H[A] <= H[B] {
        ans[A] = false
    }
    if H[B] <= H[A] {
        ans[B] = false
    }
}

let count = ans.filter{ e in e }.count
print(count)

Measured memory_bytes: 13580
#![allow(non_snake_case)]
#![allow(unused_imports)]

use proconio::{input, fastout};
use proconio::marker::*;
use whiteread::parse_line;
use std::collections::*;
use num::*;

use itertools::Itertools;
use itertools_num::ItertoolsNum;

pub fn enum_divisors(n: usize) -> Vec<usize> {
    let mut res: Vec<usize> = Vec::new();

    let mut i: usize = 1;

    while i * i <= n {
        if n % i == 0 {
            res.push(i);
            if n / i != i { res.push(n / i) }
        }
        i += 1;
    }
    res.sort();
    res
}

#[fastout]
fn main() {
    input!{
        n: usize,
        mut a_vec: [usize; n],
    }

    a_vec.sort();
    let a_set = a_vec.iter().map(|x| *x).collect::<HashSet<usize>>();
    // dbg!(&a_vec);
    let mut map: HashMap<usize, usize> = HashMap::new();
    for a in a_vec.iter() {
        *map.entry(*a).or_insert(0) += 1;
    }

    let duplicated = map.iter().filter(|&(_, y)| *y > 1).map(|(x, _)| *x).collect::<HashSet<usize>>();
    // dbg!(&duplicated);   
    let mut ans = 0;

    for i in 0..n {
        if duplicated.contains(&a_vec[i]) { continue }
        // if i == n-1 && n-1 != 0 && a_vec[i] == a_vec[i-1] {
        //     continue
        // }
        let divisors: HashSet<usize> = enum_divisors(a_vec[i]).into_iter().collect();
        // dbg!(&divisors);
        let set = divisors.intersection(&a_set).collect::<HashSet<_>>();
        // dbg!(&a_vec[i], &set);
        if set.len() == 1 && set.contains(&&a_vec[i]) {
            ans += 1;
        }
    }

    println!("{}", ans);
}


Measured memory_bytes: 14848
import sys

if __name__ == '__main__' :
    
    N,K = map(int, input().split())
    x = list(map(int, input().split()))

    min_dis = sys.maxsize
    for i in range(0,N-K+1):
        l = i
        r = i + K - 1 
        # 左に行った後に右に行くパターン
        dis_l = abs(x[l]) + abs(x[r]-x[l])
        # 右に行った後に左に行くパターン
        dis_r = abs(x[r]) + abs(x[r]-x[l])
        min_dis = min(min_dis,dis_l,dis_r)
    print(min_dis)


Measured memory_bytes: 14228
#include <stdio.h>

#define arr_print_d0dn(a, n) for(int i=0;i<(n)-1;++i)put_uint((a)[i]),putchar_unlocked(' ');put_uint((a)[(n)-1]),putchar_unlocked('\n')

#define INPUT__LENGTH (20000000)
char _in[INPUT__LENGTH];
char *_p = _in;
int read_uint() {
    int n = 0;
    while(47 < *_p && *_p < 58) n = 10 * n + (*_p++ & 0xf);
    _p++;
    return n;
}
void put_uint(int n) {
    if(!n) {
        putchar_unlocked('0');
        return;
    }
    char buf[11];
    int i = 0;
    while(n) buf[i++] = (char)(n % 10 + '0'), n /= 10;
    while(i--)putchar_unlocked(buf[i]);
}
void counting_sort(int *dst, const int *src, const int N, const int max) {
    // 'int c[max+1] = {}' cannot initialize
    int c[10001] = {};
    for(int i = 0; i < N; ++i) c[src[i]]++;
    for(int i = 1; i < max; ++i) c[i] += c[i - 1];
    for(int i = N - 1; i >= 0; --i) {
        int x = src[i];
        int y = c[x];
        dst[c[src[i]]-- - 1] = src[i];
    }
}
int main(int argc, char **argv) {
    fread_unlocked(_in, 1, INPUT__LENGTH, stdin);
    int n = read_uint();
    int a[n], b[n];
    for(int i = 0; i < n; ++i) a[i] = read_uint();
    counting_sort(b, a, n, 10000);
    arr_print_d0dn(b, n);
    return 0;
}



Measured memory_bytes: 26688
#include <algorithm>
#include <complex>
#include <cstdio>
#include <iostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
#define REP(var, a, b) for (int var = (a); var < (b); var++)
#define rep(var, n) for (int var = 0; var < (n); ++var)
#define ALL(c) (c).begin(), (c).end()
#define rALL(c) (c).rbegin(), (c).rend()
ll MOD = 1000000007;
const ll INF = 1LL << 60;

int main() {
  //
  vl a(1000001, 0);
  ll s;
  cin >> s;
  a[s] = 1;
  ll cur = s;
  REP(i, 2, 100001) {
    if (cur & 1) {
      cur = 3 * cur + 1;
    } else {
      cur = cur / 2;
    }
    if (a[cur] > 0) {
      cout << i << endl;
      return 0;
    } else {
      a[cur] = 1;
    }
  }
  return 0;
}


Measured memory_bytes: 8064
#include<iostream>
#include<algorithm>
#include<string>
using namespace std;
int main() {
  string s;
  int m,a;
  while(cin >> s,s!="-") {
      cin >> m;
      for(int i=0; i<m; i++) {
          cin >> a;
          s=s.substr(a,s.size()-a)+s.substr(0,a);
      }
      cout << s << endl;
  }
}


Measured memory_bytes: 3184
#include <bits/stdc++.h>
class union_find {
 public:
  using tp = std::vector<size_t>::size_type;
  // 取り扱う型.

  explicit union_find(const tp n) : parent(n), rank(n, 0), cache() {
    for (tp i = 0; i < n; i++) {
      parent[i] = i;
    }
    cache.reserve(n);
  }

  tp root(tp n) {
    // 番号nの親を求める. ついでに経路圧縮を行う.

    while (parent[n] != n) {
      // 根になるまで親を探索. ついでにキャッシュ変数に追加.
      cache.push_back(n);
      n = parent[n];
    }
    for (const auto i : cache) {
      // キャッシュ変数に追加された子の親を経路圧縮.
      parent[i] = n;
    }
    cache.clear();
    return n;
  }

  bool same(tp x, tp y) {
    // xとyが同じグループに属しているか計算.
    return root(x) == root(y);
  }

  void unite(const tp x, const tp y) {
    // xとyを同じグループにする.
    const auto x_root = root(x);
    const auto y_root = root(y);

    if (x_root == y_root) {
      // 根が同じなら元から同じグループ.
      return;
    }

    if (rank[x_root] < rank[y_root]) {
      // rankの大きい方の根を統合後の根にする.
      parent[x_root] = y_root;
    } else if (rank[y_root] < rank[x_root]) {
      // rankの大きい方の根を統合後の根にする.
      parent[y_root] = x_root;
    } else {
      // rankが同じなら, どっちかを根にして根になったほうのランクを上げる.
      parent[x_root] = y_root;
      rank[x_root]++;
    }
  }

 private:
  std::vector<tp> parent;
  // 親の番号を格納. 自分が根なら parent[i] == i になる.
  std::vector<tp> rank;
  // 自分の下に何段分の子があるかを格納.
  std::vector<tp> cache;
  // root計算のときに経路圧縮を行うためのキャッシュ変数.
};


int main() {
  int n, m;
  std::cin >> n >> m;
  std::vector<std::pair<int, int>> e(m);
  for (auto &i : e) {
    std::cin >> i.first >> i.second;
  }

  int count = 0;

  for (int i = 0; i < m; i++) {
    union_find uf(n);
    for (int j = 0; j < m; j++) {
      if (j != i) {
        uf.unite(e[j].first - 1, e[j].second - 1);
      }
    }
    for (int j = 0; j < n; j++) {
      if (!uf.same(0, j)) {
        count++;
        break;
      }
    }
  }
  std::cout << count << std::endl;
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <float.h>
 
#pragma region 定義
#define i_cin(X) scanf("%d", &X)
#define i_cin2(X,Y) scanf("%d %d",&X,&Y)
#define i_cin4(X,Y,Z,W) scanf("%d %d %d %d",&X,&Y,&Z,&W)
#define i_cin3(X,Y,Z) scanf("%d %d %d",&X,&Y,&Z)
#define l_cin(X) scanf("%ld",&X)
#define f_cin(X) scanf("%f",&X)
#define l_cin2(X,Y) scanf("%ld %ld",&X,&Y)
#define s_cin(X) scanf("%s",&X)
#define ll_cin(X) scanf("%lld", &X)
 
#define  i_cout(X) printf("%d\n",X)
#define  f_cout(X) printf("%g\n",X)
#define  i_cout2(X,Y) printf("%d %d\n",X,Y)
#define  l_cout(X) printf("%ld\n",X)
#define  s_cout(X) printf("%s\n",X)
#define  ll_cout(X) printf("%lld\n",X)
 
typedef long long  ll;
#define rept(x, s, n) for (int x = s; x < n; x++)
 
#define S_RTN(S)  s_cout(S);return 0
 
 
#define _itoa(A,N) sprintf(A, "%d", N);
 
int i_cins(int n, int* A);
int l_cins2(int n, long* A, long* B);
int s_dsort(const void* a, const void* b);
int s_asort(const void* a, const void* b);
 
int  _gcd(int a, int b);
int  _swp(int* a, int* b);
int _cknum(char* a, int n);
int _atoi(char* s, int len);
 
 
int s_asorts(const void* a, const void* b);
 
//昇順
int s_asorts(const void* a, const void* b) {
    return(strcmp((char*)a, (char*)b));
}
int s_dsort(const void* a, const void* b) {
    return(*(int*)b - *(int*)a);
}
int s_asort(const void* a, const void* b) {
    return(*(int*)a - *(int*)b);
}
int l_cins2(int n, long* a, long* b) {
    int i;
    rept(i, 0, n) {
        l_cin2(*(a + i), *(b + i));
    }
    return 0;
}
int i_cins(int n, int* a) {
    int i;
    for (i = 0; i < n; i++) {
        i_cin(*(a + i));
    }
 
    return 0;
}
int _gcd(int a, int b) {
    int r, tmp;
    if (a < b) { tmp = a; a = b; b = tmp; }
    r = a % b;
    while (r) {
        if (!r) break;
        a = b; b = r;
        r = a % b;
    }
    return(b);
}
 
long _max(long a, long b) {
    return a > b ? a : b;
}
long _min(long a, long b) {
    return a < b ? a : b;
}
int _swp(int* a, int* b)
{
    int tmp;
    tmp = *b; *b = *a; *a = tmp;
    return 0;
}

int compare_int(const void *a, const void *b)
{
    return *(int*)a - *(int*)b;
}


int main(){
    int N,K;
    scanf("%d %d",&N,&K);
    int wa[100001]={0};
    int ac[100001]={0};
    int cntw=0;
    int cnta=0;
    rept(i,0,K){
        int t=0;
        char b[3];
        scanf("%d",&t);
        scanf("%s",b);
        if(strcmp("WA",b)==0 && wa[t] != -1){
            wa[t]++;
        }else if(strcmp("AC",b)==0 && ac[t] != -1){
            cnta++;
            cntw+=wa[t];
            ac[t]=-1;
            wa[t]=-1;
        }
        
    }
    
    printf("%d %d",cnta,cntw);
    
}

Measured memory_bytes: 896
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
Int k;
double ans;

template<typename T1,typename T2> void chmax(T1 &a,T2 b){if(a<b) a=b;};

vector<Int> pr;

Int isprime(Int x){
  if(x<=1) return 0;
  for(Int i=2;i*i<=x;i++)
    if(x%i==0) return 0;
  return 1;
}

void dfs(Int x,double y,Int p,Int c){
  //if(x<=k) cout<<y<<" "<<x<<":"<<(y/x)<<endl; 
  if(x<=k) chmax(ans,y/x);
  else return;
  Int t=1;
  double s=0;
  if(c==0) return;
  for(Int i=0;i<=c;i++){
    if(x>k/t) break;
    s+=t;
    dfs(x*t,y*s,p+1,i);
    if(t>k/pr[p]) break; 
    t*=pr[p];
  }
} 

struct Precision{
  Precision(){
    cout<<fixed<<setprecision(6);
  }
}precision_beet;

signed main(){  
  cin.tie(0);
  ios::sync_with_stdio(0);
  
  
  for(Int i=2;i<1e5;i++) if(isprime(i)) pr.emplace_back(i);
  
  while(cin>>k,k){
    ans=1;
    dfs(1,1,0,100);
    cout<<ans<<endl;
  } 
  return 0;
}



Measured memory_bytes: 3420
from math import sqrt


def isPrime(n):
    if n > 2 and n % 2 == 0: return False
    i = 3
    while i <= sqrt(n):
        if n % i == 0:
            return False
        i += 2
    return n > 1


n = int(input())
while not isPrime(n):
    n += 1
print(n)


Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define rep(i,b) FOR(i,0,b)
#define INF mugen
#define dump(x) cerr<<#x<<"="<<x<<endl
#define all(a) (a).begin(),(a).end()
typedef vector<int> vi;
typedef vector<vi> vii;
typedef vector<vii> viii;
typedef pair<int,int> P;
template <class T> void chmin(T & a, T const & b) { if (b < a) a = b; }

using ll = long long;
const ll mod = LLONG_MAX;

int N,ans;
int a[112345];
int main(){
  cin>>N;
  rep(i,N){
    int temp;
    cin>>temp;
    if(temp<=100000){
      a[temp]++;
    }else{
      ans++;
    }
  }
  rep(i,100001){
    if(a[i]>=i)ans+=(a[i]-i);
    else ans+=a[i];
  }
  cout<<ans<<endl;



}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <cstring>

using namespace std;

typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vii;
typedef vector<pair<int,int>> vip;

#define ZOOM ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define pb push_back
#define ff it->first
#define ss it->second
#define all(v) (v).begin(),(v).end()
#define rep(i,n) for(auto i=0;i<n;++i)
#define LOOP_IT(it,s) for(auto it=(s).begin();it!=(s).end();++it)


#ifdef LOCAL
#define cerr cout
#else
#endif

#define TRACE

#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
	cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
	const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...)
#endif


void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif


int main(int argc,char* argv[])
{
    ZOOM

    string s;
    cin>>s;
    bool f=0;
    int n=s.size();
    rep(i,n)
    {
        if(s[i]=='7')
            {f=1;break;}
    }
    cout<<(f?"Yes\n":"No");


    return 0;
}



Measured memory_bytes: 3656
#include<bits/stdc++.h>
using namespace std;
#define ALL(v) (v).begin(),(v).end()
#define REP(i,p,n) for(int i=p;i<(int)(n);++i)
#define rep(i,n) REP(i,0,n)
#define SZ(x) ((int)(x).size())
#define INF 999999999
typedef long long int Int;
using ll = long long;
using VI = vector<int>;
int gcd(Int a, Int b) {
  return b != 0 ? gcd(b, a % b) : a;
}
int lcm(Int a, Int b) {
  return a / gcd(a, b)*b;
}
bool isSquare(Int a){
  bool flag = false;
  double z = double(sqrt(a));
  if(ceil(z)==floor(z)) flag = true;
  return flag;
}
/*bool isSquare(ll n) {
	ll d = (ll)sqrt(n) - 1;
	while (d * d < n) ++d;
	return d * d == n;
}*/

int main(){
  int n,d;cin >> n >> d;
  vector<vector<int>> a(n, vector<int>(d));
  rep(i,n){
    rep(j,d){
      cin >> a[i][j];
    }
  }
  int ans = 0;
  rep(i,n){
    REP(j,i+1,n){
      int dd = 0;
      rep(k,d) dd+= abs(a[i][k]-a[j][k]) * abs(a[i][k]-a[j][k]);
      if(isSquare(dd)) ans++;
    }
  }

  cout << ans << endl;


}


Measured memory_bytes: 256
#!/usr/bin/env python3
import sys, math, itertools, collections, bisect
input = lambda: sys.stdin.buffer.readline().rstrip().decode('utf-8')
inf = float('inf') ;mod = 10**9+7
mans = inf ;ans = 0 ;count = 0 ;pro = 1

X,Y,A,B,C = map(int,input().split())
P = list(map(int,input().split()))
Q = list(map(int,input().split()))
R = list(map(int,input().split()))
P.sort(reverse = True)
Q.sort(reverse = True)
D = []
for i in range(X):
  D.append(P[i])
for j in range(Y):
  D.append(Q[j])
for ri in R:
  D.append(ri)
# print(D)
D.sort(reverse = True)
print(sum(D[:X+Y]))
# R.sort(reverse = True)
# i = j = k = 0
# while True:
#   if P[i] < Q[j]:
#     # Pを変えるべき
#     if P[i] < R[k]:
#       P[i] = R[k]
      
# print(sum(D))

Measured memory_bytes: 92848
#include<cstdio>
#include<iostream>
#include<cstring>
#include<cmath>
using namespace std;
char a[100010],b[100010];
int n,num,tot;
const int mod=998244353;
int jc[100010],inv[100010],ans;
const int G=3;
int x1[100010],x2[100010];
int fast_pow(int a,int x)
{
	int ans=1;
	for (;x;x>>=1,a=1ll*a*a%mod)
		if (x&1) ans=1ll*ans*a%mod;
	return ans;
}
void change(int y[],int len)
{
	int i,j,k;
	for (i=1,j=len/2;i<len-1;i++)
	{
		if (i<j) swap(y[i],y[j]);
		k=len/2;
		while (j>=k) j-=k,k>>=1;
		if (j<k) j+=k; 
	}
	return;
}
void fft(int y[],int len,int ifi)
{
	change(y,len);
	for (int h=2;h<=len;h<<=1)
	{
		int wn=fast_pow(G,(ifi==1)?(mod-1)/h:mod-1-(mod-1)/h);
		for (int j=0;j<len;j+=h)
		{
			int w=1;
			for (int k=j;k<j+h/2;k++)
			{
				int u=y[k];
				int t=1ll*w*y[k+h/2]%mod;
				y[k]=(u+t)%mod;
				y[k+h/2]=(1ll*u-t+mod)%mod;
				w=1ll*w*wn%mod;
			} 
		} 
	}
	if (ifi==-1)
	{
		int iv=fast_pow(len,mod-2);
		for (int i=0;i<len;i++) y[i]=1ll*y[i]*iv%mod;
	}
}
void add(int len)
{
	fft(x2,len,1);
	for (int i=0;i<len;i++) x2[i]=1ll*x2[i]*x2[i]%mod;
	fft(x2,len,-1);
	for (int i=num+1;i<len;i++) x2[i]=0;
}
int main()
{
	scanf("%s%s",a+1,b+1);
	n=strlen(a+1);
	for (int i=1;i<=n;i++)
	{
		if (a[i]=='1'&&b[i]=='1') num++;
		if (a[i]=='1') tot++;
	}
	jc[0]=1;
	for (int i=1;i<=tot+1;i++) jc[i]=1ll*jc[i-1]*i%mod;
	inv[tot+1]=fast_pow(jc[tot+1],mod-2);
	for (int i=tot;i>=0;i--) inv[i]=1ll*inv[i+1]*(i+1)%mod; 
	for (int i=0;i<=tot;i++) inv[i]=inv[i+1];

	int len=1;
	while (len<=2*num) len<<=1;
	x1[0]=1;
	for (int i=1;i<len;i++) x1[i]=0;
	for (int i=0;i<=num;i++) x2[i]=inv[i];
	for (int i=num+1;i<len;i++) x2[i]=0;
	
	for (int i=tot-num;i;i>>=1,add(len))
		if (i&1)
		{
			fft(x2,len,1);fft(x1,len,1);
			for (int j=0;j<len;j++) x1[j]=1ll*x1[j]*x2[j]%mod;
			fft(x1,len,-1);fft(x2,len,-1);
			for (int j=num+1;j<len;j++) x1[j]=0;
		}
	//cout<<len<<endl;
	
//	for (int i=1;i<=tot-num;i++)
//	{
//		for (int j=num+1;j<len;j++) x1[j]=0;
//		for (int j=0;j<len;j++) printf("%d ",x1[j]);cout<<endl;
//		for (int j=0;j<len;j++) printf("%d ",x2[j]);cout<<endl;
//		fft(x1,len,1);fft(x2,len,1);
//		for (int j=0;j<len;j++) printf("%d ",x1[j]);cout<<endl;
//		for (int j=0;j<len;j++) printf("%d ",x2[j]);cout<<endl;
//		for (int j=0;j<len;j++)
//			x1[j]=1ll*x1[j]*x2[j]%mod;
//		//for (int i=0;i<len;i++) printf("%d ",x1[i]);cout<<endl;
//		//for (int i=0;i<=tot;i++) printf("%d ",x2[i]);cout<<endl;
//		fft(x1,len,-1);fft(x2,len,-1);
//		for (int j=0;j<len;j++) printf("%d ",x1[j]);cout<<endl;
//		//for (int i=0;i<=tot;i++) printf("%d ",x2[i]);cout<<endl;
//		cout<<endl;
//	}
	
	
	int ans=0;
	for (int i=0;i<=num;i++) ans=(ans+x1[i])%mod;
	printf("%d",1ll*ans*jc[tot-num]%mod*jc[num]%mod*jc[tot]%mod);
}

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

signed main(void)
{
	int x, cnt;
	vector<int> v;

	cin >> x;
	for(int b = 1; b <= x; b++)
	{
		cnt = b;
		for(int p = 0; p <= x; p++)
		{
			cnt *= b;
			if (cnt <= x)
				v.push_back(cnt);
			else
				break;
		}
	}
	sort(v.rbegin(), v.rend());
	cout << v[0] << endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <map>
using namespace std;
const int maxn = 1e5+10;
int a[maxn];
int main(){
    int n, m, x, y;
    scanf("%d%d", &n, &m);
    for(int i = 0; i < m; ++i){
        scanf("%d%d", &x, &y);
        a[x]++, a[y]++;
    }
    for(int i = 1; i <= n; ++i){
        if(a[i]&1){
            return printf("NO\n"), 0;
        }
    }
    printf("YES\n");
    return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <map>
#include <cmath>
#include <queue>
#include <stack>
#include <list>
#include <sstream>

#define endl "\n"
using namespace std;
using ll = long long;
const ll MOD = 1e9+7;
const ll INF = 1e18;
#define REP(i, n) for(int i = 0; i < n; i++)
using Graph = vector<vector<int>>;

int main(){
    int l,r,d;
    cin>>l>>r>>d;
    int ans = 0;
    for(int i=l;i<=r;i++){
        if(i % d == 0) ans++;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 3616
n=int(input())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
c=[]
d=[]
s=0
for i in range(n):
  if a[i]-b[i]>0:
    c.append(a[i]-b[i])
  if a[i]-b[i]<0:
    d.append(a[i]-b[i])
  s+=a[i]-b[i]
c.sort(reverse=True)
if s<0:
  print(-1)
elif len(d)==0:
  print(0)
else:
  ans=len(d)
  i=0
  while len(d)>0:
    if c[i]>=abs(d[0]):
      c[i]-=abs(d[0])
      d.remove(d[0])
    else:
      d[0]+=c[i]
      i+=1
  print(ans+i+1)

Measured memory_bytes: 19068
#include<iostream>
#include<complex>
#include<cmath>
#include<vector>
#include<algorithm>

using namespace std;

const double eps=1e-9;
typedef complex<double> P;

vector<P> intersection(P a,double ra,P b,double rb){
  double c=abs(b-a);
  double costheta=-(rb*rb-ra*ra-c*c)/2/ra/c;
  if(-1<=costheta&&costheta<=1){
    double theta=acos(costheta);
    double ang=arg(b-a);
    return {a+polar(ra,ang+theta),a+polar(ra,ang-theta)};
  }else{
    return {};
  }
}

bool includes(P a,double r,P b){
  return abs(a-b)<=r+eps;
}

double sst(double a,double b){
  return sqrt(a*a-b*b);
}

int main(){
  for(int n;cin>>n,n;){
    int x[10],y[10],l[10];
    for(int i=0;i<n;i++){
      cin>>x[i]>>y[i]>>l[i];
    }
    if(n==1){
      cout<<l[0]<<endl;
    }else{
      double lo=0,hi=*min_element(begin(l),begin(l)+n);
      for(int i=0;i<99;i++){
	double m=(lo+hi)/2;
	bool is=false;
	auto all_include=[&](P p){
	  bool f=false;
	  for(int o=0;o<n;o++){
	    f|=!includes(P(x[o],y[o]),sst(l[o],m),p);
	  }
	  return !f;
	};
	for(int j=0;j<n;j++){
	  is|=all_include(P(x[j],y[j]));
	  for(int k=j+1;k<n;k++){
	    auto it=intersection(P(x[j],y[j]),sst(l[j],m),P(x[k],y[k]),sst(l[k],m));
	    for(auto e:it){
	      is|=all_include(e);
	    }
	  }
	}
	if(is){
	  lo=m;
	}else{
	  hi=m;
	}
      }
      cout<<fixed<<lo<<endl;
    }
  }
}

Measured memory_bytes: 1432
#!/usr/bin/env python3
import sys
from math import *
from itertools import *
from collections import *
from functools import *
from bisect import *
try:
    from math import gcd
except Exception:
    from fractions import gcd


def solve(A: int, B: int, Q: int, s: "List[int]", t: "List[int]", x: "List[int]"):
    rs = []
    for xx in x:
        si = bisect(s, xx)
        ti = bisect(t, xx)

        ret = float('inf')
        for ss, tt in product([s[max(0, si - 1)], s[min(si, A - 1)]], [t[max(0, ti - 1)], t[min(ti, B - 1)]]):
            ret = min(ret, abs(ss - xx) + abs(tt - ss))
            ret = min(ret, abs(tt - xx) + abs(tt - ss))
        rs.append(ret)
    return '\n'.join([str(r) for r in rs])


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    A = int(next(tokens))  # type: int
    B = int(next(tokens))  # type: int
    Q = int(next(tokens))  # type: int
    s = [ int(next(tokens)) for _ in range(A) ]  # type: "List[int]"
    t = [ int(next(tokens)) for _ in range(B) ]  # type: "List[int]"
    x = [ int(next(tokens)) for _ in range(Q) ]  # type: "List[int]"
    result = solve(A, B, Q, s, t, x)
    print(result)

if __name__ == '__main__':
    main()


Measured memory_bytes: 30108
#include <bits/stdc++.h>
using namespace std;
#define all(x) x.begin(),x.end()
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
template<class T> inline bool chmax(T&a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T> inline bool chmin(T&a,T b){if(a>b){a=b;return 1;}return 0;}
typedef long long ll;

int n,m,k,x;
string s,t;

int main() {
  cin >> k >> x;
  cout <<(500*k>=x ? "Yes" : "No") << endl;
}

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

const int N = 200006;

int a[N];

int main ()
{
    int n;
    scanf("%d",&n);
    for (int i=1;n>=i;i++)
    {
        int x;
        scanf("%d",&x);
        a[x] = a[x-1] + 1;
    }
    printf("%d\n",n-(*max_element(a+1,a+n+1)));
}


Measured memory_bytes: 1024
#include<iostream>
using namespace std;
int main(){
int A,B,C;
    int ans;
    int min=999999,max=-1000;
    cin>>A>>B>>C;
    if(A<min){
        min=A;
        if(B>C)
            ans = (B*10+C)+min;
        else
            ans = (C*10+B)+min;
    }
    if(B<min){
        min=B;
       if(A>C)
            ans = (A*10+C)+min;
        else
            ans = (C*10+A)+min;
     
    }
    if(C<min){
        min=C;
        if(B>A)
            ans = (B*10+A)+min;
        else
            ans = (A*10+B)+min;

    }
    
    cout<<ans<<endl;
}

Measured memory_bytes: 256