akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <numeric>
#include <string>
#include <cstdio>
#include <cstring>
#include <queue>
#include <stack>
#include <set>
#include <cmath>
#include <bitset>
#include <iomanip> 

using ll = long long;
using ull = unsigned long long;
using namespace std;

#define FALSE printf("false\n");
#define TRUE printf("true\n");
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int i = 0;(i) < ((int)(n));++(i))
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() )
#define test(a) cout<<"line:"<<__LINE__<<"["<<(#a)<<": "<<(a)<<"]"<<endl

const int INF = 1e9+7;
const ll INFL = 9*1e18;

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

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

ll inline digit(ll num){int tmp = 0;while(num){tmp++;num/=10;}return tmp;} // 桁数
template<typename T>inline void print(T&& x){cout<<x<<endl;}// 改行付き出力
template<typename T>inline T SUM(vector<T> vec){return accumulate(all(vec),(T)0);} // vectorの中身を全部足す
template<typename T>inline T digitSum(T num){T sum = 0;while(num){sum+=num%10;num/=10;}return sum;} // 各桁の和
template<typename T>inline T gcd(T a,T b){if(b == 0)return a;return gcd(b,a%b);} // 最大公約数
template<typename T>inline T lcm(T a, T b){T g = gcd(a,b);return a/g*b;} // 最小公倍数
template<typename T>inline T power(T a,T b){T tmp=1;rep(i,b){tmp*=a;}return tmp;} // 累乗
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
int ctoi(char c){return c-'0';}



// TODO: write
int main() {
  ll a,b;cin>>a>>b;
  ll ans = INFL;
  if(a <= b){
    ans = b-a;
    ans = min(ans,1+abs(-a-b));
  }else{
    if(a >= 0)ans = 1 + abs(-a-b);
    ans = min(ans,2+abs(a-b));
  }
  print(ans);
  return 0;
}

Measured memory_bytes: 3600
#include<stdio.h>
#include<stdlib.h>
int main()
{
	int n,i;
	long a[100],x=0,y=1000000001;

	scanf("%d",&n);
	for(i=0;i<n;i++)
		scanf("%ld",&a[i]);

	for(i=0;i<n;i++){
		if(x<a[i])
			x=a[i];
		if(y>a[i])
			y=a[i];
	}
	printf("%ld",x-y);
	return 0;
}

