akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define REPLL(i, n) for (ll i = 0; i < (ll)(n); i++)
using namespace std;
template<class T>inline bool chmax(T &a, const T &b){if(a < b){a = b; return 1;}return 0;}
template<class T>inline bool chmin(T &a, const T &b){if(a > b){a = b; return 1;}return 0;}
typedef long long ll;

int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll N, D, A; cin >> N >> D >> A;
  vector<pair<ll, ll> > XI(N, pair<ll, ll>());
  vector<ll> X(N, 0);
  vector<ll> H(N, 0);
  vector<ll> AA(N+1, 0);
  REPLL(i, N){
    ll x, h; cin >> x >> h;
    XI[i] = {x, i};
    X[i] = x;
    H[i] = h;
  }
  sort(XI.begin(), XI.end());
  sort(X.begin(), X.end());
  ll ans = 0;
  REP(i, N){
    if(i != 0){
      AA[i] += AA[i-1];
    }
    ll hh = H[XI[i].second];
    ll a = ((hh-AA[i]*A+(A-1))/A < 0 ? 0 : (hh-AA[i]*A+(A-1))/A);
    ans += a;
    AA[i] += a;
    ll dis = X[i]+2*D;
    auto itr = lower_bound(X.begin(), X.end(), dis);
    ll idx = *itr;
    if(idx == dis){
      AA[itr-X.begin()+1] += -a;
    }else{
      AA[itr-X.begin()] += -a; 
    }
  }
  cout << ans << endl;
}

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

const int inf = 1000000007;
const int MOD = 1000000007;
const long long INF = 1000000000000000007;

int main()
{
    int N;
    cin >> N;
    cout << N * N * N << endl;
}


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

using namespace std;
#define For(i,l,r) for (int i = l; i <= r; ++i)

