akhauriyash/Code-Regression huggingface dataset:
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.util.InputMismatchException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

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

    static class FManjuGame {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int n = in.nextInt();
            int[] a = in.nextIntArray(n);

            int[] sum = new int[2];
            for (int i = 0; i < n; i++) {
                sum[i % 2] += a[i];
            }

            if (n % 2 == 0) {
                int sugim = Math.max(sum[0], sum[1]);
                int sigma = Math.min(sum[0], sum[1]);
                out.println(sugim + " " + sigma);

                return;
            }

            int max = Integer.MAX_VALUE / 2;
            int min = Integer.MIN_VALUE / 2;
            while (max - min > 1) {
                int x = (max + min) / 2;

                int[] b = a.clone();
                for (int i = 0; i < n - 2; i += 2) {
                    if (b[i] < x || b[i + 1] < b[i]) {
                        b[i + 2] += b[i] - b[i + 1];
                    }
                }

                if (b[n - 1] >= x) {
                    min = x;
                } else {
                    max = x;
                }
            }

            int sugim = Math.max(sum[0], sum[1] + min);
            int sigma = sum[0] + sum[1] - sugim;
            out.println(sugim + " " + sigma);
        }

    }

    static class InputReader {
        private BufferedReader br;
        private StringTokenizer st;

        public InputReader(InputStream inputStream) {
            br = new BufferedReader(new InputStreamReader(inputStream));
            st = new StringTokenizer("");
        }

        public String nextString() {
            while (!st.hasMoreTokens()) {
                try {
                    st = new StringTokenizer(br.readLine(), " ");
                } catch (IOException e) {
                    throw new InputMismatchException();
                }
            }
            return st.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(nextString());
        }

        public int[] nextIntArray(int n) {
            int[] res = new int[n];
            for (int i = 0; i < n; i++) {
                res[i] = nextInt();
            }
            return res;
        }

    }
}



Measured memory_bytes: 63460
// In The Name Of The Queen
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long N;
    int tm = 0, tp = 0;
    vector < int > vec;
    scanf("%lld", &N); N ++;
    while (N > 1)
    {
        if (N & 1)
            vec.push_back(-- tm);
        vec.push_back(tp ++);
        N >>= 1;
    }
    int K = (int)vec.size();
    printf("%d\n", K * 2);
    for (int i = 1; i <= K; i ++)
        printf("%d ", i);
    for (int i : vec)
        printf("%d ", (i + K) % K + 1);
    return 0;
}

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

using namespace std;

typedef long long ll;

int main()
{
    int N;
    while(cin>>N)
    {
        int a[100005],i,flag=1;
        for(i=0; i<N; i++)
            scanf("%d",&a[i]);
        a[0]--;
        for(i=1; i<N; i++)
        {
            if(a[i]<a[i-1])
            {
                flag=0;
                break;
            }
            if(a[i]>a[i-1])
                a[i]--;
        }
        if(flag)
            cout<<"Yes"<<endl;
        else
            cout<<"No"<<endl;
    }
    return 0;
}


Measured memory_bytes: 640
#include <cstdio>
#include <string>
 
class List
{
    int* data_; //[4000000];
    int begin_;
    int end_;
public:
    List()
    {
        data_ = new int[4000000];
        begin_ = 2000000;
        end_  = 2000000;
    }
    // ~List()
    // {
    //     delete[] data_;
    // }
    void Insert(int X)
    {
        --begin_;
        data_[begin_] = X;
    }
    void Delete(int X)
    {
        int Index = end_;
        for(int i = begin_; i < end_; ++i){
            if(X == data_[i]){
                Index = i;
                break;
            }
        }
        if(Index == end_) return;
        for(int i = Index; i < end_; ++i){
            data_[i] = data_[i+1];
        }
        end_--;
    }
    void DeleteFirst()
    {
        begin_++;
    }
    void DeleteLast()
    {
        end_--;
    }
    void Show()const
    {
        printf("%d", data_[begin_]);
        for(int i = begin_ + 1; i < end_; ++i){
            printf(" %d", data_[i]);
        }
        printf("\n");
    }
};
 
int main()
{
    List list;
    int n, X;
    std::scanf("%d\n", &n);
    char com[1024];
    for(int i = 0; i < n; ++i){
        std::fgets(com, 1024, stdin);
        if(com[6] == 'F'){
            list.DeleteFirst();
        }else
        if(com[6] == 'L'){
            list.DeleteLast();
        }else{
            int v = 0;
            for(int j = 7; com[j] >= '0' && com[j] <= '9'; ++j){
                v = v*10 + (com[j] - '0');
            }
            if(com[0] == 'i'){
                list.Insert(v);
            }else
            if(com[0] == 'd'){
                list.Delete(v);
            }
        }
    }
    list.Show();
    return 0;
}

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

