akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

// region template
#define rep(i, a, b) for (int i = (a); i < (b); ++i)
#define trav(a, x) for (auto &a : x)
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef vector<int> vi;

ll gcd(ll a, ll b) { return __gcd(a, b); }

ll euclid(ll a, ll b, ll &x, ll &y) {
    if (b) { ll d = euclid(b, a % b, y, x);
        return y -= a/b * x, d; }
    return x = 1, y = 0, a;
}

typedef unsigned long long ull;
typedef long double ld;
ull mod_mul(ull a, ull b, ull M) {
    ll ret = a * b - M * ull(ld(a) * ld(b) / ld(M));
    return ret + M * (ret < 0) - M * (ret >= (ll)M);
}
ull mod_pow(ull b, ull e, ull mod) {
    ull ans = 1;
    for (; e; b = mod_mul(b, b, mod), e /= 2)
        if (e & 1) ans = mod_mul(ans, b, mod);
    return ans;
}

const ll mod = 1000000007;
struct Mod {
    ll x;
    Mod(ll xx) : x(xx) {}
    Mod operator+(Mod b) { return Mod((x + b.x) % mod); }
    Mod operator-(Mod b) { return Mod((x - b.x) % mod); }
    Mod operator*(Mod b) { return Mod((x * b.x) % mod); }
    Mod operator/(Mod b) { return *this * invert(b); }
    Mod invert(Mod a) {
        ll x, y, g = euclid(a.x, mod, x, y);
        assert(g == 1); return Mod((x + mod) % mod);
    }
    Mod operator^(ll e) {
        if (!e) return Mod(1);
        Mod r = *this ^ (e / 2); r = r * r;
        return e & 1 ? *this * r : r;
    }
};
// endregion

struct th {
    int a, b, c;
    const bool operator<(const th& t) const {
        return a != t.a ? a < t.a : b != t.b ? b < t.b : c < t.c;
    }
};

int main() {
    cin.sync_with_stdio(0); cin.tie(0); cin.exceptions(cin.failbit);

    while (true) {
        int n, m, a; cin >> n >> m >> a;
        if (!n) break;
        vector<th> v(m);
        rep(i, 0, m) cin >> v[i].a >> v[i].b >> v[i].c;
        sort(all(v));
        vector<int> st(n + 1);
        rep(i, 1, n + 1) st[i] = i;
        rep(i, 0, m) swap(st[v[i].b], st[v[i].c]);
        cout << st[a] << endl;
    }
}


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

using ll = long long;

int main() {
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	int N; cin >> N;
	vector<ll> A(N);
	for (ll& a : A) cin >> a;

	ll xorSum = 0;
	ll addSum = 0;
	ll ans = 0;
	for (int i = 0, j = 0; i < N; i++) {
		while (j < N && (xorSum ^ A[j]) == (addSum + A[j])) {
			xorSum ^= A[j];
			addSum += A[j];
			j++;
		}
		ans += j - i;
		xorSum ^= A[i];
		addSum -= A[i];
	}
	cout << ans << '\n';

	return 0;
}


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

int main() 
{
    ll n, m, k;
    cin >> n >> m >> k;
    vector<ll> a(n), b(m);
    for (int i = 0; i < n; ++i)cin >> a[i];
    for (int i = 0; i < m; ++i)cin >> b[i];
    vector<ll> sumA(n + 1), sumB(m + 1);
    for (int i = 0; i < n; ++i)sumA[i + 1] = sumA[i] + a[i];
    for (int i = 0; i < m; ++i)sumB[i + 1] = sumB[i] + b[i];
	ll ans = 0;
    for (ll i = 0; i <= n; ++i) 
	{
    	
        ll cur = sumA[i];
        ll rest = k - cur;
        if (rest < 0) break;
        ans = max(ans, i + (ll)(upper_bound(sumB.begin(), sumB.end(), rest) - sumB.begin() - 1));
    }
    cout << ans << endl;
}

Measured memory_bytes: 9532
#include <iostream>
#include <vector>
#define rep(i, x) for(int i=0;i<(x);++i)
using namespace std;


int main() {
    vector<vector<int>> c(3, vector<int>(3, 0));
    rep(i, 3)rep(j, 3) cin >> c[i][j];

    for (int i = 0; i <= 100; ++i) {
        for (int j = 0; j <= 100; ++j) {
            for (int k = 0; k <= 100; ++k) {
                int a1 = i;
                int a2 = j;
                int a3 = k;

                if (((c[0][0] - a1 == c[1][0] - a2) && (c[1][0] - a2 == c[2][0] - a3)) &&
                    ((c[0][1] - a1 == c[1][1] - a2) && (c[1][1] - a2 == c[2][1] - a3)) &&
                    ((c[0][2] - a1 == c[1][2] - a2) && (c[1][2] - a2 == c[2][2] - a3))) {
                        cout << "Yes" << endl;
                        return 0;
                   }
            }
        }
    }
    cout << "No" << endl;
}

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

#define int long long int

int32_t main()
{
  int n,m;
  cin>>n>>m;
  int ans=0;
  if(n>=13) ans=m;
  if(n<=12 && n>=6) ans=m/2;
  else if(n<=5) ans=0;

  cout<<ans<<endl;

  return 0;
}

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

int main() {
  int n, c, k;
  cin >> n >> c >> k;
  vector<int> t(n);
  int total = 0;
  int lim = 0;
  int ans = 0;
  for(int i=0;i<n;i++) {
    cin >> t[i];
  }
  sort(t.begin(), t.end());

  for(int i=0;i<n;i++) {
    if(total == 0) {
      lim = t[i] + k;
    }
    if(t[i] > lim) {
      total = 0;
      lim = t[i] + k;
      ans++;
    }

    total++;

    if(total == c) {
      total = 0;
      lim = 0;
      ans++;
    }

    if(i == n-1 && total != 0) ans++;
  }

  cout << ans << endl;
}

Measured memory_bytes: 640
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <deque>
#include <queue>
#include <set>
#include <functional>
#include <cmath>
#include <set>


//マクロ
/*動かない・・・
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define REP(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define _roverload3(_1,_2,_3,name,...) name
#define _rrep(i,n) repi(i,0,n)
#define rrepi(i,a,b) for(int i=int(a);i<int(b);++i)
#define RREP(...) _roverload3(__VA_ARGS__,rrepi,_rrep,)(__VA_ARGS__)
//*/
#define REP(i,n) for(int i=0; i<(int)(n); ++i)
#define REPS(i,n) for(int i=1; i<=(int)(n); ++i)
#define RREP(i,n) for(int i=(int)(n)-1; i>=0; --i)
#define RREPS(i,n) for(int i=(int)(n); i>0; --i)
#define FOR(i,s,e) for(int i=(int)(s); i<(int)(e); ++i)
#define RFOR(i,s,e) for(int i=(int)(e)-1; i>=(int)(s); --i)
//*/
#define All(a) (a).begin(),(a).end()
#define dump(x)  cerr << #x << " = " << (x) << endl;

