akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <bitset>
#include <cmath>
#include <deque>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <vector>

using namespace std;
using ll = int64_t;
using VL = vector<ll>;
using VD = vector<double>;
using VVL = vector<VL>;

#define FOR(i, start, end) for(ll i = (start), (i ## xxxx_end)=(end); i < (i ## xxxx_end); ++i)
#define FORD(i, start, end) for(ll i = (start), (i ## xxxx_end)=(end); i > (i ## xxxx_end); --i)
#define REP(i, n) FOR(i, 0, n)
#define REPD(i, n) FORD(i, n - 1, -1)

#define ALL(x) (x).begin(), (x).end()
#define SIZE(x) ((ll)(x).size())
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))

template<class T, class U>bool chmax(T &a, const U &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T, class U>bool chmin(T &a, const U &b) { if (b<a) { a=b; return 1; } return 0; }

template <class T, class U>ostream &operator<<(ostream &o, const map<T, U>&obj) {o << "{"; for (auto &x : obj) o << " {" << x.first << " : " << x.second << "}" << ","; o << " }"; return o;}
template <class T>ostream &operator<<(ostream &o, const set<T>&obj) {o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr) o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;}
template <class T>ostream &operator<<(ostream &o, const multiset<T>&obj) {o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr) o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;}
template <class T>ostream &operator<<(ostream &o, const vector<T>&obj) {o << "{"; for (int i = 0; i < (int)obj.size(); ++i)o << (i > 0 ? ", " : "") << obj[i]; o << "}"; return o;}
template <class T, class U>ostream &operator<<(ostream &o, const pair<T, U>&obj) {o << "{" << obj.first << ", " << obj.second << "}"; return o;}
template <template <class tmp>  class T, class U> ostream &operator<<(ostream &o, const T<U> &obj) {o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr)o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;}
void print(void) {cout << endl;}
template <class Head> void print(Head&& head) {cout << head;print();}
template <class Head, class... Tail> void print(Head&& head, Tail&&... tail) {cout << head << " ";print(forward<Tail>(tail)...);}

#define INF (1LL << 60)
#define MOD 1000000007LL

ll N;
VL sums;
VVL dp;

ll f(ll i, ll j) {
    if(i == j) {
        return 0;
    }

    if(dp[i][j - 1]){
        return dp[i][j - 1];
    }

    ll ret = INF;
    FOR(mid, i, j) {
        chmin(ret, f(i, mid) + f(mid + 1, j));
    }
    ret += sums[j + 1] - sums[i];
    return dp[i][j - 1] = ret;
}

void solve() {
    cin >> N;
    sums = VL(N + 1, 0);
    REP(i, N) {
        ll a;
        cin >> a;
        sums[i + 1] = sums[i] + a;
    }

    // dp[i][j]: i番目以上からj番目未満までが合体したスライムの最小コスト
    dp = VVL(N, VL(N, 0));
    print(f(0, N - 1));
}

int main() {
    solve();
    return 0;
}

Measured memory_bytes: 1536
#include<stdio.h>
int main(){
  int N;
  scanf("%d",&N);
  int i;
  unsigned long int count=0;
  for(i=0;i<=N;i++){
    if(i%3!=0&&i%5!=0){
      count=count+i;
    }
  }
  printf("%lu",count);
}


Measured memory_bytes: 1736
#include <iostream>
#include <cmath>
 
using namespace std;
int main() {
	int n, k;
	cin >> n >> k;
 
	long long c = 0;
	for (int b = k+1; b <= n; b++) {
		c += (n / b) * max(0, b - k) + max(0, n % b - k + 1);
	}
	if (k == 0) c -= n;
 
	cout << c << endl;
	return 0;
}

Measured memory_bytes: 256
import qualified Data.Set as S

