akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef string str;
#define REP(i, n) for(int i=0; i<n; ++i)
#define ALL(obj) (obj).begin(), (obj).end()
using P = pair<int, int>;
const int inf = 1e9;
const ll INF = 1e18;
const ll mod = 1e9+7;

struct edge{
    int to;
    int cost;
};
using graph = vector<vector<edge>>;

int main(){
    bool from_front = true;
    str s; cin >> s;
    int q; cin >> q;
    int t, f;
    char c;
    stack<char> from_front_stack;
    stack<char> from_back_stack;
    queue<char> from_front_queue;
    queue<char> from_back_queue;
    REP(i, q){
        cin >> t;
        if(t == 1){
            from_front = !from_front;
        }else{
            cin >> f >> c;
            if((from_front && f == 1) || (!from_front && f == 2)){
                from_front_stack.push(c);
                from_back_queue.push(c);
            }else{
                from_back_stack.push(c);
                from_front_queue.push(c);
            }
        }
    }
    if(from_front){
        while(!from_front_stack.empty()){
            cout << from_front_stack.top();
            from_front_stack.pop();
        }
        cout << s;
        while(!from_front_queue.empty()){
            cout << from_front_queue.front();
            from_front_queue.pop();
        }
    }else{
        while(!from_back_stack.empty()){
            cout << from_back_stack.top();
            from_back_stack.pop();
        }
        for(int i=s.size()-1; i>=0; i--){
            cout << s[i];
        }
        while(!from_back_queue.empty()){
            cout << from_back_queue.front();
            from_back_queue.pop();
        }
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 1024
S = input()
R_check = lambda x: 1 if x=="R" else 0
rain_flg = list(map(R_check, S))
if sum(rain_flg) == 2:
  if rain_flg[1] == 0:
    print(1)
  else:
    print(2)
else:
  print(sum(rain_flg))

Measured memory_bytes: 61856
#include<bits/stdc++.h>
#define ll long long
#define pa pair<ll,vector<int> >
using namespace std;
ll s[200004];
map<ll , vector<int> >mert;
int n;
ll k;
int main(){
    mert.clear();
    scanf("%d%lld",&n,&k);
    s[0]=0;
    for(int i=1;i<=n;i++){
        int x;scanf("%d",&x);
        s[i]=s[i-1]+x;
    }
    for(int i=1;i<=n;i++){
        s[i]%=k;
    }
    for(int i=0;i<=n;i++){
        s[i]-=i;
        s[i]%=k;
        s[i]+=k;
        s[i]%=k;
        mert[s[i]].push_back(i);
    }
    ll ans=0;
    for(pa p:mert){
        vector<int>now=p.second;
        int r=0;
        //cout<<p.first<<endl;
        for(int i=0;i<now.size();i++){
            //cout<<now[i]<<" ";
            while(r+1<now.size()&&now[r+1]<now[i]+k)r++;
            if(now[r]<now[i]+k)ans+=r-i;
        }
        //if(p.first==1)ans+=now.size();
        //cout<<endl;
    }
    printf("%lld\n",ans);
    return 0;
}


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

#define int long long
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define fr(i,j,k) for(i = j; i < (k); i++)
#define all(x) x.begin(), x.end()
#define el '\n'
#define remax(a,b) a = max(a, b)
#define remin(a,b) a = min(a, b)
#define sz(x) int32_t(x.size())

typedef long double ld;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vpi;
// --------------------------------------------------------------------

const pii dxy[] = { {-1, 0}, {1, 0}, {0, 1}, {0, -1} };
const int mod = 1e9 + 7;
const int INF = 2e18;
const ld EPS = 1e-9;
const int NN = 1e5 + 2;

vvi g(NN);
void solve() {
      int i = 0, j = 0, k = 0, n = 0, m = 0; 
      cin >> n >> m;
      vi h(n+1);
      fr(i,0,n) {
            cin >> h[i+1];
      }

      fr(j, 0, m) {
            int a,b;
            cin >> a >> b;
            g[a].pb(b);
            g[b].pb(a);
      }
      int a =0;
      fr(i, 1, n+1) {
            if(sz(g[i]) == 0) {
                  a++;
                  continue;
            }
            bool c = 1;
            for(int b : g[i]) {
                  if(h[b] >=  h[i]) {
                        c = 0;
                        break;
                  }
            }

            a += c;
      }

      cout << a << endl;
}

int32_t main() {
      ios::sync_with_stdio(false); cin.tie(0); 
      int T = 1; 
      // cin >> T;
      for(int tc = 1; tc <= T; tc++) {
            solve();
       }
      return 0;
}

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

#define  all(x)          (x).begin(), (x).end()
#define  rall(v)          v.rbegin() , v.rend()
#define  ones(x)          __builtin_popcount(x)
#define  sz(v)           ((int)((v).size())
#define  debug(x)        cout << '>' << #x << ':' << x << endl;
#define  clr(v, d)       memset(v, d, sizeof(v));
#define  rep(i,a,b)      for(ll i=a; i<=b;i++)
#define  fo(i,n)         for(ll i=0;i<n;i++)
#define  rfo(i,n)        for(ll i=n-1;i>=0;i--)
#define  unq(vec)        sort(all(vec)); vec.resize(unique(all(vec)) - vec.begin());
#define  era(v)          sort(v.begin(), v.end());v.erase(unique(v.begin(), v.end()), v.end());
#define  pb              push_back
#define  mp              make_pair
#define  endl            '\n'
#define  fi               first
#define  se               second

using namespace std;
typedef long long         ll;
typedef long double       ld;
typedef vector<int>       vi;
typedef vector<long long> vll;
typedef vector<double>    vd;
typedef vector<vi >       vvi;
typedef vector< vd >      vvd;
typedef vector<string>    vs;
typedef pair<int,int>     pii;
typedef vector<pii>       vii;
typedef map<int,int>      mii;

ll gcd(ll a, ll b){return !b ? a : gcd(b, a % b);}
ll lcm(ll a, ll b){return (a / gcd(a, b)) * b;}
//ll modpow(ll a, ll b, ll m = MOD){a %= m; ll res = 1; while (b) {if (b & 1)res = (res * a) % m; a = (a * a) % m; b >>= 1;} return res;}
//ll bpow(ll a, ll b){ll res = 1; while (b) {if (b & 1)res = res * a; a = a * a; b >>= 1;} return res;}
//ll modinv(ll a, ll m = MOD) {return modpow(a, m - 2, m);}

const ll MOD = 1e9 + 7;
const int dx4[4] = {0, 1, 0, -1};
const int dy4[4] = {-1, 0, 1, 0};
const int dx8[8] = {-1, -1, -1, 0, 1, 1, 1, 0};
const int dy8[8] = {-1, 0, 1, 1, 1, 0, -1, -1};
bool cmp(int X,int Y){return X>Y;}

int main()
{ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
ll x;cin>>x;
ll n = x%10;
if(n==3){cout<<"bon";}
else if(n==0 || n==1 || n==6 || n==8){
    cout<<"pon";
}else{
cout<<"hon";}
}















Measured memory_bytes: 3652
#include <stdio.h>
#include <stdlib.h>
#include <limits.h>
#include <string.h>

int main(void) {
    int N, K, Q;
    scanf("%d %d %d", &N, &K, &Q);

    int *A = (int*)malloc(Q * sizeof(int));
    int *x = (int*)malloc(N * sizeof(int));
    int temp;
    
    int i, j;
    for(i=0; i<N; i++) {
        x[i] = 0;
    }
    for(i=0; i<Q; i++) {
        scanf("%d", &temp);
        A[i] = temp - 1;
        x[A[i]]++;
    }
    
 
    for(i=0; i<N; i++) {
        if(x[i] + K - Q > 0) {
            printf("Yes\n");
        }
        else {
            printf("No\n");
        }
    }




    free(A);
    free(x);
    return 0;
}


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

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

int H, W;
int g[400][400] = {};
int b[400*400+1] = {};
int w[400*400+1] = {};

void dfs(vector<string> &S, int y, int x, int id) {
    if (S[y][x] == '#') {
        b[id] ++;
    } else {
        w[id] ++;
    }
    g[y][x] = id;
    for (int i=0; i<4; ++i) {
        int ny, nx;
        ny = y + dy[i];
        nx = x + dx[i];
        if (0 <= ny && ny < H && 0 <= nx && nx < W && g[ny][nx] == 0 && S[y][x] != S[ny][nx]) {
            dfs(S, ny, nx, id);
        }
    }
}

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

    cin >> H >> W;

    vector<string> S(H);
    for (int i=0; i<H; ++i) {
        cin >> S[i];
    }

    int id = 1;
    for (int i=0; i<H; ++i) {
        for (int j=0; j<W; ++j) {
            if (g[i][j] != 0) continue;
            dfs(S, i, j, id++);
        }
    }

    long long sum = 0;
    for (int i=1; i<id; ++i) {
        sum += (long long)b[i] * w[i];
    }
    cout << sum << endl;

    return 0;
}

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

N = int(input())
l = []

for _ in range(N):
    Xi, Li = map(int, input().split())
    l.append((Xi-Li, Xi+Li))

l.sort(key=lambda k: k[1])
now = -10**18
ans = 0
i = 0

while i<N:
    if now<=l[i][0]:
        now = l[i][1]
        ans += 1
    
    i += 1

print(ans)


Measured memory_bytes: 52628
#include <vector>
#include <iostream>
#include <cmath>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <fstream>
#include <unistd.h>
#include <string.h>
#include <string>
#include <numeric>
#include <queue>
#include <deque>
#include <sstream>
#include <iomanip>
#include <set>
#include <stack>
#include <cassert>
#include <functional>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<vvl> vvvl;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<bool> vb;
typedef vector<vector<bool>> vvb;
typedef vector<vvb> vvvb;
typedef vector<vvvb> vvvvb;
typedef vector<string> vs;
typedef vector<vs> vvs;
typedef vector<vvs> vvvs;
typedef vector<char> vc;
typedef vector<vector<char>> vvc;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<vvd> vvvd;
typedef pair<ll, ll> PL;
typedef vector<PL> vpl;
typedef vector<vector<PL>> vvpl;
const int INF = 1001001001;
const ll LINF = 1e17;
const double pi = 3.1415926535897932;
const string endstr = "\n";
#define FOR(i, a, b) for(ll i = (a); i < b; i++)
#define RFOR(i, a, b) for(ll i = (a); i > b; i--)
#define rep(i, n) for(ll i = 0; i < n; i++)
#define rrep(i, n) for(ll i = n-1; i > -1; i--)
#define FORMAP(it, m) for(auto it = m.begin(); it != m.end(); it++)
#define ff first
#define ss second
#define pb push_back
#define epb emplace_back
#define ALL(X) (X).begin(),(X).end()

template <typename T>
T gcd(T a, T b) {
    return (a == 0) ? b : gcd(b%a, a);
}
template <typename T>
T lcm(T a, T b) {
    return a / gcd(a, b) * b;
}

bool p_comp_fs(const PL p1, const PL p2){ return p1.first < p2.first;};
bool p_comp_fg(const PL p1, const PL p2){ return p1.first > p2.first;};
bool p_comp_ss(const PL p1, const PL p2){ return p1.second < p2.second;};
bool p_comp_sg(const PL p1, const PL p2){ return p1.second > p2.second;};
template <typename T>
vector<T> uniquen(vector<T> vec){
    sort(ALL(vec));
    vec.erase(unique(vec.begin(), vec.end()), vec.end());
    return vec;
}

inline ll popcnt(ll x){return __builtin_popcountll((unsigned long long)x);};
template<class T> bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; }
//friend bool operator<(const stc& lhs, const stc& rhs){
//    return std::tie(lhs.l, lhs.r) < std::tie(rhs.l, rhs.r);
//}



