akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define FRE freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);
#define int long long
#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1) {
  cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args) {
  const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...)
#endif
#define endl "\n"
const int oo = INT_MAX;
const int MOD = 1e9 + 7;
const int sz = 1e5 + 5;
int solve(vector<int>& x, vector<int>& y) {
    int res = 0, n = x.size(), smallest, cur;
    for (int p : {1, -1}) {
        for (int q : {1, -1}) {
            smallest = p * x[0] + q * y[0] + 0;
            for (int i = 1; i < n; ++i) {
                cur = p * x[i] + q * y[i];
                res = max(res, cur - smallest);
                smallest = min(smallest, cur);
            }
        }
    }
    return res;
}
int32_t main() {
    IOS;
    int tc = 1;
    //cin >> tc;
    while(tc--) {
        int n; cin >> n;
        vector<int> x(n), y(n);
        for(int i = 0; i < n; ++i) {
            cin >> x[i] >> y[i];
        }
        cout << solve(x, y);
    }
}

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

int main(int argc, char const *argv[])
{
	int n;
	string s;
	cin >> n >> s;

	int a[30] = {};
	for (int i = 0; i < n; i+=2)
	{
		++a[s[i]-'a'];
	}
	sort(a, a+30);
	reverse(a, a+30);
	int ans=0, now=-1, cnt=0;
	for (int i = 0; i < 30; )
	{
		if (a[i]==0) break;
		else if (a[i]==1) ans+=2, ++i;
		else
		{
			now = a[i];
			while(now==a[i]) ++cnt, ++i;
			if (cnt>2) ans += 8+(cnt-2)*2;
			else ans += 4*cnt;
			cnt = 0;
		}
	}
	cout << ans-1 << endl;
	return 0;
}


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

int main() {
  int r,g,b,n;
  cin>>r>>g>>b>>n;
  int ans=0;
  for(int i=0;i<=3000;i++)
    for(int j=0;j<=3000;j++){
      int a=i*r+j*g;
      if(n>=a&&(n-a)%b==0)ans++;
    }
  cout<<ans<<endl;
}

Measured memory_bytes: 764
import java.util.*;
import java.util.Map.Entry;
import java.math.*;
import java.awt.geom.*;
import java.io.*;
      
      
public class Main {	
	static char[] tank = new char[] {'^','>','v','<'};
	static int[] vx = new int[] {0,1,0,-1};
	static int[] vy = new int[] {-1,0,1,0};
	static final int INF = 2 << 28;
	static String str;
	static StringBuilder sb;
	static int ID;
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int S = sc.nextInt();
		for(int TIME = 0; TIME < S; TIME++) {
			long[] N = new long[9];
			for(int i = 0; i < 9; i++) {
				N[i] = sc.nextLong(16);
			}
			long K = 0;
			for(int i = 0; i < 32; i++) {
				long cSum = 0;
				for(int j = 0; j < 8; j++) {
					cSum += N[j] ^ K;
				}
				if((cSum & 1L << i) != ((N[8] ^ K) & 1L << i)) {
					K |= 1L << i;
				}
			}
			System.out.println(Long.toHexString(K));
			
		}
		
	}
	
	
	
	
	
 }

Measured memory_bytes: 30096
/*
 *
 * Author: r3gz3n
 * 
 * 3b 13 12 9 56 4e
 * 6 56 a a 5f f
 * 6 56 47 18 56 d
 * 13 46 14 1f 13 27
 * 52 52 a 5a 47 1
 * 1d 13 b 1b 49 17
 *
 */


#include <bits/stdc++.h>

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;


#define endl '\n'


class Solution {
public:
    void solve(std::istream& in, std::ostream& out) {
        int n, m, ans;
        in >> n >> m;
        ans = (n*(n-1)) / 2 + (m*(m-1))/2;
        out << ans << endl;
    }
};

void solve(std::istream& in, std::ostream& out)
{
    out << std::setprecision(12);
    Solution solution;
    solution.solve(in, out);
}


#include <fstream>
#include <iostream>


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


    istream& in = cin;


    ostream& out = cout;

    solve(in, out);
    return 0;
}




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

