akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<math.h>
#include<algorithm>
#include<stdint.h>
#include<vector>
#include<deque>
#include<stack>
#include<functional>
#include<string>
#include<cstring>
#include<time.h>
#include<array>
#include<iomanip>
#include<list>
#include<set>
#include<map>
#include<random>
#include<unordered_map>
#include<unordered_set>
#include<bitset>
#include <queue>


using namespace std;
using ll = long long;
using ull = unsigned long long;
using uint = unsigned int;
using ldouble = long double;


//BDD,ZDD,kdtree, bdtree,bicalc, bolonoy, doloney, tree, chinesemod,segmenttree,daikusutora, saidairyuu, 2bugurahu, heirokenshutu, topologicalsort, kyourenketuseibun

#define REP(i,a,b) for(ll i = a; i < b; ++i)
#define PRI(s) cout << s << endl
#define PRIY PRI("Yes")
#define PRIN PRI("No")

int main() {
	ll N;
	cin >> N;
	vector<ll> A(N);
	vector<pair<ll, ll>> P(N);
	vector<ll> L1(N), L2(N), R1(N), R2(N);
	REP(i, 0, N) {
		cin >> A[i];
		P[i].first = A[i];//atai
		P[i].second = i;//basho
	}
	sort(P.begin(), P.end(), [](const pair<ll, ll>& a, const pair<ll, ll>& b) {return a.first > b.first; });
	set<ll,greater<ll>> tmp;
	for (ll i = 0; i < N; ++i) {
		auto l1 = tmp.upper_bound(P[i].second);
		if (l1 == tmp.end()) {
			L1[P[i].second] = -1;
			L2[P[i].second] = -1;
		}
		else {
			L1[P[i].second] = *l1;
			auto l2 = tmp.upper_bound(*l1);
			if (l2 == tmp.end()) L2[P[i].second] = -1;
			else L2[P[i].second] = *l2;
		}
		tmp.insert(P[i].second);
	}
	set<ll> tmp2;
	for (ll i = 0; i < N; ++i) {
		auto r1 = tmp2.upper_bound(P[i].second);
		if (r1 == tmp2.end()) {
			R1[P[i].second] = N;
			R2[P[i].second] = N;
		}
		else {
			R1[P[i].second] = *r1;
			auto r2 = tmp2.upper_bound(*r1);
			if (r2 == tmp2.end()) R2[P[i].second] = N;
			else R2[P[i].second] = *r2;
		}
		tmp2.insert(P[i].second);
	}
	ll ans = 0;
	sort(P.begin(), P.end(), [](const pair<ll, ll>& a, const pair<ll, ll>& b) {return a.second < b.second; });
	REP(i, 0, N) {
		ans += (P[i].first) * (R1[P[i].second] - P[i].second) * (L1[P[i].second] - L2[P[i].second]);
		ans += (P[i].first) * (R2[P[i].second] - R1[P[i].second]) * (P[i].second - L1[P[i].second]);
	}
	PRI(ans);
	return 0;
}




Measured memory_bytes: 17884
#define _CRT_SECURE_NO_WARNINGS
#include <cstdio>
#include <vector>
#include <string>
#include <iostream>
#include <algorithm>
#include <map>
#include <iterator>
#include <functional>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <fstream>
#include <iomanip>
#include <numeric>
#include <cmath>
#include <list>
#include <sstream>
#include <cstring>
#include <stdio.h>
using namespace std;
#pragma GCC optimize("O3")
#pragma GCC target("sse4")

typedef long double LD;
typedef long long LL;
typedef unsigned long long ULL;
typedef pair<int, int> PII;
typedef pair<LD, LD> PDD;
typedef pair<LL, LL> PLL;
typedef vector<LL> VI;
typedef vector<LL> VLL;
typedef vector<char> VCH;
typedef vector<LD> VLD;
typedef vector<string> VS;
typedef vector<VS> VSS;
typedef vector<VI> VVI;
typedef vector<VLL> VVLL;
typedef vector<VCH> VVCH;
typedef vector<PII> VPII;
typedef vector<PLL> VPLL;
typedef vector<PDD> VPDD;
#define MP make_pair
#define PB push_back
#define X first
#define Y second
#define next fake_next
#define prev fake_prev
#define left fake_left
#define right fake_right

#define FOR(i,a,b) for(int i = (a); i < (b); ++i)
#define RFOR(i,b,a) for(int i = (b) - 1; i >= (a); --i)
#define REP(i, t) FOR(i,0,t)
#define ALL(a) a.begin(), a.end()
#define SZ(a) (int)((a).size())
#define FILL(a, value) memset(a, value, sizeof(a))

const LD PI = acos(-1.0);
const LD EPS = 1e-9;
const LL INF = 1e9;
const LL mod = 1000000007;
const LL LINF = 1e18 + 10;
const LL MAX = 1001;

int main()
{
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	//freopen("In.txt", "r", stdin);
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);


	int n;
	cin >> n;
	VI a(n);
	int ans = 1;
	FOR(i, 0, n)
		cin >> a[i];

	int up = 0;
	if (n < 3)
	{
		cout << 1;
		return 0;
	}

	if (a[0] < a[1])
		up = 1;
	else
		if (a[0] > a[1])
			up = 2;
		else
			up = 0;

	FOR(i, 1, n - 1)
	{
		if (up == 0)
		{
			if (a[i] == a[i + 1])
				continue;

			if (a[i] < a[i + 1])
				up = 1;
			else
				up = 2;

			continue;
		}

		if (up == 1)
		{
			if (a[i] > a[i + 1])
			{
				up = 0;
				++ans;
			}

			continue;
		}

		if (a[i] < a[i + 1])
		{
			up = 0;
			++ans;
		}
	}
		
	cout << ans;
	cin >> n;

	return 0;
}

Measured memory_bytes: 1024
#include <stdio.h>

int main(void)
{
	int a, b;

	scanf("%d %d", &a, &b);

	if (a > b)
	{
		printf("a > b\n");
	}
	else
	{
		if (a == b)
		{
			printf("a == b\n");
		}
		else
		{
			printf("a < b\n");
		}
	}

	return 0;
}


Measured memory_bytes: 2128
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define FOR(i, s, n) for (int i = (s); i < (n); i++)
#define RFOR(i, s, n) for (int i = (n) - 1; i >= (s); i--)
#define REP(i, n) FOR(i, 0, n)
#define RREP(i, n) RFOR(i, 0, n)
#define ALL(a) a.begin(), a.end()
#define IN(a, x, b) (a <= x && x < b)
const long long MOD = 1e9+7, INF = 1e18;
template<class T>inline bool CHMAX(T&a,T b){if(a<b){a=b;return true;}return false;}
template<class T>inline bool CHMIN(T&a,T b){if(a>b){a=b;return true;}return false;}

