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

using namespace std;

#define INF 100000000
#define YJ 1145141919
#define INF_INT_MAX 2147483647
#define INF_LL 9223372036854775
#define INF_LL_MAX 9223372036854775807
#define EPS 1e-10
#define MOD 1000000007
#define MOD9 998244353
#define Pi acos(-1)
#define LL long long
#define ULL unsigned long long
#define LD long double

#define int long long

using II = pair<int, int>;

int gcd(int a, int b) { return b != 0 ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a * b / gcd(a, b); }
int extgcd(int a, int b, int &x, int &y) { int g = a; x = 1; y = 0; if (b != 0) g = extgcd(b, a % b, y, x), y -= (a / b) * x; return g; }

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(a)  begin((a)), end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())

const int MAX_N = 100005;
int X, Y, A, B, C;

int P[MAX_N], Q[MAX_N], R[MAX_N];

int calcScore(int la)
{
  int ret = 0;
  int r = 0;
  REP(i,la) {
    ret += P[i];
  }
  for(;r<C && la + r < X; r++) {
    ret += R[r];
  }
  if (la + r != X) {
    return -1;
  }

  int y = 0;
  int b = 0;
  while(y < Y) {
    if (r < C) {
      if (R[r] < Q[b]) {
        ret += Q[b++];
      } else {
        ret += R[r++];
      }
    } else {
      ret += Q[b++];
    }
    y++;
  }

  return ret;
}

signed main()
{
  cin >> X >> Y >> A >> B >> C;

  REP(a,A) {
    cin >> P[a];
  }
  REP(b,B) {
    cin >> Q[b];
  }
  REP(c,C) {
    cin >> R[c];
  }

  sort(P, P+A, greater<int>());
  sort(Q, Q+B, greater<int>());
  sort(R, R+C, greater<int>());

  int l = -1, r = X+1;
  while(r-l>3) {
    int midL = l + (r-l)/3, midR = l + 2*(r-l)/3;
    if(calcScore(midL) <= calcScore(midR)) {
      l = midL;
    } else {
      r = midR;
    }
  }

  int ans = 0;
  l = max((LL)0,l-10);
  r = min(r+10,X+1);
  FOR(i,l,r) {
    ans = max(ans, calcScore(i));
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 2560
#include <stdio.h>
int main(){;
  double men,naga,r;
  scanf("%lf",&r);
  men=(double)r*r*3.141592653589;
  naga=(double)r*3.141592653589*2.0;

  printf("%8.6f %8.6f\n",men,naga);
  return 0;
}

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

#define int long long
#define For(i, a, b) for (int i = (a); i <= static_cast<int>(b); i++)
#define Forr(i, a, b) for (int i = (a); i >= static_cast<int>(b); i--)
#define rep(i, n) For(i, 0, n - 1)
#define repall(i, arr) for (auto& i : (arr))
#define all(x) (x).begin(), (x).end()
#define pb push_back
#define dump(x) cerr << #x << " = " << (x) << '\n'

template <typename T>
using pq = priority_queue<T>;
template <typename T>
using pqr = priority_queue<T, vector<T>, greater<T>>;
const int INF = INT_MAX / 2;
constexpr int MOD = 1e9 + 7;
using P = pair<int, int>;
using vec = vector<int>;
using mat = vector<vec>;

template <typename T1, typename T2>
ostream& operator<<(ostream& stream, const pair<T1, T2>& p) {
    return stream << p.first << " " << p.second;
}
template <typename T>
void print(const vector<vector<T>> matrix) {
    repall (vec, matrix)
        print(vec);
}
template <typename T>
void print(const vector<T> vec) {
    unsigned int len = vec.size();
    rep (i, len - 1)
        cout << vec[i] << ' ';
    cout << vec[len - 1] << '\n';
}
template <typename Arg>
void print(const Arg arg) {
    cout << arg << '\n';
}
template <typename Head, typename... Args>
void print(const Head head, const Args... args) {
    cout << head << " ";
    print(args...);
}
template <typename T>
T sum_(vector<T> vec, T init = 0) {
    return std::accumulate(all(vec), T(init));
}

void yn(bool tf) { print(tf ? "Yes" : "No"); }
void YN(bool tf) { print(tf ? "YES" : "NO"); }

template <typename T>
void init(vector<vector<T>> m) {
    repall (v, m)
        init(v);
}

template <typename T>
void init(vector<T>& v) {
    rep (i, v.size())
        cin >> v[i];
}

int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
// -------------------------------------------------------------------

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

    int s;
    cin >> s;
    set<int> st;

    int i = 1;
    while (i++) {
        st.insert(s);
        s = s % 2 ? 3 * s + 1 : s / 2;
        if (st.find(s) != st.end()) break;
    }
    print(i);

    return 0;
}

Measured memory_bytes: 384
#ifdef LOCAL
#define _GLIBCXX_DEBUG
#endif
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;++i)
#define rrep(i,n) for(int i=n-1;i>=0;--i)
#define reps(i,a,b) for(int i=a;i<b;++i)
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
using namespace std;
using ll = long long;
using P = pair<int, int>;
template<typename T> inline bool chmax(T &a,T b){if(a<b){a=b;return 1;}return 0;}
template<typename T> inline bool chmin(T &a,T b){if(b<a){a=b;return 1;}return 0;}
template<typename T> vector<T> make_vec(size_t a){return vector<T>(a);}
template<typename T,typename... Ts>
auto make_vec(size_t a,Ts... ts){return vector<decltype(make_vec<T>(ts...))>(a,make_vec<T>(ts...));}
template<typename T,typename U,typename... V>
typename enable_if<is_same<T,U>::value>::type fill_v(U &u,const V... v){u=U(v...);}
template<typename T,typename U,typename... V>
typename enable_if<!is_same<T,U>::value>::type fill_v(U &u,const V... v){for(auto &e:u)fill_v<T>(e,v...);}

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

    int q;
    cin >> q;
    set<int> st;
    while (q--) {
        int com, x, l, r;
        cin >> com;
        if (com == 0) {
            cin >> x;
            st.insert(x);
            cout << st.size() << endl;
        } else if (com == 1) {
            cin >> x;
            cout << st.count(x) << endl;
        } else if (com == 2) {
            cin >> x;
            st.erase(x);
        } else {
            cin >> l >> r;
            auto litr = st.lower_bound(l);
            auto ritr = st.upper_bound(r);
            for (auto itr = litr; itr != ritr; ++itr) cout << *itr << endl;
        }
    }
}



