akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <cstdio>
using namespace std;
using ll = long long;
const int MOD = 1000000007;

int main() {
    int n;
    cin >> n;
    vector<int> a(n);
    for (int i = 0; i < n; i++) {
	cin >> a[i];
    }
    ll s = 0;
    for (int i = 0; i < n; i++) {
	s += a[i];
	s %= MOD;
    }
    ll ans = 0;
    for (int i = 0; i < n; i++) {
	s -= a[i];
	s %= MOD;
	if ( s < 0) s += MOD;
	ans += (a[i] * s) % MOD;
	ans %= MOD;
    }
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 4020
#include<iostream>
#include<set>
using namespace std;
int main()
{
	char a;
	set<char> s;
	for(int i=0;i<3;i++){
		 cin>>a;
		 s.insert(a);
	}
	if(s.size()==3) cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
	return 0;
}

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

using namespace std;

int lt[200005], a[200005];

int main() {
    int n;
    scanf("%d", &n);
    
    for (int i = 0; i < n; i++) scanf("%d", &a[i]);
    
    int res = 0;
    memset(lt, -1, sizeof(lt));
    lt[0] = 0;
    
    for (int i = 0; i < n; i++) {
        if (lt[a[i] - 1] == -1) continue;
        lt[a[i]] = max(lt[a[i]], lt[a[i] - 1] + 1);
        res = max(res, lt[a[i]]);
    }
    
    if (res == 0) printf("-1\n");
    else printf("%d\n", n - res);
}

Measured memory_bytes: 1792
import sys

h, w, k = map(int, input().split())
MOD = 1000000007

dp = [[0] * w for _ in range(h + 1)]
dp[0][0] = 1

fn = [1, 1, 2, 3, 5, 8, 13, 21, 34]

if w == 1:
    print(1)
    sys.exit()

for i in range(1, h + 1):
    for j in range(w):
        dp[i][j] = dp[i - 1][j] * fn[j] * fn[w - j - 1]
        if j < w - 1:
            dp[i][j] += dp[i - 1][j + 1] * fn[j] * fn[w - j - 2]
        if 0 < j:
            dp[i][j] += dp[i - 1][j - 1] * fn[j - 1] * fn[w - j - 1]
        dp[i][j] %= MOD

print(dp[-1][k - 1] % MOD)

Measured memory_bytes: 9108
import sys

sys.setrecursionlimit(4100000)


def inputs(num_of_input):
    ins = [input() for i in range(num_of_input)]
    return ins


def solve(inputs):
    s = inputs[0]

    prev_c = s[0]

    for i in range(1, len(s)):
        if prev_c == s[i]:
            return "Bad"
        prev_c = s[i]

    return "Good"


def string_to_int(string):
    return list(map(lambda x: int(x), string.split()))


if __name__ == "__main__":
    ret = solve(inputs(1))
    print(ret)


Measured memory_bytes: 3064
#include<bits/stdc++.h>
//#include<boost/multiprecision/cpp_int.hpp>
#define fl(i,a,n) for(int i=a;i<=n;i++)
#define pb push_back
#define pob pop_back
#define int long long int
#define ff first
#define ss second
#define pi 3.1415926535898
#define vi vector<int>
#define mi map<int,int>
#define umi unordered_map<int,int>
#define endl "\n"
#define w(x) int x; cin>>x; while(x--)
#define db(x) cout<<(#x)<<" "<<(x)<<"\n";
#define db2(x,y) cout<<(#x)<<" "<<(x)<<" ,"<<(#y)<<" "<<(y)<<"\n";
#define db3(x,y,z) cout<<(#x)<<" "<<(x)<<" ,"<<(#y)<<" "<<(y)<<" ,"<<(#z)<<" "<<(z)<<"\n";
#define print(a) for(auto x:a){cout<<x<<" ";}
#define ios ios_base::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL);
using namespace std;
//using namespace boost::multiprecision;
int mod = 1000000007;
int gcd(int a, int b) {
    return (b == 0) ? a : gcd(b, a % b);
}
int lcm(int a, int b) {
    return (a * b) / gcd(a, b);
}
template<class type>
type power(type x, int n) {
    type temp; int y = n;
    if (y == 0) return 1;
    temp = power(x, y / 2);
    return ((y % 2) ? ((y > 0) ? x * temp * temp : (temp * temp) / x) : temp * temp);
}
void c_p_c() {
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
}
int32_t main() {

    ios
    //c_p_c();
    //w(t)
    {
int x;cin>>x;
int ans=0;
ans+=(x/500)*1000;
ans+=(x-(x/500)*500)/5*5;
cout<<ans<<endl;
}

    return 0;
}
//ctrl+option+F to auto format- sublimeastyleformat package


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

int main() {
  int a, b, c;
  cin >> a >> b >> c;
  
  int gcd = min(a, b);
  
  while(gcd > 1){
  	if(a == a/gcd * gcd && b == b/gcd * gcd) {
    	break;
    }
  else{
  	gcd--;
  }
  }
  if(c/gcd * gcd == c) {
  	cout << "YES" << endl;
  }
  else{
  	cout << "NO" << endl;
  }
  
}

Measured memory_bytes: 256
s = [input().split() for i in range(2)]

a, b, c, d = int(s[0][0]), int(s[0][1]), int(s[1][0]), int(s[1][1])

sum_cells_count = a * b
row_cells_count = b * c
col_cells_count = (a - c) * d

filled_cells_count = row_cells_count + col_cells_count

blank_cells_count = sum_cells_count - filled_cells_count
print(blank_cells_count)


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

int main() {
    ios::sync_with_stdio(false);
    string a;
    cin >> a;
    int af[30] = {0};
    for(int i = 0;i < a.length(); ++i) {
        af[a[i]-'a'] ++;
    }
    for(int i = 0;i < 26; ++i)
        if(af[i] == 0) {
            cout << char(i+'a') << "\n";
            return 0;
        }
    cout << "None\n";


    return 0;
}


Measured memory_bytes: 512
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <string>
#include <cstring>
#define pb push_back
#define mp make_pair
#define ll long long
using namespace std;

int n, k;
bool dislike[10];
bool cool(int x)
{
    while(x)
    {
        if(dislike[x % 10])
            return false;
        x /= 10;
    }
    return true;
}




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

    cin >> n >> k;
    for(int i = 1; i <= k; i++)
    {
        int x;
        cin >> x;
        dislike[x] = true;
    }

    while(!cool(n))
        n++;

    cout << n << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ll long long
#define fi first
#define se second
#define pb push_back
#define rep(i, s, n) for (int i = s; i < n; i++)
#define rrep(i, s, n) for (int i = (n)-1; i >= (s); i--)
#define REP(i,n) for(int i = 0;i < n; i++)
#define all(a) a.begin(),a.end()
typedef pair<int,int>pint;
typedef vector<int>vint;
typedef vector<pint>vpint;
const long long MOD = 1000000007, INF = 1e18;

#define endl '\n'
#define IOS() ios_base::sync_with_stdio(0);cin.tie(0)
 
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;}
template<typename T>vector<T>
make_v(size_t a){return vector<T>(a);}
template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
	return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}

