akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define all(v) v.begin(), v.end()
using ll = long long;
auto chmin = [](auto&& a, auto b){ if (a > b) {a = b; return true;} return false; };
auto chmax = [](auto&& a, auto b){ if (a < b) {a = b; return true;} return false; };
 
template < typename Container, typename Value = typename Container::value_type, std::enable_if_t<!std::is_same< Container, std::string >::value, std::nullptr_t> = nullptr>
std::istream& operator>> (std::istream& is, Container& v)
    { for (auto & x : v) { is >> x; } return is; }
 
template < typename Container, typename Value = typename Container::value_type, std::enable_if_t<!std::is_same< Container, std::string >::value, std::nullptr_t> = nullptr >
std::ostream& operator<< (std::ostream& os, Container const& v) {
 os << "{";
    for (auto it = v.begin(); it != v.end(); it++)
        {os << (it != v.begin() ? "," : "") << *it;}
    return os << "}";
}
 
int main() {
    std::cin.tie(0); std::cin.sync_with_stdio(false);
    int n; 
    cin >> n;
    vector<int> a(n);
    cin>>a;
    sort(all(a));
    // aの末尾のイテレータ==重複を除いた範囲の、末尾の次を指すイテレータ
    cout << ((a.end()==unique(all(a)))?"YES":"NO") << endl; 
    return 0;
}


Measured memory_bytes: 3968
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func main() {
	s := wordScanner(100)
	_, a := scanNAndIntSlice(s)

	var t float64
	for _, ai := range a {
		b := 1.0 / float64(ai)
		t += b
	}

	fmt.Println(1.0 / t)
}

func wordScanner(n int) *bufio.Scanner {
	s := bufio.NewScanner(os.Stdin)
	s.Split(bufio.ScanWords)
	b := make([]byte, n)
	s.Buffer(b, n)
	return s
}

func scanNAndIntSlice(s *bufio.Scanner) (int, []int) {
	s.Scan()
	n, _ := strconv.Atoi(s.Text())
	return n, scanIntSlice(s, n)
}

func scanIntSlice(s *bufio.Scanner, n int) []int {
	vals := make([]int, n)
	for i := range vals {
		s.Scan()
		m, _ := strconv.Atoi(s.Text())
		vals[i] = m
	}
	return vals
}


Measured memory_bytes: 640
/**
SXR0aXAkI0JwbXptI3FhI3Z3I293bCNqY2IjUG0jMCNicG0jVHFkcXZvLyNCcG0jQW10bjBhY2phcWFicXZvLyNNYm16dml0MSNWdyNhdGN1am16I2tpdiNhbXF9bSNQcXUjVnd6I0F0bW14MSNQcWEjaXptI2l0dCNicHF2b2EjUXYjYnBtI3BtaWRtdmEjaXZsI3d2I21pemJwMSNFcHcjcWEjYnBtem0ja2l2I3F2Ym16a21sbSNRdiNQcWEjeHptYW12a20jbXtrbXhiI0lhI3BtI3htenVxYmJtYnBHI1BtI3N2d2VtYnAjRXBpYiMraXh4bWl6bWJwI2J3I1BxYSNrem1pYmN6bWEjSWEsI0ptbnd6bSN3eiNJbmJteiN3eiNKbXBxdmwjYnBtdTEjVnd6I2FwaXR0I2JwbXwja3d1eGlhYSNJY29wYiN3biNwcWEjc3Z3ZXRtbG9tI017a214YiNpYSNQbSNlcXR0bWJwMSNQcWEjYnB6d3ZtI2x3YnAjbXtibXZsI1dkbXojYnBtI3BtaWRtdmEjSXZsI3d2I21pemJwLyNpdmwjUG0jbm1tdG1icCNWdyNuaWJxb2NtI3F2I29jaXpscXZvI0l2bCN4em1hbXpkcXZvI2JwbXUvI053eiNQbSNxYSNicG0jVXdhYiNQcW9wMSNCcG0jQWN4em11bSMrcXYjb3R3enwsMQ==
*/
#include <cstring>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <queue>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cassert>

#define F first
#define S second
#define endl '\n'
#define deb(x) cout<<#x<<' '<<x<<endl;
#define pb push_back

/*
#ifdef IZI_KATKA
#define int __int64_t
#else
#define int __int64
#endif
*/

const long long MOD = 1e9 + 7;
const long long MAXN = 1e6 + 1;
using namespace std;

typedef long long ll;

long long readInt() {
    bool minus1 = false;
    long long result = 0;
    char ch;
    ch = getchar();
    while (true) {
        if (ch == '-') break;
        if (ch >= '0' && ch <= '9') break;
        ch = getchar();
    }
    if (ch == '-') minus1 = true; else result = ch-'0';
    while (true) {
        ch = getchar();
        if (ch < '0' || ch > '9') break;
        result = result*10 + (ch - '0');
    }
    if (minus1)
        return -result;
    else
        return result;
}


int main() {
	#ifdef IZI_KATKA
	assert(freopen("input", "r", stdin));
    assert(freopen("output", "w", stdout));
    #endif
    string s;
    cin >> s;
	int n = s.size();
	s = '@' + s;
	int ans = n;
	set <int> v;
	for (int i = 1; i <= n;i++) {
		if (s[i] == 'T') {
			v.insert(i);
		}
	}
	for (int i = 1; i <= n; i++) {
		if (s[i] == 'S') {
			if (v.size() > 0) {
				ans -= 2;
				//used[*v.begin()] = 1;
				v.erase(v.begin());
			}
		} else {
			if (v.find(i) != v.end()) {
				v.erase(i);
			}
		}		
	}
	cout << ans;
    return 0;
}

Measured memory_bytes: 5184
s = list(str(input()))
ln = []
for i in range(len(s)):
    if s[i] == '0':
        ln.append(s[i])
    if s[i] == '1':
        ln.append(s[i])
    if s[i] == 'B':
        if len(ln) != 0:
            ln.pop()
print(''.join(ln))

Measured memory_bytes: 3060
package main

import (
	"bufio"
	"container/heap"
	"fmt"
	"os"
	"strconv"
)

var sc, wr = bufio.NewScanner(os.Stdin), bufio.NewWriter(os.Stdout)

func scanString() string   { sc.Scan(); return sc.Text() }
func scanRunes() []rune    { return []rune(scanString()) }
func scanInt() int         { a, _ := strconv.Atoi(scanString()); return a }
func scanInt64() int64     { a, _ := strconv.ParseInt(scanString(), 10, 64); return a }
func scanFloat64() float64 { a, _ := strconv.ParseFloat(scanString(), 64); return a }

func scanInts(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ {
		res[i] = scanInt()
	}
	return res
}

func debug(a ...interface{}) { fmt.Fprintln(os.Stderr, a...) }

func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}
func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}
func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

