akhauriyash/Code-Regression huggingface dataset:
// ----- In the name of ALLAH, the Most Gracious, the Most Merciful -----

#include <bits/stdc++.h>
using namespace std;

#define sim template <class c
#define ris return *this
#define dor > debug &operator<<
#define eni(x)                                                                 \
  sim > typename enable_if<sizeof dud<c>(0) x 1, debug &>::type operator<<(    \
            c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c *x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
  ~debug() { cerr << endl; }
  eni(!=) cerr << boolalpha << i;
  ris;
} eni(==) ris << range(begin(i), end(i));
}
sim, class b dor(pair<b, c> d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
  sim dor(const c &) { ris; }
#endif
}
;
#define deb(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
#define memo(dp, val) memset(dp, val, sizeof(dp))
#define NINJA                                                                  \
  ios_base::sync_with_stdio(0);                                                \
  cin.tie(0);                                                                  \
  cout.tie(0)
#define all(a) a.begin(), a.end()
#define fo(i, n) for (int i = 0; i < n; i++)
#define Fo(i, k, n) for (int i = k; i < n; i++)
#define for1(i, n) for (int i = 1; i <= n; i++)
#define dloop(i, n) for (int i = n - 1; i >= 0; i--)
#define iii tuple<int, int, int>
#define vi vector<int>
#define ii pair<int, int>
#define vii vector<ii>
#define int long long
#define ld long double
#define pb push_back
#define endl "\n"
#define setbits __builtin_popcountll
#define mp map<int, int>
#define F first
#define S second
#define sz(v) (int)v.size()
#define mod 1000000007
#define inf (int)1e18

int32_t main() {
  NINJA;

  int n;
  cin >> n;
  vector<pair<int, int>> a(n);

  fo(i, n) cin >> a[i].first >> a[i].second;

  bool ok = 0;
  fo(i, n - 2) {
    if (a[i].first == a[i].second && a[i + 1].first == a[i + 1].second &&
        a[i + 2].first == a[i + 2].second) {
      ok = 1;
      break;
    }
  }

  cout << (ok ? "Yes" : "No") << endl;

  return 0;
}

Measured memory_bytes: 3604
#dt = {} for i in x: dt[i] = dt.get(i,0)+1
#dt = {k:v for k,v in sorted(x.items(), key=lambda i: i[1])}
ipnl = lambda n: [int(input()) for _ in range(n)]
inp = lambda :int(input())
ip = lambda :[int(w) for w in input().split()]

k = inp()
s = input()
if len(s) <= k:
    print(s)
else:
    print(s[:k]+"...")

Measured memory_bytes: 61912
using System;
using System.Linq;
class Program
{
    static void Main()
    {
        int N = int.Parse(Console.ReadLine());
        int[] s = new int[N];
        for (int i = 0; i < N; i++)
        {
            s[i] = int.Parse(Console.ReadLine());
        }
        int score = s.Sum();
        if (score % 10 == 0)
        {
            if (s.Any(x => x % 10 != 0))
            {
                score -= s.Where(x => x % 10 != 0).Min();
            }
            else
            {
                score = 0;
            }
        }
        Console.WriteLine(score);
    }
}

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

using ll = long long;
using ull = unsigned long long;
using ld = long double;

#define MOD 1000000007LL

#define rep(i, n) for(ll (i) = 0LL;(i) < (ll)(n);(i)++)
#define rep2(i, s, e) for(ll (i) = (ll)(s);(i) < (ll)(e);(i)++)
#define repi(i, n) for(ll (i) = 0LL;(i) <= (ll)(n);(i)++)
#define repi2(i, s, e) for(ll (i) = (ll)(s);(i) <= (ll)(e);(i)++)
#define per(i, n) for(ll (i) = (ll)(n) - 1LL;(i) >= 0LL;(i)--)
#define per2(i, s, e) for(ll (i) = (ll)(s) - 1LL;(i) >= (ll)(e);(i)--)
#define peri(i, n) for(ll (i) = (ll)(n);(i) >= 0LL;(i)--)
#define peri2(i, s, e) for(ll (i) = (ll)(s);(i) >= (ll)(e);(i)--)
#define iter(i, it) for(auto &(i): (it))

