akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Text.RegularExpressions;
using System.Diagnostics;
using static System.Math;
using static System.Array;

//var input = Console.ReadLine().Split().Select(int.Parse).ToArray();
namespace AtCoderSolve
{

    class Solve
    {
        const int mod = 1000000007;
        const int INF = 2147483647;
        const long SINF = 9223372036854775807;

        static string sa, sb, sc;
        
        

        public static void Input()
        {
            var cin = new Scanner();
            sa = Console.ReadLine();
            sb = Console.ReadLine();
            sc = Console.ReadLine();
        }

        static void Main(string[] args)
        {
            Input();

            //var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            //Console.SetOut(sw);

            List<char> a = sa.ToList();
            List<char> b = sb.ToList();
            List<char> c = sc.ToList();
            a.Reverse();
            b.Reverse();
            c.Reverse();
            char cur = 'a';
            string ans = "";

            while (ans=="")
            {
                if (cur == 'a')
                {
                    if (a.Count() == 0)
                    {
                        ans = "A";
                        break;
                    }
                    cur = a[a.Count() - 1];
                    a.RemoveAt(a.Count() - 1);
                }
                else if (cur == 'b')
                {
                    if (b.Count() == 0)
                    {
                        ans = "B";
                        break;
                    }
                    cur = b[b.Count() - 1];
                    b.RemoveAt(b.Count() - 1);
                }
                else if (cur == 'c')
                {
                    if (c.Count() == 0)
                    {
                        ans = "C";
                        break;
                    }
                    cur = c[c.Count() - 1];
                    c.RemoveAt(c.Count() - 1);
                }
            }

            Console.WriteLine(ans);


            //Console.Out.Flush();

        }





    }

    public class Scanner
    {
        public int[] SplitReader()
        {
            int[] array = Console.ReadLine().Split().Select(int.Parse).ToArray();
            return array;
        }
        public long[] SplitReaderL()
        {
            long[] array = Console.ReadLine().Split().Select(long.Parse).ToArray();
            return array;
        }

    }

    public class Graph
    {
        
    }
}

    



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

#define rep(i, n)     for (int i = 0; i < n; ++i)
#define rep1(i, n)    for (int i = 1; i < n + 1; ++i)
#define repN(i, m, n) for (int i = m; i < n; ++i)
#define repR(i, n)    for (int i = n - 1; i >= 0; --i)

using namespace std;

int main() {
	long long n, d;
	long count = 0;
	cin >> n >> d;
	rep(i, n) {
		long long x, y;
		scanf("%lld %lld", &x, &y);
		if (x > d || y > d) {
			continue;
		}
		if (sqrt(x * x + y * y) <= d) {
			++count;
		}
	}

	cout << count;

	return 0;
}


Measured memory_bytes: 3736
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;

int main()
{
    int N,r,a;
    r=0;
    cin >>N;
    vector<int> P(N);
    for(int i=0;i<N;i++){
        cin>>P.at(i);
    }
    a=P.at(0);
    for(int i=0;i<N-1;i++){
        a=min(a,P.at(i+1));
        if(a<P.at(i+1)){
            r++;
        }
    }
    cout << N-r <<endl;
}

Measured memory_bytes: 1024
#include <iostream>
#include <deque>


int main()
{
	std::deque<int> dq;
	
	int q; std::cin >> q;
	for (int i=0; i<q; i++) {
		int op;
		std::cin >> op;
		int d, key, index;
		switch (op) {
		case 0:
			std::cin >> d >> key;
			if (d==0) dq.push_front(key);
			else dq.push_back(key);
			break;
		case 1:
			std::cin >> index;
			std::cout << dq[index] << std::endl;
			break;
		case 2:
			std::cin >> d;
			if (d==0) dq.pop_front();
			else dq.pop_back();
			break;
		}
	}
	
	return 0;
}
		



Measured memory_bytes: 4612
#include <bits/stdc++.h>
#define f first
#define s second
#define MOD 1000000007
#define PMOD 998244353
#define pb(x) push_back(x)
using namespace std;

typedef long long int ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> plii;
typedef pair<int, pii> piii;
const int INF = 1e9+10;
const ll LINF = 1LL*INF*INF;
const int MAXN = 2e5+10;
const int MAXM = 5e3+10;

priority_queue<int> pq;
vector<vector<int> > graph;
queue<int> que;

int A[MAXN];
char S[MAXN];

ll mygcd(ll a,ll b){
    return a?mygcd(b%a,a):b;
}

ll INV(ll a, ll m) {
    ll m0 = m, y = 0, x = 1;
    if (m == 1)    return 0;
    while (a > 1) {
        ll q = a / m;
        ll t = m;
        m = a % m, a = t;
        t = y;
        y = x - q * y;
        x = t;
    }
    if (x < 0) x += m0;
    return x;
}

int main()
{
    ll n,m,k,a,b,x,y,q;
    int sum = 0;
    int cnt = 0;
    int mx = 0;
    int mn = INF;
    int cur = 0, idx = -1;
    int tc;

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    cin>>n;

    if(n==1){
        cout<<1<<"\n";
        return 0;
    }

    n<<=1;

    ll res = n-1;

    ll curv;
    ll gc;

    for(ll i=2;i*i<=n;i++){
        if(n%i)continue;

        a = i;
        b = n/i;

        gc = mygcd(a,b);

        if(gc>1)continue;

        curv = INV(a,b);
        curv *= a;
        res = min(res,curv-1);

        curv = INV(b,a);
        curv *= b;
        res = min(res,curv-1);
    }

    cout<<res<<"\n";

    return 0;
}


Measured memory_bytes: 3660
#include<iostream>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<algorithm>
#include<numeric>
#include<cmath>
#include<queue>
#include<stack>
#include<list>
#include<unordered_map>
#include<unordered_set>
#include<cctype>
#include<iomanip>

using namespace std;
typedef long long int ll;typedef pair<int, int> P;
const long long mod = 1e9 + 7;
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define all(a) (a).begin(),(a).end()
#define allg(a) (a).begin(),(a).end(),greater<>()
#define SUM(a) accumulate((a).begin(),(a).end(),0)
const double PI = 3.14159265359;

