akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <stdlib.h>
#include <string.h>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <stdio.h>
#include <tuple>
#include <bitset>
#include <cfloat>
#include <fstream>
#include <limits.h>
#include <list>
#include <math.h>
#include <random>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <numeric>
#include <utility>
#include <sstream>

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

using namespace std;
#define int long long
#define ll long long
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define FORR(i,a,b)for(ll i=(a);i<=(b);i++)
#define repr(i,n) for(ll i=n;i>=0;i--)
#define P pair<ll, ll>
#define sz(x) (ll)x.size()
#define ALL(x) (x).begin(),(x).end()
#define ALLR(x) (x).rbegin(),(x).rend()
#define VE vector<ll>
#define COUT(x) cout<<(x)<<endl
#define MA map<ll,ll>
#define SE set<ll>
#define PQ priority_queue<ll>
#define PQR priority_queue<ll,VE,greater<ll>>
#define COUT(x) cout<<(x)<<endl
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define EPS (1e-10)
ll gcd(ll a, ll b) {
	if (a < b)swap(a, b);
	if (b == 0) return a;
	return gcd(b, a % b);
}
ll lcm(ll a, ll b) {
	ll g = gcd(a, b);
	return a / g * b;
}
bool prime(ll n) {
	for (ll i = 2; i <= sqrt(n); i++) {
		if (n%i == 0)return false;
	}
	return n != 1;
}


const long long MOD = 1000000007;
const long long INF = 1LL << 60;


const int MAX_N = 100010;
signed main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	VE a(3); rep(i, 3)cin >> a[i];
	sort(ALL(a));
	int m = a[2];
	if ((3 * m) % 2 != (a[0] + a[1] + a[2])%2) {
		m++;
	}
	int ans = 0;
	ans += (m - a[0]) / 2;
	a[0] += (m - a[0]) / 2 * 2;
	ans += (m - a[1]) / 2;
	a[1] += (m - a[1]) / 2 * 2;
	ans += (m - a[2]) / 2;
	a[2] += (m - a[2]) / 2 * 2;
	if (a[0]!=m||a[1]!=m||a[2]!=m)ans++;
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cmath>
#include<vector>
#include<string>
#include<cstdio>
typedef unsigned long long ull;
#define rep(i,a) for(int i=0;i<a;i++)
#define loop(i,a,b) for(int i=a;i<b;i++)
using namespace std;
const double eps = 1e-10;
const double pi = acos(-1);
const double inf = (int)1e8;

int main(void){
  int word[4] = {0};
  string str;
  getline(cin,str);
  rep(i,str.size()){
    if(str[i] == 'K')word[1]++;
    if(str[i] == 'U')word[2]++;
    if(str[i] == 'P')word[3]++;
    if(str[i] == 'C')word[0]++;
  }
  int res = 1000000;
  rep(i,4)res = min(res,word[i]);
  cout<<res<<endl;
  return 0;
}

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

#define REP(i,n) for(int i=0; i < (n); ++i)
#define REPR(i,n) for(int i=(n); i >= 0; --i)
#define FOR(i, m, n) for(int i = (m); i < (n); ++i)

using ll = long long;
#define INF 1e9

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

int N;
vector<int> A;
int main(){
  cin >> N;
  A.resize(N);
  REP(i, N){
    cin >> A[i];
  }
  vector<int> gcd_a(N), gcd_r(N);
  int G = A[0];
  REP(i, N){
    G = gcd(G, A[i]);
    gcd_a[i] = G;
  }
  G = A.back();
  REPR(i, N-1){
    G = gcd(G, A[i]);
    gcd_r[i] = G;
  }
  int ans = 0;
  REP(i, N){
    if(i == 0){
      ans = max(ans, gcd_r[1]);
    }
    else if(i == N-1){
      ans = max(ans, gcd_a[N-2]);
    }
    else{
      ans = max(ans, (int)gcd(gcd_a[i-1], gcd_r[i+1]));
    }
  }
  cout << ans <<endl;

  return 0;
}


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

int main()
{
	bool f = 0;
	int a, b;
	cin >> a >> b;
	if (a % 3 == 0)
		f = 1;
	else if (b % 3 == 0)
		f = 1;
	else if ((a + b) % 3 == 0)
		f = 1;

	if (f)
		cout << "Possible" << endl;
	else
		cout << "Impossible" << endl;

	return 0;
}


Measured memory_bytes: 384
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<stack>
#include<queue>
#include <cstring>
#include<vector>
#include<cmath>
#include<utility>
#include<set>
#include<stack>
#include<complex>
#define vi vector<int>
#define vvi vector<vector<int> >
#define ll long long int
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vb vector<bool>
#define ld long double
#define INF 1e9
#define EPS 0.0000000001
#define rep(i,n) for(int i=0;i<n;i++)
#define CC puts("-------ok--------");
#define all(in) in.begin(), in.end()
#define bv vector<bool>
using namespace std;
typedef pair<int, int>PA;
using namespace std;
#define MAX  999999
int main(){
	while(true){
	int ans =0;
	int n; cin >> n; if(!n) break;
	stack<int>stl;
	stack<int>str;
	char s[2]; scanf("%s",s);
	int lastsize = 0;
	rep(i,n){ 
	if(i != 0) scanf("%s",s);
	if(strcmp(s,"lu") == 0) stl.push(1); 
	if(strcmp(s,"ld") == 0)	stl.pop(); 
	if(strcmp(s,"ru") == 0) str.push(1);
	if(strcmp(s,"rd") == 0) str.pop();
	int lsize = stl.size();
	int rsize = str.size();
	if(lsize ==rsize && lsize != lastsize){ans++;lastsize = lsize;}
		}
	cout << ans << endl;
	}
}

Measured memory_bytes: 3144
#include <iostream>
#include <string>
#include <algorithm>
#include <set>
#include <cmath>

typedef long long ll;

using namespace std;

int main()
{
    ll r, d, x;
    cin >> r >> d >> x;

    for (ll i=0; i<10; ++i)
        x = r * x - d, cout << x << endl;

    return 0;
}


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

using namespace std;

int main()
{
    int a, b, c;
    cin >> a >> b >> c;
    if (a + b >= c) {
        cout << "Yes" << endl;
    }
    else {
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
template < typename T > string tost( const T& n ) { ostringstream stm; stm << n; return stm.str();}
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;}
int const INF = 1001001001;


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

string S;
cin >> S;
int N = S.size();
stack<char> st;
rep(i,N) {
    if(st.empty()) st.push(S[i]);
    else {
        if(S[i] == st.top()) st.push(S[i]);
        else st.pop();
    }
}
cout << N - st.size() << endl;
return 0;
}

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

