akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;

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

  int start, last;
  for (unsigned i = 0; i < s.size(); i++) {
    if (s[i] == 'A') {
      start = i;

      break;
    }
  }
  for (unsigned i = s.size(); i > 0; i--) {
    if (s[i] == 'Z') {
      last = i;

      break;
    }
  }

  int answer = last - start + 1;

  cout << answer << endl;
}


Measured memory_bytes: 640
n = int(input())
lis1 = list(map(int, input().split()))
lis2 = list(map(int, input().split()))
count = 0
for i in range(n):
    if lis1[i] >= lis2[i]:
        count += lis2[i]
    else:
        count += lis1[i]
        temp = lis2[i]-lis1[i]
        if lis1[i+1] <= temp:
            count += lis1[i+1]
            lis1[i+1] = 0
        else:
            count += temp
            lis1[i+1] -= temp
print(count)

Measured memory_bytes: 18624
#include "bits/stdc++.h"
using namespace std;
#define int long long
#define double long double
#define low lower_bound
#define upp upper_bound
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#define Rep(i,n) for (int i = (int)(n); i >= 0; i--)
#define all(vec) vec.begin(),vec.end()
#define rever(vec) reverse(all(vec));
#define cend cout << endl;
#define prique(T) priority_queue<T,vector<T>,greater<T>>
#define prique2(T) priority_queue<T>
struct edge { int to, cost; };
using P = pair<int, int>;
using PP = pair<P, int>;
const int mod2 = 998244353;
const int mod = 1e9 + 7, inf = 1e16;

int modpow(int x, int n) {
	int ans = 1;
	while (n > 0) {
		if (n & 1) {
			ans *= x;
			if (mod <= ans) ans %= mod;
		}
		x *= x;
		if (mod <= x) x %= mod;
		n >>= 1;
	}
	return ans;
}

int fact_memo[114514];
int fact(int n) {
	int ans = 1;
	if (fact_memo[n]) return fact_memo[n];
	rep(i, n) {
		ans *= (i + 1);
		if (mod <= ans) ans %= mod;
		fact_memo[i + 1] = ans;
	}
	return (ans + mod) % mod;
}

int comb(int n, int r) {
	if (n < r) return 0;
	if (n - r < r) r = n - r;
	return (fact(n) * modpow(fact(n - r), mod - 2) % mod * modpow(fact(r), mod - 2) + mod) % mod;
}

int perm(int n, int r) {
	if (n < r) return 0;
	if (n - r < r) r = n - r;
	return (fact(n) * modpow(fact(n - r), mod - 2) % mod + mod) % mod;
}

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

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

bool pri(int p) {
	for (int i = 2; i * i <= p; i++) if (p % i == 0) return false;
	return p > 1;
}

map<int, int>factring(int n) {
	map<int, int>ans;
	for (int i = 2; i * i <= n; i++) {
		while (n % i == 0) {
			n /= i;
			ans[i]++;
		}
	}
	if (n != 1) ans[n]++;
	return ans;
}

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

class unionfind {
private:
	int par[200010], rankth[200010], sizeth[200020];
public:
	void init(int n) {
		rep(i, n) {
			par[i] = i;
			rankth[i] = 0;
			sizeth[i] = 1;
		}
	}
	int par2(int x) {
		return par[x];
	}
	int root(int x) {
		while (par[x] != x) {
			x = par[x] = par[par[x]];
		}
		return x;
	}

	bool same(int x, int y) {
		return root(x) == root(y);
	}

	void unite(int x, int y) {
		x = root(x);
		y = root(y);
		if (x == y) return;
		if (rankth[x] < rankth[y]) {
			par[x] = y;
			sizeth[y] += sizeth[x];
		}
		else {
			par[y] = x;
			if (rankth[x] == rankth[y]) rankth[x]++;
			sizeth[x] += sizeth[y];
		}
	}
};

int n, k, l;
map<P, int>mp;
unionfind a, b;
signed main() {
	scanf("%lld %lld %lld", &n, &k, &l);
	a.init(n + 1), b.init(n + 1);
	rep(i, k) {
		int p, q;
		scanf("%lld %lld", &p, &q);
		a.unite(p, q);
	}
	rep(i, l) {
		int r, s;
		scanf("%lld %lld", &r, &s);
		b.unite(r, s);
	}
	rep(i, n) {
		mp[P(a.root(i + 1), b.root(i + 1))]++;
	}
	rep(i, n) {
		if (i < n - 1) {
			printf("%lld ", mp[P(a.root(i + 1), b.root(i + 1))]);
		}
		else {
			printf("%lld\n", mp[P(a.root(i + 1), b.root(i + 1))]);
		}
	}
}


Measured memory_bytes: 22272
# include <bits/stdc++.h>
# 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 rrep(i, n) for(int i=((int)(n)-1); i>=0; --i)
# define rreps(i, n) for(int i=((int)(n)); i>0; --i)
# define ALL(x) (x).begin(), (x).end()
# define SZ(x) ((int)(x).size())
# define pb push_back
# define optimize_cin() cin.tie(0); ios::sync_with_stdio(false)
using namespace std;
using ll = long long;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const long long INF = 1LL << 60;

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

uintmax_t combination(unsigned int n, unsigned int r) {
  if ( r * 2 > n ) r = n - r;
  uintmax_t dividend = 1;
  uintmax_t divisor  = 1;
  for ( unsigned int i = 1; i <= r; ++i ) {
    dividend *= (n-i+1);
    divisor  *= i;
  }
  return dividend / divisor;
}

int modPow(long long a, long long n, long long p) {
  if (n == 1) return a % p;
  if (n % 2 == 1) return (a * modPow(a, n - 1, p)) % p;
  long long t = modPow(a, n / 2, p);
  return (t * t) % p;
}

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

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

    double sans = 0;
    double ans;
    double count; 

    reps(i,n){
        double cnt = 1;
        double t = i;
        rep(j,100000){
            if(t >= k){
                count = 1/cnt;
                sans+=count;
                break;
            }
            t*=2;
            cnt*=2;
        }
    }

    ans = sans/n;

    cout << fixed << setprecision(10) << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;
int ap[2][200005];
int n,m,i,a,b;
int main()
{
    cin>>n>>m;
    for(i=1;i<=m;i++)
    {
        cin>>a>>b;
        if(a==1||b==1)
            ap[0][(a^b^1)]=1;
        if(a==n||b==n)
            ap[1][(a^b^n)]=1;
    }
    for(i=2;i<n;i++)
    {
        if(ap[0][i]&&ap[1][i])
        {
            cout<<"POSSIBLE";
            return 0;
        }
    }
    cout<<"IMPOSSIBLE";
    return 0;
}

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

