akhauriyash/Code-Regression huggingface dataset:
void main() {
	auto N = readAs!ulong;
	
	// 75 = 3 * 5^2
	// (75), (3, 25), (5, 15), (3, 5, 5)
	// (74), (2, 24), (4, 14), (2, 4, 4)
	pl = generate_prime_list(100);
	ulong[ulong] arr;
	foreach(i;  1..N+1) {
			foreach(k; pl) {
			ulong p = 1;
			while(i % k^^p == 0) {
				arr[k]++;
				p++;
			}
		}
	}
	ulong res;
	ulong r(ulong m) {
		return arr.values.count!(i => i >= m - 1);
	}
	res += r(75);
	res += r(25) * (r(3) - 1);
	res += r(15) * (r(5) - 1);
	res += r(5) * (r(5) - 1) * (r(3) - 2) / 2;
	res.writeln;
}

ulong[] pl;

ulong[] generate_prime_list(T)(T N) if(isIntegral!T) {
	ulong[] prime_list = [2];
	bool not_prime = false;
	foreach(i; 3..N.to!ulong+1) {
		foreach(j; prime_list) {
			if(i % j == 0) {
				not_prime = true;
				break;
			}
		}
		if(!not_prime) prime_list ~= i;
		not_prime = false;
	}
	return prime_list;
}

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

import std.stdio;
import std.string;
import std.functional;
import std.algorithm;
import std.range;
import std.traits;
import std.math;
import std.container;
import std.bigint;
import std.numeric;
import std.conv;
import std.typecons;
import std.uni;
import std.ascii;
import std.bitmanip;
import core.bitop;

T readAs(T)() if (isBasicType!T) {
	return readln.chomp.to!T;
}
T readAs(T)() if (isArray!T) {
	return readln.split.to!T;
}

T[][] readMatrix(T)(uint height, uint width) if (!isSomeChar!T) {
	auto res = new T[][](height, width);
	foreach(i; 0..height) {
		res[i] = readAs!(T[]);
	}
	return res;
}

T[][] readMatrix(T)(uint height, uint width) if (isSomeChar!T) {
	auto res = new T[][](height, width);
	foreach(i; 0..height) {
		auto s = rs;
		foreach(j; 0..width) res[i][j] = s[j].to!T;
	}
	return res;
}

int ri() {
	return readAs!int;
}

double rd() {
	return readAs!double;
}