f :: String -> S.Set Char -> Int
f [] s = 0
f (x:xs) s = max n (f xs s')
  where s' = S.insert x s
        t = S.fromList xs
        n = S.size (S.intersection s' t)

main = do
    n <- readLn :: IO Int
    s <- getLine
    print $ f s S.empty


Measured memory_bytes: 892
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
typedef long long ll;
typedef pair<int,int> pint;
typedef pair<ll,int> pli;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;

int main(){
    int n,q;
    cin>>n>>q;
    string s;
    cin>>s;
    vector<int> cnt(n+1);
    rep(i,n-1){
        if(s[i]=='A'&&s[i+1]=='C')++cnt[i+1];
    }
    rep(i,n)cnt[i+1]+=cnt[i];
    while(q--){
        int l,r;
        cin>>l>>r;
        cout<<cnt[r-1]-cnt[l-1]<<endl;
    }
    return 0;
}

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

int main(){
	int y[] = {0, 2, 5, 5, 4, 5, 6, 3, 7, 6};
	int N, M; cin >> N >> M;

	vector<int> A(M);
	for(int i=0; i<M; ++i) cin >> A[i];
	sort(A.begin(), A.end(), greater<int>());

	vector<int> dp(N+10, -1);
	dp[0] = 0;
	for(int i=0; i<N; ++i){
		if(dp[i] == -1) continue;
		for(auto x : A){
			dp[i + y[x]] = max(dp[i + y[x]], dp[i] + 1);
		}
	}

	int cnt = N;
	string ans;
	while(cnt > 0){
		for(auto x : A){
			if(cnt - y[x] >= 0 && dp[cnt - y[x]] == dp[cnt] - 1){
				cnt -= y[x];
				ans += to_string(x);
				break;
			}
		}
	}
	sort(ans.begin(), ans.end(), greater<char>());

	cout << ans << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
 #define int long
  int N,M;cin>>N>>M;
  vector<int>A(N);for(int i=0;i<N;i++)cin>>A[i];
  vector<pair<int,int>>CB(M);
  for(int i=0;i<M;i++)cin>>CB[i].second>>CB[i].first;
  sort(CB.begin(),CB.end(),greater<pair<int,int>>());
  int t=0,i=0;
  while(t<=N&&i<M){
    for(int _=0;_<CB[i].second;_++)A.push_back(CB[i].first);
    t+=CB[i].second;
    i++;
  }
  sort(A.begin(),A.end(),greater<int>());
  int ans=0;
  for(int i=0;i<N;i++)ans+=A[i];
  cout<<ans;
}

Measured memory_bytes: 6032
import java.util.*;
public class Main{
    public static void main(String[] args){
	new Main().run();
    }
    Scanner sc = new Scanner(System.in);

    int[] dis;
    int[][] nums = { {0, 1, 1, 1, 1, 1, 1},
		     {0, 0, 0, 0, 1, 1, 0},
		     {1, 0, 1, 1, 0, 1, 1},
		     {1, 0, 0, 1, 1, 1, 1},
		     {1, 1, 0, 0, 1, 1, 0},
		     {1, 1, 0, 1, 1, 0, 1},
		     {1, 1, 1, 1, 1, 0, 1},
		     {0, 1, 0, 0, 1, 1, 1},
		     {1, 1, 1, 1, 1, 1, 1},
		     {1, 1, 0, 1, 1, 1, 1}, };
    int n;

    void run(){
	while(sc.hasNext()){
	    n = sc.nextInt();
	    if(n==-1) break;
	    dis = new int[7];
	    for(int i=0; i<n; i++)	
		solve(sc.nextInt());
	}
    }

    void solve(int a){
	String ans = "";
	for(int i=0; i<dis.length; i++){
	    ans += dis[i]==nums[a][i] ? "0":"1";
	    dis[i] = nums[a][i];
	}
	System.out.println(ans);
    }
}

Measured memory_bytes: 20700
<?php

$input = file_get_contents('php://stdin');

$alphabet = array_fill_keys(range('a', 'z'), 0);
foreach (str_split($input) as $c) {
    if (! ctype_alpha($c)) { continue; }

    $alphabet[strtolower($c)]++;
}

foreach ($alphabet as $char => $count) {
    printf('%s : %d%s', $char, $count, PHP_EOL);
}

Measured memory_bytes: 6796
num = int(input())

a = [ [0 for x in range(14)] for y in range(4)]

mark = ["S", "H", "C", "D"]

for i in range(num):
    m,t = input().split()
    n = int(t)
    if m == "S":
        a[0][n] =1
    elif m == "H":
        a[1][n] =1
    elif m == "C":
        a[2][n] =1
    elif m == "D":
        a[3][n] =1

for i in range(4):
    for j in range(1,14):
        if a[i][j] ==0:
            print(mark[i], j)



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

using namespace std;

typedef uint64_t u64;
typedef int64_t s64;
typedef uint32_t u32;
typedef int32_t s32;
typedef vector<s32> vs32;
typedef vector<u32> vu32;
typedef vector<s64> vs64;
typedef vector<u64> vu64;

const double PI=3.14159265358979323846;

#define MAX(x, y) ((x) < (y) ? (y) : (x))
#define MIN(x, y) ((x) > (y) ? (y) : (x))

#define rep(i, N) for(int i = 0; i < N; ++i)

#define CEIL(x, y) (((x) + (y) - 1) / (y))
#define MOD 1000000007ULL

#define IN(l, r, x) ((l) <= (x) && (x) < (r))


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

    int h, w;
    cin >> h >> w;
    int n;
    cin >> n;
    vs32 a(n);
    rep (i, n) cin >> a[i];

    vector< vs32 > ans(h, vs32(w));

    int x = 0, y = 0;
    int aim = 1;
    rep (i, n)
    {
        rep (j, a[i])
        {
            if ((x < w && aim == 1) || (x >= 0 && aim == -1)) ans[y][x] = i + 1;
            x += aim;
            if (x == w && aim == 1)
            {
                ++y;
                x = w - 1;
                aim = -1;
            }
            else if (x == -1 && aim == -1)
            {
                ++y;
                x = 0;
                aim = 1;
            }
        }
    }

    rep (i, h)
    {
        rep (j, w)
        {
            if (j > 0) cout << " ";
            cout << ans[i][j];
        }
        cout << "\n";
    }
    return 0;
}



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

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

  int ans = 0;

  for(int i = 0;i < 4;i++){
      for(int j = 1; j < 4; j++){
          if(S[i] == S[i+j]) {
              ans++;
          }else {
              continue;
          }
      }
  }

  if(ans == 2){
      cout << "Yes" << endl;
  } else {
      cout << "No" << endl;
  }
  
  return 0;
}


Measured memory_bytes: 256
using System;
using System.Text;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using static System.Console;
using static System.Math;

namespace AtCoder
{
    public class Program
    {
        public static void Main(string[] args)
        {
            new Program().Solve(new ConsoleInput(Console.In, ' '));
        }

        public void Solve(ConsoleInput cin)
        {
            var N = cin.ReadInt;
            // 初期状態をt[0], x[0], y[0]とすることで便利になります
            var t = new int[N + 1];
            var x = new int[N + 1];
            var y = new int[N + 1];
            y[0] = x[0] = y[0] = 0;
            for (int i = 1; i <= N; ++i)
            {
                t[i] = cin.ReadInt;
                x[i] = cin.ReadInt;
                y[i] = cin.ReadInt;
            }

            var flag = true;
            for (int i = 0; i < N; ++i)
            {
                var time = t[i + 1] - t[i];
                var dist = Abs(x[i + 1] - x[i]) + Abs(y[i + 1] - y[i]);
                if (time < dist) flag = false;
                if (Abs(time - dist) % 2 != 0) flag = false;
            }

            if (flag) WriteLine("Yes");
            else WriteLine("No");
        }
    }

    public class ConsoleInput
    {
        private readonly System.IO.TextReader _stream;
        private char _separator = ' ';
        private Queue<string> inputStream;
        public ConsoleInput(System.IO.TextReader stream, char separator = ' ')
        {
            this._separator = separator;
            this._stream = stream;
            inputStream = new Queue<string>();
        }
        public string Read
        {
            get
            {
                if (inputStream.Count != 0) return inputStream.Dequeue();
                string[] tmp = _stream.ReadLine().Split(_separator);
                for (int i = 0; i < tmp.Length; ++i)
                    inputStream.Enqueue(tmp[i]);
                return inputStream.Dequeue();
            }
        }
        public string ReadLine { get { return _stream.ReadLine(); }}
        public int ReadInt { get { return int.Parse(Read); }}
        public long ReadLong { get { return long.Parse(Read); }}
        public double ReadDouble { get { return double.Parse(Read); }}
        public string[] ReadStrArray(long N) { var ret = new string[N]; for (long i = 0; i < N; ++i) ret[i] = Read; return ret;}
        public int[] ReadIntArray(long N) { var ret = new int[N]; for (long i = 0; i < N; ++i) ret[i] = ReadInt; return ret;}
        public long[] ReadLongArray(long N) { var ret = new long[N]; for (long i = 0; i < N; ++i) ret[i] = ReadLong; return ret;}
    }
}


Measured memory_bytes: 17356
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <numeric>
#include <functional>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll mod = 1000000007;
const ll INF = 1e16;
const ll MAX_N = 100010;
 
int main() {
    string s;
    cin >> s;

    rep(b, 1<<3) {
        ll now = s[0] -'0';
        vector<string> op(3);
        rep(i, 3) {
            ll x = s[i+1] - '0';
            if(b & 1<<i) {
                now += x;
                op[i] = "+";
            }
            else {
                now -= x;
                op[i] = "-";
            }
        }
        if(now == 7) {
            cout << s[0] << op[0] << s[1] << op[1] << s[2] << op[2] << s[3] << "=7" << endl;
            re0;
        }
    }
    
    re0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<n; i++)
using namespace std;
using ll = long long;
 
