akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;

#define IOS ios_base::sync_with_stdio(false);   cin.tie(NULL); cout.tie(NULL);

#define endl "\n";

#define loop(i,s,n)  for(ll i=s;i<n;i++)
#define test  ll t; cin>>t; while(t--)
#define p push_back
typedef long long ll;
int main()
{IOS
ll n,count=0,sum=0,total=0,acc=0;
cin>>n;
while(n--)
{string s;
cin>>s;
if(s=="AC")
{count++;}
if(s=="WA")
{sum++;}
if(s=="TLE")
{total++;}
if(s=="RE")
{acc++;}
}
cout<<"AC"<<" "<<"x"<<" "<<count<<endl
cout<<"WA"<<" "<<"x"<<" "<<sum<<endl
cout<<"TLE"<<" "<<"x"<<" "<<total<<endl
cout<<"RE"<<" "<<"x"<<" "<<acc<<endl
return 0;
}





Measured memory_bytes: 3624
n = STDIN.gets.to_i
h = STDIN.gets.split.map(&:to_i)

tiles = Array.new(n)
tiles[0] = 0

for i in 1...n do
  tiles[i] = tiles[i - 1] + (h[i] - h[i - 1]).abs
  if i - 2 >= 0 && tiles[i] > tiles[i - 2] + (h[i] - h[i - 2]).abs
    tiles[i] = tiles[i - 2] + (h[i] - h[i - 2]).abs
  end
end

puts tiles[-1]


Measured memory_bytes: 8844
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
map<ll,ll>mp;

int main(){
    ll n;scanf("%lld",&n);
    ll sum=0;
    for(ll i=0;i<n;i++){
        ll num;
        scanf("%lld",&num);
        mp[num]++;
        sum+=num;
    }
    ll q;scanf("%lld",&q);
    for(ll i=0;i<q;i++){
        ll b,c;scanf("%lld%lld",&b,&c);
        mp[c]+=mp[b];
        sum+=mp[b]*(c-b);
        mp[b]=0;
        cout<<sum<<endl;
    }
    return 0;
}

Measured memory_bytes: 9552
#include <iostream>
#include <vector>
#include <cstring>
#include <algorithm>
#include <cassert>
#include <deque>
#include <map>
#include <queue>
#include <climits>
#include <set>
#include <stack>
#include <cmath>
#include <unordered_map>
#include <unordered_set>

using namespace std;

#define ll long long
#define MAX 100000
#define MAX1 10000
#define MAX2 100000
#define inf 1000000000
#define eps 1e-12
#define MOD 1000000007

int main() {

    ios_base::sync_with_stdio(0);
    cin.tie(0);
#ifndef ONLINE_JUDGE
    freopen("in.txt", "r", stdin);
    freopen("out.txt", "w", stdout);
#endif

    int n, i;
    ll ans = 0;
    cin >> n;
    int a[n + 5];
    for (i = 0; i < n; ++i) {
        cin >> a[i];
    }
    for (i = 0; i < n - 1; ++i) {
        if (a[i] > a[i + 1]) {
            ans += a[i] - a[i + 1];
            a[i + 1] = a[i];
        }
    }
    cout << ans;

    return 0;
}


Measured memory_bytes: 4412
N, M, X, Y = map(int, input().split())
x = list(map(int, input().split()))
y = list(map(int, input().split()))
z = []

for i in range(X + 1, Y + 1):
    if max(x) < i and i <= min(y):
        z.append(i)

if len(z) == 0:
    print('War')
else:
    print('No War')



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

class Main{

	public static void main(String args[]){
        Stack<String> problem = new Stack<String>();
        Scanner s = new Scanner(System.in);
        
        String equation = s.nextLine();
        String[] parts = equation.split(" ");
        int len = parts.length;
        int i = 0;
        
        int x;
        int y;
        
        while(i < len){
            if(parts[i].equals("+")){
                x = Integer.parseInt((String) problem.pop());
                y = Integer.parseInt((String) problem.pop());
                problem.push(Integer.toString(x+y));
            }
            else if(parts[i].equals("-")){
                x = Integer.parseInt((String) problem.pop());
                y = Integer.parseInt((String) problem.pop());
                problem.push(Integer.toString(y-x));
            }
            else if(parts[i].equals("*")){
                x = Integer.parseInt((String) problem.pop());
                y = Integer.parseInt((String) problem.pop());
                problem.push(Integer.toString(x*y));
            }
            else if(parts[i].equals("/")){
                x = Integer.parseInt((String) problem.pop());
                y = Integer.parseInt((String) problem.pop());
                problem.push(Integer.toString(x/y));
            }
            else{
                problem.push(parts[i]);
            }
            i++;
            
        }
        System.out.println(problem.pop());
    }
}


Measured memory_bytes: 26164
#include <bits/stdc++.h>
using namespace std;
const int N=1e5+10;
	int a[N];
int main(){
	ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	int n,t=1;
	cin>>n;
	int max1=-1,sum=0;
	for(int i=0;i<n;i++)
	{
		cin>>a[i];
		if(a[i]>max1)max1=a[i];
		sum+=a[i];
	}
	if(sum-max1>max1)cout<<"Yes";
	else cout<<"No";
}


Measured memory_bytes: 256
// Try AtCoder
// author: Leonardone @ NEETSDKASU
package main

import "fmt"

func seek(s string, rn byte) int {
    for j:= 0; j < 101; j++ {
        c := 0
        for i := range s {
            if rn != s[i]{
                break
            }
            c++
        }
        if c == len(s) {
            return j
        }
        tp := ""
        for i := 1; i < len(s); i++ {
            if s[i-1]==rn || s[i]==rn {
                tp += string(rn)
            } else {
                tp+=string(s[i])
            }
        }
        s = tp
    }
    return -1
}

func main() {
    var s string
    fmt.Scan(&s)
    mp := make(map[byte]int)
    for i := range s {
        mp[s[i]]++
    }
    ans := len(s)
    for k := range mp {
        tmp := seek(s, k)
        if tmp < ans {
            ans = tmp
        }
    }
    fmt.Println(ans)
}

Measured memory_bytes: 4992
n = int(input())
E = [[] for i in range(n)]#[[]]*nだと同一アドレスの単一リストがコピーされる
lrg = 10**8
for i in range(n):
    inpt = list(map(int, input().split( )))
    for j in range(inpt[1]):
        E[inpt[0]].append(inpt[2*j+2:2*j+4])
    #print(inpt[0],E[inpt[0]],*inpt)

D = [lrg]*n
D[0] = 0

G =[0]

