akhauriyash/Code-Regression huggingface dataset:
#pragma comment(linker, "/stack:20000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,sse3,sse4,popcnt,abm,mmx")
 
#include <bits/stdc++.h>
 
#define f first
#define s second
 
#define pb push_back
#define pp pop_back
#define mp make_pair
 
#define sz(x) (int)x.size()
#define sqr(x) ((x) * 1ll * (x))
#define all(x) x.begin(), x.end()
 
#define rep(i, l, r) for (int i = l; i <= r; i++)
#define per(i, l, r) for (int i = l; i >= r; i--)
 
#define dbg(x) cerr << (#x) << " --> " << (x) << nl;
#define Kazakhstan ios_base :: sync_with_stdio(0), cin.tie(0), cout.tie(0);
 
#define nl '\n'
#define ioi exit(0);
 
using namespace std;
 
#ifdef superset
  #include <ext/pb_ds/assoc_container.hpp>
  #include <ext/pb_ds/tree_policy.hpp>
  #include <ext/pb_ds/detail/standard_policies.hpp>
 
  using namespace __gnu_pbds;
  typedef tree < pair <int, int>, null_type, less < pair <int, int> >, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
#endif
 
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
 
const int N = 5e5 + 7, inf = 1e9 + 7, mod = 1e9 + 7;
const ll linf = (ll)1e18 + 7;
const int dx[] = {-1, 0, 1, 0, 1, -1, -1, 1}, dy[] = {0, 1, 0, -1, 1, -1, 1, -1};
 
int get_int() {
  char x = getchar();
  bool mns = 0;
  while (!isdigit(x)) mns |= x == '-', x = getchar();
  int res = 0;
  while (isdigit(x)) res = res * 10 + x - '0', x = getchar();
  if (mns) res = -res;
  return res;
}
void add(int &x, int y) {
  x += y;
  if (x >= mod) x -= mod;
  if (x < 0) x += mod;
}
int mult(int x, int y) {
  return x * 1ll * y % mod;
}
int sum(int x, int y) {
  add(x, y);
  return x;
}
 
int a, b, c, d, e, f;
ld need;
ld calc(int x, int y) {
  if (!y) return 0;
  return (100 * y) / (ld)(x + y);
}
map <ll, bool> g1, g2;
ld mx = -1;
int ax, ay;
void solve() {
  cin >> a >> b >> c >> d >> e >> f;
  a *= 100;
  b *= 100;
  rep(i, 0, 100)
    rep(j, 0, 100)
      g1[i * a + j * b] = 1;
  rep(i, 0, 3000)
    rep(j, 0, 3000)
      g2[i * c + j * d] = 1;
 
  need = (ld)100 / e;
//  ax = f;
  rep(i, 0, f) {
    rep(j, 0, i) {
      if (i + j <= f && (ld)j * (ld)need <= (ld)i && g1[i] && g2[j]) {
        if (calc(i, j) >= mx) {
          mx = calc(i, j);
          ax = i + j, ay = j;
        }
      }
    }
  }
  cout << ax << ' ' << ay;
}
int main() {
  #ifdef IOI2018
    #define Toktama ""
    freopen (Toktama".in", "r", stdin);
    //freopen (Toktama".out", "w", stdout);
  #endif
  int T = 1;
  while (T--)
    solve();
  ioi
}

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

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


Measured memory_bytes: 3104
//inlclude前用define 
#define _USE_MATH_DEFINES

//include
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<cmath>
#include<type_traits>
#include<numeric>
//#include<deque>
#include<iomanip>
#include<set>
#include<tuple>
#include<map>
#include<limits>

using namespace std;

//typedef
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<char> VC;
typedef long long int ll;

//define
#define INF 1e9 
#define NUM 1000000007
#define all(x) begin(x), end(x)
#define rep(i,n) for(int i=0;i<(int)(n);i++)

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

  ll ans=0;
  int d,res;
  rep(a,k){
    rep(b,k){
      rep(c,k){
        d=__gcd(a+1,b+1);
        res=__gcd(c+1,d);
        ans+=res;
      }
    }
  }
  cout<<ans<<endl;


}

Measured memory_bytes: 3620
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;

class Program
{
    internal static void Main(string[] args)
    {
        var N = int.Parse(ReadLine());
        var S = new Dictionary<String, long>() {
            {"M", 0},
            {"A", 0},
            {"R", 0},
            {"C", 0},
            {"H", 0}
        };
        for (int i = 0; i < N; i++) {
            var str = ReadLine().Substring(0, 1);
            if (S.ContainsKey(str)) {
                S[str]++;
            }
        }

        string[] p = { "M", "M", "M", "M", "M", "M", "A", "A", "A", "R" };
        string[] q = { "A", "A", "A", "R", "R", "C", "R", "R", "C", "C" };
        string[] r = { "R", "C", "H", "C", "H", "H", "C", "H", "H", "H" };

        long ans = 0;
        for (int i = 0; i < 10; i++) {
            ans += S[p[i]] * S[q[i]] * S[r[i]];
        }
        WriteLine(ans);
    }
}


Measured memory_bytes: 15320
#include <iostream>

using namespace std;

int main (void)
{
    int c[3][3];

    for (int i = 0; i < 3; i++) {
        for (int j = 0; j < 3; j++) {
            cin >> c[i][j];
        }
    }

    int a[3], b[3];

    a[0] = 0;
    for (int i = 0; i < 3; i++) {
        b[i] = c[0][i] - a[0];
    }
    for (int i = 1; i < 3; i++) {
        a[i] = c[i][0] - b[0];
    }

    bool correct = true;
    for (int i = 0; i < 3; i++) {
        for (int j = 0; j < 3; j++) {
            if (c[i][j] != a[i] + b[j]) {
                correct = false;
            }
        }
    }
    cout << ((correct)? "Yes": "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);
		// 整数の入力
		long A = sc.nextLong();
		long B = sc.nextLong();
		int C = sc.nextInt();
		int D = sc.nextInt();

		long a =C,b=D;
		long x = a * b;
		long tmp,r;
		if (a < b) {
			tmp = a;
			a = b;
			b = tmp;
		}

		r = a % b;
		while (r != 0) {
			a = b;
			b = r;
			r = a % b;
		}

		long min = x/b;
		System.out.println(B-A-(countup(A,B,C)+countup(A,B,D)-countup(A,B,min))+1);

	}
	static long countup(long A,long B,long n) {
		return countup(B,n)-countup(A,n)+(A%n==0?1:0);
	}
	static long countup(long A,long n) {
		return A/n;
	}
}

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

