akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define XOX
using namespace std;

#define fast ios_base::sync_with_stdio(false),cin.tie(NULL)
#define ldb long double 
#define db double
#define int long long

#define fr first
#define se second
#define lb lower_bound 
#define ub upper_bound 
#define pb push_back
#define mpr make_pair

#define pi pair<int,int>
#define pdb pair<db,db>
#define pldb pair<ldb,ldb>

#define vi vector<int>
#define vdb vector<db>
#define vldb vector<ldb>
#define vpi vector< pi >

#define mi map<int,int>
#define mdb map<db,db>
#define mldb map<ldb,ldb>


#define forr(a,b) for (int i = (a); i < (b); ++i)
#define rrof(a,b) for (int i = (b)-1; i >= (a); --i)

#define sz(x) (int)x.size()
#define all(x) begin(x), end(x)

const int md = 1e9+7;
const int MX = 2e5+5;
const int INF = 1e18; 
const ldb PI = 4*atan((ldb)1);

int power_md(int a,int n)
{
 int res=1;
 while(n)
{
 if(n%2)
  res=(res%md*a%md)%md;
  a=(a%md*a%md)%md;
  n/=2;
}
res%=md;
return res;
}

int power(int a,int n)
{
 int res=1;
 while(n)
{
 if(n%2)
  res*=a;
  a=a*a;
  n/=2;
}
return res;
}

int abst(int a)
{
 return ((a<0)?(-1*a):(a));
}

class cmp_set{
public:
	bool operator() (int a, int b){
		return a > b;
	}
};

vector<string> vec_splitter(string s) {
	s += ',';
	vector<string> res;
	while(!s.empty()) {
		res.push_back(s.substr(0, s.find(',')));
		s = s.substr(s.find(',') + 1);
	}
	return res;
}
void debug_out(
vector<string> __attribute__ ((unused)) args,
__attribute__ ((unused)) int idx, 
__attribute__ ((unused)) int LINE_NUM) { cerr << endl; } 
template <typename Head, typename... Tail>
void debug_out(vector<string> args, int idx, int LINE_NUM, Head H, Tail... T) {
	if(idx > 0) cerr << ", "; else cerr << "Line(" << LINE_NUM << ") ";
	stringstream ss; ss << H;
	cerr << args[idx] << " = " << ss.str();
	debug_out(args, idx + 1, LINE_NUM, T...);
}
#ifdef XOX
#define debug(...) debug_out(vec_splitter(#__VA_ARGS__), 0, __LINE__, __VA_ARGS__)
#else
#define debug(...) 42
#endif

int fun(int i)
{
    if(i%2)
     return (3*i+1);
     else
      return (i/2);
}

int32_t main()
{
   int s;
   cin>>s;
   map< int,int > mp;
   mp[s]++;
   int prev=s;
   int c=1;
   while(1)
   {
       c++;
       int p=fun(prev);
       if(mp.count(p)!=0)
       {
           cout<<c<<"\n";
           break;
       }
       else
       {
           mp[p]++;
           prev=p;
       }
   }
    return 0; 
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, srt, end) for (long long i = (srt); i < (long long)(end); i++)
#define VL vector<ll>
#define VS vector<string>
#define VB vector<bool>
#define VP vector<pair<ll,ll>>
#define VVL vector<vector<ll>>
#define VVP vector<vector<pair<ll,ll>>>
#define PL pair<ll,ll>
#define ALL(v) (v).begin(), (v).end()

string S, T;
vector<string> v;
 
int main() {
    cin.tie(0); ios::sync_with_stdio(false);
    cin >> S >> T;
    rep(i,0,S.size()-T.size()+1) {
        bool flag = true;
        rep(j,0,T.size()) {
            if (S[i+j]=='?') continue;
            else flag &= S[i+j]==T[j];
        }
        if (flag) {
            string s = "";
            rep(j,0,S.size()) {
                if (i<=j && j<i+T.size()) s += T[j-i];
                else {
                    if (S[j]=='?') s += "a";
                    else s += S[j];
                }
            }
            v.push_back(s);
        }
    }
    sort(v.begin(), v.end());
    if (v.size()==0) cout << "UNRESTORABLE" << endl;
    else cout << v[0] << endl;
    return 0;
}

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

namespace Contest
{
    class ABC
    {
        static void Main()
        {
            Solve();
        }
        private static void Solve()
        {
            string s = Console.ReadLine();
            string t = Console.ReadLine();
            int res = 0;
            for(int i = 0; i < 3; i++)
            {
                if (s[i] == t[i]) res++;
            }
            Console.WriteLine(res);
        }
        
    }
}


Measured memory_bytes: 11092
#include <bits/stdc++.h>
#define all(v) (v).begin(),(v).end()
using namespace std;
using LL = long long;
const int INF = 1e9;

int main(void)
{
    LL N, M;
    string S;
    cin >> N >> M;
    cin >> S;

    vector<LL> stop;
    stop.push_back(N);
    LL current = N;
    while (current > 0) {
        bool move = false;
        for (LL i = min(current, M); i >= 1; i--) {
            if (S[current-i] == '0') {
                current = current-i;
                move = true;
                stop.push_back(current);
                break;
            }
        }
        if (move == false) {
            cout << -1 << endl;
            return 0;
        }
    }
    for (int i = stop.size()-1; i > 0; i--) {
        cout << stop[i-1] - stop[i] << " ";
    }
    cout << endl;
    return 0;
}



Measured memory_bytes: 1528
import java.util.*;
public class Main {

    private static List<Set<Integer>> setList = new ArrayList<Set<Integer>>();
    public static void main(String[] args) {
        //System.out.println(new App().getGreeting());
        Scanner s = new Scanner(System.in);
        int num = s.nextInt();
        int query = s.nextInt();

        //初期セット完了
        //命令処理開始
        for(int i=0;i<query;i++)
        {
            boolean result=false;
            switch(s.nextInt())
            { 
                case 0:
                    result = unite(s.nextInt(),s.nextInt());
                break;
                case 1:
                    result = same(s.nextInt(),s.nextInt());
                    System.out.println(result?1:0);
                break; 
            }
        }
    }
    private static boolean unite(int x,int y)
    {
        Set<Integer> xSet =null;
        Set<Integer> ySet =null;
        for(Set<Integer> tmpSet:setList)
        {
            //xが含まれているか？
            if(tmpSet.contains(x))
            {
                xSet = tmpSet;
                if(ySet!=null)
                {
                    break;
                }
            }
            //yが含まれているか？
            if(tmpSet.contains(y))
            {
                ySet = tmpSet;
                if(xSet!=null)
                {
                    break;
                }
            }
        }
        if(xSet==null&&ySet==null)
        {
            Set<Integer>tmpHashSet = new HashSet<Integer>();
            tmpHashSet.add(x);
            tmpHashSet.add(y);
            setList.add(tmpHashSet);
            return true;
        }
        if(xSet==null){
            ySet.add(x);
            return false;
        }
        if(ySet==null){
            xSet.add(y);
            return false;
        }
        if(xSet.equals(ySet))return false;
        //xSetもySetもnullではない
        xSet.addAll(ySet);
        setList.remove(ySet);
        return true;
    }
    private static boolean same(int x,int y)
    {
        for(Set<Integer> tmpSet:setList)
        {
            //xが含まれているか？
            if(tmpSet.contains(x))
            {
                if(tmpSet.contains(y))
                {
                    return true;
                }
                else
                {
                    return false;
                }
            }
        }
        return false;
    }
}


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

