akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;

long long ans[100005];
long long a[100005], b[100005];
int main()
{
	int n,k;
	cin >> n >> k;
	for(int i = 1 ; i<= n ; i++)
	{
		cin >> a[i] >> b[i];
	}
	long long fans = 0;
	for(int i = 1 ; i <=n ; i++)
	{
		for(int j = k ; j>=a[i] ; j--)
		{
			ans[j] = max(ans[j] , b[i] + ans[j-a[i]]);
		}
	}
	for(int i = 1 ; i<=k ; i++)
		fans = max(fans , ans[i]);
	cout << fans;
	return 0;
}

Measured memory_bytes: 1024
N = int(input())
li = list(map(int, input().split()))
count = 0
while True:
    flag = False
    for i in range(N):
        if li[i] % 2 == 0:
            li[i] /= 2
        else:
            flag = True
    if flag == True: break
    count += 1
print(count)

Measured memory_bytes: 3060
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
using namespace std;
int n,a,b,c,d,i,j,k;
int main()
{
	scanf("%d%d%d%d%d",&n,&a,&b,&c,&d);
	--n;
	for(i=0;i<=n;++i)
	{
		if(i<=n-i)
		{
			j=n-i-i;
			if(1ll*i*(c-d)-1ll*j*d<=b-a&&1ll*i*(d-c)-1ll*j*c>=b-a)
			{
				printf("YES");
				return 0;
			}
		}
		else
		{
			j=i-(n-i);
			if(1ll*(n-i)*(c-d)+1ll*j*c<=b-a&&1ll*(n-i)*(d-c)+1ll*j*d>=b-a)
			{
				printf("YES");
				return 0;
			}
		}
	}
	printf("NO");
	return 0;
}


Measured memory_bytes: 128
#include<stdio.h>

#define N 500000
#define INFTY 1000000000

void mergeSort(int S[],int n,int left,int right);
void merge(int S[],int n,int left,int mid,int right);

int L[N/2 + 2],R[N/2 + 2];
int count;

int main(void)
{
  int S[N],n;
  int i;

  scanf("%d",&n);
  for(i = 0;i < n;i++){
    scanf("%d",&S[i]);
  }

  mergeSort(S,n,0,n);

  printf("%d",S[0]);
  for(i = 1;i < n;i++){
    if(i != n) printf(" ");
    printf("%d",S[i]);
  }
  printf("\n");
  printf("%d\n",count);
  
  return 0;
}
    




void merge(int S[],int n,int left,int mid,int right){
  int n1,n2;
  int i,j,k;
  
  n1 = mid - left;
  n2 = right - mid;

  for(i = 0;i < n1;i++){
    L[i] = S[left+i];
  }
  for(i = 0;i < n2;i++){
    R[i] = S[mid+i];
  }
  
  L[n1] = INFTY;
  R[n2] = INFTY;
  
  i = 0;
  j = 0;
  
  for(k = left;k < right;k++){
    if(L[i] <= R[j]){
      S[k] = L[i];
      i++;
    } else {
      S[k] = R[j];
      j++;
    }
    count++;
  }
}



void mergeSort(int S[],int n,int left,int right){
  int m;
  
  if(left+1 < right){
    m = (left + right)/2;
    
    mergeSort(S,n,left,m);
    mergeSort(S,n,m,right);
    merge(S,n,left,m,right);
  }
}



Measured memory_bytes: 5616
function gets(str){
  this._s = str.split("\n");
  this._y = 0;
};
gets.prototype = {
  a: function(f){
    var s = this._s, y = this._y, r;
    if(typeof s[y] === "string")s[y] = s[y].split(" ").reverse();
    r = s[y].pop();
    if(!s[y].length)this._y++;
    return f?r:+r;
  },
  l: function(f){
    var s = this._s[this._y++].split(" ");
    return f?s:s.map(a=>+a);
  },
  m: function(n,f){
    var s = this._s, y = this._y, r = [], i = 0;
    if(f)for(;i < n; i++)r[i] = s[y+i].split(" ");
    else for(;i < n; i++)r[i] = s[y+i].split(" ").map(a=>+a);
    this._y += n;
    return r;
  },
};
var o=new gets(require("fs").readFileSync("/dev/stdin","utf8"));
function gcd(a,b){return a<b?gcd(b,a):b?gcd(b,a%b):a;};

console.log(main());
function main(){
  var n = o.a();
  var x = o.a();
  var a = o.l();
  var ans = Math.abs(x-a[0]);
  for(var i = 1; i < n; i++){
    ans = gcd(ans, Math.abs(a[i]-a[0]));
  }
  return ans;
}

Measured memory_bytes: 21192
using System;

namespace C_BuildStairs
{
    class Program
    {
        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());
            string[] line = Console.ReadLine().Split(' ');

            int min = 1000000000;

            for(int i=n-1; 0<=i; i--){
                int hi = int.Parse(line[i]);
                if(hi<min) min = hi;
                if(min+2<=hi){
                    Console.WriteLine("No");
                    return;
                }
            }
            Console.WriteLine("Yes");
        }
    }
}


Measured memory_bytes: 24544
#!/usr/bin/env python3
import sys


def solve(T: int, X: int):
    print(T/X)
    return


# Generated by 1.1.3 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    T = int(next(tokens))  # type: int
    X = int(next(tokens))  # type: int
    solve(T, X)

if __name__ == '__main__':
    main()


Measured memory_bytes: 2940
S=input()

i=1
buf=S[0]
count=1
while i<=len(S)-1:
    if buf==S[i]:
        i=i+2
        if i<=len(S):
            count = count + 1
        buf=""
    else:
        count=count+1
        buf=S[i]
        i=i+1
print(count)

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

int main(){
 int n;
 cin >> n;
 double ans = (n%100)%10;

 if(ans==2 || ans==4 || ans==5 || ans==7 || ans==9){
   cout << "hon" << endl;
 } 
 else if(ans==0 || ans==1 || ans==6 || ans==8){
   cout << "pon" << endl;
 }
 else if(ans==3){
   cout << "bon" << endl;
 } 
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
#define maxn (int)(1e5)
#define i64 long long
#define pii pair<i64,i64>
#define all(x) x.begin(),x.end()
#define LB(x,v) lower_bound(all(x), v) - x.begin()
#define fread() freopen("in.txt", "r", stdin);
using namespace std;
int p[51];

bool solve(int n){
    int cnt=0;
    for(int i=1;i<=n;i++) {
        if(p[i] != i) cnt++;
        if(cnt > 2) return false;
    }
    return true;
}

int main() {
    /*BEFORE SUBMIT, CHECK
    sample i/o format
    statements for debugging are removed/comment out
    global values / stl containers are initialized/cleared for each test (if needed)
    all array size are sufficient
    loop variable or output value doesn't cross min/max limit of input
    // */
    
    int n,k;
    while(scanf("%d",&n)==1){
        for(int i=1;i<=n;i++) scanf("%d",&p[i]);
        printf("%s\n", solve(n) ? "YES" : "NO");     
    }
    return 0;
}

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

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout.precision(12);
    cout.setf(ios_base::fixed, ios_base::floatfield);
    
    int n, m;
    int a[1000];
    while(true){
        cin >> n >> m;
        if(n == 0 && m == 0) break;
        for(int i=0;i<n;++i) cin >> a[i];
        int ans = -1;
        for(int i=0;i<n;++i){
            for(int j=i+1;j<n;++j){
                if(a[i] + a[j] <= m) ans = max(ans, a[i] + a[j]);
            }
        }
        if(ans >= 0) printf("%d\n", ans);
        else printf("NONE\n");
    }
    
    return 0;
}