int main(){
    int N;
    cin >> N;
    vector<int>a(N,0);
    for(int i=0;i<N;i++)cin >> a[i];

    std::vector<int>::iterator min_num = min_element(a.begin(),a.end());
    if(*min_num!=1) cout << "-1" << endl;
    else{
        std::vector<int>::iterator before_pos = a.begin();
        int cnt = 0;
        std::vector<int>::iterator idx;
        for(int i=0;i<N;i++){
            idx = find(before_pos, a.end(), i+1);            
            if(*idx == i+1){
                cnt +=1;
                before_pos = idx;
            }
            else if(idx!=a.end() && before_pos<=idx){
                cnt +=1;
                before_pos = idx;
            }
            else{break;}
        }
    cout << N-cnt << endl;
    }
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define F first
#define S second
#define pii pair<int, int>
#define eb emplace_back
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep3(i, l, n) for (int i = l; i < (n); ++i)
#define sz(v) (int)v.size()
#define inf (int)(1e9+7)
#define abs(x) (x >= 0 ? x : -(x))
#define ceil(a, b) a / b + !!(a % b)
template<typename T1, typename T2> inline void chmin(T1 &a, T2 b) { if (a > b) a = b; }
template<typename T1, typename T2> inline void chmax(T1 &a, T2 b) { if (a < b) a = b; }
ll pow(ll a, int b) { return b ? pow(a * a, b / 2) * (b % 2 ? a : 1) : 1; }
template<typename T> T gcd(T a, T b) { if (b == 0) return a; return gcd(b, a % b); }

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


int main() {
    
    int n;
    cin >> n;
    vector<int> a(n), b(n), c(n - 1);
    rep(i, n) { cin >> a[i]; a[i]--; }
    rep(i, n) cin >> b[i];
    rep(i, n - 1) cin >> c[i];
    
    int ans = 0;
    ans = b[a[0]];
    rep3(i, 1, n) {
        ans += b[a[i]];
        if (a[i - 1] + 1 == a[i]) {
            ans += c[a[i - 1]];
        }
       //  cout << ans << '\n';
    }
    cout << ans << '\n';
}


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

#define ALL(v) v.begin(), v.end()
#define V vector
#define P pair
#define ld long double
#define ll long long

const int MOD =  1000000007;
const int IINF = INT_MAX;
const ll INF = 1LL << 60;

int main() {
    ll n, m; cin >> n >> m;

    ll ans = 1;
    for(ll i = 1; i * i <= m; i++){
        if(m % i != 0) continue;
        ll j = m / i;
        if(i * n <= m) ans = max(ans, i);
        if(j * n <= m) ans = max(ans, j);
    }
    cout << ans << endl;


    return 0;
}


Measured memory_bytes: 3636
#include <stdio.h>

int main (void){
    int a, aa, b, ba, i;

    // 偶数・奇数
    scanf("%d %d", &a, &b );

    aa = 0, ba = 0;

    if ( a > 1){
        for ( i = 2; i <= a; i++ ){
            aa += i - 1;
        }
    }
    if ( b > 1 ){
        for ( i = 2; i <= b; i++ ){
            ba += i - 1;
        }
    }
    printf("%d\n", aa + ba );

    return 0;
}


Measured memory_bytes: 128
#include <stdio.h>
#include <string.h>
#define LEN 100005

typedef struct pp{
    char name[100];
    int t;
} P;

P Q[LEN];
int head, tail, n;

void enque(P x){
    Q[tail] = x;
    tail = (tail+1)%LEN;
}

P deque(){
    P x = Q[head];
    head = (head+1)%LEN;
    return x;
}

int min(int a, int b){return a<b?a:b;}

int main(){
    int elaps = 0, c;
    int i, q;
    P u;
    scanf("%d %d", &n, &q);
    for(i=1;i<=n;i++){
        scanf("%s", Q[i].name);
        scanf("%d", &Q[i].t);
    }
    head = 1;tail = n+1;

    while(head != tail){
        u = deque();
        c = min(q, u.t);
        u.t -= c;
        elaps += c;
        if(u.t>0)enque(u);
        else{
            printf("%s %d\n", u.name, elaps);
        }
    }
    return 0;
}

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

int main()
{
	int n;
	cin >> n;
	vector<int> a(n);
	for(int i = 0; i < n; i++) cin >> a[i];
	int ans = 0;
	for(int i = 0; i < n; i++){
		if(i % 2 == 0 && a[i] % 2) ans++;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3564
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>

int main()
{
	long long n;
	long long sum = 0;
	std::cin >> n;
	std::vector<long long> A;
	std::map<long long, long long> Occ;	
	std::vector<long long> ANS;
	for (int i = 0; i < n; i++)
	{
		int a;
		std::cin >> a;
		sum += a;
		++Occ[a];
		A.push_back(a);
	}
	long long q;
	std::cin >> q;
	long long diff;
	for (int i = 0; i < q; i++)
	{
		int b, c;
		std::cin >> b >> c;
		diff = c - b;
		sum =  sum + Occ[b] * diff;
		Occ[c] += Occ[b];
		Occ[b] = 0;
		ANS.push_back(sum);
	}
	for (int i = 0; i < q; i++)
		std::cout << ANS.at(i) << '\n';


}

Measured memory_bytes: 10780
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<n; ++i)
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
using namespace std;
using ll = int64_t;
using P = pair<int, int>;
using vs = vector<string>;
using vi = vector<ll>;
using vvi = vector<vi>;
const int INF = 100010001;
const ll LINF = (ll)INF*INF*10;

int main() {
    int k;
    cin >> k;
    vi a(k);
    rep(i, k) {
        cin >> a[i];
    }

    reverse(all(a));

    ll mi = 2, ma = mi;
    bool x = true;
    rep(i, k) {
        if(a[i] > ma or mi%a[i] and mi/a[i] == ma/a[i]) {
            x = false;
            break;
        }
        
        mi = (mi+a[i]-1)/a[i] * a[i];
        ma = ma/a[i]*a[i] + a[i] - 1;
    }

    if(x) cout << mi << ' ' << ma << endl;
    else cout << -1 << endl;
}

Measured memory_bytes: 1152
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
template<class T>inline bool chmax(T &a, const T &b){if(a < b){a = b; return 1;}return 0;}
template<class T>inline bool chmin(T &a, const T &b){if(a > b){a = b; return 1;}return 0;}
typedef long long ll;
int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  int N; cin >> N;
  string A, B, C; cin >> A >> B >> C;
  int ans = 0;
  REP(i, N){
    int cnt = 0;
    if(A[i] != B[i]) cnt++;
    if(B[i] != C[i]) cnt++;
    if(C[i] != A[i]) cnt++;
    if(cnt == 3) ans += 2;
    if(cnt == 2) ans += 1;
  }
  cout << ans << endl;
}

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

int main()
{
    int n;
    cin>>n;
    int arr[n];
    for(int i=0;i<n;++i)
    cin>>arr[i];
    int cnt=1;
    int mn=arr[0];
    for(int i=1;i<n;++i)
    if(arr[i]<=mn){
        cnt++;
        mn=arr[i];
    }
    cout<<cnt;
    return 0;
}


Measured memory_bytes: 1024
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include<stdio.h>
typedef struct {
	int num,
		fish;
}FISHING;
int main() {
	FISHING d[20];
	int i=1, n,t,max;
	scanf("%d", &n);
	scanf("%d%d", &d[0].num, &d[0].fish);
	max = d[0].fish, t = 0;
	while (i<n) {
		scanf("%d%d", &d[i].num, &d[i].fish);
		if (d[i].fish > max) max = d[i].fish, t = i;
		else if (d[i].fish == max) t = d[t].num < d[i].num ? t : i;
		i++;
	}
	printf("%d %d\n", d[t].num, d[t].fish);
	return 0;
}

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

int main() {
  int x;
  int a;
  int b;
  int c;
  
  cin >> x; 
  
  a = x / 100;
  b = (x - a * 100) / 10;
  c = (x - a * 100 - b * 10) / 1;
  
  cout << a + b + c << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
int main(void){

int A,B,C;
scanf("%d%d%d",&A,&B,&C);

int D = A-B;
int E = C-D;

if(E <= 0){
printf("%d\n", 0);
}

if(0 < E){
printf("%d\n", E);
}

return 0;
}

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

void maximumProfit()
{
	const int MAX = 200000;
	int R[MAX];
	int N;
	cin >> N;
	for (int i = 0; i < N; i++)
	{
		cin >> R[i];
	}
	int mi = R[0];
	int ma = -2000000000;
	for (int i = 1; i < N; i++)
	{
		ma = max(ma, R[i] - mi);
		mi = min(mi, R[i]);
	}

	cout << ma << endl;
}

void insertionSort()
{
	const int LEN = 1000;
	int N;
	int A[LEN];
	cin >> N;
	for (int i = 0; i < N; i++)
	{
		cin >> A[i];
	}

	for (int k = 0; k < N; k++)
	{
		if (k == 0)
		{
			cout << A[k] << flush;
		}
		else
		{
			cout << " " << A[k] << flush;
		}
	}
	cout << endl;

	for (int i = 1; i < N; i++)
	{
		int j = i - 1;
		int v = A[i];
		while (j >= 0 && A[j] > v)
		{
			A[j + 1] = A[j];
			j--;
		}
		A[j + 1] = v;

		for (int k = 0; k < N; k++)
		{
			if (k == 0)
			{
				cout << A[k] << flush;
			}
			else
			{
				cout << " " << A[k] << flush;
			}
		}
		cout << endl;

	}

}

int main()
{
	//maximumProfit();
	insertionSort();
	return 0;
}

Measured memory_bytes: 1164
flag = "Yes"
N = int(input())
W = input()
words = [W]
while len(words) < N:
    a = input()
    if W[-1] == a[0] and (a not in words):
        W = a
        words.append(a)
    else:
        flag = "No"
        words.append(a)

    #print(flag,words)

print(flag)




Measured memory_bytes: 3316
#include<bits/stdc++.h>
using namespace std;
#define N 100010
#define ll long long
int main()
{
    int l,r,n;
    cin>>l>>r>>n;
    int sum = 0;
    for(int i = l; i <= r; i++){
        if(i % n == 0){
            sum++;
        }
    }
    cout<<sum;
    return 0;
}


Measured memory_bytes: 3584
#include <bits/stdc++.h>
#include <iostream>
#include <queue>
#include <stack>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <random>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define repp(i,n,m) for (int i = m; i < (n); ++i)
#define repl(i,n) for (long long i = 0; i < (n); ++i)
#define reppl(i,n,m) for (long long i = m; i < (n); ++i)
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;
using PL = pair<long long, long long>;
using Pxy = pair<double, double>;
using T = tuple<int, int, bool>;
const int INF = 1001001007;
const int mod = 1000000007;
const int MOD = 998244353;
const ll inf = 1e18;
template <typename AT>
void printvec(vector<AT> &ar){
    rep(i,ar.size()-1) cout << ar[i] << " ";
    cout << ar[ar.size()-1] << endl;
}
template <typename Q>
void printvvec(vector<vector<Q>> &ar){
    rep(i,ar.size()){
        rep(j,ar[0].size()-1) cout << ar[i][j] << " ";
        cout << ar[i][ar[0].size()-1] << endl;
    }
}
template <typename S>
bool range(S a, S b, S x){
    return (a <= x && x < b);
}

ll gcd (ll a, ll b){
    ll k = a % b;
    while (k > 0){
        a = b;
        b = k;
        k = a % b;
    }
    return b;
}

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

Measured memory_bytes: 3592
import java.util.Scanner;

public class Main{
	public static void main(String[] args){
		Scanner S = new Scanner(System.in);
		
		int N = S.nextInt();
		int[][][] room = new int[4][3][10];
		
		for(int i = 0;i< N;i++){
			int b = S.nextInt();
			int f = S.nextInt();
			int r = S.nextInt();
			int v = S.nextInt();
			
			room[b - 1][f - 1][r - 1] += v;
		}
		
		for(int i = 0;i < 4;i++){
			for(int j = 0;j < 3;j++){
				for(int s = 0;s < 10;s++){
					System.out.print(" "+room[i][j][s]);
				}
				System.out.println();
			}
			if(i != 3)
			System.out.println("####################");
		}	
	}
}

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

typedef long long ll;

int main(){
  ll n,a[5];
  cin >> n;
  for(int i=0;i<5;i++){
    cin >> a[i];
  }
  ll x=a[0];
  for(int i=1;i<5;i++){
    x=min(x,a[i]);
  }
  cout << (n-1)/x+5 << endl;
}
  
  

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, s, e) for (int i = (int)(s); i <= (int)(e); i++)
#define printYesNo(is_ok) puts(is_ok ? "Yes" : "No");
#define SORT(v) sort(v.begin(), v.end());
#define RSORT(v) sort(v.rbegin(), v.rend());
#define REVERSE(v) reverse(v.begin(), v.end());

template <typename T>
void printlnVector(T v)
{
  rep(i, v.size())
  {
    cout << v[i] << endl;
  }
}

template <typename T>
void printVector(T v)
{
  rep(i, v.size())
  {
    cout << v[i] << " ";
  }
  cout << endl;
}

int main()
{
  int X, Y, Z;
  cin >> X >> Y >> Z;
  cout << Z << " " << X << " " << Y << endl;
  return 0;
}

Measured memory_bytes: 256
/*
 G - Longest Path
 * 
Problem Statement

There is a directed graph G
with N vertices and M edges. The vertices are numbered 1,2,…,N, and for each i (1≤i≤M),

the i-th directed edge goes from Vertex xi to yi. G does not contain directed cycles.

Find the length of the longest directed path in G.

Here, the length of a directed path is the number of edges in it.
G does not contain directed cycles.
 */

using namespace std;

#include<bits/stdc++.h>
#define um unordered_map
#define fastIO ios_base::sync_with_stdio(false); cin.tie(NULL);
#define lli long long int

int n, m;
lli max_dist[100001];

lli dfs(vector<int> list[], int start) {
	if(max_dist[start] != -1) {
		return max_dist[start];
	}
	bool isLeaf = true;
	lli longest_distance = 0;
	for(int child:list[start]) {
		isLeaf = false;
		longest_distance = max(longest_distance, dfs(list, child));
	}
	max_dist[start] = isLeaf? 0: 1 + longest_distance;
	return max_dist[start];
}

int main() {
	fastIO
	vector<int> list[100001];
	cin>>n>>m;
	for(int i = 1; i <= m; i++) {
		int u, v;
		cin>>u>>v;
		list[u].push_back(v);
	}
	fill(max_dist, max_dist + 100001, -1);
	lli result = 0;
	for(int i = 1; i <= n; i++) result = max(result, dfs(list, i));
	cout<<result;
	return 0;
}

Measured memory_bytes: 8576
#include <bits/stdc++.h>
const long long INF = 1LL << 60;
const long long MOD = 1000000007;
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define rep1(i, n) for (ll i = 1; i <= (n); ++i)
#define rrep(i, n) for (ll i = (n - 1); i >= 0; --i)
#define perm(c) sort(ALL(c));for(bool c##p=1;c##p;c##p=next_permutation(ALL(c)))
#define ALL(obj) (obj).begin(), (obj).end()
#define RALL(obj) (obj).rbegin(), (obj).rend()
#define MAX max<ll>
#define MIN min<ll>
#define pb push_back
#define to_s to_string
#define len(v) (ll)v.size()
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
#define print(x) cout << (x) << '\n'
#define drop(x) cout << (x) << '\n', exit(0)
#define debug(x) cout << #x << ": " << (x) << '\n'
using namespace std;
using ll = long long;
typedef pair<ll, ll> P;
typedef vector<ll> vec;
typedef vector<vector<ll>> vec2;
typedef vector<vector<vector<ll>>> vec3;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
ll devc(ll x, ll y) { return (x + y - 1) / y; }

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout << fixed << setprecision(20);

    ll sx, sy, tx, ty;
    cin >> sx >> sy >> tx >> ty;
    ll X = tx - sx, Y = ty - sy;

    string ans = "";
    rep(i, X) ans += "R";
    rep(i, Y) ans += "U";
    rep(i, X) ans += "L";
    rep(i, Y + 1) ans += "D";
    rep(i, X + 1) ans += "R";
    rep(i, Y + 1) ans += "U";
    ans += "LU";
    rep(i, X + 1) ans += "L";
    rep(i, Y + 1) ans += "D";
    ans += "R";

    print(ans);

    return 0;
}

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

