akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <utility>
#include <queue>
#include <set>
#include <map>
#include <deque>
#include <iomanip>
#include <cstdio>

using namespace std;
typedef  long long ll;
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;
#define  MP make_pair
#define  PB push_back
#define inf  1000000007
#define rep(i,n) for(int i=0;i<(int)(n);++i)

template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}
int main(){
    int d,n;
    cin >> d >> n;
    if(n==100){
        cout << n+1;
    }else{
    cout << n;
    }
    for(int i=0;i<d;i++){
        cout << "00";
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 256
#include <functional>
#include <algorithm>
#include <iostream>
#include <numeric>
#include <iomanip>
#include <utility>
#include <cstdlib>
#include <sstream>
#include <bitset>
#include <vector>
#include <cstdio>
#include <ctime>
#include <queue>
#include <deque>
#include <cmath>
#include <stack>
#include <list>
#include <map>
#include <set>

using namespace std;

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

#define dump(x)  cerr << #x << " = " << (x) << endl
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(a)  (a).begin(),(a).end()
#define pb push_back


int main() {
    int n;
    cin>>n;
    int sum=0;
    rep(i,n){
        int x,y,b,p;
        cin>>x>>y>>b>>p;
        
        if(b>=5 && p>=2){
            sum=(b*x+p*y)*0.8;
        }
        else{
            sum=min(b*x+p*y, (int)( (max(5,b)*x + max(2,p)*y)*0.8 ) );
        }
        cout<<sum<<endl;
    }
    
    return 0;
}

Measured memory_bytes: 1160
package main

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

var sc = bufio.NewScanner(os.Stdin)
func scanInt() int {
	sc.Scan()
	a,_ := strconv.Atoi(sc.Text())
	return a
}

func scanText() string {
	sc.Scan()
	return sc.Text()
}

type vert struct {
	a int
	b int
}

func main() {
	sc.Split(bufio.ScanWords)
	
	n,m := scanInt(),scanInt()
	g := make([][]int, n)
	for i := 0; i < m; i++ {
		u,v := scanInt()-1,scanInt()-1
		g[u] = append(g[u],v)
	}

	s,t := scanInt()-1,scanInt()-1

	g3 := make([][]int, n)
	for i := 0; i < n; i++ {
		g3[i] = append(g3[i], []int{-1,-1,-1}...)
	}

	g3[s][0] = 0

	queue := make([]vert, 0)
	queue = append(queue, vert{s,0})
	for ; len(queue) > 0; {
		a,b := queue[0].a, queue[0].b
		for _, e := range g[a] {
			if g3[e][(b+1)%3] != -1 {
				continue
			}

			g3[e][(b+1)%3] = g3[a][b]+1
			queue = append(queue, vert{e,(b+1)%3})
		}
		queue = queue[1:]
	}

	if g3[t][0] == -1 {
		fmt.Println(-1)
	} else {
		fmt.Println(g3[t][0]/3)
	}

	// fmt.Println(g3)
}


Measured memory_bytes: 18688
N, Y = map(int, input().split())
ans = [-1,-1,-1]
flag=False
for i in range(N+1):
    for j in range(N-i+1):
        if (i*10000 + j*5000 + (N-i-j)*1000) == Y:
            ans = [i,j,N-i-j]
            flag =True
            break
    if flag:
        break
print('{} {} {}'.format(*ans))

Measured memory_bytes: 8992
#include<bits/stdc++.h>
using namespace std;
#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(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
typedef long long ll;
int main(){
    int n,m; cin >> n >> m;
    vector<ll> a(n+1);
    FOR(i,1,n+1){
        cin >> a[i];
        a[i] += a[i-1];
        a[i] %= m;
    }
    
    ll ans = 0;
    unordered_map<ll,ll> mp;
    rep(i,n+1) mp[a[i]]++;

    for(auto k : mp){
        ll cnt = k.second;
        ans += (cnt*(cnt-1))/2;
    }

    cout << ans << endl;
}


Measured memory_bytes: 4492
#include <iostream>
#include <cstdio>

#define LL long long

using namespace std;

const int maxN = (int) 5e5;
const int mod = (int) 998244353;

LL qpow(LL a, LL b)
{
	LL ans = 1;
	while (b)
	{
		if (b & 1) ans = ans * a % mod;
		a = a * a % mod;
		b >>= 1;
	}
	return ans;
}

int n, m, ans;
int fac[maxN + 2], ifac[maxN + 2];

void init(int n)
{
	fac[0] = 1;
	for (int i = 1; i <= n; ++i) fac[i] = 1ll * fac[i - 1] * i % mod;
	ifac[n] = qpow(fac[n], mod - 2);
	for (int i = n - 1; i >= 0; --i) ifac[i] = 1ll * ifac[i + 1] * (i + 1) % mod;
}

int C(int n, int m)
{
	if (n < 0 || m < 0 || m > n) return 0;
	return 1ll * fac[n] * ifac[m] % mod * ifac[n - m] % mod;
}

int main()
{ 
	scanf("%d%d", &n, &m);
	if (n < m) swap(n, m);
	init(n);
	for (int k = 0; k <= m; ++k)
	{
		ans += 1ll * qpow(-1, k) * C(n, k) % mod * C(m, k) % mod * fac[k] % mod * qpow(m + 1, n - k) % mod * qpow(n + 1, m - k) % mod;
		ans %= mod;
		(ans += mod) %= mod;
	}
	printf("%d\n", (1ll * ans + mod) % mod);
}


Measured memory_bytes: 4096
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
#define fr(i,n) for(long long i=0;i<(n);++i)
#define Fr(i,n) for(long long i=1;i<=(n);++i)
#define ifr(i,n) for(long long i=(n)-1;i>=0;--i)
#define iFr(i,n) for(long long i=(n);i>0;--i)
using Graph = vector<vector<int>>;
 
  int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  ll a,ans,b;
  ans=0;
  cin>>a;
  ll arr[a];
  fr(i,a){
    ll r;
    cin>>r;
    ans=ans^r;
    arr[i]=r;
  }
  fr(i,a){
    b=ans^arr[i];
    cout<<b<<"\n";
  }
}

Measured memory_bytes: 5124
import std.algorithm;
import std.array;
import std.conv;
import std.math;
import std.range;
import std.stdio;
import std.string;

void main() {
  int n, k;
  readf (" %d %d", &n, &k);
  int x = n - (k - 1);
  if (k == 1) {
    writeln (0);
  } else {
    writeln (abs (x - 1));
  }
}



Measured memory_bytes: 256
S = gets.to_i
a =[]
a << S

count = 1
while true

	newa = 0
	count += 1
	if a.last.even?
		newa =  (a.last / 2)
	else
		newa =(a.last * 3 + 1)
	end
	unless a.include?(newa)
		a << newa
	else
		break
	end

end
puts count

Measured memory_bytes: 14196
#include <iostream>
#include<cstdio>
#include<algorithm>
#include<stack>
#include<queue> 
#include<cstring>
using namespace std;
#define ll long long
#define N 200005
struct cnm
{
	ll l,r;
	ll sum;
	void update(ll v)
	{
	    sum+=v*(r-l+1);
	}
};
struct ops
{
    ll pos,quan;
};
cnm tree[N<<2];
ops w[N<<2];
bool cmp(ops a,ops b)
{
	if(a.quan==b.quan)
	return a.pos<b.pos;
	return a.quan<b.quan;
}
#define mid (tree[x].l+tree[x].r)/2
#define lc x<<1
#define rc x<<1|1
void push_up(ll x)
{
	tree[x].sum=tree[lc].sum+tree[rc].sum; 
}
void built(ll l,ll r,ll x)
{
	tree[x].l=l;
	tree[x].r=r;
	tree[x].sum=0;
	if(l==r)
	return;
	built(l,mid,lc);
	built(mid+1,r,rc);
	push_up(x);
}
void update(ll x,ll pot)
{   
	if(tree[x].l==pot&&tree[x].r==pot)
	{
	    tree[x].sum++;
	    return;
	}
	if(pot<=mid)
	update(lc,pot);
	if(pot>mid)
	update(rc,pot);
	push_up(x);
}
ll he(ll l,ll r,ll x)
{  
	if(tree[x].l==l&&tree[x].r==r)
	return tree[x].sum;
	ll ans=0;
	push_up(x);
	if(r<=mid)
	return he(l,r,lc);
	else if(l>mid)
	return he(l,r,rc);
	else
	return he(mid+1,r,rc)+he(l,mid,lc);
}
int main()
{
           ll m,n;
           while(~scanf("%lld%lld",&m,&n))
           {
           	  ll a;
           	  built(1,m,1);
           	  for(int i=1;i<=m;i++)
           	  {
           	  	  scanf("%lld",&a);
           	  	  w[i].pos=i;
           	  	  a-=n;
           	  	  w[i].quan=w[i-1].quan+a;
			  }
			  sort(w+1,w+1+m,cmp);
			  ll ans=0;
			  for(int i=1;i<=m;i++)
			  {
			  	  update(1,w[i].pos);
			  	  if(w[i].quan>=0)
			  	  ans++;
			  	  if(w[i].pos==1)
			  	  continue;
			  	  ans+=he(1,w[i].pos-1,1);
			  }
			  printf("%lld\n",ans);
		   }
            return 0;
}


Measured memory_bytes: 18688
#include <stdio.h>
#include <stdlib.h>
#include <ctype.h>
#include <string.h>
#include <limits.h>
#include <math.h>
#include <time.h>
#include <stdarg.h>
#include <queue>
#include <algorithm>
#include <map>
#include <iostream>

using namespace std;

bool check(string & s, int k) {
  string w = "";
  map<string, int> last;
  for (int i=0; i<s.length(); i++) {
    if (i+k-1 >= s.length()) break;

    if (i==0) {
      for (int j=0; j<k; j++) 
        w += s[j];
    }
    else {
      w.erase(w.begin());
      w += s[i+k-1];
    }

    if (last.find(w) != last.end()) {
      if (i-last[w] >= k)
        return true;
    }
    else {
      last[w] = i;
    }
  }

  return false;
}

int
main() {
 
  int n;
  scanf("%d\n", &n);

  string s;
  cin>>s;

  if (s.length() == 1) {
    cout<<0<<endl;
  }
  else {

    int bottom = 1, top = s.length()/2+1;

    while (1) {
      if (bottom == top) break;

      int mid = (bottom+top) / 2;
      if (check(s, mid)) 
        bottom = mid+1;
      else
        top = mid;
    }

    cout<<bottom-1<<endl;
  }

  return 0;
}




Measured memory_bytes: 6684
n = int(input())
p = list(map(int, input().split()))
#print(p)
cnt = 0
for i in range(1,n-1):
    if p[i] == max(p[i-1],p[i],p[i+1]):
        continue
    if p[i] == min(p[i-1],p[i],p[i+1]):
        continue
    else:
        cnt += 1
print(cnt)

Measured memory_bytes: 3064
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <stdio.h>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <utility>
#include <tuple>
#include <math.h>
#include <set>
#include <map>
using namespace std ;
using ll = long long ;
using ld = long double ;
using vll = vector<ll> ;
using vvll = vector<vll> ;
using vc = vector<char> ;
using vvc = vector<vc> ;
using vb = vector<bool> ;
using vvb = vector<vb> ;
using pll = pair<ll,ll> ;
#define all(v) v.begin(),v.end() 
const ll INF = 1e18 ;
const ll mod = 1e9+7 ;
const double pie = acos(-1); 
vll dx4 = {-1,0,1,0} ;
vll dy4 = {0,-1,0,1} ;
vll dx8 = {-1,0,1,1,1,0,-1,-1} ;
vll dy8 = {-1,-1,-1,0,1,1,1,0} ; 

void fix_cout(){cout << fixed << setprecision(20) << endl ; }
ll gcd(ll a,ll b){if(b==0) return a ; return gcd(b,a%b) ; }
ll lcm(ll a,ll b){return a/gcd(a,b)*b ; }
void chmax(ll &a,ll b){if(a<b) a = b ; }
void chmin(ll &a,ll b){if(a>b) a = b ; }

int solve(){
	ll n,m ;
	cin >> n >> m ;
	vll a(n) ;
	for(auto &i:a) cin >> i ;
	sort(all(a)) ; 
	ll l=0,r=a.at(n-1)*2+1,mid ;
	while(l+1<r){
		mid = (l+r)/2 ;
		ll cnt = 0 ;
		for(auto i:a){
			cnt += a.end()-lower_bound(all(a),mid-i) ;
		}
		if(cnt>=m) l = mid ;
		else r = mid ;
	}
	ll ans = 0 ;
	ll cnt = 0 ;
	vll sum(n+1,0) ;
	for(int i=0;i<n;i++) sum.at(i+1) = sum.at(i)+a.at(i) ;
	for(auto i:a){
		auto itr = lower_bound(all(a),r-i) ;
		ll d = itr-a.begin() ;
		ans += sum.at(n)-sum.at(d)+i*(n-d) ;
		cnt += n-d ;
	}
	ans += (m-cnt)*l ;
	cout << ans << endl ;
}

int main(){
	solve() ;
}

Measured memory_bytes: 1920
#include <bits/stdc++.h>
#define rep(i,n) for(int i=(0);i<(n);i++)

using namespace std;

typedef long long ll;

struct RollingHash {
    static const int base1 = 1007, base2 = 2009;
    static const int mod1 = 1000000007, mod2 = 1000000009;
    vector<long long> hash1, hash2, power1, power2;

    // construct
    RollingHash(const string &S) {
        int n = (int)S.size();
        hash1.assign(n+1, 0);
        hash2.assign(n+1, 0);
        power1.assign(n+1, 1);
        power2.assign(n+1, 1);
        for (int i = 0; i < n; ++i) {
            hash1[i+1] = (hash1[i] * base1 + S[i]) % mod1;
            hash2[i+1] = (hash2[i] * base2 + S[i]) % mod2;
            power1[i+1] = (power1[i] * base1) % mod1;
            power2[i+1] = (power2[i] * base2) % mod2;
        }
    }

    // get hash of S[left:right]
    inline pair<long long, long long> get(int l, int r) const {
        long long res1 = hash1[r] - hash1[l] * power1[r-l] % mod1;
        if (res1 < 0) res1 += mod1;
        long long res2 = hash2[r] - hash2[l] * power2[r-l] % mod2;
        if (res2 < 0) res2 += mod2;
        return {res1, res2};
    }

    // get lcp of S[a:] and T[b:]
    inline int getLCP(int a, int b) const {
        int len = min((int)hash1.size()-a, (int)hash1.size()-b);
        int low = 0, high = len;
        while (high - low > 1) {
            int mid = (low + high) >> 1;
            if (get(a, a+mid) != get(b, b+mid)) high = mid;
            else low = mid;
        }
        return low;
    }
};

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

	int n;
	cin >> n;

	string s;
	cin >> s;

	RollingHash rh(s);

	int res = 0;
	rep(i, n){
		for(int j = i + 1; j < n; j++){
			int l = min(rh.getLCP(i, j), j - i);
			res = max(res, l);
		}
	}

	cout << res << endl;
}


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

