akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

//#include <boost/multiprecision/cpp_int.hpp>
// using namespace boost::multiprecision;
// using cint = cpp_int;
//#define input(a) scanf("%lld", &(a))
//#define output(a) printf("%lld\n", (a))

// Define
using ll = long long;
using ull = unsigned long long;
using ld = long double;
const ll MOD = 1e9 + 7;
const ll INF = LONG_MAX;
const ull MAX = ULONG_MAX;
#define mp make_pair
#define pb push_back
#define x first
#define y second
#define endl '\n'
#define space ' '
#define def inline auto
#define func inline constexpr ll
#define run __attribute__((constructor)) def _
#define all(v) begin(v), end(v)

// Debug
#define debug(...)                                                             \
    {                                                                          \
        cerr << __LINE__ << ": " << #__VA_ARGS__ << " = ";                     \
        for (auto &&X : {__VA_ARGS__}) cerr << "[" << X << "] ";               \
        cerr << endl;                                                          \
    }

// Loop
#define inc(i, a, n) for (ll i = (a), _##i = (n); i <= _##i; ++i)
#define dec(i, a, n) for (ll i = (a), _##i = (n); i >= _##i; --i)
#define each(i, a) for (auto &&i : a)
#define rep(i, n) inc(i, 0, n - 1)

// Stream
#define fout(n) cout << fixed << setprecision(n)
#define fasten cin.tie(0), ios::sync_with_stdio(0)

// Speed
run() { fasten, fout(10); }
#pragma GCC optimize("O3")
#pragma GCC optimization_level 3
#pragma GCC target("avx")

// Math
func gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
func lcm(ll a, ll b) { return a * b / gcd(a, b); }

def input() {
    ll A;
    cin >> A;
    return A;
}

#define len(A) (to_string(A).size())

ll N, M, A[100000], B[100000];
vector<vector<ll>> P;

string PUSH(ll A, ll B) {
    string S = "";
    rep(i, 6 - len(A)) S += "0";
    S += to_string(A);
    rep(i, 6 - len(B)) S += "0";
    S += to_string(B);
    return S;
}

signed main() {
    cin >> N >> M;
    rep(i, N) P.pb({});
    rep(i, M) {
        cin >> A[i] >> B[i];
        P[A[i] - 1].pb(B[i]);
    }
    rep(i, N) sort(all(P[i]));
    rep(i, M) {
        ll K = lower_bound(all(P[A[i] - 1]), B[i]) - P[A[i] - 1].begin();
        cout << PUSH(A[i], K + 1) << endl;
    }
}

// for compilation: g++ -Ofast -march=native -o _ _.cpp -std=c++17


Measured memory_bytes: 8560
#include<bits/stdc++.h>
using namespace std;
#define int long long
signed main(){
  int x,k;
  cin>>x>>k;
  int r[k];
  for(int i=0;i<k;i++) cin>>r[i];
  int q;
  cin>>q;
  int t[q],a[q];
  for(int i=0;i<q;i++) cin>>t[i]>>a[i];
  int L=0,R=x;//[L,R]
  int j=0,p=0,d=0;
  int lv=0,uv=x;
  for(int i=0;i<q;i++){
    while(j<k&&r[j]<=t[i]){
      if(j%2==0){
	p+=r[j]-d;
	lv=max(lv-(r[j]-d),0LL);
	uv=max(uv-(r[j]-d),0LL);
      }else{p-=r[j]-d;
	lv=min(lv+(r[j]-d),x);
	uv=min(uv+(r[j]-d),x);
      }
      L=max(L,p);
      R=min(R,x+p);
      d=r[j++];
    }
    int c;
    if(L<=a[i]&&a[i]<=R) c=a[i]-p;
    if(a[i]<L) c=lv;
    if(R<a[i]) c=uv;
    if(j%2==0) c=max(c-(t[i]-d),0LL);
    else c=min(c+(t[i]-d),x);
    cout<<c<<endl;
  }
  return 0;
}


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

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

    vector<int> A(N);
    for (int i = 0; i < N; i++)
    {
        cin >> A[i];
    }

    map<int, int> operation;
    int B, C;
    for (int i = 0; i < M; i++)
    {
        cin >> B >> C;
        operation[C] += B;
    }

    sort(A.begin(), A.end());
    int idx = 0;
    for (auto itr = operation.rbegin(); itr != operation.rend(); itr++)
    {
        int b = itr->second;
        int c = itr->first;
        while (idx < A.size() && c > A[idx] && b > 0)
        {
            A[idx] = c;
            b--;
            idx++;
        }
    }

    long long ans = 0;
    for (int a : A)
    {
        ans += a;
    }
    cout << ans << endl;
}


Measured memory_bytes: 5376
#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;
use std::io::{Write, BufWriter};
// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, [ $t:tt ]) => {{
        let len = read_value!($next, usize);
        (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    }};

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

#[allow(unused)]
macro_rules! debug {
    ($($format:tt)*) => (write!(std::io::stderr(), $($format)*).unwrap());
}
#[allow(unused)]
macro_rules! debugln {
    ($($format:tt)*) => (writeln!(std::io::stderr(), $($format)*).unwrap());
}

fn solve() {
    let out = std::io::stdout();
    let mut out = BufWriter::new(out.lock());
    macro_rules! puts {
        ($($format:tt)*) => (write!(out,$($format)*).unwrap());
    }
    input!(s: chars);
    const INF: i64 = 1 << 50;
    let n = s.len();
    let mut dp = vec![[-INF; 3]; n + 1];
    dp[0][0] = 0;
    for i in 1..n + 1 {
        for l in 1..min(2, i) + 1 {
            for k in 0..3 {
                if dp[i - l][k] <= -INF { continue; }
                if s[i - l - k..i - l] != s[i - l..i] {
                    dp[i][l] = max(dp[i][l], dp[i - l][k] + 1);
                }
            }
        }
    }
    let mut ma = -INF;
    for i in 0..3 {
        ma = max(ma, dp[n][i]);
    }
    puts!("{}\n", ma);
}

fn main() {
    // In order to avoid potential stack overflow, spawn a new thread.
    let stack_size = 104_857_600; // 100 MB
    let thd = std::thread::Builder::new().stack_size(stack_size);
    thd.spawn(|| solve()).unwrap().join().unwrap();
}


Measured memory_bytes: 14588
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
typedef long long ll;
const int INF (1<<30);

