akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using i64 = long long;
using std::cout;
using std::endl;
using std::cin;

int main() {
	int a, b, c; scanf("%d%d%d", &a, &b, &c);
	a -= b;
	a -= a / c * c;
	printf("%d\n", a);
	return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<queue>
using namespace std;
#define	 N 100
char s[4][N+5];
int lens[4];
queue<char> S[4];
int main()
{
	scanf("%s %s %s",s[1]+1,s[2]+1,s[3]+1);
	lens[1]=strlen(s[1]+1);
	lens[2]=strlen(s[2]+1);
	lens[3]=strlen(s[3]+1);
	for(int i=1;i<=3;i++)
		for(int j=1;j<=lens[i];j++)
	{
		if(i==1)
			S[1].push(s[1][j]);
		if(i==2)
			S[2].push(s[2][j]);
		if(i==3)
			S[3].push(s[3][j]);
	}
	int t=1;
	while(!S[t].empty())
	{
		int f=S[t].front();
		S[t].pop();
		t=f-'a'+1;
	}
	printf("%c",t+'a'-1-32);
 } 

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

using namespace std;

using ll = long long;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vector<int> d(n);
    for (int i = 0; i < n; i++) {
        cin >> d[i];
    }
    sort(d.begin(), d.end());
    int ok = 0, ng = d[0] + 1;
    while (ng - ok > 1) {
        int mid = (ng + ok) / 2;
        vector<int> t(n, -1);
        int cur = 0;
        for (int i = 0; i < n; i++) {
            if (d[i] - cur >= mid) {
                cur = d[i];
                t[i] = d[i];
            } else {
                t[i] = 24 - d[i]; 
            }
        }
        bool flag = true;
        for (int i = 0; i < n; i++) {
            for (int j = i + 1; j < n; j++) {
                int tmp = abs(t[i] - t[j]);
                if (min(tmp, 24 - tmp) < mid) {
                    flag = false;
                    break;
                }
            }
            if (!flag) break;
        }
        if (flag) ok = mid;
        else ng = mid;
    }
    cout << ok << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <vector>
#include <iostream>
#include<algorithm>
#include<string>
#include <map>
#include <queue>
#include <stack>
#include <set>

#define DIV 1000000007
using namespace std;
using ll = long long;

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

    string s;
    cin >> s;

    bool flag = false;
    int cnt = 0;
    for (int i = 0; i <= N ; i++) {
        if (s[i] == '1')
            cnt++;
        else {
            if (cnt >= M) {
                flag = true;
                break;
            }
            cnt = 0;
        }
    }

    if (flag) cout << -1 << endl;
    else {
        vector<int> cost(N + 1, -1);
        int right = N, temp = N;
        int cnt = 1;
        cost[N] = 0;
        for (int i = right; i >= 0; i--) {
            for (int j = 1; j <= min(M,right); j++) {
                if (s[right - j] == '0') {
                    cost[right - j] = cnt;
                    temp = right - j;
                }
            }
            right = temp;
            cnt++;
        }

        int bb = cost[0];
        vector<int> ans;
        ans.push_back(0);
        for (int i = 0; i <= N; i++) {
            if (cost[i] != -1 && cost[i] == bb - 1) {
                bb--;
                ans.push_back(i);
            }
        }

        for (int i = 1; i < ans.size(); i++)
            cout << ans[i] - ans[i - 1] << " ";
        cout << endl;

    }
    
}



Measured memory_bytes: 1528
import java.lang.Math;
import java.util.Scanner;

class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int a = scanner.nextInt();
        int b = scanner.nextInt();

        if (a == b) {
            System.out.println(a + b);
        } else {
            System.out.println(Math.max(a, b) * 2 - 1);
        }
    }
}

Measured memory_bytes: 23764
#include "bits//stdc++.h"
using namespace std;
typedef long long ll;
const ll INF = 1LL << 60;
const ll MOD = 1e9 + 7;

#define ALL(v) v.begin(), v.end()
int main() {
	int N, K;
	cin >> N >> K;
	string S;
	string ans;
	ans.resize(N);
	cin >> S;
	deque<int> que;
	int len = 1;
	for (int i = 1; i < S.size(); i++) {
		if (S[i - 1] == S[i]) {
			len++;
		}
		else {
			que.push_back(len);
			len = 1;
		}
	}
	que.push_back(len);
	bool head = (S[0] == 'B');
	int i;
	for (i = 1; i <= K; i++) {
		if (head) {
			if (que.size() == 1) {
				head = 0;
				continue;
			}
			int len = que.front(); que.pop_front();
			if (len > 1) {
				que.push_front(len - 1);
				head = 0;
				if (que.size() % 2 == 0) que.push_back(1);
				else que.back()++;
			}
			else {
				if (que.size() % 2 == 0) que.back()++;
				else que.push_back(1);
			}
		}
		else {
			int len = que.front(); que.pop_front();
			if (len > 1) {
				que.push_front(len - 1);
				que.push_front(1);
			}
			else {
				if (que.size() > 0) que.front()++;
				else que.push_front(1);
			}
			head = 1;
		}
		if (que.size() == N) break;
	}
	int pos = 0;
	while (!que.empty()) {
		int len = que.front(); que.pop_front();
		for (int i = 0; i < len; i++) {
			ans[pos++] = head ? 'B' : 'A';
		}
		head ^= 1;
	}
	if (i <= K && (K - i) % 2 == 1) {
		ans[0] = 'B';
	}
	cout << ans << endl;
}


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

using namespace std;

int main(){
  int n, a[16], x[16][16], y[16][16];
  cin >> n;
  for(int i=0;i<n;i++){
    cin >> a[i];
    for(int j=0;j<a[i];j++){
      cin >> x[i][j] >> y[i][j];
      x[i][j]--;
    }
  }
  int mx=0;
  for(int i=0;i<1<<n;i++){
    int cnt=0;
    bool ok=true;
    for(int j=0;j<n;j++){
      if((i>>j)&1){
        cnt++;
        for(int k=0;k<a[j];k++){
          if(((i>>x[j][k])&1) != y[j][k])ok=false;
        }
      }
    }
    if(ok)mx = max(cnt, mx);
  }
  cout <<mx << endl;
}



Measured memory_bytes: 256
#include <iostream>
#include <map>
#include <utility>
#include <vector>
using namespace std;

#define FOR(i,m,n) for(int i=(m);i<(n);++i)

