akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#include <algorithm>
#include <complex>
#include <array>
#include <functional>
using namespace std;
 
#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()
 
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<double> VD;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef vector<VD> VVD;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

template<typename T> void chmin(T &a, T b) { if (a > b) a = b; }
template<typename T> void chmax(T &a, T b) { if (a < b) a = b; }

int in() { int x; scanf("%d", &x); return x; }
ll lin() { ll x; scanf("%lld", &x); return x; }

struct union_find{
    VI par, sz;

    void init(int n){
        par.resize(n);
        REP(i,n) par[i] = i;
        sz.assign(n, 1);
    }

    int find(int x){
        if (par[x] == x) return x;
        else return par[x] = find(par[x]);
    }

    bool same(int x, int y){
        return find(x) == find(y);
    }

    void merge(int x, int y){
        x = find(x);
        y = find(y);
        if (x == y) return;
        par[x] = y;
        sz[y] += sz[x];
    }

    int size(int x){
        return sz[find(x)];
    }
};

int main(void){
    int n, m, k;
    cin >> n >> m >> k;
    union_find uf;
    uf.init(n);
    VVI f(n), b(n);
    REP(i,m){
        int u = in() - 1, v = in() - 1;
        f[u].push_back(v);
        f[v].push_back(u);
        uf.merge(u, v);
    }
    REP(i,k){
        int u = in() - 1, v = in() - 1;
        b[u].push_back(v);
        b[v].push_back(u);
    }
    vector<set<int>> st(n);
    REP(i,n) st[uf.find(i)].insert(i);
    VI ans(n);
    REP(i,n){
        for (int x : st[i]){
            int cnt = st[i].size() - 1;
            for (int y : f[x]) if (st[i].count(y)) cnt--;
            for (int y : b[x]) if (st[i].count(y)) cnt--;
            ans[x] = cnt;
        }
    }
    REP(i,n) printf("%d ", ans[i]);
    cout << endl;
    return 0;
}


Measured memory_bytes: 22776
#include <bits/stdc++.h>
#define x first
#define y second
using namespace std;
typedef long long ll;
const int N = 1e2 + 10;
const int mod = 1e9 + 7;



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

    cin >> n;
    int cur = 1;
    for (int i = 1; i <= n; ++i)
    {
        int a;
        cin >> a;
        if (a == cur) ++cur;
    }
    if (cur == 1)
    {
        cout << -1;
        return 0;
    }
    cout << n - cur + 1;
    return 0;
}


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

int main()
{
	int n;
	cin >> n;
	vector<long long> v(n);
	for_each(v.begin(), v.end(), [&](long long & i)
	{
		cin >> i;
	});
	cout << * min_element(v.begin(), v.end());
	cout << " ";
	cout << * max_element(v.begin(), v.end());
	cout << " ";
	//cout << accumulate(v.begin(), v.end(), 0);
	long long s = 0;
	for (size_t i = 0; i < n; i++)
	{
		s += v[i];
	}
	cout << s;
	cout << endl;
	return 0;
}

Measured memory_bytes: 3180
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<string> vs;
string ALP = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
string alp = "abcdefghijklmnopqrstuvwxyz";
vi d1 = {1, 0, -1, 0}, d2 = {0, 1, 0, -1};
void Yes() {cout << "Yes" << endl;}
void No() {cout << "No" << endl;}
void YES() {cout << "YES" << endl;}
void NO() {cout << "NO" << endl;}
void neg() {cout << -1 << endl;}

