akhauriyash/Code-Regression huggingface dataset:
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author Echizen
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskA solver = new TaskA();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskA {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int a, b, c;
            a = in.nextInt();
            b = in.nextInt();
            c = in.nextInt();
            if ((a * 100 + b * 10 + c) % 4 == 0) {
                out.println("YES");
            } else {
                out.println("NO");
            }
        }
    }
}



Measured memory_bytes: 23636
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define pb push_back
#define fi first
#define se second
const int N = 3e3+6;
const int mod = 1e9+7;
const ll inf = 1e18;
int a[N];
void solve(){
    int n;
    cin>>n;
    vector<int>v,w;
    for(int i=0;i<n;i++){
        int x;
        cin>>x;
        v.pb(x);
    }
    sort(v.begin(),v.end());
    if(n%2==0){
        ll p2 = 1;
        for(int i=1;i<n;i+=2){
            w.pb(i);
            w.pb(i);
            p2*=2;
            p2%=mod;
        }
        bool match = true;
        for(int i=0;i<n;i++){
            if(v[i]!=w[i])match  = false;
        }
        if(match)cout<<p2<<endl;
        else cout<<0<<endl;

    }
    else{

        ll p2 = 1;
        w.pb(0);
        for(int i=2;i<n;i+=2){
            w.pb(i);
            w.pb(i);
            p2*=2;
            p2%=mod;
        }
        bool match = true;
        for(int i=0;i<n;i++){
            if(v[i]!=w[i])match  = false;
        }
        if(match)cout<<p2<<endl;
        else cout<<0<<endl;
    }
}
int main(){
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    int t=1;
//    cin>>t;
    while(t--)solve();
    return 0;
}


Measured memory_bytes: 1400
def main():
    N, H = map(int, input().split())
    a = 0
    b = []
    for i in range(N):
        t = list(map(int, input().split()))
        a = max(a, t[0])
        b.append(t[1])
    b = sorted(b, reverse=True)
    # print(a)
    # print(b)
    i = 0
    while b[i] > a and H > 0:
        H -= b[i]
        i += 1
        if i >= N:
            break
    if H > 0:
        if H%a == 0:
            i += H//a
        else:
            i += H//a + 1
    print(i)

if __name__ == "__main__":
    main()


Measured memory_bytes: 8284
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i, c) for (int i = 0; i < (int)c; i++)
#define all(v) v.begin(), v.end()
using ll = long long;
using P = pair<int, int>;
//const int inf = 1e9; //1(1倍)e(指数)9(10^9)
//const ll MX = 1e18; //1(1倍)e(指数)18(10^18)
//const ll MOD = 1e9 + 7; //1000000007で割った余りを聞かれたら使う
//加算代入演算子は+=
//int 2^31 10^9まで
//intは10桁、long longは18桁、doubleは308桁、long double は4932桁
//10^10くらいまででdoubleは誤差が発生しちゃう。なるべく整数にすること
//doubleからlong longにキャストするときは、+0.5で切り捨ての誤差を調整
//__int128()で128bit対応の整数（多倍長整数）
//||は片方が成り立つとき
int main()
{
    int n;
    cin >> n;
    vector<P> seat(n);
    rep(i, n)
    {
        int a, b;
        cin >> a >> b;
        seat.at(i) = make_pair(a, b);
    }
    int ans = 0;
    rep(i, n)
    {
        if (seat.at(i).first != seat.at(i).second)
        {
            ans += (abs(seat.at(i).first - seat.at(i).second) + 1);
        }
        else
            ans++;
    }
    cout << ans << endl;
}

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

int main(){
    int w, h, n;
    cin >> w >> h >> n;
    int maxx = 0, maxy = 0;
    rep(i,n){
        int x, y, a;
        cin >> x >> y >> a;
        if(a == 1)      maxx = max(maxx, x);
        else if(a == 2) w = min(w, x);
        else if(a == 3) maxy = max(maxy, y);
        else            h = min(h,y);
    }
    if(maxx > w || maxy > h){
        cout << 0 << endl;;
    }else{
        cout << (w - maxx)*(h - maxy) << endl;
    }
}


Measured memory_bytes: 256
// ABC.cpp : このファイルには 'main' 関数が含まれています。プログラム実行の開始と終了がそこで行われます。
//

#include <iostream>
#include <vector>
#include <algorithm>
#include <math.h>
#define rep(i,n) for(int i = 0; i < n;i++)
#define repr(i, a, b) for (int i = a; i < b; i++)
#define PI 3.14159265358979323846264338327950L
using namespace std;
typedef long long ll;
typedef long double ld;

int main(){
	vector <int> x(5);
	int n = 0;
	rep(i,x.size()) {
		cin >> x.at(i);
	}
	rep(i,x.size()) {
		if (x.at(i) == 0) {
			n = i + 1;
			break;
		}
	}
	cout << n << endl;
}

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

using namespace std;

typedef long long ll;

const ll MOD = 1000000007;

const int dx[4] = {+1, 0, -1, 0};
const int dy[4] = {0, -1, 0, +1};

