akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std; 
using ll = long long;
#define MOD ll(1e9+7)
vector<vector<vector<ll>>> memo(1e4+5, vector<vector<ll>> (1e2+5, vector<ll>(2, -1)));

ll dp(vector<int> &v, int i, int vv, int d, int p){
    if(i >= v.size())
        return vv == 0;
    if(memo[i][vv][p] != -1)
        return memo[i][vv][p];
    memo[i][vv][p] = 0;
    for(int j = 0; j < v[i]; j++){
        memo[i][vv][p] = (memo[i][vv][p] + dp(v, i+1, (vv+j)%d, d, 0)) % MOD;
    }
    if(p){
        memo[i][vv][p] = (memo[i][vv][p] + dp(v, i+1, (vv+v[i])%d, d, 1)) % MOD;
    }else{
        for(int j = v[i]; j < 10; j++){
            memo[i][vv][p] = (memo[i][vv][p] + dp(v, i+1, (vv+j)%d, d, 0)) % MOD;
        }   
    }   
    return memo[i][vv][p];
}

signed main() { 
    cin.tie(0);
    cin.sync_with_stdio();
    string s;
    int d; 
    cin>>s>>d;
    vector<int> v(s.size());
    for(int i = 0; i < s.size(); i++){
        v[i] = s[i]-'0';
    }
    cout<<(dp(v, 0, 0, d, 1)+MOD-1)%MOD;
}


Measured memory_bytes: 59136
import java.util.Arrays;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int a = scanner.nextInt();
        int b = scanner.nextInt();
        int c = scanner.nextInt();
        int k = scanner.nextInt();

        int[] arr = {a, b, c};
        Arrays.sort(arr);
        for (int i = 0; i < k; i++) arr[2] *= 2;
        System.out.println(Arrays.stream(arr).sum());
    }
}

Measured memory_bytes: 26708
n = int(input())

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

x = [0] * n
tmp = 0

for i in range(n):
    tmp += (-1) ** i * A[i]
x[0] = tmp

for i in range(n-1):
    x[i+1] = 2 * A[i] - x[i]

print(' '.join(map(str, x)))

Measured memory_bytes: 19144
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int m = sc.nextInt();
        char[][] s = new char[n][m];
        for(int i = 0 ; i < n ; i++) s[i] = sc.next().toCharArray();
        // マス(n, m)より上or下or左or右にいくつの連続した空マスが存在するか
        int[][] top = new int[n][m];
        int[][] bottom = new int[n][m];
        int[][] left = new int[n][m];
        int[][] right = new int[n][m];
        for(int i = 0; i < n; i++) {
            int cnt = 0;
            for(int j = 0; j < m; j++) {
                left[i][j] = cnt;
                if(s[i][j] == '.') cnt++;
                else cnt = 0;
            }
            cnt = 0;
            for(int j = m - 1; j >= 0; j--) {
                right[i][j] = cnt;
                if(s[i][j] == '.') cnt++;
                else cnt = 0;
            }
        }
        for(int i = 0; i < m; i++) {
            int cnt = 0;
            for(int j = 0; j < n; j++) {
                top[j][i] = cnt;
                if(s[j][i] == '.') cnt++;
                else cnt = 0;
            }
            cnt = 0;
            for(int j = n - 1; j >= 0; j--) {
                bottom[j][i] = cnt;
                if(s[j][i] == '.') cnt++;
                else cnt = 0;
            }
        }
        int ans = 0;
        for(int i = 0; i < n; i++) {
            for(int j = 0; j < m; j++) {
                if(s[i][j] == '.') {
                    ans = Math.max(ans, left[i][j] + right[i][j] + top[i][j] + bottom[i][j] + 1);
                }
            }
        }
        System.out.println(ans);
    }
}

Measured memory_bytes: 142432
import sys
input = sys.stdin.readline

if __name__ == '__main__':
    N, K = map(int, input().rstrip().split())
    H = list(map(int, input().rstrip().split()))
    if K >= N:
        print(0)
    else:
        sorted_H = sorted(H, reverse=False)[:N-K]
        print(sum(sorted_H))
        

Measured memory_bytes: 26024
import random
import time
import copy
import math
start=time.time()
d=int(input())
c=list(map(int,input().split()))
s=[]
cli=[]
for i in range(d+1):
  ch=[]
  for j in c:
    ch.append(i*j)
  cli.append(ch)
for i in range(d):
  s.append(list(map(int,input().split())))
last=[0]*26
score=0
solution=[]
for day in range(1,d+1):
  co=[]
  dla=[]
  down=0
  for (i,j) in zip(last,c):
    down+=(day-i)*j
  for (i,j) in zip(last,c):
    dla.append(down-(j*(day-i)))
  for con in range(26):
    co.append(s[day-1][con]-dla[con])
  choice=co.index(max(co))
  score+=co[choice]
  last[choice]=day
  #print(choice+1)
  #print(score)
  solution.append(choice)
#print(score)
stemp=2500
etemp=100
def tem():
  return stemp-((stemp-etemp)*(time.time()-start)/1.9)
while time.time()-start<1.95:
  
  sc=0
  sol=copy.deepcopy(solution)
  for x in [random.randrange(d) for i in range(1)]:
    sol[x]=random.randrange(26)
  last=[0]*26
  for (day,i) in zip(range(1,d+1),sol):
    sc+=s[day-1][i]
    last[i]=day
    for (i,j) in zip(last,range(26)):
      sc-=cli[day-i][j]
  try:
    prob = math.exp((sc-score)/tem())
  except:
    prob=0
  #print("{} {}".format(sc,prob))
  if prob>random.random():
    solution=copy.deepcopy(sol)
    score=sc
    #print(score)
for i in solution:
  print(i+1)
#print(sco)


Measured memory_bytes: 10300
import java.util.*;

public class Main {

    public static Scanner in = new Scanner(System.in);
    public static int n = 0, k = 0;
    public static int[] weight = new int[101];
    public static int[] benifit = new int[101];
    public static long[][] dp = new long[101][100001];

    public static long solve(int idx, int rem) {
        if (idx == n) {
            return 0;
        } else {
            if (dp[idx][rem] == -1) {
                long c1 = solve(idx + 1, rem);
                long c2 = 0;
                if (weight[idx] <= rem) {
                    c2 = (solve(idx + 1, rem - weight[idx]) + benifit[idx]);
                }
                return dp[idx][rem] = Math.max(c2, c1);
            } else {
                return dp[idx][rem];
            }
        }
    }

    public static void main(String[] args) {
        for (int i = 0; i < 101; i++) {
            for (int j = 0; j < 100001; j++) {
                dp[i][j] = -1;
            }
        }
        n = in.nextInt();
        k = in.nextInt();;
        for (int i = 0; i < n; i++) {
            weight[i] = in.nextInt();
            benifit[i] = in.nextInt();
        }
        System.out.println(solve(0, k));
    }

}


