akhauriyash/Code-Regression huggingface dataset:
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")

#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <fstream>
#include <sstream>
#include <set>
#include <map>
#include <vector>
#include <list>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <string>
#include <queue>
#include <bitset>		//UWAGA - w czasie kompilacji musi byc znany rozmiar wektora - nie mozna go zmienic
#include <cassert>
#include <iomanip>		//do setprecision
#include <ctime>
#include <complex>
using namespace std;

#define FOR(i,b,e) for(int i=(b);i<(e);++i)
#define FORQ(i,b,e) for(int i=(b);i<=(e);++i)
#define FORD(i,b,e) for(int i=(b)-1;i>=(e);--i)
#define REP(x, n) for(int x = 0; x < (n); ++x)
#define ALL(u) (u).begin(),(u).end()

#define ST first
#define ND second
#define PB push_back
#define MP make_pair
#define LL long long
#define ULL unsigned LL
#define LD long double

typedef pair<int, int> PII;

const double pi = 3.141592653589793238462643383279502884197169399375105820974944592307816406286208998628034825342;

int main()
{
	int H, W, A, B;
	scanf("%d%d%d%d", &H, &W, &A, &B);

	REP(i, B)
	{
		REP(j, A)
			printf("1");
		FOR(j, A, W)
			printf("0");
		printf("\n");
	}

	FOR(i, B, H)
	{
		REP(j, A)
			printf("0");
		FOR(j, A, W)
			printf("1");
		printf("\n");
	}

	return 0;
}

// FOR GNU C++ use the following pattern:
// Uncomment the code below and change your main into main2
// It does not build in MS C++
// But it does increase the stack size from 256 MB on CF and uses GNU C++

//#include <Processthreadsapi.h>
//#include <iostream>
//#include <Synchapi.h>
//#include <windows.h>
//#include <process.h>
//
//DWORD WINAPI MyThreadFunction(LPVOID lpParam) {
//    main2(nullptr);
//    return 0;
//}
//int main() {
//    auto h = CreateThread(nullptr, 1024 << 20, MyThreadFunction, nullptr, STACK_SIZE_PARAM_IS_A_RESERVATION, nullptr);
//    WaitForSingleObject(h, INFINITE);
//}

Measured memory_bytes: 1280
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep2(i,a,b) for(int i=a;i<b;i++)
#define each(it,v) for(auto it : v)
#define mod 1000000007
#define all(v) (v).begin(),(v).end()
#define ll long long
#define vi vector<int>
#define vll vector<ll>
#define vpii vector<pair<int,int>>
#define vv vector<vector<int>>
using namespace std;

main()
{
    string s; cin>>s;
    int t=0,ans=0;
    rep(i,s.size())
    {
        if(s[i]=='A'||s[i]=='C'||s[i]=='G'||s[i]=='T')
        {
            t++;
        }
        else
        {
            ans=max(ans,t);
            t=0;
        }
    }
    ans=max(ans,t);
    cout<<ans<<endl;

}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

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

    for(int i = 1; i <=b ; i++) {
        if (a * i % b == c) {
            cout << "YES" << endl;
            return 0;
        }
    }

    cout << "NO" << endl;
}


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

using namespace std;

int main()
{
  int N, M; cin >> N >> M;
  vector<int> K(N);
  vector<int> like(M, 0);

  for (int i = 0; i < N; ++i) {
    cin >> K[i];
    for (int j = 1; j <= K[i]; ++j) {
      int k; cin >> k;
      like[--k]++;
    }
  }

  int ans = 0;
  for (auto v : like) {
    if (v == N) ans++;
  }

  cout << ans;
}

Measured memory_bytes: 256
/*
digu_J - Digvijay Janartha
NIT Hamirpur - INDIA
*/

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

template < typename T > using ordered_set = tree < T, null_type, less < T >, rb_tree_tag, tree_order_statistics_node_update >;
template < typename T > using MinPriorityQueue = priority_queue < T, vector < T >, greater < T > >;

#ifndef ONLINE_JUDGE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template < typename Arg1 >
void __f(const char* name, Arg1&& arg1) {
    cout << name << " : " << arg1 << std :: endl;
}
template < typename Arg1, typename... Args >
void __f(const char* names, Arg1&& arg1, Args&&... args) {
    const char* comma = strchr(names + 1, ',');
    int len = comma - names;
    for (int i = 0; i < len; ++i) {
        cout << names[i];
    }
    cout <<  " : " << arg1 << " | ";
    __f(comma + 1, args...);
}
#else
#define trace(...)
#endif

typedef double db;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair < ll, ll > pll;
typedef pair < int, int > pii;
typedef vector < ll > vll;
typedef vector < int > vi;

#define eb emplace_back
#define pb push_back
#define F first
#define S second
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define unique_sort(x) (sort(x.begin(), x.end()), x.resize(distance(x.begin(), unique(x.begin(), x.end()))))
#define fast_io() ios_base :: sync_with_stdio(0); cin.tie(0); cout.tie(0)

const ll LINF = LLONG_MAX, base = 1e9, MOD = 1e9 + 7, N = 3000 + 5, M = 1e3 + 5;
const int INF = INT_MAX;
const db PI = acos(-1);

int n, a[N];
ll dp[N][N][2];
bool seen[N][N][2];

void test();
ll solve(int l, int r, bool p);

int main() {
    fast_io();
    cout << fixed << setprecision(15);
    test();
    return 0;
}

void test() {
    cin >> n;
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
    }
    cout << solve(0, n - 1, 0) << "\n";
}

ll solve(int l, int r, bool p) {
    if (l > r) {
        return 0;
    }
    ll &ans = dp[l][r][p];
    bool &vis = seen[l][r][p];
    if (!vis) {
        vis = true;
        if (p) {
            ans = min(solve(l + 1, r, !p) - a[l], solve(l, r - 1, !p) - a[r]);
        } else {
            ans = max(solve(l + 1, r, !p) + a[l], solve(l, r - 1, !p) + a[r]);
        }
    }
    return ans;
}


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

#include <type_traits>
using namespace std;

#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 drrep(i, n) for (int i = n; i > 0; --i)
#define srep(i, s, t) for (int i = s; i < t; ++i)

#define rng(a) a.begin(), a.end()
#define pb push_back
#define eb emplace_back
#define fi first
#define se second

#define chmax(x, y) (x = max(x, y))
#define chmin(x, y) (x = min(x, y))

using pi = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vi>;
using ll = long long;
using ld = long double;

template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
  os << "(" << p.first << "," << p.second << ")";
  return os;
}

template <class T>
ostream &operator<<(ostream &os, const vector<T> &v) {
  os << "{";
  rep(i, (int)v.size()) {
    if (i) os << ",";
    os << v[i];
  }
  os << "}";
  return os;
}