int main()
{
	ll n,k;
	cin >> n >> k;
	vector<ll> a(n);
	for (int q = 0; q < n; q++)
	{
		cin >> a[q];
	}
	ll dp[n][k+1];
	for (int q = 0; q <= a[0]; q++)
	{
		dp[0][q] = 1;
	}
	for (int q = a[0]+1; q <= k; q++)
	{
		dp[0][q] = 0;
	}
	for (int q = 1; q < n; q++)
	{
		dp[q][0] = 1;
		for (int w = 1; w <= a[q]; w++)
		{
			dp[q][w] = (dp[q-1][w] + dp[q][w-1]) % md;
		}
		for (int w = a[q]+1; w <= k; w++)
		{
			dp[q][w] = (dp[q][w-1] + dp[q-1][w] - dp[q-1][w - a[q]-1]) % md;
		}
	}
	cout << (dp[n-1][k] + md) % md << "\n";
	return 0;
}


Measured memory_bytes: 78336
/*
   Author : tarang
*/
#include<bits/stdc++.h>
#define ll long long
#define fastio ios_base::sync_with(false); cin.tie(0);cout.tie(0);
const int MOD = 1000000007;
#define PI = acos(-1)
using namespace std ;
int a[106];
int main(){
   int n ; cin >> n ;
   map<string , int> mp;
   string s ; cin >> s ;
   for(int i = 0 ; i < n-2 ; i++){
   	 string t ="";
   	 t+=s[i];
   	 t+=s[i+1];
   	 t+=s[i+2];
   	 mp[t]++;
   }
   cout << mp["ABC"] << endl;
   
   
}


