akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <utility>
#include <iomanip>
#include <cmath>
using namespace std;
#define REP(i,n) for (int i=0;i<(n);++i)
#define rep(i,a,b) for(int i=a;i<(b);++i)
template<class T> inline bool chmin(T &a, T b){ if(a > b) { a = b; return true;} return false;}
template<class T> inline bool chmax(T &a, T b){ if(a < b) { a = b; return true;} return false;}
using ll = long long;
constexpr ll INF = 1LL << 60;
constexpr ll MOD = 1e9 + 7;


int main() {
    cin.tie(0); ios_base::sync_with_stdio(false);
    int N,L;cin>>N>>L;
    int ans = 0;
    int diff = 1e9;
    vector<pair<int,int> > v;
    REP(i,N){
        v.emplace_back(abs(L+i),L+i);
    }
    sort(v.begin(),v.end());
    for(int i=1;i<v.size();++i){
        ans += v[i].second;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
typedef int Int;
typedef pair<Int, Int> pii;
typedef pair<Int, double> pid;
typedef pair<double, double> pdd;
typedef pair<Int, pii> pip;
typedef pair<pii, Int> ppi;
typedef pair<double, Int> pdp;
typedef vector<Int> veci;
typedef vector<double> vecd;
typedef vector<int> veci;
typedef vector<ll> vecll;
typedef vector<double> vecd;
typedef vector<pii> vecpii;
typedef vector<ppi> vecppi;
typedef vector<veci> mati;
typedef vector<vecll> matll;
typedef vector<vecd> matd;
#define PB(x) push_back(x)
#define EB(x) emplace_back(x)
#define ALL(x) x.begin(),x.end()
#define SZ(x) (x).size()
#define CLR(x) memset(x,0,sizeof x)
#define pdebug() printf("%d\n",__LINE__)
#define REP(i, a, b) for(int i = (a);i <= (b);i++)
#define FORO(i, n) REP(i,0,(int)n-1)
#define FORI(i, n) REP(i,1,(int)n)
#define FORIT(i, t) for(auto i = t.begin();i != t.end();i++)
#define eps 1e-6
#define sqr(x) ((x)*(x))
#define dist(_a, _b) sqrt(sqr(_a.A-_b.A)+sqr(_a.B-_b.B))
#define norm(_a) sqrt(sqr(_a.A)+sqr(_a.B))
#define DEBUG 1
#if DEBUG
#define DUMP(a) do { std::cout << #a " = " << (a) << ", "; } while(false)
#define DUMPLN(a) do { std::cout << #a " = " << (a) << std::endl; } while(false)
#else
#define DUMP(a)
#define DUMPLN(a)
#endif
template<typename T, typename U>
inline void getMin(T &a, U b) { if (a > b) a = b; }
template<typename T, typename U>
inline void getMax(T &a, U b) { if (a < b) a = b; }
template<typename T>
vector<T> getVector(const int n) { return vector<T>(n); }
template<typename T>
vector<T> getVector(const int n, const T a) { return vector<T>(n, a); }
template<typename T>
vector<T> getEmptyVector() { return vector<T>(); }
template<typename T>
void appendAll(vector<T> &a, vector<T> b) { a.insert(a.end(), b.begin(), b.end()); }
template <class T1, class T2> ostream &operator<<(ostream &os, const pair<T1, T2> &a) { return os << "(" << a.first << ", " << a.second << ")"; };
// #define X first
// #define Y second
const int dx[4] = {1, -1, 0, 0};
const int dy[4] = {0, 0, 1, -1};
const ll MOD = 1e9 + 7;
const int MAXN = 1 << 17;
const int inf = 1 << 27;
const ll llinf = 1LL << 50;
const int NIL = -inf;
int popcount(int x) { return __builtin_popcount(x); }


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

    int N;
    cin >> N;
    matll dp(N, vecll(4));
    dp[0][0] = 8; dp[0][1] = 1; dp[0][2] = 1;
    for(int i = 1;i < N;i++) {
        dp[i][0] = dp[i - 1][0] * 8LL;
        dp[i][1] = dp[i - 1][1] * 9LL + dp[i - 1][0];
        dp[i][2] = dp[i - 1][2] * 9LL + dp[i - 1][0];
        dp[i][3] = dp[i - 1][3] * 10LL + dp[i - 1][1] + dp[i - 1][2];
        for(int j = 0;j < 4;j++) dp[i][j] %= MOD;
    }
    cout << dp[N - 1][3] << endl;
    return 0;
}


Measured memory_bytes: 73400
#include<bits/stdc++.h>
#define ll long long
#define fi first
#define se second
#define show(x) cout<<#x<<"="<<(x)<<"\n"
using namespace std;

int n;
int t[100001],x[100001],y[100001];
int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.precision(10);
    cout<<fixed;
#ifdef LOCAL_DEFINE
    FILE *stream1;
    //FILE *stream2;
    stream1=freopen("/home/aim-cpo/CLionProjects/Debug/in","r",stdin);
    //stream2=freopen("out","w",stdout);
    if(stream1== nullptr)return 0;
    //if(stream2==NULL)return 0;
#endif
    cin>>n;
    t[0]=0;
    x[0]=0;
    y[0]=0;
    for(int i=1;i<n+1;i++) {
        cin >> t[i] >> x[i] >> y[i];
    }
    for(int i=1;i<n+1;i++){
        int temp=abs(x[i]-x[i-1])+abs(y[i]-y[i-1]);
        int temp2=t[i]-t[i-1];
        int temp3=temp2-temp;
        if(temp3%2==0 && temp3>=0)continue;
        else{
            cout<<"No"<<endl;
            return 0;
        }
    }
    cout<<"Yes"<<endl;
#ifdef LOCAL_DEFINE
    cerr<<"Time elapsed: "<<1.0*clock()/CLOCKS_PER_SEC<<"s.\n";
    fclose(stream1);
    //fclose(stream2);
#endif
    return 0;
}


Measured memory_bytes: 1408
#include<iostream>
using std::cin;
using std::cout;
using std::endl;
int main() {
	std::string a;
	cin >> a;
	const char* b = a.c_str();
	if (b[2] == b[3] && b[4] == b[5]) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
	return 0;
}

Measured memory_bytes: 256
//code by lynmisakura.wish to be accepted!
#include<bits/stdc++.h>
using namespace std;

typedef long long ll;

int main(int argc, char const *argv[])
{
  char a,b;cin >> a >> b;
  if(a < b){
    cout << '<' << endl;
  }else if(a == b){
    cout << '=' << endl;
  }else{
    cout << '>' << endl;
  }
  return 0;
}

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

