akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
//debug
#define vecprint(v) cout << "  vector: ";rep(i,v.size())cout << v[i] << " ";cout << endl;
#define setprint(s) cout << "  set: ";for(auto i=s.begin();i!=s.end();i++)cout << *i << " ";cout << endl;
#define mappairprint(s) cout << "  map: ";for(auto i=s.begin();i!=s.end();i++)cout << i->first << " " << i->second << endl;cout << endl;
//reader
#define r1(a) cin>>(a)
#define r2(a,b) cin>>(a)>>(b)
#define r3(a,b,c) cin>>(a)>>(b)>>(c)
//writer
#define w1(a) cout<<(a)<<" "
#define w2(a,b) cout<<(a)<<" "<<(b)<<" "
#define w3(a,b,c) cout<<(a)<<" "<<(b)<<" "<<(c)<<" "
#define wl1(a) cout<<(a)<<endl
#define wl2(a,b) cout<<(a)<<" "<<(b)<<endl
#define wl3(a,b,c) cout<<(a)<<" "<<(b)<<" "<<(c)<<endl
//variable definition
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
#define pll pair<ll,ll>
//roop
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rep1(i,n) for (int i = 1; i <= (n); ++i)
#define all(c) c.begin(),c.end()
//term
#define elif else if
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define eb emplace_back
using namespace std;
using ll = long long;
//const
constexpr double PI = 3.141592653589793238462643383279;
vector<int> dx = {1, 0, -1, 0}, dy = {0, 1, 0, -1};



int main() {
  //input
  int a,b,c,d;
  cin >> a >> b >> c >> d;
  
  int flag = 1;
  while(a>0 && c>0) {
    if(flag) {
      //takahashi
      c -= b;
      
      flag = 0;
    } else {
      //aoki
      a -= d;
      
      flag = 1;
    }
  }
  
  if(flag==0) cout <<"Yes" << endl;
  else cout << "No" << endl;
}

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

int main(void){
  int n;
  std::cin >> n;
  int min = 1e9;
  int max = 0;
  for(int i=0; i<n; i++){
    int a;
    std::cin >> a;
    if(a<min) min = a;
    if(a>max) max = a;
  }

  std::cout << (max-min) << std::endl;


  return 0;
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include <algorithm>
#include<cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include<iostream>
#include<list>
#include<queue>
#include<set>
#include<string>
#include <vector>

#define ll long long
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)   FOR(i,0,n)
#define FORL(i,a,b) for(ll i=(a);i<(b);++i)
#define REPL(i,n) FORL(i,0,n)
#define FORR(i,a,b) for(int i=(a);i>=(b);--i)
#define REPR(i,n)   RFOR(i,n,0)

using namespace std;

int main(){
	int a, b;
	scanf("%d %d", &a, &b);

	if (a <= b){
		printf("%d\n", a);
	}
	else{
		printf("%d\n", a - 1);
	}


	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 n;
cin >> n;

int a;

bool flag = true;

rep(i,n) {
cin >> a;
if (a % 2 != 0) continue;
flag &= a % 3 == 0 || a % 5 == 0;
}

if (flag) {
cout << "APPROVED" << endl;
} else {
cout << "DENIED" << endl;
}

return 0;
}

Measured memory_bytes: 256
import sys
stdin = sys.stdin
import numpy as np

ns = lambda: stdin.readline().rstrip()
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))

a, b = na()

#a,bの最大公約数
def gcd(a, b):
    while b:
        a, b = b, a % b
    return a

#a,bの最小公倍数
def lcm(a, b):
    return a * b // gcd (a, b)

print(lcm(a, b))

Measured memory_bytes: 12420
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <string>
#include <vector>
using namespace std;

