akhauriyash/Code-Regression huggingface dataset:
def inpf() a=gets.chomp.split(" ").map(&:to_f)end

def inps() a=gets.chomp.split(" ")end

def copy(a) Marshal.load(Marshal.dump(a)) end

def kaijo(n,r = 10**9+7)(n < 2)? 1 : (2..n).inject{|memo,u|memo=(memo*u)%r} end

def na(n,d=0) Array.new(n,d)end

def na2(n,m,d=0) Array.new(n){Array.new(m,d)}end

def na3(n,m,l,d=0) Array.new(n){Array.new(m){Array.new(l,d)}}end

def inp() a=gets.chomp.split(" ").map(&:to_i)end

def r_up(a, b) (a+b-1)/b end

n,k = inp
s = gets
s[k-1] = s[k-1].downcase
puts s


Measured memory_bytes: 1788
def i():
	return int(input())
def i2():
	return map(int,input().split())
def s():
	return str(input())
def l():
	return list(input())
def intl():
	return list(int(k) for k in input().split())

n,k = i2()
h = intl()

dp = [0]*n
m = 10
for i in range(1,n):
    if i == 1:
        dp[i] = abs(h[i] - h[0])
    else:
        dp[i] = min([int(abs(h[i] - h[i-p]) + dp[i-p]) for p in range(1,k+1) if i-p >= 0])
#print(dp)
print(dp[-1])

Measured memory_bytes: 53216
#include <bits/stdc++.h>
#define rep(i,a,b) for(ll i=ll(a);i<ll(b);i++)
#define irep(i,a,b) for(ll i=ll(a);i>=ll(b);i--)
using ll=long long;
using ld=long double;
using namespace std;
const ll mod=1e9+7;
ll a[200];
int main(){
  ll n,ans=0,tmp=0;
  cin>>n;
  rep(i,0,n)cin>>a[i];
  rep(i,0,n)if(a[i]>=1&&a[i]<=399){ans++;break;}
  rep(i,0,n)if(a[i]>=400&&a[i]<=799){ans++;break;}
  rep(i,0,n)if(a[i]>=800&&a[i]<=1199){ans++;break;}
  rep(i,0,n)if(a[i]>=1200&&a[i]<=1599){ans++;break;}
  rep(i,0,n)if(a[i]>=1600&&a[i]<=1999){ans++;break;}
  rep(i,0,n)if(a[i]>=2000&&a[i]<=2399){ans++;break;}
  rep(i,0,n)if(a[i]>=2400&&a[i]<=2799){ans++;break;}
  rep(i,0,n)if(a[i]>=2800&&a[i]<=3199){ans++;break;}
  rep(i,0,n)if(a[i]>=3200)tmp++;
  if(ans!=0)cout<<ans<<" ";
  else cout<<"1"<<" ";
  cout<<ans+tmp;
}



Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <sstream>
#include <algorithm>
#include <vector>
#include <utility>
#include <functional>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <deque>
#include <ctime>
 
using namespace std;
 
#define rep(i,n) REP(i,0,n)
#define REP(i,s,e) for(int i=(s); i<(int)(e); i++)
#define pb push_back
#define mp make_pair
#define all(r) r.begin(),r.end()
#define fi first
#define se second
#define println(X) cout<<X<<endl;
#define DBG(X) cout<<#X<<" : "<<X<<endl;
 
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vii;
typedef vector<ll> vl;
typedef vector<vl> vll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

const int INF = 1e9;
const ll MOD = 1e9 + 7;
double EPS = 1e-7;

set<pii> st;
vi v;

int main(){
	int n, q;
	cin>>n>>q;
	v = vi(n+1, 0);
	rep(i, n){
		st.insert(mp(0, i+1));
	}
	int a, b;
	pii p;
	rep(i, q){
		cin>>a>>b;
		st.erase(st.find(mp(v[a], a)));
		v[a]-=b;
		st.insert(mp(v[a], a));
		p = *st.begin();
		cout<<p.se<<" "<<-p.fi<<endl;
	}
}
 

Measured memory_bytes: 53432
var
    nm,i,x:longint;
    n:string;
begin
    readln(n);
    x:=pos(' ',n);//找空格
    delete(n,x,1);//把空格删去，即为合并
    val(n,nm);
    for i:=1 to trunc(sqrt(nm)) do//为优化，优化时间，虽说有很多蒟蒻会直接写（毕竟...你见过除一以外的数的平方等于这个数么）
    if(sqr(i)=nm)then//判断不解释哦
    begin
        writeln('Yes');
        exit;//这个其实可以不用，因为没有一个数是两个或两个以上得数的平方数
    end;
    writeln('No');
end.

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define FOR(i, m, n) for (ll i = m; i < n; i++)
#define IFOR(i, m, n) for (ll i = n - 1; i >= m; i--)
#define REP(i, n) FOR(i, 0, n)
#define IREP(i, n) IFOR(i, 0, n)
#define FOREACH(x, a) for (auto&(x) : (a))
#define ALL(v) (v).begin(), (v).end()
#define SZ(x) ll(x.size())

int main() {
  string s;
  cin >> s;
  ll sum = 0;
  for (char c : s) {
    ll d = c - '0';
    sum += d;
  }
  cout << (sum % 9 == 0 ? "Yes" : "No") << endl;
}

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

using ll = long long;
//print(fixed << setprecision(10));
#define rep(i,n) for(ll i = 0; i < (n); i++)
#define repk(i,n,k) for(ll i = k; i < (n); i++)
#define all(n) n.begin(), n.end()
#define print(n) cout << n << endl
double PI = acos(-1.0);
int INF = 1e9;
ll LINF = 1e18;
ll MOD = 1e9+7;


int main(){
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    
    int x,y;
    cin >> x >> y;
    if(y&1){
        print("No");
    }else{
        if(y<2*x || y>4*x) print("No");
        else print("Yes");
    }
    return 0;
}

Measured memory_bytes: 3612
#include <iostream>
#include <algorithm>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <bitset>
#include <complex>
#include <functional>
#include <numeric>

// output
#define SPBR(w, n) std::cout<<(w + 1 == n ? '\n' : ' ');
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl
// utility
#define ALL(i) (i).begin(), (i).end()
#define FOR(i, a, n) for(int i=(a);i<(n);++i)
#define RFOR(i, a, n) for(int i=(n)-1;i>=(a);--i)
#define REP(i, n) for(int i=0;i<int(n);++i)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define IN(a, x, b) (a<=x && x<b)
#define OUT(a, x, b) (x<a || b<=x)
template<class T> inline T chmax(T & a, const T b) { return a = (a < b) ? b : a; }
template<class T> inline T chmin(T& a, const T b) { return a = (a > b) ? b : a; }

// type/const
#define int ll
using ll = long long;
using ull = unsigned long long;
using ld = long double;
const int MOD = 1000000007;
/* const int MOD = 998244353; */
const int INF = 1e18;
const double PI = acos(-1);