int main(){
  int n;
  cin >> n;
  int CMAX = 100 / 4;
  int DMAX = 100 / 7;
  for (int i = 0; i <= CMAX; i++) {
    for (int j = 0; j <= DMAX; j++) {
      if ((i * 4) + (j * 7) == n) {
        cout << "Yes" << endl;
        return 0;
      }
    }
  }
  cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 256
import sys
def solve():
    readline = sys.stdin.buffer.readline
    write = sys.stdout.buffer.write
    M, N = map(int, readline().split())
    P = [list(map(float, readline().split())) + [0] for i in range(M)]
    M2 = (1 << M)
    dp = [[0]*(N+1) for i in range(M2)]
    dp[0][N] = 1
    for state in range(1, M2):
        dps = dp[state]
        for k in range(M):
            if state & (1 << k) == 0:
                continue
            pk = P[k]
            dpk = dp[state ^ (1 << k)]
            s = 0
            for i in range(N, -1, -1):
                s += dpk[i] * (1 - pk[i])
                dps[i] = max(dps[i], s)
                s *= pk[i-1]
    write(b"%.16f\n" % dp[M2-1][0])
solve()


Measured memory_bytes: 44252
#include <iostream>
#include <set>
#include <bitset>
#include <utility>
using namespace std;
const int N=2e5+10;
bool f[N],self[N];
bool dp[N][2];
set<int> went,graph[N];
set<pair<int,bool>>in;
bitset<N>used;
bool dfs(int now,bool need){
    if(dp[now][need])return false;
    in.insert({now,need});
    if(need==f[now]&&self[now]){
        for(int i:graph[now])if(f[i]!=need){
            if(in.find({i,!need})!=in.end())return true;
            else if(dfs(i,!need))return true;
        }
    }
    if(need==f[now]){
        for(int i:graph[now])if(f[i]==need){
            if(in.find({i,!need})!=in.end())return true;
            else if(dfs(i,!need))return true;
        }
    }
    else{
        for(int i:graph[now])if(f[i]==need){
            if(in.find({i,need})!=in.end())return true;
            else if(dfs(i,need))return true;
        }
    }
    in.erase({now,need});
    dp[now][need]=true;
    return false;
}
int main(){
    int n,m,l,r;
    string s;
    cin>>n>>m>>s;
    for(int i=0;i<n;i++)f[i+1]=(s[i]=='A');
    for(int i=1;i<=n;i++)dp[i][1]=dp[i][0]=self[i]=false;
    used.reset();
    while(m--){
        scanf("%d%d",&l,&r);
        if(l==r)self[l]=true;
        else{
            graph[l].insert(r);
            graph[r].insert(l);
        }
    }
    for(int i=1;i<=n;i++)if(!dp[i][f[i]]){
        in.clear();
        if(dfs(i,f[i])){
            printf("Yes\n");
            return 0;
        }
    }
    printf("No\n");
}

Measured memory_bytes: 48512
a, b = map(int, input().split())
print(int((b-a)*(b-a+1)/2-b))
'''
(b-a)まで足す  
(b-a)(b-a+1)/2 高い方の木の高さ
(b-a)(b-a+1)/2 - b 雪が積もった高さ
'''

Measured memory_bytes: 2940
A, B, C, D = map(int, input().split())
count_takahashi = 0
count_aoki = 0

while (A - D) > 0:
    A -= D
    count_takahashi += 1

while (C - B) > 0:
    C -= B
    count_aoki += 1

if count_takahashi >= count_aoki:
    print('Yes')
else:
    print('No')


Measured memory_bytes: 9196
N, K, Q = map(int, input().split())
A = [int(input()) for i in range(Q)]
a = []

for i in range(N):
    a.append(K-Q)

for i in A:
    a[i-1] += 1
    

for i in a:
    if i <= 0:
        print("No")

    else:
        print("Yes")


Measured memory_bytes: 11784
//https://atcoder.jp/contests/abc155/tasks/abc155_a

#include <iostream>
#include <vector>
#include <string>
#include <array>
#include <algorithm>

using namespace std;

int main ()
{

    int A, B, C;

    cin >> A >> B >> C;

    if (A == B || A == C || B == C)
    {
        if (A != B || A != C || B != C)
        {
            cout << "Yes" << endl;
        } else 
        {
            cout << "No" << endl;
        }
    } else 
    {
        cout << "No" << endl;
    }

    return 0;
}

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

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

  rep(i,n) cout << s[i] << t[i];
  cout << endl;
  
  return 0;
}

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