const int mxn = 3e3 + 5;
long long int dp[mxn][mxn][2]; // the maxi value if there are from i to j elements on player kth turn
	// [0] = maximize the valuse [1]--> minimize the value

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

	for(int i =0;i<=n;i++)
		for(int j =0;j<=n;j++){
			dp[i][j][0] = -1e18;
			dp[i][j][1] = 1e18;
		}
	for(int i =0;i<=n;i++){
		dp[i][i][0] = a[i-1];
		dp[i][i][1] = -a[i-1];
	}

	for(int j =1;j<=n;j++){
		for(int i = j-1;i>0;i--){
			dp[i][j][0] = max(a[i-1]+dp[i+1][j][1],max(a[j-1]+dp[i][j-1][1],dp[i][j][0]));
			dp[i][j][1] = min(dp[i+1][j][0]-a[i-1],min(dp[i][j-1][0] - a[j-1],dp[i][j][1]));

			
		}
		// cout << endl;
	}

	// for(int i=1;i<=n;i++){
	// 	for(int j =1;j<=n;j++){
	// 		cout <<"( "<< dp[i][j][0] << " , " << dp[i][j][1] << ")";
	// 	}
	// 	cout << endl;
	// }

	cout << dp[1][n][0] << endl;
}

Measured memory_bytes: 141184
n = int(input())
num_list = sorted([ int(v) for v in input().split() ])
ope_list = [ None for i in range(n-1) ]

for i in range(n-2):
    if num_list[i+1] >= 0:
        ope_list[i] = (num_list[0],num_list[i+1])
        num_list[0] -= num_list[i+1]
    else:
        ope_list[i] = (num_list[-1],num_list[i+1])
        num_list[-1] -= num_list[i+1]

ope_list[-1] = (num_list[-1], num_list[0])
ans = num_list[-1] - num_list[0]
print(ans)
for i in range(n-1):
    print(*ope_list[i])

Measured memory_bytes: 61756
import java.util.Scanner;

class Main{
    public static void main(String[] args) throws Exception{

        int num = 10000;

        Scanner sc = new Scanner(System.in);

        for (int i = 1; i <= num; i++) {
            int x = sc.nextInt();
            if(x == 0){
                break;
            }
            System.out.println("Case "+ i + ": " + x);
        }


    }
}

Measured memory_bytes: 42092
#include <iostream>
#include <string>
#include<vector>
#include<algorithm>
#include<utility>
#include<queue>
#include<math.h>
#include<stack>
#include<set>
#include<map>
#define INF 2e9
#define rep(i,n,m) for(int i=n;i<m;i++)

using namespace std;

int main()
{
	int n;
	string s;
	vector<int>R, G, B;
	cin >> n >> s;
	rep(i, 0, n)
	{
		switch (s[i])
		{
		case 'R':R.push_back(i + 1); break;
		case 'G':G.push_back(i + 1); break;
		case 'B':B.push_back(i + 1); break;
		}
	}

	long long int ans;
	ans = R.size() * G.size() * B.size();
	rep(i,0,n)
		rep(j, i, n)
	{
		int k = 2 * j - i;
		if (j <= k && k < n)if (s[i] != s[j] && s[k] != s[j] && s[i] != s[k])ans--;
	}
	cout << ans << endl;
	return 0;
}


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

typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<string> vs;

#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define all(x) (x).begin(),(x).end()
constexpr auto INF = 2000000000;
constexpr auto MOD = 1000000007;

int gcd(int i, int j) {
	if (i < j)swap(i, j);
	if (j == 0)return i;
	if (i % j)return gcd(j, i % j);
	else return j;
}

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

	vi l(n+1), r(n+1);
	l[0] = 0;r[0] = 0;

	rep(i, n) {
		l[i + 1] = gcd(l[i], a[i]);
		r[i + 1] = gcd(r[i], a[n-1-i]);
	}

	int ans = 1;

	rep(i, n) {
		ans = max(ans, gcd(l[i], r[n - 1 - i]));
	}

	cout << ans << endl;
}

Measured memory_bytes: 1408
#include"bits/stdc++.h"
#include"math.h"
using namespace std;

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

#define REP(i,m,n) for(ll i = m; i < (ll)(n);++i)
#define rep(i,n) REP(i,0,n)
#define all(v) v.begin(),v.end()

int main(){
  
  int n,x;cin >> n >> x;
  vector<int>a(n);rep(i,n)cin >> a[i];
  ll ans = 0;
  REP(i,1,n){
    if(a[i-1]+a[i]>x){
      int dif=a[i]+a[i-1]-x;
      if(dif>a[i]){
        a[i]=0;
      }
      else{
        a[i]-=dif;
      }
      ans += dif;
    }
  }
  cout << ans << endl;
}


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

using namespace std;

#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n) for(int i=s;i<n;i++)
#define all(a) (a).begin(),(a).end()

typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<double> vd;
typedef vector<vd> vvd;

int main()
{
	int n,m;
	cin >> n >> m;
	cout << n*(n-1)/2 + m*(m-1)/2 << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h> 
//#define <- プログラムの文字列を置換する
//typedef <- 新しい型に名前を付けるためのキーワード

using namespace std;

typedef long long ll;
typedef pair<int,int> pii;
typedef pair<pair<int,int>,int> ppiii;

const long long MOD = 1e9 + 7;
const long long INF = 1e12;
const int INF_INT = 1e9;

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

template<class TYPE>
struct edge{
    TYPE to,cost; 
    edge(TYPE t,TYPE c){
        to = t;
        cost = c;
    }
};

int main(){
    ll S;
    cin >> S;
    ll res[S + 10];
    for(int i = 0; i <= S + 10 ; i++) res[i] = 1;
    res[0] = res[1] = res[2] = 0;
    ll sub = res[3];
    for(int i = 6; i <= S + 10; i++){
        res[i] = (res[i] + sub) % MOD;
        sub = (sub + res[i - 2]) % MOD;
    }
    cout << res[S] << endl;
    return 0;
}


Measured memory_bytes: 3620
#include<iostream>
#include<vector>
#include<algorithm>
#include<cmath>
#include<string>
#include<tuple>
#include<utility>
#include<stack>
#include<set>
#include<iomanip>
using ll=long long int;
using namespace std;


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

	set <int > a;
	for (int i = 0; i < n; i++) {
		int d;
		cin >> d;
		a.insert(d);
	}

	cout << a.size() << endl;

	return 0;
}





Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main() {
	int N, M;
	cin >> N >> M;
	for (int i = 0; i < M; i++) {
		int a = 0;
		cin >> a;
		N = N - a;
	}
	if (N < 0) {
		cout << -1 << endl;
	}
	else {
		cout << N << endl;
	}
	return 0;
}

