akhauriyash/Code-Regression huggingface dataset:
k,s = map(int,input().split())

ans = 0
if(s == 0):
  print(1)
  exit()
elif(s == 3*k):
  print(1)
  exit()
  
for i in range(0,k+1):
  for j in range(0,k+1):
    z = s - i - j
    if(z >= 0 and z <= k):
      ans += 1
        
print(ans)

Measured memory_bytes: 40684
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < n; i++)
#define rep2(i,a,n) for (int i = a; i < n; i++)
using namespace std;
int N, M;
vector<pair<int, int>> P;

struct UnionFind {
    vector<int> par;

    UnionFind(int N): par(N) {
        rep(i, N) par[i] = i;
    }

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

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

    void unite(int x, int y) {
        int rx = root(x);
        int ry = root(y);

        if (same(rx, ry)) return;

        par[rx] = ry;
    }

};


void init() {
    cin >> N >> M;

    rep(i, M) {
        int a, b; cin >> a >> b;
        a--; b--;
        P.push_back({a, b});
    }

}

void solve() {
    int res =0;
    rep(de, M) {
        bool flag = false;
        UnionFind uf(N);
        rep(i, M) {
            if (i == de) continue;
            uf.unite(P[i].first, P[i].second);
        }
        int stad = 0;
        for (int i = 1; i < N; i++) {
            if (!uf.same(stad, i)) flag = true;
        }

        if (flag) res++;
    }

    printf("%d\n", res);
}

int main() {
    init();
    solve();
    return 0;
}


Measured memory_bytes: 3760
#include<cstdio>
#include<functional>
#include<algorithm>
#include<cstring>
using namespace std;
int main(void)
{
	int n,i,j,cnt,keta,x;
	scanf("%d",&n);
	cnt=0;
	for(i=1;i<=n;i++)	{
		keta=0;
		x=i;
		while(x>0)	{
			x/=10;
			keta++;
		}
		if(keta%2==1)	cnt++;
	}
	printf("%d\n",cnt);
    return 0;
}

Measured memory_bytes: 128
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <cstring>
#include <vector>
#include <map>
#include <utility>
#include <complex>
#include <stack>

using namespace std;

typedef complex<double> P;

int main(){
	int x;
	while(cin>>x){
		int ans = 0;
		for (int i = 0; i < 600; i += x)
		{
			ans += i * i * x;
		}

		cout << ans << endl;
	}

	return 0;
}

Measured memory_bytes: 0
#include<iostream>
#include<string>
#include<stack>
#include<queue>
#include<deque>
#include<vector>
#include<algorithm>
#include<unordered_map>
#include<map>
#include<climits>
#define ll long long
#define vi vector<int>
#define vll vector<long long>
#define vvi vector<vector<int>>
#define vvll vector<vector<long long>>
using namespace std;

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

    int ans = INT_MAX;
    int len = p.length();
    for(int i = 0;i<=s.length()-len;i++)
    {
        int count = 0;
        for(int j = 0;j<len;j++)
        {
            if(p[j]==s[i+j])
            {
                count++;
            }
        }
        ans = min(ans,len-count);
    }
    cout<<ans;
return 0;
}

Measured memory_bytes: 3188
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cassert>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <iostream>
using namespace std;

/* debug macros */
#ifdef WAFDAYO
#define DBG_PRINT(s, t, u) { std::cerr << s << " \e[2m=\e[m \e[1m" << t << "\e[m" << u; }
#else
#define DBG_PRINT(s, t, u) {}
#endif
#define dbg(x) DBG_PRINT(#x, x, std::endl)
#define dbgc(x) DBG_PRINT(#x, x, ", ")
#define idbg(x, i) DBG_PRINT(#x "[" << i << "]", x[i], std::endl)
#define idbgc(x, i) DBG_PRINT(#x "[" << i << "]", x[i], ", ")

/* IO utilities */
struct read_item { read_item() {}; template<class T> operator T() { T t; std::cin >> t; return t; } };

/* types and constants */
typedef long long i64;
const i64 inf = (i64)1.05e18;
// const int inf = (int)1.05e9;

int main() {

	const int n = read_item();
	vector<pair<i64, i64>> segs(n);

	for(int i = 0; i < n; i++) {
		const i64 x = read_item();
		const i64 l = read_item();
		segs[i] = {x - l, x + l};
	}

	sort(segs.begin(), segs.end(),
		[](const pair<i64, i64>& l, const pair<i64,i64>& r) { return l.second < r.second; });

	int ans = 0;
	i64 last = -1e10;

	for(int i = 0; i < n; i++) {
		i64 l = segs[i].first, r = segs[i].second;
		dbgc(l); dbgc(r);
		if(last > l) {
			continue;
		}
		dbg(last);
		last = r;
		ans += 1;
	}

	printf("%d\n", ans);

	return 0;
}

/* wafdayo~~~ */


Measured memory_bytes: 1792
N, M = map(int, input().split())
L = []
for i in range(N):
  L.append(list(map(int, input().split())))
  
#M種にいくつ票が入るか入れる
cnt = [0] * M


#N人の中でj番目の人の中でk番目の食べ物が好きであるかcntの票を足す
for j in range(N):
  for k in range(1, L[j][0]+1):
    cnt[L[j][k]-1]+= 1

#Nと同じ票入っているものだけcount
print(cnt.count(N))

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)

using namespace std;
typedef long long ll;
typedef unsigned long ul;
typedef pair<ul, ul> P;

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

int main(){
    int A, B, C;

    cin >> A >> B >> C;

    A -= B;

    if(C > A){
        cout << C - A << endl;
    } else {
        cout << 0 << endl;
    }
}

Measured memory_bytes: 256
N,L=map(int,input().split())
score = [L+i for i in range(N)]
SUM=sum(score)

MIN=10**9
argmin=-1
for i in range(N):
  res = abs(SUM - (SUM-score[i]))
  if res < MIN:
    MIN = res
    argmin=i

print(SUM-score[argmin])

Measured memory_bytes: 9136
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define In_The_Name_Of_Allah_The_Merciful ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define Alhamdulillah return 0;
#define loop(i,k,n) for (ll i = k ; i < n ; ++i)
#define all(v) v.begin(),v.end()
#define debug(n) cerr << "[" << #n << " = " << n << "]" << endl

void Suhaib_Sawalha (){

    int n , k;
    cin >> n >> k;
    int a[n];
    for (int i = 0 ; i < n ; ++i)
        cin >> a[i];

    sort(a,a+n);
    int ans = 0;
    for (int i = 0 ; i < k ; ++i)
        ans += a[i];
    cout << ans;

}

int main(){
                                In_The_Name_Of_Allah_The_Merciful   /* بسم الله الرحمن الرحيم  */
#ifndef ONLINE_JUDGE
    freopen("SuhaibSawalha1.txt","r",stdin);
#endif
//int _;for(cin>>_;_;--_,cout<<endl)
        Suhaib_Sawalha();
                                         Alhamdulillah                    /* الحمد لله */
}


Measured memory_bytes: 3644
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
typedef long long ll;