Measured memory_bytes: 3144
#include <algorithm>
#include <iostream>
#include <vector>
#include <math.h>
#include <set>
#include <map>
#include <string>
#include <stack>
#include <queue>
#include <iomanip>
#include <numeric>
#define _USE_MATH_DEFINES
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
double pi = 3.141592653589793;
ll mod = 1000000007;
int intmax = 2147483647;
int intmin = -2147483648;
ll llmax = 9223372036854775807;
ll llmin = -9223372036854775808;

struct unionFind {
    vector<int> data;
    unionFind(int size) : data(size, -1) {}
    
    bool unite(int x, int y) {
        x = root(x);
        y = root(y);
        if (x != y) {
            if(data[y] < data[x]) {
                swap(x, y);
            }
            data[x] += data[y];
            data[y] = x;
        }
        return x != y;
    }

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

    int root(int x) {
        return (data[x] < 0) ? x : data[x] = root(data[x]);
    }

    int rank(int x) {
        return -data[root(x)];
    }
};

struct edge {
    int from, to, cost;
};

bool asc (const edge &e, const edge &f) {
    return (e.cost != f.cost) ? e.cost < f.cost : (e.from != f.from ? e.from < f.from : e.to < f.to);
}

int mat[200][200];

int main() {
    int N;
    cin >> N;
    vector<edge> G;
    for (int i = 0; i < N; i++) {
        for (int j = 0; j < N; j++) {
            cin >> mat[i][j];
        }
    }
    for (int i = 0; i < N; i++) {
        for (int j = i + 1; j < N; j++) {
            if (mat[i][j] != -1) {
                edge e;
                e.from = i;
                e.to = j;
                e.cost = mat[i][j];
                G.push_back(e);
            }
        }
    }
    sort(G.begin(), G.end(), asc);
    int ans = 0;
    int num = 0;
    unionFind u(N);
    for (int i = 0; i < G.size(); i++) {
        if (u.root(G[i].from) != u.root(G[i].to)) {
            u.unite(G[i].from, G[i].to);
            ans += G[i].cost;
            num++;
        }
        if (num == N - 1) {
            break;
        }
    }
    cout << ans << endl;
}



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

using ll = long long;
#define ALL(c) (c).begin(), (c).end()
const int MOD = 1000000007;

int main() {
    int n;
    cin >> n;

    vector<int> c(n - 1);
    vector<int> s(n - 1);
    vector<int> f(n - 1);
    for (int i = 0; i < n - 1; i++) {
        cin >> c[i] >> s[i] >> f[i];
    }

    for (int i = 0; i < n - 1; i++) {
        int t = 0;
        for (int j = i; j < n - 1; j++) {
            if (t < s[j]) {
                t = s[j] + c[j];
            } else {
                if (t % f[j] == 0) {
                    t += c[j];
                } else {
                    t += (f[j] - (t % f[j])) + c[j];
                }
            }
        }
        cout << t << endl;
    }
    cout << 0 << endl;
}


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

#define rep(i, n) for (int i = (int)(0); i < (int)(n); ++i)
#define reps(i, n) for (int i = (int)(1); i <= (int)(n); ++i)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rreps(i, n) for (int i = ((int)(n)); i > 0; i--)
#define irep(i, m, n) for (int i = (int)(m); i < (int)(n); ++i)
#define ireps(i, m, n) for (int i = (int)(m); i <= (int)(n); ++i)
#define FOR(e, c) for (auto &e : c)
#define SORT(v, n) sort(v, v + n);
#define vsort(v) sort(v.begin(), v.end());
#define rvisort(v) sort(v.begin(), v.end(), greater<int>());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
#define replace_all(s, b, a) replace(s.begin(),s.end(), b, a);
// #define int long long
#define PI (acos(-1))
#define FILL(v, n, x) fill(v, v + n, x);
#define sz(x) int(x.size())

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using ul = unsigned long;

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

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

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

inline bool inside(int y, int x, int H, int W) {
    return (y >= 0 && x >= 0 && y < H && x < W);
}

const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

signed main()
{
  cin.tie( 0 ); ios::sync_with_stdio( false );
  int n; cin>>n;
  vi s(100005);
  rep(i,n){
    int a; cin>>a;
    s[a]++;
  }
  
  bool flg=true;
  for(int i=n-1;i>0;i-=2){
    if(s[i]!=2) flg=false;
  }
  if(flg){
    ll ans=1;
    rep(i,n/2) (ans*=2)%=MOD;
    cout<<ans<<endl;
  }else{
    cout<<0<<endl;
  }
  
}


Measured memory_bytes: 640
package main

import (
	"fmt"
)

func main() {
	var x, n int
	fmt.Scan(&x, &n)

	ps := make([]int, n)
	pm := make(map[int]bool)
	for i := 0; i < n; i++ {
		fmt.Scan(&ps[i])
		pm[ps[i]] = true
	}

	qs := make([]int, 0)
	for i := 0; i <= 110; i++ {
		if _, ok := pm[i]; !ok {
			qs = append(qs, i)
		}
	}

	ans := 0
	min := int(1e5)
	for i := 0; i < len(qs); i++ {
		q := qs[i]
		d := abs(x - q)
		if d < min {
			ans = q
			min = d
		}
	}

	fmt.Println(ans)
}

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


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

#define vec                vector<int>
#define vecll              vector<ll>
#define vecd               vector<double>
#define vecst              vector<string>
#define vecb               vector<bool>
#define vec2(var, n, m)    vector<vector<int>> var(n, vector<int>(m, 0))
#define vecll2(var, n, m)  vector<vector<ll>> var(n, vector<ll>(m, 0))

