akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
#define rrep(i, n) for (int i = n - 1; i >= 0; i--)
using namespace std;
using Graph = vector<vector<int>>;
typedef long long ll;
typedef pair<int,int> P;

int main(){
    long double l;
    cin >> l;
    cout << fixed << setprecision(10) << (l / 3) * (l / 3) * (l / 3) << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define sf1(n) scanf("%d",&n)
#define sf2(n,q) scanf("%d %d",&n,&q)
#define f first
#define ss second
#define pb push_back
#define lli long long
#define mem(ar,false) memset(ar,false,sizeof(ar))
#define mpr make_pair
#define endl "\n"
#define mod 1000000007
#define inf 9000000000000000000LL
using namespace std;

int ar[200005];
int n;
int dp[100005];
int func(int i)
{
    if(i==n-1)
        return 0;
    if(dp[i]!=-1)
        return dp[i];
    int ret1 = INT_MAX;
    int ret2 = INT_MAX;

    ret1 = abs(ar[i]-ar[i+1]) + func(i+1);
    if(i+2<n)
        ret2 = abs(ar[i]-ar[i+2]) + func(i+2);
    return dp[i] = min(ret1,ret2);
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    mem(dp,-1);
    cin >> n;
    for(int i=0; i<n; i++)
        cin >> ar[i];

    int ans = func(0);

    cout << ans << endl;
    return 0;

}


Measured memory_bytes: 9076
#include<iostream>
#include<string>
using namespace std;
long long a,b;
long long gcd(long long a,long long b)
{
	if(b==0)
		return a;
	return gcd(b,a%b);	
}
int main()
{
	cin>>a>>b;
	long long g=gcd(a,b);
	cout<<a*b/g<<endl;
}

Measured memory_bytes: 256
N, L = map(int, input().split())

apples = [i for i in range(L, L+N)]
abs_apples = [abs(i) for i in apples]
eaten_apple_taste = apples[abs_apples.index(min(abs_apples))]

taste_N = sum(apples)
ans = taste_N - eaten_apple_taste
print(ans)


Measured memory_bytes: 3060
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace _0027
{
    public class Program

    {
        public static void Main(string[] args)
        {
            while (true)
            {
                int[] items = RIntAr();
                if (items.Sum() == 0) break;
                Console.WriteLine(new DateTime(2004,items[0],items[1]).DayOfWeek);
            }
      
        }

        static string RSt() { return Console.ReadLine(); }
        static int RInt() { return int.Parse(Console.ReadLine().Trim()); }
        static long RLong() { return long.Parse(Console.ReadLine().Trim()); }
        static double RDouble() { return double.Parse(Console.ReadLine()); }
        static string[] RStAr(char sep = ' ') { return Console.ReadLine().Trim().Split(sep); }
        static int[] RIntAr(char sep = ' ') { return Array.ConvertAll(Console.ReadLine().Trim().Split(sep), e => int.Parse(e)); }
        static long[] RLongAr(char sep = ' ') { return Array.ConvertAll(Console.ReadLine().Trim().Split(sep), e => long.Parse(e)); }
        static double[] RDoubleAr(char sep = ' ') { return Array.ConvertAll(Console.ReadLine().Trim().Split(sep), e => double.Parse(e)); }
        static string WAr(int[] array, string sep = " ") { return String.Join(sep, array.Select(x => x.ToString()).ToArray()); }
        static string WAr(double[] array, string sep = " ") { return String.Join(sep, array.Select(x => x.ToString()).ToArray()); }
        static string WAr(long[] array, string sep = " ") { return String.Join(sep, array.Select(x => x.ToString()).ToArray()); }
    }

}



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

using namespace std;
using ll = long long int;

// to format a document: ctrl + K -> ctrl + D

int main() {
    int N, M;
    cin >> N >> M;
    vector<int> L(M), R(M);
    for (int i = 0; i < M; i++) {
        cin >> L[i] >> R[i];
    }

    sort(L.begin(), L.end(), greater<int>());
    sort(R.begin(), R.end());

    if (R[0] >= L[0])
        cout << R[0] - L[0] + 1 << endl;
    else
        cout << 0 << endl;

    return 0;
}


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

#define watch(x) cerr << (#x) << ": " << (x) << endl

double solve(int n, int k) {
    double ret = 0.0;
    for(int die = 1; die <= n; ++die) {
        double cur = 1.0;
        int d = die;
        while(d < k) {
            d *= 2;
            cur /= 2;
        }
        ret += cur;
    }
    ret /= n;
    return ret;
}

int32_t main() {

    int n, k; cin >> n >> k;

    double ans = solve(n, k);

    cout << setprecision(16) << ans << endl;
    
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define db(x) cerr<<#x<<" = "<<x<<endl;
using namespace std;
int main(){
	string s;
	int a;
	cin>>a>>s;
	if(a>=3200){
		cout<<s;
	}else{
		cout<<"red";
	}
	return 0;
}



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

using namespace std;

typedef double D;
typedef long long int LL;

#define st first
#define nd second
#define pb push_back
#define PLL pair <LL, LL>
#define PII pair <int, int>

const int N = 1e6 + 7;
const int MX = 1e9 + 7;
const LL INF = 1e18 + 9LL;

LL a, b, c, d;
LL nwd(LL x, LL y){
	if(y == 0)
		return x;
	return nwd(y, x%y);
}

void solve(){
	scanf("%lld %lld %lld %lld", &a, &b, &c, &d);
	if(a < b || d < b){
		puts("No");
		return;
	}

	LL g = nwd(b, d);
	
	LL x = c%g;
	LL y = a%g;
	LL add = (y - x + g)%g;
	
	if(add == 0)
		add = g;

	if(c + add < b)
		puts("No");
	else
		puts("Yes");
}

int main(){
	int quest;
	scanf("%d", &quest);
	
	while(quest--)
		solve();
	return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(final String[] args) {
        Scanner sc = new Scanner(System.in);
        String a = sc.next();
        String b = sc.next();
        if (a.length() > b.length()) {
            System.out.println("GREATER");
            return;
        } else if (a.length() < b.length()) {
            System.out.println("LESS");
            return;
        }

        int p = 0;
        while (p < a.length()) {
            if (a.charAt(p) > b.charAt(p)) {
                System.out.println("GREATER");
                return;
            } else if (a.charAt(p) < b.charAt(p)) {
                System.out.println("LESS");
                return;
            }
            p++;
        }
        System.out.println("EQUAL");
    }
}

Measured memory_bytes: 35644
#include <stdio.h>

int main(void)
{
	int r, c, i, j, x, a[101][101];
	
	for(i = 0; i < 101; i++){
		for(j = 0; j < 101; j++){
			a[i][j] = 0;
		}
	}
	
	scanf("%d%d%*c", &r, &c);
	for(i = 0; i < r; i++){
		for(j = 0; j < c; j++){
			scanf("%d", &x);
			a[i][j] = x;
		}
	}
	
	for(i = 0; i < r; i++){
		for(j = 0; j < c; j++){
			printf("%d ", a[i][j]);
			a[i][100] += a[i][j];
			a[100][j] += a[i][j];
		}
		printf("%d\n", a[i][100]);
	}
	for(j = 0; j < c; j++){
		printf("%d ", a[100][j]);
		a[100][100] += a[100][j];
	}
	printf("%d\n", a[100][100]);
	
	return(0);
}



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

int main(void){
  int point='A',cnt=0,tmp;
  string str;
  cin >> str;

  for(int i=0;i<str.size();i++){
    tmp=str[i];
    if(tmp>point) point=tmp;
    else{
      cnt++;
      point=tmp;
    }
  }
  cout << cnt << endl;
}

Measured memory_bytes: 3212
#include <stdio.h>

int main(){
    int d, x[11], r; //x[i](<=i+2000)  x_i+1 = r*x_i -d

//input
    scanf("%d", &r);
    scanf("%d", &d);
    scanf("%d", &x[0]);

//calc    
    for(int i=1; i<=10; i++){
        x[i] = x[i-1]*r -d;
    }

//output
    for(int i=1; i<=10; i++){
        printf("%d\n", x[i]);
    }
    
    return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <algorithm>
#include <bitset>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <cctype>
#include <assert.h>
#include <stdlib.h>
#include <stdio.h>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <limits>
#include <map>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#include <math.h>
using namespace std;

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

   cout<<s[0]<<s.size()-2<<s[s.size()-1]<<endl;
}

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

int main()
{
	long long N, K;
	cin >> N >> K;
	vector<int> A( N );
	for( int i = 0; i < N; i++ ) {
		cin >> A[i];
	}

	int l = 0;
	int c = 1;
	int v = 1;
	vector<int> a( N + 1, -1 );
	vector<int> s;
	while( a[v] < 0 ) {
		a[v] = s.size();
		s.push_back( v );
		v = A[v - 1];
	}
	c = s.size() - a[v];
	l = a[v];
	int ans;
	if( K < l ) ans = s[K];
	else ans = s[l + (K - l) % c];

	cout << ans << endl;
}


Measured memory_bytes: 5884
#include <algorithm>
#include <iostream>
#include <vector>
#include <map>
using namespace std;

map<long long, int> prime_factorize(long long n) {
    map<long long, int> res;
    for (long long p = 2; p * p <= n; ++p) {
        while (n % p == 0) { ++res[p]; n /= p; }
    }
    if (n != 1) res[n] = 1;
    return res;
}

int main() {
    int n; cin >> n;
    vector<int> cnt(n + 1);
    for (int i = 1; i <= n; i++) {
        for (auto &p: prime_factorize(i)) cnt[p.first] += p.second;
    }
    const int M = 100;
    vector<int> leq(M + 1);
    for (int i = 1; i <= n; i++) leq[cnt[i]]++;
    for (int i = M - 1; i >= 0; i--) leq[i] += leq[i + 1];
    int ans = 0;
    ans += leq[74];
    ans += leq[24] * (leq[2] - 1);
    ans += leq[14] * (leq[4] - 1);
    ans += leq[4] * (leq[4] - 1) / 2 * (leq[2] - 2);
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
// ITP1_5_A:   Print a Rectangle
#include <stdio.h>
#include <ctype.h>
#include <stdlib.h>

int main()
{
	int H, W;
	int h, w;

	while (1) {
		scanf("%d%d", &H, &W);
		if (H == 0 && W == 0) break;
		for (h = 0; h < H; h++) {
			for (w = 0; w < W; w++) putchar('#');
			putchar('\n');
		}
		putchar('\n');
	}
	return 0;
}


Measured memory_bytes: 2044
#DP A
import sys
N = int(sys.stdin.readline())
H = list(map(int, sys.stdin.readline().split()))

dp = [0 for _ in range(N)]
dp[1]= abs(H[1]-H[0])
#print(H)
#print(dp)

for i in range(2, N):
    dp[i] = min(abs(H[i]-H[i-2])+dp[i-2], abs(H[i]-H[i-1])+dp[i-1])
    #print(dp)

print(dp[-1])

Measured memory_bytes: 14016
a=input()
b=[]
for i in range(len(a)):
  if a[i]=="A" or a[i]=="C" or a[i]=="G" or a[i]=="T":
    b+=[1]
  else:
    b+=[0]

ans=""
m=""
for i in range(len(a)):
  if b[i]==0:
    continue
  for j in range(i,len(a)):
    if b[j]==0:
      break
    m+=a[j]
  if len(ans)<len(m):
    ans=m
  m=""
  
print(len(ans))

Measured memory_bytes: 3064
import java.util.*;
import java.io.*;
class Main{
  public static void main(String args[])throws IOException{
    int a = readI(),b=readI(),c=readI();
    if(a<=b*c){
      pl("Yes");
    }else{
      pl("No");
    }
  }

  static final BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
  public static void pr(String str){
    System.out.print(str);
  }
  public static void pl(String str){
    System.out.println(str);
  }
  public static String read(){
    try{
      return ctos((char)br.read());
    }catch(IOException e){
      e.printStackTrace();
      return "";
    }
  }
  public static char readC(){
    try{
      return (char)br.read();
    }catch(IOException e){
      e.printStackTrace();
      return (char)-1;
    }
  }
  public static String readL(){
    try{
      return br.readLine();
    }catch(IOException e){
      e.printStackTrace();
      return "";
    }
  }
  public static String readS(){
    StringBuilder sb = new StringBuilder();
    while(true){
      try{
        int k = br.read();
        if(k==-1||(char)k==' '||(char)k=='\n'){break;}
        sb.append((char)k);
      }catch(IOException e){
        e.printStackTrace();
      }
    }
    return sb.toString();
  }
  public static int readI(){
    return stoi(readS());
  }
  public static long readLong(){
    return stol(readS());
  }
  public static long stol(String s){
    return Long.parseLong(s);
  }
  public static String[] readSs(){
    return readL().split(" ");
  }
  public static int[] readIs(){
    return stoi(readSs());
  }
  public static int stoi(String s){
    return Integer.parseInt(s);
  }
  public static int[] stoi(String s[]){
    int a[]=new int[s.length];
    for(int i=0;i<s.length;i++){
      a[i]=stoi(s[i]);
    }
    return a;
  }
  public static String itos(int i){
    return String.valueOf(i);
  }
  public static String[] itos(int[] a){
    String s[]=new String[a.length];
    for(int i=0;i<a.length;i++){
      s[i]=itos(a[i]);
    }
    return s;
  }
  public static String ctos(char c){
    return String.valueOf(c);
  }
  public static String cstos(char[] c){
    return new String(c);
  }
  public static char stoc(String s){
    return s.charAt(0);
  }
  public static char[] stocs(String s){
    return s.toCharArray();
  }
}


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

int main(){
    long n,m;
    cin >> n >> m;
    long sum=0;
    long temp;
    rep(i,m) {
        cin >> temp;
        sum+=temp;
    }
    if(sum > n) cout << "-1" << endl;
    else cout << n-sum <<endl;
}

Measured memory_bytes: 3632
H, W = map(int, input().split())
A = [input() for _ in range(H)]
ans = [[None]*(W+2) for _ in range(H+2)]
for i in range(W+2):
    ans[0][i] = "#"
    ans[H+1][i] = "#"
for i in range(H+2):
    ans[i][0] = "#"
    ans[i][W+1] ="#"

for i in range(H):
    for j in range(W):
        ans[i+1][j+1] = A[i][j]

for i in range(H+2):
    ans[i] = "".join(ans[i])
for a in ans:
    print(a)

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

using ll = int64_t;
#define int ll

#define FOR(i, a, b) for (int i = int(a); i < int(b); i++)
#define REP(i, b) FOR(i, 0, b)
#define MP make_pair
#define PB push_back
#define EB emplace_back
#define ALL(x) x.begin(), x.end()

using pi = pair<int, int>;
using vi = vector<int>;
using ld = long double;

template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
  os << "(" << p.first << "," << p.second << ")";
  return os;
}

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

ll read() {
  ll i;
  scanf("%" SCNd64, &i);
  return i;
}

void printSpace() { printf(" "); }

void printEoln() { printf("\n"); }

void print(ll x, int suc = 1) {
  printf("%" PRId64, x);
  if (suc == 1)
    printEoln();
  if (suc == 2)
    printSpace();
}

string readString() {
  static char buf[3341000];
  scanf("%s", buf);
  return string(buf);
}

char *readCharArray() {
  static char buf[3341000];
  static int bufUsed = 0;
  char *ret = buf + bufUsed;
  scanf("%s", ret);
  bufUsed += strlen(ret) + 1;
  return ret;
}

template <class T, class U> void chmax(T &a, U b) {
  if (a < b)
    a = b;
}

template <class T, class U> void chmin(T &a, U b) {
  if (b < a)
    a = b;
}

template <class T> T Sq(const T &t) { return t * t; }

const int mod = 1e9 + 7;

signed main() {
  int n, a;
  std::cin >> n >> a;
  print((n * n) - a);
}


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

struct Dice{
  Dice(vector<int>& dice) : dice_(dice) {
    east_.push_back(4);    east_.push_back(2);
    east_.push_back(1);    east_.push_back(6);
    east_.push_back(5);    east_.push_back(3);
    north_.push_back(2);    north_.push_back(6);
    north_.push_back(3);    north_.push_back(4);
    north_.push_back(1);    north_.push_back(5);
    south_.push_back(5);    south_.push_back(1);
    south_.push_back(3);    south_.push_back(4);
    south_.push_back(6);    south_.push_back(2);
    west_.push_back(3);    west_.push_back(2);
    west_.push_back(6);    west_.push_back(1);
    west_.push_back(5);    west_.push_back(4);
  }

  void East(){
    vector<int> tmp(dice_);
    for(int i=0; i<6; i++)
      dice_[i] = tmp[east_[i]-1];
  }

  void North(){
    vector<int> tmp(dice_);
    for(int i=0; i<6; i++)
      dice_[i] = tmp[north_[i]-1];
  }

  void South(){
    vector<int> tmp(dice_);
    for(int i=0; i<6; i++)
      dice_[i] = tmp[south_[i]-1];
  }

  void West(){
    vector<int> tmp(dice_);
    for(int i=0; i<6; i++)
      dice_[i] = tmp[west_[i]-1];
  }

  void Ans(int x, int y){
    vector<int> tmpv;
    tmpv.push_back(1);    tmpv.push_back(2);
    tmpv.push_back(3);    tmpv.push_back(4);
    tmpv.push_back(5);    tmpv.push_back(6);
    Dice tmp(tmpv);

    if(x == 2)
      tmp.North();
    else if(x == 5)
      tmp.South();
    else if(x == 3)
      tmp.West();
    else if(x == 4)
      tmp.East();
    else if(x == 6){
      tmp.North();
      tmp.North();
    }
    while(tmp.dice_[1] != y || tmp.dice_[0] != x){
      tmp.East();
      tmp.South();
      tmp.West();
    }

    vector<int> xx = dice_;

    for(int i=0; i<6; i++){
      dice_[i] = xx[tmp.dice_[i]-1];
    }
  }

  bool operator==(const Dice& l){
    if(this->dice_ == l.dice_)
      return true;
    else
      return false;
  }

  void Print(){
    for(int i=0; i<6; i++)
      cout << dice_[i] << " ";
    cout << endl;
  }

  vector<int> dice_;
  vector<int> east_;
  vector<int> north_;
  vector<int> south_;
  vector<int> west_;
};

int main(){
  int n;
  cin >> n;
  vector<vector<int> > dices(n, vector<int>(6));
  vector<Dice> d;
  for(int i=0; i<n; i++){
    for(int j=0; j<6; j++)
      cin >> dices[i][j];
    Dice tmp(dices[i]);
    d.push_back(tmp);
  }
  
  bool generalFlag = true;
  for(int xx=1; xx<n; xx++){
    for(int xxm=0; xxm<xx; xxm++){
      bool flag = false;
      for(int i=1; i<=6; i++){
	for(int j=1; j<=6; j++){
	  if(i+j != 7 && i != j){
	    d[xx].dice_ = dices[xx];
	    d[xx].Ans(i, j);
	    if(d[xxm] == d[xx])
	      flag = true;
	  }
	  if(flag)
	    break;
	}
	if(flag)
	  break;
      }
      if(flag){
	generalFlag = false;
	break;
      }
    }
    if(!generalFlag)
      break;
  }
  if(generalFlag)
    cout << "Yes\n";
  else
    cout << "No\n";

  return 0;
}

Measured memory_bytes: 1256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int a = scan.nextInt();
		int b = scan.nextInt();
		int c = scan.nextInt();
		int d = scan.nextInt();
		String message = "No";
		int a_b = a - b;
		int a_c = a - c;
		int b_c = b - c;
		if(a_b < 0) {
			a_b = a_b * (-1);
		}
		if(a_c < 0) {
			a_c = a_c * (-1);
		}
		if(b_c < 0) {
			b_c = b_c * (-1);
		}
		if(a_c <= d) {
			message = "Yes";
		} else if(a_b <= d && b_c <= d) {
			message = "Yes";
		}
		System.out.println(message);
	}
}