int main(){
    int a, b, c;
    cin >> a >> b >> c;

    if((a < c && c < b) || (a > c && c > b)){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <cstring>
#include <cstdlib>
#include <utility>
#include <cstdio>
#include <vector>
#include <string>
#include <queue>
#include <stack>
#include <cmath>
#include <set>
#include <map>
using ll = long long;
using itn = int;
using namespace std;

int main(){
    int a[5];
    int sum=0;
    for(int i=0; i<5; i++){
        cin >> a[i];
        sum += ((a[i]+9)/10)*10;
    }
    int ans = sum;
    for(int i=0; i<5; i++){
        ans = min(ans,sum-((a[i]+9)/10)*10+a[i]);
    }
    cout << ans << endl;
}


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

#define ll long long
#define mod 1000000007
#define mod2 998244353
#define pii pair<ll,ll>
#define pb push_back

#define debug(a) { cout << #a << " = " << a << endl;}

void sep() {
    cout << "-------------BLOCK-----------------\n";
}

template<typename T>
void debugv(vector<T> arr) {
    for (auto t: arr)
        cout << t << " ";
    cout << "\n";
}

template<typename T>
void debugarr(T arr, int n) {
    for (int i=0;i<n;i++) cout << arr[i] << " ";
    cout << "\n";
}

ll __min(ll a, ll b) {
    return a < b ? a : b;
}

ll __max(ll a, ll b) {
    return a > b ? a : b;
}

const int maxn = 1e5+1;
ll arr[maxn], n, m, t, k, q;
unordered_map<ll,ll> u;

vector<vector<ll>> ajd;
vector<bool> vis;

void dfs(ll u=0) {
    if (vis[u]) return;
    vis[u] = true;
    for (ll v: ajd[u]) {
        if (!vis[v])
            dfs(v);
    }
}

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cin>>n>>m;
    ll a,b;
    ajd.resize(n);
    vis.resize(n, false);
    for (int i=0;i<m;i++) {
        cin>>a>>b;
        --a;--b;
        ajd[a].push_back(b);
        ajd[b].push_back(a);
    }
    ll ans=0;
    for (int i=0;i<n;i++) {
        if (!vis[i]) {
            ans++;
            dfs(i);
        }
    }
    cout << ans - 1<< endl;
}


Measured memory_bytes: 9796
N = int(input())
count = 0
count_temp = 0
for i in range(3,N+1, 2):
  count_temp = 0
  for j in range(1, i+1, 2):
    if i % j == 0:
      count_temp += 1
  if count_temp == 8:
    count += 1
print(count)

Measured memory_bytes: 3060
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<map>
using namespace std;
int main(){
    string log[]={"Opened by ","Closed by ","Unknown "};
    int state=0;
    map<string,int>M;
    int n;
    cin>>n;
    while(n--){
        string str;
        cin>>str;
        M[str]=1;
    }
    cin>>n;
    while(n--){
        string str;
        cin>>str;
        if(M.find(str)!=M.end())cout<<log[state]<<str<<endl;
        else{
            cout<<log[2]<<str<<endl;
            continue;
        }
        state=1-state;
    }
    return 0;
}

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

using namespace std;

#define ll long long

int main()
{
    int h,a;
    cin>>h>>a;
    int ans;
    if(h%a == 0)
    {
        ans =  h/a;
    }
    else
    {
        ans =  h/a+1;
    }
    cout<<ans;
}

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<int, int>;
using namespace std;

int dp[101];

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

    for (int i=0; i<n; ++i) {
        if (i == 0) dp[i] = h[i];
        else {
            if (h[i-1] <= h[i]) {
                dp[i] = dp[i-1] + (h[i] - h[i-1]);
            }
            else {
                dp[i] = dp[i-1];
            }
        }
    }

    cout << dp[n-1] << endl;
}


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

inline int read(){
	re int ans = 0;re bool f = 1;re char ch = getchar();
	while(ch<'0'||ch>'9'){if (ch=='-')f = 0;ch = getchar();}
	while(ch>='0'&&ch<='9'){
		ans = (ans<<3)+(ans<<1)+(ch^48);
		ch = getchar();
	}
	return f?ans:~(ans-1);
}

signed main(void){
	int a = read();
	printf("%lld",a+a*a+a*a*a);
	return 0;
}

Measured memory_bytes: 3772
#include <bits/stdc++.h>
using namespace std;
using Int = long long;
Int dp[100010][3];
const Int INF = 1e18;
int main() {
    int N; cin >> N;
    vector<Int> A(N);
    vector<char> op(N - 1);
    for (int i = 0; i < N; i++) {
        cin >> A[i];
        if (i != N - 1) cin >> op[i];
    }
    dp[0][0] = A[0];
    dp[0][1] = dp[0][2] = -INF;
    for (int i = 1; i < N; i++) {
        if (op[i - 1] == '+') {
            dp[i][0] = max({dp[i - 1][0] + A[i], dp[i - 1][1] + A[i], dp[i - 1][2] + A[i]});
            dp[i][1] = max(dp[i - 1][1] - A[i], dp[i - 1][2] - A[i]);
            dp[i][2] = dp[i - 1][2] + A[i];
        } else {
            dp[i][0] = max({dp[i - 1][0] - A[i], dp[i - 1][1] - A[i], dp[i - 1][2] - A[i]});
            dp[i][1] = max({dp[i - 1][0] - A[i], dp[i - 1][1] - A[i], dp[i - 1][1] + A[i], dp[i - 1][2] - A[i], dp[i - 1][2] + A[i]});
            dp[i][2] = max({dp[i - 1][1] + A[i], dp[i - 1][2] - A[i], dp[i - 1][2] + A[i]});
        }
    }
    cout << max({dp[N - 1][0], dp[N - 1][1], dp[N - 1][2]}) << endl;
    return 0;
}


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

int gcd(int x, int y){
    if(x<y)  swap(x,y);
    int r;
    while(y>0){
        r=x%y; 
        x=y;
        y=r;
    }
    cout << x <<endl;
    return 0;
}

int main(){
    int x, y;
    cin >> x >> y;
    gcd(x,y);
    return 0;
}


Measured memory_bytes: 3132
N, M = map(int, input().split())
LPY = []
for i in range(M):
    p, y = map(int, input().split())
    LPY.append([i, p, y]) # ラベル,県,年

# 県,年を県優先でソート
LPY = sorted(LPY, key=lambda x:(x[1], x[2]))

# xを追加
x = 1
for i in range(M-1):
    LPY[i].append(x)
    if LPY[i][1] == LPY[i+1][1]:
        x += 1
    else:
        x = 1
LPY[M-1].append(x)

# LPYを元にラベルと番号のリストを作成
ans = []
for i in range(M):
    label = LPY[i][0]
    p = LPY[i][1]
    x = LPY[i][3]
    num = "{0:06d}".format(p) + "{0:06d}".format(x)
    ans.append([label, num])

# ラベル順にソート
ans.sort()

# 出力
for i in range(M):
    print(ans[i][1])

