akhauriyash/Code-Regression huggingface dataset:
#![allow(unused_imports)]

#[macro_use]
mod _input {
    use std::fmt;
    use std::io::{self, Read};
    use std::str::{self, FromStr};

    macro_rules! input {
        ($($name:ident : $t:tt),*,) => {
            input!($($name: $t),*)
        };
        ($($name:ident : $t:tt),*) => {
            let mut _scanned = ::_input::Scanned::new(::std::io::stdin(), 1024);
            $(
                let $name = unsafe { _read_value!(_scanned, $t) };
            )*
        };
    }

    macro_rules! _read_value {
        ($scanned:expr, ($($t:tt),*)) => {
            ($(_read_value!($scanned, $t)),*)
        };
        ($scanned:expr, [$t:tt; $n:expr]) => {
            (0..$n).map(|_| _read_value!($scanned, $t)).collect::<Vec<_>>()
        };
        ($scanned:expr, _bytes) => {
            _read_value!($scanned, String).into_bytes()
        };
        ($scanned:expr, _1based) => {
            _read_value!($scanned, usize) - 1
        };
        ($scanned:expr, $t:ty) => {
            $scanned.next::<$t>()
        };
    }

    pub struct Scanned {
        buf: Vec<u8>,
        pos: usize,
    }

    impl Scanned {
        pub fn new<R: Read>(mut input: R, estimated: usize) -> Self {
            let mut buf_ = Vec::with_capacity(estimated);
            let _ = io::copy(&mut input, &mut buf_).unwrap();
            debug_assert!(str::from_utf8(&buf_).is_ok());
            debug_assert!(buf_.iter().all(|&c| u32::from(c) <= 0x7F));
            Scanned { buf: buf_, pos: 0 }
        }

        #[inline]
        pub unsafe fn next<T: FromStr>(&mut self) -> T
        where
            T::Err: fmt::Debug,
        {
            let mut start = None;
            loop {
                match (self.buf[self.pos], start.is_some()) {
                    (b' ', true) | (b'\n', true) => break,
                    (_, true) | (b' ', false) | (b'\n', false) => self.pos += 1,
                    (_, false) => start = Some(self.pos),
                }
            }
            let target = &self.buf[start.unwrap()..self.pos];
            str::from_utf8_unchecked(target).parse().unwrap()
        }
    }
}

use std::collections::{BTreeMap, BTreeSet, BinaryHeap, HashMap, HashSet, VecDeque};
use std::io::{self, BufWriter, Read, Stderr, StderrLock, Stdout, StdoutLock, Write};
use std::num::{ParseFloatError, ParseIntError};
use std::ops::{
    Add, AddAssign, BitAnd, BitAndAssign, BitOr, BitOrAssign, BitXor, BitXorAssign, Div, DivAssign,
    Mul, MulAssign, Neg, Not, Rem, RemAssign, Sub, SubAssign,
};
use std::str::{self, FromStr};
use std::{char, cmp, f32, f64, fmt, i16, i32, i64, i8, mem, thread, u16, u32, u64, u8};

const M: u64 = 1_000_000_007;

fn main() {
    input! {
        _n: usize,
        s: _bytes,
    }
    let mut kinds = [0; 27];
    for c in s {
        kinds[(c - b'a') as usize] += 1;
    }
    let ret = kinds.iter().map(|&n| n + 1).fold(1, |a, b| (a * b) % M) - 1;
    println!("{}", ret);
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
#ifdef __DEBUG__
    #define DBG(X) cout << #X << " = " << (X) << endl;
    #define SAY(X) cout << (X) << endl;
#else
    #define DBG(X)
    #define SAY(X)
#endif

using namespace std;

using ll = long long int;
using ull = unsigned long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

int dx[]={1, 0, -1, 0, 1,-1, 1,-1};
int dy[]={0, 1, 0, -1, 1, 1,-1,-1};
const int INT_INF = (int)(2e9);
const ll  LL_INF = (ll)(2e18);

inline void fast_io() { ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); };
template<typename T, typename S> inline ostream& operator<<(ostream& os, const pair<T, S> p) { cout << "[" << p.first << ";" << p.second << "]"; return os; }
template<typename T, typename S> inline ostream& operator<<(ostream& os, const map<T, S> p) { for (auto el : p) cout << "[" << el.first << ";" << el.second << "]"; return os; }
template<typename T> inline ostream& operator<<(ostream& os, const vector<T>& v) { for (auto el : v) cout << el << " "; return os; }
template<typename T> inline ostream& operator<<(ostream& os, const deque<T>& v) { for (auto el : v) cout << el << " "; return os; }
template<typename T> inline ostream& operator<<(ostream& os, const set<T>& v) { for (auto el : v) cout << el << " "; return os; }
template<typename T> inline vector<T> fetch_vec(int sz) { vector<T> ret(sz); for (auto& elem : ret) cin >> elem; return ret; }

ll x,y;
void input(){
    fast_io();
    cin >> x >> y;
}

int solve(){
    ll ans = 0;
    if(abs(y)>=abs(x)){
        ans = abs(abs(y)-abs(x));
        if(y>=0 && x>=0) ans; 
        else if(y>=0 || x>=0) ans++;
        else ans+=2;
    } 
    else{
        ans = abs(abs(y)-abs(x));
        if(y>0 && x>0) ans+=2; 
        else if(y>0 || x>0) ans++;
        else ans;
    }
    cout << ans << endl;
    return 0;
}   

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

Measured memory_bytes: 256
#include <stdio.h>

int Fin(int);

int main(){
  int n;

  scanf("%d",&n);
  printf("%d\n",Fin(n));

  return 0;
}

int Fin(int n){
  int i, n1 = 1, n2 = 1, tmp = 1;
  
  for(i = 1; i < n; i++){
    tmp = n1 + n2;
    n1 = n2;
    n2 = tmp;
  }
  
  return tmp;
}



Measured memory_bytes: 2112
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
#define rep(i,s,e) for(i64 (i) = (s);(i) < (e);(i)++)
#define all(x) x.begin(),x.end()
#define let auto const

template<typename... Types>
struct dynarr: std::vector<Types...> {
  using std::vector<Types...>::vector;
  using size_type = typename std::vector<Types...>::size_type;
  auto&& operator[](size_type i) { return this->at(i); }
  auto&& operator[](size_type i) const { return this->at(i); }
};

int main() {
  i64 N;
  cin >> N;
  vector<i64> p(N);
  i64 cnt = 0;
  rep(i,0,N) {
    cin >> p[i];
    p[i]--;
    if(i != p[i]) {
      cnt++;
    }
  }
  if(cnt == 0 || cnt == 2) {
    cout << "YES" << endl;
  }
  else {
    cout << "NO" << endl;
  }
}


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

