akhauriyash/Code-Regression huggingface dataset:
#if 0 
楽をするためにイテレータを用いた。
#endif
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <assert.h>
#include <complex>
#include <memory>
typedef long long ll;
#define REP(i,n) for(int i=0;i<n;i++)
using namespace std;

class MinMaxSolver {
    vector<int> vec_;
public:
    void setup();
    int min() {
        int min = 1000001;
        for (auto e : vec_) {
            if (e < min) {
                min = e;
            }
        }
        return min;
    }
    int max() {
        int max = -1000001;
        for (auto e : vec_) {
            if (e > max) {
                max = e;
            }
        }
        return max;
    }
    ll sum() {
        ll sum = 0;
        for (auto e : vec_) {
            sum += e;
        }
        return sum;
    }
    void solve();
};
void MinMaxSolver::setup() {
    int tmp;
    cin >> tmp;

    while (cin >> tmp) {
        vec_.push_back(tmp);
    }
}
void MinMaxSolver::solve() {
    setup();
    string sp = " ";
    cout << min() << sp << max() << sp << sum() << endl;
}

int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);
    // ll も int も longlongにしてしまう
    #define int long long

    shared_ptr<MinMaxSolver> solver(new MinMaxSolver());
    solver->solve();

    return 0;
}


Measured memory_bytes: 3312
/* 
  Krishnakant Tiwari
  Problem Link:
  
 */
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimization("unroll-loops")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define _cin                      \
    ios_base::sync_with_stdio(0); \
    cin.tie(0);
#define endl "\n"
#define pb push_back
#define rep(i, a, b) for (ll i = a; i < b; ++i)
#define repd(i, a, b) for (ll i = a; i >= b; --i)
#define mp make_pair
#define hell 1000000007
#define vvll vector<vector<ll>>
#define vll vector<ll>
#define mll map<ll, ll>
#define sz(x) (ll) x.size()
#define sll set<ll>
#define pll pair<ll, ll>
#define F first
#define S second
#define eb emplace_back
#define ppb pop_back
#define pf push_front
#define ppf pop_front
#define all(x) x.begin(), x.end()
#define clr(x) memset(x, 0, sizeof(x))
#define sortall(x) sort(all(x))
#define tr(it, a) for (auto it = a.begin(); it != a.end(); it++)
#define PI 3.1415926535897932384626
#define deb(x) cout << #x << "=" << x << endl
#define deb2(x, y) cout << #x << "=" << x << "," << #y << "=" << y << endl
#define precise(x) cout << fixed << setprecision(x)
const ll MAX = 1000004;
const ll INF = 1e8L;
template <class T, class U>
void chmin(T &t, const U &u)
{
    if (t > u)
        t = u;
}
template <class T, class U>
void chmax(T &t, const U &u)
{
    if (t < u)
        t = u;
}
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T)
{
    cerr << " " << H;
    debug_out(T...);
}
template <typename Arg1>
void pn(Arg1 &&arg1)
{
    cout << arg1 << "\n";
}
template <typename Arg1, typename... Args>
void pn(Arg1 &&arg1, Args &&... args)
{
    cout << arg1 << "\n";
    pn(args...);
}
template <typename Arg1>
void ps(Arg1 &&arg1)
{
    cout << arg1 << " ";
}
template <typename Arg1, typename... Args>
void ps(Arg1 &&arg1, Args &&... args)
{
    cout << arg1 << " ";
    ps(args...);
}
template <typename Arg1>
void read(Arg1 &&arg1)
{
    cin >> arg1;
}
template <typename Arg1, typename... Args>
void read(Arg1 &&arg1, Args &&... args)
{
    cin >> arg1;
    read(args...);
}

ll val(ll x, ll y)
{
    return ((x * INF) + y);
}

void solve()
{
    ll h, w, m;
    read(h, w, m);
    mll r, c, hash;
    ll maxX = 0, maxY = 0;
    rep(i, 0, m)
    {
        ll u, v;
        read(u, v);
        hash[val(u, v)]++;
        r[u]++, c[v]++;
        chmax(maxX, r[u]);
        chmax(maxY, c[v]);
    }
    vll row, col;
    rep(i, 1, h + 1) if (maxX == r[i]) row.pb(i);
    rep(i, 1, w + 1) if (maxY == c[i]) col.pb(i);
    ll ans = maxX + maxY - 1;
    bool ch = false;
    for (auto i : row)
    {
        for (auto j : col)
        {
            if (!hash[val(i, j)])
            {
                ans++;
                ch = true;
                break;
            }
        }
        if (ch)
            break;
    }
    pn(ans);
}

int main()
{

    _cin
    // ll tc;
    // cin>>tc;
    // while(tc--){
    solve();
    // }
}

Measured memory_bytes: 67844
import java.util.*;

public class Main {
	public static void main(String args[]) {
		Scanner s = new Scanner(System.in);
		String init[] = s.nextLine().split(" ");
		int W = Integer.parseInt(init[0]);
		int H = Integer.parseInt(init[1]);
		int N = Integer.parseInt(init[2]);

		String box[][] = new String[W][H];

		for (int i = 0; i < N; i++) {
			String arr[] = s.nextLine().split(" ");
			if (arr[2].equals("1")) {
				for (int j = 0; j < Integer.parseInt(arr[0]); j++) {
					for (int k = 0; k < H; k++) {
						box[j][k] = "1";
					}
				}
			}
			if (arr[2].equals("2")) {
				for (int j = Integer.parseInt(arr[0]); j < W; j++) {
					for (int k = 0; k < H; k++) {
						box[j][k] = "1";
					}
				}
			}
			if (arr[2].equals("3")) {
				for (int j = 0; j < W; j++) {
					for (int k = 0; k < Integer.parseInt(arr[1]); k++) {
						box[j][k] = "1";
					}
				}
			}
			if (arr[2].equals("4")) {
				for (int j = 0; j < W; j++) {
					for (int k = Integer.parseInt(arr[1]); k < H; k++) {
						box[j][k] = "1";
					}
				}
			}
		}

		int num = 0;
		for (String[] a : box) {
			for (String b : a) {
				if (b == null) {
					num++;
				}
			}
		}
		System.out.println("" + num);
	}
}

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

