akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
#include <functional>
#include <vector>
#include <string>
#include <map>
#include <sstream>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <stdexcept>
#include <utility>
// #include <bits/stdc++.h>
#define ll long long
#define ld long double
#define rep(i,h) for(int i = 0; i < h; ++i)
#define rep1(i,h) for(int i = 0; i <= h; ++i)
#define rep2(i,n,h) for(int i = n; i < h; ++i)
#define rep3(l,n,h) for(int l = n; i <= h; ++i)
using namespace std;


    int main() {
        double n, k;
        cin >> n >> k;
        vector<int> a(n);
        rep(i,n) cin >> a.at(i);
        // this (n-1) / (k-1) is Dividing (n-1) numbers by (k-1),(n-1) is element in all sequence excluding 1 and I can change (k-1) elements to 1 at a time.
        int ans = ceil((n - 1) / (k - 1));
        // ceil method can round up.
        cout << ans << endl;
        return 0;
    }


Measured memory_bytes: 640
# https://atcoder.jp/contests/abc098/tasks/arc098_b

N = int(input())
A = list(map(int, input().split()))


# しゃくとり法
res = 0
right = 0
sum_a = 0
for left in range(N):
    while right < N and (sum_a ^ A[right]) == (sum_a + A[right]):
        sum_a += A[right]
        right += 1
    res += right - left
    
    # update
    if left == right:
        right += 1
    else:
        sum_a ^= A[left]

print(res)

Measured memory_bytes: 77900
#[allow(unused_macros)]
macro_rules ! read_value {($ next : expr , ($ ($ t : tt ) ,* ) ) => {($ (read_value ! ($ next , $ t ) ) ,* ) } ; ($ next : expr , [$ t : tt ; $ len : expr ] ) => {(0 ..$ len ) . map (| _ | read_value ! ($ next , $ t ) ) . collect ::< Vec < _ >> () } ; ($ next : expr , chars ) => {read_value ! ($ next , String ) . chars () . collect ::< Vec < char >> () } ; ($ next : expr , usize1 ) => {read_value ! ($ next , usize ) - 1 } ; ($ next : expr , $ t : ty ) => {$ next () . parse ::<$ t > () . expect ("Parse error" ) } ; }
#[allow(unused_macros)]
macro_rules ! input_inner {($ next : expr ) => {} ; ($ next : expr , ) => {} ; ($ next : expr , $ var : ident : $ t : tt $ ($ r : tt ) * ) => {let $ var = read_value ! ($ next , $ t ) ; input_inner ! {$ next $ ($ r ) * } } ; }
#[allow(unused_macros)]
macro_rules ! input {(source = $ s : expr , $ ($ r : tt ) * ) => {let mut iter = $ s . split_whitespace () ; let mut next = || {iter . next () . unwrap () } ; input_inner ! {next , $ ($ r ) * } } ; ($ ($ r : tt ) * ) => {let stdin = std :: io :: stdin () ; let mut bytes = std :: io :: Read :: bytes (std :: io :: BufReader :: new (stdin . lock () ) ) ; let mut next = move || -> String {bytes . by_ref () . map (| r | r . unwrap () as char ) . skip_while (| c | c . is_whitespace () ) . take_while (| c |! c . is_whitespace () ) . collect () } ; input_inner ! {next , $ ($ r ) * } } ; }

fn main() {
    input! {
        n: usize,
        a_: [i32; n],
    }
    let mut a = a_.clone();
    a.sort();
    a.reverse();

    let mut ret = 0;
    for i in 0..a.len() {
        if i % 2 == 0 {
            ret += a[i];
        } else {
            ret -= a[i];
        }
    }

    println!("{}", ret);
}


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

using namespace std;
typedef long long ll;
#define rep(i, j, n) for (int i = j; i < n; i++)
#define out(ans) cout << ans << endl;
const long long mod = 1e9 + 7;

int main(){

  ll a,b,x;cin>>a>>b>>x;

  out((b/x)-(a/x)+(a%x==0));

  return 0;
}


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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define fin(x) cout << x << endl;

using namespace std;
using ll = long long;

int main(void) {
  int n;
  cin >> n;
  vector<int> vec(n);
  rep(i, n) {
    cin >> vec[i];
  }
  int min = 0;
  int tmp;
  rep(i, n) {
    min += abs((vec[i] - vec[0]) * (vec[i] - vec[0]));
  }
  sort(all(vec));
  rep(i, vec[n - 1]) {
    tmp = 0;
    rep(j, n) {
      tmp += abs((i - vec[j]) * (i - vec[j])); 
    }
    if (tmp < min) {
      min = tmp;
    }
  }
  cout << min << endl;
	return 0;
}



Measured memory_bytes: 256
import java.util.Scanner;
import java.util.Set;
import java.util.TreeSet;

public class Main {


    public static void main(String[] args) {
    	Scanner sc=new Scanner(System.in);

    	String s=sc.next();

    	int K=sc.nextInt();

    	Set<String> subs=new TreeSet<String>();

    	for(int l=1;l<=K;l++) {


    		for(int i=0;i<s.length();i++) {

    			if(i+l<=s.length()) {
    				subs.add(s.substring(i,i+l));
    			}else {
    				break;
    			}
    		}


    	}

    	int counter=1;

    	for(String str:subs) {

    		if(counter==K) {
    			System.out.println(str);
    			return ;
    		}

    		counter++;

    	}
    }


}







Measured memory_bytes: 24020
#n = int(input())
#a, b = map(int,input().split())
#l = list(map(int,input().split()))
#l = [list(map(int,input().split())) for i in range(n)]
s=input()
k=len(s)-2
print("{0}{1}{2}".format(s[0],str(k),s[-1]))

Measured memory_bytes: 9024
n = int(input())

arr = map(int,raw_input().split())

ans = 0

for i in range(n-1):
	if arr[i] == i+1:
		arr[i],arr[i+1] = arr[i+1],arr[i]
		ans += 1

print ans if arr[n-1] != n else ans + 1

Measured memory_bytes: 11328
import sys
input = sys.stdin.readline

n = int(input())
h = list(map(int, input().split()))
cnt = 0
dp = [0]*n
dp[1] = abs(h[1]-h[0])
for i in range(2, n):
    i_1 = dp[i-1] + abs(h[i]-h[i-1])
    i_2 = dp[i-2] + abs(h[i]-h[i-2])
    if i_1 > i_2:
        dp[i] = i_2
    else:
        dp[i] = i_1
print(dp[n-1])

Measured memory_bytes: 14016
#include <bits/stdc++.h>
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
typedef long long ll;
using namespace std;
const int MOD = 1000000007;
const int INF = 1010000000;
const double EPS = 1e-10;
const array<pair<int,int>,4> fd{make_pair(1,0),make_pair(-1,0),make_pair(0,1),make_pair(0,-1)}; 

