akhauriyash/Code-Regression huggingface dataset:
while true
  judge_size = gets.to_i
  break false if judge_size == 0
  numbers = []
  judge_size.times do |_|
    numbers << gets.to_i
  end
  sum = numbers.inject(0){|a,x| a + x }
  puts (sum - numbers.max - numbers.min) / (judge_size - 2)
end

Measured memory_bytes: 8688
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cstdlib>
using namespace std;
int main() {
  int N;
  cin >> N;
  int A[N-1];
  int sum=0;
  for(int i=0;i<N-1;i++){
    A[i]=0;
  }
  int tmp;
  for(int i=0;i<N-1;i++){
    cin >> tmp;
    A[tmp-1]++;
  }
  for(int i=0;i<N-1;i++){
    cout << A[i] << endl;
  }
  cout << '0';
  cout << endl;
  return 0;
}


Measured memory_bytes: 4380
import Data.List

combs _ [] = []
combs 1 xs = [[x] | x <- xs]
combs n (x:xs) = [x:y | y <- combs (n-1) xs] ++ combs n xs

main = getContents >>= print . calender_colors . read' . lines
 where read' (nm:cs) = (map read (words nm), sort (map (map read . words) cs))

calender_colors :: ([Int],[[Double]]) -> Double
calender_colors ([n,m],cs)
 | m < 2 = 0.0
 | otherwise = maximum (map total cs')
 where
  cs' = combs m cs
  total cs = sum [distance c1 c2| c1<-cs, c2<-cs, c1<c2]
  distance [l1,a1,b1] [l2,a2,b2] = (l2-l1)^2 + (a2-a1)^2 + (b2-b1)^2

Measured memory_bytes: 127400
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);
		int n = scanner.nextInt();
		int t = scanner.nextInt();
		int s = scanner.nextInt();
		int[] a = new int[n];
		int[] b = new int[n];
		for (int i = 0; i < n; i++) {
			a[i] = scanner.nextInt();
			b[i] = scanner.nextInt();
		}
		int[] dp = new int[t + 1];
		int ans = 0;
		for (int i = 0; i < n; i++)
			for (int j = t; j - b[i] >= 0; j--) {
				if (j - b[i] >= s || s >= j)
					dp[j] = Math.max(dp[j], dp[j - b[i]] + a[i]);
				ans = Math.max(ans, dp[j]);
			}
		System.out.println(ans);
	}
}

Measured memory_bytes: 29924
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <climits>
#include <cmath>
#include <map>
#include <queue>
#include <iomanip>
using namespace std;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++ )
#define repf(i,m,n) for(int (i)=m;(i)<n;(i)++)
#define all(v) (v).begin(), (v).end()
#define ll long long
#define vec(name,num) vector<ll> name((num),0);
#define op(i) cout<<(i)<<endl;
#define ip(i) cin>>(i);
#define opN cout<<"No"<<endl;
#define opY cout<<"Yes"<<endl;
#define opP cout<<"Possible"<<endl;
#define opI cout<<"Impossible"<<endl;
#define mat(name,fnum,snum); vector<vector<ll>> name((fnum),vector<ll>((snum),0));
#define matC(name,fnum,snum); vector<vector<char>> name((fnum),vector<char>((snum),0));
#define debugP int debug_point; cin>>debug_point;
#define FI first
#define SE second
const ll MOD= 1e9 + 7;
template <typename T>
void putv(vector<T>& V){
	// cout << "The elements in the vector are: " << endl;
	for(auto x: V)
		cout << x << " ";
	cout << endl;
}
ll pow_mod(ll fi,ll se,ll mod){
  if(se==0){
    return 1;
  }
  if(se%2){
    return pow_mod(fi,se-1,mod)*fi%mod;
  }
  ll t=pow_mod(fi,se/2,mod);
  return t*t%mod;
}
template <class T>
vector<T> getv(ll n){
	vector<T> Vector_temp;
	rep(i,n){
		T input;
		cin >> input;
		Vector_temp.emplace_back(input);
	}
	return Vector_temp;
}
ll gcd(ll c,ll b){
    while(1){
        if(c%b!=0){
        ll tmp=b;
        b=c%b;
        c=tmp;
        }else{
            return b;
        }
    }
}

vector<pair<int,int>> Dir={{-1,0},{1,0},{0,1},{0,-1}};
/* <3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3*/



vector<ll> dis((ll)100001,-1);
vector<vector<pair<ll,ll>>> edge(100000);

void dfs(ll now,ll dis_sum){
  for(auto itr=edge[now].begin(); itr!=edge[now].end(); itr++){
    if(dis[itr->first]==-1){
      dis[itr->first]=dis_sum+itr->second;
      dfs(itr->first,dis_sum+itr->second);
    }
  }
  return;
}


int main(){
  ll n;
  cin>>n;
  vec(a,n);
  vec(b,n);
  vec(c,n);
  rep(i,n-1){
    cin>>a[i]>>b[i]>>c[i];
    a[i]--;b[i]--;
    edge[a[i]].push_back(make_pair(b[i],c[i]));
    edge[b[i]].push_back(make_pair(a[i],c[i]));
  }
  ll q,k;
  cin>>q>>k;
  k--;
  dis[k]=0;
  dfs(k,0);
  rep(i,q){
    ll x,y;
    cin>>x>>y;
    cout<<dis[x-1]+dis[y-1]<<endl;
  }
  return 0;
}

Measured memory_bytes: 15104
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define endl "\n"
#define se second
#define ls( s) (s&(-s))
#define ll long long
#define inf 0x3f3f3f3f
#define fast    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
const int N = 2e5;
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
const ll mod =    1e9+7;

int main()
{  fast
int a,b,c,d;
cin>>a>>b>>c>>d;
while(1)
{
	c-=b;
	if(c<=0)
	{
		cout<<"Yes";
		return 0;
	}
	a-=d;
	if(a<=0)
	{
		cout<<"No";
		return 0;
	}
}
}