Measured memory_bytes: 127956
#include <iostream>
using namespace std ;
using ll = long long ;

int main(){
	ll n ; cin >> n ;
	ll mn = 100000000000000000 ;
	for(int i=0;i<5;i++){
		ll sub ; cin >> sub ;
		if(sub<mn) mn = sub ;
	}
	cout << (n-1)/mn+5 << endl ;
}

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

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

bool check[100][100][4] = { false };
int cost[100][100][4];

class Node{
public:
	int x;
	int y;
	int way;//0 -> up, 1 -> right, 2 -> down, 3-> left
	int num;

	Node(){ x = 0; y = 0; way = 0; num = 0; }
	Node(int x, int y, int way, int num) : x(x), y(y), way(way), num(num){}

};

bool operator< (const Node &n1, const Node &n2){
	return n1.num < n2.num;
}

bool operator>(const Node &n1, const Node &n2){
	return n1.num > n2.num;
}

int main(void){

	int w, h;
	int map[100][100];
	int c[4];

	while (cin >> w >> h, w, h){
		for (int i = 0; i < 100; i++){
			for (int j = 0; j < 100; j++){
				cost[j][i][3] = cost[j][i][2] = cost[j][i][1] = cost[j][i][0] = INF;
			}
		}

		for (int i = 0; i < 100; i++){
			for (int j = 0; j < 100; j++){
				check[j][i][3] = check[j][i][2] = check[j][i][1] = check[j][i][0] = false;
			}
		}

		for (int j = 0; j < h; j++){
			for (int i = 0; i < w; i++){
				cin >> map[j][i];
			}
		}

		cin >> c[0] >> c[1] >> c[2] >> c[3];

		priority_queue<Node, vector<Node>, greater<vector<Node>::value_type> > que;

		que.push(Node(0, 0, 1, 0));

		while (!que.empty()){
			Node buff = que.top();
			que.pop();

			if (check[buff.y][buff.x][buff.way]) continue;
			check[buff.y][buff.x][buff.way] = true;
			cost[buff.y][buff.x][buff.way] = min(cost[buff.y][buff.x][buff.way] , buff.num);

			if ((buff.x == w - 1) && (buff.y == h - 1)){
				cout << buff.num << endl;
				break;
			}

			if (map[buff.y][buff.x] != 4){
				int next_way = (buff.way + map[buff.y][buff.x]) % 4;
				int next_x = buff.x + dx[next_way];
				int next_y = buff.y + dy[next_way];
				if (0 <= next_x && next_x < w && 0 <= next_y && next_y < h)
					que.push(Node(next_x, next_y, next_way, buff.num));
			}

			for (int i = 0; i < 4; i++){
				int next_x = buff.x + dx[i];
				int next_y = buff.y + dy[i];
				if (0 <= next_x && next_x < w && 0 <= next_y && next_y < h)
					que.push(Node(next_x, next_y, i, buff.num + c[(4 + i - buff.way) % 4]));

			}


		}
		/*
		for (int j = 0; j < h; j++){
			for (int i = 0; i < w; i++){
				cout << min(cost[j][i][0], min(cost[j][i][1], min(cost[j][i][2], cost[j][i][3]))) << "\t";
			}
			cout << endl;
		}
		*/

	}

	return 0;
}

Measured memory_bytes: 1664
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Scanner;

//atcoderはScannerクラスのsc.next()で行ける
public class Main {
    ArrayList<int[]> arrayList = new ArrayList<>();

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] p = new int[n];
        int[] q = new int[n];
        for (int i = 0; i < n; i++) {
            p[i] = sc.nextInt();
        }
        for (int k = 0; k < n; k++) {
            q[k] = sc.nextInt();
        }
        int[] data  = new int[n];
        for (int i = 1 ; i<=n ; i++){
            data[i-1]=i;
        }
        int cnt = 0;
        int a=0,b=0;
        do {
            cnt++;
            if (Arrays.equals(p,data)){
                a = cnt;
            }
            if (Arrays.equals(q,data)){
                b = cnt;
            }
        }
        while (findNextPermutation(data));
        System.out.println(Math.abs(a-b));

    }

    // Function to swap the data
    // present in the left and right indices
    public static int[] swap(int data[], int left, int right) {

        // Swap the data
        int temp = data[left];
        data[left] = data[right];
        data[right] = temp;

        // Return the updated array
        return data;
    }

    // Function to reverse the sub-array
    // starting from left to the right
    // both inclusive
    public static int[] reverse(int data[], int left, int right) {

        // Reverse the sub-array
        while (left < right) {
            int temp = data[left];
            data[left++] = data[right];
            data[right--] = temp;
        }

        // Return the updated array
        return data;
    }

    // Function to find the next permutation
    // of the given integer array
    public static boolean findNextPermutation(int data[]) {

        // If the given dataset is empty
        // or contains only one element
        // next_permutation is not possible
        if (data.length <= 1)
            return false;

        int last = data.length - 2;

        // find the longest non-increasing suffix
        // and find the pivot
        while (last >= 0) {
            if (data[last] < data[last + 1]) {
                break;
            }
            last--;
        }

        // If there is no increasing pair
        // there is no higher order permutation
        if (last < 0)
            return false;

        int nextGreater = data.length - 1;

        // Find the rightmost successor to the pivot
        for (int i = data.length - 1; i > last; i--) {
            if (data[i] > data[last]) {
                nextGreater = i;
                break;
            }
        }

        // Swap the successor and the pivot
        data = swap(data, nextGreater, last);

        // Reverse the suffix
        data = reverse(data, last + 1, data.length - 1);

        // Return true as the next_permutation is done
        return true;
    }
}