ans=[0 for _ in range(n) ]

for i in range(n):
  a=int(input())
  ans[a-1]+=(i+1)
  
ch=1

ans1=[1]
  
for x in range(n-1):
  if ans[x]<ans[x+1]:
    ch+=1
    
  else:
    ans1.append(ch)
    ch=1
  
  if x==n-2:
    ans1.append(ch)
  
    
print(n-max(ans1))
    

Measured memory_bytes: 89968
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)

int N;
double ans = 0;

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

	cin >> N;

	REP(i,N){
		double x;
		string s;
		cin >> x >> s;
		if( s == "BTC"){
			ans += x * 380000;
		}else{
			ans += x;
		}

	}

	cout << ans << endl;

}


Measured memory_bytes: 256
from heapq import heapify, heappush, heappop
N, M = map(int, input().split())
A = list(map(int, input().split()))
A = list(map(lambda x: -x, A))
heapify(A)
for i in range(M):
    mx = heappop(A)
    heappush(A, (-1)*(-mx//2))
A = list(map(lambda x: -x, A))
print(sum(A))

Measured memory_bytes: 14180
#include<bits/stdc++.h>
using namespace std;
#define MAXN 100000
#define ff first
#define ss second
#define ll long long
#define mod 1000000007
#define pii pair<ll,ll>
#define vi vector<ll>
#define mii map<ll,ll>
#define pb push_back
#define mp make_pair
#define ps(x,y) fixed<<setprecision(y)<<x
#define mk(arr,n,type) type *arr=new type[n];
#define w(x) ll x; cin>>x; while(x--)
#define endl '\n'
void kehsihba(){
   ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#ifndef ONLINE_JUDGE
   freopen("input.txt", "r", stdin);
   freopen("output.txt", "w", stdout);
#endif
}
double maxvolume(double s) 
{ 
    // finding length 
    double length = s / 3; 
  
    s -= length; 
  
    // finding breadth 
    double breadth = s / 2; 
  
    // finding height 
    double height = s - breadth; 
  
    return (double)length * breadth * height; 
} 
int32_t main() {
	//kehsihba();
	ll l;
	cin>>l;
	cout<<ps(maxvolume(l),6);
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using vll = vector<ll> ;
#define all(v) v.begin(),v.end()

int main(){
  ll N,K;cin>>N>>K;
  vll A(N);rep(i,N)cin>>A[i];
  long double left=0,right=1e9+1;
  while(right-left>0.000001){
    long double mid=left + (right-left)/2;
    ll cnt=0;
    rep(i,N){
      cnt += ll(A[i]/mid);
    }
    if(cnt<=K) right=mid;
    else left=mid;
    //cout<<left<<right<<mid<<endl;
    //cout<<cnt<<endl;
  }
  ll cnt=0;
  rep(i,N){
    cnt += ll(A[i]/left);
  }
  if(cnt<=K)cout<<ll(left)<<endl;
  else cout<<ll(left)+1<<endl;
}

Measured memory_bytes: 4712
#include <cstdio>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <algorithm>
using namespace std;
typedef long long LL;
const int MaxN = 1e6;

int a, b;
int main()
{
	scanf("%c %c", &a, &b);
	if(a == 'H' && b == 'H') printf("H\n");
	else if(a == 'H' && b == 'D') printf("D\n");
	else if(a == 'D' && b == 'H') printf("D\n");
	else if(a == 'D' && b == 'D') printf("H\n");
	return 0;
}

Measured memory_bytes: 128
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int k = sc.nextInt();

        List<Integer> ans = new ArrayList<>();

        for (int i = a; i <= b; i++) {
            if (i < a+k && !ans.contains(i)) ans.add(i);
            if (i > b-k && !ans.contains(i)) ans.add(i);
        }

        Collections.sort(ans);

        for (Integer i: ans) {
            System.out.println(i);
        }
    }
}


Measured memory_bytes: 22612
#include <bits/stdc++.h>
using namespace std;
const unsigned int MOD = 1000000007;
#define ll long long
#define PI 3.1416
#define Imax 1e9+5
#define LLmax 1e18
#define Imin -1e9-5
#define LLmin -1e18
string day [] = {"SUN", "MON", "TUE", "WED", "THU", "FRI", "SAT"};
vector <string> v;
bool sortByFirst(const pair<int,int>&a,const pair<int,int>&b){
    return a.first>b.first;
}
void dfs (string str, string t = "", int cnt = 0) {
    if (cnt == 2) {
        v.push_back (t);
        return;
    } else {
        for (int i = 0; i <str.size (); i ++) {
            dfs (str, t + str [i], cnt + 1);
        }
    }
}
int main () {
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    int n;
    while(cin>>n){
        cin.ignore();
        char str[n+1];
        cin>>str;
        char state=' ';
        int cnt=0;
        for(char c:str){
            if(c=='A')state='A';
            else if(c=='B' && state=='A')state='B';
            else if(c=='C' && state=='B'){
                cnt++;
                state=' ';
            }
            else
                state=' ';
        }
        cout<<cnt<<endl;
    }
    return 0;
}


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

namespace program
{
    class Program
    {
        static void Main()
        {
          int[] a = Input.ScanIntArray();
          
          if(Math.Abs(a[0]-a[2]) <= a[3] || (Math.Abs(a[0]-a[1])<=a[3] && Math.Abs(a[1]-a[2])<=a[3]))
            Console.WriteLine("Yes");
          else
            Console.WriteLine("No");
        }
    }

    static class Input
    {
        static public int ScanInt() { return int.Parse(Console.ReadLine()); }
        static public uint ScanUint() { return uint.Parse(Console.ReadLine()); }
        static public double ScanDouble() { return double.Parse(Console.ReadLine()); }
        static public long ScanLong() { return long.Parse(Console.ReadLine()); }
        static public ulong ScanUlong() { return ulong.Parse(Console.ReadLine()); }
        static public int[] ScanIntArray() { return Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray(); }
        static public uint[] ScanUintArray() { return Console.ReadLine().Split(' ').Select(x => uint.Parse(x)).ToArray(); }
        static public double[] ScanDoubleArray() { return Console.ReadLine().Split(' ').Select(x => double.Parse(x)).ToArray(); }
        static public long[] ScanLongArray() { return Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToArray(); }
        static public ulong[] ScanUlongArray() { return Console.ReadLine().Split(' ').Select(x => ulong.Parse(x)).ToArray(); }

        static public string ScanStr() { return Console.ReadLine(); }
        static public string[] ScanStrArray() { return ScanStr().Split(' '); }
    }

    static class MyMath
    {
        public static int GCD(int a, int b)
        {
            Func<int, int, int> gcd = null;
            gcd = (x, y) => y == 0 ? x : gcd(y, x % y);
            return a > b ? gcd(a, b) : gcd(b, a);
        }
        public static ulong GCD(ulong a, ulong b)
        {
            Func<ulong, ulong, ulong> gcd = null;
            gcd = (x, y) => y == 0 ? x : gcd(y, x % y);
            return a > b ? gcd(a, b) : gcd(b, a);
        }
        public static int LCM(int a, int b)
        {
            return a * b / GCD(a, b);
        }
        public static ulong LCM(ulong a, ulong b)
        {
            return a * b / GCD(a, b);
        }
    }
}


Measured memory_bytes: 11476
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdio>
#include <string>
#include <vector>
#include <complex>
#include <cstdlib>
#include <cstring>
#include <numeric>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <functional>

#define mp       make_pair
#define pb       push_back
#define all(x)   (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define repi(i,a,b) for(int i = (a); i < (b); i++)

using namespace std;

typedef    long long          ll;
typedef    unsigned long long ull;
typedef    vector<bool>       vb;
typedef    vector<int>        vi;
typedef    vector<vb>         vvb;
typedef    vector<vi>         vvi;
typedef    pair<int,int>      pii;

const int INF=1<<29;
const double EPS=1e-9;

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

int main(){
	string str;
	while(1){
		getline(cin,str);
		if(str=="END OF INPUT")break;
		int cnt = 0;
		for(int i =0;i <str.length();i++){
			if(str[i]==' '){
				cout <<cnt;
				cnt = 0;
			}else{
				cnt++;
			}
		}
		cout <<cnt<<endl;
	}
	return 0;
}

Measured memory_bytes: 1184
using System;
using System.Collections;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.Text;
using System.Text.RegularExpressions;
using System.Linq;
using System.IO;
using System.Diagnostics;

class Scanner
{
    private readonly char Separator = ' ';
    private int Index = 0;
    private string[] Line = new string[0];
    public string Next()
    {
        if (Index >= Line.Length)
        {
            Line = Console.ReadLine().Split(Separator);
            Index = 0;
        }
        var ret = Line[Index];
        Index++;
        return ret;
    }

    public int NextInt()
    {
        return int.Parse(Next());
    }

}

class Magatro
{
    private int N;
    private int[] T,V;
    private void Scan()
    {
        var sc=new Scanner();
        N=sc.NextInt();
        T=new int[N+1];
        V=new int[N+1];
        for(int i=0;i<N;i++)
        {
            T[i]=sc.NextInt();
        }
        for(int i=0;i<N;i++)
        {
            V[i]=sc.NextInt();
        }
    }
    
    private double Func(int max,int from,int to,int time)
    {
        if(from>max||to>max)
        {
            return -1;
        }
        double res=0;
        double y=(double)(from+to+time)/2;
        double x=y-from;
        if(0>x||x>time)
        {
            return -1;
        }
        res+=(from+y)*x/2;
        res+=(to+y)*(time-x)/2;
        if(max<y)
        {
            res-=(y-max)*(y-max);
        }
        return res;
    }

    public void Solve()
    {
        Scan();
        var dp=new double[101];
        for(int i=0;i<N;i++)
        {
            var next=new double[101];
            for(int j=0;j<=100;j++)
            {
                next[j]=-1;
            }
            if(i==0)
            {
                for(int to=0;to<=100;to++)
                {
                    var f=Func(V[i],0,to,T[i]);
                    next[to]=dp[0]+f;
                }
            }
            else
            {
                for(int from=0;from<=100;from++)
                {
                    for(int to=0;to<=100;to++)
                    {
                        var f=Func(V[i],from,to,T[i]);
                        if(f==-1||dp[from]==-1)continue;
                        next[to]=dp[from]+f;
                    }
                }
            }
            
            dp=next;
            //Console.WriteLine(string.Join(" ",dp));
        }
        Console.WriteLine(dp[0]);
    }

    static public void Main(string[]args)
    {
        new Magatro().Solve();
    }
}

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

#define rep(i, n) for(int i = 0; i < (n); i++)
using LL = long long;
using ULL = unsigned long long;

void solve() {
	vector<unsigned> p[256];
	string s, t; cin >> s >> t;
	rep(i, s.size()) p[s[i]].push_back(i);
	
	unsigned pp = 0, cycle = 0;
	rep(i, t.size()) {
		if (p[t[i]].size() == 0) { cout << -1 << endl; return; }
		char c = t[i];
		unsigned l = 0, r = p[c].size();
		while (l != r) {
			unsigned m = (l + r) / 2;
			if (p[c][m] >= pp) r = m;
			else l = m + 1;
		}
		if (p[c].size() == l) {
			cycle++; pp = p[c][0] + 1;
		}
		else {
			pp = p[c][l] + 1;
		}
	}

	ULL ans = ULL(s.size()) * cycle + pp;
	cout << ans << endl;
}

int main() {

	solve();

	return 0;
}


Measured memory_bytes: 1216
var input = require('fs').readFileSync('/dev/stdin', 'utf8');
var Arr=(input.trim()).split("\n");
var n="I,V,X,L,C,D,M".split(",");
var m=[1,5,10,50,100,500,1000];
var obj={};
n.forEach(function(v,i){obj[v]=m[i];});

Arr.forEach(function(val){
   var arr=val.split("");
   var sum=0;
   var before=1000;
   arr.forEach(function(v){
      var num=obj[v];
      if(before<num){sum+=num-(2*before);before=1000;}
      else{sum+=num;before=num;}
   });
   console.log(sum);
});

Measured memory_bytes: 8688
using System;

namespace AtCoder.ABC106
{
    public class A
    {
        public static void Solve()
        {
            string[] input = Console.ReadLine().Split(' ');
            int a = int.Parse(input[0]);
            int b = int.Parse(input[1]);
            
            Console.WriteLine((a - 1)*(b - 1));
        }    
    }
}

namespace AtCoder {
    class Program
    {
        static void Main(string[] args)
        {
            ABC106.A.Solve();
        }
    }
}


Measured memory_bytes: 11092
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(a) (a).begin(),(a).end()
#define pb emplace_back
#define INF (1e9+1)

#define MAX_NUM 1000000
bool era[MAX_NUM+1]={false};

void makeERA(){
    for(int i=2;i<MAX_NUM;i++){
        if(era[i]==true){
            int x=MAX_NUM/i;
            for(int j=2;j<=x;j++){
                era[i*j]=false;
            }
        }
    }
    era[2]=true;
}

bool isLike(int n){
    if(era[n]&&era[(n+1)/2])return true;
    else return false;
}

int main(){
    for(int i=0;i<MAX_NUM;i++)era[i]=true;
    era[0]=false;era[1]=false;
    makeERA();
    
    vector<int> v(1000001,0);
    for(int i=3;i<100000;i+=2){
        v[i] = v[i-2] + isLike(i);
    }
    
    int q;
    cin>>q;
    rep(i,q){
        int l,r;
        cin>>l>>r;
        int p = 0;
        if(l-2>=0)p = v[l-2];
        cout<<v[r]-p<<endl;
    }
}


Measured memory_bytes: 5504
#include <bits/stdc++.h>
#define int long long
#define pb push_back
#define double long double
#define pii pair<int, int>
#define FOR(i, a, b) for(int i = a; i < (int)(b); ++i)

using namespace std;

int32_t main() {
    string s, t;
    cin >> s >> t;
    int sl = s.length(), tl = t.length();
    s = " " + s;
    t = " " + t;
    int d[sl + 1][tl + 1];
    pii p[sl + 1][tl + 1];
    FOR(i, 0, sl + 1) {
        d[i][0] = 0;
    }
    FOR(i, 0, tl + 1) {
        d[0][i] = 0;
    }
    FOR(i, 1, sl + 1) {
        FOR(j, 1, tl + 1) {
            if (s[i] == t[j]) {
                d[i][j] = d[i - 1][j - 1] + 1;
                p[i][j] = {i - 1, j - 1};
            }
            else {
                d[i][j] = max(d[i - 1][j], d[i][j - 1]);
                if (d[i - 1][j] > d[i][j - 1]) {
                    d[i][j] = d[i - 1][j];
                    p[i][j] = {i - 1, j};
                }
                else {
                    d[i][j] = d[i][j - 1];
                    p[i][j] = {i, j - 1};
                }
            }
        }
    }
    vector<char> ans;
    int x = tl, y = sl;
    while (x && y) {
        if (s[y] == t[x]) 
            ans.pb(s[y]);
        pii q = p[y][x];
        x = q.second;
        y = q.first;
    }
    reverse(ans.begin(), ans.end());
    for(auto i : ans) {
        cout << i;
    }
    return 0;
}

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

ll INF = 1e18;
ll MOD = 1e9+7;


int main(){
    ll N, W; cin >> N >> W;
    vector<pair<ll, ll>> IN(N);
    map<ll, ll> M;
    for(int i = 0; i < N; i++){
        ll w, v; cin >> w >> v;
        IN[i] = make_pair(w, v);
    } 
    //sort(IN.begin(), IN.end());
    for(auto in : IN){
        ll wi = in.first, vi = in.second;
        vector<pair<ll, ll>> O;
        for(auto m : M){
            ll ws = m.first, vs = m.second;
            O.push_back(make_pair(ws+wi, vs+vi));
        }
        for(auto o : O){
            if(o.first <= W)M[o.first] = max(M[o.first], o.second);
        }
        if(wi <= W)M[wi] = max(M[wi], vi);
        //cout << M.size() << endl;
    }
    ll ans = 0;
    for(auto m : M){
        if(m.first <= W) ans = max(ans, m.second);
    }
    cout << ans << endl;

}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
//#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

#define ms(s, n) memset(s, n, sizeof(s))
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define FORd(i, a, b) for (int i = (a) - 1; i >= (b); --i)
#define FORall(it, a) for (__typeof((a).begin()) it = (a).begin(); it != (a).end(); it++)
#define sz(a) int((a).size())
#define present(t, x) (t.find(x) != t.end())
#define all(a) (a).begin(), (a).end()
#define uni(a) (a).erase(unique(all(a)), (a).end())
#define pb push_back
#define pf push_front
#define mp make_pair
#define fi first
#define se second
#define prec(n) fixed<<setprecision(n)
#define bit(n, i) (((n) >> (i)) & 1)
#define bitcount(n) __builtin_popcountll(n)
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int, int> pi;
typedef vector<int> vi;
typedef vector<pi> vii;
const int MOD = (int) 1e9 + 7;
const int FFTMOD = 1007681537;
const int INF = (int) 1e9;
const ll LINF = (ll) 1e18;
const ld PI = acos((ld) -1);
const ld EPS = 1e-9;
inline ll gcd(ll a, ll b) {ll r; while (b) {r = a % b; a = b; b = r;} return a;}
inline ll lcm(ll a, ll b) {return a / gcd(a, b) * b;}
inline ll fpow(ll n, ll k, int p = MOD) {ll r = 1; for (; k; k >>= 1) {if (k & 1) r = r * n % p; n = n * n % p;} return r;}
template<class T> inline int chkmin(T& a, const T& val) {return val < a ? a = val, 1 : 0;}
template<class T> inline int chkmax(T& a, const T& val) {return a < val ? a = val, 1 : 0;}
inline ll isqrt(ll k) {ll r = sqrt(k) + 1; while (r * r > k) r--; return r;}
inline ll icbrt(ll k) {ll r = cbrt(k) + 1; while (r * r * r > k) r--; return r;}
inline void addmod(int& a, int val, int p = MOD) {if ((a = (a + val)) >= p) a -= p;}
inline void submod(int& a, int val, int p = MOD) {if ((a = (a - val)) < 0) a += p;}
inline int mult(int a, int b, int p = MOD) {return (ll) a * b % p;}
inline int inv(int a, int p = MOD) {return fpow(a, p - 2, p);}
inline int sign(ld x) {return x < -EPS ? -1 : x > +EPS;}
inline int sign(ld x, ld y) {return sign(x - y);}
#define db(x) cerr << #x << " = " << (x) << " ";
#define endln cerr << "\n";

void chemthan() {
    int n, m; cin >> n >> m;
    if (n > m) swap(n, m);
    if (m == 1) {
        cout << 1 << "\n";
        return;
    }
    if (n == 1) {
        cout << max(0, m - 2) << "\n";
        return;
    }
    cout << (long long) (n - 2) * (m - 2) << "\n";
}

int main(int argc, char* argv[]) {
    ios_base::sync_with_stdio(0), cin.tie(0);
    if (argc > 1) {
        assert(freopen(argv[1], "r", stdin));
    }
    if (argc > 2) {
        assert(freopen(argv[2], "wb", stdout));
    }
    chemthan();
    cerr << "\nTime elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << "ms\n";
    return 0;
} 


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

public class Program
{
    public static void Main(string[] args)
    {
        var n = int.Parse(Console.ReadLine());
        var vals = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
        var cnt = 1;
        var min = vals[0];
        for (int i = 1; i < n; i++)
        {
            if (min > vals[i])
            {
                min = vals[i];
                cnt++;
            }
        }
        Console.WriteLine(cnt);
    }
}

Measured memory_bytes: 35676
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define forn(i, n) for(ll i = 0; i < (n); i++)
#define fori(i, b, e) for(ll i = (b); i < (e); i++)
#define forr(i, b, e) for(ll i = (b); i >= (e); i--)
#define allele(v) v.begin(), v.end()

int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n, k;
  cin >> n >> k;
  vector<int> h(n);
  forn(i, n) cin >> h[i];
  vector<int> dp(n, INT_MAX);
  dp[0] = 0;
  fori(i, 1, n) fori(j, 1, min(k, (int)i) + 1) dp[i] = min(dp[i], dp[i - j] + abs(h[i] - h[i - j]));
  cout << dp[n - 1];
  return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define PI 3.14159265358979323846
constexpr int INF = numeric_limits<int>::max() / 2;
constexpr long long INFL = numeric_limits<long long>::max() / 2;
constexpr int MOD = 1000000007;
using Graph = vector<vector<int>>;



int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);

    string S;
    cin >> S;
    string ans="Good";
    rep(i,3){
        if(S[i]==S[i+1]) ans="Bad";
    }
    cout << ans << endl;



}


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