int main() {
    string a, b;
    cin >> a >> b;
    string ans;
    if (a.length() > b.length()) ans = "GREATER";
    else if (a.length() < b.length()) ans = "LESS";
    else {
        ans = "EQUAL";
        for (int i = 0; i < a.length(); i++) {
            int n = a[i] - '0';
            int m = b[i] - '0';
            if (n > m) {
                ans = "GREATER";
                break;
            }
            if (n < m) {
                ans = "LESS";
                break;
            }
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define For(i, a, b) for(int (i)=(int)(a); (i)<(int)(b); ++(i))
#define rFor(i, a, b) for(int (i)=(int)(a)-1; (i)>=(int)(b); --(i))
#define rep(i, n) For((i), 0, (n))
#define rrep(i, n) rFor((i), (n), 0)
#define fi first
#define se second
using namespace std;
typedef long long lint;
typedef unsigned long long ulint;
typedef pair<int, int> pii;
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;}
template<class T> T div_floor(T a, T b){
    if(b < 0) a *= -1, b *= -1;
    return a>=0 ? a/b : (a+1)/b-1;
}
template<class T> T div_ceil(T a, T b){
    if(b < 0) a *= -1, b *= -1;
    return a>0 ? (a-1)/b+1 : a/b;
}

constexpr lint mod = 1e9+7;
constexpr lint INF = mod * mod;
constexpr int MAX = 100010;

void f(lint t, lint i, lint &ans){
    lint k = i;
    while(t%k == 0){
        ans += ((t/k) % i == 1);
        k *= i;
    }
}

int main(){
    lint n;
    scanf("%lld", &n);
    if(n == 2){
        printf("%d\n", 1);
        return 0;
    }

    lint t = n-1;
    lint ans = 0;
    for(lint i=1; i*i<=t; ++i){
        if(t%i == 0){
            ans += (i==1 || i*i==t ? 1 : 2);
        }
    }
    t = n;
    for(lint i=2; i*i<=t; ++i){
        if(t%i == 0){
            f(t, i, ans);
            if(i*i != t) f(t, t/i, ans);
        }
    }
    printf("%lld\n", ans + 1);
}

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

int arr[100];

int cmp(const void *a, const void *b) {
	return *(const int *) a - *(const int *) b;
}

int main(void) {
	int n;
	scanf("%d", &n);

	int sum = 0;
	for (int i = 0; i < n; i++) {
		scanf("%d", &arr[i]);
		sum += arr[i];
	}
	//qsort(arr, n, sizeof arr[0], cmp);

	int min = sum;
	int part = 0;
	for (int i = 0; i < n-1; i++) {
		part += 2*arr[i];
		if (min > abs(sum-part)) min = abs(sum-part);
	}

	printf("%d\n", min);
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String line = "";

		while ((line = br.readLine()) != null && !line.isEmpty()) {
			int n = Integer.parseInt(line);
			if (n == 0) {
				break;
			}
			int[] array = new int[n];
			for (int i = 0; i < n; i++) {
				array[i] = Integer.parseInt(br.readLine());
			}

			int count = 0;
			for (int i = n - 1; i > 0; i--) {
				for (int j = 0; j < i; j++) {
					if (array[j] > array[j + 1]) {
						int swap = array[j];
						array[j] = array[j + 1];
						array[j + 1] = swap;
						count++;
					}
				}
			}
			System.out.println(count);
		}
	}
}

Measured memory_bytes: 17808
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
const ll MOD=1000000007;
const ll INF=100000000000000LL;
const int MAX=100001;
const double EPS=1e-10;
int main() {
    int n;
    cin>>n;
    vector<ll> c,d;
    for(int i=0;i<n;i++){
        int aa;
        cin>>aa;
        c.push_back(aa);
    }
    for(int i=0;i<n;i++){
        int bb;
        cin>>bb;
        d.push_back(bb);
    }
    ll ans=0;
    for(int i=0;i<31;i++){
        vector<ll> a,b;
        ll t=(1LL<<i);
        for(int j=0;j<n;j++){
            a.push_back(c[j]%(2LL*t));
            b.push_back(d[j]%(2LL*t));
        }
        sort(b.begin(),b.end());
        bool s=0;
        for(int j=0;j<n;j++){
            auto l1=lower_bound(b.begin(),b.end(),t*2-a[j]);auto r1=lower_bound(b.begin(),b.end(),t-a[j]);
            auto l2=lower_bound(b.begin(),b.end(),4*t-a[j]);auto r2=lower_bound(b.begin(),b.end(),3*t-a[j]);
            s^=(l1-r1+l2-r2)&1;
        }
        ans|=(s<<i);
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 10404
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
#define sz(x) int(x.size())
#define pb push_back
#define eb emplace_back
using ll=long long;
using P = pair<int,int>;
#define chmax(x,y) x = max(x,y)
#define chmin(x,y) x = min(x,y)
const ll MOD=1000000007;



int main() {
    int n,k;
    cin>>n>>k;
    vector<int> w(n);
    rep(i,n)cin>>w.at(i);
    ll ok=0,ng=-1;
    rep(i,n)ok+=w.at(i);
    while(ok-ng>1){
        ll m=(ok+ng)/2;
        bool judge=true;
        ll now=0,count=1;
        rep(i,n){
            if(w.at(i)>m)judge=false;
            now+=w.at(i);
            if(now>m){
                count++;
                now=w.at(i);
            }
        }
        if(count>k)judge=false;
        if(judge){ok=m;}
        else{ng=m;}
    }
    cout<<ok<<endl;
}


Measured memory_bytes: 3132
#include<stdio.h>

int main(){
  int A, B, C, D;
  
  scanf("%d %d %d %d", &A, &B, &C, &D);
  
  if(A*B >= C*D){
    printf("%d\n", A*B);
  } else {
    printf("%d\n", C*D);
  }
  
  return 0;
}
  

Measured memory_bytes: 128
// --https://kenkoooo.com/atcoder/#/table/soma62jp

#include <stdio.h>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <queue>
#include <stack>
#include <cmath>
#include <ctime>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <numeric>
#include <complex>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <iostream>
#include <iterator>
#include <algorithm>
#include <functional>
 
using namespace std;
 
typedef long long ll;
typedef unsigned int ui;
typedef long double ld;
 
#define LL_MOD          (ll)1000000007
#define LL_INF          (ll)1 << 62
#define INT_INF         (int)1 << 30
 
#define rSort(a)        sort(a.rbegin(),a.rend())
#define Sort(a)         sort(a.begin(),a.end())
#define Reverse(a) int     reverse(a.begin(),a.end())
#define Sum(a)          accumulate(a.begin(), a.end(), 0)
#define REP(i, n)       for(ui i = 0;i < n;i++)
#define REPR(i, n)      for(ui i = n;i >= 0;i--)
#define FOR(i, m, n)    for(ui i = m;i < n;i++)
#define pb(i)           push_back(i)
#define mp              make_pair
#define SWAP(x,y)       ((x != y)&&(x ^= y,y ^= x,x ^= y))
 
 
int main(int argc, char* argv[]) {
 
	cin.tie(0);
	ios::sync_with_stdio(false);

	int N;
	string S;

	cin >> N;
	cin >> S;

	for(ll i=0;i<S.size();i++){
		char wrk;
		wrk = S[i];
		wrk += N;
		if(wrk > 'Z'){
			wrk -= 26;
		}
		cout <<  wrk;
	}

	cout <<  endl;

	return 0;
 
}


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

using namespace std;
typedef long long ll;
#define REP(i,n) for(int i=0;i<(int)(n);i++)

double pi = 3.141592653589793138;
int main(){
    double a;
    cin >> a;
    cout <<setprecision(13)<<std::fixed<< pi * a*a << " " << pi*2*a << endl;
    return 0;
}


Measured memory_bytes: 3252
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <iomanip>
#include <cstring>
#define rep(i, N) for (int i = 0; i < (int)N; i++)
using namespace std;
typedef long long ll;
const ll LLINF = 9223372036854775807;
const int MOD = 1000000007;

int main() {
  int N; cin >> N;
  int a[N]; rep(i, N) { cin >> a[i]; a[i]--; }

  int pos = 0;
  int result = -1;
  rep(i, N) {
    if (pos == 1) {result = i; break;}
    pos = a[pos];
  }
  cout << result << endl;
  return 0;
}

Measured memory_bytes: 640
#include<cstdio>
#include<iostream>
using namespace std;
int main(void){
	int i,n,a[100001],flash,flg;
	cin>>n;
	for(i=1;i<=n;i++) cin>>a[i];
	flash=a[1]; flg=0;
	for(i=1;i<=n;i++){
		if(flash==2){
			flg=1;
			break;
		}
		flash=a[flash];
	}
	if(flg==1) cout<<i<<endl;
	else cout<<-1<<endl;
	return 0;
}

Measured memory_bytes: 640
#include<stdio.h>
#include<math.h>

int main(void){
  int range, watchman_num;
  double tree,watchman;
  scanf("%lf %d", &tree, &range);
  watchman = tree / (range * 2 + 1);
  watchman_num = ceil(watchman);
  printf("%d\n",watchman_num);
  return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define int long long
#define endl '\n'
#define pb push_back
#define fi first
#define se second
#define all(c) (c).begin(),(c).end()
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef vector<int> vi;

template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define TRACE
#ifndef ONLINE_JUDGE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
	cerr << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
	const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...)
#endif

const ll inf = 2e18;
const int mod = 1e9 + 7;
const int N = 2e5 + 10;

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

	int n, k;
	cin >> n >> k;
	int a[n];
	for(int i = 0; i < n; i++) {
		cin >> a[i];
	}
	sort(a, a + n);
	int ans = 0;
	for(int i = 0; i < k; i++) {
		ans += a[i];
	}
	cout << ans;

	return 0;
}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
const int MAXN = 300005;
struct N {
	int l,r;
	int len;
	bool operator < (const N & b)
	{
		return len < b.len;
	}
}g[MAXN];
int tr[MAXN],n,m;
void Add(int x,int c)
{
	for(;x<=m;x+=x&-x)
		tr[x] += c;
}
int ask(int x)
{
	int res = 0;
	for(;x;x-=x&-x)
		res += tr[x];
	return res;
}
int main()
{
	ios::sync_with_stdio(0);
	cin >> n >> m;
	for(int i=1;i<=n;i++) {
		cin >> g[i].l >> g[i].r;
		g[i].len = g[i].r - g[i].l + 1;
	}
	sort(g+1,g+1+n);

	int now = 1;
	for(int i=1;i<=m;i++) {
		while(now <= n && g[now].len < i) {
			Add(g[now].l,1);
			Add(g[now].r+1,-1);
			now++;
		}
		int ans = n-now+1;
		for(int j=i;j<=m;j+=i)
			ans += ask(j);
		cout << ans << endl;
	}
	return 0;
}


Measured memory_bytes: 4864
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)n; i++)
#define ALL(a) (a).begin(), (a).end()
const ll mod = 1e9 + 7;