Prev = [-1]*n
cnt=0
while cnt < n:#len(D)<nでは制御できていない,Dは距離,Gは到達リスト
    for v in G:
        for [u,c] in E[v]:
            if D[u]>D[v]+c:
                #print("replaced")
                D[u] = D[v]+c
                Prev[u]=v
            if u not in G:
                G.append(u)
                #print("append",u)
    cnt+=1            
for v in G:
    for [u,c] in E[v]:
        if D[u]>D[v]+c:
            D[u] = D[v]+c
            Prev[u]=v
            
for i in range(n):
    print(i,D[i])


Measured memory_bytes: 6128
#include <stdio.h>

int main(void){
    int i=0,j=0;
    while(i<9){
        i+=1;
        j=0;
        while(j<9){
            j+=1;
            printf("%dx%d=%d\n",i,j,i*j);
        }
    }
    return 0;
}

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

using namespace std;

const int N = 200200;
const int mod = 1e9 + 7;

void add(int &x,int y) {
	x += y;
	if (x >= mod) {
		x -= mod;
	}
}

int n;
int a[N];
int nxt[N];
int lst[N];
int f[N];

int main() {
	scanf("%d", &n);
	for (int i = 1; i <= n; ++i) {
		scanf("%d", a + i);
	}
	fill(lst, lst + N, n + 1);
	for (int i = n; i > 0; --i) {
		nxt[i] = lst[a[i]];
		lst[a[i]] = i;
	}
	f[1] = 1;
	for (int i = 1; i <= n; ++i) {
		add(f[i + 1], f[i]);
		if (nxt[i] <= n && nxt[i] > i + 1) {
			add(f[nxt[i]], f[i]);
		}
	}
	printf("%d\n", f[n]);
}

Measured memory_bytes: 3328
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")
#pragma warning(disable : 4996)
#include <limits.h>
#include <math.h>
#include <time.h>

#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <complex>
#include <cstdio>
#include <cstring>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>

using namespace std;

#define REP(i, n) for (int i = 0; i < n; ++i)
#define REPR(i, n) for (int i = n - 1; i >= 0; --i)
#define FOR(i, m, n) for (int i = m; i < n; ++i)
#define FORR(i, m, n) for (int i = m - 1; i >= n; --i)
#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define REVERSE(v, n) reverse(v, v + n);
#define VREVERSE(v) reverse(v.begin(), v.end())
#define ll long long
#define print(x) cout << (x) << '\n'
#define pe(x) cout << (x) << " "
#define DEBUG(x) cout << #x << ": " << x << endl
#define lb(v, n) lower_bound(v.begin(), v.end(), (n))
#define ub(v, n) upper_bound(v.begin(), v.end(), (n))
//#define int long long
//#define double long double
#define all(x) (x).begin(), (x).end()
#define print_space(v) \
    REP(i, v.size()) cout << v[i] << ((i == v.size() - 1) ? "\n" : " ")
template <typename T1, typename T2>
inline void chmin(T1& a, T2 b) {
    if (a > b) a = b;
}
template <typename T1, typename T2>
inline void chmax(T1& a, T2 b) {
    if (a < b) a = b;
}
typedef pair<int, int> pii;
typedef array<int, 3> arr3;
std::random_device rd;
std::mt19937 mt(rd());
constexpr ll MOD = 1e9 + 7;
constexpr int MAX = 2000020;
const double pi = acos(-1);
constexpr double EPS = 1e-8;
constexpr ll INF = 1e18;

template <int N>
struct Data {
    long long arr[N];
	long long que[N+10];
    constexpr Data() : arr(),que() {
		int cnt=0;
		int head=0;
		int tail=0;
		while(tail<9){
			que[tail]=tail+1;
			tail++;
		}
		while(cnt<N){
			long long x=que[head++];
			if(tail<=N){
				if(x%10!=0){que[tail++]=(10*x+x%10-1);}
				que[tail++]=(x*10+x%10);
				if(x%10!=9){que[tail++]=(10*x+x%10+1);}
			}
			arr[cnt]=x;cnt+=1;
		}
    }
};

void solve() {
    // test();
    constexpr auto data = Data<100000>();
    int k;
    cin >> k;
    cout << data.arr[k-1] << endl;
}

signed main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    // int q; cin >> q;
    // while (q--)
    solve();
}


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

int main() {
	int n;
	cin >> n;
	vector<int>v(n);
	for (int i = 0; i < n; i++)cin >> v.at(i);
	vector<int>c(n);
	for (int i = 0; i < n; i++)cin >> c.at(i);
	ll ans = 0;
	for (int i = 0; i < n; i++) {
		ans += max(0, v.at(i) - c.at(i));
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include<string>
#include<cmath>
#include<algorithm>
#include<cctype>
#include<queue>
#include<stack>
#include<stdio.h>
#include<vector>
#include<set>
#include<map>
#include<iomanip>
#define rep(i,n) for(int i=0;i<n;i++)
typedef int long long ll;
using namespace std;

int main(){
    int n,k;
    cin>>n>>k;
    
    vector<int> v(n);
    rep(i,n){
        cin>>v[i];
    }
    sort(v.rbegin(),v.rend());
    int ans=0;
    for(int i=0;i<k;i++){
        ans+=v[i];
    }
    cout<<ans<<endl;
    
    
return 0;
}


Measured memory_bytes: 256
n = int(input())

ac = 0
wa = 0
tle = 0
re = 0

for i in range(n):
    s = input()
    if "AC" == s:
        ac += 1
    elif "WA" == s:
        wa += 1
    elif "TLE" == s:
        tle += 1
    elif "RE" == s:
        re += 1

print("AC x {}".format(ac))
print("WA x {}".format(wa))
print("TLE x {}".format(tle))
print("RE x {}".format(re))




Measured memory_bytes: 9196
n = int(input())
aa = tuple(map(int, input().split()))
q = int(input())
mm = tuple(map(int, input().split()))

possible_m = set()
for bit in range(1 << n):
    total = 0
    for i, a in enumerate(aa):
        if (bit >> i) & 1:
            total += a
    possible_m.add(total)
for m in mm:
    if m in possible_m:
        print("yes")
    else:
        print("no")



Measured memory_bytes: 5652
using namespace std;
#include<iostream>
#include<stdio.h>

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

    int ans = 1;
    int uncolect = 1;
    
    for (int i = 0; i<N; i++){
        int a;
        cin >> a;
        ans *= 3;
        if (a%2 == 0){
            //偶数
            uncolect *= 2;
        }
        else{
            //奇数
            uncolect *= 1;
        }
    }

    ans -= uncolect;

    cout << ans;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < n; ++i)
#define ALL(c) (c).begin(), (c).end()
#define SUM(x) std::accumulate(ALL(x), 0LL)
#define MIN(v) *std::min_element(v.begin(), v.end())
#define MAX(v) *std::max_element(v.begin(), v.end())
#define EXIST(v, x) (std::find(v.begin(), v.end(), x) != v.end())
using namespace std;

typedef long long ll;

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; }
const int INF = 1e9;
const long long INFL = 1LL<<60;

