akhauriyash/Code-Regression huggingface dataset:
class UnionFind():
   # 作りたい要素数nで初期化
   # 使用するインスタンス変数の初期化
   def __init__(self, n):
       self.n = n
       # root[x]<0ならそのノードが根かつその値が木の要素数
       # rootノードでその木の要素数を記録する
       self.root = [-1]*(n+1)
       # 木をくっつける時にアンバランスにならないように調整する
       self.rnk = [0]*(n+1)
   # ノードxのrootノードを見つける
   def Find_Root(self, x):
       if(self.root[x] < 0):
           return x
       else:
           # ここで代入しておくことで、後の繰り返しを避ける
           self.root[x] = self.Find_Root(self.root[x])
           return self.root[x]
   # 木の併合、入力は併合したい各ノード
   def Unite(self, x, y):
       # 入力ノードのrootノードを見つける
       x = self.Find_Root(x)
       y = self.Find_Root(y)
       # すでに同じ木に属していた場合
       if(x == y):
           return
       # 違う木に属していた場合rnkを見てくっつける方を決める
       elif(self.rnk[x] > self.rnk[y]):
           self.root[x] += self.root[y]
           self.root[y] = x
       else:
           self.root[y] += self.root[x]
           self.root[x] = y
           # rnkが同じ（深さに差がない場合）は1増やす
           if(self.rnk[x] == self.rnk[y]):
               self.rnk[y] += 1
   # xとyが同じグループに属するか判断
   def isSameGroup(self, x, y):
       return self.Find_Root(x) == self.Find_Root(y)
   # ノードxが属する木のサイズを返す
   def Count(self, x):
       return -self.root[self.Find_Root(x)]
import sys
input = sys.stdin.readline
n,m=map(int,input().split())
lan=[[] for _ in range(m)]
for i in range(n):
    l=list(map(int,input().split()))
    for j in range(1,l[0]+1):
        lan[l[j]-1].append(i)
h=UnionFind(n)
for i in range(m):
    if len(lan[i])>1:
        for j in range(1,len(lan[i])):
            h.Unite(lan[i][0],lan[i][j])
print("NO" if h.Count(0)-n else "YES")

Measured memory_bytes: 16012
#include <iostream>
#include <algorithm>
#include <utility>
#include <vector>
#include <numeric>
#include <tuple>

template <class T, class U>
inline bool chmin(T& lhs, const U& rhs) {
  if (lhs > rhs) {
    lhs = rhs;
    return true;
  }
  return false;
}

template <class T, class U>
inline bool chmax(T& lhs, const U& rhs) {
  if (lhs < rhs) {
    lhs = rhs;
    return true;
  }
  return false;
}

// [l, r) from l to r
struct range {
  struct itr {
    int i;
    constexpr itr(int i_): i(i_) { }
    constexpr void operator ++ () { ++i; }
    constexpr int operator * () const { return i; }
    constexpr bool operator != (itr x) const { return i != x.i; }
  };
  const itr l, r;
  constexpr range(int l_, int r_): l(l_), r(std::max<int>(l_, r_)) { }
  constexpr itr begin() const { return l; }
  constexpr itr end() const { return r; }
};

// [l, r) from r to l
struct revrange {
  struct itr {
    int i;
    constexpr itr(int i_): i(i_) { }
    constexpr void operator ++ () { --i; }
    constexpr int operator * () const { return i; }
    constexpr bool operator != (itr x) const { return i != x.i; }
  };
  const itr r, l;
  constexpr revrange(int l_, int r_): l(l_ - 1), r(std::max<int>(l_, r_) - 1) { }
  constexpr itr begin() const { return r; }
  constexpr itr end() const { return l; }
};

template <class T>
struct fix_point: private T {
  explicit constexpr fix_point(T &&func): T(std::forward<T>(func)) { }
  template <class... Args>
  constexpr decltype(auto) operator () (Args &&... args) const {
    return T::operator()(*this, std::forward<Args>(args)...);
  }
};

template <class T>
constexpr decltype(auto) make_fix_point(T &&func) {
  return fix_point<T>{std::forward<T>(func)};
}

int main() {
  int N, M;
  std::cin >> N >> M;
  std::vector<std::vector<int>> graph(N);
  for (int i: range(0, M)) {
    int a, b;
    std::cin >> a >> b;
    --a; --b;
    graph[a].push_back(b);
    graph[b].push_back(a);
  }
  int four = 0, big = 0;
  for (int v: range(0, N)) {
    if (graph[v].size() % 2 != 0) {
      std::cout << "No\n";
      return 0;
    }
    if (graph[v].size() == 4) {
      ++four;
    }
    if (graph[v].size() >= 6) {
      ++big;
    }
  }
  if (big > 0) {
    std::cout << "Yes\n";
    return 0;
  }
  if (four >= 3) {
    std::cout << "Yes\n";
    return 0;
  }
  if (four <= 1) {
    std::cout << "No\n";
    return 0;
  }
  bool exist = false;
  auto loop = make_fix_point([&](auto &&loop, int u, int p, int s) -> void {
    if (u == s) {
      exist = true;
      return;
    }
    if (graph[u].size() == 4) {
      return;
    }
    for (int v: graph[u]) {
      if (v != p) {
        loop(v, u, s);
      }
    }
  });
  for (int i: range(0, N)) {
    if (graph[i].size() == 4) {
      for (int u: graph[i]) {
        loop(u, i, i);
      }
    }
  }
  std::cout << (exist ? "Yes" : "No") << '\n';
  return 0;
}


Measured memory_bytes: 6528
/*author : Yashvardhan
Sunday, April 26, 2020
5:39 PM
*/

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

using ll = long long;

#define int ll
#define pb push_back
#define vi vector<int>
#define pi pair<int,int>
#define vpi vector<pi>
#define ff first
#define ss second
#define mp make_pair
#define endl '\n'
#define all(a) a.begin(), a.end()
#define initialise(a, x) memset(a, x, sizeof(a))
#define rev(Y) reverse(all(Y))

#pragma GCC optimize ("O3")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define _CRT_SECURE_NO_WARNINGS

#ifdef __APPLE__
#define debug(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){cerr << name << " : " << arg1 << endl;}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
	const char* comma = strchr(names + 1, ',');
	cerr.write(names, comma - names) << " : " << arg1 << "  ";
	__f(comma + 1, args...);}
#else
#define debug(...)
#endif

template <typename T> ostream& operator << (ostream& os,const vector<T>& v){for(int i=0;i<v.size();++i) os<<v[i]<<" ";return os;} 
template <typename T> ostream& operator << (ostream& os,const set<T>& v){for(auto it:v) os<<it<<" ";return os;} 
template <typename T, typename S> ostream& operator << (ostream& os, const pair<T,S>& v) {os<<v.ff<<" "<<v.ss;return os;}

