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

namespace Structured_Program_II
{
    class Matrix_Multiplication
    {
        static void Main(string[] args)
        {
            var size = Console.ReadLine().Split(' ').Select(s => int.Parse(s)).ToArray();

            var mat1 = new int[size[0]][];
            for (int i = 0; i < mat1.Length; i++)
                mat1[i] = Console.ReadLine().Split(' ').Select(s => int.Parse(s)).ToArray();
            var mat2 = new int[size[1]][];
            for (int i = 0; i < mat2.Length; i++)
                mat2[i] = Console.ReadLine().Split(' ').Select(s => int.Parse(s)).ToArray();

            var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush=false};
            Console.SetOut(sw);

            for (int i = 0; i < size[0]; i++)
                for (int j = 0; j < size[2]; j++)
                {
                    long res = 0;
                    for (int k = 0; k < size[1]; k++)
                        res += mat1[i][k] * mat2[k][j];
                    Console.Write(res);
                    if (j != size[2] - 1) Console.Write(" ");
                    else Console.WriteLine();
                }
            Console.Out.Flush();
        }
    }
}

Measured memory_bytes: 10020
import itertools

wl, gl = tuple(map(int,input().split()))

class G:
    def __init__(self):
        self.kantis = [False for _ in range(wl)]
        self.mo = 0
    def match(self,wstates):
        re = 0
        for kanti,wstate in zip(self.kantis,wstates):
            if kanti and wstate:
                re += 1
        return re % 2 == self.mo

gs = []
for gi in range(gl):
    g = G()
    kantiwis = list(map(int,input().split()))
    kantiwis = kantiwis[1:]
    for kantiwi in kantiwis:
        kantiwi -= 1
        g.kantis[kantiwi] = True
    gs.append(g)

mos = list(map(int,input().split()))
for gi in range(gl):
    gs[gi].mo=mos[gi]


re = 0
for wstates in itertools.product([True,False], repeat=wl):
    ok = True
    for g in gs:
        if not g.match(wstates):
            ok = False
            break
    if ok:
        re += 1

print(re)

Measured memory_bytes: 3064
import sys,math,collections,itertools,heapq
input = sys.stdin.readline
def f(n):
    return -1*int(n)

x,y,a,b,c=list(map(int,input().split()))
p=sorted(list(map(int,input().split())),reverse=1)[:x]
q=sorted(list(map(int,input().split())),reverse=1)[:y]
r=list(map(f,input().split()))

p = collections.deque(p)
q = collections.deque(q)
heapq.heapify(r)

tmp = -1*heapq.heappop(r)
while tmp > p[-1]:
    p.appendleft(tmp)
    tmp = p.pop()
    tmp = -1* heapq.heappushpop(r,-1*tmp)

while tmp > q[-1]:
    q.appendleft(tmp)
    tmp = q.pop()
    tmp = -1 * heapq.heappushpop(r,-1*tmp)

print(sum(p)+sum(q))

        


Measured memory_bytes: 28512
#include <bits/stdc++.h>
using namespace std;
using Int = long long;
int PREP = (cin.tie(nullptr), ios::sync_with_stdio(false), cout << fixed << setprecision(9), 0);
//int SEGV = getenv("D") || (exit(system("D= SEGFAULT_SIGNALS=all catchsegv ./prog.exe") >> 8), 0);
const Int MOD = 1000000007;
Int POW(Int n, Int k) {
    if (k == 0) return 1;
    if (k % 2 == 0) return POW(n * n % MOD, k / 2);
    return n * POW(n, k - 1) % MOD;
}
Int COM(int n, int k){
    if (n < k || n < 0 || k < 0) return 0;
    Int a = 1, b = 1;
    for (int i = 0; i < k; i++) {
        a = a * (n - i) % MOD;
        b = b * (i + 1) % MOD;
    }
    return a * POW(b, MOD - 2) % MOD;
}
int main() {
    int N, A, B; cin >> N >> A >> B;
    Int ans = POW(2, N);
    ans += 3 * MOD - 1 - COM(N, A) - COM(N, B);
    ans %= MOD;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
n = int(input())
x_list = input().split()
avg = 0
for i in range(n):
  x_list[i] = int(x_list[i])
  avg += x_list[i]
avg = round(avg / n)
ans = 0
for i in range(n):
  ans += (x_list[i] - avg) * (x_list[i] - avg)
print(ans)


Measured memory_bytes: 3060
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<stack>
#include<string>
#include<map>
#include<set>
#include<tuple>
#include<cmath>
#include<iomanip>


using namespace std;
typedef long long ll;
typedef vector<ll> v;
typedef vector<vector<ll>> vv;


#define MOD 1000000007
#define INF 1001001001
#define MIN -1001001001
#define rep(i,k,N) for(ll i=k;i<N;i++)
#define MP make_pair
#define MT make_tuple //tie,make_tuple は別物
#define PB push_back
#define PF push_front
#define all(x) (x).begin(),(x).end()


int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};



ll N;
struct pos{
    ll x,y;
    bool operator<( const pos& a) const {
        if(x == a.x)return y < a.y;
        else return x < a.x;
    }
};

pos mpos(ll x,ll y){
    pos tmp ={x,y};
    return tmp;
}

ll calc(pos a){
    return a.x+1+a.y*N;
}

vector <ll> grid;
vector <bool> gridbool;

void del(pos now, ll c);

void update(pos now, ll c){
    grid[calc(now)] = c;
    rep(i,0,4){
        if(now.x + dx[i] <= N-1 && now.x + dx[i] >= 0 && now.y + dy[i] >= 0 && now.y + dy[i] <= N-1){
            pos nxt = mpos(now.x + dx[i], now.y + dy[i]);
            if(grid[calc(nxt)] > grid[calc(now)]+1){
                if(gridbool[calc(nxt)])update(nxt, grid[calc(now)] + 1);
                else del(nxt, grid[calc(now)] + 1);
            }
        }
    }
}

void del(pos now, ll c){
    grid[calc(now)] = c;
    rep(i,0,4){
        if(now.x + dx[i] <= N-1 && now.x + dx[i] >= 0 && now.y + dy[i] >= 0 && now.y + dy[i] <= N-1){
            pos nxt = mpos(now.x + dx[i], now.y + dy[i]);
            if(grid[calc(nxt)] > grid[calc(now)]){
                if(gridbool[calc(nxt)])update(nxt, grid[calc(now)]);
                else del(nxt, grid[calc(now)]);
            }
        }
    }
}


int main(){
    cin>>N;
    vector<pos> p(N*N);
    grid.resize(N*N+1);
    gridbool.resize(N*N+1);
    rep(i,0,N*N){
        ll a;
        cin>>a;
        ll tmp;
        if(a%N == 0)tmp = N;
        else tmp = a%N;
        p[i].x = tmp-1;
        p[i].y = (a-1)/N;
    }
    ll ans = 0;
    rep(i,0,N)rep(j,0,N){
        pos tmp = mpos(i,j);
        grid[calc(tmp)] = min(min(N-1-i,i),min(N-1-j,j));
        gridbool[calc(tmp)] = true;
    }

    rep(i,0,N*N){
        ans += grid[calc(p[i])];
        //cout<<p[i].x<<p[i].y<<" "<<grid[p[i]]<<endl;
        gridbool[calc(p[i])] = false;
        del(p[i], grid[calc(p[i])]);
    }
    cout<<ans;

    return 0;
}

