akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;
typedef long long int ll;
typedef pair<int, int> ii;
#define DEBUG freopen("in.txt", "r", stdin);

struct fastio {
    fastio() {
        ios::sync_with_stdio(false);
        cout << setprecision(10) << fixed;
        cin.tie(0);
    }
};

fastio _fast_io;

const int N = 1e5 + 5;
int n, m, k, ans;

string s;
int main() {
    cin >> s;
    int n = s.length();
    string ans;
    for (int i = 0; i < n; ++i) {
        if (s[i] != 'B') {
            ans.push_back(s[i]);
        } else {
            if (!ans.empty())
                ans.pop_back();
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3620
#include<iostream>
#include<string>
#include<algorithm>
#include<math.h>
#include<queue>
#include<vector>
#include<map>
#include<cstdlib>



using namespace std;

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

string s;
int n;

int main(){
    cin >> n;
    cin >> s;
    int m;
    char a;
    rep(i,s.size()){
        rep(j,n){
            if(s[i] == 'Z'){
                s[i] = 'A';
            }
            else s[i] = s[i] + 1;
        }
    }
    cout << s << endl;



    return 0;
}

Measured memory_bytes: 3616
#include <iostream>
#include <vector>
#include <algorithm>
#define rep(i, n) for(int i = 0; i < (int)(n); ++i)
#define REP(i, n) for(int i = 1; i < (int)(n); ++i)
using namespace std;

int main() {
    long long N;
    cin >> N;
    
    vector<long long> D;
    for (long long i = 1; i * i <= N; ++i) {
        if (N % i == 0) {
            D.push_back(i);
            if (N / i != i) D.push_back(N / i);
        }
    }
    long long ans = 0;
    for (long long d : D) {
        long long m = N / d - 1;
        if (d < m) ans += m;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 384
n = int(input())
h = list(map(int, input().split()))
dp = [float('inf')] * n
dp[0] = 0

for i in range(n - 1):
    if i <= n - 3:
        dp[i + 1] = min(dp[i + 1], dp[i] + abs(h[i] - h[i + 1]))
        dp[i + 2] = min(dp[i + 2], dp[i] + abs(h[i] - h[i + 2]))
    elif i == n - 2:
        dp[i + 1] = min(dp[i + 1], dp[i] + abs(h[i] - h[i + 1]))

print(dp[-1])


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

#include <cstdlib>  // abs() for integer 絶対値求めやつ

#include <cmath>    // abs() for float, and fabs()

#include <algorithm>
#include <vector>
#define rep(i,n) for(int i = 0; i< (n);i++)

#define SORT(a) sort((a).begin(),(a).end());

#define che(a,string) cout<<string<<":"<<(a)<<endl;

#define ch(a,string) cout<<string<<":"<<(a)<<" ";

using namespace std;

typedef pair<int,int> P;

int main(){
		int n ;cin>>n;
		if(n<1200){
		  cout << "ABC"<<endl;
		  }
		  else if(1200<=n&&n<2800) {
			cout<<"ARC"<<endl;
			}
		else{
			cout<<"AGC"<<endl;
		  }
	  }



Measured memory_bytes: 256
import java.util.Scanner

object Main extends App {
  val sc = new Scanner(System.in)

  val n  = sc.nextInt
  val k  = sc.nextInt
  val xl = List.fill(n)(sc.nextInt)


  val res = xl.foldLeft(0){(sum, x) =>
    sum + Math.min(x, k - x) * 2
  }

  println(res)
}

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

int main(){
  int n, m;
  cin >> n >> m;
  int h[n], ans[n];
  for(int i=0;i<n;i++){
    cin >> h[i];
    ans[i]=1;
    //cout << h[i]<< endl;
  }
  for(int i=0;i<m;i++){
    int x, y;
    cin >> x >> y;
    x-=1;
    y-=1;
    //cout << x << y <<endl;
    if(h[x]>h[y]){
      ans[y]=0;
    }else if(h[x]<h[y]){
      ans[x]=0;
    }else{
      ans[x]=0;
      ans[y]=0;
    }
  }
  int count=0;
  for(int i=0;i<n;i++){
    if(ans[i]==1){
      count+=1;
    }
    //cout << ans[i] << endl;
  }
  cout << count << endl;
}

Measured memory_bytes: 4400
K, N = map(int, input().split())
Alist = sorted(list(map(int, input().split())))
minus = 0
old = Alist[0]
for a in Alist[1:]:
    minus = max(minus, a - old)
    old = a
minus = max(minus, (K - a) + Alist[0])
print(K - minus)


Measured memory_bytes: 25964
#include<iostream>
#include<complex>
#include<vector>
#include<algorithm>
#include<cmath>
using namespace std;

#define REP(i,a,b) for(i=a; i<b; ++i)
#define rep(i,n) REP(i,0,n)
const double EPS = 1e-10;
const double INF = 1e12;

typedef complex<double> P;

namespace std {
  bool operator<(const P &a, const P &b) {
    return real(a) != real(b) ? real(a) < real(b) : imag(a) < imag(b);
  }
}

double cross(const P &a, const P &b) {
  return imag(conj(a)*b);
}

//inner product
double dot(const P &a, const P &b) {
  return real(conj(a)*b);
}

//line
struct L : public vector<P> {
  L(const P &a, const P &b) {
    push_back(a);
    push_back(b);
  }
};

int ccw(P a, P b, P c) {
  b -= a;
  c -= a;
  if( cross(b, c) > 0 ) return +1; // counter clockwise
  if( cross(b, c) < 0 ) return -1; // clockwise
  if( dot(b, c) < 0 ) return +2;   // c--a--b on line
  if( norm(b) < norm(c) ) return -2; // a--b--c on line
  return 0;
}

bool intersectSS(const L &s, const L &t) {
  return ccw(s[0],s[1],t[0]) * ccw(s[0],s[1],t[1]) <= 0 &&
         ccw(t[0],t[1],s[0]) * ccw(t[0],t[1],s[1]) <= 0;
}

P intersection_ls(P a1, P a2, P b1, P b2) {
  P b = b2-b1;
  double d1 = abs(cross(b, a1-b1));
  double d2 = abs(cross(b, a2-b1));
  double t = d1 / (d1 + d2);
  return a1 + (a2-a1) * t;
}

bool ontheline(const P &p) {
  if( abs(real(p)-100) < EPS || abs(real(p)+100) < EPS ||
      abs(imag(p)-100) < EPS || abs(imag(p)+100) < EPS) return true;
  return false;
}

int main() {
  int n,xa,xb,ya,yb,i,j;
  while(cin>>n, n) {
    vector<L> in;
    rep(i,n) {
      cin>>xa>>ya>>xb>>yb;
      in.push_back(L(P(xa,ya),P(xb,yb)));
    }

    int res = 2;
    vector<P> cr;
    for(int i=1; i<n; ++i) {
      cr.clear();
      rep(j,i) {
	if(intersectSS(in[j],in[i]))
	  cr.push_back(intersection_ls(in[j][0],in[j][1],
				       in[i][0],in[i][1]));
      }
      sort(cr.begin(),cr.end());

      int r = 1;
      if(!cr.empty()) {
	for(int j=0; j<cr.size(); ++j) {
	  if(j < cr.size()-1 && abs(cr[j]-cr[j+1]) < EPS) continue;
	  if(ontheline(cr[j])) continue;
	  r++;
	}
      }
      res += r;
    }
    cout<<res<<endl;
  }
}

Measured memory_bytes: 952
#include<iostream>
#include<math.h>
#include<iomanip>
using namespace std;

int main(){

  double a,b,S,L,h;
  double rad;
  double c;


  cin >> a >> b >> c;

  rad = c/180*M_PI;

  S = (a*b*sin(rad))/2;
  L = a + b + sqrt(pow(a,2)+pow(b,2)-2*a*b*cos(rad));
  h = 2*S/a;

  cout << fixed << (a*b*sin(rad))/2 << endl << L << endl << h << endl;


  return 0;
}

Measured memory_bytes: 3564
#include <bits/stdc++.h>
using namespace std;
int n,m,k,cnt,s[301],ans[301][301];
char a[301][301];
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
#ifdef LOCAL
    freopen("test.inp","r",stdin);
    freopen("test.out","w",stdout);
#endif // LOCAL
    cin>>n>>m>>k;
    for(int i=1;i<=n;i++)
        for(int j=1;j<=m;j++)
        {
            cin>>a[i][j];
            if(a[i][j]=='#') s[i]++;
        }
    cnt=1;
    for(int i=1;i<=n;i++)
    {
        if(s[i]==0)
        {
            for(int j=1;j<=m;j++)
                ans[i][j]=ans[i-1][j];
        }
        else
            for(int j=1;j<=m;j++)
            {
                if(s[i]>0) ans[i][j]=cnt;
                else ans[i][j]=cnt-1;
                if(a[i][j]=='#')
                {
                    cnt++;
                    s[i]--;
                }
            }
    }
    for(int i=n-1;i>=1;i--)
        for(int j=1;j<=m;j++)
            if(ans[i][j]==0)
                ans[i][j]=ans[i+1][j];
    for(int i=1;i<=n;i++)
    {
        for(int j=1;j<=m;j++)
            cout<<ans[i][j]<<' ';
        cout<<"\n";
    }
}




Measured memory_bytes: 1280
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#define MAX(a,b) (a > b) ? a : b
#define MIN(a,b) (a < b) ? a : b
const int inf = 1000000000; // 10^9

int main(){
   char s[101];scanf("%s",s);
   printf("%c%d%c\n",s[0],strlen(s)-2,s[strlen(s)-1]);
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
int main(){
  int l,r,d,ans=0;
  cin>>l>>r>>d;
  for(int i=l;i<=r;i++){
    if(i%d==0)
      ans++;
  }
  cout<<ans<<"\n";
  return 0;
}

Measured memory_bytes: 3620
n1 = int(input())
l1 = list(map(int,input().split()))
sum_costs = []

for p in range(min(l1), max(l1)+1):
    sum_cost = 0
    for i in range(n1):
        a_cost = (l1[i] - p) ** 2
        sum_cost = sum_cost + a_cost
    sum_costs.append(sum_cost)

print(min(sum_costs))

Measured memory_bytes: 3060
// #include <bits/stdc++.h>
#include<climits>
#include<cmath>
#include<cstdio>
#include<deque>
#include<map>
#include<set>
#include<vector>
#include<iostream>
#include<sstream>
#include<algorithm>
#include<numeric>
#include<string>
#include<tuple>
using namespace std;
// #include <boost/multiprecision/cpp_int.hpp>
// using namespace boost::multiprecision;
#define BEGIN ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define END return EXIT_SUCCESS
#define rep(I,N) for(auto I=0;I<(N);++I)
#define up(I,A,B) for(auto I=(A);I<=(B);++I)
#define dw(I,A,B) for(auto I=(A);I>=(B);--I)
#define all(C) (C).begin(),(C).end()
#define rall(C) (C).rbegin(),(C).rend()
#define ft first
#define sd second
#define mp make_pair
#define mt make_tuple
#define pf push_front
#define pb push_back
#define pt pop_front
#define pk pop_back
#define lb lower_bound
#define ub upper_bound
#define rs resize
template<class T>inline bool chmax(T& a,T b){if(a<b){a=b;return true;}return false;}
template<class T>inline bool chmin(T& a,T b){if(a>b){a=b;return true;}return false;}
template<class T>inline void                                      in(T &p){cin>>p;}
template<class T1,class T2>inline void                            in(T1 &p1,T2 &p2){cin>>p1>>p2;}
template<class T1,class T2,class T3>inline void                   in(T1 &p1,T2 &p2,T3 &p3){cin>>p1>>p2>>p3;}
template<class T1,class T2,class T3,class T4>inline void          in(T1 &p1,T2 &p2,T3 &p3,T4 &p4){cin>>p1>>p2>>p3>>p4;}
template<class T1,class T2,class T3,class T4,class T5>inline void in(T1 &p1,T2 &p2,T3 &p3,T4 &p4,T5 &p5){cin>>p1>>p2>>p3>>p4>>p5;}
template<class T>inline void                             out(T p){cout<<p<<endl;}
template<class T1,class T2>inline void                   out(T1 p1,T2 p2){cout<<p1<<" "<<p2<<endl;}
template<class T1,class T2,class T3>inline void          out(T1 p1,T2 p2,T3 p3){cout<<p1<<" "<<p2<<" "<<p3<<endl;}
template<class T1,class T2,class T3,class T4>inline void out(T1 p1,T2 p2,T3 p3,T4 p4){cout<<p1<<" "<<p2<<" "<<p3<<" "<<p4<<endl;}

inline void solve(void){
  int N;
  in(N);
  int a;
  map<int,int>m;
  rep(i,N){
    in(a);
    m[i+1]=a;
  }
  int cnt=0;
  rep(i,N){
    if(i+1==m[m[i+1]])cnt++;
  }
  out(cnt/2);
}
int main(int argc,char**argv){
  BEGIN;
  solve();
  END;
}


Measured memory_bytes: 4992
//kkc
#include <iostream>
#include <bits/stdc++.h>
#include <cmath>
#include <math.h> 
#include <stdio.h> 
#define ll long  long
#define ld long double
#define vi vector <ll>
#define mod 1000000007
#define max_char 128
#define pb push_back
#define ff first
#define ss second
#define mp make_pair
#define lbd lower_bound
#define ubd upper_bound
#define PI 3.141592653589793238
#define pf push_front
#define all(x) x.begin(),x.end()
#define FOR(i, a, b)    for(int i=a; i<b; i++)
#define rep(i,a,n) for( ll i=a ; i<n ; i++)
#define mems(x, y) memset(x, y, sizeof(x))
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;
/*

*/


void solve(){
    ll d,t,s;
    cin>>d>>t>>s;
    ld x = (d*1.0)/(s*1.0);
    if(d==0){
        cout<<"Yes\n";
        return;
    }
    if(x<=t){
        cout<<"Yes\n";
    }
    else
    {
        cout<<"No\n";
    }
    
    
}



int main(){
    fastio
    int t=1;
    // cin>>t;
    
    // freopen("input.txt", "r", stdin); 
    // freopen("output.txt", "w", stdout); 
    while(t--){  
        solve();
    }return 0;
}

Measured memory_bytes: 3616
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Buttons
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] buttons = Console.ReadLine().Split(' ');
            int[] num = buttons.Select(int.Parse).ToArray();
            int sum = 0;
            int n1 = 0;
            for(int n = 0; n <= 1; ++n)
            {
                int c = num.Max();
                sum += c;
                if (c == num[n1])
                {
                    num[n1] -= 1;
                }
                else
                {
                    num[n1 + 1] -= 1;
                }
                
            }
            Console.WriteLine(sum);
        }
    }
}


Measured memory_bytes: 13396
#include <string>
#include <queue>
#include <stack>
#include <vector>
#include <sstream>
#include <algorithm>
#include <deque>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <list>
#include <cstdio>
#include <iostream>
#include <cmath>
#include <climits>
#include <bitset>
#include <functional>
#include <numeric>
#include <ctime>
#include <cassert>
#include <cstring>
#include <fstream>
#include <iomanip>

using namespace std;

#define FOR(i, a, b) for(int (i)=(a);(i)<(b);(i)++)
#define IFOR(i, a, b) for(int (i)=(a);(i)<=(b);(i)++)
#define RFOR(i, a, b) for(int (i)=(a);(i)>=(b);(i)--)
#define REP(i, n) FOR((i), 0, (n))

using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

template<class T>
void print_container(T &container, string delim=" ") {
    bool first = true;
    for(auto &t: container){
        if(!first){
            cout << delim;
        }
        first = false;
        cout << t;
    }
    cout << endl;
}

vector<int> getnum(int x){
    vector<int> t;
    if(x / 10 == 0){
        t.push_back(0);
        t.push_back(0);
        t.push_back(x);
    }
    else if(x / 100 == 0){
        t.push_back(0);
        t.push_back(x / 10);
        t.push_back(x % 10);
    }
    else{
        t.push_back(x / 100);
        t.push_back((x%100) / 10);
        t.push_back(x % 10);
    }
    return t;
}
int main() {
    int n;
    cin >> n;
    string s;
    cin >> s;

    int ans = 0;
    IFOR(i, 0, 999){
        auto nums = getnum(i);
        int now = 0;
        REP(j, n){
            if(s[j]-'0' == nums[now])
                now++;
            if(now == 3)
                break;
        }
        if(now == 3)
            ans++;
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
def gcd(a,b):
    if b==0:
        return a
    else:
        return gcd(b,a%b)
def solve():
    n,x = map(int,input().split())
    l = list(map(int,input().split()))
    d = abs(x-l[0])
    for i in range(1,n):
        d = gcd(d,abs(x-l[i]))
    print(d)
if __name__=='__main__':
    solve()

Measured memory_bytes: 14252
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstring>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
typedef double db;

#define fr first
#define sc second
#define pb push_back
#define rep(i,x) for(ll i=0;i<x;i++)
#define rep1(i,x) for(ll i=1;i<=x;i++)
#define rrep(i,x) for(ll i=x-1;i>=0;i--)
#define rrep1(i,x) for(ll i=x;i>0;i--)
ll dp[2001];//?????????????????????????????????
ll n,k,c[2001],g[2001];
vector<ll> v[10];
ll dummy[2][2001];
int main()
{
	cin>>n>>k;
	rep(i,n){
		cin>>c[i]>>g[i];
		g[i]--;
		v[g[i]].pb(c[i]);
	}
	
	//puts("a");
	
	rep(i,10) if(v[i].size()){
		sort(v[i].begin(),v[i].end(),[](const ll& a,const ll& b){
									return a>b;
		});
		rep(j,v[i].size()){
			if(j>0) v[i][j]+=v[i][j-1];
		}
	}
	memset(dummy,0,sizeof(dummy));
	ll *next=dummy[0];
	ll *prev=dummy[1];
	/*rep(i,3){
		rep(j,v[i].size()){
			cout<<v[i][j]<<endl;
		}
	}*/
	rep(i,10){
		rep(j,k+1) next[j]=prev[j];
		rep(j,v[i].size()){//j+1????????°
			rep(f,k-j){
				next[f+j+1]=max(next[f+j+1],prev[f]+v[i][j]+(j+1)*j);
			}
		}
		swap(prev,next);
	}
	ll ans=0;
	rep(i,k+1){
		ans=max(ans,prev[i]);
	}
	cout<<ans<<endl;
	
	/*
	rep(i,10){
		if(!v[i].size()) continue;
		ll cnt=0;
		rrep(j,v[i].size()){
			if(j+1<v[i].size()) v[i][j]+=v[i][j+1];
			p.pb(P(v[i][j]+cnt,cnt+1));
			cnt++;
		}
	}
	puts("a");
	memset(dp,0,sizeof(dp));
	rep(i,p.size()){
		rrep(j,k-p[i].sc+1){
			dp[j+p[i].sc]=max(dp[j+p[i].sc],dp[j]+p[i].fr);
		}
	}
	puts("a");
	ll ans=0;
	rep(i,k+1){
		ans=max(dp[i],ans);
	}
	cout<<ans<<endl;
	//*/
}

Measured memory_bytes: 3212
#include <iostream>
#include <iomanip>
#include <cmath>
#include <string>
#include <vector>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <queue>
#include <numeric>
#include <random>
#include <algorithm>
#include <functional>
#include <cassert>

using namespace std;
typedef long long ll;

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 int INF = (1 << 30) - 1;
const ll INFLL= (1LL << 61) - 1;
const int MOD = 1000000007;
#define ALL(a) (a).begin(),(a).end()
#define rALL(a) (a).rbegin(),(a).rend()
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)

template<int Modulo = MOD>
struct Mint {
	ll val;
	constexpr Mint(ll v = 0) noexcept : val(v % Modulo) { if (val < 0) val += Modulo; }

	constexpr Mint& operator += (const Mint &r) noexcept {
		val += r.val;
		if (val >= Modulo) val -= Modulo;
		return *this;
	}
	constexpr Mint& operator -= (const Mint &r) noexcept {
		val -= r.val;
		if (val < 0) val += Modulo;
		return *this;
	}
	constexpr Mint& operator *= (const Mint &r) noexcept {
		val = val * r.val % Modulo;
		return *this;
	}
	constexpr Mint& operator /= (const Mint &r) noexcept {
		ll a = r.val, b = Modulo, u = 1, v = 0;
		while (b) {
			ll t = a / b;
			a -= t * b; swap(a, b);
			u -= t * v; swap(u, v);
		}
		val = val * u % Modulo;
		if (val < 0) val += Modulo;
		return *this;
	}

	constexpr Mint operator + (const Mint &r) const noexcept { return Mint(*this) += r; }
	constexpr Mint operator - (const Mint &r) const noexcept { return Mint(*this) -= r; }
	constexpr Mint operator * (const Mint &r) const noexcept { return Mint(*this) *= r; }
	constexpr Mint operator / (const Mint &r) const noexcept { return Mint(*this) /= r; }

	constexpr int getmod() { return Modulo; }
	constexpr Mint operator - () const noexcept { return val ? Modulo - val : 0; }

	constexpr bool operator == (const Mint &r) const noexcept { return val == r.val; }
	constexpr bool operator != (const Mint &r) const noexcept { return val != r.val; }

	friend ostream &operator << (ostream &os, const Mint<Modulo> &x) noexcept { return os << x.val; }
	friend istream &operator >> (istream &is, Mint<Modulo> &x) noexcept {
		ll tmp; is >> tmp;
		x = Mint(tmp);
		return is;
	}

	constexpr Mint pow(ll n) noexcept {
		Mint res{ 1 }, tmp{ val };
		while (n > 0) {
			if (n & 1) res *= tmp;
			tmp *= tmp;
			n >>= 1;
		}
		return res;
	}
};
using mint = Mint<>;

int MAX=510000;
vector<mint>fac(MAX),finv(MAX),inv(MAX);
void COMinit() {
  fac[0]=fac[1]=finv[0]=finv[1]=inv[1]=(mint)1;
  FOR(i,2,MAX){
    fac[i]=fac[i-1]*i;
    inv[i]=-inv[MOD%i]*(MOD/i);
    finv[i]=finv[i-1]*inv[i];
  }
}

mint COM(int N,int K){
  if(N<K || N<0 || K<0) return 0;
  return fac[N]*(finv[K]*finv[N-K]);
}

int main(){
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  int H,W,A,B;
  cin>>H>>W>>A>>B;
  COMinit();
  mint ans=0;
  FOR(i,B,W){
    ans+=COM(H-A-1+i,i)*COM(A+W-i-2,W-i-1);
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 12288
(loop with a = (read)
   with b = (read)
   repeat (read)
   with as = (make-sequence 'vector a)
   with bs = (make-sequence 'vector b)
   with a-min = (loop for i upto (1- a) for x = (read) do (setf (elt as i) x) minimize x)
   with b-min = (loop for i upto (1- b) for x = (read) do (setf (elt bs i) x) minimize x)
   minimize (- (+ (elt as (1- (read))) (elt bs (1- (read)))) (read)) into r
   finally (format t "~d~%" (min r (+ a-min b-min))))

Measured memory_bytes: 61696
A , B , C = map(int, input().split())
a = [A, B, C]

ct = 0
while True:
    if a.count(max(a)) == 3:
        break
    if max(a) == min(a) + 1 and a.count(max(a)) == 1:
        ct += 1
        break
    tmp = min(a)
    tmp += 2
    a.remove(min(a))
    a.append(tmp)
    ct += 1
print(ct)


Measured memory_bytes: 3060
#include<bits/stdc++.h>
#define ll long long int
#define ld long double
#define inf LLONG_MAX>>2
#define MAX 1000000
#define mod 1000000007
#define pb push_back
#define f(i,a,n,x) for ((i)=(a);(i)<(n);(i)+=(x))
#define fd(i,a,n,x) for ((i)=(a);(i)>=(n);(i)-=(x))
#define fi first
#define se second
#define mk make_pair
#define pi pair
#define vt vector
using namespace std;
void read(vt<ll> &a,ll n){ll i,temp;f(i,0,n,1){cin>>temp;a.pb(temp);}}
void solve(){
    ll n,i,ans;
    bool flag;
    string s1,s2;
    cin>>n>>s1>>s2;
    if (s1[0]==s2[0]){
        ans=3;
        i=1;
        flag=true;
    }
    else{
        ans=6;
        i=2;
        flag=false;
    }
    for (;i<n;)
        if (flag && s1[i]==s2[i]){
            ans=(ans*2)%mod;
            flag=true;
            i++;
        }
        else if (flag && s1[i]==s1[i+1]){
            ans=(ans*2)%mod;
            flag=false;
            i+=2;
        }
        else if (s1[i]==s2[i]){
            flag=true;
            i++;
        }
        else{
            flag=false;
            ans=(ans*3)%mod;
            i+=2;
        }
    cout<<ans<<endl;
}
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll t=1;
    //cin>>t;
    while(t--)
        solve();
    return 0;
}

Measured memory_bytes: 3636
#include<algorithm>
#include<complex>
#include<ctype.h>
#include<iomanip>
#include<iostream>
#include<map>
#include<math.h>
#include<numeric>
#include<queue>
#include<set>
#include<stack>
#include<stdio.h>
#include<string>
#include<string>
#include<vector>

using namespace std;
typedef long long ll;

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define ALL(v) (v).begin(), (v).end()
#define p(s) cout<<(s)<<endl
#define p2(s, t) cout << (s) << " " << (t) << endl
#define pn(s) cout << (#s) << " " << (s) << endl
#define p_yes() p("Yes")
#define p_no() p("No")

const ll mod = 1e9 + 7;
const ll inf = 1e18;

template < typename T >
void vprint(T &V){
	for(auto v : V){
    	cout << v << " ";
	}
	cout << endl;
}

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

    // input
    int N;
    cin >> N;

    string s1, s2;
    cin >> s1 >> s2;

    vector<char> C;

    // 左から順に、縦型か横型かだけを見ていく
    int i = 0;
    while(i < N){
        if(s1[i]==s2[i]){
            C.push_back('V');
            i++;
        }
        else{
            C.push_back('H');
            i+=2;
        }
    }

    // vprint(C);
    ll answer;
    if(C[0]=='V'){
        answer = 3;
    }else{
        answer = 6;
    }
    FOR(i, 1, C.size()){
        char prev = C[i-1];
        if(prev == 'V'){
            if(C[i]=='V'){
                answer *= 2;
                answer %= mod;
            }else{
                answer *= 2;
                answer %= mod;
            }
        }
        // prev == 'H'
        else{
            if(C[i]=='V'){
                answer *= 1;
            }else{
                answer *= 3;
                answer %= mod;
            }
        }
    }

    p(answer);
    
    return 0;
}

Measured memory_bytes: 256
program example
	implicit none

	integer(8) :: N,wa=0,i
    
    read(*,*) N
    
    do i=1,N
    
    	if(mod(i,3)==0 .or. mod(i,5)==0) then
           goto 1
        else
        	wa=wa+i
        end if      
    
    1 end do


    write(*,*) wa
end program example


Measured memory_bytes: 2792
def nikkei19q_b():
    _ = int(input())
    D = list(map(int, input().split()))
    div = 998244353

    dmax = max(D)
    cntr = [0] * (dmax + 1)
    for d in D: cntr[d] += 1  # カウンター

    if D[0] != 0: return 0  # 最初に入力される頂点1は距離0マスト
    if cntr[0] != 1: return 0  # 距離0が無い、または2つ以上、はおかしい

    ans = 1
    for i in range(1, dmax+1):
        if cntr[i] == 0: return 0  # カウント0だとつながらないのでNG
        ans = ans * (cntr[i-1] ** cntr[i]) % div
    return ans

print(nikkei19q_b())

Measured memory_bytes: 13908
#include<iostream>

using namespace std;

int main(){
    int K,S,z,count=0;
    cin>>K>>S;
        for(int i=0;i<=K;++i){
            for(int j=0;j<=K;++j){
                z=S-i-j;
                if(z>=0&&z<=K)count++;
            }
        }
    cout<<count;
}


Measured memory_bytes: 3160
#include <algorithm>
#include <iostream>
#include <cstdio>
#include <cctype>
#include <queue>
#include <set>

using namespace std;

typedef pair<int,int> P;

#define mkp(a,b) make_pair(a,b)
#define ft first
#define sd second

inline int read()
{
	int x=0,f=1;
	char ch=getchar();
	while (!isdigit(ch)) f=ch=='-'?-1:f,ch=getchar();
	while (isdigit(ch)) x=x*10+ch-'0',ch=getchar();
	return x*f;
}

const int N=100005;

set<int> edge[N];
int fa[N];
int n,tot;

int getfather(int son){return fa[son]==son?son:fa[son]=getfather(fa[son]);}

void merge(int x,int y)
{
	x=getfather(x),y=getfather(y);
	if (x==y) return;
	++tot;
	edge[x].erase(y),edge[y].erase(x);
	if (edge[x].size()<edge[y].size()) swap(x,y);
	fa[y]=x;
	queue<P> q;
	for (set<int>::iterator it=edge[y].begin();it!=edge[y].end();++it)
	{
		edge[*it].erase(y);
		if (edge[*it].find(x)==edge[*it].end()) edge[*it].insert(x);
		else q.push(mkp(*it,x));
		if (edge[x].find(*it)==edge[x].end()) edge[x].insert(*it);
		else q.push(mkp(x,*it));
	}
	edge[y].clear();
	for (;!q.empty();q.pop()) merge(q.front().ft,q.front().sd);
}

int main()
{
	//freopen("brt.in","r",stdin),freopen("brt.out","w",stdout);
	n=read();
	for (int i=1;i<=n;++i) fa[i]=i;
	tot=0;
	for (int i=1,x,y;i<=(n-1<<1);++i)
	{
		x=getfather(read()),y=getfather(read());
		if (edge[x].find(y)==edge[x].end()) edge[x].insert(y);
		else merge(x,y);
		if (edge[y].find(x)==edge[y].end()) edge[y].insert(x);
		else merge(y,x);
	}
	printf(tot==n-1?"YES\n":"NO\n");
	//fclose(stdin),fclose(stdout);
	return 0;
}

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

#define F first
#define S second

using namespace std;

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

const int N = 1010, M = 20010;

int n, m;
int a[N], b[N];
int f[M];

int main()
{
	scanf("%d%d", &m, &n);
	for (int i = 1; i <= n; i ++ ) scanf("%d%d", &a[i], &b[i]);

	memset(f, 0x3f, sizeof f);
	f[0] = 0;

	for (int i = 1; i <= n; i ++ )
		for (int j = a[i]; j <= m + a[i]; j ++ )
			f[j] = min(f[j], f[j - a[i]] + b[i]);
	
	int res = 0x3f3f3f3f;
	for (int i = m; i < M; i ++ ) res = min(res, f[i]);
	printf("%d\n", res);
	return 0;
}

Measured memory_bytes: 384
void main()
{
    long x = rdElem;

    long result;
    result += x / 500 * 1000;
    x %= 500;
    result += x / 5 * 5;

    result.writeln;
}

enum long mod = 10^^9 + 7;
enum long inf = 1L << 60;

T rdElem(T = long)()
if (!is(T == struct))
{
    return readln.chomp.to!T;
}

alias rdStr = rdElem!string;
alias rdDchar = rdElem!(dchar[]);

T rdElem(T)()
if (is(T == struct))
{
    T result;
    string[] input = rdRow!string;
    assert(T.tupleof.length == input.length);
    foreach (i, ref x; result.tupleof)
    {
        x = input[i].to!(typeof(x));
    }
    return result;
}

T[] rdRow(T = long)()
{
    return readln.split.to!(T[]);
}

T[] rdCol(T = long)(long col)
{
    return iota(col).map!(x => rdElem!T).array;
}

T[][] rdMat(T = long)(long col)
{
    return iota(col).map!(x => rdRow!T).array;
}

void rdVals(T...)(ref T data)
{
    string[] input = rdRow!string;
    assert(data.length == input.length);
    foreach (i, ref x; data)
    {
        x = input[i].to!(typeof(x));
    }
}

void wrMat(T = long)(T[][] mat)
{
    foreach (row; mat)
    {
        foreach (j, compo; row)
        {
            compo.write;
            if (j == row.length - 1) writeln;
            else " ".write;
        }
    }
}

import std.stdio;
import std.string;
import std.array;
import std.conv;
import std.algorithm;
import std.range;
import std.math;
import std.numeric;
import std.mathspecial;
import std.traits;
import std.container;
import std.functional;
import std.typecons;
import std.ascii;
import std.uni;
import core.bitop;

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define mod 1000000009
#define int long long
#define garou ios_base::sync_with_stdio(false); cin.tie(NULL);
using namespace std;
int pow(int p,int r){
	int ans=1;
	while(r>0){
     if(r&1){
		 ans=((ans%mod)*(p%mod))%mod;
	 }
	 r=r>>1;
     p=((p%mod)*(p%mod))%mod;
	}
	return ans;
}
signed main() {
	 garou;
	int k,a,b;
	cin>>k>>a>>b;
	int x=(b/k)*k;
	if(x<=b&&x>=a)
	cout<<"OK";
	else
	{
		cout<<"NG";
	}
	 
}

Measured memory_bytes: 3656
package main

import "fmt"

func main() {
	// Code for A - Day of Takahashi
	var a, b int
	fmt.Scanf("%d %d", &a, &b)
	if b-a >= 0 {
		fmt.Println(a)
	} else {
		fmt.Println(a - 1)
	}
}


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

using namespace std;

int h, n, res = 1e9;
vector <vector <int>> f;

int main() {
    cin >> h >> n;
    f.resize(2e4 + 1, vector <int> (n + 1, 1e9));
    f[0][0] = 0;
    for (int i = 1, a, b; i <= n; ++i) {
        cin >> a >> b;
        for (int j = 0; j <= 2e4; ++j) {
            f[j][i] = f[j][i - 1];
            if (j >= a) f[j][i] = min(f[j][i], f[j - a][i] + b);
            if (j >= h) res = min(res, f[j][i]);
        }
    }
    cout << res;
}

Measured memory_bytes: 79104
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<queue>
#include<cmath>
#include<map>
#include<cstdlib>
#include<iostream>
#include<algorithm>
using namespace std;
typedef long long ll;
char s[200000+5];
int main()
{
    while(~scanf("%s",s))
    {
        int len=strlen(s);
        ll sum=0,tnt=0;
        for(int i=len-1;i>=0;i--)
        {
            if(s[i]=='W')
            {
                tnt++;
            }
            else
            {
                sum+=tnt;
            }
        }
        printf("%lld\n",sum);
    }
    return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
int gcd(int x,int y){
  if(x%y==0) {
    return (y);}
  else {
    return (gcd(y,x%y));}
  }
int main() {
  ll a,b;
  cin >> a >> b;
  ll z=a*b/gcd(a,b);
  cout << z << endl;
  return 0;
  }

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <string>
#include <cmath>
#include <map>
#include <climits>
#include <cassert>
#include <algorithm>
#include <utility>

using namespace std;
using Int = long long int;
using UInt = unsigned long long int;
using VI = vector<long long int>;
using VVI = vector<vector<long long int> >;


int main(void) {
    Int a, b;
    cin >> a >> b;
    cout << a * b << endl;
    return 0;
}


Measured memory_bytes: 3544
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.IO;
using System.Diagnostics;

class Myon
{
    public Myon() { }
    public static int Main()
    {
        new Myon().calc();
        return 0;
    }

    Scanner cin;


    void calc()
    {
        cin = new Scanner();
        int[] AB = cin.ArrayInt(2,0);
       string ans="";
      if(AB[0]*AB[1]%2==0)ans="Even";
      else ans="Odd";
             
             Console.WriteLine(ans);
       
    }


}



class Scanner
{
    string[] s;
    int i;

    char[] cs = new char[] { ' ' };

    public Scanner()
    {
        s = new string[0];
        i = 0;
    }

    public string next()
    {
        if (i < s.Length) return s[i++];
        string st = Console.ReadLine();
        while (st == "") st = Console.ReadLine();
        s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
        if (s.Length == 0) return next();
        i = 0;
        return s[i++];
    }

    public int nextInt()
    {
        return int.Parse(next());
    }
    public int[] ArrayInt(int N, int add = 0)
    {
        int[] Array = new int[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextInt() + add;
        }
        return Array;
    }

    public long nextLong()
    {
        return long.Parse(next());
    }

    public long[] ArrayLong(int N, long add = 0)
    {
        long[] Array = new long[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextLong() + add;
        }
        return Array;
    }

    public double nextDouble()
    {
        return double.Parse(next());
    }


    public double[] ArrayDouble(int N, double add = 0)
    {
        double[] Array = new double[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextDouble() + add;
        }
        return Array;
    }
}


Measured memory_bytes: 11092
#include <bits/stdc++.h>
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; }

#define rep(i,cc,n) for(int i=cc;i<n;++i)
#define lrep(i,cc,n) for(long long i=cc;i<n;++i)
#define sqrep(i,cc,n) for(long long i=cc;i*i<=n;++i)
#define rrep(i,cc,n) for(long i=cc;i>n;--i)
#define pii pair<int, int>
#define pll pair<long long, long long>
 
using ll = long long;

const vector<int> dx = {1, 0, -1, 0};
const vector<int> dy = {0, 1, 0, -1};
const ll inf = 1001001001;
const ll e9  = 1000000000;
const ll mod = 1000000007;
const double PI = 3.1415926535;

int main() {
   string s;
   cin >> s;
   int n = s.size();
   vector<int>cnt(26,0);
   if(n!=26){
       rep(i, 0, n){
           cnt[s[i]-'a']++;
       }
       //cout << "ok" << endl;
       rep(i, 0, 26){
           if(cnt[i]==0){
               char t = i + 'a';
               cout << s << t << endl;
               return 0;
           }
       }
   }else if (s!="zyxwvutsrqponmlkjihgfedcba"){
       string s2 = s;
       string p;
       next_permutation(s.begin(),s.end());
       while(s>s2){
           p = s[s.size()-1];
           s.erase(s.size()-1);
       }
       cout << s << p << endl;
   }else{
       cout << -1 << endl;
   }
}

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


void solve(long long A, long long B){
    int X=6;
    X-= (A+B);
    cout << X << endl;
}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long A;
    scanf("%lld",&A);
    long long B;
    scanf("%lld",&B);
    solve(A, B);
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#define MAX 1000005
#define NIL -1

using namespace std;

struct Node {
	int parent, left, right;
};
struct Node T[MAX];
int n, D[MAX];

void getdepth(int u,int p);
void display(int u);

int main() {
	int c_cnt,id,c,l,r;
	cin >> n;
	for (int i = 0; i < n; i++) T[i].parent = T[i].left = T[i].right = NIL;

	for (int i = 0; i < n; i++) {
		cin >> id >> c_cnt;
		for (int j = 0; j < c_cnt; j++) {
			cin >> c;
			if (j == 0) T[id].left=c;
			else T[l].right = c;
			l = c;
			T[c].parent = id;
		}
	}
	for (int i = 0; i < n; i++) {
		if (T[i].parent == NIL) r = i;
	}
	getdepth(r, 0);
	for (int i = 0; i < n; i++) {
		display(i);
	}
	return 0;
}

void getdepth(int u,int p) {
	D[u] = p; //その地点の深さ
	if (T[u].right != NIL) getdepth(T[u].right, p);
	if (T[u].left != NIL) getdepth(T[u].left, p + 1);
}
void display(int u) {
	cout << "node " << u << ":";
	cout << " parent = " << T[u].parent << ",";
	cout << " depth = " << D[u] << ", ";

	if (T[u].parent == NIL) cout << "root, ";
	else if (T[u].left == NIL)cout << "leaf, ";
	else cout << "internal node, ";

	cout << "[";
	for (int i = 0, c = T[u].left; c != NIL; i++, c = T[c].right) {
		if (i) cout << ", ";
		cout << c;
	}
	cout << "]" << endl;;
}


Measured memory_bytes: 7800
def ascii_alter(c,x):
    return chr(ord(c)+x)
def main():
    S=lambda:input()
    I=lambda:int(input())
    L=lambda:list(map(int,input().split()))
    LS=lambda:list(map(str,input().split()))
    
    c=S()
    print(ascii_alter(c,1))
    
if __name__ == '__main__':
    main()

Measured memory_bytes: 3060
#include <iostream>
#include <string>
using namespace std;
int main() {
	string a, b;
	cin >> a >> b;
	int x = stoi(a + b);
	for (int i = 1;i <= 1000;i++) {
		if (i*i == x) {
			cout << "Yes" << endl;
			return 0;
		}
	}
	cout << "No" << endl;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp61
{
    class Program
    {
        static void Main(string[] args)
        {
            string S=Console.ReadLine();
            int FirstA = S.IndexOf('A');
            int LastZ = S.LastIndexOf('Z');
            Console.WriteLine(LastZ - FirstA + 1);

        }
    }
}


Measured memory_bytes: 11616
H = W = 10
Blur = [
  [[0,0], [1,-1], [1,0], [1,1], [2,0]],
  [[0,0], [0,1], [0,2], [1,0], [1,1], [1,2], [2,0], [2,1], [2,2]],
  [[0,0], [1,-1], [1,0], [1,1], [2,-2], [2,-1], [2,0], [2,1], [2,2], [3,-1], [3,0], [3,1], [4,0]],
]
Small, Medium, Large = 0, 1, 2
Y, X = 0, 1

def solve(cloth)
  @answer = Array.new
  dfs(cloth, 0, 0, 0)
  @answer
end

def dfs(cloth, y, x, depth)
  for ny in 0...H do
    for nx in 0...W do
      break if cloth[ny][nx] != 0
    end
    break if cloth[ny][nx] != 0
  end
  return true if ny==H-1 && nx==W-1 && cloth[ny][nx]==0 && @ink==depth
  return false if ny<y || (ny==y && nx<x)
  for b in 0...Blur.size do
    ok = true
    c = cloth.map(&:dup)
    Blur[b].each do |d|
      i = ny+d[Y]
      j = nx+d[X]
      if i<0 || H<=i || j<0 || W<=j || cloth[i][j]==0
        ok = false
        break
      end
      c[i][j] -= 1
    end
    next unless ok
    if dfs(c, ny, nx, depth+1)
      case b
        when Small
          @answer.push([nx, ny+1, 1])
        when Medium
          @answer.push([nx+1, ny+1, 2])
        when Large
          @answer.push([nx, ny+2, 3])
      end
      return true
    end
  end
  false
end

@ink = gets.to_i
cloth = Array.new
H.times do cloth.push(gets.split.map(&:to_i)) end
solve(cloth).each do |e|
  puts e*" "
end

Measured memory_bytes: 6144
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <numeric>

using namespace std;

using ll = long long;

#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)

#define input(...) __VA_ARGS__; in(__VA_ARGS__)

#if __has_include("debugger.cpp")
  #include "debugger.cpp"
#else
void print() {
  std::cout << std::endl;
}

template <class Head, class... Tail>
void print(Head&& head, Tail&&... tail) {
  cout << head;
  if (sizeof...(tail) > 0) cout << " ";
  print(std::forward<Tail>(tail)...);
}
# endif

void in() { }

template <class Head, class... Tail>
void in(Head&& head, Tail&&... tail) {
  cin >> head;
  in(std::forward<Tail>(tail)...);
}

int main() {
  ll input(n);
  map<string, int> cnt;
  REP(i, n) {
    string input(s);
    cnt[s] += 1;
  }

  vector<string> keys = {"AC", "WA", "TLE", "RE"};

  for(auto k: keys) {
    print(k, "x", cnt[k]);
  }
}


Measured memory_bytes: 3640
#include<iostream>
#include<vector>
#include<algorithm>
#define LL long long
LL X, Y;
int ans;
int main() {
	std::cin >> X >> Y;
	while (X <= Y) {
		ans++;
		X *= 2;
	}
	std::cout << ans << std::endl;
	return 0;
}

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

using namespace std;
using ll = long long;

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

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

  int a[n];
  rep(i, n) cin >> a[i];

  vector<int> d(n);
  for (int i = 0; i < n - 1; ++i) {
    d[i] = abs(a[i] - a[i + 1]);
  }
  d[n - 1] = (k - a[n - 1]) + a[0];

  int ans = k - *max_element(d.begin(), d.end());
  cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 1920
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ll long long
ll gcd(ll x, ll y) { return (x % y)? gcd(y, x % y): y; }    //最大公約数
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }     //最小公倍数
using Graph = vector<vector<ll>>;
ll inf=300000000000000000;
const double PI = 3.14159265358979323846;
int main(){
  int n,k;
  cin >> n >> k;
  int p[n];
  rep(i,n)cin >> p[i];
  int u[n];
  u[0]=1;
  int cnt=0;
  rep(i,n-1){
    if(p[i]<p[i+1])u[i+1]=u[i]+1;
    else u[i+1]=1;
    if(u[i+1]==k)cnt++;
  }
  int ans=n-k+1-max(0,cnt-1);
  set<int> s;
  rep(i,k)s.insert(p[i]);
  //cout << ans << endl;
  rep(i,n-k){
    s.insert(p[i+k]);
    if(*begin(s)==p[i]&&*rbegin(s)==p[i+k])ans--;
    s.erase(p[i]);
  }
  cout << ans << endl;
}


Measured memory_bytes: 14532
#include <algorithm>
#include <bitset>
#include <climits>
#include <cmath>
#include <cstddef>
#include <cstdlib>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <limits>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>

// clang-format off
template <typename T> T gcd(T a, T b) { return b == 0 ? a : gcd(b, a % b); }
template <typename T> T lcm(T a, T b) { return a * b / gcd(a, b); }
template <typename T> T clamp(T val, T min, T max) { return val < min ? min : (max < val ? max : val); }
template <typename T> size_t max_index(T begin, T end) { return distance(begin, max_element(begin, end)); }
template <typename T> size_t min_index(T begin, T end) { return distance(begin, min_element(begin, end)); }
// clang-format on

#define int long long
#define YES "Yes"
#define NO  "No"

using namespace std;

signed main(void) {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);

  int num = 0;

  int n; cin >> n;
  vector<int> v(n);
  vector<int> c(n);

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

  for (int i = 0; i < pow(2, n); ++i) {
    int x = 0;
    int y = 0;

    bitset<20> bs(i);

    for (int j = 0; j < n; ++j) {
      if (bs.test(j)) {
        x += v[j];
        y += c[j];
      }
    }

    num = max(num, x - y);
    
  }
  

  cout << num << endl;
  
  return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define pb push_back
#define mp make_pair
#define rep(i,n) for(int i=0;i<(n);++i)

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n,m;cin >> n >> m;
	vector<ll> a(n+1);
	rep(i,n) cin >> a.at(i);
	vector<ll> sum(n+1);
	rep(i,n) sum.at(i+1)=(sum.at(i)+a.at(i))%m;
	map<int,int> M;
	ll ans=0;
	rep(i,n+1){
		ans+=M[sum.at(i)];
		M[sum.at(i)]++;
	}
	cout << ans << endl;
}

Measured memory_bytes: 4736
#include<iostream>
#include<vector>
#include<cmath>
#include<algorithm>
using namespace std;
int main() {
	int n; cin >> n;
	vector<long long> a(n + 1), b(n);
	for (int i = 0; i < n + 1; i++) {
		cin >> a[i];
	}
	for (int i = 0; i < n; i++) {
		cin >> b[i];
	}
	long long gekiha;
	long long gekiha2;

	long long ans = 0;

	for (int i = 0; i < n; i++) {
		gekiha = min(a[i], b[i]);
		gekiha2 = min(a[i+1], b[i] - min(a[i], b[i]));
		a[i + 1] = a[i + 1] - gekiha2;
		ans += gekiha + gekiha2;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1792
N=int(input())
li = []

now = 0
ans = -1
count = 0

for n in range(N):
  li.append(int(input()))

for n in range(N + 1):
  if n == 0:
    now = li[0]
    count += 1

    if now == 2:
      ans = count
      break

  now = li[now - 1]
  count += 1

  if now == 2:
    ans = count
    break

print(ans)

Measured memory_bytes: 7084
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
ll in(){ll res;cin>>res;return res;}

int main(){
    ll a = in();
    ll b = in();
    ll c = in();
    if(sqrtl(a)+sqrtl(b)+1e-15<sqrtl(c)){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
}


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


using namespace std;

#define ll long long
int main() {
    string s1;
    cin>>s1;
    int l=s1.length();
    ll ans=0;
    int b=0;
    
    for(int i=l-1;i>=1;i--){
   //     cout<<s1[i]<<"  ";
        int p1=s1[i]-'0';
        if(b==1){
            p1++;
            b=0;
        }
        if(p1==10){
            b=1;
            continue;
        }
        int i1=s1[i-1]-'0';
        if(p1<5 || (p1==5 && i1<5) ){
            ans=ans+p1;
            
        }else{
            ans=ans+(10-p1);
            b=1;
        }
//        cout<<ans<<"\n";
    }
//    cout<<ans<<"\n";
  //  cout<<"-------------\n";
    int p2=s1[0]-'0';
    if(b==1){
    
        p2++;
    }
    
    
    if(p2==10){
        ans++;
    }else{
        if(p2>=6){
            ans=ans+(10-p2)+1;
            
        }else{
            ans=ans+p2;
        }
    
    }
    cout<<ans;
    
    
}


Measured memory_bytes: 1412
def main():
    S = input()
    K = int(input())
    count = 0
    same = True
    for i in range(len(S) - 1):
        if S[i] == S[i+1]:
            continue
        else:
            same = False
            break
    if same:
        count += int((len(S) * K) / 2)
    else:
        i = 0
        while i < len(S):
            c = 1
            flag = False
            if i < len(S) - 1:
                flag = True
                while S[i] == S[i+1]:
                    c += 1
                    i += 1
                    if i + 1 >= len(S):
                        flag = False
                        break
            i += 1
            if c % 2 == 0:
                count += K * int(c / 2)
            else:
                count += K * int((c - 1) / 2)
            if not flag:
                u = 0
                a = 0
                while S[u] == S[-1]:
                    u += 1
                    a += 1
                if c % 2 == 0 and a % 2 == 0:
                    continue
                elif c % 2 == 1 and a % 2 == 0:
                    continue
                elif c % 2 == 0 and a % 2 == 1:
                    continue
                else:
                    count += K - 1
            
    print(count)

if __name__ == "__main__":
    main()


Measured memory_bytes: 3064
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
 
using namespace std;
using namespace __gnu_pbds;
 
/*******  All Required define Pre-Processors and typedef Constants *******/
#define mem(a, b) memset(a, (b), sizeof(a))
#define rep(i, k) for (int i = 0; i < k; i++)
#define repA(i, a, n) for (int i = a; i <= (n); ++i)
#define repD(i, a, n) for (int i = a; i >= (n); --i)
#define all(cont) cont.begin(), cont.end()
#define mp make_pair
#define pb push_back
#define INF 1e9
#define EPS 1e-9
#define PI 3.1415926535897932384626433832795
#define LLINF 1e14
#define sz(a) int(a.size())
#define ff first
#define ss second
 
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> ii;
typedef vector<ii> vp;
typedef vector<vp> vvp;
 
int main(int argc, char const *argv[])
{
        ios_base::sync_with_stdio(false);
        cin.tie(NULL);
        int n; cin >> n;
        long double ans = 0;
        rep(i, n){
        	long double x; cin >> x;
        	ans += (1 / x);
        }

        ans = 1 / ans;
        cout << ans << '\n';
		return 0;    
}

Measured memory_bytes: 256