akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <iostream>
#include <string>
#include <cstdlib>
#include <vector>
#include <algorithm>
#include <functional>
#include <iomanip>
using namespace std;

int main()
{
	int a, b;
	cin >> a >> b;
	if (a < b) cout << "a < b" << endl;
	else if (a > b) cout << "a > b" << endl;
	else cout << "a == b" << endl;
}


Measured memory_bytes: 3084
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=(a);i<=(b);i++)
#define per(i,a,b) for(int i=(a);i>=(b);i--)
#define REP(i,n) for(int i=0;i<(n);i++)
#define qwq(x) cerr<<" #"<<#x<<" = "<<x<<endl;
#define fi first
#define se second
#define pb push_back
#define mp make_pair
using namespace std;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef long long ll;
 
template<class T> inline void read(T &x){
	int f=0;x=0;char ch=getchar();
	for(;!isdigit(ch);ch=getchar())f|=(ch=='-');
	for(;isdigit(ch);ch=getchar())x=x*10+ch-'0';
	if(f)x=-x;
}

int a,b;

int main(){
	read(a),read(b);
	if(a<=0&&b>=0)puts("Zero");
	else if(0<a)puts("Positive");
	else if((b-a+1)%2==0)puts("Positive");
	else puts("Negative");
	return 0;
}

Measured memory_bytes: 256
import java.util.*;

class Main {
	public static void main (String[] args){
        Scanner sc = new Scanner(System.in);
        
        int h,w;
        while(true){
            h = sc.nextInt();
            w = sc.nextInt();

            if(h == 0 && w == 0)    break;
            for(int i = 0;i < h;i++){
                for(int j = 0;j < w;j++){
                    System.out.print("#");
                }
                System.out.print("\n");
            }
            System.out.print("\n");
        }
    }
}


Measured memory_bytes: 35232
#include<iostream>
#include<iomanip>
#include<cmath>
using namespace std;

int main (void){
    double x1,y1,x2,y2;
    cin>>x1>>y1;
    cin>>x2>>y2;
    double d =pow(x1-x2,2)+pow(y1-y2,2);
    double x=sqrt(d);
    cout<<fixed<< setprecision(8)<<x;
    cout<<endl;
}


Measured memory_bytes: 3288
def solve():
  N, K, C = map(int, input().split())
  S = input()
  l_r,r_l = [0]*N,[0]*N
  i,cnt = 0,0
  while i<N and cnt<K:
    if S[i]=='o':
      l_r[i] = 1
      cnt += 1
      i += C
    i += 1
  j,cnt = N-1,0
  while j>=0 and cnt<K:
    if S[j]=='o':
      r_l[j] = 1
      cnt += 1
      j -= C
    j -= 1
  ans = []
  c_lr = 0
  c_rl = 0
  for i in range(1,N+1):
    if l_r[i-1]:
      c_lr += 1
    if r_l[i-1]:
      c_rl += 1
    if l_r[i-1]*r_l[i-1]==1 and c_lr==c_rl:
      ans.append(i)
  return ans
print(*solve(),sep='\n')

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

//tof
//////////////////////////////////////////////////////////////////////////
#pragma GCC optimize("O3,Ofast,no-stack-protector,unroll-loops,fast-math,-ffp-contract=off")
inline void fastscan(int &number) {
    register int c;
    number = 0;
    c = getchar();
    for (; (c>47 && c<58); c=getchar())
        number = number *10 + c - 48;
}
//////////////////////////////////////////////////////////////////////////

#define s second
#define f first

const int maxn = 60;

int n, m;
long long ans;
int sz;
int fat[maxn];
int h[maxn];
int up[maxn];
bool mark[maxn];
vector<int> adj[maxn];
vector<pair<int, int> > quer;
int S;
int cnt[maxn];

inline void in();
inline void solve();
inline void out();
inline void add(int, int, int);
void dfs(int);

int main(){
    in();
    solve();
    out();
}

inline void in(){
    fastscan(n);
    for(int i = 1; i < n; i++){
        int u, v;
        fastscan(u);
        fastscan(v);
        u--;
        v--;
        adj[u].push_back(v);
        adj[v].push_back(u);
    }
    fastscan(m);
    for(int i = 0; i < m; i++){
        int u, v;
        fastscan(u);
        fastscan(v);
        u--;
        v--;
        quer.push_back(pair<int, int>(u, v));
    }
}

inline void solve(){
    dfs(0);
    for(int i = 0; i < (1 << quer.size()); i++){
        long long wow = 1;
        for(int j = 0; j < quer.size(); j++){
            if((1 << j) & i){
                wow *= -1;
                add(quer[j].f, quer[j].s, i + 1);
            }
        }
        ans += wow *(1ll << (n - S - 1));
        S = 0;
    }
}

void dfs(int u){
    mark[u] = 1;
    for(int i = 0; i < adj[u].size(); i++){
        int v = adj[u][i];
        if(!mark[v]){
            h[v] = h[u] + 1;
            fat[v] = u;
            up[v] = sz++;
            dfs(v);
        }
    }
}

inline void add(int u, int v, int tof){
    if(h[u] > h[v])
        swap(u, v);
    while(h[v] > h[u]){
        if(cnt[up[v]] != tof){
            S++;
            cnt[up[v]] = tof;
        }
        v = fat[v];
    }
    while(u != v){
        if(cnt[up[u]] != tof){
            S++;
            cnt[up[u]] = tof;
        }
        if(cnt[up[v]] != tof){
            S++;
            cnt[up[v]] = tof;
        }
        u = fat[u];
        v = fat[v];
    }
}

inline void out(){
    printf("%lld", ans);
}


Measured memory_bytes: 384
#include <cstdio>
char a[55][55], b[55][55];
inline int check(int x, int j) {
	int res = 0;
	if(a[x-1][j-1]=='#') res ++;
	if(a[x-1][j]=='#') res ++;
	if(a[x-1][j+1]=='#') res ++;
	if(a[x][j+1]=='#') res ++;
	if(a[x+1][j+1]=='#') res ++;
	if(a[x+1][j]=='#') res ++;
	if(a[x+1][j-1]=='#') res ++;
	if(a[x][j-1]=='#') res ++;
	return res;
}
int main() {
	int r, c;
	scanf("%d %d", &r, &c);
	for(int i = 1; i <= r; i++)
		scanf("%s", a[i]+1);
	for(int i = 1; i <= r; i++) 
		for(int j = 1; j <= c; j++) 
			if(a[i][j]=='.') b[i][j] = check(i, j) + 48;
			else b[i][j] = a[i][j];
	for(int i = 1; i <= r; i++) {
		for(int j = 1; j <= c; j++) 
			printf("%c", b[i][j]);
		puts("");
	}
	return 0;
}
 