int mod = 1e9+7;
struct mint {
  ll x;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const {
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res*=a;
  }
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  mint inv() const {
    return pow(mod-2);
  }
  mint& operator/=(const mint a) {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const {
    mint res(*this);
    return res/=a;
  }
};

int main() {
  int N, P;
  cin >> N >> P;
  string S;
  cin >> S;
  reverse(all(S));

  auto corner = [&](int a) {
    ll ansC = 0LL;
    rep(i,S.length()) {
      int si = S[i] - '0';
      if (si%a == 0) ansC += (N-i);
    }
    return ansC;
  };


  ll ans = 0LL;
  if (P == 2) {
    ans = corner(2);
  }
  else if (P == 5) {
    ans = corner(5);
  }
  else {
    mod = P;
    vector<mint> sum(N);
    sum[0] = (S[0]-'0') % P;
    for (int i = 1; i < N; i++) {
      mint z = 10;
      sum[i] = (mint)(S[i]-'0')*z.pow(i) + sum[i-1];
    }
    vector<int> tmp(P, 0);
    rep(i, N) {
      tmp[sum[i].x]++;
    }

    rep(i, P) {
      ll y = tmp[i];
      if (i == 0) ans += (y+1) * y / 2;
      else ans += y * (y-1) / 2;
    }
  }
   

  cout << ans << endl;

  return 0;
}


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

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

int cnt[256];
void solve() {
  int n;
  string s;
  cin >> n >> s;
  for(int i = 0; i < n; i++) cnt[s[i]]++;
  ll ret = 1;
  for(int i = 0; i < 256; i++) {
    ret *= ++cnt[i];
    ret %= 1000000007;
  }
  ret--;
  cout << ret << endl;
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL); cout.tie(NULL);
  solve();
}


Measured memory_bytes: 512
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        
        Scanner sc = new Scanner(System.in);
        
        int N = sc.nextInt();
        int[] H = new int[N];
        
        for(int i = 0; i < N; i++){
            H[i] = sc.nextInt();
        }
        
        int maxH = 0;
        int count = 1;
        for(int i = 1; i < N; i++){
            maxH = Math.max(maxH, H[i-1]);
            if(maxH <= H[i]) count++;
        }
        
        System.out.println(count);
    }
}


Measured memory_bytes: 21844
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <tuple>
#include <cstring>
#include <functional>
using namespace std;
typedef long long ll;
typedef pair<long long, long long> P;
#define rep(i, n) for(long long i=0; i<n; i++)
#define reps(i, s, e) for(long long i=s; i<e; i++)
#define repr(i, n) for(long long i=n-1; i>=0; i--)
#define reprs(i, s, e) for(long long i=e-1; i>=s; i--)



struct UnionFind {
    vector<int> par;

    UnionFind(int n): par(n, -1) {};
    
    void init(int n) { par.assign(n, -1); }

    int root(int x){
        if(par[x] < 0) return x;
        else return par[x] = root(par[x]);
    }

    bool issame(int x, int y){
        return root(x) == root(y);
    }

    bool merge(int x, int y){
        x = root(x);
        y = root(y);

        if(x == y) return false;
        if(par[x] > par[y]) swap(x, y);
        par[x] += par[y];
        par[y] = x;
        return true;
    }

    int size(int x){
        return -par[root(x)];
    }
};


int main(){

    cin.tie(0);
    ios::sync_with_stdio(false);

    ll n, m; cin >> n >> m;
    ll x[m], y[m], z[m];
    rep(i, m){
        cin >> x[i] >> y[i] >> z[i];
        x[i]--; y[i]--;
    }

    UnionFind uf = UnionFind(n);
    rep(i, m){
        uf.merge(x[i], y[i]);
    }

    set<ll> st;
    rep(i, n){
        st.insert(uf.root(i));
    }

    cout << st.size() << endl;

    return 0;
}

Measured memory_bytes: 7680
#include<cstdio>
#include<vector>
#include<map>
#include<string>
#include<utility>
#include<algorithm>


using namespace std;


int a[200000], b[200000];
int n;
int c, cc;

int main(){
  scanf("%d", &n);
  for(int i = 0; i < n; i++){
    scanf("%d", &a[i]);
  }
  for(int i = 0; i < n; i++){
    b[i] = a[i];
  }
  sort(a, a+n);

  c = a[(n - 1)/2];
  cc = a[(n - 1)/2 + 1];

  for(int i = 0; i < n; i++){
    if(b[i] <= c){
      printf("%d\n", cc);
    }else{
      printf("%d\n", c);
    }
  }
  return 0;
}

Measured memory_bytes: 3712
#include <cstdio>
#include <cmath>
#include <iostream>
#include <set>
#include <algorithm>
#include <vector>
#include <map>
#include <cassert>
#include <string>
#include <cstring>
#include <queue>

using namespace std;

#define rep(i,a,b) for(int i = a; i < b; i++)
#define S(x) scanf("%d",&x)
#define S2(x,y) scanf("%d%d",&x,&y)
#define P(x) printf("%d\n",x)
#define all(v) v.begin(),v.end()
#define FF first
#define SS second
#define pb push_back
#define mp make_pair

typedef long long int LL;
typedef pair<int, int > pii;
typedef vector<int > vi;

const int mod = 998244353;
const int N = 100005;

map<int, int > grid[N];
vi rows[N], cols[N];
int diag[N];
int n;
LL P2[N];
int dp[N][2];

void pre() {
  P2[0] = 1;
  rep(i,1,N) {
    P2[i] = P2[i - 1] * 2 % mod;
  }
}

int getVal(int x, int y) {
  if(grid[x].find(y) == grid[x].end()) {
    return -1;
  }
  return grid[x][y];
}

