akhauriyash/Code-Regression huggingface dataset:
#include <map>
#include <set>
#include <ctime>
#include <queue>
#include <stack>
#include <cmath>
#include <vector>
#include <bitset>
#include <cstdio>
#include <cctype>
#include <string>
#include <numeric>
#include <cstring>
#include <cassert>
#include <climits>
#include <cstdlib>
#include <iostream>
#include <algorithm>
#include <functional>
using namespace std ;
#define int long long
#define rep(i, a, b) for (ll i = (a); i <= (b); ++i)
#define per(i, a, b) for (ll i = (a); i >= (b); --i)
#define loop(it, v) for (auto it = v.begin(); it != v.end(); it++)
#define cont(i, x) for (ll i = head[x]; i; i = edge[i].nex)
#define clr(a) memset(a, 0, sizeof(a))
#define ass(a, cnt) memset(a, cnt, sizeof(a))
#define cop(a, b) memcpy(a, b, sizeof(a))
#define lowbit(x) (x & -x)
#define all(x) x.begin(), x.end()
#define SC(t, x) static_cast <t> (x)
#define ub upper_bound
#define lb lower_bound
#define pqueue priority_queue
#define mp make_pair
#define pb push_back
#define pof pop_front
#define pob pop_back
#define fi first
#define se second
#define y1 y1_
#define Pi acos(-1.0)
#define iv inline void
#define enter putchar('\n')
#define siz(x) ((ll)x.size())
#define file(x) freopen(x".in", "r", stdin),freopen(x".out", "w", stdout)
typedef double db ;
typedef long long ll ;
typedef unsigned long long ull ;
typedef pair <ll, ll> pii ;
typedef vector <ll> vi ;
typedef vector <pii> vii ;
typedef queue <ll> qi ;
typedef queue <pii> qii ;
typedef set <ll> si ;
typedef map <ll, ll> mii ;
typedef map <string, ll> msi ;
const ll maxn = 2e6 + 100 ;
const ll inf = 0x3f3f3f3f ;
const ll iinf = 1 << 30 ;
const ll linf = 2e18 ;
const ll mod = 998244353 ;
const double eps = 1e-7 ;
template <class T = ll> T chmin(T &a, T b) { return a = min(a, b);}
template <class T = ll> T chmax(T &a, T b) { return a = max(a, b);}
template <class T = ll> T read()
{
	T f = 1, a = 0;
	char ch = getchar() ;
	while (!isdigit(ch)) { if (ch == '-') f = -1 ; ch = getchar() ; }
	while (isdigit(ch)) { a =  (a << 3) + (a << 1) + ch - '0' ; ch = getchar() ; }
	return a * f ;
}

ll n, ans = -linf;

ll a[maxn], opt = 1, pre[maxn], sum, cnt;

char s;

signed main()
{
	n = read();
	pre[1] = a[1] = read();
	rep(i, 2, n)
	{
		scanf("%c", &s);
		if(s == '-') opt = -1;
		else opt = 1;
		a[i] = read() * opt;
		pre[i] += pre[i - 1] + a[i];
	}
	ans = pre[n];
	per(i, n, 1)
	{
		if(a[i] < 0)
		{
			sum += a[i];
			chmax(ans, sum + cnt + pre[i - 1]);
			cnt -= sum;
			sum = 0;
		}
		else sum -= a[i];
	}
	printf("%lld\n", ans);
	return 0;
}

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

int main(){
  string S;
  cin>>S;
  if(S.at(2)==S.at(3)&&S.at(4)==S.at(5)){
    cout<<"Yes"<<endl;
  }
  else {
    cout<<"No"<<endl;
  }
}
    

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

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

	int n; cin >> n;
	int cnt = 0;
	for (int i = 1; i <= n; i++) {
		int x; cin >> x;
		if ((i % 2) == 1) {
			cnt += (x % 2);
		}
	}
	cout << cnt;

	return 0;
}


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

struct Polygon {
  struct Point {
    double x, y;

    Point() {}
    Point(double x, double y) : x(x), y(y) {}
  };

  vector<Point> P;

  void add_vertex(double a, double b) {
    P.push_back(Point(a, b));
  }

  double dist(Point a, Point b) {
    return sqrt(pow(a.x - b.x, 2) + pow(a.y - b.y, 2));
  }

  double Hero(Point a, Point b, Point c) {
    double A = dist(a, b);
    double B = dist(b, c);
    double C = dist(c, a);
    double Z = (A + B + C) / 2.0;

    return sqrt(Z * (Z - A) * (Z - B) * (Z - C));
  }

  double area() {
    double S = 0.0;
    for (int i = 1; i < P.size() - 1; ++i) {
      S += Hero(P[0], P[i], P[i + 1]);
    }
    return S;
  }
};

int main() {
  Polygon P;
  double a, b;
  while (~scanf("%lf,%lf", &a, &b)) {
    P.add_vertex(a, b);
  }

  printf("%.10lf\n", P.area());
}

Measured memory_bytes: 3148
#include<cstdio>
#include<cmath>
#include<iostream>
#include<cstring>
#include<ctime>
#include<map>
#include<queue>
#include<cctype>
#include<cstdlib>
#include<algorithm>
#include<stack>
#include<vector>

using namespace std;

	vector < int > conn[100900];
	int bio[100090];
	pair < long long , long long > dp[100900];
	#define MOD 1000000007
	
	void dfs(int node){
		
		bio[node] = true;
		
		for(int i = 0; i < conn[node].size(); i++){
			if(bio[conn[node][i]] == true) continue;
			dfs(conn[node][i]);
			dp[node].first *= (dp[conn[node][i]].first + dp[conn[node][i]].second)%MOD;
			dp[node].second *= (dp[conn[node][i]].first);
			dp[node] = make_pair(dp[node].first%MOD,dp[node].second%MOD);
		}
		
		return;
		
	} 
	

int main(){
	
	memset(bio,false,sizeof bio);
	int n; cin >> n;
	dp[n] = make_pair(1,1);
	for(int i = 0; i < n-1; i++){
		dp[i+1] = make_pair(1,1);
		int x,y; cin >> x >> y;
		conn[x].push_back(y);
		conn[y].push_back(x);
	}
	dfs(1); cout << (dp[1].first + dp[1].second)%MOD;
	
	


return 0;
}

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

int main(){
  int b,r,g,c,s,t;
  int ans;

  while(1){
    cin >> b >> r >> g >> c >> s >> t;
    if(!b && !r && !g && !c && !s && !t)break;

    ans = 100;
    ans += c*2 + g*7 + r*63 + b*95 - (t-s)*3;

    cout << ans << endl;
  }
}

