akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
int main() {
	int n, f[100][10], p[100][11], max = 0, i;
	int x[100], j[10];	/*x: number of periods which both shops are opened ; j:shop condition Open-1, Close-0*/
	int k, y, l;        
	scanf("%d", &n);
	for (i = 0; i<n; i++) {
		for (k = 0; k<10; k++) {
			scanf("%d", &f[i][k]);
		}
	}
	for (i = 0; i<n; i++) {
		for (k = 0; k <= 10; k++) {
			scanf("%d", &p[i][k]);
		}
	}
	for (j[0] = 1; j[0] >= 0; j[0]--) {
		for (j[1] = 1; j[1] >= 0; j[1]--) {
			for (j[2] = 1; j[2] >= 0; j[2]--) {
				for (j[3] = 1; j[3] >= 0; j[3]--) {
					for (j[4] = 1; j[4] >= 0; j[4]--) {
						for (j[5] = 1; j[5] >= 0; j[5]--) {
							for (j[6] = 1; j[6] >= 0; j[6]--) {
								for (j[7] = 1; j[7] >= 0; j[7]--) {
									for (j[8] = 1; j[8] >= 0; j[8]--) {
										for (j[9] = 1; j[9] >= 0; j[9]--) {
											for (i = 0; i<n; i++) {
												x[i] = 0;    /*initialize x*/
											}
											for (i = 0; i<n; i++) {
												for (k = 0; k<10; k++) {
													x[i] += f[i][k] * j[k];  /*check if both opened*/
												}
											}
											y = 0;
											for (i = 0; i<n; i++) {
												y += p[i][x[i]];		     /*income calculation: y*/
											}
											k = 1;
											for (i = 0; i<10; i++) {
												k *= j[i];                   /*check all shops' condition: if all shops are open k=1*/
											}
											l = 0;
											for (i = 0; i<n; i++) {
												if (x[i] == 0) {
													l++;                   /*count number of shops which are closed*/
												}
											}
											if ((y>max&&l != n) || k == 1) {   /*if, all income y>max while at least one shop is opened, */
												max = y;                       /* or all shops are opened, max of income is y */
											}
										}
									}
								}
							}
						}
					}
				}
			}
		}
	}
	printf("%d\n", max);
	return 0;
}

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

string M[201];
int arr[201][201][2];

int main() {
	int H, W;
	cin >> H >> W;
	for (int i = 0;i < H;i++) {
		cin >> M[i];
	}
	for (int i = 0;i < H;i++) {
		for (int j = 0;j < W;j++) {
			arr[i][j][0] = arr[i][j][1] = INT32_MIN / 5;
		}
	}
	priority_queue<tuple<int, int, int, int>> Q;
	int a, b, c, d;
	if (M[0][0] == '#')d = -1, c = 1;
	else d = 0, c = 0;
	Q.push(make_tuple(d, c, 0, 0));
	while (!Q.empty()) {
		tie(d, c, a, b) = Q.top();
		Q.pop();
		if (arr[a][b][c] >= d)continue;
		arr[a][b][c] = d;

		if (a != H - 1) {
			if (M[a + 1][b] == '#') {
				if (c)Q.push(make_tuple(d, 1, a + 1, b));
				else Q.push(make_tuple(d - 1, 1, a + 1, b));
			}
			else {
				Q.push(make_tuple(d, 0, a + 1, b));
			}
		}
		if (b != W - 1) {
			if (M[a][b + 1] == '#') {
				if (c)Q.push(make_tuple(d, 1, a, b + 1));
				else Q.push(make_tuple(d - 1, 1, a, b + 1));
			}
			else {
				Q.push(make_tuple(d, 0, a, b + 1));
			}
		}
	}
	cout << min(-arr[H - 1][W - 1][0], -arr[H - 1][W - 1][1]) << endl;
}

Measured memory_bytes: 512
package main

import(
    "fmt"
)



func main() {
    var n int
    fmt.Scan(&n)
    sum := 0
    ma := 0
    for i:=0; i<n; i++{
        var l int
        fmt.Scan(&l)
        sum += l
        ma = max32(ma,l)
    }
    ans := "No"
    if ma<sum-ma{
        ans = "Yes"
    }
    fmt.Println(ans)
}





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

func abs64(a int64) int64 {
    if a<0{
        return -a
    }
    return a
}

func min32(a, b int) int {
    if a >= b {
        return b
    }
    return a
}

func max32(a, b int) int {
    if a >= b {
        return a
    }
    return b
}

func min64(a, b int64) int64 {
    if a >= b {
        return b
    }
    return a
}

func max64(a, b int64) int64 {
    if a >= b {
        return a
    }
    return b
}

func gcd(a, b int64) int64 {
    if a % b == 0 {
        return b
    } else {
        return gcd(b, a%b)
    }
}

func lcm(a, b int64) int64 {
    return a / gcd(a, b) * b
}

func scanNums(len int) (nums []int){
    var num int
    for i:=0; i<len; i++{
        fmt.Scan(&num)
        nums = append(nums,num)
    }
    return
}

func scanNums64(len int) (nums []int64){
    var num int64
    for i:=0; i<len; i++{
        fmt.Scan(&num)
        nums = append(nums,num)
    }
    return
}

func scanString(len int) (str []string){
    var s string
    for i:=0; i<len; i++{
        fmt.Scan(&s)
        str = append(str,s)
    }
    return
}

func scanTwoNums(n,m int) ([][]int){
    Nums := make([][]int, n)
    for i:=0; i<n; i++{
        Nums[i] = make([]int, m)
    }
    return Nums
}


Measured memory_bytes: 512
sa=list(raw_input())
sb=list(raw_input())
sc=list(raw_input())
now=sa.pop(0)
while 1:
    if now=="a":
        if len(sa)==0:
            print("A")
            break
        now=sa.pop(0)
    elif now=="b":
        if len(sb)==0:
            print("B")
            break
        now=sb.pop(0)
    else:
        if len(sc)==0:
            print("C")
            break
        now=sc.pop(0)

Measured memory_bytes: 2568
#include <iostream>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>
#include <map>
#include <unordered_map>
#include <set>
#include <deque>
#include <bitset>

long long mod = 1e9+7;
class Mint {
public:
  long long x;
  Mint(){}; // 引数なしでも定義できるように引数なしコンストラクタも用意しておく
  Mint(long long a){
    x = a%mod;
    while(x<0){
      x += mod;
    }
  };
  Mint& operator += (const Mint &a){
    x+=a.x;
    x%=mod;
    return *this;
  }
  Mint& operator -= (const Mint &a){
    x += (mod - a.x);
    x%=mod;
    return *this;
  }
  Mint& operator *= (const Mint &a){
    x*=a.x;
    x%=mod;
    return *this;
  }

  // a^n mod を計算する
  // Useaeg: Mint z = y.pow(y, n);
  Mint pow(Mint a, long long n) const {
    Mint y(1);
    Mint b(a);
    while (n > 0) {
      if (n & 1) y *= b;
      b *= b;
      n >>= 1;
    }
    return y;
  }