#define rep(i,n)         for(ll i=(ll)0; i<(ll)n; i++)
#define REP(i,m,n)       for(ll i=(ll)m; i<(ll)n; i++)
#define arr(var, n)      vec var(n); rep(i,n){cin >> var[i];}
#define arrll(var, n)    vecll var(n); rep(i,n){cin >> var[i];}
#define arrst(var, n)    vecst var(n); rep(i,n){cin >> var[i];}
#define all(var)         (var).begin(), (var).end()
#define sortall(var)     sort(all(var))
#define uniqueall(v)     v.erase(unique(v.begin(), v.end()), v.end());
#define f_sum(var)       accumulate(all(var), 0)
#define f_sumll(var)     accumulate(all(var), 0LL)
#define chmin(v1, v2)    v1 = min(v1, v2)
#define chmax(v1, v2)    v1 = max(v1, v2)
#define pb(var)          push_back(var)
#define prt(var)         cout << (var) << "\n"
#define prtd(n, var)     cout << fixed << setprecision(n) << (var) << "\n"
#define prtfill(n, var)  cout << setw(n) << setfill('0') << (var);
#define prt2(v1, v2)     cout << (v1) << " " << (v2) << "\n"
#define prt3(v1, v2, v3) cout << (v1) << " " << (v2) << " " << (v3) << "\n"
#define prtall(v)        rep(i,v.size()){cout<<v[i]<<(i!=v.size()-1?" ":"\n");}
void prtok(bool ok){prt(ok ? "Yes" : "No");}
//----------------------------------------------------------------

int main(void) {
  ll n;
  cin >> n;
  vecll f(n+1);
  REP(i,1,n+1){
    for(ll j=1; i*j<=n; j++){
      f[i*j]++;
    }
  }

  ll ans=0;
  REP(i,1,n+1){
    ans += i * f[i];
  }

  prt(ans);
}


Measured memory_bytes: 81412
import java.util.*

fun main(args: Array<String>) {
    val scanner = Scanner(System.`in`)
    val a = scanner.nextInt()
    val b = scanner.nextInt()
    val c = scanner.nextInt()

    if (a == b && b == c) {
        println(0)
        return
    }

    val dp = Array(70) {
        Array(70) {
            Array(70) { Int.MAX_VALUE }
        }
    }

    dp[a][b][c] = 0

    (a until 60).forEach { i ->
        (b until 60).forEach { j ->
            (c until 60).forEach { k ->
                if (dp[i][j][k] != Int.MAX_VALUE) {
                    dp[i + 2][j][k] = Math.min(dp[i + 2][j][k], dp[i][j][k] + 1)
                    dp[i][j + 2][k] = Math.min(dp[i][j + 2][k], dp[i][j][k] + 1)
                    dp[i][j][k + 2] = Math.min(dp[i][j][k + 2], dp[i][j][k] + 1)
                    dp[i + 1][j + 1][k] = Math.min(dp[i + 1][j + 1][k], dp[i][j][k] + 1)
                    dp[i + 1][j][k + 1] = Math.min(dp[i + 1][j][k + 1], dp[i][j][k] + 1)
                    dp[i][j + 1][k + 1] = Math.min(dp[i][j + 1][k + 1], dp[i][j][k] + 1)

                    (1 until 70).forEach { v ->
                        if (dp[v][v][v] != 0 && dp[v][v][v] != Int.MAX_VALUE) {
                            println(dp[v][v][v])
                            return
                        }
                    }
                }
            }
        }
    }
}

Measured memory_bytes: 43324
#include<stdio.h>
#define N 45
int main(){
    int F[N];
    int n,i;
    scanf("%d",&n);

    for(i=0;i<=n;i++){
        if(i==0 || i==1) F[i]=1;
        else F[i]=F[i-2]+F[i-1];
    }
    printf("%d\n",F[n]);
    return 0;
}

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

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

int main(){

    int n;
    cin >> n;

    double ans = 0;
    for(int i = 0; i < n; i++){
        double x;
        string u;
        cin >> x >> u;
        if(u == "JPY") ans += x;
        else ans += 380000.0 * x;
    }
    printf("%.5lf", ans);
    return 0;
}

Measured memory_bytes: 256
use v5.18; # strict say state
use warnings;
use List::Util qw(reduce first max min sum0);

chomp (my $n = <STDIN>);
my @a;
for my $i (0..$n-1) {
  chomp (my $b = <STDIN>);
  $a[$i] = $b;
}
my $ans = 0;
$ans += int($a[0] >> 1);
$a[0] &= 1;
for my $i (1..($n-1)) {
  my $c = $a[$i]+$a[$i-1];
  $ans += int($c >> 1);
  $a[$i] = min($c&1, $a[$i]);
}
say $ans;

Measured memory_bytes: 11136
//#i#include "pch.h"
#include <iostream>
#include <algorithm>
#include <map>
#include <set>
#include <queue>
#include <bitset>
#include <limits.h>
#include <string>
#include <stack>
#include <deque>
#include <cmath>
#include <bitset>
#include <complex>
#include <functional>
#include <time.h>
#include <stdio.h>

typedef long long ll;
typedef std::pair<int, int> Pii;
typedef std::pair<long long, long long> Pll;
typedef std::pair<double, double> Pdd;

#define rip(i, n, s) for (int i = (s);i < (int)( n ); i++)
#define mapa make_pair
#define all(a) a.begin(), a.end()
#define MM << " " <<

template<typename T>
using MaxHeap = std::priority_queue<T>;
template<typename T>
using MinHeap = std::priority_queue<T, std::vector<T>, std::greater<T>>;

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

template<typename T>
std::vector<T> vec(int len, T elem) { return std::vector<T>(len, elem); }
template<typename T>
void vdeb(std::vector<T> &da) {
	for (int i = 0;i < da.size();i++) {
		if (i == da.size() - 1) std::cout << da[i];
		else std::cout << da[i] << ' ';
	}
	std::cout << std::endl;
}
template<typename T>
void vdeb(std::vector<std::vector<T>> &da) {
	for (int i = 0;i < da.size();i++) vdeb(da[i]);
	std::cout << std::endl;
}

using namespace std;

int HW[2][1600000];

void solve(int x, vector<int> &da, int n){
	rip(i,n,0){
		int co = 0;
		rip(j,n,i){
			co += da[j];
			HW[x][co]++;
		}
	}
}

ll cal(int n, int m){
	vector<int> h(n),w(m);
	rip(i,n,0) cin >> h[i];
	rip(i,m,0) cin >> w[i];
	solve(0,h,n);
	solve(1,w,m);
	ll ans = 0;
	rip(i,1600000,0) ans += HW[0][i]*HW[1][i];
	return ans;
}

int main(){
	int n,m;
	cin >> n >> m;
	vector<ll> ans(0);
	while(n|m){
		rip(i,2,0)rip(j,1600000,0) HW[i][j]=0;
		ans.push_back(cal(n,m));
		cin >> n >> m;
	}
	rip(i,ans.size(),0) printf("%lld\n", ans[i]);
}