Measured memory_bytes: 24580
alpha_small_dict = {chr(i):i-97 for i in range(97, 97+26)} #辞書ver

h,w = map(int, input().split())
data = [0]*26
for i in range(h):
    a = input()
    for x in a:
        data[alpha_small_dict[x]] += 1

if h%2 == 0 and w%2 == 0:
    check = True
    for x in data:
        if x%4:
            check = False
            break
    print("Yes" if check else "No")
elif w%2 == 0:
    check = 0

    for x in data:
        if x%4:
            if x%2:
                print("No")
                exit()
            else:
                check += 2

    print("Yes" if check <= w else "No")
elif h%2 == 0:
    check = 0
    for x in data:
        if x%4:
            if x%2:
                print("No")
                exit()
            else:
                check += 2
    print("Yes" if check <= h else "No")
else:
    check1 = 0
    check2 = 0
    for x in data:
        if x%4:
            if x%2 and check2:
                print("No")
                exit()
            elif x%2:
                check2 = 1
            else:
                check1 += 2

    print("Yes" if check1 <= h + w - 2 else "No")
    

Measured memory_bytes: 3064
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int A = scanner.nextInt();
        int B = scanner.nextInt();
        int K = scanner.nextInt();
        for(int i = A; i <= B; i++) {
            if ( i < A + K || B - K < i) {
                System.out.println(i);
            }
        }

    }
}


Measured memory_bytes: 23636
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
#define inline __inline__ __attribute__((always_inline))
const int N = 1e3 + 5, INF = 0x3f3f3f3f, M = N << 1;
const ll LNF = 0x3f3f3f3f3f3f3f3f;



int main() {
  ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  cout << setprecision(8) << fixed;
  int n;
  cin >> n;
  if (!(n & 1)) cout << 0.5 << '\n';
  else cout << (n / 2 + 1.0) / (n + 0.0) << '\n';
}

Measured memory_bytes: 256
#line 1 "rolling_hash.test.cpp"
#define PROBLEM "http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ALDS1_14_B"
#line 1 "/mnt/c/Users/leafc/dev/compro/lib/generator/integer.hpp"
#include <chrono>
#include <random>
#include <vector>
#ifndef COMPRO_GENERATOR_INTEGER
#define COMPRO_GENERATOR_INTEGER
template <class T> class IntegerGenerator {
private:
  std::mt19937 mt;

public:
  IntegerGenerator<T>() { mt = std::mt19937((std::chrono::steady_clock::now().time_since_epoch().count())); }

  // [lower_limit, upper_limit]の範囲で整数を生成します。
  T gen(T lower_limit, T upper_limit) {
    std::uniform_int_distribution<T> dist(lower_limit, upper_limit);
    return dist(mt);
  }

  //  [lower_limit, upper_limit]の範囲の要素を持つsize個の整数列を生成します。
  std::vector<T> gen_sequence(int size, T lower_limit, T upper_limit) {
    std::uniform_int_distribution<T> dist(lower_limit, upper_limit);
    std::vector<T> ret(size);
    for (int i = 0; i < size; i++) {
      ret[i] = dist(mt);
    }
    return ret;
  }
};
#endif
#line 2 "/mnt/c/Users/leafc/dev/compro/lib/rolling_hash.hpp"
#include <cassert>
#include <cstdint>
#include <string>
#line 6 "/mnt/c/Users/leafc/dev/compro/lib/rolling_hash.hpp"

#ifndef ROLLING_HASH
#define ROLLING_HASH
class RollingHash {
  using u64 = std::uint_fast64_t;

private:
  constexpr static u64 h = (1uLL << 61) - 1;
  u64 b;
  std::vector<u64> hash, pow;

  u64 mul(u64 a, u64 b) {
    const u64 m30 = (1ull << 30) - 1;
    const u64 m31 = (1ull << 31) - 1;
    u64 au = a >> 31;
    u64 ad = a & m31;
    u64 bu = b >> 31;
    u64 bd = b & m31;
    u64 mid = ad * bu + au * bd;
    u64 mid_u = mid >> 30;
    u64 mid_d = mid & m30;
    u64 res = au * bu * 2 + mid_u + (mid_d << 31) + ad * bd;
    return mod(res);
  }

  u64 mod(u64 x) {
    const u64 xu = x >> 61;
    const u64 xd = x & ((1uLL << 61) - 1);
    ulong res = xu + xd;
    if (res >= h)
      res -= h;
    return res;
  }

public:
  RollingHash(std::string str, u64 base = 0) {
    if (base == 0) {
      IntegerGenerator<u64> ig;
      b = ig.gen(0, h - 1);
    } else {
      b = base;
    }

    int size = str.length();
    hash.assign(size + 1, 0);
    pow.assign(size + 1, 0);

    hash[0] = 0LL;
    pow[0] = 1LL;
    for (int i = 0; i < size; i++) {
      pow[i + 1] = mul(pow[i], b);
      hash[i + 1] = mul(hash[i], b) + str[i];
      if (hash[i + 1] >= h)
        hash[i + 1] -= h;
    }
  }

  // [l,r)に対応するローリングハッシュを取得する
  u64 get(int l, int r) {
    assert(r < (int)hash.size() && l < r);
    u64 ret = hash[r] + h - mul(hash[l], pow[r - l]);
    if (ret >= h)
      ret -= h;
    return ret;
  }

  // bを取得する
  u64 get_base() { return b; }
};
#endif
#line 3 "rolling_hash.test.cpp"
#include <iostream>
#line 5 "rolling_hash.test.cpp"

int main() {
  std::string s, p;
  std::cin >> s >> p;
  RollingHash rhs(s);
  RollingHash rhp(p, rhs.get_base());

  int loop_num = s.length() - p.length() + 1;
  for (int i = 0; i < loop_num; i++) {
    if (rhs.get(i, i + p.length()) == rhp.get(0, p.length())) {
      std::cout << i << std::endl;
    }
  }
}



Measured memory_bytes: 20624
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);++i)
#define Rep(i,n) for(int i=1;i<=(n);++i)
using LL = long long;
using ULL = unsigned long long;

int h[100123], b[100123];