Measured memory_bytes: 3624
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner scan = new Scanner(System.in);
		int A = scan.nextInt();
		int B = scan.nextInt();
		int sum =0;
		for ( int i=0;i<2;i++){
			if(A>B){
				sum+=A;
				A=A-1;
			}else{
				sum+=B;
				B=B-1;
			}
		}
		System.out.println(sum);

	}
}



Measured memory_bytes: 23636
#include<stdio.h>
int main()
{
    int a,b,c;
    scanf("%d%d%d",&a,&b,&c);
    if(a<=b&&b<=c) printf("%d\n",a+b);
    else if(a<=c&&c<=b) printf("%d\n",a+c);
    else if(b<=c&&c<=a) printf("%d\n",b+c);
   else if(b<=a&&a<=c) printf("%d\n",a+b);
    else if(c<=a&&a<=b) printf("%d\n",a+c);
    else printf("%d\n",b+c);
    return 0;
    }

Measured memory_bytes: 128
class UnionFind:
    def __init__(self, n):
        self.par = [i for i in range(n)]
        self.rank = [0]*n
    def check(self, x, y):
        if self.find(x) == self.find(y):
            # print('x, yの親は',self.par[x], self.par[y])
            return True
        else:
            return False
    def find(self, x):
        if x == self.par[x]:
            return x
        else:
            self.par[x] = self.find(self.par[x])
            return self.par[x]
    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if self.rank[x] > self.rank[y]:
            self.par[y] = x
        else:
            self.par[x] = y
            if self.rank[x] == self.rank[y]:
                self.rank[x] += 1

                
n, m = map(int, input().split())
uf = UnionFind(n)
ans = 0
G = []

for i in range(m):
    a, b = map(int, input().split())
    G.append((a-1, b-1))
# print()
for i in range(m):
    uf = UnionFind(n)
    for j in range(m):
        if i==j:
            continue
        uf.union(G[j][0], G[j][1])
    # print(uf.par)
    if not uf.check(G[i][0], G[i][1]):
        # print(G[i][0]+1, G[i][1]+1)
        ans += 1
print(ans)

        
        

Measured memory_bytes: 68996
/* ****GT_18**** */

#include<bits/stdc++.h>
#define ll          long long
#define pb          push_back
#define	endl		'\n'
#define pii         pair<ll int,ll int>
#define vi          vector<ll int>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (ll int)x.size()
#define hell        1000000007
#define INF			1000000000000
#define rep(i,a,b)	for(ll int i=a;i<b;i++)
#define lbnd        lower_bound
#define ubnd        upper_bound
#define bs          binary_search
#define mp          make_pair
using namespace std;

#define N  100005

ll n;
ll k;
ll h[N];
ll dp[N];


ll solve(ll pos){
	if(dp[pos]!=-1)return dp[pos];
	if(pos==0)return dp[pos]=0;
	ll ans=INF;
	for(ll i=pos-1;i>=max(0LL,pos-k);i--){
		ans=min(ans,solve(i)+abs(h[pos]-h[i]));
	}
	return dp[pos]=ans;
}


int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int TESTS=1;
//	cin>>TESTS;
	rep(i,0,N)dp[i]=-1;
	while(TESTS--)
	{
			cin>>n>>k;
			rep(i,0,n){
				cin>>h[i];
			}	
			cout<<solve(n-1)<<endl;
	}
	return 0;
}

Measured memory_bytes: 9856
#include <bits/stdc++.h>
    using namespace std;
    #define watch(x) cerr << (#x) << " is " << x << '\n';
    #define int long long 
    const int mod = 1e9+7;
    vector<vector<int>> dp1,dp2;
    int32_t main(){
    	ios_base::sync_with_stdio(false);
    	cin.tie(NULL);cout.tie(NULL);
       	int n,m,h;
       	cin>>n>>m>>h;
       	cout << h / (max(n,m)) + (h%max(n,m)!=0)<< endl;
        return 0;
    }

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{long long n=0,s=0,s1=0;
    cin>>n;
    long long a[n],a1[n];
    for(long long j=0;j<n;j++)
    {
        cin>>a[j];
        s+=a[j];
        a1[j]=s;
    }
    for(long long j=0;j<n-1;j++)
    {
        s1=((s1%(1000000007))+((((a[j]%(1000000007))*((a1[n-1]-a1[j])%1000000007))%1000000007)%1000000007))%1000000007;
        
    }
    cout<<s1;
}

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


if __name__ == '__main__':

    n = int(input())
    p = [0]
    for _ in range(n):
        r, c = list(map(int, input().split(" ")))
        p[-1] = r
        p.append(c)
    m = [[0 for i in range(n+1)] for j in range(n+1)]
    
    for i in range(1, n+1):
        m[i][i] = 0
    
    for l in range(2, n+1):
        for i in range(1, n-l+2):
            j = i + l - 1
            m[i][j] = float("inf")
            for k in range(i, j):
                m[i][j] = min(m[i][j], m[i][k] + m[k+1][j] + p[i-1]*p[k]*p[j])

    print(m[1][n])





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

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

using ll = long long;

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

int main(){
  int N, Q;
  cin>>N>>Q;
  string S;
  cin>>S;
  vector<vector<int>> v(Q,vector<int>(2));
  for(int i = 0; i < Q; i++) {
    cin>>v.at(i).at(0)>>v.at(i).at(1);
  }
  vector<int> pla(N+1,0);
  for(int i = 2; i <= N; i++) {
    pla.at(i)=pla.at(i-1);
    if(S[i-2]=='A'&&S[i-1]=='C') pla.at(i)++;
  }
  for(int i = 0; i < Q; i++) {
    cout<<pla.at(v.at(i).at(1))-pla.at(v.at(i).at(0))<<endl;
  }
}

Measured memory_bytes: 6784
/*#include <iostream>
#include <cmath>
#include <vector>
#include <algorithm>
#include <array>
#include <vector>
#include <deque>
#include <set>
#include <map>
#include <string>
#include <stack>
#include <queue>
#include <unordered_map>
#include <unordered_set>
*/

#include <bits/stdc++.h>
using namespace std;

