akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Collections.Generic;
using System.Linq;

class Program
{
    static string InputPattern = "InputX";

    static List<string> GetInputList()
    {
        var WillReturn = new List<string>();

        if (InputPattern == "Input1") {
            WillReturn.Add("3");
            WillReturn.Add("5");
            WillReturn.Add("10");
            WillReturn.Add("15");
            //25
        }
        else if (InputPattern == "Input2") {
            WillReturn.Add("3");
            WillReturn.Add("10");
            WillReturn.Add("10");
            WillReturn.Add("15");
            //35
        }
        else if (InputPattern == "Input3") {
            WillReturn.Add("3");
            WillReturn.Add("10");
            WillReturn.Add("20");
            WillReturn.Add("30");
            //0
        }
        else {
            string wkStr;
            while ((wkStr = Console.ReadLine()) != null) WillReturn.Add(wkStr);
        }
        return WillReturn;
    }

    static void Main()
    {
        List<string> InputList = GetInputList();
        long[] AArr = InputList.Skip(1).Select(X => long.Parse(X)).ToArray();
        Array.Sort(AArr);

        //点数が全て10の倍数の場合
        if (Array.TrueForAll(AArr, X => X % 10 == 0)) {
            Console.WriteLine(0);
            return;
        }

        long SumVal = AArr.Sum();
        if (SumVal % 10 > 0) {
            Console.WriteLine(SumVal);
            return;
        }

        for (int I = 0; I <= AArr.GetUpperBound(0); I++) {
            if (AArr[I] % 10 == 0) continue;
            else {
                SumVal -= AArr[I];
                Console.WriteLine(SumVal);
                return;
            }
        }
    }
}


Measured memory_bytes: 13524
#include <iostream>
#include <string>

int main() {
  std::string a, b, c;
  std::cin >> a >> b >> c;
  (a[a.length() - 1] == b[0] && b[b.length() - 1] == c[0]) ? std::cout << "YES\n" : std::cout << "NO\n";
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=1; i<(n); i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define sz(x) ((int)(x).size())
using ll=long long;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define MOD  1000000007
const ll INF=1e18;
template<class T>void show(vector<T>v){for (int i = 0; i < v.size(); i++){cerr<<v[i]<<" ";}cerr<<endl;}
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; }

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

int main(int argc, char const *argv[]) {
  int n;
  cin >> n;
  ll sum = 0;
  rep(i, n+1) rep(j, n+1) rep(k, n+1) sum += gcd(gcd(i, j), k);
  cout << sum << endl;
  return 0;
}

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

int main(){
    int x,y;
    scanf("%d %d", &x,&y);
    set<int> a{1,3,5,7,8,10,12},b{4,6,9,11};
    if(x == 2 || y == 2)printf("No\n");
    else if(a.count(x) == 1 && a.count(y) == 1)printf("Yes\n");
    else if(b.count(x) == 1 && b.count(y) == 1)printf("Yes\n");
    else printf("No\n");

    return 0;
}


Measured memory_bytes: 764
#include<stdio.h>

int main()
{
	int S,h,m,s;
	
         scanf("%d",&S);
	
	h=S/(60*60);
	m=(S%(60*60))/60;
	s=(S%(60*60))%60;
	printf("%d:%d:%d\n",h,m,s);
	return 0;
}

Measured memory_bytes: 592
//
//  main.cpp
//  ABC155C
#include <iostream>
#include<vector>
#include<map>
#include<algorithm>
using namespace std;
int main(int argc, const char * argv[]) {
    int N;
    cin>>N;
    string S;
    map<string,int>poll;
    int great=0;
    for (int i=0; i<N; i++) {
        cin>>S;
        if (poll.count(S)==0) { // 初出
            poll[S]=1;
        }else{
            poll[S]++; // 既出
        }
        great=max(poll[S],great); // 出現回数の最大値 great
    }
    vector<string>ans; // 出現回数が最大値のものをリストアップする
    for (auto itr=poll.begin(); itr!=poll.end(); ++itr) {
        if(itr->second==great){
            ans.push_back(itr->first);
        }
    }
    sort(ans.begin(),ans.end()); // 昇順にソート
    unsigned long length=ans.size();
    for (long i=0; i<length; i++) {
        cout<<ans.at(i)<<endl;
    }
    return 0;
}


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

void testcase(){
    int n;
    cin >> n;
    if (n==0)
        cout << "1";
    else
        cout << "0";
}


int main(){
    ios::sync_with_stdio(0);
    cin.tie(0);
    int q=1;
  //  cin >> q;
    while(q--){
    testcase();
    }
    return 0;
}



Measured memory_bytes: 3636
def main(N,h):
    inf = 2**31-1
    dp = [inf]*N
    dp[0] = 0
    for i in range(N-1):
        if i+1 < N:
            dp[i+1] = min(dp[i+1], dp[i] + abs(h[i]-h[i+1]))
        if i+2 < N:
            dp[i+2] = min(dp[i+2], dp[i] + abs(h[i]-h[i+2]))
    return dp[N-1]

N = int(input())
h = list(map(int,input().split()))
print(main(N,h))


Measured memory_bytes: 13908
#include <bits/stdc++.h>
        using namespace std;
        #define int long long
const int MAX = 2000003;
const int MOD = 1000000007;

//
int fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
int COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

        signed main() {
    cout<<fixed<<setprecision(15);
        int n,k,t=0;
        cin>>n>>k;
        int a[n];
        for(int i=0;i<n;i++)cin>>a[i];
        sort(a,a+n);
      
        int ng=-1ll*1000000000ll*1000000000ll;
        int ok=-1*ng,mid,ok2,ng2,mid2,c;
        while(abs(ok-ng)>1){
                mid=(ok+ng)/2;
        c=0;
                for(int i=0;i<n;i++){
                         if(mid>=a[i]*a[i])c--;
                        if(a[i]>0){
                                if(a[i]*a[0]>mid)continue;
                                ok2=0;
                                ng2=n;
                                while(abs(ok2-ng2)>1){
                                        mid2=(ok2+ng2)/2;
                                        if(abs(a[i])*a[mid2]<=mid)ok2=mid2;
                                        else ng2=mid2;
                                }
                                c+=ng2;
                        }
                        if(a[i]<0){
                                if(a[i]*a[n-1]>mid)continue;
                                ng2=-1;
                                ok2=n-1;
                                while(abs(ok2-ng2)>1){
                                        mid2=(ok2+ng2)/2;
                                        if(a[i]*a[mid2]>mid)ng2=mid2;
                                        else ok2=mid2;
                                }
                                c+=n-ok2;
                        }
                        if(a[i]==0){
                                if(mid>=0)c+=n;
                                
                        }
                      
                }
                if(c>=2*k)ok=mid;
                else ng=mid;
             ///   cerr<<mid<<' '<<c<<' '<<ng<<endl;
        }
      cout<<ok;

        }


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define CINA(a,n); REP(i,(n)){ cin >> (a)[i]; }

