akhauriyash/Code-Regression huggingface dataset:
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

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

#[allow(unused_macros)]
macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

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

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

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

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}
fn main() {
    input! {
        k: i64,
        s: i64,
    }
    let mut time = 0;
    for i in 0..k + 1 {
        for j in 0..k + 1 {
            if 0 <= s - i - j && s - i - j <= k {
                time+=1;
            }
        }
    }
    println!("{}", time);
}

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

int main(){
	int n,x,y;
	cin >> n >> x >> y;
	vector<int> cnt(n);	
	for(int i = 1;i <= n-1;i++){
		for(int j = i+1;j <= n;j++){
			cnt[min({abs(j-i), abs(x-i)+1+abs(y-j), abs(y-i)+1+abs(x-j)})] += 1;
		}
	}
	for(int k = 1;k < n;k++){
		cout << cnt[k] << endl;
	}
}

Measured memory_bytes: 256
N, A, B = list(map(int,input().split()))
list = []
totalsum=0
for i in range(N+1):
    n = len(str(i))
    sum = 0
    for j in range(n):
        sum += int(str(i)[j])
    if A <= sum <= B:
        totalsum += i
print(totalsum)
    

Measured memory_bytes: 2940
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cassert>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <functional>
#include <iostream>
#include <map>
#include <set>
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pb push_back
#define mp make_pair
#define fi first
#define sc second
#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
const int INF = 1000000000;
const int mod = 1000000007;
typedef pair<ll,ll> Q;
bool cmp(Q p,Q q){
	if(p.fi != q.fi) return p.fi < q.fi;
	return p.sc < q.sc;
}
ll det(Q a,Q b){
	return a.fi*b.sc - a.sc*b.fi;
}
//det < 0 -> points may be on edge
//det <= 0 -> points must not be on edge
vector<Q> convex_hull(vector<Q>vs){
	sort(vs.begin(),vs.end(),cmp);
	int k = 0;
	vector<Q>qs (vs.size()*2);
	
	for(int i=0;i<vs.size();i++){
		while(k>1 && det(mp(qs[k-1].fi-qs[k-2].fi,qs[k-1].sc-qs[k-2].sc),mp(vs[i].fi-qs[k-1].fi,vs[i].sc-qs[k-1].sc))<0){
			k--;
		}
		qs[k++] = vs[i];
	}
	for(int i=vs.size()-2,t = k;i>=0;i--){
		while(k>t && det(mp(qs[k-1].fi-qs[k-2].fi,qs[k-1].sc-qs[k-2].sc),mp(vs[i].fi-qs[k-1].fi,vs[i].sc-qs[k-1].sc))<0){
			k--;
		}
		qs[k++] = vs[i];
	}
	qs.resize(k-1);
	return qs;
}
int n;
vector<Q>vec;
int main(){
	//if you don't use scanf / printf
	ios::sync_with_stdio(false);
	cin >> n;
	rep(i,n){
		ll x,y; cin >> x >> y; vec.pb(Q(x,y));
	}
	vector<Q>ans = convex_hull(vec);
	Q beg = mp(1e18,1e18);
	int id;
	rep(i,ans.size()) if(beg.sc > ans[i].sc || (beg.sc == ans[i].sc && beg.fi > ans[i].fi)) beg = ans[i], id = i;
	cout << ans.size() << '\n';
	rep(i,ans.size()) cout << ans[(i+id)%ans.size()].fi << " " << ans[(i+id)%ans.size()].sc << '\n';
}


Measured memory_bytes: 9156
import java.util.*;
public class Main{
	
	public static void main(String[] args) {
		Scanner input=new Scanner(System.in);
		
		Stack<Character> q=new Stack<>();
		String str=input.next();
		char a[]=str.toCharArray();
		for(int i=0;i<a.length;i++) {
			char c=a[i];
			if(q.isEmpty()&&c=='C')
				q.add(c);
			else 
			if(!q.contains(c)&&c=='F'&&!q.isEmpty())
				q.add(c);
		}
		
	if(q.size()==2&&q.get(0)=='C') {
		
		System.out.println("Yes");}
	else {
		System.out.println("No");}	
	}		
}

Measured memory_bytes: 23252
#include<cstdio>

int a, b; char op;

int main(void){
	while(1){
		scanf("%d %c %d", &a, &op, &b);
		if( op == '?' ) break;

		int ans;
		if( op == '+' ) ans = a + b;
		else if( op == '-' ) ans = a - b;
		else if( op == '*' ) ans = a * b;
		else if( op == '/' ) ans = a / b;

		printf("%d\n", ans);
	}

	return 0;
}

Measured memory_bytes: 2592
#include <bits/stdc++.h> //C++の標準ライブラリを一行で一括でインクルードする
#include <math.h> //数学関数と数学定数を利用する
#define rep(i,n) for (int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;
template<class T> void chmax(T &a,T b) { if (a<b) a=b;}
template<class T> void chmin(T &a,T b) { if (a>b) a=b;}


int main(){
  int n,m; cin >> n >> m;
  vector<int> a(n),v(n+1);
  map<int,int> mp;
  
  rep(i,n) cin >> a[i];
  rep(i,n){
    v[i+1] = (a[i] + v[i])%m;
  }
  
  ll ans = 0;
  rep(i,n+1){
    ans += mp[v[i]];
    mp[v[i]]++;
  }
  
  cout << ans << endl;
  
  
  return 0;
}