int main(void)
{
	int n,i,x[1000],y[1000];
	double p_1=0,p_2,p_3,p_inf,p2=0,p3=0,c=0.33333333333;
	scanf("%d",&n);
	for(i=0;i<n;i++)
	{
		scanf("%d",&x[i]);
	}
	for(i=0;i<n;i++)
	{
		scanf("%d",&y[i]);
	}
	for(i=0;i<n;i++)
	{
		p_1 += abs(x[i]-y[i]);
	}
	for(i=0;i<n;i++)
	{
		p2 += pow(abs(x[i]-y[i]),2);
	}
	p_2 = sqrt(p2);
	for(i=0;i<n;i++)
	{
		p3 += pow(abs(x[i]-y[i]),3);
	}
	p_3=pow(p3,c);
	p_inf=abs(x[0]-y[0]);
	for(i=1;i<n;i++)
	{
		if(p_inf<abs(x[i]-y[i]))
		{
			p_inf = abs(x[i]-y[i]);
		}
	}
	printf("%f\n%f\n%f\n%f\n",p_1,p_2,p_3,p_inf);

return 0;
}

Measured memory_bytes: 704
from collections import Counter

def main():
    inp = lambda: [int(x) for x in input().split()]
    f = lambda x: x * (x - 1) // 2

    n = int(input())
    a = inp()
    counter = Counter(a)
    ans = sum([f(counter[c]) for c in counter])
    for key in a:
        val = counter[key]
        print(ans - (f(val) - f(val-1)))
    

if __name__ == '__main__':
    main()



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

using VS = vector<string>;    using LL = long long;
using VI = vector<int>;       using VVI = vector<VI>;
using PII = pair<int, int>;   using PLL = pair<LL, LL>;
using VL = vector<LL>;        using VVL = vector<VL>;

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))
#define FOR(i, s, e) for (int(i) = (s); (i) < (e); (i)++)
#define FORR(i, s, e) for (int(i) = (s); (i) > (e); (i)--)
//#pragma GCC optimize ("-O3") 
#ifdef YANG33
#include "mydebug.hpp"
#else
#define DD(x) 
#endif
const int INF = 1e9;                          const LL LINF = 1e16;
const LL MOD = 1000000007;                    const double PI = acos(-1.0);
int DX[8] = { 0, 0, 1, -1, 1, 1, -1, -1 };    int DY[8] = { 1, -1, 0, 0, 1, -1, 1, -1 };

/* -----  2019/02/28  Problem: ABC 106 B / Link: http://abc106.contest.atcoder.jp/tasks/abc106_b  ----- */
/* ------問題------



-----問題ここまで----- */
/* -----解説等-----



----解説ここまで---- */
vector<LL> getdivisor(LL n) {
	vector<LL> res;
	for (LL i = 1; i*i <= n; i++) {
		if (n%i == 0) {
			res.push_back(i);
			if (n / i != i)res.push_back(n / i);
		}
	}
	sort(res.begin(), res.end());
	return res;
}
LL ans = 0LL;

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

	LL N; 
	cin >> N;
	FOR(i, 1, N + 1) {
		if (i % 2) {
			auto res = getdivisor(i);
			if (SZ(res) == 8) {
				ans++;
			}
		}
	}
	
	
	cout << ans << "\n";

	return 0;
}


Measured memory_bytes: 256
n=int(input())
a=list(map(int,input().split()))
mi=a[0]
ans=0
for i in range(1,n):

    if mi>a[i]:
        ans+=mi-a[i]
        mi=max(mi,a[i])
        #print(ans)
    else:
        mi=a[i]
print(ans)


Measured memory_bytes: 32300
#include<bits/stdc++.h>
#include<algorithm>
#include<math.h>
#include<string>
#include<iostream>
#include<vector>
#include<cstdlib>
#include<stdio.h>
#include<cmath>
#include<limits>
#include<iomanip>

using namespace std;
 
template <class T> using V = vector<T>;
 
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;
}
 
const long long INF = 1LL << 60;
 
using ll = long long;
using db = long double;
using st = string;
using ch = char;
using bl = bool;
using vll = V<ll>;
using vpll =V<pair<ll,ll>>;
using vst = V<st>;
using vdb = V<db>;
using vch = V<ch>;
using vbl = V<bl>;
using graph = V<V<int>>;
using pq = priority_queue<ll>;


 
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define rFOR(i,a,b) for(ll i=(a);i>=(b);i--)
#define oFOR(i,a,b) for(ll i=(a);i<(b);i+=2)
#define bgn begin()
#define en end()
#define SORT(a) sort((a).bgn,(a).en)
#define REV(a) reverse((a).bgn,(a).en)
#define M(a,b) max(a,b)
#define rM(a,b) min(a,b)
#define fi first
#define se second
#define sz size()
#define gcd(a,b) __gcd(a,b)
#define co(a) cout<<a<<endl;
#define ci(a) cin>>a;
#define pb(a) push_back(a);
  
 

ll sum(ll n) {
ll m=0;
  while(n){
    m+=n%10;
    n/=10;
  }
  return m;
}
 
 
const int MAX = 510000;
const int MOD = 1000000007;
 
long long fac[MAX], finv[MAX], inv[MAX];
 
void Comuse() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}
 
 
#define comuse Comuse()
 
ll combi(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
 
 
ll lcm(ll a,ll b){
  ll n;
  n=a/gcd(a,b)*b;
  return n;
}


vll div(ll n){
  vll ret;
  for(ll i=1;i*i<=n;i++){
    if(n%i==0){
      ret.push_back(i);
      if(i*i!=n){
        ret.push_back(n/i);
      }
    }
  }
  SORT(ret);
  return (ret);
}

void Solve();

 
/****************************************\
| Thank you for viewing my code:)        |
| Written by RedSpica a.k.a. RanseMirage |
| Twitter:@asakaakasaka                  | 
\****************************************/
 

signed main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout<<setprecision(20)<<fixed;
  Solve();
}

void Solve(){
  db a,b,x;
    cin>>a>>b>>x;
  db t=(2*a*a*b-2*x)/a/a;
  db ans=a/t;
  if(t>b){
    t=2*x/a/b;
    ans=t/b;
  }
  db pi=3.14159265;
  cout<<90-atanl(ans)*180/pi<<"\n";
}


Measured memory_bytes: 256
def odd(n):
    return int(3 * n + 1)

def even(n):
    return int(n / 2)