string rs() {
	return readln.chomp;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<string>
#include<cstring>
#include<vector>
#include<set>
#include<list>
#include<queue>
#include<cmath>
#include<functional>
#include<algorithm>
#define INF (1<<29)
#define EPS 1e-10
#define rep(i,n) for(int i=0;i<(n);i++)
using namespace std;


struct Edge{
	int to,cost,time,r;
	Edge(int b,int c,int h,int r):to(b),cost(c),time(h),r(r){}
};


int N,M,H,K;
int s,t;
vector<Edge> edge[100];


int dp[1<<8];



int minc[25][100];
int mincost(int pass){
	rep(i,25)rep(j,100)minc[i][j]=INF;
	minc[0][s]=0;
	rep(h,H){
		rep(i,N){
			rep(j,edge[i].size()){
				Edge &e=edge[i][j];
				if(H<h+e.time)continue;
				if(pass&1<<e.r)
					minc[h+e.time][e.to]
						=min(minc[h+e.time][e.to], minc[h][i]);
				else minc[h+e.time][e.to]
					=min(minc[h+e.time][e.to], minc[h][i]+e.cost);
			}
		}
	}
	int ans=INF;
	rep(h,H+1)ans=min(ans, minc[h][t]);
	return ans;
}



int main(){
	while(cin>>N>>M>>H>>K,N|M|H|K){
		rep(i,100)edge[i].clear();
		rep(i,M){
			int a,b,c,h,r;
			cin>>a>>b>>c>>h>>r;
			a--;b--;r--;
			edge[a].push_back(Edge(b,c,h,r));
			edge[b].push_back(Edge(a,c,h,r));
		}
		int p;
		int d[1<<8],ks[1<<8];
		cin>>s>>t>>p;
		s--;t--;
		rep(i,p){
			int L;
			cin>>L>>d[i];
			int mask=0;
			rep(j,L){
				int k;
				cin>>k;
				mask|=1<<k-1;
			}
			ks[i]=mask;
		}

		rep(i,1<<K)dp[i]=INF;
		dp[0]=0;
		rep(i,1<<K){
			if(dp[i]==INF)continue;
			rep(j,p){
				dp[i|ks[j]]=min(dp[i|ks[j]],dp[i]+d[j]);
			}
		}
		int ans=INF;
		rep(i,1<<K){
			if(dp[i]==INF)continue;
			ans=min(ans,dp[i]+mincost(i));
		}
		if(ans!=INF)cout<<ans<<endl;
		else cout<<-1<<endl;
	}
	return 0;
}

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

string S;

int expr(int& p);
int term(int& p);
int factor(int& p);
int number(int& p);

int expr(int& p) {
    int v1 = term(p); 
    while(S[p] == '+' || S[p] == '-') {
        char op = S[p];
        p++;
        int v2 = term(p); 
        if(op == '+') {
            v1 += v2;
        } else {
            v1 -= v2;
        }
    }
    return v1;
}

int term(int& p) {
    int v1 = factor(p);
    while(S[p] == '*' || S[p] == '/') {
        char op = S[p];
        p++;
        int v2 = factor(p);
        if(op == '*') {
            v1 *= v2;
        } else {
            v1 /= v2;
        }
    }
    return v1;
}

int factor(int& p) {
    if(isdigit(S[p])) {
        return number(p);
    }

    p++;
    int res = expr(p);
    p++;
    return res;
}

int number(int& p) {
    int res = 0;
    while(isdigit(S[p])) {
        res *= 10;
        res += S[p] - '0';
        ++p;
    }
    return res;
}


int main() {
    int n;
    cin >> n;
    for(int i=0; i<n; ++i) {
        cin >> S;
        int p = 0;
        cout << expr(p) << endl;
    }
}


Measured memory_bytes: 3156
import java.util.*;
public class Main{
	public static void main(String[] args){
    	Scanner sc = new Scanner(System.in);
      	int a = sc.nextInt();
      	int b = sc.nextInt();

      	if(a*b % 2 == 1){
        	System.out.println("Yes");
        }else{
        	System.out.println("No");
        }
    }
}

Measured memory_bytes: 35812
#include <cstdio>

int main()
{
    char S[4];
    scanf("%s", S);
    bool ans = false;
    if (S[0] == S[1]) {
        if (S[1] != S[2] && S[2] == S[3]) {
            ans = true;
        }

    } else if (S[0] == S[2] && S[1] == S[3]) {
        ans = true;
    } else if (S[0] == S[3] && S[1] == S[2]) {
        ans = true;
    }
    if (ans) {
        printf("Yes\n");
    } else {
        printf("No\n");
    }


    return 0;
}


Measured memory_bytes: 128
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <deque>
#include <complex>
#include <stack>
#include <queue>
#include <cstdio>
#include <cctype>
#include <cstring>
#include <ctime>
#include <iterator>
#include <bitset>
#include <numeric>
#include <list>
#include <iomanip>
#include <stack>
using namespace std;
#define ll int64_t
const long mod = 1e9 + 7;


const long LINF = 1e13;
const long LLINF = 1e18;
const long ALPHABET = 26;

template <class T>
void Swap(T& r, T& l) {
  T tmp = r;
  r = l;
  l = tmp;
}

template<typename T>
istream& operator >> (istream& is, vector<T>& vec) {
  for (T& x : vec) is >> x; //for(int i=0; i<vec.size(); i++) is >> x[i]; とかでもいい
  return is;
}


int main() {
  long n,m;
  char s;
  cin >> s;

  // vector<long> a(n);
  // vector<long> b(n);
  // cin >> b;




  // bool an = true;
  // long ans = 0;



  // cout << ans <<endl;
  // cout << (an?"yes":"no");

  if (s =='A'){
    cout << "T";
  }
  if (s =='T'){
    cout << "A";
  }
  if (s =='C'){
    cout << "G";
  }

  if (s =='G'){
    cout << "C";
  }



}




















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

char s[100][100];

int n;
long long count[50],count2[50];

int main(void){
    int i,j,l;
    scanf("%d",&n);

    for(i = 0;i < n;i++){
        scanf("%s",&s[i][0]);
    }

    for(i = 0;i < 'z' - 'a' + 1;i++)
        count[i] = 10000;
    for(i = 0;i < n;i++){
        l = strlen(&s[i][0]);
        for(j = 0;j < 50;j++)
            count2[j] = 0;
        for(j = 0;j < l;j++){
            count2[s[i][j] - 'a']++;
        }
        for(j = 0;j < 'z' - 'a' + 1;j++)
            if(count[j] > count2[j])
                count[j] = count2[j];
    }
    for(i = 0;i < 'z' - 'a' + 1;i++)
        for(j = 0;j < count[i];j++)
            printf("%c",i + 'a');
    printf("\n");
    return 0;
}

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

#define all(v) (v).begin(), (v).end()
#define sortv(v) sort(all(v))
#define uniqv(v) (v).erase(unique(all(v)), (v).end())
#define pb push_back
#define FI first
#define SE second
#define lb lower_bound
#define ub upper_bound
#define mp make_pair
#define test 1
#define TEST if(test)

using namespace std;

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

const int MOD = 1000000007; // 998244353
const int INF = 2e9;
const ll INFLL = 1e18;
const int MAX_N = 1;

string str;

int main(){
	cin>>str;
	if(str=="SUN"){
		cout<<7;
	}else if(str=="MON"){
		cout<<6;
	}else if(str=="TUE"){
		cout<<5;
	}else if(str=="WED"){
		cout<<4;
	}else if(str=="THU"){
		cout<<3;
	}else if(str=="FRI"){
		cout<<2;
	}else{
		cout<<1;
	}
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,N) for(int i=0;i<(N);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
using namespace std;
const long long MOD = 1e9 + 7;
const long long INF = 1e12;
const int inf = 1e9;
const int mod = 1e9+7;
typedef long long ll;
typedef pair<ll,int> P;
typedef set<int> S;
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; }
int main(){
    cout << fixed << setprecision(10);
    ll n;
    cin >> n;
    vector<ll> v(n);
    rep(i,n) cin >> v[i];
    ll ans = 0;
    sort(v.rbegin(),v.rend());
    ans += v[0];
    int i = 0;
    int cnt = 2;
    n--;
    while(--n){
        if(cnt %2 == 0) i++;
        ans += v[i];
        cnt++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 4848
import sys
import os

ii = lambda: int(sys.stdin.buffer.readline().rstrip())
il = lambda: list(map(int, sys.stdin.buffer.readline().split()))

iss = lambda: sys.stdin.buffer.readline().decode().rstrip()
isn = lambda n: [sys.stdin.buffer.readline().decode().rstrip() for _ in range(n)]


def main():
    if os.getenv("LOCAL"):
        sys.stdin = open("input.txt", "r")

    A, B, C, D = list(iss())
    print('Bad' if A == B or B == C or C == D else 'Good')


if __name__ == '__main__':
    main()


Measured memory_bytes: 3060
#include<map>
#include<vector>
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
typedef long long LL;
typedef pair<int, int> P;
typedef pair<int, P> E;
const LL MOD = 1000000007LL;
LL f(LL b, LL n)
{
	LL ret = 0;
	while (n > 0)
	{
		ret += n%b;
		n /= b;
	}
	return ret;
}
int main()
{
	LL n, s;
	cin >> n >> s;
	if (n == s)
	{
		cout << n + 1 << endl;
		return 0;
	}
	for (LL i = 2; i*i <= n; i++)
	{
		if (f(i, n) == s)
		{
			cout << i << endl;
			return 0;
		}
	}
	if (n < s)
	{
		cout << -1 << endl;
		return 0;
	}
	LL ans = 1LL << 60;
	for (LL i = 1; i*i <= n - s; i++)
	{
		if ((n - s) % i) continue;
		LL b = (n - s) / i + 1;
		if (f(b, n) == s) ans = min(ans, b);
	}
	if (ans == 1LL << 60)
	{
		cout << -1 << endl;
		return 0;
	}
	cout << ans << endl;
}

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

// Shrotening
#define fst first
#define snd second
#define pb push_back

// Loop
#define FOR(i,a,b) for(auto i=(a);i<(b);++i)
#define RFOR(i,a,b) for(auto i=(a);i>=(b);--i)

#define REP(i,a) for(long i=0;i<(a);++i)
#define RREP(i,a) for(long i=(a);i>=0;--i)

#define EACH(i,a) for(auto (i)=(a).begin(),_END=(a).end();i!=_END;++i)
#define REACH(i,a) for(auto (i)=(a).rbegin(),_END=(a).rend();i!=_END;++i)

//Algorithm
#define ALL(a) (a).begin(), a.end()
#define RALL(a) (a).rbegin(), a.rend()
#define EXIST(a,x) ((a).find(x)!=(a).end())
#define SORT(a) std::sort((a).begin(), (a).end())
#define UNIQUE(a) std::sort((a).begin(), a.end()), a.erase(std::unique((a).begin(), a.end()), a.end());
#define SUM(a) std::accumulate((a).begin(), (a).end(), 0);

//Setting
#define OPT std::cin.tie(0);std::ios::sync_with_stdio(false);

//debug message
bool debug = true;
#define MSG(s)   if(debug){std::cout << s << std::endl;}
#define DEBUG(x) if(debug){std::cout << "debug(" << #x << "): " << x << std::endl;}

//alias
typedef long long LL;
typedef std::vector<char> VC;
typedef std::vector<int>  VI;
typedef std::vector<long> VL;
typedef std::vector<long long> VLL;

typedef std::vector< VC > VC2;
typedef std::vector< VI > VI2;
typedef std::vector< VL > VL2;
typedef std::vector< VLL > VLL2;

typedef std::pair<int,int> PII;

int N;
int main() {
    std::cin >> N;
    std::cout << "ABC" << N << std::endl;
}

Measured memory_bytes: 256
N = int(input())

def ww(s, sn, ans,n):
    global N 
    if n == N:
        ans.append(s)
        return 0
    n += 1
    for i in range(sn+1):
        if i == sn:  
            ww(s+chr(ord("a")+i), sn+1, ans, n)
        else:
            ww(s+chr(ord("a")+i), sn, ans, n)
ans = []
ww("a", 1, ans, 1)

ans.sort()

for i in ans:
    print(i)

Measured memory_bytes: 12668
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,n1,n2=0,i=1,count=0;
    cin>>n;
    while(i<=n)
    {
        cin>>n1;
        if(n1%2==0)
        {
            n2++;
            if((n1%3==0) || (n1%5==0))
            {
                count++;
            }
        }
        i++;
    }
    if(n2==count)
    {
        cout<<"APPROVED"<<endl;
    }
    else
        cout<<"DENIED"<<endl;


}


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

#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;
}
int ctoi(char c) {
  if (c >= '0' && c <= '9') {
    return c - '0';
  }
  return 0;
}
ll factorial(ll n) {
  if (n == 1) {
    return 1;
  }
  ll ans = factorial(n-1);
  return ans*n;
}
ll gcd(ll a, ll b) {
  if (a < b) {
    ll tmp = a;
    a = b;
    b = tmp;
  }
  ll r = a%b;
  while(r != 0) {
    a = b;
    b = r;
    r = a%b;
  }
  return b;
}
ll lcm(ll a, ll b) {
  return (a/gcd(a, b))*b;
}

int main() {
    vector <ll> v(3);
    rep(i, 3) cin >> v.at(i);
    sort(v.begin(), v.end());
    rep(i, 3) {
        if (i < 2) {
            cout << v.at(i) << ' ';
        } else {
            cout << v.at(i) << endl;
        }
    }
}


Measured memory_bytes: 3116
def m(L,R):
 T=[]
 for l in L[::-1]:
  while R and R[-1]>l:T+=[R.pop()]
  T+=[l]
 return R+T[::-1]
def d(A):
 l=len(A);global c;c+=l
 s=l//2;return m(d(A[:s]),d(A[s:]))if l>1 else A
c=0
n=int(input())
print(*d(list(map(int,input().split()))))
print(c-n)


Measured memory_bytes: 61644
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <set>
#include <map>
#include <queue>
#include<limits.h>
#include<iomanip>
#define rep(i, n) for(int i = 0; i < n; i++)
#define rrep(i, n) for(int i = n-1; i >= 0; i--)
#define REP(i, m, n) for(int i = m; i < n; i++)
#define ALL(v) v.begin(),v.end()
#define RALL(v) v.rbegin(),v.rend()
#define lamsort(v,p) sort(v.begin(),v.end(),[](p a, p b){return a.num < b.num;});
#define check(v) rep(i,v.size()) cout << v[i] << " ";\
cout << endl
#define INF 1e8
typedef long long ll;
using namespace std;
//オーバーフローに気をつけろよおおおおおお
//確認忘れるなよおおおおおお

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int n; cin >> n;
    REP(i,1,10) {
        REP(j,1,10) {
            if(n==i*j) {
                cout << "Yes" << endl;
                return 0;
            }
        }
    }
    cout << "No" << endl;

    return 0;
}