using namespace std;


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

  int N = 99;
  vector<vector<char>> s(99, vector<char>(99, '#'));

  REP(i, N/2) REP(j, N) s[i][j] = '.';

  for(int i = 1; i < N; i += 2){
    for(int j = 1; j < N; j += 2){
      if(--B > 0) s[i][j] = '#';
    }
  }
  for(int i = 51; i < N; i += 2){
    for(int j = 1; j < N; j += 2){
      if(--A > 0) s[i][j] = '.';
    }
  }

  cout << "99 99" << endl;
  REP(i, N){
    REP(j, N) cout << s[i][j];
    cout << endl;
  }

  return 0;
}

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

using namespace std;

typedef long long ll;

unsigned euclidean_gcd(unsigned a, unsigned b) {
    if(a < b) return euclidean_gcd(b, a);
    unsigned r;
    while ((r=a%b)) {
        a = b;
        b = r;
    }
    return b;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N;
    cin >> N;
    vector<int> a(N);
    vector<int> l(N);
    vector<int> r(N);
    for (int i = 0; i < N; i++) {
        cin >> a[i];
        if (i == 0) {
            l[0] = a[0];
        } else {
            l[i] = euclidean_gcd(l[i-1], a[i]);
        }
    }

    for (int i = 0; i < N; i++) {
        if (i == 0) {
            r[0] = a[N-1];
        } else {
            r[i] = euclidean_gcd(r[i-1], a[N-i-1]);
        }
    }


    vector<int> gcd(N);
    for (int i = 0; i < N; i++) {
        if (i == 0) {
            gcd[0] = r[N-2];
        } else if (i == N-1) {
            gcd[N-1] = l[N-2];
        } else {
            gcd[i] = euclidean_gcd(l[i-1], r[N-i-2]);
        }
    }

    auto i = std::max_element(gcd.begin(), gcd.end());
    cout << *i << endl;
    return 0;
}

Measured memory_bytes: 1792
#include<iostream>
#include<cstdio>
#include<string>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
using namespace std;
typedef long long ll;
const ll MOD = 1000000007;
const ll INF = (ll)1000000007 * 1000000007;
const double EPS = 1e-9;
typedef pair<int, int> P;
typedef unsigned int ui;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef long double ld;
const ld eps=1e-8;
int main() {
	ll x[10] = { 0,1,2,3,4,5,6,7,8,9 };
	string s; cin >> s;
	int len = s.length();
	ll ch = 0; ll a = 1;
	per(i, len) {
		ch += (s[i]-'0') * a; a *= (ll)10;
	}
	ll sum = 0; a = (ll)1;
	per(i, len) {
		sum += x[i] * a; a *= (ll)10;
	}
	ll ma = sum; ll z[10] = { 0,1,2,3,4,5,6,7,8,9 };
	while (next_permutation(x, x + 10)) {
		sum = 0; a = 1;
		per(i, len) {
			sum += x[i] * a; a *= 10;
		}
		ll dif;
		if (ch > sum) {
			dif = min(ch - sum, sum + a - ch);
		}
		else {
			dif = min(sum - ch, ch + a - sum);
		}
		if (ma < dif) {
			ma = dif;
			rep(i, 10) {
				z[i] = x[i];
			}
		}
	}
	rep(i,len) {
		cout << z[i];
	}
	cout << endl;
	return 0;
}


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