Measured memory_bytes: 15564
import java.util.ArrayList;
import java.util.Scanner;

public class Main {
	private static final int NUM_NUMBERS = 5;
	
	public static void main(String[] args) {
		ArrayList<Integer> num = new ArrayList<Integer>(NUM_NUMBERS);

		setInputsToList(num);
		sort(num);
		printList(num);
	}
	
	private static void setInputsToList(ArrayList<Integer> list){
		Scanner sc = new Scanner(System.in);
		
		for(int i = 0; i < NUM_NUMBERS; i++){
			list.add(sc.nextInt());
		}
		
		sc.close();
	}
	
	private static void printList(ArrayList<Integer> list){
		for(int i = 0; i < list.size(); i++){
			System.out.printf("%d", list.get(i));
			//ÅãÌvfðoÍµ½ãÍüs
			//»êÈOÌvfðoÍµ½ãÍXy[XðoÍ
			if(i != (list.size() - 1)){
				System.out.printf(" ");
			}
			else{
				System.out.printf("\n");
			}
		}
	}
	
	public  static void sort(ArrayList<Integer> list){
		int listSize = list.size();
		for(int i = listSize - 1; i > -1; i--){
			int pivot = list.get(i);
			for(int j = 0; j < i; j++){
				int target = list.get(j);
				if(target < pivot){
					list.set(j, pivot);
					list.set(i, target);
					pivot = target;
				}
			}
		}
	}
}

Measured memory_bytes: 12000
n = int(input())
B = list(map(int,input().split()))
A = [B[0]]
for i in range(1,n-1):
    if B[i-1] > B[i]:
        A.append(B[i])
    else:
        A.append(B[i-1])
A.append(B[-1])
print(sum(A))



Measured memory_bytes: 3060
import sys
def ipnput():
    return sys.stdin.readline()[:-1]
from _collections import deque
n,m=map(int,input().split())
edg=[[] for i in range(n+1)]
for i in range(m):
    a,b=map(int,input().split())
    edg[a].append(b)
    edg[b].append(a)
dep=[-1]*(n+1)
dep[1]=0
data=deque([1])
while len(data)>0:
    p=data.popleft()
    for i in edg[p]:
        if dep[i]==-1:
            dep[i]=dep[p]+1
            data.append(i)
print("POSSIBLE" if dep[n]==2 else "IMPOSSIBLE")


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

int main() {
    string s;
    cin >> s;
    int ans = s[0] == 'R' ? 1 : 0;
    for (int i = 1; i < int(s.length()); i++) {
        if (s[i] == 'R') {
            if (s[i-1] == 'R') {
                ans++;
            } else {
                ans = 1;
            }
        }
    }
    cout << ans;
}


Measured memory_bytes: 3624
#include <iostream>
#include <vector> 
#include <cmath>
#include <algorithm>
#include <set>
#include <string>
#include <map>
#include <cerrno>
#include <stdio.h>
#include <cfenv>
#include <stack>
#include <math.h>
#include <iomanip>
#include <limits>
#include <queue>
#define ll long long int
#define pb push_back
#define mp make_pair

using namespace std;

int main(){

    int n;
    cin >> n;
    string s,s1,s2,s3,ks1,ks2;

    for(int i=0;i<n;i++){
        map<string,int> m;
        cin >> s;
        for(int i=1;i<s.size();i++){
            s1 = s.substr(0,i);
            s2 = s.substr(i,s.size());
            s3 = s1 + s2;
            m[s3] = 1;
            s3 = s2 + s1;
            m[s3] = 1;
            ks1 = s1;
            ks2 = s2;
            reverse(begin(s1),end(s1));
            reverse(begin(s2),end(s2));
            s3 = s1 + ks2;
            m[s3] = 1;
            s3 = ks2 + s1;
            m[s3] = 1;
            s3 = ks1 + s2;
            m[s3] = 1;
            s3 = s2 + ks1;
            m[s3] = 1;
            s3 = s1 + s2;
            m[s3] = 1;
            s3 = s2 + s1;
            m[s3] = 1;
        }
        cout << m.size() << endl;
    }
    return 0;
}


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

char rev(char c) {
  if(c == 'S')
    return 'W';
  else
    return 'S';
}
      


bool possible(int N, string S, char first, char second, char* s) {
  s[0] = first;
  s[1] = second;
  for(int i = 1; i < N - 1; i++) {
    bool same = false;
    if(s[i] == 'S' && S[i] == 'o') 
      same = true;

    if(s[i] == 'W' && S[i] == 'x')
      same = true;

    if(same)
      s[i + 1] = s[i - 1];
    else
      s[i + 1] = rev(s[i - 1]);
  }


  bool same = false;

  if(s[N - 1] == 'S' && S[N - 1] == 'o')  same = true;
  if(s[N - 1] == 'W' && S[N - 1] == 'x')  same = true;
  
  if(same && s[N - 2] != s[0])
    return false;
  if(!same && s[N - 2] == s[0])
    return false;

  same = false;
  if(s[0] == 'S' && S[0] == 'o') same = true;
  if(s[0] == 'W' && S[0] == 'x') same = true;

  if(same && s[1] != s[N - 1])
    return false;
  if(!same && s[1] == s[N - 1])
    return false;

  return true;
}

int main() {

  int N;
  string S;
  cin >> N >> S;

  char ans[N + 1];
  ans[N] = '\0';
  if(possible(N, S, 'S', 'S', ans))
    cout << ans << endl;
  else if(possible(N, S, 'S', 'W', ans))
    cout << ans << endl;
  else if(possible(N, S, 'W', 'S', ans))
    cout << ans << endl;
  else if(possible(N, S, 'W', 'W', ans))
    cout << ans << endl;
  else
    cout << -1 << endl;


}


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

public class Main{
   public static void main(String[] args) {
     try{
     //入力される秒数S
       BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
       int n = Integer.parseInt(br.readLine());
     //秒数をh,m,sに分けて表示する
     int h = n/3600;
     int m = (n%3600)/60;
     int s = n%60;
     System.out.println(h+":"+m+":"+s);
   }catch(IOException e){
     e.printStackTrace();
   }
    }
}