int main(void){
	string s; cin >> s;
	bool x = 1; if (s.at(0) != 'A')x = 0;
	bool c = 0;
	for (int i = 2; i < s.length()-1; i++)
		if (s.at(i) == 'C') {
			if (c) { x = 0; break; }
			else c = 1;
		}
	if (!c)x = 0;
	sort(all(s));
	if (s.at(2) >= 'A' && s.at(2) <= 'Z')x = 0;
	cout << (x ? "AC" : "WA") << endl;
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int	main(void)
{
int	A[256];
int	N, c = 0;
int	tmp;
tmp = scanf("%d", &N);
//if( tmp == EOF ) return -101;

if( N==0 || N>200 ) return 1;
for( int f= 0; f< N; ++f)
{
  tmp = scanf("%d", &A[ f ]);
  //if( tmp == EOF ) return -102;
  //printf("%d ", A[ f ]);
}
//printf("\n");

do
{
  int f= 0;
  //printf("-[");
  for( f= 0; f< N; ++f)
  {
    if( A[ f ] %2 != 0 ) break;
    A[ f ] /= 2;
    //printf("%d ", A[ f ]);
  }
  //printf("]\n");

  if( f != N )
  {
    printf("%d", c);
    return	0;
  } else {
	++c;
  }
  //printf("@\n");
} while(-1);

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


Measured memory_bytes: 128
l, r = (int(i) for i in input().split())
if r - l > 2030: print(0)
else:
    ans = 2018
    for i in range(l, r):
        for j in range(i+1, r+1):
            if i*j % 2019 < ans: ans = i*j % 2019
    print(ans)

Measured memory_bytes: 2940
import java.util.Arrays;
import java.util.LinkedList;
import java.util.List;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] a = new int[n];
        a[0] = 11;
        System.out.print(a[0] + " ");
        for (int i = 1; i < n; i++) {
            for (int j = a[i - 1] + 1; j < 55555; j++) {
                if (isPrime(j)) {
                    if (j % 5 == 1) {
                        a[i] = j;
                        System.out.print(j + " ");
                        break;
                    }
                }
            }
        }
        System.out.println();
    }

    public static boolean isPrime(int num) {
        if (num < 2)
            return false;
        else if (num == 2)
            return true;
        else if (num % 2 == 0)
            return false; // 偶数はあらかじめ除く

        double sqrtNum = Math.sqrt(num);
        for (int i = 3; i <= sqrtNum; i += 2) {
            if (num % i == 0) {
                // 素数ではない
                return false;
            }
        }

        // 素数である
        return true;
    }
}


Measured memory_bytes: 20692
SIZE=2*10**6; MOD=10**9+7 #998244353 #ここを変更する

SIZE += 1
inv = [0]*SIZE  # inv[j] = j^{-1} mod MOD
fac = [0]*SIZE  # fac[j] = j! mod MOD
finv = [0]*SIZE # finv[j] = (j!)^{-1} mod MOD
fac[0] = fac[1] = 1
finv[0] = finv[1] = 1
for i in range(2,SIZE):
    fac[i] = fac[i-1]*i%MOD
finv[-1] = pow(fac[-1],MOD-2,MOD)
for i in range(SIZE-1,0,-1):
    finv[i-1] = finv[i]*i%MOD
    inv[i] = finv[i]*fac[i-1]%MOD

def choose(n,r): # nCk mod MOD の計算
    if 0 <= r <= n:
        return (fac[n]*finv[r]%MOD)*finv[n-r]%MOD
    else:
        return 0



# coding: utf-8
# Your code here!
import sys
read = sys.stdin.read
readline = sys.stdin.readline

k, = map(int,readline().split())
s = input()

MOD = 10**9+7

l = len(s)
ans = pow(26,l+k,MOD)

p25 = [1]
for _ in range(SIZE):
    p25.append(p25[-1]*25%MOD)

for p in range(l):
    ans -= p25[k+l-p]*choose(l+k,p)%MOD

print(ans%MOD)






Measured memory_bytes: 215864
#include <bits/stdc++.h>
using namespace std;
using Int = long long;
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n,a,b;
    cin>>n>>a>>b;
    char s[n+1]={};
    for (int i = 1; i <= n; i++)cin>>s[i];
    int gou=0,kai=1;
    for (int i = 1; i <= n; i++){
        if(s[i]=='a'){
            if(gou<a+b){
                cout<<"Yes"<<'\n';
                gou++;
            }else cout<<"No"<<'\n';
        }else if(s[i]=='b'){
            if(gou<a+b&&kai<=b){
                cout<<"Yes"<<'\n';
                gou++;
                kai++;
            }else{
                cout<<"No"<<'\n';
                kai++;
            }
        }else cout<<"No"<<'\n';
    }
}

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

// マクロ
// forループ
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=(a);i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=(a);i>=(ll)(b);i--)
// xにはvectorなどのコンテナ
#define ALL(x) (x)begin(),(x).end()
#define SIZE(x) ((ll)(x).size())
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))
// 出力
#define PRINT(x) cout<<(x)<<endl
#define PRINTA(x,n) REP(i,n)PRINT(x[i])
// 定数
#define INF 1000000000000 // 10^12
#define MOD 1000000007 // 10^9+7
// 略記
#define PB push_back
#define MP make_pair

const int MAX_N = 8;

int N, x[MAX_N], y[MAX_N];

int perm[MAX_N];

double dist(int, int, int, int);

int main() {
    cin >> N;
    REP(i, N) cin >> x[i] >> y[i];

    REP(i, N) perm[i] = i;
    double sum_d = 0;
    int cnt_path = 0;

    do {
        cnt_path++;
        REP(i, N-1) {
            int x1 = x[perm[i]];
            int y1 = y[perm[i]];
            int x2 = x[perm[i+1]];
            int y2 = y[perm[i+1]];
            sum_d += dist(x1, y1, x2, y2);
        }
    } while (next_permutation(perm, perm + N));

    double ave_d = sum_d / cnt_path;
    printf("%.7f\n", ave_d);
    return 0;
}

double dist(int x1, int y1, int x2, int y2) {
    double dist = sqrt(pow(x1 - x2, 2) + pow(y1 - y2, 2));
    return dist;
}

Measured memory_bytes: 256
'use strict'