using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)

bool seen[1000000];

ll dfs(vector<set<int> >& v, int i) {
    seen[i] = true;
    ll cnt = 1;
    for (auto next : v[i]) {
        if (seen[next]) {
            continue;
        }
        cnt += dfs(v, next);
    }
    return cnt;
}

int main() {
    ll n, m;
    cin >> n >> m;
    vector<set<int> > v(n, set<int>());
    ll ans = 0;
    rep(i, m) {
        ll a, b;
        cin >> a >> b;
        a--;
        b--;
        v[a].insert(b);
        v[b].insert(a);
    }
    rep(i, n) {
        if (!seen[i]) {
            ll cnt = dfs(v, i);
            ans = max(ans, cnt);
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 41040
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < n; ++i)
#define rrep(i, n) for(int i = n-1; i >= 0; --i)
#define fi first
#define se second
using namespace std;
using lint = long long;
using uint = unsigned int;
using ulint = unsigned long long;
using ldouble = long double;
using pii = pair<int, int>;
using pli = pair<lint, lint>;
using pdd = pair<double, double>;
using pld = pair<ldouble, ldouble>;
using v1i = vector<int>;
using v1li = vector<lint>;
using v2i = vector<vector<int>>;
using v2li = vector<vector<lint>>;
using v3i = vector<vector<vector<int>>>;
using v3li = vector<vector<vector<lint>>>;
using v1b = vector<bool>;
using v2b = vector<vector<bool>>;
using v3b = vector<vector<vector<bool>>>;
using v1c = vector<char>;
using v2c = vector<vector<char>>;
using v3c = vector<vector<vector<char>>>;
constexpr lint mod1 = 1e9+7;
constexpr lint mod2 = 998244353;

int main(){
  string s; cin >> s;
  v1i v(s.size()+1, 0), u(2016, 1);
  rep(i, 2015){
    u[i+1] = u[i]*10;
    u[i+1] %= 2019;
  }
  rrep(i, s.size()){
    v[i] = v[i+1] + u[((int)s.size()-i-1)%2016]*(s[i]-'0');
    v[i] %= 2019;
  }
  map<int, lint> m;
  rep(i, s.size()+1) m[v[i]]++;
  lint a = 0;
  rep(i, 2019) a += m[i] * (m[i]-1) / 2;
  if(s.size() < 5) a = 0;
  cout << a << endl;
  return 0;
}


Measured memory_bytes: 4396
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <fstream>
using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<long, long> PLL;
typedef long long LL;
//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);

//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))
#define INF 10000000

LL dp[2][100003];
int main(){
	LL n,k;
	while(cin>>n>>k){
		if(n==0&&k==0)break;
		bool ck=false;
		vector<LL>ar;
		CLR(dp);
		REP(i,k){
			LL t;
			cin>>t;
			if(t==0)ck=true;
			else ar.PB(t);
		}
		SORT(ar);
		dp[0][0]=1;
		FOR(i,1,SZ(ar)){
			if(ar[i]-ar[i-1]==1){
				dp[0][i]=dp[0][i-1]+1;
				dp[1][i]=dp[1][i-1]+1;
			}else{
				dp[1][i]=dp[0][i-1]+1;
				if(i!=SZ(ar)-1&&ar[i+1]-ar[i]==1)dp[1][i]++;
				dp[0][i]=1;
			}
		}
		LL res=0;
		if(!ck)REP(i,SZ(ar))res=max(res,dp[0][i]);
		else REP(i,SZ(ar))res=max(res,max(dp[0][i],dp[1][i]));
		cout<<res<<endl;
	}
	return 0;
}

/*
7 5
6
2
4
7
1
7 5
6
3
0
4
7
0 0
*/

Measured memory_bytes: 3684
use v5.18; # strict say state
use warnings;
use List::Util qw(reduce first max min sum0);

chomp (my $n = <STDIN>);
chomp (my @a = split / /, <STDIN>);
my $ans = 0;
my ($cf, $uf, $df) = (1, 1, 1);
for my $i (1..($n-1)) {
  
  if ($a[$i]>$a[$i-1]) {
    if ($cf==0 && $df) {
      $cf = $uf = $df = 1;
      next;
    } else {
      $uf = 1;
      $df = 0;
    }
    if ($cf) {
      $ans++;
      $cf = 0;
    }
  } elsif ($a[$i]<$a[$i-1]) {
    if ($cf==0 && $uf) {
      $cf = $uf = $df = 1;
      next;
    } else {
      $uf = 0;
      $df = 1;
    }
    if ($cf) {
      $ans++;
      $cf = 0;
    }
  }
}
say $ans+$cf;

Measured memory_bytes: 17572
//defines e includes
#include <bits/stdc++.h>
#define fastio ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0)
#define rep1(i, n) for(int i=0;i<(int)n;i++)
#define rep2(i, a, b) for(int i=(int)a;i<(int)b;i++)
#define st first
#define nd second
#define pb push_back
#define pf push_front
#define p_b pop_back
#define p_f pop_front
#define mp make_pair
#define MAX 1000010
#define oo INT_MAX
using namespace std;
//tipagem de pares
typedef pair<int, int> ii;
typedef pair<char, char> cc;
typedef pair<int, char> ic;
typedef pair<char, int> ci;
//tipagem de vetores
typedef vector<int> vi;
typedef vector<long long> vll;
typedef vector<vector<int>> vvi;
typedef vector<pair<int, int>> vii;
typedef vector<bool> vb;
//tipagem de outras estruturas
typedef queue<int> qi;
typedef deque<int> dqi;
//tipagem de tipos primitivos
typedef long long int ll;
typedef unsigned long long int ull;

bool primes[MAX];

set<ll> v;

void sieve(){
	rep1(i, MAX){
		primes[i] = true;
	}
	for(ll p=2;p*p < MAX;p++){
		if(primes[p]){
			for(ll i=p*p;i < MAX;i+=p){
				primes[i] = false;
			}
		}
	}
	for(ll i=2;i<MAX;i++){
		if(primes[i]) v.insert(i*1LL*i);
	}
}

int main()
{
	
	fastio;
	// freopen("input.txt", "r", stdin);
	// freopen("output.txt", "w", stdout);
	
	int r, d, x;
	cin >> r >> d >> x;
	rep1(i, 10){
		cout << r*x - d << endl;
		x = r*x - d;
	}


	return 0;
}

Measured memory_bytes: 256
//AUTHOR:BlackBox Inc.//
#include<bits/stdc++.h>
#include<unordered_map>
#include<tr1/unordered_map>
#define ll long long
#define ull unsigned long long
#define vi vector<int>
#define vlli vector<long long int>
#define vvi vector<vector<int>>
#define vpii vector<pair<int,int>>
#define vs vector<string>
#define lin1(x) ll int x; x = scan();
#define lin2(x,y) ll int x, y; x = scan(), y = scan();
#define lin3(x,y,z) ll int x, y, z; x = scan(), y = scan(), z = scan();
#define pb(x) push_back(x)
#define makep(x,y) make_pair(x,y)
#define mx(a,b) (a)>(b)?(a):(b)
#define mn(a,b) (a)<(b)?(a):(b)
#define fori(s,e) for(i=s;i<=e;i++)
#define forj(s,e) for(j=s;j<=e;j++)
#define fork(s,e) for(k=s;k<=e;k++)
#define rep(i,s,e) for(int i=s;i<=e;i++)
#define brep(i,s,e) for(int i=s;i>=e;i--)
#define all(x) x.begin(),x.end()
#define mem(x,y) memset(x,y,sizeof(x));
#define bits1(x) __builtin_popcount(x)
#define pi 3.14159265358979323846264338327950
#define MOD7 1000000007
#define MOD9 1000000009
#define fast std::ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
using namespace std;
using namespace std::tr1;

int main()
{
#ifdef RAHUL
    freopen("input.txt","r",stdin);
#endif

    int n;
    cin>>n;
    std::vector<int > rohan(n);

    for (int i = 0; i < n; ++i)
    {
        cin>>rohan[i];
        /* code */
    }

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

    int answer=rohan[rohan.size()/2]-rohan[rohan.size()/2-1];

    cout<<answer<<"\n";

return 0;
}



Measured memory_bytes: 640
A, B, C = [int(i) for i in input().split()]
K = int(input())

cnt = 0
for _ in range(K):
    if A >= B:
        B *= 2
        cnt += 1
    elif B >= C:
        C *= 2
        cnt += 1

if A < B < C:
    print("Yes")
else:
    print("No")


Measured memory_bytes: 9176
#!/usr/bin/env python3

import itertools

N = int(input())
P = list(map(int, input().split()))
Q = list(map(int, input().split()))
# print(N, P, Q)

perms = list(map(list, itertools.permutations(range(1, N+1), N)))
perms.sort()
# print(perms)
# print(perms.index([1, 2, 3]))
# print(perms.index([3, 2, 1]))

a = perms.index(P) + 1
b = perms.index(Q) + 1

print(abs(a - b))


Measured memory_bytes: 47196
#include    <iostream>
#include    <cstdio>
#include    <cstdlib>
#include    <algorithm>
#include    <vector>
#include    <cstring>
#include    <queue>
#include    <complex>
#include    <stack>
#define LL long long
#define dob double
using namespace std;

const int N = 210;
const int R = 1010;
const int Inf = 1<<28;
int n,m,Q,land[N][N],sea[N][N],f[R][N],Cit[R],Ans;

inline int gi(){
  int x=0,res=1;char ch=getchar();
  while(ch>'9'||ch<'0'){if(ch=='-')res*=-1;ch=getchar();}
  while(ch<='9'&&ch>='0')x=x*10+ch-48,ch=getchar();
  return x*res;
}

main()
{
  /*freopen("Mr._Rito_Post_Office .in","r",stdin);
    freopen("Mr._Rito_Post_Office .out","w",stdout);*/
  while(1){
    n=gi();m=gi();
    if(n+m==0)break;
    for(int i=1;i<=n;++i)
      for(int j=1;j<=n;++j)
        land[i][j]=sea[i][j]=Inf;
    for(int i=1;i<=n;++i)
      land[i][i]=sea[i][i]=0;
    for(int i=1;i<=m;++i){
      int u,v,c;char type;
      scanf("%d%d%d %c",&u,&v,&c,&type);
      if(type=='L')
        land[u][v]=land[v][u]=min(land[u][v],c);
      else sea[u][v]=sea[v][u]=min(sea[u][v],c);
    }
    for(int k=1;k<=n;++k)
      for(int i=1;i<=n;++i)
        for(int j=1;j<=n;++j){
          land[i][j]=min(land[i][j],land[i][k]+land[k][j]);
          sea[i][j]=min(sea[i][j],sea[i][k]+sea[k][j]);
        }
    Q=gi();
    for(int i=0;i<=Q;++i)
      for(int j=0;j<=n;++j)
        f[i][j]=Inf;Ans=Inf;
    for(int i=1;i<=Q;++i)Cit[i]=gi();
    f[1][Cit[1]]=0;
    for(int i=2;i<=Q;++i)
      for(int j=1;j<=n;++j){
        f[i][j]=min(f[i][j],f[i-1][j]+land[Cit[i-1]][Cit[i]]);
        for(int k=1;k<=n;++k)
          f[i][j]=min(f[i][j],f[i-1][k]+land[Cit[i-1]][k]+sea[j][k]+land[j][Cit[i]]);
      }
    for(int i=1;i<=n;++i)
      Ans=min(Ans,f[Q][i]);
    printf("%d\n",Ans);
  }
  
  /*fclose(stdin);
    fclose(stdout);*/
  return 0;
}

Measured memory_bytes: 4308
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<map>
#include<set>
#include<cstdio>
#include<cmath>
#include<numeric>
#include<queue>
#include<stack>
#include<cstring>
#include<limits>
#include<functional>
#define rep(i,a) for(int i=(int)0;i<(int)a;++i)
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
using ll=long long;
static const ll mod = 1e9 + 7;
static const ll INF = 1LL << 50;
using namespace std;
 
 
int main(){
    ll n;
    cin>>n;
    vector<ll>a(n),b(n),c(n);
    rep(i,n)cin>>a[i]>>b[i]>>c[i];
    vector<vector<ll>>dp(n+1,vector<ll>(3,0));//制約が増えたから変数を１つ増やす
    rep(i,n){//A:0,B:1,C:2
      dp[i+1][0]=max(dp[i][1]+a[i],dp[i][2]+a[i]);
      dp[i+1][1]=max(dp[i][0]+b[i],dp[i][2]+b[i]);
      dp[i+1][2]=max(dp[i][0]+c[i],dp[i][1]+c[i]);
    }
    cout<<max({dp[n][0],dp[n][1],dp[n][2]})<<endl;
    return 0;
}

Measured memory_bytes: 8064
X = int(input())
ans = 0
if X >= 1800:
    ans = 1
elif X >= 1600:
    ans = 2
elif X >= 1400:
    ans = 3
elif X >= 1200:
    ans = 4
elif X >= 1000:
    ans = 5
elif X >= 800:
    ans = 6
elif X >= 600:
    ans = 7
else:
    ans = 8
print(ans)

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

int main(){
  int d[5],total = 0;
  for(int i = 0; i < 5; i++) {
    cin >> d[i];
    total += ((d[i] + 9) / 10) * 10;
  }
  int final = 0;
  for(int i = 0; i < 5; i++){
    final = max(final, ((d[i] + 9) / 10) * 10 - d[i]);
  }
  cout << total - final << endl;
}


Measured memory_bytes: 3576
#include<cstdio>
int a[110][110];
int main()
{
    int h,w,n,x,col=0,diret=1,i=1,j=1;
    scanf("%d%d%d",&h,&w,&n);
    while(n--)
    {
    	scanf("%d",&x);
    	col++;
    	while(x--)
    	{
    		a[i][j]=col;
    		j+=diret;
    		if(!j||j>w)
    		{
    			j-=diret;
    			diret=0-diret;
    			i++;
			}
		}
	}
	for(int i=1;i<=h;i++)
	{
		for(int j=1;j<=w;j++)
		printf("%d ",a[i][j]);
		printf("\n");
	}
    return 0;
}

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

int nextpettern(int pat[], int N){
  int point = -1 ;
  for(int i=0;i<N;i++){
    if(pat[i] == 0){
      point = i ;
      break ;
    }
  }
  if(point >= 0){
    pat[point] = 1 ;
    for(int i=0;i<point;i++){
      pat[i] = 0 ;
    }
    return 1 ;
  }
  return 0 ;
}

int main(){
  int N, M, X, ans = 0, cost, check ;
  cin >> N >> M >> X ;
  int C[N], A[N][M], rikai[M], pattern[N] ;
  for(int i=0;i<N;i++) pattern[i] = 0 ;
  for(int i=0;i<N;i++){
    cin >> C[i] ;
    for(int j=0;j<M;j++){
      cin >> A[i][j] ;
    }
  }
  while(nextpettern(pattern, N)){
    for(int i=0;i<M;i++) rikai[i] = 0 ;
    cost = 0 ;
    check = 1 ;
    for(int i=0;i<N;i++){
      if(pattern[i] == 1){
        cost += C[i] ;
        for(int j=0;j<M;j++){
          rikai[j] += A[i][j] ;
        }
      }
    }
    for(int i=0;i<M;i++){
      if(rikai[i] < X) check = 0 ;
    }
    if(check){
      if(ans == 0) ans = cost ;
      else if(ans > cost) ans = cost ;
    }
  }
  if(ans != 0){
    cout << ans << endl ;
  }  
  else{
    cout << -1 << endl ;
  }  
  return 0 ;
}  

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


vector<ll> enumerate_divisors(ll n) {
    vector<ll> divisor_1, divisor_2;
    ll e, root_n = (ll)(sqrt(n) + 0.5);
    for (int d = 1; d <= root_n; d++) {
        if (n % d == 0) {
            divisor_1.push_back(d);
            e = n / d;
            if (e != d) divisor_2.push_back(e);
        }
    }
    reverse(divisor_2.begin(), divisor_2.end());
    divisor_1.insert(divisor_1.end(), divisor_2.begin(), divisor_2.end());
    return divisor_1;
}


int main() {
    ll N;
    cin >> N;

    auto F = [](ll A, ll B) -> int {
        return max(to_string(A).size(), to_string(B).size());
    };

    vector<ll> divisors = enumerate_divisors(N);
    int ans = 1 << 30;
    for (ll d: divisors) {
        ans = min(ans, F(d, N / d));
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3704
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
using namespace std;
int N, M;
int i;
int cnt = 0;
int ans = 0;
int main()
{
    cin >> N;
    int X[N], Y[N];
    rep(i, N){
        cin >> X[i];
        Y[i] = X[i];
    }
    sort(Y, Y + N);
    rep(i, N){
        if(X[i] >= Y[N/2]){
            cout << Y[N/2 - 1] << endl;
        }else{
            cout << Y[N/2] << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 3712
package main

// Solution for https://atcoder.jp/contests/abc069/tasks/abc069_b

import (
	"bufio"
	"fmt"
	"io"
	"os"
)

type contest struct {
	in  io.Reader
	out io.Writer
}

func (con *contest) Scan(a ...interface{}) (int, error) {
	return fmt.Fscan(con.in, a...)
}
func (con *contest) Scanln(a ...interface{}) (int, error) {
	return fmt.Fscanln(con.in, a...)
}
func (con *contest) Scanf(f string, a ...interface{}) (int, error) {
	return fmt.Fscanf(con.in, f, a...)
}
func (con *contest) Print(a ...interface{}) (int, error) {
	return fmt.Fprint(con.out, a...)
}
func (con *contest) Println(a ...interface{}) (int, error) {
	return fmt.Fprintln(con.out, a...)
}
func (con *contest) Printf(f string, a ...interface{}) (int, error) {
	return fmt.Fprintf(con.out, f, a...)
}
func main() {
	in := bufio.NewReader(os.Stdin)
	out := bufio.NewWriter(os.Stdout)
	defer out.Flush()
	con := &contest{in: in, out: out}
	con.main()
}

func (con *contest) main() error {
	var s string
	con.Scan(&s)
	n := len(s) - 2
	con.Printf("%c%d%c\n", s[0], n, s[len(s)-1])
	return nil
}


Measured memory_bytes: 640
//In the name of 'ALLAH'//
#include<bits/stdc++.h>
using namespace std;
int main()
{
    string s1 , s2 , s3;
    cin>>s1>>s2>>s3;
    cout<<s1[0]<<s2[0]<<s3[0]<<endl;
    return 0;
}


Measured memory_bytes: 3536
#!/usr/bin/env python3
import sys


def solve(N: int, A: "List[int]"):
    A.sort(reverse=True)
    a = 0
    b = 0
    for i, v in enumerate(A):
        if i % 2 == 0:
            a += v
        else:
            b += v
    ret = a - b
    print(ret)
    return


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    a = [ int(next(tokens)) for _ in range(N) ]  # type: "List[int]"
    solve(N, a)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
public class Main {
  private static void solve() {
    char[] s = ns();
    int n = s.length;
    char[] t = "AKIHABARA".toCharArray();

    if (t.length < s.length) {
      System.out.println("NO");
      return;
    }
    int ptr = 0;
    for (int i = 0; i < t.length; i ++) {
      if (ptr == n || s[ptr] != t[i]) {
        if (t[i] == 'A') continue;
        else {
          System.out.println("NO");
          return;
        }
      } else if (ptr >= n) {
        System.out.println("NO");
        return;
      } else {
        ptr ++;
      }
    }
    System.out.println("YES");
  }

  public static void main(String[] args) {
    new Thread(null, new Runnable() {
      @Override
      public void run() {
        long start = System.currentTimeMillis();
        String debug = args.length > 0 ? args[0] : null;
        if (debug != null) {
          try {
            is = java.nio.file.Files.newInputStream(java.nio.file.Paths.get(debug));
          } catch (Exception e) {
            throw new RuntimeException(e);
          }
        }
        reader = new java.io.BufferedReader(new java.io.InputStreamReader(is), 32768);
        solve();
        out.flush();
        tr((System.currentTimeMillis() - start) + "ms");
      }
    }, "", 64000000).start();
  }

  private static java.io.InputStream is = System.in;
  private static java.io.PrintWriter out = new java.io.PrintWriter(System.out);
  private static java.util.StringTokenizer tokenizer = null;
  private static java.io.BufferedReader reader;

  public static String next() {
    while (tokenizer == null || !tokenizer.hasMoreTokens()) {
      try {
        tokenizer = new java.util.StringTokenizer(reader.readLine());
      } catch (Exception e) {
        throw new RuntimeException(e);
      }
    }
    return tokenizer.nextToken();
  }

  private static double nd() {
    return Double.parseDouble(next());
  }

  private static long nl() {
    return Long.parseLong(next());
  }

  private static int[] na(int n) {
    int[] a = new int[n];
    for (int i = 0; i < n; i++)
      a[i] = ni();
    return a;
  }

  private static char[] ns() {
    return next().toCharArray();
  }

  private static long[] nal(int n) {
    long[] a = new long[n];
    for (int i = 0; i < n; i++)
      a[i] = nl();
    return a;
  }

  private static int[][] ntable(int n, int m) {
    int[][] table = new int[n][m];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        table[i][j] = ni();
      }
    }
    return table;
  }

  private static int[][] nlist(int n, int m) {
    int[][] table = new int[m][n];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        table[j][i] = ni();
      }
    }
    return table;
  }

  private static int ni() {
    return Integer.parseInt(next());
  }

  private static void tr(Object... o) {
    if (is != System.in)
      System.out.println(java.util.Arrays.deepToString(o));
  }
}




Measured memory_bytes: 21332
# coding: utf-8
N, C, K = map(int, input().split())
T = []
for i in range(N):
    t = int(input())
    T.append(t)
T.sort()
# print(T)
ans = 0
idx = 0
s = T[0]
cnt = 1
for i in range(1,N):
    if cnt >= C:
        ans += 1
        cnt = 1
        s = T[i]
    else:
        if T[i] - s <= K:
            cnt += 1
        else:
            ans += 1
            cnt = 1
            s = T[i]
if cnt != 0:
    ans += 1
print(ans)

Measured memory_bytes: 7388
#include<bits/stdc++.h>
using namespace std;
 
/*
*****************code written By**********************
..................Marajul islam.......................
...................BSMRSTU,CSE........................
*/ 
 
int sc1() {int x; scanf("%d", &x); return x;}
 
long long sc2() {long long x; scanf("%lld", &x); return x;}
 
 
 
#define  gcd(a,b)         __gcd(a,b)
#define  lcm(a,b)         (a*b)/gcd(a,b)
#define  Int              sc1()
#define  LL               sc2()
#define  For(n)           for(int i=0;i<n;i++)
#define  Forj(n)          for(int j=0;j<n;j++)
#define  Fork(n)          for(int k=0;k<n;k++)
#define  For1(n)          for(int i=1;i<=n;i++)
#define  ll               long long
#define  vi               std::vector<int>
#define  vll              std::vector<ll>
#define  qui              qu
#define  pb               push_back
#define  mpsi             std::map<string, int>
 
 
const int mod           = 1e9 + 7;
const int inf           = (int)2e9 + 5;
const ll  Inf           = (ll)1e18 + 5;
const int N             = 5e6 + 5;
 
inline int add(int a, int b) {a += b; return a >= mod ? a - mod : a;}
inline int sub(int a, int b) {a -= b; return a < 0 ? a + mod : a;}
inline int mul(int a, int b) {return (ll)a * b % mod;}
 

 
 
int solve() {
 
	ll n,k;
	cin>>n>>k;
	ll arr[n+1];
	For(n) arr[i]=LL;
	sort(arr,arr+n);
	ll sum=0;
	for(int i=0;i<n-k;i++){
		sum+=arr[i];
	}
	cout<<sum<<endl;
 
	return 0;
}
 
 
 
 
int main()
{
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
 
	int test = 1, tc = 0;
	//scanf("%d", &test);
	//cin >> test;
	while (test--) {
		//printf("Case %d: ", ++tc);
		solve();
	}
 
	return 0;
 
 
 
 
}




Measured memory_bytes: 1792
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define USE_LLONG_AS_INT
#ifdef USE_LLONG_AS_INT
#define int long long
#define inf (1ll<<60)
#else
#define inf (1<<30)
#endif
#define rep(i,n) for(int i=0;i<n;i++)
#define Rep(i,a,b) for(int i=a;i<b;i++)
#define REP(i,a,b) for(int i=a;i<=b;i++)
#define rev(i,n) for(int i=n-1;i>=0;i--)
#define vi vector<int>
#define vvi vector<vi>
#define pb push_back
#define pi pair<int,int>
#define vp vector<pair<int,int>>
#define mp make_pair
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define MEMSET(a) memset(a,0,sizeof(a))
#define Yes(f) cout<<(f?"Yes":"No")<<endl
#define yes(f) cout<<(f?"yes":"no")<<endl
#define YES(f) cout<<(f?"YES":"NO")<<endl
#define SORT(v) sort(all(v))
#define RSORT(v) sort(all(v), greater<int>())

using namespace std;

const int mod=1e9+7;
const string sp=" ";

void run();

void init() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout<<fixed<<setprecision(12);
}

signed main(){
    init();
    run();
    return 0;
}

void run(){
    int n,m,k;
    cin>>n>>m>>k;
    vi d(m);
    rep(i,m){
        cin>>d[i];
        d[i]--;
    }
    vvi v(n,vi(k));
    rep(i,n)rep(j,k){
        cin>>v[i][j];
        v[i][j]--;
    }
    int id[n];
    memset(id,-1,sizeof(id));
    rep(i,m)id[d[i]]=i;
    int dp[1<<m];
    memset(dp,-1,sizeof(dp));
    dp[(1<<m)-1]=0;
    queue<int> q;
    q.push((1<<m)-1);
    while(!q.empty()){
        int s=q.front();
        q.pop();
        rep(i,k){
            int ns=s;
            int mask=0;
            rep(j,m){
                if((s>>j)&1){
                    ns^=(1<<j);
                    if(~id[v[d[j]][i]])mask|=1<<id[v[d[j]][i]];
                }
            }
            ns|=mask;
            if(!~dp[ns]&&s!=ns){
                dp[ns]=dp[s]+1;
                q.push(ns);
            }
        }
    }
    cout<<dp[0]<<endl;
}


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

public class Main {
	static int mod = (int) 1e9 + 7;
	static int DX[] = { -1, 0, 1, 0 }, DY[] = { 0, -1, 0, 1 };

	public static void main(String[] args) {
		FastScanner fs = new FastScanner(System.in);
		String S = fs.next();
		char c = S.charAt(0);
		System.out.println((char)(c+1));
	}
}

//高速なScanner
class FastScanner {
	private BufferedReader reader = null;
	private StringTokenizer tokenizer = null;

	public FastScanner(InputStream in) {
		reader = new BufferedReader(new InputStreamReader(in));
		tokenizer = null;
	}

	public String next() {
		if (tokenizer == null || !tokenizer.hasMoreTokens()) {
			try {
				tokenizer = new StringTokenizer(reader.readLine());
			} catch (IOException e) {
				throw new RuntimeException(e);
			}
		}
		return tokenizer.nextToken();
	}

	public String nextLine() {
		if (tokenizer == null || !tokenizer.hasMoreTokens()) {
			try {
				return reader.readLine();
			} catch (IOException e) {
				throw new RuntimeException(e);
			}
		}
		return tokenizer.nextToken("\n");
	}

	public long nextLong() {
		return Long.parseLong(next());
	}

	public int nextInt() {
		return Integer.parseInt(next());
	}

	public double nextDouble() {
		return Double.parseDouble(next());
	}

	public int[] nextIntArray(int n) {
		int[] a = new int[n];
		for (int i = 0; i < n; i++)
			a[i] = nextInt();
		return a;
	}

	public long[] nextLongArray(int n) {
		long[] a = new long[n];
		for (int i = 0; i < n; i++)
			a[i] = nextLong();
		return a;
	}
}

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

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

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

    string S; cin >>S;

    int c = 0;
    rep1(i, S.size()) if (S[i] != S[i-1]) c++;

    cout << c << endl;
}


Measured memory_bytes: 512
fn main() {
    let mut input = String::new();
    std::io::stdin().read_line(&mut input).expect("Input error");
    let mut room = vec![vec![0i32; 10]; 12];
    for _ in 0..input.trim().parse::<u32>().expect("Parse error") {
        input = String::new();
        std::io::stdin().read_line(&mut input).expect("Input error");
        let data = input
            .trim()
            .split_whitespace()
            .map(|x| x.parse::<i32>().expect("Parse error"))
            .collect::<Vec<i32>>();
        room[(data[0] as usize - 1) * 3 + data[1] as usize - 1][data[2] as usize - 1] += data[3];
    }
    for i in 0..12 {
        println!(
            " {}",
            room[i]
                .iter()
                .map(|x| x.to_string())
                .collect::<Vec<String>>()
                .join(" ")
        );
        if (i + 1) % 3 == 0 && i != 0 && i != 11 {
            println!("####################");
        }
    }
}



Measured memory_bytes: 5032
#include<iostream>
#include<string>
#include<set>
#include<vector>
#include<algorithm>

using namespace std;

int main() {
    string s; cin >> s;
    int k; cin >> k;
    set<string> substr;
    int limit = min(k, (int)s.size());
    for(int i=1; i<=limit; ++i) {
        // O(k)
        for(int j=0; j<=s.length()-i; ++j) {
            // O(N)
            string tmp = "";
            for(int k=0; k<=i-1; k++) {
                tmp += s[j+k];
            }
            substr.insert(tmp);
        }
        
    }
    vector<string> substrs;
    for(auto str:substr) {
        substrs.push_back(str);
    }

    cout << substrs[k-1] << endl;
    return 0;
}

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

int main() {
  long long x;
  cin >> x;
  long long y = 100;
  long long i = 0;
  while(y < x){
    y = y*1.01;
    i++;
  }
  cout << i << endl;
  
}


Measured memory_bytes: 3648
#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m;
  cin >> n >> m;
  map<int, int> pn;
  for(int i = 1; i <= n; ++i) pn[i] = 0;
  int ac = 0;
  int wa = 0;
  for(int i = 0; i < m; ++i) {
    int p;
    string s;
    cin >> p >> s;
    map<int, int>::iterator find = pn.find(p);
    if(find != pn.end()) {
      if(s.compare("AC") == 0) {
        ac++;
        wa += find->second;
        pn.erase(p);
      } else if(s.compare("WA") == 0) {
        (find->second)++;
      }
    }
  }
  cout << ac << " " << wa << endl;
  return 0;
}