Measured memory_bytes: 3624
#include <algorithm>
#include <bitset>
#include <boost/dynamic_bitset.hpp>
#include <cfloat>
#include <cmath>
#include <ctime>
#include <deque>
#include <iomanip>
#include <iostream>
#include <limits>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <typeindex>
#include <typeinfo>
#include <vector>

#define DEBUG(x) cout << #x << ": " << x << endl
#define INFILE() freopen("input.txt", "r", stdin)
#define REP(i, a, b) for (int i = a; i < b; i++)
#define ALL(s) begin(s), end(s)
#define RALL(s) rbegin(s), rend(s)

using namespace std;

using ll = long long;
using ull = unsigned long long;
using i_i = pair<int, int>;
using ll_i = pair<ll, int>;
using i_ll = pair<int, ll>;
using d_i = pair<double, int>;
using ll_ll = pair<ll, ll>;
using d_d = pair<double, double>;

static constexpr ll LL_MOD = 1000000009;
static constexpr int I_MOD = 1000000007;
static constexpr double EPS = numeric_limits<double>::epsilon();
static constexpr double PI = 3.14159265358979323846264338327950288;

template <class T> static void scan(vector<T> &v);
static void scan(vector<string> &v, bool isWord = true);
static boost::dynamic_bitset<> scan(char trueValue = 'o');

int main(int argc, char *argv[]) {
	// INFILE();
  string s;
  cin >> s;

  vector<string> targets{"eraser", "erase", "dreamer", "dream"};

  for (const auto &t : targets) {
    int l = t.size();

    for (size_t cur = s.find(t); cur != string::npos; cur = s.find(t, cur)) {
      s.replace(cur, l, string(l, ' '));
    }
  }

  if (s.find_first_not_of(" ") == string::npos) {
    cout << "YES\n";
    return 0;
  }

  cout << "NO\n";
  return 0;
}

template <class T> static void scan(vector<T> &v) {
  map<type_index, const char *const> m = {{typeid(int), "%d"},
                                          {typeid(ll), "%lld"},
                                          {typeid(double), "%lf"},
                                          {typeid(char), "%c"}};

  auto tFormat = m[typeid(T)];

  for (T &n : v) {
    scanf(tFormat, &n);
  }
}

static void scan(vector<string> &v, bool isWord) {
  if (isWord) {
    for (auto &n : v) {
      cin >> n;
    }
    return;
  }

  int i = 0, size = v.size();
  string s;
  getline(cin, s);

  if (s.size() != 0) {
    i++;
    v[0] = s;
  }

  for (; i < size; ++i) {
    getline(cin, v[i]);
  }
}

static boost::dynamic_bitset<> scan(char trueValue) {
  string s;
  getline(cin, s);

  if (s.size() == 0) {
    getline(cin, s);
  }

  for_each(begin(s), end(s),
           [trueValue](char &c) { c = (c == trueValue) ? '1' : '0'; });
  return boost::dynamic_bitset<>(string(rbegin(s), rend(s)));
}


Measured memory_bytes: 512
st = input()
flag = 'Yes'
for i in range(len(st)):
    if i % 2 != 1:
        if st[i] not in ['R', 'U', 'D']:
            flag = 'No'
    else:
        if st[i] not in ['L', 'U', 'D']:
            flag = 'No'
print(flag)

Measured memory_bytes: 3064
#include <iostream>
using namespace std;
int main(int argc, char const *argv[])
{
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    if (a * b > c * d)
    {
        cout << a * b;
    }
    else
    {
        cout << c * d;
    }
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>

int main(void)
{
    char s1[101], s2[102], ans[101];

    scanf("%s", s1);
    scanf("%s", s2);

    int len_s1 = strlen(s1);
    int len_s2 = strlen(s2);
    int i, j, k;

    for(i = 0; i < len_s1; i++){
        for(j = 0; j < len_s2; j++){
            k = i + j;
            if(k >= len_s1){
                k -= len_s1;
            }
            ans[j] = s1[k];
        }
        ans[j] = '\0';
        if(strcmp(ans, s2) == 0){
            printf("Yes\n");
            return 0;
        }
    }
    printf("No\n");

    return 0;
}


Measured memory_bytes: 2144
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N;
  cin >> N;
  vector<int> l(N);
  vector<int> r(N);
  int sum = 0;
  for(int i=0; i<N; i++){
    cin >> l.at(i) >> r.at(i);
    sum += r.at(i)-l.at(i)+1;
  }
  cout << sum << endl;
}

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