int main()
{
    ll n, a, b;
    cin >> n >> a >> b;
    ll summin = a + b, summax = a + b;
    if (a > b)
    {
        cout << 0 << endl;
        return 0;
    }
    else if (a == b)
    {
        cout << 1 << endl;
        return 0;
    }
    else
    {
        if (n == 1)
        {
            cout << 0 << endl;
            return 0;
        }
    }
    rep(i, n - 2)
    {
        summin += a;
        summax += b;
    }
    cout << summax - summin + 1 << endl;
    return 0;
}

Measured memory_bytes: 256
//#define _GLIBCXX_DEBUG

#include<bits/stdc++.h>
using namespace std;

#define endl '\n'
#define lfs cout<<fixed<<setprecision(10)
#define ALL(a)  (a).begin(),(a).end()
#define ALLR(a)  (a).rbegin(),(a).rend()
#define spa << " " <<
#define fi first
#define se second
#define MP make_pair
#define MT make_tuple
#define PB push_back
#define EB emplace_back
#define rep(i,n,m) for(ll i = (n); i < (ll)(m); i++)
#define rrep(i,n,m) for(ll i = (ll)(m) - 1; i >= (ll)(n); i--)
using ll = long long;
using ld = long double;
const ll MOD1 = 1e9+7;
const ll MOD9 = 998244353;
const ll INF = 1e18;
using P = pair<ll, ll>;
template<typename T1, typename T2>
bool chmin(T1 &a,T2 b){if(a>b){a=b;return true;}else return false;}
template<typename T1, typename T2>
bool chmax(T1 &a,T2 b){if(a<b){a=b;return true;}else return false;}
ll median(ll a,ll b, ll c){return a+b+c-max({a,b,c})-min({a,b,c});}
void ans1(bool x){if(x) cout<<"Yes"<<endl;else cout<<"No"<<endl;}
void ans2(bool x){if(x) cout<<"YES"<<endl;else cout<<"NO"<<endl;}
void ans3(bool x){if(x) cout<<"Yay!"<<endl;else cout<<":("<<endl;}
template<typename T1,typename T2>
void ans(bool x,T1 y,T2 z){if(x)cout<<y<<endl;else cout<<z<<endl;}  
template<typename T>
void debug(vector<vector<T>>&v,ll h,ll w){for(ll i=0;i<h;i++)
{cout<<v[i][0];for(ll j=1;j<w;j++)cout spa v[i][j];cout<<endl;}};
void debug(vector<string>&v,ll h,ll w){for(ll i=0;i<h;i++)
{for(ll j=0;j<w;j++)cout<<v[i][j];cout<<endl;}};
template<typename T>
void debug(vector<T>&v,ll n){if(n!=0)cout<<v[0];
for(ll i=1;i<n;i++)cout spa v[i];cout<<endl;};
template<typename T>
vector<vector<T>>vec(ll x, ll y, T w){
  vector<vector<T>>v(x,vector<T>(y,w));return v;}
