akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
struct custom_hash
{
   static uint64_t splitmix64(uint64_t x)
   {
       // http://xorshift.di.unimi.it/splitmix64.c
       x += 0x9e3779b97f4a7c15;
       x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
       x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
       return x ^ (x >> 31);
   }

   size_t operator()(uint64_t x) const
   {
       static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
       return splitmix64(x + FIXED_RANDOM);
   }
};
int main()
{
    // #ifndef ONLINE_JUDGE
    //     freopen("input1.txt", "r", stdin);
    //     freopen("output1.txt", "w", stdout);
    // #endif
       ios_base::sync_with_stdio(0);
       cin.tie(0);
       cout.tie(0);
    int n, w;
    cin >> n >> w;
    int i;
    string a[n];
    for (i = 0; i < n; i++)
    {
        cin >> a[i];
    }
    vector<vector<int>> dp(n, vector<int>(w, 0));
    // cout << "ankit"
    //      << "\n";
    for (i = 0; i < w; i++)
    {
        if (a[0][i] == '#')
            break;
        dp[0][i] = 1;
    }
    for (i = 0; i < n; i++)
    {
        if (a[i][0] == '#')
            break;
        dp[i][0] = 1;
    }
    // cout << "ankit"
    //      << "\n";
    int j;
    int m = 1000000007;
    for (i = 1; i < n; i++)
    {
        for (j = 1; j < w; j++)
        {
            if (a[i][j] == '.')
            {
                dp[i][j] = (dp[i - 1][j] + dp[i][j - 1]) % m;
            }
        }
    }
    // cout << "ankit"
    //      << "\n";
    // for (i = 0; i < n; i++)
    // {
    //     for (j = 0; j < w; j++)
    //     {
    //         cout << dp[i][j] << " ";
    //     }
    //     cout << "\n";
    // }
    cout << dp[n - 1][w - 1] << "\n";
}

Measured memory_bytes: 5248
def get_i() #空白区切の入力を数値(整数)の配列で返す
  return gets.chomp.split(" ").map(&:to_i)
end
def get_f() #空白区切の入力を数値(実数)の配列で返す
  return gets.chomp.split(" ").map(&:to_f)
end
def get() #空白区切の入力を文字列の配列で返す
  return gets.chomp.split(" ")
end
def get_nsp() #入力されたものを一文字ずつに区切った文字列の配列で返す
  return gets.chomp.split("")
end
def yn_judge(bool,y="Yes",n="No") #boolに真偽を投げることで、trueならy、falseならnの値を出力する
  return bool ? y : n 
end
def array(size,n=1,init=nil) #nに配列の次元数、sizeに配列の大きさ、initに初期値を投げることでその配列を返す
  if n==1
    return Array.new(size){init}
  else
    return Array.new(n).map{Array.new(size){init}}
  end
end

class SegTree
  attr_accessor:node,:n
  def initialize(n,s)
    @n=1
    @n*=2 while @n<n
    @node=array(2*@n,1,0)
    n.times do|i|
      @node[i+@n]=s[i]
    end
    (@n-1).downto(1) do|i|
      @node[i]=@node[i*2]|@node[i*2+1]
    end
  end

  def update(i,x)
    i+=@n
    @node[i]=x
    while i>1
      i/=2
      @node[i]=@node[i*2]|@node[i*2+1]
    end
  end

  def getOR(l,r)
    ret=0
    l+=@n
    r+=@n
    while l<r
      if l.odd?
        ret|=@node[l]
        l+=1
      end
      if r.odd?
        r-=1
        ret|=@node[r]
      end
      l/=2
      r/=2
    end
    return ret
  end
end
exchange=array(26,1,1)
25.times do|i|
  exchange[i+1]=exchange[i]*2
end
n=gets.to_i
s=get_nsp.map{|c| exchange[c.ord-"a".ord]}
st=SegTree.new(n,s)
q=gets.to_i
q.times do
  que=get
  if que[0].to_i==1
    next if s[que[1].to_i-1]==que[2]
    i=que[1].to_i-1
    c=que[2]
    st.update(i,exchange[c.ord-"a".ord])
  else
    l=que[1].to_i-1
    r=que[2].to_i-1
    val=st.getOR(l,r+1)
    puts val.to_s(2).count("1")
  end
end

Measured memory_bytes: 60600
using LinearAlgebra
parseline(str=readline()) = parse.(Int, split(str))
function WaterBottle()
    a, b, x = parseline()
    θ₁ = rad2deg(asin(b/norm([b, 2x/(a*b)])))
    θ₂ = rad2deg(atan(2(a^2*b - x)/a^3))
    θ = rad2deg(atan(b/a))
    println(θ₁>θ ? θ₁ : θ₂)
end
WaterBottle()

Measured memory_bytes: 215700
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
const int MOD = (int)1e9 + 7;
const int MAXN = (int)1e5 + 3;
const int infint = (int)1e9 + 3;
const ll inf = (ll)1e12;
map< pair<int, int>, int> edge;
set< pair<int, pair<int, int> > > deg;
vector<int> G[MAXN];

int n, deleted[MAXN];

void add(int u, int v)
{
	if(u > v)
		swap(u, v);
	G[u].push_back(v);
	G[v].push_back(u);
	deg.erase({-edge[{u, v}], {u, v}});
	edge[{u, v}]++;
	deg.insert({-edge[{u, v}], {u, v}});
}
void in()
{
	for (int i = 0; i < n - 1; i++)
	{
		int u, v;
		cin >> u >> v;
		add(u, v);
	}
	return;
}
void merge(int u, int v)
{
	deg.erase({-edge[{min(u, v), max(u, v)}], {min(u, v), max(u, v)}});
	if(G[u].size() < G[v].size())
		swap(u, v);
	
	for (auto c : G[v])
		if(!deleted[c] && c != u)
			add(u, c), deg.erase({-edge[{min(v, c), max(v, c)}], {min(v, c), max(v, c)}});
	
	cerr << "# " << u << " " << v << endl;
	deleted[v] = 1;
}
int main()
{
	ios::sync_with_stdio(false); 
	cin.tie(0); cout.tie(0);
	cin >> n;
	in(), in();
	int ted = 0;
	while(!deg.empty() && (*deg.begin()).first < -1)
	{
		pair<int, pair<int, int> > cur = *deg.begin();
		merge(cur.second.first, cur.second.second);
		ted++;
	}
	cout << ((ted == n - 1) ? "YES" : "NO");
}