Measured memory_bytes: 12508
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main(){
   string s;
   cin >>s;
   ll k;
   cin >>k;
   ll ss=s.size(),o=0,fl=0;
   for(ll i=0;i<k;i++){
     if(s[i]!='1') {
       fl=1;
       o=i;
       break;
     }
     if(i==ss-1) {
       break;
     }
   }
   if(fl==0) cout <<1<<endl;
   else cout <<s[o]<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <string>
#include <utility>

using namespace std;

#define REP(i,n) for(int (i)=(0);(i)<(n);++i)
#define REP1(i,n) for(int (i)=(1);(i)<(n);++i)
#define ll long long

int main(){
    int a,b,c,ans[15];
    cin >> a >> b >> c;

    ans[0]=c;

    REP1(i,11){
        ans[i] = a*ans[i-1]-b;
        cout << ans[i] << endl;
    }

    return 0;
}

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

string s;
string ans[2] = {"First", "Second"};
int main(){
  cin >> s;
  int l = s.size();
  char a = ( s[0] == s[l-1] ) ? 0 : 1;
  char b = l % 2;
  cout << ans[ a ^ b ] << endl;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
int main() {
	int N, T, A; cin >> N >> T >> A;
	int H[N];
	for(int i = 0; i < N; i++) cin >> H[i];
	int res = -1;
	double min = 1e9;
	for (int i = 0; i < N; i++)
	{
		double tmp = (double)(T - H[i] * 0.006);
		if(min > abs(A - tmp)) {
			min = abs(A - tmp);
			res = i+1;
		}
	}
	cout << res << endl;
	return 0;
}


Measured memory_bytes: 256
# https://atcoder.jp/contests/keyence2020/tasks/keyence2020_b

# 4       n
# 2 4     x_i l_1
# 4 3
# 9 3
# 100 5   x_n l_n

n = gets.to_i
array_robot = []

n.times do
  x_temp, l_temp = gets.split.map(&:to_i)
  array_robot << [x_temp-l_temp, x_temp+l_temp]
end

array_robot.sort_by! {|from, to| to }
end_pos = array_robot[0][1]
ans = 0

i = 0
array_robot.each do |from, to|
  if i == 0
    ans += 1
    i += 1
    next
  end
  if end_pos <= from
    ans += 1
    end_pos = to
  end
end

puts ans


Measured memory_bytes: 23872
#include <bits/stdc++.h>
using namespace std;
struct unionfind{
	vector<int> data;
	vector<int> size;
	unionfind(int n){
		for(int i=0;i<n;i++){
			data.push_back(i);
			size.push_back(1);
		}
	}
	
	int find(int x){
		if(data[x]==x)return x;
		return data[x]=find(data[x]);
	}
	
	bool unite(int x,int y){
		x=find(x);y=find(y);
		if(x==y)return false;
		data[x]=y;
		size[y]+=size[x];
		return true;
	}
	
	bool check(int x,int y){
		return (find(x)==find(y));
	}
	
	int get_size(int x){
		int X = find(x);
		return size[X];
	}
};


int main(){
	int N,M;
	cin>>N>>M;
	vector<pair<int,int>> E(M);
	
	for(int i=0;i<M;i++){
		cin>>E[i].first>>E[i].second;
		E[i].first--;
		E[i].second--;
	}
	
	int ans = 0;
	for(int i=0;i<M;i++){
		unionfind uf(N);
		for(int j=0;j<M;j++){
			if(i==j)continue;
			uf.unite(E[j].first,E[j].second);
		}
		if(uf.get_size(0)!=N)ans++;
	}
	
	cout<<ans<<endl;
	
	return 0;
}


Measured memory_bytes: 256
S = list(input())
ans =0
if(S[0]=='S' and S[1] == 'U'):
    ans = 7
elif(S[0]== 'M'):
    ans =6
elif(S[0]== 'T' and S[1] == 'U'):
    ans =5
elif(S[0] == 'W'):
    ans =4
elif(S[0] == 'T' and S[1] == 'H'):
    ans =3
elif(S[0] == 'F'):
    ans =2
else:
    ans =1
print(ans)

Measured memory_bytes: 3064
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
   string S;
   int a,b,c,d,e,f,g,h,I,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z;
   a=b=c=d=e=f=g=h=I=j=k=l=m=n=o=p=q=r=s=t=u=v=w=x=y=z=0;
   while(getline(cin,S)){
   for(int i=0;i<S.size();i++){
        if(S.at(i)=='a'||S.at(i)=='A'){
            a++;
        }
        if(S.at(i)=='b'||S.at(i)=='B'){
            b++;
        }
        if(S.at(i)=='c'||S.at(i)=='C'){
            c++;
        }
        if(S.at(i)=='d'||S.at(i)=='D'){
            d++;
        }
        if(S.at(i)=='e'||S.at(i)=='E'){
            e++;
        }
        if(S.at(i)=='f'||S.at(i)=='F'){
            f++;
        }
        if(S.at(i)=='g'||S.at(i)=='G'){
            g++;
        }
        if(S.at(i)=='h'||S.at(i)=='H'){
            h++;
        }
        if(S.at(i)=='i'||S.at(i)=='I'){
            I++;
        }
        if(S.at(i)=='j'||S.at(i)=='J'){
            j++;
        }
        if(S.at(i)=='k'||S.at(i)=='K'){
            k++;
        }
        if(S.at(i)=='l'||S.at(i)=='L'){
            l++;
        }
        if(S.at(i)=='m'||S.at(i)=='M'){
            m++;
        }
        if(S.at(i)=='n'||S.at(i)=='N'){
            n++;
        }
        if(S.at(i)=='o'||S.at(i)=='O'){
            o++;
        }
        if(S.at(i)=='p'||S.at(i)=='P'){
            p++;
        }
        if(S.at(i)=='q'||S.at(i)=='Q'){
            q++;
        }
        if(S.at(i)=='r'||S.at(i)=='R'){
            r++;
        }
        if(S.at(i)=='s'||S.at(i)=='S'){
            s++;
        }
        if(S.at(i)=='t'||S.at(i)=='T'){
            t++;
        }
        if(S.at(i)=='u'||S.at(i)=='U'){
            u++;
        }
        if(S.at(i)=='v'||S.at(i)=='V'){
            v++;
        }
        if(S.at(i)=='w'||S.at(i)=='W'){
            w++;
        }
        if(S.at(i)=='x'||S.at(i)=='X'){
            x++;
        }
        if(S.at(i)=='y'||S.at(i)=='Y'){
            y++;
        }
        if(S.at(i)=='z'||S.at(i)=='Z'){
            z++;
        }
   }
        
   }
   cout<<"a"<<" "<<":"<<" "<<a<<endl;
   cout<<"b"<<" "<<":"<<" "<<b<<endl;
   cout<<"c"<<" "<<":"<<" "<<c<<endl;
   cout<<"d"<<" "<<":"<<" "<<d<<endl;
   cout<<"e"<<" "<<":"<<" "<<e<<endl;
   cout<<"f"<<" "<<":"<<" "<<f<<endl;
   cout<<"g"<<" "<<":"<<" "<<g<<endl;
   cout<<"h"<<" "<<":"<<" "<<h<<endl;
   cout<<"i"<<" "<<":"<<" "<<I<<endl;
   cout<<"j"<<" "<<":"<<" "<<j<<endl;
   cout<<"k"<<" "<<":"<<" "<<k<<endl;
   cout<<"l"<<" "<<":"<<" "<<l<<endl;
   cout<<"m"<<" "<<":"<<" "<<m<<endl;
   cout<<"n"<<" "<<":"<<" "<<n<<endl;
   cout<<"o"<<" "<<":"<<" "<<o<<endl;
   cout<<"p"<<" "<<":"<<" "<<p<<endl;
   cout<<"q"<<" "<<":"<<" "<<q<<endl;
   cout<<"r"<<" "<<":"<<" "<<r<<endl;
   cout<<"s"<<" "<<":"<<" "<<s<<endl;
   cout<<"t"<<" "<<":"<<" "<<t<<endl;
   cout<<"u"<<" "<<":"<<" "<<u<<endl;
   cout<<"v"<<" "<<":"<<" "<<v<<endl;
   cout<<"w"<<" "<<":"<<" "<<w<<endl;
   cout<<"x"<<" "<<":"<<" "<<x<<endl;
   cout<<"y"<<" "<<":"<<" "<<y<<endl;
   cout<<"z"<<" "<<":"<<" "<<z<<endl;
}



Measured memory_bytes: 3156
#include"bits/stdc++.h"

using namespace std;

int main() {
	int a[] = { 0,1,3,1,2,1,2,1,1,2,1,2,1 };
	int x, y;
	cin >> x >> y;

	if (a[x] == a[y]) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <random>
#include <bitset>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
typedef long long ll;
using namespace std;
const ll MOD = 1000000007LL;

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

    string s;
    cin >> s;

    int c = 15 - s.size();
    for (int i = 0; i < s.size(); i++) {
        if (s[i] == 'o') c++;
    }

    if (c >= 8) {
        cout << "YES" << "\n";
    } else {
        cout << "NO" << "\n";
    }

    return 0;
}

Measured memory_bytes: 888
//15, 12, 2018, 10:04:05 Rafaelcs cpp
#include <bits/stdc++.h>

using namespace std;
typedef pair<int, int> pii;
typedef long double ld;
typedef long long ll;
typedef unsigned long long ull;

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

    ll sum = 0LL;

    string s;

    cin >> s;

    ll carry = 0LL;

    int n = s.length();

    for(int i = n - 1 ; i >= 0 ; i--){
        if(s[i] == 'W'){
            carry++;
        }else{
            sum += carry;
        }
    }

    cout << sum << endl;
    
    return 0;
}