//•*¨*•.¸¸♪main•*¨*•.¸¸♪(　-ω-)ノ　(　・ω・)
func main() {
	defer wr.Flush()
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 10000), 1001001)

	h, w := scanInt(), scanInt()
	bit := binaryIndexedTreeInit(w)
	for i := 0; i < w; i++ {
		bit.add(i, 1)
	}

	dp := make([]int, w)
	pq := &pqAsc{}
	for i := 0; i < w; i++ {
		heap.Push(pq, pair{0, i})
	}

	for i := 0; i < h; i++ {
		a, b := scanInt()-1, scanInt()-1

		if b+1 != w && dp[b+1] == -1 {
			s := bit.sum(b + 1)
			if s != 0 {
				k := bit.lowerbound(s)
				dp[b+1] = b + 1 - k + dp[k]
				bit.add(b+1, 1)
				heap.Push(pq, pair{dp[b+1], b + 1})
			}
		}

		s := bit.sum(a-1) + 1
		for {
			k := bit.lowerbound(s)
			if k > b {
				break
			}
			bit.add(k, -1)
			dp[k] = -1
		}

		for len(*pq) != 0 && dp[(*pq)[0].b] != (*pq)[0].a {
			heap.Pop(pq)
		}

		if len(*pq) == 0 {
			fmt.Fprintln(wr, -1)
		} else {
			fmt.Fprintln(wr, (*pq)[0].a+i+1)
		}
	}

}

type binaryIndexedTree []int

func binaryIndexedTreeInit(n int) binaryIndexedTree {
	return make(binaryIndexedTree, n+1)
}

func (t binaryIndexedTree) sum(i int) (s int) {
	for i++; i > 0; i -= i & -i {
		s += t[i]
	}
	return
}
func (t binaryIndexedTree) add(i, x int) {
	for i++; i < len(t) && i > 0; i += i & -i {
		t[i] += x
	}
}

func (t binaryIndexedTree) lowerbound(x int) int {
	idx, k := 0, 1
	for k < len(t) {
		k <<= 1
	}
	for k >>= 1; k > 0; k >>= 1 {
		if idx+k < len(t) && t[idx+k] < x {
			x -= t[idx+k]
			idx += k
		}
	}
	return idx
}

type pair struct{ a, b int }

type pqAsc []pair

func (pq pqAsc) Len() int            { return len(pq) }
func (pq pqAsc) Swap(i, j int)       { pq[i], pq[j] = pq[j], pq[i] }
func (pq pqAsc) Less(i, j int) bool  { return pq[i].a < pq[j].a }
func (pq *pqAsc) Push(x interface{}) { *pq = append(*pq, x.(pair)) }
func (pq *pqAsc) Pop() interface{} {
	x := (*pq)[len(*pq)-1]
	*pq = (*pq)[0 : len(*pq)-1]
	return x
}


Measured memory_bytes: 23072
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0, i##_len = (n); i < i##_len; i++)
#define reps(i, s, n) for(ll i = (s), i##_len = (n); i < i##_len; i++)
#define rrep(i, n) for(ll i = (n) - 1; i >= 0; i--)
#define rreps(i, e, n) for(ll i = (n) - 1; i >= (e); i--)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) ((ll)(x).size())
#define len(x) ((ll)(x).length())
#define endl "\n"
template<class T> void chmax(T &a, const T b){ a = max(a, b); }
template<class T> void chmin(T &a, const T b){ a = min(a, b); }

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    // ifstream in("input.txt");
    // cin.rdbuf(in.rdbuf());
    const ll inf = LONG_LONG_MAX / 2 - 1;
    ll n, m;
    cin >> n >> m;
    vector<ll> dp(1 << n, inf);
    dp[0] = 0;
    rep(i, m) {
        ll a, b;
        cin >> a >> b;
        vector<ll> c(b);
        rep(j, b) cin >> c[j];
        rep(bit, 1 << n) {
            if (dp[bit] == inf) continue;
            ll nb = bit;
            rep(j, b) nb |= 1 << (c[j] - 1);
            chmin(dp[nb], dp[bit] + a);
        }
    }
    cout << ((dp[(1 << n) - 1] == inf) ? -1 : dp[(1 << n) - 1]) << endl;
    return 0;
}


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

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

  if ((N[0] == N[1] && N[0] == N[2]) || (N[1] == N[2] && N[2] == N[3])){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
}

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

int main() {
  int n, a, b;
  int x = 0;
  cin >> n >> a >> b;
  if (n*a<b) {
    x = n*a;
  } else {
    x = b;
  }
  cout << x << endl;
}

Measured memory_bytes: 3560
#include <algorithm>
#include <bits/stdc++.h>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
using namespace std;

#define rep(X, S, E) for (int(X) = (S); (X) < (E); ++(X))
#define rrep(X, S, E) for (int(X) = (E)-1; (X) >= (S); --(X))
#define itrep(X, Y) for (auto(X) = (Y).begin(); (X) != (Y).end(); (X)++)
#define all(X) (X).begin(), (X).end()
#define sortDecending(X) sort(all(X), greater<ll>()) //降順
#define sortAscending(X) sort(all(X))                //昇順
#define pb push_back
#define mp make_pair
#define fi first
#define sc second
#define print(x) cout << x << endl
#define printDouble(x) cout << fixed << setprecision(13) << x << endl
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<bool> vb;
typedef priority_queue<ll, vl> decendingQueue;              //降順
typedef priority_queue<ll, vl, greater<ll>> ascendingQueue; //昇順
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
const ll INF = 9 * 1e18;
const ll MOD = 1e9 + 7;

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

  multiset<ll> less; // 中央値以下の値. less.size() >= more.size()
  multiset<ll> more; // 中央値より大きい値
  ll fx = 0;

  rep(i, 0, Q) {
    int q;
    cin >> q;

    if (q == 1) {
      // 更新
      int a, b;
      cin >> a >> b;

      fx += b;
      if (less.size() == 0) {
        less.insert(a);
        continue;
      } else {
        fx += abs(*--less.end() - a);
      }

      ll lessv = *--less.end(); // 中央値
      if (lessv < a) {
        more.insert(a);
        if (more.size() > less.size()) {
          ll morev = *more.begin();
          less.insert(morev);
          more.erase(more.lower_bound(morev));
        }
      } else {
        less.insert(a);
        if (less.size() > more.size() + 1) {
          more.insert(lessv);
          less.erase(less.lower_bound(lessv));
        }
      }

      ll lessv_new = *--less.end();
      fx += abs(lessv_new - lessv) * (more.size() - less.size());
    } else {
      // 求値
      print(*--less.end() << " " << fx);
    }
  }
  return 0;
}


Measured memory_bytes: 9600
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <string>

using ll = long long;

using namespace std;

#define MAX 50100

using P = pair<int, int>;
#define fi first
#define se second

#define amax(a, b) (a = (a < b ? b : a))

#define INF 1000000