int main() {
  int n;
  cin >> n;
  if (n % 2 == 0) {
    cout << 0.5 << endl;
  } else {
    cout << ((n+1) / 2.0) / n << endl;
  }

  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
//#include<cstdio>
#include<vector>
#include<map>
#include<queue>
#include<algorithm>
#include<cmath>
#include<cassert>
using namespace std;
typedef long long ll;

int main(){
	int N;
	cin >> N;
	double sum=0;
	for(int i=0; i<N; i++){
		double x;
		string u;
		cin >> x >> u;
		sum += (u=="JPY"?x:380000*x);
	}

	cout << setprecision(10) << sum << endl;

	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define IL inline
#define _ 105
#define ll long long
using namespace std;

IL int gi(){
	int data=0,fu=1; char ch=0; while(ch!='-'&&(ch<'0'||ch>'9'))ch=getchar();
	if(ch=='-')fu=-1,ch=getchar();
	while('0'<=ch&&ch<='9')data=(data<<1)+(data<<3)+(ch^48),ch=getchar(); return data*fu;
}

int n,q[_],p[_]; bool Ban[1000005]; ll E[_][_];
map<ll,int>M;

IL ll Halmilton(int nc){
	ll ret=0,len=0;
	for(int i=1;i<=nc;++i)p[i]=i;
	do{
		len=0;
		for(int i=2;i<=nc;++i)len+=E[p[i-1]][p[i]];
		ret=max(ret,len);
	}while(next_permutation(p+1,p+nc+1)); return ret;
}

int main(){
	n=gi();
	int l=1,nq=0; bool flag;
	while(nq<n){
		flag=true;
		for(int j=1;j<=nq;++j)if(Ban[l+q[j]])flag=false;
		if(Ban[l])flag=false;
		if(flag){
			for(int j=1;j<=nq;++j)Ban[l+q[j]]=true;
			q[++nq]=l;
		}
		++l;
	}
	E[1][2]=E[2][1]=q[1];
	for(int i=3;i<=n;++i){
		ll m=Halmilton(i-1);
		for(int j=1;j<i;++j)E[i][j]=E[j][i]=1ll*(m+1)*q[j];
	}
	for(int i=1;i<=n;++i,puts(""))
		for(int j=1;j<=n;++j)cout<<E[i][j]<<" ";
	return 0;
}


Measured memory_bytes: 256
function main(lines) {
    const input = lines.split('\n')
    for(let i=0; i<input.length; i++){
        let tmpInput = input[i].split(' ')
        let a = parseInt(tmpInput[0],10)
        let b = parseInt(tmpInput[2],10)
        let op = tmpInput[1]
        
    switch(op){
        case '+':
            console.log(a+b);
            break;
        case '-':
            console.log(a-b);
            break;
        case '*':
            console.log(a*b);
            break;
        case '/':
            console.log(parseInt(a/b,10));
            break;
        case '?':
            break
    }
    }
    

}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));
// 3657.383181 214.382911


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

using namespace std;

typedef long long ll;
const ll INF = 1LL<<60;

ll gcd(ll a, ll b) {
  if(b == 0) return a;
  return gcd(b, a % b);
}

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

ll modpow(ll a, ll n, ll mod) {
    ll res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

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

    int K, X;
    cin >> K >> X;

    int start = max(-1000000, X - K + 1);
    int end   = min( 1000000, X + K - 1);

    for(int i = start; i <= end; i++){
        cout << i << " ";
    }
    cout << endl;


    return 0;
}



Measured memory_bytes: 256
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cassert>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <functional>
#include <iostream>
#include <map>
#include <set>
#include <time.h>
using namespace std;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
typedef long long ll;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000001
#define mod 1000000009
#define fi first
#define sc second
#define rep(i,x) for(int i=0;i<x;i++)