template<class T>
class SegmentTree{
	private:
	int N;
	T initVal;
	std::vector<T>ary;
	std::function<T(T&,T&)>merge;

	void init(int n){
		while(N < n)N <<= 1;
		ary.resize(N << 1,initVal);
	}

	public:
		SegmentTree(int n,T initVal,std::function<T(T&,T&)>f):
			N(1),initVal(initVal),merge(f){init(n);}
	
	// -- a[i] = val;
	inline void update(int i,T val){
		ary[i += N] = val;
		while(i > 1){
			i >>= 1;
			ary[i] = merge(ary[i << 1],ary[(i << 1) + 1]);
		}
	}

	// -- a[i] += val;
	inline void add(int i,T val){
		update(i,ary[i + N] + val);
	}

	// -- [l,r)
	inline T query(int l,int r){
		if(l >= r)return initVal;
		T vr = initVal,vl = initVal;
		for(l += N,r += N;l != r;l >>= 1,r >>= 1){
			if(l & 1)vl = merge(vl,ary[l++]);
			if(r & 1)vr = merge(vr,ary[--r]);
		}
		return merge(vl,vr);
	}
	/*
	void debug show(){
		for(iint i = N;i < N;i++)std::cerr << ary[i] << " ";
		std:::cerr << "\n";
	}
	*/
};
using ST = SegmentTree<int>;
//SUM : ST(n,0,[](int &a,int &b){return a+b};);
//MIN : ST(n,INF,[](int &a,int &b){return min(a,b);});

signed main(){
	int N;
	cin>>N;
	vector<int>a(N);
	REP(i,N)cin>>a[i];
	auto seg = ST(N,-1,[](int &a,int &b){return max(a,b);});
	REP(i,N)seg.update(i,a[i]);
	REP(i,N){
		if(i == 0)cout<<seg.query(1,N)<<endl;
		else if(i == N - 1)cout<<seg.query(0,N-1)<<endl;
		else cout<<max(seg.query(0,i),seg.query(i+1,N))<<endl;
	}
}

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

int H, W, N;
vector<int> B;

int main(void) {
	cin >> H >> W >> N;

	B.resize(H * W);
	int p = 0;
	for (int i = 1; i <= N; ++i) {
		int a;
		cin >> a;
		for (int j = 0; j < a; ++j)
			B[p++] = i;
	}

	for (int j = 0; j < H; ++j) {
		if (j % 2 == 0) {
			for (int i = j * W; i < j * W + W; ++i) {
				char c = (i == j * W + W - 1) ? '\n' : ' ';
				cout << B[i] << c;
			}
		}
		else {
			for (int i = j * W + W - 1; i >= j * W; --i) {
				char c = (i == j * W) ? '\n' : ' ';
				cout << B[i] << c;
			}
		}
	}

	return 0;
}

Measured memory_bytes: 384
import java.util.*;

public class Main{
  public static void main(String[]args){
    Scanner sc = new Scanner(System.in);
    int N = Integer.parseInt(sc.nextLine());
    long[][] num = new long[N][2];
    for(int i = 0; i < N; i++){
      num[i][0] = Long.parseLong(sc.next());
      num[i][1] = Long.parseLong(sc.next());
    }
    
    long ans = 0;
    for(int i = N-1; i >= 0; i--){
      num[i][0] += ans;
      if(num[i][0] % num[i][1] != 0){
        long a = num[i][1] - num[i][0] % num[i][1];
        num[i][0] += a;
        ans += a;
      }
    }
    System.out.println(ans);
  }
}

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

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vector<int>> vvi;
typedef vector<vector<ll>> vvl;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  double sum = 0;
  for (int i = 0; i < n; i++) {
    string s;
    double x;
    cin >> x >> s;
    if (s == "JPY")
      sum += x;
    else
      sum += 380000 * x;
  }
  printf("%.9lf\n", sum);
  return 0;
}


Measured memory_bytes: 256
/*
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,avx,avx2")
#pragma GCC optimize("Os")
#pragma GCC target("avx2,fma")
#pragma GCC optimize("Ofast")
#pragma GCC optimize("Os")
*/
#include <bits/stdc++.h>

typedef long long ll;
typedef long double ld; 

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

using namespace std;
    
const int N = 3e3 + 123;
const ll mod = 1e9 + 7;
const ll INF = 1e18;

double dp[N][N], a[N];
int n;
bool was[N][N];

int main () {
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	
	cin >> n;
	for(int i = 1;i <= n;i++){
		cin >> a[i];
	}
	queue< pair<int, int> > q;
	q.push(MP(0, 0));
	was[0][0] = 1;
	dp[0][0] = 1;

	while(!q.empty()){
		pair<int, int> v = q.front();
		q.pop();
		if(v.X + v.Y >= n)
			continue;
	 	dp[v.X + 1][v.Y] += dp[v.X][v.Y] * a[v.X + v.Y + 1];
	 	if(!was[v.X + 1][v.Y]){
	 		q.push(MP(v.X + 1, v.Y));
	 		was[v.X + 1][v.Y] = 1;
	 	}
	 	dp[v.X][v.Y + 1] += dp[v.X][v.Y] * (1 - a[v.X + v.Y + 1]);
	 	if(!was[v.X][v.Y + 1]){
	 		q.push(MP(v.X, v.Y + 1));
	 		was[v.X][v.Y + 1] = 1;
	 	}  	
	}
	double res=0;
	for(int i = 0;i <= n;i++){
		int j = n - i;
		if(i > j){
			res += dp[i][j];
		}
	}
	cout << setprecision(12) << fixed;
	cout << res;
	
	return 0;
}

Measured memory_bytes: 84224
#include <stdio.h>

int main(void){
	int S;
	int s;
	int m = 0;
	int h = 0;

	scanf("%d", &S);
	while (S >= 60) {
		S -= 60;
		m++;
	}
	s = S;
	while (m >= 60) {
		m -= 60;
		h++;
	}

	printf("%d:%d:%d\n", h, m, s);

	return 0;
}

Measured memory_bytes: 592
import sys
def input(): return sys.stdin.readline().rstrip()
def main():
    n,m=map(int,input().split())
    A=[]
    for i in range(m):
        p,y=map(int,input().split())
        A.append((p,y,i))
    A.sort()
    cunt,pre,ans=0,0,[]
    for a in A:
        s1=str(a[0])
        if pre!=a[0]:
            cunt=1
            pre=a[0]
        s2=str(cunt)
        ans.append((a[2],s1.zfill(6)+s2.zfill(6)))
        cunt+=1
    ans.sort()
    for s in ans:
        print(s[1])