function main(input) {
  input = input
    .trim()
    .split(/\n/)
    .map(Number)
  const a = input[0]
  const b = input[1]
  const c = input[2]
  const x = input[3]
  let ans = 0
  for (let ai = 0; ai <= a; ai++) {
    for (let bi = 0; bi <= b; bi++) {
      for (let ci = 0; ci <= c; ci++) {
        const sum = ai * 500 + bi * 100 + ci * 50
        if (sum === x) ans++
      }
    }
  }
  console.log(ans)
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'))


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

int main(){
  string S;
  cin >> S;
  if (S=="Sunny")
    cout << "Cloudy" << endl;
  if (S=="Cloudy")
    cout << "Rainy" << endl;
  if (S=="Rainy")
    cout << "Sunny" << endl;
  
}

Measured memory_bytes: 256
n = int(input())
a = list(map(int, input().split()))
MOD = 10 ** 9 + 7
C = [0] * (n + 1)
C[0] = 3
ans = 1
for i in a:
    ans = ans * C[i] % MOD
    C[i] -= 1
    C[i+1] += 1
print(ans % MOD)


Measured memory_bytes: 14396
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  int n,k;
  cin>>n>>k;

  if(((n-1)%(k-1))==0){
    cout<<(n-1)/(k-1)<<endl;
  }
  else{
    cout<<(n-1)/(k-1)+1<<endl;
  }

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(void){
   int n,o=0,e=0;
   cin>>n;
   int a[n];
   for(int i=0;i<n;i++) cin>>a[i];
   sort(a,a+n);
   for(int i=0;i<n;i++){
    if(i%2) o+=a[i];
    else e+=a[i];
   }
   cout<<abs(e-o);
}


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

int main()
{
    map < string, int > mp;

    string s, u, t;
    int a, b;

    cin >> s >> t >> a >> b >> u;

    mp[s] = a;
    mp[t] = b;
    mp[u]--;

    cout << mp[s] << ' ' << mp[t] << endl;

    return 0;
}


Measured memory_bytes: 256
import sys

def solve():
    a = int(input())
    b = int(input())

    if a == b:
        print(1)
        return

    t = a ^ b
    N = len(bin(t)) - 2
    t = 1 << N

    a = a & (t - 1)
    b = b & (t - 1)

    blen = len(bin(b)) - 2

    sb = b & (2**(blen - 1) - 1)

    if sb == 0:
        sblen = 0
    else:
        sblen = len(bin(sb)) - 2

    s = (1<<sblen) - 1

    ymax = b | s

    T = 1<<(N - 1)

    ans = T - a

    if ymax < T + a:
        ans += ymax - T + 1 + T - a
    else:
        ans += T

    print(ans)


if __name__ == '__main__':
    solve()

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define db1(x) cout<<#x<<"="<<x<<'\n'
#define db2(x,y) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<'\n'
#define db3(x,y,z) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<","<<#z<<"="<<z<<'\n'
#define dbV(arr) cout << #arr << "=[ "; \
for(auto i:arr) cout << i << " "; cout << "]\n";
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define repF(i,a,n) for(int i = (a); i <= (n); ++i)
#define repB(i,a,n) for(int i = (a); i >= (n); --i)
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vi vector<int>
#define vl vector<ll>
#define umii unordered_map<int,int>
#define umll unordered_map<ll,ll>
#define mii map<int,int>
#define mll map<ll,ll>
#define seti set<int>
#define setl set<ll>
#define pb push_back
#define F first
#define S second
#define MOD 1000000007
#define all(z) z.begin(),z.end()
using namespace std;
using ll = long long;
ll solve(vector<pair<int, ll>> &item, int n, int w) {
	ll dp[n + 1][w + 1];
	rep(i, n + 1) {
		rep(j, w + 1) {
			if (!i or !j) dp[i][j] = 0;
			else if (item[i - 1].F <= j)
				dp[i][j] = max(item[i - 1].S + dp[i - 1][j - item[i - 1].F], dp[i - 1][j]);
			else
				dp[i][j] = dp[i - 1][j];
		}
	}
	return dp[n][w];
}
int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	int n, w; cin >> n >> w;
	vector<pair<int, ll>> item(n);
	rep(i, n) cin >> item[i].F >> item[i].S;
	cout << solve(item, n, w) << '\n';
	return 0;
}

Measured memory_bytes: 82460
# ABC 047 D
N, T = map(int,input().split())
A = list(map(int,input().split()))

m = A[0]
M = 0
for k in range(1,N):
    m = min(m,A[k-1])
    M = max(M,A[k]-m)

m = A[0]
ans = 0
for k in range(1,N):
    m = min(m,A[k-1])
    if A[k]-m == M:
        ans += 1

print(ans)


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

#define rep(i, a) for (int i = 0; i < (a); ++i)
#define REP(i, a, b) for (int i = a; i < (b); ++i)
#define REV(i, a, b) for (int i = a; i > (b); --i)
#define debug(a) cerr << #a << " " << a << endl
#define debug2(a, b) cerr << #a << " " << a << ", " << #b << " " << b << endl

using namespace std;
using ll = long long;
using P = pair<int, int>;

void Main() {
  double pi = 6.28318530717958623200;
  double r; cin >> r;
  cout << r*pi << endl;
}

int main() {
  std::cin.tie(nullptr);
  std::ios_base::sync_with_stdio(false);
  std::cout << std::fixed << std::setprecision(15);
  Main();
  return 0;
}


Measured memory_bytes: 3788
#include <cstdio>
#include <string>
#include <iostream>
#include <cstring>

using namespace std;

int h,w;
int fie[101][101];

int main(void){
	scanf("%d %d",&h,&w);
	memset(fie,-1,sizeof(fie));
	for(int i=0;i<h;i++){
		string str;
		cin >> str;
		for(int j=0;j<w;j++){
			if(str[j]=='c'){
				fie[i][j]=0;
			}
		}
	}
	for(int i=0;i<h;i++){
		for(int j=0;j<w;j++){
			if(fie[i][j]==-1){
				if(j>0 && fie[i][j-1]>=0)fie[i][j]=fie[i][j-1]+1;
			}
			printf("%d%c",fie[i][j],j==w-1?'\n':' ');
		}
	}
	return 0;
}

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

const int MOD=1e9+7;

const int MAX=400010;

ll fac[MAX], finv[MAX], inv[MAX];

void cmbInit() {
    fac[0]=fac[1]=1;
    finv[0]=finv[1]=1;
    inv[1]=1;
    for (int i=2;i<MAX;i++){
        fac[i]=fac[i-1]*i%MOD;
        inv[i]=MOD-inv[MOD%i]*(MOD/i)%MOD;
        finv[i]=finv[i-1]*inv[i]%MOD;
    }
}


ll cmb(int n, int k){
    if (n<k) return 0;
    if (n<0 || k<0) return 0;
    return fac[n]*(finv[k]*finv[n-k]%MOD)%MOD;
}

int main() {
    int n,k;
    cin >> n >> k;
    cmbInit();
    ll ans;
    if (k >= n) ans = cmb(2*n-1,n);
    else {
        ans = 1;
        for (int i = 1; i <= k; ++i) {
            ans += (cmb(n,i) * cmb(n-1,i)) % MOD;
            ans = ans % MOD;
        }
    }
    cout << ans << endl;
}

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

int main()
{
  string s;
  cin >> s;
  bool ans = true;
  if (s.size() % 2 == 1)
  {
    cout << "No" << endl;
    return 0;
  }
  for (int i = 0; i < s.size(); i++)
  {
    if (i % 2)
    {
      if (s.at(i) != 'i')
      {
        ans = false;
        break;
      }
    }
    else
    {
      if (s.at(i) != 'h')
      {
        ans = false;
        break;
      }
    }
  }
  cout << (ans ? "Yes" : "No") << endl;
}


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

int main(int argc, const char * argv[]) {
    string s;
    cin >> s;
    int a, b, sum = 0;
    bool flag = false;
    for (int i = 0; i < s.size()-1; i++) {
        a =  (s[i] - '0');
        b =  (s[i+1] - '0');
        if (!flag) {
            if (a + b < a - 1 + 9) {
                sum += a - 1;
                s[i] = a - 1 + '0';
                //s[i+1] = 9 + '0';
                flag = true;
            }else{
                sum += a;
            }
        }else{
            sum += 9;
            s[i] = 9 + '0';
        }
    }
    if (flag) {
        sum += 9;
    }else{
        sum += s[s.size()-1] - '0';
    }
    cout << sum << endl;
    return 0;
}