Measured memory_bytes: 3968
#ifdef xay5420
#define D(...) fprintf(stderr,__VA_ARGS__)
#else
#define D(...) ((void)0)
#define NDEBUG
#endif
#include<bits/stdc++.h>
#define pop64 __builtin_popcountll
#define ctz64 __builtin_ctzll
#define SZ(x) ((int)(x).size())
#define rep(i,a,b) for(int i=(a);i<=(b);++i)
using namespace std;
typedef long long LL;
const int N=55;
int T,n,f1[N],f2[N];
LL G1[N],G2[N];
void dfs1(int k1,int k2){
	f1[k1]=k2;
	for(LL i=G1[k1];i;i&=i-1){
		int j=ctz64(i);
		if(j!=k2){
			dfs1(j,k1);
		}
	}
}
void dfs2(int k1,int k2){
	f2[k1]=k2;
	for(LL i=G2[k1];i;i&=i-1){
		int j=ctz64(i);
		if(j!=k2){
			dfs2(j,k1);
		}
	}
}
LL H[N];
int deg[N];
int sol(int rt){
	/*rep(i,1,n)D("%d ",G1[i]);
	D("\n");*/
	dfs1(rt,0),dfs2(rt,0);
	rep(i,1,n)if(f1[i]==f2[i])if(f1[f1[i]]!=f2[f2[i]])return n+1;
	auto chk=[&](int k1){
		return f1[k1]!=f2[k1];
	};
	rep(i,1,n)H[i]=deg[i]=0;
	int tot=0;
	rep(i,1,n)if(chk(i)){
		if(chk(f1[i])){
			H[i]|=1LL<<f1[i],++deg[f1[i]];
		}
		++tot;
	}
	rep(i,1,n)if(chk(i)){
		if(chk(f2[i])){
			if(~H[f2[i]]>>i&1){
				H[f2[i]]|=1LL<<i,++deg[i];
			}
		}
	}
	static int q[N];
	int he=0,ta=0;
	rep(i,1,n)if(chk(i)&&!deg[i])q[++ta]=i;
	while(he!=ta){
		int k1=q[++he];
		for(LL i=H[k1];i;i&=i-1){
			int j=ctz64(i);
			if(!--deg[j]){
				q[++ta]=j;
			}
		}
	}
	if(ta==tot)return tot+1;
	else return D("bad\n"),n+1;
}
int main(){
#ifdef xay5421
	freopen("a.in","r",stdin);
#endif
	scanf("%d",&T);
	rep(_,1,T){
		//D("now %d\n",_);
		scanf("%d",&n);
		int ans=n+1;
		memset(G1,0,sizeof(G1));
		memset(G2,0,sizeof(G2));
		rep(i,2,n){
			int k1,k2;scanf("%d%d",&k1,&k2);
			G1[k1]|=1LL<<k2;
			G1[k2]|=1LL<<k1;
		}
		rep(i,2,n){
			int k1,k2;scanf("%d%d",&k1,&k2);
			G2[k1]|=1LL<<k2;
			G2[k2]|=1LL<<k1;
		}
		if(!memcmp(G1+1,G2+1,sizeof(G1[0])*n)){
			puts("0");
			continue;
		}
		rep(k1,1,n)if((G1[k1]&(G1[k1]-1))==0){
			int k2=ctz64(G1[k1]);
			G1[k1]=0,G1[k2]^=1LL<<k1;
			rep(i,1,n)if(i!=k1&&i!=k2){
				G1[k1]=1LL<<i;
				G1[i]^=1LL<<k1;
				//D(">>> %d %d %d\n",k1,i,sol(k1));
				ans=min(ans,sol(k1));
				G1[k1]=0;
				G1[i]^=1LL<<k1;
			}
			G1[k1]^=1LL<<k2,G1[k2]^=1LL<<k1;
		}
		printf("%d\n",ans>n?-1:ans);
	}
	return 0;
}

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

void solve() {
    string s, t;
    cin >> s >> t;

    if (s == t.substr(0, s.size())) {
        printf("Yes\n");
    } else {
        printf("No\n");
    }

}

int main(){
    solve();

	return 0;
}


Measured memory_bytes: 3628
while True:
    n, x = map(int, input().split())
    if n == 0 and x == 0:
        break
    else:
        count = 0
        for i in range(1, n+1):
            for j in range(i+1, n+1):
                    for k in range(j+1, n+1):
                        if i+j+k == x:
                            count += 1
        print(count)


Measured memory_bytes: 5592
#include <stdio.h>
#include <iostream>
#include <sstream>
#include <algorithm>
#include <functional>
#include <queue>
#define FOR(x, z, y) for(int x = (z); y; x++)
#define rep(x, y) for(int x = 0; x < (y); x++)
#define all(x) x.begin(), x.end()
#define len(x) (sizeof(x) / sizeof(x[0]))
#define split_str(str, sp_word) istringstream stream(str); string res; FOR(cnt, 0, getline(stream,res,sp_word))
#define scanln(x) fgets(x, sizeof x, stdin)
#define down_queue(x) priority_queue<x>
#define up_queue(x) priority_queue<x, vector<x>, greater<x>>
#define i_str(x) atoi(x.c_str())
typedef long long ll;
using namespace std;