int solve(int idx, int parity) {
  if(idx == n + 1) {
    return 1;
  }
  int &res = dp[idx][parity];
  if(res != -1) {
    return res;
  }
  res = 0;
  // printf("%d %d\n",idx, parity);

  int tot = idx - 2;
  rep(i,0,rows[idx].size()) {
    int y = rows[idx][i];
    if(y == idx - 1) continue;
    int a = getVal(idx, y);
    int b = getVal(y, idx);
    if(a != -1 && b != -1) {
      if(y == idx - 2) {
        if((a ^ b) != parity) return res = 0;
      } else {
        if(a != b) return res = 0;
      }
    }
    tot--;
  }

  rep(i,0,cols[idx].size()) {
    int x = cols[idx][i];
    if(x == idx - 1) continue;
    int a = getVal(x, idx);
    int b = getVal(idx, x);
    if(b != -1) continue; // processed already
    tot--;
  }
  LL ways = P2[tot];

  int cnt = 0;

  int lb = getVal(idx, idx - 1);
  if(lb != -1) {
    parity ^= lb;
  } else {
    cnt++;
  }

  int rt = getVal(idx - 1, idx);
  if(rt != -1) {
    parity ^= rt;
  } else {
    cnt++;
  }

  if(diag[idx] != -1) {
    int np = parity ^ diag[idx];

    if(cnt == 0) {
      if(np == 0) {
        res += ways * solve(idx + 1, diag[idx]) % mod;
        if(res >= mod) {
          res -= mod;
        }
      }
    } else {
      res += (cnt * ways % mod) * solve(idx + 1, diag[idx]) % mod;
      if(res >= mod) {
        res -= mod;
      }
    }

  } else {
    int np = parity;

    if(cnt == 0) {
      res += ways * solve(idx + 1, np) % mod;
      if(res >= mod) {
        res -= mod;
      }
    } else {
      res += (P2[cnt - 1] * ways % mod) * solve(idx + 1, 0) % mod;
      if(res >= mod) {
        res -= mod;
      }

      res += (P2[cnt - 1] * ways % mod) * solve(idx + 1, 1) % mod;
      if(res >= mod) {
        res -= mod;
      }
    }
  }

  return res;
}

int main() {
  pre();
  int m;
  S2(n,m);
  memset(diag, -1, sizeof(diag));
  rep(i,0,m) {
    int a,b,c;
    scanf("%d%d%d",&a,&b,&c);
    grid[a][b] = c;
    if(b < a) {
      rows[a].pb(b);
    } else if(a < b) {
      cols[b].pb(a);
    } else {
      diag[a] = c;
    }
  }

  memset(dp, -1, sizeof(dp));
  int ans = 0;
  if(diag[1] == -1) {
    ans = solve(2, 0) + solve(2, 1);
    ans %= mod;
  } else {
    ans = solve(2, diag[1]);
  }
  P(ans);
  return 0;
}


Measured memory_bytes: 24832
def main():
    x, n = map(int, input().rstrip().split(' '))
    if n == 0:
        print(x)
        return
    p = list(map(int, input().rstrip().split(' ')))
    if x not in p:
        print(x)
        return
    for i in range(1, 101):
        j, k = x - i, x + i
        # print(j, k)
        if j not in p:
            print(j)
            return
        if k not in p:
            print(k)
            return
    
    

if __name__ == '__main__':
    main()


Measured memory_bytes: 9196
#include<bits/stdc++.h>
#define all(x) (x).begin(),(x).end()

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

const ll inf = 2e18;
const ll mod = 1e9 + 7;
const ll N = 1e6 + 5;

int n, primes[N], a[N], ok = 0;

map<int, int> cnt;

void pf(int n) {
    int f = 0;
    while (n % 2 == 0) {
        n /= 2;
        f = 1;
    }


    if (f and cnt[2] > 0) {
        ok = 1;
        return;
    }

    else if (f) cnt[2]++;

    for (int i = 3; i * i <= n; i += 2) {
        f = 0;
        while (n % i == 0) n /= i, f = 1;
        if (f and cnt[i] > 0) {
            ok = 1;
            return;
        }
        else if (f) cnt[i]++;
    }


    if (n > 1) {
        if (cnt[n] > 0) {
            ok = 1;
            return;
        }

        else cnt[n]++;
    }
}

void code() {
    cin >> n;
    for (int i = 0; i < n; i++) cin >> a[i];

    for (int i = 0; i < n; i++) {
        pf(a[i]);
    }

    if (!ok) {
        cout << "pairwise coprime\n";
        return;
    }

    vector<int> suff(n + 1, 0); int gc = 0;
    for (int i = n - 1; i >= 0; i--) {
        suff[i] = __gcd(suff[i + 1], a[i]);
        gc = __gcd(gc, a[i]);
    }

    if (gc == 1) {
        cout << "setwise coprime\n";
        return;
    }

    cout << "not coprime\n";
}

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

    int t = 1;
    // cin>>t;

    while (t-- > 0) {
        code();
    }
}

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

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

#define pb push_back
#define ff first
#define ss second
#define SIZE 500002
#define INF 2e9 + 9
#define acmpIN "input.txt"
#define acmpOUT "output.txt"

//#pragma GCC optimize("Ofast")
//


ll n, m, ans;




int main()
{

    ios_base::sync_with_stdio(false);
    cin.tie(0);cout.tie(0);
//    freopen(acmpIN, "r", stdin);
//    freopen(acmpOUT, "w", stdout);


    cin >> n >> m;


    if(n == 1 || m == 1) {cout << 1; return 0;}

    n *= m;

    ans = (n + 1) / 2;



    cout << ans;

    return 0;
}



Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApplication4
{
    class Program
    {

        static void Main(string[] args)
        {
            var num = Console.ReadLine().Split().Select(x => int.Parse(x.ToString())).ToArray();

            int res = 0;
            if (num[0] == num[1])
            {
                res = num[2];
            }
            else if (num[0] == num[2])
            { res = num[1]; }
            else { res = num[0]; }

            

            Console.WriteLine(res);

        }

       

    }
}


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

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;

#define fi first
#define se second
#define repl(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define rep(i,n) repl(i,0,n)
#define each(itr,v) for(auto itr:v)
#define pb push_back
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define mmax(x,y) (x>y?x:y)
#define mmin(x,y) (x<y?x:y)
#define maxch(x,y) x=mmax(x,y)
#define minch(x,y) x=mmin(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt __builtin_popcount

#define INF INT_MAX/3

int n;
char s[22],t[22];
int res;

void dfs(int d,int nc){
  int idx=d;
  while(idx<n&&s[idx]==t[idx])idx++;
  if(idx==n){
    minch(res,nc);
    return ;
  }
  if(nc>res)return ;

  int add=(t[idx]-s[idx]+10)%10;
  string tmp;
  repl(i,idx,n)tmp+=s[i];
  repl(i,idx,n){
    s[i]=(char)('0'+(s[i]-'0'+add)%10);
    dfs(idx,nc+1);
  }
  repl(i,idx,n)s[i]=tmp[i-idx];
  return ;
}