int main(){
  int n;
  cin >> n;
  string s[n];
  rep(i,n)
    cin >> s[i];
  int a,w,t,r=0;
  rep(i,n){
    if(s[i]=="AC") a++;
    if(s[i]=="WA") w++;
    if(s[i]=="TLE") t++;
    if(s[i]=="RE") r++;
  }
  cout << "AC x " << a << endl;
  cout << "WA x " << w << endl;
  cout << "TLE x " << t << endl;
  cout << "RE x " << r << endl;
}

Measured memory_bytes: 6756
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>

#include <iostream>
#include <complex>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>

#include <functional>
#include <cassert>

typedef long long ll;
using namespace std;

#define debug(x) cerr << __LINE__ << " : " << #x << " = " << (x) << endl;

#define mod 1000000007 //1e9+7(prime number)
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define SIZE 100010

struct Dinic{
  
  struct edge {
    int to, cap, rev;
    edge(int a, int b, int c):to(a),cap(b),rev(c){}
  };
  
  vector<vector<edge> > G;
  vector<int> level, iter;
  int MAX_V;
  
  Dinic(int max_v):G(max_v,vector<edge>()),MAX_V(max_v){}
  
  int add_edge(int from,int to,int cap){
    int id = G[from].size();
    
    G[from].push_back(edge(to,cap,G[to].size()));
    G[to].push_back(edge(from,0,G[from].size() - 1));
    
    return id;
  }
  
  void bfs(int s){
    level.assign(MAX_V,-1);
    queue<int> q;
    level[s] = 0;
    q.push(s);
    while(q.size()){
      int v = q.front(); q.pop();
      for(int i=0;i<G[v].size();i++){
        edge &e = G[v][i];
        if(e.cap > 0 && level[e.to] < 0){
          level[e.to] = level[v] + 1;
          q.push(e.to);
        }
      }
    }
  }
  
  int dfs(int v, int t, int f){
    if(v == t) return f;
    for(int &i = iter[v];i < G[v].size(); i++){
      edge &e = G[v][i];
      if(e.cap > 0 && level[v] < level[e.to]){
        int d = dfs(e.to, t, min(f,e.cap));
        if(d > 0){
          e.cap -= d;
          G[e.to][e.rev].cap += d;
          return d;
        }
      }
    }
    return 0;
  }
  
  int solve(int s, int t){
    int flow = 0;
    while(1){
      bfs(s);
      if(level[t] < 0) return flow;
      iter.assign(MAX_V,0);
      int f;
      while((f = dfs(s, t, INF)) > 0) flow += f;
    }
  }
  
};

int main(){
  int n;
  string s;
  int count[26][26] = {};
  
  cin >> n;
  
  for(int i=0;i<n;i++){
    cin >> s;
    count[s[0]-'a'][s[s.size()-1]-'a']++;
  }

  for(int i=0;i<26;i++){
    int sum = 0; bool f = false;
    
    Dinic d(28), d2(30);

    for(int j=0;j<26;j++) sum += count[i][j] * (i != j);
    for(int j=0;j<26;j++) f |= count[j][i];

    if(!f) continue;
    
    for(int j=0;j<26;j++){
      for(int k=0;k<26;k++){
        if(j == k) continue;

        if(j == i){
          d.add_edge(26, k, count[j][k]);
          d2.add_edge(26, k, count[j][k]);
        }else if(k == i){
          d.add_edge(j, 27, count[j][k]);
          d2.add_edge(j, 27, count[j][k]);
        }else{
          d.add_edge(j, k, count[j][k]);
          d2.add_edge(j, k, count[j][k]);
        }
      }
    }

    d2.add_edge(28, 26, sum);
    d2.add_edge(28, 29, 1);
    for(int j=0;j<26;j++) if(i != j) d2.add_edge(29, j, 1);
    
    auto flow = d.solve(26, 27);
    auto flow2 = d2.solve(26, 27);

    if(flow == sum || flow2 == sum+1){
      printf("%c\n", i+'a');
    }
  }
  
  return 0;
}



Measured memory_bytes: 3408
#include<stdio.h>
#include<iostream>
using namespace std;

int point;
int rui;
int oc;

void hit(){
  rui++;
  if(rui>3){
    point++;
    rui=3;
  }
}
void out(){
  oc++;
}

void home(){
  point+=1;
  point+=rui;
  rui=0;
}

int main(){
  int i,n;
  string event;
  point=0;
  rui=0;
  oc=0;

  cin >> n;
  for(i=0;i<n;i++){

    while(1){
      if(oc==3){
	rui=0;
	oc=0;
	break;
}
      cin >> event;
      if(event == "HIT"){
	hit();
      }else if(event == "OUT"){
	out();
      }else if(event == "HOMERUN"){
	home();
      }
    }
    cout << point << endl;
    point=0;
  }
  return 0;
}

Measured memory_bytes: 1208
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>

using namespace std;

//----------------------- Print Function ----------------------//

inline void print() {
    cout << endl;
}
template <typename First, typename... Rest>
void print(const First &first, const Rest &... rest) {
    cout << first << ' ';
    print(rest...);
}

template <typename T>
void print(const vector<T> &v) {
    for (auto e : v) cout << e << ' ';
    cout << endl;
}

//------------------------- Libraries -------------------------//

//--------------------------- Solve ---------------------------//

void solve() {
    long long H, W; cin >> H >> W;
    long long ans = H * W;
    
    //一つ目横割り
    for (long long h = 1; h < H; h++) {
        long long hh = H - h;
        long long s1 = h * W;

        //横割り
        long long s2 = (hh / 2) * W;
        long long s3 = (hh - hh/2) * W;
        ans = min(ans, max(s1, max(s2, s3)) - min(s1, min(s2, s3)));
        //print(s1, s2, s3);

        //縦割り
        s2 = hh * (W / 2);
        s3 = hh * (W - W/2);
        ans = min(ans, max(s1, max(s2, s3)) - min(s1, min(s2, s3)));
        //print(s1, s2, s3);
    }

    //一つ目縦割り
    for (long long w = 1; w < W; w++) {
        long long ww = W - w;
        long long s1 = H * w;

        //横割り
        long long s2 = (H / 2) * ww;
        long long s3 = (H - H/2) * ww;
        ans = min(ans, max(s1, max(s2, s3)) - min(s1, min(s2, s3)));

        //縦割り
        s2 = H * (ww / 2);
        s3 = H * (ww - ww/2);
        ans = min(ans, max(s1, max(s2, s3)) - min(s1, min(s2, s3)));
    }

    cout << ans << '\n';
}

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

    solve();

    return 0;
}

Measured memory_bytes: 3656
from collections import Counter

n = int(input())
a = list(map(int, input().split()))

c = Counter(a)
for k, v in c.items():
    if (k != 0 and v != 2) or (k == 0 and (n % 2 == 0 or v != 1)):
        print(0)
        break