num_list = [int(input())]
flag = True
m = 1
delete_num = 0
while(flag):
    if(num_list[-1] % 2 == 0):
        num_list.append(even(num_list[-1]))
    else:
        num_list.append(odd(num_list[-1]))
    num_len = len(num_list)
    delete_num = num_list[-1]
    m += 1
    if(delete_num in num_list[:num_len-1]):
        flag = False
print(m)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
int main(){
  string s;
  cin >> s;
  s+="   ";
  string st="YAKI";
    for(int i=0;i<4;i++){
      if(s[i]!=st[i]){
	cout << "No" << endl;
	return 0;
      }
    }
    cout << "Yes" << endl;
  return 0;
}


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

const int MAX = 55;

typedef long long ll;

int main()
{
	string a; cin>>a;
	int n=a.length();
	int i=0; ll cntBC=0,cntA=0;
	ll ans=0;

	while(i<n){
		if(a[i]=='C' or a[i]=='B'){
			cntA=0; cntBC=0; i++; continue;
		}
		int j=i;

		while(a[j]=='A' and j<n)j++;
		if(j==n)break;
		cntA += j-i;

		cntBC = 0;
		while(a[j]=='B' and a[j+1]=='C' and j+1<n) {j += 2; cntBC += 1;}

		ans += cntA*cntBC;
		i = j;
	}

	cout<<ans;
}

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

int main(){
	int w,a,b;	cin>>w>>a>>b;
	int ans=abs(max(a,b)-(min(a,b)+w));
	if(abs(b-a)<=w)ans=0;

	cout<<ans<<endl;

	return 0;
}


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

int main(){
  string S ;
  cin >> S ;
  
  if (S.at(2) == S.at(3) && S.at(4) == S.at(5)){
   cout << "Yes" << endl ; 
  }
  
  else{
    cout << "No" << endl; 
  }
  
  
  
  
  
  
}


Measured memory_bytes: 3532
#include <iostream>
#include <iomanip>
#include <random>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#include <numeric>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <sstream>
#include <bitset>
#include <cassert>
#include <fstream>
#include <queue>

#define len(X) ((int)(X).size())

#ifdef __LOCAL
	#define DBG(X) cout << #X << "=" << (X) << endl;
#else
	#define DBG(X)
	#define endl '\n'
#endif
 
using namespace std;

using ll = long long int;
using ull = unsigned long long int;
using ld  = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

const int INT_INF = (int)(2e9);
const ll  LL_INF  = (ll)(2e18);

const ll mod = 1e9 + 7;
const int NIL = -1;
static mt19937 _g(time(nullptr));

inline ll randint(ll a, ll b) { ll w = (_g() << 31LL) ^ _g(); return a + w % (b - a + 1); }
inline void fast_io() { ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); };
template<typename T> inline T sign(T x) { return T(x > 0) - T(x < 0); }
template<typename T, typename S> inline ostream& operator<<(ostream& os, const pair<T, S> p) { cout << "[" << p.first << ";" << p.second << "]"; return os; }
template<typename T> inline ostream& operator<<(ostream& os, const vector<T>& v) { for(auto el: v) cout << el << " "; return os; }

const int MAX_N = (int)1e5 + 777;

int a[MAX_N], dp[MAX_N], n;

void solve()
{
	cin >> n;

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

	int answ = 0;

	for(int i = 0; i < n; ++i)
	{
		dp[i] = 1;

		if(i > 0 && a[i] <= a[i - 1])
			dp[i] = max(dp[i], 1 + dp[i - 1]);

		answ = max(answ, dp[i]);
	}

	cout << answ - 1 << endl;
}

int main()
{
	fast_io();
	solve();

	return 0;
}


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

using namespace std;

int gc[210][210][210];

int gcd(int a, int b)
{
	if (a == 0)
		return b;
	if (b == 0)
		return a;
	if (a == b)
		return a;

	if (a > b)
		return gcd(a - b, b);
	return gcd(a, b - a);
}

int main() {
	int n;
	cin >> n;
	int s = 0;
	memset(gc, 0, 210 * 210 * 210);
	for (int i = 1; i <= n; i++) {
		for (int j = 1; j <= n; j++)
			for (int h = 1; h <= n; h++) {
				if (gc[i][j][h] == 0) {
					gc[i][j][h] = gcd(i, gcd(j, h));
					gc[i][h][j] = gc[i][j][h];
					gc[j][i][h] = gc[i][j][h];
					gc[j][h][i] = gc[i][j][h];
					gc[h][i][j] = gc[i][j][h];
					gc[h][j][i] = gc[i][j][h];
				}
				s += gc[i][j][h];
			}
	}
	cout << s;
	cin >> n;
}

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

typedef long long int ll;
#define INF 1999999999
#define MODA 1000000007