Measured memory_bytes: 720
#include <bits/stdc++.h>
#include <boost/multi_array.hpp>
#include <boost/range/algorithm.hpp>
#define rep(i,n) for (int i=0; i< (n); ++i)
using namespace std;
typedef long long ll;
const int MOD = 1000000007;

bool cmp(tuple<int,string,int> a,tuple<int,string,int> b){
  if (get<1>(a) != get<1>(b)){
    return get<1>(a) < get<1>(b);
  }else{
    return get<2>(a) > get<2>(b);
  }
}

int main() {
  int n;
  cin >> n;
  vector<tuple<int,string,int>> a;
  rep(i,n){
    string s;
    int p;
    cin >> s >> p;
    a.emplace_back(i,s,p);
  }
  sort(a.begin(),a.end(),cmp);
  rep(i,n){
    cout << get<0>(a[i])+1 << endl;
  }

  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

int main(void){
    char c[1200] = {0};
    int i = 0;
    int j = 0;
    for(i=0;i<1200;i++){
        scanf("%c",&c[i]);
        if(c[i]=='\n'){
            break;
        }
    }
    
    for(j=0;j<=i;j++){
        if(c[j]>=65&&c[j]<=90){
            c[j] = c[j]+32;
        }
        else if(c[j]>=97&&c[j]<=122){
            c[j] = c[j]-32;
        }
    }
    
    for(j=0;j<=i;j++){
        printf("%c",c[j]);
    }
    
    return 0;
}



Measured memory_bytes: 2040
N, *A = map(int, open(0).read().split())

count = 0
loop = True
while loop:
    loop = False
    for i in range(N-1, 0, -1):
        if A[i] < A[i-1]:
            A[i], A[i-1] = A[i-1], A[i]
            loop = True
            count += 1

print(' '.join([str(a) for a in A]))
print(count)


Measured memory_bytes: 5608
#include<stdio.h>
int main(void){
	int h,w,i,j;
	
	while(1){
	scanf("%d%d",&h,&w);
		if(h==0&&w==0){
			break;
		}
		else{
			for(i=0;i<h;i++){
				for(j=0;j<w;j++){
					if((i+j)%2==0){
						printf("#");
					}
					else{
						printf(".");
					}
			}
				printf("\n");
		}
		}
		printf("\n");
	}
return 0;
}

Measured memory_bytes: 572
#include <iostream>
#include <string>
#include <vector>

int main(){
  std::string odd,even;
  std::cin>>odd;
  std::cin>>even;
  int n = odd.length()+even.length();
  std::string passwd(n,' ');
  for(int i=0;i<n;++i){
    passwd[i] = ((i%2==1)?even[i/2]:odd[i/2]);
  }

  std::cout<<passwd<<std::endl;
  return 0;
}

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


ll dp[105][100005];


int main(){

  ll n,W;
  cin>>n>>W;
  vector<ll> v(n);
  vector<ll> w(n);

  rep(i,n){
    cin>>w[i];
    cin>>v[i];
  }
  rep(i,105)rep(j,100005)dp[i][j]=0;
  rep(i,n)rep(j,W+1){
    dp[i+1][j]=max(dp[i+1][j],dp[i][j]);
    if (j>=w[i]){
      dp[i+1][j]=max(dp[i+1][j],dp[i][j-w[i]]+v[i]);
    }
  }
  ll ans=0;
  rep(i,W+1){
    ans=max(ans,dp[n][i]);
  //  cout<<ans<<endl;
  }
  cout<<ans;

}


Measured memory_bytes: 85620
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define rep(i,b) FOR(i,0,b)
#define INF mugen
#define dump(x) cerr<<#x<<"="<<x<<endl
#define ALL(a) (a).begin(),(a).end()
#define EACH(e,v) for(auto& e:v)
#define SORT(v) sort(ALL(v))
#define PERM(v) SORT(v);for(bool c##p=1;c##p;c##p=next_permutation(ALL(v)))
typedef vector<int> vi;
typedef vector<vi> vii;
typedef vector<vii> viii;
typedef pair<int,int> P;
template <class T> void chmin(T & a, T const & b) { if (b < a) a = b; }
template <class T> void chmax(T & a, T const & b) { if (b > a) a = b; }
template <typename T>
string to_string(const T &n){ostringstream stm;stm << n;return stm.str();}
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }
using ll = long long;
const ll mod = 1000'000'007;