Measured memory_bytes: 21972
//c++ -std=gnu++14 a.cpp
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <iostream>
#include <istream>
#include <iterator>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <tuple>
#include <iomanip>
#include <climits>
#include <fstream>
#include <random>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
//typedef pair<ll, ll> P;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define revrep(i, n) for(int i = (n)-1; i >= 0; i--)
#define pb push_back
#define f first
#define s second
#define chmin(x, y) x = min(x, y);
#define chmax(x, y) x = max(x, y);
#define len(x) ((int)(x).size())

//const ll INFL = LLONG_MAX;//10^18 = 2^60
const ll INFL = 1LL<<60;
//const int INF = INT_MAX;
const int INF = 1 << 30;//10^9
const ll MOD = 1000000007;
//const ll MOD = 998244353;
double EPS = 1e-10;

vector<ll> dy = {0, 1, 0, -1, 1, 1, -1, -1, 0};
vector<ll> dx = {1, 0, -1, 0, 1, -1, 1, -1, 0};

void pres(double A){printf("%.9lf\n", A);}
void BinarySay(ll x, ll y = 60){rep(i, y) cout << (x>>(y-1-i) & 1); cout << endl;}
ll cnt_bit(ll x){return __builtin_popcountll(x);}

ll pow_long(ll x, ll k){
  ll res = 1;
  while(k > 0){
    if(k % 2) res *= x;
    x *= x; k /= 2;
  }
  return res;
}