Measured memory_bytes: 4992
d,g=map(int,input().split())
p=[0]*d
c=[0]*d
for i in range(d):
  p[i],c[i]=map(int,input().split())
ans=sum(p)
for i in range(1<<d):
  a=[]
  cnt=0
  pt=0
  for j in range(d):
    if (i>>j)&1:
      pt+=p[j]*(j+1)*100+c[j]
      cnt+=p[j]
    else:a+=[(p[j],j+1)]
  if pt<g:
    j,k=a[-1]
    cnt+=(g-pt+k*100-1)//(k*100)
    pt+=k*100*j
  if pt>=g:ans=min(ans,cnt)
print(ans)

Measured memory_bytes: 74244
#include <algorithm>
#include <iostream>
#include <string>

int main() {
  int N;
  std::string s;
  std::cin >> N >> s;
  if (std::count(s.begin(), s.end(), 'B') < std::count(s.begin(), s.end(), 'R')) {
    std::cout << "Yes\n";
  } else {
    std::cout << "No\n";
  }
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <cmath>
using namespace std;
int main(void){
  double x1, x2, y1, y2;
  cin >> x1 >> y1 >> x2 >> y2;
  cout << fixed << setprecision(5);
  cout << sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2)) << endl;
}


Measured memory_bytes: 3276
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define dup(x,y) (((x)+(y)-1)/(y))
#define ALL(x) (x).begin(), (x).end()
typedef long long ll;
typedef pair<int, int> pii;
const double EPS = 1e-10;
const int INF = 1e9;
const ll LINF = 1e15;
const int MOD = 1000000007;
const double PI = acos(-1);
int dx[4] = {0,1,0,-1};
int dy[4] = {1,0,-1,0};