const int MOD = 1000000007; // 998244353;
/*-------------------------------------------------*/
struct osa_k {
  osa_k(int val = 10000000) {
    least_prime_factor.assign(val + 1, -1);
    least_prime_factor[0] = 0;
    least_prime_factor[1] = 1;
    FOR(i, 2, val + 1) if (least_prime_factor[i] == -1) {
      least_prime_factor[i] = i;
      for (int j = i * i; j <= val; j += i) {
        if (least_prime_factor[j] == -1) least_prime_factor[j] = i;
      }
    }
  }

  vector<pair<int, int> > query(int val) {
    vector<pair<int, int> > res;
    while (val > 1) {
      int prime = least_prime_factor[val], exponent = 0;
      while (least_prime_factor[val] == prime) {
        ++exponent;
        val /= prime;
      }
      res.emplace_back(prime, exponent);
    }
    return res;
  }

private:
  vector<int> least_prime_factor;
};

int main() {
  cin.tie(nullptr); ios::sync_with_stdio(false);
  // freopen("input.txt", "r", stdin);

  int n; cin >> n;
  osa_k osa(n);
  map<int, int> mp;
  FOR(i, 2, n + 1) {
    vector<pair<int, int> > tmp = osa.query(i);
    for (pair<int, int> pr : tmp) mp[pr.first] += pr.second;
  }
  long long ans = 1;
  for (pair<int, int> pr : mp) (ans *= pr.second + 1) %= MOD;
  cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i, a, b) for(ll i=(a); i<(b); i++)
#define PER(i, a, b) for(ll i=(a); i>=(b); i--)
#define rep(i, n) REP(i, 0, n)
#define per(i, n) PER(i, n, 0)
#define ALL(a)  (a).begin(),(a).end()
const ll INF = 1e18+18;
const ll MAX = 200000;
const ll MOD = 1000000007;
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl;
#define YES(n) cout << ((n) ? "YES" : "NO") << endl;
static const long double pi = 3.141592653589793;



int main(){
    string S;
    cin>>S;
    cout<<S.at(0);
    cout<<S.at(1);
    cout<<S.at(2);
    cout<<endl;
    return 0;
}


Measured memory_bytes: 3632
n, m = map(int, input().split())
sc = sorted([list(map(int, input().split()))
             for _ in range(m)], key=lambda x: x[0])
result = [-1 for _ in range(n)]

for i in range(1, len(sc)):
    if sc[i][0] == sc[i-1][0] and sc[i][1] != sc[i-1][1]:
        print(-1)
        exit()

for sc_i in sc:
    index = sc_i[0] - 1
    result[index] = sc_i[1]

if n == 1:
    print(result[0] if result[0] != -1 else 0)
    exit(0)

if result[0] == 0:
    print(-1)
    exit()
elif result[0] == -1:
    result[0] = 1

for i in range(1, n):
    result[i] = result[i] if result[i] != -1 else 0

print("".join(map(str, result)))


Measured memory_bytes: 3064
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <tuple>
#include <cstring>
#include <functional>
using namespace std;
typedef long long ll;
typedef pair<long long, long long> P;
#define rep(i, n) for(long long i=0; i<n; i++)
#define reps(i, s, e) for(long long i=s; i<e; i++)
#define repr(i, n) for(long long i=n-1; i>=0; i--)
#define reprs(i, s, e) for(long long i=e-1; i>=s; i--)

