akhauriyash/Code-Regression huggingface dataset:
class Integer
  def divisor
    res = []
    1.upto((self**0.5)) do |i|
      if self % i == 0
        res.push i
        res.push self / i if i != self / i
      end
    end
    res.sort
  end
end

x = gets.to_s.to_i

r = x % 5

divisors = x.divisor
candidates = divisors.select{|t| r == t % 5}
# p 3 ** 5
candidates.each do |d|
  
  long = x / d - d ** 4
  
  next if long % 5 != 0
  # puts long
  # puts d
  # if long == 0
    
    if x == 0**5 - (-d)** 5
      puts "0 #{-d}"
      exit
    end
    
    if x == 0**5 - (d)** 5
      puts "0 #{d}"
      exit
    end
    
    b = d - d
    if x == d**5 - 0** 5
      puts "#{d} #{0}"
      exit
    end
    
    b = (-d) - (-d)
    if x == (-d)**5 - 0** 5
      puts "#{-d} #{0}"
      exit
    end
  # end
  
  middle = long / 5
  # p middle
  m_abs = middle.abs
  # puts m_abs
  # p [d, d**4, m_abs.divisor]
  m_abs.divisor.each do |a|
    
    b = a - d
    if x == a ** 5 - b ** 5
      puts "#{a} #{b}"
      exit
    end
    
    b = -a - d
    if x == (-a)**5 - b ** 5
      puts "#{-a} #{b}"
      exit
    end
  end
  # p [x, d, m_abs.divisor]
end

divisors.each do |d|
  
  d = -d 
  
  long = x / d - d ** 4
  # puts long
  next if long % 5 != 0
  # puts long
  # puts d
  # if long == 0
    
    if x == 0**5 - (-d)** 5
      puts "0 #{-d}"
      exit
    end
    
    if x == 0**5 - (d)** 5
      puts "0 #{d}"
      exit
    end
    
    b = d - d
    if x == d**5 - 0** 5
      puts "#{d} #{0}"
      exit
    end
    
    b = (-d) - (-d)
    if x == (-d)**5 - 0** 5
      puts "#{-d} #{0}"
      exit
    end
  # end
  
  middle = long / 5
  # p middle
  m_abs = middle.abs
  # puts m_abs
  # p m_abs.divisor
  # p [d, d**4, m_abs.divisor]
  m_abs.divisor.each do |a|
    
    b = a - d
    if x == a ** 5 - b ** 5
      puts "#{a} #{b}"
      exit
    end
    
    b = -a - d
    if x == (-a)**5 - b ** 5
      puts "#{-a} #{b}"
      exit
    end
  end
  # p [x, d, m_abs.divisor]
end

# [1,2,4,8,16].each do |i|
  
#   b = i - 3
#   if x == i**5 - b ** 5
#     puts [i, b]
#   end
# end

# [1,2,4,8,16].each do |i|
  
#   b = -i - 3
#   if x == i**5 - b ** 5
#     puts [-i, b]
#   end
# end
  

# p -5.divisor  

# 1.upto(100) do |i|
  
#   # r_t = i % 5
#   # candidates = i.divisor.select{|t| r_t == t % 5}
#   p i
#   loop do
#     a = rand(-10**9..10**9)
#     b = a - i
#     break if i  == a ** 5 - b ** 5
    
#     a = rand(i-10**9..i+10**9)
#     b = a - i
#     break if i == (a ** 5 - b ** 5)
    
#     a = rand(-i-10**9..-i+10**9)
#     b = a - i
#     break if i == (a ** 5 - b ** 5)
    
#     # a = 0
#     # b = a - 1
#     # p a ** 5 - b ** 5
#     # break if (i == (a ** 5 - b ** 5))
#   end
  
#   puts i
# end

# = divisors.select{|t| t % 5 }


# cnt = 0
# 1.upto(100) do |i|
  
#   next if i == (i ** 5) - ((i-1)**5)
#   next if i == ((i-1) ** 5) - ((-1)**5)
  
#   loop do
#     rand()
  
#   cnt += 1
# end
# puts cnt


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

int main()
{
   
   ll int n,k;

   cin>>n>>k;
   ll int a[n];
   for(ll int i=0;i<n;i++)
    cin>>a[i];
  ll int dp[n];
  for(int i=0;i<n;i++)
    dp[i]=INT_MAX;
  dp[0]=0;
  if(n>1)
  dp[1]=abs(a[1]-a[0]);
//cout<<dp[1]<<endl;
  
  for(int i=2;i<n;i++)
  {
for(int j=1;j<=k &&(i-j)>=0;j++)
{
dp[i]=min(dp[i],dp[i-j]+abs(a[i]-a[i-j]));

}



  }
cout<<dp[n-1]<<endl;

}

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

struct Rectangle
{
	int h;
	int w;
};

int main(){
	vector<Rectangle> nums;
	Rectangle rec;
	int i,j,k;
	while(cin>>rec.h>>rec.w){
		if(rec.h==0 && rec.w==0) break;
		nums.push_back(rec);
	}
	for(i=0; i<nums.size(); i++){
		for(j=0; j<nums[i].h; j++){
			for(k=0; k<nums[i].w; k++){
				if(j%2==0){
					if(k%2==0){
						cout<<"#";
					}else{
						cout<<".";
					}
				}else{
					if(k%2==1){
						cout<<"#";
					}else{
						cout<<".";
					}
				}
			}
			cout<<"\n";
		}
		cout<<"\n";
	}
	return 0;
}


Measured memory_bytes: 3076
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <ctime>
#include <cstring>
#include <functional>
#include <iostream>
#include <iomanip>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

#define fix(n)          cout<<fixed<<setprecision(n)
#define rep(i,n)        for (int i = 0; i < (n); ++i)
#define sort(a)         sort((a).begin(), (a).end())
#define uniq(a)         SORT(a);(a).erase(unique((a).begin(), (a).end()), (a).end())
#define reverse(a)      reverse((a).begin(), (a).end())
#define ctos(c)         string(1, (c))
#define out(d)          cout << (d)
#define outl(d)         std::cout<<(d)<<"\n"
#define Yes()           printf("Yes\n")
#define No()            printf("No\n")
#define YES()           printf("YES\n")
#define NO()            printf("NO\n")
#define ceil(x, y)      ((x + y - 1) / (y))
#define debug(x)        cerr << #x << ": " << (x) << '\n'
#define debug2(x, y)    cerr << #x << ": " << (x) << ", " << #y << ": " << (y) << '\n'
#define debug3(x, y, z) cerr << #x << ": " << (x) << ", " << #y << ": " << (y) << ", " << #z << ": " << (z) << '\n'
#define dbg(v)          for (size_t _ = 0; _ < v.size(); ++_){ cerr << #v << "[" << _ << "] : " << v[_] << '\n'; }

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

const ll MOD = 1000000007; // 10^9 + 7