Measured memory_bytes: 47384
import java.util.Scanner;

public class Main {
    static Scanner sc = new Scanner(System.in);
    static long check = 1000000000000000000L;

    public static void main(String[] args) {
        int n = sc.nextInt();
        long arr[] = new long[n];
        for (int i = 0; i < n; i++){
            arr[i] = sc.nextLong();
        }
        long ans = 1;
        for (int i = 0; i < n; i++){
            long tmp = ans;
            ans *= arr[i];
            if (ans < 0 || ans < tmp){
                ans = -1;
                break;
            }
        }
        for (int i = 0; i < n; i++){
            if (arr[i] == 0){
                ans = 0;
                break;
            }
        }
        if (ans > check){
            System.out.println(-1);
        } else {
            System.out.println(ans);
        }
    }
}


Measured memory_bytes: 61304
#include <iostream>

using namespace std;

#define min(a, b) ((a) < (b)? (a):(b))
#define max(a, b) ((a) > (b)? (a):(b))

int main() {
	int a, b, c, d; cin >> a >> b >> c >> d;

	cout<< max(a*b, c*d) << endl;;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define int long long
#define vec(a,n) vector<int> (a)((n))
#define Vec(a,n) vector<string> (a)((n))
#define twovec(a,n,m) vector<vector<int>> a(n,vector<int>(m,0))
#define Twovec(a,n,m) vector<vector<double>> a(n,vector<double>(m,0))
#define P pair<int,int>
#define All(a) (a).begin(),(a).end()
#define Sort(a) sort(All(a))
#define Reverse(a) reverse(All(a))
#define PQ(n) priority_queue<P,vector<P>,greater<P>> (n)
#define pq(n) priority_queue<int> (n)
using namespace std;
int max_int = 1000000007;
void Debug(auto a);
int nibutan(auto a,auto b);

signed main(){
    int n,x;
    cin >> n >> x;
    vec(a,n);
    vec(b,n-1);
    REP(i,n){
        cin >> a[i];
    }
    REP(i,n-1){
        b[i] = a[i] + a[i+1] - x;
    }
    int ans = 0;
    REP(i,n-2){
        if(b[i]<=0){
            continue;
        }
        else{
            if(a[i+1]<b[i]){
                ans += b[i];
                b[i+1] -= a[i+1];
            }
            else{
                ans += b[i];
                b[i+1] -= b[i];
            }
        }
    }
    if(b[n-2]>0){
        ans += b[n-2];
    }
    cout << ans << endl;
    return 0;
}



void Debug(auto a){
    cout << "{ ";
    for(auto b: a){
        cout << b << " ";
    }
    cout << "}" << endl;
}
int nibutan(auto a,auto b){
    int x = lower_bound(All(a),b) - a.begin();
    return x-1;
}

Measured memory_bytes: 1792
from collections import deque


def read_int():
    return int(input().strip())


def read_ints():
    return list(map(int, input().strip().split(' ')))


def solve():
    N, K, C = read_ints()
    S = input().strip()
    earliest = []
    i = 0
    while len(earliest) < K:
        if S[i] == 'o':
            earliest.append(i)
            i += C+1
        else:
            i += 1
    latest = []
    i = N-1
    while len(latest) < K:
        if S[i] == 'o':
            latest.append(i)
            i -= C+1
        else:
            i -= 1
    latest.reverse()
    for i, j in zip(earliest, latest):
        if i == j:
            print(i+1)


if __name__ == '__main__':
    solve()


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

int main() {
  int H, W;
  cin >> H >> W;
  vector<string> data(H);
  for (int i = 0; i < H; i++) {
    cin >> data.at(i);
  }
  vector<vector<char>> answer(H, vector<char>(W));
  for (int i = 0; i < H; i++) {
    for (int j = 0; j < W; j++) {
      if (data.at(i).at(j) == '#') answer.at(i).at(j) = '#';
      if (data.at(i).at(j) == '.') {
        int count = 0;
        if (i != 0) {
        if (j != 0) if (data.at(i-1).at(j-1) == '#') count++;
        if (data.at(i-1).at(j) == '#') count++;
        if (j != W-1) {
          if (data.at(i-1).at(j+1) == '#') count++;
        }
        }
        if (j != 0) {
        if (data.at(i).at(j-1) == '#') count++;
        }
        if (j != W-1) {
        if (data.at(i).at(j+1) == '#') count++;
        }
        if (i != H-1) {
        if (j != 0) {
        if (data.at(i+1).at(j-1) == '#') count++;
        }
        if (data.at(i+1).at(j) == '#') count++;
        if (j != W-1) {
        if (data.at(i+1).at(j+1) == '#') count++;
        }
        }
        answer.at(i).at(j) = '0' + count;
      }
    }
  }
  for (int i = 0; i < H; i++) {
    for (int j = 0; j < W; j++) {
      cout << answer.at(i).at(j);
      if (j == W-1) cout << endl;
    }
  }
}

        


        

Measured memory_bytes: 256
#include <iostream>
using namespace std;
#include <cstdio>
#include <cmath>
#include <cstring>
#include <string>
#include <algorithm>
#include <functional> //sort(A,A.end(),greater<int>());???????????????
#include <queue>
#include <stack>
#include <vector>

#define INF 10 << 10

int main() {
	int n;
	while (cin >> n && n != 0) {

		n = 1000 - n;
		int cnt = 0;
		int coin[] = { 500, 100, 50, 10, 5 };
		for (int i = 0; i < 5; ++i) {
			if (n >= coin[i]) {
				cnt += n / coin[i];
				n = n % coin[i];
			}
		}
		cnt += n;

		cout << cnt << endl;
	}

	return 0;
}

Measured memory_bytes: 2968
N,M=map(int,input().split())
ls = list(map(int,input().split()))
ls1 = [0]*N
s = sum(ls)
for i in range(N):
  if ls[i]>=s/(4*M):
    ls1[i]=1
ss = sum(ls1)
if ss>=M:
  print("Yes")
else:
  print("No")

Measured memory_bytes: 3064
#include<stdio.h>
#include<algorithm>
#include<string.h>
using namespace std;
#define INFTY 2000000001
#define MAX 101

int p[MAX], m[MAX][MAX];
int n = 0;

void mcm() {
  for (int i = 1; i <= n; i++) m[i][i] = 0;
  for (int l = 2; l <= n; l++) {
    for (int i = 1; i <= n-l+1; i++) {
      int j = i + l - 1;
      m[i][j] = INFTY;
      for (int k = i; k < j; k++) {
        m[i][j] = min(m[i][j], m[i][k]+m[k+1][j]+p[i-1]*p[j]*p[k]);
      }
    }
  }
}

int main() {
  scanf("%d", &n);
  for ( int i = 0; i < n; i++ ) {
    scanf("%d %d", &p[i], &p[i+1]);
  }
  mcm();
  printf("%d\n", m[1][n]);
  return 0;
}



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

using namespace std;

typedef long long ll;

#define sz(x) ((int)(x).size())
#define in(x) int x;cin>>x
#define inn(x, y) int x,y;cin>>x>>y
#define innn(x, y, z) int x,y,z;cin>>x>>y>>z
#define bit(n) (1<<(n))

#define out(x) cout<<(x)<<endl;
#define outt(x,y) cout<<(x)<<" "<<(y)<<endl;
#define err(x) cerr<<(x)<<endl;
#define errr(x,y) cerr<<(x)<<" "<<(y)<<endl;
#define errrr(x,y,z) cerr<<(x)<<" "<<(y)<<" "<<(z)<<endl;

#define rep(i,n) for (int i=0;i<(n);i++)
#define repp(i,n) for (int i=1;i<=(n);i++)
#define reppp(j, i, n) for (int j=i+1; j<n; j++)

#define lim5 100002
#define lim9 1000000002

#define deg(rad) (((rad)/2/M_PI)*360)
#define mid(min, max) ((min + max) / 2)

int main() {
	in(n);

	out(n % 2 ? n / 2 + 1 : n / 2);

	return 0;
}


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

#define ll long long

#define fr(i,a,b) for (ll i = (a), _b = (b); i <= _b; i++)
#define frr(i,a,b) for (ll i = (a), _b = (b); i >= _b; i--)
#define rep(i,n) for (ll i = 0, _n = (n); i < _n; i++)
#define repr(i,n) for (ll i = n - 1; i >= 0; i--)
#define fill(ar,val) memset(ar, val, sizeof(ar))
#define fill0(ar) fill((ar), 0)
#define debug(x) cout<<#x<<": "<<x<<endl

#define ld long double
#define pb push_back
#define mp make_pair
#define ff first
#define ss second

typedef pair<int, int> ii;
typedef pair<ii, int> iii;
typedef vector<ii> vii;
typedef vector<int> vi;

#define INF 1000000000000000000
#define PI 3.14159265358979323846L

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    ll n;
    cin >> n;

   	pair<ll, ll> a[n];

   	ll aa[n];
   	ll bb[n];

   	rep(i,n)
   	{
   		cin >> aa[i] >> bb[i];
   		a[i] = mp(aa[i]+bb[i],i);
   	}

   	sort(a, a+n);

   	ll ans = 0;
   	ll ch = 0;
   	repr(i,n)
   	{
   		ll ind = a[i].ss;
   		if(ch==0)
   		{
   			ch = 1;
   			ans = ans + aa[ind];
   		}
   		else
   		{
   			ch = 0;
   			ans = ans - bb[ind];
   		}
   	}

   	cout << ans << endl;
}


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