Measured memory_bytes: 36284
#include<bits/stdc++.h>
#define int long long
#define pb emplace_back
#define mp make_pair
#define mt make_tuple
#define all(v) v.begin(),v.end()
#define rep(i,start,lim) for(long long (i)=(start);i<(lim);i++)
#define revrep(i,n) for(long long i=n-1;i>=0;i--)
#define boost ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define osit ostream_iterator<int> output (cout," ")
#define endl '\n'
#define f first
#define s second
#define PI 3.141592653589793
#define MOD 1000000007
#define set0(x) memset(x,0,sizeof(x))
#define set1(x) memset(x,1,sizeof(x))
using namespace std;
typedef vector<int> vi;
typedef list<int> li;
typedef pair<int,int> ii;
typedef vector<ii> vii;
typedef tuple<int, int, int> iii;
template<typename T> T gcd(T a,T b){if(a==0) return b; return gcd(b%a,a);}
template<typename P> P dectobin(P a){if(a==0)return 0; else return(a%2 + 10*dectobin(a/2));}
template<typename Y> Y bintodec(Y a){int ans=0,b=1,t=a; while (t){int ld=t%10; t/=10;ans+=ld* b;b=b*2;} return ans; }
template<typename H> H modExp(H x, H n){ int r=1; while(n>0){if(n%2==1){r=(r*x)%MOD;}x=(x*x)%MOD;n/=2;}return r;}
template<typename T> T isPowerOfTwo(T x){return x && (!(x & (x - 1)));}	
template<typename T> T lcm(T a,T b) {return a*b/gcd(a,b);}
//template<typename T> T extendedEuclid(T A,T B){if(B==0){d=A; x=1;y=0;}else{ extendedEuclid(B,A%B);int temp=x; x=y; y=temp-(A
//B)*y;}}
int32_t main(){
	boost;osit;
	int k;
	cin>>k;
	string s;
	cin>>s;
	int n=s.length();
	rep(i,0,min(k,n)){
		cout<<s[i];
	}
	if(n>k) cout<<"...";
	return 0;
}

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

using namespace std;

#define FOR(i,l,r) for( int i = l; i < r; i++ )
#define vi vector<int>
#define vvi vector<vi>
#define pb push_back
#define imi INT_MIN
#define li long long int

int n;

class segtree {
    public :
        vector<li> tree;
        segtree() {
            tree.assign(4*n+4,imi);
        }
        li func( li a, li b ) { 
            return max(a,b);
        }
        void recalc( int node ) {
            tree[node] = func(tree[2*node],tree[2*node+1]);
        }
        void update( int node, int l, int r, int index, li val ) {
            if( l == r ) {
                tree[node] = val;
                return;
            }
            int m = (l+r)/2;
            if( index > m ) update(2*node+1,m+1,r,index,val);
            else update(2*node,l,m,index,val);
            recalc(node);
        }
        li query( int node, int l, int r, int ql, int qr ) {
            if( ql > qr ) return imi; 
            if( l == ql && r == qr ) return tree[node];
            int m = (l+r)/2;
            return func(query(2*node,l,m,ql,min(qr,m)),query(2*node+1,m+1,r,max(ql,m+1),qr));
        }
};

int main() {
    cin>>n;
    vi h(n,0);
    vi a(n,0);
    vector<li> dp(n,0);
    FOR(i,0,n) cin>>h[i];
    FOR(i,0,n) {
        cin>>a[i];
        dp[i] = a[i];
    }
    segtree tr;
    FOR(i,0,n) {
        h[i]--;
        // cout<<dp[i]<<"\n";
        if( h[i]-1 >= 0 ) dp[i] += max(0ll,tr.query(1,0,n-1,0,h[i]-1));
        // cout<<dp[i]<<"\n";
        tr.update(1,0,n-1,h[i],dp[i]);
    }
    // FOR(i,0,n) cout<<tr.query(1,0,n-1,0,i)<<"\n";
    li ans = imi;
    FOR(i,0,n) {
        ans = max(ans,dp[i]);
    }
    cout<<ans<<"\n";
    return 0;
}

Measured memory_bytes: 9600
//code by lynmisakura.wish to be accepted!
#include<bits/stdc++.h>
using namespace std;

typedef long long ll;

double PI = 3.1415926535897932;

// Cooley–Tukey FFT algorithm O(N log N)
vector<complex<double>> fft(vector<complex<double>> a, bool inverse = false) {
    int n = a.size();
    int h = 0; // h = log_2(n)
    for (int i = 0; 1 << i < n; i++) h++;
    // バタフライ演算用の配置入れ替え
    for (int i = 0; i < n; i++) {
        int j = 0;
        for (int k = 0; k < h; k++) j |= (i >> k & 1) << (h - 1 - k);
        if (i < j) swap(a[i], a[j]);
    }
    // バタフライ演算
    for (int b = 1; b < n; b *= 2) {
        // 第 log_2(b) + 1 段
        // ブロックサイズ = b * 2
        for (int j = 0; j < b; j++) {
            // ブロック内 j 個目
            // 重み w = (1 の原始 2b 乗根の j 乗)
            complex<double> w =
                polar(1.0, (2 * M_PI) / (2 * b) * j * (inverse ? 1 : -1));
            for (int k = 0; k < n; k += b * 2) {
                // k を先頭とするブロック
                complex<double> s = a[j + k];         // 前
                complex<double> t = a[j + k + b] * w; // 後
                a[j + k] = s + t;                     // 前の更新
                a[j + k + b] = s - t;                 // 後の更新
            }
        }
    }
    // 逆変換時にサイズで割る調整
    if (inverse)
        for (int i = 0; i < n; i++) a[i] /= n;
    return a;
}
// Cooley–Tukey FFT algorithm O(N log N)
vector<complex<double>> fft(vector<double> a, bool inverse = false) {
    vector<complex<double>> a_complex(a.size());
    for (int i = 0; i < a.size(); i++) a_complex[i] = complex<double>(a[i], 0);
    return fft(a_complex, inverse);
}
 
// FFT による畳み込み O(N log N)
vector<double> convolve(vector<double> a, vector<double> b) {
    int s = a.size() + b.size() - 1; // 畳み込み結果のサイズ
    int t = 1; // FFT に使う配列のサイズ（2 の累乗）
    while (t < s) t *= 2;
    a.resize(t); // FFT するためにリサイズ
    b.resize(t); // FFT するためにリサイズ
    vector<complex<double>> A = fft(a);
    vector<complex<double>> B = fft(b);
    for (int i = 0; i < t; i++) {
        A[i] *= B[i]; // 畳み込み結果の FFT 結果を得る
    }
    A = fft(A, true); // IFFT で畳み込み結果を得る
    a.resize(s);      // 畳み込み結果を入れるためにリサイズ
    for (int i = 0; i < s; i++) a[i] = A[i].real(); // 実部が答え
    return a;
}

int main(void){
    cout << setprecision(20);
    //入力
    long long N,M;scanf("%lld %lld",&N,&M);
    vector<long long> A(N);
    for(int i = 0;i < N;i++)scanf("%lld",&A[i]);
    vector<double> a(100010,0.0),b(100010,0.0);
    for (int i = 0; i < N; ++i)
    {
        a[A[i]] += 1.000;
        b[A[i]] += 1.000;
    }

    auto c = convolve(a,b);
    long long sz = c.size();

    long long ans = 0;
    for(long long i = sz-1;i >= 0;i--){
        ll X = (ll)(c[i] + 0.5);
        if(X <= M){
            ans += i * X;
            M -= X;
        }else{
            ans += i * M;
            break;
        }
    }

    printf("%lld\n",ans);
    return 0;
}