template<typename T,typename V>
typename enable_if<is_class<T>::value==0>::type
fill_v(T &t,const V &v){t=v;}

template<typename T,typename V>
typename enable_if<is_class<T>::value!=0>::type
fill_v(T &t,const V &v){
	for(auto &e:t) fill_v(e,v);
}


signed main(){
	IOS();
	vector<int>ans;
	while(1){
		int N,M;
		cin>>N>>M;
		if(!N&&!M)break;
		int cost = 0;
		vector<pair<int,int>>v(N);
		rep(i,0,N)cin>>v[i].se>>v[i].fi;
		sort(all(v));
		reverse(all(v));
		rep(i,0,N){
			if(M>=v[i].se)M-=v[i].se;
			else{
				cost+=(v[i].se-M)*v[i].fi;
				M=max(0ll,M-v[i].se);
			}
		}
		ans.push_back(cost);
	}
	for(auto e:ans){
		cout<<e<<endl;
	}
}


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

int main() {
    int n;
    int k;
    int x;
    int moveCount = 0;
    cin >> n >> k;

    for (int i = 0; i < n; i++) {
        cin >> x;
        
        if (x < k - x) {
            moveCount += x;
        }
        else
        {
            moveCount += k - x;
        }
   }
    
    cout << moveCount * 2 << endl;
}

Measured memory_bytes: 3644
package main

import (
	"fmt"
)

func main() {

	var N, M int
	fmt.Scanf("%d %d", &N, &M)

	var A, sum int
	for i := 0; i < M; i++ {
		fmt.Scanf("%d", &A)
		sum = sum + A
	}

	if sum > N {
		fmt.Println("-1")
	} else {
		fmt.Println(N - sum)
	}
}


Measured memory_bytes: 2440
n = gets.to_i

(1..n).each do |i|
  x = i

  if (x % 3).zero?
    print " #{i}"
  elsif x % 10 == 3
    print " #{i}"
  else
    x /= 10
    until x.zero?
      if x % 10 == 3
        print " #{i}"
        break
      end
      x /= 10
    end
  end
end

puts



Measured memory_bytes: 8872
#include <algorithm>
#include <array>
#include <cstddef>
#include <cstdint>
#include <iostream>
#include <map>
#include <set>
#include <vector>

using namespace std;

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


Measured memory_bytes: 256
s = int(input())
mod = 10**9+7
n = s//3
ans = 0
for k in range(1, n+1):
    up = 1
    down = 1
    for i in range(k-1):
        up *= (s-2*k-1-i)
        up %= mod
        down *= (i+1)
    ans += up*pow(down, mod-2, mod)%mod
    ans %= mod
print(ans)

Measured memory_bytes: 73488
import java.util.Scanner;

public class Main{
 public static void main(String[] args) {
   Scanner kbd =new Scanner(System.in);
   int h=kbd.nextInt();
   int m=kbd.nextInt();
   int ht=kbd.nextInt();
   int mt=kbd.nextInt();
   int k=kbd.nextInt();
   int u=h*60+m;
   int s=ht*60+mt;
   System.out.println(s-u-k);
 }
}


Measured memory_bytes: 35776
/**
 *    author  : 𝒌𝒚𝒐𝒎𝒖𝒌𝒚𝒐𝒎𝒖𝒑𝒖𝒓𝒊𝒏
 *    created : 2020-03-15 01:37:45
**/

#include <iostream>
#include <deque>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <complex>
#include <numeric>
#include <bitset>
#include <cassert>
#include <cctype>
#include <iomanip>
#include <random>
#include <utility>
#include <chrono>

using namespace std;

using int64 = long long;

template<class T> using binary_heap = std::priority_queue<T, std::vector<T>, std::greater<T>>;
template<class T> std::ostream& operator<<(std::ostream& os, const std::vector<T>& vec) { os << '{'; size_t n = vec.size(); for (size_t i = 0; i < n; ++i) { os << vec[i]; if (i != n - 1) os << ','; } os << '}'; return os; }
template<class T, class U> std::ostream& operator<<(std::ostream& os, const std::pair<T, U>& p) { return os << '{' << p.first << " " << p.second << '}'; }
template<class T, class U> std::ostream& operator<<(std::ostream& os, const std::map<T, U>& mp) { os << '{'; for (auto it = mp.begin(); it != mp.end(); ++it) { os << '{' << it->first << ':' << it->second << '}'; if (it != --mp.end()) os << ','; } os << '}'; return os; }
template<class T> std::ostream& operator<<(std::ostream& os, const std::set<T>& st) { os << '{'; for (auto it = st.begin(); it != st.end(); ++it) { os << *it; if (it != --st.end()) os << ','; } os << '}'; return os; }
template<class T> std::istream& operator>>(std::istream& is, std::vector<T>& vec) { size_t n = vec.size(); for (size_t i = 0; i < n; ++i) is >> vec[i]; return is; }

#define all(_) begin(_), end(_)
#define rall(_) rbegin(_), rend(_)

#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]: ", debug_out(__VA_ARGS__)
#else
#define debug(...) 1728
#endif

void debug_out() { std::cerr << '\n'; }

template <class Head, class... Tail>
void debug_out(Head&& head, Tail&&... tail) {
  std::cerr << head;
  if (sizeof...(Tail) != 0) std::cerr << ", ";
  debug_out(std::forward<Tail>(tail)...);
}

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

  int n; cin >> n;

  auto DFS = [&](const auto& DFS, string s, int cur) -> void {
    if ((int) s.size() == n) {
      cout << s << '\n';
    } else {
      for (char c = 'a'; c <= (char)('a' + cur); ++c) {
        if (c == (char)('a' + cur)) {
          DFS(DFS, s + c, cur + 1);
        } else {
          DFS(DFS, s + c, cur);
        }
      }
    }
  };

  string s = "";

  DFS(DFS, s, 0);

  return 0;
}

Measured memory_bytes: 1536
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll inf = 1e18;
typedef pair<int,int> pii;
typedef pair<int,pii> pr;
ll dp[405][405];
ll minCost(vector<ll> &prefix,int i,int j){
	if(i >= j){
		return 0;
	}
	if(dp[i][j]!=-1){
		return dp[i][j];
	}
	ll ans = inf;
	for(int k=i;k<j;k++){
		ans = min(ans,prefix[j+1] - prefix[i] + minCost(prefix,i,k) + minCost(prefix,k+1,j));
	}
	return dp[i][j] = ans;
}
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	int n;
	cin>>n;
	vector<ll> arr(n);
	for(int i=0;i<n;i++){
		cin>>arr[i];
	}
	vector<ll> prefix(n+1,0);
	for(int i=1;i<=n;i++){
		prefix[i] = prefix[i-1] + arr[i-1];
	}
	memset(dp,-1,sizeof(dp));
	cout<<minCost(prefix,0,n-1)<<endl;
	return 0;
}

