akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <cmath>
#include <climits>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <fstream>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <cassert>
#include <functional>

using namespace std;

#define LOG(...) printf(__VA_ARGS__)
//#define LOG(...)
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define RSORT(c) sort((c).rbegin(),(c).rend())
#define CLR(a) memset((a), 0 ,sizeof(a))

typedef long long ll;
typedef unsigned long long ull;
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vb> vvb;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

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

struct UnionFind {
	vector<int> v;
	UnionFind(int n) : v(n) { for (int i = 0; i < n; i++) v[i] = i; }
	int  find(int x) { return v[x] == x ? x : v[x] = find(v[x]); }
	void unite(int x, int y) { v[find(x)] = find(y); }
};

int main() {
	int n, l;
	while (cin >> n >> l, n) {
		vector<pii> vpii;
		vector<pii> cvpii;
		REP(i, n) {
			char c;
			int idx;
			cin >> c >> idx;
			if (c == 'L')
				vpii.push_back({ 0,idx });
			else
				vpii.push_back({ 1,idx });
		}
		int cnt = n;
		int sec = 0;
		int ans = 0;
		while (cnt) {
			cvpii.clear();
			sec++;
			REP(i, n) {
				int moved = vpii[i].second;
				if (vpii[i].second != 0 || vpii[i].second != l) {

					if (vpii[i].first == 0)
						moved--;
					else
						moved++;
				}
				cvpii.push_back({ vpii[i].first,moved });
				REP(j, cvpii.size() - 1)
					if (cvpii[j].second == moved) {
						cvpii[j].first = (cvpii[j].first + 1) % 2;
						cvpii[cvpii.size() - 1].first = (cvpii[cvpii.size() - 1].first + 1) % 2;
					}
			}
			bool douji = false;
			if (cnt == 2)
				douji = true;
			REP(j, cvpii.size())
				if (vpii[j].second != 0 || vpii[j].second != l)
					if (cvpii[j].second == 0 || cvpii[j].second == l)
						cnt--;
			if (cnt == 0) {
				if (!douji)
					REP(j, cvpii.size())
					if (vpii[j].second != 0 || vpii[j].second != l)
						if (cvpii[j].second == 0 || cvpii[j].second == l)
							ans = (j + 1);
				if (douji)
					REP(j, cvpii.size())
					if (vpii[j].second != 0 || vpii[j].second != l)
						if (cvpii[j].second == 0)
							ans = (j + 1);
			}
			else
				vpii = cvpii;
		}
		cout << sec << ' ' << ans << endl;
	}
}

Measured memory_bytes: 3096
#pragma warning(disable:4996)
#pragma comment(linker, "/STACK:336777216")
#pragma GCC optimize("Ofast")

#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <functional>

using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
#define int long long int
typedef complex<long double> cd;
const long double pi=acos(-1);
typedef double db;
typedef long double ldb;
typedef pair <int, int> pii;
typedef pair <db, db> pdd;
typedef vector<int> vi;
typedef vector<vector<int> > matrix;

#define m1 make_pair
#define pb push_back
#define flush fflush(stdout)
#define IOS std::ios::sync_with_stdio(false); cin.tie(NULL);cout.tie(NULL);
#define reset(x,v) memset(x,v,sizeof(x))

#define fi first
#define se second
#define endl "\n"
#define debug(x) (cerr << #x << ": " << x << "\n")
#define setbits(x) __builtin_popcount(x)
#define setbitsll(x) __builtin_popcountll(x)
#define all(x) x.begin(),x.end()
#define pii pair<int,int>

inline ll gcd(ll a,ll b){if(a==0) return b;return gcd(b%a,a);}
inline ll power(ll a,ll n,ll m){if(n==0)return 1;ll p=power(a,n/2,m);p=(p%m*p%m)%m;if(n%2) return (p%m*a%m)%m;else return p;}
const double EPS = 1e-9;
const ll MOD =998244353;
const ll hell=1000000007;
const int INF = 1e18;
const ll LL_INF = 0x3f3f3f3f3f3f3f3f;
template<typename T>
using ordered_set=tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;

auto seed = chrono::high_resolution_clock::now().time_since_epoch().count();
std::mt19937 rng(seed);

double startTime;
double getCurrentTime() {
    return ((double)clock() - startTime) / CLOCKS_PER_SEC;
}
const int dx[] = { -1, 0, 1, 0 };
const int dy[] = { 0, 1, 0, -1 };

const int N=200005;


void solve()
{
   
    int n;
    cin>>n;
    int ans=power(10,n,hell);
    ans=(ans-(2*power(9,n,hell))%hell+hell)%hell;
    ans=(ans+(power(8,n,hell)))%hell;
    cout<<ans<<endl;
    
    
    
}

int32_t main()
{
    IOS;
    
    int t;
    t=1;
    //cin>>t;
    while(t--)
    {
        solve();
    }
    return 0;
}







Measured memory_bytes: 3668
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int a,b,c;
    cin>>a>>b>>c;
    if(a==b&&a!=c||a==c&&a!=b||b==c&&a!=c)
        cout<<"Yes"<<endl;
    else
        cout<<"No"<<endl;

}


Measured memory_bytes: 256
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stack>
#include <vector>
using namespace std;
typedef long long int ll;
typedef long double ld;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define Sort(Array) sort(Array.begin(), Array.end())
#define Reverse(a) reverse(a.begin(), a.end())
#define out(ans) cout << ans << endl;
const int MOD = 1000000007;
const int INF = 2147483647;
const ld PI = 3.14159265358979323846;

//------------↓------------- M -------------- E ---------------- M --------------- O ---------------↓--------------//
// コンパイル 
// g++ -std=c++1z
//
// -------型変換--------
// int を string に変換
// string s = to_string(n);
// string を int に変換
// int n = stoi(s);
//
// -------二分探索---------
// k以上の値が最初に現れる時のイテレータ
// lower_bound(data.begin(), data.end(), k)
// kより大きい値が最初の現れる時のイテレータ O(logN)
// upper_bound(data.begin(), data.end(), k)
// kがdataに存在するかをtrue or falseで返す O(logN)
// binary_search(data.begin(), data.end(), k)
// 
//
//
//
//
//
// 
//------------↑------------- M -------------- E ---------------- M --------------- O ---------------↑--------------//






int main(void) {
    
    string s; cin >> s;
    int n = 'z' - 'a' + 1;
    int cnt[n]; rep(i,n) cnt[i] = 0;
    rep(i,s.size()) {
        ++cnt[s[i] - 'a'];
    }
    
    bool flag = true;
    rep(i,n) {
        if (cnt[i] >= 2) flag = false;
    }
    if (flag) cout << "yes" << endl;
    else cout << "no" << endl;
    
    return 0;
}






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

