akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;

internal class Program {
    static void Main() => CustomMain();

    static void Solve() {
        string a, b, c;
        ReadMulti(out a, out b, out c);

        string ans = "NO";
        if (a[a.Length - 1] == b[0] && b[b.Length - 1] == c[0]) {
            ans = "YES";
        }

        WriteAnswer(ans);
    }


    static void CustomMain() {
#if DEBUG
        // ファイルからテストケースを読み込む
        ChangeStdIn();
        // 時間計測
        var stopwatch = new Stopwatch();
        stopwatch.Start();
#endif
        // 出力高速化
        var streamWriter = new StreamWriter(Console.OpenStandardOutput()) {AutoFlush = false};
        Console.SetOut(streamWriter);
        // 回答
        Solve();
#if DEBUG
        stopwatch.Stop();
        Console.WriteLine(stopwatch.Elapsed);
#endif
        Console.Out.Flush();
    }

    static string ReadString() => Console.ReadLine().Trim();
    static int ReadInt() => int.Parse(ReadString());
    static long ReadLong() => long.Parse(ReadString());
    static float ReadFloat() => float.Parse(ReadString());
    static double ReadDouble => double.Parse(ReadString());

    static string[] ReadStringArray() => ReadString().Split(' ');
    static int[] ReadIntArray() => Array.ConvertAll(ReadString().Split(' '), int.Parse);
    static long[] ReadLongArray() => Array.ConvertAll(ReadString().Split(' '), long.Parse);
    static float[] ReadFloatArray() => Array.ConvertAll(ReadString().Split(' '), float.Parse);
    static double[] ReadDoubleArray() => Array.ConvertAll(ReadString().Split(' '), double.Parse);

    static T TypeConversion<T>(string s) {
        if (typeof(T) == typeof(int)) {
            return (T) Convert.ChangeType(int.Parse(s), typeof(T));
        } else if (typeof(T) == typeof(long)) {
            return (T) Convert.ChangeType(long.Parse(s), typeof(T));
        } else if (typeof(T) == typeof(double)) {
            return (T) Convert.ChangeType(double.Parse(s), typeof(T));
        } else {
            return (T) Convert.ChangeType(s, typeof(T));
        }
    }

    static void ReadMulti<T, U>(out T a, out U b) {
        var str = ReadStringArray();
        a = TypeConversion<T>(str[0]);
        b = TypeConversion<U>(str[1]);
    }

    static void ReadMulti<T, U, V>(out T a, out U b, out V c) {
        var str = ReadStringArray();
        a = TypeConversion<T>(str[0]);
        b = TypeConversion<U>(str[1]);
        c = TypeConversion<V>(str[2]);
    }

    static void WriteAnswer(object ans) => Console.WriteLine(ans);

    static bool IsOdd(long num) {
        return (num & 1) == 1;
    }

    static bool IsEven(long num) {
        return (num & 1) == 0;
    }

    static long GCD(long a, long b) {
        return b != 0 ? GCD(b, a % b) : a;
    }

    static long RoundUp(long a, long b) {
        return (a + b - 1) / b;
    }


    static void ChangeStdIn() {
        var path = "./../../TestCase.txt";
        var exStdIn = new System.IO.StreamReader(path);
        Console.SetIn(exStdIn);
    }
}

Measured memory_bytes: 13140
function Main(input) {
    input = input.split("\n");
    for (i=0; i < input.length-1; i++) {
        tmp = input[i].split(" ");
        var a = parseInt(tmp[0], 10);
        var b = parseInt(tmp[1], 10);
        console.log('%d', a*b, a*2 + b*2);
    }
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));


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

# define pb push_back
# define fr first
# define sc second
# define mk make_pair

using namespace std;

const int inf = 1e9 + 7;
const int N = 1e6 + 5;

typedef long long ll;

int n, z, w, a[N], ans, pos, fl = 1;