template<typename T, typename U> ostream& operator<<(ostream &s, const pair<T, U> m) {
    cout << "(" << m.first << ", " << m.second << ")";
    return s;
}
template<typename T, typename U> ostream& operator<<(ostream &s, const map<T, U> m) {
    ll c = 0;
    cout << "{ ";
    iter(i, m) cout << i << (c++ == m.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}
template<typename T> ostream& operator<<(ostream &s, const vector<T> &v) {
    cout << "{ ";
    rep(i, v.size()) cout << v[i] << (i == v.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}
template<typename T> ostream& operator<<(ostream &s, const list<T> &v) {
    ll c = 0;
    cout << "{ ";
    iter(i, v) cout << i << (c++ == v.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}

int main(void) {
    ll N;
    cin >> N;
    ll ans = 0;
    repi2(i, 1, N) ans += to_string(i).size() % 2;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3744
#include <bits/stdc++.h>
using namespace std;
const int N = 110;
const int M = 100010;
const int mod = 1000000007;
int dp[N][M];
int a[N], n, sum;

int main() {
    cin >> n >> sum;
    for(int i = 1; i <= n; i ++) cin >> a[i];
    for(int i = 0; i <= n; i ++) dp[i][0] = 1;
    for(int i = 1; i <= n; i ++) {
        for(int j = 1; j <= sum; j ++) {
            dp[i][j] = (dp[i-1][j] + dp[i][j-1]) % mod;
            if(j > a[i]) dp[i][j] = (dp[i][j] - dp[i-1][j-a[i]-1] + mod) % mod;
        }
    }
    cout << dp[n][sum] << endl;
    return 0;
}


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

template<typename T>
void swapArgs(T& a, T& b) {
	T t = a;
	a = b;
	b = t;
}

int main() {
	int n;
	cin >> n;
	int* a = new int[n];
	int count = 0;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	for (int i = 0; i < n; i++) {
		int minj = i;
		for (int j = i; j < n; j++) {
			if (a[j] < a[minj]) {
				minj = j;
			}
		}
		if (i != minj) {
			swapArgs(a[i], a[minj]);
			count++;
		}
	}
	cout << a[0];
	for (int i = 1; i < n; i++) {
		cout << " " << a[i];
	}
	cout << endl << count << endl;
	delete[] a;
	return 0;
}


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

#define debug(x) cout << #x << " = " << x << endl
#define fori(i, ini, lim) for(int i = int(ini); i < int(lim); i++)
#define ford(i, ini, lim) for(int i = int(ini); i >= int(lim); i--)

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int, int> ii;

struct edge {
	int u, v, w;
	edge() {}
	edge(int _u, int _v, int _w) : u(_u), v(_v), w(_w) {}
};

const int MOD = 1e9 + 7;
const int MAX = 2e3 + 5;
int pset[MAX], pot[MAX];
int n, m;
ll x, best[MAX];
bool smaller_mst_X = false;

inline int add(int a, int b) {
	a += b;
	if(a >= MOD) {
		a -= MOD;
	}
	return a;
}

inline int sub(int a, int b) {
	a -= b;
	if(0 > a) {
		a += MOD;
	}
	return a;
}

inline int mult(int a, int b) {
	return (1LL * a * b) % MOD;
}

int find_set(int i) {
	return pset[i] == i ? i : pset[i] = find_set(pset[i]);
}

inline bool same_set(int i, int j) {
	return find_set(i) == find_set(j);
}

inline void union_sets(int i, int j) {
	pset[find_set(i)] = find_set(j);
}

ll edge_mst(int index, const vector<edge> &edges) {
	fori(i, 1, n + 1) {
		pset[i] = i;
	}


	ll weight = edges[index].w;
	union_sets(edges[index].u, edges[index].v);

	vector<int> useds {index};
	fori(i, 0, m) {
		if(!same_set(edges[i].u, edges[i].v)) {
			weight += edges[i].w;
			union_sets(edges[i].u, edges[i].v);
			useds.push_back(i);
		}
	}

	if(weight == x) {
		for(auto &each : useds) {
			if(each < index && best[each] < x) {
				smaller_mst_X = true;
			}
		}
	}

	best[index] = weight;

	return weight;
}

int main() {
	scanf("%d %d", &n, &m);

	pot[0] = 1;
	fori(i, 1, MAX) {
		pot[i] = mult(2, pot[i - 1]);
	}

	scanf("%lld", &x);

	vector<edge> edges;
	fori(i, 0, m) {
		int u, v, w;
		scanf("%d %d %d", &u, &v, &w);
		edges.emplace_back(u, v, w);
	}

	sort(edges.begin(), edges.end(), [] (const edge &lhs, const edge &rhs) {
		return lhs.w < rhs.w;
	});

	int smaller = 0, equal = 0, greater = 0;
	fori(i, 0, m) {
		ll mst = edge_mst(i, edges);

		if(mst < x) {
			smaller++;
		}
		else if(mst == x) {
			equal++;
		}
		else if(mst > x) {
			greater++;
		}
	}


	if(equal == 0) {
		puts("0");
	}
	else {
		int ans = pot[equal];
		ans = sub(pot[equal], 1);
		if(!smaller_mst_X) {
			ans = sub(ans, 1);	
		}
		if(smaller) {
			ans = mult(ans, 2);
		}
		ans = mult(ans, pot[greater]);
		printf("%d\n", ans);
	}

	return 0;
}


Measured memory_bytes: 256
s=input()
bl=[]
wl=[]
for j,si in enumerate(s):
  if si=="B":
    bl.append(j)
  else:
    wl.append(j)

blen=len(bl)
wlen=len(wl)

ans=0
for i,j in zip(wl,range(wlen)):
  ans+=abs(i-j)
  
print(ans)





Measured memory_bytes: 11368
#include<bits/stdc++.h>
using namespace std;
#define ll long long int 
#define M 1000000007
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define endl "\n"
#define all(x) (x).begin(), (x).end()
#define tr(x,it) for(auto it = x.begin();it!=x.end();++it)
#define fpresent(x,c) ((c).find(x) != (c).end())  //set,map
#define present(c,x) (find(all(c),x) != (c).end()) //vector
#define pb push_back 
#define mp make_pair
#define ff first
#define ss second
#define setv(ar, val) memset(ar, val, sizeof(ar));
#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
    cerr << *it << " = " << a << endl;
    err(++it, args...);
}
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()); //use mt19937_64 for 64 bit random no.

const int N = 200005;
vector<ll> a(N);

vector<ll> cal(ll k){
    if(k == 1)
        return a;
    vector<ll> temp = cal(k/2), p(a.size());


    for(int i=0;i<a.size();i++){
        p[i] = temp[temp[i]];
    }

    // for(auto it: p)
    //         cout<<it<<" ";
    //     cout<<endl;

    if(k%2){
        for(int i=0;i<a.size();i++){
            temp[i] = a[p[i]];
        }
        p = temp;
    }
    // cout<<k<<endl;
    
    return p;
}

int main()
{
    // freopen("input.in","r",stdin);
    // freopen("output.in","w",stdout);
    fastio;
    cin.tie(NULL);
    ll n,m,i,j,k,ans=0;
    cin>>n>>k;
    a.resize(n);
    for(i=0;i<n;i++){
        cin>>a[i];
        a[i]--;
    }

    // for(i=1;i<=5;i++){
    vector<ll> res = cal(k);
    cout<<res[0] + 1<<endl;
        // for(auto it: res)
        //     cout<<it<<" ";
        // cout<<endl;
    // }

    return 0;
}


Measured memory_bytes: 7984
#include "bits/stdc++.h"
using namespace std;
const int maxn = 100100;
int x[maxn], y[maxn];
set<int> group[maxn];
bool survive[maxn];
int M(){
    int n, m;
    if(!~scanf("%d %d", &n, &m)) return 0;
    for(int e = 0; e < m; e++)
        scanf("%d %d", x + e, y + e);
    for(int e = 1; e <= n; e++){
        group[e].clear();
        group[e].insert(e);
        survive[e] = true;
        for(int f = m-1; f >= 0; f--){
            int hasX = group[e].count(x[f]);
            int hasY = group[e].count(y[f]);
            if(hasX && hasY){
                survive[e] = false;
                break;
            } else if(hasX != hasY){
                group[e].insert(x[f]);
                group[e].insert(y[f]);
            }
        }
    }
    int pairs = 0;
    for(int e = 1; e <= n; e++)
        for(int f = e + 1; f <= n; f++){
            if(survive[e] && survive[f]){
                bool ok = true;
                for(int v : group[e])
                    if(group[f].count(v)) ok = false;
                if(ok) pairs++;
            }
        }
    printf("%d\n", pairs);
    return 1;
}
int main(){
    while(M());
    return 0;
}


Measured memory_bytes: 6400
n,m = map(int, input().split())

R = [list(map(int,input().split())) for i in range(m)]

X = []
for i in range(m):
  X.append(R[i][0])
  X.append(R[i][1])
  
for i in range(1,n+1):
  print(X.count(i))

Measured memory_bytes: 3060
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cctype>
 
#include <algorithm>
#include <tuple>
#include <random>
#include <bitset>
#include <queue>
#include <functional>
#include <set>
#include <map>
#include <vector>
#include <chrono>
#include <iostream>
#include <limits>
#include <numeric>
 
#define LOG(FMT...) fprintf(stderr, FMT)

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

// mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
 
template <class T>
istream& operator>>(istream& is, vector<T>& v) {
  for (T& x : v)
    is >> x;
  return is;
}
 
template <class T>
ostream& operator<<(ostream& os, const vector<T>& v) {
  if (!v.empty()) {
    os << v.front();
    for (int i = 1; i < v.size(); ++i)
      os << ' ' << v[i];
  }
  return os;
}

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

  int n, k;
  cin >> n >> k;
  vector<bool> taboo(10);
  while (k--) {
    int x;
    cin >> x;
    taboo[x] = true;
  }
  function<bool(int)> f = [&](int x) {
    if (x == 0) return false;
    return taboo[x % 10] || f(x / 10);
  };
  while (f(n)) ++n;
  cout << n;

  return 0;
}


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

int main(){
    string O,E;
    cin >> O >> E;
    int size_O = O.size();
    int size_E = E.size();
    int size;
    size = size_O > size_E ? size_O : size_E;
    for(int i = 0;i < size;i++){
        if(i < size_O){
            cout << O.at(i);
        }
        if(i < size_E){
            cout << E.at(i);
        }
    }
    cout << endl;
}

Measured memory_bytes: 256
import java.util.*;
import javax.lang.model.util.ElementScanner6;
//import java.lang.Math;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        // 入力
        int x = sc.nextInt();

        // 処理
        int out = 0;

        out += (x / 500) * 1000;
        out += ((x % 500) / 5) * 5;

        // 出力
        System.out.println(out);
    }
}

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

