akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define BIT(n) (1LL << (n))
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPB(i, n) for (int i = 0; i < BIT(n); i++)
#define REPS(i, x) for (int i = 1; i <= (int)(x); i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define FORA(i, n) for (auto &&i : n)
#define FORS(i, m, n) for (int i = m; i <= n; i++)
#define DEBUG(x) cerr << #x <<": "<<x<<"\n"
#define ALL(v) v.begin(), v.end()
#define fst first
#define snd second
#define mp make_pair
#define pb push_back
#define epb emplace_back
#define int long long
using namespace std;
template <class T> using vec = std::vector<T>;
template <class T = int> T in(){T x; cin>>x;return(x);}
template <class T > void print(T& x){cout<<x<<"\n";}
typedef long long ll;
const int MOD = 1000000007;
const int INF = 1061109567;
const double EPS = 1e-10;
const double PI  = acos(-1.0);
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N=in<int>(),K=in<int>();
  vec<int>a(N);
  int sum=0;
  REP(i,N){
      cin>>a[i];
      sum+=a[i];
  }
 // cout <<sum<<endl;
  vec<int>ret;
  for(int i = 1; i * i <= sum; i++) {
    if(sum % i == 0) {
      ret.pb(i);
      if(i * i != sum) ret.pb(sum / i);
    }
  }
  sort(ALL(ret));
  reverse(ALL(ret));
//  if (a[i])
int ans=1;
REP(j,(int)ret.size()){
    int num = ret[j];
    int sum=0;
    int val=0;
    vec <int>modL;
    REP(i,N){
        int mo = a[i]%num;
        if (mo>num-mo){
            val+=num-mo;
            sum+=num-mo;
            modL.pb(mo-num);
        }else{
            val+=mo;
            sum+=-mo;
            modL.pb(mo);
        }
    
    }
    bool minusflg=false;
    sort(ALL(modL));
    if (sum<0){
        minusflg=true;
        reverse(ALL(modL));
        sum*=-1;
    }
    sum/=num;
  //  DEBUG(num);
    int realsum=0;
    /* REP(i,N){
        cout <<modL[i]<<" ";
    }*/
//    cout<<endl<<num<<endl;
    REP(i,sum){
        modL[i]+=minusflg?-num:num;
    //    cout <<modL[i]<<" ";
    }
//    cout <<endl;
    REP(i,N){
        realsum+=abs(modL[i]);
    }
   // cout <<endl;
  //  cout <<num<< " "<< val <<" " <<sum<<" "<<realsum<<endl<<endl;
    if (realsum<=K*2){
        ans=num;
        break;
    }
}
cout <<ans<<endl;

}

Measured memory_bytes: 256
// Author : Mohamed Sameh
#include <bits/stdc++.h>
typedef long long ll ;
#define pb push_back
#define f first
#define s second
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define SZ(a) (int)a.size()
#define Flush fflush(stdout);
using namespace std ;
const int N = 21, M = 1e9 + 7;
ll dp[N][(1<<N)];
int n;
int a[N][N];
ll solve(int idx = 0, int msk = 0)
{
  if (idx == n)return 1;
  ll &ret = dp[idx][msk];
  if (~ret)return ret;
  ret = 0;
  for (int i = 0; i < n; i++)
  {
    if ( (msk & (1 << i)) || !a[idx][i])continue ;
    ret = (ret + solve(idx+1, (msk | (1<<i))))%M;
  }
  return ret;
}
int main()
{
  cin >> n;
  for (int i = 0; i < n; i++)
    for (int j = 0; j < n; j++)
      cin >> a[i][j];
  memset(dp, -1, sizeof dp);
  cout << solve() <<"\n";
}


Measured memory_bytes: 347692
/******************************************************************************

                            Online Java Compiler.
                Code, Compile, Run and Debug java program online.
Write your code in this editor and press "Run" button to execute it.

*******************************************************************************/
import java.util.*;
public class Main
{
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		long k = sc.nextLong();
		int q = sc.nextInt();
		n = n + 1;
		long []a = new long[n];
		int i;
		for(i=0; i<q; i++)
		{
		    int x = sc.nextInt();
		    ++a[x];
		}
		for(i=1; i<n; i++)
		{
		    long x = k - (long)(q - a[i]);
		    if(x > 0)
		        System.out.println("Yes");
		    else
		        System.out.println("No");
		}
		
	}
}


Measured memory_bytes: 60500
#include<stdio.h>
int main()
{
  int N[3][3];
  int B[3][3];
  int nb, n;
  int i, j, k;
  i = 0;
  j = 0;
  while (j < 3)
  {    
  	k = 0;
  	while (k < 3)
  	{
      B[j][k] = 0;
      k++;
     }
     j++;
  }
  while (i < 3)
  {
    scanf("%d %d %d", &N[i][0], &N[i][1], &N[i][2]);
    i++;
  }
  scanf("%d", &nb);
  i = 0;
  while (i < nb)
  {
    scanf("%d", &n);
    j = 0;
    while (j < 3)
    {
      k = 0;
      while (k < 3)
      {
        if (n == N[j][k])
        {
          B[j][k] = 1;
        }
        k++;
      }
      j++;
    }
    i++;
  }
  //行
  i = 0;
  while (i < 3)
  {
    if (B[i][0] + B[i][1] + B[i][2] == 3)
    {
      printf("Yes");
      return (0);
    }
    i++;
  }
  //列
  i = 0;
  while (i < 3)
  {
    if (B[0][i] + B[1][i] + B[2][i] == 3)
    {
      printf("Yes");
      return (0);
    }
    i++;
  }
  //斜め
  if (B[0][0] + B[1][1] + B[2][2] == 3)
    {
      printf("Yes");
      return (0);
    }
  else if (B[2][0] + B[1][1] + B[0][2] == 3)
    {
      printf("Yes");
      return (0);
    }
  printf("No");
  return (0);
}

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

int main(){
	int h, w; cin >> h >> w;
	string s[h];
	for(int i = 0; i < h; ++i) cin >> s[i];
	string ans[h];
	for(int i = 0; i < h; ++i){
		for(int j = 0; j < w; ++j){
			if(s[i][j] == '#'){
				ans[i] += '#';
			}else{	
				int po = 0;
				for(int k = -1; k <= 1; ++k){
					for(int l = -1; l <= 1; ++l){
						if(i + k < 0 || i + k >= h || j + l < 0 || j + l >= w) continue;
						if(s[i + k][j + l] == '#') ++po;
					}
				}
				ans[i] += po + '0';
			}
		}
		cout << ans[i] << endl;
	}
	return 0;
}