int main(){
  int N; cin>>N;
  int d[N]; CINA(d,N);
  sort(d,d+N);
  int m = N/2;
  cout << d[m]-d[m-1];
}

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

using namespace std;

#define pb push_back
#define mp make_pair
constexpr int INF = 1 << 29;
constexpr int MOD = 1000000007;
typedef long long ll;
typedef unsigned long long ull;

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

struct schedule {
	int t, x, y;
};

int main() {
	int N;
	vector<schedule> S;
	cin >> N;
	S.push_back((schedule){0, 0, 0});
	for (int i = 0; i < N; i++) {
		int t, x, y;
		cin >> t >> x >> y;
		S.push_back((schedule){t, x, y});
	}
	bool flag = true;
	for(int i = 0; i < N; i++) {
		int dt = S[i + 1].t - S[i].t;
		int l = abs(S[i + 1].x - S[i].x) + abs(S[i + 1].y - S[i].y);
		if (dt < l || (dt >= l && (dt - l) % 2 != 0)) flag = false;
	}
	if (flag) {
		cout << "Yes" << endl;
	} else {
		cout << "No" << endl;
	}
	return 0;
}


Measured memory_bytes: 1912
#include <iostream>
#include <vector>
#include <stack>

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

using namespace std;

vector<vector<int> > graph;
vector<vector<int> > invGraph;
vector<bool> seen;
vector<int> rootGroup;
stack<int> vStack;

void makeStack(int u) {
    seen[u] = true;
    for(int v: graph[u])
        if (! seen[v])
            makeStack(v);
    vStack.push(u);
}

void getConnectedCompRecur(int u, int root) {
    if (rootGroup[u] == -1) {
        rootGroup[u] = root;
        for(int v: invGraph[u])
            getConnectedCompRecur(v, root);
    }
}

void getConnectedComp() {
    while (! vStack.empty()) {
        int u = vStack.top();
        vStack.pop();
        getConnectedCompRecur(u, u);
    }
}

int main () {
    int V, E;
    cin >> V >> E;

    graph.resize(V);
    invGraph.resize(V);
    seen.resize(V, false);
    rootGroup.resize(V, -1);

    FOR(i,E) {
        int s, t;
        cin >> s >> t;

        graph[s].push_back(t);
        invGraph[t].push_back(s);
    }

    FOR(i, V)
        if (! seen[i]) makeStack(i);

    getConnectedComp();

    int Q;
    cin >> Q;
    FOR(i,Q) {
        int f, t;
        cin >> f >> t;
        cout << (rootGroup[f] == rootGroup[t]) << endl;
    }
}



Measured memory_bytes: 4364
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <string>
#include <vector>
#include <math.h>
#include <queue>
#include <deque>
#include <stack>
#include <map>
const int MOD = 1e9+7;
#define PI 3.14159265359
typedef long long ll;
using namespace std;


int main(){
	int a, b, c, k;
	cin >> a >> b >> c >> k;
	cout << max(a, max(b, c))*(pow(2, k)-1) + a + b + c << endl;
	return 0;
}


Measured memory_bytes: 4276
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

using namespace std;

#define _CRT_SECURE_NO_WARNINGS
#define REP(i, n) for(int i=0; i<n; i++)
#define FOR(i, m, n) for(int i=m; i<n; i++)
#define ALL(x) (x).begin(),(x).end()
#define INF 999999999

typedef vector<int> VI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

int n, m;
VS a(51), b(51);

bool cheak(int x, int y) {
	bool flag = true;
	REP(i, m) {
		REP(j, m) {
			if (b[i][j] != a[i + x][j + y])flag = false;
		}
	}
	return flag;
}
int main() {
	bool flag = false;
	cin >> n >> m;
	REP(i, n)cin >> a[i];
	REP(i, m)cin >> b[i];

	REP(i, n - m + 1) {
		REP(j, n - m + 1) {
			if (cheak(i, j))flag = true;
		}
	}
	if (flag)puts("Yes");
	else puts("No");
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
	#define LOCAL
	using namespace std;
	template <typename A, typename B>
	ostream& operator <<(ostream& out, const pair<A, B>& a) {
	out << "(" << a.first << "," << a.second << ")";
	return out;
	}
	template <typename T, size_t N>
	ostream& operator <<(ostream& out, const array<T, N>& a) {
	out << "["; bool first = true;
	for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "]";
	return out;
	}
	template <typename T>
	ostream& operator <<(ostream& out, const vector<T>& a) {
	out << "["; bool first = true;
	for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "]";
	return out;
	}
	template <typename T, class Cmp>
	ostream& operator <<(ostream& out, const set<T, Cmp>& a) {
	out << "{"; bool first = true;
	for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "}";
	return out;
	}
	template <typename U, typename T, class Cmp>
	ostream& operator <<(ostream& out, const map<U, T, Cmp>& a) {
	out << "{"; bool first = true;
	for (auto& p : a) { out << (first ? "" : ", "); out << p.first << ":" << p.second; first = 0;} out << "}";
	return out;
	}
	#ifdef LOCAL
	#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
	#else
	#define trace(...) 42
	#endif
	template <typename Arg1>
	void __f(const char* name, Arg1&& arg1){
	cerr << name << ": " << arg1 << endl;
	}
	template <typename Arg1, typename... Args>
	void __f(const char* names, Arg1&& arg1, Args&&... args){
	const char* comma = strchr(names + 1, ',');
	cerr.write(names, comma - names) << ": " << arg1 << " |";
	__f(comma + 1, args...);
	}
	#define rep(i,n) for(int i=0; i<(n); i++)
	using ll = long long;
	#define int long long
	using P = pair<int,int>;
	//#########################################
	signed main(){
		string s;cin >> s;
		int ret = 0;
		for(int i = 0,j;i < 3;i = j){
			for(;i < 3 && s[i] !='R';i++);
			if(i == 3)break;
			for(j = i+1;j < 3 && s[j] == 'R';j++);
			int len = j-i;
			ret = max(ret,len);
		}
		cout << ret << endl;
		return 0;
	}

Measured memory_bytes: 3596
package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
	"strconv"
)