else: print((2 ** (n//2)) % (10**9+7))


Measured memory_bytes: 14812
#include <limits.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#include <algorithm>
#include <cassert>
#include <cfloat>
#include <complex>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <regex>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

using namespace std;

#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define repLRE(i, l, r) for (ll i = (l); i <= (r); ++i)
#define rrepLRE(i, l, r) for (ll i = (l); i >= (r); --i)
#define Sort(v) sort(v.begin(), v.end())
#define Reverse(v) reverse(v.begin(), v.end())
#define Lower_bound(v, x) \
  distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) \
  distance(v.begin(), upper_bound(v.begin(), v.end(), x))

using ll = long long;
using ull = unsigned long long;
using P = pair<ll, ll>;
using T = tuple<ll, ll, ll>;
using vll = vector<ll>;
using vP = vector<P>;
using vT = vector<T>;
using vvll = vector<vector<ll>>;
using vvP = vector<vector<P>>;
using dqll = deque<ll>;

ll dx[9] = {-1, 1, 0, 0, -1, -1, 1, 1, 0};
ll dy[9] = {0, 0, -1, 1, -1, 1, -1, 1, 0};

/* Macros reg. ends here */

const ll INF = 1LL << 50;

static const long long mod = 1000000007;

ll siz;
ll ofst;
vll seg;

void add(ll i, ll x) {
  i += ofst;
  seg[i] += x;
  while (true) {
    i /= 2;
    if (i == 0) break;
    seg[i] = seg[2 * i] + seg[2 * i + 1];
  }
}

ll get(ll l, ll r) {
  ll s = 0;
  l += ofst, r += ofst + 1;
  while (l < r) {
    if (l % 2 == 1) {
      s += seg[l];
      l++;
    }
    l /= 2;
    if (r % 2 == 1) {
      s += seg[r - 1];
      r--;
    }
    r /= 2;
  }
  return s;
}

int main() {
  ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  cout << fixed << setprecision(15);

  ll n;
  cin >> n;
  vvll cnt(10, vll(10, 0));
  repLRE(i, 1, n) {
    string s = to_string(i);
    cnt[s[0] - '0'][s[s.size() - 1] - '0']++;
  }
  ll ans = 0;
  rep(i, 10) rep(j, 10) ans += cnt[i][j] * cnt[j][i];

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
import java.util.*;

 
class Main {
 
    private static Scanner sc = new Scanner(System.in);
 
    public static void main(String[] args) {
        String s = sc.next();
        char[] c = s.toCharArray();
        String s2="";
        for(int i=0;i<4;i++) {
            s2+=c[i];
        }
        s2+=" ";
        for(int i=4;i<c.length;i++){
        	s2+=c[i];
        }
        //String s = String.valueOf(i);
        //int i = Integer.parseInt(s);
        System.out.println(s2);

    }
}



Measured memory_bytes: 22740
#include"bits/stdc++.h"
using namespace std;

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep3(i,m,n) for(int (i)=m;(i)<=(n);(i)++)
#define rep3rev(i,m,n) for(int (i)=m;(i)>=(n);(i)--)
#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define eb emplace_back

using ll = long long;
using vll = vector<ll>;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using pii = pair<int, int>;

/*** MOD CALCULATION ***/

const int MOD = 1e9+7;
const int MAX = 510000;

ll addM(ll a, ll b){
	return (a + b) % MOD;
}

ll mulM(ll a, ll b){
	ll temp = (a * b) % MOD;
  	while(temp<0){ temp += MOD; }
  	return temp;
}

ll powM(ll a, ll b){
	if(b == 0) return 1;
  	else if(b == 1) return a%MOD;
  	else if(b%2==0) return mulM(powM(a,b/2),powM(a,b/2));
  	else return mulM(a,mulM(powM(a,(b-1)/2),powM(a,(b-1)/2)));
}

// b^{-1} = b^{p-2} (mod p)
// a/b = a*b^{p-2} (mod p)
ll divM(ll a, ll b){ 
  	return mulM(a,powM(b,MOD-2));
}

// n!, (n!)^{-1} のテーブル作成
ll fac[MAX], finv[MAX], inv[MAX];
void COMBinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    rep3(i,2,MAX-1){
        fac[i] = fac[i-1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i-1] * inv[i] % MOD;
    }
}

// 二項係数計算
ll COMB(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n-k] % MOD) % MOD;
}

/*** MOD CALCULATION ここまで ***/

void Main() {
	int N;
	cin >> N;
	vi cnt(100005, 0);
	int ans = 1;
	rep(i, N) {
	    int a;
	    cin >> a;
	    if(a == 0){
	        ans = mulM(ans, 3 - cnt[a]);
	    }
	    else{
	        ans = mulM(ans, cnt[a-1] - cnt[a]);
	    }
	    cnt[a]++;
	}
	cout << ans << endl; 
	return;
}

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

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

int main(){
  int n, m;
  cin >> n >> m;
  vector<int> x(m);
  rep(i,m) cin >> x[i];
  sort(x.begin(), x.end());
  if (n >= m) {
    cout << 0 << endl;
    return 0;
  }
  vector<ll> dif;
  ll res = 0;
  rep(i,m-1) {
    dif.push_back(abs(x[i] - x[i+1]));
    res += dif.back();
  }
  sort(dif.begin(), dif.end(), greater<ll>());
  rep(i,n-1) {
    res -= dif[i];
  }
  cout << res << endl;
  return 0;
} 

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

