akhauriyash/Code-Regression huggingface dataset:
// Problem : B - Judge Status Summary
// Contest : AtCoder - AtCoder Beginner Contest 173
// URL : https://atcoder.jp/contests/abc173/tasks/abc173_b
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define endl '\n'
#define pb push_back
#define mod 1000000007
ll power(ll x, ll y) 
{ 
    if (y == 0) 
        return 1; 
    ll p = power(x, y/2) % mod; 
    p = (p * p) % mod; 
  
    return (y%2 == 0)? p : (x * p) % mod; 
} 
ll factorial[1000007];
void fact(ll n)
{
    memset(factorial,0,sizeof(factorial));
    factorial[0]=1;
factorial[1]=1;

    for(int i=1;i<n;i++)
    {
        factorial[i]=(factorial[i-1]*i)%mod;
    }
    
}
ll ncr(ll n,ll r)
{
    ll ans=1;
    ll i;
    ans=factorial[n];
    ll ans1=power(factorial[n-r],mod-2);
    ll ans2=power(factorial[r],mod-2);
    ans=((ans*ans1)%mod*ans2)%mod;
    return ans;
}
ll gcd(ll a, ll b) 
{ 
    if (b == 0) 
        return a; 
    return gcd(b, a % b);  
      
} 

bool prime[100000006];
void sieve(ll n){
    memset(prime,true,sizeof(prime));
	prime[1]=false; 
    for (ll p=2;p*p<=n;p++){
        if (prime[p]){  
            for (ll i=p*p;i<=n;i+=p)
                prime[i]=false;
        }
    }
}
void bfs(vector<int> v[],int o,int n,int dp[]){
	queue<int> q;
	q.push(o);
	dp[o]=0;
	bool visited[n+1]={0};
	visited[o]=true;
	while(q.empty()==false){
		int a=q.front();
		q.pop();
		for(int i=0;i<v[a].size();i++){
			if(visited[v[a][i]]==false){
				visited[v[a][i]]=true;
				q.push(v[a][i]);
				dp[v[a][i]]=dp[a]+1;
			}
		}
	}
}
int nov[1000001];
bool visited[1000001];
int dp[1000001];
int dfs(vector<int> v[],int o)
{
    if(visited[o]==0)
    {
        visited[o]=1;
        for(int i=0;i<v[o].size();i++)
        {
            if(visited[v[o][i]]==0)
            {
            dp[v[o][i]]=dp[o]+1;
            nov[o]+=dfs(v,v[o][i]);
            }
        }
        return nov[o]+1;
    }
    else
    return 0;
}
// string s=bitset<64>(n).to_string();
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
	ll n;
	cin>>n;
	map<string,int> mp;
	for(int i=0;i<n;i++)
	{
		string s;
		cin>>s;
		mp[s]++;
	}
	cout<<"AC x "<<mp["AC"]<<endl;
	cout<<"WA x "<<mp["WA"]<<endl;
	cout<<"TLE x "<<mp["TLE"]<<endl;
	cout<<"RE x "<<mp["RE"]<<endl;
	return 0;
}


Measured memory_bytes: 3668
#include <bits/stdc++.h>
#define WHOLE(v) (v).begin(), (v).end()
#define REV_WHOLE(v) (v).rbegin(), (v).rend()
using i64 = int64_t;
using namespace std;
template<class F>auto recursive(F f){return[f](auto...a){return f(f,a...);};}
template<class T>using rev_priority_queue=priority_queue<T,vector<T>,greater<T>>;
template<class T>using vector2d=vector<vector<T>>;
struct fixprec{int p;fixprec(int p):p(p){}};
ostream&operator<<(ostream&o,fixprec f){return o<<fixed<<setprecision(f.p);}
int main() {
    int K;
    string S;
    cin >> K >> S;
    if(S.size() <= K) cout << S << endl;
    else {
        cout << S.substr(0, K) + "..." << endl;
    }
    return 0;
}

Measured memory_bytes: 3632
K = int(input())
if K % 2 == 0:
    print(-1)
else:
    m = 0
    for i in range(K):
        m = (m * 10 + 7) % K
        if m == 0:
            print(i+1)
            break
        elif i == K-1:
            print(-1)
            break

Measured memory_bytes: 9144
#include<stdio.h>
#define B 1000
int main()
{
  int i,v,N,j,b;
  int A[B];
  scanf("%d",&N);
  for(i=0; i<N; i++){
    scanf("%d",&A[i]);
  }
  for( i=0; i<N ; i++){
    v = A[i];
    j = i -1;
    while( j>= 0 && A[j] > v){
      A[j+1] = A[j];
      j--;
    }
    A[j+1] = v;
    for(b=0; b<N-1; b++){
      printf("%d ",A[b]);
    }
    printf("%d\n",A[b]);
  }
  return 0;
}

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

using namespace std;

const int Nmax = 1e5 + 5;
int a[Nmax], b[Nmax], c[Nmax], p[Nmax], x, n, i, m;
long long K;

void power(long long k)
{
    if(!k) return;

    int i;
    if(k&1)
    {
        for(i=1; i<n; ++i) c[i] = b[a[i]];
        for(i=1; i<n; ++i) b[i] = c[i];
    }

    for(i=1; i<n; ++i) c[i] = a[a[i]];
    for(i=1; i<n; ++i) a[i] = c[i];

    power(k/2);
}

int main()
{
  //  freopen("input", "r", stdin);
    cin.sync_with_stdio(false);

    cin >> n;
    for(i=1; i<=n; ++i) cin >> p[i], a[i] = i;

    cin >> m >> K;
    for(i=1; i<=m; ++i)
    {
        cin >> x;
        swap(a[x], a[x-1]);
    }

    p[0] = p[1];
    for(i=1; i<n; ++i) b[i] = i, p[i] = p[i+1] - p[i];
    power(K);

    long long s = p[0];
    for(i=1; i<=n; ++i)
    {
        cout << s << '\n';
        s += p[b[i]];
    }

    return 0;
}


Measured memory_bytes: 2816
#include<cstdio>
#include <iostream>
#include<algorithm>
#include<string>
#include<queue>
#include<vector>
#include<functional>
#include<cmath>
#include<map>
#include<stack>
#include<set>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;

string a, b, c;

int main()
{
	cin >> a >> b >> c;

	if (a[a.size() - 1] == b[0] && b[b.size() - 1] == c[0]) {
		cout << "YES" << endl;
	}
	else
    	cout << "NO" << endl;
	
	return 0;
}

Measured memory_bytes: 764
#include <iostream>
#include <cstdio>
#include <set>
#include <list>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <string>
#include <sstream>
#include <algorithm>
#include <cstring>
#include <cstdlib>
#include <cctype>
#include <cmath>
#include <fstream>
#include <iomanip>
//#include <unordered_map>
using namespace std;
#define dbg(x) cerr << #x " = " << x << endl;
typedef pair<int, int> P;
typedef long long ll;
#define FIN freopen("in.txt", "r", stdin);

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int a, p;
    cin >> a >> p;
    cout << (a * 3 + p) / 2 << endl;
    return 0;
}