Measured memory_bytes: 256
def make(a, b)
  ret = []
  arr = ["B"]*(a+b)
  (a+b).times.map{|i| i}.combination(a).to_a.each do |x|
    x.each{ |j| arr[j] = "A" }
    ret << arr.join
    arr = ["B"]*(a+b)
  end
  ret
end
def make2(a, b)
  if a == 5
    make(a-1, b).map{|s| s + "A"}
  else
    make(a, b-1).map{|s| s + "B"}
  end
end
a, b = gets.split.map(&:to_i)
if a <= 4 && b <= 4
  arr = make(a, b)
elsif (a == 5 || b == 5) && a + b < 10
  arr = make2(a, b)
else
  x = make2(5, 4)
  y = make2(4, 5)
  if a == 5 && b == 5
    arr = (x.map{|s| s + "B"} + y.map{|s| s + "A"}).sort
  elsif a == 6
    arr = x.map{|s| s + "A"}
  else
    arr = y.map{|s| s + "B"}
  end
end
arr.each{|res| puts res}

Measured memory_bytes: 8744
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] a = new int[n];
        int[] b = new int[n];
        int max = 0;
        for (int i = 0; i < n; i++) {
            a[i] = sc.nextInt();
            b[i] = sc.nextInt();
            max = Math.max(a[i], max);
        }

        for (int i = 0; i < n; i++) {
            if (a[i] == max) {
                System.out.println(a[i] + b[i]);
                return ;
            } 
        }
    }
}

Measured memory_bytes: 87264
import sys

sys.setrecursionlimit(200000)


def input():
    return sys.stdin.readline()[:-1]


def ii(t: type = int):
    return t(input())


def il(t: type = int):
    return list(map(t, input().split()))


def imi(N: int, t: type = int):
    return [ii(t) for _ in range(N)]


def iml(N: int, t: type = int):
    return [il(t) for _ in range(N)]


def solve():
    N, M = il()
    food = {i: 0 for i in range(1, M + 1)}
    for n in range(N):
        i = il()
        for x in i[1:]:
            food[x] += 1
    ans = 0
    for f in food:
        if food[f] == N:
            ans += 1
    return ans


if __name__ == "__main__":
    print(solve())


Measured memory_bytes: 3064
#include <vector> 
#include <list> 
#include <map> 
#include <set> 
#include <deque> 
#include <queue> 
#include <stack> 
#include <bitset> 
#include <algorithm> 
#include <functional> 
#include <numeric> 
#include <utility> 
#include <sstream> 
#include <iostream> 
#include <iomanip> 
#include <cstdio> 
#include <cmath> 
#include <cstdlib> 
#include <cctype> 
#include <string> 
#include <cstring> 
#include <ctime> 

using namespace std;

#define _int64 long long

int a[11000];
int ans[110][110];

int main()
{
  int i,j,w,h,n,now,cnt;
  scanf("%d%d",&w,&h);
  scanf("%d",&n);
  for (i=0;i<n;i++)
    scanf("%d",&a[i]);
  now=0;
  cnt=0;
  for (i=0;i<w;i++)
    if (i%2==0)
    {
      for (j=0;j<h;j++)
      {
        ans[i][j]=now;
        cnt++;
        if (cnt==a[now])
        {
          now++;cnt=0;
        }
      }
    }
    else
    {
      for (j=h-1;j>=0;j--)
      {
        ans[i][j]=now;
        cnt++;
        if (cnt==a[now])
        {
          now++;cnt=0;
        }
      }
    }
  for (i=0;i<w;i++)
  {
    for (j=0;j<h;j++)
      printf("%d ",ans[i][j]+1);
    printf("\n");
  }
  return 0;
}

Measured memory_bytes: 384
#[allow(unused_imports)]
use std::mem::swap;
#[allow(unused_imports)]
use std::cmp::{max, min};
#[allow(unused_imports)]
use std::collections::{VecDeque, HashSet, BTreeSet, BinaryHeap, HashMap};
#[allow(unused_imports)]
use std::io::{stdin, stdout, Write, BufReader, BufWriter};
#[allow(unused_imports)]
use std::io::prelude::BufRead;
 
 
fn main() {
    let vec = read_vector::<usize>();
    let mut n = vec[0];
    let mut m = vec[1];
    let mut s = read_chars();
    let mut t = read_chars();

    if n > m {
        swap(&mut n, &mut m);
        swap(&mut s, &mut t);
    }

    let div = euclid(n, m);

    for i in 0..n {
        if (m * i) % n != 0 {
            continue;
        }
        let j = (m * i) / n;
        if s[i] != t[j] {
            println!("-1");
            return;
        }
    }

    println!("{}", div * (n / div) * (m / div));
    
}

fn euclid(a: usize, b: usize) -> usize {
    let mut x = b;
    let mut y = a;
    loop {
        let tmp = x % y;
        if tmp == 0 {
            return y;
        }
        x = y;
        y = tmp;
    }
}

#[allow(dead_code)]
fn read<T>() -> T where T: std::str::FromStr, T::Err: std::fmt::Debug {
    let mut buf = String::new();
    stdin().read_line(&mut buf).unwrap();
    return buf
        .trim()
        .parse()
        .unwrap();
}
 
#[allow(dead_code)]
fn read_vector<T>() -> Vec<T> where T: std::str::FromStr, T::Err: std::fmt::Debug {
    let mut buf = String::with_capacity(100);
    stdin().read_line(&mut buf).unwrap();
    return buf
        .split_whitespace()
        .map(|s| s.parse().unwrap())
        .collect();
}
 
#[allow(dead_code)]
fn read_matrix<T>() -> Vec<Vec<T>> where T: std::str::FromStr, T::Err: std::fmt::Debug {
    use std::io::prelude::*;
    let stdin = stdin();
    let mut reader = BufReader::with_capacity(100 * 1024, stdin);
    let mut line = String::with_capacity(100);
    let mut matrix: Vec<Vec<T>> = Vec::new();
 
    while reader.read_line(&mut line).unwrap() > 0 {
        matrix.push(line
            .trim()
            .split_whitespace()
            .map(|s| s.parse().unwrap())
            .collect());
        line.clear();
    }
 
    return matrix;
}