template <typename T, size_t S>
void printArray(const T (&array)[S]) {
  for (auto val : array) std::cout << val << ", ";
  std::cout << "\n";
}

const int MOD = 1'000'000'000 + 7;
const int INF = 1'000'000'000 + 5;

struct Neighber {
	int v1, v2, color;
	int getTo(int src) {
		return (src == v2 ? v1 : v2);
	}
};

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

	int n; std::cin >> n;
	vector<vector<Neighber*>> d(n);
	vi que;
	vector<Neighber> neighbers(n-1);
	vi colors(n-1);
	rep(i, n-1) {
		int a, b; std::cin >> a >> b;
		--a, --b;
		neighbers[i].v1 = a;
		neighbers[i].v2 = b;
		neighbers[i].color = -1;
		d[a].pb(&neighbers[i]);
		d[b].pb(&neighbers[i]);
	}
	int k = 0;
	que.pb(0);
	rep(i, que.size()) {
		int vid = que[i];
		set<int> hasColor;
		for (Neighber* ptr : d[i]) {
			if (ptr->color != -1)
				hasColor.insert(ptr->color);
			else
				que.pb(ptr->getTo(i));
		}
		int color = 0;
		for (Neighber* ptr : d[i]) {
			if (ptr->color != -1) continue;
			while (hasColor.find(color) != hasColor.end())
				color++;
			ptr->color = color;
			chmax(k, color);
			color++;
		}
	}
	std::cout << k + 1 << "\n";
	rep(i, n-1) {
		std::cout << neighbers[i].color + 1 << "\n";
	}
}


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

#define rep(i,n) for(long long i=0;i<(long long)(n);i++)
#define REP(i,k,n) for(long long i=k;i<(long long)(n);i++)
#define all(a) a.begin(),a.end()
#define NP next_permutation
#define pb push_back
#define eb emplace_back
#define lb(v,k) (lower_bound(all(v),k)-v.begin())
#define ub(v,k) (upper_bound(all(v),k)-v.begin())
#define fi first
#define se second
#define pi M_PI
typedef long long ll;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> PP;
typedef multiset<ll> S;
typedef priority_queue<ll> PQ;
typedef priority_queue<P,vector<P>,greater<P>> SPQ;
using vi=vector<ll>;
using vvi=vector<vi>;
using vvvi=vector<vvi>;

const ll inf=1001001001001001;
const int INF=1001001001;
const int mod=1000000007;

template<class T> bool chmin(T&a,T b){if(a>b){a=b; return true;}return false;}
template<class T> bool chmax(T&a,T b){if(a<b){a=b; return true;}return false;}
template<class T> void decimal(T a){cout<<fixed<<setprecision(a);}
template<class T> void out(T a){cout<<a<<endl;}
template<class T> void outp(T a){cout<<'('<<a.fi<<','<<a.se<<')'<<endl;}
template<class T> void outvp(T v){rep(i,v.size())outp(v[i]);}
template<class T> void outv(T v){rep(i,v.size()){if(i)cout<<' ';cout<<v[i];}cout<<endl;}
template<class T> void outvv(T v){rep(i,v.size()){rep(j,v[i].size()){if(j)cout<<' ';cout<<v[i][j];}cout<<endl;}}

void YesNo(bool a){if(a) out("Yes"); else out("No");}
void yesno(bool a){if(a) out("yes"); else out("no");}
void YESNO(bool a){if(a) out("YES"); else out("NO");}
ll GCD(ll a,ll b){if(b==0) return a; return GCD(b,a%b);}
ll LCM(ll a,ll b){return(a/GCD(a,b))*(b/GCD(a,b))*GCD(a,b);}
ll POW(ll a,ll b){ll c=1; while(b>0){if(b&1){c=a*c %mod;}a=a*a %mod;b>>=1;}return c;}
vi calc(ll x){vi res; while(x>0){res.eb(x%10);x/=10;}reverse(all(res)); return res;}

void solve() {
  ll x;
  cin>>x;
  ll happy=0;
  happy+=1000*(x/500);
  x=x%500;
  happy+=5*(x/5);
  out(happy);
}

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


Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
int main(){
	int n;
	while(scanf("%d",&n),n){
		int m=0,v[4][2] = {{0,1},{1,0},{-1,1},{1,1}},map[257][257] = {{0}};
		for(int y=n;y;y--)for(int x=n;x;x--)scanf("%1d",&map[x][y]);

		for(int i=0;i<4;i++){
			int dp[257][257] = {{0}};
			for(int k=n;k;k--)for(int j=n;j;j--)m = std::max(m,dp[j][k] = map[j][k]?map[j][k] + dp[j+v[i][0]][k+v[i][1]]:0);}
		printf("%d\n",m);
	}
}

Measured memory_bytes: 1280
#include <bits/stdc++.h>
using namespace std;
long long INF = 1000000000000000000;
struct segment_tree{
  int N;
  vector<long long> ST;
  segment_tree(vector<long long> &A){
    int n = A.size();
    N = 1;
    while (N < n){
      N *= 2;
    }
    ST = vector<long long>(N * 2 - 1, INF);
    for (int i = 0; i < n; i++){
      ST[N - 1 + i] = A[i];
    }
    for (int i = N - 2; i >= 0; i--){
      ST[i] = min(ST[i * 2 + 1], ST[i * 2 + 2]);
    }
  }
  long long query(int L, int R, int i, int l, int r){
    if (r <= L || R <= l){
      return INF;
    } else if (L <= l && r <= R){
      return ST[i];
    } else {
      int m = (l + r) / 2;
      return min(query(L, R, i * 2 + 1, l, m), query(L, R, i * 2 + 2, m, r));
    }
  }
  long long query(int L, int R){
    return query(L, R, 0, 0, N);
  }
};
int main(){
  int N;
  long long x;
  cin >> N >> x;
  vector<long long> a(N * 2);
  for (int i = 0; i < N; i++){
    cin >> a[i];
    a[N + i] = a[i];
  }
  segment_tree ST(a);
  long long ans = INF;
  for (int i = 0; i < N; i++){
    long long tmp = x * i;
    for (int j = 0; j < N; j++){
      tmp += ST.query(j, j + i + 1);
    }
    ans = min(ans, tmp);
  }
  cout << ans << endl;
}

Measured memory_bytes: 3716
/*

mask 掩码为 1 的 bit 组成一组
s[mask] 每种 mask 代表的组获得的分数

d[mask] = max{d[mask - k] + s[k]}，k 为 mask 的子集

复杂度：O(3^n)

*/

package main

import "fmt"

const N = 16

func max(a, b int64) int64 {
  if a > b {
    return a
  } else {
    return b
  }
}