// ?????¬???????????¬??????
#pragma region MACRO
#define P(x) cout << (x) << endl
#define p(x) cout << (x)
#define PED cout << "\n"
#define rep(i,n) for(int i=0; i<(int)n; ++i)
#define REP(i,x,n) for(int i=x; i<(int)n; ++i)
#define repi(i,n) for(int i=0; i<=(int)n; ++i)
#define REPI(i,x,n) for(int i=x; i<=(int)n; ++i)
#define ILP while(true)
#define FOR(i,c) for(__typeof((c).begin())!=(c).begin(); i!=(c).end(); ++i)
#define ALL(c) (c).begin(), (c).end()
#define mp make_pair
#pragma endregion

// ???
#pragma region TYPE_DEF
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<string, string> pss;
typedef pair<string, int> psi;
typedef pair<int, string> pis;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<long double> vld;
typedef vector<long> vl;
typedef vector<long long> vll;
typedef vector<string> vs;
#pragma endregion

// Effective std
#pragma region ESTD
template<typename C, typename T> int count(C& c, T t) { return count(ALL(c), t); }
template<typename C, typename F> int count_if(C& c, F f) { return count_if(ALL(c), f); }
template<typename C, typename T> void erase(C& c, T t) { remove(ALL(c), t), c.end(); }
template<typename C> void remove(vector<C>& c, unsigned int index) { c.erase(c.begin()+index); }
template<typename C, typename T, typename U> void replace(C& c, T t, U u) { replace(ALL(c), t, u); }
template<typename C, typename F, typename U> void replace_if(C& c, F f, U u) { (ALL(c), f, u); }
template<typename C> void reverse(C& c) { reverse(ALL(c)); }
template<typename C> void sort(C& c) { sort(ALL(c)); }
template<typename C, typename Pred> void sort(C& c, Pred p) { sort(ALL(c), p); }
#pragma endregion

// ?????°
#pragma region CONST_VAL
constexpr int PI = (2*acos(0.0));
constexpr int EPS = (1e-9);
constexpr int MOD = (int)(1e9+7);
constexpr int INF = 100000000;
#pragma endregion


int main()
{
    int n;
    cin >> n;
    rep(i, n) {
        int l = 0, r = 0;
        bool f = true;
        rep(i, 10) {
            int t;
            cin >> t;
            if (t > l) l = t;
            else if (t > r) r = t;
            else f = false;
        }
        P(f ? "YES" : "NO");
    }
    return 0;
}

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

#define INF 1e9
#define llINF 1e18
#define MOD 1e9+7
#define pb push_back
#define mp make_pair 
#define F first
#define S second
#define ll long long
#define ALL(a) (a).begin(),(a).end()
#define Yes(hoge) cout<<((hoge)?"Yes":"No")<<endl;
#define YES(hoge) cout<<((hoge)?"YES":"NO")<<endl;
using namespace std;
int main(){
  int n;cin>>n;
  vector<string>vs;
  bool flag=true;
  for(int i=0;i<n;i++){
    string str;cin>>str;
    for(int j=0;j<vs.size();j++){
      if(vs[j] == str)
	flag=false;
    }
    if(i!=0){
      if(vs[i-1][vs[i-1].size()-1]!=str[0])
	flag=false;
    }
    vs.pb(str);
  }
  Yes(flag);
  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main{
	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		String s=scanner.next();
		if(s.contains("N")&&s.contains("W")&&s.contains("S")&&s.contains("E")){
			System.out.println("Yes");
		}else if(s.contains("N")&&!s.contains("W")&&s.contains("S")&&!s.contains("E")){
			
			System.out.println("Yes");
		}else if(!s.contains("N")&&s.contains("W")&&!s.contains("S")&&s.contains("E")){
			
			System.out.println("Yes");
		}else{
			System.out.println("No");
		}
	}
}


Measured memory_bytes: 9428
//
//  Median Pyramid Hard.cpp
//  National Olympiad in Informatics in Provinces
//
//  Created by 黄子齐 on 2019/10/5.
//  Copyright © 2019 黄子齐. All rights reserved.
//

#include <stdio.h>
const int N = 2e5+10;
int a[N], n;
bool b[N];
inline bool check(int mid) {
    for (int i=1; i<=2*n-1; i++) {
        b[i] = (!(a[i]<=mid));
    }
    for (int l=n-1, r=n+1; l>=1; l--, r++) {
        if (b[l] == b[l+1]) {
            return b[l];
        } else if (b[r] == b[r-1]) {
            return b[r];
        }
    }
    return b[1];
}
int main() {
//    freopen("mytestdata.in", "r", stdin);
    scanf("%d", &n);
    for (int i=1; i<=2*n-1; i++) {
        scanf("%d", &a[i]);
    }
    int l=1, r=2*n-1;
    while (l < r) {
        int mid=l+r>>1;
        if (check(mid)) {
            l = mid+1;
        } else {
            r = mid;
        }
    }
    printf("%d\n", l);
    return 0;
}


Measured memory_bytes: 1152
class _Node {
  constructor(key, parent = null, left = null, right = null) {
    this.key = key;
    this.parent = parent;
    this.left = left;
    this.right = right;
  }
}

class BinaryTree {
  constructor() {
    this.root = null;
  }

  static get Node() { return _Node; }