  // a^{-1} mod を計算する
  Mint modinv(const Mint &a) const {
    return pow(a, mod-2);
  }

  Mint& operator /= (const Mint &a) {
    x *= modinv(a).x;
    x %= mod;
    return *this;
  }

  Mint operator + (Mint &a) const {
    Mint y(*this);
    y += a;
    return y;
  }

  Mint operator - (Mint &a) const {
    Mint y(*this);
    y -= a;
    return y;
  }

  Mint operator * (Mint &a) const {
    Mint y(*this);
    y *= a;
    return y;
  }

  Mint operator / (Mint &a) const {
    Mint y(*this);
    y/=a;
    return y.x;
  }

  // nCk @mod を計算する
  Mint nCk(Mint &n, const long long k) const {
    Mint y = Mint(1);
    for (Mint i(0); (i.x)<k; i.x++){
      y *= (n-i);
      y /= i;
    }
    return y;
  }

  // nPk @mod を計算する
  Mint nPk(Mint &n, long long k) const {
    Mint y(1);
    for (Mint i(0); (i.x)<k; i.x++){
      y *= (n-i);
    }
    return y;
  }
};

struct node {
  int v;
  int supply;
  int amari;
};

class MyComparison {
public:
  bool operator()(node n1, node n2) {
    return (n1.supply!=n2.supply)?(n1.supply>n2.supply):(n1.amari<n2.amari);
  }
};

int main() {
  std::string s;
  std::cin >> s;
  int renzoku = 0;
  int ans = 0;
  for (char tenki : s){
    if (tenki=='R') {
      renzoku++;
    } else {
      ans = std::max(ans, renzoku);
      renzoku = 0;
    }
  }
  ans = std::max(ans, renzoku);
  std::cout << ans << std::endl;
  return 0;
}

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

int main() {
  string s;
  cin>>s;
  int n=s.size();
  vector<char> v={'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'};
  for(int i=0;i<n;i++){
    for(int j=0;j<26;j++){
      if(s.at(i)==v.at(j)){
    s.at(i)=v.at((j+23)%26);
      break;
}
    }
  }
  cout<<s<<endl;
}



Measured memory_bytes: 3224
import std.stdio, std.array, std.string, std.conv, std.algorithm;
import std.typecons, std.range, std.random, std.math, std.container;
import std.numeric, std.bigint, core.bitop, core.stdc.stdio;

void main() {
    auto N = readln.chomp.to!int;
    auto A = readln.split.map!(x => x.to!int-1).array;

    auto st = new SegmentTree!(int, (a,b)=>a+b, 0)(N);
    int ans = 0;

    foreach (i, a; A) {
        if (st.query(a, N-1) == i.to!int) ans += 1;
        st.add(a, 1);
    }

    ans.writeln;
}

class SegmentTree(T, alias op, T e) {
    T[] table;
    int size;
    int offset;

    this(int n) {
        size = 1;
        while (size <= n) size <<= 1;
        size <<= 1;
        table = new T[](size);
        fill(table, e);
        offset = size / 2;
    }

    void assign(int pos, T val) {
        pos += offset;
        table[pos] = val;
        while (pos > 1) {
            pos /= 2;
            table[pos] = op(table[pos*2], table[pos*2+1]);
        }
    }

    void add(int pos, T val) {
        pos += offset;
        table[pos] += val;
        while (pos > 1) {
            pos /= 2;
            table[pos] = op(table[pos*2], table[pos*2+1]);
        }
    }

    T query(int l, int r) {
        return query(l, r, 1, 0, offset-1);
    }

    T query(int l, int r, int i, int a, int b) {
        if (b < l || r < a) {
            return e;
        } else if (l <= a && b <= r) {
            return table[i];
        } else {
            return op(query(l, r, i*2, a, (a+b)/2), query(l, r, i*2+1, (a+b)/2+1, b));
        }
    }
}

Measured memory_bytes: 11536
N,K = map(int,input().split())
A = list(map(int,input().split()))

l = 1
r = 10**9 + 1

while l < r:
    mid = (l + r) // 2
    counter = 0
    for i in range(N):
        if A[i] > mid:
            counter += A[i] // mid
    if counter <= K:
        r = mid
    else:
        l = mid + 1

print(l)

Measured memory_bytes: 31244
#include <bits/stdc++.h>
#define N 1000000007
using namespace std;
int main()
{
	long long n;
	long long a=1,b=1,c=1;
	cin >> n;
	for(long long i=1; i<=n; i++)
	{
		a = a % N * 10 % N;
		b = b % N * 9 % N;
		c = c % N * 8 % N;
	}
	cout << (((a % N + c % N) % N + N - b) % N + N - b) % N << endl;
}

Measured memory_bytes: 3584
package main

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

func nextLine(r *bufio.Reader) string {
	var buf []byte
	for {
		line, isPrefix, err := r.ReadLine()
		if err != nil {
			panic(err)
		}
		buf = append(buf, line...)
		if !isPrefix {
			break
		}
	}
	return string(buf)
}

func nextStr(s *bufio.Scanner) string {
	s.Scan()
	ref := s.Bytes()
	cp := make([]byte, len(ref))
	copy(cp, ref)
	return string(cp)
}

func nextInt(s *bufio.Scanner) int {
	n, err := strconv.Atoi(nextStr(s))
	if err != nil {
		panic(err)
	}
	return n
}

func nextInt64(s *bufio.Scanner) int64 {
	n, err := strconv.ParseInt(nextStr(s), 0, 64)
	if err != nil {
		panic(err)
	}
	return n
}

func main() {
	s := bufio.NewScanner(os.Stdin)
	s.Split(bufio.ScanWords)

	N := nextInt(s)

	var prod int64 = 1
	x := make([]int64, N)
	for i := 0; i < N; i++ {
		x[i] = nextInt64(s)
		if x[i] == 0 {
			fmt.Println(0);
			return;
		}
	}

	for i := 0; i < N; i++ {
		if (1e18 / prod < x[i]) {
			fmt.Println(-1)
			return
		}
		prod *= x[i]
	}

	fmt.Println(prod)
}


Measured memory_bytes: 6144
#include <bits/stdc++.h>
#define ll long long
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end))) // rep(i, 1, 5) --> {1,2,3,4} // rep(i, 5, 1) --> {4,3,2,1} // rep(it, end(v), begin(v)) --> *it

using namespace std;

int main()
{
    ll n, k;
    cin >> n >> k;
    ll res = 0;
    ll mod = 1e9+7;
    rep(i, k, n + 2)
    {
        ll a = (i-1) * i / 2;
        ll b = i * (n + n-i+1) / 2;
        // cout << a << " " << b << endl;
        res += (b - a + 1) % mod;
    }
    cout << res % mod;    
    return 0;
}

Measured memory_bytes: 3608
#include "bits/stdc++.h"
using namespace std;

typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define REP(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) std::cout << x << '\n'
#define all(a) a.begin(), a.end()
#define pb push_back
#define sz(x) ((int)(x).size())
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { ll g = gcd(a, b); return a / g * b; }
const int dx[4] = { 1, 0, -1,  0 };
const int dy[4] = { 0, 1,  0, -1 };
const int INF = (int)1e9;
const ll  inf = (ll)1e18;
const int mod = 1000000007;
const int MAX_N = 100010;
const double PI = acos(-1);

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(10);
	/*------------------------------*/

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

	sort(all(a));

	int ai = a[n - 1];
	int aj = a[0];
	rep(i, n - 1) {
		if (abs(a[i] - ai / 2) <= abs(aj - ai / 2)) {
			aj = a[i];
		}
	}

	cout << ai << " " << aj;

	return 0;
}

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

int digit(int n){
    if(n<10) return 1;
    else return digit(n/10) + 1;
}

int main(){
    int N;  cin >> N;
    int nDigit = digit(N);
    int ans = 0;
    for(int i=1; i<nDigit; i+=2){
        ans += 9*pow(10, i-1);
    }
    if(nDigit%2==1){
        ans += N - pow(10, nDigit-1) + 1;
    }
    cout << ans << endl;
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
long long n,W;
long long a,b;
long long dp[100010];
int main()
{
	cin>>n>>W;
	for(int i=1;i<=n;i++){
		cin>>a>>b;
		for(int j=W-a;j>=0;j--){
			dp[j+a]=max(dp[j+a],dp[j]+b);
		}
	}
	long long maxx=0;
	for(int i=1;i<=W;i++)
	   if(dp[i]>maxx)
	      maxx=dp[i];
	cout<<maxx<<endl;
	return 0;
}


Measured memory_bytes: 1024
//#include <bits/stdc++.h>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <cmath>
#include <numeric>
using namespace std;
#define rep(i, n) for(int i=0;i<n;i++)
#define irep(i, n) for(int i=n-1;i>=0;i--)
#define sort(x) sort(x.begin(), x.end())
typedef long long ll;
typedef vector<long long> llv;
typedef vector<vector<long long> > llvv;


int main(){
    ll n, q, l, r;
    cin >> n >> q;
    string s;
    cin >> s;
    llv list(n+1);
    list.assign(list.size(), 0);
    rep(i, n-1){
        if (s.substr(i, 2) == "AC") list[i+1] = list[i] + 1;
        else list[i+1] = list[i];
    }
    list[n] = list[n-1];
    // rep(i,n) cout << list[i] << endl;
    while (cin >> l >> r){
        cout << list[r-1] - list[l-1] << endl;
    }
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const ll MOD = 1000000007;
const int IINF = INT_MAX;
const ll LLINF = LLONG_MAX;
const ll MAX_N = ll(1e5 + 5);
const double EPS = 1e-10;
const int di[] = {0, 1, 0, -1}, dj[] = {1, 0, -1, 0};
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define SORT(v) sort((v).begin(), (v).end())
#define ALL(v) (v).begin(), (v).end()

int main() {
    ll n, a[MAX_N], ans = 0, ans2 = 0;
    cin >> n;
    REP(i, n) cin >> a[i];
    sort(a, a + n);
    ans += abs(a[n - 1] - a[0]);

    int pr = 0;
    for (int i = 0; i < n / 2; i++) {
        int j = i/2 + 1;
        int nx = (i%2 == 0 ? n - j*2 : j*2);
        if (nx == pr) break;
        if (nx == n/2 && n%2 == 1) break;
        ans += abs(a[nx] - a[pr]);
        pr = nx;
    }
    pr = n - 1;
    for (int i = 0; i < n / 2; i++) {
        int j = i / 2 + 1;
        int nx = (i % 2 == 1 ? n - j * 2 : j * 2) - 1;
        if (nx == n / 2 && n % 2 == 1) break;
        if (nx == pr) break;
        ans += abs(a[nx] - a[pr]);
        pr = nx;
    }
    if (n % 2 == 1)
        ans += max(abs(a[n / 2 + 1] - a[n / 2]), abs(a[n / 2 - 1] - a[n / 2]));

    reverse(a,a+n);
    ans2 += abs(a[n - 1] - a[0]);

    pr = 0;
    for (int i = 0; i < n / 2; i++) {
        int j = i / 2 + 1;
        int nx = (i % 2 == 0 ? n - j * 2 : j * 2);
        if (nx == pr) break;
        if (nx == n / 2 && n % 2 == 1) break;
        ans2 += abs(a[nx] - a[pr]);
        pr = nx;
    }
    pr = n - 1;
    for (int i = 0; i < n / 2; i++) {
        int j = i / 2 + 1;
        int nx = (i % 2 == 1 ? n - j * 2 : j * 2) - 1;
        if (nx == n / 2 && n % 2 == 1) break;
        if (nx == pr) break;
        ans2 += abs(a[nx] - a[pr]);
        pr = nx;
    }
    if (n % 2 == 1)
        ans2 += max(abs(a[n / 2 + 1] - a[n / 2]), abs(a[n / 2 - 1] - a[n / 2]));


    cout << max(ans,ans2) << endl;
    return 0;
}


Measured memory_bytes: 1152
#include <iostream>
#include <vector>
#define rep(i, a, b) for(int i = (a); i < (b); i++)
using namespace std;

int main() {
  int n, m;
  cin >> n >> m;
  vector<int> imos(n, 0), rui(n, 0);
  rep(i, 0, m) {
    int l, r;
    cin >> l >> r;
    imos[l-1]++;
    if(r < n) {
      imos[r]--;
    }
  }
  rep(i, 0, n) {
    if(i == 0) {
      rui[i] = imos[i];
    } else {
      rui[i] = rui[i-1] + imos[i];
    }
  }
  int c = 0;
  rep(i, 0, n) {
    if(rui[i] == m) {
      c++;
    }
  }
  cout << c;
}

Measured memory_bytes: 1024
/// time is tough.....so don't stop ...keep learning ...keep growing :)

#include <bits/stdc++.h>
using namespace std ;
typedef long long ll ;
typedef long double ld ;
const int N = 1e5+5 ;
const int K = 50 ;
const ll mod =  1e9+7 ;
#define pb push_back
#define ft first 
#define sd second 
#define IOS ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
ll poww(ll a,ll b){ll res=1;while(b){if(b&1){res*=a;}a=a*a;b>>=1;}return res;}
ll poww(ll a,ll b,ll mod){ll res=1;while(b){if(b&1){res*=a;res%=mod;}a=a*a;a%=mod;b>>=1;}return res;}
const int INF = 2e9 ;
int n, c1, c2, c3;
ld dp[305][305][305];
ld f(int c1, int c2, int c3) {
    if(c1 + c2 + c3 == 0) return 0.f;
    ld &res = dp[c1][c2][c3]; 
    if(abs(res+1.f)>1e-6)return res;
    res = 1;
    if(c1 > 0){
        res += 1.0*c1 / n * f(c1 - 1, c2, c3);
    }
    if(c2 > 0) {
        res += 1.0*c2 / n * f(c1 + 1, c2 - 1, c3); 
    }
    if(c3 > 0){
        res += 1.0*c3 / n * f(c1, c2 + 1, c3 - 1);
    }
    res = res * n * 1.0/ (c1 + c2 + c3);
    return res;
}
int main() {
    cin >> n;
    int x ;
    for(int i=0;i<=300;i++){
        for(int j=0;j<=300;j++){
            for(int k=0;k<=300;k++) dp[i][j][k] = -1;
        }
    }
    for(int i=1;i<=n;i++) {
        cin >> x ;
        if(x == 1)c1++;
        else if(x == 2) c2++;
        else if(x == 3) c3++; 
    }
    cout << fixed << setprecision(10) << f(c1,c2,c3) << '\n';
    return 0;
}


Measured memory_bytes: 438528
#! /usr/bin/env python3

from fractions import gcd
from collections import Counter, deque, defaultdict
from heapq import heappush, heappop, heappushpop, heapify, heapreplace, merge
from bisect import bisect_left, bisect_right, bisect, insort_left, insort_right, insort
from itertools import accumulate, product, permutations, combinations, combinations_with_replacement

S = input()

if "7" in S:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 10392
object Main extends App {
  var a = readInt
  var ab = readLine.split(" ").map(_.toInt)
  var sum = 9999
  def b(c:Int,d:Int):Int ={
    if(c%2!=1) {
      b(c/2,d+1)
    } else {
     return d
    }
  }
  for(i <- 0 until a) {
    sum = Math.min(sum,b(ab(i),0))
  }
  println(sum)  
}

Measured memory_bytes: 25648
A,B = map(int,input().split())
def GCD(p,q):
    if p<q:
        p,q = q,p
    r = p
    p = q
    q = r%q
    if q!=0:
        return GCD(p,q)
    else:
        return p
gcd = GCD(A,B)
ans = (A*B)//gcd
print(ans)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0; i<(n); ++i)
#define REP(i, d, n) for(int i=(d); i<(n); ++i)
#define all(v) v.begin(), v.end()
using ll = long long;
using P = pair<int, int>;

int digsum(int n) {
    int res = 0;
    while(n > 0) {
        res++;
        n /= 10;
    }
    return res;
}

int main() {

    int n;
    cin >> n;

    int ans = 0;
    REP(i, 1, n+1){
        int res = digsum(i);
        if(res % 2 == 1){
            ans++;
        }
    }
    cout << ans << endl;

    return 0;
}

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



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

	for (int i = 1; i < x; ++i)
	{
		if((y+z)*i+z>x){
			cout<<i-1<<endl;
			break;
		}
	}

return 0;
}




Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll a, b;