//定数
#define INF 1e12
#define MOD (int)(1e9+7)

typedef long long ll;
typedef unsigned long long ull;
/*
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;
//*/
using namespace std;
using Graph = vector<vector<int>>;

//とりあえず書いておく変数
int dx[4] = { 1,0,-1,0 };
int dy[4] = { 0,1,0,-1 };

//今回の変数
int n,a;
set<int> s;

//使用する関数
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;
}

ll calc(ll a) {
	if (a == 1)return 1;
	return calc(a / 2) * 2 + 1;
}

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

	cin >> n;
	REP(i, n) {
		cin >> a;
		decltype(s)::iterator it = s.find(a);
		if (it != s.end()) {
			cout << "NO" << endl;
			return 0;
		}
		else {
			s.insert(a);
		}
	}
	cout << "YES" << endl;
}

Measured memory_bytes: 9600
package main

import "fmt"

func main() {
	var n, m int
	fmt.Scanln(&n, &m)
	a := make([][]int, n)
	for i := 0; i < n; i++ {
		a[i] = make([]int, m)
	}
	b := make([]int, m)
	ab := make([]int, n)
	for i := 0; i < n; i++ {
		for j := 0; j < m; j++ {
			fmt.Scan(&a[i][j])
		}
	}
	for i := 0; i < m; i++ {
		fmt.Scan(&b[i])
	}
	for i := 0; i < n; i++ {
		for j := 0; j < m; j++ {
			ab[i] += a[i][j] * b[j]
		}
	}
	for i := 0; i < n; i++ {
		fmt.Println(ab[i])
	}
	return
}



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

int main(){
    int N,M; cin >> N >> M;
    vector<string> A(N), B(M);
    for(int i = 0; i < N; i++) cin >> A[i];
    for(int i = 0; i < M; i++) cin >> B[i];
    
    for(int i = 0; i < N - M + 1; i++){
        for(int j = 0; j < N - M + 1; j++){
            
            bool ok = true;
            for(int a = 0; a < M; a++){
                for(int b = 0; b < M; b++){
                    if(A[i+a][j+b]!=B[a][b])ok = false;
                }
            }
            if(ok){
                cout << "Yes" << endl;
                return 0;
            }
        }
    }
    cout << "No" << endl;
    return 0;
}


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

int main(){


	int n;
	int num;
	int max=0;
	int price=0;
	cin>>n;
	for(int i=0;i<n;i++){
	cin>>num;
	
		if(num>max){
		max=num;
		}
	price+=num;
		
	}
	cout<<(price-max)+max/2<<endl;
}

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

using ll = long long;
using Pi = pair<int, int>;
using Pl = pair<ll, ll>;
using vint = vector<int>;
using vll = vector<ll>;
template<typename T> using uset = unordered_set<T>;
template<typename T1, typename T2> using umap = unordered_map<T1, T2>;

constexpr int INF = (1 << 30) - 1;
constexpr ll LLINF = 1LL << 60;
constexpr int dy[] = {1, 0, -1, 0, 1, -1, -1, 1};
constexpr int dx[] = {0, 1, 0, -1, 1, 1, -1, -1};
constexpr char el = '\n';
constexpr int mod = 1000000007;

template<typename T> T gcd(T a, T b) { return (b ? gcd(b, a % b) : a); }
template<typename T> T lcm(T a, T b) { return (a / gcd(a, b) * b); }
template<typename T1, typename T2> inline void chmin(T1 &a, T2 b) { if (a > b) a = b; }
template<typename T1, typename T2> inline void chmax(T1 &a, T2 b) { if (a < b) a = b; }

int main() {
        int N;
        Pl pp[200005];
        ll maxv = -LLINF;
        ll minv = LLINF;
        ll minr = LLINF;

        multiset<ll>st; 
        cin >> N;
        for (int i = 0; i < N; i++) {
                cin >> pp[i].first >> pp[i].second;
                if (pp[i].first > pp[i].second) swap(pp[i].first, pp[i].second);
                maxv = max(maxv, pp[i].second);
                minv = min(minv, pp[i].first);
                minr = min(minr, pp[i].second);
                st.insert(pp[i].first);
        }

        sort(pp, pp + N);
        ll ans = LLINF;
        for (int i = 0; i < N; i++) {
                st.erase(st.find(pp[i].first));
                st.insert(pp[i].second);
                ans = min(ans, (*st.rbegin() - *st.begin()) * (maxv - minv));
        }
        cout << min(ans, (pp[N - 1].first - pp[0].first) * (maxv - minr)) << endl;
    return (0);
}


Measured memory_bytes: 12800
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define sz(x) (int)x.size();
#define all(x) (x).begin(), (x).end()
#define Red ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define rep(i, n) for(int i =0 ; i < n; ++i)
#define Rep(i,a,b) for(int i=a;i<=b;i++)
#define pii pair < int, int >
typedef vector<int> vi;
typedef  long long ll;
const int inf = int(1e9);
const int mod =1e9+7;
const int N = (int)2e5 + 5;



