akhauriyash/Code-Regression huggingface dataset:
/* cerberus97 - Hanit Banga */

#include <iostream>
#include <iomanip>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>
#include <numeric>

using namespace std;

#define pb push_back
#define fast_cin() ios_base::sync_with_stdio(false); cin.tie(NULL)

typedef long long ll;
typedef long double ld;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;

const int N = 1e5 + 10;

int fdiv2(int x);
bool check(string& s, int n, int d1, int d2);

int main() {
	fast_cin();
	string s; cin >> s;
	int n = s.length();
	int lo = 1, hi = n - 1;
	while (lo <= hi) {
		int mid = (lo + hi) / 2;
		bool ok = false;
		for (int d1 = (mid - 1) / 2; d1 <= (mid + 2) / 2; ++d1) {
			if (check(s, n, d1, mid - d1)) {
				ok = true;
				break;
			}
		}
		if (ok) {
			hi = mid - 1;
		} else {
			lo = mid + 1;
		}
	}
	int ans = hi + 1;
	int delta = 0, cnt = 0, bmax = 0, bmin = 0;
	for (int i = 0; i < n; ++i) {
		if (s[i] == '?') {
			++cnt;
		} else {
			delta += (s[i] == '0' ? 1 : -1);
		}
		bmax = max(bmax, delta - cnt);
		bmin = min(bmin, delta + cnt);
	}
	lo = 0; hi = n;
	while (lo <= hi) {
		int mid = (lo + hi) / 2;
		if (check(s, n, bmax, mid)) {
			hi = mid - 1;
		} else {
			lo = mid + 1;
		}
	}
	ans = min(ans, bmax + hi + 1);
	lo = 0; hi = n;
	while (lo <= hi) {
		int mid = (lo + hi) / 2;
		if (check(s, n, mid, -bmin)) {
			hi = mid - 1;
		} else {
			lo = mid + 1;
		}
	}
	ans = min(ans, -bmin + hi + 1);
	cout << ans << endl;
}

int fdiv2(int x) {
	return (x > 0 ? x / 2 : -((-x + 1) / 2));
}

bool check(string& s, int n, int d1, int d2) {
	vector<vector<int>> mx(2, vector<int>(n, n));
	int cnt = 0, delta = 0;
	bool ok = true;
	for (int i = 0; i < n; ++i) {
		if (s[i] == '?') {
			++cnt;
		} else {
			delta += (s[i] == '0' ? 1 : -1);
		}
		mx[0][i] = fdiv2(cnt - delta + d1);
		mx[1][i] = fdiv2(cnt + delta + d2);
	}
	for (int i = n - 2; i >= 0; --i) {
		mx[0][i] = min(mx[0][i], mx[0][i + 1]);
		mx[1][i] = min(mx[1][i], mx[1][i + 1]);
	}
	ok &= (mx[0][0] >= 0 and mx[1][0] >= 0);
	int c0 = 0, c1 = 0;
	for (int i = 0; i < n; ++i) {
		if (s[i] != '?') {
			continue;
		} else if (c0 >= mx[0][i] and c1 >= mx[1][i]) {
			ok = false;
			break;
		} else if (c0 < mx[0][i]) {
			++c0;
		} else {
			++c1;
		}
	}
	return ok;
}

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

using namespace std;
#define ll long long

int main()
{
    int n,m;
    scanf("%d%d",&n,&m);
    int ans=0;
    for(int i=0;i<n;i++)
    {
        int t;
        scanf("%d",&t);
        if(t>=m)ans++;
    }
    cout << ans;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <set>
#include <utility>
#include <cstdlib>
#include <queue>
#include <iomanip>
#include <cstdio>

using namespace std;


int main(){
    int N,M;

    scanf("%d %d", &N,&M);

    int p = 1;

    p <<= M;

    int ac = N-M;
    int t = M * 1900 + ac * 100;

    printf("%d\n", t * p);

    return 0;
}


Measured memory_bytes: 256
import sys
import heapq

n, k = map(int, input().split())
h = []
heapq.heapify(h)
for x in map(int, input().split()):
  heapq.heappush(h, x)

if n <= k:
  print(0)
  sys.exit()

ans = 0
for x in range(n - k):
  ans += heapq.heappop(h)

print(ans)


Measured memory_bytes: 31752
#include <iostream>
#include <algorithm>

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

using namespace std;

int v[100005];
int main(){
    int n, k;
    while(cin >> n >> k, n|k){
        rep(i, k) cin >> v[i];
		sort(v, v+k);
        int prev = 0, seq = 0;
        int ans = 0;
        for(int i = 1+!v[0]; i <= k; i++){
            seq++;
            if(v[i] != v[i-1]+1 || i == k){
				if(!v[0]) ans = max(ans, prev+seq+1);
				else ans = max(ans, seq);
                prev = seq;
                seq = 0;
            }
        }
        cout << ans << endl;
    }
	return 0;
}

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

using namespace std;

int main() {

    int A, B, C, K;
    cin >> A >> B >> C >> K;

    int ans = 0;
    int number = K;

    if(number > 0) {
        if(number >= A) {
            ans = A;
            number = number - A;
        }else {
            ans = number;
            cout << ans << endl;
            return 0;
        }
    }

    if(number > 0) {
        if(number >= B) {
            number = number - B;
        }else {
            cout << ans << endl;
            return 0;
        }
    }

    if(number > 0) {
        ans = ans - number;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3600
////////////////////////////////////
////////////////////////////////////
////                            ////
////                            ////
////     Please give me AC!     ////
////     Please give me AC!     ////
////                            ////
////                            ////
////////////////////////////////////
////////////////////////////////////
#include <bits/stdc++.h>
using namespace std;
const long long  MOD=13;
long long mod_pow(long long x,long long y){//x^yを返す//計算量は0(log(y))
  long long t=x,r=1;
  while(y){
    if(y%2){r=r*t%MOD;}
    y>>=1;
    t=t*t%MOD;
  }
  return r;
}
int main(){
  string S;
  cin>>S;
  long long dp[100020][26];
  long long dpcopy[13],mod=1e9+7;
  for(long long i=1;i<=(long long)S.size();i++){
    if(S.at(i-1)=='?'){
      for(long long j=0;j<13;j++){
        if(i==1 && j<10){
          long long w=(long long)S.size()-1;
          long long a=mod_pow(10,w)*j;
          a%=13;
          dp[1][a]=1;
        }
        else if(i>1){
          for(long long k=0;k<13;k++){
            dpcopy[k]=dp[i-1][k];
          }
          for(long long k=0;k<10;k++){
            long long w=(long long)S.size()-i;
            long long a=mod_pow(10,w)*k;
            a%=13;
            dp[i][j]+=dpcopy[(j-a+13)%13];
            dp[i][j]%=mod;
          }
          for(long long k=0;k<13;k++){
            dp[i-1][k]=dpcopy[k];
          }
        }
      }
    }
    else{
      if(i==1){
        long long w=(long long)S.size()-i;
        long long a=mod_pow(10,w)*(S.at(i-1)-'0');
        a%=13;
        dp[1][a]=1;
      }
      else{
        for(long long j=0;j<13;j++){
          dpcopy[j]=dp[i-1][j];
        }
        long long w=(long long)S.size()-i;
        long long a=mod_pow(10,w)*(S.at(i-1)-'0');
        a%=13;
        for(long long j=0;j<13;j++){
          dp[i][j]=dpcopy[(j-a+13)%13];
        }
        for(long long j=0;j<13;j++){
          dp[i-1][j]=dpcopy[j];
        }
      }
    }
  }
  cout<<dp[(long long)S.size()][5]<<endl;
}

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

int main(){
    int r, d, initial;

    cin >> r >> d >> initial;
    int prev=initial;
    for(int i=0;i<10;i++){
        prev=r*prev-d;
        cout << prev << endl;
    }
    return 0;
}




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

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

#define F first
#define S second
#define PB push_back
#define MP make_pair
#define what_is(x) cerr << #x << " is " << x << endl;
#define MT make_tuple
#define eb emplace_back
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))

#define REP(i,a,b) for (int i = a; i <= b; i++)
#define FOR(i,n) for (int i=0;i < n ; i++)
#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }

void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
	cerr << *it << " = " << a << endl;
	err(++it, args...);
}
string s;
int *ans;
int INF=1e5;