Measured memory_bytes: 3160
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
  //ツ素ツ青板青カツ青ャ
  const int NUM = 1000000;
  bool prime[NUM];
  prime[0] = false;
  prime[1] = false;
  for(int i=2;i<NUM;i++)
    prime[i] = true;
  for(int i=2;i*i<NUM;i++)
    for(int k=2;i*k<NUM;k++)
      prime[i*k]=false;

  while(true){
    int n,x;
    cin>>n>>x;
    if(!n&&!x)break;
    int menu[n];
    for(int i=0;i<n;i++){
      cin>>menu[i];
    }
    sort(menu,menu+n);
    reverse(menu,menu+n);
    int p = -1;
    bool money[x+1];
    money[0] = true;
    for(int i=1;i<x+1;i++){
      money[i] = false;
      for(int j=0;j<n;j++){
	if(i>=menu[j]&&money[i-menu[j]]){
	  money[i] = true;
	  break;
	}
      }
      if(money[i]&&prime[i])p=i;
    }
    if(p==-1)cout<<"NA"<<endl;
    else cout<<p<<endl;
  }
  return 0;
}

Measured memory_bytes: 2824
#include<stdio.h>
#define N 10000
#define Q 500
 
int main(){
  int i,j,n,q;
  int S[N],T[Q],count=0;
 
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&S[i]);
  }
  scanf("%d",&q);
  for(j=0;j<q;j++){
    scanf("%d",&T[j]);
    for(i=0;i<n;i++){
      if(S[i]==T[j]){
    count++;
    break;
      }
    }
  }
    printf("%d\n",count);
    return 0;
}

Measured memory_bytes: 640
/*
  Motto - try hard to become an expert
*/
#include <bits/stdc++.h>
#include <map>
#include <algorithm>
#include <vector>
#include <string.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <chrono>
#include <thread>
#include <iomanip>
 
//define
#define rep(i,n)    for(int i=0;i<n;i++)
#define repu(i,k,n) for(int i=k;i<=n;i++)
#define repd(i,k,n) for(int i=k;i>=n;i--)
#define se second
#define fi first
#define pb push_back
#define mp make_pair
#define INF (int)INT_MAX
#define all(v)  v.begin(), v.end()
#define endl "\n"
 
//typedef
typedef long long int ll;
typedef long double ld;
typedef std::pair<int, int> pii;
typedef std::vector<int> vi;
typedef std::vector< pii > vii;
typedef std::vector< ll > vll;
typedef std::vector< std::pair < pii, int > > vpp;
 
const int N = 3*1e5 +5 ;
const long long MOD = 998244353;
const long long inf = 1e18;
 
using namespace std;
 
ll MAXN=100001;
ll spf[100001]; 
 
ll modpow(ll x,ll n){
    ll res=1;
    while(n>0){
        if(n&1) res=res*x%MOD;
        x=x*x%MOD;
        n>>=1;
    }
    return res;
}
 
ll modFact(ll n, ll p) 
{ 
    if (n >= p) 
        return 0; 
  
    ll result = 1; 
    for (ll i = 1; i <= n; i++) 
        result = (result * i) % p; 
  
    return result;  
} 
 
bool isPrime(int x)
{
    if(x%2==0)
        return 0;
    for(int i=3;i<=sqrt(x);i+=2)
    {
        if(x%i==0)
            return 0;
    }
    return 1;
}
bool compare(const pair<int , int>&a , const pair<int,int>&b){
	return a.fi<b.fi ; 
}
void solve()
{
	int  n , m ;
	cin>>n>>m ;
	int s[m]  ,c[m] ;
	rep(i ,m){
		cin>>s[i]>>c[i] ;
	}
	
	if(n==1){
		repu(i , 0 , 9){
			int arry[1] ; 
			arry[0] = i ;
			bool ok = true ;
			rep(j , m){
				ok &= (arry[s[j]-1]==c[j]) ;
			}
			
			if(ok){
				cout<<i;
				return ;
			}
		}
	}
	else if(n==2){
		repu(i , 10 , 99){
			int arry[2] ;
			arry[0] = i%10 ; 
			arry[1] = (i- i%10)/10 ;
			bool ok = true ;
			int tarry[2]  ;
			tarry[0] =arry[1] ;
			
			tarry[1] = arry[0] ;
			rep(j , m){
				ok &= (tarry[s[j]-1] == c[j]) ;
			}
			if(ok){
				cout<<i ;
				return ;
			}
		}
	}
	else{
		repu(i , 100 , 999){
			int arry[3]  ;
			arry[0] = i%10 ;
			arry[1]  =  ((i - i%10)/10 )%10;
			arry[2] = ((i - i%10)/10 - ((i - i%10)/10 )%10 ) / 10 ;
			bool ok = true; 
			int tarry[3]  ;
			tarry[0] = arry[2 ];
			tarry[1] = arry[1] ;
			tarry[2] = arry[0] ;
			rep(j , m){
				ok &= (tarry[s[j]-1]==c[j]) ;
			}
			if(ok){
				cout<<i;
				return ;
			}
		}
	}
	cout<<-1 ;
}
 
int main() {
    // #ifndef ONLINE_JUDGE
    //     // for getting input from input.txt
    //     freopen("input.txt", "r", stdin);
    //     // for writing output to output.txt
    //     freopen("output.txt", "w", stdout);
    // #endif
    
    // ios_base::sync_with_stdio(0);
    // cin.tie(NULL);
    int t = 1;
    //cin>>t;
    while(t--)
    {
        solve();
    } 
    // cerr << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC << "ms\n";
}

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

#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define bg begin()
#define ed end()
#define all(x) x.bg, x.ed
#ifdef LOCAL
#define dmp(x) cerr << __LINE__ << " " << #x << " " << x << endl
#else
#define dmp(x) void(0)
#endif

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 (b < a)
        a = b;
}

template <class t>
using vc = vector<t>;
template <class t>
using vvc = vc<vc<t>>;

using vi = vc<int>;