int main(){
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    int n; cin >> n;
    string a, b, c;
    cin >> a >> b >> c;
    int cnt = 0;
    for(int i=0;i<n;i++){
        if(a[i] == b[i] && b[i] == c[i] && c[i] == a[i]){
            cnt += 0;
        }else if(a[i] != b[i] && b[i] != c[i] && c[i] != a[i]){
            cnt += 2;
        }else{
            cnt += 1;
        }
    }
    cout << cnt << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using ll=long long;
using vi = vector<int>;
using Graph = vector<vi>;
using P = pair<int,int>;
const int MOD=(int)1e9+7;
const int INF=(int)1e9;
const ll LINF=(ll)1e18;

int main(){
    int n;
    cin >> n;
    vector<P> in(n);
    rep(i,n){
        int a,b;
        cin >> a >> b;
        in[i] = make_pair(a+b,a-b);
    }
    sort(in.begin(),in.end());
    int bl=in[0].second,br=in[0].first;
    //cout << bl << " " << br << endl;
    int cnt = 0;
    for(int i=1;i<n;i++){
        if(in[i].second<br){
            cnt++;
        }    else{
            bl = in[i].second;
            br = in[i].first;
        }
        //cout << bl << " " << br << endl;
    }
    cout << n - cnt << endl;
}

Measured memory_bytes: 1024
#include <stdio.h>
#include <cstdio>
#include <queue>
#include <set>
using namespace std;

int main(){
  
  char n[4];
  /* read input */
  scanf("%s", n);

  for(int i = 0; i < 3; i++){
    if(n[i] == '1'){
      n[i] = '9';
    }
    else if(n[i] == '9'){
      n[i] = '1';
    }
  }
  printf("%s", n);
  return 0;
}


Measured memory_bytes: 128
#include <algorithm>
#include <iostream>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <list>
#include <cmath>
#include <stack>
#include <string>
#include <cstring>
#include <numeric>
#include <iomanip>
#include <fstream>
using namespace std;
const long long inf=1e9+7;
const long long mod=1e9+7;
const int64_t CYCLES_PER_SEC=2800000000;
//
inline uint32_t Xor128(){
	static uint32_t x=123456789;
	static uint32_t y=362436069;
	static uint32_t z=521288629;
	static uint32_t w=88675123;
	uint32_t t=x^(x<<11);
	x=y;y=z;z=w;
	return w=(w^(w>>19))^(t^(t>>8));
}
struct Timer{
	int64_t start;
	Timer(){reset();}
	void reset(){start=getcycle();}
	void plus(double a){start-=(a*CYCLES_PER_SEC);}
	inline double get(){return (double)(getcycle()-start)/CYCLES_PER_SEC;}
	inline int64_t getcycle(){
		uint32_t low,high;
		__asm__ volatile ("rdtsc":"=a"(low),"=d"(high));
		return ((int64_t)low)|((int64_t)high<<32);
	}
};
int x,y,a,b,c;
vector<long long> p,q,r;
int main(){
	cin>>x>>y>>a>>b>>c;
	for(int i=0;i<a;i++){
		long long hoge;
		cin>>hoge;
		p.push_back(hoge);
	}
	for(int i=0;i<b;i++){
		long long hoge;
		cin>>hoge;
		q.push_back(hoge);
	}
	for(int i=0;i<c;i++){
		long long hoge;
		cin>>hoge;
		r.push_back(hoge);
	}
	sort(p.rbegin(),p.rend());
	sort(q.rbegin(),q.rend());
	sort(r.rbegin(),r.rend());
	long long ans=0;
	priority_queue<long long,vector<long long>,greater<long long> > red,green;
	for(int i=0;i<x;i++){
		red.push(p[i]);
	}
	for(int i=0;i<y;i++){
		green.push(q[i]);
	}
	int id=0;
	while(id<c){
		if(red.top()>=r[id]&&green.top()>=r[id]){
			break;
		}else{
			if(red.top()<green.top()){
				red.pop();
				red.push(r[id]);
			}else{
				green.pop();
				green.push(r[id]);
			}
			id++;
		}
	}
	while(!red.empty()){
		ans+=red.top();
		red.pop();
	}
	while(!green.empty()){
		ans+=green.top();
		green.pop();
	}
	cout<<ans<<endl;
	return 0;
}

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

using namespace std;

int main(void) {
    int N, T;
    cin >> N >> T;
    // --T;
    vector<int> A(N+2), B(N+2);
    for(int i=1; i<=N; i++) {
        cin >> A[i] >> B[i];
    }

    vector< vector<int> > dp1(N+2, vector<int>(T));
    for(int i=1; i<=N; i++) {
        for(int t=0; t<T; t++) {
            if(t-A[i] < 0) {
                dp1[i][t] = dp1[i-1][t];
            } else {
                dp1[i][t] = max(dp1[i-1][t], dp1[i-1][t-A[i]]+B[i]);
            }
        }
    }

    vector< vector<int> > dp2(N+2, vector<int>(T));
    for(int i=N; i; i--) {
        for(int t=0; t<T; t++) {
            if(t-A[i] < 0) {
                dp2[i][t] = dp2[i+1][t];
            } else {
                dp2[i][t] = max(dp2[i+1][t], dp2[i+1][t-A[i]]+B[i]);
            }
        }
    }


    int ans = 0;
    for(int i=1; i<=N; i++) {
        int tmp = 0;
        for(int t=0; t<T; t++) {
            tmp = max(tmp, dp1[i-1][t] + dp2[i+1][T-1-t]);
        }
        ans = max(ans, tmp+B[i]);
    }

    cout << ans << endl;
    return 0;
}


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

#define int long long int
#define rep(a,b,c) for(int a=b;a<c;a++)
#define repm(a,b,c) for(int a=(b-1);a>=c;a--)
#define pb push_back
#define str string
#define sf(a) scanfs("%d",&a)
#define pb push_back
#define mp make_pair
#define Fi first
#define Se second
#define ALL(v) (v).begin(), (v).end()
using namespace std;
const int INF = 1e18 + 9;
const int Mod = 1e9 + 7;
inline int replac(str s){double ans=0;rep(i,0,s.length()){ans+=(s[i]-'0')*pow(10,s.length()-i-1);}return (int)ans;}
inline string numstr(int m){str s="";while(m>0){char c;int a=m/10;if(a>0)a=m%(a*10);else a=m;c=(char)('0'+a);s+=c;m/=10;}str st="";for(int i=s.size()-1;i>=0;i--){st+=s[i];}return st;}
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef vector<pii> vii;
int cost[1001][1001];///i->j=cost;
int mincost[1001];///shougoX->minimum-cost
bool used[1001];///inX?
int N;///ten-kazu
int prim(){
    rep(i,0,N){
        mincost[i]=INF;
        used[i]=false;
    }
    mincost[0] = 0;
    int res = 0;

    while(true){
        int v = -1;
        rep(u,0,N){
            if(!used[u]&&(v == -1 || mincost[u] < mincost[v]))v=u;
        }
        if(v == -1)break;
        used[v] = true;
        res += mincost[v];

        rep(i,0,N){
            mincost[i] = min(mincost[i], cost[v][i]);
        }
    }
    return res;
}

signed main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    map<int,int> mx,my;
    int n;
    cin >> n;
    N=n;
    rep(i,0,1001){
        rep(j,0,1001){
            cost[i][j]=INF;
        }
    }
    rep(i,0,n){
        rep(j,0,n){
            int x;cin >> x;
            if(x==-1)continue;
            cost[i][j]=x;
            cost[j][i]=x;
        }
    }
    cout << prim() << endl;
    return 0;
}

Measured memory_bytes: 10960
#include <iostream>
#include <vector>
#include <queue>
#include <set>
#include <functional>
#include <algorithm>
#include <climits>

using namespace std;

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

struct Edge
{
	int to;
	int cost;
};

struct Node
{
	int city_index;
	int total_cost;
	int current_life;
	int remain_can_regain;

	bool operator >(const Node &a) const
	{
		return total_cost > a.total_cost;
	}
};