Measured memory_bytes: 3596
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<iostream>
#include<string>
#include<vector>
#include<stack>
#include<bitset>
#include<cstdlib>
#include<cmath>
#include<set>
#include<list>
#include<deque>
#include<map>
#include<queue>
#define INF 0x3f3f3f3f
using namespace std;
typedef long long ll;
int main()
{
    int n,m;
    scanf("%d%d",&n,&m);
    string a="";
    string b="";
    for(int i=0;i<n;i++)
        a+=(m+'0');
    for(int i=0;i<m;i++)
        b+=(n+'0');
    if(a<b)
        cout<<a<<endl;
    else
        cout<<b<<endl;
    return 0;
}





Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using lli = long long int;
#define filein freopen ("in.txt", "r", stdin)
#define fileout freopen ("out.txt", "w", stdout)
#define dbg(args...) do {cerr << #args << " : "; debug(args); } while(false)
#define all(v) ((v).begin()),((v).end())
#define size(x) (int) x.size() 
#define pb emplace_back
#define mp make_pair
#define PI 3.14159265
#define mod 1000000007
void debug () {cerr << endl;}
template< class T > T gcd(T a, T b) { return (b != 0 ? gcd<T>(b, a%b) : a); }
template< class T > T lcm(T a, T b) { return (a / gcd<T>(a, b) * b); }
template < typename T, typename ... hello>void debug( T arg, const hello &... rest) {cerr << arg << ' ';debug(rest...);}
int main(){
	ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int a;
    cin >> a;
    cout << (int) (a) + (a * a) + (a * a * a);
}
 


Measured memory_bytes: 3632
#標準入力を高速に
import sys 
input = sys.stdin.readline

#main関数(若干早くなる)
def main():
    N = int(input())
    INF = float("inf")
    #dp[i]...i円を引き出すのに必要な最小回数
    dp = [INF]*(N+1)
    dp[0] = 0

    #配るDP
    while dp[N] == INF:
        for i in range(N):
            if dp[i] != INF:
                dp[i+1] = min(dp[i]+1, dp[i+1])
                j = 1
                while i+6**j <= N:
                    dp[i+6**j] = min(dp[i]+1, dp[i+6**j])
                    j += 1
                k = 1
                while i+9**k <= N:
                    dp[i+9**k] = min(dp[i]+1, dp[i+9**k])
                    k += 1

    print(dp[N])
    

if __name__ == '__main__':
    main()




Measured memory_bytes: 46928
/*
これを入れて実行
g++ code.cpp
./a.out
 */
 
#include <iostream>
#include <vector>
#include <string>
#include <queue>
#include <deque>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <cmath>
#include <math.h>
#include <tuple>
#include <iomanip>
 
using namespace std;
typedef long long ll;
typedef long double ld;
 
int dy4[4] = {-1, 0, +1, 0};
int dx4[4] = {0, +1, 0, -1};
int dy8[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
int dx8[8] = {0, 1, 1, 1, 0, -1, -1, -1};
 
const long long INF = 1LL << 60;
const ll MOD = 1e9 + 7;
 
bool greaterSecond(const pair<int, int>& f, const pair<int, int>& s){
    return f.second > s.second;
}
 
ll gcd(ll a, ll b){
	if (b == 0)return a;
	return gcd(b, a % b);
}
 
ll lcm(ll a, ll b){
    return a / gcd(a, b) * b;
}
 
ll nCr(ll n, ll r){
    if(r == 0 || r == n){
        return 1;
    } else if(r == 1){
        return n;
    }
    return (nCr(n - 1, r) + nCr(n - 1, r - 1));
}
 
ll nPr(ll n, ll r){
    r = n - r;
    ll ret = 1;
    for (ll i = n; i >= r + 1; i--) ret *= i;
    return ret;
}
 
//-----------------------ここから-----------

int main(void){
    int a, b, c;
    cin >> a >> b >> c;

    if(a + b + c >= 22){
        cout << "bust" << endl;
    } else {
        cout << "win" << endl;
    }
}

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

using namespace std;

int main() {
	stack<int> st;
	int a,i;
	while(cin >> a){
		if (a == 0) {
			cout << st.top()<<endl;
			st.pop();
		}
		else {
			st.push(a);
		}
	}
	return 0;
}

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

//ask the right questions.  

// dp[i] means max length possible to reach vertex i (~item and not index) 
int dp[100001];

map<int,vector<int>> edgesendsat;       //ending at index M

void calculate(int i)
{
    vector<int> v = edgesendsat[i];
    int ans=0;
    for(int j=0;j<v.size();j++) 
    {
        //if v[j]>=i and dp[v[j]]=-1 then branch to calculating that dp[v[j]]
        if(dp[v[j]]==-1)
            calculate(v[j]); 
        ans = max(ans, dp[v[j]]);    
    }
    dp[i] = 1 + ans;
}


int main()
{
    int N,M;
    cin >> N >> M;
    int x,y;
    for(int i=0;i<M;i++) 
    {
        cin >> x >> y;
        if(edgesendsat.find(y)!=edgesendsat.end()) 
        {
            edgesendsat[y].push_back(x);
        }
        else 
        {
            edgesendsat.insert({y,{x}});
        }
    }

    //trivial case : since vertex numbering starts from 1
    dp[0]=0;

    //base case: 
    for(int i=1;i<=N;i++) {
        dp[i]=-1;             //2 purpose 
        if(edgesendsat.find(i)==edgesendsat.end())
            dp[i]=0;
    }


    for(int i=1;i<=N;i++)
     {
        //check if vertex can be reached 
        if(edgesendsat.find(i)!=edgesendsat.end()) 
        {
            vector<int> v = edgesendsat[i];
            int ans=0;
            for(int j=0;j<v.size();j++) 
            {
                //if dp[v[j]]=-1 then branch to calculating that dp[v[j]]
                if(dp[v[j]]==-1)
                    calculate(v[j]); 
                ans = max(ans, dp[v[j]]);    
            }
            dp[i] = 1 + ans;
        }
    }
    

    int ansterm=0;
    for(int i=1;i<=N;i++) {
        ansterm = max(ansterm, dp[i]);
    }
    cout << ansterm <<endl;

    return 0;
}



Measured memory_bytes: 26960
package main

import (
	"fmt"
)

func main() {
	var n,y,total int
	fmt.Scan(&n,&y)
	
	for a := 0; a <= n; a++ {
		for b := 0; b <= n-a; b++ {
			c := n - (a + b)
			total =  10000 * a + 5000 * b + 1000 * c
			if a + b + c == n && total == y {
				fmt.Printf("%d %d %d",a,b,c)
				return
			}
		}
	}
	fmt.Println("-1 -1 -1")
}


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

using ll = long long;
#define FOR(i, m, n) for (int i = (m); i < (n); i++)
#define REP(i, n) FOR(i, 0, n)
#define ALL(c) (c).begin(), (c).end()
template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return false;}
const int MOD = 1000000007;

int main() {
    int n, k;
    cin >> n >> k;
    if (k == 1) {
        cout << 0 << endl;
        return 0;
    }
    cout << n - k << endl;
}


Measured memory_bytes: 256
package main

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

func fill(s []int, x int) {
	for i := 0; i < len(s); i++ {
		s[i] = x
	}
}

func min(x, y int) int {
	if x < y {
		return x
	}
	return y
}

