akhauriyash/Code-Regression huggingface dataset:
#include <iostream>

//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <queue>
#include <bitset>
#include <tuple>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>

using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s)
{
    int v;
    istringstream sin(s);
    sin >> v;
    return v;
}
template <class T>
inline string toString(T x)
{
    ostringstream sout;
    sout << x;
    return sout.str();
}

//math
//-------------------------------------------
template <class T>
inline T sqr(T x) { return x * x; }

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<long long> VL;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i, c) for (auto i = (c).begin(); i != (c).end(); ++i)
#define EXIST(s, e) ((s).find(e) != (s).end())
#define SORT(c) sort((c).begin(), (c).end())

//repetition
//------------------------------------------
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI = acos(-1.0);

//clear memory
#define CLR(a) memset((a), 0, sizeof(a))

//debug
// #define dump(x) cerr << #x << " = " << (x) << endl;
// #define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" \
//                       << " " << __FILE__ << endl;

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

    vector<int> A(N, -1);

    REP(i, N)
    {
        int a;
        cin >> a;
        A[a - 1] = i + 1;
    }

    REP(i, N)
    {
        cout << A[i] << ' ';
    }

    cout << endl;
}

Measured memory_bytes: 1280
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define F first
#define S second
#define pii pair<int, int>
#define eb emplace_back
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep3(i, l, n) for (int i = l; i < (n); ++i)
#define sz(v) (int)v.size()
const int inf = 1e9 + 7;
const ll INF = 1e18;
// int mod = 998244353;
int mod = 1000000007;
#define abs(x) (x >= 0 ? x : -(x))
#define lb(v, x) (int)(lower_bound(all(v), x) - v.begin())
#define ub(v, x) (int)(upper_bound(all(v), x) - v.begin())
template<typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { if (a < b) { a = b; return 1; } return 0; }
ll gcd(ll a, ll b) { if (b == 0) return a; return gcd(b, a % b); }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
ll pow(ll a, int b) { return b ? pow(a * a, b / 2) * (b % 2 ? a : 1) : 1; }
ll modpow(ll a, ll b, ll _mod) { return b ? modpow(a * a % _mod, b / 2, _mod) * (b % 2 ? a : 1) % _mod : 1; }
template<class T> ostream& operator << (ostream& os, const vector<T>& vec) { rep(i, sz(vec)) { if (i) os << " "; os << vec[i]; } return os; }
template<class T, class U> ostream& operator << (ostream& os, const pair<T, U>& p) { os << p.F << " " << p.S; return os; }
template<typename T> inline istream& operator >> (istream& is, vector<T>& v) { rep(j, sz(v)) is >> v[j]; return is; }
template<class T, class T2> inline void add(T &a, T2 b) { a += b; if (a >= mod) a -= mod; }


void solve();

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

  int T;
  // cin >> T;
  T = 1;

  while (T--) {
    solve();
  }
}

void solve() {
  int n;
  cin >> n;
  ll ans = 0;
  rep(i, n) {
    if ((i + 1) % 3 == 0 || (i + 1) % 5 == 0) {

    } else {
      ans += i + 1;
    }
  }
  cout << ans << endl;
}


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

int main(){
    using namespace std;

    int a, b, c = 0;
    cin >> a >> b >> c;
    
    vector<int> vec;
    vec.push_back( a );
    vec.push_back( b );
    vec.push_back( c );

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

    for( unsigned int i = 0; i < vec.size(); ++i ){
        cout << vec[i];
        if( i != vec.size() - 1 ){
            cout << ' ';
        }else{
            cout << endl;
        }
    }
}

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

int main(void)
{
  int n,i,a,b,c;

  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d%d%d",&a,&b,&c);  
    if(a*a==b*b+c*c ||b*b==a*a+c*c || c*c==b*b+a*a)
      printf("YES\n");
    else
      printf("NO\n"); 
  }
  return 0;
}

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

// #define int long long
#define rep(i, n) for (long long i = (long long)(0); i < (long long)(n); ++i)
#define reps(i, n) for (long long i = (long long)(1); i <= (long long)(n); ++i)
#define rrep(i, n) for (long long i = ((long long)(n)-1); i >= 0; i--)
#define rreps(i, n) for (long long i = ((long long)(n)); i > 0; i--)
#define irep(i, m, n) for (long long i = (long long)(m); i < (long long)(n); ++i)
#define ireps(i, m, n) for (long long i = (long long)(m); i <= (long long)(n); ++i)
#define SORT(v, n) sort(v, v + n);
#define REVERSE(v, n) reverse(v, v+n);
#define vsort(v) sort(v.begin(), v.end());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
#define replace_all(s, b, a) replace(s.begin(),s.end(), b, a);
#define PI (acos(-1))
#define FILL(v, n, x) fill(v, v + n, x);
#define sz(x) long long(x.size())

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vs = vector<string>;
using vpll = vector<pair<ll, ll>>;
using vtp = vector<tuple<ll,ll,ll>>;
using vb = vector<bool>;

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 ll INF = 1e9+10;
const ll MOD = 1e9+7;
const ll LINF = 1e18;



signed main()
{
  cin.tie( 0 ); ios::sync_with_stdio( false );
  
  string s; cin>>s;
  ll n=s.size();
  vll a(n+1);
  
  rep(i,n){
    if(s[i]=='<') a[i+1]=a[i]+1;
  }
  
  for(ll i=n-1; i>=0; i--){
    if(s[i]=='>') chmax(a[i], a[i+1]+1);
  }
  
  // rep(i,n) cout<<a[i]<<' ';
  // cout<<endl;
  
  ll ans=0;
  rep(i,n+1) ans+=a[i];
  cout<<ans<<endl;
}

Measured memory_bytes: 7700
#include<stdio.h>

int main() {
	int n, m, i;
	scanf("%d %d", &n, &m);
	int a[m];
	for (i = 0; i < m; i++) {
		scanf("%d", &a[i]);
	}
	for (i = 0; i < m; i++) {
		n -= a[i];
	}
	if (n >= 0)  printf("%d", n);
	else printf("-1");
}

Measured memory_bytes: 1724
#include<bits/stdc++.h>
using namespace std;
#define mod 1000000007
#define pie 3.142857143
#define ll long long int
#define fr(i,a,n) for(ll i=a;i<n;i++)
#define vi vector<int>
#define vlli vector<ll>
#define pb push_back
#define ppb pop_back
#define mp make_pair
#define fv(i,a) for(auto i:a)
#define sz(a) int((a).size())
#define all(c) (c).begin(),(c).end()
#define frv(i,c) for(auto i = c.begin(); i != c.end(); i++)

