akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

//def
#define debug(x) cout << #x << ": " << x << endl
#define out(x) cout << x << endl
#define repeat(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define revrepeat(i, a, b) for (int i = (int)(b)-1; i >= (int)(a); i--)
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define revrep(i, n) for (int i = (int)(n)-1; i >= 0; i--)
#define foreach(e, v) for (auto &e : v)
#define all(x) (x).begin(), (x).end()
#define CYES cout << "Yes" << endl
#define CNO cout << "No" << endl
#define SPC(x) cout << fixed << setprecision(x)
#define ZERO(a) memset(a, 0, sizeof(a))
#define MINUS(a) memset(a, 0xff, sizeof(a))

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<vector<int>> vii;
typedef vector<ll> vl;
typedef vector<vector<ll>> vll;
typedef pair<int, int> P;
constexpr int MOD = 1e9 + 7;
constexpr int INF = __INT_MAX__;               // 2^31 - 1
constexpr long long INFLL = __LONG_LONG_MAX__; // 2^61 - 1
constexpr int MAX_N = 1e5 + 5;
constexpr double PI = acos(-1);

// make vector of divisor O(sqrt(n))
vector<long long> divisor(long long n) {
    vector<long long> res;
    for (long long i = 1; i * i <= n; i++) {
        if (n % i == 0) {
            res.push_back(i);
            if (i != n / i) res.push_back(n / i);
        }
    }
    return res;
}

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

    ll n;
    cin >> n;
    ll ans = 0;

    auto factors = divisor(n - 1);
    auto factor = divisor(n);

    ans += factors.size() - 1;
    foreach (e, factor) {
        if (e == 1) continue;

        ll cp_n = n;
        do {
            cp_n /= e;
        } while (cp_n % e == 0);

        if (cp_n % e == 1) ans++;
    }

    out(ans);
    return 0;
}


Measured memory_bytes: 384
import math
from functools import reduce
from collections import deque
import sys
sys.setrecursionlimit(10**7)

# スペース区切りの入力を読み込んで数値リストにして返します。
def get_nums_l():
    return [ int(s) for s in input().split(" ")]

# 改行区切りの入力をn行読み込んで数値リストにして返します。
def get_nums_n(n):
    return [ int(input()) for _ in range(n)]

# 改行またはスペース区切りの入力をすべて読み込んでイテレータを返します。
def get_all_int():
    return map(int, open(0).read().split())

def log(*args):
    print("DEBUG:", *args, file=sys.stderr)

n,m = get_nums_l()
A = get_nums_l()

A.sort(reverse=True)

_sum = sum(A)

print("Yes" if A[m-1] >= (_sum / (4*m)) else "No")

Measured memory_bytes: 38384
#include <stdio.h>

int main()
{
    long n;
    long p=1;
    scanf("%ld",&n);
    for(long i=1;i<=n;i++){
        p*=i;
        if(p>100000) p = p%(1000000000+7);
    }
    printf("%ld\n",p%(1000000000+7));
    return 0;
}

Measured memory_bytes: 128
#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)
#define ALL(v) begin(v),end(v)
#define fi first
#define se second
template<typename A, typename B> inline bool chmax(A &a, B b) { if (a<b) { a=b; return 1; } return 0; }
template<typename A, typename B> inline bool chmin(A &a, B b) { if (a>b) { a=b; return 1; } return 0; }
using ll = long long;
using pii = pair<int, int>;
constexpr ll INF = 1ll<<30;
constexpr ll longINF = 1ll<<60;
constexpr ll MOD = 1000000007;
constexpr bool debug = 0;
//---------------------------------//

struct LazySegTree {
	vector<ll> node, lazy;
	int n;
	
	LazySegTree(int _n) {
		n = 1;
		while (n < _n) n *= 2;
		
		node.resize(n * 2 - 1, 0);
		lazy.resize(n * 2 - 1, 0);
	}
	
	void eval(int k, int l, int r) {
		if (lazy[k] == 0) return;
		node[k] += lazy[k];
		if (r - l > 1) {
			lazy[k * 2 + 1] += lazy[k];
			lazy[k * 2 + 2] += lazy[k];
		}
		lazy[k] = 0;
	}
	
	void add(int a, int b, ll x, int k = 0, int l = 0, int r = -1) {
		if (r < 0) r = n;
		eval(k, l, r);
		
		if (a >= r || b <= l) return;
		if (a <= l && r <= b) {
			lazy[k] += x;
			eval(k, l, r);
		}
		else {
			add(a, b, x, k * 2 + 1, l, (l + r) / 2);
			add(a, b, x, k * 2 + 2, (l + r) / 2, r);
			node[k] = min(node[k * 2 + 1], node[k * 2 + 2]);
		}
	}
	
	ll query(int a, int b, int k = 0, int l = 0, int r = -1) {
		if (r < 0) r = n;
		eval(k, l, r);
		
		if (a >= r || b <= l) return 1ll<<60;
		if (a <= l && r <= b) return node[k];
		return min( query(a, b, k * 2 + 1, l, (l + r) / 2), query(a, b, k * 2 + 2, (l + r) / 2, r) );
	}
};

int N, D, A;
ll X[212345], H[212345];

int main() {
	cin >> N >> D >> A;
	REP(i, N) scanf("%lld %lld", X + i, H + i);
	
	vector<ll> cx, nx(N);
	REP(i, N) cx.push_back(X[i]);
	cx.push_back(-longINF);
	cx.push_back(longINF);
	sort(ALL(cx));
	REP(i, N) nx[i] = lower_bound(ALL(cx), X[i]) - cx.begin();
	
	LazySegTree seg(N + 2);
	REP(i, N) seg.add(nx[i], nx[i] + 1, H[i]);
	
	// REP(i, N + 2) cout << seg.query(i, i + 1) << endl;
	// puts("K");
	
	ll ans = 0;
	REP(i, N + 2) {
		ll cur = seg.query(i, i + 1);
		if (cur <= 0) continue;
		ll cnt = (cur + A - 1) / A;
		ll dam = cnt * A;
		
		int r = upper_bound(ALL(cx), cx[i] + 2 * D) - cx.begin();
		seg.add(i, r, -dam);
		ans += cnt;
		
		// cout << i << " " << cnt << "dam : " << dam<< endl;
	}
	
	cout << ans << endl;
	
	return 0;
}


Measured memory_bytes: 14832
local mfl, mce, mmi = math.floor, math.ceil, math.min
local SegTree = {}
SegTree.updateAll = function(self)
  for i = self.stagenum - 1, 1, -1 do
    for j = 1, self.cnt[i] do
      self.stage[i][j] = self.func(self.stage[i + 1][j * 2 - 1], self.stage[i + 1][j * 2])
    end
  end
