akhauriyash/Code-Regression huggingface dataset:
#define _USE_MATH_DEFINES
#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<string>
#include<iostream>
#include<cctype>
#include<cstdio>
#include<vector>
#include<stack>
#include<queue>
#include <algorithm>
#include<math.h>
#include<set>
#include<map>
#include<iomanip>

//#include<bits/stdc++.h>


using namespace std;



int main() {
	
	int n;
	cin >> n;
	vector<int>y;
	for (int i = 0; i < n*3; i++) {
		int x;
		cin >> x;
		y.push_back(x);
	}
	sort(y.begin(), y.end());
	reverse(y.begin(), y.end());
	long long int ans = 0;
	for (int i = 1; i < 2 * n; i+=2)
		ans += y[i];

	cout << ans << endl;

	return 0;

}


Measured memory_bytes: 2548
(let* ((n (read))
       (a (make-hash-table :size n))
       b)
  (loop :for _ :from 1 :to n
        :for x := (read)
        :do (if (gethash x a) (incf (gethash x a)) (setf (gethash x a) 1)))
  (maphash (lambda (k v) (push (cons k v) b)) a)
  (setf a (sort  b (lambda (x y) (< (car x) (car y)))))
  (format t "~A~%" (if (or (and (= (length a) 1) (= (caar a) 0))
                           (and (= (length a) 2) (= (caar a) 0) (= (cdar a) (/ n 3)))
                           (and (= (length a) 3)
                                (= (cdar a) (cdadr a) (cdaddr a))
                                (= 0 (logxor (caar a) (caadr a) (caaddr a)))))
                       "Yes"
                       "No")))


Measured memory_bytes: 75056
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <bitset>
using namespace std;

#ifdef LOCAL
	#define eprintf(...) fprintf(stderr, __VA_ARGS__);fflush(stderr);
#else
	#define eprintf(...) 42
#endif

using ll = long long;
using ld = long double;
using uint = unsigned int;
using ull = unsigned long long;
template<typename T>
using pair2 = pair<T, T>;
using pii = pair<int, int>;
using pli = pair<ll, int>;
using pll = pair<ll, ll>;
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
ll myRand(ll B) {
	return (ull)rng() % B;
}

#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second

clock_t startTime;
double getCurrentTime() {
	return (double)(clock() - startTime) / CLOCKS_PER_SEC;
}

const ll INF = (ll)1e18;
ll mult(ll x, ll y) {
	if (INF / x < y) return INF;
	return min(INF, x * y);
}
ll mySqrt(ll x) {
	ll y = (ll)sqrt(x);
	while(y * y > x) y--;
	while(y * y < x) y++;
	if (y * y == x) return y;
	return -1;
}

map<ll, int> mapchik;

ll cubeFree(ll x) {
	ll res = 1;
	for (ll p = 2; p * p * p <= x; p++) {
		if (x % p) continue;
		int t = 0;
		while(x % p == 0) {
			x /= p;
			t++;
		}
		t %= 3;
		while(t--) res *= p;
	}
	return res * x;
}
ll getPair(ll x) {
	ll res = 1;
	for (ll p = 2; p * p * p <= x; p++) {
		if (x % p) continue;
		int t = 0;
		while(x % p == 0) {
			x /= p;
			t++;
		}
		assert(t < 3);
		if (t == 1) {
			res = mult(res, p);
			res = mult(res, p);
		} else {
			res = mult(res, p);
		}
	}
	if (x > 1) {
		ll y = mySqrt(x);
		if (y == -1) {
			res = mult(res, x);
			res = mult(res, x);
		} else {
			res = mult(res, y);
		}
	}
	return res;
}

int main()
{
	startTime = clock();
//	freopen("input.txt", "r", stdin);
//	freopen("output.txt", "w", stdout);

	int n;
	scanf("%d", &n);
	while(n--) {
		ll x;
		scanf("%lld", &x);
		mapchik[cubeFree(x)]++;
	}
	int ans = 0;
	if (mapchik.count(1)) {
		ans++;
		mapchik.erase(1);
	}
	while(!mapchik.empty()) {
		ll x = mapchik.begin()->first;
		ll y = getPair(x);
		ans += max(mapchik[x], mapchik[y]);
		mapchik.erase(x);
		mapchik.erase(y);
	}
	printf("%d\n", ans);

	return 0;
}


Measured memory_bytes: 9456
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <set>
#include <cmath>
#define rep(i,n) for (int i = 0; i < n; ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;

int gcd(int a, int b) {
  if (a % b == 0) return b;
  return gcd(b, a % b);
}

int gcd(int a, int b, int c) {
  int ans = 1;
  for (int i = 1; i <= min(min(a,b), c); ++i) {
    if (a % i == 0) {
      if (b % i == 0) {
        if (c % i == 0){
          ans = i;
        }
      }
    }
  }
  return ans;
}

int main() {
  int K;
  cin >> K;
  int ans = 0;
  for (int a = 1; a <= K; a++) {
    for (int b = 1; b <= K; b++) {
      for (int c = 1; c <= K; c++) {
        ans += gcd(gcd(a, b), c);
      }
    }
  }
  cout << ans << endl;
  return 0;
}

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

#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)

#define all(x) (x).begin(), (x).end()

#define INF 100000000

using namespace std;
typedef long long int ll;

ll a, b, c, n, w, h, x, y, z, sum, diff, ans = 0, cnt = 0, mx = 0, mn = INF;
string s;

int main(){
    cin >> s;
    rep(i, s.size()){
        if(s[i] == 'W'){
            ans += i - cnt;
            cnt++;
        }
    }
    cout << ans << endl;
}



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

int main() {
 int n; cin >> n;
 vector<string> s(n);
 rep(i,n)cin >> s[i];
 map<string,int> mp;
  rep(i,n)mp[s[i]]++;

  int cnt=0;
  for(auto c: mp){
    int x=c.second;
    cnt=max(cnt,x);
  }
  vector<string> ans;
  for(auto c: mp){
    int x=c.second;
    if(x==cnt){
      ans.push_back(c.first);
    }
  }
  sort(ans.begin(),ans.end());

  rep(i,ans.size())cout << ans[i] <<endl;

}


Measured memory_bytes: 28404
N = int(input())
s = [int(input()) for _ in range(N)]

s.sort()
ans = sum(s)
cnt = []
Flg = False
if(ans%10 != 0):
    print(ans)
else:
    for i in range(N):
        if(s[i]%10 != 0):
            cnt.append(s[i])
            Flg = True
    if(Flg):
        cnt.sort()
        print(ans-cnt[0])
    else:
        print(0)

Measured memory_bytes: 3064
H, W = map(int, input().split())
a = [list(input()) for _ in range(H)]
a_h = [False]*H
a_w = [False]*W

for i in range(H):
  for j in range(W):
    if a[i][j] == '#':
      a_h[i] = True
      a_w[j] = True

for i in range(H):
  if a_h[i] == True:
    for j in range(W):
      if a_w[j] == True:
        print(a[i][j],end='')
    print()

  

Measured memory_bytes: 4596
abcd = gets.split("").map(&:to_i)