Measured memory_bytes: 23000
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<stack>
#include<string>
#include<map>

#define mod 1000000007
#define rep(i,k,N) for(int i=k;i<N;i++)
#define MP make_pair
#define PB push_back

using namespace std;

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

int main(){
    string S;
    cin>>S;
    int lose_cnt=0;
    rep(i,0,S.size()){
        if(S[i]=='x')lose_cnt++;
    }
    if(lose_cnt<=7)cout<<"YES";
    else cout<<"NO";
    return 0;
}

Measured memory_bytes: 256
(() -> begin
  n = readline() |> x->parse.(Int,x)
  s = readline()
  ans = count("R", s) * count("G", s) * count("B", s)
  for i in 1:n-2
    for j in i+1:n-1
      k = 2 * j - i
      if k <= n && s[i] != s[j] && s[j] != s[k] && s[k] != s[i]
        ans -= 1
      end
    end
  end
  println(ans)
end)()


Measured memory_bytes: 165804
#include <iostream>
#include <algorithm>
#include <bitset>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <cstring>
#include <utility>
#include <vector>
#include <complex>
#include <valarray>
#include <fstream>
#include <cassert>
#include <cmath>
#include <functional>
#include <iomanip>
#include <numeric>
#include <climits>
#include <random>

using namespace std;

int main()
{
    string S;

    cin >> S;

    if(S == "AAA"){
        cout << "No" << endl;
    }
    if(S == "BBB"){
        cout << "No" << endl;
    }
    if(S == "AAB"){
        cout << "Yes" << endl;
    }
    if(S == "ABA"){
        cout << "Yes" << endl;
    }
    if(S == "BAA"){
        cout << "Yes" << endl;
    }
    if(S == "ABB"){
        cout << "Yes" << endl;
    }
    if(S == "BAB"){
        cout << "Yes" << endl;
    }
    if(S == "BBA"){
        cout << "Yes" << endl;
    }

    return 0;
}

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

int main(){
  int H,W,A,B; cin >> H >> W >> A >> B;
  for(int i=0; i<B; i++){
    for(int j=0; j<A; j++) cout << "0";
    for(int j=0; j<W-A; j++) cout << "1";
    cout << endl;
  }
  for(int i=0; i<H-B; i++){
    for(int j=0; j<A; j++) cout << "1";
    for(int j=0; j<W-A; j++) cout << "0";
    cout << endl;
  }
}

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

#define int long long
#define pb push_back
#define mp make_pair
#define fr first
#define sc second
#define Rep(i, n) for( int i = 0; i < (n); i++ )
#define Rrep(i, a, n) for( int i = (a); i < (n); i++ )
#define All(v) v.begin(), v.end()

typedef pair<int, int> Pii;
typedef pair<int, Pii> Pip;
const int INF = 1107110711071107;

signed main() {
    string s;
    cin >> s;
    bool flag = false;
    Rep(i, (int)s.size()-1) {
        if ( s[i] == 'A' && s[i+1] == 'C' ) flag = true;
    }

    if ( flag ) cout << "Yes" << endl;
    else cout << "No" << endl;
}


Measured memory_bytes: 256
from bisect import bisect_left
n=int(input())
l=list(map(int,input().split()))
l.sort()
ans=0
for i in range(n):#一番短い棒
  for j in range(i+1,n):#二番目に短い棒
    #1+2番目の棒の長さより短く、2番目に短い棒より長い棒の範囲を探す
    ans += bisect_left(l,l[i]+l[j])-(j+1)
print(ans)

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

int balls[10];

int dfs(int i, int a, int b){
	if(i >= 10)
		return 1;
	
	int res = 0;
	if(a < balls[i])
		res |= dfs(i + 1, balls[i], b);
	if(b < balls[i])
		res |= dfs(i + 1, a, balls[i]);
	return res;
}

int main() {
	int n;
	cin >> n;
	for(int i = 0; i < n; ++i){
		for(int j = 0; j < 10; ++j)
			scanf("%d", &balls[j]);
		int ans = dfs(0, 0, 0);
		if(ans)
			cout << "YES" << endl;
		else
			cout << "NO" << endl;
	}
	return 0;
}

Measured memory_bytes: 1228
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}
fn main(){
    input!{
        a:i64,
        b:i64,
        c:i64,
    }
    if b / a < c {
        println!("{}",b/a);
    } else {
        println!("{}",c);
    }
}

Measured memory_bytes: 4352
/*Lucky_Glass*/
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;

const int N=1e5;
const long long MOD=(long long)1e9+7;

int n;
char str[2*N+10];
int tmp[2*N+10];
long long an$s,fac;

int main(){
	scanf("%d%s",&n,str+1);
	n*=2;
	int cnt=0;an$s=fac=1;
	for(int i=1;i<=n;i++){
		if(2*i<=n) fac=fac*i%MOD;
		if(tmp[i]) continue;
		if((cnt&1)^(str[i]=='W')){
			if(!cnt){
				printf("0\n");
				return 0;
			}
			an$s=an$s*cnt%MOD;
			cnt--;
		}
		else
			cnt++;
	}
	if(cnt){
		printf("0\n");
		return 0;
	}
	printf("%lld\n",fac*an$s%MOD);
	return 0;
}

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

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

    int ab = a-b;
    int ac = a-c;
    int bc = b-c;
    if ( (ab == 0 && ac != 0 && bc != 0) ||
         (ab != 0 && ac == 0 && bc != 0) ||
         (ab != 0 && ac != 0 && bc == 0) )
        printf("Yes\n");
    else
        printf("No\n");

    return EXIT_SUCCESS;
}


Measured memory_bytes: 128
using System;

namespace ChokudaiScanner
{
    class MainClass
    {
        static void Main()
        {
            Scanner cin = new Scanner();

            string N = cin.Next();

            if (N == "ABC")
            {
                Console.WriteLine("ARC");
            }
            else if(N=="ARC")
            {
                Console.WriteLine("ABC");
            }
        }
    }

    class Scanner
    {
        string[] s;
        int i;

        char[] cs = new char[] { ' ' };

        public Scanner()
        {
            s = new string[0];
            i = 0;
        }

        public string Next()
        {
            if (i < s.Length) return s[i++];
            string st = Console.ReadLine();
            while (st == "") st = Console.ReadLine();
            s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
            if (s.Length == 0) return Next();
            i = 0;
            return s[i++];
        }

        public string[] ArrayNext(int N)
        {
            string[] Array = new string[N];
            for (int i = 0; i < N; i++)
            {
                Array[i] = Next();
            }
            return Array;
        }

        public int NextInt()
        {
            return int.Parse(Next());
        }
        public int[] ArrayInt(int N, int add = 0)
        {
            int[] Array = new int[N];
            for (int i = 0; i < N; i++)
            {
                Array[i] = NextInt() + add;
            }
            return Array;
        }

