akhauriyash/Code-Regression huggingface dataset:
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);
		int X = sc.nextInt();
		int Y = sc.nextInt();
		int Z = sc.nextInt();
		int ans = 1;
		X = X-(Y+2*Z);
		while(X-(Y+Z)>=0) {
			ans++;
			X = X-(Y+Z);
		}
		System.out.println(ans);
	}
	
	static int binarySearch(int[] A, int x) {
		int l = 0;
		int r = A.length;
		while(l<r) {
			int mid = (l+r)/2;
			if(A[mid] == x) return mid;
			else if(x<A[mid]) r = mid;
			else l = mid+1;
		}
		return -1;
	}
	
	static long upper_bound(int[] A, int b) {
		// bよりおおきい値がはじめて出てくるindexを返す
		return lower_bound(A, b+1);
	}

	static long lower_bound(int[] A, int b) {
		// b以上の値がはじめて出てくるindexを返す
		int lb=0;
		int ub=A.length;
		while(ub>lb) {
			int mid = (lb+ub)/2;
			if(A[mid]>=b) ub = mid;
			else lb = mid+1;
		}
		return lb;
	}
	
	// union find lib
	// usage:
	// 最初にinitを呼ぶ
	// root: 直接は呼ばないで
	// unite: まとめる
	// same: グループ判定
	static void init(int par[], int N) {
		for(int i=0; i<N; i++) {
			par[i] = i;
		}
	}
	
	static int root(int x, int [] par) {
		if(par[x] == x) {
			return x;
		} else {
			return (par[x] = root(par[x], par));
		}
	}
	
	static boolean same(int x, int y, int[] par) {
		return root(x, par) == root(y, par);
	}
	
	static void unite(int x, int y, int[] par) {
		x = root(x, par);
		y = root(y, par);
		if(x == y) return;
		par[x] = y;
	}
	
	// end union find lib
	
	// number lib
	
	static int max(int...ls) {
		int ans = Integer.MIN_VALUE;
		for(int i=0; i<ls.length; i++) {
			ans = Math.max(ans, ls[i]);
		}
		return ans;
	}
	
	static int min(int...ls) {
		int ans = Integer.MAX_VALUE;
		for(int i=0; i<ls.length; i++) {
			ans = Math.min(ans, ls[i]);
		}
		return ans;
	}
	
	static long lcm(long a, long b) {
		return a*(b/gcd(a, b));
	}
	
	static long gcd(long a, long b) {
		long ta = Math.max(a, b);
		long tb = Math.min(a, b);
		long tmp;
		while((tmp = ta%tb) != 0) {
			ta = tb;
			tb = tmp;
		}
		return tb;
	}
	
	static long modcomb(long n, long k, long mod) {
		if(k==1) {
			return n;
		}
		
		long ans = 1;
		for(long i=n; i>=n-k+1; i--) {
			ans = (ans * i)%mod;
		}
		for(long i=k; 0<i; i--) {
			ans = (ans * modpow(i, mod-2, mod)) % mod;
		}
		return ans;
	}
	
	static long modpow(long a, long b, long mod) {
		if(b==0) return 1;
		if(b%2==0) {
			long d = modpow(a, b/2, mod);
			return (d*d)%mod;
		} else {
			return (a*modpow(a, b-1, mod))%mod;
		}
	}
	
	static int disit(long a, long d) {
		int count = 0;
		while(a!=0) {
			a = a/d;
			count++;
		}
		return count;
	}
	
	// end number lib
}

Measured memory_bytes: 21844
import java.util.*;
 
public class Main {
  public static void main(String args[]){
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    long sum = 0;
    int[] A = new int[1000001];
    for (int i = 0; i < N; i++) {
      int a = sc.nextInt();
      A[a]++;
      sum += a;
    }
    int Q = sc.nextInt();
    for (int j = 0; j < Q; j++) {
      int b = sc.nextInt();
      int c = sc.nextInt();
      sum += (long)(c-b)*A[b];
      A[c] += A[b];
      A[b] = 0;
      System.out.println(sum);
    }
  }
}

Measured memory_bytes: 63652
#include <stdio.h>
int main(){
    int w,h,x,y,r;
    scanf("%d %d %d %d %d",&w,&h,&x,&y,&r);
    if(x+r >w || x-r <0 || y+r >h || y-r <0){
        printf("No\n");
    }else{
        printf("Yes\n");
    }
    return 0;
}


Measured memory_bytes: 2112
'use strict';

function main(input) {
  const arr = input.trim().split('\n');
  const a = Number(arr[0]);
  const b = arr[1].split(' ').map(x => Number(x));
  let isPass = true;

  for (let i = 0; i < a; i++) {
    if (b[i] % 2 === 0 && b[i] % 3 !== 0 && b[i] % 5 !== 0) {
      isPass = false;
    } else {
      continue;
    }
  }
  console.log(isPass ? 'APPROVED' : 'DENIED');
}

main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 7372
#include <bits/stdc++.h>
#include <cassert>
typedef long long int ll;
using namespace std;

#if defined(DEBUG)

#include <unistd.h>
#include <sys/fcntl.h>
#define DLOG(...)        cerr << dbgFormat(__VA_ARGS__) << endl
#define DCALL(func, ...) func(__VA_ARGS__)

template <class... Args>
string dbgFormat(const char* fmt, Args... args) {
  size_t len = snprintf(nullptr, 0, fmt, args...);
  char buf[len + 1];
  snprintf(buf, len + 1, fmt, args...);
  return string(buf);
}

#else  // defined(DEBUG)

#define DLOG(...)
#define DCALL(func, ...)

#endif // defined(DEBUG)
// ----------------------------------------------------------------------

template<typename F>
class FixPoint : private F {
public:
  explicit constexpr FixPoint(F&& f) noexcept : F(forward<F>(f)) {}

  template<typename... Args>
  constexpr decltype(auto) operator()(Args&&... args) const {
    return F::operator()(*this, forward<Args>(args)...);
  }
};

template<typename F>
static inline constexpr decltype(auto) fix(F&& f) noexcept {
  return FixPoint<F>{forward<F>(f)};
}