Measured memory_bytes: 384
import java.util.*
fun main(args:Array<String>) {
    val (N,K) = readLine()!!.split(" ").map(String::toInt)

    val An = readLine()!!.split(" ").map(String::toInt)

    (Math.ceil((N-1).toDouble()/(K-1).toDouble()).toInt()).run(::println)
}

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

int main(int argc, char const *argv[]) {
    int n, k;
    cin >> n >> k;

    double ans = 0;
    for (int i = 1; i <= n; i++) {
        int point = i;
        double rate = (double)1/n;
        while (point < k) {
            point *= 2;
            rate *= (double)1/2;
        }
        ans += rate;
    }

    printf("%.20f\n", ans);
    return 0;
}


Measured memory_bytes: 3684
import numpy

x, y = map(int, input().split())
cost = 0
if x == y == 1:
    cost += 400000

if x == 1:
    cost += 300000
elif x == 2:
    cost += 200000
elif x == 3:
    cost += 100000

if y == 1:
    cost += 300000
elif y == 2:
    cost += 200000
elif y == 3:
    cost += 100000
print(cost)


Measured memory_bytes: 22044
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>

#define int long long

#define override_rep(i, l, r, mes, ...) mes
#define rep1(i, n) for (int i = 0; i < n; i++)
#define rep2(i, l, r) for (int i = l; i < r; i++)
#define rep(...) override_rep(__VA_ARGS__, rep2, rep1)(__VA_ARGS__)

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

using bint = boost::multiprecision::cpp_int;

constexpr int MOD = 1e9 + 7;

template<typename T, typename U>
istream& operator>>(istream& in, pair<T, U>& p) {
    in >> p.first >> p.second;
    return in;
}

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

// https://twitter.com/vane11ope ←フォローしましょう
// (ノ)>◡<(ヾ)ﾓﾁﾓﾁ
signed main(signed argc, char* argv[]) {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);

    int h,w,m;
    cin>>h>>w>>m;
    vector<int> bh(m),bw(m);
    rep(i,m)cin>>bh[i]>>bw[i];
    vector<int> ch(h,0),cw(w,0);
    rep(i,m){
        ch[bh[i]-1]++;
        cw[bw[i]-1]++;
    }
    int hmx=0,hcnt=0,wmx=0,wcnt=0;
    rep(i,h){
        if(hmx<ch[i]){
            hmx=ch[i];
            hcnt=0;
        }
        if(hmx==ch[i]){
            hcnt++;
        }
    }
    rep(i,w){
        if(wmx<cw[i]){
            wmx=cw[i];
            wcnt=0;
        }
        if(wmx==cw[i]){
            wcnt++;
        }
    }
    int cnt=hcnt*wcnt;
    rep(i,m){
        if(ch[bh[i]-1]==hmx&&cw[bw[i]-1]==wmx){
            cnt--;
        }
    }
    if(cnt==0)cout<<hmx+wmx-1<<endl;
    else cout<<hmx+wmx<<endl;
}


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




int32_t main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	string s;
	cin >> s;
	int N = 0;
	for (int i = 0 ; i < s.size() ; i++)
	{
		N += (s[i] - '0');
	}
	if (N % 9 == 0) cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
}

Measured memory_bytes: 3756
import bisect


N = int(input())
str_l = input()
num = 0
L = []
for v in str_l.split(' '):
    L.append(int(v))

L.sort()
for i in range(N - 1):
    a = L[i]
    for j in range(i, N - 2):
        b = L[j + 1]
        index = bisect.bisect_left(L[j + 2:], a + b)
        num += index
        # for k in range(0, index):
        #     c = (L[j + 2:])[k]
        #     if b + c > a and a + c > b:
        #         num += 1

print(num)

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

#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 