int main() {
  for (int i = 0; i < 3; i++) {
    string s;
    cin >> s;
    cout << s.at(i);
  }
  cout << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define MOD 1000000007
using namespace std;
int main()
{
    int x;
    cin >> x;
    int ans = 1;
    for(int i = 2;i <= x;i++)
    {
        for(int j = i * i;j <= x;j *= i)
        {
            if(j > ans)
            {
                ans = j;
            }
        }
    }
    cout << ans;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h> 
using namespace std; 
int main() { 
  int N, M; cin >> N >> M; 
  int sumN, sumM;
  if (N == 0 || N == 1) {
    sumN == 0;
  }
  else {
    sumN = N * (N-1) / 2;
  }
  if (M == 0 || M == 1) {
    sumM == 0;
  }
  else {
    sumM = M * (M-1) / 2;
  }
  cout << sumN + sumM << endl;
} 


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,k,n) for(int i = (int)(k); i < (int)(n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(a) a.begin(), a.end()
#define MS(m,v) memset(m,v,sizeof(m))
typedef long long ll;
typedef long double ld;
typedef vector<ll> vi;
typedef vector<string> vs;
typedef pair<int, int> pii;
const int MOD = 1e9 + 7;
template<class T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template<class T> T &chmax(T &a, const T &b) { return a = max(a, b); }
template<class T>
istream& operator >> (istream& is, vector<T>& v)
{
	for (auto &i : v) is >> i;
	return is;
}
template<class T>
ostream& operator<<(ostream& os, vector<T>& v)
{
	const string delimiter = "\n";
	REP(i, v.size())
	{
		os << v[i];
		if (i != v.size() - 1) os << delimiter;
	}
	return os;
}
/*--------------------template--------------------*/

void out(bool f)
{
	cout << (f ? "YES" : "NO") << endl;
	exit(EXIT_SUCCESS);
}

int main()
{
	cin.sync_with_stdio(false); cout << fixed << setprecision(10);
	ll n; cin >> n;
	vi a(n); cin >> a;
	ll sum = 0;
	for (auto i : a) sum += i;
	ll x = (1ll + n) * n / 2ll;
	if (sum % x != 0) out(0);
	ll cnt = sum / x;
	ll y = cnt;
	ll beg = a[0]; a.push_back(beg);
	REP(i, n)
	{
		ll dif = a[i + 1] - a[i];
		if (y - dif < 0) out(0);
		if ((y - dif) % n != 0) out(0);
		cnt -= (y - dif) / n;
	}
	if (cnt == 0) out(1);
	return 0;
}

Measured memory_bytes: 1792
#define _USE_MATH_DEFINES

#include <iostream>
#include <iomanip>
#include <iterator>
#include <vector>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <cfloat>
#include <queue>
#include <stack>
#include <string>
#include <map>
#include <functional>
#include <stdexcept>

typedef long long ll;
typedef unsigned int ui;
typedef unsigned short us;
typedef unsigned long long ull;

template <typename T>
std::ostream& operator<< (std::ostream& out, const std::vector<std::vector<T>>& v) {
  if (!v.empty()) {
    for (std::vector<T> v2 : v) {
      std::copy(v2.begin(), v2.end(), std::ostream_iterator<T>(out, ", "));
      out << "\b\b \n";
    }
  }
  return out;
}
template <typename T>
std::ostream& operator<< (std::ostream& out, const std::vector<T>& v) {
  if ( !v.empty() ) {
    std::copy (v.begin(), v.end(), std::ostream_iterator<T>(out, ", "));
    out << "\b\b ";
  }
  return out;
}

using namespace std;

namespace my {
  class LCS
  {
  public:
    LCS() = default;
    ~LCS() = default;

  private:

  };
}

int main(int argc, const char * argv[]) {
  int q;
  cin >> q;
  vector<string> x;
  vector<string> y;
  for (size_t i = 0; i < q; i++)
  {
    string temp;
    cin >> temp;
    x.push_back(temp);
    cin >> temp;
    y.push_back(temp);
  }
  
  
  
  for (size_t i = 0; i < q; i++)
  {
    size_t x_length = x[i].length();
    size_t y_length = y[i].length();
    size_t max_length = min(x_length, y_length);
    vector<int> length_y_nanmoji(1, y_length);
    map<char, vector<int>> y_nanmoji;
    for (size_t j = 0; j < x_length; j++)
    {
      char x_char = x[i][j];
      if (y_nanmoji.find(x_char) == y_nanmoji.end()) {
        size_t count = 0;
        bool is_looped = false;
        do
        {
          count = y[i].find(x_char, count);
          if (count >= y_length) {
            if (!is_looped) {
              y_nanmoji[x_char].push_back(-1);
            }
            break;
          }
          else {
            y_nanmoji[x_char].push_back((int)count);
            count++;
          }
        } while (is_looped = true, true);
      }

      auto y_nanmoji_now = y_nanmoji[x_char];
      if (y_nanmoji_now[0] == -1) {
        continue;
      }
      for(int l = (int)y_nanmoji_now.size() - 1; l >= 0; l--)
      {
        int val = y_nanmoji_now[l];
        bool is_done = false;
        for (int k = 0; k < (int)length_y_nanmoji.size(); k++)
        {
          if (length_y_nanmoji[k] >= val) {
            length_y_nanmoji[k] = val;
            is_done = true;
            break;
          }
        }
        if (!is_done) {
          length_y_nanmoji.push_back(val);
        }
      }

    }
    int kotae = length_y_nanmoji[0] >= y_length ? 0 : length_y_nanmoji.size();
    cout << kotae << endl;
  }

  return 0;
}


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

void solve(){
    ll n; cin >> n;
    map<ll, ll> mp;
    REP(i, n){
        ll a;
        cin >> a;
        mp[a]++;
    }

    vector<ll> v;
    for(auto it=mp.begin(); it!=mp.end(); it++){
        if((it->second) > 1){
            ll num = (it->second)/2;
            REP(i, num) v.pb(it->first);
        }
    }

    ll size = v.size();
    if(size < 2) cout << 0 << endl;
    else cout << v[size-1]*v[size-2] << endl;
}

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

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

int main()
{
    double a,b;
    cin >> a >> b;
    int ans = -1;
    for(int i = 1; i <= 1000; ++i)
    {
        int ta = (i*8/100);
        int tb = (i/10);
        if(ta == a
        && tb == b)
        {
            ans = i;
            break;
        }
    }
    cout << ans << endl;
}

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

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;

#define sz(a) int((a).size())
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define all(c) (c).begin(),(c).end()
#define rall(c) (c).rbegin(),(c).rend()
#define ini(a, i) memset(a, i, sizeof(a))
#define inin(a, n, i) memset(a, i, sizeof(a[0])*(n))
#define contains(c, i) ((c).find(i) != (c).end())
#define present(i, c) (find(all(c), i) != (c).end())

#define trav(x, c) for(auto& x : c)
#define rep(i, n) for(int i = 0; i < n; i++)
#define repa(i, b, e) for(int i = (b)-((b)>(e)); i != (e)-((b)>(e)); i += 1-2*((b)>(e)))
	
template<class T> bool chkmax(T &x, T y) { return x < y ? x = y, true : false; }
template<class T> bool chkmin(T &x, T y) { return x > y ? x = y, true : false; }
template<class A, class B> A cvt(B x) { stringstream s; s << x; A r; s >> r; return r; }

void read() {}
void print() {}
template<class T, class... Args> void read(T& a, Args&... args) { cin >> a; read(args...); }
template<class T, class... Args> void print(T a, Args... args) { cout << a << ' '; print(args...); }
template<class... Args> void println(Args... args) { print(args...); cout << '\n'; }

#define debug(args...) { string s_(#args); replace(all(s_), ',', ' '); stringstream ss_(s_); istream_iterator<string> it_(ss_); cerr_(it_, args); }
void cerr_(istream_iterator<string> it) { (void) it; }
template<class T, class... Args> void cerr_(istream_iterator<string> it, T a, Args... args) { cerr << *it << " = " << a << endl; cerr_(++it, args...); }

template<class T, class S>  ostream& operator<<(ostream& os, const pair<T, S>& p) { os << "(" << p.first << ", " << p.second << ")"; return os; }
template<class T> ostream& operator<<(ostream &os, const vector<T> &v) { os << '{'; string sep; for (const auto &x : v) os << sep << x, sep = ", "; return os << '}'; }
template<class T> ostream& operator<<(ostream &os, const set<T> &s) { os << '{'; string sep; for (const auto &x : s) os << sep << x, sep = ", "; return os << '}'; }
template<class T, class S> ostream& operator<<(ostream &os, const map<T, S> &m) { os << '{'; string sep; for (const auto &x : m) os << sep << x, sep = ", "; return os << '}'; }
template<class T, size_t size> ostream& operator<<(ostream &os, const array<T, size> &arr) { os << '{'; string sep; for (const auto &x : arr) os << sep << x, sep = ", "; return os << '}'; }

const int INF = 0x3F3F3F3F;
const int MAXN = (int) 1e6;
const int MOD = (int) 1e9+7;

//=========================

void run_test() {
	int n; read(n);
	println(1 - n);
}

//=========================

int main() {
	ios::sync_with_stdio(false); cin.tie(nullptr);
	//int t_ = 1, t__; cin >> t__; while(t_ <= t__) { cout << "Case #" << t_++ << ": "; run_test(); }
	// int t_; cin >> t_; while(t_--) run_test();
	run_test();
	return 0;	
}


Measured memory_bytes: 3644
import sys 
input=sys.stdin.readline 
def getsum(BITTree,i): 
	s = 0 
	i = i+1
	while i > 0: 
		s += BITTree[i] 
		i -= i & (-i) 
	return s 
def updatebit(BITTree , n , i ,v): 
	i += 1
	while i <= n: 
		BITTree[i] += v 
		i += i & (-i) 
def construct(arr, n): 
	BITTree = [0]*(n+1) 
	for i in range(n): 
		updatebit(BITTree, n, i, arr[i]) 
	return BITTree 
n=int(input())
arr=[int(i) for i in input().split()]
from collections import Counter 
c=Counter(arr)
m=int(input())
sm=sum(arr)
for i in range(m): 
    a,b=map(int,input().split())
    if c[a]:
        sm-=c[a]*a 
        sm+=c[a]*b 
        c[b]+=c[a]
        c[a]=0 
    print(sm)


Measured memory_bytes: 20564
import itertools

a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = int(input())

k = int(input())

x = [a,b,c,d,e]

res = 0
for i,j in itertools.combinations(x, 2):
  if abs(j - i) > k:
    res = 1
    print(':(')
    break

if res == 0:
	print('Yay!')


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

int main() {
  int n;
  int t[100];

  while (cin >> n) {
    for (int i = 0; i < n; i++) {
      cin >> t[i];
    }
    for (int res = 100; res >= 1; res--) {
      int cnt = 0;
      for (int i = 0; i < n; i++) {
        if (res <= t[i]) {
          cnt++;
        }
      }
      if (cnt >= res) {
        cout << res << endl;
        break;
      }
    }
  }
}

Measured memory_bytes: 3080
n = int(input())
p = [0]
for i in range(n):
    p.append(int(input()))
kar = 1
ans = 0
c = 0
while True:
    if kar == -1:
        print(-1)
        exit()
    elif kar == 2:
        print(ans)
        exit()
    else:
        c = kar
        kar = p[kar]
        p[c] = -1
        ans += 1

Measured memory_bytes: 7080
#include <iostream>

int main(void){
  int a[5];
  int min = 10;
  int sum = 0;
  for(int i = 0; i < 5; i++)
    std::cin >> a[i];
  for(int i = 0; i < 5; i++){
    if(0 < a[i] % 10 && a[i] % 10 < min){
      min = a[i] % 10;
    }
    sum += (a[i] % 10 == 0)? a[i] / 10 : a[i] / 10 + 1;
  }
  if(min % 10 == 0)
    std::cout << sum * 10;
  else
    std::cout << sum * 10 + min % 10 - 10 << std::endl;
  return 0;
}

Measured memory_bytes: 256
S = input().strip()
T = input().strip()

ds = {}
dt = {}
ans = 'Yes'
for s, t in zip(S, T):
    if s not in ds or ds[s] == t:
        ds[s] = t
    else:
        ans = 'No'
        break
    if t not in dt or dt[t] == s:
        dt[t] = s
    else:
        ans = 'No'
        break
print(ans)

Measured memory_bytes: 3632
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
int N;
using namespace std;
int main(){
  cin >> N;
  vector<string> S(N);
  for (int i=0; i<N; i++){
    string s;
    vector<char> A(10);
    cin >> s;
    
    for(int j=0; j<10; j++){
      A[j] = s[j];
    }
    sort(A.begin(), A.end());
    for(int j=0; j<10; j++){
      s[j] = A[j];
    }
    S[i] = s;
  }
  sort(S.begin(), S.end());
  
  long int totalcount = 0;
  vector<long int> count;
  count.push_back(1);
  for(int i=1; i<N; i++){
    if (S[i-1] == S[i]){
      count.back() += 1;
    }
    else{
      count.push_back(1);
    }
  }
  for(int i=0; i<count.size(); i++){
    totalcount += count[i]*(count[i]-1)/2;
  }
  cout << totalcount << endl;
  return 0;
}

Measured memory_bytes: 6904
package main

import (
	"fmt"
)

func main() {
	ls := []int8{1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51}
	var i int
	fmt.Scanf("%d", &i)
	fmt.Println(ls[i - 1])
}


Measured memory_bytes: 512
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <fstream>
#include <cassert>
#include <cstring>
#include <unordered_set>
#include <unordered_map>
#include <numeric>
#include <ctime>
#include <bitset>
#include <complex>
#include <random>

using namespace std;

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

	int n, m;
	cin >> n >> m;
	cout << (n * (n - 1)) / 2 + (m * (m - 1)) / 2 << endl;
} 


Measured memory_bytes: 896
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <set>

using namespace std;

int main() {
  int N, l[1000];
  set<int> s;
  bool remove[1000];
  int size = 0;

  scanf("%d", &N);

  pair<int,int> p[1000];

  for (int i=0; i<N; i++) {
    char d[2];
    scanf("%s%d", d, l + i);
    remove[i] = d[0] == 'y';
    s.insert(i);
    p[i] = {l[i] * 2 + !remove[i], i};
    size += !remove[i];
  }

  sort(p, p+N);

  int ans = 0;

  for(int i=0; i<N; i++) {
    int idx = p[i].second;

    auto it = s.find(idx);

    if (it == s.end()) continue;
    if (!remove[*it]) { s.erase(it); continue; }

    ans++;

    while(it != s.end() && remove[*it]) {
      it = s.erase(it);
    }

    while(1) {
      if (s.begin() == it) break;
      it--;
      if (!remove[*it]) break;
      it = s.erase(it);
    }
  }

  cout << ans << endl;

  return 0;
}



Measured memory_bytes: 3284
#include<iostream>
#include<vector>
#include<string>
#include<cmath>
#include<algorithm>
#include<functional>
#include<numeric>
#include<queue>
#include<stack>
#include<map>
#include<unordered_map>
#include<set>
#include<bitset>
#include<random>

#pragma region
using namespace std;
#define FOR(i,r,n) for(ll i = (ll)(r); i < (ll)(n); i++)
#define rep(i,n) FOR(i,0LL,n)
#define RFOR(i,r,n) for(ll i=(ll)(n-1);i>=r;i--)
#define rrep(i,n) RFOR(i,0LL,n)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define COUNT(a,y,x) upper_bound(all(a), y) - lower_bound(all(a), x)
#define UNIQUE(a) sort(all(a)); a.erase(unique(all(a)), a.end())
#define pb push_back
typedef long long int ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<ll, ll> pll;
typedef vector<pll> vpll;
typedef vector<string> vs;
typedef map<ll, ll> MAP;
const ll inf = 2222222222222222222LL;
const ll mod = 1000000007LL;

ll n = 0, m = 0, ans = 0, tmp = 0, ma = -inf, mi = inf;
string s;
bool ok;
ll dx[9] = { 0,1,-1,0,0,1,1,-1,-1 }, dy[9] = { 0,0,0,1,-1,1,-1,1,-1 };
#define endl '\n'
#pragma endregion
#define MAX 222222





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


  string a, b, c;
  cin >> n;
  cin >> a >> b >> c;
  rep(i, n) {
    if (a[i] != b[i] && b[i] != c[i] && c[i] != a[i]) ans += 2;
    else if (a[i] == b[i] && b[i] == c[i]);
    else ans++;
  }
  cout << ans << endl;



  return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <vector>
#include <algorithm>
#include <iostream>
#include <cassert>
using namespace std;
#define REP(i, n) for(int i = 0; i < (int)(n); ++i)
typedef long long ll;

ll K, X, Y;

vector<pair<ll,ll> > solve(void) {
  vector<pair<ll,ll> > res;
  if(abs(X)+abs(Y) == K) {
    res.push_back(make_pair(X, Y));
    return res;
  }

  if((X+Y) % 2 != 0 && K % 2 == 0) {
    return res;
  }
  
  ll cx = 0;
  ll cy = 0;
  ll gx = X+Y;
  ll gy = X-Y;
  while(abs(cx-gx) > 2*K || abs(cy-gy) > 2*K) {
    ll nx, ny;
    if(cx+K < gx) {
      nx = cx+K;
    } else {
      nx = cx-K;
    }
    if(cy+K < gy) {
      ny = cy+K;
    } else {
      ny = cy-K;
    }
    cx = nx;
    cy = ny;
    res.push_back(make_pair((cx+cy)/2, (cx-cy)/2));
  }
  // for parity
  if((K * (ll)res.size() & 1LL) != ((X+Y) & 1LL)) {
    ll nx, ny;
    if(cx+K < gx) {
      nx = cx+K;
    } else {
      nx = cx-K;
    }
    if(cy+K < gy) {
      ny = cy+K;
    } else {
      ny = cy-K;
    }
    cx = nx;
    cy = ny;
    res.push_back(make_pair((cx+cy)/2, (cx-cy)/2));
  }
  // last
  ll nx, ny;
  if(cx < gx) {
    nx = cx + K;
  } else {
    nx = cx - K;
  }
  if(cy < gy) {
    ny = gy - K;
  } else {
    ny = gy + K;
  }
  res.push_back(make_pair((nx+ny)/2, (nx-ny)/2));
  res.push_back(make_pair((gx+gy)/2, (gx-gy)/2));
  return res;
}

// void validate(const vector<pair<ll,ll> >& ps) {
//   ll cx = ps[ps.size()-2].first;
//   ll cy = ps[ps.size()-2].second;
//   REP(i, ps.size()) {
//     ll dist = abs(cx-ps[i].first) + abs(cy-ps[i].second);
//     if(dist != K) {
//       assert(false);
//     }
//     cx = ps[i].first;
//     cy = ps[i].second;
//   }
// }

int main(void) {
  cin >> K >> X >> Y;
  vector<pair<ll,ll> > res = solve();
  if(res.size() == 0) {
    puts("-1");
  } else {
    // validate(res); // XXX TEST
    printf("%d\n", (int)res.size());
    REP(i, res.size()) {
      printf("%lld %lld\n", res[i].first, res[i].second);
    }
  }
  return 0;
}


Measured memory_bytes: 5996
import sys
sys.setrecursionlimit(65536)

a,b,c,d,e,f=map(int, input().split())

def memoize(f):
	memo = {}
	def g(*args):
		if args not in memo:
			memo[args] = f(*args)
		return memo[args]
	return g

@memoize
def search(w, s):
	if 100*w+s > f:
		return (-1, w, s)

	if s > e * w or w == 0:
		return max(search(a+w, s), search(b+w, s))
	else:
		return max(search(w, s+c), search(w, s+d), (100*s/(100*w+s), w, s))

_,w,s=search(0, 0)
print(100*w+s, s)


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

//{ START
using namespace std;
#define int int64_t
#define rep(i, a, n) for (int i = (a); i < (n); ++i)
#define reps(i, a, n) for (int i = (a); i > (n); --i)
#define arep(i, x) for (auto &&i : (x))
#define irep(i, x) for (auto i = (x).begin(); i != (x).end(); ++i)
//降順はgreater<T>()
#define all(x) (x).begin(), (x).end()
#define rv(s) reverse((s).begin(), (s).end())
// gcd lcmはそのままok
#define gcd(a, b) __gcd(a, b)
#define bits(n) (1LL << (n))
#define pcnt(x) __builtin_popcountll(x)
//配列内等要素削除
#define unique(x) (x).erase(unique((x).begin(), (x).end()), (x).end())
#define Fixed(n) fixed << setprecision(n)
//総和
#define sowa(n) ((n) * ((n) + 1)) / 2
#define pb(x, a) (x).push_back(a)
#define fb(x, a) (x).push_front(a)
#define eb(x, a) (x).emplace_back(a)
#define F first
#define S second
#define cauto const auto &
using P = pair<int, int>;
using Graph = vector<vector<P>>;
template <class T>  //昇順
using min_heap = priority_queue<T, vector<T>, greater<T>>;
template <class T>  //降順
using max_heap = priority_queue<T>;
template <class A, class B>
using umap = unordered_map<A, B>;
template <class A>
using uset = unordered_set<A>;
template <typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val) {  //多次元初期化
  std::fill((T *)array, (T *)(array + N), val);
}
template <class T>
bool chmax(T &a, const T &b) {  //最大値更新 返り値はbool
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T>
bool chmin(T &a, const T &b) {  //最小値更新 返り値はbool
  if (b < a) {
    a = b;
    return 1;
  }
  return 0;
}
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
constexpr int INF = 0x3f3f3f3f;
constexpr int LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr int mod1 = 1e9 + 7;
constexpr int mod2 = 998244353;
//} END

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

  int n,a,ans=0;
  cin>>n;
  vector<int> x(n+1,0);

  rep(i,1,n+1){
    cin>>a;
    x[i] = a;
  }

  rep(i,1,n+1){
    if(x[x[i]] == i) ++ans;
  }
  cout<<ans/2<<'\n';
}

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

typedef long long ll;
typedef pair<int,int> P;
int dx[] = {-1, 1, 0,  0};
int dy[] = { 0, 0, 1, -1};

 
int main(){
  int n;
  cin >> n;
  cout << "Christmas";
  while(n<25){
    cout << " Eve";
    n++;
  }
  cout << endl;
  return 0;
}


Measured memory_bytes: 256
h,w=map(int,input().split())
S=[]
s=[]
for i in range(w+2):
    s.append(0)
S.append(s)
for i in range(h):
    si="0"+input()+"0"
    ssi=[]
    for j in range(w+2):
        ssi.append(si[j])
    S.append(ssi)
S.append(s)
for i in range(1,h+1):
    for j in range(1,w+1):
        if S[i][j]==".":
            countij=0
            seqij=[]
            seqij.append(S[i-1][j-1])
            seqij.append(S[i-1][j])
            seqij.append(S[i-1][j+1])
            seqij.append(S[i][j-1])
            seqij.append(S[i][j+1])
            seqij.append(S[i+1][j-1])
            seqij.append(S[i+1][j])
            seqij.append(S[i+1][j+1])
            for k in range(8):
                if seqij[k]=="#":
                    countij+=1
            S[i][j]=countij
for i in range(1,h+1):
    for j in range(1,w+1):
        print(S[i][j],end="")
    print()

Measured memory_bytes: 3572
N,*A = `dd`.split.map &:to_i
es = (0..N).map{ [] }
(2..N).each{ |i| es[A[i-2]] << i }
#p es
ds = Array.new(N+1, nil)
que = [1]
while w = que.pop do
  if !ds[w]
    ds[w] = 0
    que << w
    que.concat(es[w])
  else
    ds[w] = es[w].map{ |a| ds[a] }.sort.reverse.map.with_index{ |d,i| d + i + 1 }.max || 0
    #p [w, es[w], es[w].map{ |a| [a,ds[a]] }, ds[w]]
  end
end

p ds[1]

Measured memory_bytes: 24716
import java.util.Scanner;

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

		// 入力値の取得
		int N = sc.nextInt();
		int R = sc.nextInt();
		
		// 結果の出力
		if (N < 10) {
			System.out.println(100*(10-N)+R);
		}
		else {
			System.out.println(R);
		}

		sc.close();
	}
}