int main() {
    while (true) {
        int n;
        cin >> n;
        if (n == 0) break;
        int p[n]; for (auto &pi:p) {
            cin >> pi;
        }
        P dp[n+1][MAX];
        fill(dp[0], dp[n+1], P{-INF, -INF});
        dp[0][0] = P{0, 0};
        for (int i=0; i<n; i++) {
            for (int j=0; j<MAX; j++) {
                amax(dp[i+1][j], dp[i][j]);
                if (j >= (p[i] + 500) % 1000)
                    amax(dp[i+1][j - ((p[i] + 500) % 1000)], P(dp[i][j].fi + 1, dp[i][j].se - p[i]));
                int change = 1000 - ((p[i] - 1) % 1000 + 1);
                if (j + change % 500 <= MAX)
                    amax(dp[i+1][j + change % 500], P(dp[i][j].fi + change / 500, dp[i][j].se - p[i]));
                // if (j % 100 == 0 && j < 1000)
                //     cerr << i << ' ' << j << ' ' << dp[i][j].fi << ' ' << dp[i][j].se << ' ' << (p[i] + 500) % 1000 << '\n';
            }
        }
        P ans = {0, -INF};
        for (auto &di:dp[n]) amax(ans, di);
        cout << ans.fi << ' ' << -ans.se << '\n';
    }
    return 0;
}


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

int main(){
    rep(i,9){
        rep(j,9){
            cout << i+1 << "x" << j+1 << "=" << (i+1) * (j+1) << endl;
        }
    }
}


Measured memory_bytes: 3096
#include <bits/stdc++.h>
#define rep(i, a, n) for (int i = (int)(a); i <= (int)(n); ++i)
#define rrep(i, a, n) for (int i = (int)(a); i >= (int)(n); --i)
#define debug(x) cerr << #x << " = " << x << "\n"
#define debugv(x) \
  rep(f, 0, (x.size() - 1)) cerr << x[f] << (f == (x.size() - 1) ? "\n" : " ")
#define debug2(x, y)                       \
  cerr << "(" << #x << "," << #y << ") = " \
       << "(" << x << "," << y << ")\n"
#define all(x) x.begin(), x.end()
#define each(a, x) for (auto &a : (x))
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define int long long
#define yn(x) puts((x ? "Yes" : "No"))
using namespace std;
using pii = pair<int, int>;
using vi = vector<int>;
const int MX = 1e5 + 5, INF = 5LL << 57;
const int MAX = 2 * (1e6 + 5);
const int MOD = 998244353;
long long fac[MAX], finv[MAX], inv[MAX];
void com_init()
{
  fac[0] = fac[1] = 1;
  finv[0] = finv[1] = 1;
  inv[1] = 1;
  for (int i = 2; i < MAX; i++)
  {
    fac[i] = fac[i - 1] * i % MOD;
    inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
    finv[i] = finv[i - 1] * inv[i] % MOD;
  }
}

