akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif

int gcd(int a, int b) {return b == 0 ? a : gcd(b, a % b);}

#define ll long long
#define pb push_back
#define ld long double
#define mp make_pair
#define F first
#define S second
#define pii pair<ll,ll> 

using namespace :: std;

const ll maxn=4e5+500;
const ll inf=1e9+800;
const ll mod=1e9+7;

ll cnt[maxn];
ll f[maxn];
ll ans;
void add(ll x,ll v){
	if(v==+1){
		ll imp=x-cnt[x];
		if(imp>0){
			f[imp]++;
			if(f[imp]==1)ans--;
		}
	}else{
		ll imp=x-cnt[x]+1;
		if(imp>0){
			f[imp]--;
			if(f[imp]==0)ans++;
		}
	}
	cnt[x]+=v;
}



ll a[maxn];
int main(){
	ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);	
	ll n,m;
	cin>>n>>m;
	ans=n;
	for(ll i=1;i<=n;i++){
		cin>>a[i];
		add(a[i],1);
	}
	for(ll i=1;i<=m;i++){
		ll x,y;
		cin>>x>>y;
		add(a[x],-1);
		a[x]=y;
		add(a[x],+1);
		cout<<ans<<endl;
	}

}




















Measured memory_bytes: 9216
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  int N;
  long long Y;
  cin >> N >> Y;
  int a=-1, b=-1, c=-1;
  for(int i=0; i<=N; i++){
    if(((Y - 1000 * N) - (4000 * i)) % 9000 == 0){
      int tmpb = i;
      int tmpa = (Y - 1000 * N - 4000 * i) / 9000;
      int tmpc =  N - tmpb - tmpa;
      if(tmpa >= 0 && tmpb >= 0 && tmpc >= 0){
        a=tmpa;
        b=tmpb;
        c=tmpc;
        break;
      }
    }
  }
  cout << a << " " << b << " " << c;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)n; i++)
#define debug(x)      cerr << "L" << __LINE__ << ": " << #x << " = " << (x) << endl
#define debugvec(v)   rep(i, v.size()) cerr << "L" << __LINE__ << ": " << #v << "[" << i << "] = " << v[i] << endl;
#define debugvec2(v)  cerr << "L" << __LINE__ << ": " << #v << " = { "; rep(i, v.size()) cerr << v[i] << (i + 1 == v.size() ? "" : ", "); cerr << " }" << endl;
typedef long long ll;  /* 10^18 くらいまでいける */

