akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <cmath>
#include <algorithm>
using namespace std;
int n, a, b;

int main() {
	while(~scanf("%d %d %d", &n, &a, &b)) {
		int sum = 0;
		for(int i = 1; i <= n; i++) {
			int s = i;
			int tmp = 0;
			while(s) {
				tmp += s % 10;
				s /= 10;
			}
			if(tmp >= a && tmp <= b) sum += i;
		}
		printf("%d\n", sum);
	}
	return 0;
}

Measured memory_bytes: 128
import sys
import numba

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

@numba.njit
def main(N):
    x = 0
    for a in range(1, N+1):
        for b in range(1, N//a+1):
            x += a*b
    return x

N = int(read())
print(main(N))


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

#define REP(i, n) for (ll (i) = 0 ; (i) < (ll)(n) ; ++(i))
#define REPN(i, m, n) for (ll (i) = m ; (i) < (ll)(n) ; ++(i))
#define REP_REV(i, n) for (ll (i) = (ll)(n) - 1 ; (i) >= 0 ; --(i))
#define REPN_REV(i, m, n) for (ll (i) = (ll)(n) - 1 ; (i) >= m ; --(i))

#define INF 2e9
#define INF_LL 1LL<<60
#define ll long long

#define MAX_V 105

int main(){
    int n;
    cin >> n;
    int ans = 0;
    vector<int> a(n);
    REP(i, n) cin >> a[i];

    int tmp = 1;
    REP(i, n-1) {
        if(a[i] == a[i+1]) {
            tmp++;
        } else {
            ans += tmp / 2;
            tmp = 1;
        }
    }

    ans += tmp / 2;

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main()
{
       int k,i,a,b,c=0;
       scanf("%d %d %d",&k,&a,&b);
       i=a;
       while(i <= b)
       {
              if(i % k == 0)
              {
                     c++;
              }
              i++;
       }
       if(c == 0)
       {
           printf("NG\n");
       }
       else
       {
           printf("OK\n");
       }
       return 0;
}


Measured memory_bytes: 1600
#include <iostream>
#include <cstdio>
#include <cstring>

using namespace std;

const int MAXN = 501;
char s[MAXN][MAXN];
bool a[MAXN][MAXN] , b[MAXN][MAXN];
int h , w;

int main(){
	cin >> h >> w;
	for(int i = 0 ; i < h ; ++ i)
		cin >> s[i];
	for(int i = 0 ; i < h ; ++ i){
		a[i][0] = 1;
		b[i][w - 1] = 1;
	}
	for(int i = 0 ; i < h ; ++ i)
		if(i & 1)
			for(int j = 1 ; j < w - 1 ; ++ j)
				a[i][j] = 1;
		else
			for(int j = 1 ; j < w - 1 ; ++ j)
				b[i][j] = 1;
	for(int i = 0 ; i < h ; ++ i)
		for(int j = 0 ; j < w ; ++ j)
			if(s[i][j] == '#')
				a[i][j] = b[i][j] = 1;
	for(int i = 0 ; i < h ; ++ i , cout << endl)
		for(int j = 0 ; j < w ; ++ j)
			if(a[i][j])
				cout << '#';
			else
				cout << '.';
	cout << endl;
	for(int i = 0 ; i < h ; ++ i , cout << endl)
		for(int j = 0 ; j < w ; ++ j)
			if(b[i][j])
				cout << '#';
			else
				cout << '.';
	return 0;
}

Measured memory_bytes: 1408
#include<stdio.h>

int main(){
  int x,y,i,tmp;
  for(i=0;;i++){
    scanf("%d %d",&x,&y);
    if(x == 0 && y ==0) break;
    if(x>y){
      printf("%d %d\n",y,x);
    } else{
      printf("%d %d\n",x,y);
    }
  }

    return 0 ;
  }
      
  


Measured memory_bytes: 2032
X, N = map(int, input().split())
P = list(map(int, input().split()))
P.sort()

ans = -1
for k in range(X, -1, -1):
    if not k in P:
        ans = k
        break
for k in range(X, 102):
    if not k in P:
        if X-ans <= k-X:
            break
        else:
            ans = k
            break
print(ans)


Measured memory_bytes: 61676
s = input()
t = input()
ls = len(s)
lt = len(t)
dp = [[0] * (lt+1) for _ in range(ls+1)]

for i in range(ls):
    for j in range(lt):
        if s[i] == t[j]:
            dp[i+1][j+1] = max(dp[i+1][j+1], dp[i][j]+1)
        dp[i+1][j+1] = max(dp[i+1][j+1], dp[i+1][j])
        dp[i+1][j+1] = max(dp[i+1][j+1], dp[i][j+1])

#import numpy as np
#print(np.array(dp))

#from collections import deque
#ans = deque()

ans = ''
i, j = ls, lt
while i > 0 and j > 0:
    if dp[i][j] == dp[i-1][j]:
        i -= 1
    elif dp[i][j] == dp[i][j-1]:
        j -= 1
    else:
        i -= 1
        j -= 1
        #ans.appendleft(s[i])
        ans = s[i] + ans
#print(''.join(ans))
print(ans)

Measured memory_bytes: 113500
#include<bits/stdc++.h>
#define ll long long
#define pii pair<int,int>
#define pb push_back
#define f first
#define s second
#define MOD 1000000007
 
using namespace std;

ll mpow(int x, ll p){
	if(p==0) return 1;
	ll ans = mpow(x,p/2);
	if(p%2 == 1) return (x*((ans*ans)%MOD))%MOD;
	else return (ans*ans)%MOD;
}
ll fr[1000001];
void solve(){
	int x,y; cin>>x>>y;
	int a,b;
	fr[0] = 1;

	for(int i=1; i<=1000000; i++){
		fr[i] = (fr[i-1]*i)%MOD;
	}
	b = (2*x - y)/3;
	if((2*x - y) >=0 && (2*x - y)%3 ==0){
		b = (2*x - y)/3;
	}
	else{
		cout<<0; return;
	}
	if(x - 2*b >= 0){
		a = x - 2*b;
	}
	else{
		cout<<0; return;
	}
	cout<<(fr[a+b]*((mpow(fr[a],MOD-2)*mpow(fr[b],MOD-2))%MOD))%MOD;
}


int main()
{ 
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout<<fixed<<setprecision(12);
	
	int t =1; 
	//cin>>t;

	for(int i=1; i<=t; i++){
		solve();
		cout<<"\n";
	}
	return 0;

}

Measured memory_bytes: 8064
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int N=0;
    int D=0;
    int i=1; //人数
    cin >> N;
    cin >> D;
    while(N > (2*D+1)*i){
        i+=1;
    }
    cout << i;
    //cout << N <<D;
}

Measured memory_bytes: 384
import java.util.ArrayList;
import java.util.Collections;
import java.util.Scanner;

public class Main {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		int list_max = 10;
		ArrayList<Integer> list = new ArrayList<Integer>();
		// 標準入力を取得
		Scanner scan = new Scanner(System.in);

		for (int i = 0; i < list_max; i++) {
			list.add(scan.nextInt());
		}
		Collections.sort(list);
		System.out.println(list.get(list.size()-1));
		System.out.println(list.get(list.size()-2));
		System.out.println(list.get(list.size()-3));
	}
}