long long com(int n, int k)
{
  if (n < k)
  {
    return 0;
  }
  if (n < 0 || k < 0)
  {
    return 0;
  }
  return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
long long pow_mod(long long a, long long b)
{
  long long ans = 1;
  long long mul = a;
  for (; b; mul = (mul * mul) % MOD)
  {
    if ((b & 1) == 1)
      ans = (ans * mul) % MOD;
    b >>= 1;
  }
  return ans;
}
int N, M, K;
void input()
{
  cin >> N >> M >> K;
  ;
  ;
}
void solve()
{
  int ans = 0;
  rep(k, 0, K)
  {
    int cm = com(N - 1, k) * M % MOD;
    int left = N - k - 1;
    int p = pow_mod(M - 1, left);
    cm *= p;
    cm %= MOD;
    ans += cm;
    ans %= MOD;
  }
  cout << ans << endl;

  // int cm = com(N - 1, K);
  // debug(cm);
  // int left = N - K;
  // int mm = (left + 1) / 2;
  // int m1 = left / 2;
  // int ans = cm;
  // int aaa = pow_mod(M, mm);
  // debug(aaa);
  // int bbb = pow_mod(M - 1, m1);
  // debug(bbb);

  // ans *= aaa;
  // ans %= MOD;
  // ans *= bbb;
  // ans %= MOD;
  // cout << ans << endl;

  ;
  ;
}
signed main()
{
  com_init();
  cout << setprecision(12);
  input();
  solve();
  return 0;
}

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

int main() {
    set<ll> num;
    ll t = 1;
    while(t<ll(1e9)+5){
        t*=2;
        num.insert(t);
    }
    ll N;
    cin >> N;
    map<ll,ll> mp;
    vector<ll> A(N);
    for(int i=0;i<N;i++){
        cin >> A[i];
        mp[A[i]]++;
    }
    sort(A.rbegin(),A.rend());
    ll ans =0;
    for(int i=0;i<N;i++){
        if(mp[A[i]] ==0){
            continue;
        }
        ll n = A[i];
        ll t = *num.upper_bound(n);
        t-=n;
        mp[n]--;
        if(mp.find(t) == mp.end()|| mp[t] ==0){
            continue;
        }
        ans++;
        mp[t]--;
    }
   
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 17236
import sys
def input():return sys.stdin.readline()[:-1]
def N(): return int(input())
def NM():return map(int,input().split())
def L():return list(NM())
def LN(n):return [N() for i in range(n)]
def LL(n):return [L() for i in range(n)]
def Yes(x):print("Yes")if x==True else print("No")

D=N()
c=[0]+L()
s=[[0]*27]+[[0]+L() for i in range(D)]

dp=[]
T=[0]
for i in range(1,D+1):
    ma=0
    t=0
    for j in range(1,27):
        if s[i][j]>ma:
            ma=s[i][j]
            t=j
    T.append(t)
        
sc=sum(c)
def point():
    ld=[0]*(27)
    score=-sc*((D+1)*D//2)
    for i in range(1,D+1):
        t=T[i]
        score+=s[i][t]+(i-ld[t])*(D-i+1)*c[t]
        ld[t]=i
    return score


now=point()
import random
for i in range(1000):
    d,q=random.randrange(1,D+1),random.randrange(1,27)
    old=T[d]
    T[d]=q
    new=point()
    if new>now:
        now=new
    else:
        T[d]=old
for i in T[1:]:
    print(i)

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

int main() {
  while(1) {
    int n,m,q;
    cin >> n >> m>> q;
    if(n==0 && m==0 && q==0) break;
    int flg[37][1001]  = {};
    bool a[1001]={};
    int b[1001];
    while(q--) {
      char t;
      for(int i=0;i<n;i++) {
	cin >> t;
	if(t =='1') a[i] = (a[i]+1)%2;
      }
      for(int i=0;i<m;i++) cin>>t ,b[i] = t-'0';
     
      for(int i=0;i<n;i++)
	for(int j=0;j<m;j++){
	  if(flg[i][j] == -1) continue;
	  if(a[i] == 1 && b[j] == 1) flg[i][j] = 1;
	  else if(a[i]==1 && b[j] == 0) flg[i][j] = -1;
	  else if(a[i] == 0 && b[j] == 1) flg[i][j] = -1;
	}

     }
   
      int ans[1001] = {};
      for(int i=0;i<m;i++) ans[i] = -1;  
      for(int i=0;i<n;i++)
	for(int j=0;j<m;j++){
	  if(flg[i][j] == -1) continue;
	  if(ans[j] != -1) ans[j] = -2;
	  else ans[j] = i;
	}
      
      for(int i=0;i<m;i++){
	char ch = 'A'+(ans[i]-10);
	if(ans[i]==-2) cout <<"?";
	else if(ans[i] > 9) cout << ch ;
	else cout << ans[i];
      }
      cout << endl;
  }
  return 0;
}  

Measured memory_bytes: 1320
#include <bits/stdc++.h>
#define MOD 1000000007
#define Nmax 2004
#define pii pair<int,int>
using namespace std;

int a,b,c,nr,mat[Nmax][Nmax],S[Nmax][Nmax],L[Nmax][Nmax],C[Nmax][Nmax],x,y,x2,y2,n,m;
char s[Nmax][Nmax];

int main()
{
    cin >> n >> m >> c;
    for (int i=1;i<=n;i++){
        cin >> s[i] + 1;
        for (int j=1;j<=m;j++){
            mat[i][j] = (s[i][j] == '1');
        }
    }

    for (int i=1;i<=n;i++){
        for (int j=1;j<=m;j++){
            S[i][j] = S[i-1][j] + S[i][j-1] - S[i-1][j-1] + mat[i][j];
            int A = 0, B = 0;
            if (mat[i][j] == 1 && mat[i][j-1] == 1) A = 1;
            if (mat[i][j] == 1 && mat[i-1][j] == 1) B = 1;
            L[i][j] = L[i-1][j] + L[i][j-1] - L[i-1][j-1] + A;
            C[i][j] = C[i-1][j] + C[i][j-1] - C[i-1][j-1] + B;
        }
    }

    for (int i=1;i<=c;i++){
        cin >> x >> y >> x2 >> y2;
        int A = S[x2][y2] - S[x-1][y2] - S[x2][y-1] + S[x-1][y-1];
        y++;
        int B = L[x2][y2] - L[x-1][y2] - L[x2][y-1] + L[x-1][y-1];
        y--;x++;
        B += C[x2][y2] - C[x-1][y2] - C[x2][y-1] + C[x-1][y-1];
        cout << A - B << '\n';
    }

    return 0;
}


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

int main(){
	int height[10];
	for(int i=0; i<10; i++) cin >> height[i];
	sort(height, height+10,greater<int>());
	for(int i=0; i<3; i++){
		cout << height[i] << endl;
	}

    return 0;
}

Measured memory_bytes: 1176
N, M = [int(n) for n in input().split()]

l, r = 1, 10**5
for i in range(M):
    l_, r_ = [int(n) for n in input().split()]
    l = max(l, l_)
    r = min(r, r_)

if l > r:
    print(0)
else:
    print(r-l+1)

Measured memory_bytes: 3060
#define Kafuu signed
#define Chino main

#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <cstring>

#define maxn 500005
#define inf 0x3f3f3f3f
#define pn putchar('\n')
#define px(x) putchar(x)
#define ps putchar(' ')
#define pd printf("======================")
#define pj printf("++++++++++++++++++++++")

using namespace std;

inline int read(){
	int x=0,y=0;
	char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')y=1;ch=getchar();}
	while(ch>='0'&&ch<='9')x=(x<<1)+(x<<3)+(ch^48),ch=getchar();
	return y?-x:x;
}
template<typename T>
inline T read(){
	T x=0;
	int y=0;
	char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')y=1;ch=getchar();}
	while(ch>='0'&&ch<='9')x=(x<<1)+(x<<3)+(ch^48),ch=getchar();
	return y?-x:x;
}
int pos[maxn],f[maxn],a[maxn];
Kafuu Chino(){
	int n=read();
	pos[0]=read();
	for(register int i=1;i<=n;++i){
		a[i]=read();
		if(a[i]<=pos[i-1])pos[i]=pos[i-1]-a[i];
		else if(a[i]>pos[i-1]&&a[i]<pos[i-1]<<1)pos[i]=a[i]-pos[i-1];
		else pos[i]=pos[i-1];
	}
	f[n+1]=1;
	for(register int i=n;i;--i){
		f[i]=f[i+1]+a[i];
		if(a[i]>f[i+1]<<1)f[i]=min(f[i],a[i]-f[i+1]);
		if(a[i]>=f[i+1]<<1)f[i]=f[i+1];
	}
	int t=read();
	while(t--)n=read(),puts(pos[n-1]>=f[n+1]?"YES":"NO");
}


Measured memory_bytes: 7808
#include <bits/stdc++.h>
using namespace std;
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
	int a,b,c,n,v,count=0,sum=0,flag=0;
	string s;
	vector<int> ve(10000,0);
	cin>>s;
	if(s[0]=='S'){
	   cout<<"Cloudy"<<'\n';
	}
	if(s[0]=='C'){
	    cout<<"Rainy"<<'\n';
	}
	if(s[0]=='R'){
	       cout<<"Sunny"<<'\n';
	}
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define lop(i,n,a) for(int i=0;i<n;i+=a)
#define rep(i,n,a) for(int i=a;i<n;i++)
#define inarr(arr,n) lop(i,n,1)cin>>arr[i]
#define ll long long int
#define pb push_back
#define all(v) v.begin(),v.end()
#define endl "\n"
#define eb emplace_back
#define fr first
#define sc second
#define pii pair<int,int>
#define IOS ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define ret return 0
#define pi 3.1415926536
#define hell 1000000007
using namespace std;
// syntax for min priority_queue of pairs
// priority_queue<pair<ll,ll>,vector<pair<ll,int>>,greater<pair<ll,int>>> q;
int solve(){
  int n;cin>>n;
  map<int,int> mp;
  int arr[n];
  lop(i,n,1){
      int t;cin>>t;
      mp[t]++;
      arr[i]=t;
  }
  if(mp[1]==0){
      cout<<-1<<endl;
  }
  else{
      int sum=0;
      int j=1;
      for(int i=0;i<n;i++){
         if(arr[i]==j)sum++,j++;
         
      }
      cout<<n-sum<<endl;
  }
  ret;
}
int main(){
    IOS;
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    int t=1;//cin>>t;
    while(t--){
        solve();
    }
    ret;
}
 


Measured memory_bytes: 10368
const input = require('fs').readFileSync('/dev/stdin', 'utf8');

const n: number = Number(input.split("\n")[0].split(" "));
const h: number[] = input.split("\n")[1].split(" ").map(Number);

let count = 0;
let top = 0;
for(let i=0; i<n; i++){
 if(h[i]>=top){ top = h[i]; count = count+1; }
}
console.log(count);

Measured memory_bytes: 9420
#include <bits/stdc++.h>
using namespace std;
int main(){
  string s;
  cin>>s;
  sort(s.begin(),s.end());
  if(s[0]=='a' and s[1]=='b' and s[2]=='c'){
    cout<<"Yes"<<endl;
  }
  else{
    cout<<"No"<<endl;
  }
  return 0;
}

Measured memory_bytes: 256
from collections import deque

q = deque([1,2,3,4,5,6,7,8,9])
cnt = 0
l = []
used = set()

while cnt<100000:
    p = q.popleft()
    if p in used:continue
    used.add(p)
    l.append(p)
    cnt += 1
    for i in range(max((p%10)-1,0), min((p%10)+1, 9)+1):
        q.append(10*p+i)

N = int(input())
print(l[N-1])

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

using namespace std;

using ll = long long;
using ld = long double;

#define mp make_pair

const int p = 999983;


int mul(int a, int b) {
    return (1LL * a * b) % p;
}

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

int sub(int a, int b) {
    int s = (a+p-b);
    if (s>=p) s-=p;
    return s;
}

int po(int a, int deg)
{
    if (deg==0) return 1;
    if (deg%2==1) return mul(a, po(a, deg-1));
    int t = po(a, deg/2);
    return mul(t, t);
}

int inv(int n)
{
    return po(n, p-2);
}


mt19937 rnd(time(0));

/*struct DSU {
    vector<int> sz;
    vector<int> parent;

    void make_set(int v) {
        parent[v] = v;
        sz[v] = 1;
    }

    int find_set(int v) {
        if (v == parent[v])
            return v;
        return parent[v] = find_set(parent[v]);
    }

    void union_sets(int a, int b) {
        a = find_set(a);
        b = find_set(b);
        if (a != b) {
            if (sz[a] < sz[b])
                swap(a, b);
            parent[b] = a;
            sz[a] += sz[b];
        }
    }

    DSU(int n) {
        sz.resize(n);
        parent.resize(n);
        for (int i = 0; i < n; i++) make_set(i);
    }
};*/

/*
const int N = 1200000;

vector<int> facs(N), invfacs(N);

void init()
{
    facs[0] = 1;
    for (int i = 1; i<N; i++) facs[i] = mul(facs[i-1], i);
    invfacs[N-1] = inv(facs[N-1]);
    for (int i = N-2; i>=0; i--) invfacs[i] = mul(invfacs[i+1], i+1);
}

int C(int n, int k)
{
    if (n<k) return 0;
    return mul(facs[n], mul(invfacs[k], invfacs[n-k]));
}
*/


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

    ll n, a, b;
    cin>>n>>a>>b;
    if (a>b) {cout<<0; return 0;}
    if (n==1)
    {
        if (a==b) cout<<1; else cout<<0;
        return 0;
    }
    cout<<b*(n-1) + a - (a*(n-1) + b) + 1;


}



Measured memory_bytes: 3600
import java.util.Scanner;

public class Main
{
	static long n;
	static int nDigit;
	static int[] nums = { 3, 5, 7 };

	static int memo[][] = new int[30][1000000];

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

		n = sc.nextInt();
		nDigit = String.valueOf(n).length();

		for(int i = 0; i < memo.length; ++i)
		{
			for(int j = 0; j < memo[0].length; ++j)
			{
				memo[i][j] = -1;
			}
		}

		/*
		System.out.println(n);
		System.out.println(nDigit);
		*/
		System.out.println(solve(0, 0, 0, 0));
	}

	private static int solve(long num, int digit, int stat, int bits)
	{
		if(memo[digit][stat] != -1)
		{
			return memo[digit][stat];
		}

		int ret = 0;
		for(int i = 0; i < 3; ++i)
		{
			long nextNum = num * 10 + nums[i];
			int nextBits = bits | (1 << i);

			if(nextNum <= n)
			{
				ret += solve(nextNum, digit + 1, stat * 3 + i, nextBits);
				if(nextBits == 7) {
					++ret;
				}
			}
		}

		return memo[digit][stat] = ret;
	}
}

Measured memory_bytes: 153808
#include <cstdio>
#include <iostream>
#include <cstring>
#include <cstdlib>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <vector>
#include <map>
#include <set>
#include <utility>
#include <algorithm>
#include <cmath>
#include <climits>
#ifdef DEBUG
    #include <ctime>
#endif
using namespace std;

// template

// abbreviations
#define vi vector<int>
#define vl vector<ll>
#define vb vector<bool>
#define vs vector<string>
#define ii pair<int, int>
#define a first
#define b second
#define vii vector<ii>
#define mii map<ii>
#define vvi vector<vi>
#define vvl vector<vl>
#define que queue
#define pque priority_queue
#define stk stack
#define pub push_back
#define pob pop_back
#define puf push_front
#define pof pop_front
#define pu push
#define po pop
#define mp make_pair
#define sz(var) ((int) var.size())
#define rep(it, n) for(int it = 0; it < n; ++it)
#define dep(it, n) for(int it = n - 1; it >= 0; --it)
#define rep1(it, n) for(int it = 1; it <= n; ++it)
#define dep1(it, n) for(int it = n; it > 0; --it)
#define loop(it, from, to) for(int it = (from); it <= (to); ++it)
#define iter(it, cont) for(__typeof((cont).begin()) it = (cont).begin(); it != (cont).end(); ++it)
#define riter(it, cont) for(__typeof((cont).rbegin()) it = (cont).rbegin(); it != (cont).rend(); ++it)
#define all(cont) (cont).begin(), (cont).end()
#define rng(cont, n) cont, cont + n
#define memclr(var) memset(var, 0, sizeof(var))

typedef unsigned long long ull;
typedef long long ll;

const int INF = INT_MAX;
const int NINF = INT_MIN;
const ll INF_LL = LLONG_MAX;
const ll NINF_LL = LLONG_MIN;
const double PI = acos(-1.0);
const int MOD = 1e9 + 7;

#ifdef DEBUG
    #define debug(fmt, args...) printf("Line %d, in %s\t: " fmt, __LINE__, __FUNCTION__, ##args)
    #define rep_rt() printf("[Run time: %.3fs]\n", ((double) clock()) / CLOCKS_PER_SEC)
#else
    #define debug(...)
#endif

// end of template

ll f(ll b, ll n) {
    if (n < b)
        return n;
    return f(b, n / b) + (n % b);
}

int main() {
#ifdef DEBUG
    freopen("arc060_b.in", "r", stdin);
#endif
    
    ll n, s;
    scanf("%lld", &n);
    scanf("%lld", &s);
    if (n == s) {
        printf("%lld\n", n + 1);
        return 0;
    }

    // if b is less or equal than sqrt(n)
    for (ll b = 2; b <= sqrt(n); ++b) {
        if (f(b, n) == s) {
            printf("%lld\n", b);
            return 0;
        }
    }
    vl ods;
    for (ll val = 1; val <= sqrt(n - s); ++val) {
        if ((n - s) % val != 0) {
            continue;
        }
        ll d = val;
        ods.pub((n - s) / val);
        if (f(d + 1, n) == s) {
            printf("%lld\n", d + 1);
            return 0;
        }
    }
    reverse(all(ods));
    iter(val_p, ods) {
        ll od = *val_p;
        debug("%lld\n", od);
        if (f(od + 1, n) == s) {
            printf("%lld\n", od + 1);
            return 0;
        }
    }
    puts("-1");

#ifdef DEBUG
    rep_rt();
#endif
    return 0;
}

Measured memory_bytes: 256
// なんかバケツソートで解くらしい
// 勘違いしてた.Ｋ番目に小さい値らしい
#include <bits/stdc++.h>

using namespace std;

int main() {
    int N;
    long long K;
    cin >> N >> K;

    vector<pair<long long , long long>> list(N);

    for(int i = 0; i < N; ++i) {
        cin >> list[i].first >> list[i].second;
    }

    // aをソートする
    sort(list.begin(), list.end());
    long long sum_b = 0;
    int ans = 0;

    for (int i = 0; i < N; ++i)
    {
        // 何番目の要素
        sum_b += list[i].second;
        // cout << sum_b << endl;
        if(K <= sum_b) {
            ans = list[i].first;
            cout << ans << endl;
            return 0;
        }
    }
}

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

using lint = long long int;
using pint = pair<int, int>;
using plint = pair<lint, lint>;
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((lint)(x).size())
#define POW2(n) (1LL << (n))
#define FOR(i, begin, end) for (int i = (begin), i##_end_ = (end); i < i##_end_; i++)
#define IFOR(i, begin, end) for (int i = (end)-1, i##_begin_ = (begin); i >= i##_begin_; i--)
#define REP(i, n) FOR(i, 0, n)
#define IREP(i, n) IFOR(i, 0, n)
#ifdef LOCAL
#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
#define eprintf(...) 42
#endif

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

    string s;
    cin >> s;
    
    if(s[2]==s[3]&&s[4]==s[5]){
        cout << "Yes" << "\n";
    }else{
        cout << "No"
             << "\n";
    }

    return 0;
}

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