Measured memory_bytes: 128
{-# LANGUAGE FlexibleInstances    #-}
{-# LANGUAGE TypeSynonymInstances #-}

import           Control.Applicative
import           Control.DeepSeq
import           Control.Monad
import           Control.Monad.ST
import qualified Data.Array                    as A
import qualified Data.Array.IArray             as IA
import qualified Data.Array.IO                 as AI
import qualified Data.Array.MArray             as MA
import qualified Data.Array.ST                 as STA
import qualified Data.Array.Unboxed            as AU
import           Data.Bits
import qualified Data.ByteString.Char8         as BS
import           Data.Char
import qualified Data.Graph                    as G
import           Data.Int
import qualified Data.IntMap                   as IM
import qualified Data.IntSet                   as IS
import           Data.List
import qualified Data.Map.Strict               as M
import           Data.Maybe
import           Data.Ord
import qualified Data.Sequence                 as SQ
import qualified Data.Set                      as S
import           Data.Time
import qualified Data.Tree                     as T
import qualified Data.Vector                   as V
import qualified Data.Vector.Mutable           as VM
import qualified Data.Vector.Unboxed           as VU
import qualified Data.Vector.Unboxed.Mutable   as VUM

readInt :: IO [Int]
readInt = map (fst . fromJust . BS.readInt) . BS.words <$> BS.getLine

readInts :: Int -> IO [[Int]]
readInts n = replicateM n readInt

readInteger :: IO [Integer]
readInteger = map (fst . fromJust . BS.readInteger) . BS.words <$> BS.getLine

readIntegers :: Int -> IO [[Integer]]
readIntegers n = replicateM n readInteger

readString :: IO [String]
readString = map BS.unpack . BS.words <$> BS.getLine

readStrings :: Int -> IO [[String]]
readStrings n = replicateM n <$> readString

toPair :: [a] -> (a, a)
toPair [x, y] = (x, y)

count :: Eq a => a -> [a] -> Int
count a as = length $ filter (== a) as

put :: Show a => a -> IO ()
put = putStr . show

putLn :: Show a => a -> IO ()
putLn = print

putList :: Show a => [a] -> IO ()
putList [n     ] = put n
putList (n : ns) = do
  put n
  putStr " "
  putList ns

putStrList :: [String] -> IO ()
putStrList [n     ] = putStr n
putStrList (n : ns) = do
  putStr n
  putStr " "
  putStrList ns

yesNoUpper b | b         = putStrLn "YES"
             | otherwise = putStrLn "NO"

yesNo b | b         = putStrLn "Yes"
        | otherwise = putStrLn "No"

main = do
  [a, b,c] <- readInt
  yesNo $ (a<=c&&c<=b)

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

#define lint long long
#define P pair<int, int>
#define LLP pair<long long, long long>
#define REP(i, x, n) for(int i = (x), i##_len = (int)(n) ; i < i##_len ; ++i)
#define rep(i, n) for(int i = 0, i##_len = (int)(n) ; i < i##_len ; ++i)
#define repr(i, n) for(int i = (int)(n) - 1 ; i >= 0 ; --i)
#define SORT(x) sort((x).begin(), (x).end())
#define SORT_INV(x) sort((x).rbegin(), (x).rend())

const int IINF = 1e9 + 10;
const long long LLINF = (long long)1e18 + 10;
const long long MOD = (long long)1e9 + 7;
const int dx4[] = {1, 0, -1, 0}, dy4[] = {0, 1, 0, -1};
const int dx8[] = {1, 1, 0, -1, -1, -1, 0, 1}, dy8[] = {0, -1, -1, -1, 0, 1, 1, 1};
const double EPS = 1e-8;

int h, w;
vector< vector<char> > v;

void dfs(int y, int x, char c){
    v[y][x] = '.';
    rep(i, 4){
        int ny = y + dy4[i], nx = x + dx4[i];
        if(v[ny][nx] == c){
            dfs(ny, nx, c);
        }
    }
    return;
}

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

    while(cin >> h >> w, h){
        v.resize(h + 2);
        rep(i, h + 2){
            v[i].clear();
            v[i].resize(w + 2, '.');
        }
        REP(i, 1, h + 1){
            REP(j, 1, w + 1){
                cin >> v[i][j];
            }
        }
        int ans = 0;
        REP(i, 1, h + 1){
            REP(j, 1, w + 1){
                if(v[i][j] != '.'){
                    ++ans;
                    dfs(i, j, v[i][j]);
                }
            }
        }
        cout << ans << endl;
    }

    return 0;
}


Measured memory_bytes: 3820
using System;
using System.Collections.Generic;

class Program
{
    static void Main(string[] args)
    {
        string[] input = Console.ReadLine().Split();

        List<int> intlist = new List<int>();

        foreach (string s in input)
        {
            intlist.Add(int.Parse(s));
        }

        if ((intlist[0] == intlist[1]) && (intlist[1] == intlist[2]))
        {
            Console.WriteLine("Yes");
        }
        else
        {
            Console.WriteLine("No");
        }
    }
}


Measured memory_bytes: 11092
S=input()
T=input()

s,t=len(S),len(T)
#DPテーブル作成
dp=[[0]*(t+1) for _ in range(s+1)]

for i in range(s):
    for j in range(t):
        if S[i] ==T[j]:
            dp[i+1][j+1] =dp[i][j] + 1
        else:
            dp[i+1][j+1] =  max([ dp[i+1][j] , dp[i][j+1] ])
# print(*dp,sep="\n")

res = ''
while s != 0 and t != 0:
    if dp[s][t] == dp[s-1][t]:
        s -= 1
    elif dp[s][t] == dp[s][t-1]:
        t -= 1
    else:
        s -= 1
        t -= 1
        res = S[s] + res

# print(dp[s][t])
print(res)

Measured memory_bytes: 112604
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<cstdlib>
#include<queue>
#include<set>
#include<cstdio>
#include<map>

using namespace std;

#define ll long long
#define rep(i, n) for(int i = 0; i < n; i++)
#define P pair<int, int>

typedef vector<int> vec;
typedef vector<vec> mat;

const ll mod = 1000000007;

int main(){
    int n;
    cin >> n;
    vector<P> dec[n];
    rep(i, n){
        int a;
        cin >> a;
        rep(j, a){
            int x, y;
            cin >> x >> y;
            x--;
            dec[i].push_back(P(x, y));
        }
    }
    int ans = 0;
    rep(i, 1<<n){
        bool flag = true;
        rep(j, n){
            if ((i>>j)&1){
                rep(k, dec[j].size()){
                    if(((i>>dec[j][k].first)&1) != dec[j][k].second) flag=false;
                }
            }
        }
        if(flag){
            int ans_ = 0;
            rep(j, n){
                if((i>>j)&1)ans_++;
            }
            ans = max(ans, ans_);
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3612
object Main extends App {
  val inputs: Seq[String] = scala.io.Source.stdin.getLines().toList
  val n  = inputs(0).toInt
  val ai = inputs(1).split(" ").map(_.toInt)

  println(solve(n, ai))

  def solve(n: Int, ai: Seq[Int]): Long = {
    var start = ai(0).toLong
    val size  = ai.size
    var money = 1000L
    var stock = 0L

    (1 until size).foreach { i =>
      val currentStockPrice = ai(i).toLong
      if(start < currentStockPrice) {
        // 過去の改竄
        stock = money / start // 安かったときに全力買い
        money = money % start // 残金
        // println(s"購入: stock = $stock, money = $money")

        // 現在の処理
        money = money + (stock * currentStockPrice) // 今の値段で全部売る
        stock = 0
        start = currentStockPrice
        // println(s"売却: stock = $stock, money = $money")
      } else if (start > currentStockPrice) {
        start = currentStockPrice
      }
      // println(s"仕入れ値: $start")
    }

    money
  }
}

Measured memory_bytes: 54828
#include <iostream>
#include <string>
#include <map>
#include <set>
#include <vector>
#include <algorithm>
#include <iomanip>

using namespace std;

int main()
{
  int a;
  cin >> a;

  if (a == 1)
  {
    cout << "Hello World" << endl;
  }
  else if (a == 2)
  {
    int A, B;
    cin >> A >> B;
    cout << A + B << endl;
  }
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES

#include <array>
#include <iostream>
#include <string>
#include <sstream>
#include <vector>
#include <utility>
#include <tuple>
#include <algorithm>
#include <limits>
#include <fstream>
#include <numeric>
#include <stack>
#include <queue>
#include <list>
#include <cstring>
#include <unordered_set>
#include <cmath>
#include <iomanip>

namespace
{
	template<int N>
	std::array<int, N> GetValue(std::istream& stream)
	{
		std::string buf;
		std::getline(stream, buf);

		std::stringstream sstr(buf);
		std::array<int, N> retval;

		for (int i = 0; i < N; ++i)
		{
			std::getline(sstr, buf, ' ');
			retval[i] = std::stoi(buf);
		}

		return retval;
	}

	std::vector<int> GetValue(std::istream& stream, int num, char delim)
	{
		std::string buf;
		std::getline(stream, buf);
		std::stringstream sstr(buf);

		std::vector<int> retval;
		retval.reserve(num);

		std::string input;;
		for (int i = 0; i < num && std::getline(sstr, input, delim); ++i)
		{
			retval.push_back(std::stoi(input));
		}

		return retval;
	}

	int GetValue(std::istream& stream)
	{
		int in;
		stream >> in;

		return in;
	}

	std::vector<std::string> GetValueString(std::istream& stream, int num, char delim)
	{
		std::string buf;
		std::vector<std::string> retval;
		retval.reserve(num);

		std::getline(stream, buf);
		std::stringstream sstr(buf);

		for (int i = 0; i < num && std::getline(sstr, buf, delim); ++i)
		{
			retval.push_back(std::move(buf));
		}

		return retval;
	}

	template<typename Itr>
	void PrintLine(Itr begin, Itr end)
	{
		bool first = true;

		for (int i = 0; begin != end; ++begin, ++i)
		{
			if (!first)
			{
				std::cout << ' ';
			}

			std::cout << (*begin);

			first = false;
		}
		std::cout << std::endl;
	}

	template<typename T>
	void Print(const std::vector<T>& sequence)
	{
		for (const auto& e : sequence)
		{
			std::cout << e << '\n';
		}

		std::cout << std::flush;
	}

	const int N = 100;
	int Adj[N][N] = {};
	int distance[N];

	void Bfs(int node, int num)
	{
		std::queue<int> q;
		q.push(node);
		for (int i = 0; i < N; ++i)
		{
			distance[i] = std::numeric_limits<int>::max();
		}

		distance[node] = 0;

		int u;
		while (!q.empty())
		{
			u = q.front();
			q.pop();
			for (int v = 0; v < num; ++v)
			{
				if (Adj[u][v] == 0)
				{
					continue;
				}

				if (distance[v] != std::numeric_limits<int>::max())
				{
					continue;
				}

				distance[v] = distance[u] + 1;
				q.push(v);
			}
		}
	}
}

int main(int argc, char* argv[])
{
	auto file = (argc == 1) ? std::ifstream() : std::ifstream(argv[1]);
	std::istream& stream = (argc == 1) ? std::cin : file;
	if (argc == 1)
	{
		std::cin.tie(0);
		std::ios::sync_with_stdio(false);
	}

	int num;
	stream >> num;

	int node, degree;
	int t;

	for (int i = 0; i < num; ++i)
	{
		stream >> node >> degree;
		for (int j = 0; j < degree; ++j)
		{
			stream >> t;
			Adj[node - 1][t - 1] = 1;
		}
	}

	Bfs(0, num);

	for (int i = 0; i < num; ++i)
	{
		std::cout << i + 1 << ' ' << 
			((distance[i] == std::numeric_limits<int>::max()) ? -1 : distance[i]) <<
			std::endl;
	}
}



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

#include <cstdio>
#include <cstring>
#include <cmath>
#include <utility>
#include <iostream>
#include <functional>
#include <bitset>
#include <algorithm>
#include <vector>
#include <forward_list>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <numeric>
#define ll long long int
#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
using namespace std;
int mx4[] = {0,1,0,-1};
int my4[] = {1,0,-1,0};
int mx2[] = {1,0};
int my2[] = {0,1};

class DTeleporter {
public:
	void solve(istream& in, ostream& out) {
		int n; ll k;
		in >> n >> k;
		int to[60][200005];
		rep(i,n){
		    in >> to[0][i];
		    to[0][i]--;
		}
		for (int i = 0; i < 59; i++) {
		    for(int j = 0; j < n; j++) {
		        to[i+1][j] = to[i][to[i][j]];
		    }
		}
		int v = 0;
		for(int i = 59; i >= 0; i--) {
		    ll l = (1ll << i);
		    if(k >= l){
		        v = to[i][v];
		        k -= l;
		    }
		}
		out << v + 1 << endl;
	}
};

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

Measured memory_bytes: 50512
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<cmath>
using namespace std;
int main(){
	int a,b,c,d;
	cin>>a>>b>>c>>d;
	if(1<=c && c<=12 && d==1) cout<<1<<endl;
	else cout<<0<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <stdlib.h>
#include <math.h>
#include <string.h>

using namespace std;

int main(){
	char S[100001]={};
	cin>>S;
	int l=strlen(S);
	char c=S[0];
	int n=0;
	for(int i=1;i<l;i++){
		if(S[i]!=c){
			n++;
			c=S[i];
		}
	}
	cout<<n<<endl;
	return 0;
}

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

using namespace std;

// 0-indexに直す
int main() {
  int maxH, maxW;
  cin >> maxH >> maxW;
  int ch, cw;
  cin >> ch >> cw;
  ch--;
  cw--;
  int dh, dw;
  cin >> dh >> dw;
  dh--;
  dw--;

  // 0: 壁, 1: 通路, 2: visit
  vector<vector<int>> maze(maxH, vector<int>(maxW));
  for (int i = 0; i < maxH; i++) {
    for (int j = 0; j < maxW; j++) {
      char c;
      cin >> c;
      if (c == '.') {
        maze[i][j] = 1;
      }
    }
  }

  deque<vector<int>> q;
  q.push_back({ch, cw, 0});
  while (!q.empty()) {
    auto next = q.front();
    const int curH = next[0];
    const int curW = next[1];
    const int count = next[2];
    q.pop_front();
    maze[curH][curW] = 2;
    if (curH == dh && curW == dw) {
      cout << count << endl;
      return 0;
    }
    for (int i = -2; i <= 2; i++) {
      for (int j = -2; j <= 2; j++) {
        const int nh = i + curH;
        const int nw = j + curW;
        if (nh < 0 || maxH <= nh || nw < 0 || maxW <= nw || maze[nh][nw] != 1) {
          continue;
        }
        if (abs(i) != 2 && abs(j) != 2 && i * j == 0) {
          // walk
          q.push_front({nh, nw, count});
        } else {
          // magic
          q.push_back({nh, nw, count + 1});
        }
      }
    }
  }

  cout << -1 << endl;
}


Measured memory_bytes: 33404
import java.io.IOException;
import java.util.HashSet;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) throws IOException {
		Scanner sc1 = new Scanner(System.in);
		int num = Integer.parseInt(sc1.next());
		String text = (sc1.next());
		System.out.println(cutAndCount(num, text));
		sc1.close();
	}

	public static int cutAndCount(int num, String s2) {
		int count = 0;
		for (int i = 1; i < num; i++) {
			char[] charLeft = s2.substring(0, i).toCharArray();
			char[] charRight = s2.substring(i).toCharArray();
			HashSet<Character> setLeft = new HashSet<>();
			HashSet<Character> setRight = new HashSet<>();
			for (char c : charLeft) {
				setLeft.add(c);
			}
			for (char c : charRight) {
				setRight.add(c);
			}
			setLeft.retainAll(setRight);
			if(setLeft.size() > count) count = setLeft.size();
		}
		return count;
	}
}

Measured memory_bytes: 22484
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
template<class T> using vt = vector<T>;
template<class T> using vvt = vector<vt<T>>;
template<class T> using ttt = tuple<T,T>;
using tii = tuple<int,int>;
using vi = vector<int>;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define pb push_back
#define mt make_tuple
#define ALL(a) (a).begin(),(a).end()
#define FST first
#define SEC second
#define DEB cerr<<"!"<<endl
#define SHOW(a,b) cerr<<(a)<<" "<<(b)<<endl
#define DIV ll(1e9+7)
const int INF = (INT_MAX/2);
const ll LLINF = (LLONG_MAX/2);
const double eps = 1e-8;
//const double PI = M_PI;  
inline ll pow(ll x,ll n,ll m){ll r=1;while(n>0){if((n&1)==1)r=r*x%m;x=x*x%m;n>>=1;}return r%m;}
inline ll lcm(ll d1, ll d2){return d1 / __gcd(d1, d2) * d2;}
// IT 5000兆　欲しい
/* Coding space */
int main(){
  vi x;
  vi tx;
  ll n; cin >> n;
  rep(i,n){int in; cin >> in; x.pb(in);}
  
  tx = x;
  sort(ALL(x));
  
  rep(i,n){
    int d = lower_bound(ALL(x),tx[i]) - x.begin();
    if(d >= n/2) cout << x[n/2 -1] << endl;
    else cout << x[n/2] << endl;
  }
  
}

Measured memory_bytes: 3828
s = list(input())
def change(i):
    global s
    #print(i)
    if s[i : i + 3] == ["A", "B", "C"]:
        s[i:i + 3] = ["B", "C", "A"]
        #print(s)
        return 1
    return 0

cnt = 0
cnA = 0
i = 0
while i < len(s) - 1:
    #print(i, cnA)
    if s[i:i + 2] == ["B", "C"]:
        cnt += cnA
        i += 1
    elif s[i] == "A":
        cnA += 1
    else:
        cnA = 0
    i += 1

print(cnt)

Measured memory_bytes: 62192
#include<bits/stdc++.h>
using namespace std;
int main(){
  string sa,sb,sc;cin>>sa>>sb>>sc;
  char a=sa.at(0);
  int m=sa.size(),n=sb.size(),o=sc.size();
  int p=0,q=-1,r=-1;
  string ans;
  while(true){
    if(a=='a'){
      p++;
      if(p==m){ans="A";break;}
      a=sa.at(p);
    }
    else if(a=='b'){
      q++;
      if(q==n){ans="B";break;}
      a=sb.at(q);}
    else {
      r++;
      if(r==o){ans="C";break;}
      a=sc.at(r);
    }
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<cassert>
#include<iostream>
#include<sstream>
#include<string>
#include<vector>
#include<queue>
#include<set>
#include<map>
#include<utility>
#include<numeric>
#include<algorithm>
#include<bitset>
#include<complex>

using namespace std;

typedef long long Int;
typedef vector<int> vint;
typedef pair<int,int> pint;
#define mp make_pair

template<class T> void pv(T a, T b) { for (T i = a; i != b; ++i) cout << *i << " "; cout << endl; }
template<class T> void chmin(T &t, T f) { if (t > f) t = f; }
template<class T> void chmax(T &t, T f) { if (t < f) t = f; }
int in() { int x; scanf("%d", &x); return x; }

int main() {
	int n;
	while(n=in()){
		int i,j,k,res=0;
		for(i=1;i<n;i++){
			k=n;
			for(j=i;k>0;j++)k-=j;
			if(k==0){
//cout<<i<<endl;
				res++;
			}
		}
		cout<<res<<endl;
	}
	return 0;
}

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

int main(){
  int N, A;
  cin >> N;
  int x = 0,y = 0;
  for(int i = 0; i < N; i ++){
    cin >> A;
    while(A % 2 == 0){
      x ++;
      A /= 2;
    }
    if(i == 0) y = x;
    if(i > 0 && y > x){
      y = x;
    }
    x = 0;
  }
  cout << y << endl;
}

Measured memory_bytes: 256
#pragma GCC optimize ("O3")

#include <bits/stdc++.h>

using namespace std;

#ifdef LOCAL
#include <prettyprint.hpp>
#define debug(...)  cerr << "[" << #__VA_ARGS__ << "]: ", d_err(__VA_ARGS__);
#else
#define debug(...) 83;
#endif

void d_err() {
    cerr << endl;
}

template <typename H, typename... T>
void d_err(H h, T... t) {
    cerr << h << " ";
    d_err(t...);
}

#define ALL(x) (x).begin(), (x).end()
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define REP(i, n) FOR(i, 0, n)
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define bcnt __builtin_popcountll

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<ll,ll> Pll;
typedef pair<int,int> Pin;

ll INF = 1e16;
int inf = 1e9;
ll MOD = 1e9+7;

int main(){
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(20);
    
    int A, B, C, D;
    cin >> A >> B >> C >> D;

    int c1 = C / B, c2 = A / D;
    if (C % B) c1++;
    if (A % D) c2++;

    if (c1 <= c2) cout << "Yes" << endl;
    else cout << "No" << endl;
    
}


Measured memory_bytes: 3652
// C - Cat Snuke and a Voyage
#include <bits/stdc++.h>
using namespace std;
using vi = vector<int>;

string solve(int N, vi &P){
	while(N--) if(P[N] == 0b11) return "POSSIBLE";
	return "IMPOSSIBLE";
}

int main(){
	int N,M; cin>>N>>M;
	vi P(N);
	while(M--){
		int a,b; cin>>a>>b;
		if(a==1) P[b-1] = ((P[b-1]>>1)<<1) + 1;
		if(b==N) P[a-1] = 2 + (P[a-1]&1);
	}
	cout<< solve(N, P) <<endl;
}

Measured memory_bytes: 1024
#include <iostream>

int main()
{
char Forecast[3] , Reality[3];
for(int i = 0 ; i < 3 ; i++) std :: cin >> Forecast[i];
for(int i = 0 ; i < 3 ; i++) std :: cin >> Reality[i];

int res = 0;
for(int i = 0 ; i < 3 ; i++)
if(Forecast[i] == Reality[i])
res++;

std :: cout << res << '\n';
}


Measured memory_bytes: 256
// #define _GLIBCXX_DEBUG // for STL debug (optional)
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
using namespace std;
using ll = long long int;
using int64 = long long int;
 
template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}
 
int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
const ll INF = 1001001001001001LL;
const ll MOD = 1000000007LL;
 
int main() {
    string s; cin >> s;
    s += 'R';
    int N = s.length();

    vector<int> ans;
    char c = 'R';
    vector<int> cons;
    cons.emplace_back(0);
    for(int i=0; i<N; i++) {
        if(s[i] == c) cons.back()++;
        else {
            c ^= 'L' ^ 'R';

            if(s[i] == 'R') {
                int cntR = cons[0], cntL = cons[1];
                // fprintf(stderr, "cntR = %d, cntL = %d\n", cntR, cntL);
                for(int k=0; k<cntL + cntR; k++) {
                    int cl = (cntL + 1) / 2;
                    int cr = (cntR + 1) / 2;
                    if(k == cntR - 1) {
                        int v = (cntL - cl) + cr;
                        ans.emplace_back(v);
                    }
                    else if(k == cntR) {
                        int v = cl + (cntR - cr);
                        ans.emplace_back(v);
                    }
                    else {
                        ans.emplace_back(0);
                    }
                }
                cons.clear();
            }
            cons.emplace_back(1);
        }
    }

    for(int i=0; i+1<N; i++) {
        cout << ans[i] << " \n"[i + 2 == N];
    }
    return 0;
}


Measured memory_bytes: 1144
#include <iostream>
#include <algorithm>
#include <cmath>
#include <stdio.h>
#include <stdlib.h>
#include <vector>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <string.h>
#include <stack>
#define Endl endl
#define mp make_pair
#define ll long long 
#define pii pair<int,int>
#define pll pair<ll,ll>
#define over(A) {cout<<A<<endl;exit(0);}
#define all(A) A.begin(),A.end()
#define ceil(a,b) ((a-1)/b+1)
#define srand() mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#define rand(l,r) uniform_int_distribution<int>(l,r)(rng)
typedef unsigned long long ull;
const int inf=1039074182;
using namespace std;
int a[1005][1005];
int A,B;
int n,m;

int main()
{
//	freopen("input.txt","r",stdin);
	cin>>n>>m>>A>>B;
	for(int j=0;j<A;j++)
	{
		for(int i=0;i<n;i++)
		{
			a[i][j]^=1;
		}
	}
	for(int i=0;i<B;i++)
	{
		for(int j=0;j<m;j++)
		{
			a[i][j]^=1;
		}
	}
	for(int i=0;i<n;i++)
	{
		for(int j=0;j<m;j++)
		{
			printf("%d",a[i][j]);
		}
		puts("");
	}
	return 0;
}

Measured memory_bytes: 5120
n,p=map(int,input().split())
a=list(map(int,input().split()))
even=0
odd=0
for i in a:
    if i%2==0:
        even+=1
    else:
        odd+=1
import math
ans=2**even
if p==0:
    m=odd//2
    t=1
    for i in range(1,m+1):
        i*=2
        t+=math.factorial(odd)/math.factorial(i)/math.factorial(odd-i)
else:
    m=(odd+1)//2
    t=0
    for i in range(1,m+1):
        i=2*i-1
        t+=math.factorial(odd)/math.factorial(i)/math.factorial(odd-i)
ans*=t
print(int(ans))

Measured memory_bytes: 9124
n = int(input())
arr = sorted([list(map(int, input().rstrip().split())) for _ in range(n)])
cnt = {}
for i, j in arr:
    for k, l in arr:
        if (i, j) == (k, l):
            continue
        dif = (k - i, l - j)
        cnt.setdefault(dif, 0)
        cnt[dif] += 1
print(n - max(cnt.values(), default=0))

Measured memory_bytes: 3444
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;

typedef long long ll;
typedef pair<int,int> ii;
typedef tree<ii,null_type,less<ii>,rb_tree_tag,tree_order_statistics_node_update> indexed_set;

int main() {
	cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);
	int N; cin>>N;
	vector<int> x(N), y(N);
	for (int i=0; i<N; i++)
		cin>>x[i]>>y[i];
	map<ii,int> ct;
	for (int i=0; i<N; i++) {
		for (int j=0; j<N; j++) {
			if(i==j)
				continue;
			ct[{x[i]-x[j],y[i]-y[j]}]++;
		}
	}
	int ret=N;
	for (auto it : ct)
		ret=min(ret,N-it.second);
	cout<<ret<<"\n";
	return 0;
}

Measured memory_bytes: 384
#include <stdio.h>
int main(void){
    // Your code here!
    char s[1000], t[1000], u[1000000];
    int n, i, j=0;
    
    scanf("%d",&n);
    scanf("%s%s",s,t);
    
    for(i=0;i<n*2;i++){
        u[i+j]=s[i];
        j++;
        u[i+j]=t[i];
    }
    u[n*2]='\0';
    printf("%s\n",u);
    return 0;
}

Measured memory_bytes: 128
import numpy as np
 
N,Max_W = map(int,input().split())
INF = np.inf

dp = np.full(N*10**3+1,Max_W+1,dtype=np.int64)
dp[0] = 0
for i in range(N):
    w,v = map(int,input().split())
    a = dp[:-v] + w
    b = dp[v:]
    m = np.minimum(a,b)
    dp[v:] = m
max_w = 0
max_v = 0
ans = np.where( dp <= Max_W )
print(np.max(ans))

Measured memory_bytes: 17128
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
	string s,t;
	cin>>s>>t;
	int len=t.size();
	for(int i=0;i<len;i++){
		int num=0;
		for(int j=0;j<len;j++){
			if(s[j]==t[(i+j)%len])
				num++;
			else
				break;
		}
		if(num==len){
			cout<<"Yes";
			return 0;
		}
	}
	cout<<"No";
	return 0;
}

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


int main()
{
    int n,k;cin>>n>>k;
    vector<int> l(n);
    for(int i = 0; i<n; i++)cin>>l[i];
    sort(l.begin(), l.end(), greater<int>());
     int sum = 0;
    for(int i = 0; i < k; i++)sum += l[i];
   
    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);
		
		int n = sc.nextInt();
		
		pos = new int[n][2];
		
		for(int i = 0; i < n; i++) {
			pos[i][0] = sc.nextInt();
			pos[i][1] = sc.nextInt();
		}
		
		visit = new boolean[n];
		index = new int[n];
		
		dfs(0, n);
		
//		System.out.println(fact(n));
		System.out.println(result/fact(n));
	}
	
	static double result = 0;
	
	static int pos[][];

	static boolean visit[];
	static int index[];
	static void dfs(int depth, int n) {
		if(depth == n) {
			//debug
//			for(int i = 0; i < n; i++) {
//				System.out.print(index[i]+" ");
//			}
//			System.out.println();
			for(int i = 0; i < n - 1; i++) {
				result += Math.sqrt(Math.pow(pos[index[i]][0] - pos[index[i + 1]][0], 2)
						+ Math.pow(pos[index[i]][1] - pos[index[i + 1]][1], 2));
			}
			
//			System.out.println(result);
			return;
		}
		
		for(int i = 0; i < n; i++) {
			if(!visit[i]) {
				visit[i] = true;
				index[depth] = i;
				dfs(depth + 1, n);
				visit[i] = false;
			}
		}
	}
	
	static long fact(int n) {
		if(n == 0) {
			return 1;
		}
		
		long result = 1;
		for(int i = 1; i <= n; i++) {
			result *= i;
		}
		
		return result;
	}
}


Measured memory_bytes: 24504
import sys
readline = sys.stdin.readline

N = int(readline())
A = list(map(int,readline().split()))

# 最も絶対値の大きい数を、それが正の数なら右から、負の数なら左から、
# 昇順になっていない場所に足していく

# print(A)

ans = []
plusmax = 0
minusmax = 0
plusmax_i = -1
minusmax_i = -1
  
target = -1
maxdiff = 0
for i in range(len(A)):
  if A[i] < minusmax:
    minusmax = A[i]
    minusmax_i = i
  if A[i] > plusmax:
    plusmax = A[i]
    plusmax_i = i
# 最も絶対値が大きいものが正であれば、左から順に足していく
# 負であれば右から
# この方針は途中で変えない。正なら最後まで正。
# 2要素の差の最大値は、絶対値の最大がたとえば1000のときに1000～-1000の差なので、
# 2回足せば必ず差が埋まる
  
if abs(plusmax) > abs(minusmax):
  # 正でいく場合
  maxval = plusmax
  max_i = plusmax_i
  for i in range(1,len(A)):
    if A[i - 1] > A[i]:
      ans.append((max_i + 1,i + 1))
      ans.append((max_i + 1,i + 1))
      A[i] += 2 * maxval
      max_i = i
      maxval = A[i]
else:
  # 負でいく場合
  minval = minusmax
  min_i = minusmax_i
  for i in range(len(A) - 1, 0,-1):
    if A[i - 1] > A[i]:
      ans.append((min_i + 1, i))
      ans.append((min_i + 1, i))
      A[i - 1] += 2 * minval
      min_i = i - 1
      minval = A[i - 1]
        
print(len(ans))
for a in ans:
  print(*a)


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

int main(){
  int N,result=0;
  cin>>N;
  vector<int> d(N);
  for(int i=0;i<N;i++){
    cin>>d[i];
  }
  for(int i=0;i<N;i++){
    for(int j=i+1;j<N;j++){
      result+=d[i]*d[j];
    }
  }
  cout<<result;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cassert>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#define rep(i, n) for (int i = 0; i < (n); i++)

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

// const int INF = (1 << 30) - 1;
// const ll LL_INF = (1LL << 62) - 1;
// const ll MOD = 1e9 + 7;
// const double PI = M_PI;

ll N, M, K;
vector<ll> A, B;
vector<ll> sumA, sumB;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin >> N >> M >> K;
  A.resize(N);
  B.resize(M);
  rep(i, N) { cin >> A[i]; }
  rep(i, M) { cin >> B[i]; }

  sumA.resize(N + 1, 0);
  rep(i, N) { sumA[i + 1] = sumA[i] + A[i]; }
  sumB.resize(M + 1, 0);
  rep(i, M) { sumB[i + 1] = sumB[i] + B[i]; }

  ll ans = 0;
  for (int i = 0; i <= N; i++) {
    if (sumA[i] > K) {
      continue;
    }
    ll num = upper_bound(sumB.begin(), sumB.end(), K - sumA[i]) - sumB.begin();
    ans = max(ans, i + num - 1);
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 9152
N = gets.to_i
As = gets.split.map(&:to_i)
M = 10**9 + 7

ar = As.reverse
ss = ar.each_with_object([0]){|a, o| o << (o.last + a)%M}
puts ar.zip(ss).inject(0){|r, (a, s)| (r + a*s)%M}

Measured memory_bytes: 41864
n=int(input())
a=list(map(int,input().split()))
b=list(map(int,input().split()))

cnt=0

for i in range(n):
  if a[n-i]>=b[n-1-i]:
    cnt+=b[n-1-i]
  else:    
    if a[n-1-i]-(b[n-1-i]-a[n-i])>=0:
      a[n-1-i]-=b[n-1-i]-a[n-i]
      cnt+=b[n-1-i]
    else:
      cnt+=a[n-i]+a[n-1-i]
      a[n-1-i]=0
      
print(cnt)

Measured memory_bytes: 97648
#include<bits/stdc++.h>
#define REP(i,n) for(int i = 0;i < (n);i++)
#define P pair<int,int>
#define pb push_back
#define mk make_pair
using namespace std;
const int INF = 1 << 20;

typedef long long ll;

bool Sosuu(int r){
  for(int i = 2;i <= sqrt(r);i++){
    if(r%i == 0)
      return false;
  }
  return true;
}


int main(){
  int n,m;

  while(cin >> n){
    int a = n-1;
    while(1){
      bool f = Sosuu(a);
      if(f)
	break;
      a--;
      
    }
    int b = n+1;
    while(1){
      bool f = Sosuu(b);
      if(f)
	break;
      b++;
    }
    cout << a << " " << b << endl;
  }
  return 0;
}



Measured memory_bytes: 3100
#include <stdio.h>
#include <stdlib.h>
int asc(const void *a, const void *b) {
  return *(int *)a - *(int *)b;
}

int main(){
	int n,t,c;
	scanf("%d",&n);
	int d[n];
	for(int i=0;i<n;i++){
		scanf("%d",&d[i]);
	}

	qsort(d,n,sizeof(int),asc);

	t=d[n/2-1];
	c=d[n/2];
	printf("%d\n",c-t);
	return 0;
}

Measured memory_bytes: 892
#include "bits/stdc++.h"

using namespace std;

#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl

typedef long long ll;
#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
#define pll pair<ll,ll>
template<class S, class T> pair<S, T> operator+(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first + t.first, s.second + t.second); }
template<class S, class T> pair<S, T> operator-(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first - t.first, s.second - t.second); }
template<class S, class T> ostream& operator<<(ostream& os, pair<S, T> p) { os << "(" << p.first << ", " << p.second << ")"; return os; }
#define X first
#define Y second
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define rep1(i,n) for(ll i=1;i<=(ll)(n);i++)
#define rrep(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define rrep1(i,n) for(ll i=(ll)(n);i>0;i--)
#define REP(i,a,b) for(ll i=(ll)a;i<(ll)b;i++)
#define in(x, a, b) (a <= x && x < b)
#define all(c) c.begin(),c.end()
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 (a>b) { a = b; return 1; } return 0; }
const ll inf = 1000000001;
const ll INF = 2e18;
const ll MOD = 1000000007;
const double pi = 3.14159265358979323846;
#define Sp(p) cout<<setprecision(15)<< fixed<<p<<endl;
int dx[4] = { 1,0, -1,0 }, dy[4] = { 0,1,0,-1 };
int dx2[8] = { 1,1,0,-1,-1,-1,0,1 }, dy2[8] = { 0,1,1,1,0,-1,-1,-1 };
#define fio() cin.tie(0); ios::sync_with_stdio(false);


