akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define debug(x) cout << '>' << #x << ':' << x << endl;
#define ll long long

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int n, m, sum = 0;
	cin >> n >> m;
	vector<vector<char>> arr(n + 2, vector<char>(m + 2, '.'));

	for (int i = 1; i <= n; i++)
		for (int j = 0; j < m; j++) {
			cin >> arr[i][j];
			if (arr[i][j] == '#')
				sum++;
		}
	if (sum == m + n - 1) {
		cout << "Possible\n";
	} else
		cout << "Impossible\n";

	return 0;

}


Measured memory_bytes: 3592
#include<string>
#include<cstring>
#include<stack>
#include<iostream>
#include<cstdlib>
using namespace std;

int main()
{
    string word;
    stack<int> S;
    int num;
    int count=-1;
    while(cin >> word)
    {
        count++;
        if(word=="+")
        {
            int a=S.top(); S.pop();
            int b=S.top(); S.pop();
            num=a+b;
            S.push(num);
        }
        else if(word=="-")
        {
            int a=S.top(); S.pop();
            int b=S.top(); S.pop();
            num=b-a;
            S.push(num);
        }
        else if(word=="*")
        {
            int a=S.top(); S.pop();
            int b=S.top(); S.pop();
            num=a*b;
            S.push(num);
        }
        else
        {
            num=atoi(word.c_str());
            S.push(num);
        }
     }
    int n=S.top();
    cout <<n<< endl;
}


Measured memory_bytes: 3220
#include<iostream>
#include<algorithm>
#include<string>
#include<cstdlib>
#include<map>
#include<iomanip>
using namespace std;

int main() {
	long long int n, m, p;
	string str;
	cin >> n >> m >> p;
	cout << (n - m + 1)*(n - p + 1);
} 

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