int main() {
cin >> a;
for (ll i = 1; i <= 9; i++){
	if (a%i == 0){
		if ((a/i) <= 9){
			cout << "Yes"; return 0;
			}
		}
	}
	cout << "No";

}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<queue>
#define dbg(x) cerr << #x << " = " << x <<endl
using namespace std;
typedef long long ll;
typedef double db;
typedef pair<int,int> pii;
template<typename T>inline T _min(T A,T B){return A<B?A:B;}
template<typename T>inline T _max(T A,T B){return A>B?A:B;}
template<typename T>inline char MIN(T&A,T B){return A>B?(A=B,1):0;}
template<typename T>inline char MAX(T&A,T B){return A<B?(A=B,1):0;}
template<typename T>inline void _swap(T&A,T&B){A^=B^=A^=B;}
template<typename T>inline T read(T&x){
	x=0;int f=0;char c;while(!isdigit(c=getchar()))if(c=='-')f=1;
	while(isdigit(c))x=x*10+(c&15),c=getchar();return f?x=-x:x;
}
const int N=100000+7;
struct thxorz{
	int u,v,w;
	thxorz(int u=0,int v=0,int w=0):u(u),v(v),w(w){}
	inline bool operator <(const thxorz&A)const{return w<A.w;}
}e[N<<1];
int n,tot;
struct stothx{int x,y,id;}A[N];
inline bool cmp1(stothx a,stothx b){return a.x<b.x;}
inline bool cmp2(stothx a,stothx b){return a.y<b.y;}
int anc[N];
ll ans;
inline int get_anc(int x){return anc[x]==x?x:anc[x]=get_anc(anc[x]);}

int main(){//freopen("test.in","r",stdin);//freopen("test.ans","w",stdout);
	read(n);
	for(register int i=1;i<=n;++i)read(A[i].x),read(A[i].y),A[i].id=i;
	sort(A+1,A+n+1,cmp1);
	for(register int i=1;i<n;++i)e[++tot]=thxorz(A[i].id,A[i+1].id,A[i+1].x-A[i].x);
	sort(A+1,A+n+1,cmp2);
	for(register int i=1;i<n;++i)e[++tot]=thxorz(A[i].id,A[i+1].id,A[i+1].y-A[i].y);
	sort(e+1,e+tot+1);
	for(register int i=1;i<=n;++i)anc[i]=i;
	for(register int i=1;i<=tot;++i)if(get_anc(e[i].u)^get_anc(e[i].v))ans+=e[i].w,anc[anc[e[i].u]]=anc[e[i].v];
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 4224
n = int(input())
mod = 10**9+7

dp = [0] * n
dp[0] = 1
tot = 1
for i in range(1,n):
    if(i==1):
        dp[i] = tot
    else:
        dp[i] = tot - dp[i-2]
    dp[i] %= mod
    tot += dp[i]
    tot %= mod

ans = 0
for i in range(n-1):
    ans += dp[i] * ((n-1)**2 + min(n-1, i+2))
    ans %= mod

ans += dp[-1]*n
ans %= mod
print(ans)

Measured memory_bytes: 81440
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <cfloat>
#include <ctime>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <numeric>
#include <list>

using namespace std;

#ifdef _MSC_VER
#define __typeof__ decltype
template <class T> int __builtin_popcount(T n) { return n ? 1 + __builtin_popcount(n & (n - 1)) : 0; }
#endif

#define foreach(it, c) for (__typeof__((c).begin()) it=(c).begin(); it != (c).end(); ++it)
#define all(c) (c).begin(), (c).end()
#define rall(c) (c).rbegin(), (c).rend()
#define popcount __builtin_popcount
           
#define rep(i, n) for (int i = 0; i < n; ++i)

template <class T> void max_swap(T& a, const T& b) { a = max(a, b); }
template <class T> void min_swap(T& a, const T& b) { a = min(a, b); }

const double EPS = 1e-10;
typedef long long ll;
typedef pair<int, int> pint;


int main()
{
    int n, m;
    while (scanf("%d%d", &n, &m), n | m)
    {
	int w = n + m;
	static int t[22222];
	rep (i, w)
	    scanf("%d", t + i);
	t[w++] = 0;
	sort(t, t + w);
	int res = -1;
	for (int i = 1; i < w; ++i)
	    max_swap(res, t[i] - t[i - 1]);
	printf("%d\n", res);
    }
}

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

using namespace std;
int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  for(auto&& x:a)cin >> x;
  sort(a.begin(), a.end());
  vector<pair<int, int> > sol;
  for(int i=1;i<n-1;i++){
    if(a[i] > 0){
      sol.emplace_back(a[0], a[i]);
      a[0] -= a[i];
    }
    else{
      sol.emplace_back(a[n-1], a[i]);
      a[n-1] -= a[i];
    }
  }
  sol.emplace_back(a[n-1], a[0]);
  a[n-1] -= a[0];
  cout << a[n-1] << endl;
  for(auto&& x:sol)cout << x.first << " " << x.second << endl;
  return 0;
}

