akhauriyash/Code-Regression huggingface dataset:
//C
#include <cassert>
//#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdalign>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>

//ここまで標準include

using namespace std;

long aCb(long a, long b) {
	long out = 1;
	for (long i = 1; i <= b; i++) {
		out = out * (a + 1 - i) / i;
	}
	return out;
}

int main() {
	int N;
	cin >> N;
	vector<string>data(N);
	for (int i = 0; i < N; i++){
		vector<char>c(10);
		for (int j = 0; j < 10; j++) {
			cin >> c.at(j);
		}
		sort(c.begin(), c.end());
		for (int j = 0; j < 10; j++) {
			data.at(i) = data.at(i) + c.at(j);
		}
	}
	sort(data.begin(), data.end());
	long ans = 0;
	for (int i = 0; i < N;) {
		int count = 1;
		string last = data.at(i);
		while (i >= 0) {
			if (i < N - 1 && last == data.at(i + 1)) {
				count++;
				i++;
			}
			else {
				i++;
				break;
			}
		}
		ans += aCb(count, 2);
	}
	cout << ans << endl;
}


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

ll func(ll n, ll x){
    if(n >= 0){
        return n / x + 1;
    } else {
        return 0;
    }
}

int main(void)
{
    ll a, b, x;
    cin >> a >> b >> x;

    ll ans = func(b, x) - func(a-1,x);
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3592
#include <algorithm>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
using namespace std;
typedef long long unsigned int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define rep(i, n) for (int i = 0; i < n; i++)

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

  int red = 0;
  int blue = 0;
  for (char c : s) {
    if (c == 'R') {
      red++;
    } else if (c == 'B') {
      blue++;
    } else {
      cout << "error" << endl;
    }
  }

  if (red > blue) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
  return 0;
}


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

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

    int hun = n / 100;
    int mod = n % 100;

    if(hun * 11 >= mod) ans = hun * 111;
    else ans = (hun + 1) * 111;

    cout << ans;
}

Measured memory_bytes: 256
n,k=map(int,input().split())
ans=[0]*(10**5+1)
for i in range(n):
    a,b=map(int,input().split())
    ans[a]+=b
    
for i in range(len(ans)):
    k-=ans[i]
    if k<=0:
        print(i)
        break

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

int main()
{
	int n,k,sum=0;
	cin>>n>>k;
	vector<int> v;
	for(int i=0;i<n;i++)
	{
		int p;
		cin>>p;
		v.push_back(p);
	}
	sort(v.begin(),v.end());
	for(int i=0;i<k;i++)
	{
		sum = sum + v[i];
	}
	cout<<sum<<endl;

	return 0;
}



Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
#define int long long
signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int grundy = 0;
    int n;
    cin >> n;
    for (int i=0; i < n; i++){
        int a, k;
        cin >> a >> k;
        while (a % k != 0){
            int old = a-a%k;
            int diff = a-old;
            int um = a/k + 1;
            int dl = diff/um;
            if (diff%um==0) a -= dl*um;
            else a -= (dl+1)*um;
        }
        grundy ^= (a/k);
    }
    if (grundy == 0) cout << "Aoki" << endl;
    else cout << "Takahashi" << endl;
    return 0;
}


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

bool func(deque<int> &v, string &t, int num){
    if(v.size() == 1){
        if(num - v.front() == 0){
            t = t + to_string(v.front());
            return true;
        } 
        else return false;
    } 
    int back_val = v.back();
    int num1 = num + back_val;
    int num2 = num - back_val;
    v.pop_back();
    deque<int> v1 = v;
    deque<int> v2 = v;
    if(func(v1, t, num1)){
        t.push_back('-'); 
        t = t + to_string(back_val);
        return true;
    } 
    if(func(v2, t, num2)){
        t.push_back('+');
        t = t + to_string(back_val);
        return true;
    }
    return false;
}

int main(){
    string s, t;
    cin >> s;
    deque<int> v;
    for(unsigned int i=0; i<s.size(); i++) v.push_back((int)s[i] - (int) '0');
    func(v, t, 7);
    t += "=7";
    cout << t << endl;
}

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

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

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

Measured memory_bytes: 256
N = int(input())
A = list(map(int, input().split()))
n_money = 1000
n_stock = 0
for i in range(N-1):
    if A[i+1] > A[i]:
        # buy
        n_buy_stock = n_money // A[i]
        n_stock += n_buy_stock
        n_money = n_money - n_buy_stock * A[i]
    else:
        # sell
        n_money += n_stock * A[i]
        n_stock = 0
n_money += n_stock * A[N-1]
print(n_money)