func main() {
	nextReader = newScanner()
	n, m := nextInt(), nextInt()

	total := 0.0
	as := make([]float64, n)
	for i := 0; i < n; i++ {
		as[i] = float64(nextInt())
		total += as[i]
	}

	sort.Sort(sort.Reverse(sort.Float64Slice(as)))
	if as[m-1] >= total/float64(4*m) {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}

// ---------------------------------------------------------------
// I/O
// ---------------------------------------------------------------
var nextReader func() string

func newScanner() func() string {
	sc := bufio.NewScanner(os.Stdin)
	sc.Buffer(make([]byte, 1024), int(1e11))
	sc.Split(bufio.ScanWords)
	return func() string {
		sc.Scan()
		return sc.Text()
	}
}

func nextString() string { return nextReader() }

func nextInt() int { n, _ := strconv.Atoi(nextReader()); return n }

func nextInts(size int) []int {
	ns := make([]int, size)
	for i := 0; i < size; i++ {
		ns[i] = nextInt()
	}
	return ns
}


Measured memory_bytes: 1760
p[10],m[1<<20],v[8<<18],*d,*e,w,x,t,i,c;Q(y){m[y]&4&&v[y]<t?v[*++e=y]=v[x]+1:0;}main(n){scanf("%*d%d%d",&w,&n);for(x=w++;c=-~getchar(x++)%88%35;m[x]=c>13?p[c-14]=x,12:c);for(;i<n;)for(d=e=v+(1<<20),t=++v[*e=p[i++]];c=v[p[i]],c<t;Q(x-1),Q(x+1),Q(x-w),Q(x+w))x=*d++;x=!printf("%d\n",c-n);}

Measured memory_bytes: 0
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <math.h>
#define MOD 1000000007
typedef long long ll;
using namespace std;

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

  int ans=0;
  for(int i=n;i>0;i--){
    for(int j=0;j<i;j++){
      if(s[n-i+j]!=t[j]) break;
      if(j==i-1) ans=i;
    }
    if(ans>0) break;
  }

  cout<<2*n-ans<<endl;
  return 0;
}


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

#define rep(i, n) for(int i=0; i<n; i++)

int main() {
    int a, b; cin >> a >> b;
    cout << (b-1)/(a-1) + ((b-1)%(a-1)==0 ? 0 : 1) << endl;
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>

struct node{
  struct node *right;
  struct node *left;
  struct node *parent;
  int key;
};
typedef struct node * Node;
#define NIL NULL

Node root;

Node treeMinimum(Node x){

  while(x->left!=NIL) x=x->left;

  return x;

}
Node treeMaximum(Node x){

  while(x->right!=NIL) x=x->right;

  return x;

}

Node treeSearch(Node u, int k){

  if(u==NIL||k==u->key)
    return u;
  if(k<u->key)
    return treeSearch(u->left,k);
  else
    return treeSearch(u->right,k);

}

Node treeSuccessor(Node x){
  Node y;
  if(x->right!=NIL) return treeMinimum(x->right);//case 1                       

  y=x->parent;
  while(y!=NIL&&x==y->right){
    x=y;
    y=y->parent;
  }
  return y;//case 2                                                             

}
void treeDelete(Node z){
  Node y; // node to be deleted                                                 
  Node x; // child of y                                                         

  if(z->left==NIL||z->right==NIL) y=z;
  else y=treeSuccessor(z);

  if(y->left!=NIL) x=y->left;
  else x=y->right;

  if(x!=NIL) x->parent=y->parent;
  if(y->parent==NIL)
    y=x;
  else if(y==y->parent->left)
    y->parent->left=x;
  else
    y->parent->right=x;

  if(y!=z)
    z->key=y->key;
}
void insert(int k){
  Node y = NIL;
  Node x = root;
  Node z;

  z = malloc(sizeof(struct node));
  z->key = k;
  z->left = NIL;
  z->right = NIL;

  while(x!=NIL){
    y=x;
    if(z->key<x->key)
      x=x->left;
    else
      x=x->right;
  }
  z->parent=y;

  if(y==NIL)//Tree is empty                                                     
    root=z;
  else if(z->key<y->key)
    y->left=z;
  else
    y->right=z;

}

void inorder(Node u){
  if(u!=NIL){
    inorder(u->left);
    printf(" %d",u->key);
    inorder(u->right);
  }
}
void preorder(Node u){
  if(u!=NIL){
    printf(" %d",u->key);
    preorder(u->left);
    preorder(u->right);
  }
}
Node find(Node u,int k){

  if(u!=NIL&&u->key!=k){
    if(k<u->key) find(u->left,k);
    else find(u->right,k);
  }
  return u;
}
    
int main(){
  int n, i, x;
  char com[20];
  scanf("%d", &n);

  for ( i = 0; i < n; i++ ){
    scanf("%s", com);
    if ( com[0] == 'f' ){
      scanf("%d", &x);
      Node t = treeSearch(root, x);
      if ( t != NIL ) printf("yes\n");
      else printf("no\n");
    } else if ( com[0] == 'i' ){
      scanf("%d", &x);
      insert(x);
    } else if ( com[0] == 'p' ){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    } else if ( com[0] == 'd' ){
      scanf("%d", &x);
      treeDelete(treeSearch(root, x));
    } else if ( com[0] == 'f' ){
      scanf("%d",&x);
      Node a=find(root,x);
      if(a!=NIL) printf("yes\n");
      else printf("no\n");
    }
  }
  return 0;
}



Measured memory_bytes: 20532
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cstdint>
#include <cstdlib>
#include <cmath>
#include <complex>
#include <chrono>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>
#include <random>
#include <utility>
#include <limits>
#include <list>
#include <type_traits>

/* template start */

using i64=std::int_fast64_t;
using u64=std::uint_fast64_t;
 
#define rep(i, a, b) for (i64 i = (a); (i) < (b); (i)++)
#define all(i) i.begin(), i.end()

#ifdef LOCAL
#define debug(...) std::cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...)
#endif

void debug_out(){std::cerr<<std::endl;}

template<typename Head,typename... Tail>
void debug_out(Head h,Tail... t){
  std::cerr<<" "<<h;
  if(sizeof...(t)>0)std::cout<<" :";
  debug_out(t...);
}
 
template <typename T1, typename T2>
std::ostream& operator<<(std::ostream& os, std::pair<T1, T2> pa) {
  return os << pa.first << " " << pa.second;
}
 
template <typename T>
std::ostream& operator<<(std::ostream& os, std::vector<T> vec) {
  for (std::size_t i = 0; i < vec.size(); i++)os << vec[i] << (i + 1 == vec.size() ? "" : " ");
  return os;
}
 
template<typename T1,typename T2>
inline bool chmax(T1& a,T2 b){return a<b && (a=b,true);}
 
template<typename T1,typename T2>
inline bool chmin(T1& a,T2 b){return a>b && (a=b,true);}

template<typename Num>
constexpr Num mypow(Num a, u64 b,Num id=1) {
  if(b==0)return id;
  Num x = id;
  while (b > 0) {
    if(b & 1)x*=a;
    a*=a;
    b >>= 1;
  }
  return x;
}

/* template end */

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

  i64 x,k,d;
  std::cin>>x>>k>>d;

  x=std::abs(x);

  if(x/d > k){
    std::cout<<x-k*d<<"\n";
    return 0;
  }

  i64 ans=std::numeric_limits<i64>::max();

  rep(i,x/d-1,x/d+4){
    if(i%2 == k%2){
      chmin(ans,std::abs(x-i*d));
    }
  }

  std::cout<<ans<<"\n";
  
  return 0;
}

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

