akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
int main(void){
    
    int n,m,l;
    int i,j,k;
    int a[100][100] = {0}, b[100][100] = {0};
    long long int c[100][100] = {0};
    
    scanf("%d %d %d",&n,&m,&l);
    for(i = 0; i < n; i++){
        for(j = 0; j < m; j++){
            scanf("%d",&a[i][j]);
        }
    }
    for(i = 0; i < m; i++){
        for(j = 0; j < l; j++){
            scanf("%d",&b[i][j]);
        }
    }
    for(i = 0; i < n; i++){
        for(k = 0; k < l; k++){
            for(j = 0; j < m; j++){
                c[i][k] = c[i][k]+a[i][j]*b[j][k];
            }
        }
    }
    
    for(i = 0; i < n; i++){
        for(j = 0; j < l; j++){
            if(j == l-1) printf("%lld",c[i][j]);
            else  printf("%lld ",c[i][j]);
        }
        printf("\n");
    }
}

Measured memory_bytes: 1956
#include<bits/stdc++.h>
#define int long long
using namespace std;

int n,a[20];
map<pair<int,int>,int>dp[22][22];

int dfs(int l,int r,int mul_l,int mul_r){
	if(l>r)return 0;
	if(dp[l][r].count(make_pair(mul_l,mul_r)))return dp[l][r][make_pair(mul_l,mul_r)];
	int &ret=dp[l][r][make_pair(mul_l,mul_r)];ret=1e18;
	for(int mid=l;mid<=r;mid++){
		ret=min(ret,dfs(l,mid-1,mul_l,mul_l+mul_r)+dfs(mid+1,r,mul_l+mul_r,mul_r)+a[mid]*(mul_l+mul_r));
	}
//	cerr<<l<<" "<<r<<" "<<mul_l<<" "<<mul_r<<" "<<ret<<endl;
	return ret;
}

signed main(){
	cin>>n;
	for(int i=1;i<=n;i++)cin>>a[i];
	cout<<a[1]+a[n]+dfs(2,n-1,1,1)<<endl;
	return 0;
}

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

#define rep(i, n) for(long long i=0;i<n;i++)
using ll = long long;
const ll INF = (1LL<<60);

int main(){

    ll h, a; cin >> h >> a;

    cout << (h/a)+!!(h%a) << endl;

    return 0;
}

Measured memory_bytes: 256
package main

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

func out(x ...interface{}) {
	fmt.Println(x...)
}

var sc = bufio.NewScanner(os.Stdin)

func getInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func getString() string {
	sc.Scan()
	return sc.Text()
}

// min, max, asub, absなど基本関数
func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func asub(a, b int) int {
	if a > b {
		return a - b
	}
	return b - a
}

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

func lowerBound(a []int, x int) int {
	idx := sort.Search(len(a), func(i int) bool {
		return a[i] >= x
	})
	return idx
}

func upperBound(a []int, x int) int {
	idx := sort.Search(len(a), func(i int) bool {
		return a[i] > x
	})
	return idx
}

func main() {
	sc.Split(bufio.ScanWords)
	sc.Buffer([]byte{}, 1000000)
	X, Y := getInt(), getInt()

	for i := 0; i <= X; i++ {
		a := i
		b := X - a
		if 2*a+4*b == Y {
			out("Yes")
			return
		}
	}
	out("No")
}


Measured memory_bytes: 1760
#include <cstdio>
#include <cstring>
#include <algorithm>

using namespace std;

char st[104014];

int main(){
  while(~scanf("%s", st)){
    int len = strlen(st);
    if(st[0] != st[len-1]){
      if(len & 1) printf("First\n");
      else printf("Second\n");
    }
    else {
      if(len & 1) printf("Second\n");
      else printf("First\n");
    }
  }
  return 0;
}


Measured memory_bytes: 256
# スタックの実装。
class Stack():
    def __init__(self):
        self.stack = []
    # データを追加する。
    def push(self, item):
        self.stack.append(item)
    # データを取り出す。
    def pop(self):
        return self.stack.pop()
    # スタックの中身を確認する。
    def get_stack(self):
        return self.stack
    # スタックが空ならばTrueを返す。
    def isEmpty(self):
        return len(self.stack) == 0
    # スタックに格納されているものの数を返す。
    def count(self):
        return len(self.stack)
    #　スタックのトップを見る（取り出さずに）。
    def top(self):
        return self.stack[-1]

# ヒストグラムの最大長方形を求める関数。
def Histogram(n,l):
    if n == 0:
        return 0
    stack = Stack()
    t = 0
    ans = 0
    while t < n:
        r = l[t]
        if stack.isEmpty():
            stack.push((r,t))
            t += 1
            # print(stack.get_stack(),t)
        elif stack.top()[0] < r:
            stack.push((r,t))
            t += 1
            # print(stack.get_stack(),t)
        elif stack.top()[0] == r:
            t += 1
            # print(stack.get_stack(),t)
        elif stack.top()[0] > r:
            while stack.top()[0] > r:
                p,q = stack.pop()
                ans = max(ans,p*(t-q))
                # print(stack.get_stack(),t)
                if stack.isEmpty():
                    break;
            stack.push((r,q))
            t += 1
    while not stack.isEmpty():
        p,q = stack.pop()
        ans = max(ans, p*(t-q))
        # print(stack.get_stack(),t)
    return ans


H,W  = [int(_) for _ in input().split()]
dp = [[0]*W for _ in range(H)]
for i in range(H):
    for j,value in enumerate([int(_) for _ in input().split()]):
        dp[i][j] = value
c = 1
for j in range(W):
    i = 0
    while i < H:
        if dp[i][j] == 0:
            dp[i][j] = c
            c += 1
        else:
            dp[i][j] = 0
            c = 1
        i += 1
    c = 1

# for i in range(H):
#     print(dp[i])

ans = 0
l = []
for i in range(H):
    for j in range(W):
        if dp[i][j] == 0:
            ans = max(ans,Histogram(len(l),l))
            # print(len(l),l)
            l = []
        else:
            l.append(dp[i][j])
    ans = max(ans,Histogram(len(l),l))
    # print(len(l),l)
    l = []
print(ans)


# print('TEST')
# print(Histogram(5, [3,5,4,5,5]))