Measured memory_bytes: 0
def main():
  from functools import reduce
  from fractions import gcd
  ans = 0
  n = int(input())
  b = tuple(map(int, input().split()))
  ov = 10**9+7
  def lcm(x,y):
    return (x * y) // gcd(x, y)
  def lcm_list(a):
    return reduce(lcm, a, 1)
  l = lcm_list(b)
  for i in range(n):
    ans += l//b[i]
  print(ans%ov)
if __name__ == "__main__":
  main()


Measured memory_bytes: 6084
n = int(raw_input())
m = map(int, raw_input().split())

for i in range(1, n):
  m[i] += m[i - 1]

mini = 1e10
for i in range(0, n - 1):
  diff = abs(m[i] - (m[n - 1] - m[i]))
  if diff < mini:
    mini = diff

print(mini)

Measured memory_bytes: 19992
#include<bits/stdc++.h>
using namespace std;
int main(){
	vector<int> s(3);
	int x=1;
	for(int i=0;3>i;i++){
		cin>>s.at(i);
	}
	sort(s.begin(),s.end());
	for(int i=0;3>i+1;i++){
		if(s.at(i)!=s.at(i+1)){
			x++;
		}
	}
	cout<<x<<endl;
}

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

// c++11
#include <array>
#include <tuple>
#include <unordered_map>
#include <unordered_set>

#define mp make_pair
#define mt make_tuple
#define rep(i, n) for (int i = 0; i < (n); i++)

using namespace std;

using ll = long long;
using ull = unsigned long long;
using pii = pair<int, int>;

const int INF = 1 << 29;
const ll LL_INF = 1LL << 60;
const double EPS = 1e-9;
const ll MOD = 1000000007;

const int dx[] = {1, 0, -1, 0}, dy[] = {0, -1, 0, 1};
int N;
vector<int> A;
int main()
{
    cin >> N;
    A.resize(N);
    for (int i = 0; i < N; i++)
    {
        cin >> A[i];
    }
    sort(A.rbegin(), A.rend());
    int result = 0;
    for (int i = 0; i < N; i++)
    {
        if (i % 2 == 0)
        {
            result += A[i];
        }
        else
        {
            result -= A[i];
        }
    }
    cout << result << endl;
    return 0;
}

Measured memory_bytes: 888
//#pragma GCC optimize ("-O3","unroll-loops")
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include<iterator>
#include<complex>
#include<stack>
#include<unordered_map>
#include<unordered_set>
#include<time.h>
#include<random>

using namespace std;

#define REP(i, n) for(int i = 0;i < n;++i)
#define REPR(i, n) for(int i = n-1;i >= 0;--i)
#define FOR(i, m, n) for(int i = m;i < n;++i)
#define FORR(i, m, n) for(int i = m-1;i >= n;--i)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define REVERSE(v,n) reverse(v,v+n);
#define VREVERSE(v) reverse(v.begin(), v.end())
#define ll long long
#define pb(a) push_back
#define print(x) cout<<(x)<<endl
#define pe(x) cout<<(x)<<" "
#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define lb(v,n) lower_bound(v.begin(), v.end(), n)
#define ub(v,n) upper_bound(v.begin(), v.end(), n)
#define int long long
#define all(x) (x).begin(), (x).end()
#define print_space(v) REP(i,v.size())cout << v[i] << ((i == v.size() - 1) ? "\n" : " ")

template<typename T1, typename T2> inline void chmin(T1 & a, T2 b) { if (a > b) a = b; }
template<typename T1, typename T2> inline void chmax(T1& a, T2 b) { if (a < b) a = b; }
//typedef pair<int, int>P;
const int MOD = 1e9 + 7; const int MAX = 1000020;
const double pi = acos(-1); const double EPS = 1e-12;
const ll INF = 1e16;

ll dp[3030][3030][2];
int mx[3030];
int A[3030];
int B[3030];
void solve() {
	int N, T; cin >> N >> T;
	REP(i, N)cin >> A[i] >> B[i];
	dp[0][0][0] = 0;
	REPR(i, N) {
		mx[i] = max(mx[i + 1], B[i]);
	}
	ll ans = mx[0];
	REP(i, N) {
		REP(t, T) {
			dp[i + 1][t][0] = max(dp[i][t][0], dp[i + 1][t][0]);
			dp[i + 1][t][1] = max(dp[i][t][1], dp[i + 1][t][1]);
			if (A[i] + t < T) {
				dp[i+1][A[i]+t][0]=max(dp[i + 1][A[i] + t][0], dp[i][t][0] + B[i]);
				dp[i + 1][A[i] + t][1] = max(dp[i + 1][A[i] + t][1], dp[i][t][1] + B[i]);
			}
			dp[i + 1][t][1] = max(dp[i + 1][t][1], dp[i][t][0] + B[i]);
		}
	}
	REP(i, N + 1) {
		REP(t, T) {
			ans = max({ans, dp[i][t][1], dp[i][t][0]});
		}
	}
	print(ans);
}

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

	solve();

}



Measured memory_bytes: 143616
let rec gcd a b = 
    match b with
    | 0.0 -> a
    | x -> gcd x (a % x)

let lcm a b = a * b / (gcd a b)

let allLcm xs =
    let rec inAllLcm n l =
        match l with
        | [] -> n
        | y :: ys -> inAllLcm (lcm y n) ys
    inAllLcm 1.0 xs

let n = int (stdin.ReadLine())
let a = stdin.ReadLine().Split() |> Array.map float |> List.ofArray
let s = allLcm a
let b = List.sumBy (fun x -> s / x) a
printfn "%f" (s / b)

Measured memory_bytes: 14044
#include<bits/stdc++.h>
#define _for(i, a, b) for (int i = (a); i < (b); i++)
#define _count(i, a, b) for (int i = (a); i <= b; i++)
#define PB emplace_back
#define MINI -2147483648
#define MAXI 2147483647
#define MAXLL 9223372036854775807
#define MINLL -9223372036854775808
#define VI vector<int>
#define VB vector<bool>
#define VLL vector<long long>
#define LL long long
#define ULL unsigned long long
#define ALL(X) X.begin(), X.end() 
#define pii pair<int, int>
#define F first
#define S second
#define mp make_pair
//#define Remilia_is_so_cute
#define StarBurst std::ios::sync_with_stdio(false),cin.tie(NULL);
#define lowerBit(x) x&-x
using namespace std;
 
inline void R_P(vector<int> &vec) {
  int temp;
  cin>>temp;
  vec.push_back(temp);
} 
inline bool checkMax(int &base, int test) {
  return (test > base) ? base = test, true : false; 
}
 
inline bool checkMin(int &base, int test){
  return (test < base)? base = test, true : false;
}
template <class T>
void test(vector<T> &vec, const string &warn) {
  cout<<warn<<'\n';
  _for(i, 0, vec.size())
    cout<<vec[i]<<' ';
  cout<<"\nTest end..............\n";
}
 