Measured memory_bytes: 23892
B, A = map(int, input().split())
K = []
for i in range(50):
    K.append(["."]*100)
for j in range(50):
    K.append(["#"]*100)
a = 1
b = 1
t = 0
while(True):
    if A == a:
        break
    for i in range(0, 100, 4):
        K[t][i] = "#"
        a += 1
        if A == a:
            break
    if A == a:
        break
    t += 1
    for i in range(2, 100, 4):
        K[t][i] = "#"
        a += 1
        if A == a:
            break
    t += 1

t = 51
while(True):
    if B == b:
        break
    for i in range(0, 100, 4):
        K[t][i] = "."
        b += 1
        if B == b:
            break
    if B == b:
        break
    t += 1
    for i in range(2, 100, 4):
        K[t][i] = "."
        b += 1
        if B == b:
            break
    t += 1
print(100, 100)
for i in range(100):
    for j in K[i]:
        print(j, end="")
    print()

Measured memory_bytes: 74796
# -*- coding: utf-8 -*-

import sys
import math
from decimal import Decimal, ROUND_DOWN
from collections import deque
from itertools import combinations
import copy

debug = False

def log(text):
    if debug:
        print(text)

def parse_input(lines_as_string = None):

    global debug
    lines = []
    if lines_as_string is None:
        debug = False
        for line in sys.stdin:
            lines.append(line.strip())
    else:
        debug = True
        lines = [e for e in lines_as_string.split("\n")][1:-1]

    (n, ) = [int(e) for e in lines[0].split(' ')]
    a = [int(e) for e in lines[1].split(' ')]


    return (n, a)