Measured memory_bytes: 51996
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<vector>
#include<queue>
#include<stack>
#include<cmath>
using namespace std;
char a[10005];
int x,y,vis;
int main(){
	scanf("%d%d",&x,&y);
	scanf("%s",a+1);
	for(int i=1;i<=x;i++){
		if(a[i]>'9'||a[i]<'0')vis=1;
	}
	if(a[x+1]!='-')vis=1;
	for(int i=x+2;i<=y+x+1;i++){
		if(a[i]>'9'||a[i]<'0')vis=1;
	}
	if(vis==1)cout<<"No";
	else cout<<"Yes";
    return 0;
}


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

#define NMAX 100
#define MAX(X,Y) ((X)>(Y)?(X):(Y))
#define MIN(X,Y) ((X)<(Y)?(X):(Y))

int main(void){
  int height[NMAX][NMAX];
  int shorter[NMAX], taller[NMAX];
  int n, na;
  
  while (cin >> n){
    if (n==0) break;
    for (int i=0; i<n; i++){
      shorter[i] = 1<<30;
      taller[i] = -(1<<30);
    }
    for (int i=0; i<n; i++){
      for (int j=0; j<n; j++){
        cin >> height[j][i];
        shorter[i] = MIN(shorter[i], height[j][i]);
        taller[j] = MAX(taller[j], height[j][i]);
      }
    }
    na = 1;
    for (int i=0; i<n; i++){
      for (int j=0; j<n; j++){
        if (na && height[j][i] == taller[j] &&
            height[j][i] == shorter[i]){
          na = 0;
          cout << height[j][i] << endl;
        }
      }
    }
    if (na) cout << 0 << endl;
  }
  return 0;
}


Measured memory_bytes: 3028
using System;

class Program
{
    static void Main(string[] args)
    {
        var s = Console.ReadLine();
        var t = new[] { "dream", "dreamer", "erase", "eraser" };

        while (s != "")
        {
            var any = false;
            for (int i = 0; i < 4; i++)
            {
                if (s.EndsWith(t[i]))
                {
                    s = s.Substring(0, s.Length - t[i].Length);
                    any = true;
                    break;
                }
            }
            if (!any)
            {
                Console.WriteLine("NO");
                return;
            }
        }
        Console.WriteLine("YES");
    }
}


Measured memory_bytes: 31784
from decimal import *

import numpy as np

import math

if __name__ == '__main__':
    n = int(input())
    count = 0

    for i in range(n):
        b, c = map(str, input().split())
        if c =="JPY":
            count+=int(b)
        else:
            count+=  Decimal(380000 ) * Decimal(b)

    print(count)



Measured memory_bytes: 13380
#include <cstdio>

int Y, M, D;

int solve() {
    int num_large_year = (Y - 1) / 3;
    int num_small_year = (Y - 1) - num_large_year;

    int days = 0;

    days += num_large_year * (20 * 10);
    days += num_small_year * (20 * 5 + 19 * 5);

    if (Y % 3 == 0) { // large year
        days += (M - 1) * 20;
    } else { // small year
        for (int i = 1; i < M; i++) {
            days += (i % 2 == 1 ? 20 : 19);
        }
    }

    days += D - 1;

    return 196470 - days;
}

int main() {
    int n;
    scanf("%d", &n);
    for (int i = 0; i < n; i++) {
        scanf("%d%d%d", &Y, &M, &D);
        printf("%d\n", solve());
    }
    return 0;
}

Measured memory_bytes: 1024
r,c = map(int,input().split())
excel = [list(map(int,input().split())) for _ in range(r)]
ans =  [[0]*(c+1) for _ in range(r+1)]
for i,x in enumerate(excel):
    x.append(sum(x))
    ans[i] = x
_sum = 0
for i in range(c+1):
    for j in range(r):
        _sum += excel[j][i]
    ans[r][i] = _sum
    _sum = 0
for y in ans:
    print(*y)


Measured memory_bytes: 6244
n,k=map(int,input().split(' '))
h=list(map(int,input().split(' ')))
node=[0]*n
for i in range(1,n):
    x=[abs(h[i]-h[i-m])+node[i-m] for m in range(1,min(i+1,k+1))]
    node[i]=min(x)
print(node[-1])

Measured memory_bytes: 52192
#define _USE_MATH_DEFINES 
#include<iomanip> 
#include<cmath>  
#include<iostream>
#include<fstream>
#include<vector>
#include<algorithm>
#include<numeric>
#include<bitset>
#include<map>
#include<unordered_map>
#include<set>
#include<unordered_set>
#include<queue>
#include<deque>
#include<stack>
using namespace std;
typedef long long ll;
#define repi(i,a,b) for(ll i = (ll)(a) ; i < (ll)(b) ; i++)
#define repd(i,a,b) for(ll i = (ll)(a) ; i > (ll)(b) ; i--)
#define rd(x) cin >> x
#define wr(x)  cout << x
#define wrln(x) cout << x << endl
const ll MAX_10p5 = 100010;
const ll MAX_10p9 = 1000000010;
const ll MAX_10p18 = 1000000000000000010;
const ll MOD = 1000000007;
const ll m4x[4] = { 1,0,-1,0 };
const ll m4y[4] = { 0,1,0,-1 };
const ll m8x[8] = { 1,1,0,-1,-1,-1,0,1 };
const ll m8y[8] = { 0,1,1,1,0,-1,-1,-1 };
const ll m9x[9] = { 1,1,0,-1,-1,-1,0,1,0 };
const ll m9y[9] = { 0,1,1,1,0,-1,-1,-1,0 };

struct edge {
	ll from, to, cost;
	bool operator<(const edge& right) const {
		return cost < right.cost;
	}
};
struct point {
	ll x, y;
	bool operator<(const point& right) const {
		return x == right.x ? y < right.y : x < right.x;
	}
};

///////////////////////////////////////////////////////////////////////////////////////

ll N, M;
edge es[2020];
vector<edge> nodes[1010];
ll d[1010];
bool visited[1010];
bool loop[1010];

void dfs(ll node) {
	if (visited[node]) return;
	visited[node] = true;
	if (node == N - 1) return;
	repi(i, 0, nodes[node].size()) {
		dfs(nodes[node][i].to);
	}
}