void solve()
{
	ll x, y, t;
	cin >> x >> y;
	t = (4 * x ) - y;
	if (t >= 0 && t % 2 == 0 && y > 1 && (t / 2) <= x)
		cout << "Yes\n";
	else

		cout << "No\n";
}


int main() {
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen ("output.txt", "w", stdout);
#endif
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int t;
	//cin>>t;
	t = 1;
	while (t--)
	{
		solve();
	}


	return 0;
}

Measured memory_bytes: 3652
N = int(input())						# 5

C=[0]
S=[0]
F=[0]
for i in range(N-1):
	c, s, f = map(int, input().split())		# 5 7 2
	C.append(c)
	S.append(s)
	F.append(f)

#print("C", C)
#print("S", S)
#print("F", F)

ans=[0]*(N+1)





# n駅からn+1駅へ移動した時の到着時刻
def nextArrive(n, iArrive, C,S,F):
	iAns = 0
	if iArrive < S[n]:
		#⇒まだ
		iAns = S[n] + C[n]
		#print("A", n, iAns, S[n], C[n])
	else:
		#⇒順次運行中
		iOver = iArrive % F[n]
		if iOver == 0:
			iAns = iArrive + C[n]
		else:
			iAns = iArrive + (F[n] - iOver) + C[n]
		#print("B", n, iArrive, iWait, C[n], iAns)
	
	return iAns

iArrive=0
for i in range(1, N):
	iArrive = S[i]
	for n in range(i, N):
		iArrive = nextArrive(n, iArrive, C,S,F)

	ans[i] = iArrive






#print(ans)

for i in range(1,N+1):
	print(ans[i])


Measured memory_bytes: 3188
#include <iostream>
#include<string.h>
#include<algorithm>
#include<string.h>
#include<stdio.h>
#include<map>
#include<set>
#include<queue>
#include<vector>
#include<cmath>
#define ll long long
#define eps 1e-8
using namespace std;
int main()
{
    int n;
    cin>>n;
    if(n%10==9||n/10==9)
        cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}

Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
#include<algorithm>//next_permutation
#define rep(i,n) for (int i = 0;i < (n);i++)
#define all(v) v.begin(),v.end()
#define dec(n) cout << fixed << setprecision(n);
#define large "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
#define small "abcdefghijklmnopqrstuvwxyz"
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using vl = vector<ll>;
using vvl = vector<vl>;

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

const ll MOD = 1000000007;
const ll MAX = 2000001;

ll mod(ll a){
  return a % MOD;
}

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

ll fac[MAX], finv[MAX], inv[MAX];