#define pb push_back
#define mp make_pair
#define f first
#define s second
#define int long long
#define double long double
typedef long long ll;
typedef pair<int,int> pii;
#define MAXN 1123456
#define INF LLONG_MAX
#define MOD 32416187567
#define cte 10002
#define MAX ULLONG_MAX

pair<int,pii> v[112345];


int32_t main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.precision(11);
    cout.setf(ios::fixed);

    int n;
    cin>>n;

    for(int i=0;i<n;i++){
        cin>>v[i].f>>v[i].s.f>>v[i].s.s;
    }

    sort(v,v+n);

    int dis=abs(v[0].s.s)+abs(v[0].s.f);
    //cout<<dis<<endl;
    if(dis>v[0].f || (v[0].f-dis)%2==1){
        cout<<"No"<<endl;
        return 0;
    }


    for(int i=1;i<n;i++){
        int dis=abs(v[i].s.s-v[i-1].s.s)+abs(v[i].s.f-v[i-1].s.f);
        //cout<<dis<<endl;
        if(dis>v[i].f-v[i-1].f || ((v[i].f-v[i-1].f)-dis)%2==1){
            cout<<"No"<<endl;
            return 0;
        }
    }

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

}






Measured memory_bytes: 2560
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const long long INF = 1LL<<60;

ll GCD(ll x,ll y){
    if(y == 0) return x;
    else return GCD(y,x%y);
}

ll LCM(ll a,ll b){
    return a / GCD(a,b) * b;
}

const int MOD = 1000000007;

long long rec(long long N) {
    if (N == 1) return 1;
    ll a = rec(N/2) * 2 + 1;
    return a;
}

int main() {
   long long N;
   cin >> N;
   cout << rec(N) << endl;
}


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

#define REP(i,n) for(ll i=0; i<(ll)(n); i++)
#define FOR(i,n,m) for (ll i=n; i<(ll)(m); i++)
#define pb push_back
#define INF 1000000007LL
#define all(a) (a).begin(),(a).end()

typedef long long ll;
typedef pair<int,int> p;

int dy[4]={-1,1,0,0};
int dx[4]={0,0,1,-1};
int d[110][110];
map<int, map<int, int> > ext;

struct edge{int a, b , c;};

int N, M;
int main(){
    ios::sync_with_stdio(false);
    vector<edge> e;
    REP(i,110) REP(j,110) {
        d[i][j] = INF;
    }
    cin >> N >> M;
    REP(i,N) {
        d[i][i] = 0;
    }
    REP(i,M) {
        int a, b, c;
        cin >> a >> b >> c;
        a--;b--;
        d[a][b] = c;
        d[b][a] = c;
        e.pb(edge{a,b,c});
    }
    
    for(int k = 0; k < N; ++k) for(int i = 0; i < N; ++i) for(int j = 0; j < N; ++j)d[i][j] = min(d[i][j],d[i][k] + d[k][j]);
    
    int ans = 0;
    for(auto x: e) {
        REP(i,N) REP(j,N) {
            if (d[i][x.b]+x.c+d[x.a][j]==d[i][j] || d[i][x.a]+x.c+d[x.b][j]==d[i][j]) {
                ans++;
                goto BREAK;
            }
        }
        BREAK:
            continue;
    }
    
    cout << M - ans << endl;
    
    return 0;
}

Measured memory_bytes: 384
import sys

cards = {
    "S": [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13],
    "H": [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13],
    "C": [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13],
    "D": [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13],
}

patterns = ['S', 'H', 'C', 'D']


def resolve():
    n = int(input())
    for card in sys.stdin:
        p, n = map(str, card.split())
        cards[p].remove(int(n))
    for pattern in patterns:
        for card in cards[pattern]:
            print("{} {}".format(pattern, card))


resolve()


Measured memory_bytes: 5608
#include <iostream>
#include <vector>
#include <map>
#include <unordered_map>
#include <queue>
#include <set>
#include <algorithm>
#include <string>
#include <math.h>
#include <limits.h>
#include<stdio.h>

using namespace std;

typedef long long ll;
typedef pair<ll, int> P;

struct edge{
    ll to;
    ll cost;
};

int V;
vector<edge> G1[100100];
vector<edge> G2[100100];
ll d1[100100];
ll d2[100100];

void dijkstra1(int s){
    priority_queue<P, vector<P>, greater<P> > que;
    fill(d1, d1+V, LONG_LONG_MAX);
    d1[s] = 0;
    que.push(P(0, s));

    while(!que.empty()){
        P p = que.top(); que.pop();
        int v = p.second;
        if(d1[v] < p.first) continue;
        for(int i = 0; i < G1[v].size(); i++){
            edge e = G1[v][i];
            if(d1[e.to] > d1[v] + e.cost){
                d1[e.to] = d1[v] + e.cost;
                que.push(P(d1[e.to], e.to));
            }
        }
    }
}

void dijkstra2(int s){
    priority_queue<P, vector<P>, greater<P> > que;
    fill(d2, d2+V, LONG_LONG_MAX);
    d2[s] = 0;
    que.push(P(0, s));

    while(!que.empty()){
        P p = que.top(); que.pop();
        int v = p.second;
        if(d2[v] < p.first) continue;
        for(int i = 0; i < G2[v].size(); i++){
            edge e = G2[v][i];
            if(d2[e.to] > d2[v] + e.cost){
                d2[e.to] = d2[v] + e.cost;
                que.push(P(d2[e.to], e.to));
            }
        }
    }
}


ll res[100100];

int main(){
    int m, s, t;
    cin >> V >> m >> s >> t;
    s--; t--;
    for(int i = 0; i < m; i++){
        int u, v;
        ll a, b;
        cin >> u >> v >> a >> b;
        u--; v--;
        edge e1, e2;
        e1.to = v;  e1.cost = a;
        e2.to = u;  e2.cost = a;
        G1[u].push_back(e1);
        G1[v].push_back(e2);

        edge e3, e4;
        e3.to = v;  e3.cost = b;
        e4.to = u;  e4.cost = b;
        G2[u].push_back(e3);
        G2[v].push_back(e4);
    }

    dijkstra1(s);
    dijkstra2(t);


    ll yen = LONG_LONG_MAX;
    for(int i = V-1; i >= 0; i--){
        ll c = d1[i] + d2[i];
        if(yen > c){
            yen = c;
        }
        res[i] = yen;
    }
    ll xx = 1e15;
    for(int i = 0; i < V; i++){
        cout << xx - res[i] << endl;
    }

    return 0;
}

Measured memory_bytes: 19140
n,m,*a=map(int,open(0).read().split())
d=[0]*n*9
for i in range(n):
 for j in a:
  c=(0,2,5,5,4,5,6,3,7,6)[j]
  if d[i]or i<1:d[i+c]=max(d[i+c],d[i]*10+j)
print(d[n])

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

using namespace std;