int main(){
  vector<string> S;

  string str;
  getline(cin,str);
  split_str(str,' '){
    S.push_back(res);
  }

  char end_word = S[0].back();

  FOR(i,1,i <= 2){
    if(S[i].front() != end_word){
      puts("NO");
      return 0;
    }
    end_word = S[i].back();
  }
  puts("YES");
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define  LL long long
using namespace std;
const int MN=INT_MAX/2;
const int M=10e5;
LL sum[M<<1];
int n;
LL ans;
LL max(LL a,LL b)
{
	if(a<b)return b;
	else return a;
}
LL min(LL a,LL b)
{
	if(a<b)return a;
	else return b;
}
LL cacu(LL a,LL b,LL c,LL d)
{
	LL ma,mi;
	if(a<=b)ma=b,mi=a;
	else ma=a,mi=b;
	ma=max(max(b,c),max(ma,d));
	mi=min(min(b,c),min(mi,d));
	return ma-mi;
}
void judge(int k)
{
	LL maxt,mint;
	LL maxr,minr,minl,maxl;
	maxr=maxl=MN/2;
	minr=minl=-MN/2;
	int l,r,mid;
	l=1,r=k;
	while(l<r)
	{
		mid=(l+r)/2;
		mint=min(sum[mid],sum[k]-sum[mid]);
		maxt=sum[k]-mint;
		if(maxt-mint<maxl-minl)maxl=maxt,minl=mint;
		if(mint==maxt)break;
		else if(sum[k]-sum[mid]<sum[mid])r=mid;
		else l=mid+1;
	}
	
	l=k+1,r=n;
	while(l<r)
	{
		mid=(l+r)/2;
		mint=min(sum[mid]-sum[k],sum[n]-sum[mid]);
		maxt=sum[n]-sum[k]-mint;
		if(maxt-mint<maxr-minr)maxr=maxt,minr=mint;
		if(mint==maxt)break;
		else if(sum[n]-sum[mid]<sum[mid]-sum[k])r=mid;
		else l=mid+1;
	}
   //cout<<maxr<<" "<<maxr<<" "<<minl<<" "<<minr<<endl; 
	ans=min(ans,cacu(maxr,maxl,minl,minr));
}
int main()
{
	LL t;
	while(cin>>n)
	{
		sum[0]=0;
		for(int i=1;i<=n;++i)
		{
			scanf("%lld",&t);
			sum[i]=sum[i-1]+t;
		}
		int k=2;
		ans=MN;
		while(k<=n-2)
		{
			judge(k);
			k++;
		}
		cout<<ans<<endl;
	}
}

Measured memory_bytes: 1792
#include <stdio.h>

int main()
{
	int N, M, C;
	scanf("%d %d %d", &N, &M, &C);

	int res = 0;

	int B[20];
	for(int m=0; m<M; m++){
		scanf("%d", B+m);
	}

	for(int n=0; n<N; n++){
		int score = 0;
		for(int m=0; m<M; m++){
			int a;
			scanf("%d", &a);
			score += a * B[m];
		}
		if(score + C > 0){
			res ++;
		}
	}

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


Measured memory_bytes: 128
#include<iostream>
using namespace std;
int main()
{
 int H,A;
  cin>>H>>A;
  int arr[A];
  int i,sum=0;
  for(i=0;i<A;i++)
  {
    cin>>arr[i];
    sum=sum+arr[i];
  }
  if(sum<H)
    cout<<"No";
  else
    cout<<"Yes";
  return 0;
}

Measured memory_bytes: 640
<?php

while ($str = trim(fgets(STDIN))) {
    $line1 = explode(" ", $str);
    $n = $line1[0];
    $m = $line1[1];
    if ($n == 0 && $m == 0) {
        break;
    }

    $str = trim(fgets(STDIN));
    $line2 = explode(" ", $str);
    $ans = 0;
    for ($i=0; $i < $n; $i++) {
        for ($j=$i+1; $j < $n; $j++) {
            $t = (int)$line2[$i] + (int)$line2[$j];
            if ($t >= $ans && $t <= $m) {
                $ans = $t;
            }
        }
    }

    if ($ans == 0) {
        echo "NONE" . "\n";
        continue;
    }
    echo $ans . "\n";
}


Measured memory_bytes: 9380
#include <bits/stdc++.h>
using namespace std;
int main(){
	int a, b, c;
	cin>>a>>b>>c;
	if((a < c && c < b) || (a > c && c > b)){
		cout<<"Yes"<<endl;
	}
	else{
		cout<<"No"<<endl;
	}	
	return 0;
}


Measured memory_bytes: 256
// -*- coding:utf-8-unix -*-

use proconio::input;

fn main() {
    input! {
        s: String,
        t: String
    }

    let s = s.chars();
    let t = t.chars();

    let iter = s.zip(t);

    let res = iter.filter(|(si, ti)| si != ti).count();

    println!("{}", res);
}

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

const int MAX = 45000;
int main() {
	int X;
	cin >> X;
	int max = MAX;
	for (int min = 0, mid = max >> 1;max - min > 1;mid = min + (max - min >> 1)) {
		if (mid * (mid + 1) >= X << 1) max = mid;
		else min = mid;
	}
	cout << max;
	return 0;
}
/*
31536000のコメント解説欄
ここテンプレで用意してるから、A問題とかだとこの先空欄の危険あり
また、コンテスト後に https://31536000.hatenablog.com/ で解説していると思うので、良かったら読んでねー

時間iまでには最大で1+2+...+i=i(i+1)/2まで移動できる
つまり(i-1)i/2 < X ≦ i(i+1)/2なるiを導出すれば良い
(i-1)i < 2X ≦ i(i+1)とすれば、O(logX)で求まる
*/

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ALL(x) x.begin(),x.end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define debug(v) cout<<#v<<":";for(auto x:v){cout<<x<<' ';}cout<<endl;
#define INF 1000000000
#define mod 1000000007
using ll=long long;
const ll LINF=1001002003004005006ll;
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};
// ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return true;}return false;}
template<class T>bool chmin(T &a,const T &b){if(b<a){a=b;return true;}return false;}

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(0);
    
    int n;cin>>n;
    // 圧縮?
    vector<string> s;
    rep(i,n){
        string t;cin>>t;
        stack<char> st;
        for(auto c:t){
            if(st.empty()){
                st.push(c);
                continue;
            }

            if(c==')' and st.top()=='('){
                st.pop();
            }else{
                st.push(c);
            }
        }
        if(st.empty()) continue;
        string y="";
        while(!st.empty()){
            y.push_back(st.top());
            st.pop();
        }
        reverse(ALL(y));
        s.push_back(y);
    }

    int cnt=0;
    stack<char> st;
    vector<bool> check(s.size(),false);
    rep(i,s.size()){
        if(s[i][0]=='('){
            rep(_,s[i].size()) st.push('(');
            check[i]=true;
        }
    }

    stack<char> rs;
    rep(i,s.size()){
        if(s[i].back()==')'){
            rep(_,s[i].size()) rs.push(')');
            check[i]=true;
        }
    }

    vector<pair<int,int>> dif;
    rep(i,s.size()){
        if(check[i]) continue;
        int p=0;
        for(auto c:s[i]){
            if(c==')')  p--;
            else        p++;
        }
        dif.push_back(make_pair(p,i));
    }

    sort(ALL(dif));reverse(ALL(dif));

    for(auto p:dif){
        int idx=p.second;
        for(auto c:s[idx]){
            if(c==')'){
                if(st.empty()){
                    cout<<"No"<<endl;
                    return 0;
                }  
                st.pop();
            }
            else{
                st.push(c);
            }
        }
    }
    if(st.size()==rs.size()) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    return 0;
}


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

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

#define FOR(i, n, m) for (ll(i) = (m); (i) < (n); ++(i))
#define REP(i, n) FOR(i, n, 0)
#define OF64 std::setprecision(10)

const ll MOD = 998244353;
const ll INF = (ll)1e15;

class BinaryIndexTree
{
public:
    BinaryIndexTree(int n)
        : mN(n)
    {
        mPow = 1;
        while (mPow < n)
            mPow <<= 1;
        node.resize(n + 1);
        REP(i, n + 1)
        {
            node[i] = 0;
        }
    }
    ~BinaryIndexTree()
    {
        node.resize(0);
    }

    //! 1-index get
    ll sum(int index)
    {
        ll sum = 0;
        for (int i = index; i > 0; i -= i & (-i))
            sum += node[i];
        return sum;
    }

    //! 1-index add
    void add(int index, ll value)
    {
        for (int i = index; i <= mN; i += i & (-i))
            node[i] += value;
    }

    int lowerBound(ll value)
    {
        if (value <= 0)
            return 0;
        int x = 0;
        for (int k = mPow; k > 0; k >>= 1)
        {
            if (x + k <= mN && node[x + k] < value)
            {
                value -= node[x + k];
                x += k;
            }
        }
        return x + 1;
    }

private:
    vector<ll> node;
    ll mN;
    ll mPow;
};

pll S[200005];
ll P[200005];
pll L[200005];
pll R[200005];