ll pow_mod(ll x, ll k){
  ll res = 1;
  while(k > 0){
    if(k % 2){
      res *= x; res %= MOD;
    }
    x *= x; x %= MOD;
    k /= 2;
  }
  return res;
}

ll inverse(ll x){return pow_mod(x, MOD - 2);};

ll gcd(ll a, ll b){
    if(b == 0) return a;
    return gcd(b, a % b);
}

ll lcm(ll x, ll y){
  ll res = x / gcd(x, y);
  res *= y;
  return res;
};


//コンビネーション
const int MAXcomb = 2000010;
ll fac[MAXcomb], finv[MAXcomb], inv[MAXcomb];
//facはn!,finvは1/n!
//invは逆元
void COMinit(){
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for(int i = 2; i < MAXcomb; i++){
        fac[i] = fac[i-1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD/i) % MOD;
        finv[i] = finv[i-1] * inv[i] % MOD;
    }
}
ll comb(int n, int k){
    if(n < k) return 0;
    if(n < 0 || k < 0) return 0;
    return fac[n] * finv[k] % MOD * finv[n-k] % MOD;
}



ll disit(ll s, ll base = 10){
  ll res = 0;
  while(s){
    res++;
    s /= base;
  }
  return res;
}

void solve(){
  string S;
  cin >> S;
  int cnt = 0;
  rep(i, len(S)){
    if(S[i] == 'R'){
      cnt += 1;
    }
  }
  if(cnt == 2 && S == "RSR"){
    cnt = 1;
  }
  cout << cnt << endl;
}

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