int main() {
	int n;
	cin >> n >> n;
	int Max = 0, sum = 0;
	For(i,1,n) {
		int t;
		scanf("%d", &t);
		Max = max(Max, t);
		sum += t;
	}
	cout << max(0, Max * 2 - sum - 1) << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using vi = vector<int>;
using vvi = vector<vi>;
#define debug(x) cout<<#x<<" = "<<(x)<<endl


int N,D;
int X[10][20];

int isIntDistance(int i, int j){
  double dist = 0.0;
  for(int k=0; k<D; k++){
    dist += (X[i][k]-X[j][k]) * (X[i][k]-X[j][k]);
  }
  dist = sqrt(dist);
  //debug(dist);
  return (dist==(int)dist ? 1 : 0);
}

int main(){
  cin>>N>>D;
  for(int i=0; i<N; i++)for(int j=0; j<D; j++){
    cin>>X[i][j];
  }
  int ans = 0;
  for(int i=0; i<N; i++){
    for(int j=i+1; j<N; j++){
      ans += isIntDistance(i,j);
    }
  }

  cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <vector>
#include <set>
#include <map>
#include <cassert>
#include <queue>
#include <ctime>
#include <string>
#include <cstring>
#define mp make_pair
#define pb push_back
#define NAME ""
#define y1 y1_423
#define list lista

using namespace std;

typedef long long ll;
typedef long double ld;

template<typename T>
ostream& operator << (ostream& cout, const vector<T> &a) {
	if ((int)a.size() == 0) {
		return (cout << "()");
	}
	cout << "(" << a[0];
	for (int i = 1; i < (int)a.size(); i++) {
		cout << "; " << a[i];
	}
	return (cout << ")");
}

template<typename T>
ostream& operator << (ostream& cout, const set<T> &a) {
	if ((int)a.size() == 0) {
		return (cout << "{}");
	}
	auto it = a.begin();
	cout << "{" << *it;
	++it;
	for (; it != a.end(); ++it) {
		cout << "; " << *it;
	}
	return (cout << "}");
}

template<typename T>
ostream& operator << (ostream& cout, const multiset<T> &a) {
	if ((int)a.size() == 0) {
		return (cout << "{}");
	}
	auto it = a.begin();
	cout << "{" << *it;
	++it;
	for (; it != a.end(); ++it) {
		cout << "; " << *it;
	}
	return (cout << "}");
}

template<typename T1, typename T2>
ostream& operator << (ostream& cout, const pair<T1, T2> &a) {
	return cout << "(" << a.first << "; " << a.second << ")";
}

const int nmax = 2000 * 1000;
const int inf = 2000 * 1000 * 1000;
const ll infl = 1000ll * 1000ll * 1000ll * 1000ll * 1000ll * 1000ll;
const int mod = 1000 * 1000 * 1000 + 7;
const ld pi = acos(-1.0);

int n, m;
string s[nmax];

int main() {
	//freopen("input.txt", "r", stdin);freopen("output.txt", "w", stdout);
	//freopen(NAME".in", "r", stdin);freopen(NAME".out", "w", stdout);
	cin >> n >> m;
	getline(cin, s[0]);
	for (int i = 0; i < n; i++) {
		getline(cin, s[i]);
	}
	for (int i = 0; i < n; i++) {
		cout << s[i] << endl << s[i] << endl;
	}
	return 0;
}


Measured memory_bytes: 15872
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 55;

string s[N],k;
int sum[N];
 
int main()
{
    int n,sums = 0;
    sum[0] = 0;
    scanf("%d",&n);
    for(int i = 1;i <= n;++i){
    	cin >> s[i];
    	scanf("%d",&sum[i]);
    	sums += sum[i];
    	sum[i] += sum[i-1];
	}
	
	cin >> k;
	for(int i = 1;i <= n;++i){
		if(s[i] == k){
			printf("%d\n",sums-sum[i]);
			return 0;
		}
	}
    return 0;
}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline

def main():
    n, k = map(int, input().split())
    h = sorted([int(input()) for i in range(n)])

    mn = 10**10

    for i in range(n - k + 1):
        mn = min(mn, h[i + k - 1] - h[i])
    print(mn)

if __name__ == "__main__":
    main()

Measured memory_bytes: 44252
using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Globalization;
using System.Diagnostics;
using static System.Console;
using Pair = System.Collections.Generic.KeyValuePair<int, int>;
//using System.Numerics;

class Program
{
    static void Main()
    {
        //SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
        new Program().solve();
        Out.Flush();
    }
    Scanner cin = new Scanner();
    Random rnd = new Random();
    Stopwatch sw = new Stopwatch();
    readonly int[] dd = { 0, 1, 0, -1, 0 };
    readonly int mod = 1000000007;
    readonly string alfa = "abcdefghijklmnopqrstuvwxyz";
    readonly string ALFA = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";

    int N;
    void solve()
    {
        N = cin.nextint;
        var Q = new int[100002];
        for (int i = 0; i < N; i++)
        {
            Q[cin.nextint]++;
            Q[cin.nextint + 1]--;
        }
        for (int i = 1; i < Q.Length; i++)
        {
            Q[i] += Q[i - 1];
        }
        WriteLine(Q.Count(i => i >= 1));
    }

}

class Scanner
{
    string[] s; int i;
    char[] cs = new char[] { ' ' };
    public Scanner() { s = new string[0]; i = 0; }
    public string[] scan { get { return ReadLine().Split(); } }
    public int[] scanint { get { return Array.ConvertAll(scan, int.Parse); } }
    public long[] scanlong { get { return Array.ConvertAll(scan, long.Parse); } }
    public double[] scandouble { get { return Array.ConvertAll(scan, double.Parse); } }
    public string next
    {
        get
        {
            if (i < s.Length) return s[i++];
            string st = ReadLine();
            while (st == "") st = ReadLine();
            s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
            i = 0;
            return next;
        }
    }
    public int nextint { get { return int.Parse(next); } }
    public long nextlong { get { return long.Parse(next); } }
    public double nextdouble { get { return double.Parse(next); } }
}

Measured memory_bytes: 13376
#include <iostream>
//#include <array>

int main()
{
    int n, m;
    bool flag = 0;
    std::cin >> n >> m;
    for (int i = n; i <= m / 2; i++) {
        if (m % i == 0) {
            std::cout << m / i << std::endl;
            flag = 1;
            break;
        }
    }
    if (!flag) {
        std::cout << 1 << std::endl;
    }
    return 0;
}

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

LL V(int M) {
	LL ans = 1;
	for (int pos = 2; pos <= M; pos++)
		ans *= pos;
	return ans;
}

LL C(int M, int N) {
	return V(M) / V(N) / V(N - M);
}

int main() {
	int num; 
	cin >> num;
	cout << (num / 2 * (num - num / 2));
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define MM 1000000000
#define mod MM+7
#define INF (ll)1e18
#define PI acos(-1.0)
#define NIL -1
int dx[4] = {0, 1, 0, -1};
int dy[4] = {1, 0, -1, 0};

const int MAX = 8;
bool G[MAX][MAX];

int dfs(int v, int n, bool visited[MAX]){
    bool all_visited = true;
    for(int i = 0; i < n; i++){
        if(visited[i] == false){
            all_visited = false;
        }
    }
    if(all_visited){
        return 1;
    }
    int ret = 0;
    for(int i = 0; i < n; i++){
        if(G[v][i] == false) continue;
        if(visited[i]) continue;

        visited[i] = true;
        ret += dfs(i,n,visited);
        visited[i] = false;
    }
    return ret;
}

int main(){
    int n, m; cin >> n >> m;
    int a[m],b[m];
    for(int i = 0; i < m; i++){
        cin >> a[i] >> b[i];
        G[a[i]-1][b[i]-1] = true;
        G[b[i]-1][a[i]-1] = true;
    }
    bool visited[MAX];

    for(int i = 0; i < n; i++){
        visited[i] = false;
    }
    visited[0] = true;
    cout << dfs(0,n,visited) << endl;
    return 0;
}


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

using namespace std;

template< typename T >
vector< T > slide_min(const vector< T > &v, int k) {
  deque< int > deq;
  vector< T > ret;
  for(int i = 0; i < v.size(); i++) {
    while(!deq.empty() && v[deq.back()] >= v[i]) {
      deq.pop_back();
    }
    deq.push_back(i);
    if(i - k + 1 >= 0) {
      ret.emplace_back(v[deq.front()]);
      if(deq.front() == i - k + 1) deq.pop_front();
    }
  }
  return (ret);
}


int main() {
  int N, K;
  cin >> N >> K;
  vector< int > v(N);
  for(int i = 0; i < N; i++) {
    cin >> v[i];
  }
  bool first = false;
  for(auto &x : slide_min(v, K)) {
    if(first++) cout << " ";
    cout << x;
  }
  cout << endl;
}



Measured memory_bytes: 11012
/*
If you want to shine like a sun, first burn like a sun.
*/

#include <bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp> 
// #include <ext/pb_ds/tree_policy.hpp> 
// using namespace __gnu_pbds;
using namespace std;
#define mod 1000000007
#define pb push_back
#define mp make_pair
#define ll long long int
#define ld long double
#define vi vector<int>
#define vl vector<ll>
#define v2i vector<vector<int>>
#define v2l vector<vector<ll>>
#define ppi pair<int,int>
#define ppl pair<ll,ll>
#define vpi vector<ppi>
#define vpl vector<ppl>
#define all(x) x.begin(),x.end()
#define ii int,int 
#define ff first    
#define ss second
#define forn(i,a,b) for(int i=a;i<b;i++)
#define forr(i,a,b) for(int i=a;i>=b;i--)
#define forv(i,m) for(auto i : m)
#define imx INT_MAX
#define imn INT_MIN
#define inf 9000000000000000000
#define minf -inf
#define endl "\n"
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);
#define sze size()
#define rvs reverse 
#define itr iterator 
#define pre cout<<fixed<<setprecision(10);
#define umap unordered_map
#define uset unordered_set
#define pi 3.141592653589793
#define MAXN 100005
#define test1(x) cout << #x " = " << x << endl;
#define test2(x,y) cout << #x " = " << x << " " << #y " = " << y << endl;
const ll infinity = 9e18;

/*
#define oset tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
#define MODM(a,b,md) ((a%md)*(b%md))%md
#define MODA(a,b,md) ((a%md)+(b%md))%md
#define ull unsigned long long int
*/

/*
bool compare(int a,int b) {return a > b;}
bool compare1(ppi a,ppi b) {return a.ff > b.ff;}
bool compare2(ppi a,ppi b) {return a.ss < b.ss;}
ll Npower(ll a,ll b) {ll product = 1; while(b){if(b&1){product = product*a;}a = a*a;b = b>>1;} return product;}
ll power(ll a,ll b,ll md) {ll product = 1; while(b){if(b&1){product = MODM(product,a,md);}a = MODM(a,a,md);b = b>>1;} return product%md;}
bool isprime(ll n){if(n < 2) return 0; ll i = 2; while(i*i <= n){if(n%i == 0) return 0; i++;} return 1;}
ll GCD(ll a,ll b) {return b==0 ? a:GCD(b,a%b);}
ll LCM(ll a,ll b) {return (a/GCD(a,b))*b; }
*/


int main()
{
    fast

/*
    #ifndef ONLINE_JUDGE
        freopen("input.txt",  "r",  stdin);
        freopen("output.txt", "w", stdout);
    #endif
//*/

        
    ll n,k;
    cin>>n>>k;

    ll mini = min(n,abs(n-k));
        
    if(n >= k)
    {
        n -= k*(n/k);
        mini = min(mini,n);
        mini = min(mini,abs(k-n));
    }    


    cout<<mini;









    return 0;
}

Measured memory_bytes: 256
const log = console.log;

function Main(input: string): void {
  const [r, d, x] = input
    .trim()
    .split(/\s/g)
    .map(s => parseInt(s));

  let currentX = x;

  for (let i = 0; i < 10; i++) {
    currentX = r * currentX - d;
    log(currentX);
  }
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));


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

using namespace std;

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    long long int x;
    cin>>x;
    long long int r500=(x/500)*1000;
    long long int r5=((x-((x/500)*500))/5)*5;
    cout<<r500+r5;
    return 0;
}

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