ll gcd(ll x,ll y){ll r;while(y!=0&&(r=x%y)!=0){x=y;y=r;}return y==0?x:y;}
vector<ll>dx={1,-1,0,0,1,1,-1,-1};
vector<ll>dy={0,0,1,-1,1,-1,1,-1};
template<typename T>
vector<T> make_v(size_t a,T b){return vector<T>(a,b);}
template<typename... Ts>
auto make_v(size_t a,Ts... ts){
  return vector<decltype(make_v(ts...))>(a,make_v(ts...));
}
template<typename T1, typename T2>
ostream &operator<<(ostream &os, const pair<T1, T2>&p){
  return os << p.first << " " << p.second;
}
//mt19937 mt(chrono::steady_clock::now().time_since_epoch().count());
struct nazo_basis{
  vector<ll>basis;
  nazo_basis() = default;
  ll rank(){return basis.size();};
  bool insert(ll k){
    for(auto b:basis)chmin(k, k^b);
    if(k){
      basis.push_back(k);
      return true;
    }
    else return false;
  }
  bool include(ll k){
    for(auto b:basis)chmin(k, k^b);
    return k;
  }
  ll subset_max(){
    ll k=0;
    for(auto b:basis)chmax(k, k^b);
    return k;
  }
  void print(){
    for(auto b:basis)cout<<b<<" ";
    cout<<endl;
  }
};
int main(){
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  ll res=0,buf=0;
  bool judge = true;
  ll n;cin>>n;
  vector<ll>a(n);
  rep(i,0,n)cin>>a[i];
  ll xorbuf=0;
  rep(i,0,n)xorbuf^=a[i];
  rep(i,0,60){
    if(xorbuf&1LL<<i){
      rep(j,0,n)a[j]&=~(1LL<<i);
    }
  }
  nazo_basis b;
  rep(i,0,n)b.insert(a[i]);
  cout<<xorbuf+b.subset_max()*2<<endl;
  return 0;
}

Measured memory_bytes: 1024
/*
h s, d't skp th si tll i's svedclTabCtrl
 * ABC141 E
 * ABC145 D
 * ABC147 F
 * ABC174 F
*/
#include<bits/stdc++.h>
#define ll long long
#define mod 1000000007
using namespace std;
int main()
{
string s;
cin>>s;
int ans=0;
if(s[0]=='R' || s[1]=='R' || s[2]=='R')
{
ans=1;
}
if((s[0]==s[1] && s[1]=='R') || (s[1]==s[2] && s[1]=='R'))
{
ans=2;
}
if(s[0]==s[1] && s[0]==s[2] && s[0]=='R')
{
ans=3;
}
cout<<ans;
}

/*
 *||||

 */

Measured memory_bytes: 3592
import math
import collections

k = int(input())
gcd_table = [[0] * k for i in range(k)]
for i in range(1, k+1):
    for j in range(i, k+1):
        gcd_table[i-1][j-1] = math.gcd(i, j)

ans = 0
combination_list = [0, 1, 3, 6]
for p in range(1, k+1):
    for q in range(p, k+1):
        if gcd_table[p-1][q-1] == 0:
            tmp_gcd = math.gcd(p, q)
            gcd_table[p-1][q-1] = tmp_gcd
        else:
            tmp_gcd = gcd_table[p-1][q-1]
        for r in range(q, k+1):
            if gcd_table[q-1][r-1] == 0:
                tmp_gcd_2 = math.gcd(q, r)
                gcd_table[q-1][r-1] = tmp_gcd_2
            else:
                tmp_gcd_2 = gcd_table[q-1][r-1]
            unique_num = len(collections.Counter([p, q, r]))
            ans += math.gcd(tmp_gcd, tmp_gcd_2) * combination_list[unique_num]
print(ans)

Measured memory_bytes: 76112
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include<iterator>
#include<complex>
#include<stack>
#include<sstream>
#include<iterator>
using namespace std;
typedef  long long int lint;
typedef pair<int, int> IP;
typedef pair<lint, lint> LLP;
typedef pair<char, char>CP;
#define rep(i, n) for (int i = 0; i < n; i++)
#define repr(i, n) for (int i = n; i >= 0; i--)
#define sort(v) sort((v).begin(), (v).end())
#define reverse(v) reverse((v).begin(), (v).end())
#define upper(v,hoge) upper_bound(v.begin(),v.end(),hoge)
#define lower(v,hoge) lower_bound(v.begin(),v.end(),hoge)
#define llower(v,hoge) *lower_bound(v.begin(), v.end(), hoge)
#define lupper(v,hoge) *upper_bound(v.begin(), v.end(), hoge)

int main() {
	int N;
	while (cin >> N) {
		int cnt = 0;
		rep(a, 10) {
			rep(b, 10) {
				rep(c, 10) {
					rep(d, 10) {
						if (a + b + c + d == N) {
							cnt++;
						}
					}
				}
			}
		}
		cout << cnt << endl;
	}
}


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

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

    int n, k, prev, ind = -1;
    cin >> n >> k;

    cin >> prev;
    for (int i = 1; i < n; i++) {
        int x;
        cin >> x;
        if (x + prev >= k)
            ind = i;
        prev = x;
    }

    if (ind == -1)
        cout << "Impossible\n";
    else {
        cout << "Possible\n";
        for (int i = 1; i < ind; i++)
            cout << i << '\n';
        for (int i = n - 1; i > ind; i--)
            cout << i << '\n';
        cout << ind << '\n';
    }
}

Measured memory_bytes: 3696
#include <iostream>
#include <vector>
#include <set>
#include <string>
#include <utility>
#include <functional>
#include <queue>
#include <cmath>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <iomanip>      // std::setprecision
#include <boost/range/irange.hpp>
#include <boost/range/algorithm.hpp>
#include <boost/range/numeric.hpp>
#include <boost/multi_array.hpp>
#include <boost/math/common_factor_ct.hpp>
#include <boost/algorithm/string.hpp>
#include <boost/pending/disjoint_sets.hpp>
#include <boost/icl/interval_map.hpp>
#include <boost/graph/graph_traits.hpp>
#include <boost/graph/strong_components.hpp>
#include <boost/graph/adjacency_list.hpp>
#include <boost/graph/dijkstra_shortest_paths.hpp>
#include <boost/graph/bellman_ford_shortest_paths.hpp>
#include <boost/graph/kruskal_min_spanning_tree.hpp>
#include <boost/graph/graph_utility.hpp>