// ----------------------------------------------------------------------
int main(int argc, char *argv[]) {
#if defined(DEBUG)
  // GDB on Cygwin ignores redirection at run command.
  if (argc == 2) dup2(open(argv[1], 0), 0);
#else
  // For performance.  We should not use C-style stdio functions
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
#endif
  cout << setprecision(20);

  int N, M; cin >> N >> M;
  vector<ll> A(N);
  vector<int> X(N), Y(N);
  for (int i = 0; i < N; i++) cin >> A.at(i);
  vector<vector<int>> nbr(N);
  for (int i = 0; i < M; i++) {
    cin >> X.at(i) >> Y.at(i);
    nbr.at(X.at(i)).push_back(Y.at(i));
    nbr.at(Y.at(i)).push_back(X.at(i));
  }
  vector<bool> visited(N);

  auto dfs = fix([&](auto f, int nd, int pa, auto& costs) -> void {
      if (visited.at(nd)) return;
      visited.at(nd) = true;
      costs.push_back(A.at(nd));
      for (int j : nbr.at(nd)) {
	if (j == pa) continue;
	f(j, nd, costs);
      }
    });

  vector<ll> mins;
  vector<ll> sndCosts;
  for (int i = 0; i < N; i++) {
    if (visited.at(i)) continue;
    vector<ll> costs;
    dfs(i, -1, costs);
    ll tMin = LLONG_MAX;
    for (ll c : costs) tMin = min(tMin, c);
    mins.push_back(tMin);
    bool hit = false;
    for (ll c : costs) {
      if (!hit && c == tMin) {
	hit = true;
      }else {
	sndCosts.push_back(c);
      }
    }
  }
  int k = mins.size();
  if (2*(k-1) > N) {
    cout << "Impossible\n";
    return 0;
  }
  if (k == 1) {
    cout << 0 << endl;
    return 0;
  }
  sort(sndCosts.begin(), sndCosts.end());
  ll cost1 = accumulate(mins.begin(), mins.end(), 0LL);
  ll cost2 = accumulate(sndCosts.begin(), sndCosts.begin() + k-2, 0LL);
  ll cost = cost1 + cost2;
  // cout << cost1 << endl;
  // cout << cost2 << endl;
  cout << cost << endl;

  return 0;
}



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

// 型定義
typedef long long ll;
typedef pair<ll, ll> P;

// forループ
#define REP(i,n) for(ll i=0; i<(ll)(n); ++i)

// 定数宣言
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

// グラフ表現
using Graph = vector<vector<int>>;

// グラフの辺表現
using Edge = map<pair<int,int>,int>;

// n次元配列の初期化。第２引数の型のサイズごとに初期化していく。
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

// 最大公約数
ll gcd(ll a,ll b){
   if (a%b == 0) return(b);
   else return(gcd(b, a%b));
}

// 最小公倍数
ll lcm(ll a, ll b){
    return a*b/gcd(a, b);
}

int main()
{
    cout << fixed << setprecision(15);
    ll N;
    string S;
    cin >> N;
    cin >> S;

    ll ans = 0;

    for(ll i = 0; i<= N-2; i++){
        map<char, bool> A;
        map<char, bool> B;
        for(ll j=0; j<=i; j++){
            if(!A.count(S[j])) A[S[j]] = true; 
        }
         for(ll j=i+1; j<=N-1; j++){
            if(!B.count(S[j])) B[S[j]] = true; 
        }

        ll temp = 0;
        for (auto iter = A.begin(); iter != A.end(); iter++){
            if(B.count(iter->first)) temp++;
        }
        ans = max(ans, temp);
    }
    cout << ans << endl;
    return 0;
}

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

#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define ll long long
#define INF 999999999
#define MOD 1000000007

using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

int iy[]={0, 0, 1, -1};
int ix[]={1, -1, 0, 0};

ll n, m, sx[100010], sy[100010], sumx, sumy;

int main(){
	cin >> n >> m;
	for(ll i=1;i<=n;i++){
		cin >> sx[i];
	}
	for(ll i=1;i<=m;i++){
		cin >> sy[i];
	}
	for(ll i=1;i<=n-1;i++){
		sumx = (sumx + i*(n-i)*(sx[i+1]-sx[i])) % MOD;
	}
	for(ll i=1;i<=m-1;i++){
		sumy = (sumy + i*(m-i)*(sy[i+1]-sy[i])) % MOD;
	}
	cout << (sumx+MOD)*(sumy+MOD)%MOD << endl;
	return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<ll>;
using vs = vector<string>;
#define  rep(i,n) for(ll i = 0; i < (n); ++i)
#define  red(i,n) for(ll i = (n)-1; i >= 0; --i)
#define  all(a)   begin(a),end(a)
#define  pb(a)    push_back(a)
#define  yn       cout<<"Yes\n"; else cout<<"No\n";
inline ll gcd(ll a,ll b) { return b?gcd(b,a%b):a; }
const int INF=1000000009;
const ll LINF = 1e18;


int main()
{
    int a,b,k;
    cin>>a>>b>>k;
    for(int i=a;i<=b;i++) if(i-a<k || b-i<k) cout<<i<<endl;

    return 0;
}


Measured memory_bytes: 256
#define DBG 0 //submit 0
#define ll long long
#if DBG
    #include <algorithm>
    #include <array>
    #include <ctime>
    #include <cstdlib>
    #include <string>
    #include <vector>
    #include <unordered_map>
    #include <iostream>
    #include <cmath>
    #include <queue>
    #include <numeric>
#else
    #include <bits/stdc++.h>
#endif
 
using namespace std;
 
 
int main(){
    int n,t,a,h,index=0,ans=0;
    double temp=0.0,def,low=1000000000000000.0;
    
    cin >> n >> t >> a;

    for(int i=0;i<n;i++){
        cin >> h;
        def = t-0.006*h-a;
        def *= def;
        if(low > def){
            index = i;
            low = def;
        }
    }

    ans=index+1;
    //cout << (flag ? "Yes" : "No") << endl;
    cout << ans << endl;
}


Measured memory_bytes: 256
// clang-format off

#include <bits/stdc++.h>

#define int long long int
#define main signed main()
#define bye return 0
#define rep(i, n) for (int i = 0; i < (n); i++)
#define loop(i, a, n) for (int i = (a); i < (n); i++)
#define each(p, v) for (auto p = (v).begin(); p != (v).end(); p++)
#define all(v) (v).begin(), (v).end()
#define prec(n) fixed << setprecision(n)
#define dump(x) cerr << "(L" << __LINE__ << ") " << #x << " = " << (x) << endl

#define sum(v) accumulate(all(v), 0)
#define stlice(s, l) substr(s, (s) + (l) + 1)
#define odd(n) ((n) % 2)
#define even(n) (!((n) % 2))

#define INF 1e9
#define MOD (1e9 + 7)

#define pb push_back
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define vi vector<int>
#define vb vector<bool>
#define vc vector<char>
#define vs vector<string>

using namespace std;

// clang-format on

int N, W;
int w[100], v[100];
map<pair<int, int>, int> mm;

int f(int i, int j) {
  auto p = mp(i, j);
  if (!mm.count(p)) {
    if (i == N) {
      mm[p] = 0;
    } else if (j < w[i]) {
      mm[p] = f(i + 1, j);
    } else {
      mm[p] = max(f(i + 1, j), f(i + 1, j - w[i]) + v[i]);
    }
  }
  return mm[p];
}

main {
  cin >> N >> W;
  rep(i, N) cin >> w[i] >> v[i];
  cout << f(0, W) << endl;
  bye;
}


Measured memory_bytes: 6400
/** Author : Parth Prajapati
 * 	Institute : Pandit Deendayal Petroleum University
**/
#include<bits/stdc++.h>

using namespace std;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    long long int n,a,b,ans;
    cin>>n>>a>>b;
    ans = (n/(a+b))*a + min(a,(n%(a+b)));
    cout<<ans;
    return 0;
}

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

