akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
using namespace std;

void solve(){
  int n; cin >> n;
  vector<int> a(n);
  for(int i = 0; i < n; i++){
    cin >> a[i];
  }
  int cnt = 0;
  for(int i = 1; i <= n - 1; i++){
    for(int j = n - 1; j >= i; j--){
      if(a[j] < a[j - 1]){
        int t = a[j];
        a[j] = a[j - 1];
        a[j - 1] = t;
        cnt++;
      }
    }
  }
  for(int i = 0; i < n - 1; i++){
    cout << a[i] << " ";
  }
  cout << a[n - 1] << endl;
  cout << cnt << endl;
  return;
}

int main(){
  solve();
  return 0;
}



Measured memory_bytes: 3100
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<climits>
#include<iostream>
#include<sstream>
#include<utility>
#include<map>
#include<vector>
#include<queue>
#include<algorithm>
#include<set>
#include<stack>
using namespace std;
typedef long long ll;
typedef pair<int,int>P;
vector<int> pr,t(1005,true);
map<int,int>cnt;

int main()
{
	int N,c=0;
	ll r=1;
	cin>>N;
	for(int i=2;i<=1000;i++)
	{
		if(t[i])
		{
			pr.push_back(i);
			cnt.insert(make_pair(i,1));
			for(int j=i;j<=1000;j+=i)t[j]=false;
		}
	}
	for(int k=1;k<=N;k++)
	{
		int p=k;
		for(int i=0;i<pr.size();i++)
		{
			while(p>=pr[i]&&p%pr[i]==0)
			{
				cnt[pr[i]]++;
				p/=pr[i];
			}
			if(p<=1)break;
		}
	}
	for(int i=0;i<cnt.size();i++)
		r=(r*cnt[pr[i]])%1000000007;
	cout<<r<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using vi   = vector<int>;
using vvi  = vector<vi>;
using vb   = vector<bool>;
using vvb  = vector<vb>;
using pii  = pair<int,int>;
using vpii = vector<pii>;
 
int main() {
    int N, X, T; cin >> N >> X >> T;
    int tmp = N / X; 
    int ans;
    if (N % X == 0) ans = (tmp)*T;
    else ans = (tmp+1)*T;

    cout << ans << endl;

}

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

int main(){
	cin.tie(0),ios::sync_with_stdio(false);
	vector<int>a(4);
	for(auto&i:a)cin>>i;
	int ans=0;
	if(a.at(3)>a.at(0)&&a.at(1)>a.at(2)){
		sort(a.begin(),a.end());
		ans=a.at(2)-a.at(1);
	}
	cout<<ans<<"\n"s;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using lint = long long int;
using P = pair<int, int>;
using PL = pair<lint, lint>;
#define FOR(i, begin, end) for(int i=(begin),i##_end_=(end);i<i##_end_;i++)
#define IFOR(i, begin, end) for(int i=(end)-1,i##_begin_=(begin);i>=i##_begin_;i--)
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
#define ALL(a)  (a).begin(),(a).end()
constexpr int MOD = 1000000007;
constexpr int INF = 2147483647;
constexpr double PI = 3.14159265358979;
void yes(bool expr) {cout << (expr ? "Yes" : "No") << "\n";}
struct Data {
  lint x, y;
  double theta;
};
int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int N;
  cin >> N;
  vector<Data> d(N);
  REP(i, N) {
    cin >> d[i].x >> d[i].y;
    d[i].theta = atan2(d[i].y, d[i].x);
  }
  sort(ALL(d), [](auto const &a, auto const &b) { return a.theta < b.theta; });
  REP(i, N) {
    d.push_back(d[i]);
    d[i+N].theta += 2*PI;
  }
  lint ans = 0;
  REP(i, N) {
    lint xsum = 0;
    lint ysum = 0;
    FOR(j, i, i+N) {
      xsum += d[j].x;
      ysum += d[j].y;
      ans = max(ans, xsum*xsum + ysum*ysum);
    }
  }
  cout << fixed << setprecision(10) << sqrt(ans) << "\n";
}

Measured memory_bytes: 4068
function Main(s) {
	const n = parseInt(s[0]);
	var a = s[1].split(" ").map(a => parseInt(a));
	var cost = Math.abs(a[0]);
	for(var i = 1; i < n; i++){
		cost += Math.abs(a[i-1] - a[i]);
	}
	cost += Math.abs(a[n-1]);
	
	var ans = [];
	ans[0] = cost - Math.abs(a[0]) - Math.abs(a[1] - a[0]) + Math.abs(a[1]);
	for(var i = 1; i < n - 1; i++){
		ans[i] = cost - Math.abs(a[i] - a[i-1]) - Math.abs(a[i+1] - a[i]) + Math.abs(a[i+1] - a[i-1]);
	}
	ans[n-1] = cost - Math.abs(a[n-1]) - Math.abs(a[n-1] - a[n-2]) + Math.abs(a[n-2]);
	console.log(ans.join("\n"));
}

Main(require("fs").readFileSync("/dev/stdin", "utf8").split("\n"));

Measured memory_bytes: 47888
import java.util.Arrays;
import java.util.Comparator;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int A = sc.nextInt();
		int B = sc.nextInt();
		Integer[] b = new Integer[3];
		b[0]  =A+B;
		b[1] =A-B;
		b[2] =A*B;
		Arrays.sort(b,Comparator.reverseOrder());
		System.out.println(b[0]);
		
	}

}


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

using ll = long long;
using pii = pair<int, int>;
template <class T>
using V = vector<T>;
template <class T>
using VV = V<V<T>>;

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define rep(i, n) rep2(i, 0, n)
#define rep2(i, m, n) for (int i = m; i < (n); i++)
#define ALL(c) (c).begin(), (c).end()

constexpr ll TEN(int n) { return (n == 0) ? 1 : 10 * TEN(n - 1); }

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 <class T, class U>
ostream& operator<<(ostream& os, const pair<T, U>& p) {
    os << "(" << p.first << "," << p.second << ")";
    return os;
}

template <class T>
ostream& operator<<(ostream& os, const vector<T>& v) {
    os << "{";
    rep(i, v.size()) {
        if (i) os << ",";
        os << v[i];
    }
    os << "}";
    return os;
}

#ifdef LOCAL
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
    cerr << " " << H;
    debug_out(T...);
}
#define debug(...) \
    cerr << __LINE__ << " [" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#define dump(x) cerr << __LINE__ << " " << #x << " = " << (x) << endl
