akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#pragma GCC optimize("O3")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define rep(i,N) for(int i=0;i<(int)N;i++)
const long LMIN=0x8000000000000000l;
struct TAG{long* array;int size,head,tail,count;};
typedef struct TAG* DEQUE;
static inline void PUT(char c)
{
  static char buf[1<<15],*ptr=buf;
  if(ptr==buf+strlen(buf)||c==0){fwrite(buf,1,ptr-buf,stdout),ptr=buf;}*ptr++=c;
}
static inline long IN(void)
{
  long x=0,f=0,c=getchar();while(c<48||c>57){f^=c==45,c=getchar();}
  while(c>47&&c<58){x=x*10+c-48,c=getchar();}return f?-x:x;
}
static inline void OUT(long a)
{
  if(a<0)PUT('-'),a=-a;
  int d[40],i=0;do{d[i++]=a%10;}while(a/=10);
  while(i--){PUT(d[i]+48);}PUT('\n');
}
static inline long Max(const long x,const long y){return x<y?y:x;}
static inline void* xmalloc(size_t size){void* p=malloc(size);if(p==NULL){exit(EXIT_FAILURE);}return p;}
static inline DEQUE CREATE(void)
{
  const int size=10000;
  struct TAG* deque=(DEQUE)xmalloc(sizeof(struct TAG));
  deque->array=(long*)xmalloc(sizeof(long)*size);
  deque->size=size;deque->head=deque->tail=deque->count=0;return deque;
}
static inline void DELETE(DEQUE deque){free(deque->array);free(deque);}
static inline int PREV(DEQUE deque,int index){return(!index)?deque->size-1:index-1;}
static inline int NEXT(DEQUE deque,int index){return(index+1)%deque->size;}
static inline void PUSH(DEQUE deque,long val,int back)
{
  //front=0,back=1;
  if(deque->count==deque->size){exit(EXIT_FAILURE);}
  if(back)deque->tail=NEXT(deque,deque->tail);else deque->head=PREV(deque,deque->head);
  deque->array[(back)?deque->tail:deque->head]=val;deque->count++;
  if(deque->count==1){if(back)deque->head=deque->tail;else deque->tail=deque->head;}
}
static inline long POP(DEQUE deque,int back)
{
  if(!deque->count){exit(EXIT_FAILURE);}
  long val=deque->array[(back)?deque->tail:deque->head];
  if(back)deque->tail=PREV(deque,deque->tail);else deque->head=NEXT(deque,deque->head);
  deque->count--;return val;
}
int main(void)
{
  int N=IN(),K=IN(),C[5000],P[5000],vis[5000]={0};long score=LMIN,vector[15000];
  rep(i,N){P[i]=IN()-1;}rep(i,N){C[i]=IN();score=Max(score,C[i]);}if(score<0){return OUT(score),0;}
  rep(i,N)
  {
    if(vis[i]){continue;}
    int len=0,now=K,sz=0,x=P[i];long high=LMIN,temp=0,y=1l*C[x];vis[i]=1;
    vector[sz++]=0,vector[sz++]=y;
    while(!vis[x]){vis[x]=1;x=P[x];y+=1l*C[x];vector[sz++]=1l*C[x];}
    if(y>0)
    {
      temp+=1l*Max(1l*now/(sz-1l)-1l,0l)*y;
      if(now>sz-1){now%=sz-1;now+=1l*sz-1l;}
    }
    len=sz;
    rep(j,len-1){vector[sz++]=1l*vector[j+1];}
    rep(j,len-1){vector[sz++]=1l*vector[j+1];}
    rep(j,sz-2){vector[j+2]+=1l*vector[j+1];}
    DEQUE dq=CREATE();PUSH(dq,0,0);
    rep(j,sz-1)
    {
      while(dq->count&&vector[dq->array[dq->head]]>vector[j+1]){POP(dq,0);}
      PUSH(dq,j+1,0);
      while(dq->count&&j+1-dq->array[dq->tail]>now){POP(dq,1);}
      if((j+1)!=dq->array[dq->tail]){high=1l*Max(1l*high,1l*vector[j+1]-1l*vector[dq->array[dq->tail]]);}
    }
    temp+=1l*high;score=1l*Max(score,temp);DELETE(dq);
  }
  return OUT(score),0;
}

Measured memory_bytes: 1752
#include <bits/stdc++.h>
 
using namespace std;
 
int main()
{
    int m, n1, n2;
    while(cin >> m >> n1 >> n2, m || n1 || n2){
    int P[201];
    for(int i = 0; i < m; i++) cin >> P[i];
    int ans = n1;
    for(int i = n1; i <= n2; i++){
        if(P[ans-1]-P[ans] <= P[i-1]-P[i]) ans = i;
    }
    cout << ans << endl;
    }
     
    return 0;
}

Measured memory_bytes: 3052
#include <iostream>

int main()
{
	using namespace std;
	int A, B, C;
	cin >> A;
	cin >> B;
	cin>> C;
	if (A == B) {
		cout << C;
	}
	if (B == C) {
		cout << A;
	}
	if (A==C){
		cout << B;
	}
	
}

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

int main()
{
  int N, K;
  cin >> N >> K;
  
  if(N % 2 == 0)
  {
    if(K <= N / 2)
    {
      cout << "YES" << endl;
      return 0;
    }
    else
    {
      cout << "NO" << endl;
      return 0;
    }
  }
  else
  {
    if(K <= N / 2 + 1)
    {
      cout << "YES" << endl;
      return 0;
    }
    else
    {
      cout << "NO" << endl;
      return 0;
    }
  }
}

Measured memory_bytes: 256
///B - Tap Dance

#include<bits/stdc++.h>
using namespace std;
#define ll long long

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

  char odd[3]={'R','U','D'};
  char even[3]={'L','U','D'};

  string str;

  cin>>str;

  int flag_odd=0,flag_even=0;

  for(int i=0;i<str.size();i++)
  {
      if(i%2==0)
      {
          for(int j=0;j<3;j++)
          {
              if(str[i]==odd[j])
              {
                  flag_odd++;
              }
          }

      }
      else if(i%2==1)
      {
          for(int j=0;j<3;j++)
          {
              if(str[i]==even[j])
              {
                  flag_even++;
              }
          }

      }
  }

  if(flag_even+flag_odd==str.size())
  {
       cout<<"Yes"<<"\n";

  }
  else
  {
      cout<<"No"<<"\n";
  }
  return 0;
}



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

using namespace std;

#define fst(t) std::get<0>(t)
#define snd(t) std::get<1>(t)
#define thd(t) std::get<2>(t)
#define unless(p) if(!(p))
#define until(p) while(!(p))