func readKey() [2]int {
	a := readInt()
	b := readInt()
	m := 0
	for i := 0; i < b; i++ {
		c := readInt()
		m |= 1 << uint(c-1)
	}
	return [2]int{a, m}
}

func main() {
	N := readInt()
	M := readInt()
	keys := make([][2]int, M)
	for i := 0; i < M; i++ {
		keys[i] = readKey()
	}

	dp := make([]int, 1<<uint(N))
	fill(dp, math.MaxInt64)

	dp[0] = 0
	for i := 0; i < M; i++ {
		a, m := keys[i][0], keys[i][1]
		for j := (1 << uint(N)) - 1; j >= 0; j-- {
			if dp[j] == math.MaxInt64 {
				continue
			}
			dp[j|m] = min(dp[j|m], dp[j]+a)
		}
	}
	if dp[(1<<uint(N))-1] == math.MaxInt64 {
		fmt.Println(-1)
	} else {
		fmt.Println(dp[(1<<uint(N))-1])
	}
}

const (
	ioBufferSize = 1 * 1024 * 1024 // 1 MB
)

var stdinScanner = func() *bufio.Scanner {
	result := bufio.NewScanner(os.Stdin)
	result.Buffer(make([]byte, ioBufferSize), ioBufferSize)
	result.Split(bufio.ScanWords)
	return result
}()

func readString() string {
	stdinScanner.Scan()
	return stdinScanner.Text()
}

func readInt() int {
	result, err := strconv.Atoi(readString())
	if err != nil {
		panic(err)
	}
	return result
}


Measured memory_bytes: 768
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> VI;
ll mm=1000000000;ll MM=mm+7;
#define rep(i, n) for(int i=0;i<n;i++)
 