Measured memory_bytes: 4972
package main

import (
	"fmt"
)

func main() {
	var a int
	fmt.Scan(&a)
	var nums = make([]int, a)

	count := 0
	for i := 0; i < a; i++ {
		fmt.Scan(&nums[i])
		if nums[i] != i+1 {
			count++
		}
	}

	if count == 2 || count == 0 {
		fmt.Print("YES")
	} else {
		fmt.Println("NO")
	}

}


Measured memory_bytes: 512
#include <stdio.h>
#include <bits/stdc++.h>
#define pb push_back
#define pp pop_back
#define mp make_pair
#define f first
#define s second
#define all(x) x.begin(), x.end()
#define sz(x) (int)x.size()
typedef long long ll;

using namespace std;

const int N = 3e5 + 111, inf = 1e9, mod = 1e9 + 7, C = 2000;
const double pi = acos(-1.0), eps = 1e-9;
const ll INF = 1e18;

int n, m, ans, ok[N], cnt[N];

int main(){
	srand(time(NULL));
	cin.tie(0);
	cout.tie(0);
	ios_base::sync_with_stdio(0);
	cout << setprecision(10) << fixed;

	cin >> n >> m;
	ok[1] = 1;
	for(int i = 1; i <= m; ++i){
		int x, y;
		cin >> x >> y;
		ok[y] |= ok[x];
		cnt[y]++;
		cnt[x]--;
		if(cnt[x] == -1)
			ok[x] = 0;
	}

	for(int i = 1; i <= n; ++i)
		ans += ok[i];

	cout << ans;

	//cout << (clock() + 0.0) / CLOCKS_PER_SEC;
	return 0;
}

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

int main() {
    int i,j,k;
     string s;
    cin >> s;
    for(i=0; i<s.length(); i++)
    {
      if(i%2==0)
      {
        if(s[i]=='R' || s[i]=='U' || s[i]=='D')
        {
        }else
        {
            cout << "No" << endl;

          break;
        }
      }else 
      {
        if(s[i]=='L' || s[i]=='U' || s[i]=='D')
        {
        }else 
        {
            cout << "No" << endl;

          break;
        }
      }
      if(i==s.length()-1)
      {
        cout << "Yes" << endl;
      }
    }
  
}


Measured memory_bytes: 256
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"

using namespace std;

const long long int MOD = 1000000007;

long long int N, M, K, H, W, L, R;

long long int gcd(long long int a, long long int b) {
	if (a < b)swap(a, b);
	while (b) {
		a %= b;
		swap(a, b);
	}
	return a;
}

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

	int loop = 0;
	cin >> loop;
	vector<string>ans;
	while (loop) {
		loop--;
		cin >> N >> M >> L >> R;
		if (N < M) {
			ans.push_back("No");
			continue;
		}
		if (M > R) {
			ans.push_back("No");
			continue;
		}
		if (M <= L + 1) {
			ans.push_back("Yes");
			continue;
		}
		long long int lessL = N;
		lessL -= ((N - L) / M + !!((N - L) % M))*M;
		if (lessL < 0) {
			ans.push_back("No");
			continue;
		}
		long long int add = R % M;
		long long int deadL = L + 1;
		long long int deadR = M - 1;
		long long int g = gcd(M, add);
		if (g == 1) {
			ans.push_back("No");
			continue;
		}
		lessL %= g;
		deadL -= lessL;
		deadR -= lessL;
		if (deadR / g != deadL / g || deadL % g == 0) {
			ans.push_back("No");
			continue;
		}
		ans.push_back("Yes");
	}
	for (auto i : ans)cout << i << endl;
	return 0;
}

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