using namespace std;

int main(int argc, const char *argv[]) {
  int n;
  cin >> n;

  set<string> s;
  for (int i = 0; i < n; i++) {
    string str;
    cin >> str;
    s.insert(str);
  }

  cout << s.size() << '\n';
  return 0;
}

Measured memory_bytes: 19152
#include <bits/stdc++.h>
using namespace std;
 
int n, c, o=1;
 
int main (){
	cin >> n>> c;
	for(int i=1;i<=n;i++){
		if(o+c<=2*o){
			o=o+c;	
		}
		else if(o+c>2*o){
			o=o*2;
		} 
	}
	cout << o << endl;
}

Measured memory_bytes: 256
from collections import deque
import sys
if __name__ == "__main__":
    n, m = map(int, input().split())
    distance = [float('inf')] * n
    prev_node = [-1] * n
    visit = [False] * n
    graph = []
    for i in range(n):
        graph.append([])
    for i in range(m):
        a, b = map(int, input().split())
        a -= 1
        b -= 1
        graph[a].append(b)
        graph[b].append(a)
    
    que = deque()
    que.appendleft((0, 0))
    distance[0] = 0
    visit[0] = True

    while que:
        now, cost = que.pop()
        for nei in graph[now]:
            if not visit[nei]:
                prev_node[nei] = now
                distance[nei] = cost + 1
                que.appendleft((nei, cost + 1))
                visit[nei] = True

    for i in range(1, n):
        if distance == float('inf'):
            print("No")
            sys.exit(0)
    print("Yes")
    for i in range(1, n):
        print(prev_node[i] + 1)

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

using namespace std;

int main(void)
{
    int n, m;

    cin >> n >> m;
    vector<int> a(m), b(m);
    vector<int> rooms(n);
    vector<vector<int>> routes(n, vector<int>(0));

    for (int i = 0; i < m; i++)
    {
        cin >> a[i] >> b[i];
        routes[a[i] - 1].push_back(b[i] - 1);
        routes[b[i] - 1].push_back(a[i] - 1);
    }

    vector<int> dist(n, -1);
    queue<int> que;

    dist[0] = 0;
    que.push(0);

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

        int cnCnt = routes[current].size();
        for(int i = 0; i < cnCnt; i++){
            int to = routes[current][i];
            if(dist[to] != -1) continue;

            dist[to] = dist[current] + 1;
            que.push(to);
        }
    }

    vector<vector<int>> depthMap(n, vector<int>(0));
    for(int i =0; i < n; i++){
        if(dist[i] >= 0){
            depthMap[dist[i]].push_back(i);
        }
    }

    bool success = true;
    vector<int> result(n - 1);
    for(int i = 1; i < n; i++){
        vector<int> upper = depthMap[dist[i] - 1];
        if(upper.size() == 0) {
            success = false;
            break;
        }
        for(auto v : routes[i]){
            if(find(upper.begin(), upper.end(), v) != upper.end()){
                result[i - 1] = upper[0];
                break;
            }
        }
    }

    if(success){
        cout << "Yes\n";
        for(auto i : result){
            cout << i + 1 << endl;
        }
    } else {
        cout << "No\n";
    }
    return 0;
}


Measured memory_bytes: 15952
#include<bits/stdc++.h>
using namespace std;
const int N=200006;
int n,t,p=0,cnt=0,maxn=-1,minn=1e9,f[N],v[N],s[N],g[N],fa[N],head[N];
struct edge{int nxt,to;}e[N<<1];
inline void add(int u,int v){e[++cnt].nxt=head[u],e[cnt].to=v,head[u]=cnt;} 
inline int read(){
  int T=0,F=1; char ch=getchar();
  while(ch<'0'||ch>'9'){if(ch=='-') F=-1; ch=getchar();}
  while(ch>='0'&&ch<='9') T=(T<<3)+(T<<1)+(ch-48),ch=getchar();
  return F*T; 
} 
void dfs(int x){
	f[x]=0;
    for(int i=head[x];i;i=e[i].nxt) if(!g[e[i].to]) dfs(e[i].to);
	for(int i=head[x];i;i=e[i].nxt) if(!g[e[i].to]) v[f[e[i].to]]=1;	
    while(v[f[x]]) ++f[x];
	for(int i=head[x];i;i=e[i].nxt) if(!g[e[i].to]) v[f[e[i].to]]=0;		
}
int main(){
	n=read(),t=1;
	for(int i=1;i<=n;++i) fa[i]=read(),add(fa[i],i);
	while(!s[t]) s[t]=1,t=fa[t];
	while(!g[t]) g[t]=1,t=fa[t];
	for(int i=1;i<=n;++i) if(g[i]) ++p,dfs(i),maxn=max(maxn,f[i]),minn=min(minn,f[i]);
	if(maxn==minn&&(p&1)) printf("IMPOSSIBLE\n");
	else printf("POSSIBLE"); 
	return 0;
}

Measured memory_bytes: 6784
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;

ll dp[3001][3001][3], a[3001][3001];

ll func(int r, int c, int cnt) {
    if(r < 0 || c < 0 || cnt < 0) return 0;
    if(dp[r][c][cnt] != -1) return dp[r][c][cnt];
    return dp[r][c][cnt] = max({func(r-1, c, 2) + a[r][c], func(r, c-1, cnt), func(r, c-1, cnt-1) + a[r][c]});
}

int main() {
    ll r,c,items, x , y, v, maxi = 0;
    cin >> r >> c >> items;
    while(items--) {
    	cin >> x >> y >> v;
    	a[x-1][y-1]=v;
    }
    for(int i=0;i<r;i++) for(int j=0;j<c;j++) for(int k=0;k<4;k++) dp[i][j][k] = -1;
    maxi = func(r-1, c-1, 2);
    cout << maxi;
	return 0;
}

Measured memory_bytes: 285380
package main

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

var sc = bufio.NewScanner(os.Stdin)

func init() {
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 1024*1024), bufio.MaxScanTokenSize)
}

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

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

//func nextUint64() uint64 {
//	sc.Scan()
//	i, e := strconv.ParseUint(sc.Text(), 10, 64)
//	if e != nil {
//		panic(e)
//	}
//	return i
//}

func main() {
	n := nextInt()
	s := make([]string, n, n)
	c := make([]int, 4, 4)

	for i := 0; i < n; i++ {
		s[i] = nextString()

		switch s[i] {
		case "AC":
			c[0]++
		case "WA":
			c[1]++
		case "TLE":
			c[2]++
		case "RE":
			c[3]++
		default:
		}
	}

	fmt.Printf("AC x %d\n", c[0])
	fmt.Printf("WA x %d\n", c[1])
	fmt.Printf("TLE x %d\n", c[2])
	fmt.Printf("RE x %d\n", c[3])

}