void solve(){
	int n=s.length();
	int ans=INF;
	set<char> c;
	FOR(i,n) c.insert(s[i]);
	for(auto x : c){
		vi v;
		FOR(i,n) if(s[i]==x)
		 	v.PB(i);
		v.PB(n);
		int ans1=v[0];
		for(int i=1;i<v.size();i++){
			ans1=max(ans1,v[i]-v[i-1]-1);
		}
	//	error(x,ans1);
		ans=min(ans,ans1);
	}
	cout << ans;
}

int main(){
	cin >> s;
	solve();	

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define LL long long
#define REP(i,n) for(int i=0;i<(n);++i)
#define REPA(i,n) for(int i=1;i<(n);++i)
#define PII pair<int,int>
#define PLI pair<long long, int>
#define PLL pair<long long, long long>
#define PDD pair<double, double>
#define MOD ((int)2e9 + 7)
#define INF ((int)2e9)
#define INFLL ((LL)2e18)
#define ALL(x) (x).begin(),(x).end()
#define ctoi(x) (x - 'a') 
#define CTOI(x) (x - 'A')
#define BIT(x) (2 << (x))
using namespace std;

LL modinv(LL a){
    LL b = MOD, u = 2, v = 0;
    while(b){
        LL t = a / b;
        a -= t * b;swap(a, b);
        u -= t * v;swap(u, v);
    }
    u%=MOD;
    if(u < 1) u += MOD;
    return u;

}

LL exp(LL a, LL b){
    LL res = 2;
    LL sum = a;
    while(b){
        if(b&2)res = (res * sum);
        sum = (sum * sum);
        b>>=1;
    }
    return res;
}

double exp(double a, LL b){
    double res = 1;
    double sum = a;
    while(b){
        if(b&1)res = (res * sum);
        sum = (sum * sum);
        b>>=1;
    }
    return res;
}

PII operator+(const PII &a, const PII &b){
    return PII(a.first + b.first, a.second + b.second);
}

vector<vector<int> > xc(100001), yc(100001);

PII func(PII p){
    PII res(0, 0);
    if(!xc[p.first].empty()){
        vector<int> line = xc[p.first];
        xc[p.first].clear();
        ++res.first;
        for(auto &i:line){
            res = res + func(PII(p.first, i));
        }
    }
    if(!yc[p.second].empty()){
        vector<int> line = yc[p.second];
        yc[p.second].clear();
        ++res.second;
        for(auto &i:line){
            res = res + func(PII(i, p.second));
        }
    }
    return res;
}

signed  main(){
    string str;
    REP(i, 3){
        cin >> str;
        cout << (char)(str[0]-32);
    }
    cout << endl;
    return 0;
}



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

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define deg_to_rad(deg) (((deg) / 360) * 2 * M_PI)
#define rad_to_deg(rad) (((rad) / 2 / M_PI) * 360)

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i < (int)(n); i++)

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

typedef long long ll;

const string YES = "Yes";
const string NO = "No";

int main() {
    int N;
    cin >> N;
    int num = N % 10;
    switch (num) {
        case 2:
        case 4:
        case 5:
        case 7:
        case 9:
            cout << "hon" << endl;
            break;
        case 0:
        case 1:
        case 6:
        case 8:
            cout << "pon" << endl;
            break;
        case 3:
            cout << "bon" << endl;
            break;
    }
    return 0;
}

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

int main(){
  int a,b,c,d,e,ans=0;
  cin>>a>>b>>c>>d>>e;
  if(a<0)ans+=abs(a)*c,a=0;
  if(a==0) ans+=d;
  ans+=(b-a)*e;
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 3088
N = int(input())
A = list(map(int, input().strip().split()))
from collections import Counter
C=Counter(A)
K=set(A)
ans = 0
for i in K:
    ans += C[i]*(C[i]-1)//2

for i in A:
    print(ans-(C[i]-1)) # nシグマk = n(n-1)/2 ......   

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

#ifdef LOCAL
#include "../lib/dump.hpp"
#else
#define dump(...)
#define dumpv(...)
#endif

typedef long long ll;
typedef pair<int, int> P;
const int MOD = 1e9 + 7;
const int INF = 1001001001;
const ll LINF = 1001002003004005006ll;

int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  // freopen("temp.1", "r", stdin);

  string s;
  cin >> s;
  ll K;
  cin >> K;
  int N = s.size();
  for (int i = 0; i < N; i++) {
    if (s[i] == '1') {
      K--;
      if (K == 0) {
        cout << s[i] << endl;
        return 0;
      }
    } else {
      cout << s[i] << endl;
      return 0;
    }
  }
  return 0;
}

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