int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    ll N; cin >> N;
    vl A(N); rep(i, N) cin >> A[i];
    if(A[0] != 0){
        cout << -1 << endstr; return 0;
    }
    
    reverse(ALL(A));
    
    ll idx = 0, ans = 0;
    while(idx < N){
        ll now = A[idx];
        while(idx+1 < N && A[idx] == A[idx+1]+1){
            idx++;
        }
        if(idx+1 < N && A[idx] > A[idx+1]+1){
            cout << -1 << endstr; return 0;
        }
        ans += now;
        idx++;
    }
    cout << ans << endstr;
    return 0;
}


Measured memory_bytes: 1792
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.HashMap;
import java.util.Map.Entry;
import java.util.NoSuchElementException;

public class Main {
	public static void main(String[] args) {
		FastScanner sc = new FastScanner();
		String S = sc.next();
		HashMap<String, Integer> map = new HashMap<>();

		for (int i = 0; i < S.length(); i++) {
			String str = String.valueOf(S.charAt(i));
			if(map.containsKey(str)) {
				map.put(str, map.get(str)+1);
			} else {
				map.put(str, 1);
			}
		}

		PrintWriter out = new PrintWriter(System.out);
		if(map.keySet().size() != 2) {
			out.println("No");
		} else {
			for (Entry<String, Integer> entry : map.entrySet()) {
				if (entry.getValue() != 2) {
					out.println("No");
				}
			}
			out.println("Yes");
		}

		out.flush();
	}

	public static int gcd(int a, int b) {
	    if (b == 0) return Math.abs(a);
	    return gcd(b, a % b);
	}
}

