akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
typedef long long ll;
using namespace std;
int main()
{
  string O, E;
  cin >> O >> E;
  rep(i, O.size())
  {
    cout << O.at(i);
    if (i < E.size())
    {
      cout << E.at(i);
    }
  }
  cout << endl;
  return 0;
}

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

int main(void){
    long long n, d, ans = 0;
    cin >> n >> d;
    vector<long long> x(n), y(n);
    for(int i = 0; i < n; i++){
        cin >> x[i];
        cin >> y[i];
    }
    for(int i = 0; i < n; i++){
        if(x[i]*x[i] + y[i]*y[i] <= d*d){
            ans++;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 6424
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<ll,ll> l_l;
const int INF=1001001000;
const int mINF=-1001001000;
const ll LINF=1010010010010010000;
int main(){
    int n;cin >> n;
    vector<ll> a(n);
    for(int i=0;i<n;i++) cin >> a[i];
    queue<ll> q;
    ll sum=0;
    ll ans=0;
    ll cnt=0;
    ll checker=0;
    for(int i=0;i<n;i++){
        sum+=a[i];
        q.push(a[i]);
        cnt++;
        checker=checker^a[i];
        while(checker!=sum){
            sum-=q.front();
            checker=checker^q.front();
            q.pop();
            cnt--;
            //cout << "i" << i << "q.sz" << q.size() << endl;
        }
        ans+=cnt;
    }
    cout << ans << endl;
    return 0;
}

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

/*
ll modpow(ll n, ll x, ll p){
    if(x == 1) return n % p;
    if(x % 2 == 1) return (modpow(n, x-1, p) * n) % p;
    ll t = modpow(n, x/2, p);
    return (t * t) % p;
}
*/

int main() {
    ll n, k;
    cin >> n >> k;
    ll res = 0;
    ll p = 1e9 + 7;
  
    for(ll i = k; i <= n+1; ++i){
        res += i * (n - i + 1) + 1;
        // cout << i * (n - i + 1) + 1 << endl;
        res %= p;
    }
  
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
#include <boost/range/irange.hpp>

using namespace std;
using namespace boost;

main() {
    string s;
    cin >> s;

    reverse(s.begin(), s.end());
    int32_t len_w = 0;
    int64_t ans = 0;
    for (auto c : s) {
        if (c == 'B') {
            if (len_w > 0) {
                ans += len_w;
            }
        } else {
            ++len_w;
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
const int MAXN = 2e5 + 5;
typedef long long ll;
template <typename T> void chkmax(T &x, T y) {x = max(x, y); }
template <typename T> void chkmin(T &x, T y) {x = min(x, y); } 
template <typename T> void read(T &x) {
	x = 0; int f = 1;
	char c = getchar();
	for (; !isdigit(c); c = getchar()) if (c == '-') f = -f;
	for (; isdigit(c); c = getchar()) x = x * 10 + c - '0';
	x *= f;
}
int n; double a[MAXN], b[MAXN], f[MAXN], g[MAXN];
void init(int n) {
	static double s[MAXN], t[MAXN];
	double Max = 0; int pos = 1;
	for (int i = 1; i <= n; i++) {
		read(s[i]);
		if (s[i] > Max) {
			Max = s[i];
			pos = i;
		}
	}
	for (int i = 1; i <= n; i++)
		read(t[i]);
	int tot = 0;
	for (int i = pos; i <= n; i++, tot++)
		a[tot] = s[i], b[tot] = t[i];
	for (int i = 1; i <= pos; i++, tot++)
		a[tot] = s[i], b[tot] = t[i];
	for (int i = 1; i <= n; i++) {
		f[i] = f[i - 1] + b[i] * 2;
		g[i] = g[i - 1] + b[i] * i * 2;
	}
}
int top, s[MAXN], p[MAXN];
double query(int l, int r, int pos) {
	double delta = a[r] - a[l];
	double sum = f[r - 1] - f[l];
	double fun = g[r - 1] - g[l];
	double x = (delta - (sum * r - fun)) / (r - l);
	sum = f[pos - 1] - f[l], fun = g[pos - 1] - g[l];
	return a[l] + x * (pos - l) + (sum * pos - fun);
}
int main() {
	read(n), init(n), s[top = 1] = 0;
	for (int i = 1; i <= n; i++) {
		while (top >= 1 && query(s[top - 1], i, s[top]) > a[s[top]]) top--;
		s[++top] = i;
	}
	double ans = 0;
	for (int i = 1; i <= top; i++)
	for (int j = s[i - 1] + 1; j <= s[i]; j++)
		ans += query(s[i - 1], s[i], j);
	printf("%.10lf\n", ans / n);
	return 0;
}


Measured memory_bytes: 13776
#include<iostream>
#include<stdio.h>
#include<algorithm>
#include<vector>
#include<string.h>
#include<math.h>
#include<map>
#include<iomanip>

#define MOD 1e9+7;
#define INF 1e17+9;
#define PI acos(-1);

using namespace std;

int main() {
	
	vector<double> p(1001,0);
	for(int i=1;i<=1000;i++){
		p[i]+=((double)(i)+1)/2;
	}
	
	int n,k;
	cin >> n >> k;
	vector<double> a(n);
	
	for(int i=0;i<n;i++){
		cin >> a[i];
	}
	
	double tot=0,ans=0;
	for(int i=0;i<k;i++){
		tot+=p[a[i]];
	}
	ans=tot;
	
	for(int i=k;i<n;i++){
		tot+=p[a[i]];
		tot-=p[a[i-k]];
		ans=max(ans,tot);
	}
	
	cout << fixed << setprecision(12) << ans << endl;
	return 0;
}



Measured memory_bytes: 1920
#include<iostream>
#include<algorithm>
#include<string>
using namespace std;
int main(){
	int K;
	int a[32]={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
	cin>>K;
	cout<<a[K-1];
	return 0;
}

Measured memory_bytes: 256
from operator import itemgetter
N=int(input())
R=[list(map(int,input().split())) for n in range(N)]
B=[list(map(int,input().split())) for n in range(N)]
R.sort(key=itemgetter(1),reverse=True)
B.sort()
ans=0

for c,d in B :
    for a,b in R :
        if a<c and b<d :
            ans+=1
            R.remove([a,b])
            break

print(ans)

Measured memory_bytes: 9092
#include <stdio.h>
#define DIVISION 10000000
struct rmn_long{
	int n1;
	int n2;
	int n3;
	int n4;
};

struct rmn_long rmn_long_mul(struct rmn_long x, int y){
	x.n4 *= y;
	x.n3 *= y;
	x.n2 *= y;
	x.n1 *= y;
	x.n3 += (x.n4 / DIVISION);
	x.n2 += (x.n3 / DIVISION);
	x.n1 += (x.n2 / DIVISION);
	x.n4 %= DIVISION;
	x.n3 %= DIVISION;
	x.n2 %= DIVISION;
	return x;
}
struct rmn_long fact(int n){
	struct rmn_long res;
	if(n < 1){
		res.n1 = 0;
		res.n2 = 0;
		res.n3 = 0;
		res.n4 = 1;
		return res;
	}else{
		return rmn_long_mul(fact(n-1),n);
	}
	
}
int getDigitNum(int n){
	int counter = 0;
	while(n > 0){
		n /= 10;
		counter++;
	}
	return counter;
}
void rmn_long_print(struct rmn_long x){
	int i;
	int full = getDigitNum(DIVISION)-1;
	if(x.n1){
		printf("%d",x.n1);
		for(i = getDigitNum(x.n2)+1; i <= full; i++){
			putchar('0');
		}
	}
	if(x.n2){
		printf("%d",x.n2);
		for(i = getDigitNum(x.n3)+1; i <= full; i++){
			putchar('0');
		}
	}
	if(x.n3){
		printf("%d",x.n3);
		for(i = getDigitNum(x.n4)+1; i <= full; i++){
			putchar('0');
		}
	}
	printf("%d\n",x.n4);
	
}
int main(void){
	int n;
	struct rmn_long ans;
	scanf("%d",&n);
	ans = fact(n);
	rmn_long_print(ans);
	return 0;
}

Measured memory_bytes: 0
while True:
	m,a,b=map(int,input().split())
	if m==a==b==0:
		exit()
	ans=10**8
	ran=-1
	q=[]
	for i in range(m):
		x=int(input())
		q.append(x)
	for i in range(m-1):
		if -q[i+1]+q[i]>=ran and a<=i+1<=b:
			ans=i+1
			ran=-q[i+1]+q[i]
	print(ans)



Measured memory_bytes: 5616
#define _USE_MATH_DEFINES
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<stdio.h>
#include<cmath>
#include<stack>
#include<set>
#include<map>
#include<stdio.h>
#include<functional>
#include<queue>

using ll = long long;

using namespace std;

ll mod = 1000000007;
//ll mod = 998244353;

ll n_pow(ll a, ll n) {
	if (n == 0)return 1;
	ll t = n_pow(a, n / 2);
	t *= t;
	//t %= mod;
	if (n % 2 == 1)t *= a;
	return t /*% mod*/;
}

const int INF = 1001001001;
//const ll INF = 1e18;

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

ll cal_gcd(ll a, ll b) {
	ll m = max(a, b);
	ll n = min(a, b);
	while (m%n != 0) {
		ll b = m % n;
		m = n;
		n = b;
	}
	return n;
}

vector<pair<ll, ll>> prime_factorize(ll N) {
	vector<pair<ll, ll>> res;
	for (long long a = 2; a * a <= N; ++a) {
		if (N % a != 0) continue;
		long long ex = 0;
		while (N % a == 0) {
			++ex;
			N /= a;
		}
		res.push_back({ a, ex });
	}
	if (N != 1) res.push_back({ N, 1 });
	return res;
}


int main() {
	string s, t;
	cin >> s >> t;
	int ans = 0;
	for (int i = 0; i < s.size(); i++) {
		if (s[i] != t[i])ans++;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 3920
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <queue>
#include <algorithm>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <memory.h>
#include <ctime>
#include <bitset>

using namespace std;

#define ABS(a) ((a>0)?a:-(a))
#define MIN(a,b) ((a<b)?(a):(b))
#define MAX(a,b) ((a<b)?(b):(a))
#define FOR(i,a,n) for (int i=(a);i<(n);++i)
#define MEMS(a,b) memset((a),(b),sizeof(a))
#define FI(i,n) for (int i=0; i<(n); ++i)
#define pnt pair <int, int>
#define mp make_pair
#define LL long long
#define U unsigned

int ans[510*510];
int a[510];
pnt b[510];

int main()
{
#ifdef Fcdkbear
        freopen("in.txt", "r", stdin);
        //freopen("out.txt", "w", stdout);
        double beg = clock();
#endif

        int n;
        cin >> n;
        FOR(i,0,n) {
        	cin >> a[i];
        	a[i]--;
        	ans[a[i]] = i + 1;
        	b[i] = mp(a[i],i);
        }
        sort(b, b + n);
        int p = 0;
        FOR(i,0,n) {
        	int cnt = b[i].second;
        	while ((p < b[i].first) && (cnt > 0)) {
        		if (ans[p] == 0) {
        			ans[p] = b[i].second + 1;
        			cnt--;
        		}
        		p++;
        	}
        	if (cnt > 0) {
        		cout << "No" << endl;
        		return 0;
        	}
        }
        p = n * n - 1;
        for (int i = n - 1; i >= 0; --i) {
        	int cnt = n - b[i].second - 1;
			while ((p > b[i].first) && (cnt > 0)) {
				if (ans[p] == 0) {
					ans[p] = b[i].second + 1;
					cnt--;
				}
				p--;
			}
			if (cnt > 0) {
				cout << "No" << endl;
				return 0;
			}
        }
        cout << "Yes" << endl;
        FOR(i,0,n * n) {
        	if (i)
        		printf(" ");
        	printf("%d",ans[i]);
        }
        cout << endl;

#ifdef Fcdkbear
        double end = clock();
        fprintf(stderr, "*** Total time = %.3lf ***\n", (end - beg) / CLOCKS_PER_SEC);
#endif
        return 0;
}


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

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

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

    sort(s, s + n);
    int flag = 0;

    if(ans % 10 != 0){
        cout << ans << endl;
    }else{
        for(int i = 0; i < n; i++){
            if(s[i] % 10 != 0){
                ans -= s[i];
                flag = 1;
                break;
            }
        }

        if(flag == 0){
            cout << 0 << endl;
        }else{
            cout << ans << endl;
        }
    }
}

Measured memory_bytes: 256
import java.io.*;
import java.util.*;
import java.lang.*;

class Main{
  public static void main(String[] args) throws IOException{
    Scanner scan=new Scanner(System.in);

    while(true){

      int n=Integer.parseInt(scan.next());
      if(n==0)break;
      int cardA=0;
      int cardB=0;
      int pointA=0;
      int pointB=0;
      for(int i=0;i<n;i++){
        cardA=Integer.parseInt(scan.next());
        cardB=Integer.parseInt(scan.next());
        if(cardA>cardB){
          pointA+=cardA+cardB;
        }else if(cardA<cardB){
          pointB+=cardA+cardB;
        }else{
          pointA+=cardA;
          pointB+=cardB;
        }
      }
      System.out.println(pointA+" "+pointB);
    }
  }
}


Measured memory_bytes: 45764
#include <cstdio>
#include <iostream>
#include <string>
#include <sstream>
#include <stack>
#include <algorithm>
#include <cmath>
#include <queue>
#include <map>
#include <set>
#include <cstdlib>
#include <bitset>
#include <tuple>
#include <assert.h>
#include <deque>
#include <bitset>
#include <iomanip>
#include <limits>
#include <chrono>
#include <random>
#include <array>
#include <unordered_map>
#include <functional>
#include <complex>

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 long long MAX = 5100000;
const long long INF = 1LL << 60;
const long long mod = 1000000007LL;
//const long long mod = 998244353LL;

using namespace std;
typedef unsigned long long ull;
typedef long long ll;

ll n;
vector<ll> a;
ll dp[350][350];

ll dfs(ll left, ll right) {
	if (dp[left][right] != -1) return dp[left][right];
	if (left == right) return 0;
	if (left + 1 == right) return 0;
	ll res = 0;
	for (ll i = left + 1; i < right; i++) {
		chmax(res, dfs(left, i) + dfs(i, right));
	}
	if (llabs(a[right - 1] - a[left]) <= 1 && dfs(left + 1, right - 1) == (right - left - 2)) {
		chmax(res, dfs(left + 1, right - 1) + 2);
	}
	return dp[left][right] = res;
}
int main()
{
	/*
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	*/

	while (1) {
		ll n; scanf("%lld", &n);
		if (n == 0) break;
		a.resize(n); for (ll i = 0; i < n; i++) scanf("%lld", &a[i]);
		for (ll i = 0; i <= n; i++) for (ll j = 0; j <= n; j++) dp[i][j] = -1;
		printf("%lld\n", dfs(0, n));
	}
	return 0;
}



Measured memory_bytes: 4072
using System;
using System.Collections;

public class p2204
{
	p2204 ()
	{
		string str;
		string[] st;
		int n;
		int[] a;
		
		while ((str=Console.ReadLine())!= null && str != "0") {
			n = int.Parse (str);
			a = new int[n];
			for (int i = 0; i < n; ++i) {
				st = (Console.ReadLine ()).Split (' ');
				foreach (string s in st)
					a [i] += int.Parse (s);
			}
			Array.Sort (a);
			
			Console.WriteLine ("{0} {1}", a[n-1], a[0]);
		}
	}
	
	public static int Main(string[] args){
		new p2204();
		return 0;
	}
}

Measured memory_bytes: 5920
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;
#define chmax(x,y) x = max(x,y);
const int di[] = {-1, 0, 1, 0};
const int dj[] = {0, -1, 0, 1};
const int INF = 1001001001;

int dp[105][4][2];

int main() {
    string s;
    cin >> s;
    int n = s.size();
    int K;
    cin >> K;
    dp[0][0][0] = 1;
    rep(i,n)rep(j,4)rep(k,2) {
        int nd = s[i] - '0';
        rep(d,10) {
            int ni = i+1, nj = j, nk = k;
            if (d != 0) nj++;
            if (nj > K) continue;
            if (k == 0) {
                if (d > nd) continue;
                if (d < nd) nk = 1;
            }
            dp[ni][nj][nk] += dp[i][j][k];
        }
    }
    int ans = dp[n][K][0] + dp[n][K][1];
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3596
import sys
N=int(input())
w=[]
flag="Yes"

for i in range(N):
  w.append(input())

if len(set(w))<len(w):
  flag="No"

if flag=="Yes":
  for i in range(N-1):
    if w[i][-1]!=w[i+1][0]:
      flag="No"
      break

print(flag)
  

Measured memory_bytes: 3060
#include <stdio.h>
main()
{
	int a[3], i, j, w;
	scanf("%d %d %d", &a[0], &a[1], &a[2]);
	for (i = 0; i < 3 - 1; i++) {
		for (j = i + 1; j < 3; j++) {
			if (a[i] > a[j]) {
				w = a[i];
				a[i] = a[j];
				a[j] = w;
			}
		}
	}
	printf("%d %d %d\n", a[0], a[1], a[2]);
}


Measured memory_bytes: 2672
#include <bits/stdc++.h>
using namespace std;
#define modulo 1000000007
#define mod(mod_x) (((long long)mod_x)%modulo)
long long ans = 0;
vector<bool> V(0);

void get_ans(){
	int now = 0;
	for(int i=0;i<V.size();i++){
		if(V[i]){
			ans+=i-now;
			now++;
		}
	}
	V.clear();
}

int main(){
	
	string S;
	cin>>S;
	
	for(int i=0;i<S.size();i++){
		if(S[i]=='A'){
			V.push_back(false);
			continue;
		}
		if(i!=S.size()-1){
			if(S[i]=='B'&&S[i+1]=='C'){
				V.push_back(true);
				i++;
				continue;
			}
		}
		get_ans();
	}
	get_ans();
	
	cout<<ans<<endl;
	
	return 0;
}

Measured memory_bytes: 640
from itertools import permutations
from math import sqrt, factorial

N = int(input())
P = [list(map(int, input().split())) for _ in range(N)]
ans = 0
for p in permutations(range(N),N):
    for i in range(N-1):
        x1, y1 = P[p[i]]
        x2, y2 = P[p[i+1]] 
        ans += sqrt((x1-x2)**2+(y1-y2)**2)
ans /= factorial(N)
print(ans)

Measured memory_bytes: 40684
a,b=map(int, input().split()) 
count=0
for i in range(2,a+1):
  for j in range(2,b+1):
    daylist = list(str(j))
    day1 = int(daylist[0])
    if len(daylist) != 1 :
      day2 = int(daylist[1])
      #print(day1 * day2)
      if i == day1 * day2:
        if day1 !=1:
          if day2 !=1:
            #print(str(i)+str(" ")+str(day1)+str(" ")+str(day2))
            count += 1
print(count)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n ; i++)
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define whole(f, x, ...) ([&](decltype((x)) whole) { return (f)(begin(whole), end(whole), ## __VA_ARGS__); })(x) // decltypeで型取得、引数があればva_argsのところに入れる
using namespace std;
typedef long long ll; // long longをllでかけるようにした
const int INF = 1e9;
const double PI = 3.1415926535;
const int MOD = 1000000007; // 計算してからmodで割る ans = (ans * a) % mod
#define int long long
template <typename T = long long > T in () { T x; cin >> x; return(x);}
// int a = in() のように使うlong long以外の型の時はstirng s = in<string>()のように型を指定する

signed main(void){
    int a, b, c; cin >> a >> b >> c;
    int x, y; cin >> x >> y;
    int ans = INF;
    if(a + b <= c * 2){
        ans = a * x + b * y;
    }else{
        int many;
        if(x < y) many = b;
        else many = a;

        ans = c * max(x, y) * 2;
        ans = min(ans, c * min(x, y) * 2 + abs(x - y) * many);
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
var GET=(function(){function f(s){return new g(s);}function g(s){this._s=s.trim().split("\n");this._y=0;}g.prototype.a=function(f){var s=this._s, y=this._y, r;if(typeof s[y]==="string")s[y]=s[y].split(" ").reverse();r=s[y].pop();if(!s[y].length)this._y++;return f?r:+r;};g.prototype.l=function(f){var s=this._s[this._y++].split(" ");return f?s:s.map(a=>+a);};g.prototype.m=function(n,f){var r=this._s.slice(this._y,this._y+=n).map(a=>a.split(" "));return f?r:r.map(a=>a.map(a=>+a));};g.prototype.r=function(n,f){var r=this._s.slice(this._y,this._y+=n);return f?r:r.map(a=>+a);};return f;})();
var o=GET(require("fs").readFileSync("/dev/stdin","utf8"));

console.log(main());
function main(){
  var n = o.a();
  var m = o.a();
  var a = o.m(n);
  a.sort((a,b)=>a[0]-b[0]);
  var ans = 0;
  var c = 0;
  for(var i = 0; i < n; i++){
    if(m-c <= a[i][1]){
      ans += (m-c) * a[i][0];
      break;
    }
    ans += a[i][0] * a[i][1];
    c += a[i][1];
  }
  return ans;
}

Measured memory_bytes: 65780
#include<bits/stdc++.h>
#define fo(i,a,b) for((i)=(a);i<=(b);i++)
#define rfo(i,a,b) for((i)=(a);i>=(b);i--)
#define inrange(x,y,z) (((x)>=(y))&&((x)<=(z)))
#define ALL(vec) ((vec).begin(),(vec).end())
#define SOR(vec) sort(ALL(vec))
#define UNI(vec) (vec).erase(unique(ALL(vec)),(vec).end())
using namespace std;
int n,k,a[200100],mn[200100],mx[200100];
deque<int> q;
int main(){
	#ifdef FILIN
		#ifndef LOCAL
			freopen(FILIN,"r",stdin);
			freopen(FILOUT,"w",stdout);
		#endif
	#endif
	ios::sync_with_stdio(0);
	cin.tie(NULL);
	cout.tie(NULL);
	cin>>n>>k;
	for(int i=1;i<=n;i++){
		cin>>a[i];
	}
	while(q.size())
		q.pop_back();
	for(int i=n;i>=1;i--){
		//i~i+k minimum
		while(q.size()&&q.front()>=i+k)
			q.pop_front();
		while(q.size()&&a[q.back()]>a[i])
			q.pop_back();
		q.push_back(i);
		if(q.size()==1){
			mn[i]=1;
		}
	}
	while(q.size())
		q.pop_back();
	for(int i=1;i<=n;i++){
		//i-k~i maximum
		while(q.size()&&q.front()<=i-k)
			q.pop_front();
		while(q.size()&&a[q.back()]<a[i])
			q.pop_back();
		q.push_back(i);
		if(q.size()==1){
			mx[i]=1;
		}
	}
	int num=0;
	for(int i=1,j=1;i<=n;i=j){
		j++;
		while(j<=n&&a[j]>a[j-1])
			j++;
		if(j>=i+k)
			num++;
	}
	int tot=n-k+1-max(num-1,0);
	for(int i=k;i<=n;i++){
		tot-=(mx[i]&&mn[i-k]);
	}
	cout<<tot<<endl;
	return 0;
}


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

int main() {
    int n;
    cin >> n;
    vector<long long> a(n+1,0);

    for(int i=0;i<n;i++){
        int input;
        cin >> input;
        a.at(i+1) = a.at(i)+input;
    }

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

    long long ans=0;
    long long sirial=1;

    for(int i=0;i<n;i++){
        if(a.at(i)==a.at(i+1))sirial++;
        else {
            ans += sirial*(sirial-1)/2;
            sirial=1;
        }
    }

    ans += sirial*(sirial-1)/2;

    cout << ans << endl;
}

Measured memory_bytes: 1792
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        String plane = "",str="";
        int row = 0;
        Scanner scan = new Scanner(System.in);
        
        while(scan.hasNext()){
            str = scan.next();
            plane += str;
            if(row++ > 6){
                row = 0;
                if(plane.matches(".*1111.*"))System.out.println("C");
                else if(plane.matches(".*110000011.*"))System.out.println("G");
                else if(plane.matches(".*1100000011.*"))System.out.println("A");
                else if(plane.matches(".*11000000011.*"))System.out.println("E");
                else if(plane.matches(".*1000000110000001.*"))System.out.println("D");
                else if(plane.matches(".*100000001100000001.*"))System.out.println("F");
                else if(plane.matches(".*1000000010000000100000001.*"))System.out.println("B");
                plane = "";
            }
        }
    }
}



Measured memory_bytes: 30560
import java.util.Scanner;

public class Main {

  public static void main(String[] args) {

    Scanner sc = new Scanner(System.in);

    int H = Integer.parseInt(sc.next());
    int W = Integer.parseInt(sc.next());

    boolean S[][] = new boolean[H][W];
    for (int i = 0; i < H; i++) {
      String str = sc.next();
      for (int j = 0; j < W; j++) {
        if (str.charAt(j) == '#') {
          S[i][j] = true;
        } else {
          S[i][j] = false;
        }
      }
    }

    int di[] = { -1, 0, 1, 0 };
    int dj[] = { 0, -1, 0, 1 };
    boolean flag = true;

    for (int i = 0; i < H; i++) {
      for (int j = 0; j < W; j++) {
        if (!S[i][j]) {
          continue;
        }
        flag = false;
        for (int k = 0; k < 4; k++) {
          int ni = i + di[k];
          int nj = j + dj[k];
          if (ni < 0 || ni >= H || nj < 0 || nj >= W) {
            continue;
          }
          if (S[ni][nj]) {
            flag = true;
          }
        }
        if (!flag) {
          System.out.println("No");
          return;
        }
      }
    }

    System.out.println("Yes");
  }
}

Measured memory_bytes: 21844
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;

int main(void) {

	int a, b, c;

	cin >> a >> b >> c;

	if (a <= c) {
		if (a + b > c)
			cout << "YES" << endl;
		else
			cout << "NO" << endl;
	}
	else
		cout << "NO" << endl;
	
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main{

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = Integer.parseInt(sc.next());
		int K = Integer.parseInt(sc.next());

		double s=0;
		int p=0;
		double k=1;
		for(int i=1;i<=N;i++) {

			k=1;
			for(p=i;p<K;) {

				p *= 2;
				k/=2;

			}
			s+=k;
		}


		s*=(double)1/N;
		System.out.println(s);

	}
}

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

int main()
{
  int R, G;
  int res=0;
  cin >> R >> G;

  res = 2*G-R;

  cout << res << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<map>
#include<queue>
#include<functional>
#include<cmath>
#include<algorithm>
typedef  long long ll;

int main() {
	ll lcm(ll m, ll n);
	ll gcd(ll m, ll n);
	ll ans = 1;
	int n = 0;
	std::cin >> n;
	ll num = 0;
	for (int i = 0; i < n; i++) {
		std::cin >> num;
		ans = lcm(ans, num);
	}
	std::cout << ans << std::endl;
	return 0;
}ll gcd(ll m, ll n)
{
	if (n < m) {
		std::swap(n, m);
	}
	if (m == 0) {
		return n;
	}
	return gcd(m, n % m);
}
ll lcm(ll m, ll n)
{
	if ((0 == m) || (0 == n))
		return 0;

	return ((m / gcd(m, n)) * n);
}

Measured memory_bytes: 256
n = int(input())
bn = [int(num) for num in input().split()]
 
an = [0]*n
an[0] = bn[0]
an[n-1] = bn[n-2]
for i in range(1,n-1):
    s = min(bn[i],bn[i-1])
    an.append(s)
    
print(sum(an))

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

typedef long long ll;

int main(){
     ll a,b,c;

   cin >> a >> b >> c;

   ll d = c - a - b;

    if(d > 0 && d*d > 4*a*b){
    cout << "Yes" << endl;
    } else {
    cout << "No" << endl;
    }

}

/*
ここで ε = 10−14 の値を大きくしすぎたり小さくしすぎたりすると WA になってしまいます。
なぜ ε = 10−14 であるとうまくいくのかは説明できるのですが、より簡単で安全な方法は、全て整数でやってしまうことです。
 √√√
a+ b< c (1)
⇔ (√a+√b)2<c (2) √
⇔ 2 ab<c−a−b (3) ⇔ c−a−b > 0∧4ab < (c−a−b)2
*/ 

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

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

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

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

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

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

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

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

fn main() {
    input! {
        n:i64,
        k:i64,
    }

    let mut x = n;

    if k < x {
        x = x % k;
    }

    let res = std::cmp::min(x, k - x);
    println!("{}", res);
}


Measured memory_bytes: 4352
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const ll INF=1LL<<60;
const int inf=1<<30;
const int mod=1e9+7;
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int h,w;cin >> h >> w;
    int c[10][10];
    for(int i=0;i<10;i++){
        for(int j=0;j<10;j++){
            cin >> c[i][j];
        }
    }
    for(int i=0;i<10;i++){
        for(int j=0;j<10;j++){
            for(int k=0;k<10;k++){
                chmin(c[j][k],c[j][i]+c[i][k]);
            }
        }
    }
    int ans=0;
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            int a;cin >> a;
            if(a==-1){
                continue;
            }
            ans+=c[a][1];
        }
    }
    cout << ans << endl;
}

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

int main() {
  int N;
  int a[150];
  cin >> N;
  for(int i=0;i<N;i++){
    cin >> a[i];
  }
  sort(a,a+N);
  reverse(a,a+N);
  int Alice=0;
  int Bob=0;
  for(int i=0;i<N;i++){
    if(i%2==0){
      Alice+=a[i];
    }
    else{
      Bob+=a[i];
    }
  }
  cout << Alice - Bob;
}

Measured memory_bytes: 256
package main

import (
	"fmt"
	"strconv"
)

func main() {
	var n string
	fmt.Scan(&n)

	var b [3]rune

	for i, v := range n {
		if v == '1' {
			b[i] = '9'
		} else {
			b[i] = '1'
		}
	}

	ans, _ := strconv.Atoi(string(b[:]))
	fmt.Println(ans)

}


Measured memory_bytes: 1776
use std::io::prelude::*;

fn input<T>() -> T
where
    T: std::str::FromStr,
{
    let stdin = std::io::stdin();
    let token: String = stdin
        .lock()
        .bytes()
        .map(|c| c.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().unwrap()
}

fn main() {
    let a: i64 = input();
    let b: i64 = input();
    println!(
        "{}",
        if a % 2 == 1 && b % 2 == 1 {
            "Odd"
        } else {
            "Even"
        }
    );
}


Measured memory_bytes: 4352
import heapq

n, k = map(int, input().split())
sushi = [list(map(int, input().split())) for _ in range(n)]
sushi.sort(key=lambda x: x[1])
t = {}
x = []
z = 0
for i in range(n - 1, n - k - 1, -1):
    ti, di = sushi[i]
    if ti in t.keys():
        x.append(di)
        t[ti] += 1
    else:
        t[ti] = 1
    z += di

p = len(t.keys())
ans = z + p ** 2
j = 1
for i in range(n - k - 1, -1, -1):
    if j == len(x) + 1:
        break
    ti, di = sushi[i]
    if ti not in t.keys():
        t[ti] = 1
        z += di - x[-j]
        p += 1
        j += 1
        ans = max(ans, z + p ** 2)

print(ans)


Measured memory_bytes: 32212
#!/usr/bin/env python3
import sys


def solve(N: int):
    multi_list = []
    for i in range(1, 10):
        for j in range(1, 10):
            multi_list.append(i * j)
    if N in multi_list:
        print("Yes")
    else:
        print("No")
    return


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word

    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    solve(N)


if __name__ == "__main__":
    main()


Measured memory_bytes: 3060
#pragma GCC optimize ("O3")
#pragma GCC target ("avx")
//#include<bits/stdc++.h>
#include<cstdio>
#include<algorithm>
#include<vector>
#include<functional>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define Would
#define you
#define please

const int cm = 1 << 17;
char cn[cm], * ci = cn + cm, ct;
inline char getcha() {
	if (ci - cn == cm) { fread_unlocked(cn, 1, cm, stdin); ci = cn; }
	return *ci++;
}
inline int getint() {
	int A = 0;
	if (ci - cn + 16 > cm) while ((ct = getcha()) >= '0') A = A * 10 + ct - '0';
	else while ((ct = *ci++) >= '0') A = A * 10 + ct - '0';
	return A;
}
pair<int, int> E[100001];
int H[100001];
int n[100001];
int sagasu(int A) {
	if (!n[A]) return 0;
	vector<int> V(n[A]);
	int k = 0;
	for (int i = H[A]; i; i = E[i].second) {
		V[k++] = sagasu(E[i].first);
	}
	sort(V.begin(), V.end(), greater<int>());
	int ret = 0;
	rep(i, n[A]) ret = max(ret, i + V[i]);
	return ret + 1;
}

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


	int N = getint();

	for (int i = 2; i <= N; i++) {
		int a = getint();
		n[a]++;
		E[i] = mp(i, H[a]);
		H[a] = i;
	}

	printf("%d\n", sagasu(1));

	Would you please return 0;
}

Measured memory_bytes: 12800
#include<bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
int main(){
  map<P,int> mp;
  int ans=0,n,x,y,w;
  cin>>n;
  for(int i=0;i<n;i++){
    cin>>x>>y>>w;
    for(int j=0;j<2;j++)
      for(int k=0;k<2;k++)
	ans=max(ans,mp[P(x+j,y+k)]+=w);
  }
  cout<<ans<<" / 1"<<endl;
  return 0;
}

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

using ll = long long;
using P = pair<int, int>;

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

// 4近傍、8近傍
int dx[] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[] = {0, 1, 0, -1, 1, 1, -1, -1};

int main() {
  // 入力
  ll N, A, B;
  cin >> N >> A >> B;

  ll ans;
  if (A > B) {
    ans = 0;
  } else {
    if (N == 1) {
      ans = (A == B ? 1 : 0);
    } else {
      ans = (N - 2) * B - (N - 2) * A + 1;
    }
  }

  // 解答
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cmath>

using namespace std;

int main() {
	int n = 0;
	cin >> n;
	if (n == 1) {
		cout << "Hello World";
	}
	else {
		int a, b;
		cin >> a >> b;
		cout << a + b;
	}

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define lli long long int
#define uli unsigned long long int
#define INF 999999999999999999
#define rep(i,m,n) for(lli i = m;i < n;i++)
#define rrep(i,m,n) for(lli i=m-1;i>=n;i--)
#define pb(n) push_back(n)
#define UE(N) N.erase(unique(N.begin(),N.end()),N.end());
#define Sort(n) sort(n.begin(), n.end())
#define Rev(n) reverse(n.begin(),n.end())
#define Out(S) cout << S << endl
#define NeOut(S) cout << S
#define HpOut(S) cout << setprecision(25) << S << endl
#define Vec(K,L,N,S) vector<L> K(N,S)
#define DV(K,L,N,M,S) vector<vector<L>> K(N,vector<L>(M,S))
#define TV(K,L,N,M,R,S) vector<vector<vector<L>>> K(N,vector<vector<L>>(M,vector<L>(R,S)))
#define pint pair<lli,lli>
#define paf(L,R) pair<L,R>
#define mod 1000000007
#define MAX 510000
#define ALL(a)  a.begin(),a.end()
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
int main(){
  lli A,B,C,D,E,F,N,M,K,L,X,Y,Z,H,W,sum=0,num=0,flag=0;string S,T;
  cin >> X >> Y;
  if(X==3)sum+=100000;
  if(X==2)sum+=200000;
  if(X==1)sum+=300000;
  if(Y==3)sum+=100000;
  if(Y==2)sum+=200000;
  if(Y==1)sum+=300000;
  if(X==Y&&Y==1)sum+=400000;
  Out(sum);
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);++i)
using ll = long long;
using P = pair<int, int>;
#include<algorithm>
#include<math.h>
#include<map>
#include<queue>
#include<set>
#include<iomanip>

int main() {
	int w, h,x,y;
	cin >> w >> h>>x>>y;
	double men = double(w) * double(h) / 2.0;
	cout <<fixed<< setprecision(12)<<men<<" ";
	int w2 = w / 2;
	int h2 = h / 2;
	if (2*x == w && h == 2*y) {
		cout << 1;
	}
	else {
		cout << 0;
	}
	return 0;

}

Measured memory_bytes: 3768
#include<stdio.h>
#include<string.h>

int m[18][18],x,y,s,a,b,i,j;

int main(){
	memset(m,0,sizeof(m));
	while(scanf("%d,%d,%d",&x,&y,&s)!=EOF){
		if(s==1){
			m[x+2][y+2]++;
			m[x+2+1][y+2]++;
			m[x+2][y+2+1]++;
			m[x+2-1][y+2]++;
			m[x+2][y+2-1]++;
		}
		if(s==2){
			m[x+2][y+2]++;
			m[x+2+1][y+2]++;
			m[x+2][y+2+1]++;
			m[x+2-1][y+2]++;
			m[x+2][y+2-1]++;
			m[x+2+1][y+2+1]++;
			m[x+2-1][y+2+1]++;
			m[x+2-1][y+2-1]++;
			m[x+2+1][y+2-1]++;
		}
		if(s==3){
			m[x+2][y+2]++;
			m[x+2+1][y+2]++;
			m[x+2][y+2+1]++;
			m[x+2-1][y+2]++;
			m[x+2][y+2-1]++;
			m[x+2+1][y+2+1]++;
			m[x+2-1][y+2+1]++;
			m[x+2-1][y+2-1]++;
			m[x+2+1][y+2-1]++;
			m[x+2+2][y+2]++;
			m[x+2][y+2+2]++;
			m[x+2-2][y+2]++;
			m[x+2][y+2-2]++;
		}
	}
	a=b=0;
	for(i=2;i<12;i++){
		for(j=2;j<12;j++){
			if(m[i][j]==0)a++;
			if(m[i][j]>b)b=m[i][j];
		}
	}
	printf("%d\n%d\n",a,b);
	
	return 0;
}

Measured memory_bytes: 0
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <cmath>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <iostream>
#include <random>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <cassert>
#include <fstream>
#include <unordered_map>
#include <cstdlib>
#include <complex>
#include <cctype>
#include <bitset>
using namespace std;

using ll = long long;
using vll = vector<ll>;
using pll = pair<ll, ll>;
using qll = queue<ll>;
using vb = vector<bool>;
using mll = map<ll, ll>;
using sll = stack<ll>;
#define REP(i,n) for(ll i(0);(i)<(n);(i)++)
#define rep(i,n) for(ll i(0);(i)<(n);(i)++)
#define ALL(a) a.begin(), a.end()
#define enld endl //* missspell check
const ll INF = 1LL << 60;


void solve(long long N, std::vector<long long> P, std::vector<long long> Q){
    ll a=0, b=0;
    vll c(N);
    REP(i, N) c[i] = i+1;
    do{
        a++;
        bool isGood = true;
        REP(i, N){
            if(c[i] != P[i]){
                isGood = false;
                break;}
        }
        if(isGood)
            break;

    }while(next_permutation(ALL(c)));
    REP(i, N) c[i] = i+1;
    do{
        b++;
        bool isGood = true;
        REP(i, N){
            if(c[i] != Q[i]){
                isGood = false;
                break;}
        }
        if(isGood)
            break;
    }while(next_permutation(ALL(c)));

    cout<< abs(a-b)<<endl;
}

int main(){
    long long N;
    scanf("%lld",&N);
    std::vector<long long> P(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&P[i]);
    }
    std::vector<long long> Q(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&Q[i]);
    }
    solve(N, std::move(P), std::move(Q));
    return 0;
}


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

// Implementaci??n did??ctica
class SegmentTreeRMQ {
    // st es el arreglo de nodos del segment tree
    vector<long long> arr, st;
    // leaf guarda la ubicaci??n de cada hoja en st
    vector<int> leaf; int n;

    // construir nodo u, que representa al rango [i,j]
    void build(int u, int i, int j) {
        // caso de que el rango representa una hoja
        if (i == j) {
            leaf[i] = u;
            st[u] = arr[i];
            return;
        }
        // l y r son los hijos izquierdo y derecho de u
        int m = (i+j)/2, l = u*2+1, r = u*2+2;
        build(l, i, m);
        build(r, m+1, j); // es importante el +1
        st[u] = min(st[l], st[r]); // range min. query
    }

    // query en el rango [a,b], considerando que nos
    // encontramos en el nodo u que representa a [i,j]
    long long query(int a, int b, int u, int i, int j) {
        // nodo fuera del rango [a,b], retornar neutro
        if (j < a or b < i)
            return 1e18; //infinito = neutro del m??n.
        // nodo totalmente contenido en [a,b]
        if (a <= i and j <= b)
            return st[u]; // responder directamente
        // si no, componer queries de ambos hijos
        int m = (i+j)/2, l = u*2+1, r = u*2+2;
        long long x = query(a, b, l, i, m);
        long long y = query(a, b, r, m+1, j); // +1 !!
        return min(x, y);
    }

    // actualizar nodo u considerando que uno de sus
    // hijos fue actualizado antes (o es una hoja)
    void update(int u) {
        int l = u*2+1, r = u*2+2;
        st[u] = min(st[l], st[r]); // actualizar info
        // si no es la ra??z (nodo 0) actualizar padre
        if (u != 0) update((u-1)/2);
    }

public:
    // construir segment tree a partir de un vector
    SegmentTreeRMQ(vector<long long>& v) {
        arr = v;
        n = v.size();
        leaf.resize(n);
        // reservar tama?±o para el peor caso, 4*N
        st.resize(n*4+5);
        // construir desde la ra??z
        build(0, 0, n-1);
    }

    // [a,b] es inclusivo inclusivo, indexado desde 0
    long long query(int a, int b) {
        // responder query procesando desde la ra??z
        return query(a, b, 0, 0, n-1);
    }

    // setea un valor en cierto ??ndice del arreglo
    void update(int index, long long value) {
        int u = leaf[index];
        arr[index] = value;
        st[u] = arr[index];
        // chequea si la hoja es ra??z por si N = 1
        if (u != 0) update((u-1)/2);
    }
};

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

    int n, Q;
    cin>>n>>Q;
    vector<long long> arr(n, INT_MAX);
    SegmentTreeRMQ st(arr);
    rep(q,Q) {
        long long cmd, x, y;
        cin>>cmd>>x>>y;
        if (cmd == 0) {
            st.update(x, y);
        } else {
            cout<<st.query(x, y)<<'\n';
        }
    }

    return 0;
}

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

int main()
{
  int R;

  cin >> R;

  if (1200 > R) {
    cout << "ABC" << endl;
  } else if (2800 > R) {
    cout << "ARC" << endl;
  } else {
    cout << "AGC" << endl;
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
    int N;
    string c;
    cin >> N;
    vector<int> k(10);
    while (N != 0) {
        cin >> c;
        int t = 0;
        int a = 0;
        fill(k.begin(), k.end(), 0);
        for (int i = 0; i < 100; i++) {
            t = i % N;
            if (c[i] == 'M') {
                k[t]++;
            } else if (c[i] == 'S') {
                a += k[t] + 1;
                k[t] = 0;
            } else {
                k[t] += a + 1;
                a = 0;
            }
        }
        sort(k.begin(), k.begin() + N);
        for (int i = 0; i < N; i++) {
            cout << k[i] << " ";
        }
        cout << a << "\n";    
        cin >> N;
    }
    return 0;
}


Measured memory_bytes: 3216
s = input()
def ans():
    for i in range(len(s)):
        if i%2==0:
            if s[i]!= 'R' and s[i]!= 'U' and s[i]!= 'D':
                print('No')
                return
        else:
            if s[i]!= 'L' and s[i]!= 'U' and s[i]!= 'D':
                print('No')
                return
    print('Yes')
ans()

Measured memory_bytes: 3060
import java.util.Scanner;

public class Main {
	static Scanner sc = new Scanner(System.in);
	static int N = sc.nextInt();
	static String[] numlist = {"3", "5", "7"};
	public static void main(String[] args) {
		long ans = dfs(0);
		System.out.println(ans);
	}

	static long dfs(long s) {
		if (s > N) return 0;
		int ret;
		if (is753(s)) ret = 1; else ret = 0;
		for (String num : numlist) {
			String next = Long.toString(s) + num;
			ret += dfs(Long.parseLong(next));
		}
		return ret;
	}

	static boolean is753(long s) {
		String sStr = Long.toString(s);
		for (String num : numlist) {
			if (!sStr.contains(num)) return false;
		}
		return true;
	}
}


Measured memory_bytes: 41684
#include <stdio.h>
#include <math.h>

int main(void) {

  long n;
  scanf("%ld", &n);
  long a[n+1];
  for (long i = 0; i <= n; i++) {
    scanf("%ld", &a[i]);
  }
  if (n == 0) {
    if (a[0] == 1) {
      printf("1\n");
    } else {
      printf("-1\n");
    }
    return 0;
  }
  long max[n+1],rev[n+1];
  max[0] = 1;
  for (long i = 1; i <= n; i++) {
    max[i] = (max[i-1]-a[i-1])*2;
    if (max[i] > pow(10,18)) {
      max[i] = pow(10,18);
    }
    if (max[i] <= 0) {
      printf("-1\n");
      return 0;
    }
  }
  rev[n] = a[n];
  if (rev[n] > max[n]) {
    printf("-1\n");
    return 0;
  }
  for (long i = n-1; i >= 0; i--) {
    rev[i] = rev[i+1]+a[i];
  }
  long ans = 0;
  for (long i = 0; i <= n; i++) {
    if (max[i] < rev[i]) {
      ans += max[i];
    } else {
      ans += rev[i];
    }
  }
  printf("%ld\n", ans);

  return 0;
}

Measured memory_bytes: 4060
#include<bits/stdc++.h>
using namespace std ;
const double pi = acos(-1) ;
int main () {
  while(1){
    int a , b ;
    char op ;
    cin >> a >> op >> b ;
    if(op=='?') break ;
    if(op=='+') cout << a + b << endl ;
    if(op=='*') cout << a * b << endl ;
    if(op=='-') cout << a - b << endl ;
    if(op=='/') cout << a / b << endl ;
  }
}


Measured memory_bytes: 3104
// ref: https://drken1215.hatenablog.com/entry/2019/05/13/112000
// ref: https://img.atcoder.jp/abc114/editorial.pdf

//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
typedef int64_t int64;
typedef uint32_t uint;
typedef uint64_t uint64;

//---

template <typename T>
inline void print(const T& rhs){ std::cout<<" = "<<rhs<<std::endl; }
template <typename T>
inline void print(const std::vector<T>& rhs){
    std::cout<<" = [ ";
    for(uint i=0; i<rhs.size(); ++i){ std::cout<<rhs[i]<<' '; }
    std::cout<<"]"<<std::endl;
}
template <typename T>
inline void print(const std::vector<std::vector<T>>& rhs){
    std::cout<<" = "<<std::endl;
    std::cout<<"[[ ";
    for(uint p=0; p<rhs.size(); ++p){
        if(p!=0){ std::cout<<" [ "; }
        for(uint q=0; q<rhs[p].size(); ++q){
            std::cout<<rhs[p][q]<<' ';
        }
        if(p!=rhs.size()-1){ std::cout<<"]"<<std::endl; }
    }
    std::cout<<"]]"<<std::endl;
}
template <typename TL, typename TR>
inline void print(const std::vector<std::pair<TR,TL>>& rhs){
    std::cout<<" = [";
    uint i=0;
    for(; i<rhs.size()-1; ++i){ std::cout<<"[f: "<<rhs[i].first<<", s: "<<rhs[i].second<<"], "; }
    std::cout<<"[f: "<<rhs[i].first<<", s: "<<rhs[i].second<<"]]" << endl;
}
#define printn(var) {printf("%s", #var);print(var);}
#define printn_all(var) {printf("%s(%d): ", __func__, __LINE__);printf("%s", #var);print(var);}

//---

vector<pair<int64, uint>> factor(int64 n){
    vector<pair<int64, uint>> vPN;
    for(int64 p=2; p*p<=n; ++p){
        if(n % p != 0){ continue; }
        
        int num=1; n/=p;
        while(n % p == 0){ ++num; n/=p; }
        vPN.push_back( make_pair(p, num) );
    }
    if(n != 1ll){ vPN.push_back( make_pair(n, 1) ); }
    return vPN;
}

int solver(const unordered_map<int64, uint>& ht, unordered_map<int64, uint>::iterator itr, int64 num){
    if(itr==ht.end()){
        return ( num==1 ? 1:0 );
    }
    
    int64 sum=0;
    for(uint i=1; i <=(itr->second +1); ++i){
        if(num % i !=0){ continue; }
        auto itr_buf = itr;
        sum += solver(ht, ++itr_buf, num/i);
    }
    return sum;
}

int main(){
//    ios_base::sync_with_stdio(false);
//    cin.tie(NULL);
    
    unordered_map<int64, uint> ht;
    
    uint N; cin >> N;
    for(uint i=2; i<=N; ++i){
        vector<pair<int64, uint>> vPN = factor(i);
        for(uint i=0; i<vPN.size(); ++i){
            ht[ vPN[i].first ] += vPN[i].second;
        }
    }
    cout << solver(ht, ht.begin(), 75) << endl;
    
    
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<map>
#include<algorithm>
#include<cmath>
#include<string>
#include<cstdlib>
#include<iomanip>

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)   FOR(i,0,n)
#define MOD 1000000007

using namespace std;

typedef long long int ll;

const ll INF=(ll)1e18;

int main(){

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

  double ans = 0;

  FOR(i,1,N+1){
    int t = i;
    double s = 1.0/N;
    while(t < K){
      s *= 0.5;
      t = t << 1;
    }
    ans += s;
  }

  cout << setprecision(12) << ans << endl;
}

Measured memory_bytes: 256
while True:
    a,op,b=map(str,input().split())
    a=int(a)
    b=int(b)
    if op=='?':
        break
    elif op=='+':
        ans=a+b
    elif op=='-':
        ans=a-b
    elif op=='*':
        ans=a*b
    else:
        ans=a/b
    print(int(ans))


Measured memory_bytes: 5596
import java.math.BigDecimal;
import java.util.*;

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

        BigDecimal a = new BigDecimal(scanner.nextLong());
        String tmp = scanner.next().replace(".","");
        BigDecimal b = new BigDecimal(Long.valueOf(tmp));

        System.out.println(a.multiply(b).divide(new BigDecimal(100)).longValue());

    }
}

Measured memory_bytes: 36040