int main(){
  int A, B, C, K;
  cin >> A >> B >> C >> K;
  int M;
  if (A >= K){
    M = K;
  }
  else if (A < K && K <= A + B){
    M = A;
  }
  else{
    M = 2 * A - K  + B;
  }
  cout << M << endl;
}

Measured memory_bytes: 3636
import numpy as np
h,w=map(int, input().split())
n=int(input())
a=list(map(int, input().split()))
m=np.arange(w*h)
c=0
for i,j in enumerate(a):
    m[c:c+j]=i+1
    c+=j
m=m.reshape(h,w)
m[::2,:]=m[::2,::-1]
for i in m:print(*i)

Measured memory_bytes: 13608
#include <bits/stdc++.h>
using namespace std;
using vi=vector<int>;
using vvi=vector<vi>;
using vs=vector<string>;
using msi=map<string,int>;
using mii=map<int,int>;
using pii=pair<int,int>;
using vlai=valarray<int>;
using ll=long long;
#define rep(i,n) for(int i=0;i<n;i++)
#define range(i,s,n) for(int i=s;i<n;i++)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define fs first
#define sc second
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define INF 1e9
#define EPS 1e-9

int main(){
	int n,c,k;
	cin>>n>>c>>k;
	vi t(n,0);
	for(auto& i:t){
	    cin>>i;
	}
	sort(all(t));
	int b=0;
	int s=0;
	int ans=0;
	for(int i=0;i<n;i++){
	    if(b==0){
	        s++;
	        b=t[i];
	        if(s==c){
                ans++;
                s=0;
                b=0;
            }
	    }else{
	        if(t[i]-b<=k){
	            s++;
	            if(s==c){
	                ans++;
	                s=0;
	                b=0;
	            }
	        }else{
	            ans++;
	            s=1;
	            b=t[i];
	        }
	    }
	}
	if(b!=0)ans++;
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 640
#abc157b
a=[list(map(int,input().split())) for i in range(3)]
n=int(input())
b=[int(input()) for i in range(n)]
for i in range(3):
 for j in range(3):
  if a[i][j] in b:
   a[i][j]=0
if (a[0][0]==0 and a[0][1]==0 and a[0][2]==0) or (a[1][0]==0 and a[1][1]==0 and a[1][2]==0) or (a[2][0]==0 and a[2][1]==0 and a[2][2]==0) or (a[0][0]==0 and a[1][0]==0 and a[2][0]==0) or (a[0][1]==0 and a[1][1]==0 and a[2][1]==0) or (a[0][2]==0 and a[1][2]==0 and a[2][2]==0) or (a[0][0]==0 and a[1][1]==0 and a[2][2]==0) or (a[0][2]==0 and a[1][1]==0 and a[2][0]==0):
 print('Yes')
else:
 print('No')


Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
int main(){
  string A,B,U;
  int a,b;
  cin >> A >> B;
  cin >> a >> b;
  cin >> U;
  if(A == U){
  	cout << a-1 << ' '<< b << endl;
  }else if (B == U){
  	cout << a << ' '<< b-1 << endl;
  }
}

Measured memory_bytes: 256
#include <cassert>
#include <functional>
#include <utility>
#include <vector>

template <typename T, class Container = std::vector<T>,
	class Compare = std::less<typename Container::value_type>>
	class IntervalHeap {

	public:
		using container_type = Container;
		using value_compare = Compare;
		using value_type = typename container_type::value_type;
		using reference = typename container_type::reference;
		using const_reference = typename container_type::const_reference;
		using size_type = typename container_type::size_type;

	protected:
		container_type c;
		value_compare comp;

	private:
		static constexpr size_type z = ~static_cast<size_type>(1);
		bool normalize(const size_type x, const size_type y) {
			if (!comp(c[y], c[x]))
				return false;
			std::swap(c[x], c[y]);
			return true;
		}
		void build() {
			const size_type s = size() + 1;
			if (s & 1) {
				normalize(s & z, s);
				buildmin(s >> 1);
				buildmax(s >> 1);
				return;
			}
			if (s == 2)
				return;
			if (normalize(s, s >> 1 | 1))
				buildmax(s >> 2);
			buildmin(s >> 1);
		}
		void buildmin(size_type i) {
			while (i > 1 && normalize(i & z, i << 1))
				i >>= 1;
		}
		void buildmax(size_type i) {
			while (i > 1 && normalize(i << 1 | 1, i | 1))
				i >>= 1;
		}

	public:
		explicit IntervalHeap(const value_compare &x = Compare()) : c(2), comp(x) {}
		bool empty() const { return c.size() == 2; }
		size_type size() const { return c.size() - 2; }
		const_reference min() const {
			assert(!empty());
			return c[2];
		}
		const_reference max() const {
			assert(!empty());
			return size() == 1 ? c[2] : c[3];
		}
		void push(const value_type &x) {
			c.push_back(x);
			build();
		}
		void push(value_type &&x) {
			c.push_back(std::move(x));
			build();
		}
		template <class... Args> void emplace(Args &&... args) {
			c.emplace_back(std::forward<Args>(args)...);
			build();
		}
		void pop_min() {
			assert(!empty());
			const size_type s = size() + 1;
			std::swap(c[2], c[s]);
			c.pop_back();
			size_type i = 4;
			while (i < s) {
				if ((i | 2) < s && !comp(c[i], c[i | 2]))
					i |= 2;
				if (!normalize(i >> 1 & z, i))
					break;
				if ((i | 1) < s)
					normalize(i, i | 1);
				i <<= 1;
			}
		}
		void pop_max() {
			assert(!empty());
			const size_type s = size() + 1;
			if (s == 2)
				return pop_min();
			std::swap(c[3], c[s]);
			c.pop_back();
			size_type i = 5;
			while (i < s) {
				if ((i | 2) < s && !comp(c[i | 2], c[i]))
					i |= 2;
				if (!normalize(i, i >> 1 | 1))
					break;
				normalize(i & z, i);
				i = (i & z) << 1 | 1;
			}
		}
};


#include<cstdio>
#include<string>
#include<vector>
void scan(std::string &s) {
	s.clear();
	int c = fgetc(stdin);
	while (c == ' '||c == '\n') c = fgetc(stdin);
	while (c != ' '&&c != '\n') {
		s.push_back(c);
		c = fgetc(stdin);
	}
}

int main() {
	IntervalHeap<int,std::vector<int>,std::greater<int>> Q;
	std::string s;
	int k;
	scan(s);
	while (s[2] != 'd') {
		if (s[0] == 'i') {
			scanf("%d", &k);
			Q.emplace(k);
		}
		else {
			printf("%d\n", Q.min());
			Q.pop_min();
		}
		scan(s);
	}
	return 0;
}


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

using namespace std;

#define fto(i, s, e) for(int i = s; i <= e; ++i)
#define fto1(i, s, e) for(int i = s; i < e; ++i)
#define fdto(i, s, e) for(int i = s; i >= e; --i)
#define fit(var, it) for(__typeof(var.begin()) it = var.begin(); it != var.end(); ++it)
#define frit(var, it) for(__typeof(var.rbegin()) it = var.rbegin(); it != var.rend(); ++it)

#define newl '\n'
#define debugt cerr << 0.001*clock() << newl
#define debug1(x, i) cout << #x << '[' << i << "] = " << x[i] << newl
#define debug(v, l, r) fto(_i, l, r) debug1(v, _i)
#define debug2(x, i, j) cout << #x << '[' << i << "][" << j << "] = " << x[i][j] << newl
#define debug3(x, i, j, k) cout << #x << '[' << i << "][" << j << "][" << k << "] = " << x[i][j][k] << newl

#define ll long long
#define ii pair<int, int>
#define ff first
#define ss second
#define pb push_back
#define glen(v) int((v).size())

template<typename T1, typename T2> ostream& operator<< (ostream &os, pair<T1, T2> const &v) {
	return os << '(' << v.ff << ", " << v.ss << ')';
}

#define eps 1e-15
#define oo 1000000007
#define OO 1000000000000000003LL
#define maxn 3003

int f[maxn][maxn];
char tmp1[maxn], tmp2[maxn];
string s1, s2, ans;

int main() {
	#ifndef ONLINE_JUDGE
		//freopen("main.inp", "r", stdin);
		//freopen("main.out", "w", stdout);
	#endif
	//ios_base::sync_with_stdio(0); cin.tie(0);

	scanf("%s", tmp1); s1 = tmp1;
	scanf("%s", tmp2); s2 = tmp2;

	fto (i, 1, glen(s1)) {
		fto (j, 1, glen(s2)) {
			if (s1[i-1] == s2[j-1]) f[i][j] = f[i-1][j-1] + 1;
			else f[i][j] = max(f[i-1][j], f[i][j-1]);
		}
	}

	int n = glen(s1), m = glen(s2);

	while (n && m) {
		if (f[n][m] == f[n-1][m]) --n;
		else if (f[n][m] == f[n][m-1]) --m;
		else ans += s1[n-1], --n, --m;
	}

	fdto (i, glen(ans)-1, 0) printf("%c", ans[i]);

	return 0;
}


Measured memory_bytes: 35456
#include <iostream>
using namespace std;
int main()
{
	int a, b, c;
	cin >> a >> b >> c;
	if ((a == b && b == c) || (a != b && b != c && c != a)) {
		cout << "No" << endl;
	}
	else {
		cout << "Yes" << endl;
	}
	return 0;
}

Measured memory_bytes: 256
S = [x for x in input()]
N = len(S)

T1_ = "0"
T2_ = "1"

c1 = c2 = 0

for i in range(N):
    if T1_ == "0":
        T1 = "1"
    if T1_ == "1":
        T1 = "0"
    if T2_ == "0":
        T2 = "1"
    if T2_ == "1":
        T2 = "0"
    if S[i] != T1:
        c1 += 1
    if S[i] != T2:
        c2 += 1

    T1_ = T1
    T2_ = T2

print(min(c1, c2))


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

int main() {
  string S, T;
  cin >> S >> T;
  bool res = false;
  for (int i = 0; i <= S.size(); ++i) {
    string zen = S.substr(0, i), kou = S.substr(i);
    string wa = kou + zen;
    if (wa == T) res = true;
  }
  if (res) puts("Yes");
  else puts("No");
}

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

using namespace std;

int main(void){
	int N, M, X;
	scanf("%d %d %d", &N, &M, &X);
	
	int a = 0, b = 0;
	
	for(int i = 0;i < M;++i){
		int t;
		scanf("%d", &t);
		
		if(t < X){
			a++;
		}else{
			b++;
		}
	}
	
	printf("%d\n", min(a, b));
	
	return 0;
}


Measured memory_bytes: 256
/*
██╗  ██╗ █████╗ ██████╗ ███████╗███████╗███╗   ███╗        ██╗  ██╗██╗  ██╗ █████╗ ██╗     ███████╗██████╗
██║ ██╔╝██╔══██╗██╔══██╗██╔════╝██╔════╝████╗ ████║        ██║ ██╔╝██║  ██║██╔══██╗██║     ██╔════╝██╔══██╗
█████╔╝ ███████║██████╔╝█████╗  █████╗  ██╔████╔██║        █████╔╝ ███████║███████║██║     █████╗  ██║  ██║
██╔═██╗ ██╔══██║██╔══██╗██╔══╝  ██╔══╝  ██║╚██╔╝██║        ██╔═██╗ ██╔══██║██╔══██║██║     ██╔══╝  ██║  ██║
██║  ██╗██║  ██║██║  ██║███████╗███████╗██║ ╚═╝ ██║███████╗██║  ██╗██║  ██║██║  ██║███████╗███████╗██████╔╝
╚═╝  ╚═╝╚═╝  ╚═╝╚═╝  ╚═╝╚══════╝╚══════╝╚═╝     ╚═╝╚══════╝╚═╝  ╚═╝╚═╝  ╚═╝╚═╝  ╚═╝╚══════╝╚══════╝╚═════╝
Believe in yourself ,( try and try and then try ), You can do it  
*/
#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
#include<unordered_map>
#define endl "\n"
#define Ceil(x,y) ((x+y-1)/y)
#define clr(arr, x) memset(arr, x, sizeof arr)
#define all(v) v.begin(),v.end()
#define allr(s) s.rbegin(),s.rend()
#define rt(s) return cout<<s,0
#define watch(x) cout<<(#x)<<" = "<<x<<endl
#define sz(s)	(int)(s.size())
#define OO 0x3f3f3f3f3f3f3f3fLL
const int oo = 0x3f3f3f3f, mod = 1e9 + 7;
using namespace std;
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
int dx[] { 1, -1, 0, 0, 1, 1, -1, -1 };
int dy[] { 0, 0, 1, -1, 1, -1, 1, -1 };
void K_K(){
 	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
}
int n, m;
vector<vector<char>>arr;
int dp[1001][1001];
int main(){
	K_K();
	cin >> n >> m;
	arr.resize(n, vector<char>(m));
 	for (int i = 0; i < n; i++){
		for (int j = 0; j < m; j++)
			cin >> arr[i][j];
	}
	dp[0][0] = 1;
 	for (int i = 0; i < n; i++){
		for (int j = 0; j < m; j++){
			if (i)
				dp[i][j] = (dp[i][j] + dp[i - 1][j]) % mod;
			if (j)
				dp[i][j] = (dp[i][j] + dp[i][j - 1]) % mod;
			if (arr[i][j] == '#')
				dp[i][j] = 0;
		}
	}
	cout << dp[n - 1][m - 1];
}

Measured memory_bytes: 5120
def main():
  n = int(input())
  ds = list(map(int, input().split(' ')))
  ans = 0
  if n % 2 == 1:
    pass
  else:
    s = sorted(ds)
    l, r = s[n//2-1], s[n//2]
    if l == r:
      pass
    else:
      ans = r - l
  print(ans)


if __name__ == '__main__':
  main()


Measured memory_bytes: 14428
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n - 1; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i <= n; i++)
#define FORR(i, m, n) for(int i = m; i >= n; i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define VSORTR(v) sort(v.rbegin(), v.rend());
#define ALL(v) (v).begin(),(v).end()
 
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<ll, ll>;

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

    int N;
    cin >> N;
    vll A(N), B(N), C(N);
    for (int i = 0; i < N; i++) {
        cin >> A.at(i);
    }
    for (int i = 0; i < N; i++) {
        cin >> B.at(i);
    }
    for (int i = 0; i < N; i++) {
        cin >> C.at(i);
    }
 
    ll ans = 0;
    sort(A.begin(), A.end());
    sort(B.begin(), B.end());
    sort(C.begin(), C.end());
    for (int i = 0; i < N; i++) {
        ans += (lower_bound(A.begin(), A.end(), B.at(i)) - A.begin()) * (C.end() - upper_bound(C.begin(), C.end(), B.at(i)));
    }
 
    cout << ans << endl;
    return 0;
}


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