Measured memory_bytes: 128
#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;
use std::io::{Write, BufWriter};
// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, [ $t:tt ]) => {{
        let len = read_value!($next, usize);
        (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    }};

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

#[allow(unused)]
macro_rules! debug {
    ($($format:tt)*) => (write!(std::io::stderr(), $($format)*).unwrap());
}
#[allow(unused)]
macro_rules! debugln {
    ($($format:tt)*) => (writeln!(std::io::stderr(), $($format)*).unwrap());
}

fn solve() {
    let out = std::io::stdout();
    let mut out = BufWriter::new(out.lock());
    macro_rules! puts {
        ($($format:tt)*) => (write!(out,$($format)*).unwrap());
    }
    input!(n: f64);
    puts!("{}\n", (n / 2.0).ceil() / n);
}

fn main() {
    // In order to avoid potential stack overflow, spawn a new thread.
    let stack_size = 104_857_600; // 100 MB
    let thd = std::thread::Builder::new().stack_size(stack_size);
    thd.spawn(|| solve()).unwrap().join().unwrap();
}


Measured memory_bytes: 8572
#include <bits/stdc++.h>
#define LOOP(n) for (int _i = 0; _i < (n); _i++)
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define FOR(i, r, n) for (int i = (r); i < (n); ++i)
#define ALL(obj) begin(obj), end(obj)
using namespace std;
using ll = long long;
using ull = unsigned long long;

const int INF = 2100100100;
const int MOD = 1e9 + 7;

// 多次元 vector 生成
template <class T>
vector<T> make_vec(size_t a) {
    return vector<T>(a);
}
template <class T, class... Ts>
auto make_vec(size_t a, Ts... ts) {
    return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}
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;
}

int main() {
    // cin.tie(0);
    // ios::sync_with_stdio(false);
    int N;
    cin >> N;
    vector<long long> a(N);
    for (int i = 0; i < N; i++) cin >> a.at(i);

    multiset<int> mset;
    REP(i, N) {
        auto it = mset.lower_bound(a[i]);
        if (it != mset.begin()) {
            it--;
            mset.erase(it);
        }
        mset.insert(a[i]);
    }
    cout << mset.size() << endl;

    return 0;
}


Measured memory_bytes: 5760
N=int(input())
A=list(map(int,input().split()))
x=1000
y=0
for i in range(N):
    if i<N-1 and A[i]<A[i+1]:
        x,y=x-x//A[i]*A[i],y+x//A[i]
    elif y>0:
        x+=y*A[i]
        y=0
print(x)

Measured memory_bytes: 9180
#!/usr/bin/env python3
def main():
    K, N = map(int, input().split())
    A = [int(x) for x in input().split()]

    max_length = A[0] + K - A[-1]
    for i in range(1, len(A)):
        max_length = max(max_length, A[i] - A[i - 1])
    print(K - max_length)


if __name__ == '__main__':
    main()


Measured memory_bytes: 31620
#include<iostream>
#include<cstdio>
#include<stdio.h>
#include<string>
#include<sstream>

using namespace std;

int main(){
	string a, b, c;
	cin >> a >> b >> c;
	
	if(a[a.size()-1]==b[0] && b[b.size()-1]==c[0]){
		cout << "YES" << endl;
	}
	else{
		cout << "NO" << endl;
	}
	return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define REPR(i, n) for(int i = (int)(n); i >= 0; i--)
#define FOR(i, s, n) for (int i = (s); i < (int)(n); i++)
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
int MOD = 1e9 + 7;

ll N,M,K,H,W;

bool prime(ll N){
	for(ll p = 2; p <= sqrt(N); ++p){
		ll s = N%p;
      	ll r = N/p;
		if(s == 0) return false;
	}
	return true;
}

int main(){
	cin >> N;
	bool b = false;
	for(ll i = N; i < N*N; ++i){
    	if(prime(i)){ cout << i ; return 0;}
    }
	return 0;	
}




Measured memory_bytes: 256
#include<stdio.h>
#include<bits/stdc++.h>
using namespace std;
int main()
{
	string a;
	cin>>a;
	int i=0,j=(int)a.size()-1;
	int ans=0;
	int lt=0;
	while(i<j)
	{
		if(a[i]!=a[j])
		{
			if(a[i]=='x')
				ans++,i++;
			else if(a[j]=='x')
				ans++,j--;
			else
			{
				lt=1;
				break;
			}
		}
		else
			i++,j--;
	}
	if(!lt)
		printf("%d\n",ans);
	else
		printf("-1\n");
	return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <map>
#include <queue>
#include <functional>
#include <vector>
#include <stack>
#include <set>
using namespace std;
typedef unsigned long long ll;
const int maxn=3e5+50;
const int inf=0x3f3f3f3f;
const int MOD=1e9+7;
const int HASH=131;

int h[maxn];
int w[maxn];
map<pair<int,int>,int> mp;
struct node
{
    int num,id;
    friend bool operator <(node a,node b)
    {
        return a.num<b.num;
    }
};

node x[maxn],y[maxn];
int main()
{
    int n,m;
    cin>>n>>m;
    int t;
    cin>>t;
    for(int i=1;i<=t;i++)
    {
        int a,b;
        cin>>a>>b;
        h[a]++;
        w[b]++;
        mp[make_pair(a,b)]=1;
    }
    for(int i=1;i<=n;i++)
    {
        y[i].num=h[i];
        y[i].id=i;
    }
    for(int i=1;i<=m;i++)
    {
        x[i].num=w[i];
        x[i].id=i;
    }
    sort(y+1,y+1+n);
    sort(x+1,x+1+m);
    int max_y=y[n].num;
    int max_x=x[m].num;
    int sign=1;
    for(int i=n;i>=1;i--)
    {
        if(y[i].num!=max_y) break;
        for(int j=m;j>=1;j--)
        {
            if(x[j].num!=max_x) break;
            if(mp[make_pair(y[i].id,x[j].id)]==0) {sign=0;break;}
        }
        if(sign==0) break;
    }
    if(sign==0) printf("%d\n",max_y+max_x);
    else printf("%d\n",max_y+max_x-1);
    return 0;
}


Measured memory_bytes: 29460
#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <iomanip>
#include <vector>
#include <string.h>
#include <math.h>
#include <algorithm>
#include <map>
#include <queue>
#define rep(i,n) for (int i=0;i<(n);i++)

using namespace std;

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

	cout << ans << endl;

	return 0;
}

//BBBBBBBBBBBBBBBBB
//int main() {
//	int a, b;
//	cin >> a >> b;
//	if (a > b) {
//		for (int i = 0;i < a;i++) {
//			printf("%d", b);
//		}
//	}
//	else {
//		for (int i = 0;i < b;i++) {
//			printf("%d", a);
//		}
//	}
//
//	return 0;
//}

//AAAAAAAAAAAAAAAAA
//int main() {
//	int n, m;
//	cin >> n >> m;
//
//	if (n == m) {
//		cout << "Yes" << endl;
//	}
//	else {
//		cout << "No" << endl;
//	}
//	
//	return 0;
//}

Measured memory_bytes: 4040
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int a[100010],l[100010],r[100010];
int main(){
    ios_base::sync_with_stdio(false);
    int n;
    string s,t;
    cin>>n>>s>>t;
    for(int i=0;i<n;i++)
        cout<<s[i]<<t[i];


}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
	long long n;
	cin>>n;
	long long a[6];
	for(int i=1;i<=5;i++)cin>>a[i];
	long long t=0x3f3f3f3f3f3f3f3f;
	for(int i=1;i<=5;i++){
		t=min(t,a[i]);
	}
	cout<<n/t+((n%t==0)?0:1)+4<<endl;
}

