akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstring>
#include <cstdlib>
#include <algorithm>

using namespace std;
int main(void)
{
    int N;

    cin >> N;

    int t = 1;
    int count = 0;
    while (1) {
        t *= 2;
        count++;
        if (t > N) {
            cout << t / 2 << endl;
            break;
        }
    }

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define WHOLE(v) (v).begin(), (v).end()
#define REV_WHOLE(v) (v).rbegin(), (v).rend()
using i64 = int64_t;
using namespace std;
template<class I,class V=typename I::value_type>V sum_up(const I&l,const I&r){V v;for(I i=l;i!=r;i++)v=i==l?*i:v+*i;return v;}
template<class I,class T=iterator_traits<I>>I operator+(I it,int n){for(int i=0;i<n;i++)it++;return it;}
template<class I,class T=iterator_traits<I>>I operator-(I it,int n){for(int i=0;i<n;i++)it--;return it;}
template<class T>using rev_priority_queue=priority_queue<T,vector<T>,greater<T>>;
template<class T>using vector2d=vector<vector<T>>;
struct fixprec{int x;fixprec(int d):x(d){}};
ostream&operator<<(ostream&o,fixprec f){return o<<fixed<<setprecision(f.x);}
void R_YESNO(bool p) { cout << (p ? "YES" : "NO") << endl; }
void R_YesNo(bool p) { cout << (p ? "Yes" : "No") << endl; }

/*!* [binsearch] *!*/
/*+* 二分探索 *+*/
// judge を満たすような下限を求める
// l:[X] 定義域外部の上限
// r:[X] 定義域外部の下限
// judge:[X -> bool] X を評価する関数
// lower:[bool] falseにすると代わりに上限を求める
// eps:[X] 終了距離

template <typename X>
X BinSearch(X l, X r, function<bool(X)> judge, bool lower = true, X eps = 1) {
    while (r - l > eps) {
        X m = (r + l) / 2;
        if (judge(m) == lower) {
            r = m;
        } else {
            l = m;
        }
    }
    return lower ? r : l;
}

int main() {
    i64 N, M;
    cin >> N >> M;
    vector<i64> A(N), S(N, 0);
    for(i64 &x : A) cin >> x;
    sort(REV_WHOLE(A));
    for(int i = 0; i < N; i++) {
        S[i] = A[i] + (i ? S[i - 1] : 0);
    }
    // 幸福度がt以上上がるものだけにする
    int T = BinSearch<i64>(1, 1e8, [&](i64 t) -> bool {
        i64 n = 0;
        for (int i = 0; i < N; i++) {
            i64 j = BinSearch<int>(-1, N, [&](int k) -> bool {
                return A[k] + A[i] >= t;
            }, false);
            n += j + 1;
        }
        return n >= M;
    }, false); // M通り以上あるtの最大値を求める

    i64 ans = 0;
    i64 m = 0;
    for(int i = 0; i < N; i++) {
        i64 j = BinSearch<int>(-1, N, [&](int k) -> bool {
            return A[k] + A[i] >= T;
        }, false);
        if(j < 0) continue;
        ans += S[j] + A[i] * (j + 1);
        m += j + 1;
    }
    ans -= (m - M) * T;
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 1792
#include <iostream>
#include <vector>
#include <algorithm>
#include <list>

using namespace std;

int main() {
    int x[10000];
    for (int i = 1; i <= 10000;i++) {
        cin >> x[i];
        if (x[i] == 0) {
            for (int j = 1; j < i; j++) {
                cout << "Case " << j << ": " << x[j] << endl;
            }
            break;
        }
    }

}


Measured memory_bytes: 3056
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <stdlib.h>
#include <limits.h>
#include <stdbool.h>

#define rep(i, n) for(int i=0; i<(n); ++i)
#define max  200001

//qsort(str, n, sizeof(int), up_comp);
int up_comp(const void *a, const void *b){return *(int*)a - *(int*)b;}
int down_comp(const void *a, const void *b){return *(int*)b - *(int*)a;}
int int_sort( const void * a , const void * b ) {return strcmp(( char * )a , ( char * )b );}
int count_digit(int a){int i=0;while(a!=0){a=a/10;i++;}return i;}
int euclid( int a, int b ){int temp;if(a<b){temp=a;a=b;b=temp;}if(b<1)return -1;if(a%b==0) return b;return euclid(b,a%b);}

int main(void){
 
    char s[100];
    
    scanf("%s", s);
    
    if (!strcmp(s, "Sunny")) {
        printf("Cloudy");
    } else if (!strcmp(s, "Cloudy")) {
        printf("Rainy");
    } else if (!strcmp(s, "Rainy")) {
        printf("Sunny");
    }
    
    return 0;
}



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

using namespace std;

#define fi first
#define se second
#define pb push_back
#define mp make_pair

typedef pair<int, int> ii;

const int N = 2e5 + 5;

int n;

long long k, sum[N], a[N], b[N], sbd[N], cnt, total, bit[N];

vector<pair<long long, int>> vec;

void update(int pos){
    while(pos <= N - 5){
        bit[pos] += 1;
        pos += pos & (-pos);
    }
}

int get(int pos){
    int sum1 = 0;
    while(pos > 0){
        sum1 += bit[pos];
        pos -= pos & (-pos);
    }
    return sum1;
}

int main() {
    cin.tie(0), ios::sync_with_stdio(0);
    cin >> n >> k;
    for(int i = 1; i <= n; i++){
        cin >> a[i];
        sum[i] = a[i];
        sum[i] += sum[i - 1];
    }
    for(int i = 1; i <= n; i++){
        b[i] = sum[i] - 1ll * i * k;
        vec.pb({b[i], i});
    }
    sort(vec.begin(), vec.end());
    sbd[vec[0].se] = ++cnt;
    for(int i = 1; i < vec.size(); i++){
        if(vec[i].fi != vec[i - 1].fi)
            sbd[vec[i].se] = ++cnt;
        else
            sbd[vec[i].se] = cnt;
    }
    for(int i = 1; i <= n; i++){
        if(sum[i] - 1ll * i * k >= 0)
            total++;
        total += get(sbd[i]);
        update(sbd[i]);
    }
    cout << total << "\n";
}


Measured memory_bytes: 12272
n,k=map(int,input().split())
s=input()

num_cnt=[]
if s[0]=='1':
  num_cnt.append(0)

cnt=1
for i in range(1,n):
  if s[i]==s[i-1]:
    cnt+=1
  else:
    num_cnt.append(cnt)
    cnt=1
num_cnt.append(cnt)

leng=len(num_cnt)
if leng/2>k:
  ans=sum(num_cnt[:2*k])
  tot=ans
  
  if leng%2==0:
    limit=leng//2-k
  else:
    num_cnt.append(0)
    limit=leng//2-k+1
  
  #print(ans)
  #print(num_cnt)
  tmp2=num_cnt[2*k]+num_cnt[2*k+1]-num_cnt[0]
  tot+=tmp2
  if tot>ans:
    ans=tot
  
  for i in range(1,limit):
    #print(2*(i+k)+1)
    tmp=num_cnt[2*(i+k)]+num_cnt[2*(i+k)+1]-num_cnt[2*i]-num_cnt[2*i-1]
    #print(tot)
    tot+=tmp
    if tot>ans:
      ans=tot
else:
  ans=n
print(ans)
  

Measured memory_bytes: 4476
#include <stdio.h>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <set>
#include <iterator>
#pragma warning(disable:4996)

typedef long long ll;
#define MIN(a, b) ((a)>(b)? (b): (a))
#define MAX(a, b) ((a)<(b)? (b): (a))
#define MOD 1000000007
using namespace std;

long a[100];
long b[100];
long c[100];
long d[100];

int main(int argc, char* argv[])
{
    long n, k;
    scanf("%ld %ld", &n, &k);
    
    ll ans=0;
    if(k==0) {
        ans = (ll)n*n;
    }
    else {
        long b;
        for(b=k+1; b<=n; b++) {
            ans += (ll)(n/b)*(b-k)+ (ll)MAX(n%b-k+1,0);
        }
    }
    printf("%lld\n", ans);

    return 0;
}


Measured memory_bytes: 128
using namespace std;
#include <bits/stdc++.h>
#define rep(i, s) for (int i = 0; i < s; ++i)
#define repr(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define all(v) (v.begin(), v.end())
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)
#define VEC(a, n) vector<int>a(n)
#define VECV(a,n,m) vector<vector<int>> a(n, vector<int>(m));
#define PQ(a) priority_queue<int>a
#define PQmin(a) priority_queue< int, :vector<int>, greater<int> >a
#define PAIR pair<int, int>
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
#define EPS (1e-7)
#define INF (1e10)
#define PI (acos(-1))
const ll mod = 1000000007;
bool f(string s){
  bool ans=true;
  rep(i,s.size()/2){
    if(s[i]!=s[s.size()/2+i]){
      ans=false;
      break;
    }
  }
  return ans;
}
int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  string s;
  cin>>s;
  if(s=="ARC")
    cout<<"ABC"<<endl;
  else
    cout<<"ARC"<<endl;

}