int main() {
	cin >> N >> M;
	repi(i, 1, N) d[i] = MAX_10p18;
	repi(i, 0, M) {
		edge e;
		cin >> e.from >> e.to >> e.cost;
		e.from--, e.to--, e.cost = -e.cost;
		es[i] = e;
		nodes[e.from].push_back(e);
	}
	dfs(0);
	repi(i, 0, N - 1) {
		bool update = false;
		repi(j, 0, M) {
			edge e = es[j];
			if (!visited[e.from] || !visited[e.to]) continue;
			if (d[e.from] != MAX_10p18 && d[e.to] > d[e.from] + e.cost) {
				d[e.to] = d[e.from] + e.cost;
				if (d[e.to] >= MAX_10p18) d[e.to] = MAX_10p18 - 1;
				if (d[e.to] < -MAX_10p18) d[e.to] = -MAX_10p18;
				update = true;
			}
		}
		if (!update) break;
	}
	repi(i, 0, N + 1) {
		repi(j, 0, M) {
			edge e = es[j];
			if (!visited[e.from] || !visited[e.to] || d[e.from] == MAX_10p18) continue;
			if (d[e.to] > d[e.from] + e.cost) {
				d[e.to] = d[e.from] + e.cost;
				loop[e.to] = true;
				if (d[e.to] >= MAX_10p18) d[e.to] = MAX_10p18 - 1;
				if (d[e.to] < -MAX_10p18) d[e.to] = -MAX_10p18;
			}
			if (loop[e.from]) e.to = true;
		}
	}
	if (loop[N - 1]) wrln("inf");
	else wrln(-d[N - 1]);
	return 0;
}


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

// 基本テンプレート
#pragma region MACRO
#define P(x) cout << (x) << endl
#define p(x) cout << (x)
#define PED cout << "\n"
#define rep(i,n) for(int i=0; i<(int)n; ++i)
#define REP(i,x,n) for(int i=x; i<(int)n; ++i)
#define repi(i,n) for(int i=0; i<=(int)n; ++i)
#define REPI(i,x,n) for(int i=x; i<=(int)n; ++i)
#define ILP while(true)
#define FOR(i,c) for(__typeof((c).begin())!=(c).begin(); i!=(c).end(); ++i)
#define ALL(c) (c).begin(), (c).end()
#define mp make_pair
#pragma endregion

// 型
#pragma region TYPE_DEF
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<string, string> pss;
typedef pair<string, int> psi;
typedef pair<int, string> pis;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<long double> vld;
typedef vector<long> vl;
typedef vector<long long> vll;
typedef vector<string> vs;
#pragma endregion

// Effective std
#pragma region ESTD
template<typename C, typename T> int count(C& c, T t) { return count(ALL(c), t); }
template<typename C, typename F> int count_if(C& c, F f) { return count_if(ALL(c), f); }
template<typename C, typename T> void erase(C& c, T t) { remove(ALL(c), t), c.end(); }
template<typename C> void remove(vector<C>& c, unsigned int index) { c.erase(c.begin()+index); }
template<typename C, typename T, typename U> void replace(C& c, T t, U u) { replace(ALL(c), t, u); }
template<typename C, typename F, typename U> void replace_if(C& c, F f, U u) { (ALL(c), f, u); }
template<typename C> void reverse(C& c) { reverse(ALL(c)); }
template<typename C> void sort(C& c) { sort(ALL(c)); }
template<typename C, typename Pred> void sort(C& c, Pred p) { sort(ALL(c), p); }
#pragma endregion

// 定数
#pragma region CONST_VAL
constexpr int PI = (2*acos(0.0));
constexpr int EPS = (1e-9);
constexpr int MOD = (int)(1e9+7);
constexpr int INF = 100000000;
#pragma endregion


int main()
{
    int n;
    cin >> n;
    vi v;
    vi memo(100001, 0);
    rep(i, n) {
        int a;
        cin >> a;
        v.push_back(a);
        memo[a]++;
    }

    sort(v);
    sort(memo, greater<int>());
    v.erase(unique(ALL(v)), v.end());
    int tmp = 0;
    int tmp2 = 0;
    rep(i, v.size()) {
        if (memo[i]>=2)
            if (memo[i]%2==0) tmp2++;
    }
    cout << v.size() - tmp2%2 << endl;

    return 0;
}



Measured memory_bytes: 1276
#include <stdio.h>
#include <stdlib.h>

int main()
{
    int N,A,B;
    while(~scanf("%d",&N))
    {
        if(N==1)
            printf("Hello World\n");
        if(N==2)
        {
            scanf("%d %d",&A,&B);
            printf("%d",A+B);
        }
    }
    return 0;
}


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

template<typename T>
void fin (T a){
    cout<<a<<endl;
    exit(0);
}

template<typename S>
void print(S a){
    cout<<a<<endl;
}


int main(){
    int n;
    cin>>n;
    ll tmp;
    ull ans=0;

    map<int,ll> mp;
    rep(i,n){
        cin>>tmp;
        ans+=tmp;
        mp[tmp]+=1;
    }
    int q;cin>>q;
    int b,c;

    rep(i,q){
        cin>>b>>c;
        auto it = mp.find(b);
        if(it !=mp.end()){
            tmp = it->second;
            mp[c]+=tmp;
            mp.erase(it);
            ans += (c-b)*tmp;
            print(ans);
        }else{
            print(ans);
        }
    }


    return 0;
}




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

if 1 <= N < 10: print(N)
elif 10 <= N < 100: print(9)
elif 100 <= N < 1000: print(9 + N - 100 + 1)
elif 1000 <= N < 10000: print(9 + 900)
elif 10000 <= N < 100000: print(9 + 900 + N - 10000 + 1)
else: print(9 + 900 + 90000)


Measured memory_bytes: 2940
#include <stdio.h>

int main(){
  int a,b,r;
  scanf("%d%d",&a,&b);

  r = a % b;

  while(r!=0){

    a = b;
    b = r;
    r = a % b;
  }




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

  return 0;
}

Measured memory_bytes: 592
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;i++)
typedef long long ll;
using namespace std;
//const ll inf=(1e+10)+1;
int dp[101][4][2];
int main(void){
    string s;cin>>s;
    int n=s.size();
    int k;cin>>k;
    //int dp[101][4][2];グローバル変数にしないと初期値がバグる！！
    dp[0][0][0]=1;
    rep(i,n){
        int now=s[i]-'0';
        rep(j,4){
            rep(l,2){
                rep(a,10){
                    int ni=i+1,nj=j,nl=l;
                    if(a!=0)nj++;
                    if(nj>k)continue;
                    if(l==0){
                        if(a>now)break;
                        if(a<now)nl=1;
                        else nl=0;
                    }
                    dp[ni][nj][nl]+=dp[i][j][l];
                }
            }
        }
    }
    ll res=dp[n][k][1]+dp[n][k][0];
    cout<<res<<endl;
}