int main(){
  string s;
  cin >> s;
  
  map<char, int> m;

  rep(i, s.length()){
    m[s[i]]++;
  };

  map<char,int>::iterator p;	//イテレーターを用いた走査
  bool flag = true;
	for (p=m.begin(); p!=m.end(); p++) {
  	if (p->second != 2 ){
      flag=false;
      break;
    }
 	}
  
  if (flag)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
  

  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>
#define delta 0.0000001
int main(void){
  double d[20];
  int n,i,j;
  double xd1,xd2,yd1,yd2;
  scanf("%d",&n);
  for (i=0;i<n;i++){
    for(j=0;j<8;j++){
      scanf("%lf",&d[j]);
    }
    xd1 = d[0]-d[2];
    xd2 = d[4]-d[6];
    yd1 = d[1]-d[3];
    yd2 = d[5]-d[7];
    if (fabs(xd1)<delta && fabs(xd2)<delta){
      printf("YES\n");
    } else if(fabs(xd1)>delta && fabs(xd2)>delta){
        if (fabs(yd1/xd1-yd2/xd2)<delta) {
          printf("YES\n");
        } else {
          printf("NO\n");
        }
    }else{
      printf("NO\n");
    }
  }
  return 0;
}

Measured memory_bytes: 616
#include <bits/stdc++.h>
#include <ext/numeric>

using namespace std;
using namespace __gnu_cxx;

#define all(v)   v.begin(), v.end()
#define endl "\n"
#define pb push_back
#define F first
#define S second
#define START cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);
#define isOdd(n)    (n&1)
#define LLMAX LLONG_MAX
#define LLMIN LLONG_MIN
#define IMN INT_MIN
#define IMX INT_MAX
#define pow(n, m) power((ll)n, (ll)m)
#define numOfDigits(n)  ((n)? (ll)(log10(n))+1 : 1)
#define mem(x, val)    memset(x, val, sizeof(x)) //be careful
#define var auto
#define MOD 1000000007


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


int main()
{
    START
    //freopen("test cases\\in.txt", "r", stdin) ;
    int a[3];
    cin>>a[0]>>a[1]>>a[2];
    sort(a, a+3);
    cout<<(a[0]+a[1]==a[2]?"Yes":"No");
	return 0;
}


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

#define int long long
#define rep(i,l,r) for(int i=(int)(l);i<(int)(r);i++)
#define all(x) (x).begin(),(x).end()
#define pb push_back
template<class T>bool chmax(T &a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T>bool chmin(T &a,T b){if(a>b){a=b;return 1;}return 0;}

typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;

const int inf = 1LL<<60;
const int mod = 1e9 + 7;
const double eps = 1e-9;

/*{
}*/

signed main()
{
  string s;
  cin >> s;
  int n = s.size();

  int cnt1 = 0, cnt2 = 0;
  rep(i, 0, n){
    if(s[i]-'0' == i%2){
      cnt1++;
    }
    if(s[i]-'0' == (i+1)%2){
      cnt2++;
    }
  }

  cout << min(cnt1, cnt2) << endl;
  
  return 0;
}


Measured memory_bytes: 512
n = int(input())
h = list(map(int,input().split()))
dp = [10**4] * (n+1)
dp[0] = 0
dp[1] = abs(h[1]-h[0])
for i in range(2,n):
    dp[i] = min(dp[i-2] + abs(h[i-2] - h[i]), dp[i-1] + abs(h[i-1] - h[i]))
# print(dp)
print(dp[n-1])

Measured memory_bytes: 13796
#include <iostream>
#include <vector>
#include <array>
#include <set>
#include <cmath>
#include <string>
#include <queue> 
#include <list>
#include <stack>
#include <unordered_map>
#include <algorithm> 
#include <numeric>  
#include <functional>
#include <cassert>
#include <bitset>
#include <cctype>  
#include <iomanip> 
#include <limits>  
// std::numeric_limits<int>::max(), min()
// std::setprecision(X)
// std::islower(), std::isupper(), std::tolower, std::toupper
// std::accumulate(m.begin(), m.end(), 0LL);
// std::sort(begin(),end()) // 0, 1, 2, 3 ,4 (default, less);
// std::priority_queue<int, vector<int>, less<int>> que; // 4, 3, 2, 1 (defualt, less) : 
 
#define  rep(i, n) for(int i = 0; i < (int)(n);    i++)
#define rrep(i, n) for(int i = ((int)(n)-1); i>=0; i++)
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()

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

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


int main (void) {
  std::cin.tie(0);  std::ios::sync_with_stdio(false);
  
  int N; std::cin >> N;
  std::unordered_map<ll,int> A;
  rep(i,N) {
    ll ak; std::cin >> ak;
    if ( A.count(ak) == 0 ) A[ak] = 1;
    else A[ak]++;
  }

  int ans = 0;
  for(auto itr = A.begin(); itr != A.end(); ++itr) {
    if ( itr->second % 2 != 0 ) ans++;
  }
  std::cout << ans << std::endl;
  return 0;
}


Measured memory_bytes: 4388
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <string>
#include <cstring>
using namespace std;

const int A = 26;
const int N = 500100;
const int LOG = 20;
int n;
char s[N];
int a[N][A];
int b[N][LOG];

int main()
{
//	freopen("input.txt", "r", stdin);
//	freopen("output.txt", "w", stdout);

	scanf(" %s ", s);
	n = strlen(s);

	for (int i = 0; i <= n; i++)
	{
		for (int j = 0; j < A; j++)
			a[i][j] = -1;
		for (int j = 0; j < LOG; j++)
			b[i][j] = -1;
	}
	for (int i = n - 1; i >= 0; i--)
	{
		int x = (int)(s[i] - 'a');
		a[i][x] = i + 1;
		for (int c = x + 1; c < A; c++)
		{
			if (a[i][c - 1] == -1)
			{
				a[i][c] = -1;
				continue;
			}
			a[i][c] = a[a[i][c - 1]][c - 1];
		}
		if (a[i][A - 1] == -1) continue;
		b[i][0] = a[a[i][A - 1]][A - 1];
		if (b[i][0] == -1) continue;
		for (int c = 0; c < x; c++)
			a[i][c] = a[b[i][0]][c];
		for (int j = 1; j < LOG; j++)
		{
			if (b[i][j - 1] == -1) break;
			b[i][j] = b[b[i][j - 1]][j - 1];
		}
	}

	int q;
	scanf("%d", &q);
	while(q--)
	{
		int l, r;
		scanf("%d%d", &l, &r);
		l--;
		for (int k = LOG - 1; k >= 0; k--)
		{
			if (b[l][k] == -1 || b[l][k] > r) continue;
			l = b[l][k];
		}
		if (l == r)
			printf("Yes\n");
		else
			printf("No\n");
	}

	return 0;
}

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

#define rep(i, n) for(int i = 0; i < n; ++i)
#define all(a) a.begin(), a.end()
#define ll long long
#define mod 1000000007

using namespace std;

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

  int max = 0;
  int tmp = 0;
  rep(i, n - 1) {
    if (h[i + 1] > h[i]) {
      tmp = 0;
      continue;
    }
    if (++tmp > max) {
      max = tmp;
    }
  }

  cout << max << endl;
}


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

string s; int N;



int main()
{
  cin >> s; N = s.size();
  int lo = (N-1)/2+1, hi = N/2-1;
  char val = s[(N-1)/2];
  while(lo > 0)
  {
    if(s[lo-1] == val && val == s[hi+1])
    {
      --lo; ++hi;
    } else break;
  }
  //printf("%d %d\n", lo, hi);
  printf("%d\n", hi+1);
}

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

long long MOD = 1000000007;

long long extGCD(long long a, long long b, long long *px, long long *py){
    if(b == 0){
        *px = 1;
        *py = 0;
        return a;
    }
    long long d = extGCD(b, a%b, py, px);
    *py -= a/b * (*px);
    return d;
}

int main(){
    //input
    long long N, M;
    cin >> N >> M;
    long long a[N+1], a_nibeki[N+1];
    long long i;
    for(i=1; i<=N; i++){
        cin >> a[i];
        a_nibeki[i] = a[i];
    }

    //calc
    bool nibeki_safe=1;
    bool over_safe = 1;
    long long nibeki_first=0;
    long long nibeki_other;
    long long x,y;
    long long lcm_ya;
    long long ans=0;
    while(a_nibeki[1]%2==0){
        nibeki_first++;
        a_nibeki[1] = a_nibeki[1]/2;
    }
    for(i=2; i<=N; i++){
        nibeki_other=0;
        while(a_nibeki[i]%2==0){
            nibeki_other++;
            a_nibeki[i] = a_nibeki[i]/2;
        }
        if(nibeki_other!=nibeki_first){
            nibeki_safe = 0;
        }
    }
    lcm_ya=a[1];
    for(i=2; i<=N; i++){
        lcm_ya = lcm_ya*a[i]/extGCD(lcm_ya,a[i],&x,&y);
        if(lcm_ya>2*M){
            over_safe = 0;
            break;
        }
    }
    if(lcm_ya<=2*(M%lcm_ya)){
        ans++;
    }
    ans += M/lcm_ya;

    //answer
    if(nibeki_safe && over_safe){
        cout << ans << endl;
    }else{
        cout << 0 << endl;
    }
    system("pause");
    return 0;

}

Measured memory_bytes: 2040
#最大公約数
def gcd(x, y):
    while y:
        x, y = y, x % y
    return x

#最小公倍数
def lcm(x, y):
    return x * y // gcd(x, y)

N = int(input())
T = [int(input()) for _ in range(N)]

lcm_calc = T[0]

for i in range(1, N):
    lcm_calc = lcm(lcm_calc, T[i])

print(lcm_calc)


Measured memory_bytes: 3060
#include <stdio.h>

int main(void)
{
	int k, a, b;
	scanf("%d", &k);
	scanf("%d %d", &a, &b);
	while (a <= b)
	{
		if ((a % k) == 0)
		{
			puts("OK");
			return 0;
		}
		a++;
	}
	puts("NG");
	return 0;
}

Measured memory_bytes: 1620
#![allow(unused_imports, unused_macros, dead_code)]

macro_rules! min {
    (.. $x:expr) => {{
        let mut it = $x.iter();
        if let Some(z) = it.next() {
            Some(it.fold(z, |x, y| min!(x, y)))
        } else {
            None
        }
    }};
    ($x:expr) => ($x);
    ($x:expr, $($ys:expr),*) => {{
        let t = min!($($ys),*);
        if $x < t { $x } else { t }
    }}
}
macro_rules! max {
    (.. $x:expr) => {{
        let mut it = $x.iter();
        if let Some(z) = it.next() {
            Some(it.fold(z, |x, y| max!(x, y)))
        } else {
            None
        }
    }};
    ($x:expr) => ($x);
    ($x:expr, $($ys:expr),*) => {{
        let t = max!($($ys),*);
        if $x > t { $x } else { t }
    }}
}


macro_rules! ewriteln {
    ($($args:expr),*) => { let _ = writeln!(&mut std::io::stderr(), $($args),*); };
}
macro_rules! trace {
    ($x:expr) => { ewriteln!(">>> {} = {:?}", stringify!($x), $x) };
    ($($xs:expr),*) => { trace!(($($xs),*)) }
}
macro_rules! put {
    (.. $x:expr) => {{
        let mut it = $x.iter();
        if let Some(x) = it.next() { print!("{}", x); }
        for x in it { print!(" {}", x); }
        println!("");
    }};
    ($x:expr) => { println!("{}", $x) };
    ($x:expr, $($xs:expr),*) => { print!("{} ", $x); put!($($xs),*) }
}

const M: i64 = 1_000_000_007;

fn main() {
    let mut sc = Scanner::new();
    let n: usize = sc.cin();
    let xs: Vec<usize> = (0..n).map(|_| sc.cin()).collect();
    let mut memo = vec![0; n];
    for i in (0..n).rev() {
        let mut s = 0;
        for k in 2..n+1 {
            let j = (i + 1) * k;
            if j > n { break }
            s += memo[j - 1];
        }
        memo[i] = (xs[i] + s) % 2;
    }
    let ans: Vec<_> = (0..n).filter(|&i| memo[i] == 1).map(|i| i+1).collect();
    put!(ans.len());
    if ans.len() > 0 {
        put!(..ans);
    }
}

use std::io::{self, Write};
use std::str::FromStr;
use std::collections::VecDeque;

struct Scanner { stdin: io::Stdin, buffer: VecDeque<String>, }
impl Scanner {
    fn new() -> Self { Scanner { stdin: io::stdin(), buffer: VecDeque::new() } }
    fn cin<T: FromStr>(&mut self) -> T {
        while self.buffer.len() == 0 {
            let mut line = String::new();
            let _ = self.stdin.read_line(&mut line);
            for w in line.split_whitespace() {
                self.buffer.push_back(String::from(w));
            }
        }
        self.buffer.pop_front().unwrap().parse::<T>().ok().unwrap()
    }
}


Measured memory_bytes: 16636
#include <iostream>
#include <algorithm>
#include <string>
#include <math.h>
#include <numeric>
#include <boost/math/constants/constants.hpp>
#include <boost/math/common_factor_rt.hpp>

using namespace std;
#define ll long long
#define rep(i, n) for(int i = 0;i < n;i++)
#define FOR(i, n, m) for(int i=n; i<m; ++i)

int main(){
  string S;
  cin >> S;
  int N;
  N = S.length();
  int count = 0;
  int ans = 0;
  char past = 'A';
  
  while(count<N){
    if(count!=N-2){
      if(past==S[count]){
      	past = 'A';
      	count+=2;
      }else{
      	past = S[count];
      	count+=1;
      }
      
    }else{
      if(S[N-2]==S[N-1]) count+=2;
      else if(past==S[count]){
      	past = 'A';
      	count+=2;
      }else{
      	past = S[count];
      	count+=1;
      }
    }
    
    ans += 1;           
    //cout << past << endl;
  }
  
  cout << ans << endl;
}

Measured memory_bytes: 640
using System;
using System.Collections.Generic;
using System.Collections;
using System.Collections.Specialized;
using System.Linq;
using System.Text;
using System.IO;
using System.Reflection;
using static System.Math;
using System.Numerics;
static class Program{
	const int mod=(int)1e9+7;
	static void Main(){
		Sc sc=new Sc();
		var n=sc.I;
		var a=sc.Ia;
		Array.Sort(a);
		for(int i = 1;i<n;i++) {
			if(a[i]==a[i-1]){
				Console.WriteLine("NO");
				return;
			}
		}
		Console.WriteLine("YES");
	}
}
public class Sc{
	public int I{get{return int.Parse(Console.ReadLine());}}
	public long L{get{return long.Parse(Console.ReadLine());}}
	public double D{get{return double.Parse(Console.ReadLine());}}
	public string S{get{return Console.ReadLine();}}
	public int[] Ia{get{return Array.ConvertAll(Console.ReadLine().Split(),int.Parse);}}
	public long[] La{get{return Array.ConvertAll(Console.ReadLine().Split(),long.Parse);}}
	public double[] Da{get{return Array.ConvertAll(Console.ReadLine().Split(),double.Parse);}}
	public string[] Sa{get{return Console.ReadLine().Split();}}
	public object[] Oa{get{return Console.ReadLine().Split();}}
	public int[] Ia2{get{return Array.ConvertAll(("0 "+Console.ReadLine()+" 0").Split(),int.Parse);}}
	public int[] Ia3(int a){return Array.ConvertAll((a.ToString()+" "+Console.ReadLine()).Split(),int.Parse);}
	public int[] Ia3(bool a,int b,bool c,int d){return Array.ConvertAll(((a?b.ToString()+" ":"")+Console.ReadLine()+(c?" "+d.ToString():"")).Split(),int.Parse);}
	public long[] La2{get{return Array.ConvertAll(("0 "+Console.ReadLine()+" 0").Split(),long.Parse);}}
	public long[] La3(int a){return Array.ConvertAll((a.ToString()+" "+Console.ReadLine()).Split(),long.Parse);}
	public long[] La3(bool a,int b,bool c,int d){return Array.ConvertAll(((a?b.ToString()+" ":"")+Console.ReadLine()+(c?" "+d.ToString():"")).Split(),long.Parse);}
	public double[] Da2{get{return Array.ConvertAll(("0 "+Console.ReadLine()+" 0").Split(),double.Parse);}}
	public double[] Da3(int a){return Array.ConvertAll((a.ToString()+" "+Console.ReadLine()).Split(),double.Parse);}
	public double[] Da3(bool a,int b,bool c,int d){return Array.ConvertAll(((a?b.ToString()+" ":"")+Console.ReadLine()+(c?" "+d.ToString():"")).Split(),double.Parse);}
	public T[] Arr<T>(int n,Func<T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f();}return a;}
	public T[] Arr<T>(int n,Func<int,T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f(i);}return a;}
	public T[] Arr<T>(int n,Func<string[],T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f(Console.ReadLine().Split());}return a;}
	public T[] Arr<T>(int n,Func<int,string[],T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f(i,Console.ReadLine().Split());}return a;}
}