using ll = long long;
using P = std::tuple<int,int>;

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

tuple<int, int, int, int> f(int x){
    int n10, n50, n100, n500;
    n500 = x / 500;
    x %= 500;
    n100 = x / 100;
    x %= 100;
    n50 = x / 50;
    x %= 50;
    n10 = x / 10;
    return std::make_tuple(n10, n50, n100, n500);
}

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

    bool isFirst = true;

    while(true){
        int X, n10, n50, n100, n500;
        std::cin >> X;
        if(!X){break;}
        std::cin >> n10 >> n50 >> n100 >> n500;

        int r10 = -1, r50 = -1, r100 = -1, r500 = -1, mn = 10000;
        for(int i=0;i<=n10;++i){
            for(int j=0;j<=n50;++j){
                for(int k=0;k<=n100;++k){
                    for(int l=0;l<=n500;++l){
                        int sum = i * 10 + j * 50 + k * 100 + l * 500;
                        if(sum < X){continue;}
                        
                        int m10, m50, m100, m500;
                        tie(m10, m50, m100, m500) = f(sum - X);

                        if(min(i, m10) >= 1 ||
                           min(j, m50) >= 1 ||
                           min(k, m100) >= 1 ||
                           min(l, m500) >= 1){
                            continue;
                        }

                        if((m10 + m50 + m100 + m500) - (i + j + k + l) < mn){
                            tie(r10, r50, r100, r500) = std::make_tuple(i, j, k, l);
                            mn = (m10 + m50 + m100 + m500) - (i + j + k + l);
                        }
                    }
                }
            }
        }

        if(!isFirst){
            std::cout << std::endl;
        }
        vector<int> u = {r10, r50, r100, r500}, v = {10, 50, 100, 500};
        for(int i=0;i<4;++i){
            if(u[i] > 0){
                std::cout << v[i] << " " << u[i] << std::endl;
            }
        }

        isFirst = false;
    }
}



Measured memory_bytes: 3108
while True:
    data=[]
    n = int(input())
    if n==0:
        break
    for i in range(n):
        spam=list(map(int,input().split()))
        spam.append(sum(spam))
        data.append(spam)
    spam=[]
    for i in range(n+1):
        spam.append(sum(x[i] for x in data))
    data.append(spam)
    for i in range(n+1):
        for j in range(n+1):
            print('{:5}'.format(data[i][j]),end='')
        print('')

Measured memory_bytes: 6720
#include <algorithm>
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define ll long long
#define ld long double
#define INF 1000000000000000000
typedef pair<ll, ll> pll;

template <int MOD> struct Fp {
    long long val;
    constexpr Fp(long long v = 0) noexcept : val(v % MOD) {
        if (val < 0)
            v += MOD;
    }
    constexpr int getmod() { return MOD; }
    constexpr Fp operator-() const noexcept { return val ? MOD - val : 0; }
    constexpr Fp operator+(const Fp &r) const noexcept {
        return Fp(*this) += r;
    }
    constexpr Fp operator-(const Fp &r) const noexcept {
        return Fp(*this) -= r;
    }
    constexpr Fp operator*(const Fp &r) const noexcept {
        return Fp(*this) *= r;
    }
    constexpr Fp operator/(const Fp &r) const noexcept {
        return Fp(*this) /= r;
    }
    constexpr Fp &operator+=(const Fp &r) noexcept {
        val += r.val;
        if (val >= MOD)
            val -= MOD;
        return *this;
    }
    constexpr Fp &operator-=(const Fp &r) noexcept {
        val -= r.val;
        if (val < 0)
            val += MOD;
        return *this;
    }
    constexpr Fp &operator*=(const Fp &r) noexcept {
        val = val * r.val % MOD;
        return *this;
    }
    constexpr Fp &operator/=(const Fp &r) noexcept {
        long long a = r.val, b = MOD, u = 1, v = 0;
        while (b) {
            long long t = a / b;
            a -= t * b;
            swap(a, b);
            u -= t * v;
            swap(u, v);
        }
        val = val * u % MOD;
        if (val < 0)
            val += MOD;
        return *this;
    }
    constexpr bool operator==(const Fp &r) const noexcept {
        return this->val == r.val;
    }
    constexpr bool operator!=(const Fp &r) const noexcept {
        return this->val != r.val;
    }
    friend constexpr ostream &operator<<(ostream &os,
                                         const Fp<MOD> &x) noexcept {
        return os << x.val;
    }
    friend constexpr istream &operator>>(istream &is, Fp<MOD> &x) noexcept {
        return is >> x.val;
    }
    friend constexpr Fp<MOD> modpow(const Fp<MOD> &a, long long n) noexcept {
        if (n == 0)
            return 1;
        auto t = modpow(a, n / 2);
        t = t * t;
        if (n & 1)
            t = t * a;
        return t;
    }
};

const int MOD = 1000000007;
using mint = Fp<MOD>;

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

    int N;
    cin >> N;
    vector<mint> A(N), sum(N);
    rep(i, N) {
        cin >> A[i];
        sum[i] = A[i];
    }

    rep(i, N - 1) { sum[i + 1] += sum[i]; }

    mint ans = 0;
    rep(i, N) { ans += A[i] * (sum[N - 1] - sum[i]); }

    cout << ans << endl;
}

Measured memory_bytes: 6316
#include<bits/stdc++.h>
using namespace std;
long long a,b,c,d,e;
string s;
int main(){
    ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);
    cin>>s;
    a=s.size();
    for(b=0; b<a/2; b++){
        if(s[b]!=s[a-b-1]) c++;
    }
    cout<<c;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
typedef long long ll;
#define _GLIBCXX_DEBUG
typedef vector<int> vec;
typedef vector<ll> lvec;
typedef vector<char> cvec;
typedef vector<double> dvec;
typedef pair<ll, ll> LP;
typedef tuple<ll, ll, ll> LT;
typedef pair<int, int> P;
typedef tuple<int, int, int> T;
#define fs first
#define sc second
int main()	{
  int a,b;
  cin>>a>>b;
  int c=max(a-b,a+b);
  int d=max(c,a*b);
  cout<<d<<endl;
}

Measured memory_bytes: 3584
input()
nums = map(int, input().split())
result = 32
for num in nums:
  if (num & 1) == 1:
    result = 0
    break
  num = num >> 1
  div_times = 1

  while (num & 1) == 0:
    num = num >> 1
    div_times += 1
  if div_times < result:
    result = div_times
print(result)

Measured memory_bytes: 3060
import Control.Monad

toInt :: String -> Int
toInt = read :: String -> Int