Measured memory_bytes: 256
n, m = map(int,input().split())
b, c = [0]*m, [0]*m
a = [int(x) for x in input().split()]
for i in range(m):
    b[i], c[i] = map(int,input().split())
abc = sorted(zip(c + a, b + [1]*n))
tmp, pl, ans = 0, 0 , 0
while n > 0:
    n -= 1
    if tmp > 0:
        tmp -= 1
        ans += pl
        continue
    if len(abc) > 0:
        ans += abc[-1][0]
        pl = abc[-1][0]
        tmp = abc[-1][1] - 1
        abc.pop()
print(ans)


Measured memory_bytes: 33656
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for (int i=0;i<(n);i++)
#define MOD 1000000007
#define INF 1000000009
typedef long long ll;
typedef pair<int,int> P;
#define YES(s) s?cout << "YES" << endl:cout << "NO" << endl
#define Yes(s) s?cout << "Yes" << endl:cout << "No" << endl
#define Taka(s) s?cout << "Takahashi" << endl:cout << "Aoki" << endl
#define int ll

int XOR(int a,int b){
    int c=max(a,b);
    c = (int)log2(c);
    int d=0,e=1;
    for(int i=0;i<=c;i++){
        if((a/e)%2!=(b/e)%2){
            d+=e;
        }
        e*=2;
    }
    return d;
}

signed main(void){
    int N,A[214514],B[214514]={},C[214514]={};
    cin >> N;
    int Ans=0;
    REP(i,N){
        cin >> A[i];
        B[i+1]=B[i]+A[i];
        C[i+1]=XOR(C[i],A[i]);
    }
    int i=0,j=0;
    while(i<N){
        if(B[j+1]-B[i] == XOR(C[i],C[j+1])&&j<N){
            j++;
        }else{
            //cout << i << " " << j << endl;
            Ans+=j-i;
            i++;
            if(j<i)j=i;
        }
    }
    cout << Ans << endl;
    
  return 0;
}


Measured memory_bytes: 5248
#[allow(unused_imports)]
use std::cmp::Reverse;

#[allow(unused_imports)]
use proconio::{fastout, input, marker::Chars};

#[allow(unused_imports)]
use itertools::Itertools;

const MOD: i64 = 1000000007;

#[fastout]
pub fn main() {
    input! {
        n: usize,
        a: [[i32; n]; n],
    }
    let a: Vec<Vec<_>> = a
        .into_iter()
        .map(|a| a.into_iter().map(|a| a == 1).collect())
        .collect();

    let mut dp = vec![0; 1 << n];
    dp[0] = 1;
    for i in 1usize..1 << n {
        let num = i.count_ones() as usize;
        for j in 0..n {
            if ((i >> j) & 1) == 1 && a[num - 1][j] {
                dp[i] += dp[i ^ (1 << j)];
                dp[i] %= MOD;
            }
        }
    }
    println!("{}", dp[(1 << n) - 1]);
}


Measured memory_bytes: 18456
fn main() {
    let s = read::<String>();
    yn(s == "H H" || s == "D D");
}

#[allow(dead_code)]
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}
#[allow(dead_code)]
fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}
#[allow(dead_code)]
fn read_vec2<T: std::str::FromStr>(n: u32) -> Vec<Vec<T>> {
    (0..n).map(|_| read_vec()).collect()
}
#[allow(dead_code)]
fn yn(result: bool) {
    if result {
        println!("H");
    } else {
        println!("D");
    }
}


Measured memory_bytes: 4352
import java.io.IOException;
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) throws IOException {

		new Main().run();
	}

	private void run() throws IOException {
		Scanner scanner = new Scanner(System.in);
		while (true) {
			n = scanner.nextInt();
			u = scanner.nextInt();
			if ((n | u) == 0)
				break;
			need = new int[n];
			gain = new int[n];
			int all = 0;
			unit = new int[n];
			for (int i = 0; i < n; i++) {
				unit[i] = gain[i] = scanner.nextInt();
				all += unit[i];
				int k = scanner.nextInt();
				for (int j = 0; j < k; j++) {
					int x = scanner.nextInt();
					need[i] |= (1 << x);
				}
			}
			Arrays.sort(gain);
			for (int i = n - 2; i >= 0; i--)
				gain[i] += gain[i + 1];
			if (all == u) {
				System.out.println(n);
				continue;
			}
			ans = n;
			v = new boolean[1 << n];
			slove(0, 0, 0);
			System.out.println(ans);
		}
	}

	private void slove(int bit, int one, int have) {
		if (ans <= one)
			return;
		if (have >= u) {
			ans = one;
			return;
		}
		if (have + gain[n - (ans - one - 1) - 1] < u)
			return;

		for (int i = 0; i < n; i++) {
			int a = bit | (1 << i);
			if (v[a] || (bit | need[i]) != bit)
				continue;
			v[a] = true;
			slove(bit | (1 << i), one + 1, have + unit[i]);
		}
	}

	int n, u;
	int[] need, unit, gain;
	int ans;
	boolean[] v;
}

Measured memory_bytes: 56760
#include <stdio.h>

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


int main (void)
{
  int k;
  scanf("%d",&k);
  int i , j , l , ans = 0;
  
 for(i = 1;i<=k;i++){
   for(j = 1;j<=k;j++){
     for(l = 1;l<=k;l++){
       ans += gcd(gcd(i,j),l);
     }}}
  
  printf("%d",ans);
  
  return 0;
}
  

Measured memory_bytes: 1728
package main

import (
	"fmt"
	"os"
	"strconv"
	"bufio"
	"strings"
)
func main2(){
ans(10,3,50,4,60)
ans(10 ,3, 100, 5, 180)//360
ans(6, 2, 200, 3, 300)// 600

}

func main() {



    sc := bufio.NewScanner(os.Stdin)
     sc.Scan()
        args := strings.Split(sc.Text(), " ")
      

	var n, a, b, c, d int

	n, _ = strconv.Atoi(args[0])
	a, _ = strconv.Atoi(args[1])
	b, _ = strconv.Atoi(args[2])
	c, _ = strconv.Atoi(args[3])
	d, _ = strconv.Atoi(args[4])

        ans(n,a,b,c,d)
}