int main() {
	int n, k;
	cin >> n >> k;
	vector<int> v(n);
	rep(i,n) cin >> v[i];
	int l = 0;
	int r = INF + 1;
	while (l + 1 < r) {
		int x = (l + r) / 2;
		int t = 0;
		for (int p: v) {
			if (p <= x) continue;
			t += p/x;
		}
		if (t <= k) r = x;
		else l = x;
	}
	cout << r << endl;
}

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

int main()
{
	int X,Y;
	cin >> X >> Y;
	int ans = 0;
	if (X <= 3)
	{
		ans += (4-X) * 100000;
	}

	if (Y <= 3)
	{
		ans += (4-Y) * 100000;
	}

	if (X == 1 && Y == 1)
	{
		ans += 400000;
	}

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

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

using namespace std;

const int N = 1e5 + 5;
int n, k, h[N], ans, dp[N];

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

	cin>>n>>k;
	for(int i=1;i<=n;++i)cin>>h[i];

	for(int i=2;i<=n;++i){
		int val = 2e9;
		for(int j=i - 1;j >= i - k && j >= 1; --j)
			val = min(val, dp[j] + abs(h[i] - h[j]));
		dp[i] = val;
	}
	cout<<dp[n]<<"\n";
	return 0;
}

Measured memory_bytes: 1024
import java.util.Scanner;
class Main {
	public static void main (String[] args){
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
    System.out.printf("%d %d %.5f\n", a/b, a%b, (double)a/(double)b);
	}
}


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

