akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <iterator>
#include <vector>
#include <string>
#include <algorithm>

using namespace std;

bool vector_finder(std::vector<size_t> vec, int number) {
  auto itr = std::find(vec.begin(), vec.end(), number);
  size_t index = std::distance( vec.begin(), itr );
  if (index != vec.size()) { // 発見できたとき
    return true;
  }
  else { // 発見できなかったとき
    return false;
  }
}

int main(void)
{
    
    int N;
    int ans;
    string S;
    vector<int> A;
    vector<int> b;
    

    int an;
    for(int i =0; i < 9; i++){
        std::cin >> an;
        A.push_back(an);
    }
    /*
    for(int i =0; i < 9; i++){
        std::cout << A[i];
    }*/

    cin >> N;

    int bn;
    for(int i = 0; i < N; i++){

        cin >> bn;
        b.push_back(bn);
    }
    vector<size_t> index;
    int j,k;
    for(int i = 0; i < N; i++){
        auto it = find(A.begin(), A.end(), b[i]);
        index.push_back(distance(A.begin(), it));

        
        j = index[i] / 3;
        index[i] = index[i] - j * 3 + 1;
        index[i] = index[i] + 10 * (j + 1);
        

        //cout << index[i] << " ";
    }

    sort(index.begin(),index.end());
    /*
    cout << endl;
    
    for(int i = 0; i < N; i++){

        cout << index[i] << " ";
    }
    */

   //横
   if( vector_finder(index,11) && vector_finder(index,12)&&vector_finder(index,13)){
       std::cout << "Yes";
       return 0;
   }
   if( vector_finder(index,31) && vector_finder(index,32)&&vector_finder(index,33)){
       std::cout << "Yes";
       return 0;
   }
   if( vector_finder(index,21) && vector_finder(index,22)&&vector_finder(index,23)){
       std::cout << "Yes";
       return 0;
   }
   //縦
   if( vector_finder(index,11) && vector_finder(index,21)&&vector_finder(index,31)){
       std::cout << "Yes";
       return 0;
   }
   if( vector_finder(index,12) && vector_finder(index,22)&&vector_finder(index,32)){
       std::cout << "Yes";
       return 0;
   }
   if( vector_finder(index,13) && vector_finder(index,23)&&vector_finder(index,33)){
       std::cout << "Yes";
       return 0;
   }
   //斜め
   if( vector_finder(index,11) && vector_finder(index,22)&&vector_finder(index,33)){
       std::cout << "Yes";
       return 0;
   }if( vector_finder(index,13) && vector_finder(index,22)&&vector_finder(index,31)){
       std::cout << "Yes";
       return 0;
   }
    cout << "No";
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define SZ(x) ((int)(x).size())
#define ALL(x) (x).begin(),(x).end()
#ifdef _DEBUG_
	#define debug(...) printf(__VA_ARGS__)
#else
	#define debug(...) (void)0
#endif
using namespace std;
typedef long long ll;
typedef pair<int,int> PII;
typedef vector<int> VI;

const int N_MAX=1e5+10;
char str[N_MAX];

int main() {
	scanf("%s", str);
	int n=strlen(str);
	int ans=0;
	for(int i=0; i<n; i++) {
		char c = (i&1)?'p':'g';
		if(c != str[i])
			c=='p' ? ans++ : ans--;
	}
	printf("%d\n", ans);
	return 0;
}


Measured memory_bytes: 384
import java.io.PrintStream;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = null;
		PrintStream out = null;
		try {
			sc = new Scanner(System.in);
			out = System.out;
			exec(sc, out);
		} catch (Exception e) {
			e.printStackTrace();
			System.exit(1);
		} finally {
			if(out != null) {
				out.close();
			}
			if(sc != null) {
				sc.close();
			}
		}
		System.exit(0);
	}
	public static void exec(final Scanner sc, final PrintStream out) throws Exception{
		final int N = sc.nextInt();
		final int K = sc.nextInt();
		final int[] h = new int[N];
		for(int i=0;i<N;i++) {
			h[i] = sc.nextInt();
		}
		int sum = 0;
		for(int i=0;i<N;i++) {
			if(h[i]>=K) {
				sum++;
			}
		}
		out.println(sum);
	}

}


Measured memory_bytes: 49128
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define SORT(c) sort((c).begin(),(c).end())
#define REVERSE(c) reverse((c).begin(),(c).end())
#define SUM(c) accumulate((c).begin(),(c).end(),0)
#define ALL(a)  (a).begin(),(a).end()
// int gcd(int a,int b){return b?gcd(b,a%b):a;}
long long gcd(long long a,long long b){return b?gcd(b,a%b):a;}

using namespace std;

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();}
template<class T> T maxt(T x,T y) {
    if (x>y) return x;
    else return y;
}
template<class T> T mint(T x,T y) {
    if (x>y) return y;
    else return x;
}
//sort(v.rbegin(), v.rend(), [](auto& x, auto& y){return x[1] < y[1];});
//cout << fixed << setprecision(10) << ans << defaultfloat << endl;
typedef long long ll;
typedef vector<int> Vi;
typedef vector<ll> Vl;
typedef vector<double> Vd;
typedef vector<string> Vs;

//小数出力
double print_double(double d){printf("%.10f", d);}

long long m = 1e9+7, mod = 1e9+7;
//逆元　a/b の modをとるとき -> a*modinv(b)%mod
long long modinv(long long a, long long m = 1e9+7) {
    long long b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m; 
    if (u < 0) u += m;
    return u;
}

//約数列挙
vector< int64_t > divisor(int64_t n) {
  vector< int64_t > ret;
  for(int64_t i = 1; i * i <= n; i++) {
    if(n % i == 0) {
      ret.push_back(i);
      if(i * i != n) ret.push_back(n / i);
    }
  }
  sort(begin(ret), end(ret));
  return (ret);
}








int main() {
  int N,T,ans=0;
  cin >> N >> T;
  vector<Vi> v(N+1,Vi(2,0)),dp(N+1,Vi(T,0));
  rep(i,N) {
    cin >> v[i+1][0] >> v[i+1][1];
    }
  
  
  SORT(v);
  FOR(i,1,N+1){
    FOR(j,1,T){
      dp[i][j] = maxt(dp[i-1][j],dp[i][j-1]);
      if (j>=v[i][0]) dp[i][j] = max(dp[i-1][j-v[i][0]]+v[i][1],dp[i][j]);
    }
    FOR(j,i,N+1){
    ans = maxt(ans, dp[i-1][T-1] + v[j][1]);}
  }

  cout << ans;
}

Measured memory_bytes: 35712
import java.util.Scanner;

public class Main{