int main()
{
      cin >> n >> z >> w;

      for(int i = 1; i <= n; i ++)
            cin >> a[i];
      ans = abs(w - a[n]);

      if(n > 1)
            ans = max(ans, abs(a[n] - a[n - 1]));

      cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
//cin.ignore();	// better to use 2 times getline(cin,s);
// g++ iterator.cpp -std=c++17
//cout << (A + B == C ? "YES" : "NO") << endl;
//__gcd(a,b)
#define pb push_back
#define mk make_pair
#define vll vector<ll>
#define mll map<ll,ll >
#define mlli map<ll,ll>::iterator
#define size size()
#define endl "\n"
#define ll long long int
#define ld long double
void fast(){ios_base::sync_with_stdio(false);
cin.tie(NULL);cout.tie(NULL);}


int main(void)
{
	fast();
	int a,b,c;
	cin>>a>>b>>c;
	if( c-a-b>0 && 2LL*4*a*b<2LL*(c-a-b)*(c-a-b))
	{
	    cout<<"Yes"<<endl;
	}
	else 
	{
	    cout<<"No"<<endl;
	}
}

Measured memory_bytes: 256
n, w = map(int, input().split())
di = dict()
m = 0
for _ in range(n):
  x,y = map(int, input().split())
  if x not in di:
    di[x] = []
  di[x].append(y)
for i in di:
  di[i].sort(reverse=True)
a = min(di.keys())
b,c,d = a+1,a+2,a+3
for i in b,c,d:
  if i not in di:
    di[i] = []
for i in range(len(di[a])+1):
  for j in range(len(di[b])+1):
    for k in range(len(di[c])+1):
      for l in range(len(di[d])+1):
        if i*a + j*b + k*c + l*d <= w:
          m = max(m, sum(di[a][:i] + di[b][:j] + di[c][:k] + di[d][:l]))
print(m)

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

long long K, A, B;

int main() {
	cin >> K >> A >> B;

	// ビスケットを永遠にたたき続ける場合
	long long Way1 = 1LL + K;

	// その他
	long long Way2 = 0;
	long long rem = K - (A - 1LL);
	if (rem >= 0LL) {
		Way2 = A;
		long long R1 = (B - A) * (rem / 2LL);
		long long R2 = (rem % 2LL);
		Way2 += R1 + R2;
	}
	cout << max(Way1, Way2) << endl;
	return 0;
}

Measured memory_bytes: 256
find4 cs a
    | search < 0 = [-1,-1,-1,-1]
    | otherwise = [a] ++ bs
    where
        bs = zipWith (-) cs [a,a,a]
        search = foldl1 (*) bs

solve c1s c2s c3s i
    | i > 100 = "No"
    | concat [c1s,c2s,c3s] `elem` res' = "Yes"
    | otherwise = solve c1s c2s c3s (i+1)
    where
        ab = find4 c1s i
        [a1,b1,b2,b3] = find4 c1s i
        a2s = zipWith (-) c2s [b1,b2,b3]
        a3s = zipWith (-) c3s [b1,b2,b3]
        res x y = (pure (+) <*> [a1,x,y] <*> [b1,b2,b3])
        res' = pure res <*> a2s <*> a3s

main = do
    c1s <- map read . words <$>  getLine
    c2s <- map read . words <$>  getLine
    c3s <- map read . words <$>  getLine
    putStrLn $ solve c1s c2s c3s 0

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

int main(){
	cin.tie(0),ios::sync_with_stdio(false);
	string s;
	vector<int>v(26,0);
	while(getline(cin,s)){
		for(auto&&i:s){
			if(i>='a'&&i<='z')++v.at(i-'a');
			else if(i>='A'&&i<='Z')++v.at(i-'A');
		}
	}
	for(char i='a';i<='z';++i){
		cout<<i<<" : "s<<v.at(i-'a')<<"\n"s;
	}
}


Measured memory_bytes: 3228
// Created by sz
#include <bits/stdc++.h>
using namespace std;

int main(){
#ifdef LOCAL
    freopen("./input.txt", "r", stdin);
#endif
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    
    int a[3];
    for(int i = 0; i< 3; i++)cin>>a[i];
    sort(a, a+3);
    cout<<a[0]*a[1]/2<<endl;
    
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef pair<LL, LL> pii;

int N, K, num;
int A[505050];
int T[2020202];
bool chk[505050];
int ans[505050];

void update(int id, int s, int e, int t){
    if (e < t || t < s) return;
    if (s == e) {
        T[id] = t;
        return;
    }
    int mid = (s+e)/2;
    update(id*2, s, mid, t);
    update(id*2+1, mid+1, e, t);
    if (A[T[id*2]] > A[T[id*2+1]]) T[id] = T[id*2];
    else T[id] = T[id*2+1];
}

int query(int id, int s, int e, int ts, int te){
    if (e < ts || te < s) return N+1;
    if (ts <= s && e <= te) return T[id];
    int mid = (s+e)/2;
    int lret=query(id*2, s, mid, ts, te);
    int rret=query(id*2+1, mid+1, e, ts, te);
    if (A[lret] > A[rret]) return lret;
    return rret;
}

priority_queue<int> PQ;

int main(){
    scanf("%d %d", &N, &K);
    for (int i=0; i<N; i++){
        scanf("%d", &A[i]);
        update(1, 0, N-1, i);
    }
    for (int i=0; i<N; i+=K){
        int k = query(1, 0, N-1, i, min(N, i+K-1));
        if (k == query(1, 0, N-1, max(0, k-K+1), min(N-1, k+K-1))){
            PQ.push(k);
            chk[k] = true;
        }
    }
    num = N;
    while (!PQ.empty()){
        int t = PQ.top();
        PQ.pop();
        A[t] = 0;
        update(1, 0, N-1, t);
        ans[t] = num--;
        int k = query(1, 0, N-1, t/K*K, min(N-1, (t/K+1)*K-1));
        if (A[k] && !chk[k] && k == query(1, 0, N-1, max(0, k-K+1), min(N-1, k+K-1))){
            PQ.push(k);
            chk[k] = true;
        }
        k = query(1, 0, N-1, max(0, (t/K-1)*K), max(0, t/K*K-1));
        if (A[k] && !chk[k] && k == query(1, 0, N-1, max(0, k-K+1), min(N-1, k+K-1))){
            PQ.push(k);
            chk[k] = true;
        }
        k = query(1, 0, N-1, min(N, (t/K+1)*K), min(N-1, (t/K+2)*K-1));
        if (A[k] && !chk[k] && k == query(1, 0, N-1, max(0, k-K+1), min(N-1, k+K-1))){
            PQ.push(k);
            chk[k] = true;
        }
    }
    for (int i=0; i<N; i++) printf("%d\n", ans[i]);
    return 0;
}


Measured memory_bytes: 15856
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>
using namespace std;
using bint = boost::multiprecision::cpp_int;
using ll = long long;
using pint = pair<int, int>;
using pll = pair<ll, ll>;
#define rep(i,n) for (int i = 0; i < (n); i++)
#define repSE(i,s,n) for (int i = (s); i < (n); i++)
#define rrepSE(i,s,e) for (int i = (s); i > (e); i--)
#define ssort(v) sort(v.begin(), v.end())
#define gsort(v) sort(v.rbegin(), v.rend())
template<typename T> istream &operator>>(istream &is, vector<T> &vec){ for (auto &v : vec) is >> v; return is; }
template<typename T> ostream &operator<<(ostream &os, const vector<T> &vec){ os << "["; for (auto v : vec) os << v << ","; os << "]"; return os; }
template<typename T> ostream &operator<<(ostream &os, const deque<T> &vec){ os << "deq["; for (auto v : vec) os << v << ","; os << "]"; return os; }
template<typename T> ostream &operator<<(ostream &os, const set<T> &vec){ os << "{"; for (auto v : vec) os << v << ","; os << "}"; return os; }
template<typename T> ostream &operator<<(ostream &os, const unordered_set<T> &vec){ os << "{"; for (auto v : vec) os << v << ","; os << "}"; return os; }
template<typename T> ostream &operator<<(ostream &os, const multiset<T> &vec){ os << "{"; for (auto v : vec) os << v << ","; os << "}"; return os; }
template<typename T> ostream &operator<<(ostream &os, const unordered_multiset<T> &vec){ os << "{"; for (auto v : vec) os << v << ","; os << "}"; return os; }
template<typename T1, typename T2> ostream &operator<<(ostream &os, const pair<T1, T2> &pa){ os << "(" << pa.first << "," << pa.second << ")"; return os; }
template<typename TK, typename TV> ostream &operator<<(ostream &os, const map<TK, TV> &mp){ os << "{"; for (auto v : mp) os << v.first << "=>" << v.second << ","; os << "}"; return os; }
template<typename TK, typename TV> ostream &operator<<(ostream &os, const unordered_map<TK, TV> &mp){ os << "{"; for (auto v : mp) os << v.first << "=>" << v.second << ","; os << "}"; return os; }
template<typename T> bool chmax(T &m, const T q) { if (m < q) {m = q; return true;} else return false; }
template<typename T> bool chmin(T &m, const T q) { if (q < m) {m = q; return true;} else return false; }
#define DEBUG_PRINT(var) std::cout << #var << " = " << var << "\n";

int main()
{
    ll a, b, v, w, t;
    cin >> a >> v;
    cin >> b >> w;
    cin >> t;
    if (v <= w) { cout << "NO\n"; return 0; }
    bool ans  = (v - w) * t >= abs(b - a);
    cout << (ans?"YES":"NO") << "\n";
    return 0;
}


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

#define FOR(i,a,n) for (int i = a; i < (int)n; ++i)
#define REP(i,n) FOR(i,0,n)
#define whole(f,x,...) ([&](decltype((x)) whole) { \
    return (f)(begin(whole), end(whole), ## __VA_ARGS__); })(x)
template<typename T> bool chmin(T &a, const T &b) {if (a > b) { a = b; return true; }return false;}
template<typename T> bool chmax(T &a, const T &b) {if (a < b) { a = b; return true; }return false;}

using ll = long long;

constexpr ll INF = (1e9);
constexpr ll MOD = (1e9+7);

#define abs(x) (x > 0 ? (x) : (-x))

int main() {
  int n; cin >> n;
  vector<ll> a(n);
  vector<ll> b(n);
  vector<ll> b2(n);
  REP(i,n) {
    cin >> a[i];
    b[i] = a[i] - (i+1);
    b2[i] = a[i] - (i+1);
  }
  whole(sort, b);
  ll t = b[n/2];
  ll t2 = b[n/2-1];
  REP(i,n) {b[i] -= t; b[i] = abs(b[i]);}
  REP(i,n) {b2[i] -= t2; b2[i] = abs(b2[i]);}
  ll sum1 = whole(accumulate, b, 0L);
  ll sum2 = whole(accumulate, b2, 0L);
  cout << min(sum1, sum2) << endl;
  return 0;
}


Measured memory_bytes: 4992
//#pragma  GCC optimize("Ofast")

//#ifdef  DEBUG
//#define _GLIBCXX_DEBUG
//#endif

// -Ofast
// -O3
// -O2
// -fsanitize=address
// -fsanitize=undefined

// add_compile_options()

#include <iostream>
#include <map>
#include <vector>
#include <set>
#include <stack>
#include <bitset>
#include <queue>
#include <algorithm>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
#include <iomanip>
#include <unordered_map>
#include <cmath>
#include <cassert>

using namespace std;
//using namesparsace __gnu_pbds;



void solve();


int main()
{
    srand(time(0));
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
#ifdef DEBUG
    freopen("input.txt", "r", stdin);
#endif
    //freopen("input.txt", "r", stdin);
    //freopen("trench.out", "w", stdout);
    solve();
    return 0;
}

#define int long long

int max(int a, int b) {
    return a > b ? a : b;
}

const int maxN = 5e5 + 10, inf = 1e18;

int ans, n;
string s;
vector < int > a[maxN];
int e[maxN];
bool used[maxN];

void dfs(int v) {
    used[v] = true;
    int o = 0;
    for (int i = 0; i < a[v].size(); i++) {
        int to = a[v][i];
        if (!used[to]) {
            dfs(to);
        }
        o = max(o, e[to] + 1);
    }
    e[v] = o;
    ans += o;
}

void solve() {
    cin >> s;
    n = s.size();
    for (int i = 0; i < n; i++) {
        if (s[i] == '>') a[i].push_back(i + 1);
        else a[i + 1].push_back(i);
    }
    for (int i = 0; i < n + 1; i++) {
        if (!used[i]) {
            dfs(i);
        }
    }
    cout << ans;
}

Measured memory_bytes: 63772
#include <iostream>
using namespace std;
 
int main() {
  int N;
  int counter = 0;
  int D1, D2;
  cin >> N;
  for (int i = 0; i < N; i++) {
    cin >> D1 >> D2;
    if (D1 == D2) {
      counter++;
    } else {
      counter = 0;
    }
    if (counter == 3) {
      cout << "Yes" << endl;
      return 0;
    }
  }
  cout << "No" << endl;
}


Measured memory_bytes: 3592
#include <float.h>
#include <inttypes.h>
#include <limits.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <unistd.h>
#include <math.h>
#ifdef __cplusplus
#include <bits/stdc++.h>
#endif

int comp(const void *a, const void *b){return (*(int*)a>*(int*)b)-(*(int*)a<*(int*)b);}
int compr(const void *a, const void *b){return (*(int*)a<*(int*)b)-(*(int*)a>*(int*)b);}

#define putchar(c) putc_unlocked((c), stdout)
#define getchar() getc_unlocked(stdin)
char nextchar(void){ char c=getc_unlocked(stdin); while(c==' '||c=='\n') c=getc_unlocked(stdin); return c; }
int32_t nextint(void){ char c=getc_unlocked(stdin); while(c!='-'&&(c<'0'||'9'<c)) c=getc_unlocked(stdin); int s=0; if(c=='-'){s=1;c=getc_unlocked(stdin);} uint32_t x=0; while('0'<=c && c<='9'){ x=x*10+c-'0'; c=getc_unlocked(stdin); } return s?-x:x; }
int64_t nextlong(void){ char c=getc_unlocked(stdin); while(c!='-'&&(c<'0'||'9'<c)) c=getc_unlocked(stdin); int s=0; if(c=='-'){s=1;c=getc_unlocked(stdin);} uint64_t x=0; while('0'<=c && c<='9'){ x=x*10+c-'0'; c=getc_unlocked(stdin); } return s?-x:x; }
uint32_t nextpint(void){ char c=getc_unlocked(stdin); while(c<'0'||'9'<c) c=getc_unlocked(stdin); uint32_t x=0; while('0'<=c && c<='9'){ x=x*10+c-'0'; c=getc_unlocked(stdin); } return x; }
uint64_t nextplong(void){ char c=getc_unlocked(stdin); while(c<'0'||'9'<c) c=getc_unlocked(stdin); uint64_t x=0; while('0'<=c && c<='9'){ x=x*10+c-'0'; c=getc_unlocked(stdin); } return x; }
uint32_t nextstr(char *s){ char c=getc_unlocked(stdin); while(c==' '||c=='\n') c=getc_unlocked(stdin); uint32_t len=0; while(c!=' '&&c!='\n'){ *s++=c; len++; c=getc_unlocked(stdin); } *s='\0'; return len; }
uint32_t nextstrln(char *s){ char c=getc_unlocked(stdin); while(c==' '||c=='\n') c=getc_unlocked(stdin); uint32_t len=0; while(c!='\n'){ *s++=c; len++; c=getc_unlocked(stdin); } *s='\0'; return len; }

void printint(int x){ if(x<0){x=-x; putc_unlocked('-', stdout);}else if(x==0){putc_unlocked('0', stdout);} int d=0; char s[10]; while(x){ s[d]='0'+x%10; x/=10; d++; } for (int i=d-1; i>=0; i--) putc_unlocked(s[i], stdout); putc_unlocked('\n', stdout); }
void printlong(long x){ if(x<0){x=-x; putc_unlocked('-', stdout);}else if(x==0){putc_unlocked('0', stdout);} int d=0; char s[20]; while(x){ s[d]='0'+x%10; x/=10; d++; } for (int i=d-1; i>=0; i--) putc_unlocked(s[i], stdout); putc_unlocked('\n', stdout); }

inline int max2(const int a, const int b){return a>b?a:b;}
inline int min2(const int a, const int b){return a>b?b:a;}
inline int dif2(const int a, const int b){return a>b?a-b:b-a;}
inline int abs2(const int a){return a>=0?a:-a;}

long f(int a){return (long)a*(a+1)/2;}
int main(void){
	int n=nextpint();
	long ans=f(n)-f(n/3)*3-f(n/5)*5+f(n/15)*15;
	printf("%ld\n", ans);
}


Measured memory_bytes: 1596
<?php
fscanf(STDIN, '%d', $cnt);
$points = explode(' ', trim(fgets(STDIN)));
$answer = 0;
$height = 0;
foreach ($points as $key => $point) {
    $height = max($height, $point);
    if ($key === 0) {
        $answer++;
        continue;
    }
    if ($point >= $height) {
        $answer++;
    }
}
echo $answer;

Measured memory_bytes: 4728
#include <iostream>
#include <vector>
#include <string>
using namespace std;
char bit[] = {'0','1'};
string str = "";
int inf = 1<<28;
int pos_dif(string s,int index,char op){
  if(index ==  str.size())return -1;
  if(s[index] != str[index] && str[index] == op)return index;
  
  return pos_dif(s,index+1,op);
}
int swap_bit(int index,string s,int cnt){
  if(s.size() == 1) return 0;
  if(index == str.size()){
	return cnt;
  }

  if(str[index] == s[index]) {
	return swap_bit(index+1,s,cnt);
  }
  int pos = pos_dif(s,index+1,s[index]);
  if(pos == -1)return inf;
  char tmp = s[index];
  s[index] = s[pos];
  s[pos] = tmp;
  return swap_bit(index+1,s,cnt+pos-index);
}
int main(){
  
  int n,m;
  cin >> n >> m;

  for(int i = 0;i < n;i++){
	string tmp;
	cin >> tmp;
	str += tmp;
  }
  string s1 = "",s2 = "";
  for(int i = 0;i < m;i++){
	int tmp;
	cin >> tmp;
	for(int j = i;j < i+tmp;j++){
	  s1 += bit[i%2];
	  s2 += bit[(i+1)%2];
	}
  }
  cout << min(swap_bit(0,s1,0),swap_bit(0,s2,0)) << endl;

  return 0;
}

Measured memory_bytes: 1220
#include <bits/stdc++.h>
#define rep(i,cc,n) for(int i=cc;i<=n;++i)
#define drep(i,cc,n) for(int i=cc;i>=n;--i)
#define sz(s) (int)(s.size())
#define vecprint(v) rep(i,0,v.size()-1)cout << v[i] << " ";cout << endl;
using namespace std;
const int mod=1000000007;
typedef long long ll;
typedef pair<int,int> P;

int main(){
    int n,ans=0;
    cin >> n;
    vector<int> a(n),p(n);
    vector<vector<int>> x(n),y(n);
    rep(i,0,n-1){
        cin >> a[i];
        x[i].resize(a[i]);
        y[i].resize(a[i]);
        rep(j,0,a[i]-1){
            cin >> x[i][j] >> y[i][j];
        }
    }
    rep(i,0,pow(2,n)-1){
        int flg = 0;
        int cnt = 0;
        rep(j,0,n-1){
            if(i & (1<<j)){
                p[j] = 1;
                ++cnt;
            }else{
                p[j] = 0;
            }
        }
        rep(j,0,n-1){
            if(p[j] == 1){
                rep(k,0,a[j]-1){
                    if((y[j][k] == 0 && p[x[j][k]-1]==1)||(y[j][k] == 1 && p[x[j][k]-1]==0)){
                        flg = 1;
                        break;
                    }
                }
            }
        }
        if(flg == 0){
            ans = max(ans,cnt);
            //vecprint(p);
        }
    }

    cout << ans << endl;
//  printf("%.10f\n",ans);

    return 0;
}

Measured memory_bytes: 256
def dfs(i, A, B, C):
    global ans
    if i == n:
        if A and B and C:
            ans = min(ans, abs(a - sum(A)) + abs(b - sum(B)) + abs(c - sum(C)) + (len(A) + len(B) + len(C) - 3) * 10)
    else:
        # a の肉焼き器に乗せるか、 b の肉焼き器に乗せるか
        dfs(i + 1, A, B, C)
        dfs(i + 1, A + [L[i]], B, C)
        dfs(i + 1, A, B + [L[i]], C)
        dfs(i + 1, A, B, C + [L[i]])

n, a, b, c = map(int, input().split())
L = [int(input()) for i in range(n)]
ans = float("inf")
dfs(0, [], [], [])
print(ans)

Measured memory_bytes: 3064
import java.util.Scanner;

public class Main{

	public static void main(String[] args) {

		Scanner scanner = new Scanner(System.in);
		String[] tmp = scanner.nextLine().split(" ");
		long a   = Long.parseLong(tmp[0]);
		long b   = Long.parseLong(tmp[1]);
		long ans = minbai(a, b);


		System.out.println(ans);
	}

	public static long gcd(long x, long y) {

		if(x % y == 0) {

			return y;

		}else {

			return gcd(y, x % y);

		}

	}

	public static long minbai(long x, long y) {

		return x * y / gcd(x,y);

	}
}

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

int main(){
    
    int N;
    cin >> N;
    int ans =0;
    
    for(int i=1;i<=31;i++){
        int mul=i;
        for(int k=2;k<=10;k++){
            mul=i;
            for(int j=1;j<=k;j++){
                mul=mul*i;
                if(mul<=N){
                    ans = max(ans,mul);
                }
            }
        }
    }
    
    cout << ans << endl;
    return 0;
}


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

//#define int long long
#define DBG 0
#define dump(o) if(DBG){cerr<<#o<<" "<<(o)<<" ";}
#define dumpl(o) if(DBG){cerr<<#o<<" "<<(o)<<endl;}
#define dumpc(o) if(DBG){cerr<<#o; for(auto &e:(o))cerr<<" "<<e;cerr<<endl;}
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)
const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9 + 7);
template<class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (a > b) { a = b; return true; } return false; }