#define int long long
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define FOR(i,a,b) for(int (i)=(a);(i)<(b);(i)++)
#define REP(i,n) FOR(i,0,n)
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define SORT(c) sort((c).begin(),(c).end())

typedef long long ll;
const ll INF = LLONG_MAX - 100;
const ll mod = 1e9 + 7;
const int MAX_N = 5e5 + 5;
int dx[] = { -1LL,0,1LL,0 }, dy[] = { 0,1LL,0,-1LL };
vector<ll> prime;

ll inv[MAX_N], fac[MAX_N];

inline ll GCD(ll a, ll b) { ll c; while (b != 0) { c = a % b; a = b; b = c; }return a; }
inline ll LCM(ll a, ll b) { return a * b / GCD(a, b); }
inline ll POW(ll a, ll b) { ll c = 1LL; while (b > 0) { if (b & 1LL) { c = a * c%mod; }a = a * a%mod; b >>= 1LL; }return c; }
inline void _nCr() { fac[0] = 1LL; for (int i = 1LL; i < MAX_N; i++) { fac[i] = fac[i - 1LL] * i%mod; }for (int i = 0; i < MAX_N; i++) { inv[i] = POW(fac[i], mod - 2); } }
inline ll nCr(ll n, ll r) { return (fac[n] * inv[r] % mod)*inv[n - r] % mod; }
inline void PRI(ll n) { bool a[n + 1LL]; for (int i = 0; i < n + 1LL; i++) { a[i] = 1LL; }for (int i = 2; i < n + 1LL; i++) { if (a[i]) { prime.pb(i); ll b = i; while (b <= n) { a[b] = 0; b += i; } } } }

signed main() {
	string s; cin >> s;
	int tmp = 0;
	vector<int> xc;
	vector<char> ch;
	REP (i,s.size()) {
		if (s[i] == 'x') {
			tmp++;
		} else {
			xc.push_back(tmp);
			ch.push_back(s[i]);
			tmp = 0;
		}
	}
	xc.push_back(tmp);
	bool ok = true;
	int ans = 0;
	REP (i,ch.size()/2+2) {
		if (i <= (int)ch.size()-i-1) {
			if (ch[i] != ch[ch.size()-1-i]) {ok = false;}
		}
		if (i <= (int)xc.size()-1-i) {
			ans += abs(xc[i]-xc[xc.size()-i-1]);
		}
	}
	if (!ok) cout << -1 << endl;
	else cout << ans << endl;
}


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


static int Partition(int A[], int p, int r) {
    int x = A[r];
    int i = p - 1;

    for ( int j = p; j < r; j++ ) {
        if ( A[j] <= x ) {
            i = i + 1;
            int t = A[i];
            A[i] = A[j];
            A[j] = t;
        }
    }
    int t = A[i+1];
    A[i+1] = A[r];
    A[r] = t;

    return i + 1;
}

int main(void) {
    int i;
    int n;
    int r;
    int k = 0;
    int *A;

    scanf("%d\n", &n);
    A = malloc(sizeof(int) * (n + 1));

    for ( i = 0; i < n; i++ ) {
        int d;
        scanf("%d", &d);
        A[i] = d;
        if ( d > k ) {
            k = d;
        }
        (void)fgetc(stdin);
    }

    r = Partition(A, 0, n - 1);

    for ( i = 0; i < n; i++ ) {
        if ( i == r ) {
            printf("[%d]", A[i]);
        } else {
            printf("%d", A[i]);
        }
        if ( i + 1 < n ) {
            printf(" ");
        }
    }
    printf("\n");

    free(A);

    return 0;
}



Measured memory_bytes: 2140
#include<bits/stdc++.h>
#include<boost/algorithm/string/replace.hpp>
#include<boost/multiprecision/cpp_int.hpp>
using namespace std;
using namespace boost::algorithm;
using namespace boost::multiprecision;
 
#define rep(i,n) for(int i=0 ; i<(n) ; i++)
#define repr(i,n) for(int i=(n) ; i>=0 ; i--)
#define ALL(x) (x).begin(),(x).end()

typedef long long ll;
typedef unsigned long long ull;
 
const int INF = 1e9;
const int MOD = 1e9+7;

//C++17
template<typename Type>
Type GCD(Type a,Type b){ return b ? GCD(b,a%b) : a ;}
template<typename Type>
Type LCM(Type a,Type b){ return a*b / GCD(a,b) ;}

template<typename Type>//文字列の置換/Boost:replace_all()
Type replace_str(Type str, string target, string str_to) {
    string::size_type pos = 0;
    while (pos = str.find(target, pos), pos != string::npos) {
        str.replace(pos, target.length(), str_to);
        pos += str_to.length();
    }
    return str;
}

int main() {
    int x,a;cin >> x >> a;
    if(x<a)cout << 0 << endl;
    else cout << 10 << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return true; } return false; }
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define mp make_pair
#define si(x) int(x.size())
const int mod=1000000007,MAX=100005,INF=1<<30;

int main(){
    
    std::ifstream in("text.txt");
    std::cin.rdbuf(in.rdbuf());
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int N;cin>>N;
    set<pair<int,int>> sum;
    vector<int> A(N),B(N),ans(N),ca(N+1),cb(N+1),cc(N+1);
    for(int i=0;i<N;i++){
        cin>>A[i];
        ca[A[i]]++;
        cc[A[i]]++;
    }
    for(int i=0;i<N;i++){
        cin>>B[i];
        cb[B[i]]++;
        cc[B[i]]++;
    }
    
    for(int i=1;i<=N;i++){
        if(cc[i]&&cb[i]) sum.insert(mp(cc[i],i));
        
        if(cc[i]>N){
            cout<<"No"<<endl;
            return 0;
        }
        
    }
    
    cout<<"Yes"<<endl;
    
    for(int i=0;i<N;i++){
        auto it=sum.end();
        it--;
        
        while((*it).se==A[i]) it--;
        
        ans[i]=(*it).se;
        
        sum.erase(*it);
        cc[ans[i]]--;
        cb[ans[i]]--;
        if(cc[ans[i]]&&cb[ans[i]]) sum.insert(mp(cc[ans[i]],ans[i]));
        
        sum.erase(mp(cc[A[i]],A[i]));
        cc[A[i]]--;
        ca[A[i]]--;
        if(cc[A[i]]) sum.insert(mp(cc[A[i]],A[i]));
        
    }
    
    for(int i=0;i<N;i++) cout<<ans[i]<<" ";
    cout<<endl;
    
}


Measured memory_bytes: 17116
#include <iostream>
#include <cstdio>
#define N 100005
using namespace std;

