akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
// auto mod int
// https://youtu.be/L8grWxBlIZ4?t=9858
// https://youtu.be/ERZuLAxZffQ?t=4807 : optimize
// https://youtu.be/8uowVvQ_-Mo?t=1329 : division
const int mod = 1000000007;
struct mint {
    ll x;  // typedef long long ll;
    mint(ll x = 0) : x((x % mod + mod) % mod) {}
    mint operator-() const { return mint(-x); }
    mint& operator+=(const mint a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator-=(const mint a) {
        if ((x += mod - a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator*=(const mint a) {
        (x *= a.x) %= mod;
        return *this;
    }
    mint operator+(const mint a) const { return mint(*this) += a; }
    mint operator-(const mint a) const { return mint(*this) -= a; }
    mint operator*(const mint a) const { return mint(*this) *= a; }
    mint pow(ll t) const {
        if (!t) return 1;
        mint a = pow(t >> 1);
        a *= a;
        if (t & 1) a *= *this;
        return a;
    }

    // for prime mod
    mint inv() const { return pow(mod - 2); }
    mint& operator/=(const mint a) { return *this *= a.inv(); }
    mint operator/(const mint a) const { return mint(*this) /= a; }
};
istream& operator>>(istream& is, mint& a) { return is >> a.x; }
ostream& operator<<(ostream& os, const mint& a) { return os << a.x; }

// combination mod prime
// https://www.youtube.com/watch?v=8uowVvQ_-Mo&feature=youtu.be&t=1619
struct combination {
    vector<mint> fact, ifact;
    combination(int n) : fact(n + 1), ifact(n + 1) {
        assert(n < mod);
        fact[0] = 1;
        for (int i = 1; i <= n; ++i) fact[i] = fact[i - 1] * i;
        ifact[n] = fact[n].inv();
        for (int i = n; i >= 1; --i) ifact[i - 1] = ifact[i] * i;
    }
    mint operator()(int n, int k) {
        if (k < 0 || k > n) return 0;
        return fact[n] * ifact[k] * ifact[n - k];
    }
};

void solve(long long n, std::vector<long long> a) {
    ll left, right;
    vector<ll> num(n, -1);
    for (int i = 0; i < n + 1; i++) {
        --a[i];
        if (num[a[i]] == -1) {
            num[a[i]] = i;
        } else {
            left = num[a[i]];
            right = i;
            break;
        }
    }

    combination comb = combination(int(1e5) + 5);

    for (int i = 1; i <= n + 1; i++) {
        mint temp = comb(n + 1, i);
        ll remain = n + 1 - (right - (left - 1));
        // cerr << "i=" << i << "remain=" << remain << endl;
        if (remain < i - 1) {
            cout << temp << "\n";
            continue;
        }
        temp -= comb(remain, i - 1);
        cout << temp << "\n";
    }
}

// Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main() {
    long long n;
    scanf("%lld", &n);
    std::vector<long long> a(n + 1);
    for (int i = 0; i < n + 1; i++) {
        scanf("%lld", &a[i]);
    }
    solve(n, std::move(a));
    return 0;
}


Measured memory_bytes: 6352
#include<bits/stdc++.h>
#define int long long
#define PB push_back
#define MP make_pair
#define FI first
#define SE second
using namespace std;
typedef pair<int,int> pii;
static const int INF = 1ll<<60;

int dp[2][2][2][2001][2001];
int N,M;
string S,T;


int solve(int n1,int n2,int p,int s,int t){
    //if(sum.size()>=15)cout<<sum<<" "<<p<<endl;
    if(dp[n1][n2][p][s][t]!=-1)return dp[n1][n2][p][s][t];
    if(s>N||t>M){
        return -INF;
    }
    if(s==N&&t==M){
        if(p==0)return -INF;
        else return 0;
    }
    int res=0;
    int sx,tx;
    {
        if(s==N)sx=p;
        if(t==M)tx=p;
        if(S[s]=='I')sx=1;
        if(S[s]=='O')sx=0;
        if(T[t]=='I')tx=1;
        if(T[t]=='O')tx=0;
    }
    if(n1==0&&n2==0){
        if(p!=sx&&p!=tx){
            res+=max(solve(0,0,p,s+1,t),
                    max(solve(0,0,p,s,t+1),
                        max(solve(1,0,sx,s+1,t)+1,
                            max(solve(0,1,tx,s,t+1)+1,res))));
        }
        else if(p!=sx&&p==tx){
            res+=max(solve(0,0,p,s+1,t),
                    max(solve(0,0,p,s,t+1),
                        max(solve(1,0,sx,s+1,t)+1,res)));
        }
        else if(p==sx&&p!=tx){
           res+=max(solve(0,0,p,s+1,t),
                   max(solve(0,0,p,s,t+1),
                           max(solve(0,1,tx,s,t+1)+1,res)));
        }
        else{
            res+=max(solve(0,0,p,s+1,t),
                   max(solve(0,0,p,s,t+1),res));
        }
    }

    else if(n1==0&&n2!=0){
        if(p!=sx&&p!=tx){
            res+=max(solve(0,n2,p,s+1,t),
                        max(solve(1,n2,sx,s+1,t)+1,
                            max(solve(0,n2,tx,s,t+1)+1,res)));
        }
        else if(p!=sx&&p==tx){
            res+=max(solve(0,n2,p,s+1,t),
                        max(solve(1,n2,sx,s+1,t)+1,res));
        }
        else if(p==sx&&p!=tx){
           res+=max(solve(0,n2,p,s+1,t),
                        max(solve(0,n2,tx,s,t+1)+1,res));
        }
        else{
            res+=max(solve(0,n2,p,s+1,t),res);
        }
    }

    else if(n1!=0&&n2==0){
        if(p!=sx&&p!=tx){
            res+=max(solve(n1,0,p,s,t+1),
                        max(solve(n1,0,sx,s+1,t)+1,
                            max(solve(n1,1,tx,s,t+1)+1,res)));
        }
        else if(p!=sx&&p==tx){
            res+=max(solve(n1,0,p,s,t+1),
                        max(solve(n1,0,sx,s+1,t)+1,res));
        }
        else if(p==sx&&p!=tx){
           res+=max(solve(n1,0,p,s,t+1),
                        max(solve(n1,1,tx,s,t+1)+1,res));
        }
        else{
            res+=max(solve(n1,0,p,s,t+1),res);
        }
    }
    else {
        if(p!=sx&&p!=tx){
            res+=max(solve(n1,n2,sx,s+1,t)+1,
                    max(solve(n1,n2,tx,s,t+1)+1,res));
        }
        else if(p!=sx&&p==tx){
            res+=max(solve(n1,n2,sx,s+1,t)+1,res);
        }
        else if(p==sx&&p!=tx){
           res+=max(solve(n1,n2,tx,s,t+1)+1,res);
        }
        else if(p==0)return -INF;
    }
    return dp[n1][n2][p][s][t]=res;
}


signed main(){
    memset(dp,-1,sizeof(dp));
    cin>>N>>M;
    cin>>S>>T;
    cout<<solve(0,0,0,0,0)<<endl;
}

Measured memory_bytes: 253904
object Main extends App {
  import scala.io.StdIn._
  val n = readInt
  val Array(a, d) = readLine.trim.split(' ').map(_.toInt)
  val operation = Array.fill(readInt){
    val Array(x, y, z) = readLine.trim.split(' ').map(_.toInt)
    (x, y, z)
  }
  var current = readLine.trim.toInt
  for ((x, y, z) ← operation.reverse) {
    x match {
      case 0 if y == current || z == current ⇒
        current = if (y == current) z else y
      case 1 if y == current ⇒ current = z
      case _ ⇒
    }
  }
  println(a + current * d - d)
}



Measured memory_bytes: 44204
N,K = map(int,input().split())
S = input()

if S[0] == '0':
    Sc = [0]
else:
    Sc = []

c = 1
for i in range(N-1):
    if S[i] != S[i+1]:
        Sc.append(c)
        c = 1
    else:
        c += 1
Sc.append(c)

if S[-1] == '0':
    Sc.append(0)

#print(Sc)

ansp = [sum(Sc[:2*K+1])]

for i in range(2*K+1, len(Sc), 2):
    ansp.append(ansp[-1]-Sc[i-2*K-1]-Sc[i-2*K]+Sc[i]+Sc[i+1])
ans = max(ansp)
print(ans)


Measured memory_bytes: 5388
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.IOException;

public class Main {
  public static void main(String[] args) throws IOException {
    BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
    String[] str = in.readLine().split(" ");
    int a = Integer.parseInt(str[0]);
    int b = Integer.parseInt(str[1]);
    int c = Integer.parseInt(str[2]);
    
    boolean hantei = false;
    for(int i=1; i<100; i++) {
      if(a*i%b==c) {
        hantei = true;
        break;
      }
    }

    System.out.println(hantei == true?"YES":"NO");
  }
}

Measured memory_bytes: 32280
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;
typedef pair<ll,ll> pll;
//const ll mod=1e9+7;
const ll mod=998244353;
const ll inf=1LL<<61;

struct query{
  ll type;//0=empty, 1=add-sum ,2=set-min
  ll value;
  query(ll a=0,ll b=0):type(a),value(b) {}
};

ll INF=(1LL<<60);

struct segtree{
  ll SIZE;
  vector<query> s;
  vector<ll> t;// sum-add
  vector<ll> u;// min-set

  segtree(ll n=1){
    SIZE=1;
    while(SIZE<n)SIZE*=2;
    s.clear();
    t.clear();
    u.clear();
    s.resize(SIZE*2, query());
    t.resize(SIZE*2, 0);
    u.resize(SIZE*2, 0);
  }
  
  void func(ll k,ll l,ll r,query q){
    if(q.type==1){
      if(s[k].type==0)s[k]=q;
      else s[k].value+=q.value;
      t[k]+=q.value*(r-l);
      u[k]+=q.value;
    }
    if(q.type==2){
      s[k]=q;
      t[k]=q.value*(r-l);
      u[k]=q.value;
    }
  }

  void compute(ll k,ll l,ll r){
    query q=s[k];
    s[k]=query();
    if(q.type==0||r-l==1)return;
    ll m=(l+r)/2;
    func(k*2+1,l,m,q);
    func(k*2+2,m,r,q);
  }

  void Update(ll a,ll b,query x,ll k,ll l,ll r){
    if(b<=l || r<=a)return;
    compute(k,l,r);
    if(a<=l && r<=b){
      func(k,l,r,x);
    }else{
      ll m=(l+r)/2;
      Update(a,b,x,k*2+1,l,m);
      Update(a,b,x,k*2+2,m,r);
      t[k]=t[k*2+1]+t[k*2+2];
      u[k]=min(u[k*2+1],u[k*2+2]);
    }
  }

  ll Dfs(ll type,ll a,ll b,ll k,ll l,ll r){
    if(b<=l || r<=a){
      if(type==1)return 0; //add
      if(type==2)return INF; // min
    }
    compute(k,l,r);
    if(a<=l && r<=b){
      if(type==1)return t[k];
      if(type==2)return u[k];
    }else{
      ll m=(l+r)/2;
      ll lv=Dfs(type,a,b,k*2+1,l,m);
      ll rv=Dfs(type,a,b,k*2+2,m,r);
      if(type==1)return lv+rv; // add
      if(type==2)return min(lv,rv); // min
    }
  }

  void Add(ll a,ll b,ll x){
    Update(a,b,query(1,x), 0,0,SIZE);
  }
  void Set(ll a,ll b,ll x){
    Update(a,b,query(2,x), 0,0,SIZE);
  }
  ll Getsum(ll a,ll b){
    return Dfs(1,a,b, 0,0,SIZE);
  }

  ll Getmin(ll a,ll b){
    return Dfs(2,a,b, 0,0,SIZE);
  }
  
};

int main() {
  ll n;
  cin >> n;
  vector<pll> a(n);
  for(ll i=0;i<n;i++) {
    ll x,d;
    cin >> x >> d;
    x+=1e9;
    a[i]={-x,-d};
  }
  sort(a.begin(),a.end());
  segtree dp(n);
  dp.Set(0,n+1,inf);
  vec ans(n+1);
  ans[0]=1;
  for(ll i=0;i<n;i++) {
    ll x=a[i].first;
    ll d=a[i].second;
    pll tmp={x+d,inf};
    ll it=lower_bound(a.begin(),a.end(),tmp)-a.begin();
    dp.Set(i,i+1,it);
    dp.Set(i,i+1,dp.Getmin(it,i+1));
    ans[i+1]=(ans[i]+ans[dp.Getmin(i,i+1)])%mod;
  }
  cout << ans[n] << endl;
}

Measured memory_bytes: 21376
import sys
input = sys.stdin.readline

N=int(input())

E=[list(map(int,input().split())) for i in range(N)]

QU=int(input())

Q=[list(map(int,input().split())) for i in range(QU)]

TIMELIST=[]
for t,a in E:
    TIMELIST.append(t)

for l,r in Q:
    TIMELIST.append(l)
    TIMELIST.append(r)

compression_dict={a: ind for ind, a in enumerate(sorted(set(TIMELIST)))}

for i in range(N):
    E[i][0]=compression_dict[E[i][0]]

for i in range(QU):
    Q[i]=[compression_dict[Q[i][0]],compression_dict[Q[i][1]]]


    



def seg_function(x,y):# Segment treeで扱うfunction
    return x*y

seg_el=1<<(len(compression_dict).bit_length())# Segment treeの台の要素数
SEG=[1]*(2*seg_el)# 1-indexedなので、要素数2*seg_el.Segment treeの初期値で初期化

for t,a in E:
    SEG[t+seg_el]=1-0.1*a

for i in range(seg_el-1,0,-1):# 親の部分もupdate
    SEG[i]=seg_function(SEG[i*2],SEG[i*2+1])

def update(n,x,seg_el):# A[n]をxへ更新（反映）
    i=n+seg_el
    SEG[i]=x
    i>>=1# 子ノードへ
    
    while i!=0:
        SEG[i]=seg_function(SEG[i*2],SEG[i*2+1])
        i>>=1
        
def getvalues(l,r):# 区間[l,r)に関するseg_functionを調べる
    L=l+seg_el
    R=r+seg_el
    ANS=1

    while L<R:
        if L & 1:
            ANS=ANS*SEG[L]
            L+=1

        if R & 1:
            R-=1
            ANS=ANS*SEG[R]
        L>>=1
        R>>=1

    return ANS

for l,r in Q:
    print(10**9*getvalues(l,r))
    



Measured memory_bytes: 77220
#include <iostream>
//#include<stdio>
#include<math.h>
using namespace std;

int main()
{
    int a , b;
    cin >> a >> b ;
   // a = 2;
    //b = 22;
    long int c = a*b;
    
    if(c%2 == 0)
    {
        cout << "Even" <<"\n";
        
    }
    else{
        cout <<"Odd" <<"\n";
    }
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cmath>

using namespace std;

int main(){
    int hi= 0,tyou = 0;
  int a,b,c;
  while(~scanf("%d,%d,%d",&a,&b,&c)){

    a = pow(a,2);
    b = pow(b,2);
    c = pow(c,2);
    if(c == a+b)tyou++;
    if(a == b)hi++;
}
  cout << tyou << endl<< hi << endl;
  return 0;
}

Measured memory_bytes: 1208
#include <bits/stdc++.h>
using namespace std;
#define FAST       			ios_base :: sync_with_stdio(false); cin.tie(NULL);

int main() {
  FAST;
  int a, b;
  cin >> a >> b;
  if (a >= b) {
    for (int i = 0; i < a; i++) {
      cout << b;
    }
  }
  else {
    for (int i = 0; i < b; i++) {
      cout << a;
    }
  }
  cout << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep2(i,s,n) for(int i=(s);i<=(int)(n);i++)

int main(){
  int A,B,sum=0;
  cin>>A>>B;

  rep2(i,A,B){
    int a1,a2,a3,a4,a5;
    a1=i%10;
    a2=(i%100)/10;
    a3=(i%1000)/100;
    a4=(i%10000)/1000;
    a5=i/10000;

    if(a1==a5&&a2==a4){
      sum++;
    }
  }

  cout<<sum<<endl;
}

Measured memory_bytes: 256
let input = require("fs").readFileSync("/dev/stdin", "utf8")

function main({ input, load, yesno, math_sum, log_json }) {
    let [K] = load()
    let [S] = load(1,1,String)
    if(S.length <= K) return S
    return S.slice(0,K) + '...'
}



// console.time()
let inputs = input.split(/[\s\n]/)
let result = main({
    input,
    yesno: value => value ? 'Yes' : 'No',
    math_sum: numbers => numbers.reduce((acc, cur) => acc + cur, 0),
    load(rows = 1, cols = 1, type = Number) {
        const length = rows * cols
        let result = inputs.splice(0, length)
        if(type !== String) result = result.map(type)
        if(cols > 1) {
            const arrays = new Array(cols)
            for(let col = 0; col < cols; col++) {
                arrays[col] = new Array()
                for(let row = 0; row < rows; row++) {
                    arrays[col].push(result[row * cols + col])
                }
            }
            result = arrays
        }
        return result
    },
    inifinite_loop_preventer() {
        throw new Error("Infinite loop")
    },
    log_json(value) {
        console.log(JSON.stringify(value))
    },
})

if(result === undefined) {
    console.warn("result is undefined")
} else {
    console.log(result)
}
// console.timeEnd()

function math_max(numbers, initial_value = null) {
    let result = (initial_value === null) ? numbers[0] : initial_value
    for(const n of numbers) if(n > result) result = n
    return result
}

function math_min(numbers, initial_value = null) {
    let result = (initial_value === null) ? numbers[0] : initial_value
    for(const n of numbers) if(n < result) result = n
    return result
}

// 素因数分解 { 素数: n乗 }
function math_prime_factors(n) {
    const result = {}

    for(let i = 2; i * i <= n; i++) {
        if(n % i === 0) {
            n /= i
            result[i] = 1
            
            while(n % i === 0) {
                n /= i
                result[i]++
            }
        }
    }

    if(n > 1) result[n] = 1

    return result
}


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

int main(){
  int A,B,K;
  cin>>A>>B>>K;
  int temp;
  if(A>=B){
    temp=B;
    B=A;
    A=temp;
  }
  int count=0;
  for(int i=A;i>0;i--){
    if((A%i==0)&&(B%i==0)){
      count++;
      
      if(count==K){
        cout<<i<<endl;
        return 0;
      }
    }
  }
  return 0;
}



Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
#define int ll
#define double long double
#define YES {cout<<"YES"<<'\n';}
#define NO {cout<<"NO"<<'\n';}
#define Yes {cout<<"Yes"<<'\n';}
#define No {cout<<"No"<<'\n';}
#define yes {cout<<"yes"<<'\n';}
#define no {cout<<"no"<<'\n';}
void YN(bool flg){cout<<(flg?"YES":"NO")<<'\n';}
void Yn(bool flg){cout<<(flg?"Yes":"No")<<'\n';}
void yn(bool flg){cout<<(flg?"yes":"no")<<'\n';}
#define SORT(a) sort(a.begin(),a.end())
#define REVERSE(a) reverse(a.begin(),a.end())
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define out(n) {cout << n << '\n';}
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<bool> VB;
typedef vector<VI> VVI;
const int MOD = 1000000007;
const long long INF = 10e10;
const double PI = acos(-1.0);
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; }
template<class T>auto MAX(const T& a) { return *max_element(a.begin(),a.end()); }
template<class T>auto MIN(const T& a) { return *min_element(a.begin(),a.end()); }
int ABS(int a) {if(a<0) a = -a; return a;}
template<class T, class U>U SUM(const T& a, const U& v) { return accumulate(a.begin(),a.end(), v); }
template<class T, class U>U COUNT(const T& a, const U& v) { return count(a.begin(),a.end(), v); }
template<class T, class U>int LOWER(const T& a, const U& v) { return lower_bound(a.begin(),a.end(), v) - a.begin(); }
template<class T, class U>int UPPER(const T& a, const U& v) { return upper_bound(a.begin(),a.end(), v) - a.begin(); }
int GCD(int a, int b) { return b ? GCD(b, a%b) : a; }
int LCM(int a, int b) { int g = GCD(a, b); return a / g * b; }
int POW(int a, int n) { int r = 1; while (n > 0) { if (n & 1)r *= a; a *= a; n /= 2; }return r; }
int isPrime(int n){if(n<2){return 0;}for(int i=2; i*i<=n; i++){if(n%i==0){return 0;}}return 1;}
/*素因数分解*/map< int, int >prime_factor(int n){map< int, int > ret;for(int i = 2; i * i <= n; i++) {while(n % i == 0) {ret[i]++;n /= i;}}if(n != 1) ret[n] = 1;return ret;}
/*約数列挙*/vector<int> divisor(int n){vector<int> v; for(int i=1; i*i<=n; i++){if(n%i==0){v.push_back(i);if(i!=n/i){v.push_back(n/i);}}}sort(v.begin(),v.end()); return v;}
//----------------ライブラリとか----------------

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout<<fixed<<setprecision(15);

    int a,b; cin >> a >> b;
    Yn(a!=2&&b!=2);

    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <memory>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

using namespace std;

typedef long long ll;

#define sz size()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(c) (c).begin(), (c).end()
#define rep(i,a,b) for(ll i=(a);i<(b);++i)
#define per(i,a,b) for(ll i=b-1LL;i>=(a);--i)
#define clr(a, b) memset((a), (b) ,sizeof(a))
#define ctos(c) string(1,c)
#define print(x) cout<<#x<<" = "<<x<<endl;

#define MOD 1000000007

ll dl[500500];
ll dr[500500];
ll dp[500500];

int main() {
  ll n;
  cin>>n;
  string s1;
  cin>>s1;
  string s = "000";
  s += s1;
  n += 3;
  ll l = -1;
  rep(i,0,s.sz){
    if(l == -1 && s[i]=='1'){
      l = i;
    }
    if(s[i]=='0'){
      l = -1;
    }
    dl[i] = l;
  }
  ll r = -1;
  per(i,0,s.sz){
    if(r == -1 && s[i]=='1'){
      r = i;
    }
    if(s[i]=='0'){
      r = -1;
    }
    dr[i] = r;
  }
  clr(dp,0);
  rep(i,1,s.sz){
    dp[i] = max(dp[i],dp[i-1]);
    if(s[i]=='1'){
      ll a1 = i;
      ll b1 = dr[i];
      if(b1+2<s.sz){
        if(s[b1+1]=='0'&&s[b1+2]=='1'){
          dp[b1+2] = max(dp[b1+2],dp[i-1]+(b1-a1+1));
        }
      }      
    }
    if((i+2)<s.sz&&s[i]=='1'&&s[i+1]=='0'&&s[i+2]=='1'){
      ll a1 = dl[i+2];
      ll b1 = dr[i+2];
      dp[b1] = max(dp[b1],dp[i-1]+(b1-a1+1));
      if(b1-1>=i+2){
        dp[b1-1] = max(dp[b1-1],dp[i-1]+(b1-a1+1)-1);
      }
    }
  }
  cout << dp[s.sz-1] << endl;
  return 0;
}

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

int main() {
  int X, N;
  cin >> X >> N;
  vector<int> V(N);
  for (int i=0; i<N; i++) {
    cin >> V.at(i);
  }
  
  int m=101, mi=0, s=0, cont;
  for (int i=101; i>=-1; i--) {
    
    cont=0;
    for (int j=0; j<N; j++) {
      if (V.at(j) == i) {
        cont = 1;
        break;
      }
    }
    if (cont == 1) {continue;}
    
    if (i > X) {
      s = i - X;
    }
    else {
      s = X - i;
    }
    
    if (s < m) {
      m = s;
      mi = i;
    }
    else if (s == m) {
      mi = min(mi, i);
    }
    //cout << mi << endl;
  }
  cout << mi << endl;
  
}

Measured memory_bytes: 3600
#include<iostream>
#include<string>
#include<map>
#include<algorithm>
#include<vector>
using namespace std;

int main() {
	int n;
	string s;
	int r = 0, b = 0;
	cin >> n >> s;
	for (int i = 0; i < s.size(); i++)
	{
		if (s[i] == 'R') {
			r++;
		}
		else {
			b++;
		}

	}
	
	if (r > b) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;

	}
}



Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using static System.Console;
using static System.Math;
using static MyIO;
using static MyUtil;

public class B
{
	public static void Main() => (new Solver()).Solve();
}

public class Solver
{
	public void Solve()
	{
		long N = GetLong();
		long A = GetLong();
		long B = GetLong();

		long q = N / (A + B);
		long r = N - (A + B) * q;
		WriteLine(q * A + Min(r, A));
	}
}

public static class MyIO
{
	private static string[] args = null;
	private static int num = -1;
	private static int used = -1;

	private static string getArg()
	{
		if(used == num)
		{
			args = Console.ReadLine().Split(' ');
			num = args.Length;
			used = 0;
		}
		return args[used++];
	}

	public static int GetInt() => int.Parse(getArg());
	public static long GetLong() => long.Parse(getArg());
	public static double GetDouble() => double.Parse(getArg());
	public static decimal GetDecimal() => decimal.Parse(getArg());
	public static string GetString() => getArg();
	public static char GetChar() => getArg()[0];
	public static int[] GetInts(long N) => Enumerable.Range(0, (int)N).Select(_ => GetInt()).ToArray();
	public static long[] GetLongs(long N) => Enumerable.Range(0, (int)N).Select(_ => GetLong()).ToArray();
	public static double[] GetDoubles(long N) => Enumerable.Range(0, (int)N).Select(_ => GetDouble()).ToArray();
	public static decimal[] GetDecimals(long N) => Enumerable.Range(0, (int)N).Select(_ => GetDecimal()).ToArray();
	public static string[] GetStrings(long N) => Enumerable.Range(0, (int)N).Select(_ => GetString()).ToArray();
}

public static class MyUtil
{
	public static void chmax<T>(ref T x, T y) where T : IComparable<T>
	{
		if(x.CompareTo(y) < 0)
			x = y;
	}

	public static void chmin<T>(ref T x, T y) where T : IComparable<T>
	{
		if(x.CompareTo(y) > 0)
			x = y;
	}

	public static void swap<T>(ref T x, ref T y)
	{
		T tmp = x;
		x = y;
		y = tmp;
	}
}

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

#define rep( i, n, m ) for(int i = ( n ); i < ( m ); i++)
#define rep_d( i, n, m ) for(int i = ( n ) - 1; i >= ( m ); i--)
#define sort_asc( X ) sort(( X ).begin(), ( X ).end())
#define sort_desc( X ) sort(( X ).begin(), ( X ).end(), greater <>())
#define endl "\n"

template <class T> bool chmax( T& a, T b );
template <class T> bool chmin( T& a, T b );
int* eratosthenes( int N );
bool bit_search( int pattern, int N );
void initialize( void );

const ll INF = 1LL << 60;
const int k_mod = 1e9 + 7;
template <typename T, typename K> struct P {
	T a; K b;
};
bool is_kibun( string S ){

	int N = S.length();
	rep( i, 0, N / 2 + 1 ){
		if (S[ i ] != S[ N - i - 1 ]){
			return false;
		}
	}
	return true;

}

int main( void ){
	// initialize();
	string S;
	cin >> S;
	int N = S.length();
	if (!is_kibun( S ) || !is_kibun( S.substr(0, (N-1)/2) ))
	{
		cout << "No\n";
		return 0;
	}
	if (!is_kibun( S.substr((N+3)/2-1, N-(N+3)/2+1 ))) {
		cout << "No\n";
		return 0;
	}
	cout << "Yes\n";
}

template <class T> bool chmax( T& a, T b ) {
	if (a < b){
		a = b; return true;
	}
	return false;
}
template <class T> bool chmin( T& a, T b ) {
	if (a > b){
		a = b; return true;
	}
	return false;
}
int* eratosthenes( int N ){
	int* prime_array = new int[ N + 1 ];
	int lim = N;
	prime_array[ 0 ] = 0;
	prime_array[ 1 ] = 0;
	rep( i, 2, N + 1 ){
		prime_array[ i ] = 1;
	}
	rep( i, 2, lim ){
		if (prime_array[ i ] == 0)
			continue;
		lim = N / i;
		for(int j = i * 2; j < N + 1; j += i){
			prime_array[ j ] = 0;
		}
	}
	return prime_array;
}
bool bit_search( int pattern, int N ){
	int cnt = 0;
	rep( bit, 0, N ){
		if (pattern & ( 1 << bit )){
			cnt++;
		}
	}
	return true;
}
void initialize( void ){
	cout << fixed << setprecision( 10 );
}


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

int main(){
    int x = 0;
    string a, b, tmp;
    cin >> a >> b;

    tmp = a + b;
    x = stoi(tmp);

    rep(i, 1000){
        if(x == i * i){
            cout << "Yes" << endl;
            return 0;
        }
    }

    cout << "No" << endl;

    return 0;
}

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef complex<double> Point;

#define PI acos(-1.0)
#define EPS 1e-10
const ll INF = 1e16;
const ll MOD = 1e9 + 7;

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define rep(i,N) for(int i=0;i<(N);i++)
#define ALL(s) (s).begin(),(s).end()
#define EQ(a,b) (abs((a)-(b))<EPS)
#define EQV(a,b) ( EQ((a).real(), (b).real()) && EQ((a).imag(), (b).imag()) )
#define fi first
#define se second
#define N_SIZE (1LL << 20)
#define NIL -1

ll sq(ll num) { return num*num; }
ll mod_pow(ll x, ll n) {
	if (n == 0)return 1;
	if (n == 1)return x%MOD;
	ll res = sq(mod_pow(x, n / 2));
	res %= MOD;
	if (n % 2 == 1) {
		res *= x;
		res %= MOD;
	}
	return res;
}

// string n;
// ll table[3] = {7,5,3};
// ll dp[100][1<<3][2];

// int main(){
// 	cin >> n;
// 	dp[0][0][0] = 1;
// 	rep(i,n.size()){
// 		rep(j,1<<3){
// 			if(j == 0){
// 				if(n[i] - '0' != 0)dp[i+1][j][1] += dp[i][j][0];
// 				else dp[i+1][j][0] += dp[i][j][0];
// 			}
// 			rep(k,3){
// 				ll nxt = j|(1<<k);
// 				dp[i+1][nxt][1] += dp[i][j][1];
// 				if(n[i] - '0' == table[k])dp[i+1][nxt][0] += dp[i][j][0];
// 				else if(n[i] - '0' > table[k])dp[i+1][nxt][1] += dp[i][j][0];
// 			}
// 		}
// 	}
// 	cout << dp[n.size()][7][0]+dp[n.size()][7][1] << endl;
// }

ll n;

bool check(string s){
	ll cnt = 0;
	rep(i,s.size()){
		if(s[i] == '7')cnt |= (1 << 0);
		if(s[i] == '5')cnt |= (1 << 1);
		if(s[i] == '3')cnt |= (1 << 2);
	}
	return cnt == 7;
}

ll stringtoi(string s){
	ll res = 0;
	rep(i,s.size()){
		res *= 10;
		res += (s[i] - '0');
	}
	return res;
}

ll solve(string s){
	ll num = stringtoi(s);
	if(num > n)return 0;
	// cout << "!" << s << endl;
	ll res = check(s);
	res += solve(s+"7");
	res += solve(s+"5");
	res += solve(s+"3");
	return res;
}

int main(){
	cin >> n;
	cout << solve("0") << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static boolean isWrite(String s) {
	
		for(int i=0; i<s.length()-1; i++) {
			char c = s.charAt(i);
			if(c=='A') {
				if(s.charAt(i+1) == 'B' || s.charAt(i+1) == 'D'){}
				else return false;
			}
			else if(c=='B') {
				if(s.charAt(i+1) == 'A' || s.charAt(i+1) == 'C' || s.charAt(i+1) == 'E' ){}
				else return false;
			}
			else if(c=='C') {
				if(s.charAt(i+1) == 'B' || s.charAt(i+1) == 'F' ){}
				else return false;
			}
			else if(c=='D') {
				if(s.charAt(i+1) == 'A' || s.charAt(i+1) == 'E' || s.charAt(i+1) == 'G' ){}
				else return false;
			}
			else if(c=='E') {
				if(s.charAt(i+1) == 'B' || s.charAt(i+1) == 'D' || s.charAt(i+1) == 'F' || s.charAt(i+1) == 'H' ) {}
				else return false;
			}
			else if(c=='F') {
				if(s.charAt(i+1) == 'C' || s.charAt(i+1) == 'E' || s.charAt(i+1) == 'I' ){}
				else return false;
			}
			else if(c=='G') {
				if(s.charAt(i+1) == 'D' || s.charAt(i+1) == 'H' ){}
				else return false;
			}
			else if(c=='H') {
				if(s.charAt(i+1) == 'E' || s.charAt(i+1) == 'G' || s.charAt(i+1) == 'I' ){}
				else return false;
			}
			else if(c=='I') {
				if(s.charAt(i+1) == 'F' || s.charAt(i+1) == 'H' ){}
				else return false;
			}	
		
		}

		return true;
	
	}
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String[] pass = new String[1000];
		
		for(int i=0; i<1000; i++) { 
			pass[i] = sc.next();
		}			
		for(int i=0; i<1000; i++) {
			if(isWrite(pass[i])) System.out.println(pass[i]);
		}
	
	}
}

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


int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int A[3];
    rep(i, 3) cin >> A[i];
    sort(A, A + 3);
    cout << A[0] * A[1] / 2 << endl;

    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<algorithm>
#define fo(i,a,b) for(int i=a;i<=b;i++)
#define fod(i,a,b) for(int i=a;i>=b;i--)
using namespace std;
typedef long long ll;
const int N=1e5+10;
int ans[N],n,tot=0;
int main()
{
	memset(ans,0,sizeof(ans));
	scanf("%d",&n);
	for(int x,i=1;i<=n;i++) {
		scanf("%d",&x);
		if(x!=0) {ans[x+1]++;ans[x]++;ans[x-1]++;}
		else {ans[x]++;ans[x+1]++;tot++;}
	}
	int cnt=0;
	fo(i,0,N-1) cnt=max(cnt,ans[i]);
	cout<<cnt<<endl;
	return 0;
}

Measured memory_bytes: 640
from collections import defaultdict
 
N = int(input())
raw_numbers = list(map(int, input().split()))
Q = int(input())
 
total = sum(raw_numbers)
 
numbers = defaultdict(int)
 
for num in raw_numbers:
    numbers[num] += 1

for _ in range(Q):
    a, b = map(int, input().split())
    taken = numbers[a]
    total -= a * numbers[a]
    numbers[b] += numbers[a]
    total += b * taken
    numbers[a] = 0
    print(total)

Measured memory_bytes: 89672
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <queue>
#include <cstring>
#include <vector>
#include <map>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <bitset>
#include <set>
#include <stack>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define RREP(i,n) for(int i=n-1;i>=0;i--)
#define FOR(i,k,n) for(int i=(k);i<(int)(n);i++)
#define all(i,n) (i),(i+n)

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

typedef pair<int, int> P;
typedef pair<string, int> SP;
typedef long long ll;
typedef pair<ll, ll> PLL;

const int INF = 1e9;
const ll LLINF = 1e18;
const int MAX_V = 1e6+1;
const ll mod = 1000000007;
// << fixed << setprecision
// --------------------------------------
int n, x, y;
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);

