akhauriyash/Code-Regression huggingface dataset:
#include<algorithm>
#include<iostream>
#include<cstdio>
#define MN 200000
#define mod 1000000007
using namespace std;
inline int read()
{
	int x=0,f=1;char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
	return x*f;
}
int n,L[MN+5],Mx[MN+5],f[MN+5];
pair<int,int> a[MN+5],s[MN+5];
inline int Calc(int l,int r){return (f[r]-(l?f[l-1]:0)+mod)%mod;}
int main()
{
	n=read();
	for(int i=1;i<=n;++i) a[i].first=read(),a[i].second=L[i]=read();
	sort(a+1,a+n+1);sort(L+1,L+n+1);
	for(int i=1,mx=0;i<=n;++i)
	{
		a[i].second=lower_bound(L+1,L+n+1,a[i].second)-L;
		mx=max(mx,a[i].second);Mx[i]=mx;
	}
	for(int i=n,mn=n+1;i;--i)
	{
		mn=min(mn,a[i].second);
		s[i]=make_pair(Mx[i],mn);	
	}
	sort(s+1,s+n+1);f[0]=1;
	for(int i=1,j=0;i<=n;++i)
	{
		while(j<s[i].first) ++j,f[j]=f[j-1];
		f[s[i].first]=(f[s[i].first]+Calc(s[i].second-1,s[i].first))%mod;
	}
	printf("%d\n",(f[n]-f[n-1]+mod)%mod);
	return 0;
}



Measured memory_bytes: 5760
# include "bits/stdc++.h"
using namespace std;
using LL = long long;
using ULL = unsigned long long;
const double PI = acos(-1);
template<class T>constexpr T INF() { return ::std::numeric_limits<T>::max(); }
template<class T>constexpr T HINF() { return INF<T>() / 2; }
template <typename T_char>T_char TL(T_char cX) { return tolower(cX); };
template <typename T_char>T_char TU(T_char cX) { return toupper(cX); };
typedef pair<LL, LL> pii;
const int vy[] = { -1, -1, -1, 0, 1, 1, 1, 0 }, vx[] = { -1, 0, 1, 1, 1, 0, -1, -1 };
const int dx[4] = { 0,1,0,-1 }, dy[4] = { 1,0,-1,0 };
int popcnt(unsigned long long n) { int cnt = 0; for (int i = 0; i < 64; i++)if ((n >> i) & 1)cnt++; return cnt; }
int d_sum(LL n) { int ret = 0; while (n > 0) { ret += n % 10; n /= 10; }return ret; }
int d_cnt(LL n) { int ret = 0; while (n > 0) { ret++; n /= 10; }return ret; }
LL gcd(LL a, LL b) { if (b == 0)return a; return gcd(b, a%b); };
LL lcm(LL a, LL b) { LL g = gcd(a, b); return a / g*b; };
# define ALL(qpqpq)           (qpqpq).begin(),(qpqpq).end()
# define UNIQUE(wpwpw)        sort(ALL((wpwpw)));(wpwpw).erase(unique(ALL((wpwpw))),(wpwpw).end())
# define LOWER(epepe)         transform(ALL((epepe)),(epepe).begin(),TL<char>)
# define UPPER(rprpr)         transform(ALL((rprpr)),(rprpr).begin(),TU<char>)
# define FOR(i,tptpt,ypypy)   for(LL i=(tptpt);i<(ypypy);i++)
# define REP(i,upupu)         FOR(i,0,upupu)
# define INIT                 std::ios::sync_with_stdio(false);std::cin.tie(0)

map<int, int> mp;
int n;

void add(int i){
    int so = 2;
    while(i != 1){
        if(i%so == 0){
            mp[so]++;
            i /= so;
        }else{
            so++;
        }
    }
    return;
}

int main(){
    INIT;
    cin >> n;
    for(int i = 2;i <= n;i++){
        add(i);
    }
    int ans = 0;
    for(int i = 1;i <= n;i++){
        if(mp[i] == 0)continue;
        for(int j = 1;j <= n;j++){
            if(mp[j] == 0)continue;
            for(int k = j + 1;k <= n;k++){
                if(mp[k] == 0)continue;
                if(i == j || i == k)continue;
                if(mp[i] >= 2 && mp[j] >= 4 && mp[k] >= 4)ans++;
            }
            if(i == j)continue;
            if(mp[i] >= 24 && mp[j] >= 2)ans++;
            if(mp[i] >= 14 && mp[j] >= 4)ans++;
        }
        if(mp[i] >=74)ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long res, i,sum=0,n,m,ct=0;
    cin>>n>>m;
    long long ar[n],br[n],cr[n];
    for(i=0;i<n;i++)cin>>ar[i]>>br[i];
    sort(ar,ar+n);
    sort(br,br+n);
    int r=lower_bound(br,br+n,ar[n-1])-br;
    if(r>=n)r=r-1;

        for(i=n-1;i>=r;i--)
        {
            sum=sum+br[i];
            ct++;
            if(sum>=m)
            {
                cout<<ct<<endl;
                return 0;
            }
        }
            
            while(sum<m)
            {
                sum+=ar[n-1];
                ct++;
                
            }
            cout<<ct<<endl;
            //else cout<<i+res-1<<endl;



    return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int a;
  cin >> a;
  int b = a%2;
  int c = ((a-b) /10) % 2;
  int d = (((a-b)/10)-c)/10 % 2;
  cout << b+c+d << endl;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
using Int = long long int;
template<typename T> void swap(T *t1, T *t2){ T* tmp=t1; t1=t2; t2=tmp;}
Int tmp = 0;


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

    Int n, a, b;
    cin >> n >> a >> b;

    if(a*n > b){
        cout << b << endl;
    }else{
        cout << a*n << endl;
    }

    return 0;
}

Measured memory_bytes: 256
# AOJ 0099 Surf Smelt Fishing Contest II
# Python3 2018.6.22 bal4u

import heapq
MAX = 1000000
SFT = 20	# 2**20 = 1048576 > MAX
Q = []

# tbl[0:キー, 1:Magic]
n, q = list(map(int, input().split()))
tbl = [0]*(n+1)
for i in range(q):
	id, v = list(map(int, input().split()))
	tbl[id] += v
	heapq.heappush(Q, ((-tbl[id] << SFT)|id, id, tbl[id]))
	while 1:
		f, id, v = Q[0]       # 要素の確認のみ
		if tbl[id] == v:
			print(id, v)
			break
		heapq.heappop(Q)


Measured memory_bytes: 27724
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define ft first
#define sd second
#define fr(i,n) for(int i=0;i<(n);++i)
#define Fr(i,n) for(int i=1;i<=(n);++i)
#define ifr(i,n) for(int i=(n)-1;i>=0;--i)
#define iFr(i,n) for(int i=(n);i>0;--i)

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n;
    cin>>n;
    vector<int> a(n);
    for(auto&i:a) cin>>i;
    sort(a.begin(),a.end());
    if(n%3==0){
        if(a[0]==a[n/3-1]&&a[n/3]==a[(n/3)*2-1]&&a[(n/3)*2]==a[n-1]&&(a[0]^a[n/3])==a[n-1]) cout<<"Yes"<<endl;
        else cout<<"No"<<endl;
    }
    if(n%3==1){
        if(a[0]==a[n/3-1]&&a[0]==0&&a[n/3]==a[n-1]) cout<<"Yes"<<endl;
        else cout<<"No"<<endl;
    }
    if(n%3==2){
        if(a[0]==a[n/3]&&a[0]==0&&a[n/3+1]==a[n-1]) cout<<"Yes"<<endl;
        else cout<<"No"<<endl;
    }
}