//type
#define ll long long
typedef pair<int, int> P;
//定数
#define INF 1000000000000 //10^12:∞
#define MOD 1000000007    //10^9+7:合同式の法
#define MAXR 100000       //10^5:配列の最大のrange
//略記
#define PB push_back //挿入
#define MP make_pair //pairのコンストラクタ
#define F first      //pairの一つ目の要素
#define S second     //pairの二つ目の要素
#define Z class
// OTHER
// xの二乗を返す (関数テンプレート版)
template <typename T>
T square(T x) { return x * x; }
#define chmax(x, y) (x = max(x, y))
#define chmin(x, y) (x = min(x, y))
// loop
#define rep(i, n) for (int i = 0; i < (n); i++)
#define REPD(i, n) for (ll i = n - 1; i >= 0; i--)
#define FOR(i, a, b) for (ll i = a; i <= ll(b); i++)
#define FORD(i, a, b) for (ll i = a; i >= ll(b); i--)
#define FORA(i, I) for (const auto &i : I)

// vector
#define ALL(x) x.begin(), x.end()

// output
#define YES() printf("YES\n")
#define NO() printf("NO\n")
#define isYES(x) printf("%s\n", (x) ? "YES" : "NO")
#define Yes() printf("Yes\n")
#define No() printf("No\n")
#define ln cout << '\n'
template <Z A>
void pr(A a)
{
  cout << a;
  ln;
}
template <Z A, Z B>
void pr(A a, B b)
{
  cout << a << ' ';
  pr(b);
}