using namespace std;

int main() {
    int n;      cin >> n;
    long long *h = new long long[n];
    int i;
    for (i = 0; i < n; i++)
        cin >> h[i];
    bool can = true;

    h[0]--;

    for (i = 1; i < n; i++) {
        if (h[i-1] <= h[i]-1)
            h[i]--;
        else if (h[i-1] > h[i]) {
            can = false;
            break;
        }
    }

    if (can)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
    
    return 0;
}

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

using namespace std;
map<int,int> mp,ind;
typedef long long ll;
ll imos[400010] = {};
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll i,n,d,a;
    cin >> n >> d >> a;
    for(i=0;i<n;i++){
        int x,h; cin >> x >> h;
        mp[x] += h; mp[x + 2*d + 1] += 0;
    }
    int now = 0;
    for(auto x:mp){
        ind[x.first] = now; now++;
    }
    ll ans = 0,dm = 0;
    for(auto x:mp){
        dm += imos[ind[x.first]];
        if(x.second<=dm) continue;
        ll t = (x.second - dm + a - 1)/a;
        ans += t; dm += a*t;
        imos[ind[x.first + 2*d + 1]] -= a*t;
    }
    cout << ans << endl;
}

Measured memory_bytes: 40832
//abc127_b.cpp
//Thu Jun 27 22:30:17 2019

#include <iostream>
#include <string>
#include <queue>
#include <map>
#include <unordered_map>
#include <vector>
#include <algorithm>
#include <math.h>
#include <set>
#define INTINF 2147483647
#define LLINF 9223372036854775807
using namespace std;
using ll=long long;
typedef pair<int,int> P;

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

	for (int i=0;i<10;i++){
		x = x*r-d;
		cout << x << endl;
	}
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cmath>
#include<map>
#include<stdio.h>
#include<vector>
using namespace std;
#define int long long
#define rep(s,i,n) for(int i=s;i<n;i++)
#define c(n) cout<<n<<endl;
#define ic(n) int n;cin>>n;
#define sc(s) string s;cin>>s;
#define mod 1000000007
#define inf 1000000000000000007
#define f first
#define s second
#define mini(c,a,b) *min_element(c+a,c+b)
#define maxi(c,a,b) *max_element(c+a,c+b)
#define P pair<int,int>
//printf("%.12Lf\n",);
int keta(int x){
	rep(0,i,30){
		if(x<10){
			return i+1;
		}
		x=x/10;
	}
}
int gcd(int x,int y){
	int aa=x,bb=y;
	rep(0,i,1000){
		aa=aa%bb;
		if(aa==0){
			return bb;
		}	
		bb=bb%aa;
		if(bb==0){
			return aa;
		}
	}
}	
int lcm(int x,int y){
	int aa=x,bb=y;
	rep(0,i,1000){
		aa=aa%bb;
		if(aa==0){
			return x/bb*y;
		}	
		bb=bb%aa;
		if(bb==0){
			return x/aa*y;
		}
	}
}
bool p(int x){
	if(x==1)return false;
	rep(2,i,sqrt(x)+1){
		if(x%i==0&&x!=i){
			return false;
		}
	}	
	return true;
}
int max(int a,int b){
	if(a>=b)return a;
	else return b;
}
int min(int a,int b){
	if(a>=b)return b;
	else return a;
}	
int n2[41];		
int nis[41]; 
int nia[41];
int mody[41];
int nn;
int com(int n,int y){
	int ni=1;
	for(int i=0;i<41;i++){
		n2[i]=ni;
		ni*=2;
	}
	int bunsi=1,bunbo=1;
	rep(0,i,y)bunsi=(bunsi*(n-i))%mod;
	rep(0,i,y)bunbo=(bunbo*(i+1))%mod;
	mody[0]=bunbo;
	rep(1,i,41){
		bunbo=(bunbo*bunbo)%mod;
		mody[i]=bunbo;
	}
	rep(0,i,41)nis[i]=0;
	nn=mod-2;
	for(int i=40;i>=0;i-=1){
		if(nn>n2[i]){
			nis[i]++;
			nn-=n2[i];
		}
	}
	nis[0]++;
	rep(0,i,41){
		if(nis[i]==1){
			bunsi=(bunsi*mody[i])%mod;
		}
	}
	return bunsi;
}
int yakuwa(int n){
	int sum=0;
	rep(1,i,sqrt(n+1)){
		if(n%i==0)sum+=i+n/i;
		if(i*i==n)sum-=i;
	}
	return sum;
}	
bool hei(int n){
	rep(0,i,100){
		if(i*i==n){
			return true;
		}
	}
	return false;
}
int pow(int b,int a){	
	int aa=1;
	rep(0,i,a)aa*=b;	
	return aa;
}
int sankaku(int a){
	return a*(a+1)/2;
}
int a[214514];
signed main(){
	ic(n) ic(k)
	int ans=0;
	if(k==0){
		c(n*n)
		return 0;
	}	
	rep(k+1,i,n+1){
		ans+=(i-k)*(n/i);
		if(n%i>=k)ans+=n%i+1-k;
	}
	c(ans)
}		