int main()
{
    string s;
    cin >> s;
    s.insert(4," ");
    cout << s << endl;
    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <string>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <iterator>
#include <cassert>
#include <numeric>
#include <functional>
#include <cassert>
//#include <numeric>
#pragma warning(disable:4996) 
 
typedef long long ll;
#define MIN(a, b) ((a)>(b)? (b): (a))
#define MAX(a, b) ((a)<(b)? (b): (a))
#define LINF  9223300000000000000
#define LINF2 1223300000000000000
#define INF 2140000000
const long long MOD = 1000000007;
//const long long MOD = 998244353;

using namespace std;

char str[20];

void solve()
{
    int n;
    scanf("%d", &n);
    set<string> z;
    int i;
    for (i = 0; i < n; i++) {
        scanf("%s", str);
        z.insert(string(str));
    }
    printf("%d\n", (int)z.size());

    return;
}

int main(int argc, char* argv[])
{
#if 1
    solve();
#else
    int T;
    scanf("%d", &T);
    int t;
    for(t=0; t<T; t++) {
        //printf("Case #%d: ", t+1);
        solve();
    }
#endif
    return 0;
}



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

inline int next(void) {
	register int ret = 0;
	register int neg = false;
	register int bit = getchar();
	for (; bit < '0'; bit = getchar())
		if (bit == '-')neg ^= true;
	for (; bit >= '0'; bit = getchar())
		ret = ret * 10 + bit - '0';
	return neg ? -ret : ret;
}

int n, m;

int root;
int cmpk;

struct node {
	int id;
	int pos[2];
	int son[2];
	int min[2];
	int max[2];
	inline friend bool operator < 
		(const node &a, const node &b) {
			return a.pos[cmpk] < b.pos[cmpk];
	}
}tree[500005];

inline void update(int t) {
	for (int k = 0; k < 2; ++k) {
		tree[t].min[k] = tree[t].max[k] = tree[t].pos[k];
		for (int i = 0, s; i < 2; ++i)if (s = tree[t].son[i]) {
			if (tree[t].min[k] > tree[s].min[k])
				tree[t].min[k] = tree[s].min[k];
			if (tree[t].max[k] < tree[s].max[k])
				tree[t].max[k] = tree[s].max[k];
		}
	}
}

int build(int l, int r, int k) {
	int d = (l + r) / 2; cmpk = k;
	nth_element(tree + l, tree + d, tree + r + 1);
	tree[d].son[0] = l == d ? 0 : build(l, d - 1, k ^ 1);
	tree[d].son[1] = r == d ? 0 : build(d + 1, r, k ^ 1);
	return update(d), d;
}

inline void build(void) {
	for (int i = 1; i <= n; ++i) {
		tree[i].id = i - 1;
		tree[i].pos[0] = next();
		tree[i].pos[1] = next();
	}
	root = build(1, n, 0);
}

int st[2], ed[2], ans[500005], tot = 0;

inline bool judge(const node &t) {
	return t.pos[0] >= st[0]
		&& t.pos[0] <= ed[0]
		&& t.pos[1] >= st[1]
		&& t.pos[1] <= ed[1];
}

inline bool check(const node &t) {
	return t.min[0] <= ed[0]
		&& t.max[0] >= st[0]
		&& t.min[1] <= ed[1]
		&& t.max[1] >= st[1];
}

void query(int t) {
	if (judge(tree[t]))ans[tot++] = tree[t].id;
	if (tree[t].son[0] && check(tree[tree[t].son[0]]))query(tree[t].son[0]);
	if (tree[t].son[1] && check(tree[tree[t].son[1]]))query(tree[t].son[1]);
}

inline void query(void) {
	for (int i = 0; i < m; ++i, tot = 0) {
		st[0] = next();
		ed[0] = next();
		st[1] = next();
		ed[1] = next();
		tot = 0;
		query(root);
		sort(ans, ans + tot);
		for (int j = 0; j < tot; ++j)
			printf("%d\n", ans[j]);
		puts("");
	}
}

signed main(void) {
	n = next(); build();
	m = next(); query();
	//system("pause");
}

Measured memory_bytes: 20208
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
template<class T> using vt = vector<T>;
template<class T> using vvt = vector<vt<T>>;
template<class T> using ttt = tuple<T,T>;
using tii = tuple<int,int>;
using vi = vector<int>;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define pb push_back
#define mt make_tuple
#define ALL(a) (a).begin(),(a).end()
#define FST first
#define SEC second
#define DEB cerr<<"!"<<endl
#define SHOW(a,b) cerr<<(a)<<" "<<(b)<<endl
#define DIV ll(1e9+7)
const int INF = (INT_MAX/2);
const ll LLINF = (LLONG_MAX/2);
const double eps = 1e-8;
//const double PI = M_PI;  
inline ll pow(ll x,ll n,ll m){ll r=1;while(n>0){if((n&1)==1)r=r*x%m;x=x*x%m;n>>=1;}return r%m;}
inline ll lcm(ll d1, ll d2){return d1 / __gcd(d1, d2) * d2;}
// IT 5000兆　欲しい
/* Coding space */
// 最大流
#define MAX_V 100000
int main(){
  ll a,b,c,x,y; cin >> a >> b >> c >> x >> y;
  
  ll ans = 0;
  ll tar = min(x,y);
  ans += min(tar*2*c,tar*(a+b));
  if(x < y) swap(x,y),swap(a,b); // x,aが余っている
  ans += min((x - tar)*a,(x-tar)*2*c);
  cout << ans << endl;
}

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

#define ll long long
using namespace std;

#define MAXH 300


void solve()
{
	int H,W,K;
	cin>>H>>W>>K;
	int A[MAXH][MAXH];
	string s[MAXH];
	for(int i=0; i<H; ++i)
		cin>>s[i];
	int num = 1;
	for(int i=0; i<H; ++i)
	{
		int count = 0;
		for(int j=0; j<W; ++j)
			if(s[i][j] == '#')
				++count;
		if(count > 0)
		{
			for(int j=0; j<W; ++j)
			{
				A[i][j] = num;
				if(s[i][j] == '#')
					++num;
			}
			for(int j=W-1; s[i][j]!='#'; --j)
			{
				--A[i][j];
			}
		}
		else
		{
			if(i>0)
				for(int j=0; j<W; ++j)
					A[i][j] = A[i-1][j];
			else
				for(int j=0; j<W; ++j)
					A[i][j] = 0;
			
		}
	}
	for(int i=H-2; i>=0; --i)
		if(A[i][0] == 0)
			for(int j=0; j<W; ++j)
				A[i][j] = A[i+1][j];
	for(int i=0; i<H; ++i)
	{
		for(int j=0; j<W-1; ++j)
			cout<<A[i][j]<<" ";
		cout<<A[i][W-1]<<endl;
	}
}

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	//int T;
	//cin>>T;
	//while(T--)
		solve();
		
	return 0;
}


Measured memory_bytes: 1280
#include<stdio.h>
#define N 101

int main(void){

  int n,i,j,c;
  int InN,p;
  int G[N][N]={};


  scanf("%d",&n);

  for(i=1;i<n+1;i++){
    scanf("%d", &c);
    scanf("%d", &InN);
    for(j=0;j<InN;j++){
      scanf("%d",&p);
      G[c][p] = 1;
    }
  }
  for(i=1;i<n+1;i++){
    for(j=1;j<n+1;j++){
      printf("%d",G[i][j]);
      if(j<n){ printf(" "); }
    }
    printf("\n");
  }

  return 0;
}

Measured memory_bytes: 652
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <stdlib.h>
#include <string.h>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <stdio.h>
#include <tuple>
#include <bitset>
#include <cfloat>
#include <fstream>
#include <limits.h>
#include <list>
#include <math.h>
#include <random>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <numeric>
#include <utility>
#include <sstream>

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

using namespace std;
#define int long long
#define ll long long
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define FORR(i,a,b)for(ll i=(a);i<=(b);i++)
#define repr(i,n) for(ll i=n;i>=0;i--)
#define P pair<ll, ll>
#define sz(x) (ll)x.size()
#define ALL(x) (x).begin(),(x).end()
#define ALLR(x) (x).rbegin(),(x).rend()
#define VE vector<ll>
#define COUT(x) cout<<(x)<<endl
#define MA map<ll,ll>
#define SE set<ll>
#define PQ priority_queue<ll>
#define PQR priority_queue<ll,VE,greater<ll>>
#define COUT(x) cout<<(x)<<endl
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define EPS (1e-10)
ll gcd(ll a, ll b) {
	if (a < b)swap(a, b);
	if (b == 0) return a;
	return gcd(b, a % b);
}
ll lcm(ll a, ll b) {
	ll g = gcd(a, b);
	return a / g * b;
}
bool prime(ll n) {
	for (ll i = 2; i <= sqrt(n); i++) {
		if (n%i == 0)return false;
	}
	return n != 1;
}


const long long MOD = 1000000007;
const long long INF = 1LL << 60;


const int MAX_N = 100010;