int ans = 0;
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *

int main()
{

  int k;
  cin >> k;
  int a = k / 2;
  int b = k - a;
  pr(a * b);
  return 0;
}


Measured memory_bytes: 3624
N,K = map(int,input().rstrip().split(" "))
s = list(map(int,input().strip().split(" ")))
c = [-1 for _ in range(N)]
c[0] = 0
for i in range(N):
  for i2 in range(1,K + 1):
    if i + i2 <= N -1:
      if c[i + i2] == -1 or c[i] + abs(s[i] - s[i + i2]) < c[i + i2]:
        c[i + i2] = c[i] + abs(s[i] - s[i + i2])
print(c[N -1])


Measured memory_bytes: 55904
#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 dump(x)  cerr << #x << " = " << (x) << endl;
#define PB push_back
#define MP make_pair
#define ll long long
#define MOD 1000000007

inline ll toll(string s){ll v;istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x){ostringstream sout;sout<<x;return sout.str();}

ll mod_pow(const ll x, ll n, const ll mod) {
    ll res = 1;
    if (n == 0) return 1;
    if (n & 1) res = x;
    ll y = mod_pow(x, n >> 1, mod);
    res = (res * (y * y % mod)) % mod;
    return res;
}

bool visited[1000100];
int main(){
    std::ios::sync_with_stdio(false);
    ll n;
    cin >> n;
    vector<ll> a(n);

    for(ll i=0;i<n;++i){
        cin >> a[i];
    }

    map<ll,ll> factors;
    for(ll i=0;i<n;++i)
    {
        ll tmp = a[i];
        ll cnt = 0;
        for(ll ind=2; (ind * ind) <= tmp; ++ind)
        {
            while((tmp % ind) == 0) {
                cnt++;
                tmp /= ind;
            }

            if(cnt != 0)
            {
                factors[ind] = max(factors[ind], cnt);
            }
            cnt = 0;
        }
        factors[tmp] = max(factors[tmp], 1ll);
    }
    // for each a, would like to calc gcd / a mod MOD
    ll lcm_mod = 1;
    for(const auto& factor : factors) {
        lcm_mod *= mod_pow(factor.first, factor.second, MOD);
        lcm_mod %= MOD;
    }

    ll res = 0;
    for(ll i=0;i<n;++i)
    {
        ll tmp = lcm_mod * mod_pow(a[i], MOD-2, MOD);
        res += tmp;
        res %= MOD;
    }

    cout << res << endl;

    return 0;
}


