akhauriyash/Code-Regression huggingface dataset:
#define _USE_MATH_DEFINES
 
#include <iostream>
#include <iomanip>
#include <sstream>
 
#include <algorithm>
#include <cmath>
 
#include <string>
#include <queue>
#include <vector>
#include <complex>
#include <set>
#include <map>
#include <stack>
#include <list>

#include <valarray>

#include<cassert>//assert();
//#include <random>//xAOJ
/////////
#define REP(i, x, n) for(int i = x; i < n; i++)
#define rep(i,n) REP(i,0,n)
#define P(p) cout<<(p)<<endl;
 
#define PII pair<int,int>
/////////
typedef long long LL;
typedef long double LD;
typedef unsigned long long ULL;
/////////
using namespace::std;
/////////
/////////

void solve(){
	int sx,sy,tx,ty;
	cin >> sx >> sy >> tx >> ty;
	int posX,posY;
	posX = tx-sx;
	posY = ty-sy;
	//(0,0)から(X,Y)への移動 MAX(2000,2000)
//真右と上は後で
	int A,B;
	if(posX != 0 && posY != 0){
		for(A=0;A<posX;A++){cout << "R";}
		for(B=0;B<posY;B++){cout << "U";}
		cout << "L";
		for(B=0;B<posY-1;B++){cout << "D";}
		for(A=0;A<posX-1;A++){cout << "L";}
		cout << "D";
		cout << "D";
		for(A=0;A<posX+1;A++){cout << "R";}
		for(B=0;B<posY+1;B++){cout << "U";}
		cout << "L";
		cout << "U";//上から出る
		for(A=0;A<posX+1;A++){cout << "L";}
		for(B=0;B<posY+1;B++){cout << "D";}
		cout << "R";
	}
	else if( posX == 0){//真上
		for(B=0;B<posY;B++){cout << "U";}
		cout << "L";
		for(B=0;B<posY;B++){cout << "D";}
		cout << "R";
		cout << "R";
		for(B=0;B<posY;B++){cout << "U";}
		cout << "L";
		cout << "U";
		cout << "RR";
		for(B=0;B<posY+2;B++){cout << "D";}
		cout << "LLU";
	}else{//真右
		for(A=0;A<posX;A++){cout << "R";}
		cout << "U";
		for(A=0;A<posX;A++){cout << "L";}
		cout << "D";
		cout << "D";
		for(A=0;A<posX;A++){cout << "R";}
		cout << "U";
		cout << "RDD";
		for(A=0;A<posX+2;A++){cout << "L";}
		cout << "UUR";
	}
	/////
	
}