signed main() {
	int N, R, T; cin >> N >> R >> T;
	vector<int> p(N); rep(i, 0, N) { cin >> p[i]; }
	vector<int> cnt(R, 0);
	vector<int> tmp(R, 0);
	vector<int> d(N, 0);
	rep(t, 0, T) {
		rep(i, 0, N) {
			d[i] += p[i];
		}
		rep(i, 0, N) {
			int idx = d[i] % R;
			if (tmp[idx]) tmp[idx]--;
			else cnt[idx]++;
		}
		if (t == 0)continue;
		rep(i, 0, N) {
			int idx = d[i] % R;
			tmp[idx]++;
		}
		dumpc(cnt);
		dumpc(tmp);
	}
	cout << accumulate(all(cnt), 0) << endl;
	return 0;
}

Measured memory_bytes: 3092
import Data.Maybe (fromJust)
import qualified Data.ByteString.Char8 as B

main :: IO ()
main = do
    n <- readLn
    as <- (map readInt . B.words) <$> B.getLine
    print $ solve n as

-- |
--
-- >>> solve 2 [3,1,4,1,5,9]
-- 1
--
-- >>> solve 1 [1,2,3]
-- -1
--
-- >>> solve 3 [8,2,2,7,4,6,5,3,8]
-- 5
solve :: Int -> [Int] -> Int
solve n as = maximum $ zipWith diff y1s y2s
  where
    diff (lh,_) (rh,_) = lh - negate rh
    (a1s, cs) = splitAt n as
    (bs, a2s) = splitAt n cs
    q1 = foldl push Empty a1s
    q2 = foldl push Empty (map negate a2s)
    lh0 = sum a1s
    rh0 = negate $ sum a2s
    y1s = scanl (flip pushpop) (lh0,q1) bs
    y2s = scanr pushpop (rh0,q2) (map negate bs)

