akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef int64_t ll;
struct Solution {
    void solve(std::istream& in, std::ostream& out) {
        ll n, a, b;
        string s;
        in >> n >> a >> b;
        in >> s;
        bitset<100005> ans;
        ll sum = 0, sumB = 0;
        for (int i = 0; i < n; i++) {
            switch (s[i]) {
            case 'a':
                if (sum < a + b) {
                    sum++;
                    ans.flip(i);
                }
                break;
            case 'b':
                if (sum < a + b && sumB < b) {
                    sum++;
                    sumB++;
                    ans.flip(i);
                }
                break;
            default:
                break;
            }
        }
        for (int i = 0; i < n; i++) {
            if (ans[i]) {
                out << "Yes" << '\n';
            }
            else {
                out << "No" << '\n';
            }
        }
    }
};
void solve(std::istream& in, std::ostream& out) {
    out << std::setprecision(12);
    Solution solution;
    solution.solve(in, out);
}
#include <fstream>
#include <iostream>
int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    istream& in = cin;
    ostream& out = cout;
    solve(in, out);
    return 0;
}


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

 
int main() {
    int a,b;
    string s;
    cin>>a>>b>>s;

    //sの-の数を数える
    int count=0;
    rep(i,a+b+1){
        if(s[i]=='-')count++;
    }

    if(s[a]=='-'&&count==1)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}

Measured memory_bytes: 256
#include<stdio.h> 
#include<iostream> 
#include<string.h>
#include<cstring>
#include<string>
#include<math.h>
#include<algorithm>
#include<map>
#include<vector>
#include<cmath>
#include<queue>
#include<set>
#define cuttime ios::sync_with_stdio(false)
#define swap(x, y) x ^= y, y ^= x, x^= y
#define INF 0x3f3f3f3f
#define rep(i,a,b) for(int i=(a);i<=(b);++i)
#define dep(i,a,b) for(int i=(a);i>=(b);--i)
#define scan1(x) scanf("%d",&x)
#define scan2(x,y) scanf("%d%d",&x,&y)
#define scan3(x,y,z) scanf("%d%d%d",&x,&y,&z)
#define scanll1(x) scanf("%lld",&x)
#define scanll2(x,y) scanf("%lld%lld",&x,&y)
#define scanll3(x,y,z) scanf("%lld%lld%lld",&x,&y,&z)
#define lowbit(x) (x&(-x))
#define lson l,mid,rt<<1
#define rson mid+1,r,rt<<1|1
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
const int N=2e5+20;
const int MAX=10000007;
inline int read() {
    char c=getchar();int x=0,f=1;
    while(c<'0'||c>'9'){if(c=='-')f=-1;c=getchar();}
    while(c>='0'&&c<='9'){x=x*10+c-'0',c=getchar();}
    return x*f;
}

inline void out(int x) {   
	if(x>9) out(x/10);   
	putchar(x%10+'0'); 
} 
char s[20];
int main(){
	int k;
	cin>>k;
	ll sum=0;
	rep(i,1,k){

		rep(j,1,k){
			rep(o,1,k){
				int ll=__gcd(i,j);
				ll=__gcd(ll,o);
				sum+=ll;
			}
		}
	}
	cout<<sum<<endl;
	return 0;
}

Measured memory_bytes: 3624
#include <algorithm>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <deque>
#include <iostream>
#include <iterator>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

#define FOR(i,k,n) for(int(i)=(k);(i)<(n);++(i))
#define rep(i,n) FOR(i,0,n)
#define all(v) begin(v),end(v)
#define debug(x) std::cerr<<#x<<": "<<x<<"\n"
#define debug2(x,y) std::cerr<<#x<<": "<<x<<", "<<#y<<": "<<y<<"\n"
#define debug3(x,y,z) std::cerr<<#x<<": "<<x<<", "<<#y<<": "<<y<<", "<<#z<<": "<<z<<"\n"

using ll=long long;
using vi=std::vector<int>;
using vvi=std::vector<vi>;
using vll=std::vector<ll>;
using vvll=std::vector<vll>;
template<typename T> using vvec=std::vector<std::vector<T>>;
template<typename T>
auto make_v(size_t sz){return std::vector<T>(sz);}
template<typename T,typename... Ts>
auto make_v(size_t sz,Ts...ts){return std::vector<decltype(make_v<T>(ts...))>(sz,make_v<T>(ts...));}
template<typename T>
void fill_v(T&var,const T&x){var=x;}
template<typename V,typename T>
void fill_v(V&v,const T&x){for(auto&& w:v){fill_v(w,x);}}

template<typename T> std::ostream& operator<<(std::ostream&s,const std::vector<T>&v){
  int sz=v.size();s<<"\n";rep(i,sz){s<<v[i];if(i<sz-1){s<<"\t";}}s<<"\n";return s;}
template<typename T> std::ostream& operator<<(std::ostream&s,const std::vector<std::vector<T>>&v){
  for(auto&& w:v){s<<w;}return s;}
template<typename T> std::ostream& operator<<(std::ostream&s,const std::deque<T>&v){
  int sz=v.size();s<<"\n";rep(i,sz){s<<v[i];if(i<sz-1){s<<"\t";}}s<<"\n";return s;}
template<typename T> std::ostream& operator<<(std::ostream&s,const std::deque<std::deque<T>>&v){
  for(auto&& w:v){s<<w;}return s;}
template<typename T> std::ostream& operator<<(std::ostream&s, const std::set<T>&v){
  s<<"\n";for(auto&& elm:v){s<<elm<<"\t";}s<<"\n";return s;}

inline void scan(int&a){scanf("%d",&a);}
inline void scan(ll&a){scanf("%lld",&a);}
inline void scan(char&a){scanf(" %c",&a);}
inline void scan(double&a){scanf("%lf",&a);}
template<typename T>
inline void scan(std::vector<T>&v){for(auto&& sv:v){scan(sv);}}
template<typename First,typename...Args>
inline void scan(First&f,Args&...args){scan(f);scan(args...);}
inline void scan(std::string&s){char BUF[3000000];scanf(" %s",BUF);s=std::string(BUF);}
inline void print(int a){printf("%d\n",a);}
inline void print(ll a){printf("%lld\n",a);}
inline void print(double a){printf("%.12f\n",a);}
inline void print(std::string s){std::cout<<s<<"\n";}

using namespace std;

int main() {
  string n;
  scan(n);
  if ((n[0] == n[1] && n[1] == n[2]) || (n[1] == n[2] && n[2] == n[3])) {
    print("Yes");
  } else {
    print("No");
  }

  return 0;
}


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