int main() 
{
    ll a, b;
    cin >> a >> b;
    if(a>0&&a<10&&b>0&&b<10)
    {
        cout << a * b << endl;
    }
    else
    {
        cout << -1 << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>//sort,reverse
#include<utility>//pair
#include<queue>//queue,priority_queue
#include<deque>//double_ended queue
using namespace std;
typedef pair<int,int> P;//Pでpair<-,->を表す。
typedef long long LL; 
LL MOD=1000000007;


int main()
{ 
    int h;
    int w;
    cin>>h>>w;
    if(w>h){h=w;}
    int n;
    cin>>n;
    if(n%h==0){
        cout<<n/h<<endl;
    }
    else{cout<<n/h+1<<endl;}
    return 0;
}

Measured memory_bytes: 256
fun main(args: Array<String>) {
    val input = readLine()!!.split(" ")
    val n=input[0].toInt()
    val k=input[1].toLong()
    val ab = (1..n).map{
        readLine()!!.split(" ").map{it.toInt()}
    }.sortedBy { it[0] }

    var x=0L
    ab.forEach {
        x+=it[1]
        if(x>=k){
            println(it[0])
            return
        }
    }
}

Measured memory_bytes: 84848
package main

import (
  "bufio"
  "fmt"
  "os"
  "strconv"
  "strings"
)

func main() {
  input := Input{bufio.NewReaderSize(os.Stdin,100)}
  n,u := input.NextInts()
  dp := make([]int,100002)
  for i:=1;i<100002;i++ { dp[i] = 2*u }
  for i:=0;i<n;i++ {
    w,v := input.NextInts()
    for j:=100001;j>v-1;j-- {
      t := dp[j-v]+w
      if dp[j] > t { dp[j] = t }
    }
  }
  for i:=100001;i>-1;i-- {
    if dp[i] <= u { fmt.Println(i);return }
  }
}

type Input struct { reader *bufio.Reader }
func(i *Input) NextLine() string {
  var buffer []byte
  for {
    line,isPrefix,err := i.reader.ReadLine()
    if err != nil { panic(err) }
    buffer = append(buffer,line...)
    if !isPrefix { break }
  }
  return string(buffer)
}
func(i *Input) NextInts() (int,int) {
  s := strings.Split(i.NextLine()," ")
  a,_ := strconv.Atoi(s[0])
  b,_ := strconv.Atoi(s[1])
  return a,b
}

Measured memory_bytes: 1408
#include <iostream>
#include <map>
using namespace std;
typedef long long ll;
int main() {
    int n, m, a, b;
    ll c=0;
    map<int, int> p;
    cin>>n>>m>>b;
    b%=m;
    p[0]++;
    p[b]++;
    for(int i=1;i<n;i++){
        cin>>a;
        b+=a;
        b%=m;
        p[b]++;
    }
    for(auto x=p.begin();x!=p.end();x++){
        ll d=x->second;
        
        c+=d*(d-1)/2;
    }
    cout<<c<<endl;
	return 0;
}

Measured memory_bytes: 3200
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#define mod 1000000007;
#define lol(i,n) for(int i=0;i<n;i++)
typedef long long ll;
using namespace std;

ll dp[303][303][303];
int rest[310][4];

bool Cando(int a,int b,int c){
	int e1=max(a,max(b,c));
	int e3=min(a,min(b,c));
	int e2=a+b+c-e1-e3;
	if(rest[e1][1]<=e2&&e2<rest[e1][0]&&rest[e1][3]<=e3&&e3<rest[e1][2]){
		return true;
	}
	return false;
}

int main(){
	int n,m;
	cin>>n>>m;
	lol(i,n+1){
		rest[i][0]=mod;//left1
		rest[i][2]=mod;//left2
		rest[i][1]=-1;//right2
		rest[i][3]=-1;//right3
	}
	lol(i,m){
		int a,b,c;
		cin>>a>>b>>c;
		if(c==1)rest[b][0]=min(rest[b][0],a);
		if(c==3)rest[b][3]=max(rest[b][3],a);
		if(c==2){
			rest[b][1]=max(rest[b][1],a);
			rest[b][2]=min(rest[b][2],a);
		}
	}
	lol(i,n+1)lol(j,n+1)lol(k,n+1)dp[i][j][k]=0;
	dp[0][0][0]=1;
	
	for(int len=0;len<=n;len++){
		for(int i=0;i<max(1,len);i++){
			for(int j=0;j<max(1,i);j++){
				
			int R=len,G=i,B=j;
			if(Cando(R,G,B)==false)continue;
				
			int a=len+1,b=G,c=B;
			int e1=max(a,max(b,c));
			int e3=min(a,min(b,c));
			int e2=a+b+c-e1-e3;
			dp[e1][e2][e3]+=dp[R][G][B];
			dp[e1][e2][e3]%=mod;
			
			a=R,b=len+1,c=B;
			e1=max(a,max(b,c));
			e3=min(a,min(b,c));
			e2=a+b+c-e1-e3;
			dp[e1][e2][e3]+=dp[R][G][B];
			dp[e1][e2][e3]%=mod;
			
			a=R,b=G,c=len+1;
			e1=max(a,max(b,c));
			e3=min(a,min(b,c));
			e2=a+b+c-e1-e3;
			dp[e1][e2][e3]+=dp[R][G][B];
			dp[e1][e2][e3]%=mod;
			}
		}
	}
	
	ll ans=0;
	for(int i=0;i<n;i++){
		for(int j=0;j<max(i,1);j++){
			if(Cando(n,i,j)){
				ans+=dp[n][i][j];
				ans%=mod;
			}
		}
	}
	ans%=mod;
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 217344
mod=10**9+7
n,k=map(int,input().split())
arr=list(map(int,input().split()))
cnt_plus=0
cnt_zero=0
cnt_minus=0
arr_plus=[]
arr_minus=[]
for i in range(n):
  if arr[i]>0:
    cnt_plus+=1
    arr_plus.append(arr[i])
  elif arr[i]<0:
    cnt_minus+=1
    arr_minus.append(-arr[i])
  else:
    cnt_zero+=1
if cnt_plus+cnt_minus<k:
  print(0)
  exit()
if k==n:
  if cnt_zero!=0:
    print(0)
  else:
    ans=1
    for i in range(cnt_plus):
      ans*=arr_plus[i]
      ans%=mod
    for i in range(cnt_minus):
      ans*=arr_minus[i]
      ans%=mod
    if cnt_minus%2==0:
      print(ans)
    else:
      print((-ans)%mod)
  exit()
if cnt_plus==0 and k%2==1:
  if cnt_zero!=0:
    print(0)
  else:
    arr_minus=sorted(arr_minus)
    tmp=1
    for i in range(k):
      tmp*=arr_minus[i]
      tmp%=mod
    print((-tmp)%mod)
  exit()
else:
  arr_plus=sorted(arr_plus,reverse=True)
  arr_minus=sorted(arr_minus,reverse=True)
  if k%2==0:
    ans=1
    pos_plus=0
    pos_minus=0
    cnt=0
  else:
    ans=arr_plus[0]
    pos_plus=1
    pos_minus=0
    cnt=1
  while cnt<k:
    cand1=0
    if pos_plus<=cnt_plus-2:
      cand1=arr_plus[pos_plus]*arr_plus[pos_plus+1]      
    cand2=0
    if pos_minus<=cnt_minus-2:
      cand2=arr_minus[pos_minus]*arr_minus[pos_minus+1]
    if cand1>=cand2:
      pos_plus+=2
      ans*=cand1
      ans%=mod
    else:
      pos_minus+=2
      ans*=cand2
      ans%=mod
    cnt+=2
  print(ans)
  exit()

Measured memory_bytes: 31728
n = int(input())
P = list(map(int,input().split()))
I = list(map(int,input().split()))

post = 0
ans = []
def reconstruction(l,r):
    global post
    if l >= r:
        return None
    c = P[post]
    post += 1
    for i in range(n):
        if c == I[i]:
            reconstruction(l,i)
            reconstruction(i+1,r)
    ans.append(c)

reconstruction(0,n)

for i,a in enumerate(ans):
    if i != n-1:
        print(a,end=" ")
    else:
        print(a)



Measured memory_bytes: 5600
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
 
public class Main {
	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
 
		String input = br.readLine();
 
		if (input.indexOf("N") == -1) {
			if (input.indexOf("S") != -1) {
				System.out.println("No");
				return;
			}
 
		} else {
			if (input.indexOf("S") == -1) {
				System.out.println("No");
				return;
			}
		}
 
		if (input.indexOf("E") == -1) {
			if (input.indexOf("W") != -1) {
				System.out.println("No");
				return;
			}
		} else {
			if (input.indexOf("W") == -1) {
				System.out.println("No");
				return;
			}
		}
 
		System.out.println("Yes");
 
	}
}

Measured memory_bytes: 8020
#include <stdio.h>

int main()
{
  int x, y, n;

  scanf("%d %d",&x, &y);

  if(x<y){
    n = x;
    x = y;
    y = n;
  }
  while((n = x % y)!=0){
    x = y;
    y = n;
  }
  printf("%d\n",y);
  return 0;
}

Measured memory_bytes: 592
import java.util.Scanner;

public class Main {

    public static void main(String args[]) {

        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.next());
        int t = Integer.parseInt(sc.next());
        Integer[] cost = new Integer[n];
        Integer[] time = new Integer[n];
        for (int i = 0; i < n; i++) {
            cost[i] = Integer.parseInt(sc.next());
            time[i] = Integer.parseInt(sc.next());
        }

        int minCost = 1001;
        for (int i = 0; i < n; i++) {
            if (time[i] <= t) {
                minCost = Math.min(minCost, cost[i]);
            }
        }

        System.out.println(minCost > 1000 ? "TLE" : minCost);
    }
}

Measured memory_bytes: 21588
#define _USE_MATH_DEFIMES
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cctype>
#include <climits>
#include <clocale>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <regex>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

const int MOD = 1'000'000'007;
const int INF = 1'000'000'000; //1e9
const int NIL = -1;
const long long LINF = 1'000'000'000'000'000'000; // 1e18
const long double EPS = 1E-10;

template<class T, class S> inline bool chmax(T &a, const S &b){
    if(a < b){
        a = b; return true;
    }
    return false;
}
template<class T, class S> inline bool chmin(T &a, const S &b){
    if(b < a){
        a = b; return true;
    }
    return false;
}








int main(){
    int n; std::cin >> n;
    std::vector<int> r(n), c(n);
    for(int i(0); i < n; ++i) std::cin >> r[i] >> c[i];
    //dp[i][j] := iからjまでの計算に必要な回数
    std::vector<std::vector<int>> dp(n, std::vector<int>(n, 0));
    for(int d(1); d < n; ++d){
        for(int i(0), i_len(n - d); i < i_len; ++i){
            int j(i + d);
            dp[i][j] = INF;
            for(int k(i); k < j; ++k){
                chmin(dp[i][j], dp[i][k] + dp[k+1][j] + r[i]*c[k]*c[j]);
            }
        }
    }
    std::cout << dp[0][n-1] << std::endl;
    return 0;
}



Measured memory_bytes: 3196
import java.util.*

fun main(args: Array<String>) {
    val sc = Scanner(System.`in`)
    val n = sc.nextInt()
    val a = (0 until n).map { sc.next().toInt() }
    println(problem2016b(n, a))
}

fun problem2016b(n: Int, a: List<Int>): Int {
    val map = mutableMapOf<Int, Int>()
    var count = 0
    for (i in 0 until n) {
        if (map.containsKey(a[i]) && map[a[i]] == i+1) count++
        map[i+1] = a[i]
    }
    return count
}

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

using namespace std;

#define DUMP(x) std::cout << (#x) << " = " << (x) << "\n"
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define REP(i, k, n) for (int i = (k); i < (int)(n); ++ i)
#define ALL(r) r.begin(), r.end()
#define YES puts("YES")
#define Yes puts("Yes")
#define NO puts("NO")
#define No puts("No")
#define IMP puts("IMPOSSIBLE")
#define Imp puts("Impossible")
#define imp puts("impossible")
#define pb push_back

template<typename T> T DUP(T x, T y) { return (x + y - 1) / y; };
template <typename A, size_t N, typename T>
void arrayFill(A(&array)[N], const T& val) {
    std::fill((T*)array, (T*)(array + N), val);
}
using ll = int64_t;
using vint = vector<int32_t>;
using vvint = vector<vint>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vstr = vector<string>;
using pint = pair<int32_t, int32_t>;
using setint = unordered_set<int32_t>;
using setstr = unordered_set<string>;
using qint = queue<int32_t>;

constexpr std::int32_t INF = 1001001001;
constexpr std::int64_t LINF = 1001001001001001001;

void Main() {
    int n;
    string s;
    cin >> n >> s;

    char prev = '\t';
    int ans = 0;
    rep(i, n) {
        if (s[i] != prev) {
            ++ans;
            prev = s[i];
        }
    }
    cout << ans << endl;
}

int main() {
    std::cin.tie(nullptr);
    std::ios_base::sync_with_stdio(false);
    std::cout << std::fixed << std::setprecision(15);
    Main();
    return 0;
}


Measured memory_bytes: 512
n = int(input())
h = list(map(int, input().split()))

dp = [0]*(n)
dp[1] = abs(h[1] - h[0])
for i in range(2, n):
  dp[i] = min(dp[i-1] + abs(h[i-1] - h[i]), dp[i-2] + abs(h[i-2] - h[i]))
print(dp[-1])

Measured memory_bytes: 20380
#include <bits/stdc++.h>
using namespace std;
#define LOCAL
#pragma region Macros
typedef long long ll;
#define ALL(x) (x).begin(),(x).end()
const long long MOD=1000000007;
// const long long MOD=998244353;
const int INF=1e9;
const long long IINF=1e18;
const int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};
const char dir[4]={'D','R','U','L'};

