akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
const lint INF = 1e18;
#define rep(i, n) for(int i = 0; i < int(n); i++)

signed main(){
	int n, d; cin >> n >> d;
	int ans = n / (2 * d + 1);
	if(n % (2 * d + 1) != 0) ans++;
	cout << ans << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
int main()
{
	int n, i, j;
	char s;
	

	int a[4][13] = { 0 };
	
	scanf("%d\n",&n);
	
	while(n--){
		scanf("%c %d\n", &s,&j);
		
		if(s=='S')i=0;
		else if(s=='H')i=1;
		else if(s=='C')i=2;
		else i=3;
		
		a[i][j-1]=1;
	}
	
	for(i=0;i<4;i++){
		for(j=0;j<13;j++){
			if(a[i][j]==0){
				if(i==0)s='S';
				else if(i==1)s='H';
				else if(i==2)s='C';
				else s='D';
				printf("%c %d\n",s ,j+1);
			}
		}
	}
	return 0;
}


Measured memory_bytes: 2104
#include <stdio.h>

#define   i_MAXNUMBER    ( ( int )( 9 ) )

int main( void )
{
	int   i, j;

	for ( i = 1; i <= i_MAXNUMBER; i++ )
	{
		for ( j = 1; j <= i_MAXNUMBER; j++ )
		{
			printf("%dx%d=%d\n", i, j, ( i * j ) );
		}
		

	}



	return 0;

}

Measured memory_bytes: 1804
#include<bits/stdc++.h>
using namespace std;
int a[400005];
int main()
{
	int n;
	cin>>n;
	int k=1,j=0;
	for(int i=0;i<n;i++)
	{
		cin>>a[i];
		if(a[i]==k)k++,j++;
	}
	if(n-j==n)cout<<-1;
	else cout<<n-j;
	return 0;
}


Measured memory_bytes: 1024
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx")
#pragma GCC optimize("unroll-loops")
//#pragma warning(disable : 4996)




#ifdef _MSC_VER
#include <intrin.h>

#define __builtin_popcount __popcnt
#define __builtin_popcountll __popcnt64
#endif

#include <limits.h>
#include <math.h>
#include <time.h>

#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <complex>
#include <cstdio>
#include <cstring>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>



using namespace std;
//using namespace atcoder;

#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 - 1; i >= n; --i)
#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define REVERSE(v, n) reverse(v, v + n);
#define VREVERSE(v) reverse(v.begin(), v.end())
#define ll long long
#define print(x) cout << (x) << endl
#define pe(x) cout << (x) << " "
#define DEBUG(x) cout << #x << ": " << x << endl
#define lb(v, n) lower_bound(v.begin(), v.end(), (n))
#define ub(v, n) upper_bound(v.begin(), v.end(), (n))
#define int long long
//#define double long double
#define all(x) (x).begin(), (x).end()
#define print_space(v) REP(i, v.size()) cout << v[i] << " \n"[i==(int)v.size()-1]
template <typename T1, typename T2> inline void chmin(T1& a, T2 b) { if (a > b) a = b; }
template <typename T1, typename T2> inline void chmax(T1& a, T2 b) { if (a < b) a = b; }
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;
std::random_device rd;
std::mt19937 mt(rd());
constexpr ll MOD = 1e9 + 7;
constexpr int MAX = 500050;
const double pi = acos(-1);
constexpr double EPS = 1e-8;
constexpr ll LINF = 1e18 + 1;
constexpr int INF = 1e9 + 1;
void Yes(bool cond) { cout << (cond ? "Yes" : "No") << '\n'; }
void YES(bool cond) { cout << (cond ? "YES" : "NO") << '\n'; }

int ca[200020], cb[200020];
using arr4 = array<int, 4>;
vector<int>pos[200020];
void solve() {
	int N; cin >> N;
	vector<int>A(N), B(N);
	REP(i, N)cin >> A[i];
	REP(i, N)cin >> B[i];
	VREVERSE(B);
	int l = 0, r = N - 1;
	REP(i, N) {
		if (A[i] == B[i]) {
			if (l < N&&B[l] != A[i]&&A[l]!=B[i]) {
				swap(B[l++], B[i]);
			}
			else if (r >= 0 && B[r] != A[i]&&A[r]!=B[i]) {
				swap(B[r--], B[i]);
			}
			else {
				print("No"); return;
			}
		}
	}
	print("Yes");
	print_space(B);
}



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

	//int q;
	//cin >> q;
	//while (q--)
	solve();

}



Measured memory_bytes: 11116
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<cstring>
#include<vector>
#include<cmath>
#include<queue>
#include<map>
#include<set>
#define ri register int
#define max maxx
#define min minn
using namespace std;
template <class T> void in(T &x) {
	x = 0;
	bool f = 0;
	char c = getchar();
	while (c < '0' || c > '9') {
		if (c == '-') f = 1;
		c = getchar();
	}
	while ('0' <= c && c <= '9') {
		x = (x << 3) + (x << 1) + (c ^ 48);
		c = getchar();
	}
	if (f) x = -x;
}
inline int maxx(int x,int y) {
	return x>y?x:y;
}
inline int minn(int x,int y) {
	return x<y?x:y;
}
inline int gcd(int x,int y) {
	return !y?x:gcd(y,x%y);
}
int n,m,flag;
char a[120][120];
int mapp[120][120];
int sum1[120],sum2[120];
int vis[120][120];
int main() {
	in(n),in(m);
	for(ri i=1; i<=n; ++i) {
		scanf("%s",a[i]);
		for(ri j=0; j<m; ++j) {
			if(a[i][j]=='.')
				mapp[i][j+1]=1;
		}
	}

	/*for(ri i=1; i<=n; ++i) {
		for(ri j=1; j<=m; ++j)
			printf("%d ",mapp[i][j]);
		puts(" ");
	}*/

	for(ri i=1; i<=n; ++i)
		for(ri j=1; j<=m; ++j)
			sum1[i]+=mapp[i][j];
	for(ri i=1; i<=n; ++i)
		for(ri j=1; j<=m; ++j)
			sum2[j]+=mapp[i][j];
	/*for(ri i=1; i<=n; ++i)
		printf("%d ",sum1[i]);
	puts(" ");
	for(ri j=1; j<=m; ++j)
		printf("%d ",sum2[j]);*/
	for(ri i=1; i<=n; ++i)
		if(sum1[i]==m)
			for(int j=1; j<=m; ++j)
				vis[i][j]=1;
	for(ri j=1; j<=m; ++j)
		if(sum2[j]==n)
			for(ri i=1; i<=n; i++)
				vis[i][j]=1;
	for(ri i=1; i<=n; ++i) {
		flag=0;
		for(ri j=1; j<=m; ++j)
			if(!vis[i][j]) {
				flag=1;
				cout<<a[i][j-1];
			}
		if(flag)
			puts(" ");
	}
	return 0;
}


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

int main()
{
    ll k;
    cin >> k;
    queue<ll> que;
    for (int i = 1; i< 10; i++) que.push(i);

    ll cnt = 0;
    while (true) {
        ll x = que.front(); que.pop();
        cnt ++;
        if (cnt == k) {
            cout << x << endl;
            return 0;
        }

        int r = x%10;
        if (r == 0) {
            que.push(x*10);
            que.push(x*10+1);
        } else if (r == 9) {
            que.push(x*10 + 8);
            que.push(x*10 + 9);
        } else {
            que.push(x*10 + r-1);
            que.push(x*10 + r);
            que.push(x*10 + r+1);
        }
        
    } 
    return 0;
}