int fact(int n)
{
    if (n == 0)
        return 1;
    return fact(n - 1);
}
int gcd(int a, int b)
{
    if (b == 0)
        return a;
    return gcd(b, a % b);
}
int main()
{
  	int n;cin>>n;
    string a, b;
    cin >> a >> b;
    rep(i,a.length()){
    cout<<a[i]<<b[i];
    } 
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;

typedef long long LL;

LL n, x;

LL gcd(LL a, LL b){
	LL c = a%b;
	while(c){
		a = b; b = c; c = a%b;
	}
	return b ;
}

int main(){
	while(~scanf("%lld %lld", &n, &x)){
		LL p = gcd(n, x);
		n /= p;
		printf("%lld\n", (n-1)*3 * p);
	}
	return 0;
}


Measured memory_bytes: 128
#include<iostream>
using namespace std;
int main()
{
  int n,k,i;
  cin>>n>>k;
  char a[n];
  for( i = 0;i<n;i++)
    cin>>a[i];
  a[k-1] = a[k-1] +32;
  for(i=0;i<n;i++)
    cout<<a[i];
}


Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scn = new Scanner(System.in);
        int N = Integer.parseInt(scn.nextLine());
        String name = scn.nextLine();
        char[] original = name.toCharArray();
        ArrayList<Character> result = new ArrayList<>();
        result.add(original[0]);
        for (int i = 1; i < N; i++) {
            if(result.get(result.size()-1) == original[i]){
                continue;
            }
            else
                result.add(original[i]);
        }

        System.out.println(result.size());
    }
}


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

char get_win_symbol(char symbol)
{
    if (symbol == 'r')
    {
        return 'p';
    }

    if (symbol == 'p')
    {
        return 's';
    }

    if (symbol == 's')
    {
        return 'r';
    }
}

int get_winning_score(int R, int S, int P, char symbol)
{
    if (symbol == 'r')
    {
        return R;
    }

    if (symbol == 's')
    {
        return S;
    }
    if (symbol == 'p')
    {
        return P;
    }
}

int main()
{
    int N, K;
    int R, S, P;
    string T;

    cin >> N >> K;
    cin >> R >> S >> P;
    cin >> T;

    int score = 0;
    string Tlog;

    for (int i = 0; i < N; i++)
    {
        char win_symbol = get_win_symbol(T[i]);
        if (i < K || Tlog[i - K] != win_symbol)
        {
            score += get_winning_score(R, S, P, win_symbol);
            Tlog += win_symbol;
        }
        else
        {
            Tlog += "x";
        }
    }

    cout << score << endl;

    return 0;
}


Measured memory_bytes: 640
#include <stdio.h>
int main()
{
	int a, b, menseki, syu;
	scanf("%d", &a);
	scanf("%d", &b);

	if (a >=1 , b <= 100 && b > 0)
	{
		menseki = a*b, syu = (2 * a) + (2 * b);


		printf("%d %d\n", menseki, syu);
	}

	return 0;
}

Measured memory_bytes: 596
#include <bits/stdc++.h>
using namespace std;
#define rep(k,nu)    for(int i=k; i<nu;  i++)
#define rep2(k,n)   for(int j=k; j<n;  j++)
#define INF 1000000000000 //1e+12
#define MOD 10000007 //1e9+7
#define ll long long
#define pb pop_back
template<typename T> inline void chMin(T* a, T* b) {if(*a>*b) *a=*b;}
template<typename T> inline void chMax(T* a, T* b) {if(*a<*b) *a=*b;}
template<typename T> inline int  divUp(T a, T b)   {return ((a+b-1)/b);}
const double PI = acos(-1);

int main(){
    string s, t, u; cin >> s >> t;
    int a, b;       cin >> a >> b;
                    cin >> u;

    if(u == s)  cout << a-1 << " " << b;
    else        cout << a << " " << b-1;
    return 0;
}
/*
*/


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

using namespace std;

using ll = long long;

const double eps = 1e-10;
const int MOD = 1000000007;
const int INF = 1000000000;
const ll LINF = 1ll<<50;

template<typename T>
void printv(const vector<T>& s) {
  for(int i=0;i<(int)(s.size());++i) {
    cout << s[i];
    if(i == (int)(s.size())-1) cout << endl;
    else cout << " ";
  }
}

template<typename T>
ostream& operator<<(ostream& os, const vector<T>& v) {
  os << "[";
  bool a = 1;
  for(auto e : v) {
    os << (a ? "" : " " );
    os << e;
    a = 0;
  }
  os << "]";
  return os;
}

vector<vector<int>> a, result;
ll solve(vector<vector<int>>& a, vector<vector<int>>& result, int n, int y, int x, int su) {
  if(y == n-1) {
    bool ok = true;
    for(int i=0;i<n;++i) {
      int su = 0;
      for(int j=0;j<n;++j) {
        su += a[i][j] + result[i][j];
      }
      if(su != 0) {
        ok = false;
        break;
      }
    }
    return ok ? 1 : 0;
  } else if(x == n) {
    su = 0;
    for(int i=0;i<y+1;++i) {
      su -= a[i][y+1] + result[i][y+1];
    }
    return solve(a, result, n, y+1, y+2, su);
  } else if(result[y][x] != 0) {
    su += result[y][x];
    if(abs(su) <= n  - x) {
      return solve(a, result, n, y, x+1, su);
    } else {
      return 0;
    }
  } else {
    // next = 1
    int res = 0;
    a[y][x] = 1;
    a[x][y] = -1;
    su += a[y][x];
    if(abs(su) <= n - x) {
      res += solve(a, result, n, y, x+1, su);
    }
    su -= a[y][x];
    // next = -1
    a[y][x] = -1;
    a[x][y] = 1;
    su += a[y][x];
    if(abs(su) <= n - x) {
      res += solve(a, result, n, y, x+1, su);
    }
    su -= a[y][x];
    a[y][x] = 0;
    a[x][y] = 0;
    return res;
  }
}

int main () {
  cin.tie(0);
  cout << fixed << setprecision(10);

  while(1) {
    int n; cin >> n;
    if(n == 0) break;
    vector<vector<int>> a(n, vector<int>(n, 0)), result(n, vector<int>(n, 0));
    int m; cin >> m;
    for(int i=0;i<m;++i) {
      int x, y; cin >> x >> y;
      x--; y--;
      result[x][y] = 1;
      result[y][x] = -1;
    }
    cout << solve(a, result, n, 0, 1, 0) << endl;
  }
}



Measured memory_bytes: 3156
#include <iostream>
#include <map>

using namespace std;

typedef long long ll;
typedef map<ll, int> mli;

ll pow5(int x) {
    return 1ll * x * x * x * x * x;
}

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

    mli s5;
    for (int i = 0; i <= 200; i++) {
        s5[pow5(i)] = i;
    }

    int x;
    cin >> x;

    for (int i = 0; i <= 200; i++) {
        if (s5.count(pow5(i) - x)) {
            cout << i << " " << s5[pow5(i)-x] << endl;
            return 0;
        }

        if (s5.count(x - pow5(i))) {
            cout << i << " " << -s5[x-pow5(i)] << endl;
            return 0;
        }
    }

    return 0;
}


Measured memory_bytes: 3668
#include <iostream>

int main(){
	int first=0,second=0,third=0,height;
	for(int i=0;i<10;++i){
		std::cin>>height;
		if(height>first){
			third=second;
			second=first;
			first=height;
		}
		else if(height>second){
			third=second;
			second=height;
		}
		else if(height>third){
			third=height;
		}
	}
	std::cout<<first<<'\n'<<second<<'\n'<<third<<'\n';
	return 0;
}

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