int main() {
  int N,l,r,S;
  cin >> N;
  S=0;
  for(int i=0;i<N;i++){
    cin >>l >>r;
    S += r-l+1  ;
  }
  cout << S << endl;
  
 
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <algorithm>
using namespace std;
 
int N,S,W,Q,a[100005],ans;
map <int,int> MAP;
 
void go(){
    MAP.clear();
    MAP[0] = 1;
    int i,j;
    long long now = 0,mul = 1;
    for(i=N-1;i>=0;i--){
        now = (now+(a[i]*mul))%Q;
        mul = (mul*10)%Q;
        if(a[i]!=0){
            ans += MAP[now];
        }
        MAP[now]++;
    }
}
void go2(){
    int i,j,k=0;
    for(i=0;i<N;i++){
        if(a[i]!=0)
            k++;
        if(a[i]%Q==0)
            ans += k;
    }
}
 
int main()
{
    //freopen("in.txt","r",stdin);
 
    int n,i,j;
    while(scanf(" %d %d %d %d",&N,&S,&W,&Q)==4 && (N+S+W+Q)){
        int g = S;
        for(i=0;i<N;i++){
            a[i] = (g/7)%10;
            if(g%2==0)
                g = g/2;
            else
                g = (g/2)^W;
        }
        /*for(i=0;i<N;i++)
            printf("%d",a[i]);
        printf("\n");*/
        ans = 0;
        if(Q==2 || Q==5){
            go2();
            printf("%d\n",ans);
        }
        else{
            go();
            printf("%d\n",ans);
        }
    }
 
    return 0;
}

Measured memory_bytes: 5484
#include <iostream>
#include<string>
#include<algorithm>

using namespace std;
int main(void){
    long long N,x;
    cin>>N>>x;
    long long a[N];
    
    for(int i=0;i<N;i++){
        cin>>a[i];
       
        
    }
    sort(a,a+N);
    int T,ans;
    T=0;
    for(int i=0;i<N;i++){
        
        T=T+a[i];
        
        if(x==T){
            
            ans=i+1;
            break;
        }if(x<T){
            ans=i;
            break;
        }
        ans=i;
    }
    
     
    cout<<ans<<endl;
    
    return 0;
    
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
const int N = 305;
int n , m;
int arr[N][N];
int cnt[N];
int there[N];
int ans;
int cur;
int main(){
	scanf("%d %d" , &n , &m);
	for(int i = 1 ; i <= n ; ++i){
		for(int j = 1 ; j <= m ; ++j){
			scanf("%d" , &arr[i][j]);
		}
	}
	ans = n;
	memset(cnt , 0 , sizeof(cnt));
	for(int i = 1 ; i <= m ; ++i){
		there[i] = 1;
	}
	for(int i = 1 ; i <= n ; ++i){
		++cnt[arr[i][1]];
	}
	cur = 0;
	for(int i = 1 ; i <= m ; ++i){
		cur = max(cur , cnt[i]);
	}
	ans = cur;
	for(int x = 1 ; x < m ; ++x){
		int idx = -1;
		for(int j = 1 ; j <= m ; ++j){
			if(there[j]){
				if(cnt[j] == cur){
					idx = j;
				}
			}
		}
		there[idx] = 0;
		memset(cnt , 0 , sizeof(cnt));
		for(int i = 1 ; i <= n ; ++i){
			for(int j = 1 ; j <= m ; ++j){
				if(there[arr[i][j]]){
					++cnt[arr[i][j]];
					break;
				}
			}
		}
		cur = 0;
		for(int i = 1 ; i <= m ; ++i){
			cur = max(cur , cnt[i]);
		}
		ans = min(ans , cur);
	}
	printf("%d\n" , ans);
}

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

using std::cin;
using std::cout;
using std::endl;

using std::string;
using std::pair;

using std::vector;
using std::sort;
using std::lower_bound;
using std::upper_bound;
using std::find_if;
using std::copy;
using std::copy_if;

int a,b,c,d,e,f;


int main(){
    cin >> a;
    cin >> b;
    cin >> c;
    cin >> d;
    cin >> e;
    cin >> f;
    a*=100;
    b*=100;


    vector<int> w;
    for(int i=0; a*i<=f; i++){
        for(int j=0; a*i+b*j<=f; j++){
            w.push_back(a*i+b*j);
        }
    }
    vector<int> s;
    for(int i=0; c*i<=f; i++){
        for(int j=0; c*i+d*j<=f; j++){
            s.push_back(c*i+d*j);
        }
    }

    int water=0;
    int sugar=0;

    for(const auto & x : w){
        for(const auto & y : s){
            if(x+y>f || x*e < 100*y){
                continue;
            }
            if(sugar*x<=y*water){
                water=x;
                sugar=y;
            }
        }
    }

    cout << (water+sugar) << " " << sugar << endl;
    return 0;
}



Measured memory_bytes: 1400
import java.util.Scanner;
public class Main{

	public static void main(String[] args) {
		Scanner input = new Scanner(System.in);
		int h=input.nextInt();
		int a = input.nextInt();
		int sum=0;
		sum+=h/a;
		if(h%a >0)
			sum+=1;
		System.out.println(sum);
				
		

	}

}


Measured memory_bytes: 21204
#include<stdio.h>
#include<stdlib.h>
int main()
{
	char a[4];
	gets(a);
	int i;
	if (a[0] == '7' || a[1] == '7' || a[2] == '7')
	{
		printf("Yes");
	}
	else
	{
		printf("No");
	}
	return 0;
}

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

using namespace std;

using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int ddx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll MOD = 1000000007;
const ll INF = 1000000000000000000L;
#ifdef __DEBUG

/**
 * For DEBUG
 * https://github.com/ta7uw/cpp-pyprint
 */
#include "cpp-pyprint/pyprint.h"

#endif

void Main() {
    ll N, K;
    cin >> N >> K;
    vector<ll> A(N);
    rep(i, N) cin >> A[i];
    vector<ll> dp(K + 1, false);

    rep(i, K + 1) {
        rep(j, N) {
            ll a = A[j];
            if (i - a >=0) {
                dp[i] |= !dp[i - a];
            }
        }
    }
    if (dp[K]) {
        cout << "First" << '\n';
    } else {
        cout << "Second" << '\n';
    }
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    Main();
    return 0;
}


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

int main()
{
  int A, B;
  string S, T, U;

  cin >> S >> T >> A >> B >> U;

  if (U == S)
  {
    A--;
  }
  if (U == T)
  {
    B--;
  }

  cout << A << " " << B << endl;
}


Measured memory_bytes: 256
x, y = map(int, input().split())

candidates = []
for i in range(1 << 2):
    _x, _y = x, y
    c = 0
    if i & 1:
        _x *= -1
        c += 1
    if i & 2:
        _y *= -1
        c += 1
    if _x <= _y:
        c += _y - _x
        candidates.append(c)
print(min(candidates))


Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n;
	int a[200002];
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		cin>>a[i];
	}
	int f=1;
	for(int i=n;i>0;i-=2)
	{
		if(f)f=0;
		else cout<<" ";
		cout<<a[i];
	}
    for(int i=(n&1)+1;i<=n;i+=2)
    {
    	if(f)f=0;
		else cout<<" ";
		cout<<a[i];
	}
	cout<<endl;
	return 0;
}


Measured memory_bytes: 2944
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <algorithm>

using namespace std;