func ans(n,a,b,c,d int){

	ans2 := 0
	for i := 0; i < 1000; i++ {
		if i*a >= n {
			ans2 = i * b
			break
		}
	}

	for i := 0; i < 1000; i++ {
	
		if i*c >= n {
			if ans2 > i*d {


				ans2 = i *  d
			}
			break
		}
	}

	fmt.Printf("%d\n", ans2)
}


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

using namespace std;
int main()
{
  int n;
  cin >> n;
  if(n % 10 == 7)
  {
  	cout << "Yes" << endl;
    return 0;
  }
  n/=10;
  if(n % 10 == 7)
  {
  	cout << "Yes" << endl;
    return 0;
  }
  n/=10;
  if(n % 10 == 7)
  {
  	cout << "Yes" << endl;
    return 0;
  }
  cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 3624
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <numeric>  // min, max
#include <fstream>  // ifstream
#include <iomanip>  // setprecision
using namespace std;
typedef long long ll;

int main(void)
{
#ifdef FILE_DEBUG
    ifstream inputFile("data/input.txt");
    cin.rdbuf(inputFile.rdbuf());
#endif
    // これより下にコードを書く

    string S, T;
    cin >> S >> T;

    for (int i = 0; (i < S.size()); ++i) {
        char init = S[0];
        for (int j = 1; (j < S.size()); ++j) {
            S[j-1] = S[j];
        }
        S[S.size()-1] = init;
        if (S == T) {
            cout << "Yes" << endl;
            return 0;
        }
    }

    cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Scanner;

public class Main {

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

        int N = in.nextInt();
        int M = in.nextInt();

        int[] A = new int[M];
        int[] B = new int[M];

        for (int i = 0; i < M; i++) {
            A[i] = in.nextInt() - 1;
            B[i] = in.nextInt() - 1;
        }

        List<Long> ans = new ArrayList<Long>(Arrays.asList(new Long[M]));
        ans.set(M - 1, (long) N * (N - 1) / 2); // 最初は全ノード独立しているので不便さはnC2

        UnionFind uni = new UnionFind(N);
        for (int i = M - 1; i >= 1; i--) {
            ans.set(i - 1, ans.get(i));

            if (uni.root(A[i]) != uni.root(B[i])) {
                long temp = uni.size(A[i]) * uni.size(B[i]);
                ans.set(i - 1, ans.get(i - 1) - temp);
                uni.connect(A[i], B[i]);
            }
        }

        for (int i = 0; i < M; i++) {
            System.out.println(ans.get(i));
        }
    }

    static class UnionFind {
        List<Integer> parent; // parent.get(i)でiの親が取得出来る.親だった場合は「-1 * その集合のサイズ」を持つ

        UnionFind(int N) {
            parent = new ArrayList<Integer>();
            Integer[] values = new Integer[N];
            Arrays.fill(values, -1);
            parent.addAll(Arrays.asList(values)); // 最初は全ノード独立している「独立=親が-1」で表す。
        }

        int root(int A) {
            if (parent.get(A) < 0) {
                // 自分が親
                return A;
            }
            int root = root(parent.get(A)); // 自分の親を渡して再帰処理
            parent.set(A, root); //せっかく再帰関数で親を取得したので、その結果で更新しておく
            return root;
        }

        int size(int A) {
            return -parent.get(root(A));
        }

        boolean connect(int A, int B) {
            A = root(A);
            B = root(B);
            if (A == B) {
                return false;
            }

            // 大きい方に小さい方を付けたい
            if (size(A) < size(B)) {
                int temp = A;
                A = B;
                B = temp;
            }

            parent.set(A, parent.get(A) + parent.get(B));  // Aのサイズを変更
            parent.set(B, A);                              // Bの親をAに変更

            return true;
        }
    }

}


Measured memory_bytes: 108076
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rep1(i, n) for(int i = 1; i <= (int)(n); i++)
#define showmap(is, js, x) {rep(i, is){rep(j, js){cout << x[i][j] << " ";}cout << endl;}}
#define show(x) {for(auto i: x){cout << i << " ";} cout<<endl;}
#define showm(m) {for(auto i: m){cout << m.x << " ";} cout<<endl;}
typedef long long ll;
typedef pair<int, int> P;
typedef pair<ll, ll> llP;
ll gcd(int x, int y){ return y?gcd(y, x%y):x;}
ll lcm(ll x, ll y){ return (x*y)/gcd(x,y);}

/*
ダイクストラしんどい

*/

struct Edge{
    int to;
    ll cost;
    Edge(int to, ll cost) :to(to), cost(cost){};
};
const int n_max = 100050;
vector<vector<Edge>> root(n_max);

struct Data{
    int v;
    ll min;
    Data(int v, ll min): v(v), min(min){};
    //a < bとしたとき昇順データとなる
    bool operator<(const Data& other) const {
        return min > other.min;
    }
};
vector<ll> dp(n_max, 1e18);

void dijkstra(int k){
    priority_queue<Data> pq;
    auto push = [&](int v, ll c){
        if (dp[v] < c) return;
        dp[v] = c;
        pq.emplace(v, c);
    };
    push(k, 0);
    while(!pq.empty()){
        auto now = pq.top(); pq.pop();
        for(auto next: root[now.v]){
            push(next.to, dp[now.v] + next.cost);
        }
    }
}

int main()
{
    int n;
    cin >> n;
    rep(i, n-1){
        int a, b; ll c; cin >> a >> b >> c;
        a--; b--;
        root[a].emplace_back(b, c);
        root[b].emplace_back(a, c);
    } 

    int q, k;
    cin >> q >> k;
    k--;
    dijkstra(k);
    rep(i, q){
        int x, y; cin >> x >> y;
        x--; y--;
        cout << dp[x]+dp[y] << endl;
    }

}



Measured memory_bytes: 11120
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
     
using namespace std;
     
typedef long long ll;
typedef pair<int, int> pii;
     
#define fi first
#define se second
#define mp make_pair
#define fastIO ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
     
mt19937 rnd(chrono::steady_clock().now().time_since_epoch().count());

int main(){
    fastIO;
    int n, x;
    cin >> n >> x;
    int a[n];
    for(int i = 0 ; i < n ; i ++ )
        cin >> a[i];
    sort(a, a + n);
    int res = 0;
    for(int i = 0 ; i < n ; i ++ ){
        if(x >= a[i]){
            res ++ ;
            x -= a[i];
        }
        else{
            x=0;
        }
    }
    if(x != 0) res -- ;
    cout << res;
    return 0;
}

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

//{{{
/********************************************************************/
struct Fast {Fast(){std::cin.tie(0);ios::sync_with_stdio(false);}} fast;

typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vector<int> > vii;
typedef queue<int> qi;
typedef stack<int> si;
typedef deque<int> dqi;

#define reps(i, a, b) for (int i = a; i < b; ++i)
#define rep(i, n) reps(i, 0, n)
#define REPS(i, a, b) reps(i, a, b)
#define REP(i, n) rep(i, n)
#define deps(i, a, b) for (int i = a; i >= b; --i)
#define dep(i, n) deps(i, n, 0)
#define DEPS(i, a, b) deps(i, a, b)
#define DEP(i, n) dep(i, n)

#define pf push_front
#define pb push_back
#define mp make_pair
#define fst first
#define FST fst
#define sec second
#define SEC sec
#define sz(obj) ((int)(obj).size())
#define all(v) (v).begin(), (v).end()
#define ALL(v) all(v)
#define endl "\n"

const int INF = 999999999;
const int MOD = 1e9 + 7;
const int dx[] = {0, 1, 0, -1, 1, 1, -1, -1}, dy[] = {1, 0, -1, 0, 1, -1, -1, 1};

//vector<string> split(const string &s, char delim) {
//  vector<string> elems;
//  string item;
//  for (char ch: s) {
//    if (ch == delim) {
//      if (!item.empty()) elems.push_back(item);
//      item.clear();
//    }
//    else item += ch;
//  }
//  if (!item.empty()) elems.push_back(item);
//  return elems;
//}

inline bool inside(int y, int x, int H, int W) { return y >= 0 && x >= 0 && y < H && x < W; }
inline int in() { int x; std::cin >> x; return x; }
template <typename T>
void print(std::vector<T>& v, char c = ' ') {
  REP(i, v.size()) {
    if (i != 0) std::cout << c;
    std::cout << v[i];
  }
  std::cout << endl;
}
template <typename T> void print(T x) { std::cout << x << '\n'; }

/****************************************************************/
//}}}

signed main()
{
  int n, m;
  cin >> n;
  int t[n];
  rep(i, n) cin >> t[i];
  cin >> m;
  rep(i, m) {
    int p, x;
    cin >> p >> x;
    int sum = 0;
    rep(j, n) {
      sum += (j != p - 1) ? t[j] : x;
    }
    print(sum);
  }

  return (0);
}

Measured memory_bytes: 256
s = input()
len_s = len(s)
l_index = 0
r_index = len_s - 1
counter = 0
while l_index < r_index:
    if s[l_index] == s[r_index]:
        l_index += 1
        r_index -= 1
    elif s[l_index] == "x":
        counter += 1
        l_index += 1
    elif s[r_index] == "x":
        counter += 1
        r_index -=1
    else:
        counter = -1
        break
print(counter)


Measured memory_bytes: 3316
import java.util.Scanner;
class Main{

	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int [] pasta = new int[3];
		int [] drink = new int[2];
		int [][] price = new int[3][2];
		for(int i = 0;i < 3;i++){
			pasta[i] = sc.nextInt();
		}
		for(int j = 0;j < 2;j++){
			drink[j] = sc.nextInt();
		}
		for(int i = 0;i < 3;i++){
			for(int j = 0;j < 2;j++){
				price[i][j] = pasta[i] + drink[j]-50;
			}
		}
		int min = price[0][0];
		for(int i = 0;i < 3;i++){
			for(int j = 0;j < 2;j++){
				if(min > price[i][j]){
					min = price[i][j];
				}
			}
		}
		System.out.println(min);
	}

}