using ll = long long;

const int INF = 1001001001;
const ll INF_LL = 1001001001001001001LL;

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


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

int main() {
	int N;
	cin >> N;
	map<int, int> Nums;
	for (int i = 0; i < N; i++) {
		int a;
		cin >> a;
		Nums[a]++;
	}
	int ans = 0;
	for (const auto& p : Nums) ans += (p.second - p.first >= 0 ? p.second - p.first : p.second);
	cout << ans << endl;
}


Measured memory_bytes: 4736
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define perl(i,r,l) for(ll i=r-1;i>=l;i--)
#define fi first
#define se second
#define pb push_back
#define ins insert
#define all(x) (x).begin(),(x).end()
using ll=long long;
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9+10;
const ll INF=4e18;
const ll dy[8]={1,0,-1,0,1,1,-1,-1};
const ll dx[8]={0,-1,0,1,1,-1,1,-1};
using Graph = vector<vector<int>>;
double nCk(int n, int k) {
double res=1.0;
for(int i=0; i<n; i++){
res*=0.5;}
for(int i=0; i<k; i++){
res*=(double)(n-i);
res/=(double)(k-i);
}
return res;}
struct edge{ll to, cost;};
typedef pair<ll,ll> P;
struct graph{
  ll V;
  vector<vector<edge> > G;
  vector<ll> d;