#define rep(i,j) REP((i), 0, (j))
#define REP(i,j,k) for(int i=(j);(i)<(k);++i)
#define BW(a,x,b) ((a)<=(x)&&(x)<=(b))
#define ALL(v) (v).begin(), (v).end()
#define LENGTHOF(x) (sizeof(x) / sizeof(*(x)))
#define AFILL(a, b) fill((int*)a, (int*)(a + LENGTHOF(a)), b)
#define SQ(x) ((x)*(x))
#define Mod(x, mod) (((x)+(mod)%(mod))
#define MP make_pair
#define PB push_back
#define F first
#define S second
#define INF (1<<29)
#define EPS 1e-10
#define MOD 1000000007

typedef pair<int, int> P;

int N,W,H;
P Y[100005],X[100005];

int main(){
  cin>>N>>W>>H;
  rep(i,N){
    int x,y,w; cin>>x>>y>>w;
    Y[i] = P(y,w); X[i] = P(x,w);
  }
  sort(Y,Y+N); sort(X,X+N);
  int p=0;
  rep(i,N){
    if(p < Y[i].F-Y[i].S || Y[i].F+Y[i].S < p) continue;
    p = Y[i].F+Y[i].S;
    if(p >= H){cout<<"Yes\n"; return 0;}
  }
  p=0;
  rep(i,N){
    if(p < X[i].F-X[i].S || X[i].F+X[i].S < p) continue;
    p = X[i].F+X[i].S;
    if(p >= W){cout<<"Yes\n"; return 0;}
  }
  cout<<"No\n";
  return 0;
}

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

int main(){
  int a, b, temp;
  int ans[3];

  scanf("%d %d", &a, &b);

  ans[0] = a + b;
  ans[1] = a - b;
  ans[2] = a * b;
 
  temp = ans[0];
  for(int i = 1; i < 3; i++){
    if( temp < ans[i]){
      temp = ans[i];
    }
  }

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



Measured memory_bytes: 256
import sys


def input():
    return sys.stdin.readline().rstrip()


def main():
    s = input()
    n = len(s) - 1

    ans = 0

    for bit in range(1 << n):
        # 各場合で式 f を生成する
        f = s[0]

        for i in range(n):
            if bit & (1 << i):
                # フラグが立っているならば "+" を式の末尾に追加する
                f += "+"
            f += s[i + 1]

        ans += sum(map(int, f.split("+")))

    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 41324
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vin=vector<int>;
using vll=vector<long long>;
using vvin=vector<vector<int>>;
using vvll=vector<vector<long long>>;
using vstr=vector<string>;
using vvstr=vector<vector<string>>;
using vch=vector<char>;
using vvch=vector<vector<char>>;
using vbo=vector<bool>;
using vvbo=vector<vector<bool>>;
using vpii=vector<pair<int,int>>;
using pqsin=priority_queue<int,vector<int>,greater<int>>;
#define mp make_pair
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep2(i,s,n) for(int i=(s);i<(int)(n);i++)
#define all(v) v.begin(),v.end()
#define decp(n) cout<<fixed<<setprecision((int)n)
const int inf=1e9+7;
const ll INF=1e18;

int main(){
    string s;cin>>s;
    int n=s.size();
    if(s[0]!=s[n-1]){
        if(n%2)cout<<"First"<<endl;
        else cout<<"Second"<<endl;
    }
    else{
        if(n%2)cout<<"Second"<<endl;
        else cout<<"First"<<endl;
    }
}

Measured memory_bytes: 3744
#include <bits/stdc++.h>
#include <iostream>
#include <iomanip>
using namespace std;
int main(){
double n,m,d,ans;
cin >> n >> m >> d;
if (d!=0) {
ans=2*(n-d)*(m-1);
cout << setprecision(20)<< ans /(n*n);
}
else {
cout << setprecision(20)<<(m-1) /n;
}

}

Measured memory_bytes: 256
m, d = map(int, input().split())

ans = 0

if d > 9:
    for i in range(d - 9):
        s = str(i + 10)
        if int(s[-1]) > 1 and int(s[-2]) > 1:
            t = int(s[-1]) * int(s[-2])
            if t <= m and t != 0:
                ans += 1

print(ans)


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

using namespace std;

using ll = long long;
using pii = pair<int,int>;
using pll = pair<ll,ll>;
using vi = vector<int>;
using vl = vector<ll>;

using _loop_int = int;
#define REP(i,n) for(_loop_int i=0; i<(_loop_int)(n); i++)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a); i<(_loop_int)(b); i++)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1; i>=(_loop_int)(a); i--)

#define CHMIN(a,b) (a)=min((a),(b))
#define CHMAX(a,b) (a)=max((a),(b))
#define ALL(v) (v).begin(),(v).end()

#define DEBUG(x) cerr<<#x<<": "<<(x)<<endl
#define DEBUG_VEC(v) cerr<<#v<<": ";REP(__i,(v).size())cerr<<((v)[__i])<<", ";cerr<<endl

const ll MOD = 1000000007ll;

int n;
int a[125252], b[125252];

int ids[125252];
int c[125252], d[125252];

int x[125252];

int main(){
    scanf("%d",&n);
    REP(i,n)scanf("%d",a+i);
    REP(i,n)scanf("%d",b+i);

    REP(i,n)ids[i] = i;
    sort(ids,ids+n,[&](int i, int j){
        if(b[i]==b[j])return a[i]<a[j];
        return b[i] < b[j];
    });
    REP(i,n)c[i] = a[ids[i]];
    REP(i,n)d[i] = b[ids[i]];

    // REP(i,n)printf("%d ",c[i]);puts("");
    // REP(i,n)printf("%d ",d[i]);puts("");
    REP(i,n)x[i] = c[i];
    sort(x,x+n);
    bool ok = true;
    REP(i,n)ok = ok && x[i]<=d[i];
    if(!ok){
        puts("No");
        return 0;
    }

    ok = false;
    FORR(i,1,n){
        if(x[i] <= d[i-1]){
            ok = true;
        }
    }
    if(ok){
        // 完全置換ではない
        puts("Yes");
        return 0;
    }
    map<int,int> M;
    REP(i,n)M[x[i]] = i;
    vi g(n);
    REP(i,n)g[i] = M[c[i]];
    int cnt = 0;
    int cur = 0;
    do{
        cnt++;
        cur = g[cur];
    }while(cur != 0);
    puts(cnt==n ? "No" : "Yes");
    return 0;
}


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

using namespace std;

#define ll long long
#define pb push_back
#define all(x) x.begin(), x.end()
#define mp make_pair

void solve (int u) {

    string n, m;
    cin >> n >> m;

    int ns = n.size(), ms = m.size();

    int L[ns + 1][ms + 1];

    for (int i = 0; i <= ns; ++i) {
        for (int j = 0; j <= ms; ++j) {
            if (i == 0 || j == 0) L[i][j] = 0;
            else if (n[i - 1] == m[j - 1]) L[i][j] = L[i - 1][j - 1] + 1;
            else L[i][j] = max(L[i - 1][j], L[i][j - 1]);
        }
    }

    int ind = L[ns][ms];
    char lcs[ind + 1];
    lcs[ind] = '\0';

    int i = ns, j = ms;

    while (i > 0 && j > 0) {

        if (n[i - 1] == m[j - 1]) {
            lcs[ind - 1] = n[i - 1];
            i--;
            j--;
            ind--;
        } else if (L[i - 1][j] > L[i][j - 1]) {
            i--;
        } else {
            j--;
        }
    }

    cout << lcs << "\n";

//    cout << "Case #" << k << ": " << count << "\n";

}

int main () {

    ios::sync_with_stdio(0);
    cin.tie(0);

    //int t;
    //cin >> t;
    //int k = 1;
    //while (t--) {
    //    solve(k);
    //    k++;
    //}

    solve(0);
}


Measured memory_bytes: 35456
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); i++)
#define ALL(x) (x).begin(),(x).end()
#define RALL(x) (x).rbegin(),(x).rend()
#define DEBUG(x)  cout << #x << " = " << (x) << endl;
#define SORT(x) sort(ALL(x));
#define RSORT(x) sort(RALL(x));
#define SUM(x) accumulate(ALL(x),0);
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using pii = pair<int, int>;
using tiii = tuple<int, int, int>;
const ll mod = 1000000007;
const double eps = 1e-9;
const int dx[4] = {1,0,-1,0};
const int dy[4] = {0,1,0,-1};
//cout << fixed << setprecision(10);

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