Measured memory_bytes: 768
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int[][][] ink = 
			{
				{
					{0,0,0,0,0},
					{0,0,1,0,0},
					{0,1,1,1,0},
					{0,0,1,0,0},
					{0,0,0,0,0}
				},
				{
					{0,0,0,0,0},
					{0,1,1,1,0},
					{0,1,1,1,0},
					{0,1,1,1,0},
					{0,0,0,0,0}
				},
				{
					{0,0,1,0,0},
					{0,1,1,1,0},
					{1,1,1,1,1},
					{0,1,1,1,0},
					{0,0,1,0,0}
				}
			};
		int[][] paper = new int[14][14];
		while(sc.hasNext()) {
			String s = sc.next();
			String[] sp = s.split(",");
			int x = Integer.valueOf(sp[0]);
			int y = Integer.valueOf(sp[1]);
			int size = Integer.valueOf(sp[2])-1;
			for(int i=0;i<5;i++) {
				for(int j=0;j<5;j++) {
					paper[x+i][y+j]+=ink[size][i][j];
				}
			}
		}
		int empty = 0;
		int max = 0;
		for(int i=2;i<12;i++) {
			for(int j=2;j<12;j++) {
				if (paper[i][j] == 0) {
					empty++;
				}
				max = Math.max(max,paper[i][j]);
			}
		}
		System.out.println(empty + "\n" + max);
	}

}

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

int main() { 
    int n,t,a;
    cin >> n >> t >> a;
    vector<int> h(n);
    vector<double> tem(n);
    double mindif = 1000;
    int ans = -1;
    rep(i, n){
        cin >> h[i];
        tem[i] = t - h[i] * 0.006;
        mindif = min(mindif,abs(tem[i] - a));
        if(mindif == abs(tem[i] - a)) ans = i + 1;
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using lli = long long;
using pii = pair<int, int>;

#define rep(i,k,n) for(int i=(k); i != int(n); ++i)
#define sz(x) x.size()
#define all(x) x.begin(), x.end()

#define dbg(x) cout << #x << '=' << x << '\n'
#define dbg2(x, y) cout << #x << '=' << x << ' ' << #y << '=' << y << '\n' 

#define input() (*istream_iterator<lli>(cin))
#define strin() (*istream_iterator<string>(cin))
#define output(x) cout << x << '\n' 

const int mxn = 2e5+10;
lli arr[mxn];
bool is_visit[mxn];
int find_loop(int cur = 1){
    is_visit[cur] = true;
    int nx = arr[cur];
    if(is_visit[nx]) return nx;
    return find_loop(nx);
}
int main(){
    ios::sync_with_stdio(false);
    lli n = input(), k = input();
    vector<int> cycle;
    int cur = 1, dist = 0;
    for(int i = 1; i <= n; ++i) arr[i] = input();
    int loop_town = find_loop();
    //dbg(loop_town);
    while(cur != loop_town){
        cur = arr[cur];
        dist++;
        if(dist == k){
            cout << cur;
            return 0;
        }
    }
    //dbg(dist);
    k -= dist;
    cur = arr[loop_town];
    cycle.push_back(loop_town);
    while(cur != loop_town){
        cycle.push_back(cur);  
        cur = arr[cur];  
    }
    //for(int cur: cycle) cout << cur;
    k%=cycle.size();
    cout << cycle[k];

}

Measured memory_bytes: 5860
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long int n,m,i,r,s=0,b,c,j;
    scanf("%lld",&n);
    long long int a[n+10];
    long long int ar[100001]={0};
    for(i=0;i<n;i++){
        cin>>a[i];
        s+=a[i];
        ar[a[i]]++;
    }
    cin>>m;
    long long int f[m+10];
    for(i=0;i<m;i++){
        cin>>b>>c;
        s+=(c-b)*ar[b];
        ar[c]+=ar[b];
        ar[b]=0;
        cout<<s<<endl;
    }

}


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

int main() {
    int n;
    cin >> n;
    while (n--) {
        int y, m, d;
        cin >> y >> m >> d;

        ll now = d;
        for (int i = 1; i < y; ++i) {
            if (i % 3 == 0)
                now += 200;
            else
                now += 195;
        }

        rep(i, m - 1) now += 19;
        now += m / 2;
        if (y % 3 == 0) now += m - 1 - m / 2;

        cout << 196471 - now << "\n";
    }

    return 0;
}


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

using namespace std;

int main(){
        int N;
        cin>>N;
        vector <int> t(N), x(N), y(N);
        for(int i=0;i<N;i++){
                cin>>t[i]>>x[i]>>y[i];
        }
        for(int i=1;i<N;i++){
                x[i]=abs(x[i]-x[i-1]);
                y[i]=abs(y[i]-y[i-1]);
                t[i]-=t[i-1];
        }
        bool flag=true;
        for(int i=0;i<N;i++){
                int tt=x[i]+y[i];
                //cout<<tt<<":"<<t[i]<<endl;
                if(t[i]<tt){
                        flag=false;
                        break;
                }
                if((tt-t[i])%2!=0){
                        flag=false;
                        break;
                }
        }
        if(flag){
                cout<<"Yes"<<endl;
        }
        else{
                cout<<"No"<<endl;
        }
        return 0;
}


Measured memory_bytes: 1408
import java.util.Scanner;

public class Main{
  static final int MAX = 100000;
  static int n;
  static int[] l, r;

  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);

    n = sc.nextInt();
    l = new int[n];
    r = new int[n];
    for(int i = 0; i < n; i++){
      l[i] = sc.nextInt() - 1;
      r[i] = sc.nextInt() - 1;
    }

    int[] seat = new int[MAX + 1];
    for(int i = 0; i < n; i++){
      seat[l[i]]++;
      seat[r[i] + 1]--;
    }

    int sum = 0;
    int status = 0;
    for(int i = 0; i < MAX; i++){
      status += seat[i];
      if(status > 0){
        ++sum;
      }
    }

    System.out.println(sum);
  }
}


