akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <iostream>
#include <algorithm>
using namespace std;
const long long NR=210000;
string a[NR];
long long n,cnt,maxn;
int main()
{
	scanf("%lld",&n);
	for(long long i=1;i<=n;i++)
	{
		cin>>a[i];
	}
	sort(a+1,a+n+1);
	for(long long i=1;i<=n;i++)
	{
		if(a[i]==a[i-1])
		{
			cnt++;
		}
		else
		{
			cnt=1;
		}
		if(cnt>maxn)
		{
			maxn=cnt;
		}
	}
	for(long long i=1;i<=n;i++)
	{
		if(a[i]==a[i-1])
		{
			cnt++;
		}
		else
		{
			cnt=1;
		}
		if(cnt==maxn)
		{
			cout<<a[i]<<endl;
		}
	}
	return 0;
}

Measured memory_bytes: 14336
from itertools import accumulate
from fractions import gcd

N = int(input())
As = list(map(int, input().split()))

cum_gcd = list(accumulate(As, gcd))
cum_rev_gcd = list(accumulate(reversed(As), gcd))[::-1]

max_gcd = max(cum_gcd[-2], cum_rev_gcd[1])
for without in range(1, N-1):
    max_gcd = max(max_gcd, gcd(cum_gcd[without-1], cum_rev_gcd[without+1]))

print(max_gcd)

Measured memory_bytes: 16068
(n, m, c) = map(int, input().split())
b = list(map(int, input().split()))
a = []
for _ in range(n):
    a.append(list(map(int, input().split())))

num = 0
for code in a:
    sum = c
    for i in range(m):
        sum += code[i] * b[i]
    if sum > 0:
        num += 1
print(num)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define rep(i,n)for(long double i=0;i<(n);i++)
using namespace std;
typedef long long ll;
const int MOD=1e9+7;
const int MAX = 510000;
const int INF = 1e9;
const double pi=acos(-1);


  
int main(){
  double n,k;
  cin >> n >> k;
  double prob;
  double ans=0;
  double now=0;
  rep(i,n){
    now=i+1;
    double num = 0;
    while(now<k){
      num++;
      now*=2;
    }
    prob=1/n;
    rep(j,num) prob/=2;
    ans+=prob;
  }
  cout << fixed << setprecision(20) << ans << endl;
  return 0;
}


Measured memory_bytes: 256
//↓見なくていいよ！ここから--------------------------------------------------
var read = require('readline').createInterface({
  input: process.stdin,
  output: process.stdout
});
var obj;
var inLine = [];
read.on('line', function(input){inLine.push(input);});
read.on('close', function(){
  obj = init(inLine);
  myerr("-----start-----");
  var start = new Date();
  Main();
  var end = new Date() - start;
  myerr("----- end -----");
  myerr("time : " + (end) + "ms");
  myerr("memory : " + Math.round(process.memoryUsage().heapTotal / 1024) + "KB");
});
function nextInt(){return myconv(next(),1);} function nextStrArray(){return myconv(next(),2);}
function nextIntArray(){return myconv(next(),4);} function nextCharArray(){return myconv(next(),6);}
function next(){return obj.next();} function hasNext(){return obj.hasNext();}
function init(input){  
  var returnObj = {
    list : input, index : 0, max : input.length,
    hasNext : function(){return (this.index < this.max);},
    next : function(){if(!this.hasNext()){throw "ArrayIndexOutOfBoundsException これ以上ないよ";}else{var returnInput = this.list[this.index];this.index++;return returnInput;}}
  };
  return returnObj;
}
function myout(s){console.log(s);}
function myerr(s){console.error("debug:" + require("util").inspect(s,false,null));}
//[no]要素の扱い。数値型
//不明値、異常時:引数そのまま返す 1:数値へ変換
//2:半角SPで分割 4:半角SPで分割し、数値配列へ
//6:1文字で分割  7:1文字で分割し、数値配列へ
//8:半角SPで結合 9:改行で結合 0:文字なしで結合
function myconv(i,no){try{switch(no){case 1:return parseInt(i);case 2:return i.split(" ");case 4:return i.split(" ").map(Number);case 6:return i.split("");case 7:return i.split("").map(Number);case 8:return i.join(" ");case 9:return i.join("\n");case 0:return i.join("");default:return i;}}catch(e){return i;}}

//↑見なくていいよ！ここまで--------------------------------------------------
function Main(){
	var one = nextIntArray();
	var A = one[0];
	var B = one[1];
	var N = 100;
	var list = new Array(N);
	for(var i = 0; i < N; i++){
		if(i < 50){
			list[i] = new Array(N).fill("#");
		}else{
			list[i] = new Array(N).fill(".");
		}
	}
	
	for(var i = 0; i < A - 1; i++){
		var x = (i * 2) % N;
		var y = Math.floor((i * 2) / N) * 2;
		list[y][x] = ".";
	}
	
	for(var i = 0; i < B - 1; i++){
		var x = (i * 2) % N;
		var y = Math.floor((i * 2) / N) * 2 + 51;
		list[y][x] = "#";
	}
	myout(N + " " + N);
	for(var i = 0; i < N; i++){
		myout(myconv(list[i], 0));
	}
}


Measured memory_bytes: 8372
//我是菜鸡
#include<bits/stdc++.h>
#define _for(i,a,b) for(int i = (a);i<(b);++i)
#define _rfor(i,a,b) for(int i = (a);i>(b);--i)
#define _sfor(p,st) for(auto &p:st)
#define debug(x) cout<<x<<endl
using namespace std;
typedef long long ll;
const int INF = 0x3f3f3f3f;
const int maxn = 2e3;
void deprint() {
	//ofstream cout("E:\\acm dream\\debug.txt");
	return;
}
int main() {
	//ifstream cin("E:\\acm dream\\in.txt");
	//ofstream cout("E:\\acm dream\\out.txt");
	ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
	double h, a;
	while (cin >> h >> a) {
		cout << fixed<<setprecision(0)<<ceil(h / a) << '\n';
	}
	return 0;
}


Measured memory_bytes: 256
//om namah shivaay
//faith over fear
//no one wants to die,yet death is the destination we all share 
// don't think you are,know you are!!