Measured memory_bytes: 9188
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
using namespace std;
using ll = long long;
using vec = vector<ll>;
using vect = vector<double>;
using Graph = vector<vector<ll>>;
#define loop(i, n) for (ll i = 0; i < n; i++)
#define Loop(i, m, n) for (ll i = m; i < n; i++)
#define pool(i, n) for (ll i = n; i >= 0; i--)
#define Pool(i, m, n) for (ll i = n; i >= m; i--)
#define mod 1000000007ll
#define flagcount __builtin_popcount
#define flag(x) (1 << x)
#define flagadd(bit, x) bit |= flag(x)
#define flagpop(bit, x) bit &= ~flag(x)
#define flagon(bit, i) bit &flag(i)
#define flagoff(bit, i) !(bit & (1 << i))
#define all(v) v.begin(), v.end()
#define low2way(v, x) lower_bound(all(v), x)
#define high2way(v, x) upper_bound(all(v), x)
#define idx_lower(v, x) (distance(v.begin(), low2way(v, x)))  //配列vでx未満の要素数を返す
#define idx_upper(v, x) (distance(v.begin(), high2way(v, x))) //配列vでx以下の要素数を返す
#define idx_lower2(v, x) (v.size() - idx_lower(v, x))         //配列vでx以上の要素数を返す
#define idx_upper2(v, x) (v.size() - idx_upper(v, x))         //配列vでxより大きい要素の数を返す
#define putout(a) cout << a << endl
#define Gput(a, b) G[a].push_back(b)
#define Sum(v) accumulate(all(v), 0ll)
#define gcd(x, y) __gcd(x, y)
ll ctoi(char c)
{
    if (c >= '0' && c <= '9')
    {
        return c - '0';
    }
    return 0;
}
template <typename T>
T lcm(T x, T y)
{
    T z = gcd(x, y);
    return x * y / z;
}
template <typename T>
bool primejudge(T n)
{
    if (n < 2)
        return false;
    else if (n == 2)
        return true;
    else if (n % 2 == 0)
        return false;
    double sqrtn = sqrt(n);
    for (T i = 3; i < sqrtn + 1; i++)
    {
        if (n % i == 0)
        {
            return false;
        }
        i++;
    }
    return true;
}
//場合によって使い分ける
//const ll dx[4]={1,0,-1,0};
//const ll dy[4]={0,1,0,-1};
const ll dx[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll dy[8] = {0, 1, 1, 1, 0, -1, -1, -1};
//2次元配列の宣言
//vector<vector<ll>> field(h, vector<ll>(w));

int main()
{
    cout << fixed << setprecision(30);
    string s, t;
    cin >> s >> t;
    ll ans = 0;
    loop(i, s.size())
    {
        if (s[i] != t[i])
            ans++;
    }
    putout(ans);
    return 0;
}


Measured memory_bytes: 3820
#!/usr/bin/python
# -*- coding: utf-8 -*-
import sys,collections,itertools,re,math,fractions,decimal,random,array,bisect,heapq

# decimal.getcontext().prec = 50
# sys.setrecursionlimit(10000)
# MOD = 10**9 + 7

def solve(f):
    n, k = f.read_int_list()
    if k == 0: return n**2
    ans = 0
    for b in xrange(k+1, n+1):
        ans += (n/b)*(b-k)+max(0,n-((n/b)*b+k)+1)
    return ans


class Reader(object):
    def __init__(self, filename=None):
        self.file = open(filename) if filename is not None else None
        self.case = 1

    def __readline(self):
        return self.file.next().strip() if self.file else raw_input()

    def next_case(self):
        self.file.next()
        self.case += 1

    def read_int(self): return int(self.__readline())
    def read_float(self): return float(self.__readline())
    def read_long(self): return long(self.__readline())
    def read_decimal(self): return decimal.Decimal(self.__readline())
    def read_str(self): return self.__readline()

    def read_int_list(self): return map(int, self.__readline().split())
    def read_float_list(self): return map(float, self.__readline().split())
    def read_long_list(self): return map(long, self.__readline().split())
    def read_decimal_list(self): return map(decimal.Decimal, self.__readline().split())
    def read_str_list(self): return self.__readline().split()

if __name__ == '__main__':
    filename = sys.argv[1] if len(sys.argv) > 1 else None
    f = Reader(filename)
    if f.file:
        while True:
            print "Case #%d\n"%f.case, solve(f)
            try:
                f.next_case()
            except StopIteration:
                break
    else:
        print solve(f)


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

int combi(int x, int y, int z){
    if ( (x == y) )
    {
        if (y < z) return 3;
        else return 1;
    }
    else
    {
        if (y < z) return 6;
        else return 3;
    }
}

int main(){
    int k, s; 
    long long ans = 0;
    cin >> k >> s;

    for (int x = 0; x <= k; x++)
    {
        for (int y = x; y <= k; y++)
        {
            for (int z = y; z <= k; z++)
            {
                if ( (x + y + z) == s )
                {
                    ans += combi(x, y, z);
                }
            }
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
//ITP1-11-C: Dice 3
//2019.05.23

#include <stdio.h>

void throwdice(char, int*);

typedef struct dice_ {
  int d[6];
} dice;

int main(void){
  dice dice1, dice2;
  int judge = 0;

  for (int i = 0; i < 6; i++) scanf("%d", &dice1.d[i]);
  for (int i = 0; i < 6; i++) scanf("%d", &dice2.d[i]);

  for (int i = 0; i < 6; i++) {
    if (dice1.d[0] == dice2.d[i] ) {
      switch (i) {
        case 0:
          break;
        case 1:
          throwdice('N', &dice2.d[0]);
          break;
        case 2:
          throwdice('W', &dice2.d[0]);
          break;
        case 3:
          throwdice('E', &dice2.d[0]);
          break;
        case 4:
          throwdice('S', &dice2.d[0]);
          break;
        case 5:
          throwdice('N', &dice2.d[0]);
          throwdice('N', &dice2.d[0]);
          break;
      }
    }
  }
  for (int i = 1; i < 6; i++) {
    if (dice1.d[1] == dice2.d[i] ) {
      switch (i) {
        case 1:
          break;
        case 2:
          throwdice('R', &dice2.d[0]);
          throwdice('R', &dice2.d[0]);
          throwdice('R', &dice2.d[0]);
          break;
        case 3:
          throwdice('R', &dice2.d[0]);
          break;
        case 4:
          throwdice('R', &dice2.d[0]);
          throwdice('R', &dice2.d[0]);
          break;
        case 5:
          break;
      }
    }
  }

  judge = 1;
  for (int i = 0; i < 6; i++) {
    if (dice1.d[i] != dice2.d[i]) {
      judge = 0;
    }
  }

  if (judge == 1) {
    printf("Yes\n");
  }else if(judge == 0){
    printf("No\n");
  }

  /*d[0] = top
    d[1] = south
    d[2] = east
    d[3] = west
    d[4] = north
    d[5] = bottom */

  return 0;
}

void throwdice(char c, int *d){
  int tmp[6];
  for (int i = 0; i < 6; i++) {
    tmp[i] = d[i];
  }

  if (c == 'N') {
    d[0] = tmp[1]; //top
    d[1] = tmp[5]; //south
    d[2] = tmp[2]; //east
    d[3] = tmp[3]; //west
    d[4] = tmp[0]; //north
    d[5] = tmp[4]; //bottom
  }else if (c == 'E') {
    d[0] = tmp[3]; //top
    d[1] = tmp[1]; //south
    d[2] = tmp[0]; //east
    d[3] = tmp[5]; //west
    d[4] = tmp[4]; //north
    d[5] = tmp[2]; //bottom
  }else if (c == 'W') {
    d[0] = tmp[2]; //top
    d[1] = tmp[1]; //south
    d[2] = tmp[5]; //east
    d[3] = tmp[0]; //west
    d[4] = tmp[4]; //north
    d[5] = tmp[3]; //bottom
  }else if (c == 'S') {
    d[0] = tmp[4]; //top
    d[1] = tmp[0]; //south
    d[2] = tmp[2]; //east
    d[3] = tmp[3]; //west
    d[4] = tmp[5]; //north
    d[5] = tmp[1]; //bottom
  }else if (c == 'R'){
    d[0] = tmp[0]; //top
    d[1] = tmp[3]; //south
    d[2] = tmp[1]; //east
    d[3] = tmp[4]; //west
    d[4] = tmp[2]; //north
    d[5] = tmp[5]; //bottom
  }
}



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

bool graph[705][705];
int color[705];
int n, m;

int count0, count1;
bool feasible;

int candidates[705][2];
int ccnt;

void visit(int x, int c) {
  if (color[x] != -1) {
    if (color[x] != c) feasible = false;
    return;
  }
  color[x] = c;
  if (c == 0) count0++;
  else count1++;
  for (int ni = 1; ni <= n; ni++) {
    if (x != ni && graph[x][ni]) {
      if (color[ni] == -1) visit(ni, 1 - c);
      else if (color[ni] == c) {
        feasible = false;
        return;
      }
    }
  }
}

int main() {
  cin >> n >> m;
  for (int ni = 1; ni <= n; ni++) {
    for (int nj = 1; nj <= n; nj++) {
      graph[ni][nj] = true;
    }
    color[ni] = -1;
  }
  for (int mi = 0; mi < m; mi++) {
    int a, b;
    cin >> a >> b;
    graph[a][b] = graph[b][a] = false;
  }
  feasible = true;
  ccnt = 0;
  for (int ni = 1; ni <= n; ni++) {
    if (color[ni] == -1) {
      count0 = 0;
      count1 = 0;
      visit(ni, 0);
      candidates[ccnt][0] = count0;
      candidates[ccnt][1] = count1;
      ccnt++;
    }
  }
  if (feasible) {
    bool x[2][705];
    for (int i = 0; i < 2; i++) {
      for (int ni = 0; ni <= n; ni++) {
        x[i][ni] = false;
      }
    }
    x[0][0] = true;
    for (int ci = 0; ci < ccnt; ci++) {
      int cur = ci % 2;
      int nxt = 1 - cur;
      for (int ni = 0; ni <= n; ni++) {
        x[nxt][ni] = false;
      }
      for (int ni = 0; ni <= n; ni++) {
        if (x[cur][ni]) {
          x[nxt][ni + candidates[ci][0]] = true;
          x[nxt][ni + candidates[ci][1]] = true;
        }
      }
    }
    int answer = 987654321;
    for (int ni = 0; ni <= n; ni++) {
      if (x[ccnt % 2][ni]) {
        answer = min(answer, ni * (ni - 1) / 2 + (n - ni) * (n - ni - 1) / 2);
      }
    }
    cout << answer << endl;
  } else {
    cout << -1 << endl;
  }
  return 0;
}

Measured memory_bytes: 768
//#include <bits/stdc++.h>
#include <iostream>
#include <complex>
#include <sstream>
#include <string>
#include <algorithm>
#include <deque>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <vector>
#include <set>
#include <limits>
#include <cstdio>
#include <cctype>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <ctime>
#include <climits>
#include <iomanip>
#include <stack>
#include <bitset>

#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define FOR(i, j, k) for(int i = (int)(j); i < (int)(k); ++i)
#define ROF(i, j, k) for(int i = (int)(j); i >= (int)(k); --i)
#define FORLL(i, n, m) for(long long i = n; i < (long long)(m); i++)
#define SORT(v, n) sort(v, v+n)
#define REVERSE(v) reverse((v).begin(), (v).end())

using namespace std;
using ll = long long;
const ll MOD=1000000007LL;
typedef pair<int, int> P;

ll ADD(ll x, ll y) { return (x+y) % MOD; }
ll SUB(ll x, ll y) { return (x-y+MOD) % MOD; }
ll MUL(ll x, ll y) { return x*y % MOD; }
ll POW(ll x, ll e) { ll v=1; for(; e; x=MUL(x,x), e>>=1) if (e&1) v = MUL(v,x); return v; }
ll DIV(ll x, ll y) { /*assert(y%MOD!=0);*/ return MUL(x, POW(y, MOD-2)); }

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(a>b){a=b;return 1;}return 0;}

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

  int n;
  cin >> n;
  vector<int> d(n);
  REP(i,n) cin >> d[i];

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

  cout << d[n/2]-d[n/2-1] << endl;

  //for(auto &e: d) cout << e << endl;

  return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repp(i, a, b) for (int i = a; i <= (b); ++i)
#define repr(i, a, b) for (int i = a; i >= (b); --i)
typedef long long ll;
const int INF = 1001001001;
const ll LINF = 1001001001001001001ll;
const int MOD = 1000000007;

template <class T>
inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}

template <class T>
inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}

int main() {
  vector<string> s(3);
  rep(i, 3) {
    cin >> s[i];
    cout << (char)toupper(s[i][0]);
  }
  cout << endl;
}

Measured memory_bytes: 256
def compute_fact(n):
    global f
    if(n < 2):
        f = [1,1]
    else:
        f = [0 for i in range(n+1)]
        f[0] = 1
        f[1] = 1
        for i in range(2,n+1):
            f[i] = f[i-1]*i

def compute_c(n,r):
    compute_fact(n)
    ans = f[n]/(f[r] * f[n-r])
    return ans

n,m = [int(s) for s in input().split()]
if n >= 2 and m >= 2:
    print(int(compute_c(n,2) + compute_c(m,2)))
elif n >= 2:
    print(int(compute_c(n,2)))
elif m >= 2:
    print(int(compute_c(m,2)))
else:
    print(0)
    

Measured memory_bytes: 3064
//皆さん、第9回シンデレラガール総選挙は、トップでオンリーワンを目指す城ヶ崎美嘉に
//そしてボイスアイドルオーディションは、プログラミングが趣味の才女大石泉に、ぜひ投票をお願いします！
//#城ヶ崎美嘉を009のシンデレラに
//#大石泉の必勝プログラム
#include<vector>
#include<cmath>
#include<map>
#include<cstdlib>
#include<iostream>
#include<sstream>
#include<fstream>
#include<string>
#include<algorithm>
#include<cstring>
#include<cstdio>
#include<set>
#include<stack>
#include<bitset>
#include<functional>
#include<ctime>
#include<queue>
#include<deque>
#include<complex>
#include<cassert>
using namespace std;
#define pb push_back
#define pf push_front
typedef long long lint;
typedef complex<double> P;
#define mp make_pair
#define fi first
#define se second
typedef pair<int,int> pint;
#define All(s) s.begin(),s.end()
#define rAll(s) s.rbegin(),s.rend()
#define REP(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
//問題文および制約はちゃんと確認しよう！
//サイズは10^5じゃなくて2×10^5とかかもしれないし、重要な制約・条件を見落としているかも
//とりあえずサンプルを読んでから解法を考えよう？
lint num[2050];
int main()
{
	string s;cin>>s;int n=s.size(),now=0,bai=1;lint out=0;
	memset(num,0,sizeof(num));num[0]++;
	reverse(All(s));
	rep(i,n){
		//bai*=10;
		now+=(s[i]-'0')*bai;now%=2019;
		out+=num[now];num[now]++;
		bai*=10;bai%=2019;
	}
	cout<<out<<endl;
}


Measured memory_bytes: 3776
s = input()
length = len(s)
ans = 0
for i in range(1 << (length - 1)):
        front = 0
        for j in range(length):
                if 1 << j & i:
                        ans += int(s[front:j + 1])
                        front = j + 1
        ans += int(s[front:length])
print(ans)

Measured memory_bytes: 3060
#include <stdio.h>
#include <stdlib.h>
#define MAX 2000001
#define VMAX 10000

int main() 
{
    unsigned short *A,*B;
    int C[VMAX+1];
    int n,i,j;
    scanf("%d",&n);

    A = malloc(sizeof(short) * n + 1);
    B = malloc(sizeof(short) * n + 1);
    for (i = 0; i <= VMAX; i++) C[i] = 0;
    for (i = 0; i < n; i++) {
        scanf("%hu",&A[i + 1]);
        C[A[i+1]]++;
    }
    for (i = 1; i <= VMAX; i++) C[i] = C[i] + C[i - 1];
    for (j = 1; j <= n; j++) {
        B[C[A[j]]] = A[j];
        C[A[j]]--;
    } 

    for (i = 1; i <= n; i++) {
        if(i > 1) printf(" ");
        printf("%d",B[i]);
    }
    printf("\n");
    return 0;
}


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

#define int long long
#define ffor(i,n) for(int i = 0;i < (n); ++i)
#define all(v) v.begin(),v.end()
#define vi vector<int>
#define vvi vector<vi>
#define pii pair<int,int>
#define vpii vector<pii>
#define ff first
#define ss second


signed main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
	int n;
	cin >> n;
	string s;
	cin >> s;
	vector<set<int>> chr(26);

	ffor(i,n){
		chr[(int)(s[i] - 'a')].insert(i);
	}
	int q;
	cin >> q;
	while(q--){
		int tp;
		cin >> tp;
		if(tp == 1){
			int x;
			char y;
			cin >> x >> y;
			--x;
			chr[(int)(s[x] - 'a')].erase(x);
			s[x] = y;
			chr[(int)(y - 'a')].insert(x);
		}else{
			int ans = 0;
			int l,r;
			cin >> l >> r;
			--l,--r;
			ffor(i,26){
				if(chr[i].empty()) continue;
				auto it = chr[i].lower_bound(l);
				if((it != chr[i].end()) && (*it <= r)){
					ans++;
				}
			}
			cout << ans << '\n';
		}
	}
}		// l = 1 , r = 3
		// 0 4 