-- Util
readInt :: B.ByteString -> Int
readInt = fst . fromJust . B.readInt

-- Heap
data SkewHeap a = Empty | Node !a !(SkewHeap a) !(SkewHeap a)
            deriving (Show, Read, Eq)

singleton :: a -> SkewHeap a
singleton x = Node x Empty Empty

(+@+) :: Ord a => SkewHeap a -> SkewHeap a -> SkewHeap a
Empty               +@+ t2                  = t2
t1                  +@+ Empty               = t1
t1@(Node x1 l1 r1)  +@+ t2@(Node x2 l2 r2)
   | x1 <= x2   = Node x1 (t2 +@+ r1) l1
   | otherwise  = Node x2 (t1 +@+ r2) l2

push :: Ord a => SkewHeap a -> a -> SkewHeap a
heap `push` x = singleton x +@+ heap

pop :: Ord a => SkewHeap a -> (a, SkewHeap a)
pop Empty         = undefined
pop (Node x l r)  = (x, l +@+ r)

pushpop :: (Num a, Ord a) => a -> (a, SkewHeap a) -> (a, SkewHeap a)
x `pushpop` (y, h) = (y + x - x', h')
  where (x', h') = pop $ push h x


Measured memory_bytes: 205052
import java.util.Scanner;
import java.math.*;