int main()
{
    ll N;
    cin >> N;
    vector<ll> y;
    REP(i, N)
    {
        cin >> S[i].first >> S[i].second;
        y.push_back(S[i].second);
    }

    sort(S, S + N, [](pll a, pll b) { return a.first < b.first; });
    sort(y.begin(), y.end());
    y.erase(unique(y.begin(), y.end()), y.end());

    P[0] = 1;
    REP(i, N)
    {
        P[i + 1] = (2LL * P[i]) % MOD;
    }

    BinaryIndexTree bitl(N + 5);
    REP(i, N)
    {
        ll yn = lower_bound(y.begin(), y.end(), S[i].second) - y.begin();
        yn++;
        ll down = bitl.sum(yn);
        L[i] = pll(i - down, down);
        bitl.add(yn, 1);
    }
    BinaryIndexTree bitr(N + 5);
    for (int i = N - 1; i >= 0; --i)
    {
        ll yn = lower_bound(y.begin(), y.end(), S[i].second) - y.begin();
        yn++;
        ll down = bitr.sum(yn);
        R[i] = pll(N - 1 - i - down, down);
        bitr.add(yn, 1);
    }

    ll ans = 0;

    REP(i, N)
    {
        ll p = P[N] - 1;
        {
            //! 四隅だけ
            ll t = 0;
            t += P[R[i].first] - 1;
            t += P[R[i].second] - 1;
            t += P[L[i].first] - 1;
            t += P[L[i].second] - 1;
            t %= MOD;
            p = (MOD + p - t) % MOD;
        }

        {
            //! 隣り合う二つだけ
            ll t = 0;
            t += (P[R[i].first] - 1) * (P[R[i].second] - 1);
            t += (P[R[i].second] - 1) * (P[L[i].second] - 1);
            t += (P[L[i].second] - 1) * (P[L[i].first] - 1);
            t += (P[L[i].first] - 1) * (P[R[i].first] - 1);
            t %= MOD;
            p = (MOD + p - t) % MOD;
        }
        ans += p;
        ans %= MOD;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 15984
// E - Sequence Decomposing
#include <bits/stdc++.h>

using namespace std;

int main(int argc, char *argv[])
{
	ios::sync_with_stdio(false); cin.tie(0);

	int n;
	cin >> n;
	multiset<int> s;
	for (int i = 0; i < n; i++) {
		int x;
		cin >> x;
		multiset<int>::iterator it = s.lower_bound(x);
		if (it != s.begin()) s.erase(--it);
		s.insert(x);
	}
	cout << s.size() << endl;

	return 0;
}


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

#define for_(i,a,b) for(int i=a;i<b;++i)
#define ALL(a) a.begin(),a.end()
#define INIT(a,b) memset(a,b,sizeof(a))
using lint = long long int;

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

    vector<lint> A(N);
    for_(i,0,N) cin >> A[i];

    lint ans = 0, prev = A[0];
    for_(i,1,N) {
        if (prev > A[i]) ans += prev - A[i];
        else prev = A[i];
    }

    cout << ans << endl;
}

Measured memory_bytes: 4836
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;

namespace C
{
    public class Program
    {
        static void Main(string[] args)
        {
            var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);
            Solve();
            Console.Out.Flush();
        }

        public static void Solve()
        {
            var NMK = Console.ReadLine().Trim().Split(' ').Select(long.Parse).ToArray();
            var N = NMK[0];
            var M = NMK[1];
            var K = NMK[2];
            var A = Console.ReadLine().Trim().Split(' ').Select(long.Parse).ToArray();
            var B = Console.ReadLine().Trim().Split(' ').Select(long.Parse).ToArray();
            var aggA = CumulativeSum(A).ToArray();
            var aggB = CumulativeSum(B).ToArray();
            var answer = 0L;
            var j = M;
            for (var i = 0; i <= N; i++)
            {
                if (aggA[i] > K) break;
                while (aggB[j] > K - aggA[i]) j--;
                answer = Math.Max(answer, i + j);
            }

            Console.WriteLine(answer);
        }

        public static IEnumerable<long> CumulativeSum(IEnumerable<long> items)
        {
            var arr = items.ToArray();
            var ret = new long[arr.Length + 1];
            for (var i = 0; i < arr.Length; i++) ret[i + 1] = arr[i] + ret[i];
            return ret;
        }
    }
}


Measured memory_bytes: 79744
#include<bits/stdc++.h>
#define rep(i,a,b) for(register int i=a;i<=b;++i)
#define rpd(i,a,b) for(register int i=a;i>=b;--i)
#define rep1(i,x) for(register int i=head[x];i;i=nxt[i])
typedef long long ll;
inline int read() {
                                 int x=0, tmp=1;
                               char ch=getchar();
                            //233333333333333333333333
                          while( (ch<'0') || (ch>'9') ){
                         if(ch=='-')tmp=-1; ch=getchar();}
                          while( (ch>='0')&&(ch<='9') ){
                            x=x*10+ch-'0';ch=getchar();
                               }//233333333333333
                                 return (x*tmp);

}
using namespace std;
int main(){
    double n;
	cin>>n;
    int pos=(n+1)/2;
    printf("%.10lf",(double)pos/n);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define endl "\n"
using namespace std;

int main()
{
    ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
    
    string s, t;
    cin >> s >> t;
    int l = s.length(), cnt = 0;
    for (int i = 0; i < l; i++)
    {
        if (s[i] != t[i])
            ++cnt;
    }
    cout << cnt;
    
    return 0;
}

Measured memory_bytes: 3760
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"

using namespace std;

const long long int MOD = 1000000007;
const long double EPS = 1e-8;

long long int N, M, K, H, W, L, R;

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

	cin >> N >> M >> K;
	vector<vector<int>>stock(M, vector<int>(N));
	for (int i = 0; i < M; i++) {
		for (int j = 0; j < N; j++) {
			cin >> stock[i][j];
		}
	}
	for (int i = 0; i < M - 1; i++) {
		vector<int>dp(K + 1, K);
		for (int j = 0; j < K; j++) {
			for (int k = 0; k < N; k++) {
				if (j + stock[i][k] > K) continue;
				dp[j + stock[i][k]] = max(dp[j + stock[i][k]], dp[j] + stock[i + 1][k] - stock[i][k]);
			}
		}
		K = dp[K];
	}
	cout << K << endl;
	return 0;
}


Measured memory_bytes: 3180
// Try AtCoder
// author: Leonardone @ NEETSDKASU

fn main() {
    let mut stdin = String::new();
    std::io::Read::read_to_string(
        &mut std::io::stdin(),
        &mut stdin).unwrap();
    let mut stdin = stdin.split_whitespace();
    let mut get = || stdin.next().unwrap();
    macro_rules! get {
        ($t:ty) => (get().parse::<$t>().unwrap());
        () => (get!(i64));
    }
    
    let n = get!();
    let l = get!();
    let mut orig = 0;
    for i in 1 .. n+1 {
        orig += l + i - 1;
    }
    
    let mut ans = (orig, std::i64::MAX);
    for i in 1 .. n+1 {
        let mut sum = 0;
        for j in 1 .. n+1 {
            if i == j {
                continue;
            }
            sum += l + j - 1;
        }
        let diff = (orig - sum).abs();
        if diff < ans.1 {
            ans = (sum, diff);
        }
    }
    
    println!("{}", ans.0);
}