void nCrprep() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (ll i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

ll nCr(ll n, ll r){
    if (n < r) return 0;
    if (n < 0 || r < 0) return 0;
    return fac[n] * (finv[r] * finv[n - r] % MOD) % MOD;
}

ll nCrcheep(ll n,ll r){
  if(r == 0) return 1;
  else if(r == 1) return n;
  else return nCrcheep(n-1,r-1)*n/r;
}

vector<pair<ll,ll>> prime_factorize(ll n){
  vector<pair<ll,ll>> res;
  
  for(ll i=2; i*i <= n; i++){
    if(n % i != 0) continue;
    
    ll ex = 0;
    while(n % i == 0){
      ex++;
      n /= i;
    }
    
    res.push_back({i,ex});
  }
  
  if(n != 1) res.push_back({n,1});
  
  return res;
  
}




int main(){
  string s; cin >> s; vl infant(s.size());
  
  ll rcnt = 1; ll lcnt = 0;
  ll r = 0; ll l = 0;
  
  rep(i,ll(s.size()-1)){
    char a = s[i]; char b = s[i+1];
    
    if(a == b){
      if(a == 'R') rcnt++;
      else lcnt++;
    }
    else{
      if(a == 'R'){
        r = i; l = i+1; lcnt++;
      }
      else{
        infant[r] = (rcnt+1)/2 + lcnt/2;
        infant[l] = (lcnt+1)/2 + rcnt/2;
        
        rcnt = 1; lcnt = 0;
      }
    }
    
    if(i == s.size()-2){
      infant[r] = (rcnt+1)/2 + lcnt/2;
      infant[l] = (lcnt+1)/2 + rcnt/2;
    }
  }
  
  for(ll x : infant){
    cout << x << ' ';
  }
  
  cout << endl;
  
}

Measured memory_bytes: 4328
#include<iostream>

using namespace std;

int main(){ 
    long long int No;
    long long int A;
    long long int B;
    cin>> No>>A>>B;
    long long int wholesec;
    wholesec = (No/(A+B))*A;
    long long int remains;
    remains = No%(A+B);
    if(remains>A){
        wholesec += A;
      cout<< wholesec;
    }
    else{
        wholesec += remains;
      cout<< wholesec;
    }
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}


template <typename T,typename E>
struct SegmentTree{
  using F = function<T(T,T)>;
  using G = function<T(T,E)>;
  Int n;
  F f;
  G g;
  T ti;
  vector<T> dat;
  SegmentTree(){};
  SegmentTree(F f,G g,T ti):f(f),g(g),ti(ti){}

  void init(Int n_){    
    n=1;
    while(n<n_) n<<=1;
    dat.assign(n<<1,ti);
  }
  void build(const vector<T> &v){
    Int n_=v.size();
    init(n_);
    for(Int i=0;i<n_;i++) dat[n+i]=v[i];
    for(Int i=n-1;i;i--)
      dat[i]=f(dat[(i<<1)|0],dat[(i<<1)|1]);
  }
  void update(Int k,E a){
    k+=n;
    dat[k]=g(dat[k],a);
    while(k>>=1)
      dat[k]=f(dat[(k<<1)|0],dat[(k<<1)|1]);
  }
  void set_val(Int k,T x){
    dat[k+=n]=x;
    while(k>>=1)
      dat[k]=f(dat[(k<<1)|0],dat[(k<<1)|1]);    
  }
  T query(Int a,Int b){
    T vl=ti,vr=ti;
    for(Int l=a+n,r=b+n;l<r;l>>=1,r>>=1) {
      if(l&1) vl=f(vl,dat[l++]);
      if(r&1) vr=f(dat[--r],vr);
    }
    return f(vl,vr);
  }
  template<typename C>
  Int find(Int a,Int b,C &check,Int k,Int l,Int r){
    if(!check(dat[k])||r<=a||b<=l) return -1;
    if(k>=n) return k-n;
    Int m=(l+r)>>1;
    Int vl=find(a,b,check,(k<<1)|0,l,m);
    if(~vl) return vl;
    return find(a,b,check,(k<<1)|1,m,r);
  }
  template<typename C>
  Int find(Int a,Int b,C &check){
    return find(a,b,check,1,0,n);
  }
};


struct FastIO{
  FastIO(){
    cin.tie(0);
    ios::sync_with_stdio(0);
  }
}fastio_beet;

//INSERT ABOVE HERE
signed main(){
  Int n;
  cin>>n;
  vector<Int> h(n),a(n);
  for(Int i=0;i<n;i++) cin>>h[i];
  for(Int i=0;i<n;i++) cin>>a[i];

  auto f=[](Int a,Int b){return max(a,b);};
  SegmentTree<Int, Int> seg(f,f,0);
  seg.build(vector<Int>(n+1,0));

  for(Int i=0;i<n;i++){
    Int x=seg.query(0,h[i]);
    seg.update(h[i],x+a[i]);
  }
  
  cout<<seg.query(0,n+1)<<endl;
  return 0;
}


Measured memory_bytes: 9088
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<ll,ll> l_l;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
const int INF=1001001000;
const int mINF=-1001001000;
const ll LINF=1010010010010010000;
template<class T> inline bool chmin(T& a, T b) {
if (a > b) {
a = b;
return true;
}
return false;
}
template<class T> inline bool chmax(T& a, T b) {
if (a < b) {
a = b;
return true;
}
return false;
}
//グリッド：（典型）dp,dfs,bfs,最短経路,その他
const int mod = 1000000007;
struct mint {
ll x;
mint(ll x=0):x((x%mod+mod)%mod){}
mint operator-() const { return mint(-x);}
mint& operator+=(const mint a) {
if ((x += a.x) >= mod) x -= mod;
return *this;
}
mint& operator-=(const mint a) {
if ((x += mod-a.x) >= mod) x -= mod;
return *this;
}
mint& operator*=(const mint a) {
(x *= a.x) %= mod;
return *this;
}
mint operator+(const mint a) const {
mint res(*this);
return res+=a;
}
mint operator-(const mint a) const {
mint res(*this);
return res-=a;
}
mint operator*(const mint a) const {
mint res(*this);
return res*=a;
}
mint pow(ll t) const {
if (!t) return 1;
mint a = pow(t>>1);
a *= a;
if (t&1) a *= *this;
return a;
}
mint inv() const {
return pow(mod-2);
}
mint& operator/=(const mint a) {
return (*this) *= a.inv();
}
mint operator/(const mint a) const {
mint res(*this);
return res/=a;
}
};
int n;
ll a[30][30];
ll bitcnt[1<<21];
mint dp[1<<21];
int main(){
    cin >> n;
    rep(i,n){
        rep(j,n){
            cin >> a[i][j];
        }
    }
    dp[0]=1;
    for(int s=1;s<(1<<n);s++){
        bitcnt[s]=bitcnt[s/2]+s%2;
        for(int l=0;l<n;l++){
            if(!((s>>l)&1)) continue;
            dp[s]+=dp[s-(1<<l)]*a[bitcnt[s]-1][l];
        }
    }
    cout << dp[(1<<n)-1].x << endl;
    return 0;
}

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

using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define MIN(a,b) ((a)>(b)? (b): (a))
#define MAX(a,b) ((a)<(b)? (b): (a))

const long long INF = 1LL << 60;
typedef unsigned long long ll;
const long long MOD = 1000000000 + 7;

int main(){
    ll a;
    double b;
    cin >> a >> b;
    ll nb = b * 1000;
    ll out = a * nb ;
    out /= 1000;
    cout << out << endl;
    return 0;
}

Measured memory_bytes: 3704
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		String S = in.next();
		long K = in.nextLong();
		boolean flag = true;
		int i = 0;
		int k = 0;
		while (flag&&i<S.length()) {
			if (S.charAt(i) == '1') {
				i++;
			} else {
				flag = false;
				k = Integer.parseInt("" + S.charAt(i));
			}
		}
		if (K < i + 1) {
			System.out.println(1);
		} else {
			System.out.println(k);
		}

	}

}

Measured memory_bytes: 23764
S=input()
T=input()
convert = {}
flag=1
for s,t in zip(S,T):
  if s in convert and convert[s]!=t:
    flag=0
    break
  convert[s] = t
after = convert.values()
if len(after)!= len(set(after)):
  flag = 0

print("Yes" if flag else "No")

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

using std::pair;
using std::make_pair;
typedef pair<int, int> Pair;

#define update_max(a, b) if ((a) < (b)) (a) = (b)
#define update_min(a, b) if ((a) > (b)) (a) = (b)

const int N = 200000 + 10;
const int M = N << 2;

#define L(u) ((u) << 1)
#define R(u) ((u) << 1 | 1)

std::vector<int> neighbors[N];
int enter[N], leave[N], nodes[N], size;
int n, q;

int values[M], cover[M];

void push_down(int u) {
  cover[L(u)] += cover[u];
  cover[R(u)] += cover[u];
  values[L(u)] += cover[u];
  values[R(u)] += cover[u];
  cover[u] = 0;
}

void insert(int u, int l, int r, int a, int b, int x) {
  if (b < l || a > r) return;
  if (a <= l && b >= r) {
    cover[u] += x;
    values[u] += x;
  } else {
    push_down(u);
    int m = (l + r) >> 1;
    insert(L(u), l, m, a, b, x);
    insert(R(u), m + 1, r, a, b, x);
  }
}

int query(int u, int l, int r, int x) {
  if (l == r) {
    return values[u];
  }
  push_down(u);
  int m = (l + r) >> 1;
  if (x <= m) {
    return query(L(u), l, m, x);
  }
  return query(R(u), m + 1, r, x);
}


void dfs(int u, int f) {
  size ++;
  enter[u] = size;
  nodes[size] = u;
  for (auto v : neighbors[u]) {
    if (v == f) continue;
    dfs(v, u);
  }
  leave[u] = size;
}

void run(int case_id = 0) {
  std::cin >> n >> q;
  for (int i = 1; i < n; ++ i) {
    int u, v;
    std::cin >> u >> v;
    neighbors[u].push_back(v);
    neighbors[v].push_back(u);
  }
  size = 0;
  dfs(1, -1);

  while (q --) {
    int p, x;
    std::cin >> p >> x;
    insert(1, 1, n, enter[p], leave[p], x);
  }

  for (int i = 1; i <= n; ++ i) {
    std::cout << query(1, 1, n, enter[i]);
    std::cout << (i == n ? "\n" : " ");
  }
}