#[allow(dead_code)]
fn read_chars() -> Vec<char> {
    let stdin = stdin();
    let mut buf = String::new();
    let _bytes = stdin.read_line(&mut buf).unwrap();
    return buf.chars().collect();
}

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

using System.Collections;

class Program
{
    static void Main()
    {
        int[] nmxy = Console.ReadLine().Split(' ').Select(s => int.Parse(s)).ToArray();

        int N = nmxy[0];
        int M = nmxy[1];
        int X = nmxy[2];
        int Y = nmxy[3];

        int[] xList = Console.ReadLine().Split(' ').Select(s => int.Parse(s)).ToArray();
        int[] yList = Console.ReadLine().Split(' ').Select(s => int.Parse(s)).ToArray();

        int xMax = xList.Max();
        int yMin = yList.Min();

        if(xMax < yMin && X < yMin && xMax < Y)
        {
            Console.WriteLine("No War");
        }
        else
        {
            Console.WriteLine("War");
        }
    }
}


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

#define INF int(1e9)
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,n) for(int i=1;i<=(n);i++)
#define mp make_pair
#define pb push_back
#define fst first
#define snd second
typedef long long ll;
typedef pair<int,int> pii;

const int maxn=300005;
const int mod=998244353;
int n,ans;
ll A,B,K;
int fac[maxn],ifac[maxn];

ll gcd(ll a,ll b){
	return !b?a:gcd(b,a%b);
}
int C(int a,int b){
	if(a<b||a<0||b<0)return 0;
	return 1LL*fac[a]*ifac[b]%mod*ifac[a-b]%mod;
}

int main(){
	scanf("%d%lld%lld%lld",&n,&A,&B,&K);
	fac[0]=fac[1]=ifac[0]=ifac[1]=1;
	for(int i=2;i<=n;i++){
		fac[i]=1LL*fac[i-1]*i%mod;
		ifac[i]=1LL*ifac[mod%i]*(mod-mod/i)%mod;
	}
	REP(i,n)ifac[i]=1LL*ifac[i-1]*ifac[i]%mod;
	ll d=gcd(A,B);
	if(K%d){
		puts("0");
		return 0;
	}
	A/=d;B/=d;K/=d;
	rep(i,n+1){
		if(K-A*i<0||(K-A*i)%B||(K-A*i)/B>n)continue;
		int j=(K-A*i)/B;
		ans+=1LL*C(n,i)*C(n,j)%mod;
		if(ans>=mod)ans-=mod;
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 2560
#include <bits/stdc++.h>
using namespace std;
using lint     = long long;
const lint inf = 1LL << 60;
const lint mod = 1000000007;

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    set<char> s;
    for (int i = 0; i < n; ++i) {
        char a;
        cin >> a;
        s.insert(a);
    }
    if (s.size() == 3)
        cout << "Three"
             << "\n";
    else
        cout << "Four"
             << "\n";
    return 0;
}

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

int main()
{
    long long N, X, M;
    cin >> N >> X >> M;

    vector<pair<long long, long long>> first(M, make_pair(0, -1));

    long long current = 0;
    for (long long i = 1; i <= N; i++)
    {
        X %= M;
        current += X;
        if (first[X].second == -1)
        {
            first[X] = make_pair(current, i);
        }
        else
        {
            long long period = i - first[X].second;
            long long loop = max(0ll, (N - i) / period - 1);
            current += loop * (current - first[X].first);
            i += loop * period;
        }
        X *= X;
    }
    cout << current << endl;
}


Measured memory_bytes: 4836
#include<iostream>
#include<algorithm>
#define MAX 2000001
using namespace std;
int n,A[MAX],C[10001]={0},B[MAX];
void counting_sort(void){
    for(int i=0;i<n;i++){
        C[A[i]]++;
    }
    for(int i=1;i<10001;i++){
        C[i] += C[i-1];
    }
    for(int j=n-1;j>=0;j--){
        B[C[A[j]]-1] = A[j];
        C[A[j]]--;
    }
}
int main(void){
    cin >> n;
    for(int i=0;i<n;i++){
        cin >> A[i];
        //cout << A[i] << endl;
    }
    counting_sort();
    for(int i=0;i<n;i++){
        if(i!=0){
            cout << ' ';
        }
        cout << B[i];
    }
    cout << endl;
    return 0;
}


Measured memory_bytes: 18724
import java.io.*;
import java.util.*;

public class Main {
  private static int width(long v) {
    int w = 0;
    while (v > 0) {
      v /= 10;
      w++;
    }
    return w;
  }
  
  private static int solve(long n) {
    int answer = Integer.MAX_VALUE;
    for (long k = 1; k * k <= n; k++) {
      if (n % k != 0) {
        continue;
      }
      answer = Math.min(answer, width(n / k));
    }
    return answer;
  }
  
  private static void execute(ContestReader reader, PrintWriter out) {
    long n = reader.nextLong();
    out.println(solve(n));
  }
  
  public static void main(String[] args) {
    ContestReader reader = new ContestReader(System.in);
    PrintWriter out = new PrintWriter(System.out);
    execute(reader, out);
    out.flush();
  }
}

class ContestReader {
  private BufferedReader reader;
  private StringTokenizer tokenizer;
  
  ContestReader(InputStream in) {
    reader = new BufferedReader(new InputStreamReader(in));
  }
  
  public String next() {
    while (tokenizer == null || !tokenizer.hasMoreTokens()) {
      try {
        tokenizer = new java.util.StringTokenizer(reader.readLine());
      } catch (Exception e) {
        throw new RuntimeException(e);
      }
    }
    return tokenizer.nextToken();
  }
  
  public int nextInt() {
    return Integer.parseInt(next());
  }
  
  public long nextLong() {
    return Long.parseLong(next());
  }
  
  public double nextDouble() {
    return Double.parseDouble(next());
  }
  
  public String[] next(int n) {
    String[] array = new String[n];
    for (int i = 0; i < n; i++) {
      array[i] = next();
    }
    return array;
  }
  
  public int[] nextInt(int n) {
    int[] array = new int[n];
    for (int i = 0; i < n; i++) {
      array[i] = nextInt();
    }
    return array;
  }
  
  public long[] nextLong(int n) {
    long[] array = new long[n];
    for (int i = 0; i < n; i++) {
      array[i] = nextLong();
    }
    return array;
  }
  
  public double[] nextDouble(int n) {
    double[] array = new double[n];
    for (int i = 0; i < n; i++) {
      array[i] = nextDouble();
    }
    return array;
  }
  
  public char[] nextCharArray() {
    return next().toCharArray();
  }
  
  public int[][] nextInt(int n, int m) {
    int[][] matrix = new int[n][m];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        matrix[i][j] = nextInt();
      }
    }
    return matrix;
  }
  
  public long[][] nextLong(int n, int m) {
    long[][] matrix = new long[n][m];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        matrix[i][j] = nextLong();
      }
    }
    return matrix;
  }
  
  public double[][] nextDouble(int n, int m) {
    double[][] matrix = new double[n][m];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        matrix[i][j] = nextDouble();
      }
    }
    return matrix;
  }
  
  public char[][] nextCharArray(int n) {
    char[][] matrix = new char[n][];
    for (int i = 0; i < n; i++) {
      matrix[i] = next().toCharArray();
    }
    return matrix;
  }
}


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