int main()
{
	int city_count, initial_life, cooler_count, road_count, start_index, goal_index;
	while (cin >> city_count >> initial_life >> cooler_count >> road_count >> start_index >> goal_index,
		city_count)
	{
		// input
		vector<int> is_cooler(city_count, false);
		REP(i, cooler_count)
		{
			int cooler_index;
			cin >> cooler_index;
			is_cooler[cooler_index] = true;
		}
		vector<vector<Edge>> roads(city_count);
		REP(i, road_count)
		{
			int from, to, cost;
			cin >> from >> to >> cost;
			roads[from].push_back({ to, cost });
			roads[to].push_back({ from, cost });
		}

		// dijkstra
		vector<vector<int>> d(city_count, vector<int>(initial_life + 1, INT_MAX)); // [city_index][current_life] => total_cost
		d[start_index][initial_life] = 0;
		priority_queue<Node, vector<Node>, greater<Node> > pq;
		pq.push({ start_index, 0, initial_life, 0});
		while (true)
		{
			if (pq.empty())
			{
				cout << "Help!" << endl;
				break;
			}
			auto current_node = pq.top(); pq.pop();
			if (current_node.city_index == goal_index)
			{
				cout << current_node.total_cost << endl;
				break;
			}
			for (auto &road : roads[current_node.city_index])
			{
				int total_cost = current_node.total_cost + road.cost;
				int life = current_node.current_life - road.cost;
				int remain_can_regain = is_cooler[current_node.city_index] ? initial_life - current_node.current_life : current_node.remain_can_regain;
				if (life < 0)
				{
					int shortage = -life;
					remain_can_regain -= shortage;
					if (remain_can_regain < 0)
					{
						continue;
					}
					total_cost += shortage;
					life = 0;
				}
				REP(i, remain_can_regain + 1)
				{
					auto &di = d[road.to][life + i];
					if (total_cost + i < di)
					{
						di = total_cost + i;
						pq.push({ road.to, total_cost + i, life + i, remain_can_regain - i });
						break;
					}
				}
			}

		}
	}

	return 0;
}

Measured memory_bytes: 1532
// ABC056B - 

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

typedef unsigned long long int ull;
typedef long long int ll;

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

	if (a <= b) {
		if (b <= a + W) {
			cout << 0 << endl;
		} else {
			cout << b - (a + W) << endl;
		}
	} else if (b <= a) {
		if(a <= b + W) {
			cout << 0 << endl;
		} else {
			cout << a - (b + W) << endl;
		}
	}

	return 0;
}


Measured memory_bytes: 256
#include"bits/stdc++.h"
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace __gnu_pbds;
using namespace std;
 
#define int long long int
#define pb push_back
#define mp make_pair
#define loop(i,x,n) for(int i=x;i<=n;i++)
#define rloop(i,x,n) for(int i=x;i>=n;i--)
#define ff first
#define ss second
#define N4RUTO ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
 
typedef tree<int, null_type, less<int>, rb_tree_tag,  
// typedef tree<int, null_type, less_equal<int>, rb_tree_tag,  
tree_order_statistics_node_update>
ordered_set;
 
int32_t main(){
    N4RUTO;
    int t;
    t=1;
    // cin>>t;
    while(t--){
        int n;
        cin>>n;
        int a[n];
        loop(i,0,n-1) cin>>a[i];
        map<int,int> mp;
        int ans = 0;
        loop(i,0,n-1){
            ans+=mp[i-a[i]];
            mp[i+a[i]]++;
        }
        cout<<ans<<"\n";
    }
    return 0;
}

Measured memory_bytes: 27928
import bisect

N, M, K = map(int, input().split())
A = list(map(int, input().split()))
for i in range(1, N):
    A[i] = A[i] + A[i-1]
A = [0] + A
B = list(map(int, input().split()))
for i in range(1, M):
    B[i] = B[i] + B[i-1]
B = [0] + B

ans = 0
for i in range(N+1):
    if A[i] > K:
        break
    temp = K - A[i]
    val = bisect.bisect_right(B, temp) - 1
    ans = max(ans, i + val)
print(ans)

Measured memory_bytes: 45028
public class Main {
	public static void main(String[] args) {
		var sc = new java.util.Scanner(System.in);
		var N = sc.nextInt();
		var D = new int[N][];
		for(int i=0;i<N;i++) {
			D[i]=new int[2];
			D[i][0]=sc.nextInt();
			D[i][1]=sc.nextInt();
		}

		var cnt = 0;
		boolean ysFlg=false;
		for(int i=0;i<N;i++) {
			if(isZorome(D[i][0],D[i][1])) {
				cnt++;
			}else {
				cnt=0;
			}
			if(cnt>=3) {
				ysFlg=true;
				break;
			}
		}
		System.out.println((ysFlg)?"Yes":"No");


	}
	private static boolean isZorome(int a,int b) {
		return a==b;
	}
}


Measured memory_bytes: 35872
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <complex>
#include <cstdint>
#include <cstdio>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <tuple>
#include <utility>
#include <vector>
using namespace std;

using i64 = int64_t;

int H, W;
string s[101];

int main() {
    cin >> H >> W;
    for (int j = 0; j < H; ++j) {
        cin >> s[j];
    }

    int count[26];
    fill(count, count+26, 0);
    for (int j = 0; j < H; ++j) {
        for (int k = 0; k < W; ++k) {
            ++count[s[j][k]-'a'];
        }
    }

    if (H % 2 == 0 && W % 2 == 0) {
        for (int j = 0; j < 26; ++j) {
            if (count[j] % 4 != 0) {
                cout << "No" << endl;
                return 0;
            }
        }
        cout << "Yes" << endl;
        return 0;
    }

    if ((H % 2 == 0) != (W % 2 == 0)) {
        int w = (H % 2 == 1) ? W : H;
        int a = 0;
        for (int j = 0; j < 26; ++j) {
            if (count[j] % 2 == 1) {
                cout << "No" << endl;
                return 0;
            }
            if (count[j] % 4 == 2) {
                ++a;
            }
        }
        cout << (a <= w/2 ? "Yes" : "No") << endl;
        return 0;
    }

    int o = 0, d = 0;
    for (int j = 0; j < 26; ++j) {
        if (count[j] % 2 == 1) {
            ++o;
            count[j] -= count[j] % 2;
        }
        if (count[j] % 4 == 2) {
            ++d;
        }
    }
    cout << ((o == 1 && d <= (H-1)/2+(W-1)/2) ? "Yes" : "No") << endl;
    return 0;
}


Measured memory_bytes: 888
#include<iostream>
using namespace std;
int main(){
  int n,m,c,cnt=0,ans=0;
  cin >> n >> m>>c;
  int b[m],a;
  for(int i=0;i<m;i++){
    cin >> b[i];
  }
  for(int i=0;i<n;i++){
    cnt = 0;
    for(int j=0;j<m;j++){
      cin >> a;
      cnt += b[j]*a;
    }
    if(cnt+c>0) ans++;
  }
  cout << ans << endl;
}


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

typedef long long ll;

int main(){
    int A,B,C,K;
    cin>>A>>B>>C>>K;
    int ans = 0;

    while(A>0 && K > 0){
        ans++;
        K--;
        A--;
    }

    while(B > 0 && K > 0){
        B--;
        K--;
    }

    while(C > 0 && K > 0){
        C--;
        ans--;
        K--;
    }

    cout<<ans<<endl;

    return 0;
}

Measured memory_bytes: 3636
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cstdio>
#include <cmath>
#include <tuple>
#define rep(i, n) for(i = 0; i < n; i++)
#define int long long
using namespace std;

int n;
int a[100000];
int ans[100000];