Measured memory_bytes: 1024
#include<iostream>
using namespace std;
int main()
{
    int t,ac=0,wa=0,tle=0,re=0;
    string s;
    cin>>t;
    for(int i=0;i<t;i++)
    {
        cin>>s;
        if(s=="AC")
            ac++;
        else if(s=="WA")
            wa++;
        else if(s=="TLE")
            tle++;
        else
            re++;
    }
    cout<<"AC x "<<ac<<endl;
    cout<<"WA x "<<wa<<endl;
    cout<<"TLE x "<<tle<<endl;
    cout<<"RE x "<<re<<endl;
    return 0;
}


Measured memory_bytes: 3640
#include <iostream>
#include <vector>
using namespace std;
constexpr int MOD = 1e9 + 7;

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

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

bool used[101010];

int main() {
    cin.tie(0); ios_base::sync_with_stdio(false);
    int n, d; cin >> n;
    vector<int> a(n); for(int i=0; i <= n; ++i) {
        cin >> a[i];
        if(used[a[i]]) d = a[i];
        else used[a[i]] = true;
    }
    CombInit();

    int cnt = 0;
    for(int i=0; a[i] != d; ++i, ++cnt);
    for(int i=n; a[i] != d; --i, ++cnt);


    for(int i=0; i <= n; ++i) {
        long long ans = (Comb(n + 1, i + 1) - Comb(cnt, i) + MOD) % MOD;
        cout << ans << '\n';
    }
        
    return 0;
}