signed main(void){
  
  int Q; cin >> Q;
  
  priority_queue<int> former; //小さいもの半分を入れる、大きい順に取り出せるようにする
  priority_queue<int,vector<int>,greater<int>> later;
  //大きいもの半分を入れる、小さい順に取り出せるようにする
  
  int sum_B = 0,sum_former = 0,sum_later = 0;
  
  for(int i = 0; i < Q; i++){ 
    
    char c; cin >> c;
    
    if( c == '1'){
      
      //値追加query 
      string a,b; cin >> a >> b; int A = stoi(a); int B = stoi(b);
      sum_B += B;
     
      if( later.size() >= former.size() ){ 
        //前半分に値を追加したい
        
   
        if( former.empty() ) { 
          //一番初めだけ別途処理
          former.push(A);
          sum_former += A;
          continue;
        }
        
          
        int test = later.front();
        if( A < test ){ 
          former.push(A); 
          sum_former += A;
        }
        else{
          later.pop();
          sum_later -= test;
          
          former.push(test); 
          sum_former += test;
          
          later.push(A);
          sum_later += A;
        }
      }//前半分に追加する場合
      else{
        //後ろ半分に追加する場合
        int test = former.front();
        if( test < A ){ 
          later.push(A); sum_later += A;
        }
        else{
          former.pop();
          sum_former -= test;
          
          later.push(test);
          sum_later += test;
          
          former.push(A);
          sum_former += A;
        }
        
      }//後ろ半分に追加する場合終了
     
    } // if-(c==1) 
   
    
    
    else{ //最小値出力query
      
      if( former.size() == later.size() ){
        
        //偶数の時の中央値出力query
       
        
        cout << former.front() << " ";
        cout << sum_later - sum_former + sum_B  << endl;
      }
      else{ 
        //奇数の時の中央値出力query
        
        cout << former.front() << " ";
        cout << sum_later - sum_former + former.front() + sum_B << endl;
        
      }
      
    } //c == 2とじ
    
    
  }//for-Q
  
  return 0;
}

Measured memory_bytes: 3828
#include<iostream>
#include<vector>
#define pb push_back
using namespace std;

// U,R,D,L
vector<string> s[11];
char def[5] = {'a','i','u','e','o'};
char fed[10] = {'0','k','s','t','n','h','m','y','r','w'};
void init(){
  s[0].pb("wa");s[0].pb("wo");s[0].pb("nn");
  s[8].pb("ya");s[8].pb("yu");s[8].pb("yo");
  for(int i=1;i<10;i++){
    if(i == 8)continue;
    for(int j=0;j<=4;j++){
      string sin;
      if(i != 1)sin += fed[i-1];
      sin += def[j];
      s[i].push_back(sin);
    }
  }
  /*
  for(int i=0;i<10;i++){
    for(int j=0;j<s[i].size();j++){
      cout << s[i][j] << " ";
    }
    cout << endl;
  }
  */
}

int getrid(char c,char pre){
  if(!(pre == '8' || pre == '0')){
  if(c == 'T')return 0;
  if(c == 'L')return 1;
  if(c == 'U')return 2;
  if(c == 'R')return 3;
  if(c == 'D')return 4;
  }
  
  if(c == 'T')return 0;
  if(c == 'U'){
    if(pre == '8')return 1;
    return 2;
  }
  if(c == 'D'){
    if(pre == '8')return 2;
    return 1;
  }  

}

int main(){
  init();
  string S;
  cin >> S;

  for(int i=0;i<S.length();i+=2){
    cout << s[S[i]-'0'][getrid(S[i+1],S[i])];
  }
  cout << endl;

  return 0;
}

Measured memory_bytes: 1196
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <numeric>
#include <map>
#include <iomanip>
#include <limits.h>
#include <queue>

using namespace std;    
typedef long long ll;
typedef pair<ll, ll> pll;
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
const bool DEBUG = false;

class Map
{
    public:
    Map(int H, int W){
        height = H;
        width  = W;
        data.resize(H);
        for(int i = 0; i < H; i++) data[i].resize(W);
    }

    bool isIn(int h, int w){
        if(h < 0 || h >= height) return false;
        if(w < 0 || w >= width)  return false;
        return true;
    }

    ll get(int h, int w){
        if( isIn(h, w) ) return data[h][w];
        else return -1; 
    }

    void set(int h, int w, ll val){
        if( isIn(h, w) ){
            data[h][w] = val;
        }
    }

    vector < vector<ll> > data;
    int height;
    int width;

};


