akhauriyash/Code-Regression huggingface dataset:
s = str(input())
t = str(input())

len_s = len(s)
len_t = len(t)

DP = [[0 for _ in range(len_t+1)] for _ in range(len_s+1)]

for i in range(len_s):
    for j in range(len_t):
        if s[i] == t[j]:
            DP[i+1][j+1] = max(DP[i][j]+1, DP[i+1][j+1])
        else:
            DP[i+1][j+1] = max(DP[i+1][j], DP[i+1][j+1])
            DP[i+1][j+1] = max(DP[i][j+1], DP[i+1][j+1])

i = len_s
j = len_t
ans = ''

while i > 0 and j > 0:
    if DP[i][j] == DP[i-1][j]:
        i -= 1
    elif DP[i][j] == DP[i][j-1]:
        j -= 1
    else:
        ans = s[i-1] + ans
        i -= 1
        j -= 1
print(ans)
 

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

int Check1(char S[],char T[],int i)
{
    int a;
    int flag=1;
    for(a=0;a<strlen(T);a++)
    {
        if((S[i+a]!=T[a])&&(S[i+a]!='?'))
        flag=0;
    }
    if(flag==1)
            {return 1;}
        else
            {return 0;}
}
int Check2(char S[],char T[],int i)
{
    int a;
    int flag=1;
    for(a=0;a<strlen(T);a++)
    {
        if(S[i+a]!='?')
            flag=0;
    }
    if(flag==1)
        return 1;
    else
        return 0;
}
int main()
{
    char P[100];
    char T[100];
    char S[100];
    char S1[100];
    scanf("%s",P);
    scanf("%s",T);
    strcpy(S,P);
    strcpy(S1,P);
    if(strstr(S,T)!=0)
        {
            int i=0;
        for( ;i<strlen(S);i++)
        {
            if(S[i]=='?')
            S[i]='a';
        }
        printf("%s",S);
        return 0;
        }
    int tail=strlen(S)-strlen(T);
    for( ;tail>=0;tail--)
    {
        int change;
        if(Check1(S,T,tail)==1)
        {
            for(change=tail;change<tail+strlen(T);change++)
                    {S[change]=T[change-tail];
                    }
                int i=0;
                for( ;i<strlen(S);i++)
                    {
                        if(S[i]=='?')
                            S[i]='a';
                    }
        }
        change=tail;
        if(Check2(S1,T,tail)==1)
        {
            for(change=tail;change<tail+strlen(T);change++)
                    {S1[change]=T[change-tail];}
                    int i=0;
                for( ;i<strlen(S);i++)
                {
                    if(S1[i]=='?')
                        S1[i]='a';
                }
        }
        if((Check2(S1,T,tail)==1)&&(Check1(S,T,tail)==1))
           {
            if(strcmp(S1,S)>0)
            {printf("%s",S1);
            return 0;}
        else
            {printf("%s",S);
            return 0;}
           }
           else if(Check2(S1,T,tail)==1)
           {
               printf("%s",S1);
               return 0;
           }
           else if(Check1(S,T,tail)==1)
           {
               printf("%s",S);
               return 0;
           }
    }
        printf("UNRESTORABLE");
        return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <vector>

#define rep(i,a) for(int i = 0;i < a; i++)

using namespace std;

#define MAX 1000010

bool p[MAX];

void era(){

  rep(i,MAX)p[i] = (i<2)? false: true;

  for(int i = 2; i * i < MAX; i++) if(p[i]){
      for(int j = i*2; j < MAX; j += i) p[j] = false;
    }
}

int main(){
  era();
  int a, d, n;
  while(cin>>a>>d>>n,a||d||n){
    int cnt = 0;
    int k = -1;
    while(cnt != n){
      k++;
      if(p[a+d*k]) cnt++;
    }
    cout << a+d*k << endl;
  }
}

Measured memory_bytes: 2136
#include <iostream>
using namespace std;
int main()
{
    int N, sum = 0, V[20], C[20];
    cin >> N;
    for (int i = 0; i < N; i++)
    {
        cin >> V[i];
    }
    for (int i = 0; i < N; i++)
    {
        cin >> C[i];
        if (V[i] > C[i])
        {
            sum += V[i] - C[i];
        }
    }
    cout << sum << endl;
}

Measured memory_bytes: 256
word = list(map(int,input().split()))
score = list(map(int,input().split()))
score.sort()
score.reverse()
gokei = 0
for i in range(word[0]):
    gokei += score[i]
if score[word[1]-1]*4*word[1] >= gokei:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 61244
#include <stdio.h>
#include <math.h>
int main(){
	int n,i,s[1001];
	double s_sum,m,a;
	
	while(1){
		s_sum=0;
		scanf("%d",&n);
		if(n==0)break;
		
		for(i=0;i<n;i++){
			scanf("%d",&s[i]);
			s_sum+=s[i];
		}

		m=s_sum/n;
		s_sum=0;
		for(i=0;i<n;i++){
			s_sum+=(s[i]-m)*(s[i]-m);
		}
		a=s_sum/n;
		a=sqrt(a);
		
		printf("%lf\n",a);
	}
	return 0;
}

Measured memory_bytes: 636
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, a, b) for(long long i=(a);i<(b);++i)
#define rep(i, n) FOR(i, 0, n)
#define whole(x) (x).begin(),(x).end()
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
using ll = long long;
using P = pair<int, int>;
const int mod = 1000000007;

ll pow(ll a) {
    return a*a*a*a*a;
}

int main(){
    ll x;
    cin >> x;
    ll a, b;
    vector<ll> v(1000);
    rep(i, 1000) {
        v[i] = pow(i);
    }   
    rep(i, 999) for (ll j=i; j<1000; j++) {
        if (v[j]-v[i]==x) {
            a = j;
            b = i;
            break;
        }
        if (v[j]+v[i]==x) {
            a = j;
            b = -i;
            break;
        }
    }
    
    
    cout << a << " " << b << endl;
    return 0;
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
#ifdef HIRO
#define d(f_, ...) printf((f_), ##__VA_ARGS__)
#else
#define d(f_, ...)
#endif

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<long long> vll;
typedef queue<int> qi;
typedef queue< pair<int, int> > qp;
#define mp make_pair
#define pi 3.14159265358979323846
#define MAX max_element
#define MIN min_element
#define all(v) v.begin(), v.end()
#define gt(T) greater<T>()
#define sum(v) accumulate(v.begin(), v.end(), 0)
#define uni(v) do{ \
  sort(v.begin(), v.end()); \
  decltype(v)::iterator result = unique(v.begin(), v.end()); \
  v.erase(result, v.end()); \
}while(0)
#define fi(init, n) for(int i = init; i < n; ++i)
#define fj(init, n) for(int j = init; j < n; ++j)
#define fk(init, n) for(int k = init; k < n; ++k)
#define zero(x) memset(x, 0, sizeof(x))
#define negative(x) memset(x, ~0, sizeof(x))
const ll MOD = 1e9 + 7;
const int INF = 1e9;
const int di[] = { 0, 1, 0, -1 };
const int dj[] = { 1, 0, -1, 0 };