#define REP(i, N) for(int i=0; i<(N); i++)
using namespace std;
using namespace boost::math;

int main() {
	string s, t;

	cin >> s >> t;
  
    boost::multi_array<string, 2> dp(boost::extents[s.length()+1][t.length()+1]);
  
    REP(i, s.length()) {
      const auto Schar = s[i];
      REP(j, t.length()) {
        
        const auto Tchar = t[j];
        
        dp[i+1][j+1] = dp[i][j+1];
        if (dp[i+1][j+1].length() < dp[i+1][j].length())
        	dp[i+1][j+1] = dp[i+1][j];
        if (Schar == Tchar &&
            dp[i+1][j+1].length() < dp[i][j].length() + 1) {
          dp[i+1][j+1] = move(dp[i][j]) + Schar;
        }
        string().swap(dp[i][j]);	// これはひどい
      }
    }

	cout << dp[s.length()][t.length()] << endl;

	return 0;
}


Measured memory_bytes: 81788
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); i++)
#define sz(x) int(x.size())
using namespace std;
typedef long long ll;
const long long  mod = 1000000007;



int main(){
  int n;
  cin >> n;
  vector<int> p(n);
  rep(i,n){
    cin >> p[i];
    p[i]--;
  }

  int ans = 0;
  rep(i,n){
    if(i == n-1 && i == p[i]) {
      swap(p[i], p[i-1]);
      ans++;
    }
    else if(i == p[i]) {
      swap(p[i],p[i+1]);
      ans++;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 3788
// Doing Some Optimization

#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse2")

#include<bits/stdc++.h>
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
using namespace std;

#define int         long long
#define ll          long long
#define pb          push_back
#define pii         pair<int,int>
#define vi          vector<int>
#define vii         vector<pii>
#define mi          map<int,int>
#define mii         map<pii,int>
#define mp          make_pair
#define all(a)      (a).begin(),(a).end()
#define FF           first
#define SS           second
#define sz(x)       (int)x.size()
#define endl        '\n'
//#define hell          1000000007
#define rep(i,a,b)  for(int i=a;i<b;i++)
// mp::cpp_int

const int hell=1000000009;


int power(int a,int b)
{
  if(b==0)return 1;
  if(b==1)return a;
  int t=power(a,b/2);
  t%=hell;
  t*=t;
  t%=hell;
  if(b%2)return (t*a)%hell;
  else
     return t;
}

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

int digitsum(int x)
{
  while(x>9)
    {  int ans=0;
       while(x!=0)
       {
        ans+=x%10;
        x/=10;
       }
       x=ans;
    }
    return x;
}

int pw(int a,int b)
{
  int x=a;
  rep(i,1,b){a=a*x;}
  return a;
}


int solve( ){


string s;
cin>>s;
int n=s.size();
int count=0;
int ans=0;
for(int i=0;i<n-2;i++)
{     
    if(s[i]=='A')count++;
    else count=0;
  if(s[i]=='A'&&s[i+1]=='B'&&s[i+2]=='C')
  {  
    ans+=count;
    s[i+2]='A';
      // cout<<s<<" "<<count<<endl;
     i+=1;
       count--;
  }
}
cout<<ans;

return 0;
}

signed main()
{  int t=1;
 ios::sync_with_stdio(false);
   cin.tie(0);
   cout.tie(0);
   cin.exceptions(cin.failbit);                                                                    


  clock_t time_req;

    // Without using pow function
                                                                                                                   

   // cin>>t;

    int k=1;
   while(t--)
     {
       //cout<<"case #"<<k<<":"<<" ";k++;
      solve();
     }

         time_req = clock() - time_req;
    //cout <<endl<< "Processor time taken is "
      //<< (double)time_req/CLOCKS_PER_SEC << " seconds" << endl;


    return 0;
} 


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

int main(){
	int N;
	cin >> N;
	int total = 0;
	int s[N];
	rep(i,N) {
		cin >> s[i];
		total += s[i];
	}
	sort(s,s+N);
	if (total%10 != 0) {
		cout << total << endl;
		return 0;
	}

	rep(i,N) {
		if (s[i]%10 == 0) continue;
		total -= s[i];
		cout << total << endl;
		return 0;
	}
	cout << 0 << endl;
	return 0;
}


Measured memory_bytes: 3588
#include <iostream>

using namespace std;

int main() {
	 long long a, b, c, k,score;
	score = 0;
	cin >> a >> b >> c >> k;
	if (k <= a) {
		score = k;
	}
	else if (a < k && k <= a + b) {
		score = a;
	}
	else if (a + b < k) {
		score = a - (k - (a + b));
	}
	cout << score;
	return 0;
}

Measured memory_bytes: 3608
#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>;


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

  int S,W;
  cin >> S >> W;

  if (S <= W) {
    cout << "unsafe" << endl;
  }

  else {
    cout << "safe" << endl;
  }
  return 0;
}


Measured memory_bytes: 3640
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using P = pair<int,int>;

int main() {
  int n;
  cin >> n;
  
  int m = n/500;
  int l = n%500;
  int o = l/5;
  
  cout << 1000*m + 5*o<< endl;
}

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

int main(){
  int n, m, c;
  cin >> n >> m >> c;
  int a[n][m];
  int b[m];
  int i, j;
  for(i = 0; i < m; i++){
    cin >> b[i];
  }
  for(i = 0; i < n; i++){
    for(j = 0; j < m; j++){
      cin >> a[i][j];
    }
  }
  int count = 0, sum;
  for(i = 0; i < n; i++){
    for(j = 0, sum = 0; j < m; j++){
      sum += a[i][j] * b[j];
    }
    sum += c;
    if(sum > 0) count++;
  }
  cout << count << endl;

  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<bits/stdc++.h>
#include<math.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (n); i++)
#define rep1(i,n) for(int i = 1; i < (n); i++)

const int M = 1000005;

int main(){
    int n;
    cin >> n;
    vector<int> a(n);
    vector<int> c(M); 
    rep(i,n) cin >> a[i];
    for(int j : a){
        if(c[j]>0){
            c[j]=2;
            continue;
        }
        for(int i = j; i <= M; i += j){
            c[i]++;
        }
    }
    int ans = 0;
    for(int j : a){
        if(c[j]==1)ans++;
    }
    cout << ans << endl;
}

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

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

  int n, m;
  cin >> n >> m;

  vector<int> coins(30, 0); //コインの値段を記録
  for(int i = 0; i < m; i++) {
    cin >> coins[i];
  }

  vector<int> dp(500000, 100100100); //コインの枚数を記録」
  dp[0] = 0;
  for(int i = 0; i < n; i++) {
    for(int j = 0; j < m; j++) {
      dp[i+coins[j]] = min(dp[i] + 1, dp[i+coins[j]]);
    }
  }

  cout << dp[n] << endl;
}



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

#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define intll int long long
const int INF = 1e9;
const int MOD = 1e9 + 7;


int main() {
  string s ; 
  cin >> s ; 
  s = s+'@' ;
  
  rep(i,s.size()-1){
    string ans = "  " ;
    ans.at(0) = s.at(i)   ;
    ans.at(1) = s.at(i+1) ;
    if(ans == "AC" ) {
      cout << "Yes" <<endl ;
      return 0 ;
    }
  }
  
  cout << "No" <<endl ;
      
}


Measured memory_bytes: 3604
#include <iostream>
using namespace std;
int main(void){
    int a,b;
    cin>>a>>b;
    if (a<b){
        int tmp =a;
        a=b;b=tmp;
    }
    int ans = a;
    a--;
    if (a<b){
        int tmp =a;
        a=b;b=tmp;
    }
    ans+=a;
    cout<<ans;
}


Measured memory_bytes: 3560
// https://gcc.gnu.org/git/?p=gcc.git;a=blob;f=libstdc%2B%2B-v3/include/precompiled/stdc%2B%2B.h
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <array>
//#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#define rep(i,n) for (int i=0; i<(n); ++i)
#define rrep(i,n) for (int i=1; i<=(n); ++i)
#define drep(i,n) for (int i=(n)-1; i>=0; --i)
#define srep(i,s,t) for (int i=s; i<t; ++i)
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
const int INF = 1001001001;
const double PI = acos(-1);
const int mod=1e9+7;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
ll gcd (ll a, ll b) { return b ? gcd(b, a%b) : a; }
ll lcm (ll a, ll b) { return a/gcd(a,b)*b; }
/*------------------------------------------------------------------------------
...................................ENTRY POINT..................................
------------------------------------------------------------------------------*/
int main(void){
  ios_base::sync_with_stdio(0);
  cin.tie(0); cout.tie(0);
  int x;
  cin >> x;
  if (x==0) cout << 1 << endl;
  else if(x==1) cout << 0 << endl;
  return 0;
}


Measured memory_bytes: 3604
#include <iostream>
#include<algorithm>
#include<string>
#include <cmath>
#include <vector>
#include <map>
#include <cstdio>
#pragma region Macros
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<=n;i++)
#define int long long
#define all(x) (x).begin(),(x).end()
#define swap(a,b) (a += b,b = a - b,a -= b)
#define ceil(a,b) ((a+b-1)/b)
int gcd(int a, int b) // assuming a,b >= 1
{
    if (a < b)
        swap(a, b);
    if (b == 0)
        return a;
    if (a % b == 0)
        return b;
    return gcd(b, a % b);
}
int lcm(int a, int b) // assuming a,b >= 1
{
    return  a * b / gcd(a, b);
}
using namespace std;
#pragma endregion
signed main() {
    int A,B,C,D;
    cin >> A >> B >> C >>D;
    if (abs(A-C)<=D || (abs(A-B)<=D && abs(B-C) <= D))
        cout << "Yes";
    else
        cout << "No";
}

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


int main() {
  char s ; cin >> s;
  if(s=='a'||s=='i'||s=='u'||s=='e'||s=='o'){
    cout << "vowel" << endl;
  }
  else{
    cout << "consonant" << endl;
  }
}


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

 int main() {
   int N,K;
   cin >> N >> K;
   
   int a = 1;
   
   for(int i = 0;i< N;i++){
    if(a*2 >= a + K){
      a += K;
    }else if(a*2 <= a + K){
      a *= 2;
    }
   }
   cout << a << endl;
 
 }

Measured memory_bytes: 256
#include<iostream>
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0;i<n;i++)
using P = pair<int,int>;
const int INF = 1000100100;