Measured memory_bytes: 36664
#include <algorithm>
#include <cmath>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vl = vector<ll>;
#define what(x) cerr << #x << " is " << x << endl;
const int INF = 1 << 28;

int main() {
    int N, C;
    cin >> N >> C;
    vvi ch(C, vi(100001, 0));
    for (int i = 0; i < N; ++i) {
        int s, t, c;
        cin >> s >> t >> c;
        for (int j = s - 1; j < t; ++j) {
            ch[c - 1][j] = 1;
        }
    }
    int ret = 0;
    for (int i = 0; i < 100001; ++i) {
        int temp = 0;
        for (int j = 0; j < C; ++j) {
            temp += ch[j][i];
        }
        ret = max(ret, temp);
    }
    cout << ret << endl;
    return 0;
}

Measured memory_bytes: 12416
n, k = map(int, input().split())
p = list(map(lambda v: (1+int(v))/2, input().split()))

q = [0]
for v in p:
    q.append(q[-1] + v)

res = 0
for i in range(n-k+1):
    res = max(res, q[i+k] - q[i])

print(res)


Measured memory_bytes: 75656
#include <stdio.h>
#include <string.h>

int main(int argc, const char * argv[]) {
    int x[6], i, tmp=0;
    char c[100];
    for(i=0;i<6;i++){
        scanf("%d", &x[i]);
    }
    scanf("%s", c);
    for(i=0;i<strlen(c);i++){
        if(c[i] == 'N'){
            tmp = x[0];
            x[0] = x[1];
            x[1] = x[5];
            x[5] = x[4];
            x[4] = tmp;
        }else if(c[i] == 'E'){
            tmp = x[0];
            x[0] = x[3];
            x[3] = x[5];
            x[5] = x[2];
            x[2] = tmp;
        }else if(c[i] == 'S'){
            tmp = x[0];
            x[0] = x[4];
            x[4] = x[5];
            x[5] = x[1];
            x[1] = tmp;
        }else if(c[i] == 'W'){
            tmp = x[0];
            x[0] = x[2];
            x[2] = x[5];
            x[5] = x[3];
            x[3] = tmp;
        }

    }
    printf("%d\n", x[0]);
    return 0;
}

Measured memory_bytes: 596
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <stack>
using namespace std;

typedef long long ll;

ll N;
void input()
{
    cin >> N;
}

void solve()
{
    if (N == 0){
        cout << 0 << endl;
        return;
    } else {
        int mod = -2;
        stack<int> stk;
        while (N != 0){
            // cout << N / mod << " " << N % mod << endl;
            if (N % mod == -1){
                stk.push(N % mod + 2);
                N = (N - N % mod - 2) / mod;
            } else {
                stk.push(N % mod);
                N = (N - N % mod) / mod;
            }
            
        }
        while (!stk.empty()){
            cout << stk.top();
            stk.pop();
        }
        cout << endl;
    }
}

int main()
{
    cin.tie();
    ios::sync_with_stdio(false);
    input();
    solve();
    return 0;
}

Measured memory_bytes: 3664
#f = open("input.txt")
#N, K = [int(x) for x in f.readline().split(' ')]
#lines = f.readlines()
#f.close()
import sys
N, K = [int(x) for x in sys.stdin.readline().split(' ')]
lines = sys.stdin.readlines()


schedule = [0]*N
for line in lines:
    strs = line.split(' ')
    schedule[int(strs[0])-1] = int(strs[1])

number = [0]*9
for i in range(9):
    l1 = i // 3
    l2 = i % 3
    if(schedule[0]!=l2+1 and schedule[0]!=0):
        number[i] = 0
    elif(schedule[1]!=l1+1 and schedule[1]!=0):
        number[i] = 0
    else:
        number[i] = 1


for s in schedule[2:]:
    new_number = [0]*9
    for i in range(9):
        l1 = i // 3
        l2 = i % 3
        for j in range(3):
            new_number[i] += number[l2*3 + j] if((s==0 or s==l1+1) and  not (l2==j and l1==j)) else 0
    for i in range(9):
        number[i] = new_number[i] % 10000
sum = 0
for n in number:
    sum += n
print(sum % 10000)

Measured memory_bytes: 6760
#include<iostream>
#include<algorithm>
#include<queue>
using namespace std;
#define maxn 10010
#define INFTY (1<<30)
#define WHITE 0
#define GRAY 1
#define BLACK 2

int n;
vector<pair<int,int> > adj[maxn]; //加权有向图的邻接表表示法

void dijkstra(int s)
{
    priority_queue<pair<int,int> > PQ;
    int color[maxn],d[maxn],p[maxn]; //p数组可以不要
    for(int i=0;i<n;i++)
    {
        color[i]=WHITE;
        d[i]=INFTY;
        p[i]=-1;
    }
    d[s]=0;
    PQ.push(make_pair(s,0));
    color[s]=GRAY;

    while(!PQ.empty())
    {
        pair<int,int> f=PQ.top();PQ.pop();
        int u=f.second;
        color[u]=BLACK;

        if(d[u]<f.first*(-1)) continue; //取出最小值，若不是最短路径则忽略

        for(int j=0;j<adj[u].size();j++)
        {
            int v=adj[u][j].first;
            if(color[v]==BLACK) continue;
            if(d[u]+adj[u][j].second<d[v])
            {
                d[v]=d[u]+adj[u][j].second;
                //优先级队列默认优先最大值，所以要乘以-1
                PQ.push(make_pair(d[v]*(-1),v));
                p[v]=u;
                color[v]=GRAY;
            }
        }
    }

    for(int i=0;i<n;i++)
        cout<<i<<" "<<(d[i]==INFTY?-1:d[i])<<endl;
}
int main()
{
    int k,u,v,c;
    cin>>n;
    for(int i=0;i<n;i++)
    {
        cin>>u>>k;
        for(int j=0;j<k;j++)
        {
            cin>>v>>c;
            adj[u].push_back(make_pair(v,c));
        }
    }
    dijkstra(0);
    return 0;
}


Measured memory_bytes: 8072
n = int(input())
arr = list(map(int , input().split()))
arr.sort(reverse = True)
ptr = 1
s = arr[0]
n-=2
while n:
    s+=arr[ptr]
    n-=1
    if n == 0: break
    s+=arr[ptr]
    n-=1
    ptr+=1
print(s)

Measured memory_bytes: 105132
#pragma GCC optimize("O3")