Measured memory_bytes: 256
/*
 * Author:  heyuhhh
 * Created Time:  2020/5/6 20:52:09
 */
#include <iostream>
#include <algorithm>
#include <cstring>
#include <cstdio>
#include <vector>
#include <cmath>
#include <set>
#include <map>
#include <queue>
#include <iomanip>
#include <assert.h>
#define MP make_pair
#define fi first
#define se second
#define pb push_back
#define sz(x) (int)(x).size()
#define all(x) (x).begin(), (x).end()
#define INF 0x3f3f3f3f
#define Local
#ifdef Local
  #define dbg(args...) do { cout << #args << " -> "; err(args); } while (0)
  void err() { std::cout << std::endl; }
  template<typename T, typename...Args>
  void err(T a, Args...args) { std::cout << a << ' '; err(args...); }
  template <template<typename...> class T, typename t, typename... A> 
  void err(const T <t> &arg, const A&... args) {
  for (auto &v : arg) std::cout << v << ' '; err(args...); }
#else
  #define dbg(...)
#endif
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
//head
const int N = 200000 + 5;

int cnt[2019];
char s[N];

void run() {
    cin >> (s + 1);
    int n = strlen(s + 1);
    int x = 0, p = 1;
    cnt[0] = 1;
    ll ans = 0;
    for (int i = n; i >= 1; i--) {
        x = (x + (s[i] - '0') * p) % 2019;
        p = p * 10 % 2019;
        ans += cnt[x];
        ++cnt[x];
    }
    cout << ans << '\n';
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
    cout << fixed << setprecision(20);
    run();
    return 0;
}

Measured memory_bytes: 3748
from operator import itemgetter
N=int(input())
R=[]
for i in range(N):
    s,p=input().split()
    p=int(p)
    R.append([s,p])

sorted_R=sorted(R,key = itemgetter(1),reverse=True)
sorted_R=sorted(sorted_R, key = itemgetter(0))

for i in range(len(R)):
    for j in range(len(R)):
        if R[j]==sorted_R[i]:
            print(j+1)

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

int main() {

  int N, K;
  cin >> N >> K;

  vector <int> X(N);

  for (int i = 0; i < N; i++) {
   cin >> X.at(i);
  }

  vector <int> s(100);

   for (int i = 0; i < N; i++) {

    s.at(i) = (min ( (X.at(i)-0), (K-X.at(i)) ))*2;

   }


  int ans = 0;
   for (int i = 0; i < N; i++) {
     ans += s.at(i);

   }
    cout << ans << endl;


return 0;

}

Measured memory_bytes: 256
s1 = input()
s2 = input()


def levenshtein(s1, s2):
    s1_len = len(s1)
    prev = range(s1_len+1)
    current = None

    for i, c1 in enumerate(s2, start=1):
        current = [i] * (s1_len+1)
        for j, c2 in enumerate(s1, start=1):
            n1 = prev[j-1] if c1 == c2 else prev[j-1]+1
            n2 = prev[j]+1
            n3 = current[j-1]+1
            current[j] = min(n1, n2, n3)
        prev = current

    return current[-1]

print(levenshtein(s1, s2))

Measured memory_bytes: 7548
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <chrono>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <string>
#include <tuple>
#include <unordered_map>
#include <vector>
using namespace std;

#define FOR(i,m,n) for(int i=(m);i<(n);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()

const int INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3fLL;
/*----------------------------------------*/
int main() {
  cin.tie(0); ios::sync_with_stdio(false);
  // freopen("input.txt", "r", stdin);

  int n, m, q; cin >> n >> m >> q;
  vector<vector<char> > s(n, vector<char>(m)); REP(i, n) REP(j, m) cin >> s[i][j];
  vector<vector<int> > blue(n, vector<int>(m, 0)), edge_yoko(n, vector<int>(m, 0)), edge_tate(n, vector<int>(m, 0));
  REP(i, n) REP(j, m) if (s[i][j] == '1') blue[i][j] = 1;
  REP(i, n) REP(j, m-1) blue[i][j+1] += blue[i][j];
  REP(j, m) REP(i, n-1) blue[i+1][j] += blue[i][j];
  REP(i, n) REP(j, m) if (s[i][j] == '1') {
    if (i < n-1 && s[i+1][j] == '1') edge_tate[i+1][j] += 1;
    if (j < m-1 && s[i][j+1] == '1') edge_yoko[i][j+1] += 1;
  }
  REP(i, n) REP(j, m-1) {
    edge_yoko[i][j+1] += edge_yoko[i][j];
    edge_tate[i][j+1] += edge_tate[i][j];
  }
  REP(j, m) REP(i, n-1) {
    edge_yoko[i+1][j] += edge_yoko[i][j];
    edge_tate[i+1][j] += edge_tate[i][j];
  }
  REP(i, q) {
    int x1, y1, x2, y2; cin >> x1 >> y1 >> x2 >> y2;
    --x1; --y1; --x2; --y2;
    int ao = blue[x2][y2];
    if (x1 > 0) ao -= blue[x1-1][y2];
    if (y1 > 0) ao -= blue[x2][y1-1];
    if (x1 > 0 && y1 > 0) ao += blue[x1-1][y1-1];
    int eda = edge_yoko[x2][y2] + edge_tate[x2][y2];
    ++y1;
    eda -= edge_yoko[x2][y1-1];
    if (x1 > 0) eda -= edge_yoko[x1-1][y2];
    if (x1 > 0 && y1 > 0) eda += edge_yoko[x1-1][y1-1];
    --y1;
    ++x1;
    eda -= edge_tate[x1-1][y2];
    if (y1 > 0) eda -= edge_tate[x2][y1-1];
    if (x1 > 0 && y1 > 0) eda += edge_tate[x1-1][y1-1];
    cout << ao - eda << '\n';
  }
  return 0;
}


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

void boost(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
}