Measured memory_bytes: 1792
#include<iostream>
#include<cmath>
#include<algorithm>
#include<climits>

using namespace std;

int main(){
        int n;
        cin >> n;
        long long* a = new long long[n];
        bool plus = false , minus = false;
        long long sum = 0;
        for(int i=0;i<n;i++){
                cin >> a[i];
                if(a[i] > 0)
                        plus = true;
                else if(a[i] < 0){
                        minus = true;
                }
                sum += abs(a[i]);
        }

        sort(a, a+n);

        if(!plus && !minus)
        {
                cout << 0 << endl;
                for(int i=0;i<n-1;i++){
                        cout << 0 << " " << 0 << endl;
                }
        }
        else if(plus && minus)
        {
                cout << sum << endl;
                // minus;
                int i = 1;
                for(;i<n-1 && a[i] < 0;i++){
                        cout << a[n-1] << " " << a[i] << endl;
                        a[n-1] -= a[i];
                }

                for(;i<n-1;i++){
                        cout << a[0] << " " << a[i] << endl;
                        a[0] -= a[i];
                }

                cout << a[n-1] << " " << a[0] << endl;
        }else if(plus){
                cout << sum - 2 * a[0] << endl;
                for(int i = 1; i< n-1;i++){
                        cout << a[0] << " " << a[i] << endl;
                        a[0] -= a[i];
                }

                cout << a[n-1] << " " << a[0] << endl;
        }else{
                cout << sum + 2 * a[n-1] << endl;
                for(int i=0;i<n-1;i++){
                        cout << a[n-1] << " " << a[i] << endl;
                        a[n-1] -= a[i];
                }
        }
}

Measured memory_bytes: 2688
#include <bits/stdc++.h>
using namespace std;
int main() {
	int n, a, b;
	string str;
	cin >> n >> a >> b;
	cin >> str;

	int count_a = 0, count_b = 0, count_c = 0;;
	for(int i = 0; i < n; i++) {
		if(str[i] == 'a') {
			if(count_a + count_b < a + b) {
				cout << "Yes" << endl;
				count_a++;
			} else {
				cout << "No" << endl;
			}
		} else if(str[i] == 'b') {
			if((count_a + count_b < a + b)&&(count_b < b)) {
				cout << "Yes" << endl;
				count_b++;
			} else {
				cout << "No" <<endl;
			}
		} else {
			cout << "No" << endl;
			count_c++;
		}
	}

	return 0;
}