if (S//100>=13 or S//100==0) and 0<S%100<=12:
    print("YYMM")
elif (S%100>=13 or S%100==0) and 0<S//100<=12:
    print("MMYY")
elif 0<S//100<=12 and 0<S%100<=12:
    print("AMBIGUOUS")
else:
    print("NA")

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
int main ()
{
    int n, f, d ,s;
    cin >> n >> f >> d >> s;
    int q;
    if (d%f==0)
        q=d/f;
    else
        q=d/f+1;
    int w;
    if (n%s==0)
        w=n/s;
    else
        w=n/s+1;
    if (q<=w)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
}

Measured memory_bytes: 3632
# -*- coding: utf-8 -*-
S = input()
T = input()

import collections
trans_dicts1 = collections.defaultdict(set)
trans_dicts2 = collections.defaultdict(set)
for s, t in zip(S, T):
    # if s != t:
    trans_dicts1[s].add(t)
    trans_dicts2[t].add(s)

n1 = max(map(len, trans_dicts1.values()))
n2 = max(map(len, trans_dicts2.values()))

if n1 == 1 and n2 == 1:
    print('Yes')
else:
    print('No')


Measured memory_bytes: 42060
#include "bits/stdc++.h"

using namespace std;
typedef long long ll;
#define rep(i,j,n) for (ll i = j; i < (n); i++)
#define CLR(mat,f) memset(mat, f, sizeof(mat))
#define IN(a, b, x) (a<=x&&x<b)
#define out(ans) cout << ans << endl
typedef pair<ll,ll>P;
const ll mod=1e9+7;
const int INF = 1000000;
const double PI=3.14159265359;

int main(){

  ll n,p;cin>>n>>p;
  ll a[n];
  ll sum=0;
  bool e=true;
  rep(i,0,n){
    cin>>a[i];
    if(a[i]%2!=0)e=false;
    sum+=a[i];
  }
  ll ans=0;
  if(e&&p==0)ans=pow(2,n);
  else if(e&&p==1)ans=0;
  else ans=pow(2,n-1);

  out(ans);




  // ll ans=0;
  // rep(bit,0,1<<n){
  //   ll sum=0;
  //   rep(i,0,n){
  //     if(bit&(1<<i)){
  //       sum+=a[i];
  //     }
  //   }
  //   if(sum%2==p)ans++;
  // }

  // out(ans);

  return 0;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
#define l1 long long int
using namespace std;
/*
l1 max(l1 a, l1 b){
	if(a>b) return a;
	else return b;
}
*/

int main(){
	l1 a,b,c,d;
	cin>>a>>b>>c>>d;
	l1 s[4];
    s[0]=a*c;
	s[1]=a*d;
	s[2]=b*c; s[3]=b*d;
	
	sort(s, s+4);
	cout<<s[3]<<endl;
}

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

#define PI 3.1415926535897932
#define MOD 1000000007
#define INF 1e9

#define REP(i, n) for(int i = 0; i < (n); i++)
#define FOR(i, start, end) for(int i = (start); i < (end); i++)
#define ALL(v) (v).begin(), (v).end()

using namespace std;

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


void solve()
{
    string s; cin >> s >> s;
    cout << "A" << s[0] << "C" << endl;
}

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

    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main() {
    long int max, min, sum;
    int i, n;
    
    scanf("%d", &n);
    
    long int a[n + 1];
    
    for(i = 0; i < n; i++) {
        scanf("%ld", &a[i]);    
    }
    
    sum = 0;
    max = min = a[0];
    
    for(i = 0; i < n; i++) {
        if(min > a[i]) {
            min = a[i];
        }
        
        if(max < a[i]){
            max = a[i];
        }
        sum += a[i];
    }
    
    printf("%ld %ld %ld\n", min, max, sum);
    
    return 0;
}


Measured memory_bytes: 2100
#include <bits/stdc++.h>
#define FOR(i, a, b) for (int i = a; i < b; i++)
#define mFOR(i, a, b) for (int i = a; i > b; i--)
#define MP make_pair
#define PB push_back
#define N 200000
#define INF 20000000000
using namespace std;

typedef long long ll;

int main()
{
    int a, b, q;
    ll s[N] = {}, t[N] = {}, x, res;
    cin >> a >> b >> q;
    s[0] = t[0] = -INF;
    s[a + 1] = t[b + 1] = INF;
    FOR(i, 1, a + 1)
    cin >> s[i];
    FOR(i, 1, b + 1)
    cin >> t[i];
    FOR(i, 0, q)
    {
        cin >> x;
        ll *ps = upper_bound(s, s + a, x);
        ll *pt = upper_bound(t, t + b, x);
        res = min({
            abs(*ps - x) + abs(*pt - *ps),
            abs(*pt - x) + abs(*ps - *pt),
            abs(*ps - x) + abs(*(pt - 1) - *ps),
            abs(*(pt - 1) - x) + abs(*ps - *(pt - 1)),
            abs(*(ps - 1) - x) + abs(*pt - *(ps - 1)),
            abs(*pt - x) + abs(*(ps - 1) - *pt),
            abs(*(ps - 1) - x) + abs(*(pt - 1) - *(ps - 1)),
            abs(*(pt - 1) - x) + abs(*(ps - 1) - *(pt - 1))
        });
        cout << res << "\n";
    }

    return 0;
}

Measured memory_bytes: 4480
#include<bits/stdc++.h>
using namespace std;
int main()
{long long i,j,k,l,m,n,t,z,sum;
cin>>n;
long long x[n],y[n];
for(i=0;i<n;i++)
{cin>>x[i]>>y[i];}
m=0;
for(i=0;i<n;i++)
{if(x[i]==y[i])m=m+1;
else m=0;
if(m==3)break;}
if(m==3)cout<<"Yes"<<"\n";else cout<<"No"<<"\n";
return 0;}

Measured memory_bytes: 3588
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(ll i=0;i<ll(n);i++)
int main() {
    ll n,c;
    string s = "";
    cin >> n;
    rep(i, n) {
        ll a,b;
        cin >> a >> b;
        if (a == b) {
            s+= "1";
        }else {
            s+= "0";
        }
    }
    c = s.find("111");
    if (c != -1) {
        cout << "Yes" << endl;
    }else {
        cout << "No" << endl;
    }
    return 0;
}



Measured memory_bytes: 3628
import java.util.*;
class Main{
	public static void main(String[] args){
    	Scanner in = new Scanner(System.in);		
      int n = in.nextInt();
      long x = in.nextLong();
      long a[] = new long[n];
      long ac[] = new long[n];
      for( int i =0;i<n;i++){
      	a[i] = in.nextLong();
        ac[i] =a[i];
      }
      long sum=0;
      for(int i = 0; i<n-1;i++){
      	if(a[i]+a[i+1]>x){
          	long dif = a[i]+a[i+1]-x;
          	sum+=dif;
          	if(dif<a[i+1]){
            	a[i+1]-=dif;
            }
          	else{
            	dif-=a[i+1];
              	a[i+1] = 0;
              	a[i]-=dif;
            }
        }
      }
     
      System.out.println(sum);
    }
}


Measured memory_bytes: 60828
import java.util.*;
public class Main{public static void main(String[]args){
Scanner sc=new Scanner(System.in);
  int n=sc.nextInt();
  int m=sc.nextInt();
  int[][]p=new int[n][2];
  int[][]h=new int[m][2];
  for(int i=0;i<n;i++){
  p[i][0]=sc.nextInt();
    p[i][1]=sc.nextInt();
  }
  for(int i=0;i<m;i++){
  h[i][0]=sc.nextInt();
    h[i][1]=sc.nextInt();
  }
  for(int i=0;i<n;i++){
    int point=0,plen=1000000000;
  for(int j=0;j<m;j++){
  	int len=Math.abs(p[i][0]-h[j][0])+Math.abs(p[i][1]-h[j][1]);
    if(plen>len){point=j;plen=len;}
  }
    System.out.println(point+1);
  }
  
}}


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

#define pb push_back
#define mp make_pair
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef complex<double> point;
#define xx real()
#define yy imag()

#define REP(i, a, b) for(int i = (a); i < (int)(b); i++)
#define REPN(i, a, b) for(int i = (a); i <= (int)(b); i++)
#define FA(it, x) for(__typeof((x).begin()) it = (x).begin(); it != (x).end(); it++)
#define SZ(x) (int)(x).size()
#define BE(x) (x).begin(), (x).end()
#define SORT(x) sort(BE(x))
#define _1 first
#define _2 second

#define x1 gray_cat_x1
#define y1 gray_cat_y1

template<class T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }

#define file "I1"

const double EPS = 1e-9;
const double PI = acos(-1.);
const int INF = 1e9;
const ll MOD = 1e9 + 7;

const int MAXN = 1e5 + 5;

ll v[MAXN];

char op[MAXN];

char c[10];

void refresh(ll cur, ll &ans, int &fl){
	//printf("%lld %lld\n", ans, cur);
	if (!fl){
		ans = cur;
	}
	ans = max(ans, cur);
	fl = 1;
}

void solve(){
	int n;
	scanf("%d%lld", &n, &v[0]);
	ll sum = 0ll;
	REP(i, 1, n){
		scanf("%s%lld", &c[0], &v[i]);
		op[i] = c[0];
		sum += v[i];
	}
	op[n] = '-';
	n++;
	int fl = 0;
	ll l_val = v[0];
	ll ans = 0ll;
	REPN(i, 1, n){
		if (op[i] == '+'){
			l_val += v[i];
			sum -= v[i];
		} else {
			ll v2 = v[i];
			REPN(j, i + 1, n){
				if (op[j] == '-'){
					break;
				}
				v2 += v[j];
			}
			//printf("%lld %lld %lld\n", l_val, -v2, sum - v2);
			refresh(l_val - v2 + sum - v2, ans, fl);
			l_val -= v[i];
			sum -= v[i];
		}	
	}
	//refresh(l_val, ans, fl);
	printf("%lld\n", ans);
}   

int main(){

    //freopen(file".in", "r", stdin); freopen(file".out", "w", stdout);
    int t = 1;
    //cin >> t;
    while(t--){
        solve();    
    }
}


Measured memory_bytes: 1152
s = gets.chomp
if s[0] == s[1]
  if s[2] == s[3] && s[0] != s[2]
    puts "Yes"
  else
    puts "No"
  end
elsif s[0] == s[2]
  if s[1] == s[3] && s[0] != s[1]
    puts "Yes"
  else
    puts "No"
  end
elsif s[0] == s[3]
  if s[1] == s[2] && s[0] != s[1]
    puts "Yes"
  else
    puts "No"
  end
else
  puts "No"
end

Measured memory_bytes: 14308
n=int(input())
H=list(map(int,input().split()))
d=0
for i in range(0,n-1):
    if H[n-i-1]-H[n-i-2]<-1:
        print("No")
        break
    elif H[n-i-1]-H[n-i-2]==-1:
        H[n - i - 2]=H[n-i-2]-1
        d=d+1
    else:
        d=d+1
if d==n-1:
    print("Yes")

Measured memory_bytes: 15020
#include <iostream>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <map>
using namespace std;
typedef long long ll;

int main()
{
        int N, M;
        cin >> N >> M;
        map<ll, int> mp;
        vector<int> P(M);
        vector<ll> Y(M);

        for(int i = 0; i < M; i++)
        {
                int p;
                ll y;
                cin >> p >> y;
                mp[y] = p;
                P[i] = p;
                Y[i] = y;
        }

        map<ll, int> cntm;
        vector<int> cntv(N+1, 1);
        auto begin = mp.begin();
        auto end = mp.end();
        for(auto iter = begin; iter != end; iter++)
        {
                cntm[iter->first] = cntv[iter->second];
                cntv[iter->second]++;
        }

        for(int i = 0; i < M; i++)
        {
                cout << setfill('0') << right << setw(6) << mp[Y[i]];
                cout << setfill('0') << right << setw(6) << cntm[Y[i]] << endl;
        }

        return 0;
}

Measured memory_bytes: 15616
#include <bits/stdc++.h>
using namespace std;using ll=int_fast64_t;using ld=long double;using pll=pair<ll,ll>;using pld=pair<ld,ld>;
const ll INF=1LL<<60;void solve();int main(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(10);solve();}
#define foreach(i,a) for(auto &i:a)
#define SELECTOR(_1,_2,_3,_4,SELECT,...) SELECT
#define rep(...) SELECTOR(__VA_ARGS__,_rep2,_rep1,_rep0)(__VA_ARGS__)
#define _rep0(i,n) for(ll i=0;i<n;++i)
#define _rep1(i,k,n) for(ll i=k;i<n;++i)
#define _rep2(i,k,n,d) for(ll i=k;d!=0&&d>0?i<n:i>n;i+=d)
template<class T> vector<T> make_v(size_t a,T b){return vector<T>(a,b);}
template<class... Ts> auto make_v(size_t a,Ts... ts){return vector<decltype(make_v(ts...))>(a,make_v(ts...));}
template<class T> inline bool chmax(T &a,const T &b){if(a<b){a=b; return 1;} return 0;}
template<class T> inline bool chmin(T &a,const T &b){if(a>b){a=b; return 1;} return 0;}

void solve(){
  ll n; cin>>n;
  vector<ll> A(n);
  rep(i,n) cin>>A[i];
  multiset<ll> st;
  rep(i,n){
    auto it=st.lower_bound(A[i]);
    if(it!=st.begin()) st.erase(--it);
    st.insert(A[i]);
  }
  cout<<st.size()<<"\n";
}

Measured memory_bytes: 5760
#include <bits/stdc++.h>
using namespace std;
const int N=2e5 +10;
long long f[N], g[N];
int main()
{
    long long MOD=1e9+7;
    int n; cin>>n;
    int prv=0;
    f[0]=1;
    for(int i=1, x; i<=n; ++i)
    {
        cin>>x;
        f[i]=f[i-1];
        if (x!=prv)
        {
            f[i]=(f[i]+g[x])%MOD;
            g[x]=(g[x]+f[i-1])%MOD;
        }
        prv=x;
    }
    cout<<f[n];
}


Measured memory_bytes: 3328
n = int(input())
la = list(map(int,input().split()))
l = [0,0,0]
lb = []
c=1
for i in range(0,n):
    lb.append(l.count(la[i]))
    for j in range(0,3):
        
        if la[i] == l[j]:
            l[j] = l[j] + 1
            break
        else:
            continue

for i in range(0,n):
    c = c * lb[i]
print(c%1000000007)



Measured memory_bytes: 13964
use std::io;


fn main() {
    let mut n = read::<usize>();
    n.sort();
    let ans = vec![5, 5, 7];
    if n == ans {
        println!("YES");
    } else { println!("NO"); }
}


#[allow(dead_code)]
fn read<T>() -> Vec<T>
where T:
    std::str::FromStr,
    T::Err: std::fmt::Debug {

    let mut buf = String::new();
    io::stdin().read_line(&mut buf).unwrap();
    buf.split_whitespace()
        .map(|s| s.trim().parse().unwrap())
        .collect()
}

#[allow(dead_code)]
fn read_one<T>() -> T
where T:
    std::str::FromStr,
    T::Err: std::fmt::Debug {

    let mut buf = String::new();
    io::stdin().read_line(&mut buf).unwrap();
    buf.trim().parse().unwrap()
}

Measured memory_bytes: 4352
n = int(input())
a = []
for i in range(n):
  a.append(int(input()))
b = a.copy()
m = max(a)
b2 = b.remove(m)
mb = max(b)
for j in a:
  if j < m:
    print(m)
  elif j == m:
    print(mb)
    
  

Measured memory_bytes: 14060
#include <iostream>
#include<algorithm>
#include<string>
#include<map>
#include<math.h>
#include<string.h>
#include<assert.h>
#include<queue>
using namespace std;
#define endl '\n'
#define pb push_back
#define mp make_pair
#define SZ(x) ((int)(x).size())
#define all(x) x.begin(),x.end()
#define mem0(s) memset(s,0,sizeof(s))
#define meminf(s) memset(s,0x3f,sizeof(s))
#define mp_insert(a,b,c) mp.insert(map<pair<int,int>,int>::value_type(make_pair(a,b),c))
typedef long long ll;
typedef unsigned long long ull;
inline ll lowbit(ll x){return x&(-x);}
inline ll min(ll a,ll b){return a<b?a:b;}
inline ll max(ll a,ll b){return a>b?a:b;}
const int INF=0x3f3f3f3f,max_n=200005,mod=19260817;
inline ll gcd(ll a,ll b){return b==0?a:gcd(b,a%b);}
inline ll pow(ll a,ll b,ll mod){ll res=1;a%=mod;assert(b>=0);for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll sum1;
int main()
{
	ll n;cin>>n;
	if(n%2==1)
	{
		cout<<"0";
	}
	else if(n<10)cout<<"0";
	else
	{
		long long count1=10;
		while(1)
		{
			if(count1>n)break;
			sum1+=n/count1;
			count1*=5;
		}
		cout<<sum1;
	}



}

Measured memory_bytes: 3636
#include <iostream>
#include <vector>
using namespace std;
int main() {
    int n;
    cin >> n;
    vector<int> d(n);
    for (int i = 0; i < n; ++i) {
        cin >> d.at(i);
    }
    long long ans = 0;
    for (int i = 0; i < n; ++i) {
        for (int j = i + 1; j < n; ++j) {
            ans += d.at(i) * d.at(j);
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<string>
using namespace std;
char fld[8][8];
int main(){
while(cin>>fld[0]){
    for(int i=1;i<8;i++){
        cin>>fld[i];
    }
    for(int i=0;i<8;i++){
        for(int j=0;j<8;j++){
            if(fld[i][j]=='1'){
                if(fld[i][j+1]=='1'&&fld[i+1][j]=='1'&&fld[i+1][j+1]=='1'){
                    cout<<'A'<<endl;
                }
                if(fld[i+1][j]=='1'&&fld[i+2][j]=='1'&&fld[i+3][j]=='1'){
                    cout<<'B'<<endl;
                }
                if(fld[i][j+1]=='1'&&fld[i][j+2]=='1'&&fld[i][j+3]=='1'){
                    cout<<'C'<<endl;
                }
                if(fld[i+1][j]=='1'&&fld[i+1][j-1]=='1'&&fld[i+2][j-1]=='1'){
                    cout<<'D'<<endl;
                }
                if(fld[i][j+1]=='1'&&fld[i+1][j+1]=='1'&&fld[i+1][j+2]=='1'){
                    cout<<'E'<<endl;
                }
                if(fld[i+1][j]=='1'&&fld[i+1][j+1]=='1'&&fld[i+2][j+1]=='1'){
                    cout<<'F'<<endl;
                }
                if(fld[i][j+1]=='1'&&fld[i+1][j]=='1'&&fld[i+1][j-1]=='1'){
                    cout<<'G'<<endl;
                }
            }
        }
    }
}
return 0;
}

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

 
 
 
int main(){

    int i=0,X=0;
    char N[200001];
    scanf("%s",N);

    for(i;N[i]!='\0';i++){
    X += ((int)N[i] - 48);
    
    }

    if(X%9==0){
    printf("Yes");}

    else{printf("No");}

    return 0;

}

Measured memory_bytes: 1852
#include <bits/stdc++.h>
using namespace std;
#define ll long long
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);cout.tie(NULL);
    char c;
   int n;
   cin>>n;
   int p[n+1];
   for(int i=1;i<=n;i++) cin>>p[i];
   ll sum=0;
   vector<int> b(100006);
   for(int i=1;i<=100005;i++) b[i]=0;
    for(int i=1;i<=n;i++){
    	sum+=p[i];
    	b[p[i]]++;
    }
    // for(int i=1;i<=5;i++) cout<<b[i]<<" ";
   int q;
   cin>>q;
 //  cout<<sum<<"\n";
   while(q--){
   	int x,y;
   	cin>>x>>y;
   	ll temp=b[x];
   	b[y]+=b[x];
   	b[x]=0;
   	sum+=(temp*y-temp*x);
   	cout<<sum<<"\n";
}
  //for(int i=0;i<n;i++) cout<<p[i]<<" ";
  //cout<<sum<<"\n"; 
 }

Measured memory_bytes: 4012
class dice():
    def __init__(self,labels):
        self.l=labels
    def check(self,d2):
        l1=self.l
        for a in range(4):
            l1[1],l1[2],l1[3],l1[4]=l1[2],l1[4],l1[1],l1[3]
            for b in range(4):
                l1[0],l1[3],l1[2],l1[5]=l1[2],l1[0],l1[5],l1[3]
                for c in range(4):
                    l1[0],l1[1],l1[5],l1[4]=l1[4],l1[0],l1[1],l1[5]
                    if l1==d2.l:
                        return True
                        break
"""
a=dice([int(i) for i in input().split()])
b=dice([int(i) for i in input().split()])
print("Yes" if a.check(b) else "No")

"""
l=[]
n=int(input())
for _ in range(n):
    l.append(dice([int(i) for i in input().split()]))
han=False
for x in range(n-1):
    for i in range(x+1,n):
        if l[x].check(l[i]):
            han=True
            break
print("No" if han else "Yes")



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

#define mp make_pair
#define X first
#define Y second
#define FOR(i, a, b) for(int i = a; i <= b; i++)
#define FOD(i, a, b) for(int i = a; i >= b; i--)

using namespace std;

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

const int N = 5010;
const ll INF = 1e18;

/// x ->
/// y <-

int n, a[N];
int cnt[N][N];
ll x, y, F[N][N];

int main(){
    if (fopen("inp.txt", "r")){
        freopen("inp.txt", "r", stdin);
        freopen("out.txt", "w", stdout);
    }
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    cin >> n >> x >> y;
    FOR(i, 1, n)
        cin >> a[i];

    FOR(i, 0, n)
        FOR(j, 0, n)
            F[i][j] = INF;

    F[0][0] = 0;
    FOR(i, 0, n - 1)
        FOR(val, 0, n)
            if (val < a[i + 1]){
                F[i + 1][val] = min(F[i + 1][val], F[i][val] + x);
                F[i + 1][a[i + 1]] = min(F[i + 1][a[i + 1]], F[i][val]);
            } else {
                F[i + 1][val] = min(F[i + 1][val], F[i][val] + y);
            }

    ll ans = INF;

    FOR(i, 0, n)
        ans = min(ans, F[n][i]);
    cout << ans;

    return 0;
}



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

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>x>>y;
	cout<<x*x-y<<endl;
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}


Measured memory_bytes: 384
import numpy as np

N,A,B = map(int,input().split())
h = np.array([int(input()) for _ in range(N)],dtype=np.int64)

def test(n):
  # n回の魔法で全滅させられるか
  x = h - n*B
  x[x<0] = 0
  return np.ceil(x/(A-B)).sum() <= n


left = 0 # 倒せない
right = 10**9 # 倒せる

while right - left > 1:
  mid = (left + right)>>1
  if test(mid):
    right = mid
  else:
    left = mid

answer = right
print(answer)

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

ll calc_sum(vector<ll> v,string S){
  vector<ll> n;
  ll res=0,tmp=0;
  for(ll i=0;i<S.size();++i){
    if(v[i]==1){
      string s = S.substr(tmp,i+1-tmp);
      n.push_back(stoll(s));
      tmp=i+1ll;
    }
  }
  string s = S.substr(tmp,S.size()+1-tmp);
  n.push_back(stoll(s));
  res = accumulate(all(n),0ll);
  return res;
}

int main(){
  string S;cin>>S;
  ll ans=0;
  for(ll i=0;i<S.size();++i){
    if(S.size()==1){ans = stoi(S);break;}
    vector<ll> v(S.size()-1,1);
    for(ll j=0;j<i;++j) v[j]=0;
    do{
      ans += calc_sum(v,S);      
    }while(next_permutation(all(v)));
  }
  cout << ans << endl;
}

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

if k == 1:
    print('1')
    exit()
if k % 2 == 0 or k % 5 == 0:
    print('-1')
    exit()

k *= 9
a = 10
for i in range(10*k):
    if (7 * (a - 1 + k)) % k == 0:
        print(str(i+1))
        exit()
    a = (a*10) % k


Measured memory_bytes: 9108
#include <iostream>
#include <cstdio>
#include <fstream>
#include <algorithm>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <utility>
#include <stack>
#include <queue>
#include <sstream>
#include <fstream>
#include <cmath>
#include <cstring>
 
using namespace std;
#define int long long
const int mod = 1000000007;
 
int a[200001] = {}, b[200001] = {}, c[200001] = {}, d[200001] = {};
int memo[2001][2001][3]= {};
char w[2001][2001] = {};
 
signed main(){
    int M, N, K; cin >> M >> N >>K;
    for (int i = 0; i < M; i++) {
        for (int j = 0; j < N; j++) {
            cin >> w[i][j];
        }
    }
    for (int i = 0; i < K; i++) cin >> a[i] >> b[i] >> c[i] >> d[i];
    for (int i = 0; i < M; i++) {
        int t1 = 0,t2=0,t3=0;
        for (int j = 0; j < N; j++) {
            if (w[i][j] == 'J')t1++;
            else if (w[i][j] == 'O')t2++;
            else t3++;
 
            if (i == 0) {
                memo[i][j][0] = t1;
                memo[i][j][1] = t2;
                memo[i][j][2] = t3;
            }
            else {
                memo[i][j][0] = memo[i-1][j][0] + t1;
                memo[i][j][1] = memo[i-1][j][1] + t2;
                memo[i][j][2] = memo[i-1][j][2] + t3;
            }
            //cout << " i" << i << " j" << j << " " << memo[i][j][0] << memo[i][j][1] << memo[i][j][2];
        }
        //cout << endl;
    }
    for (int i = 0; i < K; i++) {
        int a1, a2, a3;
        a1 = memo[c[i] - 1][d[i] - 1][0] - memo[a[i]-2][d[i]-1][0] - memo[c[i]-1][b[i]-2][0] + memo[a[i]-2][b[i]-2][0];
        a2 = memo[c[i] - 1][d[i] - 1][1] - memo[a[i] - 2][d[i] - 1][1] - memo[c[i] - 1][b[i] - 2][1] + memo[a[i] - 2][b[i] - 2][1];
        a3 = memo[c[i] - 1][d[i] - 1][2] - memo[a[i] - 2][d[i] - 1][2] - memo[c[i] - 1][b[i] - 2][2] + memo[a[i] - 2][b[i] - 2][2];
        cout << a1 << " " << a2 << " " << a3 << endl;
 
 
    }
     
}

Measured memory_bytes: 35336
gets
D = gets.strip.split(" ").map(&:to_i)

D.sort!

ans = 0
i = 0
0.upto(10**5 + 1) do |k|
  while i < D.size && D[i] < k do
    i += 1
  end

  break if i >= D.size

  ans += 1 if i == (D.size - i)
end

puts ans


Measured memory_bytes: 11520
#include<iostream>
#include<math.h>
#include<iomanip>
#include<vector>
#include<algorithm>
#include<queue>
#include<string>
#include<stdlib.h>
#include <set>
#include<iomanip>
#include<map>
#include<unordered_map>

#include<stdio.h>
typedef long long ll;
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)

#define PI  3.141592
//----------------------------------------




int main(void)
{

	string s;
	ll q;

	cin >> s >> q;

	bool rev = 0;
	rep(i, q)
	{
		int t;
		cin >> t;

		if (t == 1) rev= !rev;

		if (t == 2)
		{
			int f;
			string c;
			cin >> f >> c;
			if ((rev + f) % 2 == 1) s.insert(0, c);
			else s += c;


		}



	}

	if (rev) reverse(s.begin(), s.end());
		cout << s << endl;

}

Measured memory_bytes: 900
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc=new Scanner(System.in);
        int n=sc.nextInt();
        int k=sc.nextInt();
        long dp[]=new long[100001];
        for(int i=1;i<dp.length;i++)dp[i]=Long.MAX_VALUE;
        for(int i=0;i<n;i++){
            int a=sc.nextInt();
            int b=sc.nextInt();
            for(int j=100000;j>=b;j--){
                if(dp[j-b]!=Long.MAX_VALUE){
                    dp[j]=Math.min(dp[j],dp[j-b]+a);
                }
            }
        }
        for(int i=100000;i>=0;i--){
            if(dp[i]<=k){
                System.out.println(i);
                break;
            }
        }
        
    }
}