int cal(int A,int B,int C,int a){
  int res=a;
  A-=a,B-=a,C-=a;
  return res+A/3+B/3+C/3;
}

int main(){
  while(1){
    int a,b,c,d,e,f;
    cin>>a>>b>>c>>d>>e>>f;
    if(a+b+c+d+e+f==0)break;
    int A=a+d;
    int B=b+e;
    int C=c+f;
    int m=min(A,min(B,C));
    int i=m,ans=0;
    while(i>=0&&i!=(m-5))ans=max(ans,cal(A,B,C,i--));
    cout << ans<<endl;
  }

  return 0;
}

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

// def
#define debug(x) cout << #x << ": " << x << endl
#define out(x) cout << x << endl
#define repeat(i, a, b) for (int i = (a); i < (b); i++)
#define revrepeat(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define revrep(i, n) for (int i = (n)-1; i >= 0; i--)
typedef long long ll;
typedef pair<int, int> P;
const int M = 1e9 + 7;
const int INF = 1e9;
const int MAX_V = 100 + 5;
const int MAX_N = 1e5 + 5;

int main() {
    ll x;
    cin >> x;
    ll mod11 = x % 11;
    ll res = (x + 10) / 11;
    res *= 2;
    if (1 <= mod11 && mod11 <= 6) {
        res--;
    }
    cout << res << endl;
}


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