#else
#define debug(...) (void(0))
#define dump(x) (void(0))
#endif

const ll INF = TEN(18);

int main() {
    int n;
    cin >> n;
    int N = n * 3;
    V<int> a(N);
    rep(i, N) cin >> a[i];
    V<ll> tol(N), tor(N);
    {
        priority_queue<ll> que;
        ll s = 0;
        rep(i, N) {
            que.push(-a[i]);
            s += a[i];
            if (que.size() > n) {
                ll v = que.top();
                que.pop();
                s += v;
            }
            if (que.size() == n) {
                tol[i] = s;
            } else {
                tol[i] = -INF;
            }
        }
    }
    {
        priority_queue<ll> que;
        ll s = 0;
        for (int i = N - 1; i >= 0; --i) {
            que.push(a[i]);
            s += a[i];
            if (que.size() > n) {
                ll v = que.top();
                que.pop();
                s -= v;
            }
            if (que.size() == n) {
                tor[i] = s;
            } else {
                tor[i] = INF;
            }
        }
    }

    ll ans = -INF;
    rep(i, N - 1) {
        if (tol[i] != -INF && tor[i + 1] != INF) {
            chmax(ans, tol[i] - tor[i + 1]);
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 7916
#include <iostream>
#include <cmath>

using namespace std;

#define MOD (256)

const double eps = 1e-10;

int main(void)
{
	int n;
	while (cin >> n, n){
		int I[n];
		for (int i = 0; i < n; i++){
			cin >> I[i];
		}

		double ent = 1 << 29;
		int S = -1, A = -1, C = -1;
		for (int s = 0; s < 16; s++){
			for (int a = 0; a < 16; a++){
				for (int c = 0; c < 16; c++){
					int R = s;
					int O[300] = {0};
					for (int i = 0; i < n; i++){
						R = (a * R + c) % MOD;
						O[(I[i] + R) % MOD]++;
					}
					double tmp = 0;
					for (int i = 0; i < 256; i++){
						if (0 < O[i]) tmp -= O[i] * 1.0 / n * log(O[i] * 1.0 / n);
					}
					if (tmp + eps < ent){
						ent = tmp;
						S = s;
						A = a;
						C = c; 
					}
				}
			}
		}
		cout << S << " " << A << " " << C << endl;
	}

	return 0;
}

Measured memory_bytes: 1204
#include<iostream>
#include<stdio.h>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
#include <queue>
#include <utility>
#include <map>
#include <set>
using namespace std;

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

    cout << (X - A) % B << endl;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long LL;
typedef pair<LL,LL> P;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T> T gcd(T a,T b){return b?gcd(b,a%b):a;}
const LL mod=998244353;
const LL LINF=1LL<<62;
const int INF=1<<30;
int dx[]={1,0,-1,0,1,-1,1,-1};
int dy[]={0,1,0,-1,1,-1,-1,1};




int main(){
    vector<int> a(3);
    cin >> a[1] >> a[2] >> a[0];
    cout << a[0] << " " << a[1] << " " << a[2] << endl;
    return 0;
}


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

int gcd(int a, int b){
  if(a >= b){
    if(b == 0){
      return a;
    }
    return gcd(b , a % b);
  }
  return gcd(b , a);
}
int main() {
  int K;
  cin >> K;
  int sum = 0;
  rep(a,K){
    rep(b,K){
      rep(c,K){
        sum += gcd(gcd(a+1,b+1),c+1);
      }
    }
  }
  cout << sum << endl;
  return 0;
}

Measured memory_bytes: 3600
# -*- coding: utf-8 -*-

N = int(raw_input())
A = map(int, raw_input().split())
count = 0
for i in range(N):
    minj = i
    for j in range(i, N):
        if A[j] < A[minj]:
            minj = j
    if i != minj:
        A[i], A[minj] = A[minj], A[i]
        count += 1
print " ".join(map(str, A))
print count

Measured memory_bytes: 6452
S = input()
I_MAX = len(S)
values = []


def calc(val, add, i):
    if i == I_MAX:
        val += add
        values.append(val)
    else:
        calc(val+add, int(S[i]), i+1)
        calc(val, 10*add+int(S[i]), i+1)


def solve():
    calc(0, int(S[0]), 1)
    print(sum(values))


if __name__ == '__main__':
    solve()

Measured memory_bytes: 3064
#include <iostream>
#include <algorithm>
using namespace std;
 
const long long INF=11111111111;
const int N=2*1e5+10;
long long a[N];

long long MM(long long a,long long b){
	return a>b ? b : a;
}

int main(){
	int n;
	long long sum=0,tmp=0;
	cin>>n;	
	for(int i=1;i<=n;i++) {cin>>a[i];sum+=a[i];}
	long long ans=INF;
	for(int i=1;i<n;i++){
		tmp+=a[i];
		ans=MM(ans,abs(2*tmp-sum));
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 1792
#include<stdio.h>
int main(void){
  int a,b,k,n=0,i=1;
  scanf("%d %d %d",&a,&b,&k);
  if(a<b){
      i=a;
  }else{
      i=b;
  }
  while(n<k){
      if(a%i==0){
          if(b%i==0){
              n++;
          }
      }
      i--;
  }
  printf("%d",i+1);
}


Measured memory_bytes: 128
#define _CRT_SECURE_NO_WARNINGS

#include<iostream>
#include<functional>
#include<algorithm>
#include<stack>
#include<queue>
#include<iomanip>
#include<set>
#include<map>
#include<utility>
#include<string>
#include<vector>

using namespace std;

#define LL long long
const int dx[4] = { 1,-1,0,0 };
const int dy[4] = { 0,0,1,-1 };
bool OOA(int x, int y, int H, int W) { return (0 <= x && x<H) && (0 <= y && y<W); }

string S,T;

int main() {
	cin>>S>>T;
	for(int i=0;i<S.size();i++){
		if(S.substr(i,T.size())==T)cout<<i<<endl;
	}
	return 0;
}



Measured memory_bytes: 3216
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <math.h>
#include <complex>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <unordered_map>
#include <set>
#include <bitset>
#include <functional>
#include <assert.h>
#define int long
#define ll long long
#define rng(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,b) rng(i,0,b)
#define gnr(i,a,b) for(int i=int(b)-1;i>=int(a);i--)
#define per(i,b) gnr(i,0,b)
#define eb emplace_back
#define all(x) x.begin(),x.end()
#define SZ(x) x.size()
#define fi first
#define se second
const int INF = 1e9;
using namespace std;

template<class t> using vc=vector<t>;
template<class t> using vvc=vc<vc<t>>;

using pi=pair<int,int>;
using vi=vc<int>;

signed main() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout<<fixed<<setprecision(20);

    string S; cin >> S;
    S=S.substr(0,SZ(S)-8);
    cout << S << endl;
    
}

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

using namespace std;

int n,h,k;

int solve(int x,int y){
    //cout << "(" << x << "," << y << ")" << " -> ";
    if(x > h) x = h - (x - h)+1;
    if(y > h) y = h - (y - h)+1;
    //cout << "(" << x << "," << y << ")" << endl;
    return (min(x,y)-1) % 3 + 1;
}

int main(){
    cin >> n >> k;
    h = n/2 + n%2;
    int x,y;
    for(int i=0;i<k;i++){
        cin >> x >> y;
        cout << solve(x,y) << endl;
    }
}

Measured memory_bytes: 1160
#include <iostream>
#include <vector>
#include <map>
#define llint long long
#define inf 1e18

using namespace std;

struct SegTree{
	llint size;
	vector<llint> seg;
	
	SegTree(){}
	SegTree(llint size){
		this->size = size;
		seg.resize(1<<(size+1));
	}
	
	void init()
	{
		for(int i = 0; i < (1<<(size+1)); i++) seg[i] = inf;
	}
	
	void update(llint i, llint val)
	{
		i += (1 << size);
		seg[i] = val;
		while(i > 1){
			i /= 2;
			seg[i] = min(seg[i*2], seg[i*2+1]);
		}
	}

	llint query(llint a, llint b, llint k, llint l, llint r)
	{
		if(b < l || r < a) return inf;
		if(a <= l && r <= b) return seg[k];
		llint lval = query(a, b, k*2, l, (l+r)/2);
		llint rval = query(a, b, k*2+1, (l+r)/2+1, r);
		return min(lval, rval);
	}
	llint query(llint a, llint b)
	{
		return query(a, b, 1, 0, (1<<size)-1);
	}
};

llint n;
llint x[200005], y[200005];
map<llint, vector<llint>> mp;
SegTree seg(18);

int main(void)
{
	cin >> n;
	for(int i = 0; i < n; i++) cin >> x[i] >> y[i];
	
	if(n == 1){
		cout << 0 << endl;
		return 0;
	}
	
	llint min_val = inf, min_i, max_val = 0, max_i;
	for(int i = 0; i < n; i++){
		if(min_val > x[i]){
			min_val = x[i];
			min_i = i;
		}
		if(min_val > y[i]){
			min_val = y[i];
			min_i = i;
		}
	}
	for(int i = 0; i < n; i++){
		if(i == min_i) continue;
		if(max_val < x[i]){
			max_val = x[i];
			max_i = i;
		}
		if(max_val < y[i]){
			max_val = y[i];
			max_i = i;
		}
	}
	if(min_val == max(max(x[min_i], y[min_i]), max_val)){
		cout << 0 << endl;
		return 0;
	}
	
	llint bmin = min_val, bmax, rmin, rmax;
	rmax = max(max(x[max_i], y[max_i]), max(x[min_i], y[min_i]));
	rmin = min(max(x[max_i], y[max_i]), max(x[min_i], y[min_i]));
	bmax = min(x[max_i], y[max_i]);
	
	for(int i = 0; i < n; i++){
		if(i == min_i || i == max_i) continue;
		bmax = max(bmax, min(x[i], y[i]));
		rmin = min(rmin, max(x[i], y[i]));
	}
	rmax = max(rmax, max(x[min_i], y[min_i]));
	llint ans = (rmax - rmin) * (bmax - bmin);
	
	bmin = min_val, bmax = max_val;
	rmin = max(x[min_i], y[min_i]), rmax = min(x[max_i], y[max_i]);
	x[min_i] = y[min_i] = rmin, x[max_i] = y[max_i] = rmax;
	
	llint ival = 0;
	for(int i = 0; i < n; i++){
		ival = max(ival, min(x[i], y[i]));
	}
	
	seg.init();
	for(int i = 0; i < n; i++){
		if(max(x[i], y[i]) <= ival) seg.update(i, max(x[i], y[i]));
		else seg.update(i, min(x[i], y[i]));
	}
	for(int i = 0; i < n; i++){
		if(max(x[i], y[i]) > ival){
			mp[max(x[i], y[i])].push_back(i);
		}
	}
	ans = min(ans, (ival - seg.query(0, n-1))*(bmax - bmin));
	
	for(auto it = mp.begin(); it != mp.end(); it++){
		for(int i = 0; i < it->second.size(); i++){
			seg.update(it->second[i], it->first);
		}
		ans = min(ans, (it->first - seg.query(0, n-1))*(bmax - bmin));
	}
	
	cout << ans << endl;
	return 0;
}

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

int main() {
  int h,w,H,W;
  cin >> h >> w;
  H=h+2;
  W=w+2;
  
  string sharp="";
  for(int i=0;i<W;i++)sharp+="#";
  vector<string> s(H,sharp);
  for(int i=1;i<H-1;i++){
    for(int j=1;j<W-1;j++){
      cin >> s.at(i).at(j);
    }
  }
  for(int i=0;i<H;i++){
      cout << s.at(i) << endl;
  }
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <algorithm>
#define rep(i,j,k) for (i=j;i<=k;i++)
using namespace std;
const int N=5e5+5;
int n,i,j,ans,top,lst,a[N],b[N],pre[N],tree[N];
char s[N];
void change(int x,int sgn) {
	while (x<=n) {	tree[x]+=sgn; x+=x&(-x); }
}
int query(int x) {
	int ret=0;
	if (x<1) return 0;
	while (x>0) { ret+=tree[x]; x-=x&(-x); }
	return ret;
}
void add() {
	int i,j;
	a[n]++; i=n;
	while (a[i]>9) a[i-1]++,a[i]=0,i--;
	rep(j,max(1,i-1),n) {
		if (b[j]>b[j+1]) change(j,-1);
		if (a[j]>a[j+1]) change(j,1);
		b[j]=a[j];
	}
	rep(j,i,n) if (a[j]==a[j-1]) pre[j]=pre[j-1]; else pre[j]=j;
}
int erfen(int x)
{
	int l=x,r=n,mid,sum,Prefix;
	Prefix=query(x-1);
	while (l<r)
	{
		mid=(l+r)>>1;
		sum=query(mid);
		if (sum-Prefix>0) r=mid;
		else l=mid+1;
	}
	return l;
}
int main()
{
//	freopen("increasing.in","r",stdin);
//	freopen("increasing.out","w",stdout);
	scanf("%s",s+1);
	n=strlen(s+1);
	rep(i,1,n) a[i]=b[i]=s[i]-'0';
	rep(i,1,n) if (a[i]==a[i-1]) pre[i]=pre[i-1]; else pre[i]=i;
	
	rep(i,1,n) if (a[i]>a[i+1]) change(i,1);
	i=1;
	while (i<=n) {
		lst=i; i=erfen(i);
		ans++;
		if (i==n) break;
		lst=max(pre[i],lst);
		a[lst]=-1; i=lst+1;
		add();
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 8576
<?php
$input_line = trim(fgets(STDIN));

for ($i = 0; $i < $input_line; $i++) {
    $s = trim(fgets(STDIN));
    $s = str_replace(array("\r\n","\r","\n"), '', $s);
    $s = explode(" ", $s);
    if (($s[0] % 2 == 0) && (($s[1] + $s[2]) % 2 == 0) && ($s[0] >= $s[1] + $s[2])) {
    	if ($i == $input_line - 1) {
        	echo "Yes";
            break;
        } else {
        	continue;
        }
    } else if (($s[0] % 2 == 1) && (($s[1] + $s[2]) % 2 == 1) && ($s[0] >= $s[1] + $s[2])) {
    	if ($i == $input_line - 1) {
        	echo "Yes";
            break;
        } else {
        	continue;
        }
    } else {
    	echo "No";
      	break;
    }
}

?>

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

int main(){
    int64_t N, A, B;
    cin >> N >> A >> B;
    N %= 12;
    for(int i=1; i<=N; i++){
        if(i%2){
            A -= B;
        }else{
            B += A;
        }
    }
    cout << A << " " << B << endl;
    return 0;
}



Measured memory_bytes: 3100
#include<algorithm>
#include<vector>
#include<list>
#include<iostream>
#include<utility>
#include<string>
#include<set>
#include<queue>
#include<stack>
#include<iterator>
#include<map>
#include<limits>
#include<iomanip>
#include<ctime>
 
const int INF=2147483647;
 
using namespace std;

//long long minEqVal;


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

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Math;

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            A();
        }

        static void A()
        {
            var b = Read();
            if (b == "A")
            {
                Println("T");
            }
            else if (b == "T")
            {
                Println("A");
            }
            else if (b == "C")
            {
                Println("G");
            }
            else if (b == "G")
            {
                Println("C");
            }
        }

        static IEnumerable<int> Range(int start, int stop)
        {
            if (start < 0 || stop < 0 || start > stop || (start <= 0 && stop <= 0))
                return new List<int>();

            return Enumerable.Range(start, stop - start);
        }

        static bool IsDigit(string str)
        {
            var i = 0;
            return int.TryParse(str, out i);
        }

        static int SumDigits(long num)
        {
            return num.ToString().Select(x => x.ToString()).Sum(int.Parse);
        }

        static int[] ToIntArray(string str)
        {
            return str.Select(x => x.ToString()).Select(int.Parse).ToArray();
        }

        static int Gcd(int a, int b) => b == 0 ? a : Gcd(b, a % b);

        static bool IsPrime(int x)
        {
            if (x <= 1 || (x != 2 && x % 2 == 0)) return false;
            if (x == 2) return true;

            for (int i = 3; i < x; i += 2)
                if (x % i == 0) return false;

            return true;
        }

        static string Read() => Console.ReadLine();
        static int ReadInt() => int.Parse(Read());
        static long ReadLong() => long.Parse(Read());

        static List<string> ReadSplit() => Read().Split().ToList();
        static List<int> ReadSplitInt() => Read().Split().Select(int.Parse).ToList();
        static List<long> ReadSplitLong() => Read().Split().Select(long.Parse).ToList();

        static void Print(object value) => Console.Write(value.ToString());
        static void Println(object value) => Console.WriteLine(value.ToString());

        static string Join<T>(IEnumerable<T> list) => string.Join("", list);
    }

    public static class MyExtensions
    {
        public static string Slice(this string str, int start = 0, int stop = 0)
        {
            if (start > str.Length || stop > str.Length || start < 0 || stop < 0)
                return "";

            if (stop == 0) stop = str.Length;
            return str.Substring(start, stop - start);
        }
    }
}

Measured memory_bytes: 13140
# -*- coding: utf-8 -*-
s = []
N = int(input())

for i in range(N):
	a = input().split()
	s.append([a[0],int(a[1]),i+1])

#同じ市に複数レスト欄があったときのために、先にスコアでソート
#reverseを指定して、スコアが高い方からにする
s.sort(key = lambda x:x[1],reverse = True)
#次に市でソート(文字コードで並び替えれば辞書順になる)することで、スコアが高い順で市を辞書順でソートできる
s.sort(key = lambda x:x[0])
for i in range(N):
	print(s[i][2])

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pll = pair<ll, ll>;
using vl = vector<ll>;

/* short */
#define pb push_back
#define mp make_pair
#define Fi first
#define Se second
#define ALL(v) begin(v), end(v)
#define RALL(v) rbegin(v), rend(v)

/* REPmacro */
#define FOR(i, a, b) for(int i = (a); i < (b); i++)
#define FORR(i, a, b) for(int i = (a); i >= (b); i--)
#define REP(i, n) for(int i = 0; i < (n); i++)
#define FOREACH(x, a) for(auto x : a)

/* exchange */
#define CHMIN(a, b) (a) = min((ll)(a), (ll)(b))
#define CHMAX(a, b) (a) = max((ll)(a), (ll)(b))

/* function */
#define IN(x) cin >> x
#define DEBUG(x) cerr << (x) << " "
#define LN() cerr << "\n"
#define PRINT(x) cout << (x) << endl
#define BR cout << endl

/* const */
const int ARRAY = 100005;
const int INF = 1001001001; // 10^9
const ll LINF = 1001001001001001001; // 10^18
const int MOD = 1e9 + 7;

ll X = 0;
ll Y = 0;
ll A, B, C;
ll t;
ll ret = 0;
string s;

priority_queue<ll> p;
priority_queue<ll> q;
priority_queue<ll> r;

priority_queue<ll, vector<ll>, greater<ll>> eated_p;
priority_queue<ll, vector<ll>, greater<ll>> eated_q;

void input() {
  IN(X);
  IN(Y);
  IN(A);
  IN(B);
  IN(C);
  REP(i, A) {
    IN(t);
    p.push(t);
  }
  REP(i, B) {
    IN(t);
    q.push(t);
  }
  REP(i, C) {
    IN(t);
    r.push(t);
  }
}

void solve() {
  REP(i, X) {
    eated_p.push(p.top());
    p.pop();
  }
  REP(i, Y) {
    eated_q.push(q.top());
    q.pop();
  }
  while(!r.empty()) {
    ll rt = r.top();
    r.pop();
    if (min(eated_q.top(), eated_p.top()) < rt) {
      if (eated_q.top() < eated_p.top()) {
        eated_q.pop();
        eated_q.push(rt);
      } else {
        eated_p.pop();
        eated_p.push(rt);
      }
    } else {
      break;
    }
  }
  while(!eated_p.empty()) {
    ret += eated_p.top();
    eated_p.pop();
  }
  while(!eated_q.empty()) {
    ret += eated_q.top();
    eated_q.pop();
  }
  PRINT(ret);
}

int main(void){
  input();
  solve();
}


Measured memory_bytes: 4852
#include <iostream>
using namespace std;
int n;
int a[100005];
int dp[100005];
int ans=0;

int main()

{
	ios::sync_with_stdio(false);
	cin>>n;
	for (int i=1;i<=n;i++)
		cin>>a[i];

	for (int i=2;i<=n;i++){
		if (a[i]<=a[i-1]) dp[i]=dp[i-1]+1;
		ans=max(ans,dp[i]);
	}

	cout<<ans<<endl;
	return 0;
}

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

#define rep(i,n) for(int i=0 ; i<(n) ; i++)
#define repr(i,n) for(int i=(n) ; i>=0 ; i--)
#define FOR(i,m,n) for(int i=(m) ; i<(n) ; i++)
#define FORR(i,m,n) for(int i=(m) ; i>=(n) ; i--)

#define All(x) (x).begin(),(x).end()

typedef long long ll;
typedef unsigned long long ull;

const int INF = 1e9;

int main(){
   string s;cin >> s;
   if(s.size() == 2){
      cout << s;
   }else{
      reverse(All(s));
      cout << s;
   }
   return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define MAXN 1000000
using namespace std;
int a[MAXN+2];
unordered_map<int,int>vis;

int f(int n){
	return (n&1 ? (3*n+1) : n/2);
}

int main() {
	int s; cin>>a[1];
	vis[a[1]] = 1;
	
	int i = 2, m;
	bool found = false;
	for(; !found; i++){
		a[i] = f(a[i-1]);
		if(vis[a[i]]){
			m = i;
			found = true;
		}
		else vis[a[i]] = 1;
	}
	printf("%d\n",m);
	return 0;
}

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

int main(){
    ll n;
    cin >> n;
    ll a[n+1];
    for(ll i=1;i<=n;i++) cin >> a[i];
    ll res=0;
    for(ll i=1;i<=n;i++){
        if(i%2==1&&a[i]%2==1) res++;
    }
    cout << res << endl;
}


Measured memory_bytes: 3596
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <numeric>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <utility>
#include <sstream>
#include <complex>

using namespace std;

#define FOR(i,a,b) for(long long i=(a);i<(b);i++)
#define REP(i,N) for(long long i=0;i<(N);i++)
#define ALL(s) (s).begin(),(s).end()
#define fi first
#define se second

#define PI acos(-1.0)
#define INF 1000000007
#define EPS 1e-10
#define MAX_N 100100
#define MAX_M 100100

typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<double, double> PD;
typedef pair<string, ll> PS;
typedef vector<ll> V;
typedef pair<P, char> PC;

bool f1[10], f2;
int n;
string s;

int main(){
	while (cin >> n&&n){
		int ans = 0;
		fill(f1, f1 + 10, 0);
		f2 = 0;
		REP(i, n){
			cin >> s;
			if (s == "ld"){
				f1[0] = 0;
				if (f2){
					if (!f1[0] && !f1[1]){
						ans++;
						f2 = 0;
					}
				}
			}
			else if (s == "rd"){
				f1[1] = 0;
				if (f2){
					if (!f1[0] && !f1[1]){
						ans++;
						f2 = 0;
					}
				}
			}
			else if (s == "lu"){
				f1[0] = 1;
				if (!f2){
					if (f1[0] && f1[1]){
						ans++;
						f2 = 1;
					}
				}
			}
			else if (s == "ru"){
				f1[1] = 1;
				if (!f2){
					if (f1[0] && f1[1]){
						ans++;
						f2 = 1;
					}
				}
			}
		}
		cout << ans << endl;
	}
}

Measured memory_bytes: 1208
def resolve():
    n,m = map(int, input().split())
    d = {}
    for i in range(m):
        a,b = map(int, input().split())
        if a not in d:
            d[a] = {}
        if b not in d:
            d[b] = {}
        d[a][b] = d[b][a] = 1

    if 1 not in d or n not in d:
        print('IMPOSSIBLE')
        return

    for a in d[1].keys():
        if a in d[n]:
            print('POSSIBLE')
            break
    else:
        print('IMPOSSIBLE')

if __name__ == '__main__':
    resolve()


Measured memory_bytes: 96760
#include <bits/stdc++.h>
using namespace std;
long long dp[100100] = {};
const int MOD = 1000000007;

int main() {
    int N, M;
    cin >> N >> M;
    for(int i=0; i<M; ++i) {
        int a;
        cin >> a;
        dp[a] = -1;
    }
    dp[0] = 1;
    for(int i=0; i<N; ++i) {
        if(dp[i] == -1) continue;
        if(i + 1 <= N && dp[i + 1] != -1) {
            dp[i + 1] += dp[i];
            dp[i + 1] %= MOD;
        }
        if(i + 2 <= N && dp[i + 2] != -1) {
            dp[i + 2] += dp[i];
            dp[i + 2] %= MOD;
        }
    }
    cout << dp[N] << endl;
}

Measured memory_bytes: 1024
#![allow(non_snake_case)]
#![allow(unused_imports)]
use proconio::input;
// use std::collections::HashMap;
// use std::collections::VecDeque;
use std::cmp::max;
use std::cmp::min;

fn main() {
    input! {
        S: String,
    }

    let N = S.len();
    if &S[N - 1..=N - 1] == "s" {
        print!("{}", S);
        println!("es");
    } else {
        print!("{}", S);
        println!("s");
    }
}


Measured memory_bytes: 2108
import sys
from collections import defaultdict

sys.setrecursionlimit(100000)
MOD = pow(10, 9) + 7
def powmod(m, p):
    if p == 0:
        return 1
    tmp = powmod(m, p // 2)
    if p & 1:
        return (tmp * tmp % MOD) * m % MOD
    else:
        return tmp * tmp % MOD


def main():
    n, m = map(int, input().split())
    div = defaultdict(lambda : 0)
    i = 2
    while i * i <= m:
        while m % i == 0:
            m //= i
            div[i] += 1
        i += 1
    if m > 1:
        div[m] += 1

    ans = 1
    for k, v in div.items():
        cn = v + n - 1
        v = min(v, cn - v)
        for i in range(v):
            ans *= cn - i
            ans %= MOD
        
        for i in range(2, v + 1):
            ans *= powmod(i, MOD - 2)
            ans %= MOD
    
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3316
#include <cstdio>
#include <vector>

using namespace std;

#define rep(i,x) for(int i=0;i<(int)(x);++i)

const long long inf = (1ll<<31) - 1;

struct SegTree {
	int n;
	vector<int> Min;
	void init(int n_) {
		n = 1;
		while (n < n_) n *= 2;
		Min.resize(2 * n);
		for (int i = 0; i < 2 * n - 1; ++i) {
			Min[i] = inf;
		}
	}
	void update(int idx, int val) {
		idx += n - 1;
		Min[idx] = val;
		while (idx > 0) {
			idx = (idx - 1) / 2;
			Min[idx] = min(Min[idx * 2 + 1], Min[idx * 2 + 2]);
		}
	}
	int get_min(int a, int b, int k = 0, int l = 0, int r = -1) {
		if (r == -1) r = n;
		if (r <= a || b <= l) return inf;
		if (a <= l && r <= b) return Min[k];
		int vl = get_min(a, b, k * 2 + 1, l, (l + r) / 2);
		int vr = get_min(a, b, k * 2 + 2, (l + r) / 2, r);
		return min(vl, vr);
	}
};

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

	SegTree seg;

	seg.init(n);

	rep(i, q) {
		int type, x, y;
		scanf("%d%d%d", &type, &x, &y);

		if (type % 2 == 0) {
			seg.update(x, y);
		} else {
			printf("%d\n", seg.get_min(x, y + 1));
		}
	}
}

Measured memory_bytes: 1796
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
const int INF = 2147483647;//int max
const int MOD = 1000000007;
using namespace std;
using ll = long long;
using P = pair<int,int>;


int main() {
    string s;
    cin >> s;
    if(s[0] == '9' || s[1] == '9')cout << "Yes\n";
    else cout << "No\n";
    return 0;
}
/*
やっほい！
　　　　　　　やほほい！
　　　　+　　 　*
　　　 ∧∧　　. ∧∞∧　*
*　ヽ(=´ω｀)人(´ω｀*)ﾉ
　.～（ O x.） （ 　 O)～　+
。*　 　∪　　　　∪
*/

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

using namespace std;
int main(){
	int a;
	int b;
	int return_value;

	// read values
	cin >> a;
	cin >> b;

	// some processing here
	if (a == b) {
		return_value = a + b;
	} else if (a > b) {
		return_value = 2 * a - 1;
	} else {
		return_value = 2 * b - 1;
	}

	cout << return_value << endl;
	
	return 0;
}

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

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef pair<int, int> P;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)


int main(){
  ll n;
  cin >> n;
  vll a(n);
  rep(i, n){cin >> a[i];}
  ll ans = 0;
  map <ll, ll> mp;
  rep(i, n){
    if (mp.find(i - a[i]) != mp.end()){
      ans += mp[i-a[i]];
    }
    if (mp.find(i+a[i]) != mp.end()){
      mp[i + a[i]] += 1;
    }
    else{
      mp[i + a[i]] = 1;
    }
  }
  cout << ans << endl;
} 

Measured memory_bytes: 17084
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#define enl printf("\n")
#define case(t) printf("Case #%d: ", (t))
#define ni(n) scanf("%d", &(n))
#define nl(n) scanf("%lld", &(n))
#define nai(a, n) for (int i = 0; i < (n); i++) ni(a[i])
#define nal(a, n) for (int i = 0; i < (n); i++) nl(a[i])
#define pri(n) printf("%d\n", (n))
#define prl(n) printf("%lld\n", (n))
#define pii pair<int, int>
#define vii vector<pii>
#define vi vector<int>
#define pb push_back
#define mp make_pair
#define fi first
#define se second
typedef long long ll;
const double pi = acos(-1);
const int MOD = 1e9 + 7;
const int INF = 1e9 + 7;
const int MAXN = 1e6 + 5;
const double eps = 1e-9;
using namespace std;
int a[MAXN];

int main()
{
    int n;
    ni(n);
    for (int i = 1; i <= n; i++)
    {
        ni(a[i]);
        a[i] -= i;
    }
    sort(a + 1, a + n + 1);
    int b = a[(1 + n) / 2];
    ll ans = 0;
    for (int i = 1; i <= n; i++)
        ans += (ll) abs(a[i] - b);
    prl(ans);
    return 0;
}


Measured memory_bytes: 1024
using System;
using System.Collections.Generic;

public class CSharp
{
    public static void Main()
    {
        Kyopuro chokudai = new Kyopuro();
        chokudai.AtCoder();
    }
}

public class Kyopuro
{

    int n;
    long[] a;
    long ans;

    public void AtCoder()
    {
        
        string[] input;
        input = Console.ReadLine().Split(' ');
        n = int.Parse(input[0]);
        a = new long[n];
        input = Console.ReadLine().Split(' ');
        for(int i=0; i<n; i++)
        {
            a[i] = long.Parse(input[i]);
        }

        ans = Solve(0, n-1, 1, 1);

        Console.WriteLine(ans);
    }

    public long Solve(int L, int R, int Lp, int Rp)
    {
        long tmp = 9999999999999999;
        if (R - L <= 1)
        {
            tmp = a[L] * Lp + a[R] * Rp;
            return tmp;
        }
        for (int i=L+1; i<R; i++)
        {
            long y = Solve(L, i, Lp, Lp + Rp);
            long z = Solve(i, R, Lp + Rp, Rp);
            if (tmp > y + z - a[i] * (Lp + Rp))
            {
                tmp = y + z - a[i] * (Lp + Rp);                
            }
        }
        return tmp;
    }
    public static void DebugWL(object x) { System.Diagnostics.Debug.WriteLine(x); }
}


Measured memory_bytes: 13140
url = "https://atcoder.jp/contests/abc162/tasks/abc162_d"
import itertools


def main():
    n, k = list(map(int, input().split()))
    a = list(map(int, input().split()))
    route = []
    istuka = [0] * (n+1)
    next = 1
    # 同じ街に訪れるまでループ
    for _ in range(k):
        if istuka[next] == 1:
            break
        else:
            istuka[next] = 1
            route.append(next)
        next = a[next - 1]
    if n >= k:
        print(next)
        exit()
    ans = route[route.index(next):]
    idx = (k - route.index(next)) % len(ans)
    print(ans[idx])



if __name__ == '__main__':
    main()

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

int main()
{
	int d, a;
	char s;
	double x = 0, y = 0, ap = 90, xi, yi;

	cin >> d >> s >> a;

	while (d != 0 || a != 0) {
		x += d * cos(ap / 180 * 3.14159);
		y += d * sin(ap / 180 * 3.14159);
		
		ap -= (double)a;
		
		cin >> d >> s >> a;
	}

	modf(x, &xi);
	modf(y, &yi);

	cout << xi << endl;
	cout << yi << endl;

	return 0;
}


Measured memory_bytes: 3384
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
//#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
template<class T>bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }
//---------------------------------------------------------------------------------------------------
/*---------------------------------------------------------------------------------------------------
　　　　　　　　　　　 ∧＿∧
　　　　　 ∧＿∧ 　（´<_｀ ）　 Welcome to My Coding Space!
　　　　 （ ´_ゝ`）　/　 ⌒i     @hamayanhamayan0
　　　　／　　　＼　 　  |　|
　　　 /　　 /￣￣￣￣/　　|
　 ＿_(__ﾆつ/　    ＿/ .| .|＿＿＿＿
　 　　　＼/＿＿＿＿/　（u　⊃
---------------------------------------------------------------------------------------------------*/














ll A, B1, B2;
//---------------------------------------------------------------------------------------------------
void _main() {
	scanf("%lld %lld.%lld", &A, &B1, &B2);

	ll ans = A * (B1 * 100 + B2) / 100;
	cout << ans << endl;
}







Measured memory_bytes: 3708
import math
pi = math.pi
a, b, h, m = map(float, input().split())

theta_a = (h/12+m/60/12)*2*pi
theta_delta = abs(theta_a - m/30*pi)
ans = math.sqrt(a**2 + b**2 - 2.0*a*b*math.cos(theta_delta))
print(ans)


Measured memory_bytes: 9432
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<iostream>
#include<vector>
#include<queue>
#include<stack>
#include<map>
#include<set>
using namespace std;
typedef long long ll;
const ll inf=1e18;
const int N=3e5+3;
multiset<int> s;
multiset<int,greater<int> > t;
ll a[N],b[N],c[N];
int n;
int main(){
    cin>>n;
    ll tmp=0,ans=-inf;
    for(int i=1;i<=n*3;i++){
    	cin>>a[i];
    	s.insert(a[i]);
    	tmp+=a[i];
    	if(s.size()>n){
    		tmp-=(*s.begin());
    		s.erase(s.begin());
    	}
    	b[i]=tmp;
    }
    tmp=0;
    for(int i=n*3;i>=1;i--){
    	t.insert(a[i]);
    	tmp+=a[i];
    	if(t.size()>n){
    		tmp-=(*t.begin());
    		t.erase(t.begin());
    	}
    	c[i]=tmp;
    }
    for(int i=n;i<=(n<<1);i++) ans=max(ans,b[i]-c[i+1]);
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 16640
import java.util.Scanner;
import java.util.Stack;
import java.util.ArrayDeque;
 
public class Main{
    public static void main(String[] aaa){
        Scanner s = new Scanner(System.in);
        Stack<Integer> x =new Stack <Integer>();
        Stack<Integer> y =new Stack <Integer>();
        int h,w,i,j,k,l,count=0,xx,yy,nx,ny;
        int[][] memo = new int[51][51];
        while(true){
        h = s.nextInt();
        w = s.nextInt();
        if(h==0&&w==0)break;
        for(i=1;i<=w;i++){
            for(j=1;j<=h;j++){
                memo[i][j] = s.nextInt();
            }
        }
        for(i=1;i<=w;i++){
            for(j=1;j<=h;j++){
                if(memo[i][j]==1){
                   // System.out.println("b"+(i)+" "+(j));
                    memo[i][j]=0;
                    x.push(i);
                    y.push(j);
                    //System.out.println("now"+now.x+" "+now.y);
                    while(x.size()>0&&y.size()>0){
                        nx=x.pop();
                        ny=y.pop();
                         
                        //System.out.println("a"+now.x+" "+now.y);
                        for(k=-1;k<=1;k++){
                            for(l=-1;l<=1;l++){
                                //if(nx==1)System.out.println("c"+(nx+k)+" "+(ny+l));
                                if((nx+k)>=1&&(nx+k)<=w&&(ny+l)>=1&&(ny+l)<=h&&memo[nx+k][ny+l]==1){
                                    memo[nx+k][ny+l]=0;
                                    x.push(nx+k);
                                    y.push(ny+l);
                                    //System.out.println("a"+(nx+k)+" "+(ny+l));
                                    //System.out.println(x.size()+" "+y.size());
                                }
                            }
                        }
                    }
                    count++;
                }
            }
        }
        System.out.println(count);
        count =0;
        for(i=1;i<=50;i++)for(j=1;j<=50;j++)memo[i][j]=0;
    }
    }
}



Measured memory_bytes: 45852
#include <stdio.h>

#define MAX 50

int main(void)
{
  int cont=0;
  int N;
  int A[MAX];
  int B[MAX];
  int C[MAX-1];
  int i;

  scanf("%d",&N);
  for(i=1;i<=N;i++)scanf("%d",&A[i]);
  for(i=1;i<=N;i++)scanf("%d",&B[i]);
  for(i=1;i<N;i++)scanf("%d",&C[i]);

  cont = B[A[N]];
  for(i=1;i<N;i++){
    cont += B[A[i]];
    if(A[i]+1==A[i+1])cont+=C[A[i]];
  }
  printf("%d\n",cont);


  return 0;
}


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

int main(void){
    string s;
    cin >> s;
    int cnt = 0, mx = 0;
    s += 'S';
    rep(i, 4){
        if(s[i] == 'R') cnt++;
        else {
            mx = max(mx, cnt);
            cnt = 0;
        }
    }
    cout << mx << endl;
    return 0;
}

Measured memory_bytes: 3620
// C++ 14
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define loop(__x, __start, __end) for(int __x = __start; __x < __end; __x++)

ll gcd3(ll a, ll b, ll c) {
  return gcd(gcd(a, b), c);
}
int main() {
  ll n; cin >> n;
  n++;
  ll sum = 0;
  loop(i,1,n) loop(j,1,n) loop(k,1,n) sum += gcd3(i,j,k);
  cout << sum << endl;
  return 0;
}


Measured memory_bytes: 3632
h,w=map(int,input().split())

s=[input() for _ in range(h)]

dx=[1,0,-1,0]
dy=[0,1,0,-1]

for i in range(h):
    for j in range(w):
        if(s[i][j]=='.'):continue
        f=False
        for k in range(4):
            ni=i+dx[k]
            nj=j+dy[k]
            if(0<=ni<=h-1 and 0<=nj<=w-1):
                if(s[ni][nj]=='#'):f=True
        if(not f):
           # print(i,j)
            print("No")
            exit()
print("Yes")

Measured memory_bytes: 3064
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

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

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

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

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

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

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

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}
fn main() {
    input! {
        n: usize,
        s: [String; n],
    }
    for i in 0..s.len() {
        if "Y" == s[i] {
            println!("Four");
            return;
        }
    }
    println!("Three");
}

Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    int n , k ; cin>>n>>k;
    double p = 0.0;
    for(int i = 1; i <= n; ++i){
        int d = 0;
        int x = i;
        while(x < k){
            d++;
            x <<= 1;
        }
        p += pow(0.5 , d);
    }
    p = p * (1.0 / n);
    printf("%0.10f\n" , p);
}


Measured memory_bytes: 256
#![allow(unused_mut)]
#![allow(non_snake_case)]
#![allow(unused_macros)]
#![allow(unused_variables)]
#![allow(unused_imports)]
// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

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

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

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

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

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

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

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

macro_rules! max {
    ($x: expr) => ($x);
    ($x: expr, $($y: expr),+) => {
        ::std::cmp::max($x, max!($($y),+))
    };
}

macro_rules! min {
    ($x: expr) => ($x);
    ($x: expr, $($y: expr),+) => {
        ::std::cmp::min($x, max!($($y),+))
    };
}

use std::cmp;
use std::collections::{HashSet, BinaryHeap, VecDeque};
use std::iter::FromIterator;
fn main() {
    input!{
        A: usize,
        B: usize,
    }

    if A < 6 {
        println!("0");
    } else if A < 13 {
        println!("{}", B/2);
    } else {
        println!("{}", B);
    }
}

Measured memory_bytes: 4352
#include <bits/stdc++.h>
#define rep(i,l,n) for(int i=l;i<n;i++)
#define all(a) a.begin(),a.end()
#define o(a) cout<<a<<endl
#define int long long
using namespace std;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> pii;

signed main(){
	int n;
	cin>>n;
	rep(i,0,n){
		string s;
		cin>>s;
		int ans=0;
		int sz=s.size();
		if(sz<6){
			ans=-1;
		}else if(s[0]=='>'&&s[1]=='\''&&s[sz-1]=='~'&&sz%2==0&&s[sz/2]=='#'){
			rep(i,2,sz-1){
				if(i!=sz/2&&s[i]!='='){
					ans=-1; break;
				}
				if(i==sz-2) ans=1;
			}
		}else if(s[0]=='>'&&s[1]=='^'&&s[sz-2]=='~'&&s[sz-1]=='~'&&sz%2==0){
			rep(i,2,sz-2){
				if(i%2==0&&s[i]!='Q'){
					ans=-1; break;
				}if(i%2&&s[i]!='='){
					ans=-1; break;
				}
				if(i==sz-3) ans=2;
			}
		}else{
			ans=-1;
		}
		if(ans==-1) o("NA");
		else if(ans==1) o("A");
		else if(ans==2) o("B");
	}	
}

Measured memory_bytes: 1204
#include <iostream>
#include <vector>
#include <string>
#include <map>
#include <algorithm>
#include <cmath>

using namespace std;

int main()
{
    int a, b;

    cin >> a >> b;

    if (a >= 13) {
        cout << b << endl;
    }
    else if (a < 13 && a >= 6) {
        cout << b/2 << endl;
    }
    else {
        cout << 0 << endl;
    }
}



Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <stdio.h>
#include <algorithm>
using namespace std;

//B - Snake Toy
//ソート問題
int main(){
    int N, K;
    int l[60];
    cin >> N >> K;
    for(int i = 0; i < N; ++i){
        cin >> l[i];
    }

    sort(l, l+N, greater<int>());
    int sum = 0;
    for(int i = 0; i < K; ++i){
        sum += l[i];
    }

    cout << sum << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pw(x) (1LL << (x))
#define db(x) cerr << #x << " = " << x << endl
#define db2(x, y) cerr << "(" << #x << ", " << #y << ") = (" << x << ", " << y << ")" << endl

using namespace std;
typedef long long ll;
typedef double dbl;
const int INF = 1.01e9;


int main() {
#ifdef HOME
    assert(freopen("in", "r", stdin));
#endif

    ll a, b, c, k;
    while (cin >> a >> b >> c >> k) {
        k %= 2;
        ll sum = a + b + c;
        if (k) {
            a = sum - a;
            b = sum - b;
            c = sum - c;
        }
        ll ans = a - b;
        if (abs(ans) > (ll)1e18) cout << "Unfair" << endl;
        else cout << ans << endl;
    }

#ifdef HOME
    cerr << "time = " << (clock() * 1. / CLOCKS_PER_SEC) << "\n";
#endif
    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cassert>
#include <cstring>
#include <string>
#include <vector>
#include <random>
#include <bitset>
#include <queue>
#include <cmath>
#include <unordered_map>
#include <set>
#include <map>
#define INCANT cin.tie(0), cout.tie(0), ios::sync_with_stdio(0), cout << fixed << setprecision(20);
#define rep(i,n) for (int i=0; i<n;++i)
#define ALL(a)  (a).begin(),(a).end()
#define PI 3.14159265358979
typedef long long ll;
using namespace std;
const ll MOD = 1e9+7LL;
const int INF = 2e9;
int N;
ll A[200005];

int main() {
  INCANT;
  cin >> N;
  rep(i, N) cin >> A[i];

  ll mx=0ll;
  ll ans =0ll;
  rep(i, N) {
    if (mx>A[i]) ans+=mx-A[i];
    else mx=A[i];
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 5212