template<typename T>
istream &operator>>(istream &is,vector<T> &v){
    for (T &x:v) is >> x;
    return is;
}
template<typename T>
ostream &operator<<(ostream &os,const vector<T> &v){
    for (int i=0;i<v.size();++i){
        os << v[i] << (i+1==v.size()?"": " ");
    }
    return os;
}
template<typename T,typename U>
ostream &operator<<(ostream &os,const pair<T,U> &p){
    os << '(' << p.first << ',' << p.second << ')';
    return os;
}
template<typename T,typename U>
ostream &operator<<(ostream &os,const map<T,U> &m){
    os << '{';
    for (auto itr=m.begin();itr!=m.end();++itr){
        os << '(' << itr->first << ',' << itr->second << ')';
        if (++itr!=m.end()) os << ',';
        --itr;
    }
    os << '}';
    return os;
}
template<typename T>
ostream &operator<<(ostream &os,const set<T> &s){
    os << '{';
    for (auto itr=s.begin();itr!=s.end();++itr){
        os << *itr;
        if (++itr!=s.end()) os << ',';
        --itr;
    }
    os << '}';
    return os;
}

void debug_out(){cerr << '\n';}
template<class Head,class... Tail>
void debug_out(Head&& head,Tail&&... tail){
    cerr << head;
    if (sizeof...(Tail)>0) cerr << ", ";
    debug_out(move(tail)...);
}
#ifdef LOCAL
#define debug(...) cerr << " ";\
cerr << #__VA_ARGS__ << " :[" << __LINE__ << ":" << __FUNCTION__ << "]" << '\n';\
cerr << " ";\
debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

template<typename T> T gcd(T x,T y){return y!=0?gcd(y,x%y):x;}
template<typename T> T lcm(T x,T y){return x/gcd(x,y)*y;}

template<class T1,class T2> inline bool chmin(T1 &a,T2 b){
    if (a>b){a=b; return true;} return false;
}
template<class T1,class T2> inline bool chmax(T1 &a,T2 b){
    if (a<b){a=b; return true;} return false;
}
#pragma endregion

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N; cin >> N;
    int seq=0,ans=0;
    for (;N--;){
        int a,b; cin >> a >> b;
        if (a==b) ++seq;
        else seq=0;
        if (seq==3) ans=1;
    }

    cout << (ans?"Yes":"No") << '\n';
}

Measured memory_bytes: 3636
#include <iostream>
#include <vector>
#include <deque>
#include <math.h>
#include <set>
#include <iomanip>
#include <time.h>
#include <list>
#include <stdio.h>
#include <queue>
#include <map>
#include <algorithm>
#include <assert.h>
#include <memory.h>

#define mk make_pair
#define sc second
#define fr first
#define pb emplace_back
#define all(s) s.begin(), s.end()
#define sz(s) ( (int)s.size() )

using namespace std;

string z = "AKIHABARA", o = "A";

bool check(string s)
{
    if (sz(s) == 9)
        return s == z;

    string em, suf = s;

    for (int i = 0; i <= sz(s); i++)
    {
        for (int j = 0; j < sz(o); j++)
        {
            if (check( em + o[j] + suf ) )
                return true;
        }
        if (i < sz(s))
            em += s[i],
            suf.erase(0, 1);
    }
    return false;
}

string s;

main ()
{
    cin >> s;
    if (sz(s) > 9 )
        puts("NO");
    else if (check(s))
        puts("YES");
    else
        puts("NO");
}


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