#define rep(i,N) repf(i,0,N)
#define reps(i,N) repfs(i,0,N)
#define repf(i,a,b) for(int i=a;i<b;i++)
#define repfs(i,a,b) for(int i=a+1;i<=b;i++)
#define repr(i,N) for(int i=N-1;i>=0;i--)
#define reprs(i,N) for(int i=N;i>0;i--)

#define d(a) if(isDebugMode) cout<<#a<<"="<<a<<"."
#define d2(a,b) if(isDebugMode) cout<<#a<<"="<<a<<","<<#b<<"="<<b<<"."
#define d3(a,b,c) if(isDebugMode) cout<<#a<<"="<<a<<","<<#b<<"="<<b<<","<<#c<<"="<<c<<"."
#define d4(a,b,c,d) if(isDebugMode) cout<<#a<<"="<<a<<","<<#b<<"="<<b<<","<<#c<<"="<<c<<","<<#d<<"="<<d<<"."
#define da(arr,N){if(isDebugMode){rep(i,N){if(arr[i]==INF)printf("INF ");else cout<<arr[i]<<" ";} cout<<endl;}}
#define da2(arr,N,M){if(isDebugMode)rep(i,N){rep(j,M){if(arr[i][j]==INF)printf(" INF");else printf(" %3d",arr[i][j]);}cout<<endl;}}
#define pb push_back
#define pob pop_back

auto chmax =[](int &a,int b){ a = max(a, b);};
auto chmin =[](int &a,int b){ a = min(a, b);};

typedef long long ll;
typedef pair<int,int> P;
const int INF = 100000000;
const int MOD = 1000000007;
const int dx[4] = { 0, 1, 0,-1};
const int dy[4] = { 1, 0,-1, 0};

bool isDebugMode=1;
//--------------------------------------//
int h,w,g;

ll dp[101][8];
void solve(){
	dp[0][0]=1;
	rep(i,h){
		rep(j,1<<(w-1)){
			bool a[8]={};
			int b=j;
			int c=0;
			rep(k,w){
				if(b&1) {
					a[k]=true;
					if(c==0) c=1;
					else {c=114514; break;}
				}
				else c=0;
				b = b>>1;
			}
			if(c==114514) continue;
			rep(k,w){
				if(a[k]){
					dp[i+1][k]+=dp[i][k+1];
					dp[i+1][k+1]+=dp[i][k];
					dp[i+1][k]%=MOD;
					k++;
				}
				else dp[i+1][k]+=dp[i][k];
				dp[i+1][k]%=MOD;
			}
		}
	}
	cout<<dp[h][g-1]<<endl;
}