public class Main {
	
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		// 整数の入力
		//int a = sc.nextInt();
		// スペース区切りの整数の入力
		//int b = sc.nextInt();
		//int c = sc.nextInt();
		// 文字列の入力
		//String s = sc.next();
		//1文字ずつ
		//s.atChar(i);
		// 出力
		//System.out.println("");
		
		int N=sc.nextInt();
		//int B=sc.nextInt();
		if(N%2==0){
			System.out.println(N);
		}else{
			System.out.println(N*2);
		}
		
	}
		
	
	
}

Measured memory_bytes: 23124
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <map>
#include <stack>
#include <queue>
#include <unordered_map>
#include <string>
#include <cmath>
#include <set>
#include <cmath>
using namespace std;


vector<vector<int>> g;
vector<int> vis;
int cnt = 0;

vector<long long> f1, f2;

const long long mod = 1e+9  + 7;

void dfs(int v)
{
	vis[v] = 1;
	cnt++;

	for (int i = 0; i < (int)g[v].size(); i++)
	{
		int nxt = g[v][i];
		if (!vis[nxt])
		{
			dfs(nxt);
		}
	}
}


void go(int v)
{
	vis[v] = 1;
	
	f1[v] = 1;
	f2[v] = 1;

	for (int i = 0; i < (int)g[v].size(); i++)
	{
		int nxt = g[v][i];
		if (!vis[nxt])
		{
			go(nxt);

			f1[v] *= f2[nxt];
			f2[v] *= (f1[nxt] + f2[nxt]);
			
			//cout << f1[v] << " " << f2[v] << "\n";

			f1[v] %= mod;
			f2[v] %= mod;
		}
	}
}

void solve()
{
	int n;
	cin >> n;

	g.resize(n);
	vis.assign(n, 0);

	f1.assign(n, 0);
	f2.assign(n, 0);

	for (int i = 0; i < n - 1; i++)
	{
		int u, v;
		cin >> u >> v;
		u--, v--;
		g[u].push_back(v);
		g[v].push_back(u);
	}

	int root = 0;
	for (int i = 0; i < n; i++)
	{
		if (!vis[i])
		{
			dfs(i);
		}

		if (cnt == n)
		{
			root = i;
			break;
		}
	}

	vis.assign(n, 0);

	go(root);

	cout << (f1[root] + f2[root]) % mod;
}

int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	//freopen("file.in", "r", stdin);//freopen("file.out", "w", stdout);

	int t = 1;
	//cin >> t;
	while (t--)
	{
		solve();
	}
	return 0;
}

Measured memory_bytes: 11904
#include <algorithm>
#include <iostream>
#include <utility>
#include <vector>
using namespace std;
int main(){
  int n, m, x, y;
  cin >> n >> m;
  vector< pair<int,int> > V;
  for(int i = 0; i < m; ++i){
    cin >> x >> y;
    V.push_back(make_pair(x,y));
  }
  sort(V.begin(),V.end());
  int D[2][n], ans[n], C[n];
  for(int i = 0; i < 2; ++i)
    fill(D[i],D[i]+n,1);
  fill(ans,ans+n,1);
  fill(C,C+n,-1);
  for(int i = 0; i < m; ++i){
    x = V[i].first;
    y = V[i].second;
    ans[y-1] += D[0][y];
    ans[y] += D[1][y-1];
    D[0][y-1] += D[0][y];
    D[1][y] += D[1][y-1];
    D[1][y-1] = 0;
    D[0][y] = 0;
  }
  for(int i = 0; i < n-1; ++i)
    cout << ans[i] << " ";
  cout << ans[n-1] << endl;

  return 0;
}

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

using namespace std;
using ll = long long;

int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  int n, m;
  cin >> n >> m;
  vector<int> a(n);
  int s = 0;
  for (auto &x : a) {
    cin >> x;
    s += x;
  }
  int cnt = 0;
  for (auto &x : a)
    if (4 * m * x >= s)
      ++cnt;
  cout << (cnt >= m ? "Yes\n" : "No\n");
  return 0;
}

Measured memory_bytes: 256
S = input()
S1 = int(S[0] + S[1])
S2 = int(S[2] + S[3])

if S1>=13 or S1==0:
  if S2>=13 or S2==0:
    print("NA")
  else:
    print("YYMM")
else:
  if S2>=13 or S2==0:
    print("MMYY")
  else:
    print("AMBIGUOUS")

Measured memory_bytes: 3060
#include<stdio.h>
#include<algorithm>
#include<string.h>
#include<string>
#include<math.h>
#include<stdlib.h>
#include<time.h>
#include<map>
#include<queue>
#include<set>
#define fo(i,a,b) for(int i=a;i<=b;i++)
#define fd(i,a,b) for(int i=a;i>=b;i--)
using namespace std;
const int p=1e9+7;
int n,m,x[120000],y[120000];
long long ans1,ans2,sx[120000],sy[120000];
int main(){
	scanf("%d%d",&n,&m);
	fo(i,1,n) scanf("%d",&x[i]);
	fo(i,1,m) scanf("%d",&y[i]);
	sort(x+1,x+n+1);
	sort(y+1,y+m+1);
	sx[n]=x[n];
	fd(i,n-1,1) sx[i]=sx[i+1]+x[i];
	sy[m]=y[m];
	fd(i,m-1,1) sy[i]=sy[i+1]+y[i];
	fo(i,1,n-1) ans1=(ans1+sx[i+1]-(n-i)*(long long)x[i])%p;
	fo(i,1,m-1) ans2=(ans2+sy[i+1]-(m-i)*(long long)y[i])%p;
	printf("%lld\n",ans1*ans2%p);
	return 0;
}

