akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using P = pair<ll,ll>;


void solve(){
    ll N;
    cin >> N;
    vector<P> num;
    ll ans =0;
    for(int i=0;i<N;i++){
        ll K,L,R;
        cin >> K >> L >>R;
        ans += L;
        num.push_back(P(L-R,K));
    }
    // cerr <<"ans=" << ans << endl;
    set<ll> s;
    for(int i=1;i<=N;i++){
        s.insert(-i);
    }
    ll canNotNum =0;
    sort(num.rbegin(),num.rend());
    ll minusIndex =-1;
    for(int i=0;i<N;i++){
        if(num[i].first <0){
            minusIndex = i;
            break;
        }
        auto itr = s.lower_bound(-num[i].second);
        // cerr <<"itr=" << *itr <<endl;
        if(itr == s.end()){
            canNotNum++;
            ans -= num[i].first;
        }else{
            s.erase(itr);
        }
    }
    if(minusIndex <0){
        // cerr <<"minus not found" << endl;
        cout << ans << "\n";
        return;
    }
    // cerr <<"ans=" << ans <<"minusIndex=" <<minusIndex << endl;

    set<ll> minusPlace;
    for(int i=minusIndex;i<N;i++){
        // cerr <<"i=" << i << endl;
        minusPlace.insert(i+1);
    }
    

    for(int i=N-1;i>=minusIndex;--i){
        // cerr <<"minus I=" << i   <<"num[i]="<<num[i].first  << "place=" << num[i].second<<endl;
         auto itr = minusPlace.upper_bound(num[i].second);
        if(itr != minusPlace.end()){
            // cerr <<"*itr =" <<*itr << endl;
            minusPlace.erase(itr);
            ans -= num[i].first;
        }
    }
    cout << ans << "\n";

    return;
}

int main() {
    ll T;
    cin >>T;
    for(int q=0;q<T;q++){
        solve();
    }

    return 0;
}

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