end
SegTree.create = function(self, n, func, emptyvalue)
  self.func, self.emptyvalue = func, emptyvalue
  local stagenum, mul = 1, 1
  self.cnt, self.stage, self.size = {1}, {{}}, {}
  while mul < n do
    mul, stagenum = mul * 2, stagenum + 1
    self.cnt[stagenum], self.stage[stagenum] = mul, {}
  end
  for i = 1, stagenum do self.size[i] = self.cnt[stagenum + 1 - i] end
  self.stagenum = stagenum
  -- for i = 1, #ary do self.stage[stagenum][i] = ary[i] end
  -- for i = #ary + 1, mul do self.stage[stagenum][i] = emptyvalue end
  for i = 1, mul do self.stage[stagenum][i] = emptyvalue end
  self:updateAll()
end
SegTree.getRange = function(self, left, right)
  if left == right then return self.stage[self.stagenum][left] end
  local start_stage = 1
  while right - left + 1 < self.size[start_stage] do
    start_stage = start_stage + 1
  end
  local ret = self.emptyvalue
  local t1, t2, t3 = {start_stage}, {left}, {right}
  while 0 < #t1 do
    local stage, l, r = t1[#t1], t2[#t1], t3[#t1]
    table.remove(t1) table.remove(t2) table.remove(t3)
    local sz = self.size[stage]
    if (l - 1) % sz ~= 0 then
      local newr = mmi(r, mce((l - 1) / sz) * sz)
      table.insert(t1, stage + 1) table.insert(t2, l) table.insert(t3, newr)
      l = newr + 1
    end
    if sz <= r + 1 - l then
      ret = self.func(ret, self.stage[stage][mce(l / sz)])
      l = l + sz
    end
    if l <= r then
      table.insert(t1, stage + 1) table.insert(t2, l) table.insert(t3, r)
    end
  end
  return ret
end
SegTree.setValue = function(self, idx, value, silent)
  self.stage[self.stagenum][idx] = value
  if not silent then
    for i = self.stagenum - 1, 1, -1 do
      local dst = mce(idx / 2)
      local rem = dst * 4 - 1 - idx
      self.stage[i][dst] = self.func(self.stage[i + 1][idx], self.stage[i + 1][rem])
      idx = dst
    end
  end
end
SegTree.new = function(n, func, emptyvalue)
  local obj = {}
  setmetatable(obj, {__index = SegTree})
  obj:create(n, func, emptyvalue)
  return obj
end

local function merge(x, y) return (x + y) % 3 end
local s = io.read()
local t = io.read()
local st1 = SegTree.new(#s, merge, 0)
local st2 = SegTree.new(#t, merge, 0)
for i = 1, #s do
  if s:sub(i, i) == "A" then
    st1:setValue(i, 1, true)
  else
    st1:setValue(i, 2, true)
  end
end
st1:updateAll()
for i = 1, #t do
  if t:sub(i, i) == "A" then
    st2:setValue(i, 1, true)
  else
    st2:setValue(i, 2, true)
  end
end
st2:updateAll()
local q = io.read("*n")
for i = 1, q do
  local a, b = io.read("*n", "*n")
  local c, d = io.read("*n", "*n")
  if st1:getRange(a, b) == st2:getRange(c, d) then
    print("YES")
  else
    print("NO")
  end
end


Measured memory_bytes: 10012
#include <bits/stdc++.h>
using namespace std;
#define all(x) x.begin(),x.end()
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
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;}
const long long MOD = 1000000007;
typedef long long ll;

int n,k;
string s,t;
int a[10][10],b[100005];
bool c[10][10];

int main() {
  rep(i,3)rep(j,3) cin >> a[i][j];
  cin >> n;
  rep(i,n) cin >> b[i];
  rep(i,n)rep(j,3)rep(k,3)if(b[i]==a[j][k]) c[j][k]=true;
  bool ok=false;
  rep(i,3)if(c[i][0] && c[i][1] && c[i][2]) ok=true;
  rep(i,3)if(c[0][i] && c[1][i] && c[2][i]) ok=true;
  if(c[0][0] && c[1][1] && c[2][2]) ok=true;
  if(c[0][2] && c[1][1] && c[2][0]) ok=true;
  cout << (ok ? "Yes" : "No") << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <queue>
#include <stack>
#include <cmath>
#include <ctime>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <numeric>
#include <complex>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <iostream>
#include <iterator>
#include <algorithm>
#include <functional>
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
typedef vector<int> vint;
typedef vector<vector<int>> v2int;
typedef vector<ll> vll;
typedef vector<vector<ll>> v2ll;
typedef list<int> liint;
typedef pair<int, int> pint;
const int INF = int(2e9);
const ll LINF = ll(2e9) * ll(2e9);
#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
template<class T, class C> void chmax(T& a, C b) { a > b ? : a = b; }
template<class T, class C> void chmin(T& a, C b) { a < b ? : a = b; }



int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int A, B, H, M;
    cin >> A >> B >> H >> M;
    double angA, angB;
    double PI = 3.14159265359;
    angA = PI * 2 * double(H * 60 + M) / 720.0;
    angB = PI * 2 * double(M) / 60.0;

    double ans = sqrt(double(A*A) + double(B*B)  
                        -double(2 * A * B) * cos(abs(angA - angB)));
    printf("%30.15f\n", ans);
    return 0;
}

Measured memory_bytes: 4180
// 30DTG
// 01072020
#include<bits/stdc++.h>
using namespace std;
#define bolt ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define F first
#define S second
#define pb push_back
#define endl "\n"
#define lb lower_bound
#define ub upper_bound
typedef long long ll;
typedef long double ld;
const ld pi=3.1415926535897932384626433;
const int mod = 1e9+7;
const ll inf=3e18;
int main()
{
   bolt;
   string s,r;
   cin>>s>>r;
   ll ans=0;
   for (ll i=0;i<s.size();i++)
   {
      if (s[i]!=r[i])
         ans++;
   }
   cout<<ans;
}


Measured memory_bytes: 3700
#include <bits/stdc++.h>
#include <vector>
#include <set>
#include <map>
#include <string>
#include <cstdio>
#include <cstdlib>
#include <climits>
#include <utility>
#include <algorithm>
#include <cmath>
#include <queue>
#include <stack>
#include <iomanip>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp> 
//setbase - cout << setbase (16); cout << 100 << endl; Prints 64
//setfill -   cout << setfill ('x') << setw (5); cout << 77 << endl; prints xxx77
//setprecision - cout << setprecision (14) << f << endl; Prints x.xxxx
//cout.precision(x)  cout<<fixed<<val;  // prints x digits after decimal in val
using namespace std;
using namespace __gnu_pbds;

#define sp << " " <<
#define mod 1000000007
#define PI 3.14159265358979323
#define y second
#define x first
#define pb push_back
#define mp make_pair
#define mem(a,b) memset(a,b,sizeof(a))
#define sz(a) a.size()
#define pqueue priority_queue< ll >
//#define pdqueue priority_queue< ll,vector<ll> ,greater< ll > >
#define codejamDebug(x) cout<<"Case #"<<x<<": ";
#define debug(x) cout<<#x<<" :"<<x<<endl;
#define rep(i,n) for(long long i=0;i<n;i++)
#define f(i,a,b) for(long long i = a; i < b; i++)
#define fd(i,a,b) for(long long i = a; i >=b; i--)
#define sync ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
typedef long long int           ll;
typedef long double             ld;
typedef unsigned long long int ull;
typedef vector <int>            vi;
typedef vector <ll>            vll;
typedef pair <int, int>        pii;
typedef pair <ll, ll>          pll;
typedef vector < pii >        vpii;
typedef vector < pll >        vpll;
typedef vector <string>         vs;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

//Handle:cyber_rajat

int main(int argc, char const *argv[])
{
	sync;

	int n;
	cin >> n;
	cout << n + n*n + n*n*n << endl;

	return 0;
}


Measured memory_bytes: 3648
#define __USE_MINGW_ANSI_STDIO 0
#include <bits/stdc++.h>
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl '\n'
#define ff first
#define ss second
#define mod 1000000007
#define pb push_back
#define mp make_pair
#define int long long
#define all(a) a.begin(), a.end()
#define inf (1LL<<61)
#define ull unsigned long long
#define debug1(x) cerr << #x << ": " << x <<'\n'
#define debug2(x, y) cerr << #x << ": " << x << '\t' << #y << ": " << y <<'\n'
#define debug3(x, y, z) cerr << #x << ": " << x << '\t' << #y << ": " << y << '\t' << #z << ": " << z <<'\n'
using namespace std;
int dx[]={1,0,-1,0};int dy[]={0,1,0,-1}; //4 Direction
//int dx[]={1,1,0,-1,-1,-1,0,1};int dy[]={0,1,1,1,0,-1,-1,-1};//8 direction
int gcd(int x,int y)
{
    if(y==0)
        return x;
    else
        return gcd(y,x%y);
}
int expo(int n,int m,int p)   //modULAR EXPONENTIATION
{
    int r=1;
    n=n%p;
    while(m>0)
    {
        if(m%2)
            r=(r*n)%p;
        n=(n*n)%p;
        m=m/2;
    }
    return r%p;
}
bool isPrime(int n)
{
    // Corner cases
    if (n <= 1)  return false;
    if (n <= 3)  return true;
 
    // This is checked so that we can skip 
    // middle five numbers in below loop
    if (n%2 == 0 || n%3 == 0) return false;
 
    for (int i=5; i*i<=n; i=i+6)
        if (n%i == 0 || n%(i+2) == 0)
           return false;
 
    return true;
}
int32_t main()
{
   IOS;
   /*#ifndef ONLINE_JUDGE
   freopen("input.txt","r",stdin); 
   freopen("output.txt","w",stdout);//abcabca
   #endif
   /********************* Code starts here ***********************/
   int a,b,c,d;
   cin>>a>>b>>c>>d;
   cout<<min(a,b)+min(c,d);
}

Measured memory_bytes: 256
import math
a, b, x = map(int, input().split())
if x <= a*a*b/2:
    # y = b/tan(z)
    y = 2 * x / (a * b)
    tanz = b / y
    z = math.degrees(math.atan(tanz))
    print(z)
else:
    # y = atan(z)
    x = a * a * b - x
    y = 2 * x / (a * a)
    tanz = y / a
    z = math.degrees(math.atan(tanz))
    print(z)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rrep(ri,n) for(int ri = (int)(n-1); ri >= 0; ri--)
#define rep2(i,x,n) for(int i = (int)(x); i < (int)(n); i++)
#define repit(itr,x) for(auto itr = x.begin(); itr != x.end(); itr++)
#define rrepit(ritr,x) for(auto ritr = x.rbegin(); ritr != x.rend(); ritr++)
#define ALL(x) x.begin(), x.end()
using ll = long long;
using namespace std;

int main(){
  string s;
  cin >> s;
  string ans;
  rep(i,s.size()){
    if(s.at(i) == '?'){
      char c;
      if(i == 0) c = 'D';
      else if(i == s.size()-1) c = 'D';
      else if(s.at(i-1) == 'P') c = 'D';
      else if(s.at(i+1) == 'D') c = 'P';
      else c = 'D';
      ans.push_back(c);
    }else{
      ans.push_back(s.at(i));
    }
  }
  cout << ans << endl;
  return 0;
}

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

int main() {
    int k, q; cin >> k >> q;
    vector<long long> D(k), d(k);
    for(int i=0; i<k; ++i) cin >> D[i];

    while(q--) {
        long long n, x, m; cin >> n >> x >> m;
        x %= m;
        long long sum = 0;
        for(int i=0; i<k; ++i) {
            d[i] = D[i] % m;
            if(d[i] == 0) d[i] = m;
            sum += d[i];
        }
        long long tmp = x + sum * ((n - 1) / k);
        for(int i=0; i<(n-1)%k; ++i) tmp += d[i];
        cout << n - 1 - (tmp / m) << endl;
    }
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0;i<(n);i++)
#define N 100000
typedef long long ll;
#define ALL(v) (v).begin(),(v).end()
#define SZ(x) int(x.size())
#define OUT(a) cout<<(a)<<endl
#define VECIN(type, c, n) vector<type> c(n);for(auto& i:c) cin>>i;

int dp[3][N+5];    
int main(){
	int n;
    cin>>n;
    vector<vector<int>> a(3,vector<int>(n));
    vector<int> b(n);
    vector<int> c(n);
    REP(i,n){
        cin>>a.at(0).at(i)>>a.at(1).at(i)>>a.at(2).at(i);
    }
    REP(i,3){
        REP(j,N+5){
            dp[i][j]=0;
        }
    }
    REP(i,n){
        REP(j,3){
            REP(l,3){
                if(j==l) continue;
                dp[j][i+1]=max(dp[j][i+1],dp[l][i]+a.at(j).at(i));;
            }
        }
    }
    OUT(max({dp[0][n],dp[1][n],dp[2][n]}));
	return 0;
}

Measured memory_bytes: 3448
use std::io::*;
use std::str::FromStr;

#[allow(dead_code)]
fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

const MOD: usize = 1e+9 as usize + 7;
fn main() {
    let n = read::<usize>();
    let m = read::<usize>();
    let mut bans = vec![false; n + 2];
    for _i in 0..m {
        let a = read::<usize>();
        bans[a] = true;
    }
    let mut dp = vec![0; n + 2];
    dp[0] = 1;
    for i in 0..n {
        if !bans[i + 1] {
            dp[i + 1] = (dp[i + 1] + dp[i]) % MOD;
        }
        if !bans[i + 2] {
            dp[i + 2] = (dp[i + 2] + dp[i]) % MOD;
        }
    }
    println!("{}", dp[n]);
}


Measured memory_bytes: 4352
import java.util.*;
public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        
        if(n%2 == 0 ){
            System.out.println(n);

        }else{
            System.out.println(n*2);
        }
    }

}