signed main() {
	int i;
	
	cin >> n;
	rep(i, n) cin >> a[i];
	
	int x = 0;
	rep(i, n) {
		if (i % 2 == 0) x += a[i];
		else x -= a[i];
	}
	
	rep(i, n) {
		ans[i] = x;
		x = 2 * a[i] - x;
	}
	
	rep(i, n) {
		cout << ans[i];
		if (i + 1 < n) cout << " ";
	}
	cout << endl;
	return 0;
}

Measured memory_bytes: 2816
#include <bits/stdc++.h>
#define rep(i, start, end) for (long long i = start; i < end; ++i)
#define srt(x) sort((x).begin(), (x).end());
#define rsrt(x) sort((x).rbegin(), (x).rend());
#define deb(x) cout<<#x<<" = "<<(x)<<" (L"<<LINE<<")"<<endl;
#define vdeb(x) {cout<<#x<<" = { "; rep(i, x.size()) cout<<x[i]<<' '; cout <<'}'<<" (L"<<LINE<<")"<<endl;}
using namespace std;
using ll = long long;
using vi = vector<int>;
using vivi = vector<vi>;
using vll = vector<long long>;
using vllvll = vector<vll>;
using vs = vector<string>;

bool IsPrime(ll num)
{
    if (num < 2) return false;
    else if (num == 2) return true;
    else if (num % 2 == 0) return false; // 偶数はあらかじめ除く

    double sqrtNum = sqrt(num);
    for (ll i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            // 素数ではない
            return false;
        }
    }

    // 素数である
    return true;
}

int main()
{
    ll A, B, N;
    cin >> A >> B >> N;
    ll tmp = B-1;
    if (N < B) {
        tmp = N;
    } 
    ll ans = floor(A*tmp/B) - A*floor(tmp/B);
    cout << ans << endl;
}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
int n,cnt,a[100005],LIS[100005];
int main(){
	scanf("%d",&n);
	for(int i=1;i<=n;i++)scanf("%d",&a[i]);
	for(int i=1;i<=n;i++)LIS[i]=1;
	for(int i=1;i<=n;i++){
		int t=upper_bound(LIS+1,LIS+n+1,-a[i])-LIS;
		while(t>1&&LIS[t-1]>-a[i])t--;while(t<n&&LIS[t]<-a[i])t++;
		LIS[t]=-a[i];
	}
	int t=upper_bound(LIS+1,LIS+n+1,1)-LIS;
	while(t>1&&LIS[t-1]==1)t--;while(t<n&&LIS[t]<1)t++;
	printf("%d\n",t-1);
	return 0;
}

Measured memory_bytes: 1024
n=int(input())
l=list(map(int,input().split()))
ans=[0 for i in range(n)]
ans[n-2]=abs(l[n-1]-l[n-2])
i=n-3
while i>-1:
	ans[i]=min(ans[i+1]+abs(l[i]-l[i+1]),ans[i+2]+abs(l[i]-l[i+2]))
	i=i-1
print(ans[0])


Measured memory_bytes: 13980
//A.cpp
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;

long long Pm(int x);

int main(){
  int N,M;
  cin >> N >> M;
  long long Ans;
  if(M<N-1||N+1<M) printf("0\n");
  else{
    Ans = Pm(N)*Pm(M) % 1000000007;
    if(N==M) Ans = (2*Ans) % 1000000007;
    printf("%lld\n",Ans);
  }

  return 0;
}

long long Pm(int x){
  long long Ans = 1;
  for(int i = 1; i <= x; i++){
    Ans *= i;
    if(Ans>=1000000007) Ans %= 1000000007;
  }
  return Ans;
}


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

string s;
int cnt[26];

signed main() {
	int i;
	
	cin >> s;
	rep(i, s.length()) cnt[s[i] - 'a']++;
	
	int ans = (int)s.length() * (s.length() - 1) / 2;
	rep(i, 26) ans -= cnt[i] * (cnt[i] - 1) / 2;
	cout << ans + 1 << endl;
	return 0;
}

Measured memory_bytes: 644
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<ll,ll>;
using vl = vector<ll>;
using Map = map<ll,ll>;
using T = tuple<ll,ll,ll>;
using vvl = vector<vector<ll>>;
#define all(v) v.begin(), v.end()
#define prt(v) cout<<(v)<<"\n";
#define fi(v) get<0>(v)
#define se(v) get<1>(v)
#define th(v) get<2>(v)
#define endl "\n"
template <typename T> bool chmax(T &a, const T &b){if (a<b){a=b;return 1;}return 0;}
template <typename T> bool chmin(T &a, const T &b){if (a>b){a=b;return 1;}return 0;}
const ll INF=1LL<<60;
const ll MOD=1000000007;



signed main(void){
    cin.tie(0);cout.tie(0);ios::sync_with_stdio(false);
    ll N;
    cin >> N;
    ll M;
    cin >> M;
    vector<ll> L(M,0);
    vector<ll> R(M,0);
    vector<ll> C(M,0);
    for(ll i=0;i<M;++i){cin>>L[i]>>R[i]>>C[i];L[i]--;R[i]--;}
    vector<vector<P>> G(N, vector<P>(0));
    for(ll i=0;i<M;++i)G[L[i]].emplace_back(P(R[i],C[i]));
    for(ll i=1;i<N;++i)G[i].emplace_back(P(i-1,0));
    priority_queue<P, vector<P>, greater<P>> pq;
    pq.emplace(P(0,0));
    vector<ll> d(N,INF);
    d[0]=0;
    while(!pq.empty()){
        P x=pq.top();
        pq.pop();
        ll y=x.first;
        ll z=x.second;
        if(y>d[z])continue;
        for(auto p: G[z]){
            if(d[p.first]>d[z]+p.second){
                d[p.first]=d[z]+p.second;
                pq.emplace(P(d[p.first],p.first));
            }
        }
    }
    if(d[N-1]==INF)prt(-1)
    else prt(d[N-1])

    return 0;
}


Measured memory_bytes: 11512
import math
n = list(map(int,input().split(" ")))
n = n[0:2]
res=0
c=0
for i in range(n[0]):
    inp = list(map(int,input().split(" ")))
    inp = inp[0:2]
    res =  math.sqrt(inp[0]*inp[0] + inp[1]*inp[1])
    if res <= n[1]:
        c+=1;
    
print(c)


Measured memory_bytes: 9212
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <set>
#include <map>

using namespace std;

#define rep(i, n) for (int i = 0; i < n; i++)
#define all(x) x.begin(), x.end()
#define pair <int, int> P;
#define first fi
#define second se
typedef long long ll;

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

    int ans = 0;
    rep(i,s.size()) {
        if(s[i] != t[i]) {
            ans++;
        }
    }

    cout << ans << "\n";
}

Measured memory_bytes: 3864
#include <iostream>
#include <algorithm>
#include <math.h>

using namespace std;

const int MAX_N = 100;