  cin >> n >> x >> y;
  x--; y--;
  vector<int> ans(n + 1, 0);
  REP(i, n - 1) {
    int t = INF;
    FOR(j, i + 1, n) {
      t = min(abs(j - i), abs(x - i) + 1 + abs(j - y));
      t = min(t, abs(y - i) + 1 + abs(x - j));
      ans[t]++;
    }
  }

  FOR(i, 1, n) cout << ans[i] << endl;
}


Measured memory_bytes: 3656
from collections import deque
A = deque(range(1,10))
B = int(input())
for i in range(B):
    C = 0
    C = A.popleft()
    if C % 10 != 0:
        A.append(C * 10 + C%10-1)
    A.append(C * 10 + C%10)
    if C % 10 != 9:
        A.append(C * 10 + C%10+1)
print(C)
        

Measured memory_bytes: 11908
#pragma warning(disable:4996)
#pragma comment(linker, "/STACK:336777216")
#pragma GCC optimize("Ofast")

#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <functional>

using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
#define int long long int
typedef complex<long double> cd;
const long double pi=acos(-1);
typedef double db;
typedef long double ldb;
typedef pair <int, int> pii;
typedef pair <db, db> pdd;
typedef vector<int> vi;
typedef vector<vector<int> > matrix;

#define m1 make_pair
#define pb push_back
#define flush fflush(stdout)
#define IOS std::ios::sync_with_stdio(false); cin.tie(NULL);cout.tie(NULL);
#define reset(x,v) memset(x,v,sizeof(x))
//#define sz(x) (int)(x.size())
#define fi first
#define se second
#define endl "\n"
#define debug(x) (cerr << #x << ": " << x << "\n")
#define setbits(x) __builtin_popcount(x)
#define setbitsll(x) __builtin_popcountll(x)
#define all(x) x.begin(),x.end()
#define pii pair<int,int>