int main() {
    string s;
    cin >> s;
    bool yes = false;
    if(s[0] != s[1])yes = true;
    if(s[1] != s[2])yes = true;
    if(yes)cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 3580
// Tazoe

#include <iostream>
using namespace std;

int main()
{
	int cntLA = 0;
	int cntLB = 0;
	int cntLC = 0;
	int cntLD = 0;
	int cntRA = 0;
	int cntRB = 0;
	int cntRC = 0;
	int cntRD = 0;

	while(true){
		double L;
		cin >> L;

		if(cin.eof())
			break;

		double R;
		cin >> R;

		if(L>=1.1){
			cntLA++;
		}
		else if(L>=0.6){
			cntLB++;
		}
		else if(L>=0.2){
			cntLC++;
		}
		else{
			cntLD++;
		}

		if(R>=1.1){
			cntRA++;
		}
		else if(R>=0.6){
			cntRB++;
		}
		else if(R>=0.2){
			cntRC++;
		}
		else{
			cntRD++;
		}
	}

	cout << cntLA << ' ' << cntRA << '\n';
	cout << cntLB << ' ' << cntRB << '\n';
	cout << cntLC << ' ' << cntRC << '\n';
	cout << cntLD << ' ' << cntRD << '\n';

	return 0;
}

Measured memory_bytes: 0
#include<iostream>
#include<iomanip>
#include<string>
#include<vector>
#include<algorithm>
#include<utility>
#include<tuple>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<numeric>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>

using namespace std;

using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

#define BIL ((ll)1e9)
#define MOD ((ll)1e9+7)
#define INF (1LL<<60)           //1LL<<63でオーバーフロー
#define inf (1<<29)             //1<<29でオーバーフロー

int main(int argc,char* argv[]){
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout << fixed << setprecision(20);

    int n;
    cin >> n;
    vector<ll> d(n);
    for(auto &x:d){
        cin >> x;
    }
    int m;
    cin >> m;
    vector<ll> t(m);
    for(auto &x:t){
        cin >> x;
    }

    if(n<m){
        cout << "NO" << endl;
        return 0;
    }

    sort(d.begin(),d.end());
    sort(t.begin(),t.end());

    bool ans=true;
    int ncount=0,mcount=0;
    while(mcount<m){
        for(int i=ncount;i<n;i++){
            if(d[i]==t[mcount]){
                ncount=i+1;
                break;
            }else{
                if(i==n-1){
                    ncount=n;
                    ans=false;
                }
            }
        }
        mcount++;
        if(n-ncount==0){
            break;
        }
        if(n-ncount<m-mcount){
            ans=false;
            break;
        }
    }

    if(ans) cout << "YES" << endl;
    else cout << "NO" << endl;

    return 0;
}


Measured memory_bytes: 6368
#include<iostream>
#include<array>
#include<algorithm>

using namespace std;

int main(){
    int n,ans;
    array<int,100000>d = {};
    cin>>n;
    for(int i = 0; i < n; i++){
        cin>>d.at(i);
    }
    sort(d.begin(),d.end());
    ans = d.at(100000 - n / 2) - d.at(99999 - n / 2);
    cout<<ans<<endl;
}

Measured memory_bytes: 768
N=int(input())
count=0
T,X,Y=0,0,0
for i in range(N):
    t,x,y=map(int,input().split())
    if abs(x-X)+abs(y-Y)<=t-T and t%2==(x+y)%2:count+=1
    T,X,Y=t,x,y
print('Yes' if count==N else 'No')

Measured memory_bytes: 3060
#include <iostream>
using namespace std;
#define MOD 1000000007

int main(int argc, const char * argv[]) {
    int N;
    cin>>N;
    
    long s=1,t=1,u=1;
    for(int i=0;i<N;++i){
        s*=10;
        s%=MOD;
        t*=9;
        t%=MOD;
        u*=8;
        u%=MOD;
    }
    int v=(int)((s-2*t+u)%MOD);
    if(v<0){
        v+=MOD;
    }
    cout<<v<<endl;
    
    return 0;
}

Measured memory_bytes: 3120
while True:
    H, W = [int(i) for i in input().split()]
    if H == W == 0:
        break

    for h in range(H):
        for w in range(W):
            if (h + w) % 2 == 0:
                print('#', end='')
            else:
                print('.', end='')

        print()
    print()

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

namespace abc164_c
{
    class Program
    {
        static void Main(string[] args)
        {
            int N = int.Parse(Console.ReadLine());
            string[] S = new string[N];

            for (int i = 0; i < N; i++)
            {
                S[i] = Console.ReadLine();
            }

            Console.WriteLine(S.Distinct().ToArray().Length);
        }
    }
}


Measured memory_bytes: 50048
main(a,b,c,d){
	d=1000;
	for(scanf("%*d");~scanf("%d%d%d",&a,&b,&c)&&d--;puts((a+b-c&&c+b-a&&a+c-b)?"NO":"YES"))a*=a,b*=b,c*=c;
	return 0;
}

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

int selectionSort(int A[],int n){
    int minj, sw=0;
    
    for(int i=0; i<n-1; i++){
        minj = i;
        for(int j=i+1; j<n; j++){
            if(A[j] < A[minj]){
                minj = j;
            }
        }
        swap(A[i], A[minj]);
        if(i != minj) sw++;
    }
    return sw;
}

int main(){
    int A[100], sw, n;
    cin >> n;
    
    for(int i=0; i<n; i++)
        cin >> A[i];
    
    sw = selectionSort(A, n);
    
    for(int i=0; i<n; i++){
        if(i) cout << ' ';
        cout << A[i];
    }
    
    cout << endl;
    cout << sw << endl;
}

Measured memory_bytes: 3096
// AtCoder165 C

#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <math.h>
#include <assert.h>
#include <string.h>
#include <memory.h>
#include <malloc.h>
#include <stdlib.h>

// qsortで用いる比較用関数．*a<*bならaが先になる．
int compare(const void* a, const void* b) {
    return *(int*)a - *(int*)b;
}

int main() {
    int i,j;
    int n;
    double x_ceil,x_floor;
    
    scanf("%d", &n);

    x_ceil = ceil(n / 1.08);
    x_floor = floor(n/1.08);

    if((int)(x_ceil * 1.08)==n){
        printf("%d", (int)x_ceil);
    }else if((int)(x_floor * 1.08) == n){
        printf("%d", (int)x_floor);
    }else{
        printf(":(");
    }


    
    return 0;
}

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

using namespace std;
using ll = long long;
using ld = long double;
using ull = unsigned long long;
#define all(x) x.begin(), x.end()

template <typename T1, typename T2> inline void chkmin(T1 &x, const T2 & y) {if (x > y) x = y;}
template <typename T1, typename T2> inline void chkmax(T1 &x, const T2 & y) {if (x < y) x = y;}

string s;

void read() {
	cin >> s;
	for (auto i : s) {
		if (i == '?') {
			cout << "D";
		} else {
			cout << i;
		}
	}
}

void run() {

}

void write() {

}

signed main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	read();
	run();
	write();
	return 0;
}