int main () {
  int N; cin >> N;
  vi A(N); rep(i,N) cin >> A[i];

  vi B(N);
  rep(i,N) {
    B[i] = A[i] - (i+1);
  }

  SORT(B);
  int b = (B[(N-1)/2]+B[N/2])/2;

  ll ans = 0;
  rep(i,N) {
    ans += abs(A[i] - (b + (i+1)));
  }
  
  cout << ans << endl;
}

Measured memory_bytes: 1792
#![allow(unused_imports)]
use std::io::*;
use std::fmt::*;
use std::str::*;
use std::cmp::*;
use std::collections::*;

macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

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

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

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

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

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

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        println!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);
    }
}

fn main() {
    input! {
        n: usize,
        a: i32, b: i32,
        p: [i32; n]
    };

    let level1 = p.iter().filter(|&&x| x <= a).count();
    let level2 = p.iter().filter(|&&x| a < x && x <= b).count();
    let level3 = p.iter().filter(|&&x| b < x).count();

    println!("{}", min(level1, min(level2, level3)));
}


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

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

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

/**
 * @brief 多次元 vector の作成
 * @author えびちゃん
 */
namespace detail {
    template<typename T, int N>
    auto make_vec(vector<int>& sizes, T const& x) {
        if constexpr (N == 1) {
            return vector(sizes[0], x);
        } else {
            int size = sizes[N-1];
            sizes.pop_back();
            return vector(size, make_vec<T, N-1>(sizes, x));
        }
    }
}
template<typename T, int N>
auto make_vec(int const(&sizes)[N], T const& x = T()) {
    vector<int> s(N);
    for (int i = 0; i < N; ++i) s[i] = sizes[N-i-1];
    return detail::make_vec<T, N>(s, x);
}

__attribute__((constructor))
void fast_io() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
}

long long gcd(long long a, long long b) { return b ? gcd(b, a%b) : a;}
long long lcm(long long a, long long b) { return a / gcd(a, b) * b;}

ll f(ll x, ll y) {
    return x / y;
}

int main() {
    ll a, b, c, d;
    cin >> a >> b >> c >> d;
    ll l = lcm(c, d);
    a--;

    ll p = f(a, c) + f(a, d) - f(a, l);
    ll q = f(b, c) + f(b, d) - f(b, l);
    ll ans = b - a - (q - p);
    cout << ans << '\n';
}


Measured memory_bytes: 3660
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 r = int.Parse(Console.ReadLine());
            int ans;

            ans = 3 * r * r;

            Console.WriteLine(ans);

            
        }
    }
}

Measured memory_bytes: 13140
# abc111_b.py
# https://atcoder.jp/contests/abc111/tasks/abc111_b

# B - AtCoder Beginner Contest 111 /
# 実行時間制限: 2 sec / メモリ制限: 1024 MB
# 配点 : 200点

# 問題文
# 黒橋君は，AtCoder Beginner Contest (ABC) にまだ参加したことがありません．
# 次に行われる ABC は第 N回です． 
# 黒橋君は，初めて参加する ABC を第 x 回としたときに，xの十進法表記でのすべての桁の数字が同じであるようにしたいです．
# 黒橋君が初めて参加する ABC としてふさわしいもののうち，最も早いものは第何回でしょうか？

# 制約
#     100≤N≤999
#     Nは整数

# 入力
# 入力は以下の形式で標準入力から与えられる．
# N

# 出力
# 黒橋君が初めて参加する ABC としてふさわしいもののうち，最も早いものは第何回かを出力せよ．

# 入力例 1
# 111

# 出力例 1
# 111

# 次に行われる ABC は第 111回です． これは黒橋君が初めて参加する ABC としてふさわしいです．

# 入力例 2
# 112

# 出力例 2
# 222

# 次に行われる ABC は第 112回です．そのため，第 111 回の ABC にはもう参加することはできません． 
# 黒橋君が初めて参加する ABC としてふさわしいもののうち，最も早いものは第 222回です．

# 入力例 3
# 750

# 出力例 3
# 777