main = do
  a <- map toInt <$> replicateM 5 getLine
  let s = sum . map (* 10) . map ceiling . map (/ 10) . map fromIntegral $ a
  let l = maximum $ map (\x -> mod (10 - (mod x 10)) 10) a
  print $ (s - l)


Measured memory_bytes: 3868
#include <limits.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <algorithm>
#include <cassert>
#include <cfloat>
#include <complex>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef vector<ll> vll;
typedef vector<vector<ll> > vvll;
typedef deque<ll> dqll;

#define MOD 1000000007

int main() {
  ll A, B;
  cin >> A >> B;
  A--;
  B--;

  puts("100 100");
  for (int i = 1; i <= 100; i++) {
    //printf("%d ", i);
    for (int j = 1; j <= 100; j++) {
      if (i % 2 == 1) {
        if (j <= 50)
          printf(".");
        else
          printf("#");
      } else {
        if(j <= 50 ){
          if (j <= 48 && j % 2 == 0 && B > 0) {
            printf("#");
            B--;
          } else {
            printf(".");
          }
        } else {
          if (j <= 98 && j % 2 == 0 && A > 0) {
            printf(".");
            A--;
          } else {
            printf("#");
          }
        }
      }
    }  // j
    printf("\n");
  }  // i

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <math.h>
#define _GLIBCXX_DEBUG
#define _LIBCPP_DEBUG 0

using namespace std;
#define ll long long
#define rep(i,n) for (int i = 0; i < n; i++)
#define MOD (1000000007)
#define vi vector<int>
#define vl vector<ll>
#define vvi vector<vi>
#define pii pair<int, int>
#define pb push_back
#define mp make_pair
#define all(a) (a).begin(),(a).end()

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

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

const ll INF = 1LL << 60;

const int dh[4] = {1,0,-1,0};
const int dw[4] = {0,1,0,-1};

int main(){
  int n; cin >> n;
  vl a(n); rep(i, n) cin >> a[i];
  vl s(n+1); rep(i, n) s[i+1] = s[i] + a[i];

  ll ans = INF;
  rep(i, n) chmin(ans, abs(s[n] - 2*s[i+1]));

  std::cout << ans << '\n';

}


Measured memory_bytes: 3456
#include <iostream>
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <string>
#include <vector>
#include <queue>
using namespace std;
typedef long long ll;
const int INF = 1<<30;
const ll MOD = 1e9+7;
const double EPS = 1e-9;

struct UnionFind {
  vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2
  
  UnionFind(int N) : par(N) { //最初は全てが根であるとして初期化
    for(int i = 0; i < N; i++) par[i] = i;
  }
  
  int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
    if (par[x] == x) return x;
    return par[x] = root(par[x]);
  }
  
  void unite(int x, int y) { // xとyの木を併合
    int rx = root(x); //xの根をrx
    int ry = root(y); //yの根をry
    if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
    par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
  }
  
  bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
    int rx = root(x);
    int ry = root(y);
    return rx == ry;
  }
};


int main(int argc, const char * argv[]) {
  int N, M;
  cin >> N >> M;
  vector<int> X(M), Y(M);
  for (int i=0; i<M; i++){
    int Z;
    cin >> X[i] >> Y[i] >> Z;
  }
  
  UnionFind tree(N);
  for (int i=0; i<M; i++){
    tree.unite(X[i]-1, Y[i]-1);
  }
  
  set<int> parent;
  for (int i=0; i<N; i++){
    parent.insert(tree.root(i));
  }
  
  cout << parent.size() << endl;
  return 0;
}

Measured memory_bytes: 6016
#include <stdio.h>
int main(void){
    // Your code here!
    int x,a;
    scanf("%d\n", &x);
    int b[x];
    
    for (int i=0;i<x;i++) {
        b[i] = 0;
    }
    
    for(int i=0;i<x-1;i++){
        scanf("%d", &a);
        b[a-1]+=1;
    }
    
    for(int i=0;i<x-1;i++){
        printf("%d\n",b[i]);
    }
    
    printf("0");
        
    }


Measured memory_bytes: 2452
#include <bits/stdc++.h>
using namespace std;
const int N=2e5+10;
double ans,ansnow;
int n,k,l,r,a[N];
double get(int x){
    return (double)(x+1)/2;
}
int main(){
    scanf("%d%d",&n,&k);
    for(int i=1;i<=n;i++)cin>>a[i];
    l=1,r=k;
    for(int i=l;i<=r;i++)ansnow+=get(a[i]);
    ans=ansnow;
    while(r<n){
        ansnow-=get(a[l]);ansnow+=get(a[r+1]);
        r++;l++;
        ans=max(ans,ansnow);
    }
    printf("%.10lf",ans);
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define fsp(x) fixed << setprecision(x)
#define xout cerr
const ll inf = LLONG_MAX;
const long double pi = acosl(-1);
void Yes() {cout << "Yes" << endl;}
void No() {cout << "No" << endl;}
void YES() {cout << "YES" << endl;}
void NO() {cout << "NO" << endl;}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    //const ll p = 1e9 + 7;
    //const ll p = 998244353;
    
    ll d;
    cin >> d;
    vector<ll> c(26);
    for (ll i = 0; i < 26; i++) cin >> c[i];
    vector<vector<ll>> s(d, vector<ll>(26));
    for (ll i = 0; i < d; i++) {
        for (ll j = 0; j < 26; j++) {
            cin >> s[i][j];
        }
    }
    
    vector<ll> ans(d);
    for (ll i = 0; i < d; i++) ans[i] = i % 26;
    
    /*auto calc_score = [&] () {
        vector<vector<ll>> v(26, vector<ll>(1, 0));
        for (ll i = 0; i < d; i++) v[ans[i]].push_back(i);
        ll ret = 0;
        for (ll i = 0; i < d; i++) {
            ret += s[i][ans[i]];
            for (ll j = 0; j < 26; j++) {
                auto itr = upper_bound(all(v[j]), d) - 1;
                ret -= c[j] * (i - *itr);
            }
        }
        return ret;
    }*/
    
    for (ll i = 0; i < d; i++) cout << i % 26 + 1 << endl;
}


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

int main() {
  double N,T,A,dif = 10000;
  cin >> N >> T >> A;
  vector<double> vec(N);
  int n = 0; //番号
  for (int i = 0; i < N; i++){
    cin >> vec.at(i);
    vec.at(i) = A - (T - vec.at(i) * 0.006);
    if(vec.at(i) < 0) vec.at(i) *= (-1);
    
    if (vec.at(i) < dif) {
      dif = vec.at(i);
      n = i;
    }
  }
  cout << n + 1 << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string w;
  cin >> w;
  
  if (w == "Sunny") cout << "Cloudy" << endl;
  if (w == "Cloudy") cout << "Rainy" << endl;
  if (w == "Rainy") cout << "Sunny" << endl;
}


