akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
using namespace std;

int bubbleSort(int A[],int N){
  int sw=0,temp;
  bool flag=1;
  for(int i=0;flag;i++){
    flag=0;
    for(int j=N-1;j>=i+1;j--){
      if(A[j]<A[j-1]){
	temp=A[j];
	A[j]=A[j-1];
	A[j-1]=temp;
	flag=1;
	sw++;
      }
    }
  }
  return sw;
}

int main(){
  int A[100],N,sw;
  cin>>N;
  for(int i=0;i<N;i++) cin>>A[i];
  sw=bubbleSort(A,N);
  for(int i=0;i<N;i++){
    if(i)cout<<" ";
    cout << A[i];
  }
  cout << endl;
  cout << sw << endl;
  return 0;
}



Measured memory_bytes: 3092
main = do
  str <- getLine
  let n = read str ::Int
  str <- getLine
  let list1 = take n $ map read (words str) ::[Int]
  str <- getLine
  let list2 = take n $ map read (words str) ::[Int]
  let list = [list1] ++ [list2]
  print $ maximum $ map sum $ cal list n


cal :: [[Int]] -> Int -> [[Int]]
cal list n
  | n < 1     = []
  | otherwise = [take n (list !! 0) ++ drop (n-1) (list !! 1)] ++ (cal list (n-1))


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

#define fi first
#define se second
#define show(x) cerr << #x << "=" << "\n"
typedef long long ll;
typedef unsigned long long ull;

using namespace std;

int n, m;
bool red[100001];
int cont[100001];

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.precision(10);
  cout << fixed;
#ifdef LOCAL_DEFINE
  FILE *stream1;
  //FILE *stream2;
  stream1 = freopen("in.txt", "r", stdin);
  //stream2 = freopen("out.txt", "w", stdout);
  if (stream1 == NULL) return 0;
  //if (stream2 == NULL) return 0;:w
#endif
  cin >> n >> m;
  red[0] = 1;
  for (int i = 0; i < n; i++) cont[i] = 1;
  for (int i = 0; i < m; i++) {
    int x, y;
    cin >> x >> y; x--; y--;
    cont[x]--;
    if (cont[x] == 0) {
      if (red[x]) red[x] = 0, red[y] = 1;
      cont[y]++;
    } else {
      if (red[x]) red[y] = 1;
      cont[y]++;
    }
  }
  int ans = 0;
  for (int i = 0; i < n; i++) {
    if (red[i]) ans++;
  }
  cout << ans << endl;
#ifdef LOCAL_DEFINE
  cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << "s.\n";
  fclose(stream1);
  //fclose(stream2);
#endif
  return 0;
}

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

int main()
{


     ios_base::sync_with_stdio(false);
     cin.tie(NULL);
   
    int t=1;
    while(t--)
    {
      
     int  a,b;
     cin>>a>>b;
     vector<int>nish;
     long long int ans=0;
     for(int i=0;i<b;i++)
     {
      int first;
      cin>>first;
      nish.push_back(first);
      ans+=first;
     }
     //accumulate(nish.begin(),nish.end(),0);
     //cout<<nish[b-1]<<endl;
     if(ans>a)
      cout<<"-1"<<endl;
     else
      cout<<a-ans<<endl;

    }

return 0;

}

Measured memory_bytes: 3688
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		// 文字列の入力
		long n = sc.nextLong();

		long f = 0;
		for ( long i=1; i<=n; i++ ) {
			if ( i%3==0 || i%5==0 ) {
				continue;
			} else {
				f = f + i;
			}
		}
		System.out.println(f);
	}
}


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

int main(){
    int h,w, n,x=0,c=0,imax=0,imin=0;

    cin >> h >> w >> n;

    imin = min(h,w);
    imax = max(h, w);

    for (int i = 1; i <= imin;i++) {
        x++;
        if (imax*i>=n) {
            break;
        }
    }

    cout << x;
}


Measured memory_bytes: 256
#include<iostream>
#include<math.h>
#include<stdio.h>
#include<algorithm>
#include<queue>
#include<map>
#include<stack>
#include<set>
#include<vector>
#include <time.h>
#include<string.h>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef pair <ll, int> pli;
typedef pair <db, db> pdd;

const int maxn = 1e5+5;
const int Mod=1000000007;
const int INF = 0x3f3f3f3f;
const ll LL_INF = 0x3f3f3f3f3f3f3f3f;
const double e=2.718281828459045235360287471352662;
const db PI = acos(-1);
const db ERR = 1e-10;