class FastScanner {
	private final InputStream in = System.in;
	private final byte[] buffer = new byte[1024];
	private int ptr = 0;
	private int buflen = 0;

	private boolean hasNextByte() {
		if (ptr < buflen) {
			return true;
		} else {
			ptr = 0;
			try {
				buflen = in.read(buffer);
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (buflen <= 0) {
				return false;
			}
		}
		return true;
	}

	private int readByte() {
		if (hasNextByte())
			return buffer[ptr++];
		else
			return -1;
	}

	private static boolean isPrintableChar(int c) {
		return 33 <= c && c <= 126;
	}

	public boolean hasNext() {
		while (hasNextByte() && !isPrintableChar(buffer[ptr]))
			ptr++;
		return hasNextByte();
	}

	public String next() {
		if (!hasNext())
			throw new NoSuchElementException();
		StringBuilder sb = new StringBuilder();
		int b = readByte();
		while (isPrintableChar(b)) {
			sb.appendCodePoint(b);
			b = readByte();
		}
		return sb.toString();
	}

	public long nextLong() {
		if (!hasNext())
			throw new NoSuchElementException();
		long n = 0;
		boolean minus = false;
		int b = readByte();
		if (b == '-') {
			minus = true;
			b = readByte();
		}
		if (b < '0' || '9' < b) {
			throw new NumberFormatException();
		}
		while (true) {
			if ('0' <= b && b <= '9') {
				n *= 10;
				n += b - '0';
			} else if (b == -1 || !isPrintableChar(b)) {
				return minus ? -n : n;
			} else {
				throw new NumberFormatException();
			}
			b = readByte();
		}
	}

	public int nextInt() {
		long nl = nextLong();
		if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE)
			throw new NumberFormatException();
		return (int) nl;
	}

	public double nextDouble() {
		return Double.parseDouble(next());
	}
}


Measured memory_bytes: 22612
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <utility>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <limits>
#include <numeric>
#include <cmath>

using namespace std;

template<class T>
class Input {
public:
    auto operator()() const {
        T v;
        cin >> v;
        return v;
    }
};

template<class L, class R>
class Input<pair<L, R>> {
public:
    auto operator()() const {
        L l;
        R r;
        cin >> l >> r;
        return make_pair(l, r);
    }
};

template<class U>
class Input<vector<U>> {
public:
    auto operator()() const {
        Input<size_t> in{};
        auto n = in();
        return (*this)(n);
    }
    auto operator()(size_t n) const {
        vector<U> v;
        v.reserve(n);
        Input<U> in{};
        for (size_t i = 0; i < n; ++i) {
            auto u = in();
            v.emplace_back(move(u));
        }
        return v;
    }
};

template<class U>
class Input<vector<vector<U>>> {
public:
    auto operator()() const {
        Input<size_t> in{};
        auto n = in();
        auto m = in();
        return (*this)(n, m);
    }
    auto operator()(size_t n, size_t m) const {
        vector<vector<U>> v;
        v.reserve(n);
        Input<vector<U>> in{};
        for (size_t i = 0; i < n; ++i) {
            auto u = in(m);
            v.emplace_back(move(u));
        }
        return v;
    }
};

class InputType
{
public:
    template<class T>
    operator T() const {
        Input<T> i{};
        return i();
    }
};

auto input() {
    return InputType();
}

size_t bitcount(size_t n) {
    size_t c = 0;
    while (n) {
        if (n & 1ull)
            ++c;
        n >>= 1;
    }
    return c;
}

auto make_order(size_t n) {
    vector<size_t> a(n, 0);
    iota(begin(a), end(a), 0);
    return a;
}

template<class T>
auto next_permutation(T&& x) {
    using std::begin;
    using std::end;
    return next_permutation(begin(x), end(x));
}

using ll = long long;
using ull = unsigned long long;

int main() {
    string s = input();
    size_t q = input();
    string b{};
    string e{};
    b.reserve(q);
    e.reserve(q);
    bool isRev = false;
    for (size_t i = 0; i < q; ++i) {
        size_t t = input();
        if (t == 1)
            isRev = !isRev;
        else {
            size_t f = input();
            string c = input();
            if (f == 1) {
                if (isRev) {
                    e.append(c);
                } else {
                    b.append(c);
                }
            } else {
                if (isRev) {
                    b.append(c);
                } else {
                    e.append(c);
                }
            }
        }
    }
    if (isRev) {
        for (auto it = rbegin(e); it != rend(e); ++it) {
            cout << *it;
        }
        for (auto it = rbegin(s); it != rend(s); ++it) {
            cout << *it;
        }
        cout << b;
    } else {
        for (auto it = rbegin(b); it != rend(b); ++it) {
            cout << *it;
        }
        cout << s;
        cout << e;
    }
    return 0;
}


Measured memory_bytes: 1024
#include<iostream>
#include<string>
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
int main(void){
    for(;;){
	int m,d;
	int data[]={0,31,29,31,30,31,30,31,31,30,31,30,31};
	cin>>m>>d;
	if(m==0&&d==0)break;
	for(int i=1;i<=m;i++){
        d+=data[i-1];
	}
	switch(d%7){
	case 0: cout << "Wednesday" << endl; break;
    case 1: cout << "Thursday" << endl;break;
    case 2: cout << "Friday" << endl;break;
    case 3: cout << "Saturday" << endl;break;
    case 4: cout << "Sunday" << endl;break;
    case 5: cout << "Monday" << endl;break;
    case 6: cout << "Tuesday" << endl;
    }




    }




	return 0;
}