typedef long long ll;
typedef pair<int,int> pii;
typedef pair<pii,int> piii;
typedef pair<ll,ll> pll;

#define reps(i,f,n) for(int i = int(f); i <= int(n); i++)
#define rep(i,n) reps(i,0,int(n)-1)
#define rrep(i,n) for(int i = n-1; i >= 0; i--)

#define all(x) (x).begin(),(x).end()
#define X first
#define Y second

#define sz size()
#define eb emplace_back
#define pb push_back

vector<pii> p[2][200000];

int u[2][200000];
int m[2];
const int INF=1000000000;

bool dfs(int now, int to, int pos){
  bool ret = true;
  //cout << now << " : " << to << " : " << pos << endl;
  m[pos] = min(m[pos], now);
  rep(i, p[pos][to].sz){
    int next = p[pos][to][i].X;
    int val = p[pos][to][i].Y;
    //cout << "next: " << next << "  val: " << val << "  u[" << 1-pos << "][" << next << "]: " << u[1-pos][next] << endl;

    if(u[1-pos][next] == INF){
      u[1-pos][next] = val-now;
      m[1-pos] = min(m[1-pos], u[1-pos][next]);
      if(m[0]+m[1] < 0)return false;
      ret &= dfs(u[1-pos][next], next, 1-pos);
    }else if(u[1-pos][next] != val-now){
      return false;
    }
  }
  //cout << "---" << endl;
  return ret;
}


int main(void){
  int r,c,n;
  int x,y,a;
  cin >> r >> c;
  cin >> n;
  rep(i,n){
    cin >> x >> y >> a;
    x--;y--;
    p[0][x].pb(make_pair(y,a));
    p[1][y].pb(make_pair(x,a));
  }
  
  rep(i, r)u[0][i] = INF;
  rep(i, c)u[1][i] = INF;

  bool ret = true;

  rep(i,r){
    if(u[0][i] == INF){
      u[0][i] = 0;
      m[0] = 0;m[1] = INF;
      ret &= dfs(0, i, 0);
    }
  }

  if(ret) cout << "Yes" << endl;
  else cout << "No" << endl;

  return 0;

}


Measured memory_bytes: 21376
#include<bits/stdc++.h>
using namespace std;
int N,a;
deque<int> q;
int main() 
{
    cin>>N;
    for(int i=1; i<=N; i++) 
    {
        cin>>a;
        if(i&1)q.push_back(a);
        else q.push_front(a);
    }
    if(N&1)reverse(q.begin(),q.end());
    for(auto it=q.begin(); it!=q.end(); it++)
    cout<<*it<<' ';
    cout<<'\n';
    return 0;
}