Measured memory_bytes: 25968
#include <algorithm>
#include <bits/stdc++.h>
#include<iostream>
#include<string>
using namespace std;
#define rep(i, n) for (int i = 0; i <(int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define ll long long
int main(){
    ll n;cin>>n;
    map<int,int>map;
    int count=0;
    int ans=0;
    ll a[n];rep(i,n){
        cin>>a[i];
        map[a[i]-1]++;
        map[a[i]]++;
        map[a[i]+1]++;
    }
    for(auto p:map){
        ans=max(ans,p.second);
    }
    cout<<ans<<endl;
    
}

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

int main() {
    string s, t;
    cin >> s >> t;
    sort(s.begin(), s.end());
    sort(t.begin(), t.end());
    reverse(t.begin(), t.end());
    if (s < t) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
import sys

n = int(input())
r0 = int(input())
r1 = int(input())
mx = r1-r0
mn = min(r1,r0)

for i in map(int,sys.stdin.readlines()):
    if mx < i - mn:
        mx = i - mn
    elif mn > i:
        mn = i

print(mx)

Measured memory_bytes: 21840
#include<stdio.h>

#define LENGTH 100000

typedef struct node{
    char name[11];
    int rtime;
}Process;

Process queue[LENGTH];
int head;
int elem_num;

void enqueue(Process in){
    queue[(head+elem_num)%LENGTH] = in;
    elem_num++;
}

Process dequeue(void){
    Process ans;
    ans = queue[head];
    head++;
    head = head%LENGTH;
    elem_num--;
    return ans;
}

int isEmpty(void){
    if(elem_num == 0) return 1;
    else return 0;
}

int main(void){
    int n,q;
    int i;
    int time = 0;
    Process in;
    scanf("%d %d", &n, &q);
    
    for(i =0; i<n; i++){
        scanf("%s %d", in.name, &(in.rtime));
        enqueue(in);
    }
    
    while(!isEmpty()){
        in = dequeue();
        if(in.rtime - q <= 0){
            time += in.rtime;
            printf("%s %d\n", in.name, time);
        }
        else{
            in.rtime -= q;
            time += q;
            enqueue(in);
        }
    }
    
    return 0;
}

Measured memory_bytes: 2156
#include <stdio.h>
int n, m, i, j, k;
char s[105];
int main(){
	scanf("%d%s", &n, s);
	if(s[n]){
		s[n] = s[n+1] = s[n+2] = '.';
		s[n+3] = 0;
	}
	printf("%s\n", s);
	return 0;
}

Measured memory_bytes: 1640
#include<bits/stdc++.h>                                                                                               
using namespace std;
 
#define rep(i,n) for(int i=0;i<(n);++i)
#define reps(i,n) for(int i=1;i<=(n);++i)
#define all(x) (x).begin(),(x).end()
#define int long long
#define mk_p(a,b)   make_pair((a),(b))
using pii = pair<int,int>;
constexpr int INF  = 0x3f3f3f3f;
constexpr long long LINF = 0x3f3f3f3f3f3f3f3fLL;

signed main(){
    string s;
    cin >> s;
    int n = s.size(),cnt = 0;
    bool flg = false;
    rep(i,n){
        if(flg){
            if(s[i] == s[i-1]){
                if(i == n-1){
                    break;
                }
                i++;
                cnt++;
                flg = false;
            }
            else cnt++;
        }
        else{
            cnt++;
            flg = true;
        }
    }   
    cout << cnt << '\n';
    return 0;
}


Measured memory_bytes: 640
#include <string>
#include <vector>
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<stack>
#include<queue>
#include<cmath>
#include<algorithm>
#include<functional>
#include<list>
#include<deque>
#include<bitset>
#include<set>
#include<map>
#include<unordered_map>
#include<cstring>
#include<sstream>
#include<complex>
#include<iomanip>
#include<numeric>
#include<cassert>
#define X first
#define Y second
#define pb push_back
#define rep(X,Y) for (int (X) = 0;(X) < (Y);++(X))
#define reps(X,S,Y) for (int (X) = S;(X) < (Y);++(X))
#define rrep(X,Y) for (int (X) = (Y)-1;(X) >=0;--(X))
#define repe(X,Y) for ((X) = 0;(X) < (Y);++(X))
#define peat(X,Y) for (;(X) < (Y);++(X))
#define all(X) (X).begin(),(X).end()
#define rall(X) (X).rbegin(),(X).rend()
#define eb emplace_back
#define UNIQUE(X) (X).erase(unique(all(X)),(X).end())

using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
template<class T> using vv=vector<vector<T>>;
template<class T> ostream& operator<<(ostream &os, const vector<T> &t) {
os<<"{"; rep(i,t.size()) {os<<t[i]<<",";} os<<"}"<<endl; return os;}
template<class S, class T> ostream& operator<<(ostream &os, const pair<S,T> &t) { return os<<"("<<t.first<<","<<t.second<<")";}
template<class T> inline bool MX(T &l,const T &r){return l<r?l=r,1:0;}
template<class T> inline bool MN(T &l,const T &r){return l>r?l=r,1:0;}
const ll MOD=1e9+7;

int main(){
  ios_base::sync_with_stdio(false);
  cout<<fixed<<setprecision(0);
  int n;
  cin>>n;
  vector<int> a(n);
  rep(i,n) cin>>a[i];
  sort(rall(a));
  a.pb(0);
  //cout<<a;
  int d;
  rep(i,n){
    if(a[i]==i+1){
      //cout<<"yoko"<<endl;
      for(d=0;a[i]==a[i+1];++i) ++d;
      break;
    }else if(a[i]!=a[i+1]){
      if(a[i+1]==i+1){
	int f1=0,f2=0;
	if((a[i]-a[i+1])%2){
	  //cout<<"bokoA"<<endl;
	  f1=1;
	}else{
	  //cout<<"bokoB"<<i<<endl;
	  for(++i;a[i]==a[i+1];++i) ++f2;
	  f2=1-f2%2;
	}
	//d=1;
	  d=f1||f2;
	break;
      }else if(a[i+1]<i+1){
	//cout<<"tate"<<endl;
	d=a[i]-(i+1);
	break;
      }
    }
  }
  //cout<<d<<endl;
  cout<<(d%2?"First":"Second")<<endl;
  return 0;
}


Measured memory_bytes: 1024
import java.util.Scanner;

class Main{
      public static void main(String[] args){
    	Scanner scan = new Scanner(System.in);
    	Dice dice1 = new Dice();
    	int v = 0;
    	int up;
    	int front;
    	
    	for(int i = 0; i < 6; i++){
    		dice1.S[i] = scan.nextInt();
    	}
    	
    	int qustion = scan.nextInt();
    	
    	for(int j = 0; j < qustion; j++){
    		up = scan.nextInt();
    		front = scan.nextInt();
			if(up == dice1.S[0]){
				if(front == dice1.S[1])  v = dice1.S[2];
				else if(front == dice1.S[2]) v = dice1.S[4];
				else if(front == dice1.S[3]) v = dice1.S[1];
				else if(front == dice1.S[4]) v = dice1.S[3];
			}else if(up == dice1.S[1]){
				if(front == dice1.S[0])  v = dice1.S[3];
				else if(front == dice1.S[2]) v = dice1.S[0];
				else if(front == dice1.S[3]) v = dice1.S[5];
				else if(front == dice1.S[5]) v = dice1.S[2];
			}else if(up == dice1.S[2]){
				if(front == dice1.S[0])  v = dice1.S[1];
				else if(front == dice1.S[1]) v = dice1.S[5];
				else if(front == dice1.S[4]) v = dice1.S[0];
				else if(front == dice1.S[5]) v = dice1.S[4];
			}else if(up == dice1.S[3]){
				if(front == dice1.S[0])  v = dice1.S[4];
				else if(front == dice1.S[1]) v = dice1.S[0];
				else if(front == dice1.S[4]) v = dice1.S[5];
				else if(front == dice1.S[5]) v = dice1.S[1];
			}else if(up == dice1.S[4]){
				if(front == dice1.S[0])  v = dice1.S[2];
				else if(front == dice1.S[2]) v = dice1.S[5];
				else if(front == dice1.S[3]) v = dice1.S[0];
				else if(front == dice1.S[5]) v = dice1.S[3];
			}else{
				if(front == dice1.S[1])  v = dice1.S[3];
				else if(front == dice1.S[2]) v = dice1.S[1];
				else if(front == dice1.S[3]) v = dice1.S[4];
				else if(front == dice1.S[4]) v = dice1.S[2];
			}
			System.out.println(v);
    	}	    	
     }
}

class Dice{
	int[] S = new int[6];
}

Measured memory_bytes: 26192
import heapq
n,a,b= map(int,input().split())
h =[int(input()) for i in range(n)]
h.sort()
p = a-b
def c(w):
    #w de umakuikkuka
    k = 0
    for i in range(n):
        l[i] = l[i]-b*w
        if l[i] > 0:
            k += l[i]//p
            if l[i] % p != 0:
                k += 1
    if w >= k:
        return True

s = 0
f = 10**12
while f-s >=2:
    m = (f+s)//2
    l = h[::]
    if c(m):
        f = m
    else:
        s = m
l = h[::]
if c(s):
    print(s)
else:
    print(f)

Measured memory_bytes: 12700
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
 
public class Main {
 
    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(
            new InputStreamReader(System.in));
        String[] data = br.readLine().split(" ");
        int a = Integer.parseInt(data[0]);
        int b = Integer.parseInt(data[1]);

        System.out
            .println((a / b) + " " + (a % b) + " "
                + String.format("%.5f", ((double) a / (double) b)));
    }
}