int main()
{
    int n, m;
    cin >> n >> m;
    Rep(i, n) scanf("%d", h+i);
    int x, y;
    while(m--) {
        scanf("%d%d", &x, &y);
        if(h[x] <= h[y]) b[x] = 1;
        if(h[y] <= h[x]) b[y] = 1;
    }
    int ans = 0;
    Rep(i, n) ans += b[i] == 0;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 4544
#include <bits/stdc++.h>
using namespace std;
int main(){
  string str;
  cin >> str;
  int cnt=0;
  for(int i=0; i<6; ++i){
    if(str[i] == '1'){
      cnt++;
    }
  }
  cout << cnt << endl;
 return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int main() {
	int n, i, a[210];
	cin >> n;
	n *= 2;
	for (i = 0; i < n; ++i) {
		cin >> a[i];
	}
	sort(a, a + n);
	int b = 0, c = 0;
	for (i = 0; i < n; i += 2) {
		b += a[i];
	}
	cout << b << endl;
	return 0;
}

Measured memory_bytes: 3596
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0; i<n; i++)
#define REP(i, n) for(int i=0; i<=n; i++)
#define repr(i, n) for(int i=n; i>0; i--)
#define REPR(i, n) for(int i=n; i>=0; i--)
#define FOR(i, a, b) for(int i=a; i<b; i++)
#define ALL(v) v.begin(),v.end()
#define pb push_back
#define eb emplace_back
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<int, ll> pil;
typedef pair<ll, int> pli;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LLINF = 1e18;
const ll MOD = 1e9+7;
template<class T> void puts(T x) { std::cout << x << std::endl; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int q;

int mmax(int a, int b, int c) {
    int ret;
    ret = max(a, b);
    ret = max(ret, c);
    return ret;
}

int lcs(string s1, string s2) {
    int n1 = s1.length();
    int n2 = s2.length();

    int dp[n1][n2];
    dp[0][0] = s1[0] == s2[0];
    for (int i = 1; i < n1; i++) {
        dp[i][0] = s1[i] == s2[0] ? 1 : dp[i-1][0];
    }
    for (int i = 1; i < n2; i++) {
        dp[0][i] = s2[i] == s1[0] ? 1 : dp[0][i-1];
    }

    for (int i = 1; i < n1; i++) {
        for (int j = 1; j < n2; j++) {
            int t = s1[i] == s2[j];
            dp[i][j] = mmax(dp[i-1][j-1] + t,
                            dp[i-1][j],
                            dp[i][j-1]);
        }
    }

    return dp[n1-1][n2-1];
}

int main() {
    cin >> q;
    rep(i, q) {
        string s1, s2; cin >> s1 >> s2;
        cout << lcs(s1, s2) << endl;
    }
}



Measured memory_bytes: 7120
S = input()
T = input()

N, M = len(S), len(T)
ans = float("inf")
for i in range(N-M+1):
    tmp = 0
    for j in range(M):
        if S[i+j] != T[j]:
            tmp += 1
    ans = min(ans, tmp)
print(ans)

Measured memory_bytes: 9132
# coding: utf-8
n = list(map(int,input()))

if   n[0]+n[1]+n[2]+n[3]==7:
    print(str(n[0])+"+"+str(n[1])+"+"+str(n[2])+"+"+str(n[3])+"=7")
elif n[0]+n[1]+n[2]-n[3]==7:
    print(str(n[0])+"+"+str(n[1])+"+"+str(n[2])+"-"+str(n[3])+"=7")

elif n[0]+n[1]-n[2]+n[3]==7:
    print(str(n[0])+"+"+str(n[1])+"-"+str(n[2])+"+"+str(n[3])+"=7")
elif n[0]+n[1]-n[2]-n[3]==7:
    print(str(n[0])+"+"+str(n[1])+"-"+str(n[2])+"-"+str(n[3])+"=7")

elif n[0]-n[1]+n[2]+n[3]==7:
    print(str(n[0])+"-"+str(n[1])+"+"+str(n[2])+"+"+str(n[3])+"=7")
elif n[0]-n[1]+n[2]-n[3]==7:
    print(str(n[0])+"-"+str(n[1])+"+"+str(n[2])+"-"+str(n[3])+"=7")

elif n[0]-n[1]-n[2]+n[3]==7:
    print(str(n[0])+"-"+str(n[1])+"-"+str(n[2])+"+"+str(n[3])+"=7")
elif n[0]-n[1]-n[2]-n[3]==7:
    print(str(n[0])+"-"+str(n[1])+"-"+str(n[2])+"-"+str(n[3])+"=7")


Measured memory_bytes: 3188
#include <stdio.h>

int main(void)
{
    int i, arr[26];
    char str, inSma, inCap, alpha_set[26];
    
    alpha_set[0] = 'a';
    for (i = 1; i < 26; i++) {
        alpha_set[i] = alpha_set[i - 1] + 1;
    }
    
    for (i = 1; i < 26; i++) {
        arr[i] = 0;
    }
    
    while ((scanf("%c", &str)) != EOF) {
        inSma = str - 'a';
        inCap = str - 'A';
        
        if (inSma >= 0 && inSma <= 25) {
            arr[inSma]++;
        }       
        if (inCap >= 0 && inCap <= 25) {
            arr[inCap]++;
        }
    }
    
    for (i = 0; i < 26; i++) {
        printf("%c : %d\n", alpha_set[i], arr[i]);
    }

    return 0;
}

Measured memory_bytes: 540
#include<bits/stdc++.h>
#define int long long
#define fi first
#define sc second
#define pii pair<int,int>
#define vi vector<int>
#define msi map<string,int>
#define si set<int>
#define all(v) v.begin(),v.end()
#define sz(v)  int((v).size())
#define rep(i,a,b)	for(int i=a;i<b;i++)
#define dep(i,a,b)	for(int i=a;i>=b;i--)
#define isinarr(i,n) ((i>=0)?((i<n)?1:0):0)
#define fastio  ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define pb push_back
#define ppb pop_back
#define present(container, element) (container.find(element) != container.end())      //set,map etc.
#define cpresent(container, element) (find(all(container),element) != container.end())    //vector
#define hell 1000000007
#define PI 3.14159265
#define mp make_pair
#define	endl '\n'

using namespace std;

bool isPalindrome(string str) 
{ 
    // Start from leftmost and rightmost corners of str 
    int l = 0; 
    int h = str.length() - 1; 
  
    // Keep comparing characters while they are same 
    while (h > l) 
    { 
        if (str[l++] != str[h--]) 
        { 
            //printf("%s is Not Palindrome", str); 
            return 0; 
        } 
    } 
    //printf("%s is palindrome", str); 
    return 1;
} 

void solve()
{
	string s,f,sec;
	cin>>s;
	int n=s.length();
	f=s.substr(0,(n-1)/2);
	sec=s.substr((n+3)/2 -1,n-1);
	if(isPalindrome(s) && isPalindrome(f) && isPalindrome(sec))
	{
		cout<<"Yes";
		return ;
	}
	cout<<"No";
} 



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

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define reps(i, n) for (int i=1; i < (int)(n); i++)
#define rrep(i, n) for (int i=((int)(n)-1); i>=0; i--)
#define rreps(i, n) for (int i=((int)(n)-1); i>0; i--)
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())
using namespace std;
using lint = long long;
using p = pair<int, int>;
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 (b<a) { a=b; return 1; } return 0; }