Measured memory_bytes: 1152
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;
//マクロ
//forループ関係
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
//Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
//xにはvectorなどのコンテナ
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x)) //最大値を求める
#define MIN(x) *min_element(ALL(x)) //最小値を求める
//定数
#define INF 1000000000000 //10^12:極めて大きい値,∞
#define inf 2,147,483,647 //int値の最大値
#define MOD 1000000007 //10^9+7:合同式の法
#define MAXR 100000 //10^5:配列の最大のrange(素数列挙などで使用)
//略記
#define PB push_back //vectorヘの挿入
#define MP make_pair //pairのコンストラクタ
#define F first //pairの一つ目の要素
#define S second //pairの二つ目の要素
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;
}
int gcd(int a, int b) {
    if (b==0) return a;
    else return gcd(b, a%b);
}
int lcm(int a, int b) {
    return a * b / gcd(a, b);
}
int main() {
    long double a,b,c;cin>>a>>b>>c;
    long double l=2*sqrt(a*b);
    if(a+b+l<c){
        cout<<"Yes"<<endl;
    }else{
        cout<<"No"<<endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
	ios::sync_with_stdio(false);
	int n,a,b,c,d;cin >> n >> a >> b >> c >> d;
	string s;
	cin >> s;s='?'+s;
	for(int i=a; i<c ;i++){
		if(s[i]=='#' && s[i+1]=='#') return cout << "No\n",0;
	}
	for(int i=b; i<d ;i++){
		if(s[i]=='#' && s[i+1]=='#') return cout << "No\n",0;
	}
	if(c<d) return cout << "Yes\n",0;
	for(int i=b-1; i<d ;i++){
		if(s[i]=='.' && s[i+1]=='.' && s[i+2]=='.') return cout << "Yes\n",0;
	}
	return cout << "No\n",0;
}

Measured memory_bytes: 720
import Data.Maybe
import Data.List

main :: IO ()
main = do
  input <- getContents
  putStrLn $ trim (solve (trim input))

--処理
solve :: String -> String
solve s = show $ (min n k) * x + (max 0 (n - k)) * y
  where [n, k, x, y] = fmap read (lines s) :: [Int]

trimHead :: String -> String
trimHead = dropWhile (\s -> isJust (elemIndex s [' ', '\t', '\n', '\r']))

trim :: String -> String
trim = reverse . trimHead . reverse . trimHead

Measured memory_bytes: 508
#include <bits/stdc++.h>
    #include <math.h>
 
    using namespace std;
    typedef long long ll;
    typedef unsigned long long ull;
    # define M_PI  3.14159265358979323846
 
 
    const int M=1e9+7;
    long long mod(long long x){
        return ((x%M + M)%M);
    }
    long long add(long long a, long long b){
        return mod(mod(a)+mod(b));
    }
 
    vector<ll>a(5005);
    vector<ll>b(5005);
    vector<ll>track;
    bool vis[5005];

    void dfs(int u , long long total_cycle){
        if(vis[u]) return ;
        vis[u]=true;
        total_cycle+=b[u];
        track.push_back(total_cycle);
        dfs(a[u],total_cycle);
    }
    void solve(){
        int n,k;
        cin>>n>>k;
        for(int i=0;i<n;i++){
            cin>>a[i];
            a[i]--;
        }
        for(int i=0;i<n;i++)
            cin>>b[i];
        ll ans=-(1e18);
        for(int i=0;i<n;i++){
            memset(vis,false,sizeof(vis));
            dfs(i,0);
            if(track.back()>0 && k>=(int)(track.size())){
                ll cycles=(ll)(k/(int)track.size());
                ll left=(ll)(k%(int)track.size());
                ll maxi=-1e18;
                for(int x=0;x<(int)track.size();x++)
                    maxi=max(maxi,track[x]);
                ans=max(ans,(cycles-1LL)*(track.back())+maxi);
                maxi=-1e18;
                for(int x=0;x<left;x++)
                    maxi=max(maxi,track[x]);
                ans=max(ans,(cycles*track.back()) + maxi);
            }
            else{
                for(int j=0;j<(min((int)track.size(),k));j++){
                    ans=max(ans,track[j]);
                }
            }
            track.clear();
        }
        cout<<ans;
        return;
    }
    int main(){
        ios::sync_with_stdio(0);
        cin.tie(0);
        cout.tie(0);
        cout<<fixed;
        cout<<setprecision(10);
//        freopen("timber_input.txt", "r", stdin);
//        freopen("timber_output.txt", "w", stdout);
        int t=1;
        // cin>>t;
        for(int i=1;i<=t;i++){
//            cout<<"Case #"<<i<<": ";
            solve();
        }
        return 0;
    }

Measured memory_bytes: 3896
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repi(i, s, n) for (int i = (s); i < (n); i++)
#ifdef LOCAL
#define INPUT_FILE                   \
  ifstream in("atcoder-problems/abc137_b.txt"); \
  cin.rdbuf(in.rdbuf());
#define print_vec(v) \
rep(l, v.size()) { cout << v[l] << " "; } \
cout << endl;
#else
#define INPUT_FILE
#define print_vec(v)
#endif
#define CIN_OPTIMIZE \
  cin.tie(0);        \
  ios::sync_with_stdio(false);
typedef pair<int, int> P;
typedef long long ll;
typedef pair<ll, ll> pl;
const int INF = 100100100;
const ll LINF = 1e18+100;
const int MOD = 1e9 + 7;

int main() {
  INPUT_FILE CIN_OPTIMIZE;

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

  repi(i, X - K + 1, X + K) { cout << i << endl; }
}

Measured memory_bytes: 3640
#include <string>
#include <vector>
#include <iostream>
#include <iomanip>
#include <cmath>
#include <algorithm>
#include <functional>
#include <utility>
#include <map>
using namespace std;


#define prec(i) cout << fixed << setprecision(i)

const long long int MOD = 1000000007;


int ctoi(char c) {
	if (c >= '0' && c <= '9')
		return c - '0';
	else
		return -1;
}



int main()
{
	long long int n, ans;

	cin >> n;

	if (n % 2 == 0)
		ans = (n - 1) * (n / 2);
	else
		ans = ((n - 1) / 2) * n;

	cout << ans << endl;

	return 0;

}

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <string>
#include <cstring>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <cmath>
#include <iomanip>
#include <cassert>
#include <bitset>
using namespace std;

typedef pair<int, int> P;
#define rep(i, n) for (int i=0; i<(n); i++)
#define all(c) (c).begin(), (c).end()
#define uniq(c) c.erase(unique(all(c)), (c).end())
#define index(xs, x) (int)(lower_bound(all(xs), x) - xs.begin())
#define _1 first
#define _2 second
#define pb push_back
#define INF 1145141919
#define MOD 1000000007

int N;
vector<int> G[100000];
int T[100000], R[100000];
long long S[100000];
long long A[100000];
map<P, long long> cost;

void dfs(int x, int p, int r) {
  T[x] = 1;
  R[x] = r;
  for (int t : G[x]) {
    if (t == p) continue;
    dfs(t, x, r+1);
    T[x] += T[t];
  }
}

long long dfs2(int x, int p, long long d) {
  long long s = d;
  for (int t : G[x]) {
    if (t == p) continue;
    s += dfs2(t, x, d+cost[P(x, t)]);
  }
  return s;
}

signed main() {
  ios::sync_with_stdio(false); cin.tie(0);
  cin >> N;
  vector<P> edges;
  rep(i, N-1) {
    int u, v;
    cin >> u >> v;
    u--, v--;
    G[u].pb(v);
    G[v].pb(u);
    edges.pb(P(u, v));
  }
  rep(i, N) cin >> S[i];
  dfs(0, -1, 0);
  P g = P(-1, -1); int gi = -1;

  rep(i, N-1) {
    int u, v; tie(u, v) = edges[i];
    if (R[u] > R[v]) swap(u, v);
    long long diff = abs(S[u]-S[v]);
    int d = abs(T[v]-(N-T[v]));
    if (d == 0) {
      g = P(u, v);
      gi = i;
      continue;
    }
    assert(diff%d == 0);
    A[i] = diff/d;
    cost[P(u, v)] = cost[P(v, u)] = A[i];
  }
  if (gi != -1) {
    int u = g._1, v = g._2;
    long long diff = S[u] - dfs2(u, -1, 0);
    assert(diff%T[v] == 0);
    A[gi] = diff/T[v];
  }
  rep(i, N-1) cout << A[i] << "\n";
  return 0;
}


Measured memory_bytes: 29812
import java.util.Scanner;

/**
 *
 * @author lenovo
 */
public class Main {

    public static void main(String[] args) {

        Scanner scanner = new Scanner(System.in);
        int a = scanner.nextInt();
        int b = scanner.nextInt();
        if (a > b) {
            System.out.println("a > b");
        } else if (a < b) {
            System.out.println("a < b");
        } else {
            System.out.println("a == b");

        }
    }
}

Measured memory_bytes: 26268
#include<deque>
#include<list>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<vector>
#include<algorithm>
#include<string>
#include<iostream>
#include<sstream>
#include<cmath>
#include<cstring>
using namespace std;
int main(){
  int i,j,k,l,m;
  int n;
  cin>>n;
  for(i=0;i<n;++i){
    int a[7][7],b[6]={};
    memset(a,-1,sizeof(a));
    for(j=1;j<=5;++j){
      for(k=1;k<=5;++k){
	cin>>a[j][k];
	if(a[j][k])
	  b[a[j][k]-1]++;
      }
    }
    for(j=0;j<6;++j){
      if(b[j]!=1)
	break;
    }
    if(j<6){
      cout<<"false"<<endl;
    }else{
      int c[7][7];
      memset(c,-1,sizeof(c));
      for(j=1;j<=5;++j){
	for(k=1;k<=5;++k){
	  if(a[j][k]&&c[j][k]){
	    int dx[4]={-1,0,1,0},dy[4]={0,-1,0,1};
	    for(l=0;l<4;++l){
	      for(m=0;;++m){
		if(a[j+dy[l]+dx[l]*m][k+dx[l]+dy[l]*m]>0){
		  if(a[j+dy[l]*2+dx[l]*m][k+dx[l]*2+dy[l]*m]>0&&c[j+dy[l]*2+dx[l]*m][k+dx[l]*2+dy[l]*m]&&a[j][k]+a[j+dy[l]*2+dx[l]*m][k+dx[l]*2+dy[l]*m]==7){
		    c[j][k]=c[j+dy[l]*2+dx[l]*m][k+dx[l]*2+dy[l]*m]=0;
		    break;
		  }
		}else{
		  break;
		}
	      }
	      if(c[j][k]==0)
		break;
	      for(m=0;;++m){
		if(a[j+dy[l]-dx[l]*m][k+dx[l]-dy[l]*m]>0){
		  if(a[j+dy[l]*2-dx[l]*m][k+dx[l]*2-dy[l]*m]>0&&c[j+dy[l]*2-dx[l]*m][k+dx[l]*2-dy[l]*m]&&a[j][k]+a[j+dy[l]*2-dx[l]*m][k+dx[l]*2-dy[l]*m]==7){
		    c[j][k]=c[j+dy[l]*2-dx[l]*m][k+dx[l]*2-dy[l]*m]=0;
		    break;
		  }
		}else{
		  break;
		}
	      }
	      if(c[j][k]==0)
		break;
	    }
	    if(l==4)
	      break;
	  }
	}
	if(k<=5)
	  break;
      }
      if(j>5)
	cout<<"true"<<endl;
      else
	cout<<"false"<<endl;
    }
  }
  return 0;
}

Measured memory_bytes: 0
import java.util.Scanner;
import java.util.Set;

public class Main {

	/** 母音の文字の一覧 */
	private static final Set<String> SET = Set.of("a", "e", "i", "o", "u");

	public static void main(String[] args) {
		try (Scanner scanner = new Scanner(System.in)) {
			String s = scanner.next();
			System.out.println(SET.contains(s) ? "vowel" : "consonant");
		}
	}
}


Measured memory_bytes: 35632
#include<iostream>
#include<cstdlib>
#include<cstring>
#include<stack>
#include<queue>
#include<algorithm>
#include<vector>
#include<math.h>
#include<bitset>
#include<iomanip>
#include<numeric>
#include<list>
using namespace std;

typedef stack<int> IntStack;
typedef queue<int> IntQueue;

const double pi = 3.141592653589793;


//最大公約数
template<class T> T gcd(T a, T b)
{
	while (true)
	{
		T r;
		if (a%b == 0) return b;
		else
		{
			r = a % b;
			a = b;
			b = r;
		}
	}
}
//最小公倍数
template<class T> T lcm(T a, T b)
{
	return a / gcd(a, b)*b;
}
//文字0~9をint型0~9に変換
int char_to_int(char c)
{
	if (c == '0') return 0;
	if (c == '1') return 1;
	if (c == '2') return 2;
	if (c == '3') return 3;
	if (c == '4') return 4;
	if (c == '5') return 5;
	if (c == '6') return 6;
	if (c == '7') return 7;
	if (c == '8') return 8;
	if (c == '9') return 9;
	else return -1;
}
//int型0~9を文字0~9に変換
char int_to_char(int c) {
	if (c == 0) return '0';
	if (c == 1) return '1';
	if (c == 2) return '2';
	if (c == 3) return '3';
	if (c == 4) return '4';
	if (c == 5) return '5';
	if (c == 6) return '6';
	if (c == 7) return '7';
	if (c == 8) return '8';
	if (c == 9) return '9';
	else return'x';
}
//a^b mod MODを計算
long long int ModPower(long long int a, long long int b, long long int MOD)
{
	if (b == 0) return 1;
	else if (b % 2 == 0)
	{
		long long int d = ModPower(a, b / 2, MOD);
		return (d*d) % MOD;
	}
	else
	{
		return (a*ModPower(a, b - 1, MOD)) % MOD;
	}
}
//nCr mod MODを計算
long long int ModCombi(long long int n, long long int r, long long int MOD)
{
	if (n == 0 || r == 0) return 1;

	long long int Kn = 1, Kr = 1, Knr = 1;

	long long int temp = 1;
	for (long long int i = 1; i <= n; i++)
	{
		temp *= i;
		temp %= MOD;
		if (i == n) Kn = temp;
		if (i == r) Kr = temp;
		if (i == n - r) Knr = temp;
	}

	long long int x = ModPower(Kr, MOD - 2, MOD);
	long long int y = ModPower(Knr, MOD - 2, MOD);

	long long int ans;
	ans = Kn * x;
	ans %= MOD;
	ans *= y;
	ans %= MOD;

	return ans;
}
//int型10進数をord桁のstring型2進数に変換する
string binary(int x, int ord)
{
	int y;
	string ans = "";
	for (int i = 0; i < ord; i++)
	{
		y = x / (int)pow(2, ord - 1 - i);
		y %= 2;
		if (y == 0) ans += "0";
		else ans += "1";
	}

	return ans;
}
//ord桁のstring型2進数をint型10進数に変換する
int rep_binary(string x, int ord)
{
	int res = 0;
	for (int i = 0; i < ord; i++)
	{
		if (x[i] == '1') res += (int)pow(2, ord - 1 - i);
	}
	return res;
}
//xとyのビットごとの排他的論理和
template<class T> T XOR(T x, T y)
{
	T n = 0;
	while (max(x, y) > pow(2, n)) n++;
	T ans=0;
	for (int i = 0; i <= n; i++)
	{
		T x1 = (x % (T)pow(2, i + 1)) / (T)pow(2, i);
		T y1 = (y % (T)pow(2, i + 1)) / (T)pow(2, i);
		if (x1 != y1) ans += (T)pow(2, i);
	}
	return ans;
}

/*ここまでテンプレ*//*ここまでテンプレ*//*ここまでテンプレ*//*ここまでテンプレ*/


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

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

using namespace std;

int main() {
    int N, M; cin >> N >> M;
    bool graph[10][10] = {};
    bool turn_on_odd[10] = {};
    for(int i = 0; i < M; i++) {
        int k; cin >> k;
        for(int j = 0; j < k; j++) {
            int l; cin >> l;
            graph[i][l-1] = true;
        }
    }

    for(int i = 0; i < M; i++) {
        int s; cin >> s;
        if(s) turn_on_odd[i] = true;
        else turn_on_odd[i] = false;
    }

    int m = 0;
    for(int i = 0; i < pow(2, N); i++) {
        // cout << "SUM: " << i << endl;
        vector<int> S = {};

        for (int j = 0; j < N; j++) {
            if (i & (1<<j)) {
                S.push_back(j);
                // cout << "light: " << j << endl;
            }
        }

        // ついている電球の個数を求める
        int count = 0;
        // 電球i
        for(int i = 0; i < M; i++) {

            // つながっているswitchの数
            int switch_sum = 0;
            // スイッチj
            for(int j = 0; j < N; j++) {
                if(graph[i][j] && find(S.begin(), S.end(), j) != S.end()) switch_sum++;
            }

            if(switch_sum % 2 == 1 && turn_on_odd[i]) count++;
            else if(switch_sum % 2 == 0 && !turn_on_odd[i]) count++;
            // cout << "switch_sum: " << switch_sum << endl;
        }

        if(count == M) m++;
    }

    cout << m << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define LL long long
using namespace std;
const int N=2e6+1000;
const LL P=1e9+7;
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;
}
void print(int x){
    if(x>9) print(x/10);
    putchar(x%10+'0');
}
int n,m;
int f[N],sz[N];
int find(int x){
	if(f[x]==x) return x;
	else return f[x]=find(f[x]);
}
int main(){
	scanf("%d%d",&n,&m);
	for(int i=1;i<=n;++i){
		f[i]=i;
		sz[i]=1;
	}
	int u,v;
	for(int i=1;i<=m;++i){
		scanf("%d%d",&u,&v);
		u=find(u);v=find(v);
		if(u==v) continue;
		f[u]=v;
		sz[v]+=sz[u];
	}
	int ans=0;
	for(int i=1;i<=n;++i){
		u=find(i);
		ans=max(ans,sz[u]);
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 11324
#include<iostream>
#include<stdio.h>
int cnt=0;
void inSort(int A[],int n,int g){
  int i,j,v;
  for(i=g;i<n;i++){
    v=A[i];
    j=i-g;
    while(j>=0 && A[j]>v){
      A[j+g]=A[j];
      j-=g;
      cnt++;
    }
    A[j+g]=v;
  }
}
void shSort(int A[],int n){
  int i,j,k,l,G[20];

  int m=0; for(i=1;i<=n;i=i*3+1) G[m++]=i;

  for(i=m-1;0<=i;i--) inSort(A,n,G[i]);

  printf("%d\n%d",m,G[m-1]);
  for(i=m-2;0<=i;i--) printf(" %d",G[i]);
  printf("\n%d\n",cnt);
  for(i=0;i<n;i++) printf("%d\n",A[i]);
}
int main(){
  int i,n,A[1000000];
  std::cin>>n;
  for(i=0;i<n;i++) std::cin>>A[i];
  shSort(A,n);
  return 0;
}

Measured memory_bytes: 6964
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define ll long long
#define rep(i,n) for (int i = 0; i < n; i++)
#define vl vector<ll>
#define vpl vector<pair<ll,ll>>
#define vvl vector<vector<ll>> //a(縦行,vector<ll>(横列));
#include<algorithm>//__gcd(a,b)

int main(){
 ll k,a,b;
cin>>k>>a>>b;
 bool ans=0;

 for(ll i=a;i<=b;i++){

     if(i%k==0){ans=1;break;}
 }

 if(ans==1){cout<<"OK"<<endl;}
 if(ans==0){cout<<"NG"<<endl;}

}

Measured memory_bytes: 3636
#include <stdio.h>
#include <math.h>
#include <stdlib.h>

#define xy fabs(x[j]-y[j])

int main(void)
{
    int i,j,n;
    double x[1010]={0},y[1010]={0},max=0,p1,p2,p3;
    
    scanf("%d",&n);
    for(j=0;j<n*2;j++){
        if(j<n) scanf("%lf",&x[j]);
        else scanf("%lf",&y[j-n]);
    }
    
    for(j=0;j<n;j++){
        p1+=xy;
        p2+=pow(xy,2);
        p3+=pow(xy,3);
        if(xy>max)max=xy;
    }
    p2=sqrt(p2);
    p3=cbrt(p3);
    printf("%f\n%f\n%f\n%f\n",p1,p2,p3,max);
    
    return 0;
}


Measured memory_bytes: 2044
#include<bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define SZ(x) ((int)x.size())
#define L(i,u) for (register int i=head[u]; i; i=nxt[i])
#define rep(i,a,b) for (register int i=(a); i<=(b); i++)
#define per(i,a,b) for (register int i=(a); i>=(b); i--)
using namespace std;
typedef long long ll;
typedef unsigned int ui;
typedef pair<int,int> Pii;
typedef vector<int> Vi;
template<class T> inline void read(T &x){
	x=0; char c=getchar(); int f=1;
	while (!isdigit(c)) {if (c=='-') f=-1; c=getchar();}
	while (isdigit(c)) {x=x*10+c-'0'; c=getchar();} x*=f;
}
template<class T> inline void umin(T &x, T y){x=x<y?x:y;}
template<class T> inline void umax(T &x, T y){x=x>y?x:y;}
inline ui R() {
	static ui seed=416;
	return seed^=seed>>5,seed^=seed<<17,seed^=seed>>13;
}
const int N = 1002000,mo=1e9+7;
int n,cnt[N],res=1;char s[N];
int main() {
	read(n);scanf("%s",s+1);
	rep(i,1,n)cnt[s[i]-'a']++;
	rep(i,0,25)res=1LL*res*(cnt[i]+1)%mo;
	res=(res-1+mo)%mo;cout<<res;
	return 0;
}


Measured memory_bytes: 384
import java.util.Scanner;

public class Main {

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

	    int input1 = scanner.nextInt();
	    int input2 = scanner.nextInt();

	    if(input1<=8 && input2<=8){
	    	System.out.println("Yay!");
	    } else System.out.println(":(");

	    scanner.close();
    }

}


Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (ll)n; ++i)
static const int dx[4] = { 0, 1, 0, -1 };
static const int dy[4] = { 1, 0, -1, 0 };
static const char dir[4] = { 'u', 'r', 'd', 'l' };
static const ll INF = 1 << 21;
static const ll MOD = 1e9 + 7;

int N, Q, K;
const int limit = 100010;
using edge = struct {
    int to;
    ll cost;
};
vector<edge> tree[limit]; // 隣接リスト
ll depth[limit];

// あるノードの距離を決める
// cur:現在の頂点, p: curの親ノード, d: 現在の距離
void dfs(int cur, int p, ll d)
{
    depth[cur] = d;
    for (auto& e : tree[cur]) { // 隣接するノードの距離を更新
        if (e.to == p) {
            continue;
        }
        dfs(e.to, cur, d + e.cost);
    }
    return;
}

signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cin >> N;
    rep(i, N-1)
    {
        int a, b, c;
        cin >> a >> b >> c;
        --a, --b;
        tree[a].push_back({ b, c });
        tree[b].push_back({ a, c });
    }
    cin >> Q >> K;
    --K;
    dfs(K, -1, 0);
    rep(i, Q)
    {
        int x, y;
        cin >> x >> y;
        --x, --y;
        cout << depth[x] + depth[y] << endl;
    }

    return 0;
}

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