Measured memory_bytes: 4104
import std.stdio;
import std.array;
import std.conv;
import std.algorithm;
alias asort = std.algorithm.sort;
import std.range;
import std.string;
import std.math;

void main() {
  if (
    readln.chomp.split(" ").map!(to!uint).array.asort.equal([5, 5, 7])
  ) {
    writeln("YES");
  } else {
    writeln("NO");
  }
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>

int main(void){
    int n, k;
    char s[51];
    scanf("%d %d", &n, &k);
    scanf("%s", &s);
    s[k-1] += 32;
    for(int i = 0;i < n;i++){
        printf("%c", s[i]);
    }
    printf("\n");
    return 0;
}

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

int cnt = 0;

void insertionSort(int num[], int N, int g);
void shellSort(int num[], int N);
void showArray(int num[], int N);

int main()
{
	int N;
	cin >> N;
	int *num = new int[N];
	for(int i = 0; i < N; i++)
		cin >> num[i];
	shellSort(num, N);
	showArray(num, N);
}

void insertionSort(int num[], int N, int g)
{
	for(int i = g; i<N; i++)
	{
		int temp = num[i];
		int j = i-g;
		while(j >= 0 && num[j] > temp)
		{
			num[j+g] = num[j];
			j -= g;
			cnt++;
		}
		num[j+g] = temp;
	}
}

void shellSort(int num[], int N)
{
	int m = 0;
	int G[100];
	for(int i = 1; ; )
	{
		if(i >N)
			break;
		G[m] = i;
		m++;
		i = i*3+1;
	}

	cout<<m<<endl;
	for(int i = m-1; i >= 0; i--)
	{
		insertionSort(num, N, G[i]);
		cout<<G[i];
		if(i!=0)
			cout<<' ';
	}
	cout << endl << cnt << endl;
}

void showArray(int num[], int N)
{
	for(int i = 0; i < N; i++)
		cout <<num[i] << endl;
}

Measured memory_bytes: 5088
#include <iostream>

using namespace std;

string candidate_strings[4] = {"dream", "dreamer", "erase", "eraser"};
string cut_word(string base_word);


int main() {
  string S;
  cin >> S;
  // 入力された文字列を逆順にする
  reverse(S.begin(), S.end());

  // 候補の文字列も逆順にする
  for (int i = 0; i < 4; i++) {
    reverse(candidate_strings[i].begin(), candidate_strings[i].end());
  }
  while(1) {
    string before_S = S;
    S = cut_word(S);
    //cout << S.size() << endl;
    if (S.size() == 0) {
      //cout << "break success=============" << endl;
      cout << "YES" << endl;
      return 0;
    } else if (before_S.size() == S.size()) {
      break;
    }
  }
  cout << "NO" << endl;
}

string cut_word(string base_word) {
  // 各候補を一個ずつ見ていく

  //cout << "size" << candidate_strings.size() << endl;
  for (int i = 0; i < 4; i++) {
    bool is_ok = true;
    // 1文字ずつ見ていく
    for (int j = 0; j < candidate_strings[i].size(); j++) {
      // 文字が異なったらそこでNG
      if (base_word[j] != candidate_strings[i][j]) {
        is_ok = false;
      }
    }
    if (is_ok) {
      //cout << "cut by:" << candidate_strings[i] << endl;
      for (int j = 0; j < candidate_strings[i].size(); j++) {
        base_word.erase(base_word.begin());
        //cout << base_word << endl;
      }
    }
  }
  return base_word;
}


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

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);

const int mod=1e9+7;

string x;
int dp[10005][101][2];
int d;

int dfs(int i,int sum, bool smaller){
    if(i==(int)x.size()){
        return (sum%d == 0);
    }
    if(dp[i][sum][smaller] != -1){
        return dp[i][sum][smaller];
    }

    int lower_limit, upper_limit;
    if(i==0) lower_limit=1;
    else lower_limit=0;
    int t=x[i]-'0';
    if(smaller) upper_limit=9;
    else upper_limit=t;


    int ans=0;
    for(int digit=0; digit<=upper_limit; ++digit){
        int t=x[i]-'0';
        bool f=smaller;
        if(digit < t){
            f|=1;
        }
        ans=(ans+dfs(i+1,(sum+digit)%d,f))%mod;
    }
    return dp[i][sum][smaller]=ans;
}

int main() {
    IOS
    cin>>x>>d;
    memset(dp, -1, sizeof(dp));
    cout<<(dfs(0,0,0)-1+mod)%mod;
    return 0;
}

Measured memory_bytes: 12328
x, n = map(int, input().split())
p = list(map(int, input().split()))

counter = 0

for i in range(1, 101):
    if x in p:
        if counter == 0:
            x -= i
            counter = 1
        else:
            x += i
            counter = 0
    else:
        exit
print(x)

Measured memory_bytes: 9132
// AtCoder Beginner Contest 098
// C - Attention

#include <iostream>
#include <cstring>

int main(int argc, char *argv[]);
unsigned long judge(char s[], unsigned long n, unsigned long e, unsigned long es[]);
unsigned long count_e_and_s(char s[], unsigned long n, unsigned long es[]);

int main(int argc, char *argv[])
{
  unsigned long n;
  char s[300001];
  unsigned long es[300000];

  std::cin >> n >> s;

  unsigned long e = count_e_and_s(s, n, es);

  std::cout << judge(s, n, e, es) << std::endl << std::flush;
  //std::cout << "NUM of E: " << e << std::endl;
  return 0;
}

// returns number of 'E'
unsigned long count_e_and_s(char s[], unsigned long n, unsigned long es[])
{
  unsigned long ret=0L;
  for(unsigned long i=0; n>i; i++)
    {
      if('E' == s[i])
        {
          ret++;
          es[i] = ret;
        }
    }

  return ret;
}

#if 1
unsigned long judge(char s[], unsigned long n, unsigned long e, unsigned long es[])
{
  unsigned long w_in_first = 0L;
  unsigned long e_in_second = 0L;
  unsigned long min = n;

  for(unsigned long leader = 0; n > leader; leader++)
    {
      //std::cout << "Leader: " << leader << std::endl;
      w_in_first = 0L;
      e_in_second = 0L;

      // leaderより西にいて西を向いている人を数える
      // すでに数えてある
      //for(unsigned long idx1=0; leader > idx1; idx1++)
      //  {
      //    //std::cout << "s_" << idx1 << "=" << s[idx1] << std::endl;
      //    if('W' == s[idx1])
      //      {
      //        //std::cout << "West!!" << std::endl;
      //        w_in_first++;
      //      }
      //  }

      w_in_first = leader - es[leader];
      if('E' == s[leader])
        {
          w_in_first++;
        }

      // leaderより東にいて東を向いている人を数える
      //for(unsigned long idx2=leader; n > idx2; idx2++)
      //  {
      //    //std::cout << "s_" << idx1 << "=" << s[idx1] << std::endl;
      //    if('E' == s[idx2])
      //      {
      //        e_in_second++;
      //      }
      //  }

      // leaderより東にいて東を向いている人は、
      // leaderより前にいる人の中で、leaderより西にいて西を向いている人を引き、
      // その数を東向きの人の数から引く。
      e_in_second = e - (leader - w_in_first);

      if('E' == s[leader])
        {
          e_in_second--;
        }

      if(min > w_in_first + e_in_second)
        {
          min = w_in_first + e_in_second;
        }
    }

  return min;
}