inline ll gcd(ll a,ll b){if(a==0) return b;return gcd(b%a,a);}
inline ll power(ll a,ll n,ll m){if(n==0)return 1;ll p=power(a,n/2,m);p=(p%m*p%m)%m;if(n%2) return (p%m*a%m)%m;else return p;}
const ll MOD =998244353;
const ll hell=1000000007;
const int INF = 1e17;
const ll LL_INF = 0x3f3f3f3f3f3f3f3f;
typedef tree<int, null_type, less<int>, rb_tree_tag,
tree_order_statistics_node_update>
ordered_set;
const int N=1000005;
void solve()
{
    int h;
    int a;
    cin>>h>>a;
    int ans=ceil((double)h/a);
    cout<<ans<<endl;
}
int32_t main()
{
   
    IOS;
    int t;
    t=1;
    //cin>>t;
    while(t--)
    {
        solve();
    }
    return 0;
}




Measured memory_bytes: 256
import java.util.*;

class Main {
  public static void main(String[] args) {
  Scanner sc = new Scanner(System.in);
  int a=sc.nextInt();
  int b=sc.nextInt();
  int c=sc.nextInt();
  int d=sc.nextInt();
  int e=sc.nextInt();
  int k=sc.nextInt();
  if(e-a<=k){
    System.out.print("Yay!");
  }else{
    System.out.print(":(");
  }
  }
}

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