int main(){
  int n;
  cin >> n;
  VI a(n);
  rep(i,n){
    cin >> a.at(i);
  }
  int gra=0;
  int br=0;
  int gre=0;
  int sky=0;
  int blu=0;
  int ye=0;
  int ora=0;
  int red=0;
  int all=0;
  rep(i,n){
    if(a.at(i)<400)gra++;
    if(a.at(i)>=400  && a.at(i)<800)br++;
     if(a.at(i)>=800 && a.at(i)<1200)gre++;
     if(a.at(i)>=1200 && a.at(i)<1600)sky++;
     if(a.at(i)>=1600 && a.at(i)<2000)blu++;
     if(a.at(i)>=2000 && a.at(i)<2400)ye++;
     if(a.at(i)>=2400 && a.at(i)<2800)ora++;
     if(a.at(i)>=2800 && a.at(i)<3200)red++;
     if(a.at(i)>=3200) all++;
  }
  int col=0;
  if(gra!=0) col++;
  if(br!=0) col++;
  if(gre!=0) col++;
  if(sky!=0) col++;
  if(blu!=0) col++;
  if(ye!=0) col++;
  if(ora!=0) col++;
  if(red!=0) col++;
  if(col==0)cout << 1 << " " ;
  else cout << col << " ";
  cout << col+all << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<queue>
#define rep(i,n) for (int i = 0; i < n; i++)
using namespace std;
using ll = long long;
using P = pair<int,int>;

int gcd (int a,int b) {
  int r = 1;
  while(r != 0) {
    r = a%b;
    a = b;
    b = r;
  }
  return a;
}

int ngcd (int a,int b,int c) {
  int d=0;
  d = gcd(d,a);
  d = gcd(d,b);
  d = gcd(d,c);
  return d;
}

int main() {
  int k;
  cin >> k;
  int ans = 0;

  for(int i=1;i<=k;i++) {
    for (int j=1;j<= k;j++) {
      for (int m=1;m<= k;m++) {
        ans += gcd(gcd(i,j),m);
      }
    }
  }

  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3164
#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <math.h>
#include <algorithm>
#include <string>
#include <string.h>
#include <vector>
#include <functional>
#include <queue>
#include <unordered_set>
#include <climits>

using namespace std;
typedef long long ll;

int main()
{
	int W, H, N;
	int x[101];
	int y[101];
	int a[101];
	cin >> W >> H >> N;
	for(int i = 0; i < N; i++){
		cin >> x[i] >> y[i] >> a[i];
	}
	
	int leftX = 0;
	int rightX = W;
	int topY = H;
	int buttomY = 0;
	
	for(int i = 0; i < N; i++){
		if(a[i] == 1){
			leftX = max(leftX, x[i]);
		}else if(a[i] == 2){
			rightX = min(rightX, x[i]);
		}else if(a[i] == 3){
			buttomY = max(buttomY, y[i]);
		}else if(a[i] == 4){
			topY = min(topY, y[i]);
		}
	}
	if(rightX-leftX > 0 && topY - buttomY > 0){
		cout << (rightX-leftX) * (topY - buttomY) << endl;
	}
	else{
		cout << 0 << endl;
	}
	
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define mod 1000000007
using namespace std;
int main()
{
    int n,m,k; cin>>n>>k;
    vector<int>a(n);
    for(int i=0;i<n;i++) {cin>>a[i];}
    int dp[k+1]={0};
    for(int i=1;i<=k;i++)
    {
        for(auto v:a)
        {
            if(v>i) continue;
            if(dp[i-v]==0) dp[i]=1;
        }
    }
  dp[k]==1?cout<<"First":cout<<"Second"; 
}

Measured memory_bytes: 640
#include "iostream"
#include "algorithm"
#include "vector"
#include "string"
#include "cmath"
typedef long long ll;
using namespace std;

int main(int argc, char const *argv[]) {
  ll AA, BB;


  std::cin >> AA >> BB;

  if (AA <=5) {
    std::cout << "0" << '\n';
  }else if(AA <= 12){
    std::cout << BB/2 << '\n';
  }else{
    std::cout << BB << '\n';
  }



  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <deque>
#include <queue>
#include <string>
#include <string.h>
#include <math.h>
#include <iomanip>
using namespace std;

#define int64 long long
#define pii pair <int64, int64>
#define fr first
#define sc second
#define heap priority_queue
struct piii{
    int64 fr, sc, th;
    bool operator < (const piii &b){
        if (fr != b.fr) return fr < b.fr;
        if (sc != b.sc) return sc < b.sc;
        return th < b.th;
    }
};
///////////////////////////////////////////////
///////////////////////////////////////////////

int main(){
    cout << setprecision(10) << fixed;
    ios::sync_with_stdio(false), cin.tie(0);
    //freopen("input.txt", "r", stdin);
    int n;
    cin >> n;
    double res, val;
    for (int i = 0; i < n; i++){
        cin >> val;
        res += 1 / val;
    }
    cout << 1 / res;
    return 0;
}


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

int main(){
	int d;
	int s=0;
	while (cin >> d){
		for (int i = 0; i < 600/d ; i++){
			s = s + i*d*i*d*d;
		}
		cout << s << endl;
		s = 0;
	}
}


Measured memory_bytes: 3104
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author cherrypi59
 */

#pragma GCC optimize ("O2")
#pragma GCC optimize ("tree-vectorize")
#pragma GCC target ("sse4")

#include <bits/stdc++.h>
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define FFOR(i, a, b) FOR(i, a, b+1)
#define REP(i, n) FOR(i, 0, n)
#define RREP(i, n) FOR(i, 1, n+1)
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define LEN(x) (int)(x).size()
#define DUMP(x) cerr<<__LINE__<<' '<<#x<<"="<<(x)<<endl;
#define pb push_back
#define eb emplace_back
#define mp make_pair

using namespace std;
using lint = long long;
using pii =  pair<int, int>;
using pll =  pair<lint, lint>;
template <typename T> using vc = vector<T>;
template <typename T> using vvc = vector<vector<T>>;
template <typename T> inline bool chmax(T &a, T b){if(a<b){a = b; return true;} return false;}
template <typename T> inline bool chmin(T &a, T b){if(a>b){a = b; return true;} return false;}

constexpr lint ten(int n) {return n==0 ? 1 : ten(n-1)*10;}

class CSnukeTheWizard {
public:
    void solve(std::istream& in, std::ostream& out){
        ios_base::sync_with_stdio(false);
        in.tie(nullptr), out.tie(nullptr);
        int N, Q;
        in>>N>>Q;
        string S;
        in>>S;
        vc<char> T(Q), D(Q);
        REP(i, Q) in>>T[i]>>D[i];
        int l1 = -1, r1 = N;
        while(1<r1-l1){
            int mid = (l1+r1) >> 1;
            int now = mid;
            REP(i, Q){
                if(T[i]!=S[now]) continue;
                if(D[i]=='L') --now;
                else ++now;
                if(now==-1 or now==N) break;
            }
            if(now==-1) l1 = mid;
            else r1 = mid;
        }
        int l2 = -1, r2 = N;
        while(1<r2-l2){
            int mid = (l2+r2) >> 1;
            int now = mid;
            REP(i, Q){
                if(T[i]!=S[now]) continue;
                if(D[i]=='L') --now;
                else ++now;
                if(now==-1 or now==N) break;
            }
            if(now==N) r2 = mid;
            else l2 = mid;
        }
        out<<r2-r1<<'\n';
    }
};


int main() {
	CSnukeTheWizard solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 3896
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.InputMismatchException;
import java.util.StringTokenizer;

public class Main {

	public static void main(String[] args) throws IOException {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		InputReader in = new InputReader(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		TaskX solver = new TaskX();
		solver.solve(1, in, out);
		out.close();
	}

	static int INF = 1 << 30;
	static int modP = 1000000007;

	static int[] mh = {0,-1,1,0};
	static int[] mw = {-1,0,0,1};

	static class TaskX {
		public void solve(int testNumber, InputReader in, PrintWriter out) {

			int h = in.nextInt(), w = in.nextInt();
			char[][] s = new char[h][w];
			for (int i = 0; i < h; i++) {
				s[i] = in.nextString().toCharArray();
			}

			boolean[][] visited = new boolean[h][w];
			for (int i = 0; i < h; i++) {
				for (int j = 0; j < w; j++) {
					if (s[i][j] == '#') {
						for (int k = 0; k < 4; k++) {
							if (0 <= i+mh[k] && i+mh[k] < h && 0 <= j+mw[k] && j+mw[k] < w) {
								if (s[i+mh[k]][j+mw[k]] == '#') {
									visited[i][j] = true;
									visited[i+mh[k]][j+mw[k]] = true;
								}
							}
						}
					}
				}
			}

			for (int i = 0; i < h; i++) {
				for (int j = 0; j < w; j++) {
					if (s[i][j] == '#') {
						if (visited[i][j]) {
							continue;
						} else {
							out.println("No");
							return;
						}
					}
				}
			}

			out.println("Yes");

		}
	}

	static class InputReader {
		BufferedReader in;
		StringTokenizer tok;

		public String nextString() {
			while (!tok.hasMoreTokens()) {
				try {
					tok = new StringTokenizer(in.readLine(), " ");
				} catch (IOException e) {
					throw new InputMismatchException();
				}
			}
			return tok.nextToken();
		}

		public int nextInt() {
			return Integer.parseInt(nextString());
		}

		public long nextLong() {
			return Long.parseLong(nextString());
		}

		public double nextDouble() {
			return Double.parseDouble(nextString());
		}

		public int[] nextIntArray(int n) {
			int[] res = new int[n];
			for (int i = 0; i < n; i++) {
				res[i] = nextInt();
			}
			return res;
		}

		public long[] nextLongArray(int n) {
			long[] res = new long[n];
			for (int i = 0; i < n; i++) {
				res[i] = nextLong();
			}
			return res;
		}

		public InputReader(InputStream inputStream) {
			in = new BufferedReader(new InputStreamReader(inputStream));
			tok = new StringTokenizer("");
		}

	}

}


Measured memory_bytes: 21332
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i, c) for (int i = 0; i < (int)c; i++)
#define all(v) v.begin(), v.end()
using ll = long long;
using P = pair<int, int>;
const int inf = 1000000000; //10^9
const ll MOD = 1e9 + 7;
//加算代入演算子は+=！！！！！
//int 2^31 10^9まで
int main()
{
    int w, a, b;
    cin >> w >> a >> b;
    int ans = 0;
    if (a + w < b)
    {
        cout << b - (a + w) << endl;
    }
    else if (b + w < a)
    {
        cout << a - (b + w) << endl;
    }
    else cout << 0 << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i, n) for(int (i)=0 ;i <(n); ++(i))
#define REP(i,m,n) for(int (i) = (m); (i) <= (n); ++(i))
#define yorn(f) puts((f)?"Yes":"No")
#define YORN(f) puts((f)? "YES":"NO")
typedef long long ll;
using namespace std;

int main() {
  int x,t;
  cin >> x >> t;
  if(x<=t) {
    cout << 0 << endl;
  }
  else {
    cout << x - t << endl;
  }
  return 0;
}

Measured memory_bytes: 764
//  C/C++ program to convert n into negative base form
#include <bits/stdc++.h>
using namespace std;
 
//  Utility method to convert integer into string
string toString(int n)
{
    string str;
    stringstream ss;
    ss << n;
    ss >> str;
    return str;
}
 
// Method to convert n to base negBase
string toNegativeBase(int n, int negBase)
{
    //  If n is zero then in any base it will be 0 only
    if (n == 0)
        return "0";
 
    string converted = "";
    while (n != 0)
    {
        // Get remainder by negative base, it can be
        // negative also
        int remainder = n % negBase;
        n /= negBase;
 
        // if remainder is negative, add abs(base) to
        // it and add 1 to n
        if (remainder < 0)
        {
            remainder += (-negBase);
            n += 1;
        }
 
        // convert remainder to string add into the result
        converted = toString(remainder) + converted;
    }
 
    return converted;
}
 
//  Driver code to test above methods
int main()
{
    int n;
    cin >> n;
    int negBase = -2;
 
    cout << toNegativeBase(n, negBase);
 
    return 0;
}

Measured memory_bytes: 256
n, k = map(int, input().split())
r, s, p = map(int, input().split())
t_list = list(input())
towin = {"r": p, "s": r, "p": s}
ans = 0
for i in range(n):
    if i < k:
        ans += towin[t_list[i]]
    else:
        if t_list[i - k] == t_list[i]:
            t_list[i] = "-1"
        else:
            ans += towin[t_list[i]]
print(ans)

Measured memory_bytes: 4084
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vint;
typedef pair<int,int> pint;
typedef vector<pint> vpint;
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,f,n) for(int i=(f);i<(n);i++)
#define each(it,v) for(__typeof((v).begin()) it=(v).begin();it!=(v).end();it++)
#define all(v) (v).begin(),(v).end()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
const int MOD = 1e9 + 7;
const int INF = 1e9;

int main(void){
	while(1){
		int n; cin >> n;
		if(n == 0) break;
		priority_queue<pint, vector<pint>, greater<pint> > q;
		q.push(make_pair(0, INF));
		map<int, vpint> m;
		rep(i, n){
			char c; cin >> c;
			if(c == 'W'){
				int num, size; cin >> num >> size;
				while(size > 0){
					int l = q.top().fi, r = q.top().se;
					q.pop();
					if(r - l + 1 >= size){//??????
						q.push(make_pair(l + size, r));
						m[num].push_back(make_pair(l, l + size - 1));
						size = 0;
					}else{//?¶??????????
						m[num].push_back(make_pair(l, r));
						size -= (r - l + 1);
					}
				}
			}else if(c == 'D'){
				int num; cin >> num;
				for(auto u : m[num]){
					q.push(make_pair(u.fi, u.se));
				}
				m[num].erase(all(m[num]));
			}else{
				int idx; cin >> idx;
				bool flag = false;
				each(it, m){
					auto key = it->fi;
					auto v = it->se;
					for (int i = 0; i < v.size(); ++i){
						if(v[i].fi <= idx && idx <= v[i].se){
							printf("%d\n", key);
							flag = true;
							break;
						}
					}
					if(flag) break;
				}
				if(!flag){
					printf("-1\n");
				}
			}
		}
		printf("\n");
	}
	return 0;
}

Measured memory_bytes: 23480
#include <bits/stdc++.h>
#define ll long long
#define double long double
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,n) for(int i=1;i<=(n);i++)
#define mod (ll)(1e9+7)
#define inf (ll)(3e18+7)
#define pi (double) acos(-1)
#define P pair<int,int>
#define PiP pair<int,pair<int,int>>
#define all(x) x.begin(),x.end()
using namespace std;

int main(){
    string s;
    cin >> s;
    cout << "ABC"+s;
}

Measured memory_bytes: 256
N, M, X = list(map(int, input().split()))
C_A = [list(map(int, input().split())) for _ in range(N)]
slv_cost = 0
A = [0]*M
for i in range(N):
    slv_cost += C_A[i][0]
    for j in range(M):
        A[j] += C_A[i][j+1] 

for i in range(M):
    if X > A[i]:
        print(-1)
        exit()

for i in range(1, 2**N):
    st = bin(i)[2:][::-1]
    tmp_A = [0]*M
    tmp_cost = 0
    for j in range(len(st)):
        if st[j] == "1":
            tmp_cost += C_A[j][0]
            for l in range(M):
                tmp_A[l] += C_A[j][l+1]
    ok = True
    for j in range(M):
        if X > tmp_A[j]:
            ok = False
    if ok == True:
        slv_cost = min(slv_cost, tmp_cost)
print(slv_cost)


Measured memory_bytes: 68920
#include <iostream>
#include <vector>

int main () {
  std::vector<std::vector<int>> a, vis;
  a.assign (3, std::vector<int> (3, 0));
  vis.assign (3, std::vector<int> (3, 0));
  for (int i = 0; i < 3; ++i)
    for (int j = 0; j < 3; ++j)
      std::cin >> a[i][j];
  int n; std::cin >> n;
  for (int i = 0; i < n; ++i) {
    int x; std::cin >> x;
    for (int j = 0; j < 3; ++j)
      for (int k = 0; k < 3; ++k)
        if (x == a[j][k])
          vis[j][k] = 1;
  }
  bool flag = false;
  for (int i = 0; i < 3; ++i) {
    bool ok_1 = true, ok_2 = true;
    for (int j = 0; j < 3; ++j) {
      if (!vis[i][j]) ok_1 = false;
      if (!vis[j][i]) ok_2 = false;
    }
    if (ok_1 || ok_2) flag = true;
  }
  bool ok_1 = true, ok_2 = true;
  for (int i = 0; i < 3; ++i) {
    if (!vis[i][i]) ok_1 = false;
    if (!vis[i][2-i]) ok_2 = false;
  }
  if (ok_1 || ok_2) flag = true;
  if (flag)
    std::cout << "Yes\n";
  else
    std::cout << "No\n";
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <algorithm>
using namespace std;
const int N=1e5+10;
int main(){
    int n,temp,a[N];
    long long int ans,now,tot;
    while(true){
        scanf("%d",&n);
        if(n==0)return 0;
        scanf("%lld",&tot);
        now=n;
        n--;
        for(int i=0;i<n;i++){
            scanf("%d",&temp);
            tot+=temp;
        }
        for(int i=0;i<n;i++)scanf("%d",&a[i]);
        sort(a,a+n);
        ans=now*tot;
        for(int i=n-1;i>=0;i--){
            tot+=a[i];
            now--;
            if(now*tot<ans)break;
            else ans=now*tot;
        }
        printf("%lld\n",ans);
    }
}


Measured memory_bytes: 3012
import java.util.*;

class Main{

    public static void main(String[] args){

	Scanner sc = new Scanner(System.in);

	int N = sc.nextInt();

	int[] v = new int[N];

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

	v[i] = sc.nextInt();

  }

	Arrays.sort(v);

	double ans = v[0];

	for(int i=1; i<N; i++){

	ans = (ans+v[i])/2;

  }
 

	System.out.println(ans);


 }
}

Measured memory_bytes: 23764
N, K = map(int, input().split())
P = list(map(int, input().split()))
t = [0] * 1000000
for i in range(N):
    t[i + 1] = t[i] + P[i] + 1
ans = 0
for i in range(N - K + 1):
    ans = max(ans, t[i+K] - t[i])
print(ans / 2)


Measured memory_bytes: 26568
#ABC141D
def main():
    import sys
    import heapq as hp
    N, M = map(int, sys.stdin.readline().split())
    A = list(map(lambda x:-int(x), sys.stdin.readline().split()))
    A.sort()
    hp.heapify(A)
    #print(A)
    while M>0:
        tmp = hp.heappop(A) #左から取り出す
        tmp = -((-tmp)//2)
        hp.heappush(A, tmp)
        M-=1
    print(-sum(A))
   
if __name__=='__main__':
    main()


Measured memory_bytes: 14204
"""
int #整数
float #小数

#for
for name in fruits: #fruitの頭から操作
    print(name)
    
#リスト
list0 = [] #リスト生成
list0 = [1,2,3,4] #初期化
list0 = [0]*10 #[0,0,0,0,0,0,0,0,0,0]
list1= [i for i in range(10)] #>>> [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
list1 = list(map(int, input().split()))　# 複数の入力をリストに入れる
number=[int(input()) for i in range(int(input()))] #複数行の入力をリストに
list1 = list1 + [6, 7, 8] #リストの追加
list2.append(34) #リストの追加　最後に（）内が足される
list.insert(3,10) #リストの追加　任意の位置（追加したい位置,追加したい値）
len(list4) #リストの要素数
max(sa) #list saの最小値
list5.count(2) #リスト(文字列も可）内の2の数
list1.sort() #並び替え小さい順
list1.sort(reverse=True)  #並び替え大きい順
set(list1) #list1内の重複している要素を削除し、小さい順に並べる
sum([2,3,   ,3]) #リストの合計

abs(a) #aの絶対値
max(a,b) min(a,b) #最大値　最小値
text1 = text1.replace("34","test") #text1内の"34"を"test"に書き換える(文字列内の文字を入れ替える)

exit(0) #強制終了
"""
K, S = map(int, input().split())
count = 0
for i in range(K + 1):
    for j in range(K + 1):
        Z=S-i-j
        if 0<=Z<=K:
            count += 1

print(count)


Measured memory_bytes: 67500
#include <bits/stdc++.h>
using namespace std;
#define fori(i, S, E) for (int i = S; i < E; i++)
#define all(x) x.begin(), x.end()

int main() {
    int H, W, K;
    cin >> H >> W >> K;

    vector<vector<char>> C (H, vector<char>(W));

    fori(i, 0, H) {
    fori(j, 0, W) {
        cin >> C[i][j];
    }
        cin.ignore();
    }

    int best = 987654321;

    vector<int> amount (H, 0);
    vector<int> line_amount (H, 0);

    fori(b, 0, 1 << (H - 1)) {
        fill(all(amount), 0);

        vector<int> cuts (W, 0);

        bool impossible = false;

        fori(j, 0, W) {
            int p = 0;

            fori(i, 0, H) {
                line_amount[p] += C[i][j] - '0';

                if (amount[p]+line_amount[p] > K) {
                    fill(all(amount), 0);
                    if (cuts[j] == 0) {
                        cuts[j] = 1;
                    } else {
                        impossible = true;
                    }
                }

                if (b & (1 << i)) {
                    p++;
                }
            }

            fori(k, 0, H) {
                amount[k] += line_amount[k];
                line_amount[k] = 0;
            }
        }

        if (!impossible) {
            int horizontal_cuts = accumulate(all(cuts), 0);
            int vertical_cuts = __builtin_popcount(b);

            best = min(best, horizontal_cuts + vertical_cuts);
        }
    }

    cout << best << "\n";
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <iomanip>
using namespace std;
#define INF 1e9
#define PI acos(-1)
typedef long long ll;


int main() {
	//k個のグループ一つとk-1個のグループが何個でn個をカバーできるか。
	int n, k;
	cin >> n >> k;
	int ans = 0;
	int pos = 1;

	while (true) {
		if (n <= pos)break;
		ans++;
		if (pos == 0)pos += k;
		else pos += k - 1;
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef pair<LL, LL> PII;

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

template <typename T>
function<T(T, T)> op_max = [](T a, T b) -> T { return max(a, b); };
template <typename T>
function<T(T, T)> op_min = [](T a, T b) -> T { return min(a, b); };

template <typename T>
function<T(T, T)> op_sum = [](T a, T b) -> T { return a + b; };

using namespace std;
//********************  dumps ************************//

template <typename T>
void dump(const T &data, vector<int> &iter)
{
  cout << data << " ";
}
template <typename T>
void dump(const vector<T> &data, vector<int> &iter)
{
  for (auto elem : data)
    dump(elem, iter);
  cout << endl;
}

template <typename T>
void dump(const vector<vector<T>> &data, vector<int> &iter)
{
  for (auto elem : iter)
  {
    cout << "[" << elem << "]";
  }
  cout << endl;
  for (int i = 0; i < data.size(); i++)
  {
    iter.push_back(i);
    dump(data[i], iter);
    iter.pop_back();
  }
  cout << endl;
}

template <typename T>
void dump(const vector<T> &data, int dummy)
{
  for (int i = 0; i < data.size(); i++)
  {
    cout << "[" << i << "] " << data[i] << endl;
  }
}
template <typename T>
void dump(const T &data)
{ // T : data, U = base type val.
  vector<int> iter;
  dump(data, iter);
}
///////////////////////////////////////////////

void solve(long long A, long long B, double H, double M)
{
  double cs = cos(abs(H * 30 + M / 2 - M * 6) / 180.0 * M_PI);
  double c2 = A * A + B * B - 2 * A * B * cs;
  cout << sqrt(c2) << endl;
}

int main()
{
  cout << setprecision(10);
  long long A;
  scanf("%lld", &A);
  long long B;
  scanf("%lld", &B);
  long long H;
  scanf("%lld", &H);
  long long M;
  scanf("%lld", &M);
  solve(A, B, H, M);
  return 0;
}


Measured memory_bytes: 4156
N = input()
A, B = map(int, raw_input().split())
C = input()
D = [input() for i in range(N)]
D.sort(reverse=True)
best = 0
for i in range(N):
    topping = D[:i]
    k = len(topping)
    price = A + B * k
    calory = C + sum(topping)
    best = max(best, calory / price)
print best

Measured memory_bytes: 4224
/* 
chirag11032000
Chirag Thakur
*/

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

using ll = long long;
using db = double;
using pii = pair < int, int >;
using pll = pair < ll, ll >;

template < typename T > using OrderedSet = tree < T, null_type, less < T >, rb_tree_tag, tree_order_statistics_node_update >;
template < typename T > using MinPriorityQueue = priority_queue < T, vector < T >, greater < T > >;

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

#define eb emplace_back
#define mp make_pair
#define mt make_tuple
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define unique_sort(x) sort(all(x)), x.resize(distance(x.begin(), unique(all(x))))

const db PI = acos(-1);
const ll LINF = LLONG_MAX;
const int INF = INT_MAX, MOD = 1e9 + 7, N = 1e5 + 10;

void test_case();

int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	test_case();
	cerr << "Time taken: " << int((clock() * 1000.) / CLOCKS_PER_SEC) << "ms\n";
	return 0;
}

void test_case() {
	int a, b;
	cin >> a >> b;
	if (b % a == 0) {
		cout << a + b << "\n";
	} else {
		cout << b - a << "\n";
	}
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main()
{
    int n = 0;
    int d[1000] = {};
    cin >> n;
    int heath = 0;
    int i = 0;
    int g = 0;
    for(i = 1;i<=n;i++)
    {
        cin >> d[i];
    }
    for(i = 1;i<=n;i++)
    {
        for(g = i + 1;g<=n;g++)
        {
            heath = heath + d[i] * d[g];
        }
    }
    cout<<heath;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=2e5+5;
vector<ll>g[N];
ll n,u,v,color[N],c[N],son[N],res[N]={0};
ll f(ll n) {return n*(n+1)/2;}
void dfs(ll u,ll fa){
    auto tmp=c[color[u]];
    for(auto v:g[u]){
        if(v==fa) continue;
        c[color[u]]=0;
        dfs(v,u);
        son[u]+=son[v];
        res[color[u]]+=f(son[v]-c[color[u]]);
    }
    c[color[u]]=tmp+son[u];
}

int main(){
    cin>>n;
    for(ll i=1;i<=n;i++){
        son[i]=1;
        cin>>color[i];
    }
    for(ll i=1;i<n;i++){
        cin>>u>>v;
        g[u].push_back(v);
        g[v].push_back(u);
    }
    dfs(1,-1);
    for(int i=1;i<=n;i++){
        cout<<f(n)-f(n-c[i])-res[i]<<endl;
    }
    return 0;
}


Measured memory_bytes: 39572
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  long long n;
  string s;
  cin >> n >> s;
  long long w=0;
  long long bl;
  long long wr;
  
  for(long i=0; i<n; i++){
    if(s.at(i) == '.'){
      w++;
    }
  }
  
  bl=0;
  wr=w;
  long long res = bl+wr;
  
  for(long i=0; i<n; i++){
    if(s.at(i) == '.'){
      wr--;
    }else{
      bl++;
    }
    
    res = min(res,wr+bl);
  }
  cout << res << endl;
}

Measured memory_bytes: 640
n, q = map(int, input().split())
s = input()
t = [0] * (n + 1)
for i in range(n):
    if s[i : i + 2] == "AC":
        t[i + 1] = t[i] + 1
    else:
        t[i + 1] = t[i]
for i in range(q):
    l, r = map(int, input().split())
    print(t[r - 1] - t[l - 1])


Measured memory_bytes: 50904
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <string>
#include <queue>
#include <numeric>
#include <ctype.h>
#include <limits>
#include <iomanip>

#define rep(i,n) for (int i = 0; i < n; i++)
#define all(x) (x).begin(),(x).end()
using namespace std;

typedef long long ll;

int main() {
	/*string s;
	cin >> s;
	rep(i, 4) {
		int a = 0;
		rep(j, 4) { 
			if (s[i] == s[j])a++;
		}
		if (a != 2) {
			cout << "No";
			return 0;
		}
	}
	cout << "Yes";*/

	/*int n;
	cin >> n;
	vector<int>p(n + 1);
	int i;
	for (i = 1; i < n + 1; i++)cin >> p[i];
	int ans = 0;
	for (i = 2; i < n; i++) {
		if (p[i] != min({ p[i - 1],p[i],p[i + 1] }) && p[i] != max({ p[i - 1],p[i],p[i + 1] }))ans++;
	}
	cout << ans;*/


	int N;
	cin >> N;
	vector<int>d(N);
	int i;
	rep(i, N)cin >> d[i];
	sort(all(d));
	cout << d[N / 2] - d[N / 2 - 1];
	
	return 0;
}

Measured memory_bytes: 640
#include <string>
#include <vector>
#include <cstring>
#include <algorithm>
#include <iostream> 
#include <cmath>
 
using namespace std;
typedef long long ll;
typedef long double ld;

//repetition
#define REP(i,n)  for(ll i=0;i<n;i++)

ll P_POW(ll i, ll n) {
  if(n==0) return 1;

  n--;
  ll rep = i;

  while(n) {
    rep = rep * i;
    n--;
  }
  return rep;
} 

unsigned GetDigit(unsigned num){
    unsigned digit=0;
    while(num!=0){
        num /= 10;
        digit++;
    }
    return digit;
}
 
unsigned binarySearch(ll target, ll max, ll min) {
  while((max - min) > 1) {
      if((max + min)/2 > target) {
        max = (max + min)/2;
        min = min;
      } else {
        max = max;
        min = (max + min)/2;
      }
    }
}

ll n;


long long solve2(long long N) {
    if (N % 2 == 1) return 0;

    long long res = 0;
    N /= 2;
    while (N) {
        res += N / 5;
        cout << "N/5: " << N/5 <<  endl;
        cout << "res1: " << res <<  endl;
        N /= 5;
    }
    return res;
}


ll solve(ll n) {
    if (n % 2 == 1) return 0;

    ll res = 0;
    n /= 2;
    int c = 1;

    while ((ll) n/((ll)pow(5,c))) {
      res += n/P_POW(5,c);
      c++;
    }
    return res;
}

int main() {
  ll n;
  cin >> n;
  cout << solve(n) << endl;
}


Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
static int MAX_N = 10;
int X, Y;
void solve();

int main(){


  //標準出力より入力
  scanf("%d %d", &X, &Y);
  solve();
}

void solve(){
  int result = std::max({X+Y, X-Y, X*Y});
  printf("%d\n", result);
  // printf("%d %d\n", X, Y);
}


Measured memory_bytes: 128
#include <iostream>
#include <cstdlib>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <stack>
#include <queue>
#include <cctype>
#include <complex>
#include <vector>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <cassert>
#include <iomanip>

using namespace std;

#define pb push_back
#define dump(x)  cout << " "<< #x << " = " << (x) << endl;
typedef long long ll;
typedef complex<int> P;
const double EPS = 1e-10;
const double PI  = acos(-1.0);


const int dmax = 1500 * 1000 + 10;	//
int a[dmax] = {0};					//

bool solve(){
	int n, m;
	cin>> n>> m;
	if(n==0 && m==0) return false;
	
	vector<int> w(n), h(m);
	for(int i=0;i<n;i++) cin>> w[i];
	for(int i=0;i<m;i++) cin>> h[i];
	
	vector<int> W, H;
	for(int i=0;i<n;i++){
		int x = w[i];
		W.pb(x);
		for(int j=i+1;j<n;j++){
			x += w[j];
			W.pb(x);
		}
	}
	for(int i=0;i<m;i++){
		int x = h[i];
		H.pb(x);
		for(int j=i+1;j<m;j++){
			x += h[j];
			H.pb(x);
		}
	}
	
	int ans = 0;
	memset(a, 0, sizeof(a));
	for(int i=0;i<W.size();i++){
		a[W[i]]++;
	}
	for(int j=0;j<H.size();j++){
		ans += a[H[j]];
	}
	cout<< ans<< endl;
	
	return true;
}

int main(){
	cout.setf(ios::fixed);
	cout.precision(10);
	
	while(solve());
	return 0;
}

 

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

int main() {
  int n, m;
  cin >> n >> m;
  int k;
  int food[m] = {};
  for(int i = 0; i < n; i++) {
    cin >> k;
    int a[k];
    for(int j = 0; j < k; j++) {
      cin >> a[j]; 
      food[a[j] - 1]++;
    }
  }
  int ans = 0;
  for(int i = 0; i < m; i++) {
    if(food[i] == n) ans++;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
typedef long long ll;
#define rep(i,n) for (int i = 0; i < (n); i++)
#define repe(i,n) for (int i = 0; i <= (n); ++i)
#define repe1(i,n) for (int i = 0; i <= (n); ++i)
#define all(x) (x).begin(),(x).end()
#define pb(x) push_back(x)
#define eb(k,v) emplace_back(k,v)
#define ct(res) cout << res << "\n";
#define vi vector<int>
#define vl vector<ll>
using namespace std;
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; }
const int INF = 1e9;
const ll MOD = 1000000007;
using Graph = vector<vector<int>>;


void recursive_comb(int *indexes, int s, int rest, std::function<void(int *)> f) {
  if (rest == 0) {
    f(indexes);
  } else {
    if (s < 0) return;
    recursive_comb(indexes, s - 1, rest, f);
    indexes[rest - 1] = s;
    recursive_comb(indexes, s - 1, rest - 1, f);
  }
}

// nCkの組み合わせに対して処理を実行する
void foreach_comb(int n, int k, std::function<void(int *)> f) {
  int indexes[k];
  recursive_comb(indexes, n - 1, k, f);
}

ll modPow(ll x, ll n) {
    if(n==0) return 1;
    ll res = modPow(x*x%MOD, n/2);
    if(n&1) res=res*x%MOD;
    return res;
}
ll mul(ll l, ll r) {
    ll ret =1;
    for(int i=0; i<l-r+1; ++i) {
        ret*=i+r;
        ret%=MOD;
    }
    return ret;
}
ll com(ll n, ll k) {
    ll ret1 = mul(n,n-k+1);
    ll ret2 = mul(k,1);
    ll ret3 = modPow(ret2, MOD-2);
    return ret1*ret3%MOD;
}
int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int n; cin >> n;
    int ans = 0;
    for(int i=1; i<=9; ++i) {
      if (n%i==0 && n/i<=9) {
        ct("Yes");
        return 0;
      }
    }
    ct("No");
}



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


int main() {
long N;
cin>>N;
vector<long> a(100005);
long mod=1e9+7;

for(int i=0;i<N;i++) {
  int t;
  cin>>t;
  a[t]++;
}

if(N%2==1){
  if(a[0]!=1){
    cout<<0<<endl;
    return 0;
  }
  for(int i=2;i<=N-1;i+=2){
    if(a[i]!=2){
      cout<<0<<endl;
      return 0;
    }
  }
}

if(N%2==0){
  for(int i=1;i<=N-1;i+=2){
    if(a[i]!=2){
      cout<<0<<endl;
      return 0;
    }
  }
}

long ans=1;
for(int i=1;i<=N/2;i++){
  ans*=2;
  ans%=mod;
}
cout<<ans<<endl;


}


Measured memory_bytes: 1024
import java.util.*;

public class Main{
    public static void main(String[]args){
     Scanner sc = new Scanner(System.in);
     int X=0;
     int Y=0;
     int Z=0; 
     X=sc.nextInt();
     Y=sc.nextInt();
     Z=sc.nextInt();
       System.out.print(Z+" ");
       System.out.print(X+" ");
       System.out.print(Y);
    }
}

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

int main(){
	int h1,h2,m1,m2,k; cin >> h1 >> m1 >> h2 >> m2 >> k;
    int d1 = h1*60 + m1;
    int d2 = h2*60 + m2;
    cout << ((d2-k-d1 <= 0) ? 0 : d2-k-d1) << endl;
    return 0;
}



Measured memory_bytes: 3656
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
typedef long long ll;

int main(){
    int n, k;
    cin >> n >> k;
    string s;
    cin >> s;
    s[k-1] = s[k-1] + ('a' -'A');
    cout << s << endl;        
}


Measured memory_bytes: 256
#include <stdio.h>

int main()
{
	int N = 0;
	int a = 0;

	scanf("%d", &N);

	if (N % 2 == 0) {
		a = N / 2;
		printf("%d", a);
	}
	else {
		a = (N + 1) / 2;
		printf("%d", a);
	}


	return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
#define sd(x) scanf("%d",&x)
#define slld(x) scanf("%lld",&x)
#define ss(x) scanf("%s",x)
#define ll long long
#define mod 1000000007
#define bitcount    __builtin_popcountll
#define pb push_back
#define fi first
#define se second
#define mp make_pair
#define pi pair<int,int>
int main()
{
    //freopen("in.txt","r",stdin);
    //freopen("out.txt","w",stdout);
    int i,j,k;
    sd(i);
    sd(j);
    if(i==1)
    	i=14;
    if(j==1)
    	j=14;
    if(i==j)
    	printf("Draw\n");
    else if(i>j)
    	printf("Alice\n");
    else
    	printf("Bob\n");
    return 0;
}

Measured memory_bytes: 256