int main(){

    int N, M;
    cin >> N >> M;

    Map m1(N , N);
    Map m2(M , M);

    string s;
    for(int i = 0; i < N; i++){
        cin >> s;
        for(int j = 0; j < s.size(); j++){
            if(s[j] == '#') m1.set(i, j, 1);
            else m1.set(i, j, 0);
        }
    }

    for(int i = 0; i < M; i++){
        cin >> s;
        for(int j = 0; j < s.size(); j++){
            if(s[j] == '#') m2.set(i, j, 1);
            else m2.set(i, j, 0);
        }
    }

    bool flag = true;
    for(int i = 0; i < N; i++){
        for(int j = 0; j < N; j++){
            flag = true;
            for(int k = 0; k < M; k++){
                if(!flag) break;
                for(int l = 0; l < M; l++){
                    ll col1 = m1.get(i + k, j + l);
                    ll col2 = m2.get(k, l);
                    if(col1 != col2) flag = false;
                    if(!flag) break;
                }
            }
            if(flag){
                cout << "Yes" << endl;
                return 0;
            }
        }
    }

    cout << "No" << endl;

}

Measured memory_bytes: 256
n= int(input())
lis = list(map(int,input().split()))
ans = 0
status = 0
for high in range(1,101):
    for i in range(n):
        if lis[i] >= high:
            status = 1
        else:
            if status == 1:
                ans += 1
                status = 0
    ans += status
    status = 0
print(ans)

Measured memory_bytes: 3060
def main():
    from math import ceil
    n, a, b, *k = map(int, open(0).read().split())
    k.sort()

    l = k[-1] // a
    r = k[-1] // b + 1
    m = (l + r) // 2
    while l + 1 < r:
        c = sum(ceil((i - m * b) / (a - b)) if i - m * b > 0 else 0 for i in k)
        if c <= m:
            r = m
        else:
            l = m

        m = (l + r) // 2

    print(r)


if __name__ == '__main__':
    main()


Measured memory_bytes: 20152
#include <algorithm>
#include<iostream>
#include<stdio.h>
#include <algorithm>
#include<iostream>
#include<stdio.h>
#include<vector>
#include<set>
#include<string>
#include<iomanip>
#include<queue>
#include<functional>
#include<cmath>
#define rep(i,n) for(int i=0; i<(int)n; i++)//n回繰り返す
using namespace std;
using ll = long long;
using P = pair<int, int>;
using graph = vector<vector<int>>;
int main() {
	int a, b; cin >> a >> b;
	string A(a, b + '0'), B(b, a + '0');

	
	cout <<min(A,B)<< endl;
	

}




	
	


	


	


		






Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(a) (a).begin(),(a).end()
#define pb emplace_back
#define INF (1e9+1)

int main(){
    int h,w,k;
    cin>>h>>w>>k;
    
    for(int a=0;a<=h;a++){
        for(int b = 0; b<= w; b++){
            if(k==a*w + b*h - 2*a*b){
                cout<<"Yes"<<endl;
                return 0;
            }
        }
    }
    cout<<"No"<<endl;
}

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

map<int, int> c;
long long arr[100001];

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

    long long n, a, x, y;
    cin >> n;

    for (int i = 0; i < n; ++i)
    {
        cin >> a;
        arr[i] = a;
        c[a]++;
    }

    sort(arr, arr + n, greater<int>());

    bool doneone = false, donetwo = false;

    for (int i = 0; i < n; ++i)
    {
        if (c[arr[i]] > 1 && !doneone)
        {
            x = arr[i];
            doneone = true;
            if (c[arr[i]] > 3)
            {
                cout << (long long)x * x << '\n';
                return 0;
            }
        }
        else if (c[arr[i]] > 1 && !donetwo && arr[i] != x)
        {
            y = arr[i];
            donetwo = true;
            cout << (long long)x * y << '\n';
            return 0;
        }
    }
    cout << 0 << '\n';
}

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

int main() {
  int N; cin >> N;
  int A, B;
  if (N == 2) cin >> A >> B;  
  
  if (N == 1) cout << "Hello World" << endl;
  else cout << A + B << endl;
  return 0;
}

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

const int DIM = 2e5 + 5;

pair<int, int> arr[DIM];
int mn1[DIM], mn2[DIM], mx1[DIM], mx2[DIM];

int main( void ) {
    
    int n;
    cin >> n;
    
    for( int i = 1; i <= n; i ++ ) {
        cin >> arr[i].first >> arr[i].second;
        
        if( arr[i].first > arr[i].second )
            swap( arr[i].first, arr[i].second );
    }
    
    sort( arr + 1, arr + n + 1 );
    
    for( int i = 1; i <= n; i ++ ) {
        if( i == 1 )
            mn1[i] = mx1[i] = arr[i].second;
        else {
            mn1[i] = min( mn1[i - 1], arr[i].second );
            mx1[i] = max( mx1[i - 1], arr[i].second );
        }
    }
    
    for( int i = n; i >= 1; i -- ) {
        if( i == n )
            mn2[i] = mx2[i] = arr[i].second;
        else {
            mn2[i] = min( mn2[i + 1], arr[i].second );
            mx2[i] = max( mx2[i + 1], arr[i].second );
        }
    }
    
    long long ans = 1LL * ( arr[n].first - arr[1].first ) * ( mx1[n] - mn1[n] );
    
    for( int i = 1; i < n; i ++ ) {
        int mi1 = min( arr[1].first, mn2[i + 1] ), ma1 = max( arr[i].first, mx2[i + 1] );
        int mi2 = min( arr[i + 1].first, mn1[i] ), ma2 = max( arr[n].first, mx1[i] );
        
        ans = min( ans, 1LL * ( ma1 - mi1 ) * ( ma2 - mi2 ) );
    }
    
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 4992
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define ALL(x) (x).begin(), (x).end()
typedef long long ll;
typedef pair<int, int> pii;
const int INF = 1e9;
const int MOD = 1000000007;
const double PI = acos(-1);
int dx[4] = {0,1,0,-1};
int dy[4] = {1,0,-1,0};

void solve() {
	int n, k;
	cin >> n >> k;
	int r, s, p;
	cin >> r >> s >> p;
	string t;
	cin >> t;
	ll ans = 0;
	for (int i = 0; i < k; i++) {
		char c = 'x';
		for (int j = i; j < n; j += k) {
			if (c == t[j]) c = 'x';
			else {
				if (t[j] == 'r') ans += p;
				else if (t[j] == 's') ans += r;
				else ans += s;
				c = t[j];
			}
		}
	}
	cout << ans << endl;
}

int main() {
	solve();
	return 0;
}

Measured memory_bytes: 3756
import itertools
N=int(input())
r= [[int(i) for i in input().split()] for i in range(N)]
l=list(itertools.permutations(range(N)))
ans=[]
for i in range(len(l)):
    length_list=[]
    for j in range(N-1):
        length_list.append(((r[l[i][j]][0]-r[l[i][j+1]][0])**2+(r[l[i][j]][1]-r[l[i][j+1]][1])**2)**0.5)
    ans.append(sum(length_list))
print(sum(ans)/len(l))

Measured memory_bytes: 9332
/*https://bom.to/nxtvde2k1m4l*/
#include<bits/stdc++.h>
using namespace std;
template <typename A, typename B>
string to_string(pair<A, B> p);

template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p);