int main() {
  string s;
  cin >> s;
  string H = "Heisei";
  string T = "TBD";
  if (s > "2019/04/30") {
    cout << T << endl;
  }
  else {
    cout << H << endl;
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
    long long x, a = 0;
    cin >> x;
    a += (x / 11) * 2;
    x %= 11;
    if (x > 6) a += 2;
    else if (x > 0) a++;
    cout << a;
}

Measured memory_bytes: 3584
#include <iostream>
#include <vector>

int main() {
    int n;
    std::cin >> n;
    std::vector<int> b(n - 1);
    for (int i = 0; i < n - 1; i++) {
        std::cin >> b[i];
    }

    int ans = b[0] + b[n - 2];
    for (int i = 0; i < n - 2; i++) {
        ans += std::min(b[i], b[i + 1]);
    }

    std::cout << ans << std::endl;

    return 0;
}


Measured memory_bytes: 256
let n, k, r, s, p = Scanf.scanf " %d %d %d %d %d" @@ fun a b c d e -> a, b, c, d, e
let ts = Array.init n @@ fun _ -> Scanf.scanf " %c" @@ fun c -> c
let us = Array.make n ' '
let ans = ref 0
let f = function 'r' -> 'p' | 's' -> 'r' | _ -> 's'
let g t u = List.(filter (fun x -> x <> t && x <> u) ['r'; 's'; 'p'] |> hd)
let h = function 'r' -> r | 's' -> s | _ -> p
let _ = Array.iteri (fun i t -> us.(i) <- if i - k >= 0 && us.(i - k) = f t then g t @@ if i + k < n then f ts.(i + k) else f t else (ans := !ans + h (f t); f t)) ts; Printf.printf "%d\n" !ans

Measured memory_bytes: 6016
#include <bits/stdc++.h>
using namespace std;
struct Edge {
    int to;     // 辺の行き先
    int weight; // 辺の重み
    Edge(int t, int w) : to(t), weight(w) { }
};
using Graph = vector<vector<Edge>>;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define reprep(i,j,h,w) rep(i,h)rep(j,w)
#define rrep(i,m, n) for(int i = m; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define aall(x,n) (x).begin(),(x).begin()+(n)
#define VEC(type,name,n) std::vector<type> name(n);rep(i,n)std::cin >> name[i];
#define pb push_back
#define pf push_front
#define lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#define sum accumulate
#define keta fixed<<setprecision
#define vvector(name,typ,m,n,a)vector<vector<typ> > name(m,vector<typ> (n,a))
#define vvvector(name,t,l,m,n,a) vector<vector<vector<t> > > name(l, vector<vector<t> >(m, vector<int>(n,a)));
typedef long long ll;
const int INF = 2000000000;
const long INF64 = 1000000000000000ll;
const ll MOD = 1000000007LL;
typedef unsigned int uint;
int main(){
  string s;
  std::cin >> s;
  std::vector<int> a;
  rep(i,s.size())a.pb(s[i]-'0');
  int ans,d=INF;
  rep(i,s.size()-2){
    int dum=a[i]*100+a[i+1]*10+a[i+2];
    if(abs(753-dum)<d){
      ans=dum;
      d=abs(753-dum);
    }
  }
  std::cout << d << std::endl;
}


Measured memory_bytes: 256
<?php
list($sx, $sy, $tx, $ty) = explode(' ', trim(fgets(STDIN)));
$x = abs($tx - $sx);
$y = abs($ty - $sy);

//root1
echo str_repeat('U', $y);
echo str_repeat('R', $x);
echo str_repeat('D', $y);
echo str_repeat('L', $x);

//root2
echo 'L';
echo str_repeat('U', $y + 1);
echo str_repeat('R', $x + 1);
echo 'D';
echo 'R';
echo str_repeat('D', $y + 1);
echo str_repeat('L', $x + 1);
echo 'U';
?>

Measured memory_bytes: 4604
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define countof(array) (sizeof(array) / sizeof(array[0]))
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = (n)-1; i >= 0; --i)
#define rep2(i,n) for(int i = 1; i <= (n); ++i)
#define rrep2(i,n) for(int i = (n); i > 0; --i)
#define srep(i,s,n) for(int i = s; i < (n); ++i)
#define rsrep(i,s,n) for(int i = (n)-1; i >= s; --i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define aall(a) (a), (a)+countof(a)//for array sorting
#define raall(a) (a), (a)+countof(a), greater<>()
#define show(x) cout<<#x<<" = "<<(x)<<endl;
#define vfind(v, a) find(all(v), a) != v.end()
#define yn(f) { if (f) puts("YES"); else puts("NO"); }
#define yns(f) { if (f) puts("Yes"); else puts("No"); }
#define show_ary(...) { cout<<#__VA_ARGS__<<" = "; for (const auto& x : (__VA_ARGS__)) { cout<<x<<" "; } cout<<endl; }
#define show_pair(...) cout<<#__VA_ARGS__<<" = "<<endl; for (const auto& x : (__VA_ARGS__)) { cout<<"  "<<x.fi<<" : "<<x.se<<endl; }
#define out_ary(...) { int n = (__VA_ARGS__).size(); rep(i, n) printf("%d%s", (__VA_ARGS__)[i], i != n-1 ? " " : "\n"); }
#define argmax(v) distance((v).begin(), max_element(all(v)))
#define argmin(v) distance((v).begin(), min_element(all(v)))
#define vmax(v) *max_element(all(v))
#define vmin(v) *min_element(all(v))
typedef long long int ll;
typedef pair<int, int> P;
typedef vector<P> vpair;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<double> vdouble;
typedef vector<string> vstr;
typedef vector<bool> vbool;
typedef vector<vint> vvint;
typedef vector<vll> vvll;
typedef vector<vstr> vvstr;
typedef vector<vbool> vvbool;
const ll LINF = 2000000000000000000ll;
const int INF = 1000000100;
const ll MOD = 1e9+7;


int main() {
    int l, r;
    cin >> l >> r;
    ll ans = LINF;
    srep(i, l, r) {
        srep(j, i+1, r+1) {
            ll num = ((ll)i*(ll)j)%2019;
            if (num == 0) {
                puts("0");
                return 0;
            }
            ans = min(ans, num);
        }
    }

    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <utility>
#include <vector>
#include <cmath>
#include <algorithm>
#include <string>
using namespace std;
typedef long long ll;

ll mod = 1e9 + 7;

// 正方行列同士の掛け算
vector <vector<ll>> matmul(vector<vector<ll>> &a, vector<vector<ll>> &b) {
  int n = a.size();
  vector<vector<ll>> res(n, vector<ll>(n));
   for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      for(int k = 0; k < n; k++) {
         res[i][j] = (res[i][j] + a[i][k] * b[k][j]) % mod;
      }
    }
  }
  return res;
}