Measured memory_bytes: 2944
#include <bits/stdc++.h>
#define err(args...) {}
#ifdef DEBUG
#include "_debug.cpp"
#endif
using namespace std;
using ll = long long;
using ld = long double;
template <typename T> using lim = numeric_limits<T>;
template <typename T> istream& operator>>(istream& is, vector<T>& a) { for(T& x : a) { is >> x; } return is; }
template <typename X, typename Y> istream& operator>>(istream& is, pair<X, Y>& p) { return is >> p.first >> p.second; }
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int n, W;
    cin >> n >> W;
    vector<ll> w(n), v(n);
    for(int i = 0; i < n; i++) {
        cin >> w[i] >> v[i];
    }
    vector<vector<ll>> total_value(4, vector<ll>(1));
    for(int d = 0; d <= 3; d++) {
        for(int i = 0; i < n; i++) {
            if(w[i] == w[0] + d) {
                total_value[d].push_back(v[i]);
            }
        }
        sort(total_value[d].begin() + 1, total_value[d].end(), greater<ll>());
        partial_sum(total_value[d].begin(), total_value[d].end(), total_value[d].begin());
    }
    ll ans = 0;
    for(int k0 = 0; k0 < total_value[0].size(); k0++) {
        for(int k1 = 0; k1 < total_value[1].size(); k1++) {
            for(int k2 = 0; k2 < total_value[2].size(); k2++) {
                for(int k3 = 0; k3 < total_value[3].size(); k3++) {
                    if(k0 * w[0] + k1 * (w[0] + 1) + k2 * (w[0] + 2) + k3 * (w[0] + 3) <= W) {
                        ans = max(ans, total_value[0][k0] + total_value[1][k1] + total_value[2][k2] + total_value[3][k3]);
                    }
                }
            }
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
var input = require('fs').readFileSync('/dev/stdin', 'utf8');
var Arr=(input.trim()).split("\n");
var x=0;
var y=0;
var r=0;
for(var i=0;i<Arr.length;i++){
if(Arr[i]=="0,0")break;
var arr=Arr[i].split(",").map(Number);
x+=arr[0]*Math.cos(r*Math.PI/180);
y+=arr[0]*Math.sin(r*Math.PI/180);  
r+=arr[1];
}
console.log(parseInt(y,10));
console.log(parseInt(x,10));

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

#define MP make_pair
#define PB push_back
#define ALL(x)      (x).begin(),(x).end()
#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,d,n) for(int i=(d);i<(n);i++)
#define RREP(i,n)   for(int i=(n);i>=0;i--)
#define CLR(a)      memset((a),0,sizeof(a))
#define MCLR(a)     memset((a),-1,sizeof(a))
#define RANGE(x,y,maxX,maxY) (0 <= (x) && 0 <= (y) && (x) < (maxX) && (y) < (maxY))

typedef long long LL;
typedef unsigned long long ULL;
typedef vector<int> VI;
typedef vector<VI > VVI;
typedef vector<string> VS;
typedef vector<LL> VLL;
typedef pair<int,int> PII;

const int INF = 0x3f3f3f3f;
const LL INFL = 0x3f3f3f3f3f3f3f3fLL;
const double EPS = 1e-9;

const int DX[]={1,0,-1,0},DY[]={0,-1,0,1};

int memo[100001];
void solve(long long N, std::vector<long long> A){
    REP(i, N) {
        memo[A[i]]++;
    }

    int double_eat = 0;
    int single_eat = 0;

    REP(i, 100001) {
        if(memo[i] == 2) {
            single_eat++;
        } else if (2 < memo[i]) {
            double_eat += (memo[i]-1) / 2;
            single_eat += (memo[i] % 2 == 0);
        }
    }

    cout << (N - double_eat * 2 - single_eat - (single_eat % 2 == 1)) << endl;
}

int main(){
    long long N;
    scanf("%lld",&N);
    std::vector<long long> A(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&A[i]);
    }
    solve(N, std::move(A));
    return 0;
}


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

int main(){
  string s;
  cin >> s;
  ll n = s.size();
  ll Max=n/2;
  ll count=0;
  for(int i=0; i<n; i++) if(s[i]=='p')count++;
  
  cout << Max-count << endl;
  
  return 0;
  
  
}

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

using namespace std;

typedef long long int lli;

int main() {
    int n, a, b, c, d;
    string s;

    cin >> n >> a >> b >> c >> d;
    cin >> s;
    for (int i = a; i < c; i++) {
        if (s[i-1] == '#' && s[i] == '#') {
            cout << "No" << endl;
            return 0;
        }
    }
    for (int i = b; i < d; i++) {
        if (s[i-1] == '#' && s[i] == '#') {
            cout << "No" << endl;
            return 0;
        }
    }

    if (c < b || c < d) {
        cout << "Yes" << endl;
        return 0;
    }
    for (int i=b-1; i < d; i++) {
        //cout << i << " ";
        if (s[i-1] == '.' && s[i] == '.' && s[i+1] == '.') {
            cout << "Yes" << endl;
            return 0;
        }
    }
    //cout << endl;

    cout << "No" << endl;

    return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <utility>
#include <algorithm>
#include <cstdio>
#include <iomanip>
#include <queue>
#include <deque>
#include <stack>
#include <fstream>
#include <cmath>
#include <random>
#include <complex>
#include <functional>

#define ll int64_t
#define Rep(i, n) for (ll i = 0; i < n; i++)
using namespace std;
typedef vector<ll> vec;
typedef vector<vec> mat;

const ll inf = 1LL << 60;

template<class T> inline void chmin(T& a, T b) {
    if (a > b) {
        a = b;
    }
}
template<class T> inline void chmax(T& a, T b) {
    if (a < b) {
        a = b;
    }
}

struct UnionFind {
    vector<ll> par;

    UnionFind(ll N) : par(N) {
        Rep (i, N) par[i] = i;
    }

    ll root (ll x) {
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }

    void unite (ll x, ll y) {
        ll rx = root(x);
        ll ry = root(y);
        if (rx == ry) return;
        par[rx] = ry;
    }

    bool same (ll x, ll y) {
        ll rx = root(x);
        ll ry = root(y);
        return rx == ry;
    }
};

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

    ll N, M, K;
    cin >> N >> M >> K;

    UnionFind uf(N);
    vec cnt(N, 0);
    Rep (i, M) {
        ll A, B;
        cin >> A >> B;
        A--; B--;
        uf.unite(A, B);
        cnt[A]++;
        cnt[B]++;
    }

    vec size(N, 0);
    Rep (i, N) {
        size[uf.root(i)]++;
    }

    vec ans(N);
    Rep (i, N) {
        ans[i] = size[uf.root(i)] - cnt[i] - 1;
    }

    while (K--) {
        ll C, D;
        cin >> C >> D;
        C--; D--;
        if (uf.same(C, D)) {
            ans[C]--;
            ans[D]--;
        }
    }

    Rep (i, N) {
        cout << ans[i] << " \n"[i==N-1];
    }

}

Measured memory_bytes: 4352
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
int main(int argc, char const *argv[])
{
    int n, al = 0, bo = 0;
    cin >> n;
    vector<int> a(n);

    for (int i = 0; i < n; i++)
    {
        int input;
        cin >> input;
        a[i] = input;
    }
    sort(a.rbegin(), a.rend());
    for (int i = 0; i < n; i++)
    {
        if (i % 2 == 0)
        {
            al += a[i];
        }
        else
        {
            bo += a[i];
        }
    }
    cout << al - bo;

    /* code */
    return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
#define rep(i,l,r) for(ll i=l;i<r;i++)
#define LINF (ll)1e18
#define INF (int)1e9
struct aaa{aaa(){cin.tie(0); ios::sync_with_stdio(0); cout<<fixed<<setprecision(10);};}aaaaaaa;
inline void in() {}
template <class Head, class... Tail>
inline void in(Head&& head,Tail&&... tail){
    cin>>head;
    in(move(tail)...);
}
template <class T>
inline void out(T t) {
    cout<<t<<'\n';
}
template <class Head, class... Tail>
inline void out(Head head,Tail... tail){
    cout<<head<<' ';
    out(move(tail)...);
}
int main(){
    int n,h;
    in(n,h);
    int a,b,max=-INF;
    vector<int> damage(n);
    rep(i,0,n){
        in(a,b);
        damage[i]=b;
        if(max<a)max=a;
    }
    sort(damage.begin(), damage.end(), greater<int>());
    int cnt=0;
    rep(i,0,n){
        if(damage[i]<=max||h<=0)break;
        h-=damage[i];
        cnt++;
    }
    if(h>0)cnt+=(h+max-1)/max;
    out(cnt);
}























Measured memory_bytes: 640
//#include <fsociety>
#include <cmath>
#include <deque>
#include <algorithm>
#include <iterator>
#include <list>
#include <map>
#include <unordered_map>
#include <queue>
#include <set>
#include <unordered_set>
#include <stack>
#include <string>
#include <vector>
#include <iostream>
//end of libraries ;
#define INF 999999
#define N 3000003
#define F first
#define S second
#define pb push_back
#define ll long long
#define fcin ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);
using namespace std;
ll n , m ;
int main(){
fcin;
	cin>>n>>m;
	ll ans1 = n*(n-1) / 2;
	ll ans2 = m*(m-1) / 2;
	cout<<ans1 + ans2<<endl;
}

Measured memory_bytes: 256
import java.util.Iterator;
import java.util.LinkedHashSet;
import java.util.Scanner;
import java.util.Set;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		
		int N = sc.nextInt();
		
		Set<String> Ws = new LinkedHashSet<>();

		for (int i = 0; i < N; i++) {
			Ws.add(sc.next());
		}
		
		if (Ws.size() != N) {
			System.out.println("No");
			return;
		}
		
		Iterator<String> iteratorWs = Ws.iterator();
		
		String W = iteratorWs.next();
		
		String lastCha = W.substring(W.length() - 1);
			
		//System.out.println(lastCha);
		
		for (int i = 1; i < N; i++) {
			
			String tmp = iteratorWs.next();
			//System.out.println(tmp);
			
			if (!lastCha.equals(tmp.substring(0,1))) {
				System.out.println("No");
				return;
			}
			lastCha = tmp.substring(tmp.length() - 1);
			//System.out.println(lastCha);
			
			
		}
		
		System.out.println("Yes");
	}
}

Measured memory_bytes: 22740
#include<stdio.h>
#include<stdlib.h>
int N,A[100],i,j,k;
void d(){int x;for(x=0;x<N;x++)printf("%d%s",A[x],x==N-1?"\n":" ");}
int main()
{
    scanf("%d",&N);
    for(i=0;i<N;i++)
        scanf("%d",&A[i]);
    for(i=1;i<N;A[j+1]=k,i++)
        for(k=A[i],j=i-1,d();A[j]>k;j--)
            A[j+1]=A[j];
    d();
    return 0;
}