int x[110]; 
signed main(){
    int n;
    cin>>n;
    rep(i,n)cin>>x[i];

    int ans=112345678;
    for(int i=1;i<=100;i++){
        int tmp=0;
        for(int j=0;j<n;j++){
            tmp+=(x[j]-i)*(x[j]-i);
        }
        chmin(ans,tmp);
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
using System;
using System.Linq;

namespace ABC152B {
    class Program {
        static void Main(string[] args) {
            var input = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
            var attacks = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();

            Console.WriteLine(attacks.Sum() >= input[0] ? "Yes" : "No");
        }
    }
}

Measured memory_bytes: 18144
#include<stdio.h>
#include<string.h>
char s1[11];
int order(int a,int b,char s[11]){
  if(a==b)
    return 0;
  order(a,(a+b)/2,s);
  order((a+b)/2+1,b,s);
  int i=a,j=(a+b)/2+1,k=a;
  while(k<=b){
    if(i<(a+b)/2+1 && j<b+1){
      if(s[i]>s[j]){
        s1[k]=s[i];
        i++;
      }
      else{
        s1[k]=s[j];
        j++;
      }
    }
    else if(j>b){
      s1[k]=s[i];
      i++;
    }
    else{
      s1[k]=s[j];
      j++;
    }
    k++;
  }
  for(i=a;i<=b;i++)
    s[i]=s1[i];
  return 0;
}

//20000桁のマージソート(1単語10文字以下)
char c[100001][11];
int sort(int a,int b,char s[][11]){
  if(a==b)
    return 0;
  sort(a,(a+b)/2,s);
  sort((a+b)/2+1,b,s);
  int i=a,j=(a+b)/2+1,k=a;
  while(k<=b){
    if(i<(a+b)/2+1 && j<b+1){
      if(strcmp(s[i],s[j])>0){
        strcpy(c[k],s[i]);
        i++;
      }
      else{
        strcpy(c[k],s[j]);
        j++;
      }
    }
    else if(j>b){
      strcpy(c[k],s[i]);
      i++;
    }
    else{
      strcpy(c[k],s[j]);
      j++;
    }
    k++;
  }
  for(i=a;i<=b;i++)
    strcpy(s[i],c[i]);
  return 0;
}

int main(){
  int n,i;
  long long count=0,sum;
  scanf("%d",&n);
  char s[n+1][11];
  for(i=0;i<n;i++){
    scanf("%s",s[i]);
    order(0,9,s[i]);
  }
  sort(0,n-1,s);
  sum=1;
  for(i=0;i<n-1;i++){
    if(strcmp(s[i],s[i+1])==0)
      sum++;
    else{
      count+=sum*(sum-1)/2;
      sum=1;
    }
  }
  count+=sum*(sum-1)/2;
  printf("%lld\n",count);
  return 0;
}


Measured memory_bytes: 2304
# -*- coding: utf-8 -*-


def check_solvable_recursively(number, is_solvable, candidate_numbers):
    """exhaustively search representable as summation of numbers in candidate_numbers

    Args:
        number: representable number
        is_solvable: is solvable list
        candidate_numbers: candidate numbers to be used

    Returns:
        None
    """
    if not is_solvable[number]:
        is_solvable[number] = True
    if candidate_numbers:
        check_solvable_recursively(number + candidate_numbers[0], is_solvable, candidate_numbers[1:])
        check_solvable_recursively(number, is_solvable, candidate_numbers[1:])


def main():
    raw_input()  # pass length
    candidate_numbers = [int(x) for x in raw_input().strip().split(' ')]
    raw_input()  # pass length
    target_number_list = [int(x) for x in raw_input().strip().split(' ')]

    is_solvable_list = [False] * 2001

    check_solvable_recursively(0, is_solvable_list, candidate_numbers)

    for target_number in target_number_list:
        if is_solvable_list[target_number]:
            print "yes"
        else:
            print "no"

if __name__ == "__main__":
    main()

Measured memory_bytes: 6448
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
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);
        TaskB solver = new TaskB();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskB {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int n = in.nextInt();
            int x = in.nextInt();
            int[] l = new int[n];
            for (int i = 0; i < n; i++)
                l[i] = in.nextInt();
            int ans = 1;
            int lastCoordinate = 0;
            for (int i = 1; i <= n; i++) {
                int curCoordinate = lastCoordinate + l[i - 1];
                lastCoordinate = curCoordinate;
                if (curCoordinate <= x)
                    ans++;
            }
            out.println(ans);
        }

    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

    }
}



Measured memory_bytes: 22740
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner cin = new Scanner(System.in);
        int N = cin.nextInt();
        int M = cin.nextInt();
        int[] a = new int[M * 2];
        for (int i = 0; i < M * 2; i++) {
            a[i] = cin.nextInt();
        }

        int[] x = new int[N];

        for (int i = 0; i < M * 2; i++) {
            x[a[i] - 1]++;
        }

        for (int i = 0; i < N; i++) {
            System.out.println(x[i]);
        }
    }
}

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

#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)

#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=int(a)-1;i>=int(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)

#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define getidx(ary,key) lower_bound(_all(ary),key)-begin(ary)
#define clr(a,b) memset((a),(b),sizeof(a))
#define bit(n) (1LL<<(n))
#define popcount(n) (__builtin_popcountll(n))

using namespace std;

template<class T>bool chmax(T &a, const T &b) { return (a<b)?(a=b,1):0;}
template<class T>bool chmin(T &a, const T &b) { return (b<a)?(a=b,1):0;}

using ll=long long;
using R=long double;
const R EPS=1e-9L; // [-1000,1000]->EPS=1e-8 [-10000,10000]->EPS=1e-7
inline int sgn(const R& r){return(r > EPS)-(r < -EPS);}
inline R sq(R x){return sqrt(max(x,0.0L));}

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