int main() {
  vector<int> a(3);
  cin >> a[0] >> a[1] >> a[2];
  
  sort(a.begin(),a.end());
  
  if(a[0]+a[1]==a[2]) cout << "Yes"<<endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 256
import Control.Applicative
import Control.Monad
import Data.Functor
import Data.Monoid
import Data.Maybe
import Data.List

getInts = map read . words <$> getLine :: IO [Int]
sjoin = unwords . map show

fizzBuzz = let fb k s n = guard (n`mod`k==0) $> s in fromMaybe <$> show <*> fb 3 "Fizz" <> fb 5 "Buzz"

f m ss = f' [1..m] $ zipWith (==) ss $ map fizzBuzz [1..]
  where
    f' [p] _ = [p]
    f' ps [] = sort ps
    f' (p:ps) (b:subs) = f' (if b then ps ++ [p] else ps) subs

main = do
    [m,n] <- getInts
    unless (n==0 && m==0) $ replicateM n getLine >>= putStrLn . sjoin . f m >> main


Measured memory_bytes: 9300
#include <iostream>
#include <climits>
#include <string>
#include <stdlib.h>
#include <algorithm>

using namespace std;
 
int ascSort(const void* v1, const void* v2) {
    const int _v1 = *((const int*)v1);
    const int _v2 = *((const int*)v2);
 
    if ( _v1 < _v2 ) {
        return 1;
    } else if ( _v1 > _v2 ) {
        return -1;
    } else {
        return 0;
    }
}

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

Measured memory_bytes: 256
;; -*- coding: utf-8 -*-
(eval-when (:compile-toplevel :load-toplevel :execute)
  (defparameter OPT
    #+swank '(optimize (speed 3) (safety 2))
    #-swank '(optimize (speed 3) (safety 0) (debug 0)))
  #+swank (ql:quickload '(:cl-debug-print :fiveam)))
#+swank (cl-syntax:use-syntax cl-debug-print:debug-print-syntax)
#-swank (disable-debugger) ; for CS Academy

;; BEGIN_INSERTED_CONTENTS
(declaim (ftype (function * (values fixnum &optional)) read-fixnum))
(defun read-fixnum (&optional (in *standard-input*))
  (declare #.OPT
           #-swank (sb-kernel:ansi-stream in))
  (macrolet ((%read-byte ()
               `(the (unsigned-byte 8)
                     #+swank (char-code (read-char in nil #\Nul))
                     #-swank (sb-impl::ansi-stream-read-byte in nil #.(char-code #\Nul) nil))))
    (let* ((result (loop (let ((byte (%read-byte)))
                           (when (<= 48 byte)
                             (return (- byte 48)))))))
      (declare ((integer 0 #.most-positive-fixnum) result))
      (loop
        (let* ((byte (%read-byte)))
          (if (<= 48 byte)
              (setq result (+ (- byte 48) (* 10 (the (integer 0 #.(floor most-positive-fixnum 10)) result))))
              (return result)))))))

(declaim (inline println))
(defun println (obj &optional (stream *standard-output*))
  (let ((*read-default-float-format* 'double-float))
    (prog1 (princ obj stream) (terpri stream))))

;; Body

(define-modify-macro minf (new-value)
  (lambda (x y) (min x y)))

(defun main ()
  (declare #.OPT)
  (let* ((n (read))
         (k (read))
         (hs (make-array 100000 :element-type '(unsigned-byte 32)))
         (dp (make-array 100000 :element-type '(unsigned-byte 32) :initial-element #xffffffff)))
    (declare ((unsigned-byte 31) n k))
    (setf (aref dp 0) 0)
    (dotimes (i n)
      (setf (aref hs i) (read-fixnum)))
    (dotimes (i n)
      (let ((h (aref hs i))
            (d (aref dp i)))
        (loop for dest from (+ i 1) to (min (+ i k) (- n 1))
              do (minf (aref dp dest) (+ d (abs (- h (aref hs dest))))))))
    (println (aref dp (- n 1)))))

#-swank (main)


Measured memory_bytes: 8680
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep_(i, n, m) for (int i = n; i < (int)(m); i++)
#define all(v) v.begin(), v.end()
#define int long long
#define stoi stoll


signed main() {
  int X, N; cin >> X >> N;
  unordered_map<int,int> map;
  rep(i, N) {
    int p; cin >> p;
    map[p]++;
  }
  
  int k = 0;
  while(true) {
    if(map[X-k] == 0) {
      cout << X-k << endl;
      return 0;
    }
    if(map[X+k] == 0) {
      cout << X+k << endl;
      return 0;
    }
    k++;
  }
    
}

Measured memory_bytes: 3636
N, M = map(int, input().split())
X = [list(map(int, input().split())) for _ in range(N)]
Y = [list(map(int, input().split())) for _ in range(M)]

for i in range(N):
  ans = 10**10
  ansIndex = -1
  for j in range(M):
    tmp = abs(X[i][0]-Y[j][0])+abs(X[i][1]-Y[j][1])
    if tmp < ans:
      ans = tmp
      ansIndex = j
  print(ansIndex+1)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define ft first
#define sc second
#define lb lower_bound
#define ub upper_bound
#define pb push_back
#define pt(sth) cout << sth << "\n"
#define chmax(a, b) {if(a<b) a=b;}
#define chmin(a, b) {if(a>b) a=b;}
#define moC(a, s, b) (a)=((a)s(b)+MOD)%MOD
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef map<ll, ll> Map;
static const ll INF=1e18;
static const ll MAX=1e5+7;
static const ll MOD=1e9+7;
ll max(ll a, ll b) {return a>b ? a:b;}
ll min(ll a, ll b) {return a<b ? a:b;}

int main(void) {
    ll N;
    cin >> N;
    ll a[MAX*2];
    ll i;
    
    for(i=0; i<N; i++) cin >> a[i];
    
    ll ans=0;
    ll l=0, r=1, s=0;
    for(l=0; l<N; l++) {
        
        while(s+a[r-1]==(s^a[r-1]) && r<=N) {
            s+=a[r-1];
            r++;
        }
        
        ans+=r-1-l;
        
        if(l==r-1) r++;
        else s-=a[l];
        
    }
    
    pt(ans);
    
}


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

#define all(v) (v).begin(), (v).end()
typedef long long LL;
using namespace std;

int ceil(LL numerator, LL denominator)
{
    int quotient = numerator/denominator;
    int remainder_exists = (numerator%denominator != 0);

	return (quotient + remainder_exists);
}

int possible(vector <LL> H, LL A, LL B, LL explosions)
{
	for(int i = 1; i < H.size(); i++)
	{
		H[i] -= (explosions*B);
	}

	LL explosions_used = 0;
	for(int i = H.size() - 1; i > 0 && H[i] > 0; i--)
	{
		explosions_used += ceil(H[i], A - B);
	}

	return (explosions_used <= explosions);
}

int main()
{
    int no_of_monsters, A, B;
    cin >> no_of_monsters >> A >> B;

    vector <LL> health(no_of_monsters + 1);
    for(int i = 1; i <= no_of_monsters; i++)
    	cin >> health[i];

    sort(all(health));

    int left_explosions = 1, right_explosions = 1e9;
    while(left_explosions <= right_explosions)
    {
    	int mid_explosions = (left_explosions + right_explosions) >> 1;

    	if(possible(health, A, B, mid_explosions))
    	{
    		if(mid_explosions == left_explosions || !possible(health, A, B, mid_explosions - 1))
    		{
    			cout << mid_explosions;
    			break;
    		}
    		else
    		{
    			right_explosions = mid_explosions - 1;
    		}
    	}
    	else
    	{
    		left_explosions = mid_explosions + 1;
    	}
    }
	return 0;
}



Measured memory_bytes: 1792
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<cmath>
#include<map>
#include<iomanip>
#include<queue>
#include<stack>
#include<time.h>
#define rep(i,n)for(ll i=0;i<n;i++)
#define ll long long
#define ggr getchar();getchar();return 0;
#define prique priority_queue
#define inf 1145141919364364
#define double long double
using namespace std;
typedef pair<ll, ll>P;
bool prime(int n) {
	int cnt = 0;
	for (int i = 1; i <= sqrt(n); i++) {
		if (n % i == 0)cnt++;
	}
	if (cnt != 1)return false;
	else return n != 1;
}
ll gcd(ll x, ll y) {
	if (y == 0)return x;
	return gcd(y, x % y);
}
ll lcm(ll x, ll y) {
	return x * y / gcd(x, y);
}
ll n;
P a[114514];
signed main() {
	cin >> n;
	rep(i, n)cin >> a[i].first;
	rep(i, n)a[i].second = i + 1;
	sort(a, a + n);
	rep(i, n)cout << a[i].second << " ";
	ggr
}

Measured memory_bytes: 2432
#include <iostream>
#include <string>
#include <algorithm>
#include <iomanip>
#include <vector>
#include <map>
#include <cmath>
#include <queue>
#include <utility>
#include <functional>
#include <deque>
#include <cctype>
#include <stack>

using ll = long long;
typedef std::pair<int, int>p;

ll min(ll a, ll b) {
	if (a >= b)return b;
	else return a;
}
ll max(ll a, ll b) {
	if (a >= b)return a;
	else return b;
}
ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a%b);
}
ll lcm(ll a, ll b) {
	ll g = gcd(a, b);
	return a / g * b;
}

const ll Z = 1000000007;
const ll INF = 1 << 30;
const ll INF2 = 9000000000000000000LL;
bool flag = true;
bool fl = true;
bool used[210];
bool graph[100][100];

int main() {
	int n, m, a[200000], b[200000];
	std::cin >> n >> m;
	std::vector<p>pa(m);
	for (int i = 0;i < m;i++) {
		std::cin >> a[i] >> b[i];
		pa[i] = std::make_pair(a[i], b[i]);
	}
	std::sort(pa.begin(), pa.end());
	for (int i = 0;pa[i].first == 1;i++) {
		int l = 0, r = m - 1;
		while (r - l > 1) {
			int mid = (l + r) / 2;
			if (pa[mid].first < pa[i].second) l = mid;
			else if (pa[mid].first >= pa[i].second)r = mid;
		}
		for (;pa[r].first == pa[i].second;r++) {
			if (pa[r].second == n) {
				flag = false;
				break;
			}
		}
		if (flag == false)break;
	}
	if (flag) {
		std::cout << "IMPOSSIBLE" << std::endl;
	}
	else {
		std::cout << "POSSIBLE" << std::endl;
	}
}

Measured memory_bytes: 3328
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<vector>
#include<cmath>
#include<algorithm>
#include<map>
#include<queue>
#include<deque>
using namespace std;
typedef long long int LL;
typedef pair<int,int> P;
typedef pair<int,pair<int,int> > PP;
typedef pair<LL,int> LP;
const int INF=1<<30;
const LL MAX=1e9+7;

void array_show(int *array,int array_n,char middle=' '){
	for(int i=0;i<array_n;i++)printf("%d%c",array[i],(i!=array_n-1?middle:'\n'));
}
void array_show(LL *array,int array_n,char middle=' '){
	for(int i=0;i<array_n;i++)printf("%lld%c",array[i],(i!=array_n-1?middle:'\n'));
}
void print_YES_NO(bool answer){cout<<(answer?"YES":"NO")<<endl;}
void print_Yes_No(bool answer){cout<<(answer?"Yes":"No")<<endl;}
void print_POSSIBLE_IMPOSSIBLE(bool answer){cout<<(answer?"POSSIBLE":"IMPOSSIBLE")<<endl;}

const int move[4][2]={{-1,0},{1,0},{0,-1},{0,1}};
char ca[200005];
int t[2][200005];

bool check(int y,int w,int r,int l,int n){
	int a=0,b=w-1;
	int i,j,k;
	for(i=n-1;i>=0;i--){
		if(t[1][i]==r){
			if(a>0)a--;
		}
		if(t[1][i]==l){
			if(b<w-1)b++;
		}
		if(t[0][i]==r)b--;
		if(t[0][i]==l)a++;
		if(a>b)return false;
	}
	if(a<=y && y<=b)return true;
	return false;
}

int main(){
	int h,w,n;
	int i,j,k;
	int a,b,c;
	int x,y;
	cin>>h>>w>>n;
	cin>>x>>y;
	x--,y--;
	for(i=0;i<2;i++){
		cin>>ca;
		for(j=0;j<n;j++){
			if(ca[j]=='L')t[i][j]=0;
			if(ca[j]=='R')t[i][j]=1;
			if(ca[j]=='U')t[i][j]=2;
			if(ca[j]=='D')t[i][j]=3;
		}
	}
	print_YES_NO(check(y,w,1,0,n)&&check(x,h,3,2,n));
}


Measured memory_bytes: 2048
#include<stdio.h>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
 
 
using namespace std;
 
//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
 
//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}
 
//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
 
//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
 
//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
 
//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
 
//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))
 
//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

int main(void){
  int a,b,c;
  cin >> a>>b>>c;

  cout<<min(b/a,c)<<endl;
}


Measured memory_bytes: 256
import numpy as np
from functools import reduce
from operator import add,sub,mul,truediv
from fractions import gcd
import itertools 

n,k = map(int,input().split())

x = [0]*k

for i in range(1,n+1):
    x[i%k] = x[i%k]+1


ans = x[0]*x[0]*x[0]

for i in range(1,k):
    b = i%k #決め打ち
    a = (k-b) # 必要なあまりを計算
    c = (k-b) # 必要なあまりを計算
    if((a+c)%k != 0):continue
    ans  = ans + x[a] * x[b] * x[c]

print(ans)


Measured memory_bytes: 14656
def solve(c)
    2.times do |i|
        d = c[i + 1][0] - c[i][0]
        1.upto(2) do |j|
            if c[i + 1][j] - c[i][j] != d
                return false
            end
        end
    end
    
    2.times do |j|
        d = c[0][j + 1] - c[0][j]
        1.upto(2) do |i|
            if c[i][j + 1] - c[i][j] != d
                return false
            end
        end
    end
    return true
end

c = Array.new(3)
3.times do |i|
    c[i] = gets.split.map(&:to_i)
end
puts solve(c) ? "Yes" : "No"

Measured memory_bytes: 1788
#include <bits/stdc++.h>
#define rep(i,n) for (int i=0;i<(n);++i)
using namespace std;
int main(){
	float n;cin>>n;
	float a;
	float ans=0;
	rep(i,n){
		cin>>a;
		ans+=1/a;
	}
	cout<<1/ans<<endl;
}

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

int main () {

    string day[7] = {"SUN", "MON", "TUE", "WED", "THU", "FRI", "SAT"};

    string S;
    cin >> S;
    for (int i = 0; i < 7; i++) {
        if (day[i] == S) {
            cout << 7 - i << endl;
            break;
        }
    }

    return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
#define in std::cin
#define out std::cout
#define rep(i,N) for(int i=0;i<N;++i)
typedef long long int LL;

int n, m;
std::vector<int>a, b, G[5123], cou, ans;
std::vector<bool>isAlready;
std::map<std::pair<int, int>, bool>isGame;
bool flag = false;

void dfs(int p)
{
	if (isAlready[p]) { return; }
	isAlready[p] = true;
	for (auto i : G[p]) { dfs(i); }
	ans.push_back(p);
}

int main()
{
	in >> n >> m;
	a.resize(m); b.resize(m);
	isAlready.resize(n + 1); cou.resize(n + 1);
	rep(i, m) { in >> a[i] >> b[i]; }

	rep(i, m)
	{
		G[b[i]].push_back(a[i]);
		isGame[std::make_pair(a[i], b[i])] = true;
	}
	rep(i, n) { dfs(i + 1); }
	rep(i, n - 1)
	{
		if (!isGame[std::make_pair(ans[i], ans[i + 1])])
		{
			flag = true;
			break;
		}
	}

	for (auto i : ans) { out << i << std::endl; }
	out << (flag ? 1 : 0) << std::endl;
	return 0;
}

Measured memory_bytes: 10864
//https://atcoder.jp/contests/abc126/tasks/abc126_a

import java.util.Scanner;

class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int K = sc.nextInt();
        StringBuffer S = new StringBuffer(sc.next());
        sc.close();
        if (String.valueOf(S.charAt(K-1)).equals("A")){
            S.setCharAt(K-1, 'a');
        } else if (String.valueOf(S.charAt(K-1)).equals("B")){
            S.setCharAt(K-1, 'b');
        } else if (String.valueOf(S.charAt(K-1)).equals("C")){
            S.setCharAt(K-1, 'c');
        }
        System.out.println(S);
    }
}

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

long read_long() {
	long ret=0,t=1;char c=getchar();
	while(c<'0' ||c>'9') {
		if(c=='-') t=-1;
		c=getchar();
	}	while(c>='0' && c<='9') {
		ret=ret*10+c-'0';
		c=getchar();
	}		return ret*t;
}

const long MAXN=100100;
long n,m;
long a[MAXN];
long num_of_2;

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

long long lcm(long long a,long long b) {
	long GGCCDD=gcd(a,b);
	return (a/GGCCDD)*(b/GGCCDD)*GGCCDD;
}

int main() {
	register long i;
	n=read_long();
	m=read_long();
	for(i=1;i<=n;++i) {
		a[i]=read_long();
		a[i]/=2;
	}
	
	long a0=a[1];
	while(a0%2==0) {
		a0/=2;++num_of_2;
	}
	long here_num_2;
	for(i=2;i<=n;++i) {
		here_num_2=0;
		a0=a[i];
		while(a0%2==0) {
			a0>>=1;++here_num_2;
		}
		if(here_num_2!=num_of_2) {
			cout<<"0"<<endl;
			return 0;
		}
	}
	
	long long LLCCMM=1;
	for(i=1;i<=n;++i) {
		LLCCMM=lcm(LLCCMM,a[i]);
		if(LLCCMM>m) {
			cout<<"0"<<endl;
			return 0;
		}
	}
	
	long ans=m/LLCCMM;
	cout<<(ans+1)/2<<endl;
	return 0;
}

Measured memory_bytes: 1024
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
//#include "MyMath.h"
#include <map>
#include <set>
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <queue>
#include <vector>
#include <functional>
#include <math.h>
using namespace std;
const int num = 40, num1 = 10000000;
double numd = 10000000.0;
const int INF = 2000000000;
typedef long long int ll;
pair<ll, ll> l[1 << (num / 2)], r[1 << (num - num / 2)], a[num / 2], b[num / 2];
int main() {
	int n;
	ll W;
	cin >> n >> W;
	int m = n - n / 2;
	for (int i = 0; i < n / 2; i++)
		cin >> a[i].second >> a[i].first;
	//int k = 0;
	for (int i = 0; i < m; i++)
		/*cin >> b[k].second;
		cin >> b[k++].first;*///????????§k??????????????????
		cin >> b[i].second >> b[i].first;
	for (int i = 0; i < 1 << n / 2; i++) {
		ll v = 0, w = 0; 
		for(int j = 0; j < n / 2; j++)
			if (i >> j & 1) {
				v += a[j].second;
				w += a[j].first;
			}
		l[i] = make_pair(w, v);
	}
	for (int i = 0; i < 1 << m; i++) {
		ll v = 0, w = 0;
		for (int j = 0; j < m; j++)
			if (i >> j & 1) {
				v += b[j].second;
				w += b[j].first;
			}
		r[i] = make_pair(w, v);
	}
	sort(l, l + (1 << n / 2));
	sort(r, r + (1 << m));
	int s = 0;
	/*for (int i = 0; i < 1 << n / 2; i++)
		cout << l[i].first << " " << l[i].second << endl;
	for (int i = 0; i < 1 << m; i++)
		cout << r[i].first << " " << r[i].second << endl;*/
	for (int i = 1; i < 1 << n / 2; i++) 
		if (l[s].second < l[i].second) {
			l[++s] = l[i];
			//cout << "S" << endl;
		}
	int t = 0;
	for (int i = 1; i < 1 << m; i++)
		if (r[t].second < r[i].second) {
			r[++t] = r[i];
			//cout << "T" << endl;
		}
	//cout << "s" << s << "t" << t << endl;
	/*for (int i = 0; i <= s; i++)
		cout << l[i].first << " " << l[i].second << endl;
	for (int i = 0; i <= t; i++)
		cout << r[i].first << " " << r[i].second << endl;*/
	ll maxv = 0;
	/*for (int i = 0; i <= s; i++) {
		if (W < l[i].first) continue;
		ll w = W - l[i].first;
		cout << "i" << i << endl;	
		cout << "w" << w << endl;
		cout << "u" << upper_bound(r, r + t, make_pair(w, l[i].second))->second << endl;
		cout << "u" << upper_bound(r, r + t + 1, make_pair(w, l[i].second)) -> second << endl;
		cout << "u" << upper_bound(r, r + t + 2, make_pair(w, l[i].second))->second << endl;
		cout << "l" << lower_bound(r, r + t + 1, make_pair(w, l[i].second)) -> second << endl;
		cout << (upper_bound(r, r + t + 1, make_pair(w, l[i].second)) - 1)->second + l[i].second << endl;
		maxv = max(maxv, (lower_bound(r, r + t + 1, make_pair(w, l[i].second)) - 1)->second + l[i].second);
	}*/
	for (int i = 0; i <= t; i++) {
		if (W < r[i].first) continue;
		ll w = W - r[i].first;
		maxv = max(maxv, (lower_bound(l, l + s + 1, make_pair(w, r[i].second)) - 1)->second + r[i].second);
	}
	cout << maxv << endl;
	return 0;
}

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

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	vector<int> inp(4);
	rep(i, 4) cin >> inp[i];
	if (abs(inp[2] - inp[0]) <= inp[3]) {
		cout << "Yes" << endl;
		return 0;
	}
	if (abs(inp[1] - inp[0]) <= inp[3] && abs(inp[2] - inp[1]) <= inp[3]) {
		cout << "Yes" << endl;
		return 0;
	}
	cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cstring>
#include <cstdlib>
#include <cmath>
using namespace std;
using ll = long long;

constexpr int P = 1000000007;

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

    int n;
    cin >> n;

    constexpr int T = (1 << 8) - 1;
    constexpr ll S = T | (ll)T << 32, X = (unsigned long long)-1 / T;
    ll p0[8][4] = {};
    ll r = 0;

    for (int i0 = 0; i0 < n; i0 += T) {
        ll p[8] = {};
        int i1 = min(T, n - i0);
        for (int i = 0; i < i1; i++) {
            ll a;
            cin >> a;

            for (int k = 0; k < 8; k++) {
                p[k] += a & X;
                a >>= 1;
            }
        }

        for (int k = 0; k < 8; k++) {
            ll c = p[k];
            for (int h = 0; h < 4; h++) {
                p0[k][h] += c & S;
                c >>= 8;
            }
        }
    }

    for (int k = 0; k < 32; k++) {
        ll c = p0[k % 8][k / 8];
        for (int h = 0; h < 2; h++) {
            ll t = c & ((1LL << 32) - 1);
            c >>= 32;
            r += (1LL << (32 * h + k)) % P * t % P * (n - t) % P;
        }
    }
    r %= P;

    cout << r << endl;

    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void){
  int a,b,c,d,left,right;
  scanf("%d %d %d %d",&a,&b,&c,&d);
  left=a+b;
  right=c+d;
  if(left>right){
    printf("Left\n");
  }else if(left==right){
    printf("Balanced\n");
  }else{
    printf("Right\n");
  }
  return 0;
}


Measured memory_bytes: 128
#include<cstdio>
#include<cstring>
char str[]={"AKIHABARA"};
char s[110];
int b[110];
int main()
{
	scanf("%s",s);
	int c=0,i,n=strlen(s);
	for(i=0;c<9;c++)
	{
		if(s[i]==str[c])
		{
			b[c]=1;
			i++;
		}
	}
	if(i<n)
	{
		printf("NO");
		return 0;
	}
	for(int i=0;i<9;i++)
	{
		if(b[i]==0)
		{
			if(str[i]!='A')
			{
				printf("NO");
				return 0;
			}
		}
	}
	printf("YES");
	return 0;
}

Measured memory_bytes: 128
///
// File:  1172.cpp
// Author: ymiyamoto
//
// Created on Sun Nov 12 17:31:51 2017
//

#include <cmath>
#include <cstdint>
#include <iostream>

using namespace std;

bool is_prime(uint32_t n)
{
  for (uint32_t i = 2; i <= (uint32_t)sqrt((double)n); i++) {
    if (n % i == 0) {
      return false;
    }
  }
  return true;
}

int32_t main()
{
  while (true) {
    uint32_t n;
    cin >> n;

    if (n == 0) break;

    uint32_t count = 0;
    for (uint32_t i = n + 1; i <= 2 * n; i++) {
      if (is_prime(i)) {
        count++;
      }
    }
    cout << count << endl;
  }

  return 0;
}

Measured memory_bytes: 3028
#include<bits/stdc++.h>
#define rep(i,m) for(long long i=0; i<m; i++)
#define per(i,m) for(long long i=m-1; i>=0; i--)
#define FOR(i,n,m) for(long long i=n; i<m; i++)
#define ROF(i,n,m) for(long long i=n-1; i>=m; i--)
#define all(x) (x).begin(),(x).end()
#define EPS (1e-7)
#define INF (1e18)
#define PI (acos(-1))
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
using namespace std;
typedef long long ll;
const ll MOD = 1000000007;
typedef pair<ll, ll> LP;

ll POW(ll x,ll n){
  if(n==0)return 1;
  if(n%2==0)return POW(x*x%MOD,n/2);
  return x*POW(x,n-1)%MOD;
}

ll gcd(ll u, ll v) {
  ll r;
  while (0 != v) {
    r = u % v; u = v; v = r;
  }
  return u;
}
 
ll KAI(ll m)
{
  if(m<0) return 0;
  if(m==0) return 1;
  return m*KAI(m-1)%MOD;
}
 
ll extGCD(ll a, ll b, ll &x, ll &y) {
    if (b == 0) {
        x = 1;
        y = 0;
        return a;
    }
    ll d = extGCD(b, a%b, y, x);
    y -= a / b * x;
    return d;
}
 
inline ll mod(ll a, ll m) {
    return (a % m + m) % m;
}
 
ll modinv(ll a) {
    ll x, y;
    extGCD(a, MOD, x, y);
    return mod(x, MOD);
}
 
ll COM(ll m,ll n)
{
  if(m<n) return 0;
  if(n<0) return 0;
  if(n==0) return 1;
  if(m==n) return 1;
  return KAI(m)%MOD*modinv(KAI(n)%MOD*KAI(m-n)%MOD)%MOD;
}

ll DEC(ll x,ll m,ll n)
{
  return x%POW(m,n+1)/POW(m,n);
}

ll keta(ll x,ll n)
{
  if(x==0)return 0;
  return keta(x/n,n)+1;
}

ll DIV(ll x,ll n)
{
  if(x==0)return 0;
  return x/n+DIV(x/n,n);
}


int main()
{
  ll a,b,c;
  cin >> a >> b >> c;
  if(b%a==0)printf("%lld",a+b);
  else printf("%lld",b-a);
}

Measured memory_bytes: 256
import java.util.*;

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

    private void run() {
        Scanner scanner = new Scanner(System.in);
        int N = scanner.nextInt();
        int M = scanner.nextInt();
        long[] H = new long[N];

        for(int i = 0; i < N; i++) {
            H[i] = scanner.nextLong();
        }

        Map<Integer, Set<Integer>> map = new HashMap<>();
        for (int i = 0; i < M; i++) {
            int a = scanner.nextInt();
            int b = scanner.nextInt();
            Set<Integer> aList = map.getOrDefault(a, new HashSet<>());
            aList.add(b);
            map.put(a, aList);
            Set<Integer> bList = map.getOrDefault(b, new HashSet<>());
            bList.add(a);
            map.put(b, bList);
        }

        int ret = 0;
        for(int i = 1; i <= N; i++) {
            Set<Integer> list = map.getOrDefault(i, new HashSet<>());
            if(list.size() == 0) {
                ret++;
                continue;
            }
            boolean flg = true;
            for (int l : list) {
                if (H[i-1] <= H[l-1]) {
                    flg = false;
                }
            }
            if (flg) {
                ret++;
            }
        }
        System.out.println(ret);
    }
}

Measured memory_bytes: 89780
#include<bits/stdc++.h>
using namespace std;
int main(){
	int x;
	cin >> x;
	
	int h = x/3600;
	int m = (x/60) % 60;
	int s = x % 60;
	cout << h << ":" << m << ":" << s <<endl;
return 0;
}


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

int main() {
    int N;
    cin >> N;
    vector<ull> A(N);
    for (int i=0; i<N; i++) {
        cin >> A[i];
    }
    ull memo = 0;
    ull adjust = 0;
    for (int i=0; i<N; i++) {
        if (memo < A[i]) {
            memo = A[i];
        }
        else {
            adjust += memo - A[i];
        }
    }
    cout << adjust << endl;
}

Measured memory_bytes: 4840
#include<bits/stdc++.h>
#define MAX_N 100001
#define INF_INT 2147483647
#define INF_LL 9223372036854775807
#define REP(i,n) for(int i=0;i<(int)(n);i++)
using namespace std;
typedef long long int ll;
typedef pair<ll,ll> P;
void init(int n);
int find(int n);
void unite(int x,int y);
bool same(int x, int y);
ll bpow(ll,ll,ll);
typedef vector<int> vec;
typedef vector<vec> mat;
mat mul(mat &A,mat &B);
mat pow(mat A,ll n);
int dx[4] = {1,0,0,-1};
int dy[4] = {0,1,-1,0};
const int MOD = 1000000007;
ll dp[51][51][2600] = {0};
bool cmp_P(const P &a,const P &b){
  return a.second < b.second;
}
int main()
{
  ll sum,N,A,x[51];
  cin >> N >> A;
  REP(i,N)cin >> x[i+1];
  REP(i,51)REP(j,51)REP(k,2600)dp[i][j][k] = 0;
  dp[0][0][0] = 1;
  
  for(int i=1;i<=N;i++){
    for(int j=0;j<=N;j++){
    for(int k=0;k<=2500;k++){
      if(k-x[i] >= 0 && j-1 >= 0)
        dp[i][j][k] = dp[i-1][j-1][k-x[i]] + dp[i-1][j][k];
      else
        dp[i][j][k] = dp[i-1][j][k];
    }
    }
  }
  for(ll j=1;j<=50 && A*j <= 2500;j++)
    sum += dp[N][j][A*j];
  cout << sum << endl;
  return 0;
}


Measured memory_bytes: 53120
from sys import stdin
n,k = map(int,stdin.readline().split())
a = map(int,stdin.readline().split())
def solve(b):
    req = 0
    ans = 0
    pr = b[0]-1
    for ii in b:
        i = ii
        if i <= pr:
            ans += pr+1-i
            i = pr+1
        pr = i
    return ans


ma = 1<<n
res = 10**38
for mask in xrange(ma):
    b = [a[0]]
    ma = a[0]
    pr = a[0]
    for i in xrange(1,n):
        if mask & (1<<i):
            b.append(a[i])
        elif a[i] > pr:
            b.append(a[i])
            
        pr = max(pr,a[i])
    if len(b)>=k:
        res = min(res, solve(b[:k]))
print res
            

Measured memory_bytes: 2696
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>

#define fo(i,j,l) for(int i=j;i<=l;++i)
#define fd(i,j,l) for(int i=j;i>=l;--i)

using namespace std;
typedef long long ll;
const ll N=22e4;

char s[N];
int len,n,m;
ll L,R;
int app[N][26],p[N];

ll count(ll a,ll b)
{
	if(a<=(n<<1))return a<=n?app[a][b]:app[n][b]+app[a-n][b];
	ll f1=n,f2=m,k1=app[n][b],k2=app[m][b],k3,f3;
	while(f1*2<a){
		f3=f1+f2; f2=f1; f1=f3;
		k3=k1+k2; k2=k1; k1=k3;
	}
	return k3+count(a-f1,b);
}

int main()
{
	scanf("%s",s+1);
	len=strlen(s+1); n=len>>1;
	cin>>L>>R; --L;
	fo(i,1,n){
		fo(l,0,25)app[i][l]=app[i-1][l];
		++app[i][s[i]-97];
	}
	for(int j=0,i=2;i<=n;++i){
		while(j!=0&&s[j+1]!=s[i])j=p[j];
		if(s[j+1]==s[i])++j;
		p[i]=j;
	}
	m=n-p[n];
	fo(i,0,25)printf("%lld ",count(R,i)-count(L,i));
}

Measured memory_bytes: 12288
x = int(input())
score_A = 0
score_B = 0
ans = []
while x:
    for i in range(x):
        y = [int(i) for  i in input().split()]
        if y[0] > y[1]:
            score_A += sum(y)
        elif y[0] < y[1]:
            score_B += sum(y)
        else:
            score_A += y[0]
            score_B += y[1]
    ans.append([score_A,score_B])
    score_A = 0 ; score_B = 0
    x = int(input())
for i in ans:
    print(*i)


Measured memory_bytes: 5616
#!usr/bin/env python3
from collections import defaultdict, deque
from heapq import heappush, heappop
from itertools import permutations, accumulate
import sys
import math
import bisect
def LI(): return [int(x) for x in sys.stdin.buffer.readline().split()]
def I(): return int(sys.stdin.buffer.readline())
def LS():return [list(x) for x in sys.stdin.readline().split()]
def S():
    res = list(sys.stdin.readline())
    if res[-1] == "\n":
        return res[:-1]
    return res
def IR(n):
    return [I() for i in range(n)]
def LIR(n):
    return [LI() for i in range(n)]
def SR(n):
    return [S() for i in range(n)]
def LSR(n):
    return [LS() for i in range(n)]

sys.setrecursionlimit(1000000)
mod = 1000000007

def solve():
    n = I()
    D = defaultdict(lambda : 0)
    ans = 0
    for i in range(n):
        d = [0]*26
        s = input()
        for j in s:
            d[ord(j)-ord("a")] += 1
        td = tuple(d)
        ans += D[td]
        D[td] += 1
    print(ans)
    return

#Solve
if __name__ == "__main__":
    solve()


Measured memory_bytes: 126040
{
  const main = (input: string): void | string | number => {
    const r = reader(input)
    const N = r.n()

    const v = r.ns()
    const c = r.ns()

    let sum = 0

    for (let i = 0; i < N; i++) {
      const k = v[i] - c[i]

      sum += Math.max(0, k)
    }

    return sum
  }

  const reader = (str: string) => {
    const lines = str.trim().split('\n')
    const s = () => lines.shift() || ''
    const n = () => Number(s())

    const ss = () => s().split(' ')
    const ns = () => ss().map(Number)
    const nls = () => lines.map(Number)

    return { lines, s, n, ss, ns, nls }
  }

  const getInput = () => require('fs').readFileSync('/dev/stdin', 'utf8')
  const res = main(getInput())

  if (typeof res === 'number' || typeof res == 'string') console.log(res)
}


Measured memory_bytes: 7500
import collections

n = int(input())

counts = collections.defaultdict(int)
for x in range(2, n + 1):
    for y in range(2, n + 1):
        while x % y == 0:
            counts[y] += 1
            x //= y

def f(a):
    return sum(1 for b in counts if counts[b] >= a - 1)

answer = f(75) \
           + f(5) * (f(5) - 1) * (f(3) - 2) // 2 \
           + f(15) * (f(5) - 1) \
           + f(25) * (f(3) - 1)
print(answer)


Measured memory_bytes: 3572
#pragma GCC optimize("Ofast", "unroll-loops")

#include <bits/stdc++.h>

using namespace std;

int main() {
	int A, B, C, D;
	cin >> A >> B >> C >> D;
	while (1) {
		C -= B; // 高橋君の攻撃
		if (C <= 0) {
			cout << "Yes" << endl;
			break;
		}
		A -= D; // 青木君の攻撃
		if (A <= 0) {
			cout << "No" << endl;
			break;
		}
	}
	return 0;
}

Measured memory_bytes: 3624
function Main(input) {
    input = input.trim().split("\n");
    var N = parseInt(input[0],10);
 
    var tmp = [];
    for(var i = 0; i < N; i++){
        tmp[i] = input[i+1].split(" ")[0] + (999 - parseInt(input[i+1].split(" ")[1],10)) + "," + (i+1);
    }
    tmp.sort();
 
    for(var i = 0; i < N; i++){
        console.log(tmp[i].split(",")[1]);
    }
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 7628
#include "bits/stdc++.h"
#define in std::cin
#define out std::cout
#define rep(i,N) for(int i=0;i<N;++i)
typedef long long int LL;

LL K;
std::vector<LL>ans;

LL f(LL n)
{
	LL res = 0;
	while (n > 0)
	{
		res += n % 10;
		n /= 10;
	}
	return res;
}

int main()
{
	in >> K;
	for (LL i = 0; i <= 15; ++i)
	{
		for (LL j = 1; j <= 1000; ++j)
		{
			if (i == 0 && j == 1) continue;
			LL tmp = j * pow(10LL, i);
			--tmp;
			ans.push_back(tmp);
		}
	}
	std::sort(ans.begin(), ans.end());
	ans.erase(std::unique(ans.begin(), ans.end()), ans.end());
	rep(i, ans.size())
	{
		for (int j = i + 1; j < ans.size(); ++j)
		{
			if ((long double)ans[i] / f(ans[i]) > (long double)ans[j] / f(ans[j]))
			{
				ans.erase(ans.begin() + i);
				--i;
				break;
			}
		}
	}
	rep(i, K) out << ans[i] << std::endl;
	return 0;
}


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

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;
typedef vector<ll> vl;
typedef vector<vl> vvl;
template<typename T> using v = vector<T>;
template<typename T> using pq = priority_queue<T>;
template<typename T> using minpq = priority_queue<T, vector<T>, greater<T>>;
template<typename T, typename K> using ump = unordered_map<T, K>;
const ll dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
const ll mod = 1000000007;
const ll inf = ll(1e9);
const ll e5 = ll(1e5);
const ll ll_inf = ll(1e9) * ll(1e9);

#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define repr(i, n) for(ll i = n - 1; i >= 0; i--)
#define repone(i, n) for(ll i = 1; i <= (ll)(n); i++)
#define each(i, mp) for(auto& i:mp)
#define eb emplace_back
#define F first
#define S second
#define all(obj) (obj).begin(), (obj).end()

template<class T>
void dump_debug(T list) {
#ifdef MY_DEBUG
    each(e, list) cout << e << " ";
    printf("\n");
#endif
}

inline ll inl() {
    ll x;
    cin >> x;
    return x;
}

inline string ins() {
    string x;
    cin >> x;
    return x;
}

const int MAX = 510000;
long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; 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;
}

/* ------------- ANSWER ------------- */
/* ---------------------------------- */

int main() {
#ifdef MY_DEBUG
    while (true) {
#endif
        ll n, k;
        cin >> n >> k;
        COMinit();
        for (long long i = 1; i <= k; ++i) {
            cout << (COM(n - k + 1, i) * COM(k - 1, i - 1)) % mod << endl;
        }

#ifdef MY_DEBUG
    }
#endif
    return 0;
}

Measured memory_bytes: 12160
#include <iostream>
#include <vector>
using namespace std;
int main() {
  int n, k;
  cin>>n>>k;
  vector<int> Ventrada, Vcusto;
  for(int i=0;i<n;i++){
    int j;
    cin>>j;
    Ventrada.push_back(j);
  }
  Vcusto.push_back(0);
  int menor;
  for(int i=1;i<n;i++){
    menor = Vcusto[i-1]+abs(Ventrada[i]-Ventrada[i-1]);
    for(int j=i-k;j<i;j++){
      if(j>=0 && Vcusto[j]+abs(Ventrada[i]-Ventrada[j])<menor){
        menor=abs(Ventrada[i]-Ventrada[j]) + Vcusto[j];
      }
    }
    Vcusto.push_back(menor);
  }
  
  cout<<Vcusto.back()<<endl;
}

Measured memory_bytes: 1400
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>

using namespace std;

vector<string>split(string s){
  vector<string>res;
  int pre = 0;
  for(int i=0;i<s.size();i++){
    if(s[i]=='0'){
      if(i-pre>0)res.push_back(s.substr(pre,i-pre));
      pre = i+1;
    }
  }
  return res;
}

int main(void){

  map<char,string>mp;
  mp['0']="";
  mp['1']=".,!? ";
  mp['2']="abc";
  mp['3']="def";
  mp['4']="ghi";
  mp['5']="jkl";
  mp['6']="mno";
  mp['7']="pqrs";
  mp['8']="tuv";
  mp['9']="wxyz";
  
  int n;
  cin >> n;

  while(n--){
    string s;
    cin >> s;
    vector<string>res = split(s);
    for(int i=0;i<res.size();i++){
      cout << mp[res[i][0]][(res[i].size()-1)%max(1,(int)mp[res[i][0]].size())];
    }
    cout << endl;
  }
  
  return 0;
}

Measured memory_bytes: 3052
using System;
using System.Linq;
using System.Collections.Generic;

class P
{
    static void Main()
    {
        string s = Console.ReadLine();
        if(s[0] == s[1])
        {
            Console.WriteLine("1 2");
            return;
        }
        for (int i = 0; i < s.Length - 2; i++)
        {
            if (s[i] == s[i + 1] || s[i + 1] == s[i + 2] || s[i] == s[i + 2])
            {
                Console.WriteLine($"{i + 1} {i + 3}");
                return;
            }
        }
        Console.WriteLine("-1 -1");
    }
}

Measured memory_bytes: 13280
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define sf scanf
#define pf printf
#define pb push_back
#define MP make_pair
#define llu unsigned long long
#define U unsigned int
#define ff first
#define ss second
#define SIZE 100005
#define pie 3.14159265358979323
#define minuss 1e-6
#define pair pair<ll,ll>
#define fast_cin ios_base::sync_with_stdio(false);cin.tie(NULL)
#define BIG 1000000000
#define INF 1000000000000005
#define N 10000
vector<ll>vec;
map<string,ll> mps;
map<ll,string> mpss;
set<ll>s1;
set<string>s2;
map<string,ll>::iterator str;
set<ll>::iterator itr;
/*
std::cout << std::fixed;
std::cout << std::setprecision(1);
std::cout << VALUE NAME<<endl;
*/
ll tra[100006],tra1[100006];


int main()
{
    fast_cin;
    ll t;

    map<ll,ll>mp;
    map<ll,ll>::iterator it;
    string s,s1;
    ll lock=0,sum=0,co=0;
    ll n,m;
    cin>>n;
    cin>>s;

    for(int i=0; i<n; i++)
    {
        if(s[i]!=s[i+1] && i<=n-1)
        {
             s1+=s[i];
            // cout<<s[i]<<endl;
        }

        else if(i==n-1 && s[i]!=s[i-1])
            s1+=s[i];
    }
    if(s1.length()==0)
        cout<<"1"<<endl;
    else
        cout<<s1.length()<<endl;


    s1.clear();
    vec.clear();

}



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

using namespace std;

int main()
{
	int n;
	int i,j,k;
	
	for(k=0;;k++)
	{
		cin >> n ;
		if(n==0)
			break;
		if(k!=0)
			cout << endl;
		string str[11];
		int win[11],lose[11],drow[11];
		int score[11]={0};
		int num[11];
		for(i=0;i<n;i++)
		{
			num[i]=i;
			cin >> str[i] >> win[i] >> lose[i] >> drow[i] ;
			score[i] = win[i]*3+drow[i];
		}
		for(i=0;i<n-1;i++)
		{
			for(j=i+1;j<n;j++)
			{
				if(score[i]<score[j])
				{
					int a;
					string aa;
					a=score[i];
					score[i]=score[j];
					score[j]=a;
					a=num[i];
					num[i]=num[j];
					num[j]=a;
					aa=str[i];
					str[i]=str[j];
					str[j]=aa;
				}
			}
		}
		for(i=0;i<n-1;i++)
		{
			for(j=i+1;j<n;j++)
			{
				if(score[i]==score[j] && num[i]>num[j])
				{
					int a;
					string aa;
					a=score[i];
					score[i]=score[j];
					score[j]=a;
					a=num[i];
					num[i]=num[j];
					num[j]=a;
					aa=str[i];
					str[i]=str[j];
					str[j]=aa;
				}
			}
		}
		
		for(i=0;i<n;i++)
		{
			cout << str[i] << "," << score[i] << endl;
		}
	}
}

Measured memory_bytes: 0
n = gets.to_i
ps = gets.split.map(&:to_i)
qs = gets.split.map(&:to_i)
p_rank = 0
q_rank = 0
(1..n).to_a.permutation.with_index do |s, i|
  p_rank = i if s == ps
  q_rank = i if s == qs
end

puts (p_rank - q_rank).abs


Measured memory_bytes: 2172
#include <stdio.h>

int main()
{
    int n;
    long long a[100001];
    long long max = 1000000000000000000;
    long long mul = 1;

    scanf("%d", &n);
    for (int i = 0; i < n; i++)
    {
        scanf("%lld", &a[i]);
        if (a[i] == 0)
        {
            printf("0");
            return 0;
        }
    }

    for (int i = 0; i < n; i++)
    {
        // printf("%lld %lld %lld\n", tmp, mul_,mul_ / a[i]);
        // if (i > 0)
        //     if (mul_ / a[i] != tmp||mul_>N)
        //     {
        //         printf("-1");
        //         return 0;
        //     }
        if (a[i] > max)
        {
            printf("-1");
            return 0;
        }
        mul *= a[i];
        max /= a[i];

        
    }
    printf("%lld", mul);
    return 0;
}

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


int main(){
  int k, s, ans = 0;
  cin >> k >> s;
  for(int i = 0; i <= k; i++) for(int j = 0; j <= k; j++) {
    if(0 <= s - i - j && s - i - j <= k) ans++;
  }
  cout << ans << endl;
}
  

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int c,b,a[100001],i;
    a[0]=1;
    cin>>c>>b;
    for(i=1;i<=c;i++)
        a[i]=min(a[i-1]+b,a[i-1]*2);
    cout<<a[c];
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
struct Fast {
    Fast() {
        std::cin.tie(0);
        ios::sync_with_stdio(false);
        cout.precision(20);
    }
} fast;

/* define */
#define FOR(I, X, Y) for(long long(I) = (X); (I) < (Y); (I)++)
#define REP(I, X, Y) for(long long(I) = (Y)-1; (I) >= (X); (I)--)
#define ALL(X) (X).begin(), (X).end()
#define pb push_back
#define COUNT(V, X)                                                            \
    (upper_bound((V).begin(), (V).end(), X) -                                  \
     lower_bound((V).begin(), (V).end(), X))
#define debug(x) cerr << #x << ':' << x << endl;
#define DEBUG(v)                                                               \
    {                                                                          \
        cerr << #v << ':';                                                     \
        for(auto xv : v) cerr << xv << ' ';                                    \
        cerr << endl;                                                          \
    }
#define Yes(X) cout << (X ? "Yes" : "No") << endl;
#define YES(X) cout << (X ? "YES" : "NO") << endl;
#define ctoi(C) (C - '0')
#define pow2(x) ((long long)((long long)1 << x))

/* alias */
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vii = vector<vector<int>>;
using vl = vector<long long>;
using vll = vector<vector<long long>>;
using pi = pair<int, int>;
using pl = pair<long long, long long>;
template <typename T> using PQ = priority_queue<T>;
template <typename T> using minPQ = priority_queue<T, vector<T>, greater<T>>;

/* const */
const long long dx[] = {1, 0, -1, 0};
const long long dy[] = {0, 1, 0, -1};
const long long dx8[] = {1, 1, 0, -1, -1, -1, 0, 1};
const long long dy8[] = {0, 1, 1, 1, 0, -1, -1, -1};
const long long dx9[] = {1, 1, 0, -1, -1, -1, 0, 1, 0};
const long long dy9[] = {0, 1, 1, 1, 0, -1, -1, -1, 0};
const int INF = 1000000007;
const long long LINF = 1000000000000000007;

/* func */
template <typename T1, typename T2> inline bool chmin(T1 &a, const T2 &b) {
    if(a > b) a = b;
    return a > b;
}
template <typename T1, typename T2> inline bool chmax(T1 &a, const T2 &b) {
    if(a < b) a = b;
    return a < b;
}
long long max(long long x, int y) {
    return max(x, (long long)y);
}
long long max(int x, long long y) {
    return max((long long)x, y);
}
long long min(long long x, int y) {
    return min(x, (long long)y);
}
long long min(int x, long long y) {
    return min((long long)x, y);
}

/* liblary */

/* main */

signed main() {
    ll N, K;
    cin >> N >> K;
    ld ans = 0;
    for(size_t i = 1; i <= N; i++) {
        ll n = 0;
        ll x = i;
        ld p = (ld)1.0 / (ld)N;
        while(x < K) {
            n++;
            x *= 2;
            p *= 0.5;
        }
        ans += p;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <string>
#include <bitset>
#include <cstring>
using namespace std;

const char *t1=" ',-.?ABCDEFGHIJKLMNOPQRSTUVWXYZ";
const char *v1[]={"101","000000","000011","10010001","010001","000001","100101","10011010","0101","0001","110","01001","10011011","010000","0111","10011000","0110","00100","10011001","10011110","00101","111","10011111","1000","00110","00111","10011100","10011101","000010","10010010","10010011","10010000"};
const char *t2="ABCDEFGHIJKLMNOPQRSTUVWXYZ .,-'?";

int main(){
  string s,t,z;
  int i,j;
  for(;z=t="",getline(cin,s);cout<<t<<endl){
    for(i=0;i<s.size();i++)
      if((j=strchr(t1,s[i])-t1)+t1)z+=v1[j];
    for(;z.size()%5;z+='0');
    for(i=0;i<z.size()/5;i++)
      t+=t2[bitset<5>(z,i*5,i*5+5).to_ulong()];
  }
}

Measured memory_bytes: 0
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>
#include <cmath>

static const int MOD = 1000000007;
using ll = long long;
using u32 = uint32_t;
using namespace std;

template<class T> constexpr T INF = ::numeric_limits<T>::max()/32*15+208;

int main() {
    int n, m;
    cin >> n >> m;
    vector<int> v(n+1);
    for (int i = 0; i < m; ++i) {
        int l, r;
        cin >> l >> r;
        v[l-1]++; v[r]--;
    }
    for (int i = 0; i < n; ++i) {
        v[i+1] += v[i];
    }
    int ans = 0;
    for (int i = 0; i < n; ++i) {
        if(v[i] == m) ans++;
    }
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <string>
#define len 100000
using namespace std;

struct process{
  string name;
  int time;
};

int n, qms, head, tail;
process p[len];

bool isEmpty(){return head == tail;}

bool isFull(){return head == (tail + 1) % len;}

void enqueue(process x, int qms){
  if(isFull()){
    cout << "Error" << endl;
    return;
  }
  x.time -= qms;
  p[tail] = x;
  //cout << "tail=" << tail << endl;
  if(tail+1 == len){
    tail = 0;
  }else{
    tail++;
  }
}

process dequeue(){
  process x = p[head];
  if(head+1 == len){
    head = 0;
  }else{
    head++;
  }
  //cout << "head " << head << endl;
  return x;
}

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

  for(int i=0; i<n; i++){
    cin >> p[i].name >> p[i].time;
  }

  int total_time = 0;
  head = 0;
  tail = n;
  process x;
  int i = 0;
  while(true){
    if(isEmpty()){break;}
    x = dequeue();
    //cout << i << endl << x.name << endl << total_time << endl;
    if(x.time <= qms){
      total_time += x.time;
      cout << x.name << " " << total_time << endl;
    }else{
      total_time += qms;
      enqueue(x, qms);
    }
    i++;
  }
  return 0;
}



Measured memory_bytes: 7052