#define INF_LL (int64)1e18
#define INF (int32)1e9
#define REP(i, n) for(int64 i = 0;i < (n);i++)
#define FOR(i, a, b) for(int64 i = (a);i < (b);i++)
#define all(x) x.begin(),x.end()
#define fs first
#define sc second

using int32 = int_fast32_t;
using uint32 = uint_fast32_t;
using int64 = int_fast64_t;
using uint64 = uint_fast64_t;
using PII = pair<int32, int32>;
using PLL = pair<int64, int64>;

const double eps = 1e-10;

template<typename A, typename B>inline void chmin(A &a, B b){if(a > b) a = b;}
template<typename A, typename B>inline void chmax(A &a, B b){if(a < b) a = b;}

const int64 mod = 1e9+7;

using Row = vector<int64>;
using Mat = vector<Row>;

string s, t;
using T = tuple<int64, int32, int32>;
T dp[3030][3030] = {};

int main(void){
	cin >> s >> t;
	s += '.'; t += '.';
	REP(i, s.size()){
		REP(j, t.size()){
			dp[i][j] = T(0, -1, -1);
		}
	}
	REP(i, s.size()){
		REP(j, t.size()){
			if(s[i] == t[j]){
				chmax(dp[i+1][j+1], T(get<0>(dp[i][j])+1, i, j));
			}
			chmax(dp[i+1][j], dp[i][j]);
			chmax(dp[i][j+1], dp[i][j]);
		}
	}
	string res = "";
	int32 ni = s.size(), nj = t.size();
	while(ni >= 0 && nj >= 0){
		res = s[ni]+res;
		int32 x;
		tie(x, ni, nj) = dp[ni][nj];
	}
	cout << res.substr(0, get<0>(dp[s.size()][t.size()])-1) << endl;
}


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

using namespace std;
#define all(x) (x).begin(),(x).end()
#define rep(i, n) for (int i = 0; i < (n); i++)
#define chmin(x, y) (x) = min((x), (y))
#define chmax(x, y) (x) = max((x), (y))
#define endl "\n"
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

template <typename T> ostream &operator<<(ostream &os, const vector<T> &vec){os << "["; for (const auto &v : vec) {os << v << ","; } os << "]"; return os; }
template <typename T, typename U> ostream &operator<<(ostream &os, const pair<T, U> &p) {os << "(" << p.first << ", " << p.second << ")"; return os;}

void solve() {
    int N;
    cin >> N;
    vector<vector<ll>> A(N, vector<ll>(N));
    for (int i = 0; i < N; i++) {
        for (int j = 0; j < N; j++) {
            cin >> A[i][j];
        }
    }
    vector<ll> sum(1 << N);
    for (int i = 0; i < 1 << N; i++) {
        for (int j = 0; j < N; j++) {
            if (!(i >> j & 1)) continue;
            for (int k = j; k < N; k++) {
                if (!(i >> k & 1)) continue;
                sum[i] += A[j][k];
            }
        }
    }

    vector<ll> dp(1 << N, -(1LL << 60));
    dp[0] = 0;
    for (int i = 0; i < 1 << N; i++) {
        int mask = (~i) & ((1 << N) - 1);
        for (int k = mask; k > 0; k = (k - 1) & mask) {
            dp[i | k] = max(dp[i | k], dp[i] + sum[k]);
        }
    }
    cout << dp[(1 << N) - 1] << endl;
}

int main() {
    std::cin.tie(0);
    std::ios::sync_with_stdio(false);
    cout.setf(ios::fixed);
    cout.precision(16);
    solve();
    return 0;
}

Measured memory_bytes: 1280
#include <algorithm>  
#include <iostream>  
#include <sstream>  
#include <string>  
#include <cstring>
#include <vector>  
#include <queue>  
#include <set>  
#include <map>  
#include <cstdio>  
#include <cstdlib>  
#include <cctype>  
#include <cmath>  
#include <list>  
#include <cassert>
#include <ctime>
#include <climits>
using namespace std;  

#define PB push_back  
#define MP make_pair  
#define SZ(v) ((int)(v).size())  
#define FOR(i,a,b) for(int i=(a);i<(b);++i)  
#define REP(i,n) FOR(i,0,n)  
#define FORE(i,a,b) for(int i=(a);i<=(b);++i)  
#define REPE(i,n) FORE(i,0,n)  
#define FORSZ(i,a,v) FOR(i,a,SZ(v))  
#define REPSZ(i,v) REP(i,SZ(v))  
typedef long long ll;
typedef unsigned long long ull;
ll gcd(ll a,ll b) { return b==0?a:gcd(b,a%b); }

const int MAXN=100;

int n,W;
int w0;
vector<int> v[4];
vector<int> sv[4];

void run() {
	scanf("%d%d",&n,&W); REP(i,4) v[i].clear();
	REP(i,n) {
		int cw,cv; scanf("%d%d",&cw,&cv); if(i==0) w0=cw;
		v[cw-w0].PB(cv);
	}
	//REP(i,4) v[i].clear(); REP(i,3) REP(j,34) v[i].PB(10000000); w0=0; W=1000000000;
	REP(i,4) sort(v[i].begin(),v[i].end()),reverse(v[i].begin(),v[i].end());
	REP(i,4) { sv[i].clear(); sv[i].PB(0); REPSZ(j,v[i]) sv[i].PB(sv[i].back()+v[i][j]); }
	//REP(i,4) { printf("v%d:",i); REPSZ(j,v[i]) printf(" %d",v[i][j]); puts(""); }
	int ret=0;
	REPSZ(a,sv[0]) REPSZ(b,sv[1]) REPSZ(c,sv[2]) {
		ll sum=(ll)a*w0+(ll)b*(w0+1)+(ll)c*(w0+2); if(sum>W) continue; int d=min(SZ(v[3]),(int)(W-sum)/(w0+3));
		int cur=sv[0][a]+sv[1][b]+sv[2][c]+sv[3][d]; if(cur>ret) ret=cur;
	}
	printf("%d\n",ret);
}

int main() {
	run();
	return 0;
}


Measured memory_bytes: 256
import math
import copy
import sys
import fractions
# import numpy as np
# import statistics
import decimal
import heapq
import collections
import itertools
import bisect

# from operator import mul

sys.setrecursionlimit(100001)


# input = sys.stdin.readline
# sys.setrecursionlimit(10**6)

# ===FUNCTION===

def getInputIntList():
    outputDataList = []
    inputData = input().split()
    outputDataList = [int(n) for n in inputData]

    return outputDataList


def getSomeInputInt(n):
    outputDataList = []
    for i in range(n):
        inputData = int(input())
        outputDataList.append(inputData)

    return outputDataList


def getSomeInputListInt(n):
    inputDataList = []
    outputDataList = []
    for i in range(n):
        inputData = input().split()
        inputDataList = [int(n) for n in inputData]
        outputDataList.append(inputDataList)

    return outputDataList


# ===CODE===

h, w = map(int, input().split())

table = [[1 for _ in range(w)] for _ in range(h)]
d_table = [[-1 for _ in range(w)] for _ in range(h)]

for i in range(h):
    s = input()
    tmp = list(s)
    for j, ts in enumerate(tmp):
        if ts == ".":
            table[i][j] = 0