Measured memory_bytes: 256
#include <bitset>
#include <cstdio>
#include <vector>
#include <algorithm>
using namespace std;
int V, E, a, b, col[100009]; bool flag; vector<int> g[100009];
void dfs(int pos) {
	a++;
	if (col[pos] == 1) b++;
	for (int i : g[pos]) {
		if (col[pos] == col[i]) flag = true;
		if (!col[i]) col[i] = 3 - col[pos], dfs(i);
	}
}
int main() {
	scanf("%d %d", &V, &E);
	for (int i = 0; i < E; i++) {
		scanf("%d %d", &a, &b); a--, b--;
		g[a].push_back(b);
		g[b].push_back(a);
	}
	bitset<100001> dp = 1;
	int cur = 0;
	for (int i = 0; i < V; i++) {
		if (!col[i]) {
			a = b = 0; col[i] = 1;
			dfs(i);
			if (b * 2 > a) b = a - b;
			cur += b;
			dp |= dp << (a - b * 2);
		}
	}
	long long ret = 0;
	for (int i = cur; i <= V; i++) {
		if (dp[i - cur]) ret = max(ret, 1LL * i * (V - i));
	}
	printf("%lld\n", (flag ? -1LL : ret - E));
	return 0;
}


Measured memory_bytes: 9168
import java.util.*;

public class Main{
	public static void main(String[] args){
		Scanner sc=new Scanner(System.in);
		int N=Integer.parseInt(sc.nextLine());
		int d[]=new int[N];
		for(int i=0;i<N;i++){
			d[i]=Integer.parseInt(sc.nextLine());
		}
		int X=N;
		int buf;
		for(int i=0;i<N;i++){
			buf=d[i];
			for(int j=0;j<i;j++){
				if(buf==d[j]&&d[j]!=0){
					X-=1;
					d[j]=0;
				}
			}
		}
		System.out.println(X);
	}
}


Measured memory_bytes: 21844
x,n=map(int,input().split())
p=list(map(int,input().split()))

ans=1000

for i in range(1,101):
    if abs(x-ans)>abs(x-i) and i not in p:
        ans=i

if x<=abs(x-ans):
    if x<=101-x:
        print(0)
    else:
        print(101)
else:
    if abs(x-ans)<=101-x:
        print(ans)
    else:
        print(101)


Measured memory_bytes: 9188
#include<stdio.h>
 
int main()
{
  char str[101];
  scanf("%s",str);
  int len;
  for(len = 0;str[len] != '\0'; ++len);
  int count = 0;
  for(int i = 0;i < len/2;++i)
  {
    if(str[i] != str[len-1-i])++count;
  }
  printf("%d",count);
}

Measured memory_bytes: 128
row = input().split(' ')
n = int(row[0])
m = int(row[1])
c = int(row[2])
b_list = [int(b) for b in input().split(' ')]
a_mat = list()
for _ in range(n):
    a_mat.append([int(a) for a in input().split(' ')])
ans = 0
for i in range(n):
    v = c + sum([a * b for a, b in zip(a_mat[i], b_list)])
    if v > 0:
        ans += 1
print(ans)

Measured memory_bytes: 3064
#include<cstdio>
#include<algorithm>
#include<queue>
#include<iostream>
#include<cmath>
#include<vector>
#include<set>
#include<stack>
#include<map>
#include<cstring>
#define eps 1e-8
#define pi acos(-1)
#define mp make_pair
#define PH push
#define pb push_back
#define PII pair<ll,ll>
#define VI vector<int>
#define fi first
#define se second
#define N(a,b) a=N(a,b)
#define Min(a,b) a=min(a,b)
#define sqr(x) ((x)*(x))
#define CL(a) memset(a,0,sizeof a)
#define fr(i,n) for(int i=1;i<=n;i++)
#define FR(i,S,n) for(int i=S;i<=n;i++)
#define dr(i,n) for(int i=n;i;i--)
#define DR(i,n,S) for(int i=n;i>=S;i--)
#define SZ(x) ((int)(x).size())
#define all(n) n.begin(),n.end()
#define rd(x) scanf("%d",&x)
#define pr(x) printf("%d",x)
#define prn(x) printf("%d\n",x)
typedef long long ll;
typedef unsigned long long ull;
ll expow(ll a,ll b,ll p) {ll v=1; for (; b; b>>=1,a=a*a%p)if (b&1)v=v*a%p; return v;}
ll inv(ll a,ll p) {return expow(a,p-2,p);}
using namespace std;
const int N=1000+10;
int a[N];
int main(){
    a[1]=1;
    for(int j=2;j<=1000;j++){
        int cnt=j*j;
        while(cnt<=1000){
            a[cnt]=1;
            cnt*=j;
        }
    }
    int n;
    cin>>n;
    while(a[n]==0) n--;
    printf("%d\n",n);
    return 0;
}


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

class Dijkstra {
public:
    struct edge { long long v, dist; };

    struct state {
        long long v, cost;
        bool operator>(const state s) const { return cost > s.cost; }
    };

    const long long INF = (1LL << 60);
    long long N;
    vector< vector<edge> > E;

    Dijkstra(long long n): N(n), E(n) {}

    //有効グラフの時はこっち。u→vに距離dで結ぶ
    void add_directed_edge(long long u, long long v, long long d) {
        E[u].push_back((edge) { v, d });
    }

    //無向グラフの時はこっち。uとvを双方向に距離dで結ぶ
    void add_undirected_edge(long long u, long long v, long long d) {
        E[u].push_back((edge) { v, d });
        E[v].push_back((edge) { u, d });
    }

    //Sを始点として、他の頂点への最短経路を探す
    vector<long long> shortest_path(long long S) {
        vector<long long> dp(E.size(), INF);
        priority_queue<state, vector<state>, greater<state> > q;
        q.push((state) { S, 0 });
        while(!q.empty()) {
            long long v = q.top().v, cost = q.top().cost;
            q.pop();
            if(dp[v] <= cost) continue;
            dp[v] = cost;
            for(int i=0;i < E[v].size() ; i++) {
            long long nv = E[v][i].v, ncost = cost + E[v][i].dist;
            if(dp[nv] > ncost) q.push((state) { nv, ncost });
            }
        }
        return dp;
    }
};

 
int main(){
    int n;
    cin>>n;
    int a[n],b[n];
    Dijkstra di(n);
    for(int i=0;i<n-1;i++){
        cin>>a[i]>>b[i];
        a[i]--,b[i]--;
        di.add_undirected_edge(a[i],b[i],1);
    }
    vector<long long> v=di.shortest_path(0);
    long long l=0,p=0;
    for(int i=0;i<n;i++){
        if(v[i]>l){
            l=v[i];
            p=i;
        }
    }
    vector<long long> vv=di.shortest_path(p);
    l=0;
    for(int i=0;i<n;i++){
        l=max(l,vv[i]);
    }
    cerr<<l<<endl;
    if(l%3==1){
        cout<<"Second"<<endl;
    }
    else cout<<"First"<<endl;

}

