akhauriyash/Code-Regression huggingface dataset:
import copy
def SelectionSort(a):
    for i in range(len(a)):
        mini = i
        for j in range(i,len(a)):
            if a[j][1]<a[mini][1]:
                mini = j
        if i != mini:
            tmp = a[i]
            a[i] = a[mini]
            a[mini] = tmp
def BubbleSort(a):
    for i in range(len(a)):
        for j in range(len(a)-1,i,-1):
            if a[j][1]< a[j-1][1]:
                tmp = a[j]
                a[j] = a[j-1]
                a[j-1] = tmp

n = int(input())
a = list(input().split())
item = []
for i in a:
    item.append([i[0],int(i[1])])
a1 = copy.copy(item)
BubbleSort(a1)
ans1 = []
for i in a1:
    s = i[0] + str(i[1])
    ans1.append(s)
print(*ans1)
print("Stable")
a2 = copy.copy(item)
SelectionSort(a2)
ans2 = []
for i in a2:
    s = i[0] + str(i[1])
    ans2.append(s)
print(*ans2)
if ans1 == ans2:
    print("Stable")
else:
    print("Not stable")


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

int main() {
    int N, M;
    cin >> N >> M;
    vector<pair<int, int>> p(N);
    rep(i, N) cin >> p[i].first >> p[i].second;
    sort(p.begin(), p.end());

    priority_queue<int> que;
    int now = 0;

    ll ans = 0;
    for (int cnt = 1; cnt <= M; ++cnt) {
        for (int i = now; i < N; ++i) {
            if (p[i].first <= cnt)
                que.push(p[i].second);
            else {
                now = i;
                break;
            }

            if (i == N - 1)
                now = N;
        }

        if (!que.empty()) {
            ans += que.top();
            que.pop();
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 1660
#pragma GCC optimize(2)
#include <bits/stdc++.h>
using namespace std;
using LL = long long;
using PII = pair<int, int>;
using PLL = pair<LL, LL>;
const LL INF = 1e18;
const int MXN = 100005;
const int MXV = 0;
#define MP make_pair
#define PB push_back
#define EB emplace_back
#define Fi first
#define Se second
#define Be begin()
#define En end()
#define FOR(i, L, R) for (int i = L; i != (int)R; ++i)
#define FORD(i, L, R) for (int i = L; i != (int)R; --i)
#define IOS                                                                    \
    cin.tie(nullptr);                                                          \
    cout.tie(nullptr);                                                         \
    ios_base::sync_with_stdio(false);

bitset<MXN> vis;
vector<int> ans, x;
vector<PII> G[MXN + 1];

int dfs(int u)
{
    vis[u] = true;
    int res = x[u];
    for (auto it : G[u])
    {
        if (!vis[it.Fi])
        {
            int tmp = dfs(it.Fi);
            if (tmp != 0)
            {
                ans.PB(it.Se);
            }
            res ^= tmp;
        }
    }
    return res;
}

int main()
{
    int n, m;
    cin >> n >> m;
    vector<PII> bombs(n), crods(m);
    x.resize(n + 1);
    FOR(i, 0, n) { cin >> bombs[i].Fi >> bombs[i].Se; }
    sort(bombs.Be, bombs.En);
    x[0] = bombs[0].Se;
    FOR(i, 0, n - 1) { x[i + 1] = bombs[i].Se ^ bombs[i + 1].Se; }
    x[n] = bombs[n - 1].Se;

    FOR(i, 0, m)
    {
        int L, R;
        cin >> L >> R;
        L = lower_bound(bombs.Be, bombs.En, PII{L, 0}) - bombs.Be;
        R = upper_bound(bombs.Be, bombs.En, PII{R, 1}) - bombs.Be;
        G[L].EB(R, i + 1);
        G[R].EB(L, i + 1);
    }
    vis.reset();
    FOR(i, 0, n + 1)
    {
        if (vis[i])
        {
            continue;
        }
        if (dfs(i))
        {
            cout << "-1\n";
            return 0;
        }
    }
    cout << ans.size() << '\n';
    sort(ans.Be, ans.En);
    FOR(i, 0, ans.size()) { cout << ans[i] << " \n"[i == (int)ans.size() - 1]; }
}

Measured memory_bytes: 17788
#include <bits/stdc++.h>
using namespace std;
int main(){

  int N,A,B;
  cin >> N >> A >> B;//B-A-1が二人のコマの間にあるマスの数.

  //間のマスが偶数個であればBorysが勝つ.(対合するのがBorysのターンであるから.)奇数個であればAliceのターンで対合するのでAliceが勝つ.
  if((B-A-1) % 2 == 0)cout << "Borys" << endl;
  else cout << "Alice" << endl;

  return 0;
}


Measured memory_bytes: 256
const input=require('fs').readFileSync('/dev/stdin', 'utf8').split(/[\s]/);const nin=()=>{const r = input[0];input.shift();return Number(r)};const nrin=(n)=>{const a:number[]=[];rep(n,()=>a.push(nin()));return a};const sin=()=>{const r = input[0];input.shift();return String(r)};const out=(...a)=>{console.log(...a)};const floor=(a)=>{return Math.floor(a)};const abs=(a)=>{return Math.abs(a)};const min=(...a)=>{return Math.min(...a)};const max=(...a)=>{return Math.max(...a)};const rep=(n, callback)=>{for(let i = 0;i < n; i++){callback()}};const strrep=(s, i, v)=>{return s.slice(0, i)+v+s.slice(i+1);};const permutation=({result=[],pre=[],post,n=post.length})=>{if(n>0){post.forEach((_,i)=>{const rest=[...post];const elem=rest.splice(i, 1);permutation({result, pre: [...pre,...elem],post:rest,n:n-1})})}else{result.push(pre)}return result};const sw=(s,a:any[],op:'=='|'>='|'>'|'<='|'<'='==')=>{for(let i=0;i<a.length;i+=2){if(op==='=='){if(s==a[i])return a[i+1]}else if(op==='>='){if(s>=a[i])return a[i+1]}else if(op==='<='){if(s<=a[i])return a[i+1]}else if(op==='>'){if(s>a[i])return a[i+1]}else if(op==='<'){if(s<a[i])return a[i+1]}}return a[a.length-1];};const or=(a,...b)=>{for(let i=0;i<b.length;i++)if(a==b[i])return true;return false};const maxindex=(...a)=>{return a.indexOf(Math.max.apply(null,a))};const asc=(ar:number[])=>{return ar.sort((a,b)=>{return a-b})};const desc=(ar:number[])=>{return ar.sort((a,b)=>{return b-a})};const ceil=a=>{return Math.ceil(a)};const srin=s=>{const a:string[]=[];rep(s,()=>a.push(sin()));return a};let ssinteger=-1;const ssin=()=>{ssinteger++;return input[0][ssinteger]};
const main = ()=>{
  let[a,b]=nrin(2)
  out(floor(a/500)*500+b>=a?'Yes':'No')
}
main()

Measured memory_bytes: 7372
/**
  * @brief atcoder
  * @author yao
  */
#include <cstdlib>
#include <cstdio>
#include <cctype>
#include <cstring>
#include <utility>
#include <algorithm>
#include <functional>
#include <climits>
#include <map>
#define ft first
#define sd second
#ifdef DBG
#   define dbg_pri(x...) fprintf(stderr,x)
#else
#   define dbg_pri(x...) 0
#   define NDEBUG
#endif //DBG
#include <cassert>

typedef unsigned int uint;
typedef long long int lli;
typedef unsigned long long int ulli;

int mp[32][32];

lli get()
{
    int pow[10] = {1, 10, 100, 1000, 10000, 100000, 1000000, 10000000, 100000000, 1000000000};
    int a,b=0,n=0;
    char c;
    scanf("%d%c", &a, &c);
    if(c == '.') scanf("%d%n", &b, &n);
    return (lli)a*pow[9] + (lli)b*(pow[9-n]);
}

int main()
{
    int n;
    scanf("%d", &n);
    lli ans = 0;
    for(int i=0;i<n;++i)
    {
        lli a = get();
        dbg_pri("poi 1: %d %lld\n", i, a);
        int c2=0, c5=0;
        while(c2<18 && a%2==0) ++c2, a/=2;
        while(c5<18 && a%5==0) ++c5, a/=5;
        for(int i2=18-c2;i2<=18;++i2)for(int i5=18-c5;i5<=18;++i5)
        {
            ans += mp[i2][i5];
        }
        ++mp[c2][c5];
    }
    printf("%lld\n", ans);
    return 0;
}


Measured memory_bytes: 1708
#include <stdio.h>

int main() {
  int n=0, m=0, c=0;
  scanf ("%d %d %d\n", &n, &m, &c);
  int count = 0;
  int b[m];
  for (int i=0; i<m; i++) {
    scanf("%d", b+i);
  }
  int buf = 0;
  int add = 0;
  for (int i=0; i<n; i++) {
    for (int j=0; j<m; j++) {
      scanf("%d", &buf);
      add += buf*b[j];
    }
    add += c;
    if (add > 0) count++;
    add = 0;
  }
  printf("%d\n", count);
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <array>
#include <vector>
#include <iomanip>
#include <string>
#include <cmath>
#include <algorithm>
#include <queue>
#include <map>
#include <set>

using namespace std;

typedef  pair<int,int> P;
typedef long long LL;
typedef vector<LL> VEC;

const LL INF=1<<30;
const LL MOD=1000000007;






int main(){
    	int r,g;
        cin>>r>>g;
        cout<<2*g-r<<endl;
}



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

int yakusuu(int n) {
  int ans = 0;
  for (int i = 1; i * i <= n; i++) {
    if (n % i == 0) ans += 2;
    
    if (n == i * i) ans++;
  }
  
  return ans;
}

  
int main() {
  int N;
  cin >> N;
  
  int ans = 0;
  for (int i = 1; 2 * i - 1<= N; i++) {
    if (yakusuu(2 * i - 1) == 8) {
      ans++;
    }
  }
  
  cout << ans << endl;
  
  
}



Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main()
{
  int min=0,count=0;
  string str;
  cin>>str;
  for(int i=0;i<3;i++){
    if(str[i]=='R'){
      count++;
    }
    else if(str[i]=='S'){
     // min=count;
      count=0;
      continue;
    }
    if(count>min){
      min=count;
    }
  }
  cout<<min<<endl;
  return 0;
}

Measured memory_bytes: 3592
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, a, b) for (int i = a; i < (int)b; i++)
#define all(v) v.begin(), v.end()
const int MOD = 1e9 + 7;
const int INF = 1e9;
//'A' = 65, 'Z' = 90, 'a' = 97, 'z' = 122

int main() {
    string s;
    cin >> s;
    int n = s.size();
    int ans = 0;
    if (n % 2 == 0) {
        rep(i, 0, n / 2) {
            if (s[i] != s[n - 1 - i]) ans++;
        }
    } else {
        rep(i, 0, n / 2) {
            if (s[i] != s[n - 1 - i]) ans++;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#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>;

int INF = 1001001001;

const int di[] = {-1,0,1,0};
const int dj[] = {0,-1,0,1};



int main() {
    int h, w;
    cin >> h >> w;
    vector<string> s(h);
    rep(i,h) cin >> s[i];
    int ans = 0;
    rep(si,h)rep(sj,w) {
        if (s[si][sj] == '#') continue;
        vector<vector<int>> dist(h, vector<int>(w, INF));
        queue<P> q;
        auto update = [&](int i, int j, int x) {
            if (dist[i][j] != INF) return;
            dist[i][j] = x;
            q.push(P(i,j));
        };
        update(si,sj,0);
        while (!q.empty()) {
            int i = q.front().first;
            int j = q.front().second; q.pop();
            rep(dir,4) {
                int ni = i+di[dir], nj = j+dj[dir];
                if (ni<0||ni>=h||nj<0||nj>=w) continue;
                if (s[ni][nj] == '#') continue;
                update(ni, nj, dist[i][j]+1);
            }
        }
        rep(i,h)rep(j,w) {
            if (dist[i][j] == INF) continue;
            ans = max(ans, dist[i][j]);
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3564
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<vector>
#include<stack> 
#include<queue>
#include<cmath>
#include<map>
#include<set>
#define LL long long
#define N 200100
#define MOD 1000000007
#define FOR(i,l,r) for (int i = (l); i <= (r); i ++)
#define CLR(a,x) memset(a,x,sizeof(a))
#define INF 0x7fffffff
#define pb push_back
#define X first
#define Y second
using namespace std;
int main(){
	int x;
	scanf("%d",&x);
	int l = 1,r = x,ma = 0;
	while (l <= r){
		int m = (l + r) / 2;
		if ((LL)(m + 1) * m / 2 >= (LL)x){
			ma = m;
			r = m - 1;
		}
		else l = m + 1;
	}
	printf("%d\n",ma);
}

Measured memory_bytes: 256
#include <algorithm>
#include <assert.h>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <typeinfo>
#include <unordered_map>
#include <utility>
#include <vector>
#define loop(i, a, b) for (int i = a; i < b; i++)
#define rep(i, a) loop(i, 0, a)
#define FOR(i, a) for (auto i : a)
#define pb push_back
#define all(in) in.begin(), in.end()
#define shosu(x) fixed << setprecision(x)
#define show1d(v)                                                              \
  rep(i, v.size()) cout << " " << v[i];                                        \
  cout << endl << endl;
#define show2d(v)                                                              \
  rep(i, v.size()) {                                                           \
    rep(j, v[i].size()) cout << " " << v[i][j];                                \
    cout << endl;                                                              \
  }                                                                            \
  cout << endl;
using namespace std;
typedef long long ll;
typedef int Def;
typedef pair<Def, Def> pii;
typedef vector<Def> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<Def, pii> pip;
typedef vector<pip> vip;
template <typename A, typename B> bool cmin(A &a, const B &b) {
  return a > b ? (a = b, true) : false;
}
template <typename A, typename B> bool cmax(A &a, const B &b) {
  return a < b ? (a = b, true) : false;
}
const double PI = acos(-1);
const double EPS = 1e-9;
Def inf = sizeof(Def) == sizeof(long long) ? 2e18 : 1e9 + 10;
int dx[] = {0, 1, 0, -1};
int dy[] = {1, 0, -1, 0};

int main(int argc, char *argv[]) {
  int n;
  cin >> n;
  vector<ll> s(n);
  rep(i, n) cin >> s[i];
  int q, ans = 0;
  cin >> q;

  rep(i, q) {
    ll t;
    cin >> t;
    auto res = find(s.begin(), s.end(), t);
    if (res != s.end())
      ans++;
  }
  cout << ans << endl;
  return 0;
}



Measured memory_bytes: 3152
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>

using namespace std;

int main()
{
    string s, t;
    cin >> s >> t;
    s = s + s;
    for(int i = 0; i < s.length() / 2; i++)
        //cout << s
        if(t == s.substr(i, s.length() / 2))
            return cout << "Yes", 0;
    cout << "No";
}


Measured memory_bytes: 256
/*input
9
*/
#include <bits/stdc++.h>
#define ll long long int
#define ull unsigned long long
#define mod 1000000007
#define inf 1000000000000000001
#define all(c) c.begin(),c.end()
#define mem(a,val) memset(a,val,sizeof(a))
#define eb emplace_back
#define sz(a) int((a).size())
#define pb push_back
#define tr(c,i) for(typeof((c).begin() i = (c).begin(); i != (c).end(); i++)
#define present(c,x) ((c).find(x) != (c).end())
#define cpresent(c,x) (find(all(c),x) != (c).end())     
#define rep(i,j,n) for(ll i=j;i<n;i++)
#define mp make_pair
#define N 998244353
#define PI acos(-1.0)
//if (s.find('R') != std::string::npos)
//s.replace(s.find("10"), sizeof("10") - 1, "");
using namespace std;
bool comp(pair<string,ll>a,pair<string,ll>b){
  if(a.first==b.first) return a.second>b.second;
  return a.first<b.first;
}
int main()
{
  // added the two lines below 
  ios_base::sync_with_stdio (false); 
  cin.tie(NULL);
  cout.tie(0);
  
  ll n;
  cin>>n;
  ll arr[n];
  rep(i,0,n) cin>>arr[i];
  ll c=1,mx=arr[0];
  for(int i=1;i<n;i++){
    if(mx<=arr[i]) {
      c++;
      mx=arr[i];
    }
  }
  cout<<c;


}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

  public static final int alphabet_num = 'z' - 'a';

  public static void main(String[] args) throws IOException {
    BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
    /*
     String in;
     while ((in = reader.readLine()) != null) {

     }
     */
    int dataNum = Integer.valueOf(reader.readLine());
    for (int i = 0; i < dataNum; i++) {
      String[] in = reader.readLine().split(" ");
      float xA = Float.valueOf(in[0]);
      float yA = Float.valueOf(in[1]);
      float xB = Float.valueOf(in[2]);
      float yB = Float.valueOf(in[3]);
      float xC = Float.valueOf(in[4]);
      float yC = Float.valueOf(in[5]);
      float xD = Float.valueOf(in[6]);
      float yD = Float.valueOf(in[7]);
      float slopeOfLineAtoB = (yB - yA) / (xB - xA);
      float slopeOfLineCtoD = (yD - yC) / (xD - xC);
      if (slopeOfLineAtoB == slopeOfLineCtoD)
        System.out.println("YES");
      else
        System.out.println("NO");
    }
  }

}

Measured memory_bytes: 24472
#include<stdio.h>

int main()
{
	double a, b;
	
	scanf("%lF %lf", &a, &b);
	{
		int x = a, y = b;
		
		printf("%d %d %.5lf\n", x/y, x%y, a/b);
	}	

	return 0;
}



Measured memory_bytes: 2752
#include <iostream>
#include <bits/stdc++.h>
 
#define rep(i,z) for(int i = 0; i<(int)(z); i++)
#define rep1(i,z) for(int i = 1; i<=(int)(z); i++)
 
using namespace std;
 
typedef long long ll;
const ll mod=1e9+7;
 
using pear = pair<int,int>;
 
int main(){
    int n; cin >> n;
    vector<int> h(n),s(n);
    rep(i,n) {
        cin >>h[i];
        if(i > 0 && h[i] <= h[i-1]){
            if(s[i-1] == 0) s[i] = 1;
            else s[i] = s[i-1]+1;
        }
    }
    sort(s.begin(),s.end());
    cout << s[n-1]<<endl;
}

Measured memory_bytes: 1024
//#include <bits/stdc++.h>
#include <string>
#include <iostream>
#include <cstdio>
#include <vector>
#include <cmath>
#include <algorithm>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <utility>
#include <climits>

using namespace std;
using ll=long long;

void solve(){
  while(1){
    int m,mi,ma;
    cin >> m >> mi >> ma;
    if(!(m|mi|ma))return;
    int ar[m];
    for(int i=0;i<m;i++)
      cin >> ar[i];
    int res=0,j=-1;
    for(int i=mi;i<=ma;i++)
      if(res<=ar[i-1]-ar[i])
      {res=ar[i-1]-ar[i];j=i;}
    cout << j << endl;
  }
}

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



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

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

    sort(a.begin(),a.end());
    int ans=n;
    for(int i=0; i<n-1; i++){
        if(a.at(i)==a.at(i+1)){
            ans-=2;
            i+=1;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3792
#include<iostream>
#include <cmath>
#include<vector>
using namespace std;

int main() {
	int N, d[50];
	cin >> N;
	int ans = 0;
	for (int i = 0; i < N; i++) {
		cin >> d[i];
	}
	for (int i = 0; i < N; i++) {
		for (int j = 0; j < N; j++) {
			if (i != j) {
				ans += d[i] * d[j];
			}
		}
		
	}
	ans /= 2;
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
from bisect import bisect_left,bisect_right;N=int(input());A=sorted([int(i) for i in input().split()]);B=[int(i) for i in input().split()];C=sorted([int(i) for i in input().split()]);ans=0
for i in range(N):ans+=bisect_left(A,B[i])*(N-bisect_right(C,B[i]))
print(ans)


Measured memory_bytes: 23616
s = list(str(input()))
flag = True
if s[0] != 'A':
    flag = False

count = 0
for i in range(2,len(s)-1):
    if s[i] == 'C':
        count += 1

if count != 1:
    flag = False

for i in range(len(s)):
    if s[i] == 'A' or s[i] == 'C':
        pass
    else:
        if s[i].islower():
            pass
        else:
            flag = False
if flag:
    print('AC')
else:
    print('WA')


Measured memory_bytes: 3064
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define REP(i,a,b) for (int i = a; i < (b); ++i)
#define all(x) (x).begin(),(x).end()
const int INF = 1000000007;
typedef long long ll;
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
ll lcm(ll a, ll b) { return (a * b) / gcd(a,b); }
ll fac(ll a) { return a > 1 ? fac(a - 1) * a : 1; }
bool echeck(ll a) { return a % 2 == 0 ? 1 : 0; }
ll comb(ll n, ll m){
  ll tmp = 1;
  for(int i = n; i >= n - m + 1; i--){
    tmp *= i;
  }
  ll temp = 1;
  for(int i = 1; i <= m; i++){
    temp *= i;
  }
  return tmp / temp;
}
int main(){
  // ios::sync_with_stdio(false);cin.tie(nullptr);
  ll n,a,b,c,d,e;
  cin >> n >> a >> b >> c >> d >> e;
  cout << max({ (n - 1) / a, (n - 1) / b, (n - 1) / c, (n - 1) / d, (n - 1) / e }) + 5 << endl;
  return 0;
}  

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <sstream>
#include <string>
#define _repargs(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _repargs(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define mod 1000000007
#define inf 2000000007
#define mp make_pair
#define pb push_back
typedef long long ll;
using namespace std;
template <typename T>
inline void output(T a, int p = 0) {
    if(p) cout << fixed << setprecision(p)  << a << "\n";
    else cout << a << "\n";
}
// end of template

int main() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    // source code
    string s;
    ll K;
    cin >> s >> K;
    if (s.size() == 1) {
        output(K / 2);
        return 0;
    }
    bool equal = true;
    rep(i, s.size() - 1) {
        if(s[i] != s[i + 1]) equal = false;
    }
    if(equal) {
        output(K * (ll)s.size() / 2);
        return 0;
    }
    ll one = 0;
    ll cnt = 1;
    rep(i, s.size() - 1) {
        if(s[i] == s[i + 1]) cnt++;
        else {
            one += cnt / 2;
            cnt = 1;
        }
    }
    one += cnt / 2;
    ll two = 0;
    string t = s + s;
    cnt = 1;
    rep(i, t.size() - 1) {
        if(t[i] == t[i + 1]) cnt++;
        else {
            two += cnt / 2;
            cnt = 1;
        }
    }
    two += cnt / 2;
    ll ans = one + (K - 1) * (two - one);
    
    output(ans);
    
    
    
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
#define rep(i,n) for (ll i=0;i<n;++i)
#define rep2(i,a,b) for (ll i=a;i<b;++i)
const ll MOD=1e9+7;
const ll INF=1e9;
const ll IINF=1e18;
const double EPS=1e-8;
const double pi=acos(-1);

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;
}

int main(){
    ll N;
    cin >> N;
    vector<ll> A(N),B(N);
    rep(i,N) cin >> A[i] >> B[i];
    ll m=IINF,ans=0;
    rep(i,N){
        ans+=A[i];
        if (A[i]-B[i]>0) chmin(m,B[i]);
    }
    ans-=m;
    if (m==IINF) ans=0;
    cout << ans << endl;
}

Measured memory_bytes: 512
// #define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
// #include <atcoder/all>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(a) (a).begin(), (a).end()
using namespace std;
// using namespace atcoder;
using ll = long long;
const ll mod = 1e9 + 7;
 
void solve()
{
    int n;
    cin >> n;
    vector<int> a(n), b(n), c(n);
    rep(i, n) cin >> a[i];
    rep(i, n) cin >> b[i];
    rep(i, n) cin >> c[i];
    sort(all(a));
    sort(all(b));
    sort(all(c));
    ll ans = 0;
    rep(i, n)
    {
        int up = lower_bound(all(a), b[i]) - a.begin();
        int lp = upper_bound(all(c), b[i]) - c.begin();
        lp = n - lp;
        ans = ans + (ll)up * lp;
    }
    cout << ans << endl;
}
 
int main()
{
    // srand((unsigned)time(NULL));
    // int t = clock();
    solve();
    // double et = 1.0 * (clock() - t) / CLOCKS_PER_SEC;
    // printf("Execution Time: %.4lf sec\n", et);
    return 0;
}

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

int main() {
  int n,k; cin >> n >> k;
  vector<double> p(n,0); for(int i = 0;i < n;i++) { cin >> p[i]; }
  vector<double> e(n,0); for(int i = 0;i < n;i++) { e[i] = (p[i]+1)/2; }

  double sum=0,max;
  for(int i = 0;i < k;i++) { sum += e[i]; }

  max = sum;
  for(int i = 1;i+(k-1) < n;i++) {
    sum += (e[i+(k-1)] - e[i-1]);
    if(max < sum) { max = sum; }
  }

  //cout << max << endl;
  printf("%.10f\n",max);
  return 0;
}

Measured memory_bytes: 3328
#include<bits/stdc++.h>
using namespace std;
#define INFTY 1<<20
#define rep(i,n) for (ll i = 0; i < (n); ++i)
typedef long long int ll;
using ipair = pair<int,int>;
bool operator< (const ipair a, const ipair b){return a.first < b.first;};
const int MOD=1000000007;

int main(){  
    int x; cin>>x;
    if(x>=30)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    return 0;
}

Measured memory_bytes: 3636
def main(str)
  lines = str.split("\n").map { |x| x.split(' ').map(&:to_i) }
  _n, k = lines[0]
  as = lines[1]
  pluses = as.select { |x| x >= 0 }.sort_by { |x| -x }
  minuses = as.select { |x| x < 0 }.map(&:abs).sort_by { |x| -x }
  if k % 2 == 1
    return -minuses.sort[0...k].inject { |x, m| m = (m * x) % (10 ** 9 + 7)  } if pluses.none?
    ans = pluses.shift
    k -= 1
  else
    ans = 1
  end
  loop do
    ans = ans % (10 ** 9 + 7)
    return ans if k == 0
    return raise if k == 1
    k -= 2
    return ans * pluses.shift * -minuses.shift  if pluses.count == 1 && minuses.count == 1
    if pluses.count < 2
      2.times { ans *= minuses.shift }
      next
    end
    if minuses.count < 2
      2.times { ans *= pluses.shift }
      next
    end
    
    x = pluses[0] * pluses[1]
    y = minuses[0] * minuses[1]
    if x >= y
      2.times { ans *= pluses.shift }
    else
      2.times { ans *= minuses.shift }
    end
  end
end

unless ENV["TEST"]
  puts(main($stdin.read.chomp) % (10 ** 9 + 7))
  exit(0)
end

require 'minitest/autorun'

class TestA < Minitest::Test
  def test_main
    assert_equal(12, main("4 2
-1 -2 -3 -4"))
    assert_equal(12, main("4 2
1 2 -3 -4"))
    assert_equal(-6, main("4 3
-1 -2 -3 -4"))
    assert_equal(24, main("4 4
1 -1 -2 -3 -4"))
    assert_equal(24, main("4 5
1 -1 -2 -3 -4"))
    assert_equal(864, main("4 7
1 -1 -2 -3 -4 3 4 3"))
    assert_equal(1000000000, main("2 1
-1 1000000000"))
    assert_equal(999983200, main("10 10
1000000000 100000000 10000000 1000000 100000 10000 1000 100 10 1"))
  end
end




Measured memory_bytes: 37220
def main():
    A=input()
    N=len(A)
    ans=1
    p={}
    for i,a in enumerate(A):
        if a not in p:
            p[a]=0
        ans+=i-p[a]
        p[a]+=1    
    print(ans)

if __name__ == "__main__":
    main()

Measured memory_bytes: 3500
#include <iostream>
#include <cstdio>
#include <string>
#include <cmath>
#include <algorithm>
#include <cctype>
using namespace std;

int main() {
    int a, b, c, ans;
    cin >> a >> b >> c;
    ans = c < b / a ? c : b / a;
    cout << ans << endl;

}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string>
#include<map>
#include<vector>
#include<set>
using namespace std;
typedef long long ll;
typedef long long int llint;
typedef pair<ll, ll> pa;
#define MM 1000000000
#define MOD MM+7
#define MAX 101000
#define MAP 110
#define initial_value -1
#define MAX_T 1001
#define Pair pair<int,int>
#define chmax(a,b) (a<b ? a=b:0)
#define chmin(a,b) (a>b ? a=b:0)
#define INF (1 << 29) //536870912
const ll DEP = 1e18;
int dx[4] = {-1,0,1,0};
int dy[4] = {0,-1,0,1};
ll n,m;
struct edge{ll from,to,cost;};
vector<edge> es;
ll d[MAX_T];
bool BellmanFord(ll s){
    for(int i = 0; i < n; i++) d[i] = -DEP;
    d[s] = 0;
    for(int i = 0; i < n-1; i++){
        for(int j = 0; j < m; j++){
            edge e = es[j];
            if(d[e.from] != -DEP && d[e.to] < d[e.from] + e.cost){
                d[e.to] = d[e.from] + e.cost;
            }
        }
    }
    ll dn = d[n-1];
    for(int i = 0; i < n; i++){
        for(int j = 0; j < m; j++){
            edge e = es[j];
            if(d[e.to] != -DEP && d[e.to] < d[e.from] + e.cost){
                d[e.to] = d[e.from] + e.cost;
            }
        }
    }
    if(d[n-1] > dn) return 0;
    else return 1;
}
//v = n,e = m;
int main(){
    cin >> n >> m;
    for(int i = 0; i < m; i++){
        ll a,b,c;
        cin >> a >> b >> c;
        a--; b--;
        es.push_back({a,b,c});
    }
    if(BellmanFord(0)) cout << d[n-1] << endl;
    else cout << "inf" << endl;
    return 0;
}



Measured memory_bytes: 384
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair

using namespace std;

const int INF = 2000000000;
const double pi = 3.1415926;
const int base = 1000000007;

double n;

int main()
{
//    ifstream cin ("house.in");
//    ofstream cout ("house.out");
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    cout.precision(25);
    cout.setf(ios_base::fixed);
    cin >> n;
    cout << 2 * pi * n;
    return 0;
}


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

using namespace std;

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

  int a, b;
  cin >> a >> b;

  string u;
  cin >> u;

  if (u == s) a--;
  if (u == t) b--;
  cout << a << " " << b << endl;

  return 0;
}


Measured memory_bytes: 256
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.PrintWriter;

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

    static class ARainySeason {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            String s = in.readString();
            int ans = 0;
            if (s.contains("R"))
                ans = 1;
            if (s.contains("RR"))
                ans = 2;
            if (s.contains("RRR"))
                ans = 3;

            System.out.println(ans);
        }

    }

    static class InputReader {
        private InputStream stream;
        private byte[] buf = new byte[1024];
        private int curChar;
        private int numChars;

        public InputReader(InputStream stream) {
            this.stream = stream;
        }

        public int read() {
            if (numChars == -1)
                throw new RuntimeException();
            if (curChar >= numChars) {
                curChar = 0;
                try {
                    numChars = stream.read(buf);
                } catch (IOException e) {
                    throw new RuntimeException();
                }
                if (numChars <= 0)
                    return -1;
            }
            return buf[curChar++];
        }

        public String readString() {
            final StringBuilder stringBuilder = new StringBuilder();
            int c = read();
            while (isSpaceChar(c))
                c = read();
            do {
                stringBuilder.append((char) c);
                c = read();
            } while (!isSpaceChar(c));
            return stringBuilder.toString();
        }

        public boolean isSpaceChar(int c) {
            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }

    }
}



Measured memory_bytes: 32364
#include <bits/stdc++.h>
#define va first
#define vb second
using namespace std;
typedef pair<int,int> pii;
const int MN = 2e5+5;
const int INF = 1e9;
bool ch;
int main()
{
    ios_base::sync_with_stdio(0),cin.tie(0);
    int H,W,A,B;
    cin >> H >> W >> A >> B;
    if(A<=W/2&&B<=H/2){
        for(int i=0; i<B; i++){
            for(int j=0; j<A; j++) cout << 1;
            for(int j=A; j<W; j++) cout << 0;
            cout << '\n';
        }
        for(int i=B; i<H; i++){
            for(int j=0; j<A; j++) cout << 0;
            for(int j=A; j<W; j++) cout << 1;
            cout << '\n';
        }
    }
    else cout << -1;
}


Measured memory_bytes: 1280
#include <bits/stdc++.h>
using namespace std;
inline void ci(void){
  return;
}
template <typename First, typename... Rest>
void ci(First& first, Rest&... rest){
  cin >> first;
  ci(rest...);
  return;
}
inline void co(void){
  cout << "\n";
  return;
}
template <typename First, typename... Rest>
void co(First first, Rest... rest){
  cout << first << " ";
  co(rest...);
  return;
}
#define ll long long
#define ld long double
#define st string
#define dl double
#define wh while
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define tp tuple
#define ft first
#define sc second
#define ve vector
#define tos to_string
#define len length
#define rt return 0
#define br break
#define con continue
#define lcm(n, m) (n * m / gcd(n, m))
#define np next_permutation
#define repi(i, m, n) for(int i=(int)(m);i<(int)(n);i++)
#define rep(i, n) repi(i, 0, n)
#define repill(i, m, n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define repll(i, n) repill(i, 0, n)
#define revi(i, m, n) for(int i=(int)(m);i>(int)(n);i--)
#define rev(i, n) revi(i, 0, n)
#define revill(i, m, n) for(ll i=(ll)(m);i>(ll)(n);i--)
#define revll(i, n) revill(i, 0, n)
#define sz(v) ((int)(v).size()) 
#define each(i, n) for(auto&& i: n)
#define all(n) (n.begin(), n.end())
#define allr(n) (n.rbegin(), n.rend())
#define sp(n) cout << fixed << setprecision(n)
// sqrt ルート, int 2*10^9, gcd　最大公約数
// __builtin_popcount bitの個数

int main() {
  int a, b;
  ci(a, b);
  if(a * b % 2 == 0){
    co("Even");
  }
  else{
    co("Odd");
  }
}


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

int main(){
	int N;
	cin >> N;
	vector<int> A(N);
	for(int i=0;i<N;i++){
		cin >> A[i];
	}
	vector<int> LMAX(N), RMAX(N);
	LMAX[0] = A[0];
	for(int i=1;i<N;i++){
		LMAX[i] = max(LMAX[i-1], A[i]);
	}
	RMAX[N-1] = A[N-1];
	for(int i=N-2;i>=0;i--){
		RMAX[i] = max(RMAX[i+1], A[i]);
	}
	cout << RMAX[1] << endl;
	for(int i=1;i<N-1;i++){
		cout << max(LMAX[i-1], RMAX[i+1]) << endl;
	}
	cout << LMAX[N-2] << endl;
}

Measured memory_bytes: 3968
#include <iostream>
#include <algorithm>
#include <queue>
#include <vector>
using namespace std;
typedef long long ll;
typedef struct pair<int,int> P;
typedef struct pair<int,P> P2;

const ll INF=1000000000000000001;
int main() {

	string s;
	cin>>s;
	int ls=s.length();
	int m;
	for(m=(ls/2+ls%2);(m<ls)&&(s[m]==s[m-1]);m++);
	int n;
	for(n=ls/2;(n>0)&&(s[n]==s[n-1]);n--);

	cout<<min(m,ls-n)<<endl;
	return 0;
}


Measured memory_bytes: 512
L, A, B, M = map(int, input().split())

ten = 0

def pow_(x, t):
  if t == 0:
    return 1
  if t % 2 == 1:
    return (pow_(x, t - 1) * x) % M
  else:
    y = pow_(x, t // 2)
    return (y * y) % M

def f(l):
  if l == 0:
    return 0
  if l % 2 == 1:
    pl = l - 1
    x = f(pl)
    return x * ten + 1
  else:
    pl = l // 2
    x = f(pl)
    return x * pow_(ten, pl) + x

def g(l):
  if l == 0:
    return 0
  if l % 2 == 1:
    pl = l - 1
    x = g(pl)
    return x * ten + B * pl
  else:
    pl = l // 2
    x = g(pl)
    return x * pow_(ten, pl) + x + B * pl * f(pl)

last = A + B * (L - 1)
ans = 0
ten = 10
for _ in range(18):
  l = ten // 10
  r = ten - 1
  
  if last < l:
    ten *= 10
    continue
  if A > r:
    ten *= 10
    continue
  na = 0 #初項
  nl = 0 #長さ

  if A >= l:
    na = A
  else:
    na = (l - A + B - 1) // B * B + A
    na = min(na, last)
  
  nlast = 0
  if last <= r:
    nlast = last
  else:
    nlast = (r - A) // B * B + A
  nl = (nlast - na) // B + 1

  ans *= pow_(ten, nl) % M
  ans += (na * f(nl)) % M
  ans += g(nl) % M
  ten *= 10

print(ans % M)


Measured memory_bytes: 3064
import sys; input = sys.stdin.buffer.readline
from collections import defaultdict
import queue
con = 10 ** 9 + 7; INF = float("inf")

class Graph(object):
	def __init__(self):
		self.graph = defaultdict(list)

	def __len__(self):
		return len(self.graph)

	def add_edge(self, a, b):
		self.graph[a].append(b)

class BFS(object):
	def __init__(self, graph, s, N):
		self.g = graph.graph
		self.Q = queue.Queue()
		self.Q.put(s)
		self.visit = ["No"] * N
		self.visit[s] = "Yes"
		self.prev = [None] * N
		while not self.Q.empty():
			v = self.Q.get()
			for i in self.g[v]:
				if self.visit[i] == "No":
					self.prev[i] = v
					self.Q.put(i)
					self.visit[i] = "Yes"

def getlist():
	return list(map(int, input().split()))

#処理内容
def main():
	N = int(input())
	G = Graph()
	D = defaultdict(int)
	for i in range(N - 1):
		a, b = sorted(getlist())
		a -= 1; b -= 1
		G.add_edge(a, b)
		G.add_edge(b, a)
		D[10000 * a + b] = i

	M = int(input())
	MbitTable = [0] * (N - 1)
	for i in range(M):
		u, v = getlist()
		u -= 1; v -= 1
		BF = BFS(G, u, N)
		prev = BF.prev
		node = v
		edge = []
		while prev[node] != None:
			a, b = sorted([node, prev[node]])
			edgenum = D[10000 * a + b]
			edge.append(edgenum)
			node = prev[node]

		for j in edge:
			MbitTable[j] += 2 ** i

	DP = [[0] * (2 ** M) for i in range(N)]
	DP[0][0] = 1
	for i in range(N - 1):
		for j in range(2 ** M):
			DP[i + 1][j] += DP[i][j]
			DP[i + 1][j | MbitTable[i]] += DP[i][j]

	print(DP[-1][-1])

if __name__ == '__main__':
	main()

Measured memory_bytes: 446868
a,b,k=map(int, input().split())
c=0
for j in range(max(a,b)):
    i=max(a,b)-j
    #print(i,a % i==0 , b % i==0)
    if a % i==0 and b % i==0:
        c+=1
        if c==k:
            print(i)
            break


Measured memory_bytes: 38384
#pragma GCC optimize("O3", "unroll-loops")

#include <bits/stdc++.h>

using namespace std;

#define ll long long

int main(void){
    int A, B, M; cin >> A >> B >> M;
    vector<int> a(A), b(B);
    for (int i = 0; i < A; ++i) cin >> a[i];
    for (int i = 0; i < B; ++i) cin >> b[i];
    int res = *min_element(a.begin(), a.end()) + *min_element(b.begin(), b.end());
    for (int i = 0; i < M; ++i){
        int x, y, c; cin >> x >> y >> c;
        --x, --y;
        res = min(res, a[x] + b[y] - c);
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 1024
#include<stdio.h>
int dp[2][3001];
int a[3000];
int b[3000];
int max(int a,int b){return a>b?a:b;}
int main(){
	int n,s,t;
	int i,j;
	scanf("%d %d %d",&n,&t,&s);
	for(i=0;i<n;i++)scanf("%d %d",&a[i],&b[i]);
	for(i=0;i<=t;i++){
		dp[0][i]=0;
		dp[1][i]=0;
	}
	for(i=0;i<n;i++){
		for(j=0;j<=t;j++){
			dp[i%2][j]=max(dp[i%2][j],dp[(i+1)%2][j]);
			if(j>=b[i]&&!(j-b[i]<s&&s<j))dp[i%2][j]=max(dp[i%2][j],dp[(i+1)%2][j-b[i]]+a[i]);
		}
		for(j=1;j<=t;j++)dp[i%2][j]=max(dp[i%2][j],dp[i%2][j-1]);
	}
	printf("%d\n",dp[(n-1)%2][t]);
	return 0;
}

Measured memory_bytes: 1072
#include <stdio.h>
#define INF 2100000000
int dist[100][100];
int main(){
	int V,E,i,j,k;
	scanf("%d%d",&V,&E);
	for(i=0;i<V;i++){
		for(j=0;j<i;j++)dist[i][j]=INF;
		dist[i][j++]=0;
		for(;j<V;j++)dist[i][j]=INF;
	}
	for(;E--;)scanf("%d%d%d",&i,&j,&k),dist[i][j]=k;
	for(k=0;k<V;k++)for(i=0;i<V;i++)for(j=0;j<V;j++)
		if(dist[i][k]<INF && dist[k][j]<INF && dist[i][j]>dist[i][k]+dist[k][j])
			dist[i][j]=dist[i][k]+dist[k][j];
	for(i=0;i<V;i++)if(dist[i][i]<0){puts("NEGATIVE CYCLE");return 0;}
	for(i=0;i<V;i++)for(j=0;j<V;j++){
		if(dist[i][j]==INF)printf("INF");
		else printf("%d",dist[i][j]);
		printf(j<V-1?" ":"\n");
	}
	return 0;
}

Measured memory_bytes: 636
#include<iostream>
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<queue>
#include<cstring>
#define rep(i,a,n) for(register int i = a;i <= n;i++)
#define per(i,n,a) for(register int i = n;i >= a;i--)
#define enter putchar('\n')
#define pr pair<int,int>
#define mp make_pair
#define fi first
#define sc second
using namespace std;
typedef long long ll;
const int M = 100005;
const int N = 10000005;
const double INF = 1e13;
 
int read()
{
   int ans = 0,op = 1;
   char ch = getchar();
   while(ch < '0' || ch > '9')
   {
      if(ch == '-') op = -1;
      ch = getchar();
   }
   while(ch >='0' && ch <= '9')
   {
      ans *= 10;
      ans += ch - '0';
      ch = getchar();
   }
   return ans * op;
}

char s[105];

int pos;

int main()
{
    scanf("%s",s+1);
    int l = strlen(s+1);
    rep(i,1,l) if(s[i] == 'C') {pos = i;break;}
    if(!pos) printf("No\n"),exit(0);
    rep(i,pos+1,l) if(s[i] == 'F') printf("Yes\n"),exit(0);
    printf("No\n");
    return 0;
}

Measured memory_bytes: 256
n = int(input())
alst = [int(v) for v in input().split()]
blst = [int(v) for v in input().split()]

buster = 0
rage = 0
for a, b in zip(alst, blst):
    buster += min(a, rage)
    a -= min(a, rage)
    buster += min(a, b)
    if a < b:
        rage = b - a
    else:
        rage = 0
buster += min(alst[-1], rage)

print(buster)


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

#define DEBUG(x) cout << '>' << #x << ':' << x << endl;
#define mem(x,val) memset((x),(val),sizeof(x))
#define all(x) x.begin(),x.end()
#define pb push_back
#define mp make_pair
#define PI acos(-1.0) 
#define MAXN 111111

const int INF = 1 << 29 ;
typedef long long ll ;
typedef pair < int , int > pii ;

int a[MAXN] , k ;

ll get(ll N , int pos = 0){
    if(pos >= k) return N ;
    return get(N-N%a[pos] , pos+1) ;
}

int main() {
    ll lo , hi , mid , l , r , temp ;
    scanf("%d" ,&k) ;
    for(int i = 0 ;i<k ;i++) scanf("%d"  , &a[i]) ;
    temp = *max_element(a , a+k)*1LL*k + 100 ;
    lo = 2 , hi = temp ;

    while(hi>lo) {
        mid = (lo+hi+1)>>1 ;
        if(get(mid) <=2) lo =mid ;
        else hi =mid -1 ;
    }

    r = lo ;lo = 2 ; hi = temp ;

    while(hi>lo) {
        mid = (lo+hi-1)>> 1 ;
        if(get(mid)>=2) hi = mid ;
        else lo = mid + 1 ;
    }
    l = hi ;
    if(l>r) printf("-1\n") ;
    else printf("%lld %lld\n" , l , r) ;
    return 0 ;
}

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

using namespace std;

using int64 = long long;
const int mod = 998244353;

const int64 infll = (1LL << 62) - 1;
const int inf = (1 << 30) - 1;

struct IoSetup {
  IoSetup() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
    cerr << fixed << setprecision(10);
  }
} iosetup;


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

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

template< typename T >
ostream &operator<<(ostream &os, const vector< T > &v) {
  for(int i = 0; i < (int) v.size(); i++) {
    os << v[i] << (i + 1 != v.size() ? " " : "");
  }
  return os;
}

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

template< typename T1, typename T2 >
inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }

template< typename T1, typename T2 >
inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }

template< typename T = int64 >
vector< T > make_v(size_t a) {
  return vector< T >(a);
}

template< typename T, typename... Ts >
auto make_v(size_t a, Ts... ts) {
  return vector< decltype(make_v< T >(ts...)) >(a, make_v< T >(ts...));
}

template< typename T, typename V >
typename enable_if< is_class< T >::value == 0 >::type fill_v(T &t, const V &v) {
  t = v;
}

template< typename T, typename V >
typename enable_if< is_class< T >::value != 0 >::type fill_v(T &t, const V &v) {
  for(auto &e : t) fill_v(e, v);
}

template< typename F >
struct FixPoint : F {
  FixPoint(F &&f) : F(forward< F >(f)) {}

  template< typename... Args >
  decltype(auto) operator()(Args &&... args) const {
    return F::operator()(*this, forward< Args >(args)...);
  }
};

template< typename F >
inline decltype(auto) MFP(F &&f) {
  return FixPoint< F >{forward< F >(f)};
}

int main() {
  int N;
  cin >> N;
  vector< int > A(N);
  cin >> A;
  int ret = 1;
  for(int i = 1; i < N; i++) {
    ret += A[i - 1] >= A[i];
  }
  cout << ret << endl;
  cout << N << endl;
}



Measured memory_bytes: 3368
#include <cstdio>

int main(){
    int i, n, k;
    scanf("%d %d",&n,&k);
    int w[n];
    int p = 0;
    int sum = 0;
    for(i=0;i<n;i++){
        scanf("%d",w+i);
        sum += w[i];
    }
    p = sum / k;
    if(sum%k)p++;
    int p_, k_;
    for(;;p++){
        p_ = 0;
        k_ = 0;
        for(i=0;i<n;i++){
            if(w[i]>p)break;
            else if(p_+w[i]<=p)p_+=w[i];
            else{
                p_ = w[i];
                k_++;
            }
            if(k_>=k)break;
        }
        if(i==n)break;
    }
    printf("%d\n",p);
    return 0;
}



Measured memory_bytes: 3128
h,w,d = map(int,input().split())
a = [list(map(int,input().split())) for _ in range(h)]
dic = {}
q = int(input())

for i in range(h):
    for j in range(w):
        dic[a[i][j]] = i,j

li = [0]*(h*w+1)

for i in range(d+1,h*w+1):
    if i-d not in dic:
        continue
    li[i] = li[i-d] + abs(dic[i][0]-dic[i-d][0]) + abs(dic[i][1]-dic[i-d][1])

for _ in range(q):
    l,r = map(int,input().split())
    print(li[r]-li[l])

Measured memory_bytes: 24976
from bisect import bisect_left
n = int(input())
L = list(map(int,input().split()))
L.sort()
ans =0
for i in range(n):
    for j in range(i+1,n):
        bc = L[i]+L[j]
        a = bisect_left(L,bc)
        ans+= a-j-1
print(ans)


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

bool include3(int n){
	while(n!=0){
		if(n%10==3){
			return true;
		}
		n = n /10;
	}
	return false;
}

void call(int n){
	for(int i = 1; i <= n; i++){
		if( i % 3 == 0 || include3(i) ){
			cout << " " << i;
		}
	}
	cout << endl;
}

int main()
{
	int num;
	cin>>num;
	call(num);
	return 0;
}

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

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

    long long ans = 0;
    for (int i = 1; i <= n-1 ; i++) {
        ans += (n-1) / i;
    }

    cout << ans << endl;
}

Measured memory_bytes: 3632
#include<iostream>
#include<numeric>
#include<math.h>
#include<vector>
#include<algorithm>
#include<set>
#include<map>
#include<queue>
#include<climits>
#define fi first
#define se second
#define pb push_back
#define pii pair<int,int>
#define ll long long
#define mkp make_pair
#define pll pair<ll,ll>
#define rep(i,from,to) for(int i=from;i<to;i++)
#define repd(i,from,till) for(int i=from;i>=till;i--)
#define waste ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define inf 1e9+1
#define mod 1e9+7
#define inf1 1e18+1
#define pie 3.14159265358979323846
#define N 100005
using namespace std;
/*
ll bin(ll i,ll j){
	ll mid=(i+j)/2;
	if(a[mid]==x)reutrn mid;
	else if(ans>x)return bin(i,mid-1);
	else return bin(mid+1,j);
}/*
ll power(ll base,ll power){
    ll res=1;
    base=base%mod;
    while(power>0){
    	if(power&1){
    		res=(res*base)%mod;
		}
		power=power>>1;
		base=(base*base)%mod;
	}
	return res;
}
*/
/*
int nCr(int x, int y){
	if(y>x)return 0;
	int num=fact[x];
	num*=invfact[y];
	num%=mod;
	num*=invfact[x-y];
	num%=mod;
	return num;
}
*/
/*bool prime[n+1];
void SieveOfEratosthenes(int n){
	rep(i,0,n+1)prime[i]=true
    for (int p=2;p*p<=n;p++)
        if (prime[p])
            for (int i=p*p;i<=n;i+=p)prime[i]=false;
}*/
/*
int gcd(int a,int b){
	if(b==0)return a;
	else return gcd(b,a%b);
}
*/
int solve(){
    int n,m;
    cin>>n>>m;
	if(n>=10)cout<<m<<endl;
	else cout<<m+100*(10-n)<<endl;
	return 0;
}
int main(){
    waste;
    int t;
    //cin>>t;
    t=1;
    while(t--){
       	solve();
    }
}


Measured memory_bytes: 256
N = int(input())
D = []

for i in range(N):
    D.append(list(map(int, input().split(" "))))

count = 0
flag = False
for d in D:
    if d[0] == d[1]:
        count += 1
    else:
        count = 0
    if count >= 3:
        flag = True
        break

if flag:
    print("Yes")
else:
    print("No")


Measured memory_bytes: 62312
#include<iostream>
using namespace std;
int k,a,b;
int main()
{
	cin>>k>>a>>b;
	if(b-a<2) return printf("%d\n",k+1),0;
	long long ans=1;
	int tt=min(k,a-1),fl=0;
	ans+=tt;k-=tt;
	tt=k/2,fl=k%2;
	ans+=1ll*tt*(b-a)+fl;
	cout<<ans<<endl;
}


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

using namespace std;

int main(){
    int a, b;
    cin >> a >> b;
    cin.ignore();

    long double ao_min, ao_max; // minは閉区間 maxは開区間
    long double bo_min, bo_max;

    ao_min = a / (long double) 0.08;
    ao_max = (a + 1) / (long double) 0.08;

    bo_min = b / (long double) 0.1;
    bo_max = (b + 1) / (long double ) 0.1;

    int ao_min_d = ceil(ao_min);
    int bo_min_d = ceil(bo_min);

    int ans_min = (ao_min_d < bo_min_d) ? bo_min_d : ao_min_d; // 大きい方が下限(閉区間)
    int ans_max = (ao_max   < bo_max  ) ? ao_max   : bo_max;   // 小さい方が上限(開区間)

    if(ans_min < ans_max){
        cout << ans_min << endl;
        return 0;
    } else {
        cout << "-1" << endl;
        return 0;
    }
    return 0;
}

Measured memory_bytes: 256