Measured memory_bytes: 32732
#include <bits/stdc++.h>
#define rep(i,n) for (long long i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
const ll MOD = 1000000007;
const ll INF = 1000000000000000000;
#define all(v) v.begin(), v.end()



int main(){
  cout << 36336 << endl;
  cout << "+ 0 1 3" << endl;
  rep(i,60){
    if(i==0){
      cout << "< 2 3 " << 100+i << endl;
    }else{
      cout << "+ " << 99+i << " " << 99+i << " " << 100+i << endl;
    }
  }
  cout << "+ 0 100 4" << endl;
  cout << "+ 1 100 5" << endl;
  rep(i,30){
    cout << "+ " << 250+i << " " << 129-i << " 6" << endl;
    cout << "< 6 4 " << 200+i << endl;
    cout << "+ " << 200+i << " 10 6" << endl;
    rep(j,29-i){
      cout << "+ 6 6 6" << endl;
    }
    cout << "+ " << 250+i << " 6 " << 251+i << endl;
    cout << "+ 2 2 6" << endl;
  }
  rep(i,30){
    cout << "+ " << 350+i << " " << 129-i << " 6" << endl;
    cout << "< 6 5 " << 300+i << endl;
    cout << "+ " << 300+i << " 10 6" << endl;
    rep(j,29-i){
      cout << "+ 6 6 6" << endl;
    }
    cout << "+ " << 350+i << " 6 " << 351+i << endl;
    cout << "+ 2 2 6" << endl;
  }
  cout << "+ 2 2 3" << endl;
  cout << "+ 2 2 4" << endl;
  cout << "+ 2 2 5" << endl;
  rep(i,30){
    rep(j,30){
      cout << "+ " << 200+i << " " << 200+i << " 3" << endl;
      cout << "+ " << 300+j << " " << 300+j << " 4" << endl;
      cout << "< " << 300+j << " 3 5" << endl;
      cout << "< 4 " << 200+i << " 6" << endl;
      cout << "< 6 5 " << 400+30*i+j << endl;
      rep(k,58-i-j){
        cout << "+ " << 400+30*i+j << " " << 400+30*i+j << " " << 400+30*i+j << endl;
      }
      cout << "+ 2 2 3" << endl;
      cout << "+ 2 2 4" << endl;
      cout << "+ 2 2 5" << endl;
      cout << "+ 2 2 6" << endl;
    }
  }
  rep(i,900){
    cout << "+ 2 " << 400+i << " 2" << endl;
  }
      
}