typedef long long ll;
ll n, m, ans, a[N], mx[N], mx2[N], s[N];
int main()
{
	ll i;
	cin >> n >> m;
	for (i = 1; i <= n; i++) {
		scanf ("%lld", &a[i]);
		s[i] = s[i - 1] + a[i];
		mx[i] = max(mx[i - 1], mx[i - 1] + a[i]);
	}
	for (i = n; i >= 1; i--) {
		mx2[i] = max(mx2[i + 1], mx2[i + 1] + a[i]);
	}
	for (i = 1; i <= n - m + 1; i++) {
		ans = max(ans, mx[i - 1] + mx2[i + m] + max(s[i + m - 1] - s[i - 1], 0ll));
	}
    cout << ans;
    return 0;
}


Measured memory_bytes: 3328
#include<iostream>
#include<math.h>
#include<algorithm>
#include<stdint.h>
#include<vector>
#include<deque>
#include<stack>
#include<string>
#include<cstring>
#include<time.h>
#include<iomanip>
#include<list>
#include<set>
#include<unordered_map>
#include<unordered_set>
#include<random>
#include<bitset>
#include <queue>
#include <map>


using namespace std;
using ll = long long;
using ull = unsigned long long;
using uint = unsigned int;
using ldouble = long double;

#define repi(i,a,b) for(ll i = (a); i < (b); i++)
#define rep(i, n) for(ll i = 0; i < (n); ++i)

int main() {
    int n, k;
    cin >> n >> k;
    int cur = (n - 1) * (n - 2) / 2;
    if (cur < k) {
        cout << -1 << endl;
        return 0;
    }
    int c = 0;
    vector<pair<int, int>> link;
    repi(i, 1, n) link.push_back(pair<int, int>(0, i));
    repi(i, 1, n - 1)repi(j, i + 1, n) {
        if (cur - c == k) goto END;
        link.push_back(pair<int, int>(i, j));
        c++;
    }
END:
    cout << link.size() << endl;
    for (pair<int, int> p : link) {
        cout << p.first+1 << " " << p.second+1 << endl;
    }
    return 0;
}



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

int main() {
  int A, B, C, X;
  cin >> A >> B >> C >> X;
  int res = 0;
  for (int a = 0; a <= A; ++a) {
    for (int b = 0; b <= B; ++b) {
      for (int c = 0; c <= C; ++c) {
        int total = 500*a + 100*b + 50*c; // 合計金額
        if (total == X) ++res; // 合計金額が X に一致したら答えをインクリメント
      }
    }
  }
  cout << res << endl;
}


Measured memory_bytes: 3600
#include <iostream>

using namespace std;

int main(){
    int H,W;
    while(H!=0||W!=0){
        cin>>H>>W;
        if(H==0&&W==0)break;
        for(int i=0;i<H;i++){
            for(int v=0;v<W;v++){
                if(v!=W-1)cout<<"#";
                if(v==W-1)cout<<"#"<<endl;
            }
        }
        cout<<endl;
    }
    return 0;
}



Measured memory_bytes: 3076
#define _USE_MATH_DEFINES
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <complex>
#include <string>
#include <vector>
#include <array>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
#include <iterator>
#include <memory>
#include <regex>
using namespace std;

int main()
{
    int h, w;
    cin >> h >> w;

    vector<string> s(h, string(w, ' '));
    vector<bool> a(h, false), b(w, false);
    for(int y=0; y<h; ++y){
        for(int x=0; x<w; ++x){
            cin >> s[y][x];
            if(s[y][x] == '#'){
                a[y] = true;
                b[x] = true;
            }
        }
    }
    
    for(int y=0; y<h; ++y){
        if(!a[y])
            continue;
        for(int x=0; x<w; ++x){
            if(b[x])
                cout << s[y][x];
        }
        cout << endl;
    }

    return 0;
}


Measured memory_bytes: 256
import sys
def input(): return sys.stdin.readline().rstrip()

def main():
    N = int(input())
    V = tuple(map(int, input().split()))
    C = tuple(map(int, input().split()))

    ans = 0
    for v, c in zip(V, C):
        ans += max(v-c, 0)
    print(ans)

if __name__ == '__main__':
    main()


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

int main()
{
	int n,m,temp;
	cin>>n>>m;
	
	string s;
	
	vector<pair<int,string> >arr;
	
	bool vis[n+1];
	memset(vis,false,sizeof(vis));
	int cwa[n+1];
	memset(cwa,0,sizeof(cwa));
	
	for(int i=0;i<m;i++)
	{
		cin>>temp>>s;
		arr.push_back({temp,s});
	}
	
	int  ac=0,penal=0;
	for(int i=0;i<m;i++)
	{
		if(arr[i].second=="AC" && !vis[arr[i].first])
		{
			ac++;
			vis[arr[i].first]=true;
		}
		if(arr[i].second=="WA" && !vis[arr[i].first])
		{
			cwa[arr[i].first]++;
		}
	}
	for(int i=1;i<=n;i++)
	{
		if(vis[i])
		{
			penal+=cwa[i];
		}
	}
	cout<<ac<<" "<<penal<<endl;
	

}

Measured memory_bytes: 7024
#include <iostream>
#include <vector>
#include <algorithm>
int main(){
    long N,K;
    std::cin >> N >> K;

    std::vector<long> H(N);
    for (int i = 0;i < N;i++){
        std::cin >> H[i];
    }
    std::sort(H.begin(),H.end());

    long sum = 0;
    for (int i = 0;i < N-K;i++){
        sum += H[i];
    }

    std::cout << sum << "\n";
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF (1e9)

int main() {
  ll n, all; cin >> n; all = 0;
  vector<ll> a(n), cnt(n);
  for(int i = 0; i < n; i++) cin >> a[i];
  for(int i = 0; i < n; i++) a[i]--;
  for(int i = 0; i < n; i++) cnt[a[i]]++;
  for(int i = 0; i < n; i++) all += cnt[i] * (cnt[i] - 1) / 2;

  for(int i = 0; i < n; i++) {
    cout << all - cnt[a[i]] + 1 << endl;
  }

  return 0;
}

Measured memory_bytes: 5760
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int A = sc.nextInt();
		int B = sc.nextInt();
		String frame = "#";
		StringBuilder sb = new StringBuilder();

		sb.append(frame.repeat(B+2));
		sb.append("\n");
		for (int i = 0; i < A; i++) {
			sb.append(frame + sc.next() + frame );
			sb.append("\n");
		}
		sb.append(frame.repeat(B+2));

		System.out.println(sb.toString());




	}


}



Measured memory_bytes: 39984
#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;
int n,l[110],ans;
bool check(int x,int y,int z) {
    if(x==y||y==z||x==z)
        return 0;
    if(x+y>z)
        return 1;
    else
        return 0;
}
int main() {
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
	    scanf("%d",&l[i]);
	sort(l+1,l+n+1);
	for(int i=1;i<=n;i++)
	    for(int j=i+1;j<=n;j++)
	        for(int k=j+1;k<=n;k++)
	            if(check(l[i],l[j],l[k]))
	                ans++;
	printf("%d\n",ans);
}