Measured memory_bytes: 21716
#include <bits/stdc++.h>
#define fo(i,m,n) for(int i = m; i <= n; i++)
#define fod(i,m,n) for(int i = m; i >= n; i--)
#define fov(i,x) for(auto &i : x)
#define x first
#define y second
using namespace std;
typedef int64_t i64;
typedef pair<int,int> _ii;
typedef pair<int,_ii> _iii;
_ii start, endd;
int H,W;
bool visited[1007][1007];
int d[1007][1007];
int _x[] = {-1,1,0,0};
int _y[] = {0,0,-1,1};
vector <string> s;
void Input()
{
    cin >> H >> W;
    cin >> start.x >> start.y;
    cin >> endd.x >> endd.y;
    s.resize(H+1);
    fo(i,1,H)
    {
        cin >> s[i];
        s[i] = "A" + s[i];
    }
    fo(i,1,H) fo(j,1,W) d[i][j] = 1e9;
}
int Run()
{
    int cnt = 0;
    priority_queue<_iii,vector <_iii>, greater<_iii> > A;
    A.push(_iii(0,start));
    while(cnt < H*W && A.size())
    {
        _iii h = A.top();
        A.pop();
        if(visited[h.y.x][h.y.y]) continue;
        visited[h.y.x][h.y.y] = true;
        cnt++;
        if(h.y == endd)
        {
            return d[h.y.x][h.y.y];
        }
        fo(i,0,3)
        {
            int u = h.y.x + _x[i];
            int v = h.y.y + _y[i];
            if(u >= 1 && v >= 1 && u <= H && v <= W)
            {
                if(s[u][v]  == '.' && d[u][v] > h.x)
                {
                    d[u][v] = h.x;
                    A.push(_iii(d[u][v],_ii(u,v)));
                }
            }
        }
        fo(i,-2,2)
        {
            fo(j,-2,2)
            {
                int u = h.y.x + i;
                int v = h.y.y + j;
                if(u >= 1 && v >= 1 && u <= H && v <= W)
                {
                    if(s[u][v] == '.' && d[u][v] > h.x+1)
                    {
                        d[u][v] = h.x+1;
                        A.push(_iii(d[u][v],_ii(u,v)));
                    }
                }
            }
        }
    }
    return -1;
}
int main()
{
    ios_base::sync_with_stdio(false);
	cin.tie(0); cout.tie(0);
    Input();
    cout << Run();
    return 0;
}