#define ll long long
#define db double
#define el "\n"
#define ld long double
#define rep(i,n) for(int i=0;i<n;i++)
#define rev(i,n) for(int i=n;i>=0;i--)
#define rep_a(i,a,n) for(int i=a;i<n;i++)
#define tr(ds, it) for(auto it=ds.begin(); it!=ds.end(); it++)
#define rtr(ds, it) for(auto it=ds.rbegin(); it!=ds.rend(); it--)
#define all(ds) ds.begin(), ds.end()
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
typedef priority_queue <int> pq;
typedef vector< long long > vi;
typedef pair<long long, long long> ii;
#define o_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update> 
#define graph vector<vi>

const ll mod = 1000000007;
ll po(ll x, ll n ){ 
    ll ans=1;
     while(n>0){
         if(n&1) ans=(ans*x)%mod;
         x=(x*x)%mod;
         n/=2;
     }
     return ans;
}



int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
   
    int T=1;
    //cin >> T;
    while(T--){
        ll n,m,x;
        cin>>n>>m;
        ll s=0;
        rep(i,m){
            cin>>x;
            s+=x;
        }
        if(s>n) cout<<-1<<el;
        else cout<<n-s<<el;
    }

    return 0;
}

Measured memory_bytes: 3656
import java.util.*;
public class Main{
	public static void main(String[] args){
    	Scanner sc = new Scanner(System.in);
      	int a = sc.nextInt();
		int b = sc.nextInt();
      	if(a%2 != b%2) System.out.println("IMPOSSIBLE");
		else System.out.println((a+b)/2);
    }
}

Measured memory_bytes: 35456
#include<iostream>
#include<vector>
#include<queue>
#include<stack>
#include<map>
#include<string>
#include<algorithm>
#include<utility>
#include<math.h>
#include<cstdlib>
#define rep(i, n) for(int i=0;i<n;i++)
#define repb(i, a, b) for(int i=a;i<b;i++)

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

const int INF = 1<<30;

int sf_factors[] = {0, 2, 4, 14, 24, 74};
int n_prime;
vector<int> prime_cnt;

int calc(int pos, int num){
  if(pos==n_prime){
    return num==75;
  }else{
    int ret=0;
    for(int i=0;i<6;i++){
      if(prime_cnt[pos]<sf_factors[i])break;
      int new_num = num*(1+sf_factors[i]);
      if(75%new_num==0)ret += calc(pos+1, new_num);
    }
    return ret;
  }
}

int main(){
  int n;cin>>n;
  vector<bool> prime(51, true);
  for(int i=2;i<=int(sqrt(50));i++){
  	for(int j=2*i;j<=50;j+=i){
      prime[j]=false;
    }
  }
  vector<int> prime_num;
  for(int i=2;i<51;i++){
  	if(prime[i])prime_num.push_back(i);
  }
  n_prime=(int)prime_num.size();
  prime_cnt.resize(n_prime);
  for(int i=1;i<=n;i++){
    int t=i;
  	for(int j=0;j<n_prime;j++){
      int cnt=0;
      while(t%prime_num[j]==0){t/=prime_num[j];cnt++;}
      prime_cnt[j]+=cnt;
    }
  }
  cout<<calc(0, 1)<<endl;
}

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

using namespace std;

typedef long long LL;
typedef pair<int , int> P2;
typedef pair<pair<int , int> , int> P3;
typedef pair<pair<int , int> , pair<int , int> > P4;
#define PB(a) push_back(a)
#define MP(a , b) make_pair((a) , (b))
#define M3P(a , b , c) make_pair(make_pair((a) , (b)) , (c))
#define M4P(a , b , c , d) make_pair(make_pair((a) , (b)) , make_pair((c) , (d)))
#define repp(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)

const int MC = (1<<18) + 3;
int N;
int A[MC];
int ans[MC][2];

int main(){
	cin >> N;
	repp(i,0,1<<N){
		cin >> A[i];
		ans[i][0] = i;
		ans[i][1] = (1<<N);
	}
	int m = 0;
	repp(i,0,(1<<N)-1){
		repp(k,0,N) if(!(i&(1<<k))){
			int j = i^(1<<k);
			if(A[ans[i][0]] > A[ans[j][0]]){
				ans[j][1] = ans[j][0];
				ans[j][0] = ans[i][0];
				if(A[ans[i][1]] > A[ans[j][1]]){
					ans[j][1] = ans[i][1];
				}
			} else if(ans[i][0] != ans[j][0] && A[ans[i][0]] > A[ans[j][1]]){
				ans[j][1] = ans[i][0];
			}
		}
		m = max(A[ans[i+1][0]] + A[ans[i+1][1]],m);
		cout << m <<endl;
	}
	return 0;
}


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

//#define int long long
typedef long long ll;

typedef unsigned long long ul;
typedef unsigned int ui;
const ll mod = 1000000007;
const ll INF = mod * mod;
const int INF_N = 1e+9;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
#define all(v) (v).begin(),(v).end()
typedef pair<ll, ll> LP;
typedef long double ld;
typedef pair<ld, ld> LDP;
const ld eps = 1e-12;
const ld pi = acos(-1.0);
//typedef vector<vector<ll>> mat;
typedef vector<int> vec;

//繰り返し二乗法
ll mod_pow(ll a, ll n, ll m) {
	ll res = 1;
	while (n) {
		if (n & 1)res = res * a%m;
		a = a * a%m; n >>= 1;
	}
	return res;
}

struct modint {
	ll n;
	modint() :n(0) { ; }
	modint(ll m) :n(m) {
		if (n >= mod)n %= mod;
		else if (n < 0)n = (n%mod + mod) % mod;
	}
	operator int() { return n; }
};
bool operator==(modint a, modint b) { return a.n == b.n; }
modint operator+=(modint &a, modint b) { a.n += b.n; if (a.n >= mod)a.n -= mod; return a; }
modint operator-=(modint &a, modint b) { a.n -= b.n; if (a.n < 0)a.n += mod; return a; }
modint operator*=(modint &a, modint b) { a.n = ((ll)a.n*b.n) % mod; return a; }
modint operator+(modint a, modint b) { return a += b; }
modint operator-(modint a, modint b) { return a -= b; }
modint operator*(modint a, modint b) { return a *= b; }
modint operator^(modint a, int n) {
	if (n == 0)return modint(1);
	modint res = (a*a) ^ (n / 2);
	if (n % 2)res = res * a;
	return res;
}

//逆元(Eucledean algorithm)
ll inv(ll a, ll p) {
	return (a == 1 ? 1 : (1 - p * inv(p%a, a)) / a + p);
}
modint operator/(modint a, modint b) { return a * modint(inv(b, mod)); }

const int max_n = 1 << 18;
modint fact[max_n], factinv[max_n];
void init_f() {
	fact[0] = modint(1);
	for (int i = 0; i < max_n - 1; i++) {
		fact[i + 1] = fact[i] * modint(i + 1);
	}
	factinv[max_n - 1] = modint(1) / fact[max_n - 1];
	for (int i = max_n - 2; i >= 0; i--) {
		factinv[i] = factinv[i + 1] * modint(i + 1);
	}
}
modint comb(int a, int b) {
	if (a < 0 || b < 0 || a < b)return 0;
	return fact[a] * factinv[b] * factinv[a - b];
}
using mP = pair<modint, modint>;

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