func main() {
  var n int
  fmt.Scanln(&n)
  var a [N][N]int
  for i := 0; i < n; i++ {
    for j := 0; j < n; j++ {
      fmt.Scan(&a[i][j])
    }
  }
  s := make([]int64, 1 << n)
  for m := 0; m < 1<<n; m++ {
    for i := 0; i < n; i++ {
      for j := i+1; j < n; j++ {
        if m & (1 << i | 1 << j) == (1 << i | 1 << j) {
          s[m] += int64(a[i][j])
        }
      }
    }
  }
  d := make([]int64, 1 << n)
  for m := 0; m < 1<<n; m++ {
    for sub := m;; sub = (sub-1)&m {
      d[m] = max(d[m], d[m^sub] + s[sub])
      if sub == 0 {
        break
      }
    }
  }
  
  fmt.Println(d[1<<n-1])
}

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

ll N, K, t, d, sum, ans;
vector<ll> F, S;
vector<pair<ll, ll>> v;
map<ll, ll> mp;

main() {
    cin >> N >> K;
    for (int i = 0; i < N; i++) {
        cin >> t >> d;
        v.push_back(make_pair(t, d));
    }
    sort(v.rbegin(), v.rend());
    for (int i = 0; i < v.size(); i++) {
        pair<ll, ll> p = v[i];
        if (mp[p.first] == 0) F.push_back(p.second);
        else S.push_back(p.second);
        mp[p.first]++;
    }
    sort(F.rbegin(), F.rend());
    sort(S.rbegin(), S.rend());
    ll L = F.size(), M = S.size();
    for (int i = 0; i < min(K, L); i++) sum += F[i];
    if (K > L) {
        int check = 0;
        for (ll i = 0; i < K - L; i++) sum += S[i], check = i;
        check++, ans = sum + L * L;
        for (ll j = L - 1; j > 0 && check < M; j--) {
            sum = sum - F[j] + S[check];
            check++;
            ans = max(ans, sum + j * j);
        }
        cout << ans << endl;
    }
    else {
        ans = sum + K * K;
        for (ll i = 0; i < K - 1 && i < M; i++) {
            sum -= F[K - 1 - i];
            sum += S[i];
            ans = max(ans, sum + (K - i - 1) * (K - i - 1));
        }
        cout << ans << endl;
    }
}

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

int main()
{
	int total, x, tmp;
	cin >> total >> x;
	vector<int> number(total);
	for (int i = 0; i < total; i++) {
		cin >> number[i];
	}
	sort(number.begin(), number.end());
	/*for (int i = 0; i < total; ++i) {
		for (int j = i + 1; j < total; ++j) {
			if (number[i] > number[j]) {
				tmp = number[i];
				number[i] = number[j];
				number[j] = tmp;
			}
		}
	}*/

	int counter = 0;
	for (int i = 0; i < total; i++) {
		if (x - number[i] >= 0) {
			counter++;
			if (x - number[i] > 0 && i == total - 1) {
				counter--;
			}
			else if (x - number[i] == 0 && i == total - 1){
				break;
			}
			else{
				x = x - number[i];
		}
	}
		else if (x - number[i] < 0) {
		counter = counter;
			if (counter == 0) {
				counter = 0;
					
			}
		break;
		}
}

cout << counter << endl;
return 0;


}

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

using namespace std;
using ll = long long;

int main() {
    int A, B, K;
    cin >> A >> B >> K;

    if(B - A + 1 < 2*K) {
        for(int i = 0; i < B - A + 1; i++) {
            cout << A + i << endl;
        }
        return 0;
    }

    for(int i = 0; i < K; i++) {
        cout << A + i << endl;
    }
    for(int i = 0; i < K; i++) {
        cout << B - K + 1 + i << endl;
    }

    return 0;
}

Measured memory_bytes: 3504
import itertools
import math
import fractions
import functools
import copy

a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = int(input())
original = [a,b,c,d,e]

sum = 0
minimum = 10
index = 0
for i in range(len(original)):
    if original[i] % 10 != 0:
        sum += original[i]//10 * 10 + 10
        if original[i]%10 < minimum:
            index = i
            minimum = original[i]%10
    else:
        sum += original[i]
if minimum != 10:
    print(sum-(original[index]//10 * 10 + 10)+original[index])
else: print(a+b+c+d+e)

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

using namespace std;

#define EACH(i,a) for (auto& i : a)
#define FOR(i,a,b) for(int i=(int)a;i<(int)b;++i)
#define RFOR(i,a,b) for(int i=(int)b-1;i>=(int)a;--i)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define ALL(a) (a).begin(),(a).end()
#define debug(x) cerr << #x << ":" << x << endl;
#define OK(ok) cout << (ok ? "Yes" : "No") << endl;
typedef long long ll;

void CINT(){}
template <class Head,class... Tail>
void CINT(Head&& head,Tail&&... tail) {
  cin >> head; CINT(move(tail)...);
}
#define CIN(...) int __VA_ARGS__;CINT(__VA_ARGS__)
#define LCIN(...) ll __VA_ARGS__;CINT(__VA_ARGS__)
#define SCIN(...) string __VA_ARGS__;CINT(__VA_ARGS__)

const int INF = 1e9 + 1;
const int MOD = 1e9 + 7;
const int MAX_N = 1e5 + 1;

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

  int x = 0;
  int y = 0;
  SCIN(S);

  bool n, w, s, e;
  n = w = s = e = false;
  EACH(si, S) {
    switch(si) {
    case 'N':
      n = true;
      break;
    case 'W':
      w = true;
      break;
    case 'S':
      s = true;
      break;
    case 'E':
      e = true;
      break;
    }
  }

  if (!w && !e) {
    OK(n && s);
  } else if (!n &&  !s) {
    OK(w && e);
  } else {
    OK((n && s) && (w && e));
  }
  
  return 0;
}



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

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

    string o = "AZ";
    int cnt = 0;
    for(int i = 0; i < s.length(); i++){
        if(s[i] == o[cnt%2])    cnt++;
    }

    if(cnt%2)   cnt--;
    if(cnt == 0)    cout << -1;
    else            for(int i = 0; i < cnt/2; i++)  cout << "AZ";
    cout << endl;

    return 0;
}


Measured memory_bytes: 3212
#include <stdio.h>
using namespace std;

int main() {
  int a,b;
  scanf("%d %d", &a, &b);
  if(a > b){
      printf("a > b\n");
  }else if (a < b){
      printf("a < b\n");
  }else{
      printf("a == b\n");
  }

  return 0;
}


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