int main() {
	int totalTime = 0;
	for (int i = 0; i < 4; i++) {
		int x;
		cin >> x;
		totalTime += x;
	}
	cout << totalTime / 60 << endl;
	cout << totalTime % 60 << endl;
	return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
#define forx(i,a,b) for(int i=(a);i<(b);i++)
#define rep(j,n) for(int j=0;j<(n);j++)

typedef long long ll; 

int main()
{ 
    int a,b,c,d;
    cin>>a>>b>>c>>d;
    string s="No";
    if(abs(a-c)<=d)s="Yes";
    if(abs(a-b)<=d&&abs(c-b)<=d)s="Yes";
    cout<<s<<endl;
    
return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define R register
#define ll long long
#define mp make_pair
#define pii pair<int, int>
using namespace std;
const int N = 110000, M = N << 1;

int n, m, hd[N], to[M], nxt[M], fa[N], noedg = 1, ac, son, col[N], g[N], tp[N], cnt, vis[N];
ll ans;

inline void addEdg(int x, int y) {
    nxt[++noedg] = hd[x], hd[x] = noedg, to[noedg] = y;
    nxt[++noedg] = hd[y], hd[y] = noedg, to[noedg] = x;
    return;
}

template <class T>
inline void read(T &x) {
    x = 0;
    char ch = getchar(), w = 0;
    while (!isdigit(ch)) w = ch == '-', ch = getchar();
    while (isdigit(ch)) x = (x << 1) + (x << 3) + (ch ^ 48), ch = getchar();
    x = w ? -x : x;
    return;
}

void dfs(int now) {
    col[now] = col[fa[now]] ^ 1, vis[now] = 1;
    for (R int i = hd[now], v; i; i = nxt[i]) {
        if ((v = to[i]) == fa[now]) continue;
        if (vis[v]) {
            if (!ac) ac = v, son = now;
        }
        else fa[v] = now, dfs(v), g[now] += g[v];
    }
    g[now] += col[now] ? 1 : -1;
    return;
}

int main() {
    int x, y;
    read(n), read(m);
    if (n & 1) return printf("-1\n"), 0;
    for (R int i = 1; i <= m; ++i)
        read(x), read(y), addEdg(x, y);
    dfs(1);
    if (!ac) {
        if (g[1]) return printf("-1\n"), 0;
        for (R int i = 1; i <= n; ++i)
            ans += abs(g[i]);
        return printf("%lld\n", ans), 0;
    }
    if (col[ac] == col[son]) {
        ans = g[1] >> 1;
        for (R int i = ac; i; i = fa[i])
            g[i] -= ans;
        for (R int i = son; i; i = fa[i])
            g[i] -= ans;
        ans = abs(ans);
        for (R int i = 1; i <= n; ++i)
            ans += abs(g[i]);
        return printf("%lld\n", ans), 0;
    }
    if (g[1]) return printf("-1\n"), 0;
    for (R int i = son; i != ac; i = fa[i])
        tp[++cnt] = g[i];
    tp[++cnt] = 0;
    sort(tp + 1, tp + 1 + cnt);
    ans = tp[(cnt + 1) >> 1];
    for (R int i = son; i != ac; i = fa[i])
        g[i] -= ans;
    ans = abs(ans);
    for (R int i = 1; i <= n; ++i)
        ans += abs(g[i]);
    cout << ans << endl;
    return 0;
}

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

#define Vsort(a) sort(a.begin(), a.end())
#define Vreverse(a) reverse(a.bigin(), a.end())
#define Srep(n) for(int i = 0; i < (n); i++)
#define rep(i,n) for(int i = 0; i < (n); i++)
#define Lrep(i,a,n) for(int i = (a); i < (n); i++)
#define Brep(n) for(int bit = 0; bit < (1<<n); bit++)
#define vi vector<int>
#define vi64 vector<int64_t>
#define vvi vector<vector<int>>
#define vvi64 vector<vector<int64_t>>

using namespace std;

int main(){
    int a,b;
    cin >> a >> b;
    if(a <= 5) cout << "0" << endl;
    else if((a > 5) && (a <= 12)) cout << b / 2 << endl;
    else cout << b << endl;
}

Measured memory_bytes: 3612
#include<stdio.h>
#define MAX 100000
#define SENTINEL 2000000000

struct Card{
  char suit;
  int value;
};

struct Card L[MAX/2+2], R[MAX/2+2];

void merge(struct Card A[], int n, int left, int mid, int right){
  int i, j, k;
  int n1 = mid - left;
  int n2 = right - mid;
  for ( i = 0 ; i < n1 ; i++ ) L[i] = A[left + i];
  for ( i = 0 ; i < n2 ; i++ ) R[i] = A[mid + i];
  L[n1].value = R[n2].value = SENTINEL;
  i = j = 0;
  for ( k = left ; k < right ; k++ ){
    if ( L[i].value <= R[j].value ){
      A[k] = L[i++];
    }
    else {
      A[k] = R[j++];
    }
  }
}

void mergeSort(struct Card A[],int n,int left,int right){
  int mid;
  if ( left+1 < right ){
    mid = (left + right)/2;
    mergeSort(A,n,left,mid);
    mergeSort(A,n,mid,right);
    merge(A,n,left,mid,right);
  }
}

int partition(struct Card A[],int n,int p,int r){
  int i, j;
  struct Card w, x;
  x = A[r];
  i = p - 1;
  for ( j = p ; j < r ; j++ ){
    if ( A[j].value <= x.value ){
      i++;
      w = A[i];
      A[i] = A[j];
      A[j] = w;
    }
  }
  w = A[i+1];
  A[i+1] = A[r];
  A[r] = w;
  return i+1;
}

void quickSort(struct Card A[],int n,int p,int r){
  int q;
  if ( p < r ){
    q = partition(A, n, p, r);
    quickSort(A, n, p, q - 1);
    quickSort(A, n, q + 1, r);
  }
}

int main(){
  int n, i, v;
  struct Card A[MAX], B[MAX];
  char C[10];
  int stable = 1;
  scanf("%d",&n);

  for ( i = 0 ; i < n ; i++ ) {
    scanf("%s %d",C,&v);
    A[i].suit = B[i].suit = C[0];
    A[i].value = B[i].value = v;
  }

  mergeSort(A,n,0,n);
  quickSort(B,n,0,n-1);

  for ( i = 0 ; i < n ; i++ ){
    if ( A[i].suit != B[i].suit )
      stable = 0;
  }

  if ( stable == 1 ) printf("Stable\n");
  else printf("Not stable\n");
  for ( i = 0 ; i < n ; i++ ) {
    printf("%c %d\n",B[i].suit,B[i].value);
  }
}


Measured memory_bytes: 4092
#include<iostream>
#include<cstdio>
#include<string>
#include<cstdlib>
using namespace std;


struct Node {
	int key;
	Node *right, *left, *parent;
};

Node *root, *NIL;

void insert(int k) {
	Node *y = NIL;
	Node *x = root;
	Node *z;


	z = (Node *)malloc(sizeof(Node));

	z->key = k;
	z->left = NIL;
	z->right = NIL;

	while (x != NIL) {
		y = x;
		if (z->key < x->key) {
			x = x->left;
		}
		else {
			x = x->right;
		}
	}
	z->parent = y;
	if (y == NIL) {
		root = z;
	}
	else {
		if (z->key < y->key) {
			y->left = z;

		}
		else {
			y->right = z;
		}
	}
}

Node* find(Node *x, int k) {

	while (x != NIL && k != x->key) {
		if (k < x->key) {
			x = x->left;
		}
		else {
			x = x->right;
		}
	}
	return x;
}

Node * treeMinimum(Node *x) {
	while (x->left != NIL)x = x->left;
	return x;
}
Node * treeSuccessor(Node *x) {
	if (x->right != NIL) return treeMinimum(x->right);
	Node *y = x->parent;
	while (y != NIL && x == y->right) {
		x = y;
		y = y->parent;
	}
	return y;
}
void treeDelete(Node *z) {
	Node *y;//削除する対象
	Node *x;//yの子

	if (z->left == NIL || z->right == NIL)y = z;
	else y = treeSuccessor(z);

	if (y->left != NIL) {
		x = y->left;
	}
	else {
		x = y->right;
	}

	if (x != NIL) {
		x->parent = y->parent;
	}

	if (y->parent == NIL) {
		root = y;
	}
	else {
		if (y == y->parent->left) {
			y->parent->left = x;
		}
		else {
			y->parent->right = x;
		}
	}

	if (y != z) {
		z->key = y->key;
	}

	free(y);
}

void inorder(Node *u) {
	if (u == NIL)return;
	inorder(u->left);
	printf(" %d", u->key);
	inorder(u->right);
}

void preorder(Node *u) {
	if (u == NIL)return;
	printf(" %d", u->key);
	preorder(u->left);
	preorder(u->right);

}

int main() {
	int n, i, x;
	string com;

	cin >> n;
	for (i = 0; i < n; i++) {
		cin >> com;
		if (com == "insert") {
			scanf("%d", &x);
			insert(x);
		}
		else if (com == "print") {
			inorder(root);
			printf("\n");
			preorder(root);
			printf("\n");

		}
		else if (com == "find") {
			scanf("%d", &x);
			Node* no = find(root, x);
			if (no == NIL) {
				printf("no\n");
			}
			else {
				printf("yes\n");
			}

		}
		else if (com == "delete") {
			scanf("%d", &x);
			treeDelete(find(root, x));
		}
	}

	return 0;

}


Measured memory_bytes: 21932
#include <bits/stdc++.h>
#define vsort(v) sort(v.begin(), v.end())
#define rvsort(v) sort(v.begin(), v.end(), greater<ll>())
#define prvsort(v) sort(v.begin(), v.end(), greater<pair<ll, ll>>())
#define ll long long
#define ld long double
#define fixset(val) fixed << setprecision(10) << val 
#define rep(i, s, g) for (ll i = (s); i < (g); i++)
#define mod 1000000007
#define vfind(v, target) find(v.begin(), v.end(), target)
#define notFound(v, target) (vfind(v, target) == v.end())

using namespace std;

int main()
{
  string S; cin >> S;
  ll N = S.size();
  vector<ll> A(N, 0);
  ll a = 0, b, c;
  rep(i, 0, N) {
  	if (S.substr(i, 2) == "RL") {
    	b = i;
    }
    if (i == N - 1 || S.substr(i, 2) == "LR") {
    	c = i;
      	if ((c - a + 1) % 2 == 0) {
        	A[b] = (c - a + 1) / 2;
          	A[b + 1] = A[b];
        } else if ((b - a + 1) % 2 == 1){
        	A[b + 1] = (c - a + 1) / 2;
          	A[b] = A[b + 1] + 1;
        } else {
        	A[b] = (c - a + 1) / 2;
          	A[b + 1] = A[b] + 1;
        }
      	if (i < N - 1) a = i + 1;     	
    }
  }
  rep(i, 0, N) {
  	cout << A[i] << " ";
  }
}

Measured memory_bytes: 1408
A1 = list(map(int,input().split(' ')))
A2 = list(map(int,input().split(' ')))
A3 = list(map(int,input().split(' ')))
N = int(input())
B = [0]*N
for i in range(N):
    b = int(input())
    B[i]=b

marubatu = [[0,0,0],
[0,0,0],
[0,0,0]]

for b in B:
    for i,a1 in enumerate(A1):
        if b==a1:
            marubatu[0][i]=1
    for i,a2 in enumerate(A2):
        if b==a2:
            marubatu[1][i]=1
    for i,a3 in enumerate(A3):
        if b==a3:
            marubatu[2][i]=1

def tate():
    f = False
    for i in range(3):
        if (marubatu[i][0])and(marubatu[i][1])and(marubatu[i][2]==1):
            f=True
    return f

def yoko():
    f = False
    for i in range(3):
        if (marubatu[0][i])and(marubatu[1][i])and(marubatu[2][i]==1):
            f=True
    return f

def migisagari():
    f = False
    if (marubatu[0][0])and(marubatu[1][1])and(marubatu[2][2]==1):
        f=True
    return f

def hidarisagari():
    flag=False
    if (marubatu[0][2])and(marubatu[1][1])and(marubatu[2][0]==1):
        flag=True
    return flag

#print(marubatu)

f1 = tate()
f2 = yoko()
f3 = migisagari()
f4 = hidarisagari()

if f1 or f2 or f3 or f4:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 3188
def MAP(): return map(int,input().split())
s = input()
ans_1, ans_2= 0,0
for i,v in enumerate(s):
    if (i%2==0) and (v!="0"):
        ans_1+=1
    elif (i%2==1) and (v!="1"):
        ans_1+=1

for i,v in enumerate(s):
    if (i%2==0) and (v!="1"):
        ans_2+=1
    elif (i%2==1) and (v!="0"):
        ans_2+=1

print(min(ans_1,ans_2))

Measured memory_bytes: 3188
#include <bits/stdc++.h>
#define SORT(a) sort(a.begin(), a.end())
#define RSORT(a) sort(a.rbegin(), a.rend())
#define REP(i, n) for (int i = 0; i < n; i++)
#define RREP(i, n) for (int i = n - 1; 0 <= i; i--)
#define FOR(i, start, end) for (int i = start; i < end; i++)
#define RFOR(i, start, end) for (int i = start - 1; 0 <= i; i--)
#define ALL(a) a.begin(), a.end()
using ll = long long;
using namespace std;
constexpr int INF32       = 1'050'000'000;
constexpr long long INF64 = 4'000'000'000'000'000'000;
constexpr int MOD7        = 1'000'000'007;
constexpr int MOD9        = 1'000'000'009;
template <class T> inline bool chmin(T &a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template <class T> inline bool chmax(T &a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
void print() { std::cout << '\n'; }
template <class H, class... T> void print(H &&head, T &&... args) {
    std::cout << head;
    sizeof...(args) == 0 ? std::cout << "" : std::cout << ' ';
    print(std::forward<T>(args)...);
}
template <class T> void print(std::vector<T> &v) {
    for (int i = 0; i < v.size(); i++) {
        std::cout << v[i];
        i == v.size() - 1 ? std::cout << '\n' : std::cout << ' ';
    }
}
template <class T> void print(std::vector<std::vector<T>> &v) {
    for (int i = 0; i < v.size(); i++) {
        for (int j = 0; j < v[i].size(); j++) {
            std::cout << v[i][j];
            j == v[i].size() - 1 ? std::cout << '\n' : std::cout << ' ';
        }
    }
}
void scan() {}
template <class H, class... T> void scan(H &&head, T &&... args) {
    std::cin >> head;
    scan(std::forward<T>(args)...);
}
template <class T> void scan(std::vector<T> &v) {
    for (auto &&i : v) {
        scan(i);
    }
}

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

    ll N;
    scan(N);
    ll ans = (N * (N - 1)) / 2;
    print(ans);

    return 0;
}

Measured memory_bytes: 256
N, K = map(int, input().split())
S = input()

# 累積和で実装

now = 1
cnt = 0
nums = []
for i in range(N):
    if int(S[i]) == now:
        cnt += 1
    else:
        nums.append(cnt)
        cnt = 1
        now = 1 - now
nums.append(cnt)
if int(S[-1]) == 0:
    nums.append(0)

# print(nums)

cumulative_sum = []
M = len(nums)
sum = 0
for i in range(M):
    sum += nums[i]
    cumulative_sum.append(sum)

# print(cumulative_sum)

ans = 0
start = 0
final = 2 * K
answers = []

# M = len(nums) = len(cumulative_sum)
if M < 2 * K + 1:
    print(len(S))
    exit()
if final <= M-1:
    while(final <= M-1):
        if start == 0:
            answers.append(cumulative_sum[final])
        else:
            ans = cumulative_sum[final] - cumulative_sum[start-1]
            answers.append(ans)

        # print(start, final, ans)
        start += 2
        final += 2
    print(max(answers))
else:
    print(cumulative_sum[0])

# print(answers)


Measured memory_bytes: 9468
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = int64_t;
using P = pair<ll, ll>;
template <class T>
using V = vector<T>;

struct L {
  ll cost;
  int x;
  int y;
  bool operator<(const L& rhs) const { return cost < rhs.cost; }
  bool operator>(const L& rhs) const { return cost > rhs.cost; }
};

const ll INF = 1e9;

int main() {
  int h, w;
  cin >> h >> w;
  int sx, sy, gx, gy;
  cin >> sy >> sx;
  cin >> gy >> gx;
  sx--;
  sy--;
  gx--;
  gy--;
  V<string> g(h);
  rep(i, h) cin >> g[i];

  V<V<ll>> c(h, V<ll>(w, INF));
  priority_queue<L, V<L>, greater<L>> q;

  q.push({0, sx, sy});
  while (!q.empty()) {
    auto e = q.top();
    q.pop();
    for (int i = -2; i <= 2; i++)
      for (int j = -2; j <= 2; j++) {
        int x = e.x + i;
        int y = e.y + j;
        if (x >= w || y >= h) continue;
        if (x < 0 || y < 0) continue;
        if (g[y][x] == '#') continue;
        ll cost = e.cost;
        if (abs(i) + abs(j) > 1) cost++;
        if (cost < c[y][x]) {
          q.push({cost, x, y});
          c[y][x] = cost;
        }
      }
  }
  ll ans = c[gy][gx];
  if (ans == INF) ans = -1;
  cout << ans << endl;
}


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

using namespace std; 


int main(){
	
	string s; 
	int year;
	int month;
	int plus = 0;
	int day;
	string cad; 
	cin >> s;
	
	for(int i=0;i<s.size();i++){
		
		if(s[i]=='/'){
			plus++;
			stringstream val(cad);
			if(plus==1) val >> year;
			if(plus==2)val >> month;
			cad = "";
		}else{
			cad+=s[i];
		}
	}
	
	stringstream val(cad);
	val >> day ;
	
	bool ans = (year>2019||(year==2019 && month>4))?true:false;
	
	if(ans){
		cout << "TBD" << endl;
	}else{
		cout << "Heisei" << endl;
	}
	
	
		
    return 0;
}


Measured memory_bytes: 384
X, Y = map(int, input().split())
counter = 0
if Y % 2 != 0:
    print("No")
    quit()
else:
    while X >= 0:
        i = (X * 2) + (counter * 4)
        if i == Y:
            print("Yes")
            quit()
        X -= 1
        counter += 1
print("No")



Measured memory_bytes: 9172
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.IO;

namespace ABC
{
    class ABC171C
    {
        const string FILE = "/tmp/data.txt";

        static void Main(string[] args)
        {
#if DEBUG
            Console.SetIn(new StreamReader(FILE));
#endif
            string line;
            line = Console.ReadLine();
            long N = long.Parse(line);

            Console.WriteLine(ToName(N));
            /*
            Console.WriteLine("1:" + ToName(1));
            Console.WriteLine("2:" + ToName(2));
            Console.WriteLine("25:" + ToName(25));
            Console.WriteLine("26:" + ToName(26));
            Console.WriteLine("27:" + ToName(27));
            Console.WriteLine("51:" + ToName(51));
            Console.WriteLine("52:" + ToName(52));
            Console.WriteLine("53:" + ToName(53));
            Console.WriteLine("701:" + ToName(701));
            Console.WriteLine("702:" + ToName(702));
            Console.WriteLine("703:" + ToName(703));
            for (int i = 25; i < 100; ++i)
            {
                Console.WriteLine(i + ":" + ToName(i));
            }
            for (int i = 650; i < 705; ++i)
            {
                Console.WriteLine(i + ":" + ToName(i));
            }
            */

            //string s = N.ToString("x");




            /*
            foreach( char c in s )
            {
                if (c <= '9')
                {
                    result.Append((char)('a' + c - '1'));
                }
                else
                {
                    result.Append((char)(c + 9));
                }
            }
            Console.WriteLine(result);
            */

#if DEBUG
            Console.WriteLine("*** end ***");
            Console.SetIn(Console.In);
            Console.ReadKey();
            Console.WriteLine();
#endif
        }

        public static string ToName(long N)
        {
            StringBuilder result = new StringBuilder();
            while (N > 0)
            {
                N -= 1;
                long endN = N % 26;
                char c = (char)('a' + endN);
                result.Append(c);
                N /= 26;
            }
            return string.Join("", result.ToString().Reverse());
        }
    }



}


Measured memory_bytes: 28296
#include <iostream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <map>
#include <set>
#include <list>
#include <algorithm>
#include <cctype>
#include <queue>
#include <complex>
#include <functional>
#include <sstream>
#include <tuple>

using namespace std;

int main()
{
#ifdef IMPETUS
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    string s;
    long long k;
    cin >> s >> k;
    int f = -1;
    for (int i = 0; i < s.length(); i++)
    	if (s[i] != '1')
    	{
    		f = i;
    		break;
    	}
    if (f == -1 || k < f + 1)
    	cout << "1";
    else
    	cout << s[f];
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#define rep(i, start, end) for (int i = (int)start; i < (int)end; ++i)
#define rrep(i, start, end) for (int i = (int)start - 1; i >= (int)end; --i)
#define all(x) (x).begin(), (x).end()
using namespace std;
using ll = long long;
template<typename T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return 0;}
template<typename T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return 0;}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int D, S, T;
    cin >> D >> S >> T;
    if (D <= T * S) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    return 0;
}

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

using namespace std;

int main(){

  map< char , int > count;

  string str;

  while( cin>>str ){

    for(int i=0;i<(int)str.size();i++){
      if(isupper(str[i])){
	str[i]  = tolower(str[i]);
      }


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

  for(char ch='a';ch<='z';ch++){

    cout << ch << " : " << count[ch] << endl;
  }

  return 0;

}


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

using Graph = vector< pair<int, vector<int> > >;

const ll INF64 = 1LL << 60;
const int INF32 = 1 << 29;
const int MOD = 1000000007;

// Lib
//

int main(){
#ifdef MYLOCAL
    ifstream in("input.txt");
    cin.rdbuf(in.rdbuf());
#endif
    int N, Q;
    cin >> N >> Q;
    Graph tree(N);
    for(int i = 0; i < N - 1; ++i){
        int a, b; cin >> a >> b;
        --a, --b;
        tree[b].second.push_back(a);
    }

    for(int i = 0; i < Q; ++i){
        int p, x; cin >> p >> x;
        --p;
        tree[p].first += x;
    }

    for(int i = 0; i < N; ++i){
        for(auto it : tree[i].second){
            tree[i].first += tree[it].first;
        }
        cout << tree[i].first << endl;
    }

    return 0;
}


Measured memory_bytes: 15872
#include <iostream>
#include <string>
#include <algorithm>
#include <set>
#include <cmath>
#include <vector>
#include <numeric>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <tuple>

using ll = long long int;
using ul = unsigned long long int;
const ll LL_MAX (1LL<<60);
const ll MOD (1000000007);

#define rep(i,s,e) for(ll i=(s); i<(e); i++) 

using namespace std;

using T = tuple<ll,ll>;
using Graph = vector<vector<T>>;

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

    ll x, y, z;
    cin >> x >> y >> z;
    swap(x, y);
    swap(x, z);

    cout << x << " " << y << " " << z << endl;

    return 0;
}


Measured memory_bytes: 256
import heapq
V, E ,r = list(map(int, input().split()))

INF = 10 ** 15

# ダイクストラのアルゴリズムは
# 再帰
def dijkstra(edges, s):
    d = [INF for x in range(V)]
    d[s] = 0
    que = []
    heapq.heappush(que, (0,s))
    while len(que) > 0:
        u_d,u = heapq.heappop(que)
        if d[u] < u_d:
            continue
        for  v_d,v in edges[u]:
            if d[v] > d[u] + v_d:
                d[v] = d[u] + v_d
                heapq.heappush(que,(d[v],v))
    return d

#cost = [[float("inf") for i in range(V)] for i in range(V)] 
cost = [[] for i in range(V)]
#cost[u][v] : 辺uvのコスト(存在しないときはinf この場合は10**10)
for i in range(E):
    x,y,z = map(int,input().split())
    cost[x].append((z, y))
    #cost[y][x] = z
d = dijkstra(cost, r)
for c in d:
    if c == INF:
        print("INF")
    else:
        print(c)


Measured memory_bytes: 89284
import java.util.ArrayList;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner in = new Scanner(System.in);
		// ?????????????????°?????\???
		int gameCount = in.nextInt();
		// ??????????????????????????°????????\???
		int[] cardNum = new int[9];
		// ????????????????????????????????\???
		String[] cardColor = new String[9];
		// ??????????????????????´????????????????
		ArrayList<Integer> resultList = new ArrayList<>();

		for(int setCount = 0; setCount < gameCount; setCount++) {

			for(int cardCount = 0; cardCount < 9; cardCount++) {

				cardNum[cardCount] = in.nextInt();

			}

			for(int cardCount = 0; cardCount < 9; cardCount++) {

				cardColor[cardCount] = in.next();

			}


			Rummy rummy = new Rummy();

			int[][] hasCard = rummy.hasCardSet(cardNum, cardColor);

			int point = 0;

			point += rummy.sameNumberCheck(hasCard);

			point += rummy.continuousNumberCheck(hasCard);

			if(point == 3) {

				resultList.add(1);

			} else {

				resultList.add(0);

			}
		}

		for(int result: resultList) {

			System.out.println(result);

		}

	}
}