template<typename T>
T gcd(T a, T b) {
	return b ? gcd(b, a % b) : a;
}
template<typename T>
T lcm(T a, T b) {
	return a * b / gcd(a, b);
}
template<typename T>
int finder(vector<T> vec, T number) {
	auto itr = find(vec.begin(), vec.end(), number);
	size_t index = distance(vec.begin(), itr);
	if (index != vec.size()) return 1;
	else return 0;
}
ll frac(ll n){
	if (n == 0) return 1;
	return (n * frac(n - 1)) % MOD;
}
template<class T> inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
template<class T> inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}

int main(int argc, char** argv) {
#ifdef HIRO
  string quiz(argv[1]);
  string id(argv[2]);
  string filename("input/" + quiz + "/" + id + ".txt");
  ifstream fin(filename);
  if (fin.peek() == ifstream::traits_type::eof()) {
    cout << "No input.";
    return 0;
  }
  ifstream cin(filename);
  std::cin.rdbuf(cin.rdbuf());
#endif
  ll ans = 0;
  ll n;
  cin >> n;
  // ll n, m;
  // cin >> n >> m;
  // ll n, m, k;
  // cin >> n >> m >> k;
  int dir = 1, x;
  vi v;
  fi(0, n) {
    cin >> x;
    if(dir)
      v.push_back(x);
    else
      v.insert(v.begin(), x);
    dir ^= 1;
  }
  if(!dir)
    reverse(all(v));
  fi(0, n)
    cout << v[i] << " ";
  cout << endl;
  // cout << ans << endl;
  return 0;
}



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

int X[100], Y[100];

int main() {
  int N, A, B, result;
  int i;
  scanf ("%d %d %d", &N, &A, &B);
  
  result = A * N;
  result = (result>B) ? B : result;
  
  
  printf("%d", result);
  return 0;
}




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

string O, E;