Measured memory_bytes: 256
import Control.Monad
import Data.Maybe
import qualified Data.ByteString.Char8 as BS
import Data.List
import qualified Data.Vector as V

readInt = fst . fromJust . BS.readInt
readIntList = map readInt . BS.words
getInt = readInt <$> BS.getLine
getIntList = readIntList <$> BS.getLine

main = do
    k <- getInt
    l <- length <$> getLine
    print $ (solve k l) `mod` 1000000007

solve 0 _ = 1
solve k l = foldl' (plusMod) 0 [(comb (l+i-1) i) `mulMod` (powerMod 25 i) `mulMod` (powerMod 26 (k-i)) | i <- [0..k]]

moduloN :: Int
moduloN = 10 ^ 9 + 7

modN = flip mod moduloN

plusMod x y = modN $ x + y

minusMod x y | x < y = moduloN + x - y
             | otherwise = x - y

mulMod x y = modN $ x * y

powerMod x 0 = 1
powerMod x y
    | even y = mulMod t t
    | otherwise = mulMod x $ mulMod t t
    where
        t = powerMod x $ div y 2

invMod n = powerMod n $ moduloN - 2

finv :: Int -> Int
finv k = finvs V.! k
    where finvs :: V.Vector Int
          finvs = V.generate 2000001 finv'
              where finv' 0 = 1
                    finv' n = modN $ finvs V.! (n - 1) * inv n

inv :: Int -> Int
inv k = invs V.! k
    where inv' 1 = 1
          inv' n = modN (-(invs V.! r) * q)
              where (q, r) = moduloN `divMod` n
          invs :: V.Vector Int
          invs = V.generate 2000001 inv'

fact :: Int -> Int
fact k = facts V.! k
    where fact' 0 = 1
          fact' n = modN $ n * (facts V.! (n - 1))
          facts :: V.Vector Int
          facts = V.generate 2000001 fact'

comb :: Int -> Int -> Int
comb n k | n < 0 || k < 0 || n < k = 0
         | otherwise = modN $ modN (fact n * finv k) * finv (n - k)

Measured memory_bytes: 367068
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
    ios_base:: sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    ll x,n;cin>>x>>n;
    set<ll> st;for(ll i=0,x;i<n;i++)cin>>x,st.insert(x);
    for(ll l=x,r=x;;l--,r++){
        if(!st.count(l))return cout<<l , 0;
        if(!st.count(r))return cout<<r , 0;
    }
}



Measured memory_bytes: 3660
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  long long H,W;
  cin >> H >> W ;
 if ((H%2==0 || W%2==0) && (H>1 && W>1)) {cout << H*W/2 << endl;}
 else if (H>1 && W>1) {cout << (H*W+1)/2 << endl;}
 else {cout << 1 << endl;}
 
}

Measured memory_bytes: 256
def main():
    N, M = (int(i) for i in input().split())
    A = [int(i) for i in input().split()]
    sumA = sum(A)
    C = [a >= sumA/(4*M) for a in A]
    print("Yes" if C.count(True) >= M else "No")


if __name__ == '__main__':
    main()


Measured memory_bytes: 38384
N = int(input())
A = [int(x) for x in input().split()]
B = [int(x) for x in input().split()]

cntA = [0 for i in range(N+1)]
cntB = [0 for i in range(N+1)]

for i in range(N):
    cntA[A[i]] += 1
for i in range(N):
    cntB[B[i]] += 1#cntA[B[i]]にしていた…

temp = False
for i in range(N):
    if cntA[A[i]] + cntB[A[i]] > N:
        temp = True
        break

if temp:
    print("No")


else:
    print("Yes")
    cA = 0
    cB = 0
    flag = False
    C = [B[N-i-1] for i in range(N)]
    D = [B[N-i-1] for i in range(N)]

    for i in range(1,N+1):
        if cA + cB + cntA[i] + cntB[i] == N:
            break
        elif cA + cB + cntA[i] + cntB[i] < N:
            cA += cntA[i]
            cB += cntB[i]
        elif cA + cB + cntA[i] >= N:
            if cA >= cntB[i]:
                for j in range(cntB[i]):
                    C[j] = i
                for j in range(N-cB-cntB[i]):
                    C[j+cntB[i]] = D[j]
            else:
                for j in range(cA):
                    C[j] = i
                for j in range(N-cB-cntB[i]):
                    C[j+cA] = D[j]
                for j in range(cB):
                    C[j+N-(cB+cntB[i]-cA)] = D[N-1-j]
                for j in range(cntB[i]-cA):
                    C[N-j-1] = i
            break
        else:#elif cA + cB + cntB[i] >= N:にしてたが、cntA[i]もcntB[i]も覆えない時を含めた。
            if cntA[i] + cntB[i] <= N-cB:
                for j in range(cntB[i]-(N-cB-(cA+cntA[i]))):
                    C[j] = i
                for j in range(N-(cB+cntB[i])):
                    C[j+cntB[i]-(N-cB-(cA+cntA[i]))] = D[j]
                for j in range(N-cB-(cA+cntA[i])):
                    C[j+cA+cntA[i]] = i
            else:
                for j in range(cA):
                    C[j] = i
                for j in range(N-(cB+cntB[i])):
                    C[j+cA] = D[j]
                for j in range(cB):
                    C[j+N+cA-(cB+cntB[i])] = D[N-j-1]
                for j in range(cntB[i]-cA):
                    C[N-(cntB[i]-cA)+j] = i
            break
    F = [str(x) for x in C]
    print(" ".join(F))

Measured memory_bytes: 156316
import sys
answer = [i for i in input().split()]
inp = [i for i in input().split()]
if answer == inp:
    print("Yes")
    sys.exit()
for i in range(1,33):
    if (i<=20 and i%5==0) or i==22 or i==27 or i==28:
        s = "N"
    else:
        s = "E"
    if s == "E":
        a = []
        a.append(inp[3])
        a.append(inp[1])
        a.append(inp[0])
        a.append(inp[5])
        a.append(inp[4])
        a.append(inp[2])
        inp = a
        if answer == inp:
            print("Yes")
            break
    elif s == "N":
        a = []
        a.append(inp[1])
        a.append(inp[5])
        a.append(inp[2])
        a.append(inp[3])
        a.append(inp[0])
        a.append(inp[4])
        inp = a
        if answer == inp:
            print("Yes")
            break
    if i == 32:
        print ("No")

Measured memory_bytes: 7608
#include <stdio.h>
#include <iostream>
#include <vector>
#include <queue>
#include <stack>
#include <algorithm>

using ll = long long int;
const int INF = (1<<30);
const ll INFLL = (1ll<<60);
const ll MOD = (ll)(1e9+7);

#define l_ength size

void mul_mod(ll& a, ll b){
	a *= b;
	a %= MOD;
}

void add_mod(ll& a, ll b){
	a = (a<MOD)?a:(a-MOD);
	b = (b<MOD)?b:(b-MOD);
	a += b;
	a = (a<MOD)?a:(a-MOD);
}

