akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <iostream>
#include <vector>

using namespace std;

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

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

int main() {
  while (true) {
    int n[2][4];
    REP(i, 2) REP(j, 4) {
      if (!(cin >> n[i][j])) return 0;
    }
    int a[10] = {};
    int b[10] = {};
    REP(i, 4) a[n[0][i]] = i + 1;
    REP(i, 4) b[n[1][i]] = i + 1;
    int hit = 0, blow = 0;
    REP(i, 10) {
      if (a[i] && b[i] && a[i] == b[i]) {
        hit++;
      } else if (a[i] && b[i] && a[i] != b[i]) {
        blow++;
      }
    }
    cout << hit << " " << blow << endl;
  }
  return 0;
}


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

const ll MOD = 1e9+7;

ll repsq(ll x,ll p){
    if(p == 0) return 1;
    if(p & 1) return x * repsq(x,p-1) %MOD;
    else {
        ll t = repsq(x,p/2);
        return t * t %MOD;
    }
}

int main(){
    ll n,a,b;cin>>n>>a>>b;
    ll ans = (repsq(2,n)-1) % MOD;

    ll x_a = 1,y_a = 1;
    ll x_b = 1,y_b = 1;
    ll dis_a = 0,dis_b = 0;

    for(ll i=0;i<a;i++){
        x_a = (x_a * (n-i)) % MOD;
        y_a = (y_a * (i+1)) % MOD;
    }
    dis_a = x_a * repsq(y_a,MOD-2) % MOD;

    for(ll i=0;i<b;i++){
        x_b = (x_b * (n-i)) % MOD;
        y_b = (y_b * (i+1)) % MOD;
    }
    dis_b = x_b * repsq(y_b,MOD-2) % MOD;

    ans = (ans - dis_a - dis_b +MOD) %MOD;
    
    cout<<(ans +MOD) %MOD<<endl;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
const int N=100010;
int n,tot,p[N],ans[N];
char s[N];
int main(){
	scanf("%s",s+1);
	n=strlen(s+1);
	for(int i=1;i<n;i++)
		if(s[i]=='R'&&s[i+1]=='L')
			p[++tot]=i;
	for(int i=1;i<=n;i++){
		if(s[i]=='L'){
			int d=p[upper_bound(p+1,p+tot+1,i)-p-1];
			if((i-d)&1)
				ans[d+1]++;
			else ans[d]++;
		}
		if(s[i]=='R'){
			int d=p[lower_bound(p+1,p+tot+1,i)-p];
			if((d-i)&1)
				ans[d+1]++;
			else ans[d]++;
		}
	}
	for(int i=1;i<=n;i++)
		printf("%d ",ans[i]);
	return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
using ll = long long;

int main(){
    int N,K;cin>>N>>K;
    vector<ll> A;
    for(int i = 0;i < N;i++){
        ll _a;cin>>_a;
        A.push_back(_a);
    }
    for(int i = 0;i < N-K;i++){
        // cout<<A[i]<<" "<<A[i+K]<<endl;
        if(A[i] < A[i+K]){
            cout<<"Yes"<<endl;
        }else{
            cout<<"No"<<endl;
        }
    }
}

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

//#define int long long
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<n;++i)
#define exrep(i, a, b) for(ll i = a; i < b; i++)
#define out(x) cout << x << endl
#define EPS (1e-7)
#define gearup ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<bool> > vvb;
typedef vector<vector<double> > vvd;
typedef vector<vector<string> > vvs;
typedef vector<ll> vl;
typedef vector<vector<ll> > vvl;
typedef vector<vector<vector<ll> > > vvvl;
ll MOD = 1000000007;
const long long L_INF = 1LL << 60;
const int INF = 2147483647; // 2^31-1
const double PI = acos(-1);
//cout<<fixed<<setprecision(10);

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 T> void debug(T v){rep(i,v.size()) cout<<v[i]<<" ";cout<<endl;}
const ll dx[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll dy[8] = {0, 1, 1, 1, 0, -1, -1, -1};

signed main()
{   
    gearup;
    int n,s; cin >> n >> s;
    ll mod = 998244353;
    vvl dp(s+1,vl(n+1));
    dp[0][0] = 1;
    vl a(n);
    rep(i,n)cin>>a[i];
    rep(i,s+1){
        rep(j,n){ 
            dp[i][j+1] += dp[i][j]*2 % mod;
            if(i - a[j] >= 0)dp[i][j+1] += dp[i-a[j]][j];
            dp[i][j+1] %= mod;
        }
    }
    out(dp[s][n]);
}


Measured memory_bytes: 73684
#include<iostream>
using namespace std;
const int MAXN=40;
const int MAXM=10;
const int INF=10000;
int dp[50][500][500];

int main(){
    int n,ma,mb;
    cin >> n >> ma >> mb;
    int a[MAXN],b[MAXN],c[MAXN];
    for(int i=0;i<n;i++){
        cin >> a[i] >> b[i] >> c[i];
    }
    for(int i=0;i<=n;i++){
        for(int j=0;j<=MAXN*MAXM;j++){
            for(int k=0;k<=MAXN*MAXM;k++){
                dp[i][j][k]=INF;
            }
        }
    }
    dp[0][0][0]=0;
    for(int i=0;i<n;i++){
        for(int j=0;j<=MAXN*MAXM;j++){
            for(int k=0;k<=MAXN*MAXM;k++){
                dp[i+1][j+a[i]][k+b[i]]=min(dp[i+1][j+a[i]][k+b[i]],dp[i][j][k]+c[i]);
                dp[i+1][j][k]=min(dp[i+1][j][k],dp[i][j][k]);
            }
        }
    }
    int ans=INF;
    for(int j=1;j<=MAXN*MAXM;j++){
        for(int k=1;k<=MAXN*MAXM;k++){
            if(j*mb==k*ma){
                ans=min(ans,dp[n][j][k]);
            }
        }
    }
    if(ans==INF) ans=-1;
    cout << ans << endl;
}

Measured memory_bytes: 40832
import java.util.*;

public class Main {

    public static void main(String[] args) {
        final Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        final Map<Integer, Integer> a = new HashMap<>();
        final Map<Integer, Integer> b = new HashMap<>();
        int aMaxCount = 0;
        int aMax2Count = 0;
        int bMaxCount = 0;
        int bMax2Count = 0;
        int aMax = 0;
        int aMax2 = 0;
        int bMax = 0;
        int bMax2 = 0;

        for (int i = 0; i < n; ++i) {
            int current = scanner.nextInt();
            if (i % 2 == 0) {
                int count = a.getOrDefault(current, 0) + 1;
                a.put(current, count);
                if (count >= aMaxCount) {
                    if (current != aMax) {
                        aMax2Count = aMaxCount;
                        aMax2 = aMax;
                    }
                    aMaxCount = count;
                    aMax = current;
                } else if (count >= aMax2Count) {
                    aMax2Count = count;
                    aMax2 = current;
                }
            } else {
                int count = b.getOrDefault(current, 0) + 1;
                b.put(current, count);
                if (count >= bMaxCount) {
                    if (current != bMax) {
                        bMax2Count = bMaxCount;
                        bMax2 = bMax;
                    }
                    bMaxCount = count;
                    bMax = current;
                } else if (count >= bMax2Count) {
                    bMax2Count = count;
                    bMax2 = current;
                }
            }
        }


        if (aMax != bMax) {
            System.out.println(n - aMaxCount - bMaxCount);
        } else {
            if (aMax2Count == 0 && bMax2Count != 0) {
                System.out.println(n - bMaxCount);
            } else if (aMax2Count == 0 && bMax2Count == 0) {
                System.out.println(n / 2);
            } else if (aMax2Count != 0 && bMax2Count == 0) {
                System.out.println(n - aMaxCount);
            } else {
                int change1 = n - aMaxCount - bMax2Count;
                int change2 = n - bMaxCount - aMax2Count;
                System.out.println(Math.min(change1, change2));
            }
        }


    }
}


Measured memory_bytes: 63140
using System;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using static System.Math;
using static System.Console;
using static exMath;
using static exReadLine;


class Program
{
    static void Main(string[] args)
    {
        int N, K;
        intReadLine(out N, out K);
        long[] H = ReadLine().Split().Select(long.Parse).ToArray();
        Array.Sort(H);
        Array.Reverse(H);
        long ans = 0;
        if (K <= N)
        {
            for (int i = 0; i < K; i++)
            {
                H[i] = 0;
            }
            
            for (int i = 0; i < N; i++)
            {
                ans += H[i];
            }
        }
        WriteLine(ans);
    }
}

static class exReadLine
{
    public static void intReadLine(out int a)
    {
        a = int.Parse(ReadLine());
    }
    public static void intReadLine(out int a, out int b)
    {
        int[] input = ReadLine().Split().Select(int.Parse).ToArray();
        a = input[0];
        b = input[1];
    }
    public static void intReadLine(out int a, out int b, out int c)
    {
        int[] input = ReadLine().Split().Select(int.Parse).ToArray();
        a = input[0];
        b = input[1];
        c = input[2];
    }
    public static void intReadLine(out int a, out int b, out int c, out int d)
    {
        int[] input = ReadLine().Split().Select(int.Parse).ToArray();
        a = input[0];
        b = input[1];
        c = input[2];
        d = input[3];
    }

    public static void longReadLine(out long a)
    {
        a = long.Parse(ReadLine());
    }
    public static void longReadLine(out long a, out long b)
    {
        long[] input = ReadLine().Split().Select(long.Parse).ToArray();
        a = input[0];
        b = input[1];
    }
    public static void longReadLine(out long a, out long b, out long c)
    {
        long[] input = ReadLine().Split().Select(long.Parse).ToArray();
        a = input[0];
        b = input[1];
        c = input[2];
    }
    public static void longReadLine(out long a, out long b, out long c, out long d)
    {
        long[] input = ReadLine().Split().Select(long.Parse).ToArray();
        a = input[0];
        b = input[1];
        c = input[2];
        d = input[3];
    }
}

static class exMath
{
    // 最大公約数
    public static int Gcd(int a, int b)
    {
        if (a < b) return Gcd(b, a);
        while (b != 0)
        {
            var r = a % b;
            a = b;
            b = r;
        }
        return a;
    }
    public static long Gcd(long a, long b)
    {
        if (a < b) return Gcd(b, a);
        while (b != 0)
        {
            var r = a % b;
            a = b;
            b = r;
        }
        return a;
    }

    // 最小公倍数
    public static long Lcm(int a, int b)
    {
        return BigMul(a, b) / Gcd(a, b);
    }
    public static long Lcm(long a, long b)
    {
        return a * b / Gcd(a, b);
    }
}

Measured memory_bytes: 41472
#include<ctime>
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstdlib>
#include<cmath> 
#include<cstring>
#include<cassert>
#include<string>
#include<sstream>
#include<fstream>
#include<deque>
#include<queue>
#include<vector>
#include<map>
#include<list>
#include<stack>
#include<set>
#include<bitset>
#include<iomanip>
#include<utility>
#include<functional>
#include<cctype>
#include<cerrno>
#include<cfloat>
#include<ciso646>
#include<climits>
#include<clocale>
#include<complex>
#include<csetjmp>
#include<csignal>
#include<cstdarg>
#include<cstddef>
#include<cwchar>
#include<cwctype>
#include<exception>
#include<locale>
#include<numeric>
#include<new>
#include<stdexcept>
#include<limits>
using namespace std;

#define ll long long
#define INF 1e8
#define rep(i,n) for(int (i)=0;(i)<n;i++)
#define REP(i,n) for(int (i)=1;(i)<=n;i++)
#define mk(a,b) make_pair(a,b)
#define fi first
#define se second
#define pii pair<int,int> 
#define N (1<<7)

const int maxn=45;
int n,ma,mb,ans=INF;
int a[maxn],b[maxn],c[maxn];
int dp[2][405][405];

int main()
{
	scanf("%d%d%d",&n,&ma,&mb);
	REP(i,n)scanf("%d%d%d",&a[i],&b[i],&c[i]);
	for(int cnt=1;cnt<=min(400/ma,400/mb);cnt++)
	{
		int x=ma*cnt,y=mb*cnt;
		for(int p=0;p<2;p++)for(int i=0;i<=x;i++)for(int j=0;j<=y;j++)dp[p][i][j]=INF;
		dp[0][0][0]=0;
		for(int p=1;p<=n;p++)
		for(int i=x;i>=0;i--)for(int j=y;j>=0;j--)
		{
			dp[p&1][i][j]=dp[(p-1)&1][i][j];
			if(i>=a[p]&&j>=b[p])dp[p&1][i][j]=min(dp[(p-1)&1][i-a[p]][j-b[p]]+c[p],
			dp[p&1][i][j]);
		}
		ans=min(ans,dp[n&1][x][y]);
	}
	if(ans==INF)printf("-1");
	else printf("%d",ans);
	return 0;
}
/*
40 2 3
10 10 100
10 10 100
10 10 100
10 10 100
10 10 100
10 10 100
10 10 100
10 10 100
10 10 100
10 10 100
10 10 100
10 10 100
10 10 100
10 10 100
10 10 100
10 10 100
10 10 100
10 10 100
10 10 100
10 10 100
10 10 100
10 10 100
10 10 100
10 10 100
10 10 100
10 10 100
10 10 100
10 10 100
10 10 100
10 10 100
10 10 100
10 10 100
10 10 100
10 10 100
10 10 100
10 10 100
10 10 100
10 10 100
10 10 100
10 10 100
*/

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

const int maxN = 105;
const int MOD = 10000;

int a[maxN];
int n,m;
int main()
{
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		scanf("%d",&a[i]);
	}
	int ans = a[1];
	int cnt = 1;
	for(int i=2;i<=n;i++)
	{
		ans = max(ans,a[i]);
		if(a[i]>=ans)
			cnt++;
	}
	cout<<cnt<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string.h>
#include <vector>
using namespace std;
#define mod 1000000007
vector<int> v[(1<<20)];
int a[500005],tree[2000005],lazy[2000005];
void push(int node,int st,int en)
{
	tree[node]=(tree[node]+1LL*lazy[node]*(en-st+1))%mod;
	if (st!=en)
	{
		lazy[2*node]=(lazy[2*node]+lazy[node])%mod;
		lazy[2*node+1]=(lazy[2*node+1]+lazy[node])%mod;
	}
	lazy[node]=0;
}
void update(int node,int st,int en,int l,int r,int val)
{
	if (l<=st && en<=r)
	lazy[node]=(lazy[node]+val)%mod;
	push(node,st,en);
	if (en<l || st>r || r<l || (l<=st && en<=r))
	return;
	int mid=(st+en)/2;
	update(2*node,st,mid,l,r,val);
	update(2*node+1,mid+1,en,l,r,val);
	tree[node]=(tree[2*node]+tree[2*node+1])%mod;
}
int query(int node,int st,int en,int l,int r)
{
	push(node,st,en);
	if (en<l || st>r || r<l)
	return 0;
	if (l<=st && en<=r)
	return tree[node];
	int mid=(st+en)/2;
	return (query(2*node,st,mid,l,r)+query(2*node+1,mid+1,en,l,r))%mod;
}
int main()
{
	int n;
	scanf("%d",&n);
	for (int i=1;i<=n;i++)
	{
		scanf("%d",&a[i]);
		a[i]^=a[i-1];
	}
	for (int i=0;i<=n;i++)
	v[a[i]].push_back(i);
	int z=v[0].size();
	int ans=0;
	if (!a[n])
	{
		ans=1;
		for (int i=2;i<z;i++)
		ans=(ans*2)%mod;
	}
	update(1,0,z-1,0,0,1);
	for (int i=1;i<(1<<20);i++)
	{
		for (int j:v[i])
		{
			int idx=upper_bound(v[0].begin(),v[0].end(),j)-v[0].begin();
			update(1,0,z-1,idx,z-1,query(1,0,z-1,0,idx-1));
		}
		if (!a[n])
		ans=(ans+query(1,0,z-1,z-1,z-1))%mod;
		if (a[n]==i)
		ans=(ans+query(1,0,z-1,0,z-1))%mod;
		reverse(v[i].begin(),v[i].end());
		for (int j:v[i])
		{
			int idx=upper_bound(v[0].begin(),v[0].end(),j)-v[0].begin();
			update(1,0,z-1,idx,z-1,mod-query(1,0,z-1,0,idx-1));
		}
	}
	printf("%d",ans);
}

Measured memory_bytes: 45812
import bisect
import copy
import heapq
import sys
import itertools
import math
import queue
input = sys.stdin.readline
sys.setrecursionlimit(1000000)
# mod = 10 ** 9 + 7

def read_values(): return map(int, input().split())
def read_index(): return map(lambda x: int(x) - 1, input().split())
def read_list(): return list(read_values())
def read_lists(N): return [read_list() for n in range(N)]
def init_dp1(init, N): return [init for _ in range(N)]
def init_dp2(init, N, M): return [[init for _ in range(M)] for _ in range(N)]


def bfs(N, L):
    P = [0] * N
    Q = queue.Queue()
    Q.put(0)
    close = {0}
    while not Q.empty():
        v = Q.get()

        close.add(v)
        for w in L[v]:
            if w in close:
                continue
            close.add(w)
            P[w] = v
            Q.put(w)
    return P


def main():
    N, M = read_values()
    L = {i: set() for i in range(N)} 
    
    for _ in range(M):
        i, j = read_index()
        L[i].add(j)
        L[j].add(i)

    P = bfs(N, L)

    if -1 in P[1:]:
        print("No")
        return
    
    print("Yes")
    
    for p in P[1:]:
        print(p + 1)


if __name__ == "__main__":
    main()



Measured memory_bytes: 131476
#define _USE_MATH_DEFINES
#include <iomanip>
#include <iostream>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <map>
#include <tuple>
#include <climits>
#include <algorithm>
#include <cmath>
using namespace std;

typedef long long LL;
typedef vector<int> VI;
typedef vector<double> VD;
typedef vector<LL> VLL;
typedef vector<string> VS;
typedef vector<bool> VB;
typedef vector<vector<int>> VVI;
typedef vector<vector<long long>> VVLL;
typedef vector<vector<bool>> VVB;
typedef vector<vector<double>> VVD;

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

const int MOD = 1000000007;

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(a>b){
		a=b;
		return true;
	}
	return false;
}

void debug(VI &arr){
	int n=arr.size();
	rep(i,n){
		cout<<arr.at(i)<<endl;
	}
}

void debug(VVI &board){
	int h = board.size();
	int w = board.at(0).size();
	rep(i,h){
		rep(j,w){
			cout << board.at(i).at(j) << " ";
		}
		cout<<endl;
	}
}

void debug(VVLL &board){
	int h = board.size();
	int w = board.at(0).size();
	rep(i,h){
		rep(j,w){
			cout<<board.at(i).at(j)<<" ";
		}
		cout<<endl;
	}
}

void debug(VS &board){
	int h = board.size();
	rep(i,h){
		cout<<board.at(i)<<endl;
	}
	return;
}

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

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


Measured memory_bytes: 256
N = int(input())
Alist = list(map(int, input().split()))
S = sum(Alist)

ans = [S - sum([2 * Alist[i] for i in range(1, N - 1, 2)])]
for i in range(1, N):
    ans.append(-ans[i - 1] + 2 * Alist[i - 1])


print(*ans)

Measured memory_bytes: 14092
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef long double ld;

int n,m,v,p;
vector<ll> a;

bool solve(int x)
{
	int bigger = 0;
	int less = 0;
	int other = 0;
	REP(i,n) if(i!=x){
		if(a[i] > a[x]+m) bigger++;
		else if(a[i] <= a[x]) less++;
		else other++;
	}
	if(p<=bigger) return false;
	int rest = v-1 - bigger - less;
	if(rest<=0) return true;

	ll to = 0;
	int cnt = 0;
	REP(i,n) if(a[x] < a[i] && a[i] <= a[x] + m){
		to += a[x] + m - a[i];
		cnt++;
		int ok = min(to/m, (ll)min(other, rest));
		int ng = rest - ok;
		if(bigger+ng < p && cnt+ng <= other){
			return true;
		}
	}
	return false;
}

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cin >> n >> m >> v >> p;
	a.resize(n);
	REP(i,n) cin >> a[i];
	sort(ALL(a));

	int ok = n;
	int ng = -1;
	while(abs(ok - ng) > 1) {
  	int mid = (ok + ng) / 2;
  	if(solve(mid)) 	ok = mid;
  	else	ng = mid;
		//cout << ok << " " << ng << '\n';
	}

	cout << n-ok << '\n';
	return 0;
}