Measured memory_bytes: 27620
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<queue>
#include<cmath>
#include<cstdio>
#include<tuple>
#include<bitset>
#include<map>

using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
#define ALL(x) x.begin(),x.end()
using ll = long long;
using lint = long long;
typedef pair<int,int> P;
const lint inf=1e18+7;
const int MOD=1000000007;
signed main(){
    int n;cin>>n;
    vector<int> a(n);
    int res=0;
    int l=0;int r=0;
    rep(i,n)cin>>a[i];
    a.push_back((1ll<<60)-1);
    int sm=(1ll<<50);
    while(l<n){
        while(sm+a[r]==(sm^a[r])){
            sm+=a[r];
            ++r;
        }
        res+=r-l;
        sm-=a[l];
        ++l;
    }
    cout<<res<<"\n";
    return 0;
}

Measured memory_bytes: 4864
package main

import (
	"fmt"
	"math"
)

const (
	MAX_INF = math.MaxInt64 / 2
)

var height []int

func main() {
	var N int
	var K int
	var c int
	fmt.Scan(&N, &K)
	height = make([]int, N+1)
	cost := make([]int, N+1)
	var h int
	for i := 1; i <= N; i++ {
		fmt.Scan(&h)
		height[i] = h
	}
	cost[0] = 0
	cost[1] = 0
	for i := 2; i <= N; i++ {
		minCost := MAX_INF
		for k := 1; k <= K; k++ {
			if i-k > 0 {
				c = cost[i-k] + getCost(i, i-k)
				if c < minCost {
					minCost = c
				}
			}
		}
		cost[i] = minCost
	}
	fmt.Println(cost[N])

}

func getCost(i, j int) int {
	return int(math.Abs(float64(height[i] - height[j])))
}

func getMin(a, b int) int {
	if a < b {
		return a
	} else {
		return b
	}
}


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

typedef long long ll;

int n,k,a,f;
map<int,int> mp,pr;
ll ans;

int main(){

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

    cin>>n>>k;
    mp[0]=1;
    for(int i=1;i<=n;i++){
        cin>>a;f=(f+a-1)%k;
        pr[i+1]=f;
        if(i>=k)mp[pr[i-k+1]]--;
        ans+=mp[f]++;
    }
    cout<<ans<<endl;

    return 0;
}

Measured memory_bytes: 19072
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n, i, j;
  cin>>n;
  int arr[n];
  for(i=0; i<n; i++)
    cin>>arr[i];

  long int sum = 0;
  for(i=0; i<n; i++)
    for(j=i+1; j<n; j++)
      sum += arr[i]*arr[j];
  cout<<sum<<endl;
  return 0;
}


Measured memory_bytes: 256
//k_k_dubey_
#include<bits/stdc++.h>
#define mod 1000000007
#define ll long long
#define inf 999999999999
#define mx 200005
#define gcd __gcd
#define pb push_back
#define mk make_pair
#define bs binary_search
#define ub upper_bound
#define lb lower_bound
#define endl "\n"
#define vl vector<ll>
#define vs vector<string>
#define non __builtin_popcount
#define ml map<ll, ll> 
#define ms map<string , ll> 
using namespace std;

bool isp[mx];

void sv(){

	ll i,j;
	memset(isp, true, sizeof(isp));
	
	isp[1]= false;
	for(i=2;i*i<mx;i++){
		if(isp[i]){
			for(j=i*i;j<mx;j+=i)
			isp[j]= false;
		}
	}
}

ll powr(ll a,ll b)
{
	ll res=1;
	while(b)
	{
		if(b&1)res=(res*a)%mod;
		a=(a*a)%mod;
		b>>=1;
	}
	return res;
}
ll fac[mx];
ll ncr(ll n, ll r ){
    
    ll kk= fac[n];
    ll k2= (fac[n-r]* fac[r])%mod;
    ll ans= kk* ( powr(k2, mod-2) %mod)%mod;
    return ans;
}
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
	//sv();
	
	ll n,k, i,j;
	fac[0]= 1;
	for(i=1; i< mx; i++)
	fac[i]= (i*fac[i-1])%mod;
	
	cin>>n>>k;
	for(i=1; i<k+1; i++){
	    ll ans;
	    if(n-k +1 <i)
	    ans= 0;
	    else{
	        ll a1= ncr(n-k+1, i);
	        ll a2= ncr(k-1, i-1);
	        ans= (a1* a2)%mod;
	    }
	    
	    cout<<ans<<endl;
	}
    return 0;
}























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

int main() {
  double W,H,x,y;
  cin >> W >> H >> x >> y;
  
  double div = (y-H/2)/(x-W/2);
  double sep = H/2 -div*W/2;
  double c = div*W + sep;
  
  if(x==W/2 && y==H/2) cout << (double)H*W/2 << " "<< 1;
  else if(x==W/2) cout << (double)H*W/2 << " " << 0;
  else cout << (double)min((sep+c)*W/2, H*W-(sep+c)*W/2) << " " << 0;
  

}

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