void solve(){
	int n;
	cin>>n;
	int a[n+1];
	for(int i=1;i<=n;i++)cin>>a[i];
	ll ans=0;
	for(int i=1;i<=n;i++){
		for(int j=i+1;j<=n;j++){
			ans+=a[i]*1LL*a[j]*1LL;
		}
	}
	cout<<ans;
}
int main(){
	Red;
	int t=1;
	//cin>>t;
	while(t--)
	solve();
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <numeric>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <utility>
#include <sstream>
#include <complex>
#include <fstream>
#include <bitset>
#include <time.h>
#include <tuple>

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef complex<double> Point;

#define PI acos(-1.0)
#define EPS 1e-10
const ll INF = (1LL << 60) - 1;
const ll MOD = 1e9 + 7;

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define rep(i,N) for(int i=0;i<(N);i++)
#define ALL(s) (s).begin(),(s).end()
#define EQ(a,b) (abs((a)-(b))<EPS)
#define EQV(a,b) ( EQ((a).real(), (b).real()) && EQ((a).imag(), (b).imag()) )
#define fi first
#define se second
#define N_SIZE (1LL << 20)
#define NIL -1
#define MAX_N 100100 * 3

string s;

int main() {
	cin >> s;
	string t = s;
	reverse(ALL(t));
	if (t == s)cout << "Yes" << endl;
	else cout << "No" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
const int MAX_C = 35;
const int MAX_N = 505;
int D[MAX_C][MAX_C],c[MAX_N][MAX_N],d0[MAX_C],d1[MAX_C],d2[MAX_C];
int ch0[MAX_C],ch1[MAX_C],ch2[MAX_C];

int main()
{
	int N,C;
	cin >> N >> C;
	rep(i,C)
	{
		rep(j,C)
		{
			cin >> D[i+1][j+1];
		}
	}
	rep(i,N)
	{
		rep(j,N)
		{
			cin >> c[i][j];
			if ((i+j) % 3 == 0) d0[c[i][j]]++;
			if ((i+j) % 3 == 1) d1[c[i][j]]++;
			if ((i+j) % 3 == 2) d2[c[i][j]]++;
		}
	}

	rep(i,C)
	{
		rep(j,C)
		{
			ch0[i+1] += D[j+1][i+1] * d0[j+1];
			ch1[i+1] += D[j+1][i+1] * d1[j+1];
			ch2[i+1] += D[j+1][i+1] * d2[j+1];
		}
	}

	int ans = 1000 * 500 * 500 + 10;
	rep(i,C)
	{
		rep(j,C)
		{
			rep(k,C)
			{
				if (i != j && j != k && k != i)
				{
					//cout << i << " " << j << " " << k << "  " << ch0[i+1]+ch1[j+1]+ch2[k+1] << endl;
					ans = min(ans,ch0[i+1]+ch1[j+1]+ch2[k+1]);
				}
			}
		}
	}
	cout << ans << endl;
	return 0;
}

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

int main() {
 int n,m,x;
 cin>>n>>m>>x;
 int A[m];
 for(int i=0;i<m;i++){
 	cin>>A[i];}
 	int count1 = 0 ,count2 = 0;
 	for(int i=0;i<m;i++){
 		if(x>A[i]){
 			count1++;}
 			else count2++;
 	}
 	int ans = min(count1,count2);
 	cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
  
using namespace std;
  
template<class T> void ckmin(T &a, T b) { a = min(a, b); }
template<class T> void ckmax(T &a, T b) { a = max(a, b); }
  
#define pb push_back
#define mp make_pair
#define cotu cout
#define itn int
#define Red ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define F first
#define S second
#define sz(x) (int)x.size()
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for(int i = 0; i < n; ++i)
#define repr(i,n) for(int i = n - 1; i >= 0; --i)
#define Rep(i, a, n) for(int i = (a); i <=(n); ++i)
#define repst(i, n) for(auto it = n.begin(); it != n.end(); ++it)
#define Repr(i, a, n) for(int i = (n); i >= (a); --i)
  
#define ordered_set tree<int , null_type,less<int >, rb_tree_tag,tree_order_statistics_node_update> 
  
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 
  
typedef long long ll;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;
  
const int inf = int(1e9);
const int mod = 16714589;
const int N = 1e5 + 555; // TL MB
const double PI = acos(-1.0);
double eps = 1e-6;

void solve()
{
	int n, k;
	cin >> n >> k;
	vector<bool> good(n + 1, true);
	rep(i, k){
		int d;
		cin >> d;
		rep(j, d){
			int x;
			cin >> x;
			good[x] = false;
		}
	}
	int res = 0;
	for(int i = 1; i <= n; ++i) res += good[i];
		cout << res;


}


 
 
int main()
{
	Red;
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
  	int T = 1; 
  	//cin >> T; 
  	for(int i = 1; i <= T; ++i){
  		solve();
  	}
    return 0;
}

Measured memory_bytes: 3648
#include <bits/stdc++.h>
#define PI 3.14159265358979323846
#define MAXINF (1e18L)
#define INF (1e9L)
#define EPS (1e-9)
#define MOD ((ll)(1e9+7))
#define REP(i, n) for(int i=0;i<int(n);++i)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define ALL(v) v.begin(),v.end()
#define FIND(v,x) (binary_search(ALL(v),(x)))
#define SORT(v) sort(ALL(v))
#define RSORT(v) sort(ALL(v));reverse(ALL(v))
#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl
#define Yes(n) cout<<((n)?"Yes":"No")<<endl
#define YES(n) cout<<((n)?"YES":"NO")<<endl
#define pb push_back
#define fi first
#define se second
using namespace std;
template<class A>void pr(A a){cout << (a) << endl;}
template<class A,class B>void pr(A a,B b){cout << a << " "  ;pr(b);}
template<class A,class B,class C>void pr(A a,B b,C c){cout << a << " " ;pr(b,c);}
template<class A,class B,class C,class D>void pr(A a,B b,C c,D d){cout << a << " " ;pr(b,c,d);}
template<class T> void pr_vec(vector<T> &v, char ep=' '){int n=v.size();REP(ni,n){cout<<v[ni];if(ni!=n-1)cout<<ep;}cout<<endl;};
template<class T> inline bool chmin(T& a, T b){return a>b ? a=b, true : false;}
template<class T> inline bool chmax(T& a, T b){return a<b ? a=b, true : false;}
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll,ll> pll;

int main(void)
{
    int N;
    ll K;
    cin >> N >> K;
    vector<int> A(N);
    for (int i = 0; i < N; i++) {
        cin >> A[i];
        A[i]--;
    }

    vector<ll> V(N, -1);
    vector<ll> T;
    int ls , le;
    int now = 0;
    REP(i, N){
        if(V[now] != -1){
            ls = V[now];
            le = i;
            break;
        }
        T.pb(now);
        V[now] = i;
        now = A[now];
    }

    if(ls > K){
        pr(T[K]+1);
    }else{
        pr(T[((K-ls)%(le-ls))+ls]+1);
    }
}

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

int N, M, X[100000];
int main()
{
	cin >> N >> M;
	for (int i = 0; i < M; i++)
		cin >> X[i];
	sort(X, X + M);
	int Y[100000];
	for (int i = 0; i < M - 1; i++)
	{
		Y[i] = X[i + 1] - X[i];
	}
	sort(Y, Y + M - 1);

	int ans = 0;

	for (int i = 0; i < M - N; i++)
	{
		ans += Y[i];
	}

	cout << ans;
	return 0;
}

Measured memory_bytes: 1024
#![allow(unused, non_snake_case, dead_code, non_upper_case_globals)]
use {
    proconio::{marker::*, *},
    std::{cmp::*, collections::*, mem::*},
};
fn main() {
    input! {//
         h:usize, w:usize,
    mut     a:[Chars;h],
     }

    let mut ans = 0;
    let mut q = VecDeque::new();
    let mut memo = vec![vec![std::usize::MAX >> 1; w]; h];
    let dx = vec![-1, 0, 0, 1];
    let dy = vec![0, -1, 1, 0];
    for hh in 0..h {
        for ww in 0..w {
            if a[hh][ww] != '#' {
                continue;
            }
            q.push_back((hh, ww, 0));
        }
    }
    while let Some(x) = q.pop_front() {
        let (hh, ww, dis) = x;
        if memo[hh][ww] <= dis {
            continue;
        }
        memo[hh][ww] = dis;
        for nxi in 0..4 {
            let nxh = hh as i64 + dx[nxi];
            let nxw = ww as i64 + dy[nxi];
            if (0..h as i64).contains(&nxh) && (0..w as i64).contains(&nxw) {
                // if a[nxh as usize][nxw as usize] == '.' {
                q.push_back((nxh as usize, nxw as usize, dis + 1));
                // }
            }
        }
    }
    for hh in 0..h {
        for ww in 0..w {
            ans = max(ans, memo[hh][ww]);
        }
    }
    println!("{}", ans);
}


Measured memory_bytes: 113204
# python template for atcoder1
import sys
sys.setrecursionlimit(10**9)
input = sys.stdin.readline

N, K = map(int, input().split())
sushis = [list(map(int, input().split())) for _ in range(N)]

sushis = sorted(sushis, key=lambda x: (x[1], x[0]), reverse=True)

p = 0


def calcPoint(selected_sushis):
    p = 0
    vari = set()
    for i, v in selected_sushis:
        vari.add(i)
        p += v
    p += len(vari)**2
    return p, vari


selected = sushis[:K]
unSelected = sushis[K:]

p, vari = calcPoint(selected)
cand = [p]

va = len(vari)
v = [0]*(N+1)
for i, _ in selected:
    v[i] += 1

can_del = []
for i, d in reversed(selected):
    if v[i] >= 2:
        v[i] -= 1
        can_del.append(d)

can_in = []
for i, d in unSelected:
    if not i in vari:
        vari.add(i)
        can_in.append(d)

#print("del->", can_del, can_in)
for od, nd in zip(can_del, can_in):
    nextp = p-od+nd-(va)**2+(va+1)**2
    p = nextp
    cand.append(p)
    va += 1
print(max(cand))


Measured memory_bytes: 41776
#include <iostream>
#include <cstdio>
#include <stdio.h>
#include <string>
using namespace std;
int main(){
	char p='A';
	string str;
	while(cin>>str){
		if(str[0]==p){
			p=str[2];
		}else if(str[2]==p){
			p=str[0];
		}
	}
	cout<<p<<endl;
	return 0;
}

Measured memory_bytes: 1172
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define FOR(i,s,n) for(int i = (s); i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) for(int i = (n); i >= 0; i--)
#define ALL(n) (n).begin(), (n).end()
#define RALL(n) (n).rbegin(), (n).rend()
#define ATYN(n) cout << ( (n) ? "Yes":"No") << '\n';
#define CFYN(n) cout << ( (n) ? "YES":"NO") << '\n';
#define OUT(n) cout << (n) << '\n';
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;
using pll = pair<ll,ll>;

int main(void)
{
    IOS
    int N; cin >> N;
    ll ans = 0;
    bool odd = false;
    REP(i,N) {
        int a; cin >> a;
        if (a != 0 && odd) {
            ans++;
            a--;
        }
        ans += a / 2;
        odd = ( a % 2 == 1);
    }

    cout << ans << '\n';

    return 0;
}

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

int main() {
int a;
cin >> a;
int ans = a + a*a + a*a*a;
cout << ans << endl;
}


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

int main() {
  int A, B, C, D, L, R;
  cin >> A >> B >> C >> D;
  
  // 左側の天秤
  L = A + B;
  // 右側の天秤
  R = C + D;
  
  // 条件の記載
  if (L == R) {
    cout << "Balanced" << endl;
  }
  
  else if (L > R) {
    cout << "Left" << endl;
  }
  
  else {
    cout << "Right" << endl;
  }
  
  
}

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

using namespace std;

#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
#define FORR(i, a, b) for(int i = (a); i > (b); --i)
#define REP(i, n) for(int i = 0; i < (n); ++i)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOREACH(x, a) for(auto &(x) : (a))
#define VECCIN(x)                                                              \
    for(auto &youso_ : (x)) cin >> youso_
#define mp make_pair
#define bitcnt __builtin_popcount
#define All(a) (a).begin(), (a).end()
template <typename T = long long> inline T IN() {
    T x;
    cin >> x;
    return (x);
}
inline void CIN() {}
template <class Head, class... Tail>
inline void CIN(Head &&head, Tail &&... tail) {
    cin >> head;
    CIN(move(tail)...);
}
#define CINT(...)                                                              \
    int __VA_ARGS__;                                                           \
    CIN(__VA_ARGS__)
#define LCIN(...)                                                              \
    ll __VA_ARGS__;                                                            \
    CIN(__VA_ARGS__)
#define SCIN(...)                                                              \
    string __VA_ARGS__;                                                        \
    CIN(__VA_ARGS__)
#define Yes(a) cout << (a ? "Yes" : "No") << "\n"
#define YES(a) cout << (a ? "YES" : "NO") << "\n"

typedef long long ll;
typedef unsigned long long ul;
typedef vector<int> V;
typedef vector<ll> VL;
typedef pair<int, int> Pair;
typedef pair<ll, ll> PL;
typedef priority_queue<int> PQ;
typedef priority_queue<int, V, greater<int>> PQG;

const int INF = 1e9;
const int MOD = 1e9 + 7;
// const int MOD = 998244353;
const ll LINF = 1e18;

string A;
map<char, ll> dic;

int main() {
    cin >> A;
    ll N = A.length();
    REP(i, N) dic[A[i]]++;
    ll ans = N * (N - 1) / 2;
    FOREACH(d, dic) { ans -= d.second * (d.second - 1) / 2; }
    cout << ans + 1 << "\n";
    return 0;
}


Measured memory_bytes: 640
//---------------------------------------------------------------
#include <bits/stdc++.h>
using namespace std;
#include <iostream>
#include <vector>
#include <cstdlib>
#include <cmath>
#include <math.h>
#include <sstream>
#include <numeric>
#include <cctype>
#include <bitset>
#include <cassert>
#include<algorithm>
//---------------------------------------------------------------
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i <= (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define SIZE 100005
#define INF 1e18
#define all(x) x.begin(),x.end()
#define fi first
#define se second
#define vec vector
using pint = pair<int,int>;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
//---------------------------------------------------------------
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const double pi = acos(-1);
//---------------------------------------------------------------

//↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓


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

    ll n;
    string s;
    cin>>n;
    cin>>s;
    ll re=0;
    ll rw=0;
    rep(i,n){
        if(s[i]=='E')re++;
        if(s[i]=='W')rw++;
    }
    ll le=0;
    ll lw=0;

    ll ans=INF;
    for(int i=0;i<n;i++){
        ans=min(lw+re,ans);
        if(s[i]=='E') re--,le++;
        if(s[i]=='W') rw--,lw++;
    }
    ans=min(lw+re,ans);
    cout<<ans<<endl;
}

Measured memory_bytes: 3872
import copy

n=int(input())
a=[int(x) for x in input().rstrip().split()]

now=0
ans1=0
for i in range(n):
  now+=a[i]
  if i%2==0:
    if now<=0:
      ans1+=abs(now)+1
      now=1
  else:
    if 0<=now:
      ans1+=abs(now)+1
      now=-1

now=0
ans2=0
for i in range(n):
  now+=a[i]
  if i%2==0:
    if 0<=now:
      ans2+=abs(now)+1
      now=-1
  else:
    if now<=0:
      ans2+=abs(now)+1
      now=1
print(min(ans1,ans2))

Measured memory_bytes: 20692
N,K=[int(thing) for thing in input().split(" ")]
H_list=[int(thing) for thing in input().split(" ")]
H_list=sorted(H_list,reverse=True)
fuckable=sum(H_list[0:K])
health_sum=sum(H_list)
need_attack=health_sum-fuckable
print(need_attack)

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

int main(){
  int L,R,d;
  cin>>L>>R>>d;

  int count=0;
  for(int i=0;R-i>=L;i++){
    if((R-i)%d==0)
      count++;
  }
    cout<<count<<endl;
}

Measured memory_bytes: 3628
import sys
input=sys.stdin.readline
n,q=map(int,input().split())
c=list(map(int,input().split()))
l=[]
for i in range(q):
  L,R=map(int,input().split())
  l.append([L,R,i])
l.sort(key=lambda x:x[1])

L=[-1]*(5*10**5+1)

class Bit:
  def __init__(self,n):
    self.size=n
    self.tree=[0]*(n + 1)
    self.depth=n.bit_length()

  def sum(self,i):
    s=0
    while i>0:
      s+=self.tree[i]
      i-=i&-i
    return s

  def add(self,i,x):
    while i<=self.size:
      self.tree[i]+=x
      i+=i&-i

BIT=Bit(n+1)

ans=[0]*q
ct=0
for i,j,k in l:
  while ct<=j:
    if L[c[ct-1]-1]!=-1:
      BIT.add(L[c[ct-1]-1],-1)
    L[c[ct-1]-1]=ct+1
    BIT.add(ct+1,1)
    ct+=1
  ans[k]=BIT.sum(j+1)-BIT.sum(i)

for i in ans:
  print(i)

Measured memory_bytes: 226608
#define MOD_TYPE 1

#pragma region Macros
#include <bits/stdc++.h>
using namespace std;
/*
#include <boost/multiprecision/cpp_int.hpp>
#include <boost/multiprecision/cpp_dec_float.hpp>
using multiInt = boost::multiprecision::cpp_int;
using lld = boost::multiprecision::cpp_dec_float_100;
*/
/*
#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
*/
using ll = long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using pld = pair<ld, ld>;
template <typename Q_type>
using smaller_queue = priority_queue<Q_type, vector<Q_type>, greater<Q_type>>;

constexpr ll MOD = (MOD_TYPE == 1 ? (ll)(1e9 + 7) : 998244353);
//constexpr ll MOD = 1;
constexpr int INF = (int)1e9;
constexpr ll LINF = (ll)4e18;
constexpr ld PI = acos(-1.0);
constexpr ld EPS = 1e-11;
constexpr int Dx[] = {0, 0, -1, 1, -1, 1, -1, 1, 0};
constexpr int Dy[] = {1, -1, 0, 0, -1, -1, 1, 1, 0};

#define REP(i, m, n) for (ll i = m; i < (ll)(n); ++i)
#define rep(i, n) REP(i, 0, n)
#define REPI(i, m, n) for (int i = m; i < (int)(n); ++i)
#define repi(i, n) REPI(i, 0, n)
#define MP make_pair
#define MT make_tuple
#define YES(n) cout << ((n) ? "YES" : "NO") << "\n"
#define Yes(n) cout << ((n) ? "Yes" : "No") << "\n"
#define possible(n) cout << ((n) ? "possible" : "impossible") << "\n"
#define Possible(n) cout << ((n) ? "Possible" : "Impossible") << "\n"
#define Yay(n) cout << ((n) ? "Yay!" : ":(") << "\n"
#define all(v) v.begin(), v.end()
#define NP(v) next_permutation(all(v))
#define dbg(x) cerr << #x << ":" << x << "\n";

inline void init_main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << setprecision(30) << setiosflags(ios::fixed);
}
template <typename T>
inline bool chmin(T &a, T b)
{
  if (a > b)
  {
    a = b;
    return true;
  }
  return false;
}
template <typename T>
inline bool chmax(T &a, T b)
{
  if (a < b)
  {
    a = b;
    return true;
  }
  return false;
}
inline ll CEIL(ll a, ll b)
{
  return (a + b - 1) / b;
}
template <typename A, size_t N, typename T>
inline void Fill(A (&array)[N], const T &val)
{
  fill((T *)array, (T *)(array + N), val);
}
template <typename T, typename U>
constexpr ostream &operator<<(ostream &os, pair<T, U> &p) noexcept
{
  os << p.first << " " << p.second;
  return os;
}
#pragma endregion

int main()
{
  init_main();

  int n;
  ll t;
  cin >> n >> t;
  vector<ll> a(n);
  rep(i, n) cin >> a[i];
  ll sum = t;
  rep(i, n - 1)
  {
    sum += min(a[i + 1] - a[i], t);
  }
  cout << sum << "\n";
  return 0;
}

Measured memory_bytes: 1792
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
ull B = 100000007;
ll mod = 1000000007;
int INF = 0x3f3f3f3f;

int main() {
    int n, k;
    cin >> n >> k;
    set<int> st;
    for(int i = 0; i < k; ++i) {
        int n1;
        cin >> n1;
        for(int j = 0; j < n1; ++j) {
            int nn;
             cin >> nn;
             if(st.find(nn) == st.end()) {
                 st.insert(nn);
             }
        }
    }

    int res = 0;
    for(int i = 1; i <= n; ++i) {
        if(st.find(i) == st.end()) {
            res++;
        }
    }
    cout << res << endl;

    return 0;
}



Measured memory_bytes: 3636
weather = input()

raining = False
count = 0
max = 0
for w in weather:
    if w == 'R':
        if not raining:
            raining = True
            count = 1
        else:
            count += 1
    elif w == 'S':
        raining = False
        count = 0
    if max < count:
        max = count

print(max)

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

typedef pair<int, int> Coor;
typedef pair<Coor, Coor> Pair;

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

int H;
int W;
int sty[2];
int stx[2];
int y[2];
int x[2];
char field[2][50][50];
bool dp[50][50][50][50];

bool WithinRange(int y, int x) {
  if (y < 0 || H <= y) return false;
  if (x < 0 || W <= x) return false;
  return true;
}

int main() {
  while (1) {
    scanf("%d%d", &W, &H);
    if (W == 0 && H == 0) return 0;

    for (int i=0; i<H; i++) {
      for (int j=0; j<W; j++) {
        scanf(" %c", &field[0][i][j]);
        if (field[0][i][j] == '%') {
          sty[0] = i;
          stx[0] = j;
        } else if (field[0][i][j] == 'L') {
          y[0] = i;
          x[0] = j;
        } else assert(field[0][i][j] == '.' || field[0][i][j] == '#');
      }

      for (int j=W-1; j>=0; j--) {
        scanf(" %c", &field[1][i][j]);
        if (field[1][i][j] == '%') {
          sty[1] = i;
          stx[1] = j;
        } else if (field[1][i][j] == 'R') {
          y[1] = i;
          x[1] = j;
        } else assert(field[1][i][j] == '.' || field[1][i][j] == '#');
      }
    }

    for (int i=0; i<H; i++) {
      for (int j=0; j<W; j++) {
        for (int k=0; k<H; k++) {
          for (int l=0; l<W; l++) {
            dp[i][j][k][l] = false;
          }
        }
      }
    }

    dp[y[0]][x[0]][y[1]][x[1]] = true;
    queue<Pair> q;
    q.push(Pair(Coor(y[0], x[0]), Coor(y[1], x[1])));
    while (!q.empty()) {
      Pair p = q.front(); q.pop();
      Coor c1 = p.first;
      int y1 = c1.first;
      int x1 = c1.second;
      Coor c2 = p.second;
      int y2 = c2.first;
      int x2 = c2.second;

      for (int i=0; i<4; i++) {
        int newy1 = y1 + dy[i];
        int newx1 = x1 + dx[i];
        if (!WithinRange(newy1, newx1) || field[0][newy1][newx1] == '#') {
          newy1 = y1;
          newx1 = x1;
        }

        int newy2 = y2 + dy[i];
        int newx2 = x2 + dx[i];
        if (!WithinRange(newy2, newx2) || field[1][newy2][newx2] == '#') {
          newy2 = y2;
          newx2 = x2;
        }

        if (dp[newy1][newx1][newy2][newx2]) continue;
        dp[newy1][newx1][newy2][newx2] = true;
        if (newy1 == sty[0] && newx1 == stx[0]) {
          if (newy2 == sty[1] && newx2 == stx[1]) break;
          continue;
        }
        if (newy2 == sty[1] && newx2 == stx[1]) continue;
        q.push(Pair(Coor(newy1, newx1), Coor(newy2, newx2)));
      }
    }

    if (dp[sty[0]][stx[0]][sty[1]][stx[1]]) puts("Yes");
    else puts("No");
  }
}

Measured memory_bytes: 9956
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <string>
#include <queue>
#include <stack>

#define fast ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);

using namespace std;
int main() {
	fast
		string a, b,c;
	cin >> a >> b;
	int n, x;
	cin >> n >> x>>c;
	if (a == c)n--;
	if (b == c)x--;
	cout << n << " " << x<<endl;;

}

 

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<(n); ++i)
#define rep1(i,n) for(int i=1; i<=(n); ++i)
#define repi(i,a,b) for(int i=a; i<=(b); ++i)
#define rrep(i,n) for(int i=(n-1); i>=0; --i)
#define ALL(obj) (obj).begin(), (obj).end()
#define RALL(obj) (obj).rbegin(), (obj).rend()
#define pb push_back
#define mp make_pair
#define to_s to_string
#define sz(v) (int)v.size()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() )
#define pr(x) cout<<(x)<<'\n'
#define debug(x) cout << #x << ": " << (x) << '\n'
#define yes "Yes"
#define no "No"
using namespace std;
using ll = long long;
using Edge = pair<int,long long>;
using Graph = vector<vector<Edge>>;
typedef pair<int,int> P;
struct aaa{aaa(){ cin.tie(0); ios::sync_with_stdio(0); cout<<fixed<<setprecision(20);};}aaaaaaa;
int MOD = 1e9 + 7;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return (a*b)/gcd(a,b);}
ll devc(ll x, ll y){return 1 + (x-1)/y;}