Measured memory_bytes: 26268
#include <cstring>
#include <cstdio>
#include <vector>
#include <queue>
#include <algorithm>
#include <cmath>
#define MaxN 100005
using namespace std;

long long N,T,Total,End,X;
int main()
{
	scanf("%lld%lld",&N,&T);
	Total=N*T;
	for(int i=1;i<=N;i++)
	{
		scanf("%lld",&X);
		if(X<End)
			Total-=End-X;
		End=X+T;
	}
	printf("%lld",Total);
	return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define mp make_pair
#define f(i,a,n) for(int i=a;i<n;i++)
#define ve vector
#define ss second 
#define ff first
#define pf pop_front
#define pob pop_back
#define psf push_front
#define res(x) cout<<x<<'\n'
#define read(t) ll t;cin>>t

int main(){
    int k;cin>>k;
    string s;cin>>s;
    if(s.length()<=k){
        cout<<s<<endl;
    }
    else{
        f(i,0,k){
            cout<<s[i];
        }
        cout<<"..."<<endl;
    }
}

Measured memory_bytes: 3616
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int x = Integer.parseInt(sc.next());

		if (x == 7 || x == 5 || x == 3){
			System.out.println("YES");
		}else {
			System.out.println("NO");
		}
	}
}

Measured memory_bytes: 22868
#include <algorithm>
#include <cassert>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
/* #include <regex> */

using namespace std;

/* g++ -g -std=c++11 */

/* freopen("input.txt", "rt", stdin); */
/* freopen("output.txt", "wt", stdout); */

#define ALL(c)          (c).begin(), (c).end()
#define ALLR(c)         (c).rbegin(), (c).rend()
#define FOR(i,a,b)      for (int i=(a); i < (b); ++i)
#define FORR(i,a,b)     for (int i=(a); i > (b); --i)
#define FOR_ALL(i,c)    for (__typeof((c).begin()) i=(c).begin();   \
                             i != (c).end(); ++i)
#define FOR_ALLR(i,c)   for (__typeof((c).rbegin()) i=(c).rbegin(); \
                             i != (c).rend(); ++i)
#define SZ(array)       (sizeof(array)/sizeof(array[0]))
#define lc(x)           (x<<1)     /* 2*x */
#define rc(x)           (x<<1 | 1) /* 2*x+1 */
#define lowbit(x)       (x & (-x)) /* 0b10100 -> 0b100 */