Measured memory_bytes: 3788
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <bitset>
#include <math.h>
#include <iomanip>
#include <queue>
#define inp(X) cin >> X
#define out(X) cout << X << endl
#define rep(i,n) for(int i=0;i<n;i++ )
#define rep2(i,f,n) for(int i=f;i<n;i++ )
#define SORT(A) sort(A.begin(),A.end())
using namespace std;

typedef long long int ll;
#define MOD 1000000007
#define INF 1000000001

int mem(vector<int> &dp, int i, int N, vector<int> S)
{
	if(dp[i]!=INF) return dp[i];
	int ret = INF;
	if(i<=N-2) ret = min(ret,mem(dp,i+1,N,S));
	if(i<=N-3) ret = min(ret,mem(dp,i+2,N,S));
	if(i<=N-4) ret = min(ret,mem(dp,i+3,N,S));
	if(S[i]==1) ret++;
	return dp[i]=ret;
}

class Key{
	public:
		int value;
		int box=0;
};

ll gcd(ll x, ll y){
	if(y==0) return x;
	return gcd(y,x%y);
}

int main(void) {
	int N; inp(N);
	int M; inp(M);
	vector<Key> keys(M);
	rep(j,M){
		int a; inp(a);
		int b; inp(b);
		keys[j].value = a;
		rep(k,b){
			int c; inp(c);
			keys[j].box |= 1 << --c;
		}
	}
	vector<int> dp(1<<N, INF);
	dp[0]=0;
	rep(i,1<<N){
		rep(j,M){
			dp[i|keys[j].box] = min(dp[i|keys[j].box],dp[i]+keys[j].value);
//			cout << (i|keys[j].box) << endl;
		}
	}

	if(dp[(1<<N)-1] != INF) out(dp[(1<<N)-1]);
	else out(-1);

}




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