void solve() {
  int n; cin >> n;
  int sum = 0;
  rep(i, n) {
    int l, r; cin >> l >> r;
    sum += r - l + 1;
  }
  outl(sum);
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  srand((unsigned)time(NULL));
  fix(12);

  solve();
}


Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <limits.h>
#include <map>
#include <numeric>
#include <queue>
#include <sstream>
#include <string>
#include <string.h>
#include <tuple>
#include <vector>

#define REP(i,x) for(int i{ 0 }; i < (int)(x); i++)
#define REPC(i,x) for(int i{ 0 }; i <= (int)(x); i++)
#define RREP(i,x) for(int i{ (int)(x) - 1 }; i >= 0 ;i--)
#define RREPC(i,x) for(int i{ (int)(x)}; i >= 0; i--)
#define REP1O(i,x) for(int i{ 1 }; i < (int)(x); i++)
#define REP1C(i,x) for(int i{ 1 }; i <= (int)(x); i++)
#define REPIT(i,x) for(auto i{(x).begin()}; i != (x).end(); i++) 

#define PB push_back
#define MP make_pair
#define SZ(x) ((int)(x).size())
#define ALL(x) (x).begin(),(x).end()

using namespace std;

typedef int64_t ll;
typedef double dbl;
typedef vector<bool> Vb;
typedef vector<char> Vc;
typedef vector<double> Vd;
typedef vector<int> Vi;
typedef vector<ll> Vl;
typedef vector<string> Vs;
typedef vector<vector<int>> VVi;
typedef vector<vector<ll>> VVl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;

template<class T> inline bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }
inline void swap(ll& a, ll& b) { a ^= b; b ^= a; a ^= b; }
inline void swap(int& a, int& b) { a ^= b; b ^= a; a ^= b; }
inline void YES() { cout << "YES" << endl; } inline void Yes() { cout << "Yes" << endl; }
inline void NO() { cout << "NO" << endl; } inline void No() { cout << "No" << endl; }

const int inf = 1 << 30;
const ll linf = 1LL << 60;
const int MOD = 1000000007;

template <class T> inline T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
void generatePrimes(ll n);
void factorize(ll n);

#include <set>

Vl primes;
ll donePrime = 1;
ll ans = 1;

void get(ll n)
{
	ll lim = (ll)ceil(sqrt(n));

	if (!(n & 1))
	{
		ans += 1;
		while (n && !(n & 1))
			n >>= 1;
	}

	for (ll d = 3; d <= lim; d += 2)
	{
		if (!(n % d))
		{
			++ans;

			while (n && !(n % d))
				n /= d;
		}
	}

	if (n != 1)
		++ans;	
}


int main()
{
	ll a, b; cin >> a >> b;
	ll g = gcd(a, b);

	if (g == 1)
	{
		cout << 1 << endl;
		return 0;
	}

	get(g);

	cout << ans << endl;
}


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

int main(){
  int k, x;
  cin >> k >> x;
  int min = -1000000;
  int max = 1000000;
  if(x-k+1 > min) min =x-k+1;
  if(x+k-1 < max) max =x+k-1;
  for(int i = min; i <= max; i++) cout << i << " " ;
  cout << endl;
}

Measured memory_bytes: 256
[<AutoOpen>]
module Program

open System

let read f = stdin.ReadLine() |> f
let reads f = stdin.ReadLine().Split() |> Array.toList |> List.map f

let conv i j xs =
    List.skip i xs
    |> List.rev
    |> List.skip j

let check xs =
    List.forall (fun c -> List.contains c ['A';'C';'G';'T']) xs

[<EntryPoint>]
let main argv =
    let s = read id
    let n = String.length s
    let ss = s.ToCharArray() |> Array.toList
    seq {
        for i = 0 to n do
            for j = 0 to n do
                if i + j <= n then
                    let cs = conv i j ss
                    if check cs then yield List.length cs
    }
    |> Seq.max
    |> printfn "%i"
    0

Measured memory_bytes: 12892
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<cstring>
#include<vector>
#include<queue>
#include<set>
#include<map>
#include<stack>
#include<bitset>
#include<ext/pb_ds/priority_queue.hpp>
using namespace std;

const int maxn = 1E5 + 10;

int n,m,tp,stk[maxn];
bool vis[maxn];

vector <int> v[maxn];

void Dfs(int x)
{
	for (int i = 0; i < v[x].size(); i++)
	{
		int to = v[x][i];
		if (vis[to]) continue;
		vis[to] = 1; stk[++tp] = to;
		Dfs(to); return;
	}
}

int main()
{
	#ifdef DMC
		freopen("DMC.txt","r",stdin);
	#endif
	
	cin >> n >> m;
	while (m--)
	{
		int x,y; scanf("%d%d",&x,&y);
		v[x].push_back(y); v[y].push_back(x);
	}
	stk[tp = 1] = 1; vis[1] = 1; Dfs(1);
	reverse(stk + 1,stk + tp + 1); Dfs(1); cout << tp << endl;
	for (int i = 1; i < tp; i++) printf("%d ",stk[i]); cout << stk[tp] << endl;
	return 0;
}

Measured memory_bytes: 6784
import java.util.Scanner;


public class Main {
	Scanner in = new Scanner(System.in);
	int N, T, L, B;
	double[][] dp;
	boolean[] lose, back;
	
	public void run() {
		while (true) {
			N = in.nextInt();
			T = in.nextInt();
			L = in.nextInt();
			B = in.nextInt();
			if (B == 0 && N == 0 && T == 0 && L == 0) break;
			dp = new double[T+2][N+1];
			lose = new boolean[N+1];
			back = new boolean[N+1];
			dp[0][0] = 1;
			for (int i = 0; i < L; i++) {
				lose[in.nextInt()] = true;
			}
			for (int i = 0; i < B; i++) {
				back[in.nextInt()] = true;
			}
			
			for (int i = 0; i < T; i++) {
				for (int j = 0; j < N; j++) {
					if (dp[i][j] != 0) {
						for (int k = 1; k <= 6; k++) {
							int next = j + k;
							if (next > N) {
								next = 2*N - next;
							}
							if (lose[next]) {
								dp[i+2][next] += dp[i][j] / 6;
							} else if (back[next]) {
								dp[i+1][0] += dp[i][j] / 6;
							} else {
								dp[i+1][next] += dp[i][j] / 6;
							}
						}
					}
				}
			}
			double ans = 0;
			for (int i = 1; i <= T; i++) {
				ans += dp[i][N];
			}
			
			System.out.printf("%6f\n", ans);
		}
	}
	public static void main(String[] args) {
		new Main().run();
	}

}

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

#define rep(i,x,y) for(int i=(x);i<(y);++i)
#define debug(x) #x << "=" << (x)

#ifdef DEBUG
#define _GLIBCXX_DEBUG
#define print(x) std::cerr << debug(x) << " (L:" << __LINE__ << ")" << std::endl
#else
#define print(x)
#endif

const int inf=1e9;
const int64_t inf64=1e18;
const double eps=1e-9;

template <typename T> ostream &operator<<(ostream &os, const vector<T> &vec){
    os << "[";
    for (const auto &v : vec) {
    	os << v << ",";
    }
    os << "]";
    return os;
}