Measured memory_bytes: 3516
#include <bits/stdc++.h>
#ifdef LOCAL_DEBUG
#define DEBUG 1
#define CERR if(DEBUG) cerr
#define MACRO(_1,_2,_3,_4,_5,_6,_7,_8,_9,_10,NAME,...) NAME
#define pr(...) CERR<<MACRO(__VA_ARGS__,pr10,pr9,pr8,pr7,pr6,pr5,pr4,pr3,pr2,pr1)(__VA_ARGS__)<<endl
#define pr1(a) (#a)<<"="<<(a)<<" "
#define pr2(a,b) pr1(a)<<pr1(b)
#define pr3(a,b,c) pr1(a)<<pr2(b,c)
#define pr4(a,b,c,d) pr1(a)<<pr3(b,c,d)
#define pr5(a,b,c,d,e) pr1(a)<<pr4(b,c,d,e)
#define pr6(a,b,c,d,e,f) pr1(a)<<pr5(b,c,d,e,f)
#define pr7(a,b,c,d,e,f,g) pr1(a)<<pr6(b,c,d,e,f,g)
#define pr8(a,b,c,d,e,f,g,h) pr1(a)<<pr7(b,c,d,e,f,g,h)
#define pr9(a,b,c,d,e,f,g,h,i) pr1(a)<<pr8(b,c,d,e,f,g,h,i)
#define pr10(a,b,c,d,e,f,g,h,i,j) pr1(a)<<pr9(b,c,d,e,f,g,h,i,j)
#define prArr(a){CERR<<(#a)<<"={";int i=0;for(auto t:(a))CERR<<(i++?", ":"")<<t;CERR<<"}"<<endl;}
#else
#define DEBUG 0
#define pr(...)
#define prArr(a)
#endif
using namespace std;
using Int = long long;
using _int = int;
using ll = long long;
using Double = long double;
const Int INF = (1LL<<60)+1e9; // ~ 1.15 * 1e18
const Int mod = (1e9)+7;
const Double EPS = 1e-8;
const Double PI = 6.0 * asin((Double)0.5);
using P = pair<Int,Int>;
template<class T> T Max(T &a,T b){return a=max(a,b);}
template<class T> T Min(T &a,T b){return a=min(a,b);}
template<class T1, class T2> ostream& operator<<(ostream& o,pair<T1,T2> p){return o<<"("<<p.first<<","<<p.second<<")";}
template<class T1, class T2, class T3> ostream& operator<<(ostream& o,tuple<T1,T2,T3> t){return o<<"("<<get<0>(t)<<","<<get<1>(t)<<","<<get<2>(t)<<")";}
template<class T1, class T2> istream& operator>>(istream& i,pair<T1,T2> &p){return i>>p.first>>p.second;}
template<class T> ostream& operator<<(ostream& o,vector<T> a){Int i=0;for(T t:a)o<<(i++?" ":"")<<t;return o;}
template<class T> istream& operator>>(istream& i,vector<T> &a){for(T &t:a)i>>t;return i;}
//INSERT ABOVE HERE


signed main(){
  srand((unsigned)time(NULL));
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cout << fixed << setprecision(12);

  Int N;
  cin>>N;
  vector<Int> A(N);
  cin>>A;

  Int ans = 0;
  multiset<Int> S;
  for(Int i=0;i<N;i++){
    auto it = S.lower_bound(A[i]);
    if(it == S.begin()){
      ans++;
      S.insert(A[i]);
    }
    else{
      --it;
      S.insert(A[i]);
      S.erase(it);
    }
  }
  cout<<ans<<endl;

  return 0;
}


Measured memory_bytes: 5760
# from math import factorial,sqrt
# from itertools import permutations as permus
# from fractions import gcd
# from collections import deque,Counter
# from decimal import Decimal, getcontext
# # getcontext().prec = 1000
# # eps = Decimal(10) ** (-100)

# import numpy as np
# import scipy as scp

# 入力の受け取り
r,d,x = map(int,input().split())

def solve(r,d,x):
    return r*x-d

for _ in range(10):
    print(solve(r,d,x))
    x = solve(r,d,x)
# print("{:.10f}".format(ans))
# print(*ans)   # unpackして出力。間にスペースが入る
# for row in board:
#     print(*row,sep="")    #unpackして間にスペース入れずに出力する



Measured memory_bytes: 2940
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func main() {
	S := nextString()

	if S == "RRR" {
		fmt.Println(3)
	} else if S == "SRR" || S == "RRS" {
		fmt.Println(2)
	} else if S == "SSS" {
		fmt.Println(0)
	} else {
		fmt.Println(1)
	}
}

var stdin = initStdin()

func initStdin() *bufio.Scanner {
	bufsize := 1 * 1024 * 1024 // 1 MB
	var stdin = bufio.NewScanner(os.Stdin)
	stdin.Buffer(make([]byte, bufsize), bufsize)
	stdin.Split(bufio.ScanWords)
	return stdin
}

func nextString() string {
	stdin.Scan()
	return stdin.Text()
}

func nextBytes() []byte {
	stdin.Scan()
	return stdin.Bytes()
}

func nextInt() int {
	i, _ := strconv.Atoi(nextString())
	return i
}

func nextInt64() int64 {
	i, _ := strconv.ParseInt(nextString(), 10, 64)
	return i
}

func debug(args ...interface{}) {
	fmt.Fprintln(os.Stderr, args)
}


Measured memory_bytes: 1808
given = input()

if given != given[::-1]:
    print("No")
    exit()

former_half = given[:int(len(given)/2)]
if former_half != former_half[::-1]:
    print("No")
    exit()

latter_part = given[int((len(given) + 3) / 2 - 1):]
if latter_part != latter_part[::-1]:
    print("No")
    exit()

print("Yes")