Measured memory_bytes: 3240
#include <bits/stdc++.h>
#include <unordered_map>
#include <unordered_set>
#define pb push_back
#define mpr make_pair
#define pii pair<int, int>
#define pll pair<ll, ll>
#define ll long long
#define ld long double
#define all(arr) arr.begin(), arr.end()
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define fo(i, l, r) for (int i = l; i <= r; i++)
#define INF 1000000001
#define inf1 1000000000000000001
#define mod 1000000007
#define pie 3.14159265358979323846264338327950L
#define N 100005
#define mid(l, r) l + (r - l) / 2
#define vec vector<int>
#define vecl vector<ll>
#define umap unordered_map<ll,ll>
#define yes cout << "Yes" << endl;
#define no cout << "No" << endl;
#define endl "\n"
using namespace std;

int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};
int ddx[8]={1,1,0,-1,-1,-1,0,1},ddy[8]={0,1,1,1,0,-1,-1,-1};
ll gcd(ll a,ll b){ if(!a)return b;return gcd(b%a,a);}


unordered_map<int , vector<int> > mp;
int vis[1000005];
int ans = 0;

int dfs(int u) {

    int cnt = 1;
    vis[u] = 1;
    for(auto it : mp[u]) {
        if(vis[it] == 0) {
            cnt+= dfs(it);
        }
    }

    return cnt;
    
}

    
void test_case() {

    
  int n , m;
  cin>>n;

  cin>>m;

  rep(i,m) {
      int a, b;
      cin>>a>>b;

      mp[a].pb(b);
      mp[b].pb(a);
  }

  for(int i=1; i<=n; i++) {
     if(vis[i] == 0) {
         ans = max(ans, dfs(i));
     }
  }


  cout<<ans<<endl;











    

}


int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    cout<<fixed<<setprecision(20);

    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);


    int t = 1;
    // cin >> t;
    while (t--)
    {
        test_case();
    }
}

Measured memory_bytes: 34132
#define _USE_MATH_DEFINES
#define INF 0x3f3f3f3f
#include <cstdio>
#include <iostream>
#include <sstream>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <queue>
#include <stack>
#include <limits>
#include <map>
#include <string>
#include <cstring>
#include <set>
#include <deque>
#include <bitset>
#include <list>
#include <cctype>
#include <utility>

using namespace std;

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

int tx[] = {0,1,0,-1};
int ty[] = {-1,0,1,0};

static const double EPS = 1e-8;

int main(){
	int n;

	while(~scanf("%d",&n)){
		if(n==0) break;
		int maxv = 0;
		for(int i=0;i*i*i<=n;i++){
			int used = i*i*i;
			if(used < n){
				int j=1;
				for(;j*(j+1)*(j+2)/6<=n-used;j++){			
				}
				used += (j-1)*(j-1+1)*(j-1+2)/6;
			}

			maxv = max(maxv,used);
		}

		printf("%d\n",maxv);
	}
}

Measured memory_bytes: 1188
#include <stdio.h>
typedef long long ll;

