akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<vector>
#include<utility>
#include<queue>
#include<string>
#include<cmath>
#include<tuple>
#include<algorithm>
#define INF 1111111111
using namespace std;
typedef pair<int,int> P;
typedef tuple<int,int,int> tup;
typedef long long ll;
vector<int> vec(100100);
vector<int> passed(100100);
vector<int> dx = {-1,1};
int n,k;

int main() {
  cin >> n;
  int x[101],y[101],h[101];
  
  for(int i=0;i<n;i++)
    cin >> x[i] >> y[i] >> h[i];

  for(int i=0;i<=100; i++){
    for(int j=0;j<=100;j++){
        int H=1111111111;
      for(int k=0;k<n;k++){
        if(H>h[k]+abs(x[k]-i)+abs(y[k]-j))
          H = h[k]+abs(x[k]-i)+abs(y[k]-j);
      }
      for(int k=0;k<n;k++){
        if(h[k] == max(H-abs(x[k]-i)-abs(y[k]-j),0)){
          if(k == n-1){
            cout << i << " " << j << " " << H << endl;
            return 0;
          }
          continue;
        }
        else{
          break;
        }
      }
    }
  }
}

Measured memory_bytes: 1024
n = int(input())
a = []
for i in range(n):
  a.append(int(input()))
frag = [True for _ in range(n)]
frag[0] = False
ans = 0
now = 1
while(now != 2):
  ans += 1
  now = a[now-1]
  if(frag[now-1]):
    frag[now-1] = False
  else:
    ans = -1
    break
print(ans)
  

Measured memory_bytes: 13852
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//#pragma GCC optimize("unroll-loops")

#define _CRT_SECURE_NO_WARNINGS
#include <bits/stdc++.h>

using namespace std;

typedef pair <int, int> pii;
typedef pair <long long, long long> pll;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;

#define endl "\n"
#define mt make_tuple
#define mp make_pair

template <typename T1, typename T2>
bool umax(T1 &a, const T2&b) { return a < b ? a = b, 1 : 0;}
template <typename T1, typename T2> 
bool umin(T1 &a, const T2 &b) {return a > b ? a = b, 1 : 0;}
template <typename T>
T sqr(T a) {return a * a;}

mt19937 rng(20010709);
const int mod = 1000000007;
const int INF = 1000000001;

int n;
ld dp[3000][6005], p[3000];
ld result;

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

    cin >> n;

    for (int i = 1; i <= n; i++)
        cin >> p[i];

    dp[0][0 + n] = 1;

    for (int i = 1; i <= n; i++) {
        for (int j = 1; j <= n * 2; j++) {
            dp[i][j + 1] += dp[i - 1][j] * p[i];
            dp[i][j - 1] += dp[i - 1][j] * (1.0 - p[i]);
        }
    }

    for (int i = 1; i <= n; i++)
        result += dp[n][i + n];

    cout << fixed << setprecision(15) << result << endl;

    return 0;
}

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

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

#define yes "Yes"
#define yse "Yes"
#define no "No"

#define pb push_back
#define rep(i, l, n) for (int i = (l); i < n; i++)
#define rep_cs(i, l, n) for (int i = (l); i <= n; i++)
#define rep_d(j, n) for (int j = n; j >= 0; j--)
#define rep_d_op(j, n, a) for (int j = n; j >= a; j--)

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 int MOD = 1000000007;
const vector<int> dx = {1, 0};
const vector<int> dy = {0, 1};
const ll INF = 1LL << 60;

// int max = *std::max_element(vec.begin(), vec.end());
// int sum = accumulate(list, list + size, 0);

int GCD(int a, int b) { return b ? GCD(b, a % b) : a; }

using Graph = vector<vector<int>>;
Graph G;
vector<bool> seen;
void dfs(const Graph &G, int v)
{
    seen[v] = true;

    for (auto next_v : G[v])
    {
        if (seen[next_v])
            continue;
        dfs(G, next_v);
    }
}

ll dp[100100];
ll v[110];
ll w[110];

int main()
{
    ll N, K;
    cin >> N >> K;
    ll c[N];
    rep(i, 0, N) cin >> c[i];
    rep(i, 0, 100100) dp[i] = INF;

    dp[0] = 0;

    rep(i, 0, N)
    {
        rep_cs(j, 1, K)
        {
            chmin(dp[i + j], dp[i] + abs(c[i + j] - c[i]));
        }
    }

    cout << dp[N - 1] << endl;
}

Measured memory_bytes: 1792
#include <complex>
#include <cmath>
#include <iostream>
using namespace std;
typedef complex<double> xy_t;

double x[4], y[4];

double cross_product(xy_t a, xy_t b) { return (conj(a)*b).imag(); }

int main() {
  while (true) {
    for (int i=0; i<4; ++i) cin >> x[i] >> y[i];
    if (!cin) break;
    xy_t a(x[0],y[0]), b(x[1],y[1]), c(x[2],y[2]), p(x[3],y[3]);
    double pab = cross_product(a-p,b-p);
    double pbc = cross_product(b-p,c-p);
    double pca = cross_product(c-p,a-p);

    bool ok = pab*pbc>0 && pbc*pca>0;
    cout << (ok ? "YES" : "NO") << endl;
  }
}


Measured memory_bytes: 3104
#include <iostream>
#include <cstdlib>
#include <vector>
#include <queue>
#include <algorithm>

int main() {
    int32_t n, m;
    std::cin >> n >> m;

    std::vector<std::vector<int32_t>> links(n);
    for (int32_t i = 0; i < m; ++i) {
        int32_t a, b;
        std::cin >> a >> b;
        links[a - 1].push_back(b - 1);
        links[b - 1].push_back(a - 1);
    }
    for (int32_t i = 0; i < n; ++i) {
        if (links[i].empty()) {
            std::cout << "No" << std::endl;
            return 0;
        }
        std::sort(links[i].begin(), links[i].end());
        links[i].erase(std::unique(links[i].begin(), links[i].end()), links[i].end());
    }
    
    using R = std::pair<int32_t, int32_t>;
    std::vector<R> rec(n);
    std::fill(rec.begin(), rec.end(), R(std::numeric_limits<int32_t>::max(), -1));
    rec[0] = R(0, 0);
    
    using P = std::pair<int32_t, int32_t>;
    std::queue<P> queue;
    
    queue.push(P(0, 0));
    while(!queue.empty()) {
        const auto& top = queue.front();
        int32_t cost = top.first;
        int32_t index = top.second;
        queue.pop();
        if (rec[index].first < cost) {
            continue;
        }

        for (auto i : links[index]) {
            auto dist = cost + 1;
            
            if (dist < rec[i].first) {
                rec[i].first = dist;
                rec[i].second = index;
                queue.push(P(dist, i));
            }
        }
    }

    std::cout << "Yes" << std::endl;    
    for (auto i = 1; i < n; ++i) {
        std::cout << rec[i].second + 1 << std::endl;
    }
    
    return 0;
}