Measured memory_bytes: 23508
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define PI 3.141592653589793
#define rep(i, n) for (int i = 0; i < (n); i++)
#define REP(i, a, n) for (int i = a; i < (n); i++)
#define rrep(i, n, k) for (int i = (n); i >= (k); i--);
#define all(x) (x).begin(), (x).end()
#define vi vector<int>
template<class T> istream &operator>>(istream&is,vector<T>&v){for(auto &elemnt:v)is>>elemnt;return is;}
template<class T,class U> istream &operator>>(istream&is,pair<T,U>&p){is>>p.first>>p.second;return is;}
template<class T>vector<T> make_vector(size_t a){return vector<T>(a);}
template<class T, class... Ts>auto make_vector(size_t a, Ts... ts){return vector<decltype(make_vector<T>(ts...))>(a, make_vector<T>(ts...));}
const int MOD = 1e9 + 7;
const int INF = 9e18;

struct info {
    int before, now, distance;
};

signed main() {
    int N, M;
    cin >> N >> M;
    vector<map<int, int>> human(N + 1);
    bool close = false;
    for (int i = 0; i < M; i++) {
        int L, R, D;
        cin >> L >> R >> D;
        if (human[L].find(R) != human[L].end()) close = true;
        human[L][R] = D;
        if (human[R].find(L) != human[R].end()) close = true;
        human[R][L] = -D;
    }
    if (close) {
        cout << "No" << endl;
        return 0;
    }
    vector<int> check(N + 1, INF);
    stack<info> next;
    for (int i = 1; i <= N; i++) {
        if (check[i] == INF) {
            check[i] = 1e9;
            next.push({-1, i});
        }
        while (!next.empty()) {
            auto temp = next.top();
            next.pop();

            if (temp.before != -1) {
                if (check[temp.before] != INF && check[temp.now] != INF) {
                    if (check[temp.now] - check[temp.before] != temp.distance) {
                        cout << "No" << endl;
                        return 0;
                    }
                } else {
                    check[temp.now] = check[temp.before] + temp.distance;
                }
            }

            for (auto itr = human[temp.now].begin(); itr != human[temp.now].end();) {
                next.push({temp.now, itr->first, itr->second});
                human[itr->first].erase(temp.now);
                itr = human[temp.now].erase(itr);
            }

            if (temp.before != -1) {
                for (auto itr = human[temp.before].begin(); itr != human[temp.before].end();) {
                    next.push({temp.before, itr->first, itr->second});
                    human[itr->first].erase(temp.before);
                    itr = human[temp.before].erase(itr);
                }
            }
        }
    }
    cout << "Yes" << endl;
}