#define Se second
#define Fi first
#define pb push_back
int sum[3];
char str[4];
int main()
{
    ios::sync_with_stdio(false);
   cin>>str;
   int ans=0;
   for(int i=0;i<3;i++)
   {
        sum[str[i]-'a']++;
   }
   for(int i=0;i<3;i++)
     ans+=(sum[i]!=0);
   if(ans==3)
    cout<<"Yes"<<endl;
   else
    cout<<"No"<<endl;
    return 0 ;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <iomanip>
#include <ios>

using namespace std;

//skip
void C111()
{
  int n;
  cin >> n;
  vector<int> v(n);
  for (int i = 0; i < n; ++i) cin >> v[i];
}


void pyramid()
{
  int n;
  cin >> n;
  vector<int> x(n), y(n), h(n);
  int x1, y1, h1;
  for (int i = 0; i < n; ++i)
  {
    cin >> x[i] >> y[i] >> h[i];
    if (h[i] >= 1)
    {
      x1 = x[i];
      y1 = y[i];
      h1 = h[i];
    }
  }

  for (int i = 0; i <= 100; ++i)
  {
    for (int j = 0; j <= 100; ++j)
    {
      int h_max = max(0, h1 + abs(i - x1) + abs(j - y1));
      int exist_ans = 1;
      for (int k = 0; k < n; ++k)
      {
        if (h[k] != max(0, h_max - abs(i - x[k]) - abs(j - y[k])))
        {
          exist_ans = 0;
          break;
        }
      }
      if (exist_ans)
      {
        cout << i << " " << j << " " << h_max << "\n";
        return;
      }
    }
  }
}


void id_113()
{
  int n, m;
  cin >> n >> m;
  
  vector<vector<pair<int, int>>> py(n);
  for (int i = 0; i < m; ++i)
  {
    int p, y;
    cin >> p >> y;

    py[p - 1].push_back(make_pair(y, i));
  }

  for (int i = 0; i < n; ++i) sort(py[i].begin(), py[i].end());

  map<int, pair<int, int>> ans;
  for (int i = 0; i < n; ++i)
  {
    for (int j = 0; j < py[i].size(); ++j)
    {
      ans[py[i][j].second] = make_pair(i + 1, j + 1);
    }
  }
  
  for (int i = 0; i < m; ++i)
  {
    cout << setfill('0') << right << setw(6) << ans[i].first;
    cout << setfill('0') << right << setw(6) << ans[i].second << "\n";
  }
}


void C_755()
{
  int n;
  cin >> n;

  for (int i = 1; i <= n; ++i)
  {
    //string s = (string)n;
  }
}


void christmas_eve()
{
  int n, k;
  cin >> n >> k;
  vector<int> h(n);
  for (int i = 0; i < n; ++i) cin >> h[i];

  sort(h.begin(), h.end());

  int h_diff = 1000000000;
  for (int i = 0; i < n - k + 1; ++i)
  {
    h_diff = min(h_diff, h[i + k - 1] - h[i]);
  }

  cout << h_diff << "\n";
}


void grand_garden()
{
  int n;
  cin >> n;
  vector<int> h(n);
  for (int i = 0; i < n; ++i) cin >> h[i];

  int ans = 0, pre_flower = 0;
  for (int i = 0; i < n; ++i)
  {
    if (h[i] > pre_flower) ans += h[i] - pre_flower;
    pre_flower = h[i];
  }
  cout << ans << "\n";
}


int main()
{
  //C111();
  //pyramid();
  //id_113();
  //C_755();
  //christmas_eve();
  grand_garden();
}


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

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

  string s, t;
  cin >> s >> t;

  string u = s + t;
  int x = atoi(u.c_str());
  int d = sqrt(x);

  if (d * d == x) cout << "Yes" << '\n';
  else cout << "No" << '\n';

  return (0);
}

Measured memory_bytes: 3608
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <cmath>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <iostream>
#include <random>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <cassert>
#include <fstream>
#include <unordered_map>
#include <cstdlib>
#include <complex>
#include <cctype>
#include <bitset>
using namespace std;

using ll = long long;
using vll = vector<ll>;
using pll = pair<ll, ll>;
using qll = queue<ll>;
using vb = vector<bool>;
using mll = map<ll, ll>;
using sll = stack<ll>;
#define REP(i,n) for(ll i(0);(i)<(n);(i)++)
#define rep(i,n) for(ll i(0);(i)<(n);(i)++)
#define ALL(a) a.begin(), a.end()
#define enld endl //* missspell check
const ll INF = 1LL << 60;


void solve(long long N, long long M, std::vector<long long> x, std::vector<long long> y){
    vector<pll> A(N, pll(1, 0));
    A[0].second = 1;
    REP(i, M){
        ll a=x[i], b=y[i];
        if(A[a].second){
            A[b].second = 1;
        }
        A[a].first --;
        A[b].first ++;
        if(A[a].first==0){
            A[a].second = 0;
        }
    }
    ll cnt = 0;
    REP(i, N){
        if(A[i].second)
            cnt ++;
    }
    cout << cnt<<endl;

}

int main(){
    long long N;
    scanf("%lld",&N);
    long long M;
    scanf("%lld",&M);
    std::vector<long long> x(M);
    std::vector<long long> y(M);
    for(int i = 0 ; i < M ; i++){
        scanf("%lld",&x[i]);
        scanf("%lld",&y[i]);
        x[i]--; y[i]--;
    }
    solve(N, M, std::move(x), std::move(y));
    return 0;
}


Measured memory_bytes: 3328
#include <bits/stdc++.h>
using namespace std;
int main(void){
    // Your code here!
    int n,k,sum=0;
    cin>>n>>k;
    vector<int>p(n);
    for(int i=0; i<n; i++){
            cin>>p[i];
    }
    sort(p.begin(),p.end());
    for(int i=0; i<k; i++){
            sum+=p[i];
    }
    cout<< sum <<endl;
}


Measured memory_bytes: 3576
#include <stdio.h>
#include <string>
#include <iostream>
#include <iomanip>
#include <map>
#include <algorithm>
#include <vector>
#include <math.h>
#define MOD 1000000007
using namespace std;

int main(void){
    int a,b,c;
    cin >> a >> b >> c;
    /*if((a<b) ^ (b<c))cout << "Yes" << endl;
    else cout << "No" << endl;*/
    if((b<c&&c<a)||(a<c&&c<b))cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

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

#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define ALL(x) (x).begin(), (x).end()

typedef long long ll;

const int INF = 1e9;

struct Edge{
  int src, dst;
  Edge() {}
  Edge(int src, int dst) : src(src), dst(dst) {}
};

using Edges = vector<Edge>;
using Graph = vector<Edges>;

const int MAXN = 1001;
const int MAXV = MAXN * (MAXN - 1) / 2;

vector<int> dp(MAXV, -1); // max length of path from v
vector<bool> visited(MAXV, false), calculated(MAXV, false);

int dfs(const Graph & g, int v) {
  if (visited[v]) {
    if (!calculated[v]) return -1;
    return dp[v];
  }
  visited[v] = true;
  dp[v] = 1;
  for (Edge e : g[v]) {
    int ret = dfs(g, e.dst);
    if (ret == -1) return -1;
    dp[v] = max(dp[v], ret + 1);
  }
  calculated[v] = true;
  return dp[v];
};

int solve(int N, const vector<vector<int>> & A) {
  int V = 0;
  vector<vector<int>> index(N, vector<int>(N));
  auto toId = [&](int i, int j) {
    if (i > j) swap(i,j);
    return index[i][j];
  };
  REP(i,N)REP(j,N) if (i < j) index[i][j] = V++;

  Graph g(V);
  REP(i,N)REP(j,N-2) {
    int u = toId(i, A[i][j+1]);
    int v = toId(i, A[i][j]);
    g[u].push_back(Edge(u, v));
  }

  int ret = 0;
  REP(i,V) {
    int tmp = dfs(g, i);
    if (tmp == -1) return -1;
    ret = max(ret, tmp);
  }
  return ret;
}

int main(){
  int N;
  cin >> N;
  vector<vector<int>> A(N, vector<int>(N-1));
  REP(i,N)REP(j,N-1) {
    cin >> A[i][j]; A[i][j]--;
  }

  cout << solve(N, A) << endl;

  return 0;
}



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

using namespace std;

#define int long long

const int mod = 998244353;

int n, s;
int a[3001], f[3001];

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

	cin >> n >> s;
	for (int i = 1; i <= n; i++)	
		cin >> a[i];
	f[0] = 1;
	for (int i = 1; i <= n; i++)
		for (int j = s; j >= 0; j--)
		{
			(f[j] *= 2) %= mod;
			if (j >= a[i])
				(f[j] += f[j - a[i]]) %= mod;	
		}
	cout << f[s];
}