Measured memory_bytes: 3188
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=2e6+5,mod=1e9+7;
ll f[N],invf[N];
ll C(int n,int m)
{
    return f[n]*invf[n-m]%mod*invf[m]%mod;
}
ll c1,c2,r1,r2;
ll qpow(ll a,ll n)
{
    ll ans=1;
    while(n)
    {
        if(n&1) ans=ans*a%mod;
        a=a*a%mod;
        n>>=1;
    }
    return ans;
}
ll g(ll x,ll y)
{
    ll ans=0;
    for(int i=0;i<=x;i++)
        ans=(ans+C(i+y+1,i+1))%mod;
    return ans;
}
int main()
{
    f[0]=f[1]=invf[0]=invf[1]=1;
    for(int i=2;i<N;i++) f[i]=f[i-1]*i%mod,invf[i]=(mod-mod/i)*invf[mod%i]%mod;
    for(int i=2;i<N;i++) invf[i]=invf[i-1]*invf[i]%mod;
    scanf("%lld%lld%lld%lld",&r1,&c1,&r2,&c2);
    ll ans=g(r2,c2)-g(r1-1,c2)-g(r2,c1-1)+g(r1-1,c1-1);
    ans=(ans+mod)%mod;
    printf("%lld\n",ans);
}


Measured memory_bytes: 31488
// "header" {{{
#include <iostream>
#include <vector>
#include <algorithm>
#include <unordered_map>
#include <string>
#include <deque>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <cstring>
#include <iomanip>
#include <tuple>

using namespace std;

#define rep(i,n) for(int i=0;i<(n);++i)
#define reps(i,n) for(int i=1;i<=(n);++i)
#define all(x) (x).begin(),(x).end()
#define pii pair<int,int> 
#define int long long
#define setout(n,x) setw(n) << setfill(x)
#define Fixed fixed << setprecision(10)
const int INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3fLL;
const long long mod = 1000000007;

inline double sqrt( const double &x) 
{
	double         xHalf = 0.5 * x;
	int64_t  tmp   = 0x5FE6EB50C7B537AAl - ( *(int64_t*)&x >> 1);
	double         xRes  = * (double*)&tmp;

	xRes *= ( 1.5 - ( xHalf * xRes * xRes ) );
	xRes *= ( 1.5 - ( xHalf * xRes * xRes ) );
	xRes *= ( 1.5 - ( xHalf * xRes * xRes ) );
	xRes *= ( 1.5 - ( xHalf * xRes * xRes ) );
	return xRes * x;
}
// }}}

signed main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;
	cin >> n;
	vector<int> h(n);
	rep(i,n){
		cin >> h[i];
	}
	vector<int> dp(n);
	reps(i,n-1){
		if(i == 1){
			dp[i] = abs(h[i]-h[i-1]);
		}
		else dp[i] = min(abs(h[i] - h[i-2]) + dp[i-2],abs(h[i] - h[i-1]) + dp[i-1]);
	}
	cout << dp[n-1] << '\n';
	return 0;	
}


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