void solve() {
    int N; cin >> N;
    vector<ll> a(N);
    set<int> st;
    rep(i, N){
        cin >> a[i];
        st.insert(a[i]);
    }

    auto it = st.begin();
    ll res = 0;
    sort(all(a));
    rep(i, st.size()){
        ll tmp = upper_bound(all(a), *it) - lower_bound(all(a), *it);
        if(tmp < *it) res += tmp;
        if(tmp > *it) res += tmp - *it;
        it++;
    }

    cout << res << endl;
}

signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  //cout << fixed << setprecision(10);
  //init_f();
  //init();
  //int t; cin >> t; rep(i, t)solve();
  solve();
//   stop
    return 0;
}


Measured memory_bytes: 9600
N, M = map(int, raw_input().split())
D = []
for i in range(N):
  D.append([1000000]*N)
  D[i][i] = 0
A = [0]*M
B = [0]*M
C = [0]*M
for i in range(M):
  a, b, C[i] = map(int, raw_input().split())
  A[i] = a-1
  B[i] = b-1
  D[A[i]][B[i]] = C[i]
  D[B[i]][A[i]] = C[i]
for k in range(N):
  for i in range(N):
    for j in range(N):
      D[i][j] = min(D[i][j], D[i][k]+D[k][j])
r = 0
for i in range(M):
  if D[A[i]][B[i]] < C[i]:
    r += 1
print r

Measured memory_bytes: 2936
#■標準入力ショートカット


def get_next_int():
    return int(float(input()))


def get_next_ints(delim=" "):
    return tuple([int(float(x)) for x in input().split(delim)])


def get_next_str():
    return input()


def get_next_strs(delim=" "):
    return tuple(input().split(delim))


def get_next_by_types(*value_types, delim=" "):
    return tuple([t(x) for t, x in zip(value_types, input().split(delim))])


def isMine(x, y, field):
    return field[y][x] == '#'


def count(H, W, x, y, field):
    diff = [-1, 0, 1]
    count = 0
    for d in diff:
        if x + d >= 0 and x + d < W:
            for d2 in diff:
                if y + d2 >= 0 and y + d2 < H:
                    count += 1 if isMine(x + d, y + d2, field) else 0
    return count


def solve():
    H, W = get_next_ints()
    field = []
    for i in range(H):
        field.append(list(get_next_str()))
    for y, line in enumerate(field):
        for x, cell in enumerate(line):
            if cell == '.':
                field[y][x] = str(count(H, W, x, y, field))
    for line in field:
        print(''.join(line))

solve()

Measured memory_bytes: 3188
import math
n, k = map(int, input().split())
prob = 0
for i in range(1, n + 1):
    if i <= k - 1:
        t = math.ceil(math.log2(k / i))
        prob += 0.5 ** t
    else:
        prob += 1
prob *= 1/ n
print(prob)

Measured memory_bytes: 3060
/*input

*/

#include <algorithm>
#include <iostream>
#include <string.h>
#include <stdlib.h>
#include <iomanip>
#include <utility>
#include <vector>
#include <math.h>
#include <queue>
#include <stack>
#include <map>
#include <set>

using namespace std;

#define pb                push_back
#define pp                pop_back
#define nl                cout << "\n"
#define MIN(con)          (*min_element(ALL(con)))
#define MAX(con)          (*max_element(ALL(con)))
#define NX(cont)          next_permutation(ALL(cont))
#define PX(cont)          prev_permutation(ALL(cont))
#define prec(n)           cout << fixed << setprecision(n)
#define PI                3.14159265358979323846264338327951
#define all(c)            c.begin(),c.end()
#define rep(i,a,b)        for(ll i=a;i<b;i++)
#define sp                cout << " "
#define mod               1000000007    //9
#define ifalse            ios_base::sync_with_stdio(false),cin.tie(NULL)

using ll = long long;
using ld = long double;
 
template < typename T > T GCD(T a, T b)            { ll t; while(a) { t = a; a = b % a; b = t; } return b; }
template < typename T > T LCM(T a, T b)            { return (a * b) / GCD(a, b); }
template < typename T > string toString(T a)       { return to_string(a); }  // Convert int to string
template < typename T > void toInt(string s, T &x) { stringstream str(s); str >> x;}  // Convert string to int

ll add(ll x, ll y) { x += y; if(x >= mod) x -= mod; return x; }
ll sub(ll x, ll y) { x -= y; if(x < 0) x += mod; return x; }
ll mul(ll x, ll y) { return ((x % mod) * (y % mod)) % mod; }

ll powr(ll a, ll b) {
    ll x = 1LL;
    while(b) {
        if(b & 1) x = mul(x, a);
        a = mul(a, a);
        b >>= 1;
    }
    return x;
}

ll inv(ll a) { return powr(a, mod - 2); }
const int inv2 = (mod + 1) >> 1;
const ll INF =  1e18;
const int inf = 1e9;

bool check(ll n)
{
    if(n == 1) return 0;
    if(n == 2 or n == 3) return 1;
    if(n % 2 == 0 or n % 3 == 0) return 0;
    for(ll i = 5; i * i <= n; i += 6) if(n % i == 0 or n % (i + 2) == 0) return 0;
    return 1;
}

/*********************************************START**************************************************************/

int main()
{
    ifalse;
    int n;
    cin >> n;
    vector < pair < ll, pair < ll, ll > > > v;
    rep(i, 0, n) {
    	ll x, y;
    	cin >> x >> y;
    	v.pb({x + y, {x, y}});
    }
    sort(all(v));
    reverse(all(v));
    ll ans = 0;
    for(int i = 0; i < n; i ++) {
    	if(i % 2 == 0) ans += v[i].second.first;
    	else ans -= v[i].second.second;
    }
    cout << ans;
    return 0;
}

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

#include<vector>

using namespace std;

//vector<int>is;

int main(){

    int n,k;

    cin>>n>>k;

     bool arr[n];

   memset(arr,0,sizeof(arr));

   //fill(arr.begin(),arr.end(),0);

    for(int i=0;i<k;i++){

    	int d;    	cin>>d;

    	while(d--){

    		int x;

    		cin>>x;

    		

    	   arr[x-1]=1;

    	}

    }

    int cnt =0;

    for(int i=0;i<n;i++){

        if(!arr[i])cnt++;

    }

    cout<<cnt;

}

Measured memory_bytes: 3644
package main

import (
	"fmt"
	"math"
)

func max(a, b int) int {
	if a >= b {
		return a
	}
	return b
}
func cntdigits(a int64) int {
	cnt := 1
	for {
		a /= 10
		if a > 0 {
			cnt++
		} else {
			break
		}
	}
	return cnt
}

func f(a, b int64) int {
	return max(cntdigits(a), cntdigits(b))
}

func main() {
	var A, B, N int64
	fmt.Scan(&N)
	min := math.MaxInt64
	for A = 1; A*A <= N; A++ {
		if N%A == 0 {
			B = N / A
		}
		cur := f(A, B)
		if min > cur {
			min = cur
		}
	}
	fmt.Println(min)
}


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