int main(){
  string s,t;cin>>s>>t;
  int sl = s.length(), tl = t.length();
  for(int i = sl - tl;i>=0;i--){
    bool possible = true;
    rep(j,tl){
      if(s[i+j] != t[j] && s[i+j] != '?'){
        possible = false;
        break;
      }
    }
    if(possible){
      rep(j,i){
        if(s[j] == '?')cout << 'a';
        else cout << s[j];
      }
      cout << t;
      repd(j,i+tl,sl){
        if(s[j] == '?')cout << 'a';
        else cout << s[j];
      }
      cout << endl;
      return 0;
    }
  }
  cout << "UNRESTORABLE" << endl; 
}
// ?tc???? sl = 7, coder tl = 5


Measured memory_bytes: 256
//To debug :  g++ -g file.cpp -o code
//to flush output : fflush(stdout) or cout.flush()
//cout<<setprecision(p)<<fixed<<var
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i,a,n) for(i=a;i<n;++i)
#define irep(i,n,a) for(i=n;i>a;--i)
#define mod 1000000007
#define pb push_back
#define big 9223372036854775807
#define big1 LONG_MAX
#define big2 INT_MAX
#define big3 1000000000
#define sma1 LONG_MIN
#define sma2 INT_MIN
#define sma3 -1000000000
#define mp make_pair
#define dub double
#define ivec vector<int>
#define lvec vector<long long>
#define cvec vector<char>
#define svec vector<string>
#define mt make_tuple
#define PI acos(-1)
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); 

ll num=0,den=1;
ll dow[200002];
ll po2[200002];
ll par[200002];

void calc_po2()
{
	ll i,v=1;

	for(i=0;i<200002;++i)
	{
		po2[i]=v;
		v = (v*2)%mod;
	}

}

void dfsrec(vector<ll> *adj,ll nod,bool *vis)
{
	//mark this node 'nod' visited , see all of it's adjacent 
	//vertices and if they are not visited then call 'dfsrec'

	vis[nod]=true;

	ll i=0,siz = adj[nod].size();
	dow[nod]=1;

	for(i=0;i<siz;++i)
	{
		if(!vis[adj[nod][i]])
		{
			dfsrec(adj,adj[nod][i],vis);
			dow[nod] += dow[adj[nod][i]];
			par[adj[nod][i]]=nod;
		}
	}

}


void dfs(vector<ll> *adj,ll n)
{
	

	ll i;
	bool vis[n] = {false};
	par[0]=-1;
	dfsrec(adj,0,vis);

}

long long powt[64];
long long sumpow2(long long num,long long *arr)
{
	long long i,j;
	if(powt[0] == 0)
	{
		powt[0]=1;
		for(i=1;i<64;++i)
			powt[i]=powt[i-1]*2;
	}
	i=0;
	j=0;
	while(num>0)
	{
		if(powt[i]==num)
		{
			arr[j]=i;
			num-=powt[i];
			++j;
		}
		else if(powt[i]>num)
		{
			arr[j]=i-1;
			num-=powt[i-1];
			i=0;
			++j;
		}
		else
			++i;
	
	}

	return j;	
}

long long modinv(long long num,long long prime)
{
	long long var = prime-2,j,i;
	
	ll arr[100];

	j=sumpow2(var,arr);

	long long ans[100];

	ans[0]=num%prime;

	for(i=1;i<=arr[0];++i)
	{
		ans[i] = (ans[i-1]*ans[i-1])%prime;
	}

	for(i=1;i<j;++i)
	{
		ans[arr[0]+i] = (ans[arr[0]+i-1]*ans[arr[i]])%prime;
	}

	return ans[arr[0]+j-1];
}



void sum_it(ll &tn,ll &td,ll p,ll q)
{
	tn = ((q*tn)%mod + (p*td)%mod)%mod;
	td = (td*q)%mod;
}


int main()
{

	ll n,u,v,i,d,ans,j,tn,td,tot,var,p;

	cin>>n;

	vector<ll> adj[n];

	for(i=0;i<(n-1);++i)
	{
		cin>>u>>v;
		adj[u-1].pb(v-1);
		adj[v-1].pb(u-1);
	}

	dfs(adj,n);
	calc_po2();

	p=tot=po2[n-1];



	for(i=0;i<n;++i)
	{
		tn=0;
		td=1;

		if(adj[i].size()==1)
			continue;

		for(auto cov : adj[i])
		{


			if(cov==par[i])
			{
				var=n-dow[i];
				var=po2[var];
			}
			else
			{
				var=po2[dow[cov]];
			}


			var = (var-1)%mod;

			if(var<0)
				var = (var+mod)%mod;

			sum_it(tn,td,var,tot);

		}

		sum_it(tn,td,1,tot);

		tn = (td-tn)%mod;
		if(tn<0)
			tn = (tn+mod)%mod;

		td = (2*td)%mod;

		sum_it(num,den,tn,td);

	}

	ans = (num * modinv(den,mod))%mod;

	cout<<ans<<"\n";

	return 0;
}

Measured memory_bytes: 25344
#include <bits/stdc++.h>
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<bool> VB;
typedef vector<double> VD;
typedef vector<string> VS;
typedef vector<char> VC;
typedef vector<VC> VVC;
typedef pair<int, int> PII;
typedef long long LL;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;

//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 SQ(a) ((a)*(a))
#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())
#define LB lower_bound
#define UB upper_bound

//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);
const LL INF = 1e9;
const LL MOD = 1e9+7;

//other
//-------------------------------------------
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define FI first
#define SE second

//memo
// setprecision()

LL Gcd(LL a, LL b) {
  if (a < b) {
    return Gcd(b,a);
  }
  if (b == 0) {
    return a;
  }
  else {
    return Gcd(b,a%b);
  }
}

LL Lcm(LL a, LL b) {
  LL abd = Gcd(a,b);
  LL x = a / abd, y = b / abd;
  
  return x*y*abd;
}


LL RepSqu(LL N, LL P, LL M) {
  if(P == 0) {
    return 1;
  }
  if(P%2 == 0) {
    LL t = RepSqu(N, P/2, M);
    return t*t % M;
  }
  return (N * RepSqu(N, P-1, M)) % M;
}


int main() {
  
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  string S,A,B;
  int Q, u=1;
  cin >> S >> Q;
  
  REP(i,Q){
    int T;
    cin >> T;
    
    
    if(T == 1){
      u *= -1;
      
    }else if(T == 2){
      int F;
      char C;
      cin >> F >> C;
      
      if(F == 1){
        if(u == 1){
          A += C;
        }else if(u == -1){
          B += C;
        }
        
      }else if(F == 2){
        if(u == -1){
          A += C;
        }else if(u == 1){
          B += C;
        }
      }
    }
  }
  

  if(u == -1){
    reverse(ALL(S));
    reverse(ALL(B));
    cout << B << S << A << endl;
  }else if(u == 1){
    reverse(ALL(A));
    cout << A << S << B << endl;
  }
    
  return 0;
}