#endif


Measured memory_bytes: 2944
#include<iostream>
#include<vector>
#include<math.h>
using namespace std;

int min(vector<int> c){
    int min = c[0];

    for(int i=1;i<c.size();i++){
        if(c[i]<min){
            min=c[i];
        }
    }
    return min;
}
int main(){
    int n, k, temp;
    cin>>n>>k;
    vector<int> c;
    vector<int> h;
    for(int i=0;i<n;i++){
        cin>>temp;
        h.push_back(temp);
    }
    vector<int> cost;
    cost.push_back(0);
    cost.push_back(abs(h[1]-h[0]));
    for(int i=2;i<n;i++){
        int j=1;
        while(j<=k&&(i-j)>=0){
            temp = cost[i-j]+abs(h[i]-h[i-j]);
            c.push_back(temp);
            j++;
        }
        cost.push_back(min(c));
        c.clear();
    }
    cout<<cost[cost.size()-1]<<endl;
}

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

using namespace std;

int n, cur;
int a[12], used[12];

void dfs(int v) {
    if (v == n + 1) {
        for (int j = 1; j <= n; ++j) cout << char('a' + a[j]);
        cout << '\n';
        return;
    }
    for (int i = 1; i <= v; ++i) {
        a[v] = i - 1;
        used[i]++;
        dfs(v + 1);
        used[i]--;
        if (used[i] == 0) break;
    }
}

main() {
#ifdef HOME
    //freopen("input.txt", "r", stdin);
#endif // HOME
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    cin >> n;
    dfs(1);
    return 0;
}



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