int main(void){
	int n;
	std::string s = "pphbhhphph";
	std::cin >> n;
	n %= 10;
	std::cout << s[n] << "on" << std::endl;
	return 0;
}


Measured memory_bytes: 3628
class UnionFind:
    def __init__(self, size):
        self.parent = [-1] * size
        self.rank = [1] * size
        self.groups = size

    def get_root(self, node):
        parent = self.parent[node]
        if parent == -1:
            root = node
        else:
            root = self.get_root(parent)
            self.parent[node] = root  # 同じnodeへの2回目以降のget_rootを高速にするために、直接rootに繋いでおく
        return root

    def in_same_group(self, node1, node2):
        root1 = self.get_root(node1)
        root2 = self.get_root(node2)
        return root1 == root2

    def unite(self, node1, node2):
        if self.in_same_group(node1, node2):
            return
        main_root = self.get_root(node1)
        sub_root = self.get_root(node2)
        if self.rank[main_root] < self.rank[sub_root]:
            main_root, sub_root = sub_root, main_root

        self.parent[sub_root] = main_root
        self.rank[main_root] += self.rank[sub_root]
        self.groups -= 1


n, m = map(int, input().split())
uf = UnionFind(n)

for i in range(m):
    x, y, z = map(int, input().split())
    x -= 1
    y -= 1
    uf.unite(x, y)

print(uf.groups)


Measured memory_bytes: 5936
#include <bits/stdc++.h>
 
using namespace std;
 
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define all(a) a.begin(), a.end()
#define rep(i, st, n) for (int i = (st); i < (n); ++i)
#define debug(x) std::cout << #x << ": " << x << endl
 
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef long double ld;
 
template <typename T1, typename T2> bool chkmin(T1 &x, T2 y) { return y < x ? (x = y, true) : false; }
template <typename T1, typename T2> bool chkmax(T1 &x, T2 y) { return y > x ? (x = y, true) : false; }

const ll INF = 1e18;
const int maxN = 302;
int N, K;
ll f[maxN][maxN];
ll H[maxN];
ll dp[maxN][maxN][2];

signed main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
#ifdef DEBUG
    freopen("in", "r", stdin);
#endif

    cin >> N >> K;
    for (int i = 1; i <= N; ++i)
        cin >> H[i];
    for (int l = 1; l <= N; ++l)
    {
        for (int r = l; r <= N; ++r)
        {
            f[l][r] = H[l];
            for (int i = l + 1; i <= r; ++i)
                if (H[i] > H[i - 1])
                    f[l][r] += H[i] - H[i - 1];
        }
    }
    for (int i = 0; i < maxN; ++i)
        for (int j = 0; j < maxN; ++j)
            for (int k = 0; k < 2; ++k)
                dp[i][j][k] = INF;
    dp[0][0][0] = dp[0][0][1] = 0;
    for (int i = 1; i <= N; ++i)
    {
        for (int k = 0; k <= i; ++k)
        {
            // dp[i][k][0]
            for (int c = 0; c <= k; ++c)
            {
                chkmin(dp[i][k][0], dp[i - c][k - c][1] - min(H[i + 1], H[i - c]));
            }
            // dp[i][k][1]
            for (int j = 1; j <= i; ++j)
            {
                chkmin(dp[i][k][1], dp[j - 1][k][0] + f[j][i]);
            }
        }
    }
    ll ans = INF;
    for (int k = 0; k <= K; ++k)
    {
        chkmin(ans, dp[N][k][0]);
        chkmin(ans, dp[N][k][1]);
    }
    cout << ans << '\n';

    return 0;
}





Measured memory_bytes: 2560
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repp(i, a, b) for (int i = a; i <= (b); ++i)
#define repr(i, a, b) for (int i = a; i >= (b); --i)
#define bit(n) (1LL << (n))
typedef long long ll;
const int INF = 1001001001;
const ll LINF = 1001001001001001001ll;
const int MOD = 1000000007;

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;
}

struct mint {
  ll x;
  mint(ll x = 0) : x((x % MOD + MOD) % MOD) {}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= MOD)
      x -= MOD;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += MOD - a.x) >= MOD)
      x -= MOD;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= MOD;
    return *this;
  }
  mint operator+(const mint a) const {
    mint res(*this);
    return res += a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res -= a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res *= a;
  }
  /* 変数名.pow(n) */
  mint pow(ll t) const {
    if (!t)
      return 1;
    mint a = pow(t >> 1);
    a *= a;
    if (t & 1)
      a *= *this;
    return a;
  }

  // 以降はMODが素数のみ
  mint inv() const {
    return pow(MOD - 2);
  }
  mint& operator/=(const mint a) {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const {
    mint res(*this);
    return res /= a;
  }
};

int main() {
  ll N, K;
  cin >> N >> K;
  vector<ll> A(N);
  rep(i, N) cin >> A[i];

  mint ans = 0;
  rep(i, N) {
    ll a = A[i];
    ll l = 0;
    repp(j, 0, i - 1) {
      if (A[j] < a)
        l++;
    }
    ll r = 0;
    repp(j, i + 1, N - 1) {
      if (A[j] < a)
        r++;
    }
    mint temp = ((K * (K + 1)) % MOD) * r;
    temp /= 2;
    ans += temp;
    temp = ((K * (K - 1)) % MOD) * l;
    temp /= 2;
    ans += temp;
  }
  cout << ans.x << endl;
}

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

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
using ll = long long;
string char_to_string(char val) {
  return string(1, val);
}
int char_to_int(char val) {
  return val - '0';
}
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;
}
int vector_finder(std::vector<ll> vec, int number) {
  auto itr = std::find(vec.begin(), vec.end(), number);
  size_t index = std::distance( vec.begin(), itr );
  if (index != vec.size()) { // 発見できたとき
    return 1;
  }
  else { // 発見できなかったとき
    return 0;
  }
}
struct edge {
  ll to, cost;
};

int main() {
  ll N, K; cin >> N >> K;
  vector<ll> H(N); REP(i, N) cin >> H[i];
  sort(all(H), greater<ll>());
  ll ans = 0;
  for(int i = K; i < N; ++i) ans += H[i];
  cout << ans << endl;
}

Measured memory_bytes: 4804
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#include <queue>
#include <numeric>

using namespace std;
#define repp(i,a,b) for(int i = (int)(a) ; i < (int)(b) ; ++i)
#define reppe(i,a,b) for(int i = (int)(a) ; i <= (int)(b) ; ++i)
#define repm(i,a,b) for(int i = (int)(a) ; i > (int)(b) ; --i)
#define repme(i,a,b) for(int i = (int)(a) ; i >= (int)(b) ; --i)

typedef long long ll;

long long GCD(long long a, long long b){if(b==0)return a;return GCD(b,a%b);}