Measured memory_bytes: 24892
#include <iostream>
#include <cstdio>
#include <string>
#include <cstdlib>
#include <vector>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <stdlib.h>
#include <cmath>
#include <map>
using namespace std;
long long INF = 1000000009;
map<int, int> mp;
int main()
{
	int n;
	cin >> n;
	int tmp = (n + 110) / 111;
	cout << tmp * 111 << endl;
}

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

long long t[101][1000001];

using namespace std;

void Knapsack(vector<long long> wt, vector<long long> val, long long w, long long n)
{
	if(w == 0 || n == 0)
	{
		return;
	}

	for(int i = 1; i < n + 1; i ++)
	{
		for(int j = 1; j < w + 1; j ++)
		{
			if(wt[i - 1] <= j)
			{
				t[i][j] = max(val[i - 1] + t[i - 1][j - wt[i - 1]], t[i - 1][j]);
			}

			else{
				t[i][j] = t[i - 1][j];
			}
		}
	}
}


int main()
{
	int n,w;

	cin >> n;
	cin >> w;

// 	memset(t, -1, sizeof(t));

	vector<long long> wt(n);
	vector<long long> val(n);

	for(int i = 0; i < n; i++)
	{
	    cin >> wt[i] >> val[i];
    }

	for(int i = 0; i < n + 1; i++)
	{
		for(int j = 0; j < w + 1; j++)
			{
				if(i == 0 || j == 0)
				{
					t[i][j] = 0;
				}
			}

	}

	Knapsack(wt, val, w, n);

	cout << t[n][w];
}

Measured memory_bytes: 82740
#include <bits/stdc++.h>
#define ll long long 
#define rep(i,a,n) for(int i=a;i<n;i++)
#define pb push_back
#define endl "\n"
#define dd double
const int INF = INT_MAX;
#define all(x) x.begin(),x.end()
#define mod 1000000007
using namespace std;
int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
  ll n;
  cin>>n;
  set<string>v;
  rep(i,0,n)
  {
    string s;
    cin>>s;
    v.insert(s);
  }
  cout<<v.size()<<endl;

  
}

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

int main() {
    long n, ans;
    cin >> n;
    vector<long> a(n), b(n);
    rep(i, n) cin >> a.at(i) >> b.at(i);
    sort(a.begin(), a.end());
    sort(b.begin(), b.end());
    if(n % 2) {
        ans = b.at(n / 2) - a.at(n / 2) + 1;
    } else {
        ans = b.at(n / 2 - 1) + b.at(n / 2) - a.at(n / 2 - 1) - a.at(n / 2) + 1; 
    }
    cout << ans << endl;
}

Measured memory_bytes: 6372
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <cmath>
#include <numeric>
#include <vector>
#include <set>
#include <map>
#include <cstring>
#include <stack>
#include <unordered_map>
#define lld long long int
#define DBG1(vari1) cerr<<#vari1<<" = "<<(vari1)<<endl;
#define DBG2(vari1,vari2) cerr<<#vari1<<" = "<<(vari1)<<" "<<#vari2<<" = "<<(vari2)<<endl;
#define DBG3(vari1,vari2,vari3) cerr<<#vari1<<" = "<<(vari1)<<" "<<#vari2<<" = "<<(vari2)<<" "<<#vari3<<" = "<<(vari3)<<endl;
using namespace std;
lld MOD = 1e9+7;
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	lld res=1;
	lld n;
	cin >> n;
	for(int i=1;i<=n;i++)
	{
		res=((res%MOD)*(i%MOD))%MOD;
	}
	cout << res;
}

Measured memory_bytes: 256
n = int(input())

data = list(map(int,input().split()))

odd = [data[i] for i in range(0,n,2)]
even = [data[i] for i in range(1,n,2)]

odd_dict = dict({})
even_dict = dict({})

