akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")
typedef long long lint;
typedef unsigned int uint;
typedef pair<int, int> pii;
typedef pair<lint, lint> pll;
typedef unsigned long long ulint;
#define endl '\n'
#define fst first
#define sed second
#define pb push_back
#define mp make_pair
#define rint register int
#define newline putchar('\n')
#define leave_space putchar(' ')
#define all(x) (x).begin(), (x).end()
#define reveal(x) cerr << #x << " = " << (x) << endl
#define rep(it, f, e) for (rint it = (f); it <= (e); ++it)
#define per(it, f, e) for (rint it = (f); it >= (e); --it)
const int MAXN = 1e5 + 10;
const int MAXV = (1 << 18) + 10;
int ary[MAXN];
struct Segment_Tree {
	#define lson (root << 1)
	#define rson (root << 1 | 1)
	#define len(x) (tree[x].stdr - tree[x].stdl + 1)
	#define mid ((tree[root].stdl + tree[root].stdr) >> 1)
	struct Node {
		lint tgl, tgr;
		int stdl, stdr;
	}	tree[MAXV];
	inline void buildtree(int root, int l, int r) {
		tree[root].stdl = l;
		tree[root].stdr = r;
		tree[root].tgl =
		tree[root].tgr = 0;
		if (l == r) return;
		buildtree(lson, l, mid);
		buildtree(rson, mid + 1, r);
	}
	inline void pushdown(int root) {
		if (tree[root].tgr) {
			lint cl = (tree[root].tgr - tree[root].tgl) / (len(root) - 1);
			tree[lson].tgl += tree[root].tgl;
			tree[lson].tgr += tree[root].tgl + (len(lson) - 1) * (cl);
			tree[rson].tgl += tree[root].tgl + len(lson) * cl;
			tree[rson].tgr += tree[root].tgr;
			tree[root].tgl = tree[root].tgr = 0;
		}
	}
	inline void add(int root, int l, int r, int al, int ar) {
		if (l == tree[root].stdl && tree[root].stdr == r) {
			tree[root].tgl += al;
			tree[root].tgr += ar;
			return;
		}
		pushdown(root);
		if (r <= mid) add(lson, l, r, al, ar);
		else if (l > mid) add(rson, l, r, al, ar);
		else {
			add(lson, l, mid, al, al + mid - l);
			add(rson, mid + 1, r, ar - r + mid + 1, ar);
		}
	}
	inline lint getans(int root) {
		if (tree[root].stdl == tree[root].stdr) {
			return tree[root].tgl;
		}
		pushdown(root);
		return max(getans(rson), getans(lson));
	}
	inline void print(int root) {
		if (tree[root].stdl == tree[root].stdr) {
			cout << tree[root].tgl << ' '; return;
		}
		pushdown(root);
		print(lson), print(rson);
	}
	#undef lson
	#undef rson
	#undef mid
	#undef len
}	Tree;
int main() {
	ios::sync_with_stdio(false);
	cin.tie(NULL), cout.tie(NULL);
	int n, m;
	lint ans = 0;
	cin >> n >> m;
	Tree.buildtree(1, 1, m); 
	rep (i, 1, n) {
		cin >> ary[i];
	}
	rep (i, 1, n - 1) {
		ans += ary[i] < ary[i + 1] ? ary[i + 1] - ary[i] : ary[i + 1] + m - ary[i];
		if (ary[i] < ary[i + 1]) {
			Tree.add(1, ary[i] + 1, ary[i + 1], 0, ary[i + 1] - ary[i] - 1);
		} else if (ary[i] > ary[i + 1]) {
			if (ary[i] != m) Tree.add(1, ary[i] + 1, m, 0, m - ary[i] - 1);
			Tree.add(1, 1, ary[i + 1], m - ary[i], m - ary[i] + ary[i + 1] - 1);
		}
	}
	cout << ans - Tree.getans(1) << endl;
	return 0;
}

Measured memory_bytes: 6784
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const ll INF = 1LL << 60;
const int MAX = 1000000010;
const ll MOD = 1000000007;
const double PI = acos(-1);