Measured memory_bytes: 9612
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;

const ll INF = 1e18;
const int MX = 2005;

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

Measured memory_bytes: 3596
#include <algorithm>
#include <bitset>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <stack>
#include <string>
#include <utility>
#include <vector>

#define repd(i, a, b) for (ll i = (a); i < (b); i++)
#define rep(i, n) repd(i, 0, n)
typedef long long ll;

using namespace std;

template <typename T> void output(T, int);
int gcd(int a, int b);

int main() {
    // source
    int n;
    cin >> n;
    int a[n];
    rep(i, n) { cin >> a[i]; }
    sort(a, a + n);
    int sample[n];

    if (n % 2 == 0) {
        int num = 1;
        rep(i, n / 2) {
            sample[2 * i] = num;
            sample[2 * i + 1] = num;
            num += 2;
        }
    } else {
        sample[0] = 0;
        int num = 2;
        rep(i, (n - 1) / 2) {
            sample[1 + i * 2] = num;
            sample[2 + i * 2] = num;
            num += 2;
        }
    }

    bool judge = true;
    rep(i, n) {
        if (a[i] != sample[i]) {
            judge = false;
            cout << 0 << endl;
            return 0;
        }
    }

    ll ans = 1;
    int loop = n / 2;
    int mod = pow(10, 9) + 7;

    rep(i, loop) {
        ans *= 2;
        if (ans > mod) {
            ans %= mod;
        }
    }

    cout << ans << endl;

    return 0;
}

template <typename T> void output(T a, int precision) {
    if (precision > 0) {
        cout << setprecision(precision) << a << "\n";
    } else {
        cout << a << "\n";
    }
}

template <typename T> T min(T a, T b) {

    if (a < b) {
        return a;
    } else {
        return b;
    }
}

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


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>
using namespace std;
typedef long long ll;
namespace mp = boost::multiprecision;
using Mint = mp::cpp_int;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repi(i,a,b) for(int i = int(a); i < int(b); i++)
#define all(v) v.begin(), v.end()
#define uni(v) v.erase(unique(all(v)), v.end())
#define sort_g(v) sort(all(v), greater<int>())
#define dump(x) cerr << #x << ' ' << '=' << ' ' << x << endl

int main() {
    int K, A, B;
    cin >>  K >> A >> B;

    bool flg = false;
    repi(i, A, B+1) {
        if(i % K == 0) {
            flg = true;
            break;
        }
    }

    cout << (flg ? "OK" : "NG") << endl;
}

Measured memory_bytes: 3596
package main

import (
	"fmt"
)

func main() {

	var N, K, Q int
	fmt.Scanf("%d %d %d", &N, &K, &Q)

	point := make(map[int]int, N)

	var A int
	for i := 0; i < Q; i++ {
		fmt.Scanf("%d", &A)
		point[A]++
	}

	for i := 0; i < N; i++ {
		if (K + point[i+1] - Q) > 0 {
			fmt.Println("Yes")
		} else {
			fmt.Println("No")
		}
	}
}


Measured memory_bytes: 7244
#include <stdio.h>
#define min(a,b) (((a)<(b))?(a):(b))
#define max(a,b) (((a)>(b))?(a):(b))

int main() {
	long long int a, b, i;
	int k;
	scanf("%lld%lld%d", &a, &b, &k);
	for (i = a; i < min(a + k, b + 1); i++)
	{
		printf("%lld\n", i);
	}
	for (i = max(b - k + 1, a + k); i <= b; i++)
	{
		printf("%lld\n", i);
	}
	return 0;
}

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

ll N, M;
const int MAX_M = 1.0e5 + 100;
pair<ll, ll> AB[MAX_M];
priority_queue<ll> pq;