int main() {
	string str;
	cin >> str;
	stack<char> st;

	for (int i=0; i<str.length(); i++) {
		if (str[i] == 'B' ) {
			if (!st.empty())
				st.pop();
		}
		else {
			st.push(str[i]);
		}
	}

	vector<char> res;
	while (!st.empty()) {
		res.push_back(st.top());
		st.pop();
	}

	for (int i=res.size()-1; i>=0; i--)
		cout << res[i];
	return 0;
}

Measured memory_bytes: 3636
#include<iostream>
#include<algorithm>
#include<cmath>
#include<stdio.h>
using namespace std;
int n,m;
int fa[2000003],vis[2000003],D[2000003],C[2000003];
inline int find(int x){
	if(fa[x]==x){
		return fa[x];
	}else{
		return fa[x]=find(fa[x]);
	}
}
int main(){
	cin>>n>>m;
    for(int i=1;i<=1000;i++){
    	fa[i]=i;
	}
    for(int i=1;i<=n;i++){
        int x,y,a,b,c,d;
        cin>>a>>b>>c>>d;
        x=!c?a+500:-c+500;
        y=!d?-b+500:d+500;
        fa[find(x)]=find(y);
        D[x]++,D[y]--;
		vis[x]=1;
    }
    int flag=1;
    for(int i=1;i<500;i++){
    	if(D[i]>0){
			puts("NO");
    		return 0;
		}
	}
    for(int i=501;i<=1000;i++){
    	if(D[i]<0){
    		puts("NO");
    		return 0;
		}
	}
    for(int i=1;i<=1000;i++){
    	vis[find(i)]|=vis[i];
	}
    for(int i=1;i<=1000;i++){
		if(D[i]!=0){
			C[find(i)]=1;
		}
	}
    for(int i=1;i<=1000;i++){
    	if(fa[i]==i&&!C[i]&&vis[i]){
    		puts("NO");
    		return 0;
		}
	}
	cout<<"YES"<<endl;
    return 0;
}

Measured memory_bytes: 6528
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define N 200005

vector<ll> m, b;
ll h[N];
int ptr;
ll dp[N];

bool bad(int f1, int f2, int f3)
{
    return 1.0 * (b[f3] - b[f1]) * (m[f1] - m[f2]) <=
           1.0 * (b[f2] - b[f1]) * (m[f1] - m[f3]);
}

void add(ll nm, ll nb)
{
    m.push_back(nm);
    b.push_back(nb);
    int sz = m.size();
    while(sz >= 3 && bad(sz - 3, sz - 2, sz - 1))
    {
        m.erase(m.end() - 2);
        b.erase(b.end() - 2);
        sz--;
    }
}

ll f(int i, ll x)
{
    return m[i] * x + b[i];
}

ll query(ll x) {
  if(ptr >= m.size()) ptr = m.size() - 1;
  while(ptr < m.size() - 1 &&
    f(ptr, x) > f(ptr+1, x)) ptr++;
  return f(ptr, x);
}


int main()
{
    ll n;
    ll c;
    cin >> n >> c;
    for(int i = 1; i <= n; i++) cin >> h[i];
    for(int i = 1; i <= n; i++)
    {
        if(i > 1) dp[i] = query(h[i]) + (h[i] * h[i]);
        add(-2 * h[i], dp[i] + (h[i] * h[i]) + c);
    }
    cout << dp[n] << endl;
}


Measured memory_bytes: 6756
// IOI 2021
 
#include <bits/stdc++.h>

using namespace std;

#define endl '\n'
#define ends ' '
#define die(x) return cout << x << endl, 0
#define all(v) v.begin(), v.end()
#define sz(x) (int)(x.size())
#define debug(x) cerr << #x << ": " << x << endl
#define debugP(p) cerr << #p << ": {" << p.first << ", " << p.second << '}' << endl
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const ll INF = 1e9;
const ll MOD = 1e9 + 7;

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

const int N = 1e5 + 5;

int n, k, ans, A[N];
vector<int> G[N];

int DFS(int v) {
	int mx = 0;
	for (int u : G[v]) {
		int d = DFS(u);
		if (d == k - 1 && v != 1) ans++;
		else mx = max(mx, d + 1);
	}
	return mx;
}

int main() {

	ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);

	cin >> n >> k;
	for (int i = 1; i <= n; i++) cin >> A[i];
	for (int i = 2; i <= n; i++) G[A[i]].push_back(i);
	ans += (A[1] != 1);
	DFS(1);
	cout << ans << endl;

	return 0;
}

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

ll n, k;
vector<ll> p, q, ip, iq, tot1, tot2, id;

vector<ll> mul(vector<ll> a, vector<ll> b) {
	vector<ll> ans;
	ans.resize(n);
	for (ll i = 0; i < n; ++i)
		ans[i] = a[b[i]];
	return ans;
}

vector<ll> inv(vector<ll> a) {
	vector<ll> ans;
	ans.resize(n);
	for (ll i = 0; i < n; ++i)
		ans[a[i]] = i;
	return ans;
}

vector<ll> exp(vector<ll> a, ll j) {
	if (j == 0)
		return id;
	if (j%2 == 1)
		return mul(a, exp(a, j-1));
	auto b = exp(a, j/2);
	return mul(b, b);
}

vector<ll> get1(ll j) {
	ll l = 2*((j-1)/3);
	if (j%3 != 1)
		l += 2;
	auto ans = exp(tot1, l/4);
	if (l%4 == 0)
		return ans;
	if (l%4 == 1)
		return mul(ans, q);
	if (l%4 == 2)
		return mul(ans, mul(q, ip));
	if (l%4 == 3)
		return mul(ans, mul(q, mul(ip, iq)));
}

