akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using ll=long long;

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n,k; cin>>n>>k;
  double ans=0;
  vector<int> p(n);
  rep(i,n) cin>>p.at(i);
  double memo;
  rep(i,n){
    if(k>i){
      ans+=p.at(i);
      memo+=p.at(i);
    }else{
      memo+=p.at(i)-p.at(i-k);
      ans=max(memo,ans);
    }
  }
  cout<<fixed<<setprecision(6);
  cout<<(ans+k)/2<<endl;
}

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

const int MOD=998244353;
const int INF=0x3f3f3f3f;
const ll INFL=0x3f3f3f3f3f3f3f3f;

P p[300000];
vector<int>E[300000];
bool used[300000];

ll dfs(int v){
	used[v]=true;
	ll res=1;
	for(int u:E[v]){
		(res*=dfs(u))%=MOD;
	}
	(res+=1)%=MOD;
	return res;
}
int main(){
	int n;cin>>n;
	rep(i,n){
		scanf("%d%d",&p[i].first,&p[i].second);
	}
	sort(p,p+n);
	set<P>se;
	for(int i=n-1;i>=0;i--){
		while(!se.empty()&&se.begin()->first<p[i].first+p[i].second){
			E[i].push_back(se.begin()->second);
			se.erase(se.begin());
		}
		se.insert(P(p[i].first,i));
	}
	ll ans=1;
	rep(i,n){
		if(!used[i]){
			(ans*=dfs(i))%=MOD;
		}
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 24704
H,W = map(int,input().split())
if H%3 == 0 or W%3 == 0:
    print(0)
    exit()

if H > W:
    H,W = W,H

ans = min(H,W)

if H%2 == 0:
    for lw in range(1,W):
        a = lw * H
        b = (W-lw) * (H//2)
        ans = min(ans, abs(a-b))
else:
    for lw in range(1,W):
        a = lw * H
        b = (W-lw) * (H//2)
        c = (W-lw) * (H//2 + 1)
        tmp = max(a,b,c) - min(a,b,c)
        ans = min(ans, tmp)

H,W = W,H

if H%2 == 0:
    for lw in range(1,W):
        a = lw * H
        b = (W-lw) * (H//2)
        ans = min(ans, abs(a-b))
else:
    for lw in range(1,W):
        a = lw * H
        b = (W-lw) * (H//2)
        c = (W-lw) * (H//2 + 1)
        tmp = max(a,b,c) - min(a,b,c)
        ans = min(ans, tmp)

print(ans)

Measured memory_bytes: 3064
// inputに入力データ全体が入る
function Main(input) {
	var args = input.split("\n");
	var A = parseInt(args[0],10);
	var B = parseInt(args[1],10);
	var C = parseInt(args[2],10);
	var X = parseInt(args[3],10);
	var count = 0;

	for(var i = 0 ; i <= A ; i++){//500
		for(var j = 0 ; j <= B ; j++){//100
			for(var k = 0 ; k <= C ; k++){//50
				var sum = 500 * i + 100 * j + 50 * k;
				if(sum == X) count++;
			}
		}
	}
	//出力
	console.log(count);
}

//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 22964
N = int(input())
eat = list(map(int, input().split())) #料理の番号
sat = list(map(int, input().split())) #i番目の料理の満足度
ad_sat = list(map(int, input().split())) #追加の満足度

#print(N, eat, sat, ad_sat)
sum_sat = sat[eat[0]-1]
for i in range(1,N):
  sum_sat += sat[eat[i]-1]
  #print(eat[i]-1)
  #print(sum_sat)
  if eat[i] == 1 + eat[i-1]:
    sum_sat += ad_sat[eat[i-1]-1]
    #print("add")

print(sum_sat)

Measured memory_bytes: 3064
#include <set>
#include <array>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <stack>
#include <queue>
#include <vector>
#include <tuple>
#include <string>
#include <math.h>
#include <time.h>
#include <bitset>
#include <stdio.h>
#include <string.h>
#include <iostream>
#include <algorithm>
#include <limits>
#include <climits>
#include <numeric>

#define lnd '\n'
// #define reverse(i, n) for(ll i = n-1; i >= 0; --i)
#define from(i, n) for (ll i = 0; i < n; ++i)
#define REPN(i, n) for (ll i = 1; i <= n; ++i)
#define ALL(s) (s).begin(), (s).end()
#define rALL(s) (s).rbegin(), (s).rend()
#define sz(s) (int)(s).size()
#define mk make_pair
#define pb push_back
#define sqr(s) ((s) * (s))

using namespace std;

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef unsigned int ui;


void solution();

template <class T>
T GCD (T a, T b) {
  if(a == 0) return b;
  return GCD(b%a, a);
}

template <class T>
T modpow(T x, T p){
    T res = 1;
    while(p > 0){
        if(p&1) res *= x;
        x *= x;
        p /= 2;
    }
    return res;
}

template <class T>
void print(T a[], ll n){
    for (ll i = 0; i < n; i++) std::cout << a[i] << ' ';
    cout << endl;
}

template<class T>
void printc(T c){
    for(auto const& v: c) std::cout << v << ' ';
    cout << endl;
}

struct HASH{
  size_t operator()(const pair<long,long>&x)const{
    return hash<long long>()(((long long)x.first)^(((long long)x.second)<<32));
  }
};

bool pair_sort(const pair<int, int> &p1, const pair<int,int> &p2){
    if(p1.first != p2.first) return p1.first < p2.first;
    else return p1.second < p2.second;
}

const int INF = std::numeric_limits<int>::max();
const ll M_INF = std::numeric_limits<ll>::min();

int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    solution();
    return 0;
}



void solution(){
    ll n;
    cin >> n;
    unordered_map<string, int> maps;
    from(i, n){
        string s;
        cin >> s;
        maps[s]++;
    }

    vector<pair<int, string>> ans(maps.size());
    for(auto item: maps){
        ans.emplace_back(item.second, item.first);
    }

    sort(ans.begin(), ans.end(), [](auto &x, auto &y)->bool{
        if(x.first == y.first) return x.second < y.second;
        else return x.first > y.first;
    });

    int first = ans[0].first;
    for(auto &v: ans){
        if(v.first == first){
            cout << v.second << endl;
        }else{
            break;
        }
    }
}   

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

namespace ABC123A
{
    class Program
    {
        static void Main(string[] args)
        {
            var a = int.Parse(Console.ReadLine());
            var x = int.Parse(Console.ReadLine());
            x = int.Parse(Console.ReadLine());
            x = int.Parse(Console.ReadLine());
            var e = int.Parse(Console.ReadLine());
            var k = int.Parse(Console.ReadLine());
            if (e - a <= k)
            {
                Console.WriteLine("Yay!");
            }
            else
            {
                Console.WriteLine(":(");
            }

        }
    }
}


Measured memory_bytes: 13140
#include <iostream>
#include <algorithm>
#include <vector>

using namespace std;

int main()
{
	int a, b, c;

	cin >> a >> b >> c;

	if ((100*a + 10*b + c) % 4 == 0) {
		cout << "YES" << endl;
	}
	else {
		cout << "NO" << endl;
	}
}

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

public class Main {
	
	public static void main(String[] args) {
		try {
			BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
			String str = reader.readLine();
			String[] arr = str.split(" ");
			int a = Integer.parseInt(arr[0]);
			int b = Integer.parseInt(arr[1]);
			System.out.println(a * b + " " + (a + b) * 2);
		} catch (IOException e) {
			e.printStackTrace();
		}
	}

}

Measured memory_bytes: 24148
#include <bits/stdc++.h>
#include <vector>
#include <string>

using namespace std;

vector<string> split(const string &s, char delim) {
  vector<string> elems;
  string item;
  for (char ch: s) {
    if (ch == delim) {
      if (!item.empty()) {
        elems.push_back(item);
      }
      item.clear();
    }
    else {
      item += ch;
    }
  }
  if (!item.empty()) {
    elems.push_back(item);
  }
  return elems;
}

string to_str_with_zero(int i, int w) {
  ostringstream sout;
  sout << std::setfill('0') << std::setw(w) << i;
  string s = sout.str();
  return s;
}

int gcd(int a, int b) {
  if (a == b) {
    return a;
  }
  else if (a > b) {
    return gcd(a - b, b);
  }
  else {
    return gcd(a, b - a);
  }
}

int main() {
  std::cout << std::setprecision(9);
  vector<int> x(5);
  for (int i=0; i<5; i++) {
    cin >> x.at(i);
    if (x.at(i) == 0) {
      cout << i + 1 << endl;
    }
  } 
}

Measured memory_bytes: 3600
#include <bits/stdc++.h>
using namespace std;
const int MOD=1e9+7;
const int INF=1e9;
//const int MOD=998244353;
const long long LINF=1e18;
//template
int N,now,T=200001;
map<int,int> ma;
int dpw[11][200001];
std::vector<int> v(T),w(T),dp(T),subma(T);//w[i]はi番目のmapのそれの容量
/*
v[i-1]<v[i]の場合はその分だけ0を付け足せばいい
v[i-1]==V[i]の場合は末尾に1を追加 mになろうとしたら1繰り上げて本人は0になる
v[i-1]>v[i]の場合は削ってから末尾に1を追加

0文字目に入ってきたらout

このままだと1e9個の容量を用意する必要があるので考える
mapで座圧して容量を差で考える
例えばv[i]で6の次に大きい数が9の場合、９のやつが容量pw(3,m)を持つと考える
*/
set<int> s;
int pw(int n,int k){
  if(k<0)return INF;
  if(n<=10)return dpw[n][k];
  if(k>9)return INF;
  int res=1;
  while(k--){
    res*=n;
    if(res>100000000)return INF;
    if(res<0)return INF;
  }
  return res;
}
bool can(int m){
  for(auto i=s.begin();i!=s.end();i++)dp[*i]=0;s.clear();
  /*
  if(m<=5){
    cout<<m<<":";for(int j=0;j<=5;j++)cout<<dp[j]<<" ";cout<<endl;
    for(auto p:s)cout<<p<<" ";cout<<endl;
  }
  */
  //if(m<=5)cout<<m<<":";
  //if(m<=5)for(int j=0;j<=10;j++)cout<<dp[j]<<" ";cout<<endl;
  for(int j=1;j<N;j++){
    if(v[j]>v[j-1]){
      for(auto i=s.upper_bound(subma[j-1]);i!=s.end();){
        dp[*i]=0;i=s.erase(i);
      }
    }
    else{
      dp[subma[j]]++; now=subma[j];
      while(dp[now]==pw(m,w[now])){
        dp[now]=0;s.erase(now);
        dp[--now]++;
      }
      s.insert(now);
    }
    /*
    if(m<=5){
      cout<<m<<":";for(int j=0;j<=5;j++)cout<<dp[j]<<" ";cout<<endl;
      for(auto p:s)cout<<p<<" ";cout<<endl;
    }
    */
    if(dp[0])return false;
  }
  return true;
}
//main
signed main(){
  cin>>N;
  for(int i=0;i<N;i++)cin>>v[i];
  bool f=true;for(int i=1;i<N;i++)if(v[i]<=v[i-1])f=false;if(f){cout<<1<<endl;return 0;}
  for(int i=0;i<N;i++)ma[v[i]]=0;
  ma[0]=0;int tmp=-1;int cnt=0;
  for(auto &p:ma){
    if(~tmp)w[cnt]=p.first-tmp;
    tmp=p.first;
    p.second=cnt++;
  }
  for(int i=0;i<N;i++)subma[i]=ma[v[i]];
  w[0]=-1;
  for(int i=2;i<=10;i++){
    dpw[i][0]=1;
    for(int j=1;j<T;j++){
      dpw[i][j]=min(10000000,dpw[i][j-1]*i);
      if(dpw[i][j]==10000000){
        for(int k=j+1;k<T;k++)dpw[i][j]=10000000;
        continue;
      }
    }
  }
  int l=1,r=N+2,m;
  while(r-l>1){
    m=(l+r)>>1;
    if(can(m))r=m;
    else l=m;
  }
  cout<<r<<endl;
}


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

using namespace std;

#define REP(i, n) for (int i = 0; i < (n); i++)
#define int long long
#define FOR(i, m, n) for (int i = (m); i < (n); i++)
using Point = complex<double>;
constexpr double EPS = 1e-8;

struct Circle {
    double x, y, z, r;
    Circle(double x, double y, double z, double r) : x(x), y(y), z(z), r(r) {}
};

double dist(const Circle &a, const Circle &b) {
    double d = sqrt((a.x - b.x) * (a.x - b.x) + (a.y - b.y) * (a.y - b.y) + (a.z - b.z) * (a.z - b.z));
    d -= (a.r + b.r);
    if (d < EPS)
        return 0;
    else
        return d;
}

struct UnionFind {
    int N;
    vector<int> siz, par, Rank;

    UnionFind(int n) : siz(n, 1), par(n), Rank(n, 0), N(n) { REP(i, N) par[i] = i; }

    int find(int x) {
        if (par[x] == x)
            return x;
        else
            return par[x] = find(par[x]);
    }

    void unite(int x, int y) {
        x = find(x);
        y = find(y);
        if (x == y) return;
        if (Rank[x] < Rank[y]) {
            par[x] = y;
            siz[x] += siz[y];
            siz[y] = siz[x];
        } else {
            siz[y] += siz[x];
            siz[x] = siz[y];
            par[y] = x;
            if (Rank[x] == Rank[y]) Rank[x]++;
        }
    }
    bool same(int x, int y) { return find(x) == find(y); }
};

bool solve() {
    int N;
    cin >> N;
    if (N == 0) return false;
    vector<Circle> cs;
    REP(i, N) {
        double x, y, z, r;
        cin >> x >> y >> z >> r;
        cs.push_back(Circle(x, y, z, r));
    }
    UnionFind uf(N);
    double sum = 0;
    REP(_, N - 1) {
        double mn = 1e9;
        int id1 = 0, id2 = 0;
        REP(i, N) FOR(j, i + 1, N) {
            if (uf.same(i, j)) continue;
            double cost = dist(cs[i], cs[j]);
            if (cost < mn) {
                mn = cost;
                id1 = i, id2 = j;
            }
        }
        sum += mn;
        uf.unite(id1, id2);
    }
    cout << fixed << setprecision(3) << sum << endl;

    return true;
}

signed main() {
    while (solve())
        ;
}


Measured memory_bytes: 3180
# AtCoder Beginner Contest 125
# A - Biscuit Generator

'''
Result: All Correct
Score: 100
Code length: 91 Byte
Execution Time: 17 ms
Memory usage: 2940 KB
'''

hoge = input()
a, b, t = [int(x) for x in hoge.split(' ')]
print(int(((t+0.5)//a)*b))

Measured memory_bytes: 2940
using System;
using System.IO;
using System.Collections.Generic;

namespace ABC099A
{
    public class Program
    {
        void Solve(StreamScanner ss, StreamWriter sw)
        {
            //---------------------------------
            var N = ss.Next(int.Parse);
            if (N <= 999) sw.WriteLine("ABC");
            else sw.WriteLine("ABD");
            //---------------------------------
        }

        static void Main()
        {
            var ss = new StreamScanner(new StreamReader(Console.OpenStandardInput()));
            var sw = new StreamWriter(Console.OpenStandardOutput()) {AutoFlush = false};
            new Program().Solve(ss, sw);
            sw.Flush();
        }

        static readonly Func<string, string> String = s => s;
    }

    public class StreamScanner
    {
        static readonly char[] Sep = {' '};
        readonly Queue<string> buffer = new Queue<string>();
        readonly TextReader textReader;

        public StreamScanner(TextReader textReader)
        {
            this.textReader = textReader;
        }

        public T Next<T>(Func<string, T> parser)
        {
            if (buffer.Count != 0) return parser(buffer.Dequeue());
            var nextStrings = textReader.ReadLine().Split(Sep, StringSplitOptions.RemoveEmptyEntries);
            foreach (var nextString in nextStrings) buffer.Enqueue(nextString);
            return Next(parser);
        }

        public T[] Next<T>(Func<string, T> parser, int x)
        {
            var ret = new T[x];
            for (var i = 0; i < x; ++i) ret[i] = Next(parser);
            return ret;
        }

        public T[][] Next<T>(Func<string, T> parser, int x, int y)
        {
            var ret = new T[y][];
            for (var i = 0; i < y; ++i) ret[i] = Next(parser, x);
            return ret;
        }
    }
}

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

// Optimization
//#pragma GCC optimize("O3")
#define endl '\n'

// Shortcut

#define int long long
#define eb emplace_back
#define pb push_back
#define pob pop_back
#define mp make_pair
#define upb upper_bound
#define lwb lower_bound
#define fi first
#define se second
#define For(i, l, r) for (int i = l; i < r; i++)
#define ForE(i, l, r) for (int i = l; i <= r; i++)
#define Ford(i, r, l) for (int i = r; i > l; i--)
#define FordE(i, r, l) for (int i = r; i >= l; i--)
#define Fora(i, a) for (auto i : a)

// I/O & Debug

#define PrintV(a) for (int iiii = 0; iiii < a.size(); iiii++) cout << a[iiii] << ' ';
#define PrintVl(a) for (int iiii = 0; iiii < a.size(); iiii++) cout << a[iiii] << endl;
#define PrintA(a, n) for (int iiii = 0; iiii < n; iiii++) cout << a[iiii] << ' ';
#define PrintAl(a, n) for (int iiii = 0; iiii < n; iiii++) cout << a[iiii] << endl;
#define Ptest(x) return cout << x, 0;
#define gl(s) getline(cin, s);
#define setpre(x) fixed << setprecision(x)
/*
#define debug(args...){ string _sDEB = #args; replace(_sDEB.begin(), _sDEB.end(), ',', ' '); stringstream _ssDEB(_sDEB); istream_iterator<string> _itDEB(_ssDEB); DEB(_itDEB, args); }
void DEB(istream_iterator<string> it) {}
template<typename T, typename... Args>
void DEB(istream_iterator<string> it, T a, Args... args){
    cout << *it << " = " << a << endl;
    DEB(++it, args...);
}
*/

// Functions

//#define isvowel(a) (a == 'a' || a == 'e' || a == 'i' || a == 'o' || a == 'u')
#define bend(a) a.begin(), a.end()
#define rbend(a) a.rbegin(), a.rend()
#define mset(a) memset(a, 0, sizeof(a))
#define m1set(a) memset(a, 1, sizeof(a))
#define mn1set(a) memset(a, -1, sizeof(a))
#define mmset(a) memset(a, 0x3f, sizeof(a))
#define gcd __gcd
#define __builtin_popcount __builtin_popcountll
//mt19937 rando(chrono::steady_clock::now().time_since_epoch().count());

// Data Structure

#define pque priority_queue
#define mts multiset
#define y0 _y0_
#define y1 _y1_
#define div divi
typedef long long ll;
typedef long double ld;
typedef vector <int> vi;
typedef vector <ll> vll;
typedef vector <ld> vld;
typedef vector <string> vs;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef vector <vi > vvi;
typedef vector <vll > vvll;
typedef vector <pii > vpii;
typedef vector <pll > vpll;

const int N = 3e5 + 5, mod = 1e9 + 7, mod1 = 998242353, mod2 = 1e9 + 9;
const ll inf = 1e18 + 7;

int a, b;

signed main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    cin >> a >> b;
    a--;
    b--;
    cout << (b + a - 1) / a;
}

/*
==================================+
INPUT:                            |
------------------------------    |

------------------------------    |
==================================+
OUTPUT:                           |
------------------------------    |

------------------------------    |
==================================+
*/

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<iostream>
#include<cstdio>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
using namespace std;
#define rep(i,x) for(ll i = 0; i < (ll)(x); i++)
#define rrep(i,x) for(ll i = (ll)(x)-1;0 <= i; i--)
#define reps(i,x) for(ll i = 1; i < (ll)(x)+1; i++)
#define rreps(i,x) for(ll i = (ll)(x); 1 <= i; i--)
#define debug(x) cerr << #x << ": " << (x) << "\n";
#define all(x) (x).begin(), (x).end()
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<ll,ll> Pll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef vector<vector<vector<ll>>> vvvl;
const ll INF = numeric_limits<ll>::max()/4;
const int n_max = 1e5+10;

template<class T>
bool chmax(T &a, T b){if(a < b){a = b; return true;} return false;}
template<class T>
bool chmin(T &a, T b){if(a > b){a = b; return true;} return false;}

int main(){
    ll a,b,m; cin >> a >> b >> m;
    vector<ll> A(a);
    rep(i,a) cin >> A[i];
    vector<ll> B(b);
    rep(i,b) cin >> B[i];
    ll ans = INF;
    rep(i,m){
        ll x,y,c; cin >> x >> y >> c;
        x--;y--;
        chmin(ans, A[x] + B[y] - c);
    }

    chmin(ans, *min_element(all(A)) + *min_element(all(B)));

    cout << ans << endl;
}

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

int main(){
  string S;cin>>S;
  int n=(S.size()-1)/2;
  bool ans=1;
  for(int i=0;i<(n+1)/2;i++){
    if(S.at(i)!=S.at(n-1-i)||S.at(i)!=S.at(n+1+i)||S.at(i)!=S.at(S.size()-1-i)){
      ans=0;
      break;
    }
  }
  cout<<(ans?"Yes":"No")<<endl;
}



Measured memory_bytes: 256
def main():
  n = str(input())
  
  if n[-1]=='2' or n[-1]=='4' or n[-1]=='5' or n[-1]=='7' or n[-1] =='9':
    print('hon')
  elif n[-1]=='0' or n[-1]=='1' or n[-1]=='6' or n[-1]=='8':
    print('pon')
  else:
    print('bon')
    
main()

Measured memory_bytes: 9056
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); ++i)
#define rep2(i,n) for(int i=1; i<=(n); ++i)
#define all(x) (x).begin(),(x).end()
#define Sort(x) sort((x).begin(),(x).end())
#define Sort2(x) sort((x).begin(),(x).end(), greater<int>())
#define pb push_back
using namespace std;
using ll = long long;
using P = pair<int,int>;
using Graph = vector<vector<int>>;

static int INF = 1001001001;

int a[12][12];

int main()
{
    int n,m,x; cin >> n >> m >> x;
  	vector<int> c(n);
    rep(i,n){
      cin >> c[i];
      rep(j,m) cin >> a[i][j];
    }
    int mn_cost = INF;
    // n冊のビット演算。3冊なら8。0~7。000 ~ 111。
    rep(s, 1<<n){
      vector<int> rikaido(m,0);
      int cost = 0;
      rep(i, n){
        if(s>>i&1){
          //i冊目を読む
          cost += c[i];
          rep(j,m) rikaido[j] += a[i][j];
        }
        bool flg = true;
        for(int r : rikaido){
          if(r < x) flg = false;
        }
        if(flg) mn_cost = min(mn_cost, cost);
      }
    }
    if(mn_cost == INF) cout << -1 << endl;
    else cout << mn_cost << endl;
  
    return 0;
}

/*
g++ c.cpp
./a.out

oj d https://atcoder.jp/contests/abc167/tasks/abc167_c
oj t
*/


Measured memory_bytes: 3612
#include <iostream>
#include <cstring>
#include <algorithm>
#include <iomanip>
#include <vector>
#include <map>
#include <cmath>
#include <queue>
#include <utility>
#include <functional>
#include <deque>
#include <cctype>
#include <stack>
#include <bitset>

using ll = long long;
using namespace std;
typedef unsigned long long ull;
typedef pair<ll, ll>P;

ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a%b);
}
ll lcm(ll a, ll b) {
	ll g = gcd(a, b);
	return a / g * b;
}

const ll mod = 1000000007;
const ll INF = 1 << 30;
const ll INF2 = 9000000000000000000LL;
bool fl = true;
int dx[4] = { 1,0,-1,0 }, dy[4] = { 0,1,0,-1 };
string abc = "abcdefghijklmnopqrstuvwxyz";
struct edge { ll to, cost; };
struct edge1 { ll from, to, cost; };
double pai = 3.141592653589793;

int main() {
	ll n, a, b, c;
	string s, t;
	cin >> n >> a;
	cout << n*n - a << endl;
}

Measured memory_bytes: 256
import java.util.*;

public class Main{
    public static void main(String[] args){
	Scanner sc = new Scanner(System.in);

	double max = Double.MIN_VALUE;
	double min = Double.MAX_VALUE;
	while(sc.hasNext()){
	    double mountain = sc.nextDouble();

	    if(mountain>max){max = mountain;}
	    if(mountain<min){min = mountain;}

	}

	System.out.println(max-min);
    }
}

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

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    string S; cin >> S;
    vector<string> a={"KIH","B","R"};
    int ok=0;
    for (int mask=0;mask<(1<<4);++mask){
        string check="";
        for (int i=0;i<4;++i){
            if (mask&1<<i) check+='A';
            if (i<3) check+=a[i];
        }
        if (S==check) ok=1;
    }
    cout << (ok?"YES":"NO") << '\n';
}

Measured memory_bytes: 256
import std.stdio;
import std.conv, std.array, std.algorithm, std.string;
import std.math, std.random, std.range, std.datetime;
import std.bigint;
import std.container;
string read(){ static string[] ss; while(!ss.length) ss = readln.chomp.split; string res = ss[0]; ss.popFront; return res; }

// when small

// [t, t] -> (t - 1) * 2
// [t + 2, t - 1] -> t * 2 - 1

// (k: odd)  t = (k + 1) / 2, n = 2, as = [t + 2, t - 1]
// (k: even) t = k / 2 + 1, n = 2, as = [t, t]


// when larger

// [t, t, ..., t] (50) -> (t - 49) * 50
// [t + a, t + a, ..., t + a] (b) ~ [t - b, t - b, ..., t - b] (50 - b) -> (t - 49) * 50 + b
// where a = 50 - (b - 1)

// k = 50 * m + r
// m = t - 49, r = b
// t = m + 49, a = 49 - r, b = r

void main(){
	long k = read.to!long;
	
	long n;
	long[] as;
	
	if(k < 100000){
		
		n = 2;
		if(k % 2) as = [(k + 1) / 2 + 2, (k + 1) / 2 - 1];
		else as = [k / 2 + 1, k / 2 + 1];
		
		}
	else{
		
		n = 50;
		long m = k / 50, r = k % 50;
		if(r == 49){
			long t = m + 49, a = 49 - r + 2, b = r;
			foreach(i; 0 .. b) as ~= t + a;
			foreach(i; 0 .. 50 - b) as ~= t - b;
			}
		else{
			long t = m + 49, a = 49 - r, b = r;
			foreach(i; 0 .. b) as ~= t + a;
			foreach(i; 0 .. 50 - b) as ~= t - b;
			}
		
		}
		
	n.writeln;
	as.map!(to!string).join(" ").writeln;
	
	
	}



Measured memory_bytes: 256
#include <algorithm>
#include <cstdio>
const int MAXN = 5005;
char S[MAXN];
int dp[MAXN][MAXN];
int N;

int solve() {
  for (int i = 0; i <= N; ++i) {
    dp[i][0] = dp[0][i] = 0;
  }
  int ret = 0;
  for (int i = 1; i <= N; ++i) {
    for (int j = 1; j <= N; ++j) {
      if ((i == j) || (S[i] != S[j])) {
        dp[i][j] = 0;
      } else if (S[i] == S[j]) {
        dp[i][j] = std::min(dp[i-1][j-1] + 1, std::abs(i - j));
        ret = std::max(dp[i][j], ret);
      }
    }
  }
  return ret;
}

int main() {
  scanf(" %d%s", &N, S+1);
  printf("%d\n", solve());
  return 0;
}

Measured memory_bytes: 98048
#include <cstdio>
#include <cstring>
#include <algorithm>
 
using std::inplace_merge;
using std::sort;
 
const int MAXN=200005;
int n;
int a[MAXN],b[MAXN];
 
void mge_sort(int a[],int mid){
	int pos=n;
	for(int i=0;i<n;++i){
		if(pos==n&& a[i]>=mid) pos=i;
		a[i]&=mid-1;
	}
	inplace_merge(a,a+pos,a+n);
}
 
inline long long cal(int lim){
	long long ret=0;
	for(int i=0,cur=n-1;i<n;++i){
		while(cur>=0 && a[i]+b[cur]>=lim)
			--cur;
		ret+=n-1-cur;
	}
	return ret;
}
 
int main(){
	scanf("%d",&n);
	for(int i=0;i<n;++i)
		scanf("%d",&a[i]);
	for(int i=0;i<n;++i)
		scanf("%d",&b[i]);
	sort(a,a+n),sort(b,b+n);
	int ans=0;
        long long tmp;
	for(int i=28;i>=0;--i){
		mge_sort(a,2<<i),mge_sort(b,2<<i);
		tmp=cal(1<<i)-cal(2<<i)+cal(3<<i);
		ans|=(tmp&1)<<i;
	}
	printf("%d",ans);
	return 0;
}

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

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

   	if(s[s.length()-1] == 's'){
   		cout << s + "es" << endl;
   	} else {
   		cout << s + "s" << endl;
   	}

    return 0;
}



Measured memory_bytes: 3608
N = int(input())
p = list(map(int, input().split()))
ans = 0
for i in range(N - 1):
    if p[i] == i + 1:
        p[i], p[i + 1] = p[i + 1], p[i]
        ans += 1

if p[-1] == N:
    ans += 1

print(ans)


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

int main(){
    int N;
    cin >> N;
    vector<int> A(N);
    for(int i = 0; i < N; i ++){
        cin >> A.at(i);
    }
    sort(A.begin(), A.end());
    cout << A.at(N-1) - A.at(0) <<endl;
}

Measured memory_bytes: 256
n = gets.to_i
g = (1..n).map{ Array.new(n, 0) }
n.times do
  u, k, *v = gets.split(' ').map(&:to_i)
  v.each do |vi|
    g[u - 1][vi - 1] = 1
  end
end

# p g

g.each do |r|
  puts r.join(" ")
end

Measured memory_bytes: 8828
#include <bits/stdc++.h>
#define F first
#define S second
using namespace std;
typedef long long LL;
typedef pair<int, int> pii;
const LL INF = 0x3f3f3f3f3f3f3f3fLL;
const LL MOD = 1e9 + 7;
const int MAXV = 1e5 + 5;
void marmot0814() {
    int n, m; cin >> n >> m;
    vector<vector<char>> G(n, vector<char>(m));
    for (auto &vv : G)
        for (auto &c : vv)
            cin >> c;
    vector<vector<LL>> dp(n, vector<LL>(m, 0));
    dp[0][0] = 1;
    for (int i = 0 ; i < n ; i++) {
        for (int j = 0 ; j < m ; j++) {
            if (G[i][j] == '#')
                continue;
            LL sum = 0;
            if (i - 1 >= 0)
                (sum += dp[i - 1][j]) %= MOD;
            if (j - 1 >= 0)
                (sum += dp[i][j - 1]) %= MOD;
            dp[i][j] += sum;
        }
    }
    cout << dp[n - 1][m - 1] << '\n';
}
int main() {
    ios_base::sync_with_stdio(false); cin.tie(0);
    int t = 1, kase = 0; // cin >> t;
    while (t--) {
        // cout << "Case #" << ++kase << ":";
        marmot0814();
    }
}

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

int n,m,memo[110][110][11];
vector<int> x,a,b,c;

int rec(int l, int r, int k){
  if(memo[l][r][k])return memo[l][r][k];
  if(r<=l)return -1;
  if(r-l==1)return (x[l] == a[k]) ? 1 : -1;
  
  int res = -1;
  for(int m=l+1;m<r;m++){
    if(rec(l,m,b[k])>0 && rec(m,r,c[k])>0){
      res = 1;
      break;
    }
  }

  return memo[l][r][k] = res;
}

int main(){
  cin >> n;
  x.resize(n);
  rep(i,n)cin >> x[i];
  cin >> m;
  a = b = c = vector<int>(m);
  rep(i,m){
    cin >> a[i] >> b[i] >> c[i];
    b[i]--; c[i]--;
  }

  memset(memo,0,sizeof(memo));
  cout << (rec(0,n,0)>0 ? "Yes" : "No") << endl;
}

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

LL n, x, y, minx = 1e18, maxx= -1e18, miny = 1e18, maxy = -1e18;
 
int main() {
    LL n;
    cin >> n;
    for (int i = 1; i <= n; i++) {
        LL x, y;
        cin >> x >> y;
        minx = min(minx, x + y), maxx = max(maxx, x + y);
        miny = min(miny, x - y), maxy = max(maxy, x - y);
    }
    cout << max(maxx - minx, maxy - miny) << endl;
    return 0;
}

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

using namespace std;

#define fi first
#define se second
#define pb push_back
#define mp make_pair

#define int long long

typedef pair<int, int> ii;

const int mod = 1e9 + 7;

const int N = 2e5 + 5;

const int inf = 1e15;

int dp[N], n, h[N], c, pter = 0;

vector<ii> vec;

int mul(int x, int y) {
    return (1ll * x * 1ll * y) % mod;
}

int del(int x, int y) {
    return ((1ll * x - 1ll * y) % mod + mod) % mod;
}

long double findx(ii x, ii y) {
    return ((long double)(y.se) - (long double)(x.se)) / ((long double)(x.fi) - (long double)(y.fi));
}

bool compare(ii x, ii y, ii z) {
    return(findx(x, y) > findx(x, z));
}

void add(int a, int b) {
    vec.pb({a, b});
    while(vec.size() >= 3 && compare(vec[vec.size() - 3], vec[vec.size() - 2], vec[vec.size() - 1])) {
        vec.pop_back();
        vec.pop_back();
        vec.pb({a, b});
    }
}

int query(int x) {
    pter = min(pter, (long long)(vec.size()) - 1);
    while(pter + 1 < vec.size() && vec[pter].fi * x + vec[pter].se >= vec[pter + 1].fi * x + vec[pter + 1].se)
        pter++;
    return vec[pter].fi * x + vec[pter].se;
}

signed main() {
    cin.tie(0), ios::sync_with_stdio(0);
    cin >> n >> c;
    for(int i = 1; i <= n; i++)
        cin >> h[i];
    dp[1] = 0;
    add(-2 * h[1], h[1] * h[1] + dp[1] + c);
    for(int i = 2; i <= n; i++) {
        dp[i] = query(h[i]) + h[i] * h[i];
        add(-2 * h[i], h[i] * h[i] + dp[i] + c);
    }
    cout << dp[n];
}



Measured memory_bytes: 9200
#include<bits/stdc++.h>
#define ll long long
#define clr(x,i) memset(x,i,sizeof(x))
using namespace std;
const int N=200005;
const ll mod=1e9+7;
inline int read()
{
    int x=0,f=1; char ch=getchar();
    while(ch<'0'||ch>'9') {if(ch=='-') f=-1; ch=getchar();}
    while(ch>='0'&&ch<='9') {x=x*10+ch-'0',ch=getchar();}
    return x*f;
}
vector<int> G[N];
int n,siz[N],siz2[N];
ll fac[N],inv[N],f[N],f2[N],ans[N];
ll qpow(ll x,ll k)
{
	ll ret=1;
	while(k){
		if(k&1) ret*=x,ret%=mod;
		x*=x,x%=mod,k>>=1;
	}
	return ret;
}
ll INV(ll x)
{
	return qpow(x, mod-2);
}
ll C(int x,int y)
{
	return fac[x]*inv[y]%mod*inv[x-y]%mod;
}
void dfs1(int u,int pre)
{
	ll s=0; f[u]=siz[u]=1;
	for(auto v:G[u])if(v!=pre){
		dfs1(v, u); s+=siz[v]; siz[u]+=siz[v];
		f[u]=f[u]*f[v]%mod*C(s, siz[v])%mod;
	}
}
void dfs2(int u,int pre)
{
	if(u!=1){
		siz2[u]=n; siz2[pre]=n-siz[u];
		f2[pre]=ans[pre]*INV(f[u])%mod*INV(C(n-1, siz[u]))%mod;
		f2[u]=f[u]*f2[pre]%mod*C(siz[u]-1+siz2[pre], siz2[pre])%mod;
	}
	else f2[u]=f[u];
	ans[u]=f2[u];
	for(auto v:G[u]) if(v!=pre) dfs2(v, u);
}
int main()
{
	n=read();
	for(int i=1; i<n; i++){
		int u=read(),v=read();
		G[u].push_back(v); G[v].push_back(u);
	}
	fac[0]=1;
	for(int i=1; i<=n; i++) fac[i]=fac[i-1]*i%mod;
	inv[n]=INV(fac[n]);
	for(int i=n-1; ~i; i--) inv[i]=inv[i+1]*(i+1)%mod;
	dfs1(1, 0);
//	for(int i=1; i<=n; i++) printf("%lld\n",f[i]); puts("");
	dfs2(1, 0);
	for(int i=1; i<=n; i++) printf("%lld\n",ans[i]);
	return 0;
}

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

int main() {
  cin.tie(0); ios::sync_with_stdio(false);
  int n; cin >> n;
  long long a[n];
  for (int i = 0; i < n; i++) cin >> a[i];
  long long res = 0;
  for (int i = 0; i < n - 1; i++) {
    res += a[i] / 2;
    a[i] %= 2;
    if (a[i] == 1 && a[i + 1] > 0) {
      a[i + 1]--;
      res++;
    }
  }
  res += a[n - 1] / 2;
  cout << res << "\n";
  return 0;
}

Measured memory_bytes: 1024
#include<iostream>
#include<map>
#include<vector>
#include<set>
#include<unordered_map>
#include<unordered_set>
#include<utility>
#include<algorithm>
#include<deque>

#define ssync ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0)
#define F first
#define S second
#define mp make_pair
#define pb push_back

using namespace std;

typedef long long int ll;
typedef unsigned long long int ull;
typedef long double ld;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef vector<vs> vvs;
typedef vector<ll> vll;
typedef vector<vll> vvl;
typedef pair<int,int> pii;
typedef pair<int,ll> pil;
typedef pair<ll,ll> pll;
const ll MOD = 1e9+7;
const ld PI = 3.14159265;

ll powerWithMod(ll base, ll exponent, ll modulus = LLONG_MAX)
{
	ll result = 1;
	base %= modulus;
	while(exponent > 0)
	{
		if(exponent % 2 == 1)
			result = (result * base) % modulus;
		exponent >>= 1;
		base = (base * base) % modulus;
	}
	return result;
}

ll modInverse(ll a, ll m = MOD)
{
	return powerWithMod(a, m-2, m);
}

int n;
ll a[123456], A, B;

bool check(ll k)
{
	ll tot=0;
	for(int i=1; i<=n; i++)
	{
		if(a[i] <= k*B)
			continue;
		tot += ((a[i] - k*B) + A - B - 1) / (A - B);
	}
	return tot <= k;
}

int main()
{
	ssync;
	cin >> n >> A >> B;
	for(int i=1; i<=n; i++)
		cin >> a[i];
	ll l=1, h=(ll)1e10;
	while(l+1 < h)
	{
		ll mid = (l + h)/2;
		if(check(mid))
			h=mid;
		else
			l=mid;
	}
	if(check(l-1))
		cout << l-1 << "\n";
	else if(check(l))
		cout << l << "\n";
	else
		cout << l+1 << "\n";
	return 0;
}

Measured memory_bytes: 1024
#define _CRT_SECURE_NO_WARNINGS

#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <set>
#include <map>
#include <vector>
#include <math.h>
#include <cmath>
#include <queue>
#include <stack>
#include <list>
#include <functional>
#include <numeric>
#include <iostream>
#include <string>
#include <time.h>

using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()
ll GCD(ll a, ll b) { return b ? GCD(b, a % b) : a; }

int N, A[112345], B[112345];
/*ll memo[112345][2];

ll f(int i, bool n) {
	if (memo[i][n] != -1) return memo[i][n];
	if (i == N + 1) return memo[i][n] = 0;
	ll a = 0, b = 0;
	ll c = 0;
	if (n) {
		a = min(B[i], A[i] - B[i - 1]);
		b = min(B[i], A[i + 1]);
	}
	else {
		a = min(B[i], A[i]);
		b = min(B[i], A[i + 1]);
	}
	return memo[i][n] = max(f(i + 1, false) + a, f(i + 1, true) + b);
}*/

int main() {

	//memset(memo, 0xff, sizeof(memo));

	scanf("%d", &N);

	rep(i, N+1) scanf("%d", &A[i]);
	rep(i, N) scanf("%d", &B[i]);

	ll c = 0;

	rep(i, N) {
		if (A[i] < B[i]) {
			B[i] -= A[i];
			c += A[i];
			if (A[i + 1] < B[i]) {
				c += A[i + 1];
				A[i + 1] = 0;
			}
			else {
				c += B[i];
				A[i + 1] -= B[i];
			}
		}
		else {
			c += B[i];
		}
	}
printf("%lld\n", c);
	//printf("%lld\n", f(0, false));

	return 0;
}


Measured memory_bytes: 1152
#include <bits/stdc++.h>
using namespace std;
#define lli long long int
#define rep(i, n) ;for (int i = 0;i < (int)(n);i++)
#define rep2(i, s, n) ;for (int i = s; i < (int)(n);i++)
#define ALL(vec)  (vec).begin(),(vec).end()
#define pi 3.1415926535897932384626433832795
#define MAX_INF 9223372036854775807
#define MIN_INF (922337203685477587+1)
#define sosuu 1000000007

int main() {
 lli N, A, B, lefty, righty;
  cin >> N >> A >> B;
  if(A<B)
    swap(A,B);
  lefty=B-1;
  righty=N-A;
  if((A-B)%2==0){
  cout << abs(A-B)/2 << endl;
  }
  else{
  if(lefty<righty){
  cout << lefty+1+(A-lefty-2)/2 << endl;
  }
  else{
  cout << righty+1+(N-righty-B)/2 << endl;  
  }
  }
}

Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<cstring>
#define LL long long
using namespace std;
char s[1000];
LL ans;
bool vis[1000];
int n;
void dfs(int x,int cnt)
{
	//if(cnt){
	LL res=0;
	for(int i=1;i<=n;i++)
	{
		res=res*10+s[i]-'0';
		if(vis[i]){
			ans+=res;res=0;
		}	
	}
	ans+=res;
	if(cnt==n-1) return;
	//}
	for(int i=x+1;i<n;i++)
	{
		if(!vis[i])
		{
			vis[i]=true;
			dfs(i,cnt+1);
			vis[i]=false;
		}
	}
}
int main()
{
	scanf("%s",s+1);
	n=strlen(s+1);
	dfs(0,0);
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    string s;
    cin>>s;
    int cnt[27];
    for(int i=0; i<27; i++) cnt[i]=0;
    int i=0;
    while(s[i]!='\0')
    {
        cnt[s[i]-'a']++;
        i++;
    }
    int c= 1;
    for(i=0; i<27; i++)
    { //cout<<cnt[i]<<" ";
        if(cnt[i]>0)
        {
            if(cnt[i]%2==0) c=1;
            else {c=0; break;}
        }
    }
    if(c==1) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    return 0;
}


Measured memory_bytes: 3604
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define rep1(i, n) for(ll i = 1; i < (ll)(n); i++)
const ll mo=1000000007;
const ll INF=1<<30;
ll ans=0;
char a[1010][1010];
ll b[1010][1010];
ll h,w;
const int dx[4] = {0, -1, 1, 0};
const int dy[4] = {-1, 0, 0, 1};
bool in(ll x,ll y){
    return (x>=0&&y>=0&&x<w&&y<h);
}

int main()
{ 

cin >> h>>w; 
queue<pair<int, int>> q;
rep(j,h)rep(i,w) {
    b[j][i]=INF;
    cin >> a[j][i];
    if(a[j][i]=='#'){
        q.push({i,j});
        b[j][i]=0;
    }
}
while(!q.empty()){
    pair<int, int> p = q.front();
    int x = p.first;
    int y = p.second;
    q.pop();
    rep(i,4){
        ll nx=x+dx[i];
        ll ny=y+dy[i];
        if(in(nx,ny)&&b[ny][nx]==INF){
            b[ny][nx]=b[y][x]+1;
            q.push({nx,ny});
        }
    }
}
rep(j,h)rep(i,w) {
    ans=max(ans,b[j][i]);
}
cout << ans << endl;
return 0;
} 

Measured memory_bytes: 17424
import java.util.Scanner;

class Main{
	public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int A = sc.nextInt();
        int B = sc.nextInt();
        
        System.out.print(lcm(A,B));
  
        
	}
	
	  private static long gcd(long m, long n) {
	        if(m < n) return gcd(n, m);
	        if(n == 0) return m;
	        return gcd(n, m % n);
	    }
	    
	    private static long lcm(long m, long n) {
	        return m * n / gcd(m, n);
	    }
    
}



Measured memory_bytes: 23124
#include<iostream>
#include<algorithm>
#include<vector>
#define all(c) (c).begin(),(c).end()

using namespace std;

int mergecount(vector<int> &a) {
  int count=0,n=a.size();
  if (n>1){
    vector<int>b(a.begin(),a.begin()+n/2);
    vector<int>c(a.begin()+n/2,a.end());
    count+=mergecount(b);
    count+=mergecount(c);
    for (int i=0,j=0,k=0;i<n;i++)
      if (k == c.size())a[i]=b[j++];
      else if (j == b.size())a[i]=c[k++];
      else if (b[j]<=c[k])a[i]=b[j++];
      else a[i]=c[k++],count+=n/2-j;
  }
  return count;
}

int main(void){
  int n;
  cin >> n;
  vector<int>v(n);
  for(int i=0;i<n;i++)cin >> v[i];
  int cnt=mergecount(v);
  sort(all(v));
  for(int i=0;i<n;i++)cout << v[i] << (i<n-1?" ":"\n");
  cout << cnt << endl;
  return 0;
}

Measured memory_bytes: 1220
#pragma GCC optimize("Ofast")
#include<iostream>
#include<stdio.h>
#include<algorithm>
#include<vector>
#include<string.h>
#include<math.h>
#include<map>
#include<iomanip>
#include<queue>

const long long INF = 1e17+7;
const long long MOD = 1e9+7;
const double PI=acos(-1);

using namespace std;

int main(){
	int x,t;
	cin >> x >> t;
	int ans = x-t;
	if(ans<0)ans=0;
	cout << ans << endl;
	return 0;
}



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

int main() {
    long long n, a, b, c, d, e;
    cin >> n >> a >> b >> c >> d >> e;
    
    long long mini = min({a, b, c, d, e});

    long long bn = (n - 1) / mini + 1;

    cout << bn + 4 << endl;
}

Measured memory_bytes: 3648
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define pii pair<int,int>
#define sorted(a_1) sort(a_1.begin(),a_1.end())
#define rsorted(a_1) sort(a_1.rbegin(),a_1.rend())
#define t1(a_1) cout<<a_1<<endl;
#define t2(a_1) for(auto it_test : a_1) cout<<it_test<<" ";
#define MOD 1000000007


ll dp[3001][3001];
ll maxValue(vector<int>&arr, int n, int i, int j){
	if(i==j){
		// t1(i)
		return arr[i];
	}
	if(dp[i][j]>-1) return dp[i][j];
	dp[i][j] = max(arr[i]-maxValue(arr,n,i+1,j),arr[j]-maxValue(arr,n,i,j-1));
	return dp[i][j];
}
void solve(){
    int n;
    cin>>n;
    vector<int>arr(n);
    for(int i=0;i<n;i++){
    	cin>>arr[i];
    }
    memset(dp,-1,sizeof(dp));
    ll ans = maxValue(arr,n,0,n-1);
    // dp[0][0] = 0;
    // for(int i=1;i<=n;i++){
    // 	for(int j=n-1;j>=0;j--){
    // 		if(i<j)
    // 			dp[i][j] = max(arr[i-1] - dp[i-1][j],arr[j]-dp[i][j+1]);
    // 		if(i==j){
	   //  		dp[i][j] = arr[i-1];
    // 			break;
    // 		}
    // 	}
    // }
    t1(ans)
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int t=1;
    while(t--){
        solve();
    }

return 0;
}

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

using namespace std;
typedef long long int ll;
typedef vector<int> vi;
typedef vector<ll> vl;

const int INF = 1e9;
const ll LINF = 1e18;
const int MOD = 1e9+7;
const int SIZE = 303;


int main() {
	int n;
	ll ans = 0;
	scanf ("%d", &n);
	ll d[SIZE][SIZE];
	ll m[SIZE][SIZE];

	for (int i = 0; i < n; i++) {
		for (int j = 0; j < n; j++) {
			ll buf; scanf("%lld", &buf);
			m[i][j] = buf;
			d[i][j] = buf;
			ans += buf;
		}
	}
	ans /= 2;
	
	bool flg = true;

	for (int k = 0; k < n; k++) {
		for (int i = 0; i < n; i++) {
			for (int j = i; j < n; j++) {
				if (d[i][j] > d[i][k] + d[k][j]) {
					d[i][k] = d[i][k] + d[k][j];
					flg = false;
				} else if (d[i][j] == d[i][k] + d[k][j]
						&& i != k
						&& j != k
						&& m[i][j] != LINF) {
//					ans -= d[i][j];
					m[i][j] = LINF;
				}
			}
		}
	}

	ll ans1 = 0;
	for (ll i = 0; i < n; i++) {
		for (ll j = i; j < n; j++) {
			if (m[i][j] != LINF) {
				ans1 += m[i][j];
			}
		}
	}

	if (flg) {
		printf("%lld\n", ans1);
	} else {
		printf("-1\n");
	}

	
}


Measured memory_bytes: 1664
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <utility>
#include <numeric>
#include <array>
#include <cmath>
#include <memory>
using namespace std;
//変数デバッグ
#define DEB(variable) cout << #variable << '=' << variable << endl

//for簡易表記(引数ミス防止)
#define FOR(LoopVariable,numberOFbegin,numberOFend) for (long long int LoopVariable = (numberOFbegin); (LoopVariable) < (numberOFend); (LoopVariable)++)
#define DEFOR(LoopVariable,numberOFbegin,numberOFend) for (long long int LoopVariable = (numberOFbegin)-1; (LoopVariable) >= (numberOFend); (LoopVariable)--)
#define REP(LoopVariable,numberOFend) for(long long int LoopVariable = 0;(LoopVariable)<(numberOFend);LoopVariable++)

constexpr long long int linf = numeric_limits<long long int>::max()-5;
constexpr int inf= numeric_limits<int>::max()-5;
constexpr long long int mod = 1000000007;

int main(){

    long long int n;
    cin>>n;
    double x=0;
    REP(i,n){
        if((i+1)%2==1){
            x++;
        }
    }
    cout<<x/n<<endl;

    return 0;
}


Measured memory_bytes: 888
#include<bits/stdc++.h>
using namespace std;
int main()
{
	long long n,l=0,r=0,d;
	cin>>n;
	long long i,j,a[n];
	for(i=0;i<n;i++)
	{
		cin>>a[i];
		l+=a[i];
	}
	for(i=n-1;i>=0;i--)
	{
		l-=a[i];
		r+=a[i];
		if(i==n-1 || abs(l-r)<d) d=abs(l-r);
	}
cout<<d;
}

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

int main()
{
    int n;
    std::cin >> n;
    std::vector<long long> a(n);
    long long l = 0, r = 0;
    for (int i = 0; i < n; i++) {
        std::cin >> a[i];
        r += a[i];
    }

    for (int i = 0; i < n; i++) {
        l += a[i];
        r -= a[i];

        if (l < r)
            continue;
        std::cout << std::min(std::abs(r-l), std::abs(r+a[i]-(l-a[i]))) << std::endl;
        return 0;
    }

    std::cout << std::abs(r - l) << std::endl;
    return 0;
}


Measured memory_bytes: 1792
#include <iostream>
#include <iomanip>
#include <cmath>
#include <vector>
#include <queue>
#include <limits>
#include <algorithm>
#include <string>
#include <set>
#include <map>
using namespace std;

int main()
{
	int32_t N;
	cin >> N;

	vector<int32_t> h(N);
	for (int32_t i = 0; i < N; i++) {
		cin >> h[i];
	}

	int32_t res = 0;
	bool allzero = false;
	while (!allzero) {
		int32_t start = 0;
		int32_t _min = h[start];
		allzero = true;
		for (int32_t i = 0; i < N; i++) {
			if (h[i] == 0) {
				if (i == start) {
					start++;
				} else {
					for (int32_t j = start; j < i; j++) {
						h[j] -= _min;
					}
					res += _min;
					start = i + 1;
				}
				if (start < N)
					_min = h[start];
			} else {
				_min = min(_min, h[i]);
				allzero = false;
			}
		}
		if (start < N) {
			for (int32_t j = start; j < N; j++) {
				h[j] -= _min;
			}
			res += _min;
		}
	}
	cout << res << endl;

	return 0;
}


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

int main(){
  int n,k;
  cin >> n >> k;
  vector<int> vec(n);
  for(int i=0;i<n;i++) cin >> vec.at(i);
  int count=0;
  for(int i=0;i<n;i++){
    if(vec.at(i) >= k) count++;
  }
  cout << count << endl;
  
}

Measured memory_bytes: 640
import math
n = int(input())

for a in range(11,-1,-1):
  if n > (26*pow(26,a)-26)/(26-1):
    break
n -= (26*pow(26,a)-26)/(26-1)+1
n = int(n)
a += 1

# print(n)

ans = []
for i in range(a):
  s = n%26
  ans.append(chr(97+s))
  n //= 26
print(''.join(ans[::-1]))


Measured memory_bytes: 61932
N = int(input())
A = [(i,int(input())) for i in range(N)]
B = sorted(A,key=lambda x:x[1],reverse=True)
cnt = 0
bmax = B[0][1]
for i in range(N):
    if B[i][1]==bmax:
        cnt += 1
    else:break
for i in range(N):
    if A[i][1] < bmax:
        print(bmax)
    elif A[i][1]==bmax and cnt==1:
        print(B[1][1])
    elif A[i][1]==bmax and cnt>1:
        print(bmax)

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

int main()
{
  int n,t;
  long long x,y,a,b;
  cin>>n;
  t=n-1;
  cin>>x>>y;
  while(t--)
  {
    cin>>a>>b;
    while(x%a) x++;
    if(b * (x/a)<y)
      {
        while(y%b) y++;
        x = a * (y/b);
      }
    else
      y = b * (x/a);
    //cout<<x<<" "<<y<<"\n";
  }
  cout<<x+y<<"\n";
  return 0;
}


Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <string.h>
int main(void)
{
	char s[101];
	int i, a = 0;
	scanf("%s", s);
	for (i = 0; i < strlen(s); i++) {
		if (a == 0 && s[i] == 'C')a = 1;
		if (a == 1 && s[i] == 'F')a = 2;
	}
	if (a == 2)puts("Yes");
	else puts("No");
	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <utility>
#include <sys/time.h>
#include <cmath>
#include <tuple>
#include <queue>

using namespace std;

void solve(string s) {
    string aki = "AKIHABARA";
    bool flag = true;
    while (!aki.empty()) {
        if (aki.back() == s.back()) {
            aki.pop_back();
            s.pop_back();
        } else if (aki.back() == 'A'){
            aki.pop_back();
        } else {
            flag = false;
            break;
        }
    }
    if (flag && s.empty()) {
        std::cout << "YES" << std::endl;
    } else {
        std::cout << "NO" << std::endl;
    }
}

int main() {
    struct timeval start,end;
    long long span;
    string s;

    gettimeofday(&start,NULL);

    std::cin >> s;
    solve(s);

    gettimeofday(&end,NULL);
    span = (end.tv_sec -start.tv_sec)*1000000LL + (end.tv_usec - start.tv_usec);
    std::cerr << "--Total Time: " << span/1000 << "ms" << endl;
    return 0;
}


Measured memory_bytes: 256
# coding: utf-8
# submission # - User: herp_sy
# https://atcoder.jp/contests/
#
# lang: Python3 (3.4.3)

s = input()
r, b = 0, 0
for i in range(len(s)):
  if s[i] == '0':
    r += 1
  else:
    b += 1
print(2 * min(r, b))


Measured memory_bytes: 3188
#include<bits/stdc++.h>
using namespace std;
int main(){
    string s;
    cin >> s;
    string t;
    bool ans=true;
    while(s.size()>0){
        t = s.substr(0,5);

        if(t=="erase"){
            s.erase(0,5);
            if(s[0]=='r')s.erase(0,1);
        }else if(t=="dream") {
            s.erase(0,5);
            if(s.substr(0,6)=="eraser")s.erase(0,6);
            else if(s.substr(0,5)=="erase")s.erase(0,5);
            else if(s.substr(0,2)=="er")s.erase(0,2);
        }
        else{
            ans=false;
            break;
        }
    }
    if(ans) cout <<"YES" <<endl;
    else cout << "NO" <<endl;

}

Measured memory_bytes: 3736
def si():

    n = int(input()) 
    tk = [input() for i in range(n)]
    tu = len(set(tk))
    l =[]
    k = []

 
        
    oo = 0


    while oo < tu:
        t = tk[oo]
        l.append(t[0])
        k.append(t[-1])
        oo += 1
        
    oo = 0


    while oo < tu-1:
        if k[oo] != l[oo+1]:
            return False
        
        oo += 1


    if tu != n:
        return False
    
    return True
    
if si():
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3064