int main()
{
    int N,val,cnt=0,ans=-1,ans1=0;
    cin >> N;

    for(int i=1; i<=N; i++){
        val = i;
        cnt = 0;
        while(1){
            if(val%2 == 0){
                val /= 2;
                cnt++;
            }else{
                break;
            }
        }
        if(cnt > ans){
            ans = cnt;
            ans1 = i;
        }
    }
    cout << ans1 << endl;
    return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize(2)
#include <bits/stdc++.h>
using namespace std;
using LL = long long;
using PII = pair<int,int>;
using PLL = pair<LL, LL>;
const int INF = 1e9;
const int MXN = 0;
const int MXV = 0;
#define MP make_pair
#define PB push_back
#define F first
#define S second
#define FOR(i, L, R) for(int i = L; i != (int)R; ++i)
#define FORD(i, L, R) for(int i = L; i != (int)R; --i)
#define IOS cin.tie(nullptr); cout.tie(nullptr); ios_base::sync_with_stdio(false);

int main()
{
    IOS;
    int n, k, ans = 0;
    cin >> n >> k;
    while(n)
    {
        n /= k;
        ++ans;
    }
    cout << ans << '\n';
}


Measured memory_bytes: 256
#include <stdio.h>
int main(void)
{
    int n;
    scanf("%d", &n);
    int a[100];
    for (int i = 0; i < n; i++)
    {
        scanf("%d", &a[i]);
    }
    if (n >= 1)
        printf("%d", a[n - 1]);
    for (int i = n - 2; i >= 0; i--)
        printf(" %d", a[i]);
    putchar('\n');
    return 0;
}


Measured memory_bytes: 2012
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>

using namespace std;

int n, C, fir, L[7], ord[7];

double F[1 << 5][444][444];

double Solve() {
    memset(F, 0, sizeof F);
    F[0][0][0] = 1;
    for(int s = 0; s < (1 << (n - 1)) - 1; s++)
        for(int i = 0; i < C * n; i++)
            for(int k = 0; k <= i; k++) if(F[s][i][k])
                for(int nxt = 0; nxt < n - 1; nxt++) if(!((s >> nxt) & 1))
                    for(int j = i / n * n + ord[nxt] + (ord[nxt] < i % n) * n; j < C * n; j += n)
                        F[s + (1 << nxt)][j][k >= j - L[nxt] * n ? j : k] += F[s][i][k];
    double ans = 0;
    for(int i = (C - fir) * n; i < C * n; i++)
        for(int j = (C - fir) * n; j <= i; j++)
            ans += F[(1 << (n - 1)) - 1][i][j];
    return ans;
}

int main() {
    scanf("%d%d", &n, &C);
    for(int i = 0; i < n; i++) scanf("%d", &L[i]);
    sort(L, L + n);
    fir = L[n - 1];
    for(int i = 0; i < n - 1; i++) ord[i] = i + 1;
    double ans = 0, tmp = 0;
    do {
        ans += Solve();
    } while(next_permutation(ord, ord + n - 1));
    for(int i = 1; i < n; i++) ans /= i;
    printf("%.15lf\n", ans / pow(C, n - 1));
    return 0;
}


Measured memory_bytes: 49536
def near(x, Y):
    i = bisect_left(Y,x)
    if i == 0:
        return Y[i]-x
    elif i == len(Y):
        return x-Y[i-1]
    else:
        return min(Y[i]-x, x-Y[i-1])

def near2(x, Y):
    i = bisect_left(Y,x)
    if i == 0:
        return Y[i]-x + D[i][1]
    elif i == len(Y):
        return x-Y[i-1] + D[i-1][1]
    else:
        return min(Y[i]-x+D[i][1], x-Y[i-1]+D[i-1][1])

from bisect import *
A, B, Q = map(int, input().split())
S = []
T = []
for _ in range(A):
    S.append(int(input()))
for _ in range(B):
    T.append(int(input()))
D = []
for a in S:
    D.append((a, near(a, T)))
for b in T:
    D.append((b, near(b, S)))
D.sort(key=lambda x:x[0])
D2 = [d for d, _ in D]
for _ in range(Q):
    x = int(input())
    print(near2(x,D2))



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

using namespace std;

typedef long long ll;

#define faster ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0)
#define read freopen("in.txt", "r", stdin)
#define write freopen("out.txt", "w", stdout)
#define mem(x, n) memset(x, n, sizeof(x))
#define all(x) x.begin(), x.end()
#define endl "\n"

int main() {
	faster;

	ll x, k, d, ans = 0;
	cin >> x >> k >> d;
	x = abs(x);
	ll moves = (x/d);

	if(moves > k){
		cout << (x - (k * d)) << endl;
	}else {
		ll res = (x-(moves * d));
		k -= moves;
		if(k % 2 != 0) res -= d;
		cout << abs(res) << endl;
	}

	return 0;
}

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

#define rep(i, n) for (int i = 0; i < int(n); i++)
#define rrep(i, n) for (int i = int(n) - 1; i >= 0; i--)
#define reps(i, n) for (int i = 1; i <= int(n); i++)
#define rreps(i, n) for (int i = int(n); i >= 1; i--)
#define repc(i, n) for (int i = 0; i <= int(n); i++)
#define rrepc(i, n) for (int i = int(n); i >= 0; i--)
#define repi(i, a, b) for (int i = int(a); i < int(b); i++)
#define repic(i, a, b) for (int i = int(a); i <= int(b); i++)
#define each(x, y) for (auto &x : y)
#define all(a) (a).begin(), (a).end()
#define bit(b) (1ll << (b))

using namespace std;

using i32 = int;
using i64 = long long;
using u64 = unsigned long long;
using f80 = long double;
using vi32 = vector<i32>;
using vi64 = vector<i64>;
using vu64 = vector<u64>;
using vf80 = vector<f80>;
using vstr = vector<string>;

inline void yes() { cout << "Yes" << '\n'; exit(0); }
inline void no() { cout << "No" << '\n'; exit(0); }
inline i64 gcd(i64 a, i64 b) { if (min(a, b) == 0) return max(a, b); if (a % b == 0) return b; return gcd(b, a % b); }
inline i64 lcm(i64 a, i64 b) { return a / gcd(a, b) * b; }
inline u64 xorshift() { static u64 x = 88172645463325252ull; x = x ^ (x << 7); return x = x ^ (x >> 9); }
void solve(); int main() { ios::sync_with_stdio(0); cin.tie(0); cout << fixed << setprecision(16); solve(); return 0; }
template <typename T> class pqasc : public priority_queue<T, vector<T>, greater<T>> {};
template <typename T> class pqdesc : public priority_queue<T, vector<T>, less<T>> {};
template <typename T> inline void amax(T &x, T y) { if (x < y) x = y; }
template <typename T> inline void amin(T &x, T y) { if (x > y) x = y; }
template <typename T> inline T power(T x, i64 n, T e = 1) { T r = e; while (n > 0) { if (n & 1) r *= x; x *= x; n >>= 1; } return r; }
template <typename T> istream& operator>>(istream &is, vector<T> &v) { each(x, v) is >> x; return is; }
template <typename T> ostream& operator<<(ostream &os, vector<T> &v) { rep(i, v.size()) { if (i) os << ' '; os << v[i]; } return os; }
template <typename T, typename S> istream& operator>>(istream &is, pair<T, S> &p) { is >> p.first >> p.second; return is; }
template <typename T, typename S> ostream& operator<<(ostream &os, pair<T, S> &p) { os << p.first << ' ' << p.second; return os; }

void solve() {
  int n;
  cin >> n;
  vi64 a(n);
  cin >> a;
  rep(i, n) a[i] *= 2;
  i64 sum = 0;
  rep(i, n) sum += a[i];
  sum /= 2;
  vi64 acc(n + 1);
  rep(i, n) acc[i + 1] += acc[i] + a[i];
  i64 mi = 1e18;
  reps(i, n) amin(mi, abs(acc[i] - sum));
  cout << mi << endl;
}


Measured memory_bytes: 3456
N, K = map(int, input().split())
K = min(N, K)
H =list(map(lambda x: - int(x), input().split()))
#print(H)
import heapq
heapq.heapify(H)
for i in range(K):
  heapq.heappop(H)
ans = 0
for i in range(N - K):
  ans += - heapq.heappop(H)
print(ans)

Measured memory_bytes: 25768
import sys
sys.setrecursionlimit(10**9)

H, W = map(int, input().split())
field = [list(input()) for _ in range(H)]
MOD = 10 ** 9 + 7
count = [0]
dp = [[-1] * W for _ in range(H)]

def dfs(x, y):
  if x == W-1 and y == H-1:
    return 1
  ret = 0
  for nx, ny in ((1,0), (0,1)):
    nx += x
    ny += y
    if nx >= W or ny >= H:
      continue
    if dp[ny][nx] > -1:
      ret += dp[ny][nx]
    elif field[ny][nx] == ".":
      ret += dfs(nx, ny)
  dp[y][x] = ret % MOD
  return ret

dfs(0,0)
print(dp[0][0])


Measured memory_bytes: 168456
#include <bits/stdc++.h>
#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)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define eb emplace_back
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
ll gcd(ll a, ll b) { return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a/gcd(a,b)*b;}
int const INF = 1001001001;
ll const MOD = 1000000007;


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

int A,B;
cin >> A >> B;
int cnt = 0;

for( int i = A ; i <= B ; i++ ) {
    int now = i;
    vi t(5);
    rep(i,5) {
        t[i] = now % 10;
        now /= 10;
    }
    if(t[0] == t[4] && t[1] == t[3]) cnt++;
}

cout << cnt << endl;
 
return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define x first
#define y second
#define ll long long
#define dl double
#define pii pair<int,int>
#define pb push_back
#define all() begin(),end()
#define nl '\n'
#define adm(a,b,m) ((a+b)%m)
#define gum(a,b,m) ((a*1LL*b)%m)
#define lo(i,j,n) for(int i=j;i<n;i++)


int main(){
	int n;
	cin>>n;
	int ok=0;
	int i,x;
	lo(i,0,n){
		cin>>x;
		while(!(x&1))x>>=1,ok++;
	}
	cout<<ok<<nl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main() 
{
    int i,a,b,c,ans;
    scanf("%d %d %d",&a,&b,&c);
    for(i=0;i<=1000;i++)
    {
        ans=a*i;
        if(ans%b==c)
        {
            printf("YES\n");
            return 0;
        }
    }
    printf("NO\n");
}

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

#define ll long long
#define Fi first
#define Se second
#define Pb push_back
#define vi vector<int>
#define vp vector<pair<int,int>>
#define vvi vector<vector<int>>
#define vvp vector<vector<pair<int,int>>>

const int INF = 1e9;
const int MOD = 1e9+7;
using Graph = vector<vector<int>>; //Caution!! Segmentation Fault!! Don't forget to add +1!

#define all(v) v.begin(),v.end()
#define output_s(a) printf("%s\n",(a).c_str())

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define Rep(i,n,m) for(int i=(int)(n);i<(int)(m);i++)
#define RepS(i,n,m) for(int i=(int)(n);i<=(int)(m);i++)
#define RRepS(i,n,m) for(int i=(int)(n);i>=(int)(m);i--)
#define RepA(x) for(auto &item:(x))

void CINT(){}
template <class Head,class... Tail>
void CINT(Head&& head,Tail&&... tail){
    cin>>head;
    CINT(move(tail)...);
}    
#define CIN(...) int __VA_ARGS__;CINT(__VA_ARGS__)
#define LCIN(...) ll __VA_ARGS__;CINT(__VA_ARGS__)
#define SCIN(...) string __VA_ARGS__;CINT(__VA_ARGS__)

template<typename TypeInt> //最大公約数
TypeInt GCD(TypeInt a,TypeInt b){
    if(a%b==0) return b;
    else return GCD(b,a%b);
}
template<typename TypeInt> //最小公倍数
TypeInt LCM(TypeInt a,TypeInt b){
    return a*b/GCD(a,b);
}

int IN_int(){
    int x;
    scanf("%d",&x);
    return x;
}

//library----------------------------------------------

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

const int NMAX = 100;
bool flag;

bool comp(int x,int y){
    return abs(0-x)<abs(0-y);
}

signed main(){
    CIN(N);
    vi v(N);
    rep(i,N)cin>>v[i];
    sort(all(v),greater<int>());
    int A=0,B=0;
    rep(i,N){
        i%2==0?A+=v[i]:B+=v[i];
    }
    printf("%d\n",A-B);

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<math.h>
#include<tuple>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
int main() {
	ll n;
	cin >> n;
	ll ans = 0;
	ll sum = 0;
	for (ll i = 1; i <= n; i++) {
		sum += i;
		if (i % 3 == 0 || i % 5 == 0) {
			ans += i;
		}
	}
	cout << sum - ans << endl;
	return 0;
}


Measured memory_bytes: 3596
#include <bits/stdc++.h>
using namespace std;
#define pii pair<int,int>
#define pll pair<long long, long long >
#define ll long long
#define lcm(a,b) (a)/__gcd((a),(b))*(b)
#define pb push_back
#define mp make_pair
#define x first
#define y second
#define maxn 10000000000000
#define endl '\n'
#define trace(x) cerr << #x << ": " << x << endl;
#define trace2(x, y) cerr << #x << ": " << x << " | " << #y << ": " << y << endl;
#define trace3(x, y, z) cerr << #x << ": " << x << " | " << #y << ": " << y << " | " << #z << ": " << z << endl;
#define trace4(a, b, c, d)cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << endl;
int mod(int x,int y)
{
  int s;
  s = abs(x)/y;
  if(x<0)s--;
  return x-y*s;
}
int dir8[2][8] = {{1,-1,0,0,1,-1,1,-1},{0,0,1,-1,1,-1,-1,1}};
int dir4[2][4] = {{1,-1,0,0},{0,0,1,-1}};
ll m,n,row,col,k;
ll memo[105][100006];
ll cost[105],weight[105];
ll dp(int i, ll w)
{
  if(i  >= n)return 0;
  if(memo[i][w]!=-1)return memo[i][w];
  ll p1 = 0, p2 = 0;
  if(weight[i] + w <= m)p1 = cost[i] + dp(i+1,w+weight[i]);
  p2 = dp(i+1,w);
  memo[i][w] = max(p1,p2);
  return memo[i][w];
}
void solve()
{
  scanf("%lld%lld",&n,&m);
  for(int w=0;w<n;w++)scanf("%lld%lld",&weight[w],&cost[w]);
  //memset(memo,-1,sizeof memo);
  //ll ans = dp(0,0);

  for(int w=0;w<=m;w++)memo[n-1][w] = (w + weight[n-1] <= m) ? cost[n-1]: 0;
  for(int i=n-2;i>=0;i--)
  {
    for(int w=0;w<=m;w++)
    {
      if(w + weight[i] <= m)
      {
        memo[i][w] = max(memo[i+1][w+weight[i]]+cost[i],memo[i+1][w]);
      }
      else memo[i][w] = memo[i+1][w];
    }
  }
  printf("%lld\n",memo[0][0]);


}
void test()
{
  int t;
  //scanf("%d",&t);
  t=1;
  for(int test=1;test<=t;test++)
  {
    //memset(memo,-1,sizeof memo);
    solve();
  }
}
int main()
{
  test();
  return 0;
}


Measured memory_bytes: 80128
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const long long inf = 1000000000000;

ll point(int n, int count, vector<ll> v, ll p0, ll p1, ll p2, ll a, ll b, ll c){
  if(count == n){
    if(p0 == 0 || p1 == 0 || p2 == 0){
      return inf;
    }
    return abs(a-p0) + abs(b-p1) + abs(c-p2) - 30;
  }
  
  ll ans1 = point(n, count + 1, v, p0, p1, p2, a, b, c);
  ll ans2 = point(n, count + 1, v, p0 + v[count], p1, p2, a, b, c) + 10;
  ll ans3 = point(n, count + 1, v, p0, p1 + v[count], p2, a, b, c) + 10;
  ll ans4 = point(n, count + 1, v, p0, p1, p2 + v[count], a, b, c) + 10;
  
  return min(ans1, min(ans2, min(ans3, ans4)));
}
    

int main(){
  ll n,a,b,c;
  cin >> n >> a >> b >> c;
  
  vector<ll> v(n);
  for(int i=0; i<n; i++) cin >> v[i];
  
  ll ans;
  ans = point(n, 0, v, 0, 0, 0, a,b,c);
  
  cout << ans << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<stack>
#include<queue>
#include<cstdio>
#include<climits>
#include<cmath>
#include<cstring>
#include<string>
#include<complex>
#include<map>

#define f first
#define s second
#define mp make_pair

#define REP(i,n) for(int i=0; i<(int)(n); i++)
#define FOR(i,c) for(__typeof((c).begin()) i=(c).begin(); i!=(c).end(); i++)
#define ALL(c) (c).begin(), (c).end()
#define EPS (1e-10)
using namespace std;

typedef unsigned int uint;
typedef long long ll;
typedef complex<double> P;

int memo[50][12][12];

int search(int s, int n, int p){
  if(s == 0 && n == 0)
    return 1;
  if(n == 0 || s < 0 || p == 10)
    return 0;
  if(memo[s][n][p]!=-1)
    return memo[s][n][p];
  return memo[s][n][p] = search(s,n,p+1) + search(s-p,n-1,p+1);
}

int main(){
  int n,s;
  memset(memo,-1,sizeof(memo));
  while(cin>>n>>s,n+s){
    if(s >= 50 || n >= 12)
      cout << 0 << endl;
    else
      cout << search(s,n,0) << endl;
  }
  return 0;
}

Measured memory_bytes: 0
#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)swap(a,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);}//saisyo kobaisu
#define NEXTP(x) next_permutation(x.begin(),x.end())
const ll INF=1e18+7;
const ll MOD=1e9+7;
#define out(a) cout<<fixed<<setprecision((a))


int main(){
	ll N,D;
	cin >> N >> D;
	ll ans = 0;
	while(N>0){
		N -= 2*D+1;
		ans++;
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
n = int(input())
a = []
for i in range(n):
    a.append(list(map(int,input().split())))

ans = 0
for i in range(n):
    b = (a[n-i-1][0]+ans)%a[n-i-1][1]
    if b != 0:
        ans += (a[n-i-1][1]-b)
print(ans)

Measured memory_bytes: 27380
#include<iostream>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<list>
#include<map>
#include<numeric>
#include<iomanip>
#define REP(i,m,n) for(int i=(int)(m);i<(int)(n);i++)
#define rep(i,n) REP(i,0,n)
#define ll long long

using namespace std;

//最大公約数
ll gcd(ll a, ll b) {
	if (b == 0) {
		return a;
	}
	return gcd(b, a % b);
}

//最小公倍数
ll lcm(ll a, ll b) {
	return a * b / gcd(a, b);
}

int main() {
	int n, k;
	cin >> n >> k;
	vector<double>p(n);
	rep(i, n)cin >> p[i];

	vector<double>expected_value(n);
	rep(i, n) {
		double s = (p[i] / 2) * (2 * 1 + (p[i] - 1) * 1);
		expected_value[i] = s / p[i];

	}

	double temp = 0;
	rep(i, k) {
		temp += expected_value[i];
	}

	double ans = -1;
	ans = max(ans, temp);

	rep(i, n - k) {
		temp -= expected_value[i];
		temp += expected_value[i + k];
		ans = max(ans, temp);
	}

	cout << fixed << setprecision(12) << ans << endl;
	return 0;
}

Measured memory_bytes: 3328
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000


int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int H, W;
    cin >> H >> W;
    if (H == 1 && W == 1) {
        cout << "Yes" << endl;
        return 0;
    }
    int cnt[26] = {};
    rep(i, H) rep(j, W) {
        char a; cin >> a;
        cnt[a - 'a']++;
    }
    /*
    rep(i, 26) {
        if (cnt[i] != 0) cout << (char)('a' + i) << ":" << cnt[i] << endl;
    }
    */
    int count1 = 0;
    int count2 = 0;
    int count4 = 0;
    rep(i, 26) {
        while(cnt[i]){
            if (cnt[i] % 4 == 0 && cnt[i]) {
                count4++;
                cnt[i] -= 4;
            } else if (cnt[i] % 2 == 0 && cnt[i]) {
                count2++;
                cnt[i] -= 2;
            } else if (cnt[i]) {
                count1++;
                cnt[i]--;
            }
        }
    }
    // dump(count1); dump(count2); dump(count4);
    if (H % 2 == 0 && W % 2 == 0) {
        if (count1 == 0 && count2 == 0) {
            cout << "Yes" << endl;
        } else {
            cout << "No" << endl;
        }
    }
    else if (W % 2 == 0) {
        if (count1 == 0 && count2 % 2 == (W/2) % 2 && count2 <= W/2)  {
            cout << "Yes" << endl;
        } else {
            cout << "No" << endl;
        }
    } else if (H % 2 == 0) {
        if (count1 == 0 && count2 % 2== (H/2) % 2 && count2 <= H/2) {
            cout << "Yes" << endl;
        } else {
            cout << "No" << endl;
        }
    } else {
        if (count1 == 1 && count2 % 2 == (H/2 + W/2) % 2 && count2 <= (H/2 + W/2)) {
            cout << "Yes" << endl;
        } else {
            cout << "No" << endl;
        }
    }

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define chmin(a, b) ((a)=min((a), (b)))
#define chmax(a, b) ((a)=max((a), (b)))
#define fs first
#define sc second
#define eb emplace_back
using namespace std;
 
typedef long long ll;
typedef pair<int, int> P;
typedef tuple<int, int, int> T;
 
const ll MOD=1e9+7;
const ll INF=1e18;
 
int dx[]={1, -1, 0, 0};
int dy[]={0, 0, 1, -1};

double p[305][2];
int n;

double dist(int a,int b){
    return sqrt((p[a][0]-p[b][0])*(p[a][0]-p[b][0])+(p[a][1]-p[b][1])*(p[a][1]-p[b][1]));
}

double get_o(int i,double st,double en,double th,double b){
    double diff = 1.0;
    while(diff > 0.00001){
        double half[2];
        half[0] = (en+st)/2.0;
        half[1] = th*half[0] + b;
        if( (p[i][0]-half[0])*(p[i][0]-half[0]) + (p[i][1]-half[1])*(p[i][1]-half[1]) >1){
            en = half[0];
        }else{
            st = half[0];
        }
        diff = en - st;
        if(diff < 0 ) diff = -1.0 * diff;
    }
  //  cout << "st:" << st << ", en:" << en << endl;
    return st;
}

int find_ans(double x,double y,int a,int b){
    int ans = 2;
    for(int i = 0;i < n;i++){
        if(i == a || i == b)continue;
        if( (p[i][0]-x)*(p[i][0]-x) + (p[i][1]-y)*(p[i][1]-y) <= 1.0) ans++;
    }
    return ans;
}

int main(){
    while(true){
        cin >> n;
        if(n == 0)break;
        for(int i = 0;i < n;i++){
            cin >> p[i][0] >> p[i][1];
        }
        int ans = 1;
        for(int i = 0;i < n;i++){
            for(int j = i+1;j < n;j++){
                double d = dist(i,j);
                if(d > 2.0)continue;
                if(true){
            //    if(p[i][1] != p[j][1]){
                    double th = -(p[j][0]-p[i][0])/(p[j][1]-p[i][1]);
                    double half[2];
                    half[0] = (p[i][0]+p[j][0])/2.0;
                    half[1] = (p[i][1]+p[j][1])/2.0;
                    double b = half[1] - th*half[0];
                    double o[2];
                    o[0] = get_o(i,half[0],half[0]+1,th,b);
                    o[1] = th*o[0] + b;
                //    cout << "x1:" << p[i][0] << ",y1" << p[i][1] << ",x2" << p[j][0] << ",y2" << p[j][1] << ",ox" << o[0] << ",oy" << o[1] << endl;
                    ans = max(ans,find_ans(o[0],o[1],i,j));
                    o[0] = get_o(i,half[0],half[0]-1,th,b);
                    o[1] = th*o[0] + b;
                //    cout << "x1:" << p[i][0] << ",y1" << p[i][1] << ",x2" << p[j][0] << ",y2" << p[j][1] << ",ox" << o[0] << ",oy" << o[1] << endl;
                    ans = max(ans,find_ans(o[0],o[1],i,j));
                }
            }
        }
        cout << ans << endl;
    }
}


Measured memory_bytes: 3220
import java.util.*;

class Main {
  public static void main(String args[]) {
    Scanner sc = new Scanner(System.in);
    String[] s = sc.nextLine().split(" ");
    int r = Integer.parseInt(s[0]);
    int c = Integer.parseInt(s[1]);
    int rPlus1 = r + 1;
    int cPlus1 = c + 1;
    int t[][] = new int[rPlus1][cPlus1];
    for (int i = 0; i < r; i++) {
      t[i][c] = 0;
      for (int j = 0; j < c; j++) {
        t[i][j] = sc.nextInt();
        t[i][c] += t[i][j];
        t[r][j] += t[i][j];
        t[r][c] += t[i][j];
      }
    }
    for (int i = 0; i < rPlus1; i++) {
      for (int j = 0; j < cPlus1; j++) {
        if (j != c) {
          System.out.print(t[i][j] + " ");
        } else {
          System.out.println(t[i][j]);
        }
      }
    }
  }
}

Measured memory_bytes: 39432
#include <iostream>

using namespace std;

int main() {
  int A, B, C;
  cin >> A >> B >> C;
  int fivec = 0, sevenc = 0;
  if(A == 5) {
    fivec++;
  } else if(A == 7) {
    sevenc++;
  }
  if(B == 5) {
    fivec++;
  } else if(B == 7) {
    sevenc++;
  }
  if(C == 5) {
    fivec++;
  } else if(C == 7) {
    sevenc++;
  }
  if(fivec == 2 && sevenc == 1) {
    cout << "YES" << endl;
  } else {
    cout << "NO" << endl;
  }
}

Measured memory_bytes: 256
n,m = [int(i) for i in input().split()]
a = []
for i in range(n):
	array = input()
	a.append(array)
b = []
for i in range(m):
	line = input()
	b.append(line)
ans = 'No'
for i in range (n-m+1):
	for j in range(n-m+1):
		Ans = ans
		if a[i][j:j+m] == b[0]:
			#print(i,j)
			for k in range(m):
				if not a[i+k][j:j+m] == b[k]:
					ans = Ans
					break
				else:
					ans = 'Yes'
					#print(ans)
print(ans)

Measured memory_bytes: 3064
#include <stdio.h>
#include <stdlib.h>

int max(int a, int b){
	return a >= b ? a : b;
}

int min(int a, int b){
	return a <= b ? a : b;
}

int main(){
	int N, Q, i, tmp;
	scanf("%d%d", &N, &Q);
	int *A = (int *)malloc(sizeof(int) * Q);
	int *B = (int *)malloc(sizeof(int) * Q);
	for(i = 0; i < Q; i++){
		scanf("%d%d", &A[i], &B[i]);
		A[i]--;
		B[i]--;
	}
	int *ball = (int *)malloc(sizeof(int) * (Q + 1));
	ball[0] = 0;
	for(i = 0; i < Q; i++){
		if(A[i] == ball[i]){
			ball[i + 1] = B[i];
		}
		else if(B[i] == ball[i]){
			ball[i + 1] = A[i];
		}
		else{
			ball[i + 1] = ball[i];
		}
	}
/*	for(i = 0; i <= Q; i++){
		printf("ball[%d] = %d\n", i, ball[i]);
	}
*/	int *P = (int *)malloc(sizeof(int) * N);
	int *can = (int *)malloc(sizeof(int) * N);
	for(i = 0; i < N; i++){
		P[i] = i;
		can[i] = 0;
	}
	can[ball[Q]] = 1;
	for(i = Q; i >= 0; i--){
		can[P[max(0, ball[i] - 1)]] = 1;
		can[P[min(N - 1, ball[i] + 1)]] = 1;
		if(i == 0){
			break;
		}
		else{
			tmp = P[A[i - 1]];
			P[A[i - 1]] = P[B[i - 1]];
			P[B[i - 1]] = tmp;
		}
	}
	int ans = 0;
	for(i = 0; i < N; i++){
		ans += can[i];
	}
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 2176
n = int(input())
p = [int(input()) for i in range(n)]
a = [0] * n
for i in range(n):
    a[p[i]-1] = i
prv = -1
mx = 1
nw = 0
for i in range(n):
    if prv < a[i]:
        nw += 1
        mx = max(mx, nw)
    else:
        nw = 1
    prv = a[i]
print(n-mx)


Measured memory_bytes: 18924
#include <bits/stdc++.h>
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define RFOR(i,a,b) for(ll i=(b) - 1;i>=(a);i--)
#define REP(i,n) for(ll i=0;i<(n);i++)
#define RREP(i,n) for(ll i=n-1;i>=0;i--)

#define PB push_back
#define INF INT_MAX/3
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define CLR(a) memset(a,0,sizeof(a))

typedef long long int ll;

using namespace std;

int main(){
    ll n,K;
    vector<ll> vx;
    vector<ll> vy;
    vector<ll> vd;
    cin >> n >> K;
    vector<ll> x1(n),x2(n),y1(n),y2(n),d1(n),d2(n);
    REP(i,n){
	cin >> x1[i] >> y1[i] >> d1[i] >> x2[i] >> y2[i] >> d2[i];
	vx.PB(x1[i]);
	vx.PB(x2[i]);
	vy.PB(y1[i]);
	vy.PB(y2[i]);
	vd.PB(d1[i]);
	vd.PB(d2[i]);
    }
    sort(ALL(vx));
    sort(ALL(vy));
    sort(ALL(vd));
    int num[101][101][101] = {0};
    REP(i,n){
	int xl = lower_bound(ALL(vx),x1[i])-vx.begin();
	int xr = lower_bound(ALL(vx),x2[i])-vx.begin();
	int yl = lower_bound(ALL(vy),y1[i])-vy.begin();
	int yr = lower_bound(ALL(vy),y2[i])-vy.begin();
	int dl = lower_bound(ALL(vd),d1[i])-vd.begin();
	int dr = lower_bound(ALL(vd),d2[i])-vd.begin();
	FOR(j,xl,xr)FOR(k,yl,yr)FOR(l,dl,dr){
	    num[j][k][l]++;
	}
    }

    ll ans = 0;
    REP(i,vx.size())REP(j,vy.size())REP(k,vd.size()){
	if(num[i][j][k] >= K){
	    ans += abs( (vx[i]-vx[i+1])*(vy[j]-vy[j+1])*(vd[k]-vd[k+1]));
	}
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 5248
using System;

class Program
{
    static void Main()
    {
        for (; ; )
        {
            var line = Console.ReadLine().Split(' ');
            int H = int.Parse(line[0]);
            int W = int.Parse(line[1]);
            if (H == 0 && W == 0) break;
            for (var i = 1; i <= H; i++)
            {
                for (var j = 1; j <= W; j++) Console.Write("#");
                Console.WriteLine();
            }
            Console.WriteLine();
        }
    }

}
    


Measured memory_bytes: 7820
// https://blog.csdn.net/forever_shi/article/details/83189155 
#include<bits/stdc++.h>
using namespace std;
const int N=1e5+10;
int n,j,ans,a[N];
int main()
{
    scanf("%d",&n);
    for (register int i=1; i<=n; ++i) scanf("%d",&a[i]);
    sort(a+1,a+n+1);
	reverse(a+1,a+n+1);	
    for (register int i=1; i<=n; ++i)
    if (i+1>a[i+1])
	{
    	j=i+1,ans=0; 
		while (a[j]==i) ans++,j++;
		if (ans%2==1 || (a[i]-i)%2==1) puts("First");
		else puts("Second");
		return 0;
    }
}

Measured memory_bytes: 640
#include <iostream>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <algorithm>
#include <limits>
#include <ios>
#include <iomanip>
#include <stdio.h>
#include <iomanip>
#include <queue>
#include <set>
using namespace std;

#define rep(i,N) for(int (i)=0; (i)<(N); (i)++)
#define revrep(i,N) for(int (i)=(N)-1; (i)>=0; (i)--)
#define dump(vec) for(int i = 0; i < (vec).size(); i++){cout << vec.at(i) << ",";}cout << endl

typedef long long ll;

int main(void)
{
    string str ;
    cin >> str;
    if ("SUN" == str) {
        cout << 7<< endl;
    } else  if ("MON" == str) {
        cout << 6<< endl;
    } else  if ("TUE" == str) {
        cout << 5<< endl;
    } else  if ("WED" == str) {
        cout << 4<< endl;
    } else  if ("THU" == str) {
        cout << 3<< endl;
    } else  if ("FRI" == str) {
        cout << 2<< endl;
    } else  if ("SAT" == str) {
        cout << 1<< endl;
    }

    return 0;
}


Measured memory_bytes: 768
#include <stdio.h>
#include <stdlib.h>

void read_list(char list[128]) {
	int num;
	int i;
	if (scanf("%d", &num) != 1) exit(1);
	for (i = 0; i < num; i++) {
		int id;
		if (scanf("%d", &id) != 1) exit(1);
		list[id] = 1;
	}
}

int main(void) {
	int N;
	char Alist[128] = {0}, Blist[128] = {0}, Clist[128] = {0};
	int i, count = 0;
	if (scanf("%d", &N) != 1) return 1;
	read_list(Alist);
	read_list(Blist);
	read_list(Clist);
	for (i = 1; i <= N; i++) {
		if ((!Alist[i] && Clist[i]) || (Blist[i] && Clist[i])) count++;
	}
	printf("%d\n", count);
	return 0;
}



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

int main(void) {
	int a, b,i, sum = 0;

	cin >> a >> b;

	if (3 <= a, b <= 20) {
		for (i = 0; i < 2; i++) {
			if (a > b) {
				sum = sum + a;
				a--;
			}
			else {
				sum = sum + b;
				b--;
			}
		}
		cout << sum;
	}
	else
		cout << "0";
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll ;
const int N=200020;
int a[N];

int main(){
    int n;cin >> n;
    map<int,int> mp;
    for(int i=1;i<=n;i++){
        cin >> a[i];
        mp[i-a[i]]++;
    }
    ll ans=0;
    for(int i=1;i<=n;i++){
        mp[i-a[i]]--;
        ans+=mp[i+a[i]];
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 21372
A1 = list(map(int,input().split(' ')))
A2 = list(map(int,input().split(' ')))
A3 = list(map(int,input().split(' ')))
N = int(input())
b = []
for k in range(N):
    b.append(int(input()))

checklist = [A1, A2, A3, [A1[0], A2[0], A3[0]], [A1[1], A2[1], A3[1]], [A1[2], A2[2], A3[2]],[A1[0], A2[1], A3[2]],[A1[2], A2[1], A3[0]]]
#print(checklist)

ans = "No"

for cl in checklist:
    if set(cl).issubset(b) == True:
        ans = "Yes"
        break

print(ans)


Measured memory_bytes: 3064
import java.util.*;

class Main {
  public static final long MOD = 1000000007;
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int K = sc.nextInt();
    Integer A[] = new Integer[N];
    for(int i=0; i<N; i++){
      A[i] = sc.nextInt();
    }
    int ans;
    ans = (N-2) / (K-1) + 1;
    System.out.println(ans);
    
  }

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

Measured memory_bytes: 64592
#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() {
   string s;cin>>s;
   sort(s.begin(),s.end());
   if (s[0]!=s[3]&&s[0]!=s[2]&&s[0]==s[1]&&s[2]==s[3])
   {
      /* code */
      cout<<"Yes"<<endl;
   }
   else
   {
      cout<<"No"<<endl;
   }
   
   
   }

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <cmath>
#include <queue>
#include <cstring>
#include <vector>
#include <string>
#include <stack>
#include <set>
#include <map>
#include <iostream>
#include <algorithm>
using namespace std;
#define MP make_pair
#define PB push_back
typedef long long LL;
typedef pair<int, int> Pii;
const int inf = 0x3f3f3f3f;
const LL INF = (1uLL << 63) - 1;
const LL mod = 1000000007;
const int N = 1e5 + 5;
const double Pi = acos(-1.0);
const int maxn = 1e5 + 5;
LL num[100005];
int main() {
#ifdef local
    freopen("in", "r", stdin);
#endif
    LL n , x;
    cin>>n>>x;
    for(int i = 0 ; i < n ; i++){
        cin>>num[i];
    }
    LL res = 0;
    if(num[0] > x){
        res += num[0] - x;
        num[0] = x;
    }
    for(int i = 1; i < n ; i++){
        if(num[i] + num[i-1] > x){
            res += num[i] + num[i-1] - x;
            num[i] = x - num[i-1];
        }
    }
    cout<<res<<endl;
}


Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cmath>
using namespace std;

using ll = long long;
using P = pair<int, int>;

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

// 4近傍、8近傍
int dx[] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[] = {0, 1, 0, -1, 1, 1, -1, -1};

int cnt[100010];

int main() {
  // 入力
  int N;
  cin >> N;
  int a[N];
  for (int i = 0; i < N; i++) cin >> a[i];

  int ans = 0;
  for (int i = 0; i < N; i++) {
    if (a[i] > 100000) {
      ans++;
    } else {
      cnt[a[i]]++;
    }
  }

  for (int i = 1; i <= 100000; i++) {
    if (cnt[i] < i) ans += cnt[i];
    else ans += cnt[i] - i;
  }

  // 解答
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
#define rep(i,n) for(int i=0;i<n;i++)
typedef vector<int> vec;
//配列の添字ズレに注意
//=に注意
int main(){
  int N,M; cin>>N>>M;
  Graph G(N);
    for (int i=0;i<M;++i){
        int a,b;
        cin>>a>>b;
        G[a-1].push_back(b-1);
        G[b-1].push_back(a-1);
    }
  
  vec dist(N,-1);
  vec sign(N,-1);
  queue<int> que;
  
  dist[0] = 0;
  que.push(0);

  while (!que.empty()) {
        int v = que.front();
        que.pop();

        for (int nv : G[v]) {
            if (dist[nv] != -1) continue;
            dist[nv]=dist[v]+1;
            que.push(nv);
            sign[nv]=v+1;
        }
    }
  cout<<"Yes"<<endl;
  for(int i=1;i<N;i++)cout<<sign[i]<<endl;
}


Measured memory_bytes: 10624
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        MyScanner in = new MyScanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        ABC058A solver = new ABC058A();
        solver.solve(1, in, out);
        out.close();
    }

    static class ABC058A {
        public void solve(int testNumber, MyScanner in, PrintWriter out) {
            int a = in.Int();
            int b = in.Int();
            int c = in.Int();
            out.println(b - a == c - b ? "YES" : "NO");

        }

    }

    static class MyScanner {
        private BufferedReader in;
        private StringTokenizer st;

        public MyScanner(InputStream stream) {
            in = new BufferedReader(new InputStreamReader(stream));
        }

        public String next() {
            while (st == null || !st.hasMoreTokens()) {
                try {
                    String rl = in.readLine();
                    if (rl == null) {
                        return null;
                    }
                    st = new StringTokenizer(rl);
                } catch (IOException e) {
                    return null;
                }
            }
            return st.nextToken();
        }

        public int Int() {
            return Integer.parseInt(next());
        }

    }
}



Measured memory_bytes: 21460
#pragma GCC optimize(2)
#include<bits/stdc++.h>
#define ll long long
#define maxn 1000005
#define inf 1e9
#define pb push_back
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define per(i,a,b) for(int i=a;i>=b;i--)
using namespace std;

inline int read()
{
	int x=0,w=1; char c=getchar();
	while(c<'0'||c>'9') {if(c=='-') w=-1; c=getchar();}
	while(c<='9'&&c>='0') {x=(x<<1)+(x<<3)+c-'0'; c=getchar();}
	return w==1?x:-x;
}

string S;
set <string> s;

int main()
{
	int n=read();
	for(int i=1;i<=n;i++)
	{
		cin>>S;
		s.insert(S);
	}
	cout<<s.size()<<endl;
	return 0;
}

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

int main() {
        int N;
        int A, // 4桁目
            B, // 3桁目
            C, // 2桁目
            D; // 1桁目

        cin >> N;

        A = N / 1000;
        B = (N - A * 1000) / 100;
        C = (N - (A * 1000) - (B * 100)) / 10;
        D = (N - (A * 1000) - (B * 100) - (C * 10));

        if ((A == B && B == C) || (B == C && C == D) || (((A == B) && (B == C) && (C == D)))) {
                cout << "Yes" << endl;
        }
        else {
                cout << "No" << endl;
        }

}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(void){
    int a,c = 0;
    cin >> a;
  int b[a];
  for(int i = 0;i < a;i++){
    cin >> b[i];
  }
  for(int i = 0;i < a - 1;i++){
    for(int j = i + 1;j < a ;j++){
      c += b[i] * b[j];
    }
  }
  cout << c;
}

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

#define CPP_CAT(x,y) CPP_CAT_I(x,y)
#define CPP_CAT_I(x,y) x ## y
//#define CPP_STR(x) CPP_STR_I(x)
//#define CPP_STR_I(args...) #args
//#define ASSERT(expr...) assert((expr))

using i8 = int8_t;
using u8 = uint8_t;
using i16 = int16_t;
using u16 = uint16_t;
using i32 = int32_t;
using u32 = uint32_t;
using i64 = int64_t;
using u64 = uint64_t;
using f32 = float;
using f64 = double;
//using f80 = __float80;
#pragma endregion

#pragma region const
constexpr i64 INF = 1'010'000'000'000'000'017LL;
constexpr i64 MOD = 1'000'000'007LL;
constexpr f64 EPS = 1e-12;
constexpr f64 PI = 3.14159265358979323846;
#pragma endregion

#pragma region util
#define FOR(i, start, end) for(i64 i = (start), CPP_CAT(i,xxxx_end)=(end); i < CPP_CAT(i,xxxx_end); ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(f,c,...) (([&](decltype((c)) cccc) { return (f)(std::begin(cccc), std::end(cccc), ## __VA_ARGS__); })(c))

template<typename C>
i64 SIZE(const C& c) { return static_cast<i64>(c.size()); }
template<typename T, size_t N>
i64 SIZE(const T(&)[N]) { return static_cast<i64>(N); }

template<typename T, typename U, typename Comp = less<>>
bool chmax(T& xmax, const U& x, Comp comp = {}) {
	if (comp(xmax, x)) {
		xmax = x;
		return true;
	}
	return false;
}
template<typename T, typename U, typename Comp = less<>>
bool chmin(T& xmin, const U& x, Comp comp = {}) {
	if (comp(x, xmin)) {
		xmin = x;
		return true;
	}
	return false;
}
#pragma endregion

#pragma region init
struct ProconInit {
	static constexpr int IOS_PREC = 15;
	static constexpr bool AUTOFLUSH = false;

	ProconInit() {
		cin.tie(nullptr);
		ios::sync_with_stdio(false);
		cout << fixed << setprecision(IOS_PREC);
		if (AUTOFLUSH)
			cout << unitbuf;
	}
} PROCON_INIT;
#pragma endregion

int main()
{
	double T,X;
	cin >> T >> X;
	cout << (T / X) << endl;
	return 0;
}


Measured memory_bytes: 256
#include <atcoder/all>
#include <bits/stdc++.h>
#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)
using namespace std;
using namespace atcoder;
const int INF = 1001001001;
const long long LINF = 1001002003004005006ll;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
typedef long long ll;
typedef pair<int,int> P;

int op(int a,int b) {return max(a,b);}

int e() {return -1;};

int main(){
  int n,k;
  cin >> n >> k;
  vector<int> a(n);
  rep(i,n)cin >> a[i];

  vector<int> v(300100,0);
  segtree<int,op,e> seg(v);

  rep(i,n){
    int l = max(0,a[i]-k);
    int r = min(300100,a[i]+k+1);
    int mx = seg.prod(l,r);
    seg.set(a[i],mx+1);
  }
  cout << seg.all_prod() << endl;
}

Measured memory_bytes: 9604
#include<bits/stdc++.h>
using namespace std;
int main(){
	int x;
	cin>>x;
	float n=x/1.08;
	int n1=x*100/108;
	if(n==n1){
		printf("%d\n",n1);
	}else{
		int n2=(n1+1)*1.08;
		if(n2==x){
			printf("%d\n",n1+1);
		}else{
			printf(":(\n");
		}
	}
	return 0;
} 

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

#define rep(i,a,n) for(int i=a; i<n; i++)
#define repr(i,a,n) for(int i=a; i>=n; i--)
#define pb(a) push_back(a)
#define fr first
#define sc second
#define INF 999999999

#define X real()
#define Y imag()
#define EPS (1e-10)
#define EQ(a,b) (abs((a) - (b)) < EPS)
#define EQV(a,b) ( EQ((a).X, (b).X) && EQ((a).Y, (b).Y) )
#define LE(n, m) ((n) < (m) + EPS)
#define GE(n, m) ((n) + EPS > (m))

typedef vector<int> VI;
typedef vector<VI> MAT;
typedef pair<int, int> pii;
typedef long long int ll;

typedef complex<double> P;
typedef pair<P, P> L;
typedef pair<P, double> C;

int const MOD = 1000000007;

int dayOfTheWeek( int y, int m, int d )
{
    if( m < 3 ) {
        y--; m += 12;
    }
    return ( y + y/4 - y/100 + y/400 + ( 13*m + 8 )/5 + d )%7;
}

int main() {
    string dayname[] = {"Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"};
    int m,d;
    while(cin >> m, m) {
        cin >> d;
        cout << dayname[dayOfTheWeek(2004,m,d)] << endl;
    }
    return 0;
}

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

template <typename T>
class weighted_quick_find {
	vector<pair<int, T>> data;
	vector<vector<int>> all;
public:
	weighted_quick_find(int n) : data(n), all(n, vector<int>(1)) {
		for (int i = 0; i < n; i++) {
			data[i].first = i;
			all[i][0] = i;
		}
	}
	void unite(int a, int b, T d) {
		if (same(a, b)) return;
		d += data[a].second - data[b].second;
		a = data[a].first;
		b = data[b].first;
		if (all[a].size() < all[b].size()) swap(a, b), d = -d;
		for (auto& id : all[b]) {
			data[id] = { a, data[id].second + d };
		}
		copy(all[b].begin(), all[b].end(), back_inserter(all[a]));
	}
	bool same(int a, int b) const {
		return data[a].first == data[b].first;
	}
	T dist(int a, int b) const {
		return data[b].second - data[a].second;
	}
};

int main()
{
	ios::sync_with_stdio(false), cin.tie(0);
	int n, q;
	cin >> n >> q;
	weighted_quick_find<int> wqf(n);
	while (q--) {
		int com, x, y;
		cin >> com >> x >> y;
		if (com == 0) {
			int z;
			cin >> z;
			wqf.unite(x, y, z);
		}
		else if (wqf.same(x, y)) {
			printf("%d\n", wqf.dist(x, y));
		}
		else {
			puts("?");
		}
	}
	return 0;
}



Measured memory_bytes: 10272
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<queue>
#include<map>
#include<cmath>
#include<set>
using namespace std;
#define REP(i, limit) for(int i=0; i< limit; ++i)
#define FOR(i, j, limit) for(int i=j; i< limit; ++i)
#define DUMP(a) REP(d,a.size()){cout<<a[d];if(d!=a.size()-1)cout<<" ";else cout<<endl;}
#define ECHO(x) cout<<x<<endl;
#define LL long long
int INF = 2147483647;
LL LINF = 9223372036854775807;
LL MOD = 1000000007;
typedef pair<int, int>P;
typedef pair<LL, LL>PL;
typedef vector<int> vi;
typedef vector<LL> vl;

vector<int>ans;
void swap(int x, int loc){
  int i=0;
  while(ans[i]!=x) ++i;
  if(i==loc) return;

  ans[i] = ans[i]^ans[loc];
  ans[loc]=ans[i]^ans[loc];
  ans[i]=ans[i]^ans[loc];
  return;
}

int main(){
  int n, x;
  cin>>n>>x;

  if(x==1||x==2*n-1){
    cout<<"No"<<endl;
    return 0;
  }
  cout<<"Yes"<<endl;

  REP(i, 2*n-1) ans.push_back(i+1);

  if(n!=2){
    swap(x, n-1);
    swap(x-1, n);
    swap(x+1, n-2);
    if(x==2){
      swap(x+2, n+1);
    }
    else{
      swap(x-2, n-3);
    }
  }

  REP(i, 2*n-1) cout<<ans[i]<<endl;

  return 0;
}


Measured memory_bytes: 2420
import java.util.*;
class Main{
    public static void main(String[] args){
        Scanner sc=new Scanner(System.in);
        int arr[]=new int[3];
        arr[0]=sc.nextInt();
        arr[1]=sc.nextInt();
        arr[2]=sc.nextInt();
        Arrays.sort(arr);
        System.out.println(arr[0]+" "+arr[1]+" "+arr[2]);
    }
}

Measured memory_bytes: 17156
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		int n = sc.nextInt();
		int m = sc.nextInt();
		int x = sc.nextInt();

		int l = 0;
		int r = 0;
		for (int i = 0; i < m; i++) {
			int a = sc.nextInt();
			if (a < x) {
				l++;
			} else {
				r++;
			}
		}

		System.out.println(Math.min(l, r));

		sc.close();
	}
}


Measured memory_bytes: 23636
def resolve():
    n = int(input())
    a = list(map(int, input().split()))

    if 0 in a:
        print(0)
    else:
        ans = 1
        for i in a:
            if ans > 10**18:
                ans = -1
                break
            ans *= i
        print(ans if ans <= 10**18 else -1)
resolve()

Measured memory_bytes: 84680
N = int(input())
S = [input() for i in range(N)]

def count(s):
    p = 0
    result = 0
    while 1:
        q = s.find("AB", p)
        if q < 0:
            break
        p = q + 2
        result += 1
    return result

result = 0

la = 0
sb = 0
ab = 0

for s in S:
    r = count(s)
    # print("*", s, r)
    if s[-1] == "A":
        la += 1
    if s[0] == "B":
        sb += 1
        if s[-1] == "A":
            ab += 1
    result += r

la -= ab
sb -= ab

#print(la, sb, ab)

f = 0
while 1:
    if f:
        if ab >= 1:
            f = 1
            ab -= 1
            result += 1
        elif sb >= 1:
            f = 0
            sb -= 1
            result += 1
        else:
            break
    else:
        if la >= 1:
            la -= 1
            f = 1
        elif ab >= 1:
            ab -= 1
            f = 1
        else:
            break

#result += min(la, sb, N - 1)

print(result)


Measured memory_bytes: 46680