(1 << 3).times do |bit|
  ans = []

  sum = abcd[0]
  ans << abcd[0]

  3.times do |i|
    sum += (-1) ** bit[i] * abcd[i + 1]
    ans << (bit[i] == 0 ? "+" : "-") << abcd[i + 1]
  end

  if sum == 7
    puts "#{ans.join}=7"
    break
  end
end


Measured memory_bytes: 1916
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include<iterator>
#include<complex>
#include<stack>
#include<sstream>
using namespace std;
typedef  long long int lint;
typedef pair<int, int> P;
typedef pair<lint, lint> LLP;
typedef pair<char, char>CP;
#define rep(i, n) for (int i = 0; i < n; i++)
#define repr(i, n) for (int i = n; i >= 0; i--)
#define sort(v) sort((v).begin(), (v).end())
#define reverse(v) reverse((v).begin(), (v).end())
#define upper(v,hoge) upper_bound(v.begin(),v.end(),hoge)
#define lower(v,hoge) lower_bound(v.begin(),v.end(),hoge)
#define llower(v,hoge) *lower_bound(v.begin(), v.end(), hoge)
#define lupper(v,hoge) *upper_bound(v.begin(), v.end(), hoge)
/*
vector<char>al(26);
al = {'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
vector<char>AL(26);
AL = {'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'};
vector<char>NUM(10);
	NUM = { '0','1','2' ,'3' ,'4' ,'5' ,'6' ,'7' ,'8' ,'9' };
*/