Measured memory_bytes: 3060
#include<bits/stdc++.h>
#define ll long long 
#define pb push_back
#define ff first
#define ss second
#define setbits(x)          __builtin_popcountll(x)
#define lp(a,n) for(ll i=a; i<n; i++)
#define lpi(a,n) for(int i=a; i<n; i++)
#define w(t) int t; cin>>t; while(t--)
#define vi vector<int> 
#define vll vector<ll>
#define pll pair<ll, ll>
#define pii pair<int, int>
#define inf 1e9
#define LB lower_bound
#define UB upper_bound
const int mod = 1000000007;
using namespace std;
ll gcd(ll a,ll b){
    if(a==0)return b;
    return gcd(b%a,a);
}
ll lcm(ll a, ll b){
    return (a*b)/gcd(a,b);
}

int prime[100007];
void SieveOfEratosthenes(int n) 
{ 
    memset(prime, -1, sizeof(prime)); 
  
    for (int p=2; p*p<=n; p++) 
    { 
         
        if (prime[p] == -1) 
        { 
            for (int i=p*p; i<=n; i += p) 
                prime[i] = p; 
        } 
    } 
    
} 
int lps(string s){
    int len = 0;
    int n = s.length();
    int dp[n];
    dp[0] = 0;
    for(int i=1; i<n; i++){
        if(s[i] == s[len]){
            len++;
            dp[i] = len;
            continue;
        }
        if(len!=0){
            len = dp[len-1];
            i--;
            continue;
        }
        dp[i]=0;
    }
    return dp[n-1];
}
 
ll power(unsigned ll x,unsigned  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);
   int n;
   cin>>n;
   int x = n%1000;
   if(x!=0)
   cout<<1000-x<<endl;
   else cout<<0<<endl;
}

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

int main() {
    string S; cin >> S;
    auto f = [&](auto &&f, int i, long long n, long long m) -> long long {
        if(i == S.size()) return n + m;
        int a = S[i] - '0';
        long long res = f(f, i + 1, n + m, a); // + で区切る
        if(i) res += f(f, i + 1, n, 10 * m + a);
        return res;
    };
    cout << f(f, 0, 0, 0) << '\n';
}


Measured memory_bytes: 256
import java.util.*;
import java.io.*;
import static java.lang.Math.*;

class Main {

    public static void main( final String[] args ) {

	final Scanner stdin = new Scanner( System.in );

	int w = 0;
	int k = 0;

	int[] scores = new int[ 10 ];
	for ( int i = 0; i < 10; i++ ) {
	    scores[ i ] = stdin.nextInt();
	}
	Arrays.sort( scores );
	w = scores[ 9 ] + scores[ 8 ] + scores[ 7 ];
	
	for ( int i = 0; i < 10; i++ ) {
	    scores[ i ] = stdin.nextInt();
	}
	Arrays.sort( scores );
	k = scores[ 9 ] + scores[ 8 ] + scores[ 7 ];

	System.out.printf( "%d %d\n", w, k );
    }    
}

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

typedef pair<int,int> P;
#define ll long long
#define ld long double
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define PI 3.14159265358979323846
#define sz(x) ((int)(x).size())
#define chmin(x,y) x = min(x,y)
#define chmax(x,y) x = max(x,y)

const int INF = 1e9;
const int MOD = 1e9 + 7;
const ll LINF = 1e18;
int main()
{
    string s; cin >> s;
    int sl = (int)s.length();
    string temp = "";
    temp.push_back(s[0]);

    for (int i = 1; i < sl; i++)
    {
        if(s[i]!=s[i-1]) temp.push_back(s[i]);
    }

    cout << (int)temp.length()-1<< endl;
    
}

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

int main(){
    ll h,a;
    cin>>h>>a;
    cout<<(h+a-1)/a<<endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
using namespace std;
typedef long long ll;

ll p2[50] = {};

ll pow2(ll n){
  if(n==0 || n==1) return n+1;
  if(p2[n] != 0) return p2[n];
  else return pow2(n/2)*pow2(n/2)*pow2(n-2*(n/2));
}

int main()
{
  ll l,n=0,m=0,k[30];
  cin >> l;
  while(pow2(n)<=l) n++;
  m=2*(n-1);
  for(ll i=0;i<n;i++){
    k[i]=(l%pow2(i+1)-l%pow2(i))/pow2(i);
    if(i<n-1 && k[i]==1) m++;
  }
  cout<< n << " " << m<<endl;
  for(ll i=1;i<n;i++) cout<< i << " " << i+1 << " " << 0 << endl << i << " " << i+1 << " " << pow2(n-i-1) << endl;
  for(ll i=0;i<n-1;i++){
    if(k[i]==1) cout<< 1 << " " << n-i << " " << l-l%pow2(i+1) << endl;
  }
  
}

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

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

    ll x, y;
    cin >> x >> y;

    int c = 0;

    ll t = x;
    while(t <= y) {
        ++c;
        t *= 2;
    }

    cout << c << endl;
    return 0;
}

Measured memory_bytes: 3648
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
#define rep(i,m,n) for(int i=(int)(m);i<(int)(n);++i)
#define rREP(i,m,n) for(int (i)=(n)-1; (i)>=(m);--(i))
#define all(x) (x).begin(),(x).end()
#define out(y,x,h,w) (y)<0||(x)<0||(y)>=(h)||(x)>=(w)
constexpr int INF = 1000000001;
constexpr ll mod = 1000000007;
constexpr double PI = 3.1415926535897932;

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;
}
inline void init() {
	cin.tie(nullptr); cout.tie(nullptr);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);
}

int main() {
	init();

	string s; cin >> s;
	bool is = true;
	string key[] = { "dream","dreamer","erase","eraser" };
	rep(i, 0, 4)reverse(all(key[i]));
	reverse(all(s));
	rep(i, 0, s.size()) {
		if (s[i] == 'r') {
			if (key[1] == s.substr(i, key[1].size())) {
				i += key[1].size() - 1;
			}
			else if (key[3] == s.substr(i, key[3].size())) {
				i += key[3].size() - 1;
			}
			else {
				is = false;
				break;
			}
		}
		else if (s[i] == 'e') {
			if (key[2] == s.substr(i, key[2].size())) {
				i += key[2].size() - 1;
			}
			else {
				is = false;
				break;
			}
		}
		else if (s[i] == 'm') {
			if (key[0] == s.substr(i, key[0].size())) {
				i += key[0].size() - 1;
			}
			else {
				is = false;
				break;
			}
		}
		else {
			is = false;
			break;
		}
	}
	cout << (is ? "YES" : "NO") << "\n";

	return 0;
}

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

signed main(){
  int H;
  cin>>H;
  
  if(H==1){
    cout<<1<<endl;
    return 0;
  }
  int co=-1;
  while(H!=1){
    co++;
    H/=2;
  }
  int ans=3;
  rep(i,co){
    ans*=2;
    ans++;
  }
  cout<<ans<<endl;
  return 0;
}

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