vector<vector<ll>> matpow(vector<vector<ll>> &a, ll m) {
  int n = a.size();
  vector<vector<ll>> res(n, vector<ll>(n));
  for (int i = 0; i < n; i++) {
    res[i][i] = 1;
  }
  vector<vector<ll>> b(a);
  while (m > 0) {
    if (m & 1) {
      res = matmul(res, b);
    }
    b = matmul(b, b);
    m = m >> 1;
  }
  return res;
}

int main() {
  ll n, k;
  cin >> n >> k;
  vector <vector<ll>> a(n, vector<ll>(n));
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
       int k;
       cin >> k;
       a[i][j] = k;
    }
  }

  vector <vector<ll>> dp(n, vector<ll>(n));
  for (int i = 0; i < n; i++) {
    dp[i][i] = 1;
  }
  // dp = matmul(dp, a);
  dp = matpow(a, k);
  ll ans = 0;
   for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      // cout << "i: " << i << endl;
      // cout << "j: " << j << endl;
      // cout << dp[i][j] << endl;
      // cout << a[i][j] << endl;
      ans = (ans + dp[i][j]) % mod;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 384
#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
#define int long long

signed main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int H, W;
    cin >> H >> W;
    if (H % 3 == 0 || W % 3 == 0) {
        cout << 0 << endl;
        return 0;
    }
    int ans = min(H, W);
    rep(k, 2) {
        for(int i = max(0LL, H / 3 - 1000); i <= min(H, H / 3 + 1000); i++) {
            for(int j = 0; j <= W; j++) {
                int S1 = W * i;
                int S2 = j * (H - i);
                int S3 = (W - j) * (H - i);
                ans = min(ans, max({S1, S2, S3}) - min({S1, S2, S3}));
            }
        }
        swap(H, W);
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<math.h>
#include<queue>
#include<vector>
#include<climits>
#include<map>
#include<string>
#include<functional>
#include<iomanip>
#include<deque>
#include<random>
#include<set>
#include<bitset>
#include<cassert>

using namespace std;
typedef long long ll;
typedef double lldo;
#define mp make_pair
#define pub push_back
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define sz(x) int(x.size())
ll gcd(ll a, ll b) { if (a % b == 0) { return b; } else  return gcd(b, a % b); }
ll lcm(ll a, ll b) { if (a == 0) { return b; }return a / gcd(a, b) * b; }
template<class T>ll LBI(vector<T>& ar, T in) { return lower_bound(ar.begin(), ar.end(), in) - ar.begin(); }
template<class T>ll UBI(vector<T>& ar, T in) { return upper_bound(ar.begin(), ar.end(), in) - ar.begin(); }

ll d, c[30] = {}, s[370][30] = {}, last[30] = {}, ans[370] = {};

int main() {
	cin >> d;
	rep(i, 26)cin >> c[i];
	rep(i, d) {
		rep(j, 26)cin >> s[i][j];
	}
	rep(i, d) {
		ll satisfaction = -1000000, contest = 0;
		rep(j, 26) {
			if (satisfaction < s[i][j] - c[j] * (i - last[j])) {
				satisfaction = s[i][j] - c[j] * (i - last[j]);
				contest = j;
			}
			ans[i] = contest;
			last[contest] = i;
		}
	}
	rep(i, d)cout << ans[i] + 1 << endl;
	return 0;
}

Measured memory_bytes: 3724
N=int(input())
mod=10**9+7
dp=[0]*N
idx=dict()
idx[int(input())]=0
dp[0]=1
for i in range(1,N):
    C=int(input())
    if C in idx.keys():
        if idx[C]<i-1:
            dp[i]=(dp[idx[C]]+dp[i-1])%mod
        else:
            dp[i]=dp[i-1]
    else:
        dp[i]=dp[i-1]
    idx[C]=i
print(dp[-1])

Measured memory_bytes: 34196
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
template<class T,class U> using P = pair<T,U>;
template<class T> using vec = vector<T>;
template<class T> using vvec = vector<vec<T>>;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
const int INF = 1001001001;
 
int orsum(int x, int y) {
  int ans = 0;
  int count = 0;
  while(true) {
    if (x==0 && y==0) break;
    if (x%2==1 || y%2==1) ans += pow(2, count);
    x /= 2;
    y /= 2;
    count++;
  }
  return ans;
}

int main(){
  int n, m;
  cin >> n >> m;
  vec<int> a(m), b(m);
  vec<int> c(m);
  vec<int> dp(1<<n, INF);
  dp[0] = 0;
  rep(i, m) {
    cin >> a[i] >> b[i];
    rep(j, b[i]) {
      int tmp;
      cin >> tmp;
      c[i] += pow(2, tmp-1);
    }
  }  
  // cout << (2 | 6) << endl;
  rep(j, 1<<n) rep(i, m){
    dp[j | c[i]] = min(dp[j] + a[i], dp[j | c[i]]);
  }
  int ans = dp[(1<<n) -1];
  if (ans == INF) cout << -1 << endl;
  else cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#pragma GCC optimize("Ofast")
using namespace std;
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
typedef long long ll;
#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REP(i,num,n) for(int i=num, i##_len=(n); i<i##_len; ++i)
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; }
#define print(x) (cout << (x) << endl)
#define pb push_back
#define mp make_pair
#define sz(x) int(x.size())
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
#define fs first
#define sc second

const int INF = 1e9;
const ll LLINF = 1e16;
const ll MOD = 1e9+7;
template<class T> inline void add(T &a, T b){a = ((a+b) % MOD + MOD) % MOD;};

template<typename T>
vector<T> make_v(size_t a){return vector<T>(a);}
 
template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
  return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}
 

// 指定した文字cが文字列に何文字入ってるか
ll stringcount(string s, char c) {
    return count(s.cbegin(), s.cend(), c);
}


// 割り算の切り上げ処理
template<typename T>
T rp(T a, T b) {
  return (a + b - 1) / b;
}

// 桁和
template<typename T>
T digsum(T n) {
    T res = 0;
    while(n > 0) {
        res += n%10;
        n /= 10;
    }
    return res;
}

// 回文判定
bool kai (string s) {
    string t{s};
    reverse(begin(t), end(t));
    return s == t;
}

using pint = pair<int, int>;
using pll = pair<ll, ll>;