Measured memory_bytes: 4096
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
#define sz(x) int(x.size())
#define pb push_back
#define eb emplace_back
using ll=long long;
using P = pair<int,int>;
using LP=pair<ll,int>;
#define chmax(x,y) x = max(x,y)
#define chmin(x,y) x = min(x,y)
const ll MOD=1000000007,MOD2=998244353;

int D;
vector<int> down(26);
vector<vector<int>> up;

int main() {
    //std::chrono::system_clock::time_point  start, end; // 型は auto で可
    //start = std::chrono::system_clock::now();

    cin>>D;
    rep(i,26)cin>>down.at(i);
    up.resize(D,vector<int>(26));
    rep(i,D)rep(j,26)cin>>up.at(i).at(j);

    ll ans=0;
    vector<ll> human(26,0);
    rep(day,D){
        rep(i,26){
            human.at(i)+=down.at(i);
            ans-=human.at(i);
        }
        int choice=0;
        rep(i,26){
            if(human.at(i)+up.at(day).at(i)>human.at(choice)+up.at(day).at(choice)){
                choice=i;
            }
        }
        ans+=human.at(choice)+up.at(day).at(choice);
        human.at(choice)=0;
        cout<<choice+1<<endl;
    }

    //double elapsed;
    
    /*while(elapsed<1950){//時間が許す限り
        
        end = std::chrono::system_clock::now();  // 計測終了時間
        elapsed = std::chrono::duration_cast<std::chrono::milliseconds>(end-start).count();
    }*/
    
}

Measured memory_bytes: 3664
#include<stdio.h>
#include<iostream>
#include<math.h>
using namespace std;
int n,tot=0,temp;
bool m[10005];
bool pri(int mt){
	for(int i=2;i<=(int)sqrt(mt);i++){
		if(mt%i==0){
			return 0;
		}
	}
	return 1;
}
int main(void){
	scanf("%d",&n);
	for(int i=0;i<n;i++){
		scanf("%d",&temp);
		if(temp>2){
			if(pri(temp)){
				tot++;
			}
		}
		else if(temp==2){
			tot++;
		}
		else if(temp==1||temp==0){
		}
	}
	printf("%d\n",tot);
	return 0;
}

Measured memory_bytes: 3204
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <random>
#include <iomanip>
#include <functional>
#include <cassert>

using namespace std;

typedef long long ll;

int main() {
  ios_base::sync_with_stdio(false); cin.tie(0);
#ifdef LOCAL
  freopen("input.txt", "r", stdin);
#endif
  int n;
  cin >> n;
  vector <int> a(n);
  for (int i = 0; i < n; ++i) cin >> a[i];
  map <int, int> have;
  for (int x : a) ++have[x];
  int ans = 0;
  for (int d = (1 << 30); d >= 1; d /= 2) {
    for (int x : a) {
      if (have.count(d - x) && x != d - x && have[x] != 0 && have[d - x] != 0) {
        int can = min(have[x], have[d - x]);
        ans += can;
        have[x] -= can;
        have[d - x] -= can;
      }
    }
  }
  for (int d = (1 << 30); d >= 1; d /= 2) {
    for (int x : a) {
      if (have.count(d - x) && x == d - x && have[x] > 1) {
        int can = have[x] / 2;
        ans += can;
        have[x] -= 2 * can;
      }
    }
  }
  cout << ans << '\n';
}



Measured memory_bytes: 12416
#include <bits/stdc++.h>//Carefully Crafted by hetp111
using namespace std;
#define int long long
#define double long double
#define all(v) (v).begin(),(v).end()
#define vi vector<int>
#define vvi vector<vi>
#define pii pair<int,int>
#define vii vector<pii>
#define MOD (1000000007)
#define PI acos(-1)
#define eps (1e-8)
#define INF (1e18)
#define FASTER ios_base::sync_with_stdio(0);cin.tie(0)
template<class A,class B>ostream&operator<<(ostream&out,const pair<A,B>&a){return out<<"("<<a.first<<","<<a.second<<")";}
template<class A>ostream&operator<<(ostream&out,const vector<A>&a){for(const A &it:a)out<<it<<" ";return out;}
template<class A,class B>istream&operator>>(istream&in,pair<A,B>&a){return in>>a.first>>a.second;}
template<class A>istream&operator>>(istream&in,vector<A>&a){for(A &i:a)in>>i;return in;}
//ifstream cinn("input.txt");ofstream coutt("output.txt");

signed main(){
    FASTER;
    int n,cnt=0;cin>>n;
    int v[n+1],mp[n+1];
    for(int i=1;i<=n;i++){
        cin>>v[i];
    }
    int mx=INF;
    for(int i=1;i<=n;i++){
        if(v[i]<=mx){
            cnt++;
        }
        mx=min(mx,v[i]);
    }
    cout<<cnt;

}

Measured memory_bytes: 1792
object Main extends App {
  val in = new java.util.Scanner(System.in)
  val A, B, C, K = in.nextInt

  def twice(a: Int, b: Int, cnt: Int): (Int, Int) = {
    if (a < b) (b, cnt) else twice(a, b * 2, cnt + 1)
  }

  val (newB, cntB) = twice(A, B, 0)
  val (_, cnt) = twice(newB, C, cntB)

  println(if (cnt <= K) "Yes" else "No")
}

Measured memory_bytes: 55420
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner scn = new Scanner(System.in);
		int a = scn.nextInt();
		int b = scn.nextInt();
		int c = scn.nextInt();
		int[] arr = { a, b, c };
		Arrays.parallelSort(arr);
		if (arr[0] == 5 && arr[1] == 5 && arr[2] == 7) {
			System.out.println("YES");
		} else {
			System.out.println("NO");
		}

	}

}


Measured memory_bytes: 26976
package main

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

var sc = bufio.NewScanner(os.Stdin)

func Scan() string {
	sc.Scan()
	return sc.Text()
}

func iScan() int {
	n, _ := strconv.Atoi(Scan())
	return n
}

func fScan() float64 {
	n, _ := strconv.ParseFloat(Scan(), 64)
	return n
}
func stringToInt(s string) int {
	n, _ := strconv.Atoi(s)
	return n
}
func SScan(n int) []string {
	a := make([]string, n)
	for i := 0; i < n; i++ {
		a[i] = Scan()
	}
	return a
}
func iSScan(n int) []int {
	a := make([]int, n)
	for i := 0; i < n; i++ {
		a[i] = iScan()
	}
	return a
}
func abs(x int) int {
	if x < 0 {
		x = -x
	}
	return x
}
func larger(a, b int) int {
	if a < b {
		return b
	} else {
		return a
	}
}
func smaller(a, b int) int {
	if a > b {
		return b
	} else {
		return a
	}
}
func max(a []int) int {
	x := a[0]
	for i := 0; i < len(a); i++ {
		if x < a[i] {
			x = a[i]
		}
	}
	return x
}
func min(a []int) int {
	x := a[0]
	for i := 0; i < len(a); i++ {
		if x > a[i] {
			x = a[i]
		}
	}
	return x
}
func sum(a []int) int {
	x := 0
	for _, v := range a {
		x += v
	}
	return x
}