int main() {
	int N;
	cin >> N;
	double X;
	string U;
	double ans = 0;
	rep(i, N) {
		cin >> X >> U;
		if (U == "JPY") {
			ans += X;
		}
		else {
			ans += (X * 380000);
		}
	}
	cout <<setprecision(30)<< ans << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;
import java.lang.Math;

class Main {
	public static void main(String args[])
	{
		Scanner sc = new Scanner(System.in);
		int a = Math.abs(sc.nextInt());
		int b = Math.abs(sc.nextInt());
		int c = Math.abs(sc.nextInt());
		if(!(a*a + b*b != c*c))
			System.out.print(a*b/2);
		
	}
}

Measured memory_bytes: 22612
#define rep(i,n) for(ll i=0, i##_len=(n); i<i##_len; ++i)
#define rrep(i,n) for(ll i##_len=(n) ,i=i##_len-1;i>=0;--i)
#define repi(i,a,b) for(ll i=ll(a);i<ll(b);++i)
#define printd(val) std::cout<< #val" = " <<val<<"\n";
#include<bits/stdc++.h>
using ll = long long;
using pii = std::pair<ll,ll>;
using namespace std;
template<class T>T chmin(T a,T b){if(a>b){a^=b;b^=a;a^=b;return 1;}return 0;}
template<class T>T chmax(T b,T a){if(a<b){a^=b;b^=a;a^=b;return 1;}return 0;}

ll n,a,b;
void input(){
    cin>>n>>a>>b;
}
void src(){
    cout<<min(a*n,b);

}

int main(int argc,char* argv[]){
    ios::sync_with_stdio(false);
 //   ifstream in( argv[1] ); cin.rdbuf(in.rdbuf());
    input();
    src();    
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
// #include <numeric> // gcdとかlcmとか C++17から
#include <time.h> // time_t timer; time(&timer); でtimerに現在時刻が代入される．
#include <unistd.h> // sleep関数．引数は秒単位．
using namespace std;

typedef long long ll;

ll my_gcd(ll a, ll b){
	return (b==0) ? a : my_gcd(b, a%b);
}

ll my_lcm(ll a, ll b){
	return a*b / my_gcd(a,b);
}

ll factorial(ll a){
	ll ans = 1;
	for(ll i=a; i>0; i--){
		ans *= i;
	}
	return ans;
}

ll pow(ll a, ll b) {
	ll a_powered = 1;
	for (int i=0; i<b; i++) { a_powered *= a;
	}
	return a_powered;
}


int main(int argc, char *argv[]){
	int a;
	string s;

	cin >> a >> s;

	if(a >= 3200){
		cout << s << endl;
	} else{
		cout << "red" << endl;
	}
}


Measured memory_bytes: 256
N = 60
MOD = 10**9 + 7
n = int(input())
# c1 = [0 for _ in range(N)]
c1 = [0 for _ in range(N)]

a = list(map(int,input().split()))
for i in range(n):
    for j in range(N):
        if a[i] & (1 << j) != 0:
            c1[j] += 1
        # else:
        #     c1[j] += 1

ans = 0
for i in range(n-1):
    for j in range(N):
        if a[i] & (1 << j) != 0:
            c1[j] -=1
        # else:
        #     c0[j] -=1
    for j in range(N):
        if a[i] & (1 << j) != 0:
            ans += (1<<j) * (n-i-1-c1[j])
        else:
            ans += (1<<j) * c1[j]
            #ans += (1<<j) * c1[j]

print(ans % MOD)

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

using namespace std;

#define int long long
#define all(v) begin(v), end(v)
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define reps(i, s, n) for(int i = (int)(s); i < (int)(n); i++)
#define min(...) min({__VA_ARGS__})
#define max(...) max({__VA_ARGS__})

template<class T1, class T2> void chmin(T1 &a, T2 b){if(a>b)a=b;}
template<class T1, class T2> void chmax(T1 &a, T2 b){if(a<b)a=b;}

using pint = pair<int, int>;
using tint = tuple<int, int, int>;
using vint = vector<int>;

const int inf = 1LL << 55;
const int mod = 1e9 + 7;

signed main()
{
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cout << fixed << setprecision(12);

  int H, W;
  char mas[101][101];
  int sy, sx, gy, gx;
  int delay[101][101] = {{}};
  int maki = 0;
  map<pint, int> mp;

  auto in = [&](int y, int x) -> bool {
    return 0 <= y && y < H && 0 <= x && x < W;
  };

  cin >> W >> H;
  rep(i, H) rep(j, W) {
    cin >> mas[i][j];
    chmax(delay[i][j], 1);
    if(mas[i][j] == 'S') sy = i, sx = j;
    else if(mas[i][j] == 'G') gy = i, gx = j;
    else if(mas[i][j] == 'M') mp[make_pair(i, j)] = maki++;
    else if(mas[i][j] == '#') {
      delay[i][j] = inf;
      reps(k, 1, 4) {
	reps(l, -4+k, 4-k+1) {
	  if(in(i-4+k, j+l)) chmax(delay[i-4+k][j+l], k);
	  if(in(i+4-k, j+l)) chmax(delay[i+4-k][j+l], k);
	  if(in(i+l, j-4+k)) chmax(delay[i+l][j-4+k], k);
	  if(in(i+l, j+4-k)) chmax(delay[i+l][j+4-k], k);
	}
      }
    }
  }

  struct state {
    int y, x, bit, dist;
    state(int y = 0, int x = 0, int bit = 0, int dist = 0)
      :y(y), x(x), bit(bit), dist(dist){}
    bool operator < (const state& s) const {
      return dist > s.dist;
    }
  };

  priority_queue<state> que;
  int d[101][101][1<<5];
  int dy[] = {1, 0, -1, 0};
  int dx[] = {0, 1, 0, -1};

  que.emplace(sy, sx, 0, 0);
  rep(i, 101) rep(j, 101) rep(k, 1<<5) d[i][j][k] = inf;
  d[sy][sx][0] = 0;
  while(que.size()) {
    state st = que.top(); que.pop();
    int y = st.y, x = st.x, bit = st.bit, dist = st.dist;
    if(y == gy && x == gx && bit == (1<<maki)-1) {
      cout << dist << endl;
      return 0;
    }
    if(d[y][x][bit] < dist) continue;
    rep(i, 4) {
      int ny = y + dy[i], nx = x + dx[i], nbit = bit;
      if(!in(ny, nx) || mas[ny][nx] == '#') continue;
      if(mas[ny][nx] == 'M') nbit |= 1<<(mp[make_pair(ny, nx)]);
      if(dist + delay[y][x] < d[ny][nx][nbit]) {
	d[ny][nx][nbit] = dist + delay[y][x];
	que.emplace(ny, nx, nbit, d[ny][nx][nbit]);
      }
    }
  }

  return 0;
}

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

using namespace std;

const int N = 100000, M = 100000;

int oo[1 + M * 2], oj[1 + M * 2];

int link(int o, int j) {
	static int _ = 1;
	oo[_] = o, oj[_] = j;
	return _++;
}

int ae[N], hh[N];

int main() {
	int n, m; cin >> n >> m;
	for (int i = 0; i < n; i++)
		cin >> hh[i];
	while (m--) {
		int i, j; cin >> i >> j, i--, j--;
		ae[i] = link(ae[i], j);
		ae[j] = link(ae[j], i);
	}
	int ans = 0;
	for (int i = 0; i < n; i++) {
		bool good = true;
		for (int o = ae[i]; o; o = oo[o]) {
			int j = oj[o];
			if (hh[i] <= hh[j]) {
				good = false;
				break;
			}
		}
		if (good)
			ans++;
	}
	cout << ans << '\n';
	return 0;
}


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

namespace Atcoder
{

    class Atcoderrrrrrr
    {
        static void Main(string[] args)
        {
            long N = long.Parse(Console.ReadLine());
            double ans = 0;
            for (int i = 0; i <= N; i++)
            {
                double obj = Math.Pow(i,2);
                if(obj<=N){
                    ans = obj;
                }else{
                    break;
                }
            }
            Console.WriteLine(ans);
        }
    }
}


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

int main(){
    char a;
    cin >> a;
    if(a >= 'a' && a <= 'z'){
        cout << 'a' << endl;
    }
    else{
        cout << 'A' << endl;
    }
}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
int main(){
    int N; cin >> N;
    vector<char> mark(N), mark_s(N);
    vector<int> num(N), num_s(N);
    string s;
    for(int i = 0; i < N; i++){
        cin >> s;
        mark[i] = s[0]; num[i] = s[1];
        mark_s[i] = s[0]; num_s[i] = s[1];
    }
    //Bubble
    for(int i = 0; i < N-1; i++){
        for(int j = N-1; j > i; j--){
            if(num[j-1] > num[j]){
                int t = num[j-1];
                num[j-1] =  num[j];
                num[j] = t;
                char tm = mark[j-1];
                mark[j-1] = mark[j];
                mark[j] = tm;
            }
        }
    }

    //Select
    for(int i = 0; i < N; i++){
        int temp = i;
        for(int j = i; j < N; j++){
            if(num_s[j] <  num_s[temp]){
                temp = j;
            }
        }
        if(i != temp){
            int t = num_s[i];
            num_s[i] = num_s[temp];
            num_s[temp] = t;
            char tm = mark_s[i];
            mark_s[i] = mark_s[temp];
            mark_s[temp] = tm;
        }
    }
    for(int i = 0; i < N; i++){
        cout << mark[i] << num[i]-'0';
        if(i != N-1) cout << ' ';
    }
    cout << endl;
    cout << "Stable"<< endl;

    bool flag = true;
    for(int i = 0; i < N; i++){
        cout << mark_s[i] << num_s[i]-'0';
        if(i != N-1) cout << ' ';
        if(flag){
            if(mark[i] != mark_s[i]){
                flag =  false;
            }
        }
    }
    cout << endl;
    if(flag) cout << "Stable"<< endl;
    else cout << "Not stable"<< endl;
}


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

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

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

struct Edge {
  int to;
  int weight;
  Edge(int to, int weight): to(to), weight(weight) {}
};

using Tree = vector<vector<Edge>>;

// 1: 黒, 0: 白, -1:未訪問
vector<int> color;

bool DFS(const Tree &T, int v, int current_color = 0) {
  color[v] = current_color;
  for (auto e: T[v]) {
    if (color[e.to] != -1) {
      if ((e.weight%2 == 1 && color[e.to] == current_color) &&
          (e.weight%2 == 0 && color[e.to] != current_color)) {
            return false;
      } else {
        continue;
      }
    }

    if (e.weight%2 == 0) {
      if (!DFS(T, e.to, current_color)) {
        return false;
      }
    } else {
      if (!DFS(T, e.to, 1 - current_color)) {
        return false;
      }
    }
  }
  return true;
}

int main(){
  int N; cin >> N;
  Tree T(N);
  for (int i = 0; i < N-1; i++) {
    int u, v, w; cin >> u >> v >> w; u--; v--;
    T[u].push_back(Edge(v, w));
    T[v].push_back(Edge(u, w));
  }
  color.assign(N, -1);
  for (int v = 0; v < N; v++) {
    if (color[v] != -1) continue;
    if (DFS(T, v)) break;
  }
  for (int v = 0; v < N; v++) cout << color[v] << endl;
  return 0;
}

Measured memory_bytes: 8192
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <functional>
#include <queue>
#include <string>
#include <cstring>
#include <numeric>
#include <cstdlib>
#include <cmath>
using namespace std;

typedef long long ll;

#define INF 10e10
#define rep(i,n) for(int i=0; i<n; i++)
#define rep_r(i,n,m) for(int i=m; i<n; i++)
#define MAX 100
#define MOD 1000000007
#define pb push_back

/* add vars here */

ll n,m,q;
int p[505][505];

/* add your algorithm here */

int main() {
  cin >> n >> m >> q;

  rep(i,m) {
    int a,b;
    scanf("%d %d", &a, &b);
    p[a][b]++;
  }

  for (int i = 1; i <= n; ++i) {
    for (int j = 1; j <= n; ++j) {
      p[i][j] += p[i-1][j];
    }
  }

  for (int i = 1; i <= n; ++i) {
    for (int j = 1; j <= n; ++j) {
      p[i][j] += p[i][j-1];
    }
  }

  /*for (int i = 0; i <= n; ++i) {
    for (int j = 0; j <= n; ++j) {
      cout << p[i][j] << " ";
    }

    cout << endl;

  }*/

  for (int i = 0; i < q; ++i) {
    int tp,tq;
    scanf("%d %d", &tp, &tq);
    int ans = p[tq][tq] - p[tp-1][tq] - p[tq][tp-1] + p[tp-1][tp-1];
    cout << ans << endl;
  }
}


Measured memory_bytes: 1920
#include<bits/stdc++.h>
using namespace std;
int n,wt;
long long a[100007];
long long v[100007];
long long mem[107][100007];
long long res = 0;

long long swim(int i=0,int wzn=wt)
{
    if(i == n || wzn == 0)
        return 0;
    long long &r = mem[i][wzn];
    if(~r)
        return r;
    return r= max(swim(i+1,wzn), a[i] <= wzn ? swim(i+1,wzn - a[i]) + v[i] : 0 );
}

int main()
{
    cin>>n>>wt;
    for(int i=0;i<n;++i)
        cin>>a[i]>>v[i];
    memset(mem,-1,sizeof(mem));
    cout<<swim()<<endl;
    return 0;
}


Measured memory_bytes: 84224
#include <iostream>
#include <iomanip>
#include <utility>
#include <cmath>
#include <random>
#include <vector>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <string>
#include <algorithm>
using namespace std;

#define rep(i,n) for(int i = 0; i<n; ++i)
#define REP(i,n) for(int i = 1; i<=n; ++i)
#define all(x) begin(x),end(x)
#define show(obj) {for(auto x:obj)cout<<x<<' ';cout<<endl;}
#define line "----------"
typedef long long ll;
typedef pair<int,int> ip;
typedef pair<ll,ll> lp;
const int inf = 1001001000;
const ll INF = 1LL<<60;
const int MOD = (int)1e9 + 7;

int main(){
	string day[7] = {"SUN","MON","TUE","WED","THU","FRI","SAT"};
	string s; cin>>s;
	int t; 
	rep(i,7){
		if(s == day[i]){
			t = i; break;
		}
	}
	cout<<7-t<<endl;
	return 0;
}

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

int main() {
    int n, k;
    cin >> n >> k;
    vector<pair<int, int>> sushi(n);
    rep(i, n) cin >> sushi[i].second >> sushi[i].first;
    sort(sushi.begin(), sushi.end());

    vector<bool> type_set(n + 1, false);
    stack<int> to_del;
    ll sum = 0, type = 0;
    for (int i = n - 1; i >= n - k; i--) {
        sum += sushi[i].first;
        if (type_set[sushi[i].second]) {  // second (or more) times to see this type
            to_del.push(sushi[i].first);
        } else {  // first time to see this type
            type_set[sushi[i].second] = true;
            type++;
        }
    }
    ll ans = sum + type * type;
    for (int i = n - k - 1; i >= 0; i--) {
        if (type_set[sushi[i].second]) continue;
        // i th sushi is the type never seen
        if (to_del.empty()) continue;
        // and there's some sushi that shares the same type
        sum -= to_del.top();
        to_del.pop();
        sum += sushi[i].first;
        type_set[sushi[i].second] = true;
        type++;
        ans = max(ans, sum + type * type);
    }
    cout << ans << endl;
}

// int main() {
//     int n, k;
//     cin >> n >> k;
//     vector<pair<ll, ll>> s(n);
//     rep(i, n) cin >> s[i].second >> s[i].first;
//     sort(ALL(s), greater<>());
//     ll sum = 0, type = 0;
//     for (int i = 0; i < k; i++) {
//         sum += s[i].first;
//         if (!v[s[i].second]) {
//             type++;
//             v[s[i].second] = 1;
//         } else {
//             v2.push(s[i].first);
//         }
//     }
//     ll ans = sum + type * type;
//     for (int i = k; i < n; i++) {
//         if (v[s[i].second] == 1)
//             continue;
//         else {
//             if (v2.empty()) break;
//             sum += s[i].first;
//             v[s[i].second] = 1;
//             sum -= v2.top();
//             v2.pop();
//             type++;
//         }
//         ans = max(ans, (sum + type * type));
//     }
//     cout << ans << endl;
// }


Measured memory_bytes: 1152
#pragma G++ optimize (2)
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <algorithm>
#include <string>
#include <queue>
#define INF 0x3f3f3f3f
#define NO 200005
#define MO 100005
typedef long long ll;
typedef double db;
using namespace std;
inline ll read()
{
	char ch = ' ', last;
	ll ans = 0;
	while (ch < '0' || ch > '9')
		last = ch, ch = getchar();
	while (ch >= '0' && ch <= '9')
		ans = ans * 10 + int(ch - '0'), ch = getchar();
	if (last == '-')
		return -ans;
	return ans;
}
void write(ll x)
{
	if (x >= 10)
		write(x / 10);
	putchar(x % 10 + '0');
}
//head

int n, cnt, head[NO];
bool book[NO];
struct node
{
	int next, to, cost;
}edge[NO * 2];
//variable

void add(int from, int to, int cost)
{
	edge[++cnt].next = head[from];
	edge[cnt].cost = cost;
	edge[cnt].to = to;
	head[from] = cnt;
}
void init()
{
	n = read();
	for (int i = 1; i < n; i++)
	{
		int x = read(), y = read(), z = read();
		add(x, y, z), add(y, x, z);
	}
}
void dfs(int now, int last)
{
	for (int i = head[now]; i; i = edge[i].next)
		if (edge[i].to != last)
		{
			if (edge[i].cost % 2)
				book[edge[i].to] = book[now] ^ 1;
			else
				book[edge[i].to] = book[now];
			dfs(edge[i].to, now);
		}
}
//functions

int main()
{
	init();
	book[1] = true, dfs(1, 0);
	for (int i = 1; i <= n; i++)
		cout << book[i] << endl;
	return 0;
}
//main

Measured memory_bytes: 7296
#include<iostream>
#include<cstdio>
#include<vector>
#include<algorithm>

using namespace std;
int X,Y,imap[20][20];
const int dx[3] = {-1,0,1};
const int dy[3] = {1,1,1};
int sam,dp[20][20];

int solve(){
  
  int ans = 0;
  for(int i=0;i<=Y;i++)for(int j=0;j<=X;j++)dp[i][j] = (i==0 && imap[i][j] != 1)?1:0; 

  for(int i=0;i<Y-1;i++){
    for(int j=0;j<X;j++){
      if(dp[i][j] == 0 || imap[i][j] == 1)continue;
      if(imap[i][j] == 0){
	for(int k=0;k<3;k++){
	  int nx = j+dx[k],ny = i+dy[k];
	  if(0<= nx && nx<X && 0<= ny && ny < Y && imap[ny][nx] != 1){
	      if((k == 0 || k == 2) && imap[ny][nx] == 2)continue;
	      dp[ny][nx]+=dp[i][j];
	  }
	}
      }
      else if(imap[i][j] == 2){
	if(i+2 < Y && imap[i+2][j] != 1){
	  dp[i+2][j]+=dp[i][j];
	}
	else if(i+2 >= Y){
	  //if(imap[Y-1][j] != 1)
	    dp[Y-1][j]+=dp[i][j];
	}
      }
    }
  }
  /*
  cout << endl;
    for(int i=0;i<Y;i++){
      for(int j=0;j<X;j++)cout << dp[i][j] << " ";
	cout << endl;
    }
  */
    for(int i=0;i<X;i++)ans += dp[Y-1][i];
    return ans;
}



bool Init(){
  cin >> X >> Y;
  if(X+Y == 0)return false;
  for(int i=0;i<Y;i++){
    for(int j=0;j<X;j++){
      cin >> imap[i][j];
    }
  }
  sam = 0;
  return true;
}



int main(){
  while(true){
    if(!Init())break;
    cout << solve() << endl;
  }
  return 0;
}

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

int main(){
   int n;cin>>n;
   int F[50];

   F[0] = F[1] = 1;
   for(int i = 2; i < 50; i++) {
      F[i] = F[i-2] + F[i-1];
   }
   cout << F[n] << endl;
   return 0;
}



Measured memory_bytes: 3096
#include<iostream>
#include<string>
#include<vector>
#include<math.h>
#include<algorithm>
#define ll long long
using namespace std;
struct dog {
	string a;
	int b;
};
int main()
{
	//dog shiba; dog pa;
	//cin >> shiba.a >> pa.a;
	//cin >> shiba.b >> pa.b;
	//string key;
	//cin >> key;
	//if (shiba.a == key)shiba.b -= 1;
	//else if (pa.a == key)pa.b -= 1;
	//cout << shiba.b << " " << pa.b;

	//string key;
	//cin >> key;
	//for (int i = 0; i < key.length(); i++)
	//{
	//	cout << "x";
	//}

	int n;
	cin >> n;
	vector<ll>dog;
	for (int i = 0; i < n; i++)
	{
		ll a;
		cin >> a;
		dog.push_back(a);
	}
	sort(dog.begin(), dog.end());
	for (int i = 0; i+1 < n; i++)
	{
			if (dog[i] == dog[i+1])
			{
				cout << "NO";
				exit(0);
			}	 
	}

	cout << "YES";
}



Measured memory_bytes: 5344
from itertools import product
from bisect import bisect_left

def main():
    while True:
        N, M = map(int, input().split())
        if N == M == 0:
            break
        p = [int(input()) for _ in range(N)]
        p.append(0)
        points = []
        for i in range(N + 1):
            for j in range(i, N + 1):
                points.append(p[i] + p[j])
        points.sort()
        ans = 0
        for i in range(len(points)):
            index = bisect_left(points, M - points[i])
            if index != 0:
                ans = max(ans, points[i] + points[index - 1])
        print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 28444
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <iostream>
#include <queue>
using namespace std;
int n;
long long d[400][400],g[400][400],flag=0,vis[400][400];
main()
{
	scanf("%lld",&n);
	for (int i=1;i<=n;i++)
		for (int j=1;j<=n;j++)
			scanf("%d",&g[i][j]),d[i][j]=g[i][j];
	
	for (int k=1;k<=n;k++)
		for (int i=1;i<=n;i++)
			for (int j=1;j<=n;j++)
			if (i!=k && j!=k)
			{
//				if (d[i][j]>g[i][k]+g[k][j]) 
//					d[i][j]=g[i][k]+g[k][j];
				if (d[i][j]>=d[i][k]+d[k][j]) 
				{
					if (d[i][j]>d[i][k]+d[k][j]) 
					flag=1;
					d[i][j]=d[i][k]+d[k][j],vis[i][j]=1;
					
				}
			}
	long long sum=0;
	for (int i=1;i<=n;i++)
		for (int j=1;j<=n;j++)
			if (!vis[i][j])
				sum+=d[i][j];
	if (flag)
		puts("-1");
	else
	printf("%lld",sum/2);
	
}

Measured memory_bytes: 3072
#include<iostream>
#include<vector>
#include<algorithm>
#include<complex>
#include<string.h>
#include<string>
using namespace std;
typedef long long int llint;
int main() {
	int n;
	char s[110];
	cin >> n >> s;
	vector<int>x(n + 1);
	x[0] = 0;
	for (int i = 1;i <= n;i++) {
		if (s[i - 1] == 'I') {
			x[i] = x[i - 1] + 1;
		}
		else {
			x[i] = x[i - 1] - 1;
		}
	}
	sort(x.begin(), x.end());
	cout << x[n] << endl;
	return 0;
}

Measured memory_bytes: 256
<?php
  
fscanf(STDIN,"%d %d %d",$n,$k,$q);
$a_li = array();

for($i=0;$i<$q;$i++){
  $a_li[] = trim(fgets(STDIN));
}

$res = array();

foreach($a_li as $a){
  $res[$a]++;
}


$life = $k;

for($i=1;$i<=$n;$i++){
  
  if(!empty($res[$i])){
    $life = $life+$res[$i];
  }
	$life -= $q;
  if($life<=0){
    echo "No\n";
  }else{
    echo "Yes\n";
  }
  
  $life = $k;
}



Measured memory_bytes: 14836
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int64_t MOD=1000000007;
const long long INF = 1LL<<60;

void YN(bool x){
  if(x) cout<<"Yes";
  else cout<<"No";
}
int main() {
  bool J=false;
  int N,C=0; cin>>N;
  rep(i,N){
    int A,B; cin>>A>>B;
    if(A==B){
      C++;
    }
    else{
      if(C>=3) J=true;
      C=0;
    }
  }
  if(C>=3) J=true;
  YN(J);
}

Measured memory_bytes: 3588
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define USE_LLONG_AS_INT
#ifdef USE_LLONG_AS_INT
#define int long long
#define inf (1ll<<60)
#else
#define inf (1<<30)
#endif
#define rep(i,n) for(int i=0;i<n;i++)
#define Rep(i,a,b) for(int i=a;i<b;i++)
#define REP(i,a,b) for(int i=a;i<=b;i++)
#define rev(i,n) for(int i=(n)-1;i>=0;i--)
#define vi vector<int>
#define vvi vector<vi>
#define pb push_back
#define pi pair<int,int>
#define vp vector<pair<int,int>>
#define mp make_pair
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define MEMSET(a) memset(a,0,sizeof(a))
#define Yes(f) cout<<(f?"Yes":"No")<<endl
#define yes(f) cout<<(f?"yes":"no")<<endl
#define YES(f) cout<<(f?"YES":"NO")<<endl
#define SORT(v) sort(all(v))
#define RSORT(v) sort(all(v), greater<int>())

using namespace std;

const int mod=1e9+7;
const string sp=" ";

void run();

void init() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout<<fixed<<setprecision(12);
}

signed main(){
    init();
    run();
    return 0;
}

void run(){
    string s;
    cin>>s;
    int n=s.length();
    vi r(n),l(n);
    rep(i,n){
        if(s[i]=='R')r[i]++;
        else l[i]++;
    }
    rev(i,n-1)if(r[i])r[i]+=r[i+1];
    Rep(i,1,n)if(l[i])l[i]+=l[i-1];
    // rep(i,n)cout<<r[i]<<sp;cout<<endl;
    // rep(i,n)cout<<l[i]<<sp;cout<<endl;
    vi ans(n);
    rep(i,n){
        if(s[i]=='R'){
            ans[i+r[i]-r[i]%2]++;
        }
        else{
            ans[i-l[i]+l[i]%2]++;
        }
    }
    rep(i,n)cout<<ans[i]<<sp;
}

Measured memory_bytes: 3024
#include <bits/stdc++.h>
typedef long long ll;
#define rep(i,n) for(ll i=0;i<(n);i++)
#define repr(i,n) for(ll i=(n-1);i>=0;i--)
#define pb push_back
#define mp make_pair
#define all(x) x.begin(),x.end()
#define br cout << endl;
using namespace std;
const int INF = 1e9;
const int MOD = 1e9+7;
using Graph = vector<vector<ll>>;
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;}