int main(){
    boost();
    ll ans=0;
    string s,t;
    cin >> s >> t;
    ll i;
    for(i=0;i<s.length();i++)
    if(s[i]!=t[i])
    ans++;
    
    cout << ans << endl;
}

Measured memory_bytes: 3804
#include <cstdio>

#define MOD 1000000007
#define MAX_N 100001

/* -----------------------------------------------------------------------------
	大域データ
----------------------------------------------------------------------------- */

char S[MAX_N];	// 文字列(1≦N≦10^5)
int  cnt[13];

void update(char c) {

	int cnt0[13];

	for(int i = 0; i < 13; i++) {
		 cnt0[i] = cnt[i]; cnt[i] = 0;
	}

	if(c != '?') {
		int n = c - '0';
		for(int i = 0; i < 13; i++) {
			int r = (i * 10 + n) % 13;
			cnt[r] = cnt0[i];
		}
	} else {
		for(int n = 0; n <= 9; n++) {
			for(int i = 0; i < 13; i++) {
				int r = (i * 10 + n) % 13;
					cnt[r] = (cnt[r] + cnt0[i]) % MOD;
			}
		}
	}
	return;
}

int main () {

	// 整数の数の読込み
	scanf("%s", S);

	// 初期化
	cnt[0] = 1;

	// 文字列スキャン
	int i = 0;
	while(S[i] != '\0') update(S[i++]);

	printf("%d\n", cnt[5]);

	return 0;
}

Measured memory_bytes: 256
from collections import deque
 
N, M = map(int, input().split())
 
graph = [[] for i in range(N)]
to_this = [0] * N
for i in range(M):
  x, y = map(int, input().split())
  graph[x-1].append(y-1)
  to_this[y-1] += 1
 
 
depth = [0] * N
d = deque([i for i in range(N) if not to_this[i]])
while d:
  l = len(d)
  for i in range(l):
    node = d.popleft()
    children = graph[node]
    for child in children:
      to_this[child] -= 1
      if not to_this[child]:
        d.append(child)
      depth[child] = depth[node] + 1
 
print(max(depth))  

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

namespace AtCoderProblem___Station_and_Bus
{
    class Program
    {
        static void Main(string[] args)
        {            
            string S = Console.ReadLine();
            if(S == "AAA" || S == "BBB")
            {
                Console.WriteLine("No");
            }
            else
            {
                Console.WriteLine("Yes");
            }
        }
    }
}


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

int main(){
  int n,k;
  cin >> n >> k;
  int kids[n+1];
    for(int i=1; i<=n; i++){
      kids[i] = i;
    }
  int d;  
  for(int i=0; i<k; i++){
    cin >> d;
  int A;
  for(int j=0; j<d; j++){
    cin >> A;
    for(int h=1; h<=n; h++){
      if(A == h){
	kids[h] = 0;
	break;
      }
    }
  }
  }
  int ans=0;
  for(int i=1; i<=n; i++){
    if(kids[i] != 0)ans++;
  }
  cout << ans << endl;
}


Measured memory_bytes: 3596
#include<bits/stdc++.h>
using namespace std;
#ifdef LOCAL_DEBUG
  #include "LOCAL_DEBUG.hpp"
#endif
#define int long long

signed main(){

  string s; cin >> s;

  int n = s.size();
  static int dp[100064][64];
  for(int i = 0; i < n; i++){
    dp[i][1] = i + (s[i] == 'R' ? 1 : -1);
  }
  for(int k = 1; k < 60; k++){
    for(int j = 0; j < n; j++){
      dp[j][k+1] = dp[dp[j][k]][k];
    }
  }

  vector<int> ans(n, 0);
  for(int i = 0; i < n; i++){
    if(0 <= dp[i][60] && dp[i][60] < n){
      ans[dp[i][60]]++;
    }
  }
  for(int i = 0; i < n; i++){
    cout << ans[i] << " ";
  }
  cout << endl;

  return 0;
}


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

using namespace std;

class Solution {
public:
	void solve() {
		string s;
		cin >> s;
		for(int i=0; i < 3; i++){
			for(int j=0; j < 3; j++){
				if(s[i] != s[j]){
					cout << "Yes\n";
					return;
				}
			}
		}
		cout << "No\n";
		return;
	};
};

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

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<iomanip>
#include<set>
#include<queue>

using namespace std;

int main()
{
	int k,a,b;
	cin >> k >> a >> b;
	bool flg=false;
	for(int i=0;i<=1000;i++)
	{
		int tmp=i*k;
		if(a<=tmp and tmp<=b)flg=true;
	}
	cout << (flg ? "OK":"NG") << endl;



}

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

#if MYDEBUG
#include "lib/cp_debug.hpp"
#else
#define DBG(...) ;
#endif
#if __cplusplus <= 201402L
template <typename T>
T gcd(T a, T b) { return ((a % b == 0) ? b : gcd(b, a % b)); }
template <typename T>
T lcm(T a, T b) { return a / gcd(a, b) * b; }
#endif
using LL = long long;
constexpr LL LINF = 334ll << 53;
constexpr int INF = 15 << 26;
constexpr LL MOD = 1E9 + 7;

namespace Problem {
using namespace std;

class Solver2 {
 public:
  int k, x;
  Solver2(LL k, LL x) : k(k), x(x){};

  void solve() {
    for (int i = x - k + 1; i <= x + k - 1; ++i) {
      cout << i << ' ';
    }
    cout << endl;
  }
};
}  // namespace Problem

int main() {
  std::cin.tie(0);
  std::ios_base::sync_with_stdio(false);
  // std::cout << std::fixed << std::setprecision(12);
  long long n = 0, m;
  std::cin >> n >> m;

  Problem::Solver2 sol(n, m);
  sol.solve();
  return 0;
}


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

#define rep(i, a, b) for(int i = (a); i < (b); ++i)
#define per(i, a, b) for(int i = (b)-1; i >= (a); --i)
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fst first
#define snd second

template<class T> bool ckmin(T& a, const T& b) { return b < a ? a = b, 1 : 0; }
template<class T> bool ckmax(T& a, const T& b) { return a < b ? a = b, 1 : 0; }

typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<pii> vii;

int main() {
  cin.tie(0)->sync_with_stdio(0);
  cin.exceptions(cin.failbit);

  int n;
  cin >> n;
  n %= 10;
  switch (n) {
    case 3:
      cout << "bon\n";
      break;
    case 0:
    case 1:
    case 6:
    case 8:
      cout << "pon\n";
      break;
    default:
      cout << "hon\n";
      break;
  }
}


Measured memory_bytes: 3652
#include<iostream>
#include<string>
#include<cstring>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;
#define PI 3.141592653589793

vector<int> V[101010];
int dp[101010];

int rec(int x){
  if(dp[x]!=-1) return dp[x];
  dp[x] = 0;
  for(int i : V[x]){
    dp[x] = max(dp[x], rec(i)+1);
  }
  return dp[x];
}     