var mod int = 1000000007

func main() {
	buf := make([]byte, 0)
	sc.Buffer(buf, mod)
	sc.Split(bufio.ScanWords)
	n := iScan()
	t := iScan()
	ans := mod
	for i := 0; i < n; i++ {
		x, y := iScan(), iScan()
		if y <= t {
			ans = smaller(x, ans)
		}
	}
	if ans == mod {
		fmt.Println("TLE")
	} else {
		fmt.Println(ans)
	}
}


Measured memory_bytes: 1776
#include <iostream>
#include<algorithm>
#include<string>
#include <cmath>
#include <vector>
#include <map>
#include <cstdio>
#include <iomanip>
#include<set>
#include <numeric>
#pragma region Macros
#define int long long
#define double long double
constexpr int MOD = 1000000007;
constexpr double PI = 3.14159265358979323846;
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<=n;i++)
#define LAST(x) x[x.size()-1]
#define ALL(x) (x).begin(),(x).end()
#define swap(a,b) (a += b,b = a - b,a -= b)
#define DIVCEIL(a,b) ((a+b-1)/b)
//int CHMAX

int FACT(int a) {
	if (a == 0)
		return 1;
	else
		return a * FACT(a - 1);
}
int MODFACT(int a, int mod) {
	if (a == 0)
		return 1;
	else
		return (a * FACT(a - 1))%mod;
}
int nPr(int n, int r) {
	int s = n - r + 1;
	int sum = 1;
	for (int i = s; i <= n; i++)
		sum *= i;
	return sum;
}
int MODnPr(int n, int r, int mod) {
	int s = n - r + 1;
	int sum = 1;
	for (int i = s; i <= n; i++) {
		sum *= i;
		sum = sum % MOD;
	}
	return sum;
}
//int nCr(int n, int r)
int nCr2(int n, int r) {
	return FACT(n) / (FACT(r) * FACT(n - r));
}
int GCD(int a, int b)
{
	if (a < b)
		swap(a, b);
	if (b == 0)
		return a;
	if (a % b == 0)
		return b;
	return GCD(b, a % b);
}
int LCM(int a, int b)
{
	return  a * b / GCD(a, b);
}
int NUMOFDIV(int n) {
	//約数の数（だっけ？）
	int ans = 0;
	REP(i, n) {
		if (n % i == 0)
			ans++;
	}
	return ans;
}
int CEIL1(int n) {
	//1桁目切り上げ
	return (n + 9) / 10 * 10;
}
int DIGIT(int n,int k) {
	//nのk桁目
	rep(i, k-1)
		n /= 10;
	return n % 10;
}
int DIGITSUM(int n) {
	int sum = 0, dig;
	while (n) {
		dig = n % 10;
		sum += dig;
		n /= 10;
	}
	return sum;
}
int DIVTIME(int n, int k) {
	//nをkで何回割れるか的な
	int div = 0;
	while (n % k == 0) {
		div++;
		n /= k;
	}
	return div;
}
int MODPOW(int a, int n, int mod) {
	// a^n mod
	int ans = 1;
	while (n > 0) {
		if (n & 1)
			ans = ans * a % mod;
		a = a * a % mod;
		n >>= 1;
	}
	return ans;
}
double LOG(int a, int b) {
	return log(b) / log(a);
}
inline bool BETWEEN(int x, int min, int max) {
	if (min <= x && x <= max)
		return true;
	else
		return false;
}
inline bool between(int x, int min, int max) {
	if (min < x && x < max)
		return true;
	else
		return false;
}
inline bool PRIMEOR(int x) {
	if (x == 1)
		return false;
	if (x == 2)
		return true;
	if (x % 2 == 0)
		return false;
	double sqrtx = sqrt(x);
	for (int i = 3; i <= sqrtx; i += 2) {
		if (x % i == 0)
			return false;
	}
	return true;
}
bool SQRTOR(int n) {
	if (sqrt(n) == (int)sqrt(n))
		return true;
	else
		return false;
}
// 順位付け
using namespace std;
#pragma endregion
signed main() {
	int D, N;
	cin >> D >> N;
	if (N != 100)
		cout << N;
	else
		cout << 101;
	rep(i, D)
		cout << "00";
}

Measured memory_bytes: 256
fun pfactorize(n: Long): Map<Long, Int> {
    val primes = mutableMapOf<Long, Int>()
    fun _add(x: Long) {
        val e = primes[x]
        if (e == null) {
            primes[x] = 1
        } else {
            primes[x] = e + 1
        }
    }
    fun _pfactorize(x: Long): Long {
        var p = 2L
        while (p * p <= x) {
            if (x % p == 0L) {
                _add(p)
                return _pfactorize(x / p)
            }
            p++
        }
        return x
    }
    _add(_pfactorize(n))
    return primes
}

fun main(args: Array<String>) {
    val (n, p) = readLine()!!.split(" ").map(String::toLong)
    val primes = pfactorize(p)
    var gcd = 1L
    primes.forEach {
        val f = it.key
        val e = it.value
        gcd *= Math.pow(f.toDouble(), (e / n).toDouble()).toLong()
    }
    println(gcd)
}


Measured memory_bytes: 37912
#include<stdio.h>

int main(){
  int i, j;
  int h, w;

  while(1){
    scanf("%d %d", &h, &w);

    if(h == 0 && w == 0) break;
  
    for(i = 0; i < h; i++){
      for(j = 0; j < w; j++){
	if(i == 0 || i == h - 1 || j == 0 || j == w - 1){
	  printf("#");
	}
	else{
	  printf(".");
	}
      }
      printf("\n");
    }
    printf("\n");
  }
  
  return 0;
}


Measured memory_bytes: 2036
#include <bits/stdc++.h> 
using namespace std; 
using str = string; 
using ll = long long; 
#define REP(i,n) for(int i=0; i<int(n); i++) 
#define RREP(i,n) for(int i=int(n)-1; i>=0; i--) 
#define FOR(i,f,t) for(int i=int(f); i<=int(t); i++) 
#define RFOR(i,f,t) for(int i=int(f); i>=int(t); i--) 
#define ALL(vec) (vec).begin(),(vec).end() 
#define ASORT(vec) sort(ALL(vec)) 
#define DSORT(vec) sort(ALL(vec), greater<int>()); 
#define MAX(x) *max_element(ALL(x)) 
#define MIN(x) *min_element(ALL(x)) 
#define YES(ans) if(ans) cout<<"YES"<<endl; else cout<<"NO"<<endl; 
#define Yes(ans) if(ans) cout<<"Yes"<<endl; else cout<<"No"<<endl; 
#define yes(ans) if(ans) cout<<"yes"<<endl; else cout<<"no"<<endl; 