const int mod = 1e9 + 7;
const int inf = 2e18;
const int ninf = -2e18;

int takemod(int a){return ((a%mod)+mod)%mod;}

int pow(int a, int b, int m)
{
	int ans = 1;
	a %= m;
	while (b)
	{
		if (b & 1)
			ans = (ans * a) % m;
		b /= 2;
		a = (a * a) % m;
	}
	return ans;
}

int modinv(int a){return takemod( pow( takemod(a), mod-2,mod ) );}


signed main()
{

	ios_base::sync_with_stdio(false);
	cin.tie(0);

	#ifdef __APPLE__
		freopen("input.txt","r",stdin);
		freopen("output.txt","w",stdout);
		freopen("error.txt","w",stderr);
	#endif

	time_t t1, t2;
	t1 = clock();
	
	set<string> s;
	int n;
	cin >> n;

	for(int i = 0; i < n; i++){
		string x;
		cin >> x;
		s.insert(x);
	}	

	cout << s.size() << endl;
	

	t2 = clock();
	cerr << endl << t2-t1 << endl;
	
	return 0;
}



Measured memory_bytes: 19248
import collections


class Formatter:
    def __init__(self, s):
        self._d = collections.deque(s)
        self._d_reverse = collections.deque(reversed(s))

    def reverse(self):
        self._d, self._d_reverse = self._d_reverse, self._d

    def append(self, s):
        self._d.append(s)
        self._d_reverse.appendleft(s)

    def appendleft(self, s):
        self._d.appendleft(s)
        self._d_reverse.append(s)

    def __iter__(self):
        return iter(self._d)


S = input()
Q = int(input())

d = Formatter(S)

for _ in range(Q):
    Qi = input()
    if Qi == "1":
        d.reverse()
    else:
        T, F, C = Qi.split()
        if F == "1":
            d.appendleft(C)
        else:
            d.append(C)

print("".join(d))


Measured memory_bytes: 11116
#include <bits/stdc++.h>
#define int long long
using namespace std;

signed main() {
  int N, M;
  cin >> N >> M;
  if( N == 1 && M == 1 ){
    cout << 1 << endl;
    return 0;
  }
  if( N == 1 || M == 1 ){
    cout << N*M-2 << endl;
  }else{
    cout << (N-2) * (M-2) << endl;
  }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#include<math.h>
#include<string.h>
int main()
{
    unsigned ll a,b,c,d,test,i,j,k,l,m,o,p;
    cin>>a;
    ll s=0;
    if(a%2==1)printf("0\n");
    else
    {
        for(i=10; i<=a; i=i*5)
        {
            s=a/i+s;
        }
        cout<<s<<endl;
    }
    return 0;
}


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

int main() {
	
	int x,a,b;
	scanf("%d %d %d", &x, &a, &b);
	
    int dist1 = abs(x-a), dist2 = abs(x-b);
    
    if(dist1<dist2){
        printf("A\n");
    } else printf("B\n");

	return 0;
}


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

int main(){
  int A,B,i,sum;
  cin >> A >> B;
  sum=0;
  
  for(i=0; i<2; i=i+1){
    if(A==B){
      sum=A+sum;
      A=A-1;
    }
    else if(A>B){
      sum=A+sum;
      A=A-1; 
    }
    else if(A<B){
      sum=sum+B;
      B=B-1;
    }    
  }
  cout << sum <<endl;
  
  return 0;
  
}

Measured memory_bytes: 256
h, w, k = map(int, input().split())
dp = [[0] * w for _ in range(h + 1)]
dp[0][0] = 1
fb = (1, 1, 2, 3, 5, 8, 13, 21)
for y in range(1, h + 1):
    for x in range(w):
        if x - 1 >= 0:
            dp[y][x] += dp[y - 1][x - 1] * fb[x - 1] * fb[w - x - 1]
        if x + 1 <= w - 1:
            dp[y][x] += dp[y - 1][x + 1] * fb[x] * fb[w - x - 2]
        dp[y][x] += dp[y - 1][x] * fb[x] * fb[w - x - 1]
        dp[y][x] %= 1000000007
print(dp[h][k - 1])

Measured memory_bytes: 3064
#include <iostream>
#include <algorithm>
#include <map>
#include <vector>
#include <queue>
#include <string>
#define int long long
#define P pair<int,int>
#define vec vector<int>
#define rep(i,n) for(int i=0;i<n;i++)
#define vsort(vec) sort(vec.begin(),vec.end())
#define INF 1000000007
using namespace std;
int solve(int n) {
	if (n == 0)return 1;
	return (solve(n-1)*n) % 1000000007;
}
signed main() {
	int n, m;
	cin >> n >> m;
	if (abs(n - m) > 1)cout << 0 << endl;
	else if ((n + m) % 2) {
		cout << (solve(n)*solve(m)) % INF << endl;
	}
	else {
		cout << (solve(n)*solve(m) * 2) % INF << endl;
	}
	system("PAUSE");
	return 0;
}


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

using namespace std;

template <class T>inline T updmax(T& a, T b) {return a = max(a, b);}
template <class T>inline T updmin(T& a, T b) {return a = min(a, b);}

class Solution {
public:
	void solve() {
		int n, k, s;
		cin >> n >> k >> s;
		vector<int> a(n, 0);
		for(int i=0; i < k; i++)a[i] = s;
		for(int i=k; i < n; i++)a[i] = (s==1)?2:s-1;
		for(int i=0; i<n; i++)cout << a[i] << " ";
		cout << "\n";
		return;
	};
};

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	Solution solution;
	solution.solve();
	return 0;
}

Measured memory_bytes: 1792
x,y=input().split()
l=['1','3','5','7','8','10','12','4','6','9','11','2']
x_loc=l.index(x)
y_loc=l.index(y)

if x_loc==11 and y_loc==11:
    print('Yes')
elif x_loc<7 and y_loc<7:
    print('Yes')
elif x_loc>6 and x_loc<11 and y_loc>6 and y_loc<11:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 3064
import sys
input = sys.stdin.readline
s = input().strip()
n = len(s)
ans = 0
for i in range(1<<(n-1)):
    t = ''
    for j in range(n-1):
        t += s[j]
        if (i >> j) & 1:
            t += '+'
    else:
        t += s[n-1]
    ans += eval(t)
print(ans)


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

using namespace std;