int main () {
  StarBurst
  #ifdef Remilia_is_so_cute
  freopen("input.txt", "r", stdin);
  freopen("output.txt", "w", stdout);
  #endif
  
  string s, t;
  cin >> s >> t;
  int ans = t.size();
  _for(i, 0, s.size() - t.size() + 1) {
    int cur = 0;
    _for(j, i, i + t.size())
      if (s[j] != t[j - i])
        cur++;
    ans = min(cur, ans);
  }
 
  cout << ans << '\n';
 
  return 0;
}

Measured memory_bytes: 3648
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using ll=long long;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll dp[110][100100];
  ll n, w;
  cin >> n >> w;
  vector<int> weight(n);
  vector<int> value(n);
  rep(i,n) cin >> weight[i] >> value[i];
  rep(i,n){
    rep(sum_w,w+1){
      if(sum_w - weight[i] >= 0){
        dp[i+1][sum_w] = max(dp[i+1][sum_w], dp[i][sum_w - weight[i]] + value[i]);
      }
      dp[i+1][sum_w] = max(dp[i+1][sum_w], dp[i][sum_w]);
    }
  }
  cout << dp[n][w] << endl;
}

Measured memory_bytes: 80128
import java.util.Scanner;
 

//result = Math.pow(num1, num3)
//StringBuffer str = new StringBuffer(hoge1);
//String hoge2 = str.reverse().toString();
//map.containsKey(A)
//Map<String, Integer> map = new HashMap<String, Integer>(n);
//ArrayList<String> cc = new ArrayList<>(n);
//Collections.sort(list);
//Array.sort(list);
//Arrays.asList(c).contains("a")

public class Main {
	private static Scanner sc = new Scanner(System.in);
	static void p(String ans) {System.out.println(ans);};
	static void p(int ans) {System.out.println(ans);};
	static void p(long ans) {System.out.println(ans);};
	static void p(double ans) {System.out.println(ans);};
	//static String eikomoji[]={"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"};
	static int Y,N;
	public static void main(String[] args) {

	String S=sc.next();
	String T=sc.next();
	int ans;
	p(T+S);
	}
}


Measured memory_bytes: 20948
#include <iostream>

int main()
{
    std::uint64_t X;
    std::cin >> X;

    std::uint64_t answer  = 0;
    std::uint64_t current = 100;
    while(current < X)
    {
        current = current * 1.01;
        answer += 1;
    }
    std::cout << answer << std::endl;
    return 0;
}


Measured memory_bytes: 3620
import java.util.*;

class Main {
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int n = in.nextInt();
		int m = in.nextInt();
		int[] w = new int[n+1];
		int[] v = new int[n+1];
		for(int i=1;i<=n;i++) {
			w[i] = in.nextInt();
			v[i] = in.nextInt();
		}
		long[][] dp = new long[m+1][n+1];
		for(int i=0;i<=m;i++) {
			for(int j=1;j<=n;j++) {
				if(i>=w[j]) {
					dp[i][j] = Math.max(dp[i][j-1], dp[i-w[j]][j-1]+v[j]);
				}else {
					dp[i][j] = dp[i][j-1];
				}
				//System.out.print(dp[i][j]+" ");
			}
			//System.out.println();
		}
		System.out.println(dp[m][n]);
	}
}

Measured memory_bytes: 128340
#include <stdio.h>
#define ll long long
#define rep(i,l,r)for(ll i=(l);i<(r);i++)
ll pom(ll a,ll n,int m){ll x=1;for(a%=m;n;n/=2)n&1?x=x*a%m:0,a=a*a%m;return x;}
#define MOD 1000000007
#define invp(a,p)pom(a,p-2,p)

//階乗,二項係数
//*
ll fact[100010];
ll invfact[100010];
void makefact(int n,ll m){
	fact[0]=1;
	rep(i,0,n)fact[i+1]=fact[i]*(i+1)%m;
	invfact[n]=invp(fact[n],m);
	for(int i=n;i>0;i--)invfact[i-1]=invfact[i]*i%m;
}
ll choose(int n,int r,int m){return n<0||r<0||n-r<0?0:fact[n]*invfact[r]%m*invfact[n-r]%m;}
//*/

int main(){
	makefact(2000,MOD);
	int n,m;
	scanf("%d%d",&n,&m);
	printf("%lld\n",choose(m,n,MOD));
}


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

import sys
import math
from bisect import bisect_right as br
from bisect import bisect_left as bl
sys.setrecursionlimit(2147483647)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))

l = I()
ans = (l/3)**3
print(ans)


Measured memory_bytes: 38384
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<cmath>
#include<algorithm>
#include<functional>
typedef long long ll;
int main() {
	int n = 0,num = 0,ans = 0;
	std::vector<int> save;
	std::map<int, int> m;
	std::cin >> n;
	for (int i = 0; i < n; i++) {
		std::cin >> num;
		if (m[num] == 0) {
			save.push_back(num);
		}
		m[num]++;		
	}
	if (save.size() % 2 == 0) {
		std::cout << save.size() - 1 << std::endl;
	}
	else {
		std::cout << save.size() << std::endl;
	}
}
	

Measured memory_bytes: 5368
#include <bits/stdc++.h>
#include <iostream>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 1; i <= (n); i++)

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

	int A[N], B[N];
	rep(i, N) {
		cin >> A[i];
		B[A[i]] = i;
	}

	rep(i, N)
	{
		cout << B[i] << endl;
	}
	return 0;
}

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

typedef long long int ll;

int main() {
    ll n;

    cin >> n;
    ll ans = n - 1;
    for (ll f = 1; f * f <= n; ++f) {
        if (n % f == 0) {
            ans = min(ans, (f - 1) + (n / f - 1));
        }
    }

    cout << ans << '\n';
    return 0;
}



Measured memory_bytes: 384
#include<bits/stdc++.h>
#include <math.h>
#include <algorithm>
#include <functional>
#include<iostream>
#include <string>
using namespace std;
typedef long long ll;
#define pb pushback
#define fr(i,n) for(int i=0;i<n;i++)
#define ifr(i,n) for(int i=n-1;i>=0;i--)


int main() {
    int n,m,q,l,r,x,y;
	cin >> n>> m>> q;
    int eki[n][n];
    fr(i,n){
      fr(j,n){
        eki[i][j]=0;
      }
    }
    fr(i,m){
      cin >> l>> r;
      eki[l-1][r-l]+=1;
    }
    fr(i,n-1){
      fr(j,n-i-1){
        eki[i][j+1]+=eki[i][j];
      }
    }
    fr(i,q){
      int ans=0;
      cin >> x>> y;
      x--;
      y--;
      fr(j,y-x+1){
        ans+=eki[x+j][y-x-j];
      }
      cout << ans << endl;
    }
}