Measured memory_bytes: 256
import java.util.*;
public class Main {
	boolean isPrime(int num) {
		if(num == 1) return(false);
		for(int r = 2; r <= Math.sqrt(num); r++) {
			if(num % r == 0) return(false);
		}
		return(true);
	}
	
	void doIt() {
		Scanner stdIn = new Scanner(System.in);
		while(true) {
			int N = stdIn.nextInt();
			int P = stdIn.nextInt();
			if(N == -1 && P == -1) break;
			
			ArrayList<Integer> list = new ArrayList<Integer>(100);
			for(int r = N; list.size() < 100; r++) {
				if(isPrime(r)) list.add(r);
			}
		
			for(int r = 0; r < list.size(); r++) {
				if(list.get(r) > N) { 
					N = r; //添字にする 
					break;
				}
			}
			
			ArrayList<Integer> output = new ArrayList<Integer>();
			for(int r = N; r < list.size(); r++) {
				for(int c = r; c < list.size(); c++) {
					output.add(list.get(r) + list.get(c));
				}
			}
			Collections.sort(output);
			System.out.println(output.get(P - 1));
		}
	}
	public static void main(String[] args) {
		new Main().doIt();
	}
}

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

int main(){
    int n, rank, cards[4][13] = {};
    char pic;
    cin >> n;
    for (int i = 0; i < n; i++){
        cin >> pic >> rank;
        if (pic == 'S'){
            cards[0][rank-1] = 1;
        } else if(pic == 'H'){
            cards[1][rank-1] = 1;
        } else if(pic == 'C'){
            cards[2][rank-1] = 1;
        } else{
            cards[3][rank-1] = 1;
        }
    }
    for (int i = 0; i < 4; i++){
        for (int j = 0; j < 13; j++){
            if (cards[i][j] == 0){
                if (i == 0){
                    cout << 'S' << ' ' << j+1 << endl;
                } else if(i == 1){
                    cout << 'H' << ' ' << j+1 << endl;
                } else if(i == 2){
                    cout << 'C' << ' ' << j+1 << endl;
                } else{
                    cout << 'D' << ' ' << j+1 << endl;
                }
            }
        }
    }
    return 0;
}


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

int main() {
  string S;
  cin >> S;
  vector<int> alphabet(26, 0);
  for (int i = 0; i < S.size(); i++) alphabet[(int)S[i] - 97]++;
  bool same = false;
  for (int i = 0; i < 26; i++) {
    if (alphabet[i] > 1) {
      same = true;
      break;
    }
  }
  if (same) cout << "no" << endl;
  else cout << "yes" << endl;
}


Measured memory_bytes: 256
// 1_3_B

#include <iostream>
using namespace std;

int main(){
  int x;
  for(int i = 1; i <= 10000; i++){
    cin >> x;
    if(x == 0) return 0;
    cout << "Case " << i << ": " << x << endl;
  }
  return 0;
}

Measured memory_bytes: 3072
#include "math.h"
#include "stdio.h"
#include <iostream>

using namespace std;

void solve(int n, int x) {
  int cc = 0;
  int sum = 0;

  for(int a = 1; a<= n; a++) {
    if(a > x) {
      break;
    }

    for(int b = a+1; b<= n; b++) {
      if(a+b > x) {
        break;
      }

      for(int c = b+1; c<= n; c++) {
        sum = a+b+c;
        if(sum > x) {
          break;
        }
        else if(sum == x) {
          cc++;
        }
      }
    }
  }

  printf("%d\n", cc);
}

int main() {
  int n, x;

  while(scanf("%d%d", &n, &x) && !(n == 0 && x == 0)) {
    solve(n, x);
  }
}


Measured memory_bytes: 3216
#include<bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rep2(i, m, n) for(int i = (int)(m); i < (int)(n); i++)
#define rep_inv(i, n, m) for(int i = (int)(n); i > (int)(m); i--)
using namespace std;
using ll = long long;
using vl = vector<ll>;
using vc = vector<char>;
using vvl = vector<vl>;
using vvc = vector<vc>;
using pll = pair<ll, ll>;
using vpll = vector<pll>;

int main(){
  ll N;
  cin >> N;
  vvl txy(N + 1, vl(3));
  txy[0][0] = txy[0][1] = txy[0][2] = 0;
  rep2(i, 1, N + 1) cin >> txy[i][0] >> txy[i][1] >> txy[i][2];

  rep2(i, 1, N + 1){
    ll t = txy[i][0] - txy[i - 1][0];
    ll xdif = abs(txy[i][1] - txy[i - 1][1]);
    ll ydif = abs(txy[i][2] - txy[i - 1][2]);

    if((t < xdif + ydif) || ((t - xdif - ydif) % 2 == 1)){
      cout << "No" << endl;
      return 0;
    }
  }

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


Measured memory_bytes: 5760
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin>>n;
    vector<long long> vec(n);
    long long sum=0;
    long long ans=0;
    long long mod=1e9+7;
    for(auto &e:vec)
    {
        cin>>e;
        sum+=e;
    }
    sum=sum%mod;
    for(int i=0;i<n;i++)
    {
        sum=(sum-vec[i]+mod)%mod;
        ans=ans+((vec[i]%mod)*(sum%mod))%mod;
        ans=ans%mod;
    }
    cout<<ans<<"\n";
    return 0;
}

Measured memory_bytes: 4836
#include<cstdio>
int a,b;
int gcd(const int &a,const int &b){
    if(a==0)return b;
    else if(b==0)return a;
    else if(a>b)return gcd(b,a-b);
    else return gcd(a,b-a);
}
int main(){
    scanf("%d%d",&a,&b);
    printf("%d\n",gcd(a,b));
    return 0;
}


Measured memory_bytes: 2720
#include <iostream>
#include <vector>
#include <deque>
#include <cmath>
#include <map>
#include <set>
#include <unordered_set>
#include <algorithm>
#include "iomanip"
#include <cstdio>
#include <cstring>

using namespace std;


int main() {
    int a, b, c;
    cin >> a >> b >> c;
    cout << ((b - a == c - b) ? "YES" : "NO");

}

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

using namespace std;

int main()
{
    int k=0;
   /// char a[200005],b[20005];
    string a,b;
    cin>>a>>b;
    for(int i=0;i<a.size();i++){
        if(a[i]!=b[i]){
            k++;
        }
    }
    cout<<k;

    return 0;
}