#include "bits/stdc++.h"
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
typedef pair<int, int> pi;
tree<int,int,greater<int>,rb_tree_tag,tree_order_statistics_node_update> map_t;
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define F0R(i, a) for(int i = 0; i < (a); ++i)
#define pb push_back
#define sz(x) (int)x.size()
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
#define REV(x) reverse(x.begin(),x.end())
int dx[]={-1,0,1,0};
int dy[]={0,-1,0,1};
const int INF=3e8;
const int mxN=2e5+5;
bool lr[mxN],rl[mxN];

int main()
{
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    int n,k,c;
    string s;
    cin >> n >> k >> c >> s;
    int prev=-INF;
    int cnt=0;
    F0R(i,n) {
        if(s[i]=='o' && i-prev>c) {
            lr[i]=1;
            cnt++;
            prev=i;
        }
    }
    if(cnt>k)
        return 0;
    prev=INF;
    for(int i=n-1; ~i; i--) {
        if(s[i]=='o' && prev-i>c) {
            rl[i]=1;
            prev=i;
        }
    }
    F0R(i,n) {
        if(lr[i] && rl[i])
            cout << i+1 << "\n";
    }
    
    return 0;
}


Measured memory_bytes: 2196
#include <iostream>
#include <math.h>
using namespace std;
using ll = long long;
int main(){
    ll a,b,c;
    cin>>a>>b>>c;
    if(c-a-b <= 0){
        cout << "No" << endl;
    }else if(a*b*4 < (c-a-b)*(c-a-b)){
        cout<<"Yes"<<endl;

    }else{
        cout<<"No"<<endl;
    }


}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){

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

}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define INF 1000000005
#define MOD 1000000007
#define rep(i,n) for(int i=0;i<n;++i)

using namespace std;

typedef pair<int,int>P;

const int MAX_N = 200005;

vector<int> rd[MAX_N],ry[MAX_N];
int n,K,L;
int par[MAX_N][2];
int nrank[MAX_N][2];
map<P,int> mp;

void initial(int n,int id){		//初期化
	for(int i=0;i<n;i++){
		par[i][id] = i;
		nrank[i][id] = 0;
	}
}

int find(int x,int id){		//木の根を求める
	if(par[x][id] == x){
		return x;
	}else{
		return par[x][id] = find(par[x][id],id);
	}
}

void unite(int x,int y,int id){
	x = find(x,id);
	y = find(y,id);
	if(x == y) return;
	if(nrank[x][id] < nrank[y][id]){
		par[x][id] = y;
	}else{
		par[y][id] = x;
		if(nrank[x][id] == nrank[y][id])
			nrank[x][id]++;
	}
}

bool same(int x,int y,int id){
	return find(x,id) == find(y,id);
}

int main()
{
	scanf("%d%d%d",&n,&K,&L);
	rep(i,K){
		int p,q;
		scanf("%d%d",&p,&q);
		rd[p-1].push_back(q-1);
	}
	rep(i,L){
		int r,s;
		scanf("%d%d",&r,&s);
		ry[r-1].push_back(s-1);
	}
	rep(i,2){
		initial(n,i);
	}
	rep(i,n){
		rep(j,rd[i].size()){
			unite(i,rd[i][j],0);
		}
	}
	rep(i,n){
		rep(j,ry[i].size()){
			unite(i,ry[i][j],1);
		}
	}
	rep(i,n){
		mp[P(find(i,0),find(i,1))]++;
	}
	rep(i,n-1){
		printf("%d ",mp[P(find(i,0),find(i,1))]);
	}
	printf("%d\n",mp[P(find(n-1,0),find(n-1,1))]);
	return 0;
}

Measured memory_bytes: 26496
#include <iostream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
#include <set>

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,j) FOR(i,0,j)
#define mp std::make_pair

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

typedef unsigned long long ull;

int main(){
    int a, b;
    std::cin >> a >> b;

    printf("%.4f\n", 1.0 * a * b / 3.305785);
}

Measured memory_bytes: 1192
<?php
fscanf(STDIN, '%d %d', $n, $m);
$s = array_fill(1, $m, NULL);
for ($i  = 0; $i < $n; $i++) {
    fscanf(STDIN, '%d %d', $a, $b);
    $s[$a][] = $b;
}

$cnt = 0;
$q = new SplPriorityQueue();
for ($i = 1; $i <= $m; $i++) {
    if (!is_null($s[$i])) {
        foreach ($s[$i] as $v) {
            $q->insert($v, $v);
        }
    }
    if (!$q->isEmpty()) $cnt += $q->extract();
}
echo $cnt.PHP_EOL;

Measured memory_bytes: 59896
n = int(input())
a = list(map(int, input().split()))

for i in range(n):
    if a[i]%2 == 0:
        if a[i]%3 != 0 and a[i]%5 != 0:
            print("DENIED")
            break
    if i == n-1:
        print("APPROVED")
        break

Measured memory_bytes: 3060
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<vector>
using namespace std;
long long cnt;
int l;
int A[1000000];
int n;
vector<int> G;
void xxx(int A[],int n,int g)
{
	for(int i=g;i<n;i++)
	{
	int v=A[i];
	int j=i-g;
	while(j>=0 &&A[j]>v)
	{
		A[j+g]=A[j];
		j-=g;
		cnt++;
	}
	A[j+g]=v;
 } 
}
void xx(int A[],int n)
{
	for(int h=1; ;)
	{
		if(h>n)
		break;
		G.push_back(h);
		h=3*h+1;
	}
	for(int i=G.size()-1;i>=0;i--)
	
	{
		xxx(A,n,G[i]);
	}
}
int main()
{
	cin>>n;
	for(int i=0;i<n;i++)
	scanf("%d",&A[i]);
	cnt=0;
	xx(A,n);
	cout<<G.size()<<endl;
	for(int i=G.size()-1;i>=0;i--)
	{
		printf("%d",G[i]);
		if(i)
		printf(" ");
	}
	printf("\n");
	printf("%d\n",cnt);
	for(int i=0;i<n;i++)
	printf("%d\n",A[i]);
	return 0;
	}