int A[100010];
int main()  {
    int n;
    scanf("%d",&n);
    for ( int c=1 ; c<=n ; c++ )    scanf("%d",&A[c]);
    bool pos = true;
    long long sum = 0,ans=0;
    for ( int c=1 ; c<=n ; c++ )
    {
        sum += A[c];
        if ( pos )
        {
            if ( sum <= 0 )
            {
                ans += 1-sum;
                sum = 1;
            }
        }
        else
        {
            if ( sum >= 0 )
            {
                ans += 1+sum;
                sum = -1;
            }
        }
        pos = !pos;
    }
    pos = false;
    sum = 0;
    long long ans2=0;
    for ( int c=1 ; c<=n ; c++ )
    {
        sum += A[c];
        if ( pos )
        {
            if ( sum <= 0 )
            {
                ans2 += 1-sum;
                sum = 1;
            }
        }
        else
        {
            if ( sum >= 0 )
            {
                ans2 += 1+sum;
                sum = -1;
            }
        }
         pos = !pos;
    }
    cout << min(ans,ans2);
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
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 n, m;
vector< vector<int> > graph(100100, vector<int>());
int dp[100100];

int rec(int check) {
    if(dp[check] != -1) return dp[check];
    int res = 0;
    for(int i = 0; i < graph.at(check).size(); ++i) {
        chmax(res, rec(graph.at(check).at(i))+1);
    }
    return dp[check] = res;
}

int main() {
    cin >> n >> m;
    for(int i = 0; i < m; ++i) {
        int x, y;
        cin >> x >> y;
        x--; y--;
        graph.at(x).push_back(y);
    }

    for(int i = 0; i <= n; ++i) dp[i] = -1;

    int ans = 0;
    for(int i = 0; i < n; ++i) chmax(ans, rec(i));

    cout << ans << endl;
}

Measured memory_bytes: 8192
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

typedef struct data
{
  char s[16];
  int p;
  int n;
} DATA;

static void sort(DATA *d, int n, int key)
{
  int i = 0;
  int j = 0;

  for(i = 0; i < n - 1; i++)
  {
    for(j = 1; j < n - i; j++)
    {
      if(!key)
      {
        if(d[j].p > d[j-1].p)
        {
          DATA tmp = d[j];
          d[j] = d[j-1];
          d[j-1] = tmp;
        }
      }
      else
      {
        if(strcmp(d[j].s, d[j-1].s) < 0)
        {
          DATA tmp = d[j];
          d[j] = d[j-1];
          d[j-1] = tmp;
        }
      }
    }
  }
}

int main(int argc, char **argv)
{
  DATA d[100] = {0};
  int n = 0;
  int i = 0;

  scanf("%d", &n);

  for(i = 0; i < n; i++)
  {
    scanf("%s %d", d[i].s, &d[i].p);
    d[i].n = i + 1;
  }

  sort(d, n, 0);
  sort(d, n, 1);

  for(i = 0; i < n; i++)
  {
    printf("%d\n", d[i].n);
  }

  return 0;
}


Measured memory_bytes: 128
//#pragma GCC optimize("O3") 
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx") 
//#define __USE_MINGW_ANSI_STDIO 0
#include <bits/stdc++.h>
#define TASK "zak"
#define pb push_back
#define fi first
#define se second
using namespace std;

#ifdef LOCAL
	#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
	#define eprintf(...) (void)42
#endif

// every true-boy doesn't read statement!

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

int N;
multiset < int > st;
ll sum = 0;

void solve() {
	cin >> N;
	int x;
	for (int i = 0; i < 3 * N; i++)
		cin >> x, st.insert(x);
	while (!st.empty()) {
		st.erase(st.find(*st.rbegin()));
		st.erase(st.begin());
		sum += *st.rbegin();
		st.erase(st.find(*st.rbegin()));
	}
	cout << sum;
}

int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
#ifdef LOCAL
	assert(freopen("xxx.in", "r", stdin));
	assert(freopen("xxx.out", "w", stdout));
#else
	//assert(freopen(TASK".in", "r", stdin));
	//assert(freopen(TASK".out", "w", stdout));
#endif
	solve();
	return 0;
}

Measured memory_bytes: 14336
N=int(input())
AC=0
TLE=0
WA=0
RE=0
for i in range(N):
    x=input()
    if x == "AC":
        AC += 1
    elif x == "TLE":
        TLE+=1
    elif x=="WA":
        WA+=1
    else:
        RE+=1
print("AC x " + str(AC))
print("WA x " + str(WA))
print("TLE x " + str(TLE))
print("RE x " + str(RE))

Measured memory_bytes: 74048
#include<bits/stdc++.h>
#define fast ios::sync_with_stdio(false), cin.tie(0);
#define ll long long
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define endl '\n'

using namespace std;

main()
{
    fast;
    int a,b,num;
    cin>>a>>b;
    if (b<10)
        num=a*10+b;
    else if (b<100)
        num=a*100+b;
    else
        num=a*1000+b;
    int p=sqrt(num);
    if (p*p==num || (p-1)*(p-1)==num || (p+1)*(p+1)==num)
        cout<<"Yes\n";
    else
        cout<<"No\n";
}

Measured memory_bytes: 256
using System;

public class hello
{
    public static void Main()
    {
        var n = int.Parse(Console.ReadLine().Trim());
        var g = int.Parse(Console.ReadLine().Trim());
        string[] line = Console.ReadLine().Trim().Split(' ');
        var t = Array.ConvertAll(line, int.Parse);
        var game = new int[g, n];
        for (int i = 0; i < g; i++)
        {
            string[] line2 = Console.ReadLine().Trim().Split(' ');
            for (int j = 0; j < n; j++)
                game[i, j] = int.Parse(line2[j]);
        }
        var player = new int[n];
        for (int i = 0; i < g; i++)
        {
            var count = 0;
            for (int j = 0; j < n; j++)
                if (t[i] == game[i, j]) player[j] += 1;
                else count++;
            player[t[i] - 1] += count;
        }
        foreach (var x in player)
            Console.WriteLine(x);
    }
}

Measured memory_bytes: 9352
N = int(input())
aa = list(map(int, input().split()))

if N % 2 == 0:
    dp = [[[0, 0] for j in range(2)] for i in range(N)]

    for i, a in enumerate(aa):
        dp[i][0][1] = dp[i - 1][0][0] + a
        dp[i][0][0] = dp[i - 1][0][1]

        dp[i][1][0] = max(dp[i - 1][1][1], dp[i - 1][0][0])
        dp[i][1][1] = dp[i - 1][1][0] + a

    print(max(max(dp[-1][0]), dp[-1][1][1]))
else:
    dp = [[[0, 0] for j in range(3)] for i in range(N)]

    for i, a in enumerate(aa):
        dp[i][0][1] = dp[i - 1][0][0] + a
        dp[i][0][0] = dp[i - 1][0][1]

        dp[i][1][0] = max(dp[i - 1][1][1], dp[i - 1][0][0])
        dp[i][1][1] = dp[i - 1][1][0] + a

        dp[i][2][0] = max(dp[i - 1][2][1], dp[i - 1][1][0])
        dp[i][2][1] = dp[i - 1][2][0] + a

    print(max(max(dp[-1][1]), dp[-1][2][1]))