vector<ll> get2(ll j) {
	ll l = 2*((j-1)/3);
	if (j%3 != 0)
		l--;
	auto ans = exp(tot2, l/4);
	if (l%4 == 0)
		return ans;
	if (l%4 == 1)
		return mul(iq, ans);
	if (l%4 == 2)
		return mul(p, mul(iq, ans));
	if (l%4 == 3)
		return mul(q, mul(p, mul(iq, ans)));
}

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

	cin >> n >> k;
	p.resize(n);
	q.resize(n);
	for (ll i = 0; i < n; ++i) {
		cin >> p[i]; p[i]--;
	}
	for (ll i = 0; i < n; ++i) {
		cin >> q[i]; q[i]--;
	}
	id.resize(n);
	for (ll i = 0; i < n; ++i)
		id[i] = i;

	ip = inv(p);
	iq = inv(q);
	tot1 = mul(q, mul(ip, mul(iq, p)));
	tot2 = mul(ip, mul(q, mul(p, iq)));

	vector<ll> ans;
	if (k == 1)
		ans = p;
	else if (k == 2)
		ans = q;
	else if (k == 3)
		ans = mul(q, ip);
	else
		ans = mul(get1(k), get2(k));
	for (ll i = 0; i < n; ++i)
		cout << ans[i]+1 << ' ';
	cout << endl;
}

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

using namespace std;

const int maxn = 1e5 + 10;

const long long mod = 1e9 + 7;

int n, cnt[maxn], ai;

long long ans = 1, tmp;

int main() {
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> ai;
		if (ai == 0)
			tmp = 3;
		else
			tmp = cnt[ai - 1];
		tmp -= cnt[ai];
		cnt[ai]++;
		ans = (ans * tmp) % mod;
	}
	cout << ans << '\n';
	return 0;
}

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

using namespace std;

int Search(int n, int x, vector<int> &d) {
	if (n == 13) {
		int a = 0, b = 1, ans = 12;
		while (x > 0) {
			if (x & 1) {
				ans = min(ans, b - a);
				a = b;
			}
			x >>= 1;
			b++;
		}
		return min(ans, 24 - a);
	}
	if (d[n] == 0)
		return Search(n + 1, x, d);
	if (d[n] == 1)
		return max(Search(n + 1, x + (1 << (n - 1)), d), Search(n + 1, x + (1 << (23 - n)), d));
	return Search(n + 1, x + (1 << (n - 1)) + (1 << (23 - n)), d);
}

int main(void) {
	int num, i, a, ans = 1;
	cin >> num;
	vector<int> d(13, 0);
	d[0] = 1;
	for (i = 0; i < num; i++) {
		scanf("%d", &a);
		d[a]++;
	}
	if (d[0] > 1 || d[12] > 1)
		ans = 0;
	for (i = 1; i < 12; i++) {
		if (d[i] > 2)
			ans = 0;
	}
	if (ans > 0)
		ans = Search(1, 0, d);
	cout << ans << "\n";
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <climits>
#include <string>
#include <bitset>
#include <cfloat>
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<ll> > vvll;
#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 fin(ans) cout<<(ans)<<endl
#define STI(s) atoi(s.c_str())
#define mp(p,q) make_pair(p, q)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define Sort(a) sort(a.begin(), a.end())
#define Rort(a) sort(a.rbegin(), a.rend())
#define MATHPI acos(-1)
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;}
struct io{io(){ios::sync_with_stdio(false);cin.tie(0);};};
const int MOD = 1000000007;
const int INF = INT_MAX;
const ll LLINF = 1LL<<60;


int main(void) {

    string s="";
    int n;
    cin>>n;
    while(n!=0){
        if(n%2!=0){
            s+='1';
            n--;
        } else {
            s+='0';
        }
        n/=-2;
    }
    reverse(s.begin(),s.end());
    if(s.size()==0){
        fin(0);
        return 0;
    }
    fin(s);
}



Measured memory_bytes: 256
/*
    @uthor: Amit Kumar
    user -->GitHub: drviruses ; CodeChef: dr_virus_ ; Codeforces,AtCoder,Hackerearth,Hakerrank: dr_virus;
*/
#include <bits/stdc++.h>
#include <chrono>
using namespace std;
using namespace std::chrono;
//#include <boost/multiprecision/cpp_int.hpp>
//namespace mp = boost::multiprecision;
//#define ln mp::cpp_int;
#define ll    long long
#define ld    long double
#define ull   unsigned long long
#define endl "\n"
#define all(vec) vec.begin(),vec.end()
ll google_itr = 1;
#define google(x) cout<<"Case #"<<x<<":"
#define pi 3.14159265358979323846264338327950L

const ll mod = 1e9+7;
const ll inf = 1e18;


void virus(){
          ll len, wt;
          cin >> len >> wt;
          vector<ll> w, val;
          for(auto i=0; i<len; i++){
              ll a, b;
              cin >> a >> b;
              w.push_back(a); val.push_back(b);
          }
          ll dp[len+1][wt+1];
          for(auto i=0; i<=len; i++){
              for(auto j=0; j<=wt; j++){
                  if(i == 0 or j == 0) dp[i][j] = 0;
                  else if(w[i - 1] <= j) dp[i][j] = max( dp[i - 1][j], val[i - 1] + dp[i - 1][j - w[i - 1]] );
                  else dp[i][j] = dp[i - 1][j];
              }
          }
          cout<<(ll)dp[len][wt];
}


int32_t main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    
  /*#ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    #endif*/

    ll t = 1;
    //cin>>t;
    while(t--){
           auto start = high_resolution_clock::now();
           virus();
           auto stop = high_resolution_clock::now();
           auto duration = duration_cast<seconds>(stop - start);
           //cerr << "\nTime: "<<duration.count()<<endl;
        //your code goes here
    }
    return 0;
}

Measured memory_bytes: 82524
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define UNIQUE(v) v.erase(unique(all(v)), v.end());
#define ZIP(v) sort(all(v)),UNIQUE(v)
#define ADD(a, b) a = (a + b) % mod
#define SUB(a, b) a = (a+mod-b)%mod
#define MUL(a, b) a = (a * b) % mod
#define repi(i,m,n) for(int i = m;i < n;i++)
#define drep(i,n,m) for(int i = n;i >= m;i--)
#define rep(i,n) repi(i,0,n)
#define rrep(i,n) repi(i,1,n+1)
#define chmin(x,y) x = min(x,y)
#define chmax(x,y) x = max(x,y)
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(), v.rend()
#define dmp(x,y) make_pair(x,y)
#define pb(x) push_back(x)
#define fi first
#define se second
typedef pair<int,int> P;
typedef pair<int, P> PP;
typedef pair<P, int> Pi;
typedef vector<int> vi;
typedef deque<int> dq;
const int inf = 1e9+7;
const int INF = 1e18+7;

