akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
using namespace std;

int main() {
  int N, A, B, t, s, tmp;
  cin >> N >> A >> B;
  for (int i = 1; i <= N; i++) {
    tmp = i;
    t = 0;
    while (tmp >= 10) {
      t += tmp % 10;
      tmp /= 10;
    }
    t += tmp;
    if (t >= A && t <= B) {
      s += i;
    }
  }
  cout << s << endl;
  return 0;
}

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

int main() {
    int n;
    cin >> n;
    vector<int> h(n);
    rep(i, n) cin >> h[i];

    --h[0];
    for (int i = 1; i < n; ++i) {
        if (h[i] - 1 >= h[i - 1])
            --h[i];
        if (h[i] < h[i - 1]) {
            cout << "No" << endl;
            return 0;
        }
    }

    cout << "Yes" << endl;

    return 0;
}

Measured memory_bytes: 640
import bisect
import sys
input = sys.stdin.readline

INF = float('INF')

a, b, q = map(int, input().split())
S = [-INF] + [int(input()) for _ in range(a)] + [INF]
T = [-INF] + [int(input()) for _ in range(b)] + [INF]
X = [int(input()) for _ in range(q)]

ans = []
for x in X:
    S_idx = bisect.bisect_left(S, x)
    T_idx = bisect.bisect_left(T, x)

    s_left, s_right = S[S_idx-1], S[S_idx]
    t_left, t_right = T[T_idx-1], T[T_idx]
    pathA = x - min(s_left, t_left)
    pathB = max(s_right, t_right) - x
    pathC = min(x-s_left, t_right-x) + t_right - s_left
    pathD = min(x-t_left, s_right-x) + s_right - t_left
    ans.append(str(min(pathA, pathB, pathC, pathD)))

print('\n'.join(ans))

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

using namespace std;

int main() {
    int x1, x2, x3, y1, y2;
    cin >> x1 >> x2 >> x3 >> y1 >> y2;

    int ans = min({x1, x2, x3}) + min(y1, y2) - 50;
    cout << ans << endl;
    return 0;
}



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



int main(){
	ll N;
	cin >> N;
	ll K;
	cin >> K;
	ll ans=0;
	vector<ll> h(N,0);
	for(ll i=0;i<N;i++){
		cin>>h[i]
	;}
	for(ll i=0;i<N;i++){
		if(h[i]>=K){ans++;}
	;}
	cout<<ans<<endl;

return 0;
}  



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

int main(){
    long long N;
    cin >> N;
    long long A[N];
    long long B[N];

    for (int i = 0; i < N; i ++){
        B[i] = 0;
    }

    for (int i = 0; i < N; i ++){
        cin >> A[i];
        B[A[i] - 1]++;
    }

    long long tmp = 0;

    for (int i = 0; i < N; i ++){
        if (B[i] != 0){
            tmp += (B[i] * (B[i] - 1)) / 2;
        }
    }

    for (int k = 1; k <= N; k++){
        long long ans = 0;
        long long tmp2 = 0;

        tmp2 = B[A[k - 1] - 1] - 1;
        ans = tmp - tmp2;
        cout << ans << endl;
    }
}


Measured memory_bytes: 5760
#include<bits/stdc++.h>
using namespace std;
int main(){
  long N,M;cin>>N>>M;
  vector<pair<long,long>> a(N);
  for(int i=0;i<N;i++)cin>>a.at(i).first>>a.at(i).second;
  sort(a.begin(),a.end());
  
  long ans=0,count=0;
  for(int i=0;i<N;i++){
    if(count+a.at(i).second<M){
      ans+=a.at(i).first*a.at(i).second;
      count+=a.at(i).second;
    }
    else{
      ans+=a.at(i).first*(M-count);
      break;
    }
  }
  cout<<ans<<endl;
}

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

int main(){

    while(true){
        std::string s;
        std::cin >> s;

        if(s == "-") break;

        size_t m;
        std::cin >> m;

        for(size_t i = 0; i < m; i++){
            size_t h;
            std::cin >> h;

            std::string tmp;

            tmp += s.substr(h);
            tmp += s.substr(0, h);

            s = std::move(tmp);
        }

        std::cout << s << std::endl;
    }

    return 0;
}



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

void solve(){
	string str;
	cin >> str;
	if(str[2] == str[3] && str[4] == str[5]){
		cout << "Yes" << "\n";
	}
	else{
		cout << "No" << "\n";
	}
}

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	solve();	
}

Measured memory_bytes: 3652
import java.util.Scanner;

// ALDS1_2_A
public class Main {
	void bubbleSort(int[] array, int n) {
		boolean flag = true;
		int tmp, count = 0;
		while (flag) {
			flag = false;
			for (int j = n - 1; j > 0; j--) {
				if (array[j] < array[j-1]) {
					tmp = array[j]; array[j] = array[j-1]; array[j-1] = tmp;
					count++;
					flag = true;
				}
			}
		}
		for (int i = 0; i < n; i++) {
			System.out.print(array[i]);
			if (i < n - 1) System.out.print(" ");;
		}
		System.out.println();
		System.out.println(count);
	}
	
	void run() {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] array = new int[n];
		for (int i = 0; i < n; i++) {
			array[i] = sc.nextInt();
		}
		bubbleSort(array, n);
	}

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


Measured memory_bytes: 26540
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll n,x,ans;