void multi_cases_main() {
  int num_tests;
  std::cin >> num_tests;
  for (int t = 1; t <= num_tests; ++ t) {
    run(t);
  }
}

int main() {
  std::ios::sync_with_stdio(false);
  run();
  return 0;
}


Measured memory_bytes: 31360
import java.util.*;

public class Main {
    public static int[] dx = new int[]{-1, 0, 0, 1};
    public static int[] dy = new int[]{0, -1, 1, 0};

    static class Node {
        int x, y;
        Node(int x, int y) {
            this.x = x;
            this.y = y;
        }
    }

    private static boolean in(int nx, int ny, int n, int m) {
        return 1 <= nx && nx <= n && 1 <= ny && ny <= m;
    }

    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int n = scan.nextInt();
        int m = scan.nextInt();
        int sc = scan.nextInt();
        int sd = scan.nextInt();
        int ec = scan.nextInt();
        int ed = scan.nextInt();
        int[][] a = new int[n + 1][m + 1];
        for (int i = 1; i <= n; i++) {
            String st = scan.next();
            for (int j = 1; j <= m; j++) {
                char ch = st.charAt(j - 1);
                if (ch == '.') a[i][j] = 0;
                else a[i][j] = 1;
            }
        }
        int[][] vis = new int[n + 1][m + 1];
        int[][] dp = new int[n + 1][m + 1];
        for (int i = 1; i <= n; i++) Arrays.fill(dp[i], -1);
        vis[sc][sd] = 1;
        dp[sc][sd] = 0;
        Deque<Node> Q = new ArrayDeque();
        Q.offer(new Node(sc, sd));
        while (!Q.isEmpty()) {
            Deque<Node> nQ = new ArrayDeque();
            while (!Q.isEmpty()) {
                Node cur = Q.poll();
                nQ.offer(cur);
                for (int i = 0; i < 4; i++) {
                    int nx = cur.x + dx[i];
                    int ny = cur.y + dy[i];
                    if (in(nx, ny, n, m) && vis[nx][ny] == 0 && a[nx][ny] == 0) {
                        vis[nx][ny] = 1;
                        dp[nx][ny] = dp[cur.x][cur.y];
                        Q.offer(new Node(nx, ny));
                    }
                }
            }
            Q = nQ;
            int size = Q.size();
            for (int k = 1; k <= size; k++) {
                Node cur = Q.poll();
                for (int i = cur.x - 2; i <= cur.x + 2; i++) {
                    for (int j = cur.y - 2; j <= cur.y + 2; j++) {
                        if (in(i, j, n, m) && vis[i][j] == 0 && a[i][j] == 0) {
                            vis[i][j] = 1;
                            dp[i][j] = dp[cur.x][cur.y] + 1;
                            Q.offer(new Node(i, j));
                        }
                    }
                }
            }
        }
        System.out.println(dp[ec][ed]);
    }
}


Measured memory_bytes: 73896
#include <bits/stdc++.h>
using namespace std;
int main(){
	int n;
	cin >> n; 
	int sumw=0, sumr=0;
	vector<char> c(n);
	for(int i=0; i<n; ++i){
		cin >> c[i];
		if(c[i]=='W') ++sumw;
		else ++sumr;
	}

	int cnt=0;
	for(int i=0; i<sumr; ++i){
		if(c[i]=='W') ++cnt;
	}

	cout << cnt << endl;
}

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

vector<ll> b(110), a(110);

ll dfs(ll n, ll x){
  if(n == 0){
    if(x <= 0) return 0;
    else return 1;
  } else if(x > a[n - 1] + 1) {
    return b[n - 1] + 1 + dfs(n - 1, x - a[n - 1] - 2);
  } else {
    return dfs(n - 1, x - 1);
  }
}

int main(){
  ll n, x;
  cin >> n >> x;
  b[0] = 1; a[0] = 1;
  for(int i = 1; i <= n; ++i){
    b[i] = (2 * b[i - 1]) + 1;
    a[i] = (2 * a[i - 1]) + 3;
  }
  cout << dfs(n, x) << endl;
}

Measured memory_bytes: 256
import sys
stdin = sys.stdin
sys.setrecursionlimit(10**6)
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
nn = lambda: list(stdin.readline().split())
ns = lambda: stdin.readline().rstrip()

import math

a,b = nn()
c,d = b.split('.')
a,b = int(a),int(c)*100+int(d)