main()
{
long long int A,B,C,D,x=1,y,z,a,b,c,ar[1000],br[1000],cr[1000],n,aaa,k,i,r=0,rr=0,d1,dd=0,d2,d3,ck=0,m,j,aa,bb,cc;
//char cr[1000];
//scanf("%lld",&n);
cin>>A>>B>>C>>D;

    aa=C;
    bb=D;

   m=__gcd(C,D);

  // cout<<m<<endl;
   x=(C*D)/m;

   //cout<< "x"<<x;

//cout<<"hh"<<x<<"         ";

   k=abs(B-A)+1;
   //cout<<y;
  if(A%C==0){
        d1=(B/C)-(A/C)+1;
        }
   else{
         d1=(B/C)-(A/C);

   }


   if(A%D==0)
    {
        d2=(B/D)-(A/D)+1;
    }
    else{
        d2=(B/D)-(A/D);
    }


if(A%x==0){

   d3=(B/x)-(A/x)+1;
}
else{
    d3=(B/x)-(A/x);
}
  // cout<<d1<<d2;

   cc=k-(d1+d2-d3);

  cout<<cc;
//printf("%lld",dd);

    return 0;
}

Measured memory_bytes: 256
/*
AizuOnline A0502
Title Dice
*/
#include <stdio.h>
#include <string.h>
int t,s,e,n,w,b;
int NN;
char op[6];
char order[]="NEWSRL";
//
void change(int s1,int s2,int s3,int s4,int *d1,int *d2,int *d3,int *d4)
{
        int w1,w2,w3,w4;

        w1=s1,w2=s2;w3=s3;w4=s4;
        *d1=w1;*d2=w2,*d3=w3;*d4=w4;
}
int rot(char * op)
{
        int num;
        
        num=strchr(order,op[0])-order;
        switch(num)
        {
        case 0://north
                change(t,s,b,n,&n,&t,&s,&b); 
                break;
        case 1://east
                change(t,w,b,e,&e,&t,&w,&b);                
                break;
        case 2://west
                change(t,e,b,w,&w,&t,&e,&b);
                break;
        case 3://south
                change(t,n,b,s,&s,&t,&n,&b); 
                break;
        case 4://right
                change(e,n,w,s,&s,&e,&n,&w); 
                break;
        case 5://left
                change(s,e,n,w,&e,&n,&w,&s); 
                break;
        }
        return(t);
}

main()
{
        int i,sum;;

        while(EOF!=scanf("%d",&NN) && NN)
        {
                sum=1; //init value
                t=1;s=2;e=3;n=5;w=4;b=6;

                for(i=0;i<NN;i++)
                {
                        scanf("%s",op);
                        sum += rot(op);
                        //printf("TNWESB%d %d %d %d %d %d\n",t,n,w,s,e,b);
                }
                printf("%d\n",sum);
        }
return(0);
}

Measured memory_bytes: 608
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, a, b) for (int i = (a); i < (b); i++)
#ifdef tabr
#include "library/debug.cpp"
#else
#define debug(...) 0
#endif

template <ll mod>
struct modular {
    ll value;
    modular(ll x = 0) {
        value = x % mod;
        if (value < 0) value += mod;
    }

    modular& operator+=(modular other) {
        if ((value += other.value) >= mod) value -= mod;
        return *this;
    }
    modular& operator-=(modular other) {
        if ((value -= other.value) < 0) value += mod;
        return *this;
    }
    modular& operator*=(modular other) {
        value = value * other.value % mod;
        if (value < 0) value += mod;
        return *this;
    }
    modular& operator/=(modular other) {
        ll u = 0, v = 1, w = other.value, m = mod;
        while (w != 0) {
            ll t = m / w;
            m -= t * w;
            swap(w, m);
            u -= t * v;
            swap(u, v);
        }
        value = value * u % mod;
        if (value < 0) value += mod;
        return *this;
    }
    modular& operator^=(modular other) {
        ll r = 1, x = value, n = other.value;
        while (n > 0) {
            if (n & 1) r = r * x % mod;
            x = x * x % mod;
            n >>= 1;
        }
        value = r;
        return *this;
    }
    modular operator+(modular rhs) {
        return modular(*this) += rhs;
    }
    modular operator-(modular rhs) {
        return modular(*this) -= rhs;
    }
    modular operator*(modular rhs) {
        return modular(*this) *= rhs;
    }
    modular operator/(modular rhs) {
        return modular(*this) /= rhs;
    }
    modular operator^(modular rhs) {
        return modular(*this) ^= rhs;
    }
    bool operator==(modular rhs) {
        return value == rhs.value;
    };
    bool operator!=(modular rhs) {
        return value != rhs.value;
    };
    bool operator<(modular rhs) {
        return value < rhs.value;
    }
};
template <ll mod>
string to_string(modular<mod> x) {
    return to_string(x.value);
}
template <ll mod>
ostream& operator<<(ostream& stream, modular<mod> x) {
    return stream << x.value;
}
template <ll mod>
istream& operator>>(istream& stream, modular<mod>& x) {
    stream >> x.value;
    x.value %= mod;
    if (x.value < 0) x.value += mod;
    return stream;
}
const ll mod = 1e9 + 7;
using mint = modular<mod>;

vector<mint> fac;
void cinit(int n) {
    fac.resize(n, 1);
    for (int i = 2; i < n; i++) {
        fac[i] = fac[i - 1] * i;
    }
}

mint C(int n, int k) {
    if (n < k || k < 0 || n < 0) return 0;
    return fac[n] / fac[k] / fac[n - k];
}

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

    cinit(5000);
    int n, k;
    cin >> n >> k;
    vector<mint> ans(k + 1);
    rep(i, 1, k + 1) {
        cout << (C(n - k + 1, i) * C(k - 1, i - 1)) << endl;
    }
    return 0;
}

Measured memory_bytes: 256
import itertools

def main():
    N, K = map(int, input().split())
    S = input()

    A = []
    tmp = S[0]
    cnt = 0
    for i in range(len(S)):
        if S[i] == tmp:
            cnt += 1
        else:
            A.append(cnt)
            tmp = S[i]
            cnt = 1
    else:
        A.append(cnt)

    B = list(itertools.accumulate([0] + A))
    ans = 0
    if S[0] == '1':
        for i in range(1,len(B)+1,2):
            right = i + 2 * K
            if right >= len(B):
                right = len(B) - 1
            tmp = B[right]-B[i-1]
            ans = max(ans, B[right]-B[i-1])
    if S[0] == '0':
        C = [0] + B
        for i in range(1,len(C)+1,2):
            right = i + 2 * K
            if right >= len(C):
                right = len(C) - 1
            tmp = C[right]-C[i-1]
            ans = max(ans, C[right]-C[i-1])

    print(ans)

    
main()

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

#define MOD (1000000000+7)

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

	if( K % 2 ) {
		cout << 0 << endl;
		return 0;
	}
	K /= 2;
	vector<vector<vector<long long>>> dp( n + 1, vector<vector<long long>>( n + 1, vector<long long>( K + 1 + n ) ) );
	dp[0][0][0] = 1;
	for( int i = 0; i < n; i++ ) {
		for( int j = 0; j <= i; j++ ) {
			for( int k = 0; k <= K; k++ ) {
				dp[i + 1][j][k + j] += dp[i][j][k];
				dp[i + 1][j][k + j] %= MOD;
				dp[i + 1][j + 1][k + j + 1] += dp[i][j][k];
				dp[i + 1][j + 1][k + j + 1] %= MOD;
				dp[i + 1][j][k + j] += dp[i][j][k] * 2 * j;
				dp[i + 1][j][k + j] %= MOD;
				if( j > 0 ) {
					dp[i + 1][j - 1][k + j - 1] += dp[i][j][k] * j * j;
					dp[i + 1][j - 1][k + j - 1] %= MOD;
				}
			}
		}
	}

	long long ans = dp[n][0][K];

	cout << ans << endl;
}