int main(){

    cin.tie(0);
    ios::sync_with_stdio(false);

    ll a, b, c;
    cin >> a >> b >> c;

    if(a + b + c >= 22){
        cout << "bust" << endl;
    }
    else{
        cout << "win" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <utility>
#include <typeinfo>
#include <cmath>
#include <numeric>
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <map>
#include <stack>
#include <queue>
#include <string>
#include <vector>
#include <tuple>
#define REP(i,n) for(int i=0;i<n;i++)
typedef long long int ll;
using namespace std;
typedef vector<ll> vll;
typedef pair<ll,ll> pll;
typedef vector<pll> vpll;
typedef vector<string> vs;


int main()
{
    ll n ;
    cin >> n;
    int m = 0;
    if(n==1){cout<<1<<endl;return 0;}
    int sum = 0;
    for(int i=0; i<n ;i++)
    {
        if(sum + i + 1 > n )
        {
            m = i;
            break;
        }
        else
        {
            sum += i + 1;
        }
    }

    for(int i = 0; i < m;i++)
    {
        if(i < m - (n - sum))
        {
            cout << i+1 << endl;
        }
        else
        {
            cout << i+2 << endl;
        }
    }

   return 0 ;
}


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

int main() {
	string s,t;
	int n,m,ans,p;

	cin >> s >> t ;
	n=s.size();
	m=t.size();
	ans=m;
	rep(i, n-m+1){
		p=0;
		rep(j,m){
			if(s.at(i+j)!=t.at(j)) p++;
		}
		if (p<ans) ans=p;
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 3628
import scala.io.StdIn._

object Main {
  def main(args: Array[String]) = {
    val n = readInt
    val x = readLine.split(' ').map(a => a.toInt)

    println(x.mkString(" "))
    for (i <- 1 until n) {
      val v = x(i)
      var j = i - 1
      while (j >= 0 && x(j) > v) {
        x(j + 1) = x(j)
        j = j - 1
      }
      x(j + 1) = v

      println(x.mkString(" "))
    }
  }
}

Measured memory_bytes: 45780
import math
n = int(input())
c = [None for i in range(n-1)]
s = [None for i in range(n-1)]
f = [None for i in range(n-1)]
for i in range(n-1):
    c[i], s[i], f[i] = list(map(int, input().split()))
answer = [0 for i in range(n)]
for i in range(n-1):
    for j in range(i, n-1):
        if answer[i] > s[j]:
            answer[i] = math.ceil((answer[i] - s[j])*1./f[j]) * f[j] + s[j] + c[j]
        else:
            answer[i] = s[j] + c[j]
for i in answer:
    print (i)


Measured memory_bytes: 3188
N = int(input())
A = [list(map(int, input().split())) for _ in range(N)]
dp = [[-float('Inf')] * 3 for _ in range(N+1)]
dp[0] = [0, 0, 0]

for i in range(1, 1+N):
    for frm_action in range(3):
        for to_action in range(3):
            if frm_action == to_action:
                dp[i][to_action] = max(dp[i][to_action], dp[i-1][frm_action])
            else:
                dp[i][to_action] = max(
                    dp[i][to_action], dp[i-1][frm_action] + A[i-1][to_action])

# print(*dp, sep='\n')
print(max(dp[-1]))


Measured memory_bytes: 84692
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n;
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		char s;
		cin>>s;
		if(s=='Y')
		{
			cout<<"Four";
			exit(0);
		}
	}
	cout<<"Three";
	return 0;
}

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

int main(){
  stack<int> S;
  int a, b, x;
  string s;

  for(; cin >> s;){
    if (s[0] == '+'){
      a = S.top(); S.pop();
      b = S.top(); S.pop();
      S.push(a + b);
    }
    else if (s[0] == '-'){
      b = S.top(); S.pop();
      a = S.top(); S.pop();
      S.push(a - b);
    }
    else if (s[0] == '*'){
      a = S.top(); S.pop();
      b = S.top(); S.pop();
      S.push(a * b);
    }
    else{
      S.push(atoi(s.c_str()));
    }
  }

  cout << S.top() << endl;

  return 0;
}

Measured memory_bytes: 3204
n, k = map(int, input().split())
tds = [list(map(int, input().split())) for _ in range(n)]

tds.sort(key=lambda x:x[1])

arr = {}
for idx, td in enumerate(tds):
    t, d = td
    arr[t] = [d, n - idx - 1]

tds = [y for x, y in tds[::-1]]

base = 0
rest = sum(tds[:k])
res = 0
kind = 0
new_arr = sorted(arr.values(), reverse=True)

for x, y in new_arr:
    kind += 1
    base += x
    if y < k:
        rest -= x
        tds[y] = 0
    else:
        while k >= 1 and tds[k - 1] == 0:
            k -= 1
        rest -= tds[k - 1]
        k -= 1
        if k <= 0:
            break
    res = max(res, kind ** 2 + base + rest)

if k >= 0:
    res = max(res, kind ** 2 + base + rest)

print(res)


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

using namespace std;

#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 REPR(i, n) for(int i = n; i >= 0; i--)
#define FOREACH(x, a) for(auto &(x) : (a))
#define VECCIN(x)                                                              \
    for(auto &youso_ : (x)) cin >> youso_
#define mp make_pair
#define bitcnt __builtin_popcount
#define All(a) (a).begin(), (a).end()
template <typename T = long long> inline T IN() {
    T x;
    cin >> x;
    return (x);
}
inline void CIN() {}
template <class Head, class... Tail>
inline void CIN(Head &&head, Tail &&... tail) {
    cin >> head;
    CIN(move(tail)...);
}
#define CINT(...)                                                              \
    int __VA_ARGS__;                                                           \
    CIN(__VA_ARGS__)
#define LCIN(...)                                                              \
    ll __VA_ARGS__;                                                            \
    CIN(__VA_ARGS__)
#define SCIN(...)                                                              \
    string __VA_ARGS__;                                                        \
    CIN(__VA_ARGS__)
#define Yes(a) cout << (a ? "Yes" : "No") << "\n"
#define YES(a) cout << (a ? "YES" : "NO") << "\n"

typedef long long ll;
typedef vector<int> V;
typedef vector<ll> VL;
typedef pair<int, int> P;
typedef pair<ll, ll> PL;
typedef priority_queue<int> PQ;
typedef priority_queue<int, V, greater<int>> PQG;

const int INF = 1e9;
const int MOD = 998244353;
const ll LINF = 1e18;

int x[5], k;

int main() {
    REP(i, 5) cin >> x[i];
    int mo = INF, idx;
    REP(i, 5) {
        if(x[i] % 10) {
            if(x[i] % 10 < mo) {
                idx = i;
                mo = x[idx] % 10;
            }
        } else
            continue;
    }
    int ans = 0;
    REP(i, 5) {
        if(i == idx)
            continue;
        else {
            ans += (x[i] / 10) * 10;
            if(x[i] % 10) ans += 10;
        }
    }
    ans += x[idx];
    cout << ans << "\n";
    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++)
using ll = long long;

int main(){
  ll n, a, b;
  cin >> n >> a >> b;
  ll ans;
  if((b- a) % 2 == 0) ans = (b-a)/2;
  else {
    ll r = n-b;
    r += (n-a-r+1)/2;
    ll l = a-1;
    l += (b-l)/2;
    ans = min(l,r);
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
x=input()
y=x.split()
a=int(y[0])
b=int(y[1])
c=int(y[2])
if a>b:
    m=b
    b=a
    a=m
if b>c:
    m=c
    c=b
    b=m
if a>b:
    m=b
    b=a
    a=m
print (a,b,c)


Measured memory_bytes: 5596
#include<deque>
#include<stdint.h>
#include<set>
#include<stack>
#include <iostream>
#include <algorithm>
#include<cmath>
#include<cstring>
#include<cstdio>
#include<cstdlib>
#include<vector>
#include<iomanip>
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<queue>
#include<cstring>
#include<map>
using namespace std;
int n,m,i,j,dp[200005],ls[30],pre[200005],mx;
char as[200005];
string st;
void print(int x)
{
	cout<<as[x];
	if (pre[x]<st.size()) print(pre[x]+1);
}
int main()
{
	cin>>st;
	for (i=1;i<=26;i++) ls[i]=st.size();
	dp[st.size()]=1;
	pre[st.size()]=st.size()+1;
	for (i=st.size();i>=0;i--)
	{
		ls[st[i]-'a'+1]=i;
		mx=1;
		for (j=2;j<=26;j++) if (dp[ls[j]+1]<dp[ls[mx]+1]) mx=j;
		dp[i]=dp[ls[mx]+1]+1;pre[i]=ls[mx];as[i]=mx+'a'-1;
	}
	print(0);
	return 0;
}

Measured memory_bytes: 2564
//B - Golden Coins

#include <iostream>
#include <algorithm>

using namespace std;

int main()
{
    long long x;

    cin >> x;

    long long ans = 0;

    ans += 1000 * (x / 500);
    ans += 5 * ((x % 500) / 5);

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


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

using namespace std;

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


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define deb(x) cerr<<#x<<x<<"\n"
using namespace std;
int main(){
	int n;
	int q;
	cin>>n>>q;
	string s;
	cin>>s;
	//int no = s.size();
	vector<int> pre(n+2,0);
	int prev=-1;
	for(int i=0;i<n;i++){
		if(prev == 1){
			if(s[i] == 'C'){
				pre[i+1] = 1;
				prev = 0;
			}
		}
		if(s[i] == 'A'){
			prev = 1;
		}
		else{
			prev = 0;
		}
		pre[i+1] = pre[i]+ pre[i+1];
	}
	/*for(int i=0;i<n;i++){
		deb(pre[i+1]);
	}*/
	while(q--){
		int l,r;
		cin>>l>>r;
		//deb(pre[r]);
		//deb(pre[l-1]);
		int val = pre[l-1];
		if(s[l-1] == 'C' && l>=2 && s[l-2] == 'A'){
			val = val+1;
		}
		cout<<pre[r] - val<<"\n";
	}
	return 0;
}


Measured memory_bytes: 1408
#include<iostream>
#include <stdio.h>
using namespace std;
  
int main(){
	int n;
	for(n=0;n<3;n++){
	int h1,m1,s1,h2,m2,s2;
	cin>>h1>>m1>>s1>>h2>>m2>>s2;
	int h=h2-h1;
	int m=m2-m1;
	int s=s2-s1;
	if(s<0){m--;
	s+=60;}
	if(m<0){h--;
	m+=60;}
	cout<<h<<" "<<m<<" "<<s<<endl;
	}
	return 0;}


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

int main() {
  int N;
  int sum = 0;
  cin >> N;
  // ここにプログラムを追記
  for(int i=0; i<N; i++){
    int l, r;
    cin >> l >> r;
    sum = sum + r - l +1;
}
  cout << sum << endl;
}

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

#define int long long

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

  int n;
  cin >> n;

  if ( n == 1 ) cout << 2 << endl;
  else if ( n == 0 || n == 2 ) cout << 1 << endl;
  else cout << 0 << endl;
  
  return 0;
}



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

int main(){
  string S;
  cin >> S;
  bool a = false;
  bool b = false;
  for(int i=0;i<3;i=i+1){
    if(S.at(i) == 'A')a=true;
    else if(S.at(i) == 'B')b=true;
  }
  if(a && b)cout << "Yes" << endl;
  else cout << "No" << endl;
}


Measured memory_bytes: 256
k = int(input(''))
s = str(input(''))

while not 1 <= k <= 100:
    print('out of range! enter again')
    k = int(input(''))

while not s.islower():
    print('must be lowercase! enter again')
    s = str(input(''))
    
if k >= len(s):
    print(s)

else:
    out = s[:k] + '...'
    print(out)
    


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

long gcd(long a,long b);

int main(void){
  long a,b,n,t,k,ans=1;
  cin >> a >> b;
  n=t=gcd(a,b);
  for (k=2;k*k<=n;k++){
    if (t%k==0){
      ans++;
      while (t%k==0) t/=k;
    }
  }
  if (t!=1) ans++;
  cout << ans << endl;
  return 0;
}

long gcd(long a,long b){
  if (a>b) swap(a,b);
  if (a==0) return b;
  return gcd(b%a,a);
}

Measured memory_bytes: 256
n = int(input())
*arr, = map(int, input().split())

compressed = []

mx = max(arr)

start = 0
for i, v in enumerate(arr):
    if i == len(arr) - 1 or arr[i + 1] < arr[i]:
        compressed.append((arr[start], arr[i]))
        start = i + 1

ans = 1000
for start, end in compressed:
    ans = (ans // start * end) + ans % start

print(ans)



Measured memory_bytes: 61940
#include <bits/stdc++.h>
using namespace std;
using lint = long long int;
template<class T = int> using V = vector<T>;
template<class T = int> using VV = V< V<T> >;
template<class T> void assign(V<T>& v, int n, const T& a = T()) { v.assign(n, a); }
template<class T, class... Args> void assign(V<T>& v, int n, const Args&... args) { v.resize(n); for (auto&& e : v) assign(e, args...); }


int main() {
  cin.tie(nullptr); ios::sync_with_stdio(false);
  int n; cin >> n;
  struct Edge { int to, w; };
  VV<Edge> g(n);
  for (int i = 0; i < n - 1; ++i) {
    int s, t, w; cin >> s >> t >> w;
    g[s].push_back({t, w});
    g[t].push_back({s, w});
  }
  V<> d(n, -1);
  d[0] = 0;
  auto dfs = [&](auto dfs, int v, V<>& d) -> void {
    for (const auto& e : g[v]) if (d[e.to] == -1) {
      d[e.to] = d[v] + e.w;
      dfs(dfs, e.to, d);
    }
  };
  dfs(dfs, 0, d);
  int v0 = distance(begin(d), max_element(begin(d), end(d)));
  V<> d0(n, -1);
  d0[v0] = 0;
  dfs(dfs, v0, d0);
  int v1 = distance(begin(d0), max_element(begin(d0), end(d0)));
  V<> d1(n, -1);
  d1[v1] = 0;
  dfs(dfs, v1, d1);
  for (int i = 0; i < n; ++i) cout << max(d0[i], d1[i]) << '\n';
}


Measured memory_bytes: 4012
use std::io;

fn main() {
    let mut s = String::new();
    io::stdin().read_line(&mut s).ok();
    let x: i32 = s.trim().parse().ok().unwrap();
    let ans = if x >= 30 {
        "Yes"
    } else {
        "No"
    };
    println!("{}", ans);
}


Measured memory_bytes: 2116
import collections

n = int(input())
a=[int(i) for i in input().split()]
#a.sort()

c = collections.Counter(a)

#print(c)
ans=0
for i in set(a):
  tmp=c[i]
  if tmp-i<0:
    ans+=tmp
  else:
    ans+=tmp-i
  
print(ans)



Measured memory_bytes: 74920
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<vector>
#include<iostream>
using namespace std;
int main(){
    int N,D,X;
    int A[101];
    memset(A,0,sizeof(A));
    cin>>N;
    cin>>D>>X;
    int days=0;
    int sum=0;
    for(int i=1;i<=N;i++){cin>>A[i];}
    for(int i=1;i<=N;i++){
        while((A[i]*days+1)<=D){
            days++;
        }
        sum+=days;
        days=0;
    }

    cout<<sum+X<<endl;
}

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

int main(){
    ll n,k,ans;
    cin >> n >> k;
    vector<ll> h(n);
    rep(i,n) cin >> h[i];
    sort(h.begin(),h.end(),greater<ll>());
    for(int i = k;i < n;i++){
        ans += h[i];
    }
    cout << ans;
    return 0;
}


Measured memory_bytes: 1792
#include <iostream>
#include <bits/stdc++.h>
#include <math.h>

using namespace std;

int main(){
    int n,q;
    cin>>n>>q;
    queue<pair<string,int>> hoge;
    for(int i=0;i<n;i++){
        string s;
        int in;
        cin>>s>>in;
        pair<string,int> q=make_pair(s,in);
        hoge.push(q);
    }
    
    int t=0;
    
    while(!hoge.empty()){
        if(hoge.front().second<=q){
            t+=hoge.front().second;
            cout<<hoge.front().first<<" "<<t<<endl;
            hoge.pop();
        }else{
            t+=q;
            pair<string,int> fuga=hoge.front();
            hoge.pop();
            fuga.second-=q;
            hoge.push(fuga);
        }
    }
    
    return 0;
}


Measured memory_bytes: 6344
#include<algorithm>
#include<cmath>
#include<iostream>
#include<vector>
#include<string>
using namespace std;
typedef long long ll;

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

int main(){
    int N, K;
    int d;
    int i, j;

    cin >> N >> K;

    vector<bool> snk (N, 0);


    for(i=0;i<K;i++){
        cin >> d;
        for(j=0;j<d;j++){
            int ai;
            cin >> ai;
            snk[ai-1] = 1;
        }
    }

    cout << count(snk.begin(), snk.end(), 0) << endl;

    return 0;
}


Measured memory_bytes: 3168
#include<cstdio>
#include<queue>
#include<utility>
#include<cstring>
#include<stack>
#include<algorithm>
#include<cmath>
#include<iostream>
#define MAX_N 100002
#define INF 2147483647
#define REP(i,n) for(int i=0;i<(int)(n);i++)
int dx[4] = {1,0,0,-1};
int dy[4] = {0,1,-1,0};
using namespace std;

int par[MAX_N];
int ranks[MAX_N];

//n要素で初期化
void init(int n){
  REP(i,n){
    par[i] = i;
    ranks[i] = 0;
  }

}

//木の根を求める
int find(int x){
  if(par[x] == x){
    return x;
  }else{
    return par[x] = find(par[x]);
  }
}

void unite(int x,int y){
  x = find(x);
  y = find(y);
  if(x == y) return ;
  if(ranks[x] < ranks[y]){
    par[x] = y;
  }else{
    par[y] = x;
    if(ranks[x] == ranks[y]) ranks[x]++;
  }
}

bool same(int x, int y){
  return find(x) == find(y);
}

int main()
{
  int res=0,x[100001],y[100001],N,M,p[100001];
  cin >> N >> M;
  REP(i,N) cin >> p[i];
  REP(i,M) cin >> x[i] >> y[i];
  init(N+1);
  REP(i,M) unite(x[i],y[i]);
  REP(i,N) if(same(i+1,p[i]))res++;
  cout << res << endl;
  return 0;
}


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

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

template<class T> using v = std::vector<T>;
template<class T> using vv = v<v<T>>;

const int mod = 1000000007;
const int INF = 1001001001;
const ll LINF = 1001002003004005006ll;
//const int mod = 998244353;

struct mint {
    ll x; // typedef long long ll;
    mint(ll x=0):x((x%mod+mod)%mod){}
    mint operator-() const { return mint(-x);}
    mint& operator+=(const mint a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator-=(const mint a) {
        if ((x += mod-a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
    mint operator+(const mint a) const { return mint(*this) += a;}
    mint operator-(const mint a) const { return mint(*this) -= a;}
    mint operator*(const mint a) const { return mint(*this) *= a;}
    mint pow(ll t) const {
        if (!t) return 1;
        mint a = pow(t>>1);
        a *= a;
        if (t&1) a *= *this;
        return a;
    }

    // for prime mod
    mint inv() const { return pow(mod-2);}
    mint& operator/=(const mint a) { return *this *= a.inv();}
    mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}


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

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;}

// combination mod prime
// https://www.youtube.com/watch?v=8uowVvQ_-Mo&feature=youtu.be&t=1619
struct combination {
    vector<mint> fact, ifact;
    combination(int n):fact(n+1),ifact(n+1) {
        assert(n < mod);
        fact[0] = 1;
        for (int i = 1; i <= n; ++i) fact[i] = fact[i-1]*i;
        ifact[n] = fact[n].inv();
        for (int i = n; i >= 1; --i) ifact[i-1] = ifact[i]*i;
    }
    mint operator()(int n, int k) {
        if (k < 0 || k > n) return 0;
        return fact[n]*ifact[k]*ifact[n-k];
    }
};

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

    double ans = 0;
    cout << fixed << setprecision(10);
    int n; cin >> n;
    if (n % 2 == 0) {
        ans = .5;
        cout << ans << endl;
    } else {
        int cnt = n - (n / 2);
        ans = cnt / (double)n;
        cout << ans << endl;
    }
    return 0;
}


Measured memory_bytes: 256
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int a = sc.nextInt();
        int b = sc.nextInt();
        String res;
        if(a+b<n){
            res = Math.min(a,b) + " 0";
        }else{
            res = Math.min(a,b) + " " + (a+b-n);
        }
        System.out.println(res);
                
            
        
        
        
        
        
        }
    }

Measured memory_bytes: 38712
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var sc, wr = bufio.NewScanner(os.Stdin), bufio.NewWriter(os.Stdout)

func scanString() string   { sc.Scan(); return sc.Text() }
func scanRunes() []rune    { return []rune(scanString()) }
func scanInt() int         { a, _ := strconv.Atoi(scanString()); return a }
func scanInt64() int64     { a, _ := strconv.ParseInt(scanString(), 10, 64); return a }
func scanFloat64() float64 { a, _ := strconv.ParseFloat(scanString(), 64); return a }

func scanInts(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ {
		res[i] = scanInt()
	}
	return res
}

func debug(a ...interface{}) { fmt.Fprintln(os.Stderr, a...) }

func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}
func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}
func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

//•*¨*•.¸¸♪main•*¨*•.¸¸♪(　-ω-)ノ　(　・ω・)
func main() {
	defer wr.Flush()
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 10000), 1001001)

	k := scanInt()
	s := scanString()
	n := len(s) + k

	combInit(n)

	ans := 0
	a, b := make([]int, n), make([]int, n)
	a[0] = 1
	b[0] = 1
	for i := 1; i < n; i++ {
		a[i] = a[i-1] * 25 % mod
		b[i] = b[i-1] * 26 % mod
	}

	for i := 0; i < n; i++ {
		if i < len(s)-1 {
			continue
		}
		ans += comb(i, len(s)-1) * a[i-len(s)+1] % mod * b[n-i-1] % mod

		ans %= mod
	}

	fmt.Fprintln(wr, ans)
}

const mod = 1000000007

var fac, ifac, inv []int

func combInit(n int) {
	fac = make([]int, n+1)
	ifac = make([]int, n+1)
	inv = make([]int, n+1)

	fac[0], fac[1] = 1, 1
	ifac[0], ifac[1] = 1, 1
	inv[1] = 1

	for i := 1; i < n; i++ {
		fac[i+1] = fac[i] * (i + 1) % mod
		inv[i+1] = mod - inv[mod%(i+1)]*(mod/(i+1))%mod
		ifac[i+1] = ifac[i] * inv[i+1] % mod
	}
}

func comb(a, b int) int { return (fac[a] * ifac[b] % mod) * ifac[a-b] % mod }
func perm(a, b int) int { return fac[a] * ifac[a-b] % mod }

func mpow(a, n int) int {
	res := 1
	for n > 0 {
		if n&1 == 1 {
			res = res * a % mod
		}
		a = a * a % mod
		n >>= 1
	}
	return res
}


Measured memory_bytes: 85912
S = input()
ans = 0
for i in range(8):
    tmp = S[0]
    for j in range(3):
        if i & (1<<j):
            tmp += "-"
        else:
            tmp += "+"
        tmp += S[j+1]
    if eval(tmp) == 7:
        print(tmp+"=7")
        break


Measured memory_bytes: 2940
#include<bits/stdc++.h>
 
using namespace std;
 
#define INF 1000000007
#define LINF 1000000000000000007
 
typedef long long i64;
typedef pair<i64,i64> P;


i64 r,g,z, n;

int main(){
	cin >> r >> g >> z>> n;
	
	int c = 0;
	for(int i = 0; i <= n; i+=r){
		for(int j = 0; j + i<= n; j+=g){
			if((n-i-j) % z == 0) c++;
		}
	}
	
	cout << c << endl;
	
	return 0;
}

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

using namespace std;

int main() {
    string in;
    cin >> in;
    bool flag = true;
    for(int i = 0; i < (int)in.size(); i++) {
        if (i % 2 == 0) {
            if (in[i] == 'L') {
                flag = false;
                break;
            }
        } else {
            if (in[i] == 'R') {
                flag = false;
                break;
            }
        }
    }
    if (flag) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int n,A[20000000];
void maxHeapify(int);
int main(){
  int i;
  scanf("%d",&n);
  for(i=1;i<=n;i++){
    scanf("%d",&A[i]);
  }
  for(i=n/2;i>=1;i--){
    maxHeapify(i);
  }
  for(i=1;i<n;i++){
    printf(" %d",A[i]);
  }
  printf(" %d\n",A[i]);
}

void maxHeapify(int i){
  int l,r,largest,temp;
  l=i*2;
  r=i*2+1;
  if(l<=n && A[l]>A[i]){
    largest=l;
  }
  else{
    largest=i;
  }
  if(r<=n && A[r]>A[largest]){
    largest=r;
  }
  if(largest!=i){
    temp=A[i];
    A[i]=A[largest];
    A[largest]=temp;
    maxHeapify(largest);
  }
}



Measured memory_bytes: 3808
#include <bits/stdc++.h>
#define pi 3.14159
using namespace std;

int main()
 {
 	string s;
 	cin>>s;
		
	// string day[7]={"SUN","MON","TUE","WED","THU","FRI","SAT"}
	 if(s=="SUN")
	 	cout<<"7"<<endl;
	else if(s=="MON")
		cout<<"6"<<endl;
	else if(s=="TUE")
		cout<<"5"<<endl;
	else if(s=="WED")
		cout<<"4"<<endl;
	else if(s=="THU")
		cout<<"3"<<endl;
	else if(s=="FRI")
		cout<<"2"<<endl;
	else if(s=="SAT")
		cout<<"1"<<endl;	
 	return 0;
}
 	
 					

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<ll,ll> l_l;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
#define pb push_back
#define sz(x) (int)(x).size()
#define fi first
#define se second
#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)
const int INF=1001001000;
const int mINF=-1001001000;
const ll LINF=1010010010010010000;
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;
}
//グリッド：（典型）dp,dfs,bfs,最短経路,その他
int main(){
    ll h,w,n;cin>>h>>w>>n;
    vl a(n),b(n);rep(i,n)cin>>a[i]>>b[i];
    map<l_l,ll> mp;
    rep(i,n){
        for(int y=a[i]-2;y<=a[i];y++){
            for(int x=b[i]-2;x<=b[i];x++){
                if(y<=0||y+2>h||x<=0||x+2>w)continue;
                mp[{y,x}]++;
            }
        }
    }
    vl cnt(10);
    ll sum=0;
    for(auto now:mp){
        //cout<<now.fi.fi<<" "<<now.fi.se<<" "<<now.se<<endl;
        cnt[now.se]++;
        sum++;
    }
    cnt[0]=(h-2)*(w-2)-sum;
    rep(i,10){
        cout<<cnt[i]<<endl;
    }
    return 0;
}

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

using namespace std;

#define MODULO 1000000007

int main()
{
	long long n;
	cin >> n;
	vector<long long> prime = {2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97, 101, 103, 107, 109, 113, 127, 131, 137, 139, 149, 151, 157, 163, 167, 173, 179, 181, 191, 193, 197, 199, 211, 223, 227, 229, 233, 239, 241, 251, 257, 263, 269, 271, 277, 281, 283, 293, 307, 311, 313, 317, 331, 337, 347, 349, 353, 359, 367, 373, 379, 383, 389, 397, 401, 409, 419, 421, 431, 433, 439, 443, 449, 457, 461, 463, 467, 479, 487, 491, 499, 503, 509, 521, 523, 541, 547, 557, 563, 569, 571, 577, 587, 593, 599, 601, 607, 613, 617, 619, 631, 641, 643, 647, 653, 659, 661, 673, 677, 683, 691, 701, 709, 719, 727, 733, 739, 743, 751, 757, 761, 769, 773, 787, 797, 809, 811, 821, 823, 827, 829, 839, 853, 857, 859, 863, 877, 881, 883, 887, 907, 911, 919, 929, 937, 941, 947, 953, 967, 971, 977, 983, 991, 997};
	vector<long long> count(prime.size(), 0);
	long long result = 1;
	for (int i = 0; i < prime.size(); i++)
	{
		auto p = prime[i];
		while (p <= n)
		{
			count[i] += n/p;
			p *= prime[i];
		}
		result = (result*(count[i]+1)) % MODULO;
	}
	cout << result << endl;
	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#define max(p,q)((p)>(q)?(p):(q))
int ans;
int n,m,q;
int a[99],b[99],c[99],d[99];
int p[99];
void dfs(int pos){
	if(pos==n+1){
		int temp=0;
		for(int i=0;i<q;i++)if(p[b[i]]-p[a[i]]==c[i])temp+=d[i];
		ans=max(ans,temp);
	}else{
		for(int i=p[pos-1];i<=m;i++){
			p[pos]=i;
			dfs(pos+1);
		}
	}
}
int main(){
	scanf("%d%d%d",&n,&m,&q);
	for(int i=0;i<q;i++)scanf("%d%d%d%d",a+i,b+i,c+i,d+i);
	p[0]=1;
	dfs(1);
	printf("%d",ans);
}

Measured memory_bytes: 1704
package main

import (
	"fmt"
)

func abs(x int) int {
	if x < 0 {
		return -x
	}
	return x
}

func main() {
	var N, T, A int
	fmt.Scanf("%d", &N)
	fmt.Scanf("%d%d", &T, &A)
	a := 0
	ta := 1145141919
	for i := 0; i < N; i++ {
		var Hi int
		fmt.Scanf("%d", &Hi)
		ti := 1000*T - 6*Hi
		if abs(1000*A-ti) < abs(1000*A-ta) {
			a = i
			ta = ti
		}
	}
	fmt.Printf("%d\n", a+1)
	return
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i, s, n) for (int i = (s); i < (n); ++i)
#define rrep(i, n, g) for (int i = (n)-1; i >= (g); --i)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define len(x) (int)(x).size()
#define dup(x, y) (((x) + (y)-1) / (y))
#define pb push_back
#define Field(T) vector<vector<T>>
using namespace std;
using ll = long long;
using P = pair<int, int>;

int main() {
  int n;
  ll ans = 1;
  vector<int> num(3, -1);
  cin >> n;
  vector<int> table(n);
  rep(i, 0, n) {
    int check = 0;
    cin >> table[i];
    rep(j,0,3){
      if(num[j]==table[i]-1){
        if (check == 0){
          num[j]++;
        }
        check++;
      }
    }
    ans *= check;
    ans %= 1000000007;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3772
#define _USE_MATH_DEFINES
#include <iostream>
#include <numeric>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <iterator>
#include <math.h>
#include <cmath>
#include <set>   

using namespace std;

int main() {
	int a[3] = {};
	string x, y, z;

	for (int i = 0; i < 3; i++)
	{
		cin >> a[i];
	}
	
	sort(a, a + 3, greater<int>());
	
	x = to_string(a[0]);
	y = to_string(a[1]);

	z = x + y;
	int ans = stoi(z);

	cout << ans + a[2] << endl;
	return 0;
}

Measured memory_bytes: 256
using System;
					
public class Program
{
	public static void Main()
	{
		int n = int.Parse(Console.ReadLine());
		
		int[,] G = new int[n,n];
		
		for(int i = 0; i < n; i++) {
			int[] u = Array.ConvertAll(Console.ReadLine().Split(" ".ToCharArray()), int.Parse);
			
			for(int j = 0; j < u[1];  j++) {
				G[u[0]-1, u[j+2]-1] = 1;
			}
		}
		
		for(int i = 0; i < n ; i++) {
			for(int j = 0; j < n; j++) {
				Console.Write(G[i,j]);
				if(j == n -1) Console.WriteLine();
				else Console.Write(" ");
			}
		}
	}
}

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

int main() {
  int64_t A,B,K;
  cin >> A>>B>>K;
  if(A+B<=K)cout<<"0"<<" "<<"0"<<endl;
  else if(A<=K)cout<<"0"<<" "<<B-(K-A)<<endl;
  else cout<<A-K<<" "<<B<<endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<cmath>
#include<vector>
#include<deque>
#include<set>
#include<map>
#include<unordered_map>
#include<algorithm>

using namespace std;

#define endl                   '\n'
#define gap                    ' '
#define MAX                    LLONG_MAX
#define MIN                    LLONG_MIN
#define MOD                    1000000007
#define remax(a, b)            a = max(a, b)
#define remin(a, b)            a = min(a, b)
#define PI                     3.1415926535897932384626433832795
#define nps                    string::npos
#define int                    int64_t
#define double                 long double
#define vi                     vector<int>
#define di                     deque<int>
#define si                     set<int>
#define vpii                   vector<pair<int,int>>
#define dpii                   deque<pair<int,int>>
#define pi                     pair<int,int>
#define pub                    push_back
#define puf                    push_front
#define pob                    pop_back
#define pof                    pop_front
#define emb                    emplace_back
#define mpr                    make_pair
#define mtp                    make_tuple
#define rep(i, s, n)           for(int i = s; i < n; ++i)
#define repe(i, s, n)          for(int i = s; i <= n; ++i)
#define repr(i, n, s)          for(int i = n; i >= s; --i)
#define read(a)                for(auto& xy : a) cin >> xy
#define speak(a)               cout << endl; for(auto& xy : a) cout << xy << ' '
#define work(xy, a)            for(auto& xy : a)
#define dbg(x)                 cerr << endl << (#x) << " is " << (x)
#define sz(x)                  (int)(x).size()
#define all(a)                 (a).begin(),(a).end()
#define rall(a)                (a).rbegin(),(a).rend()

int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);

    string s;
    cin >> s;
    s += 'S';
    int ma = 0, c = 0;

    work(x, s) {
        if (x == 'R') {
            c++;
        } else {
            remax(ma, c);
            c = 0;
        }
    }
    cout << ma;
}

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

const int maxn = 200010;
int n, a[maxn], b[maxn];
long long ans;
priority_queue<pair<int, int>, vector<pair<int, int> >,
    greater<pair<int, int> > > q;

bool chk(int i) {
    return b[i] - b[(i - 1 + n) % n] - b[(i + 1) % n] >= a[i];
}

int main() {
    scanf("%d", &n);
    for (int i = 0; i < n; i++) {
        scanf("%d", &a[i]);
    }
    for (int i = 0; i < n; i++) {
        scanf("%d", &b[i]);
    }
    for (int i = 0; i < n; i++) {
        if (chk(i)) q.push({b[i], i});
    }
    while (!q.empty()) {
        int i = q.top().second; q.pop();
        int t = b[(i - 1 + n) % n] + b[(i + 1) % n];
        ans += (b[i] - a[i]) / t;
        b[i] -= (b[i] - a[i]) / t * t;
        i = (i - 1 + n) % n;
        if (chk(i)) q.push({b[i], i});
        i = (i + 2 + n) % n;
        if (chk(i)) q.push({b[i], i});
    }
    for (int i = 0; i < n; i++) {
        if (a[i] ^ b[i]) printf("-1\n"), exit(0);
    }
    printf("%lld\n", ans);
    return 0;
}

Measured memory_bytes: 2936
fun main(args: Array<String>) {
    val n = readLine()!!.toInt()
    val a = readLine()!!.split(' ').map { it.toInt() }
    val cnt = mutableMapOf<Int, Long>()
    a.map{cnt[it] = (cnt[it] ?: 0) + 1}
    val s = cnt.map { entry -> entry.value * (entry.value - 1) / 2 }.sum()
    (0 until n).map { println(s - cnt[a[it]]!! + 1) }
}

Measured memory_bytes: 104740
N, Y = map(int, input().split())
break_flag = False

for i in range(N + 1):
    
    for j in range(i, N + 1):
        a, b, c = i, j - i, N - j
        
        if(10000 * a + 5000 * b + 1000 * c == Y):
            print(a, b, c)
            
            break_flag = True
            break
    
    if break_flag: break

if not break_flag: print('-1 -1 -1')

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define rep(begin, end) for (i=begin;i<end;i++)
#define init(arr, val) for (i=0;i<end;i++) arr[i] = val;
#define printint(i0, i1) printf("%d %d\n", i0, i1)

using namespace std;
const int inf = pow(10,9);
const int nil = -1;
int i, n, m, k, ans;
int a[200001];

int main() {
    scanf(" %d", &n);
    rep(0,n) a[k] = 0;
    rep(0,n-1) {
        scanf(" %d", &k);
        a[k]++;
    }
    rep(1,n+1) {
        printf("%d\n", a[i]);
    }
}

Measured memory_bytes: 4492
#include <iostream>
//#include <iomanip>
#include <string>
#include <vector>
//#include <algorithm>
//#include <utility>
//#include <set>
#include <map>
//#include <queue>
//#include <deque>
//#include <bitset>
//#include <math.h>
using namespace std ;
using ll = long long ;
//using ld = long double ;
using vll = vector<ll> ;
//using vvll = vector<vll> ;
//using vc = vector<char> ;
//using vvc = vector<vc> ;
//using vb = vector<bool> ;
//using vvb = vector<vb> ;
//using pll = pair<ll,ll> ;
//#define all(v) v.begin(),v.end()
//ll mod = 1000000007 ;
//long double pie = acos(-1) ;
//ll INF = 1000000000000 ;

//void yorn(bool a){if(a) cout << "Yes" << endl ; else cout << "No" << endl ;}
//void YorN(bool a){if(a) cout << "YES" << endl ; else cout << "NO" << endl ;}
//ll gcd(long long a,long long b){if(b==0) return a ; return gcd(b,a%b) ;}
//ll lcm(long long a,long long b){return a/gcd(a,b)*b ;}
//ll sa(long long a,long long b){if(a>b) return a-b ; return b-a ;}
//void mysort(vector<long long> &a){sort(a.begin(),a.end()) ;}
//void myrev(vector<long long> &a){reverse(a.begin(),a.end()) ;}
//void fix_cout(){cout << fixed << setprecision(20) ;}

int main(){
	string s ; cin >> s ;
	ll n = s.size() ;
	vll sum(n+1,0) ;
	ll ten = 1 ;
	for(int i=0;i<n;i++){
		sum.at(n-1-i) = (sum.at(n-i)+(s.at(n-1-i)-'0')*ten)%2019 ;
		ten = ten*10%2019 ;
	}
//	for(auto i:sum) cout << i << " " ; cout << endl ;
	map<ll,ll> m ;
	for(int i=0;i<=n;i++) m[sum.at(i)]++ ;
	ll ans = 0 ;
	for(int i=n-1;i>=0;i--){
		ans += m[sum.at(i+1)]-1 ;
		m[sum.at(i+1)]-- ;
	}
	cout << ans << endl ;
}



Measured memory_bytes: 5152
N,K = map(int,input().split())
D = set(list(map(int,input().split())))


for i in range(N,100001): 
    tmp = i 
    while tmp > 0 and tmp % 10 not in D:
        tmp = tmp // 10 
    if tmp == 0:
        print(i)
        break 


Measured memory_bytes: 2940
/*  -*- coding: utf-8 -*-
 *
 * b.cc: B - Tax Rate
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>

using namespace std;

/* constant */

/* typedef */

/* global variables */

/* subroutines */

/* main */

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

  for (int x = n * 100 / 108;; x++) {
    int m = x * 108 / 100;
    if (m > n) break;
    if (m == n) {
      printf("%d\n", x);
      return 0;
    }
  }

  puts(":(");
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll x,ans=0;
int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
        cin>>x;
	ans+=1000*(x/500);
	x%=500;
	ans+=5*(x/5);
	x%=5;
	cout<<ans;
	return 0;
} 

Measured memory_bytes: 384
#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(){
	int n, l, l2;
	cin >> n >> l;
	l2 = l;
	int ans = 0;
	for(int i=0; i<n; i++){
    	ans += l2;
    	l2++;
    }
	vector<int> vec(n);
	if(l >= 0){
    	cout << ans-l << endl;
    }else if(n+l <= 0){
    	cout << ans-(n+l-1) << endl;
    }else{
    	cout << ans << endl;
    }
}

Measured memory_bytes: 256
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;
import java.util.stream.IntStream;

public class Main {

	/** 100までの素数 */
	private static final int[] PRIMES = new int[] { 2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61,
			67, 71, 73, 79, 83, 89, 97 };

	public static void main(String[] args) {
		try (Scanner scanner = new Scanner(System.in)) {
			int n = scanner.nextInt();
			Map<Integer, Integer> primeMap = new HashMap<>();
			IntStream.rangeClosed(2, n).forEach(i -> {
				int m = i, j = 0;
				while ((m > 1) && (m >= PRIMES[j])) {
					while (0 == (m % PRIMES[j])) {
						m /= PRIMES[j];
						primeMap.put(PRIMES[j], primeMap.getOrDefault(PRIMES[j], 0) + 1);
					}
					j++;
				}
			});
			// 約数が74個以上の素数の数
			int over74Count = (int) primeMap.values().stream().filter(i -> i >= 74).count();
			// 約数が24個以上の素数の数
			int over24Count = (int) primeMap.values().stream().filter(i -> i >= 24).count();
			// 約数が14個以上の素数の数
			int over14Count = (int) primeMap.values().stream().filter(i -> i >= 14).count();
			// 約数が4個以上の素数の数
			int over4Count = (int) primeMap.values().stream().filter(i -> i >= 4).count();
			// 約数が2個以上の素数の数
			int over2Count = (int) primeMap.values().stream().filter(i -> i >= 2).count();
			int answer = 0;
			// 75x1=75
			answer += over74Count;
			// 25x3=75
			answer += over24Count * (over2Count - 1);
			// 15x5=75
			answer += over14Count * (over4Count - 1);
			// 5x5x3=75
			answer += over4Count * (over4Count - 1) / 2 * (over2Count - 2);
			System.out.println(answer);
		}
	}
}


Measured memory_bytes: 36136
#define _GLIBCXX_DEBUG
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
using ll = long long ;
using ull = unsigned long long;
using namespace std;

int main(){
    int A, B, C;
    cin >> A >> B >> C;
    cout << C << " "<< A << " "<< B;
}

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

using namespace std;

int main() {
    string t;
    cin >> t;
    for (int i = 0; i < t.size(); i++) {
        if (t[i] == '?') t[i] = 'D';
    }
    cout << t << endl;
    return 0;
}

Measured memory_bytes: 3748