int digit(int n) {
  int ret = 0;
  while (n > 0) {
    ret ++;
    n /= 10;
  }
  return ret;
}
int main() {
  int N; cin >> N;
  int ans = 0;
  for (int i = 1; i <= N; i++) {
    if (digit(i)%2) {
      ans ++;
    }
  }
  printf("%d\n", ans); 
  
  return 0;
}


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

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

  	string A = s.substr(0, 2);
  	string B = s.substr(2, 2);
    int a = atoi(A.c_str());
    int b = atoi(B.c_str());

    if(a >= 1 && a <= 12){
        if(b >= 1 && b <= 12){
            cout << "AMBIGUOUS" << endl;
        }else{
            cout << "MMYY" << endl;
        }
    }else{
        if(b >= 1 && b <= 12){
            cout << "YYMM" << endl;
        }else{
            cout << "NA" << endl;
        }
    }

    return 0;
}

Measured memory_bytes: 256
import sys
import numpy as np
from scipy.misc import comb
sys.setrecursionlimit(1000000)
 
n,k = map(int,input().split())

mod = 10**9+7
ans = 0

for i in range(1,k+1):
    print(comb(n-k+1, i, exact=True) * comb(k-1, i-1, exact=True) % mod)


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

using namespace std;

#define rep(i, n) for(int i = 0; i < (int)n; ++i)
#define FOR(i, a, b) for(ll i = a; i < (ll)b; ++i)
#define rrep(i, n) for(int i = ((int)n - 1); i >= 0; --i)

typedef long long ll;

const int Inf = 1e9;
const double EPS = 1e-9;
const int MOD = 1e9 + 7;

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    ll n;
    cin >> n;
    FOR (a, 1, 3501) {
        FOR (b, 1, 3501) {
            ll t = 4 * a * b - n * b - n * a;
            if (t && (n * a * b) % t == 0) {
                ll c = (n * a * b) / t;
                if (c > 0) {
                    cout << a << " " << b << " " << c;
                    return 0;
                }
            }
        }
    }
    
    return 0;
}



Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
int a, b, c, d;
int main() {
 scanf("%d %d %d %d",&a,&b, &c, &d);
 if ((a + b) == (c + d)) {
    puts("Balanced");
  }
  else if ((a + b) > (c + d)) {
    puts("Left");
  }
  else if ((a + b) < (c + d)) {
    puts("Right");
  }
}

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

const int INF = 1 << 30;
const int dx[] = {1, 0, -1, 0};
const int dy[] = {0, 1, 0, -1};

class Dice
{
private:
  /*
    pip[0] = top, pip[1] = south, pip[2] = east
    pip[3] = bottom, pip[4] = north, pip[5] = west
  */
  int pip[6];
public:
  enum { TOP, SOUTH, EAST, BOTTOM, NORTH, WEST };

  Dice(int top = 1, int south = 2, int east = 3)
  {
    pip[TOP] = top;
    pip[SOUTH] = south;
    pip[EAST] = east;
    pip[BOTTOM] = 7 - top;
    pip[NORTH] = 7 - south;
    pip[WEST] = 7 - east;
  }

  // east:+, west:-
  void rotateX(int r)
  {
    if (r < 0)
      r += 4 * (-(r/4) + 1);
    r %= 4;
    for (int i = 0; i < r; ++i) {
      int tmp = pip[TOP];
      pip[TOP] = pip[WEST];
      pip[WEST] = pip[BOTTOM];
      pip[BOTTOM] = pip[EAST];
      pip[EAST] = tmp;
    }
  }

  // south:+, north:-
  void rotateY(int r)
  {
    if (r < 0)
      r += 4 * (-(r/4) + 1);
    r %= 4;
    for (int i = 0; i < r; ++i) {
      int tmp = pip[TOP];
      pip[TOP] = pip[NORTH];
      pip[NORTH] = pip[BOTTOM];
      pip[BOTTOM] = pip[SOUTH];
      pip[SOUTH] = tmp;
    }
  }
 
  inline int get(int p) const
  {
    return pip[p];
  } 
};

class State
{
public:
  int x, y, cost;
  Dice dice;
  State(int _x = 0, int _y = 0, int _cost = 0)
    :x(_x), y(_y), cost(_cost) {}

  bool operator < (const State& st) const
  {
    return this->cost > st.cost;
  }
};