        public long NextLong()
        {
            return long.Parse(Next());
        }

        public long[] ArrayLong(int N, long add = 0)
        {
            long[] Array = new long[N];
            for (int i = 0; i < N; i++)
            {
                Array[i] = NextLong() + add;
            }
            return Array;
        }

        public double NextDouble()
        {
            return double.Parse(Next());
        }


        public double[] ArrayDouble(int N, double add = 0)
        {
            double[] Array = new double[N];
            for (int i = 0; i < N; i++)
            {
                Array[i] = NextDouble() + add;
            }
            return Array;
        }
    }
}

Measured memory_bytes: 17616
import java.util.*;
public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int k=sc.nextInt();
        int[] arr={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
        System.out.println(arr[k-1]);
    }
}

Measured memory_bytes: 21716
//おまじない
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#define INF 1e9+7
#define roop(i,m,n) for(int i=m;i<n;i++)
#define mroop(i,m,n) for(int i=m;i<n;i--)
#define NO cout<<"NO"<<endl;
#define YES cout << "YES"<<endl;
#define No cout << "No"<<endl;
#define Yes cout << "Yes"<<endl;
using namespace std;
typedef long long int ll;

//(int)'a'は97 (int)'A'は65
//おまじない



int main() {
	
	int x, y,z;
	cin >> x >> y>>z;

	if ((x * 100 + y * 10 + z) % 4 == 0) {
		YES;
	}
	else {
		NO;
	}


	return 0;
}


Measured memory_bytes: 256
/*
freopen("input.txt","r",stdin);
freopen("output.txt","w",stdout);
*/
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define pb push_back
#define inout freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
//#define 
int main(){
	//inout
	int n,k;
	cin>>n>>k;
   	ll a[n+1];
	ll b[n+1];
	for(int i=1;i<n+1 ;i++)
		cin>>b[i];

    for(int i=0;i<=n;i++)
		a[i] = INT_MAX;
	a[1]=0;
	for(int i=1;i<=n;i++){
		for(int j=i+1 ;j<=i+k ;j++){
			if(j<=n){
				ll ans= abs(b[j] - b[i]) + a[i] ;
				a[j]  = min(a[j] ,ans) ;
			}
		}
	}
	cout<<a[n]<<"\n";
}

Measured memory_bytes: 1792
K, S = [int(a) for a in input().split()]

cnt = 0
for x in range(0,K+1):
  if x > S:
    continue
  for y in range(0,K+1):
    if x+y > S:
      continue
    elif x+y+K < S:
      continue
    else:
      cnt +=1
        
print(cnt)

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