Measured memory_bytes: 27264
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define chmin(x,y) x = min(x,y)
#define chmax(x,y) x = max(x,y)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;

int main() {
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);
  ll n, a, b;
  cin >> n >> a >> b;
  ll temp = n / (a+b);
  ll ans;
  if (n - (a+b)*temp > a) ans = a*temp + a;
  else ans = a*temp + n - (a+b)*temp;
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
n, k = map(int, input().split())
info = [list(map(int, input().split())) for i in range(n)]


set_ = set([k])
for i in range(k.bit_length()):
    if (k >> i) & 1:
        mask1 = (1 << i) - 1
        mask2 = (1 << k.bit_length() + 1) - 1 - (1 << i)
        set_.add((k | mask1) & mask2)

ans = 0
for bit_state in set_:
    tmp_ans = 0
    for w, val in info:
        if bit_state | w == bit_state:
            tmp_ans += val
    ans = max(tmp_ans, ans)
print(ans)

Measured memory_bytes: 61272
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define MOD (ll) (1e9+7)
int main()
{
	ll d,t,s;
	cin>>d>>t>>s;
	double no_hrs = d/(double)(s);
	if(no_hrs<=t)
	{
		cout<<"Yes\n";
	}
	else{
		cout<<"No\n";
	}
}

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

using namespace std;

int n,m,b;
map<int,vector<int> > adj;
map<int,bool> vis;
long long a[200005],nm[200005];

void dfs(int node,int sm){
    a[node] += sm;
    vis[node] = 1;
    for(int i = 0 ; i < adj[node].size() ; i ++){
        int f = adj[node][i];
        if(vis[f]){
            continue;
        }
        dfs(f,sm + nm[f]);
    }
}

int main()
{
    cin >> n >> m;
    for(int i = 0 ; i < n - 1 ; i ++){
        int x,y;
        cin >> x >> y;
        adj[x].push_back(y);
        adj[y].push_back(x);
    }
    for(int i = 0 ; i < m ; i ++){
        int x,y;
        cin >> x >> y;
        nm[x] += y;
    }
    dfs(1,nm[1]);
    for(int i = 1 ; i <= n ; i ++){
        if(i > 1){
            cout << " ";
        }
        cout << a[i];
    }
    cout << endl;
    return 0;
}


Measured memory_bytes: 55296
#include <iostream>
#include <sstream>
#include <string>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cassert>

using namespace std;

#define FOR(i,k,n) for(int i=(k); i<(int)(n); ++i)
#define REP(i,n) FOR(i,0,n)
#define FORIT(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)

template<class T> void debug(T begin, T end){ for(T i = begin; i != end; ++i) cerr<<*i<<" "; cerr<<endl; }
inline bool valid(int x, int y, int W, int H){ return (x >= 0 && y >= 0 && x < W && y < H); }

typedef long long ll;
const int INF = 100000000;
const double EPS = 1e-8;
const int MOD = 1000000007;
int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
int N;
inline bool infected(int S, int x, int y){
  return S >> (y * N + x) & 1;
}
int next(int S, int bx, int by){
  int NS = 0;
  for(int y = 0; y < N; y++){
    for(int x = 0; x < N; x++){
      if(bx == x && by == y) continue;
      int cnt = 0;
      for(int r = 0; r < 8; r++){
        if(valid(x + dx[r], y + dy[r], N, N) && infected(S, x + dx[r], y + dy[r]))cnt++;
        if(bx == x + dx[r] && by == y + dy[r]) cnt++;
        if(cnt >= 4) break;
      }
      if(infected(S, x, y) && (cnt == 2 || cnt == 3)) NS |= 1 << (y * N + x);
      if(!infected(S, x, y) && cnt == 3) NS |= 1 << (y * N + x);
    }
  }
  return NS;
}
void output(int bx, int by, int s, int t){
  printf("time = %d:\n", t);
  REP(y, 5){
    REP(x, 5){
      if(x == bx && y == by){
        assert(!infected(s, x, y));
        putchar('@');
      }else if(infected(s, x, y)){
        putchar('#');
      }else{
        putchar('.');
      }
    }
    putchar('\n');
  }
  putchar('\n');
}

int main(){
  while(cin >> N && N){
    vector<string> grid(N);
    REP(i, N) cin >> grid[i];
    int ss = 0, sx = 0, sy = 0;
    REP(y, N) REP(x, N) {
      if(grid[y][x] == '@'){
        sx = x, sy = y;
      }
      if(grid[y][x] == '#'){
        ss |= 1 << (y * N + x);
      }
    }
    queue<int> qs, qx, qy;
    qx.push(sx); qy.push(sy); qs.push(ss);
    int t = 0;
    qx.push(-1); qy.push(-1); qs.push(-1);
    set<int> visit[5][5];
    int ans = -1;
    while(qx.size() > 1){
      int x = qx.front(), y = qy.front(), s = qs.front();
      qx.pop(); qy.pop(); qs.pop();
      if(s == 0){
        ans = t;
        break;
      }
      if(s == -1){
        t++;
        qx.push(-1); qy.push(-1); qs.push(-1);
        continue;
      }
      REP(r, 8){
        int nx = x + dx[r];
        int ny = y + dy[r];
        if(valid(nx, ny, N, N) && !infected(s, nx, ny)){
          int ns = next(s, nx, ny);
          if(visit[ny][nx].insert(ns).second){
            qx.push(nx); qy.push(ny); qs.push(ns);
          }
        }
      }
    }
    cout << ans << endl;
  }
  return 0;
}

Measured memory_bytes: 2528
#include<stdio.h>
#define N 3
int main(){
    char s[N];
    int ans=0,i;

    scanf("%s",s);

    for(i=0; i<=N; i++){
        if('+' == s[i])ans++;
        if('-' == s[i])ans--;
        }
    
    printf("%d\n",ans);

}

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

using namespace std;

#define int long long
#define FOR(i, a, b) for(ll i = (a); i < (b); ++i)
#define FORR(i, a, b) for(ll i = (a); i > (b); --i)
#define REP(i, n) for(ll i = 0; i < (n); ++i)
#define REPR(i, n) for(ll i = n; i >= 0; i--)
#define FOREACH(x, a) for(auto &(x) : (a))
#define VECCIN(x)                                                              \
    for(auto &youso_ : (x)) cin >> youso_