using i64=int64_t;

class union_find{
	private:
	vector<int> parent,rank,gs;
    int size;
	public:
    int count_group;
    union_find()=default;
    union_find(int n){ init(n); }

    void init(int n){
		size=n;
		count_group=n;
		parent.resize(size);
		rank.assign(size,0);
        gs.assign(size,1);
		for(int i=0; i<size; ++i) parent[i]=i;
	}

	int find(int x){
		if(parent[x]==x) return x;
		else return parent[x]=find(parent[x]);
	}

	void unite(int x,int y){
		x=find(x);
		y=find(y);
		if(x==y) return;
		if(rank[x]<rank[y]){
			parent[x]=y;
            gs[y]+=gs[x];
		} else {
			parent[y]=x;
            gs[x]+=gs[y];
			if(rank[x]==rank[y]) ++rank[x];
		}
		--count_group;
	}

	bool is_same_group(int x,int y){
		return find(x)==find(y);
	}

    int group_size(int x){
        return gs[find(x)];
    };
};


void solve(){
    int N,M,Q;
    cin >> N >> M >> Q;
    vector<string> S(N);
    rep(i,0,N) cin >> S[i];

    vector<vector<int>> a(N,vector<int>(M)),b(N,vector<int>(M)),c(N,vector<int>(M));
    {
        vector<vector<int>> s(N,vector<int>(M));
        rep(i,0,N){
            if(S[i][0]=='1') ++s[i][0];
            rep(j,1,M) s[i][j]=s[i][j-1]+(S[i][j]=='1');
        }
        rep(j,0,M){
            a[0][j]=s[0][j];
            rep(i,1,N) a[i][j]=a[i-1][j]+s[i][j];
        }
    }
    {
        vector<vector<int>> s(N,vector<int>(M));
        rep(i,0,N) rep(j,1,M) s[i][j]=s[i][j-1]+(S[i][j]=='1' and S[i][j-1]=='1');
        rep(j,0,M){
            b[0][j]=s[0][j];
            rep(i,1,N) b[i][j]=b[i-1][j]+s[i][j];
        }
    }
    {
        vector<vector<int>> s(N,vector<int>(M));
        rep(j,0,M) rep(i,1,N) s[i][j]=s[i-1][j]+(S[i][j]=='1' and S[i-1][j]=='1');
        rep(i,0,N){
            c[i][0]=s[i][0];
            rep(j,1,M) c[i][j]=c[i][j-1]+s[i][j];
        }
    }

    rep(i,0,Q){
        int x1,y1,x2,y2;
        cin >> x1 >> y1 >> x2 >> y2;
        --x1;
        --y1;
        --x2;
        --y2;
        int v=a[x2][y2];
        if(x1-1>=0) v-=a[x1-1][y2];
        if(y1-1>=0) v-=a[x2][y1-1];
        if(x1-1>=0 and y1-1>=0) v+=a[x1-1][y1-1];
        int e=b[x2][y2]+c[x2][y2];
        if(x1-1>=0) e-=b[x1-1][y2];
        if(x1>=0) e-=c[x1][y2];
        if(y1>=0) e-=b[x2][y1];
        if(y1-1>=0) e-=c[x2][y1-1];
        if(x1-1>=0 and y1>=0) e+=b[x1-1][y1];
        if(x1>=0 and y1-1>=0) e+=c[x1][y1-1];
        cout << v-e << endl;
    }
}

int main(){
    std::cin.tie(0);
    std::ios::sync_with_stdio(false);
    cout.setf(ios::fixed);
    cout.precision(10);
    solve();
    return 0;
}


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

typedef long long ll;
typedef pair<int, int> P;
#define MOD 1000000007
#define INF (1 << 30)
#define REP(i, m, n) for(int i = (int)m; i < (int)n; ++i)
#define rep(i, n) REP(i, 0, n)


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

    int n; cin >> n;
    vector<int> l(n);
    rep(i, n) cin >> l[i];
    sort(l.begin(), l.end());
    ll ans = 0;
    rep(i, n) REP(j, i+1, n) {
        // c < a+b
        int tmp = l[i]+l[j];
        int k = lower_bound(l.begin(), l.end(), tmp) - l.begin();
        ans += max(0, k-(j+1));
    }
    cout << ans << '\n';
    return 0;
} 

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define all(x) x.begin(), x.end()
using namespace std;

void PUNKS_NOT_DEAD() {
    int h, w;
    cin >> h >> w;
    cout << (h - 1) / w + 1;
}