int main(){
  int h, w;
  cin >> h >> w;
  vector<vector<char> > a(h + 2, vector<char>(w + 2, '.'));
  rep1 (i, h) {
    rep1 (j, w) {
      char s;
      cin >> s;
      a[i][j] = s;
    }
  }
  
  rep1 (i, h) {
    rep1 (j, w) {
      if (a[i][j] == '.'){
        continue;
      }
      stack<pii> st;
      st.push(pii(i, j));
      //DEBUG(st.top());
      a[i][j] = '.';
      bool flag = false;
      while (!st.empty()) {
        pii now = st.top();
        //DEBUG(now);
        st.pop();
        rep (k, 4) {
          int ni = now.first + dx[k], nj = now.second + dy[k];
          //DEBUG(pii(ni, nj));
          if (a[ni][nj] == '#') {
            flag = true;
            a[ni][nj] = '.';
            st.push(pii(ni, nj));
          }
        }
      }
      if (!flag) {
        cout << "No" << endl;
        return 0;
      }
    }
  }
  cout << "Yes" << endl;
}
            
                           


Measured memory_bytes: 256
N = gets.to_i
h = {
  'M' => [],
  'A' => [],
  'R' => [],
  'C' => [],
  'H' => []
}
while line = gets
  l = line.chomp
  k = l[0]
  next if !h.keys.include?(k)
  h[k] << l