int main(){
  int N, M;
  cin >> N >> M;
  rep(i, M){
    int a, b;
    cin >> a >> b;
    a--; b--;
    V[a].push_back(b);
  }
  int ans = 0;
  rep(i, N){
    dp[i] = -1;
  }
  rep(i, N){
    ans = max(ans, rec(i));
  }
  cout << ans << endl;
}

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

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout.precision(12);
    cout.setf(ios_base::fixed, ios_base::floatfield);
    
    int n, t[100], v[101], st[101];
    cin >> n;
    for(int i=0;i<n;i++) cin >> t[i];
    for(int i=0;i<n;i++) cin >> v[i];
    v[n] = 0;

    st[0] = 0;
    for(int i=1;i<=n;i++) st[i] = st[i-1] + t[i-1];

    int vel[40001];
    int pos = 0;
    vel[0] = 0;
    for(int i=1;i<=st[n]*2;i++){
        vel[i] = min(vel[i-1]+1, v[pos]*2);
        for(int j=pos+1;j<=n;j++) vel[i] = min(vel[i], v[j]*2 + 2*st[j]-i);
        if(i == st[pos+1]*2) pos++;
    }

    double ans = 0;
    for(int i=1;i<=st[n]*2;i++){
        if(vel[i-1] != vel[i]) ans += 1;
        ans += min(vel[i-1], vel[i]) * 2;        
    }
    cout << ans/8 << endl;
    return 0;
}

Measured memory_bytes: 384
#include<iostream>
#include<string.h>
#include<ctype.h>
#include<cstring>
#include<iomanip>
#include<cstdlib>
#include<set>
#include<utility>
#include<algorithm>

typedef long long ll;

using namespace std;

int main()
{
    
    int x,y,z;
    cin>>x>>y>>z;
    int temp=x;
    x=y;
    y=temp;
    int temp2;
    temp2=x;
    x=z;
    z=temp2;
    cout<<x<<" "<<y<<" "<<z;
    
    return 0;
}

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