int main()
{
	scanf("%lld%lld",&n,&x);
	n-=x; ans+=n+x;
	while(n%x)
	{
		ans+=(n/x)*2*x;
		n=n%x; swap(n,x);
	}
	ans+=(n/x-1)*2*x+x;
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 256
import java.util.*;
//import java.lang.Math;
public class Main{

    public static int ten[]={1,10,100,1000,10000,100000,1000000,10000000};

    public static int digit(int N,int K){
        return (N/ten[7-K])%10;
    }
    public static void main(String[] args){
        Scanner sc=new Scanner(System.in);
        Map<Integer,Integer> pz=new HashMap<Integer,Integer>();
        Map<Integer,Boolean> reach=new HashMap<Integer,Boolean>();
        pz.put(1234567,0);
        reach.put(1234567,true);
        Queue<Integer> q=new ArrayDeque<Integer>();
        q.add(1234567);
        while(q.size()>0){
            int now=q.poll();
            int dis=pz.get(now);
            int cnt=0;
            for(int i=0;i<10;i++){
                int p=now;
                if(i<3 ||(i>=4 && i<=6)){
                    int a=digit(p,i);
                    int b=digit(p,i+1);
                    if(a!=0 && b!=0) continue;
                    int minus=a*ten[7-i]+b*ten[7-i-1];
                    p-=minus;
                    p+=b*ten[7-i]+a*ten[7-i-1];
                    if(reach.containsKey(p)) continue;
                    else{
                        pz.put(p,dis+1);
                        reach.put(p,true);
                        q.add(p);
                    }
                }
                else{
                    int a=digit(p,cnt);
                    int b=digit(p,cnt+4);
                    int s=cnt;
                    cnt++;
                    if(a!=0 && b!=0) continue;
                    int minus=a*ten[7-s]+b*ten[7-s-4];
                    p-=minus;
                    p+=b*ten[7-s]+a*ten[7-s-4];
                    if(reach.containsKey(p)) continue;
                    else{
                        pz.put(p,dis+1);
                        reach.put(p,true);
                        q.add(p);
                    }
                }
            }
        }
        while(sc.hasNext()){
            int N=0;
            for(int i=0;i<8;i++){
                int a=sc.nextInt();
                N+=a*ten[7-i];
            }
            System.out.println(pz.get(N));
        }
    }
}


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

int main() {
	int a, b, c;
	while (cin >> a >> b >> c, a | b | c) {
		int d;
		cin >> d;
		vector<int>s(a+b+c,2);
		vector<vector<int>>e(d);
		for (int f = 0; f < d; f++) {
			vector<int>g(4);
			for (int h = 0; h < 4; h++)cin >> g[h];
			e[f] = g;
		}
		for (int i = 0; i < d; i++) {
			if (e[i][3]) { s[e[i][0]-1] = 1;s[e[i][1]-1] = 1;s[e[i][2]-1] = 1; }
		}
		for (int i = 0; i < d; i++) {
			if (s[e[i][0] - 1] == 1 && s[e[i][1] - 1] == 1 && s[e[i][2] - 1] != 1 && e[i][3] == 0)s[e[i][2] - 1] = 0;
			else if (s[e[i][0] - 1] == 1 && s[e[i][2] - 1] == 1 && s[e[i][1] - 1] != 1 && e[i][3] == 0)s[e[i][1] - 1] = 0;
			else if (s[e[i][1] - 1] == 1 && s[e[i][2] - 1] == 1 && s[e[i][0] - 1] != 1 && e[i][3] == 0)s[e[i][0] - 1] = 0;
		}
		for (int x : s) {
			cout << x << endl;
		}
	}
}

Measured memory_bytes: 3176
import java.util.Scanner;

class Main {

    private static Scanner sc = new Scanner(System.in);

    public static void main(String[] args) {
        int n = sc.nextInt();
        int m = 0, a = 0, r = 0, c = 0, h = 0;
        for (int i = 0; i < n; i++) {
            char ch = sc.next().charAt(0);
            if (ch == 'M') {
                m++;
            } else if (ch == 'A') {
                a++;
            } else if (ch == 'R') {
                r++;
            } else if (ch == 'C') {
                c++;
            } else if (ch == 'H') {
                h++;
            }
        }
        long count = ((long) m * a * r) + ((long) m * a * c) + ((long) m * a * h)
                     + ((long) m * r * c) + ((long) m * r * h) + ((long) m * c * h)
                     + ((long) a * r * c) + ((long) a * r * h) + ((long) a * c * h)
                     + ((long) r * c * h);
        System.out.println(count);
    }
}


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

const int MOD = 1000000007;
const int MAX_N = 101010;

ll fac[MAX_N], finv[MAX_N], inv[MAX_N];

void init(int n) {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i <= n; i++) {
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

ll COM(int n, int k) {
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int main() {
    int n, k;
    cin >> n >> k;
    init(n);
    ll a[n], b[n];
    for (int i = 0; i < n; i++) {
        cin >> a[i];
        b[i] = a[i];
    }
    sort(a, a + n);
    sort(b, b + n);
    ll ans = 0;
    for (int i = 0; i < n; i++) {
        a[i] *= COM(i, k - 1);
        a[i] %= MOD;
        b[i] *= COM((n - 1 - i), k - 1);
        b[i] %= MOD;
        ans += a[i];
        ans %= MOD;
        ans -= b[i];
        while (ans < 0) ans += MOD;
    }
    cout << ans << endl;
}

Measured memory_bytes: 4096
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <stdint.h> // uint64_t

#define max(a,b) ((a) > (b) ? (a) : (b))
#define min(a,b) ((a) > (b) ? (b) : (a))

int64_t get_int(void) {
  int64_t num;
  scanf("%lld", &num);
  return num;
}

int get_int2(int *a1, int *a2) {
  scanf("%d.%d", a1, a2);
  return 0;
}

int main(void) {
    int64_t num = get_int();
    int i, f;
    get_int2(&i, &f);
    int64_t ans = num * ((i*100)+f);
    printf("%lld\n", ans/100);
}


Measured memory_bytes: 1724
#include <bits/stdc++.h>
#define ALL(a)  (a).begin(),(a).end()
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef pair<long long, long long> Pll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<long long> vll;
typedef vector<vector<long long>> vvll;
template <typename T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template <typename T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const long long INF = 1LL << 60;
const int INT_INF = 1 << 30;
#define MOD 1000000007LL
#define endl "\n"

int main(){
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  ll K, A, B;
  cin >> K >> A >> B;
  bool ok = false;
  for(int i = A; i <= B; i++){
    if(i % K == 0) ok = true;
  }
  if(ok) cout << "OK" << endl;
  else cout << "NG" << endl;
}

Measured memory_bytes: 3652
import java.util.*;
 
public class Main {
 	public static void main(String[] args){
    	
    	Scanner sc = new Scanner(System.in);
    	int [][] c = new int [3][3];
    	
    	for(int i=0; i<3; i++){
    	    for(int j =0; j<3; j++){
    	        c[i][j] = sc.nextInt();
    	    }
    	}
    	
    	int a1 =0;
    	
    	int b1 = c[0][0] - a1;
    	int b2 = c[0][1] - a1;
    	int b3 = c[0][2] - a1;
    	int a2 = c[1][0] - b1;
    	int a3 = c[2][0] - b1;
    	
    	if(a2+b2 == c[1][1] && a2 + b3 == c[1][2] && a3 + b2 == c[2][1] && a3 + b3 ==c[2][2]){
    	    System.out.println("Yes");
    	}
    	
    	else{
    	    System.out.println("No");
    	}
    }
}

Measured memory_bytes: 23376
import sys
import itertools
input = sys.stdin.readline
sys.setrecursionlimit(100000)


def read_values():
    return map(int, input().split())


def read_index():
    return map(lambda x: x - 1, map(int, input().split()))


def read_list():
    return list(read_values())


def read_lists(N):
    return [read_list() for n in range(N)]


def functional(N, mod):
    F = [1] * (N + 1)
    for i in range(N):
        F[i + 1] = (i + 1) * F[i] % mod
    return F


def main():
    A = []
    for _ in range(3):
        a = read_list()
        A.extend(a)
    N = int(input())
    B = [False] * 9
    for _ in range(N):
        b = int(input())
        if b in A:
            c = A.index(b)
            B[c] = True

    if ((B[0] and B[1] and B[2]) or
        (B[3] and B[4] and B[5]) or
        (B[6] and B[7] and B[8]) or 
        (B[0] and B[3] and B[6]) or
        (B[1] and B[4] and B[7]) or
        (B[2] and B[5] and B[8]) or
        (B[0] and B[4] and B[8]) or
        (B[2] and B[4] and B[6])):
        print("Yes")
    else:
        print("No")


if __name__ == "__main__":
    main()

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

using namespace std;

int main()
{
	int n, c;
	cin>>c>>n;
	int a;
	string ans="No";
	while(n--)
	{
		cin>>a;
		c -= a;
	}
	if(c<=0) ans="Yes";
	cout<<ans<<endl;
	return 0;
}

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

const ll INF64 = 1LL << 60;
const int INF32 = 1 << 29;
const ll MOD = 1000000007;


int main(){
	ll k; cin >> k;
	ll n = 50;
	ll div = k/n;
	ll rem = k%n;
	vector<ll> a(n);
	for(ll i = 0; i < n; ++i){
		a[i] = n-1+ div - rem;
    }
    
    for(ll i = 0; i < rem; ++i){
		a[i] += n+1;
    }
	cout << n << endl;
	for(ll i = 0; i < n-1; ++i){
		cout << a[i] << " ";
    }
    cout << a[n-1] << endl;
    
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
using namespace std;
const int SIZE = 10000;
int main (int argc, char *argv[]) {
	// make sieve
	vector<bool> sieve(SIZE,true);
	sieve[0] = false; sieve[1] = false;
	for(int i = 2; i < SIZE; ++i) {
		if (sieve[i]) {
			for(int j = i+i; j < SIZE; j+=i) {
				sieve[j] = false;
			}
		}
	}
	// count p
	int N;
	while (cin >> N) {
		vector<int> inc(N), dec(N);
		for (int i=0;i<N;i++) {
			inc[i] = i+1;
			dec[i] = N-i;
		}
		int count = 0;
		for(int i = 0; i < N; ++i) {
			if (sieve[inc[i]] && sieve[dec[i]]) count++;
		}
		cout << count << endl;
	}
	return 0;
}

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

using namespace std;

bool solve(){
    int n;
    cin>>n;
    if(n==0)return false;
    int ans=0;
    for (int k = 2; k <= 100; ++k) {
        for (int i = 1; i < 1000; ++i) {
            int t=(i+(i+k-1))*k/2;
            if(t==n)++ans;
        }
    }
    cout<<ans<<endl;

    return true;
}

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


Measured memory_bytes: 3068
#include <algorithm>
#include <iostream>
#include <math.h>
#include <stdio.h>
#include <string>
#include <sstream>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#include <queue>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
using namespace std;

int main()
{
	int c11,c12,c13;
	int c21,c22,c23;
	int c31,c32,c33;
	cin>>c11>>c12>>c13;
	cin>>c21>>c22>>c23;
	cin>>c31>>c32>>c33;
	bool answer = false;
	if( (2*c11-(c12+c13)) == (2*c21-(c22+c23)) && (2*c11-(c12+c13)) == (2*c31 - (c32+c33))){
		if( (2*c11 - (c21+c31)) == (2*c12-(c22+c32)) &&  (2*c11 - (c21+c31)) == (2*c13 - (c23 + c33))){
			answer = true;
		}
	}
	if(answer == true){
		cout<<"Yes"<<endl;
	}else{
		cout<<"No"<<endl;
	}
	return 0;
}



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

#define Fast ios_base::sync_with_stdio(0);cin.tie(0),cout.tie(0)
#define FO freopen("in.txt", "r", stdin)
#define FC freopen("out.txt", "w", stdout)
#define aise cout<<"aise"<<endl
#define pb push_back
#define mp make_pair
#define ll long long
#define mset(v, a) memset(v, a, sizeof(v))
#define pll pair< ll, ll >
#define pdd pair< double, double >
#define ff first
#define ss second
#define pi acos(-1.0)
#define mxN 2097162
#define inf 1e9
#define MOD 1000000007

int main()
{


    double x, y;
    cin >> x;
    y = x/3.0;
    printf("%.10lf\n", y*y*y);
}


Measured memory_bytes: 384
#include "bits/stdc++.h"

#define REP(i,n) for(ll i=0;i<ll(n);++i)
#define RREP(i,n) for(ll i=ll(n)-1;i>=0;--i)
#define FOR(i,m,n) for(ll i=m;i<ll(n);++i)
#define RFOR(i,m,n) for(ll i=ll(n)-1;i>=ll(m);--i)
#define ALL(v) (v).begin(),(v).end()
#define UNIQUE(v) v.erase(unique(ALL(v)),v.end());
#define DUMP(v) REP(aa, (v).size()) { cout << v[aa]; if (aa != v.size() - 1)cout << " "; else cout << endl; }
#define INF 1000000001ll
#define MOD 1000000007ll
#define EPS 1e-9

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


using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
ll max(ll a, int b) { return max(a, ll(b)); }
ll max(int a, ll b) { return max(ll(a), b); }
ll min(ll a, int b) { return min(a, ll(b)); }
ll min(int a, ll b) { return min(ll(a), b); }
///(´・ω・`)(´・ω・`)(´・ω・`)(´・ω・`)(´・ω・`)(´・ω・`)///


int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;
	cin >> n;
	vi a(n);
	int cnt = 0;
	REP(i, n) {
		cin >> a[i];
		cnt += a[i] % 2;
	}
	cout << pow(3, n) - pow(2, n - cnt) << endl;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  for(int i=0;i<(n);++i)
#define REPr(i,n) for(int i=(n)-1;i>=0; --i)
#define FORq(i, m, n) for(int i = (m);i <= (n);++i)
#define FORqr(i, m , n) for(int i = (n);i >=(m);--i)
#define SCD(n) scanf("%d",&n)
#define SCD2(m,n) scanf("%d%d",&m,&n)
#define SCD3(m,n,k) scanf("%d%d%d",&m,&n,&k)
#define SCLLD(n) scanf("%lld",&n)
#define SCLLD2(m,n) scanf("%lld%lld",&m,&n)
#define SCLLD3(m,n,k) scanf("%lld%lld%lld",&m,&n,&k)
#define PB push_back
#define MP make_pair
#define ARSCD(A,N) REP(i,N){SCD(A[i]);}
#define ARSCD1(A,N) FORq(i,1,N){SCD(A[i]);}
#define VSCD(v,N) REP(i,N){int (x); SCD(x); v.PB(x);}
#define VSCLLD(v,N) REP(i,N){long long (x); SCLLD(x); v.PB(x);}
#define PRINTD(n) printf("%d\n",n)
#define PRINTLLD(n) printf("%lld\n",n)
#define DEBUG printf("%s\n","debug")
#define fst first
#define snd second
#define SIN(x,S) (S.count(x) != 0)
#define M0(x) memset(x,0,sizeof(x))
#define FILL(x,y) memset(x,y,sizeof(x))
#define MM(x) memset(x,-1,sizeof(x))
#define ALL(x) (x).begin(),(x).end()
using namespace std;
typedef pair<int,int> PII;
typedef pair<long long,long long> PLL;
typedef vector<int> VI;
typedef vector < VI > VVI;
typedef vector<long long> VL;
typedef long long ll;
typedef long long integer;
///////////////////////////////////////////////
const ll MOD = 1000000007;
ll gcd(ll x,ll y){return y?gcd(y,x%y):x;}

template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
///////////////////////////////////////////////
int N;
map<ll, map<string,ll> > f;

bool chk(string last){
    REP(i,4){
        string con = last;
        if (i != 3) swap(con[i],con[i+1]);
        if (con.find("AGC") != string::npos){
            return false;
        }
    }

    return true;
}


ll dfs(ll depth,string last){
    if (f[depth][last] != 0) return f[depth][last];
    if (depth == N) return 1;
    ll ret = 0;
    string C[4] = {"A","C","G","T"};

    REP(i,4){
        if (chk(last + C[i])){
            string next = last.substr(1,2) + C[i];
            ret = ret + dfs(depth+1,next) % MOD;
        }
    }

    f[depth][last] = ret;
    return ret;

}
/*（๑•﹏•๑｀) */
int main() {

    cin >> N;
    // 'A' = 0
    // 'C' = 1
    // 'G' = 2
    // 'T' = 3

    dfs(0,"TTT");
    cout << f[0]["TTT"] % MOD << "\n";


}


Measured memory_bytes: 896
#include <stdio.h>

int main(){
  char str1[11], str2[11], str3[11];
  scanf("%s%s%s", str1, str2, str3);
  str1[0]=str1[0]-32;
  str2[0]=str2[0]-32;
  str3[0]=str3[0]-32;
  printf("%c%c%c\n", str1[0], str2[0], str3[0]);
  return 0;
}


Measured memory_bytes: 128
#include <stdio.h>

int n;
int m[101][101];

int Lookup_Chain(int *r, int *c, int i, int j)
{
    int m_min;
    int min = 1000000;
    if (m[i][j] == 1000000)
    {
        if (i == j)
        {
            m[i][j] = 0;
        }
        else
        {
            for (int k = i; k < j; k++)
            {
                m_min = Lookup_Chain(r, c, i, k) + Lookup_Chain(r, c, k + 1, j) + r[i] * c[k] * c[j];
                if (m_min < min)
                {
                    min = m_min;
                }
            }
            m[i][j] = min;
        }
    }
    return m[i][j];
}

int Memorized_Matrix_Chain(int n, int *r, int *c)
{
    for (int i = 1; i <= n; i++)
    {
        for (int j = i; j <= n; j++)
        {
            m[i][j] = 1000000;
        }
    }
    return Lookup_Chain(r, c, 1, n);
}

int main(void)
{
    int r[101], c[101];

    scanf("%d", &n);
    for (int i = 1; i <= n; i++)
    {
        scanf("%d %d", &r[i], &c[i]);
    }

    printf("%d\n", Memorized_Matrix_Chain(n, r, c));

    return 0;
}


Measured memory_bytes: 2132
import java.util.*;
 
public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int T = sc.nextInt();
        int t[] = new int[N];
        int total =  0;
        for (int i = 0; i < N; ++i){
            t[i] = sc.nextInt();
        }
        for (int i = 0; i < N-1; ++i){
            total += Math.min(T,t[i+1]-t[i]);
        }
        
        total += T; 
        
        System.out.println(total);
        
    }
}

Measured memory_bytes: 58364
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <cmath>
#include <cstring>
#include <string>

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define FFOR(i,a,b) for(int i=(a);i<=(b);i++)
#define REP(i,b) FOR(i,0,b)
#define RREP(i,b) FFOR(i,1,b)
#define PB push_back
#define F first
#define S second
#define BE(c) c.begin(),c.end()
using namespace std;
typedef long long LL;
typedef LL ut;
typedef long double ld;
typedef pair<ut,ut> pr;
typedef vector<pr> Vpr;
typedef vector<ut> VI;
typedef pair<ut,pr> ppr;
typedef priority_queue<pr,Vpr, greater<pr> > PQ;
const int SIZE=5+3*1e+4;
const ut INF=1<<30;
const ld eps=1e-6;
const LL p=7+1e+9;

int main(){
  int n;
  while(cin >> n && n){
    int k[n], ans = 0;
    bool ok = false;
    REP(i,n){
      cin >> k[i];
      if(k[i] >= 2){
        ok = true;
      }
      if(k[i] >= 1)
        ans++;
    }
    if(!ok){
      cout << "NA" << endl;
      continue;
    }
    else{
      cout << ans + 1 << endl;
    }
  }
  return 0;
}

Measured memory_bytes: 1200
#include<bits/stdc++.h>
using namespace std;
 
int main()
{
  int a,b,c;
  cin>>a>>b;
  if(a==1&&b==2)
    cout<<3;
   else if(a==1&&b==3)
    cout<<2;  
   else if(a==2&&b==1)
	cout<<3;
   else if(a==2&&b==3)
     cout<<1;
   else if(a==3&&b==2)
     cout<<1;
  else if(a==3&&b==1)
    cout<<2;
}

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

using namespace std;

#define SZ(v) ((int)(v).size())
#define ALL(v) (v).begin(),(v).end()
#define one first
#define two second
using ll = long long;
using pi = pair<int, int>;
const int INF = 0x3f3f3f3f;
const ll LINF = 1ll * INF * INF;

int main() {
	int w, a, b; cin >> w >> a >> b;
	if(a > b) swap(a, b);
	cout << max(0, b-(a+w)) << endl;
	return 0;
}


Measured memory_bytes: 256
/*
ID: rchalam1
LANG: C++14
TASK:
*/
// For train.usaco.org, fill the template above.

// Competitive Coding Template

// GCC OPTIMIAZTION FLAGS
#ifdef ONLINE_JUDGE
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
#endif

#include <bits/stdc++.h>

/*
#include <fstream>
#include <iostream>
#include <string>
#include <vector>
*/
// All Includes for Competitive Coding Template

using namespace std;

using ll = long long;
using ull = unsigned long long;
using ld = long double;

using vi = std::vector<int>;
using vll = std::vector<long long>;
using vull = std::vector<unsigned long long>;

#define FOR(i, a, b) for (auto i = (a); i < (b); ++i)
#define F0R(i, a) FOR(i, 0, a)
#define ROF(i, a, b) for (auto i = (a); i >= (b); --i)
#define R0F(i, a) ROF(i, a, 0)
#define ITR(a, x) for (auto& a: x)

#define FSRT(set) sort((set).begin(),(set).end())
#define RSRT(set) sort((set).rbegin(),(set).rend())
#define CSRT(set, function) sort((set).begin(),(set).end(), (function))
#define TRS(set) sort((set).begin(),(set).end(), greater<>())
#define REV(set) reverse((set).begin(),(set).end());

#define ALL(set) (set).begin(), (set).end()

#define mp make_pair
#define mt make_tuple
#define pb push_back
#define eb emplace_back
#define ff first
#define ss second

// For stdio, call setIO() or setIO("").
void setIO(std::ifstream &readFile, std::ofstream &writeFile, const std::string &name = "", bool stdIO = false)
{
	std::ios_base::sync_with_stdio(false);
	std::cin.tie(nullptr);
	std::cout.tie(nullptr);
	if(!name.empty() && !stdIO)
	{
		readFile.open(name + ".in");
		if(readFile.fail()) return;
		writeFile.open(name + ".out");
		std::cin.rdbuf(readFile.rdbuf());
		std::cout.rdbuf(writeFile.rdbuf());
	}
}

// To time program, create object Timer  to start timing, and call Timer.elapsed().
#include <chrono>

class Timer
{
	std::chrono::time_point<std::chrono::high_resolution_clock> m_beg;
public:
	Timer() : m_beg(std::chrono::high_resolution_clock::now())
	{}

	void reset()
	{ m_beg = std::chrono::high_resolution_clock::now(); }

	[[nodiscard]] long double elapsed() const
	{
		return std::chrono::duration_cast<std::chrono::duration<long double, std::ratio<1> >>(
				std::chrono::high_resolution_clock::now() - m_beg).count();
	}
};

// Defines datatype
using dt = int;
// Defines MAXN value
constexpr dt MAXN = 1e5 + 1;
// Defines Modulus
constexpr dt MOD = 1e9 + 7;
// Defines Floating Point Correction
constexpr long double EPS = 1e-9;

//*****
//START CODE BELOW
//*****

int main(int argc, char *argv[])
{
	static std::ifstream readFile;
	static std::ofstream writeFile;
	setIO(readFile, writeFile);
	map<string, int> net;
	int n;
	cin >> n;
	while(n--)
	{
		string s;
		cin >> s;
		++net[s];
	}
	int m;
	cin >> m;
	while(m--)
	{
		string s;
		cin >> s;
		--net[s];
	}
	int answer = 0;
	for(auto &values : net) answer = max(answer, values.ss);
	cout << answer << '\n';
}

Measured memory_bytes: 3588
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <cfloat>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <queue>
#include <sstream>
#include <stack>
#include <time.h>
#include <vector>
#include <complex>
#include <map>
#include <set>
#include <iomanip>
#include <math.h>
#include <stdlib.h>
#include <list>
#include <utility>
#include <memory>
#include <cstring>
#include <fstream>
#include <numeric>
#include <assert.h>
#include <bits/stdc++.h>
using namespace std;
int div(int x){
	int num=0;
	for (int i=1;i<=x;i++)
		if (x%i==0)
			num++;
	return num;
}
int main(){
	int n,ans=0;
	cin>>n;
	for (int i=1;i<=n;i++)
		if (i%2==1)
			if (div(i)==8)
				ans++; 
	cout<<ans;
	return 0;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
#define  ft  ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define  ll  long long
string s,p;
int main()
{
    ft
    ll t,i,j,n,m=0,l,r;
    cin>>s;
    n=s.size();
    for(i=0;i<n;i++)
    {
        if((i+1)<n && s[i]==s[i+1])
        {
            cout<<(i+1)<<" "<<(i+2)<<"\n";
            return 0;
        }
        else if(((i+2)<n && s[i]==s[i+2]))
        {
            cout<<(i+1)<<" "<<(i+3)<<"\n";
            return 0;
        }
    }
    cout<<"-1 -1\n";
    return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
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;
}

#define EPS (1e-7)
#define INF (1e18)
#define PI (acos(-1))
//const ll mod = 1000000007;
int N;
string S;
vector<int> pathes[2005];
ll ans = INF;

struct query {
    ll mini;
    ll maxi;
    ll num;
};

query dfs(int now, int from) {
    ll num = 0;
    ll maxisum = 0;
    query ret;
    vector<query> v;
    for(int i = 0; i < pathes[now].size(); i++) {
        int to = pathes[now][i];
        if(to == from) continue;
        v.push_back(dfs(to, now));
        num += v.back().num;
        maxisum += v.back().maxi;
    }
    ll mini = 0;
    if(num % 2 == 1) mini = 1;
    for(int i = 0; i < v.size(); i++) {
        if(maxisum - v[i].maxi < v[i].mini) {
            mini = v[i].mini - (maxisum - v[i].maxi);
        }
    }
    ret.num = num;
    if(S[now] == '1') ret.num++;
    ret.maxi = maxisum;
    ret.mini = mini;
    ret.maxi += ret.num;
    ret.mini += ret.num;
    return ret;
}

void f(int root) {
    vector<query> v;
    ll maxisum = 0;
    for(int i = 0; i < pathes[root].size(); i++) {
        int to = pathes[root][i];
        v.push_back(dfs(to, root));
        maxisum += v.back().maxi;
    }
    //cerr << root << " " << sum << " " << maxi << endl;
    cerr << root << " " << maxisum << endl;
    if(maxisum % 2 == 1) return;
    for(int i = 0; i < v.size(); i++) {
        if(maxisum - v[i].maxi < v[i].mini) return;
    }
    chmin(ans, maxisum / 2);
    return;
}

int main() {
    //cout.precision(10);
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> N >> S;
    S = "#" + S;
    for(int i = 1; i < N; i++) {
        int a, b;
        cin >> a >> b;
        pathes[a].push_back(b);
        pathes[b].push_back(a);
    }
    for(int i = 1; i <= N; i++) {
        f(i);
    }
    if(ans == INF) ans = -1;
    cout << ans << endl;
    return 0;
}


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


int main() {
	int N; cin >> N;
	vector<int> s(N);
	int ans = 0, ds = -1;
	for (int i = 0; i < N; i++) {
		cin >> s[i];
		ans += s[i];
		if (s[i] % 10 != 0 && (ds > s[i] || ds == -1)) ds = s[i];
	}
	if (ans % 10 == 0) {
		if (ds != -1) ans -= ds;
		if (ds == -1) ans = 0;
	}

	cout << ans << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <iomanip>
#include <iostream>
using namespace std;
using ll = long long;
const long long INF = 1LL << 60;

template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
ll max(ll a, ll b){
    if(a > b) return a;
    else return b;
}
 
ll min(ll a, ll b){
    if(a < b) return a;
    else return b;
}

int main(void){
    ll N,K; cin >> N >> K;
    vector<pair<int, int>> p(N);
    for(int i = 0; i < N; i++){
        cin >> p[i].first >> p[i].second;
    }
    
    sort(p.begin(), p.end());
    ll ans;
    for(int i = 0; i < N; i++){
        K -= p[i].second;
        if (K <= 0){
            ans = p[i].first;
            break;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#include <string>
#include <cmath>
#include <sstream>
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define FORD(i, a, b) for(int i = (a-1); i >= (b); i--)
#define pb(a) push_back(a)
#define mp(a,b) make_pair(a,b)
typedef long long int ll;
using namespace std;
//ll mod=1000000007;
//ll mod=67280421310721;
ll mod=998244353;
ll INF=1e18;
ll po(ll a,ll b)
{
	ll re=1;
	while(b)
	{
		if(b%2==1)
		{
			re=(re*a);
			re%=mod;
		}
		a=(a*a);
		a%=mod;
		b>>=1;
	}
	return re;
}
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	int test=1;
//	cin>>test;
	while(test--)
	{
		set<string> k;
		int n;
		cin>>n;
		string d;
		FOR(i,0,n)
		{
			cin>>d;
			k.insert(d);
		}
		cout<<k.size();
	}
	return 0;
}

Measured memory_bytes: 19272
#include<bits/stdc++.h>
using namespace std;
#define intt long long int
#define intu unsigned long long int
#define vi vector<int>
#define ii pair<int,int>
#define pb push_back
//#define mp make_pair
#define ff first
#define ss second
#define fast_io ios::sync_with_stdio(0);cin.tie(NULL);std::cout.tie(NULL);
# define PI           3.14159265358979323846 
#define all(a) a.begin(),a.end()
#define for0(i, n) for (int i = 0; i < n; i++)
#define for1(i, n) for (int i = 1; i <= n; i++)
#define loop(i,a,b) for (int i = a; i < b; i++)
#define bloop(i,a,b) for (int i = a ; i>=b;i--)
#define tc(t) int t; cin >> t; while (t--)
int mod = 1000000007;
int gcd(int a, int b) {return b ? gcd(b, a % b) : a;}
int lcm(int a, int b) {return a * b / gcd(a, b); }
intt bpow(intt a,intt b) 
{
  intt res = 1;
  while (b > 0) {
    if (b & 1)res = ((res%mod) * (a%mod))%mod;
      a = ((a%mod) * (a%mod))%mod;
      b >>= 1;
  }
  return res;
}
intt fact(intt n) { 
   if ((n==0)||(n==1))
      return 1; 
   else
      return n*fact(n-1);
}
void go()
{
#ifndef ONLINE_JUDGE
  freopen("inn.txt","r",stdin);
  freopen("ouut.txt","w",stdout);
  #endif
}
///////////U L R D
int dx[4]={0,-1,1,0};
int dy[4]={1,0,0,-1};


int main() 
{ 
    fast_io
    go();
    int n;cin>>n;
    vi v(n);
    map<intt,intt> mp;
    intt arr[200005];
    for0(i,n)
    {
      cin>>v[i];
      mp[v[i]]++;
    }
    intt ans=0;
    for(auto it=mp.begin();it!=mp.end();it++)
    {
      intt temp=it->ss;
      temp=temp*(temp-1)/2;
      arr[it->ff]=temp;
      ans+=temp;
    }
    
    for0(i,n)
    {
      intt anss=ans;
      auto it=mp.find(v[i]);
      intt temp=it->ss;
      anss-=arr[v[i]];
      temp--;
      temp=temp*(temp-1)/2;
      anss+=temp;
      cout << anss <<"\n";
    }
}

/*!
    You are under no obligation to be the same person you were a minute ago,
    You have the right to grow !
*/




















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

int main(){
	int N,K;
	scanf("%d%d",&N,&K);
	int ni[N],i=0,k,work =1;
	
	for(k=N;k>0;k--){
		 
		while(k*work < K){
			i++;
			work = work * 2;
		}
		
		ni[k-1] = i;
	}
	
	double sum=1;
	for(k=1;k<N;k++){
		sum = sum + pow(2,ni[0]-ni[k]);
	}
	printf("%.15f",sum / (pow(2,ni[0])*N));
	return 0;
}

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

#define int long long
using namespace std;
#define rep(i, n) for(int i=0;i<(n);++i)
typedef pair<int, int> pii;
const int INF = 1l << 60;
#define u_b upper_bound
#define l_b lower_bound


signed main() {
    string S;
    cin >> S;
    if (S[0] == S[1] || S[1] == S[2] || S[2] == S[3]) {
        cout << "Bad" << endl;
    } else {
        cout << "Good" << endl;
    }
    return 0;
}


Measured memory_bytes: 764
#include<bits/stdc++.h>
#define all(v) (v).begin(),(v).end()
#define pb push_back
#define ppb pop_back
#define mp make_pair
#define ri(x) scanf("%d",&(x))
#define ri2(x,y) scanf("%d %d",&(x),&(y))
#define ri3(x,y,z) scanf("%d %d %d",&(x),&(y),&(z))
#define rll(x) scanf("%lld",&(x))
#define rll2(x,y) scanf("%lld %lld",&(x),&(y))
#define rll3(x,y,z) scanf("%lld %lld %lld",&(x),&(y),&(z))
#define gc(x) ((x) = getchar())
using namespace::std;

const long double PI = acos(-1);
const long long MOD = 1000000000 +7;

typedef long long ll;
typedef pair<ll,ll> pll;
typedef pair<ll,pll> tll;
typedef pair<int,int> ii;
typedef pair<int,ii> iii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef vector<iii> viii;
typedef vector<ll> vll;
typedef vector<pll> vpll;
typedef vector<tll> vtll;
typedef vector<string> vs;
typedef set<int> si;
typedef set<ii> sii;
typedef set<iii> siii;

ll gcd(ll a, ll b){ return b==0?a:gcd(b,a%b);}

ll add(ll a, ll b, ll m = MOD){
	if(a >= m) a %= m;
	if(b >= m) b %= m;
	if(a < 0) a += m;
	if(b < 0) b += m;
	ll res = a+b;
	if(res >= m or res <= -m) res %= m;
	if(res < 0) res += m;
	return res;
}

ll mul(ll a, ll b, ll m = MOD){
	if(a >= m) a %= m;
	if(b >= m) b %= m;
	if(a < 0) a += m;
	if(b < 0) b += m;
	ll res = a*b;
	if(res >= m or res <= -m) res %= m;
	if(res < 0) res += m;
	return res;
}

ll pow_mod(ll a, ll b, ll m = MOD){
	ll res = 1LL;
	a = a%m;
	while(b){
		if(b&1) res = mul(res,a,m);
		b >>= 1;
		a = mul(a,a,m);
	}
	return res;
}

ll fastexp(ll a, ll b){
	ll res = 1LL;
	while(b){
		if(b&1) res = res*a;
		b >>= 1;
		a *= a;
	}
	return res;
}

int gcdExtendido(int a, int b, int *x, int *y){
	if(a == 0){
		*x = 0;
		*y = 1;
		return b;
	}
	int x1, y1;
	int gcd = gcdExtendido(b%a,a,&x1,&y1);
	
	*x = y1-(b/a)*x1;
	*y = x1;
	return gcd;
}

int modInverso(int a, int m){
	int x, y;
	int g = gcdExtendido(a,m,&x,&y);
	if(g!=1) return -1;
	else return (x%m + m)%m;
}

/****************************************
*************P*L*A*N*T*I*L*L*A************
*****************************************/

const int N = 100000+5;

int n;
int x;
int a[N];

int main(){
	ri2(n,x);
	for(int i=1; i<=n; i++) ri(a[i]);
	ll ans = 0LL;
	for(int i=1; i<=n; i++){
		int val = a[i-1] + a[i];
		int take = max(0,val - x);
		int take1 = min(a[i],take);
		a[i] -= take1;
		take -= take1;
		ans += take1;
		a[i-1] -= take;
		ans += take;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
int arr[100005];
int dp[3005][3005];
int anss  = 0 ;
char rep[100005];
int c=0;
string str1,str2;
int lcs(int first,int last)
    {
        if(first<=0|last<=0)
            {
                return 0;
            }
        if(dp[first][last]!=-1)
            return dp[first][last];
        if(str1[first]==str2[last]&&(first!=str1.size()&&last!=str2.size()))
        {
            dp[first][last]=1+lcs(first-1,last-1);
            anss = max(anss,dp[first][last]);
 
        }
        else
            {
            dp[first][last] = max(dp[first][last],max(lcs(first-1,last),lcs(first,last-1)));
            }
        return dp[first][last];
 
    }
void printstring()
    {
        int i = str1.size();
        int j = str2.size();
        //int idx = anss;
        int idx=lcs(str1.size()-1,str2.size()-1);
        char str[anss+1];
        str[idx+1]='\0';
        while(i>0&&j>0)
        {
            if(str1[i]==str2[j])
            {
                str[idx]= str1[i];
                idx--;
                i--;
                j--;
            }
            else if(dp[i-1][j]>dp[i][j-1])
            {
                i--;
            }
            else
                j--;
        }
        cout<<str<<endl;
    }
int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    for(int i=0;i<3006;i++)
        for(int j=0;j<3006;j++)
            dp[i][j]=-1;
    cin>>str1>>str2;
    str1="X"+str1;
    str2="Y"+str2;
    string ans="";
    int n = min(str2.size(),str1.size());
    int n1 = max(str2.size(),str1.size());
    //lcs(str1.size()-1,str2.size()-1);
    printstring();
 
}
 
 

Measured memory_bytes: 39256
#include <iostream>
#include <algorithm>
#include <vector>
#include <deque>
#include <queue>
#include <set>
#include <map>
#include <limits>
#include <cmath>
#include <iomanip>
#include <functional>
#include <random>
#include <boost/multiprecision/cpp_int.hpp>

using namespace std;
using ll = long long;
namespace mp = boost::multiprecision;

ll BASE_NUM = 1000000007;


int main()
{
    // 整数の入力
    ll N,K,R,S,P;
    string T;
    cin >> N >> K;
    cin >> R >> S >> P;
    cin >> T;
    vector<vector<char>> data(K);
    for(int i = 0;i< N;i++){
        data[i % K].push_back(T[i]);
    }

    map<char,ll> scores{
        {'s',R},
        {'p',S},
        {'r',P},
        {'-',0}
    };
    ll count = 0;
    for(int i = 0;i< K;i++){
        char last_char = '-';
        ll char_continue = 0;
        for(auto c: data[i]){
            if (c == last_char){
                char_continue++;
            }else{
                count += (char_continue + 1)/2 * scores[last_char];
                last_char = c;
                char_continue = 1;
            }
        }
        count += (char_continue + 1)/2  * scores[last_char];
    }

    cout << count << endl;
    return 0;
}

Measured memory_bytes: 5120
#include <bits/stdc++.h>
#define pb push_back
#define eb emplace_back
#define sz(V) ((int)(V).size())
#define allv(V) ((V).begin()),((V).end())
#define befv(V) ((V)[sz(V)-2])
#define sorv(V) sort(allv(V))
#define revv(V) reverse(allv(V))
#define univ(V) (V).erase(unique(allv(V)),(V).end())
#define upmax(a,b) (a)=max((a),(b))
#define upmin(a,b) (a)=min((a),(b))
#define rb(x) ((x)&(-(x)))
#define INF (0x3f3f3f3f)
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
void fuk() { puts("-1"); exit(0); }

const int MAXN = 200005;

int A[MAXN];

ll Ans;
int N;

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

	cin >> N;
	for(int i = 1; i <= N; i++) cin >> A[i];
	if(A[1]) fuk();

	for(int i = 1; i <= N; i++) {
		if(A[i-1]+1 < A[i]) fuk();
	}

	unordered_set<int> PQ;

	for(int i = N; i; i--) {
		if(!A[i]) continue;
		int t = i - A[i];
		auto it = PQ.find(t);

		if(PQ.end() != it) continue;

		Ans += A[i];
		PQ.insert(t);
	}

	cout << Ans << endl;
	return 0;
}


Measured memory_bytes: 8776
n = input()
a = map(int, raw_input().split())

b = []
for i in xrange(1, n):
    if a[i] - a[i-1] != 0:
        b.append(a[i] - a[i-1])
dont_mind = True
c = 1
i = 1
while i < len(b):
    prev = b[i-1]
    t = prev * b[i]
    if t >= 0:
        i += 1
        continue
    if t < 0:
        c += 1
        i += 2
        continue
    i += 1
print c

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

int main(){
    int h,w;
    cin >> h >> w;
    int maze[h][w];
    for(int i=0; i<h; i++){
        for(int j=0; j<w; j++){
            char c;
            cin >> c;
            if(c=='.') maze[i][j] = 1;
            else maze[i][j] = 0;
        }
    }
    int max_distance = 0;
    for(int i=0; i<h; i++){
        for(int j=0; j<w; j++){
            if(maze[i][j] == 0) continue;
            int d[h][w];
            for(int a=0; a<h; a++){
                for(int b=0; b<w; b++){
                    d[a][b] = 0;
                }
            }
            queue<pair<int,int>> que;
            que.push(make_pair(i,j));
            while(!que.empty()){
                pair<int,int> p = que.front();
                que.pop();
                int x = p.first, y = p.second;
                for(int dx=-1; dx<=1; dx+=2){
                    if(x+dx < 0 || h<= x+dx) continue;
                    int dy = 0;
                    if(d[x+dx][y+dy] != 0) continue;
                    if(maze[x+dx][y+dy] == 0) continue;
                    if(x+dx==i && y+dy==j) continue;
                    d[x+dx][y+dy] = d[x][y]+1;
                    max_distance = max(max_distance,d[x][y]+1);
                    que.push(make_pair(x+dx,y+dy));
                }
                for(int dy=-1; dy<=1; dy+=2){
                    if(y+dy < 0 || w<= y+dy) continue;
                    int dx = 0;
                    if(d[x+dx][y+dy] != 0) continue;
                    if(maze[x+dx][y+dy] == 0) continue;
                    if(x+dx==i && y+dy==j) continue;
                    d[x+dx][y+dy] = d[x][y]+1;
                    max_distance = max(max_distance,d[x][y]+1);
                    que.push(make_pair(x+dx,y+dy));
                }
            }
        }
    }
    cout << max_distance << endl;
    return 0;
}


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

public class Main {
	public static void main(String[] args) throws NumberFormatException,
			IOException {
		BufferedReader reader = new BufferedReader(new InputStreamReader(
				System.in));
		StringBuilder builder = new StringBuilder();
		String line;
		double max=0;
		double min=Integer.MAX_VALUE;
		
		while ((line = reader.readLine()) != null) {
			if (line.isEmpty()) {
				break;
			}
			double a = Double.parseDouble(line);
			max = Math.max(max, a);
			min = Math.min(min, a);
		}
		System.out.println(max-min);
	}
}

Measured memory_bytes: 16988
#include<iostream>
#include<algorithm>
#include<cmath>
#include<vector>
#include<map>
#include<queue>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep1(i, n) for (int i = 1; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int INF = 1001001001;

struct Sieve {
  int n;

  // 0からnまで、その数を素因数分解した時に求まる最小の素数のリスト
  // 外部から使われることはないはず
  vector<int> f;

  // nまでの素数リスト
  vector<int> primes;

  Sieve(int n=1):n(n), f(n+1) {
    f[0] = f[1] = -1; // 0と1は素数ではないので例外的に-1を入れる
    for (ll i = 2; i <= n; ++i) {
      if (f[i]) continue;
      primes.push_back(i);
      f[i] = i;
      for (ll j = i*i; j <= n; j += i) {
        if (!f[j]) f[j] = i;
      }
    }
  }

  // xが素数かどうかのbool値を返す (x <= n)
  bool isPrime(int x) { return f[x] == x;}

  // xの素因数分解の結果リストを返す (x <= n)
  vector<int> factorList(int x) {
    vector<int> res;
    while (x != 1) {
      res.push_back(f[x]);
      x /= f[x];
    }
    return res;
  }

  // xの素因数分解の結果をP(基数, 指数)の形にしたリストを返す (x <= n)
  vector<P> factor(int x) {
    vector<int> fl = factorList(x);
    if (fl.size() == 0) return {};
    vector<P> res(1, P(fl[0], 0));
    for (int p : fl) {
      if (res.back().first == p) {
        res.back().second++;
      } else {
        res.emplace_back(p, 1);
      }
    }
    return res;
  }
};

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

  Sieve s(2*100000);
  int ans;
  for(int prime : s.primes) {
    if (prime >= X) {
      ans = prime;
      break;
    }
  }

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


Measured memory_bytes: 1280
fn read<T: std::str::FromStr>(
    stdin_lock: &mut std::io::StdinLock,
    buf: &mut Vec<u8>,
    delimiter: u8,
) -> T {
    buf.clear();
    let l = std::io::BufRead::read_until(stdin_lock, delimiter, buf).unwrap();
    buf.truncate(l - 1); // remove delimiter
    let s = unsafe { std::str::from_utf8_unchecked(&buf) };
    s.parse().unwrap_or_else(|_| panic!("read"))
}

fn main() {
    let stdin = std::io::stdin();
    let mut stdin_lock = stdin.lock();
    let mut buf: Vec<u8> = Vec::new();
    let n: i32 = read(&mut stdin_lock, &mut buf, b' ');
    let m: i32 = read(&mut stdin_lock, &mut buf, b'\n');
    println!("{}", if n == m { "Yes" } else { "No" });
}


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

typedef long long ll;
typedef unsigned int ui;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> ii;
typedef vector<ii> vii;
const int INF = int (1e9) + int (1e5);
const ll INFL = ll(2e18) + ll(1e10);
const ui MOD = 1E9 + 7;
const double EPS = 1e-9;
#define FOR(i,n) for (int i=0;i<(n);++i)
#define ROF(i,x) for(int i = (x) ; i >= 0 ; --i)
#define MP make_pair
#define ALL(a) (a).begin(),(a).end()
#define ODD(x) (((x)&1)==0?(0):(1))
#define sign(x) ((x > 0) - (x < 0))
std::mt19937_64  generator(std::chrono::system_clock::now().time_since_epoch().count());

inline ll powmod(ll a,ll b,ll mod) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a, ll b) { return a ? gcd(b%a, a): b; }
ll lcm(ll a, ll b) { return a / gcd(a,b) * b; }


void READ(bool _local){
    ios_base::sync_with_stdio(false); cin.tie(0);
#ifdef _DEBUG
    if (_local)
        freopen ("in.txt", "r", stdin);
#endif
}

int main() {
    READ(0);
    int a,b;cin>>a>>b;
    cout << lcm(a,b);

    return 0;
}



Measured memory_bytes: 384