Measured memory_bytes: 4352
use std::io::*;
use std::str::*;

fn read<T: FromStr>() -> Option<T> {
    let stdin = stdin();
    let s = stdin
        .bytes()
        .map(|c| c.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect::<String>();
    s.parse::<T>().ok()
}


fn main() {
    let mut n: usize = read().unwrap();
    let k: usize = read().unwrap();
    let mut count = 0;
    if n > 0 {
        while n > 0 {
            n = n / k;
            count += 1;
        }
    }
    println!("{}", count);
}

Measured memory_bytes: 4352
#include<stdio.h>
#include<math.h>
int main(){
    int n, t, mm, d=0, a=1, i;
    scanf("%d%d", &n, &t); //input the number of test and target number
    for(i = 0;i < n ; i++){
        scanf("%d", &mm);
        if(mm<=t){
            d = d+mm;
            if(d<=t)
            a++;
        }
    }
    printf("%d\n", a);
    return 0;
}


Measured memory_bytes: 128
import java.util.Scanner;
 class Main{
   public static void main(String[] args) {
     Scanner scanner = new Scanner(System.in);
     int N = scanner.nextInt();
     int K = scanner.nextInt();
     int X = 0;
     int[] numbers = new int[N];
     
     for(int i=0;i<N;i++) {
      numbers[i] = scanner.nextInt();
       if(numbers[i]>=K) {
         X++;
       }
     }
     System.out.println(X);
   }
 }

Measured memory_bytes: 46656
#include<bits/stdc++.h>
#define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define ll long long
#define pb push_back 
#define max(a,b) (a>b?a:b)
#define min(a,b) (a<b?a:b)

using namespace std;

const int mod = 1e9 + 7;

int power(int x,int y)
{
    if(y == 0)
        return 1;
    int a = power(x,y/2);
    a = (1LL * a *a)%mod;
    if(y%2)
        a = (1LL * a * x)%mod;
    return a;
}

const int N = 1000000;
int smallest_prime[1000001];

void Sieve()
{
    smallest_prime[1] = 1;
    for(int i = 1; i<= N;i++)
        smallest_prime[i] = i;
    for(int i = 2;i <= sqrt(N);i++)
    {
        if(smallest_prime[i] == i)
        {
            for(int j = 2; j*i <= N; j++)
                smallest_prime[i*j] = min(smallest_prime[i*j],i);
        }

    }
}

int main()
{
    IOS;
    int n;
    cin >> n;
    int arr[n+1];
    Sieve();
    int sum = 0;
    map<int,int>lcm;
    vector<map<int,int>>vals;
    for(int i = 1; i<=n;i++)
    {
        cin >> arr[i];
        map<int,int>factors;
        int x = arr[i];
        while(x > 1)
        {
            factors[smallest_prime[x]]++;
            x/=smallest_prime[x];
        }
        for(auto it:factors)
            lcm[it.first] = max(lcm[it.first],it.second);
    }  
    int prod = 1;
    for(auto it:lcm)
        prod = (1LL * prod * power(it.first,it.second))%mod;
    for(int i = 1; i<=n;i++)
    {
        int new_prod = prod;
        new_prod = (1LL * new_prod * power(arr[i],mod-2))%mod;
        sum += new_prod;
        sum %= mod;
    }
    cout << sum;
}

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

typedef long long ll;
ll MOD = 1000000007;

int main()
{
    int N, tmp;
    cin >> N;
    vector <int> a(N, 0), b(N, 0);
    for (int i = 0; i < N; i++) {
        cin >> tmp;
        a[i] = tmp;
        b[i] = tmp;
    }
    sort(b.begin(), b.end());

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


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

int main(){
    int n,m;
    cin >> n >> m;
    int city[n];
    int i,j;
    int a[m],b[m];
    for(i=0;i<n;i++)
        city[i] =0;
    
    for(i=0;i<m;i++)
        cin >> a[i] >> b[i];
    
    for(i=0;i<m;i++){
        city[a[i]-1] +=1;
        city[b[i]-1] +=1;
    }
    
    for(i=0;i<n;i++)
        cout << city[i] << endl;
}

Measured memory_bytes: 3540
//simplecal.cpp
#include <bits/stdc++.h>
using namespace std;
int main (){
  char op;
  int a, b;
  cin >> a >> op >> b;
  while (op != '?') {
    switch (op) { 
      case '+': cout << a + b << endl; break;
      case '-': cout << a - b << endl; break;
      case '*': cout << a * b << endl; break;
      case '/': cout << a / b << endl; break;
    };
  cin >> a >> op >> b;
  };
}



Measured memory_bytes: 3076
import core.bitop, std.algorithm, std.ascii, std.bigint, std.conv,
    std.functional, std.math, std.numeric, std.range, std.stdio, std.string,
    std.random, std.typecons, std.container;

ulong MAX = 100_100, MOD = 1_000_000_007, INF = 1_000_000_000_000;
alias sread = () => readln.chomp();
alias lread(T = long) = () => readln.chomp.to!(T);
alias aryread(T = long) = () => readln.split.to!(T[]);
alias Pair = Tuple!(long, "a", long, "b");
alias PQueue(T, alias less = "a<b") = BinaryHeap!(Array!T, less);

void main()
{
    auto n = lread();
    long check = true;
    long c_t, c_x, c_y;
    foreach (_; iota(n))
    {
        long t, x, y;
        scan(t, x, y);
        auto manh = abs(c_x - x) + abs(c_y - y);
        long t_dif = t - c_t;
        check = check && (t_dif >= manh) && ((t_dif - manh) % 2 == 0);
        c_t = t;
        c_x = x;
        c_y = y;
    }
    if (check)
        writeln("Yes");
    else
        writeln("No");
}

void scan(TList...)(ref TList Args)
{
    auto line = readln.split();
    foreach (i, T; TList)
    {
        T val = line[i].to!(T);
        Args[i] = val;
    }
}


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

using namespace std;
using ll = long long;

#define int ll

#define rep(i, a) for (int i = 0; (i) < (int) (a); (i)++)
#define reps(i, a, b) for (int i = (int) (a); (i) < (int) (b); (i)++)
#define rrep(i, a) for (int i = (int) a-1; (i) >= 0; (i)--)
#define rreps(i, a, b) for (int i = (int) (a)-1; (i) >= (int) (b); (i)--)
#define MP(a, b) make_pair((a), (b))
#define PB(a) push_back((a))
#define all(v) (v).begin(), (v).end()
#define PERM(v) next_permutation(all(v))
#define UNIQUE(v) sort(all(v));(v).erase(unique(all(v)), v.end())
#define CIN(type, x) type x;cin >> x
#define TRUE__  "Yes"
#define FALSE__ "No"
#define PRINT(f) if((f)){cout << (TRUE__) << endl;}else{cout << FALSE__ << endl;}
#define RS(N) resize(N)
#define CINV(v, N) do {\
	v.RS(N);\
	rep(i, N) cin >> v[i];\
} while (0);
#define RCINV(v, N) do {\
	v.RS(N);\
	rrep(i, N) cin >> v[i];\
} while (0);