  graph(ll n){
    init(n);
  }

  void init(ll n){
    V = n;
    G.resize(V);
    d.resize(V);
    rep(i,V){
      d[i] = INF;
    }
  }

  void add_edge(ll s, ll t, ll cost){
    edge e;
    e.to = t, e.cost = cost;
    G[s].push_back(e);
  }

  void dijkstra(ll s){
    rep(i,V){
      d[i] = INF/10;
    }
    d[s] = 0;
    priority_queue<P,vector<P>, greater<P> > que;
    que.push(P(0,s));
    while(!que.empty()){
      P p = que.top(); que.pop();
      ll v = p.second;
      if(d[v]<p.first) continue;
      for(auto e : G[v]){
        if(d[e.to]>d[v]+e.cost){
          d[e.to] = d[v]+e.cost;
          que.push(P(d[e.to],e.to));
        }
      }
    }
  }
};
int main() {
 ll n; cin>>n;
  ll k = 0;
  ll wa = 0;
  ll ans = 0;
  rep(i,n){
    ll a,b; cin>>a>>b;
    wa += a*b;
    k += b;
  }
  ll f;
  while(wa>=10){
    f = wa%10;
    wa/=10;
    k+=wa;
    wa +=f;}
  cout << k-1 << endl;}


Measured memory_bytes: 3564
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<functional>
#include<iomanip>
#include<iostream>
#include<numeric>
#include<math.h>
#include<map>
#include<queue>
#include<set>
#include<string>
#include<utility>
#include<vector>
// 追加１
#include <fstream>