def solve(n, a):

   
    total = 0
    m = int(10**9 + 7)
    s = sum(a)
    s_current = 0
    for i in range(n):
        s_current = s_current + a[i]
        total = (total + a[i] * (s - s_current)) % m

    total = total % m


    return total
    


def main():
    # 出力
    result = solve(*parse_input())
    if isinstance(result, list):
        for r in result:
            print("%s" % r, sep='')
    else:
        print("%s" % result, sep='')

if __name__ == '__main__':

    main()
	


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

int main(){
  int N;
  cin >> N;
  vector<string> s(N);
  for(int i=0;i<N;i++){
    cin>>s.at(i);
    sort(s.at(i).begin(),s.at(i).end());
  }
  sort(s.begin(),s.end());
  long long int ans=0;
  long long int count=0;
  for(int j=1;j<N;j++){
    if(s.at(j-1)==s.at(j)){
      count+=1;
      ans+=count;
      }else{
        count=0;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 7296
#include<iostream>
#include<algorithm>
#include<vector>
#include<string.h>
#include<cstdlib>
#include<map>
#include<fstream>
#include<string>
#include<sstream>
#include<iomanip>
#include<cmath>

using namespace std;

long long dp[3][100100] = {};
const long long INF = 1LL << 60;
#define 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; }

/**
* @fn
* 最大値を取ります.Vector<int>を渡すこと.
*/
long long int imax(vector<int> a) {
	int MAX = -10000000;
	for (int i = 0; i < a.size(); i++) {
		if (MAX < a.at(i)) MAX = a.at(i);
	}
	return MAX;
}

/**
* @fn
* 最小値を取ります.Vector<int>を渡すこと.
*/
long long int imin(vector<int> a) {
	int MIN = 1000000000;
	for (int i = 0; i < a.size(); i++) {
		if (MIN > a.at(i)) MIN = a.at(i);
	}
	return MIN;
}


long long int absmin(vector<int> a, long long int b) {
	int mini = 100000000;
	int d = 0;
	for (int i = 0; i < a.size(); i++) {
		if (mini > abs(a.at(i) - b)) {
			mini = abs(a.at(i) - b);
			d = i;
		}
	}
	return d;
}

int gcd(int a, int b)
{
	if (a < b) swap(a, b);
	if (b < 1) return -1;
	if (a % b == 0) return b;
	return gcd(b, a % b);
}

//ここまでライブラリ
//ここから本文

long long int tpimin(vector<int> a) {
	int MIN = 1000000000;
	int number = 0;
	for (int i = 0; i < a.size(); i++) {
		if (MIN > a.at(i)) MIN = a.at(i);
		number = i;
	}
	return number;
}



int main() {
	int m, n;
	cin >> n >> m;
	vector<string> a(m+2);
	vector<string> b(n+2);
	for (int i = 0; i < m + 2; i++) {
		a.at(i) = string(1000, 'a');
	}
	for (int i = 0; i < n + 2; i++) {
		b.at(i) = string(1000, 'a');
	}

	for (int i = 0; i < n; i++) {
		cin >> b.at(i);
	}
	for (int i = 0; i < m; i++) {
		cin >> a.at(i);
	}
	if (m == 1) {
		for (int i = 0; i < n; i++) {
			if (b.at(i).find(a.at(0).at(0)) != string::npos) {
				cout << "Yes" << endl;
				return 0;
			}
		}
		cout << "No" << endl;
		return 0;
	}

	for (int i = 0; i <= n - m; i++) {
		for (int j = 0; j <= n - m; j++) {
			for (int p = 0; p < m+1; p++) {
				if (p == m) {
					cout << "Yes" << endl;
					return 0;
				}
//				cout << b.at(i + p).substr(j, n) << "|" << a.at(i + p) << endl;
					if (b.at(i + p).substr(j, m) != a.at(p)) break;
			}
		}
	}
	cout << "No" << endl;
}



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

#define IL __inline__ __attribute__((always_inline))

#define For(i, a, b) for (int i = (a), i##end = (b); i <= i##end; ++ i)
#define FOR(i, a, b) for (int i = (a), i##end = (b); i < i##end; ++ i)
#define Rep(i, a, b) for (int i = (a), i##end = (b); i >= i##end; -- i)
#define REP(i, a, b) for (int i = (a) - 1, i##end = (b); i >= i##end; -- i)

typedef long long LL;

template<class T>
IL bool chkmax(T &a, const T &b) {
  return a < b ? ((a = b), 1) : 0;
}

template<class T>
IL bool chkmin(T &a, const T &b) {
  return a > b ? ((a = b), 1) : 0;
}

template<class T>
IL T mymax(const T &a, const T &b) {
  return a > b ? a : b;
}

template<class T>
IL T mymin(const T &a, const T &b) {
  return a < b ? a : b;
}

template<class T>
IL T myabs(const T &a) {
  return a > 0 ? a : -a;
}

const int INF = 0X3F3F3F3F;
const double EPS = 1E-10, PI = acos(-1.0);

#define DEBUG(...) fprintf(stderr, __VA_ARGS__)
#define OK DEBUG("Passing [%s] in LINE %d...\n", __FUNCTION__, __LINE__)
/*------------------------------header------------------------------*/

const int MAXN = 200 + 5;

int len[MAXN];

int main() {
  int n;
  scanf("%d", &n);
  For(i, 1, n << 1) {
    scanf("%d", &len[i]);
  }
  std::sort(len + 1, len + (n << 1) + 1);
  int answer = 0;
  for (int i = 1; i <= n << 1; i += 2) {
    answer += len[i];
  }
  printf("%d\n", answer);
  return 0;
}


Measured memory_bytes: 256
N,K=map(int,input().split())
o=[0]*N
d=[]
A=[]
for i in range(K):
    d.append(int(input()))
    A.append(list(map(int,input().split())))

for i in range(K):
    C=A[i]
    for j in C:
        o[j-1]=1
c=0
for i in o:
    if i==0:
        c+=1

print(c)

Measured memory_bytes: 9224
#pragma region include
#include <iostream>
#include <iomanip>
#include <stdio.h>

#include <sstream>
#include <algorithm>
#include <iterator>
#include <cmath>
#include <complex>

#include <string>
#include <cstring>
#include <vector>
#include <tuple>
#include <bitset>

#include <queue>
#include <complex>
#include <set>
#include <map>
#include <stack>
#include <list>

#include <fstream>
#include <random>
//#include <time.h>
#include <ctime>
#pragma endregion //#include
/////////
#define REP(i, x, n) for(int i = x; i < n; ++i)
#define rep(i,n) REP(i,0,n)
#define ALL(X) X.begin(), X.end()
/////////
#pragma region typedef
typedef long long LL;
typedef long double LD;
typedef unsigned long long ULL;
typedef std::pair<LL,LL> PLL;//
typedef std::pair<int,int> PII;//
#pragma endregion //typedef
////定数
const int INF = (int)1e9;
const LL MOD = (LL)1e9+7;
const LL LINF = (LL)4e18+20;
const LD PI = acos(-1.0);
const double EPS = 1e-9;
/////////
using namespace::std;

void solve(){
	int N,K;
	cin >> N >> K;
	vector<int> hist(N+1,0);
	for(int i=0;i<N;++i){
		int ter;
		cin >> ter;
		hist[ter]++;
	}

	vector<int> num;
	for(int i=1;i<=N;++i){
		if( hist[i] ){
			num.push_back( hist[i] );
		}
	}

	sort( num.begin(),num.end() );
	int size = num.size();
	int ans = 0;
	for(int i=0;i<size-K;++i){
		ans += num[i];
	}

	cout << ans << endl;
}

#pragma region main
signed main(void){
	std::cin.tie(0);
	std::ios::sync_with_stdio(false);
	std::cout << std::fixed;//小数を10進数表示
	cout << setprecision(16);//小数点以下の桁数を指定//coutとcerrで別	

	solve();
}
#pragma endregion //main()

Measured memory_bytes: 2168
fun main(args:Array<String>){
  var n = readLine()!!.toInt()
  var d = readLine()!!.split(" ").map{it.toInt()}.sorted()
  var ans = 0
  if(d[n/2-1] != d[n/2]){
    ans = d[n/2] - d[n/2-1]
  }
  println(ans)
}

Measured memory_bytes: 52456
#include <bits/stdc++.h>
#define int long long

using namespace std;
typedef pair <int, int> ii;

int n, a[200001], b[200001];

int32_t main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
//    freopen("INP.INP", "r", stdin);
//    freopen("OUT.OUT", "w", stdout);
    cin >> n;
    for (int i = 1; i <= n; i++)
        cin >> a[i] >> b[i];
    sort (a + 1, a + n + 1);
    sort (b + 1, b + n + 1);
    if (n % 2 != 0) {
        cout << abs(b[(n + 1) / 2] - a[(n + 1) / 2]) + 1;
    }
    if (n % 2 == 0) {
        int mida = (a[n / 2] + a[n / 2 + 1]);
        int midb = (b[n / 2] + b[n / 2 + 1]);
        cout << abs(mida - midb) + 1;
    }
    return 0;
}


Measured memory_bytes: 6704
#include <stdio.h>

int main(void)
{
	int kai1[3][10],kai2[3][10],kai3[3][10],kai4[3][10];
	int a,b,c,d,e,f,g;
	
	for(b = 0;b < 3;++b){
		for(g = 0;g < 10;++g){
			kai1[b][g] = 0;
		}
	}
	for(b = 0;b < 3;++b){
		for(g = 0;g < 10;++g){
			kai2[b][g] = 0;
		}
	}
	for(b = 0;b < 3;++b){
		for(g = 0;g < 10;++g){
			kai3[b][g] = 0;
		}
	}
	for(b = 0;b < 3;++b){
		for(g = 0;g < 10;++g){
			kai4[b][g] = 0;
		}
	}


	
	scanf("%d",&a);
	
	for(b = 0;b < a;++b){
		scanf("%d %d %d %d",&c,&d,&e,&f);
		if(c == 1 && (d <= 3 && d >= 1) && (e <= 10 && e >= 1) && f <= 9){
			kai1[d-1][e-1] += f;
		}
		if(c == 2 && (d <= 3 && d >= 1) && (e <= 10 && e >= 1) && f <= 9){
			kai2[d-1][e-1] += f;
		}
		if(c == 3 && (d <= 3 && d >= 1) && (e <= 10 && e >= 1) && f <= 9){
			kai3[d-1][e-1] += f;
		}
		if(c == 4 && (d <= 3 && d >= 1) && (e <= 10 && e >= 1) && f <= 9){
			kai4[d-1][e-1] += f;
		}
	}
	
	for(b = 0;b < 3;++b){
		for(g = 0;g < 10;++g){
			if(kai1[b][g] >= 0){
				printf(" %d",kai1[b][g]);
			}
			else if(kai1[b][g] < 0){
				kai1[b][g] = 0;
				printf(" %d",kai1[b][g]);
			}
		}
		printf("\n");
	}
	
	printf("####################\n");
	
	for(b = 0;b < 3;++b){
		for(g = 0;g < 10;++g){
			if(kai2[b][g] >= 0){
				printf(" %d",kai2[b][g]);
			}
			else if(kai2[b][g] < 0){
				kai1[b][g] = 0;
				printf(" %d",kai2[b][g]);
			}
		}
		printf("\n");
	}
	
	
	printf("####################\n");
	
	for(b = 0;b < 3;++b){
		for(g = 0;g < 10;++g){
			if(kai3[b][g] >= 0){
				printf(" %d",kai3[b][g]);
			}
			else if(kai3[b][g] < 0){
				kai3[b][g] = 0;
				printf(" %d",kai3[b][g]);
			}
		}
		printf("\n");
	}
	
	
	printf("####################\n");
	
	for(b = 0;b < 3;++b){
		for(g = 0;g < 10;++g){
			if(kai4[b][g] >= 0){
				printf(" %d",kai4[b][g]);
			}
			else if(kai1[b][g] < 0){
				kai4[b][g] = 0;
				printf(" %d",kai4[b][g]);
			}
		}
		printf("\n");
	}
	
	
	return(0);
}

Measured memory_bytes: 2676
#include "bits/stdc++.h"

using namespace std;
 
const int inf = 1e8;
#define ll long long
#define fr(i,a,n) for (int i=a;i<n;i++)
#define rfr(i,n,a) for (int i=n;i>=a;i--)
#define mp make_pair
#define pb push_back
#define pii pair<int,int>
#define pll pair<ll,ll> 
#define endl "\n"
typedef vector<int> VI;
typedef vector<ll> VL;


ll n,m,k;

int main() {
	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);	
	cin >> n >> m >> k;
	cout << k << " " << n << " " << m << endl;
	return 0;
}

Measured memory_bytes: 256
N=int(input())
c=list(map(int,input().split()))
c.sort()
m=10**9+7
ans=0
for i in range(N):
    ans+=(c[i]*(N-i+1)*pow(2,(N-2)%(m-1),m))%m
print((ans*pow(2,N,m))%m)

Measured memory_bytes: 31624
// https://atcoder.jp/contests/abc159/tasks/abc159_f

#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;

#define REP(i,n)   for(int i=0; i<(int)(n); i++)
#define FOR(i,b,e) for(int i=(b); i<=(int)(e); i++)
#if DEBUG
  #define DUMP(a) REP(_i, a.size()) cout << a[_i] << (_i + 1 == a.size() ? "\n" : " ")
  #define DUMP2D(b) REP(_j, b.size()) DUMP(b[_j]); cout << endl
#else
  #define DUMP(a)
  #define DUMP2D(b)
#endif

const int N_MAX = 3000;
const int S_MAX = 3000;
const int A_I_MAX = 3000;
const int MOD = 998244353;

int N, S;
vector<int> A;

vector<ll> dp;

int main() {
  cin >> N >> S;
  A = vector<int>(N);
  REP(i, N) cin >> A[i];

  ll ans = 0;
  dp = vector<ll>(S + 1, 0);
  REP(i, N) {
    dp[0] = i + 1;
    dp[S] = 0;
    for (int j = S; j >= A[i]; j--) {
      dp[j] = (dp[j] + dp[j - A[i]]) % MOD;
    }
    ans = (ans + dp[S] * (N - i) % MOD) % MOD;
  }

  cout << ans << endl;
}


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

int main(){
  vector<int> hand(5);
  char c;
  
  while(cin >> hand[0]>>c>>hand[1]>>c>>hand[2]>>c>>hand[3]>>c>>hand[4]){
    vector<int> cnt(15, 0);
    for(int i=0; i<5; i++){
      cnt[hand[i]]++;
      if(hand[i] == 1) cnt[14]++;
    }
    bool flag = false;

    // four card
    for(int i=1; i<=13; i++){
      if(cnt[i] == 4){
        cout << "four card" << endl; flag = true;
      }
    }
    if(flag) continue;

    // three card or full house
    for(int i=1; i<=13; i++){
      if(cnt[i] == 3){
        for(int j=1; j<=13; j++){
          if(cnt[j] == 2){
            cout << "full house" << endl; flag = true;
          }
        }
        if(flag) break;
        cout << "three card" << endl; flag = true;
      }
    }
    if(flag) continue;

    // two pair or one pair
    for(int i=1; i<=13; i++){
      if(cnt[i] == 2){
        for(int j=i+1; j<=13; j++){
          if(cnt[j] == 2){
            cout << "two pair" << endl; flag = true;
          }
        }
        if(flag) break;
        cout << "one pair" << endl; flag = true;
      }
    }
    if(flag) continue;

    // straight
    for(int i=1; i<=13; i++){
      if(cnt[i] == 1 && cnt[i+1] == 1 && cnt[i+2] == 1 && cnt[i+3] == 1 && cnt[i+4] == 1){
        cout << "straight" << endl; flag = true;
      }
    }
    if(flag) continue;

    //null
    cout << "null" << endl;
  }

}
  
  


Measured memory_bytes: 3016
/* {{{ Shinobu kawaii */
/*
  ______   __        _                  __                 
.' ____ \ [  |      (_)                [  |                
| (___ \_| | |--.   __   _ .--.   .--.  | |.--.   __   _   
 _.____`.  | .-. | [  | [ `.-. |/ .'`\ \| '/'`\ \[  | | |  
| \____) | | | | |  | |  | | | || \__. ||  \__/ | | \_/ |, 
 \______.'[___]|__][___][___||__]'.__.'[__;.__.'  '.__.'_/ 
                                                           
*/
/* }}} */
/* include {{{ */
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <iostream>
#include <vector>
#include <string>
#include <sstream>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <functional>
using namespace std;
/* }}} */

// #define int long long

/* cpp template {{{ */
/* short */
#define pb push_back
#define mp make_pair
#define print(x) cout << x << '\n'
#define Fi first
#define Se second

/* REPmacro */
#define REPS(i, a, n) for (int i = (a); i < (n); i++)
#define REP(i, n) for (int i = 0; i < (n); i++)
#define RREP(i, n) for (int i = 1; i <= (n); i++)
#define DEPS(i, a, n) for (int i = (a); i >= n; i--)
#define DEP(i, n) for (int i = (n); i >= 0; i--)

/* typedef */
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<vector<int> > vii;
typedef pair<int, int> pii;

/* const */
const int INF = 999999999;
const int dx[] = {0, 1, 0, -1, 1, -1, 1, -1}, dy[] = {1, 0, -1, 0, 1, -1, -1, 1};

/* func */
inline bool is_uruu(int y) {return (y % 4 == 0 && (y % 100 != 0 || y % 400 == 0));}
inline bool inside(int y, int x, int H, int W) {return (y >= 0 && x >= 0 && y < H && x < W);}

/* }}} */

int N, K;
int pasta[128];
int dp[101][4][4];

int dfs(int now, int one, int two)
{
  if (now == N){
    return 1;
  }

  if (dp[now][one][two] != -1){
    return dp[now][one][two];
  }

  int ans = 0;
  if (pasta[now] == 0){
    RREP(i, 3){
      if (one == two && two == i) continue;
      ans += dfs(now + 1, i, one) % 10000;
    }
  } else {
    if (one == two && two == pasta[now]) return 0;
    ans = dfs(now + 1, pasta[now], one) % 10000;
  }

  return dp[now][one][two] = ans;
}

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

  memset(dp, -1, sizeof(dp));
  cin >> N >> K;
  REP(i, K){
    int day, taste;
    cin >> day >> taste;
    pasta[day - 1] = taste;
  }

  print(dfs(0, 0, 0) % 10000);
  
  return (0);
}