int main(int argc, char const *argv[]) {
  int n, k, x[MAX_N];
  cin >> n >> k;
  for (size_t i = 0; i < n; i++) cin >> x[i];

  int ans = 0;
  for (size_t i = 0; i < n; i++) {
    if (x[i] > k-x[i]) ans += 2*(k-x[i]);
    else ans += 2*x[i];
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}

fn read_vec2<T: std::str::FromStr>(n: u32) -> Vec<Vec<T>> {
    (0..n).map(|_| read_vec()).collect()
}
fn main(){
    let (n,k) = {
        let r = read_vec::<i64>();
        (r[0],r[1])
    };
    if k % 2 != 0 {
        println!("{}",(n/k).pow(3) );
    } else {
        let mut c:i64 = 0;
        for i in 0..n+1{
            if i % k == k / 2{ c += 1;}
        }
        println!("{}",(n/k).pow(3) + c.pow(3) );
    }
}

Measured memory_bytes: 4352
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
using namespace std;
typedef long long int ll;

struct Edge{
	int to; ll cost;
	Edge(){}
	Edge(int to,int cost):to(to),cost(cost){}
};

vector<Edge> G[100010];
int n,m;

ll d[2][100010];

int main(){
	cin >> n >> m;
	for(int i=0;i<m;i++){
		int a,b; ll c;
		cin >> a >> b >> c;
		a--; b--;
		G[a].push_back(Edge(b,c));
		G[b].push_back(Edge(a,c));
	}
	for(int i=0;i<2;i++){
		for(int j=0;j<n;j++){
			d[i][j]=1e18;
		}
	}
	d[0][0]=0;
	queue<pair<int,int> > q;
	q.push(make_pair(0,0));
	bool ok=true;
	while(q.empty()==false){
		pair<int,int> now=q.front();
		q.pop();
		int eo=now.first; int v=now.second;
		for(auto p:G[v]){
			int tv=p.to;
			ll co=p.cost;
			if(d[1-eo][tv]==1e18){
				d[1-eo][tv]=co-d[eo][v];
				q.push(make_pair(1-eo,tv));
			}
			else{
				if(d[1-eo][tv]!=co-d[eo][v]){ // 辻褄が合わない
					ok=false;
					break;
				}
			}
		}
		if(ok==false){
			cout << 0 << endl;
			return 0;
		}
	}
	if(d[1][0]!=1e18){
		if(d[1][0]<=0||d[1][0]%2==1){
			cout << 0 << endl;
			return 0;
		}
		ll fi=d[1][0]/(ll)2; // 最初の頂点の数が一意に定まる
		ll mi=1e18;
		for(int i=0;i<n;i++){
			mi=min(mi,d[0][i]);
		}
		ll ma=1e18;
		for(int i=0;i<n;i++){
			ma=min(ma,d[1][i]);
		}
		mi=-mi+(ll)1;
		ma--;
		if(mi<=fi&&fi<=ma){
			cout << 1 << endl;
			return 0;
		}
		else{
			cout << 0 << endl;
			return 0;
		}
	}
	else{
		ll mi=1e18;
		for(int i=0;i<n;i++){
			mi=min(mi,d[0][i]);
		}
		ll ma=1e18;
		for(int i=0;i<n;i++){
			ma=min(ma,d[1][i]);
		}
		mi=-mi+(ll)1;
		ma--;
		if(mi<=ma){
			cout << ma-mi+1 << endl;
			return 0;
		}
		else{
			cout << 0 << endl;
			return 0;
		}
	}
}

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

using namespace std;

int main()
{
    long long a,b,c;
    cin >> a >> b >> c;
    if(a % 2 == 0 || b % 2 == 0 || c % 2 == 0)
        cout << 0;
    else
    {
        cout << min(a*b, min(b*c, a*c));
    }
    return 0;
}


Measured memory_bytes: 256
import time
startTimeProblem=time.time()

import fileinput, sys, itertools, functools
from math import *
from bisect import *
from heapq import *
from collections import *

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

class InputHelper:
    def __init__(self):
        self.myinput = fileinput.input()

    def isLocal(self):
        return not fileinput.isstdin()

    def int(self):
        return int(self.myinput.readline().rstrip())

    def ints(self):
        return [int(_) for _ in self.myinput.readline().rstrip().split()]

    def str(self):
        return self.myinput.readline().rstrip()

    def strs(self):
        return [_ for _ in self.myinput.readline().rstrip().split()]

class OutputHelper:
    def int(self, a):
        print(a)    

    def ints(self, a):  
        print(" ".join([str(_) for _ in a]))
    
    def intsNL(self, a):
        for _ in a:
            print(_)
    
    def str(self, s):
        print(s)

    def strs(self, s):
        print(" ".join([_ for _ in s]))

    def strsNL(self, s):
        for st in s:
            print(st)

class ListNode:
    def __init__(self, val):
        self.val = val
        self.next = None
        self.prev = None

In = InputHelper()
Out = OutputHelper()

######################################

S = In.str()

if S[-1]=="s":
    Out.str(S+"es")
else:
    Out.str(S+"s")

######################################

if len(sys.argv)>2 and sys.argv[2]=="TIMEIT":
    fin = (time.time()-startTimeProblem)*1000
    print("{:.2f}".format(fin) + "ms")

Measured memory_bytes: 69200
import sys
X = int(input())
N = X
def num(n):
    if n == 1:
        return False
    for i in range(2,int(n**0.5)+1):
        if n % i == 0:
            return False
    return True
while True:
    if num(N) != False:
        print(N)
        sys.exit()
    else:
        N += 1

Measured memory_bytes: 3060
#include<cstdio>
#include<cmath>
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
    int num[1000]={0};
    int a;
    while(cin>>a)num[a]++;
    int flg=0;
    for(int i=100;;i--){
        for(int j=0;j<200;j++){
            if(num[j]==i){
                flg=1;
                cout<<j<<endl;
            }
        }
        if(flg)break;
    }
    return 0;
}

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

#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define size_t unsigned long long
#define ll long long
#define rep(i,a) for(int i=0;i<(a);i++)
#define repr(i,a) for(int i=(int)(a)-1;i>=0;i--)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define FORR(i,a,b) for(int i=(int)(b)-1;i>=a;i--)
#define ALL(a) a.begin(), a.end()
using namespace std;
int si() { int x; scanf("%d", &x); return x; }
long long sl() { long long x; scanf("%lld", &x); return x; }
string ss() { string x; cin >> x; return x; }
void pi(int x) { printf("%d ", x); }
void pl(long long x) { printf("%lld ", x); }
void pd(double x) { printf("%.15f ", x); }
void ps(const string &s) { printf("%s ", s.c_str()); }
void br() { putchar('\n'); }

const ll MOD = 1e9 + 7;
const ll INF = 1e9 + 5;

struct mint {
    int n;
    mint(int n_ = 0) : n(n_) {}
};