if __name__=='__main__':
    main()

Measured memory_bytes: 35620
#include <iostream>
#include <cstdio>
#include <vector>
#include <iomanip>
using namespace std;

int main() {
    int H;
    int W;
    int K;

    cin >> H >> W >> K;

    vector <string> choco(H);

    const int INF = 100000000;
    int ans = INF;

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

    int upper = 1<<(H-1);

    for (int s = 0; s < upper; ++s) {
        vector<vector <int>> groups(1);

        for (int i = 0; i < H; ++i) {
            groups.back().push_back(i);

            if ((1<<i) & s) {
                groups.push_back(vector<int>());
            }
        }

        vector <int> cnt(groups.size());
        int cut = __builtin_popcount(s);

        for (int i = 0; i < W && cut < INF; ++i) {
            bool failed = false;

            for (int j = 0; j < groups.size() && !failed; ++j) {
                for (int k = 0; k < groups[j].size(); ++k) {
                    cnt[j] += (choco[groups[j][k]][i] == '1');

                    if (cnt[j] > K) {
                        failed = true;
                        break;
                    }
                }
            }

            if (failed) {
                fill(cnt.begin(), cnt.end(), 0);
                failed = false;

                for (int j = 0; j < groups.size(); ++j) {
                    for (int k = 0; k < groups[j].size(); ++k) {
                        cnt[j] += (choco[groups[j][k]][i] == '1');

                        if (cnt[j] > K) {
                            failed = true;
                            break;
                        }
                    }
                }

                ++cut;

                if (failed) { // impossible
                    cut = INF;
                    break;
                }
            }
        }

        //cout << "DEBUG " << s << " " << cut << endl;
        ans = min(ans, cut);
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
#include<stdlib.h>
#include<stdio.h>
  
int main()
{
    long long n,ans=0,binarry=1;
    cin>>n;
    while(n>=1){
        ans+=binarry;
        n=n/2;
        binarry*=2;
    }
    cout<<ans<<"\n";
    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef map<int,int> mii;
typedef vector<int> vi;
typedef vector<vector<int>> vii;
typedef vector<long long> vl;
typedef vector<vector<ll>> vll;
typedef vector<bool> vb;
typedef set<int> si; 
typedef queue<int> qi;
typedef stack<int> sti;
typedef priority_queue<int> pqi;
#define fori(i,a,b) for(int i = (a); i < (b); ++i)
#define rep(i,b,a) for(int i = (b); i >= (a); --i)
#define all(a) (a).begin(), (a).end()
//#define __builtin_popcountll bitCountLL
//#define __builtin_popcount bitCount
//__builtin_ctz 末尾0的个数, __builtin_clz 前导0的个数
//__builtin_ffs 最后一个1的位置
mt19937 mt_rand(chrono::high_resolution_clock::now().time_since_epoch().count());
//std::uniform_int_distribution<long long> rg(1,1e18);
#define maxn 100005
#define Mod 1000000007
const int INF = 2e9;
const ll ML = 4e18;
ll exgcd(ll a, ll b,ll &x,ll &y)//扩展欧几里得算法
{
    if(b==0)
    {
        x=1;y=0;
        return a;  //到达递归边界开始向上一层返回
    }
    ll r=exgcd(b,a%b,x,y);
    ll temp=y;    //把x y变成上一层的
    y=x-(a/b)*y;
    x=temp;
    return r;     //得到a b的最大公因数
}

void solve() {
    ll n;
    cin >> n;
    n *= 2;
    ll ans = n / 2;
    ll p = 2;
    vector<pair<ll, int>> vp;
    vl rs;
    while(p * p <= n) {
        if(n % p == 0) {
            int cnt = 0;
            ll t = 1;
            while(n % p == 0) {
                n /= p;
                t *= p;
                cnt++;
            }
            vp.push_back({p,cnt});
            rs.push_back(t);
        }
        if(n == 1) break;
        p++;
    }
    if(n > 1) {
        vp.push_back({n,1});
        rs.push_back(n);
    }
    int m = vp.size();
    
    fori(i,0,(1 << m)) {
        ll a = 1, b = 1;
        fori(j,0,m) {
            if(i & (1 << j)) {
                a *= rs[j];
            }
            else b *= rs[j];
        }
        if(a == 1 || b == 1) continue;
        ll x, y;
        exgcd(a, b, x, y);
        ll r = min(abs(a * x), abs(b * y));
        ans = min(r, ans);
    }
    cout << ans << endl;
}

int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
	//cout.precision(30); cout << fixed;
	//freopen("D:\\data_in.txt", "r", stdin);
   
    solve();
   
    /*
    clock_t start,finish;
    start = clock();
    
    finish = clock();
    cout << "\n" << (double)(finish - start) / (double)(CLOCKS_PER_SEC) * 1000 << "ms" << endl;
    */
    return 0;
}

/***************************************************************
 question:
 idea:
 tag:
 record:
 ***************************************************************/


Measured memory_bytes: 3652
import sys

n, k, *aaa = map(int, sys.stdin.buffer.read().split())
l = 0
r = max(aaa)
while l + 1 < r:
    m = (l + r) // 2

    cut = 0
    for a in aaa:
        cut += (a - 1) // m

    if cut > k:
        l = m
    else:
        r = m

print(r)


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

#define INF 10000000

int main(){

    int n, m; cin >> n >> m;
    vector<vector<int> > dist(n, vector<int> (n, INF));
    for(int i = 0; i < n; i++) dist[i][i] = 0;
    vector<int> a(m);
    vector<int> b(m);
    vector<int> c(m);

    for(int i = 0; i < m; i++){
        cin >> a[i] >> b[i] >> c[i];
        a[i]--;
        b[i]--;
        
    
        dist[a[i]][b[i]] = dist[b[i]][a[i]] = c[i];
    }


    //わー
    for(int k = 0; k < n; k++){
        for(int i = 0; i < n; i++){
            for(int j = 0; j < n; j++){
                dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j]);
            }
        }
    }


    int ans = 0;
    for(int i = 0; i < m; i++){
        if(dist[a[i]][b[i]] == c[i]) ans++;
    }

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

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Text;
using static System.Console;
using static System.Math;

namespace CP
{
    class Atria
    {
        static void Main(string[] args)
        {
            long[] ab = ReadLine().Split(' ').Select(long.Parse).ToArray();
            long a = ab[0];
            long b = ab[1];

            if (0 < a)
            {
                WriteLine("Positive");
            }
            else if (b < 0)
            {
                if (((Abs(a) - Abs(b)) + 1) % 2 == 0)
                {
                    WriteLine("Positive");
                }else
                    WriteLine("Negative");
            }
            else if (a <= 0 && 0 <= b)
            {
                WriteLine("Zero");
            }
        }
    }
}


Measured memory_bytes: 13396
from bisect import bisect_left, bisect_right

N = int(input())

A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))
A.sort()
B.sort()
C.sort()