Measured memory_bytes: 1208
#include<stdio.h>

int main(void){

  int m,f,r,p;

  while(1){

    scanf(" %d %d %d",&m,&f,&r,&p);
    if(m==-1&&f==-1&&r==-1)
      break;
   p=m+f;
    if(m==-1||f==-1)
      printf("F\n");
    else if(p>=80)
      printf("A\n");
    else if(65<=p&&p<80)
      printf("B\n");
    else if(50<=p&&p<65)
      printf("C\n");
    else if(30<=p&&p<50){
      if(50<=r)
    printf("C\n");
      else
    printf("D\n");
    }
    else if(p<30)
      printf("F\n");
  }

  return 0;

}

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

typedef long long ll;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef vector<vector<vector<ll>>> vvvll;
typedef vector<bool> vb;
typedef vector<vector<bool>> vvb;
typedef vector<vector<vector<bool>>> vvvb;
typedef pair<ll, ll> pll;
typedef vector<pll> vpll;
typedef vector<vpll> vvpll;
typedef vector<double> vd;
typedef vector<vd> vdd;

#define FOR(i,x,y) for(ll i=(ll)x; i<(ll)y; ++i)
#define REP(i,y) FOR(i, 0, y)
#define RFOR(i,x,y) for(ll i=(ll)x; i>=(ll)y; --i)
#define RREP(i,x) RFOR(i, x, 0)
#define ALL(a) a.begin(), a.end()
#define pb push_back
#define debug_print(x...) cerr << "line " << __LINE__ << " : "; debug_print_in(x);