int main() {
    int N, M; cin >> N >> M;
    vector<bool> valid1(N + 1);
    vector<bool> validN(N + 1);
    for (int i = 0; i < M; i++) {
        int a, b; scanf("%d %d", &a, &b);
        if (a == 1) valid1[b] = 1;
        if (b == N) validN[a] = 1;
    }

    for (int i = 2; i <= N - 1; i++) {
        if (valid1[i] && validN[i]) {
            cout << "POSSIBLE" << endl;
            return 0;
        }
    }

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

Measured memory_bytes: 3732
#include <algorithm>
#include <iostream>
#include <cstdlib>
#include <cstring>
#include <cstdio>
#include <vector>
#include <cmath>
#include <ctime>
#include <queue>
#include <map>
#include <set>
using namespace std;
const int N=3e5+30,M=524288;
const int MAX=2e9;
const long long Mod=1e9+7;
int trans[8][2]={{2,1},{4,3},{6,5},{3,3},{7,1},{2,1},{2,2},{4,4}};
long long dp[N][8];
char s[N];
int n;
int main(){
    //freopen("problem.in","r",stdin);
    //freopen("problem.out","w",stdout);
    scanf("%s",s+1);
    n=strlen(s+1);
    dp[0][0]=1;
    for(int i=0;i<n;i++){
        for(int j=0;j<8;j++){
            if(s[i+1]!='0'){
                dp[i+1][trans[j][1]]+=dp[i][j];
                dp[i+1][trans[j][1]]%=Mod;
            }
            if(s[i+1]!='1'){
                dp[i+1][trans[j][0]]+=dp[i][j];
                dp[i+1][trans[j][0]]%=Mod;
            }
        }
    }
    printf("%lld\n",(dp[n][1]+dp[n][3])%Mod);
    return 0;
}

Measured memory_bytes: 19328
use std::io::prelude::*;

fn input<T: std::str::FromStr>() -> T {
    let stdin = std::io::stdin();
    let token: String = stdin
        .lock()
        .bytes()
        .map(|c| c.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().unwrap()
}

fn main() {
    let n: i32 = input();
    let a: i32 = input();
    let b: i32 = input();
    println!("{}", std::cmp::min(a * n, b));
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
const int mx = 305;

int n, ase[4];
double dp[mx][mx][mx];

double fun(int i, int j, int k){
    if(i+j+k == 0) return 0.0;

    double &ans = dp[i][j][k];
    if(ans > -0.5) return ans;

    double res = double(n) / (i+j+k); ans=0.0;
    if(i) ans += (fun(i-1,j,k)+res)   * i / (i+j+k);
    if(j) ans += (fun(i+1,j-1,k)+res) * j / (i+j+k);
    if(k) ans += (fun(i,j+1,k-1)+res) * k / (i+j+k);
    return ans;
}

int main(){
    cin.tie( nullptr );
    ios_base::sync_with_stdio(0);

    cin >> n;
    for(int x, i=0; i<n; i++)
        cin >> x, ase[x]++;

    for(int i=0; i<=n; i++)
    for(int j=0; j<=n; j++)
    for(int k=0; k<=n; k++)
        dp[i][j][k] = -1;

    cout << setprecision(10) << fixed;
    cout << fun(ase[1], ase[2], ase[3]) << "\n";

    return 0;
}


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

const int m_MAX = 50;
const int f_MAX = 50;
const int r_MAX = 100;
int m[m_MAX], f[f_MAX], r[r_MAX];

char scorejudge(int x, int y, int z){
	char scoreX;
	if (x == -1 || y == -1)scoreX = 'F';
	else if (x + y >= 80)scoreX = 'A';
	else if (x + y >= 65)scoreX = 'B';
	else if (x + y >= 50)scoreX = 'C';
	else if (x + y >= 30 && z >= 50)scoreX = 'C';
	else if (x + y >= 30)scoreX = 'D';
	else scoreX = 'F';
	return scoreX;
}

int scoreinput(){
	int i = 0;

	for (;; i++){
		cin >> m[i] >> f[i] >> r[i];
		if (m[i] == -1 && f[i] == -1 && r[i] == -1)break;
	}

	return i;
}

int main(){
	int i=scoreinput();

	for (int j = 0; j < i; j++){
		cout << scorejudge(m[j], f[j], r[j]) << endl;
	}

	return 0;
}


Measured memory_bytes: 3056
def wa(ka, li):
    t = 0
    i = 0
    while ka > 0:
        t = (t + (li[-(i + 1)] - li[i]) * (ka - 1)) % (10 ** 9 + 7)
        ka -= 2
        i += 1
    return t


n, m = map(int, input().split())
x = list(map(int, input().split()))
y = list(map(int, input().split()))
print(wa(n, x)*wa(m, y) % (10**9+7))

Measured memory_bytes: 18624
//Robs Code

/***********HEADER***************/
#include <iostream>
#include <bitset>
#include <deque>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <string>
#include <algorithm>
#include <list>
#include <vector>
#include <unordered_set>
#include <unordered_map>
#include <stack>
#include <set>
#include <queue>
#include <map>
#include <iomanip>

/***********MACROS***************/
#define int long long int
#define all(x) x.begin(),x.end()
#define allr(x) x.rbegin(),x.rend()
#define endl "\n"
#define pb push_back
#define _1 first
#define _2 second
#define pii pair<int,int>

using namespace std;

const int N = 1e5 + 1;
int n,m,i,j,k,l,x,y,z,cnt[3],sum[3];

/***********MAIN**************/
signed main(){
	ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
	cin >> n;
	vector<int> v(n);
	for(auto &x : v){
		cin >> x;
	}
	int ans = 0;
	for(int i = 0;i < n;i++){
		for(int j = i + 1;j < n;j++){
			for(int k = j + 1;k < n;k++){
				if(v[i] == v[j] || v[j] == v[k] || v[k] == v[i]) continue;
				if((v[i] + v[j]) <= v[k]){
					continue;
				}
				if((v[j] + v[k]) <= v[i]){
					continue;
				}
				if((v[k] + v[i]) <= v[j]){
					continue;
				}
				ans++;
			}
		}
	}
	cout << ans;
}
//.........

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

int main() {
  int a , b;
  cin >> a >> b;
  
  if(a%2 == 1 && b%2 == 1){
    cout << "Odd" << endl;
  }
  
  else{
    cout << "Even" << endl;
  }
    
    
}

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

#define ln                '\n'
#define all(dat)           dat.begin(), dat.end()
#define loop(i, to)        for (int i = 0; i < to; ++i)
#define cont(i, to)        for (int i = 1; i <= to; ++i)
#define circ(i, fm, to)    for (int i = fm; i <= to; ++i)
#define foreach(i, dat)    for (__typeof(dat.begin()) i = dat.begin(); i != dat.end(); ++i)

typedef long long          num;

using namespace std;

const int nsz = 2e5;
const num inf = 0x3f3f3f3f3f3f3f3f;
int n, m;
num w[nsz + 5], dp[nsz + 5], ans;
pair<pair<int, int>, int> dat[nsz + 5];
vector<int> sl[nsz + 5], sr[nsz + 5];

struct segment_tree {
#define ls (u << 1)
#define rs (u << 1 | 1)
    num mx[4 * nsz + 5], del[4 * nsz + 5];
    
    void inline down(int u) {
        if (!del[u])  return;
        mx[ls] += del[u];
        del[ls] += del[u];
        mx[rs] += del[u];
        del[rs] += del[u];
        del[u] = 0;
    }
    
    void inline upd(int el, int er, num val, int u = 1, int l = 0, int r = n) {
        if (l >= el && r <= er) {
            mx[u] += val;
            del[u] += val;
            return;
        }
        down(u);
        int md = (l + r) >> 1;
        if (el <= md) {
            upd(el, er, val, ls, l, md);
        }
        if (er > md) {
            upd(el, er, val, rs, md + 1, r);
        }
        mx[u] = max(mx[ls], mx[rs]);
    }
    
    num inline qry(int el, int er, int u = 1, int l = 0, int r = n) {
        if (l >= el && r <= er)  return mx[u];
        down(u);
        int md = (l + r) >> 1;
        num res = -inf;
        if (el <= md) {
            res = qry(el, er, ls, l, md);
        }
        if (er > md) {
            res = max(res, qry(el, er, rs, md + 1, r));
        }
        return res;
    }
};
segment_tree tr;

int main() {
    scanf("%d%d", &n, &m);
    cont (i, m) {
        int l, r, c;
        scanf("%d%d%d", &l, &r, &c);
        w[l] += c;
        w[r + 1] -= c;
        dat[i] = make_pair(make_pair(l, r), c);
        sl[l].push_back(i);
        sr[r].push_back(i);
    }
    cont (i, n) {
        w[i] += w[i - 1];
    }
    cont (i, n) {
        dp[i] = tr.qry(0, i - 1) + w[i];
        tr.upd(i, i, dp[i]);
        loop (j, sl[i].size()) {
            int id = sl[i][j], l = dat[id].first.first, r = dat[id].first.second, c = dat[id].second;
            tr.upd(l, r, -c);
        }
        loop (j, sr[i].size()) {
            int id = sr[i][j], l = dat[id].first.first, r = dat[id].first.second, c = dat[id].second;
            tr.upd(l, r, +c);
        }
    }
    cont (i, n) {
        ans = max(ans, dp[i]);
    }
    printf("%lld\n", ans);
}

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

using namespace std;


bool solve()
{
	int n; cin >> n;
	if (n == 0)return false;

	int ans = 1000000;
	for (int z = 0; z*z*z <= n; ++z)
	{
		for (int y = 0; z*z*z + y*y <= n; ++y)
		{
			int x = n - z*z*z - y*y;
			ans = min(ans, x + y + z);
		}
	}
	cout << ans << endl;
	return true;
}


int main()
{
	while(solve())
	{
	}
	


	return 0;
}


Measured memory_bytes: 2980
from collections import Counter
S = input()

check_str = 'LR'
S_=[]
s_temp = ''
for s in range(len(S)):
    s_temp += S[s]
    
    if s < len(S)-1:
        s_= s+1 
        if S[s]=='L' and S[s_] == 'R':
            S_.append(Counter(s_temp))
            s_temp =''
            
    else:
        S_.append(Counter(s_temp))

def get_ans_temp(S_temp):
    S_R = S_temp['R']
    S_L = S_temp['L']
    
    S_R_ans=[0]*S_R
    S_L_ans=[0]*S_L
    
    if (S_R + S_L) % 2 ==0 :#偶数の時
        S_R_ans[-1] = (S_R + S_L) // 2
        S_L_ans[0] = (S_R + S_L) // 2

    elif S_R != S_L :#奇数の時
        if S_R > S_L:
            S_R_ans[-1] = (S_R + S_L) // 2 +1
            S_L_ans[0] = (S_R + S_L) // 2         
        else:
            S_R_ans[-1] = (S_R + S_L) // 2
            S_L_ans[0] = (S_R + S_L) // 2 + 1
            
        max_RL_num = max(S_R,S_L)
        if max_RL_num % 2 == 0:
            _ = S_R_ans[-1]
            S_R_ans[-1]=S_L_ans[0]
            S_L_ans[0]=_

    ans_temp = []
    ans_temp.extend(S_R_ans)
    ans_temp.extend(S_L_ans)
    return ans_temp

ans_list=[]
for S_temp in S_:
    ans_list.extend(get_ans_temp(S_temp))
    
ans=' '.join(map(str,ans_list))

print(ans)

Measured memory_bytes: 118612
mod = 10**9 + 7

def power(b, e):
	if e == 0: return 1

	half = power(b, e // 2)

	if e % 2 == 0:
		return (half * half) % mod
	else:
		return (((half * half) % mod) * b) % mod

def mod_inv(n):
	return power(n, mod - 2)

def choose(n, a):
	num = 1
	den = 1
	for i in range(1, a + 1):
		num = (num * (n - i + 1)) % mod
		den = (den * i) % mod

	# print("inv:", mod_inv(den))
	# print(num, den)
	return (num * mod_inv(den)) % mod


if __name__ == "__main__":
	line = input().split(" ")
	n, a, b = int(line[0]), int(line[1]), int(line[2])

	# print(power(2, n))
	# print("nca", choose(n, a))
	# print("ncb", choose(n, b))
	ans = (power(2, n) - choose(n, a) - choose(n, b) - 1 + 2* mod) % mod 

	print(ans)

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

int main(void){
  int h, w;
  cin >> h >> w;

  char input;
  vector<vector<bool> > cloud(h, vector<bool>(w, false));
  for(int i = 0; i < h; i++){
    for(int j = 0; j < w; j++){
      cin >> input;
      if(input == 'c'){ cloud[i][j] = true; }
    }
  }

  vector<vector<int> > ans(h, vector<int>(w, -1));
  for(int i = 0; i < h; i++){
    for(int j = 0; j < w; j++){
      for(int k = j; k >= 0; k--){
        if(cloud[i][k]){
          ans[i][j] = j - k;
          break;
        }
      }
    }
  }

  for(int i = 0; i < h; i++){
    for(int j = 0; j < w; j++){
      if(j != 0){ cout << " "; }
      cout << ans[i][j];
    }
    cout << endl;
  }
  
  return 0;
}

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

int main(){
	int N, M, P, X;
	int i;
	double rate, sum;
	
	cin >> N >> M >> P;
	while(N!=0 || M!=0 || P!=0){
		vector<int> v;
		sum=0.0;
		rate=100-P;
		
		for(i=0; i<N; ++i){
			cin >> X;
			sum+=100*X;
			v.push_back(X);
		}
		sum=sum*rate/100/v[M-1];
		
		if(v[M-1]==0) cout << 0 << endl;
		else cout << (int)sum << endl;
		
		cin >> N >> M >> P;
	}
	return 0;
}

Measured memory_bytes: 3120
from itertools import product

H, W, K = map(int, input().split())
S = [[int(i) for i in input()] for _ in range(H)]

T = [t for t in zip(*S)]
if sum(map(sum, T)) <= K:
    print(0)
    quit()

ans = float("inf")
for P in product([0, 1], repeat=H - 1):
    cnt = sum(P)
    if cnt >= ans:
        continue

    II = [[0]]
    for i, p in enumerate(P, 1):
        if p:
            II.append([])
        II[-1].append(i)

    A = [0] * len(II)
    for t in T:
        for i, I in enumerate(II):
            A[i] += sum(t[x] for x in I)

        if any(a > K for a in A):
            cnt += 1
            if cnt >= ans:
                break

            A = [sum(t[x] for x in I) for I in II]
            if any(a > K for a in A):
              cnt = 1 + ans
              break

    ans = min(ans, cnt)

print(ans)

Measured memory_bytes: 3316
#include <bits/stdc++.h>
#define repi(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rrepi(i,a,b) for(int i=((int)(b)-1);i>=(a);--i)
#define rep(i,n) repi(i,0,n)
#define rrep(i,n) rrepi(i,0,n)
#define ALL(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
#define ZERO(x) memset(x,0,sizeof(x))
#define MINUS(x) memset(x,-1,sizeof(x))
#define UNIQUE(x) (x).erase(unique(ALL(x)), (x).end())
#define TOUPPER(x) transform(ALL(x), (x).begin(), ::toupper)
#define TOLOWER(x) transform(ALL(x), (x).begin(), ::tolower)
#define debug(var)  do{std::cout << #var << " : "; view(var);}while(0)
#define fi first
#define se second
using namespace std;
using ll = long long;
using P = pair<int,int>;
template<typename T> void view(const std::vector<T>& v){for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void view(const std::vector<std::vector<T> >& vv){for(const auto& v : vv){ view(v); } }
template<typename T> void view(T e){std::cout << e << std::endl;}
template<typename T> void viewarr(T arr[], int n) { for(int i = 0; i < n; ++i) std::cout << arr[i] << " "; std::cout << std::endl; }
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; }
ll qp(ll a,ll b){ll ans=1;do{if(b&1)ans=1ll*ans*a;a=1ll*a*a;}while(b>>=1);return ans;}
ll qp(ll a,ll b,ll mo){ll ans=1;do{if(b&1)ans=1ll*ans*a%mo;a=1ll*a*a%mo;}while(b>>=1);return ans;}
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
const int INF = 1e9;
const ll INFL = 1e18;
const int MOD = 1e9 + 7;
const int MAX_N = 1e5;

int main() {
    int X, Y; cin >> X >> Y;
    rep(i,X+1) {
        int leg = 2 * i + 4 * (X - i);
        if(leg == Y) {
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 3636
from sys import stdin, setrecursionlimit
from collections import Counter, deque, defaultdict
from math import floor, ceil
from bisect import bisect_left
from itertools import combinations
setrecursionlimit(100000)

INF = int(1e10)
MOD = int(1e9 + 7)

def main():
    from builtins import int, map
    a, b, c, d = map(int, input().split())
    ans = max(
        a * c,
        a * d,
        b * c,
        b * d
    )
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 65228
#include<iostream>

using namespace std;

const int MAX = 105;
const int MOD = 10000;

int N,K;
int pasta[MAX];
int dp[MAX][3][3];

void input(){
  cin >> N >> K;
  for(int i = 0; i < K; i++){
    int a,b;
    cin >> a >> b;
    pasta[a] = b;
  }
}

void solve(){
 

  if(pasta[1] == 0){
    for(int i = 0; i < 3; i++) dp[1][i][0] = 1;
  }else{
    dp[1][pasta[1]-1][0] = 1;
  }
  
  for(int i = 1; i < N; i++){//day
    if(pasta[i+1] != 0){
    
      for(int j = 0; j < 3; j++)// previous pasta
	for(int k = 0; k < 2; k++) //number of day of eating same pasta
	  if(pasta[i+1]-1 == j){
	    if(k < 1) dp[i+1][j][k+1] = (dp[i+1][j][k+1]+dp[i][j][k])%MOD;
	  }else{
	    dp[i+1][pasta[i+1]-1][0] = (dp[i+1][pasta[i+1]-1][0]+dp[i][j][k])%MOD;
	  }
	 
    
    }else{
    
      for(int j = 0; j < 3; j++)//next pasta
	for(int k = 0; k < 3; k++)// previous pasta
	  for(int l = 0; l < 2; l++)//number of day of eating same pasta
	    if(j == k){
	      if(l < 1) dp[i+1][j][l+1] = (dp[i+1][j][l+1]+dp[i][j][l])%MOD;
	    }else{
	      dp[i+1][j][0] = (dp[i+1][j][0]+dp[i][k][l])%MOD;
	    }
	  
    }
  }

  long long ans = 0;

  for(int i = 0; i < 3; i++)
    for(int j = 0; j < 2; j++)
      ans += dp[N][i][j];
  cout << ans%MOD << endl;
}

int main(){
  input();
  solve();
  return 0;
}

Measured memory_bytes: 1160
#include<stdio.h>
int main(void){
	int a,b,ans;
	char op;
	while(op!='?'){
		scanf("%d %c %d",&a,&op,&b);
		switch(op){
		case '+':
			ans = a+b;
			printf("%d\n",ans);
			break;
		case '-':
			ans = a-b;
			printf("%d\n",ans);
			break;
		case '*':
			ans = a*b;
			printf("%d\n",ans);
			break;
		case '/':
			ans = a/b;
			printf("%d\n",ans);
			break;
		}
	}
	
	return 0;
}

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

int main() {
    string s;
    cin >> s;
    for (int bit = 0; bit < (1<<3); ++bit){
        string pm;
        int sum = s[0] - '0';
        for (int i = 0; i < 3; ++i) {
            if (bit & (1<<i)) {
                sum += s[i+1] - '0';
                pm.push_back('+');
            } else {
                sum -= s[i+1] - '0';
                pm.push_back('-');
            }
        }
        if(sum == 7) {
            cout << s[0] << pm[0] << s[1] << pm[1] << s[2] << pm[2] << s[3] << "=7" << '\n';
            return 0;
        }
    }
    
    return 0;
}


Measured memory_bytes: 256
n = int(input())
a = list(map(int,input().split()))
ans = 0
for i in range(n-1) :
    if a[i+1] - a[i] >= 0 :
        continue
    else :
        ans += abs(a[i+1] - a[i])
        a[i+1] += abs(a[i+1] - a[i])
print(ans)

Measured memory_bytes: 32092
#include <algorithm>
#include <iostream>
#include <vector>
#include <string>
#include <cstring>
class JNum{
	static constexpr uint64_t mod = 1000000007;
	uint64_t num;
public:
	JNum(uint64_t x):num(x%mod){}
	JNum operator+(const JNum& j)const{
		return (num + j.num)%mod;
	}
	JNum operator*(const JNum& j)const{
		return (num * j.num)%mod;
	}
	void operator+=(const JNum& j){
		num += j.num;
		num %= mod;
	}
	void operator*=(const JNum& j){
		num *= j.num;
		num %=mod;
	}
	uint64_t out()const{return num;}
};

int main(void){
	int n,l;
	std::cin >> n;
	std::vector<int64_t> v;
	for(int i=0;i<n;i++){
		int64_t x;
		std::cin >> x;
		v.push_back(x);
	}
	uint64_t ans1=0,ans2=0;
	int64_t cur1=0,cur2=0;
	int c1 = 1,c2 = -1;
	for(int i=0;i<v.size();i++){
		cur1 += v[i];cur2+=v[i];
		if(cur1 * c1<=0){
			ans1 += std::abs(cur1)+1;
			cur1=c1;		
		}
		if(cur2 * c2 <=0){
			ans2 += std::abs(cur2)+1;
			cur2=c2;		
		}
		c1*=-1;c2*=-1;
	}
	if(ans2<ans1)ans1=ans2;
	std::cout << ans1 << std::endl;
}

Measured memory_bytes: 1400
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb push_back
#define pll pair<long long int, long long int>
#define great (long long int)(1e9+7)
#define fastio ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define fst first
#define scd second

void solve()
{
   ll n,m,k;
   cin>>n>>m>>k;
   ll A[n],B[m];
   for(ll i=0;i<n;i++)
   {
       cin>>A[i];
   }
    for(ll i=0;i<m;i++)
   {
       cin>>B[i];
   }
   vector<ll>a,b;
   ll s=0;
   for(ll i=0;i<n;i++)
   {
       s=s+A[i];
       a.pb(s);
   }
   s=0;
   for(ll i=0;i<m;i++)
   {
       s=s+B[i];
       b.pb(s);
   }
   if(k<a[0]&&k<b[0]) {cout<<0<<endl;return;}
   ll ans=0;
   for(ll i=0;i<n&&a[i]<=k;i++)
   {ll ind1,ind2;

       if(*(lower_bound(a.begin(),a.end(),a[i]))==a[i])
       {
            auto it1=lower_bound(a.begin(),a.end(),a[i]);
            ind1=it1-a.begin()+1;
           ll n1=k-a[i];
           //if(n1<0) break;
           if(*(lower_bound(b.begin(),b.end(),n1))==n1)
           {
               auto it2=lower_bound(b.begin(),b.end(),n1);
               ind2=it2-b.begin()+1;

           }
           else
           {
                auto it2=lower_bound(b.begin(),b.end(),n1);
                ind2=it2-b.begin();
           }

       }
       else
       {
           auto it1=lower_bound(a.begin(),a.end(),a[i]);
           ind1=it1-a.begin();
           ll n1=k-a[i];
           //if(n1<0) break;
           if(*(lower_bound(b.begin(),b.end(),n1))==n1)
           {
                auto it2=lower_bound(b.begin(),b.end(),n1);
                ind2=it2-b.begin()+1;

           }
           else
           {
                auto it2=lower_bound(b.begin(),b.end(),n1);
                ind2=it2-b.begin();

           }
       }
       ans=max(ans,ind1+ind2);

   }
   for(ll i=0;i<m&&b[i]<=k;i++)
   {ll ind1,ind2;

       if(*(lower_bound(b.begin(),b.end(),b[i]))==b[i])
       {
            auto it1=lower_bound(b.begin(),b.end(),b[i]);
            ind1=it1-b.begin()+1;
           ll n1=k-b[i];
           //if(n1<0) break;
           if(*(lower_bound(a.begin(),a.end(),n1))==n1)
           {
               auto it2=lower_bound(a.begin(),a.end(),n1);
               ind2=it2-a.begin()+1;

           }
           else
           {
                auto it2=lower_bound(a.begin(),a.end(),n1);
                ind2=it2-a.begin();
           }

       }
       else
       {
           auto it1=lower_bound(b.begin(),b.end(),b[i]);
           ind1=it1-b.begin();
           ll n1=k-b[i];
           //if(n1<0) break;
           if(*(lower_bound(a.begin(),a.end(),n1))==n1)
           {
                auto it2=lower_bound(a.begin(),a.end(),n1);
                ind2=it2-a.begin()+1;

           }
           else
           {
                auto it2=lower_bound(a.begin(),a.end(),n1);
                ind2=it2-a.begin();

           }
       }
       ans=max(ans,ind1+ind2);

   }
    cout<<ans<<endl;
}
int main()
{
    //fastio;
    ll t=1;
    //cin>>t;
    while(t--)
        solve();
    return 0;
}


Measured memory_bytes: 11056
a,b,c,d=[int(i) for i in input()]

if a+b+c+d==7:
    print("{}+{}+{}+{}=7".format(a,b,c,d))
elif a+b+c-d==7:
    print("{}+{}+{}-{}=7".format(a,b,c,d))
elif a+b-c+d==7:
    print("{}+{}-{}+{}=7".format(a,b,c,d))
elif a-b+c+d==7:
    print("{}-{}+{}+{}=7".format(a,b,c,d))
elif a+b-c-d==7:
    print("{}+{}-{}-{}=7".format(a,b,c,d))
elif a-b+c-d==7:
    print("{}-{}+{}-{}=7".format(a,b,c,d))
elif a-b-c+d==7:
    print("{}-{}-{}+{}=7".format(a,b,c,d))
else:
    print("{}-{}-{}-{}=7".format(a,b,c,d))

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

#define REP(i, n) for(int (i) = 0; (i) < (n); ++(i))
#define REPR(i, n) for(int (i) = (n); (i) >= 0; --(i))
#define FOR(i, n, m) for(int (i) = (n); (i) < (m); ++(i))

constexpr int INF = 1e9;
//constexpr ll INF = 1LL<<61;
// constexpr ll mod = 1e9+7;


int main(){
  int N, K;
  cin >> N >> K;
  vector<int> A(N);
  REP(i, N){
    cin >> A[i];
  }
  int loop = K;
  while(loop--){
    vector<int> sum(N+1, 0);
    REP(i, N){
      int right =min(A[i]+i+1, N);
      int left = max(i-A[i], 0);
      sum[right]--;
      sum[left]++;
    }
    REP(i, N){
      sum[i+1] += sum[i];
      A[i] = sum[i];
    }
    bool flag = true;
    REP(i, N){
      if(A[i] != N){
        flag = false;
        break;
      }
    }
    if(flag) break;
  }
  REP(i, N){
    cout << A[i] << " ";
  }
  cout << endl;
  return 0;
}

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

#define MAX(a,b) ((a)>(b)?(a):(b))

int cmp(const void *a,const void *b){
  return *(int *)a-*(int *)b;
}

void run(void){
  int n,m;
  scanf("%d%d",&n,&m);
  int cnt[10]={9,2,5,5,4,5,6,3,7,6};
  int use[10]={0};
  while(m--){
    int a;
    scanf("%d",&a);
    use[a]=1;
  }
  int *dp=(int *)calloc(n+1+6,sizeof(int));
  const int ini=-1;
  int i,j;
  for(i=1;i<=n;i++) dp[i]=ini;
  for(i=0;i<n;i++){
    if(dp[i]==ini) continue;
    for(j=1;j<=9;j++){
      if(use[j]==0) continue;
      int c=cnt[j];
      dp[i+c]=MAX(dp[i+c],dp[i]+1);
    }
  }
  int ans[10]={0};
  i=n;
  while(i>0){
    for(j=9;j>=1;j--){
      int c=cnt[j];
      if(use[j]==0 || i-c<0) continue;
      if(dp[i-c]==dp[i]-1){
	ans[j]++;
	i-=c;
	break;
      }
    }
  }
  for(i=9;i>=1;i--){
    while(ans[i]--) putchar('0'+i);
  }
  puts("");
}

int main(void){
  run();
  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

int main(void){
	int sum;
	int i,j;
	
	for(i=1;i<=9;i++){
		for(j=1;j<=9;j++){
			sum=i*j;
			printf("%dx%d=%d\n",i,j,sum);
		}
	}
	
	return 0;
}

Measured memory_bytes: 0
#define _USE_MATH_DEFINES	//M_PI
#include <iostream>			//std::cout, std::cin
#include <string>			//std::string
#include <vector>			//std::vector
#include <valarray>			//std::valarray	??°????????????????¬???????
#include <algorithm>		//std::sort
#include <time.h>			//localtime_s
#include <cstdlib>			//abs
#include <cmath>			//abs, pow, sqrt, sin, cos,
#include <fstream>			//std::ifstream
#include <iomanip>			//std::setprecision
#include <random>			//std::random

int main(void) {

	//test??¨
	//std::ifstream in("test.txt");
	//std::cin.rdbuf(in.rdbuf());

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

	int q = 0;
	std::cin >> q;
	std::vector<int> ans(q);

	for (int i = 0; i < q; i++) {

		int up, front;
		std::cin >> up >> front;

		std::random_device order;
		while (dice[0] != up || dice[1] != front) {
			int temp[6];
			if (order() % 2 == 0) {
				temp[0] = dice[3];
				temp[1] = dice[1];
				temp[2] = dice[0];
				temp[3] = dice[5];
				temp[4] = dice[4];
				temp[5] = dice[2];
				for (int j = 0; j < 6; j++) {
					dice[j] = temp[j];
				}
			}
			else {
				temp[0] = dice[1];
				temp[1] = dice[5];
				temp[2] = dice[2];
				temp[3] = dice[3];
				temp[4] = dice[0];
				temp[5] = dice[4];
				for (int j = 0; j < 6; j++) {
					dice[j] = temp[j];
				}
			}
		}
		ans[i] = dice[2];
	}

	for (int i = 0; i < q; i++) {
		std::cout << ans[i] << std::endl;
	}

}

Measured memory_bytes: 3220
#include<bits/stdc++.h>
using namespace std;
int main() {
  int x,y;
  bool f = true;
  cin>> x >> y;
  for ( int i = 0 ; i <=  x ; i++ ) {
    int a = y-2*i;
    if (a == 4*(x-i) ) {
      cout << "Yes" << endl;
      f = false;
      break;
    }
  }
  
  if (f) {
    cout << "No" << endl;  }
}

Measured memory_bytes: 3596
from collections import Counter
def solve():
    N = int(input())
    A = list(map(int, input().split()))
    counter = Counter(A)

    mx = -1
    for i in range(1,10**5):
        sm = counter[i-1]+counter[i]+counter[i+1]
        mx = max(sm,mx)
        
    print(mx)




if __name__ == '__main__':
    solve()

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

public class Main {
	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String[] input = br.readLine().split(" ");
		int[] sides = new int[6];
		for (int i = 0; i < 6; i++) {
			sides[i] = Integer.parseInt(input[i]);
		}
		Dice dice = new Dice(sides);

		char[] ca = br.readLine().toCharArray();
		for (char c : ca) {
			switch (c) {
				case 'N':
					dice.N();
					break;
				case 'E':
					dice.E();
					break;
				case 'S':
					dice.S();
					break;
				case 'W':
					dice.W();
					break;
				default:
				break;
			}
		}
		System.out.println(dice.getSide(0));
	}
	
}
class Dice {
	private int[] sides = new int[6];
	Dice(int[] sides) {
		this.sides = sides;
	}

	public void N() {
		int tmp = sides[0];
		sides[0] = sides[1];
		sides[1] = sides[5];
		sides[5] = sides[4];
		sides[4] = tmp;
	}

	public void E() {
		int tmp = sides[0];
		sides[0] = sides[3];
		sides[3] = sides[5];
		sides[5] = sides[2];
		sides[2] = tmp;
	}

	public void S() {
		int tmp = sides[0];
		sides[0] = sides[4];
		sides[4] = sides[5];
		sides[5] = sides[1];
		sides[1] = tmp;
	}

	public void W() {
		int tmp = sides[0];
		sides[0] = sides[2];
		sides[2] = sides[5];
		sides[5] = sides[3];
		sides[3] = tmp;
	}

	public int getSide(int i) {
		return sides[i];
	}
}

Measured memory_bytes: 17064
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<n; i++)
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
long long mo = 1e9 + 7;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
template<class A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}cout << "\n";}
ld PI=3.14159265358979323846;

ll N,A,B,C;
vector<ll> l(8);
ll dfs(ll cur, ll a, ll b, ll c){
    if(cur == N){
        if(min(min(a,b),c) > 0){
            return abs(A-a) + abs(B-b) + abs(C-c) -30;
        }
        return 1e18;
    }
    ll ret0 = dfs(cur+1, a,b,c);
    ll ret1 = dfs(cur+1, a + l[cur], b, c)+10;
    ll ret2 = dfs(cur+1, a, b + l[cur], c)+10;
    ll ret3 = dfs(cur+1, a, b, c+l[cur])+10;
    return min(min(ret0,ret1),min(ret2,ret3));
}


int main(){
    cin >> N >> A >> B >> C;
    rep(i,N){
        cin >> l[i];
    }
    cout << dfs(0,0,0,0) << endl;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using ld=long double;
#define rep(i, n) for (int i = 0; i < (n); i++)
using P=pair<int,int>;
int main() {
    string s;cin>>s;
    cout<<s[0]<<s[1]<<s[2]<<endl;
}

Measured memory_bytes: 3628
n,k = gets.split.map(&:to_i)
a = []
k = k.to_f
for i in 1..n
  s = Math.log2(k/i).ceil
  s = 0 if s < 0
  a << s
end
x = 0.to_f
a.each do |j|
  x += (0.5**j).to_f
end
puts (1.to_f/n)*x

Measured memory_bytes: 2684
#ifndef ___Rank_Union_Find
#define ___Rank_Union_Find

#include <vector>

// ------ Class ------ //
class UnionFind {
private:
	unsigned size_; std::vector<unsigned> par, rank;
public:
	UnionFind() : size_(0), par(std::vector<unsigned>()), rank(std::vector<unsigned>()) {};
	UnionFind(unsigned size__) : size_(size__) {
		par.resize(size_); rank.resize(size_);
		for (unsigned i = 0; i < size_; i++) par[i] = i, rank[i] = 0;
	}
	unsigned size() { return size_; }
	unsigned root(unsigned x) { return par[x] == x ? x : par[x] = root(par[x]); }
	bool same(unsigned x, unsigned y) { return root(x) == root(y); }
	void unite(unsigned x, unsigned y) {
		x = root(x), y = root(y);
		if (x == y) return;
		if (rank[x] < rank[y]) par[x] = y;
		else if (rank[x] == rank[y]) par[y] = x, rank[x]++;
		else par[y] = x;
	}
	bool operator==(const UnionFind &u) { return par == u.par; }
	bool operator!=(const UnionFind &u) { return par != u.par; }
};

#endif

#include <set>
#include <string>
#include <vector>
#include <iostream>
using namespace std;
vector<int> x, y; int t;
bool same(vector<int> a, vector<int> b) {
	for (int i = 0; i < 4; i++) {
		for (int j = 0; j < 4; j++) {
			for (int k = 0; k < 4; k++) {
				for (int l = 0; l < 4; l++) {
					string s;
					for (int m = 0; m < i; m++) s += 'N';
					for (int m = 0; m < j; m++) s += 'E';
					for (int m = 0; m < k; m++) s += 'S';
					for (int m = 0; m < l; m++) s += 'W';
					for (int i = 0; i < s.size(); i++) {
						t = a[0];
						switch (s[i]) {
						case 'N':
							a[0] = a[1];
							a[1] = a[5];
							a[5] = a[4];
							a[4] = t;
							break;
						case 'E':
							a[0] = a[3];
							a[3] = a[5];
							a[5] = a[2];
							a[2] = t;
							break;
						case 'S':
							a[0] = a[4];
							a[4] = a[5];
							a[5] = a[1];
							a[1] = t;
							break;
						case 'W':
							a[0] = a[2];
							a[2] = a[5];
							a[5] = a[3];
							a[3] = t;
							break;
						}
					}
					if (a == b) return true;
				}
			}
		}
	}
	return false;
}
int n; string s;
int main() {
	while (cin >> n, n) {
		vector<vector<int> > v(n, vector<int>(6));
		for (int i = 0; i < n; i++) {
			for (int j = 0; j < 6; j++) {
				cin >> s;
				v[i][j] = s[0];
			}
		}
		UnionFind uf(n);
		for (int i = 0; i < n; i++) {
			for (int j = i + 1; j < n; j++) {
				if (same(v[i], v[j])) uf.unite(i, j);
			}
		}
		set<int> s_;
		for (int i = 0; i < n; i++) s_.insert(uf.root(i));
		cout << n - s_.size() << endl;
	}
	return 0;
}

Measured memory_bytes: 3180
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef long double ld;
const int inf=1e9+7;
const ll longinf=1LL<<60;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define F first
#define S second

const int mx=200010;
const ll mod=1e9+7;

//snuke
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const {
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res*=a;
  }
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }
 
  // for prime mod
  mint inv() const {
    return pow(mod-2);
  }
  mint& operator/=(const mint a) {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const {
    mint res(*this);
    return res/=a;
  }
};
 
int main(){
  int n;
  cin >> n;
  vector<ll> c(n);
  rep(i,n){ cin >> c[i]; }
  sort(c.begin(),c.end());
  
  vector<mint> two(n+1);
  two[0] = 1;
  rep(i,n){ two[i+1] = two[i]*2; }

  mint ans=0;
  for(int i=0; i<n; i++){
    int l=i, r=n-1-i;
    mint cur = two[r];
    if(r!=0){ cur += two[r-1]*r;}
    cur *= two[l];
    cur *= c[i];
    ans += cur;
  }
  ans *= two[n];
  cout << ans.x << endl; 
  return 0;
}

Measured memory_bytes: 3328
def calc(i, subed=False):
    if i >= len(k_bin):
        return 0
    pos = len(k_bin)-i-1

    max_val = 0
    if ones[pos] <= N//2 and (subed or k_bin[i] == '1'):
        max_val = (N-ones[pos]) * 2**pos + calc(i+1, subed)
    else:
        max_val = max(max_val, ones[pos] * 2**pos +
                      calc(i+1, True if k_bin[i] == '1' else subed))
    return max_val


N, K = map(int, input().split())
As = list(map(int, input().split()))

max_length = 0

ones = [0] * 40
for a in As:
    a_bin = bin(a)[2:]
    max_length = max(max_length, len(a_bin))
    for i in range(len(a_bin)):
        if a_bin[i] == '1':
            pos = len(a_bin)-i-1
            ones[pos] += 1

k_bin = bin(K)[2:].rjust(max_length, "0")
print(calc(0))


Measured memory_bytes: 14828
import java.util.Scanner;

public class Main {

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

        if (c >= a && b >= c) {
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }
    }
}


Measured memory_bytes: 21844
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define For(i,n,k) for(int i=(n);i<(k);i++)
#define ALL(a)  (a).begin(),(a).end()
void Main(){
    ll n;
    cin>>n;
    string ans="";
    while(n){
        char c=n%26+'a'-1;
        if(n%26==0){
            c='z';
            n--;
        }
        n/=26;
        ans.push_back(c);
    }
    reverse(ALL(ans));
    cout<<ans<<endl;
}
int main(){
    Main();
    /*
    東方風神録は神が出てくるので当然神ゲー
    */
    return 0;
}

Measured memory_bytes: 3628
<?php
    $l1 = str_split(trim(fgets(STDIN)));
    $l2 = str_split(trim(fgets(STDIN)));
    $l3 = str_split(trim(fgets(STDIN)));
    $num = array(0,0,0);

    $card = $l1[0];
    $last_turn = "";

    while($num[0] != count($l1) + 1 && $num[1] != count($l2) + 1 && $num[2] != count($l3) + 1){
        switch ( $card ) {
            case "a":
                $card = $l1[$num[0]];
                $last_turn = "a";
                $num[0]++;
                break;

            case "b":
                $card = $l2[$num[1]];
                $last_turn = "b";
                $num[1]++;
                break;

            case "c":
                $card = $l3[$num[2]];
                $last_turn = "c";
                $num[2]++;
                break;
            
            default:
                break;
        }
//        echo $num[0].$num[1].$num[2]." card:".$card." last:".strtoupper($last_turn);
//        echo "\r\n";
    }
    echo strtoupper($last_turn);
?>


Measured memory_bytes: 3576
#include <iostream>
#include <string>

using namespace std;

int main()
{
  string line;
  
  cin >> line;
  
  int ans = 0;
  int cur = 0;
  if (line[0] == 'R')
    cur = 1;
  for(int i = 1; i < line.size(); i++) {
    if (line[i] == 'R' && line[i-1] == 'R') {
      cur++;
    }
    if (line[i] == 'R' && line[i-1] != 'R') {
      cur++;
    }
    if (line[i] != 'R' && line[i-1] == 'R') {
      if (ans < cur) ans = cur;
      cur = 0;
    }
  }
  if (ans < cur ) ans = cur;
  cout << ans << endl;
}


Measured memory_bytes: 3188
my $N = <>;

my $AC=0;
my $WA=0;
my $TLE=0;
my $RE=0;

for(my $i=0;$i<$N;$i++){
    my $str = <>;chomp $str;
    #print "$str\n";
    if( $str eq "AC" ){ $AC++;}
    if( $str eq "WA" ){ $WA++;}
    if( $str eq "TLE" ){ $TLE++;}
    if( $str eq "RE" ){ $RE++;}
}

print "AC x $AC\n";
print "WA x $WA\n";
print "TLE x $TLE\n";
print "RE x $RE\n";


Measured memory_bytes: 4548
a = int(input())
b = int(input())
c = int(input())
x = int(input())

money = []
for a_i in range(a+1):
	for b_i in range(b+1):
		for c_i in range(c+1):
			money.append(500*a_i+100*b_i+50*c_i)

cnt = 0
for m in money:
	if m == x:
		cnt+=1
print(cnt)

Measured memory_bytes: 8404
import java.util.ArrayDeque;
import java.util.Deque;
import java.util.Scanner;

public class Main {
public static void main(String[] args) {
  Scanner in = new Scanner(System.in);
  Deque<Number> deque = new ArrayDeque<Number>(40);
  Scanner in2;
  while (in.hasNextLine()) {
	in2 = new Scanner(in.nextLine());
	while (in2.hasNext()) {
	  if (in2.hasNextInt()) {
		deque.addFirst(in2.nextInt());
	  } else {
		double val;
		double a = deque.removeFirst().doubleValue();
		double b = deque.removeFirst().doubleValue();
		switch (in2.next().charAt(0)) {
		case '-':
		  a = -a;
		case '+':
		  val = a + b;
		  break;
		case '/':
		  val = b / a;
		  break;
		case '*':
		  val = a * b;
		  break;
		default:
		  System.out.println("err");
		  val = 0.0;
		}
		deque.addFirst(val);
	  }
	}
	in2.close();
	if (deque.size() == 1) {
	  System.out.printf("%.6f", (
		  (Number) deque.removeFirst()).doubleValue());
	  System.out.println();
	}
  }
}
}

Measured memory_bytes: 12000
#include <iostream>
#define REP(i, a, n) for(int i = a; i <= n; i++)
#define SIZE 100001
using namespace std;


int N, T, A[SIZE];

int main(void) {
  cin >> N >> T;
  REP(i, 1, N) cin >> A[i];

  int m = A[1];
  int d = -1;
  int cnt = 0;
  REP(i, 2, N) {
    if(m < A[i]) {
      if(A[i] - m > d) {
        d = A[i] - m;
        cnt = 1;
      } else if(A[i] - m == d) {
        cnt++;
      }
    } else if(m > A[i]) {
      m = A[i];
    }
  }

  cout << cnt << endl;

  return 0;
}


Measured memory_bytes: 640
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace B
{
    class Program
    {
        static void Main(string[] args)
        {
            string line;
            string[] strs;
            int[,] bingo = new int[3, 3];
            for (int j = 0; j < 3; j++)
            {
                line = Console.ReadLine();
                strs = line.Split(' ');
                for (int i = 0; i < 3; i++)
                {
                    bingo[j, i] = int.Parse(strs[i]);
                }
            }
            line = Console.ReadLine();
            int N = int.Parse(line);
            List<int> b = new List<int>();
            for (int i = 0; i < N; i++)
            {
                line = Console.ReadLine();
                b.Add(int.Parse(line));
            }

            if ((b.Contains(bingo[0, 0]) && b.Contains(bingo[0, 1]) && b.Contains(bingo[0, 2]))
                || (b.Contains(bingo[1, 0]) && b.Contains(bingo[1, 1]) && b.Contains(bingo[1, 2]))
                || (b.Contains(bingo[2, 0]) && b.Contains(bingo[2, 1]) && b.Contains(bingo[2, 2]))
                || (b.Contains(bingo[0, 0]) && b.Contains(bingo[1, 0]) && b.Contains(bingo[2, 0]))
                || (b.Contains(bingo[0, 1]) && b.Contains(bingo[1, 1]) && b.Contains(bingo[2, 1]))
                || (b.Contains(bingo[0, 2]) && b.Contains(bingo[1, 2]) && b.Contains(bingo[2, 2]))
                || (b.Contains(bingo[0, 0]) && b.Contains(bingo[1, 1]) && b.Contains(bingo[2, 2]))
                || (b.Contains(bingo[2, 0]) && b.Contains(bingo[1, 1]) && b.Contains(bingo[0, 2]))
                )
            {
                Console.WriteLine("Yes");
            }
            else
                Console.WriteLine("No");
        }
    }
}


Measured memory_bytes: 13268
using AtCoderBeginnerContest136.Questions;
using AtCoderBeginnerContest136.Extensions;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;

namespace AtCoderBeginnerContest136.Questions
{
    public class QuestionB : AtCoderQuestionBase
    {
        public override IEnumerable<object> Solve(TextReader inputStream)
        {
            var n = inputStream.ReadInt();
            yield return Enumerable.Range(1, n).Count(i => GetDigitCount(i) % 2 == 1);
        }

        int GetDigitCount(int n)
        {
            var digit = 1;
            while (n >= 10)
            {
                n /= 10;
                digit++;
            }
            return digit;
        }
    }
}


namespace AtCoderBeginnerContest136
{
    class Program
    {
        static void Main(string[] args)
        {
            IAtCoderQuestion question = new QuestionB();    // 問題に合わせて書き換え
            var answers = question.Solve(Console.In);
            foreach (var answer in answers)
            {
                Console.WriteLine(answer);
            }
        }
    }
}

#region Base Classes

namespace AtCoderBeginnerContest136.Questions
{

    public interface IAtCoderQuestion
    {
        IEnumerable<object> Solve(string input);
        IEnumerable<object> Solve(TextReader inputStream);
    }

    public abstract class AtCoderQuestionBase : IAtCoderQuestion
    {
        public IEnumerable<object> Solve(string input)
        {
            var stream = new MemoryStream(Encoding.Unicode.GetBytes(input));
            var reader = new StreamReader(stream, Encoding.Unicode);

            return Solve(reader);
        }

        public abstract IEnumerable<object> Solve(TextReader inputStream);
    }

}

#endregion

#region Extensions

namespace AtCoderBeginnerContest136.Extensions
{
    internal static class TextReaderExtensions
    {
        internal static int ReadInt(this TextReader reader) => int.Parse(ReadString(reader));
        internal static long ReadLong(this TextReader reader) => long.Parse(ReadString(reader));
        internal static double ReadDouble(this TextReader reader) => double.Parse(ReadString(reader));
        internal static string ReadString(this TextReader reader) => reader.ReadLine();

        internal static int[] ReadIntArray(this TextReader reader, char separator = ' ') => ReadStringArray(reader, separator).Select(int.Parse).ToArray();
        internal static long[] ReadLongArray(this TextReader reader, char separator = ' ') => ReadStringArray(reader, separator).Select(long.Parse).ToArray();
        internal static double[] ReadDoubleArray(this TextReader reader, char separator = ' ') => ReadStringArray(reader, separator).Select(double.Parse).ToArray();
        internal static string[] ReadStringArray(this TextReader reader, char separator = ' ') => reader.ReadLine().Split(separator);
    }
}

#endregion

Measured memory_bytes: 13268
#include<stdio.h>
int main(void)
{
	int n,h[100000];
	int i,j,cnt,x=0;
	scanf("%d",&n);
	for(i=0;i<n;i++){
		scanf("%d",&h[i]);
	}
	cnt=0;
	for(i=0;i<n-1;i++){
		if(h[i]>=h[i+1]){
			cnt++;
			if(x<=cnt){
				x=cnt;
			}
		}
		else{
			cnt=0;
		}
	}
	printf("%d\n",x);
	return 0;
}


Measured memory_bytes: 2096
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
using namespace std;

int main(){
	int n;
	cin >> n;
	int bbq[2*n];
	for(int i = 0; i < 2 * n; i++){
		cin >> bbq[i];
	}
	sort(bbq, bbq + 2 * n);
	int ans = 0;
	for(int i = 0; i < n; i++){
		ans += bbq[2 * i];
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll,ll>;

void solve(long long N){
    cout << ((N+999)/1000)*1000 -N << endl;

}

// Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long N;
    scanf("%lld",&N);
    solve(N);
    return 0;
}


Measured memory_bytes: 3760