#define mp make_pair
#define bitcnt __builtin_popcount
#define SZ(x) ((ll)(x).size())
#define All(a) (a).begin(), (a).end()
template <typename T = long long> inline T IN() {
    T x;
    cin >> x;
    return (x);
}
inline void CIN() {}
template <class Head, class... Tail>
inline void CIN(Head &&head, Tail &&... tail) {
    cin >> head;
    CIN(move(tail)...);
}
#define CINT(...)                                                              \
    int __VA_ARGS__;                                                           \
    CIN(__VA_ARGS__)
#define LCIN(...)                                                              \
    ll __VA_ARGS__;                                                            \
    CIN(__VA_ARGS__)
#define SCIN(...)                                                              \
    string __VA_ARGS__;                                                        \
    CIN(__VA_ARGS__)
#define Yes(a) cout << (a ? "Yes" : "No") << "\n"
#define YES(a) cout << (a ? "YES" : "NO") << "\n"
#define Printv(v)                                                              \
    {                                                                          \
        FOREACH(x, v) { cout << x << " "; }                                    \
        cout << "\n";                                                          \
    }
template <typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val) {
    std::fill((T *)array, (T *)(array + N), val);
}

typedef long long ll;
typedef unsigned long long ul;
typedef vector<ll> VL;
typedef pair<ll, ll> PL;
typedef priority_queue<ll> PQ;
typedef priority_queue<ll, VL, greater<ll>> PQG;

const int INF = 1e9;
const int MOD = 1e9 + 7;
// const int MOD = 998244353;
const ll LINF = 1e18 + 1;
const ll dx[] = {1, -1, 0, 0};
const ll dy[] = {0, 0, 1, -1};

ll N;
VL A;

signed main() {
    cin >> N;
    ll ans = 0;
    REP(i, N) {
        A.emplace_back(IN());
        if(A[0] != 0 || (i > 0 && A[i] > A[i - 1] + 1)) {
            cout << -1 << "\n";
            return 0;
        } else if(i > 0 && A[i] != A[i - 1] + 1)
            ans += A[i - 1];
    }
    ans += A[N - 1];
    cout << ans << "\n";
}


Measured memory_bytes: 2420
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pcc pair<char,char>
#define vi vector <int>
#define vl vector <ll>
#define sd(x) scanf("%d",&x)
#define slld(x) scanf("%lld",&x)
#define pd(x) printf("%d",x)
#define plld(x) printf("%lld",x)
#define pds(x) printf("%d ",x)
#define pllds(x) printf("%lld ",x)
#define pdn(x) printf("%d\n",x)
#define plldn(x) printf("%lld\n",x)
#define INF 2e9
#define INFLL 4e18
using namespace std;
ll powmod(ll base,ll exponent,ll mod){ // with mod < 1e9
	ll ans=1;
	while(exponent){
		if(exponent&1)ans=(ans*base)%mod;
		base=(base*base)%mod;
		exponent/=2;
	}
	return ans;
}
ll gcd(ll a, ll b){
	if(b==0) return a;
	else return gcd(b,a%b);
}
const int upperlimit = 2e5+100;
const int mod = 1e9+7;
int main() {
	ll x,a,b;
	slld(x);
	a=100;
	for(int i = 1; ;i++){
		b=a/100;
		a+=b;
		if(a>=x){
			pd(i);break;
		}
	}
	return 0;
}