Measured memory_bytes: 24220
#include <bits/stdc++.h>
#define ll long long
#define INF INT_MAX 
#define mod 1000000007
using namespace std;
int main(){
    int N;
    cin >> N;
    int X[N],Y[N];
    for(int i=0;i<N;i++){
        cin >> X[i];
        Y[i] = X[i];
    }
    sort(Y,Y+N);
    for(int i=0;i<N;i++){
        if(Y[(N/2)-1]>=X[i]){
            cout << Y[N/2] << endl;
        }else{
            cout << Y[N/2 - 1] << endl;
        }
    }
}

Measured memory_bytes: 3712
#include <iostream>
#include <math.h>
#include <stdio.h>
#include <string>
#include <string.h>
#include <algorithm>
#include <cmath>
#include <limits>
#include <sstream>

using namespace std;

int main (void)
{
	for (long long u = 0; u < 50000; u++)
	{
		long long n,m,a[1001];
		cin >> n >> m;
		if (n == 0 && m == 0)
		{
			break;
		}
		int p = 0;
		int o = 0;

		for (long i = 0; i < n; i++)
		{
			cin >> a[i];
		}

		sort(a,a + n);

		for (int i = 0; i < n; i++)
		{
			for (int j = 1; j < n; j++)
			{
				if (i < j && a[i] + a[j] <= m)
				{
					if (p < a[i] + a[j])
					{
						p = 0;
						p = a[i] + a[j];
					}
				}
				else if (a[i] + a[j] > m)
				{
					break;
				}
			}
			if (p == 0 && i == n - 1)
			{
				cout << "NONE" << endl;
				o = -1;
			}
		}

		if (o != -1)
		{
			cout << p << endl;
		}
	}
}



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