Measured memory_bytes: 1024
#include <stdio.h>

int main(void)
{
    int H, W;
    while (1)
    {
        scanf("%d %d", &H, &W);
        if(H == 0 && W == 0) break;

        for (int i = 0; i < H; i++)
        {
            for (int j = 0; j < W; j++)
            {
                if (i != 0 && i != H - 1 &&
                    j != 0 && j != W - 1)
                {
                    printf(".");
                }
                else
                {
                    printf("#");
                }
            }
            printf("\n");
        }
        printf("\n");
    }

    return 0;
}


Measured memory_bytes: 2032
#include <iostream>
#include <set>
#include <queue>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <cstring>
#include <climits>
#include <sstream>
#include <iomanip>
#include <map>
#include <stack>
#include <numeric>
#include <functional>

using namespace std;
#define ALL(x)              (x).begin(),(x).end()
#define REP(i, n)           for (int (i) = 0 ; (i) < (ll)(n) ; ++(i))
#define REPN(i, m, n)       for (int (i) = m ; (i) < (ll)(n) ; ++(i))
#define INF                 (int)2e9
#define MOD                 (1000 * 1000 * 1000 + 7)
#define Ceil(x, n)          (((((x))+((n)-1))/n))
#define CeilN(x, n)         (((((x))+((n)-1))/n)*n)
#define FloorN(x, n)        ((x)-(x)%(n))
#define IsOdd(x)            (((x)&0x01UL) == 0x01UL)
#define IsEven(x)           (!IsOdd((x)))
#define M_PI                3.14159265358979323846
typedef long long           ll;
typedef pair<ll, ll>        P;