class Rummy{


	// ???????????????????????????????????£??????????????´?????????????????????
	int[][] hasCardSet(int[] cardNum, String[] cardColor) {

		int[][] hasCard = new int[3][9];

		for(int i = 0; i < 9; i++) {

			for(int j = 1; j <= 9; j++) {

				if(cardNum[i] == j) {

					switch(cardColor[i]) {

					case "R":

						hasCard[0][j-1] += 1;

						break;

					case "G":

						hasCard[1][j-1] += 1;

						break;

					case "B":

						hasCard[2][j-1] += 1;

						break;

					}

					break;

				}
			}
		}

		return hasCard;

	}

	int sameNumberCheck(int[][] hasCard) {

		int point = 0;


		for(int i = 0; i < 3; i++) {

			for(int j = 0; j < 9; j++) {

				if(hasCard[i][j] >= 3) {

					point++;
					hasCard[i][j] -= 3;

				}
			}
		}

		return point;

	}

	int continuousNumberCheck(int[][] hasCard) {

		int point = 0;
		int continuousCount = 0;


		for(int i = 0; i < 3; i++) {

			for(int j = 0; j < 9; j++) {

				if(hasCard[i][j] != 0) {

					continuousCount++;

					if(continuousCount == 3) {

						point++;
						hasCard[i][j] -= 1;
						hasCard[i][j-1] -= 1;
						hasCard[i][j-2] -= 1;
						j = 0;
						continuousCount = 0;

					}

				} else {

					continuousCount = 0;

				}
			}
		}

		return point;

	}
}