alters_count = 0
for b in B:
    aidx = bisect_left(A, b)
    cidx = bisect_right(C, b)
    if cidx == N:
        continue
    alters_count += aidx * (N - cidx)

print(alters_count)

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

int main() {
 int N ;
  cin >> N;
  
  int M = N%10;
  
    if(M == 2 || M == 4 || M == 5 || M == 7 || M == 9){
  	cout << "hon" << endl;
  }else if(M == 0 || M == 1 || M == 6 || M == 8){
  	cout << "pon" << endl;
  }else{
    cout << "bon" << endl;
  }

}




Measured memory_bytes: 3624
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<n ; ++i)
#define REP(i,a,b) for(int i=a; i<b; ++i)
using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<ll>>;
const ll INF = 1e9;
//プロトタイプ宣言
void faster(void);
ll gcd(auto , auto);
ll get_digent(auto);
ll POW(auto , auto);

int main(){
  faster();
  ll k,s,ans=0;
  cin >> k >> s;
  for(ll i=0;i<=k;i++)for(ll j=0;j<=k;j++){
      if(s < i+j) continue;
      if((s-i-j) <= k) ans++;
  }
  cout << ans << endl;
}








































//以下、ライブラリ

void faster(void){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
}

ll gcd(auto a, auto b) {
  return (b ? gcd(b, a%b) : a);
} //ユークリッドの互除法

ll get_digent(auto x){
  string s;
  s = to_string(x);
  ll digent = s.size();
  return digent;
} //桁数取得

ll POW(auto x,auto y){
  if(y==0) return 1;
  if(y%2 == 1){
    ll temp = POW(x,y-1);
    return (temp*x);
  }
  else{
    ll temp = POW(x,y/2);
    return temp*temp;
  }
} //べき乗計算

Measured memory_bytes: 256
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    
    int N = Integer.parseInt(sc.nextLine());
    char[] c = sc.nextLine().toCharArray();
    
    int redCount = 0;
    
    for(int i = 0; i < N; ++i) {
      if(c[i] == 'R') ++redCount;
    }
    
    int whiteCount = 0;
    for(int i = 0; i < redCount; ++i) {
      if(c[i] == 'W') ++whiteCount;
    }
    
    System.out.println(whiteCount);
  }
}

Measured memory_bytes: 41764
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>
#define rc(x) return cout<<x<<endl,0
#define pb push_back
#define mkp make_pair
#define in insert
#define er erase
#define fd find
#define fr first
#define sc second
#define all(x) x.begin(),x.end()
#define lun(x) (int)x.size()
typedef long long ll;
typedef long double ld;
const ll INF=0x3f3f3f3f3f3f3f3f;
const ll llinf=(1LL<<60);
const int inf=(1<<30);
const int nmax=1e5+50;
const ll mod=1e9+7;
using namespace std;
int n,nr,i,x;
int main()
{
	//freopen("sol.in","r",stdin);
	//freopen("sol.out","w",stdout);
	//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
	ios_base::sync_with_stdio(false);cin.tie(0);cerr.tie(0);cout.tie(0);
	cin>>n;
	for(i=1;i<=n;i++)
	{
		cin>>x;
		if(x&1 && i&1)nr++;
	}
	cout<<nr<<endl;
	return 0;
}


Measured memory_bytes: 3600
#define _USE_MATH_DEFINES
#include <cmath>
#include <iostream>
# include <bits/stdc++.h>
using namespace std;
long long powerexp(long long base, long long exp, int mod) {
   long long res = 1;
   while (exp > 0) {
      if (exp % 2 == 1)
         res= (res * base) % mod;
      exp = exp >> 1;
      base = (base * base) % mod;
   }
   return res;
}
int gcd(int a, int b)
{
    int c = a % b;
    while(c != 0)
    {
        a = b;
        b = c;
        c = a % b;
    }
    return b;
}
void PrintVector(vector<long long int> v,long long int n)
{
 
    for(int i=0;i<v.size();i++)
    {
        cout<<v[i]<<" ";
    }
    cout<<endl;
}
void Takevector(vector<long long int> &v,long long int n)
{
  for(long long int i=0;i <n;i++)
  { long long int number;
    cin>>number;
    v.push_back(number);
  }
}
typedef long long int ll;
typedef vector<long long int> vi;
#define sci(x)         int x;       scanf("%d", &x);
#define scii(x, y)     int x, y;    scanf("%d %d", &x, &y);
#define sciii(x, y, z) int x, y, z; scanf("%d %d %d", &x, &y, &z);
#define scl(x)         ll x;       scanf("%lld", &x);
#define scll(x, y)     ll x, y;    scanf("%lld %lld", &x, &y);
#define sclll(x, y, z) ll x, y, z; scanf("%lld %lld %lld", &x, &y, &z);
#define TC(x)          sci(x); while(x --)
#define rep(i, x, y)   for (__typeof(x) i = x; i <= y; i ++)
#define repi(i, x, y)  for (__typeof(x) i = x; i >= y; i --)
#define fore(itr, x)   for (__typeof(x.begin()) itr = x.begin(); itr != x.end(); itr ++)
#define forei(itr, x)  for (__typeof(x.end()) itr = x.end() - 1; itr != x.begin() - 1; itr --)
#define nl cout<<"\n";
int min(int x, int y)  
{  
    return (x < y)? x: y;  
      
}  

int main()
{
  ll sum=0,tot=0,ans=0;
	int flag=1,flag1=0;
	scii(n,m);
	string s[n];
	rep(i,0,n-1)
	{
		cin>>s[i];
	}  
	rep(i,0,n-1)
	{
		int cnt=0;
		rep(j,0,m-1)
		{
			if(s[i][j]!='.')
				break;
			else cnt++;
		}
		if(cnt==m){
			for(int k=i;k<n-1;k++)
			{
				s[k]=s[k+1];
			}
			n--;
			i--;
		}
			

	}
	// rep(i,0,n-1)
	// {
	// 	cout<<s[i]<<endl;
	// }
	rep(i,0,m-1)
	{
		int cnt=0;
		rep(j,0,n-1)
		{
			if(s[j][i]!='.') break;
			else cnt++;
		}
		if(cnt==n){
			rep(j,0,n-1){
			for(int k=i;k<m-1;k++)
			{
				s[j][k]=s[j][k+1];
			}
		}
		m--;
		i--;
		}
	}
	for(int i=0;i<n;i++)
	{
		for(int j=0;j<m;j++)
		{
			cout<<s[i][j];
		}
		cout<<endl;
	}
return 0;
}