Measured memory_bytes: 2560
def main(n, m, t, p):
    dpn = [1] * n
    dpm = [1] * m
    ldpn = n
    ldpm = m
    for _ in range(t):
        d, c = map(int, input().split())
        if d == 1:
            if ldpn // 2 < c:
                for i in range(ldpn - c):
                    dpn[c - i - 1] += dpn[c + i]
                dpn = dpn[c - 1::-1]
                ldpn = c
            else:
                for i in range(c):
                    dpn[c + i] += dpn[c - 1 - i]
                dpn = dpn[c:]
                ldpn -= c
        else:
            if ldpm // 2 < c:
                for i in range(ldpm - c):
                    dpm[c - i - 1] += dpm[c + i]
                dpm = dpm[c - 1::-1]
                ldpm = c
            else:
                for i in range(c):
                    dpm[c + i] += dpm[c - 1 - i]
                dpm = dpm[c:]
                ldpm -= c
    ans = []
    for _ in range(p):
        x, y = map(int, input().split())
        ans.append(str(dpn[x] * dpm[y]))
    print("\n".join(ans))


while 1:
    n, m, t, p = map(int, input().split())
    if n == m == t == p == 0:
        break
    main(n, m, t, p)


Measured memory_bytes: 5628
#include <bits/stdc++.h>
using namespace std;
int main(){
    long long n, i;
    string s[100001];
    map<string, long long> mp;
    cin >> n;
    for(i=0;i<n;i++){
        cin >> s[i];
        mp[s[i]]++;
    }
    cout << "AC x " << mp["AC"] <<endl;
    cout << "WA x " << mp["WA"] <<endl;
    cout << "TLE x " << mp["TLE"] <<endl;
    cout << "RE x " << mp["RE"] <<endl;
    return 0;
}



Measured memory_bytes: 6764
import collections

N=int(input())
ans=0

def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a


if N==1:
	print(0)
	
else:
	lis=collections.Counter(prime_factorize(N))
	lis_=list(lis.values())
	for i in range(len(lis_)):
		for h in range(1,45):
			if lis_[i]>=h*(h+1)/2:
				ans+=1
	print(int(ans))
		

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

using namespace std;

int nr, N, x[20], y[20], v[20], t[20];
pair < double, pair < int, int > > e[20 * 20];

void read ()
{
    pair < long long, pair < int, int > > initE[20 * 20];
    scanf ("%d", &N);
    for (int i=0; i<N; i++)
        scanf ("%d %d %d", &x[i], &y[i], &v[i]);
    for (int i=0; i<N; i++)
        for (int j=i + 1; j<N; j++)
            initE[++nr] = {1LL * (x[i] - x[j]) * (x[i] - x[j]) + 1LL * (y[i] - y[j]) * (y[i] - y[j]), {i, j}};
    sort (initE + 1, initE + nr + 1);
    for (int i=1; i<=nr; i++)
        e[i].first = (double) sqrt ((double) initE[i].first), e[i].second = initE[i].second;
}

int tata (int x)
{
    if (t[x] == x) return x;
    return t[x] = tata (t[x]);
}

int sz[(1 << 15) + 5];
double mst[(1 << 15) + 5], sum[(1 << 15) + 5], dp[(1 << 15) + 5];
void buildMSTs ()
{
    for (int msk = 0; msk < (1 << N); msk ++)
    {
        sum[msk] = 0.0;
        for (int i=0; i<N; i++)
            if (msk & (1 << i))
                t[i] = i, sum[msk] += v[i], sz[msk] ++;
        for (int i=1; i<=nr; i++)
        {
            int x = e[i].second.first, y = e[i].second.second;
            if ((msk & (1 << x)) == 0 || (msk & (1 << y)) == 0) continue;
            x = tata (x), y = tata (y);
            if (x == y) continue;
            t[x] = y, mst[msk] += e[i].first;
        }
    }
}

void doDp ()
{
    dp[0] = 1e18;
    for (int msk = 1; msk < (1 << N); msk ++)
    {
        dp[msk] = 0.0;
        for (int subMsk = msk; subMsk != 0; subMsk = (subMsk - 1) & msk)
        {
            double curr = (sum[subMsk] - mst[subMsk]) / (1.0 * sz[subMsk]);
            if (curr < 0.0) continue;
            if (dp[msk ^ subMsk] < curr)
                curr = dp[msk ^ subMsk];
            if (curr > dp[msk])
                dp[msk] = curr;
        }
    }
}

int main ()
{
//freopen ("input", "r", stdin);
//freopen ("output", "w", stdout);

read ();
buildMSTs ();
doDp ();
printf ("%.14f\n", dp[(1 << N) - 1]);

return 0;
}


Measured memory_bytes: 1152
using System;
using System.Collections.Generic;
using System.Text;

namespace abc171_c
{
  class Program
  {
    static void Main(string[] args)
    {
      var N = CIn.ReadLong();

      var sb = new StringBuilder();

      while (N > 0)
      {
        N -= 1;
        var c = (char)(N % 26 + 'a');
        sb.Insert(0, c);
        N /= 26;
      }

      Console.WriteLine(sb.ToString());
    }
  }

  static class CIn
  {
    private static readonly Queue<string> fieldBuffer = new Queue<string>();

    public static string Read()
    {
      if (fieldBuffer.Count == 0)
      {
        foreach (var field in Console.ReadLine().Split())
        {
          fieldBuffer.Enqueue(field);
        }
      }
      return fieldBuffer.Dequeue();
    }

    public static int ReadInt() => int.Parse(Read());
    public static long ReadLong() => long.Parse(Read());
    public static double ReadDouble() => double.Parse(Read());

    public static string[] ReadStringArray(int n)
    {
      var array = new string[n];
      for (var i = 0; i < n; i++)
      {
        array[i] = Read();
      }
      return array;
    }

    public static int[] ReadIntArray(int n)
    {
      var array = new int[n];
      for (var i = 0; i < n; i++)
      {
        array[i] = ReadInt();
      }
      return array;
    }

    public static long[] ReadLongArray(int n)
    {
      var array = new long[n];
      for (var i = 0; i < n; i++)
      {
        array[i] = ReadLong();
      }
      return array;
    }

    public static double[] ReadDoubleArray(int n)
    {
      var array = new double[n];
      for (var i = 0; i < n; i++)
      {
        array[i] = ReadDouble();
      }
      return array;
    }