int main() {
    // string tmp = "32";
    cin >> O >> E;

    rep(i, E.size()) {
        cout << O[i] << E[i];
    }

    if (O.size() != E.size()) cout << O[O.size() - 1];

    cout << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <algorithm>
#include <string>
#include <vector>
#include <set>
using namespace std;

int main(){
    long long A, B, N;

    cin >> A >> B >> N;


    long long m = floor(A * min(N,B-1)/ B) - A * floor(min(N,B-1) / B);

    cout << m << endl;
}

Measured memory_bytes: 3588
#include<stdio.h>

int dp[50];

int fib(int);

int main(){
  int n,i;
  for(i=0;i<50;i++)dp[i]=-1;

  scanf("%d",&n);
  printf("%d\n",fib(n));

  return 0;
}

int fib(int n){
  if(n == 0 || n == 1)return dp[n] = 1;
  if(dp[n] != -1)return dp[n];
  return dp[n] = fib(n-1)+fib(n-2);
}

Measured memory_bytes: 596
#include <bits/stdc++.h>
#define rep(i, n) for (int i=0; i<(int)(n); i++)
#define all(v) v.begin(), v.end()
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
const ll MOD = 1000000007;
const ll INF = 9999999999;
const int INFI = 2147483647;
template<class T> inline bool chmin(T& a, T b){if (a>b){a = b; return true;}return false;}
template<class T> inline bool chmax(T& a, T b){if (a<b){a = b; return true;}return false;}
template<class T> inline T powerM(T a,T b){if (b==0) return 1;
  T tmp = powerM(a,b/2); if (b%2==0) return tmp*tmp%MOD; else return tmp*tmp%MOD*a%MOD; }


int main() {
  int n,m,k; cin >>n >>m >>k;
  bool ok = false;
  for (int i=0; i<=n; i++){
    for (int j=0; j<=m; j++){
      int res = i * m;
      res += (n-i-i) * j;
      if (res == k) ok = true;
    }
  }
  cout <<(ok ? "Yes" : "No") <<endl;
}


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

using namespace std;

int main()
{
    int a, b, c, d, e, na, nb, nc;
    while (cin >> a >> b >> c >> d >> e, a) {
        cin >> na >> nb >> nc;
        int cost = 0;
        if (nc >= d) {
            cost += nc * e;
            nc = 0;
        }

        if (na + nb + nc >= d) {
            int T = d - nc, j = 0, k = 0;
            
            while (j < nb && T > 0) {
                T--; j++;
            }

            while (k < na && T > 0) {
                T--; k++;
            }
            
            int t = a * na + b * nb + c * nc;
            int t2 = (k + j + nc) * e + a * (na - k) + b * (nb - j);            
            cost += min(t, t2);
        } else {
            int t = a * na + b * nb + c * nc;
            int t2 = d * e;
            cost += min(t, t2);
        }
        cout << cost << endl;
    }
    return 0;
}

Measured memory_bytes: 1160
N,M,S=map(int,input().split())

ways=[[] for _ in range(N)]
CD=[[0]*2 for _ in range(N)]

class Way:
  def __init__(self,t,f,ti):
    self.to=t
    self.fare=f
    self.time=ti 

for i in range(M):
  U,V,A,B=map(int,input().split())
  U-=1
  V-=1
  ways[U].append(Way(V,A,B))
  ways[V].append(Way(U,A,B))

for i in range(N):
  C,D=map(int,input().split())
  CD[i][0]=C
  CD[i][1]=D
  
#dp[i][j]:駅iにおいて銀貨をj枚所持するための最短時間
dp=[[float("inf")]*(50*N+1) for _ in range(N)]
S=min(S,50*N)
dp[0][S]=0
import heapq

#data型は(時間、駅、お金)
#q=heapq.heapify([(0,0,S)])
#q=heapq.heapify([])
q=[]
heapq.heappush(q,(0,0,S))
#print(q)
def Push(time,station,money):
  #print("called")
  global q,dp
  if money<0:
    return
  money=min(money,50*N)
  if dp[station][money] <= time:
    return
  dp[station][money] = time
  heapq.heappush(q,(time,station,money))

while q:
  #print("called!")
  dat = heapq.heappop(q)
  time,station,money=dat[0],dat[1],dat[2]
  
  if dp[station][money]!=time:
    continue
  #まず、両替。
  Push(time+CD[station][1],station,money+CD[station][0])
  #次に、各道について移動
  for w in ways[station]:
    Push(time+w.time,w.to,money-w.fare)

for i in range(1,N):
  ans=float("inf")
  for j in range(50*N+1):
    ans=min(ans,dp[i][j])
  print(ans)
    

  
  

Measured memory_bytes: 101788
#include<bits/stdc++.h>
using namespace std;
//Optimisations
#pragma GCC target ("avx2")
#pragma GCC optimization ("unroll-loops")
#pragma GCC optimize("O2")
//shortcuts for functions
#define pb push_back
#define mp make_pair
#define ff first 
#define ss second
#define all(v) v.begin(),v.end()
#define prec(n) fixed<<setprecision(n)
#define n_l '\n'
// make it python 
#define gcd __gcd
#define append push_back
#define str to_string
// utility functions shortcuts
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define sswap(a,b) {a=a^b;b=a^b;a=a^b;}
#define swap(a,b) {auto temp=a; a=b; b=temp;}
#define init(dp) memset(dp,-1,sizeof(dp));
#define set0(dp) memset(dp,0,sizeof(dp));
#define bits(x) __builtin_popcount(x)
#define SORT(v) sort(all(v))
#define endl "\n"
#define forr(i,n) for(ll i=0;i<n;i++)
// declaration shortcuts
typedef long long int ll;
#define int ll
// Constants
constexpr int dx[] = {-1, 0, 1, 0, 1, 1, -1, -1};
constexpr int dy[] = {0, -1, 0, 1, 1, -1, 1, -1};
constexpr ll INF = 1999999999999999997; 
constexpr int inf= INT_MAX;
constexpr int MAXSIZE = int(1e6)+5;
constexpr auto PI  = 3.14159265358979323846L;
constexpr auto oo  = numeric_limits<int>::max() / 2 - 2;
constexpr auto eps = 1e-6;
constexpr auto mod = 1000000007;
constexpr auto MOD = 1000000007;
constexpr auto MOD9 = 1000000009;
constexpr auto maxn = 100006;
//void IOfile(){
//freopen(file_name, reade_mode, stdin);
//freopen(file_name, write_mode, stdout);
//}
void fastio(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
}
int32_t main(){
	fastio();
	int n,l;
	cin >> n >> l;
	int sum = 0;
	for(int i = 1; i <= n; i++){
		sum += (l + i - 1);
	}
	set<int>s;
	for(int i = 1; i <= n; i++){
		s.insert(sum - (l + i - 1));
	}
	int diff = INF;
	int ans;
	for(auto i:s){
		if(abs(sum - i) < diff){
			diff = abs(sum - i);
			ans = i;
		}
	}
	cout << ans;
}

Measured memory_bytes: 3588
// C - Same Integers
#include <bits/stdc++.h>
using namespace std;
using vi = vector<int>;
#define all(x) (x).begin(),(x).end()

int main(){
	int A,B,C; cin>>A>>B>>C;
	vi S{A,B,C};
	int ans = 0;
	while(!(S[0]==S[1] && S[1]==S[2])){
		sort(all(S));
		if(S[0] == S[1]){//same small 2
			if(S[2]-S[0] >= 2){
				S[0] += 2;
				ans++;
			}
			else{
				S[0] += 1;
				S[1] += 1;
				ans++;
			}
		}
		else if(S[1] == S[2]){//same big 2
			if(S[2]-S[0] >= 2){
				S[0] += 2;
				ans++;
			}
			else{
				S[1] += 1;
				S[2] += 1;
				ans++;
			}
		}
		else{//not same
			if(S[2]-S[1] >= 2){
				S[0] += 2;
				ans++;
			}
			else{
				S[0] += 1;
				S[1] += 1;
				ans++;
			}
		}
	}
	cout<< ans <<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rrep(i, n) for(int i = ((int)(n)-1); i >= 0; i--)
#define all(x) (x).begin(),(x).end()
 
using namespace std;
using ll = long long;
 
struct edge { int to, cost; };
 
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> P;
 
const int INF = ~(1<<31);
const int MOD = 1e9+7;
const double EPS = 1e-10;
const double PI = acos(-1.0);
 
const int mx4[] = {0,1,0,-1};
const int my4[] = {1,0,-1,0};
const int mx8[] = {0,1,1,1,0,-1,-1,-1};
const int my8[] = {1,1,0,-1,-1,-1,0,1};

int dp[100010];

int main(){
	int n;
	cin >> n;
	int a[n];
	rep(i,n) cin >> a[i];
	reverse(a,a+n);

	rep(i,n) dp[i] = INF;

	rep(i,n){
		*upper_bound(dp,dp+n,a[i]) = a[i];
	}

	cout << lower_bound(dp,dp+n,INF)-dp << endl;

	return 0;
}

Measured memory_bytes: 1024
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"
#include "numeric"
#include "cassert"
#include "ctime"
#include "string"

using namespace std;
using ll = long long;
using P = pair<int, int>;
#define rep(i,n) for(int i = 0; i < n; i++)

int main() {
	string s;
	cin >> s;
	int a = stoi(s.substr(0, 2));
	int b = stoi(s.substr(2, 2));
	if (1 <= a && a <= 12 && 1 <= b && b <= 12) cout << "AMBIGUOUS" << endl;
	else if (1 <= a && a <= 12 && (b == 0 || 13 <= b)) cout << "MMYY" << endl;
	else if (1 <= b && b <= 12 && (a == 0 || 13 <= a)) cout << "YYMM" << endl;
	else cout << "NA" << endl;
	return 0;
}

Measured memory_bytes: 256
def selection_sort(numbers, n):
    """selection sort method

    Args:
        numbers: a list of numbers to be sorted
        n: len(numbers)

    Returns:
        sorted numberd, number of swapped times
    """
    counter = 0
    for i in range(0, n - 1):
        min_j = i
        for j in range(i + 1, n):
            if numbers[j] < numbers[min_j]:
                min_j = j
        if min_j != i:
            numbers[min_j], numbers[i] = numbers[i], numbers[min_j]
            counter += 1
    return numbers, counter


length = int(raw_input())
numbers = [int(x) for x in raw_input().split()]

numbers, number_of_swapped_times = selection_sort(numbers, length)
print(" ".join([str(x) for x in numbers]))
print(number_of_swapped_times)

Measured memory_bytes: 6360
#include <cstdio>
#include <vector>
#include <algorithm>
#include <functional>

using namespace std;
typedef long long ll;

struct Item {
	int weight;
	int value;
	Item(int w, int v) : weight(w), value(v) {}
};

const bool operator > (const Item a, const Item b) {
	return (a.value > b.value);
}

int main() {
	int n, w; scanf("%d %d", &n, &w);
	vector<Item> items(n, Item(0, 0));
	for (int i = 0; i < n; ++i) {
		scanf("%d %d", &(items[i].weight), &(items[i].value));
	}

	long long rootW = items[0].weight;

	vector<vector<Item>> byweight(4, vector<Item>());

	for (int i = 0; i < n; ++i) {
		byweight[items[i].weight - rootW].push_back(items[i]);
	}

	for (int i = 0; i < 4; ++i) {
		sort(byweight[i].begin(), byweight[i].end(), greater<Item>());
	}


	vector<vector<ll>> prefixw(4, vector<ll>());
	for (int i = 0; i < 4; ++i) {
		prefixw[i] = vector<ll>(byweight[i].size() + 1, 0);
		for (int j = 1; j < prefixw[i].size(); ++j) {
			prefixw[i][j] = prefixw[i][j-1] + byweight[i][j-1].value;
			//printf("first %d items of weight %d have total value %d\n", j, rootW + i, prefixw[i][j]);
		}
	}

	ll maxval = 0;
	for (int rc = 0; rc <= byweight[0].size(); ++rc) {
		for (int rcp1 = 0; rcp1 <= byweight[1].size(); ++rcp1) {
			for (int rcp2 = 0; rcp2 <= byweight[2].size(); ++rcp2) {
				for (int rcp3 = 0; rcp3 <= byweight[3].size(); ++rcp3) {
					ll curw = (rootW * rc) + ((rootW + 1) * rcp1) + ((rootW + 2) * rcp2) + ((rootW + 3) * rcp3);
					//printf("selection of %d %d %d %d has total w %lld\n", rc, rcp1, rcp2, rcp3, curw);
					if (curw <= w) {
						maxval = max(maxval,
							prefixw[0][rc] + prefixw[1][rcp1] + prefixw[2][rcp2] + prefixw[3][rcp3]);
					}
				}
			}
		}
	}

	printf("%lld\n", maxval);
	return 0;
}

Measured memory_bytes: 256
import Data.List

putListLn :: Show a => [a] -> IO ()
putListLn = putStrLn . unwords . map show
getList :: Read a => IO [a]
getList = fmap (map read . words) getLine

isortStates :: Ord a => [a] -> [[a]]
isortStates l = tail $ zipWith (++) (scanl (flip insert) [] l) (tails l)

main :: IO ()
main = do
  _ <- getLine
  ns <- getList :: IO [Int]
  mapM_ putListLn $ isortStates ns

Measured memory_bytes: 4008
#include <iostream>
using namespace std;
typedef long long ll;
int main(){
  ll a,b,c,d;cin>>a>>b>>c>>d;
  while(a>0&&c>0){
    c-=b;
    a-=d;
  }
  if(c<=0){
    cout << "Yes"<<endl;
  }else{
    cout << "No"<<endl;
  }
}

Measured memory_bytes: 3636
a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = int(input())
import itertools
menu=[a,b,c,d,e]
menu_p = list(itertools.permutations(menu))

min = 10000000000
for list in menu_p:
    total = 0
    for i in range(len(list)):
        if i == len(list)-1 or list[i] % 10 == 0:
            total += list[i]
        else:
            total += list[i] + (10 - list[i]%10)
    if min > total:
        min = total
print(min)


Measured memory_bytes: 3064
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
''' 
------------------------
author : iiou16
------------------------
'''

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

    p = [1 / N] * N

    for i in range(1, N+1):
        count = 2
        point = i
        while point < K:
            p[i-1] *= 0.5
            point = point * count
        # print(point, p[i-1])
    print(sum(p))


if __name__ == '__main__':
    main()

Measured memory_bytes: 3828
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
constexpr long long MOD = (long long)1e9 + 7;

int main() {
    string S; cin >> S;
    vector<ll> dp(13,0);
    int N = S.size();
    
    //1桁目が数字ならその値で初期化
    if(S[0]!='?') dp[S[0]-'0']++;
    //そうじゃないなら0-9を初期化
    else for(int i = 0; i < 10; ++i) dp[i]++;

    //上の桁からdp
    for(int i = 1; i < N; ++i){
        vector<ll> tmp(13,0);
        if(S[i]=='?'){
            for(int k = 0; k < 10; ++k){
                for(int j = 0; j < 13; ++j){
                    (tmp[(j*10+k)%13] += dp[j]) %= MOD;
                }
            }
        }
        else{
            int m = S[i] - '0';
            for(int j = 0; j < 13; ++j){
                (tmp[(j*10+m)%13] += dp[j]) %= MOD;
            }
        }
        dp = tmp;
    }
    cout << dp[5] << endl;
    return 0;
}


Measured memory_bytes: 512
n,k=map(int,input().split())
r,s,p=map(int,input().split())
t=input()
score=0
free=[0]*n
for i in range(n):
    if i>=k:
        if (t[i]==t[i-k])&(free[i-k]==0):
            free[i]=1
        else:
            if t[i]=="r":
                score+=p
            elif t[i]=="s":
                score+=r
            elif t[i] == "p":
                score += s
    else:
        if t[i] == "r":
            score += p
        elif t[i] == "s":
            score += r
        elif t[i] == "p":
            score += s
print(score)

Measured memory_bytes: 4084
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rrep(ri,n) for(int ri = (int)(n-1); ri >= 0; ri--)
#define rep2(i,x,n) for(int i = (int)(x); i < (int)(n); i++)
#define rrep2(ri,x,n) for(int ri = (int)(n-1); ri >= (int)(x); ri--)
#define repit(itr,x) for(auto itr = x.begin(); itr != x.end(); itr++)
#define rrepit(ritr,x) for(auto ritr = x.rbegin(); ritr != x.rend(); ritr++)
#define ALL(x) x.begin(), x.end()
using ll = long long;
using namespace std;

int main(){
  int d;
  cin >> d;
  cout << "Christmas";
  int c = 25 - d;
  rep(i, c) cout << " Eve";
  cout << endl;
  return 0;
}

Measured memory_bytes: 3624
#include<iostream>
#include<string>
#include<vector>
#include<math.h>
#include<algorithm>
#include<cstdio>
#include<stdio.h>
#include<stack>
#include<sstream>
#include<iomanip>
#include<map>
#include<unordered_map>
#include<list>
#include<numeric>
typedef long long ll;

#define pi 3.14159265358979323846
#define VI vector<int>
#define VLL vector<long long>
#define MAX max_element
#define MIN min_element
#define all(v) v.begin(), v.end()
const ll MOD = 1e9 + 7;
using namespace std;
template<typename T>
T gcd(T a, T b) {
	return b ? gcd(b, a % b) : a;
}
template<typename T>
T lcm(T a, T b) {
	return a * b / gcd(a, b);
}

template<typename T>
T binarysearch(vector<T> A, T key) {
	ll left = 0;ll right = 4;ll mid;
	while (left < right) {
		mid = (left + right) / 2;
		if (key == A[mid]) return 1;
		if (key > A[mid]) left = mid + 1;
		else if (key < A[mid]) right = mid;
	}
	return 0;
}

template<typename T>
T finder(vector<T> vec, T number) {
	auto itr = find(vec.begin(), vec.end(), number);
	size_t index = distance(vec.begin(), itr);
	if (index != vec.size()) { // 発見できたとき
		return 1;
	}
	else { // 発見できなかったとき
		return 0;
	}
}
ll frac(ll n)//階乗
{
	if (n == 0) {
		return 1;
	}
	return (n * frac(n - 1)) % MOD;
}

template<typename T>
T keta(T a) {
	ll kazu = 1;
	while (1) {
		if (a / 10 != 0) { a /= 10;kazu++; }
		else break;
	}
	return kazu;
}//桁数


template<typename T>
T nCr(ll n, T r) {
	ll ans = 1;
	for (int i = n; i > n - r; --i) {
		ans = ans * i;
	}
	for (int i = 1; i < r + 1; ++i) {
		ans = ans / i;
	}
	return ans;
}
/*char r[4];
int yaju[4];
char op[3];
int sum = 0;
scanf("%s", r);
for (int i = 0;i < 4;i++) {
	yaju[i] = r[i] - '0';
}
*/
int main() {
	ll A, B;cin >> A >> B;
		for (ll i = 1;i <= 100000;i++) {
			if (floor(i * 0.08) == A && floor(i * 0.1) == B) { cout << i << endl; break; }
			if (i == 100000)cout << -1 << endl;
		}
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <set>
#include <cmath>
#include <vector>
#include <numeric>
#include <unordered_map>
#include <unordered_set>
#include <queue>

typedef long long ll;
const ll LL_MAX (1LL<<60);

#define rep(i,s,e) for(ll i=(s); i<(e); i++) 

using namespace std;

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

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

    double pa, pb;
    rep(i,1,1010)
    {
        pa = floor(i*0.08);
        if (a != pa) continue;

        rep(j,1,1010)
        {
            pb = floor(j*0.1); 
            if (b != pb) continue;
        
            if (a == pa && b == pb && i==j)
            {
                cout << i << endl;
                return 0;
            }
        }
    }

    cout << -1 << endl;

    return 0;
}


Measured memory_bytes: 256
/*
title:

url:
*/

#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <functional>
#include <queue>
#include <limits>
#include <string>
#include <utility>
#include <cstring>
#include <map>
#include <cmath>
#include <iterator>

using namespace std;

#define REP(i, n) for (int i = 0; i < (n); i++)
#define INF 1000000007

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

int main()
{
    int a, b;
    cin >> a >> b;
    int ans = 0;
    for (int i = a; i <= b; i++)
    {
        string tmp = to_string(i);
        string rvs = "";
        for (int i = tmp.size() - 1; i >= 0; i--)
        {
            rvs = rvs + tmp[i];
        }
        if (rvs == tmp)
            ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
import sys
n = int(input())
c = list(map(int, input().split()))
c = [x-1 for x in c]
# print(c)
adj = [[] for i in range(n)]
for i in range(n-1):
    a, b = tuple(map(int, input().split()))
    a -= 1
    b -= 1
    adj[a].append(b)
    adj[b].append(a)


size = [1 for i in range(n)]
stack = [[] for color in range(n)]
in_time = [-1 for i in range(n)]
out_time = [-1 for i in range(n)]
timer = 0
total = n*(n+1)//2
ans = [total for color in range(n)]
# print(ans)


def dfs(parent, root):
    global timer
    in_time[root] = timer
    timer += 1

    for child in adj[root]:
        if parent == child:
            continue
        dfs(root, child)
        size[root] += size[child]

        cnt = size[child]
        while stack[c[root]]:
            x = stack[c[root]][-1]
            if in_time[x] > in_time[root] and out_time[x] != -1:
                cnt -= size[x]
                stack[c[root]].pop()
            else:
                break
        ans[c[root]] -= cnt*(cnt+1)//2

    out_time[root] = timer
    timer += 1

    stack[c[root]].append(root)


sys.setrecursionlimit(10**6)

dfs(0, 0)
# print(size)
for color in range(n):
    cnt = n
    while len(stack[color]) > 0:
        x = stack[color][-1]
        cnt -= size[x]
        stack[color].pop()
    # print("node:", -1, "color:", color, "cnt:", cnt)
    ans[color] -= cnt*(cnt+1)//2
    print(ans[color])


Measured memory_bytes: 399044
#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>;
const int INF = 1 << 29;

int main() {
	string s;
	cin >> s;
	int x = INF;
	for (int i = 0; i < s.size()-2; i++) {
		string sub = s.substr(i, 3);
		int now = stoi(sub);
		x = min(x, abs(753-now));
	}
	cout << x << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int64_t i=0;i < (int64_t)(n);i++)
#define invrep(i,n) for(int64_t i=n-1;i >= 0;i--)
using namespace std;

//////全探索したいときに開けよ////////
vector<vector<int>> fspattern;
vector<int> fspattern_draft;
int fspcnt = 0;

void setfspattern_core(int floor,int number,int degree){
  if(floor==degree){
    fspattern.at(fspcnt) = fspattern_draft;
    fspcnt++;
  }else{
    rep(i,number){
      fspattern_draft.at(floor) = i;
      setfspattern_core(floor+1,number,degree);
    }
  }
}

void setfspattern(int number,int degree){
  fspcnt = 0;
  int64_t array_num = 1;
  rep(i,degree){
    array_num *= number;
  }
  fspattern = vector<vector<int>>(array_num,vector<int>(degree));
  fspattern_draft = vector<int>(degree);
  setfspattern_core(0,number,degree);
}

//////nCrのmodを求めたいときに開けよ/////////
//int64_t univMod = 1000000007;
//int64_t factnum = 100000
//vector<int64_t> modfact(factnum);
//vector<int64_t> modinvfact(factnum);

/*void setmodfact(){
  for(int i=0;i<factnum;i++){
    if(i == 0){
      modfact.at(i) = 1;
    }else{
      modfact.at(i) = (modfact.at(i-1)*i)%univMod;
    }
  }
}

int64_t calcmodpower(int64_t a,int64_t n){
  int64_t res = 1;
  while(n != 0){
    if(n & 1){
      res = (res * a) % univMod;
    }
    a = (a*a) % univMod;
    n = n >> 1;
  }
  return res;
}

int64_t calcinverse(int64_t n){
	return calcmodpower(n,univMod-2);
}

void setmodinvfact(){
  for(int i=0;i<factnum;i++){
    if(i==0){
      modinvfact.at(i) = 1;
    }else{
      modinvfact.at(i) = calcmodpower(modfact.at(i),univMod-2);
    }
  }
}*/


/*
int64_t calcGCD(int64_t a,int64_t b){
	int64_t p = a;
	int64_t q = b;
	int64_t c = a%b;
	while(c != 0){
		p = q;
		q = c;
		c = p%q;
	}
	return q;
}
*/
struct position{
  int x;
  int y;
};

int main(){
  int n;
  cin >> n;
  set<char> S;
  rep(i,n){
    char hoge;
    cin >> hoge;
    S.insert(hoge);
  }
  if(S.size() == 4){
    cout << "Four" << endl;
  }else{
    cout << "Three" << endl;
  }
      
      
  
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n) for(long long int i=1;i<=n;i++)
#define lli long long int
#define ll long long 
#define dd double
#define endl "\n"
#define mod 1000000007

const double pi=3.14159265358;

using namespace std;

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	
	lli a,b,c,k,sum=0;
	cin>>a>>b>>c>>k;
	if(k>0 && a>0)
	{
		if(k<=a)
		{
			sum+=k;
			k=0;
		}
		else
		{
			sum+=a;
			k=k-a;
		}
	}
	if(k>0 && b>0)
	{
		if(k<=b)
		{
			sum+=0;
			k=0;
		}
		else
		{
			sum+=0;
			k=k-b;
		}
	}
	if(k>0 && c>0)
	{
		if(k<=c)
		{
			sum+=-1*k;
			k=0;
		}
		else
		{
			sum+=-1*k;
			k=k-c;
		}
	}
	cout<<sum<<endl;	
}

Measured memory_bytes: 3640
#include <iostream>
#include <cstdio>
#include <complex>
#include <cmath>
#include <vector>
#define rep(i,n) for(int i=0;i<n;++i)
#define fs first
#define sc second
using namespace std;
typedef double D;
typedef complex<D> P;
typedef pair<P,P> L;
typedef vector<P> Pol;
double x[3],y[3],eps=1e-10;
P p[3],m[3],ran=P(1048576,1048576);
Pol tri;
bool eq(D a, D b) { return abs(a-b)<eps;}
inline D cro(P a,P b){
	return imag(conj(a)*b);
}
inline int ccw (P a, P b, P c){
	if(cro(b-a,c-a)>eps) return 1;
	if(cro(b-a,c-a)<-eps) return -1;
	if(eq(abs(a-c)+abs(c-b),abs(a-b))) return 0;
	if(eq(abs(a-b)+abs(b-c),abs(a-c))) return -2;
	if(eq(abs(c-a)+abs(a-b),abs(c-b))) return 2;
}
enum ENCONT{INP=1,ONP=0,OUTP=-1};
int contain(Pol pol, P p){
	bool in=false;
	rep(i,pol.size()){
		P a=pol[i]-p,b=pol[(i+1)%pol.size()]-p;
		if(ccw(a,b,P(0,0))==0) return ONP;
		if(imag(a)>imag(b)) swap(a,b);
		if(imag(a)<eps && eps<imag(b) && ccw(P(0,0),a,b)==1) in=!in;
	}
	return in ? INP : OUTP;
}
inline D verlength(L l,P p){
	return abs(cro(l.fs-l.sc,p-l.sc)/abs(l.fs-l.sc));
}
bool containC(Pol tri,P p,L l,D r){
	return (contain(tri,p)==1)&&verlength(l,p)>r;
}
P decidec2(P c1,D r1){
	double ub=100000,lb=0;
	P c2;
	D r2;
	while(ub-lb>eps){
		double mid=(ub+lb)/2;
		c2=p[1]+mid*m[1];
		r2=verlength(L(p[1],p[2]),c2);
		if(!containC(tri,c2,L(p[2],p[0]),r2)){
			ub=mid;
			continue;
		}
		if(abs(c1-c2)>r1+r2) lb=mid;
		else ub=mid;
	}
//	cout<<ub<<"   "<<abs(c1-c2)<<" "<<r1+r2<<endl;
//	if(abs(abs(c1-c2)-(r1+r2))>1e-5) return ran;
	return c2;
}
P decidec3(P c2,D r2){
	double ub=100000,lb=0;
	P c3;
	while(ub-lb>eps){
		double mid=(ub+lb)/2;
		c3=p[2]+mid*m[2];
		D r3=verlength(L(p[2],p[0]),c3);
		if(!containC(tri,c3,L(p[0],p[1]),r3)){
			ub=mid;
			continue;
		}
		if(abs(c2-c3)>r2+r3) lb=mid;
		else ub=mid;
	}
	return c3;
}
int main(){
	while(true){
		rep(i,3) cin>>x[i]>>y[i];
		rep(i,3) p[i]=P(x[i],y[i]);
		if(p[0]==p[1]) break;
		tri.clear();
		rep(i,3) tri.push_back(p[i]);
		rep(i,3){
			int cu=i,ne1=(i+1)%3,ne2=(i+2)%3;
			P a=p[ne1]-p[cu],b=p[ne2]-p[cu];
			a/=abs(a);
			b/=abs(b);
			m[i]=a+b;
			m[i]/=abs(m[i]);
		}
		double ub=100000,lb=0;
		D r1,r2,r3;
		P c1,c2,c3;
		while(ub-lb>eps){
			double mid=(ub+lb)/2;
			c1=p[0]+mid*m[0];
			r1=verlength(L(p[0],p[1]),c1);
			if(!containC(tri,c1,L(p[1],p[2]),r1)){
				ub=mid;
				continue;
			}
/*			if(r1<0.01){
				lb=mid;
				continue;
			}*/
			c2=decidec2(c1,r1);
//			cout<<"c1 "<<c1<<endl;
//			cout<<"r1 "<<r1<<endl;
//			cout<<"c2 "<<c2<<endl;
			r2=verlength(L(p[1],p[2]),c2);
/*			if(r2<0.01){
				ub=mid;
				continue;
			}*/
			c3=decidec3(c2,r2);
			r3=verlength(L(p[2],p[0]),c3);
/*			if(r3<0.01){
				lb=mid;
				continue;
			}*/
			if(abs(c3-c1)>r3+r1) lb=mid;
			else ub=mid;
//			cout<<"c3 "<<c3<<endl;
		}
//		cout<<"dist(c1,c2)= "<<abs(c1-c2)<<endl;
//		cout<<"dist(c2,c3)= "<<abs(c2-c3)<<endl;
//		cout<<"dist(c3,c1)= "<<abs(c3-c1)<<endl;
		printf("%.10f %.10f %.10f\n",r1,r2,r3);
	}
}

Measured memory_bytes: 1256
#include <cstdio>
#include <string>

using namespace std;

int main() {
    char buf[1<<10];
    scanf("%s", buf);
    string T(buf);

    scanf("%s", buf);
    string P(buf);

    for (size_t pos=0; (pos=T.find(P, pos))!=string::npos; ++pos)
        printf("%zd\n", pos);

    return 0;
}

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

#define _GLIBCXX_DEBUG
#define _LIBCPP_DEBUG 0

int main() {
  ll k, x;
  cin >> k >> x;

  if (500 * k >= x) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}


Measured memory_bytes: 3580
// ABC139C.cpp : このファイルには 'main' 関数が含まれています。プログラム実行の開始と終了がそこで行われます。
//

//#include "pch.h"
#include <iostream>
#include<vector>
using namespace std;
int main()
{
	int N;
	cin >> N;
	vector<int>H(N);
	vector<int>dp(N);
	for (int i = 0; i < N; i++)
	{
		cin >> H.at(i);
	}
	for (int j = N - 1; j >= 1; j--)
	{
		if (H.at(j - 1) >= H.at(j))
		{
			dp.at(j - 1) = dp.at(j) + 1;
		}
		else
		{
			dp.at(j - 1) = 0;
		}
	}
	int max = 0;
	for (int k = 0; k < N; k++)
	{
		if (max < dp.at(k)) {
			max = dp.at(k);
		}
	}
	cout << max << endl;
}


Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <iomanip>
#include <utility>
#include <tuple>
#include <functional>
#include <bitset>
#include <cassert>
#include <complex>
#include <stdio.h>
#include <time.h>
#include <numeric>
#include <random>
#include <unordered_map>
#include <unordered_set>
#define all(a) a.begin(),a.end()
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define pb push_back
#define debug(x) cerr << #x << ':' << (x) << '\n'
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<ll, ll> P;
typedef complex<ld> com;
constexpr int inf = 1000000010;
constexpr ll INF = 1000000000000000010;
constexpr ld eps = 1e-12;
constexpr ld pi = 3.141592653589793238;
template<class T, class U> inline bool chmax(T &a, const U &b) { if (a < b) { a = b; return true; } return false; }
template<class T, class U> inline bool chmin(T &a, const U &b) { if (a > b) { a = b; return true; } return false; }


int main() {
	/*cin.tie(0);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(20);*/

	vector<char> c(62);
	rep(i, 26) c[i] = 'a' + i;
	for (int i = 26; i < 52; i++) c[i] = 'A' + (i - 26);
	for (int i = 52; i < 62; i++) c[i] = '0' + (i - 52);
	vector<int> cnt(62);
	rep(i, 62) {
		string s;
		rep(_, 128) s += c[i];
		cout << "? " << s << endl;
		int n;
		cin >> n;
		cnt[i] = 128 - n;
	}
	string ans = "";
	rep(i, 62) {
		int pre = 0;
		rep(j, cnt[i]) {
			int sz = ans.size() + 1;
			int l = pre, r = sz;
			while (r - l > 1) {
				int mid = (l + r) / 2;
				string check = ans.substr(0, l) + c[i] + ans.substr(mid - 1, sz - mid + 1);
				cout << "? " << check << endl;
				int n;
				cin >> n;
				for (int k = i + 1; k < 62; k++) n -= cnt[k];
				n -= cnt[i] - j - 1;
				if (n >= mid - l) l = mid;
				else r = mid;
			}
			string tmp = ans.substr(0, l) + c[i] + ans.substr(l);
			ans = tmp;
			pre = l + 1;
			debug(ans);
		}
	}
	cout << "! " << ans << endl;
}

Measured memory_bytes: 3804
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
int n,k,mod,C[310][310],dp[310][310],sum[310];
int main()
{
	scanf("%d %d %d",&n,&k,&mod);
	for(int i=0;i<=n;++i)
	{
		C[i][0]=1;
		for(int j=1;j<=i;++j)(C[i][j]=C[i-1][j-1]+C[i-1][j])>=mod?C[i][j]-=mod:0;
	}
	for(int i=k;~i;--i)
	{
		dp[i][1]=1;
		for(int j=1;j<=n+1;++j)
			for(int l=1;l<j;++l)
				dp[i][j]=(dp[i][j]+1ll*dp[i][j-l]*sum[l]%mod*C[j-2][l-1])%mod;
		for(int j=1;j<=n+1;++j)(sum[j]+=dp[i][j])>=mod?sum[j]-=mod:0;
	//	for(int j=1;j<=n+1;++j)printf("%d ",dp[i][j]);printf("\n");
	}
	printf("%d",dp[0][n+1]);
	return 0;
}


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

long double a,b,x,p;
long double angle;

int main()
{
 cin >> a >> b >> x;
 if(0.5*a*a*b==x) angle=atan((double)b/a);
 else if(0.5*a*a*b>x)
 {
  a=x*2/b/a;
  angle=atan((double)b/a);
 }
 else
 {
  p=2*x/a/a-b;
  angle=atan((double)(b-p)/a);
 }
 cout << fixed << setprecision(10) << angle/M_PI*180 << endl;
 return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}

//INSERT ABOVE HERE
signed main(){
  Int n;
  cin>>n;
  vector<Int> a(n);
  for(Int i=0;i<n;i++) cin>>a[i];

  Int p1=0,p2=0;
  Int m1=0,m2=0;
  for(Int i=0;i<n;i++){
    if(a[i]==+1) p1++;
    if(a[i]==+2) p2++;
    if(a[i]==-1) m1++;
    if(a[i]==-2) m2++;    
  }
  
  if(m1&&(m2&1)) m1=1;
  else if(m2&1) m1=0,m2--;
  else m1=0;

  if(p2+m2==0){
    cout<<0<<endl;
    return 0;
  }
  vector<Int> ans;
  for(Int i=0;i<n;i++){
    if(a[i]==+1) continue;
    if(a[i]==+2) ans.emplace_back(i);
    if(a[i]==-1) if(m1) ans.emplace_back(i),m1--;
    if(a[i]==-2) if(m2) ans.emplace_back(i),m2--;
  }
  cout<<ans.size()<<endl;
  for(Int x:ans) cout<<x+1<<endl;
  return 0;
}



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

#if MYDEBUG
#include "lib/cp_debug.hpp"
#else
#define DBG(...) ;
#endif
#if __cplusplus <= 201402L
template <typename T>
T gcd(T a, T b) { return ((a % b == 0) ? b : gcd(b, a % b)); }
template <typename T>
T lcm(T a, T b) { return a / gcd(a, b) * b; }
#endif
using LL = long long;
constexpr LL LINF = 334ll << 53;
constexpr int INF = 15 << 26;
constexpr LL MOD = 1E9 + 7;

namespace Problem {
using namespace std;

class Solver {
 public:
  int n, m;
  vector<vector<int>> coGraph;
  vector<pair<int, int>> size;
  vector<int> visit;
  Solver(LL n) : n(n), coGraph(n, vector<int>(n, 1)), visit(n, -1){};

  void solve() {
    cin >> m;
    for (int i = 0; i < n; ++i) {
      coGraph[i][i] = 0;
    }
    for (int i = 0; i < m; ++i) {
      int a, b;
      cin >> a >> b;
      --a;
      --b;
      coGraph[a][b] = coGraph[b][a] = 0;
    }
    for (int i = 0; i < n; ++i) {
      vector<set<int>> st(2);
      if (visit[i] >= 0) continue;
      dfs(i, 0, st);
      size.emplace_back(st[0].size(), st[1].size());
    }
    vector<vector<int>> dp(size.size() + 1, vector<int>(n + 1));
    dp[0][0] = 1;
    for (int i = 1; i <= size.size(); ++i) {
      for (int j = 0; j <= n; ++j) {
        if (j - size[i - 1].first >= 0) {
          dp[i][j] |= dp[i - 1][j - size[i - 1].first];
        }
        if (j - size[i - 1].second >= 0) {
          dp[i][j] |= dp[i - 1][j - size[i - 1].second];
        }
      }
    }
    int ans = INF;
    for (int i = 0; i <= n; ++i) {
      if (dp[size.size()][i] and i * (i - 1) / 2 + (n - i) * (n - i - 1) / 2 < ans) {
        ans = i * (i - 1) / 2 + (n - i) * (n - i - 1) / 2;
      }
    }
    cout << ans << endl;
  }
  void no() {
    cout << -1 << endl;
    exit(0);
  }
  void dfs(int x, int b, vector<set<int>> &st) {
    if (visit[x] != -1) {
      if (visit[x] != b) {
        no();
      } else {
        return;
      }
    }
    visit[x] = b;
    st[b].insert(x);
    for (int i = 0; i < n; ++i) {
      if (coGraph[x][i]) {
        dfs(i, !b, st);
      }
    }
  }
};
}  // namespace Problem

int main() {
  std::cin.tie(0);
  std::ios_base::sync_with_stdio(false);
  // std::cout << std::fixed << std::setprecision(12);
  long long n = 0;
  std::cin >> n;

  Problem::Solver sol(n);
  sol.solve();
  return 0;
}


Measured memory_bytes: 4224
import math
def plot(x,y):
    print(f'{x:.8f} {y:.8f}')
def Koch(n, x1,y1,x2,y2):
    if n == 0:
        plot(x1,y1)
        return
    sx = (2*x1+x2)/3
    sy = (2*y1+y2)/3
    tx = (x1+2*x2)/3
    ty = (y1+2*y2)/3
    ux = (tx-sx)*(1/2)-(ty-sy)*(math.sqrt(3)/2)+sx
    uy = (tx-sx)*(math.sqrt(3)/2)+(ty-sy)*(1/2)+sy
    Koch(n-1, x1,y1, sx,sy)
    Koch(n-1, sx,sy, ux,uy)
    Koch(n-1, ux,uy, tx,ty)
    Koch(n-1, tx,ty, x2,y2)
    
n = int(input())
Koch(n, 0,0, 100,0)
plot(100,0)





Measured memory_bytes: 5752
#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 rep3(i, x, n) for(int i = x; i >= n; i--)
#define elif else if
#define sp(x) fixed << setprecision(x)
#define pb push_back
#define eb emplace_back
#define all(x) x.begin(), x.end()
#define sz(x) (int)x.size()
using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using pil = pair<int, ll>;
using pli = pair<ll, int>;
using pll = pair<ll, ll>;
const ll MOD = 1e9+7;
//const ll MOD = 998244353;
const int inf = (1<<30)-1;
const ll INF = (1LL<<60)-1;
const ld EPS = 1e-10;
template<typename T> bool chmax(T &x, const T &y) {return (x < y)? (x = y, true) : false;};
template<typename T> bool chmin(T &x, const T &y) {return (x > y)? (x = y, true) : false;};

int main(){
    int MAX = 1<<19;
    int N;
    cin >> N;
    vector<int> r[MAX], u[MAX], d[MAX], l[MAX];
    vector<int> r1[MAX], r2[MAX], u1[MAX], u2[MAX], d1[MAX], d2[MAX], l1[MAX], l2[MAX];
    rep(i, N){
        int x, y; char c;
        cin >> x >> y >> c;
        if(c == 'R') r[y].pb(x), r1[x+y].pb(x-y), r2[x-y+(1<<18)].pb(x+y);
        if(c == 'U') u[x].pb(y), u1[x+y].pb(x-y), u2[x-y+(1<<18)].pb(x+y);
        if(c == 'D') d[x].pb(y), d1[x+y].pb(x-y), d2[x-y+(1<<18)].pb(x+y);
        if(c == 'L') l[y].pb(x), l1[x+y].pb(x-y), l2[x-y+(1<<18)].pb(x+y);
    }
    int ans = inf;
    rep(i, MAX) sort(all(r[i])), sort(all(u[i])), sort(all(d[i])), sort(all(l[i]));
    vector<int>::iterator it;;
    rep(i, MAX){
        for(auto &e: r[i]){
            it = lower_bound(all(l[i]), e);
            if(it == l[i].end()) continue;
            else chmin(ans, *it-e);
        }
        for(auto &e: u[i]){
            it = lower_bound(all(d[i]), e);
            if(it == d[i].end()) continue;
            else chmin(ans, *it-e);
        }
    }
    rep(i, MAX) sort(all(r1[i])), sort(all(u1[i])), sort(all(d1[i])), sort(all(l1[i]));
    rep(i, MAX){
        for(auto &e: r1[i]){
            it = lower_bound(all(u1[i]), e);
            if(it == u1[i].end()) continue;
            else chmin(ans, *it-e);
        }
        for(auto &e: d1[i]){
            it = lower_bound(all(l1[i]), e);
            if(it == l1[i].end()) continue;
            else chmin(ans, *it-e);
        }
    }
    rep(i, MAX) sort(all(r2[i])), sort(all(u2[i])), sort(all(d2[i])), sort(all(l2[i]));
    rep(i, MAX){
        for(auto &e: r2[i]){
            it = lower_bound(all(d2[i]), e);
            if(it == d2[i].end()) continue;
            else chmin(ans, *it-e);
        }
        for(auto &e: u2[i]){
            it = lower_bound(all(l2[i]), e);
            if(it == l2[i].end()) continue;
            else chmin(ans, *it-e);
        }
    }
    if(ans == inf) cout << "SAFE" << endl;
    else cout << ans*5 << endl;
}

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

int main(void){
    int a,b,n;

    while(cin>>a){
        cin>>b>>n;
        int ans=0;
        for(int i=0;i<n;i++){

            a=10*(a%b);
            ans+=a/b;

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

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

int main() {
	int h, w;

	while (1) {
		cin >> h >> w;
		if (h == 0 && w == 0) break;

		for (int i = 0; i < h; i++) {
			for (int j = 0; j < w; j++) {
				if ((i + j) % 2 == 0) cout << "#";
				else cout << ".";
			}
			cout << endl;
		}
		cout << endl;
	}

	return 0;
}




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

const int MAXN = 505;

int n, m;
char str[MAXN][MAXN], A[MAXN][MAXN], B[MAXN][MAXN];
int T[MAXN];

int vis[MAXN];

int main()
{
	scanf("%d%d", &n, &m);
	for (int i = 1; i <= n; i++) {
		scanf("%s", str[i]+1);
		for (int j = 1; j <= m; j++)
			A[i][j] = B[i][j] = '.';
	}
	memset(T, 0, sizeof T);
	for (int i = 2; i <= n; i++) A[i][1] = '#';
	vis[1] = 1;
	int last = 1;
	for (int j = 2; j <= m; j++) {
		int flag = 1;
		for (int i = 2; i < n; i++)
			if (str[i][j] == '#' && T[i]) {
				flag = 0;
				break;
			}
		if (!flag && !vis[j-1]) {
			memset(T, 0, sizeof T);
			vis[j] = 1;
			for (int i = 2; i <= n; i++) {
				A[i][j] = '#';
				T[i] = (str[i][j] == '#');
			}
			last = j;
		} else {
			for (int i = 2; i <= n; i++)
				if (str[i][j] == '#') {
					T[i] = 1;
					for (int k = last+1; k <= j; k++)
						A[i][k] = '#';
				}
		}
	}
	for (int j = 1; j < m; j++) A[n][j] = '#';
	for (int i = 1; i <= n; i++)
		for (int j = 1; j <= m; j++)
			if (str[i][j] == '#' || A[i][j] == '.')
				B[i][j] = '#';
	for (int i = 1; i <= n; i++) {
		for (int j = 1; j <= m; j++)
			putchar(A[i][j]);
		puts("");
	}
	for (int i = 1; i <= n; i++) {
		for (int j = 1; j <= m; j++)
			putchar(B[i][j]);
		puts("");
	}
	return 0;
}


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

using namespace std;
typedef long long ll;

int main(){
    int a,b,c,x,y;
    cin>>a>>b>>c>>x>>y;
    int numa,numb,cost = 0;
    if(a + b <= 2*c){
        cost = a*x + b*y;
    }
    else{
        if(x<y){
            swap(x,y);
            swap(a,b);
        }
        cost = min(2*x*c,2*y*c + (x-y)*a);
    }
    cout<<cost<<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;

int main(void){
    int n, k;
    cin >> n >> k;
    vector<int> a(n);
    rep(i, n) cin >> a[i];
    int l = 0, h = 1e9;
    while(h - l > 1){
        int mid = (l + h) / 2, cnt = 0;
        rep(i, n) cnt += (a[i] - 1) / mid;
        if(cnt <= k) h = mid;
        else l = mid;
    }
    cout << h << endl;
    return 0;
}

Measured memory_bytes: 3904
#include "bits/stdc++.h"
using namespace std;

int main(){
  
  string s,t;
  cin >> s >> t;
  
  string ans = "Yes";
  
  sort(s.begin(),s.end());
  sort(t.begin(),t.end());
  reverse(t.begin(),t.end());
  
  if(t <= s)ans = "No";
  
  cout << ans << endl;
  
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
 int main(){
  int a,b;
   cin>>a>>b;
   if(a*500>=b){
   cout<<"Yes"<<endl;
   }
   else{
   cout<<"No"<<endl;
   }
  
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
#ABC140
import sys
#sys.setrecursionlimit(100000)

#n=int(input())
tmp = input().split()
n,k = list(map(lambda a: int(a), tmp))
s=input()


count=0
for i in range(n-1):
	if(s[i]==s[i+1]):
		count+=1

count+=k*2

if(count>=n):
	count=n-1

print(count)

Measured memory_bytes: 3316