for i in range(n//2):
    if odd_dict.__contains__(odd[i]):
        odd_dict[odd[i]]+=1
    else:
        odd_dict[odd[i]] = 1
    if even_dict.__contains__(even[i]):
        even_dict[even[i]]+=1
    else:
        even_dict[even[i]] = 1

odd = sorted(odd_dict.items(), key=lambda d:d[1],reverse=True)
even = sorted(even_dict.items(), key=lambda d:d[1],reverse=True)

odd.append((0,0))
even.append((0,0))
if odd[0][0] == even[0][0]:
    print(min(n-odd[0][1]-even[1][1],n-odd[1][1]-even[0][1]))
else:
    print(n-odd[0][1]-even[0][1])


Measured memory_bytes: 21244
#include <iostream>
#include <string>
using namespace std;
int main(int argc, char *argv[])
{
	string 	s;
	cin>>s;
	long long n,k=0,c=0;
	cin>>n;
	if(s.size()==1)cout<<s;
	else {
			for(int i=0;i<n;i++)
			if(s[i]=='1')c++;
			else{
				k=s[i]-'0';break;
			}
			if(c>=n)cout<<1<<'\n';
		else cout<<k<<'\n';
	}
	
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <cstdio>
using namespace std;

typedef pair<int,int> P;

int rnk[200000],par[200000];

void init(int n){
	for(int i = 0;i < n;i++){
		rnk[i] = 0;
		par[i] = i;
	}
}

int find(int x){
	if(par[x] == x) return x;
	return par[x] = find(par[x]);
}

void unite(int x,int y){
	x = find(x);
	y = find(y);
	if(x == y) return;
	if(rnk[x] < rnk[y]){
		par[x] = y;
	}else{
		par[y] = x;
		if(rnk[x] == rnk[y]) rnk[x]++;
	}
}

int main(){
	int n,k,l,a[200000];
	vector<P> vec;
	cin >> n >> k >> l;
	init(n);
	for(int i = 0;i < k;i++){
		int u,v;
		cin >> u >> v; u--; v--;
		unite(u,v);
	}
	for(int i = 0;i < n;i++) a[i] = find(i);
	init(n);
	for(int i = 0;i < l;i++){
		int u,v;
		cin >> u >> v; u--; v--;
		unite(u,v);
	}
	for(int i = 0;i < n;i++) vec.push_back(P(a[i],find(i)));
	sort(vec.begin(),vec.end());
	for(int i = 0;i < n;i++){
		if(i) printf(" ");
		printf("%d",upper_bound(vec.begin(),vec.end(),P(a[i],find(i))) - lower_bound(vec.begin(),vec.end(),P(a[i],find(i))));
	}
	puts("");
	return 0;
}

Measured memory_bytes: 4724
num_slimes = gets.chomp.to_i
slimes_colors = gets.chomp
previous_slime_color = ""
num_fusioned_slimes = 0
slimes_colors.each_char do |char|
    if previous_slime_color != char
        num_fusioned_slimes += 1
        previous_slime_color = char
    end
end

puts num_fusioned_slimes

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

//#define int long long
typedef long long ll;
//const int INF = 2e9;
//const ll INF = 9e18;


signed main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    string s;
    cin >> s;
    int n = s.size();
    int ans = 0;
    char me = 'g';
    for (int i=0;i<n;i++){
        if (s[i] == 'g' && me == 'p') ans++;
        else if (s[i] == 'p' && me == 'g') ans--;
        if (me == 'g') me = 'p';
        else me = 'g';
    }
    cout << ans << "\n";
}

Measured memory_bytes: 3772
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset

using namespace std;

int main() {

	long n,k,sum=0;

	char s[100001];

	cin >> n >> k;

	for (int i = 0; i < n; i++) {
		cin >> s[i];
	}
	for (int i = 0; i < n; i++) {
		if (s[i] == s[i + 1])sum++;

	}

	sum = sum + k * 2;
	if (sum > n - 1)sum = n - 1;

	cout << sum << endl;

	return 0;
}


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

int main(){
    string s,t,u;
    int a,b;
    cin >> s >> t ;
    cin >> a >> b ;
    cin >> u ;
    if (s==u){
        --a;
    }
    else {
        --b;
    }
    printf("%d %d",a,b);

    

    return 0;
}

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

#define debug(x) cerr<<#x<<'='<<x<<endl
#define set0(x) memset(x,0,sizeof(x))
using namespace std;
typedef long long ll;
typedef pair<ll,ll> pii;
template<typename T> void read(T &x){
	x = 0;char ch = getchar();ll f = 1;
	while(!isdigit(ch)){if(ch == '-')f*=-1;ch=getchar();}
	while(isdigit(ch)){x = x*10+ch-48;ch=getchar();}x*=f;
}
template<typename T, typename... Args> void read(T &first, Args& ... args) {
	read(first);
	read(args...);
}

int H,W,N,x,y;
int cmi[200020];
int main() {
	read(W,H,N);
	for(int i=1;i<=W;i++)cmi[i] = H+1;
	for(int i=0;i<N;i++){
		read(x,y);
		cmi[x] = min(cmi[x],y);
	}
	int cv = 1;
	for(int i=1;i<=W;i++){
		if(cmi[i] > cv)cv+=1;
		if(cmi[i] < cv){
			cout<<i-1<<endl;
			return 0;
		}
	}
	cout<<W<<endl;
	return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define ll  long long int 
#define pb push_back
#define mk make_pair
using namespace std;
int gcd(int a,int b){
    if(b==0)
     return a;
    return gcd(b,a%b);
}
int main(){
   ll a,b,c,d;
   cin>>a>>b>>c>>d;
   ll ans=INT64_MIN;
   ans=max(a*c,ans);
   ans=max(a*d,ans);
   ans=max(b*c,ans);
   ans=max(b*d,ans);
   cout<<ans<<endl;
}

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


int n;
vector<vector<int>> v(1010);
int x[1010];
bool used[1010];
bool pos = true;

array<int,2> dfs(int p){
    used[p] = 1;
    vector<array<int,2>> a;
    int ret = 0;
    int sum = 0;
    for(auto i:v[p]){
        if(!used[i]){
            array<int,2> get = dfs(i);
            a.push_back(get);
            if(get[0] > x[p] && get[1] > x[p]) pos = false;
            sum += get[0] + get[1];
        }
    }
    ret = sum;
    if(a.size()){
        int m = a.size();
        bool dp[m+1][x[p]+1]={};
        dp[0][0] = 1;
        for(int i=0;i<m;i++){
            for(int j=0;j<=x[p];j++){
                if(j + a[i][0] <= x[p]) dp[i+1][j+a[i][0]] |= dp[i][j];
                if(j + a[i][1] <= x[p]) dp[i+1][j+a[i][1]] |= dp[i][j];
            }
        }
        bool ok = false;
        for(int i=0;i<=x[p];i++){
            if(dp[m][i]) ret = min(ret,sum-i),ok=1;
        }
        if(!ok) pos = false;
    }
    return {x[p],ret};
}

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(20);
    

    cin>>n;
    for(int i=1;i<n;i++){
        int a;
        cin>>a;
        a--;
        v[i].push_back(a);
        v[a].push_back(i);
    }
    for(int i=0;i<n;i++){
        cin>>x[i];
    }
    dfs(0);
    if(pos){
        cout << "POSSIBLE\n";
    }
    else cout << "IMPOSSIBLE\n";
}

Measured memory_bytes: 640
import java.io.*;
class Main{
    static int heapSize;
    static long[] heapTree;

    public static void main(String[] args){
	BufferedReader bin = new BufferedReader(new InputStreamReader(System.in));
	String line = new String();
	StringBuffer returned = new StringBuffer("");

	//read Tree
	try{
	    line = bin.readLine();
	}
	catch(IOException e){
	    System.out.println("Error");
	}
	heapSize=Integer.parseInt(line);
	heapTree = new long[heapSize+1];
	heapTree[0]=-1;
	try{
	    line=bin.readLine();
	}
	catch(IOException e){
	    System.out.println("Error");
	}

	//make Tree
	String[] key = line.split(" ");
	for(int i=1; i<heapTree.length; i++){
	    heapTree[i]=Long.parseLong(key[i-1]);
	}

	//buildMaxHeap
	for(int j = (heapSize+1)/2; j>=1; j--)maxHeapify(j);

	//print
	for(int i=1; i<heapTree.length; i++){
	    returned.append(" "+heapTree[i]);
	}
	System.out.println(returned);
    }
    

    static int getLeft(int i){
	return 2*i;
    }

    static int getRight(int i){
	return 2*i+1;
    }
    
    static void maxHeapify(int i){
	int l = getLeft(i);
	int r = getRight(i);
	int largest=1;

	if(l<=heapSize && heapTree[l]>heapTree[i])largest=l;
	else largest = i;
	if(r<=heapSize && heapTree[r]>heapTree[largest])largest=r;
	if(largest!=i){
	    long x = heapTree[i];
	    heapTree[i]=heapTree[largest];
	    heapTree[largest]=x;
	    maxHeapify(largest);
	}
    }
}

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

namespace ConsoleApp2
{

    class Program
    {
        static void Main(string[] args)
        {
            int N = int.Parse(Console.ReadLine());

            int cnt = 0;
            for(int i =1; i <= N; i++)
            {
                int len = i.ToString().Length;
                if (len % 2 == 0)
                {
                    i = i * 10 - 1;
                }
                else
                {
                    cnt++;
                }
            }
            Console.WriteLine(cnt);
        }
    }
}

Measured memory_bytes: 29872
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main(){
    int N; cin>>N;
    vector<int> A(100003,0);
    for(int i=0;i<N;i++){
        int a; cin>>a;
        A[a]++;
        A[a+1]+=1;
        A[a+2]+=1;
    }
    sort(A.begin(),A.end());
    reverse(A.begin(),A.end());
    cout<<A[0];
    return 0;
}

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

using namespace std;

using ll = int64_t;
using Vi = vector<int>;
using Vl = vector<ll>;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

constexpr int I_INF = 2147483647;
constexpr ll L_INF = 9223372036854775807LL;

//===




int main()
{
	int n;
	cin >> n;
	Vi v(n);
	for (int i = 0; i < n; ++i) {
		cin >> v[i];
	}

	unordered_map<int, int> mp1, mp2;
	mp1[0] = 0; mp2[0] = 0;
	for (int i = 0; i < n; i += 2) {
		++mp1[v[i]];
	}
	for (int i = 1; i < n; i += 2) {
		++mp2[v[i]];
	}

	vector<Pii> num1, num2;
	for (auto& p : mp1) num1.emplace_back(p.second, p.first);
	sort(num1.begin(), num1.end(), greater<Pii>());
	for (auto& p : mp2) num2.emplace_back(p.second, p.first);
	sort(num2.begin(), num2.end(), greater<Pii>());

	int ans;
	if (num1[0].second == num2[0].second) {
		int tmp1, tmp2;
		tmp1 = (n + 1) / 2 - num1[0].first + n / 2 - num2[1].first;
		tmp2 = (n + 1) / 2 - num1[1].first + n / 2 - num2[0].first;
		ans = min(tmp1, tmp2);
	}
	else {
		ans = (n + 1) / 2 - num1[0].first + n / 2 - num2[0].first;
	}

	cout << ans << endl;
}

Measured memory_bytes: 5896
#include <stdio.h>

int linearSeach(int *,int,int);

int main(){
  int S[100000];
  int T[100000];
  int N,q,i;
  int cnt=0;

  scanf("%d",&N);
  for(i=0;i<N;i++){
    scanf("%d",&S[i]);
  }

  scanf("%d",&q);
  for(i=0;i<q;i++){
    scanf("%d",&T[i]);
    if( linearSearch(S,N,T[i]) )cnt++;
  }

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

  return 0;
}

int linearSearch(int A[],int N,int key){
  int i=0;

  A[N]=key;

  while(A[i] != key){
    i++;
  }
   return i != N;
}



Measured memory_bytes: 2052
// 🐋💭
import Foundation

func readInts() -> [Int] {
    return readLine()!.split(separator: " ").map { Int($0)! }
}

func readInt() -> Int {
    return Int(readLine()!)!
}

func readDoubles () -> [Double] {
    return readLine()!.split(separator: " ").map { Double($0)! }
}

func readDouble() -> Double{
    return Double(readLine()!)!
}
///最大公約数を返す
func gcd(_ m:Int, _ n:Int) -> Int {
    if n == 0 {return m}
    return gcd(n, m % n)
}

///最大公約数を返す
func gcd(_ array: [Int]) -> Int {
    var value = array[0]
    if array.count > 1 {
        for i in 1..<array.count {
            value = gcd(value, array[i])
        }
    }
    return value
}

///最小公倍数を返す
func lcm(_ m:Int, _ n:Int) -> Int {
    return m * n / gcd(m, n)
}

///素数判定(試し割り)
func isPrime(_ x:Int) -> Bool {
    if x <= 1 || x % 2 == 0 { return false }
    if x == 2 { return true }
    for i in stride(from: 3, to: Int(ceil(sqrt(Double(x)))), by: 2){
        if x % i == 0 {
            return false
        }
    }
    return true
}

//https://program-life.com/669
///実行速度の計測
func exectionTime(action: () -> Void) {
    let startDate = Date()
    action()
    let endDate = Date()
    print(endDate.timeIntervalSince(startDate))
}

// https://melheaven.hatenadiary.jp/entry/atcoder144
///約数の配列を返す
func makeDivisors(_ n:Int) -> [Int] {
    var divisors = [Int]()
    for i in 1..<Int(pow(Double(n), 0.5)) + 1 {
        if n % i == 0{
            divisors.append(i + n / i)
        }
    }
    
    return divisors
}

//https://riptutorial.com/ja/swift/example/14738/インデックスを知らずに配列から要素を削除する
extension Array where Element: Equatable {
    
    mutating func remove(_ element: Element) {
        _ = firstIndex(of: element).flatMap {
            self.remove(at: $0)
        }
    }
}

func binarySearch(rifgt:Int, key:Int, ary:[String]) -> Int{
    var left = 0
    var right = rifgt
    
    while abs(right - left) > 1 {
        let mid = left + (right - left) / 2
        
        if Int(ary[mid])! < key {
            left = mid
            
        } else {
            right = mid
        }
    }
    return left
}

func arrangement (prev:String, ary:[String], returnVal:[String]) -> [String] {
    var returnVal = returnVal
    if ary.count == 0 {
        returnVal.append(prev)
        return returnVal
    }
    
    for s in ary {
        let wprev = prev + s
        var wary = ary
        wary.remove(s)
        returnVal = arrangement(prev: wprev, ary: wary, returnVal: returnVal)
    }
    return returnVal
}

func main() {
    let (n, aryA) = (readInt(), readInts())
    //＿＿＿＿＿＿＿＿＿＿＿＿＿＿＿＿＿＿＿＿＿＿＿＿＿＿＿＿＿＿＿＿ここまで入力
    var ans = 0
    for i in 0..<n {
        ans += aryA[i] - 1
    }
    print(ans)
}

main()


Measured memory_bytes: 13644
A,B,K = map(int,input().split())
L = []
M = []

for n in range(A,min(A+K,B+1)):
  L.append(n)
  
for n in range(max(A,B-K),B+1):
  M.append(n)
  
L = sorted(set(L[:K]+M[-K:]))
  
print(*L,sep="\n")

Measured memory_bytes: 9148
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> i_i;
typedef pair<ll, ll> l_l;
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
//const ll mod = 1000000007;

string s;
int cA,cX;
bool flg;
int main() {
    cin >> s;
    int n = s.size();

    ll ans = 0;
    int i=0;
    while(i<n) {
        if(s[i]=='A') {
            cA++;
        }
        else if (i+1<n && s[i]=='B' && s[i+1]=='C') {
            i++;
            ans += cA;
        } 
        else {
            cA = 0;
        }
        i++;
    }
    cout << ans << endl;

}

Measured memory_bytes: 640
n = gets.to_i
hash = {}
n.times do
  str = gets.chomp
  if hash[str].nil?
    hash[str] = 1
  else
    hash[str] += 1
  end
end

puts "AC x #{hash["AC"] || 0}"
puts "WA x #{hash["WA"] || 0}"
puts "TLE x #{hash["TLE"] || 0}"
puts "RE x #{hash["RE"] || 0}"


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

using namespace std;
typedef long long LL;
typedef pair<int,int> pii;

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define debug(x)  do{cerr<<#x<<": "<<x<<"\n";}while(0)
#define debugv(x) do{cerr<<#x<<": ";for(auto&e: (x))cerr<<e<<" ";cerr<<"\n";}while(0)
#define fori(i, n) for (int i = 0; i < (int)(n); ++i)
#define forn(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, n) for (int i = (int)(n); i >= 0; --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)
template<typename T> bool mmax(T &m, const T q) { if (m < q) {m = q; return true;} else return false; }
template<typename T> bool mmin(T &m, const T q) { if (m > q) {m = q; return true;} else return false; }
#define RETURN(x) do{cout << x << '\n'; return 0;}while(0)

const int MOD = 1e9+7;
const int MAXN = 1e5+5;

int main(int argc, char **argv) {
#ifdef OJ
    freopen("input.txt", "rt", stdin);
    //freopen("output.txt", "wt", stdout);
#endif
    ios::sync_with_stdio(false);
    cin.tie(0);

    int n;
    cin >> n;
    vector<double> x(n), y(n);
    double X,Y;
    fori(i,n) {
        cin >> x[i] >> y[i];
        X += x[i];
        Y += y[i];
    }
    X /= n;
    Y /= n;

    auto dist = [&](double a, double b) {
        return a*a + b*b;
    };

    double P = 0.1;
    double d;
    fori(i,30000) {
        int f = 0;
        d = dist(X-x[0], Y - y[0]);
        fore(j,1,n-1) {
            double e = dist(X-x[j], Y-y[j]);
            if(d < e) {
                d = e;
                f = j;
            }
        }

        X += (x[f] - X)*P;
        Y += (y[f] - Y)*P;
        P *= 0.999;
    }

    double ans = sqrt(d);
    cout << fixed << setprecision(8) << ans << endl;
    return 0;
}


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

const int SIZE = 3e3 + 5;

int DP[SIZE][SIZE];
char z[SIZE][SIZE];

string B = "0", A = "0", K = "0", P, Q;

void read(){
    cin >> P >> Q;
    A+= P; B += Q;
}

void COUNT_LCS(){
    for (int i = 1; i <= A.size()-1; i++)
        for (int j = 1; j <= B.size()-1; j++)
        {
            if(A[i] == B[j])
            {
                DP[i][j] += DP[i-1][j-1]+1;
                z[i][j] = A[i];
            }
            else
            {
                if (DP[i-1][j] > DP[i][j-1])
                {
                    DP[i][j] += DP[i-1][j];
                    z[i][j] = '#';
                }
                else
                {
                    DP[i][j] += DP[i][j-1];
                    z[i][j] = '$';
                }
            }
        }
}

void odzyskaj(){
    int j = B.size()-1;
    for (int i = A.size()-1; i >= 1;)
    {
        if (z[i][j] == '#')
        {
            i--; continue;
        }
        if (z[i][j] == '$')
        {
            j--; continue;
        }
        if (z[i][j] != 0)
        {
            K += z[i][j];
            i--; j--; continue;
        }
        break;
    }
}

void RESULT(){
    for (int i = K.size()-1; i>= 1; i--)
        cout << K[i];
}

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);             cout.tie(0);
    
    read();
    COUNT_LCS(); 
    odzyskaj(); 
    RESULT();
}