Measured memory_bytes: 7196
#include<iostream>
#include<string>
#include<cmath>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<list>
#include<iomanip>
#include<vector>
#include<functional>
#include<algorithm>
#include<cstdio>
#include<math.h>
#include<unordered_map>
using namespace std;
#define int long long
typedef long double ld;
const long double pi= 3.14159265358979323846264338327950288;
int n, dp[41][401][401], ma, mb;
struct A {
	int a, b, c;
};
A a[41];
const int inf = 999999999999999999;
signed main() {
	cin >> n >> ma >> mb;
	for (int i = 0; i < n; i++) {
		cin >> a[i].a >> a[i].b >> a[i].c;
	}
	for (int i = 0; i <= n; i++) {
		for (int j = 0; j < 401; j++) {
			for (int z = 0; z < 401; z++)
				dp[i][j][z] = inf;
		}
		dp[i][0][0] = 0;
	}
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < 401; j++) {
			for (int z = 0; z < 401; z++) {
				if (dp[i][j][z] != inf) {
					dp[i + 1][j + a[i].a][z + a[i].b] = min(dp[i + 1][j + a[i].a][z + a[i].b], dp[i][j][z] + a[i].c);
					dp[i + 1][j][z] = min(dp[i + 1][j][z], dp[i][j][z]);
				}
			}
		}
	}
	int ans = inf;
	int j = 1;
	while (ma*j < 401 && mb*j < 401) {
		ans = min(ans, dp[n][ma*j][mb*j]);
		j++;
	}
	if (ans == inf)
		ans = -1;
	cout << ans << endl;
	cin >> ans;
}

Measured memory_bytes: 51712
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int n, t, a;
  cin >> n >> t >> a;
  int ans;
  int min_abs;
  for (int i = 0; i < n; i++) {
    int h;
    cin >> h;
    int ave_t = 1000 * t - (h * 6);
    if (i == 0 || abs(1000 * a - ave_t) < min_abs) {
      min_abs = abs(1000*a - ave_t);
      ans = i + 1;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <cstdio>
#include <vector>

using namespace std;

vector<pair<double,double> > v;

double s(double x1, double y1, double x2, double y2, double x3, double y3){
  double a,b,c,z;

  a = sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2));
  b = sqrt((x1-x3)*(x1-x3)+(y1-y3)*(y1-y3));
  c = sqrt((x2-x3)*(x2-x3)+(y2-y3)*(y2-y3));

  z = (a+b+c)/2;

  return sqrt(z*(z-a)*(z-b)*(z-c));
}