signed main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int n, k; cin >> n >> k;
	VE h(n); rep(i, n)cin >> h[i];
	sort(ALL(h));
	int ans = INF;
	rep(i, n - k + 1) {
		chmin(ans, h[i + k - 1] - h[i]);
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 1024
from functools import reduce

def gcd(a,b):
  if a < b:
    a, b = b, a
  while a % b != 0:
    a, b = b, a % b
  return b

def lcm_base(x, y):
  return (x * y) // gcd(x, y)

def lcm_list(numbers):
  return reduce(lcm_base, numbers, 1)

a,b,c,d = map(int,input().split())

lcm = lcm_list([c,d])

res1 = a - 1 - ((a - 1) // c + (a - 1) // d - (a - 1) // lcm)
res2 = b - (b // c + b // d - b // lcm)

print(res2 - res1)


Measured memory_bytes: 3572
#include <iostream>
#include <vector>
using namespace std;
int main()
{
  int N, D, X;
  cin >> N >> D >> X;
  vector<int> A(N);
  for (int i = 0; i < N; i++)
    cin >> A[i];
  int ans = X;
  for (int i = 0; i < N; i++)
    ans += (D + A[i] - 1) / A[i];
  cout << ans << endl;
  return 0;
}

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

typedef long long LL;

int n;
LL li[3005];
LL memo[3005][3005];

LL dp(int l, int r){
   if(l>r) return 0LL;
   LL &ret = memo[l][r];
   if(ret!=-1) return ret;
   ret = max(-1LL*dp(l+1,r) + li[l] , -1LL*dp(l,r-1)+li[r]);
   return ret;
}

int main(){
   memset(memo,-1,sizeof(memo));
   scanf("%d",&n);
   for(int i=1;i<=n;i++) scanf("%lld",&li[i]);
   LL ans = dp(1,n);
   printf("%lld\n",ans);
	return 0;
}


Measured memory_bytes: 71040
#include<iostream>
#include<algorithm>
#include<string>
#include<functional>
#include<utility>
#include<ctime>
#include<cmath>
#include<vector>
#include<set>
#include<queue>
#include<deque>
#include<map>
#include<cstring>
#include<stack>
#include<cctype>
#include<cstdio>
#include<bitset>
#ifdef LOCAL
	#define enu(i,n) for(int i=0;i<n;i++)
	#define tri(x) x*(x+1)/2;
	#define sqrsum(x) x*(x+1)*(2*x+1)/6;
	#define sqrsum_range(a,b) sqrsum(b)-sqrsum(a-1);
#endif
#define FOR(i,a,b) for(int i=a,_b=b;i<_b;i++)
#define REP(i,a,b) FOR(i,a,b+1)
#define ll_max 9223372036854775807LL
#define ll_min -9223372036854775808LL
#define int_max 2147483647
#define int_min -2147483648
#define PI 3.14159265358979323846265
#define eps 0.00000001
#define elif else if
using namespace std;
void fast()
{
	cin.tie(NULL);
	cout.tie(NULL);
	ios_base::sync_with_stdio(false);
	return ;
}
bool isprime(int x)
{
	if(x<2)
		return false;
	for(int i=2;i<=sqrt(x);i++)
		if(x%i==0)
			return false;
	return true;
}
int GCD(int a,int b)
{
	return (b?GCD(b,a%b):a);
}
struct Tm
{
	int h,m,s;
	bool add()
	{
		s++;
		if(s==60)
			m++,
			s=0;
		if(m==60)
			h++,
			m=0;
		return (h<100);
	}
	void print()
	{
		printf("%02d:%02d:%02d",h,m,s);
		return ;
	}
	void println()
	{
		print();
		puts("");
	}
};
int A[100100],ans[100100];
long long Sum;
int main()
{
	int N;
	cin>>N;
	for(int i=0;i<N;i++)
		cin>>A[i],
		Sum+=A[i],
		A[i]*=2;
	for(int i=1;i<N;i+=2)
		Sum-=A[i];
	ans[0]=Sum;
	for(int i=1;i<N;i++)
		ans[i]=A[i-1]-ans[i-1];
	for(int i=0;i<N;i++)
		cout<<ans[i]<<" ";
	return 0;
}

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

template <class T>
inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}

template <class T>
inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}

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

// -------------------------------------------------------
string a, b;

int main() {
  cin >> a >> b;
  int num = atoi((a + b).c_str());
  rep(i, 0, 1000) {
    if (i * i == num) {
      cout << "Yes" << endl;
      return 0;
    }
  }
  cout << "No" << endl;
}


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

using namespace std;

#define ll long long
#define ld long double
#define P pair<ll, ll>

#define FORm(i, m) for (auto i = m.begin(); i != m.end(); i++)

#define all(v) v.begin(), v.end()

#define sortAl(v) sort(all(v))
#define sortAlr(v)          \
  sort(v.begin(), v.end()); \
  reverse(v.begin(), v.end())

#define cout(n) cout << fixed << setprecision(n)

#define rep(i, n) for (ll i = 0; i < n; i++)
#define REP(i, n) for (ll i = 1; i < n; i++)

template <class T>
inline void chmax(T &a, T b) {
  a = std::max(a, b);
}
template <class T>
inline void chmin(T &a, T b) {
  a = std::min(a, b);
}

#define mod (ll)(1e9 + 7)
#define INF LLONG_MAX

// 最大公約数
ll gcd(ll a, ll b) {
  // ユークリッドの互除法
  while (a) {
    if (a < b) {
      swap(a, b);
    }
    a %= b;
  }

  return b;
}

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

  ll n, x;
  cin >> n >> x;

  vector<ll> c(n);

  rep(i, n) {
    cin >> c[i];
  }

  ll ans = abs(x - c[0]);
  REP(i, n) {
    ans = gcd(ans, abs(c[i] - c[i - 1]));
  }

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include<algorithm>
using namespace std;
typedef long long ll;
const int maxn=999999+5;
int prime[maxn];
bool is_prime[maxn];
int sieve(int n)
{
    int p=0;
    fill(is_prime,is_prime+n+1,true);
    is_prime[0]=is_prime[1]=true;
    for(int i=2;i<=n;i++)
    {
        if(is_prime[i]){
            prime[p++]=i;
            for(int j=2*i;j<=n;j+=i) is_prime[j]=false;
        }
    }
    return p;
}

int main()
{
    int n;
    while(cin>>n)
    {
        cout<<sieve(n)<<endl;
    }
    return 0;
}

Measured memory_bytes: 2444
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
typedef long long ll;
typedef pair<int, int> P;
const int INF = 100100100;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;
struct Edge {
  ll to;
  ll cost;
};
int main() {
  int N;
  cin >> N;
  vector<long double> v(N);
  REP(i, N) cin >> v[i];
  sort(v.begin(), v.end(),greater<long double>());
  while (1 < v.size()) {
    long double a = v[v.size()-1], b = v[v.size()-2];
    v.resize(v.size() - 2);
    v.push_back((a + b) / 2);
    sort(v.begin(), v.end(), greater<long double>());
  }
  cout <<fixed<<setprecision(6)<< v[0] << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pb push_back
#define ll long long
#define md 1000000007
#define ld long double
using namespace std;

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll n, i = 0, j= 0, k = 0, l = 0, m = 0, a = 0, b = 0, sum = 0, x = 0, y = 0, z = 0, c, p = 0;
    string s;
    cin >> s;
    if(s[2] == s[3] && s[4] == s[5]){
        cout << "Yes";
    }
    else{
        cout << "No";
    }

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define sync ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define MOD  1000000007 
int powm(int base,int exp,int mod=MOD) {int ans=1;while(exp){if(exp&1) ans=(ans*base)%mod;exp>>=1,base=(base*base)%mod;}return ans;}
int32_t main()
{
	sync
	int n;
	cin>>n;
	int a[n];
	for(int i=0;i<n;i++)
		cin>>a[i];
	int maxcount=0;
	int count=0;
	for(int i=0;i<n-1;i++)
	{
		if(a[i]>=a[i+1])
		{
			count++;
			maxcount=max(count,maxcount);
		}
		else
		{
			count=0;
		}
	}
	cout<<maxcount<<endl;
}

Measured memory_bytes: 1024
#include <iostream>

using namespace std;

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

	bool compare = h >= w;
	int temp = 0;
	int i;
	for (i = 0; i < (compare ? w : h); ++i) {
		temp += compare ? h : w;

		if (temp >= n) break;
	}

	cout << ++i;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb push_back
#define mp make_pair
#define ios ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);

int main() {
	ios;
	string a,b;
	cin>>a>>b;
	cout<<(a[0]==b[0])+(a[1]==b[1])+(a[2]==b[2])<<"\n";
	return 0;
}
 

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long int
#define pragi(a,b) for(ll i = a;i<b;i++)
#define pragj(a,b) for(ll j = a;j<b;j++)
#define pragk(a,b) for(ll k = a;k>=b;k--)
#define all(v) (v.begin(),v.end())
#define eb emplace_back
#define lb lower_bound
#define ub upper_bound
#define MP make_pair
#define MT make_tuple
#define F first
#define S second
#define KAKA ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
using namespace std;
const int mod = 1e9 + 7;

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<bool> vb;
typedef long double ld;
typedef pair<int, int> pii;
//typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<vvl> vvvl;
typedef pair<ll, ll> pll;
vector<ll> h;

bool predicate(ll x,ll a,ll b)
{
    ll sum = 0;
    ll n = h.size();
    
    pragi(0,n)
    {
        ll ele = h[i];
        ll lo = 0,hi = x;
        if((x * a) < h[i]) return false;
        while(lo < hi)
        {
            ll mid = lo + (hi - lo)/2;
            ll val = (mid * a) + ((x - mid)*b);
            if(val < ele) lo = mid + 1;
            else hi = mid;
        }
      sum += lo;
    }
   // cout<<sum<<" ";
    if(sum <= x) return true;
    else return false;
}
void Compute(ll n,ll a,ll b)
{
    KAKA
    h.resize(n);    
    pragi(0,n)
    {
        cin>>h[i];
    }
    //cout<<h[0]<<"\n";
    //Binary search the answer
    ll hmax = *max_element(h.begin(),h.end());
    ll lo = 1,hi = hmax/b + 1;
   //bool f1 =  predicate(15,a,b);
   //bool f2 = predicate(16,a,b);
   //bool f3 = predicate(14,a,b);
  // cout<<f3<<" "<<f1<<" "<<f2<<"\n";
    while(lo < hi)
    {
        ll mid = lo + (hi - lo)/2;
        if(predicate(mid,a,b)) hi = mid;
        else lo = mid + 1;
    }
    cout<<lo<<"\n";
}
int main()
{
    KAKA
    ll n,a,b;
    cin>>n>>a>>b;
    Compute(n,a,b);
}

Measured memory_bytes: 3972
import java.util.Scanner;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    double a = sc.nextInt();
    double b = sc.nextInt();
    double x = sc.nextInt();
    double result;
    if (x > a * a * b / 2)
      result = Math.toDegrees(Math.atan(2 * (b - x / a / a) / a));
    else
      result = Math.toDegrees(Math.atan(b * b * a / x / 2));
    System.out.println(result);
  }
}