Measured memory_bytes: 3612
#include<iostream>
#include<stdio.h>
#include<vector>
#include<algorithm>
#include<set>
#include<string>
#include<map>
#include<string.h>
#include<complex>
#include<math.h>
#include<queue>
#include <functional>
#include<time.h>
#include <stack>
#include<iomanip>
using namespace std;
#define rep(i,a,n) for(int i=(a);i<(n);i++)
#define ll long long
#define llint long long int
#define reverse(v)  reverse(v.begin(), v.end());
#define Yes(ans) if(ans)cout<<"Yes"<<endl; else cout<<"No"<<endl;
#define YES(ans) if(ans)cout<<"YES"<<endl; else cout<<"NO"<<endl;
#define hei(a) vector<a>
#define whei(a) vector<vector<a>>
#define UF  UnionFind
#define rt (a); return (a); 
#define Pint pair<int,int>
#define keta(a)  fixed << setprecision(a)
constexpr auto INF = 1000000000;
constexpr auto mod = 1000000007;
//辞書順はnext_permutation( begin( v ), end( v ) );やで！
llint gcd(llint a, llint b) {
	if (b > a)swap(a, b);
	if (a % b == 0)return b;
	return gcd(b, a % b);
}
llint Tow(int n) {//2のn乗
	if (n == 0)return 1;
	llint x = Tow(n / 2);
	x %= mod;
	x *= x;
	x %= mod;
	if (n % 2 == 1)x *= 2;
	x %= mod;
	return x;
}
int dx[4] = { 1,0,-1,0 };
int dy[4] = { 0,1,0,-1 };
char a[501][501];
bool seen[1000][1000] = { false };
void dfs(int x,int y,int h,int w) {
	seen[x][y] = true;
	for (int i = 0; i < 4; i++) {
		int Nx = x + dx[i];
		int Ny = y + dy[i];
		if (Nx >= h || Ny >= w || seen[Nx][Ny] || a[Nx][Ny] == '#' || Nx < 0 || Ny < 0)continue;
		dfs(Nx, Ny,h,w);
	}
}
int main() {
	int n;
	cin >> n;
	hei(int) s(n, 0);
	rep(i, 0, n-1) {
		int a;
		cin >> a;
		s[a - 1]++;
	}
	rep(i, 0, n) {
		cout << s[i] << endl;
	}
	return 0;
}

Measured memory_bytes: 4056
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
const int maxn=1e6+5;
int main() {
    string s;cin>>s;
    if(s.front()==s.back()&&s.length()%2==0) puts("First");
    else if(s.front()!=s.back()&&s.length()%2) puts("First");
    else puts("Second");
    return 0;
}

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

using namespace std;

int main() {
  int n;
  cin >> n;
  int d, x;
  cin >> d >> x;
  vector<int> v(n);
  int count = 0;
  for(int i=0; i < n; i++) {
    int t; cin >> t;
    int q = 1;
    while(q <= d) {q += t; count++;}
  }
  cout << count+x << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) FOR(i,0,n)
#define repr(i,n) for(int i=(n)-1;0<=i;--i)
#define each(e,v) for(auto&& e:(v))
#define all(v) begin(v),end(v)
#define dump(x) cerr<<#x<<": "<<(x)<<endl
using namespace std;
using vint = vector<int>;
using ll = long long;
using vll = vector<ll>;
template <class T> void chmin(T& a, const T& b) { a = min(a, b); }
template <class T> void chmax(T& a, const T& b) { a = max(a, b); }
void yes() { cout << "Yes" << endl; exit(0); }
void no() { cout << "No" << endl; exit(0); }

int main() {
    int a, b, c; cin >> a >> b >> c;
    cout << min(c, b / a) << endl;
    return 0;
}


Measured memory_bytes: 256
#python3

def main():
    n = int(input())
    a = [int(i) for i in input().split()]
    b = [0 for _ in range(n)]
    for i in reversed(range(1, n+1)):
        s = 0
        j = i + i
        while j <= n: 
            s ^= b[j-1]
            j += i
        b[i-1] = s^a[i-1]
    
    m = sum(b)
    print(m)
    for i in range(n):
        if b[i] == 1:
            if i == n-1:
                print(i+1)
            else:
                print(i+1, end=' ')
        
main()

Measured memory_bytes: 7276
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <array>
#include <tuple>
#include <string>
#include <algorithm>
#include <functional> // greater など
#include <cmath> // abs など
#include <numeric> // accumulate など
#include <stdexcept>
#include <cassert> // assert
using namespace std;

#define REP(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long ll;

// #define NDEBUG 1
// debug用出力 https://trap.jp/post/998/
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T)
{
    cerr << H << " ";
    debug_out(T...);
}
#ifdef NDEBUG
#define debug(...)
#else
#define debug(...) debug_out(__VA_ARGS__)
#endif

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