int main() {
  int n;
  cin >> n;
  int d[n];
  for (int i = 0; i < n; i++) {
    cin >> d[i];
  }
  sort(d, d + n);
  cout << d[n / 2] - d[n / 2 - 1] << endl;
}

Measured memory_bytes: 640
import sys
import re
import math
import collections
import decimal
import bisect
import itertools
import fractions
import functools
import copy

# import heapq
# from collections import deque
# import decimal

sys.setrecursionlimit(10000001)
INF = sys.maxsize
MOD = 10 ** 9 + 7

ni = lambda: int(sys.stdin.readline())
ns = lambda: map(int, sys.stdin.readline().split())
na = lambda: list(map(int, sys.stdin.readline().split()))


# ===CODE===

def main():
    n, m, x = ns()

    d = []
    for _ in range(n):
        d.append(na())

    ans = INF
    for i in range(2 ** n):
        score = [0 for _ in range(m + 1)]
        for j in range(n):
            if i >> j & 1:
                for k in range(m + 1):
                    score[k] += d[j][k]

        ## check
        flg = True
        for j in range(1, m + 1):
            if score[j] < x:
                flg = False
                break
        if flg:
            ans = min(ans, score[0])

    if ans == INF:
        print(-1)
    else:
        print(ans)

if __name__ == '__main__':
    main()


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

#define rep(i, a, b) for (int i = (a); i < (int)(b); i++)
#define rrep(i, a, b) for (int i = (a); i >= (int)(b); i--)
#define all(x) (x).begin(), (x).end()
using i32 = int32_t;
using i64 = int64_t;
using f32 = float;
using f64 = double;
using P   = pair<int, int>;

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

template <class T>
void dump_vec(const vector<T>& v) {
    auto len = v.size();
    rep(i, 0, len) {
        cout << v[i] << (i == (int)len - 1 ? "\n" : " ");
    }
}

struct FastIO {
    FastIO() {
        cin.tie(0);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(20);
    }
} FASTIO;

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

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

signed main() {
    string S, T;
    cin >> S >> T;
    const auto slen = S.size(), tlen = T.size();
    vector<int> ans;
    rep(i, 0, slen) {
        int r = i;
        while (r < slen && S[r] == T[r - i]) {
            r++;
        }
        if (r - i == tlen) ans.push_back(i);
    }

    rep(i, 0, ans.size()) {
        cout << ans[i] << "\n";
    }
}



Measured memory_bytes: 3240
#include<stdio.h>
int main()
{
    int a,b,c;
    while(scanf("%d %d",&a,&b)!=EOF)
    {
        while(c=a%b)
        {
            a=b;
            b=c;
        }
        printf("%d\n",b);
        }
        return 0;
}

Measured memory_bytes: 0
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<iostream>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<sstream>
#include<unordered_map>
#include<unordered_set>
#include<vector>
#include<random>
using ll = long long;
enum : int { M = (int)1e9 + 7 };
enum : ll { MLL = (ll)1e18L + 9 };
using namespace std;
#ifdef LOCAL
#include"rprint2.hpp"
#include"debug_deque.hpp"
#define vector DebugDeque
#else
#define FUNC(name) template <ostream& out = cout, class... T> void name(T&&...){ }
FUNC(prints) FUNC(printe) FUNC(printw) FUNC(printew) FUNC(printb) FUNC(printd) FUNC(printde) FUNC(printdu);
#endif
template <class S, class T>
istream& operator >> (istream& in, pair<S, T>& p){ return in >> p.first >> p.second; }
template <class T>
istream& operator >> (istream& in, vector<T>& v){ for(auto& e : v){ in >> e; } return in; }

/*
chokudai redcoder
reokudai
redkuoai
redcouai
redco

ii ab
*/

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    bool ok = true;
    map<char, vector<int>> mp1, mp2;
    string s; cin >> s;
    string t; cin >> t;
    for(size_t i = 0; i < s.size(); i++){
        mp1[s[i]].push_back(i);
        mp2[t[i]].push_back(i);
    }
    for(auto& p : mp2){
        char c = 0;
        for(auto& pos : p.second){
            if(c){
                if(c != s[pos]){
                    ok = false;
                }
            }else{
                c = s[pos];
            }
        }
    }
    for(auto& p : mp1){
        char c = 0;
        for(auto& pos : p.second){
            if(c){
                if(c != t[pos]){
                    ok = false;
                }
            }else{
                c = t[pos];
            }
        }
    }
    // string s, t;
    // cin >> s >> t;
    // map<char, char> mp;
    // for(size_t i = 0; i < s.size(); i++){
    //     if(s[i] != t[i]){
    //         if(mp.count(s[i])){
    //             if(mp[s[i]] != t[i]){
    //                 ok = false;
    //             }
    //         }else{
    //             mp[s[i]] = t[i];
    //         }
    //         if(mp.count(t[i])){
    //             if(mp[t[i]] != s[i]){
    //                 ok = false;
    //             }
    //         }else{
    //             mp[t[i]] = s[i];
    //         }
    //     }
    // }
    cout << (ok ? "Yes" : "No") << '\n';
}


Measured memory_bytes: 2964
#include <iostream>
#include <iomanip>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <algorithm>
#include <sstream>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <numeric>
#include <cmath>
#include <climits>
#include <limits>
#include <cfloat>
#include <fstream>
using namespace std;

int main()
{
//	cut here before submit 
//	freopen("testcase.saa", "r", stdin);
	string str = "";
	int total = 0;
	int sum = 0;
	int avg = 0;
	int count = 0;
	while (getline (cin, str ) ){
		if (str.empty() ){
			break;
		} // end if
		++count;
		while (str.find(',') != string::npos ){
			str = str.replace(str.find(','), 1, " ");
		} // end while
		stringstream ss(str);
		int price, num;
		ss >> price >> num;
		total += price*num;
		sum += num;
	} // end for
	avg = (int)((double)sum/(double)count + 0.5);
	cout << total << endl;
	cout << avg << endl;
		
	return 0;
}

Measured memory_bytes: 0
#include "bits/stdc++.h"
using namespace std;
#define Would
#define you
const long long INF = 1e18;
const long long MOD = 1e9 + 7;
const double pi = acos(-1);
const int SIZE = 1 << 17;
int dx[] = { 1,0,-1,0 }, dy[] = { 0,1,0,-1 }, alp[30];
long long fac[200005], finv[200005], inv[200005];
vector<long long>dij;
struct edge { long long to, cost; };
vector<vector<edge> >G;