Measured memory_bytes: 21972
#include <stdio.h>

int main(void){
	int sum = 0, time;
	int i;
	
	for (i = 0; i < 4; i++){
		scanf("%d", &time);
		
		sum += time;
	}
	
	printf("%d\n", sum/60);
	printf("%d\n", sum%60);
	
	return 0;
}

Measured memory_bytes: 596
#include <stdio.h>
#include <math.h>
#include <string.h>

int main(){
	int i, j, x, count = 0;
	char str[100];
	while(scanf("%s", &str) != EOF){
		x = 0;
		j = strlen(str) - 1;
		i = 0;
		while(j > i){
			if(str[i] != str[j]){
				x++;
				break;
			}
			i++;
			j--;
			if(i >= j) break;
		}
		if(x == 0) count++;
	}
	printf("%d\n", count);
	return 0;
}

Measured memory_bytes: 540
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
#include <fstream>
#include<cstdio>
#include<iomanip>

#define REP(i, n) for(int i=1;i<n+1;i++)

using namespace std;

typedef long long ll;
typedef unsigned long ul;
typedef long double ld;

//const int maxN = 200000;

ll A, B, C;

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

}





Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> l_l;
typedef pair<int , int> i_i;
typedef vector<ll> vel;
typedef vector<int> vei;
typedef vector<char> vec;
typedef vector<bool> veb;
typedef vector<string> ves;
typedef vector<vector<ll>> ve_vel;
typedef vector<vector<int>> ve_vei;
typedef vector<vector<char>> ve_vec;
typedef vector<vector<bool>> ve_veb;
typedef vector<vector<string>> ve_ves;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<(int)(n);i++)
#define rep2(i,n) for(int i=2;i<(int)(n);i++)
#define repk(i,k,n) for(int i=k;i<(int)(n);i++)
#define fs first
#define sc second
#define pub push_back
#define puf push_front
#define pob pop_back
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define maxel(a) *max_element(all(a))
#define minel(a) *min_element(all(a))
#define acc accumulate
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define mod (1000000007)
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 (a>b) { a=b; return 1; } return 0; }
template<typename T> void remove(T & vector, unsigned int index){vector.erase(vector.begin() + index);}