Measured memory_bytes: 17176
#include <bits/stdc++.h>
using namespace std;
const int MOD = 1e9 + 7;
//
long long fib(int);
vector<long long> val;
int main(){
    int n, m;
    cin >> n >> m;
    vector<int> a;
    a.push_back(-1);
    for(int i = 0; i < m; i++){
        int in; cin >> in;
        a.push_back(in);
    }
    a.push_back(n + 1);
    long long ans = 1;
    val.push_back(0);
    val.push_back(1);
    for(int i = 0; i < a.size() - 1; i++){
        ans = (ans * fib(a[i + 1]- a[i] - 1)) % MOD;
    }
    cout << ans << endl;
}

long long fib(int len){
    if(len <= val.size() - 1) return val[len];
    for(int i = val.size(); i <= len; i++){
        val.push_back((val[i - 2] + val[i - 1]) % MOD);
    }
    return val[len];
}

Measured memory_bytes: 1400
#include <cstdio>
int main(){
    int n,m;
    while(1){
        scanf("%d %d",&n,&m);
        if(n==0 && m==0) break;
        for(int i=0;i<n;i++){
            for(int j=0;j<m;j++){
                if((i+j)%2==1){
                    printf(".");
                }else {
                    printf("#");
                }
            }
            printf("\n");
        }
        printf("\n");
    }
    return 0;
}


Measured memory_bytes: 2604
n,m=map(int,input().split())
for i in range(n+1):
    for j in range(n+1):
        k=n-i-j
        if 0<=k:
            if 10000*i+5000*j+1000*k==m:
                print(i,j,k)
                exit()
else:
    print(-1,-1,-1)
    exit()

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std; 
const int dx[]={1,0,-1,0,1,-1,-1,1}; 
const int dy[]={0,1,0,-1,1,1,-1,-1}; 
const int INF = 1e9; 
const long long LINF = 1e18; 
const double EPS = 1e-8; 
#define pb push_back 
#define mk make_pair 
#define fr first 
#define sc second 
#define ll long long 
#define reps(i,j,k) for(int i = (j); i < (k); ++i) 
#define rep(i,j) reps(i,0,j) 
#define all(a) (a).begin(),(a).end() 
#define MOD 1000000007 
typedef pair<int,int> Pii;
typedef pair<Pii,int> P;
typedef vector<int> vi;
int H,W,D;
string stage[128];
map<pair<Pii,Pii>,int> memo;
bool used[128][128];
int search(int y,int x){
    int res = 0;
    rep(k,4){
        bool flg = true;
        int ny,nx;
        rep(d,D){
            ny = y + d*dy[k];
            nx = x + d*dx[k];
            
            if(ny < 0 || ny > H-1 || nx < 0 || nx > W-1){
                flg = false;
                break;
            }
            
            if(stage[ny][nx] == '#'){
                flg = false;
                break;
            }
            
        }
        if(flg){
            Pii a = Pii(y,x);
            Pii b = Pii(ny,nx);
            auto p = mk(a,b);
            auto q = mk(b,a);
            
            if(memo[p] || memo[q]){
                continue;
            }
            memo[p] = 1;
            memo[q] = 1;
            
            ++res;
            
        }
    }
    return res;
}
int main(){
    //input
    cin >> H >> W >> D;
    
    rep(i,H){
        cin >> stage[i];
    }
    
    int ans = 0;
    
    rep(i,H){
        rep(j,W){
            if(stage[i][j] != '#'){
                ans += search(i,j);
            }
        }
    }
    
    cout << ans << endl;
    
    return 0;
}

Measured memory_bytes: 5128
while True:
    n, x = map(int, input().split())
    if (n, x) == (0, 0): break
    ans = []
    for i in range(n, 1, -1):
        for j in range(1,n):
            tmp = x-(i+j)
            if tmp > n: continue
            if tmp > 0 and i > 0 and j > 0:
                if tmp != j and tmp != i and i != j:
                    pmt = sorted([i, j, tmp])
                    if not pmt in ans: ans.append(pmt)
    print(len(ans))



Measured memory_bytes: 5604
A, B, C = map(int, input().split())