Measured memory_bytes: 3528
import sys
stdin = sys.stdin

def li(): return map(int, stdin.readline().split())
def li_(): return map(lambda x: int(x)-1, stdin.readline().split())
def lf(): return map(float, stdin.readline().split())
def ls(): return stdin.readline().split()
def ns(): return stdin.readline().rstrip()
def lc(): return list(ns())
def ni(): return int(stdin.readline())
def nf(): return float(stdin.readline())

from collections import Counter

s = ns()
t = ns()

cnt_s = Counter(s)
cnt_t = Counter(t)

val_s = sorted(list(cnt_s.values()))
val_t = sorted(list(cnt_t.values()))

if val_s == val_t:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 4144
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <string>
#include <cstring>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <cmath>
#include <iomanip>
#include <cassert>
#include <bitset>
using namespace std;

typedef pair<int, int> P;
#define rep(i, n) for (int i=0; i<(n); i++)
#define all(c) (c).begin(), (c).end()
#define uniq(c) c.erase(unique(all(c)), (c).end())
#define index(xs, x) (int)(lower_bound(all(xs), x) - xs.begin())
#define _1 first
#define _2 second
#define pb push_back
#define INF 1145141919
#define MOD 1000000007

string S;
bool used[256];

void dfs(string T) {
  if (T+'~' < S) return;
  if (T > S) {
    cout << T << "\n";
    exit(0);
  }
  for (char x='a'; x<='z'; x++) if (!used[x]) {
    used[x] = true;
    dfs(T+x);
    used[x] = false;
  }
}