string s;
ll dp[105000][14];

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

    cin >> s; s = "#" + s;
    dp[0][0] = 1;

    rep1(i,s.size()) {
        rep(j,13) { 
            rep(k,10) {
                if(s[i] != '?' and s[i] != ('0' + k ) ) continue;
                int a = (j * 10 + k) % 13;
                dp[i][a] += dp[i-1][j];
                dp[i][a] %= mod;
            }
        }
    }
    cout << dp[s.size() - 1][5] << endl;
    return 0;

}



Measured memory_bytes: 11372
import os
import heapq
import sys,threading
import math
import bisect
import operator
from collections import defaultdict
sys.setrecursionlimit(10**5)
from io import BytesIO, IOBase
def gcd(a,b):
    if b==0:

        return a
    else:
        return gcd(b,a%b)
def power(x, p,m):
    res = 1
    while p:
        if p & 1:
            res = (res * x) % m
        x = (x * x) % m
        p >>= 1
    return res
def inar():
    return [int(k) for k in input().split()]

def lcm(num1,num2):
    return (num1*num2)//gcd(num1,num2)

def main():
    take=[0]*3
    take[int(input())-1]=1
    take[int(input())-1]=1
    for i in range(3):
        if take[i]==0:
            print(i+1)




BUFSIZE = 8192


class FastIO(IOBase):
    newlines = 0

    def __init__(self, file):
        self._fd = file.fileno()
        self.buffer = BytesIO()
        self.writable = "x" in file.mode or "r" not in file.mode
        self.write = self.buffer.write if self.writable else None

    def read(self):
        while True:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            if not b:
                break
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines = 0
        return self.buffer.read()

    def readline(self):
        while self.newlines == 0:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            self.newlines = b.count(b"\n") + (not b)
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines -= 1
        return self.buffer.readline()

    def flush(self):
        if self.writable:
            os.write(self._fd, self.buffer.getvalue())
            self.buffer.truncate(0), self.buffer.seek(0)


class IOWrapper(IOBase):
    def __init__(self, file):
        self.buffer = FastIO(file)
        self.flush = self.buffer.flush
        self.writable = self.buffer.writable
        self.write = lambda s: self.buffer.write(s.encode("ascii"))
        self.read = lambda: self.buffer.read().decode("ascii")
        self.readline = lambda: self.buffer.readline().decode("ascii")


sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)
input = lambda: sys.stdin.readline().rstrip("\r\n")

if __name__ == "__main__":
    main()
    #threadin.Thread(target=main).start()


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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i < (int)(n); i++)
typedef long long ll;

int main() {
    int n;
    int t[110000], x[110000], y[110000];
    cin >> n;
    t[0] =x[0] = y[0] = 0;
    rep(i,n) cin >> t[i+1] >> x[1+i] >> y[1+i];

    bool can = true;
    rep(i,n){
        int dt = t[i+1] - t[i];
        int dist = abs(x[i+1] - x[i]) + abs(y[i+1] - y[i]);
        if(dist > dt) can = false;
        if(dist % 2 != dt % 2) can = false;
    }
    if(can) cout << "Yes" << endl;
    else cout << "No" << endl;
}

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

typedef long long LL;

const int MAXN = 1e5 + 10;

int n, m, sum;
int head[MAXN];
struct Edge { int link, to; } e[MAXN << 1];
inline void add(int u, int v) { e[++sum] = (Edge) { v, head[u] }, head[u] = sum; }

namespace Tree {
	int del[MAXN];
	void dfs(int u, int fa, int D) {
		del[u] = D % 2 == 1 ? 1 : -1;
		for (int i = head[u]; i; i = e[i].to) {
			int v = e[i].link;
			if (v == fa) continue;
			dfs(v, u, D + 1), del[u] += del[v];
		}
	}
	inline void gao() {
		dfs(1, 0, 1);
		LL ans = 0;
		for (int i = 1; i <= n; ++i) ans += abs(del[i]);
		if (del[1]) puts("-1");
		else printf("%lld\n", ans);
	}
};
namespace GayRingTree {
	int S, T, cnt, len, tot;
	bool flg;
	int dep[MAXN], del[MAXN], f[MAXN], b[MAXN], tmp[MAXN];
	bool vis[MAXN];
	void dfs1(int u, int fa) {
		vis[u] = true, dep[u] = dep[fa] + 1, f[u] = fa;
		del[u] = dep[u] % 2 == 1 ? 1 : -1;
		for (int i = head[u]; i; i = e[i].to) {
			int v = e[i].link;
			if (vis[v] && v != fa) S = u, T = v;
			if (vis[v] || v == fa) continue;
			dfs1(v, u), del[u] += del[v];
		}
	}
	void dfs2(int u, int fa) {
		vis[u] = true, del[u] = dep[fa] + 1;
		del[u] = dep[u] % 2 == 1 ? 1 : -1;
		for (int i = head[u]; i; i = e[i].to) {
			int v = e[i].link;
			if (vis[v] || v == fa) continue;
			dfs2(v, u), del[u] += del[v];
		}
	}
	inline void gao() {
		dfs1(1, 0), flg = (dep[S] + dep[T] + 1) % 2;
		int L = S, R = T, lca; len = 1;
		while (L != R) {
			if (dep[L] > dep[R]) L = f[L];
			else R = f[R];
			++len;
		}
		lca = L;
		if (flg) {
			if (del[1] & 1) return puts("-1"), void();
			int hhz = del[1] >> 1;
			for (int i = S; i; i = f[i]) del[i] -= hhz;
			for (int i = T; i; i = f[i]) del[i] -= hhz;
			LL ans = abs(hhz);
			for (int i = 1; i <= n; ++i) ans += abs(del[i]);
			printf("%lld\n", ans);
		} else {
			// assert(0);
			if (del[1]) return puts("-1"), void();
			tmp[++tot] = lca;
			for (int i = S; i != lca; i = f[i]) tmp[++tot] = i;
			for (int i = T; i != lca; i = f[i]) tmp[++tot] = i;
			memset(vis, false, sizeof(vis));
			dfs2(S, 0);
			for (int i = 1; i <= tot; ++i) b[++cnt] = del[tmp[i]];
			std::sort(b + 1, b + cnt + 1);
			int QAQ = b[(cnt + 1) / 2];
			for (int i = 1; i <= tot; ++i) del[tmp[i]] -= QAQ;
			LL ans = 0;
			for (int i = 1; i <= n; ++i) ans += abs(del[i]);
			printf("%lld\n", ans);
		}
	}
};

int main() {
	scanf("%d%d", &n, &m);
	for (int i = 1, u, v; i <= m; ++i) scanf("%d%d", &u, &v), add(u, v), add(v, u);
	if (n % 2 == 1) return puts("-1"), 0;
	if (m < n) Tree::gao();
	else GayRingTree::gao();
	return 0;
}