using namespace std;

#define LOG(...) fprintf(stderr, __VA_ARGS__)
//#define LOG(...)
#define FOR(i, a, b) for(int i = (int)(a); i < (int)(b); ++i)
#define REP(i, n) for(int i = 0; i < (int)(n); ++i)
#define RREP(i, n) for(int i = (int)(n - 1); i >= 0; --i)
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define EXIST(s, e) ((s).find(e) != (s).end())
#define SORT(c) sort(ALL(c))
#define RSORT(c) sort(RALL(c))
#define SQ(n) (n) * (n)

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<pii> vpi;
typedef vector<pll> vpl;
typedef vector<ll> vll;
typedef vector<vb> vvb;
typedef vector<vi> vvi;
typedef vector<vc> vvc;
typedef vector<vll> vvll;

int main() {
  int n;
  while(cin >> n, n) {
    bitset<128> know[128];
    bitset<128> leak;
    REP(i, n){
      int m;
      cin >> m;
      REP(j, m){
        int p;
        cin >> p;
        know[i][--p] = 1;
      }
    }
    int k;
    cin >> k;
    REP(i, k) {
      int l;
      cin >> l;
      leak[--l] = true;
    }

    int res = -1;
    REP(i, n){
      if ((know[i] & leak) == leak) {
        if (res != -1) {
          res = -1;
          break;
        }
        res = i + 1;
      }
    }
    cout << res << endl;
  }
}

Measured memory_bytes: 3072
// God put a smile upon your face <3

#include <bits/stdc++.h>

#define slld(longvalue) scanf("%lld", &longvalue)

#define ll long long
#define ull unsigned long long
#define pll pair < long long, long long >

#define fastio ios_base:: sync_with_stdio(false); cin.tie(0); cout.tie(0)

#define pb push_back

#define bug printf("BUG\n")

#define mxlld LLONG_MAX
#define mnlld -LLONG_MAX

#define mxd 2e8
#define mnd -2e8

#define pi 3.14159265359

using namespace std;

bool check(ll n, ll pos)
{
    return n & (1LL << pos);
}

ll Set(ll n, ll pos)
{
    return n = n | (1LL << pos);
}

ll dp[3003][3003][4];
ll val[3003][3003];
ll r, c;

ll solve(ll rr, ll cc, ll took)
{
    ll &ret = dp[rr][cc][took];

    if(ret != -1) return ret;

    if(rr > r || cc > c) return ret = 0;

    if(val[rr][cc] == -1)
    {
		return ret = max(solve(rr + 1, cc, 0), solve(rr, cc + 1, took));

    }

    ret = 0;

    if(took != 3)
    {
        ret = max(ret, solve(rr, cc + 1, took + 1) + val[rr][cc]);
    }

    ret = max(ret, solve(rr, cc + 1, took));


    ret = max(ret, solve(rr + 1, cc, 0) + (took == 3 ? 0 : val[rr][cc]));


//	cout << rr << " " << cc << " " << took << " = " << ret << endl;

    return ret;
}

int main()
{
    ll i, j, k, l, m, n, o, q;
    ll testcase;
    ll input, flag, tag, ans;

//    freopen("input.txt", "r", stdin);

//    freopen("output.txt", "w", stdout);

    while(cin >> r >> c >> n)
    {
        memset(dp,-1,sizeof dp);
        memset(val,-1,sizeof val);

        for(ll i = 1; i <= n; i++)
        {
            ll x, y;

            cin >> x >> y >> val[x][y];
        }

        ans = solve(1,1,0);

        cout << ans << "\n";
    }


}





Measured memory_bytes: 356360
#include <cstdio>
#include <cmath>
#include <cstring>
#include <string>
#include <cstdlib>
#include <climits>
#include <ctype.h>
#include <vector>
#include <queue>
#include <deque>
#include <set>
#include <stack>
#include <map>
#include <iostream>
#include <algorithm>
using namespace std;
typedef long long LL;
const int INF=0x3f3f3f3f;
const LL mod=1e9+7;
const int MAXN=1e6+5;
const int MAXM=1e6+5;
int main()
{
    int x,a,b;
    cin>>x>>a>>b;
    if(abs(x-a)>=abs(x-b))
        printf("B\n");
    else printf("A\n");


    return 0;
}


Measured memory_bytes: 256
package main

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

var sc = bufio.NewScanner(os.Stdin)

func main() {
	scanInit()
	w := map[string]int{}
	n := nextInt()

	for i := 0; i < n; i++ {
		w[nextStr()]++
	}
	m := nextInt()

	for i := 0; i < m; i++ {
		w[nextStr()]--
	}

	ans := 0
	for _, v := range w {
		ans = max(ans, v)
	}

	fmt.Println(ans)

}
func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

// ---- readfunc
func scanInit() {
	const cap = 200 * 1024 // Default=64
	var buf = make([]byte, cap)
	sc.Buffer(buf, cap)
	sc.Split(bufio.ScanWords)
	return
}
func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}
func nextStr() string {
	sc.Scan()
	return sc.Text()
}


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

int main(){
    long long L,R;cin>>L>>R;
    if(R-L>3000)cout<<0<<endl;
    else{
        long long res=2018;
        for(long long i=L;i<R;i++){
        for(long long j=i+1;j<=R;j++){
        res=min(res,(i*j)%2019);}
        }
        cout<<res<<endl;
    }
}

Measured memory_bytes: 256
import java.io.PrintWriter;
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		PrintWriter pw = new PrintWriter(System.out);
		int N = sc.nextInt();
		long[] x = new long[N];
		for(int i=0; i<N; i++)
			x[i] = (sc.nextLong()-1)<<10 | (i+1);

		int[] ans = solve(N, x);
		
		if(ans==null) {
			pw.println("No");
		} else {
			pw.println("Yes");
			for(int i=0; i<N*N; i++)
				pw.print(ans[i] + (i==N*N-1 ? "\n" : " "));
		}
		sc.close();
		pw.close();
	}
	
	static int[] solve(int N, long[] x) {
		Arrays.sort(x);
		
		int[] ans = new int[N*N];
		int p = 0;
		for(int i=0; i<N; i++) {
			int idx = (int)(x[i]&((1<<10)-1));
			int pos = (int)(x[i]>>10);
			if(ans[pos]!=0)
				return null;
			ans[pos] = idx;
			for(int j=0; j<idx-1; j++) {
				while(ans[p]!=0)
					p++;
				if(p>pos)
					return null;
				ans[p] = idx;
			}
		}
		
		p = N*N-1;
		for(int i=N-1; i>=0; i--) {
			int idx = (int)(x[i]&((1<<10)-1));
			int pos = (int)(x[i]>>10);
			for(int j=0; j<N-idx; j++) {
				while(ans[p]!=0)
					p--;
				if(p<pos)
					return null;
				ans[p] = idx;
			}
		}
		
		return ans;
	}
}


Measured memory_bytes: 30700
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef deque<int> di;
typedef pair<int,int> pi;
#define pb push_back
#define mp make_pair
#define mh make_heap
#define pf push_front
#define IOS ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define INF 1000000000
#define FOR(i,a,b) for(ll i=a;i<b;i++)