  insert(key) {
    this.root = new BinaryTree.Node(key, null, null, null);

    this.insert = (key) => {
      let x = this.root, y;
      let newNode = new BinaryTree.Node(key, null, null, null);
      while (x != null) {
        y = x;
        x = x[key < x.key ? 'left' : 'right'];
      }
      newNode.parent = y;
      y[key < y.key ? 'left' : 'right'] = newNode;
    }
  }

  printByIneorder() {
    let str = '';
    let innerFunc = (n) => {
      if (n === null) return;
      innerFunc(n.left);
      str += ` ${n.key}`;
      innerFunc(n.right);
    }
    innerFunc(this.root)
    console.log(str);
  }

  printByPreorder(n = this.root) {
    let str = '';
    let innerFunc = (n) => {
      if (n === null) return;
      str += ` ${n.key}`;
      innerFunc(n.left);
      innerFunc(n.right);
    }
    innerFunc(this.root)
    console.log(str);
  }

  print() {
    this.printByIneorder();
    this.printByPreorder();
  }
}

(function main(){
  const lines = require('fs').readFileSync('/dev/stdin', 'utf8').trim().split('\n');
  const n = Number(lines.shift());

  const tree = new BinaryTree();
  const commands = lines.map((line) => line.split(' '));
  commands.forEach(function(cmd) {
    switch(cmd[0].charAt(0)) {
    case 'i':
      tree.insert(Number(cmd[1]));
      break;
    default:
      tree.print();
    }
  });

})();



Measured memory_bytes: 270320
import bisect,collections,copy,heapq,itertools,math,string
from collections import defaultdict as D
from functools import reduce
import numpy as np
import sys
import os
from operator import mul

sys.setrecursionlimit(10**7)

def _S(): return sys.stdin.readline().rstrip()
def I(): return int(_S())
def LS(): return list(_S().split())
def LI(): return list(map(int,LS()))

if os.getenv("LOCAL"):
    inputFile = basename_without_ext = os.path.splitext(os.path.basename(__file__))[0]+'.txt'
    sys.stdin = open(inputFile, "r")
INF = float("inf")
IINF = 10 ** 18
MOD = 10 ** 9 + 7
# MOD = 998244353    

N = I()
B = LI()

A = [0]*N

A[0]=B[0]
for i in range(1,N-1):
    A[i]=min(B[i],B[i-1])
A[N-1]=B[N-2]
print(sum(A))

Measured memory_bytes: 27104
#include<stdio.h>
#include<algorithm>
int main()
{
	static char a[1000][1002];
	static int n,i,j,w[1000][1000],v;
	while(scanf("%d",&n),n)
	{
		for(i=0;i<n;++i)
		{
			scanf("%s",a[i]);
			w[i][0] = (a[i][0]=='.');
		}
		for(j=0;j<n;++j)
			w[0][j] = (a[0][j]=='.');
		v=0;
		for(i=1;i<n;++i)
			for(j=1;j<n;++j)
			{
				if(a[i][j]=='*') w[i][j]=0;
				else
				{
					w[i][j] = std::min(w[i-1][j], std::min(w[i-1][j-1],w[i][j-1]))+1;
					v = std::max(w[i][j],v);
				}
			}
		printf("%d\n",v);
	}
	return 0;
}

Measured memory_bytes: 0
from itertools import combinations

N, M = map(int, input().split())
S = []
for _ in range(M):
    s = [int(s) for s in input().split()]
    s.pop(0)
    S.append(s)
P = [int(s) for s in input().split()]

ANS = [i for i in range(2**N)]
for p, s in zip(P, S):
    for r in range(p ^ 1, len(s) + 1, 2):
        for selected in combinations(s, r):
            others = set(s) - set(selected)
            n = 0
            for i in selected:
                n += 2**(i - 1)
            m = 0
            for i in others:
                m += 2**(i - 1)
            ANS = [ans for ans in ANS if not (ans & n == n and ans & m == 0)]
print(len(ANS))


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

   scanf("%d",&n);
   if((n==1)||(n==2)||(n==3)||(n==5)||(n==6)||(n==9)||(n==10)||(n==13)||(n==17)) printf("No\n");
   else printf("Yes\n");
           return 0;
}



Measured memory_bytes: 128
n = int(input())
a = []
for i in range(2):
    a.append(list(map(int, input().split())))

cnt = []
for i in range(n):
    cnt.append(a[0][i])
    for j in range(i):
        cnt[i] += a[0][j]
    for j in range(i, n):
        cnt[i] += a[1][j]

print(max(cnt))

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

const ll MOD=LLONG_MAX;
const int INF=0x3f3f3f3f;
const ll INFL=0x3f3f3f3f3f3f3f3f;

int main(){
	string s;cin>>s;
	if(s=="ABC"){
		cout<<"ARC"<<endl;
	}
	else{
		cout<<"ABC"<<endl;
	}
}

Measured memory_bytes: 3620
#include<stdio.h>
int compare_string(const void *a, const void *b){
	while(*(char*)a!=0 && *(char*)a==*(char*)b){
		(char*)a++; (char*)b++;
	}
	if(*(char*)a==0){
		return 1;
	}else{
		return 0;
	}
}

int n, i;
char s[101], t[101];
int main(void){
  scanf("%d%s%s", &n, s, t);
  for(i=0; i<n; i++){
    if(compare_string(s+i, t)){break;}
  }
  printf("%d\n", n+i);
}


Measured memory_bytes: 128
#include <stdio.h>// standard input output
#include <iostream>// input output stream, cin cout( console in console out)
#include <cmath>// circle math ( sin, con, sinh
#include <string>
#include <vector>
#include <algorithm>
#include <iomanip>// input output manipulation

using namespace std;
#define rep(i,a, n) for(int i = (int)a; i < (int)n; i++)
#define ll long long

int main() {

  ll N;
  cin>>N;
  ll h[N];
  rep(i,0,N) cin >> h[i];
  long cost[N];
  //rep(i,N) h[i] = -1;

  cost[0] = 0;
  cost[1] = abs(h[0]-h[1]);

  rep(i,2,N)
    cost[i] = min( cost[i-2] + abs(h[i] - h[i-2]), cost[i-1] + abs(h[i] - h[i-1]));

  cout << cost[N-1] << endl;
  return 0;
}

Measured memory_bytes: 1792
#include <iostream>
#include <sstream>
#include <string>

using namespace std;

int N, A, B, C, X;

int solve(stringstream&& ss){
    int Y, pY = -1, F = -1;
    for(;ss>>Y && F<=10000; pY=Y, X=(A*X+B)%C, F++){
        for(;Y!=X && F<=10000; X=(A*X+B)%C, F++);
    }
    return 10000 < F? -1: F;
}

int main(){
    while(cin >> N >> A >> B >> C >> X, N|A|B|C|X){
        cin.ignore();
        string line;
        getline(cin, line);
        cout << solve(stringstream(line)) << '\n';
    }
    return 0;
}