Measured memory_bytes: 114860
#include <bits/stdc++.h>
#define LL long long
#define FAST_READ ios_base::sync_with_stdio(false); cin.tie(NULL);
using namespace std;


int main()
{
    string s, ss;
    cin >> s >> ss;
    s += ss;
    stringstream sss(s);
    int d;
    sss >> d;
    int x = sqrt(d);
    if(x*x == d){
        cout << "Yes\n";
    }
    else{
        cout << "No\n";
    }
    return 0;
}


Measured memory_bytes: 256
candidate = []
# べき乗リストを更新する
for i in range(32):
    if i >= 1:
        for j in range(32):
            if i**j <= 1000:
                if j > 1:
                    if i**j not in candidate:
                        candidate.append(i**j)
            else:
                break

candidate = sorted(candidate)
x = int(input())
result = 1
for c in candidate[1:]:
    if x >= c:
        result = c
    else:
        break
print(result)

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

int main(){
    int N,M;
    cin >> N >> M;
    vector<long long> a(N);
    vector<long long> b(N);
    vector<long long> c(M);
    vector<long long> d(M);
    
    rep(i,N)cin >>a[i] >> b[i];

    rep(i,M)cin >>c[i] >> d[i];

    typedef pair<long long, int> ManDist;
    auto comp = [](ManDist l, ManDist r){
        if(l.first != r.first){
            return (l.first > r.first);
        }else{
            return (l.second > r.second);
        }
    };
    // auto comp = [](ManDist l, ManDist r){return (l.first > r.first); };

    rep(i,N){
        priority_queue<ManDist, vector<ManDist>, decltype(comp)> que(comp);
        for(int j=0; j<M; j++){
            long long dist = abs(a[i] - c[j]) + abs(b[i] - d[j]);
            // cout << dist << " : " << j << endl;
            que.push(ManDist(dist, j+1));
        }
        ManDist man = que.top();
        cout << man.second << endl;
    }
    return 0;
}

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

int main() {
	double r;

	cin >> r;

	cout << fixed;
    cout << setprecision(6);
    cout << M_PI*r*r << " " << 2*M_PI*r << endl;

	return 0;
}


Measured memory_bytes: 3292
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define x first
#define y second
#define pii pair<int , int>
#define mp make_pair
#define pb push_back
#define sz(a) (int)(a.size())
const int INF = 1000 * 1000 * 1000 + 7;
const ll LINF = INF * (ll)INF;
const int MAX = 2005;
const int LOG = 20;
int dp[105][105][2];
string s[105];
void upd(int &a , int b)
{
	a = min(a , b);
}
int main()
{
	ios_base::sync_with_stdio(0);
	int n, m;
	cin >> n >> m;
	for(int i = 0;i < n; i++)
	{
		cin >> s[i];
		for(auto &x : s[i])
			x = x == '#';
	}
	for(int i = 0; i < n; i++)
		for(int j = 0; j < m; j++)
			for(int k = 0; k < 2; k++)
				dp[i][j][k] = INF;
	dp[0][0][0] = s[0][0] == 0 ? 0 : INF;
	dp[0][0][1] = s[0][0] == 1 ? 1 : INF;
	for(int i = 0; i < n; i++)
		for(int j = 0; j < m; j++)	
			for(int k = 0; k < 2; k++)
			{
				if(i + 1 < n)
					upd(dp[i + 1][j][s[i + 1][j]] , dp[i][j][k] + (k != s[i + 1][j] && s[i + 1][j]));
				if(j + 1 < m)
					upd(dp[i][j + 1][s[i][j + 1]] , dp[i][j][k] + (k != s[i][j + 1] && s[i][j + 1]));
			}
					
	cout << min(dp[n - 1][m - 1][0] , dp[n - 1][m - 1][1]);
}


Measured memory_bytes: 384
package main

import (
	"fmt"
)

func main() {
	var h1, m1, h2, m2, k int
	fmt.Scanf("%d %d %d %d %d", &h1, &m1, &h2, &m2, &k)
	answer := schedule(h1, m1, h2, m2, k)
	fmt.Println(answer)
}

func schedule(h1, m1, h2, m2, k int) int {
	start := 60*h1 + m1
	end := 60*h2 + m2
	return end - k - start
}


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

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

using Graph = vector<vector<int>>;

ll calc(ll a, ll b, ll p){//aのb乗をpで割った余り
  if(b == 0) return 1;

  else if(b%2 == 0){
    ll d = calc(a,b/2,p);
    return (d*d)%p;
  }
  else if(b%2 == 1){
    return (a * calc(a,b-1,p))%p;
  }
}

typedef pair<int,int> P;

bool is_prime(int n){//nが素数であるかどうか判定 iで割り切れると素数でない
    if(n == 1) return false;//1は例外
    for(int i = 2;i*i <= n;i++){
        if(n%i == 0) return false;
    }
    
    return true;
}
int factorial(int a){
  int res = 1;
  while(a){
    res *= a;
    a--;
  }
  return res;
}