signed main() {
  ios::sync_with_stdio(false); cin.tie(0);
  cin >> S;
  dfs("");
  cout << -1 << "\n";
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
vector<pair<int, int>> directions = {{1, 0}, {0, 1}, {-1, 0}, {0, -1}};

int bfs(const vector<string> &table, int x, int y){
    int H = table.size(), W = table[0].size();
    queue<pair<int, int>> que;
    vector<vector<int>> dist(H, vector<int>(W, -1));
    que.push({x, y});
    int ret = 0;
    dist[y][x] = 0;
    while(!que.empty()){
        int nx = que.front().first, ny = que.front().second;
        que.pop();
        ret = max(ret, dist[ny][nx]);
        for (int i = 0; i < 4; i++)
        {
            int dx = directions[i].first, dy = directions[i].second;

            if (!(0 <= nx + dx && nx + dx < W && 0 <= ny + dy && ny + dy < H)) continue;
            else if (table[ny + dy][nx + dx] == '#') continue;
            if(dist[ny + dy][nx + dx] == -1){
                dist[ny + dy][nx + dx] = dist[ny][nx] + 1;
                que.push({nx + dx, ny + dy});
            }
        }
    }
    return ret;
}

int main() {
    int H, W;
    vector<string> table;
    cin >> H >> W;
    for (int i = 0; i < H; i++){
        string s;cin >> s;
        table.push_back(s);
    }
    int ans = 0;
    for (int x = 0; x < W; x++) for (int y = 0; y < H; y++) {
        if (table[y][x] != '#') ans = max(bfs(table, x, y), ans);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3484
#include<bits/stdc++.h>
using namespace std;
#define sync ios_base::sync_with_stdio(false), cin.tie(NULL)
#define F first
#define S second
#define pb emplace_back
#define mt make_tuple
#define gcd __gcd
#define PI 3.141592653589
// Input
#define in(a) scanf("%d",&a)
#define in2(a,b) scanf("%d%d",&a,&b)
#define in3(a,b,c) scanf("%d%d%d",&a,&b,&c)
#define llin(a) cin >> a
#define inl(a) scanf("%lld",&a)
#define read(v,i,n) for(i=0;i<n;i++)in(v[i])
#define twod(mat,i,j,n,m) rep(i,n){rep(j,m)in(mat[i][j]);}
#define sc(ch) scanf("%c",&ch)
#define sstr(str) scanf("%s",str)
// Output
#define pr(a) printf("%d ",a)
#define pr2(a,b) printf("%d %d\n",a,b)
#define pr3(a,b,c) printf("%d %d %d\n",a,b,c)
#define out(a) printf("%d\n",a)
#define outl(a) printf("%lld\n",a)
#define llpr(a) cout << a << " "
#define llout(a) cout << a << "\n"
#define yes printf("YES\n")
#define no printf("NO\n")
#define lin printf("\n")
// Iterator
#define lp(i,a,b) for(i=a;i<b;i++)
#define rep(i,n) for(i=0;i<n;i++)
#define all(vec) vec.begin(),vec.end()
#define lower(v,k) lower_bound(v.begin(),v.end(),k)-v.begin()
#define upper(v,k) upper_bound(v.begin(),v.end(),k)-v.begin()
#define tf(mytuple) get<0>(mytuple)
#define ts(mytuple) get<1>(mytuple)
#define tt(mytuple) get<2>(mytuple)
// Debug
#define dbg(v,i,n) for(i=0;i<n;i++)pr(v[i]); lin
#define what(x) cerr << #x << " : " << x << "\n"
#define ck printf("continue\n")
#define debug(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args)
{
	cerr << *it << " = " << a << "\n";
	err(++it, args...);
}
// Data Type
#define ll long long int
#define ii pair<int,int>
#define pli pair<ll,int>
#define triple tuple<int,int,int>
#define vi vector<int>
#define vii vector<pair<int,int> >
#define vvi vector<vector<int> >
#define viii vector<pair<pair<int,int>,int> >
#define vvii vector<vector<pair<int,int> > >
#define M 1000000007
#define N 500005  //check the limits, man
int main()
{
    int n,d,i,q;
    in2(n,d);
    vi v(n);
    read(v,i,n);
    vi rem(n+1,0);
    vi cant(n+1,0);
    rem[0]=d;
    rep(i,n)
    {
        if(v[i]<=rem[i])
            rem[i+1]=rem[i]-v[i];
        else if(v[i]<2*rem[i])
            rem[i+1]=abs(rem[i]-v[i]);
        else
            rem[i+1]=rem[i];
    }
    if(rem[n]>0)
    {
        in(q);
        while(q--)
            in(i),yes;
        exit(0);
    }
    cant[n]=1;
    for(i=n-1;i>=0;i--)
    {
        if(v[i]<2*cant[i+1])
            cant[i]=cant[i+1]+v[i];
        else
            cant[i]=cant[i+1];
    }
    in(q);
    while(q--)
    {
        in(i);
        i--;
        if(rem[i]>=cant[i+1])
            yes;
        else
            no;
    }
}



Measured memory_bytes: 7808
#include<stdio.h>
int W, A, B;
int main(){
  scanf("%d%d%d", &W, &A, &B);
  if(A+W<B){
    printf("%d\n", B-A-W);
  }else if(B+W<A){
    printf("%d\n", A-B-W);
  }else{
    printf("0\n");
  }
}


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

from collections import deque

def Topologicalsort(n):     #n??????????????°
    start=deque()
    for i in xrange(n):
        if indeg[i]==0 :
            start.append(i)
    while len(start)>0:
        i=start.popleft()
        ans.append(i)
        for j in g[i]:
            indeg[j]-=1
            if indeg[j]==0:
                start.append(j)
    return ans

v,e=map(int,raw_input().split())
g=[[]for i in xrange(v)]
indeg=[0]*v
ans=[]
for i in xrange(e):
    s,t=map(int,raw_input().split())
    g[s].append(t)
    indeg[t]+=1
    
ans=Topologicalsort(v)
for i in ans:
    print(i)

Measured memory_bytes: 9028
from fractions import gcd

n = int(input())
a = list(map(int, input().split()))

fgcd, ftmp = [], a[0]
for i in a:
    ftmp = gcd(ftmp,i)
    fgcd.append(ftmp)

bgcd, btmp = [], a[-1]
for i in a[::-1]:
    btmp = gcd(btmp, i)
    bgcd.append(btmp)
bgcd=bgcd[::-1]

egcd = [bgcd[1]] + [0] * (n - 2) + [fgcd[n - 2]]
for i in range(1, n - 1):
    egcd[i] = gcd(fgcd[i - 1], bgcd[i + 1])
print(max(egcd))


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

int main(){
  int N;
  cin>>N;
  vector<int64_t> H(N);
  for(int i=0;i<N;++i){
    cin>>H.at(i);
  }

  bool ans=true;
  vector<int64_t> H_minus(N);
  
  for(int i=0;i<N;++i){
    if(i==0){
      H_minus.at(i)=H.at(i)-1;
    }
    else{
      if(H.at(i)<H_minus.at(i-1)){
        ans=false;
        break;
      }
      else if(H.at(i)==H_minus.at(i-1)){
        H_minus.at(i)=H_minus.at(i-1);
      }
      else{
        H_minus.at(i)=H.at(i)-1;
      }
    }
  }
  
  if(ans){cout<<"Yes"<<endl;}
  else{cout<<"No"<<endl;}
}

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

typedef long long ll;

int n;
ll p, a[10005];
string s;
vector<array<ll, 2>> v;
int mod = 998244353;
int main(){
	cin >> n;
	v.resize(n);
	for(int i=0;i<n;++i){
		cin >> v[i][0] >> v[i][1] ;
	}
	sort(v.begin(), v.end());
	vector<ll>dp(n+1, 0);
	dp[n] = 1;
	vector<pair<ll,ll>> p;
	p.push_back({n, 2e9});
	for(int i = n - 1; i >= 0;--i){
		while(v[i][0]+v[i][1] > p.back().second){
			p.pop_back();
		}

		int take = p.back().first;
		dp[i] = dp[take];
		dp[i] += dp[i+1];
		dp[i] %= mod;
		p.push_back({i, v[i][0]});
	}
	dp[0] += mod;
	dp[0] = dp[0]%mod;
	cout << dp[0];
}


Measured memory_bytes: 7156
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.util.TreeSet;

public class Main {

    public static void main(String[] args) throws IOException {
        new Main().solve();
    }

    private void solve() throws IOException {
        BufferedReader f = new BufferedReader(new InputStreamReader(System.in));
        PrintWriter out = new PrintWriter(System.out);
        StringTokenizer tokenizer = new StringTokenizer(f.readLine());
        int x = Integer.parseInt(tokenizer.nextToken());
        int n = Integer.parseInt(tokenizer.nextToken());
        tokenizer = new StringTokenizer(f.readLine());
        int minNum = Integer.MAX_VALUE;
        int minDiff = Integer.MAX_VALUE;
        TreeSet<Integer> treeSet = new TreeSet<Integer>();
        for (int i = 0; i < n; i++) {
            treeSet.add(Integer.parseInt(tokenizer.nextToken()));
        }
        for (int i = 0; i <= 101; i++) {
            if (!treeSet.contains(i) && Math.abs(x - i) < minDiff) {
                minNum = i;
                minDiff = Math.abs(x - i);
            }
        }

        System.out.println(minNum);
    }
}


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

int main(){
	int n, A, V;
	cin >> n;
	for(int i = 0; i < n; i++){
		int a, v;
		cin >> a >> v;
		if( i == 0 ){
			A = a; V = v;
		}else{
			if( V < v || ( V == v && a < A) ){
				V = v; A = a;
			}
		}
	}
	cout << A << " " << V << endl;
}

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



int main() {
    ios_base::sync_with_stdio(false);
//   freopen("a.in", "r", stdin);

    int n;
    cin >> n;
    int k;
    cin >> k;
    vector<long long> pref1;
    vector<long long> pref2;
    vector<int> V(n);
    for(int i = 0;i < n;++i) cin >> V[i];

    int cnt = INT_MAX;
    if(V[0] >= 0) cnt = -1;
    else{
        for(int i = 1;i < n;++i){
            if(V[i - 1] < 0 && V[i] >= 0) cnt = i;
        }
    }
    if(cnt == -1){
        int pos = 0;
        long long ans = 0;
        for(int i = 0;i < k;++i){
            ans = ans + V[i] - pos;
            pos = V[i];
        }
        cout << ans;
        return 0;
    }
    else{
        if(cnt == INT_MAX){
            int pos = 0;
            long long ans = 0;
            for(int i = n - 1;i >= n - k;i--){
                ans = ans + pos - V[i];
                pos = V[i];
            }
            cout << ans;
            return 0;
        }

        pref1.push_back(V[cnt]);
        pref2.push_back(-V[cnt - 1]);
        for(int i = cnt + 1;i < n;++i){
            pref1.push_back(pref1[(int)pref1.size() - 1] + V[i] - V[i - 1]);
        }
        for(int i = cnt - 2;i >= 0;i--){
            pref2.push_back(pref2[(int)pref2.size() - 1] + V[i + 1] - V[i]);
        }

        long long ans = LLONG_MAX;
        long long cur = 0;
        for(int l = (int)pref1.size() - 1;l >= 0;l--){
            if(l + 1 > k) continue;
            else{
                int r = k - l - 1;
                if(r == 0) cur = pref1[l];
                if(r > (int)pref2.size()) continue;
                else{
                    cur = min(pref1[l] + 2 * pref2[r - 1], pref1[l] * 2 + pref2[r - 1]);
                    ans = min(ans, cur);
                }
            }
        }
        cout << ans;
    }

//    cout << "\n" << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
    return 0;
}


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

//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>

#define sf scanf
#define pf printf
#define pb push_back
#define mp make_pair
#define IN freopen("input.txt","r",stdin)
#define OUT freopen("output.txt","w",stdout)
#define FOR(i,a,b) for(i=a ; i<=b ; i++)
#define DBG pf("Hi\n")
#define INF 1000000000
#define i64 long long int
#define eps (1e-8)
#define xx first
#define yy second
#define ln 17
#define off 2

//using namespace __gnu_pbds;
using namespace std ;

typedef pair<int, int> pi ;
//typedef tree< pi, null_type, less<pi>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;

const i64 mod = 1000000007LL ;

#define maxn 500005

/*
     *os.find_by_order(k) -> returns the k'th smallest element (indexing starts from 0)
      os.order_of_key(v)  -> returns how many elements are strictly smaller than v
*/

char s[100005] ;

int main()
{
    int ans = 0 , a = 0 , b = 0 , ab = 0 ;

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


    for(int i=0 ; i<n ; i++)
    {
        scanf("%s",s) ;
        int m = strlen(s) ;
        for(int j=1 ; j<m ; j++) if( s[j-1]=='A' && s[j]=='B' ) ans++ ;
        if( s[0]=='B' && s[m-1]=='A' ) ab++ ;
        else if( s[0]=='B' ) b++ ;
        else if( s[m-1]=='A' ) a++ ;
    }

    if( ab > 0 )
    {
        ans += (ab-1) ;
        if( a > 0 ) ans++ , a-- ;
        if( b > 0 ) ans++ , b-- ;
    }

    ans += min(a,b) ;

    printf("%d\n",ans) ;

    return 0 ;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <numeric> // accumulate(v.begin(), v.end(), 0)                                                         
 
using namespace std;
#define ll long long
 
bool al[26];
 
int check(int n){
  for(int i=n; i<26; i++){
    if(!al[i])
      return i;
  }
  return -1;
}
 
int main(){
  string S;
  cin >> S;
  for(int i=0; i<S.size(); i++){
    al[S[i] - 'a'] = true;
  }
 
  int n = 0;
  string O;
  while(al[n] && n < 26){
    n++;
  }
  if(n == 26){
    int m = 25;
    while(check(S[m] - 'a') == -1 && m > -1){
      al[S[m] - 'a'] = false;
      m--;
    }
    if(m == -1){
      O = "-1";
    } else {
      O = S.substr(0, m) + (char)('a' + check(S[m] - 'a'));
    }
  } else {
    O = S + (char)('a' + n);
  }
 
  cout << O << endl;
 
  // for(int i=0; i<26; i++)                                                                                    
  //   cout << al[i] << ' ';                                                                                    
  // cout << endl;                                                                                              
 
  return 0;
}

Measured memory_bytes: 888
fun main(args: Array<String>) {
    val n = readLine()!!.toInt()
    val a = readLine()!!.split(' ').map(String::toInt).sorted()
    var j = 0
    var ans = true
    var levels = 0
    while (j < n) {
        var nj = j
        while (nj < n && a[nj] == a[j]) nj++
        val l = nj - j
        if (j == 0 && l > 2 || j > 0 && nj != n && l < 2 || nj < n && a[nj] != a[j] + 1) {
            ans = false
            break
        }
        j = nj
        levels++
    }
    if (ans) {
        if (a[0] == a[1] && levels != a[0]) ans = false
        if (a[0] != a[1] && levels != a[0] + 1) ans = false
    }
    println(if (ans) "Possible" else "Impossible")
}

Measured memory_bytes: 22776
#include<iostream>
#include<algorithm>
#include<sstream>
#include<stack>
#include<cmath>
#include<vector>
#include<iomanip>
#include<map>
#include<set>
#include<queue>
#include<deque>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(i,n) for(int i = 0; i < n;i++)
#define req(i,n) for(int i = 1;i <= n;i++)
#define rrep(i,n) for(int i = n -1;i >= 0;i--)
#define ALL(a)  (a).begin(),(a).end()
#define fix  fixed << setprecision(10)
const int MOD = 1000000007;
const ll INF = (1LL << 60);
string t,u; ll n, m,k,q, ans, sum = 0, r,s,p;
bool f = true;
int main() {
    cin >> n;
    req(i, n) {
        sum += i;
        if (sum >= n) {
            req(j, i) {
                if (sum - n == j) continue;
                cout << j << endl;
            }
            return 0;
        }
    }
}

Measured memory_bytes: 256
#include<stdio.h>
main(void)
{
  int a = 0;
  int W,H,x,y,r = 0;
  scanf("%d %d %d %d %d",&W,&H,&x,&y,&r);
  if(x - r >= 0 && x + r <= W){
    if(y - r >= 0 && y + r <= H){
      a = 1;
    }
  }
  else{
    a = 0;
  }
  if(a == 1){
    printf("Yes\n");
  }
  else if(a == 0){
    printf("No\n");
  }
  return 0;
}
 

 

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

int main()
{
    int h, w;
    cin >> h >> w;
    vector<vector<char>> table(h, vector<char>(w));
    set<int> h_ignore, w_ignore;
    for (int i = 0; i < h; i++) {
        for (int j = 0; j < w; j++) {
            cin >> table[i][j];
            if (table[i][j] == '#') {
                h_ignore.insert(i);
                w_ignore.insert(j);
            }
        }
    }

    for (int i = 0; i < h; i++) {
        if (!(h_ignore.find(i) != h_ignore.end()))
            continue;
        for (int j = 0; j < w; j++) {
            if ((w_ignore.find(j) != w_ignore.end()))
                cout << table[i][j];
        }
        cout << endl;
    }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int a,b;
    cin>>a>>b;
    if((a ==1 && b == 2)||(a ==2 && b == 1))
        printf("3\n");
    else if((a ==1 && b == 3)||(a ==3 && b == 1))
        printf("2\n");
    else
        printf("1\n");
}


Measured memory_bytes: 256
def main():
  N,K=map(int,input().split())
  A=list(map(int,input().split()))
  n=[0]*N
  #行ったことある町リスト
  d=[1]
  for _ in range(K):
    T=A[d[-1]-1]
    if n[T-1]==1:
      break
    else:
      n[T-1]=1
    d.append(T)
  F=d.index(T)
  LOOP_TOWN=d[F:]
  q=(K-F)%len(LOOP_TOWN)
  print(LOOP_TOWN[q])

if __name__ == "__main__":
    main()


Measured memory_bytes: 95500
#include <bits/stdc++.h>
#define ll long long int
#define MOD 1000000007
#define PI 3.14159265358979

using namespace std;

int main(void){
  ll n, k;

  cin >> n >> k;

  vector<ll> a(n), f(n);

  for (int i = 0; i < n; i++){
    cin >> a[i];
  }
  for (int i = 0; i < n; i++){
    cin >> f[i];
  }

  sort(a.begin(), a.end());
  sort(f.begin(), f.end());


  ll l = -1, r = 1e12 + 1, mid;
  while (l + 1 < r){
    mid = (l + r) / 2;
    int id = 0;
    ll t = k;
    while (id < n){
      if (a[id] > mid / f[n - 1 - id])
        t -= a[id] - mid / f[n - 1 - id];
      id++;
    }

    if (t < 0)
      l = mid;
    else
      r = mid;
  }

  cout << r << endl;

  return 0;
}


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

#ifdef LOCAL
#include <debug.hpp>
#else
#define debug(...) void()
#endif

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int h, w, a, b;
  cin >> h >> w >> a >> b;
  for (int i = 0; i < h; i++) {
    for (int j = 0; j < w; j++) {
      cout << ((i < b) ^ (j < a));
    }
    cout << '\n';
  }
  return 0;
}

Measured memory_bytes: 3600
#include <stdio.h>

int digit_sum(int n){
    int sum = 0;
    while(n > 0){
        sum += n % 10;
        n /= 10;
    }
    return sum;
}

int main(void){
    int n, a, b;

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

    int sum = 0;
    int sum_k = 0;
#if 0
    for(int i = 0;i <= n;++i){
        sum_k = i % 10 + ((i / 10) % 10) + ((i / 100) % 10) + ((i / 1000) % 10) + (i / 10000);
        if(a <= sum_k && sum_k <= b) sum += i;
    }
#endif

    for(int i = 0;i <= n;++i){
        sum_k = digit_sum(i);
        if(a <= sum_k && sum_k <= b) sum += i;
    }

    printf("%d\n", sum);

    return 0;
}

Measured memory_bytes: 1728
package main

import "fmt"

func main() {
	var N, M, Q int
	fmt.Scan(&N, &M, &Q)

	memo := make([][]int, N+1, N+1)
	for i := range memo {
		memo[i] = make([]int, N+1, N+1)
	}

	for i := 0; i < M; i++ {
		var l, r int
		fmt.Scan(&l, &r)
		memo[l][r] += 1
	}

	for i := 1; i <= N; i++ {
		for j := 1; j <= N; j++ {
			memo[i][j] += memo[i][j-1]
		}
	}

	for i := 1; i <= N; i++ {
		for j := 1; j <= N; j++ {
			memo[i][j] += memo[i-1][j]
		}
	}

	for i := 0; i < Q; i++ {
		var l, r int
		fmt.Scan(&l, &r)
		fmt.Println(memo[r][r] + memo[l-1][l-1] - memo[r][l-1] - memo[l-1][r])
	}
}


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

#define int long long
typedef vector<int> vint;
typedef pair<int, int> pint;
const double PI = 3.141592653589793238462643383279;
const int DY[8] = {0, 1, 0, -1, 1, 1, -1, -1};
const int DX[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
template<typename T, typename U> inline bool chmax(T &a, const U &b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
template<typename T, typename U> inline bool chmin(T &a, const U &b) {
    if (b < a) {
        a = b;
        return true;
    }
    return false;
}
struct Init {
    Init() {
        cout << fixed << setprecision(20);
    };
} init;

int N;
int A[55], B[55], C[55];
signed main() {
    cin >> N;
    int ans = 0;
    for (int i = 1; i <= N; i++) { cin >> A[i]; }
    for (int i = 1; i <= N; i++) { cin >> B[i], ans += B[i]; }
    for (int i = 1; i <= N - 1; i++) { cin >> C[i]; }
    for (int i = 1; i <= N - 1; i++) {
        if (A[i] + 1 == A[i + 1]) { ans += C[A[i]]; }
    }
    cout << ans << endl;
}


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

int main(){
    int n,x,temp;
    vector<int> m;
    cin >> n >> x;
    for(int i = 0; i < n; i++){
        cin >> temp;
        m.push_back(temp); 
    }
    int ans, sum = 0;
    for(int i = 0; i < n; i++){
        sum += m[i]; 
    }
    int res = x-sum;
    int minx = *min_element(m.begin(),m.end());
    if(minx <= res){
        ans = m.size() + res / minx;
    }
    else ans = m.size();

    cout << ans << endl;

    return 0;
}

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

int main(){
    int n;
    cin >> n;
    if(n%2==0){
        cout << n << endl;
        return 0;
    }else{
        cout << n*2 << endl;
        return 0;
    }
}


Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#define _USE_MATH_DEFINES
#include "bits/stdc++.h"

using namespace std;

using u8 = uint8_t;
using u16 = uint16_t;
using u32 = uint32_t;
using u64 = uint64_t;
using i8 = int8_t;
using i16 = int16_t;
using i32 = int32_t;
using i64 = int64_t;

constexpr char newl = '\n';
constexpr double eps = 1e-10;

#define FOR(i,a,b) for (int i = (a); i < (b); i++)
#define F0R(i,b) FOR(i,0,b)
#define RFO(i,a,b) for (int i = ((b)-1); i >=(a); i--)
#define RF0(i,b) RFO(i,0,b)
#define fi first
#define se second
#define debug(x) cout << #x << ": " << x << '\n';
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()

template<typename T1, typename T2> inline void chmin(T1& a, T2 b) { if (a > b) a = b; }
template<typename T1, typename T2> inline void chmax(T1& a, T2 b) { if (a < b) a = b; }
template<class T> void Print(vector<T> v) {
  F0R(i, v.size()) {
    cout << v[i] << ' ';
  }
  cout << newl;
}

#if 1


// INSERT ABOVE HERE
signed main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);

  int N;
  cin >> N;
  vector<int> as(N);
  int d = 1;
  int r = 0;
  F0R(i, N) {
    int a;
    cin >> a;
    if (a != d) {
      r++;
    }
    else {
      d++;
    }
  }

  cout << (r < N ? r : -1);
}
#endif


Measured memory_bytes: 1024
#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 main()
{
    int a,b,c,d;
    cin>>a>>b>>c>>d;
    if(abs(a-c)<=d || (abs(a-b)<=d && abs(b-c)<=d))
    {
        cout << "Yes"<<endl;
    }
    else
    {
        cout<<"No"<<endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include <math.h>
#include <time.h>
#include <ctype.h>
#include <stdio.h>
#include <assert.h>
#include <stdlib.h>
#include <string.h>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <string>
#include <vector>
#include <iostream>
#include <algorithm>
#include<iomanip>

#define mod 1000000007
#define ll long long int
#define pb(x) push_back(x)
#define MP(x,y) make_pair(x,y)

using namespace std;

ll power(ll a, ll b, ll m)
{
	ll sol = power(a, b / 2, m);
	sol = (sol * sol) % m;
	if (b % 2 == 1)
		sol = (sol * a) % m;
	return(sol);
}
ll gcd(ll a, ll b)
{
	if (b == 0)
		return a;
	else
	{
		return gcd(b, a % b);
	}
}void solve()
{
	int x, a;
	cin >> x >> a;
	if (x < a)
		cout << "0";
	else
		cout << "10"; 
}

int main()
{
	int t = 1;
	//cin >> t;
	while (t--)
		solve();
	return(0);
}

Measured memory_bytes: 256
#include<cstdio>
int main(){
    int n,m,a[31]={};
    scanf("%d%d",&n,&m);
    for(int i=0;i<n;i++){
        int k;
        scanf("%d",&k);
        for(int j=0;j<k;j++){
            int aij;
            scanf("%d",&aij);
            a[aij]++;
        }
    }
    int ans=0;
    for(int i=1;i<=m;i++){
        if(a[i]==n)ans++;
    }
    printf("%d",ans);
    return 0;
}

Measured memory_bytes: 128
def main():
    n, m, x = [int(e) for e in input().split()]
    CA = [[int(e) for e in input().split()] for i in range(n)]

    ans = 10 ** 9
    for i in range(1, 2 ** n):
        bs = format(i, f'0{n}b')

        cs = 0
        Sm = [0] * m
        for i in range(n):
            if bs[i] == '1':
                cs += CA[i][0]
                for mi in range(m):
                    Sm[mi] += CA[i][mi + 1]

        if all(sm >= x for sm in Sm):
            ans = min(cs, ans)

    print(-1 if ans == 10 ** 9 else ans)


if __name__ == '__main__':
    main()


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

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

void dijkstra(vector<vector<pair<long long,long long>>> &g, vector<long long> &dist, long long st){
    long long INF=1e17;
    long long n=g.size();
    dist.assign(n,INF);
    priority_queue<pair<long long,long long>,vector<pair<long long,long long>>,greater<pair<long long,long long>>> pq;
    dist[st]=0;
    pq.emplace(dist[st],st);
    while(!pq.empty()) {
        pair<long long,long long> p=pq.top();
        pq.pop();
        long long v=p.second;
        long long d=p.first;
        if(dist[v] < d) continue;
        for(auto &np:g[v]) {
            long long nv=np.first;
            long long nd=np.second;
            if(dist[nv]>dist[v]+nd){
                dist[nv]=dist[v]+nd;
                pq.push(make_pair(dist[nv],nv));
            }
        }
    }
}

//#define int long long
//signed main(){
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n;
    cin >> n;
    vector<vector<pair<ll,ll>>> g(n);
    for(ll i = 0; i < n-1; i++) {
        ll a,b,c;
        cin >> a >> b >> c;
        a--;
        b--;
        g[a].emplace_back(b,c);
        g[b].emplace_back(a,c);
    }
    ll q,k;
    cin >> q >> k;
    k--;
    vector<ll> d(n);
    dijkstra(g,d,k);

    for(ll i = 0; i < q; i++) {
        ll x,y;
        cin >> x >> y;
        x--;
        y--;
        ll dist=d[x]+d[y];
        cout << dist << "\n";
    }

    return 0;
}

Measured memory_bytes: 14036