template <typename First>
void debug_print_in(First first){
  cerr << first << endl;
  return;
}

template <typename First, typename... Rest>
void debug_print_in(First first, Rest... rest){
  cerr << first << " ";
  debug_print_in(rest...);
  return;
}

void IN(void){
  return;
}

template <typename First, typename... Rest>
void IN(First& first, Rest&... rest){
  cin >> first;
  IN(rest...);
  return;
}

template <typename First>
void OUT(First first){
  cout << first << endl;
  return;
}

template <typename First, typename... Rest>
void OUT(First first, Rest... rest){
  cout << first << " ";
  OUT(rest...);
  return;
}

template<class t, class u> void chmax(t&a,u b){if(a<b)a=b;};
template<class t, class u> void chmin(t&a,u b){if(a>b)a=b;};
int popcount(int t){return __builtin_popcount(t);} //GCC
int popcount(ll t){return __builtin_popcountll(t);} //GCC

template <typename T>
void vec_print(vector<T> VEC){
  REP(i, VEC.size()){
    cerr << VEC[i] << " ";
  }
  cerr << endl;
};

template <typename T>
void mat_print(vector<vector<T> > MAT){
  REP(i,MAT.size()){
    REP(j,MAT[i].size()){
      cerr << MAT[i][j] << " ";
    }
    cerr << endl;
  }
};