// Problem Specific Parameter:

int main(void){
	int n;
	cin >> n;
	
	set<int> below_3200;
	int over_or_eqaul_to_3200 = 0;

	rep(i,n){
		int rate;
		cin >> rate;
		if(rate >= 3200)
			over_or_eqaul_to_3200++;
		else
			below_3200.insert(rate/400);
	}

	const int ans_min = max(1,int(below_3200.size()));
	const int ans_max = over_or_eqaul_to_3200 + int(below_3200.size());
	
	cout << ans_min << " " << ans_max << endl;
	return 0;
}

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

int main(){
  int a, b, c;
  cin >> a >> b >> c;
  if(a == b+c || b == a+c || c == a+b){
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
  return 0;
}

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

using namespace std;    

const int maxn = 3e5 + 222;

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

	int f = 0, s = 0;
	cin >> n;
	f += n * 60;
	cin >> n;
	f += n;
	cin >> n;
	s += n * 60;
	cin >> n;
	s += n;

	cin >> n;
	cout << s - f - n;
	return 0;
}
                                               

Measured memory_bytes: 3652
#include<bits/stdc++.h>
using namespace std;
float a[3];
int main()
{
	int c,b;
	cin>>c>>b;
	a[0]=c+b;
	a[1]=c-b;
	a[2]=c*b;
	sort(a,a+3);
	cout<<a[2];
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(int argc, char const *argv[])
{
	set < int > st;
	int a, b, c;
	cin >> a >> b >> c;
	st.insert(a);
	st.insert(b);
	st.insert(c);
	cout << st.size() << endl;
	return 0;
}

Measured memory_bytes: 256
// https://atcoder.jp/contests/aising2020/tasks/aising2020_d

#include "algorithm"
#include "bitset"
#include "cmath"
#include "functional"
#include "iomanip"
#include "iostream"
#include "map"
#include "numeric"
#include "queue"
#include "set"
#include "string"
#include "vector"
#define rep(i, to) for (ll i = 0; i < (to); ++i)
#define rep1(i, to) for (ll i = 1; i <= (to); ++i)
#define repf(i, from, to) for (ll i = from; i < (to); ++i)
#define repr(i, from) for (ll i = from - 1; i >= 0; --i)
#define all(vec) vec.begin(), vec.end()
#define unless(cond) if (!(cond))
#define fi first
#define se second
using namespace std;
typedef long long ll;
typedef long double ld;
template <typename T>
using V = vector<T>;
using VL = V<ll>;
using VVL = V<VL>;
template <typename T, typename U>
using P = pair<T, U>;
using PL = P<ll, ll>;
using VPL = V<PL>;

template <typename T>
inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}

template <typename T>
inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}

template <typename T>
inline ll len(V<T> arr) {
  return arr.size();
}

struct exit_exception : public std::exception {
  const char* what() const throw() { return "Exited"; }
};

template <typename T>
void drop(T res) {
  cout << res << endl;
  throw exit_exception();
}

const ll INF = 1e18;

void solve();

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

  try {
    solve();
  } catch (exit_exception& e) {
  }

  return 0;
}
#endif

void solve() {
  ll N;
  string S;
  cin >> N >> S;

  ll x_pop_ct = 0;
  rep(i, N) {
    if (S[i] == '1') {
      x_pop_ct++;
    }
  }

  V<map<ll, ll>> two_mods(N, map<ll, ll>());

  for (ll diff : {-1, 1}) {
    if (x_pop_ct + diff == 0) continue;

    two_mods[0][diff] = 1;
    rep(i, N - 1) {
      two_mods[i + 1][diff] = two_mods[i][diff] * 2 % (x_pop_ct + diff);
    }
  }

  // X を x_pop_ct ±1 で割ったあまりに書き換えた値
  map<ll, ll> x_first_changed_map = {};
  for (ll diff : {-1, 1}) {
    if (x_pop_ct + diff == 0) continue;

    rep(i, N) {
      if (S[N - 1 - i] == '1') {
        x_first_changed_map[diff] += two_mods[i][diff];
        x_first_changed_map[diff] %= (x_pop_ct + diff);
      }
    }
  }

  rep(i, N) {
    ll diff = S[i] == '1' ? -1 : 1;
    ll pop_ct = x_pop_ct + diff;
    ll val = x_first_changed_map[diff];

    if (pop_ct == 0) {
      cout << 0 << "\n";
      continue;
    }

    if (diff > 0) {
      val = (val + two_mods[N - 1 - i][diff]) % pop_ct;
    } else if (diff < 0) {
      val = (val + pop_ct - two_mods[N - 1 - i][diff]) % pop_ct;
    }

    ll res = 1;

    while (val > 0) {
      ll pct = __builtin_popcountll(val);
      val = val % pct;
      res++;
    }

    cout << res << "\n";
  }
}


Measured memory_bytes: 37852
#include <iostream>
using namespace std;
int n, t, a, b, mn=1e9;
int main() {
	cin>>n>>t;
	while(n--) {
		cin>>a>>b;
		if(b<=t) mn = min(mn, a);
	}
	if(mn<1e9) cout<<mn;
	else cout<<"TLE";
	return 0;
}

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

using ll = long long;
using ull = unsigned long long;

vector<vector<int>> g;
int visit_cnt;
vector<int> parent;

void bfs(int s) {
    queue<int> que;
    set<int> visited;

    que.push(s);
    visited.insert(s);
    visit_cnt = 1;

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

        for (int v: g[u]) {
            if (!visited.count(v)) {
                parent[v] = u;
                visited.insert(v);
                que.push(v);
                ++visit_cnt; 
            }
        }
    }
}

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

    int n, m;
    cin >> n >> m;

    g.resize(n + 1);
    parent.resize(n + 1);

    for (int i = 0; i < m; ++i) {
        int u, v;
        cin >> u >> v;
        g[u].emplace_back(v);
        g[v].emplace_back(u);
    }

    bfs(1);

    if (visit_cnt < n) {
        cout << "No\n";
    } else {
        cout << "Yes\n";
        for (int i = 2; i <= n; ++i) {
            cout << parent[i] << "\n";
        }
    }

    return 0;
}

Measured memory_bytes: 14804
using System;
using System.Numerics;
namespace HelloWorld
{
    class Program
    {
        static void Main()
        {
            int line = int.Parse(Console.ReadLine());
            for (int i = 0; i < line; ++i)
            {
                var alpha = BigInteger.Parse(Console.ReadLine());
                var beta = BigInteger.Parse(Console.ReadLine());
                var gamma = alpha + beta;
                Console.WriteLine(gamma.ToString().Length > 80 ? "overflow" : gamma.ToString());
            }
        }
    }
}



