akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define forn(i, s, t) for (int i = s ; i < (int)t ; i++)
#define fi first
#define se second
#define all(x) x.begin(),x.end()
#define pf2(x,y) printf("%d %d\n",x,y)
#define pf(x) printf("%d\n",x)
#define each(x) for(auto it:x)  cout<<it<<endl;
#define pi pair<int,int>
#define pb push_back
#define sc(x) scanf("%d",&x)
#define sc2(x,y) scanf("%d%d",&x,&y) 
#define pf(x) printf("%d\n",x)
#define pf2(x,y) printf("%d %d\n",x,y)
#define mem(a,x) memset(a,x,sizeof(a))
#define copy(b,a) memcpy(a,b,sizeof(a))
#define SZ(x) (int)x.size()
#define VI vector<int> 
#define VII vector<pair<int,int>> 
#define PI pair<int,int>
using namespace std;
typedef long long ll;
ll qpow(ll x,ll y,ll p){ll ans=1;for(x%=p;y;y>>=1,x=x*x%p)if(y&1) ans=ans*x%p;return ans;}
ll inv(ll x,ll p){return x<=1?1:(p-p/x)*inv(p%x,p)%p;}
ll sqrt2(ll x){ll l=1,r=2e9;while(l<r){ll mid=(l+r+1)>>1;if(mid*mid<=x) l=mid;else r=mid-1;}return l;}
ll sqrt3(ll x){ll y=(ll)(powl((long double)x,1.0/3.0)+0.5);while(y*y*y<x) y++;while(y*y*y>x) y--;return y;}
ll comb(ll n,ll m,ll p){if(m>n||n<0) return 0;if(m>n-m) m=n-m;ll ans=1;for(int i=1;i<=m;i++)ans=ans*n%p,ans=ans*inv(i,p),n--;return ans;}
ll comb(ll n,ll m){if(m>n||n<0) return 0;if(m>n-m) m=n-m;ll ans=1;for(int i=1;i<=m;i++)ans=ans*n,ans/=i,n--;return ans;}
ll ceil(ll x,ll y){return (x+y-1)/y;}
int lowerbit(int x) {return x&-x;}
int HighBit(int x){for(int i=30;i>=0;i--)if(x>>i&1) return i;}
const int maxn=1e5+5;
const int maxm=1e4+5;
const ll P=1e9+7;
char s[maxn];
int n;
int main(){
	sc(n);
	scanf("%s",s);
	ll ans=0;
	forn(i,1,n-1){
		int cntl_R=0,cntl_G=0,cntl_B=0;
		int cntr_R=0,cntr_G=0,cntr_B=0;
		forn(l,0,i)
			if(s[l]=='R') cntl_R++;
			else if(s[l]=='G') cntl_G++;
			else cntl_B++;
		forn(r,i+1,n)
			if(s[r]=='R') cntr_R++;
			else if(s[r]=='G') cntr_G++;
			else cntr_B++;
		if(s[i]=='R') {
			ans+=cntl_G*cntr_B;
			ans+=cntl_B*cntr_G;
			for(int j=1;i-j>=0 && i+j<n ;j++)
				if(s[i-j]=='G' && s[i+j]=='B') ans--;
				else if(s[i-j]=='B' && s[i+j]=='G') ans--;
		}
		if(s[i]=='G'){
			ans+=cntl_R*cntr_B;
			ans+=cntl_B*cntr_R;
			for(int j=1;i-j>=0 && i+j<n ;j++)
				if(s[i-j]=='R' && s[i+j]=='B') ans--;
				else if(s[i-j]=='B' && s[i+j]=='R') ans--;
		}
		if(s[i]=='B'){
			ans+=cntl_G*cntr_R;
			ans+=cntl_R*cntr_G;
			for(int j=1;i-j>=0 && i+j<n ;j++)
				if(s[i-j]=='G' && s[i+j]=='R') ans--;
				else if(s[i-j]=='R' && s[i+j]=='G') ans--;
		}
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 3752
#if 1
#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <stack>
#include <array>
#include <deque>
#include <algorithm>
#include <utility>
#include <cstdint>
#include <functional>
#include <iomanip>
#include <numeric>
#include <assert.h>

auto& in = std::cin;
auto& out = std::cout;


const int MAX_E = 2000;
const int MAX_V = 1000;
const int64_t INF = 1000000000000000000;
// 頂点fromから頂点toへのコストcostの辺
struct edge { int from, to; int64_t cost; };
edge es_[2][MAX_E]; // 辺
edge* es; // 辺
int64_t d[MAX_V]; // 最短距離
int V, E; // Vは頂点数、Eは辺数
		  // s番目の頂点から各頂点への最短距離を求める
void shortest_path(int s) {
	for (int i = 0; i < V; i++) d[i] = INF;
	d[s] = 0;
	for (int count = 0; count <= V; count++) {
		bool update = false;
		for (int i = 0; i < E; i++) {
			edge e = es[i];
			if (d[e.from] != INF && d[e.to] > d[e.from] + e.cost) {
				d[e.to] = d[e.from] + e.cost;
				update = true;
				if (e.to == V - 1) {
					goto check;
				}
			}
		}
		if (!update) return;
		// n回目にも更新があるなら負の閉路が存在する
		if (count>=V) {
			//通るわけがない
			throw 0; exit(0);
		}
	}

check:;
	//閉路チェック
	for (int count = 0; count < 3*V; count++) {
		bool update = false;
		bool GOAL_update = false;
		for (int i = 0; i < E; i++) {
			edge e = es[i];
			if (d[e.from] != INF && d[e.to] > d[e.from] + e.cost) {
				d[e.to] = d[e.from] + e.cost;
				update = true;
				if (e.to == V - 1) {
					GOAL_update=true;
				}
			}
		}
		if (!update) break;
		// n回目にも更新があるなら負の閉路が存在する
		if (count>V && GOAL_update) {
			std::cout << "inf\n"; exit(0);
		}
	}
}

int main()
{
	using std::endl;
	in.sync_with_stdio(false);
	out.sync_with_stdio(false);

	in >> V>>E;
	for (int32_t i = 0; i < E; ++i)
	{
		int a, b;int64_t c;
		in >> a >> b >> c; --a; --b; c = -c;
		es_[0][i] = edge{ a,b,c };
	}
	es = es_[0];
	shortest_path(0);
	std::cout << -d[V - 1] << std::endl;
	return 0;
}
#endif


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

int main(){
    int n;
    cin >> n;
    cout << 3 * (n * n);
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <cstdint>

int main() {
	std::string a;
	std::cin >> a;

	int64_t ans = a.size() * (a.size() - 1) / 2 + 1;
	for (int i = 0; i < 26; ++i) {
		auto c = std::count(a.begin(), a.end(), 'a' + i);
		ans -= c * (c - 1) / 2;
	}

	std::cout << ans << std::endl;
}

Measured memory_bytes: 640
#include"iostream"
#include<stdlib.h>
#include<stdio.h>
#include<time.h>
#include<list>
#include<map>
#include<string>
#include<algorithm> 
#include <queue> 
#include <sstream>
#include <fstream>
#include<cmath>
#define INF 1000000000
#define LL long long
using namespace std;

vector<LL> v;

long long N, M,K, ans, A[100000],use[10],B;
string s;



int main() {
	cin >> N>>K;
	for (int i = 0; i < N; i++) {
		cin >> A[i];
	}
	sort(A, A + N);
	ans = INF;
	for (int i = K-1; i < N; i++) {
		ans = min(ans, A[i] - A[i - (K-1)]);
	}
	cout << ans<<endl;
	return 0;
}

Measured memory_bytes: 1024
import java.util.Scanner;

public class Main {
	void run() {
		Scanner scan = new Scanner(System.in);
		while (true) {
			int n = scan.nextInt();
			int p = scan.nextInt();
			if (n == 0 && p == 0) return;
			int[] num = new int[n];
			int pebble = p;
			for (int i = 0;; i++) {
				if (pebble != 0) {
					pebble--;
					num[i]++;
				} else {
					pebble = num[i];
					num[i] = 0;
				}
				if (num[i] == p) {
					System.out.println(i);
					break;
				}
				if (i == n - 1) i = -1;
			}
		}
	}
	public static void main(String[] args) {
		new Main().run();
	}
}

Measured memory_bytes: 26440
#pragma region template 2.4
#include <bits/stdc++.h>
using namespace std;
template <typename T>
using pq_asc = priority_queue<T, vector<T>, greater<T>>;
typedef long long ll;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef pair<ll, ll> ii;
typedef vector<ii> vii;
typedef vector<string> vs;
#define REP(i, n) for (ll i = 0; i < (n); ++i)
#define REP1(i, n) for (ll i = 1; i <= (n); ++i)
#define FOR(i, a) for (auto &i : a)
#define CH(f, x, y) x = f(x, y)
#define IN(T, x) \
    T x;         \
    cin >> x;
#define AIN(T, a, n) \
    vector<T> a(n);  \
    FOR(i, a)        \
    cin >> i;
#define A2IN(T1, a, T2, b, n) \
    vector<T1> a(n);          \
    vector<T2> b(n);          \
    REP(i, n)                 \
    cin >> a[i] >> b[i];
#define OUT(x) cout << (x) << endl;
#define FOUT(x) cout << fixed << setprecision(15) << (x) << endl;
#define ALL(a) (a).begin(), (a).end()
#define SORT(a) sort(ALL(a))
#define RSORT(a) \
    SORT(a);     \
    reverse(ALL(a))
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define DUMPA(a)          \
    cout << #a << " = {"; \
    JOUT(ALL(a), ", ", cout) << "}" << endl;

template <typename T>
ostream &JOUT(T s, T e, string sep = " ", ostream &os = cout)
{
    if (s != e)
    {
        os << *s;
        ++s;
    }
    while (s != e)
    {
        os << sep << *s;
        ++s;
    }
    return os;
}

ostream &YES(bool cond, string yes = "Yes", string no = "No", ostream &os = cout)
{
    if (cond)
    {
        os << yes << endl;
    }
    else
    {
        os << no << endl;
    }
    return os;
}

template <typename T1, typename T2>
ostream &operator<<(ostream &os, const pair<T1, T2> &p)
{
    os << '(' << p.first << ", " << p.second << ')';
    return os;
}

template <typename T>
ostream &operator<<(ostream &os, const vector<T> &v)
{
    os << '[';
    JOUT(ALL(v), ", ", os) << ']';
    return os;
}

const ll INF = 1e18;
const ll MOD = 1e9 + 7;
#pragma endregion template

const ll C = 1e5;
ll N, M;
vi V, W;
vvi dp;

void f(ll i)
{
    if (i > M)
    {
        return;
    }
    REP1(j, C)
    {
        dp[i][j] = dp[i / 2][j];
        if (j >= W[i])
        {
            CH(max, dp[i][j], dp[i / 2][j - W[i]] + V[i]);
        }
    }
    f(2 * i);
    f(2 * i + 1);
}

ll g(ll i, ll L)
{
    if (i <= M)
    {
        return dp[i][L];
    }
    ll res = g(i / 2, L);
    if (L >= W[i])
    {
        CH(max, res, g(i / 2, L - W[i]) + V[i]);
    }
    return res;
}

int main()
{
    cin >> N;
    V.resize(N + 1);
    W.resize(N + 1);
    REP1(i, N)
    {
        cin >> V[i] >> W[i];
    }
    M = min(512LL, N);
    dp.assign(M + 1, vi(C + 1));
    f(1);
    IN(ll, Q);
    REP(q, Q)
    {
        IN(ll, v);
        IN(ll, L);
        OUT(g(v, L));
    }
}

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

/* #pragma */
//#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")


/*alias*/
//#define F first
#define S second

#define y0 y3487465
#define y1 y8687969
#define j0 j1347829
#define j1 j234892
#define next asdnext
#define prev asdprev
#define itn int

/*template*/
template<class T>inline bool amax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>inline bool amin(T &a, const T &b) { if (b < a) { a = b; return 1; } return 0; }

/* func */
int32_t GCD(int32_t a, int32_t b){return b ? GCD(b, a%b) : a;}
int64_t GCD(int64_t a, int64_t b){return b ? GCD(b, a%b) : a;}
int32_t LCM(int32_t a, int32_t b){return a * b / GCD(a, b);}
int64_t LCM(int64_t a, int64_t b){return a * b / GCD(a, b);}

/*struct*/
struct aaa {
	aaa() {
		cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(20);
	};
}aaaaaaa;

/* const */
constexpr int32_t INF = 1001001001;
constexpr int64_t LINF = 1001001001001001001ll;
constexpr int32_t MOD = 1e9 + 7; //10^9
constexpr int64_t EPS = 1e-9;
constexpr int32_t dx[] = { 1, 1, 0, -1, -1, -1, 0, 1 }, dy[] = { 0, 1, 1, 1, 0, -1, -1, -1 };
//constexpr int32_t dx[] = {1, 0, -1, 0}, dy[] = {0, 1, 0, -1};
//Counterclockwise from the 6o'clock direction
//Take the x-axis downward and the y-axis right


//g++ -std=c++14 -Wall --pedantic-errors -o template template.cpp
//g++ -std=c++14 -Wall --pedantic-errors template.cpp
//chcp 65001

/*global*/

template<class Monoid> struct SegTree{
	using Func = function<Monoid(Monoid, Monoid)>;
	vector<Monoid> dat;
	int SIZE_R;
	const Func F;
	const Monoid UNITY;

	SegTree(int n, const Func f, const Monoid &unity): F(f), UNITY(unity){ init(n); }
	void init(int n){
		SIZE_R = 1;
		while(SIZE_R < n) SIZE_R *= 2;
		dat .assign(SIZE_R*2, UNITY);
	}

	void set(int a, const Monoid &v) { dat[a+SIZE_R] = v;}
	void build(){
		for(int k = SIZE_R -1; k > 0; --k){
			dat[k] = F(dat[k*2], dat[k*2+1]);
		}
	}

	void update(int a, const Monoid &v){
		int k = a + SIZE_R;
		dat[k] = v;
		while(k >>= 1){
			dat[k] = F(dat[k*2], dat[k*2+1]);
		}
	}

	Monoid get(int a, int b){
		Monoid vleft = UNITY, vright = UNITY;
		for(int left = a+SIZE_R, right = b+SIZE_R; left < right; left >>= 1, right >>= 1){
			if(left & 1) vleft = F(vleft, dat[left++]);
			if(right & 1) vright = F(dat[--right], vright);
		}
		return F(vleft, vright);
	}
	inline Monoid operator [] (int a){return dat[a+SIZE_R]; }
};

#define int int64_t
signed main()
{
    int n; cin >> n;
	SegTree<int64_t> seg(n, [](int64_t a, int64_t b){return GCD(a, b);}, 0);

	vector<int> a(n);
	for(int i = 0; i < n; ++i){
		cin >> a[i];
		seg.set(i, a[i]);
	}
	seg.build();

	int64_t ans{};
	for(int i = 0; i < n; ++i){
		int64_t left = seg.get(0,i);
		int64_t right = seg.get(i+1, n);
		amax(ans, GCD(left, right));
	}
	cout << ans << endl;
}


Measured memory_bytes: 3200
#include <bits/stdc++.h>
using namespace std;
int main(){
	int t, h, m, s;
	cin >> t;
	h = t/3600;
	t = t%3600;
	m = t/60;
	t = t%60;
	s = t;
	cout << h << ":" << m << ":" << s << endl;
	return 0;
}



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

int main(){
        
    int n;
    cin >> n;
    vector<int>a(n);
    for(int i = 0; i < n; i++){
        cin >> a[i];
    }
    
    
    map<int, int>mp;
    for(int i = 0; i < n; i++){
        mp[a[i]] += 1;
    }
    
    int res = 0;
    for(auto v : mp){
        //cout << v.first << " " << v.second << endl;
        int current = v.second;
        if(mp.find(v.first + 1) != mp.end()){
            current += mp[v.first + 1];
        }
        if(mp.find(v.first - 1) != mp.end()){
            current += mp[v.first - 1];
        }
        res = max(res, current);
    }
    
    cout << res << endl;
    
    
    return 0;
    
    
}


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

int main(){
  int64_t N;
  cin >> N;
  vector<int64_t> A(N);
  map<int64_t,int64_t> m;
  for(int64_t i=0;i<N;i++){
    cin >> A.at(i);
    if(m.count(A.at(i))){
      m.at(A.at(i))++;
    }else{
      m[A.at(i)]=1;
    }
  }
  vector<int64_t> comb(N+1);
  comb.at(0)=0;
  for(int64_t i=1;i<=N;i++){
    comb.at(i)=i*(i-1)/2;
  }
  int64_t sum=0;
  for(auto p:m){
    sum+=comb.at(p.second);
  }
  int64_t ans;
  for(int64_t i=0;i<N;i++){
    ans=sum;
    ans=ans-comb.at(m.at(A.at(i)))+comb.at(m.at(A.at(i))-1);
    cout << ans << endl;
  }
  return 0;
}


Measured memory_bytes: 12672
//
//AtCoder Beginner Contest 082
//C
//

#include <iostream>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <ctime>
#include <queue>
#include <map>
#include <set>
#include <tuple>
#include <functional>
#include <cassert>
#include <bitset>

using namespace std;

#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
#define ALL(x) (x).begin(),(x).end()
#define RALL(x) (x).rbegin(),(x).rend()
#define SIZE(x) (int)(x).size()
#define SIZEL(x) (ll)(x).size()
#define MSG(a) cout << #a << " " << a << endl;

using ll = long long;
using ld = long double;
using Graph = vector<vector<int>>;

const double PI = 3.14159265358979323846;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

ll gcd(ll x, ll y) { return (x % y)? gcd(y, x % y): y; }    //最大公約数
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }            //最小公倍数

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

    vector<int> a(n);
    REP(i, n) cin >> a[i];

    sort(ALL(a));

    int ans = 0;
    int bef = -1;
    int cnt = 1;
    REP(i, n){
        if (bef==a[i]) {
            cnt++;
        }else{
            if (bef!=-1){
                if(bef>cnt) ans+=cnt;
                if(bef<cnt) ans+=cnt-bef;
            }
            bef=a[i];
            cnt=1;
        }
    }
    if (bef!=-1){
        if(bef>cnt) ans+=cnt;
        if(bef<cnt) ans+=cnt-bef;
    }
    cout << ans << endl;
    return 0;
}


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

int N;
vector<int> b;

int main() {
    cin >> N;
    for (int i = 0; i < N; i++) {
        int b_in;
        cin >> b_in;
        b.push_back(b_in);
    }

    vector<int> ans;
    bool f = true;
    for (int i = 0; i < N; i++) {
        for (int j = b.size() - 1; j >= 0; j--) {
            if (b[j] == j+1) {
                ans.push_back(b[j]);
                b.erase(b.begin() + j);
                f = false;
                break;
            }
        }

        if (f) {
            break;
        }
    }

    if (ans.size() != N) {
        cout << -1 << endl;
    }
    else {
        for (int i = ans.size() - 1; i >= 0; i--) {
            cout << ans[i] << endl;
        }
    }
    

    return 0;
}


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

using namespace std;
using ll = long long;
using vl = vector<ll>;
using pll = pair<ll, ll>;

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

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

constexpr ll INF = 0x3f3f3f3f3f3f3f3fLL;
constexpr ll mod = 1000000007;

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

int main() {
    ll K;
    cin >> K;
    ll ans = 0;
    for (int i = 1; i <= K; ++i) {
        for (int j = 1; j <= K; ++j) {
            ll tmp = GCD(i, j);
            if (tmp == 1) {
                ans += K;
            } else {
                for (int l = 1; l <= K; ++l) {
                    ans += GCD(tmp, l);
                }
            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3608
# -*- coding: utf-8 -*-
"""
Created on Sun Jul  5 21:45:44 2020

@author: NEC-PCuser
"""
import heapq

N = int(input())

a = list(map(int, input().split()))
a.sort(reverse=True)
ans = 0
b = [-a[0]]
heapq.heapify(b)
for i in range(1, N):
    ans -= heapq.heappop(b)
    heapq.heappush(b, -a[i])
    heapq.heappush(b, -a[i])
    
print(ans)

Measured memory_bytes: 31532
# -*- coding: utf-8 -*-
import sys
sys.setrecursionlimit(200000)
input = sys.stdin.readline
def ii(): return int(input())
def mi(): return map(int, input().rstrip().split())
def lmi(): return list(map(int, input().rstrip().split()))
def fi(): return float(input())
def mfi(): return map(float, input().rstrip().split())
def lmfi(): return list(map(float, input().rstrip().split()))
def li(): return list(input().rstrip())
def debug(*args, sep=" ", end="\n"): print("debug:", *args, file=sys.stderr, sep=sep, end=end) if not __debug__ else None
def exit(*arg): print(*arg); sys.exit()
# template


def main():
    color = [-1] * 3
    n = ii()
    A = lmi()
    num = [0] * (max(A) + 10)
    ans = 1
    num[0] = 3
    for i in range(n):
        num[A[i] + 1] += 1
        ans *= num[A[i]]
        num[A[i]] -= 1
        ans %= 1000000007
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 53868
#include<bits/stdc++.h>
using namespace std;
#define ALL(x) x.begin(),x.end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define debug(v) cout<<#v<<":";for(auto x:v){cout<<x<<' ';}cout<<endl;
#define mod 1000000007
using ll=long long;
const int INF=1000000000;
const ll LINF=1001002003004005006ll;
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};
// ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return true;}return false;}
template<class T>bool chmin(T &a,const T &b){if(b<a){a=b;return true;}return false;}

struct IOSetup{
    IOSetup(){
        cin.tie(0);
        ios::sync_with_stdio(0);
        cout<<fixed<<setprecision(12);
    }
} iosetup;

template<typename T1,typename T2>
ostream &operator<<(ostream &os,const pair<T1,T2>&p){
    os<<p.first<<" "<<p.second;
    return os;
}

template<typename T>
ostream &operator<<(ostream &os,const vector<T>&v){
    for(int i=0;i<(int)v.size();i++) os<<v[i]<<(i+1==v.size()?"":" ");
    return os;
}

int a[2010][2010],b[2010][2010],c[2010][2010];

signed main(){
    int h,w,q;cin>>h>>w>>q;
    string s[h];
    rep(i,h) cin>>s[i];
    
    rep(i,h)rep(j,w) a[i+1][j+1]=a[i+1][j]+a[i][j+1]-a[i][j]+(int)(s[i][j]=='1');
    rep(i,h)rep(j,w) if(i) b[i+1][j+1]=b[i+1][j]+b[i][j+1]-b[i][j]+(int)(s[i][j]=='1' and s[i-1][j]=='1');
    rep(i,h)rep(j,w) if(j) c[i+1][j+1]=c[i+1][j]+c[i][j+1]-c[i][j]+(int)(s[i][j]=='1' and s[i][j-1]=='1');

    while(q--){
        int d,e,f,g;cin>>d>>e>>f>>g;d--,e--,f--,g--;
        int E=b[f+1][g+1]+b[d+1][e]-b[f+1][e]-b[d+1][g+1]+c[f+1][g+1]+c[d][e+1]-c[f+1][e+1]-c[d][g+1];
        int V=a[f+1][g+1]+a[d][e]-a[f+1][e]-a[d][g+1];
        cout<<V-E<<endl;
    }

    return 0;
}


Measured memory_bytes: 54824
#include<bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i=(a);i<=(b);++i)
#define rrep(i,a,b) for(int i=(a);i>=(b);--i)
#define PB push_back
#define ar2 array<int,2>
typedef long long LL;
const LL P = 1e9+7;
const int INF = 0x3fffffff;
const int N = 25;
mt19937 rng(time(0));

int x,y,ans;

int calc(int x){
	if(x==1) return 300000;
	if(x==2) return 200000;
	if(x==3) return 100000;
	return 0;
}

int main(){
	#ifndef ONLINE_JUDGE
	//freopen("test.in","r",stdin);
	#endif
	cin>>x>>y;
	ans = calc(x) + calc(y);
	if(x==1 && y==1) ans += 400000;
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<unordered_map>
#include<unordered_set>
#include<queue>
#include<algorithm>
using namespace std;
const int N=100005;
int f[N];
int getf(int x)
{
	return f[x]==x?x:f[x]=getf(f[x]);
}
struct myhash
{
	static const size_t B=1e9+7,MOD=1e9+9;
	size_t operator()(const pair<int,int>& pr)const
	{
		return (pr.first*B+pr.second)%MOD;
	}
};
unordered_set<int> mat[N];
int main()
{
	ios::sync_with_stdio(false);
	int n;
	cin>>n;
	unordered_map<pair<int,int>,int,myhash> occur;
	queue<pair<int,int> > Q;
	for(int i=1;i<=n*2-2;i++)
	{
		int u,v;
		cin>>u>>v;
		mat[u].insert(v);
		mat[v].insert(u);
		if(u>v)
			swap(u,v);
		if(++occur[make_pair(u,v)]==2)
			Q.push(make_pair(u,v));
	}
	for(int i=1;i<=n;i++)
		f[i]=i;
	while(!Q.empty())
	{
		int u=getf(Q.front().first),v=getf(Q.front().second);
		Q.pop();
		mat[u].erase(v);mat[v].erase(u);
		if(mat[u].size()<mat[v].size())
			swap(u,v);
		for(int x:mat[v])
		{
			if(x>v)
				occur[make_pair(v,x)]=0;
			else
				occur[make_pair(x,v)]=0;
			mat[x].erase(v);
			mat[x].insert(u);
			if(x>u)
			{
				if(++occur[make_pair(u,x)]==2)
					Q.push(make_pair(u,x));
			}
			else
			{
				if(++occur[make_pair(x,u)]==2)
					Q.push(make_pair(x,u));
			}
			mat[u].insert(x);
		}
		f[v]=u;
		mat[v].clear();
	}
	int cnt=0;
	for(int i=1;i<=n;i++)
		cnt+=getf(i)==i;
	if(cnt==1)
		cout<<"YES\n";
	else
		cout<<"NO\n";
	return 0;
}

Measured memory_bytes: 42952
import sys
stdin = sys.stdin

sys.setrecursionlimit(10 ** 7)

def li(): return map(int, stdin.readline().split())
def li_(): return map(lambda x: int(x) - 1, stdin.readline().split())
def lf(): return map(float, stdin.readline().split())
def ls(): return stdin.readline().split()
def ns(): return stdin.readline().rstrip()
def lc(): return list(ns())
def ni(): return int(stdin.readline())
def nf(): return float(stdin.readline())


def dfs(graph: list, node: int, start: int) -> list:
    # 未探索のノードは距離INF
    INF = float("inf")
    dist = [INF] * node

    # 始点ノードの距離を0とし、dfsのためのstackを作成
    dist[start] = 0
    stack = [(0, start)]

    while stack:
        cost, cur_node = stack.pop()

        # 未探索のノードをstackに入れる
        for nex_cost, nex_node in graph[cur_node]:
            if dist[nex_node] != INF:
                continue
            else:
                dist[nex_node] = dist[cur_node] + nex_cost
                stack.append((dist[nex_node], nex_node))

    return dist

def judge(graph, edges):
    node = len(graph)
    start = 0

    dist = dfs(graph, len(graph), 0)

    for i, j in edges:
        if abs(dist[i]-dist[j])%2 == 0:
            return False

    return True

import numpy as np

n = ni()
grid = [lc() for _ in range(n)]
graph = [[] for _ in range(n)]
numgraph = np.zeros((n, n))
edges = []
for row, si in enumerate(grid):
    for col, sij in enumerate(si):
        if sij == "1":
            edges.append((row, col))
            graph[row].append((1, col))
            numgraph[row][col] = 1

# 二部グラフ判定
is_nibu = judge(graph, edges)

if is_nibu:
    from scipy.sparse.csgraph import floyd_warshall
    dists = floyd_warshall(numgraph)
    ans = 0
    for i in range(n):
        ans = max(ans, max(dists[i,:]))

    print(int(ans) + 1)

else:
    print(-1)


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

typedef long long ll;
const int INF = 1e9 + 5;


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


vector<int> sieve(int n) {
	vector<int> primes;
	vector<bool> v(n + 1);

	for (int i = 2; i <= n; i++) {
		if (v[i]) continue;
		primes.push_back(i);
		for (int j = i * i; j <= n; j+=i) {
			v[j] = true;
		}
	}
	return primes;
}

int prime_divisor(int a, int b, vector<int> &primes) {
	for (int i = 0; i < primes.size(); i++) {
		if (a % primes[i] == 0 && b % primes[i] == 0) return primes[i];
	}
}

int main() {
	ios_base::sync_with_stdio(false);
	ll n;
	cin >> n;
	vector<ll> a(5);
	for (int i = 0; i < 5; i++) {
		cin >> a[i];
	}
	cout << 4 + max((long long)ceil((double)n / (*min_element(a.begin(), a.end()))), 1LL);
	
}


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

using namespace std;
const int maxn=2e5+5;
int dp[3][3000];
char str[maxn];
int main()
{
    scanf("%s", str);
    int i, j, mod=0, x, n=strlen(str);
    long long ans=0;
    for(i=0; i<n; i++)
    {
        x=str[i]-'0';
        for(j=0; j<=2019; j++)
        {
            dp[1][(j*10+x)%2019]+=dp[0][j];
        }
        dp[1][x]++;
        for(j=0; j<=2019; j++)
        {
            dp[0][j]=dp[1][j];
            dp[1][j]=0;
//            if(dp[0][j]!=0)
//            {
//                printf("%d %d %d\n", i, j, dp[0][j]);
//            }
        }
        ans+=dp[0][0];
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 3836
# -*- coding: utf-8 -*-
N = int(input())
A = [int(n) for n in input().split()]

x2 = sum([a%2!=0 for a in A])
o2x4 = sum([(a%2==0)&(a%4!=0) for a in A])
o4 = sum([a%4==0 for a in A])


if o2x4 == 0:
    if o4 + 1 >= x2:
        print("Yes")
    else:
        print("No")
else:
    if o4 >= x2:
        print("Yes")
    else:
        print("No")

Measured memory_bytes: 14252
#include <iostream>
#include <fstream>
#include <vector>
#include <algorithm>
#define REP(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;

int main()
{
    ll a, b, k;
    cin >> a;
    cin >> b;
    cin >> k;

    ll aa = 0, bb = 0;

    aa = a - k;
    if (aa < 0)
        aa = 0;

    k = k - a;
    if (k < 0)
        k = 0;

    b = b - k;
    if (b < 0)
        b = 0;

    cout << aa << " " << b << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define lvector vector<ll>
#define cvector vector<char>
#define svector vector<string>
#define lque queue<ll>
#define lpque priority_queue<ll>
#define dlpque priority_queue<ll,lvector,greater<ll>>
#define P pair<ll,ll>
#define ALL(a) a.begin(),a.end()
#define RALL(a) a.rbegin(),a.rend()
#define rep(i,n) for(ll i=0; i<n; ++i)
#define print(a) cout << (a) << endl

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll n,m,ans=0,a,b,prev;cin>>n>>m;
  vector<lvector> G(n);
  rep(i,m) {
    cin>>a>>b;a--,b--;
    G[a].emplace_back(b),G[b].emplace_back(a);
  }
  lvector v;rep(i,n-1) v.emplace_back(i+1);
  bool isok;
  do {
    isok=true;
    prev=0;
    for(ll i:v) {
      if(find(ALL(G[prev]),i)!=G[prev].end()) prev=i;
      else {isok=false;break;}
    }
    if(isok) ans++;
  } while(next_permutation(ALL(v)));
  print(ans);
  return 0;
}

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

vector<int> v;

int dp(int p, int n){
    if(p == v.size() && n <= 21) return n;
    else if(21 < n) return 0;
    else {
        if(v[p] == 1){
            return max(dp(p+1, n+1), dp(p+1, n+11));
        }
        else return dp(p+1, n+v[p]);
    }
}

int main(){
    string input;
    while(getline(cin, input), input != "0"){
        int n;
        v.clear();
        while(input.find_first_of(" ") != string::npos){
            n = atoi(input.substr(0, input.find_first_of(" ")).c_str());
            if(n/10 == 1) n = n-n%10;
            v.push_back(n);
            input = input.substr(input.find_first_of(" ")+1);
        }
        n = atoi(input.c_str());
        if(n/10 == 1) n = n-n%10;
        v.push_back(n);

        cout << dp(0, 0) << endl;
    }
}

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

int main( void )
{
  int N;
  cin >> N;
  vector<int> A( N );

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

  int ans = 0;
  while( 1 ) {
    for( int i = 0; i < N; i++ ) {
      if( A.at( i ) % 2 == 0 )
	count++;
    }
    
    if( count == N ) {
      for( int i = 0; i < N; i++ ) {
	A.at( i ) /= 2;
      }
	ans++;
      }
    else
      break;
    
    count = 0;
 
  }
  cout << ans << endl;
}


Measured memory_bytes: 3612
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int x = sc.nextInt();
		int y = sc.nextInt();
		if (y % 2 == 1) {
			System.out.println("No");
			return;
		}
		// 2x <= y <= 4x
		if (y >= 2 * x && y <= 4 * x) {
			System.out.println("Yes");
			return;
		}
		System.out.println("No");
	}
}








Measured memory_bytes: 35780
#include <bits/stdc++.h>
using namespace std;
#define GET_MACRO(_1, _2, _3, NAME, ...) NAME
#define _repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define _rep(i,n) _repl(i,0,n)
#define rep(...) GET_MACRO(__VA_ARGS__, _repl, _rep)(__VA_ARGS__)
#define mp(a,b) make_pair((a),(b))
#define pb(a) push_back((a))
#define all(x) (x).begin(),(x).end()
#define uniq(x) sort(all(x)),(x).erase(unique(all(x)),end(x))
#define fi first
#define se second
#define dbg(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
void _dbg(string){cout<<endl;}
template<class H,class... T> void _dbg(string s,H h,T... t){int l=s.find(',');cout<<s.substr(0,l)<<" = "<<h<<", ";_dbg(s.substr(l+1),t...);}
template<class T,class U> ostream& operator<<(ostream &o, const pair<T,U> &p){o<<"("<<p.fi<<","<<p.se<<")";return o;}
template<class T> ostream& operator<<(ostream &o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}


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

  while(s.size()>3){
    int i = 0;
    int n = s.size();
    string t;
    set<char> skip;
    while(i<n){
      while(i<n && s.substr(i,3) != "ABC"){
        skip.insert(s[i]);
        t.pb(s[i]);
        i++;
      }
      if(i<n){
        t.pb('X');
        i += 3;
      }
    }
    s.clear();
    if(skip.size()!=2){
      break;
    }
    char rp;
    rep(j,3) if(skip.count('A'+j)==0) rp = j+'A';
    for(char c : t){
      if(c=='X') s.pb(rp);
      else s.pb(c);
    }
  }

  if(s=="ABC") cout << "Yes" << endl;
  else cout << "No" << endl;

  return 0;
}

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

// # DEFINES # //
#define ll long long
#define M (ll)1e9+7
#define EPS 1e-9

using namespace std;


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

    ll p, q, r;

    cin >> p >> q >> r;

    cout << min(min(p+q, p+q), min(q+r, p+r)) << endl;


    return 0;
}

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

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

    int n;
    cin >> n;
    vector<int> A(n), B(n), C(n);
    REP(i, n) cin >> A[i];
    REP(i, n) cin >> B[i];
    REP(i, n) cin >> C[i];

    sort(A.begin(), A.end());
    sort(B.begin(), B.end());
    sort(C.begin(), C.end());
    
    long long ans = 0;
    REP(i, n){
        long long tmp = 0;
        tmp = lower_bound(A.begin(), A.end(), B[i]) - A.begin();
        tmp *= n - (upper_bound(C.begin(), C.end(), B[i]) - C.begin());
        ans += tmp;
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 1408
#include<bits/stdc++.h>
using namespace std;
int N,M,K;
int UD[200];
int x[200],l[200],f[200],d[200];
double X[200],L[200],F[200],D[200];
double V[200],t[200];

int id[2000];
map<int,double> s[200];

int main(){
  while(1){

    for(int i=0;i<200;i++)s[i].clear();
    for(int i=0;i<2000;i++)id[i]=-1;

    cin>>N>>M>>K;
    if(N==0&&M==0&&K==0)break;
 
    for(int i=0;i<N;i++){
      cin>>x[i]>>l[i]>>f[i]>>d[i]>>UD[i];
      X[i]=x[i],L[i]=l[i],F[i]=f[i],D[i]=d[i];
      id[x[i]]=i;
    } 

    for(int i=0;i<M;i++)cin>>V[i];
 
    for(int i=0;i<N;i++){
      t[i]=0;
      if(UD[i]==1){
        t[i]=L[i]/F[i];
        swap(F[i],D[i]);
      }
    }
 

    for(int j=1;j<=K+M-1;j++){
      s[0][j]=s[0][j-1]+1.0/V[0];
      if(id[j-1]==-1)continue;
      int k=id[j-1];

      if(s[0][j-1]<t[k]){
	s[0][j]=t[k]+L[k]/F[k]+1.0/V[0];
	t[k]=t[k]+L[k]/F[k]+L[k]/D[k];
      }else{
	s[0][j]=s[0][j-1]+L[k]/F[k]+1.0/V[0];
	t[k]=s[0][j-1]+L[k]/F[k]+L[k]/D[k];
      }
    }

    
    for(int i=1;i<M;i++){
      double v=1.0/V[i];
      for(int j=-i+1;j<=-i+K+M-1;j++){
	s[i][j]=max(s[i][j-1]+v,s[i-1][j+1]);
	if(j-1<0||id[j-1]==-1)continue;
	int k=id[j-1];
	if(s[i][j-1]<t[k]){
	  s[i][j]=max(s[i][j],t[k]+L[k]/F[k]+v);
	  t[k]=t[k]+L[k]/F[k]+L[k]/D[k];
	}else{
	  s[i][j]=max(s[i][j],s[i][j-1]+L[k]/F[k]+v);
	  t[k]=s[i][j-1]+L[k]/F[k]+L[k]/D[k];
	}
      }
    }
 
    printf("%.10f\n",s[M-1][K]);
  }
  return 0;

}

Measured memory_bytes: 8152
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int a,b;
    cin>>a>>b;
    int ans=0;
    if(a>b)
    {
        ans+=a;
        a-=1;
    }
    else
    {
        ans+=b;
        b-=1;
    }
    ans+=max(a,b);
    cout<<ans;
}



Measured memory_bytes: 3572
#include "bits/stdc++.h"

using namespace std;

//int N,M,K,L,R,H,W;
long long int N,M,K,L,R,H,W;

constexpr long long int MOD=1000000007;
//constexpr  int MOD=1000000007;
//constexpr int MOD=998244353;
//constexpr long long int MOD=998244353;

constexpr long double EPS=1e-8;

long long int power(long long int x, long long int n, long long int M) {
	long long int ret = 1;
	long long int by = x;
	while (n) {
		if (n & 1) {
			ret *= by;
			ret %= M;
		}
		by *= by;
		by %= M;
		n >>= 1;
	}
	return ret;
}

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	
	cin>>W>>H;
	int sum=W+H;
	if(sum%3){
		cout<<0<<endl;
		return 0;
	}
	W-=sum/3;
	H-=sum/3;
	if(W<0||H<0){
		cout<<0<<endl;
		return 0;
	}
	vector<long long int>by(1000001,1);
	vector<long long int>rev(1000001,1);
	for(int i=2;i<=1000000;i++){
		by[i]=by[i-1]*i;
		by[i]%=MOD;
		rev[i]=power(by[i],MOD-2,MOD);
	}
	long long int ans=by[sum/3];
	ans*=rev[H];
	ans%=MOD;
	ans*=rev[W];
	ans%=MOD;
	cout<<ans<<endl;
}

Measured memory_bytes: 15872
#include<cstdio>
#include<iostream>
#include<string>
#include<set>
#include<map>
#include<vector>
#include<queue>
#include<stack>
#include<deque>
#include<tuple>
#include<algorithm>
#include<numeric>
#include<limits>
#include<boost/multiprecision/cpp_int.hpp>
using namespace boost::multiprecision;
using namespace std;
#define BEGIN ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define END return EXIT_SUCCESS
#define up(I,A,B) for(auto I=(A);I<=(B);++I)
#define dw(I,A,B) for(auto I=(A);I>=(B);--I)
#define rep(I,N) up(I,0,N-1)
#define all(C) (C).begin(),(C).end()
#define rall(C) (C).rbegin(),(C).rend()
#define ft first
#define sd second
#define mp make_pair
#define mt make_tuple
#define pf push_front
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define rs resize
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
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;}
template<class T>inline void                                      in(T &p){cin>>p;}
template<class T1,class T2>inline void                            in(T1 &p1,T2 &p2){cin>>p1>>p2;}
template<class T1,class T2,class T3>inline void                   in(T1 &p1,T2 &p2,T3 &p3){cin>>p1>>p2>>p3;}
template<class T1,class T2,class T3,class T4>inline void          in(T1 &p1,T2 &p2,T3 &p3,T4 &p4){cin>>p1>>p2>>p3>>p4;}
template<class T1,class T2,class T3,class T4,class T5>inline void in(T1 &p1,T2 &p2,T3 &p3,T4 &p4,T5 &p5){cin>>p1>>p2>>p3>>p4>>p5;}
template<class T>inline void                                      ins(T &p){for_each(all(p),in<decltype(p[0])>);}
template<class T>inline void                             out(T p){cout<<p<<"\n";}
template<class T1,class T2>inline void                   out(T1 p1,T2 p2){cout<<p1<<" "<<p2<<"\n";}
template<class T1,class T2,class T3>inline void          out(T1 p1,T2 p2,T3 p3){cout<<p1<<" "<<p2<<" "<<p3<<"\n";}
template<class T1,class T2,class T3,class T4>inline void out(T1 p1,T2 p2,T3 p3,T4 p4){cout<<p1<<" "<<p2<<" "<<p3<<" "<<p4<<"\n";}
inline void                                              out(ld p){printf("%.12Lf\n",p);}
template<class T>inline void outml(T p){for_each(all(p),out<decltype(p[0])>);}//ml=multi line
template<class T>inline void outol(T V){auto n=V.size();rep(i,n)cout<<V[i]<<" \n"[i==n-1];}//ol=one line
inline void solve(void){
  ll X;
  in(X);
  for(ll i=1;i*i<=X;i++){
    if(X%i==0){
      for(ll b=-1000;b<=1000;b++){
        ll a=b+i;
        if(a*a*a*a+a*a*a*b+a*a*b*b+a*b*b*b+b*b*b*b==X/i){
          out(a,b);
          return;
        }
      }
    }
  }
}
int main(void){
  BEGIN;
  solve();
  END;
}


Measured memory_bytes: 3648
#include "bits/stdc++.h"

using namespace std;

#define ll long long
#define vi  vector<int>
#define vvi vector<vi>
#define pi  pair<int,int>
#define mp  make_pair
#define pb  push_back
#define MOD 1e9 + 7
#define PAI  3.1415
#define all(x) (x).begin(),(x).end()
#define chmax(x,y) x = max(x,y)
#define chmin(x,y) x = min(x,y)
#define pr(x) cout << x << endl
#define Endl endl
#define rep(i,n) for(int i = 0 ; i < n; i++)

const int dx[4] = {1,0,-1,0};
const int dy[4] = {0,1,0,-1};
const int ddx[8] = {-1,0,1,-1,1,-1,0,1};
const int ddy[8] = {-1,-1,-1,0,0,1,1,1};
const int inf = 99999999;
const ll linf = 1LL << 62;

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

ll lcm(ll a,ll b){
  if(a < b)swap(a , b);
  return (a/gcd(a , b))*b;
}

struct UnionFind {
  vi par; //par[i] : iの親番号（例）par[3] = 2 : 3の親は2

  UnionFind(int N) : par(N) { //最初は全てが根として初期化
    rep(i,N) par[i] = i;
  }

  int root(int x){ //データxが属する木の根を再帰で得る : root(x) = {xの木の根}
    if(par[x] == x)return x;
    return par[x] = root(par[x]);
  }

  void unite(int x, int y){ //xとyの木を併合
    int rx = root(x); //xの根をrx
    int ry = root(y); //yの根をry
    if(rx == ry)return; //xとyの根が同じ
    par[rx] = ry; //xとyの根が同じでない時、xの根rxをyの根にryにつける。
  }

  bool same(int x, int y){//2つのデータx，yが属する木が同じならtrueを返す
    int rx = root(x);
    int ry = root(y);
    return rx == ry;
  }
};


int main(){

  string s; cin >> s;

  int ans = 0;
  rep(i,s.length()){
    if(s[i] == '-')ans--;
    else ans ++;
  }

  cout << ans << endl;

  return 0;

}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <vector>
using namespace std;
const long long INF = 1LL << 60;    // 1.15x10^18

int main() {
    int n; cin >> n;
    vector<int> a(n);
    for (auto &ai: a) cin >> ai;
    vector<long long> acc(n + 1);
    for (int i = 0; i < n; i++) acc[i + 1] = acc[i] + a[i];
    long long mi = INF;
    int left = 0, right = 2;
    for (int mid = 1; mid < n - 1; mid++) {
        auto check = [&](int l, int m, int r) {
            long long dif1 = (acc[m] - acc[l]) - (acc[r] - acc[m]);
            m++;
            long long dif2 = (acc[m] - acc[l]) - (acc[r] - acc[m]);
            return abs(dif1) > abs(dif2);
        };
        while (check(0, left, mid)) left++;
        while (check(mid, right, n)) right++;
        long long p = acc[left] - acc[0], q = acc[mid] - acc[left];
        long long r = acc[right] - acc[mid], s = acc[n] - acc[right];
        mi = min(mi, max({p, q, r, s}) - min({p, q, r, s}));
    }
    cout << mi << endl;
    return 0;
}


Measured memory_bytes: 2560
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
using namespace std;
typedef long long ll;
struct UF{
    int par[100000];
    int rank[100000];
    int g[100000];
    void init(int n){
        for(int i=0;i<n;i++){
            par[i]=i;
            rank[i]=0;
            g[i]=1;
        }
    }
    int find(int x){
        if(par[x]==x)return x;
        return par[x]=find(par[x]);
    }
    void unite(int x, int y){
        x=find(x);
        y=find(y);
        if(x!=y){
            if(rank[x]<rank[y]){
                par[x]=y;
                g[y]+=g[x];
                g[x]=0;
            }else{
                par[y]=x;
                if(rank[x]==rank[y])rank[x]++;
                g[x]+=g[y];
                g[y]=0;
            }
        }
    }
    bool same(int x, int y){
        return find(x)==find(y);
    }
};

int main(void){
    int n,m,r;
    ll a[100000],b=0;
    UF u;
    map<int, vector<int> > v;
    vector<int> w;
    cin>>n>>m;
    u.init(n);
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    for(int i=0;i<m;i++){
        int x,y;
        cin>>x>>y;
        u.unite(x, y);
    }
    for(int i=0;i<n;i++){
        int p=u.find(i);
        v[p].push_back(a[i]);
    }
    int s=v.size();//n-m
    if(s*2-2>n){
        cout << "Impossible" << endl;
        return 0;
    }else if(s==1){
        cout<<0<<endl;
        return 0;
    }

    for(auto x=v.begin();x!=v.end();x++){
        vector<int> y=x->second;
        sort(y.begin(), y.end());
        b+=y[0];
        for(int i=1;i<y.size();i++){
            w.push_back(y[i]);
        }
    }
    sort(w.begin(), w.end());
    for(int i=0;i<s-2;i++){
        b+=w[i];
    }

    cout << b << endl;


}


Measured memory_bytes: 13184
#include <iostream>

using namespace std;

int main() {
	int n; cin >> n;
	int ans = 0;
	for (int i = 1; i <= n; ++i) {
		int a; cin >> a;
		if (i & a & 1) ++ans;
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 3616
#include <cstdio>
#include <cctype>
#include <cstring>
#include <algorithm>
#include <vector>
#include <queue>

#define debug(...) fprintf(stderr, __VA_ARGS__)

#ifndef AT_HOME
#define getchar() IO::myGetchar()
#define putchar(x) IO::myPutchar(x)
#endif

namespace IO {
	static const int IN_BUF = 1 << 23, OUT_BUF = 1 << 23;

	inline char myGetchar() {
		static char buf[IN_BUF], *ps = buf, *pt = buf;
		if (ps == pt) {
			ps = buf, pt = buf + fread(buf, 1, IN_BUF, stdin);
		}
		return ps == pt ? EOF : *ps++;
	}

	template<typename T>
	inline bool read(T &x) {
		bool op = 0;
		char ch = getchar();
		x = 0;
		for (; !isdigit(ch) && ch != EOF; ch = getchar()) {
			op ^= (ch == '-');
		}
		if (ch == EOF) {
			return false;
		}
		for (; isdigit(ch); ch = getchar()) {
			x = x * 10 + (ch ^ '0');
		}
		if (op) {
			x = -x;
		}
		return true;
	}

	inline int readStr(char *s) {
		int n = 0;
		char ch = getchar();
		for (; isspace(ch) && ch != EOF; ch = getchar())
			;
		for (; !isspace(ch) && ch != EOF; ch = getchar()) {
			s[n++] = ch;
		}
		s[n] = '\0';
		return n;
	}

	inline void myPutchar(char x) {
		static char pbuf[OUT_BUF], *pp = pbuf;
		struct _flusher {
			~_flusher() {
				fwrite(pbuf, 1, pp - pbuf, stdout);
			}
		};
		static _flusher outputFlusher;
		if (pp == pbuf + OUT_BUF) {
			fwrite(pbuf, 1, OUT_BUF, stdout);
			pp = pbuf;
		}
		*pp++ = x;
	}

	template<typename T>
	inline void print_(T x) {
		if (x == 0) {
			putchar('0');
			return;
		}
		std::vector<int> num;
		if (x < 0) {
			putchar('-');
			x = -x;
		}
		for (; x; x /= 10) {
			num.push_back(x % 10);
		}
		while (!num.empty()) {
			putchar(num.back() ^ '0');
			num.pop_back();
		}
	}

	template<typename T>
	inline void print(T x, char ch = '\n') {
		print_(x);
		putchar(ch);
	}

	inline void printStr_(const char *s, int n = -1) {
		if (n == -1) {
			n = strlen(s);
		}
		for (int i = 0; i < n; ++i) {
			putchar(s[i]);
		}
	}

	inline void printStr(const char *s, int n = -1, char ch = '\n') {
		printStr_(s, n);
		putchar(ch);
	}
}
using namespace IO;

const int N = 100005;

int n, m, a[N], fa[N], cnt[N], vis[N];

int find(int x) {
	return fa[x] == x ? x : (fa[x] = find(fa[x]));
}

bool merge(int x, int y) {
	x = find(x), y = find(y);
	if (x == y) {
		return false;
	}
	fa[y] = x;
	return true;
}

int main() {
	read(n), read(m);
	for (int i = 0; i < n; ++i) {
		read(a[i]);
		fa[i] = i;
	}
	for (int i = 0; i < m; ++i) {
		int u, v;
		read(u), read(v);
		merge(u, v);
	}
	if (m == n - 1) {
		print(0);
		return 0;
	}
	std::vector<std::pair<int, int>> A;
	for (int i = 0; i < n; ++i) {
		A.push_back({a[i], i});
	}
	std::sort(A.begin(), A.end());
	int sum = 2 * (n - m - 1);
	long long ans = 0;
	for (int i = 0; i < n; ++i) {
		int x = find(A[i].second);
		if (cnt[x] == 1) {
			continue;
		}
		++cnt[x], --sum, ans += A[i].first;
		vis[i] = 1;
	}
	for (int i = 0; i < n && sum; ++i) {
		int x = find(A[i].second);
		if (vis[i] || cnt[x] == n - m - 1) {
			continue;
		}
		++cnt[x], --sum, ans += A[i].first;
	}
	if (sum) {
		printStr("Impossible");
		return 0;
	}
	print(ans);
}


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

typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,int> plli;
typedef pair<int,pii> pipii;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<pii> vpii;

#define rep(i,n) for (int i=0;i<(n);i++)
#define rep2(i,a,b) for (int i=(a);i<(b);i++)
#define rrep(i,n) for (int i=(n);i>0;i--)
#define rrep2(i,a,b) for (int i=(a);i>b;i--)
#define pb push_back
#define fi first
#define se second
#define all(a) (a).begin(),(a).end()

const ll mod = 1e9 + 7;
const ll INF = 1<<30;
const int dx4[4] = {1, 0, -1, 0};
const int dy4[4] = {0, 1, 0, -1};
const int dx8[8] = {1, 1, 1, 0, 0, -1, -1, -1};
const int dy8[8] = {0, 1, -1, 1, -1, 0, 1, -1};
const double pi = 3.141592653589793;

int a, b;
int card_a[5005], card_b[5005];

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> a >> b;
    rep(i, a) cin >> card_a[i];
    rep(i, b) cin >> card_b[i];
    int ans = 0;
    rep(i, b) {
        int now_b = i;
        int len = 0;
        rep(j, a) {
            if (card_b[now_b] == card_a[j]) {
                now_b++;
                len++;
            }
            if (now_b == b) break;
        }
        ans = max(ans, len);
    }
    cout << ans << endl;
}

Measured memory_bytes: 3284
#include <iostream>
#include <iomanip>
#include <vector>
#include <string>

#include <algorithm>
#include <numeric>
#include <math.h>

using namespace std;
#define rep(i,n) REP(i,0,n)
#define REP(i,x,n) for(int i=x;i<n;++i)
#define ll long long

///////////////////////////////////////////////////
// ------------------- utils ------------------- //
///////////////////////////////////////////////////
// change min/max
template<class T> inline bool chMin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chMax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

void Main() {
    int A, B; cin >> A >> B;
    int res;
    if      (A >= 13) res = B;
    else if (A >= 6)  res = B/2;
    else  res = 0;
    cout << res << endl;
}

int main() {
    std::ios::sync_with_stdio(false);
    std::cin.tie(0);
    std::cout << std::fixed << std::setprecision(15);
    Main();

    return 0;
}


Measured memory_bytes: 256