def F(a, b, c):
    if a % 2 == 1 or b % 2 == 1 or c % 2 == 1:
        return 0
    if a == b == c:
        return -1
    return F((a + b) // 2, (b + c) // 2, (c + a) // 2) + 1


print(F(A, B, C))



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

using namespace std;

typedef long long ll;

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

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

vector<vector<int>> obs_row;
vector<vector<int>> obs_col;
vector<string> grid;

int solve(const int H, const int W) {
    int maximum = 0;
    for (int h = 1; h <= H; h++) {
        for (int w = 1; w <= W; w++) {
            if (grid[h][w] == '#') continue;
            // printf("h: %d, w: %d\n", h, w);
            auto row = obs_row[h];
            auto col = obs_col[w];
            // cout << upper_bound(row.begin(), row.end(), w) - row.begin() << endl; 
            int left = *(upper_bound(row.begin(), row.end(), w) - 1);
            int right = *(lower_bound(row.begin(), row.end(), w));
            int up = *(upper_bound(col.begin(), col.end(), h) - 1);
            int down = *(lower_bound(col.begin(), col.end(), h));
            int res = right - left - 1 + down - up - 1 - 1;
            // printf("left: %d, right: %d, up: %d, down: %d\n", left, right, up, down);
            // printf("res: %d\n", res);
            chmax(maximum, res);
        }
    }

    return maximum;
}

int main(void) {
    int H, W;
    cin >> H >> W;

    grid.resize(H + 1);
    obs_row.resize(H + 2);
    obs_col.resize(W + 2);
    for (int i = 0; i < W + 2; i++) {
        obs_col[i].push_back(0);
    }
    for (int i = 1; i <= H; i++) {
        string S;
        cin >> S;
        grid[i] = "#" + S;
        obs_row[i].push_back(0);
        for (int j = 0; j < W; j++) {
            if (S[j] == '#') {
                obs_row[i].push_back(j + 1);
                obs_col[j + 1].push_back(i);
            }
        }
        obs_row[i].push_back(W + 1);
    }
    for (int i = 0; i < W + 2; i++) {
        obs_col[i].push_back(H + 1);
    }

    // cout << "obs_row: " << endl;
    // for (int i = 0; i < (int) obs_row.size(); i++) {
    //     for (int j = 0; j < (int) obs_row[i].size(); j++) {
    //         cout << obs_row[i][j] << " ";
    //     }
    //     cout << endl;
    // }
    // cout << endl;

    // cout << "obs_col: " << endl;
    // for (int i = 0; i < (int) obs_col.size(); i++) {
    //     for (int j = 0; j < (int) obs_col[i].size(); j++) {
    //         cout << obs_col[i][j] << " ";
    //     }
    //     cout << endl;
    // }
    // cout << endl;

    cout << solve(H, W) << endl;

    return 0;
}


Measured memory_bytes: 39936
#include <iostream>
#include <vector>

const int MAX = 101;
const int START = 1;
const int GOAL = 2;

using namespace std;

int main()
{
    vector<int> load(MAX);    
    int s, f;
    while(cin >> s && cin >> f){
        load[s]++;
        load[f]++;
        if(s == 0){
            int odd_cnt = 0;
            for(int i = 1; i <=MAX; i++){
                if(load[i] % 2 == 1) odd_cnt++;
            }

            if(odd_cnt == 2){
                if(load[START] % 2 == 1 && load[GOAL] % 2 == 1){
                    cout << "OK" << endl;
                } else {
                    cout << "NG" << endl;
                }
            } else {
                cout << "NG" << endl;
            }
            for(int i = 0; i < MAX; i++){
                load[i] = 0;
            }
        }
    }
    return 0;
}

Measured memory_bytes: 1188
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
using namespace std;
int main() {
    int a,b;
    int p;
    cin >> a >> b;
    if (b % a == 0){
        p = a + b;
    }
    else{
        p = b - a; 
    }
    cout << p << endl; 
}

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

int m, k;

int main() {
	cin >> m >> k;
	int sum = 0;
	for(int i = 0; i < (1 << m); ++i) if(i != k) sum ^= i;
	if(!k) {
		for(int i = 0; i < (1 << m); ++i) printf("%d %d ", i, i);
		puts("");
		return 0;
	}
	if(sum != k) {puts("-1"); return 0;}
	printf("%d ", k);
	for(int i = 0; i < (1 << m); ++i) if(i != k) printf("%d ", i);
	printf("%d ", k);
	for(int i = (1 << m) - 1; i >= 0; --i) if(i != k) printf("%d ", i);
}

Measured memory_bytes: 1792
#include"bits/stdc++.h"
using namespace std;
typedef long long ll;
const ll MOD = (ll)(1e9+7);
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for(int (i)=0; (i)<(int)(n); (i)++)

int N;
ll W, w[1000], v[1000];

ll memo[1000][100001];
ll solve(int n, int W){
    if(W < 0) return LLONG_MIN;
    if(n == N) return 0LL;
    if(memo[n][W] != -1) return memo[n][W];
    return memo[n][W] = max(solve(n+1, W), solve(n+1, W-w[n])+v[n]);
}

signed main(){
    scanf("%d%d", &N, &W);
    assert(1 <= W && W <= 100000);
    assert(1 <= N && N <= 1000);
    rep(i, N){
        scanf("%d%d", w+i, v+i);
        assert(1 <= w[i] && w[i] <= 100000);
        assert(1 <= v[i] && v[i] <= 1000000000);
    }
    memset(memo, -1, sizeof(memo));
    printf("%lld\n", solve(0, W));
}

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

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

int N;
int P[1010];
vector<int> R;

void proc(int k) {
	R.push_back(k);
	for(int i=k;i<N;i++) swap(P[i],P[i-k]);
}

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>N;
	FOR(i,N) cin>>P[i];
	FOR(i,200*200) {
		if(P[0]&&P[N-1]&&P[N-1]>P[0]) proc(N-1);
		proc(1);
	}
	while(P[0]) proc(1);
	cout<<R.size()<<endl;
	FORR(r,R) cout<<r<<endl;
	
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}


Measured memory_bytes: 764
package main

import "fmt"

func main() {
	var a, b string
	fmt.Scan(&a, &b)

	if a == b {
		fmt.Println("EQUAL")
	} else if a > b && len(a) >= len(b) {
		fmt.Println("GREATER")
	} else {
		fmt.Println("LESS")
	}
}


Measured memory_bytes: 512
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<bitset>
#include<cstdio>
#include<cmath>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<sstream>
#include<stack>
#include<string>
#include<tuple>
#include<utility>
#include<vector>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef vector<int> vi;

#define rep(i, a, n)  for(int i=a; i<n; i++)
#define REP(i, n)  for(int i=0; i<(int)(n); i++)
#define REPS(i, n)  for(int i=1; i<=(int)(n); i++)
#define PER(i, n) for(int i=(int)(n)-1; i>= 0; i--)
#define PERS(i, n)  for(int i=(int)(n)-1; i>0; i--)
#define FOR(i, c) for(__typeof((c).begin()) i = (c).begin(); i!=(c).end(); i++)
#define RFOR(i, c)  for(__typeof((c).rbegin()) i=(c).rbegin(); i!=(c).end(); i++)
#define ALL(container)  (container).begin(), (container).end()
#define RALL(container) (container).rbegin(), (container).rend()
#define SZ(container) (container).size()
#define FILL0(n)  setfill('0') << right << setw(n)
#define mp(a, b)  make_pair(a, b)
#define toLower(c)  c+0x20
#define toUpper(c)  c-0x20
#define pb  push_back
#define eb  emplace_back

const int INF = 1<<28;
const int MOD = 1000000007;

vector<string> split(const string &str, char sep){
  vector<string>  v;
  stringstream ss(str);
  string buffer;
  while(getline(ss, buffer, sep)){
    v.push_back(buffer);
  }
  return v;
}

int main(){
  while(true){
    string s; cin >> s;
    if(s == "#")  break;
    int a, b, c, d; cin >> a >> b >> c >> d;
    a--;  b--;  c--;  d--;
    vector<string> ss = split(s, '/');
    vector<string> board(ss.size(), "");
    rep(i, 0, board.size()){
      for(const char& c:ss[i]){
        if(c=='b')  board[i]+='b';
        else{
          int num = c-'0';
          string tmp(num, '.');
          board[i]+=tmp;
        }
      }
    }
    char tmpc = board[a][b];
    board[a][b] = board[c][d];
    board[c][d] = tmpc;

    string ans = "";
    rep(i, 0, board.size()){
      int dotn = 0;
      rep(j, 0, board[i].length()){
        if(board[i][j]=='b'){
          if(dotn > 0)  {
            ans += (char)(dotn+'0');
            dotn = 0;
          }
          ans += 'b';
        }else{
          dotn++;
        }
      }
      if(dotn > 0)  ans += (char)(dotn+'0');
      if(i!=board.size()-1) ans += '/';
    }
    cout << ans << endl;
  }
  return 0;
}



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