ll solve(ll N){
    return 3*N*N;
}

int main(){
    ll N; cin >> N;
    pr(solve(N));
    return 0;
}

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

#define ll long long
#define vvi vector< vector<int> >
#define vi vector<int>
#define All(X) X.begin(),X.end()
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define pb push_back
#define pii pair<int,int>
#define mp make_pair
#define pi 3.14159265359
#define shosu(X) fixed << setprecision(X)
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;}

int n;
string s;

int solve(int t){
	set<int> v;
	for(int i = 0; i <= n-t; i++){
		string tmp = "";
		REP(j,t) tmp += s[i+j];
		if(tmp[0] != '0') v.insert(stoi(tmp));
		if(t == 1 && tmp[0] == '0') v.insert(0);
	}
	int f;
	if(t == 1) f = 0;
	else f = pow(10,t-1);
	for(int i = f; i < pow(10,t)-1; i++){
		if(v.find(i) == v.end()) return i;
	}
	return -1;
}
int main(){
	s = "";
	cin >> n;
	REP(i,n){
		char c;
		cin >> c;
		s += c;
	}
	int k = 1;
	while(1){
		int res = solve(k);
		k++;
		if(res != -1){
			cout << res << endl;
			return 0;
		}
	}
}

Measured memory_bytes: 3412
import time
X = int(input())
flag = 0
T_0 = time.time()