using namespace std;
typedef long long ll;
const int N=1e5;
int n ;
int arr[N+1];
int dp[N+1];
int rec(int i)
{
    if(i>=n)
    {
        return 0;
    }
    int &ret=dp[i];
    if(ret!=-1)
    {
        return ret;
    }
    ret=1e9;
    if(i+1<=n)
    {
        ret=min(ret , rec(i+1)+abs(arr[i+1]-arr[i]));
    }
    if(i+2<=n)
    {
        ret=min(ret , rec(i+2)+abs(arr[i+2]-arr[i]));
    }
    return ret;
}
int main()
{

    cin >>  n ;
    memset(dp , -1 , sizeof dp);
    for(int i = 1 ; i <=n ; i++)
    {
        cin >> arr[i];
    }
    /*ll ans = 1e10 , x;
    dp[2]=abs(arr[2]-arr[1]);
    dp[1]=0;
    for(int i = 3 ; i<= n ; i++)
    {
        //x=min(abs(arr[i-2]-arr[i] , abs(arr[i-1]-arr[i])) ;
        dp[i]=min(dp[i-1]+abs(arr[i-1]-arr[i]),dp[i-2]+abs(arr[i-2]-arr[i]));
    }
    */
    cout << rec(1) ;
    return 0;
}


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