Measured memory_bytes: 3828
local read = setmetatable({}, {__index = function(t, k) local a = {} for i=1,#k do table.insert(a, '*'..string.sub(k, i, i)) end local r = io.read local u = table.unpack or unpack return function() return r(u(a)) end end})
read.N = function(N) local t={} for i=1,N do t[i]=read.n() end return t end
string.totable = function(s) local t={} local u=string.sub for i=1,#s do t[i] = u(s, i, i) end return t end
string.split = function(s) local t={} for w in string.gmatch(s, "[^%s]+") do table.insert(t, w) end return (table.unpack or unpack)(t) end
local function array(dimension, default_val) assert(type(default_val) ~= 'table') local n=dimension local m={}if default_val~=nil then m[1]={__index=function()return default_val end}end for i=2,n do m[i]={__index=function(p, k)local c=setmetatable({},m[i-1])rawset(p,k,c)return c end}end return setmetatable({},m[n])end
local function open(...) for _,t in pairs{...} do for k,v in pairs(t) do _G[k]=v end end end
----
open(table, math)
local A = {"a", "b", "c", "d", "e", "f", "g", "h", "i", "j"}
local N = read.n()

local ans = {}
local q = {["b"]=1, ["f"]=1}
local function count()
    return q.f - q.b
end
local function pop()
    local a = q[q.b]
    q[q.b] = nil
    q.b = q.b + 1
    return unpack(a)
end
local function push(a)
    q[q.f] = a
    q.f = q.f + 1
end

push({0,0,{}})
while count() > 0 do
    local i,mx,t = pop()
    if i == N then
        insert(ans, concat(t, ""))
    else
        for j=1,mx+1 do
            local n = {unpack(t)}
            insert(n, A[j])
            push {i+1, max(j,mx), n}
        end
    end
end
for i=1,#ans do
    print(ans[i])
end

Measured memory_bytes: 71532
/*
    Zeolim - An AC a day keeps the bug away
*/
  
//#pragma GCC optimize(2)
//#pragma GCC ("-W1,--stack=128000000")
#include <bits/stdc++.h>
using namespace std;
#define mp(x, y) make_pair(x, y)
#define fr(x, y, z) for(int x = y; x < z; ++x)
#define pb(x) push_back(x)
#define mem(x, y) memset(x, y, sizeof(x))
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef std::pair <int, int> pii;
typedef std::vector <int> vi;
void re(ll &x){x=0;char s=getchar();while(s<'0'||s>'9')s=getchar();while(s>='0'&&s<='9'){x=x*10+s-'0';s=getchar();}}
void wr(ll x){if(x>9) wr(x/10);putchar(x%10+'0');}
const ld PI = acos(-1.0);
const ld E = exp(1.0);
const ll INF = 0x3f3f3f3f3f3f3f3f;
const ll MOD = 386910137;
const ull P = 13331;
const int MAXN = 1e6 + 100;
 
ld a, b, x, y;
 
ld to(ld x) { return (x / 180.0) * PI; }
ld ret(ld x) { return x / PI * 180.0; }
 
ld cal(ld deg)
{
	if(deg >= y)
	{
		ld rb = a * tan(PI / 2.0 - deg) ;
		return a * b * a - a * rb / 2.0 * a;
	}
	else
	{
		ld ra = b * tan(deg);
		return (b * ra / 2.0 * a);
	}
}
 
 
int main()
{  
    //ios::sync_with_stdio(0);
    //cin.tie(0); cout.tie(0);
    //freopen("d:\out.txt","w",stdout);
    //freopen("d:\in.txt","r",stdin);  
  	
  	cin >> a >> b >> x;
  	
  	y = atan2(a, b);
  	
  	ld fst = 0, lst = PI / 2.0, mid;
  	
  	for(int i = 0; i < 1000; ++i)
  	{
  		mid = (fst + lst) / 2.0;
  		
  		if(cal(mid) >= x)
  			lst = mid;
  		else
  			fst = mid;
	}
	  
	cout << fixed << setprecision(10) << 90.0 - mid / PI * 180.0 << '\n';
    
    return 0;
}


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

int main() {
  
  int A,B,K;
  cin >> A >> B >> K;
  
  if (B - A + 1 >= K) {
    for (int i = 0; i < K; i++) 
      cout << A + i << endl;
    if (A + K - 1 < B - (K - 1)) {
      for (int i = 0; i < K; i++)
        cout << B - (K - i - 1)  << endl;
    }
    else {
      for (int i = A + K; i <= B; i++)
        cout << i << endl;
    }
  }
  else {
    for (int i = A; i <= B; i++)
      cout << i << endl;
  }
  
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
string s;
long long dfs(long long a,long long b,long long c)
{
	if(a==s.size())
		return(b*(c==0));
	return(dfs(a+1,b,c*10+s[a]-'0')+dfs(a+1,b+c*10+s[a]-'0',0));
}
int main()
{
	cin>>s;
	cout<<dfs(0,0,0);

	return 0;
}

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

int h, w, a, b;

int main()
{
    scanf("%d%d", &h, &w);
    scanf("%d%d", &a, &b);
    int r = h / a, c = w / b;
    printf("%d\n", h * w - r * c * a * b);
}



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

using namespace std;


string temp7;
typedef unsigned long long ull;

ull K,tempdiv,out;

int main()
{
    cin>>K;

    tempdiv = 7 % K;

    for(ull i = 1; i<=K; i++){
        tempdiv = tempdiv % K;

        if(tempdiv == 0){
            cout<<i<<endl;
            return 0;
        }

        tempdiv = tempdiv * 10 + 7;
    }

    cout<<"-1 \n";
    return 0;
}


Measured memory_bytes: 3628
package main

import (
	"fmt"
	"sort"
)

type ivec []int

// コレクション内の要素数
func (v ivec) Len() int { return len(v) }

// インデックスiで示される要素がインデックスjの前に並び替えるべきかを返す
func (v ivec) Less(i, j int) bool { return v[i] > v[j] }

// インデックスi,jの要素を入れ替える
func (v ivec) Swap(i, j int) { v[i], v[j] = v[j], v[i] }

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

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

	sort.Sort(mochi)

	count := 0
	for i := 0; i < n; i++ {
		if i == 0 {
			count++
		}
		if i != n-1 && mochi[i] != mochi[i+1] {
			count++
		}
	}
	fmt.Println(count)
}


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

using namespace std;

#define Rep(b, e, i) for (ll i = b; i <= e; i++)
#define Repr(e, b, i) for (ll i = e; i >= b; i--)
#define rep(n, i) Rep(0, n - 1, i)
#define repr(n, i) Repr(n - 1, 0, i)
#define all(v) (v).begin(), (v).end()
#define pb(v) push_back(v)
#define uniq(v) (v).erase(unique(all(v)), (v).end())
#define bitcnt(x) __builtin_popcount(x)
#define fst first
#define snd second
#define Pqaz(T) priority_queue<T, vector<T>, greater<T>>
#define Pqza(T) priority_queue<T>
#define put(x) cout << x;
#define putsp(x) cout << x << ' ';
#define putbd cout << "---------------------------------------------" << endl;
#define putln(x) cout << x << endl;
#define debug(x) cerr << #x << "=" << x << endl;
#define ENJYU std::ios::sync_with_stdio(false) std::cin.tie(0);

typedef long long ll;
typedef pair<ll, ll> llP;
typedef pair<int, int> intP;
typedef complex<double> comp;
typedef vector<int> vec;
typedef vector<ll> vecll;
typedef vector<double> vecd;
typedef vector<vec> mat;
typedef vector<vecll> matll;
typedef vector<vecd> matd;

template <class T>
ostream &operator<<(ostream &o, const vector<T> &v)
{
	o << "{";
	for (int i = 0; i < (int)v.size(); i++)
		o << (i > 0 ? ", " : "") << v[i];
	o << "}";
	return o;
}

const int MAX = 1000010;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const int INF = 1 << 29;
const ll INFL = 1e18;
const ll MOD = 1e9+7;

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

//********************************template END****************************************//

void solve()
{
	int N;
	cin >> N;
	long ans = 0;
	priority_queue<pair<long long, int>> q;
	vec used(N);
	vecll as(N), bs(N);
	rep(N, i)
	{
		cin >> as[i] >> bs[i];
		q.emplace(as[i]+bs[i], i);
	}
	int turn = 0;
	while (turn < N)
	{
		auto p = q.top();
		q.pop();
		int i = p.second;
		if (used[i]) continue;
		if (turn % 2 == 0)
		{
			ans += as[i];
		}
		else
		{
			ans -= bs[i];
		}
		used[i] = 1;
		turn++;
	}

	cout << ans << endl;
}

int main()
{
	solve();
	//cout << "yui(*-v・)yui" << endl;
	return 0;
}


Measured memory_bytes: 4340
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <numeric>
#include <cmath>

using namespace std;

typedef long long int ll;

#define all(x) x.begin(),x.end()

const ll mod = 1e9+7;
const ll INF = 1e9;
const ll MAXN = 1e5;


map<ll, ll> prime_factor(ll n)
{
	map<ll, ll> res;

	for(ll i = 2; i * i <= n; i++)
	{
		while(n % i == 0)
		{
			++res[i];
			n /= i;
		}
	}

	if (n != 1)
	{
		res[n] = 1;
	}

	return res;
}

vector<ll> fact,inv;

ll f(ll a,ll b, ll p)  // a^b mod pを求める
{
	if (b == 0)
	{
		return 1;
	}else if (b % 2 == 0)
	{
		ll d = f(a,b/2,p);  //a^b = a^(2k) = (a^k)^2  k = b / 2
		return d * d % mod;
	}else
	{
		return a * f(a,b-1,p) % mod;
	}
}

void init(ll n)
{
	fact.resize(n+1,1);
	inv.resize(n+1,1);

	for(int i = 2; i <= n; i++)  //　nまでの階乗を求める
	{
		fact[i] = fact[i-1] * i % mod;
	}
	for(int i = 2; i <= n; i++)  //a^(-1) mod p = a^(p-2) mod p  ここをもう少し早くできるぽい
	{
		inv[i] = f(fact[i],mod-2,mod) % mod;
	}
}

ll comb(ll n,ll k)  //n_C_k
{
	if (n < k)
	{
		return 0;
	}
	return (fact[n] * inv[k] % mod) * inv[n-k] % mod;
}
int main()
{
	ll n,m;
	cin >> n >> m;
	map<ll,ll> pf = prime_factor(m);

	init(MAXN+100);

	ll ans = 1;
	for(auto itr = pf.begin();  itr != pf.end() ; ++itr){
		ans *= comb(itr->second+n-1,itr->second);
		ans %= mod;
	}

	cout << ans << endl;


	return 0;
}

Measured memory_bytes: 1792