constexpr int INF = (1<<30);
constexpr ll INFLL = 1LL<<62;
constexpr long double EPS = 1e-12;
constexpr ll MOD = (ll)((1E+9)+7);

int main(){
  cin.tie(0); // cut the cin and cout (default, std::flush is performed after std::cin)
  ios::sync_with_stdio(false); // cut the iostream and stdio (DON'T endl; BUT "\n";)

  vll P = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};

  ll K;
  IN(K);

  OUT(P[K-1]);

  return 0;
}

Measured memory_bytes: 256
import math

n = int(input())

#faccs = [0 for i in range(int(n/2) +1)]
faccs = {}


def isPrime(n) : 
  
    if (n <= 1) : 
        return False
    if (n <= 3) :
        return True

    if (n % 2 == 0 or n % 3 == 0) : 
        return False
  
    i = 5
    while(i * i <= n) : 
        if (n % i == 0 or n % (i + 2) == 0) : 
            return False
        i = i + 6
  
    return True

if isPrime(n):
    print(1)
else:
    while n % 2 == 0:
        if 2 in faccs:
            faccs[2] += 1
        else:
            faccs[2] = 1
        n = n / 2

    for i in range(3,int(math.sqrt(n))+1,2): 
          

        while n % i== 0:
            if i in faccs:
                faccs[i] += 1
            else:
                faccs[i] = 1
            n = n / i 

    if n > 2:
        faccs[math.floor(n)] = 1 

    count = 0

    for i in faccs.values():
        if i > 0:
            temp = 1
            while (i-temp)>=0:
                i -= temp
                temp +=1
                count += 1
    print(count)



Measured memory_bytes: 9328
package main

import (
	"bufio"
	"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)

	n := scanInt()
	s := scanInts(n)

	ma := 0
	for i := 1; i < n; i++ {
		done := map[int]bool{}
		sum := 0
		for k := 0;; k++ {
			if n-1-k*i < 0 || (k+1)*(n-1-k*i)-(n-1) < 0{
				break
			}

			if done[k*i] || done[n-1-k*i] || k*i == n-1-k*i {
				break
			}
			done[k*i],done[n-1-k*i] = true, true
			sum += s[k*i]+s[n-1-k*i]
			ma = max(ma, sum)
			// debug(i,k,sum)
		}
	}

	fmt.Fprintln(wr, ma)
}


Measured memory_bytes: 8448