int main()
{
    int r,c,i,j,x,k,y, p,s,t,m,n=0;
    cin>>r>>c;

    int a[50][50];

    for(i=0;i<r;i++)
    {
        for(j=0;j<c;j++)
        {
            scanf("%d",&a[i][j]);
        }
    }

    for(i=0;i<(r-1);i++)
    {
        for(j=(i+1);j<r;j++)
        {
            for(k=0,s=0;k<c;k++)
            {
                x=a[i][k];y=a[j][k];
                p=abs(x-y);
                s=s+(p*p);
            }

            m=s;
            t=sqrt(m);

            if((t*t)== s) n++;

        }
    }
    printf("%d\n",n);
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<functional>
#include<cmath>
#include<set>
#include<random>
#include<map>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define F first
#define S second
const long long mod = 1000000007;
const long long inf = 1145141919810;
typedef pair<int, int> P;
typedef pair<P, P> PP;
struct edge {int to, cost;};
vector<int>ans;

void disp() {
	rep(i, ans.size()) {
		if (i)cout << ' ';
		cout << ans[i];
	}
	cout << endl;
}

void back1(int k,int n) {
	int er = 0;
	for (int x = 0; x < n; x++) {
		int a = ans[ans.size() - 1];
		ans.pop_back();
		if (a != 1) {
			a--;
			ans.push_back(a);
			rep(i, er)ans.push_back(k);
			er = 0;
		}
		else {
			er++;
		}
	}
}

signed main() {
	int k, n; cin >> k >> n;
	if (k & 1) {
		rep(i, n)ans.push_back((k + 1) / 2);
		back1(k, n / 2);
		disp();
	}
	else {
		rep(i, n) {
			if (i)ans.push_back(k);
			else ans.push_back(k / 2);
		}
		disp();
	}
}

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

using namespace std;
using ll = long long;

int main() {
    int n;
    ll k;
    cin>>n>>k;
    vector<int> a(n);
    for(int i = 0;i < n;++i) {
        cin>>a[i];
        --a[i];
    }
    ll cnt=0;
    int cur=0;
    ll syu=-1;
    map<int,ll> mp;
    mp[0]=0;
    do{
        cur=a[cur];
        ++cnt;
        --k;
        if(k==0){
            cout<<cur+1<<endl;
            return 0;
        }
        if(mp.find(cur)==mp.end()) {
            mp[cur]=cnt;
        }
        else {
            syu=cnt-mp[cur];
            break;
        }
    }while(cur!=0);

    k%=syu;
    for(int i = 0;i < k;++i) {
        cur=a[cur];
    }
    cout<<cur+1<<endl;
    return 0;
}


Measured memory_bytes: 14080
#include<iostream>
#include<string>
#include<cstring>
#include<algorithm>
using namespace std;
typedef long long ll;
char s[600005];
int main()
{
	//string s;
	int l,r=0;
	
	cin>>s+200005;
	l=200005;
	r=200005;
	for(int i=200006;s[i];i++)
	{
		r++;
	}
	//cout<<l<<r<<endl;
	int q;
	cin>>q;
	int ri=1;
	for(int i=1;i<=q;i++)
	{
		//cout<<l<<" "<<r<<endl;
		int t;
		cin>>t;
		if(t==1)
		{
			int temp;
			temp=l;
			l=r;
			r=temp;
			ri++;
		}
		else if(t==2)
		{
			int f;
			cin>>f;
			char c;
			cin>>c;
			if(f==1)
			{
				//s=c+s;
				if(ri%2)
				{
					l--;
					s[l]=c;
				}
				else
				{
					l++;
					s[l]=c;
				}
			}
			else
			if(f==2)
			{
				//s=s+c;
				if(ri%2)
				{
					r++;
					s[r]=c;
				}
				else
				{
					r--;
					s[r]=c;
				}
			}
		}
	}
	//cout<<l<<" "<<r<<endl;
/*
if(l>r)
{
	int temp;
	temp=l;
	l=r;
	r=temp;
}*/
    if(l<r)
	for(int i=l;i<=r;i++)
	{
		cout<<s[i];
		//cout<<"???";
	}
	else
	for(int i=l;i>=r;i--)
	{
		cout<<s[i];
		//cout<<"???";
	}

}

Measured memory_bytes: 896
import java.util.Scanner;

public class Main {
	public static void main(String args[]) {
		Scanner scan = new Scanner(System.in);
		int N=scan.nextInt();
		int A=scan.nextInt();
		int B=scan.nextInt();
		if(B<A*N) {
			System.out.println(B);
		} else {
			System.out.println(A*N);
		}
	}
}

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

using namespace std;

#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl
#define DEBUG_MAT(v) cerr<<#v<<endl;for(int i=0;i<v.size();i++){for(int j=0;j<v[i].size();j++) {cerr<<v[i][j]<<" ";}cerr<<endl;}


typedef long long ll;
#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
#define pll pair<ll,ll>
template<class S, class T> pair<S, T> operator+(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first + t.first, s.second + t.second); }
template<class S, class T> pair<S, T> operator-(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first - t.first, s.second - t.second); }
template<class S, class T> ostream& operator<<(ostream& os, pair<S, T> p) { os << "(" << p.first << ", " << p.second << ")"; return os; }
#define X first
#define Y second
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define rrep(i,n) for(int i=(n)-1;i>=0;i--)
#define rrep1(i,n) for(int i=(n);i>0;i--)
#define REP(i,a,b) for(int i=a;i<b;i++)
#define in(x, a, b) (a <= x && x < b)
#define all(c) c.begin(),c.end()
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a = b; return 1; } return 0; }
#define UNIQUE(v) v.erase(std::unique(v.begin(), v.end()), v.end());
const ll inf = 1000000001;
const ll INF = (ll)1e18 + 1;
const ll MOD = 1000000007;
//const ll MOD = 998244353;
const double pi = 3.14159265358979323846;
#define Sp(p) cout<<setprecision(15)<< fixed<<p<<endl;
int dx[4] = { 1,0, -1,0 }, dy[4] = { 0,1,0,-1 };
int dx2[8] = { 1,1,0,-1,-1,-1,0,1 }, dy2[8] = { 0,1,1,1,0,-1,-1,-1 };
#define fio() cin.tie(0); ios::sync_with_stdio(false);
//#define mp make_pair

ll popfront(ll &a, ll &b) {
  ll mask = 1LL << 60;
  while ((mask & a) == (mask & b)) {
    if (mask & a) {
      a -= mask;
      b -= mask;
    }
    mask >>= 1;
  }
  return mask;
}

ll range(pll a, pll b) {
  if (a.second < b.first || b.second < a.first) {
    return a.second - a.first + 1 + b.second - b.first + 1;
  }
  else {
    ll mi = min(a.first, b.first), ma = max(a.second, b.second);
    return ma - mi + 1;
  }
}

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

  if (a == b) {
    cout << 1 << endl;
    return 0;
  }

  ll mask = popfront(a, b);

  vector<pll> can;
  can.push_back(pll(a, mask - 1));
  can.push_back(pll(a + mask, 2*mask - 1));

  ll mask2 = mask >> 1;
  while (mask2 > 0) {
    if (b & mask2) break;
    mask2 >>= 1;
  }
  if (mask2 == 0) {
    can.push_back(pll(mask, mask));
  }
  else {
    can.push_back(pll(mask, mask + 2*mask2 - 1));
  }

  ll ans = can[0].second - can[0].first + 1 + range(can[1], can[2]);
  cout << ans << endl;
  
}


Measured memory_bytes: 256
N, Y = map(int, input().split())
 
ans10000, ans5000, ans1000 = -1, -1, -1
for i in range(0, N+1):
    for j in range(0, (N+1)-i):
        k = N - (i + j)
        if k >= 0:
            o = 10000*i + 5000*j + 1000*k
            if o == Y:
                ans10000 = i
                ans5000 = j
                ans1000 = k
                
print(ans10000, ans5000, ans1000)

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