end

ans = 0
%w(M A R C H).combination(3).each do |k1, k2, k3|
  ans += h[k1].length * h[k2].length * h[k3].length
end
p ans

Measured memory_bytes: 10364
n = int(input())
l = [0 for x in range(n)]
l = list(map(int,input().split()))
l.sort()
if l[0] == 0:
    ans = 0
else:
    ans = 1
    for i in range(n):
        ans *= l[i]
        if ans > 10**18:
            ans = -1
            break
print(ans)

Measured memory_bytes: 23112
#include<iostream>
#include<map>
#include<set>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
#include<stack>
#include<limits>
#include<sstream> 
#include<unordered_map>      

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef int itn;
typedef vector<int> vi;
typedef vector<ll> vl;

const int inf = numeric_limits<int>::max() >> 2;
const ll linf = numeric_limits<ll>::max() >> 2;
const ull ulinf = numeric_limits<ull>::max() >> 2;
const double pi = acos(-1);
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
const int dx8[8]={-1,0,1,-1,1,-1,0,1};
const int dy8[8]={-1,-1,-1,0,0,1,1,1};

#define p_queue(i) priority_queue<i> 
#define rp_queue(i) priority_queue<i, vector<i>, greater<i>> 
#define umap(i,j) unordered_map<i,j>
#define P(p) cout<<(p)<<endl
#define PS(p) cout<<(p)<< " "
#define IN cin >> 
#define rep(i,m,n) for(int i = (m); i < (int)(n); i++)
#define rrep(i,m,n) for(int i = (m-1); i >= (int)(n); i--)
#define inrep(n,a) for(int i = 0; i < (int)(n); i++)cin >> a[i];
#define mod(i) ((i)%(ll)(1e9 + 7))
#define divm(a,b) (mod(a * modpow((ll)b,(ll)(1e9+5))))
#define rsort(a,b,c) sort(a, b, greater<c>())
#define vsort(v) sort(v.begin(), v.end());
#define rvsort(v) sort(v.end(), v.begin());
#define ft first
#define sd second
#define pb push_back
#define it insert
#define sz(x) ((int)(x).size())
#define lb(a,n,k) (lower_bound(a,a+n,k) - a) 
#define vlb(a,k)  (lower_bound(a.begin(),a.end(),k) - a.begin())
#define ub(a,n,k) (upper_bound(a,a+n,k) - a) 
#define vub(a,k)  (upper_bound(a.begin(),a.end(),k) - a.begin())
#define YES cout<<"YES"<< endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl  
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
#define ret return