char al[26] = {'a','b','c','d','e','f','g','h','i','j'};
vector<string> res;
int N; 
void recv(string s, int types, int depth) {
    
    if (depth > N) {
        res.push_back(s);
        return;
    }
    repp(i,0,types - 1) {
        recv(s+al[i], types, depth+1);
    }
    recv(s+al[types-1], types+1, depth+1);
}
int main() {
    cin >> N;
    if (N == 1) cout << "a" << endl;
    else {
        recv("a", 2, 2);
    }
    sort(res.begin(), res.end());
    
    //cout << res.size() << endl;
    for(auto x: res) cout << x << endl;
}


Measured memory_bytes: 7796
S = int(input())
K = int(input())

lst = []
while S > 0:
    lst.append(S%10)
    S //= 10 
lst.reverse()

if len(lst) == lst.count(1):
	print(1)

elif K == lst[:K].count(1):
	print(1)
  
else:
	for i in range(K):
		if lst[i] != 1:
			print(lst[i])
			break


  
  

Measured memory_bytes: 3060
#include <cstdio>
#include <iostream>
#include <algorithm>

using namespace std;

typedef unsigned long long ULL;

ULL h, k, m[2000010], r;


int main() {
    scanf("%llu%llu", &h, &k);
    if(h <= k) {
        printf("0");
        return 0;
    }
    for(ULL i = 0; i < h; i++)
        scanf("%llu", &m[i]);
    
    sort(m, m + h);
    for(ULL i = 0; i < h - k; i++)
        r += m[i];
    printf("%llu", r);
    return 0;
}



Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define MOD 1000000007
#define F first
#define S second
using namespace std;
typedef pair<int,int> pii;
int n,m; char arr[30][30]; int dist[404][404],ans;
main()
{
	cin>>n>>m;
	for(int i=0;i<n;i++)
	{
		for(int j=0;j<m;j++)
		{
			scanf(" %c",&arr[i][j]);
		}
	}
	for(int i=0;i<n;i++)
	{
		for(int j=0;j<m;j++)
		{
			if(arr[i][j]=='#') continue;
			if(i&&arr[i-1][j]=='.') dist[i+n*j][i-1+n*j]=1;
			if(j&&arr[i][j-1]=='.') dist[i+n*j][i+n*(j-1)]=1;
			if(i+1<n&&arr[i+1][j]=='.') dist[i+n*j][i+1+n*j]=1;
			if(j+1<m&&arr[i][j+1]=='.') dist[i+n*j][i+n*(j+1)]=1;
		}
	}  for(int i=0;i<400;i++)
	{
		for(int j=0;j<400;j++) if(dist[i][j]==0&&i!=j)
		{
			dist[i][j]=MOD;
		}
	} for(int k=0;k<400;k++)
	{
		for(int i=0;i<400;i++)
		{
			for(int j=0;j<400;j++)
				dist[i][j]=min(dist[i][j],dist[i][k]+dist[k][j]);
		}
	} for(int i=0;i<400;i++)
	{
		for(int j=0;j<400;j++) if(dist[i][j]!=MOD&&dist[i][j]>ans)
		{
			ans=dist[i][j];
		}
	} printf("%d",ans);
}

Measured memory_bytes: 896
//#define _GLIBCXX_DEBUG
#include "bits/stdc++.h"

using namespace std;

//------------------------------- Type Names -------------------------------//

using i64 = int_fast64_t;

using seika = string;
//{akari : 1D, yukari : 2D, maki : 3D} vector
template <class kizuna>
using akari = vector<kizuna>;
template <class yuzuki>
using yukari = akari<akari<yuzuki>>;
template <class tsurumaki>
using maki = akari<yukari<tsurumaki>>;
//{akane : ascending order, aoi : decending order} priority queue
template <class kotonoha>
using akane = priority_queue<kotonoha, akari<kotonoha>, greater<kotonoha>>;
template <class kotonoha>
using aoi = priority_queue<kotonoha>;

//------------------------------- Libraries ---------------------------------//

//------------------------------- Dubug Functions ---------------------------//

inline void print()
{
    cout << endl;
}
template <typename First, typename... Rest>
void print(const First &first, const Rest &... rest)
{
    cout << first << ' ';
    print(rest...);
}

//------------------------------- Solver ------------------------------------//

void solve()
{
    int n, k, s;
    cin >> n >> k >> s;
    for (int i = 0; i < k; i++)
    {
        cout << s << ' ';
    }
    for (int i = k; i < n; i++)
    {
        cout << int(s == 1e9 ? (1e9) - 1 : 1e9) << ' ';
    }
    cout << endl;
}

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


Measured memory_bytes: 1280
#include"bits/stdc++.h"
using namespace std;