/*-----------------------------------------------------------------------------
　処理
 -----------------------------------------------------------------------------*/
int main()
{
	int N;
	cin >> N;
	vector<P> A(100000 + 5);
	REP(i, A.size()) {
		A[i].first = 0;
		A[i].second = i;
	}
	
	REP(i, N) {
		int a;
		cin >> a;
		A[a].first++;
	}
	
	REP(i, A.size()) {
		if (1 <= A[i].first) A[i].first--;
	}
	
	int ans = 0;
	REP(i, A.size()) {
		ans += A[i].first;
	}

	cout << N - CeilN(ans, 2) << endl;

	return 0;
}



Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define endl "\n"
#define sz(x) ((ll)(x).size())
#define pb push_back
#define all(x) (x).begin(),(x).end()
#define prt(x) cout << (x)
#define prtl(x) cout << (x) << endl
#define rep(i,a,b) for(ll i=a; i<b; i++)
#define rrep(i,a,b) for(ll i=a; i>b; i--)
#define mp(a, b) make_pair(a, b)
using namespace std;
using vi = vector<int>;
using vll = vector<long long int>;
using vb = vector<bool>;
using vvb = vector<vector<bool>>;
using vc = vector<char>;
using vvi = vector<vector<int>>;
using vvll = vector<vector<long long int>>;
using vvc = vector<vector<char>>;
using ll = long long int;
using P = pair<long long int, long long int>;
using Map = map<long long int, long long int>;