#define MOD 1000000007

template<class T>
inline T GET() {
	T x;
	cin >> x;
	return x;
}

void init();
void solve();

signed main()
{
	init();
	solve();
}


void init()
{
	double a, b;
	cin >> a >> b;
	cout << fixed << setprecision(12) << a / b << endl;
}

void solve()
{
}




Measured memory_bytes: 256
import numpy as np

n, ww = map(int, input().split())

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

dp = np.full(n*10**3+1, np.inf)
dp[0] = 0

for w, v in wv:
    dp[v:] = np.minimum(dp[v:], dp[:-v]+w)

for i in range(n*10**3+1)[::-1]:
    if dp[i] <= ww:
        print(i)
        exit()

Measured memory_bytes: 14820
//#include<bits/stdc++.h>
#include<iostream>
#include<stdio.h>
#include<algorithm>
#include<cmath>
#include<cstring>
//#include<cstdlib>
#include<map>
#include<set>
#include<vector>
#include<stack>
#include<queue>
#include<iterator>
#include<deque>

using namespace std;
#define PI          acos(-1)
#define INF         10000000000000000ll
#define sc(n)       scanf("%d",&n);
#define lsc(n)      scanf("%lld",&n);
#define dsc(n)      scanf("%lf",&n);
#define LL          long long int
#define UI          unsigned int
#define ULL         unsigned long long int
#define DB          double
#define pii         pair<int,int>
#define PB          push_back
#define MP          make_pair
#define M(mx,a)     mx=max(mx,a)
#define IT          ::iterator
#define all(a)      a.begin(),a.end()
#define mems(a,b)   memset(a,b,sizeof(a))
#define ARC(n)      for(i=0;i<n;i++)
#define ASC(n,aa)   for(i=0;i<n;i++)scanf("%lld",&aa[i]);
#define PNT(n,aa)   for(i=0;i<n;i++)printf("%lld ",aa[i]);
#define mod         1000000007
#define NUM         5009
#define NUM2        1000000000


int a[NUM],aa[NUM];
LL neww[NUM][NUM],nxt[NUM][NUM];


int main()
{
    int T=1,QQ=0;
    //cin >> T ;
    while(T--)
    {
        int n,i,j ;
        LL aaa,bbb,k ;
        cin >> n >> aaa >> bbb ;
        for(i=1; i<=n; i++)
        {
            sc(a[i]);
            aa[a[i]]=i;
        }
        for(i=0; i<=n; i++)
        {
            for(int j=0; j<=n; j++)
            {
                neww[i][j]=nxt[i][j]=INF;
            }
        }
        for(i=0; i<=n; i++)
            nxt[0][i]=neww[0][i]=0ll;
        for(i=1; i<=n; i++)
        {
            for(j=0; j<=n; j++)
            {
                if(j==aa[i])
                {
                    neww[i][j]=min(neww[i][j],nxt[i-1][j-1]);
                }
                if(j<aa[i])
                    k=nxt[i-1][j]+bbb;
                else
                    k=nxt[i-1][j]+aaa;
                neww[i][j]=min(neww[i][j],k);
            }
            nxt[i][0]=neww[i][0];
            for(j=1; j<=n; j++)
                nxt[i][j]=min(nxt[i][j-1],neww[i][j]);
        }
        cout << nxt[n][n] ;
    }
}


Measured memory_bytes: 392064
from math import sqrt, cos, radians
A, B, H, M = map(int, input().split())

theta_h = H / 12 * 360 + M / 60 * 30
theta_m = M / 60 * 360
theta = abs(theta_h - theta_m)
theta = min(360 - theta, theta)

ans = A**2 + B**2 - 2 * A * B * cos(radians(theta))

print(sqrt(ans))

Measured memory_bytes: 62652
/*input
3
2 3
3 1
1 2
*/

#include <bits/stdc++.h>
using namespace std;

int main() {
    int n;
    cin >> n;
    vector<vector<int>> a(n);
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < n-1; j++) {
            int k;
            cin >> k;
            a.at(i).push_back(k);
        }
    }
    vector<int> game(n);
    vector<int> day(n);
    int cnt = 0;
    int pre = 0;
    int M = n*(n-1)/2;
    bool ok = true;
    while (cnt < M) {
        for (int i = 0; i < n; i++) {
            if (cnt == M) {
                break;
            }
            if (game[i] != n-1) {
                int opp = a.at(i).at(game.at(i))-1;
                int opp_opp = a.at(opp).at(game.at(opp))-1;
                if (opp_opp == i) {
                    cnt += 1;
                    game.at(i) += 1;
                    game.at(opp) += 1;
                    int mday = max(day.at(i)+1, day.at(opp)+1);
                    day.at(i) = mday;
                    day.at(opp) = mday;
                }
            }
        }
        if (cnt == pre) {
            ok = false;
            break;
        }
        else {
            pre = cnt;
        }
    }
    if (ok) {
        int mday = 0;
        for (int i: day) {
            mday = max(mday, i);
        }
        cout << mday << endl;
    }
    else {
        cout << -1 << endl;
    }
}

Measured memory_bytes: 4352
import java.util.*;


public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        
        String s = sc.next();
        int n = s.length();
		
		long ans = 0L;
		for (int i=0; i<Math.pow(2,n-1); i++) {
			StringBuilder sb = new StringBuilder(s);
			for (int j=n-1; j>=0; j--) {
				if ((1&i>>j) == 1) {
					sb.insert(j+1,"+");
				}
			}
			
			String[] ar = sb.toString().split("\\+",0);
			for (int j=0; j<ar.length; j++) {
				ans += Long.parseLong(ar[j]);
			}
		}
		
		System.out.println(ans);
	}
}


Measured memory_bytes: 37024
using System;

class MainClass
    {
        public static void Main(string[] args)
        {
            var N = int.Parse(Console.ReadLine());
            var K = int.Parse(Console.ReadLine());

            var ans = 1;
            for (int i = 0; i < N; i++)
            {
                if (ans > K)
                    ans += K;
                else
                    ans *= 2;
            }

            Console.WriteLine(ans);
        }
    }

Measured memory_bytes: 13140
A, B=list(map(int,input().split()))

a = int(A*12.5)
b = B*10
ans = -1

if a < b:
    for i in range(a, b+2):
        if (int(i*0.1) == B) and (int(i*0.08) == A):
            if ans == -1:
                ans = i