int main() {
    cin >> N >> M;
    for (int i = 0; i < N; i++) {
        ll a, b;
        cin >> a >> b;
        AB[i] = make_pair(a, b);
    }

    sort(AB, AB+N);

    ll ans = 0;
    int i = 0;
    for (int j = 1; j <= M; j++) {
        while(i < N && AB[i].first == j) {
            pq.push(AB[i].second);
            i++;
        }
        if (!pq.empty()) {
            ans += pq.top();
            pq.pop();
        }
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 2936
//?????§??????????£???????????????¶?????????????????¨?????§??¨????£???§???????????¨????????????.
//?????????????????°??????????????¢??°????????????????????????????????????#N - #E + #F = 2, #F <= #N - 1 (????§???¢??????????????´???????????§)
//??????, #E = #2N - 3????????????. ?????£???, M ??? 2 * N - 3??¨??????, ???????????????????????¨???????????£??????
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <cstdio>
#include <cmath>
using namespace std;

struct Edge {
	int src, dst;
	double cost;
	Edge() {
	}
	Edge(int s, int d, double c) {
		src = s; dst = d; cost = c;
	}
	bool operator>(const Edge &r) const {
		return cost > r.cost;
	}
};

class UF {
	int par[10000];
public:
	UF() { for (int i = 0; i < 10000; i++) par[i] = i; }
	int root(int x) { if (par[x] == x) return x; return par[x] = root(par[x]); }
	void marge(int x, int y) { x = root(x); y = root(y); par[x] = y; }
	bool isSame(int x, int y) { return root(x) == root(y); }
};

int n, m;
int x[10000], y[10000];
vector<Edge> edges;
UF uf;

int main() {
	int i;
	
	cin >> n >> m;
	for (i = 0; i < n; i++) cin >> x[i] >> y[i];
	
	double sumCost = 0;
	for (i = 0; i < m; i++) {
		int p, q;
		double c;
		cin >> p >> q; p--; q--;
		c = (x[p] - x[q]) * (x[p] - x[q]) + (y[p] - y[q]) * (y[p] - y[q]);
		c = sqrt(c);
		edges.push_back(Edge(p, q, c));
		sumCost += c;
	}
	sort(edges.begin(), edges.end(), greater<Edge>());
	
	double treeCost = 0;
	for (i = 0; i < edges.size(); i++) {
		int s = edges[i].src;
		int d = edges[i].dst;
		if (!uf.isSame(s, d)) {
			uf.marge(s, d);
			treeCost += edges[i].cost;
		}
	}
	
	printf("%.14f\n", sumCost - treeCost);
	return 0;
}

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

int main(){
	int a,b;
	int ca=0;
	double cb=0;
	int i=0;
	while(scanf("%d,%d",&a,&b)!=EOF){
		ca+=a*b;
		cb+=b;
		i++;
		}
		double cc=cb/i;
		double cd=round(cc);
		cout<<ca<<endl<<cd<<endl;
		return 0;
	}

Measured memory_bytes: 3420
x = int(input())

if 400 <= x <= 599:
    print(8)
elif 600 <= x <= 799:
    print(7)
elif 800 <= x <= 999:
    print(6)
elif 1000 <= x <= 1199:
    print(5)
elif 1200 <= x <= 1399:
    print(4)
elif 1400 <= x <= 1599:
    print(3)    
elif 1600 <= x <= 1799:
    print(2)
else:
    print(1)

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

int main(){
  int H,W,h,w;
  cin>>H>>W>>h>>w;
  int ans=H*W-(h*W+H*w)+h*w;
  if(ans<0)
    cout<<0<<endl;
  else
    cout<<ans<<endl;
}


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

#define _CRT_SECURE_NO_WARNINGS

int main(int argc, char const *argv[]){
	char s1[12],s2[12],s3[12];
	scanf("%s %s %s",s1,s2,s3);
	printf("%c%c%c\n", (s1[0] - 0x20),(s2[0] - 0x20),(s3[0] - 0x20));
	return 0;
}


Measured memory_bytes: 128
import java.util.Scanner;

public class Main {

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

		int ans = (int) Math.ceil((double) N / (double) (2*D + 1));
		System.out.println(ans);
	}
}


Measured memory_bytes: 21844
/*
オーダー
10**6	余裕を持って間に合う	
10**7	おそらく間に合う	余裕を持って間に合う
10**8	非常にシンプルな処理でない限り厳しい	おそらく間に合う
10**9		非常にシンプルな処理でない限り厳しい
logn	:OK
n		:10^7
nlogn	:10^6
n**2	:10^4
n**3	:300
2**n	:20
n!		:10



// 各桁の和を計算する関数
int findSumOfDigits(int n) {
  int sum = 0;
  while (n > 0) { // n が 0 になるまで
    sum += n % 10;
    n /= 10;
  }
  return sum;
}

sort(a, a + N, greater<int>());  // a[0:N] を大きい順にソート

int num[110] = {0};  // バケット
for (int i = 0; i < N; ++i) {
    num[d[i]]++;  // d[i] が 1 個増える
}

map<string, int> mp; // 連想配列 map<キー型, 値型> オブジェクト名
for (int i = 0; i < N; ++i) {
    auto itr = mp.find(s[i]);        // s[i] が設定されているか？
    if(itr != mp.end() ) {
         mp[s[i]] += 1;
    }
    else {
         mp[s[i]] += 1 ;
    }
}
stack<int> s;	//intをデータとするスタックを用意
s.push(1);		//{} -> {1}
printf("%d\n", s.top());	// 3
s.pop();

queue<int> que;	//intをデータとするキューを用意
que.push(1);		//{} -> {1}
printf("%d\n", que.front());	// 1
que.pop();
*/

#include <iostream>
#include <set>
#include <map>
#include <string>
#include <math.h>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <bitset>
#include <string.h>

using namespace std;

// #define for(i,a,b) for (int i=(a);i<(b);++i)
typedef long long ll;
typedef pair<ll,ll> P;
#define REP(i,n) for(long long i = 0; i < (long long)(n); i++)
#define pb push_back // vectorに要素追加
#define INF (ll)1e18
// int 
// // 各桁の和を計算する関数
// int findSumOfDigits(int n) {
//   int amari = 0;
//   int keta = 0;
//   while (n > 0) { // n が 0 になるまで
//     amari += n % 2;
//     if (keta%2==0)
//     n /= 10;
//   }
//   return sum;
// }
 
ll gcd(ll a, ll b) {
	if(b == 0) return a;
	return gcd(b, a % b);
}

// const ll MAX_N = 1e5;
// ll N;
// ll h[MAX_N];
// ll dp[MAX_N+1]; // メモ化テーブル
 
// // i番目以降の品物から重さの総和がj以下になるように選ぶ
// void rec(ll i){
// 	if (i==0) dp[i] = 0;
// 	else if (i==1) dp[i] = abs(h[1]-h[0]);
// 	else dp[i] = min(dp[i-1]+abs(h[i]-h[i-1]), dp[i-2]+abs(h[i]-h[i-2]));
// 	return;
// }
 
 
int main() {
	// 入力
	ll N;
	cin >> N;
	string S[N];
	REP(i,N)cin>>S[i];
	string abc = "abcdefghijklmnopqrstuvwxyz";

	// 解法
	string S2[N];
	REP(i,N){
		ll tmp[26] = {0};
		REP(j,S[i].size()){
			REP(k,26){
				if (S[i][j]==abc[k]) tmp[k]++;
			}
		}
		string s_tmp;
		REP(j,26){
			s_tmp += abc[j]*tmp[j];
		}
		// cout<<s_tmp<<endl;
		S2[i] = s_tmp;
	}
	sort(S2, S2+N);
	// REP(i,N) cout<<S2[i]<<endl;
	ll tmp = 1;
	ll ans = 0;
	REP(i,N-1){
		if (i==N-2 & S2[i]==S2[i+1]) ans += tmp*(tmp+1)/2;
		else if (i==N-2) ans += tmp*(tmp-1)/2;
		else if (S2[i]!=S2[i+1]){
			ans += tmp*(tmp-1)/2;
			tmp = 1;
		}
		else tmp++;
		// printf("%lld\n", tmp);
	}
	cout<<ans<<endl;
}


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

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;}

