akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
using namespace std;
 
struct Card{
    char a;
    int  b;
};
 
bool compare_as_ints(Card i, Card j)        
{
    return (i.b<j.b);
}
 
int partition(Card A[], int p, int r)
{
    Card x = A[r];
    int i = p-1;
 
    for(int j=p; j<=r-1; j++){
        if(A[j].b<=x.b){
            i++;
            swap(A[i], A[j]);
        }
    }
 
    swap(A[i+1], A[r]);
 
    return i+1;
}
 
void quickSort(Card A[], int p, int r)
{
    if(p<r){
        int q = partition(A, p, r);
        quickSort(A, p, q-1);
        quickSort(A, q+1, r);
    }
}
 
int main()
{
    int n;
    cin >> n;
 
    Card A[100000], B[100000];
    for(int i=0; i<n; i++){
        cin >> A[i].a >> A[i].b;
        B[i] = A[i];
    }
 
    quickSort(A, 0, n-1);
    stable_sort(B, B+n, compare_as_ints);   
 
    bool flg = true;
    for(int i=0; i<n; i++){
        if(!(A[i].a==B[i].a && A[i].b==B[i].b)){
            flg = false;
            break;
        }
    }
    if(flg){
        cout << "Stable" << endl;
    }
    else{
        cout << "Not stable" << endl;
    }
 
    for(int i=0; i<n; i++){
        cout << A[i].a << ' ' << A[i].b << endl;
    }
 
    return 0;
}

Measured memory_bytes: 4672
// 2_abc137_b
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rep1(i, n) for(int i = 1; i <= (int)(n); i++)
#define SZ(x) ((int)(x).size())
#define INF (1e16)
typedef long long ll;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int k, x;
    cin >> k >> x;

    for(int i = k - 1; i > 0; i--){
        cout << x - i << " ";
    }
    cout << x << " ";
    for(int i = 1; i <= k - 1; i++){
        cout << x + i << " ";
    }
    cout << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <utility>
#include <cmath>
#include <tuple>
#include <queue>
#include <bitset>
#include <set>
#include <map>
#include <list>

using namespace std;


void solve(long long N, long long x){
  if (x == 1 || x == (2*N-1)) {
    std::cout << "No" << std::endl;
    return;
  }

  vector<int> ans(2*N-1);
  if (N == 2) {
    ans[0] = 1;
    ans[1] = 2;
    ans[2] = 3;
  } else {
    if (x == 2) {
      ans[N-2] = 4;
      ans[N-1] = 1;
      ans[N] = 2;
      ans[N+1] = 3;
    } else if (x == (2*N-2)) {
      ans[N-2] = 2*N - 4;
      ans[N-1] = 2*N - 1;
      ans[N] = 2*N - 2;
      ans[N+1] = 2*N - 3;
    } else {
      ans[N-2] = x+2;
      ans[N-1] = x-1;
      ans[N] = x;
      ans[N+1] = x+1;
    }

    int a = 1;
    for (int i = 0; i < 2*N-1; ++i) {
      if (i >= N-2 && i <= N+1) continue;
      while (a == ans[N-2] || a == ans[N-1] || a == ans[N] || a == ans[N+1]) a++;
      ans[i] = a;
      a++;
    }
  }

  std::cout << "Yes" << std::endl;
  for (int i = 0; i < 2*N-1; ++i) {
    std::cout << ans[i] << std::endl;
  }
}

int main(){
  long long N;
  scanf("%lld",&N);
  long long x;
  scanf("%lld",&x);
  solve(N, x);
  return 0;
}


Measured memory_bytes: 2304
import scala.io.StdIn

/**
  * AOJ
  */
object Main {

  def main(args: Array[String]): Unit = {

    val in = StdIn.readLine().split(" ").map(_.toInt)
    val n = in(0)
    val m = in(1)

    val A = Array.ofDim[Int](n,m)
    val b = new Array[Int](m)

    for(i <- 0 until n){ A(i) = StdIn.readLine().split(" ").map(_.toInt) }
    for(i <- 0 until m){ b(i) = StdIn.readInt() }

    for(i <- 0 until n){
      println((A(i),b).zipped.map(_ * _).sum)
    }
  }
}

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

int main(int argc,char** argv)
{

	int n,counta=0,countb=0;
	cin >> n;
	int a[n];
	for(int i = 0; i < n; i++){
		cin >> a[i];
	}
	sort(a,a+n);
	reverse(a,a+n);
	for(int i = 0; i < n; i++){
		if(i%2 == 0){
			counta += a[i];
		}
		else{
			countb += a[i];
		}
	}
	cout << counta-countb << endl;
	return 0;

}


Measured memory_bytes: 256
#include<iostream>
#include<cmath>
#include<string.h>
#include<stdio.h>
using namespace std;

int n,m,a,b;
char p[1011][1011];

int main()
{
    int i,j,k;
    cin>>n>>m>>a>>b;
    
    for(i=1;i<=n;i++)
    {
        for(j=1;j<=m;j++)
        {
            p[i][j]='.';
        }
    }
    
    
    if(m%2==1)
    {
        for(i=1;i<=n-1;i+=2)
        {
            if(b==0)break;
            p[i][1]='^';
            p[i+1][1]='v';
            b--;
        }
    }
    
    if(b%2!=0)
    {
        if(p[n-1][m]=='.')
        {
           b--;
           p[n-1][m]='^';
           p[n][m]='v';
        }
    }
    
    for(i=1;i<=n-1;i+=2)
    {
        for(j=1;j<=m;j++)
        {
            if(b==0)break;
            
            if(p[i][j]!='.' || p[i+1][j]!='.')continue;
            
            p[i][j]='^';
            p[i+1][j]='v';
            b--;
        }
        if(b==0)break;
    }
    
    
    
    for(i=n;i>=1;i--)
    {
        for(j=1;j<=m-1;j++)
        {
            if(a==0)break;
            if(p[i][j]=='.' && p[i][j+1]=='.')
            {
                p[i][j]='<';
                p[i][j+1]='>';
                j++;
                a--;
            }
        }
        if(a==0)break;
    }
    if(a>0 || b>0)
    {
        cout<<"NO"<<endl;
    }
    else
    {
        cout<<"YES"<<endl;
        for(i=1;i<=n;i++)
        {
            for(j=1;j<=m;j++)
            {
                cout<<p[i][j];
            }
            cout<<endl;
        }
    }
    
    return 0;
}


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

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

    for(int i=0;i<n;i++){
        int minj=i;
        bool flag=false;

        for(int j=i;j<n;j++){
            if(d[minj]>d[j]){
                minj=j;
                flag=true;
            }
        }
        if(flag)swap(d[minj],d[i]);
    }

    int x=d[0];
    int ans=1;
    for(int i=1;i<n;i++){
        if(x<d[i])ans++;
        x=d[i];
    }

    cout<<ans<<endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdint>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <cassert>