using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const ll mod = 1000000007;
#define rep(i,n) for(int i=0;i<n;i++)
#define repl(i,s,e) for(int i=s;i<e;i++)
#define reple(i,s,e) for(int i=s;i<=e;i++)
#define revrep(i,n) for(int i=n-1;i>=0;i--)
#define all(x) (x).begin(),(x).end()

int main()
{
    int A, B, C, D;
    cin >> A >> B >> C >> D;

    
    while (A > 0 && B > 0)
    {
        A -= D;
        C -= B;
    }

    if (C <= 0)
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }

    return 0;
}

Measured memory_bytes: 3624
package main

import "fmt"

func main() {
	var n int
	fmt.Scan(&n)
	a := make([]int, n)
	for i := 0; i < n; i++ {
		fmt.Scan(&a[i])
	}

	res := 0
	loop := true
	for {
		for i := 0; i < len(a); i++ {
			if a[i] == 0 || a[i]%2 == 1 {
				loop = false
				break
			} else {
				a[i] = a[i] / 2
			}
		}
		if !loop {
			break
		}
		res++
	}
	fmt.Printf("%v", res)
}


Measured memory_bytes: 512
/*

                                  In the name of Allah, Most Gracious, Most Merciful


*/
#include<bits/stdc++.h>
#include<numeric>
using namespace std;

//*** constant value ***
const long double PI = 3.141592653589793238;
const double EPS = 1e-6 ;
//*** constant value ***

//****** define ********
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ll long long
#define dd double
#define vll vector<ll>
#define vs vector<string>
#define fn(i,n) for(ll i = 0; i<n; i++)
#define f(i,a,b) for(i=a;i<b;i++)
#define f1(i,a,b) for(i=b-1;i>=a;i--)
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pls pair<ll,string>
#define vpl vector<pll>
#define pb push_back
#define mk make_pair
#define x first
#define y second
#define tt cout<<"Came here"<<endl;
//****** define ********

const long long mod = 1000000007;


int main()
{
    IOS;
    ll n;
    cin>>n;
    vll v1(n), v2(n);

    fn(i,n)
    {
        cin>>v1[i];
        if(i > 0)
              v2 [i] = v1[i] + v2[i-1];
    }

    ll ans = 0;

    fn(i,n)
    {
          ll sum = (v2[n-1] - v2[i]) % mod;
          ans += (sum*v1[i] );

          ans %= mod;
    }

    cout<<ans<<endl;


return 0;
}