int main(){
    ll n,m,start=0,end=1e5,count=0;
    cin >> n >> m;
    vector<ll> l(m),r(m);
    rep(i,m){
        cin >> l[i] >> r[i];
    }
    rep(i,m){
        if(l[i] > start) start = l[i];
        if(r[i] < end) end = r[i];
    }
    if(n<start){
        cout << '0' << endl;
        return 0;
    }
    if(n>=start && n<=end){
        for (int i = start;i <= n; i++) count++;
    }
    if(n>end){
        for (int i = start;i <= end; i++) count++;
    }
    cout << count << endl;
    return 0;
}

Measured memory_bytes: 1792
#ifdef ConanYu
#include "local.hpp"
#else
#pragma GCC optimize("-O3")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
void Main();
#define debug(...) do { } while(0)
int main() {
  ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
  Main();
}
#endif

const int N = 66666, MOD = 1e9 + 7;
vector<int> v;

int base[2][N], len[N];

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

void upd(int id, int at, int x) {
  for(int i = at; i < int(v.size()); i += i & (-i)) {
    add(base[id][i], x);
  }
}

int sum(int id, int at) {
  int ans = 0;
  for(int i = at; i > 0; i -= i & (-i)) {
    add(ans, base[id][i]);
  }
  return ans;
}