int main() {
	string h;
	int n;
	cin >> h >> n;
	set<string>s;
	for (int i = 0; i < h.length(); ++i) {
		for (int j = 1; j <= n; ++j) { s.insert(h.substr(i, j)); }
	}
	set<string>::iterator t = s.begin();
	for (int i = 1; i < n; ++i) { ++t; }

	cout << *t << endl;
}

Measured memory_bytes: 1664
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; ++i)
#define REPR(i, n) for (int i = n - 1; i >= 0; --i)
#define FOR(i, a, b) for (int i = a; i < b; ++i)
#define FORR(i, a, b) for (int i = b - 1; i >= a; --i)
#define SORT(v) sort(v.begin(), v.end())
#define SORTR(v) sort(v.rbegin(), v.rend())
#define REV(v) reverse(v.begin(), v.end())
#define ITER(v) for (auto itr = v.begin(), itr != v.end(); ++itr)
#define LB(v, x) lower_bound(v.begin(), v.end(), x) - v.begin()
#define UB(v, x) upper_bound(v.begin(), v.end(), x) - v.begin()
#define SZ(v) (int)v.size()
using namespace std;
using ll = long long;
using P = pair<int, int>;

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

    int N, M;
    cin >> N >> M;
    vector<int> memo(N);
    REP(i, M) {
        int a, b;
        cin >> a >> b;
        --a;
        --b;
        memo[a]++;
        memo[b]++;
    }
    string res = "YES";
    REP(i, N) if (memo[i] % 2) res = "NO";
    cout << res << endl;

    return 0;
}


Measured memory_bytes: 640
#include <map>
#include <cmath>
#include <cstdio>
#include <vector>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <algorithm>
using namespace std;
typedef long long LL;
const int maxn = 105;
const int mod = 1e9 + 7;
short dp[maxn][maxn][maxn][maxn];
short row[maxn][maxn], col[maxn][maxn];
char mp[maxn][maxn];
short max(short a, short b) {
    return a>b? a : b;
}
int main()
{
    int n, m, ex, ey;
    scanf("%d%d", &n, &m);
    for (int i=1; i<=n; i++) scanf("%s", mp[i]+1);
    for (int i=1; i<=n; i++) for (int j=1; j<=m; j++) {
            if (mp[i][j] == 'E'){
                ex = i, ey = j;
                break;
            }
    }
    for (int i=1; i<=n; i++) for (int j=1; j<=m; j++) {
            row[i][j] = row[i][j-1] + (mp[i][j] == 'o');
            col[i][j] = col[i-1][j] + (mp[i][j] == 'o');
    }
    int L = ey - 1, R = m - ey, U = ex - 1, D = n - ex;
    memset(dp, -1, sizeof dp);
    dp[0][0][0][0] = 0;
    short ans = 0;
    for (int l=0; l<=L; l++){
        for (int u=0; u<=U; u++){
            for (int r=0; r<=R; r++){
                for (int d=0; d<=D; d++) if(dp[l][u][r][d] != -1){
                    int up = max(ex - u, d + 1), down = min(ex + d, n - u);
                    int left = max(ey - l, r + 1), right = min(ey + r, m - l);
                    if (up > down || left > right) continue;
                    ans = max(ans, dp[l][u][r][d]);
                    short add;
                    //printf("\n=========%d %d %d %d -> %d %d %d %d=========\n",l,u,r,d,left,up,right,down);
                    if (l+r < L){
                        add = col[down][ey-l-1] - col[up-1][ey-l-1];
                        //printf("l: %d ",add);
                        dp[l+1][u][r][d] = max(dp[l+1][u][r][d], dp[l][u][r][d] + add);
                    }
                    if(u+d < U){
                        add = row[ex-u-1][right] - row[ex-u-1][left-1];
                        //printf("u: %d ",add);
                        dp[l][u+1][r][d] = max(dp[l][u+1][r][d], dp[l][u][r][d] + add);
                    }
                    if(l+r < R){
                        add = col[down][ey+r+1] - col[up-1][ey+r+1];
                        //printf("r: %d ",add);
                        dp[l][u][r+1][d] = max(dp[l][u][r+1][d], dp[l][u][r][d] + add);
                    }
                    if(u+d < D){
                        add = row[ex+d+1][right] - row[ex+d+1][left-1];
                        //printf("d: %d ",add);
                        dp[l][u][r][d+1] = max(dp[l][u][r][d + 1], dp[l][u][r][d] + add);
                    }
                }
            }
        }
    }
    printf("%d\n", ans);
    return 0;
}

Measured memory_bytes: 237824
package main

import (
	"fmt"
)

func main() {
	var n int
	fmt.Scan(&n)
	ns := make([][]int, n)
	for i := range ns {
		ns[i] = make([]int, 2)
	}
	for i := 0; i < n; i++ {
		var a int
		fmt.Scan(&a)
		if i-a >= 0 {
			ns[i-a][0]++
		}
		if i+a < n {
			ns[i+a][1]++
		}
	}
	var sum int
	for _, v := range ns {
		sum += v[0] * v[1]
	}
	fmt.Println(sum)
}


Measured memory_bytes: 18788
n, x = map(int, input().split())

def func(a, b):
    if a < b:
        a, b = b, a

    res = 0
    while b > 0:
        c, d = divmod(a, b)
        res += 2 * b * c
        a = b
        b = d
    
    return res - a

print(n + func(x, n-x))

Measured memory_bytes: 9128
n = int(input())
a = [int(x) for x in input().split()]
ans = []
for i in a:
  if i % 2 == 0:
    ans.append(i)

for i in ans:
  if i %3 == 0 or i %5 ==0:
    pass
  else:
    print('DENIED')
    quit()

print('APPROVED')

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define REP(i, a, n) for (int i = (a); i < (int)(n); ++i)
#define REPC(i, a, n) for (int i = (a); i <= (int)(n); ++i)
#define ALL(t) t.begin(), t.end()
#define RALL(t) t.rbegin(), t.rend()
#define MATINIT(type, row, col, init) \
  vector<vector<type>>(row, vector<type>(col, init));
#define Yes(cond) cout << (cond ? "Yes" : "No") << endl;
#define YES(cond) cout << (cond ? "YES" : "NO") << endl;
using namespace std;
using LL = long long;
using ULL = unsigned long long;
template <class T>
using VEC = std::vector<T>;
template <class T>
using MAT = std::vector<std::vector<T>>;
void DUMP() { cerr << endl; }
template <class Head, class... Tail>
void DUMP(Head &&head, Tail &&... tail) {
  cerr << head << ", ";
  DUMP(std::move(tail)...);
}
template <typename T>
ostream &operator<<(ostream &os, vector<T> &vec) {
  os << "{";
  for (auto v : vec) os << v << ",";
  os << "}";
  return os;
}
template <typename T1, typename T2>
ostream &operator<<(ostream &os, map<T1, T2> &m) {
  os << "{";
  for (auto p : m) os << p << ",";
  os << "}";
  return os;
}
template <typename T1, typename T2>
ostream &operator<<(ostream &os, pair<T1, T2> p) {
  os << "[" << p.first << " " << p.second << "]";
  return os;
}