Measured memory_bytes: 600
#include <bits/stdc++.h>
using namespace std;
#define REP(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) REP(i, 0, n)
#define rrep(i, n) for (int i = (int)(n-1); i >= 0; i--)
#define sz(x) int(x.size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define INF 2e9
#define LINF 1e18
template<class T> inline bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T &a, const T &b) { if (a > b) { a = b; return 1; } return 0; }
typedef long long ll;
typedef pair<int, int> P;

int main() {
    int n, k; cin >> n >> k;
    vector<int> h(n);
    rep(i, n) cin >> h[i];

    int ans = 0;
    rep(i, n) {
        if (h[i] >= k) ans++;
    }

    cout << ans << endl;
}

Measured memory_bytes: 640
//Never stop chasing!-MdSourav.
#include <bits/stdc++.h>

#define yes            cout<<"YES"<<endl
#define no             cout<<"NO"<<endl
#define sz(x)          x.size()
#define ll                    long long int
#define ls             long int
#define start          ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define test           int t;cin>>t;while(t--)
#define f(i, a, n)     for(int i=a; i<n;i++)
#define gcd(a,b)       __gcd(a,b)
#define lcd(a,b)       (a*b)/gcd(a,b)
#define pb             push_back
#define mp(x,y)        make_pair(x,y)
#define rsrt(v)        sort(v.begin(),v.end(),greater<int>())
#define srt(v)         sort(v.begin(),v.end())
#define basrt(a,n)     sort(a,a+n,greater<int>())
#define asrt(a,n)      sort(a,a+n)
#define fact(n)        ll x=1;for(ll i=1;i<=n;i++){x=(x*i);}
#define F              first
#define S              second
#define deb(x)         cout << #x << ": " << x << endl;
#define enter(v,n)     for(ll i=0;i<n;i++){ll x;cin>>x;v.pb(x);}
#define INF 	       1000000007
#define unique(v)      v.erase(unique(v.begin(),v.end()),v.end())
using namespace std;

double pi=3.14159265358979323846;
typedef vector<ll> vll ;
typedef vector<int> vii ;

template<typename T>
ostream& operator<<(ostream &os, const vector<T> &v)
{
    os << '{';
    for (const auto &x : v) os << " " << x;
        return os << '}';
}

void solve()
{

	 int a,b,c,d,e;
	 int v[5];
	 cin>>a>>b>>c>>d>>e;
	 v[0]=a,v[1]=b,v[2]=c,v[3]=d,v[4]=e;
	 for(int i=0;i<5;i++)
	 {
	 	if(v[i]==0)
		{
			cout << i+1;
		}
	 }






}
int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0);cout.tie(0);
    ll test_case=1;
    //cin>>test_case;
    while(test_case--)
	{
		solve();
	}

	return 0;
}

Measured memory_bytes: 3580
#include<stdio.h>

int main(){
	int a,b,ans=0;
	scanf("%d%d",&a,&b);
	if(a>b){
		ans+=a;
		a--;
	}else {
		ans+=b;
		b--;
	}if(a>b){
		ans+=a;
		a--;
	}else {
		ans+=b;
		b--;
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 128
loop do
  n = gets.to_i
  break if n==0
  s = n.to_s(8)
  for i in 0..(s.length-1)
    c = s[i]
    if '4'<=c
      c.next!
    end
    if '6'<=c
      c.next!
    end
    print c
  end
  print "\n"
end

Measured memory_bytes: 6104
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,b)  FOR(i,0,b)
#define X real()
#define Y imag()
#define S second;
#define F first;
#define PB(a) push_back(a)
#define BE(c) c.begin(),c.end()
using namespace std;
typedef long long LL;
typedef pair<int,int> pr;
typedef pair<pr,int> ppr;
typedef priority_queue<pr,vector<pr>,greater<pr> > PQ;
typedef vector<pr> Vpr;
typedef vector<LL> VI;
typedef complex<LL> cld;
typedef vector<cld> Vcld;
const int SIZE=1000010;
const LL INF=1LL<<58;
int main(){
	int N,K;
	cin >> N >> K;
	REP(i,K){
		int x,y;
		cin >> x >> y;
		x=min(x,N-x+1);
		y=min(y,N-y+1);
		int ans=min(x,y);
		cout << (ans-1)%3+1 << endl;
	}
	return 0;
}

Measured memory_bytes: 1160
sx, sy, tx, ty= map(int, input().split())

w = tx-sx
h = ty-sy


ans = ""
ans+="R"*w
ans+="U"*h
ans+="L"*w
ans+="D"*h

ans+="D"
ans+="R"*(w+1)
ans+="U"*(h+1)
ans+="L"

ans+="U"
ans+="L"*(w+1)
ans+="D"*(h+1)
ans+="R"

print(ans)

Measured memory_bytes: 3064
import java.util.*;
import java.lang.*;
public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		
		int A = sc.nextInt();
		int B = sc.nextInt();
		if( A>9 || B>9 ){
			System.out.println("-1");
		}else{
			System.out.println(A*B);
		}
	}
}


Measured memory_bytes: 21972
object MainKt {
  @JvmStatic fun main(args:Array<String>) {
    val N=readLine()!!.toInt()
    val A=readLine()!!.split(" ").map {it.toInt()}

    val Odd=A.filter {it % 2==1}
    // println(N)
    // println(A)
    println(if(Odd.size % 2 == 0) {"YES"} else {"NO"}) 
  }
}


Measured memory_bytes: 41148
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
using namespace std;
 
#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define pi M_PI
 
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

int main() {
    int h, w;
    while (cin >> h >> w && w > 0){
        int d = h*h + w*w;
        int x = 150, y, m = 1e9;
        FOR(i,1,150){
            FOR(j,1,i-1){
                int p = i*i + j*j;
                if (p == d && j > h && j < x){
                    m = p;
                    x = j;
                    y = i;
                }
                if (p > d && (p < m || (p == m && j < x))) {
                    m = p;
                    x = j;
                    y = i;
                }
            }
        }
        cout << x << " " << y << endl;
    }

    return 0;
}