A = 0
B = 0
for a in range(2000):
    for b in range(2000):
        if (a-1000)**5 - (b-1000)**5 == X:
            flag = 1
            A = a-1000
            B = b-1000
            break
        else:
            pass
    if flag == 1:
        break
T_1 = time.time()

print(A,B)

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

int main(){
    ll N; cin >> N;
    ll ans = N + 1;
    for(ll i = 1; i < (ll)sqrt(N) + 1; i++){
        if(N % i == 0) ans = min(ans, i + N / i);
    }
    cout << ans - 2 << endl;
}

Measured memory_bytes: 256
def get_num(n, x):
    ans = 0
    for n3 in range(min(n, x), (x + 2) / 3, -1):
        for n2 in range(min(n3 - 1, x - n3), (x - n3 + 1) / 2 - 1, -1):
            for n1 in range(min(n2 - 1, x - n3 - n2), 0, -1):
                if n1 + n2 + n3 == x:
                    ans += 1
                    break
    return ans


# data = []
while True:
    [n, x] = [int(m) for m in raw_input().split()]
    if [n, x] == [0, 0]:
        break
    if x < 3:
        # data.append(0)
        print(0)
    else:
        # data.append(get_num(n, x))
        print(get_num(n, x))

# for n in data:
#     print(n)