#include<bits/stdc++.h>
using namespace std;
 
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define pb push_back
#define ll long long 
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define rep(i,n) for(i=0;i<n;i++)
#define forn(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define for1(i, n) for (ll i = 1; i <= (ll)(n); ++i)
#define ford(i, n) for (ll i = (ll)(n) - 1; i >= 0; --i)
#define fore(i, a, b) for (ll i = (ll)(a); i <= (ll)(b); ++i)
#define fora(it,x) for(auto it:x)
#define PI 3.14159265
#define sync ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define endl "\n"
 
typedef pair<ll, ll> pii;
typedef vector<ll> vi;
typedef vector<pii> vpi;
typedef vector<vi> vvi;
typedef long long i64;
typedef vector<i64> vi64;
typedef vector<vi64> vvi64;
typedef pair<i64, i64> pi64;
typedef long double ld;
 
template<class T> bool uin(T &a, T b) { return a > b ? (a = b, true) : false; }
template<class T> bool uax(T &a, T b) { return a < b ? (a = b, true) : false; }

ll a[2*100002],b[2*100002];

void fun(ll n,ll k){
    if(k==0) return;
    ll f=0;
    forn(i,n){ if(a[i]!=n){
        f=1;
        break;
    }
    }
    if(f==0) return;
    forn(i,n+1) b[i]=0;
    forn(i,n){
        b[max((ll)1,-a[i]+i+1)]+=1;
        if((a[i]+i+1+1)<=n) b[a[i]+i+2]-=1; 
    }
    for1(i,n) b[i]+=b[i-1];
    forn(i,n){
        a[i]=b[i+1];
    }
    fun(n,k-1); 
}

int main(){
    ll n,k;
    cin>>n>>k;
    forn(i,n) cin>>a[i];
    fun(n,k);
    forn(i,n) cout<<a[i]<<" ";
}

Measured memory_bytes: 6708
#include <iostream>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <string>
#include <vector>
#include <map>

using namespace std;

int main()
{
	int n;
	cin >> n;
	cout << n * 800 - n / 15 * 200 << endl;
	return 0;
}



Measured memory_bytes: 256
n,m,k=gets.split.map(&:to_i)
a=gets.split.map(&:to_i)
b=gets.split.map(&:to_i)
sa=[0]
sb=[0]
n.times do |i|
  sa << sa[-1]+a[i]
end
m.times do |i|
  sb << sb[-1]+b[i]
end
mx=0
j=0
n.downto(0) do |i|
  while j<m&&sa[i]+sb[j+1]<=k
    j+=1
  end
  if sa[i]+sb[j]<=k&&mx<i+j
    mx=i+j
  end
end
puts mx


Measured memory_bytes: 44984
#include <iostream>
#include <algorithm>
#include <vector>

using namespace std;


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

    int i;
    vector<int> L(2*N);
    for (i=0; i<2*N; i++) {
        cin >> L[i];
    }

    sort(L.begin(), L.end());

    int A=0;
    for (i=0; i<N; i++) {
        A += min(L[i<<1], L[i<<1|1]);
    }

    cout << A << endl;
    return 0;
}


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