ans = -1
search_table = [[-1, 0], [1, 0], [0, -1], [0, 1]]

q = collections.deque([])
q.append([0,0])
table[0][0]=1
d_table[0][0]=0

gy, gx = [h-1, w-1]

while len(q) > 0:
    qy, qx = q.popleft()

    for y, x in search_table:
        cy = qy + y
        cx = qx + x

        if cy < 0 or cy > h - 1 or cx < 0 or cx > w - 1:
            continue

        if table[cy][cx] == 0 and d_table[cy][cx] == -1:
            table[cy][cx] = 1
            d_table[cy][cx] = d_table[qy][qx] + 1
            q.append([cy, cx])

            if cy == gy and cx == gx:
                ans = d_table[cy][cx]

if ans == -1:
    print(-1)
    exit(0)

cnt = 0

for i in range(h):
    for j in range(w):
        tmp = d_table[i][j]
        if tmp > -1:
            cnt+=1
        elif tmp == -1 and table[i][j]==0:
            cnt+=1

res = cnt -ans -1



print(res)


Measured memory_bytes: 66156
#include <stdio.h>
#include <stdlib.h>

int main()
{
    int n=0,besn=0,T=0,A=0,hei,tema=0,td=0;
    scanf("%d",&n);
    scanf("%d %d",&T,&A);

    for(int i=0;i<n;i++){
	scanf("%d",&hei);
	tema=1000*T-hei*6;

	if(i==0 || abs(1000*A-tema)<td){
	    td=abs(1000*A-tema);
	    besn=i;
	}

    }
    printf("%d",besn+1);
    return 0;
}



Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)   FOR(i,0,n)
#define pb emplace_back
typedef long long ll;
typedef pair<int,int> pint;

int t;
ll a,b,c,d;
int main(){
    cin>>t;
    rep(i,t){
        cin>>a>>b>>c>>d;
        if(a<b||b>d) cout<<"No"<<endl;
        else if(b<=c) cout<<"Yes"<<endl;
        else{
            ll g=__gcd(b,d);
            ll mx=(-g+b)%b+a%g;
            if(mx<=c) cout<<"Yes"<<endl;
            else cout<<"No"<<endl;
        }
    }
    return 0;
}

Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10**9)

def mi(): return map(int,input().split())
def ii(): return int(input())
def isp(): return input().split()
def deb(text): print("-------\n{}\n-------".format(text))

INF=10**20
def main():
    N=ii()
    A=list(mi())

    ans = 0
    for i in range(N):
        a = A[i]
        if (i+1) % 2 == 1 and a % 2 == 1:
            ans += 1
    
    print(ans)




if __name__ == "__main__":
    main()


Measured memory_bytes: 61808
// #define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define rep(i, n) for (int i = 0; i < n; ++i)
#define REP(i, n) for (int i = 0; i < n; ++i)
#define range(i,a,b) ((a)<=(i) && (i)<(b))
#define debug(x) cout << #x << ' ' << '=' << ' ' << (x) << endl;
#define fs first
#define sc second
#define pb push_back
#define eb emplace_back
typedef long long ll;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> T;
typedef vector<ll> vec;
typedef vector<P> pvec;
typedef vector<vector<ll>> vvec;
typedef vector<vector<P>> pvvec;
typedef priority_queue<ll> PQI;
typedef priority_queue<P> PQP;
typedef priority_queue<ll,vector<ll>,greater<ll>> PQIG;
typedef priority_queue<P,vector<P>,greater<P>> PQPG;
const vector<int> dx = {0, -1, 0, 1, 1, 1, -1, -1};
const vector<int> dy = {1, 0, -1, 0, 1, -1, 1, -1};
const int MOD = (1000000007);
// const int MOD = (998244353);
// const int INF = (1 << 30); // 1073741824
const int INF = (1LL << 60); // 1152921504606846976
const double EPS = (1 >> 30);
template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return 1;} return 0;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return 1;} return 0;}
template< typename T1, typename T2 > istream &operator>>(istream &is, pair< T1, T2 > &p) { is >> p.first >> p.second; return is; }



signed main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(15);
    //---------------------------------------------
    
    ll n;
    cin>>n;
    ll k;cin>>k;
    ll a[n];
    rep(i,n)cin>>a[i];
    ll ans=0;
    ll ret=0;
    for(int i=40;i>=0;--i){
        ll mask=1LL<<i;
        ll cnt=0;
        rep(j,n){
            if(a[j]&mask)++cnt;
        }
        if(cnt>=n-cnt){
            ans+=mask*cnt;
        }
        else {
            if(mask+ret<=k){
                ans+=(n-cnt)*mask;
                ret+=mask;
            }
            else ans+=mask*cnt;
        }
    }
    cout<<ans<<endl;
    
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define clr(x) memset(x, 0, sizeof(x))
#define sz(x) (int)x.size()

using namespace std;

typedef long long ll;
typedef pair<long , long> pll;

const ll mx = 105;
const ll maxn = 1000001;
const ll mod = 1000000007;

vector<vector<int>> adj;
vector<int> res;
vector<int> ord;

int main(){

   ios_base::sync_with_stdio(false);
   cin.tie(0);
   
   ll n, m, i, j, k, t, q;

   cin>>n>>k;

   ll res1 = n%k;
   ll res2 = abs(res1-k);

   if(res1 < res2){
       cout<<res1<<"\n";
   }
   else{
       cout<<res2<<"\n";
   }

}




Measured memory_bytes: 256
num = gets.chomp.to_i
len = gets.chomp.split.map(&:to_i)

c = 0

len.combination(3).to_a.each do |l|
  l_1 = l[0] < l[1] + l[2]
  l_2 = l[1] < l[2] + l[0]
  l_3 = l[2] < l[0] + l[1]
  l_len = l.uniq.length == 3
  
  c += 1 if l_1 && l_2 && l_3 && l_len
end
puts c

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

typedef long long ll;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef vector<vector<vector<ll>>> vvvll;
typedef vector<bool> vb;
typedef vector<vector<bool>> vvb;
typedef vector<vector<vector<bool>>> vvvb;
typedef pair<ll, ll> pll;
typedef vector<pll> vpll;
typedef vector<vpll> vvpll;
typedef vector<double> vd;
typedef vector<vd> vdd;

#define FOR(i,x,y) for(ll i=(ll)x; i<(ll)y; ++i)
#define REP(i,y) FOR(i, 0, y)
#define RFOR(i,x,y) for(ll i=(ll)x; i>=(ll)y; --i)
#define RREP(i,x) RFOR(i, x, 0)
#define ALL(a) a.begin(), a.end()
#define pb push_back
#define debug_print(x...) cerr << "line " << __LINE__ << " : "; debug_print_in(x);

template <typename First>
void debug_print_in(First first){
  cerr << first << endl;
  return;
}

template <typename First, typename... Rest>
void debug_print_in(First first, Rest... rest){
  cerr << first << " ";
  debug_print_in(rest...);
  return;
}

void IN(void){
  return;
}

template <typename First, typename... Rest>
void IN(First& first, Rest&... rest){
  cin >> first;
  IN(rest...);
  return;
}