void Main() {
  int n, k; cin >> n >> k;
  v.push_back(1);
  for(int i = 1, j; i <= n; i = j + 1) {
    j = n / (n / i);
    v.push_back(j + 1);
  }
  for(int i = 0; i + 1 < int(v.size()); i++) {
    len[i] = v[i + 1] - v[i];
  }
  upd(0, 1, 1);
  for(int q = 1; q <= k; q++) {
    for(int i = 1; i < int(v.size()); i++) {
      base[q & 1][i] = 0;
    }
    int cur = 1, whe = int(v.size()) - 1;
    for(int i = 1, j; i <= n; i = j + 1, cur++, whe--) {
      j = n / (n / i);
      upd(q & 1, cur, 1ll * sum(~q & 1, whe) * len[cur - 1] % MOD);
    }
  }
  cout << sum(k & 1, int(v.size()) - 1) << "\n";
}


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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

#define INF 1<<30
#define LINF 1ll<<60ll
#define MOD 1000000007
#define pb(a) push_back(a)

#define _overload3(_1,_2,_3,_4,name,...) name
#define _rep(i,n) _repi(i,0,n)
#define _repi(i,a,b) for(int i=a, i##_len=(b); i<i##_len; ++i)
#define _repis(i,a,b,s) for(int i=a, i##_len(b); i<i##_len; i+=s)
#define REP(...) _overload3(__VA_ARGS__,_repis,_repi,_rep,)(__VA_ARGS__)