Measured memory_bytes: 1920
#include <algorithm>
#include <iostream>
#include <cstdio>

using namespace std ;

char s[100] ;

int main ()
{
	int n , k , i ;
	scanf("%d %d %s",&n,&k,s+1);
	for ( i=1 ; i<k ; i++ ) putchar(s[i]);
	putchar(s[k]-'A'+'a');
	for ( i=k+1 ; i<=n ; i++ ) putchar(s[i]);
	return 0 ;
}

Measured memory_bytes: 256
using System;
using System.Numerics;

namespace c
{
    class Program
    {
        static void Main(string[] args)
        {
            var _ = Console.ReadLine().Split();
            var n = long.Parse(_[0]);
            var m = long.Parse(_[1]);

            if(Math.Abs(n - m) <= 1){
                var s = 0L;
                if((n + m) % 2 != 0){
                    s = Calc(n, 1000000007) * Calc(m, 1000000007);
                }else{
                    s = (Calc(n, 1000000007) * Calc(m, 1000000007)) * 2;
                }                
                Console.WriteLine(s % 1000000007);
            }else{
                Console.WriteLine(0);
            }
        }

        static long Calc(long x, long mod){
            var val = 1L;
            while(x > 0){
                val =  val * x % mod;
                x--;
            }
            return val;
        }
    }
}


Measured memory_bytes: 13140
#include<stdio.h>
int main()
{
    int a,b,ave,acu_ave;
    scanf("%d %d",&a,&b);
    if((a+b)%2==0)
    {
        ave=(a+b)/2;
        printf("%d\n",ave);
    }
    else
    {
        ave=(a+b)/2;
        acu_ave=ave+1;
        printf("%d\n",acu_ave);
    }

    return 0;
}


Measured memory_bytes: 256
N, A, B, C = map(int, (input().split(' ')))
a_list = list(map(int, [input() for _ in range(N)]))
kado = [0] * 3
calc = []

def calc_mp(kado, score):
    calc.append(abs(A - kado[0]) + abs(B - kado[1]) + abs(C - kado[2]) + score)


def solve(kado, a_list, score):
    if all([k != 0 for k in kado]):
        calc_mp(kado, score)
    if a_list == []:
        return
    for i in range(4):
        if i == 3:
            solve(kado, a_list[1:], score)
        else:
            empty = [0, 0, 0]
            empty[i] += a_list[0]
            solve([i + j for i, j in zip(kado, empty)], a_list[1:], score + 10)

solve(kado, a_list, 0)
print(min(calc) - 30)


Measured memory_bytes: 5500
{-# LANGUAGE BangPatterns #-}
import Control.Arrow
import Data.List
import qualified Data.ByteString.Char8 as B
import Control.Monad
import Control.Monad.Primitive
import qualified Data.Vector as V 
import qualified Data.Vector.Mutable as VM
import Control.Monad.ST
import Data.Foldable

main :: IO ()
main = breads >>= main'
    where
        main' nm = breads >>= main'' nm
        main'' [n, m] ps = replicateM m breads >>= print . solve n m ps

solve :: Int -> Int -> [Int] -> [[Int]] -> Int
solve n m ps xys = runST solveST
    where
        solveST :: ST s Int
        solveST = initTree >>= count
        initTree :: ST s (UFTree s)
        initTree = makeTreeM n >>= (\t -> t <$ mapM_ (\[x, y] -> unionNodesM (x - 1) (y - 1) t) xys)
        count uft = foldlM ff 0 $ zip [0..] ps
            where
                ff acc (i, p) = check acc <$> isSameM i (p - 1) uft 
                check acc b
                    | b = acc + 1
                    | otherwise = acc
            

data UFTree s = UFTree !(VM.MVector s (Int, Int))

makeTreeM :: (PrimMonad m) => Int -> m (UFTree (PrimState m))
makeTreeM n = UFTree <$> V.unsafeThaw vec
    where
        vec = V.fromListN n $ zip (repeat 0) [0..]

findRootM :: (PrimMonad m) => Int -> UFTree (PrimState m) -> m Int
findRootM v t@(UFTree vs) = VM.unsafeRead vs v >>= checkRoot
    where
        checkRoot (_, root)
            | v == root = return v
            | otherwise = findRootM root t
            
unionNodesM :: (PrimMonad m) => Int -> Int -> UFTree (PrimState m) -> m ()
unionNodesM a b t@(UFTree vs) = mapM (flip findRootM t) [a, b] >>= checkRoot
    where
        checkRoot [c, d]
            | c == d = return ()
            | otherwise = mapM (VM.unsafeRead vs) [c, d] >>= checkRank c d 
        checkRank c d [ra, rb]
            | ra < rb = VM.unsafeModify vs (second (const d)) c
            | ra > rb = VM.unsafeModify vs (second (const c)) d
            | otherwise = VM.unsafeModify vs (\(x, _) -> (x + 1, c)) d
            
isSameM :: (PrimMonad m) => Int -> Int -> UFTree (PrimState m) -> m Bool
isSameM a b t = (==) <$> findRootM a t <*> findRootM b t
        

breads :: IO [Int]
breads = unfoldr (\s -> second (maybe B.empty snd . B.uncons) <$> B.readInt s) <$> B.getLine

Measured memory_bytes: 42364
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstdlib>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <set>
#include <string>
#include <utility>
#include <vector>
#define REP(i, n) for(int i = 0; i < (n); ++i)
typedef long long ll;
const ll MOD = 1000000007;
using namespace std;

int main(){
    int x; cin >> x;
    REP(i, 1000000){
        if(i * (i+1) / 2 >= x){
            cout << i << "\n";
            return 0;
        }
    }
    return 0;
}

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

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

    int v[n];

    for(int i=0;i<n;i++){
        cin >> v[i];
    }
    sort(v,v+n);

    double ans = 0;
    ans += v[0]/pow(2,n-1);
    ans += v[1]/pow(2,n-1);

    for(int i=2;i<n;i++){
        ans += v[i]/pow(2,n-i);
    }

    cout << ans << endl;

    return 0;
}


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

std::vector<char> t, d;
std::string s;
int N, Q;

int end(int);

int main()
{
	scanf("%d%d", &N, &Q);
	
	std::cin >> s;

	t.resize(Q);
	d.resize(Q);
	for (int i{}; i < Q; i++) scanf(" %c %c", &t[i], &d[i]);
	int left{-1}, right{N};
	while (left + 1 < right)
	{
		int mid{(left + right) / 2};
		if (end(mid) == -1) left = mid;
		else right = mid;
	}
	int sum{left + 1};
	left = -1; right = N;
	while (left + 1 < right)
	{
		int mid{(left + right) / 2};
		if (end(mid) == N) right = mid;
		else left = mid;
	}
	sum += N - right;
	printf("%d\n", N - sum);

	return 0;
}