template <typename First>
void OUT(First first){
  cout << first << endl;
  return;
}

template <typename First, typename... Rest>
void OUT(First first, Rest... rest){
  cout << first << " ";
  OUT(rest...);
  return;
}

template<class t, class u> void chmax(t&a,u b){if(a<b)a=b;};
template<class t, class u> void chmin(t&a,u b){if(a>b)a=b;};
int popcount(int t){return __builtin_popcount(t);} //GCC
int popcount(ll t){return __builtin_popcountll(t);} //GCC

template <typename T>
void vec_print(vector<T> VEC){
  REP(i, VEC.size()){
    cerr << VEC[i] << " ";
  }
  cerr << endl;
};

template <typename T>
void mat_print(vector<vector<T> > MAT){
  REP(i,MAT.size()){
    REP(j,MAT[i].size()){
      cerr << MAT[i][j] << " ";
    }
    cerr << endl;
  }
};

constexpr int INF = (1<<30);
constexpr ll INFLL = 1LL<<62;
constexpr long double EPS = 1e-12;
constexpr ll MOD = (ll)((1E+9)+7);

int main(){
  cin.tie(0); // cut the cin and cout (default, std::flush is performed after std::cin)
  ios::sync_with_stdio(false); // cut the iostream and stdio (DON'T endl; BUT "\n";)

  ll N, K;
  IN(N,K);
  if(K>((N-1)*(N-2))/2){
    OUT(-1);
    return 0;
  }

  ll count = ((N-1)*(N-2))/2;
  vll u(N-1), v(N-1);
  REP(i,N-1){
    u[i] = 1;
    v[i] = i+2;
  }
  ll start = 2;
  ll end = 3;
  while(count>K){
    u.pb(start);
    v.pb(end);
    end++;
    count--;
    if(end>N){
      start++;
      end=start+1;
    }
  }

  printf("%lld\n", u.size());
  REP(i,u.size()){
    printf("%lld %lld\n", u[i], v[i]);
  }

  return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <cstdint>
int main()
{
    std::uint32_t N, H, W;
    std::cin >> N >> H >> W;
    std::size_t count = 0;
    for(std::uint32_t i = 0; i < N; ++i){
        std::uint32_t a, b;
        std::cin >> a >> b;
        if(a/ H && b / W) ++count;
    }
    std::cout << count << std::endl;
}

Measured memory_bytes: 256
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE BangPatterns #-}

import Control.Applicative
import Control.Monad
import Control.Arrow
import Data.List
import Data.Maybe
import Data.Char
import qualified Data.ByteString.Char8 as B
import Text.Printf

readInt = ( readLn :: IO Int )
readInts = map ( read :: String -> Int ) . words <$> getLine

getList = map ( fst . fromJust . B.readInt ) . B.words <$> B.getLine

which a b f = if f then a else b
mp [ a, b ] = ( a, b )

main = do
	[ x, t ] <- readInts
	print . max 0 $ x - t


Measured memory_bytes: 508
#include <stdio.h>
#include <string.h>
#include <limits.h>
#include <math.h>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <bitset>

typedef unsigned long long ULLONG;
typedef long long LLONG;
static const LLONG MOD_NUM = 1000000007; //998244353;

template<class _T> static void get(_T& a) {
	std::cin >> a;
}
template<class _T> static void get(_T& a, _T& b) {
	std::cin >> a >> b;
}
template<class _T> static void get(_T& a, _T& b, _T& c) {
	std::cin >> a >> b >> c;
}

static void exec();

int main()
{
	exec();
	fflush(stdout);
	return 0;
}

static void exec()
{
	int r;
	get(r);

	printf("%d\n", r * r);
}


Measured memory_bytes: 3752
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {


		Scanner sc = new Scanner(System.in);

		while(true) {
			long b = sc.nextLong();
			if(b == 0) {
				break;
			}
			long n_k1 = 0;
			long kn= 0;
			long sqB = (long)Math.sqrt(2*b);
			long n = 0;
			long k = 0;

			for(long i = sqB; i >0 ; i--) {
				if(2*b%i == 0) {
					//i がn-k+1
					n_k1= i;
					kn = 2*b/i;

					if((n_k1 -1 + kn)%2 == 0) {
						 n = (n_k1 -1 + kn)/2;
						 k = kn -n;
						break;
					}

				}
			}



			System.out.println(k +" "+ n_k1);

		}
	}
}



Measured memory_bytes: 30400
# from math import factorial,sqrt,ceil,gcd
# from itertools import permutations as permus
# from collections import deque,Counter
# import re
# from functools import lru_cache # 簡単メモ化 @lru_cache(maxsize=1000)
# from decimal import Decimal, getcontext
# # getcontext().prec = 1000
# # eps = Decimal(10) ** (-100)

import numpy as np
# import networkx as nx
# from scipy.sparse.csgraph import shortest_path, dijkstra, floyd_warshall, bellman_ford, johnson
# from scipy.sparse import csr_matrix
# from scipy.special import comb

# slist = "abcdefghijklmnopqrstuvwxyz"
N = int(input())
arrA = np.array(input().split(),dtype=np.int64)

arr = np.bincount(arrA)
ans = 0
if len(arr)<=2:
    ans = sum(arr)
else:
    for i in range(len(arr)):
        if i+3>len(arr):
            break
        num = sum(arr[i:i+3])
        ans = max(ans,num)

print(ans)
# print(*ans)   # unpackして出力。間にスペースが入る
# for row in board:
#     print(*row,sep="")    #unpackして間にスペース入れずに出力する
# print("{:.10f}".format(ans))
# print("{:0=10d}".format(ans))


Measured memory_bytes: 22584
S = input()
T = input()

maxtmp = 0
if len(S) == 1:
    if T in S:
        print(0)
    else:
        print(1)
else:
    for i in range(len(S)- len(T)+1):
        tmp = 0
        for j in range(len(T)):
            if S[i+j] == T[j]:
                tmp += 1
        if maxtmp < tmp:
            maxtmp = tmp
    print(len(T) - maxtmp)



Measured memory_bytes: 67624
#include <iostream>
using namespace std;
int main()
{
	int n,k,num = 0,i,j,t;
	cin >> n >> k;
	char *a = new char[n + 1];
	cin >> a;
	for(i = 1;a[i] != '\0';i ++)
		if(a[i] == a[i - 1])
			num ++;
	for(t = 0,i = 1;t < k;t ++)
	{
		for(;a[i] != '\0' && a[i] == a[i - 1];i ++);
		if(a[i] != '\0')
		{
			for(j = i + 1;a[j] != '\0' &&a[j] == a[j - 1];j ++);
			if(a[j] == '\0')
			{	
				num ++;
				i = j;
			}
			else
			{	
				num += 2;
				i = j + 1;
			}
		}
		if(a[i] == '\0')
			break;
	}
	cout << num << endl;
	delete[] a;
	return 0;
}

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