/* 大文字を小文字に変換 */
char tolower(char c) {return (c + 0x20);}
/* 小文字を大文字に変換 */
char toupr(char c) {return (c - 0x20);}

// if('A'<=s[i] && s[i]<='Z') s[i] += 'a'-'A';

/*
string s = "abcdefg"
s.substr(4) "efg"
s.substr(0,3) "abc"
s.substr(2,4) "cdef"

// イテレータ要素のインデックス
distance(A.begin(), itr);
*/

int main()
{
    int n, m, q; cin >> n >> m >> q;
    int sum[n][n];
    rep(i,n) rep(j,n) sum[i][j] = 0;

    rep(i,m){
        int l,r; cin >> l >> r;
        --l, --r;
        sum[l][r] += 1;
    }

    rep(i,n){
        if(i != 0){
            sum[i][0] = sum[i][0] + sum[i-1][0];
            sum[0][i] = sum[0][i] + sum[0][i-1];
        }
    }
    for(int i=1; i<n; i++){
        for(int j=1; j<n; j++){
            sum[i][j] = sum[i][j] + sum[i-1][j] + sum[i][j-1] - sum[i-1][j-1];   
        }
    }

    rep(_,q){
        int P, Q; cin >> P >> Q; --P, --Q;
        if(P == 0){
            cout << sum[Q][Q] << endl;
        }else{
            int res = sum[Q][Q]-sum[Q][P-1] - sum[P-1][Q] + sum[P-1][P-1];
            cout << res << endl;
        }
    }
}

Measured memory_bytes: 4604
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <queue>
#include <cstring>
#include <vector>
#include <map>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <bitset>
using namespace std;

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

int dx4[4]={1,0,-1,0};
int dy4[4]={0,-1,0,1};
int dx8[8]={1,0,-1,1,-1,1,0,-1};
int dy8[8]={1,1,1,0,0,-1,-1,-1};

typedef pair<int, int> P;
typedef pair<string, int> SP;
typedef long long ll;

const int INF = 1e9;
const int MAX_V = 1e6+1;
const ll mod = 1000000007;

// --------------------------------------
int n;
int A, B, C;
int l[10];