Measured memory_bytes: 896
x, k, d = map(int, input().split())
neg = (x < 0)
x = abs(x)
if x // d > k: ans = (x - k * d)
else:
    if (x // d) % 2 == k % 2: ans = x - x // d * d
    else: ans = x - x // d * d - d
print(abs(ans))

Measured memory_bytes: 9184
#include<iostream>
#include<string.h>
using namespace std;
int main(void){
    long n,root[100][21],k;
    memset(root,0,sizeof(root));
    long cnt,ans,t,h;
    cin>>n;
    cin>>k;
    root[0][k]++;
    for(int i=1;i<n-1;i++){
        cin>>k;
        for(int o=0;o<=20;o++){
            if(root[i-1][o]!=0){
                t=o+k;
                h=o-k;
                if(t<=20&&t>=0){
                    root[i][t]+=root[i-1][o];
                }
                if(h<=20&&h>=0){
                    root[i][h]+=root[i-1][o];
                }
            }
        }
    }
    ans=0;
    cin>>k;
    cout<<root[n-2][k]<<endl;
}

Measured memory_bytes: 3124
#include <iostream>
#include <cstdio>
#include <cstring>
using namespace std;

const int maxn = 100010;

char str[maxn], cur[maxn];
int len;
int l[maxn];

void init()
{
	memset(l,0,sizeof(l));
	int cnt = 0;
	for (int i=0;i<=len;i++)
	{
		if (str[i] == '0' || i == len)
		{
			for (int j=i-cnt;j<=i-1;j++) l[j] = cnt;
			cnt = 0;
			continue;
		}
		cnt++;
	}
	//for (int i=0;i<len;i++) cout<<l[i]<<" ";
	//cout<<endl;
}

bool check(int k)
{
	for (int i=0;i<len;i++)
	{
		if (str[i] == '0') continue;
		if (i >= k || len-1-i>=k) continue;
		if (l[i] >= k) continue;
		return false;
	}
	return true;
}

int main()
{
	//freopen("D.in","r",stdin);
	scanf("%s",str);


	len = strlen(str);
	init();
	int lb = 1, ub = len + 1;
	while (ub > lb + 1)
	{
		int mid = (lb + ub)/2;
		if (check(mid)) lb = mid;
		else ub = mid;
	}

	for (int i=0;i<len;i++) str[i] = (str[i]=='1')?'0':'1';
	init();
	int lb2 = 1, ub2 = len + 1;
	while (ub2 > lb2 + 1)
	{
		int mid = (lb2 + ub2)/2;
		if (check(mid)) lb2 = mid;
		else ub2 = mid;
	}

	printf("%d\n",max(lb,lb2));
	return 0;
}


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

int main(){
    int n;
    string s,t;
    cin>>n>>s>>t;
    int ans=INF;
    for(int i=0;i<=n;i++){
        string ss=s.substr(n-i,i);
        string tt=t.substr(0,i);
        if(ss==tt){
            ans=min(ans,n*2-i);
        }
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 3596
#include <iostream>
#include <sstream>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <deque>
#include <stack>
#include <iomanip>
#include <cmath>


using namespace std;


typedef long long ll;
typedef long double ld;


const ll MOD = 1000000007ll;


ll modSum(ll a, ll b) {
  return ((a % MOD) + (b % MOD)) % MOD;
}


ll modSubtract(ll a, ll b) {
  return (((a % MOD) - (b % MOD)) + MOD + MOD) % MOD;
}


ll modProd(ll a, ll b) {
  return ((a % MOD) * (b % MOD)) % MOD;
}


ll getPowMod(ll x, ll e) {
  if (e == 0) return 1;
  if (e % 2 == 0) {
    ll tmp = getPowMod(x, e/2);
    return modProd(tmp, tmp);
  } else {
    ll tmp = getPowMod(x, e-1);
    return modProd(tmp, x);
  }
}


ll getPow(ll x, ll e) {
  if (e == 0) return 1;
  if (e % 2 == 0) {
    ll tmp = getPow(x, e/2);
    return tmp * tmp;
  } else {
    ll tmp = getPow(x, e-1);
    return tmp * x;
  }
}


ll getInverse(ll x) {
  return getPowMod(x, MOD-2);
}


bool isEven(ll x) {
  ll tmp = ((x % 2) + 2) % 2;
  return tmp == 0;
}


ll getSumOfDigitsInBase(ll n, ll b) {
  ll ret = 0;
  while (n > 0) {
    ret += n % b;
    n /= b;
  }
  return ret;
}


vector<int> getKMP(string &s) {
  int len = (int)s.size();
  vector<int> ret (len, 0);
  for (int i = 1 ; i < len ; i++) {
    int at = ret[i-1];
    while (at > 0 && s[i] != s[at]) {
      at = ret[at-1];
    }
    if (s[i] == s[at]) {
      at++;
    }
    ret[i] = at;
  }
  return ret;
}


string getSubstring(string &s, int from, int to) {
  int l = to-from+1;
  if (l <= 0) {
    return "";
  }
  return s.substr(from, l);
}

ll gcd(ll a, ll b, ll & x, ll & y) {
    if (a == 0) {
        x = 0;
        y = 1;
        return b;
    }
    ll x1, y1;
    ll d = gcd(b % a, a, x1, y1);
    x = y1 - (b / a) * x1;
    y = x1;
    return d;
}












const int MAXN = 1001;


int N;
ll t[MAXN], a[MAXN];


void input() {
  cin >> N;
  for (int i = 1 ; i <= N ; i++) {
    cin >> t[i] >> a[i];
  }
}


void preprocess() {
}


void solve() {
  ll num = t[1], den = a[1];
  for (int i = 2 ; i <= N ; i++) {
    ll mul = max((num-1)/t[i] + 1, (den-1)/a[i] + 1);
    num = t[i] * mul;
    den = a[i] * mul;
  }
  cout << num+den << "\n";
}


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

  int T;
//  cin >> T;
  T = 1;

  for (int i = 0 ; i < T ; i++) {
    input();
    preprocess();
    solve();
  }

  return 0;
}

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

using namespace std;

class UnionFind {
public:
  UnionFind(long long n);
  long long size(long long n);
  bool merge(long long a, long long b);
  long long root(long long a);
  bool isSame(long long a, long long b);

private:
  long long N;
  vector<long long> parentArr;
  vector<long long> sizeArr;
  vector<long long> rankArr;
};

UnionFind::UnionFind(long long n) {
  N = n;
  parentArr.resize(n);
  sizeArr.resize(n);
  rankArr.resize(n);

  for (long long i = 0; i < n; i++) {
    parentArr[i] = i;
    sizeArr[i] = 1;
    rankArr[i] = 0;
  }
}

long long UnionFind::size(long long a) { return sizeArr[root(a)]; }

bool UnionFind::merge(long long a, long long b) {
  long long root_a = root(a);
  long long root_b = root(b);

  if (root_a == root_b) {
    return false;
  }

  if (rankArr[root_a] < rankArr[root_b]) {
    parentArr[root_a] = root_b;
    sizeArr[root_b] += sizeArr[root_a];
  } else {
    parentArr[root_b] = root_a;
    sizeArr[root_a] += sizeArr[root_b];
    if (rankArr[root_a] == rankArr[root_b]) {
      rankArr[root_a]++;
    }
  }
  return true;
}

long long UnionFind::root(long long a) {
  long long tmp = a;
  while (tmp != parentArr[tmp]) {
    tmp = parentArr[tmp];
  }
  return parentArr[a] = tmp;
}

bool UnionFind::isSame(long long a, long long b) { return root(a) == root(b); }

int main(int argc, char const *argv[]) {
  long long N, M;
  cin >> N >> M;

  UnionFind uf(N + 1);

  vector<pair<long long, long long>> bridge(M + 1);
  vector<long> ans(M + 1);
  ans[M] = N * (N - 1) / 2;

  for (long long i = 1; i < M + 1; i++) {
    cin >> bridge[i].first >> bridge[i].second;
  }

  for (long long i = M - 1; i >= 1; i--) {
    long long a = bridge[i + 1].first;
    long long b = bridge[i + 1].second;

    if (uf.isSame(a, b)) {
      ans[i] = ans[i + 1];
    } else {
      ans[i] = ans[i + 1] - uf.size(a) * uf.size(b);
      uf.merge(a, b);
    }
  }

  for (long long i = 1; i < M + 1; i++) {
    cout << ans[i] << "\n";
  }
  return 0;
}


Measured memory_bytes: 6016
#include <iostream>
using namespace std;
long long k, n=50, a;
int main() {
	cin>>k;
	cout<<n<<endl;
	a = k/n - k%n + n-1;
	for(int i=0; i<n; i++) cout<<(i<k%n ? a+n+1 : a)<<' ';
	return 0;
}

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

using namespace std;

template<class T, class U>
void ckmin(T &a, U b)
{
    if (a > b) a = b;
}

template<class T, class U>
void ckmax(T &a, U b)
{
    if (a < b) a = b;
}

#define MP make_pair
#define PB push_back
#define LB lower_bound
#define UB upper_bound
#define fi first
#define se second
#define SZ(x) ((int) (x).size())
#define ALL(x) (x).begin(), (x).end()
#define FOR(i, a, b) for (auto i = (a); i < (b); i++)
#define FORD(i, a, b) for (auto i = (a) - 1; i >= (b); i--)
#define MAXN 300013

typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<pii> vpi;
typedef vector<pll> vpl;

int K, N;
vector<array<int, 3> > ans;

int32_t main()
{
    cout << fixed << setprecision(12);
    cerr << fixed << setprecision(4);
    ios_base::sync_with_stdio(false); cin.tie(0);
    cin >> N >> K;
    if (2 * K > N + 1)
    {
        cout << "-1\n";
        return 0;
    }
    if (N & 1)
    {
        int k = (N + 1) / 2;
        int lo = k + 2 * N, hi = k + 3 * N - 1;
        FOR(i, 0, N / 2)
        {
            ans.PB({k + (N / 2) - 1 - i, 0, lo + i});
            ans.back()[1] = ans.back()[2] - ans.back()[0];
        }
        FOR(i, N / 2, N)
        {
            ans.PB({k + i, 0, hi - (i - (N / 2))});
            ans.back()[1] = ans.back()[2] - ans.back()[0];
        }
        // for (auto a : ans)
        // {
        //     cout << a[0] << ' ' << a[1] << ' ' << a[2] << endl;
        // }
        // return 0;
    }
    else
    {
        FOR(i, 0, N / 2)
        {
            ans.PB({N / 2 + i, 0, 3 * N - 1 - i});
            ans.back()[1] = ans.back()[2] - ans.back()[0];
        }
        FOR(i, N / 2, N)
        {
            ans.PB({N / 2 + i, 0, 7 * N / 2 - (i - N / 2) - 1});
            ans.back()[1] = ans.back()[2] - ans.back()[0] - 1;
        }
        // for (auto a : ans)
        // {
        //     cout << a[0] << ' ' << a[1] << ' ' << a[2] << endl;
        // }
        // return 0;
    }
    //for a fixed N, the max K gets smaller?
    //else take K = (N + 1) / 2
    FOR(i, 0, SZ(ans))
    {
        FOR(j, 0, 3)
        {
            ans[i][j] -= ((N + 1) / 2 - K);
        }
        cout << ans[i][0] << ' ' << ans[i][1] << ' ' << ans[i][2] << '\n';
    }
    return 0;
}


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

int main() {
  int N,K;
  cin >> N >> K;
  int num = 1;

  for (int i = 0; i < N; i++) {
    if (num * 2 >= num + K ) {
      num = num + K;
    }
    else {
      num = num * 2;
    }
  }
  
  cout << num << endl;
}



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

typedef long long ll; 

int main(){
        string s; cin>>s; 
        for(int i=0;i<s.size()-1;i++){
                if(s[i]==s[i+1]) { cout<<i+1<<" " <<i+2; return 0; }
        }
        for(int i=0;i<s.size()-2;i++){
                if(s[i]==s[i+2]){ cout<<i+1<<" " <<i+3; return 0; }
        }
        cout<<-1<<" " <<-1; 
	return 0; 
}



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

int a[200000];

int main(){
  int n;
  cin >> n;
  if(n%2==1){
    cin >> a[n/2];
    for(int i=1; i<n; i++){
      if(i%2==0){
        cin >> a[n/2-i/2];
      }
      else{
        cin >> a[n/2+(i+1)/2];
      }
    }
  }else{
    cin >> a[n/2];
    for(int i=1; i<n; i++){
      if(i%2==0){
        cin >> a[n/2+i/2];
      }else{
        cin >> a[n/2-(i+1)/2];
      }
    }
  }
  for(int i=0; i<n; i++){
    cout << a[i] << ' ';
  }
  cout << endl;
  return 0;
}

Measured memory_bytes: 2944
#!/usr/bin/env python3
s = input()
idx_a = 0
idx_z = 0
for i in range(len(s)):
    if s[i] == "A": 
        idx_a = i
        break
for i in range(len(s)-1,0,-1):
    if s[i] == "Z": 
        idx_z = i
        break
print(idx_z - idx_a + 1)

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

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

int main()
{
    long long A, B, K;
    cin >> A >> B >> K;
    if(A > K){
        cout << (A - K) << " " << B << endl;
    }
    else{
        cout << 0 << " " << ((B - (K - A)) > 0 ? B - (K - A) : 0) << endl;
    }
}

Measured memory_bytes: 256
function main(input) {
    new Main(input).walk(); 
}
  
var input = '';

process.stdin.resume();
process.stdin.setEncoding('utf8');
process.stdin.on('data', function(chunk) {
    input += chunk;
});
process.stdin.on('end', function() {
    main(input);
});
var tmp = `6
5 6 4 2 1 3`

class Main{
    constructor(input){
        var splits = input.split("\n");
        this.N = Number(splits[0]);
        this.A = splits[1].split(" ").map(v=>Number(v));
        this.count = 0;
    }
    walk(){
        for(var i=0; i<this.N; i++){
            var minj = i;
            for(var j=i; j<this.N; j++){
                if(this.A[j] < this.A[minj]){
                    minj = j;
                }
            }
            if(i != minj){
                this.swap(i, minj);
                this.count++;
            }
        }
        console.log(this.A.join(" "));
        console.log(this.count);
    }
    swap(i, j){
        var tmp = this.A[i];
        this.A[i] = this.A[j];
        this.A[j] = tmp;
    }
}
// new Main(tmp).walk();


Measured memory_bytes: 15576
#include<iostream>
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<set>
#include<map>
#include<queue>
#include<vector>
using namespace std;
typedef long long ll;
const int MOD=1e9+7;
int main() {
  string s;
  int n,cnt=0,ans=0;
  cin >> n >> s;
  for(int i=0; i<n; i++) {
    if(s[i]==s[i+1]) {
      ans++;
      while(i<n&&s[i]==s[i+1]) {
        i++;
      }
    }
    else {
      ans++;
    }
  }
  cout << ans << endl;   
}

Measured memory_bytes: 512
#include <iostream>
#include <set>
#include <algorithm>
#include <functional>
#include <string>
#include <vector>
#include <map>
#include <cstdio>
using namespace std;
#define rep(i,n) for(i = 0; i < n; i++)
#define repe(i,n) for(i = 0; i <= n; i++)
#define FOR(i,m,n) for(i = m, i < n; i++)
#define repr(i,n) for(i = n; i >= 0; i--)
#define INF = 999999999
#define SORT(v,n) sort(v, v+n)
#define ALL(x) (x).begin(),(x).end()
typedef long long ll;
const int MOD = 1000000007;

  
int main(){
    int i,n,d,x,a[100],nyan[100] = {0};
    cin >> n >> d >> x;
    rep(i,n) cin >> a[i];
    int ans;
    rep(i,n) nyan[i] = d / a[i];
    int sum = 0;
    rep(i,n) sum += nyan[i];
    sum += n;
    ans = x + sum;
    int minus = 0;
    rep(i,n) if(d % a[i] == 0) minus++;
    cout << ans - minus << endl;
    return 0;  
}

       


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

using namespace std;

int main()
{
    int n,k,sum=0;
    cin>>n>>k;
    int p[n];
    for(int i=0;i<n;i++)
    {
        cin>>p[i];
    }
    sort(p,p+n);
    for(int i=0;i<k;i++)
    {
        sum+=p[i];
    }
    cout<<sum<<endl;
    
}


Measured memory_bytes: 3636
N = int(input())
a = [[[] for i in range(10)] for j in range(10)]
ans = 0
for i in range(1, N+1):
  a[int(str(i)[0])][int(str(i)[-1])].append(i)
#print(a)
for i in range(1, 10):
  ans += len(a[i][i]) ** 2
for i in range(1, 9):
  for j in range(i+1, 10):
    ans += len(a[i][j]) * len(a[j][i]) * 2
print(ans)

Measured memory_bytes: 11508
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <queue>
#include <vector>
#include <set>
#include <map>
#include <numeric>

using namespace std;

int main(){
    int a[3];
    cin>>a[0]>>a[1]>>a[2];
    sort(a,a+3);
    int ans=3;
    if(a[0]==a[1])ans=2;
    if(a[1]==a[2])ans=2;
    if(a[0]==a[2])ans=1;
    cout<<ans<<endl;

}


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

int main() {
    int n;
    cin >> n;
    vector<int> a(n);
    int sum = 0;
    for (int i=0; i<n; ++i) {
        cin >> a[i];
        sum += a[i];
    }
    int mean = sum/n;
    vector<int> check = {mean-1, mean, mean+1};
    int ans = 1e9;
    for (int m: check) {
        int s = 0;
        for (int i=0; i<n; ++i) s += (a[i] - m) * (a[i] - m);
        ans = min(ans, s);
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
# =============================================================================
#　How many Islands?
# =============================================================================
import sys
sys.setrecursionlimit(10**8)
while True:
    W,H=map(int,input().split())
    if W==0 and H==0:
        break
    field=[list(map(int,input().split())) for _ in range(H)]

    MV=[(1,0),(1,1),(0,1),(-1,1),(-1,0),(-1,-1),(0,-1),(1,-1)]

    def dfs(field,h,w):
        global seen
        field[h][w]=0
        for mv in MV:
            nh=h+mv[0];nw=w+mv[1]
            if nh<0 or nh>=H or nw<0 or nw>=W:
                continue
            if field[nh][nw]==0:
                continue
            dfs(field,nh,nw)

    cnt=0
    for h in range(H):
        for w in range(W):
            if field[h][w]==1:
                dfs(field,h,w)
                cnt+=1
    print(cnt)



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

#define int long long
#define all(v) (v).begin(), (v).end()

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

const int INF = 1e18;

int A, B, Q;
vector<int> s, t;

int solve(int x) {
  // Right, Leftはxより右にあるか左にあるか
  int sRight = *lower_bound(all(s), x);
  int sLeft = *(upper_bound(all(s), x) - 1);
  int tRight = *lower_bound(all(t), x);
  int tLeft = *(upper_bound(all(t), x) - 1);

  int ret = INF;

  // (s, t) -> (t, s) -> x
  chmin(ret, abs(min(sLeft, tLeft) - x));

  // s -> x -> t
  chmin(ret, abs(tRight - sLeft) + abs(min(x - sLeft, tRight - x)));

  // t -> x -> s
  chmin(ret, abs(sRight - tLeft) + abs(min(x - tLeft, sRight - x)));

  // x -> (s, t) -> (t, s)
  chmin(ret, abs(max(tRight, sRight) - x));

  return ret;
}

signed main() {
  cin >> A >> B >> Q;
  s.resize(A);
  t.resize(B);
  for (int i = 0; i < A; i++) {
    cin >> s[i];
  }
  for (int i = 0; i < B; i++) {
    cin >> t[i];
  }

  // 番兵を設置すると値が見つからなかったときの処理が楽になる
  s.push_back(INF);
  s.push_back(-INF);
  t.push_back(INF);
  t.push_back(-INF);
  sort(all(t));
  sort(all(s));

  while (Q--) {
    int x;
    cin >> x;
    int ans = solve(x);
    cout << solve(x) << endl;
  }

  return 0;
}

Measured memory_bytes: 2912
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<ll> vi;
typedef vector<bool> vb;
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define sq(x) ((x)*(x))
#define fo(i,n) for(int i=0;i<n;i++)
#define fp(i,k,n) for(int i=k;i<n;i++)
#define Fo(i,n) for(int i=1;i<=n;i++)
#define all(x) x.begin(),x.end()
#define deb(x) cout<<#x<<"="<<x<<"\n"
#define deb2(x,y) cout<<#x<<"="<<x<<" "<<#y<<"="<<y<<"\n"
#define fi first
#define se second
const double pi = 3.14159265358979323846;
#define uni(c) (c).resize(unique(all(c))-(c).begin())
#define fast ios_base::sync_with_stdio(0);cin.tie(NULL)
//pair <int, int> w[4] = {mp(-1, 0), mp(0, -1), mp(1, 0), mp(0, 1)};   // for matrix movement:
void cp()
{
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif // ONLINE_JUDGE
}
void solve()
{
	ll n; cin >> n;
	ll a[n];
	fo(i, n)cin >> a[i];
	//sort(a, a + n);
	ll ans = 0;
	for (int i = 0; i < n; i++)
	{
		for (int j = i + 1; j < n; j++)
		{
			for (int k = j + 1; k < n; k++)
			{
				ll b[3] = {a[i], a[j], a[k]};
				sort(b, b + 3);
				if (b[0] + b[1] > b[2] and b[0] != b[1] and b[1] != b[2] and b[0] != b[2])
					ans++;
			}
		}
	}
	cout << ans;

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


	return 0;
}

Measured memory_bytes: 3640
#include <bits/stdc++.h>
using namespace std;
char s[100001];
long long p=0,r=0,w=0,l=0;
int main()
{
	cin>>s;
	for (long long i=0;i<strlen(s);i++)
	{
		if (s[i]=='p')
		{
			if (p>=r)
			{
			l++;
			r++;
			}
			else
			p++;
		}
		if (s[i]=='g')
		{
			if (p<r)
			{
			p++;
			w++;
			}
			else
			r++;
		}
	}
	cout<<w-l;
	return 0; 
} 

Measured memory_bytes: 384
#include "bits/stdc++.h"
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
typedef long double LD;
#define fastio ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define fileio freopen("in","r",stdin);freopen("out","w",stdout);

const LL N = 500005;
const LD PI = 3.141592653589793;
struct point{
	LL x;
	LL y;
};
struct cmp{
	bool operator()(point a, point b){
		if (a.y != b.y) return a.y < b.y;
		return a.x < b.x;
	}
};
point S, E, t, mx, mn;
LL n, cnt;
map<LL, LL> m;
LL ft[N];
vector<point> p;	
void update(LL pos, LL val){
	while (pos <= cnt + 2){
		ft[pos] = max(ft[pos], val);
		pos += (pos & (-pos));
	}
}
LL query(LL pos){
	LL res = 0;
	while (pos > 0){
		res = max(res, ft[pos]);
		pos -= (pos & (-pos));
	}
	return res;
}
int main(){
	//fileio
	fastio
	cin >> S.x >> S.y >> E.x >> E.y;
	cin >> n;
	mx.x = max(S.x, E.x);
	mx.y = max(S.y, E.y);
	mn.x = min(S.x, E.x);
	mn.y = min(S.y, E.y);
	if (S.x > E.x && S.y > E.y){
		swap(S.x, E.x);
		swap(S.y, E.y);	
	}
	for (LL i = 1; i <= n; i++){
		cin >> t.x >> t.y;
		if (mn.x <= t.x && t.x <= mx.x && mn.y <= t.y && t.y <= mx.y){
			p.push_back(t);
		}
	}
	if (S.x > E.x && S.y <= E.y){
		E.x -= S.x;
		E.y -= S.y;
		E.x = -1 * E.x;
		for (auto &c : p){
			c.x -= S.x;
			c.y -= S.y;
			c.x = -1 * c.x;
		}
		S.x = 0, S.y = 0;
	}
	else if (S.x <= E.x && S.y > E.y){
		E.y -= S.y;
		E.x -= S.x;
		E.y = -1 * E.y;
		for (auto &c : p){
			c.x -= S.x;
			c.y -= S.y;
			c.y = -1 * c.y;	
		}
		S.x = S.y = 0;
	}
	else{
		E.y -= S.y;
		E.x -= S.x;
		for (auto &c : p){
			c.x -= S.x;
			c.y -= S.y;
		}
		S.x = S.y = 0;
	}
	if (E.x == 0){
		LD dist = E.y * 100;
		for (auto c : p){
			if (c.y <= E.y){
				dist += (PI * 10) - 20;
				break;
			}
		}
		cout << fixed << setprecision(20) << dist;
		return 0;
	}
	if (E.y == 0){
		LD dist = E.x * 100;
		for (auto c : p){
			if (c.x <= E.x){
				dist += (PI * 10) - 20;
				break;
			}
		}
		cout << fixed << setprecision(20) << dist;
		return 0;
	}
	m[S.x], m[E.x];
	for (auto c : p)
		m[c.x];
	for (auto &c : m){
		c.second = ++cnt;
	}++cnt;
	LD dist = 100.0 * (E.x + E.y);
	if (!p.empty())
	{
		sort(p.begin(), p.end(), cmp());
		for (auto c : p){
			LL q = query(m[c.x]);
			update(m[c.x], q + 1);
		}
		LL fountains = query(cnt);
		if (fountains == min(E.x, E.y) + 1)
		{
			fountains--;
			dist += (10 * PI) - 20;
		}
		while (fountains --){
			dist -= (20.0 - (PI * 5));
		}
	}
	cout << fixed << setprecision(20) << dist;
	return 0;
}

Measured memory_bytes: 18412
import kotlin.math.*

fun readString() = readLine()!!
fun readInt() = readLine()!!.toInt()
fun readLong() = readLine()!!.toLong()
fun readIntList() = readLine()!!.split(" ").map(String::toInt)
fun readLongList() = readLine()!!.split(" ").map(String::toLong)
fun <T> Array<Array<T>>.print() {
    this.forEach {
        println(it.joinToString(" "))
    }
}

fun main() {
    val (a, b, h, m) = readIntList()
    val ar = (m.toDouble() / 60) * 360
    val br = ((h.toDouble() + m.toDouble() / 60) / 12) * 360
    val d = abs(br - ar)
    val theta = min(d, abs(360 - d))
    val c = sqrt(a * a + b * b - 2 * a * b * cos(PI * theta / 180F))
    println(c)
}

Measured memory_bytes: 36596
#include <bits/stdc++.h>
using namespace std;
template <typename T> void read(T &t) {
	t=0; char ch=getchar(); int f=1;
	while (ch<'0'||ch>'9') { if (ch=='-') f=-1; ch=getchar(); }
	do { (t*=10)+=ch-'0'; ch=getchar(); } while ('0'<=ch&&ch<='9'); t*=f;
}
typedef long long ll;
const ll mod=(1e9)+7;
const int maxn=(2e5)+10;
int n,k;
ll ans,jc[maxn],ivjc[maxn],iv[maxn];
ll C(int x,int y) {
	if (y<0||x<y) return 0;
	return jc[x]*ivjc[y]%mod*ivjc[x-y]%mod;
}
int main() {
	//freopen("1.txt","r",stdin);
	read(n); read(k);
	jc[0]=iv[0]=ivjc[0]=1;
	jc[1]=iv[1]=ivjc[1]=1;
	for (int i=2;i<=n;i++) {
		jc[i]=jc[i-1]*i%mod;
		iv[i]=(mod-mod/i)*iv[mod%i]%mod;
		ivjc[i]=ivjc[i-1]*iv[i]%mod;
	}
	for (int i=0;i<=min(n,k);i++) {
		ans+=C(n,i)*C(n-1,n-i-1)%mod; ans%=mod;
	}
	printf("%lld\n",ans);
	return 0;
}
/*
  0. Enough array size? Enough array size? Enough array size? Interger overflow?
  
  1. Think TWICE, Code ONCE!
  Are there any counterexamples to your algo?
    
  2. Be careful about the BOUNDARIES!
  N=1? P=1? Something about 0?
    
  3. Do not make STUPID MISTAKES!
  Time complexity? Memory usage? Precision error?
*/

Measured memory_bytes: 4992
n = int(input())
a = list(map(int,input().split()))
b = []
if n%2 == 0:
    for i in range(n-1,0,-2):
        b.append(a[i])
    for i in range(0,n-1,2):
        b.append(a[i])
else:
    for i in range(n-1,-1,-2):
        b.append(a[i])
    for i in range(1,n-1,2):
        b.append(a[i])
print(*b)

Measured memory_bytes: 30832
#include <bits/stdc++.h>
#define endl "\n"
#define ll long long int
#define pii pair<int,int>
#define pll pair<long long, long long>
#define mod 1000000007
#define inf 1000000000000000001;
#define all(c) c.begin(),c.end()
#define mp(x,y) make_pair(x,y)
#define mem(a,val) memset(a,val,sizeof(a))
#define eb emplace_back
#define f first
#define s second
#define MAXN 1000007
#define fr(i, s, e, st) for(ll (i) = (s); (i) < (e); (i) += (st))
#define fre(i, s, e, st) for(ll (i) = (s); (i) <= (e); (i) += (st))
#define fastio ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);cout<<fixed;cout<<setprecision(10);

using namespace std;

int main()
{
    fastio;
    int T = 1;
    while(T--){
        ll n, c=0;
        cin>>n;
        string s;
        cin>>s;
        fr(i, 0, n-2, 1) if(s[i]=='A' && s[i+1]=='B' && s[i+2] == 'C') c++;
        cout<<c<<endl;
    }                                               
    return 0;
}

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

int main()
{
    int n, k, i, j, INF = 1e9 + 5;
    cin >> n >> k;
    int a[n + 1];
    vector<int> dp(n + 1, INF);
    for(i = 1; i <= n; ++i)
        cin >> a[i];

    dp[1] = 0;
    dp[2] = abs(a[2] - a[1]);
    for(i = 3; i <= n; ++i) {
        for(j = 1; j <= k; ++j) {
            if((i - j) > 0)
                dp[i] = min(dp[i], abs(a[i] - a[i - j]) + dp[i - j]);
            else
                break;
        }
    }
    cout << dp[n] << "\n";
    return 0;
}

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

int imos[100002][30];

int main() {
    int n, C;cin >> n >> C;
    for(int i=0;i<n;i++){
        int s, t, c;cin >> s >> t >> c;
        c--;
        imos[s][c]++;
        imos[t][c]--;
    }

    int now = 0;
    int ans = 0;
    for(int i=0;i<100001;i++){
        int d = 0;
        for(int j=0;j<C;j++){
            if(imos[i+1][j] == 1){
                d++;
            }
            if(imos[i][j] == -1){
                d--;
            }
        }
        now += d;
        ans = max(ans, now);
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 11904
import sys
sys.setrecursionlimit(10000)

def nat_sum(n):
  if n==0:
    pass
  else:
    k = 0
    for i in range(n):
      if i*(i+1)//2 < n <= (i+1)*(i+2)//2:
        k = i+1
        break
    print(k)
    nat_sum(n-k)
    
n = int(input())
nat_sum(n)

Measured memory_bytes: 45040
#include <iostream>

using namespace std;

int main(){
  int N;
  cin>>N;
  if(N<=0 || 81<N){
    cout<<"No\n";
    return 0;
  }
  for(int i=9;0<i;i--){
  if(N%i==0){
    int n=N/i;
    if(n==1||n==2||n==3||n==4||n==5||n==6||n==7||n==8||n==9){
      cout<<"Yes\n";
      return 0;
    }
  }
  }
  cout<<"No\n";
  
  return 0;
}

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

typedef long long ll;

int main(){
  int N, M;
  cin >> N >> M;
  vector<ll> A(N);
  vector<ll> B(N);
  for (int i = 0; i < N; i++) {
    cin >> A.at(i) >> B.at(i);
  }
  vector<ll> index(A.size());
  iota(index.begin(), index.end(), 0);
  sort(
      index.begin(),
      index.end(),
      [&](ll x, ll y){return A.at(x) < A.at(y);}
  );
  ll cnt=0;
  for (int i = 0; i < index.size(); i++) {
    if(M==0) break;
    int num=B.at(index.at(i));
    if(M>=num){
      M -= num;
      cnt += num*A.at(index.at(i));
    }else{
      cnt += M*A.at(index.at(i));
      break;
    }
  }
  cout << cnt << endl;
}


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

int main(){
  int a,b,d;
  int i=0;
  int dif1,dif2;
  cin>>a>>b;
  if(a>b){
    d=a;
  }
  if(a<b){
    d=b;
  }
  for(int i;i<d;i++){
    dif1=a-i;
    if(a<i){
      dif1=i-a;
    }
    dif2=b-i;
    if(b<i){
      dif2=i-b;
    }
    if(dif1==dif2){
      cout<<i<<endl;
      break;
    }
    if(i==d-1){
      cout<<"IMPOSSIBLE"<<endl;
    }
  }  
  return 0;
}

Measured memory_bytes: 256
//by yjz
#include<bits/stdc++.h>
using namespace std;
#define FF first
#define SS second
#define PB push_back
#define MP make_pair
#define bged(v) (v).begin(),(v).end()
#define foreach(it,s) for(__typeof((s).begin()) it=(s).begin();it!=(s).end();it++)
typedef long long ll;
const int Imx=2147483647;
const ll Lbig=2e18;
const int mod=1e9+7;
//My i/o stream
struct fastio
{
	char s[100000];
	int it,len;
	fastio(){it=len=0;}
	inline char get()
	{
		if(it<len)return s[it++];it=0;
		len=fread(s,1,100000,stdin);
		if(len==0)return EOF;else return s[it++];
	}
	bool notend()
	{
		char c=get();
		while(c==' '||c=='\n')c=get();
		if(it>0)it--;
		return c!=EOF;
	}
}_buff;
#define geti(x) x=getnum()
#define getii(x,y) geti(x),geti(y)
#define getiii(x,y,z) getii(x,y),geti(z)
#define puti(x) putnum(x),putchar(' ')
#define putii(x,y) puti(x),puti(y)
#define putiii(x,y,z) putii(x,y),puti(z)
#define putsi(x) putnum(x),putchar('\n')
#define putsii(x,y) puti(x),putsi(y)
#define putsiii(x,y,z) putii(x,y),putsi(z)
inline ll getnum()
{
	ll r=0;bool ng=0;char c;c=_buff.get();
	while(c!='-'&&(c<'0'||c>'9'))c=_buff.get();
	if(c=='-')ng=1,c=_buff.get();
	while(c>='0'&&c<='9')r=r*10+c-'0',c=_buff.get();
	return ng?-r:r;
}
template<class T> inline void putnum(T x)
{
	if(x<0)putchar('-'),x=-x;
	register short a[20]={},sz=0;
	while(x)a[sz++]=x%10,x/=10;
	if(sz==0)putchar('0');
	for(int i=sz-1;i>=0;i--)putchar('0'+a[i]);
}
inline char getreal(){char c=_buff.get();while(c==' '||c=='\n')c=_buff.get();return c;}
int n,a[111],cnt[111];
void failed()
{
	puts("Impossible");
	exit(0);
}
int main()
{
	geti(n);
	int mx=0;
	for(int i=1;i<=n;i++)geti(a[i]),mx=max(mx,a[i]),cnt[a[i]]++;
	if(mx%2==0)
	{
		for(int i=1;i<mx/2;i++)if(cnt[i]>0)failed();
		if(cnt[mx/2]!=1)failed();
		for(int i=mx/2+1;i<=mx;i++)if(cnt[i]<2)failed();
		puts("Possible");
	}
	else
	{
		for(int i=1;i<=mx/2;i++)if(cnt[i]>0)failed();
		if(cnt[mx/2+1]!=2)failed();
		for(int i=mx/2+2;i<=mx;i++)if(cnt[i]<2)failed();
		puts("Possible");
	}
	return 0;
}

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

#define REP(i,n) for(int i=0;i<n;i++)
int N, M, C;
int B[21];
int A[21][21];

int main() {
  scanf("%d %d %d", &N, &M, &C);
  REP(i, M) scanf("%d", &B[i]);
  REP(i, N) {
    REP(j, M) {
      scanf("%d", &A[i][j]);
    }
  }
  int ans = 0;
  REP(i, N) {
    int tmp = C;
    REP(j, M) {
      tmp += B[j] * A[i][j];
    }

    if (tmp > 0) ans++;
  }
  printf("%d\n", ans);
  
  return 0;
}


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

#define cnd(c, a, b) (c ? a : b);
#define fl(x,y,z) for(int x=y;x<z;x++)
#define fe(x,y,z) for(int x=y;x<=z;x++)
#define fge(x,y,z) for(int x=z;x>=y;x--)

#define debug(x) std::cerr << #x << " --> " << x << "\n";
#define fastIO std::ios_base::sync_with_stdio(false);std::cin.tie(0);std::cout.tie(0);
#define pb push_back
#define pob pop_back
 
#define ln '\n'
typedef long long int ll;

ll mod=1e9+7;

void decrypt() {
	ll n, x, t;
	cin>>n>>x>>t;
	ll div = n/x;
	if(n%x==0) {
		cout<<(div)*t<<ln;
	}else {
		cout<<(div+1)*t<<ln;
	}
	return;
}

int main() {
    fastIO
    int t = 1;
    // cin >> t;
    fl(i,0,t) {
    	// cout << "Case #"<< i+1 <<": ";
    	decrypt();
    }
    return 0;
}

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

using namespace std;

int main(){
    int a[3];
    int N; cin >> N;
    while(N--){
        cin >> a[0] >> a[1] >> a[2];
        sort(a, a+3);
        if(a[0]*a[0]+a[1]*a[1] == a[2]*a[2]) cout << "YES" << endl;
        else cout << "NO" << endl;
    }
}

Measured memory_bytes: 0
import sys
n=int(input())

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

num0=a.count(0)
if num0>0:
    print(0)
    sys.exit()
ans=1
for i in range(n):
    ans *= a[i]
    if ans > 10**18:
        print(-1)
        sys.exit()
print(ans)

Measured memory_bytes: 87116
#include<iostream>
#include<cstdio>
#include<cstring>
#include <cstdlib>  
#include <math.h>
#include <cmath>
#include<cctype>
#include<string>
#include<set>
#include<iomanip>
#include <map>
#include<algorithm>
#include <functional>
#include<vector>
#include<climits>
#include<stack>
#include<queue>
#include <deque>
#include <climits>
#include <typeinfo>
#include <utility> 
#define all(x) (x).begin(),(x).end()
#define rep(i,m,n) for(int i = m;i < n;++i)
#define pb push_back
#define fore(i,a) for(auto &i:a)
#define rrep(i,m,n) for(int i = m;i >= n;--i)
#define INF INT_MAX/2
using namespace std;
using ll = long long;
using R = double;
using Data = pair<ll, vector<int>>;
const ll MOD = 1e9 + 7;
const ll inf = 1LL << 50;
struct edge { ll from; ll to; ll cost; };
typedef tuple<ll, ll, ll>T;
typedef pair<int, int>pint;




int main() {
	int r, g, b, n;
	cin >> r >> g >> b >> n;
	ll ans = 0;
	rep(i, 0, 4000)rep(j, 0, 4000) {
		if (n - i * r - j * g >= 0 && (n - i * r - j * g) % b == 0)ans++;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <set>
#include <cstdlib>
#include <cstdio>
#include <algorithm>
#include <queue>
#define REP(i,n) for(int i=0; i<(int)(n); i++)

inline int getInt(){ int s; scanf("%d", &s); return s; }

#include<complex>
#define EPS 1e-10

using namespace std;

using std::complex;

typedef complex<double> P;

struct S{
  P p1;
  P p2;
  S(P p,P q) : p1(p), p2(q) {}
};

int ccw(P p0, P p1, P p2){
  P d1 = p1-p0;
  P d2 = p2-p0;
  double dx1 = d1.real(), dx2 = d2.real();
  double dy1 = d1.imag(), dy2 = d2.imag();

  if(dx1*dy2 > dy1*dx2) return  1;
  if(dx1*dy2 < dy1*dx2) return -1;
  if((dx1*dx2 < 0) || (dy1*dy2 < 0)) return -1;
  if((dx1*dx1+dy1*dy1) < (dx2*dx2+dy2*dy2)) return 1;
  return 0;
}

bool intersect(const S &s1, const S &s2){
  return ((ccw(s1.p1, s1.p2, s2.p1)
           *ccw(s1.p1, s1.p2, s2.p2)) <= 0)
    &&((ccw(s2.p1, s2.p2, s1.p1)
        *ccw(s2.p1, s2.p2, s1.p2)) <= 0);
}

int main(){
  int nA = getInt();
  int nB = getInt();

  vector<P> a(nA);
  vector<P> b(nB);

  REP(i,nA){
    a[i].real() = getInt();
    a[i].imag() = getInt();
  }

  REP(i,nB){
    b[i].real() = getInt();
    b[i].imag() = getInt();
  }

  double ans = 1e10;

  REP(cc, 2){
    double res = std::abs(a[0] - a[1]);

    typedef pair<double, int> data;
    priority_queue<data, vector<data>, greater<data> > pq;
    vector<double> memo(nB, 1e10);
    vector<bool>   flag(nB, false);

    pq.push(make_pair(0.0, 0));
    // REP(i,nA) cout << a[i] << " "; cout << endl;
    // REP(i,nB) cout << b[i] << " "; cout << endl;

    while(pq.size()){
      data d = pq.top(); pq.pop();
      double dist = d.first;
      int    pos  = d.second;

      if(flag[pos]) continue;
      flag[pos] = true;
      if(pos == 1){
        res += dist;
        break;
      }

      REP(i,nB) if(!flag[i]){
        double dd = dist + std::abs(b[pos] - b[i]);
        if(dd < memo[i]){
          if(!intersect(S(a[0], a[1]), S(b[pos], b[i]))){
            memo[i] = dd;
            pq.push(make_pair(dd, i));
          }
        }
      }
    }

    if(flag[1])
      ans = min(ans, res);
    a.swap(b);
    swap(nA, nB);
  }

  if(ans < 1e9) printf("%.11f\n", ans);
  else printf("-1\n");

  return 0;
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
using namespace std;
typedef long long       ll;
#define MOD ((int)1e9+7)
#define N ((int)2e5+123)
void reads(string& x){ char kk[N]; scanf("%s",kk); x = kk;}

int ans, val,v[N], n, x, dist;

void solve(){
    scanf("%d %d", &x, &n);
    dist = 1000;
    for(int i=0;i<n;i++){
        scanf("%d",&val);
        v[val]=1;
    }
    for(int i=0;i<1000;i++){
        if(v[x-i]){
            if(v[x+i]){
                continue;
            }
            else{
                printf("%d\n",x+i);
                return;
            }
        }
        else{
            printf("%d\n",x-i);
            return;
        }
    }
}

int main(){
    ios_base::sync_with_stdio(0);
    int t = 1; //scanf("%d",&t);
    for(int caso=1;caso<=t;caso++){
        solve();
    }
}

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

void swap(int *a, int *b)
{
	int *temp = a;
	a = b;
	b = a;
}

int main()
{
	int w, n;
	cin >> w >> n;
	int b, c;
	int a[31];
	for (int i = 1; i < 31; ++i) {
		a[i] = i;
	}
	char d;
	for (int i = 0; i < n; ++i) {
		cin >> b >> d >> c;
		swap(a[b], a[c]);
	}
	for (int i = 1; i <= w; ++i) {
		cout << a[i] << endl;
	}
	return 0;
}

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

int main()
{
	int n,ac=0,wa=0,tle=0,re=0;
	cin>>n;
	string s;
	for(int i=1;i<=n;i++)
	{
		cin>>s;
		if(s[0]=='A')
		  ac++;
		if(s[0]=='W')
		  wa++;
		if(s[0]=='T')
		  tle++;
		if(s[0]=='R')
		  re++;
	}
	cout<<"AC"<<" x "<<ac<<endl;
	cout<<"WA"<<" x "<<wa<<endl;
	cout<<"TLE"<<" x "<<tle<<endl;
	cout<<"RE"<<" x "<<re<<endl;
	return 0; 
}

Measured memory_bytes: 3628
#include<bits/stdc++.h>
const int N=200008;
using namespace std;
map<int,int>tab;
int num[N];
int main()
{
	int n,m;
	int tot=0;
	cin>>n;
	for(int i=1;i<=n;++i) 
	{
		int x;
		scanf("%d",&x);
	    if(tab.find(x)==tab.end()) tab[x]=++tot,num[tot]++;
	    else num[tab[x]]++;
	}
	cin>>m;
	for(int i=1;i<=m;++i)
	{
		int x;
		scanf("%d",&x);
		if(tab.find(x)==tab.end())
		{
			printf("NO\n");
			return 0;
		}
		else 
		{
		   int pos=tab[x];
		   if(num[pos]<=0)
		   {
		   	printf("NO\n");
		   	return 0;
		   }
		   num[pos]--;
		}
	}
	printf("YES\n");
	return 0;
}

Measured memory_bytes: 10368
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define rep2(i, s, n) for (ll i = s; i < (ll)(n); i++)
#define repr(i, n) for (ll i = n; i >= 0; i--)
#define pb push_back
#define COUT(x) cout << (x) << "\n"
#define COUTF(x) cout << setprecision(15) << (x) << "\n"
#define ENDL cout << "\n"
#define DF(x) x.erase(x.begin())  // 先頭文字削除
#define ALL(x) x.begin(), x.end()
#define SZ(x) (ll) x.size()
#define SORT(x) sort(ALL(x))
#define REVERSE(x) reverse(ALL(x))
#define ANS cout << ans << "\n"
#define RETURN(x)    \
  cout << x << "\n"; \
  return 0
clock_t CLOCK;
#define START_TIMER CLOCK = clock()
#define SHOW_TIMER cerr << "time: " << (ld)(clock() - CLOCK) / 1000000 << "\n"
#define init() \
  cin.tie(0);  \
  ios::sync_with_stdio(false)
#define LINE cerr << "[debug] line: " << __LINE__ << "\n";
#define debug(x) cerr << "[debug] " << #x << ": " << x << "\n";
#define debugV(v)                       \
  cerr << "[debugV] " << #v << ":";     \
  rep(i, v.size()) cerr << " " << v[i]; \
  cerr << "\n";
using namespace std;
using ll = long long;
using ld = long double;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using mll = map<ll, ll>;
using qll = queue<ll>;
using P = pair<ll, ll>;

constexpr ll INF = 0x3f3f3f3f3f3f3f3f;
constexpr ld PI = 3.141592653589793238462643383279;
ll get_digit(ll x) {
  return to_string(x).size();
}

ll gcd(ll x, ll y) {
  return y ? gcd(y, x % y) : x;
}

ll lcm(ll a, ll b) {
  return a / gcd(a, b) * b;
}

vector<P> factorize(ll n) {
  vector<P> result;
  for (ll i = 2; i * i <= n; ++i) {
    if (n % i == 0) {
      result.pb({i, 0});
      while (n % i == 0) {
        n /= i;
        result.back().second++;
      }
    }
  }
  if (n != 1) {
    result.pb({n, 1});
  }
  return result;
}

vll divisor(ll n) {
  vll ret;
  for (ll i = 1; i * i <= n; i++) {
    if (n % i == 0) {
      ret.push_back(i);
      if (i * i != n) ret.push_back(n / i);
    }
  }
  SORT(ret);
  return (ret);
}

signed main() {
  init();
  ll N;
  cin >> N;
  vll T(N);
  rep(i, N) cin >> T[i];
  ll sum = 0;
  rep(i, N) sum += T[i];
  ll M;
  cin >> M;
  rep(i, M) {
    ll p, x;
    cin >> p >> x;
    p--;
    COUT(sum - T[p] + x);
  }
  return 0;
}

Measured memory_bytes: 3636