// 0 false, 1 true 
// string to int : -48
// ceil(a)  1.2->2.0
// c++17	g++ -std=c++17 a.cpp

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

    for(ll i = 1; i < 1251; i++){
        if(floor(i*0.08) == a && floor(i*0.1) == b){
            cout << i << endl;
            return 0;
        }
    }

    cout << -1 << endl;
    return 0;


}

Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
ll a7=1000000007;
ll inf=1000000000000000;
typedef pair<ll,ll> l_l;
#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define pb push_back


ll min(ll a,ll b){
    if(a<b)return a;
    return b;
}
ll max(ll a,ll b){
    if(a>b)return a;
    return b;
}

ll c[100010];

int main(){
    ll n;cin>>n;
    ll a[n];
    rep(i,0,n-1){
        cin>>a[i];
        c[a[i]-1]++;
        c[a[i]]++;
        c[a[i]+1]++;
    }
    ll ans=-1;
    rep(i,0,100000){
        ans=max(ans,c[i]);
    }
    cout<<ans<<endl;
    
    return 0;
}







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

typedef long long ll;
const ll MOD = 1000000007;

int main(){
  int n;
  string s;
  cin >> n >> s;
  static bool dp[1400];
  for(int i = 0 ; i < 1400 ; i ++)dp[i]=false;
  for(int i = 0 ; i < n ; i ++){
    int d = s[i]-'0'+1;
    for(int j = 1 ; j <= 10 ; j ++){
      for(int k = 1 ; k <= 10 ; k ++){
        if(dp[11*j+k])dp[121*j+11*k+d] = true;
      }
    }
    for(int j = 1 ; j <= 10 ; j ++){
      if(dp[j])dp[11*j+d]=true;
    }
    dp[d] = true;
  }
  int ret = 0;
  for(int i = 1 ; i <= 10 ; i ++){
    for(int j = 1 ; j <= 10 ; j ++){
      for(int k = 1 ; k <= 10 ; k ++){
        if(dp[121*j+11*k+i])ret ++;
      }
    }
  }
  cout << ret << endl;
}