//関数
//main関数
int main() {
    
    
    //入力
    long A,B;
    cin>>A>>B;
    //計算
    //出力
    cout<<max(2*A-1,max(A+B,2*B-1))<<endl;
}





Measured memory_bytes: 256
#include <bits/stdc++.h>
#define f first
#define s second
#define MOD 1000000007
#define PMOD 998244353
#define pb(x) push_back(x)
using namespace std;

typedef long long int ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> plii;
typedef pair<int, pii> piii;
const int INF = 1e9+10;
const ll LINF = 1LL*INF*INF;
const int MAXN = 2e5+10;
const int MAXM = 5e3+10;

priority_queue<int> pq;
vector<vector<int> > graph;
queue<int> que;

int A[MAXN];
char S[MAXN];

int main()
{
    int n,m,k,a,b,x,y,q;
    int sum = 0;
    int cnt = 0;
    int mx = 0;
    int mn = INF;
    int cur = 0, idx = -1;
    int tc;

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    cin>>S;

    n = strlen(S);

    for(int i=0;i<n;i+=2)
    {
        if(S[i]=='L'){
            cout<<"No\n";
            return 0;
        }
    }
    for(int i=1;i<n;i+=2)
    {
        if(S[i]=='R'){
            cout<<"No\n";
            return 0;
        }
    }

    cout<<"Yes\n";

    return 0;
}


Measured memory_bytes: 256
N, M, V, P = map(int, input().strip().split())
A = sorted(list(map(int, input().strip().split())),reverse=True)
ans=P

sum_=[0]*N
sum_[0]=A[0]
for i in range(1,N):
    sum_[i]=(sum_[i-1]+A[i])
# sum_=[0]
# cnt=0
# for i in range(N):
#   # 累積和
#   cnt += A[i]
#   sum_.append(cnt)

for i in range(P,N):
    thre=A[i]+M
    if thre < A[P-1]:
        continue

    remain=V-(P-1)-(N-i)
    if remain <=0:
        ans+=1
    else:
        if P!=1:
            if sum_[i-1]-sum_[P-2]+M*remain <= thre*(i-P+1):
                ans+=1
        else:
            if sum_[i-1]+M*remain <= thre*(i-P+1):
                ans+=1
print(ans)

Measured memory_bytes: 14480
import java.util.*;
import java.util.Scanner;

class Main {

    public static void main(String args[]) {
        Scanner sc = new Scanner(System.in);
        final String S = sc.nextLine();
        final int N = S.length();
        char[] seq = S.toCharArray();
        int[] ans = new int[N];

        ArrayList<Integer> RL = new ArrayList<Integer>();
        ArrayList<Integer> LR = new ArrayList<Integer>();

        // RL.add(0);
        int left = -1;

        for(int i=0;i<N-1;i++){
            if(seq[i] == 'R' && seq[i+1] == 'L'){
                ans[i] += (i-left)/2+(i-left)%2;
                ans[i+1] += (i-left)/2;
                left = i; 
                // RL.add(i);
            }else if(seq[i] == 'L' && seq[i+1] == 'R'){
                // LR.add(i);
                ans[left] += (i-left)/2;
                ans[left+1] += (i-left)/2+(i-left)%2;
                left = i;
            }
        }        
        ans[left] += (N-1-left)/2;
        ans[left+1] += (N-1-left)/2+(N-1-left)%2;
        left = N-1;


        // ans[RL.get(0)]+=RL.get(0)/2+RL.get(0)%2;
        // ans[RL.get(0)+1]+=RL.get(0)/2;



        // for(int i=1;i<RL.size();i++){
        //     int left = RL.get(0);
        //     int right = LR.get(0);

        //     ans[right]
        // }
        for(int i=0;i<N;i++){
            System.out.print(ans[i]+" ");
        }
        System.out.println();
    }
}

Measured memory_bytes: 43156
#include <bits/stdc++.h>
using namespace std;
#define IOS                           \
    std::ios::sync_with_stdio(false); \
    cin.tie(NULL);                    \
    cout.tie(NULL);
    void solve()
    {
        int n,x,t;
        cin >> n>>x >>t;
        cout << (((n+x-1)/x)*t);
    }
    int main()
    {
        IOS
        int t=1;
        while(t--)
        solve();
        return 0;
    }

Measured memory_bytes: 3620
#[allow(unused_imports)]
use std::cmp::{max, min, Ordering};
#[allow(unused_imports)]
use std::collections::{HashMap, HashSet};

mod util {
    use std::io::stdin;
    use std::str::FromStr;
    use std::fmt::Debug;

    #[allow(dead_code)]
    pub fn line() -> String {
        let mut line: String = String::new();
        stdin().read_line(&mut line).unwrap();
        line.trim().to_string()
    }

    #[allow(dead_code)]
    pub fn get<T: FromStr>() -> T
    where
        <T as FromStr>::Err: Debug,
    {
        let mut line: String = String::new();
        stdin().read_line(&mut line).unwrap();
        line.trim().parse().unwrap()
    }

    #[allow(dead_code)]
    pub fn gets<T: FromStr>() -> Vec<T>
    where
        <T as FromStr>::Err: Debug,
    {
        let mut line: String = String::new();
        stdin().read_line(&mut line).unwrap();
        line.split_whitespace()
            .map(|t| t.parse().unwrap())
            .collect()
    }

    #[allow(dead_code)]
    pub fn get2<T: FromStr, U: FromStr>() -> (T, U)
    where
        <T as FromStr>::Err: Debug,
        <U as FromStr>::Err: Debug,
    {
        let mut line: String = String::new();
        stdin().read_line(&mut line).unwrap();
        let mut iter = line.split_whitespace();
        (
            iter.next().unwrap().parse().unwrap(),
            iter.next().unwrap().parse().unwrap(),
        )
    }

    #[allow(dead_code)]
    pub fn get3<S: FromStr, T: FromStr, U: FromStr>() -> (S, T, U)
    where
        <S as FromStr>::Err: Debug,
        <T as FromStr>::Err: Debug,
        <U as FromStr>::Err: Debug,
    {
        let mut line: String = String::new();
        stdin().read_line(&mut line).unwrap();
        let mut iter = line.split_whitespace();
        (
            iter.next().unwrap().parse().unwrap(),
            iter.next().unwrap().parse().unwrap(),
            iter.next().unwrap().parse().unwrap(),
        )
    }
}

#[allow(unused_macros)]
macro_rules! debug {
    ($x: expr) => {
        println!("{}: {:?}", stringify!($x), $x)
    }
}