Measured memory_bytes: 10888
#include <bits/stdc++.h>
#define int long long
using namespace std;
int n,a[100005],cnt;
map<int,int>mp;
signed main(){
  cin>>n;
  for(int i=0;i<n;i++){
    cin>>a[i];
    mp[a[i]]=i;
  }
  sort(a,a+n);
  for(int i=0;i<n;i++){
    if(abs(mp[a[i]]-i)%2)cnt++;
  }
  cout<<cnt/2<<endl;
}

Measured memory_bytes: 7296
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a) for(int i = 0; i < (a); i++)
#define ALL(a) (a).begin(),(a).end()
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1e9;
const long long LINF = 1e18;
const long long MOD = 1e9 + 7;

signed main(){
    int n;
    cin >> n;
    ll a[n];
    REP(i,n){
        cin >> a[i];
    }
    ll sum[n + 1] = {};
    for(int i = 0; i < n; i++){
        sum[i + 1] = sum[i] + a[i];
    }
    int l = 1, r = 3;
    ll ans = LINF;
    for(int i = 2; i <= n - 2; i++){
        while(abs((sum[l] - sum[0]) - (sum[i] - sum[l])) > abs((sum[l + 1] - sum[0]) - (sum[i] - sum[l + 1]))){
            l++;
        }
        while(abs((sum[r] - sum[i]) - (sum[n] - sum[r])) > abs((sum[r + 1] - sum[i]) - (sum[n] - sum[r + 1]))){
            r++;
        }
        ll v[4] = {sum[l] - sum[0], sum[i] - sum[l], sum[r] - sum[i], sum[n] - sum[r]};
        sort(v, v + 4);
        ans = min(ans, v[3] - v[0]);
    }
    cout << ans << endl;
    return 0;
}

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

#include <iostream>
#include <vector>
#include <string>
#include <queue>
#include <deque>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <cmath>
#include <math.h>
#include <tuple>
#include <iomanip>

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

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

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

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

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 nCr(ll n, ll r){
    if(r == 0 || r == n){
        return 1;
    } else if(r == 1){
        return n;
    }
    return (nCr(n - 1, r) + nCr(n - 1, r - 1));
}

ll nPr(ll n, ll r){
    r = n - r;
    ll ret = 1;
    for (ll i = n; i >= r + 1; i--) ret *= i;
    return ret;
}

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

int main(void){
    int n, h, w;
    cin >> n >> h >> w;

    int ans = 0;
    for(int i = 0; i < n; i++){
        int a, b;
        cin >> a >> b;

        if(a >= h && b >= w){
            ans++;
        }
    }

    cout << ans << endl;


}


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

using namespace std;

#define sz(x) ((int) ((x).size()))
typedef long long ll;
typedef long double ld;

int h, w, a, b;
int r[2000][2000], c[2000];

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout << fixed << setprecision(10);
  cin >> h >> w >> a >> b;
  for (int i = 0; i <= h; i++)
    for (int j = 0; j <= w; j++)
      if (i * a + (h - i) * (w - a) == j * b + (w - j) * (h - b)) {
        for (int x = 0; x < w; x++)
          c[x] = x < j ? b : h - b;
        int m = h - b;
        for (int y = h - 1; y >= 0; y--) {
          int z = y < i ? a : w - a;
          while (z && m) {
            for (int x = 0; x < w && z; x++)
              if (!r[x][y] && c[x] == m)
                c[x]--, z--, r[x][y] = 1;
            if (z)
              m--;
          }
        }
        for (int y = 0; y < h; y++) {
          for (int x = 0; x < w; x++)
            cout << r[x][y];
          cout << "\n";
        }
        return 0;
      }
  cout << "-1\n";
}


Measured memory_bytes: 9472
#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>
using namespace std;
#define REP(i,m,n) for(int i=(int)m ; i < (int) n ; ++i )
#define rep(i,n) REP(i,0,n)
typedef long long ll;
typedef pair<int,int> pint;
typedef pair<ll,int> pli;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;
#define SIZE_OF_ARRAY(a) (sizeof(a)/sizeof(a[0]))

unsigned GetDigit(unsigned num){
    return std::to_string(num).length();
}