int dfs(int cur, int a, int b, int c) {
  if(cur == n) {
    if(min({a, b, c}) > 0) {
      return abs(a - A) + abs(b - B) + abs(c - C) - 30;
    } else {
      return INF;
    }
  }

  int r1, r2, r3, r4;
  r1 = dfs(cur + 1, a, b, c);
  r2 = dfs(cur + 1, a + l[cur], b, c) + 10;
  r3 = dfs(cur + 1, a, b + l[cur], c) + 10;
  r4 = dfs(cur + 1, a, b, c + l[cur]) + 10;

  return min({r1, r2, r3, r4});
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >> n >> A >> B >> C;

  REP(i, n) {
    cin >> l[i];
  }

  cout << dfs(0, 0, 0, 0) << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define RFOR(i,a,b) for(int i=(b) - 1;i>=(a);i--)
#define REP(i,n) for(int i=0;i<(n);i++)
#define RREP(i,n) for(int i=n-1;i>=0;i--)

#define PB push_back
#define INF (1<<29)
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define CLR(a) memset(a,0,sizeof(a))
const int dx[] = {-1,0,0,1},dy[] = {0,1,-1,0};

typedef long long int ll;

using namespace std;
int losen[101][101];
int d[3][101];

int n,m;

int main(){
    while(true){
	cin >> n >> m;
	if(n==0&&m==0) break;
	REP(i,101)REP(j,101) losen[i][j] = -1;
	REP(i,3)REP(j,101) d[i][j] = 1000000;
	REP(i,m){
	    int a,b,c;
	    cin >> a >> b >> c;
	    losen[a][b] = c;
	    losen[b][a] = c;
	}
	queue<int> qx;
	queue<int> qd;
	queue<int> qv;
	qx.push(1);
	qd.push(2);
	d[2][1] = 0;
	while(!qx.empty()){
	    int x = qx.front();
	    int dim = qd.front();
	    //printf("x = %d dim = %d v = %d\n",x,dim,v);
	    qx.pop();
	    qd.pop();
	    FOR(i,1,n+1){
		if(dim != 1 && losen[x][i] > 0 && d[dim][x] + losen[x][i] < d[dim][i]){
		    d[dim][i] = d[dim][x] + losen[x][i];
//		    printf("push: %d to %d dim = %d v = %d\n",x,i,dim,v+losen[x][i]);
		    qx.push(i);
		    qd.push(dim);
		}
		if(dim >= 1 && losen[x][i] > 0 && d[dim][x] < d[dim-1][i]){
		    d[dim-1][i] = d[dim][x];
//		    printf("free ticket push: %d to %d dim = %d v = %d\n",x,i,dim,v);
		    qx.push(i);
		    qd.push(dim-1);
		}
	    }
	}
	int ans = 1000000;
	ans = min(d[0][n],d[2][n]);
//	printf("d[0][n] = %d\n",d[0][n]);
//	printf("d[2][n] = %d\n",d[2][n]);
	cout << ans << endl;
    }
    return 0;
}

Measured memory_bytes: 1256
#include "bits/stdc++.h"
// Custom Header {{{
#define ALL(x) x.begin(), x.end()
#define rep(i, s, n)      for(int i(s); i < int(n); ++i)
#define endl '\n'
#ifndef YDK
#define eprintf(...)
#endif
using namespace std;
using i64 = long long;
using pii = pair<i64, i64>;
template<class A, class B>inline bool chmax(A &a, const B &b){return b>a ? a=b,1 : 0;}
template<class A, class B>inline bool chmin(A &a, const B &b){return b<a ? a=b,1 : 0;}
constexpr const int INF  = 0x3f3f3f3f;
constexpr const i64 LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr const int MOD  = int(1e9) + 7;
// }}}

// Library {{{
template<class Array>
vector<i64> ruisekiwa(const Array &src, int N)
{
    vector<i64> s(N, src[0]);
    for (int i = 1; i < N; ++i) s[i] = s[i-1] + src[i];
    return s;
}

inline i64 partSum(const vector<i64> &s, int l, int r)
{
    if (l > r) swap(l, r);
    if (r >= s.size()) return 0;
    return s[r] - (l <= 0 ? 0 : s[l-1]);
}
// }}}

struct FastIO {
    FastIO() { cin.tie(nullptr); ios::sync_with_stdio(false); }
} fastIO_ydk ;

signed main()
{
    int N;
    i64 a[100010];

    cin >> N;
    vector<i64> odd(N+1);
    vector<i64> even(N+1);

    for (int i = 1; i <= N; ++i) {
        cin >> a[i];
        odd[i] = even[i] = a[i];

        if (i % 2 == 0) {
            odd[i] = -odd[i];
        } else {
            even[i] = -even[i];
        }
    }

    auto os = ruisekiwa(odd, N+1);
    auto es = ruisekiwa(even, N+1);

    vector<i64> ans;

    ans.push_back(partSum(os, 1, N));

    for (int i = 1; i < N; ++i) {
        i64 a, b;
        if  (i % 2 == 1) {
            a = partSum(os, 1, i);
            b = partSum(es, i+1, N);
        } else {
            a = partSum(es, 1, i);
            b = partSum(os, i+1, N);
        }
        ans.push_back(a+b);
    }

    for (int i = 0; i < ans.size(); ++i) {
        cout << ans[i] << (i+1 < ans.size() ? ' ' : '\n');
    }

    return 0;
}


Measured memory_bytes: 6132
#include "iostream"
#include "vector"
#include "array"
#include "string"
#include "algorithm"

using namespace std;
#define rep(p,q) for(int i = p;i < q;i++)


//b
int main(void) {
	int n,d,x = 0;
	cin >> n >> d >> x;
	int count = 0;
	rep(0, n) {
		int ai = 0;
		cin >> ai;
		count++;
		count += (d - 1) / ai;
	}
	cout << count + x << endl;

}


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

int main(){
    int h,w; cin>>h>>w;
    string s; int ansh; char answ;

    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            cin>>s;
            if(s=="snuke") {ansh=i+1; answ='A'+j; break;}
        }
    }
    cout<<answ<<ansh<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <bitset>
typedef long long ll;
#define rep(i,n) for(int i = 0;i<n;++i)
#define repnc(bit,k,n) for (int bit = (1<<k)-1;bit < (1<<n); bit = next_combination(bit))
#define repi(itr,vec) for(auto itr = vec.begin();itr!=vec.end();++itr)
using namespace std;

/* next combination */
int next_combination(int sub) {
  int x = sub & -sub, y = sub + x;
  return (((sub & ~y) / x) >> 1) | y;
}

int main(){
        ios::sync_with_stdio(false);
        cin.tie(nullptr);
  ll d,g;
  cin >> d >> g;
  ll p[d] ;
  ll c[d] ;
  rep(i, d) cin >> p[i] >> c[i];
  ll ans = 100000;
  rep(bit, 1<<d){
    ll score = 0, count = 0;
    ll itr = 0;
    rep(i, d){
      if(bit&(1<<d-1-i)){
        score+=100*(i+1)*p[i]+c[i];
        count+=p[i];
      }
      if((~bit&-~bit)&1<<i){
        itr = d-1-i;
      }
    }
    if((g-score)>=100*(itr+1)*p[itr]){
      //cout <<"exceed"<< g-score << endl;
      continue;
    }
    //cout << g-score<<endl;
    if((g-score)>0){
      //cout << "itr"<<itr<<endl;
      if((g-score)%(100*(itr+1))) count+=(g-score)/(100*(itr+1))+1;
      else count+=(g-score)/(100*(itr+1));
    }
    ans = min(ans, count);
  }
  cout << ans << '\n';

        return 0;
}

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