Measured memory_bytes: 14124
#include <iostream>
#include <vector>
#include <cmath>
using namespace std;
int main(void){
    // Your code here!
    vector<char> a{'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z'};
    long N;
    cin >> N;
    if(N<=26){ //1
        cout << a.at(N-1) << endl;
    }else if(N<=((pow(26,3)-26)/25)){ //2
        cout << a.at(int((N-26-1)/26));
        cout << a.at((N-26-1)%26) << endl;
    }else if(N<=((pow(26,4)-26)/25)){ //3
        long cal = N-((pow(26,3)-26)/25)-1;
        for(int i=0;i<2;i++){
            cout << a.at(int(cal/pow(26,2-i)));
            cal = cal%long(pow(26,2-i));
        }
        cout << a.at(cal%26) << endl;
    }else if(N<=((pow(26,5)-26)/25)){ //4
        long cal = N-((pow(26,4)-26)/25)-1;
        for(int i=0;i<3;i++){
            cout << a.at(int(cal/pow(26,3-i)));
            cal = cal%long(pow(26,3-i));
        }
        cout << a.at(cal%26) << endl;
    }else if(N<=((pow(26,6)-26)/25)){ //5
        long cal = N-((pow(26,5)-26)/25)-1;
        for(int i=0;i<4;i++){
            cout << a.at(int(cal/pow(26,4-i)));
            cal = cal%long(pow(26,4-i));
        }
        cout << a.at(cal%26) << endl;
    }else if(N<=((pow(26,7)-26)/25)){ //6
        long cal = N-((pow(26,6)-26)/25)-1;
        for(int i=0;i<5;i++){
            cout << a.at(int(cal/pow(26,5-i)));
            cal = cal%long(pow(26,5-i));
        }
        cout << a.at(cal%26) << endl;
    }else if(N<=((pow(26,8)-26)/25)){ //7
        long cal = N-((pow(26,7)-26)/25)-1;
        for(int i=0;i<6;i++){
            cout << a.at(int(cal/pow(26,6-i)));
            cal = cal%long(pow(26,6-i));
        }
        cout << a.at(cal%26) << endl;
    }else if(N<=((pow(26,9)-26)/25)){ //8
        long cal = N-((pow(26,8)-26)/25)-1;
        for(int i=0;i<7;i++){
            cout << a.at(int(cal/pow(26,7-i)));
            cal = cal%long(pow(26,7-i));
        }
        cout << a.at(cal%26) << endl;
    }else if(N<=((pow(26,10)-26)/25)){ //9
        long cal = N-((pow(26,9)-26)/25)-1;
        for(int i=0;i<8;i++){
            cout << a.at(int(cal/pow(26,8-i)));
            cal = cal%long(pow(26,8-i));
        }
        cout << a.at(cal%26) << endl;
    }else if(N<=((pow(26,11)-26)/25)){ //10
        long cal = N-((pow(26,10)-26)/25)-1;
        for(int i=0;i<9;i++){
            cout << a.at(int(cal/pow(26,9-i)));
            cal = cal%long(pow(26,9-i));
        }
        cout << a.at(cal%26) << endl;
    }else{ //11
        long cal = N-((pow(26,11)-26)/25)-1;
        for(int i=0;i<10;i++){
            cout << a.at(int(cal/pow(26,10-i)));
            cal = cal%long(pow(26,10-i));
        }
        cout << a.at(cal%26) << endl;
    }

   return 0;
}

Measured memory_bytes: 4108
#include<bits/stdc++.h>
#include<string.h>
 
typedef long long int ll;
 
using namespace std;
 
void SieveOfEratosthenes(int n,vector <int> &primes) 
{ 
    // Create a boolean array "prime[0..n]" and initialize 
    // all entries it as true. A value in prime[i] will 
    // finally be false if i is Not a prime, else true. 
    bool prime[n+1]; 
    memset(prime, true, sizeof(prime)); 
  
    for (int p=2; p*p<=n; p++) 
    { 
        // If prime[p] is not changed, then it is a prime 
        if (prime[p] == true) 
        { 
            // Update all multiples of p greater than or  
            // equal to the square of it 
            // numbers which are multiple of p and are 
            // less than p^2 are already been marked.  
            for (int i=p*p; i<=n; i += p) 
                prime[i] = false; 
        } 
    } 
  
    // Print all prime numbers 
    for (int p=2; p<=n; p++) 
       if (prime[p]) 
          primes.push_back(p);
} 
 
ll max(ll a,ll b)
{
    if(a>b)
        return a;
    return b;
}
 
ll power(ll x, ll y,ll mod) 
{ 
    ll temp; 
    if( y == 0) 
        return 1; 
    temp = power(x, y/2,mod); 
    if (y%2 == 0) 
        return (temp*temp)%mod; 
    else
        return (((x*temp)%mod)*temp)%mod; 
} 
 
 

int main()
{
    ll n,a,b;
    cin>>n>>a>>b;
    ll x=n/(a+b);
    x*=a;
    x+=min(a,n%(a+b));
    cout<<x<<endl;

    return 0;   
}
 
 


Measured memory_bytes: 256
#include <stdio.h>

int main(void) {
    int a, b;
    scanf("%d %d", &a, &b);
    if(a < b) {
        printf("a < b\n");
    } else if(a > b) {
        printf("a > b\n");
    } else {
        printf("a == b\n");
    }
    
    return 0;
}

Measured memory_bytes: 580
#include <bits/stdc++.h>
using namespace std;
#define ALL(x) (x).begin(),(x).end()
#define COUT(x) cout<<(x)<<"\n"
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define REP(i, n) for(int i=0;i<n;i++)
#define YES(x) cout<<(x?"YES":"NO")<<"\n"
#define Yes(x) cout<<(x?"Yes":"No")<<"\n"
#define dump(x) cout<<#x<<" = "<<(x)<<"\n"
#define endl "\n"
using G = vector<vector<int>>;
using M = map<int,int>;
using P = pair<int,int>;
using PQ = priority_queue<int>;
using PQG = priority_queue<int,vector<int>,greater<int>>;
using V = vector<int>;
using ll = long long;
using edge = struct { int to; int cost; };
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; }
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

int main() {
  IOS;
  int n; cin >> n;
  string c;
  cin >> c;
  string r = c;
  sort(ALL(r));
  int ans = 0;
  REP(i,n) {
    if (c[i] == 'W' && r[i] == 'R') {
      ans++;
    }
  }
  COUT(ans);

  return 0;
}

Measured memory_bytes: 3868