template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p);

string to_string(const string& s) {
  return '"' + s + '"';
}

string to_string(const char* s) {
  return to_string((string) s);
}

string to_string(bool b) {
  return (b ? "true" : "false");
}

string to_string(vector<bool> v) {
  bool first = true;
  string res = "{";
  for (int i = 0; i < static_cast<int>(v.size()); i++) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(v[i]);
  }
  res += "}";
  return res;
}

template <size_t N>
string to_string(bitset<N> v) {
  string res = "";
  for (size_t i = 0; i < N; i++) {
    res += static_cast<char>('0' + v[i]);
  }
  return res;
}

template <typename A>
string to_string(A v) {
  bool first = true;
  string res = "{";
  for (const auto &x : v) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(x);
  }
  res += "}";
  return res;
}

template <typename A, typename B>
string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}

template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p) {
  return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ")";
}

template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p) {
  return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ", " + to_string(get<3>(p)) + ")";
}

void debug_out() { cout << endl; }

template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cout << " " << to_string(H);
  debug_out(T...);
}

#define debug(...) cout << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#define task "e"
typedef pair<int,int> ii;
typedef long long ll;
void init()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    freopen(task".inp","r",stdin);
    freopen(task".out","w",stdout);
}
int n;
ll dp[105][3][5];
string a;
ll cal(int pos, int ok, int j)
{
    if (j == 0) {
        return 1;
    }
    if (pos == n + 1) return 0;
    ll &res = dp[pos][ok][j];
    if (res != - 1) return res;
    res = 0;
    int low = 0, high = 9;
    if (!ok) high = a[pos] - '0';
    for (int i = low; i <= high; i ++) {
        int new_ok = 1;
        if (!ok && i == high) new_ok = 0;
        if (i == 0) res += cal(pos + 1, new_ok, j );
        else if (j - 1 >= 0) res += cal(pos+1,new_ok , j - 1);
    }
    return res;
}
int main()
{

    /// dp[i][j] the i_th digit and contains j
    cin >> a;
    int k ; cin >> k;
    a = " " + a;
    memset(dp,-1,sizeof(dp));
    n = a.length() - 1;
    cout << cal(1,0,k);
}







Measured memory_bytes: 256
target = int(input()) + 1
fib = [0 for n in range(target + 1)]
for i in range(target + 1):
    if i == 0:
        continue
    elif i == 1:
        fib[i] = 1
    else:
        fib[i] = fib[i - 1] + fib[i - 2]
print(fib[target])

Measured memory_bytes: 7768
#include <bits/stdc++.h>
#define INT long long
using namespace std;
INT n, W[300030], E[300030], ans;
string s;
int main()
{
    ios::sync_with_stdio(false);
    cin>>n>>s;
    for(int i = 0 ; i < n ; i++ )
        if( s[i] == 'W' ) W[i] = W[i-1]+1, E[i] = E[i-1];
        else W[i] = W[i-1], E[i] = E[i-1] +1;
    ans = min( W[n-1], E[n-1] );
    for(int i = 0 ; i < n ; i++ )
        ans = min( ans, W[i]+E[n-1]-E[i] );
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 5396
#include <iostream>
#include <algorithm>

using namespace std;

int main()
{
	int v[3];
	for (int a = 0; a < 3; a++) {
		cin >> v[a];
	}
	sort(v,v+3);
	cout << v[0] << ' ' << v[1] << ' ' << v[2] << endl;
}


Measured memory_bytes: 3144
#include "bits/stdc++.h"
using namespace std;

#define all(container) container.begin(), container.end()
#define sortall(container) (sort(container.begin(), container.end()))
#define yn(cond) ((cond) ? (cout << "yes" << endl) : (cout << "no" << endl))
#define Yn(cond) ((cond) ? (cout << "Yes" << endl) : (cout << "No" << endl))
#define YN(cond) ((cond) ? (cout << "YES" << endl) : (cout << "NO" << endl))

typedef long long       ll;

typedef vector<int>     vi;
typedef vector<ll>      vll;
typedef vector<double>  vd;
typedef vector<bool>    vb;
typedef vector<char>    vc;
typedef vector<string>  vs;
typedef pair<int, int>  pii;
typedef pair<ll, ll>    pll;
typedef vector<vi>		vvi;
typedef vector<vll>		vvll;
typedef vector<vd>		vvd;
typedef vector<vb>		vvb;
typedef vector<vc>		vvc;
typedef vector<vs>		vvs;
typedef vector<pii>     vpii;
typedef vector<pll>     vpll;

typedef struct edge_ {
	ll to;
	ll cost;
} edge;

typedef struct point_ {
	ll x, y;
	point_(ll x = 0, ll y = 0) : x(x), y(y) {}
} point;

template <typename T>
using mat2d = vector<vector<T>>;

constexpr double	PI = 3.14159265358979323846;
constexpr ll		INF = 1 << 15;
constexpr ll		MOD = (ll)1e9 + 7;
constexpr double	EPS = 1e-7;
constexpr int		dy4[4] = { 0, 1, 0, -1 };
constexpr int		dx4[4] = { 1, 0, -1, 0 };
constexpr int		dy8[8] = { 0, 1, 1, 1, 0, -1, -1, -1 };
constexpr int		dx8[8] = { 1, 1, 0, -1, -1, -1, 0, 1 };

template<typename T>
istream& operator >> (istream& is, vector<T>& vec) {
	for (T& x : vec) is >> x;
	return is;
}

template<typename T>
ostream& operator << (ostream& os, const vector<T>& vec) {
	for (const T& x : vec) os << x << " ";
	return os;
}

template<typename S, typename T>
istream& operator >> (istream& is, pair<S, T>& p) {
	is >> p.first >> p.second;
	return is;
}

istream& operator >> (istream& is, point& p) {
	is >> p.x >> p.y;
	return is;
}

template<typename S, typename T>
ostream& operator << (ostream& os, const pair<S, T>& p) {
	os << "{" << p.first << " : " << p.second << "}";
	return os;
}

template<typename T>
ostream& operator << (ostream& os, const set<T>& s) {
	for (const T& x : s) os << x << " ";
	return os;
}

ostream& operator << (ostream& os, const edge e) {
	os << "{to: " << e.to << ", cost: " << e.cost << "}";
	return os;
}

ostream& operator << (ostream& os, const point& p) {
	os << "(" << p.x << " " << p.y << ")";
	return os;
}

/******************************************************************************/
/**********************         Don't make WA !!         **********************/
/******************************************************************************/

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

	for (int m = 0; m < N; m++) {
		ll left = (C + D) * m - (N - 1) * D;
		ll right = (C + D) * m - (N - 1) * C;
		if (left <= B - A && B - A <= right) {
			cout << "YES" << endl;
			return 0;
		}
	}

	cout << "NO" << endl;

	return 0;
}