#define INF_LL (int64)1e18
#define INF (int32)1e9
#define REP(i, n) for(int i = 0;i < (n);i++)
#define FOR(i, a, b) for(int i = (a);i < (b);i++)
#define all(x) x.begin(),x.end()
#define fs first
#define sc second

using int32 = int_fast32_t;
using uint32 = uint_fast32_t;
using int64 = int_fast64_t;
using uint64 = uint_fast64_t;
using PII = pair<int32, int32>;
using PLL = pair<int64, int64>;

const double eps = 1e-6;

template<typename A, typename B>inline void chmin(A &a, B b){if(a > b) a = b;}
template<typename A, typename B>inline void chmax(A &a, B b){if(a < b) a = b;}

const int64 mod = 1e9+7;
int32 n, m, p;

int32 luz(int32 x){
	return x*(100+n)/100;
}

int32 beet(int32 x){
	return x*(100+m)/100;
}

int main(void){
	while(cin >> n >> m >> p && (n || m || p)){

		int32 res = 0;
		FOR(i, 1, p){
			FOR(j, i, p-i+1){
				if(luz(i)+luz(j) == p){
					res = max(res, beet(i)+beet(j)); 
				}
			}
		}
		cout << res << endl;
	}
}


Measured memory_bytes: 3096
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<map>
#define mod 1000000007
using namespace std;
map<string,int> cost,nz;
map<string,vector<string> > parent,child;
vector<string> v;
void DFS(string s){
	int ans=0;
	for(int i=0;i<child[s].size();i++){
		ans+=cost[child[s][i]];
	}
	ans=min(ans,cost[s]);
	if(child[s].size()>0)cost[s]=ans;
	for(int i=0;i<parent[s].size();i++){
		string to=parent[s][i];
		nz[to]--;
		if(nz[to]==0){
			DFS(to);
		}
	}
}
int main(){
	int n,m;
	while(cin>>n&&n){
		cost.clear();
		nz.clear();
		child.clear();
		parent.clear();
		v.clear();
		for(int i=0;i<n;i++){
			string s;int a;
			cin>>s>>a;
			cost[s]=a;
			nz[s]=0;
			v.push_back(s);
		}
		cin>>m;
		for(int i=0;i<m;i++){
			string s;int k;
			cin>>s>>k;
			nz[s]=k;
			for(int j=0;j<k;j++){
				string r;cin>>r;
				child[s].push_back(r);
				parent[r].push_back(s);
			}
		}
		for(int i=0;i<v.size();i++){
			if(nz[v[i]]==0)DFS(v[i]);
		}
		string s;cin>>s;
		cout<<cost[s]<<endl;
	}
	return 0;
}

Measured memory_bytes: 3184
#include<bits/stdc++.h>
using namespace std;
 
#define lli long long
#define FOR(i,a,b) for (lli i=(a);i<(b);i++)
#define REP(i,n) for (lli i=0;i<(n);i++)
#define rep(i,n) for (lli i=0;i<(n);i++)
 
#define INF INT_MAX/3
#define PB push_back
#define pb push_back
#define all(a) (a).begin(),(a),end()
#define pll pair<lli,lli>