int main() {
  int n, k;
  cin >> n >> k;
  vector<int> d(k);
  for (int i = 0; i < k; i++) {
    cin >> d[i];
  }

  for (int ans = n; ans < 100000; ans++) {
    int tmp = ans;
    vector<int> v;
    while (tmp != 0) {
      v.push_back(tmp % 10);
      tmp /= 10;
    }

    bool flag = true;
    for (int j = 0; j < k; j++) {
      if (count(v.begin(), v.end(), d[j])) flag = false;
    }

    if (flag) {
      cout << ans << endl;
      break;
    }
  }

  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define mp make_pair
#define pb push_back
#define ip pair<ll,ll>
#define ff first
#define ss second
#define MAX 100005
const ll MOD = 1000000007;

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

	int h,w,k;
	cin>>h>>w>>k;
	string s[h];
	for(int i=0;i<h;i++)
		cin>>s[i];

	ll ans = 0;
	for(int i=0;i<(1<<h);i++){
		vector<int> rows;
		for(int i1=0;i1<h;i1++){
			if(i & (1<<i1))
				rows.pb(i1);
		}

		for(int j=0;j<(1<<w);j++){
			vector<int> cols;
			for(int j1=0;j1<w;j1++){
				if(j & (1<<j1))
					cols.pb(j1);
			}

			string grid[h];
			for(int i=0;i<h;i++)
				grid[i] = s[i];

			for(int idx: rows){
				for(int l1=0;l1<w;l1++)
					grid[idx][l1] = '.';
			}

			for(int idx: cols){
				for(int l1=0;l1<h;l1++)
					grid[l1][idx] = '.';
			}

			int cnt = 0;
			for(int l1=0;l1<h;l1++){
				for(int l2=0;l2<w;l2++){
					if(grid[l1][l2] == '#')
						++cnt;
				}
			}

			if(cnt == k)
				++ans;
		}
	}	

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

Measured memory_bytes: 3644
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>

using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
typedef vector<vector<int>> Graph;

int main() {

	int N, K, Q;
	cin >> N >> K >> Q;

	vector<int>a(N);
	rep(i, Q) {
		int b;
		cin >> b;
		b--;

		a[b]++;
	}

	rep(i, N) {
		a[i] = K + a[i] - Q;
		if (a[i] <= 0)
			cout << "No" << endl;
		else
			cout << "Yes" << endl;
	}

	return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <iomanip>
#include <cmath>
#include <vector>
#include <queue>
#include <limits>
#include <algorithm>
#include <string>
#include <cstring>
#include <map>

using namespace std;
typedef long long ll;
const int MOD = 1000000007;
#define MAX_N (100010)

int main()
{
	char S[MAX_N];
	scanf("%s", S);
	int N = strlen(S);

	ll dp[MAX_N][4];
	memset(dp, 0, sizeof(dp));

	dp[0][0] = 1;
	for(int i = 1; i <= N; i++) {
		for(int j = 0; j < 4; j++)
			dp[i][j] = dp[i - 1][j];

		switch (S[i - 1]) {
		case 'A':
			dp[i][1] += dp[i - 1][0];
			break;
		case 'B':
			dp[i][2] += dp[i - 1][1];
			break;
		case 'C':
			dp[i][3] += dp[i - 1][2];
			break;
		case '?':
			for(int j = 1; j < 4; j++)
				dp[i][j] += dp[i - 1][j - 1];
			for(int j = 0; j < 4; j++)
				dp[i][j] += dp[i - 1][j] * 2LL;
			break;
		}
		for(int j = 0; j < 4; j++)
			dp[i][j] %= MOD;
	}
	printf("%lld\n", dp[N][3]);

	return 0;
}


Measured memory_bytes: 3456
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef vector<vector<int> > Graph;
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 = 1e16;

int main(){
    int n;
    cin >> n;
    vector<int>d(n);
    rep(i,n){
        cin >> d[i];
    }
    sort(d.begin(),d.end());
    n/=2;
    int l=d[n-1];
    int r=d[n];
    cout << r-l <<endl;
    return 0;
}

Measured memory_bytes: 764
#include <cstdio>
typedef long long ll;
int n, a, b, l, r=1e9, m, h[100005];
 
bool f(int p) {
    ll i, c=0;
    for (i=0; i<n; i++)
        c += h[i] > (ll)p*b ? (h[i]-p*b+a-1)/a : 0;
    return c<=p;
}
 
int main() {
    scanf("%d%d%d", &n, &a, &b);
    a -= b;
    for (int i=0; i<n; i++) scanf("%d", &h[i]);
    while (l<r) {
        m = (l+r) / 2;
        if (f(m)) r = m;
        else l = m+1;
    }
    printf("%d", r);
    return 0;
}

Measured memory_bytes: 512
#include<iostream>
#include<algorithm>
using namespace std;
static const int MAX_W = 100;
static const int MAX_H = 100;

int dx[] = {-1, 0, 1, 1, 0, -1};
int dy1[] = {0, 1, 0, -1, -1, -1};
int dy2[] = {1, 1, 1, 0, -1, 0};

int w, h;
int field[MAX_H + 2][MAX_W + 2];
bool visited[MAX_H + 2][MAX_W + 2];

int dfs(int cx, int cy, int cnt){
	visited[cx][cy] = true;
	int nx, ny;
	for(int i = 0; i < 6; i++){
		nx = cx + dx[i];
		if(cx % 2 == 0) ny = cy + dy1[i];
		else ny = cy + dy2[i];
		if(nx < 0 || nx > h + 1 || ny < 0 || ny > w + 1) continue;
		if(visited[nx][ny]) continue;
		if(field[nx][ny] == 1) cnt++;
		else cnt = dfs(nx, ny, cnt);
	}
	return cnt;
}

int main(){
	cin >> w >> h;
	fill(field[0], field[h + 2], 0);
	fill(visited[0], visited[h + 2], false);
	for(int i = 1; i <= h; i++){
		for(int j = 1; j <= w; j++){
			cin >> field[i][j];
		}
	}
	cout << dfs(0, 0, 0) << endl;
	return 0;
}


Measured memory_bytes: 3396
def main():
    N = int(input())
    A = map(int, input().split())

    def count(x):
        ret = 0
        while x % 2 == 0:
            x //= 2
            ret += 1
        return ret

    ans = min(map(count, A))
    print(ans)


if __name__ == '__main__':
    main()


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

int main() {
  int n;cin>>n;
  vector<int> a(n);
  rep(i,n)cin>>a[i];
  int x=-999;
  rep(i,n){
    if(x<=a[i]-1)x=a[i]-1;
    else if(x<=a[i])x=a[i];
    else {
      cout<<"No"<<endl;
      return 0;
    }
  }
  cout<<"Yes"<<endl;
}

Measured memory_bytes: 3756
#define _USE_MATH_DEFINES
#include <iostream>
#include <complex>
#include <algorithm>
#include <vector>
#include <stack>
#include <string>
#include <queue>
#include <cmath>
#include <math.h>
#include <numeric>
#include <list>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <climits>
#include <set>
#include <memory.h>
#include <memory>
#include <cstdio>
#include <cstdlib>
#include <cctype>
#include <cassert>
#include <map>
#include <cassert>
#include <time.h>
#include <ctime>

using namespace std;

typedef complex<double> xy_t;
typedef pair<xy_t, xy_t> line;
typedef vector<xy_t> polygon;
typedef long long ll;
typedef pair<int, int> P;
typedef pair<int , P> PP;
typedef pair<int, string> Ps;
typedef vector<int> vec;
typedef vector<vec> mat;
const int INF = 1 << 29;
const double EPS = 1e-10;
const double PI = 3.1415926535897932384626433832795;
const int CLK = CLOCKS_PER_SEC;

#define rep(i, n) for(int i = 0; i < n; i++)
#define rep2(i, m, n) for(int i = m; i < n; i++)
#define repD(i, n) for(int i = n; i >= 0; i--)

P ps[10000];

int main(){
	int n;
	int id, d1, d2;
	while(cin >> n && n){
		rep(i, n){
			cin >> id >> d1 >> d2;
			ps[i] = P(d1 + d2, id);
		}
		sort(ps, ps + n);
		cout << ps[n-1].second << " " << ps[n-1].first << endl;
	}
	return 0;
}

Measured memory_bytes: 0
import java.util.*;

public class Main {
	static class Segment {
		static final int MAX = (int) Math.pow(2, 19);
		static int n;
		static int size;
		int segment[] = new int[MAX * 2 - 1];

		public static void setSize(int n) {
			Segment.n = n;
			size = 1;
			for (int i = 0; i < n; ++i) {
				if (n <= size)
					break;
				size *= 2;
			}
		}

		public boolean add(int index) {
			int leaf = size - 1 + index;
			if (segment[leaf] > 0)
				return false;
			segment[leaf] = 1;
			while (leaf > 0) {
				leaf = parent(leaf);
				int left = left(leaf);
				int right = right(leaf);
				segment[leaf] = segment[left] + segment[right];
			}
			return true;
		}

		public boolean remove(int index) {
			int leaf = size - 1 + index;
			if (segment[leaf] <= 0)
				return false;
			segment[leaf] = 0;
			while (leaf > 0) {
				leaf = parent(leaf);
				int left = left(leaf);
				int right = right(leaf);
				segment[leaf] = segment[left] + segment[right];
			}
			return true;
		}

		public int parent(int n) {
			return (n - 1) / 2;
		}

		public int left(int n) {
			return 2 * n + 1;
		}

		public int right(int n) {
			return 2 * n + 2;
		}

		public int query(int a, int b, int k, int l, int r) {
			if (r <= a || l >= b)
				return 0;
			if (a <= l && r <= b)
				return segment[k];
			int left = left(k);
			int right = right(k);
			int mid = (r + l) / 2;
			int vl = query(a, b, left, l, mid);
			int vr = query(a, b, right, mid, r);
			return vl + vr;
		}

		public boolean query(int l, int r) {
			int q = query(l - 1, r, 0, 0, size);
			if (q > 0)
				return true;
			return false;
		}
	}

	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		Segment.setSize(n);
		Segment pos[] = new Segment[26];
		for (int i = 0; i < 26; ++i)
			pos[i] = new Segment();
		String s = sc.next();
		char copy[] = s.toCharArray();
		for (int i = 0; i < n; ++i) {
			int t = (int) (copy[i] - 'a');
			pos[t].add(i);
		}
		int q = sc.nextInt();
		for (int i = 0; i < q; ++i) {
			int type = sc.nextInt();
			if (type == 1) {
				int index = sc.nextInt() - 1;
				String c = sc.next();
				char tar = c.charAt(0);
				char cur = copy[index];
				if (cur != tar) {
					int t = (int) (cur - 'a');
					pos[t].remove(index);
					copy[index] = tar;
					t = (int) (tar - 'a');
					pos[t].add(index);
				}
			} else {
				int ans = 0;
				int l = sc.nextInt();
				int r = sc.nextInt();
				for (int j = 0; j < 26; ++j) {
					if (pos[j].query(l, r))
						ans++;
				}
				System.out.println(ans);
			}
		}
		sc.close();
	}
}


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

int main(){
	int a, b, c, d;
	cin >> a >> b >> c >> d;
	
	if (abs(a-c) <= d) {
		cout << "Yes" << endl;
	} else if ((abs(a-b) <= d) && (abs(b-c) <= d)) {
		cout << "Yes" << endl;
	} else {
		cout << "No" << endl;
	}
}

Measured memory_bytes: 256
fn main(){
  let nm: Vec<usize> = read_vec();
  let n = nm[0];
  let m = nm[1];
  let mut q: Vec<(usize, usize)> = Vec::new();
  let mut py: Vec<Vec<usize>> = vec![Vec::new(); n+1];

  for _ in 0..m {
    let tpy: Vec<usize> = read_vec();
    q.push((tpy[0], tpy[1]));
    py[tpy[0]].push(tpy[1]);
  }

  for i in 0..n {
    py[i+1].sort();
  }
  
  for &(p, y) in &q {
    let i: usize = py[p].binary_search(&y).unwrap();
    println!("{:06}{:06}", p, i+1);
  }
}

fn read_vec<T>() -> Vec<T>
  where T: std::str::FromStr,
        T::Err: std::fmt::Debug
{
  let mut buf = String::new();
  std::io::stdin().read_line(&mut buf).expect("failed to read");
  buf.split_whitespace().map(|e| e.parse().unwrap()).collect()
}


Measured memory_bytes: 13820
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <ctime>
using namespace std;

int N; vector<int> A;
void input()
{
    cin >> N;
    A.resize(N);
    for (int i = 0; i < N; ++i) cin >> A[i];
}

void solve()
{
    int pl = 0,mi = 0,zr = 0;
    for (int i = 0; i < N; ++i){
        A[i] -= i+1;
        if (A[i] > 0) ++pl;
        else if (A[i] < 0) ++mi;
        else ++zr;
    }
    
    if (mi > pl){
        for (int i = 0; i < N; ++i) A[i] = -A[i];
        swap (pl, mi);
    }

    sort(A.begin(),A.end());

    long long ans = 0;
    for (int i = 0; i < N; ++i) ans += abs (A[i]);
    auto iter = upper_bound(A.begin(),A.end(),0);
    while (mi + zr < pl){
        int cnt = 0;
        for (int i = 0; iter + i < A.end(); ++i) {
            if (*iter == *(iter + i)) ++cnt;
            else break;
        }
        mi += zr;
        zr = cnt;
        pl -= cnt;
        iter += cnt;

        if (mi + zr >= pl){
            iter -= cnt;
            break;
        }
    }
    long long sum = 0;
    int desc = *iter;
    for (int i = 0; i < N; ++i){
        A[i] -= desc;
        sum += abs (A[i]);        
    }
    cout << min (ans,sum) << endl;
}

int main()
{
    cin.tie();
    ios::sync_with_stdio(false);
    // int ti = clock();
    input();
    solve();
    // printf("Execution Time: %.4lf sec\n", 1.0 * (clock() - ti) / CLOCKS_PER_SEC);
    return 0;
}


Measured memory_bytes: 3984
#include<iostream>
#include<string>
#include<vector>
#include<cstdio>
#include<sstream>
#include<algorithm>
#include<cmath>
#include<map>
#include<functional>
#include<queue>
#include<stack>
#include<set>
using namespace std;
#define SZ(n)  (int)n.size()
#define dump(x) cerr<<#x<<" = "<<(x)<<endl;
#define debug(x)cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define REP(i,n) for(int i=0;i<n;i++)
#define MP make_pair
#define PB push_back
int main(){
	map<string ,vector<int> >ta;
	string s;
	int t;
	while(cin>>s>>t){
	ta[s].push_back(t);
	}
	map<string , vector<int> >::iterator it=ta.begin();
	for(;it!=ta.end();it++){
		cout<<(*it).first<<endl;
		vector<int>tmp=(*it).second;
		sort(tmp.begin(),tmp.end());
		for(int i=0;i<SZ(tmp);i++){
		cout<<tmp[i];
		(i==SZ(tmp)-1)?cout<<endl:cout<<" ";
		}
	}
	return 0;
}

Measured memory_bytes: 1244
#include <bits/stdc++.h>
#define INF LLONG_MAX
#define ll  long long
#define ull unsigned long long
#define rep(i,n) for(int i=0; i<n; ++i)
#define MOD 1000000007
using namespace std;
template<class T> inline bool chmin(T& a, T b) { if(a>b) {a=b; return true;} return false;}
template<class T> inline bool chmax(T& a, T b) { if(a<b) {a=b; return true;} return false;}

char m[2010][2010];
int wmap[2010][2010];
int hmap[2010][2010];



int main() {
  int H, W; cin >> H >> W;
  rep(i,H) { rep(j,W) { cin >> m[i][j]; } }
  int ans = 0;

  rep(i,H) {
    rep(j,W) {
      if(m[i][j] == '.') {
        if(j-1>=0 && wmap[i][j-1] != 0) {
          wmap[i][j] = wmap[i][j-1];
        } else {
          int tmp=1;
          for(int x=1; j+x<W; ++x){
            if(m[i][j+x]=='.') ++tmp;
            else break;
          }
          wmap[i][j] = tmp;
        }
      } else {
        wmap[i][j] = 0;
      }
    }
  }
  rep(i,H) {
    rep(j,W) {
      if(m[i][j] == '.') {
        if(i-1>=0 && hmap[i-1][j] != 0) {
          hmap[i][j] = hmap[i-1][j];
        } else {
          int tmp=1;
          for(int y=1; i+y<H; ++y){
            if(m[i+y][j]=='.') ++tmp;
            else break;
          }
          hmap[i][j] = tmp;
        }
      } else {
        hmap[i][j] = 0;
      }
    }
  }
  rep(i,H) {
    rep(j,W) {
      if(m[i][j] == '.') {
        chmax(ans, hmap[i][j]+wmap[i][j]-1);
      }
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 35712
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define sz(x) (int)(x).size()
#define uni(x) x.erase(unique(rng(x)),x.end())
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define EPS (1e-10)
#define equals(a, b) (fabs((a)-(b)) < EPS)
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
typedef set<int> S;
typedef queue<int> Q;
typedef queue<P> QP;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
const int MOD = 1000000007;
  
int main() {
  int N;
  cin >> N;
  cout << N*(N+1)/2 << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep0(i, n) for (long long i = 0; i < (long long)(n); i++)
#define rep1(i,n) for(long long i=1;i<=(long long)(n);i++)
#define all(v) v.begin(),v.end()
#define Sort(v) sort(all(v))
#define Reverse(v) reverse(all(v))
#define Rsort(v) sort(all(v),greater)
#define pub(v) push_back(v)
#define pob(v) pop_back(v)
typedef long long ll;
typedef vector<ll> vel;
typedef vector<vector<ll>> vel2d;
typedef string str;
typedef pair<ll,ll> pal;
typedef vector<str> ves;


int main() {
    ll N,ans;
    cin>>N;
    ans=N*(N-1)/2;
    cout<<ans<<endl;
}


Measured memory_bytes: 256
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<algorithm>
using namespace std;
int main()
{
	char s;
	int a,b;
	while(cin>>a>>s>>b)
	{
		if(s=='+')
			cout<<a+b;
		else
			cout<<a-b;
		cout<<endl;
	}
return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll a[100010];
int main()
{
    for (int i=1; i<=40000; i++)  a[i] = (ll)i*i;

    ll n;
    while (~scanf("%lld", &n)){
        for (int i=1; i<=40000; i++){
            if (a[i] > n){
                printf("%lld\n", a[i-1]);
                break;
            }
        }
    }
    return 0;
}


Measured memory_bytes: 512
N = int(input())
p = list(map(int,input().split(" ")))
order = list(range(1,N+1))

i = 0
ans = 0

while i < (N-1):
	if p[i] == order[i]:
		p[i] = -1
		if p[i+1] == order[i+1]:
			p[i+1] = -1
			ans += 1
			i += 1
		else:
			ans += 1

	i += 1

if p[N-1] == order[N-1]:
	ans += 1

print(ans)


Measured memory_bytes: 14008
#include<iostream>
#include<string>
using namespace std;
int main()
{
	long x;
	long ans;
	cin >> x;
	ans = x / 500;
	x = x % 500;
	ans *= 1000;
	ans += ((long)(x / 5)) * 5;
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <numeric>
#include <bitset>

using namespace std;

typedef long long ll;

const ll MAX_N = 1010;

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

  ll ans = 0;
  
  for (int bi = 0; bi < (1<<3); ++bi)
  {
  	bitset<3> bs(bi);
  	vector<pair<ll, int> > vec; 
  	for (int i = 0; i < n; ++i)
  	{
  		ll temp = 0;
  		if (bs[0]==0) temp -= x[i];
  		else temp += x[i];
  		if (bs[1]==0) temp -= y[i];
  		else temp += y[i];
  		if (bs[2]==0) temp -= z[i];
  		else temp += z[i];

  		vec.push_back(make_pair(temp, i));
  	}
  	sort(vec.begin(), vec.end());
  	reverse(vec.begin(), vec.end());
  	ll sumx = 0, sumy = 0, sumz = 0;
  	for (int i = 0; i < m; ++i) {
  		sumx += x[vec[i].second];
  		sumy += y[vec[i].second];
  		sumz += z[vec[i].second];
  	}
  	ans = max(ans, abs(sumx)+abs(sumy)+abs(sumz));
  }

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


Measured memory_bytes: 256
nn, k = gets.split.map(&:to_i)

rate = 0
1.upto(nn) do |n|
  coin_cnt = 0
  while n<k do
    coin_cnt+=1
    n*=2
  end
  rate += (1/nn.to_f) * (2**(-coin_cnt)).to_f
  #puts rate
end
puts rate

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

int main(){
  int a,b;
  cin >> a >> b;
  string s;
  cin >> s;
  bool flag = true;
  rep(i,a+b+1){
    if(i == a){
      if(s.at(i) != '-'){
        flag = false;
      }
    }else{
      if('0' <= s.at(i) && s.at(i) <= '9'){
        //do nothing
      }else{
        flag = false;
      }
    }
  }
  if(flag){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }

        
        
}

Measured memory_bytes: 256
import java.util.*;
import java.io.*;
public class Main{
	public static void main(String[] args) {
		Scanner scn=new Scanner(System.in);
		int A = scn.nextInt();
		int B = scn.nextInt();
		
		System.out.println(Math.max(Math.max(A+B, A-B), A*B));
	}
}


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

using namespace std;

#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) (int)(x).size()
#define F first
#define S second
#define forn(i, n) for (int i = 0; i < (int)n; i++)
#define pb push_back
#define fastIO ios::sync_with_stdio(0), cin.tie(0)
#define endl '\n'
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
void debug_out() {
    cerr << endl;
}
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
    cerr << " " << to_string(H), debug_out(T...);
}
const int m=1e9+7;
int main() {
#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
    freopen("in.txt", "r", stdin);
    // freopen("out.txt", "w", stdout);
#else
#define debug(...) 3
    fastIO;
#endif
    int n;
    cin>>n;
    ll dp[n+2];
    memset(dp,0,sizeof dp);
    dp[0]=1;
    for(int sum=3; sum<=n; sum++) {
        for(int i=3; i<=sum; i++) {
                dp[sum]+=dp[sum-i];
                dp[sum]=dp[sum]%m;
        }
    }
    cout<<dp[n]<<endl;
    return 0;
}


Measured memory_bytes: 3672
#include <iostream>
#define PRE_MEIJI 18680908
#define MEIJI 19120730
#define TAISHO 19261225
#define SHOWA 19890108
using namespace std;

int main(){
	int y, m, d, a;
	int sum;
	while (cin >> y >> m >> d) {
		sum = d + m*100 + y*10000;
		if (sum < PRE_MEIJI) {
			cout << "pre-meiji" << endl;
		}else if (sum < MEIJI) {
			a = y - PRE_MEIJI/10000 + 1;
			cout << "meiji " << a << " " << m << " " << d << endl;
		}else if (sum < TAISHO) {
			a = y - MEIJI/10000 + 1;
			cout << "taisho " << a << " " << m << " " << d << endl;
		}else if (sum < SHOWA) {
			a = y - TAISHO/10000 + 1;
			cout << "showa " << a << " " << m << " " << d << endl;
		}else {
			a = y - SHOWA/10000 + 1; 
			cout << "heisei " << a << " " << m << " " << d << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 0
import java.util.Arrays;
import java.util.Scanner;
import java.util.TreeSet;

public class Main implements Runnable {

    private static int MOD = 1_000_000_007;

    public static void main(String[] args) {
        // Run with 32MB stack
        Thread thread = new Thread(null, new Main(), "", 32 * 1024 * 1024);
        thread.start();
    }

    @Override
    public void run() {
        final Scanner scanner = new Scanner(System.in);
        solve(scanner);
    }

    static void solve(Scanner scanner) {
        int N = Integer.parseInt(scanner.next());
        int W = Integer.parseInt(scanner.next());
        int[][] n = new int[N][2];
        for (int i = 0; i < N; i++) {
            n[i][0] = Integer.parseInt(scanner.next());
            n[i][1] = Integer.parseInt(scanner.next());
        }
        long[][] dp = new long[N + 1][W + 1];
        for (int i = 0; i < N; i++) {
            for (int j = 0; j < W; j++) {
                if (j + n[i][0] <= W) {
                    dp[i + 1][j + n[i][0]] = Math.max(dp[i + 1][j + n[i][0]], dp[i][j] + n[i][1]);
                }
                dp[i + 1][j] = Math.max(dp[i + 1][j], dp[i][j]);
            }
        }

        long ans = 0;
        for (int i = 0; i <= W; i++) {
            ans = Math.max(ans, dp[N][i]);
        }
        System.out.println(ans);
    }

}



Measured memory_bytes: 124756
#include<bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define int long long
#define ll long long
#define ls p<<1
#define rs p<<1|1
#define For(i,j,k) for(int i=(int)(j);i<=(int)(k);i++)
#define Rep(i,j,k) for(int i=(int)(j);i>=(int)(k);i--)
inline ll read(){
	ll x=0;char ch=getchar();bool f=0;
	for(;!isdigit(ch);ch=getchar()) if(ch=='-') f=1;
	for(;isdigit(ch);ch=getchar()) x=x*10+ch-'0';
	return f?-x:x;
}
void write(ll x){
	if(x<0) putchar('-'),x=-x;
	if(x>=10) write(x/10);putchar(x%10+'0');
}
void writeln(ll x){write(x);puts("");}
void writep(ll x){write(x);putchar(' ');}
const int N=1e5+5;
int mn[N<<2],f[N];
void build(int p,int l,int r){
	if(l==r) return void(mn[p]=f[l]);
	int mid=(l+r)>>1;
	build(ls,l,mid);
	build(rs,mid+1,r);
	mn[p]=min(mn[ls],mn[rs]);
}
void upt(int p,int l,int r,int pos,int val){
	if(l==r) return void(mn[p]=val);
	int mid=(l+r)>>1;
	if(pos<=mid) upt(ls,l,mid,pos,val);
	else upt(rs,mid+1,r,pos,val);
	mn[p]=min(mn[ls],mn[rs]);
}
int query(int p,int l,int r,int ql,int qr){
	if(ql<=l&&r<=qr) return mn[p];
	int mid=(l+r)>>1,res=1e18;
	if(ql<=mid) res=min(res,query(ls,l,mid,ql,qr));
	if(mid+1<=qr) res=min(res,query(rs,mid+1,r,ql,qr));
	return res;
}
vector< pair<int,int> > vec[N];
signed main(){
	int n=read();
	int m=read(),l,r,c;
	for(int i=1;i<=m;++i){
		l=read();r=read();c=read();
		vec[r].push_back(make_pair(l,c));
	}
	f[1]=0;
	for(int i=2;i<=n;++i)
		f[i]=1e18;
	build(1,1,n);
	for(int i=2;i<=n;++i){
		for(int j=0;j<vec[i].size();++j){
			l=vec[i][j].fi; r=i-1; c=vec[i][j].se;
			if(l<=r) f[i]=min(f[i],query(1,1,n,l,r)+c);
		}
		upt(1,1,n,i,f[i]);
	}
	if(f[n]==1e18) puts("-1");
	else cout<<f[n];
	return 0;
}


Measured memory_bytes: 11792
import collections

n = int(input())
s = input()

count = collections.Counter(s)
ans = 0

if "R" in count.keys():
    if count["R"] != n:
        r_count = collections.Counter(s[:count["R"]])
        if r_count["R"] == 0:
            ans = count["R"]
        else:
            ans = r_count["W"]

print(ans)

Measured memory_bytes: 9664
package main

import "fmt"

func main() {
	var N int
	fmt.Scan(&N)
	h := make([]int, N)
	for i := 0; i < N; i++ {
		fmt.Scan(&h[i])
	}

	ans := 0
	for l := 0; l < N; l++ {
		for h[l] > 0 {
			h[l]--
			for r := l + 1; r < N; r++ {
				if h[r] == 0 {
					break
				}
				h[r]--
			}
			ans++
		}
	}

	fmt.Println(ans)
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#include <map>
#include <set>
#include <vector>
#include <algorithm>
#include <iostream>
#include <bitset>
#include <cassert>
#include <queue>
#include <stack>
#include <iomanip>
#include <math.h>
#include <time.h>
using namespace std;
#define rep(i, n) for (ll i = 0; i < (ll)n; i++)
#define repf(i, a, b) for (ll i = (ll)a; i < (ll)b; i++)
#define repr(i, a, b) for (ll i = (ll)a; i > (ll)b; i--)
#define all(v) (v).begin(), (v).end()
#define mp(a, b) make_pair(a, b)
#define pb(x) push_back(x)
#define eb(x) emplace_back(x)
#define F first
#define S second
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ld, ld> pdd;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<int> vii;
typedef vector<vii> vvii;
const ll mod = 1e9 + 7;
const int infi = 1147483600;
const ll infl = 1e18 + 5;
const char ENDL = '\n';
//cout << fixed << setprecision(17) << res << endl;
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int a;cin>>a;
    string s;
    cin >> s;
    if (a>=3200)
        cout << s << ENDL;
    else
        cout << "red" << ENDL;
}


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

#define MAX 20

int main()
{
    // cout << "Chokudai Contest 004" << endl;

    int N;
    int A[MAX];
    int B[MAX];
    int C[MAX-1];

    // 入力
    scanf("%d", &N);
    for( int count = 0; count < N; count++) {
        scanf("%d", &A[count]);
    }
    for( int count = 0; count < N; count++) {
        scanf("%d", &B[count]);
    }
    for( int count = 0; count < N-1; count++) {
        scanf("%d", &C[count]);
    }

    int i = 0;
    int old_i = -999;
    int sum=0;

    for( int count = 0; count < N; count++) {
        i = A[count];
        sum += B[i-1];
        if( old_i+1 == i ) {
            sum += C[i-2];
        }
        old_i = i;
    }


    cout << sum << endl;


    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <complex>
#include <string>
#include <sstream>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <functional>
#include <iostream>
using namespace std;
typedef pair<int,int> P;
typedef long double ld;
typedef vector<int> vi;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-9
#define INF 2000000000
#define LINF 1000000000000000ll
#define sz(x) ((int)(x).size())
#define fi first
#define sec second
#define SORT(x) sort((x).begin(),(x).end())
#define all(x) (x).begin(),(x).end()
#define EQ(a,b) (abs((a)-(b))<eps)
bool isin(int a,int b,int c,int d,int p,int q)
{
	//printf("%d %d %d %d %d %d\n",a,b,c,d,p,q);
	ld s,t;
	ld A=a,B=b,C=c,D=d,P=p,Q=q;
	if(b==0)
	{
		t=Q/D;
		s=P/A-(C*Q)/(A*D);
		//cout << s << ' ' << t << endl;
		if(s>0&&t>0&&s+t<1)return true;
		else return false;
	}
	if(a==0)
	{
		t=P/C;
		s=Q/B-(D*Q)/(B*C);
		//cout << s << ' ' << t << endl;
		if(s>0&&t>0&&s+t<1)return true;
		else return false;
	}
	t=(P*B-A*Q)/(B*C-A*D);
	s=(P-C*t)/A;
	//cout << s << ' ' << t << endl;
	if(s>0&&t>0&&s+t<1)return true;
	else return false;
}
int main()
{
	int Q;
	scanf("%d",&Q);
	int x1,x2,x3,y1,y2,y3,xk,yk,xs,ys;
	for(int i=0;i<Q;i++)
	{
		scanf("%d %d %d %d %d %d %d %d %d %d",&x1,&y1,&x2,&y2,&x3,&y3,&xk,&yk,&xs,&ys);
		int a,b,c,d,p,q,r,s;
		a=x2-x1;
		b=y2-y1;
		c=x3-x1;
		d=y3-y1;
		p=xk-x1;
		q=yk-y1;
		r=xs-x1;
		s=ys-y1;
		bool orihime = isin(a,b,c,d,p,q);
		bool kengyu = isin(a,b,c,d,r,s);
		if(kengyu!=orihime)cout << "OK" << endl;
		else cout << "NG" << endl;
	}
	return 0;
}

Measured memory_bytes: 1200
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main(){
	int N, M;
	cin >> N >> M;
	int ans = 1900 * M + 100 * (N - M);
	for(int i = 1; i <= M; i++) ans *= 2;
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
const int INF = 1e9;
const int MOD = 1e9+7;
const long long LINF = 1e18;
#define dump(x)  cout << 'x' << ' = ' << (x) << ` `;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)
#define FOREACH(x,a) for(auto& (x) : (a) )
typedef long long ll;
using namespace std;
typedef pair<ll, ll> P;

template<typename T>
void print(const vector<T> &x) {
    int n = x.size();
    rep(i,n) {
        cout << x[i];
        if (i!=n-1) cout<<" ";
        else cout << endl;
    }
}

template<typename T>
void print(const vector<vector<T>> &x) {
    int n = x.size();
    rep(i,n) {
        rep(j,x[i].size()) {
            cout << x[i][j] << " ";
        }
        cout << endl;
    }
}

template<typename T>
void print(const vector<T> &x, int n) {
    rep(i,n) {
        cout << x[i];
        if (i!=n-1) cout<<" ";
        else cout << endl;
    }
}

template<typename T>
void print(const vector<vector<T>> &x, int n, int m) {
    rep(i,n) {
        rep(j,m) {
            cout << x[i][j] << " ";
        }
        cout << 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; }

void input_init() {
    cin.tie(0); ios::sync_with_stdio(false);
}

int main(int argc, char const *argv[]) {
    ll x; cin>>x;
    ll s = x/500;
    ll y = x%500;
    ll g = y/5;
    cout << s*1000+g*5 << '\n';
    return 0;
}

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

using namespace std;

#define endl '\n'

int n,m;
const int nax = 1e5 + 5;
vector <int> adj[nax];
int ans[nax];


bool bfs(int s){
  queue <int> q;
  q.push(s);
  vector <bool> vis(n+1,false);

  while(!q.empty()){
    int u = q.front();
    q.pop();

    for(int i=0;i<adj[u].size();i++){
      int v = adj[u][i];
      if(!vis[v]){
        vis[v] = true;
        q.push(v);
        ans[v] = u;
      }
    }
  }






  for(int i=2;i<=n;i++)
    if(ans[i] == 0)
      return false;

  return true;
}

int main(){

  ios_base :: sync_with_stdio(false);
  cin.tie(NULL);

  cin >> n >> m;

  while(m--){
    int a,b;
    cin >> a >> b;
    adj[a].push_back(b);
    adj[b].push_back(a);
  }

  if(!bfs(1)){
    cout << "No" << endl;
    return 0;
  }
  
  cout << "Yes" << endl;

  for(int i=2;i<=n;i++)
    cout << ans[i] << endl;

  return 0;
}

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

using namespace std;

const int INF = 1e9;
const int N = 1e5;
const int MOD = 1e9 + 7;

const double PI = acos(-1);


int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0), cout.tie(0);
    int n;
    cin >> n;
    int a[n];
    for (int& x : a)
        cin >> x;
    int find = 1;
    int ans = 0;
    for (int i = 0; i < n; i++) {
        if (a[i] != find) {
            ans++;
        } else {
            find++;
        }
    }
    if (find == 1)
        ans = -1;
    cout << ans;
}

Measured memory_bytes: 1024
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.math.BigDecimal;

class Main {


    public static void main(String[] args) {

        // ストリームを作成する
        BufferedReader reader = new BufferedReader(new InputStreamReader(
                System.in));

        int week = readNumber(reader);
        BigDecimal debt = BigDecimal.valueOf(100000);
        for (int i = 0; i < week; i++) {
            // 5%の利子を追加し、1000円未満は切り捨て
            debt = debt.multiply(BigDecimal.valueOf(1.05)).setScale(-3, BigDecimal.ROUND_UP);
        }
        System.out.println(debt.toPlainString());

    }

    /**
     * ストリームから1行読み込んで、数値として返す。
     *
     * @param reader
     *            入力ストリーム
     * @return 数値
     */
    private static int readNumber(BufferedReader reader) {
        int result = 0;
        try {
            String line = reader.readLine();
            result = Integer.parseInt(line);
        } catch (IOException e) {
            throw new RuntimeException();
        }
        return result;
    }
}

Measured memory_bytes: 16984
import sys
input = sys.stdin.readline
H, W, D = map(int, input().split())

A = []
for _ in range(H):
    a = list(map(int, input().split()))
    A.append(a)

Q = int(input())
LR = []
for _ in range(Q):
    l, r = map(int, input().split())
    LR.append((l, r))
# H*Wのマスをマスの数値をkeyにした辞書にする
A_dict = {}
for i, sub_a in enumerate(A):
    for j, a in enumerate(sub_a):
        A_dict[a] = (i+1, j+1)

# costの辞書化
from collections import defaultdict
cost_dict = defaultdict(lambda: {})
N = H*W+1
for i in range(1, N):
    s = i
    g = i+D
    if g >= N:
        break
    cost = abs(A_dict[s][0]-A_dict[g][0])+abs(A_dict[s][1]-A_dict[g][1])
    cost_dict[s][g] = cost
    

dist = defaultdict(lambda: {})
for i in range(1, D+1):
    dist[i][i] = 0
    s = i
    g = i+D
    while g < N:
        dist[i][g] = dist[i][s] + cost_dict[s][g]
        s = g
        g = s + D

    
#print(dist)
for l, r in LR:
    idx = r%D
    if idx == 0:
        idx = D
    print(dist[idx][r]-dist[idx][l])
        




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

using namespace std;

int main(){
    int A, B; scanf("%d %d", &A, &B);
    if(B == 1) puts("0");
    else{
        printf("%d\n", (B - A) / (A - 1) + ((B - A) % (A - 1) > 0) + 1);
    }
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
#include <queue>
#include <utility>
#include <map>
#include <set>
#include <deque>
using namespace std;

string YorN(bool P) { if (P)return "YES"; else return "NO"; }

int main() {

    string C1, C2, C, R;
    cin >> C1>>C2;
    C = R = C1 + C2;
    
    reverse(R.begin(), R.end());

    cout << YorN(C==R) << endl;
    
    return 0;

}

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
int heap_size;
int T[2000000];
void maxHeapify(int i){
	int r, l;
	int largest;
	int tmp;
	l=2*i;
	r=2*i+1;
	if( l<= heap_size && T[l]>T[i] ) largest=l;
	else largest=i;
	if( r<=heap_size && T[r]>T[largest] ) largest=r;
	if( largest!=i ){
		tmp=T[i];
		T[i]=T[largest];
		T[largest]=tmp;
		maxHeapify(largest);
	}
}
void buildMaxHeap(void){
	int i;
	for( i=heap_size/2; i>0; i-- ){
		maxHeapify(i);
	}
}
void heapIncreaseKey(int i, int key){
	int tmp;
	if( key<T[i] ) return;
	T[i]=key;
	while( i>1 && T[i/2]<T[i]){
		tmp=T[i];
		T[i]=T[i/2];
		T[i/2]=tmp;
		i=i/2;
	}
}
void maxHeapInsert(int key){
	heap_size=heap_size+1;
	T[heap_size]=-2000000001;
	heapIncreaseKey(heap_size, key);
}
int heapExtractMax(void){
	int max;
	if( heap_size<1 ) return 0;
	max=T[1];
	T[1]=T[heap_size];
	heap_size=heap_size-1;
	maxHeapify(1);
	return max;
}
int main(void){
  char com[20];
  int key;
  while(1){
	  scanf("%s", com);
	  if( strncmp(com,"insert", 6)==0){
		  scanf("%d", &key);
		  maxHeapInsert(key);
	  }
	  else if( strncmp(com,"extract",6)==0){
		printf("%d\n", heapExtractMax());
	  }
	  else if( strncmp(com,"end",3)==0 )break;
  }
  return 0;
}

Measured memory_bytes: 4700
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <queue>
#include <unordered_map>
#include <set>
#include <algorithm>
#include <utility>
#include <cmath>
using namespace std;

typedef long long llong;
typedef unsigned long long ullong;
// -2.1e-9 <= int <= 2.1e9
// -9.2e-18 <= long long <= 9.2e18
// 0 <= unsigned int <= 4.2e9
// 0 <= unsigned long long <= 18.4e18
// cout << fixed << setprecision(10);

int main() {
    int a;
    cin >> a;
    int ans = a + (a * a) + (a * a * a);
    cout << ans << endl;
}


Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(false);cin.tie(0);
#define pii pair<ll,ll>
#define F first
#define S second
#define pb push_back
#define mp make_pair
#define rep(i,a,b) for(ll i=a;i<=(ll)b;++i)
#define per(i,a,b) for(ll i=a;i>=(ll)b;--i)
#define ll long long
#define lowbit(x) ((x)&(-x))

bool ok(string s)
{
    int len=s.size();
    for(int i=0,j=len-1;i<j;++i,--j)
    {
        if(s[i]!=s[j]) return false;
    }
    return true;
}
int main()
{
    IOS
    string s; cin>>s;
    int n=s.size();
    int cnt=0;
    if(ok(s)) ++cnt;
    if(ok(s.substr(0,(n-1)/2))) ++cnt;
    int tem=(n+3)/2;
    if(ok(s.substr(tem-1,n-tem+1))) ++cnt;
    if(cnt==3) cout<<"Yes"<<"\n";
    else cout<<"No"<<"\n";
}


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

#define ln '\n'
#define REP(i, n) for (int i = 0; i < (int)(n); ++i)
#define FOR(i, a, b) for (int i = (a); i <= (int)(b); ++i)
#define FORR(i, a, b) for (int i = (a); i >= (int)(b); --i)
#define ALL(c) (c).begin(), (c).end()

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef pair<int, int> P;
typedef pair<ll, ll> PL;
typedef vector<P> VP;
typedef vector<PL> VPL;
typedef vector<string> VS;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int k, x;
    cin >> k >> x;
    FOR(i, x - k + 1, x + k - 1) {
        if (i == x + k - 1)
            cout << i << ln;
        else
            cout << i << " ";
    }
    return 0;
}


Measured memory_bytes: 3564
// Template from https://techracho.bpsinc.jp/jhonda/2019_08_05/78537

// input macro for competive-programming from https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

#[allow(unused_macros)]
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)*}
    };

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

#[allow(unused_macros)]
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<_>>()
    };

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

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

    ($iter:expr, bytes) => {
        read_value!($iter, String).into_bytes()
    };

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

fn main() {
    use std::io::Read;
    let mut s = String::new();
    std::io::stdin().read_to_string(&mut s).unwrap();

    println!("{}", solve(&s));
}

macro_rules! test {
    ($($input:expr => $output:expr),* $(,)*) => {
        #[test]
        fn solve_test() {
            $(
                assert_eq!(solve($input), $output);
            )*
        }
    };
}

test! {
r#"abaababaab"# => r#"6"#,
r#"aab"# => r#"2"#,
r#"aa"# => r#"2"#,
}

fn solve(src: &str) -> String {
    input! {
        source = src,
        s: chars,
    }
    let mut ans = s.len();

    for i in 1..s.len() {
        let t = &s[0..s.len()-i];
        let tl = t.len();
        if tl % 2 == 0 && t[0..(tl / 2)] == t[(tl / 2)..tl] {
            ans = tl;
            break;
        }
    }
    // println!("{:?}", ans);
    ans.to_string()
}

Measured memory_bytes: 4352
import java.util.PriorityQueue;
import java.util.Scanner;

public class Main {
	
	static class Dic implements Comparable<Dic>{
		String moji;
		int page;
		Dic(String moji, int page){
			this.moji=moji;
			this.page=page;
		}
		public int compareTo(Dic d) {
			if(this.moji.equals(d.moji)) {
				return this.page-d.page;
			}
			else {
				return this.moji.compareTo(d.moji);
			}
		}
	}
	
	public static void main(String[] args) {
		try(Scanner sc = new Scanner(System.in)){
			PriorityQueue<Dic> pq=new PriorityQueue<>();
			while(sc.hasNextLine()) {
				String str=sc.nextLine();
				String[] token=str.split(" ");
				String s=token[0];
				int n=Integer.parseInt(token[1]);
				pq.add(new Dic(s, n));
			}
			String pre="";
			while(!pq.isEmpty()) {
				Dic dic=pq.poll();
				if(dic.moji.equals(pre)) {
					System.out.print(" "+dic.page);
				}
				else if(pre.equals("")) {
					System.out.println(dic.moji);
					System.out.print(dic.page);
				}
				else {
					System.out.println();
					System.out.println(dic.moji);
					System.out.print(dic.page);
				}
				pre=dic.moji;
			}
			System.out.println();
		}
	}
}


Measured memory_bytes: 26580
#include<iostream>
#include<vector>
#include<sstream>
#include<string>
#include<numeric>
#include <algorithm>
#include<math.h>
#include<cstdio>
#include<string.h>
#include<unistd.h>
#include <array>
#include <map> 
#define ALL(a)  (a).begin(),(a).end()



using namespace std;
typedef long long ll;
struct point{
  int x;
  int y;

};
int gcd(int a, int b)
{
	return a == 0 ? b : gcd(b % a, a);
}
int lcm( int m, int n )
{
	// 引数に０がある場合は０を返す
	if ( ( 0 == m ) || ( 0 == n ) )
		return 0;
	
	return ((m / gcd(m, n)) * n); // lcm = m * n / gcd(m,n)
}//lcm
int input(){
  int x;
  cin>>x;
  return x;
}

int moji(char in)
{
    int ans = (int)in-(int)'a';
    if((ans < 0) || (ans > 25)){
        ans = 26;
    }
    return ans;
}
const int VV=10;//場合に応じてVVの値のみ変更する必要あり
//dijkstra(s)sがスタート地点でそこからの最短距離を配列dで表す。正の重みのみ使用可能
int cost[VV][VV];
int d[VV];
bool used[VV];
void dijkstra(int s){
  fill(d,d+VV,100000);
  fill(used,used+VV,false);
  d[s]=0;
  while(true){
    int v=-1;
    for(int u=0;u<VV;u++){
      if(!used[u]&&(v==-1||d[u]<d[v]))v=u;
    }
    if(v==-1)break;
    used[v]=true;
    for(int u=0;u<VV;u++){
      d[u]=min(d[u],d[v]+cost[v][u]);
    }
  }

}

int compare_int(const void *a, const void *b)//qsort(quick sort利用時に使用)
{
    return *(int*)a - *(int*)b;
}

int binary_searchh(long long x,long long k[],int n){
  int l=0;
  int r=n;
  while(r-l>=1){
    int i=(l+r)/2;
    if(k[i]==x)return i;
    else if(k[i]<x)l=i+1;
    else r=i;
  }
  return -1;
}

struct File {
    int aa;
    int bb;

    File(const int& aa, const int& bb)
        : aa(aa), bb(bb) {}
};

bool operator<(const File& a, const File& b)
{
    // ファイル種別、ファイル名の順番で優先順位を付けて比較
    return std::tie(a.aa, a.bb) < std::tie(b.aa, b.bb);
}

long long kaijo(long long x){
  long long l=10*10*10*10*10*10*10*10*10+7;
  long long sum=1;
  for(int i=x;i>0;i--){
    sum*=i;
    if(sum>l){
      sum%=l;
    }
  }
  return sum;
}






int main(){
  long long N;
  cin>>N;
  long long A[N];
  long long B[N];
  for(int i=0;i<N;i++){
    cin>>A[i]>>B[i];
  }
  long long sum=0;
  for(int i=N-1;i>=0;i--){
    A[i]+=sum;
    int tmp=A[i]%B[i];
    if(tmp!=0){
    sum+=B[i]-tmp;}

  }
  cout<<sum<<endl;


}





  
  



Measured memory_bytes: 1792
n = int(input())
s = [0] * (n+1)
d = [int(i) for i in input().split()]
cnt = 0

for i in range(n):
	s[i+1] = s[i] + d[i]
s.sort()

t = 1
for i in range(n):
	if s[i+1] == s[i]:
		t += 1
		if i+1 == n:
			cnt += t * (t-1) // 2
			break
	else:
		cnt += t * (t-1) // 2
		t = 1

print(cnt)


Measured memory_bytes: 27512
#include<iostream>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
#include<set>
#include<map>
using namespace std;

static const int INF=1e9;
typedef long long ll;
typedef pair<int,int> P;
const ll MOD=1000000007;

ll mod_pow(ll x, ll n){ //べき乗
    ll ans=1;
    while(n!=0){
        if(n&1) ans=ans*x%MOD;
        x=x*x%MOD;
        n=n>>1;
    }
    return ans;
}

int main(){
    int n,m;
    cin >> n >> m;
    vector<int> ok(n+1,true);
    for(int i=0;i<m;i++){
        int a;
        cin >> a;
        ok[a]=false;
    }
    vector<ll> dp(n+1);
    dp[0]=1;
    for(int i=0;i<n;i++){
        if(ok[i+1]==true&&i+1<=n){
            dp[i+1]+=dp[i];
            dp[i+1]%=MOD;
        }
        if(ok[i+2]==true&&i+2<=n){
            dp[i+2]+=dp[i];
            dp[i+2]%=MOD;
        }
    }
    cout << dp[n] << endl;
}


Measured memory_bytes: 1408