ll modpow(ll i,ll j){ ll tmp=1; while(j){ if(j%2)tmp=mod(tmp*i);i=mod(i*i);j/=2;}return tmp;}
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }

vector<string> split(const string &str, char sep){
    vector<string> v;
    stringstream ss(str);
    string buffer;
    while( getline(ss, buffer, sep) ) {
        v.push_back(buffer);
    }
    return v;
}

//ll ncr[100][100];
//ll nCr(int n, int r){if(n==r) ret ncr[n][r] = 1; if(r==0) ret ncr[n][r] = 1; if(r==1) ret ncr[n][r] = n;if(ncr[n][r]) ret ncr[n][r]; ret ncr[n][r] = nCr(n-1,r) + nCr(n-1,r-1);}

//ll npr[100][100]={};
//ll nPr(int n,int r){if(npr[n][r])ret npr[n][r];if(r==0)ret npr[n][r] = 1;if(r==1)ret npr[n][r] = n;ret npr[n][r] = n * nPr(n-1,r-1);}

//ll nHr(int n,int r){ret nCr(n+r-1,r);}

///////////////////////////////////////////////////////////////////////////


int main(){
    
    int a,b;
    cin >> a >> b;
    
    if(a > b)swap(a,b);
    
    if((b-a)&1){
	P("IMPOSSIBLE");
    }else{
	int c = (b-a)/2;
	P(b-c);
    }
    return  0;
}


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