mint operator+(mint a, mint b) { a.n += b.n; if (a.n >= MOD) a.n -= MOD; return a; }
mint operator-(mint a, mint b) { a.n -= b.n; if (a.n < 0) a.n += MOD; return a; }
mint operator*(mint a, mint b) { return (long long)a.n * b.n % MOD; }
mint &operator+=(mint &a, mint b) { return a = a + b; }
mint &operator-=(mint &a, mint b) { return a = a - b; }
mint &operator*=(mint &a, mint b) { return a = a * b; }

typedef pair<int, int> P;

const ll N = 2e5+5;
string s;
ll n,p[N],num,m;

int main () {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  cin >> n;
  m = INF;
  rep(i,n) {
    cin >>  p[i];
  }
  rep(i,n) {
    if(m >= p[i]) num++;
    m = min(m, p[i]);
  }
  cout << num << endl;
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
int len;
long long  dp[200005][3][3][2];
char t[200005];
#define mo 998244353
int hashw(char c[]){
	int ans=0;
	for(int i=0;i<strlen(c);i++)
		ans=10*ans+c[i]-'a'+1;
	return ans;
}
bool vis[100000];
int wei(int t,int w){
	t=t/(pow(10,w-1));
	return t%10;
}
void doit(){
	int ans=1;
	queue<int> q;
	q.push(hashw(t));
	vis[hashw(t)]=1;
	while(!q.empty()){
		int s=q.front();q.pop();
		for(int i=2;i<=len;i++){
			int u=wei(s,i),v=wei(s,i-1),a1=6-u-v;
			if(u==v) continue;
			int k=s+( a1-wei(s,i) )*pow(10,i-1)+(a1-wei(s,i-1))*pow(10,i-2);
			if(!vis[k]){
				vis[k]=1;
				q.push(k);ans++;
			}
		}
	}
	cout<<ans;
}
int main()
{
	
	scanf("%s",t);
	len=strlen(t);
	int sum=0;
	for(int i=0;i<len;i++)
		sum+=t[i]-'a';
	sum%=3;
	
	bool h=1;
	for(int i=1;i<len;i++)
		 if(t[i]!=t[i-1]) h=0;
	if(h) {cout<<1;return 0;}
	
	if(len<=3) {doit();return 0;}
	for(int i=0;i<=2;i++)
		dp[1][i][i][0]=1;
	for(int i=2;i<=len;i++){
		for(int p=0;p<=2;p++)
		for(int j=0;j<=2;j++)
		for(int k=0;k<=2;k++){
			if(p==j)
				dp[i][p][(k+p)%3][1]+=dp[i-1][j][k][0];	
			else 
				dp[i][p][(k+p)%3][0]+=dp[i-1][j][k][0];
			dp[i][p][(k+p)%3][1]+=dp[i-1][j][k][1];
			dp[i][p][(k+p)%3][1]%=mo;
			dp[i][p][(k+p)%3][0]%=mo;
		}
	}
	long long ans=0;
	for(int i=0;i<=2;i++)
		ans+=dp[len][i][sum][1];
	int flag=1;
	for(int i=1;i<len;i++)
		if(t[i]==t[i-1]) flag=0;
	cout<<(ans+flag)%mo;
	
	return 0;
}

Measured memory_bytes: 28544
#include<stdio.h>
#include<string.h>
int main(void)
{
    char s[201],t[201],u[201];
    int i,j,k,l=0,ans=0,a;
    scanf("%s",s);
    j=strlen(s);
    while(j>1){
        j--;
        a=0;
        l=0;
        k=j/2;
        for(i=0;i<k;i++)
            t[i]=s[i];
        t[i]='\0';
        for(i=k;i<j;i++){
            u[l]=s[i];
            l++;
        }
        u[l]='\0';
        for(i=0;i<k;i++)
            if(t[i]==u[i])
                a++;
        if((a==strlen(t))&&(ans<strlen(t)))
            ans=strlen(t);
    }
    printf("%d\n",ans*2);
    return 0;
}

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

using namespace std;

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

    int n, m;
    cin >> n >> m;
    int A[n], ans = 0;
    int Total = 0;
    for(int i = 0; i < n; i++)
    {
        cin >> A[i];
        Total += A[i];
    }

    double MinPoints = Total / (4 * (double)m);
    for(int i = 0; i < n; i++)
    {
        if(A[i] >= MinPoints)
            ans++;
    }

    if(ans >= m)
        cout << "Yes\n";
    else
        cout << "No\n";

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
using namespace std;
typedef long long ll;
const int MOD = 1e9 + 7;

int main() {
  int n, k;
  string s;
  cin >> n >> s >> k;
  for (int i = 0; i < n; i++) {
    if (s[i] != s[k - 1]) s[i] = '*';
  }
  cout << s << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <math.h>

using namespace std;


int main(){
    int n;
    cin >> n;
    if(n < 0 || n > 10000)  return -1;
    int o1 = 1000000;
    int o2= -1000000;
    long o3=0;
    for(int i = 0; i < n; i ++){
        int tmp ;
        cin >> tmp;
        if(tmp < -1000000 || tmp > 1000000) return -1;
        if(tmp < o1) o1 = tmp;
        if(tmp > o2) o2 = tmp;
        o3 += tmp;
    }

    cout << o1 << " " << o2 << " " << o3 << endl;

    return 0;
}


Measured memory_bytes: 3088
import java.math.BigDecimal;
import java.math.MathContext;
import java.util.*;
//無理やりBigDecimalで通したが 循環小数の考え方で任意の整数で可能。
class Main {
	Scanner sc = new Scanner(System.in);

	public void run() {
		while(sc.hasNext()){
			int n=sc.nextInt();

			int val=1;
			for(int i=0;i<n;i++){
				val+=1+i;
			}
			ln(val);
		}
	}

	public static void main(String[] args) {
		new Main().run();
	}

	public static void pr(Object o) {
		System.out.print(o);
	}

	public static void ln(Object o) {
		System.out.println(o);
	}

	public static void ln() {
		System.out.println();
	}
}

Measured memory_bytes: 12000
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int main(void) {
    
    int n,x,t;
    scanf("%d %d %d",&n,&x,&t);

    printf("%d\n",((n / x) + ((n%x != 0)? 1 : 0)) * t);

    return 0;
}

Measured memory_bytes: 1688
#include<stdio.h>
#include<string.h>
int main(void){
  int a,b,c;
  scanf("%d %d %d",&a,&b,&c);
  if(a > b){
    int t = a;
    a = b;
    b = t;
  }
  if(a < c && c < b){
    printf("Yes\n");
  }else{
    printf("No");
  }
  return 0;
}
//scanf("%d",&);
//printf("%d\n",);

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

int main()
{
    int str[200];
    int n;
    cin>>n;
    int i;
    for(i=0;i<n;i++)
        cin>>str[i];
    sort(str,str+n);
    int ans=0;
    int flag=0;
    for(i=n-1;i>=0;i--)
    {
        if(flag==0)
        {
            ans+=str[i];
            flag=1;
        }
        else
        {
            ans-=str[i];
            flag=0;
        }
    }
    cout<<ans;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int n, k;
double x[65], y[65], c[65], r[65];
double eps = 1e-8;

double dist(pair<double, double> p, pair<double, double> q) {
	double xx = (p.first - q.first)*(p.first - q.first);
	double yy = (p.second - q.second)*(p.second - q.second);

	return sqrt(xx + yy);
}

vector<pair<double, double>> circle_circle_intersection(double x1, double y1, double r1, double x2, double y2, double r2) {
	vector<pair<double, double>> ans;
	double d = dist(make_pair(x1, y1), make_pair(x2, y2));
	if (d > r1 + r2) {
		return ans;
	}
	if (x1 == x2 && y1 == y2) {
		ans.push_back(make_pair(x1, y1)); return ans;
	}
	if (d < abs(r1 - r2)) {
		ans.push_back(make_pair(x1, y1)); return ans;
	}

	double a = (r1*r1 - r2*r2 + d*d)/(2*d);
	double h = sqrt(r1*r1 - a*a);


	double x3 = (x2 - x1)*(a/d) + x1;
	double y3 = (y2 - y1)*(a/d) + y1;

	ans.emplace_back(x3 + h*(y2 - y1)/d, y3 - h*(x2 - x1)/d);
	ans.emplace_back(x3 - h*(y2 - y1)/d, y3 + h*(x2 - x1)/d);

	return ans;
}

int check(double t) {
	int ans = 0;
	for (int i = 0; i < n; i++) {
		r[i] = t/c[i];
	}

	for (int i = 0; i < n; i++) {
		for (int j = 0; j < n; j++) {
			vector<pair<double, double> > pts = circle_circle_intersection(x[i], y[i], r[i], x[j], y[j], r[j]);
			for (auto p: pts) {
				int cnt = 0;
				for (int k = 0; k < n; k++) {
					if (dist(p, make_pair(x[k], y[k])) <= r[k] +eps) cnt++;
				}
				ans = max(ans, cnt);
			}
		}
	}
	

	return ans;
}

int main() {
	ios::sync_with_stdio(0); cin.tie(0);
	cin >> n >> k;
	if (k == 1) {
		cout << "0\n"; exit(0);
	}
	for (int i = 0; i < n; i++) {
		cin >> x[i] >> y[i] >> c[i];
	}

	double l = 0, r = 100000000;
	while(r-l>=1e-7)
	{
		double mid = (l + r)/2;

		if (check(mid) >= k) {
			r = mid;
		} else {
			l = mid;
		}
	}
	cout << fixed << setprecision(9) << r << '\n'; 

	return 0;
}


Measured memory_bytes: 256
N = int(input())
M = 10**9 + 7

if N < 3:
    print(0)
elif N < 6:
    print(1)
else:
    dp = [0] * (N + 1)

    dp[3] = 1
    dp[4] = 1
    dp[5] = 1
    for i in range(6, N + 1):
        dp[i] = sum(dp[3:i - 3 + 1]) + 1
        dp[i] %= M

    print(dp[-1] % M)

Measured memory_bytes: 73456
#include <stdio.h>
#include <stdlib.h>
int main() {
  long long x,y,c=0;
  scanf("%lld %lld",&x,&y);
  if (x*y<0||(x==0&&y<0)||(y==0&&x>0)) {
    c=1;
  } else if ((llabs(y)-llabs(x))*x<0) {
    c=2;
  }
  printf("%lld\n",c+llabs(llabs(y)-llabs(x)));
  return 0;
}

Measured memory_bytes: 128
#include<stdio.h>
#include<math.h>
#include<stdlib.h>
#include<string.h>

#define N_MAX 200000
#define MODVAL 1000000007

int main(void){
	int n,k;
	int d;
	int h;
	int x[100] = {};
	int ret = 0;

	int i,j;

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

	for(i=0;i<k;i++){
		scanf("%d",&d);
		for(j=0;j<d;j++){
			scanf("%d",&h);
			x[h-1]++;
		}
	}

	for(i=0;i<n;i++){
		if(x[i] == 0){
			ret++;
		}
	}


	printf("%d\n",ret);


	return 0;
}


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

const int DEPTH = 17;
const int INF = ((1LL << 31) - 1);
class Segtree {
	int value[1 << (DEPTH + 1)];
public:
	Segtree() {
		for (int i = 0; i < (1 << (DEPTH + 1)); i++) {
			value[i] = INF;
		}
	}
	void update(int pos, int x) {
		pos = (1 << DEPTH) - 1 + pos;
		value[pos] = x;
		while (pos > 0) {
			pos = (pos - 1) / 2;
			value[pos] = min(value[pos * 2 + 1], value[pos * 2 + 2]);
		}
	}
	//[l, r)
	int getMin(int l, int r, int a = 0, int b = (1 << DEPTH), int id = 0) {
		if (a >= r || b <= l) return INF;
		if (l <= a && b <= r) return value[id];
		int x = getMin(l, r, a, a + (b - a) / 2, id * 2 + 1);
		int y = getMin(l, r, a + (b - a) / 2, b, id * 2 + 2);
		return min(x, y);
	}
};

Segtree seg;
int n, q;
int com, x, y;

int main() {
	cin >> n >> q;
	for (int i = 0; i < q; i++) {
		cin >> com >> x >> y;
		if (com == 0) seg.update(x, y);
		else cout << seg.getMin(x, y + 1) << endl;
	}
	return 0;
}

Measured memory_bytes: 4124
#include<iostream>

using namespace std;
const int N = 100;

int main() {

	int n, u, k, v;
    int A[N][N];

	cin>>n;

	for( int i = 0; i < n; i++ ) {
		for( int j = 0; j< n; j++ ) A[i][j] = 0;
	}
	
	for ( int i = 0; i < n; i++ ) {
		cin >> u >> k;
		while( k-- ) {
			cin >> v;
			A[u - 1][ v - 1] = 1;
		}
	}
	for( int i = 0; i < n; i++ ) {
		for( int j = 0; j< n; j++ ) {
			if ( j ) cout << " ";
			cout << A[i][j];
		}
		cout << endl;
	}
	return 0;
}


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

const double EPS = 1e-10;
const ll INF = 100000000;
const ll MOD = 1000000007;

int h, w;
bool b[2000][2000];
int c[2000][2000];
int height[2000][2000];

int teq(int hist[2000]) {
    int ret = 0;
    int R[2000], L[2000];
    int box[2000];
    int it = 0;
    rep(i,w-1) {
        while(it > 0 && hist[box[it-1]] >= hist[i]) it--;
        L[i] = it==0?0:(box[it-1]+1);
        box[it++] = i;
    }
    it = 0;
    for(int i = w-2; i >= 0; i--) {
        while(it > 0 && hist[box[it-1]] >= hist[i]) it--;
        R[i] = it==0?w-1:box[it-1];
        box[it++] = i;
    }
    
    rep(i,w-1) ret = max(ret, (hist[i]+1)*(R[i]-L[i]+1));
    return ret;
}

int main(){
    cin >> h >> w;
    rep(i,h) {
        rep(j,w) {
            char hoge; cin >> hoge;
            if(hoge == '.') {
                b[i][j] = true;
            } else {
                b[i][j] = false;
            }
        }
    }
    if(h == 1 || w == 1) {
        cout << max(h, w) << endl;
        return 0;
    }
    for(int i = 0; i < h; i++) {
        for(int j = 0; j < w-1; j++) {
            c[i][j] = b[i][j]^b[i][j+1];
        } 
    }
    for(int i = 0; i < h-1; i++) {
        for(int j = 0; j < w-1; j++) {
            c[i][j] = c[i][j]^c[i+1][j];
        }
    }
    for(int i = 0; i < h-1; i++) {
        for(int j = 0; j < w-1; j++) {
            if(c[i][j] == 0) {
                if(i != 0) height[i][j] = height[i-1][j]+1;
                else height[i][j] = 1;
            }
        }
    }
    int ans = max(h, w);
    rep(i,h-1) {
        ans = max(ans, teq(height[i]));
    }
    cout << ans << endl;
}
































Measured memory_bytes: 35456
#include<bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define pb push_back
#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 srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()
#define uni(x) x.erase(unique(rng(x)),x.end())
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define dup(x,y) (((x)+(y)-1)/(y))
#define v(T) vector<T>
#define vv(T) v(v(T))
using ll = int64_t;
using ull = uint64_t;
using uint = uint32_t;
using pii = pair<int,int>;
using pll = pair<ll,ll>;
using pil = pair<int,ll>;
using pil = pair<int,ll>;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
template<typename T>inline istream& operator>>(istream&i,v(T)&v)
{rep(j,v.size())i>>v[j];return i;}
template<typename T>string join(const v(T)&v)
{stringstream s;rep(i,v.size())s<<' '<<v[i];return s.str().substr(1);}
template<typename T>inline ostream& operator<<(ostream&o,const v(T)&v)
{if(v.size())o<<join(v);return o;}
template<typename T1,typename T2>inline istream& operator>>(istream&i,pair<T1,T2>&v)
{return i>>v.fi>>v.se;}
template<typename T1,typename T2>inline ostream& operator<<(ostream&o,const pair<T1,T2>&v)
{return o<<v.fi<<","<<v.se;}
const double eps = 1e-6;
const ll LINF = 100200300400500600ll;
const int INF = 1001001001;
//--------------------------------------------------------
#define fastio cin.tie(nullptr); std::ios::sync_with_stdio(false);
#define myio ifstream iofi; if(argc>1){iofi.open(argv[1]); std::cin.rdbuf(iofi.rdbuf());}
#define myloopset int loop = 1; if(argc>2) loop =stoi(argv[2]); rep(i,loop)
//--------------------------------------------------------------
template <class T> T chmin(T &a,T b){if(a>b){a=b; return 1;}else return 0;}
template <class T> T chmax(T &a,T b){if(a<b){a=b; return 1;}else return 0;}
const int dx[4] = {0,1,0,-1};
const int dy[4] = {-1,0,1,0};
const int mod = 1000000007;
#define Yes(ifeq) cout<<(( ifeq )? "Yes":"No")<<endl;

void Main(){
  int x,y,a,b,c;
  cin>>x>>y>>a>>b>>c;
  vl p(a),q(b),r(c);
  cin>>p>>q>>r;
  sort(rrng(p));
  sort(rrng(q));
  priority_queue<ll> que;
  rep(i,x) que.push(p[i]);
  rep(i,y) que.push(q[i]);
  rep(i,c) que.push(r[i]);
  ll ans=0;
  rep(i,x+y){
    ans+=que.top(); que.pop();
  }
  cout<<ans<<endl;
} signed main(int argc,char** argv)
{fastio; myio; myloopset Main();}


Measured memory_bytes: 8432
#include <iostream>
#include <algorithm>
#include <cstring>
#include <cstdio>

using namespace std;

string s;
string::iterator it;
int i=0;
int main()
{
    getline(cin,s);
    while(i<s.length())
    {
          if(s[i]=='B')
          {
              if(i>0)
                s.erase(i-1,2),
                i--;
              else
                  s.erase(i,1);
          }

        else
            i++;

    }

    cout<<s;


    return 0;
  }





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

int main() {
  int H, W; cin >> H >> W;
  vector<vector<char>> table(H+2, vector<char>(W+2,'.')); 
  for (int i=1; i<H+1; i++){
    for (int j=1; j<W+1; j++){
      cin >> table.at(i).at(j);
    }
  }

  for (int i=1; i<H+1; i++){
    for (int j=1; j<W+1; j++){
      if(table.at(i).at(j)=='#')  cout << table.at(i).at(j);
      else{
        int counter = 0;
        for(int k=-1; k<2; k++){
          for(int l=-1; l<2; l++){
            if(table.at(i+k).at(j+l)=='#') counter++;
          }
        }
        cout << counter;
      }
    }
    cout << endl;
  }
 

}

Measured memory_bytes: 3624
#include<stdio.h>
 int main()
 { 
    long long int n,a,c,d;
     scanf("%lld",&n);
     scanf("%lld",&a);
     c=n%500;
     if(c==0)
     printf("Yes\n");
     else{
     
    d=c-a; 
    if(d<=0) 
    printf("Yes\n");
     else printf("No\n");}
     return 0;
     }

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

int main(){
  
  string s;
  cin >> s;
  if(s.at(1)==s.at(0)&&s.at(0)==s.at(2)&&s.at(2)==s.at(1)){
    cout <<"No" <<endl;
  }
  else{
    cout << "Yes" <<endl;
  }
}


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

int main(void)
{
    int K;
    std::cin >> K;
    int X;
    std::cin >> X;

    int min_val = X - K + 1;
    int max_val = X + K - 1;

    if (min_val < -1000000)
        min_val = -1000000;
    if (max_val > 1000000)
        max_val = 1000000;
    
    for (int i = min_val; i <= max_val; i++) {
        std::cout << i << " ";
    }
    std::cout << std::endl;

    return 0;
}

Measured memory_bytes: 256
from itertools import product
N=int(input())
f=[0]*N
for x,y,z in product(range(1,100),repeat=3):
    n=x**2+y**2+z**2+x*y+y*z+z*x
    if n<=N:
        f[n-1]+=1
print(*f,sep="\n")

Measured memory_bytes: 9504
line = gets.chomp.split(" ").map(&:to_i)
# line = [1000, 1, 1000]
N, X, T = line

shortest_time = 0

if N <= X
    shortest_time = T
elsif N > X
    burn_time = N / X
    # 1
    if N % X != 0 # 8
        shortest_time = (burn_time * T) + T
    else
        shortest_time = T * burn_time
    end
end 

p shortest_time




Measured memory_bytes: 14300