int main(){
    string s;
    cin >> s;
    if(s[2]==s[3]&&s[4]==s[5]){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }

    return 0;
}  

Measured memory_bytes: 256
#include<bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;


int N;
int table_index;
int table[362880][9];
int tmp_array[9];
bool used[10];
map<ll,int> MAP;

void recursive(int index){

	if(index == N){

		ll num = 0;

		for(int i = 0; i < N; i++){
			table[table_index][i] = tmp_array[i];
			num = 10*num+tmp_array[i];
		}

		MAP[num] = table_index++;
		return;
	}

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

		if(used[i])continue;
		tmp_array[index] = i;
		used[i] = true;
		recursive(index+1);
		used[i] = false;
	}
}

void output(int index){

	printf("%d",table[index][0]);
	for(int i = 1; i < N; i++){
		printf(" %d",table[index][i]);
	}
	printf("\n");
}


int main(){

	scanf("%d",&N);

	int tmp;

	if(N == 1){

		scanf("%d",&tmp);

		printf("1\n");
		return 0;
	}

	table_index = 0;

	for(int i = 1; i <= N; i++)used[i] = false;

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

		tmp_array[0] = i;
		used[i] = true;
		recursive(1);

		used[i] = false;
	}

	ll num = 0;
	for(int i = 0; i < N; i++){
		scanf("%d",&tmp);
		num = 10*num+tmp;
	}

	int index = MAP[num];

	if(index > 0){
		output(index-1);
	}
	output(index);
	if(index < table_index-1){
		output(index+1);
	}

	return 0;
}



Measured memory_bytes: 38584
process.stdin.resume();
process.stdin.setEncoding('utf8');

process.stdin.on('data', function (chunk) {
	var numbers = chunk.toString().split(' ');
	var sx = parseInt(numbers[0]);
	var sy = parseInt(numbers[1]);
	var tx = parseInt(numbers[2]);
	var ty = parseInt(numbers[3]);
	
	var A = tx - sx;
	var B = ty - sy;

	function concatN (c, N) {
		var ret = "";
		for (var i=0; i < N; i++)
		    ret = ret + c;
		return ret;
	}
	
	var ans = concatN("R", A);
	ans = ans + concatN("U",B);
	
	ans = ans + concatN("L",A);
	ans = ans + concatN("D",B);
	
	ans = ans + "D" + concatN("R",A+1);
	ans = ans + concatN("U",B+1) + "L";
	
	ans = ans + "U" + concatN("L",A+1);
	ans = ans + concatN("D",B+1) + "R";
	
	console.log(ans);
	
	process.exit();
});

Measured memory_bytes: 21192
import java.util.*;

class Main {
  public static void main(String[] a) {
    Scanner scan = new Scanner(System.in);
    int i = Integer.valueOf(scan.nextLine());
    int h = i / 3600;
    int m = i % 3600 / 60;
    int s = i % 60;
    System.out.printf("%d:%d:%d\n",h,m,s);
    
  }   
}



Measured memory_bytes: 26204
/*
Though leaves are many, the root is one;
Through all the lying days of my youth
I swayed my leaves and flowers in the sun,
Now may I wither into the truth.

- William Butler Yeats
*/
#include <iostream>
#include <algorithm>
#include <math.h>
#include <string.h>
#include <cstdio>
#include <vector>
#include <set>
#include <cassert>
#include <cstdlib>
#include <complex>
#include <cctype>
#include <cmath>
#include <ctime>
#include <deque>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <sstream>
#include <functional>
#include <iomanip>
#include <bitset>
//#include <windows.h>  //Should be deleted when using AtCoder&POJ
using namespace std;

#define ll long long
#define pii pair<int,int>
#define qi ios::sync_with_stdio(0)
/**==Info==
*Program:3
*Problem:Strings of Eternity
*Date:2019-7-28
*Algorithm:My KMP that is still WA
*Status:Unknown*/

bool debug=false;

string a,b,sa;

const int sz=3000005;

bool found[sz];


int fail[sz];

void build(string& model){
	int j=-1;
	fail[0]=-1;
	for(int i=1;i<=model.size();i++){
		while(j>=0 && model[j]!=model[i-1]){
			j=fail[j];
		}
		
		j++;
		fail[i]=j;
	}
}

void match(string& str,string& model){
	build(model);
	
	int j=0;
	for(int i=0;i<str.size();i++){
		while(j>=0 && str[i]!=model[j]){
			j=fail[j];
		}
		
		j++;
		if(j==model.size()){
			
			found[i-int(model.size())+1]=true;
			
//			cout<<i-model.size()+2<<endl;
		}
	}
}




int visit[sz]; //0=unvisit 1=visiting 2=visited

int dp[sz];

inline int dfs(int pos){
	if(found[pos]==0){
		return 0;
	}
	if(visit[pos]==1){
		cout<<"-1";
		exit(0);
	}
	if(dp[pos]!=-1){
		return dp[pos];
	}
	
	visit[pos]=1;
	
	int ans=dfs((pos+b.size())%sa.size());
	
	visit[pos]=2;
	return dp[pos]=ans+1;
}

char tmp1[500005],tmp2[500005];

int main(int argc,char* argv[]){
	
	scanf("%s%s",tmp1,tmp2);
	
	sa=tmp1;
	b=tmp2;
	
	a="";
	while(a.size()<b.size()+sa.size()){
		a+=sa;
	}
	
//	return 0;
	match(a,b);
	
//	return 0;
	memset(dp,-1,sizeof(dp));
	
	int ans=0;
	for(int i=0;i<sa.size();i++){
		if(!visit[i]){
			ans=max(ans,dfs(i));
		}
		
	}
	
	printf("%d",ans);
	return 0;
}



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

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

  stack<char> list;

  int places = 1;
  ll cum = 0;

  while (cum < n) {
    cum += pow(26, places);
    places++;
  }
  places--;

  rep(i, places) {
    int rem = (n - 1) % 26;
    n = (n - 1) / 26;
    char c = 'a' + rem;
    list.push(c);
  }

  while (list.size() > 0) {
    cout << list.top();
    list.pop();
  }

  return 0;
}


Measured memory_bytes: 4104
#include<bits/stdc++.h>
using namespace std;
 