print(a*b//100)


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

using namespace std;
typedef long long ll;

int main() {

  ll N;
  cin >> N;

  ll sum = 0;

  for(ll i=1; i*i<=N; i++){
    if(N%i != 0) continue;
    ll t = N/i;
    t--;
    if(i<t) sum+=t;
  }

  cout << sum;

  return 0;
}


Measured memory_bytes: 256
#include <cstdlib>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <deque>
#include <iomanip>
#include <iostream>
#include <list>
#include <numeric>
#include <sstream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <unordered_set>
#include <unordered_map>

using namespace std;

#define sz(X) ((int)(X).size())
#define pb push_back
#define mp make_pair
#define X first
#define Y second
#define all(X) (X).begin(),(X).end()
#define FOR(i, a, n) for(int i=(a), __ ## i=(n); i<__ ## i; i++)
#define REP(I,N) FOR(I,0,N)
#define PR(X) cout<<#X<<" = "<<(X)<<" "
#define PRL cout<<endl
#define PRV(X) {cout<<#X<<" = {";REP(__prv,sz(X)-1)cout<<(X)[__prv]<<",";if(sz(X))cout<<*(X).end();cout<<"}"<<endl;}

template<class T> ostream &operator<<(ostream &os, const vector<T> &vec)
{
    os << '{';
    REP(i, sz(vec))
    {
        os << vec[i];
        if (i + 1 != sz(vec) )
            os << ',';
    }
    os << '}';
    return os;
}

template<class T1, class T2> ostream &operator<<(ostream &os, const pair<T1, T2> &par)
{
    os << '(' << par.X << ',' << par.Y << ')';
    return os;
}

typedef long long lint;
typedef vector<int> VI;
typedef pair<int, int> PII;

int gcd(int x, int y)
{
    return y ? gcd(y, x % y) : abs(x);
}

template<class T> T sqr(T x)
{
    return x * x;
}

int a[110 * 1000];

int main()
{
//    if (!freopen("1.in", "r", stdin))
//    {
//        cerr << "No input file" << endl;
//        return 1;
//    }
//    if (!freopen("1.out", "w", stdout))
//    {
//        cerr << "Error creating output file" << endl;
//        return 1;
//    }
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    int k = 0;
    lint ans = 1;
    int mod = 1000 * 1000 * 1000 + 7;
    REP(i, n) {
    	int x;
    	cin >> x;
    	int y = (i - k) * 2;
    	if (y >= x) {
    		ans = ans * (i - k + (x == y)) % mod;
    		++k;
    	}
    }
    FOR(i, k, n)
    	ans = ans * (n - i) % mod;
    PRL;
    cout << ans << "\n";
    return 0;
}


Measured memory_bytes: 632
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using p = pair<int, int>;
#define INF 1001001001
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repX(i, n ,x) for (int i = x; i < (int)(n); i++)
#define repBack(i, n) for (int i = n; i >= 0; i--)
#define dup(x,y) (((x)+(y)-1)/(y))

int main() {
    int N,M;
    cin >> N >> M;
    ll sum = 0;
    rep(i,M){
        int a;
        cin >> a;
        sum += a;
    }
    if(N-sum<0)cout << "-1" << endl;
    else cout << N-sum << endl;

    return 0;
}

Measured memory_bytes: 3616
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstring>
#include <deque>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <stdlib.h>
#include <string>
#include <utility>
#include <vector>

#define rep(i, n) for (int i = 0; i < (n); i++)
#define loop(i, x, n) for (int i = (x); i < (n); i++)
#define all(v) (v).begin(), (v).end()
#define int long long
#define INF 1e9
using namespace std;
template<typename T> void cmin(T &a, T b) { a = min(a, b); }
template<typename T> void cmax(T &a, T b) { a = max(a, b); }

signed main() {
  int N, H, W;
  cin >> N >> H >> W;
  vector<int> a(20000, 0), x(N);
  rep(i, N) cin >> x[i];

  rep(i, N) {
    int p, q;
    if ((i + 1) % 2 == 0) {
      p = W * i - x[i];
      q = W * (i + 1) - x[i];
      a[p] += 1;
      a[q] -= 1;
    } else {
      p = W * i + x[i];
      q = W * (i + 1) + x[i];
      a[p] += 1;
      a[q] -= 1;
    }
  }
  rep(i, 20000) a[i + 1] += a[i];

  int cnt = 0;
  rep(i, N * W) if (a[i] == 0) cnt++;
  cout << cnt * H << endl;

  return 0;
}



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

int main (){
    int N;
    cin >> N;
    double Y = 0;
    for (int i =  0; i < N; i++){
        double x;
        string u;
        cin >> x >> u;
        if (u == "JPY"){
            Y += x;
        } else if (u == "BTC"){
            Y += 380000.00000 * x;
        }
    }
    cout << Y << endl;
    return 0;
}



Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
	int t;
	cin>>t;
	for(int u=0;u<t;u++){
	int x,y,w,h;
	cin>>x>>y>>w>>h;
	int n,a,b;
	cin>>n;
	int ans=0;
	for(int i=0;i<n;i++){
		cin>>a>>b;
		if(a>=x&&a<=x+w&&b>=y&&b<=y+h){
			ans++;
		}
	}
	cout<<ans<<endl;
	}
	return 0;
}

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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define RITR(x,c) for(__typeof(c.rbegin()) x=c.rbegin();x!=c.rend();x++)
#define setp(n) fixed << setprecision(n)

#define lf double
#define ll long long
#define vll vector<ll>
#define vi vector<int>
#define pll pair<ll,ll>
#define pi pair<int,int>

#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define ins insert

using namespace std;

int main(void)
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll n, s; cin>>n>>s;
	ll ans=-1;
	ll M;
	for(M=2; M*M<=n; M++){
		ll sum=0, cur=n;
		do{
			sum+=cur%M;
		}while(cur/=M);
		if (sum==s){
			ans = M;
			break;
		}
	}
	M = (ll)sqrt(n-1);
	if (ans<0){
		for(ll i=M; i>=1; i--){
			ll left = n/(i+1)+1;
			ll right = n/i;
			//if (left>right || i*i>=n) continue;
			ll D = n%left - s + i;
			if (D>=0 && D%i == 0 && left+D/i<=right && left+D/i>=2){
				ans = left+D/i;
				break;
			}
		}
	}
	if (ans<0 && s==n){
		ans = s+1;
	}

	cout << ans << "\n";

	return 0;
}

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


int main() {
    #ifndef ONLINE_JUDGE
        //freopen("input.txt", "r", stdin);
        //freopen("output.txt", "w", stdout);
    #endif
    ios_base::sync_with_stdio(false);
    cin.tie(0);

    double n, k;
    double ans = 0;
    cin >> n >> k;
    for(int i=1;i<=n;i++){
        int num = i, cnt=0;
        while(num < k){
            num*=2;
            cnt++;
        }
        ans += (1.0/n)*(double)pow(0.5, cnt);
    }

    cout << fixed << setprecision(12) << ans << '\n';

    return 0;
}


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

int main(void){
  int x,i = 1;
  while (1){
    cin >> x;
    if (x == 0){
      break;
    }
    cout << "Case" << " " << i << ":" <<  " " << x << endl;
    i += 1; 
  }
  return 0;
}


Measured memory_bytes: 3072
#include <iostream>
#include <cstdlib>

int main( void )
{
    std::size_t x;
    std::cin >> x;

    std::size_t N;

    if( (x % 111) == 0 ){
        N = x;
    }
    else{
        N = ( ((std::size_t)(x / 111) + 1) * 111 );
    }

    std::cout << N << std::endl;

    return EXIT_SUCCESS;
}

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

using namespace std;
typedef long long int ll;
typedef pair<ll, ll > pi;  
typedef pair<pair<ll, ll >, ll > pii;  
vector<ll > vec;
vector<vector<ll > > vec2;
ll MOD = 1000000007;
ll INF = 1145141919454519;

int main(){

    string S;
    cin >> S;

    map<char, ll > mp;

    for(ll i = 0; i < S.length(); i++){
        mp[S[i]]++;
    }

    if(mp.size() == S.length()){
        cout << "yes" << endl;
    }else{
        cout << "no" << endl;
    }

}

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

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

	cin >> N >> K;

	vector<int> vec(N, 0);
	vector<int> box(N + 1, 0);
	
	for (int i = 0; i < N; ++i) {
		cin >> vec[i];
	}
		
	for (int i = 0; i < N; ++i) {
		box[vec[i]]++;
	}
	sort(box.begin(), box.end());

	int ans = 0;

	for (int i = 0; i < N + 1; ++i) {
		if (box[i] != 0) {
			int variation = N + 1 - i;
			for (int j = i; j < N + 1; ++j) {
				if (variation <= K)
					break;
				else {
					variation--;
					ans += box[j];
				}
			}
			break;
		}
	}

	cout << ans;
	return 0;
}