else:
    for i in range(b, a+2):
        if (int(i*0.1) == B) and (int(i*0.08) == A):
            if ans == -1:
                ans = i

print(ans)


Measured memory_bytes: 3064
import sys

def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split())

r,D,x = LI()
temp = x
for _ in range(10):
   temp = r * temp - D
   print(temp)

Measured memory_bytes: 9076
#include <bits/stdc++.h>
using namespace std;
int main(void){
    long long int n,k,i=0,j,c=0,p,m=0,max=0,h[100000],dp[100000],saisyo=100000000;
    string s;
    cin >> n >> k;
    for(i=0;i<n;i++)
    {
        cin >> h[i];
    }
    for(i=1;i<=k;i++)
    {
        dp[i]=abs(h[0]-h[i]);
    }
    for(i=k;i<n;i++)
    {   
        for(j=1;j<=k;j++)
        {
            if(saisyo>abs(h[i]-h[i-j])+dp[i-j])
            {
                saisyo=abs(h[i]-h[i-j])+dp[i-j];
            }
        }
        dp[i]=saisyo;
        saisyo=1000000000;
    }
    cout << dp[n-1] << endl;
    return 0;

}


Measured memory_bytes: 5108
#include<iostream>
#include<iomanip>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
#define MOD 1000000007LL
using namespace std;
int f[105][4][4],ans,n;
string s[3];
int main()
{	cin>>n;
	cin>>s[1];s[1]=' '+s[1];
	cin>>s[2];s[2]=' '+s[2];
	if(s[1][1]==s[2][1])f[1][1][1]=f[1][2][2]=f[1][3][3]=1;
	else f[1][1][2]=f[1][2][1]=f[1][1][3]=f[1][3][1]=f[1][2][3]=f[1][3][2]=1;
	for(int i=2;i<=n;i++)
	{	if(s[1][i]==s[2][i])
		{	if(s[1][i-1]==s[2][i-1])
			{	f[i][1][1]=(f[i][1][1]+f[i-1][2][2])%MOD;	
				f[i][1][1]=(f[i][1][1]+f[i-1][3][3])%MOD;
				f[i][2][2]=(f[i][2][2]+f[i-1][1][1])%MOD;	
				f[i][2][2]=(f[i][2][2]+f[i-1][3][3])%MOD;	
				f[i][3][3]=(f[i][3][3]+f[i-1][1][1])%MOD;	
				f[i][3][3]=(f[i][3][3]+f[i-1][2][2])%MOD;
			}	
			else
			{	f[i][1][1]=(f[i][1][1]+f[i-1][2][3])%MOD;
				f[i][1][1]=(f[i][1][1]+f[i-1][3][2])%MOD;
				f[i][2][2]=(f[i][2][2]+f[i-1][1][3])%MOD;
				f[i][2][2]=(f[i][2][2]+f[i-1][3][1])%MOD;
				f[i][3][3]=(f[i][3][3]+f[i-1][1][2])%MOD;
				f[i][3][3]=(f[i][3][3]+f[i-1][2][1])%MOD;
			}
		}	
		else 
		{	if(s[1][i]==s[1][i-1])
			{	memcpy(f[i],f[i-1],sizeof(f[i-1]));
			}
			else if(s[1][i-1]==s[2][i-1])
			{	f[i][2][3]=(f[i][2][3]+f[i-1][1][1])%MOD;
				f[i][3][2]=(f[i][3][2]+f[i-1][1][1])%MOD;
				f[i][1][3]=(f[i][1][3]+f[i-1][2][2])%MOD;
				f[i][3][1]=(f[i][3][1]+f[i-1][2][2])%MOD;
				f[i][1][2]=(f[i][1][2]+f[i-1][3][3])%MOD;
				f[i][2][1]=(f[i][2][1]+f[i-1][3][3])%MOD;
			}
			else 
			{	f[i][3][1]=(f[i][3][1]+f[i-1][1][2])%MOD;
				f[i][2][3]=(f[i][2][3]+f[i-1][1][2])%MOD;
				f[i][2][1]=(f[i][2][1]+f[i-1][1][2])%MOD;
				
				f[i][1][3]=(f[i][1][3]+f[i-1][2][1])%MOD;
				f[i][3][2]=(f[i][3][2]+f[i-1][2][1])%MOD;
				f[i][1][2]=(f[i][1][2]+f[i-1][2][1])%MOD;
				
				f[i][1][2]=(f[i][1][2]+f[i-1][2][3])%MOD;
				f[i][3][1]=(f[i][3][1]+f[i-1][2][3])%MOD;
				f[i][3][2]=(f[i][3][2]+f[i-1][2][3])%MOD;
				
				f[i][2][1]=(f[i][2][1]+f[i-1][3][2])%MOD;
				f[i][1][3]=(f[i][1][3]+f[i-1][3][2])%MOD;
				f[i][2][3]=(f[i][2][3]+f[i-1][3][2])%MOD;
				
				f[i][2][1]=(f[i][2][1]+f[i-1][1][3])%MOD;
				f[i][3][1]=(f[i][3][1]+f[i-1][1][3])%MOD;
				f[i][3][2]=(f[i][3][2]+f[i-1][1][3])%MOD;
				
				f[i][1][2]=(f[i][1][2]+f[i-1][3][1])%MOD;
				f[i][1][3]=(f[i][1][3]+f[i-1][3][1])%MOD;
				f[i][2][3]=(f[i][2][3]+f[i-1][3][1])%MOD;
			}
		}
	} 
	for(int i=1;i<=3;i++)
		for(int j=1;j<=3;j++)
			ans=(ans+f[n][i][j])%MOD;
	printf("%d",ans);
}

Measured memory_bytes: 256
import sys
def input(): return sys.stdin.readline().strip()
def mapint(): return map(int, input().split())
sys.setrecursionlimit(10**9)

N, C, K = mapint()

Ts = [int(input()) for _ in range(N)]
Ts.sort()
last_cus = Ts[0]
cum = 1
bus = 0
for i in range(1, N):
    t = Ts[i]
    last_cus = min(last_cus, t)
    if t-last_cus>K:
        bus += 1
        cum = 0
        last_cus = t
    cum += 1
    if cum==C:
        bus += 1
        cum = 0
        last_cus = 10**18
if cum!=0:
    print(bus+1)
else:
    print(bus)

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

typedef long long ll;
typedef long double ld;

#define MOD 1000000007
#define all(x) (x).begin(),(x).end()
#define rep(i, n) for(int i = 0; i < (int)(n); i++)

ll gcd(ll a, ll b){return b ? gcd(b, a % b) : a;}