def calculation(lines):
    N = int(lines[0])
    # X, Y = list(map(int, lines[0].split()))
    # n = lines[0]

    if N % 111 == 0:
        result = N
    else:
        result = -(-N//111) * 111 

    return [result]


# 引数を取得
def get_input_lines(lines_count):
    lines = list()
    for _ in range(lines_count):
        lines.append(input())
    return lines


# テストデータ
def get_testdata(pattern):
    if pattern == 1:
        lines_input = ['111']
        lines_export = [111]
    if pattern == 2:
        lines_input = ['112']
        lines_export = [222]
    if pattern == 3:
        lines_input = ['750']
        lines_export = [777]
    return lines_input, lines_export


# 動作モード判別
def get_mode():
    import sys
    args = sys.argv
    if len(args) == 1:
        mode = 0
    else:
        mode = int(args[1])
    return mode


# 主処理
def main():
    import time
    started = time.time()
    mode = get_mode()
    if mode == 0:
        lines_input = get_input_lines(1)
    else:
        lines_input, lines_export = get_testdata(mode)

    lines_result = calculation(lines_input)

    for line_result in lines_result:
        print(line_result)

    # if mode > 0:
    #     print(f'lines_input=[{lines_input}]')
    #     print(f'lines_export=[{lines_export}]')
    #     print(f'lines_result=[{lines_result}]')
    #     if lines_result == lines_export:
    #         print('OK')
    #     else:
    #         print('NG')
    # finished = time.time()
    # duration = finished - started
    # print(f'duration=[{duration}]')


# 起動処理
if __name__ == '__main__':
    main()


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

using namespace std;

#define endl           '\n'
#define LL             long long
#define ULL            unsigned long long
#define all(x)         x.begin(), x.end()


const LL Mod = 1000000007;
const int N = 50 + 5;

int n, m;
string a[N];
string b[N];

inline bool Found(int p, int q) {
    for (int i = p, ii = 0; i < p + m; i++, ii++) {
        for (int j = q, jj = 0; j < q + m; j++, jj++) {
            if (a[i][j] != b[ii][jj]) return false;
        }
    }
    return true;
}

int main() {
    cin >> n >> m;
    if (m > n) return !printf("No\n");
    for (int i = 0; i < n; i++) cin >> a[i];
    for (int i = 0; i < m; i++) cin >> b[i];
    for (int i = 0; i <= n - m; i++) {
        for (int j = 0; j <= n - m; j++) {
            if (Found(i, j)) return !printf("Yes\n");
        }
    }
    puts("No");
}

Measured memory_bytes: 256
fn main() {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    if  s.chars().nth(0) == s.chars().nth(1) && s.chars().nth(1) == s.chars().nth(2) ||
        s.chars().nth(1) == s.chars().nth(2) && s.chars().nth(2) == s.chars().nth(3) {
        println!("Yes");
    }
    else {
        println!("No");
    }

}


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

int main(){
    int N;
    cin>>N;
    int arr[N];
    for(int i=0; i<N; i++)cin>>arr[i];
    int dp[N];
    dp[0]=0;
    dp[1]=abs(arr[1]-arr[0]);
    for(int i=2; i<N; i++){
        dp[i]=min(dp[i-2]+abs(arr[i-2]-arr[i]), dp[i-1]+abs(arr[i-1]-arr[i]));
    }
    cout<<dp[N-1]<<endl;
}

Measured memory_bytes: 1024
'''
    Auther: ghoshashis545 Ashis Ghosh
    College: jalpaiguri Govt Enggineering College

'''
from os import path
import sys
from heapq import heappush,heappop
from functools import cmp_to_key as ctk
from collections import deque,defaultdict as dd 
from bisect import bisect,bisect_left,bisect_right,insort,insort_left,insort_right
from itertools import permutations
from datetime import datetime
from math import ceil,sqrt,log,gcd
def ii():return int(input())
def si():return input().rstrip()
def mi():return map(int,input().split())
def li():return list(mi())
abc='abcdefghijklmnopqrstuvwxyz'
mod=1000000007
# mod=998244353
inf = float("inf")
vow=['a','e','i','o','u']
dx,dy=[-1,1,0,0],[0,0,1,-1]

def bo(i):
    return ord(i)-ord('a')

def ceil(a,b):
    return (a+b-1)//b
file=1

def f():
    sys.stdout.flush()





def solve():

    # for _ in range(ii()):
   
    n,x,m = mi()  
    m1 = {}
    m1[x]=0
    a = [x]
    ans = x
    f  = 0
    for i in range(1,n):
        x = (x*x)%m
        if x in m1:
            now = i
            f = 1
            break
        m1[x] = i
        if x==0:
            print(ans)
            exit(0)
        ans += x
        a.append(x)
    if(f == 0):
        print(ans)
        exit(0)

    ans = 0
    for i in range(m1[x]):
        ans += a[i]
    b = []
    cnt = n - m1[x] 
    ans1 = 0
    x1 = cnt//(now-m1[x])
    cnt %= (now-m1[x])
    for i in range(m1[x],len(a)): 
        ans1 += a[i]
    k = m1[x]
    ans += (ans1*x1)
    for i in range(cnt):
        ans += a[k+i]
    print(ans)









        
if __name__ =="__main__":

   
    if path.exists('input.txt'):
        sys.stdin=open('input.txt', 'r')
        sys.stdout=open('output.txt','w')
    else:
        input=sys.stdin.readline
    solve()
    

Measured memory_bytes: 78164
#include <iostream>
#include <algorithm>
#include <math.h> 
#include <string>
#include <iomanip>
#include <queue>
using namespace std;
int main(){
    string s;
    cin >> s;
    int ans = 0;
    for(int i = 0; i < 4; i++){
        if(s[i] == '+') ans = ans + 1;
        if(s[i] == '-') ans = ans - 1;
    } 
    cout << ans << endl;
}

Measured memory_bytes: 256
import sys
from collections import defaultdict
def input(): return sys.stdin.readline().strip()


def main():
    S = input()
    l = len(S)

    # base[i] = 10**i % 2019
    base = [0] * l
    base[0] = 1
    for i in range(1, l):
        base[i] = (base[i - 1] * 10) % 2019 

    d = defaultdict(int)
    #show = [0] * l
    pre = 0
    for i in range(l):
        j = l - i - 1
        rem = (pre + int(S[j]) * base[i]) % 2019 # rem = (S[j]...S[l-1]) % 2019
        d[rem] += 1
        #show[j] = rem
        pre = rem
    #print(show)
    
    ans = 0
    for rem in d:
        n = d[rem]
        ans += n * (n - 1) // 2
    print(ans + d[0])

    
    
    

if __name__ == "__main__":
    main()


Measured memory_bytes: 70560
#include <iostream>
#include <vector>
#include <algorithm>
#include <fstream>
using namespace std;

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

int main(int argc, const char * argv[]) {
    int n;
    long long int c, k;
    long long int t[100010];
    
    cin >> n >> c >> k;
    rep(i, n) cin >> t[i];
    sort(t, t + n);
    
    int ans = 1;
    long long int cusnum = 0;
    
    long long int genkai = t[0] + k;
    
    rep(i, n) {
        
        if(cusnum < c && t[i] <= genkai) {
            ++cusnum;
        }
        else {
            genkai = t[i] + k;
            cusnum = 1;
            ++ans;
        }
    }
    
    cout << ans << endl;
}


Measured memory_bytes: 3912
#include<iostream>
#include<vector>
#include<map>
#include<string>
#include<utility>
#include<algorithm>
#include<cstdio>
#include<iomanip>
using namespace std;
#define ll int64_t
#define REP(i, n) for (ll i=0; i<n; i++)

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

    string N;
    cin >> N;

    int ans = N[0] - '0' + 9 * (N.size()-1);
    for (int i=1; i<N.size(); i++) {
        if (!(N[i] == '9')) {
            ans--;
            break;
        }
    }

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

Measured memory_bytes: 256
#!/usr/bin/env python
# -*- coding: utf-8 -*-

"""
input:
3 5
0 1 1
0 2 2
0 3 3
1 1 2
1 2 2

output:
3
2
"""

import sys


class BinaryIndexedTree(object):
    __slots__ = ('length', 'dat')

    def __init__(self, n):
        """
        Init a BIT with update and find for range sum queries.
        """
        self.length = int(n)
        self.dat = [0] * (self.length + 1)

    # sum(A[1] ... A[i])
    def __init_sum(self, i):
        _sum = 0
        while i > 0:
            _sum += self.dat[i]
            i -= i & (-i)
        return _sum

    def get_sum(self, s, t):
        return self.__init_sum(t) - self.__init_sum(s - 1)

    # A[i] += x
    def get_add(self, i, x):
        while i <= self.length:
            self.dat[i] += x
            i += i & (-i)
        return None


def action(cmd_list):
    case = BinaryIndexedTree(n_num)
    
    for query in cmd_list:
        cmd, ele_1, ele_2 = map(int, query)
        if cmd == 0:
            case.get_add(ele_1, ele_2)
        elif cmd == 1:
            res = case.get_sum(ele_1, ele_2)
            print(res)

    return case


if __name__ == '__main__':
    _input = sys.stdin.readlines()
    n_num, q_num = map(int, _input[0].split())
    q_list = map(lambda x: x.split(), _input[1:])

    ans = action(q_list)

Measured memory_bytes: 18000
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <array>
#include <algorithm>
#include <utility>
#include <numeric>
#include <deque>
#include <stack>
#include <queue>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <cmath>
#include <limits>
#include <cassert>
#include <bitset>
#include <list>
#include <iomanip>
#include <cctype>
#include<chrono>
#include<random>

#define for0(i, N)    for (long long i = 0  ; i <  (N); ++i)
#define for1n(i, N)   for (long long i = 1  ; i <= (N); ++i)
#define for1(i, N)    for (long long i = 1  ; i <  (N); ++i)
#define forn(i, N)    for (long long i = 0  ; i <= (N); ++i)
#define forx(i, N, x) for (long long i = (x); i <  (N); ++i)
#define forl(i, N, x, a) for (long long i = (x), a = 0; a < (N);    \
                              i = (i + 1) % (N), ++a)