Measured memory_bytes: 44288
#include <algorithm>
#include <cassert>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <vector>

#include <limits.h>

using namespace std;

typedef long long ll;

template<class T>
inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}

template<class T>
inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}

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

    int pay = ((N + 1000 - 1) / 1000) * 1000;
    cout << pay - N << endl;

    return 0;
}


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

  int arr[n];
  int sum=0;
  for(int i=0;i<n;i++)
  {
    cin>>arr[i];
    sum=sum+arr[i];
    
  }
  if(sum>=h)
    cout<<"Yes"<<endl;
  else
    cout<<"No"<<endl;
  
  
}

Measured memory_bytes: 3956
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <cstring>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <bitset>
#include <stack>
#include <cmath>
#include <time.h>
#include <unordered_set>
#include <unordered_map>
#define ll long long
#define LINF 0x3f3f3f3f3f3f3f3f
#define INF 0x3f3f3f3f
#define PI 3.14159265
#define RAND (rand()*rand())
#define MAX(x, y) ((x) > (y) ? (x):(y)) 
#define MIN(x, y) ((x) > (y) ? (y):(x))
#define ABS(x) ((x) > 0 ? (x) : -(x))
#define CEIL(x, y) (((x) + (y) - 1)/(y))
using namespace std;
const int MAXN = 1e5 + 5;
const ll MOD = 1e9 + 7;
int N, M, K, Q, T;