Measured memory_bytes: 3868
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cmath>
#include<map>
#include<cstdio>
#include<stack>
#include<queue>
#include<fstream>
#include<cstdio>
#include<deque>
#include<iomanip>
#include <numeric>

using namespace std;
#define ok1 printf("ok1\n");
#define ok2 printf("ok2\n");
#define M 1000000000000000000LL
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n) for(int i=(s);i<(n);i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define REPR(i,s,n) for(int i=(s);i>=(n);(i)--)
#define all(a) (a).begin(),(a).end()
#define reall(a) (a).rbegin(),(a).rend()
#define pb push_back
#define pf push_front
#define MIN(a,b) a=min((a),(b))
#define MAX(a,b) a=max((a),(b))
#define SIZE(v) (int)v.size()
const double pi = acos(-1.0);

typedef vector<int> vi;
typedef vector<string> vs;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef deque<ll> dll;
typedef pair<string, int> P;
#define mod 1e9 + 7;
ll gcd(ll x, ll y)
{
	ll r;
	while ((r = x % y) != 0)
	{
		x = y;
		y = r;
	}
	return y;
}
ll lcm(ll x, ll y)
{
	x /= gcd(x, y);
	y /= gcd(x, y);
	return (x * y);
}


int main()
{
	ios_base::sync_with_stdio(false);
	ll a,b,c,d,n, ret = 0;
	string s;
	cin >> a >> b >> c >> d;
	ll x1, x2, y1, y2;
	n = c - a; ret = d - b;
	x1 = c - ret;
	y1 = d + n;
	x2 = a - ret;
	y2 = b + n;
	cout << x1 << " " << y1 << " " << x2 << " " << y2 << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using pli = pair<ll, int>;
using pil = pair<int, ll>;
using uint = unsigned int;
template <typename T>
using Graph = vector<vector<T>>;
const int MOD = 1e9 + 7;
const ld PI = acosl(-1);

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

    int N, L;
    cin >> N >> L;
    vector<int> a(N);
    ll tmp = 0;
    int idx = -1;
    for (int i = 0; i < N; ++i) {
        cin >> a[i];
        tmp += a[i];
        if (i >= 1) {
            if (i >= 2)
                tmp -= a[i - 2];
            if (tmp >= L) {
                idx = i;
                break;
            }
        }
    }

    cout << (~idx ? "Possible" : "Impossible") << '\n';
    if (~idx) {
        for (int i = 1; i < idx; ++i)
            cout << i << '\n';
        for (int i = N - 1; i > idx; --i)
            cout << i << '\n';
        cout << idx << '\n';
    }

    return 0;
}


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

using namespace std;

#define REP(i,n) for(ll (i) = (0);(i) < (n);++i)
#define REV(i,n) for(ll (i) = (n) - 1;(i) >= 0;--i)
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define SHOW1d(v,n) {REP(WW,n)cerr << v[WW] << ' ';cerr << endl << endl;}
#define SHOW2d(v,WW,HH) {REP(W_,WW){REP(H_,HH)cerr << v[W_][H_] << ' ';cerr << endl;}cerr << endl;}
#define ALL(v) v.begin(),v.end()
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL
#define MOD 998244353

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

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

	char c;cin >> c;
	cout << (char)(c+1) << endl;

	return 0;
}


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

using namespace std;

int main() {
	int n;
	cin >> n;
	vector < int > a(n), dp(n);
	for ( int i = 0; i < n; i++ ) {
		cin >> a[i];
	}
	for ( int i = 1; i < n; i++ ) {
		dp[i] = dp[i - 1] + abs( a[i] - a[i - 1] );
		if ( i > 1 )
			dp[i] = min( dp[i], dp[i - 2] + abs( a[i] - a[i - 2] ) );
	}
	cout << dp[n - 1];  
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long a,b,c,x,y,mn,mx,d;
    cin>>a>>b>>c>>x>>y;
    mn=min(x,y);
    mx=max(x,y);
    if(mn==x)
        d=(mx-mn)*b;
    else
        d=(mx-mn)*a;
    cout<<min({(a*x)+(b*y),mx*c*2,((mn*2)*c)+d})<<endl;
}


Measured memory_bytes: 3608
class Combination:
    def __init__(self, n_max, mod=10**9+7):
        # O(n_max + log(mod))
        self.mod = mod
        f = 1
        self.fac = fac = [f]
        for i in range(1, n_max+1):
            f = f*i%mod
            fac.append(f)
        f = pow(f, mod-2, mod)
        self.facinv = facinv = [f]
        for i in range(n_max, 0, -1):
            f = f*i%mod
            facinv.append(f)
        facinv.reverse()

    def __call__(self, n, r):  # self.C と同じ
        return self.fac[n]*self.facinv[r]%self.mod*self.facinv[n-r]%self.mod

    def C(self, n, r):
        if not 0 <= r <= n: return 0
        return self.fac[n]*self.facinv[r]%self.mod*self.facinv[n-r]%self.mod

    def P(self, n, r):
        if not 0 <= r <= n: return 0
        return self.fac[n]*self.facinv[n-r]%self.mod

    def H(self, n, r):
        if (n == 0 and r > 0) or r < 0: return 0
        return self.fac[n+r-1]*self.facinv[r]%self.mod*self.facinv[n-1]%self.mod