using namespace std;

int dp[100000][3];

int main()
{
	int n;
	cin >> n;
	for (int i = 0; i < n; i++)
	{
		int a, b, c;
		cin >> a >> b >> c;
		if (i == 0)
		{
			dp[i][0] = a;
			dp[i][1] = b;
			dp[i][2] = c;
		}
		else
			for (int j = 0; j < 3; j++)
				for (int k = 0; k < 3; k++)
					if (j != k)
						dp[i][j] = max(dp[i][j], dp[i - 1][k] + (j == 0 ? a : (j == 1 ? b : c)));
	}
	cout << max({dp[n - 1][0], dp[n - 1][1], dp[n - 1][2]});

	return 0;
}


Measured memory_bytes: 1408
using System;
using System.Linq;
using System.Collections.Generic;
// Gluttony
namespace E
{
    class Program
    {
        static long Solve(int n, long k, List<long> a, List<long> f)
        {
            a.Sort();
            f.Sort();
            f.Reverse();
            var scores = a.Zip(f, (ai, fi) => new { ai, fi });
            var max = scores.Select(s => s.ai * s.fi).Max();

            Func<long, bool> pred = x =>
            {
                return scores.Select(score => Math.Max(0, score.ai - x / score.fi)).Sum() <= k;
            };

            //Func<long, long, long> binarySearch = null;
            //binarySearch = (start, end) => {
            //    if (start + 1 >= end)
            //    {
            //        return pred(start)
            //        ? start
            //        : end;
            //    }
            //    var m = (start + end) / 2;
            //    return pred(m)
            //        ? binarySearch(start, m)
            //        : binarySearch(m, end);
            //};

            //return binarySearch(0, max);

            // another version of binary search
            long start = -1;
            long end = max;
            while (Math.Abs(start - end) > 1)
            {
                long m = (start + end) / 2;
                if (pred(m))
                {
                    end = m;
                }
                else
                {
                    start = m;
                }
            }
            return end;

        }


        static void Main(string[] args)
        {
            string[] line = Console.ReadLine().Split(' ');
            int n = Convert.ToInt32(line[0]);
            long k = Convert.ToInt64(line[1]);
            var a = Console.ReadLine().Split(' ').Select(x => Convert.ToInt64(x));
            var f = Console.ReadLine().Split(' ').Select(x => Convert.ToInt64(x));
            Console.Write(Solve(n, k, a.ToList(), f.ToList()));

        }
    }
}


Measured memory_bytes: 48756
#include<bits/stdc++.h>
#define pb push_back
#define rep(i,a,b) for(int i=a;i<=b;++i)
#define per(i,b,a) for(int i=b;i>=a;--i)
#define gcd(a,b) __gcd(a,b)
#define MEM(a,x) memset(a,x,sizeof(a))
#define VI vector<int>
#define ll long long
#define INF 0x3f3f3f3f
using namespace std;
const int N=2e5+5;
template<class T>inline void read(T &res)
{
char c;T flag=1;
while((c=getchar())<'0'||c>'9')if(c=='-')flag=-1;res=c-'0';
while((c=getchar())>='0'&&c<='9')res=res*10+c-'0';res*=flag;
}
int a,b,c;
int main(){
    cin>>a>>b>>c;
    swap(a,b);swap(a,c);
    printf("%d %d %d\n",a,b,c);
	return 0;
}


Measured memory_bytes: 256
from collections import defaultdict

def factorize(N):
    p = 2
    PRIME = []
    while p * p <= N:
        if N % p == 0:
            N //= p
            PRIME.append(p)
        else:
            p += 1
    if N > 1:
        PRIME.append(N)
    return PRIME


n, p = map(int, input().split())

prime = factorize(p)
cnt = defaultdict(int)
for i in prime:
    cnt[i] += 1