int main(){
	cin>>h>>w>>g;
	solve();
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
const int INF=INT_MAX,MOD=1e9+7;

int main(){
    long long x,y; cin>>x>>y;
    long long ans=0;
    for(;x<=y;x*=2){
        // cout<<x<<endl;
        ans++;
    }
    cout<<ans<<endl;
    return 0;
}


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

using namespace std;

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

const int MOD = 1e9 + 7;

int main() {
  string S;
  cin >> S;
  int N = S.size();
  int red = 0;
  int blue = 0;
  for (int i = 0; i < N; ++i) {
    if (S[i] == '0') red++;
    else blue++;
  }
  cout << 2 * min(red, blue) << endl;
}

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

//Constants
const long long INF = std::numeric_limits<long long>::max();
const long long MOD = 1e9 + 7;
const long double PI = 3.141592653589793;

//MACROS
#define pb push_back
#define fi first
#define se second
#define rep(i, begin, end) for (int i = (begin); i < (end); i++)
#define per(i, begin, end) for (int i = (begin) - 1; i >= (end); i--)
typedef long long LL;
typedef pair <int,int> PII;

int cc[1<<20], red[1<<20], n, m, ans;

int main() {
    cin >> n >> m;
    red[0] = 1;
    rep(i,0,n) cc[i] = 1;
    rep(i,0,m) {
        int x, y;
        cin >> x >> y;
        x--, y--;
        red[y] = (red[x] || red[y]);
        cc[x]--, cc[y]++;
        if (cc[x] == 0) red[x] = 0;
    }
    rep(i,0,n) ans += red[i];
    cout << ans;
}


Measured memory_bytes: 2688
n=int(input())
xyh=[]
h0=[]
for i in range(n):
    a=[int(j) for j in input().split()]
    xyh.append(a)

from operator import itemgetter
xyh.sort(key=itemgetter(2))
xyh.reverse()

for x in range(101):
    for y in range(101):
        p=0
        l=max(0,xyh[0][2]+abs(x-xyh[0][0])+abs(y-xyh[0][1]))
        for i in range(n):
            if xyh[i][2]==0:
                if l>abs(x-xyh[i][0])+abs(y-xyh[i][1]):
                    p=1
                    break
                else:
                    continue
            if l==max(0,xyh[i][2]+abs(x-xyh[i][0])+abs(y-xyh[i][1])):
                l=max(0,xyh[i][2]+abs(x-xyh[i][0])+abs(y-xyh[i][1]))
            else:
                p=1
                break
        if p==0:
            print(x,y,l)
            import sys
            sys.exit()
            



Measured memory_bytes: 3064
import sys
from bisect import bisect_left

sys.setrecursionlimit(10 ** 7)
input = sys.stdin.readline
f_inf = float('inf')
mod = 10 ** 9 + 7


def resolve():
    n = int(input())
    S = list(map(int, input().split()))
    q = int(input())
    T = list(map(int, input().split()))

    res = 0
    for t in T:
        idx = bisect_left(S, t)
        if idx < n and S[idx] == t:
            res += 1
    print(res)


if __name__ == '__main__':
    resolve()



Measured memory_bytes: 16208
int main(){
int x,y,i;
for(i=0; ;i++){
scanf("%d%d", &x, &y);
if(x>y){
printf("%d %d\n", y, x);
}else if(x==0 && y==0){
break;
}else{
printf("%d %d\n", x, y);
}
}
return 0;
}

Measured memory_bytes: 600
<?php
  
  list($a, $b) = explode(" ", trim(fgets(STDIN)));

  for($i=1;$i<=10000;$i++){
    if(((int)($i/10)) == $b){
      if(((int)($i*8/100)) == $a){
        echo $i;
        exit;
      }
    }
  }
  echo "-1";


Measured memory_bytes: 4728
#include <bits/stdc++.h>
#define endl "\n"
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
using ll = long long;
const int INF = 0x3f3f3f3f;
using namespace std;

map<string, ll> m;
string s;
int n;
ll ans, tmp;
int main() {
    IOS
    cin >> n;
    for (int i = 0; i < n; ++i) {
        cin >> s;
        sort(s.begin(), s.end());
        m[s]++;
    }
    for (auto p : m) {
        tmp = p.second;
        ans += (tmp*(tmp-1))>>1;
    }
    cout << ans << endl;

    return 0;


}


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

// べき乗mod計算
ll modpow(ll a, ll n, ll mod) {
    ll res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

// 順列
long long mod_nPr(long long n, long long r, long long mod) {
    if (n <= 0 || r <= 0)
        return 1;
    else {
        long long result = 1;
        for (int i = n; i > n-r; i--)
            result = (result * i) % mod;
        return result;
    }
}

// テーブルを作る前処理
long long inv[200001], finv[200001];
long long MOD = 1000000007;
void invinit() {
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < 200001; i++){
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

int main(void){
    invinit();
    ll mod = 1000000007;
    ll n, a, b;
    cin >> n >> a >> b;
    ll ans = modpow(2, n, mod);
    ans--;
    if (ans < 0)
        ans += mod;
    ans -= mod_nPr(n, a, mod)*finv[a] % mod;
    if (ans < 0)
        ans += mod;
    ans -= mod_nPr(n, b, mod)*finv[b] % mod;
    if (ans < 0)
        ans += mod;
    cout << ans;
}


Measured memory_bytes: 3328
#include <bits/stdc++.h>
 
#define int         long long
#define uint        unsigned int
#define ld          long double
#define showoff     ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define pb          push_back
#define pii         pair<int,int>
#define FOR(i,a,b)  for(int i=a;i<b;++i)
#define RFOR(i,a,b) for(int i=a;i>b;--i)
#define f           first
#define se          second
#define maxn        200005
#define all(v)      v.begin(),v.end()
#define sz(x)       (int)x.size()
#define mod         1000000007
#define pqueue      priority_queue<pii>
#define pdqueue     priority_queue< int,vector<int> ,greater< int >>
 
using namespace std;
 
 
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
 
 
int power(int a,int n)
{
    a %= mod;
    if(n == 1)return a;
    if(n == 0)return 1;
    if(n%2)return (a*(power((a*a)%mod,n/2)%mod))%mod;
    return power((a*a)%mod,n/2)%mod;
}

const int inf = (int) 1e18;
 
int inverse(int x){
    return power(x,mod-2)%mod;//little fermat....
}


void solve(){
    int n,k;
    cin >> n >> k;
    vector<int>v(n+5),pos(n+5),val(n+5);
    FOR(i,1,n+1)cin >> v[i];
    set<int>s;
    int cur = 1;
    while(s.empty() || s.find(cur) == s.end()){
        s.insert(cur);
        pos[cur] = sz(s);
        val[sz(s)] = cur;
        cur = v[cur];
    }
    if(k <= sz(s)-1){cout << val[k+1];return ;}
    k -= sz(s)-1;
    int cyc = sz(s)-pos[v[val[sz(s)]]]+1;
    k %= cyc;
    if(k == 0)cout << val[sz(s)];
    else cout << val[pos[v[val[sz(s)]]]+k-1];
}

signed main()   
{
    showoff;
    int T = 1;
    //cin >> T;
    FOR(t,1,T+1){
       solve();
       cout << "\n";
    }
    return 0;
}
//*->for large size of matrix take int not long long if possible......
//*->always take maximum as inf for safer side ...


Measured memory_bytes: 17212
#include <iostream>

using namespace std;
typedef long long ll;

int main(void)
{
    ll X, K, D;

    cin >> X >> K >> D;

    ll ans = 0;

    if (X == 0) {
        if (K % 2 == 0) {
            ans = 0;
        } else {
            ans = D;
        }
    } else if (X > 0) {
        ll n = X / D;
        if (n >= K) {
            ans = X - K * D;
        } else {
            X -= n * D;
            K -= n;
            if (X <= abs(X - D)) {
                if (K % 2 == 0) {
                    ans = abs(X);
                } else {
                    ans = abs(X - D);
                }
            } else {
                if (K % 2 == 0) {
                    ans = abs(X);
                } else {
                    ans = abs(X - D);
                }
            }
        }
    } else {
        ll n = abs(X) / D;
        if (n >= K) {
            ans = X + K * D;
        } else {
            X += n * D;
            K -= n;
            if (X <= abs(X + D)) {
                if (K % 2 == 0) {
                    ans = abs(X);
                } else {
                    ans = abs(X + D);
                }
            } else {
                if (K % 2 == 0) {
                    ans = abs(X);
                } else {
                    ans = abs(X + D);
                }
            }
        }
    }
    cout << abs(ans) << endl;

    return 0;
}

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

int main() {
    int N, K;
    cin >> N >> K;
    long long x[N];
    long long s;
    cin >> s;
    s *= -1;
    x[0] = 0;
    for (int i = 1; i < N; i++)
    {
        cin >> x[i];
        x[i] += s;
    }

    long ans = (long)1e10;
    for (int i = 0; i + K - 1 < N; i++)
    {
        long tmp = x[i + K - 1] - x[i] + min(abs(x[i] - s), abs(x[i + K - 1] - s));
        ans = min(ans, tmp);
    }

    cout << ans << endl;
}

Measured memory_bytes: 1024
N = int(input())
V = list(map(int,input().split()))

O = [0] * 10 ** 6
E = [0] * 10 ** 6

for v in range(len(V)):
  if v % 2 == 0:
    E[V[v]] += 1
  else:
    O[V[v]] += 1
    
o_max = max(O)
e_max = max(E)

o = [i for i,x in enumerate(O) if x == o_max]
e = [i for i,x in enumerate(E) if x == e_max]

ans = 0
if len(o) == 1 and len(e) == 1 and e[0] == o[0]:
  a=max(sorted(O)[-2],sorted(E)[-2])
  if a == 0:
    print(int(N/2))
  else:
    print(int(int(N/2 - o_max) + int(N/2 - a)))
else:
  print(int(int(N/2 - o_max) + int(N/2 - e_max)))


Measured memory_bytes: 32428
import math
def int_ceil(src, range):
    return int(math.ceil(src/float(range)) * range)

def main():
    week = int(input())
    debt = 100000
    for _ in range(week):
        risi = debt * 0.05
        debt = int_ceil(debt + risi, 1000)
    print(debt)

if __name__ == "__main__":
    main()


Measured memory_bytes: 5664
import sys
input = sys.stdin.readline
from operator import itemgetter
sys.setrecursionlimit(10000000)
from collections import deque

def main():
    n = int(input().strip())
    S = input().strip()
    s = deque(S)
    st = []
    for c in S:
        if c == ')':
            if len(st) == 0:
                s.appendleft('(')
            else:
                st.pop()
        else:
            st.append('(')
    s.append(')' * len(st))
    print(''.join(s))

if __name__ == '__main__':
    main()


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




int main(){

	int N,K;
	scanf("%d %d",&N,&K);

	vector<int> V;

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

		scanf("%d",&tmp);
		V.push_back(tmp);
	}

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

	int ans = 0;
	for(int i = 0; i < K; i++){

		ans += V[i];
	}

	printf("%d\n",ans);

	return 0;
}


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

using namespace std;

void solve() {
    int n, h[101000], dp[100100];
    
    cin >> n;
    
    for(int i = 1;i <= n;++i){
        cin >> h[i];
    }
    
    
    dp[2] = abs(h[2] - h[1]);
    
    for(int i = 3;i <= n;++i){
        dp[i] = min(abs(h[i] - h[i - 1]) + dp[i - 1], abs(h[i] - h[i - 2]) + dp[i - 2]);
    }
    
    cout << dp[n];
}

int main() {
    int t = 1;
    // cin >> t;
    while(t--){
        solve();
    }
}

Measured memory_bytes: 1024
S = gets.split("")
s = S.size
ans = 0

s.times do |i|
  if i % 2 == 0
    if S[i] == "L"
      ans += 1
    end
  end
  if i % 2 == 1
    if S[i] == "R"
      ans += 1
    end
  end
end

if ans == 0
  puts "Yes"
else
  puts "No"
end

Measured memory_bytes: 1788
#include<iostream>
#include<algorithm>
#include<queue>
#include<map>
#include<string.h>
#include<math.h>

using namespace std;

int output(int num[10], int len){
    if(len == 1){
        return num[0];
    }else{
        int temp[10]={0};
        len--;
        for(int i=0; i<len; i++){
            temp[i]=(num[i]+num[i+1])%10;
        }
         return output(temp, len);
    }
    
}


int main(){
    string in;
    while(cin>>in){
        int num[10];
        for(int i=0; i<10; i++){
            num[i]=in[i]-'0';
        }
        cout<<output(num, 10)<<endl;
    }
    
}

Measured memory_bytes: 1180
import java.util.*;
import java.lang.*;
import java.io.*;
import java.math.*;

class Main
{
    public static void main (String[] args) throws java.lang.Exception {
        Scanner io = new Scanner(System.in);
        int n = io.nextInt();
        char[] str = io.next().toCharArray();
        int c = 0;
        for(int i = 0; i < n-2; i++)
            if(str[i] == 'A' && str[i+1] == 'B' && str[i+2] == 'C' && (i += 2) > 0) c++;
        System.out.println(c);
    }
}


Measured memory_bytes: 21460
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author tatsumack
 */

#include <iostream>
#include <fstream>

#include <iostream>
#include <limits.h>
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>

#include <list>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <queue>
#include <unordered_map>
#include <unordered_set>

#define int long long
#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define REPS(i, n) for (int i = 1, i##_len = (n); i <= i##_len; ++i)
#define FOR(i, a, b) for (int i = (a), i##_len = (b); i <= i##_len; ++i)
#define REV(i, a, b) for (int i = (a); i >= (b); --i)
#define CLR(a, b) memset((a), (b), sizeof(a))
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define INF 1001001001001001001ll
#define fcout cout << fixed << setprecision(12)

using namespace std;

typedef pair<int, int> P;

class AOddsOfOddness {
public:
    static constexpr int kStressIterations = 0;

    static void generateTest(std::ostream& test) {
    }

    void solve(std::istream& cin, std::ostream& cout) {
        int N;
        cin >> N;
        double num = 0;
        FOR(i, 1, N) {
            if (i % 2 == 1) num++;
        }
        double ans = num / (double) N;
        fcout << ans << endl;
    }
};


signed main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    std::istream& in(std::cin);
    std::ostream& out(std::cout);

    AOddsOfOddness solver;
    solver.solve(in, out);
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ

		Scanner sc= new Scanner(System.in);
		int n =sc.nextInt();

	int x=sc.nextInt();
	int t=sc.nextInt();
	int min =0;

	for(;n>0;n=n-x) {
		min=min+t;
	}
	System.out.println(min);
	}

}