int main(){

    ll R;

    cin >> R;

    cout << (R < 1200 ? "ABC" : (R < 2800 ? "ARC" : "AGC")) << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <boost/range/irange.hpp>


using namespace std;
using namespace boost;
using uint = unsigned int;
using ll = long long int;
using ull = unsigned long long int;

enum ChairCondition {
    vacant, male, female
};

struct Range {
    uint start_index;
    uint end_index;
    ChairCondition start_condition;
    ChairCondition end_condition; // conditions[end_index]
    Range(uint _start_index, uint _end_index, ChairCondition _start_condition, ChairCondition _end_condition) :
            start_index(_start_index),
            end_index(_end_index),
            start_condition(_start_condition),
            end_condition(_end_condition) {}
};

ChairCondition cnv(const string &s);

ChairCondition cnv(const string &s) {
    if (s == "Vacant") {
        return ChairCondition::vacant;
    } else if (s == "Male") {
        return ChairCondition::male;
    } else {
        return ChairCondition::female;
    }
}

void split_range(Range & r) {
    uint query_index = (r.start_index + r.end_index) / 2;
    cout << query_index << endl;
    string s;
    cin >> s;
    ChairCondition c;
    if (s == "Vacant") {
        exit(0);
    } else if (s == "Male") {
        c = ChairCondition::male;
    } else {
        c = ChairCondition::female;
    }
    uint left_length{query_index - r.start_index + 1};
    if ((left_length % 2 == 0) != (r.start_condition == c)){
        r.start_index = query_index;
        r.start_condition = c;
    }else{
        r.end_index = query_index;
        r.end_condition = c;
    }
}

    int main() {
    uint N;
    cin >> N;
    cout << 0 << endl;
    string s;
    cin >> s;
    ChairCondition c;
    if (s == "Vacant") {
        exit(0);
    } else if (s == "Male") {
        c = ChairCondition::male;
    } else {
        c = ChairCondition::female;
    }
    Range r(0, N, c, c);
    for (auto i: irange((uint)0, (uint)20)) {
        split_range(r);
    }
    cout << "invalid finish" << endl;
    return 1;
}

Measured memory_bytes: 852
#include <bits/stdc++.h>
#include <atcoder/all>
#ifndef ONLINE_JUDGE
#define _GLIBCXX_DEBUG
#endif
using namespace std;
using namespace atcoder;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = s; i < (int)(n); i++)
#define Clear(a) a = decltype(a)()
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define vec vector
typedef long long ll;
typedef pair<ll,ll> P;
//const ll big=998244353;
const ll big=1000000007LL;
const ll INF=1e18;
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
ll max(ll x,ll y){
if(x>y)return x;
else return y;
}
ll min(ll x,ll y){
if(x<y)return x;
else return y;
}
ll expm(ll x,ll y){
    if(y==0)return 1;//0^0=1
    if(x==1||x==0)return x;
    if(y%2==1)return (expm(x,y-1)*x)%big;
    ll t=expm(x,y/2);
    return (t*t)%big;
}
ll exp(ll x,ll y){
    if(y==0)return 1;//0^0=1
    if(x==1||y==0)return x;
    if(y%2==1)return exp(x,y-1)*x;
    ll t=exp(x,y/2);
    return t*t;
}
ll inv(ll x){
    return expm(x,big-2);
}


int main(){
    ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    cout << fixed << setprecision(10);
    /*--------------------------------*/
  
  int n,q;cin >> n >> q;
  dsu d(n);
  rep(i,q){
    int t,u,v;cin >> t >> u >> v;
    if(t==0)d.merge(u,v);
    else cout << d.same(u,v) << endl;
  }
}

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

int main() {
    int N;
    int64_t x;
    cin >> N >> x;
    vector<int64_t> A(N);
    REP(i,N) cin >> A.at(i);
    int64_t ans = 0;
    if(A.at(0)>x){
        ans += A.at(0)-x;
        A.at(0) = x;
    }
    REP(i,N-1){
        if(A.at(i)+A.at(i+1)>x){
            ans += A.at(i+1)-(x-A.at(i));
            A.at(i+1) = x-A.at(i);
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1024
//============================================================================
// Name        : competitive_programing.cpp
// Author      : .Data_Nerd.
// Description : problem solving training
//============================================================================

#include <bits/stdc++.h>
#define Data_Nerd ios_base::sync_with_stdio(); cin.tie(0); cout.tie(0);
#define files freopen("input.txt","r",stdin); freopen("output.txt","w",stdout);
#define mod 1000000007
#define OO 0x3f3f3f3f
#define NIL -1
using namespace std;
typedef long long ll;

int n, k, arr[105];

bool memo[100005];


int main() {
	Data_Nerd

	scanf("%d%d", &n, &k);

	for(int i = 0; i < n; ++i)
		scanf("%d", &arr[i]);

	for(int i = 0; i <= k; ++i){
		if(!memo[i]){
			for(int j = 0; j < n; ++j){
				if(arr[j] + i <= k){
					memo[arr[j] + i] = true;
				}
			}
		}
	}

	memo[k] ? puts("First") : puts("Second");

	return 0;
}


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

int main(void){
    int N,L;
    cin >> N >> L;
    int ate,ans=0;
    if(L>0){
        ate = 0;
    }else if(N-1+L<0){
        ate = N-1;
    }else{
        ate = -1;
    }
    for (int i = 0; i < N; i++)
    {
        if(i != ate)
            ans += L + i;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>

using namespace std;

int main(){
    int num, n, miss = 0;
    int numbers[1000005];
    cin >>n;
    for(int i = 0; i < n; i++){
        cin >>num;

        if(numbers[num] == 0){
            numbers[num] = 1;
        }else{
            miss++;
        }

    }
    //cout << miss << endl;
    if(miss % 2==1){
        miss++;
    }
    //cout << numbers.size() << endl;
    int ans = n - miss;
    cout << ans << endl;

}

Measured memory_bytes: 2560
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>

using namespace std;
typedef long long ll;

int main()
{
	int n, c[4];
	cin >> n;
	for (int i = 0; i < 4; i++) {
		c[i] = 0;
	}
	string str;
	for (int i = 0; i < n; i++) {
		cin >> str;
		if (str == "AC") {
			c[0]++;
		}
		else if (str == "WA") {
			c[1]++;
		}
		else if (str == "TLE") {
			c[2]++;
		}
		else if (str == "RE") {
			c[3]++;
		}
	}
	cout << "AC x " << c[0] << endl;
	cout << "WA x " << c[1] << endl;
	cout << "TLE x " << c[2] << endl;
	cout << "RE x " << c[3] << endl;
	return 0;
}

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

using namespace std;

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)

int main(){
    const int ans[]={64,32,16,8,4,2,1};
    int n;cin>>n;
    REP(i,8){
        if(n>=ans[i]){
            cout<<ans[i]<<endl;
            break;
        }
    }
    return 0;
}

Measured memory_bytes: 256