Measured memory_bytes: 24284
#include <bits/stdc++.h>
using namespace std;
//debug
#ifdef grief
#define debug(...) do{\
	fprintf(stderr , "%s - %d : (%s) = " , __PRETTY_FUNCTION__ , __LINE__ , #__VA_ARGS__ );\
	_DO(__VA_ARGS__);\
}while(0)
template<typename I> void _DO(I&&x){
	cerr<<x<<endl;
}
template<typename I,typename...T> void _DO(I&&x,T&&...tail){
	cerr<<x<<" , ";
	_DO(tail...);
}
#else
#define debug(...)
#endif
//type
typedef long long ll;
typedef pair<int,int> pii;
typedef long long ll;
typedef pair<ll,ll> pll;
typedef priority_queue<pll,vector<pll>,greater<pll> > heap;
//macro
#define SZ(x) ((int)(x).size())
#define ALL(x) (x).begin(),(x).end()
#define F first
#define S second
#define REP(i,n) for(ll i=0;i<(n);i++)
#define REP1(i,a,b) for(ll i=(a);i<=(b);i++)
#define mkp make_pair
#define pb push_back
const ll INF=1e18;
const ll MA=1e6+5;
const ll MOD=1e9+7;
const int M=1e5+5;
//}}}
ll n;
string s;
int ans[100010];
int g[200010];
inline int T(int k){
	if(k==0) return n;
	if(k==n+1)	return 1;
	return k;
}
bool right(int k){
	assert(g[T(k+1)]&&g[T(k-1)]);
	int c=g[k]; if(s[k-1]=='x')	c=3-c;
	if(c==1)	return g[T(k+1)]==g[T(k-1)];
	else 		return g[T(k+1)]!=g[T(k-1)];
}
bool can(){
	for(int i=2;i<n;i++){
		int k=g[i]; if(s[i-1]=='x')	k=3-k;
//		cout<<g[i]<< ' ';
		if(k==1){
			g[i+1]=g[i-1];
		}
		else{
			g[i+1]=3-g[i-1];
		}
	}
//	cout<< '\n';
	if(right(1)&&right(n))	return 1;
	return 0;
}
int main(){
	cin>>n;
	cin>>s;
	g[1]=1; g[2]=1;
	if(can()){
		for(int i=1;i<=n;i++){
			if(g[i]==1)
				cout<<'S';
			else
				cout<<'W';
		}
		cout<<'\n';
		return 0;
	}
	g[1]=1; g[2]=2;
	if(can()){
		for(int i=1;i<=n;i++){
			if(g[i]==1)
				cout<<'S';
			else
				cout<<'W';
		}
		cout<<'\n';
		return 0;
	}
	g[1]=2; g[2]=1;
	if(can()){
		for(int i=1;i<=n;i++){
			if(g[i]==1)
				cout<<'S';
			else
				cout<<'W';
		}
		cout<<'\n';
		return 0;
	}
	g[1]=2; g[2]=2;
	if(can()){
		for(int i=1;i<=n;i++){
			if(g[i]==1)
				cout<<'S';
			else
				cout<<'W';
		}
		cout<<'\n';
		return 0;
	}
	cout<<"-1\n";
	return 0;
}

Measured memory_bytes: 924
#include<stdio.h>
#include<stdlib.h>
#define Max 1000000000
#define N 500000
void merge1(int *,int,int,int);
void merge2(int *,int,int);
int cnt=0;
int main()
{
  int n,S[N];
  int i;
  scanf("%d",&n);
  for(i=0; i<n; i++){
    scanf("%d",&S[i]);
  }
  
  merge2(S,0,n);

  for(i=0; i<n; i++){
    printf("%d",S[i]);
    if(i<n-1) printf(" ");
  }
  printf("\n%d\n",cnt);
  
  return 0;
}

void merge1(int A[],int left,int mid,int right)
{
  int n1,n2;
  int i,j,k;
  int *R,*L;
  
  n1 = mid -left;
  n2 = right - mid;
  L=(int *)malloc(sizeof(int)*(n1+1));
  R=(int *)malloc(sizeof(int)*(n2+1));

  for(i=0; i<=n1-1; i++){
    L[i] = A[left+i];
  }
  
  for(i=0; i<=n2-1; i++){
    R[i] = A[mid+i];
  }
  i = 0;
  j = 0;
  R[n2]=Max;
  L[n1]=Max;
  
  for(k=left; k<=right-1; k++){
    if(L[i]<=R[j]){
      A[k] = L[i];
      i = i + 1;
      cnt++;
    }
    else{
      A[k] = R[j];
      j = j + 1;
      cnt++;
    }
  }
  free(R);
  free(L);
}

void merge2(int A[],int left,int right)
{
  int i,mid;
  if(left+1<right){
    mid = (left+right) / 2;
    merge2(A,left,mid);
    merge2(A,mid,right);
    merge1(A,left,mid,right);
  }
}

    
		      
  
  
  

Measured memory_bytes: 4480
#include<iostream>

using namespace std;

int insertionSort(int R[],int n,int g){
  int count=0;
  for(int i=g;i<n;i++){
    int j=i-g;//入れ換えるポイント
    int v=R[i];//入れ物の設置
    while(j>=0&&R[j]>v){
      R[j+g]=R[j];
      R[j]=v;
      j-=g;
      count++;
    }
  }
  return count;
}

int main(){
  int n,m;
  cin>>n;
  int R[n],G[100];
  G[0]=1;
  G[1]=2;
  G[2]=4;
  G[3]=6;
  G[4]=9;
  G[5]=12;
  G[6]=15;
  G[7]=18;
  G[8]=21;
  G[9]=24;
  int x=10;
  for(int i=0;i<100;i++){
    x=x*1.129;
    if(i>9)G[i]=x;
    if(G[i]>n){
      m=i;
      break;
    }
  }
  //入力
  for(int i=0;i<n;i++){
    cin>>R[i];
  }
  int count=0;
  for(int i=m-1;i>=0;i--){
    count+=insertionSort(R,n,G[i]);
  }
  cout<<m<<endl;
  for(int i=m-1;i>=0;i--){
    if(i==0){
      cout<<G[i]<<endl;
    }else{
      cout<<G[i]<<" ";
    }
  }
  cout<<count<<endl;
  for(int i=0;i<n;i++){
    cout<<R[i]<<endl;
  }
  return 0;
}



Measured memory_bytes: 6992
#include <bits/stdc++.h>
using namespace std;
bool p(string s, int j, int k){
  for(int i=0; i<k-j+1;i++){
    if(s.at(j-1+i)!=s.at(k-i-1)){
    return false;
    }
  }
  return true;
}
int main(){
  string s;
  cin >>s;
  int n=s.size();
  if(p(s, 1, n)&&p(s, 1, (n-1)/2)&&p(s, (n+3)/2, n))cout<<"Yes";
  else{cout<<"No";}

}



Measured memory_bytes: 256
import collections
N = int(input())
S_list = [input() for i in range(N)]

c = collections.Counter(S_list)
c2 = c.most_common()
cnt_list = c.values()
cnt_max = max(cnt_list)

str_list = []