int N, L;
string s[110];

int main() {
	cin >> N >> L;
	for (int i = 0; i < N; i++) {
		cin >> s[i];
	}
	sort(s, s + N);
	for (int i = 0; i < N; i++) {
		cout << s[i];
	}
	cout << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
#define cases long long test;cin>>test;while(test--)
#define f_io ios::sync_with_stdio(false); cin.tie(0)
#define foi(a,n) for(long long i=a;i<n;i++)
#define foj(a,n) for(long long j=a;j<n;j++)
#define fok(a,n) for(long long k=a;k<n;k++)
#define ll long long
#define MOD 1000000007
#define INF 1000000000
using namespace std;
//using namespace __gnu_pbds;
//typedef tree<ll,null_type,less<ll>,rb_tree_tag, tree_order_statistics_node_update> indexed_set;


int main()
{
    f_io;
    string s;
    cin >> s;
    if(s=="RRR")
        cout << "3";
    else if(s=="RRS" or s=="SRR")
        cout << "2";
    else if(s=="SSS")
        cout << "0";
    else
        cout << "1";
    return 0;
}


Measured memory_bytes: 3636
import Control.Monad
import Data.List

main = do
  [n, k] <- map read . words <$> getLine
  members <- forM [1..(k::Int)] $ \x -> do
    getLine
    member <- map read . words <$> getLine
    return (member::[Int])
  
  putStrLn $ show $ n - (length $ ans n [] members)

push member current = 
	union member current
  --member ++ ( filter (\x -> (x `elem` member) == False) current)

ans :: Int -> [Int] -> [[Int]] -> [Int]
ans n buffer members
  | xs == [] = push buffer x
  | length buffer == n = buffer
  | otherwise = ans n (push buffer x) xs
  where (x:xs) = members


Measured memory_bytes: 5292
#include <bits/stdc++.h>
using namespace std;using ll=int_fast64_t;using ld=long double;using pll=pair<ll,ll>;using pld=pair<ld,ld>;
const ll INF=1LL<<60;void solve();int main(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(10);solve();}
#define SELECTOR(_1,_2,_3,_4,SELECT,...) SELECT
#define rep(...) SELECTOR(__VA_ARGS__,_rep2,_rep1,_rep0)(__VA_ARGS__)
#define _rep0(i,n) for(ll i=0;i<n;++i)
#define _rep1(i,k,n) for(ll i=k;i<n;++i)
#define _rep2(i,k,n,d) for(ll i=k;d!=0&&d>0?i<n:i>n;i+=d)
#define foreach(i,A) for(auto &i:A)
#define all(A) A.begin(),A.end()
#define len(A) (ll)A.size()
template<class T> vector<T> make_v(size_t a,T b){return vector<T>(a,b);}
template<class... Ts> auto make_v(size_t a,Ts... ts){return vector<decltype(make_v(ts...))>(a,make_v(ts...));}
template<class T> inline bool chmax(T &a,const T &b){if(a<b){a=b; return 1;} return 0;}
template<class T> inline bool chmin(T &a,const T &b){if(a>b){a=b; return 1;} return 0;}

void solve(){
  ll n; cin>>n;
  multiset<ll> S{-1};
  rep(_,1<<n){
    ll s; cin>>s;
    S.insert(s);
  }

  vector<ll> now{*S.rbegin()}; // 初めは最大値から
  rep(_,n){
    auto next=now;
    foreach(v,now){
      auto it=S.lower_bound(v);
      ll s=*(--it);
      if(s==-1){
        cout<<"No"<<"\n";
        return;
      }
      S.erase(it);
      next.push_back(s);
    }
    now=next;
  }
  cout<<"Yes"<<"\n";
}


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

using namespace std;

using i64 = long;

const i64 MOD = 1e9 + 7;
const i64 INF = 1e18 + 7;


signed main(){
    int n;
    cin >> n;
    vector<int> a(n);
    for(auto& x : a)
        cin >> x;
    i64 ans = 0;
    for(int i = 0; i < n; ++i)
        for(int j = i + 1; j < n; ++j)
            ans += a[i] * a[j];
    cout << ans << endl;
}


Measured memory_bytes: 384
n, k = gets.chomp!.split(" ").map!(&:to_i)

# 1回のダイスでロールで勝つパターン
x = n - k + 1 >= 0 ? n - k  + 1 : 0
sum = 0

1.upto(n) do |i|
    j = i
    count = 0
    while j < k
        j *= 2
        count += 1
    end

    #puts "i=#{i} count=#{count}"
    sum += 1.0 / n * (1.0/2) ** count
end

puts sum


Measured memory_bytes: 1788
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i(1);i<=n;i++)
#define fast  ios_base::sync_with_stdio(0); cin.tie(0);
#define pres(x) cout<<fixed; cout<<setprecision(x);
#define open freopen("input.txt","r",stdin) ; freopen("output.txt","w",stdout);
#define watch(x) cout<<(#x)<<" is "<<x<<"\n";
#define out(x) cout<<x<<"\n";
#define mod 1000000007