ans = 1
for j in cnt:
    if cnt[j] >= n:
        ans *= j**(cnt[j]//n)
print(ans)


Measured memory_bytes: 38512
#include<math.h>
#include<map>
#include<iostream>
#include <algorithm>
#include <string>
#include<vector>
#include<array>
#include<tuple>
#include<queue>
#include<stack>
#include<iomanip>
#include<bitset>
#include <list>
#include<numeric>
//AtCoderC++.cpp

using namespace std;


inline int ceileing(int a, int b) {return a % b == 0 ? a / b : a / b + 1;}
int main() {
	int N, T; cin >> N >> T;
	auto as = vector<long long>(N);
	for (size_t i = 0; i < N; i++) cin >> as[i];
	auto gain = vector<long long>(N, 0);
	auto max_value = as[N - 1];
	auto answer = 0;
	auto max_gain = 0;
	for (int i = N - 2; i >= 0; --i) {
		max_value = max(max_value, as[i]);
		gain[i] = max_value - as[i];
		if (max_gain == gain[i]) {
			++answer;
		} else if (max_gain < gain[i]) {
			max_gain = gain[i];
			answer = 1;
		}
	}
	cout << answer << endl;
}


Measured memory_bytes: 1792
from math import sqrt
n,d=map(int,input().split())
x=[list(map(int,input().split())) for i in range(n)]

ans=0
tmp=0

for i in range(n):
  for j in range(i+1, n):
    xi,xj = x[i],x[j]
    for k in range(d):
      tmp += (xi[k]-xj[k]) ** 2  
    if sqrt(tmp)%1==0:
      tmp=0
      ans += 1
    else:
      tmp=0

print(ans)



Measured memory_bytes: 3064
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include<iterator>
#include<complex>
#include<stack>
#include<sstream>
using namespace std;
typedef  long long int lint;
typedef pair<int, int> P;
typedef pair<lint, lint> LLP;
typedef pair<char, char>CP;
#define rep(i, n) for (int i = 0; i < n; i++)
#define repr(i, n) for (int i = n; i >= 0; i--)
#define sort(v) sort((v).begin(), (v).end())
#define reverse(v) reverse((v).begin(), (v).end())
#define upper(v,hoge) upper_bound(v.begin(),v.end(),hoge)
#define lower(v,hoge) lower_bound(v.begin(),v.end(),hoge)
#define llower(v,hoge) *lower_bound(v.begin(), v.end(), hoge)
#define lupper(v,hoge) *upper_bound(v.begin(), v.end(), hoge)
/*
vector<char>al(26);
al = {'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
vector<char>AL(26);
AL = {'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'};
vector<char>NUM(10);
	NUM = { '0','1','2' ,'3' ,'4' ,'5' ,'6' ,'7' ,'8' ,'9' };
*/



int main() {
	int R, G;
	cin >> R >> G;
	cout << 2 * G - R << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
#define mp make_pair
#define PI pair<ll,ll>
#define poly vector<ll>
#define mem(a) memset((a),0,sizeof(a))
#define For(i,l,r) for(int i=(int)(l);i<=(int)(r);i++)
#define Rep(i,r,l) for(int i=(int)(r);i>=(int)(l);i--)
#define pb push_back
#define fi first
#define se second
#define SZ(x) ((int)(x.size()))
inline char gc(){
    static char buf[100000],*p1=buf,*p2=buf;
    return p1==p2&&(p2=(p1=buf)+fread(buf,1,100000,stdin),p1==p2)?EOF:*p1++;
}
#define gc getchar
inline ll read(){
	ll x = 0; char ch = gc(); bool positive = 1;
	for (; !isdigit(ch); ch = gc())	if (ch == '-')	positive = 0;
	for (; isdigit(ch); ch = gc())	x = x * 10 + ch - '0';
	return positive ? x : -x;
}
inline void write(ll a){
    if(a<0){
    	a=-a; putchar('-');
	}
    if(a>=10)write(a/10);
    putchar('0'+a%10);
}
inline void writeln(ll a){write(a); puts("");}
inline void wri(ll a){write(a); putchar(' ');}
ll rnd(){
	ull ans=0;
	For(i,0,4)ans=ans<<15^rand();
	return ans%((ull)1<<63);
}
const int N=3005,mod=998244353;
ll dp[N][N];
void add(ll &a,ll b){
	a=(a+b)%mod;
}
int main(){
	#ifdef Brollan
		freopen("1.in","r",stdin);
	#endif
	int a=read(),b=read(),c=read(),d=read();
	dp[a][b]=1;
	For(i,a,c){
		ll sum=0;
		For(j,b,d){
			sum=sum*i%mod;
			add(dp[i+1][j],sum+dp[i][j]*j);
			sum=(sum+dp[i][j])%mod;
		}
	} 
	For(i,b+1,d)dp[c][i]=(dp[c][i]+dp[c][i-1]*c)%mod;
	cout<<dp[c][d]<<endl;
}


Measured memory_bytes: 73996
#![allow(unused, non_snake_case, dead_code, non_upper_case_globals)]
use std::cmp::*;
use std::collections::*;
use std::mem::*;

fn main() {
    let (r, w, e) = (std::io::stdin(), std::io::stdout(), std::io::stderr());
    let mut io = IO::new(r.lock(), w.lock(), e.lock());
    let (n, k) = (io.read::<usize>(), io.read::<usize>());

    let mut ans = 0f64;
    // (1/2)^X
    for init in 1..n + 1 {
        let mut cnt = 0;
        let mut now = init;
        while now < k {
            now <<= 1;
            cnt += 1;
        }
        let mut pr = 1f64;
        for _ in 0..cnt {
            pr *= 0.5;
        }
        ans += pr / n as f64;
    }
    io.writeln(ans);
}

static MX: usize = 1010101;
static MOD: i64 = 1000000007;
static INF: i64 = std::i64::MAX >> 1;
// IO
use std::io::*;
struct IO<R: Read, W: Write, E: Write> {
    Read: R,
    Write: BufWriter<W>,
    Error: BufWriter<E>,
}
impl<R: Read, W: Write, E: Write> IO<R, W, E> {
    fn new(r: R, w: W, e: E) -> IO<R, W, E> {
        IO {
            Read: r,
            Write: BufWriter::new(w),
            Error: BufWriter::new(e),
        }
    }
    fn read<T>(&mut self) -> T
    where
        T: std::str::FromStr,
    {
        let next: String = self
            .Read
            .by_ref()
            .bytes()
            .map(|c| c.unwrap() as char)
            .skip_while(|c| c.is_whitespace())
            .take_while(|c| !c.is_whitespace())
            .collect();
        next.parse().ok().unwrap()
    }
    fn chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
    fn chari(&mut self) -> Vec<i64> {
        self.chars()
            .iter()
            .map(|&c| (c as u8 - b'0') as i64)
            .collect::<Vec<i64>>()
    }
    fn readn<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read::<T>()).collect::<Vec<_>>()
    }
    fn readmat<T: std::str::FromStr>(&mut self, n: usize, m: usize) -> Vec<Vec<T>> {
        (0..n).map(|_| self.readn(m)).collect()
    }
    fn write<S: ToString>(&mut self, val: S) {
        self.Write.write(val.to_string().as_bytes());
    }
    fn writeln<S: ToString>(&mut self, val: S) {
        self.Write.write(val.to_string().as_bytes());
        self.Write.write(b"\n");
    }
    fn debug<S: std::fmt::Debug>(&mut self, val: S) {
        writeln!(self.Error, "(debug) {:?}", &val);
    }
    fn debug2<S: std::fmt::Debug, T: std::fmt::Debug>(&mut self, val1: S, val2: T) {
        writeln!(self.Error, "(debug2) {:?} -> {:?}", val1, val2);
    }
    fn debug3<S: std::fmt::Debug, T: std::fmt::Debug, U: std::fmt::Debug>(
        &mut self,
        val1: S,
        val2: T,
        val3: U,
    ) {
        writeln!(
            self.Error,
            "(debug3) {:?} -> {:?} -> {:?}",
            val1, val2, val3
        );
    }
}