    public static char[,] ReadCharMatrix(int h, int w)
    {
      var array = new char[h, w];
      for (var i = 0; i < h; i++)
      {
        var l = Console.ReadLine().ToCharArray();
        for (var j = 0; j < w; j++)
        {
          array[i, j] = l[j];
        }
      }
      return array;
    }
  }
}


Measured memory_bytes: 27900
#include<cstdio>
#include<cmath>
int a,b,h;
int main()
{
	scanf("%d%d",&a,&b);
	if(b>9&&b!=100)
		h=a*100+b;
	else if(b==100)
		h=a*1000+b;
		else
		h=a*10+b;
	if((int(sqrt(h)))*(int(sqrt(h)))==h)
		printf("Yes");
	else
		printf("No");
}

Measured memory_bytes: 128
def main():
    import sys
    input = sys.stdin.readline
    sys.setrecursionlimit(10**7)
    from collections import Counter, deque
    #from collections import defaultdict
    from itertools import combinations, permutations, accumulate, groupby, product
    from bisect import bisect_left,bisect_right
    from heapq import heapify, heappop, heappush
    import math

    #inf = 10**17
    #mod = 10**9 + 7

    s = input().rstrip()
    ls = len(s)
    t = input().rstrip()
    lt = len(t)
    alphabet = 'abcdefghijklmnopqrstuvwxyz' #26
    moji = [[] for _ in range(26)]
    for i in range(ls):
        idx = alphabet.index(s[i])
        moji[idx].append(i+1)
    
    cnt = 0
    res = 0
    while cnt < lt:
        for i in range(cnt, lt):
            idx = alphabet.index(t[i])
            if not moji[idx]:
                print(-1)
                exit()
            if i == cnt:
                now = moji[idx][0] + 1
            else:
                nex = bisect_left(moji[idx], now)
                if nex == len(moji[idx]):
                    res += ls
                    cnt = i
                    break
                now = moji[idx][nex] + 1
        else:
            res += now - 1
            break
    print(res)

if __name__ == '__main__':
    main()

Measured memory_bytes: 46320
#include<bits/stdc++.h>
using namespace std;
int main()
{
  string str;

  cin>>str;
  if(str=="SAT") cout<<1<<endl;
  if(str=="FRI") cout<<2<<endl;
  if(str=="THU") cout<<3<<endl;
  if(str=="WED") cout<<4<<endl;
  if(str=="TUE") cout<<5<<endl;
  if(str=="MON") cout<<6<<endl;
  if(str=="SUN") cout<<7<<endl;

  return 0;
}


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

int main() {
	int a,b,c,d;
	cin >> a >> b >> c >> d;
	string k = "Yes";
	if(d < abs(a - c) && (d < abs(a - b) || d < abs(b - c)))
	{
		k = "No";
	}
    cout << k << endl;
	return 0;
}


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

#define vint vector<int> 
#define vbool vector<bool>
#define vvint vector<vector<int>>

#define rep(a, b, c) for(int (a)=(b); (a)<(c); (a)++)
#define all(a) (a).begin(), (a).end()

int main(){
    // ifstream in("input.txt");
    // cin.rdbuf(in.rdbuf());

    double r;
    cin >>r;
    cout << 2*r*3.1415;


}

Measured memory_bytes: 3784
/**
 *      purpose : 
 *      author  : kyomukyomupurin
 *      created : 
**/

// input/output
#include <iostream>
#include <fstream>
#include <sstream>
// container class
#include <array>
#include <deque>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
// math, algorithm
#include <algorithm>
#include <cmath>
#include <complex>
#include <numeric>
// etc
#include <bitset>
#include <cassert>
#include <cctype>
#include <cstring>
#include <chrono>
#include <iomanip>
#include <random>
#include <utility>
// using-directive
using namespace std;
// alias template
using int64 = int64_t;
using pii = pair<int, int>;
using pll = pair<int64_t, int64_t>;
// text macro replacement
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define print(x) cout << (x) << '\n'
#define debug(x) cout << #x << ": " << (x) << '\n'
// variadic template
template<typename T> inline void chmin(T &a, T b) {if (a > b) a = b; return;}
template<typename T> inline void chmax(T &a, T b) {if (a < b) a = b; return;}

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

  int n; cin >> n;
  vector<int> a(n), b(n);
  rep(i, n) cin >> a[i] >> b[i];
  vector<pii> v;

  rep(i, n) {
    v.emplace_back(b[i], a[i]);
  }

  sort(all(v));

  int cur = 0;

  rep(i, n) {
    cur += v[i].second;
    if (cur > v[i].first) {
      print("No"); return 0;
    }
  }

  print("Yes");


  return 0;
}

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

int main(){
	int n,q;
	bool x[50][100];
	while(cin >> n >> q,n||q){
		for(int i = 0; i < n; i++){
			for(int j = 0; j < 100; j++) x[i][j] = false;
		}
		for(int i = 0; i < n; i++){
			int m;
			cin >> m;
			for(int j = 0; j < m; j++){
				int date;
				cin >> date;
				x[i][date] = true;
			}
		}
		bool ok = true;
		int sum = -1, ans;
		for(int i = 1; i < 100; i++){
			int cnt = 0;
			for(int j = 0; j < n; j++){
				if(x[j][i]) cnt++;
			}
			if(cnt > sum){
				sum = cnt;
				ans = i;
			}
		}
		if(sum >= q) cout << ans << endl;
		else cout << 0 << endl;
	}
}

Measured memory_bytes: 1164
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;

namespace Tasks
{
    public class C
    {
        static void Main(string[] args)
        {
            var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);
            Solve();
            Console.Out.Flush();
        }

        public static void Solve()
        {
            var N = Scanner.Scan<int>();
            var X = Scanner.ScanEnumerable<int>().ToArray();
            var ave = (long)X.Average();
            var answer = X.Sum(x => (x - ave) * (x - ave));
            ave++;
            answer = Math.Min(answer, X.Sum(x => (x - ave) * (x - ave)));
            Console.WriteLine(answer);
        }

        public static class Scanner
        {
            private static Queue<string> queue = new Queue<string>();
            public static T Next<T>()
            {
                if (!queue.Any()) foreach (var item in Console.ReadLine().Trim().Split(" ")) queue.Enqueue(item);
                return (T)Convert.ChangeType(queue.Dequeue(), typeof(T));
            }
            public static T Scan<T>() => Next<T>();
            public static (T1, T2) Scan<T1, T2>() => (Next<T1>(), Next<T2>());
            public static (T1, T2, T3) Scan<T1, T2, T3>() => (Next<T1>(), Next<T2>(), Next<T3>());
            public static (T1, T2, T3, T4) Scan<T1, T2, T3, T4>() => (Next<T1>(), Next<T2>(), Next<T3>(), Next<T4>());
            public static (T1, T2, T3, T4, T5) Scan<T1, T2, T3, T4, T5>() => (Next<T1>(), Next<T2>(), Next<T3>(), Next<T4>(), Next<T5>());
            public static IEnumerable<T> ScanEnumerable<T>() => Console.ReadLine().Trim().Split(" ").Select(x => (T)Convert.ChangeType(x, typeof(T)));
        }
    }
}