int end(int pos)
{
	for (int i{}; i < Q; i++)
	{
		if (pos < 0 || pos >= N) return pos;
		if (t[i] != s[pos]) continue;
		if (d[i] == 'R') pos++;
		else pos--;
	}
	return pos;
}

Measured memory_bytes: 900
#include <iostream>
using namespace std;
class Dice{
public:
    int f[6];
    int right(int up, int fr){
        if(f[0] == up && f[1] == fr || f[1] == up && f[5] == fr || f[5] == up && f[4] == fr || f[4] == up && f[0] == fr) return f[2];
        else if(f[0] == up && f[2] == fr || f[2] == up && f[5] == fr || f[5] == up && f[3] == fr || f[3] == up && f[0] == fr) return f[4];
        else if(f[0] == up && f[3] == fr || f[3] == up && f[5] == fr || f[5] == up && f[2] == fr || f[2] == up && f[0] == fr) return f[1];
        else if(f[0] == up && f[4] == fr || f[4] == up && f[5] == fr || f[5] == up && f[1] == fr || f[1] == up && f[0] == fr) return f[3];
        else if(f[1] == up && f[2] == fr || f[2] == up && f[4] == fr || f[4] == up && f[3] == fr || f[3] == up && f[1] == fr) return f[0];
        else if(f[2] == up && f[1] == fr || f[1] == up && f[3] == fr || f[3] == up && f[4] == fr || f[4] == up && f[2] == fr) return f[5];
    }
};
int main(){
    Dice d;
    for(int i = 0; i < 6; i++){
        cin >> d.f[i];
    }
    int q;
    cin >> q;
    int up, fr;
    for(int i = 0; i < q; i++){
        cin >> up >> fr;
        cout << d.right(up, fr) << endl;
    }
}



Measured memory_bytes: 3052
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

#define REP(i,s,n) for(int i=(int)(s);i<(int)(n);i++)

using namespace std;
typedef long long int ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef pair<int, int> PI;
const ll mod = 1e9 + 7;
const int DEBUG = 0;

const int N = 100010;
bool done[N];

bool match(int n, int m, const VI &target, const VI &op, int tol) {
  assert (0 <= tol && tol < m);
  VI inv_t(m);
  REP(i, 0, m) {
    inv_t[target[i]] = i;
  }
  VI prog(m + 1);
  VI pass(m + 1);
  prog[0] = n;
  REP(i, 0, op.size()) {
    int idx = inv_t[op[i]];
    if (prog[idx] == 0 && !pass[idx]) {
      return false;
    }
    if (prog[idx] == 0) {
      continue;
    }
    prog[idx]--;
    prog[idx + 1]++;
    pass[idx] = 1;
  }
  if (DEBUG) {
    REP(i, 0, m + 1) {
      cout << "prog[" << i << "]=" << prog[i] << endl;
    }
  }
  REP(i, 0, tol) {
    if (prog[i] > 0) {
      return 0;
    }
  }
  return 1;
}

int main(void){
  int n, m, q;
  cin >> n >> m >> q;
  VI a(q);
  REP(i, 0, q) {
    cin >> a[i];
    a[i]--;
  }
  reverse(a.begin(), a.end());
  vector<bool> used(m);
  int cur = 0;
  VI target(m);
  REP(i, 0, q) {
    if (used[a[i]]) {
      continue;
    }
    used[a[i]] = 1;
    target[cur] = a[i];
    cur++;
  }
  REP(i, 0, m) {
    if (!used[i]) {
      target[cur++] = i;
    }
  }
  assert (cur == m);
  int oldcur = m - 1;
  while (oldcur > 0) {
    if (target[oldcur - 1] < target[oldcur]) {
      oldcur--;
    } else {
      break;
    }
  }
  if (DEBUG) {
    cerr << "target:";
    REP(i, 0, m) {
      cerr << " " << target[i];
    }
    cerr << endl << "tol = " << oldcur << endl;
  }
  cout << (match(n, m, target, a, oldcur) ? "Yes" : "No") << endl;
}


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

int main() {
    int N;
    set<ll> A;
    cin>>N;
    for(int i=0;i<N;i++){
        ll temp;
        cin>>temp;
        A.insert(temp);
    }
    if(N==A.size()) cout<<"YES";
    else cout<<"NO";
    return 0;
}

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