int main(void){
    std::cin.tie(0); 
    std::ios::sync_with_stdio(false);
    std::cout << std::fixed;//
    //cout << setprecision(16);//
	
	solve();
	
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<map>
#include<string>
#define rep(i,N) for(int i=0;i<N;i++)

long long  INF=1000000000000000000;
long long mod=1000000007;
using namespace std;

int main(){
int N;
cin>>N;
long long  cost[N],start[N],f[N];

for(int i=1;i<N;i++){
    cin>>cost[i]>>start[i]>>f[i];
}
long long now=0;
for(int k=1;k<N;k++){
    now =0;

    for(int i=k;i<N;i++){
        now=max(start[i],now);
        if(now%f[i]!=0)now+=(f[i]-(now%f[i]));
        now+=cost[i];
    }
    cout<<now<<endl;
}

cout<<"0"<<endl;


 return 0;
}
/*
3
6 5 1
1 10 1


12
11
0

4
12 24 6
52 16 4
99 2 2

187
167
101
0

4
12 13 1
44 17 17
66 4096 64

4162
4162
4162
0
*/

Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long LL;
#define SZ(X) ((int)(X).size())
#define ALL(X) (X).begin(), (X).end()
#define REP(I, N) for (int I = 0; I < (N); ++I)
#define REPP(I, A, B) for (int I = (A); I < (B); ++I)
#define RI(X) scanf("%d", &(X))
#define RII(X, Y) scanf("%d%d", &(X), &(Y))
#define RIII(X, Y, Z) scanf("%d%d%d", &(X), &(Y), &(Z))
#define DRI(X) int (X); scanf("%d", &X)
#define DRII(X, Y) int X, Y; scanf("%d%d", &X, &Y)
#define DRIII(X, Y, Z) int X, Y, Z; scanf("%d%d%d", &X, &Y, &Z)
#define RS(X) scanf("%s", (X))
#define CASET int ___T, case_n = 1; scanf("%d ", &___T); while (___T-- > 0)
#define MP make_pair
#define PB push_back
#define MS0(X) memset((X), 0, sizeof((X)))
#define MS1(X) memset((X), -1, sizeof((X)))
#define LEN(X) strlen(X)
#define PII pair<int,int>
#define VI vector<int>
#define VL vector<long long>
#define VPII vector<pair<int,int> >
#define PLL pair<long long,long long>
#define VPLL vector<pair<long long,long long> >
#define F first
#define S second

using namespace std;

int main(){
    DRII(k,q);
    VI d(k);
    REP(i,k) RI(d[i]);
    REP(nq,q){
        DRIII(n,x,m);
        n--;
        VI dm(k);
        VL sd(k+1,0);
        VI nb0(k+1,0);
        REP(i,k) {
            dm[i]=d[i]%m;
            sd[i+1]=sd[i]+dm[i];
            nb0[i+1]=nb0[i];
            if (dm[i]==0) {nb0[i+1]++;}
        }
      /*  cout<<"sd"<<endl;
        for (auto i:sd) {cout<<i<<" ";} cout<<endl;
        cout<<"nb0"<<endl;
        for (auto i:nb0) {cout<<i<<" ";} cout<<endl;*/
        LL vf=x+(LL)(n/k)*sd[k] + sd[n%k];
       // cout<<(LL)(n/k)<<" "<<sd[k]<<" "<<(LL)(n/k)*sd[k]<<endl;
        LL nbbp=vf/m-x/m;
        LL nbz=(n/k)*nb0[k] + nb0[n%k];
        LL res=n - nbbp - nbz;
        //cout<<n<<" "<<nbbp<<" "<<nbz<<" "<<vf<<endl;
        printf("%lld\n",res);
    }

}


Measured memory_bytes: 384
N, *A = gets.split.map(&:to_i)
C = N.times.map { gets.chomp }

res = []
flg = true
N.times do |i|
  command  = C[i]
  c1 = command[0] == "A" ? 0 : 1
  c2 = command[1] == "B" ? 1 : 2

  if A[c1] == 0 && A[c2] == 0
    flg = false
    break
  end

  if A[c1] > A[c2]
    res << command[1]
    A[c1] -= 1
    A[c2] += 1
  elsif A[c1] < A[c2]
    res << command[0]
    A[c1] += 1
    A[c2] -= 1
  else
    if i == N-1
      res << command[0]
      break
    end

    next_command = C[i+1]
    if command == next_command
      res << command[1]
      A[c1] -= 1
      A[c2] += 1
    else
      if (command == "AB" && next_command == "AC") || (command == "AC" && next_command == "AB")
        res << "A"
        A[0] += 1
        A[c2] -= 1
      elsif (command == "AB" && next_command == "BC") || (command == "BC" && next_command == "AB")
        res << "B"
        A[1] += 1
        if (command == "AB")
          A[0] -= 1
        else
          A[2] -= 1
        end
      else
        res << "C"
        A[2] += 1
        A[c1] -= 1
      end
    end
  end
end

if flg
  puts "Yes"
  res.each do |r|
    puts r
  end
else
  puts "No"
end


Measured memory_bytes: 29544
#include <stdio.h>
#include <algorithm>
#include <vector>

std::vector<int> vr;
const int INF = 1e9;
int dp[201][201];
int main(){
    int n,m,r;
    scanf("%d%d%d",&n,&m,&r);
    for(int i=1;i<=n;i++)
    {
        for(int j=1;j<=n;j++)
        {
            if(i!=j) dp[i][j] = INF;
        }
    }
    vr.resize(r);
    for(int i=0;i<r;i++)
    {
        scanf("%d",&vr[i]);
    }
    std::sort(vr.begin(), vr.end());
    for(int i=0;i<m;i++)
    {
        int a,b,c;
        scanf("%d%d%d",&a,&b,&c);
        dp[a][b] = c;
        dp[b][a] = c;
    }

    for(int k=1;k<=n;k++)
    {
        for(int i=1;i<=n;i++)
        {
            for(int j=1;j<=n;j++)
            {
                if(dp[i][j] > dp[i][k] + dp[k][j])
                    dp[i][j] = dp[i][k] + dp[k][j];
            }
        }
    }

    int ans = INF;
    do
    {
        int temp = 0;
        for(int i=1;i<r;i++)
        {
            temp += dp[vr[i-1]][vr[i]];
        }
        ans = std::min(ans, temp);
    }while(std::next_permutation(vr.begin(), vr.end()));
    printf("%d", ans);
}

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

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

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

const int di[4] = {1, 0, -1, 0};
const int dj[4] = {0, 1, 0, -1};

int main() {
    int h, w;
    cin >> h >> w;
    string s[h];
    for(int i = 0; i < h; ++i) cin >> s[i];
    
    bool can = true;
    for(int i = 0; i < h; ++i) {
        for(int j = 0; j < w; ++j) {
            if(s[i][j] == '#') {
                int counter = 0;
                for(int d = 0; d < 4; ++d) {
                    int ni = i + di[d];
                    int nj = j + dj[d];
                    
                    if(ni < 0 || h <= ni || nj < 0 || w <= nj) continue;
                    if(s[ni][nj] == '#') ++counter;
                }
                
                if(counter == 0) can = false;
            }
        }
    }
    
    if(can) cout << "Yes" << endl;
    else cout << "No" << endl;
}


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

int main(){
  int n,i,s1,s2,t,mi;
  cin >> n;
  vector<int> w(n);
  for(i=0;i<n;++i){
    cin >> w[i];
  }
  mi=1000000;
  s1=s2=0;
  for(t=1;t<n;++t){
    for(i=0;i<n;++i){
      if(i<=t-1){
        s1=s1+w[i];
      }else{
        s2=s2+w[i];
      }
    }
    mi=min(mi,abs(s1-s2));
    s1=s2=0;

  }
  cout << mi << endl;
  return 0;

}


Measured memory_bytes: 256
n = int(input())
d = []
sum = 0
success = 0
for i in range(0,n):
    #d.append(input().split(" "))
    d = input().split(" ")
    if d[0] == d[1]:
        sum += 1
    else:
        sum = 0
    if sum >= 3:
        success += 1
        
if success >= 1:
    print("Yes")
else:
    print("No")


Measured memory_bytes: 9168
#include<iostream>
#include<string>
#include<cstring>
#include<algorithm>
#include<vector>
#include<map>
#include<cmath>
#include<string>
#include<bitset>
#include <sstream>
#include<queue>
#include<set>
#include<iomanip>
#define rep(i,n) for(ll i=0;i<(n);++i)
using namespace std;
typedef long long ll;
typedef pair<int,int>P;
const int INF=10101;

int main()
{
    int a,b;
    cin>>a;
    cin>>b;
    int ans=6;
    cout<<ans-a-b;
}

Measured memory_bytes: 888
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <stack>
#include <iostream>
#include <queue>
#include <vector>
using namespace std;

const int MA_X = 1e-6;
const int MAxn = 1e5 + 5;

int main(){
    int n, m;
    cin >> n >> m;
    cout << (n-1)*(m-1) << endl;
    return 0;
}

Measured memory_bytes: 256
H, W = map(int, input().split())
S = [list(input()) for _ in range(H)]

#   .
# . # .
#   .
# を探す

for i in range(H):
    for j in range(W):
        if S[i][j] == "#":
            temp = set()
            if i != 0:
                temp.add(S[i-1][j])
            if i != H-1:
                temp.add(S[i+1][j])
            if j != 0:
                temp.add(S[i][j-1])
            if j != W-1:
                temp.add(S[i][j+1])
            if temp == set("."):
                print("No")
                exit()

print("Yes")

Measured memory_bytes: 9128
X,Y,A,B,C = map(int,input().split())

p = list(map(int,input().split()))
q = list(map(int,input().split()))
r = list(map(int,input().split()))

p.sort()
q.sort()
r.sort(reverse=True)
p = p[A-X:]
q = q[B-Y:]
min_p = 0
min_q = 0
j = 0

for i in range(C):
  if min_p < X and min_q < Y:
  
    if p[min_p] > r[i] and q[min_q] > r[i]:
      break
    
    if p[min_p] < q[min_q]:
      if p[min_p] <= r[i]:
        p[min_p] = r[i]
      min_p += 1
    else:
      if q[min_q] <= r[i]:
        q[min_q] = r[i]
      min_q += 1
      
  elif min_p < X:
    if p[min_p] <= r[i]:
      p[min_p] = r[i]
    min_p += 1
  elif min_q < Y:
    if q[min_q] <= r[i]:
      q[min_q] = r[i]
    min_q += 1
  else:
    break
    
print(sum(p)+sum(q))

Measured memory_bytes: 22720
#include <iostream>
#include <map>
#include <vector>
#include <string>
#include <algorithm>
#include <stdio.h>
#include <sstream>
#include <cstdlib>

using namespace std;
using ll = long long;
using ld = long double;

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

int main() {

    string s;
    cin >> s;

    vector<string> v = StringSplit(s, '/');
    int a0 = std::stoi(v[0]);
    string s1 = "";
    if (v[1][0] == '0') {
        s1 += v[1][1];
    } else {
        s1 += v[1][0];
        s1 += v[1][1];
    }

    int a1 = std::stoi(s1);
    string s2 = "";
    if (v[2][0] == '0') {
        s2 += v[2][1];
    } else {
        s2 += v[2][0];
        s2 += v[2][1];
    }
    int a2 = std::stoi(s2);

    if (a0 < 2019) {
        cout << "Heisei" << endl;
        return 0;
    }
    if (a1 < 4) {
        cout << "Heisei" << endl;
        return 0;

    }
    if (a1 == 4 && a2 <= 30) {
        cout << "Heisei" << endl;
        return 0;

    }


    cout << "TBD" << endl;
    return 0;


}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int n,w,w1,a,b,ans,num[4];
long long W[4];
vector<int> v[4];
int main(){
    cin>>n>>w;
    for(int i=0;i<n;i++){
        cin>>a>>b;
        if(!i)w1=a;
        v[a-w1].push_back(b);
    }
    for(int i=0;i<4;i++)sort(v[i].begin(),v[i].end(),greater<int>());
    for(int A=0;A<=v[0].size();A++){
        if(A){
            W[0]+=w1;
            num[0]+=v[0][A-1];
        }W[1]=W[0];
        num[1]=num[0];
        for(int B=0;B<=v[1].size();B++){
            if(B){
                W[1]+=w1+1;
                num[1]+=v[1][B-1];
            }W[2]=W[1];
            num[2]=num[1];
            for(int C=0;C<=v[2].size();C++){
                if(C){
                    W[2]+=w1+2;
                    num[2]+=v[2][C-1];
                }W[3]=W[2];
                num[3]=num[2];
                for(int D=0;D<=v[3].size();D++){
                    if(D){
                        W[3]+=w1+3;
                        num[3]+=v[3][D-1];
                    }
                    if(W[3]>w)continue;
                    ans=max(ans,num[3]);
                }
            }
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstring>
#include<string>
#include<string.h>
using namespace std;
int main()
{
	int x;
	cin>>x;
	int ans=0;
	ans+=1000*(x/500);
	x%=500;
	ans+=5*(x/5);
	x%=5;
	cout<<ans;
	return 0;
} 

Measured memory_bytes: 256
import sys

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007


def core(h, H, W):
    if W % 2 == 0:
        return abs(h * W - (H - h) * (W // 2))
    else:
        a, b, c = h * W, (H - h) * (W // 2), (H - h) * (W // 2 + 1)
        return max(abs(a - b), abs(b - c), abs(c - a))


def solve(H, W):
    ans = abs((H // 3) * W - ((H + 2) // 3) * W)

    if H % 3 == 0:
        ans = min(ans, core(H // 3, H, W))
    else:
        ans = min(ans, core(H // 3, H, W), core(H // 3 + 1, H, W))

    return ans


def main():
    H, W = map(int, readline().split())

    ans = min(solve(H, W), solve(W, H))

    print(ans)
    return


if __name__ == '__main__':
    main()


Measured memory_bytes: 80612
#include <iostream>
#include <vector>
using namespace std;
int main(){
  int N;
  cin>>N;
  vector<int> A(N);
  for(int i = 0;i < N; i++) cin >> A[i];
  vector<int> rev(N);
  for(int i = 0;i < N; i++) rev[A[i] - 1] = i + 1;
  for(int i = 0;i < N; i++) cout << rev[i] << " ";
  return 0;
}

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

int main() {
  string S;
  cin >> S;

  for(int i=0;i<S.size();i++) {
    /*if(i==0) {
      S.pop_back();
      S.pop_back();
    }
    */
    /*else if(S.size()==2 && (i==0 || S[0]!=S[1])) {
      cout << 1 << endl;
      return 0;
    }*/
    //else {
      int m=S.size()/2-i;
      
      if(i!=0 && S.substr(0,m)==S.substr(m,m)) {
        cout << 2*m << endl;
        return 0;
      }
      /*else{
        S.pop_back();
        S.pop_back();
      }*/
    //}
  }
}


Measured memory_bytes: 256
#pragma GCC optimize(2)
#include <bits/stdc++.h>
using namespace std;
using LL = long long;
using PII = pair<int, int>;
using PLL = pair<LL, LL>;
const int INF = 1e9;
const int MXN = 0;
const int MXV = 0;
#define MP make_pair
#define PB push_back
#define F first
#define S second
#define FOR(i, L, R) for (int i = L; i != (int)R; ++i)
#define FORD(i, L, R) for (int i = L; i != (int)R; --i)
#define IOS                                                                    \
    cin.tie(nullptr);                                                          \
    cout.tie(nullptr);                                                         \
    ios_base::sync_with_stdio(false);

int main()
{
    IOS;
    int n, k;
    double ans = 0;
    cin >> n >> k;
    vector<double> v(n + 1, 0);
    FOR(i, 1, n + 1)
    {
        cin >> v[i];
        v[i] = (1 + v[i]) * 0.5;
        v[i] += v[i - 1];
    }
    FOR(i, k, n + 1)
    {
        ans = max(ans, v[i] - v[i - k]);
    }
    cout << fixed << setprecision(8) << (double)ans << '\n';
}


Measured memory_bytes: 1792
#include <stdio.h>
int cnt = 0;

void bubbleSort(int A[],int n) {
    int flag = 1, tmp;
    while (flag) {
        flag = 0;
        for (int i = n-1; i > 0; i--) {
            if (A[i] < A[i-1]) {tmp = A[i]; A[i] = A[i-1]; A[i-1] = tmp; flag = 1; cnt++;}
        }
    }
}

int main(void){
    int n, A[100];
    scanf("%d", &n);
    
    for (int i = 0; i < n; i++) {
        scanf("%d", &A[i]);
    }
    
    bubbleSort(A, n);
    
    for (int i = 0; i < n; i++) {
        if (i) printf(" ");
        printf("%d", A[i]);
    }
    
    printf("\n");
    printf("%d", cnt);
    printf("\n");
    
    return 0;
}



Measured memory_bytes: 2084
//
//

#include<bits/stdc++.h>
#define ll long long
#define ALL(v) (v).begin(),(v).end()
#define REP(i,p,n) for(int i=p;i<(int)(n);++i)
#define rep(i,n) REP(i,0,n)
#define dump(a) (cerr << #a << "=" << (a) << endl)
#define DUMP(list) cout << "{ "; for(auto nth : list){ cout << nth << " "; } cout << "}" << endl;
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; }


using namespace std;
ll c = 1e9+7;

int main(){
    int H, W;
    ll dp[1001][1001];
    char a[1001][1001];
    cin >> H >> W;
    rep(i, H){
        rep(j, W){
            cin >> a[i+1][j+1];
        }
    }

    dp[1][1] = 1;


    REP(i, 1, H+1){
        REP(j, 1, W+1){
            if(i == 1){
                if (a[1][j] == '.' && j != 1) {
                    dp[1][j] = dp[1][j-1] % c;
                } else if (a[1][j] == '#'){
                    dp[1][j] = 0;
                }
            } else if (j == 1){
                if (a[i][1] == '.'){
                    dp[i][j] = dp[i-1][j] % c;
                } else {
                    dp[i][j] = 0;
                }
            } else {
                if (a[i][j] == '.'){
                    dp[i][j] = ((dp[i-1][j] % c) + (dp[i][j-1] % c)) % c;
                } else {
                    dp[i][j] = 0;
                }
            }
        }
    }

    cout << dp[H][W] << endl;


}

Measured memory_bytes: 9088
'use strict'
// import bigInt from 'big-integer'

const main = (input) => {
    input = input.trim()
    const nums = input.split("")
    const plusNum = nums.length - 1
    let answer = 0

    for (let bit = 0; bit < (1 << plusNum); bit++) {
        let tmpStrs = [nums[0]]
        for (let i = 0; i < plusNum; i++) {
            const num = nums[i + 1]
            if (bit & (1 << i)) {
                tmpStrs.push(num)
            } else {
                tmpStrs[tmpStrs.length - 1] += num
            }
        }
        answer += tmpStrs.reduce((acc, cur) => acc + parseInt(cur, 10), 0)
    }

    console.log(answer)
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'));


Measured memory_bytes: 8648
#include <bits/stdc++.h>
using namespace std;
int main(){
    int a,b,c,d;
    cin >> a >> b >> c >> d;
    if(abs(a-b)<=d&&abs(b-c)<=d||abs(a-c)<=d){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }
}

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

typedef unsigned long long ull;
typedef long long ll;

const int INF = 1001001001;
const ll MOD = 1e9 + 7;

using namespace std;
using P = pair<int,int>;

ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
ll lcm(ll c, ll d) { return c / gcd(c, d) * d; }

int main() {
  int a, b;
  cin >> a >> b;
  
  int ans = a*b;
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3624
#include<stdio.h>
#include<iostream>
#include<string.h>
#define len 100010

using namespace std;


struct Q{
  char name[110];
  int tim;
};

Q Que[len];
int n;
int head=0;
int tail=0;

/*int initialize(){
  head=tail=0;
  }*/

void enqueue(Q x){
  Que[tail]=x;
  tail=(tail+1)%len;
}

/*int isEmpty(){
  if(head==tail){
    return 1;
  }
  }*/

Q dequeue(){
  //if(isEmpty()==1)fprintf(stderr,"UnderFlow\n");
  Q y=Que[head];
  head=(head+1)%len;
  return y;
}

/*int isFull(){
  if(head==(tail+1)%len){
    return 1;
  }
  }*/

int main(){
  int c=0,d=0;
  int del=0;
  Q ll;
  //if(isFull()!=1)fprintf(stderr,"OverFlow\n");
  
  cin>>n>>del;
  head=1;
  tail=n+1;
  for(int i=1;i<=n;i++){
    cin>>Que[i].name;
    cin>>Que[i].tim;
  }
  while(1){
    //if(isEmpty()==1)break;
    if(head==tail)break;
    ll=dequeue();
    if(del<ll.tim)c=del;
    else c=ll.tim;
    ll.tim=ll.tim-c;
    d=d+c;
    if(ll.tim>0)enqueue(ll);
    else cout<<ll.name<<" "<<d<<endl;
  }
  return 0;
}



Measured memory_bytes: 14432
#define _USE_MATH_DEFINES
 
#include <bits/stdc++.h> 

using namespace std;
 
#define len(x) (int)((x).size())
#define endl '\n'
#define x first
#define y second
#define int long long
#define double long double
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define vi vector<int> 
#define vvi vector<vector<int>>
#define pb push_back
 
#ifdef LOCAL
    #define dbg(x) cout << #x << " = " << x << endl;
#else 
    #define dbg(x)
#endif 
 
void solve(); signed main() {
#ifdef LOCAL
    freopen("input.txt", "r", stdin);                                       
    freopen("output.txt", "w", stderr);
#endif
    srand(time(0));
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    cout.setf(ios::fixed); cout.precision(10);
    solve();    
}

const int INF = 1e18, MAXN = 2e5 + 10, MOD = 1e9 + 7;
int fact[MAXN], rfact[MAXN];

int bin_pow(int num, int n) {
 	if (n == 0) {
 	    return 1;
 	}	

 	if (n % 2 == 0) {
 	 	int tmp = bin_pow(num, n / 2) % MOD;
 	 	return tmp * tmp % MOD;
 	}
 	else {
 		return num * bin_pow(num, n - 1) % MOD;
 	}
}

void precalc() {
	fact[0] = 1; rfact[0] = bin_pow(fact[0], MOD - 2);
	for (int i = 1; i < MAXN; ++i) {
	 	fact[i] = (fact[i - 1] * i) % MOD;
	 	rfact[i] = bin_pow(fact[i], MOD - 2);
	}
}        	

int c(int n, int k) {
 	return (fact[n] * rfact[k] % MOD) * rfact[n - k] % MOD;
}

void solve() {
    precalc();
	
    int n, m;
    cin >> n >> m;
    
	vi cs;
    for (int i = 2; i * i <= m; i++) {
        if (m % i == 0) {
            int cnt = 0;
            while (m % i == 0) {
                m /= i;
                cnt++;                                                       	
            }
    
            cs.push_back(cnt);
        }
    }
    
    if (m > 1) {
        cs.push_back(1);
    }
    
   	dbg(c(4, 2))

    int ans = 1;
    for (int cc : cs) {
        ans = (ans * c(n + cc - 1, cc)) % MOD;
    }

    cout << ans << endl;
}	


Measured memory_bytes: 3328
#include <bits/stdc++.h>
#define int long long int
#define ii pair<int,int>
#define fi first
#define se second
#define mp make_pair
#define pb push_back
using namespace std;
#define MOD 998244353
#define output(x) for (auto a:x) cout<<a<<" ";cout<<endl;
#define output2(x) for (auto a:x) cout<<a.fi<<" "<<a.se<<endl;
 
int power(int x,int y,int mod) 
{ 
 	int ret = 1;
 	x = x % mod;
 	while (y){
 		if(y&1) ret = (ret*x)%mod;
 		y = y>>1;
 		x = (x*x)%mod;
    } 
    return ret%mod; 
}

int isprime(int x)
{
	for (int i=2;i*i<=x;i++)
		if (x%i==0) return 0;
	return 1;
}

void solve()
{	
	int n,k;
	cin>>n;
	k = 2;
	vector<int> inp(n),dp(n,1e9+5);
	dp[0] = 0;
	for (auto &x:inp) cin>>x;
	for (int i=0;i<n;i++){
		for (int j=i+1;j<i+k+1 && j<n;j++){
			dp[j] = min(dp[j],dp[i]+abs(inp[j]-inp[i])); 
		}
	}
	cout<<dp[n-1]<<endl;

}
 
 
signed main(){
	// int t;
	// cin>>t;
	// while (t--)	
	solve();	
 
}
	

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

using ll = long long;
using ld = long double;
using pii = pair<int, int>;

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
#define m0(x) memset(x,0,sizeof(x))

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


int main()
{
    int a,b;
    cin>>a>>b;
    int ans=0;
    for(int i = 0; i < 2; i++)
    {
        if(a>b) swap(a,b);
        ans+=b;
        b--;
    }
    cout<<ans<<endl;
 
    return 0;
}

Measured memory_bytes: 256
#![allow(non_snake_case)]
#[allow(unused_imports)]
use std::io::{self, Write};
#[allow(unused_imports)]
use std::collections::{BTreeMap, BTreeSet, BinaryHeap, HashMap, HashSet, VecDeque};
#[allow(unused_imports)]
use std::cmp::{max, min, Ordering};
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};
    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };
    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };
    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };
    ($next:expr, char) => {
        read_value!($next, String).chars().collect::<Vec<char>>()[0]
     };
    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
     };
    ($next:expr, isize1) => {
        read_value!($next, isize) - 1
    };
     ($next:expr, $t:ty) => {
         $next().parse::<$t>().expect("Parse error")
    };
}
macro_rules! printvec {
    ( $item:expr ) => {
        for &i in &$item {
            print!("{} ", i);
        }
        println!("");
    }
}
macro_rules! debug {
    ($($a:expr),*) => {
        println!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);
    }
}
#[derive(Eq, PartialEq, Clone, Debug)]
pub struct Rev<T>(pub T);
impl<T: PartialOrd> PartialOrd for Rev<T> {
    fn partial_cmp(&self, other: &Rev<T>) -> Option<Ordering> {
        other.0.partial_cmp(&self.0)
    }
}
impl<T: Ord> Ord for Rev<T> {
    fn cmp(&self, other: &Rev<T>) -> Ordering {
        other.0.cmp(&self.0)
    }
}
#[derive(PartialEq, PartialOrd, Clone, Debug)]
pub struct Total<T>(pub T);
impl<T: PartialEq> Eq for Total<T> {}
impl<T: PartialOrd> Ord for Total<T> {
    fn cmp(&self, other: &Total<T>) -> Ordering {
        self.0.partial_cmp(&other.0).unwrap()
    }
}
#[allow(dead_code)]
const MOD: usize = 1000000007;
#[allow(dead_code)]
fn to_num(c: char) -> i64 {
    c as i64 - 48
}


fn main() {
    input!{
        W: usize,
        a: usize, b: usize,
    }
    let ans;
    if a + W < b {
        ans = b - W - a;
    } else if a + W >= b && a <= b + W {
        ans = 0;
    } else {
        ans = a - W - b;
    }
    println!("{}", ans);
}

Measured memory_bytes: 4352
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
#define rep(i, n) for (ll i = 0; i < (int)(n); i++)
#include <vector>
#include <numeric>
#include <map>
#include <cmath>
#include <iomanip>
#include <queue>
using ll =long long;
#define PI 3.14159265358979
//#define rep(i,init,n) for(ll i=init;i<=n;++i)
using P = pair<ll , ll>;
using map = map<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vi>;
using vs = vector<string>;

int main(){
    long double a, b;
    cin >> a >> b;

    long double ans = a*b;
    

    cout << ll(ans) << endl;

    return 0;
}

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


int get(string s){
	s[2] = ' ';
	stringstream ss(s);
	int h,m;
	ss >> h >> m;
	return h * 60 + m;
}

int main(){
	int n;
	while(cin >> n && n){
		map<string,int> in;
		map<string,int> tot;
		for(int i = 0 ; i < n ; i++){
			string d,s,t,id;
			cin >> d >> s >> t >> id;
			if( t == "I" ){
				in[id] = get(s);
			}else{
				if( id == "000" ){
					for( auto e : in ){
						//cout << get(s) - max(tot["000"],tot[e.first]) << "<" << endl;
						tot[e.first] += get(s) - max(in["000"],in[e.first]);
					}
				}else if( in.count("000") ){
					tot[id] += get(s) - max(in["000"],in[id]);
				}
				in.erase(id);
			}
		}
		int ans = 0;
		for( auto e : tot ){
			if( e.first != "000" ){
				ans = max(ans,e.second);
			}
		}
		cout << ans << endl;
	}
}

Measured memory_bytes: 1288
import java.util.*;
import java.lang.*;

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        if(a==1){
            if(b==2){
                System.out.println(3);
            }else{
                System.out.println(2);
            }
        }else if(a==2){
            if(b==1){
                System.out.println(3);
            }else{
                System.out.println(1);
            }
        }else if(a==3){
            if(b==1){
                System.out.println(2);
            }else{
                System.out.println(1);
            }
        }
        sc.close();
    }
}

Measured memory_bytes: 22864
#include <iostream>
#include <sstream>
#include <string>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cassert>

using namespace std;

#define FOR(i,k,n) for(int i=(k); i<(int)n; ++i)
#define REP(i,n) FOR(i,0,n)
#define FORIT(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)

template<class T> void debug(T begin, T end){ for(T i = begin; i != end; ++i) cout<<*i<<" "; cout<<endl; }

typedef long long ll;
const int INF = 100000000;
const double EPS = 1e-8;
const int MOD = 1000000007;

int main(){
	int n;
	while(cin>>n,n){
		int x[3000],y[3000];
		set<pair<int,int> > pset;
		bool bx[10000] = {};
		bool by[10000] = {};
		REP(i,n){
			cin>>x[i]>>y[i];
			pset.insert(make_pair(x[i],y[i]));
		}
		int ans = 0;
		REP(i,n)FOR(j,i+1,n){
			int x1 = x[i], x2 = x[j], y1 = y[i], y2 = y[j];
			int dx = x2-x1;
			int dy = y2-y1;
			if(pset.count(make_pair(x1+dy, y1-dx)) && pset.count(make_pair(x2+dy, y2-dx))){
				ans = max(ans, dx*dx+dy*dy);
			}
			dx *= -1; dy *= -1;
			if(pset.count(make_pair(x1+dy, y1-dx)) && pset.count(make_pair(x2+dy, y2-dx))){
				ans = max(ans, dx*dx+dy*dy);
			}
		}
		cout<<ans<<endl;
	}
	return 0;
}

Measured memory_bytes: 1024
tiles = '><^v.'
moves = ((1,0),(-1,0),(0,-1),(0,1))
while 1:
	h, w = map(int, raw_input().split())
	if h == 0:
		exit()
	m = map(list,zip(*[raw_input() for i in xrange(h)]))
	tile = (0,0)
	p = []
	while tile != -1 and m[tile[0]][tile[1]] != '.':
		if tile in p:
			tile = -1
		else:
			p.append(tile)
			t = tiles.index(m[tile[0]][tile[1]])
			tile = (tile[0]+moves[t][0],tile[1]+moves[t][1])
	if tile == -1:
		print 'LOOP'
	else:
		print tile[0],tile[1]

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

int main(){
    std::vector<std::vector<int>> log (3, std::vector<int>(3));
    std::vector<std::vector<int>> bingo (3, std::vector<int>(3));
    int n = 0;
    int call = 0;

    for(int i = 0; i < 3; i++){
        for(int j = 0; j < 3; j++){
            std::cin >> log[i][j];
        }
    }
    std::cin >> n;

    std::vector<int> b(n);

    for(int i = 0; i < n; i++){
        std::cin >> b[i];
    }

    for(int i = 0; i < 3; i++){
        for(int j = 0; j < 3; j++){
            bingo[i][j] = 0;
        }
    }

    for(int k = 0; k < n; k++){
        for(int i = 0; i < 3; i++){
            for(int j = 0; j < 3; j++){
                if(log[i][j] == b[k]){
                    bingo[i][j] = 1;
                }
            }
        }
    }

    for(int i = 0; i < 3; i++){
            if(bingo[0][i] == 1 && bingo[1][i] == 1 && bingo[2][i] == 1){
                call = 1;
            }
            if(bingo[i][0] == 1 && bingo[i][1] == 1 && bingo[i][2] == 1){
                call = 1;
            }
    }

    if(bingo[0][0] == 1 && bingo[1][1] == 1 && bingo[2][2] == 1){
        call = 1;
    }
    else if(bingo[0][2] == 1 && bingo[1][1] == 1 && bingo[2][0] == 1){
        call = 1;
    }

    /*
    std::cout << "A11: " << log[0][0] << " " << bingo[0][0] << " " << b[5]<< std::endl;
    std::cout << "A22: " << log[1][1] << " " << bingo[1][1] << " " << b[0]<< std::endl;
    std::cout << "A33: " << log[2][2] << " " << bingo[2][2] << " " << b[1]<< std::endl;
    */
   
    if(call == 1){
        std::cout << "Yes" << std::endl;
    }
    else if(call == 0){
        std::cout << "No" << std::endl;
    }
    
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,n) for(int i=0;i<n;i++)
#define why(n,x) int n;while(cin >>n,n!=x)
#define iFOR(i,x,n)for(int i=x;i<n;i++)
#define unless(flg) if ( !(flg) )
#define read cin<<
#define echo cout<<
#define fin <<'\n'
#define __ <<" "<<
#define ___ <<" "
#define bash push_back
#define ALL(x) x.begin(),x.end()
#define SWAP(a,b) ((a != b) && (a += b,b = a - b,a -= b))
#define cinf(n,x) for(int UNCH=0;UNCH<(n);UNCH++) cin >> x[UNCH];
#define fcin(n,x) for(int UNCH=1;UNCH<=(n);UNCH++) cin>> x[UNCH];
#define memmin(x) memset((x),-1,sizeof((x)))
#define memzer(x) memset((x), 0,sizeof((x)))
#define meminf(x) memset((x),0x3f,sizeof((x)))
#define int long long
typedef long long ll;
typedef pair < int , int >  pii;
typedef vector < int > vit;
typedef map < string , int > mstit;
typedef vector < pii > vpi ;
typedef greater < pii > gpi;
typedef priority_queue < pii , vpi , gpi > dijk ;
static const signed int INF = 0x3f3f3f3f;
static const signed long long LINF = 0x3f3f3f3f3f3f3f3fLL;
static const signed int SMOD = 1000000007;
static const signed int NMOD = 1000000009;
static const signed int dx[]={1,0,-1,0,1,1,-1,-1};
static const signed int dy[]={0,-1,0,1,-1,1,-1,1};

bool inside(int x,int y,int w,int h){return (x>=0 && y>=0 && x<w && y<h);}
template<class T>T abs(T &x){return x<0 ? -x : x;}
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
int qp(int a,ll b,int mo){int ans=1;do{if(b&1)ans=1ll*ans*a%mo;a=1ll*a*a%mo;}while(b>>=1);return ans;}
int gcd(int a,int b){return b?gcd(b,a%b):a;}


signed main(){
  int n,ans=0;
  int k,x,y;
  cin >> n >> k >> x >> y;
  iFOR(i,1,n+1){
    if(i<=k) ans+=x;
    else ans+=y;
  }
  cout << ans fin;

  return 0;
}

  

struct xyz{ xyz(){ cin.tie(0), ios::sync_with_stdio(false); cout <<fixed<<setprecision(12);};}xyzzy;



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

public class Main{
	public static void main(String[] args) throws IOException{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String line = "";
		while((line = br.readLine()) != null){
			String[] s = line.split(" ");
			long a,b;
			a = Long.parseLong(s[0]);
			b = Long.parseLong(s[1]);
			System.out.println(gcd(a,b) + " " + lcm(a,b));
		}
	}
	
	public static long gcd(long a,long b){
		if(a%b == 0){ return b;}
		else{ return gcd(b,a%b);}
	}
	
	public static long lcm(long a,long b){
		return a*b / gcd(a,b);
	}
}

Measured memory_bytes: 24084
class Combination:
    """
    SIZEが10^6程度以下の二項係数を何回も呼び出したいときに使う
    使い方:
    comb = Combination(SIZE, MOD)
    comb(10, 3) => 120
    """

    def __init__(self, N, MOD=10 ** 9 + 7):
        self.MOD = MOD
        self.fact, self.inv = self._make_factorial_list(N)

    def __call__(self, n, k):
        if k < 0 or k > n or n <= 0:
            return 0
        res = self.fact[n] * self.inv[k] % self.MOD
        res = res * self.inv[n - k] % self.MOD
        return res

    def _make_factorial_list(self, N):
        fact = [1] * (N + 1)
        inv = [1] * (N + 1)
        MOD = self.MOD
        for i in range(1, N + 1):
            fact[i] = (fact[i - 1] * i) % MOD
        inv[N] = pow(fact[N], MOD - 2, MOD)
        for i in range(N, 0, -1):
            inv[i - 1] = (inv[i] * i) % MOD
        return fact, inv


if __name__ == "__main__":
    N, K = map(int, input().split())
    A = list(map(int, input().split()))
    mod = 10 ** 9 + 7
    comb = Combination(N, mod)

    ans = 0
    A.sort()
    for i in range(N - K + 1):
        Amax = A[-i - 1]
        Amin = A[i]
        ans += (Amax - Amin) * comb(N - i - 1, K - 1)
        ans %= mod

    print(ans)


Measured memory_bytes: 15568
#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <queue>
#include <map>
#include<algorithm>
#include<sstream>
#include<iomanip>


using namespace std;



int main() {
	int n;
	cin >> n;
	vector<int> x(n);
	for (int i = 0; i < n; i++) {
		cin >> x[i];
	}

	vector<int> b(x);

	sort(b.begin(), b.end());


	int mid = (b[n / 2] + b[n / 2 - 1]) / 2;

	for (int i = 0; i < n;i++) {
		if (x[i] <= mid) {
			cout << b[n / 2] << endl;
		}
		else {
			cout << b[n / 2 - 1] << endl;
		}
	}
}

Measured memory_bytes: 3712
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define Fast_IO ios::sync_with_stdio(false);
#define int long long
inline int read()
{
	char ch=getchar(); int nega=1; while(!isdigit(ch)) {if(ch=='-') nega=-1; ch=getchar();}
	int ans=0; while(isdigit(ch)) {ans=ans*10+ch-48;ch=getchar();}
	if(nega==-1) return -ans;
	return ans;
}

signed main()
{
#ifdef __LOCAL__
	freopen("in.txt","r",stdin);
#endif
	int x,y;
	cin>>x>>y;
	int g=__gcd(x,y);
	int ans=1;
	for(int i=2;i*i<=g;i++)
	{
		if(g%i==0) ans++;
		while(g%i==0) g/=i;
	}
	if(g!=1) ans++;
	cout<<ans<<endl;
#ifdef __LOCAL__
	printf("Time Used : %d\n",clock());
#endif
	return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>
#include <cstdint>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <cmath>
#include <cstdlib>
#include <sstream>
#include <functional>
#include <bitset>
#include <queue>

#include <boost/range/irange.hpp>
using boost::irange;

#include <boost/utility/string_ref.hpp>
using string_view = boost::string_ref;

#include <boost/function_output_iterator.hpp>

using namespace std;

template<class T>
constexpr T gcd(T m, T n)
{
    return n == 0 ? (m < 0 ? -m : m) : gcd(n, m % n);
}


int main()
{
    int n;;
    cin >> n;
    vector<int> as(n);
    for(auto& a : as) cin >> a;
    
    uint64_t minabs = abs(as[0]);
    uint64_t abssum = 0;
    int count_minus = 0;
    for(int a : as)
    {
        if(a < 0)
        {
            ++count_minus;
            a = -a;
        }
        abssum += a;
        minabs = min(minabs, (uint64_t)a);
    }
    if(count_minus % 2 == 0)
    {
        cout << abssum << '\n';
    }
    else
    {
        cout << (abssum - minabs * 2) << '\n';
    }
    return 0;
}


Measured memory_bytes: 640
// Copyright 2019 yaito3014
#include "bits/stdc++.h"
using namespace std;

int main() {
  cin.tie(nullptr); ios::sync_with_stdio(false);
  string S;
  cin >> S;
  int N = S.length();
  int K = 1;
  string prev;
  for (int i = 0; i < N; ++i) {
    int j = 1;
    for (; j <= N - i; ++j)
      if (prev != S.substr(0, j))break;
    if (j > N - i) {
      --K;
      break;
    }
    prev = S.substr(0, j);
    S = S.substr(j);
    if (S.empty())break;
    ++K;
  }
  cout << K << endl;
}


Measured memory_bytes: 788
#include<stdio.h>

int main()
{
	int c1,c2,c3,u20,i,n;
	double p;

	while(scanf("%d %d %d",&c1,&c2,&c3)!=EOF)
	{
		n=0;
		u20=20-(c1+c2);
		if(u20>10)u20=10;
		for(i=1;i<=u20;i++)
		{
			if(i==c1||i==c2||i==c3)n--;
			n++;
		}
		p=(double)n/7;
		if(p>=0.5){puts("YES");}
		else{puts("NO");}
	}
	return 0;
}

Measured memory_bytes: 0
l = 5.times.map{gets.chomp}.sort_by{|c| c[-1]}.map(&:to_i)
min = l.select{|n| n%10!=0}[0] || 0
sum,f = 0,false
l.each do |n|
  if (n != min and n%10 != 0) or f
    n = n/10*10 + 10
  end
  f = true if n == min
  sum += n
end
p sum

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

#define ll long long
#define ar array

int main() {
	string s;
	cin >> s;
	int r=0, mx=0;
	for(int i=0; i<3; ++i) {
		if(s[i]=='R')
			r++;
		else
			r=0;
		mx=max(mx, r);
	}
	cout << mx << "\n";
}


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

using namespace std;

int main()
{
    int N, Ma, Mb;
    cin>>N>>Ma>>Mb;

    int oo = 10000;
    vector<vector<int>> T(N*10+1, vector<int>(N*10+1, oo));
    T[0][0] = 0;
    for (int i=0; i<N; i++)
    {
        vector<vector<int>> P = T;

        int a, b, c;
        cin>>a>>b>>c;

        for (int ta=0; ta<=10*i; ta++)
        for (int tb=0; tb<=10*i; tb++)
            T[ta+a][tb+b] = min(T[ta+a][tb+b], P[ta][tb]+c);
    }

    int ans = oo;
    for (int a=1; a<=N*10; a++)
    for (int b=1; b<=N*10; b++)
        if (a*Mb==b*Ma)
            ans = min(ans, T[a][b]);
    cout<<(ans<oo ? ans : -1)<<endl;
}


Measured memory_bytes: 1536
#include <bits/stdc++.h>
using namespace std;
const int MOD = 1e9 + 7;
typedef long long lint;
const int INF = 1e7;
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define trep(i, k, n) for (int i = (k); i < (int)(n); ++i)
typedef pair<int, int> P;
#define H 55
#define W 55
int h, w;
int sx, sy;
int gx, gy;
char c[H][W];
int dx[4] = {-1, 1, 0, 0};
int dy[4] = {0, 0, 1, -1};
vector<vector<int> > d(H, vector<int>(W, INF));
int bfs(void)
{
    queue<P> q;
    q.push(P(sy, sx));
    d[sy][sx] = 0;
    while (q.size())
    {
        P p = q.front();
        q.pop();
        rep(i, 4)
        {
            int ny = p.first + dy[i];
            int nx = p.second + dx[i];
            if (0 <= ny && ny < h && 0 <= nx && nx < w && c[ny][nx] != '#' && d[ny][nx] == INF)
            {
                q.push(P(ny, nx));
                d[ny][nx] = d[p.first][p.second] + 1;
            }
        }
    }
    return d[gy][gx];
}
int main()
{
    cin >> h >> w;
    int count = 0;
    rep(i, h)
    {
        rep(j, w)
        {
            cin >> c[i][j];
            if (c[i][j] == '#')
            {
                count++;
            }
        }
    }
    sx = sy = 0;
    gy = h - 1;
    gx = w - 1;
    if (bfs() == INF)
    {
        cout << -1 << endl;
        return 0;
    }
    else
    {
        int ans = h * w - bfs() - 1 - count;
        cout << ans << endl;
        return 0;
    }
}

Measured memory_bytes: 256
/*  Author:  Hariom_Pandey
    Created: 1/12/2020 5:32:36 PM
*/
#include "bits/stdc++.h"
using namespace std;
#define Hariom_Pandey  ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define All(a)          (a).begin(), (a).end()
#define Sort(x)         sort(All(x))
#define Unique(v)       Sort(v); (v).resize(unique(All(v)) - (v).begin())

int32_t main(){

    Hariom_Pandey
    char letter;
    cin>>letter;
    letter++;
    cout<<letter; 
    
}






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

const double pi = 3.1415926535;
/********************************************************************/
#define M1 1000000007
#define M2 998244353
#define ll long long
#define pll pair<ll,ll>
#define REP(i,a,b) for(ll i=a;i<b;i++)
#define REPR(i,a,b) for(ll i=b-1;i>=a;i--)
#define forr(i,n) for(ll i=0;i<n;i++)
#define F first
#define S second
#define pb push_back
#define DB pop_back
#define mp make_pair
#define MT make_tuple
#define V(a) vector<a>
#define vi vector<ll>
#define endl '\n'
#define ce(ele) cout<<ele<<' '
#define cs(ele) cout<<ele<<'\n'
#define CASE(t) ll t; cin>>t; while(t--)
void FAST() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
}
ll gcd(ll x, ll y) {
	if (x == 0) return y;
	return gcd(y % x, x);
}

ll powM(ll x, ll y, ll m) {
	ll ans = 1, r = 1;
	x %= m;
	while (r > 0 && r <= y)
	{
		if (r & y)
		{
			ans *= x;
			ans %= m;
		}
		r <<= 1;
		x *= x;
		x %= m;
	}
	return ans;
}

map<long long, long long> factorize(long long n) {
	map<long long, long long> ans;
	for (long long i = 2; i * i <= n; i++) {
		while (n % i == 0) {
			ans[i]++;
			n /= i;
		}
	}
	if (n > 1) {
		ans[n]++;
		n = 1;
	}
	return ans;
}
/* **********END OF TEMPLATE*********** */

int main() {
	FAST();
	// ll a;
	string a, b;
	cin >> a >> b;
	ll ans = 0;
	ll n = a.size();
	for (int i = 0; i < n; i++) {
		if (a[i] != b[i])
			ans++;
	}
	cout << ans;
	return 0;
}

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

#define MAX_N 1000

int par[MAX_N];
int rank[MAX_N];

#define MAX_E 1000
struct edge { int u, v, cost; };
edge es[MAX_E];

int V, E;

void init_union_find(int n) {
  for(int i=0; i<n; i++) {
    par[i] = i;
    rank[i] = 0;
  }
}

int find(int x) {
  if(par[x] == x) {
    return x;
  } else {
    return par[x] = find(par[x]);
  }
}

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

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

bool comp(const edge& e1, const edge& e2) {
  return e1.cost < e2.cost;
}

int kruskal() {
  sort(es, es + E, comp);
  init_union_find(V);
  int res = 0;
  for(int i=0; i<E; i++) {
    edge e = es[i];
    if(!same(e.u, e.v)) {
      unite(e.u, e.v);
      res += e.cost;
    }
  }
  return res;
}

int main() {

  while(cin >> V >> E && (V||E)) {
    for(int i=0; i<E; i++) {
      int a, b, c;
      cin >> a >> b >> c;
      es[i].u = a, es[i].v = b, es[i].cost = c;
    }
    cout << kruskal() << endl;
  }
  
  return 0;
}

Measured memory_bytes: 1192
#include<bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(),v.end()
#define puts(i) cout << i << endl
#define INF INT_MAX
#define INFL LLONG_MAX
typedef long long ll;
using namespace std;
int main(){
  string s,t; cin >> s >> t;
  int len = t.size(),n=s.size();

  int ans = INF;

  for(int i=0;i<n-len+1;i++){
    int count = 0;
    for(int j=0;j<len;j++){
      if(s.at(i+j)!=t.at(j)) count++;
    }
    ans = min(count,ans);
  }

  cout << ans << endl;
}


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

int main()
{
  int n;
  cin>>n;
  string s;
  cin>>s;
  if(n%2)
    cout<<"No";
  else
  {
    int x = n/2;
    bool ans = 1;
    for(int i=0; i<x; i++)
    {
      if(s[i] != s[i+x])
      	ans = 0;
    }
    if(ans)
      cout<<"Yes";
    else
      cout<<"No";
  }
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define DAU  ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define PLEC exit(0);
using namespace std;
int n, m, a[1001], b[1001], dp[5000], c, mask, res;
int main() {
    DAU
    cin >> n >> m;
    for (int i = 1; i <= m; ++i) {
        cin >> a[i] >> b[i];
        mask = 0;
        for (int j = 1; j <= b[i]; ++j) {
            cin >> c;
            mask |= (1 << (c - 1));
        }
        b[i] = mask;
    }
    fill(dp, dp + 5000, 1e9);
    dp[0] = 0;
    for (int i = 1; i <= m; ++i)
        for (int mask = 0; mask < (1 << n); ++mask)
            dp[mask | b[i]] = min(dp[mask | b[i]], dp[mask] + a[i]);
    res = dp[(1 << n) - 1];
    if (res == 1e9)
        res = -1;
    cout << res;
    PLEC
}


Measured memory_bytes: 3644
#include <bits/stdc++.h>
//Remove below header file if c++ version greater than 14
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <set>
#include <unordered_set>
#include <unordered_map>

#define ll long long int
#define pb push_back
#define fastIO ios_base::sync_with_stdio(false); cin.tie(nullptr);
#define endl '\n'
#define deb(x) cout << #x << " "<< x << endl;
#define fo(i, n) for(i=0; i<n; i++)
#define Fo(i, k, n) for(i=k; i<n; i++)

using namespace std;
using mii=map<int, int>;
using mll=map<ll, ll>;
using pii=pair<int,int>;
using pll=pair<ll,ll>;
using vi=vector<int>;
using vll=vector<ll>;
const int mod = 1000000007;

ll desc(ll x, ll y)
{
    return x > y;
}

int main() {
    fastIO
    int n, l, i;
    cin >> n >> l;
    vi arr(n, 0);
    fo(i,n)
    {
        arr[i] = l + (i + 1) - 1;
    }
    ll tot = accumulate(arr.begin(), arr.end(), 0);


    ll temp = tot - arr[1];
    int min_abs = INT_MAX;
    for(auto x: arr)
    {
        if(abs(x) < abs(min_abs))
            min_abs = x;
    }
//    for(auto x: arr)
//        cout << x << " ";
//    cout << endl;
    cout << tot - min_abs << endl;
    return 0;
}

Measured memory_bytes: 256