const ll M = 1000000007;
 
vector<ll> fac(300001); //n!(mod M)
vector<ll> ifac(300001); //k!^{M-2} (mod M)
//a,bの範囲的にこれだけ配列を用意していけば十分

ll mpow(ll x, ll n){ //x^n(mod M) ←普通にpow(x,n)では溢れてしまうため，随時mod計算
    ll ans = 1;
    while(n != 0){
        if(n&1) ans = ans*x % M;
        x = x*x % M;
        n = n >> 1;
    }
    return ans;
}

ll comb(ll a, ll b){ //aCbをmod計算
    if(a == 0 && b == 0)return 1;
    if(a < b || a < 0)return 0;
    ll tmp = ifac[a-b]* ifac[b] % M;
    return tmp * fac[a] % M;
}

int main(){
    fac[0] = 1;
    ifac[0] = 1;
    for(ll i = 0; i<300000; i++){
        fac[i+1] = fac[i]*(i+1) % M; // n!(mod M)
        ifac[i+1] = ifac[i]*mpow(i+1, M-2) % M; // k!^{M-2} (mod M) ←累乗にmpowを採用
    }
    ll N; cin >> N;
    vll S(pow(2, N));
    Map n;
    rep(i, 0, pow(2,N)){
        cin >> S[i];
        if(n.find(S[i]) == n.end()){
            n[S[i]] = 1;
        }else{n[S[i]]++;}
    }
    sort(S.begin(),S.end(),greater<ll>());
    vll lis(0);
    ll m = S[0]; lis.emplace_back(m);
    rep(i, 1, pow(2,N)){
        if(S[i] != m){m = S[i]; lis.emplace_back(m);}
    }
    ll g = 0;
    for(auto x: lis){
        g = max(g, n[x]);
    }
    vll com(0);
    ll a = 0;
    rep(i, 0, N+1){
        a += comb(N, i);
        com.emplace_back(a);
    }
    ll c = 0;
    bool t = true;
    rep(i, 0, N+1){
        ll h = lis[i];
        rep(j, c, pow(2,N)){
            if(S[j] >= h){
                c++;
            }else{
                break;
            }
        }
        if(c > com[i]){
            t = false;
        }
    }
    if(g > pow(2, N-1)){t = false;}
    if(t){prt("Yes");}
    else{prt("No");}
}

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