int main() {
    string S; cin >> S;
    int K; cin >> K;

    int the_number_of_1 = 0;
    for (int i=0; i<(int)(S.size()); i++){
        if (S[i] == '1') {
            the_number_of_1 += 1;
        } else {
            break;
        }
    }

    if (K == 1){
        cout << S[0] << endl;
        return 0;
    } else if (K <= the_number_of_1){
        cout << 1 << endl;
        return 0;
    } else {
        cout << S[the_number_of_1] << endl;
        return 0;
    }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define REP(i,m,n) for(int i=(m);i<(n);i++)
#define rep(i,n) REP(i,0,n)
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const int inf=1e9+7;
int main(){
    int a;cin>>a;
    string s;cin>>s;
    if(a>=3200)cout<<s<<endl;
    else cout<<"red"<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
#define REP(i,n) for (ll i = 0; i < (n); ++i)
#define RREP(i, n) for (ll i = (n) - 1; i >= 0; --i)
#define ALL(v) (v).begin(), (v).end()
template<class T>
using reverse_priority_queue = priority_queue<T, vector<T>, greater<T>>;


int main(){
    ll n;
    cin >> n;
    vector<ll> x(n), y(n), p(n);
    REP(i, n){
        cin >> x[i] >> y[i] >> p[i];
    }

    vector<vector<ll>> x2d(1LL << n), y2d(1LL << n);
    REP(i, (1LL << n)){
        vector<ll> xs, ys;
        REP(j, n){
            if((i >> j) & 1){
                xs.push_back(x.at(j));
                ys.push_back(y.at(j));
            }
        }
        // sort(ALL(xs));
        // sort(ALL(ys));

        x2d[i].resize(n, numeric_limits<ll>::max());
        y2d[i].resize(n, numeric_limits<ll>::max());

        REP(j, n){
            {
                ll dx = abs(x.at(j));
                for(ll x2 : xs){ dx = min(dx, abs(x.at(j) - x2)); }
                // ll idx = lower_bound(ALL(xs), x.at(j)) - xs.begin();
                // if(idx < xs.size()){
                //     dx = min(dx, xs.at(idx) - x.at(j));
                // }
                // if(idx > 0){
                //     dx = min(dx, x.at(j) - xs.at(idx - 1));
                // }
                x2d.at(i).at(j) = dx;
            }

            {
                ll dy = abs(y.at(j));
                for(ll y2 : ys){ dy = min(dy, abs(y.at(j) - y2)); }
                // ll idx = lower_bound(ALL(ys), y.at(j)) - ys.begin();
                // if(idx < ys.size()){
                //     dy = min(dy, ys.at(idx) - y.at(j));
                // }
                // if(idx > 0){
                //     dy = min(dy, y.at(j) - ys.at(idx - 1));
                // }
                y2d.at(i).at(j) = dy;
            }
        }
    }

    ll ub = 1;
    REP(i, n){ ub *= 3; }

    vector<ll> ans(n + 1, numeric_limits<ll>::max());

    REP(i, ub){
        ll ix = 0, iy = 0, k = 0;
        {
            ll m = i;
            REP(j, n){
                const ll l = m % 3;
                if(l == 1){
                    ix += (1LL << j);
                    k++;
                }else if(l == 2){
                    iy += (1LL << j);
                    k++;
                }
                m /= 3;
            }
        }

        ll s = 0;
        const auto& dx = x2d.at(ix), dy = y2d.at(iy);
        REP(j, n){
            ll d = min(dx.at(j), dy.at(j));
            s += p.at(j) * d;
        }

        ans.at(k) = min(ans.at(k), s);
    }

    for(auto ai : ans){
        cout << ai << endl;
    }
    return 0;
}


Measured memory_bytes: 13032
a = [list(map(int, input().split())) for i in range(3)]
n = int(input())
b = [int(input()) for i in range(n)]
for i in range(3):
    for j in range(3):
        for k in range(n):
            if a[i][j] == b[k]:
                a[i][j] = 0

bingo = [0, 0, 0]
for i in range(3):
    if a[i] == bingo:
        print("Yes")
        exit()
    tate = []
    for j in range(3):
        tate.append(a[j][i])
        if tate == bingo:
            print("Yes")
            exit()

if [a[0][0], a[1][1], a[2][2]] == bingo or [a[0][2], a[1][1], a[2][0]] == bingo:
    print("Yes")
else:
    print("No") 

Measured memory_bytes: 38384
N = int(input())
abc = [list(map(int, input().split())) for i in range(N)]
dp = [[0] * 3 for i in range(N)]
#dp[i][j]=i日目にjを行った時幸福度
dp[0][0]=abc[0][0]
dp[0][1]=abc[0][1]
dp[0][2]=abc[0][2]
for i in range(1,N):
  dp[i][0]=abc[i][0]+max(dp[i-1][1],dp[i-1][2])
  dp[i][1]=abc[i][1]+max(dp[i-1][0],dp[i-1][2])
  dp[i][2]=abc[i][2]+max(dp[i-1][0],dp[i-1][1])
print(max(dp[-1]))  

Measured memory_bytes: 74456
n=int(input())
l={}
for i in range(n):
  s,p=input().split()
  p=int(p)
  if s in l:
    l[s].append([p,i+1])
  else:
    l[s]=[[p,i+1]]

dk=sorted(l.keys())
for i in dk:
  l[i].sort(reverse=True, key=lambda x:x[0])
  for j,k in l[i]:
    print(k)

Measured memory_bytes: 3064
/*************************************************************************
    > File Name: a.cpp
    > Author: Amano Sei
    > Mail: amano_sei@outlook.com 
    > Created Time: 2020年01月19日 星期日 21时26分52秒
 ************************************************************************/

#include <cstdio>

int main(){
    int n, m;
    scanf("%d%d", &n, &m);
    if(n == m)
        puts("Yes");
    else
        puts("No");
    return 0;
}


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

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 llINF = 1LL << 60;
const int iINF = 1e8;

//---main---------------------------------------------
int main(){
    //main
    int K;
    cin >> K;

    int L;
    if(K%7==0) L=K/7*9;
    else L =  L = K*9;

    int ans,c=1;
    if(L%2 == 0 || L%5 == 0){
        ans = -1;
    }else{
        for(int i=1; i<=L; i++){
            c = (c*10)%L;
            if(c==1){
                ans = i;
                break;
            }
        }
    }


   cout << ans << endl;


    return 0;
}

Measured memory_bytes: 3596
#include <iostream>
#include <vector>
#include <climits>

// -------------8<------- start of library -------8<------------------------
struct LowestCommonAncestor {
    const int root, INF, n;
    int size, no;
    std::vector<std::vector<int>> adj;
    std::vector<int> idx;
    std::vector<std::pair<int, int>> dep;

    LowestCommonAncestor(int _n, int _r = 0) :
        root(_r), INF(INT_MAX), n(_n), adj(n), idx(n) {}

    void add_edge(int u, int v) { adj[u].push_back(v); adj[v].push_back(u); }

    void Dfs(int cur, int p, int d) {
        idx[cur] = no;
        dep[size - 1 + no++] = std::make_pair(d, cur);
        for (int nxt : adj[cur]) {
            if (nxt != p) {
                Dfs(nxt, cur, d + 1);
                dep[size - 1 + no++] = std::make_pair(d, cur);
            }
        }
    }

    void Preprocessing() {
        for (size = 1; size < 2 * n - 1; ) size <<= 1;
        dep.assign(2 * size - 1, std::make_pair(INF, INF));

        no = 0;
        Dfs(root, -1, 0);

        for (int i = size - 2; 0 <= i; --i)
            dep[i] = std::min(dep[2 * i + 1], dep[2 * i + 2]);
    }

    int rmq(int l, int r) {
        std::pair<int, int> res(INF, INF);
        l += size - 1;
        r += size - 1;
        while (l < r) {
            if ((l & 1) == 0) res = std::min(res, dep[l]);
            if ((r & 1) == 0) res = std::min(res, dep[r - 1]);
            l >>= 1;
            r = (r - 1) >> 1;
        }
        return res.second;
    }

    int query(int u, int v) {
        if (idx[v] < idx[u]) std::swap(u, v);
        return rmq(idx[u], idx[v] + 1);
    }
};
// -------------8<------- end of library ---------8-------------------------

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

    // AOJ GRL_5_C: Tree - Lowest Common Ancestor
    int n;
    std::cin >> n;

    LowestCommonAncestor lca(n, 0);
    for (int v = 0, deg, c; v < n; ++v) {
        std::cin >> deg;
        while (deg--) {
            std::cin >> c;
            lca.add_edge(v, c);
        }
    }
    lca.Preprocessing();

    int q, u, v;
    std::cin >> q;
    while (q--) {
        std::cin >> u >> v;
        std::cout << lca.query(u, v) << '\n';
    }

    return 0;
}



Measured memory_bytes: 15716
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>

#include <fstream>
#include <sstream>
#include <iomanip>
#include <cmath>
#include <algorithm>
#include <functional>
#include <stack>
#include <queue>
#include <map>
#include <unordered_map>
#include <bitset>
#include <numeric>
#include <unordered_set>
#include <bitset>
#include <limits>
#include <random>
#include <complex>
#include <numeric>
#include <cstdlib>
#include <random>
#include <bits/stdc++.h>


using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
//typedef vector<ll> vec;
//typedef vector<vec> mat;

const ll mod=1000000007ll;
const ll inf=1000000000000000ll;

const ll MAX_N=60,MAX_A=60;

ll N,A,x[MAX_N],dp[MAX_N][MAX_N][MAX_A*MAX_N];

int main(){
  cin>>N>>A;
  for(ll i=1;i<=N;i++){
    cin>>x[i];
  }
  dp[0][0][0]=1;
  for(ll i=0;i<=N;i++){
    for(ll j=0;j<=N;j++){
      for(ll k=0;k<=MAX_A*MAX_N;k++){
        if(i-1>=0&&j-1>=0&&k-x[i]>=0){
          dp[i][j][k]=dp[i-1][j][k]+dp[i-1][j-1][k-x[i]];
        }
        else if(i-1>=0&&k-x[i]<0){
          dp[i][j][k]=dp[i-1][j][k];
        }
        else if(i==0&&j==0&&k==0){
          dp[i][j][k]=1;
        }
        else{
          dp[i][j][k]=0;
        }
      }
    }
  }
  ll ans=0;
  for(ll i=1;i<=N;i++){
      ans+=dp[N][i][i*A];
  }
/*
  for(ll i=0;i<=N;i++){
    for(ll j=0;j<=33;j++){
      cout<<dp[N][i][j]<<" ";
    }
    cout<<endl;
  }
*/
  cout<<ans<<endl;
  return 0;
}


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



int main(){

  int a, b, c;
  while(  cin >> a >> b >> c ){


  int cnt = 0;

  int x1 = 1, x2 = a;


  if(60 % (a+b) == 0){
    int cp = c;
    while(1){
      if(cp < x1){
	cp += 60;
	cout << -1 << endl;
	break;
      }
      if(c >= x1 && c <= x2){
	
	cout << c << endl;
	break;
      }else{
	x1=x2+b;
	x2=x1+a;
      }
      
    }

  }else {
    int cp = c;
    while(1){

      if(cp < x1){
	cp += 60;
	//cout << cp << endl;
	cnt++;
      }    
      if(cp >= x1 && cp <= x2){
	cout << cp << endl;
	break;
      }else{
	x1=x2+b;
	x2=x1+a;
      }
      if(cnt >= 1000){
	cout << -1 << endl;
	break;
      }
    }
  }
  }


}

Measured memory_bytes: 1164
#include <iostream>

const int INF = 1000001;

int main(){
   int N;
   std::cin >> N;
   int a[N];
   int max = -INF;
   int min = INF;
   int mindex, mandex;
   for(int i=0; i<N; ++i){
      std::cin >> a[i];
      if(max<a[i]){
	 max = a[i];
	 mandex = i+1;
      }
      if(min>a[i]){
	 min = a[i];
	 mindex = i+1;
      }
   }
   if(max==min){
      std::cout << 0 << std::endl;
      return 0;
   }else{	
      std::cout << 2*N-1 << std::endl;
   }
   for(int i=0; i<N; ++i){
      if(abs(max)>abs(min)){
	 a[i] += max;
	 std::cout << mandex << ' ' << i+1 << std::endl;
      }else{
	 a[i] += min;
	 std::cout << mindex << ' ' << i+1 << std::endl;
      }
   }

   if(abs(max)>abs(min)){
      for(int i=0; i<N-1; ++i){
	 std::cout << i+1 << ' ' << i+2 << std::endl;
	 a[i+1] += a[i];
      }
   }else{
      for(int i=N-2; i>=0; --i){
	 std::cout << i+2 << ' ' << i+1 << std::endl;
	 a[i] += a[i+1];
      }
   }


   return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>

int main(void){
	int card[9], n, i, j, k, s[3][9];
	char c, color[4] ={"RGB"};
	scanf("%d",&n);
	for(i = 0;i < n;i++){
		for(j = 0;j < 9;j++){
			scanf("%d",&card[j]);
			card[j]--;
		}
		getchar();
		memset(s,0,sizeof(s));
		for(j = 0;j < 9;j++){
			scanf("%c",&c);
			getchar();
			for(k = 0;k < 3;k++)
				if(color[k] == c) s[k][card[j]]++;
		}
		for(j = 0;j < 3;j++){
			for(k = 0;k < 9;k++)
				if(s[j][k] >= 3) s[j][k] %= 3;
		}
		for(j = 0;j < 3;j++){
			for(k = 0;k < 7;k++){
				if(s[j][k] && s[j][k + 1] && s[j][k + 2]){
					s[j][k]--,s[j][k + 1]--,s[j][k + 2]--;
					k--;
				}
			}
		}
		for(j = 0;j < 3;j++){
			for(k = 0;k < 9;k++)
				if(s[j][k]) break;
			if(k != 9) break;
		}
		if(j == 3)
			printf("1\n");
		else
			printf("0\n");
	}
	return 0;
}

Measured memory_bytes: 1012
#include <bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define MOD 1000000007
#define INF 1234567890
#define pii pair<int,int>
#define LL long long
using namespace std;

int main () {
    //clock_t start = clock();
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    string s;
    cin >> s;
    if (s[0] == s[1] && s[1] == s[2] && s[0] == 'R') cout << 3 << endl;
    else if ((s[0] == s[1] && s[0] == 'R') || (s[1] == s[2] && s[1] == 'R')) cout << 2 << endl;
    else if (s[0] == 'R' || s[1] == 'R' || s[2] == 'R') cout << 1 << endl;
    else cout << 0 << endl;
    //cerr << fixed << setprecision(3) << (clock()-start)*1./CLOCKS_PER_SEC << endl;
    return 0;
}

Measured memory_bytes: 3580
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

struct Node {
    int key;
    struct Node *right, *left, *parent;
};
typedef struct Node Node;

Node *root, *NIL;

Node * find(Node *u, int k) {
    while(u != NIL && k != u->key) {
        if(k < u->key) u = u->left;
        else u = u->right;
    }
    return u;
}

void insert(int k) {
    Node *y = NIL;
    Node *x = root;
    Node *z;
    
    z = (Node *)malloc(sizeof(Node));
    z->key   = k;
    z->left  = NIL;
    z->right = NIL;
    
    while(x != NIL) {
        y = x;
        if(z->key < x->key) {
            x = x->left;
        } else {
            x = x->right;
        }
    }
    
    z->parent = y;
    if(y == NIL) {
        root = z;
    } else {
        if( z->key < y->key) {
            y->left = z;
        } else {
            y->right = z;
        }
    }
}

void inorder(Node *u) {
    if(u == NIL) return;
    inorder(u->left);
    printf(" %d",u->key);
    inorder(u->right);
}
void preorder(Node *u) {
    if(u == NIL) return;
    printf(" %d",u->key);
    preorder(u->left);
    preorder(u->right);
}
    


int main(void) {
    int n, i, x;
    char com[16];
    scanf("%d",&n);
    
    for(i=0;i<n;i++) {
        scanf("%s",com);
        if(com[0] == 'f') {
            scanf("%d",&x);
            Node *t = find(root,x);
            if(t != NIL) printf("yes\n");
            else printf("no\n");
        } else if(!strcmp(com,"insert")) {
            scanf("%d",&x);
            insert(x);
        } else if(!strcmp(com,"print")) {
            inorder(root);
            printf("\n");
            preorder(root);
            printf("\n");
        }
    }

    return 0;
}


Measured memory_bytes: 20452
#include <iostream>
#include <vector>
#include <utility>
#include <algorithm>

using namespace std;

long long solve(int N, vector<int> L, vector<int> R)
{
    vector<int> TL(N), TR(N);
    for (int i=0; i<N; i++)
        TL[i] = TR[i] = i;
    sort(TL.begin(), TL.end(), [&](int a, int b){return R[a]<R[b];});
    sort(TR.begin(), TR.end(), [&](int a, int b){return L[a]>L[b];});
    vector<bool> U(N);
    long long ans = 0;
    int pos = 0;
    int lp = 0;
    int rp = 0;
    for (int i=0; i<N; i++)
    {
        int idx;
        if (i%2 == 0)
        {
            while (U[TL[lp]])
                lp++;
            idx = TL[lp];
        }
        else
        {
            while (U[TR[rp]])
                rp++;
            idx = TR[rp];
        }
        
        int np = 0;
        if (R[idx] < pos)
            np = R[idx];
        else if (L[idx] > pos)
            np = L[idx];
        else
            np = pos;
        ans += abs(np-pos);
        pos = np;
        U[idx] = true;
    }
    ans += abs(pos);
    return ans;
}

int main()
{
    int N;
    cin>>N;
    vector<int> L(N), R(N);
    for (int i=0; i<N; i++)
        cin>>L[i]>>R[i];
    long long ans = solve(N, L, R);
    for (int i=0; i<N; i++)
    {
        int t = L[i];
        L[i] = -R[i];
        R[i] = -t;
    }
    ans = max(ans, solve(N, L, R));
    cout<<ans<<endl;
}


Measured memory_bytes: 2656
#include <iostream>
#include <string>
#include <cmath>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<iomanip>
#define _USE_MATH_DEFINES
#include <math.h>
#include <functional>
#include<complex>
using namespace std;

#define rep(i,x) for(ll i=0;i<x;i++)
#define repn(i,x) for(ll i=1;i<=x;i++)

typedef long long ll;
const ll INF = 1e17;
const ll MOD = 998244353;
const ll MAX = 4000001;
const long double eps = 1E-14;

ll max(ll a, ll b) {
	if (a > b) { return a; }
	return b;
}

ll min(ll a, ll b) {
	if (a > b) { return b; }
	return a;
}

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

ll lcm(ll a, ll b) {
	return a / gcd(a, b) * b;
}

struct edge {
	ll ind;
	ll fr;
	ll to;
	ll d;
};

class mint {
	long long x;
public:
	mint(long long x = 0) : x((x% MOD + MOD) % MOD) {}
	mint operator-() const {
		return mint(-x);
	}
	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;
	}

	friend ostream& operator<<(ostream& os, const mint& m) {
		os << m.x;
		return os;
	}
};

mint pw(mint a, ll b) {
	if (b == 0) { return 1; }
	mint ret = pw(a, b >> 1);
	ret *= ret;
	if (b & 1) { ret *= a; }
	return ret;
}

typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef vector<vector<vector<ll>>> vvvll;

typedef vector<mint> vmint;
typedef vector<vector<mint>> vvmint;
typedef vector<vector<vector<mint>>> vvvmint;

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


int main() {
	ll N;
	cin >> N;
	vll a(N + 1);
	repn(i, N) cin >> a[i];

	vll sz(N + 1, 0);
	repn(i, N)sz[i] = sz[i - 1] + a[i];

	vvll dp(N + 1, vll(N + 1, INF));
	repn(i, N)dp[i][i] = 0;

	repn(x, N) {
		repn(j, N) {
			if (j + x > N) { break; }

			for (ll k = j; k < j + x; k++) {
				dp[j][j + x] = min(dp[j][j + x], dp[j][k] + dp[k + 1][j + x]+sz[j+x]-sz[j-1]);
			}
		}
	}

	cout << dp[1][N] << endl;
}

Measured memory_bytes: 4852
#include <iostream>
#include <algorithm>
#include <string>
#include <cmath> //abs();
using namespace std;

int main(void)
{
    long long int a,b,c,d,i,j,k,n,x[10];
    string s;
    char C[5];

    cin >> a >> b;

    if(a+b<10) cout << a+b;
    else cout << "error";

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
typedef pair<int,int> P;
int INF = 1e18;
int mod = 1e9+7;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
int dp[105][5][2];
signed main() {
    string N;
    int K;
    cin >> N >> K;
    for(int i = 0; i < N.size(); i++) {
        if(i == 0) {
            dp[i][1][0] = 1;
            dp[i][0][1] = 1;
            dp[i][1][1] = N[i]-'1';
            continue;
        }
        for(int j = 0; j <= K; j++) {
            if(N[i]-'0' >= 1) {
                dp[i][j][1] += dp[i-1][j][0]+dp[i-1][j][1];
                if(j-1 >= 0) {
                    dp[i][j][0] += dp[i-1][j-1][0];
                    dp[i][j][1] += dp[i-1][j-1][0]*(N[i]-'1')+dp[i-1][j-1][1]*9;
                }
            }
            else {
                dp[i][j][0] += dp[i-1][j][0];
                dp[i][j][1] += dp[i-1][j][1];
                if(j-1 >= 0) {
                    dp[i][j][1] += dp[i-1][j-1][1]*9;
                }
            }
        }
    }
    cout << dp[N.size()-1][K][0]+dp[N.size()-1][K][1] << endl;
}

Measured memory_bytes: 3628
abcd = list(input())

for i in ["+","-"]:
    for j in ["+","-"]:
        for k in ["+","-"]:
            siki = abcd[0] + i + abcd[1] + j + abcd[2] + k + abcd[3]
            if eval(siki) == 7:
                print(siki + "=7")
                exit()

Measured memory_bytes: 3060
#include <stdio.h>

int main(void){
    int i,j=0;
    char s[17],t[17]="CODEFESTIVAL2016";
    scanf("%s",s);
    for(i=0;i<16;i++){
        if(s[i]!=t[i]){
            s[i]=t[i];
            j++;
        }
    }
    printf("%d\n",j);
    return 0;
}

Measured memory_bytes: 128