Measured memory_bytes: 6420
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<iomanip>
#include<vector>
#include<queue>
#include<deque>
#include<string>
#include<utility>
#include<cmath>
#include<algorithm>
#include<cctype>
#include<set>
#include<map>
#include<bitset>
#include<stack>
#include<ctime>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll,int> pli;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vpii;
typedef vector<pli> vpli;

inline ll read(){
    ll Hashimoto=0;
	bool Kanna=1;
    char I_Love=getchar();
    while(I_Love<'0'||I_Love>'9'){
        if(I_Love=='-')Kanna=0;
        I_Love=getchar();
    }
    while(I_Love>='0'&&I_Love<='9'){
        Hashimoto=Hashimoto*10+I_Love-'0';
        I_Love=getchar();
    }
    return (Kanna?Hashimoto:-Hashimoto);
}
template<typename T1,typename T2> inline void Umax(T1 &a,T2 b){
	if(a<b)a=b;
}
template<typename T1,typename T2> inline void Umin(T1 &a,T2 b){
	if(a>b)a=b;
}

#define I_Love_Hashimoto_Kanna main
#define fastio ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define filein(s) freopen(s,"r",stdin);
#define fileout(s) freopen(s,"w",stdout);
#define file freopen("I_Love_Hashimoto_Kanna.out","w",stdout);
#define RE cout<<"I_Love_Hashimoto_Kanna"<<endl;
#define Tone(Kanna) cout<<Kanna<<endl;
#define Tall(Hashimoto,Kanna) for(int I_Love=0;I_Love<(Kanna);++I_Love)cout<<Hashimoto[I_Love]<<(I_Love==(Kanna)-1?"\n":" ");
#define FOR(I_Love,Hashimoto,Kanna) for(int I_Love=Hashimoto;I_Love<(Kanna);++I_Love)
#define MP(Hashimoto,Kanna) make_pair(Hashimoto,Kanna)
#define REV(Kanna) reverse(Kanna.begin(),Kanna.end());
#define SORT(Kanna) sort(Kanna.begin(),Kanna.end());
#define UNIQUE(Kanna) Kanna.erase(unique(Kanna.begin(),Kanna.end()),Kanna.end());
#define inf (1000000000)
#define linf (1000000000000000000ll)
#define mod (1000000007)