Measured memory_bytes: 256
using System;

namespace ITP1_2_A
{
	class Program
	{
		static void Main(string[] args)
		{
			string[] vs = Console.ReadLine().Split(' ');
			int a = int.Parse(vs[0]);
			int b = int.Parse(vs[1]);

			if(a < b) {
				Console.WriteLine("a < b");
			}
			else if(a == b) {
				Console.WriteLine("a == b");
			}
			else {
				Console.WriteLine("a > b");
			}
		}
	}
}



Measured memory_bytes: 15872
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstdlib>
#include <string>
using namespace std;
typedef long long ll;
//#define FOR(i,a,b) for(int i=(a);i<(b);++i)
//#define REP(i,n)  for(int i =0;i<n;++i)
#define mod (ll)(1e9+7)
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int  A= 0,B=0;
    cin >> A >> B;
    if(B==100)B=101;
    int ans = 1;
    int i=0;
    for(i=0;i<A;i++)ans*=100;
    cout << ans*B << endl;
    return 0;
}



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

int main(){
	int A,B,k;
	cin>>A>>B>>k;
	for(int i=0;i<k;i++){
		if(i%2==0){
			int a=A/2;
			B+=a;
			A=a;
		}
		else{
			int b=B/2;
			A+=b;
			B=b;
		}
	}
	cout<<A<<" "<<B<<endl;
	return 0;
}


Measured memory_bytes: 256
n=int(input())
a=list(map(int,input().split()))
cnt=[0]*3
ans=1
mod=10**9+7
for i in range(n):
	q=0
	if a[i]==cnt[0]:
		q+=1
	if a[i]==cnt[1]:
		q+=1
	if a[i]==cnt[2]:
		q+=1
	if a[i]==cnt[0]:
		cnt[0]+=1
	elif a[i]==cnt[1]:
		cnt[1]+=1
	else:
		cnt[2]+=1
	ans*=q
	ans%=mod
print(ans)


Measured memory_bytes: 13964
#include <iostream>

#define V_MIN -1000000000

using namespace std;

int main(){
    int n, maxv=V_MIN, minv, r;
    
    cin >> n >> minv;
    
    for(int j=1; j<n; j++){
        cin >> r;
        
        maxv = maxv<r-minv ? r-minv : maxv;
        minv = r<minv ? r : minv;
    }
    
    cout << maxv << "\n";
}



Measured memory_bytes: 3116
using System;
using System.Linq;
using System.Collections.Generic;
using System.Collections;

namespace Algorithm
{
    class Program
    {
        static void Main(string[] args)
        {
            var pq = new PriorityQueue<int>(isDescending: true);

            while (true)
            {
                var t = Console.ReadLine().Split();
                if (t == null || t[0] == "end") break;

                if (t[0] == "insert") pq.Enqueue(int.Parse(t[1]));
                else Console.WriteLine(pq.Dequeue());
            }
        }
    }

    public class PriorityQueue<T> : IEnumerable<T>
    {
        private readonly List<T> _data = new List<T>();
        private readonly IComparer<T> _comparer;
        private readonly bool _isDescending;

        public PriorityQueue(IComparer<T> comparer, bool isDescending = true)
        {
            _comparer = comparer;
            _isDescending = isDescending;
        }

        public PriorityQueue(Comparison<T> comparison, bool isDescending = true)
            : this(Comparer<T>.Create(comparison), isDescending)
        {
        }

        public PriorityQueue(bool isDescending = true)
            : this(Comparer<T>.Default, isDescending)
        {
        }

        public void Enqueue(T item)
        {
            _data.Add(item);
            var childIndex = _data.Count - 1;
            while (childIndex > 0)
            {
                var parentIndex = (childIndex - 1) / 2;
                if (Compare(_data[childIndex], _data[parentIndex]) >= 0)
                    break;
                Swap(childIndex, parentIndex);
                childIndex = parentIndex;
            }
        }

        public T Dequeue()
        {
            var lastIndex = _data.Count - 1;
            var firstItem = _data[0];
            _data[0] = _data[lastIndex];
            _data.RemoveAt(lastIndex--);
            var parentIndex = 0;
            while (true)
            {
                var childIndex = parentIndex * 2 + 1;
                if (childIndex > lastIndex)
                    break;
                var rightChild = childIndex + 1;
                if (rightChild <= lastIndex && Compare(_data[rightChild], _data[childIndex]) < 0)
                    childIndex = rightChild;
                if (Compare(_data[parentIndex], _data[childIndex]) <= 0)
                    break;
                Swap(parentIndex, childIndex);
                parentIndex = childIndex;
            }
            return firstItem;
        }

        public T Peek()
        {
            return _data[0];
        }

        private void Swap(int a, int b)
        {
            var tmp = _data[a];
            _data[a] = _data[b];
            _data[b] = tmp;
        }