#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define RREP(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define FOR(i,c) for(__typeof((c).begin()) i=(c).begin();i!=(c).end();++i)
#define LET(x,a) __typeof(a) x(a)
//#define IFOR(i,it,c) for(__typeof((c).begin())it=(c).begin();it!=(c).end();++it,++i)
#define ALL(c) (c).begin(), (c).end()
#define MP make_pair

#define EXIST(e,s) ((s).find(e)!=(s).end())

#define RESET(a) memset((a),0,sizeof(a))
#define SET(a) memset((a),-1,sizeof(a))
#define PB push_back
#define DEC(it,command) __typeof(command) it=command

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
#define debug2(x) cerr << #x << " = [";REP(__ind,(x).size()){cerr << (x)[__ind] << ", ";}cerr << "] (L" << __LINE__ << ")" << endl;

const int INF=0x3f3f3f3f;

typedef long long Int;
typedef unsigned long long uInt;
typedef long double rn;

typedef pair<int,int> pii;

/*
#ifdef MYDEBUG
#include"debug.h"
#include"print.h"
#endif
*/
// }}}

int N,T;

int main(){
	cin>>N>>T;
	Int ans = 0;
	int end = 0;
	int prev_t;
	REP(i,N){
		int t;
		cin>>t;
		int u = min(T,t-prev_t);
		if(i>0)ans+=u;
		prev_t = t;
	}
	ans+=T;
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
fun no1(args: Array<String>) {
    val numList = args[1].split(" ").map { it.toInt() }
    val mean = numList.average()
    val diff = numList.map { Math.abs(it - mean) }
    val min = diff.min()
    println(diff.indexOfFirst{ it == min })
}

fun main(args: Array<String>) {
    no1(readLineList())
}

fun readLineList(): Array<String> {
    val lineList = mutableListOf<String>()
    while (true) {
        val line = readLine()
        if (line.isNullOrBlank()) {
            break
        } else {
            lineList.add(line!!)
        }
    }
    return lineList.toTypedArray()
}

Measured memory_bytes: 37904
#include <iostream>                                     
using namespace std;                                    
                                                        
int main() {                                            
  int a, b, c;                                          
  cin >> a >> b >> c;                                   
  int t;                                                
  if (a>b) {                                            
    t = a;                                              
    a = b;                                              
    b = t;                                              
  }                                                     
  if (b>c) {                                            
    t = b;                                              
    b = c;                                              
    c = t;                                              
  }                                                     
  if (a>b) {                                            
    t = a;                                              
    a = b;                                              
    b = t;                                              
  }                                                     
  cout << a << " " << b << " " << c << endl;            
  return 0;                                             
}                                                       

Measured memory_bytes: 3100
#include <bits/stdc++.h>
#define all(a) (a).begin(), (a).end()
#define REP(i, n) for(int (i)=0; (i)<(n); (i)++)
#define RREP(i, n) for(int (i)=(n)-1, (i)>=0; (i)--)
#define ios() cin.tie(0), ios::sync_with_stdio(false)
typedef long long ll;
typedef unsigned long long ull;
ll const MOD = 1e9+7;
ll const INF = 1e18;
using namespace std;

int main(){
    int n;
    string s, t;
    cin >> n >> s >> t;
    int cnt = 0;
    REP(i, s.length()){
        bool judge = true;
        for(int j=0; i+j<min(s.length(), t.length()); j++){
            if(s[i+j] != t[j]){
                judge = false;
                break;
            }
        }
        if(judge){
            break;
        }
        cnt++;
    }
    cout << max(n, (int)max(s.length(), t.length()+cnt)) << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <unordered_map>
#include <ctime>
#include <set>
#include <sstream>
#include <bitset>
#define fi first
#define se second
#define SPEED ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define ll long long
#define all(x) x.begin(), x.end()

using namespace std;
int main () {
    string s;
    cin>>s;
    bool ok = false;
    for (int i = 0; i < 3; i++) {
        if (s[i] == '7') ok = true;
    }
    if (ok) {
        cout<<"Yes";
    }else cout<<"No";
}


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

int main()
{
    int a, b, c, k;
    cin >> a >> b >> c >> k;
    while (b <= a && k--) b *= 2;
    while (c <= b && k--) c *= 2;
    if (k >= 0 && (c > b && b > a)) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

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

using namespace std;

const int MOD = 1000 * 1000 * 1000 + 7;

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

	vector<int> A(N);
	for (auto &x : A) {
		cin >> x;
	}

	vector<long long> v(2010, 0);
	for (int i = 0; i < N; ++i) {
		++v[A[i] - 1];
	}
	for (int i = 2000; i > 0; --i) {
		v[i - 1] += v[i];
	}
	
	long long x = 0;
	for (int i = 0; i < N; ++i) {
		for (int j = i + 1; j < N; ++j) {
			if (A[i] > A[j]) {
				++x;
			}
		}
	}

	long long y = 0;
	for (int i = 0; i < N; ++i) {
		y = (y + v[A[i]]) % MOD;
	}

	long long ans = ((K * x % MOD) + (K * (K - 1) / 2 % MOD * y % MOD)) % MOD;
	cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
void hj(vector<int> &a,int n,int &d){
  for(int i=0;i<n;i++){
    int minj=i;
    for(int j=i;j<n;j++){
      if(a[j]<a[minj]){
        minj=j;
      }
    }
      swap(a[i],a[minj]);
    if(minj!=i) d++;
  }
}
int main(){
  int n;
  cin>>n;
  vector<int> a(n);
  for(int i=0;i<n;i++){
    cin>>a[i];
  }
  int f=0;
  hj(a,n,f);
  for(int i=0;i<n;i++){
    if(i==n-1){
      cout<<a[i]<<endl;
    }
    else{
      cout<<a[i]<<" ";
    }
  }
  cout<<f<<endl;
}


Measured memory_bytes: 3124
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <sstream>

using namespace std;

#define rep(i, n) for (int i = 0; i < n; i++)
#define pri(a) cout << a << endl
#define pri2(a, b) cout << a << " " << b << endl
#define in(a) cin >> a
#define in2(a, b) cin >> a >> b
#define vi vector<int>
#define vs vector<string>
#define vc vector<char>

typedef long long ll;

/*以上テンプレ*/

int main () {
    int a,p;
    in2(a, p);
    int s = (a * 3 + p) / 2;
    pri(s);
}


Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>

#define ll long long int
#define fl(i,a,n) for(int i = a; i < (n); i++)
#define fls(i,a,s) for(int i = a; s[i] != '\0'; i++)

int main() {
    int n;
    scanf("%d", &n);
    int arr[n], ctr = 0;
    fl(i,0,n){
        scanf("%d", &arr[i]);
    }
    fl(i,0,n-2){
        fl(j,i+1,n-1){
            fl(k,j+1,n){
                if((arr[i] + arr[j] > arr[k] && arr[j] + arr[k] > arr[i] && arr[i] + arr[k] > arr[j]) && (arr[i] != arr[j] && arr[k] != arr[i] && arr[j] != arr[k])){
                    ctr++;
                }
            }
        }
    }
    printf("%d\n", ctr);
    
    return 0;
}


Measured memory_bytes: 3228
#include<bits/stdc++.h>
#define ll long long
using namespace std;
const int N=5e5+10;
const ll mod=1e9+7;
struct node{
	int b,k,id;
}v[N];
int n;
int kmax[N],kmin[N],l[N],r[N];
vector<int>q[N];
ll f[N];
bool cmp(node x,node y)
{
	return x.b<y.b;
}
bool cmp1(node x,node y)
{
	return x.k<y.k||((x.k==y.k)&&(x.b<y.b));
}
bool cmp3(int x,int y){
     return x>y;
}
int fi1(int l,int r,int s,int t) 
{
     if (l>r) return 10000000;
     int mid=(l+r)/2;
     bool p=0;
     if (s>v[mid].k||((s==v[mid].k)&&(t>v[mid].b))) p=1; else p=0;
     if (p) return fi1(mid+1,r,s,t);
     else return min(fi1(l,mid-1,s,t),mid);
}
int fi2(int l,int r,int s,int t)
{
    if (l>r) return 0;
    int mid=(l+r)/2;
    bool p=0;
    if (v[mid].k>s||((s==v[mid].k)&&(v[mid].b>t))) p=1; else p=0;
    if (p) return fi2(l,mid-1,s,t);
    else return max(mid,fi2(mid+1,r,s,t));
}
int main()
{
	scanf("%d",&n);
	for (int i=1;i<=n;i++) {
		scanf("%d%d",&v[i].b,&v[i].k);
	}
	sort(v+1,v+n+1,cmp);
	kmin[n+1]=1000000001;
	for (int i=1;i<=n;i++) kmax[i]=max(kmax[i-1],v[i].k);
	for (int i=n;i>=1;i--) kmin[i]=min(kmin[i+1],v[i].k);
	for (int i=1;i<=n;i++) v[i].id=i;	
	sort(v+1,v+n+1,cmp1); 
    for (int i=1;i<=n;i++) l[i]=fi1(1,n,kmin[v[i].id],v[i].b),r[i]=fi2(1,n,kmax[v[i].id],v[i].b);	
	for (int i=1;i<=n;i++) q[r[i]].push_back(l[i]);
	for (int i=1;i<=n;i++) sort(q[i].begin(),q[i].end(),cmp3);	
	f[0]=1;
	for (int i=1;i<=n;i++)	
	{
		int len=q[i].size();
		ll ans=1,ans1=1;
		for (int j=0;j<len;j++){
		ans=(ans*2ll)%mod;
		if (j==len-1||((j!=len-1)&&q[i][j]!=q[i][j+1]))
		{
            f[i]=(f[i]+(ll)(ans-ans1+mod)%mod*(f[i-1]-(q[i][j]-1?f[q[i][j]-2]:0)+mod)%mod)%mod;
            ans1=ans;
		} 
	    }
		f[i]=(f[i-1]+f[i])%mod;
	}
	printf("%lld\n",(f[n]-f[n-1]+mod)%mod);
}

Measured memory_bytes: 32768
n=int(input())
t,a=[int(i) for i in input().split()]
H=[int(i) for i in input().split()]
T=[]
for i in H:
  ti=abs(t-i*0.006-a)
  T.append(ti)
m=min(T)
i=T.index(m)
print(i+1)


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)n; ++i)
#define repi(i, a, b) for (int i = int(a); i < int(b); ++i)
#define repr(i, n) for (int i = (int)n - 1; i >= 0; --i)
#define ALL(a) (a).begin(), (a).end()
const ll mod = 1e9 + 7;

int main() {
  string s;
  cin >> s;
  if (s.length() == 3) reverse(ALL(s));
  cout << s << endl;
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cstdio>
using namespace std;
 
#define rep(i,x) for(int i=0;i<x;i++)
 
int main(){
	int bit[11][7]={
		{0,1,1,1,1,1,1},
		{0,0,0,0,1,1,0},
		{1,0,1,1,0,1,1},
		{1,0,0,1,1,1,1},
		{1,1,0,0,1,1,0},
		{1,1,0,1,1,0,1},
		{1,1,1,1,1,0,1},
		{0,1,0,0,1,1,1},
		{1,1,1,1,1,1,1},
		{1,1,0,1,1,1,1},
		{0,0,0,0,0,0,0}
	};
	while(1){
		int n;
		scanf("%d",&n); if(n==-1)break;
 
		int a=10;
		rep(i,n){
			int b;
			scanf("%d",&b);
 
			rep(j,7){
				printf("%d",(bit[a][j]+bit[b][j])&1);
			}
			printf("\n");
			a=b;
		}
	}
}

Measured memory_bytes: 1192
#include <stdio.h>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <vector>
#include <iostream>
#include <math.h>
#include <bitset>
#include <iomanip>
#include <queue>
#include <cstring>
using namespace std;

int main() {
	int N; cin >> N;
	vector<string> s(N);
	for (int i = 0; i < N; i++)cin >> s[i];
	for (int i = 0; i < N; i++)sort(s[i].begin(), s[i].end());
	sort(s.begin(), s.end());
	long long ans = 0;
	for (int i = 0; i < N;) {
		int z = i+1;
		bool x = 1;
		while (x) {
			if (z > N-1)break;
			for (int j = 0; j < 10; j++) {
				if (s[i][j] != s[z][j]) {
					x = 0; break;
				}
			}
			if (x == 0)break;
			z++;
		}
		ans += ((long long)(z-i)*(long long)(z -i-1)) / 2;
		i = z;
	}
	cout << ans << endl;
}





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

int main() {
    int n;
    while (cin >> n, n) {
        vector<int> a(n);
        int sum = 0;
        for (int i = 0; i < n; ++i) cin >> a[i], sum += a[i];
        sum /= n;
        int num = 0;
        for (int i = 0; i < n; ++i) if (a[i] <= sum) ++num;
        cout << num << endl;
    }
}



Measured memory_bytes: 3120
#include<cstdio>
#include<cstdlib>
#include<algorithm>
#include<iostream>
#include<queue>
#include<vector>
#include <bitset>
#include <cmath>
#include <limits>
#include <iostream>
#include<set>
#include<tuple>
using namespace std;
#define INF 11000000000
#define MAX 100000
#define MOD 1000000007
typedef long long ll;
typedef pair<int,int> P;
typedef pair<pair<int,int>,int> p;
typedef pair< pair<int,int>, int> p; 
#define bit(n,k) ((n>>k)&1) /*nのk bit目*/
#define rad_to_deg(rad) (((rad)/2/M_PI)*360)
//__builtin_popcount

ll dp[1<<23];

int main(){
    int N,a[23][23];
    cin>>N;
    for(int i=1;i<=N;i++){
        for(int j=1;j<=N;j++) cin>>a[i][j];
    }
    dp[0]=1;
    for(int S=0;S<(1<<N);S++){
        int n=__builtin_popcount(S);
        for(int i=1;i<=N;i++){
            if(bit(S,i-1) && a[n][i]) dp[S]+=dp[S^(1<<i-1)];
        }
        dp[S]%=MOD;
    }
    cout<<dp[(1<<N)-1]<<endl;
}



Measured memory_bytes: 18688
//  ____            _                  _                       _       _
// |  _ \ _   _ ___| |_    ___ _ __   | |_ ___ _ __ ___  _ __ | | __ _| |_ ___
// | |_) | | | / __| __|  / __| '_ \  | __/ _ \ '_ ` _ \| '_ \| |/ _` | __/ _ \
// |  _ <| |_| \__ \ |_  | (__| |_) | | ||  __/ | | | | | |_) | | (_| | ||  __/
// |_| \_\\__,_|___/\__|  \___| .__/___\__\___|_| |_| |_| .__/|_|\__,_|\__\___|
//                            |_| |_____|               |_|

//https://github.com/manta1130/Competitive_Programming_Template_Rust

#[macro_use]
mod input {

    use std;
    use std::io;

    const SPLIT_DELIMITER: char = ' ';

    #[macro_export]
    #[allow(unused_macros)]
    macro_rules! input {
    ( $($x:expr ),*) => {
        {
            let temp_str = input_line_str();
            let mut split_result_iter = temp_str.split_whitespace();
                $(
                let buf_split_result = split_result_iter.next();
                let buf_split_result = buf_split_result.unwrap();
                    ($x) = buf_split_result.parse().unwrap();
                )*
        }
    };
}

    #[allow(dead_code)]
    pub fn input_line_str() -> String {
        let mut s = String::new();
        io::stdin().read_line(&mut s).unwrap();
        s.trim().to_string()
    }

    #[allow(dead_code)]
    pub fn p<T>(t: T)
    where
        T: std::fmt::Display,
    {
        println!("{}", t);
    }

    #[allow(dead_code)]
    pub fn input_vector2d<T>(line: usize) -> Vec<Vec<T>>
    where
        T: std::str::FromStr,
    {
        let mut v: Vec<Vec<T>> = Vec::new();

        for _ in 0..line {
            let vec_line = input_vector();
            v.push(vec_line);
        }
        v
    }

    #[allow(dead_code)]
    pub fn input_vector<T>() -> Vec<T>
    where
        T: std::str::FromStr,
    {
        let mut v: Vec<T> = Vec::new();

        let s = input_line_str();
        let split_result = s.split(SPLIT_DELIMITER);
        for z in split_result {
            let buf = match z.parse() {
                Ok(r) => r,
                Err(_) => panic!("Parse Error"),
            };
            v.push(buf);
        }
        v
    }

    #[allow(dead_code)]
    pub fn input_vector_row<T>(n: usize) -> Vec<T>
    where
        T: std::str::FromStr,
    {
        let mut v = Vec::with_capacity(n);
        for _ in 0..n {
            let buf = match input_line_str().parse() {
                Ok(r) => r,
                Err(_) => panic!("Parse Error"),
            };
            v.push(buf);
        }
        v
    }

    pub trait ToCharVec {
        fn to_charvec(&self) -> Vec<char>;
    }

    impl ToCharVec for String {
        fn to_charvec(&self) -> Vec<char> {
            self.to_string().chars().collect::<Vec<_>>()
        }
    }
}

use input::*;

const INF: usize = 1_000_000_000;

fn main() {
    let (n, k, s): (usize, usize, usize);
    input!(n, k, s);

    let mut ans;
    if s == INF {
        ans = vec![INF - 1; n];
    } else {
        ans = vec![INF; n];
    }
    for i in 0..k {
        ans[i] = s;
    }
    for i in ans {
        print!("{} ", i);
    }
    println!("");
}


Measured memory_bytes: 5372
#include <iostream>
#include <algorithm>
#include <queue>
using namespace std;
#define MAX 10000
#define INFTY (1<<20)
#define WHITE 0
#define GRAY 1
#define BLACK 2

int n;
vector<pair<int, int> > adj[MAX];
void dijkstra()
{
    priority_queue<pair<int, int> >PQ;
    int color[MAX];
    int d[MAX];
    for(int i=0; i<n; i++)
    {
        d[i] = INFTY;
        color[i] = WHITE;
    }
    d[0] = 0;
    PQ.push(make_pair(0,0));
    color[0] = GRAY;
    while(!PQ.empty())
    {
        pair<int, int> f = PQ.top();
        PQ.pop();
        int u = f.second;
        color[u] = BLACK;
        if(d[u] < f.first*(-1))   continue;
        for(int j=0; j<adj[u].size(); j++)
        {
            int v = adj[u][j].first;
            if(color[v] == BLACK)
                continue;
            if(d[v]>d[u]+adj[u][j].second)
            {
                d[v] = d[u]+adj[u][j].second;
                PQ.push(make_pair(d[v]*(-1),v));
                color[v] = GRAY;
            }
        }
    }
    for(int i=0; i<n; i++)
        cout << i << " " << d[i] << endl;
}
int main()
{
    int k, u, v, c;
    cin >> n;
    for(int i=0; i<n; i++)
    {
        cin >> u >> k;
        for(int j=0; j<k; j++)
        {
            cin >> v >> c;
            adj[u].push_back(make_pair(v,c));
        }
    }
    dijkstra();
    return 0;
}

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

using namespace std;

typedef long long ll;
typedef vector<ll> vl;
typedef long double ld;
typedef vector<ld> vd;
typedef bool bl;
typedef vector<bl> vb;
typedef unordered_map<ll,unordered_map<ll,ll>> graph;

const ll e5 = 1 << 20;
const ll mod = 998244353;
const ll e3 = 1 << 13;
const ll INF = 1ll << 60;

ll n;
ll v[e5];
ll c[e5];
ll ans;

int main(){
  cin >> n;
  for(ll i = 0;i < n;i++) cin >> v[i];
  for(ll i = 0;i < n;i++) cin >> c[i];
  for(ll i = 0;i < n;i++){
    if(v[i]-c[i] > 0) ans += v[i]-c[i];
  }
  cout << ans << endl;

}


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

int main(){
	int n,m,l;
	cin>>n>>m>>l;
	int a[n][m],b[m][l];
	for(int i=0;i<n;++i){
		for(int j=0;j<m;++j){
			cin>>a[i][j];
		}
	}
	for(int i=0;i<m;++i){
		for(int j=0;j<l;++j){
			cin>>b[i][j];
		}
	}
	long c[n][l];
	for(int i=0;i<n;++i){
		for(int j=0;j<l;++j){
			c[i][j]=0;
		}
	}
	for(int i=0;i<n;++i){
		for(int j=0;j<l;++j){
			for(int k=0;k<m;++k){
				c[i][j]+=a[i][k]*b[k][j];
			}
		}
	}
	for(int i=0;i<n;++i){
		for(int j=0;j<l;++j){
			cout<<c[i][j];
			if(j!=l-1)cout<<" ";
		}
		cout<<endl;
	}
}


Measured memory_bytes: 3224
#include <map>
#include <list>
#include <cmath>
#include <cstdio>
#include <vector>
#include <cstring>
#include <iostream>
#include <algorithm>
#define LL long long
using namespace std;

int cal[13] = {0};
int val[26] = {0},vc;
int a[55] = {0};
int n,tmp,maxn = 0;

int main(){
	scanf("%d",&n);
	for(register int i = 0;i < n;i ++){
		scanf("%d",&a[i]);
		cal[a[i]] ++;
		if(cal[a[i]] >= 3 || cal[12] >= 2 || cal[0] >= 1){
			printf("0\n");
			return 0;
		}
	}
	for(register int i = 0;i < (1 << 22);i ++){
		memset(val,0,sizeof(val)); vc = 0;
		for(register int j = 1;j <= 11;j ++){
			if(cal[j] == 0) continue;
			if(cal[j] == 1){
				if((i >> (j - 1 + j - 1)) & 1) val[++ vc] = j;
				else val[++ vc] = 24 - j;
			}
			if(cal[j] == 2){
				if((i >> (j - 1 + j - 1)) & 1) val[++ vc] = j;
				else val[++ vc] = 24 - j;
				if((i >> (j - 1 + j)) & 1) val[++ vc] = j;
				else val[++ vc] = 24 - j;
			}
		}
		if(cal[12]) val[++ vc] = 12;
		val[++ vc] = 24;
		sort(val + 1,val + 1 + vc);
		tmp = 24;
		for(register int j = vc;j >= 1;j --) tmp = min(tmp,val[j] - val[j - 1]);
		maxn = max(maxn,tmp);
	}
	printf("%d\n",maxn);
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
using namespace std;
class Dice{
private:
public:
    int num[6];
    void roll(char c){
        int b;
        if(c=='S'){
            b=num[0];
            num[0]=num[4];
            num[4]=num[5];
            num[5]=num[1];
            num[1]=b;
        }
        if(c=='W'){
            b=num[0];
            num[0]=num[2];
            num[2]=num[5];
            num[5]=num[3];
            num[3]=b;
        }
        if(c=='N'){
            b=num[0];
            num[0]=num[1];
            num[1]=num[5];
            num[5]=num[4];
            num[4]=b;
        }
        if(c=='E'){
            b=num[0];
            num[0]=num[3];
            num[3]=num[5];
            num[5]=num[2];
            num[2]=b;
        }
    }
};
bool isSame(Dice d1,Dice d2){
    int top=d1.num[0],front=d1.num[1];
    if(d2.num[2]==front||d2.num[3]==front) d2.roll('W');
    while(d2.num[1] !=front) d2.roll('S');
    while(d2.num[0] !=top) d2.roll('W');
    for(int i=2;i<6;i++){
        if(d1.num[i] !=d2.num[i]) return false;
    }
    return true;
}
int main(){
    Dice d1,d2;
    for(int i=0;i<6;i++) cin>>d1.num[i];
    for(int i=0;i<6;i++) cin>>d2.num[i];
    if(isSame(d1,d2)) cout<<"Yes"<<endl;
    else cout <<"No"<<endl;
    return 0;
}



Measured memory_bytes: 3104
#include<iostream>
#include<map>
#include<set>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
#include<stack>
#include<limits>
#include<sstream> 
#include<unordered_map>      

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef int itn;
typedef vector<int> vi;
typedef vector<ll> vl;

const int inf = numeric_limits<int>::max() >> 2;
const ll linf = numeric_limits<ll>::max() >> 2;
const ull ulinf = numeric_limits<ull>::max() >> 2;
const double pi = acos(-1);
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
const int dx8[8]={-1,0,1,-1,1,-1,0,1};
const int dy8[8]={-1,-1,-1,0,0,1,1,1};

#define p_queue(i) priority_queue<i> 
#define rp_queue(i) priority_queue<i, vector<i>, greater<i>> 
#define umap(i,j) unordered_map<i,j>
#define P(p) cout<<(p)<<endl
#define PS(p) cout<<(p)<< " "
#define IN cin >> 
#define rep(i,m,n) for(int i = (m); i < (int)(n); i++)
#define rrep(i,m,n) for(int i = (m-1); i >= (int)(n); i--)
#define inrep(n,a) for(int i = 0; i < (int)(n); i++)cin >> a[i];
#define mod(i) ((i)%(ll)(1e9 + 7))
#define divm(a,b) (mod(a * modpow((ll)b,(ll)(1e9+5))))
#define rsort(a,b,c) sort(a, b, greater<c>())
#define vsort(v) sort(v.begin(), v.end())
#define rvsort(v,c) sort(v.begin(), v.end(), greater<c>()) 
#define ft first
#define sd second
#define pb push_back
#define it insert
#define sz(x) ((int)(x).size())
#define lb(a,n,k) (lower_bound(a,a+n,k) - a) 
#define vlb(a,k)  (lower_bound(a.begin(),a.end(),k) - a.begin())
#define ub(a,n,k) (upper_bound(a,a+n,k) - a) 
#define vub(a,k)  (upper_bound(a.begin(),a.end(),k) - a.begin())
#define YES cout<<"YES"<< endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl  
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
#define ret return

ll modpow(ll i,ll j){ ll tmp=1; while(j){ if(j%2)tmp=mod(tmp*i);i=mod(i*i);j/=2;}return tmp;}
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }

vector<string> split(const string &str, char sep){
    vector<string> v;
    stringstream ss(str);
    string buffer;
    while( getline(ss, buffer, sep) ) {
        v.push_back(buffer);
    }
    return v;
}

//ll ncr[100][100];
//ll nCr(int n, int r){if(n==r) ret ncr[n][r] = 1; if(r==0) ret ncr[n][r] = 1; if(r==1) ret ncr[n][r] = n;if(ncr[n][r]) ret ncr[n][r]; ret ncr[n][r] = nCr(n-1,r) + nCr(n-1,r-1);}

//ll npr[100][100]={};
//ll nPr(int n,int r){if(npr[n][r])ret npr[n][r];if(r==0)ret npr[n][r] = 1;if(r==1)ret npr[n][r] = n;ret npr[n][r] = n * nPr(n-1,r-1);}

//ll nHr(int n,int r){ret nCr(n+r-1,r);}

///////////////////////////////////////////////////////////////////////////


int main(){

    int n;

    cin >> n;
    double a[n];
    inrep(n,a);

    double d = 0;

    rep(i,0,n){
	d += (1/a[i]);
    }

    printf("%.10lf\n",1/d);
    return  0;
}


Measured memory_bytes: 256
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <unordered_map>
#include <climits>
#include <set>
#include <unordered_set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <queue>
#include <random>
#include <complex>
#include <regex>
#include <locale>
#include <random>
#include <type_traits>

using namespace std;

#define SHOW_VECTOR(v) {std::cerr << #v << "\t:";for(const auto& xxx : v){std::cerr << xxx << " ";}std::cerr << "\n";}
#define SHOW_MAP(v){std::cerr << #v << endl; for(const auto& xxx: v){std::cerr << xxx.first << " " << xxx.second << "\n";}}

using LL = long long;

//------------------------------------------
//------------------------------------------

constexpr LL MAX = 100100;

int main() {

    LL N, M;
    cin >> N >> M;

    vector<LL> A(N), B(N);
    for (int i = 0; i < N; i++) cin >> A[i] >> B[i];

    vector<vector<LL>> C(MAX, vector<LL>());
    for (int i = 0; i < N; i++) C[A[i]].push_back(B[i]);

    LL ans = 0;
    priority_queue<LL> Q;

    for (int i = 1; i <= min(M, MAX - 2); i++) {
        for(auto x: C[i]) Q.push(x);
        if(!Q.empty()){
            ans += Q.top();
            Q.pop();
        }
    }

    cout << ans << endl;

}
























Measured memory_bytes: 7296