#define int long long

long double constexpr pi = 3.141592653589793;

template<class T>
constexpr T sigma1(T i, T n){
    return (n - i + 1) * (i + n) / 2;
}

template<class T>
constexpr T sigma2(T i, T n){
    return (i == 1 ? n * (n + 1) * (2 * n + 1) / 6 :
            sigma2(1, n) - sigma2(1, i - 1));
}

template<class T>
constexpr T sigma3(T i, T n){
    if (i == 1) {
        auto temp = sigma1(i, n);
        return temp * temp;
    }
    return sigma2(1, n) - sigma2(1, i - 1);
}

template<size_t i>
std::bitset<i> operator++(std::bitset<i> b, signed){
    static_assert(i <= 64, "Cannot cast 64bit int.");
    return b = (unsigned long long)b + 1;
}

template<size_t i>
std::bitset<i> operator++(std::bitset<i> b){
    static_assert(i <= 64, "Cannot cast 64bit int.");
    auto temp = b;
    b++;
    return temp;
}

template<size_t i>
std::bitset<i> operator--(std::bitset<i> b, signed){
    static_assert(i <= 64, "Cannot cast 64bit int.");
    return b = (unsigned long long)b - 1;
}

template<size_t i>
std::bitset<i> operator--(std::bitset<i> b){
    static_assert(i <= 64, "Cannot cast 64bit int.");
    auto temp = b;
    b--;
    return temp;
}

long long constexpr inf = std::numeric_limits<long long>::max();

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef priority_queue<ll> pq;
typedef priority_queue<ll,vector<ll>, greater<ll>> pql;
typedef stack<ll> stk;
typedef queue<ll> qu;
typedef pair<ll, ll> pll;
typedef map<ll, ll> mll;
typedef unordered_map<ll, ll> umll;
typedef set<ll> sll;
typedef unordered_set<ll> usll;
typedef vector<ll> vll;
typedef vector<ld> vld;
typedef vector<vector<ll>> vvll;


signed main(void){
    cin.tie(0); ios::sync_with_stdio(false);cout<<fixed<<setprecision(10);
    ll a;
    cin >> a;

    cout << a + a * a + a * a * a<< "\n";


    return 0;
}


Measured memory_bytes: 3648
N = int(input())
A = list(map(float, input().split()))

# コインをi枚使い、表がj枚である確率
dp = [[0]*(N+1) for _ in range(N+1)]
dp[0][0] = 1