Measured memory_bytes: 29848
#include<bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < n; i++)
#define vi vector<int>
#define all(x) (x).begin(),(x).end()
#define INF (1<<30)-1
using ll = long long;
using namespace std;
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; }

int main(){
  int h,w,k; cin >> h >> w >> k;
  vector<vector<char>> c(h,vector<char>(w));
  rep(i,h) rep(j,w) cin >> c[i][j];

  int ans = 0;
  rep(bit_h,1<<h){
    rep(bit_w,1<<w){
      int cnt = 0;
      rep(i,h){
        if(bit_h>>i & 1){
          rep(j,w){
            if(bit_w>>j & 1){
              if(c[i][j] == '#') cnt++;
            }
          }
        }
      }
      if(cnt == k) ans++;
    }
  }
  cout << ans;
  return 0;
}


Measured memory_bytes: 3632
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

class Main {

    public static void main(String[] args) throws IOException {
        ReaderC.init(System.in);
        int n = ReaderC.nextInt();
        int[][] a = new int[2][n];

        for (int i = 0; i < a.length; i++) {
            for (int j = 0; j < a[i].length; j++) {
                a[i][j] = ReaderC.nextInt();
            }
        }

        for (int i = a.length - 1; i >= 0; i--) {
            for (int j = a[i].length - 1; j >= 0; j--) {
                int max = 0;
                if (i < a.length - 1) max = Math.max(max, a[i + 1][j]);
                if (j < a[i].length - 1) max = Math.max(max, a[i][j + 1]);
                a[i][j] += max;
            }
        }

        System.out.println(a[0][0]);
    }
}