Measured memory_bytes: 6376
#include <bits/stdc++.h>
#include <typeinfo>
#include <cxxabi.h>
#ifdef LOCAL
#include "dbgtoki.hpp"
#define DUMP(i) dump((string)TOSTRING(i), demangle(typeid(i).name()), __LINE__ , i) 
#else
#define DUMP(i) 
#endif

#define TOSTRING(x) #x
#define SZ(x) (int)(x).size()
#define REP(i,n) for(int i=0;i<(n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define ALL(s) (s).begin(), (s).end()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()) , v.end());

using namespace std;
typedef long long unsigned int llu;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
const int EPS = 1e-9;
const int MOD = 1e9+7;

int main (){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int d,n;
  cin >> d >> n;
  int f;
  int ans = 0;
  if(d == 0){
    ans = 1;
    f = 1;
  }else if(d==1){
    ans = 100;
    f = 100;
  }else{
    ans = 10000;
    f = 10000;
  }
  ans *= n;
  if(n == 100)ans += f;
  cout << ans << endl;
  return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
#define ll long long
#define rep(i,n) for (ll i = 0; i < (ll)(n); ++i)
#define be(v) (v).begin(), (v).end()
#define dcout cout << fixed << setprecision(20) 
ll INF = 1LL << 60;
ll mod = 1e9 + 7;

int main() {
  string a;
  cin>>a;
  int count=0;
  int answer=0;
  
  for(int i=0;i<a.size();i++){
    if(a.at(i)=='A') count++;
    if(a.at(i)=='C') count++;
    if(a.at(i)=='G') count++;
    if(a.at(i)=='T') count++;
    answer=max(answer,count);
    if(a.at(i)!='A'&&a.at(i)!='C'&&a.at(i)!='G'&&a.at(i)!='T') count=0;
  }
  cout<<answer<<endl;
}

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

using namespace std;

#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define sz(a) (int)a.size()
#define fi first
#define se second
#define ar array

typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int > pii;
const ll MOD =1e9+7;

void solve(){
	int n, k; cin >> n >> k;
	int cnt[k];
	memset(cnt,0,sizeof cnt);
	for(int i = 1; i <= n; ++i)
		cnt[i%k]++;
	ll ans= 1LL*cnt[0]*cnt[0]*cnt[0];
	if(k%2==0)
		ans += 1LL*cnt[k/2]*cnt[k/2]*cnt[k/2];
	cout << ans;
}
int main(){
	int t=1;
	//cin >> t;
	while(t--){
		solve();
		cout <<'\n';
	}
}


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

using namespace std;

#define int long long
#define FOR(i, j, k) for(int i = j; i < k; ++i)
#define rep(i, j) FOR(i, 0, j)
#define INF 1e9
#define LINF 1e18

typedef unsigned long long ull;
typedef pair<int, int> P;
typedef pair<P, int> Pi;
typedef pair<P, P> PP;

const int MOD = 1e9 + 7;
const int dy[]={0, 0, 1, -1};
const int dx[]={1, -1, 0, 0};

template <class T> void chmin(T& a, const T& b) { a = min(a, b); }
template <class T> void chmax(T& a, const T& b) { a = max(a, b); }

int N;
int A[100002], sum[100002];

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

    cin >> N;
    FOR(i, 1, N + 1) cin >> A[i];
    FOR(i, 1, N + 1) sum[i] = sum[i - 1] + abs(A[i] - A[i - 1]);
    sum[N + 1] = sum[N] + abs(A[N]);
    FOR(i, 1, N + 1) {
        int res = sum[N + 1] - abs(A[i] - A[i - 1]) - abs(A[i + 1] - A[i]);
        res += abs(A[i + 1] - A[i - 1]);
        cout << res << endl;
    }
    return 0;
}

Measured memory_bytes: 2816
import sys
from collections import deque


def main():
    line = sys.stdin.readlines()
    deq = deque()
    for i in range(1, int(line[0]) + 1):
        input_command = line[i]

        if input_command[0] == 'i':         # 'insert index'
            deq.appendleft(input_command[7:-1])
        elif input_command[0] == 'd':
            if input_command[6] == ' ':     # 'delete index'
                key = input_command[7:-1]
                if key in deq:
                    deq.remove(key)
            elif input_command[6] == 'F':   # 'deleteFirst':
                deq.popleft()
            elif input_command[6] == 'L':   # 'deleteLast':
                deq.pop()

    print(' '.join(deq))
    return


main()


Measured memory_bytes: 212224
#include <iostream>
#include <stdlib.h>
//#include <string.h>

using namespace std;

int main()
{
    long x,d,r,i=10;
    cin>>r>>d>>x;
    while(i--)
    {
        x=r*x-d;
        cout<<x<<endl;
    }

    return 0;
}


Measured memory_bytes: 3640
n,k=map(int,input().split())
s=input()

rl=s.count('RL')
if s[0]=='L':
    start=1
else:
    start=0
if s[-1]=='R':
    end=1
else:
    end=0
a=rl-k
if a>=1:
    ans=a*2+start+end
elif a==0:
    ans=start+end
elif a<=-1:
    ans=1
print(n-ans)


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

const int INF = 100100100;
const int MOD = (int)1e9 + 7;
typedef long long ll;

int main(){
    int n; cin >> n; map <ll, ll> mp;
    ll sum = 0;mp[sum] = 1;
    for(int i = 0; i<n; ++i) {
        ll tmp; cin >> tmp;
        sum += tmp;
        if(mp.count(sum)) ++mp[sum];
        else mp[sum] = 1;
    }
    ll ans = 0;
    for(auto x : mp){
        if(x.second != 1)ans += x.second*(x.second-1)/2;
    }
    cout << ans << endl; return 0;
}

Measured memory_bytes: 12800
import sys

S = list(input())
K = int(input())
 
T = S + S

flag = 0
c = S[0]
for i in range(len(S) - 1):
    if c != S[i + 1]:
      flag = 1

if flag == 0:
  print(len(S) * K // 2)
  sys.exit()

countA = 0
for i in range(len(S) - 1):
    if S[i] == S[i + 1]:
        countA += 1
        S[i + 1] = 'A'
 
# 2bai
countB = 0
for i in range(len(T) - 1):
    if T[i] == T[i + 1]:
        countB += 1
        T[i + 1] = 'A'
tmp = countB - (2*countA)
print((countA * K) + (tmp * (K - 1)))


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

 
using namespace std;
 
#define ll long long
#define ul unsigned long long
#define snd second
#define fst first


int main(){
    std::ios::sync_with_stdio(false);
    ll a, b; cin >> a >> b;
    if(a == b) cout << "Yes";
    else cout << "No";
    return 0;
}


Measured memory_bytes: 256