Measured memory_bytes: 256
while True:
    n = input()
    s = input().split()
    n = int(n)
    s = list(map(int,s))
#for i in s:
 #       s[i]=int(s[i])
    if n==len(s):
        break
x=0
for i in range(0,n):
    for j in range(i+1,n):
        x+=s[i]*s[j]

print(x) 

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vint;
typedef pair<int,int> pint;
typedef vector<pint> vpint;
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,n) for(int i=n-1;i>=(0);i--)
#define reps(i,f,n) for(int i=(f);i<(n);i++)
#define each(it,v) for(__typeof((v).begin()) it=(v).begin();it!=(v).end();it++)
#define all(v) (v).begin(),(v).end()
#define eall(v) unique(all(v), v.end())
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
const int MOD = 1e9 + 7;
const int INF = 1e9;
const ll INFF = 1e18;

int n;
int a[110];
int memo[10];
int main(void){
	cin >> n;
	rep(i, n){
		cin >> a[i];
	}
	rep(i, n){
		if(a[i] < 3200)memo[a[i] / 400]++;
		else memo[8]++;
	}

	int cnt = 0;
	rep(i, 8) if(memo[i] > 0)cnt++;
	if(cnt != 0){
		printf("%d %d\n", cnt, cnt + memo[8]);
	}else{
		printf("%d %d\n", 1, cnt + memo[8]);
	}
	return 0;
}

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