int main() {
  int N,x;//xは桁数をしらべるための値、yは各桁の合計値
  int y = 0;
  cin >> N;
  x = N;
  for (int i=0; i< 9; i++) {
    y += x % 10;
    x = x / 10;
    if (N < 10) {
      y = y + x;
      break;
    }
  }
 if (N % y == 0){
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}


Measured memory_bytes: 256
N = int(input())
A = list(map(int,input().split()))

dic = {}

for i in A:
    if i in dic:
        dic[i] = dic[i] + 1
    else:
        dic[i] = 1


dic2 = {}


ans = 0
for key,value in dic.items():
    ans = ans + int(value * (value-1) / 2)

diff_dic = {}

for key,value in dic.items():
    diff_dic[key] = int((value*(value-1)/2) - ((value-1)*(value-2)/2))


for i in A:
    print(ans-diff_dic[i])

Measured memory_bytes: 32804
# -*- coding: utf-8 -*-
S = str(input())
Q = int(input())

rev_flag = 1
head_str = ""
tail_str = ""
for _ in range(Q):
    query = list(map(str, input().split()))
    if query[0] == "1":
        rev_flag *= -1
    else:
        h_or_t_flag = 1 if query[1] == "1" else -1
        h_or_t_flag *= rev_flag
        
        if h_or_t_flag == 1:
            head_str = query[2] + head_str
        else:
            tail_str += query[2]

ans = head_str + S + tail_str
print(ans if rev_flag == 1 else ans[::-1])

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

class Graph 
{ 
	int V;			  
	list<int> *adj;	  
					 
public: 
	Graph(int V);			
	void addEdge(int v, int w); 
	void longestPathLength();  
	pair<int, int> bfs(int u); 
						 
}; 

Graph::Graph(int V) 
{ 
	this->V = V; 
	adj = new list<int>[V]; 
} 

void Graph::addEdge(int v, int w) 
{ 
	adj[v].push_back(w); 
	adj[w].push_back(v); 
} 
std::vector<int> v;
pair<int, int> Graph::bfs(int u) 
{ 
	int dis[V]; 
	memset(dis, -1, sizeof(dis)); 

	queue<int> q; 
	q.push(u); 

	dis[u] = 0; 

	while (!q.empty()) 
	{ 
		int t = q.front();	 q.pop(); 

		for (auto it = adj[t].begin(); it != adj[t].end(); it++) 
		{ 
			int v = *it; 

			if (dis[v] == -1) 
			{ 
				q.push(v); 

		
				dis[v] = dis[t] + 1; 
			} 
		} 
	} 

	int maxDis = 0; 
	int nodeIdx; 

	for (int i = 0; i < V; i++) 
	{ 
		if (dis[i] > maxDis) 
		{ 
			maxDis = dis[i]; 
			nodeIdx = i; 
		} 
	} 
	return make_pair(nodeIdx, maxDis); 
} 
int n,m;

void Graph::longestPathLength() 
{ 
    int ma=0;
    pair<int, int> t1, t2;
	for(int i=0;i<v.size();i++)
	{
	     

    	t1 = bfs(v[i]); 
    
    	t2 = bfs(t1.first);
    	ma=max(ma,t2.second);
	}
	//cout << "Longest path is from " << t1.first << " to "
         //<< t2.first << " of length " << t2.second; 

	cout <<ma<<endl; 
} 

int main() 
{ 
    cin>>n>>m;
    char a[n][m];
    for(int i=0;i<n;i++)
    {
        for(int j=0;j<m;j++)
        {
            cin>>a[i][j];
            if(a[i][j]=='.')
            {
                v.push_back(i*m+j);
            }
        }
    }
    Graph g(n*m); 
    for(int i=0;i<n;i++)
    {
        for(int j=0;j<m;j++)
        {
            if(i<n-1 && a[i][j]==a[i+1][j] && a[i][j]=='.' )
            {
                g.addEdge(i*m+j,(i+1)*m+j);
            }
            if(j<m-1 && a[i][j]==a[i][j+1] && a[i][j]=='.' )
            {
                g.addEdge(i*m+j,(i)*m+j+1);
            }
        }
    }
	g.longestPathLength(); 
	return 0; 
} 


Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long LL;
#define SORT(c) sort((c).begin(),(c).end())

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

using namespace std;
double solve(double r1,double r2){
  return sqrt((r2+r1)*(r2+r1)-(r2-r1)*(r2-r1));
}
int main(void)
{
  int n;
  cin >> n;
  vector<double> r(n);
  REP(i,n) cin >> r[i];
  vector<double> o(n,0.0);
  double answer=0.0;
  REP(i,n){
    o[i]=max(o[i],r[i]);
    REP(j,i){
      o[i]=max(o[i],o[j]+solve(r[j],r[i]));
    }
    answer=max(answer,o[i]+r[i]);
  }
  cout << fixed << setprecision(10) << answer << endl;
}

Measured memory_bytes: 3280
#include "bits/stdc++.h"
#include <iostream>
using namespace std;
#define ll = long long;
#define all(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
int main()
{
	int n;
	cin >> n;
	vector <int> x;
	rep(i, n) {
		int a; 
		cin >> a; 
		x.push_back(a);
	} 
	sort(all(x));
	vector <vector<int>> y(n*n);
	rep(i, n) {
		rep(j, n) {
			y.at(i).push_back(x.at(i)+x.at(j));
			
		}
	}
	int ans = 0;
	rep(i, n) {
		for (int j = i+1; j < n - 1; j++) {
			for (int k = n - 1; k > j; k--) {
				if (y.at(i).at(j) > x.at(k)) {
					ans+=(k-j);
					k = 0;
				}
			}
		}
	}
	cout << ans << endl;

}
/*


  　　　 _」_
　 　×´　　　  _,,..-──-､,_ｧo､__　　  ｀メ.
　　/　    ,  '"´　 　　　   （-､__oヽ　　　_|__
　 　　　／　　　　　　　　 　 ｀ヽ.ヽﾊ）　 　ﾉ
　　　 ／　　　　　　　　　　　  　 Y⌒ヽ.
　　  /　　 /　　　　　　     ヽ.　 |　　',
　　 ,'　　!　　,　 /!　,| ＿   !.　|　　 !　　
　　　|　  |.__/|_ ,'| / ! __｀./! /|　　 |
　　　|　　|´/ |_/  ﾚ' ｧ'´￣` |／､ﾄ、 　|　　奇跡を起こして計算量をO(N)にします!
　　  '､　 |/ｧ'´￣`  　　　,,　|　|ｿ   　ﾊ　　
　　 　 ＼,ハ ,,　　 '　   　（ ＼|　 / .|
　　　 　 | ﾊ、　i7´￣｀i  ,/ ＼_）,'　 |
　　　　 ,'/｀＞ ､,｀   ,.イ/＼＿_! !　  !　　|
　　 　　/　 /｀     T7´／/ヽ､_＿ﾉ_| 　 |__,メ
　　 　　|  .|r/´`ｰ'-､／　,'./  /::/｀ヽ /
　　　　 八　i/      rﾉ,!￣ヽ､| /:/ 　  i_
　　  　,' X`;くﾄ  ､ノ､　/ﾍ｀ヽ．Y    ／::>
　　　　!　// |::|/.|::|＼/ﾉ 八__ノr:':::／/
　　　　|／　 |::|./|::|/　 ）'ﾉ:/--‐'','
　  　  /　　 八:' _ﾉ::ﾉ　 _,.ｲ／　　　　|
　　 　,'　　　 ＼_ ／,|　 　／　　　 　 !
　　　 |　　　　　　  /|　 ／ 　　　/ 　 |
*/


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

#define M_PI       3.14159265358979323846   // pi

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<ll> VI;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> t3;
typedef tuple<ll, ll, ll, ll> t4;

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

static const ll INF = (ll)1e15;

const ll mod = 1000000007;

ll mpow(ll x, ll n) {
	ll ans = 1; x %= mod;
	while (n != 0) {
		if (n & 1) ans = ans * x % mod;
		x = x * x % mod;
		n = n >> 1;
	}
	return ans;
}

ll inv_mod(ll a) { return mpow(a, mod - 2); }

class Factorial {
private:
	vector<ll> fac;
	vector<ll> ifac;
public:

	Factorial(ll N) {
		fac.push_back(1);
		for (int i = 0; i < N; i++) fac.push_back(fac[i] * (i + 1) % mod);
		ifac.resize(N + 1);
		ifac[N] = inv_mod(fac[N]);
		for (int i = 0; i < N; i++) ifac[N - 1 - i] = (ifac[N - i] * (N - i)) % mod;
	}

	ll fact(ll a) { return fac[a]; }
	ll ifact(ll a) { return ifac[a]; }

	ll cmb(ll a, ll b) {
		if (a == 0 && b == 0) return 1;
		if (a < b || a < 0 || b < 0) return 0;
		ll tmp = ifact(a - b) * ifact(b) % mod;
		return tmp * fac[a] % mod;
	}
	ll per(ll a, ll b) {
		if (a == 0 && b == 0) return 1;
		if (a < b || a < 0 || b < 0) return 0;
		return fac[a] * ifac[a - b] % mod;
	}
};

int main(void)
{
	ll n,k;
	cin >> n >> k;
	ll sum = 0;
	for (ll i = k; i <= n + 1; i++) {
		ll left = (0 + i) *(0 + i-1)/ 2;
		ll right = (n+1) * (n) / 2 - (n+1-i)*(n-i) / 2;
		auto c = right - left+ 1;
		c %= mod;
		sum += c;
		sum %= mod;
	}
	cout << sum << endl;
	return 0;
}


Measured memory_bytes: 3648
n, m = list(map(int, input().split()))
a = [0 for x in range(n)] 
b = [0 for x in range(n)] 
c = [0 for x in range(m)] 
d = [0 for x in range(m)] 
for i in range(n):
	a[i], b[i] = list(map(int, input().split()))
for i in range(m):
	c[i], d[i] = list(map(int, input().split()))

	
for i in range(n):
	mindis = 500000000
	minCheckPoint = -1
	for j in range(m):
		dis = abs(a[i]-c[j]) + abs(b[i]-d[j])
		if mindis > dis:
			mindis = dis
			minCheckPoint = j + 1
	print(minCheckPoint)

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


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

#define repi(i,a,b) for(ll i = (a); i < (b); i++)
#define rep(i, n) for(ll i = 0; i < (n); ++i)
ll MOD = 1000000007;
int main() {
    int a, b,c,d;
    cin >> a >> b >>c>>d;
    while (true) {
        c -= b;
        if(c <= 0){
            cout << "Yes" << endl;
            return 0;
        }
        a -= d;
        if (a <= 0) {
            cout << "No" << endl;
            return 0;
        }
    }
    return 0;
}



Measured memory_bytes: 3636
#include <bits/stdc++.h>
#define int long long
#define ll long long 
#define rep(i,a,b) for(signed i=a;i<(b);++i)
#define erep(i,a,b) for(signed i=a;i<=(b);++i)
#define per(i,a,b) for(signed i=(a);i>(b);--i)
#define eper(i,a,b) for(signed i=(a);i>=b;--i)
#define fore(i, x, a) for(auto &&x:a) 
#define ITR(i,b,e) for(auto i=(b);i!=(e);++i)
#define pb emplace_back
#define mp make_pair
#define ALL(x) begin(x),end(x)
#define F first
#define S second
#define debug(x)  cout << #x << ": " << (x) << '\n';
const long long INF=1001001001001001001;
const int MOD=(int)1e9 + 7;
const double EPS=1e-9;
using namespace std;
using Pii = pair<int,int>;
using vii = vector<int>;
template<class T>using  PS_queue = priority_queue<T, vector<T>, greater<T> >;
template<class T>using vv = vector<T>;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }
template<typename A, size_t N, typename T> void Fill(A (&array)[N], const T &val){fill( (T*)array, (T*)(array+N), val );}
template<class T> ostream& operator<<(ostream &os,const vector<T> &v) {
    ITR(i,begin(v),end(v))os<<*i<<(i==end(v)-1?"":" ");return os;}