using lnt = long long;
using Real = long double;

#define ALL(obj) (obj).begin(),(obj).end()
#define RALL(obj) (obj).rbegin(),(obj).rend()
#define REP(i, n) for(lnt i=0;i<(n);++i)
#define RANGE(i, a, b) for(lnt i=(a);i<(b);++i)
#define RREP(i, n) for(lnt i=(n)-1;i>= 0;--i)

#define ln '\n'
#define pb push_back
#define eb emplace_back
#define pque priority_queue
#define umap unordered_map
#define uset unordered_set
#define dcout cout<<fixed<<setprecision(20)
#define summon_tourist cin.tie(0);ios::sync_with_stdio(false)

constexpr int dx[]={1,0,-1,0,1,1,-1,-1}, dy[]={0,-1,0,1,1,-1,1,-1};
constexpr Real eps = 1e-9; const Real pi = acosl(-1);
constexpr lnt BIG = INT_MAX/10, BBIG = LLONG_MAX/10;

template<class T> inline T GCD(T a,T b){T c;while(b!=0){c=a%b;a=b;b=c;}return a;}
template<class T> inline T LCM(T a,T b){T c=GCD(a,b);a/=c;return a*b;}
template<class T> inline T nCr(T a,T b){T i,r=1;for(i=1;i<=b;i++){r*=(a+1-i);r/=i;}return r;}
template<class T> inline T nHr(T a,T b){return nCr(a+b-1,b);}
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;}