Measured memory_bytes: 1040
#include<bits/stdc++.h>
using namespace std;
#define int long long int
#define MOD 1000000007

int dp[2005];

//int ans = 0;
int solve(int n){
   //cout << n << endl;
   if(n == 0)
   {
     // cout << "count\n";
      //ans += 1;
      //ans %= MOD;
      return 1;
   }
   if(n < 3)
     return 0;
  if(dp[n] != -1)
     return dp[n]; 
   dp[n] = 0;
   for(int i = 3; i <= n; i++){
       if(n - i >= 0)
        dp[n] += solve(n - i);
        dp[n] %= MOD;
   }
   return dp[n];
}

int32_t main(){
    int n;
    cin >> n;
    memset(dp, -1, sizeof(dp));
    cout << solve(n);
}

Measured memory_bytes: 3624
# coding: utf-8

(moji_len, query_count) = [int(i) for i in input().rstrip().split(" ")]

mojiretu = input().rstrip()

count_ac = [0]
for i in range(1, moji_len):
    count_ac.append(count_ac[i-1])
    if mojiretu[i] == "C":
        if mojiretu[i-1] == "A":
            count_ac[i] += 1

ans = []
for i in range(query_count):
    q = [int(i) - 1 for i in input().rstrip().split(" ")]
    cnt = count_ac[q[1]]
    if q[0] > 0:
        cnt -= count_ac[q[0] - 1]
        if mojiretu[q[0] - 1] == "A" and mojiretu[q[0]] == "C":
            cnt -= 1
    ans.append(cnt)

for i in ans:
    print(i)


Measured memory_bytes: 10300
N, M = map(int, input().split())
AB = []
for i in range(N):
  AB.append(list(map(int, input().split())))
CD = []
for i in range(M):
  CD.append(list(map(int, input().split())))
idx = 0
for i in range(N):
  d0 = 9900000000
  for j in range(M):
    d = abs(AB[i][0]-CD[j][0])+abs(AB[i][1]-CD[j][1])
    if d0 > d:
      d0 = d
      idx = j+1
  print(idx)

Measured memory_bytes: 3064
#include <iostream>
#include <stdio.h>
using namespace std;

const int M=2e5+5;
int a[M];