using namespace std;

typedef long long ll;
typedef pair<int, int> PII;

const int MM = 1e9 + 7;
const double eps = 1e-8;
const int MAXN = 52;

int n, m;

int a[MAXN];
ll f[MAXN][MAXN*MAXN][MAXN];

void upd(ll & x, ll y){
	x += y;
}

ll tot;

void read(){
	scanf("%d%d", &n, &m);
	tot = 0;
	for(int i = 1; i <= n; i++)
		scanf("%d", &a[i]), tot += a[i];
}

void solve(){
	f[0][0][0] = 1;
	for(int i = 0; i < n; i++)
		for(int j = 0; j <= tot; j++)
			for(int k = 0; k <= i; k++)
				if (f[i][j][k]){
					upd(f[i+1][j][k], f[i][j][k]);
					upd(f[i+1][j+a[i+1]][k+1], f[i][j][k]);
				}
	ll sum = 0;
	for(int i = 1; i <= n; i++)
		if (i * m <= tot)
			upd(sum, f[n][i*m][i]);
	cout<<sum<<endl;
}

void printans(){

}
	

int main(){
	int T = 1;
//	cin>>T;
	while(T--){
		read();
		solve();
		printans();
	}
	return 0;
} 


Measured memory_bytes: 13696
#include <bits/stdc++.h>
#define fuck long long
using namespace std;
int main(){
    fuck n,ans=0,ansn=0;
    char a;
    cin>>n;
    for(fuck i=0;i<n;i++){
        cin>>a;
        if(a=='I'){
            ansn++;
        }else if(a=='D'){
            ansn--;
        }
        ans=max(ans,ansn);
    }
    cout<<ans;
    return 0;
}

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

int main(){
  cout << fixed << setprecision(12);

  int a, b;
  cin>>a>>b;

  cout<< a / b <<" ";
  cout<< a % b <<" ";
  cout<<(double)a / b <<endl;
    
  return 0;
}



Measured memory_bytes: 3284
#![allow(unused, non_snake_case, dead_code, non_upper_case_globals)]
use {
    proconio::{marker::*, *},
    std::{cmp::*, collections::*, mem::*},
};
#[fastout]
fn main() {
    input! {
        n:usize,p:usize,
        s:Chars,
    }
    let mut s = s;
    if p == 2 || p == 5 {
        let mut ans = 0i64;
        for (i, &c) in s.iter().enumerate() {
            if char_conv(c, '0') % p == 0 {
                ans += (i + 1) as i64;
            }
        }
        println!("{}", ans);
        return;
    }
    s.reverse();
    let mut tens = 1usize;
    let mut nm = 0;
    let mut ls = vec![0; p + 3];
    ls[0] = 1;
    for (i, &c) in s.iter().enumerate() {
        let now = char_conv(c, '0');
        nm = (now * tens + nm) % p;
        tens = (tens * 10) % p;
        ls[nm] += 1;
    }
    let ans = ls.iter().fold(0i64, |sum, &cnt| sum + cnt * (cnt - 1) / 2);
    println!("{}", ans);
}
pub fn char_conv(c: char, base: char) -> usize {
    return (c as u8 - base as u8) as usize;
}


Measured memory_bytes: 3048
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;
using static System.Convert;
using static System.Math;
using Pair = System.Tuple<int, int>;
using Edge = System.Tuple<int, int, long>;
//using Debug;
//using static System.Globalization.CultureInfo;

class Program
{
    static string str1;
    static string str2;
    static int[,] ct;
    static void Main(string[] args)
    {
        str1 = ReadLine();
        str2 = ReadLine();
        ct = new int[str1.Length+1, str2.Length+1];
        for (var i = 0; i < str1.Length; i++)
            for (var j = 0; j < str2.Length; j++)
                if (str1[i] == str2[j])
                    ct[i + 1, j + 1] = ct[i, j] + 1;
                else
                    ct[i + 1, j + 1] = Max(ct[i + 1, j], ct[i, j + 1]);
        WriteLine(memo(str1.Length, str2.Length));
    } 
    private static string memo(int i,int j)
    {
        if (i <= 0 || j <= 0) return "";
        if (str1[i - 1] == str2[j - 1]) return memo(i - 1, j - 1) + str1.Substring(i-1, 1);
        else if (ct[i - 1, j] > ct[i, j - 1])
            return memo(i - 1, j);
        else return memo(i, j - 1);
    }
}


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