int main(){
	int N;
	int X[200020];
	int T[200020];
	cin >> N;
	for(int n=0; n<N; ++n){
	cin >> X[n];
	}
	for(int n=0; n<N; ++n){
	T[n]=X[n];
	}
	sort(X, X+N);
	int S,L;
	S = (N/2)-1;
	L = (N/2);
	for(int n=0; n<N; ++n){
	if(T[n]<=X[S]){
	cout << X[L] << endl;
	}else{
	cout << X[S] << endl;
	}
	}
	return 0;
}

Measured memory_bytes: 3712
#include <cstdio>
#include <queue>
#include <vector>
using namespace std;

const int INF = 1<<29;

struct Edge {
    int src,dst,cost;
};
typedef vector<vector<Edge> > Graph;

// Shortest Path Faster Algorithm
// O(E)
void spfa(const Graph &g,int s,vector<int> &dist) {
    const int n = g.size();
    vector<bool> inQ(n, false);
    queue<int> q;

    q.push(s); fill(dist.begin(), dist.end(), INF);
    dist[s] = 0; inQ[s] = true;
    while(!q.empty()) {
        int v = q.front(); q.pop();
        inQ[v] = false;

        for(int i=0; i<g[v].size(); ++i) {
            int u = g[v][i].dst, d = g[v][i].cost;
            if(dist[v] + d < dist[u]) {
                dist[u] = dist[v] + d;
                if(!inQ[u]) {
                    q.push(u);
                    inQ[u] = true;
                }
            }
        }
    }
}

int main() {
    int n,m,a,b,c,s,t,d1,d2,d;
    scanf(" %d %d", &n, &m);
    Graph g(n);
    vector<int> dist(n);

    for(int i=0; i<m; ++i) {
        scanf(" %d,%d,%d,%d", &a, &b, &c, &d);
        a--,b--;
        g[a].push_back((Edge){a,b,c});
        g[b].push_back((Edge){b,a,d});
    }
    scanf(" %d,%d,%d,%d", &s, &t, &d1, &d2);
    s--,t--;

    spfa(g,s,dist);
    int ans = d1-d2-dist[t];
    spfa(g,t,dist);
    ans -= dist[s];
    printf("%d\n", ans);
}

Measured memory_bytes: 0
#include<stdio.h>
int fib(int n,int a,int b){
  int num;
   if(n>0){
     num=fib(n-1,a+b,a);
    return num;
  }

  else if(n==0){
    return a;
  }
}

int main(){
  int n;
  scanf("%d",&n);
  printf("%d\n",fib(n,1,0));
  return 0;
}

Measured memory_bytes: 596
#include<bits/stdc++.h>
#define m 1000000007
typedef long long ll;
using namespace std;

ll dp[3001][3001][2][2];

ll f(int i, int j, ll *a, int turn)
{
 if(i==j)
 {
     if(!turn)
     return a[i];
     else
     {
         return 0;
     }
 }
 if(dp[i][j][turn][1]!=-1)
 {
     return dp[i][j][turn][0];
 }
 if(!turn){
    dp[i][j][turn][0]=max((a[i]+f(i+1, j, a, 1)), (a[j]+f(i, j-1, a, 1)));
    dp[i][j][turn][1]=0;
 }
 else{
    dp[i][j][turn][0]=min((f(i+1, j, a, 0)), (f(i, j-1, a, 0)));
    dp[i][j][turn][1]=0;
 }
    return dp[i][j][turn][0];
}

int main()
{
   memset(dp, -1, sizeof(dp));
   int n;
   cin>>n;
   ll a[n];
   ll ans=0;
   for(int i=0;i<n;i++)
   {cin>>a[i];ans+=a[i];}
   cout<<(2*f(0, n-1, a, 0)-ans)<<endl;
   return 0;
}



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