int main(){
	int a,b;
	cin >> a >> b;
	cout << max(max(a+b,a-b),a*b);
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    int A,B;
    cin>>A>>B;
     
    if(A==B){
        cout<<A+B<<endl;
    }
    else if(A>B){
        cout<<A+(A-1)<<endl;
    }
    else if(A<B){
        cout<<B+(B-1)<<endl;
    }
}


Measured memory_bytes: 256
s = str(input())
if s == 'SUN':
  print(7)
elif s == 'MON':
  print(6)
elif s == 'TUE':
  print(5)
elif s == 'WED':
  print(4)
elif s == 'THU':
  print(3)
elif s == 'FRI':
  print(2)
elif s == 'SAT':
  print(1)

Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
int main(){
	string n;
	cin>>n;
	int x;
	int ans=0;
	for(x=0;x<n.size();x++){
		ans=(ans+(int)(n[x]-'0'))%9;
	}
	if(!ans){
		cout<<"Yes"<<endl;
	}
	else{
		cout<<"No"<<endl;
	}
}

Measured memory_bytes: 3744
def sol(inp=input):
    mod=10**9+7
    n,m=map(int,inp().split())
    invalids=set(int(inp()) for _ in range(m))
    nums=[0 for _ in range(n+1)]
    nums[0]=1
    for i in range(n-1):
        if i+1 not in invalids:
            nums[i+1]+=nums[i]
        if i+2 not in invalids:
            nums[i+2]+=nums[i]
            nums[i+2]%=mod
    return str((nums[n-1]+nums[n])%mod)
print(sol())

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

ll mod_pow(ll x, ll n, ll mod)
{
  ll res = 1;
  while (n > 0)
  {
    if (n & 1)
      res = res * x % mod;
    x = x * x % mod;
    n >>= 1;
  }
  return res;
}

ll MOD = 1000000007;
vector<ll> fact;
vector<ll> ifact;

void mod_ifact(ll n)
{
  fact.resize(n + 1);
  fill(fact.begin(), fact.end(), 1);
  ifact.resize(n + 1);
  fill(ifact.begin(), ifact.end(), 0);
  for (ll i=1; i<n+1; i++)
    fact[i] = fact[i-1] * i % MOD;
  ifact[n] = mod_pow(fact[n], MOD - 2, MOD);
  for (ll i=n; i>0; i--)
    ifact[i-1] = ifact[i] * i % MOD;
}

ll mod_comb(ll n, ll k)
{
  if (k < 0 || k > n)
    return 0;
  return fact[n] * ifact[k] % MOD * ifact[n-k] % MOD;
}

int main()
{
  ll x, y;
  cin >> x >> y;
  ll n = x + y;
  if (n % 3 != 0)
  {
    cout << 0 << endl;
    return 0;
  }
  ll a = (y * 2 - x) / 3;
  ll b = (x * 2 - y) / 3;
  if (a < 0 || b < 0)
  {
    cout << 0 << endl;
    return 0;
  }
  mod_ifact(a + b);
  cout << mod_comb(a + b, a) << endl;
}

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


int main(){
    string S;
    cin >> S;
    int a = 0, b = 0, c = 0;
    for(char s : S){
        if(s == 'a') a++;
        if(s == 'b') b++;
        if(s == 'c') c++;
    }
    int maxi = max(a, max(b, c));
    int mini = min(a, min(b, c));

    if(maxi - mini <= 1){
        cout << "YES" << endl;
    }else{
        cout << "NO" << endl;
    }
    return 0;
}


Measured memory_bytes: 512
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <stack>
#include <queue>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <cmath>

using namespace std;
#define PI 3.1415926535897932384626433832795
#define MOD (1000000007)
#define EPS (1e-15)
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repc(i, s, n) for (int i = (s); i <= (n); i++)
#define rrep(i, n) for (int i = (n) - 1; i >= 0; i--)
#define rrepc(i, s, n) for (int i = (s); i >= (n); i--)
#define bet(x, a, b) (a) <= (x) && (x) < (b)
typedef long long ll;
typedef unsigned long long ull;

int main()
{
	int N, M, s, c, num[4], ans = 0;

	repc(i, 1, 3) num[i] = -1;

	cin >> N >> M;
	rep(i, M) {
		cin >> s >> c;
		if (num[s] == -1) num[s] = c;
		else if (num[s] != c) ans = -1;
	}

	if (num[1] == 0) {
		if (N == 1) cout << 0 << endl;
		else cout << -1 << endl;
		return 0;
	}
	else if (ans == -1) {
		cout << ans << endl;
		return 0;
	}
	else if (N == 1 && num[1] == -1) {
		cout << 0 << endl;
		return 0;
	}

	int w = 1;
	rrepc(i, N, 1) {
		if (num[i] == -1) {
			if (i == 1) num[i] = 1;
			else num[i] = 0;
		}

		ans += num[i] * w;
		w *= 10;
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
namespace doit
{
	inline ll read()
	{
		ll x=0,p=1;
		char c;
		c=getchar();
		while(c<'0'||c>'9')
		{
			if(c=='-')
				p=-1;
			c=getchar();
		}
		while(c>='0'&&c<='9')
		{
			x=x*10+c-'0';
			c=getchar();
		}
		return x*p;
	}
	inline int f(ll n)
	{
		int len=0;
		while(n)
		{
			n/=10;
			len++;
		}
		return len;
	}
	inline void put()
	{
		ll n,ans;
		n=read();
		for(register int i=sqrt(n);i>=1;i--)
			if(n%i==0)
			{
				ans=n/i;
				break;
			}
		std::cout<<f(ans)<<"\n";
	}
}
int main()
{
	ios::sync_with_stdio(false);
	doit::put();
}

Measured memory_bytes: 256