int main(){
    int a, b, c, sum, x;
    cin >> a >> b >> c;
    sum = a + b + c;
    x = max(a, max(b, c));
    if(x%2 != sum%2){
        x++;
    }
    cout << (3*x - sum)/2 << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<list>
#include<vector>
#include<algorithm>
#include<string>
#include<stdio.h>
#include<math.h>
#include<unordered_map>
#include<map>
#include<set>

#include <memory>

const double PI = 3.14159265358979323846;

using namespace std;
using ll = long long;
using vec = vector<ll>;
using mat = vector<vec>;
using lst = list<int>;

ll MOD = 1000000007;

int N;
ll K;
vec A,F;

bool check(ll cost)
{
	ll k = 0;
	for(int i=0;i<N;++i)
	{
		k += max(0ll, A[i] - cost / F[i]);
	}
	
	return k <= K;
}


int  main()
{
	cin >> N >> K;
	A = vec(N);
	F = vec(N);

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

	std::sort(A.begin(), A.end());
	std::sort(F.rbegin(), F.rend());

	ll G = 10000000000000000ll, l = 0;
	for (int i = 0; i < 64; ++i)
	{
		ll mid = (G + l) / 2;
		if (check(mid))
		{
			G = mid;
		}
		else
		{
			l = mid;
		}

	}
	cout << G << endl;
	return 0;
}

Measured memory_bytes: 3328
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstdint>
#include <cstdio>
#include <cstring>
#include <deque>
#include <fstream>
#include <functional>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <vector>
using namespace std;
using ll = long long;
#define fst first
#define snd second

/* clang-format off */
template <class T, size_t D> struct _vec { using type = vector<typename _vec<T, D - 1>::type>; };
template <class T> struct _vec<T, 0> { using type = T; };
template <class T, size_t D> using vec = typename _vec<T, D>::type;
template <class T> vector<T> make_v(size_t size, const T& init) { return vector<T>(size, init); }
template <class... Ts> auto make_v(size_t size, Ts... rest) { return vector<decltype(make_v(rest...))>(size, make_v(rest...)); }
template <class T> inline void chmin(T &a, const T& b) { if (b < a) a = b; }
template <class T> inline void chmax(T &a, const T& b) { if (b > a) a = b; }
/* clang-format on */

struct UnionFind {
  vector<int> parent;  // parent[root] is the negative of the size.
  UnionFind(int n)
      : parent(n, -1){};
  bool unite(int u, int v) {
    u = root(u);
    v = root(v);
    if (u == v) return false;
    if (parent[u] > parent[v]) swap(u, v);
    parent[u] += parent[v];
    parent[v] = u;
    return true;
  }
  bool find(int u, int v) {
    return root(u) == root(v);
  }
  int root(int u) {
    return parent[u] < 0 ? u : parent[u] = root(parent[u]);
  }
  int size(int u) {
    return -parent[root(u)];
  }
};

int solve(ll p, ll q, const vector<ll>& x, const vector<ll>& y) {
  int N = x.size();
  UnionFind uf(N);
  for (int i = 0; i < N; i++) {
    for (int j = 0; j < N; j++) {
      ll np = x[i] - x[j], nq = y[i] - y[j];
      if (np == p && nq == q) {
        uf.unite(i, j);
      }
    }
  }
  set<int> S;
  for (int i = 0; i < N; i++) S.insert(uf.root(i));
  return S.size();
}

int main() {
#ifdef DEBUG
  ifstream ifs("in.txt");
  cin.rdbuf(ifs.rdbuf());
#endif
  int N;
  while (cin >> N) {
    vector<ll> x(N), y(N);
    for (int i = 0; i < N; i++) cin >> x[i] >> y[i];
    int res = N;
    for (int i = 0; i < N; i++) {
      for (int j = 0; j < N; j++) {
        if (j == i) continue;
        ll p = x[i] - x[j], q = y[i] - y[j];
        res = min(res, solve(p, q, x, y));
      }
    }
    cout << res << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

int main(void)
{
	int n,a[2000];
	
	scanf("%d",&n);
	
	for(int i=0;i<n;i++){
		
		scanf("%d",&a[n-1-i]);
		
	}
	for(int i=0;i<n;i++){
		
		if(i!=0){
			printf(" ");
		}
		printf("%d",a[i]);
		
	}
	
	printf("\n");
	
	return 0;
}

Measured memory_bytes: 2668
#include <bits/stdc++.h>
#define ll long long

using namespace std;

int main() {
    ll sum = 0;
    int n;
    cin >> n;
    while (n > 0) {
        if (n % 5 != 0 && n % 3 != 0) {
            sum += n;
        }
        n--;
    }
    cout << sum << endl;
    return 0;
}

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

using namespace std;

#define sqr(x) ((x) * (x))
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()

typedef long long ll;

const int MOD = 1000000007;
const int INF = 1000000007;
const ll INFLL = 1000000000000000007LL;

void solve() {
  ll N, A, B;
  cin >> N >> A >> B;
  ll ans = (N / (A + B) * A);
  ll mod = N % (A + B);
  if (mod <= A) {
    ans += mod;
  } else {
    ans += A;
  }
  cout << ans << endl;
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  // cout << fixed << setprecision(12);

  solve();

  return 0;
}


Measured memory_bytes: 256
n = int(input())
h = list(map(int, input().split()))
ans = 0
for i in range(max(h)):
    flag = False
    for num in h:
        if num > i and flag == False:
            flag = True
            ans += 1
        elif num > i and flag == True:
            pass
        else:
            flag = False
print(ans)

Measured memory_bytes: 3064
def cmb(n, r):
    if n - r < r: r = n - r
    if r == 0: return 1
    if r == 1: return n

    numerator = [n - r + k + 1 for k in range(r)]
    denominator = [k + 1 for k in range(r)]

    for p in range(2,r+1):
        pivot = denominator[p - 1]
        if pivot > 1:
            offset = (n - r) % p
            for k in range(p-1,r,p):
                numerator[k - offset] /= pivot
                denominator[k] /= pivot

    result = 1
    for k in range(r):
        if numerator[k] > 1:
            result *= int(numerator[k])

    return result

N, K = map(int, input().split())

MOD = 10 ** 9 + 7

for k in range(1, K+1):
    if k > N - K + 1:
        print(0)
    else:
        tmp1 = cmb(K-1, K-k)
        tmp2 = cmb(N-K+1, k)
        result = (tmp1 * tmp2) % MOD
        print(result)


Measured memory_bytes: 3444
#include <iostream>
#include <algorithm>
#include <vector>

using namespace std;

#define sp ' '
#define endl '\n'
#define st first
#define nd second
#define pb push_back
#define mp make_pair
#define forn(YY, yy) for(long long int yy = 0; yy < YY; ++yy)
#define prn(XX) cout << XX << endl
#define prs(XX) cout << XX << " "

typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef pair<ll, ll> pll;
typedef vector<pll> vpll;
typedef vector<vpll> vvpll;

const long long int MOD = 1e9 + 7;
const long long int INF = 2e9 + 13;
const long long int mINF = -2e9 - 13;
const double PI = 3.14159265358979;
const double EPS = 1e-9;

const int MAXN = 1e5 + 13;

vll lp(MAXN + 5), pr;

void sieve(void){
    for(ll i = 2; i < MAXN; ++i){
        if(lp[i] == 0){
            lp[i] = i;
            pr.pb(i);
        }
        for(ll j = 0; j < pr.size() and pr[j] <= lp[i] and pr[j]*i < MAXN; ++j){
            lp[i*pr[j]] = i;
        }
    }
    return;
}

int main(int argc, char **argv){
    ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
    
    sieve();

    ll N; cin >> N;
    auto itr = lower_bound(pr.begin(), pr.end(), N);
    cout << *itr << endl;

    return 0;
}

//cikisir



Measured memory_bytes: 1280
import java.util.*;

public class Main{
    public static void main(String[] args){
        Scanner scan = new Scanner(System.in);
        long a = scan.nextInt();
        long b = scan.nextInt();
        long c = scan.nextInt();
        if(a % 2 == 1 || b % 2 == 1 || c % 2 == 1){
            System.out.println(0);
            return;
        }
        if(a == b && b == c){
            System.out.println(-1);
            return;
        }
        int out = 0;
        while(a % 2 == 0 && b % 2 == 0 && c % 2 == 0){
            long aa = b / 2 + c / 2;
            long ba = a / 2 + c / 2;
            long ca = a / 2 + b / 2;
            a = aa; b = ba; c = ca;
            out++;
        }
        System.out.println(out);
        scan.close();
    }
}

Measured memory_bytes: 27096
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <set>
#include <map>
using namespace std;
int main(void){
  string s1, s2;
  cin >> s1 >> s2;
  string s3 = s1 + s2;
  int n=stoi(s3);
  for(int i=0; i*i<=n; i++){
    if(i*i==n){cout << "Yes" << endl;return 0;}
  }
  cout <<  "No" << endl;
  return 0;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.List;
import java.util.function.BiFunction;

public class Main {
	public static void main(String[] args) throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String[] sa = br.readLine().split(" ");
		int n = Integer.parseInt(sa[0]);
		int k = Integer.parseInt(sa[1]);
		int[] a = new int[n];
		for (int i = 0; i < n; i++) {
			a[i] = Integer.parseInt(br.readLine());
		}
		br.close();

		int mx = 300001;
		SegTree<Integer> st = new SegTree<>(mx, 0, (v1, v2) -> Math.max(v1, v2));
		for (int i = 0; i < n; i++) {
			int l = Math.max(0, a[i] - k);
			int r = Math.min(mx, a[i] + k + 1);
			int max = st.query(l, r);
			st.update(a[i], max + 1);
		}
		System.out.println(st.query(0, mx));
	}

	/**
	 * セグ木
	 * ■最大
	 * SegTree<Integer> st = new SegTree<>(n, 0, (v1, v2) -> Math.max(v1, v2));
	 * ■最小
	 * SegTree<Integer> st = new SegTree<>(n, Integer.MAX_VALUE, (v1, v2) -> Math.min(v1, v2));
	 * ■和
	 * SegTree<Integer> st = new SegTree<>(n, 0, (v1, v2) -> v1 + v2);
	 */
	static class SegTree<T> {
		// 親へのアクセス：(n - 1) / 2
		// 子へのアクセス：n * 2 + 1、n * 2 + 2
		int n = 2; // 要素（葉）の数
		int n2; // 全ノード数
		T NA;
		List<T> list;
		BiFunction<T, T, T> func;

		/**
		 * 初期化 O(N)
		 * @param num 要素（葉）の数
		 * @param na 単位元
		 * @param func 区間に対する操作が可能な関数（戻り値は新規オブジェクト）
		 */
		public SegTree(int num, T na, BiFunction<T, T, T> func) {
			while (n < num) n <<= 1;
			n2 = n * 2 - 1;
			NA = na;
			list = new ArrayList<T>(n2);
			for (int i = 0; i < n2; i++) list.add(NA);
			this.func = func;
		}

		/**
		 * 更新 O(logN)
		 * @param i インデックス（0～n-1）
		 * @param x 更新値
		 */
		void update(int i, T x) {
			i += n - 1; // arr上でのインデックス
			list.set(i, x);
			while (i > 0) {
				i = (i - 1) / 2;
				list.set(i, func.apply(list.get(i * 2 + 1), list.get(i * 2 + 2)));
			}
		}

		/**
		 * 取得 O(logN)
		 * インデックスl以上r未満の区間の値
		 */
		T query(int l, int r) {
			return query(l, r, 0, 0, n);
		}

		/**
		 * 取得 O(logN)
		 * インデックスl以上r未満の区間の値、beg, endにはノードkに対応する区間
		 * query(l, r, 0, 0, n);
		 */
		private T query(int l, int r, int k, int beg, int end) {
			if (end <= l || r <= beg) return NA; // 交差しない
			if (l <= beg && end <= r) return list.get(k); // 完全に含む
			T v1 = query(l, r, k * 2 + 1, beg, (beg + end) / 2);
			T v2 = query(l, r, k * 2 + 2, (beg + end) / 2, end);
			return func.apply(v1, v2);
		}
	}
}


Measured memory_bytes: 75848
Infinity = 1000000

def decreaseKey q, v, w
  q.size.times do |i|
    if q[i][0] == v
      q[i][1] = w
      break
    end
  end
end

def inQueue q, v
  q.size.times do |i|
    return true if q[i][0] == v
  end
  false
end

def prim graph
  n = graph.size
  key = Array.new(n, Infinity)
  key[0] = 0
  q = Array.new
  n.times do |i|
    q << [i, key[i]]
  end

  until q.empty?
    #最少のキー値を持つノードを取り出す
    u = -1
    min = Infinity
    q.size.times do |i|
      if q[i][1] < min
        min = q[i][1]
        u = q[i][0]
      end
    end
    q.size.times do |i|
      if q[i][0] == u
        q.delete_at(i)
        break
      end
    end

    #そのノードから接続しているすべてのノードについて、キー値を更新する
    n.times do |v|
      next if graph[u][v] == Infinity
      if inQueue(q, v)
        w = graph[u][v]
        #キー値を更新したら、キュー格納値のキーを更新
        if w < key[v]
          key[v] = w
          decreaseKey(q, v, w)
        end
      end
    end
  end
  key
end

loop do
  n,m = $stdin.gets.chomp.split(" ").map(&:to_i)
  break if (n|m) == 0
  graph = Array.new(n).map{Array.new(n, Infinity)}
  m.times do |i|
    a,b,cost = $stdin.gets.chomp.split(" ").map(&:to_i)
    graph[a][b] = cost
    graph[b][a] = cost
  end
  p prim(graph).inject(:+)
end

Measured memory_bytes: 6200
/*
    Problem 96
    https://atcoder.jp/contests/abc139/tasks/abc139_d
*/
#include <bits/stdc++.h>
using namespace std;
/* typedef */
typedef long long ll;
typedef pair<int, int> pii;
/* constant */
const int INF = 1 << 30;
const ll LINF = 1LL << 50;
const int NIL = -1;
const int MAX = 10000;
const int mod = 1000000007;
const double pi = 3.141592653589;
/* global variables */
/* function */
/* main */
int main(){
    ll N;
    cin >> N;
    cout << (N) * (N-1) / 2 << '\n';
}

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

int main() {
  int n;
  int count=0;
  cin >> n;
  
  vector<int> data(n);
  FOR(i,0,n){
    cin >> data.at(i);
  }
  
  FOR(i,1,n-1){
    if((data.at(i)>data.at(i-1)&&data.at(i)<data.at(i+1))
       ||(data.at(i)<data.at(i-1)&&data.at(i)>data.at(i+1)))
      count++;
  }
  
  cout << count;
}
    
  


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

ll get_limited_number(ll source) {
    static const ll number_set[] = {3, 5, 7};
    static const ll number_types = 3;
    ll minus = 0;
    ll surplus = number_types;
    ll division = 1;
    ll result = 0;
    ll digit = 1;
    
    while(true) {
        result += number_set[((source - minus) % surplus) / division] * digit;
        
        if ((minus + surplus) > source) {
            break;
        }
        
        digit *= 10;
        minus += surplus;
        surplus *= number_types;
        division *= number_types;
    }
    
    return result;
}

int main() {
    ll n;
    ll ln;
    ll elements[10];
    ll ans = 0;
    
    cin >> n;
    
    for (ll i = 0; ; i++) {
        ln = get_limited_number(i);
        
        if (ln > n) {
            break;
        }
        
        for (ll ii = 0; ii < 10; ii++) {
            elements[ii] = 0;
        }
        
        while (ln) {
            elements[ln % 10]++;
            ln /= 10;
        }
        
        if (
            (elements[3] > 0) &&
            (elements[5] > 0) &&
            (elements[7] > 0)
        ) {
            ans++;
        }
    }
    
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
N = int(input())
c = list(map(int, input().split()))
c.sort(reverse = True)
mod = 10 ** 9 + 7
tmp = (2 ** (N - 1)) % mod
d  = (2 ** (N - 2)) % mod
ans = 0
for ci in c:
    ans += (ci * tmp) % mod
    ans %= mod
    tmp = (tmp + d) % mod
print((ans * 2 ** N) % mod)


Measured memory_bytes: 87500
// inputに入力データ全体が入る
function Main(input) {
    // 1行目がinput[0], 2行目がinput[1], …に入る
    input = input.split("\n");
    var A1 = input[0].split(" ")
    var A2 = input[1].split(" ")
    var A3 = input[2].split(" ")
    var N = input[3]
    var bingo = [false, false, false, false, false, false, false, false, false]
    for (var i = 0; i < Number(N); i++) {
        if (Number(A1[0]) === Number(input[i + 4])) {
            bingo[0] = true
        }
        if (Number(A1[1]) === Number(input[i + 4])) {
            bingo[1] = true
        }
        if (Number(A1[2]) === Number(input[i + 4])) {
            bingo[2] = true
        }
        if (Number(A2[0]) === Number(input[i + 4])) {
            bingo[3] = true
        }
        if (Number(A2[1]) === Number(input[i + 4])) {
            bingo[4] = true
        }
        if (Number(A2[2]) === Number(input[i + 4])) {
            bingo[5] = true
        }
        if (Number(A3[0]) === Number(input[i + 4])) {
            bingo[6] = true
        }
        if (Number(A3[1]) === Number(input[i + 4])) {
            bingo[7] = true
        }
        if (Number(A3[2]) === Number(input[i + 4])) {
            bingo[8] = true
        }
    }

    var answer = "No";
    if (bingo[0] && bingo[4] && bingo[8]) {
        answer = "Yes"
    }
    if (bingo[2] && bingo[4] && bingo[6]) {
        answer = "Yes"
    }
    if (bingo[0] && bingo[1] && bingo[2]) {
        answer = "Yes"
    }
    if (bingo[3] && bingo[4] && bingo[5]) {
        answer = "Yes"
    }
    if (bingo[6] && bingo[7] && bingo[8]) {
        answer = "Yes"
    }
    if (bingo[0] && bingo[3] && bingo[6]) {
        answer = "Yes"
    }
    if (bingo[1] && bingo[4] && bingo[7]) {
        answer = "Yes"
    }
    if (bingo[2] && bingo[5] && bingo[8]) {
        answer = "Yes"
    }
    console.log(answer)
}
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 11596
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ll long long
#define FOR(i,a,b) for(int i=(a); i<=(b); i++)
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define chmin(a,b) if((a)>(b)) (a)=(b);
#define chmax(a,b) if((a)<(b)) (a)=(b);
#define vi vector<int>
#define pii pair<int,int>
#define all(v) (v).begin(),(v).end()
#define allr(v) (v).rbegin(),(v).rend()
#define pb push_back
#define pf push_front
int gcd(int a,int b){/*a>=0,b>=0,￢(a=b=0)*/
  while(min(a,b)>0){if(a<b)swap(a,b);a%=b;}return max(a,b);
}
int dx[]={1,0,-1,0,1,-1,-1,1};
int dy[]={0,1,0,-1,1,1,-1,-1};
const int MOD = 1e9+7;
const long long INF = 1e18+10;

/*--------------------------------------------------------------------*/

signed main(){
	int x;
	cin>>x;
	cout<<1-x<<endl;


	return 0;
}

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

int main(){
  int count = 0;
  char S[4], T[4];
  
  cin >> S[0] >> S[1] >> S[2] >> T[0] >> T[1] >> T[2];
  
  for(int i = 0; i < 3; i++){
    if(S[i] == T[i]){
      count++;
    }
  }
  
  cout << count << endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
typedef long long ll;

using namespace std;

int main(){

	int n;
	cin >> n;
	int p[200000]={0};
	int ans=0;
	REP(i,n){
		cin >> p[i];
	}
	int m = p[0];
	REP(i,n){
		m = min(m,p[i]);
		if(m == p[i])ans++;
	}
	cout << ans << endl;

    return 0;
}

Measured memory_bytes: 4404
def knapsack_123(values,weights,capacity):
    work = [0 for i in range(capacity+1)]
    for v,w in zip(values,weights):
        for c in range(w, capacity+1):
            work[c]=max(work[c],work[c-w]+v)
    return work[-1]
def sol(inp=input):
    n=int(inp())
    prices_a=list(map(int,inp().split()))+[1]
    prices_b=list(map(int,inp().split()))+[1]
    
    valA=knapsack_123(values=prices_b,weights=prices_a,capacity=n)
    valB=knapsack_123(values=prices_a,weights=prices_b,capacity=valA)
    return '{}'.format(valB)
print(sol())

Measured memory_bytes: 422960
import sys
sys.setrecursionlimit(100000)
import heapq
input=lambda : sys.stdin.readline().rstrip('\n')

n,m=map(int,input().split())
data=[]
for i in range(n):
    a,b=map(int,input().split())
    heapq.heappush(data,(a,b))
cnt=0
cost=0
while True:
    a,b=heapq.heappop(data)
    if cnt+b>=m:
        cost+=(m-cnt)*a
        break
    else:
        cnt+=b
        cost+=a*b
print(cost)

Measured memory_bytes: 57180
using namespace std;
#include <bits/stdc++.h>
#define fdto(i, r, l) for(int i = r; i >= l; --i)
#define fto(i, l, r) for(int i = l; i <= r; ++i)
#define forit(it, type, var) for(type::iterator it = var.begin(); it != var.end(); it++)
#define ii pair<int, int>
#define iii pair<int, ii>
#define MEMS(a,b) memset(a,b,sizeof(a))
#define fi first
#define se second
#define m_p make_pair
#define pb push_back
#define ll long long
#define ld long double
#define maxN 1000000000000000000
ll power(ll a,ll b){ll res=1;while(b>0){res*=a;b--;}return res;}
int main()
{
    
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    char x;
    cin>>x;

    if(x<='z' && x>='a')
    cout<<'a'<<endl;
    else if(x<='Z' && x>='A')
    cout<<'A'<<endl;
    return 0;
}


Measured memory_bytes: 3648
fn read<T: std::str::FromStr>() -> T {
  let mut s = String::new();
  std::io::stdin().read_line(&mut s).ok();
  s.trim().parse().ok().unwrap()
}
 
fn main() {
  let n: u32 = read();
  let x: u32 = n.to_string().chars().next().unwrap() as u32 - '0' as u32;
  let y: u32 = format!("{}{}{}", x, x, x).parse().unwrap();

  if n <= y {
    println!("{}", y);
  } else {
    println!("{}{}{}", x + 1, x + 1, x + 1);
  }
}


Measured memory_bytes: 4352
#include <cstdio>
#include <cstdlib>
#include <cctype>
#include <cmath>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <utility>
#include <iostream>
#define REP(i, a, b) for (int i = a; i <= b; ++i)
#define PER(i, a, b) for (int i = a; i >= b; --i)
#define RVC(i, S) for (int i = 0; i < S.size(); ++i)
#define mp make_pair
#define pb push_back
#define fi first
#define se second
using namespace std;

typedef long long LL;
typedef pair<int, int> pii;
typedef vector<int> VI;

int n, m, d;

int main(){
	cin >> n >> m >> d;
	double p0 = (double)(m - 1) / n;
	if (d == 0) return printf("%.10lf\n", p0), 0;
	double pp = (double)(m - 1) * 2 / ((double)n * n);
	printf("%.10lf\n", pp * (n - d));
	return 0;
}

Measured memory_bytes: 256
// Author : Sarthak Kapoor
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace std;
using namespace __gnu_pbds;
#define rep(i,n) for(int i=0;i<n;++i)
#define repa(i,a,n) for(int i=a;i<n;++i)
#define repr(i,n) for(int i=n-1;i>=0;--i)
#define repba(i,b,a) for(int i=b;i>=a;--i)
#define repab(i,a,b) for(int i=a;i<b;++i)
#define ll long long
#define ull unsigned long long
#define vi vector<int>
#define msi map<string,int>
#define mii map<int,int>
#define viip vector<pair<int,pair<int,int> > > 
#define mp make_pair
#define vip vector<pair<int,int> >
#define pb push_back 
#define po pop_back
#define fi first
#define sec second
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define s(v) v.size()
ll mod = 1000000007;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());//use rng()%n for numbers in range [0,n-1]
ll gcd(ll a,ll b){
	if(b==0)return a;
	return gcd(b,a%b);
}
int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	
	ll h;
	cin>>h;
	int n;
	cin>>n;
	vi v(n);
	ll sum = 0;
	rep(i,n){
		cin>>v[i];
		sum += v[i];
	}
	if(sum >= h)cout<<"Yes";
	else cout<<"No";
	return 0;
}

Measured memory_bytes: 640
#ABC145C
def main():
    import sys, math
    import itertools as ite
    N = int(sys.stdin.readline())
    L = [list(map(int, sys.stdin.readline().split())) for _ in range(N)]
    #print(L)
    
    A = list(ite.permutations([i for i in range(N)]))
    #print(A)
    ans = 0
    for a in A:
        for i in range(N-1):
            ans += math.sqrt((L[a[i]][0]- L[a[i+1]][0])**2 + (L[a[i]][1]- L[a[i+1]][1])**2)
    print(ans/len(A))
            





if __name__=='__main__':
    main()

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

int main()
{
  int x, a, b;
  cin >> x >> a >> b;

  if (a >= b)
    cout << "delicious" << endl;
  else if (b - a <= x)
    cout << "safe" << endl;
  else 
    cout << "dangerous" << endl;

}


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

using namespace std;

typedef long long LL;

const int N = 100 + 5;



int main(){

	ios::sync_with_stdio(false);

	cin.tie(0);

			

	int n , m , t , sum = 0;

	vector<int> a;

	cin>>n;

	m = 2 * n;

	while(m--){

		cin>>t;

		a.push_back(t);

		}

	sort(a.begin() , a.end());

	for(int i = 0 ; i < 2*n - 1; i+=2){

		sum += min(a[i] , a[i+1]);

		}

	cout<<sum<<endl;

	return 0;

	}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define pll pair<ll, ll>
#define N 1000123
#define vi vector<int>
#define vll vector<ll>
#define vpll vector<pll>
#define pb emplace_back
#define fs first
#define sc second
#define sz(x) ((int)((x).size()))
#define oo 1000000123
#define mod 1000000007LL
#define M 10000123
 
using namespace std;
 
int main(){
    ios_base::sync_with_stdio(0);
    int n;
    cin >> n;
    while(n >= 1000) n -= 1000;
    if(n == 0) cout << 0 << '\n';
    else cout << 1000-n << '\n';
    return 0;
}


Measured memory_bytes: 3656
// In the name of God

#include <iostream>
#include <algorithm>
#include <fstream>
#include <vector>
#include <deque>
#include <assert.h>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <stdio.h>
#include <string.h>
#include <utility>
#include <math.h>
#include <bitset>
#include <iomanip>
#include <complex>

using namespace std;

#define rep(i, a, b) for (int i = (a), i##_end_ = (b); i < i##_end_; ++i)
#define debug(...) fprintf(stderr, __VA_ARGS__)
#define mp make_pair
#define x first
#define y second
#define pb push_back
#define SZ(x) (int((x).size()))
#define ALL(x) (x).begin(), (x).end()

template<typename T> inline bool chkmin(T &a, const T &b) { return a > b ? a = b, 1 : 0; }
template<typename T> inline bool chkmax(T &a, const T &b) { return a < b ? a = b, 1 : 0; }
template<typename T> inline bool smin(T &a, const T &b)   { return a > b ? a = b : a;    }
template<typename T> inline bool smax(T &a, const T &b)   { return a < b ? a = b : a;    }

typedef long long LL;

const int N = (int) 0, mod = (int) 0;

int main() {
	string s;
	cin >> s;
	long long res = 0;
	int num = 0;
	for (int j = (int) s.size() - 1; j >= 0; --j) {
		if (s[j] == 'A') {
			if (s[j + 1] == 'C' && j + 1 < (int) s.size()) num = 0;	
			res += num;
		}
		if (s[j] == 'B' && j + 1 < (int) s.size()) {
			if (s[j + 1] == 'C') ++num;
			if (s[j + 1] == 'B' || s[j + 1] == 'A') num = 0;
		}
		if (s[j] == 'C' && j + 1 < (int) s.size()) {
			if (s[j + 1] == 'C') num = 0;
		}
	}
	cout << res << endl;
}



















Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using vl = vector<ll>;
using vll = vector<vl>;
using Pll = pair<ll, ll>;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(v) v.begin(), v.end()
#define sz(x) ((int) x.size())
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define F first
#define S second
const int MOD = 1e9+7;
const ll INF = 2e15;
template<class T> void print(const T& t){ cout << t << endl; }
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; }
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}

int main(){
  string abc = "abcdefghijklmnopqrstuvwxyz";
  ll n;
  cin >> n;
  vll alpha(n, vl(26, 0));
  rep(i, n)
  {
    string s;
    cin >> s;
    rep(j,sz(s)){
      alpha[i][s[j] - 'a']++;
    }
  }
  string ans = "";
  rep(i, 26){
    ll mini = INF;
    rep(j, n){
      chmin(mini,alpha[j][i]);
    }
    rep(k,mini){
      ans += abc[i];
    }
  }
  print(ans);
}

Measured memory_bytes: 3632
#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)
using ll = long long;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using mii = map<int, int>;
using msi = map<string, int>;
using pii = pair<int, int>;

struct Edge {
    int to;     // 辺の行き先
    int weight; // 辺の重み
    Edge(int t, int w) : to(t), weight(w) { }
};
using Graph = vector<vector<Edge>>;

int main()
{
    ios::sync_with_stdio(false);
    int k, x;
    cin >> k >> x;

    if(500*k >= x) cout << "Yes" <<endl;
    else cout << "No" <<endl;


    return 0;
}

Measured memory_bytes: 256
from copy import copy
S = list(input())
T = list(input())
N = len(S)
M = len(T)
l = []
flag = 0
exist = 0
for i in range(N-M+1):
    flag = 0
    for j in range(M):
        if T[j] != S[i+j] and S[i+j] != "?":
            flag += 1

    if flag == 0:
        tmp = copy(S)
        for k in range(M):
            tmp[i+k] = T[k]
        l.append(tmp)
        exist = 1

a = []
if exist == 1: 
    L = len(l)
    for i in range(L):
        tmp = copy(l[i])
        for j in range(N):
            if tmp[j] == "?":
                tmp[j] = "a"
        a.append(tmp)
    a.sort()
    ans = "".join(a[0])
    print(ans)
else:
    print("UNRESTORABLE")

Measured memory_bytes: 39732
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long LL;
typedef pair<LL,LL> P;
const LL mod=1e9+7;
const LL LINF=1LL<<62;
const int INF=1000000000;



int main(){
    int n;cin >> n;
    vector<LL> a,b;
    LL ans=0;
    for (int i = 0; i < n; i++) {
        LL A,B;
        cin >> A >> B;
        a.pb(A);
        b.pb(B);
        ans+=A;
    }
    vector<LL> x;
    for (int i = 0; i < n; i++) {
        x.pb(-a[i]-b[i]);
    }
    sort(ALL(x));
    for (int i = 1; i < n; i+=2) {
        ans+=x[i];
    }
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 3308
/*
これを入れて実行
g++ code.cpp
./a.out
 */

#include <iostream>
#include <vector>
#include <string>
#include <queue>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <cmath>
#include <tuple>
#include <iomanip>

using namespace std;
typedef long long ll;
typedef long double ld;

int dy4[4] = {-1, 0, +1, 0};
int dx4[4] = {0, +1, 0, -1};
int dy8[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
int dx8[8] = {0, 1, 1, 1, 0, -1, -1, -1};

const long long INF = 1LL << 60;
const ll MOD = 1e9 + 7;

bool greaterSecond(const pair<int, int>& f, const pair<int, int>& s){
    return f.second > s.second;
}

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

//-----------------------ここから-----------


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

	sort(s.begin(), s.end());
	sort(t.begin(), t.end(), greater<char>());

	if(s < t){
		cout << "Yes" << endl;
	} else {
		cout << "No" << endl;
	}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF = (1ll<<31)-1;

ll gcd(ll a,ll b){
    if(a*b==0) return a+b;
    if(b<a) swap(a,b);
    ll r = a%b;
    while(r){
        a = b;
        b = r;
        r = a%b;
    }
    return b;
}

struct LazySegment {
    int n;
    vector<ll> node,lazy;

    LazySegment(vector<ll> &v){
        n = 1;
        while(n < v.size()) n *= 2;

        // ノード数は ceil(log2(N))^2 * 2 (末端ノード数が2べきとなるよう調整)
        node.assign(2*n-1,0);
        lazy.assign(2*n-1,0);

        for(int i = 0;i < v.size();i ++) node[i+n-1] = v[i];
        for(int i = n-2;i >= 0;i --) node[i] = gcd(node[2*i+1],node[2*i+2]); 

    }
    /*
    void eval(int k,int l,int r){ // k番ノードについて遅延評価
        if(lazy[k]){
            node[k] = lazy[k];

            // 末端ノードでなければ子ノードに伝播
            if(r-l>1){
                lazy[2*k+1] = lazy[k];
                lazy[2*k+2] = lazy[k];
            }
            lazy[k] = 0;
        }
    }
    
    void update(int a,int b,ll x,int k=0,int l=0,int r=-1){ // [a,b)の各要素をxに更新
        if(r<0) r = n;

        eval(k,l,r);

        // 含まない
        if(b<=l || r<=a) return;
        // 完全に含む
        if(a<=l && r<=b){
            lazy[k] = x;
            eval(k,l,r);
        }else{
            update(a,b,x,2*k+1,l,(l+r)/2);
            update(a,b,x,2*k+2,(l+r)/2,r);
            node[k] = min(node[2*k+1],node[2*k+2]);
        }
    }
    */

    ll range_gcd(int a,int b,int k=0,int l=0,int r=-1){ // [a,b)の要素の総和を返す
        if(r<0) r = n;

        //eval(k,l,r);

        // 含まない
        if(b<=l || r<= a) return 0;
        // 完全に含む
        if(a<=l && r<=b) return node[k];

        ll vl = range_gcd(a,b,2*k+1,l,(l+r)/2);
        ll vr = range_gcd(a,b,2*k+2,(l+r)/2,r);
        return gcd(vl,vr);
    }
};

int main(){
    int n,ans=0;
    cin >> n;
    vector<ll> a(n);
    for(int i = 0;i < n;i ++){
        cin >> a[i];
    }
    LazySegment tree(a);
    
    for(int i = 0;i < n;i ++){
        int gl,gr,g;
        gl = i?tree.range_gcd(0,i):0;
        gr = i<n-1?tree.range_gcd(i+1,n):0;

        g = gcd(gl,gr);

        ans = max(ans,g);
    }
    cout << ans << endl;
    return 0;
}

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

#define int long long 
#define pb push_back
#define ff first
#define ss second


int32_t main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    
    int n;
    cin>>n;
    
    int t=n/500;
    int ans=t*1000LL;
    n=n-t*500LL;
    
    t=n/5;
    ans=ans+t*5LL;
    cout<<ans;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(){
    int i, j, w, h;
    
    while(1){
        scanf("%d%d", &h, &w);
        if(w == 0 && h == 0) break;
        for(i = 0; i < w; i++) printf("#");
        printf("\n");
        for(i = 1; i < h - 1; i++){
            printf("#");
            for(j = 1; j < w - 1; j++){
                printf(".");
            }
            printf("#");
            printf("\n");
        }
        for(i = 0; i < w; i++) printf("#");
        printf("\n");
        printf("\n");
    }
    
    return 0;
}


Measured memory_bytes: 2072
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.nio.charset.StandardCharsets;

public class Main {
	public static void main(String[] args) throws IOException {
		String[] aS = new String[3];
		String[] bS = new String[2];
		Integer n,h,w;
		Integer tempA, tempB,count=0;
		try (BufferedReader br = new BufferedReader(new InputStreamReader(System.in, StandardCharsets.UTF_8))) {
			aS = br.readLine().split(" ");
			n = Integer.valueOf(aS[0]);
			h = Integer.valueOf(aS[1]);
			w = Integer.valueOf(aS[2]);
			for(int i=0;i<n;i++) {
				bS = br.readLine().split(" ");
				tempA = Integer.valueOf(bS[0]);
				tempB = Integer.valueOf(bS[1]);
				if(tempA >= h && tempB >= w) {
					count++;
				}
			}
		}
		System.out.println(count);
	}
}

Measured memory_bytes: 23124
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef string str;
#define REP(i, n) for(int i=0; i<n; ++i)
#define ALL(obj) (obj).begin(), (obj).end()
using P = pair<int, int>;
const int inf = 1e9;
const ll INF = 1e18;
const ll mod = 1e9+7;

struct edge{
    int to;
    int cost;
};
using graph = vector<vector<edge>>;

int main(){
    int a, b, c; cin >> a >> b >> c;
    if(a == b && b != c){
        cout << "Yes" << endl;
    }else if(b == c && c != a){
        cout << "Yes" << endl;
    }else if(c == a && a != b){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
}

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

int main(){
	
	int t[2][4];
	int S[2]={0};
	
	for(int i=0;i<2;i++){
		for(int j=0;j<4;j++){
			cin>>t[i][j];
			S[i]+=t[i][j];
		}
	}
	
	cout<<max(S[0],S[1])<<endl;
}

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

class Main{
  public static void main(String[] arg){

    ArrayList <String> taro = new ArrayList <String>();
    ArrayList <String> hanako = new ArrayList <String>();
    

    Scanner in = new Scanner(System.in);

    String input = in.nextLine();
    int card_cnt = Integer.parseInt(input);

    for(int i=0; i<card_cnt; i++){
        input = in.nextLine();
        String [] tmp = input.split(" ", 0);
        taro.add(tmp[0]);
        hanako.add(tmp[1]);
    }

    // debug System.out.println(taro.toString());
    // debug System.out.println(hanako.toString());

    int taro_point = 0, hanako_point = 0;

    for(int i=0; i<taro.size(); i++){
        String taro_card = taro.get(i);
        String hanako_card = hanako.get(i);

        // debug System.out.println(taro_card + " " + hanako_card);
        // debug System.out.println(taro_card.compareTo(hanako_card));

        if(taro_card.compareTo(hanako_card) > 0){
            taro_point += 3;
        }
        else if(taro_card.compareTo(hanako_card) < 0){
            hanako_point += 3;
        } else {
            taro_point += 1;
            hanako_point += 1;
        }
        // debug System.out.println(taro_point + " " + hanako_point);

    }

    System.out.println(taro_point + " " + hanako_point);

  }
}

Measured memory_bytes: 30920
#include <bits/stdc++.h>
using namespace std;
int main()
{
  string s;
  cin >> s;
  int one=0,zero=0;
  int n = s.length();
  for(int i=0; i<n; i++){
    if(s[i] == '0') zero++;
    if(s[i] == '1') one++;
  }
  cout << min(zero,one)*2 << endl;
  return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define rep(i,c) for(int i=0;i<c;++i)
#define PI 3.14159265358979323846264338327950L
typedef unsigned long long uint64;
using namespace std;
int main(){
  int L,R,d;
  cin >> L >> R >> d;
  int ans = 0;
  for(int i= L;i<=R;i++){
     if(i%d==0){
        ans++;
     }
  }
cout << ans << endl;
return 0;
}

Measured memory_bytes: 3624
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vin=vector<int>;
using vll=vector<long long>;
using vvin=vector<vector<int>>;
using vvll=vector<vector<long long>>;
using vstr=vector<string>;
using vvstr=vector<vector<string>>;
using vch=vector<char>;
using vvch=vector<vector<char>>;
using vbo=vector<bool>;
using vvbo=vector<vector<bool>>;
using vpii=vector<pair<int,int>>;
using pqsin=priority_queue<int,vector<int>,greater<int>>;
#define mp make_pair
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep2(i,s,n) for(int i=(s);i<(int)(n);i++)
#define all(v) v.begin(),v.end()
#define decp(n) cout<<fixed<<setprecision((int)n)
const int inf=1e9+7;
const ll INF=1e18;

int main(){
    ll h,w;cin>>h>>w;
    ll ans=0;
    if(h%3==0||w%3==0){
        cout<<0<<endl;
        return 0;
    }
    else ans=min(h,w);
    rep2(i,1,h)ans=min(ans,max(i*w,max((h-i)*(w/2),(h-i)*(w-w/2)))-min(i*w,min((h-i)*(w/2),(h-i)*(w-w/2))));
    rep2(i,1,w)ans=min(ans,max(i*h,max((w-i)*(h/2),(w-i)*(h-h/2)))-min(i*h,min((w-i)*(h/2),(w-i)*(h-h/2))));
    cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <queue>
#include <string>
#include <numeric>
#define REP(i,n) for(int i = 0; i < (int)n; i++)
using namespace std;

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

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

int main(){
  int n;
  cin >> n;
  long long t[n];
  REP(i,n){
    cin >> t[i];
  }
  long long ans = 1;
  REP(i,n){
    ans = lcm(ans,t[i]);
  }
  cout << ans << endl;
}


Measured memory_bytes: 256