int main(){
  int n, k; cin >> n >> k;
  int v[55];
  for (int i = 0; i < n; i++){
    cin >> v[i];
  }
  int ans = 0;
  for (int i = 1; i <= min(n, k); i++){
    for (int l = 0; l <= i; l++){
      int r = i - l;
      vector<int> score;
      for (int j = 0; j < l; j++){
        score.push_back(v[j]);
      }
      for (int j = n-1; j >= n-r; j--){
        score.push_back(v[j]);
      }
      sort(score.begin(), score.end());
      int a = lower_bound(score.begin(), score.end(), 0) - score.begin();
      int b = min(a, min(i, k-i));
      int sum = 0;
      for (int j = b; j < i; j++){
        sum += score.at(j);
      }
      ans = max(ans, sum);
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10 ** 6)
# input = sys.stdin.readline    ####
def int1(x): return int(x) - 1
def II(): return int(input())

def MI(): return map(int, input().split())
def MI1(): return map(int1, input().split())

def LI(): return list(map(int, input().split()))
def LI1(): return list(map(int1, input().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]

def SI(): return input().split()

def printlist(lst, k='\n'): print(k.join(list(map(str, lst))))
INF = float('inf')

from math import ceil, floor, log2
from collections import deque
from itertools import combinations as comb, combinations_with_replacement as comb_w, accumulate, product
from heapq import heapify, heappop, heappush

from fractions import gcd
def lcm(x, y):
  return x // gcd(x, y) * y

def solve():
    n, m = MI()
    A = LI()

    # aを2で割る
    for i in range(n):
        a = A[i]
        A[i] = a // 2

    def f(x):
        res = 0
        while x % 2 == 0:
            x //= 2
            res += 1
        return res

    div2 = f(A[0])
    for i, a in enumerate(A):
        if div2 != f(a):
            print(0)
            return
        A[i] = a >> div2

    m = m >> div2
    # print(A, m)

    l = 1
    for a in A:
        l = lcm(l, a)

    # print(l)

    # l * odd <= m を数える
    ans = m // l - m // (2 * l)
    print(ans)




if __name__ == '__main__':
    solve()


Measured memory_bytes: 16344
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>
//#include <algorithm>
#include <vector>

long st_MakeVec( long m, std::vector<long>& aa )
{
    if(m==1) {
        aa.push_back( 1 );
        aa.push_back( 2 );
        aa.push_back( 0 );
        aa.push_back( 1 );
        aa.push_back( 2 );
        aa.push_back( 1 );
        return 2;
    }
    else if(m==2) {
        aa.push_back( 1 );
        aa.push_back( 2 );
        aa.push_back( 0 );
        aa.push_back( 1 );
        aa.push_back( 2 );
        aa.push_back( 1 );
        aa.push_back( 1 );
        aa.push_back( 2 );
        aa.push_back( 2 );
        return 2;
    }
    else {
        long k = (m+1)/2;
        long tmp = st_MakeVec( k-1, aa );
        aa.push_back( tmp );
        aa.push_back( tmp+1 );
        aa.push_back( 0 );
        aa.push_back( tmp );
        aa.push_back( tmp+1 );
        aa.push_back( k );
        if((m+1)%2==1) {
            aa.push_back( 1 );
            aa.push_back( tmp+1 );
            aa.push_back( m );
        }
        return (tmp+1);
    }
}

int main(int argc, char* argv[])
{
    long m;
    scanf("%ld", &m );

    std::vector<long> aa;
    long tmp = st_MakeVec( m-1, aa );

    printf("%d %d\n", tmp, static_cast<long>(aa.size())/3 );
    long i;
    for(i=0; i<static_cast<long>(aa.size())/3; i++) {
        printf("%d %d %d\n", aa[i*3], aa[i*3+1], aa[i*3+2] );
    }

    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define pii pair<ll,ll>
#define ff first
#define ss second
#define sfi(a) scanf("%d",&a)
#define sfi2(a,b) scanf("%d %d",&a,&b)
#define sfi3(a,b,c) scanf("%d %d %d",&a,&b,&c)
#define sfll(a) scanf("%lld",&a)
#define all(a) a.begin(),a.end()
#define keepu(a) a.erase(unique(all(a)),a.end())
#define inf 1e7
#define m_p make_pair
#define min3(a,b,c) min(a,min(b,c))
#define pb push_back
#define mem(x,val) memset(x,val,sizeof(x))
#define read freopen("input.txt","r",stdin)
#define write freopen("output.txt","w",stdout)
#define FAST  ios_base::sync_with_stdio(0);cout.tie(0)
#define sqr(x) ((x)*(x))

typedef long long ll;
const ll mod = 1e9+7;
const int sz = 500;


int main(){

    ll x,y;
    cin >> x >> y;
        ll rem = 0;
        rem = x%y;
        if(rem==0){
            cout << 0 << endl;
            return 0;
        }

        ll rem1 = abs(rem-y);

        cout << min(rem1,rem) << endl;


    return 0;
}


Measured memory_bytes: 256
#                               #
    # author : samars_diary #
    # 26-09-2020 │ 17:30:28 #
#                               #

import sys, os.path

#if(os.path.exists('input.txt')):
    #sys.stdin = open('input.txt',"r")
    #sys.stdout = open('output.txt',"w")

sys.setrecursionlimit(10 ** 5)

def mod(): return 10**9+7
def ii(): return int(sys.stdin.readline())
def si(): return sys.stdin.readline().strip()
def li(): return list(sys.stdin.readline().strip())
def mii(): return map(int, sys.stdin.readline().split())
def lii(): return list(map(int, sys.stdin.readline().strip().split()))

#print=sys.stdout.write

def solve():
    a = ii()
    print(a*"ACL")

for _ in range(1):
    solve()

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

int main(){
    long long H, W;
    cin >> H >> W;

    if (H == 1 or W == 1){
        cout << 1 << endl;
    }
    else if (H * W % 2 == 0){
        cout << H * W / 2 << endl;
    }
    else{
        cout << (H * W + 1) / 2 << endl;
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main () {
  int n;
  cin >> n;
  vector<int> v(n), a(n/2), b(n/2);
  for (int i = 0; i < n; i++) {
    cin >> v.at(i);
    if (i%2 == 0) a.at(i/2) = v.at(i);
    else b.at((i-1)/2) = v.at(i);
  }
  sort (a.begin(), a.end());
  sort (b.begin(), b.end());
  int c = a.at(n/2-1);
  int d = b.at(n/2-1);
  vector<int> e(c), f(d);
  for (int i = 0; i < n/2; i++) {
    int x = a.at(i);
    e.at(x-1)++;
    int y = b.at(i);
    f.at(y-1)++;
  }
  int p = 1, q = 1, m = e.at(0), l = f.at(0);
  for (int i = 0; i < c; i++) {
    if (e.at(i) > e.at(p-1)) {
      p = i+1;
      m = e.at(i);
    }
  }
  for (int i = 0; i < d; i++) {
    if (f.at(i) > f.at(q-1)) {
      q = i+1;
      l = f.at(i);
    }
  }
  if (p != q) cout << n-m-l << endl;
  else {
    int g = 0, h = 0;
    for (int i = 0; i < c; i++) {
      if (i == p-1) continue;
      else {
        if (e.at(i) > g) g = e.at(i);
      }
    }
    for (int i = 0; i < d; i++) {
      if (i == q-1) continue;
      else {
        if (f.at(i) > h) h = f.at(i);
      }
    }
    int j = max(g+l, h+m);
    cout << n-j << endl;
  }
}

Measured memory_bytes: 1792
#include<stdio.h>
#include<iostream>
#include<cmath>
#include<cstring>

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
#define REV(i,a,b) for(int i=(a)-1;i>=(b);i--)

using namespace std;

typedef long long ll;

int main(){
  int a,b;
  cin >> a >> b;
  if(b >= a){
    cout << a << endl;
  }
  else cout << a-1 << endl;



  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  string s;
  cin >> s;
  int N=s.size();
  int a=0,b=0;
  for(int i=0;i<N;i++){
    if(s.at(i)=='A'){
      a=i+1;
      break;
    }
  }
  for(int i=0;i<N;i++){
    if(s.at(i)=='Z')
      b=i+1; 
  }
    
  cout << b-a+1 << endl;
}


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

int main(void){
    string a;
    string b;
    cin >> a >> b;
    if(a[0] == 'H')
        cout << b << endl;
    if(a[0] == 'D' && b[0] == 'H')
        cout << 'D' << endl;
    if(a[0] == 'D' && b[0] == 'D')
        cout << 'H' << endl;
    return 0;
}

Measured memory_bytes: 256
using System;

namespace ALDS1
{
    class Program
    {
        static void Main(string[] args)
        {

            string[] input = Console.ReadLine().Split(' ');
            int x = int.Parse(input[0]);
            int y = int.Parse(input[1]);
           
            while(y > x || x % y != 0)
            {
                if (y > x)
                {
                    int k = y;
                    y = x;
                    x = k;
                }
               if (x % y != 0) x = x % y;
            }
            Console.WriteLine(y);
        }
    }
}

Measured memory_bytes: 9148
#include <bits/stdc++.h>
// #include "ane.cpp"

const int INF  = 1e9;
const long long INFLL = 1e18;
const int NMAX = 100005;
const int MMAX = 100005;
const int KMAX = 1005;
const int MOD  = 1e9 + 7;
using namespace std;

// comment to disable debug functions
#define DEBUG

// frequently used macros

#if __cplusplus >= 201103L
#define ALL(v) begin(v),end(v)
#define SORT(v) sort(begin(v), end(v))
#define FIND(v,x) find(begin(v), end(v), (x))
#else
#define ALL(v) (v).begin(),(v).end()
#define SORT(v) sort(v.begin(), v.end())
#define FIND(v,x) find(v.begin(), v.end(), (x))
#endif

#define MEMNEXT(from, to) do{ memmove((to), (from), sizeof(from)); \
memset((from), 0, sizeof(from)); } while(0)
#ifdef DEBUG
#define DUMP(x) do{ std::cerr << (#x) << ": " << x << std::endl; }while(0)
#else
#define DUMP(x) do{}while(0)
#endif

// frequent used aliases
typedef long long ll;
typedef pair<int, int> p;
typedef pair<ll, int> lp;
typedef pair<ll, ll> llp;
typedef vector<int> vec;
typedef vector<ll> vecll;
typedef vector<vec> mat;
typedef vector<vecll> matll;

// frequently used constants
static const int di[] = {-1, 0, 1, -1, 1, -1, 0, 1};
static const int dj[] = {-1, -1, -1, 0, 0, 1, 1, 1};

// frequently used structs
struct edge{
  int to,cost;
};

// printf for debug
#ifndef DEBUG
void debug(const char* format, ...){}
#else
void debug(const char* format, ...){
  va_list arg;
  va_start(arg, format);
  vprintf(format, arg);
  va_end(arg);
}
#endif

// dump vector
#ifdef DEBUG
#define DUMPV(v, c) do{       \
  printf("%s: ", #v);         \
  for (int i = 0; i < (c); ++i) \
  {                           \
  cout << (v)[i] << " ";      \
  }                           \
  cout << endl;               \
} while(0)
#else
#define DUMPV(v,c)
#endif

// std::fill of multi dimensions
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
  std::fill( (T*)array, (T*)(array+N), val );
}

// binary search
ll BSearch(ll _begin, ll _end, bool (*f)(int)){
  ll mid;
  while(_end - _begin > 1LL) {
  mid = (_begin + _end) / 2LL;
  if(f(mid)) {
    debug("BSearch: f(%d) == true\n", mid);
    _end = mid;
  }
  else
  {
    debug("BSearch: f(%d) == false\n", mid);
    _begin = mid;
  }
  }
  return _end;
}


int N,M,K,A[NMAX],B,C,D,E;
int dp[NMAX] = {};

string S;
vec v;
std::map<int, bool> mp;
ll ans = {};

void solve(){
  // main algorithm
  for (int i = 0; i < N; ++i)
  {
    mp[A[i]] = !mp[A[i]];
  }
  for(auto&& p : mp) {
    if(p.second) ans++;
  }
}
void debug(){
  // output debug information

}
void answer(){
  // output answer
  cout << ans << endl;
}
int main(int argc, char const *argv[])
{
  // operate inputs

  // Fill(dp, -1);
  cin >> N;
  for (int i = 0; i < N ; ++i)
  {
    scanf("%d", &A[i]);
  }
  solve();
  #ifdef DEBUG
  debug();
  #endif
  answer();

  return 0;
}

Measured memory_bytes: 5376
def main():
    N, K = map(int, input().split())
    A = list(map(int, input().split()))

    cnt = [0] * N

    for ai in A:
        cnt[ai - 1] += 1

    cnt.sort()
    ans = sum(cnt[:N-K])
    print(ans)

if __name__ == "__main__":
    main()

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

static const int N=100;

int main(){
int n,p[N+1],m[N+1][N+1];
cin >> n;
for(int i=1;i<=n;i++){
cin >> p[i-1]>>p[i];
}

for(int i=1;i<=n;i++) m[i][i]=0;
for(int l=2;l<=n;l++){
for(int i=1;i<=n-l+1;i++){
int j=i+l-1;
m[i][j]=(1<<21);
for(int k=i;k<=j-1;k++){
m[i][j]=min(m[i][j],m[i][k]+m[k+1][j]+p[i-1]*p[k]*p[j]);
}
}
}
cout << m[1][n] << endl;
return 0;
}


Measured memory_bytes: 3148
#include<stdio.h>

int main(){
  char O[51], E[51], p[101], i;
  int len = 0;
  
  scanf("%s %s", O, E);
  
  while(O[len]){
    len++;
  }
  
  for (i = 0; i < len; i++){
    p[2*i] = O[i];
    p[2*i + 1] = E[i];
  }
  p[2*i] = '\0';
  
  printf("%s\n", p);
  
  return 0;
}

Measured memory_bytes: 128
#include <iostream>

using namespace std;

int main()
{
    unsigned long long no = 0, two = 0, four = 0; //割れない, 2で割れる, 4で割れる
    unsigned long long N;

    cin >> N;

    unsigned long long a;

    for (int i = 0; i < N; i++)
    {
        cin >> a;
        if (a % 4 == 0)
        {
            four++;
        }
        else if (a % 2 == 0)
        {
            two++;
        }
        else
        {
            no++;
        }
    }

    if (two)
    {
        no++;
    }

    if (no - 1 <= four || (no == 0 && two % 2 == 0))
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
"use strict";

function main(input) {
    input = input.split(' ');
  	const N = parseInt(input[0]);
  	const Y = parseInt(input[1]);
  	
  	let combination = []

  	/* ristrictions */
  	if(N < 1 || N > 2000) {
  	    // violation
  	} else if(Y < 1000 || Y > 2*Math.pow(10,7)) {
  	    // violation
  	} else {
      	for(let i=0; i<=N; i++) {// the number of 10,000札
      	    if(combination.length > 0)break;
      	    for(let j=0; j<=N; j++) {// the number of 5,000札
      	        const num = N - (i+j)// the number of 1,000札
      	        const sum = 10000*i+5000*j+1000*num
      	        //console.log(`i=${i},j=${j},num=${num},sum=${sum},Y=${Y}`)
      	        if(num >= 0 && num <= N && sum === Y) {
      	            combination.push(i,j,num)
      	            break;
      	        }
      	    }
      	}
  	}
  	
  	if(!combination.length) {
  	    combination.push(-1,-1,-1)
  	}
	
	console.log(combination.map(c=>c.toString()).join(" "))

}

main(require("fs").readFileSync("/dev/stdin", "utf8"));

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

int main(){
    
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int n;
    cin >> n;
    
    bool flag = false;
    for(int i = 1; i <= 9; i++){
        for(int j = 1; j <= 9; j++){
            int ans = j * i;
            if(ans == n){
                flag = true;
                break;
            }
        }
    }
    
    if(flag) cout << "Yes" << endl;
    else cout << "No" << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define dbg(x) #x "=" << x << " "
#define fore(i,a,b) for(int i=a,gon=b;i<gon;++i)
#define pb push_back
#define F first
#define S second
typedef double lf;
typedef long long ll;
typedef pair<int, int> pii;

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    #ifdef LOCAL
        freopen("in.txt", "r", stdin);
        //freopen("out.txt", "w", stdout);
    #else
        #define endl '\n'
    #endif
    string s;
    cin >> s;
    cout << s.rfind('Z')-s.find('A')+1 << endl;
}


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

#define ull unsigned long long
#define ll long long

int main(){
    int n;
    cin >> n;
    map<int, int> m;

    m[n]++;
    int count=1;
    while(1){
        if(n&1){
            n = (3*n)+1;
        }
        else{
            n = n/2;
        }

        m[n]++;
        count++;

        if(m[n] == 2){
            cout << count;
            return 0;
        }
    }
}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define ld long double
#define mod 1000000007
#define endl "\n"
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define MAXX 1000000000000000000

int main()
{
    ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	ll s,w;
	cin >> s >> w;
	if(w >= s)
	{
		cout<<"unsafe";
	}
	else
	{
		cout<<"safe";
	}	
	return 0;
}

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

int main() {
	int H, W;  cin >> H >> W;
	string S;
	for (int i = 1; i <= H; i++) for (int j = 0; j < W; j++) {
		cin >> S;
		if (S == "snuke") {
			cout << (char)('A' + j) << i << endl;
		}
	}
}

Measured memory_bytes: 256