for i in range(1, N+1):
    for j in range(i+1):
        if j-1 >= 0:
            dp[i][j] = dp[i-1][j-1]*A[i-1] + dp[i-1][j]*(1 - A[i-1])
        else:
            dp[i][j] = dp[i-1][j]*(1 - A[i-1])

print(sum([dp[N][i] for i in range(N//2+1, N+1)]))

Measured memory_bytes: 262408
def resolve():
    n, m = map(int, input().split())
    l = [list(map(int, input().split())) for _ in range(n)]
    l.sort()
    ans = 0
    drink = 0
    for i in range(n):
        cost = l[i][0]
        num = l[i][1]
        if drink + num >=m:
            ans += cost*(m-drink)
            print(ans)
            exit()
        else:
            drink += num
            ans += num*cost

resolve()

Measured memory_bytes: 60504
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const ll INF = 1LL << 60;

int main() {
    int a, b, c, d, e, k; cin >> a >> b >> c >> d >> e >> k;
    if (e - a > k) {
        cout << ":(" << endl;
    } else {
        cout << "Yay!" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
import java.io.File;
import java.io.IOException;
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Deque;
import java.util.Scanner;

public class Main {
 
	public static void main(String[] args) throws IOException {
		//File file = new File("input.txt");
		//Scanner sc = new Scanner(file);
		
		Scanner sc = new Scanner(System.in);
		
		while(true){
			int H = sc.nextInt();
			int W = sc.nextInt();
			if(H == 0 && W == 0) break;
			for(int i = 0; i < H; i++){
				for(int j = 0; j < W; j++){
					System.out.print("#");
				}
				System.out.println();
			}
			System.out.println();
		}
	}
}


Measured memory_bytes: 35428
using namespace std;
#include<bits/stdc++.h>
#define int long long
#define pb push_back 
#define IOS ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define ff first
#define ss second
#define all(x) x.begin(), x.end()
#define repa(i,a,b) for (int i=a; i<=b; i++)
#define repd(i,b,a) for (int i=b; i>=a; i--)
#define endl "\n"
//debugging
#define debug1(a) cout<<#a<<" = "<<(a)<<endl;
#define debug2(a,b) cout<<#a<<" = "<<(a)<<", "<<#b<<" = "<<(b)<<endl;
#define debug3(a,b,c) cout<<#a<<" = "<<(a)<<", "<<#b<<" = "<<(b)<<", "<<#c<<" = "<<(c)<<endl;
#define debug4(a,b,c,d) cout<<#a<<" = "<<(a)<<", "<<#b<<" = "<<(b)<<", "<<#c<<" = "<<(c)<<", "<<#d<<" = "<<(d)<<endl;

const int N = 1e+6+5;
int big = 1e+18+3;
int mod = 1e+9+7;

vector<int>ans;

void recurs(int beg)
{
    ans.pb(beg);

    int val = beg%10;

    if (beg>3234566668)
        return ;

    if (val!=9)
        recurs( beg*10+val+1 );

    if (val!=0)
        recurs (beg*10+val-1 );

    recurs(beg*10+val);
}

signed main()
{
    IOS;
    int k;

    cin>>k;

    repa(i,1,9)
        recurs(i);

    sort(all(ans));


    cout<<ans[(k-1)]<<endl;
    
    
}

Measured memory_bytes: 6256
#include <iostream>
#include<algorithm>
#include<string>
#include<vector>
#define _USE_MATH_DEFINES
#include <math.h>
#include <iomanip>
#include <stdio.h>
#include <numeric>
#include <cmath>
#include <limits>
#include <bitset> 
using namespace std;

int main()
{
	int a, b, c;
	cin >> a >> b >> c;
	for (int i = 1; i <= b; i++) {
		if ((a * i) % b == c)return cout << "YES" << endl,0;
	}
	cout << "NO" << endl;
}


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

int main() {
  int A, B, C, D;
  cin >> A >> B >> C >> D;

  if ((A + B) == (C + D)) {
    cout << "Balanced" << endl;
  } else if ((A + B) > (C + D)) {
    cout << "Left" << endl;
  } else {
    cout << "Right" << endl;
  }
}


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

using namespace std;

#define BUF_SIZE 1024

struct Node{
	int data;
	Node* prev;
	Node* next;
};

class ConnectedList{
public:
	ConnectedList(){
		motherNode = new Node();
		motherNode->data = -1;
		motherNode->prev = motherNode;	
		motherNode->next = motherNode;
	};
	~ConnectedList(){
		Node* tmpNode = motherNode->next;
		Node* nextNode;
		while(tmpNode != motherNode){
			nextNode = tmpNode->next;
			delete tmpNode;
			tmpNode = nextNode;
		}
		delete motherNode;
	};
	void insertNode(int x){
		Node* tmpNode = motherNode->next;
		motherNode->next = new Node();
		motherNode->next->data = x;
		motherNode->next->next = tmpNode;
		motherNode->next->prev = motherNode;
		tmpNode->prev = motherNode->next;
	};
	void deleteNode(int x){
		Node* tmpNode = motherNode->next;
		while(tmpNode != motherNode && tmpNode->data != x){
			tmpNode = tmpNode->next;
		}
		if(tmpNode != motherNode){	
			tmpNode->prev->next = tmpNode->next;
			tmpNode->next->prev = tmpNode->prev;
			delete tmpNode;
		}
	};

	void deleteFirst(){
		Node* tmpNode = motherNode->next;
		motherNode->next = motherNode->next->next;
		motherNode->next->prev = motherNode;
		delete tmpNode;	
	};

	void deleteLast(){
		Node* tmpNode = motherNode->prev;
		motherNode->prev = motherNode->prev->prev;
		motherNode->prev->next = motherNode;
		delete tmpNode; 
	};

	void showList(){
		Node* tmpNode = motherNode->next;
		printf("%d",tmpNode->data);
		tmpNode = tmpNode->next;
		while(tmpNode != motherNode){
			printf(" %d",tmpNode->data);
			tmpNode = tmpNode->next;
		}
		printf("\n");
	}

private:
	Node* motherNode;
};


int main(){

	char buf[BUF_SIZE];
	int n = atoi(fgets(buf,BUF_SIZE,stdin));

	ConnectedList list;

	for(int i = 0; i < n; i++){

		fgets(buf,BUF_SIZE,stdin);

		if(buf[6] == 'F'){
			list.deleteFirst();
		}else if(buf[6] == 'L'){
			list.deleteLast();
		}else{
			int S = 0;
			
			if(buf[0] == 'i'){	//insert x

				for(int i = 0; buf[i] != '\0';i++){
					if(buf[i] >= '0' && buf[i] <= '9'){
						S = 10*S + (buf[i] - '0');
					}
				}
				list.insertNode(S);
			}else{	
				for(int i = 0;buf[i] != '\0';i++){
					if(buf[i] >= '0' && buf[i] <= '9'){
						S = 10*S + (buf[i] - '0');
					}
				}
				list.deleteNode(S);
			}

		}

	}

	list.showList();

}



Measured memory_bytes: 34460
//bismillahir rahmanir rahim            //Author:Fayed Anik
 
#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
 
using namespace std;
//using namespace __gnu_pbds;
 
/*
template <typename T>  using ordered_set =
    tree<T, null_type, less<T>,   /// greater<T> for sorting decreasingly
    rb_tree_tag, tree_order_statistics_node_update>;
*/

#define         ll                          long  long
#define         lf                          double
#define         pb(x)                       push_back(x)
#define         ull                         unsigned long long
#define         sfl(a)                      scanf("%lld",&a)
#define         sf(a)                       scanf("%d",&a)
#define         pf(a)                       printf("%d\n",a)
#define         pfl(a)                      printf("%lld\n",a)
#define         FOR(x,n)                    for(ll x=1;x<=n;++x)
#define         pii                         pair< ll , ll >
#define         mp(a,b)                     make_pair(a,b)
#define         mod                         1000000007
#define         INF                         2e18
#define         f1                          first
#define         f2                          second
#define         all(v)                      v.begin(),v.end()
#define         PI                          acos(-1)
#define         printminusone               printf("-1\n")
#define         bug                         printf("bug")
#define         FILEIN                      freopen("in.txt","r",stdin)
#define         FILEOUT                     freopen("out.txt","w",stdout)
 
//ll SET(ll mask,ll pos){ return mask = (mask | (1ll<<pos)); }
//ll RESET(ll mask,ll pos){ return mask = mask & ~(1ll<<pos); }
//bool CHECK(ll mask,ll pos) { return (bool) (mask & (1ll<<pos)); }
//priority_queue <ll, vector<ll>, greater<ll> > pq;

#define lim 100005
ll a[lim],b[lim];

int main(){
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    ll n;
    sfl(n);
    FOR(i,n){
        sfl(a[i]);
    }
    for(ll i=0;i<=n;i++){
        if(i==0){
            b[i]=-INF;
        }
        else{
            b[i]=INF;
        }
    }
    ll val,pos;
    for(ll i=n;i>=1;i--){
        val = a[i];
        pos = upper_bound(b,b+n+1,val)-b;
        b[pos]=val;
    }
    for(ll i=n;i>=1;i--){
        if(b[i]!=INF){
            pfl(i);
            return 0;
        }
    }
}

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

int main(){
    int n;
    cin >> n;
    double p[n];
    rep(i,n) cin >> p[i];
    vector<vector<double>> dp(n+1,vector<double>(n+2,0.0));
    dp[0][0] = 1.0;
    rep(i,n){
        rep(j,n+1){
            dp[i+1][j] += (1.0-p[i])*dp[i][j];
            dp[i+1][j+1] += p[i]*dp[i][j];
        }
    }
    double ans = 0;
    for(int i = (n+1)/2; i <= n; i++) ans += dp[n][i];
    printf("%.12f",ans);
    return 0;
}


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

using namespace std;

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

    int a,b,c;
    char op;
    
    while (cin >> a >> op >> b, op != '?') {
        switch (op) {
            case '+':
                c = a + b;
                break;
                
            case '*':
                c = a*b;
                break;
                
            case '-':
                c = a - b;
                break;
                
            case '/':
                c = a / b;
                break;
                
            default:
                break;
        }
        cout << c << endl;
    }
    
    
    return 0;
}



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

int n, m, i;
long long ans[100010] = {};
int a[100010];
int b[100010];
int cnt[100010] = {};

// https://qiita.com/ofutonfuton/items/c17dfd33fc542c222396
struct UnionFind {
    vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2

    UnionFind(int N) : par(N) { //最初は全てが根であるとして初期化
        for(int i = 0; i < N; i++) par[i] = i;
    }

    int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }

    void unite(int x, int y) { // xとyの木を併合
        int rx = root(x); //xの根をrx
        int ry = root(y); //yの根をry
        ans[i] = ans[i+1];
        if (rx == ry) {
        	return; //xとyの根が同じ(=同じ木にある)時はそのまま
    	}else{
        	par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
        	ans[i] += (long long)cnt[rx] * (cnt[rx]-1) / 2;
        	ans[i] += (long long)cnt[ry] * (cnt[ry]-1) / 2;
        	cnt[ry] += cnt[rx];
        	ans[i] -= (long long)cnt[ry] * (cnt[ry]-1) / 2;
        	return;
        }
    }

    bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
};

int main(void){
	cin >> n >> m;
	UnionFind tree(n);
	ans[m] = (long long)n * (n-1) / 2;
	for(int i = 0; i < 100010; ++i){
		cnt[i] = 1;
	}
	for(int i = 0; i < m; ++i){
		cin >> a[i] >> b[i];
		a[i]--; b[i]--;
	}
	for(i = m-1; i >= 0; --i){
		tree.unite(a[i], b[i]);
		// cout << cnt[tree.root(a[i])] << endl;
	}
	for(int i = 1; i <= m; ++i){
		cout << ans[i] << endl;
	}
	return 0;
}

Measured memory_bytes: 3712
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) (v).begin(),(v).end()
#define out(a) cout << (a) << endl
using namespace std;
using ll = long long;
int main(){
    int n, t;
    cin >> n >> t;
    int mini=1001;
    for(int i=0; i<n; i++){
        int c, x;
        cin >> c >> x;
        if(x > t) continue;
        else mini = min(mini, c);
    }
    if(mini==1001) out("TLE");
    else out(mini);
}

Measured memory_bytes: 256