Measured memory_bytes: 31872
#include<bits/stdc++.h>
using namespace std;
int a[200];
int main()
{
	int n;
	while(~scanf("%d",&n)){
		for(int i=1;i<=n;i++){
			scanf("%d",&a[i]);
		}
		int m;
		scanf("%d",&m);
		for(int i=1;i<=m;i++){
			long long sum=0;
			int j,k;
			scanf("%d%d",&j,&k);
			for(int t=1;t<=n;t++){
				if(t==j){
					sum+=k;
				}else{
					sum+=a[t];
				}
			}
			printf("%d\n",sum);
		}
	}
	return 0;
}

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

using namespace std;

vector<vector<char>> rec(301,vector<char>(301,'#'));

int main(){
  int h[300],w[300],cnt = 0;
  while(1){
    cin >> h[cnt] >> w[cnt];
    if(h[cnt] == 0 && w[cnt] == 0) break;
    cnt++;
  }

  for(int k=0;k < cnt;k++){
    for(int i=0;i < h[k];i++){
      for(int j=0;j < w[k];j++){
        if(i == 0 || i == h[k]-1){
          cout << rec.at(i).at(j);
        }else{
          if(j == 0 || j == w[k]-1) cout << rec.at(i).at(j);
          if(!(j == 0 || j == w[k]-1)) cout << '.' ;
        }
        if(j == w[k]-1) cout << "\n";
      }
    }
    cout << "\n";
  }
  return 0;
}