using namespace std;
using ll =long long;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef pair<int,int> PII;
#define SORT(a) sort((a).begin(),(a).end())
#define rSORT(a) reverse((a).begin(),(a).end())
#define For(i, a, b)    for(int i = (a) ; i < (b) ; ++i)
#define rep(i, n)       For(i, 0, n)
#define debug(x)  cerr << #x << " = " << (x) << endl;
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; }
using P = pair<int,int>;
//Write From this Line

int main()
{
	int n, x;
	cin >> n >> x;
	vector<int> a(n);
	rep(i, n)cin>>a[i];
	SORT(a);
	int ans = 0;
	rep(i,n){
		x -= a[i];
		if(i == n-1){
			if(x == 0){
				 ans ++;
				 break;
			}
			else break;
		}
		if(x >= 0) ans ++;
		else {
			break;
		}
	}
	cout << ans << endl;
}


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

using namespace std;

int l;

bool isPal (string s)
{
  for(int i=0; i<s.length()/2; ++i) if(s[i] != s[s.length()-1-i]) return false;
  return true;
}

int main ()
{
  string s;
  cin >> s;
  
  l = s.length();
  
  string a = s.substr(0, (l-1)/2);
  string b = s.substr((l+3)/2-1);
  
  if(isPal(s) and isPal(a) and isPal(b)) cout << "Yes";
  else cout << "No";
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int func(int N){
    if(N<10) return N;
    return func(N/10) + N%10;
  }
int main(){
  int N;
  cin>>N;
  
    
  int c = func(N);
  if(N%c==0){
    cout<<"Yes"<<endl;
  }
  else cout<<"No"<<endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<set>
#include<tuple>
#include<algorithm>
#include<cmath>
#include<string>
#include<stack>
#include<map>
#include<queue>
#include<iomanip>
#include<numeric>
#define INF 1e9
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(a) (a).begin(),(a).end()
using ll = long long;
using namespace std;
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<typename T1, typename T2> ostream& operator<<(ostream& s, const pair<T1, T2>& p) {return s << "(" << p.first << ", " << p.second << ")";}
template<typename T> ostream& operator<<(ostream& s, const vector<T>& v) {
  int len = v.size();
  for (int i = 0; i < len; ++i) {
    s << v[i]; if (i < len - 1) s << "\t";
  }
  return s;
}

template<typename T> ostream& operator<<(ostream& s, const vector< vector<T> >& vv) {
  int len = vv.size();
  for (int i = 0; i < len; ++i) {
  s << vv[i] << endl;
  }
  return s;
}

int N;
vector<ll> A;
signed main(){
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);
  cin >> N;
  A.resize(N);
  rep(i,N){
    cin >> A[i];
  }

  ll ret = 0;
  ll s_add = 0;
  for(int left = 0, right = 0; left < N ; left++){
    while(right < N && ((s_add ^ A[right]) == (s_add + A[right]))){
      s_add += A[right];
      right++;
    }
    ret += right - left;
    if(left == right){
      right++;
    }
    else{
      s_add -= A[left];
    }
  }
  cout << ret << endl;
  return 0;
}


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

int main() {
  int N, M;
  cin >> N >> M;
  int L[M], R[M];
  for (int i = 0; i < M; i++) cin >> L[i] >> R[i];
  int l_max = 1, r_min = N;
  for (int i = 0; i < M; i++) {
    l_max = max(l_max, L[i]);
    r_min = min(r_min, R[i]);
  }
  cout << max(0, r_min - l_max + 1) << endl;
}

Measured memory_bytes: 1024
#include<iostream>
#include<vector>
#include<algorithm>
#include<cstring>
#include<cstdio>
#include<cmath>
#include<cstdlib>
#include<ctime>
#include<queue>
#include<set>
#include<map>
#include<stack>
#include<bitset>
using namespace std;
typedef long long LL;
const int N=1e5+100,logn=1e7;
int gi() {
	int w=0;bool q=1;char c=getchar();
	while ((c<'0'||c>'9') && c!='-') c=getchar();
	if (c=='-') q=0,c=getchar();
	while (c>='0'&&c <= '9') w=w*10+c-'0',c=getchar();
	return q? w:-w;
}
vector<int>v[N];
vector<int>pri[N];
int c[N],ans[N];
int main()
{
	int n=gi(),m=gi(),i,k,t,l,r;vector<int>::iterator it;
	while (n--) l=gi(),r=gi(),v[r].push_back(l);
	for (k=1;k<=m;k++)
		for (i=k;i<=m;i+=k)
			pri[i].push_back(k);
	for (i=m;i;i--) {
		for (it=v[i].begin();it!=v[i].end();it++)
			for (t=*it;t<=m;t+=t&-t) c[t]++;
		for (it=pri[i].begin();it!=pri[i].end();it++) {
			for (t=i;t;t^=t&-t) ans[*it]+=c[t];
			for (t=i-*it;t;t^=t&-t) ans[*it]-=c[t];
		}
	}
	for (i=1;i<=m;i++)
		printf("%d\n",ans[i]);
	return 0;
}


Measured memory_bytes: 17536
//
//  main.cpp
//

#include <algorithm>
#include <array>
#include <assert.h>
#include <iostream>
#include <limits>
#include <math.h>
#include <memory>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <vector>

using namespace std;

using ll = long long;
using ull = unsigned long long;

template <typename T>
vector<vector<T>> alloc_double_vec(size_t rows, size_t cols, T init) {
    vector<vector<T>> ret;
    vector<T> ret_elem;
    ret_elem.resize(cols, init);
    ret.resize(rows, ret_elem);
    return ret;
}

int main() {
    int r;
    cin >> r;
    cout << 3 * r * r << endl;
}


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

using namespace std;
#define ll long long
const long long mod=1e9+7;
const int maxn=1e3+7;
int a[maxn],b[maxn];

int dp[maxn][maxn];

int main (){
    ll n;cin>>n;
    string ss="";
    while(n){
		n--;
		ss+=('a'+n%26);
		n/=26;
    }
    reverse(ss.begin(),ss.end());
    cout<<ss<<endl;
	return 0;
}


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

#############
# Libraries #
#############

import sys
input = sys.stdin.readline

import math
#from math import gcd
import bisect
import heapq
from collections import defaultdict
from collections import deque
from collections import Counter
from functools import lru_cache

#############
# Constants #
#############

MOD = 10**9+7
INF = float('inf')
AZ = "abcdefghijklmnopqrstuvwxyz"

#############
# Functions #
#############

######INPUT######
def I(): return int(input().strip())
def S(): return input().strip()
def IL(): return list(map(int,input().split()))
def SL(): return list(map(str,input().split()))
def ILs(n): return list(int(input()) for _ in range(n))
def SLs(n): return list(input().strip() for _ in range(n))
def ILL(n): return [list(map(int, input().split())) for _ in range(n)]
def SLL(n): return [list(map(str, input().split())) for _ in range(n)]

#############
# Main Code #
#############

N,K = IL()
data = SLL(N)
base = 10**6

BW_data = [[0 for i in range(2*K)] for i in range(2*K)]

for x,y,c in data:
  x,y = int(x)%(2*K),int(y)%(2*K)
  if c == "B":
    BW_data[y][x] += 1
  else:
    BW_data[y][x] += base

def ACC2(l):
  H = len(l)
  W = len(l[0])
  ret = [[0]*(W+1) for i in range(H+1)]
  for i in range(H):
    for j in range(W):
      ret[i+1][j+1] = ret[i+1][j] + ret[i][j+1] - ret[i][j] + l[i][j]
  return ret

def RANGE_SUM_in_ACC(l,h1,h2,w1,w2):
  return l[h2][w2]-l[h2][w1]-l[h1][w2]+l[h1][w1]

BW_ACC = ACC2(BW_data)

BW_res = [[0 for i in range(2*K)] for i in range(K)]

for j in range(K):
  for i in range(2*K):
    if i<K:
      BW_res[j][i] += RANGE_SUM_in_ACC(BW_ACC,j,j+K,i,i+K)
      BW_res[j][i] += RANGE_SUM_in_ACC(BW_ACC,0,max(0,j),0,max(0,i))
      BW_res[j][i] += RANGE_SUM_in_ACC(BW_ACC,0,max(0,j),min(2*K,i+K),2*K)
      BW_res[j][i] += RANGE_SUM_in_ACC(BW_ACC,min(2*K,j+K),2*K,0,max(0,i))
      BW_res[j][i] += RANGE_SUM_in_ACC(BW_ACC,min(2*K,j+K),2*K,min(2*K,i+K),2*K)
    else:
      BW_res[j][i] = BW_ACC[-1][-1]-BW_res[j][i-K]
      
ans = 0
for j in range(K):
  for i in range(2*K):
    ans = max(ans,BW_res[j][i]%base+BW_res[j][(i+K)%(2*K)]//base)
print(ans)

Measured memory_bytes: 179736
//
// Created by GGG1235 on 2019/11/24.
//

#include <bits/stdc++.h>

#pragma GCC optimize(3)

using namespace std;

typedef long long LL;

int main(int argc,const char **argv,const char **envp) 
{
    ios::sync_with_stdio(false);
    cin.tie();
    
    LL lA;
    LL lB;
    LL lC;
    cin >> lA >> lB >> lC;
    if (lA % 2 == 0 || lB % 2 == 0 || lC % 2 == 0) {
        cout << 0 << endl;
        return 0;
    }
    cout << min(min(lA * lB, lA * lC), lB * lC) << endl;
    return 0;
}

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

using namespace std;

int dp[3005][3005] , go[3005][3005];

int main(){
	string a , b , c = "";
	cin>>a>>b;
	for(int i = 1 ; i <= a.size() ; i++) for(int t = 1 ; t <= b.size() ; t++){
		if(a[i - 1] == b[t - 1]) dp[i][t] = dp[i - 1][t - 1] + 1 , go[i][t] = 2;
		else if(dp[i - 1][t] >= dp[i][t - 1]) dp[i][t] = dp[i - 1][t] , go[i][t] = 3;
		else dp[i][t] = dp[i][t - 1] , go[i][t] = 1;
	}
	// cout<<dp[a.size()][b.size()]<<endl;
	int x = a.size() , y = b.size();
	for(int i = 0 ; i < dp[a.size()][b.size()] ;){
		if(go[x][y] == 1) y--;
		else if(go[x][y] == 2){
			// cout<<a[x - 1]<<endl;
			c = a[x - 1] + c , x-- , y-- , i++;
		}
		else x--;
	}
	cout<<c<<endl;
}

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

#############
# Libraries #
#############

import sys
input = sys.stdin.readline

import math
import bisect
from collections import deque
from fractions import gcd
from functools import lru_cache


#############
# Constants #
#############

MOD = 10**9+7
INF = float('inf')

#############
# Functions #
#############

######INPUT######
def inputI(): return int(input().strip())
def inputS(): return input().strip()
def inputIL(): return list(map(int,input().split()))
def inputSL(): return list(map(str,input().split()))
def inputILs(n): return list(int(input()) for _ in range(n))
def inputSLs(n): return list(input().strip() for _ in range(n))
def inputILL(n): return [list(map(int, input().split())) for _ in range(n)]
def inputSLL(n): return [list(map(str, input().split())) for _ in range(n)]

#####Inverse#####
def inv(n): return pow(n, MOD-2, MOD)

######Combination######
kaijo_memo = []
def kaijo(n):
  if(len(kaijo_memo) > n):
    return kaijo_memo[n]
  if(len(kaijo_memo) == 0):
    kaijo_memo.append(1)
  while(len(kaijo_memo) <= n):
    kaijo_memo.append(kaijo_memo[-1] * len(kaijo_memo) % MOD)
  return kaijo_memo[n]

gyaku_kaijo_memo = []
def gyaku_kaijo(n):
  if(len(gyaku_kaijo_memo) > n):
    return gyaku_kaijo_memo[n]
  if(len(gyaku_kaijo_memo) == 0):
    gyaku_kaijo_memo.append(1)
  while(len(gyaku_kaijo_memo) <= n):
    gyaku_kaijo_memo.append(gyaku_kaijo_memo[-1] * pow(len(gyaku_kaijo_memo),MOD-2,MOD) % MOD)
  return gyaku_kaijo_memo[n]

def nCr(n,r):
  if(n == r):
    return 1
  if(n < r or r < 0):
    return 0
  ret = 1
  ret = ret * kaijo(n) % MOD
  ret = ret * gyaku_kaijo(r) % MOD
  ret = ret * gyaku_kaijo(n-r) % MOD
  return ret

######Factorization######
def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])
    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])
    return arr

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