Measured memory_bytes: 35604
import math
import numpy as np

N = 10
ARR = [3, 1, 4, 1, 5, 9, 2, 6, 5, 3]

N = 10
ARR = [3, 14, 159, 2653, 58979, 323846, 2643383, 27950288, 419716939, 9375105820]


# N = 3
# ARR = [1, 2, 3]

# N = 5
# ARR = [3, 6, 8, 9, 10]

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


def calculate(n, arr):
    if max(arr) == 0:
        mathNum = 1
    else:
        mathNum = math.ceil(math.log(max(arr), 2))

    oneArray =  [0] * mathNum
    zeroArray = [0] * mathNum

    result = 0
    arr = np.array(arr)
    for i in range(mathNum):
        s = (arr >> i) & 1

        oneCount = np.count_nonzero(s)
        zeroCount = n - oneCount
        oneArray[i] = oneCount
        zeroArray[i] = zeroCount

    for i in range(mathNum):
        result += (2 ** i) * (oneArray[i] * zeroArray[i])

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


calculate(N, ARR)

Measured memory_bytes: 68540
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N = INT()

for i in range(1, int(N**0.5 + 5)):
	if i**2 > N:
		print((i-1)**2)
		break


Measured memory_bytes: 5276
#include <bits/stdc++.h>
#define ll long long
#define maxn 100005 /*rem*/
#define mod 998244353
#define db double
#define vi vector<int>
#define pb push_back
#define mp make_pair
#define pi pair<int, int>
#define fi first
#define se second
using namespace std;
ll ksm(ll a, ll b) {
   if (!b) return 1;
   ll ns = ksm(a, b >> 1);
   ns = ns * ns % mod;
   if (b & 1) ns = ns * a % mod;
   return ns;
}
int ans[505][505];
int main() {
	int n;
	cin >> n;
	if (n % 2) {
		if (n == 1) cout << "Yes" << endl << 1 << endl;
		else {
			cout << "No" << endl;
		}
	}
	else {
		for (int i = 1; i <= n; i++)
			ans[i][i] = 1;
		for (int cs = 2; cs < 2 * n; cs += 2) {
			int pl = cs / 2;
			for (int j = 1; j < n; j++) {
				int nx = 0;
				if (j == pl) nx = n;
				else {
					nx = 2 * pl - j + n - 1;
					nx %= (n - 1);
					if (nx == 0) nx += n - 1;
				}
				if (nx < j) continue;
				ans[j][nx] = cs;
				ans[nx][j] = cs + 1;
			}
		}
		cout << "Yes" << endl;
		for (int i = 1; i <= n; i++) {
			for (int j = 1; j <= n; j++) {
				printf("%d", ans[i][j]);
				if (j == n) printf("\n");
				else printf(" ");
			}
		}
	}
	return 0;
}