int main()
{
	int n; scanf("%d",&n);
	for(int i=1;i<=n;i++)
		scanf("%d",&a[i]);
	int cnt=0;
	for(int i=n;i>=1;i--)
	{
		for(int j=2;i*j<=n;j++)
			a[i]=(a[i]+a[i*j])%2;
		if(a[i]) cnt++;
	}
	printf("%d\n",cnt);
	for(int i=1;i<=n;i++)
		if(a[i]) printf("%d ",i);
	printf("\n");
	return 0;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define BIG 1000000010
#define repi(i,x,n) for(int i=x;i<n;i++)
#define rep(i,n) repi(i,0,n)
#define repn(i,n) for(int i=n;i>=0;i--)
typedef long long int ll;

int n,m;
int ans=0;
int g[8][8];
int c[8]={1,0,0,0,0,0,0,0};

void solve(int p,int cnt){
  if(cnt==n) ans++;
  else{
    rep(i,n){
      if(g[i][p]==1 && c[i]==0){
	c[i]=1;
	solve(i,cnt+1);
	c[i]=0;
      }
    }
    
  } 
}


int main(){
  cin>>n>>m;
  rep(i,8){
    rep(j,8) g[i][j]=0;
  }
  int a,b;
  rep(i,m){
    cin>>a>>b;
    g[a-1][b-1]=g[b-1][a-1]=1;
  }
  solve(0,1);
  cout<<ans<<endl;
  return 0;
}






Measured memory_bytes: 256
n, q = (int(x) for x in input().split())
s = input()
t = [0]*(n+1)
for i in range(n):
  t[i+1] = t[i] + (1 if s[i : i + 2] == 'AC' else 0)
for i in range(q):
  l,r = (int(x) for x in input().split())
  print(t[r-1]-t[l-1])

Measured memory_bytes: 7748
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <ctime>
#include <cstring>
#include <functional>
#include <iostream>
#include <iomanip>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <regex>
#include <vector>

#define fix(n)          cout<<fixed<<setprecision(n)
#define rep(i,n)        for (int i = 0; i < (n); ++i)
#define sort(a)         sort((a).begin(), (a).end())
#define uniq(a)         SORT(a);(a).erase(unique((a).begin(), (a).end()), (a).end())
#define reverse(a)      reverse((a).begin(), (a).end())
#define ctos(c)         string(1, (c))
#define out(d)          cout << (d)
#define outl(d)         std::cout<<(d)<<"\n"
#define YES()           cout << "YES" << endl
#define NO()            cout << "NO" << endl
#define Yes()           cout << "Yes" << endl
#define No()            cout << "No" << endl
#define ceil(x, y)      ((x + y - 1) / (y))
#define debug(x)        cerr << #x << ": " << (x) << '\n'
#define debug2(x, y)    cerr << #x << ": " << (x) << ", " << #y << ": " << (y) << '\n'
#define debug3(x, y, z) cerr << #x << ": " << (x) << ", " << #y << ": " << (y) << ", " << #z << ": " << (z) << '\n'
#define dbg(v)          for (size_t _ = 0; _ < v.size(); ++_){ cerr << #v << "[" << _ << "] : " << v[_] << '\n'; }

using namespace std;
using ll = long long;
using P = pair<ll,ll>;

const ll MOD = 1000000007; // 10^9 + 7

void solve() {
  int n; cin >> n;
  int min = ceil(25 * n, 27);
  double max = 25 * (n + 1) / 27.0;
  max = max == int(max) ? int(max) - 1 : int(max);
  // debug2(min, max);
  if (min <= max) outl(min);
  else outl(":(");
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  srand((unsigned)time(NULL));
  fix(12);

  solve();
}


Measured memory_bytes: 256
#include <cstdio>
#include <stdlib.h>
#include <iostream>
#include <string>
using namespace std;

int main(void)
{
	int N;



	while(cin >> N,N){

	string str;
	cin >> str;

	char c;
	int co;
	while(N > 0){
		N--;
		string t;
		co = 1;
		c = str[0];
		for(int i = 1; i < str.size(); i++){
			if(str[i] == c)
				co++;
			else{
				char s[10];
				sprintf(s, "%d", co);
				t += s;
				t.push_back(c);

				c = str[i];
				co = 1;
			}
		}
				char s[10];
				sprintf(s, "%d", co);
				t += s;
				t.push_back(c);




		str = t;

	}

	cout << str.c_str() << endl;
	}
	return 0;
}

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

int main(){
    ll k,s,sum=0;
    cin>>k>>s;
    vector<ll> aji;
    ll x=s;
    ll n=s;
    for(int i=0;i<k;i++){
        aji.push_back(x);
        sum+=x;
        if(abs(0-x)<abs(0-n)){
            n=x;
        }
        x++;
    }
    cout<<sum-n<<endl;
}


Measured memory_bytes: 3604
fun main(args: Array<String>){
    val (N, K) = readLine()!!.split(" ").map { it.toInt() }
    val S = readLine()!! + "2"

    val bitList = mutableListOf<Char>()
    val countList = mutableListOf<Long>(0)

    var bit = S[0]
    var count = 1L
    for(i in 1 until S.length){
        if(bit == S[i]){
            count++
        }else{
            bitList.add(bit)
            countList.add(count)
            bit = S[i]
            count = 1
        }
    }
    for(i in 1 until countList.size){
        countList[i] += countList[i - 1]
    }

    var max = 0L
    for(i in 0 until bitList.size){
        if(bitList[i] == '0'){
            max = Math.max(max,countList[Math.min(2 * K + i, countList.size - 1)] - countList[i])
        }else{
            max = Math.max(max,countList[Math.min(2 * K + 1 + i, countList.size - 1)] - countList[i])
        }
    }
    println(max)
}

Measured memory_bytes: 41468
using System;

namespace Sample1
{
    class Program
    {
        static void Main(string[] args)
        {
            string input = Console.ReadLine();
            int a = int.Parse(input.Split(' ')[0]);
            int b = int.Parse(input.Split(' ')[1]);
            if(a + b < 24)
            {
                Console.WriteLine(a + b);
            }
            else
            {
                Console.WriteLine(a + b - 24);
            }

        }
    }
}

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

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

int X[55];
int Y[55];
vector<pii> pq;

signed main() {
    int N;
    cin >> N;
    rep(i, N) {
        cin >> X[i] >> Y[i];
    }
    rep(i, N) {
        rep(j, N) {
            if (i == j)continue;
            int p = X[i] - X[j];
            int q = Y[i] - Y[j];
            pq.push_back(pii(p, q));
        }
    }
    sort(pq.begin(), pq.end());
    int cnt = 0;
    pii pre = pii(INF, INF);
    int ans = 0;
    rep(i, pq.size()) {
        if (pq[i] == pre) {
            cnt++;
        } else {
            ans = max(ans, cnt);
            cnt = 1;
            pre = pq[i];
        }
    }
    cout << N - ans << endl;
    return 0;
}


Measured memory_bytes: 384
S=input()
f=1
while S!='':
    if S[-7:]=='dreamer':
        S=S[:-7]
    elif S[-6:]=='eraser':
        S=S[:-6]
    elif S[-5:]=='dream' or S[-5:]=='erase':
        S=S[:-5]
    else:
        f=0
        break
print(['NO','YES'][f])

Measured memory_bytes: 3188
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define all(v) v.begin(), v.end()
using in = int64_t;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
const double PI=3.14159265358979323846;
const in MOD = 1000000007;
const in INF=1<<30;
using P=pair<int,int>;
vector<int> dx={0,1,-1,0};
vector<int> dy={1,0,0,-1};



int main(){
ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
cout << fixed << setprecision(10);
    int n;
    cin>>n;
    vector<char> s(n);
    rep(i,n) cin>>s[i];
    vector<vector<int>> cnt(10,vector<int>(0,0));
    rep(i,n) cnt[s[i]-'0'].emplace_back(i);
    in ans=0ll;
    rep(i,10){
        if(cnt[i].empty()) continue;
        int x=cnt[i][0];
        rep(j,10){
            if(cnt[j].empty()) continue;
            auto yy=upper_bound(all(cnt[j]),x);
            if(yy==cnt[j].end()) continue;
             int y=*yy;
            rep(k,10){
                auto zz=upper_bound(all(cnt[k]),y);
                if(zz==cnt[k].end()) continue;
                ans ++;
            }
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 512
#include <iostream>
#include <vector>
#include <string>
#include <numeric>
#include <algorithm>
#include <iomanip>
#include <queue>
#include <functional>
using namespace std;
using Int = long long;
#define REP(i,n) for(int i=0;i<n;i++)
#define P(r) do{for(auto i:r){cout<<i<<' ';}cout<<'\n';}while(0)
int main()
{
    int sx, sy, tx, ty; cin >> sx >> sy >> tx >> ty;
    REP(i, tx - sx) cout << 'R';
    REP(i, ty - sy) cout << 'U';
    REP(i, tx - sx) cout << 'L';
    REP(i, ty - sy) cout << 'D';
    cout << 'D';
    REP(i, tx - sx + 1) cout << 'R';
    REP(i, ty - sy + 1) cout << 'U';
    cout << 'L';
    cout << 'U';
    REP(i, tx - sx + 1) cout << 'L';
    REP(i, ty - sy + 1) cout << 'D';
    cout << 'R';
    cout << '\n';
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define be(v) (v).begin(),(v).end()
#define pb(q) push_back(q)
typedef long long ll;
using namespace std;
const ll mod=1000000007, INF=(1LL<<60);
#define doublecout(a) cout<<fixed<<setprecision(10)<<a<<endl;
vector<int> calc(int n){
	vector<int> ret;
	for(int i=1LL;i * i <= n;i++){
		if(n%i == 0LL){
			if(i*i != n)ret.pb(n/i);
			ret.pb(i);
		}
	}
	return ret;
}
int main() {
    cin.tie(0);
    cout.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vector<ll> a(n);
    for(int i=0;i<n;i++){
    	cin >> a[i];
    }
    sort(be(a));
    int ans = 0;
    set<int> s;
    map<int, int> mp;
    for(int i=0;i<n;i++){
    	mp[a[i]]++;
    }
    for(int i=0;i<n;i++){
    	if(mp[a[i]] >= 2LL){
    		s.insert(a[i]);
    		continue;
    	}
    	bool maki = true;
    	for(auto& j: calc(a[i])){
    		if(s.count(j)){
    			maki =false;
    		}
    	}
    	if(maki) ans++;
    	s.insert(a[i]);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 23432
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int w = sc.nextInt();
        int h = sc.nextInt();
        int startX = 0;
        int startY = 0;
        int endX = w;
        int endY = h;

        int n = sc.nextInt();
        for (int i = 0; i < n; i++) {
            int x = sc.nextInt();
            int y = sc.nextInt();
            int a = sc.nextInt();
            if (a == 1) {
                if (startX < x) {
                    startX = x;
                }
            } else if (a == 2) {
                if (endX > x) {
                    endX = x;
                }
            } else if (a == 3) {
                if (startY < y) {
                    startY = y;
                }
            } else if (a == 4) {
                if (endY > y) {
                    endY = y;
                }
            }
        }

        if (startX > endX || startY > endY) {
            System.out.println(0);
        } else {
            System.out.println(Math.abs(startX - endX) * Math.abs(startY - endY));

        }
    }
}

Measured memory_bytes: 24148
#pragma GCC optimize("O3")
#pragma GCC target("sse4")

#include <bits/stdc++.h>

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <typeinfo>

using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
typedef long double ld;
typedef complex<ld> cd;

typedef pair<int, int> pi;
typedef pair<ll, ll> pl;
typedef pair<ld, ld> pd;

typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<cd> vcd;

template <class T>
using Tree =
    tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define FOR(i, a, b) for (int i = a; i < (b); i++)
#define F0R(i, a) for (int i = 0; i < (a); i++)
#define FORd(i, a, b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i, a) for (int i = (a)-1; i >= 0; i--)

#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define shandom_ruffle random_shuffle

const int MOD = 1000000007;
const ll INF = 1e18;
const int MX = 100001;  // check the limits, dummy

typedef long long ll;
const int inf = INT_MAX / 2;
const ll infl = 1LL << 60;
template <class T>
bool chmax(T &a, const T &b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T>
bool chmin(T &a, const T &b) {
  if (b < a) {
    a = b;
    return 1;
  }
  return 0;
}

template <class T>
void print(const vector<T> v) {
  cout << "[ ";
  F0R(i, v.size()) { cout << v[i] << ' '; }
  cout << "]" << '\n';
}

int mod(int i, int j) {
  return (i % j) < 0 ? (i % j) + 0 + (j < 0 ? -j : j) : (i % j + 0);
}

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;
}

// --------------------------------------------------------
// This is tool
// --------------------------------------------------------
void Main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);

  int N, M, sum, d;

  cin >> N;
  vi A(N + 1);
  // cout << A.size() << endl;
  // cin >> M;
  // cin >> sum;
  // cout << sum << endl;
  // sum = 0;
  // d = 0;
  FOR(i, 0, N - 1) {
    cin >> d;
    A.at(d) += 1;
    // A.push_back(d);
    // cout << A.at(d) << endl;
  }
  FOR(i, 1, N + 1) { cout << A.at(i) << endl; }
  // cout << sum << endl;
}

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

Measured memory_bytes: 3996
n = int(input())
l = list(map(int, input().split()))
l.sort()
cnt = 0

for i in range(n):
    for j in range(i+1, n):
        for k in range(j+1, n):
            if l[i] != l[j] != l[k]:
                if l[i] + l[j] > l[k]:
                    cnt += 1

print(cnt)

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


int main()
{
    int i,j,k,m,n,test;

    scanf("%d %d",&m,&n);
    if((16/m)>1 && (16/n)>1)
        printf("Yay!\n");
    else printf(":(\n");

    return 0;
}


Measured memory_bytes: 128
#include<stdio.h>
int main(){
  int n,a[10001],sum=0;
  scanf("%d",&n);
  for(int i=0;i<n;i++){
    scanf("%d",&a[i]);
    while(a[i]%2==0){
      sum++;
      a[i]/=2;
    }
  }
  printf("%d\n",sum);
}

Measured memory_bytes: 1776
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define lf long double
#define pb push_back
#define mp make_pair
#define F first
#define S second
typedef pair <ll,ll> ii;
typedef vector <ll> vi;
typedef vector <ii> vii;
typedef vector <bool> vb;
typedef vector <vector <ll> > vv;
typedef vector <string> vs;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll n,m;
    cin>>n>>m;
    vii a(n,mp(0,0));
    for(ll i=0;i<n;i++)
    {
        cin>>a[i].F>>a[i].S;
    }
    ll index=0;
    priority_queue <ll> pq;
    ll ans=0;
    sort(a.begin(),a.end());
    for(ll i=1;i<=m;i++)
    {
        while(index<n && a[index].F==i )
        {
            pq.push(a[index].S);
            index++;
        }
        if(pq.empty())
            continue;
        ans+=pq.top();
        pq.pop();
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 2936
from heapq import heappush,heappop,heapify
rep=range;R=range
def Golf():n,*t=map(int,open(0).read().split())
def I():return int(input())
def S_():return input()
def IS():return input().split()
def LS():return [i for i in input().split()]
def MI():return map(int,input().split())
def LI():return [int(i) for i in input().split()]
def LI_():return [int(i)-1 for i in input().split()]
def NI(n):return [int(input()) for i in range(n)]
def NI_(n):return [int(input())-1 for i in range(n)]
def StoLI():return [ord(i)-97 for i in input()]
def ItoS(n):return chr(n+97)
def LtoS(ls):return ''.join([chr(i+97) for i in ls])
def GI(V,E,ls=None,Directed=False,index=1):
    org_inp=[];g=[[] for i in range(V)]
    FromStdin=True if ls==None else False
    for i in range(E):
        if FromStdin:
            inp=LI()
            org_inp.append(inp)
        else:
            inp=ls[i]
        if len(inp)==2:
            a,b=inp;c=1
        else:
            a,b,c=inp
        if index==1:a-=1;b-=1
        aa=(a,c);bb=(b,c);g[a].append(bb)
        if not Directed:g[b].append(aa)
    return g,org_inp
def GGI(h,w,search=None,replacement_of_found='.',mp_def={'#':1,'.':0},boundary=1):
    #h,w,g,sg=GGI(h,w,search=['S','G'],replacement_of_found='.',mp_def={'#':1,'.':0},boundary=1) # sample usage
    mp=[boundary]*(w+2);found={}
    for i in R(h):
        s=input()
        for char in search:
            if char in s:
                found[char]=((i+1)*(w+2)+s.index(char)+1)
                mp_def[char]=mp_def[replacement_of_found]
        mp+=[boundary]+[mp_def[j] for j in s]+[boundary]
    mp+=[boundary]*(w+2)
    return h+2,w+2,mp,found

mo=10**9+7
FourNb=[(-1,0),(1,0),(0,1),(0,-1)];EightNb=[(-1,0),(1,0),(0,1),(0,-1),(1,1),(-1,-1),(1,-1),(-1,1)];compas=dict(zip('WENS',FourNb));cursol=dict(zip('LRUD',FourNb))
import sys
read=sys.stdin.buffer.read;readline=sys.stdin.buffer.readline;input=lambda:sys.stdin.readline().rstrip()

inf=1<<20
def dijkstra(edge,st):
    n=len(edge)
    d=[(0 if st==i else inf) for i in range(n)]
    q=[(0,st)]
    heapify(q)
    v=[False]*n
    while q:
        dist,cur=heappop(q)
        if v[cur]:
            continue
        v[cur]=True
        for x in edge[cur]:
            dst,dist=x>>1,x%2
            alt=d[cur]+dist
            if alt<d[dst]:
                d[dst]=alt
                heappush(q,(alt,dst))
    return d


show_flg=False
show_flg=True

ans=0

h,w=LI()
sh,sw=LI()
gh,gw=LI()

w+=2
m=[1]*w
for i in range(h):
    s=input()
    m+=[1]+[i=='#'for i in s]+[1]
m+=[1]*w
h+=2
n=h*w
v=[-1]*w*h


nbw=[-2*w+1,-2*w+2,-w+1,-w+2,2,2*w+1,2*w+2,w+1,w+2,+2*w,-2*w,-2*w-1,-2*w-2,-w-1,-w-2,-2,2*w-1,2*w-2,w-1,w-2]
nbw=[2,2*w+1,2*w+2,w+1,w+2,+2*w,2*w-1,2*w-2,w-1,w-2]
nb=[1,-1,w,-w]
nb=[1,w]
d=[-1]*n
g=[[]for i in range(n)]
for i in range(n):
    if m[i]==1:
      continue
    for di in nbw:
        nx=i+di
        if 0<=nx<n and m[nx]!=1:
            g[i]+=(nx*2+1),
            g[nx]+=(i*2+1),
    for di in nb:
        nx=i+di
        if 0<=nx<n and m[nx]!=1:
            g[i]+=(nx*2),
            g[nx]+=(i*2),
            
d=dijkstra(g,sh*w+sw)
ans=d[gh*w+gw]
if ans==inf:
    ans=-1
print(ans)


Measured memory_bytes: 284136
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <stack>
#include <queue>
#include <map>
#include <algorithm>
#include <iomanip>
#include <math.h>
#include <string.h>
#include <cstdio>
#include <tuple>
using namespace std; using ll = long long; using ld = long double;  using pll = pair<ll, ll>;
using vl = vector<ll>; using vll = vector<vl>; using vpll = vector<pll>;
const ld PI = 3.1415926535897932;
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#define rep1(n) for(ll i=0;i<n;++i)
#define rep2(i,n) for(ll i=0;i<n;++i)
#define rep3(i,a,b) for(ll i=a;i<b;++i)
#define rep4(i,a,b,c) for(ll i=a;i<b;i+=c)
#define rep(...) overload4(__VA_ARGS__,rep4,rep3,rep2,rep1)(__VA_ARGS__)
#define mp make_pair
#define mt make_tuple
#define INT(...) int __VA_ARGS__;in(__VA_ARGS__)
#define LL(...) ll __VA_ARGS__;in(__VA_ARGS__)
#define ULL(...) ull __VA_ARGS__;in(__VA_ARGS__)
#define STR(...) string __VA_ARGS__;in(__VA_ARGS__)
#define CHR(...) char __VA_ARGS__;in(__VA_ARGS__)
#define DBL(...) double __VA_ARGS__;in(__VA_ARGS__)
#define LD(...) ld __VA_ARGS__;in(__VA_ARGS__)
void in() {}
void debug_out() { cerr << endl; }
template<typename Head, typename... Tail>
void debug_out(Head h, Tail... t) {
	cerr << " " << h;
	if (sizeof...(t) > 0) cerr << " :";
	debug_out(t...);
}
template <typename T>
ostream& operator<<(ostream& os, vector<T> vec) {
	for (size_t i = 0; i < vec.size(); i++)os << vec[i] << (i + 1 == vec.size() ? "" : " ");
	return os;
}
ll ctoi(char c) {
	switch (c) {
	case '0': return 0; case '1': return 1; case '2': return 2;
	case '3': return 3; case '4': return 4; case '5': return 5;
	case '6': return 6; case '7': return 7; case '8': return 8;
	case '9': return 9;  default: return 0;
	}
}
bool pairCompare(const pll firstElof, pll secondElof)
{
	return firstElof.first > secondElof.first;
}
//**Snippetリスト**//
//rep, vin, all, iteLoop//
//bitSearch, bitList, nod, gcdlcm, isPrime, primeFactorize, Npow, divisor, modinv, dfs, bfs, eratos//
//dijkstra, WarshallFloyd, BellmanFord, UnionFind, COM, digitDP ,RMQ//
ll i, j, k, l; ll N, M, K, H, W, L, X, Y, Z, R, Q;
ll MOD = 1000000007; ll INF = 1LL << 60; ll ans = 0; ll z = 0, o = 1;
vl flag, D; vll path; vl Ans;
//***********//
void bfs(ll now) {
	queue<ll> Q;
	Q.push(now);
	flag[now] = 1;
	ll u;
	while (!Q.empty()) {
		u = Q.front();
		Q.pop();
		for (ll v = 0; v < path[u].size(); v++) {
			ll next = path[u][v];
			if (flag[next] == 0) {
				Ans[next] = u;
				flag[next] = 1;
				Q.push(next);
			}
		}
	}
}
int main() {
	cin >> N >> M;
	path.resize(N);
	flag.resize(N);
	Ans.resize(N);
	for (i = 0; i < M; i++) {
		ll a, b;
		cin >> a >> b;
		a--; b--;
		path[a].push_back(b);
		path[b].push_back(a);
	}
	bfs(0);
	cout << "Yes" << endl;
	for (i = 1; i < N; i++) {
		cout << Ans[i]+1 << endl;
	}
}

Measured memory_bytes: 13768
W,H,x,y = list(map(float,input().split()))

ans = W * H
ans = float(float(ans) / 2.0)
ans2 = 0
if x == float(float(W) / 2) and y == float(float(H) / 2):
    ans2 = 1

print(str(ans) + " " + str(ans2))

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

#define ll long long
#define P pair<int,int>
#define rep(i,n) for(int i = 0; i < (n); i++)
#define asort(x) sort(x.begin(),x.end())

int main() {
    ll a,b,n;
    cin >> a >> b >> n;
    n = min(n,b-1);
    cout << (a*n)/b - a*(n/b) << endl;
    return 0;
}

Measured memory_bytes: 3612
#include <stdio.h>
#include <stdlib.h>

int main()
{
    char a,b,c;
    scanf("%c %c",&a,&b);
    if(a=='H')
    {
        if(b=='H')
            c='H';
        if(b=='D')
            c='D';
    }
    if(a=='D')
    {
        if(b=='H')
            c='D';
        if(b=='D')
            c='H';
    }
    printf("%c",c);
}


Measured memory_bytes: 128
#include<iostream>
#include<sstream>
#include<vector>
#include<iterator>
#include<algorithm>
using namespace std;

class UnionFind {
public:
	UnionFind(int sz) :
		parent(sz, -1) {}

	int root(int id) {
		if (parent[id] < 0)
			return id;

		return parent[id] = root(parent[id]);
	}

	int size(int id) {
		return -parent[root(id)];
	}

	bool unite(int id1, int id2) {
		id1 = root(id1);
		id2 = root(id2);

		if (id1 == id2)
			return false;

		parent[min(id1, id2)] += parent[max(id1, id2)];
		parent[max(id1, id2)] = min(id1, id2);
		return true;
	}

private:
	vector<int> parent;
};

int main(void)
{
	int N, M;
	cin >> N >> M;

	vector<int> A(M), B(M);
	for (int i = 0; i < M; i++) {
		cin >> A[i] >> B[i];

		A[i]--;
		B[i]--;
	}
		

	reverse(A.begin(), A.end());
	reverse(B.begin(), B.end());

	UnionFind un(N);
	vector<long long> ans(M, 0);
	ans[0] = (long long)N * (N - 1) / 2;
	for (int i = 0; i < M - 1; i++) {
		ans[i + 1] = ans[i];

		if (un.root(A[i]) != un.root(B[i])) {
			ans[i+1] -= (long long)un.size(A[i]) * un.size(B[i]);
			un.unite(A[i], B[i]);
		}
	}

	reverse(ans.begin(), ans.end());

	for (int i = 0; i < M; i++)
		cout << ans[i] << endl;

	return 0;
}


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

int main(){

    ll n,a,b;
    
    cin >> n;
    vector<string> s(n);
    vector<int> t(n);
    ll su=0L,ans=0L;

    rep(i,n){
        cin >> s[i] >> t[i];
        su+=t[i];
    }
    bool f=false;
    string x;
    cin >> x;
    rep(i,n){
        if(f){
            ans+=t[i];
        }
        if(s[i]==x){
            f=true;
        }
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
n = int(input())
w_lis = []
ans = "Yes"
for i in range(n):
    w = input()
    if i == 0:
        w_lis.append(w)
    elif w in w_lis:
        ans = "No"
        break
    elif w not in w_lis and w[0] != w_lis[i-1][-1]:
        ans = "No"
        break
    else:
        w_lis.append(w)
print(ans)



Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (n); i++)
using namespace std;
const int MAXI = 110;

int main() {
    cin.tie(0)->sync_with_stdio(false);

	int h, w; cin >> h >> w;
	vector<vector<char> > s(h + 1, vector<char>(w + 1));
	REP(i, h) REP(j, w)
		cin >> s[i+1][j+1];

	vector<vector<int> > dp(MAXI, vector<int>(MAXI, INT_MAX));
	dp[1][1] = (s[1][1] == '#');

	for (int i = 1; i <= h; i++) {
		for (int j = 1; j <= w; j++) {
			if (i * j != 1) {
				dp[i][j] = min(dp[i-1][j]+(s[i][j]=='#'&&s[i-1][j]=='.'), dp[i][j-1]+(s[i][j]=='#'&&s[i][j-1]=='.'));
			}
		}
	}
	cout << dp[h][w] << '\n';
    return 0;
}


Measured memory_bytes: 3704
import Control.Monad
import qualified Data.ByteString.Char8 as BC
import Data.List
import Data.Maybe (fromJust)
import qualified Data.IntMap as IM

readInts :: IO [Int]
readInts = map (fst . fromJust . BC.readInt) . BC.lines <$> BC.getContents

solve :: Int -> Int -> Int -> IM.IntMap Int -> Int
solve count id n as
  | button == 2 = count
  | count > n = -1
  | otherwise = solve (count + 1) button n as
  where button = fromJust $ IM.lookup id as

main :: IO ()
main = do
  n <- readLn
  as <- readInts
  print . solve 1 1 n $ IM.fromList $ zip [1..] as

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

using namespace std;

typedef long long ll;

#define MAX 1024
#define INF LLONG_MAX/4

ll N, W;
ll memo[MAX];
vector<ll> a;

ll solve(int n)
{
    if (n == N) return 0;
    ll &res = memo[n];
    if (res != -1) return res;
    res = INF;
    ll sum = 0;
    for (int i = n; i < N; i++) {
        sum += a[i];
        res = min(res, solve(i+1) + abs(sum - W));
    }
    res = min(res, solve(N) + max(0LL, sum - W));
    return res;
}

int main()
{
    int T = 1;
    while (cin >> N >> W, N) {
        a.resize(N);
        for (int i = 0; i < N; i++) {
            cin >> a[i];
        }
        memset(memo, -1, sizeof(memo));
        cout << "Case " << T++ << ": " << solve(0) << endl;
    }    
    return 0;
}

Measured memory_bytes: 3180
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>

#define repd(i, a, b) for (ll i = (a); i < (b); i++)
#define rep(i, n) repd(i, 0, n)

using namespace std;

namespace mp = boost::multiprecision;
using Bint = mp::cpp_int;

using ll = long long;
ll mod = pow(10, 9) + 7;

template <typename T> void output(T, ll);
ll gcd(ll, ll);
ll lcm(ll, ll);
Bint comb(Bint, Bint);
void prime_map(map<ll, ll> &, ll);

int main() {
    // source
    ll k, x;
    cin >> k >> x;
    ll l = x - (k - 1), r = x + (k - 1);

    ll ans = l;
    while (ans <= r) {
        cout << ans << " ";
        ans++;
    }

    cout << endl;
    return 0;
}

Bint comb(Bint a, Bint b) {
    Bint ans = 1;

    if (a < b) {
        return 0;
    }

    rep(i, b) {
        ans *= a - i;
        ans /= i + 1;
    }

    return ans;
}

template <typename T> void output(T a, int precision) {
    if (precision > 0) {
        cout << setprecision(precision) << a << "\n";
    } else {
        cout << a << "\n";
    }
}

template <typename T> T min(T a, T 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) { return a * b / gcd(a, b); }

void prime_map(map<ll, ll> &m, ll num) {
    ll cache = num;
    repd(i, 2, sqrt(num) + 2) {
        if (num % i == 0) {
            if (m[i] == 0) {
                m[i] = 1;
            } else {
                m[i]++;
            }

            num /= i;
            break;
        }
    }

    if (cache == num) {
        if (m[num] == 0) {
            m[num] = 1;
        } else {
            m[num]++;
        }
        return;
    } else {
        prime_map(m, num);
    }
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <cassert>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <sstream>
#include <vector>
#include <queue>
#include <stack>
#include <list>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <complex>
#include <cmath>
#include <numeric>
#include <bitset>

using namespace std;

#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << ": " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ',');
  cerr.write(names, comma - names) << ": " << arg1 << " |";
  __f(comma + 1, args...);
}

typedef long long int64;
typedef pair<int, int> ii;
const int INF = 1 << 30;
const int MOD = 1e9 + 7;

int main() {
  int n;
  scanf("%d", &n);
  int A = 0, B = 0, C = 0;
  for (int i = 0; i < n; ++i) {
    int x;
    scanf("%d", &x);
    if (x % 4 == 0) {
      A++;
    } else if (x % 4 == 2) {
      B++;
    } else {
      C++;
    }
  }
  if (B) {
    puts(A >= C ? "Yes" : "No");
  } else {
    puts(A >= C - 1 ? "Yes" : "No");
  }
  return 0;
}


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

using namespace std;
typedef long long ll;
const ll INF = 1e9;
 
int main(void) {
    ll N;
    cin >> N;
    vector<ll> H(N);
    for (int i = 0; i < N; i++) { cin >> H[i]; }

    vector<int> dp(N, INF);
    dp[N - 1] = 0;
    for (int i = N - 2; i >= 0; i--) {
        if (H[i] >= H[i + 1])
            dp[i] = dp[i + 1] + 1;
        else
            dp[i] = 0;
    }
    int mv = -1;
    for (int i = 0; i < N; i++) {
        mv = max(mv, dp[i]);
    }
    cout << mv << endl;
}

Measured memory_bytes: 1408
/*
ID: anonymo14
TASK: wormhole
LANG: C++                 
*/
#include<bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<pair<int,int>> vpii;

#define F first
#define S second
#define PU push
#define PUF push_front
#define PUB push_back
#define PO pop
#define POF pop_front
#define POB pop_back

#define REP(i,a,b) for(int i=a; i<=b; i++)

#define MOD 1000000007

bool cmp(pair<int,int> &a,pair<int,int> &b){
	return a.F<b.F;
}

void solve(int test_case) {//233
	int n,d;
	cin>>n>>d;
	vector<vector<double>> arr(n, vector<double>(d));	
	for(auto &i:arr)for(auto &j:i)cin>>j;
	int cnt = 0;
	REP(i,0,n-1){
		REP(j,i+1,n-1) {
			double sum  =0;
			REP(k,0,d-1)sum+=pow(arr[i][k]-arr[j][k],2);
			sum=sqrt(sum);
			if(ceil(sum)==sum)cnt++;
		}
	}
	cout<<cnt;
}

int main() {
	
	////// FILE BASED IO////
	//freopen("wormhole.in", "r", stdin);
	//freopen("wormhole.out", "w", stdout);
	///////////////
	
	ios::sync_with_stdio(0);
	cin.tie(0);
	int t=1;
	//cin>>t;
	REP(i,1,t) {
		solve(i);
	}
	return 0;
}	


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

using namespace std;

typedef long long ll;
typedef double long dl;
typedef pair < int , int > pii;
typedef pair < pii, pii > p2i;
const int maxn = (int) 2e6 + 2;
const int mod = (int) 1e9 + 7;
const ll inf = (ll)1e18;

#define fi first
#define se second
#define acel ios_base :: sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL)
#define next continue
#define getsz(x) (int) log10(x)

int sum(ll x){
    ll res = 0;
    while(x > 0){
        res += (x % 10);
        x /= 10;
    }
    return res;
}


int n;
ll q = 1, m = 1;
int main(){
    cin >> n;
    for(int i = 1; i <= n; i++){
        cout << q << "\n";
        ll f = q + m, s = q + m * 10;
        if(f * sum(s) <= s * sum(f)){
            q = f;
        }
        else {
            q = s;
            m *= 10;
        }
    }
}


Measured memory_bytes: 256
d, g = map(int, input().split())
pc = []
for i in range(d):
    pc.append(list(map(int, input().split())))

complete = []
for i in range(2 ** d):
    temp = [0] * d
    for j in range(d):
        if (i >> j) & 1:
            temp[j] = 1
    complete.append(temp)

ans = 10 ** 9
for i in range(len(complete)):
    score = g
    solved = 0
    for j in range(d):
        zenkan = complete[i][j]
        num = pc[j][0]
        bonus = pc[j][1]
        point = (j + 1) * 100
        if zenkan == 1:
            solved += num
            score -= num * point + bonus

    if score <= 0:
        ans = min(ans, solved)
    else:
        for j in reversed(range(d)):
            zenkan = complete[i][j]
            num = pc[j][0]
            bonus = pc[j][1]
            point = (j + 1) * 100
            if zenkan == 0:
                if score - (num - 1) * point > 0:
                    solved += num - 1
                    score -= (num - 1) * point
                else:
                    if score % point == 0:
                        solved += score // point
                    else:
                        solved += score // point + 1
                    ans = min(ans, solved)
                    break

print(ans)


Measured memory_bytes: 3188
#include <iostream>
#include <vector>
#include <map>

#define int long long

using namespace std;

signed main()
{
	int n, m;
	vector<int> a;
	map<int, int> r;

	cin >> n >> m;

	a.resize(n + 1);
	a[0] = 0;
	r[0] = 1;

	int ans = 0;
	int sum = 0;
	for(int i = 1; i <= n; ++i)
	{
		cin >> a[i];

		sum += a[i];

		if(r.count(sum % m) == 0)
		{
			r[sum % m] = 1;
		}
		else
		{
			ans += r[sum % m];
			++r[sum % m];
		}
	}

	cout << ans << endl;
}

Measured memory_bytes: 4992
import sys
from collections import defaultdict
from heapq import *
sys.setrecursionlimit(10**8)

input = sys.stdin.readline

def main():
    """ main """
    N = int(input())
    dp = {}
    ans = 0
    for _ in range(N):
        str = ''.join(sorted(input().rstrip()))
        if str in dp:
            ans += dp[str]
            dp[str] += 1
        else:
            dp[str] = 1
    print(ans)

if __name__ == '__main__':
    main()


Measured memory_bytes: 18236
#include <bits/stdc++.h>
using namespace std;
using ll =long long;
#define all(v) v.begin(),v.end()
 
int main() {
  ll X;
  cin>>X;
  ll a=100;
  ll count=0;
  while(a<X) {
    a+=a/100;
    count++;
  }
  
  cout<<count<<endl;
}



Measured memory_bytes: 3512
fun main(args: Array<String>) {
    val (k, x) = readIntList()
    if (500 * k >= x) println("Yes")
    else println("No")
}

// Tools
fun readString() = readLine()!!
fun readInt() = readLine()!!.toInt()
fun readLong() = readLine()!!.toLong()
fun readStringList() = readLine()!!.split(" ")
fun readIntList() = readLine()!!.split(" ").map(String::toInt)
fun readLongList() = readLine()!!.split(" ").map(String::toLong)

Measured memory_bytes: 36072
n = int(input())
lst = []
for i in range(n):
    l = input().split()
    lst.append([l[0], int(l[1]), i+1])
sorted_lst = sorted(lst, reverse=True)
while sorted_lst != []:
    p = sorted_lst.pop()
    temp = []
    while sorted_lst != [] and p[0] == sorted_lst[-1][0]:
        temp.append(sorted_lst.pop())
    while temp != []:
        print(temp.pop()[2])
    print(p[2])

Measured memory_bytes: 3064