int main()
{
  int h, w;
  while (cin >> h >> w) {
    if ((h|w) == 0)
      break;

    vector<vector<int> > mass(h, vector<int>(w));
    for (int i = 0; i < h; ++i) {
      for (int j = 0; j < w; ++j)
	cin >> mass[i][j];
    }

    int sx, sy, gx, gy;
    cin >> sy >> sx >> gy >> gx;

    priority_queue<State> que;
    que.push(State(sx, sy, 0));
    int dp[10][10][6][6][6]; // dp[y][x][top][south][east]
    for (int y = 0; y < 10; ++y)
      for (int x = 0; x < 10; ++x)
	for (int t = 0; t < 6; ++t)
	  for (int s = 0; s < 6; ++s)
	    for (int e = 0; e < 6; ++e)
	      dp[y][x][t][s][e] = INF;

    while (!que.empty()) {
      const State st = que.top();
      que.pop();

      if (st.x == gx && st.y == gy) {
	cout << st.cost << endl;
	break;
      }

      if (dp[st.y][st.x][st.dice.get(Dice::TOP)-1][st.dice.get(Dice::SOUTH)-1][st.dice.get(Dice::EAST)-1] < st.cost)
	continue;

      dp[st.y][st.x][st.dice.get(Dice::TOP)-1][st.dice.get(Dice::SOUTH)-1][st.dice.get(Dice::EAST)-1] = st.cost;
      for (int d = 0; d < 4; ++d) {
	int x = st.x + dx[d];
	int y = st.y + dy[d];
	if (x < 0 || w <= x || y < 0 || h <= y)
	  continue;

	Dice dice = st.dice;
	if (dx[d] != 0)
	  dice.rotateX(dx[d]);
	else
	  dice.rotateY(dy[d]);

	int cost = st.cost + mass[y][x] * dice.get(Dice::BOTTOM);
	if (dp[y][x][dice.get(Dice::TOP)-1][dice.get(Dice::SOUTH)-1][dice.get(Dice::EAST)-1] > cost) {
	  dp[y][x][dice.get(Dice::TOP)-1][dice.get(Dice::SOUTH)-1][dice.get(Dice::EAST)-1] = cost;
	  State tmp(x, y, cost);
	  tmp.dice = dice;
	  que.push(tmp);
	}
      }
    }
  }
  return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
 
const ll N = 2e5 + 100;
 
ll a[N];
 
int main() {
	ll n, ans = 0;
	cin >> n;
	for (ll i = 0; i < n; ++i)
		cin >> a[i];
	for (ll i = 0; i < n; ++i) {
		if (a[i] > i || (i != 0 && a[i - 1] + 1 < a[i])) {
			cout << "-1\n";
			return 0;
		}
	}
	for (ll i = 0; i < n - 1; ++i) {
		if (a[i] + 1 != a[i + 1])
			ans += a[i];
	}
	ans += a[n - 1];
	cout << ans << '\n';
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
 
int main() {
   char c;
   cin >>c;
   if(c=='a'||c=='i'||c=='u'||c=='e'||c=='o'){
             cout<<"vowel"<<endl;
     } else{
              cout<<"consonant"<<endl;
     }
}

Measured memory_bytes: 256
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <iomanip> // setprecision
#include <complex> // complex
#include <math.h> 
#define enld '\n'
using namespace std;
using ll = long long;
using P = pair<int,int>;
constexpr ll INF = 1e18;
constexpr int inf = 1e9;
constexpr ll mod = 1000000007;
constexpr ll mod2 = 998244353;
const int dx[8] = {1, 0, -1, 0,1,1,-1,-1};
const int dy[8] = {0, 1, 0, -1,1,-1,1,-1};
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
// ---------------------------------------------------------------------------


int main(){
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  vector<int> era(300100,0);
  era[0] = era[1] = 1;
  for(int i=1; i<300100; i++){
    if(i%7 == 1 || i%7 == 6){
      bool ok = true;
      for(ll j=2; j*j<=i; j++){
        if(i%j == 0){
          if(era[j] == 0) ok = false;
          if(era[i/j] == 0) ok = false;
        }
      }
      if(!ok){
        era[i] = 1;
      }
    }else{
      era[i] = 1;
    }
  }
  while(1){
    int N;
    cin >> N;
    if(N == 1) break;
    set<int> se;
    for(ll i=1; i*i<=N; i++){
      if(N%i == 0){
        if(era[i] == 0) se.emplace(i);
        if(era[N/i] == 0) se.emplace(N/i);
      }
    }
    cout << N << ":";
    for(auto s: se){
      cout << " " << s;
    }
    cout << "\n";
  }
  return 0;
}


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

int main(){
  string s;
  cin >> s;
  
  if (s == "SAT")
    cout << 1 << endl;
  else if (s == "FRI")
    cout << 2 << endl;
  else if (s == "THU")
    cout << 3 << endl;
  else if (s == "WED")
    cout << 4 << endl;
  else if (s == "TUE")
    cout << 5 << endl;
  else if (s == "MON")
    cout << 6 << endl;
  else
    cout << 7 << endl;
}

Measured memory_bytes: 3520
program main
    implicit none
    integer:: n,a,b, i,j,k, c1,c2
    double precision, allocatable:: v(:)
    double precision:: ave, mnum
    character(1000):: cmnum

    read*, n, a, b
    allocate(v(n))
    read*, v(1:n)
    ! print*, "#1"
    call sort(v(1:n))
    ! print*, "#2"

    ave = dble(sum(v(n-a+1:n)))/dble(a)
    ! print*, "#3"
    
    c1 = count(v(1:n) == v(n-a+1))

    if (v(n) /= v(n-a)) then
        ! print*, "#4.1"
        c2 = count(v(n-a+1:n) == v(n-a+1))
        mnum = comb(c1,c2)
    else
        ! print*, "#4.2"
        c2 = min(c1,b)
        mnum = 0.d0
        do i = a, c2
            mnum = mnum + comb(c1,i)
        end do
    end if
    
    ! print*, c1,c2
    print'(f0.7)', ave
    write(cmnum,'(f0.0)') mnum
    ! print*, mnum
    print'(A)', cmnum(1:len_trim(cmnum)-1)

    

contains
function comb(n,m) result(ret)
    implicit none
    integer, intent(in):: n,m
    integer::i, end
    double precision, allocatable:: dp(:), ndp(:)
    double precision:: ret
    end = n + 1
    allocate(dp(0:end), ndp(0:end))
    dp(:) = 0.d0; ndp(:) = 0.d0
    dp(1) = 1.d0; ndp(1) = 1.d0
    do i = 1, n
        ndp(1:end) = ndp(1:end) + dp(0:end-1) 
        dp(1:end) = ndp(1:end)
    end do
    ret = dp(m+1)
end function


subroutine sort(arr)
    implicit none
    integer:: i,j
    double precision,intent(inout):: arr(:)

    do i = 1,size(arr)
        do j = i, size(arr)
            if (arr(j) >= arr(i)) cycle
            call swap(arr(i), arr(j))
        end do
    end do
end subroutine

subroutine swap(a,b)
    implicit none
    double precision, intent(inout):: a,b
    double precision:: c
    c=a; a=b; b=c
end subroutine

end program

Measured memory_bytes: 256
#include <bits/stdc++.h> 
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<long long> vll;
typedef vector<bool> vb;
const int MOD = 1e9 + 7;
 
int main() {
    int n, k;
    cin >> n >> k;
    vector<int> a(n);
    for (int i = 0; i < n; ++i)
        cin >> a[i];
 
    vector<vll> dp(n+1, vector<ll> (k+1, 0));
    dp[0][0] = 1;
    /*
    dp[i][j] No of ways i candies be distributed among first j children so far.
    */
    for (int i = 1; i <= n; ++i) {
        dp[i][0] = 1;
        vll fake(k+1, 0);
        fake[0] = 1;
        for (int j = 1; j <= k; ++j) {
            fake[j] = (fake[j-1] + dp[i-1][j]) % MOD;
        }
        for (int j = 1; j <= k; ++j) {
            int l = max(j-a[i-1], 0);
            int r = j;
            if (l > 0) {
                dp[i][j] = (MOD+fake[r] - fake[l-1])%MOD;
            } else {
                dp[i][j] = fake[r];
            }
        }
    }
    cout << dp[n][k] << endl;
    return 0;
}

Measured memory_bytes: 83144
// 解き直し.
// AtCoder Beginner Contest 123 解説.
// https://img.atcoder.jp/abc123/editorial.pdf
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
using LL = long long;
const int MAX = 1e3 + 1;
LL A[MAX], B[MAX], C[MAX];

struct cake{
    LL  d; // 美味しさの合計.
    int a; // A の index.
    int b; // B の index.
    int c; // C の index.
    bool operator < (const cake &C) const { return d < C.d; }
};

// 与えられた情報を結合して, 文字列を返却.
// @param prefix: 接頭語.
// @param d: 美味しさの合計.
// @param a: A の index.
// @param b: B の index.
// @param c: C の index.
// @return ret: map に 登録する 文字列 key.
string makeKey(string prefix, LL d, int a, int b, int c){
    string ret = prefix;
    ret += {"_"};
    ret += to_string(A[a] + B[b] + C[c]);
    ret += {"_"};
    ret += to_string(a);
    ret += {"_"};
    ret += to_string(b) + "_" + to_string(c);
    return ret;
}

int main(){
    
    // 1. 入力情報取得.
    int X, Y, Z, K;
    scanf("%d %d %d %d", &X, &Y, &Z, &K);
    FOR(i, 0, X) scanf("%lld", A + i);
    FOR(i, 0, Y) scanf("%lld", B + i);
    FOR(i, 0, Z) scanf("%lld", C + i);
    
    // 2. 降順sort.
    sort(A, A + MAX, greater<LL>());
    sort(B, B + MAX, greater<LL>());
    sort(C, C + MAX, greater<LL>());
    
    // 3. 解説通り(※Priority Queue (優先度付きキュー) を 使うパターン).
    int a = 0, b = 0, c = 0;
    priority_queue<cake> pq;
    map<string, int> m;
    pq.push({A[a] + B[b] + C[c], a, b, c});
    string s = makeKey("p", A[a] + B[b] + C[c], a, b, c);
    m[s]++;
    int index = 1;
    while(!pq.empty()){
        // 3-1. pq の中で, 一番美味しさの大きい要素を取得.
        cake i = pq.top();
        a = i.a, b = i.b, c = i.c;
        pq.pop();
        
        // 3-2. 追加されてないパターンを追加.
        cake p1 = {A[a + 1] + B[b] + C[c], a + 1, b, c};
        string s1 = makeKey("p", A[a + 1] + B[b] + C[c], a + 1, b, c);
        cake p2 = {A[a] + B[b + 1] + C[c], a, b + 1, c};
        string s2 = makeKey("p", A[a] + B[b + 1] + C[c], a, b + 1, c);
        cake p3 = {A[a] + B[b] + C[c + 1], a, b, c + 1};
        string s3 = makeKey("p", A[a] + B[b] + C[c + 1], a, b, c + 1);
        if(a < X - 1 && m[s1] == 0) pq.push(p1), m[s1]++;
        if(b < Y - 1 && m[s2] == 0) pq.push(p2), m[s2]++;
        if(c < Z - 1 && m[s3] == 0) pq.push(p3), m[s3]++;

        // 3-3. index番目 のケーキの美味しさの合計を出力.
        printf("%lld\n", i.d);
        
        // 3-4. increment.
        index++;
        
        // 3-5. index番目 が Kより大きくなったら終了.
        if(index > K) break;
    }
    // printf with std::string?
    // https://stackoverflow.com/questions/10865957/printf-with-stdstring
    // for(auto &e : m) printf("key=%s, value=%d\n", e.first.c_str(), e.second);
    return 0;
    
}

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

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep_r(i, n) for (int i = n - 1; i >= 0; i--)
#define rep1(i, n) for (int i = 1; i <= (int)(n); i++)
#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define all(x) (x).begin(), (x).end()
#define SZ(x) ((ll)(x).size())
#define bit(n) (1LL << (n))
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end());

#define INF bit(60)
#define pb push_back
#define mod 1000000007

using namespace std;
using uif = uint_fast64_t;
using ll = long long int;
using tTree = __gnu_pbds::tree<ll, __gnu_pbds::null_type, less<ll>, __gnu_pbds::rb_tree_tag, __gnu_pbds::tree_order_statistics_node_update>;

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

#define FACSIZE 200002

ll invfac[FACSIZE];
ll fac[FACSIZE];

template <class T>
bool chmax(T &, const T &);
template <class T>
bool chmin(T &, const T &);
ll gcd(ll, ll);
ll powLL(ll x, ll y);

ll mod_pow(ll, ll);
ll mod_add(ll, ll);
ll mod_mul(ll, ll);
ll mod_div(ll, ll);
ll comb(ll, ll);
void make_fact(ll);
void make_invfact(ll);
void fact_init();

int main(void)
{
  ll h, w, n;
  cin >> h >> w >> n;

  auto x = max(h, w);

  if (n % x == 0)
  {
    cout << n / x << endl;
  }
  else
  {
    cout << n / x + 1 << endl;
  }

  return 0;
}

ll mod_pow(ll x, ll r)
{
  if (r == 0)
    return 1;
  else if (r == 1)
    return x % mod;
  else if (r % 2 == 0)
  {
    ll t = mod_pow(x, r / 2) % mod;
    return mod_mul(t, t);
  }
  else
  {
    ll t = mod_pow(x, r / 2) % mod;
    ll k = mod_mul(t, t);
    return (k % mod) * (x % mod);
  }
}
ll mod_add(ll a, ll b)
{
  return ((a % mod) + (b % mod)) % mod;
}

ll mod_mul(ll a, ll b)
{
  return ((a % mod) * (b % mod)) % mod;
}

ll mod_div(ll a, ll b)
{
  return mod_mul(a, mod_pow(b, mod - 2));
}

void fact_init()
{
  make_fact(FACSIZE - 1);
  make_invfact(FACSIZE);
}

void make_fact(ll n)
{
  fac[0] = 1;
  rep(i, n)
  {
    fac[i + 1] = mod_mul(fac[i], i + 1);
  }
}

void make_invfact(ll n)
{
  invfac[n] = mod_pow(fac[n], mod - 2);
  for (int i = n - 1; i >= 0; i--)
  {
    invfac[i] = mod_mul(invfac[i + 1], i + 1);
  }
}

ll comb(ll n, ll r)
{

  return mod_mul(mod_mul(fac[n], invfac[r]), invfac[n - r]);
}
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 (b < a)
  {
    a = b;
    return 1;
  }
  return 0;
}