template <class Abel> struct BIT {
    const Abel UNITY_SUM = 0;                       // to be set
    vector<Abel> dat;
    
    /* [1, n] */
    BIT(int n) : dat(n + 1, UNITY_SUM) { }
    void init(int n) { dat.assign(n + 1, UNITY_SUM); }
    
    /* a is 1-indexed */
    inline void add(int a, Abel x) {
        for (int i = a; i < (int)dat.size(); i += i & -i)
            dat[i] = dat[i] + x;
    }
    
    /* [1, a], a is 1-indexed */
    inline Abel sum(int a) {
        Abel res = UNITY_SUM;
        for (int i = a; i > 0; i -= i & -i)
            res = res + dat[i];
        return res;
    }
    
    /* [a, b), a and b are 1-indexed */
    inline Abel sum(int a, int b) {
        return sum(b - 1) - sum(a - 1);
    }
    
    /* debug */
    void print_debug() {
        for (int i = 1; i < (int)dat.size(); ++i) cout << sum(i, i + 1) << ",";
        cout << endl;
    }
};

int main(void)
{
    cout.tie(0);
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);
    int n,q;
    cin >> n >> q;
    BIT<int> a(n);
    rep(i, q){
        int c,x,y;
        cin >> c >> x >> y;
        if(c == 0){
            a.add(x, y);
        } else {
            print(a.sum(x, y + 1));
        }
    } 


}




Measured memory_bytes: 3344
# -*- coding: utf-8 -*-

s = str(raw_input())
q = int(raw_input())
for i in range(q):
    line = map(str, raw_input().split())
    com = line[0]
    a = int(line[1])
    b = int(line[2])
    if com == "print":
        print s[a:b+1]
    elif com == "reverse":
        tmp = s[::-1]
        s = s[:a] + tmp[len(tmp)-b-1:len(tmp)-a] + s[b+1:]
    elif com == "replace":
        p = line[3]
        s = s[:a] + p + s[b+1:]
    else:
        print "Error"

Measured memory_bytes: 6468
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const static ll INF = 1e9;
const static ll MOD = 1e9+7;



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

    ll cnt = 1;
    if(A+2 >= B){
        cout << K+1 << endl;
        return 0;

    }

    else{
        for(int i = 0; i < K; i++){
            if(cnt == A) {
                int itr = (K-i)/2;
                int p = (K-i)%2;
                if(p == 1){
                    cnt += itr*(B-A) + 1;
                }
                else{
                    cnt += itr*(B-A);
                }
                break;
            }
            else cnt++;
        }
        cout << cnt << endl;
    }


}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
const double PI = 4*atan(1);
const int MOD = 1000000007;
const int INF = 0x3f3f3f3f;
const ll LINF = 0x3f3f3f3f3f3f3f3f;
const double EPS = 1e-9;
const string YES = "Possible";
const string NO = "Impossible";
#define pb push_back
#define mp make_pair

const int MAX_N = 1e5 + 12;
int N;
int M, K;
int A[MAX_N],B[MAX_N],C[MAX_N],D[MAX_N];
int par[MAX_N], sz[MAX_N];
int ans[MAX_N];
vector<int> g[MAX_N];

void init()
{
	for(int i=1;i<=N;++i){
		par[i] = i;
		sz[i] = 1;
	}
}

int look(int x)
{
	if(x == par[x]) return x;
	else return par[x] = look(par[x]);
}

void comb(int x, int y)
{
	int a = look(x), b = look(y);
	if(a != b){
		par[b] = a;
		sz[a] += sz[b];
	}
}

void solve()
{
	init();
	for(int i=0;i<M;++i){
		g[A[i]].push_back(B[i]);
		g[B[i]].push_back(A[i]);
		comb(A[i],B[i]);
	}
	for(int i=1;i<=N;++i) ans[i] = sz[look(i)]-g[i].size()-1;
	for(int i=0;i< K;++i){
		int c=C[i],d=D[i];
		if(look(c) == look(d)){
			ans[c]--, ans[d]--;
		}
	}
	for(int i=1;i<=N;++i) cout << ans[i] << ' ';
	cout << '\n';
}

int main()
{
	ios::sync_with_stdio(false);
	cin >> N >> M >> K;
	for(int i=0;i<M;++i){
		cin >> A[i] >> B[i];
	}
	for(int i=0;i<K;++i){
		cin >> C[i] >> D[i];
	}
	solve();
	return 0;
}