int main(){
	 int n,m,p,x,sum=0,t[200];
     scanf("%d",&n);
    for(int i = 0; i < n; i++)
    {
        scanf("%d",&t[i]);
        sum += t[i];
    }
    scanf("%d",&m);
    for(int i = 0; i < m; i++)
    {
        scanf("%d %d",&p,&x);
        printf("%d\n",sum-t[p-1]+x);
    }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define _ ios_base::sync_with_stdio(0);cin.tie(0);
#define REP(i,n) for(int i=0;i<(int)(n);i++)

using namespace std;
using ll=long long;
const ll MOD=1000000007LL;

int N,M;
ll a[1010];
ll b[1010];

ll perm(ll n,ll k){
  ll result=1LL;
  for(ll i=0LL;i<k;i++){
    result*=n-i;
    result%=MOD;
  }
  return result;
}

ll solve(){
  sort(a+1,a+N+1);
  sort(b+1,b+M+1);
  if(a[N]!=N*M || b[M]!=N*M) return 0;
  for(int n=2;n<=N;n++) if(a[n-1]==a[n]) return 0;
  for(int m=2;m<=M;m++) if(b[m-1]==b[m]) return 0;

  ll result=1;
  {
    int n=1,m=1;
    ll k,used=0;
    while(n<N||m<M){
      if(a[n]==b[m]){
	k=(N-n)+(M-m)+1;
	//cout<<a[n]<<" "<<b[m]<<" "<<used<<" "<<k<<endl;
	//result*=1;
	//result%=MOD;
	used++;
	k--;
	if(a[n]-used<k)return 0;
	result*=perm(a[n]-used,k);
	result%=MOD;
	used+=k;
	n++;m++;
      }else if(a[n]<b[m]){
	k=M-m+1;
	//cout<<a[n]<<" "<<b[m]<<" "<<used<<" "<<k<<endl;
	result*=k;
	result%=MOD;
	used++;
	k--;
	if(a[n]-used<k)return 0;
	result*=perm(a[n]-used,k);
	result%=MOD;
	used+=k;
	n++;
      }else{//a[n]>b[m]
	k=N-n+1;
	//cout<<a[n]<<" "<<b[m]<<" "<<used<<" "<<k<<endl;
	result*=k;
	result%=MOD;
	used++;
	k--;
	if(b[m]-used<k)return 0;
	result*=perm(b[m]-used,k);
	result%=MOD;
	used+=k;
	m++;
      }
      //cout<<result<<endl;
    }
  }

  return result;
}

int main(){ _;
  cin>>N>>M;
  REP(n,N)cin>>a[n+1];
  REP(m,M)cin>>b[m+1];
  cout<<solve()<<endl;
}


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


int main() {
int H,W;
cin >> H >> W;
int d[H][W];
char maze[H][W];
int dx[4] = {1,0,-1,0};
int dy[4] = {0,1,0,-1};

for(int i = 0;i<H;i++){
    for(int j = 0;j<W;j++){
        cin >> maze[i][j];
    }
}
for(int i = 0;i<H;i++){
    for(int j = 0;j<W;j++){
        d[i][j] = -1;
    }
}
queue<P> que;//黒マスの座標を全てqueにぶっこむ
//追加された順が早い黒マスから順に、BFSがなされる
for(int i = 0;i<H;i++){
    for(int j = 0;j<W;j++){
        if(maze[i][j] == '#'){
        d[i][j] = 0;//黒マスの距離を0に
        que.push(P(i,j));
        }
    }
}
//BFS
while(que.size()){
    P p = que.front();
    que.pop();
    for(int i = 0;i<4;i++){
      int nx = p.first + dx[i];
      int ny = p.second + dy[i];
      //隣接マスが移動可能でかつ、まだ距離をメモされていないなら距離をメモし、queにぶっこむ
     if(0<=nx && nx < H && 0<=ny && ny < W && maze[nx][ny]=='.' 
       && d[nx][ny] == -1){
      d[nx][ny] = d[p.first][p.second] + 1;
      que.push(P(nx,ny));
       } 
    }
}
int ans  =0;
for(int i = 0;i<H;i++){
    for(int j = 0;j<W;j++){
        ans  = max(ans,d[i][j]);
    }
}
cout << ans << endl;
}

Measured memory_bytes: 13328
import java.io.*;

class Main{
    public static void main(String[] args)throws IOException{
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        while(true){
            String[] line = br.readLine().split(" ");
            int a = Integer.parseInt(line[0]);
            int b = Integer.parseInt(line[2]);
            
            if(line[1].equals("+")) System.out.println(a + b);
                else if(line[1].equals("-")) System.out.println(a - b);
                    else if(line[1].equals("*")) System.out.println(a * b);
                        else if(line[1].equals("/")) System.out.println(a / b);
                            else break;
        }
        
    }
}

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

int main(){
    ll x;
    cin >> x;
    int a=0;
    while(x>=500){
        ++a;
        x-=500;
    }
    int b=0;
    while(x>=5){
        ++b;
        x-=5;
    }
    cout << 1000*a + 5*b << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <stack>
#include <math.h>
#include <map>
#include <time.h>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;

#define pb push_back
#define rep(i, a, n) for(int i = (a); i < (n); i++)
#define dep(i, a, n) for(int i = (a); i >= (n); i--)
#define mod (ll)(1e9+7)
#define int ll

__attribute__((constructor))
void initial() {
  cin.tie(0);
  ios::sync_with_stdio(false);
}

signed main() {
  int n;
  string s[10001];
  int ans = 0;
  int fb = 0, la = 0, ry = 0;
  int km = 0;
  cin >> n;
  rep(i, 0, n) {
    cin >> s[i];
    int f = false;
    rep(j, 1, s[i].length()) {
      if(s[i][j - 1] == 'A' && s[i][j] == 'B') ans++;
    }
    if(s[i][0] == 'B' && s[i][s[i].length() - 1] == 'A') {
      ry++;
    }else if(s[i][0] == 'B') fb++;
    else if(s[i][s[i].length() - 1] == 'A') la++;
  }
  if(ry > 1) ans += ry - 1, ry = 1;
  if(ry) {
    if(fb) fb--, ans++;
    if(la) la--, ans++;
  }
  ans += min(la, fb);
  cout << ans << endl;
}


Measured memory_bytes: 768
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Scanner;

public class Main {
    public static void main(String args[]){
        Scanner scan = new Scanner(System.in);
//        int a = Integer.parseInt(scan.next());
//        int b = Integer.parseInt(scan.next());
        String b = scan.next();
        String ans = null;
        if(Integer.parseInt(b.replaceAll("/",""))>20190430){
            ans = "TBD";
        }else{
            ans = "Heisei";
        }
        PrintWriter out = new PrintWriter(System.out);
        out.println(ans);
        out.flush();
        scan.close();
    }
}

Measured memory_bytes: 23252
import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int N = in.nextInt(), K = in.nextInt();
        int res = 0;
        int left = 0;
        int right = 0;
        int mod = 1000000007;
        for (int i = 0; i < N + 1; i++) {
            left += i;
            left %= mod;
            right += N - i;
            right %= mod;
            if (i + 1 >= K) {
                res += (right - left + 1 + mod) % mod;
                res %= mod;
            }
        }
        System.out.println(res);
    }
}