int a[200000];
signed main(){
	int n, ans = 1;
	scanf("%lld", &n);
	rep(i,n)scanf("%lld", &a[i]);
	sort(a, a+n);
	if(a[0] != a[n-1] and a[0]+1 != a[n-1]){printf("No\n");return 0;}
	if(a[0] == a[n-1]){
		if(a[0] == n-1 or 2*a[0] <= n)ans = 1;
		else ans = 0;
	}else{
		int x[2] = {};
		rep(i,n)x[a[0] != a[i]]++;
		//printf("%lld %lld\n", x[0], 2*(n-x[0]));
		if(x[0] < a[n-1] and 2*(a[n-1]-x[0]) <= x[1])ans = 1;
		else ans = 0;
	}
	printf("%s\n", ans ? "Yes" : "No");
	return 0;
}







Measured memory_bytes: 1024
#include <iostream>
using namespace std;
int main()
{
	int a, b, k, x = 0;
	cin >> k >> a >> b;
	for (int i = a; i <= b; i++) {
		if (i%k == 0)
			x++;
	}
	if (x == 0)
		cout << "NG";
	else
		cout << "OK";
}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define sz(x) (int)(x.size())
 
signed main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
    int n;
    cin >> n;
    int a[n];
    int cnt = 0;
    int sum = 0;
    for (int i = 0; i < n; i++) {
        cin >> a[i];
        if (a[i] < 0) {
            cnt++;
            a[i] = -a[i];
        }
        sum += a[i];
    }
    sort(a, a + n);
    if (cnt % 2) {
        cout << sum - 2 * a[0] << "\n";
    } else {
        cout << sum << "\n";
    }
}

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

using namespace std;

int main(){
    int N;
    long long K;
    cin >> N >> K;
    int a[N+10],b[N+10];
    for(int i = 0; i < N; i++){
        cin >> a[i] >> b[i];
    }
    long long c[100010];
    for(int i = 0; i < 100010; i++){
        c[i] = 0;
    }
    for(int i = 0; i < N; i++){
        c[a[i]] += b[i];
    }
    long long  count = 0;
    for(int i = 0; i < 100010; i++){
        count += c[i];
        if(count >= K){
            cout << i << endl;
            break;
        }
    }
    return 0;
}

Measured memory_bytes: 1792
s = gets.chomp.chars.map{|ss|ss == '<' ? 1 : 0}
# p s
# p s.chunk_while{|a,b|a==b}.to_a

a = [0]
s.chunk_while{|a,b|a==b}.to_a.each do |cs|
  if cs[0] == 1 # <
    (1..(cs.size)).each do |x|
      a << x
    end
  else # >
    if a[-1] <= (cs.size-1)
      a[-1] = (cs.size-1)+1
    end
    (0..(cs.size-1)).to_a.reverse.each do |x|
      a << x
    end
  end
end
sum = 0
a.each do |aa|
  sum += aa
end
p sum

# p s.chunk_while{|a,b|a==b}.to_a
# p s.sort
# a = [0]
# i = 1
# s.each{|ss|
#   if ss == "<"
#     a[i] = a[i-1]+1
#   else
#     a[i] = a[i-1]-1
#   end
#   i += 1
# }
# p a
# p a.min
# if a.min < 0
#   a.map!{|aa|aa - a.min}
# end
# p a
# p a.inject(:+)
# 3 28