Measured memory_bytes: 256
import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int m = sc.nextInt();
        int c = sc.nextInt();
        List<Integer> b = new ArrayList<>();
        for (int i = 0; i < m; i++) {
            b.add(sc.nextInt());
        }
        int ans = 0;
        for (int i = 0; i < n; i++) {
            int sum = 0;
            for (int j = 0; j < m; j++) {
                int k = sc.nextInt();
                sum += b.get(j) * k;
            }
            sum += c;
            if (sum > 0) {
                ans++;
            }
        }
        System.out.println(ans);
    }
}


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

using namespace std;

int main(){
	int n,k;
	cin >> n >> k;
	int h[n];
	int min_h = 1e18;

	for(int i=0; i<n; i++) cin >> h[i];

	sort(h,h+n);

	for(int i=0; i<n-k+1; i++){
		min_h = min(h[i+k-1]-h[i],min_h);
	}
	cout << min_h << endl;
}

Measured memory_bytes: 640
import java.util.*;import java.io.*;import java.math.*;
public class Main
{
    public static void process()throws IOException
    {
        long n=nl();
        long k=nl();
        long ans=0;
        for(long i=k;i<=n+1;i++)
        {
            long low=i*(i-1)/2;
            long high=(i*n)-(i*(i-1)/2);
            // pn(low+" "+high);
            ans=(ans+1+((high%mod)-(low%mod)+mod)%mod)%mod;
        }
        pn(ans);
    }
    static long mod=(long)1e9+7;
    static AnotherReader sc;
    static PrintWriter out;
    public static void main(String[]args)throws IOException
    {
        boolean oj = true;
        if(oj){sc=new AnotherReader();out=new PrintWriter(System.out);}
        else{sc=new AnotherReader(100);out=new PrintWriter("output.txt");}
        int t=1;
        // t=ni();
        while(t-->0) {process();}
        out.flush();out.close();  
    }

    static void pn(Object o){out.println(o);}
    static void p(Object o){out.print(o);}
    static void pni(Object o){out.println(o);out.flush();}
    static int ni()throws IOException{return sc.nextInt();}
    static long nl()throws IOException{return sc.nextLong();}
    static double nd()throws IOException{return sc.nextDouble();}
    static String nln()throws IOException{return sc.nextLine();}
    static int[] nai(int N)throws IOException{int[]A=new int[N];for(int i=0;i!=N;i++){A[i]=ni();}return A;}
    static long[] nal(int N)throws IOException{long[]A=new long[N];for(int i=0;i!=N;i++){A[i]=nl();}return A;}
    static long gcd(long a, long b)throws IOException{return (b==0)?a:gcd(b,a%b);}
    static int gcd(int a, int b)throws IOException{return (b==0)?a:gcd(b,a%b);}
    static int bit(long n)throws IOException{return (n==0)?0:(1+bit(n&(n-1)));}

/////////////////////////////////////////////////////////////////////////////////////////////////////////

    static class AnotherReader{BufferedReader br; StringTokenizer st;
    AnotherReader()throws FileNotFoundException{
    br=new BufferedReader(new InputStreamReader(System.in));}
    AnotherReader(int a)throws FileNotFoundException{
    br = new BufferedReader(new FileReader("input.txt"));}
    String next()throws IOException{
    while (st == null || !st.hasMoreElements()) {try{
    st = new StringTokenizer(br.readLine());}
    catch (IOException  e){ e.printStackTrace(); }}
    return st.nextToken(); } int nextInt() throws IOException{
    return Integer.parseInt(next());}
    long nextLong() throws IOException
    {return Long.parseLong(next());}
    double nextDouble()throws IOException { return Double.parseDouble(next()); }
    String nextLine() throws IOException{ String str = ""; try{
    str = br.readLine();} catch (IOException e){
    e.printStackTrace();} return str;}}
   
/////////////////////////////////////////////////////////////////////////////////////////////////////////////
}

Measured memory_bytes: 32848
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <set>
#include <tuple>
#include <functional>
#include <map>
#include <unordered_map>
#include <queue>
#include <tuple>

using namespace std;

#define endl '\n'

using lld = long double;
using ull = unsigned long int;
using ll = long long;

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  const int precision = 13;
  cout.precision(precision);
  cout.setf(ios_base::fixed);

  int n; cin >> n;
  vector<double> a(n);
  for (auto& it : a) cin >> it;

  vector<vector<double>> dp(n+1, vector<double>(n+1, 0));
  for (int i = 0; i < n; ++i) dp[i][0] = 1;
  for (int i = 1; i <= n; ++i) {
    for (int j = 1; j <= n; ++j) {
      dp[i][j] = dp[i-1][j-1] * a[i-1] + dp[i-1][j] * (1-a[i-1]);
    }
  }

  cout << dp[n][n/2+1] << endl;

  return 0;
}


Measured memory_bytes: 70784
/*
ID: anonymo14
TASK: wormhole
LANG: C++                 
*/
#include<bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<pair<int,int>> vpii;

#define F first
#define S second
#define PU push
#define PUF push_front
#define PUB push_back
#define PO pop
#define POF pop_front
#define POB pop_back

#define REP(i,a,b) for(int i=a; i<=b; i++)

#define MOD 1000000007

void solve(int test_case) {
	string s;
	cin>>s;
	int n;
	cin>>n;
	bool rev = false;
	while(n--) {
		int t;
		cin>>t;
		if(t==1)rev=!rev;
		else {
			int f;char c;
			cin>>f>>c;
			if(!rev) {
				if(f==1)s=c+s;
				else s+=c;
			} else {
				if(f==1)s+=c;
				else s=c+s;
			}
		}
	}
	if(rev)reverse(s.begin(),s.end());
	cout<<s;
}

int main() {
	
	////// FILE BASED IO////
	//freopen("wormhole.in", "r", stdin);
	//freopen("wormhole.out", "w", stdout);
	///////////////
	
	ios::sync_with_stdio(0);
	cin.tie(0);
	int t=1;
	//cin>>t;
	REP(i,1,t) {
		solve(i);
	}
	return 0;
}	