	public static void main(String[] args) {
		Scanner stdin = new Scanner(System.in);
		int n;
		long min = Long.MAX_VALUE;
		n = stdin.nextInt();
		long[] A = new long[n];
		A[0] = stdin.nextLong();
		for (int i = 1; i < n; i++) {
			//累積和の配列
			A[i] = A[i - 1] + stdin.nextInt();
		}
		if (n == 2) {
			//すぬけくんもアライさんも１枚の時
		min=Math.abs(A[1]-2*A[0]);
		} else {
			for (int i = 0; i < n - 1; i++) {
				if (Math.abs(A[n - 1] - 2 * A[i]) < min) {
					min = Math.abs(A[n - 1] - 2 * A[i]);
				}
			}
		}
		System.out.println(min);

	}

}


Measured memory_bytes: 77588
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#define REP(i, m, n) for(int i=int(m);i<int(n);i++)
#define EACH(i, c) for (auto &(i): c)
#define all(c) begin(c),end(c)
#define EXIST(s, e) ((s).find(e)!=(s).end())
#define SORT(c) sort(begin(c),end(c))
#define pb emplace_back
#define MP make_pair
#define SZ(a) int((a).size())

//#define LOCAL 1
#ifdef LOCAL
#define DEBUG(s) cout << (s) << endl
#define dump(x)  cerr << #x << " = " << (x) << endl
#define BR cout << endl;
#else
#define DEBUG(s) do{}while(0)
#define dump(x) do{}while(0)
#define BR
#endif


//改造
typedef long long int ll;
using namespace std;


//ここから編集する


int main() {
    ll x,a,b;
    cin >> x >> a >> b;
    if(abs(x-a) < abs(x-b)) cout << "A" << endl;
    else cout << "B" << endl;
    return 0;

}


Measured memory_bytes: 256
#include<set>
#include<map>
#include<list>
#include<queue>
#include<stack>
#include<string>
#include<time.h>
#include<math.h>
#include<memory>
#include<vector>
#include<bitset>
#include<fstream>
#include<stdio.h>
#include<utility>
#include<sstream>
#include<string.h>
#include<iostream>
#include<stdlib.h>
#include<algorithm>
using namespace std;
int a[200005];
int main()
{
    #ifdef absi2011
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    #endif
    int n;
    scanf("%d",&n);
    memset(a,-1,sizeof(a));
    int l=100000,r=100000;
    int r_tag=0;
    int i;
    for (i=0;i<n;i++)
    {
        int x;
        scanf("%d",&x);
        if (r_tag)
        {
            l--;
            a[l]=x;
        }
        else
        {
            a[r]=x;
            r++;
        }
        r_tag^=1;
    }
    if (r_tag==0)
    {
        for (i=0;i<=200000;i++)
        {
            if (a[i]!=-1) printf("%d ",a[i]);
        }
    }
    else
    {
        for (i=200000;i>=0;i--)
        {
            if (a[i]!=-1) printf("%d ",a[i]);
        }
    }
    return 0;
}


Measured memory_bytes: 2944
#include<bits/stdc++.h>
using namespace std;
#define mod 1000000007
#define pie 3.142857143
#define ll long long int
#define fr(i,a,n) for(ll i=a;i<n;i++)
#define vi vector<int>
#define vlli vector<ll>
#define pb push_back
#define ppb pop_back
#define mp make_pair
#define fv(i,a) for(auto i:a)
#define sz(a) int((a).size())
#define all(c) (c).begin(),(c).end()
#define frv(i,c) for(auto i = c.begin(); i != c.end(); i++)

void solve()
{
	ll n;
	cin >> n;
	int dp[3] = {0};
	int c[3];
	fr (i, 0, n)
	{
		fr (j, 0, 3)
		cin >> c[j];
		int ndp[3] = {0};
		fr(i, 0, 3)
		{
			fr(j, 0, 3)
			{
				if (i != j)
				{
					ndp[i] = max(dp[j] + c[i], ndp[i]);
				}
			}
		}
		fr(i, 0, 3)
		dp[i] = ndp[i];

	}
	cout << max(dp[0], max(dp[1], dp[2])) << endl;
}


int main() {
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen ("output.txt", "w", stdout);
#endif
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int t;
	//cin>>t;
	t = 1;
	while (t--)
	{
		solve();
	}


	return 0;
}

Measured memory_bytes: 3632
import numpy as np

A, B, H, M = map(int, input().split())

if H > 12:
    H -= 12

v = (H + (M / 60) * (1 / 12))
ji_ang = (H / 12 +((M / 60) * (1 / 12))) * 2 * np.pi

if 0 <= v <= 3:
    ji_ang = (np.pi / 2) - ji_ang
elif 3 < v <= 6:
    ji_ang = (ji_ang - (np.pi / 2)) * -1
elif 6 < v <= 9:
    ji_ang = (ji_ang - np.pi) * -1 - np.pi / 2
else:
    ji_ang = np.pi - (ji_ang - (np.pi * (3 / 2)))

ji_x = A * np.cos(ji_ang)
ji_y = A * np.sin(ji_ang)

fun_ang = (M / 60) * 2 * np.pi

if 0 <= M <= 15:
    fun_ang = (np.pi / 2) - fun_ang
elif 15 < M <= 30:
    fun_ang = (fun_ang - (np.pi / 2)) * -1
elif 30 < M <= 45:
    fun_ang = (fun_ang - np.pi) * -1 - np.pi / 2
else:
    fun_ang = np.pi - (fun_ang - (np.pi * (3 / 2)))

fun_x = B * np.cos(fun_ang)
fun_y = B * np.sin(fun_ang)

x = (ji_x - fun_x)
y = (ji_y - fun_y)

print(np.sqrt(x ** 2 + y ** 2))


Measured memory_bytes: 27264
#include<iostream>
#include<sstream>
#include<fstream>
#include<string>
#include<vector>
#include<deque>
#include<queue>
#include<stack>
#include<map>
#include<set>
#include<utility>
#include<functional>
#include<algorithm>
#include<bitset>
#include<ctime>
#include<cmath>
#include<cstdio>
#include<cstdlib>
using namespace std;
int n,m;
const long long mod=1000000007;
int a[100005];
int main()
{
	int n,m;
	cin>>n>>m;
	for(int i=0;i<m;i++)
	{
		int k;
		cin>>k;
		a[k]=-1;
	}
	a[0]=1;
	for(int i=1;i<=n;i++)
	{
		if(a[i]==-1)
			continue;
		if(i>=2&&a[i-2]!=-1)
			(a[i]+=a[i-2])%=mod;
		if(a[i-1]!=-1)
			(a[i]+=a[i-1])%=mod;
	}
	cout<<a[n];
	return 0;
}

Measured memory_bytes: 640
#include<iostream>
#include<cstdio>
#include<vector>
#include<stack>
#include<cstring>
#define maxn 20005
using namespace std;
int sum=0;
char s[maxn];
stack<int> s1;
stack< pair<int,int> > s2;
vector<int> ans;