int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int ans  = 0;
    int A,B,C,X;
    cin >> A;
    cin >> B;
    cin >> C;
    cin >> X;
    int count = 0;
    for(int i = 0;i <= A;i++){
        for(int j = 0;j <= B;j++){
            for(int k = 0;k <= C;k++){
                if(i * 500 + j * 100 + k * 50 == X){
                    ans++;
                }
            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
int main() {
    ll n;
    cin>>n;
    long double p=1;
    int i,j;
    for(i=1;i<=n-2;i++)
      p*=i;
         long double uu=p;
 uu*=(n-1);
 uu*=(n);
    p=(2*(n-1)*p);
    vector<pair<long double,long double>>v;
    while(n--)
    {
       long double x,y;
        cin>>x>>y;
        v.push_back(make_pair(x,y));
    }
    long double sum=0;
    // int i,j;
    for(i=0;i<v.size();i++)
    {
        for(j=i+1;j<v.size();j++)
        {
            long double u=sqrt((v[i].first-v[j].first)*(v[i].first-v[j].first)+((v[i].second-v[j].second)*(v[i].second-v[j].second)));
            sum+=(u*p);
        }
    }
    sum/=uu;
    cout<<fixed<<setprecision(15)<<sum<<endl;

    
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <math.h>
#define _GLIBCXX_DEBUG
#define _LIBCPP_DEBUG 0

using namespace std;
#define ll long long
#define rep(i,n) for (int i = 0; i < n; i++)
#define rrep(i,n) for (int i = n-1; i >= 0; i--)
#define MOD (1000000007)
#define vi vector<int>
#define vl vector<ll>
#define vb vector<bool>
#define vvi vector<vi>
#define vvl vector<vl>
#define pii pair<int, int>
#define pli pair<ll, int>a
#define pb push_back
#define sz(x) int(x.size())

#define mp make_pair
#define all(a) (a).begin(),(a).end()

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

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

ll keta(ll n){
  string s = to_string(n);
  ll num = s.size();
  return num;
}

const ll INF = 1LL << 60;

const int dh[4] = {1,0,-1,0};
const int dw[4] = {0,1,0,-1};

struct Edge{
  int to;
  int weight;
  Edge(int t, int w) : to(t), weight(w){}
};
using Graph = vector<vector<Edge>>;
using P = pair<ll, int>;

// dist[v] に頂点 s から頂点 v への距離を入れる関数
void dijkstra(int s, Graph &G, vector<ll> &dist){
  fill(all(dist), INF);
  dist[s] = 0;

  priority_queue<P, vector<P>, greater<P>> pq;//距離が小さい順に取り出す
  pq.push(P(0,s)); // 頂点 s からスタート

  while (!pq.empty()) {
    P p = pq.top(); pq.pop();
    int v = p.second;
    if(dist[v] < p.first) continue;// 既に v に辿り着く短い経路有ならスルー (これはただの高速化)

    for(auto e : G[v]){// v から行ける頂点 nv 達を走査
      int nv = e.to;
      ll w = e.weight;
      if(dist[nv] > dist[v] + w){
        dist[nv] = dist[v] + w;
        pq.push(P(dist[nv], nv));
      }
    }
  }
}

class UnionFind{
public:
  vi Parent;
  UnionFind(int n){
    Parent = vi(n,-1);
  }

  int root(int a){
    if(Parent[a] < 0) return a;
    else return Parent[a] = root(Parent[a]);
  }

  int size(int a){
    return -Parent[root(a)];
  }

  bool merge(int a, int b){
    a = root(a);
    b = root(b);
    if(a == b) return false;

    if(size(a) < size(b)) swap(a,b);
    Parent[a] += Parent[b];
    Parent[b] = a;

    return true;
  }
};

class Factrial{
public:
  vl Fac;
  Factrial(int MAX){
    Fac = vl(MAX+1);
    rep(i,MAX) {
      if(i == 0) Fac[i] = 1;
      else Fac[i+1] = ((i+1)*Fac[i])%MOD;
    }
  }
};



int main(){
  int n; cin >> n;
  int MAX = 55555;
  vb Prime(MAX+1,true);
  vi ans;
  for(int i = 2; i < MAX+1; i++) {
    if(Prime[i]){
      for(int j = 2*i; j < MAX+1; j += i) {
        Prime[j] = false;
      }
      if(i%5 == 1){
        ans.pb(i);
      }
    }
    if(ans.size() == n) break;
  }

  rep(i,n) cout << ans[i] << " ";
  cout << endl;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
// Begin Header {{{
#define all(x)          (x).begin(), (x).end()
#define rep(i, n)       for (i64 i = 0, i##_limit = (n); i < i##_limit; ++i)
#define reps(i, s, t)   for (i64 i = (s), i##_limit = (t); i <= i##_limit; ++i)
#define repr(i, s, t)   for (i64 i = (s), i##_limit = (t); i >= i##_limit; --i)
#ifndef DBG
#define trace(...)
#endif
using namespace std;
using i64 = int_fast64_t;
using pii = pair<i64, i64>;
template <class T, class U> inline bool chmax(T &a, const U &b) { return b > a && (a = b, true); }
template <class T, class U> inline bool chmin(T &a, const U &b) { return b < a && (a = b, true); }
constexpr int INF  = 0x3f3f3f3f;
constexpr i64 LINF = 0x3f3f3f3f3f3f3f3fLL;

template <class T>
inline vector<T> make_v(const T &initValue, size_t sz) {
    return vector<T>(sz, initValue);
}

template <class T, class... Args>
inline auto make_v(const T &initValue, size_t sz, Args... args) {
    return vector<decltype(make_v<T>(initValue, args...))>(sz, make_v<T>(initValue, args...));
}

inline void read() {}

template <class Head, class... Tail>
inline void read(Head &head, Tail&... tail) { cin >> head; read(tail...); }

inline void print() { cout << "\n"; }

template <class Head, class... Tail>
inline void print(Head &&head, Tail&&... tail) {
    cout << head;
    if (sizeof...(tail)) cout << ' ';
    print(forward<Tail>(tail)...);
}

template <class T>
inline ostream& operator<< (ostream &out, const vector<T> &vec) {
    static constexpr const char *delim[] = { " ", "" };
    for (const auto &e : vec) out << e << delim[&e == &vec.back()];
    return out;
}
// }}} End Header

signed main() {
    ios_base::sync_with_stdio(false); cin.tie(nullptr);

    int N;
    read(N);

    reps(i, 1, 9) {
        int j = N / i;
        if (i * j == N && 1 <= j && j <= 9) {
            print("Yes");
            return 0;
        }
    }

    print("No");

    return 0;
}


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

    vector< vector<ll> > pre_x(N, vector<ll>(1<<N, LONGINF));
    vector< vector<ll> > pre_y(N, vector<ll>(1<<N, LONGINF));
    for(int bit=0; bit<(1<<N); bit++) {
        for(int i=0; i<N; i++) {
            chmin(pre_x[i][bit], abs(X[i] - 0) * P[i]);
            chmin(pre_y[i][bit], abs(Y[i] - 0) * P[i]);
            for(int j=0; j<N; j++) {
                if(!(bit >> j & 1)) continue;
                chmin(pre_x[i][bit], abs(X[i] - X[j]) * P[i]);
                chmin(pre_y[i][bit], abs(Y[i] - Y[j]) * P[i]);
            }
        }
    }
    
    int bx = 0, by = 0;
    vector<ll> ans(N+1, LONGINF);
    auto dfs = [&](auto &&self, int k, int cnt) -> void {
        if(k == N) {
            ll res = 0;
            for(int i=0; i<N; i++) {
                ll ax = pre_x[i][bx];
                ll ay = pre_y[i][by];
                res += min(ax, ay);
            }
            chmin(ans[cnt], res);
            return;
        }

        {
            self(self, k+1, cnt);
        }
        {
            bx ^= (1 << k);
            self(self, k+1, cnt+1);
            bx ^= (1 << k);
        }
        {
            by ^= (1 << k);
            self(self, k+1, cnt+1);
            by ^= (1 << k);
        }
    };
    dfs(dfs, 0, 0);

    for(int i=0; i<=N; i++) printf("%lld\n", ans[i]);
    return 0;
}


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

#define PI (atan(1.0L) * 4)

int N;
typedef complex<long double> Complex;
typedef pair<Complex, int> Pair;
vector<Pair> P, H;
int M;
long double R[100];

long double dot(Complex z, Complex w) {
  return (conj(z) * w).real();
}

long double cross(Complex z, Complex w) {
  return (conj(z) * w).imag();
}

int main() {
  cin >> N ;
  for(int i = 0; i < N; ++i) {
    long double x, y; cin >> x >> y;
    P.push_back({Complex(x, y), i});
  }
  sort(P.begin(), P.end(),
    [](const Pair& p, const Pair& q){
      Complex a = p.first, b = q.first;
      return a.real() < b.real()
        || (a.real() == b.real() && a.imag() < b.imag());
    });
  Complex ref = P.back().first; H.push_back(P.back()); P.pop_back();
  sort(P.begin(), P.end(),
    [ref](const Pair& p, const Pair& q){
      Complex a = ref - p.first, b = ref - q.first;
      return arg(a) < arg(b)
        || (arg(a) == arg(b) && norm(a) < norm(b));
    });
  for(int i = 0; i < N - 1; ++i) {
    while((int)H.size() >= 2) {
      int M = H.size();
      Complex d1 = H[M - 1].first - H[M - 2].first,
        d2 = P[i].first - H[M - 1].first;
      if(cross(d1, d2) > 1.0e-10L) break;
      H.pop_back();
    }
    H.push_back(P[i]);
  }
  M = H.size();
  for(int i = 0; i < M; ++i) {
    Complex a = H[i].first, b = H[(i + 1) % M].first, c = H[(i + 2) % M].first;
    Complex d1 = b - a, d2 = c - b; d1 /= abs(d1); d2 /= abs(d2);
    R[H[(i + 1) % M].second] = acos(max(-1.0L, min(1.0L, dot(d1, d2)))) / (2 * PI);
  }
  for(int i = 0; i < N; ++i) {
    printf("%.10Lf\n", R[i]);
  }
  return 0;
}


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

using namespace std;

using LL = long long;

const int N = (int)2e5 + 5, mod = 998244353;
int n, nString[N << 1], pow2[N];
char x[N];

int add(int a, int b) {
    a += b;
    if (a >= mod) a -= mod;
    return a;
}
int sub(int a, int b) { return add(a, mod - b); }
int mul(int a, int b) { return (int)( (LL)a * b % mod); }

bool check(int per) {
    for (int i = 1; i <= n; ++i) {
        char cur;
        if (i % per) cur = x[i % per];
        else cur = x[per];

        if ( ( (i - 1) / per) & 1) {
            if (cur == '0') cur = '1';
            else cur = '0';
        }

        if (cur != x[i]) return cur < x[i];
    }
    return true;
}

void solve(int per) {
    per /= 2;
    for (int i = 1; i <= per; ++i) {
        if (x[i] == '1') nString[per << 1] = add(nString[per << 1], pow2[per - i]);
    }
    nString[per << 1] = add(nString[per << 1], check(per) );
}

int main() {
    scanf(" %d %s", &n, x + 1);

    pow2[0] = 1; for (int i = 1; i < N; ++i) pow2[i] = (int)(2 * pow2[i - 1] % mod);

    vector<int> divs;
    for (int i = 1; i <= (n << 1); ++i) if ( (n << 1) % i == 0 && ( (n << 1) / i) & 1) {
        solve(i);
        divs.emplace_back(i);
    }

    int ans = 0;
    for (auto per : divs) {
        for (auto per2 : divs) if (per != per2 && per % per2 == 0) nString[per] = sub(nString[per], nString[per2]);
    }
    for (auto per : divs) ans = add(ans, mul(nString[per], per) );

    printf("%d", ans);

    return 0;
}


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

using namespace std;

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define all(obj) (obj).begin(), (obj).end()
#define bit(n) (1LL << (n))

typedef long long ll;

template<class T> inline bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> inline bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

const long long INF = 1LL << 60;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  int x;cin>>x;
  
  if(x==0) cout<<1;
  else cout<<0;
  
  return 0;
}

Measured memory_bytes: 3600
#include <iostream>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <vector>
#include <utility>
#include <numeric>
#include <string>
#include <set>
#include <map>
#include <tuple>
#include <queue>
#include <stack>
#define rep(i, a, n) for(int (i) = (int)(a);(i) < (int)(n);++(i))
#define repe(i, a, n) for(int (i) = (int)(a);(i) <= (int)(n);++(i))
#define repr(i, a, n) for(int (i) = (int)(a);(i) > (int)(n);--(i))
#define reper(i, a, n) for(int (i) = (int)(a);(i) >= (int)(n);--(i))
#define SIZE(x) ((int)(x).size())
#define ALL(x) (x).begin(), (x).end()
#define RNG(x, n) &x[0], &x[n]
#define YES cout << "YES" << endl
#define NO cout << "NO" << endl
#define Yes cout << "Yes" << endl
#define No cout << "No" << endl
#define yes cout << "yes" << endl;
#define no cout << "no" << endl;
#define pb push_back
#define EPS (1e-20)
#define INF 2147483647LL
#define MOD 1000000007LL
using llint = long long;
using VI = std::vector<int>;
using PII = std::pair<int, int>;
using SI = std::set<int>;
using MII = std::map<int, int>;
using TIII = std::tuple<int, int, int>;
using namespace std;


int main(){
	string s;
	int a, b;
	rep(i, 0, 9){
		cin >> s >> a >> b;
		cout << s << ' ' << a+b << ' ' << 200*a+300*b << endl;
	}
	return 0;
}


Measured memory_bytes: 3176
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		//List<String> list= new ArrayList<String>(Arrays.asList(s.split("")));
		//List<Integer> list=new ArrayList<Integer>();
		//Integer[] array = new Integer[m];
		int n = sc.nextInt();
		int t = sc.nextInt();
		int answer=10000;
		for(int i=0;n>i;i++) {
			int a = sc.nextInt();
			int b = sc.nextInt();
			if(b<=t&&a<answer) {
				answer=a;
			}
		}
		if(answer==10000)
			System.out.println("TLE");
		else {
			System.out.println(answer);
		}
	}
}

Measured memory_bytes: 24020
#n = int(input())
n,t = map(int,input().split())
lst1 = list(map(int,input().split()))

ans = 0
start = lst1[0]
now = lst1[0]+t
for i in range(1,n):
    if now > lst1[i]:
        now = lst1[i]+t
    else:
        ans += now - start
        now = lst1[i] + t
        start = lst1[i]

ans += now-start

print(ans)


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

using namespace std;

#define all(x) (x).begin(), (x).end()

typedef long long ll;

void solve(){
	int n;
	cin >> n;
	int ac = 0, wa = 0, tle = 0, re = 0;
	
	while(n--) {
		string s;
		cin >> s;
		if(s == "AC") 
			++ac;
		if(s == "WA") 
			++wa;
		if(s == "TLE")
			++tle;
		if(s == "RE")
			++re;
	}
	
	printf("AC x %d\nWA x %d\nTLE x %d\nRE x %d", ac, wa, tle, re); 
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    
    //~ int t;
	//~ cin >> t;
	//~ while(t--)
	solve();
    
    return 0;
}


Measured memory_bytes: 3728
public class Main {
    public static void main(String[] args) {

        java.util.Scanner sc = new java.util.Scanner(System.in);

        double[] point = new double[4];
        for (int i = 0; i < 4; i ++) { point[i] = sc.nextDouble(); }
        double r = Math.sqrt((point[0] - point[2]) * (point[0] - point[2])
                             + (point[1] - point[3]) * (point[1] - point[3]));
        System.out.print(String.format("%10.8f", r));
    }
}

Measured memory_bytes: 28256
import sys
input = sys.stdin.readline
#from itertools import permutations

def gcd(a: int, b: int):
    """ https://cocodrips.hateblo.jp/entry/2014/03/05/143623
    """
    while b: a, b = b, a%b
    return a

def lcm(a: int, b: int):
    return a * b // gcd(a, b)


def main():
    #N = int(input())
    N,M = map(int, input().split())
    #vP = tuple(map(int, input().split()))
    #vA = list(map(int, input().split()))
    #vA = list(range(1,N+1))
    vS = [input().split() for _ in [0,]*M]
    vN = [False,]*(N+1)
    vW = [0,]*(N+1)

    x,p = 0,0
    for a,s in vS:
        i = int(a)
        v = s=="AC"
        if vN[i]==False:
            if v:
                x += 1
                vN[i] = True
                p += vW[i]
            else:
                vW[i] += 1

    print(x,p)

    #print(l, file=sys.stderr)
    #l //= 2
    #S = input().rstrip()
    #print(S)
    #print(chr(ord(S)+1))
    #print(lcm(N, M))
    #print("Yes" if N<=500*M else "No")
    #print(S.count("ABC"))


if __name__ == "__main__":
    main()


Measured memory_bytes: 33764
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
#define fr(i,n) for(int i=0;i<(n);++i)
#define Fr(i,n) for(int i=1;i<=(n);++i)
#define ifr(i,n) for(int i=(n)-1;i>=0;--i)
#define iFr(i,n) for(int i=(n);i>0;--i)

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    istream& in(cin);
    ostream& out(cout);
    int h,w,k,e=0;
    in>>h>>w>>k;
    vector<vector<char>> s(h,vector<char>(w));
    vector<vector<int>> v(h);
    fr(i,h) fr(j,w){
        in>>s[i][j];
        if(s[i][j]=='#') v[i].emplace_back(j),e=i;
    }
    int c=1;
    vector<vector<int>> ans(h,vector<int>(w,-1));
    fr(i,h){
        if(!v[i].empty()){
            int l=0;
            for(auto j:v[i]){
                while(l<=j){
                    int I=i;
                    while(I>=0&&ans[I][l]==-1) ans[I][l]=c,--I;
                    I=i+1;
                    while(I<h&&v[I].empty()&&ans[I][l]==-1) ans[I][l]=c,++I;
                    ++l;
                }
                ++c;
            }
            --c;
            while(l<w){
                int I=i;
                while(I>=0&&ans[I][l]==-1) ans[I][l]=c,--I;
                I=i+1;
                while(I<h&&v[I].empty()&&ans[I][l]==-1) ans[I][l]=c,++I;
                ++l;
            }
            ++c;
        }
    }
    fr(i,h){
        fr(j,w) cout<<ans[i][j]<<" ";
        cout<<endl;
    }
}