for j in range(len(c)):
  if c2[j][1] == cnt_max:
    str_list.append(c2[j][0])

str_list.sort()

for k in range(len(str_list)):
  print(str_list[k])

Measured memory_bytes: 47660
#include <stdio.h>
int main(){
	int ans,n,a,b,i;
	scanf("%d",&n);
	for(i=0;i<n;i++){
		scanf("%d%d",&a,&b);
		if(a>b){
			ans=a%b;
			if(a%b==0)ans=b;
		}
		else ans=a;
		printf("%d\n",ans);
	}
	return 0;
}


Measured memory_bytes: 2076
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <vector>
#include <algorithm>
#include <string>

using namespace std;

//ユークリッドの互除法で最大公約数を求める
int gcd( int p, int q ) {
	if( q == 0 ) return p;
	return gcd( q, p % q );
}

int main(void){

	/*
		睡眠の周期はa+b分
		睡眠と山手線の周期はlcm( a+b, 60 )
		0からlcm( a + b, 60 )までを調べれば十分？
	*/

	int a, b, c;
	int lcm;
	bool flg = false;
	int ans = 0;

	cin >> a >> b >> c;
	lcm = ( a + b ) * 60 / gcd( ( a + b ) , 60 );

	int t = 0;
	while( t <= lcm ) {
		for( int i = 0; i <= a; i++ ) {
			int tmp = t + i;
			if( tmp % 60 == c ) {
				flg = true;
				ans = tmp;
			}
		}
		if( flg ) break;
		t += ( a + b );
	}

	if( !flg ) 
		cout << -1 << endl;
	else
		cout << ans << endl;

    return 0;
}

Measured memory_bytes: 1164
n, m = map(int, input().split())
ab = [list(map(int, input().split())) for _ in range(m)]

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

ans = m
for i in range(1, m):
    if ab[i][0] < ab[i-1][1]:
        ab[i][1] = ab[i-1][1]
        ans -= 1
print(ans)


Measured memory_bytes: 28564
#include <iostream>
#include <string>
#include <cstdlib>
#include <vector>

using namespace std;

int main(){
    vector< vector<int> > dp(1001,vector<int>(1001));

    string x;
    string y;
    cin >> x;
    cin >> y;
    int xLength = x.length();
    int yLength = y.length();

    for(int i=0; i <= xLength; i++){
        dp[i][0] = i;
    }

    for(int i=0; i <= yLength; i++){
        dp[0][i] = i;
    }    


    for(int i=1; i <= xLength; i++){
        for(int j=1; j <= yLength; j++){
            int suggest[3];
            if(x[i-1] == y[j-1]){
                suggest[0] = dp[i-1][j-1]; 
            }else{
                suggest[0] = dp[i-1][j-1] + 1; 
            }
            suggest[1] = dp[i][j-1] + 1;
            suggest[2] = dp[i-1][j] + 1;

            if(suggest[0] > suggest[1]){
                suggest[0] = suggest[1];
            }
            if(suggest[0] > suggest[2]){
                suggest[0] = suggest[2];
            }
            dp[i][j] = suggest[0];
        }
    }

    cout << dp[xLength][yLength] << endl;

    return 0;
}



Measured memory_bytes: 6688
n,m=map(int,input().split())
a=list(map(int,input().split()))
ma=[0,2,5,5,4,5,6,3,7,6]
a=sorted(a)
dp=[-1]*(n+1)
dp[0]=0
for i in range(m-1,-1,-1):
    for j in range(n+1):
        if dp[j]!=-1 and j+ma[a[i]]<=n:
            dp[j+ma[a[i]]]=max(10*dp[j]+a[i],dp[j+ma[a[i]]])
print(dp[n])

Measured memory_bytes: 16492
package main

import (
	"bufio"
	"os"
	"sort"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func scanInt() int {
	sc.Scan()
	iv, _ := strconv.Atoi(sc.Text())
	return iv
}

func init() {
	sc.Split(bufio.ScanWords)
}

func main() {
	n := scanInt()
	type student struct{ n, a int }
	sts := make([]student, n)
	for i := range sts {
		sts[i].n = i + 1
		sts[i].a = scanInt()
	}
	sort.Slice(sts, func(i, j int) bool { return sts[i].a < sts[j].a })

	wr := bufio.NewWriter(os.Stdout)
	for i, v := range sts {
		wr.WriteString(strconv.Itoa(v.n))
		if i < len(sts)-1 {
			wr.WriteString(" ")
		} else {
			wr.WriteString("\n")
		}
	}
	wr.Flush()
}


Measured memory_bytes: 4224
INF = float('inf')

N, capW = map(int, input().split())
items = [tuple(map(int, input().split())) for _ in range(N)]

dp = [-INF] * (capW+1)
dp[0] = 0
for wi, vi in items:
    for w in reversed(range(capW+1)):
        if dp[w] == -INF: continue
        if w+wi <= capW:
            dp[w+wi] = max(dp[w+wi], dp[w] + vi)

print(max(dp))


Measured memory_bytes: 115024
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<n; i++)
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define fi first
#define se second
long long mo = 1e9 + 7;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
typedef pair<ll,Pll> PlP;
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
template<class A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}cout << "\n";}
ld PI=3.14159265358979323846;