int main() {
  double w, h, x, y; cin >> w >> h >> x >> y;

  printf("%.6lf ", w*h/2);

  if(x == w/2 && y == h/2) cout << 1 << endl;
  else cout << 0 << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define R cin>>
#define Z class
#define ll long long
#define ln cout<<'\n'
#define in(a) insert(a)
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define all(c) (c).begin(),(c).end()
#define iter(c) __typeof((c).begin())
#define rrep(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define rep(i,n) REP(i,0,n)
#define tr(it,c) for(iter(c) it=(c).begin();it!=(c).end();it++)
template<Z A>void pr(A a){cout<<a;ln;}
template<Z A,Z B>void pr(A a,B b){cout<<a<<' ';pr(b);}
template<Z A,Z B,Z C>void pr(A a,B b,C c){cout<<a<<' ';pr(b,c);}
template<Z A,Z B,Z C,Z D>void pr(A a,B b,C c,D d){cout<<a<<' ';pr(b,c,d);}
template<Z A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}ln;}
ll check(ll n,ll m,ll x,ll y){return x>=0&&x<n&&y>=0&&y<m;}
const ll MAX=1000000007,MAXL=1LL<<61,dx[4]={-1,0,1,0},dy[4]={0,1,0,-1};
typedef pair<int,int> P;

void Main() {
  int n,a,b;
  cin >> n >> a >> b;
  pr(min(n*a,b));
}

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