/**
 * Reader class based on the article at "https://www.cpe.ku.ac.th/~jim/java-io.html"
 */
class ReaderC {
    private static BufferedReader reader;
    private static StringTokenizer tokenizer;

    static void init(InputStream inputStream) {
        reader = new BufferedReader(new InputStreamReader(inputStream));
        tokenizer = new StringTokenizer("");
    }

    static String next() throws IOException {
        String read;
        while (!tokenizer.hasMoreTokens()) {
            read = reader.readLine();
            if (read == null || read.equals(""))
                return "-1";
            tokenizer = new StringTokenizer(read);
        }

        return tokenizer.nextToken();
    }

    static int nextInt() throws IOException {
        return Integer.parseInt(next());
    }

    static long nextLong() throws IOException {
        return Long.parseLong(next());
    }

    //    Get a whole line.
    static String line() throws IOException {
        return reader.readLine();
    }

    static double nextDouble() throws IOException {
        return Double.parseDouble(next());
    }
}



Measured memory_bytes: 21332
import sys
sys.setrecursionlimit(10**6)
from math import floor,ceil,sqrt,factorial,log
from heapq import heappop, heappush, heappushpop
from collections import Counter,defaultdict,deque
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from bisect import bisect_left,bisect_right
from copy import deepcopy
from operator import itemgetter
from fractions import gcd
mod = 10 ** 9 + 7
inf = float('inf')
ninf = -float('inf')
 