int main(void){
    int N;
    int L;
    cin >> N;
    cin >> L;

    vector<string> A;

    string tmp;

    for(int i=0;i<N;i++){
        cin >> tmp;
        A.push_back(tmp);
    }

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

    for(int i=0;i<A.size();i++)
        cout << A[i];

}

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

#define rep(i, n) for (int i=0; i<(n); ++i)
using ll = long long;
using P = pair<int, int>;

int main() {
  int w, h, x, y, r;
  cin >> w >> h >> x >> y >> r;
  if (x + r > w || x - r < 0) {
    cout << "No" << endl;
  } else if (y + r > h || y - r < 0) {
    cout << "No" << endl;
  } else {
    cout << "Yes" << endl;
  }
  return 0;
}



Measured memory_bytes: 3112
N=int(input())
A=0
W=0
T=0
R=0
for i in range(N):
    st=input()
    if st=="AC":
        A+=1
    elif st=="WA":
        W+=1
    elif st=="TLE":
        T+=1
    else:
        R+=1
print("AC x "+str(A))
print("WA x "+str(W))
print("TLE x "+str(T))
print("RE x "+str(R))

Measured memory_bytes: 9216
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int n;
vector<int> v[200010];
ll ans;
void len(int x)
{
    int t=x;
    while(x)
    {
        v[t].push_back(x%10);
        x/=10;
    }
}
ll po(int x)
{
    int ret=1;
    for(int i=0;i<x;i++)
    {
        ret*=10;
    }
    return ret;
}
int main()
{
    scanf("%d",&n);
    for(int i=1;i<=n;i++)
    {
        len(i);
    }
    for(int i=1;i<=n;i++)
    {
        if(v[i][0]==0)
        {
            continue;
        }
        if(v[i][0]<v[i][v[i].size()-1])
        {
            for(int j=0;j<=v[i].size()-2;j++)
            {
                ll p=(ll)po(j);
                ans+=2*p;
            }
        }
        else if(v[i][0]==v[i][v[i].size()-1])
        {
            if(v[i].size()<3)
            {
                ans+=2*v[i].size()-1;
            }
            else
            {
                ans+=5;
                for(int j=1;j<=v[i].size()-3;j++)
                {
                    ll p=(ll)po(j);
                    ans+=2*p;
                }
                for(int j=1;j<v[i].size()-1;j++)
                {
                    ll p=(ll)po(j-1);
                    ans+=2*p*v[i][j];
                }
            }
        }
        else
        {
            if(v[i].size()<3)
            {
                continue;
            }
            for(int j=0;j<=v[i].size()-3;j++)
            {
                ll p=(ll)po(j);
                ans+=2*p;
            }
        }
    }
    printf("%lld",ans);
}

Measured memory_bytes: 14208
process.stdin.resume();
process.stdin.setEncoding('utf-8');
process.stdin.on('data', function(chunk) {
 
var inputs = chunk.toString().trim().split('\n').map(Number);
for (var i = 0; i < inputs .length; i++) {
        if (inputs [i] === 0) {
            break;
        }
        console.log('Case ' + (i + 1) + ': ' + inputs[i]);
}
 
 
});

Measured memory_bytes: 20688
def main():
    n, c, k = map(int, input().split())
    t = [int(input()) for i in range(n)]
    t.sort()

    ans = 0
    tt = t[0]
    cc = 1
    for i in range(1, n):
        if tt + k < t[i] or c == cc:
            tt = t[i]
            ans += 1
            cc = 1
        else:
            cc += 1

    print(ans+1)


if __name__ == '__main__':
    main()