int main()
{
	int i, j;
	double L;
	scanf("%lf", &L);
	double x = L / 3.0;
	printf("%.7lf", x*x*x);
}

Measured memory_bytes: 256
import math,sys
try: sys.stdin = open('in.in','r')
except: pass

class Point:
	def __init__(self,x,y):
		self.x = x
		self.y = y
	def __add__(self,p):
		return Point(self.x+p.x,self.y+p.y)
	def __sub__(self,p):
		return Point(self.x-p.x,self.y-p.y)
	def __mul__(self,p):
		return Point(self.x*p,self.y*p)

def Dot(a,b):
	return a.x*b.x + a.y*b.y
def Cross(a,b):
	return a.x*b.y - a.y*b.x
def Dis(a,b):
	return math.sqrt( (a.x-b.x)*(a.x-b.x) + (a.y-b.y)*(a.y-b.y) )
def Dis2(a,b):
	return (a.x-b.x)*(a.x-b.x) + (a.y-b.y)*(a.y-b.y)

x0,y0,x1,y1 = map(int,input().split())
p0 = Point(x0,y0)
p1 = Point(x1,y1)
q = int(input())
for i in range(q):
	x2,y2 = map(int,input().split())
	p2 = Point(x2,y2)

	cross = Cross(p1-p0,p2-p0)
	if cross > 0:
		print('COUNTER_CLOCKWISE')
	elif cross < 0:
		print('CLOCKWISE')
	else:
		dot = Dot(p1-p0,p2-p0)
		if dot < 0:
			print('ONLINE_BACK')
		else:
			len1 = Dis2(p1,p0)
			len2 = Dis2(p2,p0)
			print( 'ONLINE_FRONT' if len1 < len2 else 'ON_SEGMENT' )



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