Measured memory_bytes: 1920
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; ++i)
#define REPP(i, n) for(int i = 1; i <= n; ++i)
#define REPR(i, n) for(int i = n-1; i >= 0; --i)
#define FOR(i, m, n) for(int i = m; i < n; ++i)
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
const ll MOD = 1000000007;

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

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n; cin >> n;
    ll sum = 0, i = 1;
    while(sum<n) {
        sum += i;
        ++ i;
    }
    -- i;
    while(n>0) {
        if(n-i>=0) {
            cout << i << '\n';
            n -= i;
        }
        -- i;
    }
    return 0;
}

Measured memory_bytes: 256
#include <cstdio>

static const int MAX = 10000;
static const int NIL = -1;

struct Node
{
  int parent;
  int left;
  int right;
};

Node T[MAX];
int n, D[MAX], H[MAX];

void set_depth(int u, int d)
{
  if (u == NIL)
    return;

  D[u] = d;
  set_depth(T[u].left, d + 1);
  set_depth(T[u].right, d + 1);
}

int set_height(int u)
{
  int h1 = 0, h2 = 0;
  if (T[u].left != NIL)
  {
    h1 = set_height(T[u].left) + 1;
  }
  if (T[u].right != NIL)
  {
    h2 = set_height(T[u].right) + 1;
  }

  H[u] = (h1 > h2 ? h1 : h2);
  return H[u];
}