int n,m;
vector<vector<int>> g;
vector<int> dp(100010,-1);

int dfs(int x){
	if(dp[x]!=-1) return dp[x];
	int ret=0;
	for(auto i:g[x]){
		ret=max(ret,dfs(i)+1);
	}
	return dp[x]=ret;
}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cin >> n >> m;
	g.assign(n,vector<int>());
	rep(i,m){
		int x,y;cin >> x >> y;
		x--;
		y--;
		g.at(x).pb(y);
	}
	int ans=0;
	rep(i,n) ans=max(ans,dfs(i));
	cout << ans << endl;
}

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

int main() {
	int n;
	cin>>n;
	int sum=0,mx=0;
	for(int i=0;i<n;i++){
		int x;
		cin>>x;
		sum+=x;
		mx=max(mx,x);
	}
	sum-=(mx/2);
	cout<<sum;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define N 100005
using namespace std;
const int mod = 1e9 + 7;

int n,k,a[N];
int fac[N],ifac[N];
int ans1,ans2;

int ksm(int x,int y){
    int res=1;
    while(y){
        if(y&1) res=1ll*res*x%mod;
        x=1ll*x*x%mod,y/=2;
    }
    return res;
}

int C(int x,int y){
    int res=1ll*fac[x]*ifac[y]%mod*ifac[x-y]%mod;
    return res;
}

int main(){
#ifdef LOCAL_JUDGE
    freopen("work.in","r",stdin);
    freopen("work.out","w",stdout);
#endif
    scanf("%d %d",&n,&k);
    for(int i=1;i<=n;i++) scanf("%d",&a[i]);
    sort(a+1,a+n+1);
    for(int i=1;i<=n;i++) if(a[i]<0) a[i]+=mod;
    fac[0]=1;for(int i=1;i<=n;i++) fac[i]=1ll*fac[i-1]*i%mod;
    ifac[n]=ksm(fac[n],mod-2);
    for(int i=n-1;i>=0;i--) ifac[i]=1ll*ifac[i+1]*(i+1)%mod;
    for(int i=k;i<=n;i++){
        ans1+=1ll*a[i]*C(i-1,k-1)%mod;
        if(ans1>=mod) ans1-=mod;
    }
    for(int i=1;i<=n-k+1;i++){
        ans2+=1ll*a[i]*C(n-i,k-1)%mod;
        if(ans2>=mod) ans2-=mod;
    }
    printf("%d\n",(ans1-ans2+mod)%mod);

    return 0; 
}


Measured memory_bytes: 1408
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define pf push_front
#define ins insert
#define mk make_pair
#define fr first
#define sc second
using namespace std;
int main()
{
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n,r=0;
    cin>>n;
    while(n!=0)
    {
    	r=n%10;
    	if(r==7)
    	{
    		cout<<"Yes";
    		return 0;
		}
    	n=n/10;
	}
	cout<<"No";
}

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

int main() {
  int N;
  cin >> N;
  vector<int> p(N);
  for (int i = 0; i < N; i++) {
    cin >> p[i];
  }
  bool ans = true;
  for (int k = 0; k < N-1; k++) {
    if(p[k] > p[k+1]) {
      ans = false;
      break;
    }
  }
  if (ans == false) {
    for (int i = 0; i < N-1; i++) {
      for (int j = i+1; j < N; j++) {
        swap(p[i], p[j]);
        for (int k = 0; k < N-1; k++) {
          ans = true;
          if(p[k] > p[k+1]) {
            ans = false;
            break;
          }
        }
        if (ans == true) break;
        swap(p[i], p[j]);
      }
      if (ans == true) break;
    }
  }
  cout << (ans ? "YES" : "NO") << endl;
}

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

#if DEBUG && !ONLINE_JUDGE
    #include "/home/tushar_garg/Desktop/cpp/debug.h"
#else
    #define dbg(x...)
#endif

typedef     long long                            ll; 
typedef     pair<ll, ll>                         pl; 
typedef     vector<ll>                           vl;
typedef     vector<char>                         vc;
typedef     vector<bool>                         vb; 
typedef     vector<vl>                           vvl; 
typedef     vector<pl>                           vll; 
typedef     map<ll, ll>                          dict; 
typedef     map<ll, ll, greater <ll> >           sdict; 
typedef     map<char, ll>                        mcl;
typedef     priority_queue<ll>                   pqi;
typedef     priority_queue<pl>                   pqii;
typedef     priority_queue<ll, vl, greater<ll>>  pqmini;

#define rep(i, a, n) for (auto i=a-(a>n); i!=n-(a>n); i+=1-2*(a>n))
#define trav(i, a) for(auto &i:a)
#define fi first 
#define se second 
#define mp make_pair 
#define pb push_back
#define eb emplace_bac
#define flash ios_base::sync_with_stdio(false),cin.tie(nullptr),cout.tie(nullptr)
#define QuickSilver cin.exceptions(cin.failbit),setprecision(12),cout.precision(12)
#define get(a) rep(i,0,sz(a))cin>>a[i];
#define sz(a) (ll)(a.size())
#define all(a) a.begin(), a.end()
#define mod 1000000007

// bool fun(int n, int m){
// 	int n,m; cin>>n>>m;
// 	vl a(n); rep(i,0,n) cin>>a[i], a[i]%=m;
// 	vl b(m,0); 
// 	rep(i,0,n){

// 	}
// 	if(fun(n-1, m)) cout<<"YES\n";
// 	else cout<<"NO\n";
// }

ll bpow(ll a, ll b){
  ll r=1; for(;b>0;a=(a*a)%mod, b>>=1) if(b&1) r=(r*a)%mod;
  return r;
}

int main(){
	flash; QuickSilver;
	int n; cin>>n;
  vl a(n); get(a);
  dict m, p;
  rep(i,0,n){
    p.clear();
    int k=a[i];
    for(int j=2; j*j<=k; j+=2){
      while(k%j==0)
        k/=j, p[j]++;
      if(j==2) j--;
    }
    if(k>1) p[k]++;
    trav(j,p) m[j.fi] = max(m[j.fi], j.se); 
  }
  ll ans=1; trav(j,m) ans=(ans*bpow(j.fi, j.se))%mod;
  ll sum=0; rep(i,0,n) sum+=bpow(a[i], mod-2);
  sum%=mod;
  cout<<(ans*sum)%mod<<"\n";
	return 0;
}

Measured memory_bytes: 1024