S = int(input())
ans = 0
mod = 10**9+7
comb = Combination(4040)
for n in range(1, S//3+1):
    # n 個に分ける
    s = S - 3 * n
    ans += comb.H(n, s)
print(ans % mod)


Measured memory_bytes: 9432
/// Source : https://atcoder.jp/contests/abc042/tasks/arc058_b
/// Author : liuyubobobo
/// Time   : 2020-09-22

#include <iostream>
#include <vector>

using namespace std;


/// Combinatorics
/// Time Complexity: O((H + W) * logP)
/// Space Complexity: O(H + W)
class Solution{

private:
    const long long MOD = 1e9 + 7;
    vector<long long> fac, inv_fac;

public:
    int ways(int H, int W, int A, int B){

        init(H + W);

        long long res = 0ll;
        for(int j = B + 1; j <= W; j ++) {
            long long a = C(H - A + j - 2, j - 1);
            long long b = C(W - j + 1 + A - 2, A - 1);
            res += a * b % MOD;
            res %= MOD;
        }
        return res;
    }

private:
    void init(int N){

        fac = {1ll, 1ll};
        for(int i = 2; i <= N; i ++)
            fac.push_back(fac.back() * i % MOD);

        inv_fac = {1ll, 1ll};
        for(int i = 2; i <= N; i ++)
            inv_fac.push_back(mypow(fac[i], MOD - 2));
    }

    long long mypow(int x, int k){

        if(k == 0) return 1ll;

        long long t = mypow(x, k / 2);
        long long res = t * t % MOD;
        if(k % 2) res = res * x % MOD;
        return res;
    }

    long long C(int n, int k){
        return fac[n] * inv_fac[k] % MOD * inv_fac[n - k] % MOD;
    }
};

int main() {

//    cout << Solution().ways(2, 3, 1, 1) << endl;
//    // 2
//
//    cout << Solution().ways(10, 7, 3, 4) << endl;
//    // 3570
//
//    cout << Solution().ways(100000, 100000, 99999, 99999) << endl;
//    // 1

    int H, W, A, B;
    scanf("%d%d%d%d", &H, &W, &A, &B);
    printf("%d\n", Solution().ways(H, W, A, B));

    return 0;
}


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

int main()
{
	int i,j;
	string s,t;
	cin>>s;
	cin>>t;
	int n=s.size();
	int m=t.size();
	
	int dp[n+1][m+1];
	
	for(i=0;i<=n;i++)
	{
		for(j=0;j<=m;j++)
		{
			if(i==0||j==0)
				dp[i][j]=0;
			
			else if(s[i-1]==t[j-1])
				dp[i][j]=dp[i-1][j-1]+1;
			else
				dp[i][j]=max(dp[i-1][j],dp[i][j-1]);
		}
	}
	
	//cout<<dp[n][m]<<"  ";
	
	 i=n; 
	 j=m;
	
	string ans="";
	
	while(i>0&&j>0)
	{
		if(s[i-1]==t[j-1])
		{
			ans+=s[i-1];
			i--;
			j--;
		}
		
		else if(dp[i-1][j]>dp[i][j-1])
		i--;
		else
		j--;
	}
	
	reverse(ans.begin(),ans.end());
	cout<<ans;
	
	return 0;
}


Measured memory_bytes: 35456
import java.util.ArrayDeque;
import java.util.List;
import java.util.Scanner;

class Submission {
  int id;
  boolean ac;
}

public class Main {
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int M = sc.nextInt();
  
    Submission[] subs = new Submission[M];
    for (int i=0; i<M; i++) {
      int id = sc.nextInt();
      String ac = sc.next();
      subs[i] =  new Submission();
      subs[i].id = id - 1;
      subs[i].ac = "AC".equals(ac);  
    }
    
    boolean[] acs = new boolean[N];
    int[] penalties = new int[N];
    for (int i=0; i<N; i++) {
      acs[i] = false;
      penalties[i] = 0;
    }

    for (int i=0; i<M; i++) {
      Submission sub = subs[i];
      if (acs[sub.id]) {
        continue;
      } else if (sub.ac) {
        acs[sub.id] = true;
      } else {
        penalties[sub.id] += 1;
      }
    }

    int ac = 0;
    int penalty = 0;
    for (int i=0; i<N; i++) {
      if (acs[i]) {
        ac += 1;
        penalty += penalties[i];
      }
    }

    sc.close();
    System.out.println(ac + " " + penalty);
  }
}

Measured memory_bytes: 66052
import kotlin.comparisons.*

fun main(args: Array<String>){
    val (N, M) = readLine()!!.split(" ").map { it.toInt() }
    val array = Array(M){ i -> readLine()!!.split(" ").map { it.toInt() }.let { CityInfo(it[0], it[1], "", i) }}
    array.sortWith(compareBy({ it.p }, { it.birth }))

    var i = 1
    var city = array[0].p
    for (a in array){
        if(city == a.p){
            a.num = add0(a.p) + add0(i)
        }else{
            i = 1
            a.num = add0(a.p) + add0(i)
        }
        city = a.p
        i++
    }
    array.sortBy { it.order }
    array.map { it.num }.joinToString("\n").let { println(it) }
}

class CityInfo(
    val p: Int,
    val birth: Int,
    var num: String = "",
    val order: Int
)

fun add0(i: Int): String{
    if(i.toString().length < 6){
        return "0".repeat(6 - i.toString().length) + i.toString()
    }else{
        return  i.toString()
    }
}