Measured memory_bytes: 1792
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

N = int(readline())
A = [int(x) for x in readline().rstrip().split()]
B = [0] * 60
ans = 0
for i in range(N):
    i_bin = list(bin(A[i]))
    i_bin = i_bin[2:]
    i_bin = i_bin[::-1]
    k = 0
    for j in i_bin:
        if j == "1":
            B[k] += 1
        k += 1

for q in range(60):
    temp = B[q] * (N - B[q])
    ans += (temp % (7 + 10 ** 9)) * ((2 ** q) % (7 + 10 ** 9))
    ans %= 7 + 10 ** 9
print(ans)    

Measured memory_bytes: 89712
using System;
class p
{
  static void Main()
  {
    string S = Console.ReadLine();
    
    int start = 0;
    for (int i = 0; i < S.Length; i++) {
      if (S[i] == 'A') {
        start = i;
        break;
      }
    }
    int end = S.Length - 1;
    for (int i = S.Length - 1; 0 <= i; i--) {
      if (S[i] == 'Z') {
        end = i;
        break;
      }
    }
    Console.WriteLine(end - start + 1);
  }
}

Measured memory_bytes: 13144
#include <bits/stdc++.h>
#define ll long long
#define l long
using namespace std;

int main()
{

    l n, d;
    cin >> n >> d;
    l ans = 0;
    while (n--)
    {
        l x, y;
        cin >> x >> y;
        l q = x * x + y * y;
        if (q <= d * d)
            ans++;
    }
    cout << ans << "\n";

    return 0;
}

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

int main(){
  int N,L;cin>>N>>L;
  int sum=0;
  for(int i=1;i<=N;++i) {
    sum+=L+i-1;
  }
  int e=L+N-1;
  int ans=0;
  if (0<=L) {
    cout<<sum-L<<endl;
  }
  else if (e<=0) {
    cout<<sum-e<<endl;
  }
  else {
    cout<<sum<<endl;
  }
}



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

template <typename T>
void print(const T &v);

int main()
{
    int n;
    cin >> n;
    int ans = 0;
    for (int i = 1; i <= n; i += 2)
    {
        int cnt = 0;
        for (int j = 1; j <= i; j++)
        {
            if (i % j == 0)
            {
                cnt++;
            }
        }
        if (cnt == 8)
        {
            ans++;
        }
    }
    cout << ans << endl;
    return 0;
}

// Use For Debug
template <typename T>
void print(T const &v)
{
    for (int i = 0; i < v.size(); i++)
    {
        if (i)
            cout << " ";
        cout << v[i];
    }
    cout << endl;
}

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

int main(){
  int N,take[3];
  cin>>N>>take[0]>>take[1]>>take[2];
  vector<int>l(N);

  for(int i=0;i<N;i++){
    cin>>l[i];
  }
  int ans=1e9;
  for(int i=0;i<(1<<(N*2));i++){
    vector<int> use[3];
    int total[3]={0};
    int mp=0;
    for(int j=0;j<N;j++){
      int tmp=(i>>(2*j))&0b11;
      //cout<<i<<endl;
      if(tmp!=0b11){
        use[tmp].push_back(j);
        total[tmp]+=l[j];
      }
    }
    //cout<<i<<" , "<<total[0]<<endl;
    for(int j=0;j<3;j++){
      if(use[j].size()==0){
        mp+=1e9;
        break;
      }
      mp+=(use[j].size()-1)*10;
      mp+=abs(take[j]-total[j]);

    }
    ans=min(ans,mp);
  }
  cout<<ans<<endl;
  return 0;
}



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

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