Measured memory_bytes: 4664
#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;
int n,m,q;
int a[50],b[50],c[50],d[50];
int ans=0;
void dfs(vector<int> hoge,int now,int cnt){
	if(cnt==10){
		int sum=0;
		for(int i=0;i<q;i++){
			if(hoge[b[i]]-hoge[a[i]]==c[i]){
				sum+=d[i];
			}
		}
		ans=max(ans,sum);
		return;
	}else{
		for(int i=now;i<=m;i++){
			hoge.push_back(i);
			dfs(hoge,i,cnt+1);
			hoge.pop_back();
		}
	}
}
int main(){
	cin>>n>>m>>q;
	for(int i=0;i<q;i++){
		cin>>a[i]>>b[i]>>c[i]>>d[i];
		a[i]--;
		b[i]--;
	}
	vector<int> nii;
	dfs(nii,1,0);
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 3600
#include <bits/stdc++.h>
 
using namespace std;
 
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define all(a) a.begin(), a.end()
#define debug(x) cerr << #x << ": " << x << endl
 
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef long double ld;
 
template <typename T1, typename T2> bool chkmin(T1 &x, T2 y) { return y < x ? (x = y, true) : false; }
template <typename T1, typename T2> bool chkmax(T1 &x, T2 y) { return y > x ? (x = y, true) : false; }

signed main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
#ifdef DEBUG
  freopen("in", "r", stdin);
#endif

  int n, m;
  cin >> n >> m;
  if (n > m) {
    swap(n, m);
  }
  if (n == 1) {
    cout << "1\n";
    exit(0);
  }
  ll x = n * (ll)m;
  if (~x & 1) {
    cout << x / 2 << '\n';
  } else {
    cout << x / 2 + 1 << '\n';
  }

  return 0;
}




Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

using ll = long long;
using ii = pair<int,int>;
using vi = vector<int>;
using vii = vector<ii>;
const int oo = 1e9+7;
const int mod = 1e9+7;
const int MAXN = 3e3+5;

char s[MAXN];

int add(const int a, const int b) {
    return (a + b) % mod;
}

int main() {
    
    int n;
    scanf("%d", &n);
    scanf("%s", s);
    
    // dp[i][j] - number of valid permutations of size i
    // such that j is the last value in the permutation
    
    vector<vector<int>> dp(n+1, vector<int>(n+1, 0));
    dp[1][1] = 1;
    
    for(int len = 2; len <= n; ++len) {
        
        vector<int> pref(n+1, 0);
        
        if(s[len-2] == '<') {
            int run = 0;
            for(int a = 1; a <= len-1; ++a) {
                run = add(run, dp[len-1][a]);
                pref[a] = run;
            }
        } else {
            int run = 0;
            for(int a = len-1; a >= 1; --a) {
                run = add(run, dp[len-1][a]);
                pref[a] = run;
            }
        }
        
        for(int b = 1; b <= len; ++b) {
            
            if(s[len-2] == '<') {
                dp[len][b] = add(dp[len][b], pref[b-1]);
            } else {
                dp[len][b] = add(dp[len][b], pref[b]);
            }
            
            //~ for(int a = 1; a <= len-1; ++a) {
                
                //~ int real_a = a;
                //~ if(real_a >= b) {
                    //~ real_a++;
                //~ }
                
                //~ if((real_a < b) != (s[len-2] == '<')) continue;
                
                //~ dp[len][b] = add(dp[len][b], dp[len-1][a]);
                
            //~ }
        }
    }
    
    int ans = 0; 
    
    for(int i = 1; i <= n; ++i) {
        ans = add(ans, dp[n][i]);
    }
    
    printf("%d\n", ans);
    
    return 0;
}




Measured memory_bytes: 35584
use std::str::FromStr;
use std::fmt::Debug;
use std::cmp;

#[allow(dead_code)]
fn read_as_vec<T>() -> Vec<T>
where T: FromStr, <T as FromStr>::Err : Debug{
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().split_whitespace().map(|c| T::from_str(c).unwrap()).collect()

}

fn main(){
    let line: Vec<u64> = read_as_vec();

    let (x, y) = (line[0], line[1]);
    let mut cur = x;
    let mut ans = 1;
    while cur*2 <= y{
        cur *= 2;
        ans += 1;
    }

    println!("{}", ans);
}


Measured memory_bytes: 4352
#include <stdio.h>

int hantei(int l1,int l2,int l3);
//??´?§?????§???¢??????????????????????????????????????????

int main(void)
{
	int kaisuu, l1, l2, l3;
	int kekka[1000];
	scanf("%d", &kaisuu);
	for(int i = 0; i < kaisuu; i++) {
		scanf("%d %d %d", &l1, &l2, &l3);
		kekka[i] = hantei(l1, l2, l3);
	}
	for(int i = 0; i < kaisuu; i++) {
		if(kekka[i] == 1) {
		 	printf("YES\n");
		}else{
			printf("NO\n");
		}
	}
	return 0;
}

int hantei(int l1,int l2,int l3)
{
	int llong, lshort1, lshort2;
	if(l1 <= l2) {
		lshort1 = l1 * l1;
		if(l2 <= l3) {
			lshort2 = l2 * l2;
			llong = l3 * l3;
		}else{
			lshort2 = l3 * l3;
			llong = l2 * l2;
		}
	}else{
		lshort1 = l2 * l2;
		if(l1 <= l3) {
			lshort2 = l1 * l1;
			llong = l3 * l3;
		}else{
			lshort2 = l3 * l3;
			llong = l1 * l1;
		}
	}
	if(lshort1+ lshort2 == llong) {
		return 1;
	}else{
		return 0;
	}
}

Measured memory_bytes: 1012
#include<cstdio>
int n,x,k,q,a[100001];
int main(){
	scanf("%d%d%d",&n,&k,&q);
	for(register int i=1;i<=n;i++)a[i]=k;
	for(register int i=1;i<=q;i++){
		scanf("%d",&x);
		a[x]++;
	}
	for(register int i=1;i<=n;i++){
		if(a[i]>q)puts("Yes");
		else puts("No");
	}
}

Measured memory_bytes: 896
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    long A = sc.nextLong();
    long B = sc.nextLong();
    int K = sc.nextInt();
    if(B-A+1<=K*2){
      for(long i=A;i<=B;i++){
        System.out.println(i);
      }
      return;
    }
    
    for(int i=0;i<K;i++){
      System.out.println(A);
      A++;
    }
    for(int i=0;i<K;i++){
      System.out.println(B-K+1);
      B++;
    }
  }
  

  
}

Measured memory_bytes: 23892
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define ok() puts(ok?"Yes":"No");
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> ii;
typedef vector<vi> vvi;
typedef vector<ii> vii;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef set<int> si;
typedef map<string, int> msi;
typedef greater<int> gt;
typedef priority_queue<int, vector<int>, gt> minq;
typedef long long ll;
typedef pair<ll,ll> pll;
const ll LINF = 1e18L + 1;
const int INF = 1e9 + 1;
//clang++ -std=c++11 -stdlib=libc++ 

int main() {
  int a,b; cin >> a >> b;
  cout << a*b << endl;
  return 0;
}

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