int main() {
  int a, b;
  cin >> a >> b;
  int c = a * b;
  if (c % 2 == 0) {
  	cout << "Even" << endl;
   
  } else {
  	cout << "Odd" << endl;
  }
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <tuple>
#include <queue>
#include <stack>

using namespace std;

class Solver {
public:
	static void solve() {
		vector<bool> res;
		string s;
		getline(cin, s);
		while (s[0] != '.') {
			res.emplace_back(balance(s));
			getline(cin, s);
		}

		for (int i = 0; i < res.size(); i++) {
			if (res[i])cout << "yes" << endl;
			else cout << "no" << endl;
		}
	}

	static bool balance(string s) {
		vector<int> index1(s.size(), -1);
		vector<int> index2(s.size(), -1);
		stack<int> stack1;
		stack<int> stack2;
		vector<int> nest1(s.size(), 0);
		vector<int> nest2(s.size(), 0);
		for (int i = 0; i < s.size(); i++) {
			if (i > 0) {
				nest1[i] = nest1[i - 1];
				nest2[i] = nest2[i - 1];
			}

			if (s[i] == '(') {
				nest1[i]++;
				stack1.push(i);
			}
			if (s[i] == ')') {
				nest1[i]--;
				if (stack1.empty())return false;
				index1[i] = stack1.top();
				stack1.pop();
			}
			if (s[i] == '[') {
				nest2[i]++;
				stack2.push(i);
			}
			if (s[i] == ']') {
				nest2[i]--;
				if (stack2.empty())return false;
				index2[i] = stack2.top();
				stack2.pop();
			}
		}
		if (!(stack1.empty() && stack2.empty()))return false;

		for (int i = 0; i < s.size(); i++) {
			if (index1[i] >= 0) {
				if (nest2[index1[i]] != nest2[i])return false;

				for (int j = index1[i] + 1; j < i; j++) {
					if (nest2[j] < nest2[i])return false;
				}
			}
			if (index2[i] >= 0) {
				if (nest1[index2[i]] != nest1[i])return false;

				for (int j = index2[i] + 1; j < i; j++) {
					if (nest1[j] < nest1[i])return false;
				}
			}
		}

		return true;
	}
};

int main() {
	Solver::solve();
}


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

using namespace std;

int main() {
	int A, B, C;
	cin >> A >> B >> C;
	
	bool ans = false;
	if (A == 5) {
		if ((B == 5 && C == 7) || (B == 7 && C == 5)) {
			ans = true;
		}
	}
	else if (A == 7) {
		if (B == 5 && C == 5) {
			ans = true;
		}
	}

	if (ans) {
		cout << "YES" << endl;
	}
	else {
		cout << "NO" << endl;
	}

	return 0;
}

Measured memory_bytes: 256
a, b, m = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
res = min(A) + min(B)
for i in range(m):
    x, y, c = map(int, input().split())
    res = min(res,  A[x - 1] + B[y - 1] - c)
print(res)

Measured memory_bytes: 18736
#include<iostream>
using namespace std;
int main()
{
	char a[4];
	int flag=0;
	while(cin>>a[0])
	{
		for(int i=1; i<4; i++)
		{
			cin>>a[i];
			if(a[i]==a[i-1])
				flag=1;
		}
		if(flag)
			cout<<"Bad"<<endl;
		else
			cout<<"Good"<<endl;
	}
	return 0;
}

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

using namespace std;

typedef vector<int> vi;
typedef vector<vi> vvi;

#define REP(i, n) for (int i = 0; i < (n); ++i)
#define FORE(x, xs) for (auto &x: (xs))

const int MAX = 1e5;

int N, M;
vi color;
int white;
vvi G;

bool dfs(int u, int p, int c) {
  /*
   * u：注目しているノード
   * p：注目しているノードに来る前のところ。重複を防ぐため
   * c：注目しているノードの色
   *
   * 戻り値<bool>：二部グラフかどうかを返す
   */
  color[u] = c;
  if (c == 1) white++;
  FORE (v, G[u]) if (v != p) {
    if (color[v] == -1) { /// 色がまだ決まってないなら
      if (!dfs(v, u, 1-c)) return false;
    } else if (color[v] != 1-c) { /// 隣接するノードの色が同じなら
      return false;
    }
  }
  return true;
}

int BipartiteGraph() {
  /*
   * 戻り値<int>：二部グラフなら一方のグループのノード数。二部グラフでないなら-1
   */

  if (!dfs(0, -1, 0)) return -1;
  REP (i, N) 
    if (color[i] == -1) return -1; /// 連結でないノードがあるとき
  return white;
}

int main() {

  cin >> N >> M;
  color.resize(N, -1);
  G.resize(N);

  REP (i, M) {
    int a, b;
    cin >> a >> b;
    a--; b--;
    G[a].push_back(b);
    G[b].push_back(a);
  }

  int res = BipartiteGraph();
  if (res == -1) /// 二部グラフでないとき
    cout << 1l*N*(N-1)/2 - M << endl;
  else
    cout << 1l*res*(N-res) - M << endl;

  return 0;
}

Measured memory_bytes: 6528
#include <iostream>
#include <algorithm>
#include <sstream>
#include <cstdio>
#include <vector>
using namespace std;

bool fizzBuzzCheck(int n,string s){
	if(n%15==0)return (s == "FizzBuzz");
	if(n%3==0)return  (s == "Fizz");
	if(n%5==0)return  (s == "Buzz");
	
	for(int i=0;i<s.length();i++) if(s[i]<'0'||s[i]>'9')return false;

	return (atoi(s.c_str()) == n);
}

int main(){
	int n,m;
	string s;
	
	while(scanf("%d %d\n",&m,&n), m){
	
		vector<int> rem(m);
		for(int i=0;i<m;i++){
			rem[i] = i+1;
		}
		int c = 0;
		for(int i=1;i<=n;i++){
			getline(cin,s);
			if(rem.size() == 1)continue;
			if( !fizzBuzzCheck(i,s) ){
				rem.erase(remove(rem.begin(),rem.end(),rem[c]),rem.end());
			}else{
				c++;
			}
			c %= rem.size();
		}
		for(int i=0;i<rem.size();i++){
			cout << (i?" ":"") << rem[i];
		}
		cout << endl;
	}
}

Measured memory_bytes: 0
// finish date: 2019/06/04

#include <bits/stdc++.h>

using namespace std;

#define FOR(i, a, b) for(int (i)=a;(i)<(b);(i)++)
#define rep(i, n)  FOR(i,0,n)
typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<vector<vector<int>>> vvvi;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef vector<double> vd;
typedef vector<vector<double>> vvd;
typedef vector<vector<vector<double>>> vvvd;
typedef vector<bool> vb;
typedef vector<vector<bool>> vvb;
typedef vector<string> vs;
typedef vector<char> vc;
typedef vector<vector<char>> vvc;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;
typedef pair<ll, pair<int, int>> plii;
const int bigmod = 998244353;
const int INF = 1050000000;
const long long INFll = 100000000000000000;


int main() {
    string s;
    cin >> s;
    int N = s.length();
    reverse(s.begin(), s.end());
    s = s + "#";
    ll ans = 0;
    int cntCB = 0;
    rep(i, N) {
        if (s[i] == 'A') {
            ans += cntCB;
        } else if (s[i] == 'B') {
            cntCB = 0;
        } else if (s[i] == 'C') {
            if (s[i + 1] == 'B') {
                cntCB++;
                i++;
            } else {
                cntCB = 0;
            }
        }
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 900
#include <bits/stdc++.h>
 
using namespace std;
 
#define MAX_N 1001
#define INF 1e9
#define all(x) (x).begin(),(x).end()
 
struct P{
    int a,b;
    bool operator < (const P &p)const{
	if(b != p.b){
	    return b < p.b;
	}else{
	    return a < p.a;
	}
    }
};
 
int N,dp[MAX_N][MAX_N];
vector<P> p;
 
int main(){
    cin >> N;
    p.resize(N);
    for(int i = 0 ; i < N ; i++){
	cin >> p[i].a >> p[i].b;
    }
    sort(all(p));
    fill(dp[0],dp[0]+MAX_N*MAX_N,INF);
    dp[0][0] = 0;
    for(int i = 0 ; i < N ; i++){
	for(int j = 0 ; j < N ; j++){
	    if(dp[i][j] == INF) continue;
	    dp[i+1][j] = min(dp[i+1][j],dp[i][j]);
	    if(dp[i][j] + p[i].a <= p[i].b){
		dp[i+1][j+1] = min(dp[i+1][j+1],dp[i][j]+p[i].a);
	    }
	}
    }
    for(int i = N ; i >= 0 ; i--){
	if(dp[N][i] != INF){
	    cout << i << endl;
	    break;
	}
    }
    return 0;
}

Measured memory_bytes: 7032
#include<iostream>
#include<stdio.h>
#include<string>
#include<vector>
#include<map>
#include<tuple>
#include<algorithm>
#include<cmath>
#include<limits>
#include<set>
#include<deque>
#include<queue>
using namespace std;
#define int long  long int
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a / gcd(a, b) * b; }
typedef pair<int, int>P;
const int MOD = 1e9 + 7;
//const int MOD = 998244353;
const int INF = 1e10;
const long double PI = (acos(-1));


signed main() {
	int N, K;
	cin >> N >> K;
	int ans = 0;
	for (int i = 1; i <= N; i++) {
		int a = N / i;
		ans += a * max(0ll, i - 1 - K + 1);
		int b = N % i;
		if (K == 0)ans += b;
		else ans += max(0ll, b - K + 1);
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#float型を許すな
#numpyはpythonで
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)
from collections import Counter, deque
from collections import defaultdict
from itertools import combinations, permutations, accumulate, groupby, product
from bisect import bisect_left,bisect_right
from heapq import heapify, heappop, heappush
from math import floor, ceil,pi,factorial
from operator import itemgetter
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
def LI2(): return [int(input()) for i in range(n)]
def MXI(): return [[LI()]for i in range(n)]
def SI(): return input().rstrip()
def printns(x): print('\n'.join(x))
def printni(x): print('\n'.join(list(map(str,x))))
inf = 10**17
mod = 10**9 + 7

a,b,q=MI()
lis1=[I() for i in range(a)]
lis2=[I() for i in range(b)]
lis1.append(inf)
lis2.append(inf)
lis1=[-inf]+lis1
lis2=[-inf]+lis2
#print(lis1)
#print(lis2)
for i in range(q):
    u=I()
    x=bisect_left(lis1,u)
    y=bisect_left(lis2,u)
    #print(u,x,y)
    Lll=u-min(lis1[x-1],lis2[y-1])
    Lrr=max(lis1[x],lis2[y])-u
    Llr1=2*(u-lis1[x-1])+(lis2[y]-u)
    Llr2=2*(lis2[y]-u)+u-lis1[x-1]
    Lrl1=2*(u-lis2[y-1])+lis1[x]-u
    Lrl2=2*(lis1[x]-u)+u-lis2[y-1]
    #print(Lll,Lrr,Lrl1,Lrl2,Llr1,Llr2)
    print(min(Lll,Lrr,Lrl1,Lrl2,Llr1,Llr2))
    
    
    
    



Measured memory_bytes: 18020
import java.io.*;
import java.util.*;

public class Main {

    public static void main(String args[]){
	boolean isPrime[] = new boolean[1000000];
	for(int i=2;i<=246912;i++){
	    isPrime[i] = true;
	}
	for(int i=2;i<=246912;i++){
	    if(isPrime[i]){
		int n = 2 * i;
		while(n<=246912){
		    isPrime[n] = false;
		    n += i;
		}
	    }
	}

	Scanner in = new Scanner(System.in);
	while( true ){
	    int n = in.nextInt();
	    if( n == 0 ) break;
	    int count = 0;
	    for(int i=n+1;i<=2*n;i++){
		if(isPrime[i]){
		    count++;
		}
	    }
	    System.out.println(count);
	}
    }

}

Measured memory_bytes: 23084
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<ll,ll>;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep2(i,m,n) for(int (i)=(m);(i)<(n);(i)++)
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
const ll INF = 1LL<<60;
const ll MOD = 1e9+7;


int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll x;cin>>x;
    for(ll a=-1000; a<=1000; a++){
        for(ll b=-1000; b<=1000; b++){
            if(a*a*a*a*a-b*b*b*b*b==x){
                cout<<a<<" "<<b;
                return 0;
            }
        }
    }
    return 0;
}

Measured memory_bytes: 3652
#include <stdio.h>
#include <assert.h>
#include <fstream>
#include <iostream>
#include <algorithm>
#include <limits>
#include <array>
#include <vector>
#include <queue>
#include <set>
#include <map>
//#include <unordered_map>
//#include <unordered_set>
//#include <boost/container/static_vector.hpp>
//#include <boost/unordered_set.hpp>
//#include <boost/unordered_map.hpp>
//#include <unistd.h>

//#include <cv.h>
//#include <highgui.h>
#include <stdlib.h>
#include <string>

std::string S, T;

const int MAX_N = 200050;
bool checked[MAX_N] = {};

int main(int argc, char **argv) {
    std::cin >> S;
    std::cin >> T;

    for (int i = 0; i < S.size(); i++) {
        if (!checked[i]) {
            for (int j = i; j < S.size(); j++) {
                if (S[j] == S[i] && T[j] == T[i]) {
                    checked[j] = true;
                } else if (S[j] == S[i]) {
                    std::cout << "No" << std::endl;
                    return 0;
                } else if (T[j] == T[i]) {
                    std::cout << "No" << std::endl;
                    return 0;
                }
            }
            checked[i] = true;
        }
    }
    std::cout << "Yes" << std::endl;

    return 0;
}

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

using namespace std;

using ll = long long;
constexpr ll MOD = 1e9 + 7;
constexpr ll INF = 1e18;

int main() {
    int n;
    cin >> n;
    int a[100001]={};
    for(int i=0;i<n;i++){
        int x;
        cin >> x;
        if(x>0)a[x-1]++;
        a[x]++;
        a[x+1]++;
    }
    int ret=0;
    for(int i=0;i<100001;i++){
        ret = max(ret,a[i]);
    }
    cout << ret << endl;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define ok cout<<"ok"<<endl
#define dbg(x) cout<<(#x)<<" is "<<x<<endl
#define pii pair<int,int>
#define fastio {ios_base::sync_with_stdio(false);cin.tie(NULL);}
using namespace std;
typedef long long ll;
const int N=2*100009;
int main()
{
  fastio;
  int red,green,A,B,C,i,r;
  ll sum=0;
  vector<pii> vec;
  cin>>red>>green>>A>>B>>C;
   for(i=1; i<=A; i++)
   {
     cin>>r;
     vec.push_back(make_pair(r,1));
   }
    
   for(i=1; i<=B; i++)
   {
   	 cin>>r;
   	 vec.push_back(make_pair(r,2)); 
   }
   for(i=1; i<=C; i++)
   {
   	 cin>>r;
   	 vec.push_back(make_pair(r,3)); 
   }

   sort(vec.rbegin(),vec.rend());
   int rtemp=0,gtemp=0;
   for(i=0; i<A+B+C; i++)
   {
      if(!red && !green) break;
      if(vec[i].second==1)
      {
      	 if(red)
      	 {
      	 	red--;
      	 	sum+=vec[i].first;
      	 }
      	 else if(rtemp)
      	 {
      	 	rtemp--; gtemp++;
      	 	green--;
      	 	sum+=vec[i].first;
      	 }
      }
      else if(vec[i].second==2)
      {
      	if(green)
      	{
      		green--;
      		sum+=vec[i].first;
      	}
      	else if(gtemp)
      	{
      		gtemp--; rtemp++;
      		red--;
      		sum+=vec[i].first;
      	}

      }
      else
      {
      	 if(red)
      	 {
      	 	rtemp++;
      	 	red--;
      	 	sum+=vec[i].first;
      	 }
      	 else if(green)
      	 {
      	 	gtemp++;
      	 	green--;
      	 	sum+=vec[i].first;
      	 }
      }
   }
   cout<<sum<<endl;
  return 0;
}

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

int main(){

    int n; cin >> n;
    vector<int> h(n), dp(n, 1e9+9);
    for(int &u:h) cin >> u;

    dp[0] = 0; for(int i=1; i<n; i++){
        dp[i] = dp[i-1] + abs(h[i] - h[i-1]);
        if(i>1)
            dp[i] = min(dp[i], dp[i-2] + abs(h[i] - h[i-2]));
    }cout << dp[n-1] << "\n";

    return 0;
}


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

#define int long long
using namespace std;
#define rep(i, n) for(int i=0;i<(n);++i)
typedef pair<int, int> pii;
const int INF = 1l << 60;
#define u_b upper_bound
#define l_b lower_bound

const int MAX_N = 5000;
int N;
int A[MAX_N];
vector<int> G[MAX_N];
vector<int> dp1[MAX_N];
vector<int> dp2[MAX_N];

vector<int> tr(vector<int> dp, vector<int> ch1, vector<int> ch2, bool flg) {
    int a = dp.size(), b = ch1.size();
    vector<int> ans(a + b - 1);
    rep(i, ans.size())ans[i] = INF;
    rep(i, dp.size()) {
        if (dp[i] == INF)continue;
        rep(j, ch1.size()) {
            if (i + j - 1 >= 0) {
                if (ch1[j] != INF)ans[i + j - 1] = min(ans[i + j - 1], dp[i] + ch1[j]);
                if (ch2[j] != INF && !flg)ans[i + j - 1] = min(ans[i + j - 1], dp[i] + ch2[j]);
            }
            if (ch1[j] != INF)ans[i + j] = min(ans[i + j], dp[i]);
            if (ch2[j] < 0)ans[i + j] = min(ans[i + j], dp[i]);
        }
    }
    return ans;
}

void dfs(int v, int par) {
    dp1[v].push_back(INF);
    dp1[v].push_back(A[v] > 0 ? A[v] : INF);
    dp2[v].push_back(INF);
    dp2[v].push_back(A[v]);
    for (int u:G[v]) {
        if (u == par)continue;
        dfs(u, v);
        dp1[v] = tr(dp1[v], dp1[u], dp2[u], true);
        dp2[v] = tr(dp2[v], dp1[u], dp2[u], false);
    }
}

int solve() {
    dfs(0, -1);
    for (int i = 0; i <= N; ++i) {
        if (dp1[0][i] < INF)return i - 1;
        if (dp2[0][i] < 0)return i - 1;
    }
    return -1;
}

signed main() {
    cin >> N;
    rep(i, N)cin >> A[i];
    rep(i, N - 1) {
        int u, v;
        cin >> u >> v;
        u--, v--;
        G[u].push_back(v);
        G[v].push_back(u);
    }
    int ans = solve();
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 179200
#include<stdio.h>
int main(){
  int n,k,x[100],i,A=0;
  scanf("%d%d",&n,&k);
  for(i=0;i<n;i++){
    scanf("%d",&x[i]);
    A+=x[i]<k-x[i]?x[i]:k-x[i];
  }
  printf("%d",A*2);
}

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

int main(){
    string s;
    cin >> s;
    long l = s.size(), ans = 0, bCount=0;

    for(int i=0; i<l; i++){
	if(s[i] == 'W')
	    ans += bCount;
	else
	    bCount++;	
    }
    cout << ans << "\n";
}



Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
bool solve(string a,string b){
    int pos=0;
    for(int i=0;i<b.length();++i){
	if(a[pos]==b[i]) ++pos;
	if(pos==a.length()) return true;
    }
    return false;
}
int main(){
    string s,t,s1,s2; cin>>s>>t;
    for(int i=0;i<s.size();++i){
	if(i%2==0) s1+=s[i];
	else s2+=s[i];
    }
    cout<<(solve(s1,t)||solve(s2,t)?"Yes":"No")<<endl;
    return 0;
}


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

int main(){
  long long N,ans=0;
  cin>>N;
  
  if(N%2!=0){cout<<0<<endl;}
  else{
    N=N/2;
    while(N!=0){
      ans+=N/5;
      N=N/5;
    }
  cout<<ans<<endl;
  }
}
    

Measured memory_bytes: 256
#pragma GCC optimize(3, "Ofast", "inline")
#include <bits/stdc++.h>
#if __cplusplus >= 201103L
#include <chrono>
using namespace std::chrono;
#endif
using namespace std;
#define ll long long
#define ull unsigned long long
#define pii pair<int, int>
#define pb push_back
#define fi first
#define se second
#ifdef LOCAL
#define prln(x) (cout << #x << ' ' << x << endl)
#define pr(x) (cout << #x << ' ' << x << ' ' )
#define prv(x) (cout << x << ' ')
#else
#define prln(x) 
#define pr(x)
#define prv(x)
#endif
#define clr(x) memset((x), 0, sizeof((x)))
#define clr1(x) memset((x), -1, sizeof((x)))
#define endl "\n"
#define pi acos(-1)
#define rep(i, st, ed) for (int i = (st); i <= (ed); ++i)
#define rep0(i, st, ed) for (int i = (st); i < (ed); ++i)
#define per(i, st, ed) for (int i = (st); i >= ed; --i)
template<class T> void _sf(T &x) {cin >> x;}
void _sf(int &x) {scanf("%d", &x);}
void _sf(ll &x) {scanf("%lld", &x);}
void _sf(double &x) {scanf("%lf", &x);}
void _sf(char &x) {scanf(" %c", &x);}
void _sf(char *x) {scanf("%s", x);}
void sf() {}
template <class T, class...U> void sf(T & head, U&... tail) { _sf(head); sf(tail...);}
const int mod = 1e9 + 7;
const int INF = 0x3f3f3f3f;

int read() {
    int x = 0, f = 1;
    char ch = getchar();
    while (ch < '0' || ch > '9') {
        if (ch == '-') f = -1;
        ch = getchar();
    }
    while (ch >= '0' && ch <= '9') {
        x = x * 10 + ch - '0';
        ch = getchar();
    }
    return x * f;
}


int main(){
    #ifdef LOCAL
        freopen("in.txt", "r", stdin);
        freopen("out.txt", "w", stdout);
        #if __cplusplus >= 201103L
        auto start = steady_clock::now();
        #endif
    #endif
    int n = read(), k = read();
    int s = 0;
    for (int i = 1; i <= n; ++i) {
        int x = read();
        if (x >= k) ++s;
    }
    cout << s << endl;

    #ifdef LOCAL
        #if __cplusplus >= 201103L
        auto end = steady_clock::now();
        duration<double> time_span = duration_cast<duration<double>>(end - start);;
        printf("Total time: %.6fs\n", time_span.count());
        #endif
    #endif
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
	int s;
	int n;
	int sk;
	
	while (scanf("%d", &n) != EOF) {
		sk = n % 39;
		
		if (sk == 0) {
			printf("3C39\n");
		}
		else if (sk < 10) {
			printf("3C0%d\n", sk);
		}
		else {
			printf("3C%d\n", sk);
		}
	}
	return (0);
}

Measured memory_bytes: 608
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define R cin>>
#define Z class
#define ll long long
#define ln cout<<'\n'
#define in(a) insert(a)
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define all(c) (c).begin(),(c).end()
#define iter(c) __typeof((c).begin())
#define rrep(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define rep(i,n) REP(i,0,n)
#define tr(it,c) for(iter(c) it=(c).begin();it!=(c).end();it++)
void pr(){ln;}
template<Z A,Z...B>void pr(const A &a,const B&...b){cout<<a<<' ';pr(b...);}
template<Z A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}ln;}
ll check(ll n,ll m,ll x,ll y){return x>=0&&x<n&&y>=0&&y<m;}
const ll MAX=1e9+7,MAXL=1LL<<61,dx[8]={-1,0,1,0,-1,-1,1,1},dy[8]={0,1,0,-1,-1,1,1,-1};
typedef pair<ll,ll> P;

void Main() {
  ll a,b,n;
  cin >> a >> b >> n;
  ll x=min(n,b-1);
  ll ans=a*x/b-a*(x/b);
  pr(ans);
}

int main(){ios::sync_with_stdio(0);cin.tie(0);Main();return 0;}


Measured memory_bytes: 3652
#include <bits/stdc++.h>
using namespace std;
int main() {
    int h, n;
    cin >> h >> n;

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

    sort(a, a + n, greater<int>());

    for(int i = 0; i < n; i++) {
        h -= a[i];
        if(h <= 0) {
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;

    return 0;
}


Measured memory_bytes: 640
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ

		Scanner sc = new Scanner(System.in);

		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();


	if (a + b == c  || b + c == a || c + a == b) {

			System.out.println("Yes");

		} else {

			System.out.println("No");

		}
	}
}


Measured memory_bytes: 25684