#define REPR(i, n) for(int i = n;i >= 0;--i)
#define REPARR(i, v) for(int i = 0;i < sz(v);++i)

#define all(vec) (vec.begin()),(vec.end())
#define sz(x) ((int)(x).size())
#define bit(n) (1ll<<(n))

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

#define YES(n) cout<<((n)?"YES":"NO")<<endl
#define Yes(n) cout<<((n)?"Yes":"No")<<endl
#define yes(n) cout<<((n)?"yes":"no")<<endl
#define poss(n) cout<<((n)?"possible":"impossible")<<endl
#define Poss(n) cout<<((n)?"Possible":"Impossible")<<endl
#define POSS(n) cout<<((n)?"POSSIBLE":"IMPOSSIBLE")<<endl



int main(){
    regex re("^A?KIHA?BA?RA?$");
    string s;
    cin>>s;
    YES(regex_match(s,re));
    return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cmath>
#include<iostream>
#include<cstring>
#include<string>
typedef long long ll;
using namespace std;

char a[100000];
int main()
{
	int a,b,h,S;
	scanf("%d%d%d",&a,&b,&h);
	S = (a + b) * h / 2;
	printf("%d\n",S);
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;
typedef pair<ll,ll> pll;
const ll mod=1e9+7;
//const ll mod=998244353;
const ll inf=1LL<<61;

int main() {
  ll n,m;
  cin >> n >> m;
  vec s(n),t(m);
  for(ll i=0;i<n;i++) cin >> s[i];
  for(ll i=0;i<m;i++) cin >> t[i];
  mat sum(n+1,vec(m+1,0));
  mat dp(n+1,vec(m+1,0));
  for(ll i=0;i<n;i++) {
    for(ll j=0;j<m;j++) {
      if(s[i]==t[j]) {
        dp[i+1][j+1]=(sum[i][j]+1)%mod;
      }
      sum[i+1][j+1]=(sum[i+1][j]+sum[i][j+1]-sum[i][j]+dp[i+1][j+1]+mod)%mod;
    }
  }
  cout << (sum[n][m]+1)%mod << endl;
}

Measured memory_bytes: 62976
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define REP(i,m,n) for(int i=(int)(m); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define rrep(i,n) RREP(i,(n)-1,0)
#define all(v) v.begin(), v.end()
#define endk '\n'
const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;
const ld eps = 1e-10;
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;}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  ld a, b, x; cin >> a >> b >> x;
  cout << fixed << setprecision(10);
  if(x <= a*a*b/2) {
    ld d = x*2/a/b;
    ld angle = atan2(b, d);
    cout << angle*180/M_PI << endk;
  } else {
    ld d = (a*a*b-x)*2/a/a;
    ld angle = atan2(d, a);
    cout << angle*180/M_PI << endk;
  }
  return 0;
}


Measured memory_bytes: 3888
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
   
public class Main {
	public static final double PI = 3.141592653589793;
	
    public static void main( String args[] ) throws IOException {
		BufferedReader bufRed	= new BufferedReader( new InputStreamReader( System.in ) );
        String[] dat			= bufRed.readLine().split( " " );
        int a, b, C;
		a = Integer.parseInt(dat[0]);
        b = Integer.parseInt(dat[1]);
        C = Integer.parseInt(dat[2]);
		
		final double radianC	= C * PI / 180.0;
		final double ab				= a * b;
          
        final double sinC = Math.sin( radianC );
        final double cosC = Math.cos( radianC );
          
          
        // S
        double S = ab * sinC / 2;
          
        // L
        double L = a + b + Math.sqrt( a * a + b * b - 2 * ab * cosC );
          
        // h
        double h = b * sinC;
          
        System.out.print(S + "\n" + L + "\n" + h + "\n");
          
    }
      
}

Measured memory_bytes: 16924
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (n); ++i)
int main(void){
    int n;
    cin >> n;
    vector<int> a(n);
    rep(i,n) {
        cin >> a[i];
        a[i]--;
    }
    int ans = 0;
    rep(i,n) {
        if (i == a[a[i]]) {
            ans++;
        }
    }
    cout << ans / 2 << endl;
}


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