int main() {
  int D, G;
  cin >> D >> G;
  VEC<int> P(D), C(D);
  REP(i, 0, D) cin >> P[i] >> C[i];
  VEC<LL> sum(D, 0);
  REP(i, 0, D) {
    REP(j, 0, P[i]) sum[i] += (i + 1) * 100;
    sum[i] += C[i];
  }
  int lim = 1 << (D + 1);
  int ans = INT32_MAX;
  REP(bit, 0, lim) {
    LL point = 0;
    VEC<bool> used(D, 0);
    int cnt = 0;
    REP(i, 0, D) {
      if (bit & (1 << i)) {
        point += sum[i];
        cnt += P[i];
        used[i] = 1;
      }
    }
    for (int i = D - 1; i >= 0; --i) {
      if (used[i]) continue;
      for (int a = 0; a < P[i] && point < G; ++a) {
        ++cnt;
        point += (i + 1) * 100;
      }
    }
    ans = min(ans, cnt);
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
import Control.Arrow
import Control.Monad
import Data.List
import qualified Data.ByteString.Char8 as B
import qualified Data.IntSet as S
import Data.Ord

main :: IO ()
main = readLn >>= readContents >>= print . solve 

solve :: [[Int]] -> Int
solve xs = calc acc0 . sortBy (flip compare) $ edit xs
    where
        calc acc (x : _ : zs) = calc (acc + x) zs
        calc acc [x] = acc + x
        calc acc _ = acc

        acc0 = negate . sum $ map last xs

        edit = map sum 

readLine :: IO [Int]
readLine = unfoldr (fmap (second (maybe B.empty snd . B.uncons)) . B.readInt) <$> B.getLine

readContents :: Int -> IO [[Int]]
readContents = flip replicateM readLine

Measured memory_bytes: 36220
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define REP(i,s,n) for(int i=s; i<(n); ++i)
#define ALL(n) begin(n),end(n)
using ll = long long;
const ll INF = 1e18;
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; }

int main(){
    ll N, D;
    cin >> N >> D;
    vector<ll> X(N), Y(N);
    REP(i,0,N){
        cin >> X[i] >> Y[i];
    }

    ll cnt = 0;
    REP(i, 0, N){
        if (X[i]*X[i]+Y[i]*Y[i] <= D*D){
            ++cnt;
        }
    }
    cout << cnt << endl;

    return 0;
}


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

//template
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(a);i>(b);i--)
#define ALL(v) (v).begin(),(v).end()
typedef long long int ll; typedef pair<ll, ll> P;
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<typename A,size_t N,typename T>void Fill(A(&array)[N],const T &val){fill((T*)array, (T*)(array+N), val);}
const int inf = INT_MAX / 2; const ll INF = LLONG_MAX / 2;
//template end



int main(){
    int x[2];
    rep(i,0,2)scanf("%d",&x[i]);
    printf("%d\n",abs(x[0]-x[1]));
    return 0;
}


Measured memory_bytes: 3216
#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")
typedef long long lint;
typedef unsigned int uint;
typedef pair<int, int> pii;
typedef pair<lint, lint> pll;
typedef unsigned long long ulint;
#define endl '\n'
#define fst first
#define sed second
#define pb push_back
#define mp make_pair
#define rint register int
#define newline putchar('\n')
#define leave_space putchar(' ')
#define all(x) (x).begin(), (x).end()
#define reveal(x) cerr << #x << " = " << (x) << endl
#define rep(it, f, e) for (rint it = (f); it <= int(e); ++it)
#define per(it, f, e) for (rint it = (f); it >= int(e); --it)
const int MAXN = 1e5 + 10;
vector<int> edge[MAXN], cycle;
struct DSU {
	int par[MAXN];
	DSU() {
		rep (i, 1, MAXN - 1) {
			par[i] = i;
		}
	}
	inline int find(int x) {
		return par[x] == x ? x : par[x] = find(par[x]);
	}
	inline void marry(int x, int y) {
		par[find(x)] = find(y);
	}
}	Dsu;
int val[MAXN], par[MAXN];
inline void dfs(int u, int col) {
	val[u] = col;
	for (auto v : edge[u]) {
		if (v == par[u]) continue;
		par[v] = u;
		dfs(v, -col);
		val[u] += val[v];
	}
}
int main() {
	ios::sync_with_stdio(false);
	cin.tie(NULL), cout.tie(NULL);
	int le1 = 1, le2 = 1;
	int n, m, u, v;
	cin >> n >> m;
	rep (i, 1, m) {
		cin >> u >> v;
		if (Dsu.find(u) != Dsu.find(v)) {
			Dsu.marry(u, v);
			edge[u].pb(v);
			edge[v].pb(u);
		} else {
			le1 = u, le2 = v;
		}
	}
	dfs(le1, 1);
	if (n == m) {
		for (int u = le2; u; u = par[u]) {
			cycle.pb(val[u]);
		}
        if (cycle.size() & 1) {
			if (val[le1] & 1) {
				cout << -1 << endl;
				return 0;
			}
			for (int u = le2; u; u = par[u]) {
				val[u] -= val[le1] / 2;
			}
        } else {
			if (val[le1]) {
				cout << -1 << endl;
				return 0;
			}
			sort(all(cycle));
			for (int u = le2; u; u = par[u]) {
				val[u] -= cycle[cycle.size() / 2 - 1];
			}
        }
	} else if (val[le1]) {
		cout << -1 << endl;
		return 0;
	}
	lint ans = 0;
	rep (i, 1, n) {
		ans += abs(val[i]);
	}
    cout << ans << endl;
	return 0;
}

Measured memory_bytes: 12412
#include <bits/stdc++.h>
#pragma GCC optimize("unroll-loops,no-stack-protector")
#pragma GCC target("sse,sse2,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define watch(x) cout << (#x) << " is " << (x) << endl

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;

const int MOD = 1e9 + 7;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n; cin >> n;
    vector<int> h(n);
    for(int i = 0; i < n; i++) cin >> h[i];
    vector<int> dp(n);
    dp[0] = 0;
    dp[1] = abs(h[1] - h[0]);
    for(int i = 2; i < n; i++) dp[i] = min(dp[i - 1] + abs(h[i] - h[i - 1]), dp[i - 2] + abs(h[i] - h[i - 2]));
    cout << dp[n - 1];

    return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
 #define int long long 