Measured memory_bytes: 10104
#include<bits/stdc++.h>
#define ll                    long long int
#define pb                    push_back
#define F                     first
#define S                     second
#define mp                    make_pair
#define MOD                   1000000007
#define vi                    vector<int>
#define vll                   vector<ll>
#define pll                   pair<ll,ll>
#define pii                   pair<int,int>
#define all(p)                p.begin(),p.end()
#define mid(s,e)              (s+(e-s)/2)
#define eb                    emplace_back
#define ull                   unsigned long long
#define KAMEHAMEHA            ios_base::sync_with_stdio(0);
#define RASENGAN              ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
using namespace std;
int main()
{
    KAMEHAMEHA
//    #ifdef _soumik
//        freopen("input.txt", "r", stdin);
//    #endif
    int n,m;
    cin>>n>>m;
    if(n==m)
        cout<<"Yes"<<endl;
    else
        cout<<"No"<<endl;
    return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <sstream>

using namespace std;

int main(){
    unsigned int N;
    cin >> N;
    vector<unsigned int> H(N);
    for(int i = 0; i < N; i++)  cin >> H[i];

    unsigned int maxH, sum;
    
    /* i = 1 */
    maxH = H[0];
    sum = 1;

    for(int i = 1; i < N; i++){
        if(H[i] >= maxH){
            sum++;
            maxH = H[i];
        }
    }

    cout << sum << endl;

    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <algorithm>
int main(){
	int n;
	scanf("%d", &n);
	long long a[200000];
	long long b[200000];
	int c[200000];
	int m;
	for (int i = 0; i < n; i++) {
		scanf("%lld", a + i);
	}
	std::sort(a, a + n);
	long long r[31];
	int l, u, k=0;
	r[0] = 1;
	for (int i = 1; i < 31; i++)r[i] = r[i - 1] * 2;
	for (int i = 0; i < 30; i++) {
		m = 0;
		for (int j = 0; j < n; j++) {
			if (a[j] % r[i] == 0 && a[j] / r[i] % 2) {
				b[m] = a[j] / r[i];
				m++;
			}
		}
		std::sort(b, b + m);
		for (int j = 0; j < m; j++)c[j] = 0;
		for (int j = 30; j > 0; j--) {
			l = 0; u = m - 1;
			while (u - l >= 1) {
				if (b[u] + b[l] == r[j] && !c[u] && !c[l]) {
					k++;
					c[u] = 1;
					c[l] = 1;
					l++;
					u--;
				}
				else {
					if (!c[u] && !c[l]) {
						if (b[u] + b[l] < r[j])l++;
						else u--;
					}
					else {
						if (c[u])u--;
						if (c[l])l++;
					}
				}
			}
		}
	}
	printf("%d\n", k);
	return 0;
}

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

int main() {
  int H,W;
  cin >> H>>W;
  vector<vector<string>> data(H+2, vector<string>(W+2,"#"));
  for (int i=1; i<H+1; i++){
        string k;
        cin>>k;
        for (int j=1; j<W+1; j++){
            data.at(i).at(j)=k.at(j-1);
        }
    }
    for (int i =0; i<H+2; i++){
        for(int j =0; j<W+2; j++){ 
          cout<<data.at(i).at(j);     

          if (j==W+1){
          cout<<endl;
          }


        }
      }
      cout<<endl;


}
   


Measured memory_bytes: 3812
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0, i##_len = (n); i < i##_len; ++i)
#define REPS(i, n) for(int i = 1, i##_len = (n); i < i##_len; ++i)
#define ALL(x) (x).begin(), (x).end()
#define PRINT(A) std::cout << (#A) << ":" << (A) << std::endl;

typedef long long int ll;
const int MOD = 2019;
const int INF = 1e9;

using namespace std;

int main() {
  ll L, R;
  cin >> L >> R;

  int start = L % MOD;
  int end = R % MOD;

  if(start >= end || R - L + 1 >= MOD) {
    cout << 0 << endl;
    return 0;
  }

  int ans = INF;
  for(int i = start; i < end; i++) {
    for(int j = i + 1; j <= end; j++) {
      int x = i * j % MOD;
      if(x < ans) {
        ans = x;
      }
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const long INF=1000000000000000;

int main() {
    long N;
    cin>>N;
    long ans=0;
    for(int i=0;i<N;i++){
        long l,r;
        cin>>l>>r;
        ans+=r-l+1;
    }
    
    cout<<ans<<endl;
    
}

Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<cstdlib>
#include<cmath>
#include<string>
using namespace std;

int main(){
    int x;
    int cnt = 0;
    cin >> x;

    if(x == 2){
        cout << 2 <<endl;
        return 0;
    }

    for(int i=0;i<10000000;i++){
        for(int j=2;j<x+i;j++){
           if((x+i)%j==0){
               break;
           }
           else{
               cnt += 1;
           }
           if(cnt==x+i-2){
               cout << x+i << endl;
               return 0;
           }
        }
    }
}



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

using namespace std;

struct Point {
    double x, y;
    Point(double x, double y) : x(x), y(y) {}
    Point() {}
};
bool operator<(const Point &p1, const Point &p2) {
    return (p1.x < p2.x) || (p1.x == p2.x && p1.y < p2.y);
}
bool compare_y(const Point &p1, const Point &p2) {
    return p1.y < p2.y;
}

double ClosestPair(vector<Point>::iterator begin, vector<Point>::iterator end) {
    const int n = end - begin;
    if (n <= 1)
        return numeric_limits<double>::max();
    int m = n / 2;
    double x = (begin + m)->x;
    double d = min(ClosestPair(begin, begin + m), ClosestPair(begin + m, end));
    inplace_merge(begin, begin + m, end, compare_y);

    vector<Point> b;
    for (auto it = begin; it != end; ++it) {
        if (d <= abs(it->x - x))
            continue;

        for (size_t i = 0; i < b.size(); ++i) {
            double dx = it->x - b[b.size() - i - 1].x;
            double dy = it->y - b[b.size() - i - 1].y;
            if (d <= dy)
                break;
            d = min(d, sqrt(dx * dx + dy * dy));
        }
        b.emplace_back(*it);
    }

    return d;
}

double Solve(vector<Point> &p) {
    sort(p.begin(), p.end());
    return ClosestPair(p.begin(), p.end());
}

int main()
{
    int n;

    scanf("%d", &n);
    vector<Point> p(n);
    for (int i = 0; i < n; ++i)
        scanf("%lf %lf", &p[i].x, &p[i].y);

    printf("%.9f\n", Solve(p));

    return 0;
}

Measured memory_bytes: 7600
//be naame khodaa
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair <int, int> pii;
#define F first
#define S second

inline int in(){int x, y; y = scanf("%d", &x); return x; }

const int N = 200002, E = 200002;

vector <int> g[N], cvs;
vector <pair<int, int>> ces;
int up[N], h[N], from[E], to[E];
bool mark[N];

int cecvme(int v, int pare = -1) // With multiple edge
{
	up[v] = h[v];
	mark[v] = true;
	int children = 0;
	for(int e : g[v])
		if(e != pare)
		{
			int u = to[e] ^ from[e] ^ v;
			if(mark[u])
				up[v] = min(up[v], h[u]);
			else
			{
				h[u] = h[v] + 1;
				up[v] = min(up[v], cecvme(u, e));
				if(up[u] >= h[v] && pare != -1)
					cvs.push_back(v);
				children++;
			}
		}
	if(pare != -1 && up[v] == h[v])
		ces.push_back({from[pare], v}); // pare
	if(pare == -1 && children > 1)
		cvs.push_back(v);
	return up[v];
}
 
int cecv(int v, int par) // Without multiple edge
{
	up[v] = h[v];
	mark[v] = true;
	int children = 0;
	for(int u : g[v])
	{
		if(mark[u] && u != par)
			up[v] = min(up[v], h[u]);
		if(!mark[u])
		{
			h[u] = h[v] + 1;
			up[v] = min(up[v], cecv(u, v));
			if(up[u] >= h[v] && h[v] > 0)
				cvs.push_back(v);
			children++;
		}
	}
	if(h[v] > 0 && up[v] == h[v])
		ces.push_back({par, v});
	if(h[v] == 0 && children > 1)
		cvs.push_back(v);
	return up[v];
}

int main()
{
	h[0] = 0;
	int n = in(), m = in();
	for(int i = 0; i < m; i++)
	{
		int u = in(), v = in();
		g[u].push_back(v);
		g[v].push_back(u);
		from[i] = u;
		to[i] = v;
	}
	cecv(0, -1);
	for(auto &e : ces)
		if(e.first > e.second)
			swap(e.first, e.second);
	sort(ces.begin(), ces.end());
	for(auto e : ces)
		cout << e.first << " " << e.second << endl;
}



Measured memory_bytes: 9724
n = int(input())
h = list(map(int, input().split()))

if n == 1:
    print('Yes')
else:
    for i in range(n-1, 0, -1):
        if i == 1:
                print('Yes')
        else:
            if h[i] - h[i-1] == -1:
                h[i-1] -= 1
            elif h[i] - h[i-1] < -1:
                print('No')
                break


Measured memory_bytes: 14396
#include<bits/stdc++.h>
#define ll long long
#define dbg(x) cout<<#x<<": "<<x<<endl;
#define N 300005
#define M 1000000007
#define pii pair<ll,ll>
#define fast ios_base::sync_with_stdio(0);cin.tie(0);
using namespace std;
main()
{
    string s,t;
    cin>>s>>t;
    int c=0;
    int n=s.size();
    for(int i=0;i<n;i++)
    {
        if(s[i]!=t[i])
            c++;
    }
    cout<<c;
}



Measured memory_bytes: 3916
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<utility>
#include<queue>
using namespace std;
int MAX = 9999999;
int mod = 10007;
//---------------------------------------------------------------------------
long long n,fig[110];
long long dp[110][23] = {};
long long sol(long long f, long long s) {
	if (dp[f][s] != -1)return dp[f][s];
	if (f == n - 1) {
		if (s == fig[n-1])return dp[f][s] = 1;
		else return dp[f][s] = 0;
	}
	long long tmp = 0;
	if (s - fig[f] >= 0) {
		tmp += sol(f + 1, s - fig[f]);
	}
	if (s + fig[f] <= 20) {
		tmp += sol(f + 1, s + fig[f]);
	}
	return dp[f][s] = tmp;
}


int main() {
	cin >> n;
	for (int i = 0; i < 110; i++) {
		for (int j = 0; j < 23; j++)dp[i][j] = -1;
	}
	for (int i = 0; i < n; i++) {
		cin >> fig[i];
	}

	cout << sol(1, fig[0]) << endl;
	return 0;
}



Measured memory_bytes: 3092
#include <bits/stdc++.h>
#define rep(i, start, end) for (long long i = start; i < end; ++i)
#define repreverse(i, start, end) for (long long i = start; i >= end; --i)
#define all(x) (x).begin(), (x).end()
#define len(x) ((long long)(x).size())
#define g(a, b) __gcd((a), (b))
#define l(a, b) ((a) / __gcd((a), (b)) * (b))
using namespace std;
using ll = long long;
using ld = long double;
using vll = vector<ll>;
using vllvll = vector<vll>;
using pll = pair<ll, ll>;
template<class T>void print1d(T x,ll n=-1){if(n==-1)n=x.size();rep(i,0,n){cout<<x[i]<<' ';}cout<<'\n';}
template<class T>void print2d(T x,ll r=-1,ll c=-1){if(r==-1)r=x.size();if(c==-1)c=x[0].size();rep(i,0,r)print1d(x[i],c);}
template<class T, class U>bool haskey(T mp, U key) { return mp.find(key) != mp.end(); }
template<class T, class U>bool isin(T el, U container) { return find(all(container), el) != container.end(); }
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; }
template<class T, class U>T rem(T a, U b) { return a - b*floor(a/b); }
template<class T>ld deg2rad(T deg) { return M_PI * deg / 180.0; }
template<class T>ld rad2deg(T rad) { return 180.0 * rad / M_PI; }
const long double pi = M_PI;
const long long big = 1LL << 50;
const long long inf = 1LL << 60;
const long long mod = 1e9 + 7;



int main()
{
        ll N;
        cin >> N;
        map<ll, ll> mp;
        rep(i, 0, N) {
                ll a;
                cin >> a;
                mp[a]++;
        }
        ll sm = 0;
        for (auto el : mp) {
                ll cnt = el.second;
                if (cnt % 2 == 1) sm++;
        }
        cout << sm << endl;
}

Measured memory_bytes: 6528
#include<bits/stdc++.h>
#define ll long long int
#define ull unsigned long long 
#define ff first
#define ss second
#define fast ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define pb push_back 
#define mp make_pair
#define inf 2000000009
#define mod 1000000007
using namespace std;

int main()
{ 
ll n,s=0;
cin>>n;

ll a[n];
for(ll i=0;i<n;i++)
{
	cin>>a[i];
	s+=a[i];
}

ll ans=s,pre=0;
for(ll i=0;i<n;i++)
{
	pre+=a[i];
	ll x=s-pre;
	ans=min(ans,abs(x-pre));
}
cout<<ans<<endl;
}




Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define fir first
#define sec second
#define pb push_back
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<int, double> pid;
typedef pair<string, string> pss;
typedef pair<string, int> psi;
const int INF = 0x3f3f3f3f;
const int N = 1e5 + 5;
const int M = 2e5 + 5;
const int MOD = 1e9 + 7;
const double PI = acos(-1.0);
const double EPS = 1e-8;
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { return a * b / gcd(a, b); }
inline ull qpow(ull a, ull b)
{
    ull ans = 1;
    while (b)
    {
        if (b & 1)
            ans = ans * a;
        a = a * a;
        b >>= 1;
    }
    return ans;
}
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    int r;
    cin>>r;
    cout<<2*PI*r;
}

Measured memory_bytes: 3808
n, m = map(int, input().split())

a = [[]for _ in range(n)]

for i in range(n):
    a[i] = list(map(int, input().split()))
    
b = [[]for _ in range(m)]
for i in range(m):
    b[i] = int(input())

for i in range(n):
  c = 0
 
  for j in range(m):
    c += a[i][j]*b[j]
 
  print(c)


Measured memory_bytes: 6020
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, s, e) for (int i = (int)(s); i <= (int)(e); i++)
#define printYesNo(is_ok) puts(is_ok ? "Yes" : "No");
#define SORT(v) sort(v.begin(), v.end());
#define RSORT(v) sort(v.rbegin(), v.rend());
#define REVERSE(v) reverse(v.begin(), v.end());

template <typename T>
void printlnVector(T v)
{
  rep(i, v.size())
  {
    cout << v[i] << endl;
  }
}

template <typename T>
void printVector(T v)
{
  rep(i, v.size())
  {
    cout << v[i] << " ";
  }
  cout << endl;
}

int bfs(vector<string> field, pair<int, int> s_pos, pair<int, int> g_pos)
{
  int dirx[] = {1, 0};
  int diry[] = {0, 1};
  int R, C;
  int INF = INT32_MAX;
  R = field.size();
  C = field[0].size();

  vector<vector<int>> cost(R, vector<int>(C, INF));
  queue<pair<int, int>> pos_queue;
  if (field[0][0] == '.')
    cost[s_pos.first][s_pos.second] = 0;
  else
    cost[s_pos.first][s_pos.second] = 1;

  pos_queue.push(s_pos);

  while (pos_queue.size())
  {
    pair<int, int> pos = pos_queue.front();
    int pos_x = pos.first;
    int pos_y = pos.second;
    pos_queue.pop();
    rep(i, 2)
    {
      int next_x = pos_x + dirx[i];
      int next_y = pos_y + diry[i];

      if (0 <= next_x && next_x < R && 0 <= next_y && next_y < C)
      {
        int next_cost;
        if (field[pos_x][pos_y] == '.' && field[next_x][next_y] == '#')
          next_cost = cost[pos_x][pos_y] + 1;
        else
          next_cost = cost[pos_x][pos_y] + 0;

        if (cost[next_x][next_y] == INF)
        {
          pos_queue.push(make_pair(next_x, next_y));
        }
        cost[next_x][next_y] = min(cost[next_x][next_y], next_cost);
      }
    }
  }

  return cost[R - 1][C - 1];
}

int main()
{
  int H, W;
  cin >> H >> W;
  vector<string> s(H);
  rep(i, H)
  {
    cin >> s[i];
  }
  pair<int, int> start = make_pair(0, 0);
  pair<int, int> goal = make_pair(H - 1, W - 1);

  int ans = bfs(s, start, goal);
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define mp make_pair
#define ld long double
#define F first
#define S second
#define pii pair<ll,ll>

using namespace :: std;

const ll maxn=1e5+1050;
const ll mod=1e9+7;
const ll inf=1e9+5;

vector<pii> yal;
ll sz[maxn];
pii d[maxn];

int main(){
   ll n;
   cin>>n;
   ll sum=0;
   for(ll i=0;i<n;i++){
        cin>>d[i].F;
        sum+=d[i].F;
        d[i].S=i+1;
   }
   sort(d,d+n);
   fill(sz,sz+maxn,1);
   for(ll i=n-1;i>=1;i--){
        ll v=d[i].S;
        ll dpar=d[i].F+2*sz[v]-n;
        ll K=lower_bound(d,d+n,mp(dpar,0LL))-d;
        if(d[K].F!=dpar || dpar>=d[i].F || K>=n){
            cout<<-1;
            return 0;
        }
        ll par=d[K].S;
        sum-=2*sz[v]*(n-sz[v]);
        sz[par]+=sz[v];
        yal.pb(mp(min(v,par),max(v,par)));
   }
   if(sum!=0){
        cout<<-1;
        return 0;
   }
   sort(yal.begin(),yal.end());
   for(auto v:yal){
        cout<<v.F<<' '<<v.S<<endl;
   }
}


Measured memory_bytes: 5488
#include<bits/stdc++.h>
#define ll long long
#include<algorithm>
#include<string>
#include<vector>
#include<unordered_set>
#include <iomanip>
using namespace std;
ll dp[14][14] = {0};
ll ans = INT_MAX;



void add(int temp[], int m, int i)
{
    for(int j=0; j<m; ++j)
    {
        temp[j] += dp[i][j+1];
    }

}


void subtract(int temp[], int m, int i)
{
    for(int j=0; j<m; ++j)
    {
        temp[j] -= dp[i][j+1];
    }

}

void check(int current_index, int x, int n, int m, int temp[], int current_cost)
{
    bool yes = 1;
    for(int i=0; i<m; ++i)
    {
        if(temp[i] < x)
        {
            yes = 0;
            break;
        }
    }
    if(yes)
    {
        ans = min(ans, (ll)current_cost);
        return ;
    }
    for(int i=current_index; i<n; ++i)
    {
        add(temp, m, i);
        check(i+1, x, n, m, temp, current_cost + dp[i][0]);
        subtract(temp, m, i);
    }
}


int main()
{

    ll n,m,x;
    cin>>n>>m>>x;
    int temp[m] = {0};

    for(int i=0; i<n; ++i)
    {
        for(int j=0; j<=m; ++j)
        {
            cin>>dp[i][j];
        }
    }

    check(0, x, n, m, temp, 0);


    if(ans == INT_MAX)
    {
        cout<<-1;
    }
    else
    {
        cout<<ans;
    }
    return 0;
}


Measured memory_bytes: 3640
import java.util.*;


public class Main {
    public static void main(String[] args) {
      
      Scanner sc = new Scanner(System.in);
      double r = Double.parseDouble(sc.next());
      
      System.out.println(calCircumference(r));
      
    }
  private static double calCircumference(double r) {
        return 2 * Math.PI * r;
    }
}

Measured memory_bytes: 35848
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    int N,M;
    long long int K;
    cin >> N >> M >> K;
    
    vector<long long int> A(N);
    vector<long long int> B(M);
    vector<long long int> a(N+1);
    vector<long long int> b(M+1);
    a.at(0) = 0;
    b.at(0) = 0;
    int i;


    for(i=0;i<N;i++){
        cin >> A.at(i);
    }
    for(i=0;i<M;i++){
        cin >> B.at(i);
    }

    int ans = 0;
    for(i=0;i<N;i++){
        a.at(i+1) = a.at(i) + A.at(i);
    }
    
    for(i=0;i<M;i++){
        b.at(i+1) = b.at(i) + B.at(i);
    }

    int j = M;
    for(i=0;i<N+1;i++){
        if(a.at(i) > K){
            break;
        }
        while(a.at(i) + b.at(j) > K){
            j --;
        }
        ans = max(i+j,ans);
    }

    cout << ans << endl;
}


Measured memory_bytes: 9560
if __name__ == '__main__':
    n, m = map(int,input().split())

    if n == 1 and m == 1:
        print(1)
    elif n == 1 and m != 1:
        print(max(0, m - 2))
    elif n != 1 and m == 1:
        print(max(0, n - 2))
    if n >= 2 and m >= 2:
        print((n-2)*(m-2))


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

int main() {
    int N, K;
    cin >> N >> K;
    string S;
    cin >> S;
    vector<int> v(N, 0);
    for (int i = 0; i < N; i++) {
        if (S[i] == '0') {
            v[i]++;
            while (S[i] == '0' && i < N) {
                i++;
            }
            i--;
        }
    }

    vector<int> s(N + 1, 0);
    partial_sum(v.begin(), v.end(), s.begin() + 1);

    int maxv = 0;
    for (int i = 1; i <= N; i++) {
        if (i == 1 || S[i - 1] == '1') {
            int m = upper_bound(s.begin() + i, s.end(), K + s[i - 1]) -
                    s.begin() - 1;
            maxv = max(maxv, m - i + 1);
        }
    }
    cout << maxv << endl;
}


Measured memory_bytes: 1280
#include <stdio.h>

int main(void){
    int a, b, c;
    scanf("%d%d%d", &a, &b, &c);

    if(a == b && b == c || a != b && b != c && c != a){
        printf("No");
        return 0;
    }else{
        printf("Yes");
    }
}

Measured memory_bytes: 128
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <string>
#define REP(i, a, b) for (int i = (a); i < (b); i++)
using ll = long long;
using namespace std;

void solve()
{
    int n;
    cin >> n;
    vector<int> a0(n), a1(n);
    REP(i, 0, n) cin >> a0[i];
    REP(i, 0, n) cin >> a1[i];
    int ans = 0;
    int count;
    REP(i, 0, n) {
        count = 0;
        REP(j, 0, i + 1)
        {
            count += a0[j];
        }
        REP(j, i, n)
        {
            count += a1[j];
        }
        if (ans < count)
            ans = count;
    }
    cout << ans << endl;
}

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


Measured memory_bytes: 256
#pragma GCC optimize "O3"
 
#include <bits/stdc++.h>
 
using namespace std;
 
constexpr int N = 1e4 + 10, INF = INT_MAX / 4;
 
class BipartiteMatching { // O( ( V + E ) * sqrt( V ) )
 public: 
  vector< int > G[ N ]; // N = total number of nodes = n + m
  int n, m, match[ N ], dist[ N ];
  // n: number of nodes on left side, nodes are numbered 1 to n
  // m: number of nodes on right side, nodes are numbered n+1 to n+m
  // G = NIL[0] ??? G1[G[1---n]] ??? G2[G[n+1---n+m]]
  bool BFS() {
    queue< int > Q;
    for (int i = 1; i <= n; i++ ) {
      if ( match[ i ] == 0 ) {
        dist[ i ] = 0;
        Q.push( i );
      }
      else dist[ i ] = INF;
    }
    dist[ 0 ] = INF;
    while ( !Q.empty() ) {
      int u = Q.front(); Q.pop();
      if ( dist[ u ] < dist[ 0 ] )
        for(int v : G[u])
          if ( dist[ match[ v ] ] == INF ) {
            dist[ match[ v ] ] = dist[ u ] + 1;
            Q.push( match[ v ] );
          }
    }
    return ( dist[ 0 ] != INF );
  }
  bool DFS( int u ) {
    if ( u != 0 ) {
      for(int v : G[u])
        if ( dist[ match[ v ] ] == dist[ u ] + 1 and DFS( match[ v ] ) ) {
          match[ v ] = u;
          match[ u ] = v;
          return true;
        }
      dist[ u ] = INF;
      return false;
    }
    return true;
  }
  int Solve() {
    int matching = 0;
    fill_n(match, n+m+1, 0);
    while ( BFS() )
      for (int i = 1; i <= n; i++ )
        if ( match[ i ] == 0 and DFS( i ) ) matching++;
    return matching;
  }
  void AddEdge( int u, int v ) { G[ u ].push_back( n + v ); }
} ob;
 
int main() {
  int E; scanf("%d %d %d", &ob.n, &ob.m, &E);
  for(int i = 0; i < E; ++i) {
    int x, y; scanf("%d %d", &x, &y);
    ob.AddEdge(x+1, y+1);
  }
  printf("%d\n", ob.Solve());
}

Measured memory_bytes: 3524
#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimization("unroll-loops")
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> ii;
typedef pair<string,ll> si;
typedef pair<ii,ll> iii;
typedef vector<ll> vi;
typedef vector<ii> vii;
typedef vector<iii> viii;
#define all(a) a.begin(),a.end()
#define pb push_back
#define pf push_front
#define popb pop_back
#define popf pop_front
#define mp make_pair
#define F first
#define S second
#define ios ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define nl "\n"
const int MOD = 1e9+7;
const ld PI = 3.1415926535898;
const ll INF = LLONG_MAX;
#define N (int)5e5+5

int main()
{
	ios;
	int n,k;
	cin>>n>>k;
	vector<ll>pos,neg;
	ll a[n];
	for(int i=0;i<n;i++)
	{
		cin>>a[i];
		if(a[i]>=0)pos.pb(a[i]);
		else neg.pb(-a[i]);
	}
	sort(all(pos));
	sort(all(neg));
	if(pos.size()==0 && k%2)
	{
		ll ans=-1;
		for(int i=0;i<k;i++)
		{
			ans*=neg[i];
			ans%=MOD;
		}
		if(ans<0)ans+=MOD;
		cout<<ans<<nl;
	}
	else
	{
		ll ans=1;
		if(k%2)
		{
			ans=pos.back();
			pos.pop_back();
			k--;
		}
		vector<ll>v;
		for(int i=pos.size()-1;i-1>=0;i-=2)
		{
			v.pb(pos[i]*pos[i-1]);
		}
		for(int i=neg.size()-1;i-1>=0;i-=2)
		{
			v.pb(neg[i]*neg[i-1]);
		}
		sort(all(v));
		for(int i=v.size()-1;i>=0;i--)
		{
			if(!k)break;
			ll curr=v[i]%MOD;
			ans*=curr;
			ans%=MOD;
			k-=2;
		}
		if(k)
		{
			ans*=pos[0];
			ans%=MOD;
			ans*=neg[0];
			ans%=MOD;
			ans=-ans;
		}
		ans%=MOD;
		if(ans<0)ans+=MOD;
		cout<<ans<<nl;
	}
}

Measured memory_bytes: 8124
#include <bits/stdc++.h>
#define REP(i,n) for (int i = 0; i < (n); i++)
#define ALL(a) a.begin(), a.end()
#define RALL(a) a.rbegin(), a.rend()
using namespace std;
using ll = long long;
const ll MOD = 1000000007;
const ll INF = MOD * MOD;

int main() {

    string s;
    cin >> s;
    
    ll ans = 0;
    for (int i = 0; i < s.size(); i++) {
        ans += s[i] - '0';
    }

    int tmp = stoi(s);
    int pw = pow(10, s.size()-1);
    if (tmp == pw){
        ans = 10;        
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <string>
#include <vector>
#include <algorithm>
#include <math.h>
#include <iostream>
#include <numeric>
#define rep(i,n) for (int i = 0;i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;
#define chmax(x,y) x = max(x,y)
int INF = 1e9;
ll  LINF = 1e18;

bool seen[100005];
vector<vector<int>> G(100005,vector<int>());
vector<int> num;
void dfs(int v){
	if(!seen[v]){
		seen[v] = true;
		for(int nv:G[v]) dfs(nv);
		num.push_back(v);
	}
	return ;
}



int main(){
	int n,m;cin >> n >> m;
	vector<bool> root(n,false);
	rep(i,n+m-1){
		int a,b;cin >> a >> b;
		--a;--b;
		root[b] = true;
		G[a].push_back(b);
	}
	int r = 0;
	rep(i,n) seen[i] = false;
	rep(i,n) {
		if(!root[i]) {
			r = i;
			break;
		}
	}
	dfs(r);
	vector<int> pare(n);
	pare[r] = -1;
	for(int i = n-1;i >= 0;i--){
		for(int nv:G[num[i]]) pare[nv] = num[i];
	}
	rep(i,n) cout << pare[i]+1 << endl;


} 


Measured memory_bytes: 14200