int main() {
    ull n;
    cin >> n;
    ull input;
    vector<ull> vec;
    vector<ull> sum;
    vec.push_back(0);
    sum.push_back(0);
    for (ull i = 1;i <= n;i++){
        cin >> input;
        vec.push_back(input);
        sum.push_back(sum[i - 1] + input); 
    }

    ull ans = 0;
    for (ull i = 1;i < n;i++) {
        // ans = (ans + (vec[i] * (sum[n] - sum[i]) % MOD)) % MOD;
        ans += ((vec[i] % MOD) * ((sum[n] - sum [i]) % MOD) % MOD);
        ans %= MOD; 
    }

    cout << ans << endl;

    return (0);
}


Measured memory_bytes: 6644
import java.util.Scanner;

public class Main {
	public static void main(String args[]) {
    	Scanner sn = new Scanner(System.in);
      String s = sn.next();
      String[] a = s.split("");
      int max = 0;
      int aux = 0;
      for(int i = 0; i < a.length; i++) {
      	if(a[i].equals("R")) {
        	aux++;
          	max = Math.max(max, aux);
        } else {
          	aux = 0;
        }
      }
      System.out.println(max);
    }
}

Measured memory_bytes: 35624
import heapq
n,m=map(int, input().split())
s=list(map(int, input().split()))
for i in range(n):
    s[i]*=-1
heapq.heapify(s)
for i in range(m):
    p=heapq.heappop(s)
    p/=2
    heapq.heappush(s,p)
ans=0
for i in range(n):
    ans+=int(-s[i])
print(ans)


Measured memory_bytes: 14180
#include <cstdio>
#include <vector>
#include <algorithm>
using namespace std;

int N, x;
vector<int> a;