int main() {
    int n, k;
    cin >> n >> k;
    if (k > (n - 1) * (n - 2) / 2) {
        puts("-1");
    } else {
        int rem = (n - 1) * (n - 2) / 2 - k;
        cout << n - 1 + ((n - 1) * (n - 2) / 2 - k) << endl;
        for (int i = 2; i <= n; i++) {
            cout << "1 " << i << endl;
        }
        int a = 2, b = 3;
        while (rem--) {
            cout << a << ' ' << b << endl;
            b++;
            if (b > n) {
                a++;
                b = a + 1;
            }
        }
    }
}


Measured memory_bytes: 3568
#include<iostream>
#include<cstring>
#include<map>
#include<vector>
#include<set>
#include<cstring>
#include<algorithm>
#include<cmath>
#define Max zhi5968
typedef long long ll;
using namespace std;

int main ()
{
	string s1,s2;
	cin>>s1;
	int i,ans=0,bj=0;
	for(i=0;i<s1.length();i++)
		if(s1[i]!='x')
			s2+=s1[i];
//	cout<<s1<<endl;
//	cout<<s2<<endl;
	for(i=0;i<s2.length()/2;i++)
		if(s2[i]!=s2[s2.length()-1-i])
		{
			bj++;
			break;
		}
	if(bj!=0)
	{
		cout<<"-1"<<endl;
		return 0;
	}
	if(s1==s2)
	{
		cout<<0<<endl;
		return 0;
	}
	int l=0,r=s1.length()-1;
	while(r-l>0)
	{
		if(s1[l]==s1[r])
		{
			l++; r--;
		}
		else
		{
			if(s1[l]=='x')
			{
	//			cout<<l<<endl;
				l++;
			}	
			else
			{
	//			cout<<r<<endl;
				r--;
			}
			ans++;
		}
	//	cout<<l<<r<<endl;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#include <iostream>
#include <set>
#include <vector>
#include <algorithm>

#define fr(i,b,e) for(int i=(b); i<(e); ++i)
#define rp(i,e) for(int i=0; i<(e); ++i)
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long int li;
typedef long long ll;
const int INF=1000000;


int main(void){
    int n;
    cin >> n;
    vector<int> a(n);
    vector<int> cnt(n);
    rp(i,n){
        cin >> a[i];
        ++cnt[a[i]-1];
    }

    ll sum=0;
    
    rp(i,n){
        sum+=(ll)cnt[i]*(cnt[i]-1);
    }

    sum=sum>>1;

    rp(i,n){
        cout << sum-cnt[a[i]-1]+1 << '\n';
    }
}

Measured memory_bytes: 4096
#include<iostream>
#include<string>
#include<vector>
#include<numeric>
#include<algorithm>
#include<cmath>

using namespace std;
void print(vector<int> a);
long long int gcd(long long int x,long long int y);
int isprime(long long int n);

int main(){
    int n; cin >> n;
    long long int mi; cin >> mi;
    long long int ma = -1e12;
    for (int i=1;i < n;i++){
        long long int v;
        cin >> v;
        if (ma < v - mi) ma = v - mi;
        if (mi > v) mi = v;
        
    }
    cout << ma << endl;


    return 0;
}

void print(vector<int> a){
    int n = a.size();
    for (int j=0;j<n;j++) {
        if (j != n-1) cout << a[j] << " ";
        else cout << a[j] << endl;
    }
}



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

int isprime(long long int n){
    if (n == 2) return 1;
    for (int i=2;i < sqrt(n)+1;i++){
        if (n % i == 0) return 0;
    }
    return 1;
}

//Sum accumulate(v.begin(),v.end(),0);
//Sort sort(v.begin(),v.end())
//Power pow(base, e)
//Min min = *std::min_element(vec.begin(), vec.end());
//Max max = *std::max_element(vec.begin(), vec.end());



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

#define ll long long
#define pb push_back
#define MP make_pair
#define F first
#define S second
#define MAX 1e9
#define MIN -1e9
#define MOD 1000000007


int main(){
	ios::sync_with_stdio(0); 
    cin.tie(0); 
	#ifndef ONLINE_JUDGE
		freopen("input.txt", "r", stdin);
		freopen("output.txt", "w", stdout);
	#endif
	char c;
	cin >> c;
	if(c >= 'A' && c <= 'Z')
		cout << "A";
	else
		cout << "a";
	return 0;
}

Measured memory_bytes: 3648
#include <iostream>
#include <bits/stdc++.h>
#include <math.h>
#include <stdio.h>
#include <algorithm>
using namespace std;
#define ll long long

int main() {
  int n;cin>>n;
  vector<int>h(n);
  for(int i=0;i<n;i++)
    cin>>h.at(i);
  int ans=0,sum=0;
  for(int i=0;i<n-1;i++)
  {
    if(h.at(i)<h.at(i+1))
       {
         ans=max(ans,sum);
         sum=0;
       }
    else{
    sum++;
    }
   }
  ans=max(ans,sum);
  cout<<ans;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
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; }

#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
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)
{ for(auto it : P) { s << "<" << it << "> "; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P)
{ for(auto it : P) { s << "<" << it.first << "->" << it.second << "> "; } return s << endl; }




int main() {
    string S;
    cin >> S;
    deque<char> dS(S.size());
    for (int i = 0; i < S.size(); ++i) dS[i] = S[i];

    int Q; cin >> Q;
    int rev = 0;
    for (int i = 0; i < Q; ++i) {
        int type; cin >> type;
        if (type == 2) {
            int f; char c;
            cin >> f >> c; --f;
            if (rev) f = 1 - f; // 反転状態だったら、フラグを反転
            if (f == 0) dS.push_front(c);
            else dS.push_back(c);
        }
        else rev = 1 - rev;
    }
    if (rev) reverse(dS.begin(), dS.end());
    for (auto c : dS) cout << c;
    cout << endl;
}


Measured memory_bytes: 896
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <map>
#include <vector>
#include <queue>
#include <algorithm>

using namespace std;

//typedef pair<int,int> P;

int main(){
	char s[100001];
	scanf("%s",s);

	for(int i=0;i<strlen(s);i+=2){
		printf("%c",s[i]);
	}
	printf("\n");

	return 0;
}


Measured memory_bytes: 384
#C-117
n, m = [int(i) for i in input().split()]
x = [int(i) for i in input().split()]
if n >= m:
  print(0)
elif n == 1:
  print(max(x) - min(x))
else:
  x.sort()
  x_diff = []
  for mi in range(m-1):
    x_diff.append([x[mi+1]-x[mi], mi])
  #print(x_diff)
  x_diff.sort(reverse = True)
  #print(x_diff)
  split_list = []
  for ni in range(n-1):
    split_idx = x_diff[ni][1]
    split_list.append(split_idx)
  split_list.sort()
  #print(split_list)
  #print(x)
  ans = 0
  ans += x[split_list[0]] - x[0]
  #print("ans",ans)
  for ni in range(n-2):
    l = split_list[ni]+1
    r = split_list[ni+1]
    ans += x[r] - x[l]
    #print("ans",ans)
  ans += x[-1] - x[split_list[-1]+1]
  print(ans)


Measured memory_bytes: 21324
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD=1e9+7;
const int INF=1e9;
const ll LINF=1e18;

int main(){
    int n,a,b;
    cin>>n>>a>>b;
    if(n<a){
        cout<<-1<<endl;
        return 0;
    }
    int cnt=0;
    int u=n+1,l=0;
    vector<int> ans;
    while(u-l>1){
        int s=min(a-cnt,u-l-1);
        if(s<=0){
            cout<<-1<<endl;
            return 0;
        }
        for(int i=0;i<s;i++){
            ans.push_back(u-s+i);
        }
        u-=s;
        int t=min(b-1-cnt,u-l-1);
        if(cnt==0&&t!=b-1){
            cout<<-1<<endl;
            return 0;
        }
        if(u-l==1)break;
        if(t<=0){
            cout<<-1<<endl;
            return 0;
        }
        for(int i=0;i<t;i++){
            ans.push_back(l+t-i);
        }
        l+=t;
        cnt++;
    }
    for(int v:ans){
        cout<<v<<" ";
    }
    cout<<endl;
}

Measured memory_bytes: 3440
import java.util.Scanner;

class Main{
	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		while(sc.hasNext()){
			String s=sc.next();
			boolean check=false;
			for(int i=0;i<s.length();i++){
				if(s.charAt(i)=='C'){
					for(int j=i+1;j<s.length();j++){
						if(s.charAt(j)=='F') check=true;
					}
				}
			}
			System.out.println(check ? "Yes" : "No");
		}
	}
}

Measured memory_bytes: 9044
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>

using namespace std;

long long cnt;

void print(vector<int> &data){
	for (int i = 0; i < data.size(); ++i){
		cout << data[i];
		if (i == data.size() - 1) cout << endl;
		else cout << " ";
	}
}

vector<int> tmp;

void helper(vector<int> &data, int l, int m, int r){
	for (int i = l; i < r; ++i) tmp[i] = data[i];

	int p1(l), p2(m), p(l);
	while (p1 < m && p2 < r) {
		if (tmp[p1] < tmp[p2]) data[p++] = tmp[p1++];
		else data[p++] = tmp[p2++];
	}

	while (p1 < m)	data[p++] = tmp[p1++];
	while (p2 < r)	data[p++] = tmp[p2++];
	cnt += (r - l);
}

void mergeSort(vector<int> &data, int l, int r){
	if (l+1 < r){
		int m = l + (r - l) / 2;
		mergeSort(data, l, m);
		mergeSort(data, m, r);
		helper(data, l, m, r);
	}
}



int main(){
	int n; cin >> n;
	vector<int> data(n);
	for (int i = 0; i < n; ++i) cin >> data[i];

	tmp.resize(data.size());
	mergeSort(data, 0, data.size());
	print(data);
	cout << cnt << endl;

	return 0;
}

Measured memory_bytes: 6708
import * as fs from 'fs';
// main
function main(input: string[]) {
    // param
    let n, k;
    let ans;
    // init
    [n, k] = input.shift().split(" ").map(x => Number(x));
    // solve
    ans = 0;
    do {
        n = Math.floor(n / k);
        ans++;
    }
    while (n != 0);
    // answer
    console.log(ans);
}
// entrypoint
function entrypoint() {
    try {
        // linux
        let input = fs.readFileSync("/dev/stdin", "utf8").trim().split("\n");
        console.debug = function () { };
        main(input);
    }
    catch (ex) {
        // windows
        const lines: string[] = [];
        // @ts-ignore
        const reader = require('readline').createInterface({
            // @ts-ignore
            input: process.stdin,
            // @ts-ignore
            output: process.stdout
        });
        reader.on('line', function (line: string) {
            lines.push(line);
        });
        reader.on('close', function () {
            let input = lines;
            main(input);
        });
    }
}
entrypoint();


Measured memory_bytes: 29584
//coded by dsingh_24
#include<bits/stdc++.h>
#define ll          long long
#define pb          push_back
#define mp          make_pair
#define pll         pair<long long,long long>
#define vll          vector<long long>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (long long)x.size()
#define hell        1000000007
#define lbnd        lower_bound
#define ubnd        upper_bound
#define bs          binary_search
#define ios         ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;
int main()
{
	ios
    ll n,i,j;
    cin>>n;
    ll a[n+1],ans=0;
    for(i=0;i<n;i++)cin>>a[i];
    for(i=0;i<n;i++)
    {
    	if(a[i]==i+1){swap(a[i],a[i+1]);ans++;}
	}
	cout<<ans;
	return 0;
}


Measured memory_bytes: 1024
#include<iostream>
#include<vector>
#include<algorithm>
#include<cmath>
#include<string>
#include<utility>
#include<queue>
#define rep(i, n) for(int i=0;i<n;i++)
using namespace std;
int main(){
	int a, b;
	cin>>a>>b;
	if(a==b)
		cout<<"Yes"<<endl;
	else
		cout<<"No"<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<iostream>
#include<iomanip>
#include<math.h>
#include<algorithm>
#include<utility>
#include<queue>
#include<string.h>
#include<string>
#include<set>
#include<functional>
using namespace std;
typedef long long LL;
#define _CRT_SECURE_NO_WARNINGS

LL N,P;
int main() {
	cin >> N >> P;
    if(N==1){
        cout << P;
        return 0;
    }
    int ans=1;
    for(int i=2;pow(i,N)<=P;i++){
        int c=0;
        LL temp=P;
        while(temp%i==0){
            temp/=i;
            c++;
        }
        if(c>=N){
            ans=i;
        }
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

class Main{

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ

			Scanner sc = new Scanner(System.in);

			String str=sc.nextLine();

			if(str.equals("ABC")) {
				System.out.println("ARC");
			}
			else if(str.equals("ARC")) {
				System.out.println("ABC");
			}
			else {

			}

			sc.close();

	}

}

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

// 型定義
typedef long long ll;
typedef pair<ll, ll> P;

// forループ
#define REP(i,n) for(ll i=0; i<(ll)(n); ++i)

// 定数宣言
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

// グラフ表現
using Graph = vector<vector<int>>;

// グラフの辺表現
using Edge = map<pair<int,int>,int>;

// n次元配列の初期化。第２引数の型のサイズごとに初期化していく。
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

int main()
{
    int N;
    int K;

    cin >> N >> K;

    int e = (N-1)*(N-2)/2 - K;
    // 構成できないとき
    if(e < 0){
        cout << -1 << endl;
        return 0;
    }

    cout << e + (N-1) << endl;
    // スターグラフの作成
    for(int i=2; i<=N; i++){
        cout << 1 << " " << i << endl;
    }

    if(e == 0) return 0;
    int count = 0;
    
    // ショートカット辺の追加
    for(int i=2; i<=N-1; i++){
        for(int j=i+1; j<=N; j++){
            cout << i << " " << j << endl;
            count++;
            if(count == e) return 0;
        }
       
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
 
#define INF 1e9
 
signed main(){
    cin.tie(0);
 
    int n,k;
    cin>>n>>k;
 
    int pos;
 
    for(int i=0;i<n;i++){
        int a;
        cin>>a;
        if(a==1)pos=i;
    }
 
    int ans=(n-1+k-2)/(k-1);
 
    cout<<ans<<endl;
 
}

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

int main()
{
	int ans=0;
	string s;cin>>s;
	for(int i=1;i<s.length();i++){
		if(s[i]==s[i-1]){
			ans++;
			s[i]='1'-s[i-1]+'0';
		}
	}
	cout<<ans<<endl; 
}


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

using namespace std;
const long long INF = 1LL <<60;

int main(void){
  int N,K,rst,tmp;
  cin >>N>>K;
  long a[N],d[K];
  int i,j,l,m;
  rst=0;
  
  for(i=0;i<N;i++){
    a[i]=0;
  }
  
  for(i=0;i<K;i++){
    cin>>d[i];
    for(j=0;j<d[i];j++){
      cin>>tmp;
      a[tmp-1]+=1;
    }
    //cout<<endl;
  }

  for(i=0;i<N;i++){
    if(a[i]==0){
      rst+=1;
    }
  }

  cout<<rst<<endl;
  
  return 0;
}
      

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

using namespace std;

inline int ctoi(char c) { if(c < '0' || '9' < c) throw invalid_argument("ctoi error"); return c - '0'; }
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define REP(i, k, n) for(int i = (int)(k); i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()

template <typename T>
inline T gcd(T x, T y){
	if (x <= 0 || y <= 0) throw invalid_argument("gcd error: x <= 0 or y <= 0");
	
	if(x < y) swap(x, y);
	T r = x % y;

	while(r != 0){
		x = y;
		y = r;
		r = x % y;
	}

	return y;
}
template <typename T>
inline T lcm(T x, T y){
	if (x <= 0 || y <= 0) throw invalid_argument("lcm error: x <= 0 or y <= 0");

	return x * y / gcd(x, y);
}

int main(){
	int n;
	cin >> n;
	
	REP(i, 1, 10){
		REP(j, 1, 10){
			if(i * j == n){
				cout << "Yes\n";
				return 0;
			}
		}
	}

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

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

int main() {
  int n, c;
  cin>>n>>c;
  int d[c][c];
  for (int i=0; i<c; i++) {
    for (int j=0; j<c; j++) {
      cin>>d[i][j];
    }
  }
  map<int, int> c0;
  map<int, int> c1;
  map<int, int> c2;
  for (int i=0; i<n; i++) {
    for (int j=0; j<n; j++) {
      int a;
      cin>>a;
      --a;
      int b = (i + j) % 3;
      if (b == 0) {
        ++c0[a];
      } else if (b == 1) {
        ++c1[a];
      } else {
        ++c2[a];
      }
    }
  }
  long ans = 1000 * 250000;
  for (int i=0; i<c; i++) {
    for (int j=0; j<c; j++) {
      if (i == j) {
        continue;
      }
      for (int k=0; k<c; k++) {
        if (k == i || k == j) {
          continue;
        }
        long tmp = 0;
        for (auto x : c0) {
          tmp += d[x.first][i] * x.second;
        }
        for (auto x : c1) {
          tmp += d[x.first][j] * x.second;
        }
        for (auto x : c2) {
          tmp += d[x.first][k] * x.second;
        }
        ans = min(ans, tmp);
      }
    }
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 256
import java.util.*;
public class Main {
	public static void main(String[] args) {
    	Scanner sc = new Scanner(System.in);
      	String x = sc.next();
        if ((x.charAt(2) == x.charAt(3)) && (x.charAt(4) == x.charAt(5))) {
 			System.out.println("Yes");
        } else System.out.println("No");
    }
 }

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

using namespace std;

int main (void) {
	string s;
	string t;
	int sel;
	int cnt;
	string test;
	
	cin >> s;
	cin >> t;
	
	sel = s.size();
	
	if (s == t){
		cout << "Yes" << "\n";
		}else{
			test = s;
			for (cnt = 0; cnt < sel; cnt++){
				test = test.substr(1) + test[0];
				if (test == t){
					cout << "Yes" << "\n";
					cnt = sel + 1;
					}
				}
			if (cnt == sel){
				cout << "No" << "\n";
				}
			}
	
	return 0;
	}

Measured memory_bytes: 256
#include<stdio.h>
#define MAX 100001
#define NMAX 10001


void Union(int A[],int x,int y,int i,int n){
int tempX,tempY,j;

if(A[x]!=-1&&A[y]!=-1){
 tempX=A[x];
 tempY=A[y];
 for(j=0;j<n;j++){if(A[j]==tempX||A[j]==tempY)A[j]=i;}
}
else if(A[x]==-1&&A[y]==-1){
 A[x]=i;
 A[y]=i;
}
else{
 if(A[x]==-1){A[x]=A[y];}
 else{A[y]=A[x];}
}

return;
}



int same(int A[],int x,int y){
if(A[x]==A[y]&&A[x]!=-1&&A[y]!=-1){return 1;}
else{return 0;}
}


int main(){
int n,q;
int i,com,x,y;
int temp;
int C[MAX];
int A[NMAX];


scanf("%d %d",&n,&q);/*n,qの読み込み*/

for(i=0;i<n;i++){A[i]=-1;}/*Aの初期化*/
for(i=0;i<q;i++){C[i]=-1;}


for(i=0;i<q;i++){
 scanf("%d %d %d",&com,&x,&y);
 switch(com){
  case 0:Union(A,x,y,i,n);
         break;
  case 1:C[i]=same(A,x,y);
         break;
 }
}



for(i=0;i<q;i++){/*表示*/
 if(C[i]==0||C[i]==1){printf("%d\n",C[i]);}
}

return 0;
}


Measured memory_bytes: 2172
#include<bits/stdc++.h>
#include<string>
#include<algorithm>
#define mem(x) memset(x,0,sizeof(x)) 
#define sca(x) scanf("%d",&x)
#define scaa(x,y) scanf("%d%d",&x,&y)
#define inf 0x7f7f7f7f
#define io ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);
#pragma GCC optimize(2)
using namespace std;
const double pi=acos(-1); 
const double eps=1e-6;
typedef pair<int,int> pii;
typedef long long ll;
typedef pair<char,char> pcc;
const ll mod=998244353;
int main()
{
	int n,m;
	cin>>n>>m;
	int ans=0;
	ans=(n*(n-1))/2+(m*(m-1))/2;
	cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void){
    int a[4];
    int in, i;

    scanf("%d", &in);

    for(i=3;i>=0;i--){
        a[i] = in % 10;
        in /= 10;
    }
    for(i=0;i<3;i++){
        if(a[i]==a[i+1]){
            printf("Bad\n");
            return 0;
        }
    }

    printf("Good\n");

    return 0;
}

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

def ri():
    return int(input())

def rl():
    return list(input().split())

def rli():
    return list(map(int, input().split()))

def main():
    n = ri()
    la = rli()
    h = 0
    ans = 0
    for a in la:
        if a < h:
            ans += h-a
        else:
            h = a
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 32376
from collections import deque
h, w = map(int, input().split())
a = ["#"]*(w+2)
maze = [a]
nsum = 0
for i in range(h):
  b = list(input())
  nsum += b.count(".")
  maze.append(["#"] + b + ["#"])
maze.append(a)
d = [[-1]*(w+2) for i in range(h+2)]  
def bfs(i, j):
  q = deque()
  q.append([i, j])
  d[i][j] = 0
  while q:
    p = q.popleft()
    if p[0] == h and p[1] == w:
      break
    for i, j in ([-1, 0], [0, -1], [1, 0], [0, 1]):
      np = [p[0]+i, p[1]+j]
      if maze[np[0]][np[1]] != "#" and d[np[0]][np[1]] == -1:
        q.append(np)
        d[np[0]][np[1]] = d[p[0]][p[1]] + 1
  if d[h][w] == -1:
    return -1
  if d[h][w] != -1:
    return nsum - d[h][w] - 1
print(bfs(1, 1))

Measured memory_bytes: 3316
// 不定方程式4x+7y=nの解
// x=7k+2n y=-n-4k
// for any integer k require
// condition x>=0&&y>=0
// if n>28 any k
// else
// if nが４の倍数かつ７の倍数
// ｋ存在
// 存在しない場合Ｎｏ
#include<iostream>
using namespace std;

int main(){
  int n;cin>>n;
  cout<<(n==1||n==2||n==3||n==5||n==6||n==9||n==10||n==13||n==17?"No":"Yes")<<endl;
  return 0;
}


Measured memory_bytes: 256
#include "iostream"
using namespace std;

int main()
{
	int n,*ans;
	cin >> n;
	if (n == 3) {
		cout << 2 << ' ' << 5 << ' ' << 63;
		return 0;
	}
	ans = new int[n];
	ans[0] = 3;
	ans[1] = 9;
	for (int i = 2; i < n-1; i++) {
		if (i <= 15000)ans[i] = 2*i-2;
		else ans[i] = 6 * i - 89991;
	}
	if (n <= 15002) {
		if (n % 3 == 1)ans[n - 1] = 29998;
		else ans[n - 1] = 30000;
	}
	else if (n % 2 == 0)ans[n - 1] = 30000;
	else ans[n - 1] = 29997;
	for (int i = 0; i < n; i++) {
		cout << ans[i] << ' ';
	}
    return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
int64_t MOD=1000000007;

int main() {
  int64_t N,C,K;
  cin>>N>>C>>K;
  vector<int64_t> T(N);
  for(int i=0;i<N;i++) cin>>T.at(i);
  sort(T.begin(),T.end());
  int64_t a=0,i=0,count=1;
  for(int i=0;i<N;i++){
    if(i<a+C&&T.at(i)<=T.at(a)+K);
      else {
        a=i;
        count++;
      }
  }
  cout<<count;   
}


Measured memory_bytes: 1024
N, M = map(int, input().split())
war = []
for i in range(M):
    war.append(list(map(int, input().split())))

war.sort(key = lambda x: x[1])
ans = 0

r = -1
for i in range(M):
    if war[i][0] <= r:
        continue
    else:
        ans += 1
        r = war[i][1]-1
print(ans)


Measured memory_bytes: 29068
#include <iomanip>
#include <iostream>
#include <string>
using namespace std;

int main() {
	int N;
	cin >> N;
	double ans = 0.0;
	for (int i = 0; i < N; ++i) {
		double x;
		cin >> x;
		string u;
		cin >> u;
		if (u == "BTC") ans += 380000.0 * x;
		else ans += x;
	}
	cout << ans;
}

Measured memory_bytes: 256
fn main() {
    use std::io::Read;
    let mut buf = String::new();
    std::io::stdin().read_to_string(&mut buf).unwrap();
    let mut iter = buf.split_whitespace();
    
    let a: u64 = iter.next().unwrap().parse::<u64>().unwrap();
    let b: u64 = iter.next().unwrap().parse::<u64>().unwrap();
    
    println!("{}", (if a>=1 {calc(a-1)} else {0}) ^ calc(b));
}

fn calc(a: u64) -> u64 {
    (a+1)/2 % 2 ^ (if a%2==0 {a} else {0})
}

#[test]
fn test_calc() {
    assert_eq!(calc(5), 1);
    assert_eq!(calc(6), 1 ^ 6);
}

Measured memory_bytes: 4352
#include <bits/stdc++.h>
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define rep(i,n) for (int i=0;i<(int)(n);i++)
#define codefor int test;scanf("%d",&test);while(test--)
#define yn(ans) cout<<(ans?"Yes":"No")<<endl
#define YN(ans) cout<<(ans?"YES":"NO")<<endl
#define umap unordered_map
#define uset unordered_set
using namespace std;
using ll = long long;
//入力系
void scan(int& a){scanf("%d",&a);}
void scan(long long& a){scanf("%lld",&a);}
template<class T> void scan(T& a){cin>>a;}
template<class T> void scan(vector<T>& vec){for(auto&& it:vec)scan(it);}
void in(){}
template <class Head, class... Tail> void in(Head& head, Tail&... tail){scan(head);in(tail...);}
//出力系
void print(const int& a){printf("%d",a);}
void print(const long long& a){printf("%lld",a);}
void print(const double& a){printf("%.15lf",a);}
template<class T> void print(const T& a){cout<<a;}
template<class T> void print(vector<T>& vec){if(vec.empty())return;print(vec[0]);for(auto it=vec.begin();++it!= vec.end();){putchar(' ');print(*it);}}
void out(){putchar('\n');}
template<class T> void out(const T& t){print(t);putchar('\n');}
template <class Head, class... Tail> void out(const Head& head, const Tail&... tail){print(head);putchar(' ');out(tail...);}
//デバッグ系
template<class T> void dprint(const T& a){cerr<<a;}
template<class T> void dprint(vector<T>& vec){if(vec.empty())return;cerr<<vec[0];for(auto it=vec.begin();++it!= vec.end();){cerr<<" "<<*it;}}
void debug(){cerr<<endl;}
template<class T> void debug(const T& t){dprint(t);cerr<<endl;}
template <class Head, class... Tail> void debug(const Head& head, const Tail&... tail){dprint(head);cerr<<" ";debug(tail...);}

int main(){
    int h,w;
    while(1){
        scanf("%d %d",&h,&w);
        if(h==0&&w==0)break;
        rep(y,h){
            rep(x,w){
                putchar('#');
            }
            putchar('\n');
        }
        putchar('\n');
    }
}


Measured memory_bytes: 3104
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = 0;
		while(sc.hasNext()){
			String s = sc.next();
			if(s.equals((new StringBuffer(s)).reverse().toString()))n++;
		}
		System.out.println(n);
	}
}

Measured memory_bytes: 17140
#include <iostream>
#include <algorithm>

using namespace std;

int main(){
    int n;
    cin >> n;
    int p[n];
    for (int i =0; i<n; i++)
        cin >> p[i];
    
    int cnt = 0;
    for(int i=1; i<n-1; i++){
        if((p[i-1] < p[i] && p[i] < p[i+1])
        || (p[i-1] > p[i] && p[i] > p[i+1]) ) {
            cnt++;
        }
    }
    cout << cnt;
}

Measured memory_bytes: 256
N = int(input())
m, a, r, c, h = 0, 0, 0, 0, 0
for _ in range(N):
    s = input()
    if s[0] == "M":   m += 1
    if s[0] == "A":   a += 1
    if s[0] == "R":   r += 1
    if s[0] == "C":   c += 1
    if s[0] == "H":   h += 1
print(m*a*r + m*a*c + m*a*h + m*r*c + m*r*h + m*c*h + a*r*c + a*r*h + a*c*h + r*c*h)


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

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

	vector<int> a(n), b(n), c(n - 1);

	int ans = 0;

	for (int i = 0; i < n; i++) { cin >> a[i]; }
	for (int i = 0; i < n; i++) { 
		cin >> b[i];
		ans += b[i];
	}
	for (int i = 0; i < n - 1; i++) { cin >> c[i]; }

	for (int i = 0; i < n - 1; i++) {	
		if ( a[i + 1] == a[i] + 1) {
			ans += c[a[i] - 1];
		}
	}
	
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
/*COMPETITIVE PROGRAMMING C++ TEMPLATE */

#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <string>
#include <cmath>
#include <iostream>
#include <stack>
#include <queue>
#include <climits>
#include <iomanip>

#define all(x) x.begin(), x.end()
#define debug(x) cout << #x << " = " << x << "\n"
#define MOD 998244353

const long double PI = 3.141592653589793236L;

typedef long long int ll;
typedef long double ld;

using namespace std;

void solve()
{
    
    ll n;

    cin >> n;

    vector<int> str;



    while(n > 0)
    {
        n--;
        str.push_back(n % 26);
        n /= 26;
    }

    string ans = "";

    for(int i = 0; i < str.size(); i++)
    {
        ans += 'a' + str[i];
    }

    reverse(all(ans));

    
    cout << ans << endl;
}

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

    int T = 1;
    //cin >> T;
    
    while (T--)
    {
        solve();
    }
    
    return 0;
}



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

using namespace std;

#define N 800
#define LL long long

const LL mod=1000000007;
LL n,m,a[N],b[N],f[N][N],g[N][N];

void upd(LL &x,LL y){x=(x+y%mod+mod)%mod;}

int main(){
	scanf("%lld",&n);
	for (LL i=0;i<n*2;++i) scanf("%lld",a+i);
	for (LL i=0;i<n;++i){
		LL x=a[i<<1],y=a[i<<1|1];
		if (x>0&&y>0){b[x]=b[y]=-1; continue;}
		if (x<0&&y<0){++m; continue;}
		if (x>0) b[x]=1;
		if (y>0) b[y]=1;
	}
	f[0][0]=1;
	for (LL i=1,x=0,y=0;i<=n*2;++i){
		if (b[i]<0) continue;
		memset(g,0,sizeof g);
		if (b[i]>0){
			for (LL j=0;j<=x+y;++j)
				for (LL k=0;k<=x+y;++k){
					upd(g[j+1][k],f[j][k]);//m
					if (k) upd(g[j][k-1],f[j][k]*k);//m
				}
			++x;
		}
		else{
			for (LL j=0;j<=x+y;++j)
				for (LL k=0;k<=y;++k){
					if ((j-k-x+y)>=0&&m-(j-k-x+y)/2>0) upd(g[j+1][k],f[j][k]);//m-1
					if (j) upd(g[j-1][k],f[j][k]);//m
					upd(g[j][k+1],f[j][k]);//m
				}
			++y;
		}
		memcpy(f,g,sizeof f);
	}
	for (int i=1;i<=m;i++) f[0][0]=1LL*f[0][0]*i%mod;
	printf("%lld\n",f[0][0]);
	
	return 0;
}

Measured memory_bytes: 10368
#include <stdio.h>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>

using namespace std;


int main()
{
	int n;
	cin >> n;
	int a[3];

	a[0] = n / 100;
	a[1] = (n - a[0]*100) / 10;
	a[2] = (n - a[0]*100 - a[1]*10);


	for (int i = 0;i < 3;i++)
	{
		if (a[i] == 1)cout << "9";
		else cout << "1";
	}

	cout << endl;
}

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

#define DEBUG 0
 


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

    if(X >= 1800){
        cout << 1;
    }else if(X >= 1600){
        cout << 2;
    }else if(X >= 1400){
        cout << 3;
    }else if(X >= 1200){
        cout << 4;
    }else if(X >= 1000){
        cout << 5;
    }else if(X >= 800){
        cout << 6;
    }else if(X >= 600){
        cout << 7;
    }else{
        cout << 8;
    }


 



    return 0;

 
}



Measured memory_bytes: 3616
#include <iostream>
#include <iomanip>
#include <algorithm>
typedef long long ll;
using namespace std;
const ll INF = 1e9;
const ll MOD = 1e9 + 7;
#define repi(i, n, init) for (ll i = init; i < (n); i++)

int main()
{
    int n, k;
    cin >> n >> k;
    int cnt = 0;
    repi(i, n, 0)
    {
        int a;
        cin >> a;
        if (a != 1)
            cnt++;
    }
    cout << (cnt + k - 2) / (k - 1) << endl;
    return 0;
}

Measured memory_bytes: 256