int main()
{
    //freopen("contest.txt","r",stdin);
    //freopen("contest.txt","w",stdout);
    IOS
    int n;
    double d;
    cin>>n>>d;
    double a,b;
    vector<pair<double,double> > vec;
    FOR(i,0,n){
    cin>>a>>b;
    vec.push_back(make_pair(a,b));
    }
    int count_=0;
    FOR(i,0,n)
    {
        if(sqrt((vec[i].first*vec[i].first)+(vec[i].second*vec[i].second))<=d)
            count_++;
    }

    cout<<count_<<endl;


    return 0;
}


Measured memory_bytes: 7520
#include <iostream>
#include <tuple>
#include <vector>
#include <algorithm>
#include <cmath>
#include <limits>
using namespace std;
#define REP(var, num) for(sll var = 0; var < num; var++)
typedef signed long long sll;
typedef unsigned long long ull;

sll dp[100000][3];
sll vs[100000][3];

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

    REP(i, n) {  cin >> vs[i][0] >> vs[i][1] >> vs[i][2]; }
    REP(i, n) {
        if (i == 0) {
            dp[0][0] = vs[0][0];
            dp[0][1] = vs[0][1];
            dp[0][2] = vs[0][2];
        } else {
            REP(j, 3) {
                dp[i][j] = numeric_limits<sll>::min();
                REP(k, 3) {
                    if (j == k)
                        continue;

                    dp[i][j] = max(dp[i][j], dp[i - 1][k] + vs[i][j]);
                }
            }
        }
    }

    sll r = 0;
    REP(i, 3) {
        r = max(r, dp[n - 1][i]);
    }
    cout <<r << endl;
    return 0;
}

Measured memory_bytes: 4992
#include <cstdio>
#include <cstdint>
#include <vector>
#include <algorithm>
#include <string>
#include <utility>
#include <tuple>
#include <queue>

template <class Tp>
std::vector<Tp> make_vector(size_t n, const Tp& x) {
  return std::vector<Tp>(n, x);
}

template <class... Ts>
auto make_vector(size_t n, size_t m, const Ts&... x) {
  return std::vector<decltype(make_vector(m, x...))>(n, make_vector(m, x...));
}

constexpr size_t m1 = -1;
constexpr size_t di[] = {m1, 0, 1, 0};
constexpr size_t dj[] = {0, m1, 0, 1};

int testcase_ends() {
  size_t h, w;
  scanf("%zu %zu", &w, &h);
  if (h == 0 && w == 0) return 1;

  std::vector<std::string> L(h+2), R(h+2);
  L[0] = L[h+1] = R[0] = R[h+1] = std::string(w+2, '#');
  size_t lsi = -1;
  size_t lsj = -1;
  size_t rsi = -1;
  size_t rsj = -1;
  for (size_t i = 1; i <= h; ++i) {
    char buf[64];
    scanf("%s", buf);
    L[i] = "#";
    L[i] += buf;
    L[i] += '#';
    for (size_t j = 1; j <= w; ++j) {
      if (L[i][j] == 'L') {
        lsi = i;
        lsj = j;
      }
    }

    scanf("%s", buf);
    R[i] = "#";
    R[i] += buf;
    R[i] += '#';
    std::reverse(R[i].begin(), R[i].end());
    for (size_t j = 1; j <= w; ++j) {
      if (R[i][j] == 'R') {
        rsi = i;
        rsj = j;
      }
    }
  }
  h += 2;
  w += 2;

  auto dp = make_vector(h, w, h, w, false);
  dp[lsi][lsj][rsi][rsj] = true;
  using zahyo = std::pair<size_t, size_t>;
  std::queue<std::pair<zahyo, zahyo>> q;
  q.emplace(std::make_pair(lsi, lsj), std::make_pair(rsi, rsj));
  while (!q.empty()) {
    size_t li, lj, ri, rj;
    std::tie(li, lj) = q.front().first;
    std::tie(ri, rj) = q.front().second;
    q.pop();
    
    for (int k = 0; k < 4; ++k) {
      size_t lni = li + di[k];
      size_t lnj = lj + dj[k];
      size_t rni = ri + di[k];
      size_t rnj = rj + dj[k];

      if (L[lni][lnj] == '#') {
        lni = li;
        lnj = lj;
      }
      if (R[rni][rnj] == '#') {
        rni = ri;
        rnj = rj;
      }

      if (L[lni][lnj] == '%' && R[rni][rnj] == '%')
        return puts("Yes"), 0;

      if (dp[lni][lnj][rni][rnj]) continue;
      if (L[lni][lnj] == '%') continue;
      if (R[rni][rnj] == '%') continue;

      dp[lni][lnj][rni][rnj] = true;
      q.emplace(std::make_pair(lni, lnj), std::make_pair(rni, rnj));
    }
  }

  puts("No");
  return 0;
}

int main() {
  while (!testcase_ends()) {}
}



Measured memory_bytes: 13700
#include <iostream>
#include <fstream>
#include <set>
#include <map>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <functional>
#include <algorithm>
#include <climits>
#include <cmath>
#include <iomanip>
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000


int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    string S; cin >> S;
    int N = S.length();
    int left = N - 1;
    int right = 0;
    rep(i, N) {
        if(S[N - i - 1] == 'A') left = N - i - 1;
        if(S[i] == 'Z') right = i;
    }
    cout << right - left + 1 << endl;

    return 0;
}


Measured memory_bytes: 3768
#include<bits/stdc++.h>
#define re register
#define int long long
using namespace std;
inline int read(){
	re int t=0;re char v=getchar();
	while(v<'0')v=getchar();
	while(v>='0')t=(t<<3)+(t<<1)+v-48,v=getchar();
	return t;
}
struct edge{
	int to,next,w;
}e[20000002];
int n,m,head[300002],ans,cnt,sum,s;
inline void add(re int x,re int y,re int w){
	e[++cnt].to=y;
	e[cnt].next=head[x];
	head[x]=cnt;
	e[cnt].w=w;
}
struct node{
    int pos,dis;
    bool operator <(const node x)const{
        return dis>x.dis;
    }
}h[300002];
priority_queue <node> q;
bool v[300002];
inline int pos(re int x,re int y){
	return x*(sum+1)+y;
}
inline void dis(re int s){for(re int i=1;i<=pos(n,sum);++i)h[i].dis=1e18,h[i].pos=i;
    h[s].dis=0;
    q.push(h[s]);
    while(!q.empty()){
        while((h[q.top().pos].dis<q.top().dis)){q.pop();if(q.empty())break;
        }
        if(q.empty())break;
        node tmp=q.top();
        q.pop();
        for(re int i=head[tmp.pos];i;i=e[i].next){
            if((tmp.dis+e[i].w)<h[e[i].to].dis){
                h[e[i].to].dis=tmp.dis+e[i].w;
                q.push(h[e[i].to]);
            }
        }
     
    }
}
signed main(){
	n=read();m=read();s=read();
	sum=5000;
	for(re int i=1,x,y,a,b;i<=m;++i){
		x=read();y=read();a=read();b=read();
		for(re int j=a;j<=sum;++j)add(pos(x,j),pos(y,j-a),b),add(pos(y,j),pos(x,j-a),b);
	}
	for(re int x,y,i=1;i<=n;++i){
		x=read();y=read();
		for(re int j=0;j<=sum;++j){
		add(pos(i,j),pos(i,min(j+x,sum)),y);if(j)add(pos(i,j),pos(i,j-1),0);}
	}
	dis(pos(1,min(s,sum)));
	for(re int i=2;i<=n;++i)printf("%lld\n",h[pos(i,0)].dis);
}


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