int main() {
    long N;
    cin >> N;
    long ans = 0;
    for(long i = 1; i <= N; i++){
        if (i % 5 != 0 && i % 3 != 0){
            ans += i;
        }
    }
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 3592
#include <stdio.h>

int main(void) 
{
    float a, b ,c, d, e, f, x, y;

    while (scanf("%f %f %f %f %f %f", &a, &b, &c, &d, &e, &f) != EOF) {
        e = e - (d / a) * b;
        f = f - (d / a) * c;
        y = f / e;
        x = (c - b * y) / a;
        printf("%.3f %.3f\n", x, y);
    }

}


Measured memory_bytes: 2040
loop do
    h, w = gets.split.map(&:to_i)

    if h == 0 && w == 0
        break
    end

    odd = (".#" * w)[0..(w-1)]
    even = ("#." * w)[0..(w-1)]

    for i in 0..h-1
        if i % 2 == 0
            puts even
        else
            puts odd
        end
    end
        
    puts
end

Measured memory_bytes: 8716
s = int(input())
p = 10**9 + 7

def cmb(n, r, p):
    r = min(r, n - r)
    return fact[n] * factinv[r] * factinv[n-r] % p

def pow(a, n, p):
    bi = str(format(n, 'b'))
    res = 1
    for i in range(len(bi)):
        res = (res * res) % p
        if bi[i] == '1':
            res = (res * a) % p
    return res

fact = [1, 1]
factinv = [1, 1]
inv = [0, 1]

for i in range(2, 2 * 10**5 + 1):
    fact.append((fact[-1] * i) % p)
    inv.append((-inv[p % i] * (p // i)) % p)
    factinv.append((factinv[-1] * inv[-1]) % p)

ans = 0
for i in range(1, s + 1):
    s_trying = s - 3*i
    if s_trying < 0:
        break
    ans = (ans + cmb(s_trying + i-1, i-1, p)) % p
print(ans)


Measured memory_bytes: 109516
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <cfloat>
#include <stack>
#include <queue>
#include <vector>
#include <string>
#include <iostream>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;

struct Info{

	Info(int arg_time,int arg_loc){
		time = arg_time;
		loc = arg_loc;
	}
	bool operator<(const struct Info &arg) const{
		return time < arg.time;
	};

	int time,loc;
};

int main() {

	int N,Limit;

	scanf("%d %d",&N,&Limit);

	Info* info = (Info*)malloc(sizeof(Info)*N);

	for(int i = 0; i < N; i++){
		scanf("%d %d",&info[i].time,&info[i].loc);
	}

	sort(info,info+N);

	ll ans = 0;
	int pre_time = 0,pre_loc = 1;
	vector<int> Elevator;

	for(int i = 0; i < N; i++){
		if(info[i].time-pre_time < abs(info[i].loc-pre_loc)){
			printf("-1\n");
			return 0;
		}

		if(info[i].time-pre_time >= (pre_loc-1)+(info[i].loc-1)){
			for(int k = 0; k < Elevator.size(); k++){
				ans += pre_time+(pre_loc-1)-Elevator[k];
			}
			Elevator.clear();
			Elevator.push_back(info[i].time);
		}else{
			if(Elevator.size() == Limit){
				printf("-1\n");
				return 0;
			}
			Elevator.push_back(info[i].time);
		}
		pre_time = info[i].time;
		pre_loc = info[i].loc;
	}

	for(int i = 0; i < Elevator.size(); i++){
		ans += pre_time+(pre_loc-1)-Elevator[i];
	}

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

	return 0;
}

Measured memory_bytes: 4264
#![allow(unused_imports, unused_macros, dead_code)]

macro_rules! min {
    (.. $x:expr) => {{
        let mut it = $x.iter();
        it.next().map(|z| it.fold(z, |x, y| min!(x, y)))
    }};
    ($x:expr) => ($x);
    ($x:expr, $($ys:expr),*) => {{
        let t = min!($($ys),*);
        if $x < t { $x } else { t }
    }}
}
macro_rules! max {
    (.. $x:expr) => {{
        let mut it = $x.iter();
        it.next().map(|z| it.fold(z, |x, y| max!(x, y)))
    }};
    ($x:expr) => ($x);
    ($x:expr, $($ys:expr),*) => {{
        let t = max!($($ys),*);
        if $x > t { $x } else { t }
    }}
}
macro_rules! ewriteln {
    ($($args:expr),*) => { let _ = writeln!(&mut std::io::stderr(), $($args),*); };
}
macro_rules! trace {
    ($x:expr) => { ewriteln!(">>> {} = {:?}", stringify!($x), $x) };
    ($($xs:expr),*) => { trace!(($($xs),*)) }
}
macro_rules! put {
    (.. $x:expr) => {{
        let mut it = $x.iter();
        if let Some(x) = it.next() { print!("{}", x); }
        for x in it { print!(" {}", x); }
        println!("");
    }};
    ($x:expr) => { println!("{}", $x) };
    ($x:expr, $($xs:expr),*) => { print!("{} ", $x); put!($($xs),*) }
}

const M: i64 = 1_000_000_007;

fn lastmove(xs: &Vec<usize>) -> Option<usize> {
    let n = xs.len();
    for i in (0..n).rev() {
        if xs[i] == i + 1 {
            return Some(i)
        }
    }
    None
}

fn remove(xs: &Vec<usize>, idx: usize) -> Vec<usize> {
    let mut r = vec![];
    for i in 0..xs.len() {
        if i == idx { continue }
        r.push(xs[i]);
    }
    r
}

fn main() {
    let mut sc = Scanner::new();
    let n: usize = sc.cin();
    let mut xs: Vec<usize> = sc.vec(n);

    let mut ans = vec![];
    while xs.len() > 0 {
        if let Some(i) = lastmove(&xs) {
            ans.push(i);
            xs = remove(&xs, i);
        } else {
            put!(-1);
            return;
        }
    }
    for &i in ans.iter().rev() {
        put!(i + 1);
    }
}

use std::io::{self, Write};
use std::str::FromStr;
use std::collections::VecDeque;

struct Scanner { stdin: io::Stdin, buffer: VecDeque<String>, }
impl Scanner {
    fn new() -> Self { Scanner { stdin: io::stdin(), buffer: VecDeque::new() } }
    fn cin<T: FromStr>(&mut self) -> T {
        while self.buffer.len() == 0 {
            let mut line = String::new();
            let _ = self.stdin.read_line(&mut line);
            for w in line.split_whitespace() {
                self.buffer.push_back(String::from(w));
            }
        }
        self.buffer.pop_front().unwrap().parse::<T>().ok().unwrap()
    }
    fn chars(&mut self) -> Vec<char> { self.cin::<String>().chars().collect() }
    fn vec<T: FromStr>(&mut self, n: usize) -> Vec<T> { (0..n).map(|_| self.cin()).collect() }
}


Measured memory_bytes: 4352
// https: //onlinejudge.u-aizu.ac.jp/courses/lesson/8/ITP2/1/ITP2_1_A

#include <iostream>
#include <deque>

int main()
{
    std::deque<int> deq;

    int q;
    std::cin >> q;
    for (int i = 0; i < q; i++)
    {
        int m;
        std::cin >> m;
        // std::cout << "m "<<m << std::endl;
        int d, x;
        if (m == 0)
        {
            std::cin >> d >> x;
            if (d == 0)
                deq.emplace_front(x);
            else if (d == 1)
                deq.emplace_back(x);
        }
        if (m == 1)
        {
            std::cin >> x;
            std::cout << deq[x] << std::endl;
        }
        if (m == 2)
        {
            std::cin >> d;
            if (d == 0)
                deq.pop_front();
            if (d == 1)
                deq.pop_back();
        }

        // for(auto& y:deq)
        // {
        //     std::cout << y ;

        // }
        // std::cout  << std::endl;
    }

    return 0;
}


Measured memory_bytes: 4560
#include<iostream>
#include<cstdio>
#include<cstring>
#include<vector>
#include<algorithm>
#include<queue>
#include<cmath>
#include<cstdlib>
#define LL long long
#define LD long double
using namespace std;
const int NN=5000 +117;
const int MM= +117;
int read(){
	int fl=1,x;char c;
	for(c=getchar();(c<'0'||c>'9')&&c!='-';c=getchar());
	if(c=='-'){fl=-1;c=getchar();}
	for(x=0;c>='0'&&c<='9';c=getchar())
		x=(x<<3)+(x<<1)+c-'0';
	return x*fl;
}
void open(){
	freopen("a.in","r",stdin);
	//freopen("a.out","w",stdout);
}
void close(){
	fclose(stdin);
	fclose(stdout);
}


int m,n;
LL dp[NN][NN]={};
int p[NN]={};
int a,b;
int main(){
	//open();
	n=read();
	a=read(),b=read();
	for(int i=1;i<=n;++i)p[i]=read();
	
	memset(dp,60,sizeof dp);
	dp[0][0]=0;
	for(int i=1;i<=n;++i){
		for(int j=0;j<=n;++j){
			if(j<p[i]){
				dp[i][p[i]]=min(dp[i][p[i]],dp[i-1][j]);
				dp[i][j]=min(dp[i][j],dp[i-1][j]+a);
			}
			else{
				dp[i][j]=min(dp[i][j],dp[i-1][j]+b);
			}
		}
	}
	LL ans=1e18;
	for(int j=0;j<=n;++j){
		ans=min(dp[n][j],ans);
	}
	printf("%lld\n",ans);
	close();
	return 0;
}

Measured memory_bytes: 204800
#include <bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
    ll m,n,l;
    cin>>n>>m>>l;
    ll a[n+1][m+1],b[m+1][l+1],i,j,k,sum[n+1][l+1];
    for(i=1; i<=n; i++)
    {
      for(j=1; j<=m; j++)
      {
          cin>>a[i][j];
      }
    }
    for(i=1; i<=m; i++)
    {
      for(j=1; j<=l; j++)
      {
          cin>>b[i][j];
      }
    }
    for(i=1; i<=n; i++)
    {
      for(j=1; j<=l; j++)
      {
          sum[i][j]=0;
      }
    }
    for(i=1; i<=n; i++)
    {
        for(j=1; j<=m; j++)
        {
            for(k=1; k<=l; k++)
            {
                sum[i][k]+=a[i][j]*b[j][k];
            }
        }
    }
    for(i=1; i<=n; i++)
    {
      for(j=1; j<=l; j++)
      {
          cout<<sum[i][j];
          if(j<l) cout<<" ";
      }
      cout<<endl;
    }
    return 0;
}



Measured memory_bytes: 3316
import java.util.*;

class Main {
    public static void main(String args[]) {
        Scanner inp = new Scanner(System.in);
        String n = inp.next();
        inp.close();
        if (n.contains("000")) System.out.println("Yes");
      	else if (n.contains("111")) System.out.println("Yes");
        else if (n.contains("222")) System.out.println("Yes");
        else if (n.contains("333")) System.out.println("Yes");
        else if (n.contains("444")) System.out.println("Yes");
        else if (n.contains("555")) System.out.println("Yes");
        else if (n.contains("666")) System.out.println("Yes");
        else if (n.contains("777")) System.out.println("Yes");
        else if (n.contains("888")) System.out.println("Yes");
        else if (n.contains("999")) System.out.println("Yes");
        else System.out.println("No");
    }
}


Measured memory_bytes: 23380
using System;

class Problem
{
  public static void Main(string[] args)
  {
    var n = int.Parse(Console.ReadLine());
    var dp = new long[86 + 1];
    dp[0] = 2;
    dp[1] = 1;
	for (var i = 2; i <= n; i++) dp[i] = dp[i - 1] + dp[i - 2];
    Console.WriteLine($"{dp[n]}");
  }
}


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

int main(){
    int n; cin >> n;
    long long array[n]; for(int i = 0; i<n; ++i)cin >> array[i];
    int ans = 0;
    for(int i = 0; i<n; ++i){
        while(array[i+1] == array[i] && i<n) ++i;
        if(array[i+1] > array[i] && i<n) while(array[i+1] >= array[i] && i<n) ++i;
        else while(array[i+1] <= array[i] && i<n) ++i;
        ++ans;
    }
    cout << ans << endl; return 0;
}

Measured memory_bytes: 1024
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<deque>
#include<stack>
#include<string>
#include<string.h>
#include<vector>
#include<set>
#include<map>
#include<bitset>
#include<stdlib.h>
#include<cassert>
#include<time.h>
#include<bitset>
using namespace std;
const long long mod=1000000007;
const long long inf=mod*mod;
const long long d2=(mod+1)/2;
const long double EPS=1e-9;
const long double PI=acos(-1.0);
int ABS(int a){return max(a,-a);}
long long ABS(long long a){return max(a,-a);}
long double ABS(long double a){return max(a,-a);}

int main(){
	int a,b;scanf("%d%d",&a,&b);
	printf("%d\n",(a*3+b)/2);
}


Measured memory_bytes: 128
#include<iostream>
#include<algorithm>
#include<functional>
#include<cmath>
#include<string>
#include<vector>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<deque>
using namespace std;
#define ll long long
const int mod = 1000000007;
const int MOD = 998244353;
const ll INF = 1000000000000000000;


int main()
{
	string S;
	cin >> S;
	for (int i = 0; i < S.size(); i++) {
		if (S[i] == '1') S[i] = '9';
		else S[i] = '1';
	}
	cout << S << endl;
}

Measured memory_bytes: 3612
/*
Author : Xinyuan
*/
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for (int i = 0; i < n; i++)
#define all(x) (x).begin(), (x).end()
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<PII> VII;
typedef vector<VI> VVI;
typedef long long int ll;
const int INF = 1e9 + 7;
const int mod = 1e9 + 7;
ll powmod(ll a, ll b) {
    ll res = 1;
    a %= mod;
    assert(b >= 0);
    for (; b; b >>= 1) {
        if (b & 1) res = res * a % mod;
        a = a * a % mod;
    }
    return res;
}
int nxt() {
    int x;
    scanf("%d", &x);
    return x;
}

// dp[i][j] - the number of ways to put numbers of prefix of size '1'
// such that the last number is 'j'
const int nax = 3005;
int dp[nax][nax], pref[nax][nax];
void add_self(int &a, int b) {
    a += b;
    if (a >= mod) a -= mod;
}

int main() {
    int n = nxt();
    string s;
    cin >> s;
    dp[1][1] = 1;
    for (int len = 2; len <= n; len++) {
        // compute prefix sum on dp[len-1]
        for (int i = 1; i <= len - 1; i++) {
            pref[len - 1][i] = (dp[len - 1][i] + pref[len - 1][i - 1]) % mod;
        }
        for (int b = 1; b <= len; b++) {
            int L, R;
            if (s[len - 2] == '<') {
                L = 1;
                R = b - 1;
            } else {
                L = b;
                R = len - 1;
            }
            if (L <= R) add_self(dp[len][b], (pref[len - 1][R] - pref[len - 1][L - 1] + mod) % mod);
            // for (int i = L; i <= R; i++) {
            //     add_self(dp[len][b], dp[len - 1][i]);
            // }
            // for (int a = 1; a <= len - 1; a++) {
            //     int real_a = a;
            //     if (real_a >= b) real_a++;
            //     assert(real_a != b);
            //     if ((real_a < b) != (s[len - 2] == '<')) continue;
            //     add_self(dp[len][b], dp[len - 1][a]);
            // }
        }
    }
    int answer = 0;
    for (int b = 1; b <= n; b++) {
        add_self(answer, dp[n][b]);
    }
    printf("%d\n", answer);
    return 0;
}


Measured memory_bytes: 58844
import java.util.Scanner;
class Main{
    public static void main(String[] args) {
        Scanner scn=new Scanner(System.in);
        int a_button=scn.nextInt();
        int b_button=scn.nextInt();
        int total=0;
        for(int i=0;i<2;i++){
            int compare=a_button-b_button;
            if(compare>=0){
                total+=a_button;
                a_button--;
            }else{
                total+=b_button;
                b_button--;
            }
        }
        System.out.println(total);
    }
}

Measured memory_bytes: 21716
#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
using namespace std;

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

    s = s + s;

    auto res = s.find(p) != string::npos;

    cout << (res ? "Yes" : "No") << "\n";
}



Measured memory_bytes: 3212
#include<iostream>
#include<sstream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<string>
#include<vector>
#include<cmath>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<numeric>
#include<functional>
#include<complex>

using namespace std;
#define BET(a,b,c) ((a)<=(b)&&(b)<(c))
#define FOR(i,n) for(int i=0,i##_end=(int(n));i<i##_end;i++)
#define SZ(x) (int)(x.size())
#define ALL(x) (x).begin(),(x).end()
#define MP make_pair
#define CLS(x,val) memset((x) , val , sizeof(x)) 
typedef long long ll_t;
typedef long double ld_t;
typedef vector<int> VI;
typedef vector<VI> VVI;

vector<ll_t> g_prime;
const int MAX_PRIME=100010;
bool is_prime_[(MAX_PRIME+1)/2] ; 

bool is_prime(ll_t x){
  if(x==2) return true;
  if(x<=1 || x%2==0) return false;
  return is_prime_[x/2];
}

void setup_prime()
{
  fill_n(is_prime_ , (MAX_PRIME+1)/2 , true);
  g_prime.clear() ; 
  g_prime.push_back(2);
  for(int i=3;i<=MAX_PRIME;i+=2){
    if(!is_prime_[i>>1]) continue;
    g_prime.push_back(i); 
    for(int j=i+i+i;j<=MAX_PRIME;j+=i+i){
      is_prime_[j>>1]=false;
    }
  }
}

int main()
{
  long x;
  cin>>x;
  setup_prime();
  while(!is_prime(x)) x++;
  cout<<x<<endl;

  return 0;
}


Measured memory_bytes: 512
#include "bits/stdc++.h"
using namespace std;

int main() {
	int N;
	cin >> N;
	int count4 = 0;
	int count2 = 0;
	for (int i = 0; i < N; ++i) {
		int n;
		cin >> n;
		if (0 == n % 4) {
			count4++;
		}
		else if (0 == n % 2) {
			count2++;
		}
	}
	N -= 2 * count4 + 1;
	if (N > 0) {
		N++;
	}
	if (count2 >= N) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
	return 0;
}

Measured memory_bytes: 3604
// AOJ 2064: Make Friendships
// 2017.11.8 bal4u@uu

#include <stdio.h>
#include <string.h>

#define HASHSIZ 2003
typedef struct { int v, id; } HASH;
HASH hash[HASHSIZ+2], *hashend = hash+HASHSIZ;

int lookup(int v)
{
	HASH *p = hash + v % HASHSIZ;
	while (p->v) {
		if (p->v == v) return p->id;
		if (++p == hashend) p = hash;
	}
	return -1;
}

void insert(int v, int id)
{
	HASH *p = hash + v % HASHSIZ;
	while (p->v) {
		if (p->v == v) return;
		if (++p == hashend) p = hash;
	}
	p->v = v, p->id = id;
}

#define MAX 1002
int   m, n;
char  graph[MAX][MAX];
char  seen[MAX];
short matchL[MAX], matchR[MAX];

int bpm(int u)
{
  int v;

  for (v = 0; v < n; v++) if (graph[u][v]) {
    if (seen[v]) continue;
    seen[v] = 1;
    if (matchR[v] < 0 || bpm(matchR[v])) {
      matchL[u] = v;
      matchR[v] = u;
      return 1;
    }
  }
  return 0;
}

int main()
{
	int M, i, j, ans;

	while (scanf("%d", &n) && n > 0) {
		memset(hash, 0, sizeof(hash));
		memset(graph, 0, sizeof(graph));
		scanf("%d", &M);
		m = 0; while (M--) {
			scanf("%d", &j);
			insert(j, m++);
		}
		for (i = 0; i < n; i++) {
			scanf("%d", &M);
			while (M--) {
				scanf("%d", &j);
				if ((j = lookup(j)) >= 0) graph[j][i] = 1;
			}
		}

	    memset(matchL, -1, m*sizeof(matchL[0]));
		memset(matchR, -1, n*sizeof(matchR[0]));

		ans = 0;
		for (i = 0; i < m; i++) {
			memset(seen, 0, n);
			if (bpm(i)) ans++;
		}
		printf("%d\n", ans);
	}
	return 0;
}

Measured memory_bytes: 2852
//Patwari26
//#include template<t> as mine
#include<bits/stdc++.h>
using namespace std;

#define ll          long long
#define pb          push_back
#define endl        '\n'
#define mii         map<ll,ll>
#define pii         pair<ll,ll>
#define vi          vector<ll>
#define all(a)      (a).begin(),(a).end()
#define x           first
#define y           second
#define sz(x)       (ll)x.size()
#define hell        1000000007
#define INF         (1ll<<60)
#define rep(i,a,b)  for(ll i=a;i<=b;i++)
#define rrep(i,a,b)  for(ll i=a;i>=b;i--)
#define ios ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define time        cerr << "\nTime elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << "ms\n";
ll gcd(ll a, ll b) { return b == 0 ? a : gcd(b, a % b); }
ll lcm(ll a, ll b) { return a * (b / gcd(a, b)); }
const int N=100005;
void solve(){
    ll n;
    cin>>n;
    string s;
    cin>>s;
    vi cr(n+1,0);
    rep(i,0,n-1) if(s[i]=='R') cr[i+1]++;
    rep(i,1,n) cr[i]+=cr[i-1];
    ll ans=cr[n]-cr[cr[n]];
    cout<<ans<<endl;
}
signed main()
{
    ios
    int TESTS=1;
    //cin>>TESTS;
    while(TESTS--){
        solve();
    }
    // time
    return 0;
}

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

#define INF_LL (int64)1e18
#define INF (int64)1e9
#define REP(i, n) for(int64 i = 0;i < (n);i++)
#define FOR(i, a, b) for(int64 i = (a);i < (b);i++)
#define all(x) x.begin(),x.end()
#define fs first
#define sc second

using int32 = int_fast32_t;
using uint32 = uint_fast32_t;
using int64 = int_fast64_t;
using uint64 = uint_fast64_t;
using PII = pair<int32, int32>;
using PLL = pair<int64, int64>;

const double eps = 1e-10;

template<typename A, typename B>inline void chmin(A &a, B b){if(a > b) a = b;}
template<typename A, typename B>inline void chmax(A &a, B b){if(a < b) a = b;}

template<typename T>
vector<T> make_v(size_t a){return vector<T>(a);}

template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
  return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}

template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value!=0>::type
fill_v(U &u,const V... v){u=U(v...);}

template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value==0>::type
fill_v(U &u,const V... v){
  for(auto &e:u) fill_v<T>(e,v...);
}


int main(void) {
    int64 sum;
    while (cin >> sum && sum) {
        vector<int64> A(9);
        REP(i, 9) cin >> A[i];
        cout << sum - accumulate(all(A), 0) << endl;
    }
}



Measured memory_bytes: 3088
#include <iostream>
#include <string>
#include <cstdlib>
#include <algorithm>
#include <utility>
 
using namespace std;

int gcd(int n, int m){

n=abs(n);
m=abs(m);

if(m<n){swap(m,n);}

if(m%n==0){return n;}
else{return gcd(m-n,n);}

}


int main() {

int N;
int X;
cin >>N>>X;

int ans;

int x;
cin>>x;

ans=abs(X-x);

for(int i=0;i<N-1;i++){
cin >>x;
ans=gcd(ans,X-x);}

cout <<ans;

}



Measured memory_bytes: 256
use std::io;

fn main() {
	let mut buf = String::new();
	io::stdin().read_line(&mut buf).expect("");
	let s = buf.trim().chars().collect::<Vec<char>>();
	let mut v = String::new();
	v = "".to_string();
	for i in 0..s.len() {
		if i%2 == 0 {
			v = format!("{}{}", v, s[i]);
		}
	}
	println!("{}", v);
}

Measured memory_bytes: 4352
using System;
using System.Collections.Generic;

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            // 各種変数の読み込み
            var n = int.Parse(Console.ReadLine());
            
            Console.WriteLine(((long)n) * (n - 1) / 2);
            

#if DEBUG
            Console.ReadKey();
#endif
        }
    }
}


Measured memory_bytes: 11092
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <map>
using namespace std;
typedef long long ll;
#define rep(i,n) for (int i=0;i < (int)(n);i++)

int main(){
  int n;
  string s,t;
  cin >> s >> t;
  int cnt = 0;
  rep(i,s.size()){
    if (s[i] != t[i]) cnt++;
  }
  cout << cnt << endl;
  return 0;
}


Measured memory_bytes: 3916