Measured memory_bytes: 16040
#include <bits/stdc++.h>
#define ll long long
#define OPEN 0
using namespace std;
ll calc(ll a, ll b, ll c) {
	ll ans1 = 0;
	ll bound2 = (ll)b / c;
	if (bound2 == 0) {
		ans1 = 0;
	}
	else {

		ll bound1 = (ll)a / c;

		if (bound1 == 0) {
			ans1 = bound2;
		}
		else {
			if (a%c != 0) {
				bound1 += 1;
			}
			ans1 = bound2 - (bound1)+1;
		}
	}
	return ans1;
}
ll gcd(ll a, ll b) {
	return b == 0 ? a : gcd(b, a%b);
}
ll lcm(ll a, ll b) {
	return a*(b / gcd(a, b));    //注意b/gcd(a,b)括起来，防止a * b发生溢出
}
int main() {
#if OPEN
	freopen("in.txt", "r", stdin);
#endif
	ll a, b, c, d;
	cin >> a >> b >> c >> d;
	ll s1 = calc(a, b, c);
	ll s2 = calc(a, b, d);
	ll e = lcm(c, d);
	ll s3 = calc(a, b, e);
	cout << (b - a + 1) - (s1 + s2 - s3) << endl;
	return 0;
}

Measured memory_bytes: 256
k , n = map(int, input().split())
a = list(map(int, input().split()))
d = []

for i in range(1, n):
    y = a[i]
    x = a[i-1]
    d.append(y-x)
d.append(k - (a[n-1] - a[0]))
d.sort(reverse = True)
print(k-d[0])

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

int main() {
    int n;
    cin >> n;
    if (n / 100 == 7 || n % 100 / 10 == 7 || n % 100 % 10 == 7) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}

Measured memory_bytes: 3552
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int (i) = 0; (i) < (n); ++(i))
#define rrep(i,n) for(int (i) = (n) - 1; (i) >= 0; --(i)) //Reversi rep
#define nfor(i,a,b) for(int (i) = (a); (i) < (b); ++(i)) //Natural for
#define rfor(i,a,b) for(int (i) = (b); (i) >= (a); --(i)) //Reversi for