using ll = long long;
using ull = unsigned long long;

#define MOD 1000000007

int main(void) {
    ll N, M, X;
    vector<ll> A;
    cin >> N >> M >> X;
    A.resize(M);
    for(ll i = 0;i < M;i++) cin >> A[i];
    if(X <= A.front() || A.back() <= X) {
        cout << 0 << endl;
    } else {
        auto iter = lower_bound(A.begin(), A.end(), X);
        ll a = distance(A.begin(), iter);
        ll b = distance(iter, A.end());
        cout << min(a, b) << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vvvll = vector<vvll>;
using vs = vector<string>;
using pll = pair<ll, ll>;
using vp = vector<pll>;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repr(i, a, b) for (int i = (a); i < (b); i++)
#define ALL(a) (a).begin(), (a).end()
#define SZ(x) ((int)(x).size())
#define PRINT(V) for (auto v:(V)) {cerr << v << " ";} cerr << endl
#define dump(x) cerr << #x << " : " << (x) << endl
#define dump2(x, y) cerr << "(" << #x << ", " << #y << ") = (" << x << ", " << y << ")" << endl
inline ll GCD(ll a, ll b){return b ? GCD(b, a % b) : a;}
const ll MOD = 1000000007;
const ll INF = 100000000000000000LL;
/* END OF TEMPLATE */

/*

Example: 101100
0***** 3**5 patterns
100*** 2**1 * 3**3 patterns
1010** 2**2 * 3**2 patterns
101100 2**3 patterns

any bit (*) -> 3 patterns (a, b) = (0, 0), (1, 0), (0, 1)
1 -> 2 patterns (a, b) = (1, 0), (0, 1)
0 -> 1 pattern (a, b) = (0, 0)

*/


ll pm3[100010];
ll pm2[100010];

// pow(3, n) % MOD -> pm3
// pow(2, n) % MOD -> pm2
void pminit(){
    ll p3 = 1;
    ll p2 = 1;
    rep(i, 100010){
        pm3[i] = p3;
        pm2[i] = p2;
        p3 *= 3;
        p2 *= 2;
        p3 %= MOD;
        p2 %= MOD;
    }
}

int main(){
    cin.tie(0); ios::sync_with_stdio(false);
    pminit();
    string L;
    cin >> L;
    ll szL = SZ(L);
    ll ans = 0;
    ll cnt = 0;
    rep(i, szL){
        if(L[i] == '1'){
            ans += pm2[cnt] * pm3[szL-i-1];
            ans %= MOD;
            cnt++;
        }
    }
    ans += pm2[cnt];
    ans %= MOD;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 2048
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <bitset>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <numeric>
#include <iostream>
#include <iomanip>
#include <string>
#include <chrono>
#include <random>
#include <cmath>
#include <cassert>
#include <climits>
#include <cstring>
#include <cstdlib>
#include <functional>
#include <sstream>

using namespace std;


int main(int argc, char** argv) {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(12);

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

    auto gcd = [&](long long a, long long b) {
        while (a != 0) {
            b %= a;
            swap(a, b);
        }
        return b;
    };

    {
        long long g = 0;
        for (auto x : A) {
            g = gcd(g, x);
        }
        if (g != 1) {
            cout << "not coprime\n";
            return 0;
        }
    }

    int m = *max_element(A.begin(), A.end());
    vector<int> cnts(m + 1, 0);
    vector<int> primes;
    primes.reserve(m + 1);
    vector<int> smallestPrimes(m + 1, 1);

    for (int i = 2; i <= m; ++i) {
        if (smallestPrimes[i] == 1) {
            smallestPrimes[i] = i;
            primes.push_back(i);
        }
        for (auto p : primes) {
            long long t = p * 1LL * i;
            if (t > m) {
                break;
            }
            smallestPrimes[t] = p;
            if (i % p == 0) {
                break;
            }
        }
    }


    for (auto x : A) {
        while (x > 1) {
            int p = smallestPrimes[x];
            ++cnts[p];
            while (x % p == 0) {
                x /= p;
            }
        }
    }

    bool ok = true;
    for (int i = 2; i <= m; ++i) {
        if (cnts[i] > 1) {
            ok = false;
            break;
        }
    }
    if (ok) {
        cout << "pairwise coprime\n";
    } else {
        cout << "setwise coprime\n";
    }
    return 0;
}

Measured memory_bytes: 15288