int main() {
  int H, W;
  cin >> H >> W;
  vector<vector<char>> a(H, vector<char>(W));
  int w,l;
  for (int i = 0; i < H; i++) {
    for (size_t j = 0; j <W; j++)
    {
        cin>> a.at(i).at(j);
    }
   }
   
    vector<char> allwhite (W,'.');
    vector<char> allnull (W,'n');
   for (size_t i = 0; i < H; i++)
   {
       if (a.at(i)==allwhite)
       {a.at(i)=allnull;
       }
   };
   
   bool Allwhite=true;
//jは高さ iは横
   for (size_t i = 0; i < W; i++)
   {
       for (size_t j = 0; j < H; j++)
       {
        if(a.at(j).at(i)=='#')
        {Allwhite=false;}
       }
      if(Allwhite)
      {
          for (size_t j = 0; j < H; j++)
          {
            a.at(j).at(i)='n';
          }
      }
      Allwhite="true";
   }

    for (size_t i = 0; i < H; i++)
    {
        for (size_t j = 0; j < W; j++)
        {
        if(a.at(i).at(j)!='n')
        cout <<a.at(i).at(j);
        if(j==W-1&&a.at(i)!=allnull)
        cout << endl;
            
        }
        
    }
    
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
using namespace std;
int main()
{
	string s;
	vector<int> pe, ap;
	int n;
	getline(cin, s);
	pe.push_back(0);
	ap.push_back(0);
	while(n=s.find("peach", pe.back() + 5), ~n)
		pe.push_back(n);
	while(n=s.find("apple", ap.back() + 5), ~n)
		ap.push_back(n);
	for(int i = 1; i < pe.size(); i++)
		s.replace(pe[i], 5, "apple");
	for(int i = 1; i < ap.size(); i++)
		s.replace(ap[i], 5, "peach");
	cout<<s<<endl;
	return 0;
}

Measured memory_bytes: 1204
#include<stdio.h>

int main(){

	int a;
	scanf("%d",&a);
	for(int i=0;i<a;i++){
		int b;
		
		scanf("%d",&b);
		printf("Case %d:\n",i+1);
		for(int j=0;j<10;j++){
			b=((b*b)%1000000/100);
			printf("%d\n",b);
		}
	}
} 

Measured memory_bytes: 0
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define M (1000000007)
#define N (100010)
int n,a[N];
ll all,ans[N],sum1[N<<1],sum2[N<<1];

int main(){
	scanf("%d",&n);
	for (int i=1;i<=n;i++) scanf("%d",&a[i]);
	for (int i=1;i<=n;i++) all+=a[i];
	for (int i=1;i<=n;i++){
		if (i&1) sum1[i]=sum1[i-2]+a[i];
		else sum2[i]=sum2[i-2]+a[i];
	}
	for (int i=1;i<=n;i++){
		if (i&1) sum2[i+n]=sum2[i+n-2]+a[i];
		else sum1[i+n]=sum1[i+n-2]+a[i];
	}
	for (int i=1;i<=n;i++){
		if (i&1) ans[i]=all-(sum2[n+i-2]-sum2[i-1])*2;
		else ans[i]=all-(sum1[n+i-2]-sum1[i-1])*2;
	}
	for (int i=1;i<=n;i++) printf("%lld ",ans[i]);
}


Measured memory_bytes: 5632
#include <iostream>
#include <vector>
#include <cstring>



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

using namespace std;

int main(){
    string A,B;
    cin >> A >> B;

    string res = "EQUAL";

    if( A.size() > B.size())
    {
        res = "GREATER";
    }
    else if(A.size() < B.size())
    {
        res = "LESS";
    }
    else
    {
        REP(i,A.size())
        {
            if(A[i] == B[i])continue;
            else if(A[i] > B[i])
            {
                res = "GREATER";
                break;
            }
            else
            {
                res = "LESS";
                break;
            }
        }
    }
    
    cout << res << endl;
}




Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int n,x,a[100005],ans;
int main()
{
	cin>>n;
	for (int i=1;i<=n;++i)
	{
		cin>>x;
		if (x!=0)
			++a[x-1];
		++a[x];
		++a[x+1];
	}
	ans=1;
	for (int i=0;i<=100000;++i)
		ans=max(ans,a[i]);
	cout<<ans;
}

Measured memory_bytes: 640