Measured memory_bytes: 3660
import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;

/**
 * 
 * @author morisin
 * 
 */
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		int S = sc.nextInt();
		
		int nextNum = S;
		
		Set<Integer> list = new HashSet<>();
		
		list.add(S);

		int size_before=0;
		int size_after=0;
		
		for(int i=2;i<=1000000;i++) {
			size_before=list.size();
			if(nextNum%2 == 0) {
				nextNum=nextNum/2;
				list.add(nextNum);
			}else {
				nextNum=nextNum*3+1;
				list.add(nextNum);
			}
			size_after=list.size();
			
			if(size_before==size_after) {
				System.out.println(i);
				break;
			}
		}
	}
}


Measured memory_bytes: 21844
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<set>
#include<ctime>
#include<vector>
#include<cmath>
#include<algorithm>
using namespace std;
inline void write(int a){
	if(a>=10)write(a/10);
	putchar('0'+a%10);
}
inline void writeln(int a){
	write(a); puts("");
}
inline int read()//不管是正负数，都可以 
{
	int x = 0; char ch = getchar(); bool positive = 1;
	for (; !isdigit(ch); ch = getchar())	if (ch == '-')	positive = 0;
	for (; isdigit(ch); ch = getchar())	x = x * 10 + ch - '0';
		return positive ? x : -x;
}
const int N=200005;
int n,ans1,peo[N],son[N],ed[N],father[N],zs,z,nextt[N],nedge;
inline void aedge(int a,int b){
	nextt[++nedge]=son[a]; son[a]=nedge; ed[nedge]=b;
}
inline void maketree(int p,int fa){
	peo[p]=1;
	for(int i=son[p];i;i=nextt[i])if(ed[i]!=fa){maketree(ed[i],p); peo[p]+=peo[ed[i]];} else father[p]=fa;
}
int main(){
	n=read();
	for(int i=1;i<n;i++){
		int s1=read(),s2=read();
		aedge(s1,s2); aedge(s2,s1); 
	}
	maketree(1,0);
	for(int i=n;i;i=father[i]){zs++;}
	for(int i=n;i;i=father[i]){z++; if(z==zs/2){
		ans1=peo[i]; break;
	}}
	if(peo[1]-ans1>ans1)puts("Fennec"); else puts("Snuke");
}

Measured memory_bytes: 5248
import math
n,m = map(int,input().split())
tmp = abs(n-m)

if tmp >= 2:
    ans = 0
elif tmp == 1:
    ans = math.factorial(n) * math.factorial(m)
else:
    ans = 2 * math.factorial(n) * math.factorial(m)

print(ans%(10**9+7))


Measured memory_bytes: 5180
let () = Scanf.scanf "%d %d\n" 
	(fun x y -> let l = [4;6;9;11] in
    Printf.printf "%s\n"
    (if List.mem x l && List.mem y l || x = 2 && y = 2 || x <> 2 && y <> 2 && not (List.mem x l || List.mem y l) 
    then "Yes" else "No"))

Measured memory_bytes: 4480
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define int long long
#define inf 1000000007
#define LINF 100000000000000007LL
#define ll long long
using namespace std;
signed main(){
	int n,q;
	string st;
	cin>>n>>st>>q;
	set<int> idx[30];
	for(int i=1;i<=n;i++){
		idx[ st[i-1] - 'a' ].insert(i);
	}
	for(int i=0;i<q;i++){
		int tp;
		cin>>tp;
		if( tp == 1 ){
			int pla;
			char ch;
			cin>>pla>>ch;
			idx[ st[pla-1] - 'a' ].erase(pla);
			st[pla-1] = ch;
			idx[ st[pla-1] - 'a' ].insert(pla);
		}
		else{
			int lef,rig;
			cin>>lef>>rig;
			int cnt = 0;
			for(int i=0;i<26;i++){
				auto it = idx[i].lower_bound(lef);
				if( it != idx[i].end() && *it <= rig ) cnt ++ ;
			}
			cout<<cnt<<endl;
		}
	}
	return 0;
}

Measured memory_bytes: 24324
#include <bits/stdc++.h>
#define MAXN 1000010
#define ll long long

using namespace std;

//struct node {/

int n, m;
int t, k;
int a[MAXN], b[MAXN];
int f;
int d, x, y, p, u, v;
string s;

int main() {
	cin >> n;
	
//	for (int i = 1; i <= n; i++) {
//		cin >> a[i];
//	}
//	
int ans =1;
	for (int i = 1; i <= 3; i++) {
		ans *= n;
	}
	cout << ans << endl;
	return 0;
}

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



int main(){
    ll n,a,b,c;cin>>n>>a>>b>>c;
    ll l[10];
    rep(i,0,n)cin>>l[i];
    ll c1,c2,c3,x,y,z,tm,MN=1e9;
    for(ll i=0;i<(1<<2*n);i++){
        x=0,y=0,z=0;
        c1=0,c2=0,c3=0;
        tm=0;
        rep(j,0,n){
            if(!(i&(1<<(2*j)))&&i&(1<<(2*j+1))){
                c1++;
                x+=l[j];
            }
            else if(i&(1<<(2*j))&&!(i&(1<<(2*j+1)))){
                c2++;
                y+=l[j];
            }
            else if(i&(1<<(2*j))&&i&(1<<(2*j+1))){
                c3++;
                z+=l[j];
            }
        }
        if(c1*c2*c3==0)continue;
        tm+=(c1-1)*10;
        tm+=(c2-1)*10;
        tm+=(c3-1)*10;
        ll A=min(abs(a-x)+abs(b-y)+abs(c-z),abs(a-x)+abs(b-z)+abs(c-y));
        ll B=min(abs(a-y)+abs(b-x)+abs(c-z),abs(a-y)+abs(b-z)+abs(c-x));
        ll C=min(abs(a-z)+abs(b-y)+abs(c-x),abs(a-z)+abs(b-x)+abs(c-y));
        tm+=min(A,min(B,C));
        MN=min(MN,tm);
    }
    cout<<MN<<endl;
}
    









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