int main(void){
  int n=0;
  double x,y;
  double ret=0;

  while(cin >> x){
	cin.ignore();
	cin >> y;
	v.push_back(make_pair(x,y));
	n++;
  }
  
  for(int i=0;i<n-2;i++){
	ret += s(v[0].first, v[0].second, v[i+1].first,
			 v[i+1].second, v[i+2].first, v[i+2].second);
  }

  printf("%.7f\n", ret);
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
typedef long long int ll;
typedef unsigned long long ull;
typedef long double ld;
typedef vector<int> vi;
typedef vector<long long int> vl;
typedef vector<vector<int>> vvi;
typedef vector<vector<long long int>> vvl;
typedef pair<int, int> pii;
typedef pair<long long int, long long int> pll;
typedef vector<pair<int, int>> vii;
typedef vector<pair<long long int, long long int>> vll;
#define fast() ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define test() long long int t; cin >> t; cin.ignore(); while(t--) 
#define ff first
#define ss second
#define pb push_back
#define pf push_front
#define mp make_pair
#define MOD 1000000007
#define SMOD 998244353
#define pq priority_queue
#define all(x) x.begin(),x.end()
#define SP(x) setprecision(x)
#define sp " "
#define inp(a) ll a;cin>>a;cin.ignore()
#define inps(a,b) ll a,b;cin>>a>>b;cin.ignore()
#define out(a) cout<<SP(20)<<a<<'\n'
#define outs(a,b) cout<<SP(20)<<a<<" "<<b<<'\n'
#define ins insert
#define er erase
#define lb lower_bound
#define ub upper_bound
#define printclock cerr<<"Time : "<<1000*(ld)clock()/(ld)CLOCKS_PER_SEC<<"ms\n";
#define inpa(a,n) ll a[n]; for(int i=0; i<n; i++){cin>>a[i];}
#define inpv(a,n) vl a; for(int i=0; i<n; i++){inp(x);a.pb(x);}
#define outa(a,n) for(int i=0;i<n;i++){cout<<a[i]<<" ";}cout<<'\n';
#define outv(v) for(auto i:v){cout<<i<<" ";}cout<<'\n';
set<char> vow = {'a','e','i','o','u','A','E','I','O','U'};
ll xpow(ll n, ll m){if(m==0){return 1;}else{ll x = xpow(n, m/2);if(m&1){return x*x*n;}else{return x*x;}}}
ll xmod(ll a, ll m){return (((a%m)+m)%m);}
ll xmodpow(ll n, ll m, ll y){if(m==0){return 1;}else{ll x = xmodpow(n, m/2, y);if(m&1){return xmod((xmod((xmod(x,y)*xmod(x,y)),y)*xmod(n,y)),y);}else{return xmod((xmod(x,y)*xmod(x,y)),y);}}}
 
int main(){
    fast();
 
/* you get what you work for not what you wish for */
    
    ll a, b, c;
    cin >> a >> b >> c;
    map <ll, ll> m;
    m[a]++;
    m[b]++;
    m[c]++;
    if(m[5]==2&&m[7]==1){
        cout << "YES" << endl;
    }
    else{
        cout << "NO" << endl;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep2(i, x, n) for(int i = x; i <= n; i++)
#define rep3(i, x, n) for(int i = x; i >= n; i--)
#define elif else if
#define sp(x) fixed << setprecision(x)
#define pb push_back
#define eb emplace_back
#define all(x) x.begin(), x.end()
#define sz(x) (int)x.size()
using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using pil = pair<int, ll>;
using pli = pair<ll, int>;
using pll = pair<ll, ll>;
const ll MOD = 1e9+7;
//const ll MOD = 998244353;
const int inf = (1<<30)-1;
const ll INF = (1LL<<60)-1;
const ld EPS = 1e-10;
template<typename T> bool chmax(T &x, const T &y) {return (x < y)? (x = y, true) : false;};
template<typename T> bool chmin(T &x, const T &y) {return (x > y)? (x = y, true) : false;};

int main(){
    ll N, A, B;
    cin >> N >> A >> B;
    ll M = B*(N-1)+A, m = B+A*(N-1);
    if(A > B || (N == 1 && A != B)) cout << 0 << endl;
    else cout << M-m+1 << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
 
#define ll long long
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define pi pair<ll,int> 
#define pii pair<int,ll>
 
ll mod = 1e9+7;
ll INF = 1e17;
/*ll gcd(ll a,ll b)
{
    if(a==0)
    return(b);
    return(gcd(b%a,a));
}*/
int main()
{
    IOS
    string s1,s2,s3;
    cin>>s1>>s2>>s3;
    ll c1=s1.size(),c2=s2.size(),c3=s3.size();
    ll c=1;
    ll i1=0,i2=0,i3=0;
    while(1)
    {
        if(c==1)
        {
            if(i1==c1)
            {
                cout<<"A";
                break;
            }
            if(s1[i1]=='a')
            c=1;
            else if(s1[i1]=='b')
            c=2;
            else
            c=3;
            i1++;
        }
        else if(c==2)
        {
            if(i2==c2)
            {
                cout<<"B"<<endl;
                break;
            }
            if(s2[i2]=='a')
            c=1;
            else if(s2[i2]=='b')
            c=2;
            else
            c=3;
            i2++;           
        }
        else
        {
            if(i3==c3)
            {
                cout<<"C"<<endl;
                break;
            }
            if(s3[i3]=='a')
            c=1;
            else if(s3[i3]=='b')
            c=2;
            else
            c=3;
            i3++;            
        }
    }
    return(0);
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (int)(n); i ++)
#define irep(i,n) for (int i = (int)(n) - 1;i >= 0;--i)
using namespace std;
using ll = long long;
using PL = pair<ll,ll>;
using P = pair<int,int>;
constexpr int INF = 1000000000;
constexpr long long HINF = 1000000000000000;
constexpr long long MOD = 1000000007;// = 998244353;
constexpr double EPS = 1e-4;
constexpr double PI = 3.14159265358979;

int main() {
    int X; cin >> X;
    int ans = 1;
    for (int i = 2;i <= X; ++i) {
        int y = i;
        while (y*i <= X) {
            y *= i;
            ans = max(ans,y);
        }
    }
    cout << ans << '\n';
    return 0;
}

Measured memory_bytes: 3632
N = gets.to_i
Cs = gets.split.map(&:to_i)
M = 10**9 + 7

cs = Cs.sort
puts ((1 << (2*N - 2)) % M)*(1 .. N).inject(0){|s, i| (s + cs[i - 1] * (N - i + 2)) % M} % M

Measured memory_bytes: 21120
#include<iostream>
#include <bits/stdc++.h>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;

int main() {

  int a,b,c,d ;
  cin >> a >> b >> c >> d  ;

  while(a>0 || c>0){
    c-=b ;
    if(c<=0) break ;
    a-=d ;
  }

  if(a<=0){
    cout << "No" << endl ;
  }else{
    cout << "Yes" << endl ;
  }


 return 0 ;
}  


Measured memory_bytes: 3636
//#include<bits/stdc++.h>
#pragma GCC optimize(2)
#pragma G++ optimize(2)
#include<map>
#include<set>
#include<cmath>
#include<queue>
#include<stack>
#include<cstdio>
#include<string>
#include<vector>
#include<cstring>
#include<utility>
#include<iostream>
#include<algorithm>
#include<functional>
#include<unordered_map>
using namespace std;

#define ios ios::sync_with_stdio(false)
#define ll long long
#define pa pair<int,int>
#define mk make_pair
#define sc(n) scanf("%d",&n)
#define ss(s) scanf("%s",s)
#define fo(i,a,b) for(int i=a;i<=b;i++)
#define of(i,a,b) for(int i=a;i>=b;i--)
#define mem(a,b) memset(a,b,sizeof a)
#define uint unsigned int
#define vr vector<int>
#define pi acos(-1)

const ll inf = 0x3f3f3f3f;
const ll mod = 1e9 + 7.;
const ll N = 1e6 + 7;

int n, m, t;
int a[200];

int main()
{
	cin >> n;
	int ans = 0;
	for (int i = 1; i <= n; i++)
		cin >> a[i];
	for (int i = 1; i <= n; i++)
	{
		for (int j = i + 1; j <= n; j++)
			ans += a[i] * a[j];
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
// https://atcoder.jp/contests/abc088/tasks/abc088_b

#include <algorithm>
#include <iostream>
#include <vector>
using namespace std;
#define max(a, b) (((a) > (b)) ? (a) : (b))
#define min(a, b) (((a) < (b)) ? (a) : (b))

int main() {
    int n, a = 0, b = 0;
    vector<int> v;
    cin >> n;
    v.resize(n);

    for (int i = 0; i < n; i++) {
        cin >> v[i];
    }
    // 大きい順にソート
    sort(v.begin(), v.end(), greater<int>());

    for (int i = 0; i < n; i++) {
        if (i % 2 == 0) {
            a += v[i];
        } else {
            b += v[i];
        }
    }
    cout << (a - b) << endl;

    return 0;
}

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

#define NOT_FOUND -1

int BinarySearch(int n, int *S, int _key){
    int left = 0;
    int right = n;
    int mid;
    while (left < right){
        mid = (int)((left + right) / 2);
        if (S[mid] == _key){
            return mid;
        } else if (S[mid] > _key){
            right = mid;
        } else {
            left = mid + 1;
        }
    }
    return NOT_FOUND;
}

int main(){
    int n, q;
    int *S, *T;
    int C = 0;
    int addr;

    cin >> n;
    S = new int[n];
    for (int i = 0; i < n; i++){
        cin >> S[i];
    }

    cin >> q;
    T = new int[q];
    for (int i = 0; i < q; i++){
        cin >> T[i];
        addr = BinarySearch(n, S, T[i]);
        if (addr != NOT_FOUND){
            C += 1;
        }
    }
    cout << C << endl;
    delete[] S;
    delete[] T;

    return 0;
}



Measured memory_bytes: 3364
import sys, os, math, bisect, itertools, collections, heapq, queue
# from scipy.sparse.csgraph import csgraph_from_dense, floyd_warshall
from decimal import Decimal
from collections import defaultdict, deque

# import fractions

sys.setrecursionlimit(10000000)

ii = lambda: int(sys.stdin.buffer.readline().rstrip())
il = lambda: list(map(int, sys.stdin.buffer.readline().split()))
fl = lambda: list(map(float, sys.stdin.buffer.readline().split()))
iln = lambda n: [int(sys.stdin.buffer.readline().rstrip()) for _ in range(n)]

iss = lambda: sys.stdin.buffer.readline().decode().rstrip()
sl = lambda: list(map(str, sys.stdin.buffer.readline().decode().split()))
isn = lambda n: [sys.stdin.buffer.readline().decode().rstrip() for _ in range(n)]

lcm = lambda x, y: (x * y) // math.gcd(x, y)
# lcm = lambda x, y: (x * y) // fractions.gcd(x, y)

MOD = 10 ** 9 + 7
MAX = float('inf')


def main():
    if os.getenv("LOCAL"):
        sys.stdin = open("input.txt", "r")

    N, M, K = il()
    A = list(itertools.accumulate([0] + il()))
    B = list(itertools.accumulate(([0] + il())))

    ret, m = 0, M
    for n in range(N+1):
        if A[n] > K:
            break

        while B[m] > K - A[n]:
            m -= 1
        ret = max(ret, n+m)
    print(ret)




if __name__ == '__main__':
    main()


Measured memory_bytes: 42436
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int a, b;
  cin >> a >> b;
  int p = (a+b) % 2;
  if(p == 1){
    int x = (a+b)/2;
    cout << x+1 << endl;
  }
  else{
   int x = (a+b)/2;
   cout << x << endl;
  }
}

Measured memory_bytes: 256
from heapq import *
import sys

sys.setrecursionlimit(10 ** 6)
input = sys.stdin.readline
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep="\n")

def impossible():
    print("Impossible")
    exit()

def main():
    h, w = map(int, input().split())
    t = [list(map(int, input().split())) for _ in range(h)]
    edge = [[0] * 101 for _ in range(101)]

    # XとYをつなぐ辺の作成
    for n_x in range(101):
        for n_y in range(101):
            cost = 0
            for i in range(h):
                for j in range(w):
                    x, y = i + 1, j + 1
                    cur_cost = t[i][j] - x * n_x - y * n_y
                    if cur_cost > cost: cost = cur_cost
            edge[n_x][n_y] = cost
    # p2D(edge)

    # 条件を満たしているかのチェック
    for i in range(h):
        for j in range(w):
            x, y = i + 1, j + 1
            tij = t[i][j]
            min_dist = 1000
            for n_x in range(101):
                for n_y in range(101):
                    dist = x * n_x + y * n_y + edge[n_x][n_y]
                    if dist < min_dist: min_dist = dist
            if tij != min_dist: impossible()

    print("Possible")
    print(202, 101 * 101 + 200)
    for u in range(1, 101):
        print(u, u + 1, "X")
    for u in range(102, 202):
        print(u, u + 1, "Y")
    for n_x in range(101):
        for n_y in range(101):
            print(n_x + 1, 202 - n_y, edge[n_x][n_y])
    print(1, 202)

main()


Measured memory_bytes: 3780
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
// #define fore(i,a) for(auto &i:a)
// #define all(x) (x).begin(),(x).end()
// #pragma GCC optimize ("-O3")
// using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
// typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
// template<class T>bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
// template<class T>bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }

using namespace std;

int main()
{
  long int n,m;
  cin>>n>>m;
  
  vector<long int> H;
  H.resize(n);
  rep(i,0,n){
    cin>>H[i];
  }
  
  vector<long int> A,B;
  A.resize(m);B.resize(m);
  rep(i,0,m){
    cin>>A[i]>>B[i];
  }
  
  int count=0;
  vector<bool> flag;
  flag.resize(n);
  rep(i,0,n){
    flag[i]=true;
  }
  
  rep(i,0,m){
    if(H[A[i]-1]<H[B[i]-1]){
      flag[A[i]-1]=false;
    }
    else if(H[A[i]-1]>H[B[i]-1]){
      flag[B[i]-1]=false;
    }
    else{
      flag[A[i]-1]=false;
      flag[B[i]-1]=false;
    }
  }
  
  rep(i,0,n){
    if(flag[i]) count++;
  }
  
  cout<<count<<endl;
  
  return 0;
}

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

using namespace std;
using ll = long long;
using ld = long double;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define reps(i, s, n) for (int i = (int)(s); i < (int)(n); i++)
const ll mod = ll(1e9) + 7;
const int INF = int(1e9);

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

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
char s[100005],ch;
bool flag=true;
int q,t,f,min1,max1,n;
struct num{
    char c;
    int id;
}x[300005];
bool cmp(struct num a,struct num b)
{
    return a.id<b.id;
}
bool cmp1(struct num a,struct num b)
{
    return a.id>b.id;
}
int main()
{
    scanf("%s%d",s,&q);
    n=strlen(s);
    for(int i=0;i<n;i++)
    {
        x[i].c=s[i];
        x[i].id=i;
    }
    min1=0;
    max1=n-1;
    while(q--)
    {
        scanf("%d",&t);
        if(t==1)
        {
            if(flag)
                flag=false;
            else
                flag=true;
        }
        else
        {
            scanf("%d %c",&f,&ch);
            if(f==1)
            {
                if(flag)
                {
                    min1--;
                    x[n].c=ch;
                    x[n++].id=min1;
                }
                else
                {
                    max1++;
                    x[n].c=ch;
                    x[n++].id=max1;
                }
            }
            else
            {
                if(flag)
                {
                    max1++;
                    x[n].c=ch;
                    x[n++].id=max1;
                }
                else
                {
                    min1--;
                    x[n].c=ch;
                    x[n++].id=min1;
                }
            }
        }


    }
    if(flag)
    {
        sort(x,x+n,cmp);
        for(int i=0;i<n;i++)
            printf("%c",x[i].c);
    }
    else
    {
        sort(x,x+n,cmp1);
        for(int i=0;i<n;i++)
            printf("%c",x[i].c);
    }
}



Measured memory_bytes: 2944
#include <bits/stdc++.h>
#include <stdlib.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;
typedef pair<ll,ll> P;
typedef priority_queue<P,vector<P>,greater<P>> P_queue;

#define REP(i,a,b) for(int i=(int)a;i<(int)b;i++)
#define rep(i,n) REP(i,0,n)
#define pb push_back
#define mp make_pair
#define ALL(a) a.begin(),a.end()
#define SORT(a) sort(ALL(a))
#define U_ERASE(V) V.erase(unique(ALL(V)), V.end());

const ll MOD=998244353;
const ll mod=1000000007;
const ll INF=1e15;
vec dx={1,0,-1,0};
vec dy={0,1,0,-1};

int main(){
    ll A,B,N; cin>>A>>B>>N;
    if(N>=B) N=B-1;
    cout<<(A*N)/B<<endl;

}

Measured memory_bytes: 3628
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
int arr[100005];
int dp[3005][3005];
int anss  = 0 ;
string str1,str2;
void lcs()
    {
        int n =  str1.size();
        int m = str2.size();
        for(int i=0;i<=n;i++)
        {
            for(int j = 0 ; j<=m;j++)
            {
                if(i==0||j==0)dp[i][j]=0;
                else if(str1[i-1]==str2[j-1])
                    dp[i][j]= 1+dp[i-1][j-1],anss=max(anss,dp[i][j]);
                else
                    dp[i][j]= max(dp[i-1][j],dp[i][j-1]);
            }
        }

    }
void printstring()
    {
        int i = str1.size();
        int j = str2.size();
        int idx = anss;
        char str[anss+1];
        str[anss]='\0';
        while(i>0&&j>0)
        {
            if(str1[i-1]==str2[j-1])
            {
                anss--;
                str[anss]=str1[i-1];
                idx--;
                i--;
                j--;
            }
            else if(dp[i-1][j]>dp[i][j-1])
            {
                i--;
            }
            else
                j--;
        }
        cout<<str<<endl;
    }
int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    cin>>str1>>str2;
    lcs();
    printstring();

}













Measured memory_bytes: 38796
#include <iostream>
#include<string>
#include <regex>
std::string tolower(std::string s)
{
	for (int i = 0;i < s.size();++i) {
		if (s[i] >= 'A' && s[i] <= 'Z') {
			s[i] += 'a' - 'A';
		}
	}
	return s;
}
int main() {
	std::string s, t;
	std::cin >> s;
	int cnt = 0;
	while (std::cin >> t && t != "END_OF_TEXT") {
		if (s == tolower(t)) {
			cnt++;
		}
	}
	std::cout << cnt << std::endl;
	return 0;
}


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

void solve() {
	int a, b, c, d, e;
	cin >> a >> b >> c >> d >> e;
	int ans = (c * 60 + d) - (a * 60 + b) - e;
	// if (ans < 0) ans += 24 * 60;
	cout << ans << "\n";
}

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

Measured memory_bytes: 3584
n = int(input())
train_info = []
for _ in range(1, n):
    train_info.append(list(map(int, input().split())))

# print(train_info)

for i in range(1, n + 1):
    # print("i = {}".format(i))
    t = 0

    if i == n:
        print(0)
    else:
        for j in range(i, n):
            # print("t = {}".format(t))
            C_j, S_j, F_j = train_info[j - 1]
            if t <= S_j:
                t = S_j + C_j
            elif t % F_j == 0:
                t += C_j
            else:
                t += F_j - t % F_j
                t += C_j

        print(t)


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

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int N, Q;
    cin >> N >> Q;
    vector<queue<int> > edges(N+1);
    for (int i = 0; i < N-1; i++) {
        int a, b;
        cin >> a >> b;
        edges[a].push(b);
        edges[b].push(a);
    }
    vector<int> counter(N+1, 0);
    for (int i = 0; i < Q; i++) {
        int p, x;
        cin >> p >> x;
        counter[p] += x;
    }
    queue<int> current;
    current.push(1);
    vector<int> distances(N+1, -1);
    distances[1] = counter[1];
    while (!current.empty()) {
        int a = current.front();
        while(!edges[a].empty()) {
            int b = edges[a].front();
            if (distances[b] == -1) {
                distances[b] = distances[a]+counter[b];
                current.push(b);
            }
            edges[a].pop();
        }
        current.pop();
    }
    for (int i = 1; i < N+1; i++) {
        printf("%d\n", distances[i]);
    }
    return 0;
}

Measured memory_bytes: 139008
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <queue>
#include <set>
#include <numeric>
#include <cmath>

using namespace std;

typedef long long int lld;

const lld mod = 1e9+7;
const lld INF = 1e9;
//const lld MAXN = 1e9;

int main()
{
	int n;
	cin >> n;
	vector<int> p(n);
	for(int i = 0; i < n; i++)
	{
		cin>>p[i];
	}
	for(int i = 0; i < n; i++)
	{
		p[i]--;
	}
	int ans = 0;
	for(int i = 0; i < n; i++)
	{
		if (p[i] == i)
		{
			if (i == n-1)
			{
				int sw = p[i];
				p[i] = p[i-1];
				p[i-1] = sw;
				ans++;
			}else
			{
				int sw = p[i];
				p[i] = p[i+1];
				p[i+1] = sw;
				ans++;
			}
		}
	}


	cout << ans << endl;

	return 0;
}

// 12345
// 21345
// 21435
// 21453

// 21435

// 1234567
// 2134567
// 2143567
// 2143657
// 2143675

Measured memory_bytes: 640
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <numeric>
#include <string>
#include <cstdio>
#include <cstring>
#include <queue>
#include <stack>
#include <set>
#include <cmath>
#include <bitset>

typedef long long ll;
using namespace std;

#define FALSE printf("false\n");
#define TRUE printf("true\n");
#define all(x) (x).begin(),(x).end()
#define print(x) cout<<(x)<<endl
#define rep(i,n) for(int i = 0;i < ((int)(n));++i)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define SUM(vec) accumulate(all(vec),0LL)
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
#define test(a) cout<<"line:"<<__LINE__<<"["<<(#a)<<": "<<(a)<<"]"<<endl

const int INF = 1e9+7;
const ll INFL = 9*1e18;

ll inline digit(ll num){int tmp = 0;while(num){tmp++;num/=10;}return tmp;}
template<typename T>inline T digitSum(T num){T sum = 0;while(num){sum+=num%10;num/=10;}return sum;} // 各桁の和
template<typename T>inline T gcd(T a,T b){if(b == 0)return a;return gcd(b,a%b);}
template<typename T>inline T lcm(T a, T b){T g = gcd(a,b);return a/g*b;}
template<typename T>inline T power(T a,T b){T tmp=1;rep(i,b){tmp*=a;}return tmp;}


bool isOk(ll key,ll value){
  return key >= value;
}

ll binary_search(vector<ll> a,ll key){
  ll ok = a.size()-1;
  ll ng = 0;

  while(abs(ok - ng) > 1){
    ll mid = (ok + ng) / 2;
    if(isOk(key,a[mid]))ok = mid;
    else ng = mid;
  }
  return ok;
}

int main() {
  cin.tie(0); ios::sync_with_stdio(0);
  string s;cin>>s;
  int n = s.size();
  string tmp[4] = {"dream", "dreamer", "erase", "eraser"};
  rep(i,4)reverse(all(tmp[i]));
  reverse(all(s));


  for(int i = 0;i < n;){
    bool can = false;
    rep(j,4){
      string temp = s.substr(i,tmp[j].size());
      if(temp == tmp[j]){
        can = true;
        i += temp.size();
        break;
      }
    }
    if(!can){
      print("NO");
      return 0;
    }
  }
  print("YES");
  return 0;
}


Measured memory_bytes: 512
#include<iostream>
#include<set>

using namespace std;

#define NMAX 100
int main(){

    int n;
    string in,tmp;
    set<string> emp[NMAX];
    string team[NMAX];

    while(1){

        cin>>n;
        if(n==0) break;

        for(int i=0;i<n;i++){
            if(emp[i].size()!=0) emp[i].clear();
        }

        for(int i=0;i<n;i++){
            cin>>in;
            tmp="";

            for(int j=0;j<in.size();j++){
                if(in[j]==':'){
                    team[i]=tmp;
                    tmp="";
                }
                else if(in[j]==','||in[j]=='.'){
                    emp[i].insert(tmp);
                    tmp="";
                }
                else{
                    tmp+=in[j];
                }
            }
        }

        for(int i=1;i<n;i++){
            for(int k=0;k<n;k++){
                if(emp[k].find(team[i])!=emp[k].end()){
                    emp[k].erase(emp[k].find(team[i]));
                    for (set<string>::iterator it = emp[i].begin(); it != emp[i].end(); it++){
                        if(emp[k].find(*it)==emp[k].end()){
                            emp[k].insert(*it);
                        }
                    }
                }
            }
        }
        cout<<emp[0].size()<<endl;
    }
    return 0;
}

Measured memory_bytes: 1472
#prag\
ma GCC optimize("O3")
#include<bits/stdc++.h>
using namespace std;

int e[300005],w[300005];
int main()
{
	ios::sync_with_stdio(false);cin.tie(0);
	int n;
	string s;
	cin>>n>>s;
	for(int i=1;i<=n;++i){
		w[i+1]=w[i];
		if(s[i-1]=='W') ++w[i+1];
	}
	for(int i=n;i>=1;--i){
		e[i-1]=e[i];
		if(s[i-1]=='E') ++e[i-1];
	}
	int ans=300005;
	for(int i=1;i<=n;++i) ans=min(ans,e[i]+w[i]);
	cout<<ans;
}

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

typedef long long ll;
int a, b, c;
int n;

ll pow(int x, int n){
    int res = 1;
    while(n>0){
        if(n&1) res = res * x;
        x = x * x;
        n >>= 1;
    }
    return res;
}

int main(){
    scanf("%d%d%d", &a, &b, &c);
    scanf("%d", &n);
    ll abc[3] = {a, b, c};
    int maxi = 0;
    for(int i=0; i< 3; i++){
        if(abc[maxi] < abc[i]){
            maxi = i;
        }
    }
    ll sum = 0;
    for(int i=0; i<3 ; i++){
        if(i != maxi) sum+=abc[i];
        else sum+=pow(2, n)*abc[i];
    }
    printf("%lld", sum);
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define repr(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define reprrev(i,a,b) for(int i=b-1;i>=a;i--) // [a, b)
#define reprev(i,n) reprrev(i,0,n)
typedef long long ll;
typedef unsigned long long ull;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

/* attention
    long longのシフト演算には気をつけよう
    タイポした時のデバッグが死ぬほどきつくなるので変数名は最低3字くらい使った方がいいかも
    sizeは(int)とキャストしよう
    cin.tie(0);
    ios::sync_with_stdio(false);<- これら、printfとかと併用しない方が良さそう

*/

const ll mod = 1e9+7;

void chmod(ll &M){
    if(M >= mod) M %= mod;
    else if(M < 0){
        M += (abs(M)/mod + 1)*mod;
        M %= mod;
    }
}

ll modpow(ll x, ll n){
    if(n==0) return 1;
    ll res=modpow(x, n/2);

    if(n%2==0) return res*res%mod;
    else return res*res%mod*x%mod;
}

int getl(int i, int N) { return i==0? N-1:i-1; };
int getr(int i, int N) { return i==N-1? 0:i+1; };


// 線分 ab の偏角 返り値は[-π, π]
double argument(const pair<double, double> &a, const pair<double, double> &b){
    double ax=a.first, ay=a.second, bx=b.first, by=b.second;
    return atan2(by-ay, bx-ax);
}

/* <-----------------------------------------------------------------------------------> */
/* <-----------------------------------------------------------------------------------> */
/* <-----------------------------------------------------------------------------------> */
/* <-----------------------------------------------------------------------------------> */




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

    ll a, b, k; cin >> a >> b >> k;

    if (a>=k) { cout << a-k << " " << b << endl; }
    else { cout << 0 << " " << max(0LL, b-(k-a)) << endl;}

    return 0;
}

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

def possible_height(cx, cy, infos):
    maxmin = 1
    minmax = 99999999999
    for i in infos:
        hmin, hmax = get_height(cx, cy, *i)
        maxmin = max(maxmin, hmin)
        minmax = min(minmax, hmax)
    if maxmin == minmax:
        return maxmin
    elif maxmin < minmax:  # Undetermined
        raise Exception
    else:  # Impossible
        return None

def get_height(cx, cy, xi, yi, hi):
    hmax = abs(cx - xi) + abs(cy - yi) + hi
    hmin = 1 if hi == 0 else hmax
    return hmin, hmax

def main():
    n = int(input())
    infos = []
    for i in range(n):
        x, y, h = map(int, input().split())
        infos.append((x, y, h))

    for cx in range(101):
        for cy in range(101):
            h = possible_height(cx, cy, infos)
            if h is not None:
                print(cx, cy, h)
                return
    raise Exception

main()


Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn = 100;
int a[maxn],b[maxn];
multiset<int> se;
int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n;
	cin >> n;
	for(int i=1;i<=n;i++){
		cin >> a[i];
	}
	for(int i=1;i<=n;i++)
	cin >> b[i];
	int sum =0;
	for(int i=1;i<=n;i++){
		if(a[i] - b[i] > 0)
		sum +=(a[i] - b[i]);
	}
	cout <<sum <<endl;

} 

Measured memory_bytes: 256