template<class T> ostream& operator<<(ostream &os,const vector<vector<T> > &v) {
    ITR(u,begin(v),end(v))ITR(w,begin(*u),end(*u))os<<*w<<(w==end(*u)-1?"\n":" ");return os;}
template<class T> istream& operator>>(istream &is,vector<T> &v) {
    ITR(i,begin(v),end(v)) is>>*i;return is;}
template<class T,class U> istream& operator>>(istream &is, pair<T,U> &p) {
    is>>p.first>>p.second;return is;}
template<class T>T gcd(T a, T b){ return b ? gcd(b, a % b) : a; }
template<class T>T lcm(T a, T b){ return a / gcd(a, b) * b; }
struct edge { int from, to, cost; };
int dy[]={0, 1, -1, 0}; int dx[]={1, 0, 0, -1};
// cout << fixed << setprecision(10) << val;

int n, h[100005];
signed main() {
 cin.tie(0);
 ios::sync_with_stdio(false);
  cin >> n;
  rep(i, 0, n) cin >> h[i];
  eper(i, n-2, 0) {
    if (h[i] > h[i+1]) h[i]--;
  }
  rep(i, 0, n-1) {
    if (h[i] > h[i+1]) {
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
  return 0;
}




Measured memory_bytes: 1024
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
      
      	String strS = sc.next();
      	
      	String strT = sc.next();
      
     	strT = strT.substring(0, strT.length() - 1);
       	
      	if (strS.equals(strT)) {
        System.out.println("Yes");
        } else {
        System.out.println("No");
        }
  	
	}
}

Measured memory_bytes: 35624
def s0():return input()
def s1():return input().split()
def s2(n):return [input() for x in range(n)]
def s3(n):return [[input().split()] for _ in range(n)]
def n0():return int(input())
def n1():return [int(x) for x in input().split()]
def n2(n):return [int(input()) for _ in range(n)]
def n3(n):return [[int(x) for x in input().split()] for _ in range(n)]
def t3(n):return [tuple(int(x) for x in input().split()) for _ in range(n)]
def p0(b,yes,no): print(yes) if b else print(no)
# from collections import Counter,deque,defaultdict
# import itertools
# import math
# import networkx
# from bisect import bisect_left,bisect_right
k,x=n1()

p0(k*500>=x,"Yes","No")

Measured memory_bytes: 3064
#include <stdio.h>

int main(void){
    int N;
    long long ans = 1;
    
    scanf("%d",&N);
    
    for(int i = 1; i < N + 1; i++){
        ans = (ans * i) % 1000000007;
    }
    
    printf("%lld\n",ans);
    
    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ii = pair<int, int>;
using iii = pair<ii, int>;
#define vt vector
#define pb push_back
#define pf push_front
#define mp make_pair
#define fi first
#define se second
#define __lcm(a, b) a * b / __gcd(a, b)x
const int MOD = 1e9 + 7;
const int INF = 2e9;
const int N = 1e3 + 5;

int R, C;
int dp[N][N];
char grid[N][N];

int add(int x, int y) {
    return ((x % MOD) + (y % MOD)) % MOD;
}

bool inside(int r, int c) {
    return r >= 1 && r <= R && c >= 1 && c <= C;
}

int f(int r, int c) {
    if(grid[r][c] == '#') return 0;
    if(!inside(r, c)) return 0;
    if(r == R && c == C) return 1;
    int &sol = dp[r][c];
    if(sol != -1) return sol;
    return sol = add(f(r + 1, c), f(r, c + 1));
}

void solve() {
    cin >> R >> C;
    for(int i = 1; i <= R; i++) {
        for(int j = 1; j <= C; j++) {
            cin >> grid[i][j];
        }
    }
    memset(dp, -1, sizeof(dp));
    cout << f(1, 1) % MOD << "\n";
}

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

    solve();
    
}

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

int read()
{
	int s=0;
	char c=getchar(),lc='+';
	while (c<'0'||'9'<c) lc=c,c=getchar();
	while ('0'<=c&&c<='9') s=s*10+c-'0',c=getchar();
	return lc=='-'?-s:s;
}
void write(int x)
{
	if (x<0)
	{
		putchar('-');
		x=-x;
	}
	if (x<10) putchar(x+'0');
	else
	{
		write(x/10);
		putchar(x%10+'0');
	}
}
void print(int x,char c='\n')
{
	write(x);
	putchar(c);
}

signed main()
{
	int h1=read(),m1=read(),h2=read(),m2=read(),k=read();
	print(max(h2*60+m2-h1*60-m1-k,0));

	return 0;
}

Measured memory_bytes: 3564
# -*- coding: utf-8 -*-
# C - Low Elements
import  sys

def solve152C(N, plist):
	
	count = 1
	maxnumber = plist[0]
	minnumber = plist[0]
	isFound = True
	for i in range(2, N+1):
		p = plist[i-1]
		if p < maxnumber and p < minnumber:
			count += 1
		
		if p > maxnumber:
			maxnumber = p
		if p < minnumber:
			minnumber = p
					
	print(count)


if __name__ == "__main__":
	
	N = int(input())
	plist= list(map(int, input().split()))

	solve152C(N, plist)


Measured memory_bytes: 24744
h, w = map(int, input().split())
s = []
for _ in range(h):
    s.append(list(input()))
for i in range(h):
    for j in range(w):
        a = 0
        if s[i][j] == '.':
            for k in range(i - 1, i + 2):
                for l in range(j - 1, j + 2):
                    if (0 <= k and k <= h - 1) and (0 <= l and l <= w - 1) and s[k][l] == '#':
                        a += 1
            s[i][j] = str(a)
for m in range(h):
    print(''.join(s[m]))