#####BitCount#####
def bit_count(n):
  count = 0
  while n:
    n &= n -1
    count += 1
  return count

#############
# Main Code #
#############

N,M,C = inputIL()
B = inputIL()

c = 0
for i in range(N):
  A = inputIL()
  if sum(A[j]*B[j]for j in range(M))+C>0:
    c += 1
print(c)

Measured memory_bytes: 64108
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i, n) for (ll i = 0; i < n; ++i)
const ll INF = 1e9;
const ll MOD = 1e9 + 7;
int main()
{
    ll n;
    cin >> n;
    vector<ll> a(n);
    deque<ll> b;
    rep(i, n) { cin >> a[i]; }
    rep(i, n)
    {
        if (i % 2 == n % 2) {
            b.push_back(a[i]);
        } else {
            b.push_front(a[i]);
        }
    }
    rep(i, n)
    {
        printf("%lld ", b[i]);
    }
    return 0;
}

Measured memory_bytes: 5376
#include<stdio.h>
#include<vector>
#include<algorithm>
#include<string.h>
#include<iostream>
#include<queue>
#include<stack>
#define Max 1000
#define INF 1000000000000000000
using namespace std;

long long int calculate(long long int x,long long int y){
	return (x-1)+(y-1);
}

int main(){
	long long int n;
	scanf("%lld",&n);
	long long int i = 1,tmp,min=INF;
	while((i*i)<=n){
		if(n%i == 0){
			tmp = calculate(i,n/i);
			min = (min > tmp)?tmp:min;
		}
		i++;
	}

	printf("%lld\n",min);

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
    int N, M;
    cin >> N >> M;
    vector<vector<bool>> ok(N, vector<bool>(M));
    for(int i = 0; i < N; i++) {
        int k;
        cin >> k;
        for(int j = 0; j < k; j++) {
            int a;
            cin >> a;
            a--;
            ok.at(i).at(a) = true;
        }
    }
    
    int ans = 0;
    for(int i = 0; i < M; i++) {
        bool x = true;
        for(int j = 0; j < N; j++) {
            if(!ok.at(j).at(i)) x = false;
        }
        if(x) ans++;
    }
    
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <vector>
using namespace std;
const int INF = (int)1e9 + 7;

int main() {
    int n, k; cin >> n >> k;
    int q; cin >> q;
    vector<int> a(n);
    for (auto &ai: a) cin >> ai;
    a.emplace_back(-INF);
    int mi = INF;
    for (int min_i = 0; min_i < n; min_i++) {
        vector<int> cand, tmp;
        for (int i = 0; i < n + 1; i++) {
            if (a[i] < a[min_i]) {
                if ((int)tmp.size() >= k) {
                    sort(begin(tmp), end(tmp));
                    for (int _ = 0; _ < k - 1; _++) tmp.pop_back();
                    cand.insert(cand.end(), tmp.begin(), tmp.end());
                }
                tmp.clear();
            } else {
                tmp.emplace_back(a[i]);
            }
        }
        if ((int)cand.size() >= q) {
            sort(begin(cand), end(cand));
            mi = min(mi, cand[q - 1] - cand[0]);
        }
    }
    cout << mi << endl;
    return 0;
}


Measured memory_bytes: 384
using System;
using System.Collections.Generic;
using System.Linq;
public class Hello{
    public static void Main(){
        var a = Console.ReadLine().Split(' ').Select(long.Parse).ToArray();
        var N = a[0];
        var M = a[1];
        
        if(N == 1 && M == 1){
            Console.WriteLine(1);
        }else if(N == 1 || M == 1){
            Console.WriteLine(M * N - 2);
        }else{
            Console.WriteLine((N - 2) * (M - 2));
        }
    }
}


Measured memory_bytes: 11348