Measured memory_bytes: 3084
from fractions import gcd
def result(n):
    lists = list()
    num = n
    for i in range(2, int((n**0.5//1))+1):
        if num%i==0:
            time=0
            while num%i==0:
                num //= i
                time+=1
            if not i in lists:
                lists.append(i)
    if num!=1:
        if not num in lists:
                lists.append(num)
    return lists
A , B = list(map(int,input().split()))
print(len(result(gcd(A,B)))+1)

Measured memory_bytes: 5560
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int a;
  int b;
  int c;
  cin >> a >>b;
  c = a+b;
  if(c%2 == 1){
   cout << (c+1)/2 <<endl;
  }
  else{
    cout<< c/2<<endl;
  }
}

Measured memory_bytes: 256
// first second push_back unordered return continue break vector visited check flag bool while iterator begin end lower_bound upper_bound temp true false ll_MAX ll_MIN insert erase clear pop push compare ll64_MAX ll64_MIN  reverse replace stringstream string::npos length substr front priority_queue

#ifndef ONLINE_JUDGE
#include "debug.h"
#else
#include <bits/stdc++.h>
using namespace std;
#define debug(...) 42
#endif

#define endl '\n'
#define ll long long
#define rint register int
#define minpq priority_queue <int, vector<int>, greater<int> >
#define maxpq  priority_queue <int>

#define re register
#define pb(x) push_back(x);
#define ce(x) cout << x << '\n';

using db = long double;
using pll = pair < ll, ll >;
#define scan(a, n) 		for(int i = 0; i < n; i++)cin >> a[i];

#define rep(i,x,n,inc) for(i=x ; i<n ; i+=inc)
#define repr(i,x,n,inc) for( i=x ; i>n ; i+=inc)
#define all(a)      (a).begin(),(a).end()
#define unique_sort(x) sort(all(x)), x.resize(distance(x.begin(), unique(all(x))))

#define mp(a,b) make_pair(a,b)
#define ff first
#define ss second
#define hell 1000000007
#define infl LLONG_MAX

#define conutBits(n)	__builtin_popcount(n)
#define Foxen(i,s) for (i=s.begin(); i!=s.end(); i++)
#define Fill(s,v) memset(s,v,sizeof(s))
#define cout_p(x, p) cout << fixed << setprecision((p)) << x << endl     //print with precision

#define tc(tt) \
    ll tt;    \
    cin >> tt; \
    for (ll _tt = 0; _tt < tt; _tt++) // testcase 

const int sz = 300009;
ll vis[sz];
std::vector<ll> g[sz];

ll dfs(ll i, ll p) {
	vis[i] = 1;

	for (auto zx : g[i]) {
		if (!vis[zx])	dfs(zx, i);
	}

	return 0;
}

int32_t main() {
	ios::sync_with_stdio(0); 		cin.tie(0); cout.tie(0);

	ll t, i, x, j, y, 	z, k, n;
	cin >> n >> t;

	rep(i, 0, t, 1) {
		cin >> x >> y;
		g[x].push_back(y);
		g[y].push_back(x);
	}
	z = -1;
	rep(i, 1, n + 1, 1) {
		if (!vis[i]) {
			z++;
			dfs(i, -1);
		}
	}
	ce(z);
	debug(z);
}



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

#define FOR(i, a, b) for (int i = (a), _b = (b); i <= _b; ++i)
#define FORd(i, a, b) for (int i = (a), _b = (b); i >= _b; --i)
#define FORall(it, a) for (__typeof((a).begin()) it = (a).begin(); it != (a).end(); ++it)
#define ms(x, n) memset(x, n, sizeof(x))
#define sz(x) int((x).size())
#define all(x) (x).begin(), (x).end()
#define uni(x) (x).erase(unique(all(x)), (x).end())
#define prec(x) fixed << setprecision((x))
#define fi first
#define se second
#define pb push_back
#define pf push_front
#define mp make_pair
#define long long long
#define db(x) cerr << #x << " = " << (x) << ", ";
#define endln cerr << "\n";
#define chkpt cerr << "------\n";
template<class T> inline int chkmax(T &a, T b) { return a < b ? a = b, 1 : 0; }
template<class T> inline int chkmin(T &a, T b) { return a > b ? a = b, 1 : 0; }
const int INF = (int) 1e9;
const long LINF = (long) 1e18;

int main() {
    int x, y; cin >> x >> y;
    set<int> s;
    s.insert(4); s.insert(6); s.insert(9); s.insert(11);
    if (x == 2 || y == 2) cout << "No";
    else {
        int a = s.find(x) != s.end();
        int b = s.find(y) != s.end();
        if (a == b) cout << "Yes";
        else cout << "No";
    }
    return 0;
}


Measured memory_bytes: 384
chomp (my $n = <>);
chomp (my @a = <>);

my @sort = sort{$b <=> $a} @a;

foreach my $a_i (@a) {
    if ($a_i == $sort[0]) {
        print $sort[1] . "\n";
        next;
    }

    print $sort[0] . "\n";
}

Measured memory_bytes: 55036
N = int(input())
V_list = list(map(int, input().split()))

V_list.sort()

bunsi = 2 ** (N - 1)

ans = 0
ans += V_list[0] / bunsi

for i, v in enumerate(V_list[1:]):
    ans += (v / bunsi) * 2 ** i

print(ans)


Measured memory_bytes: 3060
#include <cstdio>
#include <cmath>
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <map>
#include <queue>
#include <algorithm>

#ifdef _DEBUG
#define DMP(x) cerr << #x << ": " << x << "\n"
#else
#define DMP(x) ((void)0)
#endif

const int MOD = 1000000007, INF = 1111111111; 
using namespace std;
typedef long long lint;

int main() {

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

	int N, M;
	cin >> N >> M;

	vector<int> X(M);
	for (int i = 0; i < M; i++) cin >> X[i];
	sort(X.begin(), X.end());

	vector<int> sub(M - 1);
	for (int i = 0; i < M - 1; i++) sub[i] = X[i + 1] - X[i];
	sort(sub.begin(), sub.end());

	lint ans = 0;
	for (int i = 0; i < M - N; i++) ans += sub[i];

	cout << ans << "\n";

	return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <algorithm>
#include <map>
#define N 52
using namespace std;
typedef long long ll;
const ll mod = 1000000007LL;
int n, m;
int a[N], b[N];
int c[N], d[N];
int main() {
	cin>>n>>m;
	for (int i = 0; i < n; ++i) {
		cin>>a[i]>>b[i];
	}
	for (int i = 0; i < m; ++i) {
		cin>>c[i]>>d[i];
	}
	for (int i = 0; i < n; ++i) {
		int mind = 0;
		int idx = -1;
		for (int j = 0; j < m; ++j) {
			if (idx < 0) {
				idx = j;
				mind = abs(a[i]-c[j]) + abs(b[i] - d[j]);
			} else {
				int dis = abs(a[i]-c[j])+abs(b[i]-d[j]);
				if (dis < mind) {
					mind = dis;
					idx = j;
				}
			}
		}
		cout<<idx+1<<endl;
	}
	return 0;
}

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

double W, H, x, y;

int main(){
    cin >> W >> H >> x >> y;
    if(x * 2 == W && y * 2 == H){
        cout << W * H / 2 << " " << 1 << endl;
    }else{
        cout << W * H / 2 << " " << 0 << endl;
    }
}


Measured memory_bytes: 256
n = int(input())
p = [int(e) for e in input().split(" ")]

ret = 0

for i in range(n - 2):
    if (p[i] < p[i+1] and p[i+1] < p[i+2]) or (p[i] > p[i+1] and p[i+1] > p[i+2]):
        ret += 1
    
print(ret)

Measured memory_bytes: 3060
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <set>
#include <map>
#include <vector>
using namespace std;

int fa[200001],numx[200001],numy[200001];

int fin(int x){
    if (fa[x]==x) return x;
    return fa[x]=fin(fa[x]);
}


int main()
{
    int n;scanf("%d",&n);
    for (int i=1;i<=2e5;++i) fa[i]=i;

    for (int i=0;i<n;++i){
        int x,y;scanf("%d%d",&x,&y);
        fa[fin(x) ]=fin(y+1e5);
    }

    for (int i=1;i<=1e5;++i) ++numx[fin(i)];
    for (int i=1e5+1;i<=2e5;++i) ++numy[fin(i)];

    //for (int i=1;i<=2*n;++i) printf("%d ",fin(i));

    long long ans=0;
    for (int i=1;i<=2e5;++i) ans+=1LL*numx[i]*numy[i];
    ans-=n;
    printf("%lld\n",ans);
}





Measured memory_bytes: 2176
#include <iostream>
#include <map>
#include <set>
#include <algorithm>
#include <vector>
#include <sstream>
#include <string>
#include <functional>
#include <queue>
#include <deque>
#include <stack>
#include <limits>
#include <unordered_map>
#include <unordered_set>
#include <cmath>
#include <fstream>
#include <iterator>
#include <random>
#include <chrono>

 
#define forr(i,start,count) for (int i = (start); i < (start)+(count); ++i)
#define set_map_includes(set, elt) (set.find((elt)) != set.end())
#define readint(i) int i; cin >> i
#define readll(i) ll i; cin >> i
#define readdouble(i) double i; cin >> i
#define readstring(s) string s; cin >> s
 
typedef long long ll;
 
using namespace std;

ll modd = 1000*1000*1000+7;



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


int main()   {

    ios_base::sync_with_stdio(false);

    cout.precision(17);
    mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
    uniform_int_distribution<int> rand_gen(0, modd);   // rand_gen(rng) gets the rand no

//    auto start = chrono::steady_clock::now()

//    readint(test_cases);
    int test_cases = 1;
    forr(t, 1, test_cases) {
        readint(n);
        vector<int> a;
        forr(i,0,n) {
            readint(aa); a.push_back(aa);
        }
        int gcc = gcd(a[0], a[1]);
        for(auto x : a) {
            gcc = gcd(x, gcc);
        }
        if (gcc!=1) {
            cout << "not coprime" << endl; continue;
        }

        const int siz = 1000004;
        vector<int> eratosten(siz, -1);

        for(int i = 2; i*i <= siz; ++i) {
            if (eratosten[i]!=-1) {continue;}
            for(int j = 2; i*j < siz; j++) {
                eratosten[j*i] = i;
            }
        }

        vector<set<int>> prime_dec(n);
        forr(i,0,a.size()) {
            int x = a[i];
            while (x>1) {
                if (eratosten[x]==-1) {  prime_dec[i].insert(x); break; }
                prime_dec[i].insert(eratosten[x]);
                x/=eratosten[x];
            }
        }
        set<int> pp;
        bool problem = false;
        for(auto x : prime_dec) {
            for(auto p_ : x) {
                if (set_map_includes(pp, p_)) { problem = true; break;  }
                pp.insert(p_);
            }
        }

        cout << (problem ? "setwise coprime" : "pairwise coprime") <<endl;
 
//        cout << ret << endl;
    }

//    auto end = chrono::steady_clock::now();
//    cerr << chrono::duration_cast<chrono::milliseconds>(end - start).count() << endl;

    return 0;
}

Measured memory_bytes: 195352
#include <string>
#include <vector>
#include <map>
#include <set>
#include <deque>
#include <iostream>
#include <functional>
#include <algorithm>
#include <sstream>
#include <iterator>
#include <cmath>
#include <limits>
#include <tuple>
#include <queue>
#include <stack>

using namespace std;
typedef long long ll;

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define all(c) c.begin(),c.end()


int main()
{
	ll A;
	double B;
	cin >> A >> B;
	auto C = (ll)(A * (ll)round(B * 100.) / 100);
	cout << C << endl;
	return 0;
}


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

int main(){

    int N;
    cin >> N;

    int ans = 0;
    rep (i, N){
        int a;
        cin >> a;
        if ((i + 1) % 2 && a % 2) ans++; 
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3672
#include <bits/stdc++.h>
#define ll long long int
#define ld long double
const ll MOD = 998244353;
const ll INF = 1e18;
using namespace std;

map<ll, ll> dp;
ll arr[1000000];
ll a, b, c, d;
ll solve(ll n){
    if(dp.count(n)) return dp[n];
    ll res = 1e18;
    ll a1 = ((n + 1) / 2) * 2, a2 = ((n / 2)) * 2;
    ll b1 = 3ll * ((n + 2) / 3), b2 = 3ll * ((n) / 3);
    ll c1 = ((n + 4) / 5) * 5ll, c2 = (n / 5) * 5ll;

    if(n < (res / d))   res = n * d;
    res = min({res, abs(a1 - n) * d + a + solve(a1 / 2ll), abs(a2 - n) * d + a + solve(a2 / 2ll),
                abs(b1 - n) *d + b + solve(b1 / 3ll), abs(b2 - n) * d + b + solve(b2 / 3ll), 
                abs(c1 - n) * d + c + solve(c1 / 5ll), abs(c2 - n) * d + c + solve(c2 / 5ll)});

    return dp[n] = res;
}

main(){    
    #ifdef XOX
        freopen("D:\\V S Code\\cpp\\competitiveProgramming\\Input.txt", "r", stdin);
        freopen("D:\\V S Code\\cpp\\competitiveProgramming\\OPT.txt", "w", stdout);
    #endif

    ios::sync_with_stdio(!cin.tie(NULL));

    int t;
    cin >> t;
    while(t--){
        ll n;
        cin >> n >> a >> b >> c >> d;

        dp.clear();
        dp[1] = d;
        dp[0] = 0;
        cout << solve(n) << "\n";
        dp.clear();
    }
}

Measured memory_bytes: 4400
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
#define rep(i, begin, n) for (int i = begin; i < n; i++)
#define repe(i, begin, n) for (int i = begin; i <= n; i++)
#define repr(i, begin, n) for (int i = begin; i > begin - n; i--)
#define repre(i, begin, end) for (int i = begin; i >= end; i--)

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

const int inf = 1000000007;
const int MOD = 1000000007;
const long long INF = 1000000000000000007;

// -------------------------------------------------------
ll N;
ll A[101010];
ll X[101010];

int main() {
  cin >> N;
  ll sum = 0;
  ll sum_a_odd = 0;
  rep(i, 0, N) {
    cin >> A[i];
    sum += A[i];
    if (i % 2 == 1) {
      sum_a_odd += A[i];
    }
  }
  X[0] = sum - 2 * sum_a_odd;

  rep(i, 0, N - 1) {
    int idx = (2 * i) % N;
    int idx1 = (2 * i + 1) % N;
    int idx2 = (2 * i + 2) % N;
    X[idx2] = X[idx] - 2 * (A[idx] - A[idx1]);
  }

  rep(i, 0, N) {
    cout << X[i];
    if (i != N - 1) {
      cout << "\n";
    }
  }
}


Measured memory_bytes: 2944
#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;

const int INF=0x3f3f3f3f;
const ll INFL=0x3f3f3f3f3f3f3f3f;
const int MOD=1000000007;

int main(){
	puts("square1001");
}


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

using namespace std;

template<typename T>
long long modpow(const T n,const T p,const T mod);
template<typename T>
long long modinv(const T n,const T mod);
template<typename T>
bool chmax(T &a,const T &b);
template<typename T>
bool chmin(T &a,const T &b);

long long inf=1000000007;

int main(){
	long long n;
	cin>>n;
	if(n>=30) cout<<"Yes"<<endl;
	else cout<<"No"<<endl;

	return 0;
}

template<typename T>
long long modpow(const T n,const T p,const T mod){
	if(p==0) return 1;
	if(p%2==0){
		long long a=modpow(n,p/2,mod);
		return a*a%mod;
	}
	if(p%2==1) return (modpow(n,p-1,mod)*n)%mod;
	cerr<<"ERROR"<<endl;
	return 1;
}

template<typename T>
long long modinv(const T n,const T mod){
	return modpow(n,mod-2,mod);
}

template<typename T>
bool chmax(T &a,const T &b){
	if(a<b){
		a=b;
		return 1;
	}
	return 0;
}

template<typename T>
bool chmin(T &a,const T &b){
	if(a>b){
		a=b;
		return 1;
	}
	return 0;
}


Measured memory_bytes: 3632
def solve(m, A):
    if A[0] == m: return True
    if len(A)==1: return False
    if m < A[0] : return solve(m, A[1:])
    if solve(m-A[0], A[1:]):
        return True
    return solve(m, A[1:])

if __name__=='__main__':
    n=int(input()) 
    A=list(map(int,input().split()))
    q=int(input()) 
    Q=list(map(int,input().split()))
    for m in Q:
        if   m > sum(A): print('no')
        elif solve(m,A): print('yes') 
        else           : print('no') 

Measured memory_bytes: 7736
#include<bits/stdc++.h>
clock_t t=clock();
namespace my_std{
	using namespace std;
	#define pii pair<int,int>
	#define fir first
	#define sec second
	#define MP make_pair
	#define rep(i,x,y) for (int i=(x);i<=(y);i++)
	#define drep(i,x,y) for (int i=(x);i>=(y);i--)
	#define go(x) for (int i=head[x];i;i=edge[i].nxt)
	#define templ template<typename T>
	#define sz 1500
	typedef long long ll;
	typedef double db;
	mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
	templ inline T rnd(T l,T r) {return uniform_int_distribution<T>(l,r)(rng);}
	templ inline bool chkmax(T &x,T y){return x<y?x=y,1:0;}
	templ inline bool chkmin(T &x,T y){return x>y?x=y,1:0;}
	templ inline void read(T& t)
	{
		t=0;char f=0,ch=getchar();double d=0.1;
		while(ch>'9'||ch<'0') f|=(ch=='-'),ch=getchar();
		while(ch<='9'&&ch>='0') t=t*10+ch-48,ch=getchar();
		if(ch=='.'){ch=getchar();while(ch<='9'&&ch>='0') t+=d*(ch^48),d*=0.1,ch=getchar();}
		t=(f?-t:t);
	}
	template<typename T,typename... Args>inline void read(T& t,Args&... args){read(t); read(args...);}
	char __sr[1<<21],__z[20];int __C=-1,__zz=0;
	inline void Ot(){fwrite(__sr,1,__C+1,stdout),__C=-1;}
	inline void print(register int x)
	{
		if(__C>1<<20)Ot();if(x<0)__sr[++__C]='-',x=-x;
		while(__z[++__zz]=x%10+48,x/=10);
		while(__sr[++__C]=__z[__zz],--__zz);__sr[++__C]='\n';
	}
	void file()
	{
		#ifdef NTFOrz
		freopen("a.in","r",stdin);
		#endif
	}
	inline void chktime()
	{
		#ifdef NTFOrz
		cout<<(clock()-t)/1000.0<<'\n';
		#endif
	}
	#ifdef mod
	ll ksm(ll x,int y){ll ret=1;for (;y;y>>=1,x=x*x%mod) if (y&1) ret=ret*x%mod;return ret;}
	ll inv(ll x){return ksm(x,mod-2);}
	#else
	ll ksm(ll x,int y){ll ret=1;for (;y;y>>=1,x=x*x) if (y&1) ret=ret*x;return ret;}
	#endif
//	inline ll mul(ll a,ll b){ll d=(ll)(a*(double)b/mod+0.5);ll ret=a*b-d*mod;if (ret<0) ret+=mod;return ret;}
}
using namespace my_std;

const int n=1407,K=38;
//const int n=13,K=4;

int ans[sz][sz];
int S[sz][sz];

void print()
{
//	rep(i,1,n) {rep(j,1,n)putchar(ans[i][j]+'0');puts("");}
	rep(i,1,n)
	{
		rep(j,1,n) if (ans[i][j]) printf("%d ",j);
		puts("");
	}
}

int main()
{
	file();
	printf("%d %d\n",n,K);
	rep(i,0,K-2) S[i][i]=1;
	rep(i,1,K)
	{
		ans[i][1]=1;
		rep(j,0,K-2) ans[i][(i-1)*(K-1)+2+j]=1;
	}
	rep(i,2,K) rep(j,(i-1)*(K-1)+2,i*(K-1)+1) ans[j][i]=1;
	rep(i,2,K) rep(j,1,K-1)
	{
		int x=(i-1)*(K-1)+2,y=j*(K-1)+2;
		int t=(i-2)*(j-1);
		rep(a,x,x+K-1-1) rep(b,y,y+K-1-1) ans[a][b]=S[(a-x+t)%(K-1)][(b-y)%(K-1)];
	}
	print();
	return 0;
}

Measured memory_bytes: 10880
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll MOD = 1e9 + 7;
const int inf = 1e9;
const ll INF = 1e18;
const double pi = 3.14159265358979323846;
#define rep(i,n) for(ll i=0;i<n;i++)
using Graph = vector<vector<int>>;
using pint = pair<int,int>;
int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};

int main(){
    double x;cin>>x;
    ll a=100;
    for(int i=1;;i++){
        a=a+a/100;
        
        if(x<=a){
            cout<<i<<"\n";
            return 0;
        }
    }
}

Measured memory_bytes: 3728