Measured memory_bytes: 2184
#include<stdio.h>
#include<algorithm>
using namespace std;
char A[110];
char B[110];
int main(){
	int a;scanf("%d",&a);
	scanf("%s%s",A,B);
	int t=0;
	for(int i=1;i<=a;i++){
		bool ok=true;
		for(int j=0;j<i;j++)if(A[a-i+j]!=B[j])ok=false;
		if(ok)t=i;
	}
	printf("%d\n",a*2-t);
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
 
#define pb 		push_back
#define mp 		make_pair
#define prior   priority_queue
#define MOD 	1000000007
#define INF 	(long long int)9e18
#define EPS 	1e-9
#define PI 		3.1415926535897932384626433832795 
#define ll      long long int
#define ld		long double
#define ret     return
#define NUM 	1000001
const int SIZE = 2e5+4;
void fastio(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
}

void input(){
	#ifndef ONLINE_JUDGE
		freopen("input.txt","r",stdin);
		freopen("output.txt","w",stdout);
	#endif
}


int main(){
	fastio();
	input();
	
	ll n;
	cin>>n;
	ll p = 100;
	ll t=0;
	while(p<n){
		p = p + p/100;
		t++;
	}
	cout<<t<<endl;

	return 0;
}



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

int32_t main(){
	int n,a,b;
  cin>>n>>a>>b;
  int diff = abs(a-b);
  if(diff%2 == 0){
  	cout<<diff/2<<endl;
  }
  else{
    int p = n - max(a,b) + 1 + diff/2;
    int q = min(a,b) + diff/2;
    cout<<min(p,q)<<endl;
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cstring>
#include <string>
#include <cmath> 
#define ll long long
ll a[100005]={0};
using namespace std;
int main(){
	ll n;
	cin>>n;
	ll flag=1;
	ll ans=1;
	if(n%2==0){
		for(ll i=0;i<n;i++){
			ll x;
			cin>>x;
			a[x]++;
			if(x>=n || x%2==0 || a[x]>2){
				flag=0;
				cout<<"0"<<endl;
				break;
			}
			if(a[x]==1)
				ans=ans*2%1000000007;
		}
	} 
	else{
		for(ll i=0;i<n;i++){
			ll x;
			cin>>x;
			a[x]++;
			if(x>=n || x%2==1 || a[0]>1 ||a[x]>2){
				flag=0;
				cout<<"0"<<endl;
				break;
			}
			if(x!=0 && a[x]==1)
				ans=ans*2%1000000007;
		}
	}
	if(flag)
		cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 1024
n = gets.to_i
a = gets.split(' ').map(&:to_i)
b = gets.split(' ').map(&:to_i)
c = gets.split(' ').map(&:to_i)
sum = 0
n.times do |i|
  sum += b[a[i]-1]
  if i >= 1 && a[i-1] + 1 == a[i]
    sum += c[a[i-1]-1]
  end
end
puts sum


Measured memory_bytes: 1788
#include "bits/stdc++.h"
#include<random>
using namespace std;
typedef long long int lint;
typedef pair<lint, lint> plint;
typedef pair<double long, double long> pld;
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((lint)(x).size())
#define POW2(n) (1LL << (n))
#define FOR(i, begin, end) for(lint i=(begin),i##_end_=(end);i<i##_end_;i++)
#define IFOR(i, begin, end) for(lint i=(end)-1,i##_begin_=(begin);i>=i##_begin_;i--)
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
template<class T>bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }
template<typename T1, typename T2> pair<T1, T2> operator+(const pair<T1, T2>& l, const pair<T1, T2>& r) { return make_pair(l.first + r.first, l.second + r.second); }
template<typename T1, typename T2> pair<T1, T2> operator-(const pair<T1, T2>& l, const pair<T1, T2>& r) { return make_pair(l.first - r.first, l.second - r.second); }
const lint MOD = 1e9 + 7, INF = 1e18;

char mp[1000][1000];
lint H, W;
lint dp[1001][1001];
int main() {
	cin >> H >> W;
	REP(i, H) {
		REP(j, W) {
			cin >> mp[i][j];
			dp[i][j] = 0;
		}
	}
	dp[0][0] = 1;
	REP(i, H) {
		REP(j, W) {
			if (mp[i][j] != '#') {
				if (i - 1 >= 0) {
					dp[i][j] += dp[i - 1][j];
				}
				if (j - 1 >= 0) {
					dp[i][j] += dp[i][j - 1];
				}
				dp[i][j] %= MOD;
			}
		}
	}
	cout << dp[H - 1][W - 1] << endl;
}

Measured memory_bytes: 12376
S = input()
R_cnt = 1
L_cnt = 0
N = len(S)
d = [0]*N
check_point = 0
for i in range(1,N):
    if(S[i] == "R"):
        R_cnt += 1
        if(S[i-1] == "L"):
            d[check_point-1] += L_cnt//2
            d[check_point] += (L_cnt+1)//2
            L_cnt = 0
    elif(S[i] == "L"):
        L_cnt += 1
        if(S[i-1]=="R"):
            d[i-1] += (R_cnt+1)//2
            d[i] += R_cnt//2
            check_point = i
            R_cnt = 0
d[check_point-1] += L_cnt//2
d[check_point] += (L_cnt+1)//2
print(" ".join(map(str,d)))

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

using namespace std;
int main() {
  long a, b, k;
  cin >> a >> b >> k;

  if (a < k)
    k -= a, a = 0;
  else {
    a -= k;
    cout << a << " " << b << endl;
    return 0;
  }

  if (b < k)
    k -= b, b = 0;
  else {
    b -= k;
  }
  cout << a << " " << b << endl;
  return 0;
}

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

class Program
{
    static void Main(string[] args)
    {
        var input = Console.ReadLine().Split();
        int A = int.Parse(input[0]);
        int B = int.Parse(input[1]);
        Console.WriteLine(Math.Max(Math.Max(A+B,A-B),A*B));
    }
}


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

#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)

#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=int(a)-1;i>=int(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)

#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define getidx(ary,key) lower_bound(_all(ary),key)-begin(ary)
#define clr(a,b) memset((a),(b),sizeof(a))
#define bit(n) (1LL<<(n))
#define popcount(n) (__builtin_popcountll(n))

using namespace std;

template<class T>bool chmax(T &a, const T &b) { return (a<b)?(a=b,1):0;}
template<class T>bool chmin(T &a, const T &b) { return (b<a)?(a=b,1):0;}

using ll=long long;
using R=long double;
const R EPS=1e-9L; // [-1000,1000]->EPS=1e-8 [-10000,10000]->EPS=1e-7
inline int sgn(const R& r){return(r > EPS)-(r < -EPS);}
inline R sq(R x){return sqrt(max(x,0.0L));}

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

// Problem Specific Parameter:

int main(void){
	int h,w;
	cin >> h >> w;
	rep(i,h){
		string s;
		cin >> s;
		cout << s << endl << s << endl;
	}
	return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {

  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);

    int N = Integer.parseInt(sc.nextLine());
    long[] as = new long[N];
    long[] dp = new long[N];
    String[] firstInput = sc.nextLine().split("[\\s]+");
    for(int i = 0; i < N; i++) {
      as[i] = Long.parseLong(firstInput[i]);
    }
    Arrays.sort(as);
    System.out.println(Math.abs(as[0] - as[N -1]));
  }
}


Measured memory_bytes: 21972
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Linq.Expressions;
using System.Text;
class Simple {
    string S;
    void Solve() {
        //input
        S = io.String;
        //cal
        var ans = S.Where(c => c == '1').Count();
        //ret
        Console.WriteLine(ans);
    }
    SimpleIO io = new SimpleIO();
    public static void Main(string[] args) { new Simple().Stream(); }
    void Stream() {
        Solve();
        io.writeFlush();
    }
}
class SimpleIO {
    SimpleIO(bool isAutoFlush = false) { this.isAutoFlush = isAutoFlush; }
    string[] nextBuffer;
    int BufferCnt;
    char[] cs = new char[] { ' ' };
    public bool isAutoFlush;
    StreamWriter sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
    public SimpleIO() {
        nextBuffer = new string[0];
        BufferCnt = 0;
        if(!isAutoFlush)
            Console.SetOut(sw);
    }
    public string Next() {
        if (BufferCnt < nextBuffer.Length)
            return nextBuffer[BufferCnt++];

        string st = Console.ReadLine();
        while (st == "")
            st = Console.ReadLine();
        nextBuffer = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
        BufferCnt = 0;
        return nextBuffer[BufferCnt++];
    }
    public string String => Next();
    public char Char => char.Parse(String);
    public int Int => int.Parse(String);
    public long Long => long.Parse(String);
    public double Double => double.Parse(String);
    public void writeFlush() { Console.Out.Flush(); }
}


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

int main()
{
	int N, T;
	scanf("%d%d", &N, &T);
	using vi = std::vector<int>;
	using vvi = std::vector<vi>;
	vi A(N), B(N);
	for (int i{}; i < N; i++)
		scanf("%d%d", &A[i], &B[i]);
	vvi dpLeft(N + 1, vi(T)), dpRight(N + 1, vi(T));
	for (int i{}; i < N; i++)
	{
		dpLeft[i + 1] = dpLeft[i];
		for (int j{}; j + A[i] < T; j++)
			dpLeft[i + 1][j + A[i]] = std::max(dpLeft[i + 1][j + A[i]], dpLeft[i][j] + B[i]);
	}
	for (int i{N - 1}; i >= 0; i--)
	{
		dpRight[i] = dpRight[i + 1];
		for (int j{}; j + A[i] < T; j++)
			dpRight[i][j + A[i]] = std::max(dpRight[i][j + A[i]], dpRight[i + 1][j] + B[i]);
	}

	// for (auto& e: dpLeft)
	// {
	// 	for (auto& f: e) printf("%d ", f);
	// 	putchar('\n');
	// }
	// putchar('\n');
	// for (auto& e: dpRight)
	// {
	// 	for (auto& f: e) printf("%d ", f);
	// 	putchar('\n');
	// }

	int max{};
	for (int i{}; i < N; i++)
		for (int j{}; j < T; j++)
			max = std::max(max, dpLeft[i][j] + dpRight[i + 1][T - 1 - j] + B[i]);
	printf("%d\n", max);

	return 0;
}

Measured memory_bytes: 70912
#include <iostream>
#include <cstdlib>
using namespace std;
typedef long long ll;

int main() {
	ll X, K, D;
	cin >> X >> K >> D;

    if (X / D >= K) {
        cout << X - K * D << endl;
    } else if ( X / D < -K) {
        cout << - (X + K * D) << endl;
    } else {
        if (K % 2 == 0){
            ll mod = X % (2*D);
            if (mod < 0) {
                cout << min(-mod, 2*D + mod) << endl; 
            } else {
                cout << min(mod, 2*D - mod) << endl; 
            }
        } else {
            ll mod = (X+D) % (2*D);
            if (mod < 0) {
                cout << min(-mod, 2*D + mod) << endl; 
            } else {
                cout << min(mod, 2*D - mod) << endl; 
            }
        }
    }

	return 0;
}

Measured memory_bytes: 3628
import java.io.IOException;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) throws IOException {
		new Main().run();
	}

	private void run() throws IOException {
		Scanner scanner = new Scanner(System.in);
		while (true) {
			int n = scanner.nextInt();
			if (n == 0)
				break;
			int[] num = new int[10];
			while (n-- > 0) {
				int a = scanner.nextInt();
				num[a]++;
			}
			for (int i = 0; i < 10; i++) {
				if (num[i] == 0)
					System.out.println("-");
				else {
					for (int j = 0; j < num[i]; j++) {
						System.out.print("*");
					}
					System.out.println();
				}
			}
		}
	}
}