int l,r;

int I_Love_Hashimoto_Kanna() {
	//完全想清楚了再开始写。
	//写不顺、不知道怎么写、很乱的时候，停下来好好想想。
	//做得慢总比做不出好。
	fastio;
	cin>>l>>r;
	r++;
	if(r-l>=2019){
		cout<<0<<endl;
		return 0;
	}
	ll ans=inf;
	FOR(i,l,r)FOR(j,i+1,r){
		ans=min(ans,i*1ll*j%2019ll);
	}
	cout<<ans<<endl;
	
	
	return 0;
}


Measured memory_bytes: 256
//的場梨沙★担当
//結城晴★副担当
//日野茜★副担当
#include <vector>
#include <list>
#include <map>
#include <climits>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string.h>
#include <string>
#include <cstring>
#include <ctime>
#include <queue>
#include <random>
#include <cctype>
#include <complex>
#include <regex>
#include <unordered_map>
#include <string>
#include <algorithm>
#include <cctype>
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <iomanip>
#include <iostream>

using namespace std;

int main() {
    int N;
    string S;
    cin>>N>>S;
    int A;
    for(int i=0;i<N;i++){
        if(S[i]=='A'){
            if(S[i+1]=='B'){
                if(S[i+2]=='C'){
                    A++;
                }
            }


        }

    }

    cout<<A<<endl;


}