#整数input
def ii(): return int(sys.stdin.readline().rstrip()) #int(input())
def mii(): return map(int,sys.stdin.readline().rstrip().split())
def limii(): return list(mii()) #list(map(int,input().split()))
def lin(n:int): return [ii() for _ in range(n)]
def llint(n: int): return [limii() for _ in range(n)]
#文字列input
def ss(): return sys.stdin.readline().rstrip() #input()
def mss(): return sys.stdin.readline().rstrip().split()
def limss(): return list(mss()) #list(input().split())
def lst(n:int): return [ss() for _ in range(n)]
def llstr(n: int): return [limss() for _ in range(n)]

#本当に貪欲法か？ DP法では？？
#本当に貪欲法か？ DP法では？？
#本当に貪欲法か？ DP法では？？

#https://atcoder.jp/contests/cf16-final-open/tasks/codefestival_2016_final_b

n=ii()

if n==1:
    print(1)
    exit()

ans=0
i=0
p=0
while ans<n:
    i+=1
    ans+=i
if ans>n:
    p=ans-n

for k in range(1,i+1):
    if k!=p:
        print(k)

Measured memory_bytes: 67428
use std::io::{stdin, Read, StdinLock};
use std::str::FromStr;
use std::cmp;

struct Scanner<'a> {
    cin : StdinLock<'a>,
}

impl<'a> Scanner<'a> {
    fn new(cin : StdinLock<'a>) -> Scanner<'a> {
        Scanner { cin: cin }
    }

    fn read1<T: FromStr>(&mut self) -> Option<T> {
        let token = self.cin.by_ref().bytes().map(|c| c.unwrap() as char)
            .skip_while(|c| c.is_whitespace())
            .take_while(|c| !c.is_whitespace())
            .collect::<String>();
        token.parse::<T>().ok()
    }

    fn read<T: FromStr>(&mut self) -> T {
        self.read1().unwrap()
    }
}

fn main(){
    loop{
        let cin = stdin();
        let cin = cin.lock();
        let mut sc = Scanner::new(cin);
        let n : usize = sc.read();
        let m : i32 = sc.read();
        if n == 0 { break; }
        let mut v : Vec<i32> = Vec::with_capacity(n);
        for _i in 0..n {
            v.push(sc.read());
        }
        let mut ans : i32 = -1;
        for i in 0..n {
            for j in i+1..n {
                if v[i]+v[j] <= m {
                    ans = cmp::max(ans, v[i]+v[j])
                }
            }
        }
        if ans < 0 {
            println!("NONE");
        } else {
            println!("{}", ans);
        }
    }
}
    




Measured memory_bytes: 5048
using System;

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] list = Console.ReadLine().Split(' ');
            int r = int.Parse(list[0]);
            int d = int.Parse(list[1]);
            int x = int.Parse(list[2]);

            for (int i = 1; i <= 10; i++)
            {
                x = r * x - d;
                Console.WriteLine(x);
            }
        }
    }
}


Measured memory_bytes: 13140
#include <iostream>
#include <cmath>
#include <string>
#include <numeric>
#include <algorithm>
#include <iomanip>
#include <queue>
#include <vector>
using namespace std;
#define INF 1000000007
#define ll long long
#define rep(i_, __start, __end) for(ll i_=(ll)__start; i_<(ll)__end; i_++)
#define print(_a) cout << _a << endl;
#define printarray(a, len) rep(ii,0,len) cout << a[ii] << " ";
#define printarray2(aa, len) rep(ij,0,len) printarray(aa[ij], aa[ij].size()); print("");


int main(){
    string s;
    cin >> s;
    if((s[0] == s[1] && s[1] == s[2]) || (s[1] == s[2] && s[2] == s[3])){
      print("Yes");
    }else{
      print("No");
    }
   
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
typedef pair<int,int> pi;
#define f first
#define s second
#define FAST ios_base::sync_with_stdio(0); cin.tie(0);
const int mod = 2019;

string S;
int A[200005];
int co[2050];

int32_t main() {
	cin >> S;
	int val = 0, pow = 1;
	for (int i = S.length()-1; i >= 0; i--) {
		val += (pow * (S[i] - '0'));
		val %= mod;
		
		pow *= 10;
		pow %= mod;
		
		co[val]++;
		A[i] = val;
	}
	
	int ans = 0;
	for (int i =S.length()-1;i>=0;i--) {
		ans += co[A[i+1]];
		co[A[i]]--;
	}
	cout << ans;
}


Measured memory_bytes: 5320
#include<stdio.h>
int main(void){
  int a,b,k,i;
  scanf("%d%d%d",&a,&b,&k);
  for(i=0;i<k;i++){
    if(i%2){
      a+=(b/2);
      b-=(b/2+b%2);
    }
    else{
      b+=(a/2);
      a-=(a/2+a%2);
    }
  }
  printf("%d %d",a,b);
  return 0;
}

Measured memory_bytes: 128
A,B = map(int,input().split())
A-=1
def func(a):
    if a%2 == 1:
        onenum = a//2
        if onenum%2 == 1:
            return 0
        else:
            return 1
    else:
        onenum = a//2
        if onenum%2 == 0:
            return a
        else:
            return 1^a
print(func(B)^func(A))

Measured memory_bytes: 3060
#include <stdio.h>
int main(){
	int a, b, c, d, n, i, j;
	int count[4][3][10] = {};
	scanf("%d", &n);
	for(i =0; i < n; i++){
		scanf("%d %d %d %d", &a, &b, &c, &d);
		count[a-1][b-1][c-1] += d;
	}
	for(a = 0; a < 4; a ++){
		for(b = 0; b < 3; b++){
			for(c = 0; c < 10; c++){
				if(c == 9){
					printf(" %d\n", count[a][b][c]);
				}else{
					printf(" %d", count[a][b][c]);
				}
			}
			if(a != 3 && b == 2){
				for(j = 0; j < 20; j++){
					printf("#");
					if(j == 19){
						printf("\n");
					}
				}
			}
		}
	}
	
	return 0;
}

Measured memory_bytes: 600
#include<bits/stdc++.h>
using namespace std;
int main(){
  map<int,int>cnt;
  int n;
  cin>>n;
  for(int i=0;i<n;i++){
    int a;
    cin>>a;
    cnt[a]++;
  }
  int ans=0;
  for(auto u:cnt){
    if(u.second>=u.first) ans+=(u.second-u.first);
    else ans+=u.second;
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 8112