#include <climits>
#include <string>
#include <bitset>
#include <cfloat>
#include <unordered_set>
#pragma GCC optimize("Ofast")
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef vector<pair<int, int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<ll> > vvll;

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, n) for (int i = 1; i <= (n); ++i)
#define irep(it, stl) for (auto it = stl.begin(); it != stl.end(); it++)
#define drep(i, n) for (int i = (n)-1; i >= 0; --i)
#define mes(a) cout << (a) << endl
#define dmes(a, b) cout << (a) << " " << (b) << endl
#define re0 return 0
#define mp(p, q) make_pair(p, q)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define Sort(a) sort(a.begin(), a.end())
#define rSort(a) sort(a.rbegin(), a.rend())
#define MATHPI acos(-1)
#define itn int;
int dx[8] = { 1, 0, -1, 0, 1, -1, -1, 1 };
int dy[8] = { 0, 1, 0, -1, 1, 1, -1, -1 };
template <class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template <class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
struct io { io() { ios::sync_with_stdio(false); cin.tie(0); } };
const int INF = INT_MAX;
const ll LLINF = 1LL << 60;
const ll MOD = 1000000007;
const double EPS = 1e-9;

signed main(void)
{    
    ll n;
    cin >> n;
    string s;
    cin >> s;
    vll as(n), bs(n);
    
    ll tmp = 0;
    ll r = LLINF;
    
    rep(i, n) {
        as[i] = tmp;
        if(s[i] == 'W') tmp++;
    }
    
    tmp = 0;
    drep(i, n) {
        bs[i] = tmp;
        if(s[i] == 'E') tmp++;
    }
    
    rep(i, n) {
        r = min(r, as[i]+bs[i]);
    }
    
    
    
    mes(r);
    
    
    
    
    
    
}

Measured memory_bytes: 8284
#include <cstdio>
#include <iostream>
#include <algorithm>

int n, k, pos, len;
std::string s, t;
int main() {
	std::ios::sync_with_stdio(false), std::cin.tie(0), std::cout.tie(0);
	std::cin >> n >> k >> s;
	if (k > 16 || (1 << k - 1) >= n) {
		std::cout << std::string(n, *std::min_element(s.begin(), s.end())) << '\n';
		return 0;
	}
	t = s, s = s + std::string(s.rbegin(), s.rend());
	for (int i = 0; i < n; ++i) t = std::min(t, s.substr(i, n));
	for (; pos <= n && t[pos] == t[0]; ++pos) ;
	len = std::min(n, pos << k - 1);
	std::cout << std::string(len, t[0]) << t.substr(pos, n - len) << '\n';
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i=0; i<(n); ++i) 
using namespace std;
using ll = long long;
int main() {
   string s;
   cin>> s;
   for(int i=0; i<s.size(); i+=2){cout << s[i];}
   }

Measured memory_bytes: 512
#include <iostream>
using namespace std;
int main()
{
  string s;
  cin>>s;
  int c=0;
  if(s[0]=='R' && s[1]=='R' && s[2]=='R')
    c=3;
  if((s[0]=='R' && s[1]=='R' && s[2]!='R') || (s[0]!='R' && s[1]=='R' && s[2]=='R'))
    c=2;
  if((s[0]=='R' && s[2]=='R' && s[1]!='R') || (s[1]=='R' && s[0]!='R' && s[2]!='R') || (s[1]!='R' && s[0]!='R' && s[2]=='R') || (s[0]=='R' && s[1]!='R' && s[2]!='R'))
	c=1;
  if(s[0]!='R' && s[1]!='R' && s[2]!='R')
	c=0;
  cout<<c;
  return 0;
     }


Measured memory_bytes: 3632
#include<iostream>
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0;i<n;i++)
using P = pair<int,int>;

/* 大文字を小文字に変換 */
char tolower(char c) {return (c + 0x20);}
/* 小文字を大文字に変換 */
char toupr(char c) {return (c - 0x20);}

// if('A'<=s[i] && s[i]<='Z') s[i] += 'a'-'A';

/*
string s = "abcdefg"
s.substr(4) "efg"
s.substr(0,3) "abc"
s.substr(2,4) "cdef"

// イテレータ要素のインデックス
distance(A.begin(), itr);
*/

const int MAX_N = 11;