Measured memory_bytes: 3060
#include<stdio.h>
int main()
{
	int n;
	scanf("%d",&n);
	if(n<=999){
		n=n%100;
		n=n%10;
	}
	if(n<=99){
		n=n%10;
	}
	if(n<=9) n=n;
	if(n==2||n==4||n==5||n==7||n==9) printf("hon\n");
	if(n==0||n==1||n==6||n==8) printf("pon\n");
	if(n==3) printf("bon\n");
	return 0;
}

Measured memory_bytes: 1648
#include <stdio.h>
 
using namespace std;
 
int main(){
    int a,b;
    while(true){
        scanf("%d %d",&a,&b);
        if(a == 0 && b == 0) break;
        if(a > b) printf("%d %d\n",b,a);
        else{
            printf("%d %d\n",a,b);
        }
    }
}


Measured memory_bytes: 2568
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int a,b;
	cin>>a>>b;
	if(a>0)cout<<"Positive"<<endl;
	else if(a<=0&&b>=0)cout<<"Zero"<<endl;
	else if(int(abs(b)-abs(a))%2!=0)cout<<"Positive"<<endl;
	else cout<<"Negative"<<endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;
import java.util.Queue;
import java.util.ArrayDeque;



public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
	
		String s = sc.next();
		String t = sc.next();
		
		int ans = 10000;
		if(s.equals(t)) {
			ans = 0;
		}
		for(int i = 0; i < s.length()-t.length()+1;i++) {
			int temp = 0;
			for(int j = 0; j < t.length(); j++) {
				if(s.charAt(i+j) != t.charAt(j)){
					++temp;
				}
			}
			if(ans > temp) {
				ans = temp;
			}
		}
		System.out.println(ans);
	}
}