signed main(){
  int n;string s;cin>>n>>s;
  set<int> one,two,three;
  for(int i=0;i<n;i++){
    int a=(s[i]-'0');
    for(int p:two)three.insert(p*10+a);
    for(int p:one)two.insert(p*10+a);
    one.insert(a);
  }
  cout<<three.size()<<endl;
}


Measured memory_bytes: 384
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <cstring>
#include <sstream>
#include <fstream>
#include <cassert>
#include <ctime>
#include <list>
#include <numeric>
#include <iomanip>


using namespace std;
static const double EPS = 1e-6;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> PI;
#ifndef M_PI
const double M_PI=acos(-1);
#endif
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
#define mp(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define SZ(a) (int((a).size()))
#define F first
#define S second
int dx[]={0,1,0,-1,1,1,-1,-1},dy[]={1,0,-1,0,1,-1,1,-1};


main(){
  string in;
  cin >> in;
  int ans = SZ(in);
  char key[] = "KUPC";
  rep(i,4) ans = min((int)count(ALL(in),key[i]),ans);
  cout << ans << endl;
}

Measured memory_bytes: 1188
#include <iostream>
#include <string>
#include <queue>
#include <stack>
#include <algorithm>
#include <list>
#include <vector>
#include <complex>
#include <utility>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <bitset>
#include <ctime>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <cassert>
#include <cstddef>
#include <iomanip>
#include <numeric>
#include <tuple>
#include <sstream>
#include <fstream>

using namespace std;
#define REP(i, n) for (int (i) = 0; (i) < (n); (i)++)
#define FOR(i, a, b) for (int (i) = (a); (i) < (b); (i)++)
#define RREP(i, a) for(int (i) = (a) - 1; (i) >= 0; (i)--)
#define FORR(i, a, b) for(int (i) = (a) - 1; (i) >= (b); (i)--)
#define DEBUG(C) cerr << #C << " = " << C << endl;
using LL = long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VL = vector<LL>;
using VVL = vector<VL>;
using VD = vector<double>;
using VVD = vector<VD>;
using PII = pair<int, int>;
using PDD = pair<double, double>;
using PLL = pair<LL, LL>;
using VPII = vector<PII>;
template<typename T> using VT = vector<T>;
#define ALL(a) begin((a)), end((a))
#define RALL(a) rbegin((a)), rend((a))
#define SORT(a) sort(ALL((a)))
#define RSORT(a) sort(RALL((a)))
#define REVERSE(a) reverse(ALL((a)))
#define MP make_pair
#define FORE(a, b) for (auto &&a : (b))
#define FIND(s, e) ((s).find(e) != (s).end())
#define EB emplace_back
template<typename T> inline bool chmax(T &a, T b){if (a < b){a = b;return true;}return false;}
template<typename T> inline bool chmin(T &a, T b){if (a > b){a = b;return true;}return false;}

const int INF = 1e9;
const int MOD = INF + 7;
const LL LLINF = 1e18;
const long double EPS = 1e-9;

int main(void) {
    long double d;
    cin >> d;
    cout << fixed << setprecision(15) << max(sqrtl(2.0) * d, floor(d) + 1) << endl;
}

Measured memory_bytes: 3340
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<n; i++)
long long mo = 1e9 + 7;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }

int main(){
    ll N;
    string S;
    cin >> N >> S;
    vector<ll> RB(N+1), LW(N+1);
    rep(i,N){
        RB[i+1] = RB[i] + ll(S[i] == '#');
        LW[N-1-i] = LW[N-i] + ll(S[N-1-i] == '.');
    }
    ll m=1e18;
    rep(i,N+1){
        cmin(m,RB[i] + LW[i]);
    }
    cout << m << endl;
}


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

using namespace std;

#define LOG(...) fprintf(stderr,__VA_ARGS__)
//#define LOG(...)
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort(ALL(c))
#define RSORT(c) sort(RALL(c))

typedef long long ll;
typedef unsigned long long ull;
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vb> vvb;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

const int dxdy[] = {-1,3,1,-3};

int main() {
    int life;
    while (cin >> life, life) {
        char start, goal, soko;
        cin >> start >> goal >> soko;
        start -= 'A';
        goal -= 'A';
        soko -= 'A';

        vvi dp(2, vi(9, 0));
        dp[0][start] = 1;
        FOR(i, 1, life+1) {
            fill(ALL(dp[1]), 0);
            REP(j, 9) {
                if (dp[0][j] > 0) {
                    REP(k, 4) {
                        int s = j + dxdy[k];
                        if (!(0 <= s && s <= 8) ||
                            ((j == 2 || j == 5) && k == 2) || ((j == 3 || j == 6) && k == 0) ||
                            s == soko) {
                            dp[1][j] += dp[0][j];
                        } else {
                            dp[1][s] += dp[0][j];
                        }
                    }
                }
            }
            dp[0] = dp[1];
        }
        int cnt = 0;
        REP(i, 9) {
            cnt += dp[0][i];
        }
        printf("%.8f\n", (double)dp[0][goal] / cnt);
    }
}

Measured memory_bytes: 1216
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
#define rep(var, n) for (int var = 0; var < (n); ++var)
#define ALL(c) (c).begin(), (c).end()