int main(){
  int H,W,f=0;
  string str;

  cin>>H>>W;
  for(int i=0;i<H;i++){
    cin>>str;
    for(int j=0;j<W;j++){
      if(str[j]=='#')f++;
    }
  }

  if(f==H+W-1)cout<<"Possible"<<endl;
  else cout<<"Impossible"<<endl;

  return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
 
int main () {
  int N;
  cin >> N;
  
  int a1, a2, a3, a4;
  a1 = N / 1000;
  a2 = N % 1000 / 100;
  a3 = N % 100 / 10;
  a4 = N % 10;
  if (a2 == a3 && (a1 == a2 || a3 == a4)) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <math.h>
using namespace std;
int main() {
	char a, b, c, d;
	cin >> a >> b >> c >> d;
	int A = a - '0', B = b - '0', C = c - '0', D = d - '0';
	if (A + B + C + D == 7) {
		cout << A << "+" << B << "+" << C << "+" << D << "=" << "7" << endl;
		getchar();
		getchar();
		return 0;
	}
	if (A + B + C - D == 7) {
		cout << A << "+" << B << "+" << C << "-" << D << "=" << "7" << endl;
		getchar();
		getchar();
		return 0;
	}
	if (A + B - C + D == 7){
		cout << A << "+" << B << "-" << C << "+" << D << "=" << "7" << endl;
		getchar();
		getchar();
		return 0;
	}
	if (A + B - C - D == 7) {
		cout << A << "+" << B << "-" << C << "-" << D << "=" << "7" << endl;
		getchar();
		getchar();
		return 0;
	}
	if (A - B + C + D == 7) {
		cout << A << "-" << B << "+" << C << "+" << D << "=" << "7" << endl;
		getchar();
		getchar();
		return 0;
	}
	if (A - B + C - D == 7) {
		cout << A << "-" << B << "+" << C << "-" << D << "=" << "7" << endl;
		getchar();
		getchar();
		return 0;
	}
	if (A - B - C + D == 7) {
		cout << A << "-" << B << "-" << C << "+" << D << "=" << "7" << endl;
		getchar();
		getchar();
		return 0;
	}
	else {
		cout<< A << "-" << B << "-" << C << "-" << D << "=" << "7" << endl;
		getchar();
		getchar();
		return 0;
	}
}

Measured memory_bytes: 256
#include <iostream>
#include <map>
#include <set>
#include <algorithm>
#include <vector>
#include <sstream>
#include <string>
#include <functional>
#include <queue>
#include <deque>
#include <stack>
#include <limits>
#include <unordered_map>
#include <unordered_set>
#include <math.h>
#include <fstream>
#include <iterator>
#include <random>
#include <chrono>
 
 
#define forr(i,start,count) for (int i = (start); i < (start)+(count); ++i)
#define set_map_includes(set, elt) (set.find((elt)) != set.end())
#define readint(i) int i; cin >> i
#define readll(i) ll i; cin >> i
#define readdouble(i) double i; cin >> i
#define readstring(s) string s; cin >> s
 
typedef long long ll;
 
using namespace std;

ll modd = 1000*1000*1000+7;

ll binary_search(function<bool(ll)> func, ll start, ll end) {
    /*      func:int ->bool
            returns smallest int x where func(x) evaluates to true, searches in [start,end), it is assumed the values are false, .. , false, true ...
             */
    if (end <= start) {   return end;  }   // has to be here, otherwise func(end-1) in next line could be a problem
    if (!func(end-1)) {  return end;  }
    while (end-start>1) {
        ll mid = (start+end)/2;
        if (func(mid)) {  end = mid;  } else { start = mid;   }
    }
    if (func(start)) {  return start;  } else {  return end;   }
};


template<class T>
T fastpower(T a, long long n) {  // n must be >= 1
  if (n==0) {return 1;}
  if (n % 2 == 0) {  
      T halfpower = fastpower<T>(a, n/2);
      return (halfpower*halfpower) % modd;
  } else {
      if (n == 1) {  return a; } else {  
          T halfpower = fastpower<T>(a, n/2);
          return (((halfpower*halfpower)%modd)*a)%modd;
      }
  }
};


int main()   {

    ios_base::sync_with_stdio(false);

    cout.precision(17);
    mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
    uniform_int_distribution<int> rand_gen(0, modd);   // rand_gen(rng) gets the rand no
 
//    auto start = chrono::steady_clock::now();
  
//    readint(test_cases);
    int test_cases = 1;
    forr(t, 1, test_cases) {
        readint(h); readint(w); readint(k);
        vector<string> grid;
        forr(i,0,h) {
            readstring(s); grid.push_back(s);
        }

        int ret = 0;
        forr(i,0,(1<<h)) {
            forr(j,0,(1<<w)) {
                vector<string> gr(grid);
                forr(ii,0,h) {
                    forr(jj,0,w) {
                        if (((i&(1<<ii)) != 0) || (((j&(1<<jj))) != 0)) {
                            gr[ii][jj] = 'R';
                        }
                    }
                }
                int ct = 0;
                forr(ii,0,h) {
                    forr(jj,0,w) {
                        if (gr[ii][jj]=='#') {ct++;}
                    }
                }
                ret += (ct==k);
            }
        }

        cout << ret << endl;

    }
 
//    auto end = chrono::steady_clock::now();
//    cout << chrono::duration_cast<chrono::milliseconds>(end - start).count() << endl;
 
    return 0;
}

Measured memory_bytes: 3644
#include <iostream>
#include <string>
#include <algorithm>

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

int main() {

    int N;
    int a[3000];

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


    int result = 0;
    for (int i = 0; i < N; ++i) {
        result += a[i] -1;
    }
    cout << result <<endl;
    return 0;
}

Measured memory_bytes: 256
import sys
from io import StringIO
import unittest


def recursive(base, pattern, n):

    for i in ["7", "5", "3"]:

        new_target = "".join(base + str(i))

        # 条件を満たさない場合は、再帰を呼ばない。
        if int(new_target) > n:
            continue

        # 条件を満たす場合、リストに加える
        if new_target.count("7") >= 1 and new_target.count("5") >= 1 and new_target.count("3") >= 1:
            pattern.append(new_target)

        recursive(new_target, pattern, n)


def resolve():

    n = int(input())

    pattern = []

    # 再帰的処理
    for i in ["7", "5", "3"]:
        recursive(i, pattern, n)

    print(len(pattern))


class TestClass(unittest.TestCase):
    def assertIO(self, input, output):
        stdout, stdin = sys.stdout, sys.stdin
        sys.stdout, sys.stdin = StringIO(), StringIO(input)
        resolve()
        sys.stdout.seek(0)
        out = sys.stdout.read()[:-1]
        sys.stdout, sys.stdin = stdout, stdin
        self.assertEqual(out, output)

    def test_入力例_1(self):
        input = """575"""
        output = """4"""
        self.assertIO(input, output)

    def test_入力例_2(self):
        input = """3600"""
        output = """13"""
        self.assertIO(input, output)

    def test_入力例_3(self):
        input = """999999999"""
        output = """26484"""
        self.assertIO(input, output)


if __name__ == "__main__":
    #unittest.main()
    resolve()


Measured memory_bytes: 65368
#include <iostream>
#include <cstring>
using namespace std;
int main()
{
  int A,B,x,y,z;
  cin>>A>>B;
  x=A+B;
  y=A-B;
  z=A*B;
 if(x>=y && x>=z ) cout<<x;
  else if(y>=x && y>=z ) cout<<y;
  else cout<< z;

  return 0;
}

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

struct man{
	int no;
	double time;
};

man p[24];
man hk[6];

void solve(){
	man tmp;
	for(int i=0; i<7; i++){
		if(p[i].time > p[i+1].time){
			tmp = p[i];
			p[i] = p[i+1];
			p[i+1] = tmp;
			i=-1;
		}
	}
	for(int i=8; i<15; i++){
		if(p[i].time > p[i+1].time){
			tmp = p[i];
			p[i] = p[i+1];
			p[i+1] = tmp;
			i=7;
		}
	}
	for(int i=16; i<23; i++){
		if(p[i].time > p[i+1].time){
			tmp = p[i];
			p[i] = p[i+1];
			p[i+1] = tmp;
			i=15;
		}
	}
	hk[0] = p[2];
	hk[1] = p[3];
	hk[2] = p[10];
	hk[3] = p[11];
	hk[4] = p[18];
	hk[5] = p[19];
	for(int i=0; i<5; i++){
		if(hk[i].time > hk[i+1].time){
			tmp = hk[i];
			hk[i] = hk[i+1];
			hk[i+1] = tmp;
			i=-1;
		}
	}
}

int main(){
	for(int i=0; i<24; i++)
		cin >> p[i].no >> p[i].time;
	solve();
	cout << p[0].no << ' ' << setprecision(2) << fixed << p[0].time << endl;
	cout << p[1].no << ' ' << setprecision(2) << fixed << p[1].time << endl;
	cout << p[8].no << ' ' << setprecision(2) << fixed << p[8].time << endl;
	cout << p[9].no << ' ' << setprecision(2) << fixed << p[9].time << endl;
	cout << p[16].no << ' ' << setprecision(2) << fixed << p[16].time << endl;
	cout << p[17].no << ' ' << setprecision(2) << fixed << p[17].time << endl;
	cout << hk[0].no << ' ' << setprecision(2) << fixed << hk[0].time << endl;
	cout << hk[1].no << ' ' << setprecision(2) << fixed << hk[1].time << endl;
}

Measured memory_bytes: 0
n = int(input())
count = 0
if n >= 10:
    count += 9
    if n >= 1000:
        count += 900
        if n == 100000:
            count += 90000
        elif n >= 10000:
            count += n - 10000 + 1
    elif n >= 100:
        count += n - 100 + 1
else:
    count += n
print(count)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
#define pi 3.1415926535897932384626
using namespace std;
      
struct P{
  int x,y;
  bool operator < (const P &a )const{
    //if(y!=a.y)
    return y>a.y;
  };
};

int a,b,c,d,i,k,n,m,e,dx[10]={1,0,-1,0,1,1,-1,-1},dy[10]={0,1,0,-1,1,-1,1,-1};
int o[1];
int l[1];
int j[1];

long long x,y,z,mod=998244353;
string r;
//char r[111];

P u[1];
queue<int> q;

stack<int> s;
map<int,int> p;
vector<int> v;

bool as(P a,P b)
{
  if(a.x==b.x)
  return a.y<b.y;
  return a.x<b.x;
}

int main()
{
  scanf("%d %d",&a,&b);
  printf("%d",max(0,a-2*b));
}





Measured memory_bytes: 764
#include <iostream>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;

int main(void) {
  int64_t N, K;
  cin >> N >> K;

  if(K == 0) {
    int64_t answer = N * (N - K);
    cout << answer << endl;
    return 0;
  }

  int64_t answer = 0;
  for (int64_t b = K + 1; b <= N; ++b) {
    // N = pb + q;
    // p = N / b;
    int64_t a_num = (b - K) * (N / b);
    // q = N - pb -> N -> K ~ q
    a_num += max(0L, N - (N / b) * b - K + 1);
    answer += a_num;
  }
  cout << answer << endl;
  return 0;
}

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

#define FOR(i,b,e) for(int i=(b); i <= (e); ++i)
#define FORD(i,b,e) for(int i=(b); i >= (e); --i)
#define SIZE(c) (int) (c).size()
#define FORE(i,c) FOR(i,0,SIZE(c)-1)
#define FORDE(i,c) FORD(i,SIZE(c)-1,0)

#define pb push_back
#define mp make_pair
#define st first
#define nd second


using namespace std;

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

typedef vector <int> VI;
typedef vector <bool> VB;
typedef vector <pii> VP;
typedef vector <ll> VL;
typedef vector <pll> VPL;

typedef vector <VI> VVI;
typedef vector <VL> VVL;
typedef vector <VB> VVB;
typedef vector <VP> VVP;

const int MOD = 1000000007;
const int INF = 1000000001;
const ll LINF = 1000000000000000001LL;

#define x st
#define y nd

struct FAU {
    VI p, r;

    FAU(int n): p(n,-1), r(n,0) {}

    int find(int x) {
        if (p[x] == -1) return x;
        return p[x] = find(p[x]);
    }

    void join(int x, int y) {
        x = find(x); y = find(y);
        if (x == y) return ;

        if (r[x] > r[y]) p[y] = x;
        else p[x] = y;

        if (r[x] == r[y]) ++r[y];
    }
};

/*************************************************************************/

int dist(pii a, pii b) {
    return min(abs(a.x - b.x), abs(a.y - b.y));
}

int main() {
    ios_base::sync_with_stdio(0);
    
    int n;
    cin >> n;
    
    VP pts(n);
    FOR(i,0,n-1) {
        cin >> pts[i].x >> pts[i].y;
    }
    
    VP byX(n), byY(n);
    FOR(i,0,n-1) {
        byX[i] = {pts[i].x, i};
        byY[i] = {pts[i].y, i};
    }
    
    sort(byX.begin(), byX.end());
    sort(byY.begin(), byY.end());
    
    struct edge { int u, v, len; };
    
    vector <edge> edges;
    
    FOR(i,0,n-2) {
        edges.pb({byX[i].nd, byX[i+1].nd, -1});
        edges.pb({byY[i].nd, byY[i+1].nd, -1});
    }
    
    for (auto &e : edges) {
        e.len = dist(pts[e.u], pts[e.v]);
    }
    
    sort(edges.begin(), edges.end(), [](const edge &a, const edge &b) {
        return a.len < b.len;
    });
    
    FAU fau(n);
    ll ans = 0;
    
    for (auto &e : edges) {
        if (fau.find(e.u) != fau.find(e.v)) {
            fau.join(e.u, e.v);
            ans += e.len;
        }
    }
    
    cout << ans;

    return 0;
}

/*************************************************************************/


Measured memory_bytes: 7284
#include <iostream>
#include <vector>
using namespace std;
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; }

const long long INF = 1LL << 60;

int main() {
    int N, K; cin >> N >> K;
    vector<long long> h(N);
    for(int i = 0; i < N; ++i) cin >> h[i];
    
    vector<long long> dp(N, INF);
    dp[0] = 0;
    for(int i = 0; i < N; ++i) {
        for(int j = 1; j <= K; ++j) {
            chmin(dp[i+j], dp[i] + abs(h[i] - h[i+j]));
        }
    }
    
    cout << dp[N-1] << endl;
}


Measured memory_bytes: 1792
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <set>
#include <map>
#include <queue>
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <ctime>
#include <cstring>
#include <cctype>
#include <cassert>
#include <limits>
#include <functional>
#include <iomanip>
#include <complex>
#include <bitset>
#include <stack>
 
using namespace std;
 
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define rer(i,l,u) for(int (i)=(int)(l);(i)<=(int)(u);++(i))
#define reu(i,l,u) for(int (i)=(int)(l);(i)<(int)(u);++(i))
#if defined(_MSC_VER) || __cplusplus > 199711L
#define aut(r,v) auto r = (v)
#else
#define aut(r,v) __typeof(v) r = (v)
#endif
#define each(it,o) for(aut(it, (o).begin()); it != (o).end(); ++ it)
#define all(o) (o).begin(), (o).end()
#define pb(x) push_back(x)
#define mp(x,y) make_pair((x),(y))
#define mset(m,v) memset(m,v,sizeof(m))
#define INF 0x3f3f3f3f3f3f3f3fLL
#define SIZE 200105
#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
 
typedef vector<int> vi; typedef pair<int, int> pii; typedef vector<pair<int, int> > vpii; typedef long long ll;
typedef pair<int,ll> pill; typedef pair<ll,int> plli; 
typedef pair<double, int> pdi;
template<typename T, typename U> inline void amin(T &x, U y) { if(y < x) x = y; }
template<typename T, typename U> inline void amax(T &x, U y) { if(x < y) x = y; }
typedef complex<double> P;
ll MOD = 1000000007;
typedef ll Weight;
struct Edge {
	int src, dst;
	Weight weight;
};
bool operator < (const Edge &e, const Edge &f) {
	return e.weight != f.weight ? e.weight > f.weight : // !!INVERSE!!
	e.src != f.src ? e.src < f.src : e.dst < f.dst;
}
typedef vector<Edge> Edges;
int N;
int main(){
	string str;
	cin>>str;
	ll now=0;
	ll ans=0;
	rep(i,str.size()){
		if(str[i]=='W'){
			ans+=(ll)i-now;
			now++;
		}
		
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 640
#include <algorithm>
#include <iostream>
#include <limits>
#include <utility>
#include <vector>

using namespace std;


int main() {
  long N, W;
  cin >> N >> W;
  
  vector<pair<long, long>> weight_values;
  weight_values.reserve(N);
  for (size_t n = 0; n < N; ++n) {
    long w, v;
    cin >> w >> v;
    weight_values.push_back(make_pair(w, v));
  }

  vector<long> dp(100001, -1);
  dp[0] = 0;
  
  long ans = 0;
  for (size_t n = 0; n < N; ++n) {
    vector<long> tmp_dp(100001, -1);
    tmp_dp[0] = 0;
    for (long v = 1; v <= 100000; ++v) {
      long w = W + 1;
      if (weight_values[n].second <= v) {
        long pre = dp[v - weight_values[n].second];
        if (pre != -1) {
          long preval = numeric_limits<long>::max();
          if (dp[v] != -1) preval = dp[v];
    	  w = min(preval, pre + weight_values[n].first);
        } 
      }
      if (w == W +1 && dp[v] != -1) {
        w = dp[v];
      }
      if (w <= W) {
        ans = max(ans, v);
        tmp_dp[v] = w; 
      }
    }
    dp.swap(tmp_dp);
  }
  cout << ans << endl;

  return 0;
}
    

Measured memory_bytes: 1792