int main()
{
    scanf("%s",s);
    int len=strlen(s);
    for(int i=0; i<len; ++i)
    {
        if(s[i]=='/')
        {
            if(!s1.empty())
            {
                int j=s1.top();
                s1.pop();
                int a=i-j;
                sum+=a;
                while(!s2.empty() && j<s2.top().first) //??¨???????????????????????? 
                {
                    a+=s2.top().second;
                    s2.pop();
                }
                s2.push(make_pair(j,a));
            }
        }
        else if(s[i]=='_') continue;
        else s1.push(i);
    }
    while(!s2.empty())
    {
        ans.push_back(s2.top().second);
        s2.pop();
    }
    printf("%d\n%d",sum,ans.size());
    for(int i=ans.size()-1; i>=0; --i)
        printf(" %d",ans[i]);
    printf("\n");
//    for(int i=0; i<len; ++i)
//        if(s[i]=='/')
//            cout<<s[i];
//        else cout<<"-";
    return 0;
}

Measured memory_bytes: 3344
N = gets.to_i
W = N.times.map {gets.chomp}

con1 = W == W.uniq
con2 = (0...N-1).inject([]) {|a, i| a << [W[i][-1], W[i+1][0]]}.all? {|a, b| a == b}
puts [con1, con2].all? ? "Yes" : "No"

Measured memory_bytes: 3836
#include <iostream>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <algorithm>
#include <numeric>
#include <fstream>
#include <iomanip>

typedef long double ld;
typedef long long ll;
const ll INF = (ll)1e18 + 1;
const ll MOD = 1e9 + 7;

// Split
namespace util {

std::vector< std::string > split(std::string s, char delimiter)
{
  std::vector< std::string > vs;
  std::string sub;
  for (auto c : s) {
    if (c == delimiter) vs.push_back(sub), sub.clear();
    else sub += c;
  }
  vs.push_back(sub);
  return vs;
}

} // namespace util

// Minimum, Maximum
template<class T> T minimum(T head, T tail) { return std::min(head, tail); }
template<class H, class... T> H minimum(H head, T... tail) { return std::min(head, minimum(tail...)); }
template<class T> T maximum(T head, T tail) { return std::max(head, tail); }
template<class H, class... T> H maximum(H head, T... tail) { return std::max(head, maximum(tail...)); }

// Output
template<class T> std::ostream& operator << (std::ostream& os, std::vector< T > v)
{
  for (ll i = 0; i < (ll)v.size(); i++){ os << " [" << i << "]" << v[i]; if (i % 10 == 0) os << std::endl; }
  return os;
}

template<class T, class S> std::ostream& operator << (std::ostream& os, std::vector< std::pair<T, S> > vp)
{
  ll i = 0;
  for (auto p : vp){os << " [" << i++ << "]" << p.first << " " << p.second; if (i % 10 == 0) os << std::endl;}
  return os;
}

void print(){ std::cout << std::endl; }
template<typename H> void print(H head) { std::cout << head << std::endl; }
template<typename H, typename... T> void print(H head, T... tail){ std::cout << head << " ", print(tail...); }

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

  std::ostringstream oss;

  
  
  std::map< std::string, ll > mc;

  ll A, B;
  std::cin >> A >> B;

  ll cnt = 0LL;
  for (ll i = A; i <= B; i++) {
    std::ostringstream oss;
    oss << i;
    std::string str = oss.str();
    std::string rev = str;
    std::reverse(rev.begin(), rev.end());
    if (str == rev) cnt++;
  }

  print(cnt);
  return 0;
}


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