Measured memory_bytes: 1216
import java.util.*;
import java.lang.*;
import java.io.*;

public class Main {

    public static void main(String[] args)
    {
        Scanner sc = new Scanner(System.in);
        String str = sc.nextLine();
        char[] ch = str.toCharArray();

        if(ch[2]==ch[3] && ch[4]==ch[5])
        	System.out.println("Yes");
        else
        	System.out.println("No");
      
        sc.close();
    }

}


Measured memory_bytes: 21844
#include <vector>
#include <algorithm>
#include <cmath>
#include <set>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <iostream>
#include <string>
#include <map>
#include <unordered_map>
using namespace std;



int MinimumNumIncreasingSubsequences(vector <int> &arr, int n)
{
	multiset<int> last;

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

		
		multiset<int>::iterator it = last.lower_bound(arr[i]);

		
		if (it == last.begin())

			
			last.insert(arr[i]);

		else {
			it--;

			
			last.erase(it);
			last.insert(arr[i]); 
		}
	}
	return last.size(); 
}

// Driver program 
int main()
{
	int n;
	cin >> n;
	vector<int>arr(n);
	for (int i = 0; i < n; i++)
		cin >> arr[i];
	int ans = MinimumNumIncreasingSubsequences(arr, n);
	cout << ans;
}

Measured memory_bytes: 5376
#include <bits/stdc++.h>
using namespace std;
using ll=long long int;
using ld=long double;
using VI=vector<ll>;
using VD=vector<ld>;
using VVI=vector<VI>;
using VC=vector<char>;
using VVC=vector<VC>;
using VS=vector<string>;
using PLL =pair<ll,ll>;
using PLD=pair<ld,ld>;
using VPLL=vector<PLL>;
#define print(x) std::cout<<x<<"\n"
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define repd(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define ALL(x) (x).begin(),(x).end()
#define ALLR(x) (x).rbegin(),(x).rend()
#define SZ(x) ((ll)(x).size())
#define MAX(x) *max_element((x).begin(),(x).end())
#define MIN(x) *min_element((x).begin(),(x).end())
#define SORTR(x) sort((x).rbegin(),(x).rend())
#define SORT(x) sort((x).begin(),(x).end())
#define SUM(x) accumulate((x).begin(),(x).end(), 0)
#define FILL(x,a) fill(x.begin(),x.end(),a)
#define EACH(i,x) for(typeof((x).begin()) i=(x).begin(); i!=(x).end(); ++i)
#define EXIST(v, x) (std::find(v.begin(), v.end(), x) != v.end())

const ll INF = 1e18;
const ld EPS   = 1e-10;
const int MOD  = int(1e9)+7;
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; }
template <class BidirectionalIterator>
bool next_partial_permutation(BidirectionalIterator first, BidirectionalIterator middle,BidirectionalIterator last){reverse(middle, last); return next_permutation(first , last);}
ll gcd(ll x, ll y) { return (x % y)? gcd(y, x % y): y; }
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }
ll GCD(VI v){ll a = v[0]; for (ll i = 1; i<SZ(v); i++) {a = gcd(a, v[i]);} return a;}
ll LCM(VI v){ll a = v[0]; for (ll i = 1; i<SZ(v); i++) {a = lcm(a, v[i]);} return a;}
VI Bit2Vector(const ll bit, ll n) {	VI s;	rep(i,n) if (bit & (1 << i)) s.push_back(i); return s;}


void Main()
{
	ll n,m,l,k; ll res=0;
	cin>>n>>k;
	VVI dp(1001,VI(k+1,0));
	VI wei(n),val(n);
	rep(i, n) cin >> wei[i]>>val[i];
	//初期条件
	rep(i,k) dp[0][i]=0;
	rep(i,n){//すべての試行
		rep(w,k+1){//すべての重さw以下の場合の最大値を探索
			//価値[次の試行,重さ]＝最大( 価値[前の試行][重さ]+価値[重さ],価値[次の試行,重さ])
			if(w>=wei[i]) dp[i+1][w]=max(dp[i+1][w],dp[i][w-wei[i]]+val[i]);
			dp[i+1][w]=max(dp[i+1][w],dp[i][w]);
		}
	}
	res=MAX(dp[n]);
	cout << res << "\n";
	return;
}

int main()
{
	std::cin.tie(0);
	std::ios_base::sync_with_stdio(false);
	std::cout << std::fixed << std::setprecision(15);
	Main();
}


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