int main()
{
    scanf(" %d %d", &N, &x);
    for (int i = 0; i < N; i++)
    {
        int tmp;
        scanf(" %d", &tmp);
        a.push_back(tmp);
    }
    sort(a.begin(), a.end());

    int result = 0;

    int size = a.size();

    for (int i = 0; i < size; i++)
    {
        x -= a[i];
        if (x < 0)
        {
            break;
        }

        if (i == size - 1)
        {
            if (x == 0)
            {
                result++;
            }
            break;
        }

        result++;
    }

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

Measured memory_bytes: 888
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#include <x86intrin.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define all(v) v.begin(), v.end()
#define allr(v) v.rbegin(), v.rend()
#define V vector
template <typename T> bool chmin(T &a, const T &b) {if(a > b){a = b; return true;} return false;}
template <typename T> bool chmax(T &a, const T &b) {if(a < b){a = b; return true;} return false;}
template<typename A, size_t N, typename T> void Fill (A (&array)[N], const T & val) {fill ((T*)array, (T*)(array+N), val);}
V<int> dx = {-1, 1,  0, 0, -1, -1,  1, 1};
V<int> dy = { 0, 0, -1, 1, -1,  1, -1, 1};

const int mod = 1000000007;
//const int mod = 998244353;
struct mint {
    ll x;
    mint(ll x=0):x((x%mod+mod)%mod){}
    mint operator-() const { return mint(-x);}
    mint& operator+=(const mint a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator-=(const mint a) {
        if ((x += mod-a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
    mint operator+(const mint a) const { return mint(*this) += a;}
    mint operator-(const mint a) const { return mint(*this) -= a;}
    mint operator*(const mint a) const { return mint(*this) *= a;}
    mint pow(ll t) const {
        if (!t) return 1;
        mint a = pow(t>>1);
        a *= a;
        if (t&1) a *= *this;
        return a;
    }

    // for prime mod
    mint inv() const { return pow(mod-2);}
    mint& operator/=(const mint a) { return *this *= a.inv();}
    mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}

int main () {
    int n; cin >> n;
    V<mint> dp(n+1, 0);//dp[i]:iを3以上の数列で作る方法の数
    dp[0] = 1;
    for (int i = 3; i <= n; i++) {
        dp[i] = dp[i-1] + dp[i-3];
        /*
        for (int j = 3; j <= i; j++) {//先頭j
            dp[i] += dp[i-j];
        }
        */
    }
    cout << dp[n] << endl;

    return 0;
}

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

#define ll long long
#define ld long double
#define pb push_back
#define eb emplace_back
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()

#define int long long
using namespace std;
const int INF = 2e16;
const int MOD = 1e9 + 7;
const int MB = 20;

void solve() {
	int a, b, k;
	cin >> a >> b >> k;
	int x = min(a, k);
	a -= x;
	k -= x;
	b -= k;
	cout << a << " " << max(0LL, b);
}

signed main() {
	/*
	freopen("search.in", "r", stdin);
	freopen("search.out", "w", stdout);
	*/
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);
	cout << fixed;
	cout.precision(12);
	solve();
}


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

using namespace std;

int main(void) {
    int A, B, K;
    cin >> A >> B >> K;
    int cnt = 0;
    for (int i = min(A, B); ; i--) {
        cnt += (A % i == 0 && B % i == 0);
        if (cnt == K) {
            cout << i << endl;
            return 0;
        }
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int n;
  cin >> n;
  vector<int> vec(n);
  for (int i = 0; i < n; i++) {
    cin >> vec.at(i);
  }  
  sort(vec.begin(), vec.end());
  reverse(vec.begin(), vec.end());
  int suma = 0;
  int sumb = 0;
  for (int i = 0; i < n; i += 2) {
    suma += vec.at(i);
  }
  for (int i = 1; i < n; i += 2) {
    sumb += vec.at(i);
  }
  cout << suma - sumb << endl;
  

}

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

int main()
{
	//cin.tie(0);
	//ios::sync_with_stdio(false);
	int A, B, C, K;

	cin >> A >> B >> C >> K;

	if (K <= A){
		cout << K;
	}else if (K <= A + B){
		cout << A;
	}else{
		cout << A - (K - A - B);
	}

	return 0;
}

Measured memory_bytes: 3552
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=100005;
int n,x[N],t[N],m;
ll k,d[N];

typedef array<int,N> perm;
perm operator*(const perm &l,const perm &r)
{
	perm x;
	for(int i=1;i<=n;i++)x[i]=r[l[i]];
	return x;
}
perm power(perm a,ll x)
{
	perm ans;
	for(int i=1;i<=n;i++)ans[i]=i;
	for(;x;x>>=1,a=a*a)
		if(x&1)ans=ans*a;
	return ans;
}

int main()
{
	scanf("%d",&n);
	perm f;
	for(int i=1;i<=n;i++)scanf("%d",x+i),t[i]=x[i]-x[i-1],f[i]=i;
	scanf("%d%lld",&m,&k);
	for(int a;m--;)
	{
		scanf("%d",&a);
		swap(f[a],f[a+1]);
	}
	f=power(f,k);
	for(int i=1;i<=n;i++)d[i]=t[f[i]];
	for(int i=1;i<=n;i++)printf("%lld\n",d[i]+=d[i-1]);
}


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

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

  for (int i = 0; i < s.size(); i++)
  {
    if (i % 2 == 0){
      cout << s.at(i) ;
    }
  }
  cout << "" << endl;
}

Measured memory_bytes: 3668
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#include <cstdlib> 
#include <math.h>
#include<cstdio>
#include<cstring>
#define FOR(I, A, B) for (int I = (A); I <= (B); I++)
typedef vector< int > vi;
typedef vector< vi > vvi;
typedef pair< int,int > ii;
#define IOS ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define fo(i,n) for(int i=0;i<n;i++)
#define sz(a) int((a).size())
#define pb push_back
#define all(c) (c).begin(),(c).end()
#define tr(c,i) for(typeof((c)).begin() i = (c).begin(); i != (c).end(); i++)
#define present(c,x) ((c).find(x) != (c).end())
#define cpresent(c,x) (find(all(c),x) != (c).end())
const int N=1e5+5;
 
 
int pa[N];
int n,m;
 
ll szz[N];
ll ans[N];
struct edge{
    int u,v;
}edges[N];
 
int find(int x){
    if(pa[x]==x) return pa[x];
    return pa[x]=find(pa[x]);
}


 
int main(){
    IOS
    cin>>n>>m;
    int a,b;
    
    for(int i=1;i<=m;++i){
        cin>>edges[i].u>>edges[i].v;
 
    }
    //cout<<"hre"<<endl;
    
    for(int i=1;i<=n;++i){
        //raank[i]=0;
        pa[i]=i;
        szz[i]=1;
    }
    ans[m]=(ll)n*(n-1)/2;
    //cout<<"herew   df  "<<endl;
    for(int i=m;i>=1;--i){
 
          a=find(edges[i].u);
          b=find(edges[i].v);
          
         
          if(a==b){
               ans[i-1]=ans[i];
          }
          else{
               ans[i-1]=ans[i]-(szz[a]*szz[b]);
               szz[a]+=szz[b];
               pa[b]=a;
          }
          //cout<<szz[a]<<endl;
     
 
 
     }
     for(int i=1;i<=m;i++) 
         cout<<ans[i]<<endl;
      
    
     return 0;
}

Measured memory_bytes: 4096
//#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//#pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>

#define pb push_back
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define ll long long



using namespace std;

void file(){
	#ifndef ONLINE_JUDGE
    	freopen("in.txt", "r", stdin);
	#endif
}
int tc;
const int N=1e6+5,M=2e6+5,MOD=1e9+7,OO=1e9;

int main(){
	ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	//file();
	
	string a;
	ll k;

	cin>>a>>k;
	ll curr = 0;
	for(auto c : a){
		if(c=='1')curr++;
		else{
			return cout<<c<<endl,0;
		}

		if(curr==k)return cout<<1<<endl,0;

	}

	cout<<"1\n";
}	



Measured memory_bytes: 256
import sys
from collections import deque
import bisect
import copy
import heapq
import itertools
import math
input = sys.stdin.readline
sys.setrecursionlimit(1000000)
mod = 10 ** 9 + 7

def read_values(): return map(int, input().split())
def read_index(): return map(lambda x: int(x) - 1, input().split())
def read_list(): return list(read_values())
def read_lists(N): return [read_list() for n in range(N)]


def main():
    N, D = read_values()
    D *= D
    res = 0
    for _ in range(N):
        X, Y = read_values()
        if X ** 2 + Y ** 2 <= D:
            res += 1
    print(res)

if __name__ == "__main__":
    main()


Measured memory_bytes: 69012
#include<bits/stdc++.h>
using namespace std;
int main(){
  unsigned long long n,x;
  cin >> n >> x;
  unsigned long long a[n]={};
  for(unsigned long long i=0;i<n;i++){
    cin >> a[i];
  }
  unsigned long long sum=0ull;
  sort(a,a+n);
  for(unsigned long long i=0;i<n;i++){
    sum+=a[i];
    if(x==sum){
      cout << i+1ull << endl;
      break;
    }
    if(x<sum){
      cout << i << endl;
      break;
    }
    if(i==n-1){
      cout << i << endl;
    }
    
  }
}


Measured memory_bytes: 3600
/**
 *    author  : 𝒌𝒚𝒐𝒎𝒖𝒌𝒚𝒐𝒎𝒖𝒑𝒖𝒓𝒊𝒏
 *    created : 2020-02-17 07:27:29
**/

#include <iostream>
#include <deque>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <complex>
#include <numeric>
#include <bitset>
#include <cassert>
#include <cctype>
#include <iomanip>
#include <random>
#include <utility>
#include <chrono>

using namespace std;

using int64 = long long;

template<class T> std::ostream& operator<<(std::ostream& os, const std::vector<T>& vec) { os << '{'; size_t n = vec.size(); for (size_t i = 0; i < n; ++i) { os << vec[i]; if (i != n - 1) os << ','; } os << '}'; return os; }
template<class T, class U> std::ostream& operator<<(std::ostream& os, const std::pair<T, U>& p) { return os << '{' << p.first << " " << p.second << '}'; }
template<class T, class U> std::ostream& operator<<(std::ostream& os, const std::map<T, U>& mp) { os << '{'; for (auto it = mp.begin(); it != mp.end(); ++it) { os << '{' << it->first << ':' << it->second << '}'; if (it != --mp.end()) os << ','; } os << '}'; return os; }
template<class T> std::ostream& operator<<(std::ostream& os, const std::set<T>& st) { os << '{'; for (auto it = st.begin(); it != st.end(); ++it) { os << *it; if (it != --st.end()) os << ','; } os << '}'; return os; }
template<class T> std::istream& operator>>(std::istream& is, std::vector<T>& vec) { size_t n = vec.size(); for (size_t i = 0; i < n; ++i) is >> vec[i]; return is; }

#define all(_) begin(_), end(_)
#define rall(_) rbegin(_), rend(_)

#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]: ", debug_out(__VA_ARGS__)
#else
#define debug(...) 1728
#endif

void debug_out() { std::cerr << '\n'; }

template <class Head, class... Tail>
void debug_out(Head&& head, Tail&&... tail) {
  std::cerr << head;
  if (sizeof...(Tail) != 0) std::cerr << ", ";
  debug_out(std::forward<Tail>(tail)...);
}

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

  string t, s; cin >> t >> s >> t;

  cout << 'A' << s[0] << 'C' << endl;

  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int mapp[3][3];
int main()
{
for(int i=0;i<3;i++)
{
    for(int j=0;j<3;j++)
    {  
       cin>>mapp[i][j];
    }
}
int sum1=mapp[0][0]+mapp[1][1]+mapp[2][2];
int sum2=mapp[0][1]+mapp[1][2]+mapp[2][0];
int sum3=mapp[1][0]+mapp[2][1]+mapp[0][2];
if(sum1==sum2&&sum2==sum3)
       cout<<"Yes"<<endl;
else
       cout<<"No"<<endl;
return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;
import java.util.Stack;

public class Main {
	public static void main(String[] args) {
		try(Scanner sc = new Scanner(System.in)){
			Stack<String> stack=new Stack<String>();
			String s=sc.nextLine();
			String[] token=s.split(" ");
			for(String t:token) {
				if(t.equals("+") || t.equals("-") || t.equals("*")){ 
					int num1=Integer.valueOf((String) stack.pop());
					int num2=Integer.valueOf((String) stack.pop());
					if(t.equals("+")) {
						stack.push(String.valueOf(num1+num2));
					}
					else if(t.equals("-")) {
						stack.push(String.valueOf(num2-num1));
					}
					else {
						stack.push(String.valueOf(num1*num2));
					}
					
				}
				else {
					stack.push(t);
				}
			}
			System.out.println(stack.pop());

		}
	}
}


Measured memory_bytes: 26332
#include <stdio.h>
#define TAKA 1
#define AOKI 0

int main(void){
    int a,b,c,d,turn=TAKA;
    scanf("%d %d %d %d",&a,&b,&c,&d);

    while(a>0 && c>0){
        if(turn == TAKA){
            c -= b;
            turn = AOKI;
        }else{
            a -= d;
            turn = TAKA;
        }
    }

    if(a<=0){
        printf("No\n");
    }else{
        printf("Yes\n");
    }

    return 0;
}

Measured memory_bytes: 1616
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>

using namespace std;
#define ll long long
#define ld long double
#define mp make_pair

void print(vector<auto> &a)
{
    for (int i = 0; i<a.size(); i++) cout<<a[i]<<' ';
    cout<<endl;
}

void get(vector<auto> &a)
{
    for (int i = 0; i<a.size(); i++) cin>>a[i];
}

const ll p = 998244353;

int mul(int a, int b) {
    return (1LL * a * b) % p;
}

int add(int a, int b) {
    int s = (a+b);
    s = s%p;
    if (s<0) s+=p; 
    return s;
}

int po(int a, int deg)
{
    if (deg==0) return 1;
    if (deg%2==1) return mul(a, po(a, deg-1));
    int t = po(a, deg/2);
    return mul(t, t);
}

vector<vector<int>> G;

vector<bool> visited;

vector<int> topsort;

void dfs(int start)
{
    visited[start] = true;
    for (auto s: G[start]) if (!visited[s]) dfs(s);
    topsort.push_back(start);
}

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

    int n, m;
    cin>>n>>m;
    G.resize(n+1);
    visited.resize(n+1);
    int a, b;
    for(int i = 0; i<m; i++)
    {
        cin>>a>>b;
        G[a].push_back(b);
    }
    
    for (int i = 1; i<=n; i++) if (!visited[i]) dfs(i);
    vector<int> dp(n+1);
    for (int i = 0; i<n; i++)
    {
        for (auto s: G[topsort[i]]) dp[topsort[i]] = max(dp[topsort[i]], dp[s] + 1); 
    }
    
    int res = 0;
    for (int i = 1; i<=n; i++) res = max(res, dp[i]);
    cout<<res;
}

Measured memory_bytes: 8696
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
#define rrep(i,n) for(int i=1;i<(n);++i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int inf = 1001001001;
const int mod = 1000000007;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int x;
	cin >> x;
	if (x == 1) {
		cout << 0 << ' ' << -1 << endl;
		return 0;
	}
	for (int i = 1; i * i <= x; ++i) {
		if (x % i == 0) {
			if (i % 5 != x % 5) continue;
			for (int j = -1000000; j <= 1000000; ++j) {
				int tmp = i + j;
				ll now = (ll)pow(tmp, 5) - (ll)pow(j, 5);
				if (now == x) {
					cout << tmp << ' ' << j << endl;
					return 0;
				}
			}
		}
	}
	return 0;
}


Measured memory_bytes: 4272
#include<cstdio>
#include<iostream>
#include<algorithm>
using namespace std;
int main()
{
	long long  a,b;
	cin>>a>>b;
	long long t;
	t=a-b;
	if(t<0)
		cout<<"0"<<endl;
	else
		cout<<t<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long int LL;
typedef unsigned long long int ULL;
using namespace std;

// 插入此處

int a[200005];

int main() {
    int n;
    scanf("%d", &n);
    for (int i = 0; i < n; i++) {
        scanf("%d", &a[i]);
    }
    LL ans = 0;
    map<int, LL> m;
    m[-a[0] - 0] = 1;
    for (int i = 1; i < n; i++) {
        ans += m[a[i] - i];
        m[-a[i] - i]++;
    }
    printf("%lld\n", ans);
}


Measured memory_bytes: 27172
#include <algorithm>
#include <cmath>
#include <iostream>
#include <string>
#include <vector>

#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;

/* a と b の最大公約数を返す関数 */
long long GCD(long long a, long long b) {
	if (b == 0) return a;
	else return GCD(b, a % b);
}

int main()
{
	int N;
	vector<int> vec(1e5+100);

	cin >> N;
	rep(i, N)
	{
		cin >> vec.at(i);
	}

	int cp = 0;
	int cnt = 0;
	bool reached = false;
	rep(i, N) {
		if (cp == 1)
		{
			reached = true;
			break;
		}
		cnt++;
		cp = vec.at(cp) - 1;
	}

	if (reached)
	{
		cout << cnt << endl;
	}
	else
	{
		cout << "-1" << endl;
	}

	return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <bits/stdc++.h>
#include <sstream>
#define PI 3.14159265358979323846264338327950L
#define ll long long
using namespace std;

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    int t;
    cin >> t;
    int m[4];
    const char *c[4] = {"AC", "WA", "TLE", "RE"};
    for(int i=0; i<4; i++){
        m[i] = 0;
    }
    while(t--){
        string s;
        cin >> s;
        if(s == "AC"){
            m[0]++;
        }
        if(s == "WA"){
            m[1]++;
        }
        if(s == "TLE"){
            m[2]++;
        }
        if(s == "RE"){
            m[3]++;
        }
    }
    for(int i=0; i<4; i++){
        cout << c[i] << " x " << m[i] << "\n";
    }
}

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

namespace abc168_a
{
    class Program
    {
        static void Main(string[] args)
        {           
            string[] Data = Console.ReadLine().Split(' ');
            int A = int.Parse(Data[0]);
            int B = int.Parse(Data[1]);
            int C = int.Parse(Data[2]);
            int K = int.Parse(Data[3]);

            int Max = 0;
            for (int i = 0; A > 0 && K > 0; i++)
            {
                Max += 1;
                A -= 1;
                K -= 1;
            }
            for (int i = 0; B > 0 && K > 0; i++)
            {
                B -= 1;
                K -= 1;
            }
            for (int i = 0; C > 0 && K > 0; i++)
            {
                Max -= 1;
                C -= 1;
                K -= 1;
            }
            Console.Write(Max);
            Console.Read();
        }
    }
}


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

n = int(input())
counter = {t: [0] * 13 for t in ['S', 'H', 'C', 'D']}
for _ in range(n):
    tp, num = input().split()
    num = int(num)
    counter[tp][num - 1] += 1

for t in ['S', 'H', 'C', 'D']:
    for num in range(13):
        if counter[t][num] == 0:
            print('{} {}'.format(t, num + 1))


Measured memory_bytes: 5608
#include <iostream>
#include <string>
#include <cstring>
#include <cmath>
#include <cstdio>
#include <algorithm>
using namespace std;
#define ll long long
int main(){
    string s;
    cin>>s;
    cout<<s[0];
    cout<<s.size()-2;
    cout<<s[s.size()-1]<<endl;
    return 0;
}



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


def solve(x: "List[int]", y: "List[int]"):
    vec_x = x[1] - x[0]
    vec_y = y[1] - y[0]
    x3 = x[1] - vec_y
    y3 = y[1] + vec_x
    x4 = x[0] - vec_y
    y4 = y[0] + vec_x
    print(x3, y3, x4, y4)
    return


# Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word

    tokens = iterate_tokens()
    x = [int()] * (2)  # type: "List[int]"
    y = [int()] * (2)  # type: "List[int]"
    for i in range(2):
        x[i] = int(next(tokens))
        y[i] = int(next(tokens))
    solve(x, y)


if __name__ == "__main__":
    main()


Measured memory_bytes: 3064
n,k = map(int,input().split())
s = input()
if s[0] == "0":
    zero = []
    one = []
    c = 1
    now = s[0]
    for i in range(1, n):
        if s[i] == now:
            c += 1
            if i == n - 1:
                if now == "0":
                    zero.append(c)
                else:
                    one.append(c)
        else:
            if now == "0":
                zero.append(c)
                if i == n - 1:
                    one.append(1)
            else:
                one.append(c)
                if i == n - 1:
                    zero.append(1)
            c = 1
            now = s[i]

    pos_zero = len(zero)
    #print(zero, one)
    if pos_zero <= k:
        print(n)
        exit()
    q = sum(zero[:k])
    sum_zero = [q]
    for i in range(pos_zero - k):
        q = q - zero[i] + zero[k + i]
        sum_zero.append(q)
    pos_one = len(one)
    q = sum(one[:k])
    sum_one = [q]
    for i in range(pos_one - k):
        q = q - one[i] + one[k + i]
        sum_one.append(q)
    ans = sum_zero[0] + sum_one[0]
    #print(sum_zero)
    #print(sum_one)
    for i in range(1, pos_zero - k + 1):
        if i - 1 < pos_one and i < len(sum_one):
            ansq = sum_zero[i] + sum_one[i] + one[i - 1]
        elif i < len(sum_one):
            ansq = sum_zero[i] + sum_one[i]
        elif i-1 < pos_one:
            ansq = sum_zero[i] + one[i-1]
        else:
            ansq = sum_zero[i]
        ans = max(ans, ansq)

    print(ans)
else:
    zero = []
    one = []
    c = 1
    now = s[0]
    for i in range(1, n):
        if s[i] == now:
            c += 1
            if i == n - 1:
                if now == "0":
                    zero.append(c)
                else:
                    one.append(c)
        else:
            if now == "0":
                zero.append(c)
                if i == n - 1:
                    one.append(1)
            else:
                one.append(c)
                if i == n - 1:
                    zero.append(1)
            c = 1
            now = s[i]
    one.append(0)
    pos_zero = len(zero)
    #print(zero, one)
    if pos_zero <= k:
        print(n)
        exit()
    q = sum(zero[:k])
    sum_zero = [q]
    for i in range(pos_zero - k):
        q = q - zero[i] + zero[k + i]
        sum_zero.append(q)
    pos_one = len(one)
    q = sum(one[:k+1])
    sum_one = [q]
    for i in range(pos_one - k -1):
        q = q - one[i] + one[k + i + 1]
        sum_one.append(q)
    ans = sum_zero[0] + sum_one[0]
    #print(sum_zero)
    #print(sum_one)
    for i in range(1, pos_zero - k + 1):
        ansq = sum_zero[i] + sum_one[i]
        ans = max(ans, ansq)

    print(ans)

Measured memory_bytes: 45552