using namespace std;

int main() {
    unsigned int n;
    long long k;
    cin >> n >> k;

    long long ans = k;
    for (int i = 0; i < n - 1; ++i) {
        ans *= k - 1;
    }
    cout << ans;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
using namespace std;
typedef long long ll;
const int mod = 100000007;

struct Combination{
    int n;
    vector<vector<int>> dp;

    Combination(int i){
        n = i;
        dp = vector<vector<int>>(n+1, vector<int>(n+1, 0));
        constructTriangle();
    }

    void constructTriangle(){
        dp[0][0] = 1;
        for(int i = 1; i <= n; i++){
            dp[i][0] = dp[i-1][0];
            for(int j = 1; j <= i; j++){
                dp[i][j] = (dp[i-1][j] + dp[i-1][j-1]) % mod;
            }
        }
    }

    // return aCb
    int getCombination(int a, int b){
        return dp[a][b];
    }
};

int main(){
    Combination comb(1001);

    int r, c, ax, ay, bx, by;
    cin >> r >> c >> ax >> ay >> bx >> by;

    int mind = 1001;
    for(int i = -1; i <= 1; i++){
        for(int j = -1; j <= 1; j++){
            int nx = bx + i*r, ny = by + j*c;
            mind = min(mind, abs(nx-ax) + abs(ny-ay));
        }
    }

    ll ans = 0;
    for(int i = -1; i <= 1; i++){
        for(int j = -1; j <= 1; j++){
            int nx = bx + i*r, ny = by + j*c;
            int x = abs(nx-ax), y = abs(ny-ay);
            if(x+y != mind)   continue;
            ans += comb.getCombination(x+y, x);
            ans %= mod;
        }
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 6688
# N, A, B = gets.split(" ").map(&:to_i)
# S = gets.chomp
N = gets.to_i
A = gets.split(" ").map(&:to_i)
B = gets.split(" ").map(&:to_i)
C = gets.split(" ").map(&:to_i)

prev = 0
sum = 0
A.each do |a|
    sum += B[a - 1]
    sum += C[a - 2] if prev == a - 1 && a >= 2
    prev = a
end

puts sum


Measured memory_bytes: 3836
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rep1(i, n) for (int i = 1; i <= (n); ++i)
#define Sort(Array) sort(Array.begin(), Array.end())
#define Reverse(a) reverse(a.begin(), a.end())
#define out(ans) cout << ans << endl;

int main(){
    int A,B,C,K;

    cin>>A>>B>>C;
    cin>>K;
    int cnt = 0;
    while(B<=A){
        B*=2;
        cnt++;
    }
    while(C<=B){
        C*=2;
        cnt++;
    }
    if(cnt<=K) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}


Measured memory_bytes: 3616
#include <queue>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
namespace IO
{
	char buf[1 << 20 | 1] , *f1 = buf , *f2 = buf , pbuf[1 << 24 | 1] , *f3 = pbuf , sta[100];
	#define gc() ((f1 == f2) && (f2 = (f1 = buf) + fread(buf,1,sizeof buf,stdin),f1 == f2) ? EOF : *f1 ++)
	#define gt() getchar()
	inline int read()
	{
		int x = 0 , f = 1; char ch = gt();
		while(ch < '0' || ch > '9')	{if(ch == '-')	f = -1; ch = gt();}
		while(ch >= '0' && ch <= '9') {x = (x << 3) + (x << 1) + (ch ^ 48); ch = gt();}
		return x * f;
	}
	template <class T> inline void write(T x)
	{
		if(!x) return (void)(*f3 ++ = 48 , *f3 ++ = ' ');
		if(x < 0) *f3 ++ = '-' , x = ~x + 1;
		char *top = sta;
		while(x) *top ++ = x % 10 + 48 , x /= 10;
		while(top != sta) *f3 ++ = *-- top;
		*f3 ++ = ' ';
	}
	inline void put(std::string s)
	{
		int len = s.length();
		for(int i = 0;i < len;i ++) *f3 ++ = s[i];
		*f3 ++ = ' ';
	}
	inline void endline() { *f3 ++ = '\n';}
	#define flush() fwrite(pbuf,1,f3 - pbuf,stdout)
	template <class T> inline T abs(T a) { return a < 0 ? -a : a;}
	template <class T> inline T max(T a,T b) { return a > b ? a : b;}
	template <class T> inline T min(T a,T b) { return a < b ? a : b;}
	template <class T> inline void swap(T &a,T &b) { T t = a; a = b; b = t;}
}
using namespace IO;
#define int long long
const int N = 2e5 + 5, M = 1e6 + 5;
int n, a[N], mx, v[M], prime[M], tot, mu[M];
ll ans, t[M], inv[M], f[M], sum, F[M];
const int mod = 998244353;
void init(int n)
{
	mu[1] = 1;
	for(int i = 2; i <= n; i ++)
	{
		if(!v[i]) {prime[++ tot] = i; mu[i] = -1;}
		for(int j = 1; j <= tot && prime[j] * i <= n; j ++)
		{
			v[i * prime[j]] = 1;
			if(i % prime[j] == 0)
			{
				mu[i * prime[j]] = 0;
				break;
			}
			mu[i * prime[j]] = - mu[i];
		}
	}
	inv[0] = inv[1] = 1;
	for(int i = 2; i <= n; i ++) inv[i] = (mod - mod / i) * inv[mod % i] % mod;
}
signed main() 
{
	n = read();
	for(int i = 1; i <= n; i ++) a[i] = read(), t[a[i]] ++, mx = max(mx, a[i]), sum = (sum + a[i]) % mod;
	init(mx);
	for(int i = 1; i <= mx; i ++)
	{
		for(int j = i; j <= mx; j += i) F[i] = (F[i] + t[j] * j) % mod;
		F[i] = (F[i] * F[i]) % mod;
	}
	for(int i = 1; i <= mx; i ++) for(int j = i; j <= mx; j += i) f[i] = (f[i] + (F[j] * mu[j / i] % mod + mod)) % mod;
	for(int d = 1; d <= mx; d ++) ans = (ans + inv[d] * f[d] % mod) % mod;
	ans = (ans - sum + mod) % mod * inv[2] % mod;
	printf("%lld\n", (ans + mod) % mod);
	return 0;
}

Measured memory_bytes: 53504
N = int(input())
L = sorted([int(i) for i in input().split()])
from bisect import bisect_left
ans = 0
for i1,a in enumerate(L[:-2]):
    L_temp = L[i1+1:-1]
    for i2,b in enumerate(L_temp):
        L_temp2 = L[i1 + i2 + 2:]
        ans += bisect_left(L_temp2,a+b)
print(ans)
            

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

int main() {
  int x, y, k;
  cin >> x >> y >> k;
  for (int i = 0; i <= x; i++) {
    for (int j = 0; j <= y; j++) {
      int s = i*(y-j)+(x-i)*j;
      if (s == k) {
        cout << "Yes" << endl;
        return 0;
      }
    }
  }
  cout << "No" << endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <cstdlib>
int main(){
    int a[100005]={0,},k;
    char s[100005];
    scanf("%s",s);
    scanf("%d",&k);
    int len=(int)strlen(s);
    for(int i=0;i<len;i++)
        a[i]=s[i]-'a';
    for(int i=0;i<len;i++){
        if(!a[i])
            continue;
        else
            a[i]=(26-a[i]);
    }
    for(int i=0;i<len&&(k>0);i++)
        if(a[i]<=k){
            k-=a[i];
            a[i]=0;
            s[i]='a';
        }
    if(k!=0)
        s[len-1]=char(s[len-1]+k%26);
    printf("%s",s);
}

Measured memory_bytes: 768
#include<iostream>
#include<vector>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);++i)
using ll = long long;
using P = pair<int, int>;
#include<algorithm>
#include<math.h>
#include<map>
#include<queue>

int main() {
	int k;
	cin >>k ;
	queue<ll>q;
	rep(i, 9) {
		q.push(i + 1);
	}
	ll c(0);
	while (!q.empty()) {
		ll s = q.front(); q.pop(); ++c;
		if (c == k) {
			cout << s;
			return 0;
		}
		//cout << s << endl;
		ll iti = s % 10;
		ll n;
		if (iti >= 1) {
			q.push(s * 10 + iti - 1);
		}
		q.push(s * 10 + iti);
		if (iti < 9) {
			q.push(s * 10 + iti+1);
		}
	}
	return 0;
}

Measured memory_bytes: 1792
import numpy as np

t = np.array([int(input()) for _ in range(5)])
t_wasted = (10 - t % 10) % 10
t_total = t + t_wasted

last = np.argmax(t_wasted)

ans = 0
for i in range(5):
    if i != last:
        ans += t_total[i]
    else:
        ans += t[i]

print(ans)

Measured memory_bytes: 14480
#include<iostream>
#include<cstdio>
#define ll long long
using namespace std;
int n,m;
ll xx[100000+5];
ll yy[100000+5];
ll x[100000+5];
ll y[100000+5];
ll MOD = 1e9+7;
int main(){
        while( scanf("%d%d",&n,&m) != EOF){
                for(int i = 1;i <= n;++i) scanf("%lld",&xx[i]);
                for(int i = 1;i <= m;++i) scanf("%lld",&yy[i]);
                for(int i = 1;i <= n-1;++i) x[i] = xx[i+1] - xx[i];
                for(int i = 1;i <= m-1;++i) y[i] = yy[i+1] - yy[i];
                n--;m--;
                ll sumx = 0;
                ll sumy = 0;
                for(int i = 1;i <= n;++i){
                        sumx += x[i]*(n-i+1)%MOD*i%MOD;
                        sumx %= MOD;
                }
                for(int i = 1;i <= m;++i){
                        sumy += y[i]*(m-i+1)%MOD*i%MOD;
                        sumy %= MOD;
                }
                printf("%lld\n",sumx*sumy%MOD);
        }
        return 0;
}


Measured memory_bytes: 3328
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define pf push_front
#define fr first
#define sc second
#define r_0 return 0
#define ld long double

using namespace std;

    const ll N = 1e5 + 7;
    const ll mod = 1e9 + 7;
ll n , cnt ;
int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    cin >> n;
    ll arr[n + 1];
    for( int i = 0;i < n;i ++ )
        cin >> arr[i] , cnt^=arr[i];
    for( int i = 0;i < n;i ++ ){
        cout << (cnt ^ arr[i]) << " ";
    }
}


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

int main(){
    vector<int> a(9);
    vector<int> result(9, 0);
    int n;
    for(int i = 0; i < 9; i++){
        cin >> a.at(i);
    }
    cin >> n;

    int tmp;
    for(int j = 0; j < n; j++){
        cin >> tmp;
        for(int i = 0; i < 9; i++){
            if(a.at(i) == tmp){
                result.at(i) = 1;
            }
        }
    }

    /*for(int i = 0; i < 9; i++){
        cout << result.at(i) << " ";
        if(i == 2 || i == 5 || i == 8 ){
            cout << " " << endl;
        } 
    }*/

    if(result.at(0) + result.at(3) + result.at(6) == 3 || result.at(1) + result.at(4) + result.at(7) == 3 || result.at(2) + result.at(5) + result.at(8) == 3 || 
       result.at(0) + result.at(1) + result.at(2) == 3 || result.at(3) + result.at(4) + result.at(5) == 3 || result.at(6) + result.at(7) + result.at(8) == 3 || 
       result.at(0) + result.at(4) + result.at(8) == 3 || result.at(2) + result.at(4) + result.at(6) == 3){
      cout << "Yes" << endl;
    }else{
      cout << "No" << endl;  
    }

}

Measured memory_bytes: 256
#include <stdio.h>
int main(void){
	int i=0,checker=0;
	char st[11],ri[11],ng[11];
	scanf("%s %s %s",st,ri,ng);
	while(1==1){
		if(st[i]!='\0'){
			i++;
		}else{
			i--;
			break;
		}
	}
	if(st[i]==ri[0]){
		checker++;
	}
	i=0;
	while(1==1){
		if(ri[i]!='\0'){
			i++;
		}else{
			i--;
			break;
		}
	}
	if(ri[i]==ng[0]){
		checker++;
	}
	if(checker==2){
		printf("YES");
	}else{
		printf("NO");
	}
	return 0;
}

Measured memory_bytes: 128
// ABC043C - いっしょ

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

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

	vector<int> a(N);
	for (int i = 0; i < N; i++) {
		cin >> a.at(i);
	}

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

	int minimum = 200 * 200 * 100;
	for (int i = a.at(0); i <= a.at(N -1); i++) {
		int temp_min = 0;
		for (int j = 0; j < N; j++) {
			temp_min += (i - a.at(j)) * (i - a.at(j));
		}
		minimum = min(minimum, temp_min);
	}

	cout << minimum << endl;

	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define lint long long int
#define rep(i,n) for(int i=0;i<int(n);i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define arep(i,a,n) for(int i=a;i<n;i++)
#define sort(a) sort(a.begin(),a.end())
#define reverse(a) reverse(a.begin(),a.end())
#define fill(a,x) fill(a.begin(),a.end(),x)
#define eb(data) emplace_back(data)
#define pb(data) emplace_back(data)
#define mp make_pair
#define ALNUM 26
#define vint vector<int>
#define vlint vector<lint>
#define F first
#define S second
#define ALL(data) data.begin(),data.end()
#define GEts(s) getline(cin,s);
#define UNIQUE(vec) vec.erase(unique(vec.begin(), vec.end()), vec.end())

using namespace std;
template<typename Rast>inline void out(Rast rast){cout<<rast<<"\n";return;}
template<typename Rast>inline void in(Rast& rast){cin>>rast;return;}
template<typename T>istream& operator >> (istream& is, vector<T>& vec){for(T& x: vec) is >> x;return is;}
template<typename First, typename... Rest>void in(First& first, Rest&... rest){cin >> first;in(rest...);return;}
template<typename First, typename... Rest>void out(First first, Rest... rest){cout << first<<" ";out(rest...);return;}
template<typename T>T gcd(T a,T b){if(b==0)return a;return gcd(b,a%b);}
template<typename T1,typename T2>bool chmax(T1& a,T2 b){if(a<b){a=b;return true;}else{return false;}}
template<typename T1,typename T2>bool chmin(T1& a,T2 b){if(a>b){a=b;return true;}else{return false;}}
template<typename T>T lcm(T a, T b){return a * b / gcd(a, b);}
static const double pi = 3.141592653589793;
lint modpow(lint a,lint n,lint p){if (n==0)return 1%p; if(n==1)return a%p;if(n%2==1)return (a*modpow(a,n-1,p))%p;lint t=modpow(a,n/2,p);return (t*t)%p;}//a^n%p
lint MOD=pow(10,9)+7;
//lint MOD=998244353;
lint inf=pow(2,50);
int intinf=pow(2,30);
/**int dirx[]={1,0};int diry[]={0,1};//*///右、下
/**int dirx[]={0,1,0,-1};int diry[]={-1,0,1,0};//*///四方位
/**int dirx[]={-1,0,1,1,1,0,-1,-1};int diry[]={-1,-1,-1,0,1,1,1,0};//*///八方位


class unionfind{
public:
	vector<int> table;
	void init(int size){
		table.resize(size);
		rep(i,size)table[i]=i;
	};
	int root(int index){
		if(table[index]==index)return index;
		else{
			int hoge=root(table[index]);
			table[index]=hoge;
			return hoge;
		}
	};
	bool same(int x,int y){
		return(root(x)==root(y));
	};
	int marge(int x,int y){
		int yroot=root(y);
		int xroot=root(x);
		if(xroot==yroot)return 0;
		table[yroot]=xroot;
		return 0;
	}
};

int main(){
	cin.tie(0);ios::sync_with_stdio(false);cout<<std::fixed<<std::setprecision(19);
	lint n;
	in(n);
	lint ans=n-1;
	lint hoge=sqrt(n);
	for(lint i=1;i<=hoge;i++)if(n%i==0)chmin(ans,i-2+(n/i));
	out(ans);
	return 0;
}


Measured memory_bytes: 3692
#include <bits/stdc++.h>
using namespace std;
int n,a[30],cnt[30];
int main()
{
	scanf("%d",&n);
	for (int i=1;i<=26;i++) a[i]=1e9;
	for (int i=1;i<=n;i++)
	{
		char s[110];
		scanf("%s",s);
		int n=strlen(s);
		memset(cnt,0,sizeof(cnt));
		for (int j=0;j<n;j++)
		  cnt[char(s[j])-96]++;
		for (int j=1;j<=26;j++)
		  if (cnt[j]<a[j]) a[j]=cnt[j];
	}
	for (int i=1;i<=26;i++)
		if (a[i]<1e9)
	  for (int j=1;j<=a[i];j++)
	    cout<<char(i+96);
} 

Measured memory_bytes: 256