typedef long long       LL;
typedef map<int,int>    MII;
typedef pair<int,int>   PII;
typedef set<int>        SI;
typedef vector<bool>    VB;
typedef vector<double>  VD;
typedef vector<int>     VI;
typedef vector<string>  VS;

/* check if a key is in container C */
template <class C>
inline bool in_(const typename C::key_type& k, const C& A)
{ return A.find(k) != A.end(); }
inline bool in_(const string& s, const string& S)
{ return S.find(s) != string::npos; }

const int mod = 1e9+7;
const int maxn = 1e5+5;
VI G[maxn]; int dp[maxn][2];

int dfs(const int u, const int p, const int pcolr)
{
    bool leaf = true;
    FOR_ALL(v,G[u]) if (*v != p) 
        leaf = false;
    if (leaf)
        return pcolr ? 1 : 2;
    int& ans = dp[u][pcolr];
    if (-1 == ans) {
        ans = 0;
        FOR(c,0,2) if ((c&pcolr) == 0) {
            LL res = 1;
            FOR_ALL(v,G[u]) if (*v != p) {
                res *= dfs(*v,u,c);
                res %= mod;
            }
            ans += res;
            ans %= mod;
        }
    }
    return ans;
}

int main()
{
#ifdef foo_
    freopen("foo", "rt", stdin);
#endif
    ios::sync_with_stdio(false);
    int n;
    while (cin >> n) {
        FOR(i,1,n+1)
            G[i].clear();
        FOR(_,0,n-1) {
            int u,v; cin >> u >> v;
            G[u].push_back(v);
            G[v].push_back(u);
        }
        memset(dp,-1,sizeof(dp));
        cout << dfs(1,-1,0) << endl;
    }
    return 0;
}


Measured memory_bytes: 14848
#include <iostream>
#include <set>

using namespace std;

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

    set<int> s;
    for (int i = 0; i < n; ++i) {
        int t;
        cin >> t;
        s.insert(t);
    }
    cout << s.size() << '\n';
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
 
const double pi = 3.141592653589793238462643383279;
using namespace std;
//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<long long, long long> PLL;
typedef pair<int, PII> TIII;
typedef long long LL;
typedef unsigned long long ULL;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;
 
 
//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SQ(a) ((a)*(a))
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
 
 
//repetition
//------------------------------------------
#define FOR(i,s,n) for(int i=s;i<(int)n;++i)
#define REP(i,n) FOR(i,0,n)
#define MOD 1000000007
 
 
#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define trav(a, x) for(auto& a : x)
#define all(x) x.begin(), x.end()
#define sz(x) (int)(x).size()
 
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
 
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)

#define EPS 1e-10
//ここから編集
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(6);

  string t; cin >> t;
  int ct=0;
  int ans = 0;
  for(int i=0; i<t.size(); i++){
    if(t[i] == 'R') ct++;
    else ct = 0;
    ans = max(ans, ct);
  }
  cout << ans << endl;
  return 0;
}


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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()

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

    // start
    int a, b, c;
    cin >> a >> b >> c;
    if (a == b)
        cout << c << endl;
    else if (b == c)
        cout << a << endl;
    else
        cout << b << endl;
    // end

    return 0;
}


Measured memory_bytes: 256
from collections import deque
import sys

H, W = map(int, input().split())
c_h, c_w = map(int, input().split())
d_h, d_w = map(int, input().split())
c_h -= 1
c_w -= 1
d_h -= 1
d_w -= 1
maze = []

for i in range(H):
    maze.append(list(input()))

check = [[-1 for i in range(W)] for j in range(H)]
number = 0

def bfs(sy, sx):
    global number
    check[sy][sx] = number
    d = deque([[sy, sx]])
    
    while d:
        y, x = d.popleft()
        
        for k, l in ([1, 0], [0, 1], [-1, 0], [0, -1]):
            new_y, new_x = y + k, x + l
            
            if new_y < 0 or H <= new_y or new_x < 0 or W <= new_x:
                continue
            
            if check[new_y][new_x] != -1:
                continue
            
            if maze[new_y][new_x] == '#':
                continue
            
            d.append([new_y, new_x])
            check[new_y][new_x] = number
    
    number += 1
    
for i in range(H):
    for j in range(W):
        if check[i][j] == -1 and maze[i][j] == '.':
            bfs(i, j)


load = [[] for i in range(number)]
for i in range(H):
    for j in range(W):
        
        if check[i][j] != -1:
            
            for k in range(-2, 3):
                for l in range(-2, 3):
                    new_y, new_x = i + k, j + l
                    
                    if new_y < 0 or H <= new_y or new_x < 0 or W <= new_x:
                        continue
                    
                    f_num = check[i][j]
                    to_num = check[new_y][new_x]
                    
                    if to_num != -1 and to_num != f_num:
                        if not to_num in load[f_num]:
                            load[f_num].append(to_num)
                            load[to_num].append(f_num)

s_num = check[c_h][c_w]
g_num = check[d_h][d_w]

if s_num == g_num:
    print(0)
    sys.exit()

dp = [-1] * number
dp[s_num] = 0

d = deque([s_num])
ans = -1
flg = False
while d:
    if flg:
        break
    
    num = d.popleft()
    
    for i in load[num]:
        if i == g_num:
            ans = dp[num] + 1
            flg = True
            break
        
        if dp[i] != -1:
            continue
            
        dp[i] = dp[num] + 1
        d.append(i)
        
print(ans)

Measured memory_bytes: 144068
#![allow(non_snake_case)]
#![allow(dead_code)]
#![allow(unused_macros)]
#![allow(unused_imports)]

use std::str::FromStr;
use std::io::*;
use std::collections::*;
use std::cmp::*;

struct Scanner<I: Iterator<Item = char>> {
    iter: std::iter::Peekable<I>,
}

macro_rules! exit {
    () => {{
        exit!(0)
    }};
    ($code:expr) => {{
        if cfg!(local) {
            writeln!(std::io::stderr(), "===== Terminated =====")
                .expect("failed printing to stderr");
        }
        std::process::exit($code);
    }}
}

impl<I: Iterator<Item = char>> Scanner<I> {
    pub fn new(iter: I) -> Scanner<I> {
        Scanner {
            iter: iter.peekable(),
        }
    }

    pub fn safe_get_token(&mut self) -> Option<String> {
        let token = self.iter
            .by_ref()
            .skip_while(|c| c.is_whitespace())
            .take_while(|c| !c.is_whitespace())
            .collect::<String>();
        if token.is_empty() {
            None
        } else {
            Some(token)
        }
    }