Measured memory_bytes: 54120
#include <iostream>
#include <algorithm>
#include <cmath>
#include <stdio.h>
#include <stdlib.h>
#include <vector>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <string.h>
#include <stack>
#define Endl endl
#define mp make_pair
#define rep(N) for(int i=0;i<N;i++)
#define repj(N) for(int j=0;j<N;j++)
#define ll long long 
#define pii pair<int,int>
#define pll pair<ll,ll>
#define For(I,N) for(int I=0;I<N;I++)
#define cinone(N) int N;cin>>N;
#define scanfone(N) int N;cin>>N;
#define cinng(N,M) int N[M];for(int yiuytvnm=0;yiuytvnm<M;yiuytvnm++) cin>>N[yiuytvnm];
#define scanfng(N,M) int N[M];for(int qrwuoiq=0;qrwuoiq<M;qrwuoiq++) scanf("%d",&N[qrwuoiq]);
#define over(A) {cout<<A<<endl;exit(0);}
typedef unsigned long long ull;
const int inf=103974182;
using namespace std;
int n;
int a[200005];
map <ll,int> sum;

int main()
{
//	freopen("input.txt","r",stdin);
	cin>>n;
	for(int i=0;i<n;i++)
	{
		scanf("%d",a+i);
	}
	sum[0]=1;
	ll now=0;
	ll res=0;
	for(int i=0;i<n;i++)
	{
		now+=a[i];
		res+=sum[now];
		sum[now]++;
	}
	cout<<res<<endl;
	return 0;
}