int main() {
  int R, G, B, N;
  cin >> R >> G >> B >> N;
  int ans = 0;
  for (int i = 0; i <= N/R; i++) {
    for (int j = 0; j <= N/G; j++) {
      if ((N-i*R-j*G) % B == 0 && N-i*R-j*G >= 0) {
        ans++;
      }
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    int cnt = 0;
    cin>>n;
    
    if(n==100000)
        n = 99999;
        
    if(n>=10000)
        cnt += n-10000 + 1, n = 9999;
    
    if(n>=1000)
        n = 999;
    if(n>=100)
        cnt += n-100 + 1, n = 99;
    
    if(n>=10)
        n=9;
    if(n>=1)
        cnt += n-1 + 1, n=1;
    
    cout<<cnt;
    
    
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <deque>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <iomanip>
#include <bitset>
#include <set>
#include <map>
#include <stdio.h>
#include <numeric>
#include <cstring>

#define rep(i,n) for (int i = 0; i < (n); i++)
#define rep1(i,n) for (int i = 1; i < (n); i++)
#define FOR(i,a,b) for (int i=(a); i < (b); i++)
#define MOD 1000000007 //10^9+7
#define ALL(a)  (a).begin(),(a).end()
using namespace std;
using ll = long long;
using PII = pair<int, int>;
using PLL = pair<long long, long long>;
const int INF = numeric_limits<int>::max();
const ll INFL = numeric_limits<ll>::max();
constexpr ll TEN(int n) { return (n==0) ? 1 : 10*TEN(n-1); }

// 負の数にも対応した % 演算
long long mod(long long val, long long m) {
    long long res = val % m;
    if (res < 0) res += m;
    return res;
}

//greatest common divisor
long long gcd(ll a, ll b) 
{
    if (a % b == 0) {
        return b;
    } else {
        return gcd(b, a % b);
    }
}

//least common multiple
long long lcm(ll a, ll b)
{
    return a / gcd(a, b) * b ;
}

ll factorial(ll n) {
    ll res = 1;
    for (ll i = 1; i <= n; i++) {
        res *= i;
    }
    return res;
}

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

bool isOK(int index, int key, vector<ll>& a) {
    if (a[index] >= key) return true;
    else return false;
}

int binary_search(int key, vector<ll>& a) {
    int ng = -1;
    int ok = a.size();

    while (abs(ok - ng) > 1) {
        int mid = (ok + ng) / 2;

        if (isOK(mid, key, a)) ok = mid;
        else ng = mid;
    }
    return ok;
}

struct UnionFind {
    vector<int> r;

    UnionFind(int N) {
        r = vector<int>(N, -1);
    }

    int root(int x) {
        if (r[x] < 0) return x;
        return r[x] = root(r[x]);
    }

    bool unite(int x, int y) {
        x = root(x);
        y = root(y);
        if (x == y) return false;
        if (r[x] > r[y]) swap(x, y);
        r[x] += r[y];
        r[y] = x;
        return true;
    }

    int size(int x) {
        return -r[root(x)];
    }

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

//素因数分解
vector<pair<long long, long long> > prime_factorize(long long N) {
    vector<pair<long long, long long> > res;
    for (long long a = 2; a * a <= N; ++a) {
        if (N % a != 0) continue;
        long long ex = 0;
        while (N % a == 0) {
            ++ex;
            N /= a;
        }
        res.push_back({a, ex});
    }
    if (N != 1) res.push_back({N, 1});
    return res;
}
//const auto &pf = prime_factorize(i);
//for (auto p : pf) cout << p.first << " " << p.second;

int main()
{
    int a, b; cin >> a >> b;
    if (a+b < 10)
        cout << a + b << endl;
    else
        cout << "error" << endl;
    return 0;
}


Measured memory_bytes: 3604
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {
    public static void main(String[] args){
        Scanner scan = new Scanner(System.in);

        while(true){
            int sum = 0;
            String num = scan.nextLine();
            for(int i = 0; i < num.length(); i++){
                sum += Character.digit(num.charAt(i), 10);
            }
            if ( sum == 0){
                break;
            }
            System.out.println(sum);


        }
    }
}


Measured memory_bytes: 26724
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#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 <iterator>
#include <unordered_map>
#include <unordered_set>
#include <tuple> 
#include <memory>
#include <random>
#include <iterator>
#include <cassert>
using namespace std;

int main(void){
    float t, x;
    cin >> t >> x;
    float ans = t / x;
    cout << ans << endl;
}


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

int main(){
  int t, h, m, s;
  cin >> t;
  h = t/(60*60);
  m = (t%(60*60))/60;
  s = (t%(60*60))%60;
  cout << h << ":" << m << ":" << s << endl;
  return 0;
}



Measured memory_bytes: 3104
#include <iostream>
using namespace std;
int main(){
  char in[2];
  char table[][2]{
    {'A','T'},
    {'C','G'}
  };
  cin >> in;
  for(int i=0;i<sizeof(table);i++){
    if (in[0] == table[i][0]){
      cout << table[i][1];
      break;
    }
    if (in[0] == table[i][1]){
      cout << table[i][0];
      break;
    }
  }
  return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define int long long
using namespace std;
typedef pair<int, int> P;
const int mod = 1000000007;
const int INF = 1e18;

signed main(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	string s;
	cin >> s;
	if(s[0] == s[1] && s[1] == s[2]) cout << "Yes" << endl;
	else if(s[1] == s[2] && s[2] == s[3]) cout << "Yes" << endl;
	else cout << "No" << endl;
}

Measured memory_bytes: 256
import java.io.*;
import java.math.*;
import java.security.KeyStore.Entry;
import java.util.*;
public class Main {
	public static void merge(long arr[], int l, int m, int r) 
    { 
        // Find sizes of two subarrays to be merged 
        int n1 = m - l + 1; 
        int n2 = r - m; 
  
        /* Create temp arrays */
        long L[] = new long [n1]; 
        long R[] = new long [n2]; 
  
        /*Copy data to temp arrays*/
        for (int i=0; i<n1; ++i) 
            L[i] = arr[l + i]; 
        for (int j=0; j<n2; ++j) 
            R[j] = arr[m + 1+ j]; 
  
  
        /* Merge the temp arrays */
  
        // Initial indexes of first and second subarrays 
        int i = 0, j = 0; 
  
        // Initial index of merged subarry array 
        int k = l; 
        while (i < n1 && j < n2) 
        { 
            if (L[i] <= R[j]) 
            { 
                arr[k] = L[i]; 
                i++; 
            } 
            else
            { 
                arr[k] = R[j]; 
                j++; 
            } 
            k++; 
        } 
  
        /* Copy remaining elements of L[] if any */
        while (i < n1) 
        { 
            arr[k] = L[i]; 
            i++; 
            k++; 
        } 
  
        /* Copy remaining elements of R[] if any */
        while (j < n2) 
        { 
            arr[k] = R[j]; 
            j++; 
            k++; 
        } 
    } 
	 public static void sort(long arr[], int l, int r) 
	    { 
	        if (l < r) 
	        { 
	            // Find the middle point 
	            int m = (l+r)/2; 
	  
	            // Sort first and second halves 
	            sort(arr, l, m); 
	            sort(arr , m+1, r); 
	  
	            // Merge the sorted halves 
	            merge(arr, l, m, r); 
	        } 
	    } 
	 private static int gcd(int n, int l) {
	        if (l == 0)
	            return n;
	        return gcd(l, n % l);
	    }
	public static void main(String[] args) throws Exception
	{
		Scanner sc=new Scanner(System.in);
		int n=sc.nextInt();int k=sc.nextInt();
		double ans=0,p=1.0/n,p1=1.0/2;
		for(int i=1;i<=n;i++)
		{
			int steps=0;int init=i;
			while(k>init)
			{
				init*=2;
				steps++;
			}
			ans=ans+(p*Math.pow(p1, steps));
		}
		System.out.println(ans);
	}
}


Measured memory_bytes: 21844
import sys
readline = sys.stdin.buffer.readline
read = sys.stdin.read
from collections import deque
sys.setrecursionlimit(10 ** 8)
INF = float('inf')
MOD = 10 ** 9 + 7

def main():
    n, k = map(int, readline().split())
    A = list(map(int, readline().split()))
    MOD = int(1e9) + 7
    A.sort()
    ans = 1
    if A[n - 1] == 0 and (k & 1):
        ans = 0
    elif A[n - 1] <= 0 and (k & 1):
        for i in range(n - 1, n - k - 1, -1):
            ans = (ans * A[i]) % MOD
    else:
        i = 0
        j = n - 1
        if k & 1:
            ans = (ans * A[j]) % MOD
            j -= 1
            k -= 1
        k >>= 1
        for itr in range(k):
            left_product = A[i] * A[i + 1]
            right_product = A[j] * A[j - 1]
            if left_product > right_product:
                ans = (ans * left_product) % MOD
                i += 2
            else:
                ans = (ans * right_product) % MOD
                j -= 2

    print(ans % MOD)

if __name__ == '__main__':
    main()

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

int main(){
  int n;
  cin>>n;
  string ans="";
  if(n==0){
    cout<<0<<endl;
    return 0;
  }else{
    while(n!=0){
      if(n%2!=0){
        ans='1'+ans;
        n--;
      }else{
        ans='0'+ans;
      }n/=-2;
    }
    cout<<ans<<endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD = 1e9 + 7;
#define SS(type, ...)type __VA_ARGS__;MACRO_VAR_Scan(__VA_ARGS__);
template<typename T> void MACRO_VAR_Scan(T& t){cin >> t;}
template<typename First, typename...Rest> void MACRO_VAR_Scan(First& first, Rest&...rest){cin >> first;MACRO_VAR_Scan(rest...);}
#define _overload3(_1,_2,_3,name,...) name
#define _REP(i,n) REPI(i,0,n)
#define REPI(i,a,b) for(ll i=ll(a);i<ll(b);++i)
#define REP(...) _overload3(__VA_ARGS__,REPI,_REP,)(__VA_ARGS__)
ll MOP(ll a,ll b,ll mod=1e9+7) {ll c=1ll;do{if(b&1)c*=1ll*a%mod;a*=1ll*a%mod;}while(b>>=1);return c;}
#define ln '\n'

//---------------8<---------------8<---------------8<---------------8<---------------//

ll dp[5050][5050];

signed main() {

  SS(int,N);
  SS(string,s);
  int s_len = s.size();

  dp[0][0] = 1;
  REP(i,N) REP(j,N) {
    (dp[i+1][j+1] += dp[i][j]*2) %= MOD;
    (dp[i+1][j-(j!=0)] += dp[i][j]) %= MOD;
  }

  ll res = dp[N][s_len];
  REP(i,s_len) (res *= (MOD+1)/2) %= MOD;
  cout << res << ln;

}

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

int main() {
  int N;
  cin >> N;
  
  int answer = 0;

  for(int i = 0; i < N; i++){
    char S;
    cin >> S;
    
    if(S == 'Y'){
      answer++;
    }
    else{
      continue;
    }
  }

  if(answer > 0){
    cout << "Four" <<endl;
  }
   else{
    cout << "Three" <<endl;
  }
}

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

int main() {
    int w, a, b, ab;
    cin >> w >> a >> b;
    ab = abs(b - a);
    if (min(ab + w, ab - w) < 0) {
        cout << 0 << endl;
    } else {
        cout << min(ab + w, ab - w) << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repr(i, n) for (int i = (n) - 1; i >= 0; i--)
#define range(a) a.begin(), a.end()

template<class T>
struct BIT {
  vector<T> dat;

  BIT(int n) : dat(n + 1) {}

  void update(int k, T v) {
    for (int i = k + 1; i < dat.size(); i += i & -i) {
      dat[i] += v;
    }
  }

  T query(int k) {
    T res = 0;
    for (int i = k; i > 0; i -= i & -i) {
      res += dat[i];
    }
    return res;
  }

  T query(int l, int r) {
    return query(r) - query(l);
  }
};



int main() {
  int N; cin >> N;
  string S; cin >> S;
  int Q; cin >> Q;
  vector<BIT<int>> bit(26, BIT<int>(N));
  rep(i, N) {
    bit[S[i] - 'a'].update(i, 1);
  }
  while (Q--) {
    int type; cin >> type;
    if (type == 1) {
      int i; char q; cin >> i >> q; i--;
      bit[S[i] - 'a'].update(i, -1);
      S[i] = q;
      bit[S[i] - 'a'].update(i, 1);
    } else {
      int l, r; cin >> l >> r; l--;
      int ans = 0;
      rep(k, 26) {
        ans += bit[k].query(l, r) > 0;
      }
      cout << ans << '\n';
    }
  }
}

Measured memory_bytes: 53636
using System;
class abc092_b {
    static void Main(string[] args) {
        int N = int.Parse(Console.ReadLine());
        var S = Console.ReadLine().Split(' ');
        var four = false;
        for (var n = 0; n < N; n++) {
            if (S[n] == "Y") { four = true; break; }
        }
        Console.WriteLine(four ? "Four" : "Three");
    } //Main
}

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


int main(){
    long N,M;
    cin>>N>>M;
    vector<long>As(M);
    long sum=0;
    for(long i=0;i<M;i++){cin>>As[i];}
    for(long i=0;i<M;i++)
    {sum+=As[i];}
    if(N<sum){cout<<-1<<endl;}
    else{cout<<N-sum<<endl;}
}




Measured memory_bytes: 3708
#include <bits/stdc++.h>
// #include "bits:stdc++.h"
using namespace std;
#define db 0
#define f first
#define s second
typedef long long ll;
typedef pair <ll, ll> pi;
ll n, A[101], ans;
int main()
{
	cin >> n;
	for(ll i = 0; i < n; i++)
	{
		cin >> A[i];
	}
	ll prev = A[0], co = 1;
	for(ll i = 1; i < n; i++)
	{
		if(A[i] == prev)co++;
		else
		{
			if(db and co > 1)cout << i << "\n";
			if(co % 2 == 1)co -= 1;
			ans += co/2;
			prev = A[i];
			co = 1;
			if(i+1 == n)
			{
				cout << ans;
				return 0;
			}
		}
	}
	if(co % 2)co -= 1;
	ans += co/2;
	cout << ans;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <iomanip>
#include <utility>
#include <tuple>
#include <functional>
#include <bitset>
#include <cassert>
#include <complex>
#include <time.h>
#define ll long long
#define double long double
#define itn int
#define endl '\n'
#define co(ans) cout<<ans<<endl
#define COYE cout<<"YES"<<endl
#define COYe cout<<"Yes"<<endl
#define COye cout<<"yes"<<endl
#define CONO cout<<"NO"<<endl
#define CONo cout<<"No"<<endl
#define COno cout<<"no"<<endl
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define FFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,n)  FFOR(i,1,n)
#define ALL(V) (V).begin(),(V).end()
#define SORT(V) sort((V).begin(),(V).end())
#define REVERSE(V) reverse((V).begin(),(V).end())
#define INF ((1LL<<62)-(1LL<<31))
#define EPS 1e-10
#define PI 3.141592653589793238
#define MOD 1000000007
#define MAX 5100000
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 int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
bool CAN=true;
using namespace std;

int main(){
  ll N,K,ans=0;
  cin>>N>>K;
  
  ll A[N+1],SUM[N+2],BLACK[N+2];
  SUM[0]=0; //累積和
  BLACK[0]=0; //累積和(A[i]>0のみ)
  for(int i=1; i<=N; ++i){
    cin>>A[i];
    SUM[i]=SUM[i-1]+A[i];
    BLACK[i]=BLACK[i-1];
    if(A[i]>0) BLACK[i]+=A[i];
  }
  SUM[N+1]=SUM[N];
  BLACK[N+1]=BLACK[N];
  
  for(int i=1; i<=N-K+1; ++i){
    ll cnt=0;
    
    cnt+=BLACK[i-1];
    cnt+=BLACK[N]-BLACK[i+K-1];
    cnt+=max(SUM[i+K-1]-SUM[i-1],0ll);
    
    chmax(ans,cnt);
  }
  
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 2560
#include <bits/stdc++.h>
using namespace std;
int main() {
	long long int h;
	cin >> h;
	long long int qnt = 1;
	long long int q = 0;
	while(h > 1) {
		qnt *= 2;
		q += qnt;
		h = h / 2;
	}
	cout << q + 1 << endl;
	return 0;
}


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

#define LL long long
#define COIN const int
#define PII pair<int,int>
#define PSI pair<string,int>
#define PIS pair<int,string>

#define REP(i,n) for((i)=0;(i)<(int)(n);(i)++)
#define REPD(i,n) for((i)=(n)-1;(i)>=0;(i)--)

#define ALL(c) (c).begin(), (c).end()
#define LEN(s) (s).size()
#define CLEAR(x) memset(x,0,sizeof x);

#define MP make_pair
#define PB push_back
#define X first
#define Y second

#define VI vector<int>
#define VS vector<string>
#define VII vector<PII>
#define VVI vector<VI>

#define PIII 3.1415926
#define PI 3.14
/*****************************************************************************/

using namespace std;

string s;
int i;

int main()
{
	//freopen("input.txt","r",stdin);
	//freopen("output.txt","w",stdout);
	cin >>s;
	if (s.size()%2==1)
	{
		cout <<"No"<<endl;
		return 0;
	}
	REP(i,s.size())
	{
		if ((i%2==0 && s[i]!='h') || (i%2==1 && s[i]!='i'))
		{
			cout <<"No"<<endl;
			return 0;
		}
	}
	cout <<"Yes"<<endl;
	return 0;
}
/******************************************************************************
******************************************************************************/


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

typedef pair<int, int> pii;
typedef long long ll;
template<class T> using V = vector<T>;
template<class T> using VV = V<V<T>>;

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define rep(i,n) rep2(i,0,n)
#define rep2(i,m,n) for(int i=m;i<(n);i++)
#define ALL(c) (c).begin(),(c).end()
#define dump(x) cout << #x << " = " << (x) << endl
constexpr ll TEN(int n) { return (n == 0) ? 1 : 10 * TEN(n-1); }

template<class T, class U> void chmin(T& t, const U& u) { if (t > u) t = u; }
template<class T, class U> void chmax(T& t, const U& u) { if (t < u) t = u; }

template<class T, class U>
ostream& operator<<(ostream& os, const pair<T, U>& p) {
	os<<"("<<p.first<<","<<p.second<<")";
	return os;
}

template<class T>
ostream& operator<<(ostream& os, const vector<T>& v) {
	os<<"{";
	rep(i, v.size()) {
		if (i) os<<",";
		os<<v[i];
	}
	os<<"}";
	return os;
}

int slow(int N, int X, int D) {
	V<ll> A(N);
	rep(i, N) A[i] = X + (ll)D * i;
	set<ll> s;
	ll all = 0;
	rep(i, N) all += A[i];

	rep(i, 1 << N) {
		ll t = 0;
		rep(j, N) if ((i >> j) & 1) {
			t += A[j];
		}
		s.insert(t);
		//s.insert(t - (all - t));
	}
	return (int)s.size();
}

ll solve(int N, int X, int D) {
	if (D < 0) {
		X *= -1;
		D *= -1;
	}

	if (D == 0) {
		if (X == 0) {
			return 1;
		} else {
			return N + 1;
		}
	}

	V<pair<int, pair<ll, ll>>> vec;
	for (ll i = 0; i <= N; ++i) {
		ll l = i * (i-1) / 2;
		ll r = i * (N-1) - i * (i-1) / 2;
		ll m = i * X;
		ll pl = m / D, md = m % D;

		if (md < 0) {
			md += D;
			--pl;
		}
		l += pl;
		r += pl;
		vec.emplace_back(md, make_pair(l, r + 1));
	}
	sort(vec.begin(), vec.end());

	ll ans = 0;
	for (int i = 0; i < vec.size(); ) {
		int j = i;

		ll la = -TEN(18);
		while (j < vec.size() && vec[j].first == vec[i].first) {
			ll l = vec[j].second.first;
			ll r = vec[j].second.second;
			chmax(la, l);
			ans += max(0ll, r - la);
			chmax(la, r);
			++j;
		}

		i = j;
	}
	return ans;
}

int main() {
	int N, X, D; cin >> N >> X >> D;
	if (N <= 20) {
		cerr << slow(N, X, D) << endl;
	}
	ll ans = solve(N, X, D);
	//cerr << ans << endl;
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 8560