Measured memory_bytes: 82956
#include <bits/stdc++.h>
#include <unordered_set>
using namespace std;
#define ll long long
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define repeat(i,s,n) for(int (i)=s; (i)<(n); (i)++)
#define revrep(i,n) for(int (i)=(n)-1;i>=0; i--)

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout<<setprecision(std::numeric_limits<float>::max_digits10);
  cout<<fixed;
  int n;
  cin>>n;
  vector<int> z(n);
  vector<int> v(n);
  vector<int> c(n);
  rep(i,n)cin>>v[i];
  rep(i,n)cin>>c[i];
  rep(i,n) {
    z[i]=v[i]-c[i];
  }
  int ans=0;
  rep(i,n) {
    if(z[i]>0)
      ans+=z[i];
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
import sys

N, Y = [int(s) for s in sys.stdin.readline().split(" ")]
Y2 = (Y/1000)-5*N

for z in range(0, 2001):
  x = (5*z-Y2)/4
  
  if x < 0:
    continue
  
  if int(x)-x==0:
  	x = int(x)
  	y = N-x-z
  	if y<0:
  		continue
  	
  	print(z, y, x)
  	exit(0)
  
  
print("-1 -1 -1")


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
 
#define REP(i, s) for (int i = 0; i < s; ++i)
#define ALL(v) (v).begin(), (v).end()
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)
#define DEBUG
#define int long long
#define INF 1e9
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
template<class T> ostream& operator << (ostream &s, set<T> P)
{ EACH(it, P) { s << "<" << *it << "> "; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P)
{ EACH(it, P) { s << "<" << it->first << "->" << it->second << "> "; } return s << endl; }
template<class T>void show(vector<T>v){for (int i = 0; i < v.size(); i++){cerr<<v[i]<<" ";}cerr<<"\n";}
typedef long long ll;


signed main(){
    string s;
    cin>>s;
    if(s=="Sunny") cout<<"Cloudy"<<endl;
    else if(s=="Cloudy") cout<<"Rainy"<<endl;
    else cout<<"Sunny"<<endl;
   
    return 0;
}

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

int main() {
	vector<int> vec(9);
	for (auto& e : vec) {
		cin >> e;
	}
	int n;
	cin >> n;

	vector<bool> vec2(9, false);
	for (int i = 0; i < n; i++) {
		int x;
		cin >> x;
		for (int j = 0; j < 9; j++) {
			if (vec.at(j) == x) {
				vec2.at(j) = true;
				break;
			}
		}
	}

	bool ans = false;
	if (vec2.at(0) && vec2.at(1) && vec2.at(2)) ans = true;
	if (vec2.at(0) && vec2.at(4) && vec2.at(8)) ans = true;
	if (vec2.at(0) && vec2.at(3) && vec2.at(6)) ans = true;
	if (vec2.at(1) && vec2.at(4) && vec2.at(7)) ans = true;
	if (vec2.at(2) && vec2.at(5) && vec2.at(8)) ans = true;
	if (vec2.at(3) && vec2.at(4) && vec2.at(5)) ans = true;
	if (vec2.at(6) && vec2.at(7) && vec2.at(8)) ans = true;
	if (vec2.at(2) && vec2.at(4) && vec2.at(6)) ans = true;
	
	if (ans) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
}

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

#define int long long
#define sync ios::sync_with_stdio(0), cin.tie(0), cout.tie(0)
#define file freopen("input.txt", "r", stdin), freopen("output.txt", "w", stdout)
#define endl "\n"
#define ends " "
#define die(x) return cout << x << endl, 0
#define all(v) v.begin(), v.end()
#define debug(x) cerr << #x << ": " << x << endl
#define debugP(p) cerr << #p << ": {" << p.first << ", " << p.second << '}' << endl
#define debugV(v) cerr << #v << ": [ "; for(int __ = 0; __ < v.size(); __++) cerr << v[__] << ((__ != v.size() - 1) ? ", " : ends); cerr << ']' << endl
#define debugVP(v) cerr << #v << ": [ "; for(int ___ = 0; ___ < v.size(); ___++) cerr << '{' << v[___].first << ", " << v[___].second << '}' << ((___ != v.size() - 1) ? ", " : ends); cerr << ']' << endl
#define debugA(a, n) cerr << #a << ": [ "; for(int ____ = 0; ____ < n; ____++) cerr << a[____] << ((____ != n - 1) ? ", " : ends); cerr << ']' << endl
#define print(args...) fprintf (stderr, args)
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef vector<pii> vpii;
const int INF = 1e9, MOD = INF + 7;

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

const int N = 1e5 + 20;

int a[N], dp[N];

int32_t main(){

    sync;

    int n, k; cin >> n >> k;
    for(int i = 1; i <= n; i++) cin >> a[i];
  	for(int i = 2; i <= n; i++) {
  		dp[i] = INF;
  		for(int j = 1; j <= k && i - j >= 1; j++) dp[i] = min(dp[i], dp[i - j] + abs(a[i] - a[i - j]));
  	}
  	cout << dp[n] << endl;

    return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define INF (1<<30)
#define MOD 1000000007
#define l_ength size
using ll = long long;
using namespace std;

int main(){
	int ans = 0, rsd = 0;
	int c = 5;
	while( c-- ){
		int t; cin >> t;
		ans += t + ((10-t%10))%10;
		if( t%10 != 0 ){
			rsd = max( rsd, (10-t%10)%10 );
		}
	}
	cout << ans - rsd << endl;
	return 0;
}

Measured memory_bytes: 256
// https://atcoder.jp/contests/abc167/tasks/abc167_a
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define REP(i, n) FOR(i, 0, n)
#define REPR(i, n) for (int i = n - 1; i >= 0; i--)
#define FOR(i, s, n) for (int i = (s), i##_len = (n); i < i##_len; ++i)
#define ALL(obj) (obj).begin(), (obj).end()
#define ALLR(obj) (obj).rbegin(), (obj).rend()
#define DIV(a, b) ((a - 1) / b + 1)

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    string s, t;
    cin >> s >> t;
    if (s.length() + 1 == t.length() && s == t.substr(0, s.length())) {
        cout << "Yes\n";
    } else {
        cout << "No\n";
    }

    return 0;
}


Measured memory_bytes: 3652
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ll long long
#define ld long double
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
using P=pair<long long,long long>;
#define rep(i,n) for(long long i=0; i<(long long)n; i++)
#define FOR(i,a,b) for(long long i=a; i<b; i++)
#define all(x) (x).begin(), (x).end()
#define SZ(x) ((long long)(x).size())
#define COUT(x) cout << x << endl
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define vint vector<int>
#define vvint vector<vector<int>>
#define vstr vector<string>
#define vp vector<pair<int,int>>
#define vb vector<bool>
#define vvb vector<vector<bool>>
#define SUM(x) accumulate(x.begin(),x.end(),0)
#define MAX(x) *max_element(x.begin(),x.end())
#define MIN(x) *min_element(x.begin(),x.end())
#define couty cout<<"Yes"<<endl
#define coutn cout<<"No"<<endl
#define coutY cout<<"YES"<<endl
#define coutN cout<<"NO"<<endl
#define yn(x) cout<<(x?"Yes":"No")<<endl
#define YN(x) cout<<(x?"YES":"NO")<<endl
long long gcd(long long a,long long b){return b?gcd(b,a%b):a;}
long long lcm(long long a, long long b){return a*b/gcd(a,b);}
const long long dx[4]={1,0,-1,0};
const long long dy[4]={0,1,0,-1};
const long long INF = 1e12;
const long long MOD = 1e9+7;

signed main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout<<fixed<<setprecision(15);

    int a; cin >> a;
    cout<<a+a*a+a*a*a<<endl;
}

Measured memory_bytes: 3652
#include <algorithm>
#include <bitset>
#include <cassert>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <functional>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>

using namespace std;
using Graph = vector<vector<int>>;
typedef long long ll;
typedef pair<ll, ll> P;
inline ll min(ll x, ll y) { return x < y ? x : y; }
inline ll max(ll x, ll y) { return x > y ? x : y; }

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i < (int)(n); i++)
#define all(c) c.begin(), c.end()
#define pb push_back
#define fs first
#define sc second
#define show(x) cout << #x << " = " << (x) << endl
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)

int main() {
    ll A, B, K;
    cin >> A >> B >> K;
    if (K <= A) {
        cout << A - K << " " << B;
    } else if (K <= A + B) {
        cout << 0 << " " << B - (K - A);
    } else {
        cout << 0 << " " << 0;
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <cstring>
#include <limits>
using namespace std;
#define ll long long int
#define lli long long int
#define fw(i, s, e) for (ll i = s; i < e; ++i)
#define fe(i, s, e) for (ll i = s; i <= e; ++i)
#define fb(i, e, s) for (ll i = e; i >= s; --i)
#define L(T)  \
    ll T;     \
    cin >> T; \
    while (T--)
#define FASTIO                   \
    ios::sync_with_stdio(false); \
    cin.tie(nullptr);            \
    cout.tie(nullptr);
#define mem(a, i) memset(a, i, sizeof(a))
#define ld long double
#define endl "\n"
#define in(P) \
    ll P;     \
    cin >> P;
int main()
{
    FASTIO
    // L(T)
    {

        in(n);
        in(m);
        vector<ll> v[n + 90];
        fw(i, 0, m)
        {
            ll a;
            char b[23];
            cin >> a >> b;
            int c;
            if (b[0] == 'A')
            {
                c = 1;
            }
            else
            {
                c = 0;
            }

            v[a].push_back(c);
        }
        // vector<ll> g;
        ll cnt2 = 0;
        ll cnt3 = 0;
        for (ll i = 1; i <= n; ++i)
        {
            ll cnt1 = 0;
            ll f = 0;
            for (auto it : v[i])
            {
                if (it == 1)
                {

                    cnt2++;
                    f = 1;
                    break;
                }
                if (it == 0 && f == 0)
                {
                    cnt1++;
                }
            }
            if (f == 1)
            {
                cnt3 += cnt1;
            }
            // g.push_back(cnt);
        }
        cout << cnt2 << " " << cnt3;
        cout << endl;
    }
    return 0;
}

Measured memory_bytes: 9088