using pint = pair<int, int>; using plnt = pair<lnt, lnt>;
using vint = vector<int>; using vlnt = vector<lnt>;
constexpr lnt MOD = 1e9+7;

int main(){
	summon_tourist;

	lnt A, B, N; cin >> A >> B >> N;
	lnt p = N/B, q = N%B;
	if(p>0) q = B-1;
	cout << A*q / B << ln;
}

Measured memory_bytes: 3608
#include <iostream>
#include <string>
#include <vector>
#include <cstdlib>
#include <algorithm>
#define _USE_MATH_DEFINES
#include<math.h>
#define in(n) for (int i=0; i<n;i++)
#define inj(n)for (int j=0; j<n;j++)
using namespace std;

int main() {
	int N;
	cin >> N;

	vector<int> A(N);
	in(N - 1) {
		int tmp;
		cin >> tmp;
		A[tmp - 1]++;
	}

	for (auto&& a : A) {
		cout << a << endl;
	}
	return 0;
}

Measured memory_bytes: 3992
#include <iostream>

using namespace std;

int main() {
  int k, s;
  cin >> k >> s;
  int ans = 0;
  for (int i = 0; i <= k; i++) {
    for (int j = 0; j <= k; j++) {
      if (i + j <= s) {
        if (s - (i + j) <= k)
          ans++;
      }
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 888
#include <algorithm>
#include <cmath>
#include <iostream>
#include <numeric>
#include <utility>
#include <vector>

using namespace std;

// rec
long s(long n) {
    int sn = 0;
    while (n > 0) {
        sn += n % 10;
        n /= 10;
    }
    return sn;
}

bool smls(long x, long y) {
    return x * s(y) <= y * s(x);
}

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

    long nmax = 1000000000000000;
    vector<long> chl;
    long diff = nmax / 10;
    long next = nmax + nmax / 10;
    while (next - 2 > 0) {
        if (next <= diff) {
            diff /= 10;
        } else if (diff > 1 && smls(next - diff / 10 - 1, next - 1)) {
            diff /= 10;
        }
        next -= diff;
        chl.push_back(next - 1);
    }
    for (int i = 1; i <= n; i++) {
        cout << chl[chl.size() - i] << endl;
    }
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <tuple>
#include <bits/stdc++.h>
typedef long long ll;
#define REP(i,n) for(int i=0;i<n;i++)
using namespace std;

//素因数分解
vector<pair<ll,int>> factorize(ll n){
    vector<pair<ll,int>>res;
    for(ll i=2;i*i<=n;i++){
        if(n%i)continue;
        res.emplace_back(i,0);
        while (n%i == 0)
        {
        n /= i;
        res.back().second++;
        }
        
    }
    if(n != 1) res.emplace_back(n,1);
    return res;
}

int main(){
    int N,ans=0,key=0;
    cin >> N;
    int H[N];
    REP(i,N){
        int h;
        cin >> h;
        if(h>=key){
            ans++;
            key = h;
        }
    }
    cout << ans << endl;

}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int sr[100'001];
int tr[100'001];

int main()
{
    string s, t;
    cin >> s >> t;

    int n = s.size();
    for (int i = 0; i <= n; i++)
    {
        if (i == 0)
        {
            sr[i] = tr[i] = 0;
        }
        sr[i] = sr[i - 1] + (s[i - 1] == 'A' ? 1 : 2);
        tr[i] = tr[i - 1] + (t[i - 1] == 'A' ? 1 : 2);
        sr[i] %= 3;
        tr[i] %= 3;
    }

    int q;
    cin >> q;
    for (int i = 0; i < q; i++)
    {
        int a, b, c, d;
        cin >> a >> b >> c >> d;

        if ((sr[b] - sr[a - 1] + 3) % 3 == (tr[d] - tr[c - 1] + 3) % 3)
        {
            cout << "YES" << endl;
        }
        else
        {
            cout << "NO" << endl;
        }
    }

    return 0;
}

Measured memory_bytes: 1664
import java.util.ArrayList;
import java.util.Scanner;

//internous_atcoder_001 at 2018/02/15

public class Main {
	public static void main(String[] args) {
		Main main = new Main();
		main.solveB062();
	}

	private void solveA081() {
		Scanner sc = new Scanner(System.in);
		char N[] = sc.nextLine().toCharArray();
		int cnt = 0;
		for (char c : N) cnt += c - '0';
		System.out.println(cnt);
	}

	private void solveA065() {
		Scanner sc = new Scanner(System.in);
		int X = sc.nextInt();
		int A = sc.nextInt();
		int B = sc.nextInt();
		if (B - A <= 0) {
			System.out.println("delicious");
		} else if (X < B - A) {
			System.out.println("dangerous");
		} else {
			System.out.println("safe");
		}
	}

	private void solveB062() {
		Scanner sc = new Scanner(System.in);
		int H = sc.nextInt();
		int W = sc.nextInt();
		sc.nextLine();
		ArrayList<String> list = new ArrayList<>();
		for (int i = 0; i < H; i++) {
			list.add(sc.nextLine());
		}
		
		for (int j = 0; j < W + 2; j++) {
			System.out.print("#");
		}
		
		System.out.println();
		
		for (String string : list) {
			System.out.println("#" + string + "#");
		}
		
		for (int k = 0; k < W + 2; k++) {
			System.out.print("#");
		}
	}

	private void solveD() {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		System.out.println(N);
	}

	private void solveE() {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		System.out.println(N);
	}

	private void solveF() {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		System.out.println(N);
	}

}

Measured memory_bytes: 22356
#include <cstdio>

using namespace std;

int main() {
  int a, b, c, d, e, f;
  while (scanf("%d %d %d %d %d %d",
    &a, &b, &c, &d, &e, &f) == 6) {
    double t = a*e-d*b;
    double x = (c*e-b*f)/t;
    double y = (a*f-c*d)/t;
    if (x == 0) x = 0;
    if (y == 0) y = 0;
    printf("%.3f %.3f\n", x, y);
  }
  return 0;
}

Measured memory_bytes: 2580
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define mp make_pair
using namespace std;
double t,a,h,cha;
int n,ans;
int main()
{
	cin>>n>>t>>a;
	cin>>h;
	double k=t-h*0.006;
	cha=abs(a-k);
	ans=1;
	for (int i=1;i<n;i++)
	{
		cin>>h;
		double k=t-h*0.006;
		//cout<<k<<" ";
		if (abs(a-k)<cha)
		{
			cha=abs(a-k);
			ans=i+1;
			//cout<<cha<<" "<<ans<<endl;
		}
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 256
n=int(input())
r={i:list(input().split()) for i in range(n)}
r_state=[r[i][0] for i in range(n)]
r_score=[int(r[i][1]) for i in range(n)]
r_state.sort()
r_score.sort(reverse=True)
l=[]

for i in range(n):
  for j in range(n):
    for k in range(n):
      if k in r.keys():
        if r[k]==[r_state[i],str(r_score[j])]:
          l.append(k+1)
          r.pop(k)
for item in l:
  print(item)

Measured memory_bytes: 3064
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))
A.sort()
B.sort()
C.sort()


def hoge():
    count = 0
    Ai = -1
    Ci = -1
    for i in range(N):
        if Ai < N - 1:
            while A[Ai + 1] < B[i]:
                Ai += 1
                if Ai == N - 1:
                    break
        if Ci < N - 1:
            while C[Ci + 1] <= B[i]:
                Ci += 1
                if Ci == N - 1:
                    break
        count += (Ai + 1) * (N - (Ci + 1))
    return count


print(hoge())


Measured memory_bytes: 23924
#include <stdio.h>
#include <math.h>
int main(void){
    // Your code here!
    int j,N,count4,count = 0;
    scanf("%d",&N);
    for(int i = 1; i <= N; i=i+2)
    {
        j = 1;
        count4 = 0;
        while(j <= sqrt(i))
        {
            if(i%j == 0) count4++;
        
            j = j + 2;
        }
        if(count4 == 4) count++;
    }
    printf("%d\n",count);
}

Measured memory_bytes: 128