Measured memory_bytes: 256
#include <stdio.h>
int main(void){
    char w[1000];
    scanf("%s", w);
    if(w[0] == 'S'){
        printf("Cloudy\n");
    }
    if(w[0] == 'C'){
        printf("Rainy\n");
    }
    if(w[0] == 'R'){
        printf("Sunny\n");
    }
    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
typedef long long ll;
typedef unsigned long long ull;
#define reps(i,s,n) for(int (i)=(s);(i)<(n);++(i))
#define rep(i,n) reps(i,0,n)
#define reptr(i,n) for(int (i)=(n);(i)>=0;--(i))
#define All(x) (x).begin(),(x).end()
const ll MOD=1e9+7;
using namespace std;

int main(){
  int a,b,c,d,e,f;
  cin >> a >> b >> c >> d >> e >> f;
  //ans: 水, ansS: 砂糖
  vector<int> ans,ansS;

  for(int i=0;a*i<=f;i++){
    for(int j=0;100*a*i+100*b*j<=f;j++){
      if(i==0&&j==0) continue;
      ans.push_back(100*a*i+100*b*j);
    }
  }
  //yについて
  for(int i=0;c*i<=f;i++){
    for(int j=0;c*i+d*j<=f;j++){
      //if(i==0&&j==0) continue;
      //分母が0になる分には問題なし
      ansS.push_back(c*i+d*j);
    }
  }

  int sum=0,sumS=0;
  rep(i,ans.size()){
    rep(j,ansS.size()){
      if(ans[i]+ansS[j]>f) continue;
      if(ansS[j]*sum>=(ans[i]+ansS[j])*sumS){
        if(ansS[j]*(100+e)<=(ans[i]+ansS[j])*e){
          sum=ans[i]+ansS[j];
          sumS=ansS[j];
        }
      }
    }
  }
  cout << sum << " " << sumS << endl;
}

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

int main(){
    int n, m;
    cin >> n >> m;
    vector<ll> h(n), c(n);  
    rep(i, n) cin >> h[i];  
    rep(i, m){
        int a, b;
        cin >> a >> b;
        if(h[a - 1] > h[b - 1]){
            c[a - 1]++;
            c[b - 1] -= 1000000;
        }else if(h[a - 1] == h[b - 1]){
            c[a - 1] -= 1000000;
            c[b - 1] -= 1000000;
        }        
        else{
            c[b - 1]++;
            c[a - 1] -= 1000000;
        }
    }
    int ans = 0;
    rep(i, n){
        if(c[i] >= 0){
            ans++;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 4840
N, H, W = list(map(int, input().strip().split(' ')))

AB = []

cnt = 0

for i in range(N):
	AB.append(list(map(int, input().strip().split(' '))))	#[A][B]
	
	
for i in range(N):
	if int(AB[i][0]) >= H:
			if int(AB[i][1]) >= W:
				cnt += 1

print(cnt)

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

int main() {
  string n;
  cin >> n;
  for (int i = 0; i < n.size(); i++) {
    n[i] = (n[i] == '1') ? '9' : '1';
  }
  cout << n << endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
    ll n,k;
    cin>>n>>k;
    ll w[n],p[n];
    for(ll i=0;i<n;i++)
    {
        cin>>w[i]>>p[i];
    }
    vector<vector<ll>> dp(n,vector<ll>(k+1));
    for(ll i=0;i<n;i++)
    {
        for(ll j=1;j<=k;j++)
        {
            if(i==0)
            {
                if(j>=w[i])
                {
                    dp[i][j]=p[i];
                }
            }
            else
            {
                ll x=0;
                ll y=0;
                x=dp[i-1][j];
                if(j-w[i]>=0)
                {
                    y=dp[i-1][j-w[i]]+p[i];
                }
                dp[i][j]=max(x,y);
            }
        }
    }
    cout<<dp[n-1][k];
}

Measured memory_bytes: 79360
from fractions import gcd
# 最小公倍数
def lcm(x, y):
    return x // gcd(x, y) * y

N = int(input())
A = list(map(int, input().split()))

x = A[0]
for i in range(N):
    x = lcm(x, A[i]) 


sums = 0
mod = 10 ** 9 + 7
for i in range(N):
    sums += x // A[i]

print(sums % mod)


Measured memory_bytes: 6112
#include<iostream>
#include<algorithm>
using namespace std;
string s;
int n,ans;
int cnt[2<<17];
main()
{
	cin>>n>>s;
	for(int i=n;i--;)
	{
		cnt[i]=cnt[i+1]+(s[i]=='.');
	}
	int ret=0;
	ans=cnt[0];
	for(int i=0;i<n;i++)
	{
		ret+=s[i]=='#';
		ans=min(ans,ret+cnt[i+1]);
	}
	cout<<ans<<endl;
}


Measured memory_bytes: 1412
#include <bits/stdc++.h>
#define all(vec) vec.begin(),vec.end()
#define mp make_pair
using namespace std;
using ll=long long;
using P=pair<int,int>;
const ll INF=1LL<<30;
const ll LINF=1LL<<60;
const double eps=1e-9;
const ll MOD=1000000007LL;
template<typename T>void chmin(T &a,T b){a=min(a,b);};
template<typename T>void chmax(T &a,T b){a=max(a,b);};
int dx[4]={0,1,0,-1};
int dy[4]={1,0,-1,0};
int main(){
    int n;cin>>n;
    vector<int> a(n);
    int sum=0;
    for(int i=0;i<n;i++){
        cin>>a[i];
        sum+=a[i];
    }
    bitset<4100000> dp;
    dp.set(0);
    for(int i=0;i<n;i++){
        dp|=(dp<<a[i]);
    }
    for(int i=(sum+1)/2;i<=4000000;i++){
        if(dp[i]){
            cout<<i<<endl;
            return 0;
        }
    }
}

Measured memory_bytes: 1792
#include <iostream>
#include <iomanip>
#include <sstream>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>
#include <functional>
#include <iterator>
#include <limits>
#include <numeric>
#include <utility>
#include <cmath>
#include <cassert>
#include <cstdio>

// #include <unordered_set>
// #include <unordered_map>

#define rep(i, a, n) for(int i = a; i < n; i++)
#define REP(i, n) rep(i, 0, n)
#define repb(i, a, b) for(int i = a; i >= b; i--)
#define all(a) a.begin(), a.end()
#define SORT(c) sort((c).begin(),(c).end())
#define RSORT(c) sort((c).rbegin(),(c).rend())

#define pb push_back
#define mp make_pair

int gcd(int a,int b){int c;while(b!=0){c=a%b;a=b;b=c;}return a;}
int lcm(int a,int b){int c=gcd(a,b);a/=c;return a*b;}

typedef std::pair<int, int> P;
typedef long long ll;
typedef long double ld;

const int MOD = 1000000007;
const int INF = 1e9;
const ll LINF = INF * 1ll * INF;
const ld DINF = 1e200;
const double EPS = 1e-10;
const double PI  = acos(-1.0);

using namespace std;

// #define int long long

signed main(){
  

    ios::sync_with_stdio(false);
    cin.tie(0);
	//cin高速化

	int a,b;
	cin>>a>>b;
	cout<<(a+b+1)/2<<endl;


}

Measured memory_bytes: 256
#include<algorithm>
#include<bitset>
#include<climits>
#include<cmath>
#include<cstdlib>
#include<iomanip>
#include<iostream>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<stack>
#include<string>
#include<time.h>
#include<tuple>
#include<utility>
#include<vector>

using namespace std;
long gcd(long x, long y) { if (x > y) { return gcd(y, x); } long r; while (y != 0) { r = x % y; x = y; y = r; } return x; }
long lcm(long x, long y) { return (x / gcd(x, y) * y); }

void dps(long now, vector<vector<pair<long, long>>> &graph, vector<bool> &visited, vector<long> &crd , bool &res) {
	
	for (auto e : graph[now]) {
		long f = e.first, s = e.second;

		if (visited[f] && crd[f] != crd[now] + s) res = false;

		if (!visited[f]) {
			crd[f] = crd[now] + s;
            visited[f] = true;
			dps(f, graph, visited, crd, res);
		}
	}

}

int main(void) {

	bool res = true;
	long N, M; cin >> N >> M;
	vector<vector<pair<long,long>>> graph(N);
	vector<bool> visited(N, false);
	vector<long> crd(N , INT_MAX); //相対的な座標の値

	//vector<vector<long>> graph(N);

	for (int i = 0; i < M; i++) {
		long L, R, D; cin >> L >> R >> D;
		L--; R--;

		//graph[L].push_back(R);
		//graph[R].push_back(L);
		graph[L].push_back(make_pair(R, D));
		graph[R].push_back(make_pair(L, -D));
	}

	for (int i = 0; i < N; i++) {
		if (visited[i]) continue;

		crd[i] = 0;
        visited[i] = true;
		dps(i, graph, visited, crd , res);
	}

	if (res) cout << "Yes" << endl; else cout << "No" << endl;
}

Measured memory_bytes: 18304