int get_sibling(int u)
{
  if (T[u].parent == NIL)
    return NIL;

  if (T[T[u].parent].left != u &&
      T[T[u].parent].left != NIL)
    return T[T[u].parent].left;

  if (T[T[u].parent].right != u &&
      T[T[u].parent].right != NIL)
    return T[T[u].parent].right;

  return NIL;
}

void print(int u)
{
  int deg = 0;
  if (T[u].left != NIL)
    ++deg;
  if (T[u].right != NIL)
    ++deg;

  printf("node %d: ", u);
  printf("parent = %d, ", T[u].parent);
  printf("sibling = %d, ", get_sibling(u));
  printf("degree = %d, ", deg);
  printf("depth = %d, ", D[u]);
  printf("height = %d, ", H[u]);

  if (T[u].parent == NIL)
  {
    printf("root\n");
  }
  else if (T[u].left == NIL && T[u].right == NIL)
  {
    printf("leaf\n");
  }
  else
  {
    printf("internal node\n");
  }
}

int main()
{
  int v, l, r, root = 0;
  scanf("%d", &n);

  for (int i = 0; i < n; ++i)
    T[i].parent = NIL;

  for (int i = 0; i < n; ++i)
  {
    scanf("%d %d %d", &v, &l, &r);
    T[v].left = l;
    T[v].right = r;

    if (l != NIL)
      T[l].parent = v;
    if (r != NIL)
      T[r].parent = v;
  }

  for (int i = 0; i < n; ++i)
  {
    if (T[i].parent == NIL)
      root = i;
  }

  set_depth(root, 0);
  set_height(root);

  for (int i = 0; i < n; ++i)
    print(i);

  return 0;
}