    pub fn token(&mut self) -> String {
        self.safe_get_token().unwrap_or_else(|| exit!())
    }

    pub fn get<T: FromStr>(&mut self) -> T {
        self.token().parse::<T>().unwrap_or_else(|_| exit!())
    }

    pub fn vec<T: FromStr>(&mut self, len: usize) -> Vec<T> {
        (0..len).map(|_| self.get()).collect()
    }

    pub fn mat<T: FromStr>(&mut self, row: usize, col: usize) -> Vec<Vec<T>> {
        (0..row).map(|_| self.vec(col)).collect()
    }

    pub fn char(&mut self) -> char {
        self.iter.next().unwrap_or_else(|| exit!())
    }

    pub fn chars(&mut self) -> Vec<char> {
        self.get::<String>().chars().collect()
    }

    pub fn mat_chars(&mut self, row: usize) -> Vec<Vec<char>> {
        (0..row).map(|_| self.chars()).collect()
    }

    pub fn line(&mut self) -> String {
        if self.peek().is_some() {
            self.iter
                .by_ref()
                .take_while(|&c| !(c == '\n' || c == '\r'))
                .collect::<String>()
        } else {
            exit!();
        }
    }

    pub fn peek(&mut self) -> Option<&char> {
        self.iter.peek()
    }
}

fn main() {
    let cin = stdin();
    let cin = cin.lock();
    let mut sc = Scanner::new(cin.bytes().map(|c| c.unwrap() as char));
    let S = sc.chars();
    let mut ans = 0;
    let mut cnt = 0;
    for i in 0..3 {
        if S[i] == 'R' {
            cnt += 1;
        } else {
            cnt = 0;
        }
        ans = max(ans, cnt);
    }
    println!("{}", ans);
}


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

int main(){
  char s[4];
  cin >> s;
  for(int i=0;i<3;i++){
    if(s[i] == '1') s[i] = '9';
    else s[i] = '1';
  }
  for(int i=0;i<3;i++){
    cout << s[i];
  }
  cout << endl;
  return 0;
}

Measured memory_bytes: 256
N = int(input())
S = [int(item) for item in input().split()]
q = int(input())
T = [int(item) for item in input().split()]


def banhei():
    cnt = 0
    for i in range(q):
        key = T[i]
        S.append(key)
        j = 0
        # print(T[i])
        while key != S[j]:
            j += 1
        if j != N:
            # print(S[j])
            cnt += 1
        S.pop()
    return cnt

print(banhei())



Measured memory_bytes: 6552
/*
 ╔═══╦═══╦═══╗
 ║╔═╗║╔══╩╗╔╗║
 ║║░║║╚══╗║║║║
 ║║░║║╔══╝║║║║
 ║╚═╝║╚══╦╝╚╝║
 ╚══╗╠═══╩═══╝
 ░░░╚╝░░░░░░░░
 */

#include <bits/stdc++.h>
#define ll					long long
#define MOD					1000000007
#define MAX					1e9
#define MIN                 -1e9
#define PI					acos(-1.0)
#define vi					vector<int>
#define vii					vector<vi>
#define vll					vector<ll>
#define mid(s,e)			(s+(e-s)/2)
#define clz(n)				__builtin_clzll(n))

using namespace std;

void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
template<typename T>
void printVec(const T &v, char sep=' ') {for (auto &i: v) cout << i << sep;}
template<typename T>
void printVecPair(const T &v, char sep=' ') {for (auto &i: v) cout << i.first <<" " << i.second<< sep;}


#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif

int main() {
	ios::sync_with_stdio(false);
 	cin.tie(0);
	int n,k;
	cin>>n>>k;
	vi h(n);
	vll dp(n+1,MAX);
	for(int& t: h) cin>>t;
	debug(h);
	dp[0] = 0;
	for(int i=0;i<n;i++) {
			for(int j=1;j<=k;j++) {
					if(i+j<n)
							dp[i+j] = min(dp[i+j], dp[i] + abs(h[i]-h[i+j]));	
			}

	}
	cout<<dp[n-1];
	return 0;
}





Measured memory_bytes: 1792
from collections import deque

def main():

    s = deque(input())
    q = int(input())

    flag = 0
    query = []

    for _ in range(q):
        temp = input().split()
        if len(temp) == 1:
            flag += 1
        else:
            query.append(temp + [flag%2])

    for q in query:
        if q[-1] == 0:
            if q[1] == "1":
                s.appendleft(q[2])
            else:
                s.append(q[2])
        else:
            if q[1] == "1":
                s.append(q[2])
            else:
                s.appendleft(q[2])

    if flag % 2 == 1:
        print("".join(list(s)[::-1]))
    else:
        print("".join(s))

main()


Measured memory_bytes: 34920
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cassert>
#include <cmath>
#include <ctime>
#include <cctype>
#include <climits>
#include <iostream>
#include <string>
#include <array>
#include <vector>
#include <map>
#include <list>
#include <queue>
#include <deque>
#include <algorithm>
#include <numeric>
#include <utility>
#include <complex>
#include <memory>
#include <functional>

using namespace std;

#define ALL(a) (a).begin(),(a).end()
#define REP(index, begin, end) for (int (index) = (begin); (index) < (end); (index)++)
#define RE(index, end) REP(index, 0, end)
#define INF INT_MAX / 3
#define DINT(x) printf(#x " = %d\n", x);
#define GETINT(x) scanf("%d", &x)

typedef vector<int> vi;
typedef vector<long long> vl;
typedef vector<double> vd;
typedef pair<int, int> pii;
typedef pair<long, long> pll;
typedef long long ll;


int main()
{
	int stu_num, bt_num;
	vi zekken;
	GETINT(stu_num);
	GETINT(bt_num);
	zekken.reserve(stu_num);
	RE(i, stu_num)
	{
		int temp;
		GETINT(temp);
		zekken.push_back(temp);
	}
	REP(bt, 1, bt_num + 1)
	{
		RE(stu, stu_num - 1)
		{
			if (zekken[stu] % bt > zekken[stu + 1] % bt)
			{
				swap(zekken[stu], zekken[stu + 1]);
			}
		}
	}
	RE(i, zekken.size())
	{
		printf("%d\n", zekken[i]);
	}
	return 0;
}

Measured memory_bytes: 3164