int main()
{
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    ios::sync_with_stdio(false);
    cin.tie(0);
    string s;
    cin >> s;
    set<char>c;
    for(int i = 0; i < 3; i++)
    {
        c.insert(s[i]);
    }

    if(c.size() == 3)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;

    return 0;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
  int n,C,ans=1000000000,tmp;
  cin >> n >> C;
  int d[C][C],c[n][n],grp_num[3][30]={};
  for(int i=0;i<C;i++){
    for(int j=0;j<C;j++){
      cin >> d[i][j];
    }
  }
  for(int i=0;i<n;i++){
    for(int j=0;j<n;j++){
      cin >> c[i][j];
      c[i][j]--;
      grp_num[(i+j)%3][c[i][j]]++;
    }
  }
  for(int i=0;i<C;i++){
    for(int j=0;j<C;j++){
      for(int k=0;k<C;k++){
        if(i==j||j==k||i==k){
          continue;
        }
        tmp=0;
        for(int l=0;l<C;l++){
          tmp += d[l][i]*grp_num[0][l];
          tmp += d[l][j]*grp_num[1][l];
          tmp += d[l][k]*grp_num[2][l];
        }
        ans = min(tmp,ans);
      }
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 1280
k, s=map(int, input().split())

ans=0
for x in range(0, k+1):
    if x>s:
        break
    for y in range(0, k+1):
        if x+y>s:
            break
        z=s-x-y
        if 0<=z and z<=k:
            ans+=1
            continue
print(ans)

Measured memory_bytes: 3060
#include <iostream>
using namespace std;
int main()
{
	long n,ans;
	cin >> n;
	if(n==1){
		ans=0;
	}
	else if(n==2){
		ans=1;
	}
	else if(n>2){
		ans=n*(n-1)/2;
	}
	cout << ans << endl;
	return 0;
}

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

using namespace std;

typedef long long ll;
// typedef pair<ll, ll> P;
typedef pair<int, int> P;

#define MOD 1000000007
#define REP(i, N) for (int i = 0; i < N; ++i)
#define REP1(i, N) for (int i = 1; i <= N; ++i)
#define RREP(i, N) for (int i = N - 1; i >= 0; --i)
#define ALL(a) a.begin(), a.end()

int main() {
  int N, M;
  cin >> N >> M;
  vector<P> vc;
  REP(i, M) {
    int a, b;
    cin >> a >> b;
    vc.push_back(P(b, a));
  }
  sort(ALL(vc));
  int t = 1;
  int ans = 0;
  REP(i, M) {
    if (t <= vc[i].second) {
      ans++;
      t = vc[i].first;
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 1400
#[allow(unused_macros)]
macro_rules ! input { ( source = $ s : expr , $ ( $ r : tt ) * ) => { let mut iter = $ s . split_whitespace ( ) ; let mut next = || { iter . next ( ) . unwrap ( ) } ; input_inner ! { next , $ ( $ r ) * } } ; ( $ ( $ r : tt ) * ) => { let stdin = std :: io :: stdin ( ) ; let mut bytes = std :: io :: Read :: bytes ( std :: io :: BufReader :: new ( stdin . lock ( ) ) ) ; let mut next = move || -> String { bytes . by_ref ( ) . map ( | r | r . unwrap ( ) as char ) . skip_while ( | c | c . is_whitespace ( ) ) . take_while ( | c |! c . is_whitespace ( ) ) . collect ( ) } ; input_inner ! { next , $ ( $ r ) * } } ; }
#[allow(unused_macros)]
macro_rules ! input_inner { ( $ next : expr ) => { } ; ( $ next : expr , ) => { } ; ( $ next : expr , $ var : ident : $ t : tt $ ( $ r : tt ) * ) => { let $ var = read_value ! ( $ next , $ t ) ; input_inner ! { $ next $ ( $ r ) * } } ; }
#[allow(unused_macros)]
macro_rules ! read_value { ( $ next : expr , ( $ ( $ t : tt ) ,* ) ) => { ( $ ( read_value ! ( $ next , $ t ) ) ,* ) } ; ( $ next : expr , [ $ t : tt ; $ len : expr ] ) => { ( 0 ..$ len ) . map ( | _ | read_value ! ( $ next , $ t ) ) . collect ::< Vec < _ >> ( ) } ; ( $ next : expr , chars ) => { read_value ! ( $ next , String ) . chars ( ) . collect ::< Vec < char >> ( ) } ; ( $ next : expr , usize1 ) => { read_value ! ( $ next , usize ) - 1 } ; ( $ next : expr , $ t : ty ) => { $ next ( ) . parse ::<$ t > ( ) . expect ( "Parse error" ) } ; }

fn main() {
    input! {
        a: u64, b: u64
    }
    let c: u64 = format!("{}{}", a, b).parse().unwrap();
    let r = (c as f64).sqrt() as u64;
    println!("{}", if r*r == c {"Yes"} else {"No"});
}

Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,n) for(int i=0;i<n;i++)
#define why(n,x) int n;while(cin >>n,n!=x)
#define iFOR(i,x,n)for(int i=x;i<n;i++)
#define unless(flg) if ( !(flg) )
#define read cin<<
#define echo cout<<
#define fin <<'\n'
#define __ <<" "<<
#define ___ <<" "
#define bash push_back
#define ALL(x) x.begin(),x.end()
#define SWAP(a,b) ((a != b) && (a += b,b = a - b,a -= b))
#define cinf(n,x) for(int UNCH=0;UNCH<(n);UNCH++) cin >> x[UNCH];
#define fcin(n,x) for(int UNCH=1;UNCH<=(n);UNCH++) cin>> x[UNCH];
#define memmin(x) memset((x),-1,sizeof((x)))
#define memzer(x) memset((x), 0,sizeof((x)))
#define meminf(x) memset((x),0x3f,sizeof((x)))
#define int long long
typedef long long ll;
typedef pair < int , int >  pii;
typedef vector < int > vit;
typedef map < string , int > mstit;
typedef vector < pii > vpi ;
typedef greater < pii > gpi;
typedef priority_queue < pii , vpi , gpi > dijk ;
static const signed int INF = 0x3f3f3f3f;
static const signed long long LINF = 0x3f3f3f3f3f3f3f3fLL;
static const signed int SMOD = 1000000007;
static const signed int NMOD = 1000000009;
static const signed int dx[]={1,0,-1,0,1,1,-1,-1};
static const signed int dy[]={0,-1,0,1,-1,1,-1,1};

bool inside(int x,int y,int w,int h){return (x>=0 && y>=0 && x<w && y<h);}
template<class T>T abs(T &x){return x<0 ? -x : x;}
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; }
int qp(int a,ll b,int mo){int ans=1;do{if(b&1)ans=1ll*ans*a%mo;a=1ll*a*a%mo;}while(b>>=1);return ans;}
int gcd(int a,int b){return b?gcd(b,a%b):a;}



signed main(){

  int n,a,b;
  string str;

  char s[3][256];
  cinf(3,s);
  printf("%c%c%c\n",s[0][0]-'a'+'A',s[1][0]-'a'+'A',s[2][0]-'a'+'A');
  return 0;
}



//struct xyz{ xyz(){ cin.tie(0), ios::sync_with_stdio(false); cout <<fixed<<setprecision(12);};}xyzzy;



Measured memory_bytes: 256
n = int(input())
ans = n
x = []
for i in range(n):
    a ,b= map(int,input().split())
    x.append([a-b, a+b])
x.sort()

tmp= x[0]
for i in range(n-1):
    if tmp[1] <= x[i+1][0]:
        tmp = x[i+1]
    elif tmp[1] <= x[i+1][1]:
        ans -= 1
    else:
        tmp = x[i+1]
        ans -= 1
print(ans)



Measured memory_bytes: 60136
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>

using namespace std;

#define ll long long
#define ld long double
#define EPS 0.0000000001
#define INF 1e9
#define rep(i,n) for(i=0;i<n;i++)
#define loop(i,a,n) for(i=a;i<n;i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)

typedef vector<int> vi;
typedef pair<int,int> pii;


int main(void) {
  int i,j;
  int n;
  while(1){
    cin>>n;
    if(n==0)break;
    pii p[100000];
    rep(i,n){
      cin>>p[i].second;
      int sum=0;
      rep(j,4){
        int m,s;
        cin>>m>>s;
        sum+=60*m+s;
      }
      p[i].first=sum;
    }
    sort(p,p+n);
    cout<<p[0].second<<endl;
    cout<<p[1].second<<endl;
    cout<<p[n-2].second<<endl;
  }
}

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


def solve(N: int, s: "List[str]", t: "List[int]", X: str):
    index = s.index(X)
    print(sum(t[index+1:]))
    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
    s = [str()] * (N)  # type: "List[str]"
    t = [int()] * (N)  # type: "List[int]"
    for i in range(N):
        s[i] = next(tokens)
        t[i] = int(next(tokens))
    X = next(tokens)  # type: str
    solve(N, s, t, X)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3188
#B - Bite Eating(ABC131)
A=list(map(int, input().split()))
aji1=0
B=[]
C=[]
for i in range(1,A[0]+1):
    aji1+=A[1]+i-1
    B.append(abs(A[1]+i-1))
    C.append(A[1]+i-1)
print(aji1-C[B.index(min(B))])   

Measured memory_bytes: 3060
#include<bits/stdc++.h>
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
#define Reza ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define         ll          long long
#define         yes         cout<<"YES"<<endl
#define         no          cout<<"NO"<<endl
#define         ff          first
#define         sc          secound
#define         mp          make_pair
#define         MAX         100000
ll q,n,cnt,sum,f;
vector<int>v,vv;
int main()
{

     Reza;
     cin>>q>>n;
     cout<<q*n<<endl;
     
     return 0;

}


Measured memory_bytes: 3684
# 二項係数を"やるだけ"にしてくれるライブラリ
from collections import Counter
MAX = 1000005
MOD = 998244353
factrial = [0]*MAX
inverse = [0]*MAX
factrial_inverse = [0]*MAX


# テーブルを作る前処理
def COMinit():
    global factrial, inverse, factrial_inverse
    factrial[0] = 1
    factrial[1] = 1
    inverse[1] = 1
    factrial_inverse[0] = 1
    factrial_inverse[1] = 1
    for i in range(2, MAX):
        factrial[i] = factrial[i-1] * i % MOD
        inverse[i] = MOD - inverse[MOD % i] * (MOD//i) % MOD
        factrial_inverse[i] = factrial_inverse[i-1] * inverse[i] % MOD


# 二項係数計算
def COM(n, k):
    global factrial, inverse, factrial_inverse
    if n < k:
        return 0
    if n < 0 or k < 0:
        return 0
    return factrial[n] * (factrial_inverse[k] * factrial_inverse[n-k] % MOD) % MOD


# 前処理完了
COMinit()

N, M, K = map(int, input().split())
ans = 0

for i in range(K+1):  # つまり没となるブロックの数がi個
    ans += M * pow(M-1, N-(i+1), MOD) % MOD * COM(N-1, i)
print(ans % MOD)


Measured memory_bytes: 127868
{-# LANGUAGE FlexibleInstances    #-}
{-# LANGUAGE TypeSynonymInstances #-}

import           Control.Applicative
import           Control.DeepSeq
import           Control.Monad
import           Control.Monad.ST
import qualified Data.Array                  as A
import qualified Data.Array.IArray           as IA
import qualified Data.Array.IO               as AI
import qualified Data.Array.MArray           as MA
import qualified Data.Array.ST               as STA
import qualified Data.Array.Unboxed          as AU
import           Data.Bits
import qualified Data.ByteString.Char8       as BS
import           Data.Char
import qualified Data.Graph                  as G
import           Data.Int
import qualified Data.IntMap                 as IM
import qualified Data.IntSet                 as IS
import           Data.List
import qualified Data.Map.Strict             as M
import           Data.Maybe
import           Data.Ord
import qualified Data.Sequence               as SQ
import qualified Data.Set                    as S
import           Data.Time
import qualified Data.Tree                   as T
import qualified Data.Vector                 as V
import qualified Data.Vector.Mutable         as VM
import qualified Data.Vector.Unboxed         as VU
import qualified Data.Vector.Unboxed.Mutable as VUM

class Printable a where
  format :: a -> String

instance Printable Int where
  format = show

instance Printable Integer where
  format = show

instance Printable Double where
  format = show

instance Printable Float where
  format = show

instance Printable Char where
  format = show

instance Printable String where
  format x = x

instance Printable Bool where
  format = show

put :: Printable a => a -> IO ()
put = putStr . format

putLn :: Printable a => a -> IO ()
putLn = putStrLn . format

putList :: Printable a => [a] -> IO ()
putList [a] = put a
putList (a:as) = do
  put a
  putStr " "
  putList as

readInt :: IO [Int]
readInt = map (fst . fromJust . BS.readInt) . BS.words <$> BS.getLine

readInts :: Int -> IO [[Int]]
readInts n = replicateM n readInt

readInteger :: IO [Integer]
readInteger = map (fst . fromJust . BS.readInteger) . BS.words <$> BS.getLine

readIntegers :: Int -> IO [[Integer]]
readIntegers n = replicateM n readInteger

readString :: IO [String]
readString = map BS.unpack . BS.words <$> BS.getLine

readStrings :: Int -> IO [[String]]
readStrings n = replicateM n <$> readString

toPair :: [a] -> (a, a)
toPair [x, y] = (x, y)

count :: Eq a => a -> [a] -> Int
count a as = length $ filter (== a) as

main = do
  [a, b] <- readInt
  if b `mod` a == 0
    then putLn $ a + b
    else putLn $ b - a


Measured memory_bytes: 380
#include<iostream>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<map>
#include<set>
#include<queue>
#include<stack>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1000000000
int d;
int main() {
	while (cin >> d) {
		int ans = 0;
		for (int i = d;i <= 600 - d;i+=d) {
			ans += i * i*d;
		}
		cout << ans << endl;
	}
	getchar();getchar();
	return 0;
}


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

int main(){
  
  string S;
  cin >> S;
  
  for (int i=0; i<S.size(); i++){
    
    if (S.at(i)==','){
      cout << ' ';
    }
    else {
      cout << S.at(i);
    }
    
  }
}


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

#define MAX 100002
int n;

vector<int> v;

vector<int> ar;
vector<int> cer;
bool ok2(int val){
	ar.clear();
	for (int i = 0; i < v.size(); i++){
		ar.push_back(v[i] >= val);
	}
	cer.assign(ar.size(), 0);
	for (int i = 0; i < ar.size(); i++){
		if (ar[i]){
			if (i&&ar[i - 1]){
				cer[i] = ar[i];
			}
			if (i + 1 < ar.size() && ar[i + 1]){
				cer[i] = ar[i];
			}
		}
	}
	int u = n - 1;
	if (cer[u]){
		return true;
	}
	int lef = 0;
	for (int i = 0; i < u; i++){
		if (cer[i]){
			lef = i + 1;
		}
	}
	int rig = ar.size() - 1;
	for (int i = ar.size() - 1; i > u; i--){
		if (cer[i]){
			rig = i - 1;
		}
	}
	int L, R;
	L = u - 1;
	R = u + 1;
	if (n % 2 == 0){
		for (int i = 0; i < n / 2; i++){
			if (L >= lef){
				cer[L] = true;
			}
			if (R <= rig){
				cer[R] = true;
			}
			L -= 2;
			R += 2;
		}
		L += 2;
		R -= 2;
	}
	else{
		L = R = u;
		for (int i = 0; i <= n / 2; i++){
			if (L >= lef){
				cer[L] = true;
			}
			if (R <= rig){
				cer[R] = true;
			}
			L -= 2;
			R += 2;
		}
		L += 2;
		R -= 2;
	}
	L = max(L, lef);
	R = min(R, rig);
	for (int i = L; i <= R; i++){
		if (cer[i] != ar[i])return false;
	}
	return true;
}
bool ok(int val){
	if (ok2(val))return true;
	ar.clear();
	for (int i = 0; i < v.size(); i++){
		ar.push_back(v[i] >= val);
	}
	cer.assign(ar.size(), 0);
	for (int i = 0; i < ar.size(); i++){
		if (ar[i]){
			if (i&&ar[i - 1]){
				cer[i] = ar[i];
			}
			if (i + 1 < ar.size() && ar[i + 1]){
				cer[i] = ar[i];
			}
		}
	}
	int u = n-1;
	if (cer[u]){
		return true;
	}
	int lef = 0;
	for (int i = 0; i < u; i++){
		if (cer[i]){
			lef = i + 1;
		}
	}
	int rig = ar.size() - 1;
	for (int i = ar.size() - 1; i > u; i--){
		if (cer[i]){
			rig = i-1;
		}
	}
	if(rig!=ar.size()-1){
		int cnt = 0;
		int ich = rig-1;
		while (ich>=0&&ar[ich]){
			cnt++;
			ich -= 2;
		}
		ich += 2;
		int len = rig - ich+1;
		len /= 2;
		if (rig - len + 1 <= u){
			return true;
		}
	}
	if(lef){
		int cnt = 0;
		int ich = lef+1;
		while (ich < ar.size()&&ar[ich]){
			cnt++;
			ich += 2;
		}
		ich -= 2;
		int len = ich - lef + 1;
		len /= 2;
		if (lef + len-1 >= u){
			return true;
		}
	}
	return false;
}

int main(){
	cin >> n;
	for (int i = 0; i < 2 * n - 1; i++){
		int a;
		scanf("%d", &a);
		v.push_back(a);
	}
	int u = n-1;
	int mint = max(min(v[u], v[u - 1]), min(v[u], v[u + 1]));
	int maxt = *max_element(v.begin(), v.end());
	while (mint + 1 < maxt){
		int mid = (mint + maxt) >> 1;
		if (ok(mid)){
			mint = mid;
		}
		else{
			maxt = mid - 1;
		}
	}
	if (ok(maxt)){
		cout << maxt << endl;
	}
	else{
		cout << mint << endl;
	}
	return 0;
}

Measured memory_bytes: 2676
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <iostream>
using namespace std;
int n;
int left(int i) { return i * 2; }
int right(int i) { return i * 2 + 1; }
void maxHeapify(int *p, int i) {
	int l = left(i);
	int r = right(i);
	int lg;
	if (l <= n && p[i] < p[l]) 
			lg = l;
	else lg = i;
	if (r <= n && p[lg] < p[r]) 
		lg = r;
	if (lg != i) {
		swap(p[i], p[lg]);
		maxHeapify(p, lg);
	}
}
int main() {
	cin >> n;
	int *pt;
	pt = new int[n];
	for (int i = 1; i <= n; i++)
		cin >> pt[i];
	for (int i = n/2; i >= 1; i--) maxHeapify(pt, i);
	for (int i = 1; i <= n; i++) cout << " " << pt[i];
	cout << endl;
delete[] pt;
	return 0;
}

Measured memory_bytes: 4580
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String {
            bytes
                .by_ref()
                .map(|r| r.unwrap() as char)
                .skip_while(|c| c.is_whitespace())
                .take_while(|c| !c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

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

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

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

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

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

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

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

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

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

use std::cmp::min;

fn main() {
    input!{
        n: usize,
        k: usize,
        mut v: [usize; n]
    }
    v.sort();
    let mut ans = usize::max_value();
    for i in 0..n - k + 1 {
        ans = min(ans, v[i + k - 1] - v[i]);
    }
    println!("{}", ans);
}


Measured memory_bytes: 4352
Lista=[1,3,5,7,8,10,12]
Listb=[4,6,9,11]
Listc=[2]
x,y=map(int,input().split())
if ((Lista.count(x)==1 and Lista.count(y)==1)
    or (Listb.count(x)==1 and Listb.count(y)==1)
    or (Listc.count(x)==1 and Listc.count(y)==1)):
  print("Yes")
else:
  print("No")

Measured memory_bytes: 38256
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
from itertools import permutations, accumulate, combinations, combinations_with_replacement
from math import sqrt, ceil, floor, factorial
from bisect import bisect_left, bisect_right, insort_left, insort_right
from copy import deepcopy
from operator import itemgetter
from functools import reduce
from fractions import gcd
import sys
def input(): return sys.stdin.readline().rstrip()
def I(): return int(input())
def Is(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
def TI(): return tuple(map(int, input().split()))
def IR(n): return [I() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def TIR(n): return [TI() for _ in range(n)]
def S(): return input()
def Ss(): return input().split()
def LS(): return list(input())
def SR(n): return [S() for _ in range(n)]
def SsR(n): return [Ss() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
sys.setrecursionlimit(10**6)
MOD = 10**9+7
INF = 10**18
# ----------------------------------------------------------- #

a, b = Is()
if a*b % 2 != 0:
    print("Yes")
else:
    print("No")


Measured memory_bytes: 63888
#include <bits/stdc++.h>
using namespace std;
 
#define ll long long
#define all(aaa) aaa.begin(), aaa.end()

const ll INF = 1e18;
const int a[3] = {2, 3, 5};
ll w[3];
map<ll, ll> mp;
ll d;

ll f(ll x) {
    if (x == 0)
        return 0ll;
    if (mp.count(x))
        return mp[x];
    ll ans = min(x * (double)d, (double)INF);
    for (int i = 0; i < 3; i++) {
        ll r = x % a[i], anime = x / a[i];
        if (anime != x)
            ans = min(ans, f(anime) + r * d + w[i]);
        anime = (x + a[i] - 1) / a[i];
        if (anime != x)
            ans = min(ans, f(anime) + (a[i] - r) % a[i] * d + w[i]);
    }
    mp[x] = ans;
    return ans;
}   

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

    int t;
    cin >> t;

    while (t--) {
        ll n;
        cin >> n >> w[0] >> w[1] >> w[2] >> d;
        cout << f(n) << "\n";
        mp.clear();
    }

    return 0;
}

Measured memory_bytes: 4516
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll N,a,b;
map<pair<ll, ll>, pair<ll, ll>> C;
ll X;
const ll MOD = 1000000007;
vector<ll> Pow;
ll Res;
ll gcd(ll a, ll b) { return b == 0 ? a : gcd(b, a % b); }
int main(){
  cin>>N;
  for(ll i = 0; i < N; ++i){
    cin>>a>>b;
    if(a==0&&b==0) {
      ++X;
      continue;
    }
    if (b < 0 || (a < 0 && b == 0)) {
      a *= -1;
      b *= -1;
    }
    bool reg = a <= 0;
    if (reg) {
      ll oldb = b;
      b = -a;
      a = oldb;
    }
    ll g = gcd(a, b);
    a /= g;
    b /= g;
    ++(reg ? C[{a, b}].first : C[{a, b}].second);
  }
  Res = 1;
  Pow.resize(N + 1);
  Pow[0] = 1;
  for (ll i = 1; i <= N; ++i) Pow[i] = 2 * Pow[i - 1] % MOD;
  for (auto abmn : C) {
    ll m, n;
    tie(m, n) = abmn.second;
    (Res *= (Pow[m] + Pow[n] + MOD - 1)) %= MOD;
  }
  if (X) (Res += X) %= MOD;
  cout << (Res + MOD - 1) % MOD << endl;
  return 0;
}


Measured memory_bytes: 20232
import queue
import copy
D = ((0, -1), (0, 1), (-1, 0), (1, 0))

def bfs(S, s):
    M = copy.deepcopy(S)
    M[s[1]][s[0]] = '#'
    q = queue.Queue()
    q.put((s[0], s[1], 0))
    dis = 0

    while not q.empty():
        cur = q.get()

        for d in D:
            x = cur[0] + d[0]
            y = cur[1] + d[1]
            if M[y][x] != '#':
                M[y][x] = '#'
                q.put((x, y, cur[2]+1))
                dis = max(dis, cur[2]+1)

    return dis


H, W = map(int, input().split())
S = [None]*(H+2)

S[0] = ['#'] * (W + 2)
for h in range(1, H+1):
    S[h] = ['#'] + [c for c in input()] + ['#']
S[-1] = ['#'] * (W + 2)

ans = 0
for sy in range(1, H+1):
    for sx in range(1, W+1):
        if S[sy][sx] != '#':
            ans = max(ans, bfs(S, (sx, sy)))

print(ans)

Measured memory_bytes: 4072
#include<iostream>
#include<vector>
#include<utility>
#include<algorithm>
#define PB	push_back
#define FOR(n)			for(int i = 0; i < n; ++i)
#define COUT(n)			cout << n << " " << flush
#define ALL(obj)		obj.begin(), obj.end()
using namespace std;

int main() {
	int n, p;
	string s;
	cin >> n;
	vector<pair<pair<string, int>, int>> sp(n);

	FOR(n) {
		cin >> s >> p;
		sp[i] = make_pair(make_pair(s, -p), i + 1);
	}
	sort(ALL(sp));

	FOR(n)
		cout << sp[i].second << endl;

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
stack<int>S1;
stack<pair<int,int>>S2;
char ch;
int sum,r,l,a,i;
vector<int> ans;
int main(){
  for(r=0;cin>>ch;r++){
    if(ch=='\\')S1.push(r);
    else if(ch=='/'&&S1.size()>0){
      l=S1.top();S1.pop();
      sum+=r-l;
      a=r-l;
      while(S2.size()>0&&S2.top().first>l){a+=S2.top().second;S2.pop();}
      S2.push(make_pair(l, a));
    }
  }
  while(S2.size()>0){ans.push_back(S2.top().second);S2.pop();}
  reverse(ans.begin(),ans.end());
  cout<<sum<<endl;
  cout<<ans.size();
  for(i=0;i<ans.size();i++){
    cout<<" ";
    cout<<ans[i];
  }
  cout<<endl;
  return 0;
}



Measured memory_bytes: 3248
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;

#define all(v) v.begin(), v.end()

const ll mod=1000000007;

ll countBits(ll in){
  int res=0;
  for(;in>0;in>>=1){
    if((in&0x01)!=0){
      res++;
    }
  }
  return res;
}

template<typename T>
void show2dVector(vector<vector<T>>& v){
  for(int i=0;i<v.size();i++){
    int m=v[i].size();
    cout<<i<<" : ";
    for(int j=0;i<m;i++){
      cout<<v[i][j]<<" ";
    }
    cout<<endl;
  }
}

void bfs(const vector<vector<int>>&g, int v, vector<bool>& seen){
  seen[v]=true;
  cout<<v<<" ";
  for(auto next: g[v]){
    if(seen[next]){
      continue;
    }
    bfs(g,next,seen);
  }
}

bool dfs(vector<vector<int>> &g,int start,int goal,vector<bool>&seen){
  bool res=false;
  seen[start]=true;
  if(start==goal){
    return true;
  }
  for(auto next: g[start]){
    if(seen[next]){
      continue;
    }
    res=dfs(g,next,goal,seen);
    if(res){
      break;
    }
  }
  return res;
}

ll gcd(ll a,ll b) {
  return b? gcd(b,a%b): a;  
}
ll lcm(ll a,ll b) {
  return a*b/gcd(a,b);
}
bool isLowerCase(char c){
  return (c>='a'&&c<='z');
}
ll powm(ll a,ll n, ll m){
  ll ret=1;
  while(n>0){
    if(n%2==1){
      ret=(ret*a)%m;
    }
    n>>=1;
    a=(a*a)%m;
  }
  return ret;
}

const string yesno(bool ans){
  return (ans?"Yes":"No");
}
int main() {
  ll x,y;cin>>x>>y;
  ll ans=0;
  if((x+y)%3!=0){
    cout<<0<<endl;
    return 0;
  }
  ll n,m;
  n=(2*x-y)/3;
  m=(2*y-x)/3;
  if(n<0||m<0){
    cout<<0<<endl;
    return 0;
  }
  ll b=1;
  ll a=1;
  for(ll i=0;i<n;i++){
    b*=(n+m-i);
    b%=mod;
    a*=(n-i);
    a%=mod;
  }
  a=powm(a,mod-2,mod);
  ans=(b*a);
  ans%=mod;
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using P = pair<int, int>;

int main() {
	string s, t;
	cin >> s >> t;
	int n = s.size();
	int m = t.size();
	sort(s.begin(), s.end());
	sort(t.rbegin(), t.rend());
	s = s.substr(0, n);
	t = t.substr(0, n);
	if (s == t && n < m)
		cout << "Yes" << endl;
	else if (s < t)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
}

Measured memory_bytes: 3628
#include <iostream>
#include <cstdio>
#include <string>
#include <cmath>
#include <cctype>
#include <cstdlib>
#include <stack>
#include <queue>
#include <vector>
#include <algorithm>
#include <list>
using namespace std;

int main() {
    int n, k, m = 0;
    cin >> n >> k;
    int r, s, p;
    cin >> r >> s >> p;
    string t;
    cin >> t;
    queue<char> q;
    for (int i = 0; i < k; i++) {
        q.push(t[i]);
        if (t[i] == 'r') m += p;
        else if (t[i] == 's') m += r;
        else m += s;
    }
    for (int i = k; i < n;i++) {
        if (t[i] != q.front()) {
            q.push(t[i]);
            if (t[i] == 'r') m += p;
            else if (t[i] == 's') m += r;
            else if (t[i] == 'p') m += s;
        }
        else q.push('a');
        q.pop();
    }
    cout << m << endl;
}
        

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

using namespace std;

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

  if(65<= N && N <= 90){
    cout << 1 << endl;
  }else if(97 <= N && N <= 122){
    cout << 2 << endl;
  }else{
    cout << 0 << endl;
  }

  return 0;
}



Measured memory_bytes: 3128
#include <stdio.h>
#include <vector>
#include <algorithm>
#include <string>
#include <iostream>
#include <math.h>
#include <array>
#include <vector>
#include <queue>
#include <stack>
#include <numeric>
#include <list>
#include <deque>
#include <map>
#include <set>
#include <cstdlib>

using namespace std;

typedef long long LL;
typedef pair<int, int>PII;

#define FOR(i,a,b) for(int i = (a); i < (b); ++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), rend()
#define PB pushback
#define SORT(c) sort((c).begin(),(c).end())

const LL INF = 1LL << 60;

//priority_queue<int> p;




//scanf("%d",&N);

//printf("%d", ans);

//cout <<  << endl;
int i, j, k, tmp, ans, cnt, N, M, T, K;
bool flag = true;


int main(void) {
	vector<array<int,2>> vec;
	scanf("%d", &N);
	REP(i, N) {
		array<int, 2> t;
		scanf("%d", &tmp);
		t.at(0) = tmp - 1;
		t.at(1) = i;
		vec.push_back(t);
	}
	sort(vec.begin(), vec.end());
	REP(i, N) {
		printf("%d ", vec.at(i).at(1) + 1);
	}
	
	
	return 0;
}

Measured memory_bytes: 1780
h, w, k = map(int, input().split())
s = [[int(i) for i in input()] for _ in range(h)]
ans = (h-1)+(w-1)
for i in range(2**(h-1)):
    d = [(i >> j) & 1 for j in range(h-1)]
    count, count_tmp = [0]*(sum(d)+1), [0]*(sum(d)+1)
    ans_, res = 0, 0
    flag = False
    for w_ in range(w):
        count[0] += s[0][w_]
        count_tmp[0] += s[0][w_]
        res += 1
        tmp = 0
        for h_ in range(1, h):
            if d[h_-1]: tmp += 1
            if s[h_][w_]:
                count[tmp] += 1
                count_tmp[tmp] += 1
        for j in count:
            if j > k:
                if res==1:
                    flag = True
                    break
                else:
                    for idx in range(sum(d)+1):
                        count[idx] = count_tmp[idx]
                    ans_ += 1
                    res = 1
                    break
        if flag: break
        count_tmp = [0]*(sum(d)+1)
    if flag: continue
    ans_ += sum(d)
    ans = min(ans, ans_)
print(ans)

Measured memory_bytes: 47964
#include<bits/stdc++.h>
using namespace std;
int he[100005],dp[100005];
int cost(int i,int n){
    if(dp[i]!=-1) return dp[i];
    int result;
    if(i==n) result=0;
    else if(i+1==n) result=abs(he[i]-he[i+1])+cost(i+1,n);
    else{
        int t1,t2;
        t1=abs(he[i]-he[i+1])+cost(i+1,n);
        t2=abs(he[i]-he[i+2])+cost(i+2,n);
        result=min(t1,t2);
    }
    dp[i]=result;
    return dp[i];
}
int main(){
    int n;
    cin >> n;
    memset(dp,-1,sizeof(dp));
    for(int i=1;i<=n;i++){
        cin >> he[i];
    }
    cout << cost(1,n) << endl;
    
}

Measured memory_bytes: 9032
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int l;
	cin>>l;
	double m = l;
	double k = m/3;
	double j = k*3;
	if(!(m<j)&&!(m>j))
	{
		printf("%.12f\n",k*k*k);
	}
	else
	{
		int n = l/3;
		int y = l%3;
		int sum = 1;
		for(int i=0;i<3;i++)
		{
			int no = n;
			if(y)
				no+=1;
			sum*=no;
		}
		cout<<sum<<endl;
	}
	return 0;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
  
  int h,n,x,y,b[10010]={};
  cin >> h >> n;
  for(int i=0;i<n;i++){
    cin >> x >> y;
    b[y] |= 1<<x;
  }
  
  int dp[10010][20] = {};
  int ni[] = {0x0,0x3,0x06,0xc,0xf};
  int cnt[] = {0,1,1,1,2};

  for(int i=1;i<h;i++){
    
    for(int j=0;j<(1<<4);j++){
      
      if( (b[i-1]&j) != b[i-1]) continue;

      for(int k=0;k<5;k++){
	
	if( (j&ni[k])==0 && (b[i]&ni[k])==0 ){
	  dp[i][b[i]|ni[k]] = max(dp[i][b[i]|ni[k]],dp[i-1][j] + cnt[k]);
	}
	
      }
      
    }

  }

  int ans = 0;
  for(int i=0;i<(1<<4);i++) ans = max(ans,dp[h-1][i]);
  cout << ans << endl;

  return(0);
}



Measured memory_bytes: 3948