Measured memory_bytes: 13568
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, acos, atan, asin
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd
def input(): return sys.stdin.readline().strip()
def STR(): return input()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def S_MAP(): return map(str, input().split())
def LIST(): return list(map(int, input().split()))
def S_LIST(): return list(map(str, input().split()))
sys.setrecursionlimit(10 ** 9)
inf = sys.maxsize
mod = 10 ** 9 + 7

h, w = MAP()
s = [STR() for _ in range(h)]
arr = [[inf for _ in range(w)] for _ in range(h)]
arr[0][0] = 0
que = deque([[0, 0]])
dy = [1, -1, 0, 0]
dx = [0, 0, 1, -1]
while len(que):
    y, x = map(int, que.popleft())
    for i in range(4):
        ny = y + dy[i]
        nx = x + dx[i]
        if 0 <= ny < h and 0 <= nx < w:
            tmp = arr[y][x]
            arr[y][x] = min(arr[y][x], arr[ny][nx] + 1)
            if arr[ny][nx] >= inf and s[ny][nx] == '.' and not [ny, nx] in que:
                que.append([ny, nx])
    if y == h - 1 and x == w - 1:
        break
if arr[h - 1][w - 1] >= inf:
    print(-1)
    exit()
ss = 0
for i in range(h):
    ss += s[i].count('.')
print(ss - arr[h - 1][w - 1] - 1)


Measured memory_bytes: 64088
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long a,b,c,d;
    cin>>a>>b>>c>>d;
    long long x,y,w,z;
    x=a*c;
    y=a*d;
    w=b*c;
    z=b*d;
    cout<<max(max(x,y),max(w,z))<<endl;
    return 0;
}


Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
const int N = 200005;

vector<int> g[N];
int room[N];

int main() {
  int n, m;
  cin >> n >> m;
  for (int i = 0; i < m; i++) {
    int a, b;
    cin >> a >> b;
    g[a].push_back(b);
    g[b].push_back(a);
  }
  queue<pair<int, int>> q;
  int sz = g[1].size();
  room[1] = 1;
  for (int i = 0; i < sz; i++) q.push({g[1][i], 1});
  while (!q.empty()) {
    pair<int, int> p = q.front();
    q.pop();
    if (room[p.first] == 0) {
      room[p.first] = p.second;
      sz = g[p.first].size();
      for (int i = 0; i < sz; i++) q.push({g[p.first][i], p.first});
    }
  }
  for (int i = 2; i <= n; i++) {
    if (room[i] == 0) {
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
  for (int i = 2; i <= n; i++) cout << room[i] << endl;
  return 0;
}

Measured memory_bytes: 14440
r1, c1, r2, c2 = list(map(int, input().split()))

mod = 1000000007

# return an integer k s.t. (a * k) % p = 1 and 0 <= k < p.
def inversion(a):
    b = mod
    u, v = 1, 0
    while b >= 1:
        t = a // b
        a -= t * b
        a, b = b, a
        u -= t * v
        u, v = v, u
    u %= mod
    if u < 0:
        u += mod
    return u

fact = [0 for i in range(2000003)]
for i in range(2000003):
    if i <= 1:
        fact[i] = 1
    else:
        fact[i] = (fact[i-1] * i) % mod

# return nCr % p.
def combination(n, r):
    return (((fact[n] * inversion(fact[r])) % mod) * inversion(fact[n-r])) % mod

answer = (
combination(r2 + c2 + 2, r2 + 1) -
combination(r2 + c1 + 1, r2 + 1) -
combination(r1 + c2 + 1, c2 + 1) +
combination(r1 + c1    , c1    ) )

answer %= mod

if answer < 0:
    answer += mod

print(answer)


Measured memory_bytes: 82200
#include<bits/stdc++.h>
#include <math.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define lper(i,r,l) for(ll i=r-1;i>=l;i--)
#define fi first
#define se second
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define CST(x) cout<<fixed<<setprecision(x)
using ll=long long;
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
using pl=pair<ll,ll>;
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9;
const ll INF=4e18;
const ll dy[4]={1,0,-1,0};
const ll dx[4]={0,-1,0,1};
int main() {
int N;
  cin >>N;
  vector<int> vec(N);
  rep(i,N) {
cin >>vec.at(i);
  }
  sort(all(vec));
  int count=0;
  rep(i,N-1) {
if(vec.at(i)==vec.at(i+1)) {
  count++;
}
   }
   
   
   cout<<N-count<< endl;
   }
  

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

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long ll;


#define SZ(x) ((int)(x).size())
#define BIT(n) (1ll<<(n))
#define SORT(c) sort((c).begin(),(c).end())
#define RALL(a) (a).rbegin(), (a).rend()
#define ALL(x) (x).begin(),(x).end()
#define PB push_back
#define MP make_pair
#define CLR(a) memset((a), 0 ,sizeof(a))
#define retrun return
#define INF 1000000010ll
#define MOD 1000000007ll
#define REP(i,a,b) for(int i=(a);i<(b);++i)
#define RREP(i,n)  
#define rep(i,n) for(int i=n-1;i>=0;--i)
#define COUT(str) cout << str << endl


template<class T>bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); }
template<class T> inline T sqr(T x) { return x*x; }

//------------------------------------------------------------------------------------------------------

int n;
int p[10];
int ma;
int sum;
//------------------------------------------------------------------------------------------------------

int main() {
	cin >> n;
	REP(i, 0, n) {
		cin >> p[i];
		ma = max(p[i], ma);
		sum += p[i];
	}

	COUT(sum - ma / 2);

	return 0;
}


Measured memory_bytes: 256