int main() {
  int N;
  double ans;
  
  cin >> N;
  vector<double> vec(N);
  for(int i=0;i<N;++i){
    cin >> vec.at(i);
  }
  sort(vec.begin(),vec.end());
  ans = (vec.at(0) + vec.at(1))/2;
  for(int i=2;i<N;++i){
    ans = (ans+vec.at(i))/2;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3748
#include<bits/stdc++.h>
using namespace std;
int main() {
    int h,w;
    cin >> h >> w;
    while(h != 0 || w != 0) {
        for(int i = 0;i < h;i++) {
            for(int j = 0;j < w;j++) {
                char c = '.';
                if(i == 0 || i == h - 1 || j == 0 || j == w - 1)
                    c = '#';
                cout << c;
            }
            cout << endl;
        }
        cout << endl;
        cin >> h >> w;
    }
    return 0;
}


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

#define debug(x) cout <<"DEBUG"<<" "<< #x << ":" << x << '\n'
#define rep(i,n) for(int_fast32_t i = 0; i < ((int_fast32_t)(n)); i++)   // 0-indexed up
#define rep1(i,n) for(int_fast32_t i = 1; i <= ((int_fast32_t)(n)); i++) // 1-indexed up
#define rrep(i,n) for(int_fast32_t i = ((int_fast32_t)(n)-1); i >= 0; i--)  // 0-indexed down
#define rrep1(i,n) for(int_fast32_t i = ((int_fast32_t)(n)); i >= 1; i--)   // 1-indexed down
#define all(x) (x).begin(),(x).end()

using namespace std;

template<typename T>
using vec = vector<T>;
using i32 = int_fast32_t;
using i64 = int_fast64_t;
using u32 = uint_fast32_t;
using u64 = uint_fast64_t;
using ll = long long;
using ld = long double;
using vi = vec<int_fast32_t>;
using vl = vec<int_fast64_t>;
using vld = vec<ld>;
using vii = vec<vi>;
using PII = pair<int_fast32_t, int_fast32_t>;

template<class T>
using maxheap = std::priority_queue<T>;
template<class T>
using minheap = std::priority_queue<T, std::vector<T>, std::greater<T>>;

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

const ld Pi = std::acos(-1.0L);
constexpr ll infll = (1LL<<62)-1;
constexpr int inf = (1<<30)-1;
const int mod = 1000000007;
// const int mod = 998244353;


/*FUNCs=================================================*/


/*MAIN==================================================*/
signed main(){
    double START_TIME = clock();
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
//    cout << fixed << setprecision(15);

    i32 n, W; cin >> n >> W;
    i32 val, w;

    vii dp(n+1, vi(W+1));
    rep(i,n) {
        cin >> val >> w;
        for(i32 pw = 0; pw <= W; ++pw) {
            chmax(dp[i+1][pw], dp[i][pw]);
            if(pw+w <= W) chmax(dp[i+1][pw+w], dp[i][pw] + val);
        }
    }

    i32 ans = -1;
    rep(i,W+1) chmax(ans, dp[n][i]);

    cout << ans << '\n';

//     printf("ElapsedTime: %5.3f ms\n",1000*((clock()-START_TIME)/CLOCKS_PER_SEC));
}



Measured memory_bytes: 10624
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<map>
#include<set>
#include<vector>
#include<queue>
#include<stack>
#include<list>
#include<unordered_map>
using namespace std;
#define ll long long
#define dd cout<<endl
#define lll __int128
const int mod=1e9+7;
const int inf=1e9+7;
  
//const int maxn=
 
int main()
{
    ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    
    map<string,int>book;
    
    book["SAT"]=1;
    book["SUN"]=7;
    book["FRI"]=2;
    book["THU"]=3;
    book["WED"]=4;
    book["TUE"]=5;
    book["MON"]=6;
	
	string str;
	
	while(cin>>str)
		cout<<book[str]<<endl;
    
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>

#include <set>
#include <map>
#include <iomanip>

using namespace std;

#define rep(i, n) for(long long i = 0; i < (long long)(n); i++)
#define all(x) (x).begin(),(x).end()

using ll = long long;

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

	cout << 3 * r * r << endl;
	
	return 0;
}

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


int main(){
  while(1){
    int n,r;
    cin >> n >> r;
    if(n==0) break;

    deque<int> card;
    for(int i=1;i<n+1;i++){
      card.push_back(n-i+1);
    }
    for(int i=0;i<r;i++){
      int p,c;
      cin >> p >> c;
      for(int j=0;j<c;j++){
	card.push_front( card[p+c-2] );
	deque<int>::iterator ite = card.begin()+p+c-1; 
	card.erase( ite );
      }
    }
    cout << card[0] << endl;
  }
  return 0;
}

Measured memory_bytes: 1220
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < n; i++)
#define FOR(i, m, n) for(ll i = m;i < n;i++)
#define VSORT(v) sort(v.begin(), v.end());
#define VREV(v) reverse(v.begin(), v.end());
using namespace std;
using ll = long long;
using pll = pair<ll,ll>;
using vll = vector<ll>;
using vdouble = vector<double>;
using vstr = vector<string>;
typedef pair<int,int> P;
int dx[4] = {1, 0, -1, 0},dy[4] = {0, 1, 0, -1};
ll gcd(ll a, ll b) { return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a/gcd(a,b)*b;}
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 ll INF = 1LL << 60;
const ll mod = 1000000007;

//ll dp[3100][3100];// dp[i][j]=
int keta10(ll n){
	return log10(n)+1;
}
int main(){
	ll A,B,AB,X,Y;
	cin>>A>>B>>AB>>X>>Y;
	ll ans=INF;
	for(ll ab=200200;0<=ab;ab-=2){
		ll a=max((ll)0,X-(ab/2));//追加で必要なAの数
		ll b=max((ll)0,Y-(ab/2));//追加で必要なBの数
		ans=min(ans,AB*ab+A*a+B*b);
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main()
{
    ios::sync_with_stdio(false);
    string s,t,u;
    int a,b;
    cin>>s>>t;
    cin>>a>>b;
    cin>>u;
    if(u==s)
        a--;
    if(u==t)
        b--;
    cout<<a<<" "<<b<<endl;
    return 0;
}


Measured memory_bytes: 764
#include<bits/stdc++.h>
using namespace std;
int main()
{
     ios_base ::sync_with_stdio(0);cin.tie(0);cout.tie(0);
     int n,ans=0;
     cin>>n;
     vector<int> v (n);
     for(int i=0;i<n;i++)
        cin>>v[i];
     map<int,int> cnt;
     for(auto u : v){
         cnt[u]++;

     }
     sort(v.begin(),v.end());
     int sz=unique(v.begin(),v.end())-v.begin();
     for(int i=0;i<sz;i++)
        {
            if(v[i]<cnt[v[i]])
                ans+=cnt[v[i]]-v[i];
            else if(v[i]>cnt[v[i]])
                ans+=cnt[v[i]];


        }
        cout <<ans;

}


Measured memory_bytes: 8088
#include <cstring>
#include <cstdio>
#include <iostream>
#include <algorithm>
#define LL long long
using namespace std;

int main()
{
	int sum=0;
	for (int i=1;i<=4;i++)
	{
		char ch;
		cin>>ch;
		if (ch=='+') sum++;
		else sum--;
	}
	printf("%d\n",sum);
	return 0;	
} 

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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define FOR(i,n,m) for(int i=(int)(n); i<=(int)(m); i++)
#define RFOR(i,n,m) for(int i=(int)(n); i>=(int)(m); i--)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define RITR(x,c) for(__typeof(c.rbegin()) x=c.rbegin();x!=c.rend();x++)
#define setp(n) fixed << setprecision(n)

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

#define ld long double
#define ll long long
#define vll vector<ll>
#define vi vector<int>
#define pll pair<ll,ll>
#define pi pair<int,int>

#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define ins insert

using namespace std;

/* Some Libraries */

//-------------------------------------------------

int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n; cin>>n;
    cout<<n*2/__gcd(2ll,n)<<endl;
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
	int a = 0, b = 0, c = 0, d = 0;
	scanf("%d%d", &a, &b);
	c = b * 2;
	d = a - c;
	if (d>=1)
	{
		printf("%d\n", d);
	}
	else
	{
		printf("0");
	}
	return 0;
}

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


int main() {
#ifdef HOME
    freopen("in", "r", stdin);
#endif

    int n;
    while (scanf("%d", &n) == 1) {
        vector<vector<int> > e(n);
        for (int i = 0; i < n - 1; i++) {
            int u, v;
            scanf("%d%d", &u, &v);
            u--; v--;
            e[u].push_back(v);
            e[v].push_back(u);
        }
        function<int(int, int)> dfs = [&](int v, int pr) {
            int cur = 0;
            for (int to : e[v]) {
                if (to == pr) continue;
                cur ^= dfs(to, v) + 1;
            }
            return cur;
        };
        int x = dfs(0, 0);
        string ans = x == 0 ? "Bob" : "Alice";
        cout << ans << endl;
    }

#ifdef HOME
    cerr << clock() / (double)CLOCKS_PER_SEC << endl;
#endif
    return 0;
}


Measured memory_bytes: 13568
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
#define all(a) (a).begin(),(a).end()
#define dunk(a) cout << (a) << endl
using namespace std;
typedef long long ll;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n, k;
	cin >> n >> k;
	vector<int> l(n);
	rep(i, n) cin >> l[i];

	sort(l.rbegin(), l.rend());

	int ans = 0;
	rep(i, k) {
		ans += l[i];
	}

	dunk(ans);

	return 0;
}

Measured memory_bytes: 256
from heapq import heappop, heappush

def cross(a,b):
    return a[0]*b[1]-a[1]*b[0]

def calc(r1,r2):
    a = ((r1[0]-r2[0])**2+(r1[1]-r2[1])**2)**0.5
    b = r1[2]
    c = r2[2]
    cos = (a**2+b**2-c**2)/(2*a*b)
    s = b*cos
    t = (b**2-s**2)**0.5
    e = ((r2[0]-r1[0])/a,(r2[1]-r1[1])/a)
    h = (-e[1],e[0])
    return [[r1[0]+s*e[0]+t*h[0], r1[1]+s*e[1]+t*h[1]],[r1[0]+s*e[0]-t*h[0], r1[1]+s*e[1]-t*h[1]]]

def check(a,b,s,t):
    v = (b[0]-a[0],b[1]-a[1])
    v1 = (s[0]-a[0],s[1]-a[1])
    v2 = (t[0]-a[0],t[1]-a[1])
    if cross(v,v1)*cross(v,v2) > 0:
        return 0
    v = (t[0]-s[0],t[1]-s[1])
    v1 = (a[0]-s[0],a[1]-s[1])
    v2 = (b[0]-s[0],b[1]-s[1])
    if cross(v,v1)*cross(v,v2) > 0:
        return 0
    return 1

def dijkstra(m,v):
    dist = [float("inf")]*m
    q = [(0,0)]
    dist[0] = 0
    while q:
        dx,x = heappop(q)
        for y,d in v[x]:
            if dist[y] > dx+d:
                dist[y] = dx+d
                heappush(q,(dx+d,y))
    return dist[m-1]
def solve(n):
    r = [[int(x) for x in input().split()] for i in range(n)]
    p = [[r[0][0],r[0][1]]]
    for i in range(n-1):
        p += calc(r[i],r[i+1])
    p.append([r[-1][0],r[-1][1]])
    m = 2*n
    v = [[] for i in range(m)]
    gate = []
    for i in range(1,n):
        gate.append([p[2*i-1],p[2*i]])

    for i in range(m):
        x = p[i]
        for j in range(i+1,m):
            y = p[j]
            for g1,g2 in gate[(i-1)//2+1:(j-1)//2]:
                if not check(x,y,g1,g2):
                    break
            else:
                d = ((x[0]-y[0])**2+(x[1]-y[1])**2)**0.5
                v[i].append((j,d))
                v[j].append((i,d))
    print(dijkstra(m,v))

while 1:
    n = int(input())
    if n == 0:
        break
    solve(n)



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

#define INF 1.1e9
#define LINF 1.1e18
#define FOR(i,a,b) for (int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
#define pb push_back
#define pf push_front
#define fi first
#define se second
#define BIT(x,n) bitset<n>(x)
#define PI 3.14159265358979323846

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

//-----------------------------------------------------------------------------

string s;
int C=-1,F=-1;

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

	cin>>s;
	REP(i,(int)s.size()) {
		if(s[i]=='C') {
			C=i;
			break;
		}
	}
	REP(i,(int)s.size()) {
		if(s[i]=='F') F=i;
	}
	if(F<=C||C==-1||F==-1) cout<<"No"<<endl;
	else cout<<"Yes"<<endl;

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define repb(i, a, b) for(int i = a; i >= b; i--)
#define all(a) a.begin(), a.end()
#define o(a) cout << a << endl
#define int long long
#define first fi;
#define second se;
using namespace std;
typedef pair<int, int> P;

signed main(){
    int q;
    cin >> q;
    int p, n;
    char c;
    int now = 0;
    rep(i, 0, q){
        cin >> p >> c >> n;
        if(c == '(') now += n;
        else now -= n;
        if(now == 0) cout << "Yes" << endl;
        else cout << "No" << endl;
    }
}

Measured memory_bytes: 3100