fn main() {
    let (n, m): (usize, usize) = util::get2();
    let xs: Vec<i64> = util::gets();
    let ys: Vec<i64> = util::gets();

    let modulo = 1000000007;

    let mut xx = 0;
    let mut yy = 0;

    for i in 0..n - 1 {
        let x = (xs[i + 1] - xs[i]) as usize;
        xx += (1 + i) * (n - i - 1) * x % modulo;
        xx %= modulo;
    }
    for k in 0..m - 1 {
        let y = (ys[k + 1] - ys[k]) as usize;
        yy += (1 + k) * (m - k - 1) * y % modulo;
        yy %= modulo;
    }

    println!("{}", xx * yy % modulo);
}


Measured memory_bytes: 10492
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> pii;
typedef pair<double,double> pdd;
#define MEM(a, b) memset(a, (b), sizeof(a))
#define SZ(i) ll(i.size())
#define FOR(i, j, k, in) for (ll i=j ; i<k ; i+=in)
#define RFOR(i, j, k, in) for (ll i=j ; i>=k ; i-=in)
#define REP(i, j) FOR(i, 0, j, 1)
#define REP1(i,j) FOR(i, 1, j+1, 1)
#define RREP(i, j) RFOR(i, j, 0, 1)
#define ALL(_a) _a.begin(),_a.end()
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define X first
#define Y second
#ifdef tmd
#define debug(...) do{\
    fprintf(stderr,"%s - %d (%s) = ",__PRETTY_FUNCTION__,__LINE__,#__VA_ARGS__);\
    _do(__VA_ARGS__);\
}while(0)
template<typename T>void _do(T &&_x){cerr<<_x<<endl;}
template<typename T,typename ...S> void _do(T &&_x,S &&..._t){cerr<<_x<<" ,";_do(_t...);}
template<typename _a,typename _b> ostream& operator << (ostream &_s,const pair<_a,_b> &_p){return _s<<"("<<_p.X<<","<<_p.Y<<")";}
template<typename It> ostream& _OUTC(ostream &_s,It _ita,It _itb)
{
    _s<<"{";
    for(It _it=_ita;_it!=_itb;_it++)
    {
        _s<<(_it==_ita?"":",")<<*_it;
    }
    _s<<"}";
    return _s;
}
template<typename _a> ostream &operator << (ostream &_s,vector<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a> ostream &operator << (ostream &_s,set<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a,typename _b> ostream &operator << (ostream &_s,map<_a,_b> &_c){return _OUTC(_s,ALL(_c));}
template<typename _t> void pary(_t _a,_t _b){_OUTC(cerr,_a,_b);cerr<<endl;}
#define IOS()
#else
#define debug(...)
#define pary(...)
#define endl '\n'
#define IOS() ios_base::sync_with_stdio(0);cin.tie(0)
#endif

template<class T> inline bool cmax(T &a, const T &b) { return b > a ? a = b, true : false; }
template<class T> inline bool cmin(T &a, const T &b) { return b < a ? a = b, true : false; }
template<class T> using MaxHeap = priority_queue<T>;
template<class T> using MinHeap = priority_queue<T, vector<T>, greater<T>>;

const ll MOD=1000000007;
const ll INF=0x3f3f3f3f3f3f3f3f;
const ll MAXN=1e5+5;
const ll MAXLG=__lg(MAXN)+2;

struct city{
    ll X,Y,idx;
    bool operator < (const city &cp) {
        if(X == cp.X)return Y < cp.Y;
        else return X < cp.X;
    }
}c[MAXN];

ll n,m;
pii ans[MAXN];
/********** Good Luck :) **********/
int main()
{
    IOS();
    cin>>n>>m;
    REP(i,m)cin>>c[i].X>>c[i].Y,c[i].idx=i;
    sort(c,c+m);

    ll idx = 0;
    ll cnt = 0;
    while(idx < m) {
        
        cnt = 0;
        while(idx<m &&(cnt==0 || c[idx].X == c[idx-1].X)) {
            ans[c[idx].idx].X = c[idx].X;
            ans[c[idx].idx].Y = ++cnt;
            idx++;
        }
    }

    REP(i,m){
        cout<<setfill('0')<<setw(6)<<ans[i].X<<setw(6)<<ans[i].Y<<endl;
    }

    return 0;
}


Measured memory_bytes: 5504
n = gets.to_i
count = []
for i in 1..n do
 x = i
 if x % 3 == 0
 count.push(i)

 else
 while x>0 && x%10 != 3 do
 x /= 10
 end
 if x % 10 == 3
 count.push(i)
 end
 end
 end
 
 print(" ")
 puts count.join(" ")
 


Measured memory_bytes: 6916
N = int(input())
l = [list(map(int, input().split())) for l in range(N)]

last = 0
for item in l:
  if last == 0 and item[0] == item[1]:
    last = 1
    continue
  elif last == 1 and item[0] == item[1]:
    last = 2
    continue
  elif last == 2 and item[0] == item[1]:
    last = 3
    break
  else:
    last = 0

if last == 3:
  print('Yes')
else:
  print('No')

Measured memory_bytes: 9080
#include<stdio.h>

int main(void)
{
  int x,y,a,b,c,d;

  scanf("%d%d%d%d",&a,&b,&c,&d);

  if(a-b>0)
   x=b;

  else if(a-b<0)
   x=a;

  if(c-d>0)
   y=d;

  else if(c-d<0)
   y=c;


  printf("%d\n",x+y);


  return 0;
}


Measured memory_bytes: 128
/* ex4_1
   YSK722 */

#include <stdio.h>

int main(void){
    int num, watch, count;
    scanf("%d %d", &num, &watch);
    while (num > 0) {
        // 一人の監視員が監視できる本数を端から数える
        num -= (watch * 2 + 1);
        // 監視員の人数
        count++;
    }
    printf("%d", count);
}

Measured memory_bytes: 128
#include <algorithm>
#include <iostream>
#include <math.h>
#include <stdio.h>
#include <string>
#include <sstream>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)

using namespace std;


int main()
{
	double L;
	cin>>L;
	double a = L / 3;
	printf("%.6lf\n",a*a*a);
	return 0;
}



Measured memory_bytes: 256
N, M = map(int, input().split())
m = [0] * (M + 1)
for _ in range(N):
    k, *a = map(int, input().split())
    for i in a:
        m[i] += 1
ans = 0
for i in m:
    if i == N:
        ans += 1
print(ans)

Measured memory_bytes: 3060
#include<iostream>
#include<sstream>

using namespace std;

bool isnum(string s){
  for(int i = 0; i < s.length(); i++)
    if('0' > s[i] || s[i] > '9') return false;
  
  return true;
}

int solve(string s){

  // cout << s << endl;

  // if(s[0] == '-') return -1*solve(s.substr(1));
  if(isnum(s)){
    stringstream ss(s);
    int tmp;
    ss >> tmp;
    return tmp;
    
  }else{
    int para = 0;

    for(int i = s.length()-1; i >= 0; i--){
      if(s[i] == '(') para++;
      if(s[i] == ')') para--;

      if((s[i] == '+' || s[i] == '-') && para == 0 && i)
	if(s[i] == '+') return solve(s.substr(0,i))+solve(s.substr(i+1));
	else return solve(s.substr(0,i))-solve(s.substr(i+1));
    }

    para = 0;

    for(int i = s.length()-1; i >= 0; i--){
      if(s[i] == '(') para++;
      if(s[i] == ')') para--;
      
      if((s[i] == '*' || s[i] == '/') && para == 0 && i)
	if(s[i] == '*') return solve(s.substr(0,i))*solve(s.substr(i+1));
	else return solve(s.substr(0,i))/solve(s.substr(i+1));
    }

    if(s[0] == '(' && s[s.length()-1] == ')')
      return solve(s.substr(1,s.length()-2));
  }
}

int main(){
  int n;
  cin >> n;
  while(n--){
    string s;
    cin >> s;
    if(s[0] == '-') cout << solve("0"+s.substr(0,s.length()-1)) << endl;
    else cout << solve(s.substr(0,s.length()-1)) << endl;
  }
  return 0;
}

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

vector<int> cal(int D, vector<vector<int>> s, vector<int> t, vector<int> c, vector<int> v) {
    vector<int> last(26);
    for(int i = 0; i < D; i++) {
        if(i == 0)
            v[i] = s[i][t[i]-1];
        else
            v[i] = v[i-1] + s[i][t[i]-1];
        
        last[t[i]-1] = i+1;
        rep(j,26) {
            v[i] -= c[j] * (i+1 - last[j]);
        }
    }
    
    return v;
}

int main() {
    int D;
    cin >> D;
    
    vector<int> c(26);
    rep(i,26) {
        cin >> c[i];
    }
    
    vector<vector<int>> s(D, vector<int>(26));
    rep(i,D) {
        rep(j,26) {
            cin >> s[i][j];
        }
    }
    
    vector<int> t(D);
    rep(i,D) {
        t[i] = 1 + (int)(rand()*(26-1+1.0)/(1.0+RAND_MAX));
    }

    int m = 100;
    
    vector<int> d(m), q(m);
    rep(i,m) {
        d[i] = 1 + (int)(rand()*(D-1+1.0)/(1.0+RAND_MAX));
        q[i] = 1 + (int)(rand()*(26-1+1.0)/(1.0+RAND_MAX));
    }
    
    //計算開始
    vector<int> v(D);
    v = cal(D,s,t,c,v);
    
    rep(i,m) {
        int old = t[d[i]-1];
        t[d[i]-1] = q[i];
        vector<int> nv = cal(D,s,t,c,v);
        
        //cout << nv.back() << endl;
        if(v.back() > nv.back())
            t[d[i]-1] = old;
        else
            v = nv;
    }

    rep(i,D) {
        cout << t[i] << endl;
    }
    
    
    return 0;
}




Measured memory_bytes: 3740
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
int main() {
  int n, a, b, ans = 0;
  cin >> n >> a >> b;
  rep(i,n+1)
  {
    int c = 0, j = i;
    while (j != 0) {
      c += j % 10;
      j /= 10;
    }
    if (c >= a && b >= c) {
      ans += i;
    }
  }
  cout << ans;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
using namespace std;
#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define INF 1000000000
int main(){
cin.tie(0);
ios::sync_with_stdio(false);

	int N,X,Y;
	cin>>N>>X>>Y;
	if(Y-X==0){
		cout<<"Borys"<<endl;
		return 0;
	}
	if((Y-X)%2==0)
		cout<<"Alice"<<endl;
	else
		cout<<"Borys"<<endl;
	
	return 0;
}

Measured memory_bytes: 384
#pragma GCC optimize ("-O3")
#pragma GCC optimize ("unroll-loops")
#include <bits/stdc++.h>
// #include <boost/multiprecision/cpp_int.hpp>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>
#define vl vector<ll>
#define pb push_back
#define el '\n'
#define pll pair<ll, ll>
#define mll map<ll,ll>
#define vpll vector<pll>
#define vvll vector<vector<ll> >
#define vvpll vector< vector<pll> >
#define ff first
#define ss second
#define bitcount(a) __builtin_popcountll(a)
#define Tanny_12 {ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);}
#define MOD 1000000007
#define fr(i,a,b) for(ll i=a ; i<b ; i++)
#define maxS 10000005
using namespace std;
using namespace __gnu_pbds;
// using namespace boost::multiprecision;
typedef long long ll;
typedef tree<ll,null_type,less_equal <ll>,rb_tree_tag,tree_order_statistics_node_update>ordered_set;

template<typename T>
void print(T arr[], ll size)
{
    fr(i,0,size)
        cout<<arr[i]<<" ";
}

int main()
{
    Tanny_12;
    
    // ll t; cin>>t; while(t--)
    {
        ll n, x;
        cin>>n>>x;
        n -= (n/x)*x;
        
        ll ans = min(n, abs(n-x));
        
        cout<<ans<<el;
    }
    
    return EXIT_SUCCESS;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#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)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define pb push_back
#define sz(x) (int)(x).size()
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
const double eps = 1e-10;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
#define dame { puts("-1"); return 0;}
#define yn {puts("YES");}else{puts("NO");}

int main(){
    int n;
    cin >> n;
    vi h(n);
    rep(i, n) cin >> h[i];

    int l,r;
    int ans = 0;
    int flag = 0;
    while(true){
        rep(i, n){
            if(h[i]!=0){
                l = i;
                break;
            }
            else if(i==n-1) flag=1;
        }

        for(int i=l;i<n;i++){
            if(h[i]==0){
                r = i;
                break;
            }
            else if(i==n-1) r=i+1;
        }

        /*
        cout << "l:" << l << "  r:" << r << endl;
        rep(i, n-1){
            cout << h[i] << ":"; 
        }
        cout << h[n-1] << endl;
        */

        for(int i=l;i<r;i++){
            h[i] -= 1;
        }

        if(flag) break;

        ans++;
    }

    cout << ans << endl;


    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define F(i,a,b) for(int i=a;i<=(b);++i)
int n,m,x,y;
bool a[100001];
int main(){
	scanf("%d%d",&n,&m);
	F(i,1,m) scanf("%d%d",&x,&y), a[x]^=1, a[y]^=1;
	F(i,1,n) if(a[i]) {puts("NO"); return 0;}
	puts("YES");
	return 0;
}

Measured memory_bytes: 384
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<utility>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<functional>
#include<math.h>
#include<random>
using namespace std;
#define N (1000000000+7)
#define M 998244353
#define INF 1e16
typedef long long ll;
typedef pair<int,int> P;
 
ll A(ll x){
    if(x>=0)return x;
    else return -x;
}
 
ll gcd(ll a, ll b) {
	if (b > a) {
		ll tmp = b;
		b = a;
		a = tmp;
	}
	if (a%b == 0)return b;
	else return gcd(b, a%b);
}

char board[30][30];

int main(void){
	int h,w,k;
	cin>>h>>w>>k;
	for(int i=0;i<h;i++){
		for(int j=0;j<w;j++){
			cin>>board[i][j];
		}
	}
	int ans = 0;
	for(int i=0;i<(1<<h);i++){
		for(int j=0;j<(1<<w);j++){
			int tmp = 0;
			for(int row =0;row<h;row++){
				for(int column = 0;column<w;column++){
					int digit1 = (i>>row)&1;
					int digit2 = (j>>column)&1;
					if(digit1==0 && digit2==0){
						if(board[row][column]=='#')tmp++;
					}
				}
			}
			if(tmp==k)ans++;
		}
	}
	cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 3628
#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 A, B, N, ans;
  cin >> A >> B >> N;

  if (N >= B) ans = floor(A*(B-1)/B);
  else ans = floor((A*N)/B);
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3632
A = [[int(a) for a in input().split()] for _ in range(3)]
N = int(input())
B = [int(input()) for _ in range(N)]

A.extend([[A[s][h] for s in range(3)] for h in range(3)])
A.append([A[s][s] for s in range(3)])
A.append([A[s][2-s] for s in range(3)])

flag_out = False
for i in range(8):
  flag = True
  for j in range(3):
    flag = (A[i][j] in B) & flag
  if(flag==True):
    print("Yes")
    flag_out = True
    break
if(flag_out==False):
  print("No")

Measured memory_bytes: 3064
let f n = Array.(to_list @@ init n @@ fun _ -> read_line ())
let ss = f @@ read_int ()
let ts = f @@ read_int ()
let _ = List.(fold_left (fun a u -> max a @@ length (filter ((=) u) ss) - length (filter ((=) u) ts)) 0 ss) |> Printf.printf "%d\n"

Measured memory_bytes: 640
n = int(input())
a1 = [int(i) for i in input().split()]
a2 = [int(i) for i in input().split()]
b1 = [0] * n
b2 = [0] * n
c1 = 0
c2 = 0
for i in range(n):
    b1[i] = c1 + a1[i]
    c1 += a1[i]
for i in range(n):
    b2[- 1 - i] = c2 + a2[- 1 - i]
    c2 += a2[- 1 - i]
d = []
for i in range(n):
    d.append(b1[i] + b2[i])
print(max(d))

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

void Main()
{
    long n;
    cin >> n;
    vector<long> x(n);
    for (int i = 0; i < n; i++)
    {
        cin >> x[i];
    }
    
    long min_sum = 10000000;
    for (int i = 1; i <= 100; i++)
    {
        int sum = 0;
        for (int j = 0; j < n; j++)
        {
            sum += (x[j] - i) * (x[j] - i);
        }
        if(min_sum > sum) min_sum = sum;
    }
    
    cout << min_sum << endl;
}

int main(int argc, char **argv)
{
    ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    Main();
    return 0;
}


Measured memory_bytes: 3524
/*
Author: miitbh1
*/
#include <bits/stdc++.h>

#define rep(i, n) for(int i=0; i<n; i++)
#define repA(i, a, n) for(int i=a; i<n; i++)
#define repD(i, a, n) for(int i=a; i>=n; i--)
#define trav(it, ctr) for(auto it=ctr.begin(); it!=ctr.end(); it++)
#define p(x) cout<<x<<"\n"
#define FIO ios_base::sync_with_stdio(false);cin.tie(NULL);
#define pp(x, y) cout<<x<<" "<<y<<"\n"
#define btc __builtin_popcount
#define all(x) x.begin(), x.end()
#define pb push_back
#define mp make_pair
#define X first
#define Y second
#define N 1000001
 
using namespace std;
 
typedef priority_queue<int> pq;
typedef pair<int, int> ii;
typedef map<int, int> mii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef long double ld;
using ll=long long int;

int32_t main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    // cout<<fixed<<setprecision(10);
    ll n, k;
    cin>>n>>k;
    int a[n];
    rep(i, n){
        cin>>a[i];
    }
    int move[N];
    memset(move, 0, sizeof move);
    ll turn=0, step=a[0], key;
    ll start[n+1], end[n+1];
    mii done;
    while(1){
        move[turn++]=step;
        if(done.find(step)==done.end()){
            start[step]=turn;
            done[step]=1;
        }
        else{
            end[step]=turn;
            key=step;
            break;
        }
        step=a[step-1];
    }
    // rep(i, turn)cout<<move[i]<<" \n"[i==turn-1];
    int l=start[key], r=end[key];
    if(key==a[0]){
        turn-=1;
        p(move[(k-1)%turn]);
        return 0;
    }
    if(k>l){
        r-=l;
        k-=l;
        k%=r;
        k+=l-1;
        // p(k);
        p(move[k]);
    }
    else{
        p(move[k-1]);
    }
    return 0;
}

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

int main() {
	int a, b, c;
	
	scanf("%d%d%d", &a, &b, &c);
	if (a == 5 && b == 5 && c == 7) {
		printf("YES");
	} else if (a == 5 && b == 7 && c == 5) {
		printf("YES");
	} else if (a == 7 && b == 5 && c == 5) {
		printf("YES");
	} else {
		printf("NO");
	}
	return 0;
}

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

#define NMAX 1000000
#define PI 3.14159265358979323846264338327950288
#define SI (PI*60.0)/180.0
using namespace std;

void koch(double p1x,double p1y,double p2x,double p2y,int n){
	if(n==0){
		printf("%.8f %.8f\n",p1x,p1y);
	}
	else{
	double sx=((p2x-p1x)/3)+p1x;
	double sy=((p2y-p1y)/3)+p1y;
	double tx=(2*(p2x-p1x)/3)+p1x;
	double ty=(2*(p2y-p1y)/3)+p1y;
	double ux=((tx-sx)*cos(SI)-(ty-sy)*sin(SI))+sx;
	double uy=((tx-sx)*sin(SI)+(ty-sy)*cos(SI))+sy;
	koch(p1x,p1y,sx,sy,n-1);
	koch(sx,sy,ux,uy,n-1);
	koch(ux,uy,tx,ty,n-1);
	koch(tx,ty,p2x,p2y,n-1);
	}
	return;
}

int main(){
	std::ios_base::sync_with_stdio(false);

	int n;

	cin>>n;
    koch(0,0,100,0,n);
	printf("%.8f %.8f\n",100.0,0.0);
    return 0;
}

Measured memory_bytes: 1244
#include "bits/stdc++.h"
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
typedef pair<int, vector<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; }

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, m;
    cin >> n >> m;
    vector<ll> x(m);
    rep(i,m) cin >> x[i];
    if(n >= m){
        cout << 0 << endl;
        return 0;
    }
    sort(x.begin(), x.end());
    vector<ll> dis(m-1);
    rep(i,m-1){
        dis[i] = x[i+1] - x[i];
    }
    sort(dis.begin(), dis.end());
    ll ans = 0;
    rep(i,m-n){
        ans += dis[i];
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 4612
// clang-format off
#include <bits/stdc++.h>

#define mp make_pair
#define fst first
#define snd second
#define forn(i,n) for (size_t i = 0; i < size_t(n); i++)
#define forn1(i,n) for (size_t i = 1; i <= size_t(n); i++)
#define popcnt __builtin_popcount
#define ffs __builtin_ffs
#define ctz __builtin_ctz
#define clz __builtin_clz
#define all(a) (a).begin(), (a).end()
 
using namespace std;

using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;
using pli = pair<ll,int>;
using pil = pair<int,ll>;
using pll = pair<ll,ll>;
template <typename T> using vec = vector<T>;
using vi = vec<int>;
using vl = vec<ll>;
template <typename T> using que = queue<T>;
template <typename T> using deq = deque<T>;

template <typename T> T id(T b) {return b;};
template <typename T> void chmax(T &x, T y) {if (x < y) x = y;}
template <typename T> void chmin(T &x, T y) {if (x > y) x = y;}
template <typename S, typename K> bool contains(S &s, K k) { return s.find(k) != s.end(); }
void fastio() { ios_base::sync_with_stdio(false); cin.tie(nullptr); }
constexpr ll TEN(int n) { if (n == 0) return 1LL; else return 10LL*TEN(n-1); }
// clang-format on

const int MAX_N = 100000;
ll n, a, b;
int h[MAX_N];

bool check(ll m) {
    ll ans = 0;
    forn(i, n) {
        ll x = (h[i] - m * b + a - b - 1) / (a - b);
        ans += max(0LL, x);
    }
    return ans <= m;
}

int main() {
    fastio();

    cin >> n >> a >> b;
    forn(i, n) cin >> h[i];

    ll l = 0, r = TEN(9);
    while (r - l > 1) {
        ll m = (l + r) / 2;
        if (check(m))
            r = m;
        else
            l = m;
    }

    cout << r << endl;

    return 0;
}

Measured memory_bytes: 768
import java.util.Scanner;
import java.util.TreeSet;

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

    int N = scanner.nextInt();
    int K = scanner.nextInt();
    int[] p = new int[N];
    int[] cummDelta = new int[N];
    for (int i = 0; i < N; i++) p[i] = scanner.nextInt();
    for (int i = 1; i < N; i++) cummDelta[i] = cummDelta[i - 1] + (p[i] > p[i - 1] ? 1 : 0);

    int count = N - K + 1;

    TreeSet<Integer> set = new TreeSet<>();
    for (int i = 0; i < K; i++) set.add(p[i]);

    boolean atLeastOneSorted = false;
    if (cummDelta[K - 1] == K - 1) {
      atLeastOneSorted = true;
      count--;
    }
    for (int i = 0; i < N - K; i++) {
      set.remove(p[i]);

      boolean sorted = cummDelta[i + K] - cummDelta[i + 1] == K - 1;
      if ((p[i] <= set.first() && p[i + K] >= set.last()) || sorted) count--;
      if (sorted) atLeastOneSorted = true;

      set.add(p[i + K]);
    }
    if (atLeastOneSorted) count++;
    System.out.println(count);
  }
}


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

using namespace std;

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

	int K;
	cin >> K;
	int res{};
	for(int a = 1; a <= K; ++a)
	{
		for(int b = 1; b <= K; ++b)
		{
			for(int c = 1; c <= K; ++c)
			{
				int g{__gcd(a, b)};
				g = __gcd(g, c);
				res += g;
			}
		}
	}
	cout << res << "\n";

	return 0;
}

Measured memory_bytes: 3648
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main(){
  // 標準入力高速化のおまじない
  // scanfとの同期を切る。以降紛らわしいのでscanf使用不可。
  ios::sync_with_stdio(false);
  // // cin前の自動flashをやめる
  cin.tie(nullptr);

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

  vector<int> A(N);
  vector<ll> sumA(N);
  vector<int> B(M);
  vector<ll> sumB(M);

  ll sum=0;
  for(int i=0; i < N; i++){
    cin >> A[i];
    sum += A[i];
    sumA[i] = sum;
  }
  sum=0;
  for(int i=0; i < M; i++){
    cin >> B[i];
    sum += B[i];
    sumB[i] = sum;
  }

  int result=0;
  // Bからのみ選ぶ場合
  vector<ll>::iterator itr = std::upper_bound(sumB.begin(), sumB.end(), K);
  result = distance(sumB.begin(), itr);
  for(int i=0; i < N; i++){
    if(sumA[i] > K){
      break;
    }
    vector<ll>::iterator itrator = std::upper_bound(sumB.begin(), sumB.end(), K-sumA[i]);
    int temp_result = (i+1) + (distance(sumB.begin(), itrator));
    if(result < temp_result) result = temp_result;

  }
  cout << result << endl;

  return 0;
}

Measured memory_bytes: 7920
N=int(input())
stringth =input()
back = None
ans = len(stringth)
REcount = stringth.count("E")
LWcount = 0
for now in stringth:
    if back == "W":
        LWcount += 1
    if now == "E":
        REcount -=1
    if ans > LWcount+REcount:
        ans = LWcount+REcount
    back = now
print(ans)

Measured memory_bytes: 3700
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int k;
    cin>>k;
    int n=k;
    int r=0;
    int count=0;
    if(n%2==0||n%5==0)
        cout<<"-1";
    else
    {
        for(int i=0;i<(1e7);i++)
        {
            r=(r*10+7)%k;
            count++;
            if(r==0)
            {
                cout<<count;
                return 0;
            }
        }
        cout<<"-1";
    }
    return 0;
}

Measured memory_bytes: 3644
use std::io;
use std::cmp;

fn read_line() -> String {
    let mut buf = String::new();
    io::stdin().read_line(&mut buf).ok();
    buf
}


fn main() {
    let n = read_line().trim().parse::<usize>().expect("invalid");
    let mut xs:Vec<i32> = read_line().split_whitespace().map(|s| s.parse().unwrap()).collect();
    xs.sort();

    let mut ans = 0;

    for i in 0..n-1 {
        if cmp::min(xs[n-1]-ans, ans) < cmp::min(xs[n-1]-xs[i], xs[i]) {
            ans = xs[i];
        }
    }

    println!("{} {}", xs[n-1], ans);
}


Measured memory_bytes: 4352