Measured memory_bytes: 9172
using namespace std;
#define _CRT_SECURE_NO_WARNINGS
#pragma target("avx")
#pragma optimize("O3")
#pragma optimize("unroll-loops")
#include<iostream>
#include<algorithm>
#include<ctime>
#include<vector>
#include<string>
#include<cmath>
#include<map>
#include<iomanip>
#include<numeric>
#include<queue>
#include<deque>
#include<cfloat>
#include<functional>
#include<tuple>
#include<math.h>
#include<bitset>
#include<stack>
#include<set>
#include<random>
#include<stdlib.h>
#define rip(i,n) for(ll i=0;i<n;i++)
#define Rip(i,n) for(ll i=1;i<n;i++)
#define all(V) V.begin(),V.end()
#define ll long long
#define ld long double
#define MOD 998244353
#define mod MOD
#define sec setprecision
constexpr double eps = 1e-9;
constexpr double PI = 3.141592653589793238462643383279;
ll gcd(ll a, ll b) {
	if (a % b == 0)	return(b);
	else return(gcd(b, a % b));
}
ll lcm(ll a, ll b)
{
	return a * b / gcd(a, b);
}
int ketasuu(ll h) {
	if (h < 0)return(-(ketasuu(-h)));
	else if (h < 10)return(1);
	else return(1 + ketasuu(h / 10));
}
const int MAX = 510000;
long long fac[MAX], finv[MAX], inv[MAX];
void cominit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (ll i = 2; i < MAX; i++) {
		fac[i] = fac[i - 1] * i % MOD;
		inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
		finv[i] = finv[i - 1] * inv[i] % MOD;
	}
}
vector<ll> soinnsuubunnkai(ll n) {
	vector<ll>a;
	while (n % 2 == 0) {
		a.push_back(2);
		n /= 2;
	}
	ll f = 3;
	while (f * f <= n) {
		if (n % f == 0) {
			a.push_back(f);
			n /= f;
		}
		else f += 2;
	}
	if (n != 1)
		a.push_back(n);
	return(a);
}
// 二項係数計算
long long com(ll n, ll k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % mod) % mod;
}
ll pow(ll a, ll b) {
	a = a % mod;
	if (b == 0)return(1);
	else if (b % 2 == 0)return(pow((a * a) % mod, b / 2));
	else return(a * (pow(a, b - 1)));
}
void solve() {
	int a, p;
	cin >> a >> p;
	p += a * 3;
	cout << p / 2 << endl;
}
int main() {
	solve();
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include<algorithm>
#include<iomanip>
#include<queue>
#include<map>
#include<bitset>
#include<math.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define REP(i,m,n) for(int i=m;i<(int)(n);i++)
typedef pair<int,int> pint;
typedef long long ll;
const int inf   = 1e9+7;
const ll  longinf = 1LL<<60;
const int mod=1e9+7;
int dx[4]={1,0,-1,0}, dy[4]={0,1,0,-1};

int main(){
  int n;
  cin>>n;
  int a[n],b[n];
  rep(i,n){
    cin>>a[i];
    b[i]=a[i];
    }
  sort(a,a+n);
  int k=n/2;
  rep(i,n){
    if(b[i]<a[k])cout<<a[k]<<"\n";
    else cout<<a[k-1]<<"\n";
    }
  return 0;
  }

Measured memory_bytes: 3712
#include <bits/stdc++.h>
#include <iomanip>
using namespace std;
typedef long long int ll;
typedef pair<ll, ll> p_ll;
typedef vector<pair<ll, ll>> vec_p; //vector<pair<ll, ll>> pairs(n) ,pairs.at(i) = make_pair(i*i, i)

const int MOD = pow(10, 9) + 7;
//const int LLINF = pow(2, 61) - 1;
//const int INF = pow(2, 30) - 1;
const int MAX = MOD;

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



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

  vector<ll> vec(32);
  vec = {1,
         1,
         1,
         2,
         1,
         2,
         1,
         5,
         2,
         2,
         1,
         5,
         1,
         2,
         1,
         14,
         1,
         5,
         1,
         5,
         2,
         2,
         1,
         15,
         2,
         2,
         5,
         4,
         1,
         4,
         1,
         51};

  ll K;
  cin >> K;

  cout << vec.at(K - 1) << endl;

}

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

signed main(){  
  cin.tie(0);
  ios::sync_with_stdio(0);
  auto calc=[](Int x){
    if(x <= 9) return x + 1;
    Int res=10;
    Int t = 10;
    Int k = 2;
    while( t * 10 <= x){
      res += k * (t * 9);
      k++;
      t *= 10;
    }
    return res + (x - t + 1) * k;
  };

  //cout<<calc(101)<<endl;
  //cout<<calc(13)<<endl;
  
  auto sub=[](string s,Int k){
    return s.substr(s.size()-k);
  };

  auto inc=[](string s){
    for(Int i=s.size()-1;i>=0;i--){
      if(s[i]=='9'){
	s[i]='0';
	continue;
      }
      s[i]++;
      break;
    }
    return s;
  };
  
  string s;
  
  while(cin>>s,s!="#"){
    Int ans=1e18;
    for(Int i=1;i<min(Int(17),Int(s.size()));i++){
      string t=s.substr(0,i),u=s.substr(i);
      if(u.front()=='0'||u.size()>16) continue; 
      //cout<<t<<"::"<<u<<endl;
      for(Int j=max((Int)t.size(),(Int)u.size());j<17;j++){
	string x=inc(t),y=u;
	//cout<<i<<" "<<j<<":"<<x<<":"<<y<<endl;
	x=string(j-t.size(),'$')+x;
	y=y+string(j-u.size(),'$');
	bool f=0;
	for(Int k=0;k<j;k++){
	  if(k+1!=j){
	    f|=(isdigit(x[k])&&isdigit(y[k])&&x[k]!=y[k]);
	  }
	  f|=(x[k]=='$'&&y[k]=='$');
	}
	if(f) continue;
	if(y.back()!='$'){
	  if(x.back()-'0'!=y.back()-'0') continue;
	}
	
	for(Int k=0;k<j;k++){
	  if(y[k]!='$') continue;
	  y[k]=isdigit(x[k])?x[k]:'0';
	}
	if(y=="1") continue;
	Int tmp=calc(stoll(y)-1)-i;
	//cout<<i<<" "<<j<<":"<<x<<":"<<y<<":"<<tmp<<endl;
	ans=min(ans,tmp);
	
      }
    }
    //cout<<"SPL"<<endl;
    for(Int i=1;i<17;i++){
      for(Int j=0;j<i;j++){
	if(j+i>(Int)s.size()) continue;
	string t=s.substr(j,i);
	if(t.front()=='0') continue;
	Int x=stoll(t);
	//cout<<t<<" "<<x<<endl;
	if(j){
	  if(x==1) continue;
	  string u=to_string((long long)(x-1));
	  //cout<<s.substr(0,j)<<":"<<u<<" "<<sub(u,j)<<endl;
	  if(s.substr(0,j)!=sub(u,j)) continue;
	}
	Int p=j+i;
	bool f=1;
	while(p<(Int)s.size()){
	  string u=to_string((long long)++x);
	  string v=s.substr(p,min((Int)u.size(),(Int)s.size()-p));
	  //cout<<u<<":"<<v<<endl;
	  u=u.substr(0,v.size());
	  f&=(u==v);
	  p+=u.size();
	}
	if(!f) continue;
	Int tmp=calc(stoll(t)-1)-j;
	//cout<<i<<" "<<j<<" "<<":"<<t<<" "<<tmp<<endl;
	ans=min(ans,tmp);
      }
    }
    if(ans==1e18){
      ans=calc(stoll("1"+s)-1)+1;
    }
    cout<<(long long)ans<<endl;
  }
  return 0;
}

Measured memory_bytes: 3216