int main()
{
    string ss;
    int n,sum=0;
    cin>>n;
    vector<pair<string,int> >v;
    for(int i=0; i<n; i++)
    {
        int t;
        string s;
        cin>>s>>t;
        sum+=t;
        v.push_back(make_pair(s,t));
    }

    //cout<<sum<<endl;

    cin>>ss;

    for(int i=0;i<v.size();i++)
    {
        //cout<<v[i].second<<" ";
        //cout<<sum<<" ";
        if(v[i].first==ss)
        {
            sum-=v[i].second;
            break;
        }
        else
        {
            sum-=v[i].second;
        }
    }

    cout<<sum<<endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define trace1(x)                cerr<<#x<<": "<<x<<endl
#define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define trace4(a, b, c, d)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define trace5(a, b, c, d, e)    cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
#define trace6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl
#define endl '\n'
#define int long long
int p(int a,int b)
{
	int res=1;
	while(b)
	{
		if(b%2)
			res*=a;
		a*=a;
		b/=2;
	}
	return res;
}
int32_t main()
{
    int h;
    cin>>h;
    int ans=0;
    int count=0;
    while(h>0)
    {
    	h/=2;
    	count++;
    }
    cout<<p(2,count)-1;
}

Measured memory_bytes: 256
import std.algorithm, std.container, std.conv, std.math, std.range, std.typecons, std.stdio, std.string;

auto rdsp(){return readln.splitter;}
void pick(R,T)(ref R r,ref T t){t=r.front.to!T;r.popFront;}
void readV(T...)(ref T t){auto r=rdsp;foreach(ref v;t)pick(r,v);}
void writeA(T)(size_t n,T t){foreach(i,v;t.enumerate){write(v);if(i<n-1)write(" ");}writeln;}

void main()
{
  int n, k, l; readV(n, k, l);

  auto ufk = UnionFind!int(n);
  foreach (_; 0..k) {
    int p, q; readV(p, q); --p; --q;
    ufk.unite(p, q);
  }

  auto ufl = UnionFind!int(n);
  foreach (_; 0..l) {
    int r, s; readV(r, s); --r; --s;
    ufl.unite(r, s);
  }

  struct F { int k, l; }
  auto f = new F[](n);
  foreach (i; 0..n) f[i] = F(ufk[i], ufl[i]);

  auto fs = f.dup.sort!"a.k == b.k ? a.l < b.l : a.k < b.k";
  auto r = new int[](n);
  foreach (i; 0..n) r[i] = fs.equalRange(f[i]).length.to!int;

  writeA(n, r);
}

struct UnionFind(T)
{
  import std.algorithm, std.range;

  T[] p; // parent
  const T s; // sentinel
  const T n;
  T countForests; // number of forests
  T[] countNodes; // number of nodes in forests

  this(T n)
  {
    this.n = n;
    s = n;
    p = new T[](n);
    p[] = s;
    countForests = n;
    countNodes = new T[](n);
    countNodes[] = 1;
  }

  T opIndex(T i)
  {
    if (p[i] == s) {
      return i;
    } else {
      p[i] = this[p[i]];
      return p[i];
    }
  }

  bool unite(T i, T j)
  {
    auto pi = this[i], pj = this[j];
    if (pi != pj) {
      p[pj] = pi;
      --countForests;
      countNodes[pi] += countNodes[pj];
      return true;
    } else {
      return false;
    }
  }

  auto countNodesOf(T i) { return countNodes[this[i]]; }
  bool isSame(T i, T j) { return this[i] == this[j]; }

  auto groups()
  {
    auto g = new T[][](n);
    foreach (i; 0..n) g[this[i]] ~= i;
    return g.filter!(l => !l.empty);
  }
}


Measured memory_bytes: 10492
//%std
#include<bits/stdc++.h>
#define endl '\n'
using namespace std;
typedef long long ll;
inline int read()
{
	int out=0,fh=1;
	char jp=getchar();
	while ((jp>'9'||jp<'0')&&jp!='-')
		jp=getchar();
	if (jp=='-')
		fh=-1,jp=getchar();
	while (jp>='0'&&jp<='9')
		out=out*10+jp-'0',jp=getchar();
	return out*fh;
}
int k=100000;
int main()
{
	int x=read(),y=read();
	int ans=0;
	if(x==1 && y==1)
		ans+=4;
	if(x<=3)
		ans+=4-x;
	if(y<=3)
		ans+=4-y;
	cout<<ans*k<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <cmath>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <algorithm>
#include <utility>
#include <deque>
#include <stack>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<ll> vl;
typedef queue<int> qi;
typedef queue<ll> ql;
typedef pair<ll,ll> pll;
typedef pair<int,ll> pil;
typedef pair<ll,int> pli;
#define rep(i,n) for (int i=0;i<n;i++)
#define mp make_pair
#define pb push_back
#define pf push_front
#define F first
#define S second
#define INF 200000009

int main(){
	ios::sync_with_stdio(false);
	int k,a,b;cin>>k>>a>>b;
	if (a+2>=b){
		cout<<k+1<<endl;return 0; 
	}
	if (k<2){
		cout<<k+1<<endl;return 0;
	}
	if (k-2<a-1){
		cout<<k+1<<endl;return 0;
	}
	k-=a-1;
	ll ans=(ll)a+(ll)(k>>1)*(b-a)+(ll)(k&1);
	cout<<ans<<endl;
	return 0; 
}

Measured memory_bytes: 256
#if !defined(__clang__) && defined(__GNUC__)
#include <bits/stdc++.h>
#else
#include <cstdlib>
#include <climits>
#include <iostream>
#include <cstdint>
#include <vector>
#include <string>
#include <complex>
#include <bitset>
#include <queue>
#include <deque>
#include <stack>
#include <utility>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <regex>
#endif //  !defined(__clang__) && defined(__GNUG__)
#include <boost/lexical_cast.hpp>
#include <boost/algorithm/string.hpp>
#include <boost/multi_array.hpp>
#include <boost/optional.hpp>
#include <boost/math/common_factor_rt.hpp>

using namespace std;

int main()
{
    int64_t A, B;
    std::cin >> A >> B;;

    auto q = A+B;
    auto r = A-B;
    auto s = A*B;

    auto t = std::max({q, r, s});

    std::cout << t << std::endl;

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
/*
#include<iostream>
#include<vector>
#include<string>
#include<array>
#include<cmath>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<numeric>
#include<iomanip>
#include<utility>
#include<cstdlib>
#include<typeinfo>
#include<stack>
#include<cassert>
#include<functional>
*/
#define int long long int
#define double long double
using namespace std;
#define INT_DMAX 1000000007
#define INF 1000000000000000007
const int MAX_N = 1 << 17;
#define rep(i,n) for(int (i)=0, i##_len = (n);(i)<i##_len;(i)++)
#define reps(i,x) for(int (i)=1;(i)<=(int)(x);(i)++)
#define rrep(i,x) for(int (i)=((int)(x)-1);(i)>=0;(i)--)
#define rreps(i,x) for(int (i)=((int)(x));(i)>0;(i)--)
#define FOR(i,a,b) for (int (i) = (a); (i) < (b); (i)++)
#define pb push_back
#define mp make_pair
#define bit(n) ((int)(1)<<(n))
#define all(x) (x).begin(),(x).end()
#define debug(x) std::cout << #x << ": " << (x) << std::endl 
#define nint int
using namespace std;

int dy[]={0, 0, 1, -1, 0};
int dx[]={1, -1, 0, 0, 0};
typedef pair<int,int> p;
typedef pair<double,double> dop;
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 gcd(int a,int b){return b?gcd(b,a%b):a;}
struct aaa{
    aaa(){
        cin.tie(0); ios::sync_with_stdio(0); cout<<fixed<<setprecision(20);
    };
}aaaaaaa;


signed main()
{
int n;
std::cin >> n;
std::vector<int> a(n,0);
for(int i = 0; i < n; i++){
    int temp;
    std::cin >> temp;
    a[i] = temp;
}

std::vector<int> out(n,0);
int l = 0;
int r = n - 1;
for(int i = n - 1; i >= 0; i--){
    if((i + 1) % 2 == 0){
        out[r] = a[i];
        r--;
    } else {
        out[l] = a[i];
        l++;
    }
}

if(n % 2 == 0){
    for(int i = n - 1; i > 0; i--){
        std::cout << out[i] << " ";
    }
    std::cout << out[0] << std::endl;
} else {
    for(int i = 0; i < n - 1; i++){
        std::cout << out[i] << " ";
    }
    std::cout << out[n - 1] << std::endl; 
}
return 0;
}

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

using namespace std;

bool cmp(const long long&a, const long long&b)
{
    return a>b;
}
    long long A[100001];
    long long B[100001];
    long long C[400001];
    long long D[4000001];
    long long E[4000001];
int main()
{
    int X, Y, Z, K;

    cin>>X>>Y>>Z>>K;

    int o=0;
    int p=0;

    for(int i=0;i<X;i++)
        cin>>A[i];
    for(int i=0;i<Y;i++)
        cin>>B[i];
    for(int i=0;i<Z;i++)
        cin>>C[i];
    for(int i=0;i<X;i++)
        for(int j=0;j<Y;j++)
            D[o++] = A[i] + B[j];
    sort(D,D+X*Y,cmp);
    int l1 = min(K,X*Y); 
    for(int i=0;i<l1;i++)
        for(int j=0;j<Z;j++)
            E[p++] = D[i] + C[j];
    sort(E,E+l1*Z,cmp);
    int l2 = min(K,l1*Z);
    for(int i=0;i<l2;i++)
        cout<<E[i]<<endl;
    return 0;
}

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

int main(){
  int A, B, K;
  cin >> A >> B >> K;
  for(int i=0; i<K; i++){
    if(i%2==0){
      if(A%2==1){
        A--;
      }
      A/=2;
      B+=A;
    }else{
      if(B%2==1){
        B--;
      }
      B/=2;
      A+=B;
    }
  }
  cout << A << " " << B << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <typeinfo>
#include <vector>
#include <cmath>
#include <set>
#include <map>
#include <string>
#include <algorithm>
#include <cstdio>
#include <queue>
#include <iomanip>
#include <cctype>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<char> vc;
typedef vector<vc> vvc;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<25;
const double pi=acos(-1);
const double eps=1e-8;
const vi emp;

int N;
string s;

int main(){
	while(1){
		cin>>N;
		if(!N) break;
		vi a(N);
		int B=0;
		cin>>s;
		for(int i=0;i<100;i++){
			int I=i%N;
			if(s[i]=='M') a[I]++;
			else if(s[i]=='L'){
				a[I]+=B+1;
				B=0;
			}
			else{
				B+=a[I]+1;
				a[I]=0;
			}
		}
		sort(a.begin(),a.end());
		for(vi::iterator i=a.begin();i!=a.end();i++) cout<<*i<<' ';
		cout<<B<<endl;
	}
}

Measured memory_bytes: 1224
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "math.h"
#include "utility"
#include "string"
#include "map"
#include "unordered_map"
#include "iomanip"
#include "random"

using namespace std;
const long long int MOD = 1000000007;

long long int power(long long int x, long long int n, long long int M) {
	long long int tmp = 1;

	if (n > 0) {
		tmp = power(x, n / 2, M);
		if (n % 2 == 0) tmp = (tmp*tmp) % M;
		else tmp = (((tmp*tmp) % M)*x) % M;
	}
	return tmp;
}

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

using namespace std;


int main() {
	ios::sync_with_stdio(false);
	long long int num[2001][2001] = {};
	cin >> N >> M;
	long long int slime[2000] = {};
	for (int i = 0; i < N; i++) {
		cin >> slime[i];
		num[i][0] = slime[i];
	}
	for (int i = 0; i < N; i++) {
		for (int j = 1; j < N; j++) {
			num[i][j] = min(num[i][j-1], slime[(i + N - j) % N]);
			//cout << i << " " << j << " " << num[i][j] << endl;
		}
	}
	ans = LLONG_MAX;
	for (int i = 0; i < N; i++) {
		long long int box = 0;
		for (int j = 0; j < N; j++) {
			box += num[j][i];
		}
		box += M*i;
	//	cout << box << endl;
		ans = min(ans, box);
	}
	cout << ans << endl;
	return 0;
}

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

const int N = 22;
const int MASK = 1<<21;
const int MOD = 1000000000 + 7;

int add(int a, int b){
	return (a + b) % MOD;
}

int n;
int a[N][N];
bool vis[MASK];
int memo[MASK];

int DP(int mask){
	int man = n - __builtin_popcount(mask);
	if(mask == 0) return 1;
	if(vis[mask]) return memo[mask];
	int ans = 0;
	for(int nxt = mask; nxt > 0; nxt &= nxt - 1){
		int woman = 31 - __builtin_clz(nxt & (-nxt));
		if(a[man][woman]){
			ans = add(ans, DP(mask ^ (1 << woman)));
		}
	}
	vis[mask] = true;
	return memo[mask] = ans;
}

int main(){
	scanf("%d", &n);
	for(int i = 0; i < n; i++){
		for(int j = 0; j < n; j++){
			scanf("%d", &a[i][j]);
		}
	}
	printf("%d\n", DP((1 << n) - 1));
	return 0;
}


Measured memory_bytes: 13992
// When you are hungry for something and you're determined and you're focused 
// and you're committed to something it's hard to surrender, isn't it?

#include <bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(), (x).end()
#define endl "\n"
#define ll long long 
#define int ll
#define mod 1000000007
#define mod1 1000000006
#define modi 998244353
#define ff first
#define ss second
#define pb push_back
vector<ll> vi[300005];
int color[100005];
ll pa[500005];
ll si[500005];
#define pb push_back
bool visi[1000005]={false};
bool is[100005];
ll fac[10000001];
ll prime[400005];
ll bit[100005];
const long double eps = 1.0e-14;      // allowable error
#define fio ios_base::sync_with_stdio(false); cin.tie(NULL);
 
 
void fact(){
    fac[0]=1;
    for(int i=1;i<=10000000;i++){
        fac[i]=(fac[i-1]*i)%mod;
    }
    return ;
}
void sieve(){
    prime[0]=0;
    prime[1]=0;
    for(int i=2;i<400005;i++){
        prime[i]=1;
    }
    for(int i=2;i*i<400005;i++){
        if(prime[i]==1){
            for(int j=i*i;j<400005;j+=i){
                prime[j]=0;
            }
        }
    }
    
}
 
ll power(ll n , ll p ){
    if(p==0)
        return 1;
    
    ll res = power((n*n)%mod,p/2);
    if(p%2==1)
        res = (n*res)%mod;
    
    return res;
}
 
 
void upd(ll i,ll val,ll n) {
    for(;i<=n;i+=i&(-i))
        bit[i]+=val;
}
 
ll qry(ll i) {
    ll sum=0;
    for(;i>0;i-=i&(-i))
        sum+=bit[i];
    return sum;
}
 
 
ll fin(ll u) {
    if(pa[u]==u)
        return u;
    return fin(pa[u]);
}
 
void uni(ll u,ll v) {
    ll p1=fin(u);
    ll p2=fin(v);
    if(p1==p2)
        return;
    if(si[p1]<si[p2])
        swap(p1,p2);
    si[p1]+=si[p2];
    pa[p2]=p1;
    return;
}

bool check(string s) {
    
    int n=s.size(),flag=0;
    
    for(int i=0;i<n;i++){
        if(s[i]!=s[n-i-1]){
            flag = 1;
            break;
        }
    }
    if(flag)
    return false;
    else
    return true;
    
}
 
int32_t main() {
    fio

    int n,m;
    cin >> n >> m;
    
    int x = n*(n-1)/2;
    int y = m*(m-1)/2;
    
    cout << x+y << endl;
    
	return 0;
    
}

Measured memory_bytes: 8960
#include<stdio.h>

int main()
{
    int s;
    scanf("%d",&s);
    if(s/100<=12&&s%100<=12&&s/100!=00&&s%100!=00)
    printf("AMBIGUOUS");
   else if(s/100<=12&&s/100!=00&&s%100!=00)
        printf("MMYY");
        else if(s/100<=12&&s/100!=00&&s%100==00)
        printf("MMYY");
    else if(s%100<=12&&s%100!=00&&s/100!=00)
        printf("YYMM");
         else if(s%100<=12&&s%100!=00&&s/100==00)
        printf("YYMM");
    else printf("NA");
    return 0;
}


Measured memory_bytes: 128
#include <iostream>

using namespace std;

int main(){

  int s;
  cin >> s;
  const int n=1000000;  
  int a[n],counts[n]={0};
  
  a[0]=s;
  counts[s]++;
  for(int i=1;i<n;i++){
  
    if(a[i-1]%2==0){
    a[i]=a[i-1]/2;
    }
    else{
    a[i]=3*a[i-1]+1;
    }
    if(counts[a[i]]==1){ 
     cout << i+1 <<endl;
      break;
    }
    counts[a[i]]++;
  }  
  
}


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

int main(void){
  int m,n;
  double v;
  double area1=0;
  double area2=0;
  double angle1,angle2;
  while(1){
    area1=0;
    area2=0;
    angle1=360;
    angle2=360;
    cin>>n;
    if(n==0)break;
    for(int i=0;i<n-1;i++){
      cin>>v;
      angle1-=v;
      v=2*v*M_PI/360;
      area1+=sin(v)/2;
    }
    area1+=sin(2*angle1*M_PI/360)/2;
    cin>>m;
    for(int i=0;i<m-1;i++){
      cin>>v;
      angle2-=v;
      v=2*v*M_PI/360;
      area2+=sin(v)/2;
    }
    area2+=sin(2*angle2*M_PI/360)/2;
    if(abs(area1-area2)<0.00000001){
      cout<<0<<endl;
    }
    else if(area1>area2){
      cout<<1<<endl;
    }
    else{
      cout<<2<<endl;
    }
  }
  return 0;

}



Measured memory_bytes: 3388
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n=sc.nextInt(),x=sc.nextInt();
		int min =1500;
		int ans=n;

		for(int i=0;i<n;i++) {
			int m=sc.nextInt();
			x-=m;
			if(min>m) {
				min=m;
			}
		}
		ans+=x/min;
		System.out.println(ans);
	}
}

Measured memory_bytes: 25172
#include <cmath>
#include <iostream>
#include <string>
#include <vector>
#define rep(i, j) for (long long i = 0; i < j; i++)

using namespace std;

signed main()
{
    int answer = 0;
    int N;
    cin >> N;
    vector<int> A_arr;
    vector<int> B_arr;
    vector<int> C_arr;
    int x;
    rep(i, N)
    {
        cin >> x;
        A_arr.push_back(x);
    }
    rep(i, N)
    {
        cin >> x;
        B_arr.push_back(x);
    }

    rep(i, N)
    {
        cin >> x;
        C_arr.push_back(x);
    }
    int a_pre = -2;
    rep(i, N)
    {
        int a = A_arr[i];
        answer += B_arr[a - 1];
        if (a - a_pre == 1)
            answer += C_arr[a_pre - 1];
        a_pre = a;
    }
    cout << answer << endl;
}


Measured memory_bytes: 256
"use strict";
function main(input) {
    const line = input.split("\n");
    let arr = line[0].split(" ");
    const N = parseInt(arr[0]);
    const K = parseInt(arr[1]);
    let p = line[1].split(" ").map(Number);
    p.sort(function (a, b) {
        return a < b ? -1 : 1;
    });
    p = p.slice(0, K);
    console.log(p.reduce((pi, x) => pi + x));
    return;
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 29560
//============================================================================
// Name        : ATcoder.cpp
// Author      : Akari Fujii
// Version     :
// Copyright   : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================

#include <iostream>
#include <cctype>
#include <string>
#include<algorithm>
using namespace std;
typedef long long ll;
int main() {

	int a,b;
	cin>>a>>b;

	if(a+b>=10){
		cout<<"error"<<endl;
	}else{
		cout<<a+b<<endl;
	}

	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void){
    int N;
    scanf("%d", &N);
    if(N < 100 || N > 999){
        return 0;
    }
    int tmp = N;
    int ans = 0;
    while(tmp > 0){
        if(tmp%10 == 7){
            ans = 1;
        }
        tmp /= 10;
    }
    if(ans == 1){ printf("Yes\n"); }
    else{ printf("No\n"); }
    return 0;
}

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

using namespace std;

typedef struct _Rectangle
{
    int _H;
    int _W;
}Rectangle;

int main()
{
    vector<Rectangle> myRectangle;
    Rectangle rec;
    while(1)
    {
        cin>>rec._H>>rec._W;
        if(rec._H == 0 && rec._W == 0)
            break;
        myRectangle.push_back(rec);
    }

    for(int i = 0;i < myRectangle.size();i++)
    {
        for(int v = 0;v < myRectangle[i]._H;v++)
        {
            for(int h = 0;h < myRectangle[i]._W;h++)
                cout<<"#";
            cout<<endl;
        }
        cout<<endl;
    }
    return 0;
}


Measured memory_bytes: 3176
#include<bits/stdc++.h>
using namespace std;
     
#define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define int long long
#define rep(i,a,b)    for(int i=a;i<b;i++)
#define repn(i,a,b)   for(int i=a;i>=b;i--)
#define F first
#define S second
#define pii pair<int,int>
#define vi vector<int>
#define vii vector<pii>
#define pb push_back
#define mp  make_pair
#define all(v) (v).begin(), (v).end()
#define hell 1000000007  
#define hell2 998244353 

int solve(){
    int n,m,a;
    string s;
    cin>>n>>s;
    m=s[0]-'0';
    rep(i,2,s.size()){
        m=m*10+s[i]-'0';
    }
    a=n*m;
    if(s.size()==4) a=a/100;
    if(s.size()==3) a=a/10;
    cout<<a;

    return 0;
}   
     
signed main(){
    IOS;
    int t=1;
    //cin>>t;
    while(t--){
        solve();
        cout<<"\n";
      // cout<<" * "<<t<<"\n";
    }
//    return 0;
} 

Measured memory_bytes: 3628
#include <bits/stdc++.h>
#define REP(i, N) for (int i=0, i##len=(N); i<i##_len; i++)
#define REPP(i, N) for(int i=1, i##_len=(N); i<=i##_len; i++)
#define P(x) cout << (x)
using ll = long long;
using namespace std;

int a, b, c, m;
int main() {
    cin >> a >> b >> c;
    m = a - b;
    P(max({c-m, 0}));
    return 0;
}


Measured memory_bytes: 256