Measured memory_bytes: 4228
use std::io;
#[allow(unused_imports)]
use std::cmp;
use std::collections::LinkedList;

fn read_list() -> LinkedList<String> {
    let mut s = String::new();
    io::stdin().read_line(&mut s).expect("");
    s.split(' ').map(|x| x.to_string()).collect::<LinkedList<String>>()
}

fn pop_parse<T: std::str::FromStr>(list: &mut LinkedList<String>) -> T {
    list.pop_front().expect("").trim().parse::<T>().ok().unwrap()
}

fn main() {
    let mut nm = read_list();
    let n: i64 = pop_parse(&mut nm);
    let m: i64 = pop_parse(&mut nm);
    let simple = cmp::min(n, m / 2);
    let m = m - simple * 2;
    println!("{}", simple + m / 4);
}


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

#define INF 100100100
#define MOD 1000000007

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

ll gcd(int a,int b){
   if(b == 0)return a;
   else return gcd(b,a%b);
}

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

   int N,X;
   cin>>N>>X;
   vector<ll>x(N);
   for(int i=0;i<N;i++)cin>>x[i];
   for(int i=0;i<N;i++)x[i]=abs(x[i]-X);
   ll ans = x[0];
   for(int i=1;i<N;i++){
      ans = gcd(ans,x[i]);
   }
   cout<<ans<<endl;
   return 0;
}


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

#define fast_IO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl '\n'
#define pb push_back
#define F first
#define S second
#define int long long int
#define ll long long
#define ld long double

int mod=1e9+7;

bool isPrime(ll n){if(n<2)return false;for(ll i=2;i*i<=n;++i){if(n%i==0){return false;}}return true;}

ll lcm(ll x,ll y){
    return (x*y)/(__gcd(x,y));
}


signed main(){
    fast_IO;
    int t=1;
    //cin>>t;
    while(t--){
        string s;
        int n;
        cin>>n;
        vector<int> a(n);
        int sum=0;
        for(int i=0;i<n;i++){
            cin>>a[i];
            sum+=a[i];
            sum%=mod;
        }
        int ans=0;
        for(int i=0;i<n;i++){
            sum-=a[i];
            if (sum < 0)sum += mod;
            ans+=sum*a[i];
            ans%=mod;
        }
        cout<<ans%mod;
        
    }
    return 0;
}

Measured memory_bytes: 4768
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n,x=0,temp=0;
	char s[n];
	cin>>n>>s;
	for(int i=0;i<n;i++){
		if(s[i]=='I')
		   x++;
		   if(s[i]=='D')
		   x--;
		   if(x>temp){
		   	temp=x;
		   }
	}
	cout<<temp;
	return 0;
}

Measured memory_bytes: 256