int main()
{
    int a,b;
    cin >> a >> b;
    if (a%3 == 0) {
        cout << "Possible" << endl;
    }else if (b%3 == 0){
        cout << "Possible" << endl;
    }else if ((a+b)%3 == 0){
        cout << "Possible" << endl;
    }else{
        cout << "Impossible" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
from collections import Counter
from collections import deque
from sys import stdin
from bisect import *
from heapq import *
import math

g   = lambda : stdin.readline().strip()
gl  = lambda : g().split()
gil = lambda : [int(var) for var in gl()]
gfl = lambda : [float(var) for var in gl()]
gcl = lambda : list(g())
gbs = lambda : [int(var) for var in g()]
mod = int(1e9)+7
inf = float("inf")


a, b, c, d = gil()
ans = -inf
for i in [a, b]:
	for j in [c, d]:
		ans = max(ans, i*j)
        
if a <= 0<=b or c <= 0 <= d :
	ans = max(0, ans)
    
print(ans)

Measured memory_bytes: 65572
#include <iostream>
#include <sstream>
#include <fstream>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
#include <numeric>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <cmath>
using namespace std;

int main() {
    int N, A, B, C, X;
    while ( cin >> N >> A >> B >> C >> X ) {
        if ( N == 0 && A == 0 && B == 0 && C == 0 && X == 0 ) break;
        vector <int> Y;
        int y;
        for ( int i = 0; i < N; i++ ) {
            cin >> y;
            Y.push_back(y);
        }

        int yi = 0;
        bool flag = true;
        for ( int i = 0; i <= 10000; i++ ) {
            if ( X == Y[yi] ) {
                yi++;
                if ( yi == N ) {
                    cout << i << endl;
                    flag = false;
                    break;
                }
            }
            X = ( A * X + B ) % C;
        }

        if ( flag ) {
            cout << -1 << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 0
# atcoder 動的計画法
# I Coins

import numpy as np


def get_inputs():
    # N コインの枚数
    # ps 各コインが表となる確率の配列(リスト)

    N = int(input())

    ps = list(map(float, input().split()))

    return N, ps


# 動的計画法の基づきテーブルを作成する
# dp[i][j] : i番目までのコインを投げた時に、j枚が表である確率
# 集める漸化式は下のようになる
# dp[i ][j ] = dp[i -1][j ]  *  (1 - p[i])  + dp[i - 1][j - 1] * p[i]
#
#

N, ps = get_inputs()

# dp = [[0.0] * (N + 1) for _ in range(N)]
dp = np.zeros((N, N + 1), dtype=float)

dp[0][1] = float(ps[0])
dp[0][0] = float(1.0 - ps[0])

for i in range(1, N):
    dp[i][:i + 2] = dp[i - 1][:i + 2] * (1 - ps[i])
    dp[i][1:i + 2] = dp[i - 1][:i + 1] * ps[i] + dp[i][1:i + 2]

print(sum(dp[N - 1][(N + 1) // 2:]))



Measured memory_bytes: 82656
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <cctype>
#include <cstring>
#define rep(i, m, n) for (int i = m; i < n; i++)
#define repr(i, n) for (int i = n; i >= 0; i--)
#define ll long long
#define ull unsigned long long
#define push(a) push_back(a)
#define pop(a) pop_back(a)
#define debug(x) cout << #x << ": " << x << endl
#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define INF 999999999
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

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

int a[3]={};

int main(){
    cin>>a[0]>>a[1]>>a[2];
    sort(a,a+3);
    if(a[0]==5&&a[1]==5&&a[2]==7){
        cout<<"YES"<<endl;
    }else{
        cout<<"NO"<<endl;
    }
    
}

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

using namespace std;
typedef long long LL;
const LL mod = 1e9+7;
const int MAXN = 2e5+25;
LL dp[MAXN],sum[MAXN],num[MAXN],a[MAXN];
int main()
{
    int n;cin>>n;
    for(int i = 1;i <= n; ++i) cin>>a[i];
    for(int i = 1;i <= n; ++i){
        if(a[i] == a[i-1]) dp[i] = dp[i-1];
        else{
            dp[i] = (dp[i-1] + num[a[i]] + sum[a[i]]) % mod;
            num[a[i]]++;
            sum[a[i]] = (sum[a[i]] + dp[i-1]) % mod;
        }
    }
    cout<<(dp[n] + 1) % mod;
    return 0;
}

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

int main()
{
    int a,b;
    cin>>a>>b;
    if(a==1)
        a=14;
    if(b==1)
        b=14;
    if(a>b)
        cout<<"Alice"<<endl;
    else if(a==b)
        cout<<"Draw"<<endl;
    else if(a<b)
        cout<<"Bob"<<endl;
    return 0;
}


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

int main() {
	int a, b;
	cin >> a >> b;
	if (a - b > 0)
		cout << "a > b" << endl;
	else if (a - b == 0)
		cout << "a == b" << endl;
	else
		cout << "a < b" << endl;
}


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

bool isPrime(int n) {
    if (n < 2)
        return false;
    else if (n == 2)
        return true;
    else if (n % 2 == 0)
        return false;

    for (int i = 3; i * i <= n; i++) {
        if (n % i == 0) return false;
    }
    return true;
}

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

    int likes[100001] = {0};
    for (int i = 1; i <= 1e5; i++) {
        likes[i] += likes[i - 1];
        if (isPrime(i) && isPrime((i + 1) / 2)) likes[i]++;
    }

    rep(i, q) {
        int l, r;
        cin >> l >> r;
        cout << likes[r] - likes[l - 1] << endl;
    }

    return 0;
}


Measured memory_bytes: 1024
/*
    Author:zeke

    pass System Test!
    GET AC!!
*/
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
using ll = long long;
using ld = long double;
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define rep3(var, min, max) for (ll(var) = (min); (var) < (max); ++(var))
#define repi3(var, min, max) for (ll(var) = (max)-1; (var) + 1 > (min); --(var))
#define Mp(a, b) make_pair((a), (b))
#define F first
#define S second
#define Icin(s) \
    ll(s);      \
    cin >> (s);
#define Scin(s) \
    ll(s);      \
    cin >> (s);
template <class T>
bool chmax(T& a, const T& b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T& a, const T& b) {
    if (b < a) {
        a = b;
        return 1;
    }
    return 0;
}
typedef pair<ld, ld> P;
typedef vector<ld> V;
typedef vector<V> VV;
typedef vector<P> VP;
ll mod = 1e9 + 7;
ll MOD = 1e9 + 7;
ll INF = 1e18;
ld EPS=0.001;
// cout << "Case #" << index << " :IMPOSSIBLE";
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
  
    cout << fixed << setprecision(10);
    ld a;
    ld b;
    cin>>a>>b;
    cout<<(ll)(a*b+EPS)<<endl;
}


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

using namespace std;

#define fori(x) for (int i = 0; i < x; ++i)
#define forj(x) for (int j = 0; j < x; ++j)

typedef long long ll;

const int INF = 2e9 + 5;
const int alength=100100;

int main() {
	int n,k;
	cin>>n>>k;
	cout<<(int)(n%k!=0);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>

using namespace __gnu_pbds;
using namespace std;
typedef long long ll;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> indexed_set;

#define mem(dp,a)           memset(dp,a,sizeof dp)
#define rep(i,a,b)          for(ll i=a;i<b;i++)
#define pb(x)               push_back(x)
#define mp(x,y)             make_pair(x,y)
#define fastio              ios_base::sync_with_stdio(false);cin.tie(NULL)
#define F                   first
#define S                   second
#define all(v)              (v).begin(),(v).end()
#define pi					3.14159265359
ll INF=1e18+10;
ll MOD=1000000007;

int main()
{
    int a,b;cin>>a>>b;
    int ans=max(0,a-2*b);
    cout<<ans;
}


Measured memory_bytes: 256
#include<cstdio>
#include<vector>
#include<algorithm>
#include<deque>

using namespace std;

using ll=long long;
using vi=vector<int>;
using vvi=vector<vi>;
using pii=pair<int,int>;
using vll=vector<ll>;
using vvll=vector<vll>;


const ll MOD=1000000007;
const int RANK_INFINITY=99999999;


class v_t
{
public:
	int rank;
	int p, x;
	ll t;
	vi c;
	v_t() : rank(RANK_INFINITY), p(-1), x(0), t(0LL) {}
};


using vv_t=vector<v_t>;


int min_u(int&m, int v)
{
	if(m>v)
	{
		m=v;
		return 1;
	}
	return 0;
}


vi hoge(vv_t&v)
{
	deque<int> c;
	int n=v.size()-1;
	vi ret;

	for(int j=1;j<=n;j++)
	{
		if(v[j].rank==RANK_INFINITY)
		{
			ret.push_back(j);
			v[j].rank=0;
			c.push_back(j);
			while(!c.empty())
			{
				int i=c.front();
				c.pop_front();
				for(auto&mvc:v[i].c)
				{
					if(mvc<0) continue;
					if(min_u(v[mvc].rank, v[i].rank+1))
					{
						v[mvc].p=i;
						c.push_back(mvc);
					}
					else
					{
						mvc=-1;
					}
				}
			}
		}
	}
	for(int i=1;i<=n;i++)
	{
		for(int j=0;j<v[i].c.size();j++)
		{
			while(v[i].c[j]<0 && j<v[i].c.size())
			{
				v[i].c[j]=v[i].c.back();
				v[i].c.pop_back();
			}
		}
	}
	return ret;
}


void disp_vt(v_t&v)
{
	printf("r=%d p=%d c=", v.rank, v.p);
	for(auto mc:v.c) printf("%d ", mc);
	printf("\n");
	printf("  x=%d t=%lld\n", v.x, v.t);
}


ll calc(vv_t&v, int i, int k)
{
	ll ret=1;

	if(v[i].p>=0)
	{
		v_t&vp=v[v[i].p];

		ret=k-min(2, v[i].rank)-vp.x;
		vp.x++;
	}
	else
	{
		ret=k;
	}

	for(int mc:v[i].c)
	{
		ret=(ret*calc(v, mc, k))%MOD;
	}
	return ret;
}


int main(void)
{
	int n, k;

	while(scanf("%d%d", &n, &k)==2)
	{
		vv_t v(n+1);
		vi root;

		for(int i=0;i<n-1;i++)
		{
			int a, b;

			scanf("%d%d", &a, &b);
			v[a].c.push_back(b);
			v[b].c.push_back(a);
		}

		root=hoge(v);

		ll ans=1LL;
		for(int mr:root)
		{
			ans=ans*calc(v, mr, k)%MOD;
		}
//		for(auto&mv:v) disp_vt(mv);
		printf("%lld\n", ans);
	}
	return 0;
}


Measured memory_bytes: 12672
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <assert.h>
#include <math.h>

/*

(と)しかない、辞書順だから(は左に、)は右に挿入すべき

再帰レベルを(すると+1、)すると-1

(を挿入するとそれ以降の再帰レベルを+1
)を挿入するとそれ以降の再帰レベルを-1

制約: レベル0未満になってはならない
最後のレベルは0でなければならない

すべての区間で再帰レベルが正の数になるように左端に(を挿入
再帰レベルが0になるように右端に)を挿入

 */
int main(void)
{
	int N,n;
	char S[1000];
	scanf("%d\n",&N);
	scanf("%s\n",S);
	int min_rec_level = 0;
	int curr_rec_level = 0;
	for (n=0;n<N;n++){
		if (S[n]=='('){
			curr_rec_level++;
		}
		else if (S[n]==')'){
			curr_rec_level--;
			if (min_rec_level > curr_rec_level)min_rec_level = curr_rec_level;
		}
		else assert(0);
	}
	//printf("%d %d\n",min_rec_level,curr_rec_level);
	int last_rec_level = curr_rec_level;
	int p1_add = 0;
	if (min_rec_level < 0){
		p1_add = -min_rec_level;
		for (n=0;n<p1_add;n++){
			printf("(");
		}
	}
	printf("%s",S);
	int p2_add = p1_add + last_rec_level;
	for (n=0;n<p2_add;n++){
		printf(")");
	}
	return 0;
}


Measured memory_bytes: 128
package main

import (
	"fmt"
	"bufio"
	"os"
	"strconv"
	"sort"
)

var sc = bufio.NewScanner(os.Stdin)

func euclidean(a, b int) int {
	x, y := a, b
	if x < y {
		x, y = y, x
	}
	if y == 0 {
		return x
	}
	return euclidean(y, x%y)
}

func main() {
	sc.Split(bufio.ScanWords)

	var n int
	fmt.Scan(&n)
	a := make([]int, n)
	for i := 0; i < n; i++ {
		sc.Scan()
		a[i], _ = strconv.Atoi(sc.Text())
	}

	l, r := make([]int, n+1), make([]int, n+1)
	l[0], r[n] = 0, 0
	for i := 0; i < n; i++ {
		l[i+1] = euclidean(l[i], a[i])
	}
	for i := n; i > 0; i-- {
		r[i-1] = euclidean(r[i], a[i-1])
	}

	gcd := make([]int, n)
	for i := 0; i < n; i++ {
		gcd[i] = euclidean(l[i], r[i+1])
	}

	sort.Ints(gcd)
	fmt.Println(gcd[n-1])
}



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

int main() {
    int n;
    cin >> n;
    vector<int> r(n);
    for(auto& i : r) cin >> i;
    vector<vector<int>> a(3, vector<int>(n));
    for(int j = 0; j < n; j++) for(int i = 0; i < 3; i++) cin >> a[i][j];
    
    auto solve = [&](){
        vector<int> point(n), idx(n);
        iota(idx.begin(), idx.end(), 0);
        for(int i = 0; i < 3; i++){
            auto b = a[i];
            sort(b.begin(), b.end(), greater<int>());
            for(int j = 0; j < n; j++) point[j] += r[lower_bound(b.begin(), b.end(), a[i][j], greater<int>()) - b.begin()];
        }
        int rank = 1;
        for(int j = 1; j < n; j++) rank += point[j] > point[0];
        return rank;
    };
    
    for(int i = 1; i <= 100; i++){
        for(int j = 0; j < 3; j++){
            a[j][0] += i;
            if(solve() < 9){
                cout << i << endl;
                return 0;
            }
            a[j][0] -= i;
        }
    }
    puts("Saiko");
}


Measured memory_bytes: 3156
import java.io.*;
import java.util.*;

class Main
{
    public static void main (String[] args) throws Exception
    {
        BufferedReader bu=new BufferedReader(new InputStreamReader(System.in));
        StringBuilder sb=new StringBuilder();
        String s[]=bu.readLine().split(" ");
        int n=Integer.parseInt(s[0]),k=Integer.parseInt(s[1]);
        int i,a[]=new int[n];
        s=bu.readLine().split(" ");
        for(i=0;i<n;i++)
        a[i]=Integer.parseInt(s[i]);
        Queue<Integer> q=new LinkedList<>();
        for(i=0;i<k;i++)
        q.add(a[i]);
        for(i=k;i<n;i++)
        {
            if(a[i]>q.peek()) sb.append("Yes\n");
            else sb.append("No\n");
            q.poll();
            q.add(a[i]);
        }
        System.out.print(sb);
    }
}

Measured memory_bytes: 63568
#include <bits/stdc++.h>
using namespace std;
#define mp(a, b) make_pair(a, b)
typedef pair<double, int> pdi;
const int maxn = 1000 + 10;
const double INF = 1e18;
struct cir
{
	double x, y, r;
}a[maxn];
int n;
vector<pdi> E[maxn];
double dis[maxn];
bool vis[maxn];
double sqr(double x) { return x * x;}
double calc(int i, int j)
{
	double dist = sqrt(sqr(a[i].x - a[j].x) + sqr(a[i].y - a[j].y));
	return max(dist - a[i].r - a[j].r, 0.0);
}
double dij()
{
	priority_queue<pdi> Q;
	for(int i = 1; i <= n + 2; ++i) dis[i] = INF;
	dis[1] = 0;
	Q.push(mp(-dis[1], 1));
	while(!Q.empty())
	{
		auto x = Q.top(); Q.pop();
		if(vis[x.second]) continue;
		vis[x.second] = 1;
		for(auto e : E[x.second])
			if(dis[x.second] + e.first < dis[e.second])
			{
				dis[e.second] = dis[x.second] + e.first;
				Q.push(mp(-dis[e.second], e.second));
			}
	}
	return dis[2];
}		
int main()
{
	cin >> a[1].x >> a[1].y >> a[2].x >> a[2].y;
	cin >> n;
	for(int i = 3; i <= n + 2; ++i) cin >> a[i].x >> a[i].y >> a[i].r;
	for(int i = 1; i <= n + 2; ++i) 
		for(int j = i; j <= n + 2; ++j)
		{
			double dis = calc(i, j);
			E[i].push_back(mp(dis, j));
			E[j].push_back(mp(dis, i));
		}
	printf("%.10lf\n", dij());
	return 0;
}

Measured memory_bytes: 23796
import java.util.*;
 
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
        
        int n = sc.nextInt();
        int b[] = new int[n-1];

        for (int i = 0; i < n-1; i++) {
            b[i] = sc.nextInt();
        }

        int sum = b[0] + b[n-2];

        for (int i = 0; i < n-2; i++) {
            sum += Math.min(b[i], b[i+1]);
        }

        System.out.println(sum);
	}
}


Measured memory_bytes: 23764