#define mp make_pair
#define pb push_back

using namespace std;

void dfs(vector<vector<int> > &adj, int v, vector<bool> &visited, vector<int> &arr, int val){
	visited[v] = true;
	arr[v] = val;
	for(int i = 0; i < adj[v].size(); i++){
		int u = adj[v][i];
		if(!visited[u]){
			dfs(adj, u, visited, arr, val);
		}
	}
}

int
main(void){
	int n, k , l; cin >> n >> k >> l;
	
	vector<vector<int> > adj1(n);
	vector<vector<int> > adj2(n);
	vector<bool> visited1(n + 1, false);
	vector<bool> visited2(n + 1, false);
	
	int a, b;
	for(int i = 0; i < k; i++){
		cin >> a >> b;
		--a; --b;
		adj1[a].pb(b);
		adj1[b].pb(a);
	}
	for(int i = 0; i < l; i++){
		cin >> a >> b;
		--a; --b;
		adj2[a].pb(b);
		adj2[b].pb(a);
	}
	
	vector<int> arr1(n, 0), arr2(n, 0);
	
	int c = 1;
	for(int i = 0; i < n; i++){
		if(!visited1[i]){
			dfs(adj1, i, visited1, arr1, c);	
			c++;
		}
	}
	
	c = 1;
	for(int i = 0; i < n; i++){
		if(!visited2[i]){
			dfs(adj2, i, visited2, arr2, c);	
			c++;
		}
	}
	
	map<pair<int, int> , int> mp1;
	for(int i = 0; i < n; i++){
		mp1[mp(arr1[i], arr2[i])]++;
	}
	
	for(int i = 0; i < n; i++){
		cout << mp1[mp(arr1[i], arr2[i])] << " ";
	}
}

Measured memory_bytes: 27904
import math
import collections
import fractions
import itertools
import functools
import operator
import bisect

N = int(input())

def solve():
    mod = 10**9+7
    ans = 10**N - (9**N)*2 + 8**N
    ans %= mod
    print(ans)
    return 0

if __name__ == "__main__":
    solve()


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

using namespace std;
typedef long long ll;
typedef vector<int> VI;
typedef pair<ll, ll> P;


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


int main(void)
{
	ll n, m;
	cin >> n >> m;
	vector<ll> as(n);
	rep(i, n) cin >> as[i];
	vector<P> ps(m);
	rep(i, m) {
		cin >> ps[i].second >> ps[i].first;
	}
	rep(i, n) {
		ps.emplace_back(as[i], 1);
	}
	sort(ps.begin(), ps.end() ,greater<P>());
	int t = 0;
	ll s = 0;
		for (auto e : ps) {
			auto p = min((n - t), e.second);
			t += p;
			s += (ll)p * e.first;
			if (t == n) break;
		}
		cout << s << endl;


	return 0;
}

Measured memory_bytes: 7684
#include<bits/stdc++.h>
using namespace std;
const int N=1e5+5;
char s[N];
int main()
{
    scanf("%s",s+1);
    int n=strlen(s+1);
    int ans=0;
    int l=1,r=n;
    while(l<=r)
    {
        if(s[l++]!=s[r--]) ans++;
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 256
def main():
    s = int(input())
    a =[s]

    for i in range(2, 1000000):
      x = int(a[-1] / 2) if a[-1] % 2 == 0 else int(a[-1] * 3 + 1)
      if x in a:
        print(i)
        break
      else:
        a.append(x)
    
    
if __name__ == '__main__':
    main()

Measured memory_bytes: 3060
import math
values=input().split()
a=float(values[0])
b=float(values[1])
C=int(values[2])
sinC=math.sin(math.radians(C))
cosC=math.cos(math.radians(C))
S=1/2*a*b*sinC
c=pow(pow(a,2)+pow(b,2)-2*a*b*cosC,0.5)
L=a+b+c
h=2*S/a
print(S,L,h)


Measured memory_bytes: 5720
// CardGame.cc
// 太郎と花子がカードゲームをする。
// 二人はそれぞれn枚のカードを持っており、nターンの勝負を行う。
// 各ターンではそれぞれ１枚ずつカードを出す。
// カードにはアルファベットからなる動物の名前が書かれており、
// 辞書順で大きいものがそのターンの勝者となる。
// 勝者には３ポイント、引き分けの場合にはそれぞれ１ポイントが加算される。
//
// 太郎と花子の手持ちのカードの情報を読み込み、
// ゲーム終了後のそれぞれの得点を出力するプログラムを作成せよ。
//
// 【制約】
// ・入力で与えられるｎが1000を超えることはない。
// ・与えられる文字列の長さは100以下であり、アルファベットの小文字のみを含む。
// 【入力】
// 一行目にカードの数ｎが与えられる。
// 続くn行に各ターンのカードの情報が与えられる。
// １つ目の文字列が太郎のカードに書かれている文字列、
// ２つ目の文字列が花子のカードに書かれている文字列である。
// 【出力】
// １つ目の数字が太郎の得点、２つ目の数字が花子の得点として１行に出力せよ。
// ２つの数字の間に１つの空白を出力せよ。
// 【例】
// 入力；
// 3
// cat dog
// fish fish
// lion tiger
// 出力；
// 1 7
#include<iostream>
#include<string>
using namespace std;

int main( void) {
  int n;
  string t_card, h_card;
  int t_score = 0, h_score = 0;

  cin >> n;
  for ( int i = 0; i < n; i++) {
    cin >> t_card >> h_card;
    if ( t_card > h_card) t_score += 3;
    else if ( t_card < h_card) h_score += 3;
    else { t_score += 1; h_score += 1;}
  }

  cout << t_score << " " << h_score << endl;

  return 0;
}



Measured memory_bytes: 3208
import scala.io.StdIn._
object Main extends App {
  val Array(l, r) = readLine.split(" ").map(_.toLong)
  println((for {
    i <- l to Math.min(r - 1, l + 2019)
    j <- l + 1 to Math.min(r, l + 2020)
  } yield i * j % 2019).min)
}

Measured memory_bytes: 209132
n, m = map(int, input().split())
mod = 10 ** 9 + 7

g = 0
if n == m:
    g = 2
if abs(n - m) == 1:
    g = 1

N = 10 ** 5 + 10
fact = [0] * (N)
fact[0] = 1
for i in range(1, N):
    fact[i] = (fact[i-1] * i) % mod

print(g * fact[n] * fact[m] % mod)

Measured memory_bytes: 6900