int n, a[200005];
signed main(){
    cin>>n;
    for(int i = 1; i <= n; i++){
        cin>>a[i];
        a[i] -= i;
    }
    sort(a+1, a+n+1);
    int b = a[(n+1)/2], ans =0;
    for(int i = 1; i <= n; i++){
        ans += abs(b - a[i]); 
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string S;
  cin >> S;
  if (S <= "2019/04/30") {
    cout << "Heisei" << endl;
  }
  else {
    cout << "TBD" << endl;
  }
  return 0;
}

Measured memory_bytes: 256
// 9:20
#include <iostream>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <utility>
#include <vector>
#include <map>
#include <deque>
#include <tuple>
using namespace std;
typedef long long ll;
#define for1(i,n) for (ll i=0;i<(n);(i)++)
#define for2(i,m,n) for (ll (i)=(m);(i)<(n);(i)++)
#define for3(i,m,n,d) for (ll (i)=(m);(i)<(n);(i)+=(d))
#define INF (1LL << 60)
#define STRING(str) #str
#define DEBUG 0
#if DEBUG
    #define trace(var) dump(STRING(var), var)
#else
    #define trace(var)
#endif

void dump(const string& name, const ll value)
{
    cerr << name << ": " << value << endl;
}

ll keta(ll n) {
    ll ret = 0;
    if (n == 0) return 1;
    while (n != 0) {
        n /= 10;
        ret++;
    }
    return ret;
}
void solve()
{
    ll ans = 0;
    ll N;
    cin >> N;

    vector<ll> divisor;
    for (ll i = 1; i * i <= N; ++i) {
        if (N % i != 0) continue;
        ll d = N / i;
        divisor.push_back(i);
        if (d != i) {
            divisor.push_back(d);
        }
    }
    sort(divisor.begin(), divisor.end());
    ans = INF;
    for (ll d1 : divisor) {
        ll d2 = N / d1;
        if (d1 > d2) break;
        ans = min(ans, keta(d2));
    }

    cout << ans << endl;
}

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


Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<cstdio>
#include<cstdlib>
#include<string>
#include<iostream>
#include <iomanip>
#include<queue>
#include<algorithm>
#include <functional>
#include<vector>
#include <math.h>
#include <numeric>
#include <stack>
#include <map>
using namespace std;

const int n_max = 100001;
long double W, H, x, y;
int ismany = 0;

int main() {
	cin >> W >> H >> x >> y;
	if ((x == (W / 2.0)) && (y == (H / 2.0))) ismany = 1;
	cout << W * H / 2.0 << endl;
	cout << ismany << endl;
}

Measured memory_bytes: 256
<?php
    $N = trim(fgets(STDIN));
    $K = trim(fgets(STDIN));
    $X = trim(fgets(STDIN));
    $Y = trim(fgets(STDIN));
    $ans = 0;
    for($i = 1; $i <= $N; $i++){
        if($i > $K){
            $ans += $Y;
        }else{
            $ans += $X;
        }
    }
    echo $ans;

?>

Measured memory_bytes: 4604
#include <bits/stdc++.h>
 
using namespace std;
typedef long long LL;
typedef pair<int,int> pii;
typedef int ftype;
typedef complex<ftype> point;
 
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second 
#define debug(x)  do{cerr<<#x<<": "<<x<<"\n";}while(0)
#define debugv(x) do{cerr<<#x<<": ";for(auto&e: (x))cerr<<e<<" ";cerr<<"\n";}while(0)
#define fori(i, n) for (int i = 0; i < (int)(n); ++i)
#define forn(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, n) for (int i = (int)(n); i >= 0; --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)
#define RETURN(x) do{cout << x << '\n'; return 0;}while(0)
#define FIRSTWIN do{cout << "Monocarp\n"; return 0;}while(0)
#define SECONDWIN do{cout << "Bicarp\n"; return 0;}while(0)

const int MAXN = 5e3+4;
const int MOD = 1e9+7;

int N;
char S[MAXN];
int z[MAXN];

int ans;
void zfunction(char *s, char *end) {
    int n = end-s;
    for (int i = 0; i < n; i++) z[i] = 0;

    for (int i = 1, l = 0, r = 0; i < n; ++i) {
        if (i <= r)
            z[i] = min (r - i + 1, z[i - l]);
        while (i + z[i] < n && s[z[i]] == s[i + z[i]])
            ++z[i];
        if (i + z[i] - 1 > r)
            l = i, r = i + z[i] - 1;
    }

    for (int i = 1; i < n; ++i) 
        ans = max(ans, min(i, z[i]));
}

int main() {
#ifdef OJ
    freopen("input.txt", "rt", stdin);
    //freopen("output.txt", "wt", stdout);
#endif
    ios::sync_with_stdio(false);
    cin.tie(0);

    cin >> N >> S;
    char *end = S+N;
    for (char *s = S; s+1 != end; s++) 
        zfunction(s,end);

    cout << ans << '\n';
    return 0;
}


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

using namespace std;

// MACROS

#define ll long long
#define ull unsigned long long
#define ld long double

#define vi vector<int>
#define vll vector<ll>
#define vld vector<ld>
#define u_s unordered_set

#define pii pair<int,int>
#define pll pair<ll,ll>

#define FOR(i, n) for (ll (i) = 0; i < n; i++)
#define FORN(i, a, b) for (ll (i) = a; i < b; i++)
#define FORE(i, l) for (auto (i) : l)

#define pb push_back
#define pob pop_back
#define emp emplace

#define in(n) cin >> (n);
#define debug(n) cout << #n << ": " << n << '\n';

// FUNCTIONS

template< typename T >
inline T gcd(T a, T b) { if (b) return gcd(b, a % b); return a; }

template< typename T >
inline T ext_gcd(T a, T b, T & x, T & y) { if (a == 0) { x = 0; y = 1; return b; } T x1, y1; T g = ext_gcd(b % a, a, x1, y1); x = y1 - (b / a) * x1; y = x1; return g; }

int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
    ll n;
    cin >> n;
    string s;
    cin >> s;
    if (n % 2 == 0 && s.substr(0, n / 2) == s.substr(n / 2, n / 2)) cout << "Yes\n";
    else cout << "No\n";
    	
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define fori(i, a, b) for(int i = (int) a; i <= (int) b; ++i)
#define rofi(i, b, a) for(int i = (int) b; i >= (int) a; --i)
#define foreach(tt, a) for(auto &tt: a)
#define all(a) begin(a), end(a)
#define csz(a) (int) a.size()
#define pb push_back
#define epb emplace_back
#define mp make_pair
#define load(a, v) fill(begin(a), end(a), v)
#define load_mem(a, v) memset(a, v, sizeof(a));
#define iostream_optimize() ios::sync_with_stdio(false); cin.tie(0);
using ll = long long;
const ll MOD = 1e9+7, LINF = 1e16+1;
const int INF = 1e9+1;
const double EPS = 1e-10;
const int dx[4] = {-1, 0, 1, 0}, dy[4] = {0, 1, 0, -1};
const ll P1 = 31, P2 = 37, M1 = 1e9+7, M2 = 1e9+9;

// #include <ext/pb_ds/tree_policy.hpp>
// #include <ext/pb_ds/assoc_container.hpp>
// using namespace __gnu_pbds;
// template <typename T>
// using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
/* <<<<<<<<<<<<<<<<<<<<<<<<<<<< END TEMPLATE >>>>>>>>>>>>>>>>>>>>>>>>>>> */
const int N = 2001;

int n, k, q, ans = INF, a[N];
vector<int> vals;

bool check(int lo, int hi) {
	vector<pair<int,int> > segs;
	int last = 0;
	fori(i, 0, n-1) {
		if(a[i] < lo) {
			if(i-1 - last  + 1 >= k) segs.epb(last, i-1);
			last = i+1;
		}
	}
	if(n-1 - last + 1 >= k) segs.epb(last, n-1);
	int res = 0;
	foreach(p, segs) {
		int cnt_valid = 0;
		fori(i, p.first, p.second) {
			cnt_valid += a[i] <= hi;
		}
		// cout << p.first << ' ' << p.second << ' ' << cnt_valid << endl;
		res += min(cnt_valid, p.second - p.first - k + 2);
	}
	// cout << res << endl;
	return res >= q;
}

int main() {
	iostream_optimize();
	cin >> n >> k >> q;
	fori(i, 0, n-1) cin >> a[i], vals.pb(a[i]);
	sort(all(vals));
	vals.resize(unique(all(vals)) - vals.begin());
	foreach(x, vals) {
		int l = x, r = INF;
		while(l < r) {
			int mid = l+r >> 1;
			if(check(x, mid)) r = mid;
			else l = mid+1;
		}
		if(r != INF) ans = min(l - x, ans);
		// cout << x << ' ' << l << ' ' << ans << endl;
	}
	// cout << vals[0] << ' ' << vals[4] << ' ' << vals[4] - vals[0] << endl;
	// check(vals[0], vals[4]);
	cout << ans;
}

Measured memory_bytes: 256
listC = []
while True:
    n, x = map(int,input().split())
    if n == 0 and x == 0:
        break

    counter = 0


    for i in range(1, n+1):
        for j in range(i+1, n+1):
            for k in range(j+1, n+1):
                if i + j + k == x:
                    counter += 1
    listC.append(counter)
    counter = 0

for h in listC:
    print(h)



Measured memory_bytes: 5592
#include <bits/stdc++.h>
using namespace std;
struct UnionFind
{
    //自身が親であれば、その集合に属する頂点数に-1を掛けたもの
    //そうでなければ親のid
    vector<int> r;

    UnionFind(int N)
    {
        r = vector<int>(N, -1);
    }

    int root(int x)
    {
        if (r[x] < 0)
            return x;
        return r[x] = root(r[x]);
    }

    bool unite(int x, int y)
    {
        x = root(x);
        y = root(y);
        if (x == y)
            return false;
        if (r[x] > r[y])
            swap(x, y);
        r[x] += r[y];
        r[y] = x;
        return true;
    }

    int size(int x)
    {
        return -r[root(x)];
    }
    bool same(int x, int y)
    { // 2つのデータx, yが属する木が同じならtrueを返す
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
};
int main()
{
    int N, Q, i, meirei, A, B;
    cin >> N >> Q;
    UnionFind tree(N);
    for (i = 0; i < Q; i++)
    {
        cin >> meirei >> A >> B;
        if (meirei == 0)
        {
            tree.unite(A, B);
        }
        else
        {
            if (tree.same(A, B))
            {
                cout << 1 << endl;
            }
            else
            {
                cout << 0 << endl;
            }
        }
    }
}

Measured memory_bytes: 4056
#include<stdio.h>
#include<stdlib.h>

#define SET_MAX 5

/* A,B?????????????????????????´?????????????????§??????? */
typedef struct{
	int A;
	int B;
}SET;

/* main??¢??° */
int main(void){
	SET *card[SET_MAX];
	int n[SET_MAX];
	int A_score, B_score, set_cnt, i, j;

	for(i = 0;i < SET_MAX;i++)
		card[i] = NULL;

	/* ??\??????????????????????????? */
	for(set_cnt = 0;set_cnt < 5;set_cnt++){
		scanf("%d", &n[set_cnt]);
		if(n[set_cnt] == 0)break;
		card[set_cnt] = (SET*)malloc(sizeof(SET) * n[set_cnt]);
		if(card[set_cnt] == NULL){
			for(i = 0;i < set_cnt;i++)free(card[i]);
			exit(1);
		}
		for(i = 0;i < n[set_cnt];i++)
			scanf("%d %d", &card[set_cnt][i].A, &card[set_cnt][i].B);
	}

	/* ????????????????????????A,B?????????????¨?????????????????????? */
	for(i = 0;i < set_cnt;i++){
		A_score = B_score = 0;
		for(j = 0;j < n[i];j++){
			if(card[i][j].A > card[i][j].B){
				A_score += card[i][j].A + card[i][j].B;
			}else if(card[i][j].A < card[i][j].B){
				B_score += card[i][j].A + card[i][j].B;
			}else{
				A_score += card[i][j].A;
				B_score += card[i][j].B;
			}
		}

		printf("%d %d\n", A_score, B_score);
	}

	/* ?????¢???????????? */
	for(i = 0;i < set_cnt;i++)
		free(card[i]);

	return 0;
}

Measured memory_bytes: 1804
# pragma GCC optimize("O3")
# include <bits/stdc++.h>
std::pair<int,int> DR[] = {{-1,0},{0,1},{1,0},{0,-1},{-1,1},{-1,-1},{1,1},{1,-1}};
# define maxn 100005
# define ll long long
# define clock (clock() * 1000.0 / CLOCKS_PER_SEC)
# define rc(s) return cout << s,0
# define _ ios_base::sync_with_stdio(false);cin.tie(0);cerr.tie(0);cout.tie(0);
# define db(x) cerr << #x << " = " << x << '\n'
# define pb push_back
# define mp make_pair
# define sz(x) (int)((x).size())
//# define int ll
using namespace std;

int32_t main(){_
    //freopen("input","r",stdin);
	int n;
	cin >> n;
	int tmp = n;
	int ans = 0;
	while(n)
	{
		ans += n % 10;
		n /= 10;
	}
	if(tmp % ans == 0) rc("Yes");
	rc("No");
}


Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vin=vector<int>;
using vll=vector<long long>;
using vvin=vector<vector<int>>;
using vvll=vector<vector<long long>>;
using vstr=vector<string>;
using vvstr=vector<vector<string>>;
using vch=vector<char>;
using vvch=vector<vector<char>>;
using vbo=vector<bool>;
using vvbo=vector<vector<bool>>;
using vpii=vector<pair<int,int>>;
using pqsin=priority_queue<int,vector<int>,greater<int>>;
#define mp make_pair
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep2(i,s,n) for(int i=(s);i<(int)(n);i++)
#define all(v) v.begin(),v.end()
#define decp(n) cout<<fixed<<setprecision((int)n)
const int inf=1e9+7;
const ll INF=1e18;

int main(){
    int n;cin>>n;
    ll k;cin>>k;
    vll num(100050);
    rep(i,n){
        int a,b;cin>>a>>b;
        num[a]+=(ll)b;
    }
    ll sum=0;
    rep(i,100050){
        if(sum+num[i]>=(ll)k){
            cout<<i<<endl;
            return 0;
        }
        else sum+=(ll)num[i];
    }
}

Measured memory_bytes: 1024
#include <iostream>
#include <vector>

using namespace std;

int main(){
    int N,K;
    cin >> N >> K;
    vector<long int> H(N);
    for (int i = 0; i < N;i++)
        cin >> H[i];
    int cnt = 0;
    for (int i = 0; i < N;i++){
        if(H[i] >= K)
            cnt++;
    }
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
#include<iostream>
#include<string>
#include<map>
#include<cmath>
#include<vector>
#include<queue>
#include<cstdio>
#include<math.h>
#include<bitset>
#include<algorithm>
#include<iomanip>
#include<list>
#include<set>
#include<utility>
using namespace std;

//repetition
//------------------------------------------

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)  FOR(i,0,n)
//#define INF (1 << 30)
#define pii pair<int, int>

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

static const int INF = 1000000010;
int d[510][510];
string s[510];
int l[110];

int main() {
  int n;
   cin >> n;
   int ans = n / 3;
   cout << ans << endl;
}


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

#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a, 0, sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
#define SIZE(array) (sizeof(array) / sizeof(array[0]))

#define MAXAS(x,v) x = max(x,v)

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

#define PI 3.141592653589793

#define MOD 1000000007L
#define INF 100000000000

signed main() {
	int n, m;
	cin >> n >> m;
	int c[n];
	ZERO(c);
	for (size_t i = 0; i < m; i++) {
		int a, b;
		cin >> a >> b;
		c[a - 1]++;
		c[b - 1]++;
	}
	for (size_t i = 0; i < n; i++) {
		cout << c[i] << endl;
	}
}


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

int main(){
  int n;
  cin >> n;
  bool ans= false;
  for(int i=1; i<10; ++i){
    if(n%i == 0 && n/i < 10) ans = true;
  }
  if(ans) cout << "Yes" << endl;
  else cout << "No" << endl;
}

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

int main(){
  string T;
  cin >>T;
  while(T.length()!=0){
    if(T.length()>=5){
      if (T.substr(T.length()-5)=="dream"){
      T=T.substr(0,T.length()-5);
      continue;
      }
    }
    if(T.length()>=7){
      if(T.substr(T.length()-7)=="dreamer"){
      T=T.substr(0,T.length()-7);
       continue;
      }
    }
    if(T.length()>=5){
     if(T.substr(T.length()-5)=="erase"){
      T=T.substr(0,T.length()-5);
       continue;
     }
    }
    if(T.length()>=6){
     if(T.substr(T.length()-6)=="eraser"){
      T=T.substr(0,T.length()-6);
       continue;
     }
    }
    cout<<"NO"<<endl;
    return 0;
  }
  cout<<"YES"<<endl;
  return 0;
  
}

      

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

using namespace std;

#define int long long
#define all(v) begin(v), end(v)
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define reps(i, s, n) for(int i = (int)(s); i < (int)(n); i++)
#define min(...) min({__VA_ARGS__})
#define max(...) max({__VA_ARGS__})

const int inf = 1LL << 55;
const int mod = 1e9 + 7;

signed main()
{
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cout << fixed << setprecision(12);

  int n;
  string  s;
  cin >> n >> s;
  int x = 0, y = 0;
  rep(i, n) {
    if(s[i] == 'I') x++;
    else x--;
    y = max(x, y);
  }
  cout << y << endl;

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stdio.h>
#include <sstream>
#include <math.h>
#include <map>
#include <ios>     // std::left, std::right
#include <iomanip> // std::setw(int), std::setfill(char)
using namespace std;


int main(){
  int N;
  int L;
  int L_sum=0;
  vector<int> LV;
  cin>>N;
  for(int i=0;i<N;++i){
    cin>>L;
    LV.push_back(L);
    L_sum+=L;
  }
  int judge=0;
  for(int i=0;i<N;++i){
    if(LV[i]>=(L_sum-LV[i])){
      judge=1;
      break;
    }
  }
  if(judge==1){
    cout<<"No"<<"\n";
  }
  else{
    cout<<"Yes"<<"\n";
  }
return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		long n = sc.nextLong();

		long sum = 0;

		for (int i = 1; i <= n; i++) {
			if (i % 3 == 0 || i % 5 == 0) {
				continue;
			}

			sum += i;
		}

		System.out.println(sum);
	}
}


Measured memory_bytes: 35728
M, N = map(int, raw_input().split())
K = input()

D = {}

for i in range(M+1):
    D[i, 0] = 0, 0
for j in range(N+1):
    D[0, j] = 0, 0

for i in range(1, M+1):
    a = raw_input()
    for j in range(1, N+1):
        if a[j-1] == 'J':
            D[i, j] = (D[i-1, j][0] + D[i, j-1][0] - D[i-1, j-1][0] + 1,
                       D[i-1, j][1] + D[i, j-1][1] - D[i-1, j-1][1])
        elif a[j-1] == 'O':
            D[i, j] = (D[i-1, j][0] + D[i, j-1][0] - D[i-1, j-1][0],
                       D[i-1, j][1] + D[i, j-1][1] - D[i-1, j-1][1] + 1)
        else:
            D[i, j] = (D[i-1, j][0] + D[i, j-1][0] - D[i-1, j-1][0],
                       D[i-1, j][1] + D[i, j-1][1] - D[i-1, j-1][1])

for _ in range(K):
    b0, b1, b2, b3 = map(int, raw_input().split())
    nJ = D[b2, b3][0]-D[b0-1, b3][0]-D[b2, b1-1][0]+D[b0-1, b1-1][0]
    nO = D[b2, b3][1]-D[b0-1, b3][1]-D[b2, b1-1][1]+D[b0-1, b1-1][1]
    nI = (b2-b0+1)*(b3-b1+1)-nJ-nO
    print nJ, nO, nI

Measured memory_bytes: 266268
#!/usr/bin/env python
# coding: utf-8

# In[21]:


P = int(input())


# In[22]:


# i_list = list(range(1, P+1))
# p_list = i_list[1:]
# p_list.append(i_list[0])

# # print(i_list, p_list)

# ans = 0
# for i in range(P):
#     ans += i_list[i]%p_list[i]
# print(ans)

# ans = sum(range(1,P))
ans = P*(P-1)//2
print(ans)


# In[ ]:






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

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
const ull mod = 1e9 + 7;
#define REP(i,n) for(int i=0;i<(int)n;++i)

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

template<class S, class T> ostream& operator << (ostream& os, const pair<S, T> v){
  os << "(" << v.first << ", " << v.second << ")"; return os;
}
template<class T> ostream& operator << (ostream& os, const vector<T> v){
  for(int i = 0; i < (int)v.size(); i++){if(i > 0){os << " ";} os << v[i];} return os;
}
template<class T> ostream& operator << (ostream& os, const vector<vector<T>> v){
  for(int i = 0; i < (int)v.size(); i++){if(i > 0){os << endl;} os << v[i];} return os;
}

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

    vector<ll> x(4);
    REP(i, 4) cin >> x[i];
    cout << (x[0] == x[2] ? 0 : 1) << endl;
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<iostream>
using namespace std;
bool is_prime[200009]; 
int main()
{
	for(int i = 0;i<=200002;i++)
	{
		is_prime[i] = true;
	}
	for(int i = 2;i<=200002;i++)
	{
		if(is_prime[i])
		{
			for(int j = 2*i;j<=200002;j+=i)
			{
				is_prime[j] = false;
			}
		}
	}
	//cout<<is_prime[100003]<<endl;
	int n;
	cin>>n;
	for(int i=n;;i++)
	if(is_prime[i])
	{
		cout<<i;
		break;
	}
	return 0;	
}

Measured memory_bytes: 384
#include <iostream>

using namespace std;

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

    int ans = 0;
    for (int i = 3; i <= N; i+=2) {
        int cnt = 0;
        for (int j = 1; j * j <= i; j++) {
            if (i % j == 0) {
                cnt += 2;
                if (j * j == i)
                    cnt--;
            }
        }
        if (cnt == 8)
            ans++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3540
#include<iostream>
#include<cmath>
#include<vector>
#include<algorithm>
using namespace std;

int main()
{
  int n;
  cin >> n;
  vector<int> dp(n), input(n);
  fill(dp.begin(), dp.end(), 1e7);
  for (int i = 0; i < n; i++)
    cin >> input[i];

  dp[0] = 0;
  dp[1] = abs(input[0] - input[1]);
  if (n == 2)
  {
    cout << dp[1];
    return 0;
  }
  for (int i = 2; i < n; i++)
  {
    dp[i] = min(dp[i - 2] + abs(input[i] - input[i - 2]), dp[i - 1] + abs(input[i] - input[i - 1]));
  }
  cout << dp[n - 1];
  return 0;
}


Measured memory_bytes: 1024
n = int(input())
s = input()
pre = s[0]
i = 1
a = ''
while True:
    if i == n:
        a += pre
        break
    if s[i] == pre:
        i += 1
        continue
    a += pre
    pre = s[i]
    i += 1
print(len(a))



Measured memory_bytes: 3316
#include <cstdio>
#include <memory.h>
#define N 100001
int m, xp[N], yp[N], f[N];
int xlast[N], ylast[N];
int xbel[N], ybel[N];
int xnum[N] = {0}, ynum[N] = {0};
int fa(int x) {
	return x == f[x] ? x : f[x] = fa(f[x]);
}
inline void merge(int x, int y) {
	if (fa(x) != fa(y)) f[f[x]] = y;
}
int main() {
	#define init(M) memset(M, -1, sizeof(M))
	init(xlast);
	init(ylast);
	init(xbel);
	init(ybel);
	scanf("%d", &m);
	for (int i = 0; i < m; i++) f[i] = i;
	for (int i = 0; i < m; i++) {
		scanf("%d%d", xp+i, yp+i);
		if (xlast[xp[i]] != -1) merge(xlast[xp[i]], i);
		else xlast[xp[i]] = i;
		if (ylast[yp[i]] != -1) merge(ylast[yp[i]], i);
		else ylast[yp[i]] = i;
	}
	for (int i = 0; i < m; i++) {
		xbel[xp[i]] = ybel[yp[i]] = fa(i);
	}
	for (int i = 1; i <= 100000; i++) {
		if (xbel[i] != -1) xnum[xbel[i]]++;
		if (ybel[i] != -1) ynum[ybel[i]]++;
	}
	long long ans = -m;
	for (int i = 0; i < m; i++) {
		ans += 1ll * xnum[i] * ynum[i];
	}
	printf("%lld", ans);
}

Measured memory_bytes: 3200
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		try (Scanner sc = new Scanner(System.in)) {
			while (true) {
				String x = sc.nextLine();
				if ("0".equals(x)) {
					break;
				}
				long sum = 0;
				for (int i = 0; i < x.length(); i++) {
					sum += x.charAt(i) - '0';
				}
				System.out.println(sum);
			}
		}
	}
}


Measured memory_bytes: 26676
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
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 main(){
  ll n;
  cin >>n;
  ll t[n];
  for(ll i=0;i<n;i++) cin >>t[i];
  ll ans=t[0];
  for(ll i=1;i<n;i++) ans=lcm(ans,t[i]);
  cout <<ans<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define shosu(n) setprecision(n)
using namespace std;
int main() {
  long long N, A, B;
  cin >> N >> A >> B;
  if (A == B || N == 2)
    cout << 1 << endl;
  else if (A != B && N == 1 || A > B)
    cout << 0 << endl;
  else
    cout << (B - A) * (N - 2) + 1 << endl;
  return 0;
}


Measured memory_bytes: 256