Measured memory_bytes: 50264
#include<bits/stdc++.h>
using namespace std;
int main(){
int A,B,C,D;
cin >> A >> B >> C >> D;
if(A+B>C+D){
  cout <<"Left";
}
else if(A+B<C+D){
  cout <<"Right";
}
else{
  cout <<"Balanced";
}
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define fo(i,w,n) for(int i=(int) w;i<(int) n;i++)
#define qi queue<int>
#define vi vector<int>
#define ll long long
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define pii pair<int,int>
#define mp make_pair
#define all(a) (a).begin(),(a).end()
#define fi first
#define se second
#define prq priority_queue
#define foreach(it,c) for(__typeof((c).begin()) it=c.begin();it!=c.end();it++)
using namespace std;
inline ll read(){
	ll x=0;
	int f=1;
	char c=getchar();
	for(;!isdigit(c);c=getchar()) if(c=='-')f=-f;
	for(;isdigit(c);c=getchar())x=x*10+(c-'0');
	return x*f;
}
int n;
ll a[101010],b[101010],ans=0;
int main(){
	//freopen("a.in","r",stdin);
	//freopen("a.out","w",stdout);
	cin>>n;
	fo(i,0,n+1)cin>>a[i];
	fo(i,0,n)cin>>b[i];
	fo(i,0,n){
		if(b[i]>a[i]){
			if(a[i+1]<b[i]-a[i])ans+=a[i]+a[i+1],a[i+1]=0;
			else ans+=b[i],a[i+1]-=(b[i]-a[i]);
			a[i]=0;
		}else{
			a[i]-=b[i];
			ans+=b[i];
		}
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
int main(){
  string a, b, c;
  cin >> a >> b >> c;
  char d='a',ans;
  for(int i=0;i<=301;i++){
    if(d=='a'){
      if(a==""){
        break;
      }
      d=a[0];
      a=a.substr(1,a.size()-1);
    }
    if(d=='b'){
      if(b==""){
        break;
      }
      d=b[0];
      b=b.substr(1,b.size()-1);
    }
    if(d=='c'){
      if(c==""){
        break;
      }
      d=c[0];
      c=c.substr(1,c.size()-1);
    }
  }
  cout << char(d+'A'-'a') << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define fi first
#define se second
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repp(i, a, b) for (int i = a; i <= (b); ++i)
#define repr(i, a, b) for (int i = a; i >= (b); --i)
#define bit(n) (1LL << (n))
#define len(x) ((ll)(x).size())
#define debug(var) cout << "[" << #var << "]\n" << var << endl
#define int long long
typedef long long ll;
const int INF = 1001001001001001001ll;
const ll LINF = 1001001001001001001ll;
const int MOD = 1000000007;
const double EPS = 1e-9;

template <typename T>
ostream& operator<<(ostream& s, const vector<T>& v) {
  int len = v.size();
  for (int i = 0; i < len; ++i) {
    s << v[i];
    if (i < len - 1)
      s << ' ';
  }
  return s;
}

template <typename T>
ostream& operator<<(ostream& s, const vector<vector<T>>& vv) {
  int len = vv.size();
  for (int i = 0; i < len; ++i) {
    s << vv[i];
    if (i != len - 1)
      s << '\n';
  }
  return s;
}

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

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

__attribute__((constructor)) void initial() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(15);
}

signed main() {
  int N;
  cin >> N;
  vector<int> A(N);
  vector<int> cnt(N);
  rep(i, N) {
    cin >> A[i];
    A[i]--;
    cnt[A[i]]++;
  }

  int tot = 0;
  rep(i, N) {
    tot += cnt[i] * (cnt[i] - 1) / 2;
  }

  rep(i, N) {
    int a = A[i];
    int ans = tot - cnt[a] * (cnt[a] - 1) / 2 + (cnt[a] - 1) * (cnt[a] - 2) / 2;
    cout << ans << endl;
  }
}

Measured memory_bytes: 5760
import numpy as np
n= int(input())
a = np.zeros(n+2)
b = np.zeros(n+2)
c = np.zeros(n+2)
dp = np.zeros(3)
for i in range(n):
 a[i],b[i],c[i] = (int(j) for j in input().split())
 dp = [a[i]+max(dp[1],dp[2]),b[i]+max(dp[0],dp[2]),c[i]+max(dp[0],dp[1])]

print(int(max(dp)))

Measured memory_bytes: 14788
###
### atcorder test program
###

### math class
class math:
    ### pi
    pi = 3.14159265358979323846264338

    ### GCD
    def gcd(self, a, b):
        if b == 0:
            return a
        return self.gcd(b, a%b)

math = math()

### input num
#i = input()
#A, op, B = [x for x in i.split()]
#R = float(input())
#A = [int(x) for x in input().split()]

#print("{0} {1} {2:.5f}".format(A//B, A%B, A/B))

#print("{0:.6f} {1:.6f}".format(R*R*math.pi,R*2*math.pi))

while True:
    ans = 0
    i = input()
    A, op, B = [x for x in i.split()]

    if op == "+":
        ans = int(A) + int(B)
    elif op == "-":
        ans = int(A) - int(B)
    elif op == "*":
        ans = int(A) * int(B)
    elif op == "/":
        ans = int(A) // int(B)
    elif op == "?":
        break

    print(ans)



Measured memory_bytes: 5612
#include <iostream>

void HelloWorld(){
    std::cout << "Hello World" << std::endl;
}

int Cubic(int X){
    return X*X*X;
}

int Rectangle(int A, int B){
    return A*B;
}

int Circumference(int A, int B){
    return 2*A + 2*B;
}

int main() {
    // ---------------------------
    // ITP_1_1_A: Hello World
    // HelloWorld();
    // ---------------------------

    // ---------------------------
    // ITP_1_1_B: X Cubic
//    int x;
//    std::cin >> x;
//    std::cout << Cubic(x) << std::endl;
    // ---------------------------

    // ---------------------------
    // ITP_1_1_C: Rectangle
    int a, b;
    std::cin >> a >> b;
    std::cout << Rectangle(a,b) << " " << Circumference(a,b) << std::endl;
    // ---------------------------

    // ---------------------------
    // ITP_1_1_D: Watch
    // ---------------------------

    // ---------------------------
    // ITP_1_1_B
    // ---------------------------

    // ---------------------------
    // ITP_1_1_B
    // ---------------------------

    return 0;
}


Measured memory_bytes: 3096
n, m, c = map(int, input().split())
b = list(map(int, input().split()))
a = [list(map(int, input().split())) for _ in range(n)]

count = 0
for i in range(n):
    ab_sum = 0
    for j in range(m):
        ab_sum += a[i][j] * b[j]
    if ab_sum + c > 0:
        count += 1

print(count)


Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
const long long mod=1e9+7;

int main(){
int N,M;
cin>>N>>M;

vector<int>oks(N+1,true);
for(int i=0;i<M;++i){
int a;cin>>a;
oks[a]=false;
}

vector<long long int>dp(N+1);
dp[0]=1;
for(int now=0;now<N;++now){
for(int next=now+1;next<=min(N,now+2);++next){
if(oks[next]){
				dp[next]+=dp[now];
				dp[next]%=mod;
			}
		}
	}

  cout<<dp[N]<<endl;
  return 0;
}


Measured memory_bytes: 1408
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <iomanip>
#define ll long long
using namespace std;
int main(){
    int n;
    cin>>n;
    vector<double> v(n);
    for(int i=0;i<n;i++){
        cin>>v[i];
    }
    sort(v.begin(),v.end());
    double mean;
    while(v.size()>1){
        mean=0.5*(v[0]+v[1]);
        v.erase(v.begin());
        v.erase(v.begin());
        v.push_back(mean);
        sort(v.begin(),v.end());
    }
    cout<<fixed<<setprecision(6)<<mean<<endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();
        int d = sc.nextInt();
        int left = a + b;
        int right = c + d;
        if (left > right) {
            System.out.println("Left");
        } else if (left < right) {
            System.out.println("Right");
        } else {
            System.out.println("Balanced");
        }
    }

}


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

using namespace std;

inline int read()
{
    int ret=0,flag=1;char c=getchar();
    while(c<'0'||c>'9'){if(c=='-')flag=-1;c=getchar();}
    while(c>='0'&&c<='9')ret=ret*10+(c^'0'),c=getchar();
    return flag*ret;
}

int main()
{
    string s;
    cin>>s;
    if(s.size()==6&&s[2]==s[3]&&s[4]==s[5])
        printf("Yes");
    else
        printf("No");
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cctype>
#include <cstdlib>
#include <string>
#include <algorithm>
#include <vector>
#include <map>
#define rep(i, n) for(int i = 0; i < n; ++i)
using namespace std;

int comp(const void* a, const void* b){
	return *(int*)a - *(int*)b;
}

int main() {
	int n;
	double sum = 0;
	double x[12];
	string u;
	cin >> n;
	rep(i, n){
		cin >> x[i] >> u;
		if(u == "BTC"){
			sum += x[i] * 380000;
		}else{
			sum += x[i];
		}
	}
	cout << sum << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <string>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cassert>

using namespace std;

#define FOR(i,k,n) for(int i=(k); i<(int)n; ++i)
#define REP(i,n) FOR(i,0,n)
#define FORIT(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)

template<class T> void debug(T begin, T end){ for(T i = begin; i != end; ++i) cout<<*i<<" "; cout<<endl; }

typedef long long ll;
const int INF = 100000000;
const double EPS = 1e-8;
const int MOD = 1000000007;
int memo[10001] ;
int rec(vector<int> a, int n){
  if(~memo[n]) return memo[n];
  if(n == 0) return 0;
  sort(a.begin(), a.end());
  reverse(a.begin(), a.end());
  REP(i,a.size())if(n - a[i] >= 0) return memo[n] = 1 + rec(a, n-a[i]);
  return INF;
}
  
string message(vector<int> a){
  memset(memo,-1,sizeof(memo));
  int dp[10001];
  fill(dp, dp+10001, INF);
  dp[0] = 0; 

  int N = a.size();
  sort(a.begin(), a.end());
  if(a[0] > 1) return "Cannot pay some amount";
  REP(i,N)REP(j,10000)if(a[i] + j <= 10000)dp[a[i]+j] = min(dp[a[i]+j], dp[j] + 1);
  REP(i,10000)if(rec(a, i+1) != dp[i+1]){
    //printf("%d:%d,%d\n",i+1,rec(a,i+1), dp[i+1]);
    return "Cannot use greedy algorithm";
  }
  return "OK";
}

int main(){
  int n;
  int cas = 1;
  while(cin>>n,n){
    vector<int> a(n);
    REP(i,n)cin>>a[i];
    cout<<"Case #"<<cas++<<": "<<message(a)<<endl;
  }
  return 0;
}

Measured memory_bytes: 992
n, p = map(int,input().split())
s = input()

mod = p
l = 100

M = [1]  # i!のmod
m = 1
for i in range(1, l):
    m = (m * i) % mod
    M.append(m)

def pow(x, y, mod):  # x**y の mod を返す関数
    ans = 1
    while y > 0:
        if y % 2 == 1:
            ans = (ans * x) % mod
        x = (x**2) % mod
        y //= 2
    return ans

def inv(x, mod):  # x の mod での逆元を返す関数
    return pow(x, mod-2, mod)

T = [1]
for i in range(n-1):
    T.append((T[-1]*10) % p)

P = [0] * p
P[0] = 1

ans = 0
v = 0
S = [int(s[i]) for i in range(n-1,-1,-1)]

import math

if p==2 or p==5:
    for i in range(n):
        ans += (int(s[i]) % p == 0) * (i+1)
elif math.log10(p) in [1,2,3,4]:
    print("Wrong Answer")
else:
    for i in range(n):
        v = (v + T[i]*S[i]) % p
        ans += P[v]
        P[v] += 1
        # print(P)

print(ans)


Measured memory_bytes: 53472
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
#define ll long long
int main() {
    
    string s;
    cin>>s;
    ll n= s.length(),i=0,k=0;
    
    vector<string> a(n);
    string temp="";
    while(i!=n)
    {
        temp+=s[i];
        if(k==0)
        {
            a[k++]=temp;
            temp="";
            i++;
            continue;
        }
        if(a[k-1].compare(temp)==0)
        {
            i++;
            continue;
        }
        else
        {
            a[k++]=temp;
            temp="";
            i++;
            continue;
        }
        i++;
    }
    cout<<k<<endl;
    
	return 0;
}


Measured memory_bytes: 11012
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
#define REP(i,n) for (ll i = 0; i < (n); ++i)
#define RREP(i, n) for (ll i = (n) - 1; i >= 0; --i)
#define ALL(v) (v).begin(), (v).end()
template<class T>
using reverse_priority_queue = priority_queue<T, vector<T>, greater<T>>;


int main(){
    ll h, w, m;
    cin >> h >> w >> m;
    set<pair<ll, ll>> hw;
    vector<ll> hcount(h, 0), wcount(w, 0);
    REP(i, m){
        ll hi, wi;
        cin >> hi >> wi;
        hi--; wi--;
        hcount.at(hi)++;
        wcount.at(wi)++;
        hw.emplace(hi, wi);
    }

    ll ans = 0;

    const ll maxh = max_element(ALL(hcount)) - hcount.begin();
    REP(i, w){
        ll tmp = hcount.at(maxh) + wcount.at(i);
        if(hw.count(make_pair(maxh, i))){
            tmp--;
        }
        ans = max(ans, tmp);
    }

    const ll maxw = max_element(ALL(wcount)) - wcount.begin();
    REP(i, h){
        ll tmp = wcount.at(maxw) + hcount.at(i);
        if(hw.count(make_pair(i, maxw))){
            tmp--;
        }
        ans = max(ans, tmp);
    }

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


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

using LL = long long;

int main() {
#ifdef LOCAL_EXEC
//	freopen("sample.in", "r", stdin);
//	freopen("sample.out", "w", stdout);
#else
	ios_base::sync_with_stdio(false); cin.tie(NULL);
#endif

	int n; cin >> n;
	int x = n / 1.08;
	for (int i = max(0, x - 2); i <= x + 2; ++i) {
		if (i * 108 >= n * 100 && i * 108 < (n + 1) * 100) {
			cout << i << endl;
			return 0;
		}
	}
	cout << ":(\n";

	return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String a = sc.next();
        int[] b = new int[4];
        for(int i=0; i<4; i++) {
            b[i] = Integer.parseInt(a.substring(i, i+1));
        }
        if(b[0]+b[1]+b[2]+b[3]==7) {
            System.out.println(b[0]+"+"+b[1]+"+"+b[2]+"+"+b[3]+"=7");
        }else if(b[0]+b[1]+b[2]-b[3]==7) {
            System.out.println(b[0]+"+"+b[1]+"+"+b[2]+"-"+b[3]+"=7");
        }else if(b[0]+b[1]-b[2]+b[3]==7) {
            System.out.println(b[0]+"+"+b[1]+"-"+b[2]+"+"+b[3]+"=7");
        }else if(b[0]+b[1]-b[2]-b[3]==7) {
            System.out.println(b[0]+"+"+b[1]+"-"+b[2]+"-"+b[3]+"=7");
        }else if(b[0]-b[1]+b[2]+b[3]==7) {
            System.out.println(b[0]+"-"+b[1]+"+"+b[2]+"+"+b[3]+"=7");
        }else if(b[0]-b[1]+b[2]-b[3]==7) {
            System.out.println(b[0]+"-"+b[1]+"+"+b[2]+"-"+b[3]+"=7");
        }else if(b[0]-b[1]-b[2]+b[3]==7) {
            System.out.println(b[0]+"-"+b[1]+"-"+b[2]+"+"+b[3]+"=7");
        }else if(b[0]-b[1]-b[2]-b[3]==7) {
            System.out.println(b[0]+"-"+b[1]+"-"+b[2]+"-"+b[3]+"=7");
        }
    }
}

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

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

using namespace std;
using ll = long long;

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

    int n;
    cin >> n;
    vector<pair<int, int>> d(n);
    rep(i, n) {
        cin >> d.at(i).first >> d.at(i).second;
    }

    rep(i, n - 2) {
        if(d.at(i).first == d.at(i).second && d.at(i + 1).first == d.at(i + 1).second && d.at(i + 2).first == d.at(i + 2).second) {
            printf("Yes\n");
            return 0;
        }
    }

    printf("No\n");

    return 0;
}

Measured memory_bytes: 3656
#include<iostream>
using namespace std;
int main(){
int x;
cin>>x;
if(x%7==1)cout<<"fri"<<endl;
if(x%7==2)cout<<"sat"<<endl;
if(x%7==3)cout<<"sun"<<endl;
if(x%7==4)cout<<"mon"<<endl;
if(x%7==5)cout<<"tue"<<endl;
if(x%7==6)cout<<"wed"<<endl;
if(x%7==0)cout<<"thu"<<endl;
return 0;
}


Measured memory_bytes: 3116
#include <cstdio>
#include <algorithm>
#include <functional>

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

using namespace std;

const int inf = 6e6;

int m, n;
int p[10000];
int c[500];
int e[500];
int dp[501][10001];

int main(){
	scanf("%d%d", &m, &n);
	rep(i, m){
		scanf("%d", &p[i]);
	}
	rep(i, n){
		scanf("%d%d", &c[i], &e[i]);
	}

	fill_n(dp[0] + 1, m, inf);
	for(int i = 1; i <= n; ++i){
		rep(j, m + 1){
			if(j >= c[i - 1]){
				dp[i][j] = min(dp[i - 1][j - c[i - 1]] + e[i - 1], dp[i - 1][j]);
			}
			else{
				dp[i][j] = min(e[i - 1], dp[i - 1][j]);
			}
		}
	}

	sort(p, p + m, greater<int>());

	int a = 0;
	int s = 0;
	rep(i, m){
		s += p[i];
		if(dp[n][i + 1] != inf){
			a = max(s - dp[n][i + 1], a);
		}
	}
	printf("%d\n", a);
	return 0;
}

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

int main()
{
    size_t n,m,d;
    cin >> n >> m >> d;
    double a = 0;
    if(d==0){
        a = n;
    }else{
        a  = 2. * ((n-1)/d    ) * ((n-1)%d+1);
        if(d > ((n-1)%d+1)) a += 2. * ((n-1)/d - 1) * (d - ((n-1)%d+1));
    }
    cout << setprecision(15) << a/n/n*(m-1) << endl;

    return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize("O3")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target ("avx")
#include <bits/stdc++.h>
constexpr int INF = 2147483647;
constexpr long long int INF_LL = 9223372036854775807;
constexpr int MOD = 1000000007;
constexpr double PI = 3.14159265358979323846;
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;

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

	vector<pair<ll, ll>> item(N);
	ll w0;
	for (int i = 0; i < N; i++) {
		int w, v;
		cin >> w >> v;
		if (i == 0)w0 = w;
		item[i] = { w - w0,v };
	}

	//dp[i][j][k] i個まで見てj個詰め込んで重さk にしたときの最大価値
	vector<vector<vector<ll>>> dp(N + 1, vector<vector<ll>>(N + 1, vector<ll>(4 * N + 10, 0)));
	for (int i = 0; i < N; i++)for (int j = 0; j < N; j++)for (int k = 0; k < 4 * N; k++) {
		dp[i + 1][j + 1][k + item[i].first] = max(dp[i][j][k] + item[i].second, dp[i + 1][j + 1][k + item[i].first]);
		dp[i + 1][j][k] = max(dp[i][j][k], dp[i + 1][j][k]);
	}

	ll ans = 0;
	for (int i = 0; i <= N; i++)for (int j = 0; j < 4 * N; j++) {
		if (i * w0 + j <= W)ans = max(ans, dp[N][i][j]);
	}
	cout << ans << endl;

}

Measured memory_bytes: 33664
# -*- coding: utf-8 -*-

def main():

	while True:
		H,W = map(int,raw_input().split())
		if H == W == 0:
			break
		a = ''
		b = ''
		for i in xrange(W):
			if i % 2 == 0:
				a += '#'
				b += '.'
			else:
				a += '.'
				b += '#'
		for i in xrange(H):
			if i % 2 == 0:
				print(a)
			else:
				print(b)
		print('')

if __name__ == "__main__":

	main()


Measured memory_bytes: 6452
A = int(input())
B = int(input())
C = int(input())
X = int(input())

cnt = 0

for i in range(A+1):
    a = 500 * i
    for j in range(B+1):
        b = 100 * j
        for k in range(C+1):
            c = 50 * k
            if a + b + c == X:
                cnt += 1

print(cnt)


Measured memory_bytes: 3188
#pragma region RegionDefs
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0,i##_len=(n);i<i##_len;++i)
#define reps(i,l,r) for(int i=(l),i##_len=(r);i<i##_len;++i)
#define repr(i,l,r) for(int i=(r)-1,i##_left=(l);i>=i##_left;--i)
#define all(x) begin(x),end(x)
using namespace std;
typedef long long ll;
const ll INF = 1e9;
template<class T=ll> using V = vector<T>;
template<class T=ll> using PQ = priority_queue<T>;
template<class T=ll> using PQG = priority_queue<T, V<T>, greater<T>>;
const ll MOD = 1000000007LL;
void in() {}
template<class Head, class... Tail>
void in(Head&& head, Tail&&... tail) { cin >> head; in(move(tail)...); }
#define IN(...) ll __VA_ARGS__; in(__VA_ARGS__)
#define INS(T, ...) T __VA_ARGS__; in(__VA_ARGS__)
#define VIN(T, v, n) V<T> v(n); for(auto& _elem:v)cin>>_elem
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 (a>b) {a=b; return 1;} return 0;}
template<class T>
string join(vector<T>& v, string delim="") { ostringstream os; rep(i,v.size())i?os<<delim<<v[i]:os<<v[0]; return os.str(); }
#pragma endregion RegionDefs

void solve()
{
    IN(n);
    VIN(ll, v, n);
    ll s = 0;
    rep(i, n) {
        if ((i+1) % 2 == 1 && v[i] % 2 == 1) s++;
    }
    cout << s << endl;
}

int main()
{
    cin.tie(0); cout.tie(0);
    ios::sync_with_stdio(false);
    cout << setprecision(numeric_limits<double>::max_digits10);

    solve();

    return 0;
}

Measured memory_bytes: 3644
#include <algorithm>
#include <iostream>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <list>
#include <cmath>
#include <stack>
#include <string>
#include <cstring>
#include <numeric>
#include <iomanip>
#include <fstream>
using namespace std;
const long long inf=1e9+7;
const long long mod=1e9+7;
const int64_t CYCLES_PER_SEC=2800000000;
//
inline uint32_t Xor128(){
	static uint32_t x=123456789;
	static uint32_t y=362436069;
	static uint32_t z=521288629;
	static uint32_t w=88675123;
	uint32_t t=x^(x<<11);
	x=y;y=z;z=w;
	return w=(w^(w>>19))^(t^(t>>8));
}
struct Timer{
	int64_t start;
	Timer(){reset();}
	void reset(){start=getcycle();}
	void plus(double a){start-=(a*CYCLES_PER_SEC);}
	inline double get(){return (double)(getcycle()-start)/CYCLES_PER_SEC;}
	inline int64_t getcycle(){
		uint32_t low,high;
		__asm__ volatile ("rdtsc":"=a"(low),"=d"(high));
		return ((int64_t)low)|((int64_t)high<<32);
	}
};
int k,n;
int a[200000];
int main(){
	cin>>k>>n;
	for(int i=0;i<n;i++){
		cin>>a[i];
	}
	int mi=0;
	for(int i=0;i<n-1;i++){
		mi=max(mi,abs(a[i]-a[i+1]));
	}
	mi=max(mi,a[0]+k-a[n-1]);
	cout<<k-mi<<endl;
	return 0;
}

Measured memory_bytes: 1024
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <unordered_set>
using namespace std;
#define inf 999999999
#define loop(i, a, b) for (int i = (a), i##len = (b); i < i##len; ++i)
#define rep(i, n) loop(i, 0, n)
#define lin long long

int n, m;
lin bs[100001], dx[100001];

void update(int i)
{
    int newBs = i;
    int newDx = dx[i];
    while (bs[newBs] != newBs)
    {
        newBs = bs[newBs];
        newDx += dx[newBs];
    }

    bs[i] = newBs;
    dx[i] = newDx;
}

int main(void)
{
    cin >> n >> m;
    rep(i, m)
    {
        int l, r, d;
        cin >> l >> r >> d;
        if (bs[l] == 0 && bs[r] == 0)
        {
            bs[l] = l;
            bs[r] = l;
            dx[r] = d;
        }
        else if (bs[l] == 0)
        {
            bs[l] = bs[r];
            dx[l] = dx[r] - d;
        }
        else if (bs[r] == 0)
        {
            bs[r] = bs[l];
            dx[r] = dx[l] + d;
        }
        else
        {
            update(r);
            update(l);

            if (bs[r] == bs[l])
            {
                if (dx[r] - dx[l] != d)
                {
                    cout << "No" << endl;
                    return 0;
                }
            }
            else
            {
                auto newDxR = dx[l] + d;
                if (dx[r] != 0)
                {
                    bs[bs[r]] = bs[l];
                    dx[bs[r]] = newDxR - dx[r];
                }
                bs[r] = bs[l];
                dx[r] = newDxR;
            }
        }
    }

    cout << "Yes" << endl;

    // rep(i, n)
    // {
    //     cout << bs[i + 1] << ", " << dx[i + 1] << endl;
    // }
    return 0;
}


Measured memory_bytes: 1792
#include <cstdio>
#include <cstdint>
#include <cmath>
#include <iostream>
#include <algorithm>
#include <array>
#include <vector>
#include <map>
#include <unordered_map>
#include <unordered_set>

int main()
{
    int N, M;
    std::cin >> N >> M;

    // std::map<uint64_t, uint64_t> priceNum;
    std::vector<std::pair<uint64_t, uint64_t>> priceNum;

    uint64_t A, B;
    for (int i = 0; i < N; ++i) {
        std::cin >> A >> B;
        priceNum.push_back({A, B});
    }

    std::sort(priceNum.begin(), priceNum.end(), [](const auto& lhs, const auto& rhs) {
        return lhs.first < rhs.first;
    });

    uint64_t sum = 0, price = 0;
    auto itr = priceNum.begin();
    while (itr != priceNum.end()) {
        for (uint64_t i = 0; i < itr->second; ++i) {
            ++sum;
            price += itr->first;

            if (sum >= M) {
                std::cout << price << std::endl;
                return 0;
            }
        }

        ++itr;
    }

    return 0;
}

Measured memory_bytes: 2420
#include <bits/stdc++.h>
#define rep(i, a, b) for (int i = a; i < (b); i++)
#define rrep(i, a, b) for (int i = a; i >= (b); i--)
#define all(x) (x).begin(), (x).end()
using namespace std;
using ll = long long;
using P = pair<int, int>;
template <class T>
inline bool chmin(T& a, T b) {
   if (a > b) {
      a = b;
      return true;
   }
   return false;
}
template <class T>
inline bool chmax(T& a, T b) {
   if (a < b) {
      a = b;
      return true;
   }
   return false;
}
const int INF = 2e9;
const int MOD = 1e9 + 7;

int main() {
   int n, k;
   cin >> n >> k;
   int ans = 0;
   while (n) {
      n /= k;
      ans++;
   }
   cout << ans << endl;
   return 0;
}

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



int main(){
	int N,K,X,Y;
	cin>>N>>K>>X>>Y;
	if(N<=K)cout<<X*N<<endl;
	else{
		cout<<K*X+(N-K)*Y<<endl;
	}
	
	
	return 0;
}

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

int count_[26];
const int a = (int)'a';

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

    for (int i = 0; i < 26; i++)
    {
        count_[i] = 0;
    }

    for (auto s : S)
    {
        count_[(int)s - a]++;
    }

    for (int i = 0; i < 26; i++)
    {
        if (count_[i] % 2 == 1)
        {
            cout << "No" << endl;
            return 0;
        }
    }

    cout << "Yes" << endl;
    return 0;
}

Measured memory_bytes: 256
const BKRT = "\n";
const SPAC = " ";
const NOSP = "";

function Main(input){
	input = [].concat(...input.split(BKRT).map(a=>a.split(SPAC)));
  const strShift = ()=>input.shift();
  const intShift = ()=>~~input.shift();
  
  var a = intShift();
  
  var max = intShift();
  var sum = 1;
  
  for(var i = 1; i < a;i++){
  	var b = intShift();
    if(max <= b){
    	max = b;
      sum++;
    }
  }
  
  return ~~sum;
}

// If you are interested in the algorithms I used, 
// there is no need to read down from this line.

((b,c,d)=>"undefined"!=typeof require?console.log(Main(require("fs").readFileSync("/dev/stdin","utf8"))):[b=b.split("\n").slice(1,-1).join("\n"),c=function(){try{return Main(b)}catch(f){return f.stack||f.message}}(),d=typeof c,"string"==d||(c=JSON.stringify(c)),$("<form>").append([[10,b],0,[1,d],0,[10,c]].map(f=>$(f?"<textarea>":"<br>",f&&{rows:f[0],cols:40,text:f[1]}))).appendTo("body")])(`
4
6 5 6 8
`);

Measured memory_bytes: 21064
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <map>
#include <queue>
#include <iomanip>
#include <set>
#define MOD 1000000007
#define mkp make_pair
typedef long long ll;
using namespace std;

int N,K;
vector<ll> V;

int main(){
  cin>>N>>K;
  V.resize(N);
  for(int i=0;i<N;i++) cin>>V[i];

  ll ans=0;
  for(int l=0;l<=K;l++){
    for(int r=0;r+l<=K&&r+l<=N;r++){
      vector<ll> v;
      for(int i=0;i<l;i++) v.push_back(V[i]);
      for(int i=0;i<r;i++) v.push_back(V[N-i-1]);
      sort(v.begin(),v.end());

      ll res=0;
      int num=K-(r+l);
      for(int i=0;i<v.size();i++){
        if(num>0&&v[i]<0){
          num--;
        }else{
          res+=v[i];
        }
      }

      ans=max(ans,res);
    }
  }

  cout<<ans<<endl;

  return 0;
}


Measured memory_bytes: 256