int main()
{
    int n, m; cin >> n >> m;
    vector<int> s[m];
    vector<int> k(m);
    rep(i,m){
        cin >> k[i];
        rep(_,k[i]){
            int sij; cin >> sij; sij--;
            s[i].push_back(sij);
        }
    }
    vector<int> p(m);
    rep(i,m) cin >> p[i];

    int ans = 0;
    rep(i,(1<<n)){
        bitset<MAX_N> b(i);

        int sum = 0;
        rep(j,m){
            int on = 0;
            rep(kk, k[j]){
                if(b.test(s[j][kk])){
                    on++;
                }
            }
            if(on%2 == p[j]) sum++;
        }
        if(sum == m) ans++;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3592
#!/usr/bin/env python3

import sys, math, copy
# import fractions, itertools
# import numpy as np
# import scipy

HUGE = 2147483647
HUGEL = 9223372036854775807
ABC = "abcdefghijklmnopqrstuvwxyz"

def gcd(x, y):
    if x < y:
        x, y = y, x  # x >= y
    while y > 0:
        r = x % y
        x = y
        y = r
    return x

def gcd_all(a):
    g = a[0]
    for y in a:
        g = gcd(g, y)
    return g

def main():
    n, k = map(int, input().split())
    ai = list(map(int, input().split()))
    assert len(ai) == n
    g = gcd_all(ai)
    m = max(ai)
    if m - k >= 0 and (m - k) % g == 0:
        print("POSSIBLE")
    else:
        print("IMPOSSIBLE")

main()


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

#define whole(f, x, ...) ([&](decltype((x)) whole) { return (f)(begin(whole), end(whole), ## __VA_ARGS__); })(x)


using namespace std;
using ll = long long;

void solve() {
    int a, b, c;
    cin >> a >> b >> c;
    swap(a, b);
    swap(a, c);
    cout << a << " " << b << " " << c << endl;
}

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

    solve();
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;
const int inf = 1001001001;

int main(){
    int h1, m1, h2, m2, k;
    cin >> h1 >> m1 >> h2 >> m2 >> k;
    int diff = h2*60+m2 - ( h1*60 + m1);
    cout << diff - k << endl;
    
}

Measured memory_bytes: 3636
#include<stdio.h>

int main(){
    int n;
    int d;
    int tmp = 0;

    scanf("%d %d", &n, &d);


    int i;
    for(i = 0; tmp < n; i++){
        tmp += 1 + 2 * d;
    }

    printf("%d", i);

    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
ifstream fin("date.in");
int n, m, sti, stj, sfi, sfj;
bitset<1010> wall[1010], reached[1010];
int di[] = {-1, 0, 1, 0}, dj[] = {0, 1, 0, -1};
int di2[] = {-2, -2, -2, -2, -2, -1, 0, 1, 2, 2, 2, 2, 2, 1, 0, -1, -1, -1, 1, 1}, dj2[] = {-2, -1, 0, 1, 2, 2, 2, 2, 2, 1, 0, -1, -2, -2, -2, -2, -1, 1, 1, -1};

bool inside(int i, int j) {
	return i > 0 && j > 0 && i <= n && j <= m;
}

int main() {
	cin >> n >> m >> sti >> stj >> sfi >> sfj;
	for (int i = 1; i <= n; i++)
		for (int j = 1; j <= m; j++) {
			char c;
			cin >> c;
			if (c == '#')
				wall[i][j] = true;
		}

	priority_queue<pair<int, pair<int, int>>> pq;
	pq.push(make_pair(0, make_pair(sti, stj)));

	while (!pq.empty()) {
		int act_cost = -pq.top().first;
		int i_act = pq.top().second.first;
		int j_act = pq.top().second.second;
		pq.pop();

		if (reached[i_act][j_act])
			continue;
		reached[i_act][j_act] = true;

		if (i_act == sfi && j_act == sfj) {
			cout << act_cost;
			return 0;
		}

		for (int h = 0; h < 4; h++) {
			int i_nxt = i_act + di[h];
			int j_nxt = j_act + dj[h];
			if (inside(i_nxt, j_nxt))
				if (!wall[i_nxt][j_nxt] && !reached[i_nxt][j_nxt])
					pq.push(make_pair(-act_cost, make_pair(i_nxt, j_nxt)));
		}
		for (int h = 0; h < 20; h++) {
			int i_nxt = i_act + di2[h];
			int j_nxt = j_act + dj2[h];
			if (inside(i_nxt, j_nxt))
				if (!wall[i_nxt][j_nxt] && !reached[i_nxt][j_nxt])
					pq.push(make_pair(-act_cost - 1, make_pair(i_nxt, j_nxt)));
		}
	}

	cout << -1;
    return 0;
}


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

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

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

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

int main(){
  int a,sum=0;
  cin >> a;
  rep(i,a)rep(j,a)rep(k,a){
   sum += gcd(i+1,gcd(j+1,k+1));
  }
  cout << sum << endl;
}

Measured memory_bytes: 3648
import sys
import collections


def solve():
    readline = sys.stdin.buffer.readline
    mod = 10 ** 9 + 7
    n = int(readline())
    s = str(readline().rstrip().decode('utf-8'))
    d1 = collections.defaultdict(int)
    d2 = collections.defaultdict(int)
    d3 = collections.defaultdict(int)
    for i in range(n):
        t = [s[i]]
        if "".join(t) not in d1:
            d1["".join(t)]
            for j in range(i + 1, n):
                t = [s[i], s[j]]
                if "".join(t) not in d2:
                    d2["".join(t)]
                    for k in range(j + 1, n):
                        t = [s[i], s[j], s[k]]
                        d3["".join(t)]
    print(len(d3))


if __name__ == '__main__':
    solve()


Measured memory_bytes: 41180
#!/usr/bin/env python3
import sys


def solve(N: int, a: "List[int]"):
    from collections import Counter
    ans = 0
    for k, v in Counter(a).items():
        ans += v - k if v >= k else v
    return ans


# Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    a = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    print(solve(N, a))

def test():
    import doctest
    doctest.testmod()

if __name__ == '__main__':
    #test()
    main()


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

int main(void) {
	string S;
	cin >> S;
	int ans = 0;
	if (S == "SSS") printf("0\n");
	else if (S == "RSS") printf("1\n");
	else if (S == "SRS") printf("1\n");
	else if (S == "SSR") printf("1\n");
	else if (S == "RRS") printf("2\n");
	else if (S == "RSR") printf("1\n");
	else if (S == "SRR") printf("2\n");
	else if (S == "RRR") printf("3\n");

	return 0;
}


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

#define endl '\n'
long long const maxx = 3234566667;

vector<long long> nums;
void gen(long long x){
    if (x > maxx) return;
    nums.push_back(x);
    long long last = x % 10LL;
    if (last == 9){
        gen(x*10LL + 8);
        gen(x*10LL + 9);
    } else if (last == 0){
        gen(x*10LL + 0);
        gen(x*10LL + 1);
    } else{
        gen(x*10LL + last - 1);
        gen(x*10LL + last);
        gen(x*10LL + last + 1);
    }
}

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

    for (long long i=1; i<10; i++) gen(i);
    sort(nums.begin(), nums.end());
    int x; cin >> x;
    cout << nums[x-1] << endl;
}

Measured memory_bytes: 1400
#include<iostream>
#include<cstdio>
int main() {
    int x,y;
    scanf("%d%d",&x,&y);
    int ans=0;
    if(x<=3) ans+=(4-x)*100000;
    if(y<=3) ans+=(4-y)*100000;
    if(x==1&y==1) ans+=400000;
    printf("%d\n",ans);
    return 0;
}


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

#define rep(i, n) for(int i = 0; i < (int)(n); i++)

int showAll(vector<int> v) {
  for (int i = 0; i < v.size(); i++) {
    cout << v[i] << " ";
  }
  cout << endl;
  return 0;
}

int main() {
  int n;
  cin >> n;
  vector<int> v(n), v2(n);
  rep (i, n) {
    cin >> v[i];
    v2[i] = v[i];
  }

  sort(v.begin(), v.end());
  int half = n / 2;
  rep (i, n) {
    if (v[half] <= v2[i]) {
      cout << v[half - 1] << endl;
    } else {
      cout << v[half] << endl;
    }
  }

  return 0;
}



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

c=0

for i in range(N+1):
    tt=i//10**4
    t=(i%10**4)//10**3
    h=(i%10**3)//10**2
    ten=(i%10**2)//10
    o=i%10

    su= tt+t+h+ten+o

    if su >= A and su <= B:
        c+=i

print(c)

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

int main(){
    int n; cin>>n;
    pair<int,int> red[n],blue[n];
    for(int i=0;i<n;i++){
        int a,b;
        cin>>a>>b;
        red[i]=make_pair(a,b);
    }
    for(int i=0;i<n;i++){
        int c,d;
        cin>>c>>d;
        blue[i]=make_pair(d,c);
    }
    sort(red,red+n,greater<pair<int,int>>());
    sort(blue,blue+n);
    int ans=0;
    for(int i=0;i<n;i++){
        for(int j=0;j<n;j++){
            if(red[i].first<blue[j].second&&red[i].second<blue[j].first){
                ans++;
                blue[j].first=blue[j].second=-INF;
                break;
            }
        }
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <queue>
#include <map>
#include <unordered_map>
#include <stack>
#include <iomanip>
#include <queue>
#include <set>
#include <bitset>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
 
 
#define ll long long
#define uint unsigned int
#define ull unsigned ll
#define mp make_pair
#define pb push_back
#define all(x) x.begin(), x.end()
#define allr(x) x.rbegin(), x.rend()
#define speedhack() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define do(x) for(int i = 1; i <= x; i++){ solve(); }
#define sz(x) (int)x.size()
#define pii pair < int, int >
using namespace std;
using namespace __gnu_pbds;
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
 
const ll MAXN = 1e18;
const ll SIZE = 102; //are u sure?
const ll mod = 1e9+7;


void solve(){
	ll n; cin >> n;
	if(n % 2 == 1) cout << 0 << endl;
	else{
		ll res = 0;
		ll den = 10;
		while(den <= n){
			res += (n / den);
			den *= 5;
		}
		cout << res << endl;
	}
}


int main(){
	speedhack()
	// int it; cin >> it;
	int it = 1;
	do(it);
	return 0;
}

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

#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)

int calc_sum(string s) {
    return 0;
}

void binary_search(string st, int index, int len) {
    cout << st << " index: " << index << " length: " << len << endl; 
    if (index == len - 1) {
        cout << st << endl;
        return;
    }
    // cout << st << endl;
    string temp = st;
    binary_search(temp.insert(index+1, "+"), index+2, temp.length());
    binary_search(st, index + 1, len);
    return;
}

int solve(int S) {
    int sum = 0;
    string s = to_string(S);
    int len = s.length();
    binary_search(s, 0, len);
    return sum;
}


int main(){
    string S; cin >> S;
    // string s = "hello";
    // s.insert(1, "Q");
    // cout << s << endl;

    // bit brute force.
    // int n = 5;
    // for (int i = 0; i < (1<<n); i++) {
    //     vector<int> S;
    //     for (int j = 0; j < n; j++) {
    //         if (i & (1 << j)) {
    //             S.push_back(j);
    //             S.push_back(100);
    //         } else {
    //             S.push_back(j);
    //         }
    //     }
    //     cout << i << ": {";
    //     for (int k = 0; k < (int)S.size(); k++) {
    //         cout << S[k] << " ";
    //     }
    //     cout << "}" << endl;
    // }

    ll ans = 0;
    for (ll i = 0; i < (1<<(S.size()-1)); i++) {
        vector<char> S_;
        for (ll j = 0; j < S.size(); j++) {
            if(i & (1 << j)) {
                S_.push_back(S[j]);
                S_.push_back('+');
            } else {
                S_.push_back(S[j]);
            }
        }
        // cout << "Here: " << stoll(S) << endl;
        string temp;
        for (ll k = 0; k < (int)S_.size(); k++) {
            if (S_[k] == '+') {
                // cout << temp << endl;
                ans += stoll(temp);
                temp = "";
            } else {
                temp += S_[k];
            }
            // cout << "Temp: " << temp << endl;
            if (k == S_.size() - 1)
                ans += stoll(temp);
        }
        // cout << i << ": {";
        // for (ll k = 0; k < (int)S_.size(); k++) {
        //     cout << S_[k] << " ";
        // }
        // cout << "}" << endl;
        // cout << "Ans: " << ans << endl;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main() {
    ll n;
    cin>>n;
    ll a[n];
    for(int i=0;i<n;i++) {
        cin>>a[i];
    }
    ll minn = 1LL*(INT_MAX>>1)*(INT_MAX>>1);
    for(int i=-200;i<=200;i++) {
        ll temp = 0;
        for(int j=0;j<n;j++) {
            temp += (a[j]-i)*(a[j]-i);
        }
        minn = min(minn, temp);
    }
    cout<<minn<<"\n";
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FAST_IO ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define endl "\n"

int main() {

    FAST_IO;

    int n, m;
    cin >> n >> m;

    int p;
    string st;
    vector<int> cnt(n, 0);
    vector<int> done(n, 0);
    
    int cnt_dn = 0;
    int cnt_pn = 0;
    for (int i = 0; i < m; ++i) {
        cin >> p >> st;
        --p;
        if (st == "WA" && !done[p]) {
            ++cnt[p];
            continue;
        } else if (st == "AC" && !done[p]) {
            done[p] = 1;
            cnt_pn += cnt[p];
            ++cnt_dn;
        }
    }
    cout << cnt_dn << " " << cnt_pn << endl;
    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
int main()
{
	int k;
	int a[32]={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
	cin>>k;
	cout<<a[k-1]<<"\n";
}

Measured memory_bytes: 256
N, C = map(int, input().split())
D = [[int(i) for i in input().split()] for _ in range(C)]
c = [[int(i) for i in input().split()] for _ in range(N)]

ccount = [[0] * C for _ in range(3)]
for y in range(N) :
    for x in range(N) :
        ccount[(x + y) % 3][c[y][x]-1] += 1

ccost = [[0] * C for _ in range(3)]
for i, cc in enumerate(ccount) :
    m = float('inf')
    for j in range(C) :
        ccost[i][j] = sum([cc[k] * D[k][j] for k in range(C)])
        
ret = float('inf')
for i in range(C) :
    for j in range(C) :
        if i == j :
            continue
        for k in range(C) :
            if i == k or j == k :
                continue
            ret = min(ret, ccost[0][i] + ccost[1][j] + ccost[2][k])
print(ret)

Measured memory_bytes: 44124
a = int(input())
while 1:
    k = input()
    if k == '+':
        a += int(input())
    elif k == '-':
        a -= int(input())
    elif k == '*':
        a *= int(input())
    elif k == '/':
        a //= int(input())
    elif k == '=':
        print(a)
        break



Measured memory_bytes: 5592
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int k = sc.nextInt();
        long[] h = new long[n];
        for (int i = 0; i < n; i++) {
            h[i] = sc.nextLong();
        }
        Arrays.sort(h);

        long min = Math.abs(h[0] - h[k-1]);
        for (int i = 0; i <= n - k; i++) {
            long tmp = Math.abs(h[i] - h[i+k-1]);
            min = Math.min(min, tmp);
        }
        System.out.println(min);
    }
}

Measured memory_bytes: 48636
S=list(input())
A=int(S[0] + S[1])
B=int(S[2] + S[3])

FORMAT_S = ['AMBIGUOUS', 'YYMM', 'MMYY', 'NA']
format_flag = [True, True, True, True]

if A == 0 or 12 < A:
    format_flag[0] = False
    format_flag[2] = False
if B == 0 or 12 < B:
    format_flag[0] = False
    format_flag[1] = False

for i in range(4):
    if format_flag[i] == True:
        print(FORMAT_S[i])
        break

Measured memory_bytes: 3064
#include "bits/stdc++.h"
using namespace std;
#define ff first
#define ss second
#define pb push_back
typedef long long ll;
#define db(x) cerr<<__LINE__<<": "<<#x<<" = "<<(x)<<'\n'
const int inf = 1e9+7;
const int N = 1e6+9;

int main() {
    ios_base::sync_with_stdio(0);
    int a,b,n,T,cas=0;
    string s1, s2;
    cin>>s1>>s2;
    s2.pop_back();
    if(s1==s2) cout<<"Yes\n";
    else cout<<"No\n";
    return 0;
}

// ll, reset, 1, bottom

Measured memory_bytes: 3636
#include <stdio.h>
#include <math.h>
#define N 250

int main(){
  int A[N],n,i,x;
  scanf("%d",&n);
  A[0]=0;
  for(i=1;i<=n;i++) scanf("%d",&A[i]);
  
  for(i=1;i<=n;i++){
    printf("node %d: key = %d, ",i,A[i]);
    x=floor(i/2);
    if(x > 0){
      printf("parent key = %d, ",A[x]);
    }
    if(2*i <= n) printf("left key = %d, ",A[2*i]);
    if((2*i)+1 <= n) printf("right key = %d, ",A[(2*i)+1]);
    printf("\n");
  }

  return 0;
}



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

int main() {
  int N, M;
  cin >> N >> M;
  vector<vector<int>> G(N);
  for (int i = 0, a, b; cin >> a >> b; i++) {
    G.at(--a).push_back(--b), G.at(b).push_back(a);
  }
  vector<int> P(N);
  for (int i = 0; i < N; i++) P.at(i) = i;
  int ans = 0;
  do {
    if (P.at(0) != 0) break;
    int now = 0;
    for (; now < N - 1;) {
      bool next = false;
      for (auto g : G.at(P.at(now))) if (g == P.at(now + 1)) next = true;
      if (next) {
        now++;
        if (now == N - 1) ans++;
      } else {
        break;
      }
    }
  } while (next_permutation(P.begin(), P.end()));
  cout << ans << "\n";
}

Measured memory_bytes: 256
num_prob = int(input())
prob = input()
new = prob.split()
sum = 0

for j in new:
  sum += int(j)

  
num_drinks = int(input())
for i in range(num_drinks):
  line = input()
  new_line = line.split()
  if int(new_line[1]) != int(new[int(new_line[0])-1]):
    temp = sum - int(new[int(new_line[0])-1]) + int(new_line[1])
    print(temp)
  else:
    print(sum)
    
  
    


Measured memory_bytes: 9100
using System;

public class Test
{
    public static void Main()
    {
        int a, b, d, r;
        double f;
        string[] str = Console.ReadLine().Split(' ');
        a = int.Parse(str[0]);
        b = int.Parse(str[1]);

        d = a / b;
        r = a % b;
        f = (double)a / b;

        Console.WriteLine("{0} {1} {2:f5}", d, r, f);

    }
}


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

int main() {
    int number = 0;
    cin >> number;
    int area = number + 1;
    vector<long> lucas(area);
    for (int i = 0; i < area; ++i) {
        if (i == 0) {
            lucas.at(i) = 2;
        }
        if (i == 1) {
            lucas.at(i) = 1;
        }
        if (i >= 2) {
            lucas.at(i) = lucas.at(i-1) + lucas.at(i-2);
        }
    }
    
    cout << lucas.at(number) << endl;
}



Measured memory_bytes: 256
//#include <bits/stdc++.h>
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstdlib>
#include <string>
#include <vector>
#include <map>
#include <queue>

using namespace std;

typedef long long ll;
typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<n;++i)
#define mod (ll)(1e9+7)
#define FIX(a) ((a)%mod+mod)%mod
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define fi first
#define se second
#define pb push_back
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll a,b,k;
    cin >> a >> b >> k;
    REP(i,k){
        if(i%2==0){
            b += (a/2);
            a /= 2;
        }else{
            a += (b/2);
            b /= 2;
        }
    }
    cout << a << " " << b << endl;

    return 0;
}

Measured memory_bytes: 3612
N = int(input())
s = [input() for i in range(N)]
M = int(input())
t = [input() for i in range(M)]
count = 0
ans = 0

for i in range(N):
    if s[i] in t:
        if s.count(s[i]) > t.count(s[i]):
            count = s.count(s[i]) - t.count(s[i])
            if count > ans:
                ans = count
    elif s[i] not in t:
        count = s.count(s[i])
        if count > ans:
            ans = count

print(ans)


Measured memory_bytes: 3064
// 先頭か末尾に移動されない要素は、その順序関係が変わらず、間になにか挿入されることがないので、
// それらは連続していることがわかる。
// 昇順に+1の等差で並んだ、インデックスが昇順の順列の内最大のものを求める。
#include <bits/stdc++.h>
using namespace std;

int main() {
    int N;
    cin >> N;
    vector<int> P(N);
    vector<int> Q(N + 1);
    for (int i = 0; i < N; ++i) {
        cin >> P[i];
        Q[P[i]] = i;  // Q[i] := 数iがある配列Pのインデックス
    }
    vector<int> S(N + 1, 1);
    for (int i = 2; i <= N; ++i) {
        if (Q[i - 1] < Q[i]) {
            S[i] = S[i - 1] + 1;
        }
    }
    int continuous = 0;
    for (int i = 1; i <= N; ++i) {
        continuous = max(continuous, S[i]);
    }
    cout << N - continuous << endl;
    return 0;
}

Measured memory_bytes: 2560
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
#define FOR(i, j, k, in) for (int i = j; i < k; i += in)
#define RFOR(i, j, k, in) for (int i = j; i >= k; i -= in)
#define REP(i, j) FOR(i, 0, j, 1)
#define RREP(i, j) RFOR(i, j, 0, 1)

constexpr ll mod = 1000000007ll;
vector<ll> p, ip;

ll fpow(ll base, ll exp) {
    ll ret = 1ll;
    while (exp != 0) {
        if (exp % 2 == 1) ret = (ret * base) % mod;
        exp >>= 1;
        base = (base * base) % mod;
    }
    return ret;
}

void init(ll m) {
    p.resize(m + 1);
    ip.resize(m + 1);
    p[0] = 1ll;
    for (ll i = 1; i < m + 1; i++) {
        p[i] = (p[i - 1] * i) % mod;
    }
    ip[m] = fpow(p[m], mod - 2);
    for (ll i = m - 1; i >= 0; i--) ip[i] = ((i + 1ll) * ip[i + 1]) % mod;
}

ll comb(ll a, ll b) {
    ll ret = (p[a] * ip[b]) % mod;
    ret = (ret * ip[a - b]) % mod;
    return ret;
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll n, m;
    cin >> n >> m;
    init(m);
    ll ans = (comb(m, n) * p[n]) % mod;
    ll sum = 0ll;
    ll sign = -1ll;
    for (ll k = 0; k < n + 1; k++) {
        sign *= -1ll;
        ll curr = sign;
        curr = (curr * comb(n, k)) % mod;
        curr = (curr * comb(m - k, n - k)) % mod;
        curr = (curr * p[n - k]) % mod;
        sum = (sum + curr) % mod;
    }
    ans = (ans * (sum + mod) % mod) % mod;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 11004
#include<stdio.h>
 
int main(){
 
  int K1[36],K2[36],n,temp1,temp2,flag=0;
  char temp3,M1[36],M2[36];
 
  //load N
  scanf("%d",&n);
  int i,j;
 
  //load number
  for(i=1;i<=n;i++){
    scanf(" %c%d",&M1[i],&K1[i]);
    K2[i]=K1[i];
    M2[i]=M1[i];
  }
 
 
 
  
  for(i=0;i<n;i++){
    for(j=n;j > i+1;j--){
      if(K1[j]<K1[j-1]){
        temp3=M1[j];
        M1[j]=M1[j-1];
        M1[j-1]=temp3;
        temp1=K1[j];
        K1[j]=K1[j-1];
        K1[j-1]=temp1;
    }
    }
  }
  for(i=1;i<=n;i++){
    printf("%c%d",M1[i],K1[i]);
    if(i!=n)printf(" ");
  }
    printf("\nStable\n");


  for(i=1;i<=n;i++){
    temp2=i;
    for(j=i;j<=n;j++){
      if(K2[j]<K2[temp2]){
        temp2=j;
      }
    }
     temp3=M2[i];
      M2[i]=M2[temp2];
      M2[temp2]=temp3;
      temp1=K2[i];
      K2[i]=K2[temp2];
      K2[temp2]=temp1;
  }
  for(i=1;i<=n;i++){
    printf("%c%d",M2[i],K2[i]);
    if(i!=n)printf(" ");
  }
  printf("\n");
flag=0;
  for(i=1;i<=n;i++){
    if(K2[i]!=K1[i]||M2[i]!=M1[i]){
      flag=1;
      printf("Not stable\n");
      break;
    }
  }
     if(flag==0) printf("Stable\n");
   return 0;
}


Measured memory_bytes: 2108
#include <bits/stdc++.h>
using namespace std;
using ll =long long;
#define all(v) v.begin(),v.end()
 
int main() {
  ll K;
  cin>>K;
  
if(K%7==0) {
K/=7;
}
  ll L=9*K;
  if(L%2==0||L%5==0) {
cout<<-1<<endl;
    return 0;
  }
  
ll am=1;
  ll ans;
  bool a=false;
  for(ll i=1;i<1000000000;i++) {
    am*=10;
   if(am%L==1) {
     a=true;
     ans=i;
     break;
   }
    am%=L;
  }
  
  if(a) {
cout<<ans<<endl;
  }
  else {
    cout<<-1<<endl;
  }
}
    



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

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

  int N;
  cin >> N;
  vector<string> S(N);
  for(int i = 0; i < N; ++i) cin >> S.at(i);
  sort(S.begin(), S.end());

  vector<pair<int, string>> comp;
  int cnt = 0;
  string name = S.at(0);
  for(int i = 0; i < N; ++i) {
    if(name != S.at(i)) {
      comp.push_back({cnt, name});
      cnt = 1;
      name = S.at(i);
    }
    else {
      cnt++;
    }
    if(i == N - 1) {
      comp.push_back({cnt, name});
    }
  }
  sort(comp.rbegin(), comp.rend());

  // for(int i = 0; i < comp.size(); ++i) {
  //   cout << comp.at(i).first << " : " << comp.at(i).second << endl;
  // }

  vector<string> ans;
  for(int i = 0; i < comp.size(); ++i) {
    if(comp.at(0).first == comp.at(i).first) {
      ans.push_back(comp.at(i).second);
    }
  }
  sort(ans.begin(), ans.end());

  for(int i = 0; i < ans.size(); ++i) {
    cout << ans.at(i) << endl;
  }

  return 0;
}


Measured memory_bytes: 20332
//#include <bits/stdc++.h>
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstdlib>
#include <string>
#include <vector>
#include <map>
#include <queue>

using namespace std;

typedef long long ll;
typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<n;++i)
#define mod (ll)(1e9+7)
#define FIX(a) ((a)%mod+mod)%mod
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define fi first
#define se second
#define pb push_back
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};
struct UnionFind {
    vector<int> id;
    vector<vector<int> > groups;
    int gn; //number of groups
    UnionFind(int n){
        id = vector<int>(n);
        groups = vector<vector<int> >(n);
        gn = n;
        for(int i=0;i<n;++i){
            id[i]=i;
            groups[i]={i};
        }
    }
    void unite(int a, int b) {
        if(same(a,b)) return;
        gn--;
        int x = id[a];
        int y = id[b];
        if(groups[x].size()<groups[y].size()) swap(x,y);
        for(int j : groups[y]){
            id[j] = x;
            groups[x].push_back(j);
        }
        groups[y].clear();        
    }
    bool same(int a, int b) {
        return id[a] == id[b];
    }
};
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int  n;
    cin >> n;

    vector<pair<int, int> > nd(n);
    vector<pair<int, int> > xi(n);
    vector<pair<int, int> > yi(n);
    REP(i,n){
        int x,y;
        cin >> x >> y;
        nd[i] = make_pair(x,y);
        xi[i] = make_pair(x, i);
        yi[i] = make_pair(y, i);
    }
    vector<pair<int, pair<int,int> > > ed(2*n-2);
    sort(ALL(xi));
    REP(i,n-1){
        ed[i] = make_pair(xi[i+1].fi-xi[i].fi, make_pair(xi[i+1].se,xi[i].se));
    }
    sort(ALL(yi));
    REP(i,n-1){
        ed[n-1+i] = make_pair(yi[i+1].fi-yi[i].fi, make_pair(yi[i+1].se,yi[i].se));
    }
    sort(ALL(ed));
    ll ans = 0;
    UnionFind uf(n);
    for(auto p : ed){
        int a = (p.se).fi;
        int b = (p.se).se;
        if(uf.same(a,b)) continue;
        uf.unite(a,b);
        //cout << (p.se).fi << "-" << (p.se).se << ":" << p.fi << endl;
        ans += (ll)p.fi;
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 14972
import java.util.Scanner;

public class Main {

    private static long tree( long ans , long h ){

        if( h == 1 ){
            return ++ans;
        }
        return 1 + tree( ans , h/2 ) + tree( ans , h/2 );
    }

    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);
        long h = Long.parseLong( sc.nextLine() );

        if( h == 1 ){
            System.out.println( 1 );
            return;
        }

        long ans = 0;
        long depth = 0;
        long width = 1;
        while( h != 1 ){
            ans += width;
            h /= 2;
            depth++;
            width *= 2;
        }
        ans += width;
        System.out.println( ans );
    }

}


Measured memory_bytes: 23892
<?php
fscanf(STDIN, '%d %d %d', $length, $max, $quad);
$map = [];
$highScore = 0;
for ($i=0; $i < $quad; $i++) { 
    $nums = array_map('intval', explode(' ', trim(fgets(STDIN))));
    $map[] = $nums;
}
$arr = [1];
dfs($arr);
echo $highScore;

function dfs($arr) {
    global $length, $max, $highScore;
    $size = count($arr);
    if ($size-1 == $length) {
        $highScore = setHighScore($arr);
        return;
    }
    $arr[] = $arr[$size-1];
    $size++;
    while($arr[$size-1] <= $max) {
        dfs($arr);
        $arr[$size-1]++;
    }
}

function setHighScore($arr) {
    global $quad, $map, $highScore;
    $tmpScore = 0;
    for ($i=0; $i < $quad; $i++) { 
        $target = $map[$i];
        if ($arr[$target[1]]-$arr[$target[0]]==$target[2]) {
            $tmpScore+=$target[3];
        }
    }
    return max($tmpScore, $highScore);
}

Measured memory_bytes: 16224
n,y = map(int,input().split())
for i in range(n+1):
    for j in range(n+1-i):
        if (y-(10000*i+5000*j))//1000 == n-i-j:
                print("{} {} {}".format(i,j,n-i-j))
                break
    else:
        continue
    break

else:print("-1 -1 -1")


Measured memory_bytes: 2940
#include<bits/stdc++.h>
#define all(v) v.begin(),v.end()
using namespace std;
int main(){
  int n,m,b,ans=0;
  cin>>n;
  vector<int> a(n);
  for(int i=0;i<n;i++)cin>>a[i];
  sort(all(a));
  cin>>m;
  for(int i=0;i<m;i++){
    cin>>b;
    if(b==*lower_bound(all(a),b))ans++;
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 3132
import java.util.Scanner;

public class Main {
	public static void main(String args[]) {
		Scanner stdIn = new Scanner(System.in);
		int X = stdIn.nextInt();
		if(30 <= X) {
			System.out.println("Yes");
		}else {
			System.out.println("No");
		}
	}
}

Measured memory_bytes: 35820
#include<stdio.h>

int main(){
    int N;
    char s[110];
    int i, j, k;
    int fo[200], ba[200];
    int str;
    int sum, ans;

    scanf("%d", &N);
    scanf("%s", &s);

    for(i=0; i<N; i++){
        for(j=0; j<200; j++){
            fo[j] = 0;
            ba[j] = 0;
        }
        for(j=0; j<i; j++){
            str = s[j];
            fo[str] += 1;
        }
        for(j=i; j<N; j++){
            str = s[j];
            ba[str] += 1;
        }
        sum = 0;
        for(j=0; j<200; j++){
            if(0 < fo[j] && 0 < ba[j]){
                sum += 1;
            }
        }
        if(ans < sum){
            ans = sum;
        }
    }
    printf("%d", ans);

    return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<map>
#include<vector>
#include<algorithm>
#include<cmath>
#include<climits>
#include<ctime>
#include<cstring>
#include<numeric>

#define ALL(v) (v).begin(),(v).end()
#define REP(i,p,n) for(int i=p;i<(int)(n);++i)
#define rep(i,n) REP(i,0,n)
#define dump(a) (cerr << #a << "=" << (a) << endl)
#define DUMP(list) cout << "{ "; for(auto nth : list){ cout << nth << " "; } cout << "}" << endl;

using namespace std;


int main(){
  int n;
  int a[30];

  while(cin >> n && n > 0){
    a[0] = 1;
    a[1] = 2;
    a[2] = 4;
    REP(i, 3, n){
      a[i] = a[i-1] + a[i-2] + a[i-3];
    }

    cout << a[n-1]/3650 + 1 << endl;
  }

}


Measured memory_bytes: 3060
from collections import deque
N,M,*L,S,T = map(int,open(0).read().split())
G = [[] for _ in range(N)]
step = [False for _ in range(3*N)]
step[(S-1)*3] = 0
for u,v in zip(*[iter(L)]*2):
	G[u-1].append(v-1)
q = deque([(S-1,0)])
while q:
	cur,d = q.popleft()
	for nxt in G[cur]:
		if nxt==T-1 and (d+1)%3==0:
			print((d+1)//3)
			exit()
		if not step[nxt*3+(d+1)%3]:
			step[nxt*3+(d+1)%3] = True
			q.append((nxt,d+1))
print(-1)

Measured memory_bytes: 28484
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define rep(i, n) FOR(i, 0, n)
#define whole(x) (x).begin(),(x).end()
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
using P = pair<int, int>;
#define debug(var) cerr << "[" << #var << "] " << var << endl
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
const ll mod = 1000000007;
const int dx[] = {-1,0,1,0};
const int dy[] = {0,-1,0,1};

vector<int> start[100005];

int main(){
    int n, m;
    cin >> n >> m;
    vector<P> war(m);
    rep(i, m) {
        cin >> war[i].first >> war[i].second;
        war[i].first--; war[i].second--;
    }
    int ans = 0;
    sort(whole(war));
    
    rep(i, m) {
        start[war[i].second].push_back(war[i].first);
    }
    rep(i, n) {
        sort(whole(start[i]));
    }
    int pre = -1;
    rep(i, n) {
        if (start[i].size()==0) continue;
        int x = start[i].back();
        if (x>=pre) {
            ans++;
            pre = i;
        }
    }
    
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 5888
#include<cstdio>
#include<cmath>
#include<iostream>
#include<algorithm>
#include<queue>
using namespace std;
int main(){
    int N;
    cin>>N;
    long long int lis[200003];
    long long int karizen=0;
    /*
    for(int i=0;i<N;i++){
        cin>>lis[i];
        karizen+=lis[i];
        karizen%=1000000007;
    }
    long long int ans=0;
    for(int i=0;i<N;i++){
        long long int pa=karizen-lis[i];
        pa%=1000000007;
        ans+=lis[i]*pa;
        ans%=1000000007;
    }
    */
    long long int ans=0;
    for(int i=0;i<N;i++){
        cin>>lis[i];
        karizen+=lis[i];
        karizen%=1000000007;
        if(i!=0){
            long long int pa=karizen-lis[i];
            pa+=1000000007;
            pa%=1000000007;
            ans+=lis[i]*pa;
            ans%=1000000007;
        }

    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 4752
#include <iostream>
#include <vector>
#include <algorithm>
#include <utility>
#include <map>
#include <set>
#include <queue>
#include <iomanip>
#include <cmath>
using namespace std;
typedef long long int lli;
const lli mod = 1e9+7;
const lli inf = 1e18;
typedef pair<int ,int> pii;
typedef pair<lli, lli> pll;

int main(){
    int n,k;
    cin >> n >> k;
    vector<int> a(n);
    for(int i=0; i<n; i++){
        cin >> a[i];
    }
    sort(a.begin(), a.end());
    int ans = 0;
    for(int i=0; i<k; i++){
        ans += a[i];
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3640
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define lim 1000000
#define mod 1000000007
#define pb push_back
#define mp make_pair
#define eps 1e-8
#define INF 1e10
#define F first
#define S second
#define sd(n) scanf("%lld",&n)
#define pd(n) printf("%.9lf\n",n)
vector<ll> p[lim+1];
int main()
{ 
    ll k,t,n;
    cin>>k>>n;
    ll a[n+1];
    ll sm=0,mx=0;
    for(ll i=0;i<n;i++)
        {
            cin>>a[i];
            sm+=a[i];
            mx=max(mx,a[i]);
        }
        sm-=mx;
        ll ans;
        if(sm>=mx)
            ans=0;
        else
        {
            ans=mx-1-sm;
        }
        cout<<ans<<endl;
}


Measured memory_bytes: 23680
using System;
using System.Collections.Generic;

class Program
{
	static void Main(string[] args)
	{
		int T = int.Parse(Console.ReadLine());
		int[] n = new int[T];
		ulong[][] a = new ulong[T][];
		bool[][] s = new bool[T][];
		for(int i=0; i<T; i++)
		{
			string[] input = Console.ReadLine().Split(' ');
			n[i] = int.Parse(input[0]);
			input = Console.ReadLine().Split(' ');
			a[i] = new ulong[n[i]];
			for(int j=0; j<n[i]; j++) a[i][j] = ulong.Parse(input[j]);
			s[i] = new bool[n[i]];
			char[] c = Console.ReadLine().ToCharArray();
			for(int j=0; j<n[i]; j++) s[i][j] = (c[j] == '1');
		}
		for(int i=0; i<T; i++) Battle(n[i], a[i], s[i]);

	}

	static void Battle(int n, ulong[] a, bool[] s)
	{
		WinNumberSet wns = new WinNumberSet();
		for(int i=n-1; i>=0; i--)
		{
			if(s[i] && !wns.Contains(a[i]))
			{
				Console.WriteLine("1");
				return;
			}
			else
			{
				wns.Add(a[i]);
			}
		}
		Console.WriteLine("0");
	}
}

public class WinNumberSet
{
	ulong[] _numberArray;

	public WinNumberSet()
	{
		_numberArray = new ulong[64];
	}

	public void Add(ulong a)
	{
		int arrIdx = 0;
		for(ulong i = 1; (i & a) != a; i = (i << 1) + 1) arrIdx++;
		if(_numberArray[arrIdx] == 0) _numberArray[arrIdx] = a;
		else if(_numberArray[arrIdx] != a) Add(a ^ _numberArray[arrIdx]);
	}

	public bool Contains(ulong a)
	{
		int arrIdx = 0;
		for(ulong i = 1; (i & a) != a; i = (i << 1) + 1) arrIdx++;
		if(_numberArray[arrIdx] == 0) return false;
		if(_numberArray[arrIdx] == a) return true;
		else return Contains(a ^ _numberArray[arrIdx]);
	}

	public override string ToString()
	{
		string s = "";
		for(int i=0; i<64; i++)
		{
			if(i==0) s = _numberArray[i].ToString();
			else s = s + " " + _numberArray[i].ToString();
		}
		return s;
	}
}



Measured memory_bytes: 31052