Measured memory_bytes: 26968
#pragma GCC optimize("O3")
#include <bits/stdc++.h>

using namespace std;

int main(void) {
    int n, l, i, nmin=INT_MAX, w, ans=0, norig=0;
    cin >> n >> l;
    for (i = 0; i < n; i++) {
        w = abs(l+i);
        if (nmin > w) {
            nmin = w;
            norig = l+i;
        }
        ans += l+i;
    }
    ans -= norig;
    cout << ans << endl;
    
    return 0;
}


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

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

    int time_counter = 0;
    long long distance_accumulation=0;
    while (distance_accumulation < x){
        ++time_counter;
        distance_accumulation += time_counter;
    }
    cout << time_counter << endl;
    return 0;
}

Measured memory_bytes: 256
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <cmath>
#include <cstdio>
#include <string>
#include <cstring>
#include <iostream>
#include <algorithm> 
using namespace std;

#define ls st<<1
#define rs st<<1|1
#define LL long long 
#define CLR(a,b) memset(a,(b),sizeof(a))

const int MAXN = 1e3+11;
const int mod = 1e9+7;
const int INF = 0x3f3f3f3f; 

/* ------------------------基本函数-------------------------*/
long long read()
{
    long long res = 0;
    char ch = 0;
    while (ch < '0' || ch > '9')
        ch = getchar();
    while (ch >= '0' && ch <= '9')
    {
        res = res * 10 + ch - '0';
        ch = getchar();
    }
    return res;
}
bool prime(int x) {
	if(x==2 || x==3) 
		return true;
	if(x%2==0 || x%3==0 || x==1)
		return false;
	int k = sqrt(x)+1;
	for(int i = 5; i < k; i++) {
		if(x%i==0 || x%(i+2)==0)
			return false;
	}
	return true;
} 

LL pow_mod(int a, int b, int c) {
	LL ans = 1;
	while(b) {
		if(b&1)
			ans = (ans*1) % c;
		a = (a*a) % c;
		b /= 2;
	}
	return ans;
}
int gcd(int a, int b) {
	if(!b) 
		return a;
	return gcd(b,a%b);
}
/*-------------------------------------------------------*/


int main() {
	LL x,y,a,b;
	cin >> x >> y >> a >> b;
	cout << max(x*y,a*b) << endl;
return 0;
}

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

int main(){ 
    ll k; cin>>k;
    if(k%2 == 0 || k%5 == 0){
        cout<<"-1"<<endl;
        return 0;
    }

    ll n = 7;
    ll count = 1;

    while(1){
        if(n%k == 0){
            cout<<count;
            break;
        }
        if(count > k){
            cout<<"-1"<<endl;
            break;
        }

        n = (n%k)*10+7;
        count++;
    }

    return 0; 
}         

Measured memory_bytes: 3632
#include <bits/stdc++.h>
 
using namespace std;
 
#define ll long long int
#define pb push_back
#define mp make_pair
#define inf 0x7fffffff
#define inff 100000
#define ff first
#define ss second
#define sz(x) ((int) (x).size())
#define fast cin.sync_with_stdio(0);cin.tie(0)
#define rep(i,N) for(int i = 0;i < N;i++)
#define frep(i,a,b) for(int i = a;i <= b;i++)
#define pii pair<int , int>
#define pll pair<ll , ll>
#define vii vector<int>
#define vpii vector< pii >
#define fill(A,v) memset(A,v,sizeof(A))
#define setbits(x) __builtin_popcountll(x)
#define print(A,j,k) for(int ii=j;ii<k;ii++)cout<<A[ii]<<" ";cout<<"\n"
#define all(x) (x).begin(), (x).end()
#define gcd __gcd
#define SQRT 350
#define CASES int t;cin>>t;while(t--)
#define FILE freopen("inp.txt" , "r" , stdin);
#define ld long double