ll qp(ll a, ll b)
{
  ll ans = 1LL;
  do
  {
    if (b & 1LL)
      ans = 1LL * mod_mul(ans, a) % mod;
    a = 1LL * mod_mul(a, a) % mod;
  } while (b >>= 1LL);
  return ans;
}
ll qp(ll a, ll b, ll mo)
{
  ll ans = 1LL;
  do
  {
    if (b & 1LL)
      ans = 1LL * (ans % mo) * (a % mo);
    a = 1LL * (a % mo) * (a % mo);
  } while (b >>= 1LL);
  return ans;
}
ll gcd(ll a, ll b)
{
  return b ? gcd(b, a % b) : a;
}
ll powLL(ll x, ll y)
{
  ll ans = 1LL;
  for (ll i = 0LL; i < y; i++)
    ans *= x;
  return ans;
}

Measured memory_bytes: 256
#include<iostream>
#include<math.h>
#include<stdlib.h>
#include<string>
#include<limits.h>
#include<utility>
#include<queue>
#include<vector>
#include<tuple>
#include<algorithm>
#include<map>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
#define rep(i,n) for(int i=0;i<n;i++)
#define ALL(A) A.begin(),A.end()
bool comparator(P a, P b) {
	return a.first / a.second < b.first / b.second;
}
ll dist(ll a, ll b, ll c, ll d) {
	return abs(c - a) + abs(d - b);
}
int main() {
	ll n;
	cin >> n;
	ll X[n], Y[n];
	
	rep(i, n) {
		cin >> X[i] >> Y[i];
	}
	ll YE = Y[0], XE = X[0], XW = X[0], YW = Y[0];
	ll XN = X[0], YN = Y[0], XS = X[0], YS = Y[0];
	rep(i, n) {
		if (XE > X[i]) {
			XE = X[i];
			YE = Y[i];
		}
		if (XW < X[i]) {
			XW = X[i];
			YW = Y[i];
		}
		if (YN < Y[i]) {
			XN = X[i];
			YN = Y[i];
		}
		if (YS > Y[i]) {
			XS = X[i];
			YS = Y[i];
		}
	}
	ll px = (XS + XN) / 2;
	ll py = (YE + YW) / 2;
	ll dista[4];
	ll XX[4]; ll YY[4];
	rep(i, 4) {
		dista[i] = 0;
		XX[i] = px;
		YY[i] = py;
	}
	//couta << px << py << endl;
	rep(i, n) {
		ll d = dist(px, py, X[i], Y[i]);
		//cout << d << endl;
		if (X[i] >= px && Y[i] >= py) {
			if (dista[0] < d) {
				XX[0] = X[i];
				YY[0] = Y[i];
				dista[0] = d;
			}
		}
		if (X[i] <= px && Y[i] >= py) {
			if (dista[1] < d) {
				XX[1] = X[i];
				YY[1] = Y[i];
				dista[1] = d;
			}
		}
		if (X[i] <= px && Y[i] <= py) {
			if (dista[2] < d) {
				XX[2] = X[i];
				YY[2] = Y[i];
				dista[2] = d;
			}
		}
		if (X[i] >= px && Y[i] <= py) {
			if (dista[3] < d) {
				XX[3] = X[i];
				YY[3] = Y[i];
				dista[3] = d;
			}
		}
	}
	ll ans = 0;
	for (ll i = 0; i < 3; i++) {
		for (ll j = i + 1; j < 4; j++) {
			ll d = dist(XX[i], YY[i], XX[j], YY[j]);
			//cout << XX[i] << " "<<YY[i] <<" " <<XX[j] <<" "<< YY[j] << endl;
			if (d > ans) {
				ans = d;
				//cout << i << " " << j << endl;
			}
		
		}
	}
	cout << ans << endl;
}