int main() {
    int n;cin>>n;
    ll a[n],s[n];
    rep(i,n)cin>>a[i];
    
    s[0]=a[0];
    rep(i,n-1)s[i+1]=s[i]+a[i+1];
    
    ll ans=s[n-1]+100000000000;
    
    for(int i=0;i<n-1;++i){
        ans=min(ans,abs(s[i]-(s[n-1]-s[i])));
    }
    cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 3328
#include <iostream>
#include <string>
#include <vector>
#include <cctype>

using namespace std;

vector<int> g_sets;

struct Result {
        int value, p;
};

#define PARSER_DECL(name) \
        Result name (const string &s, int p)

PARSER_DECL(expr);
PARSER_DECL(factor);

PARSER_DECL(expr){
        Result r = factor(s, p);
        while(isupper(s[r.p])){
                Result q = factor(s, r.p + 1);
                switch(s[r.p]){
                        case 'A': r.value &= q.value; break;
                        case 'O': r.value |= q.value; break;
                        case 'X': r.value ^= q.value; break;
                }
                r.p = q.p;
        }
        return r;
}
PARSER_DECL(factor){
        Result r;
        if(s[p] == '('){
                r = expr(s, p + 1);
                ++r.p;
        }else{
                int index = 0;
                while(isdigit(s[p])){
                        index = (index * 10) + (s[p] - '0');
                        ++p;
                }
                r.value = g_sets[index];
                r.p = p;
        }
        return r;
}

int solve(string &s, const vector<int> &op, int i){
        int answer = 0;
        if(i == op.size()){
                answer = (expr(s, 0).value == 15 ? 1 : 0);
        }else{
                const char OPERATIONS[] = "AOX";
                for(int j = 0; j < 3; ++j){
                        s[op[i]] = OPERATIONS[j];
                        answer += solve(s, op, i + 1);
                }
        }
        return answer;
}

int main(){
        while(true){
                string s;
                getline(cin, s);
                if(s == "END"){ break; }
                vector<int> op;
                for(int i = 0; i < s.size(); ++i){
                        if(s[i] == ' '){ op.push_back(i); }
                }
                int n;
                cin >> n;
                g_sets = vector<int>(n + 1);
                for(int i = 1; i <= n; ++i){
                        int a, b, c, d;
                        cin >> a >> b >> c >> d;
                        g_sets[i] = (a << 3) | (b << 2) | (c << 1) | d;
                }
                cout << solve(s, op, 0) << endl;
                getline(cin, s);
        }
        return 0;
}

Measured memory_bytes: 1240
//teja349
#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> 
//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;
#define f(i,a,b) for(i=a;i<b;i++)
#define rep(i,n) f(i,0,n)
#define fd(i,a,b) for(i=a;i>=b;i--)
#define pb push_back
#define mp make_pair
#define vi vector< int >
#define vl vector< ll >
#define ss second
#define ff first
#define ll long long
#define pii pair< int,int >
#define pll pair< ll,ll >
#define sz(a) a.size()
#define inf (1000*1000*1000+5)
#define all(a) a.begin(),a.end()
#define tri pair<int,pii>
#define vii vector<pii>
#define vll vector<pll>
#define viii vector<tri>
#define mod (1000*1000*1000+7)
#define pqueue priority_queue< int >
#define pdqueue priority_queue< int,vi ,greater< int > >

//std::ios::sync_with_stdio(false);   
int a[123456],dp[123456],rev[123456];
int main(){
    std::ios::sync_with_stdio(false);
    int n;
    cin>>n;
    int i;
    f(i,1,n+1){
    	cin>>a[i];
    }
    f(i,1,n+1){
    	dp[i]=dp[i-1]+abs(a[i]-a[i-1]);
    }
    fd(i,n,1){
    	rev[i]=rev[i+1]+abs(a[i]-a[i+1]);
    }
    f(i,1,n+1){
    	cout<<dp[i-1]+rev[i+1]+abs(a[i+1]-a[i-1])<<endl;
    }
    return 0;  
    
}



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

using namespace std;

int main(){

	int k;
	while(cin >> k && k != 0){
		int sum = 0;
		for(int i = 0; i < k*(k-1)/2; i++){
			int tmp;
			cin >> tmp;
			sum += tmp;
		}
		cout << sum/(k-1) << endl;
	}

	return 0;
}

Measured memory_bytes: 0
N = int(input())

dp = [100000 for _ in range(N + 1)]

dp[0] = 0
for n in range(1, N + 1):
    for num in [6, 9]:
        power = 1
        while power <= n: 
            dp[n] = min(dp[n], dp[n - power] + 1)
            power *= num

print(dp[N])


Measured memory_bytes: 45040
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>

using namespace std;

typedef long long ll;
typedef double db;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<string> vs;
typedef vector<char> vc;
typedef string S;
typedef queue<int> qi;
typedef pair<ll,ll> P;
typedef vector<P> vp;
#define sort(a) sort(a.begin(),a.end())
#define reverse(a) reverse(a.begin(),a.end())
#define pb push_back
#define ft first
#define sd second
#define elif else if
#define unique(a) a.erase(unique(a.begin(),a.end()),a.end())
#define mp make_pair
#define fr(i,n)for(ll i=0;i<(n);i++)
#define ifr(i,n)for(ll i=(n)-1;i>=0;i--)
const int MOD = 1e9+7;
const ll INF =1e18;

int main(){
    int n,k;cin >> n >> k;
    vi x(n),y(n);
    vi xary,yary;
    fr(i,n){
        cin >> x[i] >> y[i];
        xary.pb(x[i]);
        yary.pb(y[i]);
        }
    
    sort(xary);
    sort(yary);
    ll ans = 1LL *(xary[n-1]-xary[0])*(yary[n-1]-yary[0]);

    fr(xi,n){
        for(int xj = xi+1;xj<n;++xj){
            fr(yi,n){
                for(int yj = yi+1;yj<n;++yj){

                    int num = 0;
                    ll lx = xary[xi],rx = xary[xj];
                    ll by = yary[yi],uy = yary[yj];
                    
                    fr(i,n){
                        if(lx <=x[i] and x[i] <= rx and by <= y[i] and y[i] <= uy) num++;
                    }                
                
                if(num >= k) ans = min(ans, 1LL * (rx-lx)*(uy-by));
                }
            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 384
def two_int():
    N, K = map(int, input().split())
    return N,K

def one_int():
    return int(input())

def one_str():
    return input()

def many_int():
    return list(map(int, input().split()))

N,K = two_int()

trees = []
for i in range(N):
    trees.append(one_int())

sort_trees = sorted(trees)

mins = 10**10
for i in range(N-K+1):
    if sort_trees[i+K-1] - sort_trees[i] < mins:
        mins = sort_trees[i+K-1] - sort_trees[i]

print(mins)

Measured memory_bytes: 51160
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//#define P pair<ll,ll>
#define FOR(I,A,B) for(ll I = ll(A); I < ll(B); ++I)
#define FORR(I,A,B) for(ll I = ll((B)-1); I >= ll(A); --I)
#define TO(x,t,f) ((x)?(t):(f))
#define SORT(x) (sort(x.begin(),x.end())) // 0 2 2 3 4 5 8 9
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin()) //xi>=v  x is sorted
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin()) //xi>v  x is sorted
#define NUM(x,v) (POSU(x,v)-POSL(x,v))  //x is sorted
#define REV(x) (reverse(x.begin(),x.end())) //reverse
ll gcd(ll a,ll b){if(a%b==0)return b;return gcd(b,a%b);}
ll lcm(ll a,ll b){ll c=gcd(a,b);return ((a/c)*(b/c)*c);}
#define NEXTP(x) next_permutation(x.begin(),x.end())
const ll INF=ll(1e16)+ll(7);
const ll MOD=1000000007LL;
#define out(a) cout<<fixed<<setprecision((a))
//tie(a,b,c) = make_tuple(10,9,87);
#define pop(a) __builtin_popcount((a))
ll keta(ll a){ll r=0;while(a){a/=10;r++;}return r;}


int main(){
  ll N,A,B;
  cin >> N >> A >> B;
  ll k = N/(A+B);
  ll ans = k*A + min(A,N-k*(A+B));
  cout << ans << endl;
}


Measured memory_bytes: 256
import sys


H, W, M = map(int, input().split())
bomb = [tuple(map(lambda x: int(x) - 1, s.split())) for s in sys.stdin.readlines()]
X = [0] * H  # X:各行の爆破対象の個数
Y = [0] * W  # Y:各列の爆破対象の個数
for h, w in bomb:
    X[h] += 1
    Y[w] += 1
maxX = max(X)
maxY = max(Y)

R = [h for h, x in enumerate(X) if x == maxX]  # R:爆破対象の数が最大となる行の番号
C = [w for w, y in enumerate(Y) if y == maxY]  # C:爆破対象の数が最大となる列の番号

bomb = set(bomb)
for r in R:
    for c in C:
        # (r, c)に爆破対象が存在しないとき, maxX + maxY が答えとなることが確定するため, 
        # 即座に探索を終了する.
        if (r, c) not in bomb:
            print(maxX + maxY)
            exit()
print(maxX + maxY - 1)

Measured memory_bytes: 199596
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i,n) for(int (i)=0;(i)<(n);++(i))
#define FOR(i,a,b) for(int (i)=(a);(i)<(b);++(i))
#define EACH(e,v) for(auto& e:v)
#define ALL(v) (v).begin(),(v).end()
#define SORT(v) sort(ALL(v))
#define RSORT(v) sort((v).rbegin(),(v).rend())
#define PERM(v) SORT(v);for(bool c##p=1;c##p;c##p=next_permutation(ALL(v)))
#define UNIQUE(v) SORT(v);(v).erase(unique(ALL(v)),(v).end())
template<typename A,typename B> inline bool chmax(A &a,const B &b){if(a<b){a=b;return 1;}return 0;}
template<typename A,typename B> inline bool chmin(A &a,const B &b){if(a>b){a=b;return 1;}return 0;}

const int MOD = (int)1e9 + 7;
const int INF = 1 << 30;
const ll INFF = 1LL << 62;

int N;
ll res = -INFF;
vector<int> S;

bool valid(int A, int B) {
    if (A <= 0 || B <= 0) return false;
    if (A <= B) return false;
    int g = __gcd(A, B);
    // A,BをGCDで割ったとき, 差が1じゃないなら大丈夫 (実験したらわかる)
    if (A / g - B / g != 1) return true;
    // mx : 例えば(3,2)のとき, (0,2,4,1,3,5)の順に訪れて, 次はもうどこにも行けない -> ハスが6個以下なら大丈夫
    //      一般化すると, (A,A-1)のとき, ハスが2*A個以下なら大丈夫
    int mx = (A / g + B / g + 1) * g;
    return (N <= mx);
}

signed main() {

    cin >> N;

    S.resize(N);
    REP(i, N) cin >> S[i];

    // d個飛ばしの累積和 : 調和級数でNlogN
    FOR(d, 1, N) {
        vector<ll> acc_front(1, 0), acc_back(1, 0);
        for (int i = d, j = 0; i < N; i += d)
            acc_front.emplace_back(acc_front[j++] + S[i]);
        for (int i = N - 1 - d, j = 0; i >= 0; i -= d)
            acc_back.emplace_back(acc_back[j++] + S[i]);
        int sz = acc_front.size();
        // 累積和からそれぞれ何個取り出すか
        REP(i, sz) {
            int A = N - 1 - d * i;
            int B = A - d;
            if (not valid(A, B)) continue;
            chmax(res, acc_front[i] + acc_back[i]);
        }
    }

    cout << res << endl;

}


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

typedef long long int ll;
typedef unsigned long long int ull;

ll power(ll x,ll y,ll p){ll r=1; x=x%p; while(y){ if(y&1) r= r*x%p; y=y>>1; x=x*x%p; } return r; }
/*  
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;*/

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

int csrand(int l=0, int r=1e9)
{
    uniform_int_distribution<int> uid(l, r);
    return uid(rng);
}

#define PR(x) cout<<#x<<" : "<<x<<"\n";
#define PR1(x,y) cout<<#x<<" : "<<x<<"  |  "<<#y<<" : "<<y<<"\n";
#define PR2(x,y,z) cout<<#x<<" : "<<x<<"  |  "<<#y<<" : "<<y<<"  |  "<<#z<<" : "<<z<<"\n";
#define ED cout<<'\n';

#define IO              ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define FILEIO          freopen("input.txt", "r", stdin);freopen("output.txt", "w", stdout);
#define all(v)          v.begin(),v.end()
#define endl            '\n'
#define fr1(j,n)        for(int j=0;j<n;j++)
#define fr(n)           for(int i=0;i<n;i++)
#define PB              push_back
#define pii             pair<int,int>
#define pll             pair<long long int,long long int>
#define F               first       
#define S               second 
#define mod             1000000007

int mod1=998244353;

const int N=2e5+99;
vector<pll> g[N];
ll dp[N];

const int maxn=2e5+99;
ll tree[4*maxn];

ll merge(ll a,ll b)
{
    ll ret=min(a,b);
    return ret;
}

ll query(int node ,int a,int b,int i,int j)
{
    if(j<a || i>b){ll ret=1e15;return ret;}
    if(a>=i && b<=j) return tree[node];
    return merge ( query(2*node,a,(a+b)/2,i,j), query(1+2*node,1+(a+b)/2,b,i,j) );        
}

void update_tree(int node,int a,int b,int i,ll value)
{
    if(i<a || i>b) return;
    if(a==b){tree[node]=value;   return;}
    update_tree(node*2,a,(a+b)/2,i,value);
    update_tree(1+node*2,1+(a+b)/2,b,i,value);
    tree[node]=merge(tree[node*2],tree[1+node*2]);
}


int32_t main()
{       
    IO

    int n,m;
    cin>>n>>m;

    fr((N<<2)) tree[i]=1e15;

    fr(m)
    {
        ll l,r,c;
        cin>>l>>r>>c;
        g[r].PB({l,c});
    }

    update_tree(1,0,n,0,1e15);
    update_tree(1,0,n,1,0);
    dp[1]=0;
    
    for(int i=2;i<=n;i++)
    {
        dp[i]=1e15;
        for(auto x:g[i])
        {
            dp[i]=min(dp[i],x.S + query(1,0,n,x.F,i-1));
        }
        update_tree(1,0,n,i,dp[i]);
     
    }
    
    if(dp[n]>=1e15)
        dp[n]=-1;
    cout<<dp[n]<<endl;



    


   

}





Measured memory_bytes: 17280
while True:
    n, x = map(int, input().split())
    if n == x == 0:
        break
    ans = 0
    for i in range(1, n+1):
        for j in range(i+1, n+1):
            for k in range(j+1, n+1):
                if k == x-i-j:
                    ans += 1
    print(ans)



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

int main()
{
	int prime_list[50]{2, 3, 5, 7, 11, 13, 17, 19, 23,29,31,37,41,43,47,53,59,61,67,71,73,79,83,89,97};
	long long prime[50]{};
	int n;
	scanf("%d", &n);
	for (int i = 2; i <= n; i++)
	{
		int num{i};
		for (int j = 0; num != 1; j++)
		{
			while (num % prime_list[j] == 0)
			{
				num /= prime_list[j];
				prime[j]++;
			}
		}
	}
	// >= 2, 4, 14, 24, 74
	long long div_list[5]{}, divnum[5]{2, 4, 14, 24, 74};
	for (int i = 0; i < 50; i++)
	{
		for (int j = 0; j < 5; j++)
			if (prime[i] >= divnum[j])
				div_list[j]++;
	}
	printf("%lld\n", div_list[4] + div_list[3] * (div_list[0] - 1)
		+ div_list[2] * (div_list[1] - 1) + div_list[1] * (div_list[1] - 1) / 2 * (div_list[0] - 2));

	return 0;
}

Measured memory_bytes: 256