int main()
{
    int n, p[10];
    scanf("%d", &n);
    for (int i = 0; i < n; i++) scanf("%d", p + i);
    std::sort(p, p + n);
    
    int sum{};
    for (int i = 0; i < n; i++) sum += p[i];
    sum -= p[n - 1] / 2;
    printf("%d\n", sum);
    
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(I,X,Y) for(long long (I)=(X);(I)<(Y);(I)++)
#define REP(I,X,Y) for(long long (I)=(Y)-1;(I)>=(X);(I)--)
#define ALL(X) (X).begin(),(X).end()
#define pb push_back
#define COUNT(V,X) upper_bound((V).begin(),(V).end(),X)-lower_bound((V).begin(),(V).end(),X)
#define debug(x) cerr<<#x<<':'<<x<<endl;
#define DEBUG(v) cerr<<#v<<':';for(auto xXx:v)cerr<<xXx<<' ';cerr<<endl;
#define INF 1000000007
#define LINF 1000000000000000007
#define Yes(X) if(X){cout<<"Yes"<<endl;}else{cout<<"No"<<endl;}
#define YES(X) if(X){cout<<"YES"<<endl;}else{cout<<"NO"<<endl;}
#define ctoi(C) (C-'0')
typedef long long ll;
typedef long double ld;
long long dx[] = {1,0,-1,0};
long long dy[] = {0,1,0,-1};
long long dx8[] = {1,1,0,-1,-1,-1,0,1};
long long dy8[] = {0,1,1,1,0,-1,-1,-1};
long long dx9[] = {1,1,0,-1,-1,-1,0,1,0};

struct matrix{
  long long H;
  long long W;
  vector<vector<long long>> data;
  matrix(vector<vector<long long>> v) : data(v),H(v.size()),W(v[0].size()) {}
  matrix(long long H,long long W) : H(H),W(W) {
    data = vector<vector<long long>>(H,vector<long long>(W,0));
  }
};

namespace Matrix{
  matrix Identity(const long long &n){
    matrix ans(n,n);
    for(long long i=0;i<n;i++)for(long long j=0;j<n;j++){
      ans.data[i][j] = (i==j ? 1 : 0);
    }
    return ans;
  }
  matrix Plus(const matrix &m1,const matrix &m2){
    matrix ans(m1.H,m1.W);
    for(long long i=0;i<m1.H;i++)for(long long j=0;j<m1.W;j++){
      ans.data[i][j] = m1.data[i][j]+m2.data[i][j];
    }
    return ans;
  }
  matrix Multiple(const matrix &m1,const matrix &m2,const long long mod){
    matrix ans(m1.H,m2.W);
    for(long long i=0;i<m1.H;i++)for(long long j=0;j<m2.W;j++){
      ans.data[i][j] = 0;
      for(long long k=0;k<m1.H;k++)ans.data[i][j] += m1.data[i][k]*m2.data[k][j],ans.data[i][j]=(ans.data[i][j]%mod+mod)%mod;
    }
    return ans;
  }
  matrix Multiple(matrix m,long long n,const long long mod){
    n %= mod;
    for(long long i=0;i<m.H;i++)for(long long j=0;j<m.W;j++)m.data[i][j]*=n,m.data[i][j]=(m.data[i][j]%mod+mod)%mod;
    return m;
  }
  matrix POW(matrix m,long long n,long long mod){
    matrix ans = Identity(m.H);
    while(n){
      if(n%2)ans = Multiple(m,ans,mod);
      m = Multiple(m,m,mod);
      n >>= 1;
    }
    return ans;
  }
  void Debug(const matrix &m){
    for(long long i=0;i<m.H;i++){
      for(long long j=0;j<m.W;j++)cerr<<m.data[i][j]<<' ';cerr<<endl;
    }
  }
}

signed main(){
    ll N,K;
    cin >> N >> K;
    vector<vector<ll>> a(N,vector<ll>(N));
    FOR(i,0,N)FOR(j,0,N){
        cin >> a[i][j];
    }
    matrix m(a);
    auto ansm = Matrix::POW(m,K,INF);
    ll ans = 0;
    FOR(i,0,N)FOR(j,0,N){
        ans += ansm.data[i][j];
    }
    cout << ans%INF << endl;
}

Measured memory_bytes: 384
n = int(input())
a = [[int(i) for i in input().split()] for _ in range(n)]
gr = [0]
for i in range(n):
    for j, s in enumerate(gr[:]):
        for k in range(n):
            if (j >> k) & 1 == 1:
                s += a[i][k]
        gr.append(s)

dp = [0] * (1 << n)
for i in range(1, 1 << n):
    j = (i - 1) & i
    ma = gr[i]
    while j > 0:
        ma = max(ma, dp[j] + dp[i ^ j])
        j = (j - 1) & i
    dp[i] = ma
print(dp[(1 << n) - 1])


Measured memory_bytes: 44252
from fractions import gcd
N, K = map(int, input().split())
a = list(map(int, input().split()))
g = 0

for i in range(N):
    g = gcd(a[i], g)
amax = max(a)
q, mod = divmod(K, g)

if mod != 0 or amax < K:
    print('IMPOSSIBLE')
else:
    if q <= amax:
        print('POSSIBLE')
    else:
        print('IMPOSSIBLE')

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

const int maxn = 1e5+10;
long long a[maxn],sum,t,n;

int main(){
	cin >> n;
	for(int i=0; i<n; i++) {
		cin>>a[i];
		sum += a[i];
	}
	t = n*(n+1)/2;
	long long k = sum/t;
	int flag = 1;
	if(sum%t) flag = 0;
	else{
		long long tmp,tt=a[0];
		a[0] = a[0]-a[n-1]-k;
		for(int i=1; i<n; i++){
			tmp = a[i];
		 	a[i] = a[i]-tt;
		 	a[i] -= k;
		 	tt = tmp;
		}
		for(int i=0; i<n; i++){
			if(a[i]>0 || a[i]%n)
				flag = 0;
		}
	}


	if(flag) puts("YES");
	else puts("NO");
}


Measured memory_bytes: 1152
#include <map>
#include <set>
#include <stack>
#include <cmath>
#include <queue>
#include <vector>
#include <cstdio>
#include <string>
#include <cstring>
#include <cstdlib>
#include <iostream>
#include <algorithm>

using namespace std;

const int max_n = 1, inf = 1011111111;

long long k;

int main() {
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    //cout << 50 * 10000000000000000LL - 1 << endl;
    cin >> k;
    if (k < 111111111) {
        cout << 2 << endl;
        long long x = 1 + k / 2, y = k / 2 + 1;
        if (k % 2) {
            ++x;
            --y;
        }
        cout << x << " " << y << endl;
        return 0;
    }
    cout << 50 << endl;
    long long x = 49 + k / 50;
    int o = k % 50;
    for (int i = 0; i < o; ++i) {
        cout << x + 51 - o << " ";
    }
    for (int i = o; i < 50; ++i) {
        cout << x - o << " ";
    }
    cout << endl;
    return 0;
}


Measured memory_bytes: 256
n = gets.chomp.to_i
ret = Hash.new{|h, k| h[k] = Array.new()}
n.times do
  s = gets.chomp.split("")
  h = Hash.new(0)
  s.each do |c|
    h[c] += 1
  end
  h.each do |k, v|
    ret[k] << h[k]
  end
end
ret.keys.sort.each do |k|
  if ret[k].size == n then
    l = ret[k].min
    print(k * l)
  end
end
puts

Measured memory_bytes: 1916
package main

import (
	"fmt"
)

func main() {
	var men int
	fmt.Scan(&men)
	// var ans = men
	var x = men
	var y = men
	// var n = 1
	// if men%2 == 1 {
	// 	n = 2
	// }
	for i := 1; i*i <= men; i = i + 1 {
		if men%i == 0 && x+y > i+(men/i) {
			x = i
			y = (men / i)
		}

	}
	fmt.Println(x + y - 2)

}


Measured memory_bytes: 512
from math import factorial as fact
import math
import fractions
import sys
import itertools
import numpy as np
from collections import Counter
import datetime
#入力:N(int:整数)
def input1():
	return int(input())

#入力:N,M(int:整数)
def input2():
	return map(int,input().split())

#入力:[n1,n2,...nk](int:整数配列)
def input_array():
	return list(map(int,input().split()))

def keta(N):
	return len(str(N))


def input_daytime(input_time):
	time,distance=input_time.split()
	t=time.split(":")
	se=str(t[-1]).split(".")
	dt1 = datetime.timedelta(hours=int(t[0]),minutes=int(t[1]),seconds=int(se[0]),milliseconds=int(se[1]))
	return dt1

def combinations(n,r):
	return list(itertools.combinations(n,r))

def all_sets(num_list):
	subsets=[]
	for i in range(2,len(num_list) + 1):
		for c in combinations(num_list, i):
			subsets.append(c) 
	return subsets

#公約数の列挙
def ch(x1):
	cf=[]
	for i in range(2,math.sqrt(x1)+1):
		if x1 % i==0:
			cf.append(i)
	return cf

def CountOneRoots(x,y):
	#x:縦，y:横
	return fact(x+y)/fact(x)/fact(y)

# 素因数分解
def factorization(n):
	tmp=n
	count=0
	for i in range(2,int(n**0.5)+2):
		if tmp%i==0:
			cnt=0
			while tmp%i==0:
				cnt+=1
				tmp//=i
			count+=1
	if tmp!=1:
		count+=1

	return count
			




n=input1()
s=[]
d={}
for k in range(n):
	ch=str(input())
	s.append(ch)
	d[ch]=0
for i in s:
	d[i]+=1
print(len(d))





	







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

main(){
	long long int a[3];
	cin >> a[0] >> a[1] >> a[2];
	sort(a,a+3);
	if(a[0]%2==0 || a[1]%2==0 || a[2]%2==0){
		cout << "0" <<endl;
	}else{
		cout << a[0]*a[1] <<endl;
	}

}


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

typedef long long ll;
 
const ll M = 1e9 + 7;
ll fac [300001];
ll ifac[300001];
 
ll powe(ll x, ll n){
    ll ans = 1;
    while(n != 0){
        if(n&1) ans = ans*x % M;
        x = x*x % M;
        n = n >> 1;
    }
    return ans;
}
 
ll comb(ll a, ll b){
    ll den = ifac[a-b]* ifac[b] % M;
    return den * fac[a] % M;
}

int main()
{
    long long n,m;
    cin >> n >> m;
    map<long long, long long> cnt;
    int num = 0;
    long long s = sqrt(m);
    
    fac[0] = 1;
    ifac[0] = 1;
    for(ll i = 0; i<300000; i++) fac[i+1] = fac[i]*(i+1) % M;
    for(ll i = 0; i<300000; i++) ifac[i+1] = ifac[i]*powe(i+1, M-2) % M;
    
    for(int i=2; i<=m && m!=1; i++){
        while(m%i == 0){
            if(cnt.count(i) == 0) 
                cnt[i] = 1;
            else
                cnt[i]++;
            m = m/i;
        }
    }
    
    long long ans = 1;
    for(auto c: cnt){
        // cout << c.first << " "<< c.second << endl;
        ans = (ans*comb(n-1+c.second, c.second))%M;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 4992
#include <bits/stdc++.h>
#define rep(i,l,r) for (int i=l,i##end=r;i<=i##end;++i)
#define per(i,r,l) for (int i=r,i##end=l;i>=i##end;--i)
#define rep0(i,r) for (int i=0,i##end=r;i<i##end;++i)
#define ll long long
using namespace std;
const int N=1e6+6;
int a[N];
int main(){
	int n; scanf("%d",&n);
	rep(i,1,n) scanf("%d",&a[i]);
	sort(a+1,a+1+n); ll s=0;
	if (n%2==0){
        rep(i,1,n/2-1) s-=2*a[i];
        rep(i,n/2+2,n) s+=2*a[i];
        s+=a[n/2+1]-a[n/2];
	}
	else{
        int m=(n+1)/2;
        rep(i,1,m-2) s-=2*a[i];
        rep(i,m+2,n) s+=2*a[i];
        s+=max(a[m]+a[m+1]-2*a[m-1],2*a[m+1]-a[m]-a[m-1]);
	}
	cout<<s<<endl;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main() {
  ll a,b;
  cin>>a>>b;
  vector<ll>vec(a);
  for(ll i=0;i<a;i++){
    cin>>vec.at(i);
  }
  sort(vec.begin(),vec.end());
  ll c=0;
  for(ll i=0;i<b;i++){
    c+=vec.at(i);
  }
  cout<<c<<endl;  
}


Measured memory_bytes: 3624
#include "bits/stdc++.h"
#define int long long
#define endl '\n'
using namespace std;
 
typedef long long ll;
#define db(x) cerr << #x << ": " << x << '\n';
#define read(a) int a; cin >> a;
#define readb(a, b) int a, b; cin >> a >> b;
#define readc(a, b, c) int a, b, c; cin >> a >> b >> c;
#define readarr(a, n) int a[(n) + 1] = {}; FOR(i, 1, (n)) {cin >> a[i];}
#define readmat(a, n, m) int a[n + 1][m + 1] = {}; FOR(i, 1, n) {FOR(j, 1, m) cin >> a[i][j];}

#define print(a) cout << a << endl;
#define printarr(a, n) FOR (i, 1, n) cout << a[i] << " "; cout << endl;
#define printv(v) for (int i: v) cout << i << " "; cout << endl;
#define printmat(a, n, m) FOR (i, 1, n) {FOR (j, 1, m) cout << a[i][j] << " "; cout << endl;} cout << endl;
#define all(v) v.begin(), v.end()
#define sz(v) (int)(v.size())
#define rz(v, n) v.resize((n) + 1);
#define pb push_back
#define fi first
#define se second
#define vi vector <int>
#define pi pair <int, int>
#define vpi vector <pi>
#define vvi vector <vi>
#define FOR(i, a, b) for (int i = (a); i <= (b); i++)
#define FORD(i, a, b) for (int i = (a); i >= (b); i--)
const ll inf = 1e18;
const ll mod = 1e9 + 7;
const ll N = 2e5 + 1;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
 
signed main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	
	readc(n, m, l);
    vvi adj (n + 1, vi(n + 1, inf)), dp(n + 1, vi(n + 1));
    
	FOR (i, 1, m)
	{
	    readc(x, y, z);
	    adj[x][y] = adj[y][x] = z;
	}
	
	dp = adj;
	FOR (k, 1, n)
	    FOR (i, 1, n)
	        FOR (j, 1, n)
	            dp[i][j] = min(dp[i][j], dp[i][k] + dp[k][j]);
    
    
    vvi dp2(n + 1, vi(n + 1, inf));
    
	FOR (i, 1, n)
        FOR (j, i + 1, n)
    	    if (dp[i][j] <= l) dp2[i][j] = dp2[j][i] = 1;
    	    
	FOR (k, 1, n)
	    FOR (i, 1, n)
	        FOR (j, 1, n)
	            dp2[i][j] = min(dp2[i][j], dp2[i][k] + dp2[k][j]);
	
	read(q);
	while(q--)
	{
	    readb(s, t);
	    if (dp2[s][t] < inf) cout << dp2[s][t] - 1 << endl;
	    else cout << -1 << endl;
	}
}























Measured memory_bytes: 2688
#include <iostream>
#include <string>
int main(){
	std::string s;
	int a,b,n;
	while (true){
		getline(std::cin,s);
		if(std::cin.eof())break;
		n=s.size();
		while(n){
			a=s[0];
			for (int i=1;i<n;i++){
				b=s[i];
				s[i-1]=(a+b-'0'*2)%10+'0';
				a=b;
			}
			n--;
		}
		std::cout<<s[0]<<"\n";
	}
}

Measured memory_bytes: 1164
fun main(args: Array<String>) = yorukatsu23c()

fun yorukatsu23c() {
    val (n, k) = readLine()!!.split(' ').map { it.toInt() }

    val answer = (1L..n).map {
        var curr = it
        var count = 0
        while (curr < k) {
            curr *= 2
            count++
        }
        1.0 / n * Math.pow(0.5, count.toDouble())
    }.sum()

    println(answer)
}


Measured memory_bytes: 38676
for _ in[0]*int(input()):
 e=input()
 for i in range(26):
  for j in range(26):
   a=''.join([c,chr(((ord(c)-97)*i+j)%26+97)][c.islower()]for c in e)
   if'that'in a or'this'in a:print(a);break


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

#define DEBUG(x) cerr << #x << ": " << x << endl;
#define ll long long

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

    map<char, int> m;
    for (char c : s) {
        m[c]++;
    }

    for (auto x : m) {
        if (x.second & 1) {
            cout <<"No" << endl;
            return 0;
        }
    }

    cout << "Yes" << endl;

    return 0;
}

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

typedef pair<int, int> P;

int main(){
	int H, W, Ch, Dh, Cw, Dw;
	cin >> H >> W >> Ch >> Cw >> Dh >> Dw;
	char S[H][W];
	for(int i=0;i<H;i++){
		for(int j=0;j<W;j++){
			cin >> S[i][j];
		}
	}
	int dh[4] = {1, 0, -1, 0}, dw[4] = {0, 1, 0, -1};
	int wh[20] = {2, 1, 0, -1, -2, 2, 1, -1, -2, 2,
					-2 , 2, 1, -1, -2, 2, 1, 0, -1, -2};
	int ww[20] = {2, 2, 2, 2, 2, 1, 1, 1, 1, 0,
					0, -1, -1, -1, -1, -2, -2, -2, -2, -2};
	queue<P> queA, queB;
	int D[H][W];
	for(int i=0;i<H;i++){
		for(int j=0;j<W;j++){
			D[i][j] = -1;
		}
	}
	queA.push(P(Ch - 1, Cw - 1));
	queB.push(P(Ch - 1, Cw - 1));
	D[Ch - 1][Cw - 1] = 0;
	while(queB.size() > 0){
		while(queA.size() > 0){
			P p = queA.front();
			queA.pop();
			if(p.first == Dh - 1 && p.second == Dw - 1) break;
			for(int i=0;i<4;i++){
				int nh = p.first + dh[i];
				int nw = p.second + dw[i];
				if(0 <= nh && nh < H &&
					0 <= nw && nw < W && 
					S[nh][nw] == '.' && D[nh][nw] == -1){
					queA.push(P(nh, nw));
					queB.push(P(nh, nw));
					D[nh][nw] = D[p.first][p.second];
					//cout << "A:" << nh << ":" << nw << ":" << D[nh][nw] << endl; 
				}
			}
		}
		if(queA.size() == 0){
			P p = queB.front();
			queB.pop();
			if(p.first == Dh - 1 && p.second == Dw - 1) break;
			for(int i=0;i<20;i++){
				int nh = p.first + wh[i];
				int nw = p.second + ww[i];
				if(0 <= nh && nh < H &&
					0 <= nw && nw < W && 
					S[nh][nw] == '.' && D[nh][nw] == -1){
					queA.push(P(nh, nw));
					queB.push(P(nh, nw));
					D[nh][nw] = D[p.first][p.second] + 1;
					//cout << "B:" << nh << ":" << nw << ":" << D[nh][nw] << endl;
				}
			}
		}
	}
	cout << D[Dh - 1][Dw - 1] << endl;
}


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

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

    if (a<c && c<b){
        cout << "Yes" << endl;
    }else if(b<c && c<a){
        cout << "Yes" << endl;
    }else {
        cout << "No" << endl;
    }
}

Measured memory_bytes: 256
import math
A, B, H, M = map(int, input().split())
sh = math.pi * (H + M / 60) / 6
sm = math.pi * M / 30
s = abs(sh - sm)
C = math.sqrt(A ** 2 + B ** 2 - 2 * A * B * math.cos(s))
print(C)

Measured memory_bytes: 9488
def main():
    n, d, *x = map(int, open(0).read().split())

    cnt = 0
    for i in range(n-1):
        for j in range(i+1, n):
            y = x[i*d:(i+1)*d]
            z = x[j*d:(j+1)*d]
            dist_double = 0
            for cur_y, cur_z in zip(y, z):
                dist_double += (cur_y - cur_z) ** 2
            dist = int(dist_double ** 0.5 + 0.5)
            if dist ** 2 == dist_double:
                cnt += 1

    ans = cnt
    print(ans)
    return()

if __name__ == '__main__':
    main()


Measured memory_bytes: 3188
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int m,d;
  int ans=0;
  cin>>m>>d;
  for(int i=2;i<10;i++)
    for(int j=2;j<10;j++)
    {
    	if(i*10+j>d)
    	  continue;
    	else
    	  if(i*j>m)
    	    continue;
    	  else
    	    ans++;
	}
  cout<<ans;
  return 0;
}

Measured memory_bytes: 256