int main(){
  ll a,b;
  cin >> a >> b;
  if(a*b <= 0){//a,bのいずれかが0か、a,bが異符号の時
    cout << "Zero" << endl;
  }
  else{
    if(a > 0) cout << "Positive" << endl;//a,bに0はなく、同一符号
    else if(b < 0 && (b-a+1)%2 == 1) cout << "Negative" << endl;//奇数個の負の積
    else if(b < 0 && (b-a+1)%2 == 0) cout << "Positive" << endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>

using namespace std;
using boost::multiprecision::cpp_int;

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

#define deg_to_rad(deg) (((deg)/360)*2*PI)

const ll LINF = LLONG_MAX;
const ll MOD = 1e9+7;
//const ll MOD = 998244353;

const ld PI = (acos(-1));
const ld EPS = 0.0000000001;
// cout << fixed << setprecision(10) << middle << endl;

int main() {
    // input, ready
    ll N;
    cin >> N;
    ll org = N;

    // resolve
    ll ans=0;
    for (ll i=2; i<=sqrt(org); i++) {
        int j=1;
        int cnt=1;
        while(N%i==0) {
            N /= i;
            if (j==cnt) {
                j++;
                cnt=0;
                ans++;
            }
            cnt++;
        }
    }

    // output
    if (N > 1) cout << ans+1 << endl;
    else cout << ans << endl;


    return 0;
}


Measured memory_bytes: 3672
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
using namespace std;
 
#include <math.h>
#include <iomanip>
#include <vector>
#include <queue>
#include <climits>
using Graph = vector<vector<int>>;
const double PI = 3.14159265358979323846;
 
 
 
long long modpow(long long a, long long n, long long mod) {
	long long res = 1;
	while (n > 0) {
		if (n & 1) res = res * a % mod;
		a = a * a % mod;
		n >>= 1;
	}
	return res;
}
 
 
//約数をベクトル形式で返す
vector<int> vect_yakusuu(int n) {
	vector<int> ret;
	for (int i = 1; i*i <= n; i++) {
		if (n%i == 0) {
			ret.push_back(i);
			if (i*i != n) ret.push_back(n / i);
		}
	}
	sort(begin(ret), end(ret));
	return ret;
}
 
 
 
int main() {
 
	long long N;
    string S[100100];
    int ans[5];

    cin >> N;
    for (int i=0;i<N;i++){
        cin >> S[i];
    }

    for (int i=0;i<4;i++){
        ans[i]=0;
    }

    for (int i=0;i<N;i++){
        if (S[i]=="AC"){
            ans[0]++;
        }
        if (S[i]=="WA"){
            ans[1]++;
        }
        if (S[i]=="TLE"){
            ans[2]++;
        }
        if (S[i]=="RE"){
            ans[3]++;
        }
    }

    cout << "AC x " << ans[0] <<endl;
    cout << "WA x " << ans[1] <<endl;
    cout << "TLE x " << ans[2] <<endl;
    cout << "RE x " << ans[3] <<endl;
    



	cin >> ans[0];
 
	return 0;
 
 
}

Measured memory_bytes: 6756
#include <iostream>
#include <string>
#include <map>

int main() {
    std::map<std::string, int> mp;
    int Q;
    std::cin >> Q;
    for (int q = 0; q < Q; ++q) {
        int t;
        std::cin >> t;
        if (t == 0) {
            std::string k;
            int x;
            std::cin >> k >> x;
            mp[k] = x;
        } else {
            std::string k;
            std::cin >> k;
            std::cout << mp[k] << std::endl;
        }
    }
}


Measured memory_bytes: 27828
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>

using  namespace std;

int main() {
    int n;
    cin >> n;
    vector<string> w(n);
    for (int i = 0; i < n; ++i) {
        cin >> w[i];
    }
    for (int i = 1; i < n; ++i) {
        bool flag = false;
        for (int j = 0; j < i; ++j) {
            if(w[j] == w[i]) flag = true;
        }
        if(!flag)
        {
            if(w[i][0] != w[i - 1].back())
            {
                cout << "No" << endl;
                return 0;
            }
        }else{
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
    return 0;
}


Measured memory_bytes: 256
import numpy as np

a = int(input())
list = []

for i in range(a):
    if (i + 1) % 3 == 0 or (i + 1) % 5 == 0:
        list.append(0)
    else:
        list.append(i + 1)

np_list = np.array(list)
print(np_list.sum())

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

dict ={}
list = []

for i in range(n, 0,-1): # Nから１までのN個の”出目”のリストを作成
    list.append(i)
#print(list)

count_dict = {}
sum = 0
count = 0
i = 0
while(i <= len(list)-1):
    if k / list[i]  <= 2 ** count:
        #print("list is", list[i])
        #print("count is", count)
        #sum += 1 / (2 ** count)
        if count not in count_dict:
            count_dict[count] = 1
        else:
            count_dict[count] += 1
        #print("sum is", sum)
        i += 1
    else:
        count += 1

max_count = max(count_dict)
#print(count_dict)
for i in range(max_count + 1):
    #print(i)
    if i in count_dict:
        sum += count_dict[i] / (2 ** i)
        #print(sum)

print(sum/n)




Measured memory_bytes: 7064
H, W, K = list(map(int, input().split()))
s = [list(input()) for _ in range(H)]

nbo = "#"

L = [0] * H
f = -1
for i in range(H):
  for j in range(W):
    if s[i][j] == nbo:
      L[i] += 1
      if f == -1:
        f = i

D = [[0] * W for _ in range(H)]
t = 1
for i in range(f, H):
  c = 0
  for j in range(W):
    if L[i] == 0:
      D[i][j] = D[i - 1][j]
    else:    
      D[i][j] = t
      if s[i][j] == nbo:
        c += 1
        if c < L[i]:
          t += 1
  if L[i] != 0:
    t += 1

for i in range(f - 1, -1, -1):
  for j in range(W):
    D[i][j] = D[i + 1][j]

for i in range(H):
  for j in range(W):
    print(D[i][j], end = " ")
  print("")

Measured memory_bytes: 53976
parseInt(x) = parse(Int, x)
parseMap(x::Array{SubString{String},1}) = map(parseInt, x)
#Int 最大値
function heap(a::Array{Int,1})
	h = Float64[a[1]]
	for i in 2:length(a)
		hpush(h,a[i])
	end
	h
end

function hpush(h::Array{Float64,1},x)
	push!(h,x)
	l = length(h)
	if l>1
		k = div(l,2)
		while h[k]<x&&k>=1
			tmp = h[k]
			h[k] = x
			h[l] = tmp
			k = max(div(k,2),1)
			l = div(l,2)
		end
	end
end

function hpop(h::Array{Float64,1})
	x = h[1]
	z = pop!(h)
	if length(h)>0
		h[1] = z
		k = 1
		l = length(h)
		while k <= l
			if 2*k>l
				break
			elseif 2*k+1>l
				if h[2*k]<=z
					break
				else
					tmp = h[2*k]
					h[2*k] = z
					h[k] = tmp
					k = 2*k
				end
			else
				if h[2*k]<=z&&h[2*k+1]<=z
					break
				else
					t = h[2*k]<h[2*k+1]?2*k+1:2*k
					tmp = h[t]
					h[t] = z
					h[k] = tmp
					k = t
				end
			end
		end
	end
	x
end


function main()
	n,m = readline() |> split |> parseMap
	a = readline() |> split |> parseMap
	h = heap(a)
	for i in 1:m
		t = hpop(h)
		t /=2
		hpush(h,t)
	end
	s = 0
	for i in 1:n
		s += floor(Int, h[i])
	end
	println(s)
end

main()

Measured memory_bytes: 170012
N, M, X = map(int, input().split())
A = list(map(int, input().split()))

cost_to_reach_0 = len([i for i in A if i < X])
cost_to_reach_N = len([i for i in A if i > X])

print(min(cost_to_reach_0, cost_to_reach_N))


Measured memory_bytes: 2940
#include <bits/stdc++.h>
#define ll long long
#define INF 1000000005
#define MOD 1000000007
#define EPS 1e-10
#define rep(i,n) for(int i=0;i<(int)n;++i)
#define each(a, b) for(auto (a): (b))
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define pb push_back
#define show(x) cout <<#x<<" = "<<(x)<<endl
#define spair(p) cout <<#p<<": "<<p.fi<<" "<<p.se<<endl
#define svec(v) cout<<#v<<":";rep(kbrni,v.size())cout<<" "<<v[kbrni];cout<<endl
#define sset(s) cout<<#s<<":";each(kbrni,s)cout <<" "<<kbrni;cout<<endl

using namespace std;

typedef pair<int,int>P;

const int MAX_N = 100005;

int main()
{
    ll K;
    cin >> K;
    ll cnt = K / 50;
    ll mod = K % 50;
    vector<ll> vec(50);
    int n = 50;
    rep(i,n){
        vec[i] = n+cnt-1;
    }
    rep(i,mod){
        vec[i]++;
    }
    for(int i=mod;i<50;i++){
        vec[i] -= mod;
    }
    cout << n << endl;
    rep(i,n-1){
        cout << vec[i] << " ";
    }
    cout << vec[n-1] << endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>

using namespace std;

int main(){
  int N,sum = 0;
  cin >> N;
  if(N < 10){
    cout << N << endl;
    return 0;
  }
  else if(N >= 10 && N < 100){
    cout << "9" << endl;
    return 0;
  }
  sum = sum + 9;
  if(N >= 100 && N < 1000){
    cout << sum + (N-99) << endl;
    return 0;
  }
  else if(N >= 1000 && N < 10000){
      cout << "909" << endl;
      return 0;
  }
  sum = sum + 900;
  if(N >= 10000 && N < 100000){
    cout << sum + (N - 9999) << endl;
    return 0;
  }
  else if(N == 100000){
      cout << "90909" << endl;
      return 0;
  }
}

Measured memory_bytes: 256
var
	N,ans,i,id:Longint;
	t:Array[1..50]of Longint;
	s:Array[1..50]of String;
	x,inp:String;
	flag:Boolean;
begin
	readln(N);
	for i:=1 to N do begin
		readln(inp);
		id:=1;
		while inp[id]<>' 'do inc(id);
		s[i]:=copy(inp,1,id-1);
		t[i]:=0;
		inc(id);
		while id<=length(inp)do begin
			t[i]:=t[i]*10+ord(inp[id])-48;
			inc(id);
		end;
	end;
	readln(x);
	for i:=1 to N do begin
		if flag then inc(ans,t[i]);
		if s[i]=x then flag:=True;
	end;
	writeln(ans);
end.


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

struct Benri { Benri() { std::cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(12);}} benri;

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using pii = pair<int, int>;
using vll = vector<long long>;
using vvll = vector<vll>;
using pll = pair<ll, ll>;
using ull = unsigned long long;

template <typename T> using PQ = priority_queue<T>;
template <typename T> using minPQ = priority_queue<T, vector<T>, greater<T>>;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define mp make_pair
#define F first
#define S second

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; }

constexpr long long MOD = 1000000007;
//constexpr long long MOD = 998244353;
//constexpr int INF = 1001001001;
constexpr ll INF = 1001001001001001001LL;
//constexpr double INF = 1e10;
constexpr double EPS = 1e-10;
using number = long long;

int main() {
    ll n, k; cin >> n >> k;
    vll a(n), f(n);
    rep(i, n) cin >> a[i];
    rep(i, n) cin >> f[i];
    sort(all(a));
    sort(all(f),greater<ll>());

    ll lb = -1LL, ub = (ll)1e12;
    while (ub - lb > 1) {
        ll mid = (lb + ub) / 2;
        ll sum = 0;
        rep(i, n) {
            if (a[i]*f[i] <= mid) continue;
            else {
                sum += a[i] - (mid / f[i]);
            }
        }
        if (sum <= k) ub = mid; //実現可能
        else lb = mid;  //不可能
    }
    cout << ub << endl;

}


Measured memory_bytes: 3456
// In the name of God

#include <iostream>
#include <algorithm>
#include <fstream>
#include <vector>
#include <deque>
#include <assert.h>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <stdio.h>
#include <string.h>
#include <utility>
#include <math.h>
#include <bitset>
#include <iomanip>

using namespace std;

const int N = (int) 1e6 + 6, mod = (int) 0;
int n, p[N], a[N];
bool check(int lim) {
    for (int i = 0; i < 2 * n - 1; ++i)
        a[i] = (p[i] <= lim);
    int cnt = 0;
    for (int i = 0; i < 2 * n - 1; ++i) {
        cnt += a[i];
   //     cout << a[i];
    }
    for (int i = n - 1, j = n - 1; i >= 1; --i, ++j) {
        if (a[i] == a[i - 1]) {
            return a[i];
        }
        if (a[j] == a[j + 1]) {
            return a[j];
        }   
    }
    return cnt == n;
}
int32_t main() {
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    cin >> n;
    for (int i = 0; i < 2 * n - 1; ++i)
        cin >> p[i];
 //   check(4);
   // return 0;
    int bl = 1, br = 2 * n - 1;
    while (bl < br - 1) {
        int bm = bl + br >> 1;
        if (check(bm))
            br = bm;
        else
            bl = bm;
    }
    cout << br << endl;
}

Measured memory_bytes: 1920
#include <iostream>
using namespace std;
int main(void){
    string s, t;
    cin >> s >> t;
    
    for(int i = 0; i < s.length() - 1; i++){
        for(int j = i+1; j < s.length(); j++){
            if(s[i] > s[j]){
                char tmp;
                tmp = s[i];
                s[i] = s[j];
                s[j] = tmp;
            }
        }
    }
    for(int i = 0; i < t.length() - 1; i++){
        for(int j = i+1; j < t.length(); j++){
            if(t[i] < t[j]){
                char tmp;
                tmp = t[i];
                t[i] = t[j];
                t[j] = tmp;
            }
        }
    }
    if(s < t){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    
    return 0;
}


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

using namespace std;

int main() {
  int numStones;
  int numHops;
  vector<int> stones;
  cin >> numStones;
  cin >> numHops;
  for (int i = 0; i < numStones; ++i) {
    int stone;
    cin >> stone;
    stones.push_back(stone);
  }
  vector<int> minCost;
  minCost.resize(numStones);
  // cost[i] = min(cost[i - 1] + abs(stone[i] - stone[i - 1]), cost[i - 2] +
  // abs(stone[i] - stone[i - 2])..., cost[i - k] + abs(stone[i] - stone[i -
  // k]).
  minCost.front() = 0;
  for (int i = 1; i < minCost.size(); ++i) {
    int cost = INT_MAX;
    for (int j = 1; j <= min(numHops, i); ++j) {
      int newCost = minCost[i - j] + abs(stones[i] - stones[i - j]);
      cost = min(cost, newCost);
    }
    minCost[i] = cost;
  }
  cout << minCost.back() << endl;
  return 0;
}

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

int main(){
    int n;
    cin>>n;

    for(int cnt=0;cnt<n;++cnt){
        int x,y,block;
        cin>>x>>y;
        cin>>block;
        int Hort[100][100];
        int Vert[100][100];
        for(int i=0;i<=100;++i){
            for(int j=0;j<=100;++j){
                Hort[i][j]=1;
                Vert[i][j]=1;
            }
        }
        
        for(int j=0;j<block;++j){
            pair<int,int> s,t;
            cin>>s.first>>s.second;
            cin>>t.first>>t.second;
            if(s.first<t.first){
                Hort[s.first][s.second]=0;
            }
            else if(s.first>t.first){
                Hort[t.first][t.second]=0;
            }
            else if(s.second<t.second){
                Vert[s.first][s.second]=0;
            }
            else if(s.second>t.second){
                Vert[t.first][t.second]=0;
            }
        }

        long long cases[100][100]={0};
        cases[0][0]=1;
        for(int i=0;i<=x;++i){
            for(int j=0;j<=y;++j){
                if(!(i+j)){
                    ;
                }
                else if(i==0){
                    cases[i][j]=cases[i][j-1]*Vert[i][j-1];
                }
                else if(j==0){
                    cases[i][j]=cases[i-1][j]*Hort[i-1][j];
                }
                else{
                    cases[i][j]=cases[i-1][j]*Hort[i-1][j]+cases[i][j-1]*Vert[i][j-1];
                }
            }
        }

        if(cases[x][y]!=0){
            cout<<cases[x][y]<<endl;
        }
        else{
            cout<<"Miserable Hokusai!"<<endl;
        }
    }
}

Measured memory_bytes: 3084
#include <bits/stdc++.h>
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 rep2(i,n) for(int i=0;i<=n;i++)
#define repr(i,a,n) for(int i=a;i<n;i++)
#define all(a) a.begin(),a.end()
#define P pair<long long,long long>
#define double long double
#define INF 1e10
#define MOD 1e9+7
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
using Graph = vector<vector<int>>;
signed main(){
int a;
  cin>>a;
  if(a%2==1)
    cout<<0;
  else{
    a=a/2;
    int b=0;
    rep1(i,25){
      int c=pow(5,i);
    b+=(a-a%c)/c;
    }
      cout<<b;                   
  }
}

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

int main(){
  string s;
  cin >> s;
  int a,b,c,d;
  a=(int)(s[0]-'0');
  b=(int)(s[1]-'0');
  c=(int)(s[2]-'0');
  d=(int)(s[3]-'0');
  for(int i=0;i<8;i++){
    if(a+((i&1)*2-1)*b+(((i>>1)&1)*2-1)*c+(((i>>2)&1)*2-1)*d==7){
      cout << a << ((i&1)?'+':'-') << b << ((i&2)?'+':'-') << c << ((i&4)?'+':'-') << d << "=7" << endl;
      return 0;
    }
  }
  return 0;
}


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


int main(){
  ll a,b,m;
  cin>>a>>b>>m;
  vector<ll> A(a);
  vector<ll> B(b);
  rep(i,a){
    cin>>A[i];
  }
  rep(i,b){
    cin>>B[i];
  }
  ll ans=INF;
  rep(i,m){
    ll x,y,c;
    cin>>x>>y>>c;
    x--;y--;
    ll temp=A[x]+B[y]-c;
    ans=min(ans,temp);
  }
  sort(A.begin(),A.end());
  sort(B.begin(),B.end());
  ans=min(ans,A[0]+B[0]);
  cout<<ans;
}


Measured memory_bytes: 1792
import java.util.*;
public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int l = sc.nextInt();
        int min = l;
        int max=n+l-1;
        int eat;
        int sum=0;
        if(min<0&&max<=0) {
            eat = max;
        }else if(min>=0&&max>0){
            eat = min;
        }else{
            eat = 0;
        }
        for(int i = 0;i<n;i++){
            sum = sum+ l+i;
        }
        sum=sum-eat;
        System.out.println(sum);
    }
}



Measured memory_bytes: 25300
// ######      ###      #######    #######    ##     #     #####        ###     ##### //
// #     #    #   #          #        #       # #    #    #     #      #   #     ###  //
// #     #   #     #        #         #       #  #   #   #       #    #     #    ###  //
// ######   #########      #          #       #   #  #   #           #########    #   //
// #     #  #       #     #           #       #    # #   #    ####   #       #    #   //
// #     #  #       #    #            #       #     ##   #    #  #   #       #        //
// ######   #       #   #######    #######    #      #    #####  #   #       #    #   //

// #pragma GCC optimize(2)
// #pragma GCC optimize(3)
// #pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math,O3")
// #pragma GCC target("avx,avx2,fma")
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double lld;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> ppl;
#define ain(a,n) for(ll i=0;i<(n);++i)	cin>>(a)[i];
#define DEBUG(x) cout << '>' << #x << ':' << x << endl;
#define loop(i,n) for(ll i=0;i<(n);++i)
#define FOR(i,a,b) for(ll i=(a);i<=(b);++i)
#define FORD(i,a,b) for(ll i=(a);i>=(b);--i)
#define cases ll T=0;cin>>T;while(T--)
#define ff first
#define ss second
#define all(v) v.begin(),v.end()
#define END "\n"
#define pb push_back
#define mp make_pair
#define go(c,itr) for(auto itr=(c).begin(); itr!=(c).end(); ++itr)
#define back(c,itr) for(auto itr=(c).rbegin(); itr!=(c).rend(); ++itr)
#define PI 3.14159265359
#define inf 9e18
#define MOD 1000000007
#define MODU 998244353
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define MAXN 200005
const string alpha = "abcdefghijklmnopqrstuvwxyz";
const ll N = 1005;
const long double epsilon = 1e-9;
ll binexp(ll a, ll b, ll m) {
	a %= m;
	ll res = 1;
	while (b > 0) {
		if (b & 1)
			res = res * a % m;
		a = a * a % m;
		b >>= 1;
	}
	return res;
}
void task(bool flag)
{
	if (flag)
		cout << "YES\n";
	else
		cout << "NO\n";
}
ll lcm(ll a, ll b)
{
	return ((1LL * a * b) / (__gcd(a, b)));
}

signed main() {
// #ifndef ONLINE_JUDGE
// 	freopen("input.txt", "r", stdin);
// 	freopen("output.txt", "w", stdout);
// #endif
	fast
	ll n;
	cin >> n;
	vl a(n);
	ain(a, n);
	ll ans = 0;
	loop(i, n)
	{
		if (i % 2 == 0 && a[i] % 2 == 1)
			++ans;
	}
	cout << ans << END;



// #ifndef ONLINE_JUDGE
// 	cout << "\nTime Elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " sec\n";
// #endif
	return 0;
}


Measured memory_bytes: 3636
/* ex2_3
   person_A*/
#include<stdio.h>
int main(void){
    int N,A;
    //入力受け取り
    scanf("%d",&N);
    scanf("%d",&A);
    //盤面の数N*Nから白マスの数を引いたものを出力
    printf("%d\n",N*N-A);
    return 0;
}


Measured memory_bytes: 128
#define _USE_MATH_DEFINES
#include <math.h>
#include <iostream>
#include <iomanip>
#include <cstdlib>
#include <algorithm>
#include <numeric>
#include <stdio.h>
#include <vector>
#include <map>
#include <queue>

using namespace std;
typedef long long ll;

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

ll func(ll n){
    ll m = 1;
    while(n>0){
        n /= 10;
        if(n>0) m++;
    }
    return m;
}

int main() {

    ll N;
    cin >> N;
    ll out = func(N);
    rep(i,sqrt(N)){
        if(N%(i+1)==0){
            out = min(out,func(N/(i+1)));
        }
    }
    cout << out << endl;
    return 0;
}


Measured memory_bytes: 3680
#include<iostream>
#include<algorithm>
#include<math.h>
#include<cstring>
#include<vector>

using namespace std;

#define long long long
#define ft(i, a, b) for (int i = (long)a ; i <= (long)b ; i++)
#define fd(i, a, b) for (int i = (long)a ; i >= (long)b ; i--)

const int MAXN = 1e5 + 5;
const long oo = 1e15;

long n;

long sum(long n) {
    return n * (n + 1) / 2;
}
void Solve() {
    cout << (sum(n) - sum(n / 3) * 3 - sum(n / 5) * 5 + sum(n / 15) * 15);  
}

void FastInput() {
    ios_base::sync_with_stdio(NULL);
    cin.tie(NULL);
    cout.tie(NULL);
    //freopen(".inp", "r", stdin);
    //freopen(".out", "w", stdout);
}

void Input() {
    cin >> n;
}

int main() {
    FastInput();
    Input();
    Solve();
}

Measured memory_bytes: 3656
#include <stdio.h>

#define NMIN 2
#define NMUX 200
#define LMIN -100
#define LMUX 100

int main(void) {

    int n, l;
    int i;
    int eatI;
    int sum;
    scanf("%d %d", &n, &l);

    if ( 0 < l ) {
        eatI = 1;
    } else if ( n <= -l+1 ) {
        eatI = n;
    } else {
        eatI = 1-l;
    }

    sum = n*(l-1)+n*(n+1)/2;
    sum -= l+eatI-1;

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

    return 0;
}



Measured memory_bytes: 128
#include <cstdio>
#include <cstring>
#include <vector>
#include <algorithm>

using namespace std;

typedef pair<int,int> P;

int N;
vector<P>stone;

int main(){
  while(scanf("%d",&N) && N){
    stone.clear();
    int c;
    for(int i=1;i<=N;i++){
      scanf("%d",&c);
      if(i&1){
	if(stone.empty() || stone[stone.size()-1].second != c) stone.push_back(P(1, c));
	else stone[stone.size()-1].first += 1;
      }else{
	if(stone[stone.size()-1].second == c) stone[stone.size()-1].first += 1;
	else{
	  stone[stone.size()-1] = P(stone[stone.size()-1].first+1, c);
	  if(stone.size()>1 && stone[stone.size()-2].second == c){
	    stone[stone.size()-2].first += stone[stone.size()-1].first;
	    stone.pop_back();
	  }
	}
      }
    }

    int res = 0;
    for(int i=0;i<stone.size();i++) if(stone[i].second == 0) res += stone[i].first;
    printf("%d\n", res);
  }
  return 0;
}

Measured memory_bytes: 1032
#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;
int main(){
int t=0,h=0;
int x,y,z;
while(scanf("%d,%d,%d",&x,&y,&z)!=EOF){
if(x*x+y*y==z*z){
t++;
}
if(x==y){
h++;
}
}
cout<<t<<endl<<h<<endl;
return 0;
}

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

int main() {
    int N;
    cin >> N;
    map<int,int> mp;
    vector<int> vec;
    for (int i = 0;i<N;i++) {
        int a;
        cin >> a;
        mp[a]++;
        mp[a+1]++;
        mp[a-1]++;
        vec.push_back(a);
    }
    int ans = 0;
    for (int i : vec) {
        ans = max(ans,mp[i]);
    }
    cout << ans << endl;
}

Measured memory_bytes: 5112
#include <bits/stdc++.h>
using namespace std;
int f(int x, int y, int z){
	return x*x + y*y + z*z + x*y + x*z + y*z;
}
int main(int argc, char const *argv[]){
	int count = 105;
	map<int, int> ans;
	for (int x = 1; x < count; ++x){
		for (int y = 1; y < count; ++y){
			for (int z = 1; z < count; ++z){
				ans[f(x,y,z)]++;
			}
		}
	}

	int n;
	cin>>n;
	for (int i = 1; i <= n; ++i){
		cout << ans[i] << endl;
	}
	return 0;
}

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

int main(){
    long long i;
    long long flg=0;
    long long c_count=0;
    string S;
    vector<string>disp{"AC","WA"};

    cin>>S;

    for(i=0;i<S.size();i++)if(i>=2 && i<=S.size()-2 && S[i]=='C')c_count+=1;

    if(c_count!=1){
        flg=1;
    }else{
        for(i=0;i<S.size();i++){
            if(i==0 && S[i]!='A'){
                flg=1;
                break;
            }else if(i>=1 && S[i]>='A' && S[i]<='Z'){
                if(S[i]!='C'){
                    flg=1;
                    break;
                }

                if((i==1 || i==S.size()-1) && S[i]=='C'){
                    flg=1;
                    break;
                }
            }
        }
    }
    cout<<disp[flg]<<endl;
}

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

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<pii, int> ppiii;

void solve() {
  int a, b;
  cin >> a >> b;
  cout << fixed << setprecision(10) << a/(double)b << endl;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  solve();
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i ,n) for(int i = 0 ; i < (n) ; i ++ )
#define all(x) (x).begin(),(x).end()
using namespace std;
using ll = long long;
using vin=vector<int>;
const int inf=1e9+7;
const ll INF=1e18;

int main() {
  int k;
  cin>>k;
  string s;
  cin>>s;
  ////
  int n=s.size();
  if(n>k){
    s.erase(k);
    rep(i,3)
    s.push_back('.');
    cout<<s<<endl;
  }
  else{
    cout<<s<<endl;
  }
}

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

int main(){
    int m, f;
    
    for(int i = 1; i > 0; i++){
        cin >> m >> f;
        if(m == 0 && f == 0) break;
        
        int c = 0;
        for(int l = 1; l <= m; l++){
            for(int s = l + 1; s <= m; s++){
                for(int t = s + 1; t <= m; t++){
                    if(l + s + t == f)c++;
                    
                }
            }
        }
        cout << c << endl;
    }
    
    return 0;
}


Measured memory_bytes: 3068