Measured memory_bytes: 2724
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(long long i = 0;i < n;i++)
#define repr(i, n) for(int i = n;i >= 0;i--)
#define Sort(v, n) sort(v, v+n);
#define VSort(v) sort(v.begin(), v.end());
#define ll long long
#define pb(a) push_back(a)
#define INF 999999999
#define cY cout<<"Yes";
#define cN cout<<"No";
#define cA(a) cout<<a;
const ll MOD = 1000000007;

int main() {
    int n;
    string s;
    cin>>n>>s;
    rep(i,s.size()) {
        if(s[i] + n <= 'Z') {
            printf("%c",s[i] + n);
        } else {
            printf("%c",s[i] + n -'Z' + 'A' -1);
        }
    }
}

Measured memory_bytes: 256
import copy
n=int(input())
a=[list(map(int,input().split())) for i in range(n)]
b=copy.deepcopy(a)
for k in range(n):
  for i in range(n):
    for j in range(n):
      b[i][j]=min(b[i][j],b[i][k]+b[k][j])
for i in range(n):
  for j in range(n):
    if b[i][j]!=a[i][j]:
      print(-1)
      exit()
ans=0
for i in range(n):
  for j in range(i+1,n):
    m=10**18
    for k in range(n):
      if i==j or j==k or k==i:
        continue
      m=min(m,b[i][k]+b[k][j])
    if m>b[i][j]:
      ans+=b[i][j]
print(ans)

Measured memory_bytes: 57948
use std::io;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let mut s = String::new();
    io::stdin().read_line(&mut s).unwrap();
    s.trim().parse().ok().unwrap()
}
fn read_two<T: FromStr>() -> (T, T) {
    let mut s = String::new();
    io::stdin().read_line(&mut s).unwrap();
    let mut x = s.split_whitespace().map(|x| x.parse().ok().unwrap());
    (x.next().unwrap(), x.next().unwrap())
}

fn main() {
    let (mut a, mut b)= read_two::<i32>();
    a -= 1;
    b -= 1;
    let x = if b % a == 0 {
        b / a
    } else {
        b / a + 1
    };
    println!("{}", x);
}


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

#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
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; }
typedef long long ll;

const long long INF = 1LL << 60;