int main() {
  //
  int n, k;
  cin >> n >> k;
  int idx = -1;
  rep(i, n) {
    int a;
    cin >> a;
    if (a == 1) {
      idx = i;
      break;
    }
  }
  int ans = 1;
  int start = 0;
  while (start + k < n) {
    ans++;
    start += (k - 1);
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
import java.io.*;
import java.util.*;

public class Main {
    public static final long mod = (long)1e9+7;
    public static final long INF = Long.MAX_VALUE/2;
    public static final int inf = Integer.MAX_VALUE/2;

    static void solve(InputReader in, PrintWriter out){
        int n = in.ni();
        int k = in.ni();
        int[] cand = new int[n];
        for (int i = 0; i < k; i++) {
            int d = in.ni();
            int[] a = in.ni(d);
            for(int j:a){
                cand[j-1]++;
            }
        }
        int ans = 0;
        for (int i = 0; i < n; i++) {
            if(cand[i]==0)ans++;
        }
        out.println(ans);
    }

    public static void main(String[] args){
        InputReader in = new InputReader(System.in);
        PrintWriter out = new PrintWriter(System.out);
        solve(in, out);
        out.close();
    }
    public static class InputReader{
        private BufferedReader br;
        private StringTokenizer st;
        public InputReader(InputStream is){
            br = new BufferedReader(new InputStreamReader(is));
            st = null;
        }
        public String ns(){
            if(st == null || !st.hasMoreTokens()){
                try{
                    st = new StringTokenizer(br.readLine());
                }catch (Exception e){
                    throw new RuntimeException(e);
                }
            }
            return st.nextToken();
        }
        public int ni(){
            return Integer.parseInt(ns());
        }
        public long nl(){
            return Long.parseLong(ns());
        }
        public double nd(){
            return Double.parseDouble(ns());
        }
        public char nc(){
            return ns().toCharArray()[0];
        }
        public int[] ni(int n){
            int[] a = new int[n];
            for (int i = 0; i < n; i++) {
                a[i] = ni();
            }
            return a;
        }
        public long[] nl(int n){
            long[] a = new long[n];
            for (int i = 0; i < n; i++) {
                a[i] = nl();
            }
            return a;
        }
        public double[] nd(int n){
            double[] a = new double[n];
            for (int i = 0; i < n; i++) {
                a[i] = nd();
            }
            return a;
        }
    }
}

Measured memory_bytes: 33580
#include <iostream>
#include <cstdio>
#include <algorithm>
using namespace std;

int main(int argc, char* argv[]) {
	static int N;
	cin >> N;
	int* a = new int[N];

	for(int i = 0; i < N; i++) cin >> a[i];
	for(int i = 0; i < N; i++){
		if(i != N - 1) printf("%d ",a[N-i-1]);
		else printf("%d",a[N-i-1]);
	}
	printf("\n");
	return 0;
}

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

typedef long long ll;
#define pii pair<int , int>
#define _FastIO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define MAXX 1005

int n , m;

int main()
{
    _FastIO;
    cin >> n >> m;

    if(n == m){
        cout << "Yes" << endl;
        return 0;
    }
    cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <iostream>
using namespace std;
#define REP(i, n) for(int i = 0; i < (int)(n); ++i)
typedef long long ll;

int main(void) {
  char buf[10];
  scanf("%s", buf);
  puts(buf[2] == buf[3] && buf[4] == buf[5] ? "Yes" : "No");
  return 0;
}


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

int main(){
    int n, q;
    string s;
    cin >> n >> q >> s;

    vector<int> l(q), r(q);
    for(int i=0; i<q; i++){
        cin >> l[i] >> r[i];
    }

    int count = 0;

    vector<int> record(s.size());// cumulative sum
    record[0] = 0;
    
    for(int i=1; i<s.size(); i++){
        if(s[i-1] == 'A' && s[i] == 'C'){
            count += 1;
        }
        record[i] = count;
    }

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

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

typedef long long ll;
ll N,A,B,C,D;

int main(){
	cin >> N >> A >> B >> C >> D;
	bool judge = false;
	for(int i=0;i<=N-1;i++){
		ll x = -i*C + (N-1-i)*D, y = (N-1-i)*C - i*D;
		if(y<=B-A && B-A <= x) judge = true;
	}
	if(judge) cout << "YES" << endl;
	else cout << "NO" << endl;
}

Measured memory_bytes: 256
//
//  main.cpp
//  
//
//  Created by yataka on 2018/10/11.
//

#include <stdio.h>
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
int main(){
    int A, B, C;
    cin >> A >> B >> C;
    string ans  ="NO";
    for(int i = A; i <= A*B; i = i + A){
        if(i % B == C){
            ans = "YES";
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
sn = input()
for i in range(len(sn)-1):
    if sn[i] == sn[i+1]:
        print(i+1, i+2)
        break
    if (i < (len(sn)-2)) and (sn[i] == sn[i+2]):
        print(i+1, i+3)
        break
else:
    print(-1, -1)

Measured memory_bytes: 3188
import collections
import sys
sys.setrecursionlimit(100000)

# ---- belmann-ford -----
V_num, E_num, r = [int(ele) for ele in input().split()]
adjc_list = []
edges = []
for _ in range(V_num):
    adjc_list.append([])

for _ in range(E_num):
    src, dst, w = [int(ele) for ele in input().split()]
    adjc_list[src].append([w, dst])
    edges.append([src, dst, w])

INF = 99999999999999
d = [INF for _ in range(V_num)]
d[r] = 0

# ---- dfs ----
stack = collections.deque()
yet = [ele for ele in range(V_num)]


def main():
    global edges
    # 連結成分の調査
    stack.clear()
    stack.appendleft(r)
    dfs(stack)
    # yet に残っているやつは非連結成分なので、bellman_fordの探索する辺リストから除外する
    edges = list(filter(lambda e: e[0] not in yet and e[1] not in yet, edges))
    output_ans() if bellman_ford() != -1 else print("NEGATIVE CYCLE")


def dfs(stack):
    if not stack:
        return

    n = stack[0]
    yet.remove(n)

    for _, dst in adjc_list[n]:  # stackの表面
        if dst in yet:  # 未訪問なら
            stack.appendleft(dst)
            dfs(stack)
    else:
        stack.popleft()


def bellman_ford():
    for _ in range(V_num - 1):
        for src, dst, w in edges:
            if d[dst] > w + d[src]:
                d[dst] = w + d[src]

    for src, dst, w in edges:
        if d[dst] > w + d[src]:
            return -1

    return


def output_ans():
    for d_i in d:
        if d_i == INF:
            print("INF")
        else:
            print(d_i)


if __name__ == "__main__":
    main()



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

int main() {
  int N;
  string S;
  cin >> N >> S;

  int count = 0;
  int pos = S.find("ABC");
  while (pos != std::string::npos) {
    count++;
    pos = S.find("ABC", pos + 3);
  }
  
  cout << count << endl;
}

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

int ans = 10000000007; 
signed main(){
    
    int n,k;
    cin >> n >> k;
    int a[n+1];
    for(int i = 1;i<=n;i++){
        cin >> a[i];
    }

    for(int i = 1;(i+k-1)<=n;i++){
        int j = i+k-1;
        //cout << j << endl;
        int tmp;
        if(a[i]<=0 && a[j]<=0)tmp = abs(a[i]);
        if(a[i]>0 && a[j]>0)tmp = a[j];
        if(a[i]<=0 && a[j]>=0)tmp = min(2*abs(a[i])+a[j], abs(a[i])+2*a[j]);
        //cout << tmp << endl;
        ans = min(ans,tmp);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 1024
#include<cstdio>
#include<math.h>
#include<algorithm>
#include<vector>
#include<queue>
#include<string>
#include<set>
#include<cstring>
#include<map>
 
 
using namespace std;
#define int long long int
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1001001001
#define LLINF 1001001001001001001
#define mp make_pair
#define pb push_back
#define MOD 1000000007



int N;
int A[10009];
map<int,int> P[10009];
map<int,int> L;

//素因数分解
map<int,int> PrimeF(int N){
    int M=N;
    map<int,int> ret;
    for(int i=2;i<sqrt(N)+1;i++){
        int cnt=0;
        while(M%i==0){
            M/=i;
            cnt++;
        }
        if(cnt>0)ret[i]=cnt;
        if(cnt>0&&cnt>L[i])L[i]=cnt;//この問題でだけ使う
    }
    if(M!=1)ret[M]=1;
    if(M!=1&&1>L[M])L[M]=1;//この問題でだけ使う
    return ret;
}

int calc_pow(int x, int pow) {
    if (pow == 0) return 1;
    int a = calc_pow(x, pow / 2);
    a = a * a % MOD;
    if (pow % 2 == 1) a *= x;
    return a % MOD;
}
int calc_div(int a,int b) {
    return a * calc_pow(b, MOD - 2) % MOD;
}

signed main(){
    scanf("%lld",&N);
    int maxA=0;
    rep(i,N){
        scanf("%lld",&A[i]);
         P[i]=PrimeF(A[i]);
         if(A[i]>maxA)maxA=A[i];
    }
    int l=1;
    int ans=0;
    for(auto itr = L.begin(); itr != L.end(); ++itr) {
        l*=calc_pow(itr->first,itr->second);
        l%=MOD;
    }
    rep(i,N){
        ans+=calc_div(l,A[i]);
        ans%=MOD;
    }
    printf("%lld\n",ans);
    return 0;
}


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

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

  double ans1 = 0;
  for(int i = 1; i <= n;i++) {
    double p = (double)1 / n;
    int num = i;

    while(num < k) {
      p /= 2;
      num *= 2;
    }

    ans1 += p;
  }
  
  
    printf("%.12f\n",ans1);
  
}

Measured memory_bytes: 256
import java.util.*;
public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		char[] s = sc.next().toCharArray();
		int n = s.length;
		long k = sc.nextLong();

		char[] _s = s.clone();
		Arrays.sort(_s);
		if(_s[0] == _s[n-1]) { //every char is the same
			long _n = n;
			System.out.println((_n*k)/2);
		}
		else {
			if(s[0] == s[n-1]) {
				long a = 1;
				for(int i = 1; i < n; i++) {
					if(s[i] == s[0]) a++;
					else break;
				}
				long b = 1;
				for(int i = n-2; i >= 0; i--) {
					if(s[i] == s[0]) b++;
					else break;
				}
				ArrayList<Long> sizes = new ArrayList<Long>();
				int last = (int)a;
				long siz = 1;
				for(int i = (int)a+1; i < n; i++) {
					if(s[i] == s[last]) siz++;
					else {
						sizes.add(siz);
						siz = 1;
						last = i;
					}
				}
				long res = 0; 
				for(long ss: sizes) {
					res += ss / 2;
				}
				res *= k;
				res += ((a+b)/2) * (k-1);
				res += a / 2 + b / 2;
				System.out.println(res);
			}
			else {
				ArrayList<Long> sizes = new ArrayList<Long>();
				int last = 0;
				long siz = 1;
				for(int i = 1; i < n; i++) {
					if(s[i] == s[last]) siz++;
					else {
						sizes.add(siz);
						siz = 1;
						last = i;
					}
				}
				sizes.add(siz);
				long res = 0;
				for(long ss: sizes) {
					res += ss / 2;
				}
				res *= k;
				System.out.println(res);
			}
		}
	}

}


Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
#define all(n) begin(n), end(n)
const long long INF = numeric_limits<long long>::max();
typedef long long ll;
typedef vector<int> vint;
typedef vector<vector<int>> vvint;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef unsigned long long ull;
template <class T>
bool chmax(T &a, const T &b)
{
    if (a < b)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T &a, const T &b)
{
    if (b < a)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <typename T>
vector<T> make_v(size_t a) { return vector<T>(a); }

template <typename T, typename... Ts>
auto make_v(size_t a, Ts... ts)
{
    return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...));
}
template <typename T, typename V>
typename enable_if<is_class<T>::value == 0>::type
fill_v(T &t, const V &v) { t = v; }

template <typename T, typename V>
typename enable_if<is_class<T>::value != 0>::type
fill_v(T &t, const V &v)
{
    for (auto &e : t)
        fill_v(e, v);
}
int main()
{
    int N, K;
    cin >> N >> K;
    ll ans = 0;
    vector<pair<ll, ll>> sushies;
    for (size_t i = 0; i < N; i++)
    {
        ll t, d;
        cin >> t >> d;
        sushies.push_back({d, t});
    }
    sort(all(sushies), greater<pair<ll, ll>>());
    map<ll, ll> cnt;
    vll anss(N + 1, -INF);
    ll idx = K - 1;
    int num=0;
    for (size_t i = 0; i < N; i++)
    {
        if (i < K)
        {
            ans += sushies[i].first;
            cnt[sushies[i].second]++;
            if (i == K - 1)
            {
                chmax(anss[cnt.size()], ans);
                num=cnt.size();
            }
                
        }
        else
        {
            if (cnt.count(sushies[i].second) == 0)
            {
                while (idx >= 0 and cnt[sushies[idx].second] <= 1)
                {
                    idx--;
                }
                if (idx < 0)
                {
                    break;
                }
                cnt[sushies[i].second]++;
                cnt[sushies[idx].second]--;
                ans = ans - sushies[idx].first + sushies[i].first;
                num++;
                chmax(anss[num], ans);
                idx--;
            }
        }
    }
    for (ll i = 1; i < N + 1; i++)
    {
        chmax(ans, anss[i] + i * i);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 9468
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Security.Cryptography.X509Certificates;
using System.Text.RegularExpressions;
using Console = System.Console;

namespace Atcoder
{
    class Program
    {
        static void Main(string[] args)
        {
            var S = Console.ReadLine();
            if (S.Contains("a") &&
                S.Contains("b") &&
                S.Contains("c"))
            {
                Console.WriteLine("Yes");
            }
            else
            {
                Console.WriteLine("No");
            }
        }
    }
}

Measured memory_bytes: 13140
from statistics import median

N = int(input())
A = [0] * N
B = [0] * N
max=0
min =0
for c in range(N):
    A[c], B[c] = map(int, input().split())

med_A = median(A)
med_B = median(B)

if N%2==0:
    print(int((med_B-med_A)*2+1))
else:
    print(med_B-med_A+1)

Measured memory_bytes: 28672
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rrep(i, n) for (int i = (n); i >= 0; i--)
#define loop(i, r, n) for (int i = (r); i < (n); i++)
#define pb push_back
#define all(in) in.begin(),in.end()

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

using ll = long long;
using ull = unsigned long long;
using namespace std;

int main(){
    ll n; cin >> n;
    map<ll,ll> mp;
    rep(i,n){
        ll a; cin >> a;
        mp[a]++;
    }
    vector<ll> data;
    for(auto p : mp){
        data.push_back(p.second);
    }
    sort(all(data));
    ll d = data.size();

    vector<ll> ans(n+1,0);
    loop(i,1,n+1){
        ll id = lower_bound(all(data),i) - data.begin();
        ans[i] += (d - id);
        ans[i] += ans[i-1];
    } // i+1回操作する
    loop(i,1,n+1){
        ll low = 0, high = n+1;
        while(high-low > 1){
            ll mid = (high+low)>>1;
            if(ans[mid] >= i*mid) low = mid;
            else high = mid;
        }
        cout << low << endl;
    }
}

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

#define REP(i, n) for(long long i = 0; i < (long long) (n); i++)
#define ALL(v) (v).begin(), (v).end()
#define INF 1e9+7

using namespace std;
typedef long long ll;

int main(){
  ll n;
  while(cin >> n and n){
    int res = 0;
    REP(i, sqrt(n)+1){
      if(i == 0) continue;
      REP(j, i+1) REP(k, j+1) REP(l, k+1){
        if(i * i + j * j + k * k + l * l == n) res++;
      }
    }
    cout << res << endl;
  }
  return 0;
}

Measured memory_bytes: 3100
#include <bits/stdc++.h>
#define all(x) x.begin(), x.end()
#define sz(x) (int)x.size()
#define x first
#define y second
using namespace std;
using ll = long long;
using ld = long double;

int main() {
#ifdef LC
    assert(freopen("input.txt", "r", stdin));
#endif
    ios::sync_with_stdio(0), cin.tie(0);
	
	string s;
	cin >> s;
	cout << string(s.size(), 'x') << endl;

	return 0;
}


Measured memory_bytes: 256
import heapq


def dijkstra(K):
    c_l = [float('inf')] * N
    c_l[K] = 0
    hq = [(K, 0)]
    while hq:
        u = heapq.heappop(hq)[0]
        for nv, c in adj_list[u]:
            if c_l[nv] > c_l[u] + c:
                c_l[nv] = c_l[u] + c
                heapq.heappush(hq, (nv, c_l[nv]))
    return c_l


N = int(input())
adj_list = [[] for _ in range(N)]

for _ in range(N - 1):
    a, b, c = map(int, input().split())
    a -= 1
    b -= 1
    adj_list[a].append((b, c))
    adj_list[b].append((a, c))

Q, K = map(int, input().split())
c_l = dijkstra(K - 1)

for _ in range(Q):
    x, y = map(int, input().split())
    x -= 1
    y -= 1
    print(c_l[x] + c_l[y])


Measured memory_bytes: 46328
#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() {
    int N,C,K;
    cin >> N >> C >> K;
    vector<int> T(N+1);
    REP(i,1,N+1){
        cin >> T[i];
    }

    sort(T.begin(),T.end());

    int ans = 0;
    int peo = 0;
    int begin = 0;
    int time = 0;
    int end = 0;
    bool stop = false;
    REP(i,1,N+1){
        if(stop){
            if( T[i] <= end && peo < C){
                time = time + T[i];
                peo++;
            }else{
                stop = false;
            }
        }


        if(!stop){
            ans++;
            begin = T[i];
            time = begin;
            end = begin + K;
            peo = 1;
            stop = true;
        }

    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
const int INF = 1e9;
const int MOD = 1e9+7;
const long long LINF = 1e18;
#define dump(x)  cout << 'x' << ' = ' << (x) << ` `;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)
#define FOREACH(x,a) for(auto& (x) : (a) )
typedef long long ll;
using namespace std;
typedef pair<ll, ll> P;

ll dp[6][400];

void print(int m) {
	rep(i,5) {
		rep(j,m) {
			cout<<dp[i][j]<<" ";
		}
		cout<<endl;
	}
}

int main(int argc, char const *argv[]) {
	int n;
	cin>>n;
	vector<ll> p(4),t(4);
	rep(i,4)cin>>p[i];
	rep(i,4)cin>>t[i];
	rep(j,400) dp[0][j] = 0;
	rep(i,4) {
		rep(j,400) {
			if (j < p[i]) dp[i+1][j]=dp[i][j];
			else dp[i+1][j] = max(dp[i][j],dp[i+1][j-p[i]]+t[i]);
		}
	}
	// print(10);
	int ans = INF;
	rep(j,5) {
		for (int i = 1; i < 400; ++i) {
			if (dp[j][i] >= n) ans = min(ans,i);
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 3132
import numpy as np
a,b = [int(i) for i in input().split()]

al = np.array([list(input()) for _ in range(a)])
bl = np.array([list(input()) for _ in range(b)])

flg  = False
for i in range(a - b + 1):
    for j in range(a - b + 1):
        if(al[i:i+b,j:j+b] == bl).all():
            flg = True
            
print('Yes' if flg else 'No')



Measured memory_bytes: 22612
#include <bits/stdc++.h>
    using namespace std;
     
    int main(void){
        long H, N, S;
        cin >> H;
        N = 0;
        while(H > 0){
            H = H/2;
            N++;
        }
        S = pow(2, N)-1;
        cout << S <<endl;
        return 0;
    }

Measured memory_bytes: 256
# include <iostream>
# include <algorithm>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <utility>
# include <stack>
# include <queue>
# include <list>
# include <tuple>
# include <unordered_map>
# include <numeric>
# include <complex>
# include <bitset>
# include <random>
# include <chrono>
# include <cstdlib>
# include <tuple>
# include <array>
using namespace std;
using LL = long long;
using ULL = unsigned long long;
using D = double;
constexpr int INF = 2147483647;
constexpr int HINF = INF / 2;
constexpr double DINF = 100000000000000000.0;
constexpr double HDINF = 50000000000000000.0;
constexpr long long LINF = 9223372036854775807;
constexpr long long HLINF = 4500000000000000000;
const double PI = acos(-1);
template <typename T_char>T_char TL(T_char cX) { return tolower(cX); };
template <typename T_char>T_char TU(T_char cX) { return toupper(cX); };
typedef pair<LL, LL> pii;
const int vy[] = { -1, -1, -1, 0, 1, 1, 1, 0 }, vx[] = { -1, 0, 1, 1, 1, 0, -1, -1 };
const int dx[4] = { 0,1,0,-1 }, dy[4] = { 1,0,-1,0 };
int popcnt(unsigned long long n) { int cnt = 0; for (int i = 0; i < 64; i++)if ((n >> i) & 1)cnt++; return cnt; }
int d_sum(LL n) { int ret = 0; while (n > 0) { ret += n % 10; n /= 10; }return ret; }
int d_num(LL n) { int ret = 0; while (n > 0) { ret++; n /= 10; }return ret; }
LL gcd(LL a, LL b) { if (b == 0)return a; return gcd(b, a%b); };
LL lcm(LL a, LL b) { LL g = gcd(a, b); return a / g*b; };
# define ALL(qpqpq)           (qpqpq).begin(),(qpqpq).end()
# define RALL(qpqpq)           (qpqpq).rbegin(),(qpqpq).rend()
# define UNIQUE(wpwpw)        sort(ALL((wpwpw)));(wpwpw).erase(unique(ALL((wpwpw))),(wpwpw).end())
# define LOWER(epepe)         transform(ALL((epepe)),(epepe).begin(),TL<char>)
# define UPPER(rprpr)         transform(ALL((rprpr)),(rprpr).begin(),TU<char>)
# define FOR(i,tptpt,ypypy)   for(LL i=(tptpt);i<(ypypy);i++)
# define RFOR(i,tptpt,ypypy)  for(LL i=(tptpt);i>=(ypypy);i--)
# define REP(i,upupu)         FOR(i,0,upupu)
# define INIT                 std::ios::sync_with_stdio(false);std::cin.tie(0)

int h, r;

int main() {
	cin >> h >> r;
	if (h + r > 0)cout << 1 << endl;
	if (h + r == 0)cout << 0 << endl;
	if (h + r < 0)cout << -1 << endl;
}


Measured memory_bytes: 3116
#include <algorithm>
#include <iomanip>
#include <iostream>
#include <set>
#include <string>
#include <vector>
#define SORT(a) sort((a).begin(), (a).end())
#define RSORT(a) sort((a).rbegin(), (a).rend())
#define REP(i, n) for (int i = 0; i < n; i++)
#define FOR(i, start, end) for (int i = start; i < end; i++)
#define FORSTEP(i, start, end, step) for (int i = start; i < end; i += step)
#define ALL(a) a.begin(), a.end()
typedef long long ll;
using namespace std;

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

    int N, M, X;
    cin >> N >> M >> X;
    vector<int> A(M);
    REP(i, M) cin >> A[i];

    int l = 0, r = 0;
    REP(i, X) {
        REP(j, M) {
            if (i == A[j])
                l++;
        }
    }

    r       = M - l;
    int ans = min(l, r);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fi first
#define se second
#define ll long long
//priority_queue<int, vector<int>, greater<int> > pq;
#define _CRT_SECURE_NO_DEPRECATE
const int N = 330030;
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
const ll mod =  1e9+7;
using namespace std;
int a[N];
int b[N];
int main() {
int n;
cin>>n;
bool pos=false,neg=false;
rep(i,0,n)
{
	cin>>a[i];
	if(a[i]>=0)
	{

	pos=true;
	b[i]=1;}
	else
	{
  b[i]=-1;
	neg=true;}
	}

	if(!(neg&&pos))
	{

	int x=0;
		rep(i,0,n)
		{
			if(abs(a[i])<abs(a[x]))
			x=i;
		}
			b[x]*=-1;
	}

	int p=-1;
	int sum=0;
	rep(i,0,n)
	{
		sum+=a[i]*b[i];
	}
	cout<<sum<<"\n";
	int q=-1;

	rep(i,0,n)
	{
		if(b[i]==1)
		{
			if(p==-1)
			p=i;
		}
		else
		{
			if(q==-1)
			q=i;
		}
	}
//cout<<p<<" "<<q<<endl;
rep(i,0,n)
{
	if(i==p||i==q)
	continue;
	if(b[i]==1)
	{
		cout<<a[q]<<" "<<a[i]<<endl;
		a[q]-=a[i];
	}
	else
	{
		cout<<a[p]<<" "<<a[i]<<endl;
		a[p]-=a[i];
	}
}
cout<<a[p]<<" "<<a[q];
}


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

void fastIO() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    cout.precision(10);
    cout<<fixed;
#ifdef _DEBUG
    freopen("input.txt", "r", stdin);
#endif
}

int main() {
    fastIO();
    ll n,k;
    cin>>n>>k;
    for(ll i=1;; ++i) {
        if((ll)pow(k,i) > n) {
            cout<<i;
            break;
        }
    }
    return 0;
}

Measured memory_bytes: 256