Measured memory_bytes: 256
def c(s):
    n = len(s)
    for i in range(n//2):
        if s[i] != s[n-i-1]:
            return False
    return True
s = input().strip()
n = len(s)
if c(s) and c(s[:n//2]) and c(s[::-1][:n//2]):
    print("Yes")
else:
    print("No")


Measured memory_bytes: 38740
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <map>

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

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

    if(a == 1 && b == 2) cout << 3 << endl;
    if(a == 1 && b == 3) cout << 2 << endl;
    if(a == 2 && b == 1) cout << 3 << endl;
    if(a == 2 && b == 3) cout << 1 << endl;
    if(a == 3 && b == 1) cout << 2 << endl;
    if(a == 3 && b == 2) cout << 1 << endl;
    
    return 0;
}

Measured memory_bytes: 256
from collections import deque

def main():
    N = int(input())
    A = deque(sorted((int(input()) for i in range(N))))
    dq = deque()
    dq.append(A.popleft())
    ans = 0
    for _ in range(N-1):
        a_first = A[0]
        a_last = A[-1]
        dq_first = dq[0]
        dq_last = dq[-1]

        ff = abs(a_first-dq_first)
        fl = abs(a_first-dq_last)
        lf = abs(a_last-dq_first)
        ll = abs(a_last-dq_last)

        comp_list = [ff, fl, lf, ll]
        max_idx = comp_list.index(max(comp_list))
        if max_idx == 0:
            ans += ff
            dq.appendleft(A.popleft())
        elif max_idx == 1:
            ans += fl
            dq.append(A.popleft())
        elif max_idx == 2:
            ans += lf
            dq.appendleft(A.pop())
        else:
            ans += ll
            dq.append(A.pop())

    print(ans)
if __name__ == "__main__":
    main()

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

using namespace std;
#define IOS ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define ll long long
#define ld long double
#define MOD 1000000007
#define endl "\n"

int main()
{
	IOS;
	int n,m;
	cin >>n>>m;
	cout << (m*(m-1)/2)+(n*(n-1)/2) <<endl;
	return 0;
}

Measured memory_bytes: 256
// Rustで競技プログラミングの入力をスッキリ記述するマクロ
// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8

use std::collections::HashSet;

macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($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:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn solve(words: Vec<Vec<char>>) {
    let mut set = HashSet::new();
    let mut end = None;
    for w in words.iter() {
        if (end == w.get(0) && !set.contains(w)) || None == end {
            set.insert(w);
            end = w.get(w.len() - 1);
        } else {
            println!("No");
            std::process::exit(0);
        }
    }
    println!("Yes");
}

fn main() {
    input! {
        n: usize,
        w: [chars; n]
    }
    solve(w)
}


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

int f(vector<vector<int> > &e, int u, int d, int l, int r){

    int res = 0;
    int hight = 10;
    for(int i = u; i <= d; i++){
        hight = min(hight, e[i][l]);
        hight = min(hight, e[i][r]);
    }

    for(int j = l; j <= r; j++){
        hight = min(hight, e[u][j]);
        hight = min(hight, e[d][j]);
    }

    for(int i = u + 1; i < d; i++){
        for(int j = l + 1; j < r; j++){
            if(hight <= e[i][j]) return 0;
            res += hight - e[i][j];
        }
    }

    return res;
}

int main(){

    while(1){
        
        int h, w; cin >> h >> w;
        if(!h) break;
        vector<vector<int> > e(h, vector<int> (w));
        for(int i = 0; i < h; i++){
            for(int j = 0; j < w; j++){
                cin >> e[i][j];
            }
        }

        int ans = 0;
        
        //[u, d]
        //[l, r]

        for(int u = 0; u < h; u++){
            for(int l = 0; l < w; l++){
                for(int d = u + 2; d < h; d++){
                    for(int r = l + 2; r < w; r++){
                        ans = max(ans, f(e, u, d, l, r));
                    }
                }
            }
        }

        cout << ans << endl;
    }

    return 0;
}


Measured memory_bytes: 3160
#include <atcoder/modint>
#include <atcoder/lazysegtree>
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using mint = atcoder::modint998244353;

vector<mint> pow10;
mint inv9 = mint(1)/mint(9);
struct S {
    mint num;
    mint base;
    ll sz;
};
S f_op(S x, S y) {
    mint r = x.num*pow10[y.sz]+y.num;
    return S{r, y.base, x.sz+y.sz};
}
S f_e() {
    return S{0,1,0};
}
struct F {
    int d;
    int t;
};
S f_map(F f, S x) {
    if ( f.d == 0 ) {
        return x;
    } else {
        mint k = (pow10[x.sz] - 1) *inv9 ;
        return S{k*f.d, x.base, x.sz};
    }
}
F f_comp(F f1, F f2) {
    if ( f1.t >= f2.t ) return f1;
    else return f2;
}
F f_id() {
    return F{0,-1};
}

ll solve() {
    ll N, Q;
    cin >> N >> Q;
    vector<ll> L(Q), R(Q), D(Q);
    for ( int i = 0; i < Q; i++ ) {
        cin >> L[i] >> R[i] >> D[i];
        L[i]--, R[i]--;
    }
    mint b(1);
    for ( int i = 0; i <= N; i++ ) {
        pow10.push_back(b);
        b *= 10;
    }

    b = mint(1);
    vector<S> ini(N);
    for ( int i = N-1; i >= 0; i-- ) {
        ini[i] = S{1,b,1};
        b *= 10;
    }
    atcoder::lazy_segtree<S, f_op, f_e, F, f_map, f_comp, f_id> sg(ini);
    vector<mint> ans(Q);
    for ( int q = 0; q < Q; q++ ) {
        sg.apply(L[q],R[q]+1, F{D[q],q});
        ans[q] = sg.all_prod().num;
    }
    for ( int q = 0; q < Q; q++ ) {
        cout << ans[q].val() << "\n";
    }
    return 0;
}

int main() {
    solve();
    return 0;
}

Measured memory_bytes: 23000
import sys
input=sys.stdin.readline
sys.setrecursionlimit(10 ** 6)
from collections import defaultdict
import fractions
import math
from collections import deque
from bisect import bisect_left
from bisect import insort_left
import itertools
from heapq import heapify
from heapq import heappop
from heapq import heappush
import numpy as np
#d = defaultdict(int)
#N = int(input())
#A = list(map(int,input().split()))
#S = list(input())
#S.remove("\n")
#N,M = map(int,input().split())
#S,T = map(str,input().split())
#A = [int(input()) for _ in range(N)]
#S = [input() for _ in range(N)]
#A = [list(map(int,input().split())) for _ in range(N)]
N,M,K = map(int,input().split())
fr = [[] for _ in range(N)]
br = [[] for _ in range(N)]
for _ in range(M):
    a,b = map(int,input().split())
    fr[a-1].append(b-1)
    fr[b-1].append(a-1)
for _ in range(K):
    c,d = map(int,input().split())
    br[c-1].append(d-1)
    br[d-1].append(c-1)
used = [-1]*N #-1なら未探索。数字はrenketuのindex
renketu = []
index = 0
def dfs(fr,cur,parent,index,li):
    children = fr[cur]
    for chi in children:
        if chi == parent or used[chi] != -1:
            continue
        used[chi] = index
        li.append(chi)
        dfs(fr,chi,cur,index,li)
for i in range(N):
    if used[i] != -1:
        continue
    li = [i]
    used[i] = index
    dfs(fr,i,-1,index,li)
    index += 1
    renketu.append(li)
ans = [0]*N
for i in range(N):
    ans[i] = len(renketu[used[i]])-1
for i in range(N):
    li1 = fr[i]
    li2 = br[i]
    for j1 in li1:
        if i < j1:
            if used[i] == used[j1]:
                ans[i] -= 1
                ans[j1] -= 1
    for j2 in li2:
        if i < j2:
            if used[i] == used[j2]:
                ans[i] -= 1
                ans[j2] -= 1
print(*ans)
    

Measured memory_bytes: 77348
#include <cstdio>
#include <algorithm>
#include <stack>
#include <queue>
#include <deque>
#include <vector>
#include <string>
#include <string.h>
#include <cstdlib>
#include <ctime>
#include <cmath>
#include <map>
#include <set>
#include <iostream>
#include <sstream>
#include <numeric>
#include <cctype>
#include <bitset>
#include <cassert>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define gep(i,g,j) for(int i = g.head[j]; i != -1; i = g.e[i].next)
#define each(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)
#define rng(a) a.begin(),a.end()
#define maxs(x,y) x = max(x,y)
#define mins(x,y) x = min(x,y)
#define pb push_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcount
#define uni(x) x.erase(unique(rng(x)),x.end())
#define snuke srand((unsigned)clock()+(unsigned)time(NULL));
#define df(x) int x = in()
#define dame { puts("-1"); return 0;}
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,vector<T>,greater<T> >
#define bn(x) ((1<<x)-1)
#define newline puts("")
#define v(T) vector<T>
#define vv(T) vector<vector<T>>
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
inline int in() { int x; scanf("%d",&x); return x;}
inline void priv(vi a) { rep(i,sz(a)) printf("%d%c",a[i],i==sz(a)-1?'\n':' ');}
template<typename T>istream& operator>>(istream&i,vector<T>&v)
{rep(j,sz(v))i>>v[j];return i;}
template<typename T>string join(const vector<T>&v)
{stringstream s;rep(i,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template<typename T>ostream& operator<<(ostream&o,const vector<T>&v)
{if(sz(v))o<<join(v);return o;}
template<typename T1,typename T2>istream& operator>>(istream&i,pair<T1,T2>&v)
{return i>>v.fi>>v.se;}
template<typename T1,typename T2>ostream& operator<<(ostream&o,const pair<T1,T2>&v)
{return o<<v.fi<<","<<v.se;}
const int MX = 100005, INF = 1001001001;
const ll LINF = 1e18;
const double eps = 1e-10;

ll dp[101][305];

int main() {
  int n,w;
  scanf("%d%d",&n,&w);
  int ws = 0, sum = 0;
  rep(i,n) {
    int a,b;
    scanf("%d%d",&a,&b);
    if (!i) {
      ws = a;
    }
    // 壓縮
    a -= ws;
    // 選擇j個，重量為sum時，選或不選第i個物品
    for ( int j=i; j>=0; j-- ) {
      for ( int k=sum; k>=0; k-- ) {
        maxs(dp[j+1][k+a], dp[j][k]+b);
      }
    }
    sum += a;
  }
  ll ans = 0;
  // 選擇i個，壓縮後的重量j
  for ( int i=0; i<=n; i++ ) {
    for ( int j=0; j<=sum; j++ ) {
      ll x = (ll)ws*i+j;
      if (x <= w) {
        maxs(ans,dp[i][j]);
      }
    }
  }
  cout<<ans<<endl;
  return 0;
}






















Measured memory_bytes: 3928
#include <math.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <queue>
#include <map>
#include <utility>
#include <iomanip>
using namespace std;

#define ll long long

void solve()
{
    ll N, K;
    cin >> N >> K;
    vector<ll> A(N);
    map<ll, ll> visited;
    for (ll i = 0; i < N; i++)
    {
        cin >> A.at(i);
        A.at(i)--;
    }

    vector<ll> list;
    visited[0] = 1;
    list.push_back(0);
    ll visit = A.at(0);
    ll count = 0;
    while (1)
    {
        // 訪問済みなら終了
        if (visited[visit] != (ll)NULL)
        {
            // for (auto a : list)
            // {
            //     cout << a << endl;
            // }
            break;
        }
        visited[visit] = 1;
        list.push_back(visit);
        count++;
        // テレポータの使用回数がKになったら終了
        if (count >= K)
        {
            cout << visit + 1 << endl;
            return;
        }

        // 次の訪問先
        visit = A.at(visit);
    }

    auto result = find(list.begin(), list.end(), visit);
    ll index = distance(list.begin(), result);
    // ループしてない部分の数
    ll noLoopCount = index;
    // cout << ";;" << noLoopCount << endl;
    // ループしてる部分の数
    ll loopCount = list.size() - noLoopCount;
    // cout << ";" << loopCount << endl;

    // ループを処理する
    ll KT = K + 1;
    KT -= noLoopCount;
    ll loopA = KT % loopCount;
    ll loopIndex = 0;
    if (loopA == 0)
    {
        loopIndex = loopCount - 1;
    }
    else
    {
        loopIndex = loopA - 1;
    }

    // cout << ";;;" << loopIndex << endl;
    cout << list.at(index + loopIndex) + 1 << endl;

    return;
}

int main()
{
    solve();
    return 0;
}


Measured memory_bytes: 15944
#include <bits/stdc++.h>
using namespace std;
int main(){
    long long k, ans=0;
    cin>>k;
    for(long long i=1;i<=k;i++){
        for(long long j=1;j<=k;j++){
            for(long long l=1;l<=k;l++){
                ans+=__gcd(__gcd(i, j), l);
            }
        }
    }cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >> N;
  string s, t;
  cin >> s >> t;
  
  string Ans = "";
  
  for(int i = 0; i < N; i++){
  Ans.push_back(s.at(i));
  Ans.push_back(t.at(i));
  }
  
  cout << Ans << endl;
}


Measured memory_bytes: 256
n = int(input()) # 入力が1つ
t, a = map(int, input().split()) # 入力が複数
h = [int(i) for i in input().split()] # 配列で数字

ans = 0
nearest = abs(t - h[0] * 0.006 - a)
for i in range(n):
    temp = abs(t - h[i] * 0.006 - a)
    if temp < nearest:
        nearest = temp
        ans = i
print(ans + 1)

Measured memory_bytes: 38384
from pprint import pprint as pp
from pprint import pformat as pf
import math

def get_data():
    input_data = int(input())
    return input_data

def make_score_list(referee_num):
    score_list = [None] * referee_num
    for i in range(referee_num):
        score_list[i] = get_data()
    return score_list

def calculate_adjusted_average(score_list, referee_num):
    referee_num -= 2
    adjusted_average = (sum(score_list) - max(score_list) - min(score_list)) / referee_num
    return adjusted_average


if __name__ == "__main__":
    while True:
        referee_num = get_data()
        if referee_num == 0:
            break
        score_list = make_score_list(referee_num)
        adjusted_average = math.floor(calculate_adjusted_average(score_list, referee_num))
        print(adjusted_average)




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

#define LL long long
#define pii pair<int,int>
using namespace std;
const int inf = 2147483647;
const int N = 100001;

int _max(int x, int y) {return x > y ? x : y;}
int _min(int x, int y) {return x < y ? x : y;}
inline int read() {
    int x = 0, f = 1; char ch = getchar();
    while(ch < '0' || ch > '9') {if(ch == '-') f = -1; ch = getchar();}
    while(ch >= '0' && ch <= '9') x = (x << 3) + (x << 1) + (ch ^ 48), ch = getchar();
    return x * f;
}
void put(int x) {
	if(x < 0) putchar('-'), x = -x;
	if(x >= 10) put(x / 10);
	putchar(x % 10 + '0');
}

int n, a[N];
struct seg {
	int c[N << 2], pos[N << 2], cnt;
	
	void bt(int n) {
		for(cnt = 1; cnt <= n; cnt <<= 1);
		for(int i = cnt + 1; i <= cnt + n; i++) c[i] = a[i - cnt], pos[i] = i - cnt;
		for(int i = cnt; i >= 1; i--) {
			if(c[i << 1] > c[i << 1 | 1]) {
				c[i] = c[i << 1], pos[i] = pos[i << 1];
			} else {
				c[i] = c[i << 1 | 1], pos[i] = pos[i << 1 | 1];
			}
		}
	}
	
	void cg(int x, int s) {
		c[x += cnt] = s;
		while(1) {
			x >>= 1;
			if(!x) break;
			if(c[x << 1] > c[x << 1 | 1]) c[x] = c[x << 1], pos[x] = pos[x << 1];
			else c[x] = c[x << 1 | 1], pos[x] = pos[x << 1 | 1];
		}
	}
} t;

int main() {
	n = read(); int m = read();
	for(int i = 1; i <= n; i++) a[i] = read();
	t.bt(n);
	for(int i = 1; i <= m; i++) {
		int hh = t.pos[1];
		a[hh] /= 2, t.cg(hh, a[hh]);
	} LL sum = 0;
	for(int i = 1; i <= n; i++) sum += a[i];
	printf("%lld\n", sum);
	return 0;
}


Measured memory_bytes: 2432
n,x=list(map(int,input().split()))
a=list(map(int,input().split()))

a.sort()
count=0
for i in range(n):
  x=x-a[i]
  if(x<0):
    break;
  count=count+1
if(x>0):
  count=count-1
print(count)

Measured memory_bytes: 3060
import sys
import math
import itertools
import bisect
from copy import copy
from collections import deque,Counter
from decimal import Decimal
def s(): return input()
def i(): return int(input())
def S(): return input().split()
def I(): return map(int,input().split())
def L(): return list(input().split())
def l(): return list(map(int,input().split()))
def lcm(a,b): return a*b//math.gcd(a,b)
sys.setrecursionlimit(10 ** 9)
INF = 10**9
mod = 10**9+7

A,B = I()
ans = 0
for i in range(A,B+1):
    F = 1
    s = str(i)
    for i in range(2):
        if s[i] != s[4-i]:
            F = 0
    if F == 1:
        ans += 1
print(ans)

Measured memory_bytes: 78076
// CountingCharacters.cc
// 与えられた英文に含まれる、各アルファベットの数を数えるプログラムを作成して下さい。
// なお、小文字と大文字は区別しません。
// 【入力】
// 複数の行にまたがる１つの英文が与えられます。
// 【出力】
// 与えられた英文に含まれる各アルファベットの数を以下に示す形式で出力して下さい：
// a : aの個数
// b : bの個数
// c : cの個数
//   .
//   .
// z : zの個数
// 【制約】
// ・英文が含む文字の数 < 1200
// 【例】
// 入力：
// This is a pen.
// 出力：
// a : 1
// b : 0
// c : 0
// d : 0
// e : 1
// f : 0
// g : 0
// h : 1
// i : 2
// j : 0
// k : 0
// l : 0
// m : 0
// n : 1
// o : 0
// p : 1
// q : 0
// r : 0
// s : 2
// t : 1
// u : 0
// v : 0
// w : 0
// x : 0
// y : 0
// z : 0
#include<cstdio>
#include<cstring>
#include<cctype>

int main( void) {
  char sentence[1200];

  // 入力された英文を受け取る。
  int i = 0;
  while ( scanf( "%c", &sentence[i]) != EOF) {
    sentence[i] = tolower( (int)sentence[i]);
    i++;
  }
  sentence[i] = '\0';
  int sentence_len = i;

  // 各英文字の数を数える。
  int cnt_char[26] = {};	// 初期化(0)しておく。
  int char_num;
  for ( int i = 0; i < sentence_len; i++) {
    char_num = sentence[i] - 'a';
    if ( 0 <= char_num && char_num <= 25) cnt_char[char_num]++;
  }

  // 各英文字の数を出力する。
  for ( int i = 0; i < 26; i++) {
    printf( "%c : %d\n", (char)( i + 'a'), cnt_char[ i]);
  }

  return 0;
}



Measured memory_bytes: 2688
#include <stdio.h>

int main(){
    int a,b,c,i,cnt=0;
    
    scanf("%d%d%d",&a,&b,&c);
    for(i=a;i<=b;i++){
        if(c%i==0)cnt++;
    }
    printf("%d\n",cnt);
    return 0;
}


Measured memory_bytes: 2116
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <map>

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

int main(){

    ll n,a,b;
    cin >> n >> a >> b;

    ll ans,tmp,tmp2;
    tmp = n / (a+b);
    ans = tmp * (a);
    tmp = n - tmp*(a+b);
    ans += min(tmp,a);
    
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
n, k = map(int,input().split())
r, s, p = map(int, input().split())
t = input()
scoremap = {
    "r": p,
    "p": s,
    "s": r,
    "-": 0
}
t=[i for i in t]

def best(ls: list):
    for i in range(len(ls) - 1):
        if ls[i] == ls[i + 1]:
            ls[i + 1] = '-'
    num=sum([scoremap[i] for i in ls])
    return num

total=0
for i in range(k):
    ls = t[i::k]
    total+=best(ls)
print(total)

Measured memory_bytes: 5564
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
//#define MOD 998244353
#define INF 1145141919810893364
#define PI 3.141592653589
typedef pair<int,int> PP;
typedef long long ll;
#define int ll
#define setdouble setprecision
#define REP(i,n) for(int i=0;i<(n);++i)
#define OREP(i,n) for(int i=1;i<=(n);++i)
#define RREP(i,n) for(int i=(n)-1;i>=0;--i)
#define GOODBYE do { cout << "No" << endl; return 0; } while (false)
#define MM <<" "<<
#define Endl endl

signed main(void){
    int N,K,Ans=0;
    int h[114514];
    cin >> N >> K;
    REP(i,N){
        cin >> h[i];
    }
    REP(i,N){
        if(h[i]>=K)Ans++;
    }
    cout << Ans << endl;
    return 0;
}



Measured memory_bytes: 1024
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author champon
 */

#include <iostream>
#include <fstream>

#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i, n) for(ll i=0; i<n; i++)
#define repr(i, s, e) for(ll i=s; i>=e; i--)
#define reps(i, s, e) for(ll i=s; i<=e; i++)
#define inf 1e18
#define all(v) v.begin(),v.end()
#define ceill(a, b) (a+b-1)/b
#define ok cout << "ok" << endl;
#define sp << " " <<
void ans(bool b){ cout << (b ? "Yes" : "No") << endl; }
void ans2(bool b){ cout << (b ? "YES" : "NO") << endl; }
template<typename T> inline bool chmax(T &a, T b){ if(a<b) a=b; return a<b; }
template<typename T> inline bool chmin(T &a, T b){ if(b<a) a=b; return b<a; }
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    fill((T*)array, (T*)(array+N), val);
}
template<typename T> void vdeb(T v){
    cout << "#vector set debug" << endl;
    for(auto vv : v) cout << vv << " ";
    cout << endl;
}
template<typename T1, typename T2> void adeb(T1 arr[], T2 n){
    cout << "#adebug" << endl;
    for(int i=0; i<=n; i++) cout << arr[i] << " ";
    cout << endl;
}
template<typename T1> void mdeb(T1 mp){
    cout << "#map pair debug" << endl;
    for(auto const& m : mp) cout << m.first sp m.second << endl;
}
int dx[] = {1, 0, -1, 0, 1, -1, 1, -1};
int dy[] = {0, 1, 0, -1, 1, -1, -1, 1};


class ESequenceDecomposing {
public:
	void solve(std::istream& in, std::ostream& out) {
        int n;
        in >> n;
        vector<ll> a(n, 0);
        rep(i, n){
            in >> a[i];
            a[i] = -a[i];
        }

        vector<ll> head;
        rep(i, n){
            int ind = distance(head.begin(), upper_bound(all(head), a[i]));
            if(ind == head.size()){
                head.push_back(a[i]);
            }else{
                head[ind] = a[i];
            }
        }

        out << head.size() << endl;
	}
};


int main() {
	ESequenceDecomposing solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 2168
#include<stdio.h>

int isPower(int x){
    int k = 0, i;
    for(i = x; i > 1; i--){
        for(int j = 2; j < i; j++){
            k = j;
            while(k <= i){
                if(k == i){
                    return i;
                }
                k *= j;
            }
        }
    }
    return i;
}

int main(void){
    int x;
    scanf("%d", &x);
    printf("%d\n", isPower(x));
    return 0;
}

Measured memory_bytes: 128
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric;

alias Path = Tuple!(int, "i", int, "to", int, "c");

void main()
{
    auto N = readln.chomp.to!int;
    Path[][] G;
    G.length = N;
    foreach (i; 0..N-1) {
        auto ab = readln.split.to!(int[]);
        auto a = ab[0]-1;
        auto b = ab[1]-1;
        G[a] ~= Path(i, b, 0);
        G[b] ~= Path(i, a, 0);
    }
    int max_n;
    foreach (n; G) max_n = max(max_n, n.length.to!int);
    int[] SC;
    SC.length = N;
    SC[0] = 1;
    void solve(int i, int par) {
        int c = (SC[i] + 1) % (max_n + 1);
        if (c == 0) c = 1;
        foreach (ref p; G[i]) if (p.to != par) {
            p.c = c;
            SC[p.to] = c;
            solve(p.to, i);
            c = (c+1) % (max_n + 1);
            if (c == 0) c = 1;
        }
    }
    solve(0, -1);
    Path[] R;
    foreach (n; G) foreach (p; n) if (p.c) R ~= p;
    sort!"a.i < b.i"(R);
    writeln(max_n);
    foreach (r; R) writeln(r.c);
}

Measured memory_bytes: 19964
a2b , b2c, c2a = map(int,input().split())
if b2c <= a2b and c2a <= a2b:
    print(b2c + c2a)
if a2b < b2c and  c2a <= b2c:
    print(a2b + c2a)
if b2c < c2a and a2b < c2a:
    print(b2c + a2b)

Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
#define rng(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,b) rng(i,0,b)
#define gnr(i,a,b) for(int i=int(b)-1;i>=int(a);i--)
#define per(i,b) gnr(i,0,b)
#define ALL(x) (x).begin(),(x).end()
#define RALL(x) (x).rbegin(),(x).rend()
#define IDX(vec, element_iter) distance((vec).begin(), element_iter)
#define pb push_back
#define mp make_pair
#define INF9 1000000000 //10^9
#define MOD 1000000007 //10^9+7
#define fi first
#define sc second
using ll=long long;
using pll=pair<ll,ll>;
using vi=vector<int>;
using vll=vector<ll>;
using vstr=vector<string>;

int main() {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
	cout<<fixed<<setprecision(20);

    ll a,b,n; cin >> a >> b >> n;
   
    ll x = min(b-1, n);
    ll ans = (a*x)/b - a*(x/b); 
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3640
s = input()
n = len(s)
MOD = 1e9 + 7
dp = [[0] * 13 for _ in range(n)]
for i in range(10):
	if s[0] == "?":
		dp[0][i] = 1
	else:
		cur = ord(s[0]) - ord("0")
		dp[0][cur] = 1
for i in range(1, n):
	if s[i] != "?":
		cur = ord(s[i]) - ord("0")
		for j in range(13):
			dp[i][(10 * j + cur) % 13] += dp[i - 1][j] % MOD
	else:
		for j in range(13):
			for cur in range(10):
				dp[i][(10 * j + cur) % 13] += dp[i - 1][j] % MOD
#print(dp)
print(int(dp[n - 1][5] % MOD))

Measured memory_bytes: 96092
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <cmath>
#include <complex>
#include <map>
#include <set>
#include <vector>
#include <stack>
#include <queue>
#include <bitset>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cassert>
#include <iomanip>
using namespace std;

#define Rep(b, e, i) for(int i = b; i <= e; i++)
#define Repr(e, b, i) for(int i = e; i >= b; i--)
#define rep(n, i) Rep(0, n-1, i)
#define repr(n, i) Repr(n-1, 0, i)
#define all(v) (v).begin(), (v).end()
#define pb(v) push_back(v)
#define uniq(v) (v).erase(unique(all(v)),(v).end())
#define bitcnt(x) __builtin_popcount(x)
#define fst first
#define snd second
#define Pqaz(T) priority_queue<T,vector<T>,greater<T>>
#define Pqza(T) priority_queue<T>
#define put(x) cout << x;
#define putsp(x) cout << x << ' ';
#define putln(x) cout << x << endl;
#define ENJYU std::ios::sync_with_stdio(false);std::cin.tie(0);

typedef long long ll;
typedef pair<ll, ll> llP;
typedef pair<int, int> intP;
typedef complex<double> comp;

//vector の中身を出力
template <class T>ostream &operator<<(ostream &o,const vector<T>&v)
{o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}

const int MAX = 32;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const ll INF = 1e18;
const int MOD = 1000000007;

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

void solve(void){
	int N, C;
	cin >> N >> C;

	int col[MAX][MAX];

	// i -> j
	rep(C, i) rep(C, j) cin >> col[i][j];

	vector <vector <int>> grid(N, vector <int> (N));

	rep(N, i) rep(N, j)
	{
		cin >> grid[i][j];
		grid[i][j]--;
	}

	ll ans = INF;

	map <int, int> mp[3];

	rep(N, i) rep(N, j)
	{
		mp[(i+j)%3][grid[i][j]]++;
	}



	rep(C, i) rep(C, j) rep(C, k)
	{
		if (i == j || j == k || k == i) continue;

		ll tmp = 0;

		rep(3, d)
		{
			int color = i;
			if (d == 1) color = j;
			if (d == 2) color = k;
			rep(C, x)
			{
				tmp += mp[d][x] * col[x][color];
			}
		}

		ans = min(ans, tmp);

	}


	cout << ans << endl;

}

int main(void){
	solve();
	//cout << "yui(*-v・)yui" << endl;
	return 0;
}


Measured memory_bytes: 1280
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<utility>
#include<cmath>
#include<climits>
#include<queue>
#include<stack>
#include<numeric>
#include<set>
#include<iomanip>
#include<map>
using namespace std;


typedef long long ll;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)

const int mod = 1000000007;


int main(){
    int n, a, b;
    cin >> n >> a >> b;
    int ans = min(a * n, b);
    cout << ans << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define LL long long
#define clr(x,i) memset(x,i,sizeof(x))
using namespace std;
const int N=100005;
inline int read()
{
    int x=0,f=1;char ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
    while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
    return x*f;
}
int a,b,c,x,y;
int main()
{
	scanf("%d%d%d%d%d",&a,&b,&c,&x,&y);
	bool fc=0;
	if(2*c<a+b) fc=1;
	int mi=min(x,y),mx=max(x,y);LL ans=0;
	if(fc){
		ans+=(LL)2*c*mi;
		if(x>y) {
			int p=x-mi;
			if(2*c<=a) ans+=(LL)2*c*p;
			else ans+=(LL)p*a;
		}
		else {
			int p=y-mi;
			if(2*c<=b) ans+=(LL)2*c*p;
			else ans+=(LL)p*b;
		}//ans+=(LL)(y-mi)*b;
	}
	else{
		ans=(LL)a*x+(LL)b*y;
	}
	cout << ans;
	
	
}

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

int main(){
    int n;
    cin >> n;
    vector<int> a(100005);
    rep(i,n){
        int x;
        cin >> x;
        a[x]++;
    }
    int ans = 0;
    rep(i,100000){
        int cnt = 0;
        rep(j,3) cnt += a[i+j];
        ans = max(ans, cnt);
    }
    cout << ans << endl;
}

Measured memory_bytes: 3740
#include<stdio.h>
#include<string.h>
#include<math.h>
#define anD &&
#define oR ||
#define max(a,b) (((a)>(b))?(a):(b))
#define min(a,b) (((a)<(b))?(a):(b))
#define rep(i,n) for((i)=0;(i)<(n);(i)++)

int is_prime( long long p) {
	int hantei,i;
	if (p == 1) {
		return 0;
	}
	else if (p == 2) {
		return 1;
	}
	else {
		for (i = 2; i <= sqrt(p); i++) {
			if (p%i == 0) return 0;
		}
		return 1;
	}
}

int main() {
	int n, i;
	int sum = 0;
	long long x;
	scanf("%d", &n);
	for (i = 0; i < n; i++) {

		scanf("%lld", &x);
		sum += is_prime(x);
	}

	printf("%d\n", sum);
	return 0;
}

Measured memory_bytes: 596
#include <iostream>
#include <cstdio>
#include <cmath>
using namespace std;

int main(){
  double a, l, x;

  while(cin >> a >> l >> x){
    double len = sqrt(l * l - (a / 2.0) * (a / 2.0));
    double b = (l + x) / 2.0;
    double s = (b + b + l) / 2.0;
    printf("%.10f\n", a * len / 2.0 + sqrt(s * (s - b) * (s - b) * (s - l)) * 2.0);
  }
}

Measured memory_bytes: 1244