Measured memory_bytes: 6320
import numpy as np
H,W=map(int, input().split())
S=[]
for h in range(H):
    s=list(input())
    S.append(s)
S=np.array(S)
ruit=np.zeros((H,W))
ruit[0,:]=np.where(S[0,:]==".",1,0)
ruil=np.zeros((H,W))
ruil[:,0]=np.where(S[:,0]==".",1,0)
ruir=np.zeros((H,W))
ruir[:,-1]=np.where(S[:,-1]==".",1,0)
ruib=np.zeros((H,W))
ruib[-1,:]=np.where(S[-1,:]==".",1,0)

for h in range(1,H):
    nowt=np.where(S[h,:]==".",1,0)
    ruit[h,:]=(ruit[h-1,:]+nowt)*nowt

    nowb=np.where(S[-(h+1),:]==".",1,0)
    ruib[-(h+1),:]=(ruib[-h,:]+nowb)*nowb

for w in range(1,W):
    nowl=np.where(S[:,w]==".",1,0)
    ruil[:,w]=(ruil[:,w-1]+nowl)*nowl
    nowr=np.where(S[:,-(w+1)]==".",1,0)
    ruir[:,-(w+1)]=(ruir[:,-w]+nowr)*nowr
#print(ruir)
#print(ruil)
#print(ruib)
print(int((ruit+ruib+ruil+ruir-3).max()))


    





Measured memory_bytes: 250932
#include <cstdio>
#include <iostream>
#include <algorithm>
using namespace std;
#define ref(i,x,y)for(int i=x;i<=y;++i)
const int N=201;
int n;
int l[N];
int main()
{
	cin>>n;
	ref(i,1,2*n)cin>>l[i];
	sort(l+1,l+2*n+1);
	int ans=0;
	ref(i,1,2*n)if(i&1)ans+=l[i];
	cout<<ans<<endl;
}

Measured memory_bytes: 256
import java.io.IOException;
import java.io.InputStream;
import java.util.NoSuchElementException;

public class Main {
	public static void main(String[] args) {
		FastScanner scan = new FastScanner();
		int a = scan.nextInt();
		int b = scan.nextInt();

		int ret = 1;
		int tap = a;
		if (b == 1) {
			ret = 0;
		} else {

			while (tap < b) {
				ret++;
				tap += a - 1;
			}
		}
		System.out.println(ret);
	}
}

class FastScanner {
	private final InputStream in = System.in;
	private final byte[] buffer = new byte[1024];
	private int ptr = 0;
	private int buflen = 0;

	private boolean hasNextByte() {
		if (ptr < buflen) {
			return true;
		} else {
			ptr = 0;
			try {
				buflen = in.read(buffer);
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (buflen <= 0) {
				return false;
			}
		}
		return true;
	}

	private int readByte() {
		if (hasNextByte())
			return buffer[ptr++];
		else
			return -1;
	}

	private static boolean isPrintableChar(int c) {
		return 33 <= c && c <= 126;
	}

	public boolean hasNext() {
		while (hasNextByte() && !isPrintableChar(buffer[ptr]))
			ptr++;
		return hasNextByte();
	}

	public String next() {
		if (!hasNext())
			throw new NoSuchElementException();
		StringBuilder sb = new StringBuilder();
		int b = readByte();
		while (isPrintableChar(b)) {
			sb.appendCodePoint(b);
			b = readByte();
		}
		return sb.toString();
	}

	public long nextLong() {
		if (!hasNext())
			throw new NoSuchElementException();
		long n = 0;
		boolean minus = false;
		int b = readByte();
		if (b == '-') {
			minus = true;
			b = readByte();
		}
		if (b < '0' || '9' < b) {
			throw new NumberFormatException();
		}
		while (true) {
			if ('0' <= b && b <= '9') {
				n *= 10;
				n += b - '0';
			} else if (b == -1 || !isPrintableChar(b)) {
				return minus ? -n : n;
			} else {
				throw new NumberFormatException();
			}
			b = readByte();
		}
	}

	public int nextInt() {
		long nl = nextLong();
		if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE)
			throw new NumberFormatException();
		return (int) nl;
	}

	public double nextDouble() {
		return Double.parseDouble(next());
	}
}

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

using namespace std;

#define SZ(x) (int)(x.size())
#define REP(i, n) for(int i=0;i<(n);++i)
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define RREP(i, n) for(int i=(int)(n);i>=0;--i)
#define RFOR(i, a, b) for(int i=(int)(a);i>=(int)(b);--i)
#define ALL(a) (a).begin(),(a).end()
#define DUMP(x) cerr<<#x<<" = "<<(x)<<endl
#define DEBUG(x) cerr<<#x<<" = "<<(x)<<" (L"<<__LINE__<<")"<< endl;

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

const double eps = 1e-8;
const ll MOD = 1000000007;
const int INF = INT_MAX / 2;
const ll LINF = LLONG_MAX / 2;

template <typename T1, typename T2>
bool chmax(T1 &a, const T2 &b) {
  if(a < b) {a = b; return true;}
  return false;
}