int main() {

 int A,B,C,K;

 cin >> A >> B >> C >> K;
 for(int i=0;i<=K;++i){
   for(int j=0;j<=K-i;++j){
     int a = A; int b = B; int c = C;
     if(b*pow(2,i) > a*pow(2,j) && c*pow(2,(K-i-j)) > b*pow(2,i)){
       cout << "Yes" << endl;
       return 0;
     }
   }
 }
 cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 4024
a,b,c,d = map(int,input().split())
A = set()
B = set()
A.add(a)
A.add(b)
B.add(c)
B.add(d)
for i in {-1,0,1}:
    A.add(i)
    B.add(i)

o = set()
for j in A:
    for k in B:
        if a <= j <= b and c <= k <= d:
            o.add(j*k)
print(max(o))

Measured memory_bytes: 61904
#include <bits/stdc++.h>
using namespace std;
#define iinf 2000000000
#define linf 1000000000000000000LL
#define ulinf 10000000000000000000ull
#define MOD1 1000000007LL
#define mpr make_pair
typedef long long LL;
typedef unsigned long long ULL;
typedef unsigned long UL;
typedef unsigned short US;
typedef pair < int , int > pii;
clock_t __stt;
inline void TStart(){__stt=clock();}
inline void TReport(){printf("\nTaken Time : %.3lf sec\n",(double)(clock()-__stt)/CLOCKS_PER_SEC);}
template < typename T > T MIN(T a,T b){return a<b?a:b;}
template < typename T > T MAX(T a,T b){return a>b?a:b;}
template < typename T > T ABS(T a){return a>0?a:(-a);}
template < typename T > void UMIN(T &a,T b){if(b<a) a=b;}
template < typename T > void UMAX(T &a,T b){if(b>a) a=b;}
int n,a[200005];
LL s,cnt;
map < LL , int > mp;
int main(){
    // inputting start
    // 数据结构记得初始化！ n，m别写反！
    scanf("%d",&n);
	int i,j,k;
	for(i=0;i<n;++i){
		scanf("%d",a+i);
	}
    #ifdef LOCAL
        TStart();
    #endif
    // calculation start
    // 数据结构记得初始化！ n，m别写反！
    for(i=0;i<n;++i){
		s+=(LL)a[i];
		++mp[s];
	}
	++mp[0];
	map < LL , int > ::iterator it;
	for(it=mp.begin();it!=mp.end();++it){
		LL v=it->second;
		cnt+=(v*(v-1LL))/2LL;
	}
	cout<<cnt;
    #ifdef LOCAL
        TReport();
    #endif
    return 0;
}

Measured memory_bytes: 13568
import sys
input=sys.stdin.readline
import itertools
N,M,Q=map(int,input().split())
T=[]

H=0
for y in range(Q):
    a,b,c,d=map(int,input().split())
    t=(a,b,c,d)
    T.append(t)
A=[x+1 for x in range(M)]
B=list(itertools.combinations_with_replacement(A,N))
C=len(B)
for z in range(C):
    E=B[z]
    G=0
    for l in range(Q):
        F=T[l]
        g=F[0]-1
        h=F[1]-1
        i=F[2]
        if E[h]-E[g]==i:
            G+=F[3]
    if G>=H:
        H=G
print(H)



Measured memory_bytes: 21512
object Main {
  def main(args: Array[String]): Unit = {
    val Array(a, b) = io.StdIn.readLine().split(" ").map(_.toInt)
    val (x, y) = extendedEuclidean(a, b)
    println(s"$x $y")
  }
  def extendedEuclidean(a: Int, b: Int): (Int, Int) = {
    def loop(pr: Int, r: Int, ps: Int, s: Int, pt: Int, t: Int): (Int, Int) =
      if (r == 0) (ps, pt)
      else {
        val q = pr / r
        loop(r, pr-q*r, s, ps-q*s, t, pt-q*t)
      }
    loop(a, b, 1, 0, 0, 1)
  }
}

Measured memory_bytes: 43964
import os
import sys

import numpy as np

if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")

sys.setrecursionlimit(10 ** 9)
INF = float("inf")
IINF = 10 ** 18
MOD = 10 ** 9 + 7
# MOD = 998244353


N, M = list(map(int, sys.stdin.buffer.readline().split()))
A = list(map(int, sys.stdin.buffer.readline().split()))

counts = np.bincount(A)
size = 1 << len(counts).bit_length() + 1
counts2 = np.rint(np.fft.irfft(np.fft.rfft(counts, size) ** 2))

cnt = 0
ans = 0
for i in np.where(counts2 > 0)[0][::-1]:
    cnt += counts2[i]
    ans += i * counts2[i]
    if cnt > M:
        ans -= i * (cnt - M)
        break
print(int(ans))


Measured memory_bytes: 33004
/**
 *
 * AtCoder Beginner Contest 105 - Problema B: Cakes and Donuts (https://abc105.contest.atcoder.jp/tasks/abc105_b)
 *
 * Check if its possible spend exactly N dollars buying cakes and donuts for 4 and 7 dollars,
 * respectively.
 *
 * DP solution: coin change with coins { 4, 7 }.
 */
#include <iostream>

using namespace std;

const int MAX { 110 };

bool possible[MAX];

void solve(int N)
{
    possible[0] = true;

    for (int i = 1; i < MAX; ++i)
        possible[i] = (possible[i - 4] | possible[i - 7]);

    cout << (possible[N] ? "Yes" : "No") << endl;
}

int main()
{
    ios::sync_with_stdio(false);

    int N;
    cin >> N;

    solve(N);

    return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
int main() {

	long a,b,c;
	cin >> a >> b >> c;
	long ans = 0;
	if (c <= a + b) ans = c + b;
	else {
		int p = c - a - b;
		ans = c + b - p + 1;
	}

	cout << ans << endl;
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <complex>
#include <string>
#include <vector>
#include <array>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
#include <iterator>
#include <memory>
#include <regex>
using namespace std;

int main()
{
    int n;
    cin >> n;
    vector<int> b(n-1);
    for(int i=0; i<n-1; ++i)
        cin >> b[i];

    vector<int> a(n, INT_MAX);
    for(int i=0; i<n-1; ++i){
        a[i] = min(a[i], b[i]);
        a[i+1] = min(a[i+1], b[i]);
    }
    int ans = accumulate(a.begin(), a.end(), 0);
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
const ll mod=1e9+7;
const ll N = 2e5+10;



void solve(){
            
      string s;cin>>s;
      set<char>st;
      for(auto &k:s){
          st.insert(k);
      }
      st.size()==1?cout<<"No":cout<<"Yes";
      
  
           
}


int main(){
    
        #ifdef debug
            freopen("input.txt", "r", stdin);
            freopen("output.txt", "w", stdout); 
            
        #endif
            ios_base::sync_with_stdio(0);
            cin.tie(0);cout.tie(0);
            
            
                solve();
            
            
            
        return 0;
}


Measured memory_bytes: 256
n,m = map(int,input().split())
x = [list(map(int,input().split()))for i in range(n)]
y = [list(map(int,input().split()))for i in range(m)]
ans = []
for a,b in x:
    dif = 10**9
    index = -1
    for i in range(m):
        c,d = y[i]
        if dif>abs(a-c)+abs(b-d):
            dif=abs(a-c)+abs(b-d)
            index = i+1
    ans.append(index)
for i in ans:
    print(i)

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

/*Range Sum,Range Add*/
/*区間和、区間加算*/

class RSAQ{
public: 
  typedef long long ll;

  //マージ可能な主データ型
  struct D{
    ll value;
    D():value(0){} /*適切な値にする!!!!!!*/
    D(ll value):value(value){}
    bool operator < (D a)const {return value < a.value;}
  };

  //遅延用の型  
  struct T{
    int type; //0 - empty   , 1 - update
    ll value;
    T():type(0),value(0){}
    T(int type,ll value):type(type),value(value){}
  };

  
  int n, n_;
  vector<D> dat;
  vector<T> td;
  D returnD = D(0); // 範囲外の時に返す値。
  
  RSAQ(){n=-1;}
  RSAQ(int n_):n_(n_){
    n=1;
    while(n < n_) n *= 2;
    td.resize(2*n-1,T());
    dat.resize(2*n-1,D());
  }
  
  inline D merge(const D &a,const D &b)const{return a.value + b.value;}
  
  void delay(int k,int len){
    if(td[k].type==0) return;
    ll type = td[k].type;
    ll v = td[k].value;
    td[k].type = 0;
    td[k].value = 0;
    len /= 2;
    {
      int l = k*2+1;
      dat[l].value += v * len;
      td[l].type = type;
      td[l].value += v;
    }
    {
      int r = k*2+2;
      dat[r].value += v * len;
      td[r].type = type;
      td[r].value += v;
    }
  }

  D write(int k, D x, int len){
    dat[k].value += x.value * len;
    td[k].type = 1;
    td[k].value += x.value;
    return dat[k];
  }
  
  D dfs(int a, int b, D x, bool flag, int k, int l, int r){
    if(r <= a||b <= l) return flag? dat[k]:returnD;
    if(a <= l && r <= b) return flag? write(k, x, r - l):dat[k];
    delay(k, r - l);
    D vl = dfs(a, b, x, flag, k*2+1, l, (l+r)/2);
    D vr = dfs(a, b, x, flag, k*2+2, (l+r)/2, r);
    return flag? (dat[k] = merge(vl, vr)):merge(vl, vr);
  }

  //[l,r)の値をx変更　query(l,r,x)
  void add(int l,int r,ll x){
    assert(l <= r);
    assert(0 <= l && l <= n);
    assert(0 <= r && r <= n);
    dfs(l, r, D(x), true, 0, 0, n);
  }
  
  //[l,r)の合計値を得る　find(a,b);
  ll get(int l,int r){
    assert(l <= r);
    assert(0 <= l && l <= n);
    assert(0 <= r && r <= n);
    D res = dfs(l, r, D(), false, 0, 0, n);
    return res.value;
  }
};


signed main(){
  int n,q;
  cin>>n>>q;
  
  RSAQ rsaq(n);

  while(q--){
    int cmd;
    cin>>cmd;
    if(cmd == 0){
      int s,t,x;
      cin>>s>>t>>x;
      rsaq.add(s-1,t,x);
    }
    
    if(cmd == 1){
      int s,t;
      cin>>s>>t;
      cout<<rsaq.get(s-1,t)<<endl;
    }
  }
  
  return 0;
}



Measured memory_bytes: 8912
#include <bits/stdc++.h>
#include<stdio.h>
using namespace std;
#define FOR(i,k,n) for(int i = (k); i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(a) begin(a),end(a)
#define MS(m,v) memset(m,v,sizeof(m))
#define D10  fixed<<setprecision(10)
typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int, int> P;
typedef long long ll;
const ll INF = 114514810;
const ll MOD = 1000000007;
const double EPS = 1e-8;
const double PI = acos(-1.0);
struct edge
{
	int to, cost;
	bool operator < (const edge& e) const { return cost < e.cost; }
	bool operator >(const edge& e) const { return cost > e.cost; }
};
int dx[] = { -1, 0, 0, 1 }; int dy[] = { 0, -1, 1, 0 };
template<class T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template<class T> T &chmax(T &a, const T &b) { return a = max(a, b); }
bool valid(int x, int y, int h, int w) { return (x >= 0 && y >= 0 && x < h&&y < w); }
///*************************************************************************************///
///*************************************************************************************///
///*************************************************************************************///

bool eq(double a, double b) { return fabs(a - b) < EPS; }
typedef complex<double> Point;
typedef vector<Point> Polygon;

namespace std
{
	bool operator < (const Point& a, const Point& b)
	{
		return real(a) != real(b) ? real(a) < real(b) : imag(a) < imag(b);
	}
}

struct Line
{
	Point a, b;
	Line(Point p, Point q) :a(p), b(q) {};
};

struct Circle
{
	Point p; double r;
	Circle(Point a, double b) :p(a), r(b) {};
};

double dot(Point a, Point b)
{
	return real(conj(a)*b);
}

double cross(Point a, Point b)
{
	return imag(conj(a)*b);
}

int ccw(Point a, Point b, Point c)
{
	b -= a; c -= a;
	if (cross(b, c) > EPS) return 1;	//counter cloclwise
	if (cross(b, c) < -EPS) return -1;  //cloclwise
	if (dot(b, c) < 0) return 2;		//c--a--b on line 
	if (norm(b) < norm(c)) return -2;   //a--b--c on line
	return 0;							//a--c--b on line
}

vector<Point> is_cc(Circle c1, Circle c2)
{
	vector<Point> res;
	double d = abs(c1.p - c2.p);
	double rc = (d*d + pow(c1.r, 2) - pow(c2.r, 2)) / (2 * d);
	double dfr = pow(c1.r, 2) - rc*rc;
	if (abs(dfr) < EPS) dfr = 0;
	if (dfr < 0.0) return res;
	double rs = sqrt(dfr);
	Point diff = (c2.p - c1.p) / d;
	res.push_back(c1.p + diff*Point(rc, rs));
	if (dfr != 0.0) res.push_back(c1.p + diff*Point(rc, -rs));
	return res;
}




int main()
{
	int n;
	while (cin >> n, n)
	{
		int ans = 1;
		vector<Point> v;
		REP(i, n)
		{
			double x, y;
			cin >> x >> y;
			v.push_back(Point(x, y));
		}
		REP(i, n - 1)
		{
			FOR(j, 1 + 1, n)
			{
				Circle c1(v[i], 1), c2(v[j], 1);
				auto vp = is_cc(c1, c2);

				REP(k, vp.size())
				{
					int cnt = 0;
					Point tmp = vp[k];
					REP(l, n)
					{
						if (abs(tmp - v[l])-1<= EPS) cnt++;
					}
					chmax(ans, cnt);
				}
			}
		}
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 1284
#include <string>
#include <vector>
#include <map>
#include <set>
#include <deque>
#include <iostream>
#include <functional>
#include <algorithm>
#include <sstream>
#include <iterator>
#include <cmath>

using namespace std;
typedef long long ll;

int main()
{
	string S;
	cin >> S;
	auto i = S.find("AC");
	if (i != wstring::npos)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
	return 0;
}


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

int main(){
	cin.tie(0),ios::sync_with_stdio(false);
	int n; cin>>n;
	string m="MARCH"s;
	vector<int>c(5,0);
	for(int i=0;i<n;++i){
		string s; cin>>s;
		for(int j=0;j<5;++j){
			if(m[j]==s[0]){
				++c[j];
				break;
			}
		}
	}
	int64_t ans=0;
	for(int i=0;i<5;++i){
		for(int j=i+1;j<5;++j){
			for(int k=j+1;k<5;++k){
				ans+=1L*c[i]*c[j]*c[k];
			}
		}
	}
	cout<<ans<<"\n"s;
}


Measured memory_bytes: 3660
#include <bits/stdc++.h>
#define ll long long
#define MODV 1000000007
#define INFLL LLONG_MAX // 9223372036854775807
#define EPS 1e-9
#define rep(i, n) for(ll i=0, i##_len=(ll)(n); i<i##_len; i++)
#define repf(i, n) for(ll i=1, i##_len=(ll)(n+1); i<i##_len; i++)
#define all(v) v.begin(), v.end()
#define endl "\n"
#define vi vector<ll>
#define vvi vector<vector<ll>>
#define Yes() cout << "Yes" << endl
#define YES() cout << "YES" << endl
#define No() cout << "No" << endl
#define NO() cout << "NO" << endl
#define Init() std::ios::sync_with_stdio(false); std::cin.tie(0); std::cout<<fixed<<setprecision(15);
template<class T>bool chmax(T &a, const T &b){ if(a<b){ a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b){ if(b<a){ a=b; return 1; } return 0; }
using namespace std;

int main(){
    Init();
    string s; cin >> s;
    if(s == "RRR") cout << 3 << endl;
    else if(s == "SRR" || s == "RRS") cout << 2 << endl;
    else if(s == "RSS" || s == "SRS" || s == "SSR" || s == "RSR") cout << 1 << endl;
    else cout << 0 << endl;
}

Measured memory_bytes: 3612
#include<cstdio>
bool BN(int i){
	if(i%10==i/10000&&i/1000%10==i%100/10)
		return true;
	return false;
}
int main(){
	int a,b,ans=0;
	scanf("%d%d",&a,&b);
	for(int i=a;i<=b;i++)
		if(BN(i))
			ans++;
	printf("%d\n",ans);
}


Measured memory_bytes: 128
#include<iostream>

int main(){
    char code[4] = {};
    bool flag = 0;
    for(int i = 0; i < 4; ++i){
        std::cin >> code[i];
        if(!flag){
            if(code[i - 1] == code[i]){
                std::cout << "Bad";
                    flag = 1;
            }
        }
    }
    if(!flag)std::cout << "Good";
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define rep(i,a,b) for(ll i=a;i<b;i++)
#define repp(i,a,b) for(ll i=a;i<=b;i++)
#define rrep(i,a,b) for(ll i=a;i>=b;i--)
#define endl "\n"
#define deb(x) cerr << #x << "=" << x << endl
#define debb(x, y) cerr << #x << "=" << x << "," << #y << "=" << y << endl
#define mod ((ll)1e9+7)
#define N ((ll)3e5+20)
#define pb push_back
#define in insert
#define F first
#define S second
#define mp make_pair
#define lb lower_bound
#define ub upper_bound
#define PI 3.1415926535897932384626
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define speed ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define test ll t; cin>>t; while(t--)
typedef pair<ll, ll> pll;
typedef vector<pll> vpll;
ll dr[] = { -1, 1, 0, 0};
ll dc[] = {0, 0, 1, -1};

/*Functions*/
ll gcd(ll a, ll b);
ll exp(ll x, ll y, ll p);
ll exp(ll x, ll y);
void InverseofNumber();
void InverseofFactorial();
void factorial();
ll Binomial(ll n, ll R);


ll factorialNumInverse[N + 1];
ll naturalNumInverse[N + 1];
ll fact[N + 1];

void fileIO() {
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
}
ll check(string x, string y) {
    ll c = 0;
    for (ll i = 0; i < x.size(); i++) {
        if (x[i] != y[i])
            c++;
    }
    return c;
}
int main() {
    clock_t start, end;
    start = clock();
    speed
    // InverseofNumber(),InverseofFactorial(),factorial();
    //fileIO();
    string X, Y; cin >> X >> Y;
    ll n = X.size(), m = Y.size();
    ll ans = 1e9;
    for (ll i = 0; i < n - m + 1; i++) {
        string tp = "";
        for (ll j = i; j < i + m; j++) {
            tp += X[j];
        }
        ans = min(ans, check(tp, Y));
    }
    cout << ans;






    end = clock();
    double timeTaken = (double(end - start) * (double(1000))) / double(CLOCKS_PER_SEC);
    deb(timeTaken);
    return 0;
}


/*All Functions*/
ll gcd(ll a, ll b) {
    if (b == 0)
        return a;
    return gcd(b, a % b);
}

ll exp(ll x, ll y, ll p) {
    ll res = 1;
    while (y) {
        if (y % 2)
            res = (res * x % p) % p;
        x = (x * x) % p;
        y /= 2;
    }
    return res;
}
ll exp(ll x, ll y) {
    ll res = 1;
    while (y) {
        if (y % 2)
            res = (res * x ) ;
        x = (x * x) ;
        y /= 2;
    }
    return res;
}
void InverseofNumber() {
    naturalNumInverse[0] = naturalNumInverse[1] = 1;
    for (ll i = 2; i <= N; i++)
        naturalNumInverse[i] = naturalNumInverse[mod % i] * (mod - mod / i) % mod;
}
void InverseofFactorial() {
    factorialNumInverse[0] = factorialNumInverse[1] = 1;
    for (ll i = 2; i <= N; i++)
        factorialNumInverse[i] = (naturalNumInverse[i] * factorialNumInverse[i - 1]) % mod;
}
void factorial() {
    fact[0] = 1;
    for (ll i = 1; i <= N; i++)
        fact[i] = (fact[i - 1] * i) % mod;
}
ll Binomial(ll n, ll R) {
    ll ans = ((fact[n] * factorialNumInverse[R]) % mod * (factorialNumInverse[n - R]) % mod) % mod;
    return ans;
}


Measured memory_bytes: 3788
L=input()
L=L+"0"
L=L[::-1]
pow3=[0 for i in range(110000)]
pow3[0]=1
mod=10**9+7
for i in range(1,100010):
    pow3[i]=pow3[i-1]*3%mod
#pow3[i]=3**iをmodで割ったあまり
a=1
for i in range(len(L)):
    if L[i]=="1":
        a=(a*2+pow3[i-1])%mod
print(a%mod)

Measured memory_bytes: 7320
import copy

n,m = map(int,input().split())
py = [list(map(int,input().split())) for _ in range(m)]

py_sorted = copy.deepcopy(py)
py_sorted = sorted(py_sorted,key=lambda x :(x[0],x[1]))

id_y = {}
pref_id= py_sorted[0][0]
city_id=1

for e in py_sorted:
  if pref_id != e[0]:
    pref_id = e[0]
    city_id =1
  id_y['{}_{}'.format(e[0],e[1])] = '{:06d}{:06d}'.format(e[0],city_id)
  city_id += 1
  
for pyi in py:
  print(id_y['{}_{}'.format(pyi[0],pyi[1])])  

Measured memory_bytes: 62212
#include<iostream>
#include<algorithm>

using namespace std;

int main(){
  for(long long a,b,c,d,e;cin>>a>>b>>c>>d>>e,a;){
    long long na,nb,nc;
    cin>>na>>nb>>nc;
    long long m=na*a+nb*b+nc*c;
    for(long long i=0;;i++){
      m=min(m,na*a+nb*b+nc*c+max(i,d)*e);
      if(nc){
	nc--;
      }else if(nb){
	nb--;
      }else if(na){
	na--;
      }else{
	break;
      }
    }
    cout<<m<<endl;
  }
}

Measured memory_bytes: 1156
#include <iostream>
#include <cstdio>
using namespace std;
 
char a[100][101];
int H,W,res;
int  dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};
 
void dfs(int x,int y,char ch){
    a[y][x]='.';
    for(int i=0;i<4;i++){
        int nx=x+dx[i],ny=y+dy[i];
        if(0<=nx&&nx<W&&0<=ny&&ny<H&&a[ny][nx]==ch)dfs(nx,ny,ch);
    }
}
 
int  solve(){
    res=0;
    for(int i=0;i<H;i++){
        scanf("%s",a[i]);
    }
    for(int i=0;i<H;i++){
        for(int j=0;j<W;j++){
            if(a[i][j]=='@'||a[i][j]=='#'||a[i][j]=='*'){
                dfs(j,i,a[i][j]);
                res++;
            }
        }
    }
    return res;
}
 
int main() {
    while(1){
            cin>>H>>W;
        if(!H&&!W)break;
        cout<<solve()<<endl;
    }
        return 0;
}

Measured memory_bytes: 1660
a1s=gets.split.map(&:to_i)
a2s=gets.split.map(&:to_i)
a3s=gets.split.map(&:to_i)
as=a1s+a2s+a3s
N,*bs=$<.read.split.map(&:to_i)

bs.each do |b|
    as = as.map{ |a| a == b ? 0 : a}
end

ass = as.each_slice(3).to_a
if ass[0][0] + ass[1][1] + ass[2][2] == 0
    puts 'Yes'
    exit 0
elsif ass[2][0] + ass[1][1] + ass[0][2] == 0
    puts 'Yes'
    exit 0
elsif ass.any? { |as| as.inject(&:+) == 0}
    puts 'Yes'
    exit 0
end
ass = ass.transpose
if ass.any? { |as| as.inject(&:+) == 0}
    puts 'Yes'
    exit 0
end
puts 'No'

Measured memory_bytes: 1916