int main(){
	cin.sync_with_stdio(false);
  while(1){
    cin>>n;
    if(n==0)break;
    cin>>s>>t;
    res=INF;
    dfs(0,0);
    cout<<res<<endl;
  }
	return 0;
}

Measured memory_bytes: 3180
N, K = map(int, input().split())
A = list(map(int, input().split()))

L = 50*50
dp = [[0 for _ in range(L+1)] for _ in range(N+1)]
dp[0][0] = 1

for i in range(N):
    a = A[i]
    for j in reversed(range(N)):
        for l in range(L+1):
            if l < a: continue
            dp[j+1][l] += dp[j][l-a]

ans = 0
for j in range(N):
    ans += dp[j+1][(j+1)*K]
print(ans)

Measured memory_bytes: 43372
#include<iostream>
#include<algorithm>
#include<cmath>
#include<vector>
#include<string>
#include<queue>
#include<set>
#include<map>
using namespace std;
typedef long long int ll;
typedef vector<pair<ll,ll> > Q;
typedef pair<int,int> P;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
const ll inf=1e9+7;

int main(){
  string s,ans;
  cin>>s;

  int t,len=s.size();
  for(t=0;t<len;t++){
    if(s.at(t)=='0') ans.push_back('0');
    else if(s.at(t)=='1') ans.push_back('1');
    else if(s.at(t)=='B' && ans.size()>0) ans.pop_back();
  }

  cout<<ans<<endl;
}

Measured memory_bytes: 256
A=list(input())
B=list(input())
C=list(input())

x=A.pop(0)
for i in range(300):
  if x=="a":
    x=""
    try:
      x=A.pop(0)
    except:
      print("A")
      break
  elif x=="b":
    x=""
    try:
      x=B.pop(0)
    except:
      print("B")
      break
  else:
    x=""
    try:
      x=C.pop(0)
    except:
      print("C")
      break

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
string a, b;
int dp[3004][3004], cont = 0;
int f(int n, int m){
	if(n == a.size() || m == b.size()) return 0;
	if(dp[n][m] != -1) return dp[n][m];
	if(a[n] == b[m]) return dp[n][m] = 1 + f(n+1, m+1);
	return dp[n][m] = max( max(f(n+1,m+1), f(n, m+1)), f(n+1, m));
}
void rec(int n, int m){
	if(n == a.size() || m == b.size()) return;
	if(a[n] == b[m] && cont < f(0,0)){
		cout << a[n];
		cont++;
		rec(n+1,m+1);
	}
	int ans1 = f(n+1,m+1), ans2 = f(n, m+1), ans3 = f(n+1, m);
	int maxi = max(max(ans1, ans2), ans3);
	if(ans1 == maxi) rec(n+1, m+1);
	else if(ans2 == maxi) rec(n, m+1);
	else rec(n+1, m);
}
int main() {
	cin >> a >> b;
	memset(dp, -1, sizeof(dp));
	f(0,0);
	rec(0, 0);
	return 0;
}

Measured memory_bytes: 35840
#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
#include<sstream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<climits>
#include<cmath>
#include<string>
#include<vector>
#include<set>
#include<map>
#include<queue>
#include<numeric>
#include<functional>
#include<algorithm>
#include<bitset>
#include<tuple>
#include<unordered_set>
#include<random>
#include<array>
#include<cassert>
using namespace std;
#define INF (1<<29)
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(v) v.begin(),v.end()
#define uniq(v) v.erase(unique(all(v)),v.end())


int n, a[100000];


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

	cin>>n;
	int mi=INF,ma=0;
	rep(i,n){
		cin >> a[i];
		mi = min(mi,a[i]);
		ma = max(ma,a[i]);
	}
	int uni = count(a,a+n,mi);
	int nuni = n-uni;
	if (mi==ma && mi==n-1){
		cout << "Yes" << endl;
		return 0;
	}

	if (mi!=ma&&mi+1!=ma){
		cout << "No"<<endl;
		return 0;
	}
	if (mi==ma && n/2 < ma){
		cout << "No" << endl;
		return 0;
	}
	if (mi + 1 == ma && (nuni==1 || (nuni/2+uni)<ma || ma<uni+1) ){
		cout << "No" << endl;
		return 0;
	}
	cout << "Yes"<<endl;

	return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  int N,W,w[100],v[100];
  long long int dp[101][100001];
  
  cin >> N >> W;
  
  for(int i=0; i<N; i++){
    cin >> w[i] >> v[i];
  }
  
  //dp[i][j] -> i番目以降のものから容量j選ぶときの価値の最大値
  for(int i=N; i>=0; i--){
    for(int j=0; j<=W; j++){
      if(i==N) dp[i][j] = 0; //1つも選べない
      else if(j<w[i]) dp[i][j] = dp[i+1][j]; //i番目の品物が入らない
      else dp[i][j] = max( dp[i+1][j],              //入れない
                           dp[i+1][j-w[i]] + v[i]); //入れる
    }
  }
  
  cout << dp[0][W] << endl;
  
  return 0;
}

Measured memory_bytes: 79104
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
const int MAXN=1e5;