template <typename T1, typename T2>
bool chmin(T1 &a, const T2 &b) {
  if(a > b) {a = b; return true;}
  return false;
}

template<typename T1, typename T2>
ostream& operator<<(ostream &os, const pair<T1, T2> p) {
  os << p.first << ":" << p.second;
  return os;
}

template<class T>
ostream &operator<<(ostream &os, const vector<T> &v) {
  REP(i, SZ(v)) {
    if(i) os << " ";
    os << v[i];
  }
  return os;
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);

  int n; cin >> n;
  vector<string> s(n);
  REP(i, n) {
    cin >> s[i];
    reverse(ALL(s[i]));
  }

  vi cnt1(n, 0);
  vi cnt2(n);
  vi cnt3(n);
  REP(i, n) {
    ll val = 0;
    RREP(j, SZ(s[i])-1) {
      if(s[i][j] == '.') {
        cnt1[i] = j;
      } else {
        val *= 10;
        val += s[i][j] - '0';
      }
    }

    if(cnt1[i] != 0) {
      REP(j, SZ(s[i])) {
        if(s[i][j] != '0') {
          break;
        } else {
          cnt1[i]--;
          val /= 10;
        }
      }
    }

    ll tmp = val;
    while(tmp % 2 == 0) {
      cnt2[i]++;
      tmp /= 2;
    }
    tmp = val;
    while(tmp % 5 == 0) {
      cnt3[i]++;
      tmp /= 5;
    }

    cnt2[i] -= cnt1[i];
    cnt3[i] -= cnt1[i];
  }

  int sz = 70;
  vvi mp4(sz, vi(sz, 0));
  REP(i, n) {
    mp4[-cnt2[i]+35][-cnt3[i]+35]++;
  }

  // +35する
  vvi su(sz+1, vi(sz+1, 0));
  REP(i, sz) {
    REP(j, sz) {
      su[i+1][j+1] = mp4[i][j] + su[i+1][j] + su[i][j+1] - su[i][j];
    }
  }



  ll ans = 0;
  REP(i, n) {
    ans += su[cnt2[i]+36][cnt3[i]+36];
    if(cnt2[i] >= 0 && cnt3[i] >= 0) {
      ans--;
    }
  }
  cout << ans / 2 << endl;



}








Measured memory_bytes: 11800
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000


int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a, b, c;
    cin >> a >> b >> c;
    if (b - a == c - b) {
        cout << "YES" << endl;
    } else {
        cout << "NO" << endl;
    }

    return 0;
}


Measured memory_bytes: 256
n = int(input())


lst = []
for _ in range(n):
    d = {}
    s = input()
    for i in s:
        if i in d:
            d[i] += 1
        else:
            d[i] = 1
    lst.append(d)

keys = [list(d.keys()) for d in lst]

a = set(keys[0])
for i in range(1, n):
    a = a & set(keys[i])


ret = {k: 100 for k in a}
for d in lst:
    for k in a:
        ret[k] = min(ret[k], d[k])

s = ""
for k, v in ret.items():
    s += k*v

s = "".join(sorted(s))

print(s)


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

using namespace std;
using ll=long long;

#define faster ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)
#define cint int t;cin>>t;while(t--)
#define rep(i,n) for(ll i=0;i<n;i++)
#define pii pair<int,int>
typedef vector<int> vint;
#define fi first
#define se second

ll mod=1e9+7;

int main(){
    faster;

    int h,n;
    cin>>h>>n;

    int dp[10001];
    rep(i,10001) dp[i]=mod;

    vector<pii> v;
    rep(i,n){
        int x,y;
        cin>>x>>y;
        v.push_back({x,y});
        dp[v[i].fi]=min(dp[v[i].fi],y);
    }
    sort(v.begin(),v.end());

    rep(i,10001){
        for(auto j:v){
            if(i-j.fi<0) break;
            else{
                dp[i]=min(dp[i],j.se+dp[i-j.fi]);
            }
        }
    }

    int ans=mod;
    for(int i=h;i<10001;i++){
        ans=min(ans,dp[i]);
    }
//    rep(i,10001) cout<<dp[i]<<" ";
//    cout<<endl;
    cout<<ans<<endl;
}

Measured memory_bytes: 384
#include<iostream>
#include<vector>
#include<algorithm>
#include<set>
#include<queue>
#include<map>
#include<math.h>
#include<string>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define reps(i, s, n) for (int i = s; i < (int)(n); i++)
#define out(x) cout << x << endl
#define INF 1ll<<60;

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

int main(){
    int a, b, h;
    cin >> a >> b >> h;
    out((a+b)*h/2);
}


Measured memory_bytes: 256
N,A,B = (int(i) for i in input().split())

if N == 1:
    if A == B:
        ans = 1
    else:
        ans = 0
else:    
    if A>B:
        ans = 0
    else:
        ans = (B-A)*(N-2) + 1

print(ans)

Measured memory_bytes: 2940
#include <iostream>
#include <cstdio>
#include <iomanip>
#include <cmath>
#include <string>
#include <cstring>
#include <algorithm>
#include <vector>
#include <sstream>
#include <set>
#include <queue>
#include <stack>
#include <cctype>
#include <map>
#include <climits>
#include <bitset>
using namespace std;
#define MATH_PI 3.14159265358979323846
int main(){
	ios::sync_with_stdio(false);
	int iTime, iYenPerHur, iTotal;
	cin >> iTime >> iYenPerHur >> iTotal;
	cout << min(iTime*iYenPerHur, iTotal) << endl;
endapp:
	//system("pause > nul");
	return 0;
}

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;
using P = pair<int, int>;

int main() {
    int a, b;
    cin >> a >> b;
    int ans = (a + b) % 24;
    cout << ans << endl;
}

Measured memory_bytes: 256
using System;
    using System.Linq;
    using System.Collections.Generic;
    using System.IO;
    using System.Text;
    using System.Text.RegularExpressions;

    class Program
    {
        static void Main()
        {
            var inputList = System.Console.ReadLine().Split(' ').Select((x) => decimal.Parse(x)).ToList();
            var x = inputList[0];
            var n = inputList[1];
            if (n == 0)
            {
                Output(x.ToString());
                return;
            }
            try
            {
                var pList = System.Console.ReadLine().Split(' ').Select((x) => decimal.Parse(x)).ToList();

                var minList = pList.OrderBy(c => Math.Abs(c - x)).ToList();
                for (int i = 0; i < n + 1; i++)
                {
                    var target = x;
                    target = x - i;
                    if (!pList.Contains(target))
                    {
                        Output(target.ToString());
                        return;
                    }
                    target = x + i;
                    if (!pList.Contains(target))
                    {
                        Output(target.ToString());
                        return;
                    }
                }
                Output(x.ToString());
            }

            catch
            {
                Output(x.ToString());
            }
        }
        private static void Output(string str)
        {
            var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);

            Console.WriteLine(str);

            Console.Out.Flush();
        }
    }


Measured memory_bytes: 28488