        private int Compare(T a, T b)
        {
            return _isDescending ? _comparer.Compare(b, a) : _comparer.Compare(a, b);
        }

        public int Count => _data.Count;

        public IEnumerator<T> GetEnumerator()
        {
            return _data.GetEnumerator();
        }

        IEnumerator IEnumerable.GetEnumerator() => GetEnumerator();
    }
}



Measured memory_bytes: 27900
#include <bits/stdc++.h>
#define fi first
#define se second
#define N 100005

using namespace std;
typedef long long ll;
typedef pair<int, int> Pair;

template <class T> inline void read(T &x) {
	char ch; bool flag = false;
	while (!isdigit(ch = getchar())) flag |= ch == '-';
	for (x = ch ^ 48; isdigit(ch = getchar()); x = x * 10 + (ch ^ 48));
	if (flag) x = -x;
}

inline int input() {
	int x; char ch; bool flag = false;
	while (!isdigit(ch = getchar())) flag |= ch == '-';
	for (x = ch ^ 48; isdigit(ch = getchar()); x = x * 10 + (ch ^ 48));
	return flag ? -x : x;
}

const int mod = 1e9 + 7;
inline int add(int x, int y) { x += y; return x >= mod ? x - mod : x; }
inline void inc(int &x, int y) { x += y; x -= x >= mod ? mod : 0; }

inline int Power(int x, int y) {
	int res = 1;
	while (y) {
		if (y & 1) res = (ll) res * x % mod;
		x = (ll) x * x % mod, y >>= 1;
	} return res;
}

template <class T> void chkmax(T &x, T y) { x = x > y ? x : y; }
template <class T> void chkmin(T &x, T y) { x = x < y ? x : y; }
template <class T> T gcd(T x, T y) { return !y ? x : gcd(x % y, y); }

int n;
int h[N];

Pair solve(int l, int r, int lim) {
	bool flag = false; int upp = h[l]; Pair res;
	for (int i = l + 1; i <= r; ++i) {
		flag |= h[i] != h[i - 1];
		chkmin(upp, h[i]);
	}
	if (!flag) {
		res.fi = add(Power(2, r - l + 1), mod - 2);
		res.se = Power(2, upp - lim - 1);
		return res;
	}
	
	int cnt = 0, last = 0, s0 = 1, s1 = 1;
	for (int i = l; i <= r + 1; ++i) {
		if (h[i] == upp) ++cnt;
		if (!last && h[i] > upp) last = i;
		else if (last && (h[i] == upp || i > r)) {
			Pair tmp = solve(last, i - 1, upp);
			s0 = (ll) s0 * (tmp.fi + 4ll * tmp.se % mod) % mod;
			s1 = (ll) s1 * tmp.se * 2 % mod;
			last = 0;
		}
	}
	
	inc(s0, mod - s1);
	res.fi = (ll) s0 * Power(2, cnt) % mod;
	inc(res.fi, (ll) s1 * add(Power(2, cnt), mod - 2) % mod);
	res.se = (ll) s1 * Power(2, upp - lim - 1) % mod;
	return res;
}

int main() {
	n = input();
	for (int i = 1; i <= n; ++i) h[i] = input();
	if (n == 1) return printf("%d\n", Power(2, h[1])), 0;
	ll Ex = 1;
	for (int i = 1; i <= n; ++i) {
		if (h[i] <= h[i - 1] || h[i] <= h[i + 1]) continue;
		Ex = Ex * Power(2, h[i] - max(h[i - 1], h[i + 1])) % mod;
		h[i] = max(h[i - 1], h[i + 1]);
	}
	Pair ans = solve(1, n, 0);
	printf("%lld\n", Ex * add(ans.fi, add(ans.se, ans.se)) % mod);
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fir first
#define sec second
#define pb push_back
#define mp make_pair
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 0x3f3f3f3f;
const int N = 1e5 + 5;
const int M = 2e5 + 5;
const int MOD = 998244353;
const double PI = acos(-1.0);
const double EXP = 1e-8;
ll gcd(ll a, ll b)
{
    return b ? gcd(b, a % b) : a;
}
ll lcm(ll a, ll b)
{
    return a * b / gcd(a, b);
}
inline ll qpow(ll a, ll b)
{
    int ans = 1;
    while (b)
    {
        if (b & 1)
            ans = ans * a;
        a = a * a;
        b >>= 1;
    }
    return ans;
}
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n,m;
    cin>>n>>m;
    int ans=n*(n-1)/2+m*(m-1)/2;
    cout<<ans;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cassert>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;

#define rep(i, n) for(ll i = 0; i < n; i++)
#define REP(i, n) for(ll i = 1; i < n + 1; i++)
#define PI 3.14159265359
#define EPS 0.0000000001
#define MOD 1000000007
//cout << std::fixed << std::setprecision(15) << y << endl;


int main(){
    ll S;
    cin >> S;

    ll size = 0;
    ll ans = 1000;
    rep(i, 10){
        ans = min(ans, abs(753 - S % 1000));
        S /= 10;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3616
#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;
const int MAX = 1000000010;
const ll MOD = 1000000007;
const double PI = acos(-1);

int main () {
    ll N; cin >> N;
    vector<char> C;
    while (N > 0) {
        int r = N % 26 - 1;
        if (r == -1) {
            C.push_back('z');
            N /= 26;
            N--;
        } else {
            C.push_back('a' + r);
            N /= 26;
        }
    }

    reverse(C.begin(), C.end());

    for (auto c : C) {
        cout << c;
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 3604
def main():
    N = int(input())
    n4 = [4+4*i for i in range(N//4)]
    n7 = [7+7*i for i in range(N//7)]
    ok = False
    for t in n4:
        if (N - t) % 7 == 0:
            ok = True
            break
    if not ok:
        for t in n7:
            if (N- t) % 4 == 0:
                ok = True
                break
    
    if ok:
        print("Yes")
    else:
        print("No")

if __name__ == "__main__":
    main()

Measured memory_bytes: 3064
#include<iostream>
#include<string>
#include<vector>
#include<math.h>
#include<cmath>
#include<stack>
#include <algorithm>
#include <functional>
//#include<stdlib.h>
using namespace std;


int main() {
	long long int  n;
	cin >> n;
	n=n*(n-1)/2;
	cout << n;
	return 0;
}

Measured memory_bytes: 256