Measured memory_bytes: 131632
#include <iostream>
using namespace std;
int main(){
    int n;
    while(cin>>n)
    {
       int x,y,z;
       x=n/100;
       y=n/10%10;
       z=n%10;
       if(z*100+y*10+x==n)
            cout <<"Yes"<<endl;
       else cout <<"No"<<endl;



    }
return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(){
  int flag,N,i=0;
  int h[100],ans=0;
  scanf("%d",&N);
  for(i=0;i<N;i++){
    scanf("%d",&h[i]);
  }
  flag=1;
  while(flag == 1){
    flag=0;
    for(i=0;i<N;i++){
      if(h[i]>0)flag=1;
      if(h[i]==0 && flag==1){
        break;
      }
      h[i]--;
    }
    ans++;
  }
  printf("%d\n",ans-1);
}

Measured memory_bytes: 128
#include<cstdio>
#include<cctype>
#include<iostream>
using namespace std;

int main(){
    char ch;
    int cnt[26] = {};
    
    while(cin >> ch){
        ch = tolower(ch);
        if(isalpha(ch)){
            cnt[ch-'a']++;
        }
    }
    for(int i = 0; i < 26; i++){
        printf("%C : %d\n", i + 'a', cnt[i]);
    }
    return 0;
}


Measured memory_bytes: 3148
import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.HashMap;
import java.util.StringTokenizer;


public class Main {
	static int [][]dp;
	
	
	public static void main(String[] args) throws IOException {
        Scanner sc=new Scanner(System.in);
        PrintWriter pw =new PrintWriter(System.out);
        char[]a=(" "+sc.next()).toCharArray();
        char[]b=(" "+sc.next()).toCharArray();
        int n=a.length;
        int m=b.length;
        dp=new int [n][m];
        for(int i=1;i<n;i++)
        {
        	for(int j=1;j<m;j++)
        	{
        		if(a[i]==b[j])dp[i][j]=1+dp[i-1][j-1];
        		else
        			dp[i][j]=Math.max(dp[i-1][j], dp[i][j-1]);
        	}
        }
        StringBuilder sb=new StringBuilder();
        int i=n-1;
        int j=m-1;
        while(i>0&&j>0)
        	{
        		if(a[i]==b[j]&&dp[i][j]==dp[i-1][j-1]+1) {
        			sb.append(a[i]);
        			i--;j--;}
        		else {
        			if(dp[i-1][j]>dp[i][j-1])
        			{
        				i--;
        			}
        			else j--;
        		}
        			
        	}
        sb.reverse();
        pw.println(sb);
        pw.flush();
	}
	
	
	static class Scanner {
		 
		StringTokenizer st;
		BufferedReader br;
 
		public Scanner(InputStream system) {
			br = new BufferedReader(new InputStreamReader(system));
		}
 
		public Scanner(String file) throws Exception {
			br = new BufferedReader(new FileReader(file));
		}
 
		public String next() throws IOException {
			while (st == null || !st.hasMoreTokens())
				st = new StringTokenizer(br.readLine());
			return st.nextToken();
		}
 
		public String nextLine() throws IOException {
			return br.readLine();
		}
 
		public int nextInt() throws IOException {
			return Integer.parseInt(next());
		}
 
		public double nextDouble() throws IOException {
			return Double.parseDouble(next());
		}
 
		public char nextChar() throws IOException {
			return next().charAt(0);
		}
 
		public Long nextLong() throws IOException {
			return Long.parseLong(next());
		}
 
		public boolean ready() throws IOException {
			return br.ready();
		}
 
		public void waitForInput() throws InterruptedException {
			Thread.sleep(3000);
		}
	}

}


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

#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;
const int INF = 1e9;

int main() {
  int n;
  cin >> n;
  for (int i = n; i <= 1e6; ++i) {
    bool flg = true;
    for (int j = 2; j < n; ++j) {
      if (i % j == 0) {
        flg = false;
        break;
      }
    }
    if (flg) {
      cout << i << endl;
      return 0;
    }
  }

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long 
#define endl "\n"
#define pb push_back
#define f(i,n) for(i=0;i<n;i++)
#define F(i,a,b) for(i=a;a<=b;i++)
#define arr(a,n) for( i=0;i<n;i++)cin>>a[i];
#define fi first
#define se second
#define mp make_pair
#define mod 1000000007
#define YES cout<<"YES"<<endl;
#define Yes cout<<"Yes"<<endl;
#define NO cout<<"NO"<<endl;
#define No cout<<"No"<<endl;
#define yes cout<<"yes"<<endl;
#define no cout<<"no"<<endl;
#define vi vector<ll>
#define ed end()
#define bg begin()
#define sz size()
#define ln length()
#define s() sort(a,a+n);
#define sr() sort(a,a+n,greater<ll>());
#define v()  sort(v.begin(),v.end());
#define vr() sort(v.begin(),v.end(),greater<ll>());
#define mod 1000000007
#define fast() ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
ll gcd(ll a, ll b){if(!b)return a;return gcd(b, a % b);}
ll power(ll x,ll y,ll p){ll res=1;x%=p;while(y>0){if(y&1)res=(res*x)%p;y=y>>1;x=(x*x)%p;}return res;}
int main() {
    /*#ifndef ONLINE_JUDGE
        // for getting input from input.txt
        freopen("input.txt", "r", stdin);
        // for writing output to output.txt
        freopen("output.txt", "w", stdout);
    #endif*/
        /* 
        Ofcourse it's Hard.
        It's supposed to be Hard.
        If it's easy everyone would do it.
        HARD IS WHAT MAKES IT GREAT

        YESTERDAY U SAID TOMORROW

        SLOWLY BECOMING THE PERSON I 
        SHOULD HAVE BEEN A LONG TIME AGO

        SAME TASK CAN'T BE FOUND DIFFICULT TWICE

        BTBHWSITW

        SPRH TU KAB P

        CP IS ALL ABOUT THINKING 
        YOU HAVE MUCH MORE POTENTIAL THAN U THINK

        AJIT SHIDDAT 10

        UR DAILY ROUTINE 


        */

fast();
//ll t;cin>>t;while(t--)
{
    ll n;
    cin>>n;
    set<string>s;
    for(int i=0;i<n;i++)
    {
      string str;
      cin>>str;
      s.insert(str);
    }
    cout<<s.size()<<endl;
}
return 0;
}

Measured memory_bytes: 19244
#include <bits/stdc++.h>
using namespace std;
int m;
int mul(long long a, long long b){
	return a * b % m;
}
int pw(long long a, long long b){
	a %= m;
	long long r = 1;
	for(; b; b >>= 1, a = mul(a, a)) if(b&1) r = mul(r, a);
	return r;
}
using mat = vector<vector<long long> >;
mat create(int n){
	return vector<vector<long long> > (n, vector<long long>(n, 0));
}
mat iden(int n){
	mat r = create(n);
	for(int i = 0; i < n; i++) r[i][i] = 1;
	return r;
}
mat mul(mat a, mat b){
	int n = a.size();
	mat r = create(n);
	for(int i = 0; i < n; i++) for(int j = 0; j < n; j++) for(int k = 0; k < n; k++){
		r[i][j] += mul(a[i][k], b[k][j]);
		if(r[i][j] >= m) r[i][j] -= m;
	}
	return r;
}
int len(long long x){
	int sz = 0;
	while(x) sz++, x /= 10;
	return sz;
}
int main(){
	long long l, a, b; cin >> l >> a >> b >> m;
	long long mv = 0, sum = 0;
	while(l > 0){
		long long lo = 1, hi = l - 1, ans = 0;
		int need = len(a);
		while(lo <= hi){
			long long mid = (lo + hi)>>1;
			if(len(a + b * mid) == need) ans = mid, lo = mid + 1;
			else hi = mid - 1;
		}
		mat now = create(3), res = iden(3);
		now[0][0] = pw(10, need);
		now[1][0] = 1;
		now[1][1] = 1;
		now[2][1] = b % m;
		now[2][2] = 1;
		long long sz = ans + 1, ind = ans + 1;
		for(; sz; sz >>= 1, now = mul(now, now)) if(sz&1) res = mul(res, now);
		sum = mul(sum, res[0][0]) + mul(a % m, res[1][0]) + res[2][0];
		sum %= m;
		a += ind * b;
		l -= ind;		
	}
	cout << sum << endl;
	return 0;
}


Measured memory_bytes: 256
N = int(input())
A  = list(map(int,input().split()))

maxA = max(A)
era = [0]*(maxA+1)

for i in range(0,N,1):
    if era[A[i]]==0:#脱落
        era[A[i]]=1#除＋カウント
    else:
        era[A[i]]=-1#除には参加カウントしない

ans = 0

for i in range(1,maxA+1,1):
    if era[i]==1:
        for j in range(2*i,maxA+1,i):
            era[j]=0
        ans+=1
    elif era[i]==-1:
        for j in range(2*i,maxA+1,i):
            era[j]=0

print(ans)
            


Measured memory_bytes: 94860
#include<bits/stdc++.h>
#define ll long long
using namespace std;
const int maxn = 1e5 + 50;
const int mod = 1e9+7;
int dp[maxn];
int h[maxn];
int main(){
    int n;
    cin >> n;
    for(int i = 1; i <= n; i++) cin >>  h[i];
    dp[1] = 0;
    dp[2] = abs(h[2] - h[1]);
    for(int i = 3; 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] << endl;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(i, a, b) for(ll i = a; i < (b); ++i)
#define trav(a, x) for(auto& a : x)
#define all(x) x.begin(), x.end()
#define sz(x) (ll)(x).size()
typedef pair<ll, ll> pii;
typedef vector<ll> vi; 
int main()
{
    cin.sync_with_stdio(0);
    cin.tie(0); cin.exceptions(cin.failbit);
    ll n;
    cin>>n;
    ll ch[2005];
    rep(i,-1000,1001)
    {
    	ch[i+1000]=i*i*i*i*i;
    }
    rep(i,0,2005)
    {
    	ll c=ch[i]-n;
    	//cout<<c<<endl;
    	ll low=0,high=2001,mid;
		while(low<=high)
		{
		mid=(low+high)/2;
		if(ch[mid]<c)
			low=mid+1;
		else if(ch[mid]>c)
			high=mid-1;
		else{
			cout<<i-1000<<" "<<mid-1000;
			return 0;
		    }
		}
    }
}


Measured memory_bytes: 3680