int main(){
    //ll N;
    string S;
    cin >> S;
    ll N = S.size();
    ll cur = 0;
    ll ans = 0;
    rep(i,N){
        if(S[i] == 'R'){
            cur++;
            cmax(ans, cur);
        }else{
            cmax(ans, cur);
            cur = 0;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3624
N=int(input())
C=[]
S=[]
F=[]
for i in range(N-1):
    CSF=list(map(int,input().split()))
    C.append(CSF[0])
    S.append(CSF[1])
    F.append(CSF[2])

ans=[0]*(N)

for i in range(N-1):
    t=0

    for j in range(i,N-1):
        m=-(-t//F[j])*F[j]
        t=max(S[j],m)
        t+=C[j]
    
    ans[i]=t

print(*ans,sep='\n')

Measured memory_bytes: 9104
# -*- coding: utf-8 -*-
from bisect import bisect, bisect_left
from collections import defaultdict

def inpl(): return list(map(int, input().split()))
MOD = 10**9 + 7
N = int(input())
C = [-1]
for i in range(N):
    c = int(input())
    if c != C[-1]:
        C.append(c)
C = C[1:]
N = len(C)
DP = [1]*N

ixs = defaultdict(lambda: [-1])
ixs[C[0]].append(0)

for i, c in enumerate(C[1:], start=1):
    l = ixs[c][bisect_left(ixs[c], i) - 1]
    if l != -1:
        DP[i] = (DP[i-1] + DP[l])%(MOD)
    else:
        DP[i] = DP[i-1]
    ixs[c].append(i)
print(DP[-1])


Measured memory_bytes: 57604
#include <stdio.h>
#include <string.h>

int main(void){
	int i=0, j=0;
	int cnt=0;
	int s_len=0, p_len=0;
	char s[100], p[100];
	
	scanf("%s", s);
	scanf("%s", p);
	
	while(s[i] != '\0'){
		s_len++;
		i++;
	}
	i=0;
	while(p[i] != '\0'){
		p_len++;
		i++;
	}
	
	for(i = 0; i < s_len+1; i++){
		for(j = 0; j < p_len+1; j++){
			if (s[(i+j)%s_len] != p[j])
			   break;
			else
			   cnt++;
			   if(cnt == p_len){
			   	printf("Yes\n");
			   	return 0;
			   }
		}
		cnt = 0;
	}
	printf("No\n");
	return 0;
}

Measured memory_bytes: 524
#include <iostream> //cout
#include <vector> //vector
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)


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


    for (int i = A; i <= B; i++){
        if(i % K == 0){
            cout << "OK" << endl;
            return 0;
        }
    }
    cout << "NG" << endl;
}


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

long int pow(int x, int y)
{
  long int result = 1;
  for (int i=0; i<y; i++)
  {
    result *= x;
  }
  return result;
}

long int dec_to_4(int x)
{
  long int result = 0;
  for (int i=0; x != 0 ;i++)
  {
    result += (x % 4) * pow(10, i);
    x /= 4;
  }
  return result;
}

int main()
{
  while(true)
  {
    int num;
    cin >> num;
    if ( num == -1 ) break;

    cout << dec_to_4(num) << endl;
  }
}

Measured memory_bytes: 1156
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef pair<int, int> pi;
typedef pair<ll, ll> pll;
typedef map<int, int> mi;
typedef set<int> si;
#define VV(T) vector<vector< T > >
#define dump(x)  cout << #x << " = " << (x) << endl
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define POSSIBLE(n) cout << ((n) ? "POSSIBLE" : "IMPOSSIBLE"  ) << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible"  ) << endl

#define rep(i, n) REP(i, 0, n)                              // 0, 1, ..., n-1
#define REP(i, x, n) for(int i = x; i < n; i++)             // x, x + 1, ..., n-1
#define FOREACH(x,a) for(auto& (x) : (a) )

#define ALL(v) (v).begin() , (v).end()
#define RALL(v) (v).rbegin(), (v).rend()

#define pb push_back
#define pu push
#define mp make_pair
#define fi first
#define sc second

#define COUT(x) cout << (x) << endl
#define VECCIN(x) for(auto&youso_: (x) )cin>>youso_
#define VECCOUT(x) for(auto&youso_: (x) )cout<<youso_<<" ";cout<<endl

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 gcd(int a, int b) {
    if (b == 0) return a;
    return gcd(b, a % b);
}

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

    int n; cin >> n;
    vector<int> a(n);
    rep(i, n) cin >> a[i];

    // 累積GCD
    vector<int> left(n + 1, 0), right(n + 1, 0);
    for (int i = 0; i < n; ++i) left[i + 1] = gcd(left[i], a[i]);
    for (int i = n - 1; i >= 0; --i) right[i] = gcd(right[i + 1], a[i]);

    int res = 0;
    for (int i = 0; i < n; i++) {
        int l = left[i];

        int r = right[i + 1];

        chmax(res, gcd(l, r));
    }
    COUT(res);
}

Measured memory_bytes: 1408
#!/usr/bin/env python3
import sys, math, itertools, collections, bisect
input = lambda: sys.stdin.buffer.readline().rstrip().decode('utf-8')
inf = float('inf') ;mod = 10**9+7
mans = inf ;ans = 0 ;count = 0 ;pro = 1

s=input()
C=collections.Counter(s)
if ((C["N"] or C["S"]) and C["N"]*C["S"] == 0):
  print("No")
elif ((C["W"] or C["E"]) and C["W"]*C["E"] == 0):
  print("No")
else:
  print("Yes")

Measured memory_bytes: 38256
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<ll, ll> p_ll;
typedef vector<pair<ll, ll>> vec_p;

const ll MOD = pow(10, 9) + 7;
const ll LLINF = pow(2, 61) - 1;
const int INF = pow(2, 30) - 1;

int main()
{
  ll N,A;
  cin >> N >> A;
  ll count = 0;

  while(N>0){
    N -= A;
    count++;
  }

  cout << count << endl;
}

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

using namespace std;

int main()
{
    int a, b;
    cin >> a >> b;
    int x = 1;
    int bb = b;
    string ans = "No";
    while (bb > 0) {
        bb /= 10;
        x *= 10;
    }
    int as = a * x + b;
    double sq = floor(sqrt(as));
    if ((double)as == (sq * sq)) ans = "Yes";

    cout << ans << endl;

    return 0;
}


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

typedef struct {
	char name[11];
	int time;
}Process;

class ProcessQueue {
public:
	ProcessQueue(int size) :
		m_size(size),
		m_head(0),
		m_tail(0),
		number(0)
	{
		m_process = new Process[m_size];
	};

	~ProcessQueue() {
		delete[] m_process;
	};

	void enQueue(Process process) {
		m_process[m_tail] = process;

		number++;

		if (m_tail < m_size - 1) {
			m_tail++;
		}
		else {
			m_tail = 0;
		}
	};

	Process deQueue() {
		number--;
		if (m_head < m_size - 1) {
			m_head++;
			return m_process[m_head - 1];
		}
		else {
			m_head = 0;
			return m_process[m_size - 1];
		}
	};

	int getnumber() {
		return number;
	}

private:
	int m_head;
	int m_tail;
	int m_size;
	int number;
	Process* m_process;
};

int main() {
	
	int n, q, totaltime = 0;
	scanf("%d%d", &n, &q);

	ProcessQueue queue(n);

	Process tmp;
	for (int i = 0; i < n; i++) {
		scanf("%s%d", &tmp.name, &tmp.time);
		queue.enQueue(tmp);
	}

	while (queue.getnumber() != 0) {
		tmp = queue.deQueue();
		if (tmp.time - q > 0) {
			totaltime += q;
			tmp.time -= q;
			queue.enQueue(tmp);
		}
		else {
			totaltime += tmp.time;
			printf("%s %d\n", tmp.name, totaltime);
		}
	}
}


Measured memory_bytes: 3504
#[allow(unused_imports)]
use std::cmp::{min,max};
#[allow(unused_imports)]
use std::collections::BTreeMap;
#[allow(unused_imports)]
use std::ops::*;
#[allow(unused_imports)]
use std::collections::BinaryHeap;

fn main() {
    let n = read_i64() as usize;
    let xs = read_vec_i64();
    let mut ys = vec![];
    for (i,&x) in xs.iter().enumerate() {
        ys.push(x-(i as i64)+1);
    }
    ys.sort();
    let mut res = 0;
    for &y in &ys {
        res += (y - ys[n/2]).abs();
    }
    println!("{}", res);
}

#[allow(dead_code)]
fn read_line() -> String {
    let mut ret = String::new();
    std::io::stdin().read_line(&mut ret).ok();
    ret.pop();
    return ret;
}

#[allow(dead_code)]
fn read_i64() -> i64 {
    let ss = read_line();
    return ss.parse::<i64>().unwrap();
}

#[allow(dead_code)]
fn read_vec_i64() -> Vec<i64> {
    let mut res = vec![];
    let ss = read_line();
    for ts in ss.split_whitespace() {
        let x = ts.parse::<i64>().unwrap();
        res.push(x);
    }
    return res;
}

use std::fmt::Display;
#[allow(dead_code)]
fn write_vec<T: Display>(xs: &Vec<T>) {
    if xs.len() == 0 {
        println!("");
        return;
    }
    print!("{}", xs[0]);
    for i in 1..xs.len() {
        print!(" {}", xs[i]);
    }
    println!("");
}


Measured memory_bytes: 10492
N = int(input())

nums = list(map(int,input().split()))

flag = True
count = 0

while(flag):
  for num in nums:
    if(num % 2 == 1):
      flag = False
  
  if(flag):
    nums = list(map(lambda x:x//2,nums))
    count += 1

print(count)

Measured memory_bytes: 3060
H, W = [int(x) for x in input().split()]

def solve(H, W):
  if H % 3 == 0 or W % 3 == 0:
    return 0  
  else:
    ans = 1e20
    for i in range(max(W//3-1, 1), min(W//3+2, W)):
      a = i
      b = W - a
      for i in range(max(H//2-1, 1), min(H//2+2, H)):
        c = i
        d = H - c
        S = [a*H, b*c, b*d]
        ans = min(ans, max(S)-min(S))
      for i in range(max(b//2-1, 1), min(b//2+2, b)):
        c = i
        d = b - c
        S = [a*H, c*H, d*H]
        ans = min(ans, max(S)-min(S))
  return ans

print(min(solve(H, W), solve(W, H)))


Measured memory_bytes: 3064
N = int(input())

X1_dict = {}
X2_dict = {}
inp_list = list(map(int, input().split(" ")))
for i, a_i in enumerate(inp_list):
	X1 = i + 1 + a_i
	X2 = i + 1 - a_i
	if X1 in X1_dict.keys():
		X1_dict[X1] += 1
	else:
		X1_dict[X1] = 1
	if X2 in X2_dict.keys():
		X2_dict[X2] += 1
	else:
		X2_dict[X2] = 1

answer = 0
for key, value in X1_dict.items():
	if key in X2_dict.keys():
		answer += value * X2_dict[key]
		
print(answer)

Measured memory_bytes: 56588
#include <stdio.h>
#include <string.h>

int main(void)
{
    int n, m;
    int o, i;
    int t[10001];
    int j;
    int max_n;
    int flag;
    
    scanf("%d%d", &n, &m);
    
    memset(t, 0, sizeof(t));
    
    t[0] = m;
    
    for (j = 1; j <= n; j++){
        scanf("%d%d", &i, &o);
        
        t[j] = t[j - 1] + i - o;
    }
    
    flag = 0;
    max_n = t[0];
    for (j = 1; j <= n; j++){
//printf("[%d]", t[j]);

        if (t[j] < 0){
            flag = 1;
            break;
        }
        if (max_n < t[j]){
            max_n = t[j];
        }
    }
    
    if (flag == 1){
        printf("0\n");
    }
    else{
        printf("%d\n", max_n);
    }
    return (0);
}

Measured memory_bytes: 1072
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
#define rep(i, n) for(ll i = 0;i < n;i++)
template<class T, class U> void cmax(T& a, U b) { if (a<b) a = b; }
template<class T, class U> void cmin(T& a, U b) { if (a>b) a = b; }

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

  string s;
  cin >> s;
  if (s.substr(0, 4) == "YAKI")
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <typeinfo>
#include <vector>
#include <stack>
#include <cmath>
#include <set>
#include <map>
#include <string>
#include <algorithm>
#include <cstdio>
#include <queue>
#include <iomanip>
#include <cctype>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<char> vc;
typedef vector<vc> vvc;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<30;
const ll INF=1ll<<52;
const double pi=acos(-1);
const double eps=1e-8;
const ll mod=1e9+7;
const vi emp;
const int dx[4]={0,1,0,-1},dy[4]={1,0,-1,-0};
const int DX[8]={-1,-1,-1,0,0,1,1,1},DY[8]={1,0,-1,1,-1,1,0,-1};

void Out(vi a){
	for(int i=0;i<a.size();i++){
		if(i) cout<<' ';
		cout<<a[i];
	}
	cout<<endl;
}

int n,m;
vi a;

int main(){
	cin>>n>>m;
	a=vi(m);
	for(int i=0;i<m;i++) cin>>a[i];
	if(m==1){
		cout<<a[0]<<endl;
		if(a[0]==1) cout<<1<<endl<<1<<endl;
		else cout<<2<<endl<<a[0]-1<<' '<<1<<endl;
	}
	else{
		int num=0;
		for(int i=0;i<m;i++) if(a[i]%2==1) num++;
		if(num>2) cout<<"Impossible"<<endl;
		else{
			bool flag=0;
			for(int i=0;i<m;i++) if(a[i]%2==1){
				if(!flag){
					swap(a[0],a[i]);
					flag=1;
				}
				else swap(a[m-1],a[i]);
			}
			Out(a);
			a[0]--;
			a[m-1]++;
			if(!a[0]) a.erase(a.begin());
			if(!a[m-1]) a.erase(a.end()-1);
			cout<<a.size()<<endl;
			Out(a);
		}
	}
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <stdio.h>
#include <cstring>
#include <queue>
#include <stack>
#include <functional>
#include <math.h>
#include <iomanip>
using namespace std;
#define Would
#define you
const int INF = 999999999;
const int MOD = 1e9 + 7;
const double pi = 3.141592653589793238;

int main() {
	while (1) {
		int a, b;
		cin >> a >> b;
		if (a == 0 && b == 0) { break; }
		for (int i = 0; i < a; ++i) {
			for (int j = 0; j < b; ++j) {
				cout << "#";
			}
			cout << endl;
		}
		cout << endl;
	}
}


Measured memory_bytes: 3100
#include<bits/stdc++.h>
using namespace std;
int main(){
	ios::sync_with_stdio(false);
	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: 3780