const int MOD = 1e9 + 7;
const int N = 1e6 + 500;
const int lgN = 20;
const ll INF = 1e16;

int main(int argc, char const *argv[])
{
	fast;

	string s;
	cin >> s;

	//finally string will be of the form TTTSSS..

	int ans = 0;
	while (s.size() > 0) {
		if ( *(s.begin()) == 'T') {
			ans++;
			s.erase(s.begin());
		}
		else
			break;
	}
	while (s.size() > 0) {
		if ( *(s.end() - 1) == 'S') {
			ans++;
			s.erase(s.end() - 1);
		}
		else
			break;
	}

	if (s.size() == 0) {
		cout << ans << "\n";
		return 0;
	}

	int a = 0 , b = 0;
	if (s[0] == 'S')
		a = 1;
	else
		b = 1;

	ans += s.size();

	for(int i = 1;i < s.size();i++) {
		if (s[i] == 'S' && s[i - 1] == 'S') {
			a++;
		}
		else if (s[i] == 'T' && s[i - 1] == 'T') {
			b++;
		}
		else if (s[i - 1] == 'T' && s[i] == 'S') {
			// cout << "a b " << a << ' ' << b << '\n';
			ans -= 2 * min(a , b);
			if (a >= b) {
				a -= b;
				a++;
			}		
			else {
				a = 1;
			}
			b = 0;
			// cout << "a b " << a << ' ' << b << '\n';
		}
		else if (s[i - 1] == 'S' && s[i] == 'T'){
			b++;		
		}
	}

	// cout << "a b " << a << ' ' << b << '\n';
	ans -= 2 * min(a , b);
	cout << ans << '\n';

	return 0;
}

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

int main() {
 int N;
 cin >> N;
 vector<ll> A(N);
  for(int i = 0;i<N;i++){
    cin >> A[i];
  }
  sort(A.begin(),A.end());
  reverse(A.begin(),A.end());
  A.push_back(0);
  
  int c = 1;
  vector<pair<ll,ll>> p;
  for(int i = 0;i<N;i++){
    if(A[i] == A[i+1]) c++;
    else if(A[i] != A[i+1]){
      p.push_back(make_pair(A[i],c));
      c = 1;
    }
  }
  
  vector<ll> ans;
  if(p[0].second >= 4) cout << p[0].first * p[0].first << endl;
  
  else{
  for(int i = 0;i<p.size();i++){
    if(p[i].second >=2) ans.push_back(p[i].first);
    if(ans.size() == 2) break;
  }
  
    if(ans.size()<=1) cout << 0 << endl;
    else if(ans.size() >= 2) cout << ans[0]*ans[1] << endl;
  }
}

Measured memory_bytes: 4080
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define fi first
#define se second
#define all(x) x.begin(),x.end()


int main() {
    
    ll n;
    cin>>n;
    string s;
    cin>>s;
   
    vector<ll> suff1(n+1,0),suff2(n+1,0),suff3(n+1,0);
    
    for (ll i=n-1;i>=0;i--){
        if (s[i]=='R')
        suff1[i]=1;
        else if (s[i]=='G')
        suff2[i]=1;
        else
        suff3[i]=1;
        
        suff1[i]+=suff1[i+1];
        suff2[i]+=suff2[i+1];
        suff3[i]+=suff3[i+1];
    }
    
    ll cnt=0;
    for (ll i=0;i<n;i++){
        for (ll j=i+1;j<n;j++){
            ll diff=j-i;
            if (s[i]!=s[j]){
                if ('R'!=s[i]&&'R'!=s[j]){
                    cnt+=suff1[j];
                }
                else if ('G'!=s[i]&&'G'!=s[j]){
                    cnt+=suff2[j];
                }
                else{
                    cnt+=suff3[j];
                }
                if (j+diff<n&&s[j+diff]!=s[j]&&s[j+diff]!=s[i])
                cnt--;
            }
            
        }
    }
    cout<<cnt<<"\n";
   
	return 0;
}

Measured memory_bytes: 3728
#include <bits/stdc++.h>
#include <math.h>
#define _GLIBCXX_DEBUG
#define _LIBCPP_DEBUG 0

using namespace std;
#define ll long long
#define rep(i,n) for (int i = 0; i < n; i++)
#define rrep(i,n) for (int i = n-1; i >= 0; i--)
#define MOD (1000000007)
#define vi vector<int>
#define vl vector<ll>
#define vb vector<bool>
#define vvi vector<vi>
#define vvl vector<vl>
#define pii pair<int, int>
#define pli pair<ll, int>a
#define pb push_back
#define sz(x) int(x.size())

#define mp make_pair
#define all(a) (a).begin(),(a).end()

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; }

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

ll keta(ll n){
  string s = to_string(n);
  ll num = s.size();
  return num;
}

const ll INF = 1LL << 60;

const int dh[4] = {1,0,-1,0};
const int dw[4] = {0,1,0,-1};

struct Edge{
  int to;
  int weight;
  Edge(int t, int w) : to(t), weight(w){}
};
using Graph = vector<vector<Edge>>;
using P = pair<ll, int>;

class UnionFind{
  public:
  vi Parent;
  UnionFind(int n){
    Parent = vi(n,-1);
  }

  int root(int a){
    if(Parent[a] < 0) return a;
    else return Parent[a] = root(Parent[a]);
  }

  int size(int a){
    return -Parent[root(a)];
  }

  bool merge(int a, int b){
    a = root(a);
    b = root(b);
    if(a == b) return false;

    if(size(a) < size(b)) swap(a,b);
    Parent[a] += Parent[b];
    Parent[b] = a;

    return true;
  }
};

class Factrial{
  public:
  vl Fac;
  Factrial(int MAX){
    Fac = vl(MAX+1);
    rep(i,MAX) {
      if(i == 0) Fac[i+1] = 1;
      else Fac[i+1] = ((i+1)*Fac[i])%MOD;
    }
  }
};


int main(){
  int n,k,r,s,p; cin >> n>>k>>r>>s>>p;
  string t; cin >> t;

  int ans = 0;

  rep(i,k) {
    bool twice = false;
    for(int j = i; j < n; j += k) {
      if(j-k >= 0 && t[j-k] == t[j] && !twice){
        twice = true;
        continue;
      }
      if(t[j] == 'r') ans += p;
      if(t[j] == 'p') ans += s;
      if(t[j] == 's') ans += r;
      twice = false;
    }
  }

  cout << ans << endl;
}

Measured memory_bytes: 512
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define ll long long
#define rep(i,l,r)for(ll i=(l);i<(r);i++)
#define max(p,q)((p)>(q)?(p):(q))
#define min(p,q)((p)<(q)?(p):(q))
#define INF ((1LL<<62)-(1LL<<31))

ll n,ans=INF;
char s[300010];
ll ss[300010];
int main(){
	scanf("%lld\n%s",&n,s+1);
	rep(i,1,n+1)ss[i]=ss[i-1]+(s[i]=='E');
	rep(i,1,n+1)ans=min(ans,(i-1-ss[i-1])+(ss[n]-ss[i]));
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 2944