int main()
{
    LL x,y;
    while(scanf("%lld%lld",&x,&y)!=EOF)
    {
        LL ans=0;
        LL now=x;
        while(now<=y)
        {
            ans++;
            now*=2;
        }
        printf("%lld\n",ans);
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll mod = 1000000007;
const int INF = 1001001001;

template<class Type>
Type modpow(Type a, Type n, Type mod)
{
	Type res = 1;
	while (0 < n) {
		if (n & 1) {
			res = res * a % mod;
		}
		a = a * a % mod;
		n >>= 1;
	}
	return res;
}

template<class Type>
Type gcd(Type x, Type y)
{
	Type r;
	if (x < y) swap(x, y);

	while (0 < y) {
		r = x % y;
		x = y;
		y = r;
	}
	return x;
}

template<class Type>
Type lcm(Type x, Type y)
{
	return x * y / gcd(x, y);
}

template<class Type>
bool is_prime(Type x)
{
	if (x == 2) return true;
	if (x < 2 || x % 2 == 0) return false;

	for (Type i = 3; i <= sqrt(x); i += 2) {
		if (x % i == 0) return false;
	}
	return true;
}

template<class Type>
vector<bool> eratos(Type n)
{
	vector<bool> isPrime(n + 1, true);
	isPrime[0] = isPrime[1] = false;
	for (Type i = 2; i <= n; i++) {
		if (isPrime[i]) {
			Type j = i + i;
			while (j <= n) {
				isPrime[j] = false;
				j = j + i;
			}
		}
	}
	return isPrime;
}

bool binary_search_judge(vector<int> a, int index, int key)
{
	if (key <= a[index]) return true;
	else return false;
}

int binary_search(vector<int> a, int key)
{
	int ng = -1;
	int ok = a.size();
	while (1 < abs(ng - ok)) {
		int mid = (ng + ok) / 2;
		if (binary_search_judge(a, mid, key)) ok = mid;
		else ng = mid;
	}
	return a[ok] == key;
}

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

	if (10 <= n) cout << r << endl;
	else cout << r + 100 * (10 - n) << endl;
}

Measured memory_bytes: 256
# トポロジカルソート
def main():
    Graph = [] ##appendのために宣言が必要
    V,E = map(int,input().split())
    # V：頂点数
    # E：辺数
    # 入力受付
    i = 0
    while i < E:
        try:
            Graph.append(list(map(int,input().split())))
            i = i + 1
        except:
            break;
            #または、quit(),os.exit()をして止める。

    point_dict = {}
    result = topological_sort(V,E,Graph,point_dict)
    print(result)

# 初期化
def initialize(v,pdict):
    i = 0
    while i < v:
        pdict[i] = 0
        i = i + 1
    return pdict

# 辺の数計算
def count_node(graph,pdict):
    i = 0
    while i < len(graph):
        pdict[graph[i][1]] = pdict[graph[i][1]] + 1
        i = i + 1
    return pdict

# 入り辺がない点を除去
def remove_point(graph,pdict):
    i = 0
    count_remove = 0
    # 入り辺がない点を探索
    while i < len(pdict):
        if pdict[i] == 0:
            m = 0
            while m < len(graph):
                # 入り辺がない頂点が始点になっている行を削除
                # i : 入り辺がない点の番号
                if graph[m][0] == i:
                    graph.pop(m)
                    # popすると行列のサイズが一つ減るので
                    m = m - 1
                    count_remove = count_remove + 1
                m = m + 1
        i = i + 1
    return (graph,count_remove)

def topological_sort(v,e,graph,pdict):
    pdict = initialize(v, pdict)
    pdict = count_node(graph,pdict)
    """
    print()
    print("Graph")
    print(graph)
    print("pdict")
    print(pdict)
    """
    graph,count_remove = remove_point(graph, pdict)
    """
    print("Graph_Remove")
    print(graph)
    print(count_remove)
    print("-----------------------------")
    """
    if len(graph) == 0:
        return 0
    elif count_remove == 0:
        return 1
    elif count_remove > 0:
        return topological_sort(v,e,graph,pdict)


if __name__ == '__main__':
    main()



Measured memory_bytes: 5644
#include <iostream>
#include <string>
using namespace std;
int main() {
    int str;
    cin >> str;
    if(str == 25){
        std::cout << "Christmas" << std::endl;
        return 0;
    }
    if(str == 24){
        std::cout << "Christmas Eve" << std::endl;
        return 0;
    }
    if(str == 23){
        std::cout << "Christmas Eve Eve" << std::endl;
        return 0;
    }
    if(str == 22){
        std::cout << "Christmas Eve Eve Eve" << std::endl;
        return 0;
    }
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
/* run this program using the console pauser or add your own getch, system("pause") or input loop */
using namespace std;
int main() {
	string s;
	cin>>s;
	if(s=="ABC")
	{
		cout<<"ARC";
	}
	else
	{
		cout<<"ABC";
	}
	return 0;
}

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

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

typedef int _loop_int;
#define REP(i,n) for(_loop_int i=0;i<(_loop_int)(n);++i)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1;i>=(_loop_int)(a);--i)

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

#define CHMIN(a,b) a=min((a),(b))
#define CHMAX(a,b) a=max((a),(b))

// mod
const ll MOD = 1000000007ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

// floating
typedef double Real;
const Real EPS = 1e-11;
#define EQ0(x) (abs(x)<EPS)
#define EQ(a,b) (abs(a-b)<EPS)
typedef complex<Real> P;

int n;
int a[125252];

int main(){
  scanf("%d",&n);
  REP(i,n)scanf("%d",a+i);
  sort(a,a+n);
  bool ok = true;
  if(n%2==1){
    if(a[0]!=0)ok=false;
    REP(i,n/2)if(a[2*i+1]!=2*i+2 || a[2*i+2]!=2*i+2)ok=false;
  }else{
    REP(i,n/2)if(a[2*i]!=2*i+1 || a[2*i+1]!=2*i+1)ok=false;
  }
  int ans = 1;
  if(ok){
    REP(i,n/2)ans=ans*2%MOD;
  }else{
    ans = 0;
  }
  cout<<ans<<endl;
  return 0;
}


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

int main(void) {
	double x[4], y[4];
	double xp, yp;

	while(cin >> x[0] >> y[0] >> x[1] >> y[1] >> x[2] >> y[2] >> xp >> yp) {
		bool l, r;
		l = r = false;
		
		x[3] = x[0];
		y[3] = y[0];

		for(int i = 0; i < 3; i++) {
			double ax = x[i+1] - x[i];
			double ay = y[i+1] - y[i];
			double px = xp - x[i];
			double py = yp - y[i];
			if(ax*py - ay*px < 0)
				r = true;
			else
				l = true;
		}
		cout << (r != l ? "YES" : "NO") << endl;
	}
	return 0;
}

Measured memory_bytes: 1216
#include <math.h>
#include <stdlib.h>
#include <string.h>
#include <algorithm>
#include <array>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

using namespace std;

int main() {
    int A,B,C;
    cin>>A>>B>>C;
    if(A==B)cout<<C<<endl;
    if(C==A)cout<<B<<endl;
    if(C==B)cout<<A<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define double long double
#define rep(i,n) for(int i=0;i<n;i++)
int n,m;
vector<vector<char>>a(55,vector<char>(55)),b(55,vector<char>(55)),c(55,vector<char>(55));
bool ans=false;
signed main(){
    cin>>n>>m;
    rep(i,n){
        rep(j,n)cin>>a[i][j];
    }
    rep(i,m){
        rep(j,m)cin>>b[i][j];
    }
    rep(i,n){
        rep(j,n){
            if(i+m>n||j+m>n)continue;
            rep(k,m){
                rep(l,m){
                    c[k][l]=a[i+k][j+l];
                }
            }
            if(b==c)ans=true;
        }
    }
    if(ans)puts("Yes");
    else puts("No");
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <string>
#include <cstdio>
#include <cstdlib>
#include <cmath>

using namespace std;

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

  vector< long long int > a(N);
  vector< long long int > b(N);
  vector< long long int > c(M);
  vector< long long int > d(M);

  for(int i = 0; i < N; i++) cin >> a[i] >> b[i];
  for(int i = 0; i < M; i++) cin >> c[i] >> d[i];

  for(int i = 0; i < N; i++) {
    long long int res = 1e10;
    int ans = -1;
    for(int j = 0; j < M; j++) {
      if(res > abs(a[i]-c[j])+abs(b[i]-d[j])) {
	res = abs(a[i]-c[j])+abs(b[i]-d[j]);
	ans = j;
      }
    }
    cout << ans + 1 << endl;
  }
 
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
	
	long long n,k;
	
	cin >> n >> k;

	vector<long long> v(100000,0);
	
	for(int i = 0;i < n;i++){
		
		long long a,b;
		
		cin >> a >> b;
		
		v[a - 1] += b;
		
	}
	
	for(int i = 0;i < 100000;i++){
		
		if(v[i] >= k){
			cout << i + 1 << endl;
			return 0;
		}
		
		k -= v[i];
		
	}
	
	return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define ll long long int
using namespace std;
ll i, temp,t,A, B, C, K, n, a[200600];
int main()
{
    //I am Monim, a tiny creature of Allah
    cin >> A >> B >> C >> K;
    while(K--)
    {
        if(A>=B)
        {
            B *= 2;
        }
        else{
            C *= 2;
        }
    }
    if(A<B && B<C)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 3640
#include <iostream>
#include <vector>
#include <iomanip>
#include <cmath>
#include <algorithm>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
template<class T> inline void chmin(T& a, T b) {if (a>b) a=b; }
template<class T> inline void chmax(T& a, T b) {if (a<b) a=b; }
inline void print() { cout << endl; }
template <class Head, class... Tail> inline void print(Head&& head, Tail&&... tail) {cout << head; if (sizeof...(tail) != 0) cout << " "; print(forward<Tail>(tail)...);}
template <class T> inline void print(vector<T>& vec) { for (auto& a : vec) {cout << a; if (&a != &vec.back()) cout << " "; } cout << endl;}
template <class T> inline void print(vector<vector<T>>& df) { for (auto& vec : df) { print(vec); }}
typedef long long ll;
const ll LINF = 1e18;
const int INF = 1e9;

template <typename T1, typename T2>
bool compare_by_second(const pair<T1, T2> &a, const pair<T1, T2> &b) {
    if (a.second != b.second) {
        return a.second < b.second;
    } else {
        return a.first < b.first;
    }
}
void show(const vector<pair<int, int>> &v) {
    // print("______");
    // print(v.size());
    REP(i, v.size()) {
        // print(v[i].second);
        cout << v[i].second << " ";
    }
    cout << endl;
}


int main() { 
    int N; cin >> N;
    vector<pair<int, int>> A;
    REP(i, N) {
        int a; cin >> a;
        auto p = make_pair(a, i+1);
        // print(p.first, p.second);
        A.push_back(p);
    }
    sort(A.begin(), A.end());
    // sort(A.begin(), A.end(), greater<pair<int, int>>());
    show(A);

    
    return 0;
}

Measured memory_bytes: 1780
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>
#define MAX(x,y) ((x>y)?(x):(y))
#define Min(x,y) ((x<y)?(x):(y))

double dp[3005];
int sugar[3005];
int main(){
	int i,j;
	int a, b, c, d, e, f;

	scanf("%d%d%d%d%d%d", &a, &b, &c, &d, &e, &f);

	for (i = 0; i <=f; i++) dp[i] = -1.0;
	dp[100*a] = 0.0;
	sugar[100*a] = 0;
	if (100*b <= f) {
		dp[100*b] = 0.0;
		sugar[100*b] = 0;
	}
	
	for (i = 0; i <= f; i++) {
		if (dp[i] == -1.0) continue;
		
		// water : + 100A
		if (i + 100*a <= f &&
		    dp[i + 100*a] <  100 * (double)sugar[i] / (double)(i + 100*a)) {
			dp[i + 100*a] = 100 * (double)sugar[i] / (double)(i + 100*a);
			sugar[i + 100*a] = sugar[i];
		}
		// water : + 100B
		if (i + 100*b <= f &&
		    dp[i + 100*b] <  100 * (double)sugar[i] / (double)(i + 100*b)) {
			dp[i + 100*b] = 100 * (double)sugar[i] / (double)(i + 100*b);
			sugar[i + 100*b] = sugar[i];
		}
		// sugar : +c
		if (i + c <= f &&
		    dp[i + c] < 100 * (double)(sugar[i] + c) / (double)(i + c) && 
		    e * (i - sugar[i]) >= (sugar[i] + c) * 100) {
			dp[i + c] = 100 * (double)(sugar[i] + c) / (double)(i + c);
			sugar[i + c] = sugar[i] + c;
		}
		// sugar : +d
		if (i + d <= f &&
		    dp[i + d] < 100 * (double)(sugar[i] + d) / (double)(i + d) && 
		    e * (i - sugar[i]) >= (sugar[i] + d) * 100) {
			dp[i + d] = 100 * (double)(sugar[i] + d) / (double)(i + d);
			sugar[i + d] = sugar[i] + d;
		}
	}

	int ans_w, ans_s;
	double ans_p;
	ans_p = 0.0;
	ans_w = 100*a;
	ans_s = 0;
	for (i = 100*a + 1; i <= f; i++) {
		if (ans_p < dp[i]) {
			ans_s = sugar[i];
			ans_w = i - sugar[i];
			ans_p = dp[i];
		}
	}
	
	printf("%d %d\n", ans_w+ans_s, ans_s);

	return 0;
}


Measured memory_bytes: 128
import java.io.*;
import java.util.*;

public class Main {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int h = scan.nextInt();
        int w = scan.nextInt();
        String[][] input = new String[h][w];
        for (int i = 0; i < h; i++) {
            String s = scan.next();
            for (int j = 0; j < s.length(); j++) {
                input[i][j] = s.substring(j, j + 1);
            }
        }
        int solve = dp(h, w, input);
        System.out.println(solve);
    }

    public static int dp(int h, int w, String[][] input) {
        int mod = (int)Math.pow(10, 9) +7;
        int[][] arr = new int[h][w];
        arr[0][0] = 1;
        for (int i = 1; i < h; i++) {
            if (!input[i][0].equals("#")) {
                arr[i][0] = arr[i - 1][0]%mod;
            } else {
                arr[i][0] = 0;
            }
        }
        for (int i = 1; i < w; i++) {
            if (!input[0][i].equals("#")) {
                arr[0][i] = arr[0][i - 1]%mod;
            } else {
                arr[0][i] = 0;
            }
        }
        for (int i = 1; i < h; i++) {
            for (int j = 1; j < w; j++) {
                if (!input[i][j].equals("#")) {
                    arr[i][j] = (arr[i - 1][j]%mod + arr[i][j - 1]%mod)%mod;
                } else {
                    arr[i][j] = 0;
                }
            }
        }
        return arr[h - 1][w - 1]%mod;
    }

}

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

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int s, w;
    cin >> s >> w;
    if(s <= w) {
        cout << "unsafe" << endl;
    }
    else {
        cout << "safe" << endl;
    }
    return 0;
}


Measured memory_bytes: 3604
<?php
list($n, $a, $b) = ints();
if ($a > $b) exit('0');
if ($a === $b) exit('1');
if ($n === 1) exit('0');
echo ($b - $a) * ($n - 2) + 1;
function ints()
{
    return array_map('intval', explode(' ', trim(fgets(STDIN))));
}

Measured memory_bytes: 16140
import java.util.*;
import java.io.*;

public class Main {
    public static boolean shiritori(String[] word){
        Set<String> announced = new HashSet<>();
        for(int n=0;n<word.length;n++){
        	if(announced.contains(word[n])) return false;
        	if(n>0 && (word[n].charAt(0)!= word[n-1].charAt(word[n-1].length()-1))) return false;
        	announced.add(word[n]);
        }
        return true;
    }
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        String[] word = new String[N];
        for(int n=0;n<N;n++) word[n]=sc.next();
        
        System.out.println(shiritori(word) ? "Yes" : "No");
    }
}

Measured memory_bytes: 21844
import sys

sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
printV = lambda x: print(*x, sep="\n")
printH = lambda x: print(" ".join(map(str,x)))
def IS(): return sys.stdin.readline()[:-1]
def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LI1(): return list(map(int1, sys.stdin.readline().split()))
def LII(rows_number): return [II() for _ in range(rows_number)]
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def LLI1(rows_number): return [LI1() for _ in range(rows_number)]

def main():
	S = IS()
	T = IS()
	ans = 0
	for i in range(3):
		if(S[i]==T[i]):
			ans+=1
	print(ans)

if __name__ == '__main__':
	main()

Measured memory_bytes: 3064
#include <iostream>
#include <string>
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
const long long INF = 1LL<<60;

// 入力
string s, t;

// DPテーブル
int dp[3100][3100] = {0}; // 初期値も初期条件も 0

int main() {
    cin >> s >> t;

    // DPループ
    for (int i = 0; i < s.size(); ++i) {
        for (int j = 0; j < t.size(); ++j) {
            if (s[i] == t[j]) chmax(dp[i+1][j+1], dp[i][j] + 1);
            chmax(dp[i+1][j+1], dp[i+1][j]);
            chmax(dp[i+1][j+1], dp[i][j+1]);
        }
    }

    // 復元
    string res = "";
    int i = (int)s.size(), j = (int)t.size();
    while (i > 0 && j > 0)
    {
        // (i-1, j) -> (i, j) と更新されていた場合
        if (dp[i][j] == dp[i-1][j]) {
            --i; // DP の遷移を遡る
        }

        // (i, j-1) -> (i, j) と更新されていた場合
        else if (dp[i][j] == dp[i][j-1]) {
            --j; // DP の遷移を遡る
        }

        // (i-1, j-1) -> (i, j) と更新されていた場合
        else {
            res = s[i-1] + res; // このとき s[i-1] == t[j-1] なので、t[j-1] + res でも OK
            --i, --j; // DP の遷移を遡る
        }
    }
    cout << res << endl;
}

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

ANS=[0]*5
flag=0

if N<100000:
    if N<10000:
        if N<1000:
            if N<100:
                if N<10:
                    ANS[0]=int(N%10)
                    flag=flag+1
                ANS[1]=9
                flag=flag+1
            ANS[2]=9+N-100+1
            flag=flag+1
        ANS[3]=909
        flag=flag+1
    ANS[4]=9+900+N-10000+1
    flag=flag+1
elif N==100000:
    print(90909)

if flag==5:
    print(ANS[0])
if flag==4:
    print(ANS[1])
if flag==3:
    print(ANS[2])
if flag==2:
    print(ANS[3])
if flag==1:
    print(ANS[4])

Measured memory_bytes: 3064
#include<iostream>
using namespace std;
#include<vector>
template<typename T>
struct weightedUF{
	int n;
	vector<int>parent,rank;
	vector<T>dweight;
	weightedUF(int n_=0,T defvalue=0):n(n_),parent(n_),rank(n_,0),dweight(n_,defvalue)
	{
		for(int i=0;i<n;i++)parent[i]=i;
	}
	int find(int a)
	{
		if(parent[a]==a)return a;
		else
		{
			int ar=find(parent[a]);
			dweight[a]+=dweight[parent[a]];
			return parent[a]=ar;
		}
	}
	T weight(int a)
	{
		find(a);
		return dweight[a];
	}
	bool same(int a,int b)
	{
		return find(a)==find(b);
	}
	bool unite(int a,int b,int w)
	{
		w+=weight(a);w-=weight(b);
		a=find(a);b=find(b);
		if(a==b)return false;
		if(rank[a]<rank[b])
		{
			parent[a]=b;
			dweight[a]=-w;
		}
		else
		{
			parent[b]=a;
			dweight[b]=w;
			if(rank[a]==rank[b])rank[a]++;
		}
		return true;
	}
	T diff(int a,int b)
	{
		return weight(b)-weight(a);
	}
};
main()
{
	int n,q;cin>>n>>q;
	weightedUF<int>P(n);
	for(int i=0;i<q;i++)
	{
		int c;cin>>c;
		if(c==0)
		{
			int x,y,w;cin>>x>>y>>w;P.unite(x,y,w);
		}
		else
		{
			int x,y;cin>>x>>y;
			if(P.same(x,y))cout<<P.diff(x,y)<<endl;
			else cout<<'?'<<endl;
		}
	}
}


Measured memory_bytes: 3892
#include<bits/stdc++.h>
using namespace std;
#define f(i,a,b) for(i=a;i<b;i++)
#define rep(i,n) f(i,0,n)
#define fd(i,a,b) for(i=a;i>=b;i--)
#define pb push_back
#define mp make_pair
#define vi vector< int >
#define vl vector< ll >
#define ss second
#define ff first
#define ll long long
#define ull unsigned long long
#define pii pair< int,int >
#define pll pair< ll,ll >
#define sz(a) a.size()
#define inf (1000*1000*1000+5)
#define all(a) a.begin(),a.end()
#define tri pair<int,pii>
#define vii vector<pii>
#define vll vector<pll>
#define viii vector<tri>
#define pi acosl(-1)
#define sqr(x) ((x)*(x))
#define mod (1000*1000*1000+7)
#define pdd pair<double,double>
#define MEMS(x) memset(x,-1,sizeof(x))
#define MEM(x) memset(x,0,sizeof(x))
template <typename T>
string NumberToString(T pNumber)
{
     ostringstream oOStrStream;
     oOStrStream << pNumber;
     return oOStrStream.str();
}
ll StringToNumber(string s)
{
    stringstream geek(s);
    ll x=0;
    geek>>x;
    return x;
}
ll modPow(ll x,ll n,ll m)
{
    if(n==0)
    return 1%m;
    ull u = modPow(x,n/2,m);
    u=u*u%m;
    if(n%2==1)
    u=u*x%m;
    return u;
}
ll gcd(ll a,ll b)
{
    if(b==0)
    return a;
    return gcd(b,a%b);
}
vl primes;
void seiveForm(ll n)
{
    ll i,j;
    vector<bool> isPrime(n+1,true);
    isPrime[0]=false;
    isPrime[1]=false;
    f(i,2,n+1)
    {
        if(isPrime[i]==true)
            for(j=i*i;j<=n+1;j+=i)
                isPrime[j]=false;
    }
    rep(i,n+1)
    {
        if(isPrime[i]==true)
            primes.pb(i);
    }
}
bool isPerfectSquare(ll num)
{
    double n = sqrt(num);
    return n==(ll)n?true:false;
}
ll countSetbits(ll num)
{
    ull temp=0;
    while(num){
        num=num&(num-1);
        temp++;
    }
    return temp;
}
bool isPowerOfTwo(ll n)
{
   if(n==0)
   return false;
   return (ceil(log2(n)) == floor(log2(n)));
}
ll power(ll x, ll y)
{
    ll res = 1;
    while (y > 0)
    {
        if (y & 1)
            res = res*x;
        y = y>>1;
        x = x*x;
    }
    return res;
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n,i,j,k,x=0,y=0;
    string s;
    cin>>s;
    vector<char> v;
    rep(i,s.length())
    {
        if(s[i]=='A')
        {
            x=i;
            break;
        }
    }
    fd(i,s.length()-1,0)
    {
        if(s[i]=='Z')
        {
            y=i;
            break;
        }
    }
    cout<<y-x+1<<endl;
    return 0;
}


Measured memory_bytes: 3680
using System;
using System.Collections.Generic;
using System.Linq;

namespace ForATCODER
{
    public class Program
    {
        public static void Main(string[] args)
        {
            String s = Console.ReadLine();
          //  long[] nm = s2larray(Console.ReadLine().Split(' '));
           // long n = nm[0]; long m = nm[1];

          for(int i = 0; i < (s.Length/2);i++)
            {
                if(s[i] != s[s.Length - i-1])
                {
                    RESULT("No");
                    return;
                }
            }
            String s_ = s.Substring(0,s.Length/2);
            for (int i = 0; i < s_.Length / 2; i++)
            {
                if (s_[i] != s_[s_.Length - i-1])
                {
                    RESULT("No");
                    return;
                }
            }
            s_ = s.Substring(((s.Length+3)/2) -1, s.Length-1-(((s.Length + 3) / 2) - 1-1));
            for (int i = 0; i < s_.Length / 2; i++)
            {
                if (s_[i] != s_[s_.Length - i-1])
                {
                    RESULT("No");
                    return;
                }
            }
            RESULT("Yes");



        }
    
    



    
      
      
        static int s2i(String s)
        {
            return Convert.ToInt32(s);
        }
        static long s2l(String s)
        {
            return Convert.ToInt64(s);
        }
        static void RESULT(double res)
        {
            Console.WriteLine(res);
        }
        static void RESULT(long res)
        {
            Console.WriteLine(res);
        }
        static void RESULT(ulong res)
        {
            Console.WriteLine(res);
        }
        static void RESULT(int res)
        {
            Console.WriteLine(res);
        }
        static void RESULT(String res)
        {
            Console.WriteLine(res);
        }
        static String[] ReadLineAll(int count)
        {
            String[] res = new String[count];
            for (int i = 0; i < count; i++)
            {
                res[i] = Console.ReadLine();
            }
            return res;
        }

        static int[] s2iarray(String[] src)
        {
            int len = src.Length;
            int[] res = new int[len];
            for (int i = 0; i < len; i++)
            {
                res[i] = Convert.ToInt32(src[i]);
            }
            return res;
        }
        static long[] s2larray(String[] src)
        {
            int len = src.Length;
            long[] res = new long[len];
            for (int i = 0; i < len; i++)
            {
                res[i] = Convert.ToInt64(src[i]);
            }
            return res;
        }
    }
}


Measured memory_bytes: 13268
#include<iostream>
#include<stdio.h>
#include<string>
#include<vector>
#include<map>
#include<tuple>
#include<algorithm>
#include<cmath>
#include<limits>
#include<set>
#include<queue>
using namespace std;
#define int long  long int
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a / gcd(a, b) * b; }
typedef pair<int, int>P;
const int INF = 1e15;
const int MOD = 1e9 + 7;
const double PI = 3.14159265358979323846;

signed main() {
	int N, A, B;
	cin >> N >> A >> B;
	if (A > B) {
		cout << 0;
		return 0;
	}

	if (N == 1) {
		if (A != B)cout << 0;
		else cout << 1;
	}
	else if (N == 2) {
		cout << 2;
	}
	else {
		if (A > B)cout << 0;
		else {
			int ans = B * (N - 2) - A * (N - 2) + 1;
			cout << ans;
		}
	}
}

Measured memory_bytes: 256