Measured memory_bytes: 28400
function main(input) {
  const args = input.split('\n');
  const ary1 = args[0].split(' ').map(n => parseInt(n, 10));
  const H = ary1[0];
  const W = ary1[1];
  let aryChars = [];
  let delCols = [];
  let delRows = [];
  let ansAry = [];
  
  //二次元配列作成
  for (let i = 1; i <= H; i++) {
    ary = args[i].split('');
    aryChars.push(ary);
  }
  
  //削除するColのインデックスを探す
  for (let x = 0; x < W; x++) {
    cnt = 0;
    for (let y = 0; y < H; y++) {
      if (aryChars[y][x] === '.') { cnt++; }
      if (cnt === H) { delCols.push(x); }
    }
  }
  
  //削除するRowのインデックスを探す
  for (let y = 0; y < H; y++) {
    cnt = 0;
    for (let x = 0; x < W; x++) {
      if (aryChars[y][x] === '.') { cnt++; }
      if (cnt === W) { delRows.push(y); }
    }
  }
  
  //Col削除の時は後ろから消したいので降順にソートしておく
  delCols.sort(function(a, b) {
    return b - a;
  });
  
  delRows.sort(function(a, b) {
    return b - a;
  });
  
  //Row削除
  for (let i = 0; i < delRows.length; i++) {
    aryChars.splice(delRows[i], 1);
  }
  
  //Col削除
  for (let i = 0; i < aryChars.length; i++) {
    for (let j = 0; j < delCols.length; j++) {
      aryChars[i].splice(delCols[j], 1);
    }
  }
  
  /**
  console.log(delRows);
  console.log(delCols);
  **/
  
  for (let i = 0; i < aryChars.length; i++) {
    console.log(aryChars[i].join(''));
  }
  
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 30496
#include<iostream>
#include<vector>
#include<utility>
#include<map>
#include<deque>
#include<numeric>
#include<algorithm>
#include<unordered_map>
#include<cmath>

using namespace std;
using ll = long long int;
constexpr int INF = 1 << 29;
constexpr ll MOD = ll(1e9 + 7);

string s;

int main(void) {
	cin >> s;
	string ret = "Yes";
	if (s.size() % 2 == 1)
		ret = "No";
	for (int i = 0; i + 1 < s.size(); i += 2) {
		if (s[i] != 'h' || s[i + 1] != 'i') {
			ret = "No";
			break;
		}
	}

	cout << ret << endl;
	return 0;
}

Measured memory_bytes: 256
use std::io::{BufRead, Read};

pub struct Scanner<R>
where
    R: BufRead,
{
    reader: R,
}

impl<R> Scanner<R>
where
    R: BufRead,
{
    pub fn new(reader: R) -> Self {
        Self { reader }
    }

    pub fn next<T>(&mut self) -> T
    where
        T: ::std::str::FromStr,
        <T as ::std::str::FromStr>::Err: ::std::fmt::Debug,
    {
        self.reader
            .by_ref()
            .bytes()
            .map(|b| b.unwrap() as char)
            .skip_while(|c| c.is_whitespace())
            .take_while(|c| !c.is_whitespace())
            .collect::<String>()
            .parse::<T>()
            .unwrap()
    }
}

fn main() {
    let stdin = std::io::stdin();
    let stdin = stdin.lock();
    let mut sc = Scanner::new(stdin);

    let n: i32 = sc.next();
    let mut taro_score: i32 = 0;
    let mut hanaco_score: i32 = 0;

    for _ in 0..n {
        let taro = sc.next::<String>();
        let hanaco = sc.next::<String>();

        if taro > hanaco {
            taro_score += 3;
        } else if taro < hanaco {
            hanaco_score += 3;
        } else {
            taro_score += 1;
            hanaco_score += 1;
        }
    }
    println!("{} {}", taro_score, hanaco_score);
}



Measured memory_bytes: 5036
import java.util.Scanner;
import java.text.DecimalFormat;
import java.math.RoundingMode;

public class Main {
	public static void main(String[] args){
		double r, m, s;
		DecimalFormat t = new DecimalFormat("0.000000");
		t.setRoundingMode(RoundingMode.HALF_UP);
		Scanner sc = new Scanner(System.in);
		r = sc.nextDouble();
		m = r * r * 3.141592653589;
		s = (r + r) * 3.141592653589;
		System.out.println(t.format(m) + " " + t.format(s));
	}
}

Measured memory_bytes: 27860
from sys import stdin

def main():
    N = int(stdin.readline().rstrip())
    data = [int(x) for x in stdin.readline().rstrip().split()]
    counter = 0
    isBreak = False
    while(True):
        for d in data:
            if d % 2 != 0:
                isBreak = True
                break
        if isBreak:
            break
        data = [x/2 for x in data]
        counter += 1
    print(counter)

if __name__ == "__main__":
    main()

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

#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define INF 1e9
typedef long long ll;


int main() {
    int A,B; cin >> A >> B;
    cout << (A-1)*(B-1) << endl;
    return 0;
}

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

int main(){
  char a,b;
  cin>>a>>b;
  if(a<b) cout<<'<'<<endl;
  else if(a==b) cout<<'='<<endl;
  else cout<<'>'<<endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
using namespace std;
const string MINUSINF="-";

void chmax(string &a,string b){
    if(a == MINUSINF) a = b;
    else if(a.size() < b.size()) a = b;
    else if(a.size() == b.size()){
        if(a < b) a = b;
    }
}
long long match[10] = {2,5,5,4,5,6,3,7,6};
string dp[11000];

int main(){
    int N,M;cin>>N>>M;
    vector<int> A(M);
    for(int i=0;i<M;i++) cin >> A[i];

    for(int i=0;i<11000;i++) dp[i] = MINUSINF;

    dp[0] = "";
    for(int i=0;i<=N;i++){
        if(dp[i] == MINUSINF)continue;
        for(auto a:A) chmax(dp[i+match[a-1]],dp[i] + (char)('0' + a));
    }
    cout<<dp[N]<<endl;
    return 0;
}

Measured memory_bytes: 43776
import collections

N = int(input())
A = list(map(int, input().split()))

L = [i+j for i, j in enumerate(A)]
R = [i-j for i, j in enumerate(A)]

l = collections.Counter(L)
r = collections.Counter(R)

ans = 0
for i in l.keys():
    ans += l[i]*r[i]

print(ans)

Measured memory_bytes: 63444
#include <iostream>
using namespace std;
int main(){
  string n;
  cin >> n;
  int i;
  for(i=0;i<3;i++){
    if(n[i]=='1') cout << '9';
    else if(n[i]=='9') cout << '1';
  }
  cout << "\n";
  return 0;
}

Measured memory_bytes: 3592