map<ll, int> f(const ll arg)
{
    ll n = arg;
    map<ll, int> res;

    // sqrt(arg)までの素因数を列挙
    for (int i = 2; (ll)i * (ll)i <= arg; i++)
    {
        while (n % i == 0)
        {
            // nは変化することに注意するとiは素数
            n /= i;
            res[i]++;
        }
    }

    // sqrt(arg)を超える素因子があるとき、それはただ一つなのでn
    if (n != 1)
    {
        res[n] = 1;
    }
    
    return res;
}

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

  	int res = 0;
    auto primes = f(n);
    for (auto p : primes) {
      int i = 0;
      int cnt = p.second;
      while (cnt >= i + 1) {
        i++;
        cnt -= i;
      }
      res += i;
    }
  
    cout << res << endl;

    return 0;
}


Measured memory_bytes: 3580
s=list(input())
al=[chr(ord('a') + i) for i in range(26)]
al=[i for i in al if i not in s]
if al:
    print(''.join(s)+al[0])
    exit()
for i in range(25,0,-1):
    if s[i-1]<s[i]:
        a=[j for j in s[i-1:] if s[i-1]<j]
        s=s[:i-1]+[sorted(a)[0]]
        print(''.join(s))
        break
        exit()
else:print(-1)

Measured memory_bytes: 3064
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 line = "";
 
        boolean[] primes = new boolean[1000000];
        int[] counts = new int[1000000];
 
        for (int i = 2; i < 1000000 / 2 + 1; i++) {
            if (!primes[i]) {
                for (int j = 2; j < 999999 / i + 1; j++) {
                    primes[i * j] = true;
                }
            }
        }
        int count = 0;
        for (int i = 2; i < 1000000; i++) {
            if (!primes[i]) {
                count++;
            }
            counts[i] = count;
        }
 
        while ((line = br.readLine()) != null && !line.isEmpty()) {
            System.out.println(counts[Integer.parseInt(line)]);
        }
    }
}

Measured memory_bytes: 30144
/*huzaifa242 copyright*/
#include <bits/stdc++.h>
using namespace std;
#define PI 3.1415926535897932384626
#define mod 1000000007
#define MAX 100005
int n,dp[MAX][3],cc[MAX][3];
int go(int x,int k)
{
    if(x==-1)
    return 0;
    if(dp[x][k]!=0)
    return dp[x][k];
    for(int i=0;i<3;i++)
    {
        if(i!=k)
        dp[x][k]=max(go(x-1,i)+cc[x][i],dp[x][k]);
    }
    return dp[x][k];
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    #ifdef ONLINE_JUDGE
        freopen("input.txt","r",stdin);
        freopen("output.txt","w",stdout);  
    #endif
    int i,j,ans=0;
    cin>>n;
    memset(dp,0,sizeof(dp));
    for(i=0;i<n;i++)
    {
    	for(j=0;j<3;j++)
        cin>>cc[i][j];
    }
    ans=max(go(n-1,0),max(go(n-1,1),go(n-1,2)));
    cout<<ans<<"\n";
    return 0;
}

Measured memory_bytes: 10368
def my_match s,t
  
  sl = s.length
  sl.times do |i|
    return false if s[i] != ?? and s[i] != t[i]
  end
  return true
end

def solve sp,t
  
  s = sp
  sl = s.length
  tl = t.length
  
  no = "UNRESTORABLE"
  return no if sl < tl
  
  k = sl - tl
  anss = []
  0.upto(k) do |i|
    if my_match(sp[i,tl],t)
      tmp = String.new(sp)
      tmp[i,tl] = t
      anss << tmp.gsub(??, ?a)
    end
  end
  
  return anss.sort[0] if anss.size != 0 
  
  return no
end

sp = gets.chomp
t = gets.chomp

puts solve sp,t


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

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

    int X[N];
    int mn = -1;
    int mx = -1;
    for (int i = 0; i < N; i++) {
        cin >> X[i];
        mn = mn == -1 ? X[i] : min(mn, X[i]);
        mx = mx == -1 ? X[i] : max(mx, X[i]);
    }

    int res = -1;
    for (int i = mn; i <= mx; i++) {
        int tmp = 0;
        for (int j = 0; j < N; j++) {
            tmp += (i - X[j]) * (i - X[j]);
        }
        res = res == -1 ? tmp : min(res, tmp);
    }

    cout << res;
}


Measured memory_bytes: 256
import sys
sys.setrecursionlimit(300000)

def I(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LMI(): return list(map(int, sys.stdin.readline().split()))
MOD = 10 ** 9 + 7
INF = float('inf')


N = I()
print(sum(i for i in range(N + 1) if i % 3 != 0 and i % 5 != 0))


Measured memory_bytes: 67760
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Main main = new Main();
		main.solve();
	}

	void solve() {
		Scanner sc = new Scanner(System.in);
		int n = Integer.parseInt(sc.next());
		String S = sc.next();
		sc.close();
        S = S.replaceAll("B", "");
       	System.out.println(n/2<S.length()?"Yes":"No");
	}

}


Measured memory_bytes: 21460
import fractions


def lcm(x, y):
    return x // fractions.gcd(x, y) * y