int main() {
  int N;
  cin >> N;
  
  int wa = 0;
  int b = N;
  
  while( b > 0 ){
    wa += b % 10;
    b /= 10;
  }
  if( N % wa == 0 ){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
  
}



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

int main(){
    int N, D; cin >> N >> D;
    int point[N][D];

    for( int i = 0; i < N; i++ ){
        for( int j = 0; j < D; j++ ){
            cin >> point[i][j];
        }
    }

    int ans = 0;
    double distance = 0;
    for( int i = 0; i < N; i++ ){
        for( int j = i+1; j < N; j++ ){
            distance = 0;
            for( int k = 0; k < D; k++ ){
                distance += (point[i][k]-point[j][k])*(point[i][k]-point[j][k]);
            }
            if( ceil(sqrt(distance)) == floor(sqrt(distance)) ) ans++;
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#define N 100
using namespace std;
int main(){
	int n[N] = {0};
	int i;
	while(cin >> i){
		n[i-1] ++;
	}
	int max = 0;
	for(int i = 0; i < N; i++){
		if(n[i] > max) max = n[i];
	}
	for(int i = 0; i < N; i++){
		if(n[i] == max) cout << i+1 << endl;
	}
	return 0;
}

Measured memory_bytes: 1164
#include<bits/stdc++.h>
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define repr(i,n) for(int i=n;i>=0;i--)
#define For(i,m,n) for(int i=m;i<n;i++)
#define Forr(i,m,n) for(int i=m;i>n;i--)
#define Sort(a) sort(a.begin(),a.end())
#define pb push_back
#define vl vector<ll>
#define vll vector<vector<ll>>
#define INF 999999999999

int main(){
 int N; double v[1001],ans;
 cin>>N;
 rep(i,N){
   cin>>v[i];
 }
 sort(v,v+N);
 int i=0;
 while(N!=1){
   v[i+1]=(v[i]+v[i+1])/2;
   ans=v[i+1];
   N--; i++;
 }
 cout<<fixed<<setprecision(10)<<ans<<endl;
 return 0;
}


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

int main()
{
    int n, m, x;
    cin >> n >> m >> x;
    vector<int> c(n);
    vector<vector<int>> a(n, vector<int>(m));

    rep(i, n) {
        cin >> c[i];
        rep(j, m)
            cin >> a[i][j];
    }

    int ans = -1;
    rep(i, 1 << n) {
        vector<int> r(m, 0);
        int total = 0;
        rep(j, n) {
            if (i & 1 << j) {
                rep(k, m)
                    r[k] += a[j][k];
                total += c[j];
            }
        }
        int flg = true;
        rep(k, m) {
            if (r[k] < x) flg = false;
        }
        if (flg) {
            if (ans == -1) {
                ans = total;
            } else {
                ans = min(ans, total);
            }
        }
    }
    cout << ans;

    return 0;
}


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

int main(){
  int K;
  int A,B;
  bool T = false;

  cin >> K;
  cin >> A >> B;

  for(int i = A; i <= B; i++){
    if(i % K == 0) T = true;
  }

  if(T) cout << "OK" << endl;
  else cout << "NG" << endl;


}


Measured memory_bytes: 3620
S = input()
words = ["dream", "dreamer", "erase", "eraser"]

id = len(S)
while(id > 0):
    if S[:id].endswith("dream"):
        id -= 5
    elif S[:id].endswith("dreamer"):
        id -= 7
    elif S[:id].endswith("erase"):
        id -= 5
    elif S[:id].endswith("eraser"):
        id -= 6
    else:
        print("NO")
        exit(0)
print("YES")


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

int main() {
	std::ios_base::sync_with_stdio(false); std::cin.tie(NULL);
	int n;
	std::cin >> n;
	std::vector<int> vals(n);
	for(int i = 0; i < n; i++) {
		std::cin >> vals[i];
		vals[i] -= i + 1;
	}
	std::sort(vals.begin(), vals.end());
	int mid = vals[n / 2];
	long long ans = 0;
	for(int i = 0; i < n; i++) {
		ans += std::max(vals[i] - mid, mid - vals[i]);
	}
	std::cout << ans << std::endl;
}

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

/**
 * A Traveler
 */
public class Main {

	public static void main(String[] args) throws IOException {

		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String line = "";

		while ((line = br.readLine()) != null && !line.isEmpty()) {

			int n = Integer.parseInt(line.substring(0, line.indexOf(' ')));
			int m = Integer.parseInt(line.substring(line.indexOf(' ') + 1));

			int[] d = new int[n];
			for (int i = 0; i < n - 1; i++) {
				d[i] = Integer.parseInt(br.readLine());
			}
			long sum = 0;
			int inn = 0;
			for (int i = 0; i < m; i++) {
				int mm = Integer.parseInt(br.readLine());
				if (mm > 0) {
					for (int j = inn; j < inn + mm; j++) {
						sum += d[j];
					}
				} else {
					for (int j = inn - 1; j >= inn + mm; j--) {
						sum += d[j];
					}
				}
				inn += mm;
			}
			System.out.println(sum % 100000);

		}

	}
}

Measured memory_bytes: 37224
def p(n):
    l=[]
    p=[2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97]
    for x in p:
        i=1
        c=0
        if x>n:break
        while x**i<=n:
            c+=(n//(x**i))
            i+=1
        l.append(c)
    return l
l=sorted(p(int(input())),reverse=True)
c=0
ln=len(l)
for i in range(ln):
    if l[i]>=74:c+=1
for i in range(ln):
    for j in range(i+1,ln):
        if l[j]>=24:c+=1
        if l[i]>=24 and l[j]>=2:c+=1
        if l[j]>=14:c+=1
        if l[i]>=14 and l[j]>=4:c+=1
for i in range(ln):
    for j in range(i+1,ln):
        for k in range(j+1,ln):
            if l[k]>=4:c+=2
            if l[i]>=4 and l[j]>=4 and l[k]>=2:c+=1
print(c)

Measured memory_bytes: 3064
#include <cstdlib>
#include <iostream>
#include <map>
#include <stack>
#include <utility>
#include <vector>
using namespace std;

struct futon {
	int x, y;
	char d;
	futon(int x = 0, int y = 0, char d = 0):x(x), y(y), d(d){}
};

istream& operator>>(istream& is, futon& f) {
	return is >> f.x >> f.y >> f.d;
}

const int LEFT_BOTTOM = (1 << 25);
const int dx[2][2][3] = {{{-1, 0, 0}, {0, -1, 1}}, {{2, 1, 1}, {0, -1, 1}}};
const int dy[2][2][3] = {{{0, 1, -1}, {-1, 0, 0}}, {{0, -1, 1}, {2, 1, 1}}};

typedef pair<int, int> point;

vector<int> color;
map<point, int> field;
vector<futon> futons;

bool dfs(int start) {
	stack<pair<int, int>> sta;
	sta.push(make_pair(start, 0));

	while(!sta.empty()) {
		const int idx = sta.top().first;
		const int c = sta.top().second;
		sta.pop();

		if(color[idx] != -1) {
			if(color[idx] == c) continue;
			else return false;
		}
		color[idx] = c;

		const int x = futons[idx].x;
		const int y = futons[idx].y;
		const int d = futons[idx].d - 'x';

		for(int i = 0; i < 2; ++i) {
			for(int j = 0; j < 3; ++j) {
				point np(x + dx[i][d][j], y + dy[i][d][j]);
				if(!field.count(np)) continue;

				int next_c = (c ^ i);
				int next_idx = field[np];
				if(!(next_idx & LEFT_BOTTOM)) next_c = !next_c;
				else next_idx &= ~LEFT_BOTTOM;

				sta.push(make_pair(next_idx, next_c));
			}
		}
	}

	return true;
}

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

	for(int n; cin >> n && n;) {
		futons.clear();
		futons.resize(n);

		field.clear();
		for(int i = 0; i < n; ++i) {
			cin >> futons[i];
			field[point(futons[i].x, futons[i].y)] = (i | LEFT_BOTTOM);
			if(futons[i].d == 'x') field[point(futons[i].x + 1, futons[i].y)] = i;
			else field[point(futons[i].x, futons[i].y + 1)] = i;
		}

		color.assign(n, -1);
		string ans = "Yes";
		for(int i = 0; i < n; ++i) {
			if(color[i] == -1 && !dfs(i)) {
				ans = "No";
				break;
			}
		}

		cout << ans << endl;
	}

	return EXIT_SUCCESS;
}

Measured memory_bytes: 4208
/*------------------------------------
........Bismillahir Rahmanir Rahim....
..........created by Abdul Aziz.......
------------------------------------*/
#include <iostream>
#include <algorithm>
#include <stdio.h>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <cstring>
#include <unordered_map>
#include <queue>
#define   mod  998244353
#define   int  long long 
#define   ld   long double
#define   pb   push_back
#define   vi  vector<int> 
#define   dbg(x)  cerr << #x << " = " << x << '\n'
#define   sz(x)  (int)x.size()
#define   all(a) (a.begin(),a.end())
#define   ff   first
#define   ss   second
#define   pii  pair<int,int> 
#define   lcm(a,b) (a*b)/__gcd(a,b) 
using namespace std;

inline void solve(){
    string  s ; cin >> s ; 
    int n=sz(s);
    vi pref(n+2,1);
    for (int i=0,c=0;i<n-1;i++){
        if (s[i]==s[i+1] and s[i]=='R'){
            pref[i+2] += pref[i];
            pref[i]=0;
        }
    }
    for (int i=n-1,c=0;i>0;i--){
        if (s[i]==s[i-1] and s[i]=='L'){
            pref[i-2] += pref[i];
            pref[i]=0;
        }
    }
    for (int i=0;i<n;i++) cout << pref[i] <<" ";
    cout << endl;
}

signed main()
{
    int n=1; // cin>>n;
    while (n--) solve();
    return 0;
}


Measured memory_bytes: 4288
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;

public class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		int n = Integer.parseInt(br.readLine());

		int x[] = new int[n];
		int y[] = new int[n];
		long h[] = new long[n];

		int index = 0;
		for (int i = 0; i < n; i++) {
			String str[] = br.readLine().split(" ");
			x[i] = Integer.parseInt(str[0]);
			y[i] = Integer.parseInt(str[1]);
			h[i] = Long.parseLong(str[2]);

			if (h[i] != 0) {
				index = i;
			}
		}

		for (int i = 0; i <= 100; i++) {
			for (int j = 0; j <= 100; j++) {
				int H = (int) (h[index] + Math.abs(i - x[index]) + Math.abs(j - y[index]));
				boolean flag = true;
				
				for (int k = 0; k < n; k++) {
					if (Math.max(H - Math.abs(i - x[k]) - Math.abs(j - y[k]), 0) != h[k]) {
						flag = false;
						break;
					}
				}
				if (flag) {
					System.out.println(i + " " + j + " " + H);
					return;
				}
			}
		}
	}
}


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

using namespace std;
 
#define rep2(x,fr,to) for(int (x)=(fr);(x)<(to);(x)++)
#define rep(x,to) for(int (x)=0;(x)<(to);(x)++)
#define repr(x,fr,to) for(int (x)=(fr);(x)>=(to);(x)--)
#define all(c) (c).begin(),(c).end()
#define sz(v) (int)(v).size()

typedef int64_t ll; typedef vector<int> VI; typedef pair<ll,ll> pii;
const ll mod = 1e9+7;

void dbg(){ cerr << "\n"; }  
template <typename T,typename ...T2>
void dbg(const T& fst, const T2&...rst){ cerr << fst << ": "; dbg(rst...); }

const ll INF = 1LL<<60;

int main()
{
 
	//cin.tie(0); ios_base::sync_with_stdio(false);
	
	int n, m;
	cin >>n >> m;
	vector<vector<pii>> r(n);
	rep(i, m){
		int l,rr,d;
		cin >>l >>rr >>d;
		r[l-1].emplace_back(rr-1, d);
		r[rr-1].emplace_back(l-1, -d);
	}


	vector<ll> ds(n, INF);
	rep(i, n){
		if(ds[i] != INF) continue;
		queue<int > que;
		que.push(i); ds[i]=0;
		while(!que.empty()){
			int cr = que.front();  que.pop();
			for(auto x: r[cr]){
				if(ds[x.first] == INF){
					que.push( x.first );
					ds[x.first] = ds[cr] + x.second;
				}else if(ds[x.first] != ds[cr] + x.second){
					puts("No");
					return 0;
				}
			}
		}
	}
	puts("Yes");
	return 0;
}


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

typedef long long ll;
typedef pair<int, int> pi;

#define rep(i, n) for (int i = 0; i < n; i++)
#define rep_op(i, a, n) for (int i = a; i < n; i++)
#define rep_d(j, n) for (int j = n; j >= 0; j--)
#define rep_d_op(j, n, a) for (int j = n; j >= a; j--)

template <class T>
inline bool chmax(T &a, T b)
{
    if (a < b)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
inline bool chmin(T &a, T b)
{
    if (a > b)
    {
        a = b;
        return 1;
    }
    return 0;
}

const int MOD = 1000000007;

const vector<int> dx = {1, 0};
const vector<int> dy = {0, 1};
const ll INF = 1LL << 60;

// int max = *std::max_element(vec.begin(), vec.end());
// int sum = accumulate(list, list + size, 0);

int main()
{
    int n;
    cin >> n;
    int res = 0;
    vector<int> a = {1, 2, 4, 8, 16, 32, 64};
    rep(i, 7)
    {
        if (n >= a[i])
        {
            res = a[i];
        }
    }
    cout << res << endl;
}


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


int main(){
  int n,m;
  cin >> n >> m;
  int h[n];
  for(int i=0;i<n;i++) cin >> h[i];

  bool dp[n];
  for(int i=0;i<n;i++) dp[i] = false;
  for(int i=0;i<m;i++){
      int a,b;
      cin >> a >> b;
      if(h[a-1] > h[b-1]) dp[b-1] =true;
      else if(h[a-1] < h[b-1]) dp[a-1]= true;
      else if(h[a-1] == h[b-1]){
          dp[a-1] = true;
          dp[b-1] = true;
      }
  }
  int cnt = 0;
  for(int i=0;i<n;i++){
      if(!dp[i]){
          cnt++;
      
      }
  }

  cout << cnt << endl;
  return 0;
}


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

int main() {
	long long x,year;
  	long long money = 100;
  
  	cin >> x;
  	for (year=0;money<x;year++) {
    	money *= 1.01;
    }
  	cout << year << endl;
  	
}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
int h,t[500001];
void maxHeapify(int i){
  int l = i*2,r = i*2+1,largest;
  if (l<=h&&t[l]>t[i])
    largest=l;
  else 
    largest = i;
  if(r<=h&&t[r]>t[largest])
    largest=r;
  if(largest!=i)
    swap(t[i],t[largest]),maxHeapify(largest);
}

void buildMaxHeap(){
  for(int i=h/2;i>0;i--)
    maxHeapify(i);
}
int main(){
  cin>>h;
  for(int i=1;i<=h;i++)cin>>t[i];
  buildMaxHeap();
  for(int i=1;i<=h;i++)cout<<" "<<t[i];
  cout<<endl;
  return 0;
}

Measured memory_bytes: 3112
#include <stdio.h>
#define M 100000
#define N -1

struct Node{
int parent,left,right;
};
struct Node T[M];
int D[M],H[M];

void setdepth(int u,int d){
  if(u==N)return;
  D[u]=d;
  setdepth(T[u].left,d+1);
  setdepth(T[u].right,d+1);
}

int setheight(int u){
  int h1=0,h2=0;
  if(T[u].left != N)
    h1=setheight(T[u].left)+1;
  if(T[u].right != N)
    h2=setheight(T[u].right)+1;
  if(h1>h2) return H[u]=h1;
  else return H[u]=h2;
}

int getsibling(int u){
  if(T[u].parent==N)return N;
  if(T[T[u].parent].left != u && T[T[u].parent].left != N)
    return T[T[u].parent].left;
  if(T[T[u].parent].right != u && T[T[u].parent].right != N)
    return T[T[u].parent].right;
  else return N;
}

void print(int u){
  int cnt=0;
  printf("node %d: ",u);
  printf("parent = %d, ",T[u].parent);
  printf("sibling = %d, ",getsibling(u));
  if(T[u].left!=N) cnt++;
  if(T[u].right!=N) cnt++;
  printf("degree = %d, ",cnt);
  printf("depth = %d, ",D[u]);
  printf("height = %d, ",H[u]);

  if(T[u].parent == N){
    printf("root\n");
  }else if(T[u].left == N && T[u].right == N){
    printf("leaf\n");
  }else{
    printf("internal node\n");
      }
}

int main(){
  int n,i,k,t,y,root;

  scanf("%d",&n);
  for(i=0;i<n;i++){
    T[i].parent=N;
  }

  for(i=0;i<n;i++){
    scanf("%d %d %d",&k,&t,&y);
    T[k].left=t;
    T[k].right=y;
    if(t!=N)T[t].parent=k;
    if(y!=N)T[y].parent=k;
  }
  for(i=0;i<n;i++){
    if(T[i].parent == N) root=i;
  }
  setdepth(root,0);
  setheight(root);

  for(i=0;i<n;i++){
    print(i);
  }

  return 0;
}
	  

  
		    



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

int main() {
  string S;
  cin>>S;
  int x=S.size();
  
  for(int i=0;i<x;i++){
    if(S.at(i)=='?')
      S.at(i)='D';
  }
  
  cout<<S<<endl;
}


Measured memory_bytes: 3720
import sys

sys.setrecursionlimit(10 ** 9)

class UnionFind:
    def __init__(self, n):
        self.parents = [i for i in range(n)]
        self.sizes = [1] * n

    def find(self, x):
        if self.parents[x] == x:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def unite(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if x == y:
            return
        self.parents[y] = x
        self.sizes[x] += self.sizes[y]
        self.sizes[y] = self.sizes[x]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def size(self, x):
        return self.sizes[self.find(x)]


n, m, k = map(int, input().split())
uf = UnionFind(n)
friends = [0] * n
blocks = [0] * n
for i in range(m):
    a, b = map(int, input().split())
    friends[a - 1] += 1
    friends[b - 1] += 1
    uf.unite(a - 1, b - 1)
for i in range(k):
    c, d = map(int, input().split())
    if uf.same(c - 1, d - 1):
        blocks[c - 1] += 1
        blocks[d - 1] += 1
ans = [0] * n
for i in range(n):
    ans[i] = uf.size(i) - friends[i] - blocks[i] - 1
print(*ans)


Measured memory_bytes: 41420
#include <bits/stdc++.h>
#define pb push_back
#define cmin(a,b) (a>b?a=b:a)
#define cmax(a,b) (a<b?a=b:a)
#define mem(a,k) memset(a,k,sizeof(a))
#define lop(i,s,t) for(int i=s;i<(t);++i)
#define rep(i,s,t) for(int i=s;i<=(t);++i)
#define dec(i,s,t) for(int i=s;i>=(t);--i)
#define fore(i,v) for(int i=g[v],d=es[i].d;i;i=es[i].nxt,d=es[i].d)
using namespace std;

#define Pr(f,...) //fprintf(stderr,f,##__VA_ARGS__),fflush(stderr)

typedef long long ll;

template<typename T>
void read(T &x){
	x=0; 
	char c;
	for(c=getchar();!isdigit(c);c=getchar()); 
	for(;isdigit(c);c=getchar())x=x*10+c-'0'; 
}

const int N=1e6+50;

int n,a[N],p[N],ans;

int main(int argc,char *argv[]){
#ifdef CURIOUSCAT
#endif
	read(n);
	rep(i,1,n)read(a[i]),p[i]=i;
	sort(p+1,p+n+1,[](int x,int y){return a[x]<a[y];});
	rep(i,1,n)ans+=p[i]%2!=i%2;
	printf("%d\n",ans/2);
	return 0;
}

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

int main() {
	int N, M, L, R, ans = 0;
	cin >> N >> M;
	vector<int> a(N + 1);
	for (int i = 0; i < M; ++i) {
		cin >> L >> R;
		--L;
		--R;
		++a[L];
		--a[R + 1];
	}
	for (int i = 1; i < N + 1; ++i) a[i] += a[i - 1];
	for (int& i : a) {
		if (i == M) ++ans;
	}
	cout << ans;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
char s[100010];
int n;
int main() {
	scanf("%d%s", &n, s);
	const int MOD = 1e9 + 7;
	int c[26] = {0};
	for(int i=0; i<n; i++)
		c[s[i]-'a']++;
	int res = 1;
	for(int i=0; i<26; i++)
		res = 1ll * res * (c[i] + 1) % MOD;
	printf("%d", res - 1);
	return 0;
}

Measured memory_bytes: 384
package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
)

func main() {
	N := ReadInt()
	m := make(map[string]int)
	for i := 0; i < N; i++ {
		s := []byte(ReadString())
		sort.Slice(s, func(i, j int) bool {
			return s[i] < s[j]
		})
		m[string(s)]++
	}
	ans := 0
	for _, c := range m {
		ans += c * (c - 1) / 2
	}
	fmt.Println(ans)
}

var reader = bufio.NewReader(os.Stdin)

func Scan(a ...interface{}) {
	if _, err := fmt.Fscan(reader, a...); err != nil {
		panic(err)
	}
}
func ReadInt() (i int)       { Scan(&i); return }
func ReadString() (s string) { Scan(&s); return }


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

int pop(int *s, int *top);
void push(int *s, int *top, int op);

int main(int argc, char const *argv[])
{
  int top=0, s[101],op1,op2;
  char ch[1000000];

  while(scanf("%s", ch) != EOF) {
    if(ch[0]=='+') {
      op1 = pop(s, &top);
      op2 = pop(s, &top);
      push(s, &top, op1 + op2);
    } else if(ch[0]=='-') {
      op1 = pop(s, &top);
      op2 = pop(s, &top);
      push(s, &top, op2 - op1);
    } else if(ch[0]=='/') {
      op1 = pop(s, &top);
      op2 = pop(s, &top);
      push(s, &top, op2 / op1);
    } else if(ch[0]=='*') {
      op1 = pop(s, &top);
      op2 = pop(s, &top);
      push(s, &top, op1 * op2);
    } else {
      push(s, &top, atoi(ch));
    }
  }
  printf("%d\n", s[1]);
  return 0;
}

int pop(int *s, int *top) {
  (*top)--;
  return s[*top+1];
}

void push(int *s, int *top, int op) {
  s[*top+1] = op;
  (*top)++;
}

Measured memory_bytes: 2764
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define ll long long int 
int main()
{
    string s;
    cin>>s;
    if(s[0]=='S')
    cout<<"Cloudy";
    else if(s[0]=='C')
    cout<<"Rainy";
    else
    cout<<"Sunny";

    return 0;
}


Measured memory_bytes: 3608
#include <bits/stdc++.h>
using namespace std;
vector<pair<int, int> > sortme;
int n,a,rs;
int main()
{
	cin>>n;
	for(int i=0; i<n; ++i)
	{
		cin>>a;
		sortme.push_back({a, i});
	}
	sort(sortme.begin(), sortme.end());
	for(int i=0; i<n; ++i)
	{
		rs+=(i%2 != sortme[i].second%2);
	}
	rs/=2;
	cout<<rs;
}


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

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

  int c, d, e;
  c=0;
  d=0;
  e=0;
  
  for(int i=a; i<b+1; i++){
    if(i<0){
      c=c+1;
    }
    if(i==0){
      d=d+1;
    }
    if(i>0){
      e=e+1;
    }
  }
  
  if(d==1){
    cout << "Zero" << endl;
  }
  if(d!=1 and c % 2 == 1){
    cout << "Negative" << endl;
  }
  if(d!=1 and c % 2 == 0){
    cout << "Positive" << endl;
  }
  
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;


#define NUM 1001

ll nCm[NUM][NUM];

int main(){

	ll N,K;
	scanf("%lld %lld",&N,&K);

	if(N < K){
		printf("0\n");
		return 0;
	}

	nCm[0][0] = 1;
	for(int n = 1; n <= N; n++){
		for(int m = 0; m <= K; m++){

			if(n == 0){

				nCm[n][m] = 1;

			}else{

				nCm[n][m] = nCm[n-1][m]+nCm[n-1][m-1];

			}
			nCm[n][m] %= MOD;
		}
	}

	printf("%lld\n",nCm[N-1][K-1]);

	return 0;
}



Measured memory_bytes: 11004
#include <algorithm>
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define ll long long
#define ld long double
#define INF 1000000000000000000
typedef pair<ll, ll> pll;
typedef pair<int, int> pint;

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

    ll N;
    cin >> N;
    ll ans = 0;
    for (int i = 1; i <= N; i++) {
        ans += (i + (N / i) * i) * (N / i) / 2;
    }

    cout << ans << endl;
}

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

int main()
{
  int n, q;
  string str;
  cin >> n >> q >> str;
  int l[q], r[q];
  for (int i = 0; i < q; i++) cin >> l[i] >> r[i];
  
  int tof[n];
  tof[0] = 0;
  for (int i = 1; i < n; i++) {
    tof[i] = (str[i-1] - str[i] == -2) ? 1 : 0;
  }
  
  int sum[n];
  sum[0] = 0;
  for (int i = 1; i < n; ++i) {
    sum[i] = sum[i-1] + tof[i];
  }

  for (int i = 0; i < q; ++i) {
    cout << sum[r[i] - 1] - sum[l[i] - 1] << endl;
  }
  return 0;
}

Measured memory_bytes: 2560
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
typedef long long LL;
int N;
int A[3][3];
bool check[3][3];
int main(){
	REP(i,3){
		REP(j,3){
			cin>>A[i][j];
			check[i][j]=false;
		}
	}
	cin>>N;
	REP(k,N){
		int b;
		cin>>b;
		REP(i,3){
			REP(j,3){
				if(A[i][j]==b){
					check[i][j]=true;
				}
			}
		}
	}
	/*REP(i,3){
		REP(j,3){
			if(check[i][j]==true){
				cout<<1<<" ";
			}else{
				cout<<0<<" ";
			}
		}
		cout<<endl;
	}*/
	if(check[0][0]==true&&check[0][1]==true&&check[0][2]==true){
		cout<<"Yes"<<endl;
		return 0;
	}
	if(check[1][0]==true&&check[1][1]==true&&check[1][2]==true){
		cout<<"Yes"<<endl;
		return 0;
	}
	if(check[2][0]==true&&check[2][1]==true&&check[2][2]==true){
		cout<<"Yes"<<endl;
		return 0;
	}
	
	if(check[0][0]==true&&check[1][0]==true&&check[2][0]==true){
		cout<<"Yes"<<endl;
		return 0;
	}
	if(check[0][1]==true&&check[1][1]==true&&check[2][1]==true){
		cout<<"Yes"<<endl;
		return 0;
	}
	if(check[0][2]==true&&check[1][2]==true&&check[2][2]==true){
		cout<<"Yes"<<endl;
		return 0;
	}
	if((check[0][0]==true)&&(check[1][1]==true)&&(check[2][2]==true)){
		cout<<"Yes"<<endl;
		return 0;
	}
	if((check[2][0]==true)&&(check[1][1]==true)&&(check[0][2]==true)){
		cout<<"Yes"<<endl;
		return 0;
	}
	cout<<"No"<<endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<functional>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<tuple>
#include<stack>
#include<queue>
#include<deque>
#include<sstream>
#include<stdio.h>
#include<math.h>
#include<stdlib.h>
#include<bitset>
#include<time.h>
#include<cstdlib>
#include<cassert>
#define ll long long
#define fi first
#define se second
using namespace std;

int n,m;
string s;
const int inf=999999999;

inline ll bfs(){
  ll ans=inf;
  queue<pair<int,ll> > q;
  q.push(make_pair(0,1));
  while(!q.empty()){
    int now=q.front().fi;
    ll nown=q.front().se;
    q.pop();
    if(now==n){
      ans=min(ans,nown);
      continue;
    }
    q.push(make_pair(now+1,nown+m));
    q.push(make_pair(now+1,nown*2));
  }
  return ans;
}
                   
int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.precision(10);
  cout<<fixed;
#ifdef LOCAL_DEFINE
    freopen("in", "r", stdin); 
    freopen("out","w",stdout);
#endif
  cin>>n>>m;
  cout<<bfs()<<endl;
#ifdef LOCAL_DEFINE
    cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif
  return 0;
}

Measured memory_bytes: 256
from collections import deque
H,W,K=map(int,input().split())
A=[list(input())for _ in[0]*H]
for i,a in enumerate(A):
	if"S"in a:y,x=i,a.index("S")
d=1e9
Q=deque([(1,y,x)])
while Q:
	c,i,j=Q.popleft();d=min(d,i,j,H-i-1,W-j-1)
	if c>K:continue
	for h,w in((i+1,j),(i,j+1),(i-1,j),(i,j-1)):
		if 0<=h<H and 0<=w<W and A[h][w]==".":A[h][w]="";Q+=[(c+1,h,w)]
print(1--d//K)

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

#define int         long long
#define pb          push_back
#define pii         pair<int,int>
#define vi          vector<int>
#define vii         vector<pii>
#define mi          map<int,int>
#define mii         map<pii,int>
#define all(a)      (a).begin(),(a).end()
#define sz(x)       (int)x.size()
#define endl        "\n"
#define repp(i,a,b) for(int i=a;i<b;i++)
#define rep(i,a,b) 	for(int i=a;i<=b;i++)
#define IOS         ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);

const int N=1e5 + 5;

int32_t main()
{
	IOS;
	int r,d,x;
	cin >> r >> d >> x;
	int ans=x;
	rep(i,1,10)
	{
		ans = r*ans - d;
		cout << ans << endl;
	}
}


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

int main() {
    ll n,k;
    cin>>n>>k;
    ll ar[n+1];
    for(ll i=1;i<=n;i++)cin>>ar[i];
    ll dp[n+1];
    for(ll i=1;i<=n;i++)dp[i]=(ll)1e18;
    dp[1]=0;
    for(ll i=2;i<=n;i++)
    {   //cout<<dp[i]<<endl;
        for(ll j=1;j<=k;j++)
       {    if(i-j<=0)break;
           dp[i]=min( dp[i-j]+abs(ar[i]-ar[i-j]) ,dp[i]);
           
       }
       
    }
    cout<<dp[n];
    
}

Measured memory_bytes: 1792
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text.RegularExpressions;
using static System.Math;
class Program
{
    public static void Main(string[] args)
    {
        var v = Enumerable
            .Range(0, 5)
            .Select(_ => int.Parse(Console.ReadLine()))
            .ToArray();
        var k = int.Parse(Console.ReadLine());

        int i = 0;
        string ret = "Yay!";
        foreach (var item1 in v)
        {
            foreach (var item2 in v.Skip(i))
            {
                if (item2 - item1 > k)
                {
                    ret  = ":(";
                }
            }
            i++;
        }

        Console.WriteLine(ret);
    }
}

Measured memory_bytes: 11348
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <string>
#include <map>
#include <set>
#include <stack>
#include <tuple>
#include <deque>
#include <numeric>
#include <bitset>
#include <iomanip>
#include <cassert>
#include <chrono>
#include <random>
#include <limits>
#include <iterator>
#include <functional>
#include <sstream>
#include <complex>
#include <cstring>
using namespace std;

using ll = long long;
using P = pair<int, int>;
constexpr int INF = 1001001001;
constexpr int mod = 1000000007;
// constexpr int mod = 998244353;

template<class T>
inline bool chmax(T& x, T y){
    if(x < y){
        x = y;
        return true;
    }
    return false;
}
template<class T>
inline bool chmin(T& x, T y){
    if(x > y){
        x = y;
        return true;
    }
    return false;
}

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

    string s;
    cin >> s;
    int n = s.length();
    int ans = 0;
    string prev = "";
    for(int i = 0; i < n;){
        if(s.substr(i, 1) != prev){
            ++ans;
            prev = s.substr(i, 1);
            ++i;
        }
        else if(i == n - 1) break;
        else{
            ++ans;
            prev = s.substr(i, 2);
            i += 2;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3784
# D
N = int(input())

a = list(map(int, input().split()))

X=[0]*N
for i in range(N, 0, -1):
    j=1
    tmp=0
    while(i*j<=N):
        tmp+=X[i*j-1]
        j+=1
    if tmp%2 == a[i-1]:
        X[i-1]=0
    else:
        X[i-1]=1
#     X[i-1] = tmp%2

# if (sum(X[1:])%2==a[0]):
#     X[0] = 0
# else:
#     X[0] = 1
    
print(sum(X))
for i, j in enumerate(X):
    if j == 1:
        print(str(i+1) + " ", end="")

Measured memory_bytes: 7148
#include <iostream>
#include <cmath>
#include <string>
#include <algorithm>
#include <set>
#include <vector>
#include <map>
#include <list>
#include <stack>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <queue>
#define mkp make_pair
#define pr(num) cout << num << "\n"
#define max(a, b) ((a)>(b) ? (a):(b))
#define min(a, b) ((a)<(b) ? (a):(b))
#define INF 1000000000000000000
#define MOD 1000000007LL
#define MAX 100010
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef map<ll, ll> Map;

ll h[55], p[55];

ll rec(ll lv, ll x) {
    if(lv==0) {
        if(x>0) return 1;
        else return 0;
    }
    
    ll res=0;
    
    if(x>h[lv-1]+1) {
        res+=rec(lv-1, x-h[lv-1]-2)+p[lv-1]+1;
    }else {
        res+=rec(lv-1, x-1);
    }
    
    return res;
}

int main(void) {
    ll N, X;
    cin >> N >> X;
    ll i;

    h[0]=p[0]=1;
    
    for(i=1; i<=N; i++) {
        h[i]=h[i-1]*2+3;
        p[i]=p[i-1]*2+1;
    }
    
    pr(rec(N, X));
    
    
}

























Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <cmath>
#include <queue>
#include <algorithm>
#include <cstring>

using namespace std;


int a[3];

int main() {
    cin >> a[0] >> a[1] >> a[2];
    sort(a, a + 3);
    a[1] -= a[0], a[2] -= a[0], a[0] = 0;
    int ans;
    if (a[1] % 2 == 0) {
        ans = a[1] / 2 + (a[2] - a[1]);
    } else {
        if (a[2] % 2 == 0) {
            ans = a[2] / 2 + 1 + (a[2] + 1 - a[1]) / 2;
        } else {
            ans = (a[2] - a[1]) / 2 + 1 + (a[2] + 1) / 2;
        }
    }
    printf("%d\n", ans);
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
using namespace std;
#define int long long
signed main() {
	int n; cin >> n;
	int max = 0, sum = 0;
	for (int i = 0; i < n; i++) {
		int p; cin >> p;
		if (p >= max) {
			sum += max;
			max = p;
		}
		else sum += p;
	}
	cout << (max < sum ? "Yes\n" : "No\n");
}

Measured memory_bytes: 256
def s(n):
    ans = 0
    for ch in str(n):
        ans += int(ch)

    return ans


def main():
    n = int(input())

    sn = s(n)

    if n % sn == 0:
        print("Yes")
    else:
        print("No")


if __name__ == "__main__":
    main()


Measured memory_bytes: 61808
import sys
input = sys.stdin.readline
from operator import itemgetter

def main():
	s = input().strip()
	k = int(input().strip())
	ans = "1"
	for i in range(len(s)):
		if s[i] != '1' and i+1 <= k:
			ans = s[i]
			break
	print(ans)

if __name__ == '__main__':
	main()


Measured memory_bytes: 38256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define rep2(i,x,n) for(int i=x; i<(n); i++)
#define ALL(n) begin(n),end(n)
#define INF ((1<<30)-1)
#define LINF (1LL<<60)
#define EPS (1e-10)
typedef long long Int;
typedef pair<Int, Int> P;
typedef pair<int, int> pint;
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    Int d,t,s; cin>>d>>t>>s;

    if(d<=t*s) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
 
    return 0;
}


Measured memory_bytes: 3660
import itertools
n = int(input())
a = [0, 3, 5, 7]
ans = []
res = 0
for i in itertools.product(a, repeat = 9):
    val = 0
    for j in range(len(i)):
        val += 10 ** j * i[j]
    # print(val)
    tmp = str(val)
    if val <= n and len(set(tmp)) == 3 and "0" not in tmp:
        res += 1
        ans.append(val)

ans.sort()
print(res)
# print(ans)

Measured memory_bytes: 10040
#include<stdio.h>
#include<iostream>
#include<string.h>
#include<algorithm>
#include<queue>
#include<stack>
#include<math.h>
#include<map>
typedef long long int ll;
using namespace std;
#define maxn 0x3f3f3f3f
int main()
{
   ll n,m;
   cin>>n>>m;
   printf("%lld\n",max((ll)0,10-n)*100+m); 

}

Measured memory_bytes: 256