int main(){
  int flag;
  double  w, h, x, y, max;
  cin >> w >> h >> x >> y;

  max = w * h / 2;
  flag = (w/2==x && h/2==y) ? 1 : 0;
  cout << max << " " << flag << endl;

  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<map>
#include<cstring>
using namespace std;
char a[10][10];
bool b[10][10];
int n,m,k;
bool judge(int x,int y) {
	memset(b,true,sizeof b);
	for(int i=0;i<n;i++) {
		if((x>>i)&1) {
			for(int j=0;j<m;j++) b[i][j]=false;
		}
	}
	for(int j=0;j<m;j++) {
		if((y>>j)&1) {
			for(int i=0;i<n;i++) b[i][j]=false;
		}
	}
	
	int res=0;
	for(int i=0;i<n;i++) {
		for(int j=0;j<m;j++) {
			if(b[i][j]&&a[i][j]=='#')
				res++;
		}
	}
	if(res==k) return true;
	else return false;
	
}
int main() {	
	cin>>n>>m>>k;
	for(int i=0;i<n;i++) {
		cin>>a[i];
	}
	int res=0;
	for(int i=0;i<(2<<(n-1));i++) {
		for(int j=0;j<(2<<(m-1));j++) {
			//cout<<i<<' '<<j<<endl;
			if(judge(i,j)) res++;
		}
	}
	cout<<res;
	return 0;
}


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

using namespace std;

int main(int argc, char *argv[]) {
  int n, m, k;
  cin >> n >> m >> k;
  for (int i = 0; i <= n; i++) {
    for (int j = 0; j <= m; j++) {
      if (i * m + j * n - i * j * 2 == k) {
        cout << "Yes" << endl;
        return 0;
      }
    }
  }
  cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 256
//
// Topological Sort
//
//
// Description:
//
//   Let G = (V, E) be a graph. An ordering ord: [n] -> V is a topological 
//   ordering if i > j then there is no edge from ord[i] to ord[j].
//   G has a topological ordering if and only if G is DAG.
//
//   A topological order can be obtained in O(n + m) time by using
//   an iterative method (Kuhn's algorithm) or a recursive method 
//   (by Tarjan's algorithm). The following implementation is a 
//   Kuhn's algorithm.
//
//   Note that if you want to find the all topological orders,
//
//
// Complexity:
//
//   O(n + m)
//
#include <bits/stdc++.h>
using namespace std;

#define fst first
#define snd second
#define all(c) ((c).begin()), ((c).end())

struct Graph {
  int n;
  vector<vector<int>> adj;
  Graph(int n) : n(n), adj(n) { }
  void addEdge(int u, int v) {
    adj[u].push_back(v);
  }
};

// return empty list if g has no topological order
vector<int> topologicalSort(Graph g) {
  vector<int> deg(g.n);
  for (int u = 0; u < g.n; ++u)
    for (int v: g.adj[u]) ++deg[v];
  vector<int> stack; 
  for (int u = 0; u < g.n; ++u)
    if (!deg[u]) stack.push_back(u);

  vector<int> order;
  while (!stack.empty()) {
    int u = stack.back(); stack.pop_back();
    order.push_back(u);
    for (int v: g.adj[u]) 
      if (!--deg[v]) stack.push_back(v);
  }
  return order.size() == g.n ? order : vector<int>();
}

int main() {
  int n, m; cin >> n >> m;
  Graph g(n);
  for (int i = 0; i < m; ++i) {
    int u, v; cin >> u >> v;
    g.addEdge(u, v);
  }
  auto ord = topologicalSort(g);
  for (int i = 0; i < ord.size(); ++i) {
    if (i > 0) cout << " ";
    cout << ord[i];
  }
}



Measured memory_bytes: 3920
#include <stdio.h>

int main(){
    int a,b,c;
    scanf("%d%d%d",&a,&b,&c);
    int ans;
    if(a==b&&b==c){
        ans=1;
    }else if(a!=b&&b!=c&&c!=a){
        ans=3;
    }else{
        ans=2;
    }
    printf("%d\n",ans);
}

Measured memory_bytes: 128
N,A,B,C,D = map(int, raw_input().rstrip().split(' '))
diff = abs(B-A)
r = False

m = N-1
for k in xrange(1, 1+m):
    hi = k*D - (m-k)*C
    lo = k*C - (m-k)*D
    if lo <= diff <= hi:
        r = True
        break

print 'YES' if r else 'NO'


Measured memory_bytes: 2568
import sys
from sys import exit
from collections import deque
from copy import deepcopy
from bisect import bisect_left, bisect_right, insort_left, insort_right
from heapq import heapify, heappop, heappush
from itertools import product, permutations, combinations, combinations_with_replacement
from functools import reduce
from math import gcd, sin, cos, tan, asin, acos, atan, degrees, radians

sys.setrecursionlimit(10**6)
INF = 10**20
eps = 1.0e-20
MOD = 10**9+7

def lcm(x,y):
    return x*y//gcd(x,y)
def lgcd(l):
    return reduce(gcd,l)
def llcm(l):
    return reduce(lcm,l)
def powmod(n,i,mod=MOD):
    return pow(n,mod-1+i,mod) if i<0 else pow(n,i,mod)
def div2(x):
    return x.bit_length()
def div10(x):
    return len(str(x))-(x==0)
def intput():
    return int(input())
def mint():
    return map(int,input().split())
def lint():
    return list(map(int,input().split()))
def ilint():
    return int(input()), list(map(int,input().split()))
def judge(x, l=['Yes', 'No']):
    print(l[0] if x else l[1])
def lprint(l, sep='\n'):
    for x in l:
        print(x, end=sep)
def ston(c, c0='a'):
    return ord(c)-ord(c0)
def ntos(x, c0='a'):
    return chr(x+ord(c0))
class counter(dict):
    def __init__(self, *args):
        super().__init__(args)
    def add(self,x,d=1):
        self.setdefault(x,0)
        self[x] += d
    def list(self):
        l = []
        for k in self:
            l.extend([k]*self[k])
        return l
class comb():
    def __init__(self, n, mod=None):
        self.l = [1]
        self.n = n
        self.mod = mod
    def get(self,k):
        l,n,mod = self.l, self.n, self.mod
        k = n-k if k>n//2 else k
        while len(l)<=k:
            i = len(l)
            l.append(l[i-1]*(n+1-i)//i if mod==None else (l[i-1]*(n+1-i)*powmod(i,-1,mod))%mod)
        return l[k]
def pf(x,mode='counter'):
    C = counter()
    p = 2
    while x>1:
        k = 0
        while x%p==0:
            x //= p
            k += 1
        if k>0:
            C.add(p,k)
        p = p+2-(p==2) if p*p<x else x
    if mode=='counter':
        return C
    S = set([1])
    for k in C:
        T = deepcopy(S)
        for x in T:
            for i in range(1,C[k]+1):
                S.add(x*(k**i))
    if mode=='set':
        return S
    if mode=='list':
        return sorted(list(S))

######################################################

H,W=mint()
A=[input() for _ in range(H)]
C=[[0]*W for _ in range(H)]
for i,j in product(range(H),range(W)):
    if A[i][j]=='.':
        C[i][j]=INF
for i,j in product(range(H),range(1,W)):
    C[i][j] = min(C[i][j],C[i][j-1]+1)
for i,j in product(range(1,H),range(W)):
    C[i][j] = min(C[i][j],C[i-1][j]+1)
for i,j in product(range(H),range(W-2,-1,-1)):
    C[i][j] = min(C[i][j],C[i][j+1]+1)
for i,j in product(range(H-2,-1,-1),range(W)):
    C[i][j] = min(C[i][j],C[i+1][j]+1)
print(max([max(c) for c in C]))

Measured memory_bytes: 122008
h = int(input())

dp = [0, 1]

for i in range(2, 100001):
    x = 1 + 2 * dp[i // 2]
    dp.append(x)


if h < 100001:
    print(dp[h])



else:
    l = []
    y = h
    while y >= 100001:
        l = [y] + l
        y = y// 2
    ans = 1 + 2 * dp[l[0] // 2]
    if len(l) > 1:
        for i in range(len(l) - 1):
            ans = 1 + 2 * ans
    print(ans)

Measured memory_bytes: 45680
#include<bits/stdc++.h>
using namespace std;
double PI=acos(-1.0);
double a,b,x,v;
double eps=1e-9;
bool check(double ang){
    double v1;
    if(ang<atan(b/a)){
        v1=0.5*a*a*tan(ang)*a;
    }
    else{
        v1=(a*2-b/tan(ang))*b*0.5*a;
    }
    if(v1+x<=v)return 1;
    else return 0;
}
int main(){
    scanf("%lf%lf%lf",&a,&b,&x);
    v=a*a*b;
    double l=0,r=PI/2,mid;
    while(abs(l-r)>eps){
        mid=(l+r)/2;
        if(check(mid)){
            l=mid;
        }
        else{
            r=mid;
        }
    }
    //cout<<r<<endl;
    printf("%.10f\n",l*180/PI);
    return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD = 1e9+7;
const int INF = 2e9;

int main(){
    vector<int> sc(3);
    for(int i=0; i<3; i++){
        cin >> sc[i];
    }
    sort(sc.begin(), sc.end());
    cout << sc[0]+sc[1] << endl;
}

Measured memory_bytes: 256
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush,heapify
import sys,bisect,math,itertools
sys.setrecursionlimit(10**8)
mod = 10**9+7
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpln(n): return list(int(sys.stdin.readline()) for i in range(n))

x = inp()
for i in range(x,0,-1):
    for b in range(1,33):
        for p in range(2,11):
            if i == b**p:
                print(i)
                quit()

Measured memory_bytes: 38768
#include <cstdio>
#include <cstring>
#include <algorithm>
#define fo(i,a,b) for(int i=a;i<=b;i++)
#define fd(i,a,b) for(int i=a;i>=b;i--)
#define rep(i,a) for(int i=last[a];i;i=ne[i])
using namespace std;

int read() {
	char ch;
	for(ch=getchar();ch<'0'||ch>'9';ch=getchar());
	int x=ch-'0';
	for(ch=getchar();ch>='0'&&ch<='9';ch=getchar()) x=x*10+ch-'0';
	return x;
}

const int N=1e6+5,inf=1e9;

struct pty{int x,y,id;}a[N],b[N];
bool cmpx(pty a,pty b) {return a.x<b.x;}
bool cmpy(pty a,pty b) {return a.y<b.y;}

int last[N],now[N],ne[N],t[N],l,cnt;
void add(int x,int y) {
	t[++l]=y;ne[l]=last[x];last[x]=l;
}

int n,tot;
void init() {
	n=read();tot=2*n;
	fo(i,1,n) {
		a[i].x=read();a[i].y=read();a[i].id=i;
		b[i].x=a[i].x;b[i].y=a[i].y;b[i].id=i;
	}
}

int rootx,rooty,le[N],ri[N];
void build(int &v,int l,int r,int flag) {
	if (l==r) {
		v=(flag==1)?(a[l].id+n):b[l].id;
		return;
	}
	v=++tot;
	int mid=l+r>>1;
	build(le[v],l,mid,flag);
	build(ri[v],mid+1,r,flag);
	add(v,le[v]);add(v,ri[v]);
}

void link(int v,int l,int r,int x,int y,int z) {
	if (x>y) return;
	if (l==x&&r==y) {add(z,v);return;}
	int mid=l+r>>1;
	if (y<=mid) link(le[v],l,mid,x,y,z);
	else if (x>mid) link(ri[v],mid+1,r,x,y,z);
	else link(le[v],l,mid,x,mid,z),link(ri[v],mid+1,r,mid+1,y,z);
}

void prepare() {
	sort(a+1,a+n+1,cmpx);
	build(rootx,1,n,1);
	sort(b+1,b+n+1,cmpy);
	build(rooty,1,n,2);
	fo(i,1,tot) now[i]=last[i];cnt=l;
}

int dfn[N],low[N],stack[N],cl[N],tmp,top,id;
bool vis[N],in[N];
void tarjan(int x) {
	vis[x]=in[x]=1;dfn[x]=low[x]=++tmp;stack[++top]=x;
	rep(i,x)
		if (!vis[t[i]]) {
			tarjan(t[i]);
			low[x]=min(low[x],low[t[i]]);
		} else if (in[t[i]]) low[x]=min(low[x],dfn[t[i]]);
	if (low[x]==dfn[x]) {
		stack[top+1]=0;++id;
		for(;stack[top+1]!=x;top--) {
			in[stack[top]]=0;
			cl[stack[top]]=id;
		}
	}
}

bool check(int mid) {
	int lx,rx;
	fo(i,1,tot) last[i]=now[i];l=cnt;
	lx=1,rx=1;
	fo(i,1,n) {
		while (lx<i&&a[i].x-a[lx].x>=mid) lx++;
		while (rx<=n&&a[rx].x-a[i].x<mid) rx++;
		link(rootx,1,n,lx,i-1,a[i].id);
		link(rootx,1,n,i+1,rx-1,a[i].id);
	}
	// xuan x ban x
	lx=1,rx=1;
	fo(i,1,n) {
		while (lx<=n&&b[i].y-a[lx].x>=mid) lx++;
		while (rx<=n&&a[rx].x-b[i].y<mid) rx++;
		link(rootx,1,n,lx,rx-1,b[i].id+n);
	}
	// xuan y ban x
	lx=1,rx=1;
	fo(i,1,n) {
		while (lx<=n&&a[i].x-b[lx].y>=mid) lx++;
		while (rx<=n&&b[rx].y-a[i].x<mid) rx++;
		link(rooty,1,n,lx,rx-1,a[i].id);
	}
	// xuan x ban y
	lx=1,rx=1;
	fo(i,1,n) {
		while (lx<i&&b[i].y-b[lx].y>=mid) lx++;
		while (rx<=n&&b[rx].y-b[i].y<mid) rx++;
		link(rooty,1,n,lx,i-1,b[i].id+n);
		link(rooty,1,n,i+1,rx-1,b[i].id+n);
	}
	// xuan y ban y
	
	tmp=top=id=0;
	fo(i,1,tot) vis[i]=cl[i]=dfn[i]=low[i]=0;
	fo(i,1,tot) if (!vis[i]) tarjan(i);
	fo(i,1,n) if (cl[i]==cl[i+n]) return 0;
	return 1;
}

void solve() {
	int l=0,r=inf;
	while (l<r) {
		int mid=l+r>>1;
		if (check(mid)) l=mid+1;
		else r=mid;
	}
	printf("%d\n",l-1);
}

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

Measured memory_bytes: 29952
import java.util.Scanner;
 
public class Main {
 
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		//int sum = 0;
		System.out.println(n*800-(n/15)*200);
	}
 
}

Measured memory_bytes: 21204
#include <stdio.h>

int main(){
    int N,K,d[101],A[101][101],sunuke[101],itazura=0;

    for(auto i=0; i<=100; i++){
        sunuke[i] = 0;
    }

    scanf("%d %d", &N, &K);
    for(auto i=1; i<=K; i++){
        scanf("%d", &d[i]);

        for(auto j=1; j<=d[i]; j++){
            scanf("%d", &A[i][j]);

            sunuke[A[i][j]]++;
        }
    }

    for(auto i=1; i<=N; i++){
        if(sunuke[i] == 0){
            itazura++;
        }
    }

    printf("%d", itazura);
    // 入力データ確認
    // printf("\n%d %d\n", N, K);
    // for(auto i=1; i<=K; i++){
    //     printf("%d\n", d[i]);

    //     for(auto j=1; j<=d[i]; j++){
    //         printf("%d ", A[i][j]);
    //     }
    //     printf("\n");
    // }


}

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

using namespace std;

#define PB push_back
#define f first
#define s second
#define what_is(x) cerr << #x << " is " << x << endl;

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

const double PI = 3.141592653589793238642643383;
int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0);
    int a, b, h, m;
    cin >> a >> b >> h >> m;
    double ang = abs(h*30 + m / 2.0 - m*6) * PI / 180;
    //cout << abs(h*30 + m / 2.0 - m*6) << "\n";
    cout << setprecision(15) << sqrt(a*a + b*b - 2 * a * b * cos(ang));
    return 0;
}


Measured memory_bytes: 4088