int main()
{
    string S;
    cin >> S;

    int red = 0, blue = 0;

    rep(i, S.size()) {
        if (S[i] == '1') blue++;
        else red++;
    }

    cout << (int)S.size() - abs(blue - red) << endl;

    return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
int n;
int a[100009];
int main()
{
    cin>>n;
    for(int i=0;i<n;i++)
        cin>>a[i];
        int ans=0;
    while(true)
    {
        for(int i=0;i<n;i++)
        {
         if(a[i]%2){cout<<ans;return 0;}
         a[i]=a[i]/2;
        }
        ans++;
    }

}


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

typedef struct {
  double x;
  double y;
}data;

void koch(int,data,data);

int main(){
  data s,t;
  int n;

  scanf("%d",&n);

  s.x = 0.0;
  s.y = 0.0;
  t.x = 100.0;
  t.y = 0.0;

  printf("%f.8 %f.8\n",s.x,s.y);
  koch(n,s,t);
  printf("%f.8 %f.8\n",t.x,t.y);
  
  return 0;
}

void koch(int n,data p1,data p2){
  data s,t,u;
  if(n == 0) return;

  s.x = (2*p1.x + 1*p2.x)/3.0;
  s.y = (2*p1.y + 1*p2.y)/3.0;
  t.x = (1*p1.x + 2*p2.x)/3.0;
  t.y = (1*p1.y + 2*p2.y)/3.0;
  u.x = (t.x-s.x)*cos(M_PI * 60.0/180.0) - (t.y-s.y)*sin(M_PI * 60.0/180.0) + s.x;
  u.y = (t.x-s.x)*sin(M_PI * 60.0/180.0) + (t.y-s.y)*cos(M_PI * 60.0/180.0) + s.y;
  

  koch(n-1,p1,s);
  printf("%f.8 %f.8\n",s.x,s.y);
  koch(n-1,s,u);
  printf("%f.8 %f.8\n",u.x,u.y);
  koch(n-1,u,t);
  printf("%f.8 %f.8\n",t.x,t.y);
  koch(n-1,t,p2);
}



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

int main() {
  int x1, y1, x2, y2, dx, dy; cin >> x1 >> y1 >> x2 >> y2;
  dx = x2 - x1;
  dy = y2 - y1;
  cout << x2-dy << " " << y2+dx << " " << x1-dy << " " << y1+dx << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <set>

using namespace std;

int main()
{
	int h, w;
	cin >> h >> w;
	vector<string> s(h);
	
	for (int i = 0; i < h; i++) {
		cin >> s[i];
	}
	set<int> hh, ww;
	for (int i = 0; i < h; i++) {
		for (int j = 0; j < w; j++) {
			if (s[i][j] == '#') {
				hh.insert(i);
				ww.insert(j);
			}
		}
	}
	for (int i = 0; i < h; i++) {
		for (int j = 0; j < w; j++) {
			if (hh.find(i) != hh.end() && ww.find(j) != ww.end()) {
				cout << s[i][j];
			}
		}
		if (hh.find(i) != hh.end()) {
			cout << endl;
		}
	}

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
  
  int A, B, C;
  cin >> A >> B >> C;
  if(A + B + C== 17){
	if(A+B-C==3 && A==B)
      cout << "YES" << endl;
    else if (A+B-C==7){
      if (A==C || B==C)
        cout << "YES" << endl;
      else
        cout << "No" << endl;
      }
    else
      cout << "No" << endl;
    }
  else
    cout << "NO" << endl;
}


Measured memory_bytes: 3572
#include<bits/stdc++.h>
#define ll long long int
#define loop(i,a,b) for(ll i=a;i<b;i++)
using namespace std;
int main()
{
	ll n,k;
	cin>>n>>k;
	ll arr[n],cost[n] = {0};
	loop(i,0,n) cin>>arr[i];
	loop(i,1,min(k,n)+1) cost[i] = abs(arr[i]-arr[0]);
	if(n>k+1)
	{
		loop(i,k+1,n)
		{
			ll tcost = 1000000000;
			loop(j,i-k,i)
			{
				if(tcost>cost[j]+abs(arr[i]-arr[j]))
					tcost = cost[j]+abs(arr[i]-arr[j]);
				cost[i] = tcost; 
			}
		}
		cout<<cost[n-1];
	}
	else
	{
		cout<<cost[n-1];
	}
	return 0;
}

Measured memory_bytes: 1792
from math import ceil,floor,comb,factorial,gcd,pow,sqrt,log2,cos,sin,tan,acos,asin,atan,degrees,radians,pi,inf
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from collections import deque,defaultdict,Counter
from bisect import bisect_left,bisect_right
from operator import itemgetter
from heapq import heapify,heappop,heappush
from copy import deepcopy
from time import time
import string
import sys
sys.setrecursionlimit(10 ** 7)
def input() : return sys.stdin.readline().strip()
def INT()   : return int(input())
def MAP()   : return map(int,input().split())
def LIST()  : return list(MAP())

h, w = MAP()
n = INT()
a = LIST()
b = [[0]*w for i in range(h)]
c = deque()

for i in range(n):
    for j in range(a[i]):
        c.append(i+1)

for i in range(h):
    for j in range(w):
        if i % 2 == 0:
            b[i][j] = c.popleft()
        else:
            b[i][w-1-j] = c.popleft()

for i in range(h):
    print(*b[i][:])

Measured memory_bytes: 10480
#include<stdio.h>

int main(void){
    int n,k,s,i;
    scanf("%d%d%d",&n,&k,&s);
    int a[n];
    for(i=0;i<k;i++){
        a[i] = s;
    }
    for(;i<n;i++){
        if(s==1000000000){
            a[i] = 1;
        }else{
            a[i] = 1000000000;
        }
    }
    for(i=0;i<n;i++){
        printf("%d ",a[i]);
    }
    return 0;
}


Measured memory_bytes: 1664
#include<stdio.h>

int main()
{
    int h,w;
    scanf("%d %d", &h, &w);


    while(h!=0 || w!=0) {
      for(int i=1; i<=h; ++i) {
        for(int j=1; j<=(w/2); ++j) {
          if(i%2==0)  printf(".#");
          else        printf("#.");
        }
        if(w%2==1) {
          if(i%2==0) printf(".");
          else       printf("#");
        }

        printf("\n");
      }

      printf("\n");
      scanf("%d %d", &h, &w);
    }

    return 0;
}



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

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

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

int main(){
    vector<int> s(4);
    rep(i, 4){
        cin >> s[i];
    }
    SORT(s);
    if(s == vector<int>{1, 4, 7, 9}){
        cout << "YES" << endl;
    }else{
        cout << "NO" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define F first
#define S second
//-std=c++11
#define print(x) printf("%.12f",x);
#define sz(x) (int)x.size()
#define all(x) (x).begin(), (x).end()
#define Red ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define rep(i, n) for(int i =0 ; i < n; ++i)
#define repr(i, n) for(int i=n-1;i>=0;i--)
#define Rep(i,a,b) for(int i=a;i<=b;i++)
#define Repr(i,a,b) for(int i=a;i>=b;i--)
#define pii pair < int, int >
#define iter ::iterator
#define forit(a) for(it=a.begin();it!=a.end();it++)
typedef vector<int> vi;
typedef  long long ll;
const int inf = int(1e9);
const int mod = 998244353;
const int N = (int)2e5 + 5;




void solve(){
	int n,x;
	cin>>n>>x;
	if(n*500>=x)cout<<"Yes";
	else cout<<"No";	

}


int main(){
	Red;
	int t=1;
	//cin>>t;
	while(t--)
	solve();
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>

using namespace std;

int ans[3];

int main()
{
  int a,b;
  cin >> a >> b;
  
  ans[0]=a+b;
  ans[1]=a-b;
  ans[2]=a*b;
  
  sort(ans,ans+3);
    
  cout << ans[2];
}


Measured memory_bytes: 3632
/*
 89798369704668 guess what it means
 */

#include <iostream>
#include <cmath>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <map>
#include <iomanip>
#include<queue>
#include<memory.h>
#include<sstream>
using namespace std;

const int MOD = 1000000007;
typedef long long ll ; 

int main() {
	//freopen("In.txt","r",stdin); 
	int a , b , c;
	int co = 0 ;
	scanf("%d%d%d" , &a , &b , &c);
	int ta , tb , tc;
	while(a>0 && b>0 && c>0){
		if(a%2 != 0 || b%2 != 0 || c%2 != 0){
			cout<<co<<endl;
			return 0;
		}
		if(a==b && b==c){
			puts("-1");
			return 0;
		}
		ta = b/2 + c/2; 
		tb = a/2 + c/2;
		tc = a/2 + b/2;
		a = ta ; 
		b = tb ; 
		c = tc ;
		co++;
	}
}

Measured memory_bytes: 256
n,m,x=map(int,input().split())
ca=[list(map(int,input().split())) for _ in range(n)]
ans=[-1]*(m+1)
tmp=[0]*(m+1)
for i in range(2**n):
  for j in range(n):
    if (i>>j)&1:
      for k in range(m+1):
        tmp[k]+=ca[j][k]
  for j in range(1,m+1):
    if tmp[j]<x:
      break
  else:
    if ans[0]>tmp[0] or ans[0]<0:
      ans=tmp
  tmp=[0]*(m+1)
print(ans[0])

Measured memory_bytes: 9140
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <set>
#include <string>
#include <vector>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
using ll = long long;
using namespace std;

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

    if(n % 1000 == 0) {
        cout << 0 << endl;
        return 0;
        }

    cout << 1000 - (n % 1000) << endl;
}

Measured memory_bytes: 3632
import sys
from collections import deque


def shave(fwd_link, bwd_link):
    # Vertices having no leaving link
    q = [v for v, links in enumerate(fwd_link) if not links]
    while q:
        v = q.pop()
        for u in bwd_link[v]:
            fwd_link[u].remove(v)
            if not fwd_link[u]:
                q.append(u)
    # Vertices having no entering link
    q = [v for v, links in enumerate(bwd_link) if not links]
    while q:
        v = q.pop()
        for u in fwd_link[v]:
            bwd_link[u].remove(v)
            if not bwd_link[u]:
                q.append(u)


def bfs(s, fwd_link):
    predecessors = [-1] * n
    q = deque()
    for v in fwd_link[s]:
        predecessors[v] = s
        q.append((v, s))
    visited = set()
    while q:
        v, p = q.popleft()
        if v in visited:
            continue
        visited.add(v)
        predecessors[v] = p

        if v == s:
            break

        for u in fwd_link[v]:
            if u not in visited:
                q.append((u, v))

    circuit = {s}
    v = predecessors[s]
    while v != s:
        circuit.add(v)
        v = predecessors[v]

    return predecessors, circuit


def check(predecessors, circuit, fwd_link):
    for v in circuit:
        fwd_link[v].intersection_update(circuit)
        if len(fwd_link[v]) == 1:
            continue
        for u in fwd_link[v]:
            if predecessors[u] != v:
                return u
    return -1


def print_ans(circuit):
    print(len(circuit))
    print(*(v + 1 for v in circuit))


def solve(fwd_link, bwd_link):
    shave(fwd_link, bwd_link)
    s = -1
    for s, (f, b) in enumerate(zip(fwd_link, bwd_link)):
        if f and b:
            break
    else:
        print(-1)
        return

    while True:
        predecessors, circuit = bfs(s, fwd_link)
        res = check(predecessors, circuit, fwd_link)
        if res == -1:
            print_ans(circuit)
            break
        s = res


n, m = map(int, input().split())
fwd_link = [set() for _ in range(n)]
bwd_link = [set() for _ in range(n)]
for line in sys.stdin:
    a, b = map(int, line.split())
    a -= 1
    b -= 1
    fwd_link[a].add(b)
    bwd_link[b].add(a)

solve(fwd_link, bwd_link)


Measured memory_bytes: 4084
while True:
    try:a,b=map(int,input().split())
    except:break
    if a=="" or b==":":
        break
    c=a+b
    ans=0
    if c>=0 and c<=9:
        ans=1
    if c>=10 and c<=99:
        ans=2
    if c>=100 and c<=999:
        ans=3
    if c>=1000 and c<=9999:
        ans=4
    if c>=10000 and c<=99999:
        ans=5
    if c>=100000 and c<=999999:
        ans=6
    if c>=1000000 and c<=9999999:
        ans=7

    print(ans)


Measured memory_bytes: 5592
#define __USE_MINGW_ANSI_STDIO 0
#include <iostream>
#include <string>
#include <vector>
#include <stdio.h>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <set>
#include <numeric>
#include <bitset>
#include <map>
#include <limits.h>
using namespace std;
typedef unsigned long ul;
typedef pair<ul, ul> P;
const int INF = 1e9;

long long gcd(long long x, long long y){
			if(x<y){
				long long temp = x;
			x = y;
				y = temp;
			}
			long long r = x % y;
				while(r!=0){
					x = y;
					y = r;
				r = x % y;
	    		}
			return y;
	    }
int main(){
long long N;
cin >> N;
vector<string> S(N);
for(int i = 0; i < N; i++){
	cin >> S[i];
}
vector<long long> M(5,0);
for(int i = 0; i < N;i++){
	if(S[i][0] == 'M')M[0]++;
	else if(S[i][0] == 'A')M[1]++;
	else if(S[i][0] == 'R')M[2]++;
	else if(S[i][0] == 'C')M[3]++;
	else if(S[i][0] == 'H')M[4]++;
}
long long ans = 0;
ans += M[0]*M[1]*M[2];
ans += M[0]*M[1]*M[3];
ans += M[0]*M[1]*M[4];
ans += M[0]*M[2]*M[3];
ans += M[0]*M[2]*M[4];
ans += M[0]*M[3]*M[4];
ans += M[1]*M[2]*M[3];
ans += M[1]*M[2]*M[4];
ans += M[1]*M[3]*M[4];
ans += M[2]*M[3]*M[4];
cout << ans << endl;


}

Measured memory_bytes: 6144
// -D_GLIBCXX_DEBUG
#include<bits/stdc++.h>
using namespace std;
#define int long long int


int32_t main() {
    int n, a; cin >> n >> a;
    vector<int> arr(n+1, 0);
    for(int i = 1; i <= n; i ++) cin >> arr[i];
    int limit = 2600;
    int l = 51;
    vector<vector<vector<int>>> dp(n+1, vector<vector<int>>(limit, vector<int>(l, 0)));
    dp[0][0][0] = 1;
    for(int i = 1; i <= n; i ++) {
        for(int j = 0; j < limit; j ++) {
            if(j == 0) {
                dp[i][j][0] = 1;
                continue;
            }
            for(int k = 1; k < l; k ++) {
                if((j-arr[i]) >= 0){
                    dp[i][j][k] += dp[i-1][j][k] + dp[i-1][j-arr[i]][k-1];
                }
                else {
                    dp[i][j][k] += dp[i-1][j][k];
                }
            }
        }
    }
    int ans = 0;
    for(int j = 1; j < limit; j ++) {
        for(int k = 1; k < l; k ++) {
            if(dp[n][j][k] && ((j%k) == 0)) {
                int mul = j/k;
                if(mul == a) ans += dp[n][j][k];
            } 
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 61244
#include<stdio.h>
using namespace std;
double dp[3000];

int main()
{
    int N;
    scanf("%d", &N);
    double p_head;
    dp[0] = 1;
    for(int i=0; i<N; i++)
    {
        scanf("%lf", &p_head);
        for(int j = i+1; j>=0; j--)
        {
            dp[j] = (j==0?0:dp[j-1])*p_head + dp[j]*(1-p_head);
        }
    }
    double ans = 0.0;
    for(int i=N/2+1; i<=N; i++)ans += dp[i];
    printf("%.10lf\n", ans);
    return 0;
}

Measured memory_bytes: 128
# _*_ coding:utf-8 _*_
#  Atcoder_Grand_Contest013-A
#  TODO https://atcoder.jp/contests/agc013/tasks/agc013_a


def solveProblem(allNumber,aList):
	flag = "Flat"
	count = 1
	for i in range(allNumber - 1):
		b = aList[i + 1] - aList[i]
		if flag == "Plus":
			if b < 0:
				flag = "Flat"
				count = count+1
		elif flag == "Minus":
			if b > 0:
				flag = "Flag"
				count = count+1
		else:
			if b > 0:
				flag = "Plus"
			elif b < 0:
				flag = "Minus"
	answer = count
	return answer

if __name__ == '__main__':
	N = int(input().strip())
	As = list(map(int,input().split()))
	solution = solveProblem(N,As)
	print("{}".format(solution))

Measured memory_bytes: 14228