signed main() {
#ifdef LOCAL
    freopen("input.txt", "r", stdin);
#endif
    ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
    PUNKS_NOT_DEAD();
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define INF (1LL<<50)
#define N 100001
using namespace std;
typedef long long ll;
ll s[N],t[N],p[N],P[N];
int main(){
  int n,m;
  cin>>n>>m;
  for(int i=0;i<n;i++) cin>>s[i]>>t[i];
  for(int i=1;i<=m;i++) cin>>p[i];
  p[m+1]=P[m+1]=(INF);
  sort(p,p+m+2);
  for(int i=1;i<m+2;i++)P[i]=p[i]-p[i-1];
  for(int i=2;i<m+1;i+=2)P[i]+=P[i-2],P[i+1]+=P[i-1];
  
  ll sum=0; 
  for(int i=0;i<n;i++){
    int idx2=upper_bound(p,p+m+2,s[i])-p,idx1=idx2-1;
    int idx4=upper_bound(p,p+m+2,t[i])-p,idx3=idx4-1;
    int f;

    if(idx2==idx4)sum+=abs(t[i]-s[i]);
    else if(s[i]<t[i]){
      sum+=(p[idx2]-s[i]);
      idx2++;
      f=idx2%2==idx3%2;
      sum+=P[idx3-f]-P[idx2-1]+f*(t[i]-p[idx3]);
    } 
    else{
      sum+=(s[i]-p[idx1]);
      idx1--;
      f=idx1%2==idx4%2;
      sum+=P[idx1]-P[idx4-!f]+f*(p[idx4]-t[i]);
    }
  }
  cout <<sum<<endl;
  
  return 0;
}

Measured memory_bytes: 4312
import sys
from collections import deque

h, w = (int(x) for x in sys.stdin.readline().split())
strings = deque(sys.stdin.read().split())

for i in range(h):
    strings[i] = ''.join(['-', strings[i], '-'])
strings.append('-' * (w + 2)); strings.appendleft('-' * (w + 2))

ans = []
for i in range(1, h + 1):
    s = ''
    for j in range(1, w + 1):
        current = strings[i][j]
        if current == '#': s += '#'
        elif current == '.':
            count = 0
            for t in range(i-1, i+2):
                for u in range(j-1, j+2):
                    if strings[t][u] == '#': count += 1
            s += str(count)
    ans.append(s)

for s in ans: print(s)



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

hen_len_lst = input().split() #辺の長さのリスト

hen_len_sum = 0 #全ての辺の長さの合計

ans_flg = "Yes" #多角形が描けないと分かり次第"No"にする

for n in range(N):
    hen_len_sum += int(hen_len_lst[n])

for n in range(N):
    if int(hen_len_lst[n]) >= (hen_len_sum - int(hen_len_lst[n])):
        ans_flg = "No"

print(ans_flg)

Measured memory_bytes: 3060
N, A, B = map(int, input().split())
HP = []

for _ in range(N):
    HP.append(int(input()))

left = 0
right = max(HP)

def canKill(count):
    ness = 0
    for hp in HP:
        ness += max(-(-(hp - B * count) // (A - B)), 0)
    if ness <= count:
        return True
    return False

while right - left > 1:
    middle = left + (right - left) // 2
    if canKill(middle):
        right = middle
    else:
        left = middle

print(right)

Measured memory_bytes: 7196
H, W = [int(s) for s in input().rstrip().split()]
S = [list(input().rstrip()) for _ in range(H)]

for i in range(H):
    for j in range(W):
        if S[i][j] == '#':
            continue
        bomb = 0
        for x in range(i-1, i+2):
            for y in range(j-1, j+2):
                if 0 <= x < H and 0 <= y < W and S[x][y] == '#':
                    bomb += 1
        S[i][j] = str(bomb)

for s in S:
    print(''.join(s))

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

using namespace std;

int main(){
	int n;
	cin >> n;
	long long ans=0;
	for(int i=1;i<=n;i++){
		for(int j=1;j<=n;j++){
			for(int k=1;k<=n;k++){
				ans+=(__gcd(i,__gcd(j,k)));
			}
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 3604
import java.io.BufferedReader;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;

public class Main {
    public static void main(String[] args){
        PrintWriter out = new PrintWriter(System.out);
        FastScanner sc = new FastScanner();

        int L = sc.nextInt();
        int R = sc.nextInt();
        int ans = 10000;

        int r = Math.min(R, L+2018);
        for (int i=L;i<=r;i++) {
            for (int j=i+1;j<=r;j++) {
                int m = i % 2019;
                int n = j % 2019;
                ans = Math.min((m*n) % 2019, ans);
            }
        }

        out.println(ans);
        out.flush();
    }

    public static class FastScanner {
        BufferedReader br;
        StringTokenizer st;

        public FastScanner(String s) {
            try {
                br = new BufferedReader(new FileReader(s));
            } catch (FileNotFoundException e) {
                e.printStackTrace();
            }
        }

        public FastScanner() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        String nextToken() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

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

        long nextLong() {
            return Long.parseLong(nextToken());
        }

        double nextDouble() {
            return Double.parseDouble(nextToken());
        }

        int[] nextIntArray(int N) {
            int a[] = new int[N];
            for (int i=0;i<N;i++) {
                a[i] = this.nextInt();
            }

            return a;
        }

        long[] nextLongArray(int N) {
            long a[] = new long[N];
            for (int i=0;i<N;i++) {
                a[i] = this.nextLong();
            }

            return a;
        }

        double[] nextDoubleArray(int N) {
            double a[] = new double[N];
            for (int i=0;i<N;i++) {
                a[i] = this.nextDouble();
            }

            return a;
        }

        String[] nextTokenArray(int N) {
            String a[] = new String[N];
            for (int i=0;i<N;i++) {
                a[i] = this.nextToken();
            }

            return a;
        }
    }
}

Measured memory_bytes: 23380
H, W = map(int, input().split())
S = [input() for _ in range(H)]

for i in range(H):
    S[i] = '.' + S[i] + '.'
S = ['.' * (W + 2)] + S + ['.' * (W + 2)]

for i in range(1,H+1):
    s = ''
    for j in range(1, W+1):
        if S[i][j] == '#':
            s += '#'
        else:
            ser = S[i-1][j-1] + S[i-1][j] + S[i-1][j+1] + S[i][j-1] + S[i][j+1] + S[i+1][j-1] + S[i+1][j] + S[i+1][j+1]
            s += str(ser.count('#'))
    print(s)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
#define lli long long
#define all(i) i.begin(),i.end()
#define rep0(i,j) for(int i=0;i<j;i++)

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

    vector <lli> vec(n);
    rep0(i,n)cin >> vec[i];
    sort(all(vec));
    rep0(i,n-1){
        if(vec[i] == vec[i+1]){
            cout << "NO";
            return 0;
        }
    }
    cout << "YES";
}

Measured memory_bytes: 1792
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#define rep(i, n) for(i = 0; i < n; i++)
using namespace std;

int c[3][3];

bool check(int a1, int a2, int a3) {
	int d[3][3];
	int i, j;
	
	rep(i, 3) rep(j, 3) d[i][j] = c[i][j];
	rep(j, 3) d[0][j] -= a1;
	rep(j, 3) d[1][j] -= a2;
	rep(j, 3) d[2][j] -= a3;
	
	rep(j, 3) if (!(d[0][j] == d[1][j] && d[1][j] == d[2][j])) return false;
	return true;
}

signed main() {
	int i, j, k;
	
	rep(i, 3) rep(j, 3) cin >> c[i][j];
	
	rep(i, 101) {
		rep(j, 101) {
			rep(k, 101) {
				if (check(i, j, k)) { cout << "Yes" << endl; return 0; }
			}
		}
	}
	cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize(2)
#include<bits/stdc++.h>
#define ll long long
#define maxn 1000005
#define inf 1e9
#define pb push_back
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define per(i,a,b) for(int i=a;i>=b;i--)
using namespace std;

inline int read()
{
	int x=0,w=1; char c=getchar();
	while(c<'0'||c>'9') {if(c=='-') w=-1; c=getchar();}
	while(c<='9'&&c>='0') {x=(x<<1)+(x<<3)+c-'0'; c=getchar();}
	return w==1?x:-x;
}

ll fac[maxn],inv[maxn],n,k,a[maxn];
const ll mod=1000000007;

inline ll pw(ll a,ll b)
{
	ll ans=1,base=a;
	while(b)
	{
		if(b&1) ans=(ans*base)%mod;
		base=(base*base)%mod; b>>=1;
	}
	return ans;
}

inline ll C(int N,int M){return (fac[N]*inv[M]%mod)*inv[N-M]%mod;}

int main()
{
	fac[0]=1; inv[0]=1;
	rep(i,1,(maxn-5)) fac[i]=(fac[i-1]*i)%mod;
	rep(i,1,(maxn-5)) inv[i]=pw(fac[i],mod-2);
	n=read(); k=read(); rep(i,1,n) a[i]=read(); sort(a+1,a+n+1);
	ll a1=0,a2=0;
	rep(i,k,n) a1=(a1+(a[i]*C(i-1,k-1))%mod)%mod;
	rep(i,1,n-k+1) a2=(a2+(a[i]*C(n-i,k-1))%mod)%mod;
	a1=(a1-a2+mod)%mod; cout<<a1<<endl; 
	return 0;
}

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

int main() {

	int n; cin >> n;
	double tmp = 0;
	for (int i = 0; i < n; i++) {
		int a; cin >> a;
		tmp += (double)1 / a;
	}
	cout << fixed << setprecision(11) << 1 / tmp << endl;
	return 0;
}

Measured memory_bytes: 3740
/* package whatever; // don't place package name! */

import java.util.*;
import java.lang.*;
import java.io.*;

/* Name of the class has to be "Main" only if the class is public. */
class Main
{
  	int dp[];
  	Main(int n){
      dp = new int[n];
      for(int i = 0; i < dp.length; i++) {
    dp[i] = -1;
}
    }
	public static void main (String[] args) throws java.lang.Exception
	{
      	FastReader s = new FastReader();
		int  n = s.nextInt();
		int arr[] = new int[n];
		for(int i=0;i<n;i++)
		arr[i]= s.nextInt();
		Main ob = new Main(n);
		int ans = ob.getCost(n-1,arr);
		System.out.println(ans);
	}
	int getCost(int n, int arr[]){
      	if (dp[n]!=-1) return dp[n];
		if(n==0) { 
          dp[0] = 0;
          return dp[0];
        }
		if(n==1) {
          dp[1] = Math.abs(arr[1]-arr[0]);
          return Math.abs(arr[1]-arr[0]);
        }
      	dp[n]=Math.min(Math.abs(arr[n]-arr[n-1])+getCost(n-1,arr),Math.abs(arr[n]-arr[n-2])+getCost(n-2,arr));
		return dp[n];
	}
  static class FastReader 
    { 
        BufferedReader br; 
        StringTokenizer st; 
  
        public FastReader() 
        { 
            br = new BufferedReader(new
                     InputStreamReader(System.in)); 
        } 
  
        String next() 
        { 
            while (st == null || !st.hasMoreElements()) 
            { 
                try
                { 
                    st = new StringTokenizer(br.readLine()); 
                } 
                catch (IOException  e) 
                { 
                    e.printStackTrace(); 
                } 
            } 
            return st.nextToken(); 
        } 
  
        int nextInt() 
        { 
            return Integer.parseInt(next()); 
        } 
  
        long nextLong() 
        { 
            return Long.parseLong(next()); 
        } 
  
        double nextDouble() 
        { 
            return Double.parseDouble(next()); 
        } 
  
        String nextLine() 
        { 
            String str = ""; 
            try
            { 
                str = br.readLine(); 
            } 
            catch (IOException e) 
            { 
                e.printStackTrace(); 
            } 
            return str; 
        } 
    } 
}


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

int main(){
  int A,B;
  char op;
  
  cin >> A >> op >> B;
  
  int ans;
  if(op == '+')
    ans = A + B;
  else
    ans = A - B;
  
  cout << ans;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define FOR(var, begin, end) for (int var = (begin); var < (end); var++)
#define RFOR(var, begin, end) for (int var = (begin) - 1; var >= (end); var--)
#define REP(var, length) FOR(var, 0, length)
#define RREP(var, length) RFOR(var, length, 0)
#define SORT(vector) sort(vector.begin(), vector.end())

const ll MOD = 1e9 + 7;

void solve(istream& cin, ostream& cout) {
  string s;
  cin >> s;
  REP(i, s.size()) {
    if (i % 2 == 0) {
      if (s[i] == 'R' || s[i] == 'U' || s[i] == 'D') {

      } else {
        cout << "No" << endl;
        return;
      }
    } else {
      if (s[i] == 'L' || s[i] == 'U' || s[i] == 'D') {

      } else {
        cout << "No" << endl;
        return;
      }
    }
  }
  cout << "Yes" << endl;
}

#ifndef TEST
int main() {
  solve(cin, cout);
}
#endif


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

using namespace std;
const int maxn = 100010;
int pa[maxn], d[maxn];
int n, m;

int findset(int x)
{
    if(pa[x] == x)return x;
    int t = findset(pa[x]);
    d[x] += d[pa[x]];
    pa[x] = t;
    return pa[x];
}

int main()
{
    memset(d, 0, sizeof(d));
    scanf("%d%d", &n, &m);
    for(int i = 0; i <= n; i++)
        pa[i] = i;
    for(int i = 1; i <= m; i++) {
        int x, y, w;
        scanf("%d%d%d", &x, &y, &w);
        int p = findset(x), q = findset(y);
        if(p != q) {
            pa[p] = q;
            d[p] = d[y] - (d[x] + w);
        } else if(d[y] - d[x] != w) {
            printf("No\n");
            return 0;
        }
    }
    printf("Yes\n");
    return 0;
}


Measured memory_bytes: 1024
#include <algorithm>
#include <iostream>
#include <vector>
#include <functional>
#include <string>
#include <cmath>  //sqrt 
#include <iomanip> //setprecision
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ll long long
#define beg begin()
#define end end()


void _main(){
    ll a,b,n; cin >> a >> b >> n;
    auto func = [&](ll x){
        return (a*x)/b;
    };
    ll out;
    if(b<=n) out = func(b-1);
    else out = func(n);

    cout << out << endl;
    return;
}
int main() {
    cout << fixed << setprecision(10);
    _main();
    return 0;
}
    

Measured memory_bytes: 3128
#pragma GCC optimize("Ofast")
#include <stdio.h>
#include <stdlib.h>
#include <time.h>

#define eprintf(...) fprintf(stderr, __VA_ARGS__)

int Max(int a, int b) {return a > b ? a : b;}

#define maxn 200005

struct T {
	char mon;
	int val, mx, fst;
	int fix;
	T *lson, *rson;
} t[maxn];

int tot;

T *new_node(int v) {
	T *x = &t[++ tot];
	x->mon = 1;
	x->val = v; x->mx = v; x->fst = v;
	x->fix = rand();
	x->lson = x->rson = 0;
	return x;
}

void pushup0(T *x) {
	x->fst = x->lson ? x->lson->fst : x->val;
	char mo = 1;
	x->mx = x->val;
	if (x->lson) {
		x->mx = Max(x->mx, x->lson->mx);
		mo &= x->lson->mon && x->lson->mx < x->val;
	}
	if (x->rson) {
		x->mx = Max(x->mx, x->rson->mx);
		mo &= x->rson->mon && x->val < x->rson->fst;
	}
	x->mon = mo;
}

void pushup1(T *x) {
	x->mon = 1;
	x->fst = x->lson ? x->lson->fst : x->val;
	x->mx = x->rson ? x->rson->mx : x->val;
}

T *merge0(T *a, T *b) {
	if (!a || !b) return a ? a : b;
	if (a->fix < b->fix) {
		a->rson = merge0(a->rson, b);
		pushup0(a);
		return a;
	} else {
		b->lson = merge0(a, b->lson);
		pushup0(b);
		return b;
	}
}

T *merge1(T *a, T *b) {
	if (!a || !b) return a ? a : b;
	if (a->fix < b->fix) {
		a->rson = merge1(a->rson, b);
		pushup1(a);
		return a;
	} else {
		b->lson = merge1(a, b->lson);
		pushup1(b);
		return b;
	}
}

int split(T *x, int v, T *&a, T *&b) {
	if (!x) {a = b = 0; return v;}
	if (x->mx < v) {a = x; b = 0; return v;}
	if (x->mon) {
		if (x->fst > v) {a = 0; b = x; return b->mx;}
		if (x->val < v) {
			a = x; split(x->rson, v, a->rson, b);
			pushup1(a); return b->mx;
		} else {
			b = x; split(x->lson, v, a, b->lson);
			pushup1(b); return b->mx;
		}
	} else {
		T *ls = x->lson, *rs = x->rson;
		x->lson = x->rson = 0;
		pushup1(x);
		v = split(ls, v, a, b);
		if (x->val > v) b = merge1(b, x), v = x->val;
		else a = merge0(a, x);
		T *c, *d;
		v = split(rs, v, c, d);
		a = merge0(a, c); b = merge1(b, d);
		return v;
	}
}

T *rt;

int main() {
//	freopen("in", "r", stdin);
	srand(200);
	int n; scanf("%d", &n);
	for (int i = 1; i <= n; ++ i) {
		int p; scanf("%d", &p);
		rt = merge0(rt, new_node(p));
	}
	int ans = 0;
	while (!rt->mon) {
		++ ans;
		T *a, *b;
		split(rt, 0, a, b);
		rt = merge0(a, b);
//		printf("%d\n", ans);
	}
	printf("%d\n", ans);
//	eprintf("time used: %.3f\n", clock() * 1.0 / CLOCKS_PER_SEC);
	return 0;
}


Measured memory_bytes: 7936
N = int(input())
p = list(map(int,input().split(' ')))
p1 = p.copy()
p1.sort()
for i in range(N):
    for i1 in range(i,N):
        p2 = p.copy()
        p2[i],p2[i1] = p2[i1],p2[i]
        if p2 == p1:
            print("YES")
            exit()
print("NO")


Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define endl '\n'
#define ll long long
#define all(a) a.begin(), a.end()
#define sz(a) a.size()
using namespace std;



int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0);
    #ifndef ONLINE_JUDGE
    //freopen("A.txt", "r", stdin);
    #endif
    int n, r=0, ans=0;
    string str;
    cin >> n >> str;
    for(int i=0; i<n; i++){
        if(str[i]=='R') r++;
    }
    for(int i=0; i<r; i++){
        if(str[i]=='W') ans++;
    }
    cout << ans;
}


Measured memory_bytes: 3656
/*
[agc033] B - LRUD Game
*/

#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;
typedef pair<ll, ll> pll;

const int MAX_H = 2e5;
const int MAX_W = 2e5;
const int MAX_N = 2e5;

const string ds = "LRUD";
const int dh[4] = {0, 0, -1, 1};
const int dw[4] = {-1, 1, 0, 0};

int H, W, N;
int sr, sc;
string S[2];

bool solve() {
    for (int k = 0; k < 4; k++) {
        int h = sr, w = sc;
        for (int i = 0; i < N; i++) {
            for (int j = 0; j < 2; j++) {
                if (S[j][i] == ds[k ^ j]) {
                    h += dh[k ^ j];
                    w += dw[k ^ j];
                    if (j == 1) {
                        h = max(h, 0);
                        h = min(h, H - 1);
                        w = max(w, 0);
                        w = min(w, W - 1);
                    } else if (h < 0 || H <= h || w < 0 || W <= w) {
                        return false;
                    }
                }
            }
        }
    }

    return true;
}

int main() {
    cin >> H >> W >> N;
    cin >> sr >> sc;
    sr--;
    sc--;
    cin >> S[0];
    cin >> S[1];

    cout << (solve() ? "YES" : "NO") << endl;

    return 0;
}


Measured memory_bytes: 776
using System;
 
namespace Aizu
{
    class OnlineJudge
    {
        public static void Main()
        {
            var p = new [] { 1, 5, 10, 50, 100, 500, 0 };
            var c = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
            for(int i = 5; i >= 0 && p[6] < 1000; p[6] += p[i] * c[i--]);
            Console.WriteLine(p[6] >= 1000 ? 1 : 0);
        }
    }
}

Measured memory_bytes: 15852
#include <atcoder/dsu>
#include <iostream>
using namespace std;
using namespace atcoder;

int main()
{
    int n, q;
    cin >> n >> q;
    dsu d(n);
    while(q--){
        int t, u, v;
        cin >> t >> u >> v;
        if(t) cout << d.same(u, v) << endl;
        else d.merge(u, v);
    }
}


Measured memory_bytes: 4044
#include <stdio.h>
#include <stdlib.h>

#define NIL NULL

struct node{
  struct node *right;
  struct node *left;
  struct node *parent;
  int key;
};

typedef struct node * Node;

Node root;

Node treeMinimum(Node x){


}

Node treeMaximum(Node x){


}

Node treeSearch(Node u, int k){


}

Node treeSuccessor(Node x){


}

void treeDelete(Node z){
  Node y; // node to be deleted
  Node x; // child of y


}

void insert(int k){
  Node y = NIL;
  Node x = root;
  Node z;

  z = malloc(sizeof(struct node));
  z->key = k;
  z->left = NIL;
  z->right = NIL;

  while(x != NIL){
    y = x;
    if(z->key < x->key) x = x->left;
    else x = x->right;
  }
  
  z->parent = y;

  if(y == NIL) root = z;
  else if(z->key < y->key) y->left = z;
  else y->right = z;


}

void inorder(Node u){
  if(u == NIL) return;
  inorder(u->left);
  printf(" %d",u->key);
  inorder(u->right);
 
}
void preorder(Node u){
  if(u == NIL) return;
  printf(" %d",u->key);
  preorder(u->left);
  preorder(u->right);
}


int main(){
  int n, i, x;
  char com[20];
  scanf("%d", &n);

  for ( i = 0; i < n; i++ ){
    scanf("%s", com);
    if ( com[0] == 'f' ){
      scanf("%d", &x);
      Node t = treeSearch(root, x);
      if ( t != NIL ) printf("yes\n");
      else printf("no\n");
    } else if ( com[0] == 'i' ){
      scanf("%d", &x);
      insert(x);
    } else if ( com[0] == 'p' ){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    } else if ( com[0] == 'd' ){
      scanf("%d", &x);
      treeDelete(treeSearch(root, x));
    }
  }

  return 0;
}



Measured memory_bytes: 25132
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define int long long
#define SPEED ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
signed main()
{
    SPEED;
  	int n,a,b;
  	cin>>n>>a>>b;
  	if(a==0)
    {
      	cout<<0;
      	return 0;
    }
  	if(n%(a+b)>a)
  		cout<<(n/(a+b)+1)*a;
  	else 
      	cout<<(n/(a+b))*a+n%(a+b);
}

Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10**6)

around = [(0,1),(1,0),(0,-1),(-1,0)]

H,W = map(int,input().split())
grid = [list(input()) for _ in range(H)]

checked = [[0]*W for _ in range(H)]

def dfs(i,j):
    checked[i][j] = 1
    for di,dj in around:
        ni = i + di; nj = j + dj
        if not(0 <= ni <= H-1 and 0 <= nj <= W-1):
            continue
        if checked[ni][nj]:
            continue
        p = grid[i][j]
        np = grid[ni][nj]
        if (p,np) == (".","#"):
            global b
            b += 1
            dfs(ni,nj)
        if (p,np) == ("#","."):
            global w
            w += 1
            dfs(ni,nj)

ans = 0
for i in range(H):
    for j in range(W):
        b = 0; w = 1
        if not checked[i][j] and grid[i][j] == ".":
            dfs(i,j)
        ans += b*w
print(ans)

Measured memory_bytes: 150728
import java.util.*;

public class Main {
    public static void main(String[] args) {
        //コード
        Scanner scanner = new Scanner(System.in);
        Integer A = Integer.parseInt(scanner.next());
        Integer B = Integer.parseInt(scanner.next());

        Integer a = 0;
        Integer start = 0;
        for(;;) {
            double tax1 = Math.floor(a * 0.08);
            if((int)tax1 <= A-1) start = a + 1;
            if(A < tax1) break;
            a++;
        }

        for (int i = start; i < a; i++) {
            double tax2 = Math.floor(i * 0.1);
            if((int)tax2 == B) {
                System.out.println(i);
                System.exit(0);
            }
        }
        System.out.println(-1);
    }
}

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

class NextPrime
{
    static void Main(string[] args)
    {
        var input = int.Parse(Console.ReadLine());
        int number = input;
        bool check = false;

        while (!check)
        {
            check = true;
            for (var i = 2; i < number; i++)
            {
                if (number % i == 0)
                {
                    check = false;
                    break;
                }
            }
            if (check)
            {
                break;
            }
                number++;
        }
        Console.WriteLine(number);
    }
}

Measured memory_bytes: 11092
#include <stdio.h>

int main() {
	int a, b;
	while (1) {
		scanf("%d %d", &a, &b);
		if (a == 0 && b == 0) break;
		if (a > b) printf("%d %d\n", b, a);
		else{
			printf("%d %d\n", a, b);
		}
	}
}


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

int main(){
  unsigned int n,sum;
  vector<int> ans;

  while(cin >> n, n){
    sum = 0;
    for(int i=0; i<n/4; ++i){
      int temp;
      cin >> temp;
      sum += temp;
    }
    ans.push_back(sum);
  }
  for(int i:ans){
    cout << i << endl;
  }
  return 0;
}

Measured memory_bytes: 3128
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#define int long long
using namespace __gnu_pbds;
using namespace std;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

signed main()
{
     ios_base::sync_with_stdio(false);
     cin.tie(NULL);  
   
 #ifndef ONLINE_JUDGE
    if(fopen("INPUT.txt","r"))
    {
    freopen ("INPUT.txt" , "r" , stdin);
    freopen ("OUTPUT.txt" , "w" , stdout);
    }
 #endif

// -------------------------------------Code starts here---------------------------------------------------------------------     

   int a[]={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
   int k;
   cin>>k;
   cout<<a[k-1];
   
// -------------------------------------Code ends here------------------------------------------------------------------
     clock_t clk;
 	clk = clock();
 
    clk = clock() - clk;
 	cerr << fixed << setprecision(6) << "Time: " << ((double)clk)/CLOCKS_PER_SEC << "\n";
 	return 0;
 }

Measured memory_bytes: 256
#include<iostream>
#include<cmath>
#define M 1000000007
using namespace std;
typedef long long llong;
typedef unsigned long long ullong;

llong pos(ullong m,ullong n){
    ullong res=1;
    while(n>0){
        if(n & 1) res=res * m %M;
        m=m*m % M;
        n>>=1;
    }
    return res;
}

int main(){
    ullong m,n;
    cin>>m>>n;
    cout<<pos(m,n)<<endl;
    return 0;
}



Measured memory_bytes: 3100
import java.util.*;
// import java.util.stream.*;

public class Main {
  public static void main(String[] args) {
    Main main = new Main();
    System.out.println(main.solve());
  }

  int a;
  int b;

  public Main() {
    Scanner sc = new Scanner(System.in);
    try {
      a = sc.nextInt();
      b = sc.nextInt();
    } finally {
      sc.close();
    }
  }

  int solve() {
    for (int i = 1; i <= 1000; i++) {
      int x = i * 8 / 100;
      int y = i * 10 / 100;
      if (x == a && y == b) return i;
    }
    return -1;
  }
}


Measured memory_bytes: 35592
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define MOD (ll) (1e9+7)
int main()
{
	ll a,b,c,d;
	cin>>a>>b>>c>>d;
	ll fimax = max(a,b);
	ll fimin = min(a,b);
	
	ll semax = max(c,d);
	ll semin = min(c,d);
	ll xx = 0;
	if(fimax == 0 || fimin == 0 || semax == 0 || semin == 0)
	{
	    cout<<max({xx,semin*fimin,fimin*semax,fimax*semin,fimax*semax});
	}
	else{
		 cout<<max({semin*fimin,fimin*semax,fimax*semin,fimax*semax});
	}
}

Measured memory_bytes: 3608
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define REP(i, n) FOR(i, 0, (n))
#define FOR(i, a, b) for(int i=(a); i<(b); i++)
#define LAR(a, b) ((a)=max((a),(b)))
#define SML(a, b) ((a)=min((a),(b)))
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<pair<int, int>> vpii;
typedef pair<int, int> pii;
#define PB push_back
#define EB emplace_back
#ifdef LOCAL_DEBUG
#define DEBUG(...) printf(__VA_ARGS__)
#else
#define DEBUG(...)
#endif

int main(){
	int a, p; scanf("%d%d", &a, &p);
	printf("%d\n", (a*3+p)/2);
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define F(i,a,b) for(ll i=a;i<b;i++)
#define RF(i,a,b) for(ll i=a;i>b;i--)
#define pii pair<ll,ll>
#define ff first
#define ss second
#define pb(x) push_back(x)
#define pob pop_back
#define mp(x,y) make_pair(x,y)
#define mod 1000000007
#define w(t) int t; cin>>t;while(t--)
using namespace std;
const int inf=(int)1e9;
char flip_bits(char c){return (c == '0')? '1': '0';}

bool isPrime(int n) 
{ 
    // Corner case 
    if (n <= 1) 
        return false; 
  
    // Check from 2 to n-1 
    for (int i = 2; i < n; i++) 
        if (n % i == 0) 
            return false; 
  
    return true; 
}
ll numberOfOneBitsInInteger(ll input) {
  ll numOneBits = 0;

  ll currNum = input;
  while (currNum != 0) {
    if ((currNum & 1) == 1) {
      numOneBits++;
    }
    currNum = currNum >> 1;
  }
  return numOneBits;
}

int main()
{
    
    ios::sync_with_stdio(0);   
    cin.tie(0);   
   
  
    
   string A,B,C;
   cin>>A>>B>>C;
   if(A[A.length()-1]==B[0] && B[B.length()-1]==C[0])
   {
    cout<<"YES";
   }
   else
   {
    cout<<"NO";
   }
return 0;
}

Measured memory_bytes: 256
import numpy as np
from math import ceil

n = int(input())
a = [int(input()) for _ in range(n)]

modulo = 998244353

a.sort(reverse=True)
cumsump1 = 1
s = sum(a)

dp = np.zeros(s + 1, dtype=np.int)
dp[0] = 1
for ai in a:
    cumsump1 += ai
    dp[ai:cumsump1] = 2 * dp[ai:cumsump1] + dp[: -ai + cumsump1]
    dp[:ai] = 2 * dp[:ai]
    dp %= modulo

ans = 3 ** n % modulo
ans -= 3 * dp[ceil(s / 2) :].sum()

if s % 2 == 0:
    dp = np.zeros(s // 2 + 1, dtype=np.int)
    dp[0] = 1
    for ai in a:
        dp[ai:] = (dp[ai:] + dp[:-ai]) % modulo

    ans += 3 * dp[s // 2]

ans %= modulo

print(ans)


Measured memory_bytes: 14676
import sys
import heapq

sys.setrecursionlimit(10 ** 7)
f_inf = float('inf')
mod = 10 ** 9 + 7


def resolve():
    n, m = map(int, input().split())

    edge = [[] for _ in range(n)]
    for _ in range(m):
        a, b = map(int, input().split())
        edge[a - 1].append([1, b - 1])
        edge[b - 1].append([1, a - 1])

    # ダイクストラ法：O(ElogV)
    def dijkstra_heap(s):
        # 始点sから各頂点への最短距離
        d = [float("inf")] * n
        used = [True] * n  # True:未確定
        d[s] = 0
        used[s] = False
        edgelist = []
        for e in edge[s]:
            heapq.heappush(edgelist, e)
        while len(edgelist):
            minedge = heapq.heappop(edgelist)
            # まだ使われてない頂点の中から最小の距離のものを探す
            if not used[minedge[1]]:
                continue
            v = minedge[1]
            d[v] = minedge[0]
            used[v] = False
            for e in edge[v]:
                if used[e[1]]:
                    heapq.heappush(edgelist, [e[0] + d[v], e[1]])
        return d

    L = dijkstra_heap(n - 1)

    if L[0] <= 2:
        print("POSSIBLE")
    else:
        print("IMPOSSIBLE")


if __name__ == '__main__':
    resolve()


Measured memory_bytes: 89056
// ===================================
//   author: M_sea
//   website: http://m-sea-blog.com/
// ===================================
#include <algorithm>
#include <iostream>
#include <cstdlib>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <queue>
#define re register
using namespace std;

inline int read() {
    int X=0,w=1; char c=getchar();
    while (c<'0'||c>'9') { if (c=='-') w=-1; c=getchar(); }
    while (c>='0'&&c<='9') X=X*10+c-'0',c=getchar();
    return X*w;
}

const int N=100000+10,M=200000+10;

int n,m,tot=0;
int x[M],y[M],c[M];
int S[M],top=0,S2[M<<1],top2=0;
vector<pair<int,int> > vec[M];
vector<int> s[M];

int f[N];
inline int find(int x) { return x==f[x]?x:f[x]=find(f[x]); }

struct edge { int v,nxt; } e[2000000];
int head[2000000];
inline void addEdge(int u,int v) {
    static int cnt=0;
    e[++cnt]=(edge){v,head[u]},head[u]=cnt;
}

int dis[2000000];
inline void bfs() {
    queue<int> Q; Q.push(1); dis[1]=1;
    while (!Q.empty()) {
        int u=Q.front(); Q.pop();
        for (re int i=head[u];i;i=e[i].nxt) {
            int v=e[i].v; if (dis[v]) continue;
            dis[v]=dis[u]+1; Q.push(v);
        }
    }
}

int main() {
    n=read(),m=read(),tot=n;
    for (re int i=1;i<=m;++i) x[i]=read(),y[i]=read(),c[i]=read();
    for (re int i=1;i<=m;++i) S[i]=c[i];
    sort(S+1,S+m+1); int top=unique(S+1,S+m+1)-S-1;
    for (re int i=1;i<=m;++i) c[i]=lower_bound(S+1,S+top+1,c[i])-S;
    for (re int i=1;i<=m;++i) vec[c[i]].push_back(make_pair(x[i],y[i]));
    for (re int i=1;i<=n;++i) f[i]=i;
    for (re int i=1;i<=top;++i) {
        for (re auto j:vec[i]) {
            int u=j.first,v=j.second;
            if (find(u)!=find(v)) f[find(u)]=find(v);
        }
        int top2=0;
        for (re auto j:vec[i]) S2[++top2]=find(j.first),S2[++top2]=find(j.second);
        sort(S2+1,S2+top2+1); top2=unique(S2+1,S2+top2+1)-S2-1;
        for (re auto j:vec[i]) {
            s[lower_bound(S2+1,S2+top2+1,find(j.first))-S2].push_back(j.first);
            s[lower_bound(S2+1,S2+top2+1,find(j.second))-S2].push_back(j.second);
        }
        for (re int j=1;j<=top2;++j) { ++tot;
            sort(s[j].begin(),s[j].end());
            addEdge(s[j][0],tot),addEdge(tot,s[j][0]);
            for (re int k=1;k<s[j].size();++k)
                if (s[j][k]!=s[j][k-1]) addEdge(s[j][k],tot),addEdge(tot,s[j][k]);
            s[j].clear();
        }
        for (re auto j:vec[i]) {
            int u=j.first,v=j.second;
            f[u]=u,f[v]=v;
        }
    }
    bfs(); --dis[n];
    if (dis[n]<0) puts("-1");
    else printf("%d\n",dis[n]>>1);
    return 0;
}


Measured memory_bytes: 34816
#include <bits/stdc++.h>
#include <cmath>
#include <iostream>
using namespace std;
typedef long long ll;
#define INF 1LL<<62
#define inf 1000000007
int main() {
	long double a,b,h,m;
	cin>>a>>b>>h>>m;
	long double A=h*30.0+m/2.0;
	long double B=6.0*m;
	long double now=double(abs(A-B));
	now=now*2.0*M_PI/360.0;
	now= double(cos( now));
     double ans=a*a+b*b-2.0*a*b*now;
	ans=sqrt(ans);
	cout <<printf("%.10f",ans);
	// your code goes here
	return 0;
}


Measured memory_bytes: 4164
fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    let mut buf = String::new();
    std::io::stdin().read_line(&mut buf).ok();
    buf.trim()
        .split(' ')
        .map(|x| x.parse().ok().unwrap())
        .collect()
}

fn main() {
    let q: Vec<i64> = read_vec();
    let (n, m) = (q[0], q[1]);
    let mut shops: Vec<Vec<i64>> = (0..n).map(|_| read_vec()).collect();
    shops.sort_by_key(|s| s[0]);

    let mut ans = 0;
    let mut rest = m;
    for s in shops {
        if s[1] >= rest {
            ans += s[0] * rest;
            break;
        } else {
            ans += s[0] * s[1];
            rest -= s[1];
        }
    }
    println!("{}", ans);
}


Measured memory_bytes: 10492