def solve(n, m, s, t):
    le = lcm(n, m)
    s_new_ps = {le // n * i for i in range(n)}
    t_new_ps = {le // m * i for i in range(m)}
    conf_new_ps = s_new_ps & t_new_ps
    for p in conf_new_ps:
        i = p // (le // n)
        j = p // (le // m)
        if s[i] != t[j]:
            return None
    return le


def main():
    n, m = (int(z) for z in input().split())
    s = input()
    t = input()
    res = solve(n, m, s, t)
    if res is None:
        print(-1)
    else:
        print(res)


if __name__ == '__main__':
    main()

Measured memory_bytes: 19280
#include<bits/stdc++.h>
using namespace std;
#define INIT  ios_base :: sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#define mp make_pair
#define pb push_back
#define ft first
#define sc second
#define ll long long
#define pii pair<int, int>
#define count_bits __builtin_popcount
#define int ll


int t, n, m, k, a[300010], q, l, r;

map<int, int> h;

int32_t main(){
INIT
cin>>n;
int sum=0;
for(int i=1; i<=n; i++){
    cin>>a[i]; sum+=a[i]; h[a[i] ]++;
}
cin>>q;
while(q--){
    int b,c; cin>>b>>c;
    h[c ]+=h[b]; sum-=h[b]*b; sum+=h[b]*c; h[b]=0;
cout<<sum<<"\n";
}

return 0;
}




Measured memory_bytes: 10260
def rs(X, Y, i):
  if i not in Y:
    return 0
  elif len(Y)==1:
    return 1
  Y.remove(i)
  
  total=0
  X_tmp=[x for x in X if i in x]
  for x in X_tmp:
    st=set(x)&set(Y)
    if st!=set():
      target=list(st)[0]
    else:
      continue
    total+=rs(X, Y[:], target)
    
  return total
  

N,M=map(int, input().split())
X=[list(map(int,input().split())) for _ in range(M)]
Y=[i+1 for i in range(N)]
print(rs(X, Y, 1))

Measured memory_bytes: 3064
cards = {
        'S': [0 for _ in range(13)],
        'H': [0 for _ in range(13)],
        'C': [0 for _ in range(13)],
        'D': [0 for _ in range(13)],
        }
  
n = int(input())
for _ in range(n):
    (s, r) = input().split()
    r = int(r)
    cards[s][r - 1] = r
  
for s in ('S', 'H', 'C', 'D'):
    for r in range(13):
        if cards[s][r] == 0:
            print( '{0:s} {1:d}'.format(s, r+1))

Measured memory_bytes: 7776
/*
	Created by : imay_10
	" It won't be EASY, but I'll make it "
*/

#include<bits/stdc++.h>
using namespace std;

typedef long long int ll;
const int mod = 1e9+7;
const ll inf = 1e18;
const double pi = 3.1415926535897932384626;

// Utility for fast exponentiation
ll mpow(ll a,ll b,ll m){
    ll res=1;
    //a%=m;
    while(b){
    	if(b%2) res=res*a%m;
		a=a*a%m;
		b/=2;
	}
	return res;
}

// Utility for GCD Calculation
ll gcd(ll a,ll b){
	if(b==0) return a;
	return gcd(b,a%b);
}

void solve(){
	//code
	string s;
	cin>>s;
	if(s[2]==s[3] and s[4]==s[5] )
		cout<<"Yes";
	else 
		cout<<"No"; 
}

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	
	solve();
 	return 0;
}


Measured memory_bytes: 3648
#include <iostream>
#include <iomanip>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>
#include <sstream>
 
using namespace std;

vector<string> vec_splitter(string s) {
  s += ',';
  vector<string> res;
  while(!s.empty()) {
    res.push_back(s.substr(0, s.find(',')));
    s = s.substr(s.find(',') + 1);
  }
  return res;
}
void debug_out(
vector<string> __attribute__ ((unused)) args,
__attribute__ ((unused)) int idx,
__attribute__ ((unused)) int LINE_NUM) { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(vector<string> args, int idx, int LINE_NUM, Head H, Tail... T) {
  if(idx > 0) cerr << ", "; else cerr << "Line(" << LINE_NUM << ") ";
  stringstream ss; ss << H;
  cerr << args[idx] << " = " << ss.str();
  debug_out(args, idx + 1, LINE_NUM, T...);
}

#ifndef ONLINE_JUDGE
#define debug(...) debug_out(vec_splitter(#__VA_ARGS__), 0, __LINE__, __VA_ARGS__)
#else
#define debug(...) 42
#endif
 
#define MOD 1000000007
#define A first
#define B second
#define all(x) (x).begin(), (x).end

typedef long long ll;
 
inline int mulmd(ll a, ll b){
  ll ret = (a * b) % MOD;
  return (int) ret;
}
 
inline int power(ll x, ll y, int m){
  ll res = 1;
  x = x % m;
  while(y > 0){
    if(y & 1){
      res = mulmd(res, x);
    }
    y = y >> 1;
    x = mulmd(x, x);
  }
  return (int) res;
}
 
inline int submd(ll a, ll b){
  ll ret = (a - b);
  if(ret < 0) ret += MOD;
  return (int) ret;
}
 
inline int addmd(ll a, ll b){
  ll ret = (a + b) % MOD;
  return (int) ret;
}
 
inline int invPow(ll a){
  return power(a, MOD - 2, MOD);
}
 
inline int divmd(ll a, ll b){
  ll ret = mulmd(a, invPow(b));
  return (int) ret;
}
 
const int N = 1e5 + 5;

int arr[N];
int dp[N];

void solve(){
  int n;
  cin >> n;
  for(int i = 0; i < n; i++) cin >> arr[i];
  dp[0] = 0;
  for(int i = 1; i < n; i++){
    if(i == 1) dp[i] = abs(arr[i] - arr[i - 1]);
    else {
      dp[i] = min(dp[i - 2] + abs(arr[i - 2] - arr[i]), dp[i - 1] + abs(arr[i - 1] - arr[i]));
    }
    debug(dp[i]);
  }
  cout << dp[n - 1];

}

int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int t;
  t = 1;
  //cin >> t;
  while(t--){
    solve();
  }
}



Measured memory_bytes: 4372
from sys import stdin
n = int(stdin.readline().rstrip())
data = list(map(int, stdin.readline().rstrip().split()))

count = 0
data.insert(0, 0)

for i in range(0,len(data)//2):

    if data[2*i+1]%2 == 1:
        count += 1

print(count)

Measured memory_bytes: 9112
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define Would
#define you
#define please

int pn, nn;
char p[3], n[3];
const int dm = 1 << 21;
char dn[dm], *di = dn;
inline void putps() {
	for (int i = pn - 1; i >= 0; i--) *di++ = *(p + i);
	*di++ = ' ';
}
inline void putp() {
	for (int i = pn - 1; i >= 0; i--) *di++ = *(p + i);
	*di++ = '\n';
}
inline void putns() {
	*di++ = '-';
	for (int i = nn - 1; i >= 0; i--) *di++ = *(n + i);
	*di++ = ' ';
}
inline void putn() {
	*di++ = '-';
	for (int i = nn - 1; i >= 0; i--) *di++ = *(n + i);
	*di++ = '\n';
}
inline void putzs() {
	*di++ = '0';	
	*di++ = ' ';
}
inline void putz() {
	*di++ = '0';
	*di++ = '\n';
}

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


	int H, W, h, w;
	cin >> H >> W >> h >> w;

	if (H % h != 0) {
		*di++ = 'Y';
		*di++ = 'e';
		*di++ = 's';
		*di++ = '\n';
		int k = H / h;
		int amari = H % h;
		int X = k + 1;
		while (X) {
			*(p + pn) = '0' + X % 10;
			X /= 10;
			pn++;
		}
		X = k + 2;
		while (X) {
			*(n + nn) = '0' + X % 10;
			X /= 10;
			nn++;
		}

		rep(i, W - 1) putps();
		putp();
		rep(j, k - 1) {
			rep(i, h - 2) {
				rep(j, W - 1) putzs();
				putz();
			}
			rep(i, W - 1) putns();
			putn();
			rep(i, W - 1) putps();
			putp();
		}
		rep(i, h - 2) {
			rep(j, W - 1) putzs();
			putz();
		}
		rep(i, W - 1) putns();
		putn();
		rep(i, amari - 1) {
			rep(j, W - 1) putzs();
			putz();
		}
		rep(i, W - 1) putps();
		putp();
	}
	else if (W % w != 0) {
		*di++ = 'Y';
		*di++ = 'e';
		*di++ = 's';
		*di++ = '\n';
		int k = W / w;
		int amari = W % w;
		int X = k + 1;
		while (X) {
			*(p + pn) = '0' + X % 10;
			X /= 10;
			pn++;
		}
		X = k + 2;
		while (X) {
			*(n + nn) = '0' + X % 10;
			X /= 10;
			nn++;
		}

		rep(i, H) {
			putps();
			rep(j, k - 1) {
				rep(j, w - 2) putzs();
				putns();
				putps();
			}
			rep(j, w - 2) putzs();
			putns();
			rep(i, amari - 1) putzs();
			putp();
		}
	}
	else {
		*di++ = 'N';
		*di++ = 'o';
		*di++ = '\n';
	}

	fwrite_unlocked(dn, di - dn, 1, stdout);

	Would you please return 0;
}

Measured memory_bytes: 2432
N,M,X = map(int, input().split())
CA_s = [list(map(int, input().split())) for _ in range(N)]
ans = 10**18
pattern = []
for i in range(2 ** (N)):
    tmp = [False] * N
    for j in range(N):
        if i >> j & 1:
            tmp[j] = True
    price = 0
    rikaidos = [0] * M
    for i in range(len(tmp)):
        if(tmp[i] == True):
            for j in range(M+1):
                if j == 0:
                    price += CA_s[i][0]
                else:
                    rikaidos[j-1] += CA_s[i][j]
    if len(list(filter(lambda x:x<X, rikaidos)))==0 and price<ans:
        ans = price
if ans == 10**18:
    ans = -1
print(ans)

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

int main() {
  int n;
  cin >> n;
  vector<int> b(n-1);
  rep(i,n-1) cin >> b[i];
  vector<int> a(n);
  a[0] = b[0];
  for (int i = 1; i <= n-2; i++) {
    a[i] = min(b[i],b[i-1]);
  }
  a[n-1] = b[n-2];
  int ans = 0;
  rep(i,n) ans += a[i];
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>

using namespace std;
int a[5];
bool is_straight()
{
  for (int i = 1; i < 5; i++) {
    if (a[i] != a[i - 1] + 1) {
      goto next;
    }
  }
  return true;
 next:
  if (a[0] == 1 && a[1] == 10 && a[2] == 11 && a[3] == 12 && a[4] == 13) {
    return true;
  }
  return false;
}


int main()
{
  while (scanf("%d" , &a[0]) == 1) {
    for (int i = 1; i < 5; i++) {
      scanf(",%d", &a[i]);
    }
    sort(a, &a[5]);
    /*for (int i = 0; i < 5; i++) {
      printf("%d ", a[i]);
    }
    printf("\n");*/
    vector<int> mx_v;
    int mx = 1;

    for (int i = 1; i < 5; i++) {
      if (a[i] == a[i - 1]) {
	mx++;
      } else {
	mx_v.push_back(mx);
	mx = 1;

      }
    }
    mx_v.push_back(mx);
    mx = *max_element(mx_v.begin(), mx_v.end());
    /*for (int i = 0; i < mx_v.size(); i++) {
      printf("mx[%d] = %d\n", i, mx_v[i]);
    }
    printf("mx = %d\n", mx);*/
    if (mx == 1) {
      if (is_straight()) {
	printf("straight\n");
	goto end;
      } else {
	printf("null\n");
	goto end;
      }
    } else if (mx == 2) {
      int c = 0;
      for (int i = 0; i < mx_v.size(); i++) {
	if (mx_v[i] == mx) {
	  c++;
	}
      }
      if (c >= 2) {
	printf("two pair\n");
	goto end;
      } else {
	printf("one pair\n");
	goto end;
      }
    } else if (mx == 3) {
      //printf("size = %d\n",mx_v.size());
      for (int i = 0;  i < mx_v.size(); i++) {
	if (mx_v[i] == 2) {
	  printf("full house\n");
	  goto end;
	}
      }
      printf("three card\n");
      goto end;
    } else if (mx == 4 || mx == 5) {
      printf("four card\n");
      goto end;
    } else {
      printf("null\n");
      goto end;
    }
  end:;
  }
}

Measured memory_bytes: 0
import java.util.Scanner;
    public class Main{
  public static void main(String[] args){
          Scanner scan = new Scanner(System.in);
          int num1 = scan.nextInt();
          int num2 = scan.nextInt();
          int num3 = scan.nextInt();
          if(num1<num2&&num2<num3){
            System.out.println(num1+" "+num2+" "+num3);
          }else if((num1==num2&&num2<num3)||(num2<num1&&num1<num3)){
            System.out.println(num2+" "+num1+" "+num3);
          }else if((num1==num2&&num2>num3)||(num3<num2&&num2<num1)){
            System.out.println(num3+" "+num2+" "+num1);
          }else if((num1==num3&&num3<num2)||(num3<num1&&num1<num2)){
            System.out.println(num3+" "+num1+" "+num2);
          }else if((num1==num3&&num3>num2)||(num2<num3&&num3<num1)){
            System.out.println(num2+" "+num3+" "+num1);
          }else if(num2==num3&&num3<num1){
            System.out.println(num2+" "+num3+" "+num1);
          }else if((num2==num3&&num3>num1)||(num1<num3&&num3<num2)||(num1==num2&&num2==num3)){
            System.out.println(num1+" "+num3+" "+num2);
          }
          scan.close();
}
}



Measured memory_bytes: 26256
object Main extends App {
	// your code goes here
	val strAry = io.StdIn.readLine().split(' ')
	val a = strAry(0).toInt
	val b = strAry(1).toInt
	((a & b) & 1) match {
		case 0 => println("Even")
		case 1 => println("Odd")
	}
}

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

typedef long long lint;
typedef long double louble;

template<typename T1,typename T2> inline T1 max(T1 a,T2 b){return a<b?b:a;}
template<typename T1,typename T2> inline T1 min(T1 a,T2 b){return a<b?a:b;}

const char lf = '\n';

namespace ae86
{
	const int bufl = 1<<15;

	char buf[bufl],*s=buf,*t=buf;

	inline int fetch()
	{
		if(s==t){t=(s=buf)+fread(buf,1,bufl,stdin);if(s==t)return EOF;}
		return *s++;
	}

	inline int ty()
	{
		int a=0,b=1,c=fetch();
		while(!isdigit(c))b^=c=='-',c=fetch();
		while(isdigit(c))a=a*10+c-48,c=fetch();
		return b?a:-a;
	}
}
using ae86::ty;

const int _ = 1007 , mo = 1000000007;

inline lint powa(lint a,lint t)
{
	lint b=1;
	while(t){if(t&1)b=b*a%mo;a=a*a%mo,t>>=1;}
	return b;
}

inline lint inva(lint a)
{
	return powa(a,mo-2);
}

lint jc[_],rjc[_];

inline void fuck(int n=_-1)
{
	jc[0]=jc[1]=rjc[0]=1;
	for(int i=2;i<=n;i++)jc[i]=jc[i-1]*i%mo;
	rjc[n]=inva(jc[n]);
	for(int i=n-1;i>=1;i--)rjc[i]=rjc[i+1]*(1ll+i)%mo;
}

inline lint C(int n,int m)
{
	if(n<m || n<0 || m<0)return 0;
	return jc[n]*rjc[m]%mo*rjc[n-m]%mo;
}

int n,m,val[_];
lint f[_][_]={0};

int main()
{
	ios::sync_with_stdio(0),cout.tie(nullptr);

	fuck();
	
	n=ty(),m=ty();
	for(int i=1;i<=m;i++)val[i]=ty();

	f[0][0]=1;
	for(int i=0;i<m;i++)
	{
		for(int j=0;j<=n;j++)
		{
			if(!f[i][j])continue;
			for(int k=0;k+j<=n && k<=val[i+1];k++)
				f[i+1][j+k]=(f[i+1][j+k]+f[i][j]*rjc[k]%mo*C(n-k,val[i+1]-k)%mo)%mo;
		}
	}
	lint ans=f[m][n]*jc[n]%mo;
	cout<<ans<<lf;
	
	return 0;
}


Measured memory_bytes: 384
#include <stdio.h>

int Array[500000];
int H;

void maxHeapify(int i){
    int left = 2*(i+1)-1;
    int right = 2*(i+1);
    int largest;
    if ( left <= H && Array[left] > Array[i])
        largest = left;
    else 
        largest = i;
    if ( right <= H && Array[right] > Array[largest])
        largest = right;

    if ( largest != i ){
        int temp = Array[i];
        Array[i] = Array[largest];
        Array[largest] = temp;
        maxHeapify(largest);
    }
}

int main(){
    scanf("%d\n",&H);
    for ( int ix = 0 ; ix < H ; ix++){
        if ( ix == H-1) scanf("%d\n",&Array[ix]);
        else scanf("%d ",&Array[ix]);
    }
    for ( int ix = (H/2)-1 ; ix >= 0 ; ix--)
        maxHeapify(ix);
    
    for ( int ix = 0 ; ix < H ; ix++)
        printf(" %d",Array[ix]);
    printf("\n");
    
    return 0;
}


Measured memory_bytes: 4544
#include <stdio.h>
int main()
{
int i, x, y;
for(i=0;i<3000;i++) {
     scanf("%d", &x);
     scanf("%d", &y);
     if(x==0 && y==0){
           break;
      }else if (x>y){
            printf("%d %d\n",y,x);
      }else{
            printf("%d %d\n",x,y);
      }
}
return 0;
}

Measured memory_bytes: 600
n=int(input())
v=list(map(int, input().split()))
even=[0]*(10**6 + 1)
odd=[0]*(10**6 + 1)



for i in range(n):
    if i%2==0:
        even[v[i]]+=1
    else:
        odd[v[i]]+=1

a=max(even)
M=even.index(a)
even[M]=0
a_second=max(even)
even[M]=a

b=max(odd)
N=odd.index(b)
odd[N]=0
b_second=max(odd)
odd[N]=b


if M!=N:
    ans=sum(even)-a + sum(odd)-b
    print(ans)
else:
    ans=min(sum(even)-a + sum(odd)-b_second, sum(even)-a_second + sum(odd)-b)
    print(ans)

Measured memory_bytes: 24804
package main

import (
	"fmt"
)

func main() {
	var sum int = 0
	var str string
	fmt.Scan(&str)
	for i, v := range []byte(str) {
		iplus := i + 1
		if (iplus < len(str) && v != str[iplus]) {
			sum++
		}
	}
	fmt.Println(sum)
}


Measured memory_bytes: 1408
#include<stdio.h>
#include<math.h>

struct Point {double x, y;};


void koch( int n, Point a, Point b){
  if(n == 0) return ;

  Point s, t, u;
  double th = M_PI * 60.0 / 180.0;

  s.x = (2.0 * a.x + 1.0 * b.x) / 3.0;
  s.y = (2.0 * a.y + 1.0 * b.y) / 3.0;
  t.x = (1.0 * a.x + 2.0 * b.x) / 3.0;
  t.y = (1.0 * a.y + 2.0 * b.y) / 3.0;
  u.x = (t.x - s.x) * cos(th) -  (t.y - s.y) * sin(th) + s.x;
  u.y = (t.x - s.x) * sin(th) +  (t.y - s.y) * cos(th) + s.y;

  koch(n-1, a, s);
  printf("%.8f %.8f\n", s.x, s.y);
  koch(n-1, s, u);
  printf("%.8f %.8f\n", u.x, u.y);
  koch(n-1, u, t);
  printf("%.8f %.8f\n", t.x, t.y);
  koch(n-1, t, b);
}

int main(){
  Point a, b;
  int n;

  scanf("%d", &n);

  a.x = 0;
  a.y = 0;
  b.x = 100;
  b.y = 0;

  printf("%.8f %.8f\n", a.x, a.y);
  koch(n, a, b);
  printf("%.8f %.8f\n", b.x, b.y);

  return 0;
}



Measured memory_bytes: 2680
#include <iostream>
#include <math.h>
#include <string>
#include <algorithm>

using namespace std;
int main()
{
    int a,b,c;
    cin>>a>>b>>c;
    if((a - b) >= c){
        cout<<"0";
    }
    else{
        cout<<c-(a-b);
    }


    return 0;
}

Measured memory_bytes: 3516
#include <stdio.h>
#include <iostream>
#include <cstdlib>
#include <iomanip>
#include <cmath>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdlib>
#include <limits>
#include <numeric>
#include <set>

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;

#define rep(i, N) for (int i = 0; i < N; i++)


int main()
{
	int n, sum, ans, temp1,temp2;
	sum = temp1 = temp2 = 0;
	ans = 100000;
	cin >> n;

	vi w(n);
	rep(i, n)cin >> w[i];
	for (int i = 0; i < n; i++) sum += w[i];

	for (int i = 1; i < n;i++) {
		temp1 = 0;
		for (int j = 0; j < i; j++)temp1 += w[j];
		if (abs((sum - temp1) - temp1) < ans)ans = abs((sum - temp1) - temp1);
	}

	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 768
#include <bits/stdc++.h>
#include <numeric>
typedef long long ll;
#define rep(i,a,b) for(int i=a;i<b;++i)
#define rrep(i,a,b) for(int i=a;i>=b;--i)
using namespace std;

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

    int N, M, C; cin >> N >> M >> C;
    vector<int> B(M);
    rep(i, 0, M) cin >> B[i];

    int res = 0;
    rep(i, 0, N) {
        int sum = C;
        rep(j, 0, M) {
            int a; cin >> a;
            sum += a*B[j];
        }
        if (sum > 0) ++res;
    }

    cout << res << endl;
}

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

int read(char);
void write(int, int);

int main() {
	int n, b;
	int x[4][13] = {};
	char a;
	cin >> n;

	for (int i = 0; i < n; i++) {
		cin >> a >> b;
		x[read(a)][b - 1] = 1;
	}

	for (int i = 0; i < 4; i++) {
		for (int j = 0; j < 13; j++) {
			if (x[i][j] == 0)	write(i, j);
		}
	}

	return 0;
}

int read(char c) {
	if		(c == 'S')	return 0;
	else if (c == 'H')	return 1;
	else if (c == 'C')	return 2;
	else if (c == 'D')	return 3;
}

void write(int i,int j) {
	if		(i == 0)	cout << 'S';
	else if (i == 1)	cout << 'H';
	else if (i == 2)	cout << 'C';
	else if (i == 3)	cout << 'D';

	cout << " " << j+1 << endl;
}

Measured memory_bytes: 1160
#include<cstdio>
#include<algorithm>
using namespace std;

int main(void){
	int t, i, n, k, j, length, a;
	scanf("%d", &t);
	for(i = 0;i < t;i++){
		scanf("%d %d", &n, &k);
		int x[n], d[n-1];
		for(j = 0;j < n;j++){
			scanf("%d", &x[j]);
			if(j)
				d[j-1] = x[j] - x[j-1];
		}
		sort(d, d + n - 1);
		reverse(d, d + n - 1);
		length = x[n-1] - x[0];
		a = min(k - 1, n - 1);
		for(j = 0;j < a;j++)
			length -= d[j];
		printf("%d\n", length);
	}
	return 0;
}

Measured memory_bytes: 3520
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
#define all(x) x.begin(),x.end()
#define rep(i,j,n) for (long long i = j; i < (long long)(n); i++)
#define _GLIBCXX_DEBUG
#define MOD 1000000007
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; }
//name[i][j]-> vvl name(i,vl(j))
//map<int,int>mp
//余りを切り上げる =>  (a + b - 1) / b 
vi vx={-1,0,1,0};
vi vy={0,1,0,-1};
using pi = pair<int,int>;

signed main(){
	int a,b; cin>>a>>b;
	vvi v(a,vi(b));
	queue<pi> q;
	rep(i,0,a){
		rep(j,0,b){
			char c; cin>>c;
			if(c=='#'){
				v[i][j]=1;
				q.push(make_pair(i,j));
			}
			else v[i][j]=0;
		}
	}
	while(!q.empty()){
		pi p=q.front(); q.pop();
		int k,l; tie(k,l)=p;
		bool ok=false;
		rep(i,0,4){
			k+=vx[i]; l+=vy[i];
			if(k>=0 && k<a){
				if(l>=0 && l<b){
					if(v[k][l]==1)ok=true;
				}
			}
			k-=vx[i]; l-=vy[i];
		}
		if(!ok){
			cout<<"No"<<endl;
			return 0;
		}
	}
	cout<<"Yes"<<endl;
	
	
	return 0;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define FOR(i, N) for (long i = 0; i < (N); i++)

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

    int N, K;

    cin >> N >> K;

    int count = 0;
    int h_i;
    FOR(i, N) {
        cin >> h_i;
        if (h_i >= K) {
            count++;
        }
    }

    cout << count << "\n";

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(void){
    int a,b,c;
    cin>>a>>b>>c;
    if(a==b+c||b==c+a||c==a+b){
        cout<<"Yes"<<endl;
    }
    else{
    cout<<"No"<<endl;
    }
}
    

Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <tuple>
#include <vector>

using namespace std;

#define rep(i, n) for (int64_t i = 0; i < (n); i++)
#define irep(i, n) for (int64_t i = 0; i <= (n); i++)
#define rrep(i, n) for (int64_t i = (n)-1; i >= 0; i--)
#define rirep(i, n) for (int64_t i = n; i >= 0; i--)

const int64_t MOD = 1'000'000'007L;

int64_t dpow(int64_t x, int64_t y)
{
    if (y == 0) {
        return 1;
    }
    if (y % 2 == 0) {
        return dpow(x * x % MOD, y / 2);
    } else {
        return x * dpow(x, y - 1) % MOD;
    }
}

int64_t inv(int64_t x)
{
    return dpow(x, MOD - 2);
}

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

    vector<int64_t> c(n);
    rep(i, n)
    {
        cin >> c[i];
    }
    sort(c.begin(), c.end());

    int64_t result = 0;
    rep(i, n)
    {
        result += (n - i + 1) * c[i] % MOD;
        result %= MOD;
    }
    cout << result * dpow(2, 2 * n - 2) % MOD << endl;

    return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define F first
#define S second
#define PB push_back
#define PF push_front
#define MP make_pair
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
const int maxn = 1e5 + 5;

int main(){
	ios_base::sync_with_stdio(false);
	string s;
	cin >> s;
	int tmp = 0;
	ll ans = 0;
	for (int i = 0; i < s.size(); i++){
		if (s[i] == 'B'){
			tmp ++;
		}
		else{
			ans += tmp;
		}
	}
	cout << ans << endl;
}


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

int main(){
    int x;
    cin >> x;
    
    int hh,mm,ss;
    
    hh = x / 60 / 60;
    mm = x / 60 % 60;
    ss = x % 60;
    
    cout << hh << ":" << mm << ":" << ss << endl;
}




Measured memory_bytes: 3072
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
using namespace std;

const int MAXN = 50000;
const int INF = 114514;

int main()
{
  int N, M;
  int coin[21];
  int dp[MAXN + 1];

  memset(dp, INF, sizeof(dp));
  dp[0] = 0;

  scanf("%d%d", &N, &M);
  for (int i = 0; i < M; i++) scanf("%d", &coin[i]);

  for (int i = 0; i < M; i++){
    for (int j = coin[i]; j <= N; j++){
      dp[j] = min(dp[j], dp[j - coin[i]] + 1);
    }
  }

  printf("%d\n", dp[N]);

  return (0);
}

Measured memory_bytes: 1392
#include <iostream>
#include <cmath>
#include <algorithm>
#include <utility>
#include <vector>
#include <string>

using namespace std;

char letter[] = {'.', ',', '!', '?', ' ', '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'};

char output(int b, int c)
{
    switch (b) {
    case 1:
        return letter[0 + (c % 5)];
        break;
    case 2:
        return letter[5 + (c % 3)];
        break;
    case 3:
        return letter[8 + (c % 3)];
        break;
    case 4:
        return letter[11 + (c % 3)];
        break;
    case 5:
        return letter[14 + (c % 3)];
        break;
    case 6:
        return letter[17 + (c % 3)];
        break;
    case 7:
        return letter[20 + (c % 4)];
        break;
    case 8:
        return letter[24 + (c % 3)];
        break;
    case 9:
        return letter[27 + (c % 4)];
        break;
    }
}

int main()
{
    int n;
    cin >> n;
    for (int cnt = 0; cnt < n; cnt++) {
        string str;
        cin >> str;
        int button = -1;
        int count = -1;
        for (char c : str) {
            if (c == '0') {
                if (button != -1) {
                    cout << output(button, count);
                }
                count = -1;
                button = -1;
            } else {
                button = c - '0';
                count++;
            }
        }
        cout << endl;
    }
    return 0;
}

Measured memory_bytes: 3052
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define per(i,a,b) for(int i=a;i>=b;i--)
#define rusha scanf("%d",&n);rep(i,1,n)scanf("%d",&a[i]);
#define rushb scanf("%d",&t);while(t--)
#define debug(x) cout<<" L-B-W-- "<<x<<" --N-B\n"
#define pb push_back
#define eb emplace_back
#define pii pair<int,int>
#define vii vector<int>
#define fi first
#define se second
#define mem(a,b) memset(a,b,sizeof a)
#define all(x) (x.begin(),x.end())
#define judgef printf("%s\n",f?"Yes":"No")
#define Judgef printf("%s\n",f?"YES":"NO")
#define sz(x) ((int)(x).size())
#define sf(x) (sizeof(x))
#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
using namespace std;
typedef long long ll;
typedef double db;
const double pai = acos(-1.0);
const double eps = 1e-8;
//const int mod=998244353;
const int mod=1e9+7;
const int inf=1e9+7;
//const ll inf=0x7f7f7f7f1234abcd;
const int maxn=1e5+10;
void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
	cerr << *it << " = " << a << endl;
	err(++it, args...);
}
inline ll ksm(ll x,ll y){ll res=1;while(y){if(y&1)res=res*x%mod;x=x*x%mod;y>>=1;}return res;}
inline ll inv(ll a,ll p){if(a==1)return 1;return (p-p/a)*inv(p%a,p)%p;}
inline ll lcm(ll a,ll b){return a * b / __gcd(a, b);}
int t,n,m,k;
int a[maxn];

int main()
{
    int a,b;
    scanf("%d%d",&a,&b);
    printf("%d\n",a*b);
    return 0;
}


Measured memory_bytes: 3824
package main

import (
	"fmt"
)

func main() {
	var n int
	fmt.Scan(&n)

	d := make([]int, n)
	for i := 0; i < n; i++ {
		fmt.Scan(&d[i])
	}

	m := make(map[int]bool)
	for _, v := range d {
		m[v] = true
	}

	fmt.Println(len(m))
}


Measured memory_bytes: 512
import java.io.*;
import java.util.*;


public class Main {
    int N;
    int[][] items;

    int solve() {
        if (N < 2) {
            int max = 0;
            for (int j = 0; j < 3; j++) {
                max = Math.max(max, items[0][j]);
            }
            return max;
        }

        int max = 0;
        for (int i = 1; i < N; i++) {
            for (int j = 0; j < 3; j++) {
                int m = 0;
                for (int col = 0; col < 3; col++) {
                    if (j != col) {
                        m = Math.max(m, items[i-1][col]);
                    }
                }
                items[i][j] += m;
                max = Math.max(max, items[i][j]);
            }
        }
        return max;
    }

    void main(FastScanner in, PrintWriter out) {
        N = in.nextInt();
        items = new int[N][3];

        for (int i = 0; i < N; i++) {
            items[i][0] = in.nextInt();
            items[i][1] = in.nextInt();
            items[i][2] = in.nextInt();
        }
        out.println( solve() );
    }

    public static void main(String[] args) throws Exception {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        FastScanner in = new FastScanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        Main m = new Main();
        m.main(in, out);
        out.close();
        in.close();
    }

    static class FastScanner {
        BufferedReader br;
        StringTokenizer st;
        public FastScanner(InputStream in) { br = new BufferedReader(new InputStreamReader(in)); }
        public int nextInt() { return Integer.parseInt(next()); }
        public long nextLong() { return Long.parseLong(next()); }
        public double nextDouble() { return Double.parseDouble(next()); }
        public String next() {
            while (st == null || !st.hasMoreTokens()) {
                try { st = new StringTokenizer(br.readLine()); }
                catch (IOException e) { e.printStackTrace(); }
            }
            return st.nextToken();
        }
        public String nextLine() {
            String str = "";
            try { str = br.readLine();
            } catch (IOException e) { e.printStackTrace(); }
            return str;
        }
        public void close() throws IOException { br.close(); }
    }
}

Measured memory_bytes: 44492
# include <bits/stdc++.h>
# define int long long
# define endl "\n"
using namespace std;

void solve() {

	string s;
	cin >> s;
	if (s == "RRS" || s == "SRR") {
		cout << 2 << endl;
	}
	else if (s == "RRR") {
		cout << 3 << endl;
	}
	else if (s == "SSS") {
		cout << 0 << endl;
	}
	else {
		cout << 1 << endl;
	}
}
signed main() {

	ios_base::sync_with_stdio(0);
	cin.tie(0);

# ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
# endif

	// int t;
	// cin >> t;
	// while (t--)
	solve();

	return 0;
}

Measured memory_bytes: 3612
#define _USE_MATH_DEFINES
#define INF 100000000

#include <iostream>
#include <sstream>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <queue>
#include <stack>
#include <limits>
#include <map>
#include <string>
#include <cstring>
#include <set>
#include <deque>
#include <bitset>
#include <list>
#include <cctype>
#include <utility>

using namespace std;

typedef long long ll;
typedef pair <int,int> P;
typedef pair <int,P> PP;

static const double EPS = 1e-8;

int stage[50][50];

void dfs(int x,int y,int w,int h){
	stage[y][x] = 0;
	for(int tx=-1;tx<=1;tx++){
		for(int ty=-1;ty<=1;ty++){
			int dx = x + tx;
			int dy = y + ty;
			if(dx < 0 || dx >=w || dy < 0 || dy >= h) continue;

			if(stage[dy][dx]==1){
				dfs(x+tx,y+ty,w,h);
			}
		}
	}
}

int main(){
	int w,h;
	while(~scanf("%d %d",&w,&h)){
		if(w==h && h==0) break;
		for(int y=0;y<h;y++){
			for(int x=0;x<w;x++){
				scanf("%d",(*(stage+y)+x));
			}
		}

		int res=0;
		for(int y=0;y<h;y++){
			for(int x=0;x<w;x++){
				if(stage[y][x]==1){
					dfs(x,y,w,h);
					res++;
				}
			}
		}

		printf("%d\n",res);
	}
}

Measured memory_bytes: 0
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;

namespace AtCoder
{
	public class Program
	{
		//static int[] parent;
		static void Main(string[] args)
		{
			int[] input = Console.ReadLine().Split().Select(p => int.Parse(p)).ToArray();
			int N = input[0];
			int K = input[1];

			// 出目が iの時に勝つ確率 = i * 2^? >= K になるまで表が出続ける
			decimal ret = 0;
			for(int i=1; i<=N; i++)
			{
				// 出目がi
				decimal win = 1;
				win /= (decimal)N;
				int p = i;
				//Console.WriteLine(p + " が出た時 " + win);
				while(p < K)
				{
					win /= 2M;
					p *= 2;
					//Console.WriteLine("面が出たら " + p + " 点 " + win);
				}
				ret += win;
			}

			Console.WriteLine(ret + "") ;
		}
	}
}


Measured memory_bytes: 13268