int main()
{
	ll n, m;
	ll r;

	scanf("%lld %lld", &n, &m);

	r = m - (2 * n);

	if (r < 0) {
		printf("%lld\n", m / 2);
	} else {
		printf("%lld\n", n + (r / 4));
	}

	return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
#include <string>

using namespace std;


int main(){
    int A,B,C; cin>>A>>B>>C;
    int ans;
    ans=C-(A-B);
    if(ans<0){
        ans=0;
    }
    cout<<ans<<endl;
    
}


Measured memory_bytes: 256
//def
#include <iostream>

#include <cmath>
#include <algorithm>
#include <iomanip>

//array
#include <vector>
#include <set>
#include <map>

using namespace std;
#define rep(i,q) for(int i = 0; (q) > i; i++)
typedef pair<int,int> Paint;
bool Pairfirst(const Paint& pf,Paint&ps){//sortCompare
  return pf.first < ps.first;
}
int main(){
  long long n,m;cin>>n>>m;
  vector<Paint> ss;
  rep(i,n){
    long long tmp,tmpp;cin>>tmp>>tmpp;
    ss.push_back(make_pair(tmp,tmpp));
  }
  sort(ss.begin(),ss.end(),Pairfirst);
  long long mon = 0;
  long long hon = 0;
  long long kekka;
  rep(i,n){
    hon += ss[i].second;
    mon += (long long)ss[i].first*ss[i].second;
    if(hon >= m){
     cout << (long long)mon - (hon-m)*ss[i].first << endl;
     break;
    }
  }
}

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

int main() {
  string S;
  cin >> S;
  int N = S.size();
  long sum = 0;
  for (int bit = 0; bit < 1 << (N - 1); bit++) {
    string num;
    num += S.at(0);
    for (int i = 1; i < N; i++) {
      if (bit >> (i - 1) & 1) sum += stol(num), num = "";
      num += S.at(i);
    }
    sum += stol(num);
  }
  cout << sum << "\n";
}

Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<cstdlib>
#include<stdio.h>
#include<time.h>
#include<math.h>
#include<algorithm>
#include<string>
#include<vector>
#include<list>
#include<queue>
#include<stack>
#include<deque>
#include<set>
#include<map>
#define REP(i, N) for(ll i = 0; i < N; ++i)
#define FOR(i, a, b) for(ll i = a; i < b; ++i)
#define ALL(a) (a).begin(),(a).end()
#define pb push_back
#define INF 1000000000
#define MOD 1000000007
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
int qx[8] = {1, 1, 0, -1, -1, -1, 0, 1};
int qy[8] = {0, 1, 1, 1, 0, -1, -1, -1};

int main(void) {
	while(true) {
		int n;
		cin>>n;
		if(n == 0) break;
		vector<int> w(n);
		REP(i, n) cin>>w[i];
		vector<vector<bool> > dp1(n, vector<bool>(n, false));
		vector<vector<int> > dp2(n, vector<int>(n, 0));
		for(int i = 2; i <= n; i += 2) {
			for(int j = 0; j < n - (i - 1); ++j) {
				if(i == 2) {
					if(abs(w[j] - w[j + (i - 1)]) <= 1) {
						dp1[j][j + (i - 1)] = true;
					}
				} else {
					if(dp1[j + 1][j + (i - 1) - 1] && abs(w[j] - w[j + (i - 1)]) <= 1) {
						dp1[j][j + (i - 1)] = true;
					} else {
						for(int k = j + 1; k <= j + (i - 1) - 2; k += 2) {
							if(dp1[j][k] && dp1[k + 1][j + (i - 1)]) {
								dp1[j][j + (i - 1)] = true;
								break;
							}
						}
					}
				}
			}
		}
		for(int i = 1; i <= n; ++i) {
			for(int j = 0; j < n - (i - 1); ++j) {
				if(i == 1) dp2[j][j + (i - 1)] = 0;
				else {
					if(dp1[j][j + (i - 1)]) dp2[j][j + (i - 1)] = i;
					else {
						dp2[j][j + (i - 1)] = max(dp2[j][j + (i - 1)], dp2[j + 1][j + (i - 1)]);
						dp2[j][j + (i - 1)] = max(dp2[j][j + (i - 1)], dp2[j][j + (i - 1) - 1]);
						for(int k = j; k <= j + (i - 1) - 2; ++k) {
							dp2[j][j + (i - 1)] = max(dp2[j][j + (i - 1)], dp2[j][k] + dp2[k + 2][j + (i - 1)]);
						}
					}
				}
			}
		}
		cout<<dp2[0][n - 1]<<endl;;
	}
}

Measured memory_bytes: 3264
N,K = map(int, input().split())
h = list(map(int, input().split()))
 
dp = [0] * N
for i in range(1, N):
    if i // K == 0:
        bef = i
    else:
        bef = K
    tmp = []
    for j in range(1, bef + 1):
        tmp.append(dp[i - j] + abs(h[i] - h[i - j]))
    dp[i] = min(tmp)
 
print(dp[-1])

Measured memory_bytes: 52448
S = input()
T = input()

counter = 0
for i in range(len(S)):
    second = 0
    group = S[i:i+len(T)]
    if len(group) < len(T):
        break
    for j in range(len(T)):
        if T[j] != group[j]:
            second += 1
    if counter == 0:
        counter = second
    elif second < counter:
        counter = second


print(counter)

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

int main() {
  char x;
  cin >> x;

  if (x == 'a') {
    cout << "vowel"<< endl;
  }
 else if (x == 'e') {
    cout << "vowel"<< endl;
  }
 else if (x == 'i') {
    cout << "vowel"<< endl;
  }
 else if (x == 'o') {
    cout << "vowel"<< endl;
  }
 else if (x == 'u') {
    cout << "vowel"<< endl;
  }
 else  {
    cout << "consonant"<< endl;
  }
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#define INF 1000000
using namespace std;


main() {
  while(1) {
    int n, k;
    cin >> n >> k;
    if(n == 0 && k == 0) break;
    int buf[k];
    int pb = 0;
    fill_n(buf, k, 0);
    int maxS = -INF;
    int sum = 0;
    for(int i = 0; i < n; i++) {
      sum -= buf[pb];
      cin >> buf[pb];
      sum += buf[pb];
      pb = (pb+1)%k;
      if(i+1 < k) continue;
      if(maxS == -INF || sum > maxS) maxS = sum;
    }
    cout << maxS << endl;
  }
}

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


int main(){

    map<int,int> m;

    int n;
    cin >> n;
    int tmp;
    int ans = 0;

    for(int i = 0;i < n;i++){
        cin >> tmp;
        m[tmp]++;
    }
    
    map<int,int>::iterator itr;

    for(itr = m.begin();itr != m.end();itr++){
        
        int key = itr->first;
        int value = itr->second;
        if(key < value){
            ans += value - key;
        }else if (key == value){
        
        }else{
            ans += value;
        }

    }

    cout << ans << endl;

    return 0;
}

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

#define F first
#define S second
#define PB push_back
#define MP make_pair
#define REP(i,a,b) for (int i = a; i <= b; i++)
#define REP_REV(i,a,b) for (int i = a; i >= b; i--)
#define what_is(x) cerr << #x << " is " << x << endl;

typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> pi;
typedef vector<ll> vl;
typedef pair<ll, ll> pl;

void solve() {
	string s, t;
	cin >> s >> t;
	vi min;

	REP(i, 0, s.size() - t.size()) {
		int index = i;
		int same = 0;
		REP(j, 0, t.size() - 1) {
			if (s[index] == t[j]) {
				same++;
			}
			index++;
		}
		min.push_back(same);
	}

	int ans = t.size() - *max_element(min.begin(), min.end());
	cout << ans;

	/*
	ll n;
	cin >> n;
	vl a(n);
	ll mod = 1e9 + 7;
	ll ans = 0;
	REP(i, 0, n - 1) cin >> a[i];
	REP(i, 0, n - 1) a[i] = a[i] % mod;
	REP(i, 0, n - 1) {
		REP(j, i + 1, n - 1) {
			ans += ((a[i] * a[j]) % mod);
		}
	}
	cout << ans % mod;
	*/
}

int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	//freopen("measurement.in", "r", stdin);
	//freopen("measurement.out", "w", stdout);
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	//ll t;
	//cin >> t;
	//while (t--) {
	solve();
	//}
	return 0;
}

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

using i64 = long long;
using P = pair<i64, i64>;

#define overload3(_1, _2, _3, name, ...) name
#define rep1(i, n) for(i64 i = 0LL; i < (n); ++i)
#define rep2(i, a, b) for(i64 i = (a); i < (b); ++i)
#define rep(...) overload3(__VA_ARGS__, rep2, rep1)(__VA_ARGS__)
#define all(v) v.begin(), v.end()


void solve(long long A, long long B){
    cout << max(0LL, A - 2 * B) << endl;
}

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

int main(){
    long long A;
    scanf("%lld",&A);
    long long B;
    scanf("%lld",&B);
    solve(A, B);
    return 0;
}


Measured memory_bytes: 256
import collections

s = collections.deque(input())
q = int(input())
rev = 0
for i in range(q):
  tmp = input().split()
  if len(tmp) == 1:
    rev += 1
  else:
    if tmp[1] == '1':
      if rev % 2 == 0:
        s.appendleft(tmp[2])
      else:
        s.append(tmp[2])
    else:
      if rev % 2 == 0:
        s.append(tmp[2])
      else:
        s.appendleft(tmp[2])
if rev % 2:
  while True:
    try:
      print(s.pop(), end='')
    except IndexError:
      break
else:
  while True:
    try:
      print(s.popleft(), end='')
    except IndexError:
      break

Measured memory_bytes: 8812
package main

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

var sc = bufio.NewScanner(os.Stdin)

func Scanner() string {
	sc.Scan()
	return sc.Text()
}

func intScanner() int {
	n, _ := strconv.Atoi(Scanner())
	return n
}

func floatScanner() float64 {
	n, _ := strconv.ParseFloat(Scanner(), 64)
	return n
}
func stringToInt(s string) int {
	n, _ := strconv.Atoi(s)
	return n
}
func stringSliceScanner(n int) []string {
	a := make([]string, n)
	for i := 0; i < n; i++ {
		a[i] = Scanner()
	}
	return a
}
func intSliceScanner(n int) []int {
	a := make([]int, n)
	for i := 0; i < n; i++ {
		a[i] = intScanner()
	}
	return a
}
func larger(a, b int) int {
	if a < b {
		return b
	} else {
		return a
	}
}
func smaller(a, b int) int {
	if a > b {
		return b
	} else {
		return a
	}
}
func max(a []int) int {
	x := a[0]
	for i := 0; i < len(a); i++ {
		if x < a[i] {
			x = a[i]
		}
	}
	return x
}
func min(a []int) int {
	x := a[0]
	for i := 0; i < len(a); i++ {
		if x > a[i] {
			x = a[i]
		}
	}
	return x
}
func abs(x int) int {
	if x < 0 {
		x = -x
	}
	return x
}

var mod int

func main() {
	mod = 1000000007
	buf := make([]byte, 0)
	sc.Buffer(buf, mod)
	sc.Split(bufio.ScanWords)
	n := intScanner()
	_ = intScanner()
	as := intSliceScanner(n)
	x := make([][]int, 1)
	x[0] = []int{as[n-1]}
	for i := n - 2; i >= 0; i-- {
		if as[i] < x[len(x)-1][0] {
			x[len(x)-1] = append(x[len(x)-1], as[i])
		} else {
			x = append(x, []int{as[i]})
		}
	}
	y := make([]int, len(x))
	mx := 0
	for i := 0; i < len(x); i++ {
		y[i] = x[i][0] - min(x[i])
		if y[i] > mx {
			mx = y[i]
		}
	}
	ans := 0
	for _, v := range y {
		if v == mx {
			ans++
		}
	}
	fmt.Println(ans)
}


Measured memory_bytes: 8448
#include <iostream>

    using namespace std;

    int main()
    {
        int num1, num2, num3;
        cin >> num1 >> num2 >> num3;
        if (num1 == num2)
            cout << num3;
        else if (num1 == num3)
            cout << num2;
        else
            cout << num1;
        return 0;
    }


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

int main(void)
{
    int N ,K;

    cin >> N >> K;

    int p[N+10]={}; 

    for (int i = 0; i < N; i++) cin >> p[i];

    sort(p, p+N);

    
    int total = 0;

    for(int i = 0; i < K; i++){
            total += p[i];
    }


    cout << total << endl;
}

Measured memory_bytes: 3640
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<string>
#include<string.h>
#include<math.h>
#include<stdlib.h>
#include<vector>
#include<queue>
#include<map>
#include<tuple>
#define rep(index,num) for(int index=0;index<num;index++)
#define rep1(index,num) for(int index=1;index<=num;index++)
#define scan(argument) cin>>argument
#define prin(argument) cout<<argument<<endl
#define kaigyo cout<<endl
#define eps 1e-15
#define mp(a1,a2) make_pair(a1,a2)
typedef long long ll;
using namespace std;
typedef pair<ll,ll> pll;
typedef pair<int,int> pint;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<pint> vpint;
typedef vector<pll> vpll;
ll INFl=1e+18+1;
int INF=1e+9+1;
struct UnionFind{
  vector<int> par;
  vector<int> sizes;
  UnionFind(int n) : par(n), sizes(n, 1) {
    rep(i,n) par[i] = i;
  }
  int root(int x) {
    if (x == par[x]) return x;
    return par[x] = root(par[x]);
  }
  void unite(int x, int y) {
    x = root(x);
    y = root(y);
    if (x == y) return;
    if (sizes[x] < sizes[y]) swap(x, y);
    par[y] = x;
    sizes[x] += sizes[y];
  }
  bool same(int x, int y) {
    return root(x) == root(y);
  }
  int size(int x) {
    return sizes[root(x)];
  }
};
int main(){
	int N;
	int x[100001],y[100001];
	vpint vx,vy;
	scan(N);
	rep(i,N){
		scan(x[i]);scan(y[i]);
		vx.push_back(mp(x[i],i));
		vy.push_back(mp(y[i],i));
	}
	sort(vx.begin(),vx.end());
	sort(vy.begin(),vy.end());
	vector<pair<int,pint> > edge;
	rep(i,N-1){
		edge.push_back(mp(vx[i+1].first-vx[i].first,mp(vx[i].second,vx[i+1].second)));
		edge.push_back(mp(vy[i+1].first-vy[i].first,mp(vy[i].second,vy[i+1].second)));
	}
	sort(edge.begin(),edge.end());
	UnionFind uf(N);
	ll ans=0;
	rep(i,edge.size()){
		int cost=edge[i].first;
		int n1=edge[i].second.first,n2=edge[i].second.second;
		if(uf.root(n1)!=uf.root(n2)){
			uf.unite(n1,n2);
			ans+=cost;
		}
	}
	prin(ans);

	return 0;
}


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

long long int n,i,a[200010],b[200010],ans;

signed main()
{
    ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	
	cin>>n;
	for (i=1;i<n+1;i++) cin>>a[i]>>b[i];
	sort(a+1,a+n+1);
	sort(b+1,b+n+1);
	if (n%2==1) ans=b[(n+1)/2]-a[(n+1)/2];
	else ans=b[n/2]+b[n/2+1]-a[n/2]-a[n/2+1];
	cout<<ans+1;
}


Measured memory_bytes: 6780
#include <bits/stdc++.h>
using namespace std;
#define int long long
typedef int ll;
typedef long double ld;
const ll N = 200005;
char en = '\n';
ll inf = 1e16;
ll mod = 1e9 + 7;
ll power(ll x, ll n, ll mod) {
  ll res = 1;
  x %= mod;
  while (n) {
    if (n & 1)
      res = (res * x) % mod;
    x = (x * x) % mod;
    n >>= 1;
  }
  return res;
}

pair<ll, ll> getFL(ll n) {
  ll last = n % 10;

  ll curr = last;
  while (n) {
    curr = n % 10;
    n /= 10;
  }
  return {curr, last};
}

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

  ll n;
  cin >> n;

  pair<ll, ll> arr[n + 5];

  map<pair<ll, ll>, ll> freq;

  for (ll i = 1; i <= n; i++) {
    arr[i] = getFL(i);
    freq[arr[i]]++;
  }

  ll res = 0;
  for (ll i = 1; i <= n; i++) {
    pair<ll, ll> req = arr[i];
    swap(req.first, req.second);
    if (freq.find(req) != freq.end())
      res += freq[req];
  }

  cout << res << en;

  return 0;
}

Measured memory_bytes: 3456
#include <bits/stdc++.h>
#define mod 1000000007
#define mod998 998244353
#define sp ' '
#define intmax 2147483647
#define llmax 9223372036854775807
#define mkp make_pair
typedef long long ll;
using namespace std;

int R, G, B, N, cnt;

int main() {
	cin >> R >> G >> B >> N;
	for (int i = 0; i <= N / R; ++i) {
		for (int j = 0; j <= (N - R*i) / G; ++j) {
			if ((N - R*i - G*j) % B == 0) {
				++cnt;
			}
		}
	}
	cout << cnt << endl;
}

Measured memory_bytes: 256