ll gcd(ll a, ll b) { 
	if (a%b == 0) return(b); 
	else return(gcd(b, a%b)); 
} 

ll lcm(ll a, ll b) { 
	return a * b / gcd(a, b); 
} 

int main() {
char c, a='a'; 
cin >> c; 
if(c<a) cout << 'A' << endl; 
else cout << 'a' << endl; 
} 


Measured memory_bytes: 3592
#include<bits/stdc++.h>
#define int long long
using namespace std;
vector < vector<int>>edges;
void dfs(int v, vector<int>& add, vector<int>& ans, int prev) {
	add[v] += add[prev];
	for (auto u : edges[v]) {
		if (u != prev)dfs(u, add, ans, v);
	}
}
signed main(void)
{
	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	string s, t;
	cin >> s >> t;
	map<char, int>cnt_s;
	map<char, int>cnt_t;
	for (auto now : s)cnt_s[now]++;
	for (auto now : t)cnt_t[now]++;
	bool flag = true;
	for (auto now : cnt_t) {
		if (cnt_s.find(now.first) == cnt_s.end())flag = false;
	}
	if (!flag) {
		cout << -1; return 0;
	}
	map<char, set<int>>cs;
	for (int i = 0; i < s.size(); i++) {
		cs[s[i]].insert(i + 1);
		cs[s[i]].insert(i + s.size() + 1);
	}
	int ans = 0, prev = 0;
	for (int i = 0; i < t.size(); i++) {
		int curr  = *cs[t[i]].upper_bound(prev);
		if (curr >= s.size()) {
			curr -= s.size();
			ans += s.size() - prev + curr;
			prev = curr;
		}
		else {
			ans += curr - prev;
			prev = curr;
		}

	}
	cout << ans;
	return 0;
}

Measured memory_bytes: 9808
// 2011/11/07 Tazoe

#include <iostream>
#include <string>
using namespace std;

int main()
{
	string S;
	cin >> S;

	int N;
	cin >> N;

	int cnt = 0;
	for(int i=0; i<N; i++){
		string R;
		cin >> R;

		R = R+R;

		if(R.find(S)!=string::npos)
			cnt++;
	}

	cout << cnt << endl;

	return 0;
}

Measured memory_bytes: 0
from operator import itemgetter
import heapq
n,m=map(int,input().split())
l=[list(map(int,input().split())) for i in range(n)]
l.sort()
ct=0
j=0
ans=[]
heapq.heapify(ans)
for i in range(1,m+1):
  if j!=n:
    while l[j][0]==i:
      heapq.heappush(ans,-l[j][1])
      j+=1
      if j==n:
        break
  if len(ans)>0:
    ct+=heapq.heappop(ans)
print(-ct)

Measured memory_bytes: 31692
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/rope>

#define ll long long
#define pb push_back
#define sz(x) (int)(x).size()
#define mp make_pair
#define f first
#define s second
#define all(x) x.begin(), x.end()

using namespace std;
using namespace __gnu_pbds;
using namespace __gnu_cxx;

template<class T> using ordered_set = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>; ///find_by_order(),order_of_key()
template<class T1, class T2> ostream& operator<<(ostream& os, const pair<T1,T2>& a) { os << '{' << a.f << ", " << a.s << '}'; return os; }
template<class T> ostream& operator<<(ostream& os, const vector<T>& a) {
	os << '{';
	for(int i=0;i<sz(a);i++)
	{
		if(i>0&&i<sz(a)-1)
			os << ", ";
		os << a[i];
	}
	os << '}';
    return os;
}
const int N=3e3+5;
double p[N][N];
int main()
{
    int n;
    scanf("%i",&n);
    p[0][0]=1;
    for(int i=1;i<=n;i++)
    {
        double h;
        cin >> h;
        double t=(double)1-h;
        for(int j=0;j<=i;j++)
        {
            p[i][j]=(double)p[i-1][j]*t;
            if(j>0)
                p[i][j]+=(double)p[i-1][j-1]*h;
        }
    }
    double pp=0;
    for(int i=n;i>n/2;i--)
        pp+=p[n][i];
    printf("%.10f\n",pp);
    return 0;
}


Measured memory_bytes: 68992
#define _USE_MATH_DEFINES
#define INF 0x3f3f3f3f

#include <complex>
#include <iostream>
#include <cstdio>
#include <sstream>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <queue>
#include <stack>
#include <limits>
#include <map>
#include <string>
#include <cstring>
#include <set>
#include <deque>
#include <bitset>
#include <list>
#include <cctype>
#include <utility>
  
using namespace std;
  
typedef long long ll;
typedef complex<double> P;
  
static const double EPS = 1e-8;
  
int tx[] = {0,1,0,-1};
int ty[] = {-1,0,1,0};

double dot(const P& a,const P& b) {
  return (a.real() * b.real() + a.imag() * b.imag());
}

double cross(P a, P b) {
  return (a.real() * b.imag() - a.imag() * b.real());
}
bool cmp_x(const P& p, const P& q){
  if(p.real() != q.real()) return p.real() < q.real();
  return p.imag() < q.imag();
}

vector<P> convex_hull(P* ps, int n){
  sort(ps, ps+n, cmp_x);
  int k = 0;
  vector<P> qs(n * 2);
  for(int i=0; i < n; i++){
    while(k > 1 && cross(qs[k - 1] - qs[k - 2],ps[i] - qs[k - 1]) <= 0) k--;
    qs[k++] = ps[i];
  }
  for(int i=n - 2,t = k; i >= 0; i--){
    while(k > t && cross(qs[k - 1] - qs[k - 2],ps[i] - qs[k - 1]) <= 0) k--;
    qs[k++] = ps[i];
  }
  qs.resize(k-1);
  return qs;
}

double dist(const P& p,const P& q){
  return dot(p-q,p-q);
}

int main(){
  int N;
  while(~scanf("%d",&N)){
    if(N == 0) break;

    P ps[10001];
    for(int i=0;i<N;i++){
      double x,y;
      scanf("%lf,%lf",&x,&y);
      ps[i] = P(x,y);
    }
    vector<P> qs = convex_hull(ps,N);
    cout << N - qs.size() << endl;
  }
}

Measured memory_bytes: 1400