Measured memory_bytes: 36236
#include<bits/stdc++.h>
using namespace std;
#define ff      first
#define ss      second
#define ll      long long
#define int     long long
#define ull     unsigned long long
#define mod     1000000007
#define vi      vector<ll>
#define ppi     pair<ll,pair<ll,ll>>
#define pb      push_back
#define mp      make_pair
#define str     string
#define pi      2*acos(0.0)
#define pr(a,n) for(int i=0;i<n;i++){cout<<a[i]<<" ";}
#define p(a)    cout<<a;
#define sp(x,y) fixed<<setprecision(y)<<x
#define w(x)    ll x; cin>>x; while(x--)
#define e       cout<<'\n';
#define all(v)  v.begin(), v.end()
#define test    cout<<"LOL_ABHISHEK"<<endl;
void kehsihba() {
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
}
int32_t main() {
	//kehsihba();
	ll sx,sy,tx,ty;
	cin>>sx>>sy>>tx>>ty;
	ll a=tx-sx,b=ty-sy;
	cout<<string(b,'U')<<string(a,'R')<<string(b,'D')<<string(a,'L');
	cout<<'L'<<string(b+1,'U')<<string(a+1,'R')<<'D';
	cout<<'R'<<string(b+1,'D')<<string(a+1,'L')<<'U';
}

Measured memory_bytes: 256
N,M = map(int,input().split())
PYi = []
pmin = float('inf')
for i in range(M):
    p,y = map(int,input().split())
    PYi.append([p,y,i])
    pmin = min(pmin,p)
PYi.sort()
now = pmin
count = 1
for i in range(M):
    p,y,j = PYi[i]
    if now == p:
        PYi[i][1] = count
        count += 1
    else:
        now = p
        PYi[i][1] = 1
        count = 2
PYi.sort(key = lambda x:x[2])
for p,y,i in PYi:
    p = str(p)
    y = str(y)
    print('0'*(6-len(p)) + p + '0'*(6-len(y)) + y)

Measured memory_bytes: 24700
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>

typedef long long ll;

double length(double x1, double y1, double x2, double y2){
    return sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2));
}

double kai(int N){
    if(N==1 || N==0){
        return 1;
    }else{
        return N*kai(N-1);
    }
}

int main(void){
    int N;
    double x[10];
    double y[10];
    double path[10][10];
    double sum;
    double bunbo=1;
    double num;

    scanf("%d", &N);
    int i,j;
    for(i = 0; i < N; i++){
        scanf("%lf %lf", &x[i], &y[i]);
        bunbo*=(i+1);
    }
    for(i=0; i<N;i++){
        for(j=i+1;j<N;j++){
            path[i][j]=length(x[i], y[i], x[j], y[j]);
        }
    }
    num=kai(N-1)*2;
    for(i=0;i<N;i++){
        for(j=i+1;j<N;j++){
            sum+=path[i][j]*num;
        }
    }

    printf("%f", sum/bunbo);
    return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
 
int main(){
  int n;
  long long sum=0,ans=0;
  cin>>n;
  vector<int> p(n);
  map<long long,int> cnt;
  for(int i=0;i<n;i++) cin>>p[i];
  cnt[0]=1;
  for(int i=0;i<n;i++){
      sum+=p[i];
      ans+=cnt[sum];
      cnt[sum]++;
  }
  
  cout<<ans<<endl;
}


Measured memory_bytes: 13568
#include<iostream>
#include<vector>
#include<algorithm>
#include<math.h>
#include<queue>
using namespace std;
typedef long long ll;

const int INF = 1001001001;
const int MOD = 1e9+7;

int main() {
    int n, k; cin >> n >> k;
    string s; cin >> s;
    int score = 0;
    for (int i = 1; i < s.size(); i++)
    {
        if(s[i] == s[i-1]) score++;
    }

    int ans = min(score+k*2, (int)s.size()-1);
    
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 512
x = int(input())

import math

def is_prime(n):
    if n == 1: return False

    for k in range(2, int(math.sqrt(n)) + 1):
        if n % k == 0:
            return False

    return True

for i in range(x, x +1000):
    if is_prime(i) == True:
        print(i)
        break

Measured memory_bytes: 3060
package main

import (
  "fmt"
)

func main() {
  var a, b int
  fmt.Scan(&a, &b)
  if a > b {
    a, b = b, a
  }
  var res int
  if a == b {
    res = a + b
  } else {
    res = b * 2 - 1
  }
  fmt.Println(res)
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
int main()
{
    double i,c=0,p;
    long long int a, n,x=100;

    cin>>n;

         while(x<n)
         {
             x=x+x/100;
             c++;
             //cout<<x<<endl;
         }



    cout<<c<<endl;
}


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

int main() {
    int N;
    cin >> N;
    int count=0;
    for (int i=0; i<N; i++) {
        int p;
        cin >> p;
        if (i+1!=p) count++;
    }
    if (count < 3) cout << "YES" << endl;
    else cout << "NO" << endl;
}

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

int abcd(int n) {
  int sum = 0;
  while (n%2 == 0) { 
    sum ++;
    n /= 2;
  }
  return sum;
}

int main(){
long long int a,b[100010],c;
cin >> a;

  for(int i=0;i<a;i++)
    cin >> b[i];
  
  c =0;
  
  for(int i=0;i<a;i++){
    c += abcd(b[i]);
  }
  
  cout << c << endl;
}

Measured memory_bytes: 384
import sys
from itertools import combinations


def input(): return sys.stdin.readline().strip()


def main():
    N = int(input())
    d = map(int, input().split())
    ans = 0
    for x, y in combinations(d, 2):
        ans += x * y

    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 3064
from collections import deque

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


# candidates of the GCD
total = sum(A)
divisor = []
divisor2 = []
for i in range(1, int(total ** 0.5) + 1):
    if total % i == 0:
        divisor.append(i)
        divisor2.append(total // i)
    if total ** 0.5 == int(total ** 0.5):
        divisor.append(int(total ** 0.5))
divisor2.reverse()
divisor += divisor2

while divisor:
    d = divisor.pop()
    remainder = []
    for i in range(N):
        if A[i] % d != 0:
            remainder.append(A[i] % d)
    remainder.sort()
    remainder = deque(remainder)

    times = 0
    while remainder:
        pre = remainder.popleft()
        times += pre
        remainder[-1] += pre

        while remainder != deque([]) and remainder[-1] >= d:
            post = remainder.pop()
            if remainder != deque([]):
                remainder[-1] += post - d
            else:
                continue
    
    if times <= K:
        print(d)
        exit()
    

Measured memory_bytes: 47580