akhauriyash/Code-Regression huggingface dataset:
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.io.IOException;
import java.util.NoSuchElementException;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        FasterScanner in = new FasterScanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskC solver = new TaskC();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskC {
        public void solve(int testNumber, FasterScanner in, PrintWriter out) {
            long w = in.nextLong();
            long h = in.nextLong();

            long ans = Long.MAX_VALUE;

            if (w % 3 == 0 || h % 3 == 0) {
                ans = 0;
            } else if (w % 2 == 0 && h % 2 == 0) {
                ans = Math.min(w, h) / 2;
            } else if (w % 2 == 0) {
                ans = w / 2;
            } else if (h % 2 == 0) {
                ans = h / 2;
            } else if (h == w) {
                ans = (w / 2) * (h / 2);
            }

            if (w < ans) ans = w;
            if (h < ans) ans = h;

            out.println(ans);
        }

    }

    static class FasterScanner {
        private InputStream in;
        private byte[] buffer;
        private int bufPointer;
        private int bufLength;

        public FasterScanner(InputStream in) {
            this.in = in;
            buffer = new byte[1024];
        }

        private boolean hasNextByte() {
            if (bufPointer < bufLength) return true;
            bufPointer = 0;
            try {
                bufLength = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            return (bufLength > 0);
        }

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

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

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

        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' || b > '9') throw new NumberFormatException();

            while (true) {
                if (b >= '0' && b <= '9') {
                    n *= 10;
                    n += b - '0';
                } else if (b == -1 || !isPrintableChar(b)) {
                    return minus ? -n : n;
                } else {
                    throw new NumberFormatException();
                }
                b = readByte();
            }
        }

    }
}



Measured memory_bytes: 25172
n,m=map(int,input().split())
a = []
for i in range(n):
    a.append(input())
b = []
for i in range(m):
    b.append(input())

ok=False
for i in range(n-m+1):
    for j in range(n-m+1):
        cf=[]
        for l in range(m):
            cf.append(a[i+l][j:j+m])
            #print(cf)
            if cf==b:
                ok=True
print("Yes"if ok else "No")

Measured memory_bytes: 3064
#include <iostream>
#include <set>
#include <vector>
#include <algorithm>

class Tea {
  public:
      long long size; // ml で保持
      long long price;
      long long price_per_size; // yen/l で保持
    bool operator<(const Tea& s) const;
};

bool Tea::operator<(const Tea& t) const
{
  return price_per_size < t.price_per_size; // リッター毎の価格でソート
}

using namespace std;

#define DEBUG(x) cout << #x << ": " << x << endl;
#define MOD 1000000007

int main() {
  vector<Tea> teas;
  long long prices[4] = {250, 500, 1000, 2000};
  for (int i = 0; i < 4; i++) {
    Tea t;
    t.size = prices[i];
    cin >> t.price;
    t.price_per_size = t.price * 1000 / t.size;
    teas.push_back(t);
  }
  sort(teas.begin(), teas.end());

  long long N;
  cin >> N;
  N = N * 1000;

  bool is_full = false;
  int tryIndex = 0;
  long long totalPrice = 0;
  while(!is_full) {
    int trySize = teas[tryIndex].size;

    // DEBUG(tryIndex);
    // DEBUG(N);
    // DEBUG(trySize);
    // DEBUG(totalPrice);

    if (N >= trySize) {
      N = N - trySize;
      totalPrice = totalPrice + teas[tryIndex].price;
    } else {
      tryIndex++;
    }
    if (N == 0) {
      is_full = true;
    }
  }

  cout << totalPrice << endl;
}


Measured memory_bytes: 256
import java.io.*;
import java.math.*;
import java.util.*;
public class Main {
 
	public static void main(String[] args) {  
		Scanner input = new Scanner(System.in);
		int N = input.nextInt();
		int T = 0;
		int F = 0; //Two and four
		int bad = 0;
		for (int i = 0; i < N; i++) {
			int x = input.nextInt();
			if (x%4==0) F++;
			else if (x%2==0) T++;
			else bad++;
		}
		if (T>=1&&T<N) { //2 2 2 2... 2 works
			bad++;//2 2 1 4 1 doesn't work
		}  //multiples of two can be joined as one contiguous sub-array since 2^2 = 4
		if (F>=1) {
			F++; //3 4s handle 4 bad slots ---> {bad,4,bad,4,bad,4,bad} --> x 4s handle x+1 bad slots
			bad-=F;
		}
		System.out.println(bad<=0?"Yes":"No");
	}
}

Measured memory_bytes: 48532
import itertools
from collections import Counter

n = int(input())
c = Counter()
for i in range(n):
    tmp = input().strip()
    if tmp[0] in ['M', 'A', 'R', 'C', 'H']:
        c[tmp[0]] += 1

result = 0
for v in itertools.permutations(c.values(), 3):
    result += v[0] * v[1] * v[2]

print(result // 6)




Measured memory_bytes: 44776
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define mp make_pair
#define pb push_back
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)


int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll N,M;
  cin >> N >> M;
  ll ans;
  if(N==1 && M==1){
    ans = 1;
  }
  else if(N==1 || M==1){
    ans =N*M - 2;
  }
  else{
    ans = (N-2LL) * (M-2LL);
  }
  cout << ans << endl;
  
  return 0;
    

}


Measured memory_bytes: 256
import java.util.*;

public class Main {

    public static void main(String args[]) {

        // 入力
        Scanner sc = new Scanner(System.in);
        int a = Integer.parseInt(sc.next());
        int b = Integer.parseInt(sc.next());
        String s = sc.next();
        sc.close();

        // 主処理
        String regex = "[0-9]{" + a + "}-[0-9]{" + b + "}";
        boolean judge = s.matches(regex);
        String result = judge ? "Yes" : "No";

        // 出力
        System.out.println(result);
    }
}


Measured memory_bytes: 22100
# -*- coding:utf-8 -*-
import sys
import heapq
from collections import defaultdict

"""解説PDF
(1) 0日目から考えると、最初に選べるアルバイトが多すぎて、どれを適切に選んでいけばよいかわからない

(2) M日後から考えると、M日後からi日前には、A_i<=iとなるアルバイトしか選べないので、これで考えると貪欲的に解ける

"""
def solve():
    N, M = list(map(int, sys.stdin.readline().split()))
    jobs = defaultdict(lambda: [])

    # jobs[a] := 報酬がa日後に貰えるアルバイトのリスト
    for i in range(N):
        a, b = list(map(int, sys.stdin.readline().split()))
        jobs[a].append(b)

    ans = 0
    heap = []  # アルバイト候補
    for i in range(1, M+1):
        # M-i日目に何のアルバイトをすればよいかを考える
        for b in jobs[i]:
            # 候補の追加
            heapq.heappush(heap, -b)  # 最大値を根にするために、マイナスをかける

        if len(heap) != 0:
            # 候補の中で報酬が最大値を取り出す
            ans += -heapq.heappop(heap)

    print(ans)


if __name__ == "__main__":
    solve()


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

using namespace std;

long long dx[] = {-1, 1, 0, 0};
long long dy[] = {0, 0, -1, 1};
char dir[] = {'L', 'R', 'D', 'U'};

int get(int x, int y) {
    return (((x + y) % 2) + 2) % 2;
}

void solve() {
    int n;
    cin >> n;
    vector<long long> x(n), y(n);
    for (int i = 0; i < n; i++) {
        cin >> x[i] >> y[i];
        if (i > 0 && get(x[i - 1], y[i - 1]) != get(x[i], y[i])) {
            cout << -1; return;
        }
    }
    int parity = get(x[0], y[0]);
    cout << 31 + (parity == 0) << "\n";
    for (int i = 0; i <= 30; i++) {
        cout << (1 << i) << ' ';
    }
    if (!parity) cout << 1 << ' ';
    cout << "\n";
    for (int i = 0; i < n; i++) {
        string s;
        if (!parity) s.push_back('D'), y[i]++;
        for (int j = 30; j >= 0; j--) {
            for (int k = 0; k < 4; k++) {
                long long nx = x[i] + 1LL * dx[k] * (1 << j), ny = y[i] + 1LL * dy[k] * (1 << j);
                if (abs(nx) + abs(ny) <= (1 << j) - 1) {
                    x[i] = nx, y[i] = ny;
                    s.push_back(dir[k ^ 1]);
                    break;
                }
            }
        }
        reverse(s.begin(), s.end());
        cout << s << "\n";
    }
}

int main() {
    ios::sync_with_stdio(NULL), cin.tie(0), cout.tie(0);
    cout.setf(ios::fixed), cout.precision(20);
    solve();
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <cmath>
#include <cstring>
#include <iomanip>
#include <random>
#include <chrono>
#include <queue>
#include <ctime>
using namespace std;
typedef long long ll;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;
#define fs first
#define sc second
#define INF 1000000000
#define MOD 1000000007
#define EPS 0.00000001

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

int main() {
    int N; cin >> N;
    vector<int> A(N);
    for(int &a:A){
        cin >> a;
    }

    vector<int> L(N+1);
    vector<int> R(N+1);
    for(int i=0; i<N; i++){
        L[i+1] = gcd(L[i], A[i]);
    }
    for(int i=N-1; i>=0; i--){
        R[i] = gcd(R[i+1], A[i]);
    }
    
    int ans = 0;
    for(int i=0; i<N; i++){
        ans = max(ans, gcd(L[i], R[i+1]));
    }

    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 1408
#pragma region template
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using ld = long double;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vvvll = vector<vvll>;
using vld = vector<ld>;
using vvld = vector<vld>;
using vvvld = vector<vvld>;
using vs = vector<string>;
using pll = pair<ll, ll>;
using vp = vector<pll>;
template <typename T>
using pqrev = priority_queue<T, vector<T>, greater<T>>;
#define rep(i, n) for (ll i = 0, i##_end = (n); i < i##_end; i++)
#define repb(i, n) for (ll i = (n)-1; i >= 0; i--)
#define repr(i, a, b) for (ll i = (a), i##_end = (b); i < i##_end; i++)
#define reprb(i, a, b) for (ll i = (b)-1, i##_end = (a); i >= i##_end; i--)
#define ALL(a) (a).begin(), (a).end()
#define SZ(x) ((ll)(x).size())
//*
constexpr ll MOD = 1e9 + 7;
/*/
constexpr ll MOD = 998244353;
//*/
constexpr ll INF = 1e+18;
constexpr ld EPS = 1e-12L;
constexpr ld PI = 3.14159265358979323846L;
constexpr ll GCD(ll a, ll b) { return b ? GCD(b, a % b) : a; }
constexpr ll LCM(ll a, ll b) { return a / GCD(a, b) * b; }
template <typename S, typename T>
constexpr bool chmax(S &a, const T &b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <typename S, typename T>
constexpr bool chmin(S &a, const T &b) {
  if (b < a) {
    a = b;
    return 1;
  }
  return 0;
}
#ifdef OJ_LOCAL
#include "dump.hpp"
#else
#define dump(...) ((void)0)
#endif
template <typename T>
bool print_(const T &a) {
  cout << a;
  return true;
}
template <typename T>
bool print_(const vector<T> &vec) {
  for (auto &a : vec) {
    cout << a;
    if (&a != &vec.back()) {
      cout << " ";
    }
  }
  return false;
}
template <typename T>
bool print_(const vector<vector<T>> &vv) {
  for (auto &v : vv) {
    for (auto &a : v) {
      cout << a;
      if (&a != &v.back()) {
        cout << " ";
      }
    }
    if (&v != &vv.back()) {
      cout << "\n";
    }
  }
  return false;
}
void print() { cout << "\n"; }
template <typename Head, typename... Tail>
void print(Head &&head, Tail &&... tail) {
  bool f = print_(head);
  if (sizeof...(tail) != 0) {
    cout << (f ? " " : "\n");
  }
  print(forward<Tail>(tail)...);
}
#pragma endregion

void Pr(bool f){
  cout << (f ? "Yes" : "No") << "\n";
  exit(0);
}

ll dp[2][2030];

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(20);
  string s;
  cin >> s;
  ll n = SZ(s);
  vll ss(n);
  rep(i, n){
    ss[i] = s[i]-'0';
  }
  dp[0][ss[0]] = 1;
  ll ans = dp[0][0];
  repr(i, 1, n){
    rep(j, 2019){
      dp[i&1][j] = 0;
    }
    rep(j, 2019){
      dp[i&1][(j*10+ss[i])%2019] += dp[!(i&1)][j];
    }
    dp[i&1][ss[i]]++;
    ans += dp[i&1][0];
  }
  print(ans);
}


Measured memory_bytes: 5120
n=int(input())
v=[[int(_) for _ in input().split()] for l in range(n)]

for x in range(101):
  for y in range(101):
    for i in range(n):
       if v[i][2]:
         H=v[i][2]+abs(v[i][0]-x)+abs(v[i][1]-y)
         break
    for i in range(n):
      if v[i][2]:
         if H != v[i][2]+abs(v[i][0]-x)+abs(v[i][1]-y):
           break
      else:
        if H>abs(v[i][0]-x)+abs(v[i][1]-y):
          break
    else:
      print(x,y,H)
      exit


Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
int l,r,ans=2019;
int main() {
	scanf("%d%d",&l,&r);
	if(r-l>2020)ans=0;
	else {
		for(int i=l; i<=r; i++) {
			for(int j=i+1; j<=r; j++) {
				ans=min(ans,(i%2019)*(j%2019)%2019);
			}
		}
	}
	printf("%d",ans);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define INF 100000000000
#define MOD 1000000007
#define ll long long int
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()



using namespace std;





int main() {
  ll N; cin>>N;
  ll A[N+1] = {};
  REP(i,N) {
    ll a; cin>>a;
    A[a]++;
  }
  ll ans = 1;
  REP(i,N){
    if(A[i] > 2) {cout<<0<<endl;return 0;}
    if(A[i] == 0) continue;
    ans *= A[i];
    ans %= MOD;
  }
  if(A[0] == 2) ans = 0;
  cout<<ans<<endl;


  return 0;
}

Measured memory_bytes: 1024
#include<cstdio>
#include<iostream>
#include<cstring>
using namespace std;
int main(void)
{
    int d,l,x,y,z;
    cin>>d>>l;
    x=d/l;
    y=d%l;
    z=x+y;
    cout<<z<<endl;
     
    return 0;
}


Measured memory_bytes: 3116
def main():
    N, K = map(int, input().split())
    m = ((N-1)*(N-2)//2)
    if m < K:
        print(-1)
        return
    g = []
    for i in range(N-1):
        g.append((N, i+1))
    e = []
    for i in range(N-1):
        for j in range(i):
            e.append((i+1, j+1))
    print(N - 1 + m - K)
    for ans in (g + e[:(m-K)]):
        print('{} {}'.format(*ans))

main()


Measured memory_bytes: 3732
#include<iostream>
#include<algorithm>
using namespace std;
static const int N=100;

int main(){
	int n,p[N+1],m[N+1][N+1];
	cin>>n;
	for(int i=1;i<=n;i++){
		cin>>p[i-1]>>p[i];
	}

	for(int i=1;i<=n;i++)	m[i][i]=0;
	for(int l=2;l<=n;l++){
		for(int i=1;i<=n-l+1;i++){
			int j=i+l-1;
			m[i][j]=(1<<21);
			for(int k=i;k<=j;k++){
				m[i][j]=min(m[i][j],m[i][k]+m[k+1][j]+p[i-1]*p[k]*p[j]);
			}
		}
	}
	cout<<m[1][n]<<endl;

	return 0;
}

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

typedef long long ll;

#define INF 10e10
#define rep(i,n) for(int i=0; i<n; i++)
#define rep_r(i,n,m) for(int i=m; i<n; i++)
#define END cout << endl
#define MOD 1000000007
#define pb push_back
// 昇順sort
#define sorti(x) sort(x.begin(), x.end())
// 降順sort
#define sortd(x) sort(x.begin(), x.end(), std::greater<int>())

/* Union-Find-Tree */
class Union_Find {
public:
  vector<long long> par;
  vector<long long> rnk;

  Union_Find (long long n) {
    // par.resize(n), rnk.resize(n);
    for (int i = 0; i < n; ++i) {
      par.pb(i);
      rnk.pb(0);
    }
  }

  // 木の根を求める
  int find(int x) {
    if (par[x] == x)
    return x;
    else
    return par[x] = find(par[x]);
  }

  // xとyの属する集合を併合
  void unite(int x, int y) {
    x = find(x);
    y = find(y);
    if (x == y) return;

    if (rnk[x] < rnk[y]) {
      par[x] = y;
    } else {
      par[y] = x;
      if (rnk[x] == rnk[y]) rnk[x]++;
    }
  }

  // xとyが同じ集合に属するか否か
  bool same(int x, int y) {
    return find(x) == find(y);
  }
};

int main() {
  ll n, k, l; scanf("%lld %lld %lld", &n, &k, &l);
  Union_Find road(n), train(n);

  rep(i,k) {
    int t,s; scanf("%d %d", &t, &s);
    t--, s--;
    if (!road.same(t,s)) road.unite(t,s);
  }

  rep(i,l) {
    int t,s; scanf("%d %d", &t, &s);
    t--, s--;
    if (!train.same(t,s)) train.unite(t,s);
  }

  vector<pair<int, int> > com(n);
  map<pair<int, int>, int> s;
  rep(i,n) {
    com[i].first = road.find(i);
    com[i].second = train.find(i);
    s[com[i]]++;
  }

  rep(i,n) {
    printf("%d ",s[com[i]]);
  }
  END;
}


Measured memory_bytes: 21988
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <climits>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <string>
#include <list>
#include <ctime>
#include <complex>
#include <bitset>
#include <tuple>
#define MAXN 100000
using namespace std;

typedef long long int lli;

struct strt{
    int v, cost;
    bool operator<(const strt& st)const{
        return cost < st.cost;
    }
    bool operator>(const strt& st)const{
        return cost > st.cost;
    }
};
int N, M, dist[MAXN], pre[MAXN];
vector<int> G[MAXN];
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cin >> N >> M;
    for(int j = 0; j < M; ++j){
        int a, b; cin >> a >> b;
        a--; b--;
        G[a].push_back(b);
        G[b].push_back(a);
    }
    for(int j = 0; j < N; ++j){
        dist[j] = -1;
        pre[j] = -1;
    }
    dist[0] = 0;
    priority_queue<strt, vector<strt>, greater<strt>> pq;
    pq.push({0, 0});
    while(!pq.empty()){
        strt t = pq.top(); pq.pop();
        
        for(int j = 0; j < G[t.v].size(); ++j){
            int u = G[t.v][j];
            if(dist[u] == -1 || dist[u] > dist[t.v] + 1){
                dist[u] = dist[t.v] + 1;
                pre[u] = t.v;
                pq.push({u, dist[u]});
            }
        }
    }
    bool pos = true;
    for(int j = 1; j < N; ++j)
        if(pre[j] == -1)
            pos = false;
    if(!pos){
        cout << "No";
        return 0;
    }
    cout << "Yes\n";
    for(int j = 1; j < N; ++j)
        cout << pre[j] + 1 << "\n";
    return 0;
}

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

string S, T;
string letter[] = {"dream", "dreamer", "erase", "eraser"};

int main() {
    cin >> S;
    T = "";

    reverse(S.begin(), S.end());
    rep(i,4) reverse(letter[i].begin(), letter[i].end());

    int flag = 1;
    for (int i = 0; i < S.size();){
        int flag2 = 1;
        rep(j,4){
            string str = letter[j];
            if (S.substr(i,str.size()) == str) {
                flag2 = 0;
                i += letter[j].size();
            }
        }
        if (flag2) {
            flag = 0;
            break;
        }
    }

    string ans = flag ? "YES" : "NO";
    cout << ans << endl;
}

Measured memory_bytes: 512
#include<iostream>
#include<string>

using namespace std;


int main(int argc, char const *argv[])
{
    string gu;

    cin>>gu;

    bool tes=false;

    
    while(!tes){
        gu.pop_back();
        gu.pop_back();

        for(int i=0;i<gu.size()/2;++i){
            if(gu[i]!=gu[gu.size()/2+i]){
                break;
            }else if(gu[i]==gu[gu.size()/2+i]&&i==gu.size()/2-1){
                tes=true;
            }
        }

    }

    cout<<gu.size()<<endl;
    

    return 0;
}


Measured memory_bytes: 256
#pragma region cp-helper
#include <bits/stdc++.h>
using namespace std;
#define AC ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define ll long long
#define ull unsigned long long
#define ii pair<int, int>
#define lll pair<ll, ll>
#define vi vector<int>
#define vvi vector<vi>
#define vl vector<ll>
#define vll vector<lll>
#define vvl vector<vl>
#define vii vector<ii>
#define all(a) a.begin(), a.end()
#define qsort(a) sort(all(a))
#define qsortd(a) sort(all(a), greater<>())
#define qsortf(a, f) sort(all(a), f)
#define pb(n) push_back(n)
#define eb(n) emplace_back(n)
#define pp(a, b) emplace_back(a, b)
#define umap unordered_map
#define uset unordered_set
#define nl '\n'
#define fileio(in, out) freopen(in, "r", stdin); freopen(out, "w", stdout)
#define qmod %mod
#define pls int
#define give main()
const int mod = 1000000007;
#pragma endregion
const int N = 200005;

pls give {
    AC;
    int h, n, total=0, a;
    cin >> h >> n;
for (int i=0; i<n; i++) {
    cin >> a;
    total += a;
}
if (total >= h) cout << "Yes";
else cout << "No";
}

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

using namespace std;

typedef long long ll;
typedef pair<int,int> pii;

#define fi first
#define se second
#define mp make_pair
#define fastIO ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);


int n,m,q;
int a[50],b[50],c[50],d[50];
int ans = 0;

void brute(vector<int> rec){
  if(rec.size() == n){
    int cur = 0;
    for(int t = 0; t < q; t ++ ){
      cur += d[t]*(rec[b[t]]-rec[a[t]]==c[t]);
    }
    ans=max(ans,cur);
    return;
  }
  if(rec.empty())
    for(int j = 1; j <= m; j ++ ){
      rec.push_back(j);
      brute(rec);
      rec.pop_back();
    }
  else{
    for(int j = rec.back(); j <= m ; j ++ ){
      rec.push_back(j);
      brute(rec);
      rec.pop_back();
    }
  }
}

int main(){
  fastIO;
  cin >> n >> m >> q;
  for(int i = 0 ; i < q; i ++ ){
    cin >> a[i] >> b[i] >> c[i] >> d[i];
    a[i]--;
    b[i]--;
  }
  brute({});
  cout << ans << "\n";
  return 0;
}


Measured memory_bytes: 3660
use std::io::{self, BufRead, BufWriter, Write};

fn solve<R, W>(reader: R, mut writer: W)
where
    R: BufRead,
    W: Write,
{
    let mut lines = reader.lines();
    let a_line = lines.next().unwrap().unwrap();
    let mut splited = a_line.trim().split_whitespace();
    let _: i32 = splited.next().unwrap().parse().unwrap();
    let mut x: i32 = splited.next().unwrap().parse().unwrap();

    let a_line = lines.next().unwrap().unwrap();
    let mut splited = a_line.trim().split_whitespace();
    let mut a: Vec<i32> = splited.map(|s| s.parse().unwrap()).collect();

    a.sort();

    let mut ans = 0;
    for i in a {
        x -= i;
        if x < 0 {
            break;
        }
        ans += 1;
    }
    if x > 0 {
        ans -= 1;
    }

    writeln!(&mut writer, "{}", ans).unwrap();
}

fn main() {
    let stdio = io::stdin();
    let input = stdio.lock();

    let stdout = io::stdout();
    let output = BufWriter::new(stdout.lock());

    solve(input, output);
}

#[cfg(test)]
mod tests {
    use super::*;

    const TESTS: &'static [(&'static [u8], &'static [u8])] = &[
        (
            br"3 70
20 30 10", br"2
",
        ),
        (
            br"3 10
20 30 10", br"1
",
        ),
        (
            br"4 1111
1 10 100 1000", br"4
",
        ),
        (
            br"2 10
20 20", br"0
",
        ),
    ];

    #[test]
    fn test_a() {
        for &(input, expected) in TESTS {
            let mut output = Vec::new();
            solve(input, &mut output);
            let expected_str = String::from_utf8(expected.to_vec()).unwrap();
            let output_str = String::from_utf8(output).unwrap();
            assert_eq!(expected_str, output_str);
        }
    }
}


Measured memory_bytes: 4352
#include<bits/stdc++.h>
using namespace std; //std::の省略のため
using ll = long long;

int main(){

    ll n,a;
    int x,y,z;
    cin >> n;
    vector<int> f(n);

    int i=0;

    while(i<n){
        f[i] = 0;
        for(x=1; x<=sqrt(i+1); x++){
            for(y=1; y<=sqrt(i+1); y++){
                for(z=1; z<=sqrt(i+1); z++){
                        a = x*x + y*y + z*z + x*y + y*z + z*x;
                        if(a == i+1) f[i]++;   
                        if(a > i+1) break;  
                }
            }
        }

        cout << f[i] << endl;
        i++;
    }

    return 0;
}

Measured memory_bytes: 3704
#include<iostream>
#include<math.h>
using namespace std;
int main()
{
	long int n,sum=0,a,b;
	cin>>n;
	b=n;
	while(n>0)
	{
		a=n%10;
		sum+=a;
		n=n/10;
	}
	if(b%sum==0)
	{
		cout<<"Yes"<<endl;
	}
	else
	{
		cout<<"No"<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void){
    int a,b;
    scanf("%d%d",&a,&b);
    if(a==b){
        printf("a == b\n");
    }
    else if(a<b){
        printf("a < b\n");
    }
    else{
        printf("a > b\n");
    }
    return 0;
}
 

Measured memory_bytes: 580
#include<cstdio>
#include<algorithm>
#include<iostream>
#include<string>
#include<math.h>
#include<cstring>
using namespace std;
string s[200005];
bool cmp(string a,string b)
{
    return a.compare(b)<0;
}
int main()
{
    int n;
    int i;
    scanf("%d",&n);
    for(i=0;i<n;i++)
        cin>>s[i];
    sort(s,s+n,cmp);
    int con=1;
    int y=1;
    for(i=1;i<n;i++)
    {
        if(s[i].compare(s[i-1])==0)
            con++;
        else
            con=1;
        y=max(con,y);
    }
    con=1;
    if(y==1)cout<<s[0]<<endl;
    for(i=1;i<n;i++)
    {
        if(s[i].compare(s[i-1])==0)
            con++;
        else
            con=1;
        if(con==y)
        cout<<s[i]<<endl;
    }
    return 0;
}


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

int main()
{
    string S;
    cin >> S;
    long long n = S.size();
    long long res = 0;
    long long num = 0;
    for (long long i = 0; i < n; ++i)
    {
        if (S[i] == 'W')
        {
            res += num;
        }
        else
        {
            ++num;
        }
    }
    cout << res << endl;
}

Measured memory_bytes: 3752
#include<iostream>
using namespace std;
int main()
{
	int a,b,c,t;
	cin>>a>>b>>c;
	if(a>b)
	{
	t=a;a=b;b=t;	
	}
	if(a>c)
	{
		t=a;a=c;c=t;
	}
	if(b>c)
	{
		t=b;b=c;c=t;
	}
	cout<<a<<" "<<b<<" "<<c<<endl;
	return 0;
}



Measured memory_bytes: 3108
def getN():
    return int(input())
def getNM():
    return map(int, input().split())
def getList():
    return list(map(int, input().split()))
def getArray(intn):
    return [int(input()) for i in range(intn)]
def input():
    return sys.stdin.readline().rstrip()

from collections import defaultdict, deque, Counter
from sys import exit
import heapq
import math
from fractions import gcd
import copy
from itertools import permutations
from operator import mul
from functools import reduce
from bisect import bisect_left, bisect_right

import sys
sys.setrecursionlimit(1000000000)
mod = 10 ** 9 + 7

from itertools import permutations
from math import factorial, hypot

#############
# Main Code #
#############

N = getN()
top = getList()
middle = getList()
bottom = getList()

top.sort()
middle.sort()
bottom.sort()

# i未満
on_mid = [0]
for i in range(N):
    index_mid = bisect_left(top, middle[i])
    on_mid.append(on_mid[i] + index_mid)

ans = 0
for j in range(N):
    index_bot = bisect_left(middle, bottom[j])
    # on_midの最初の0を取り除いてないのでインデックスが一つずれる
    ans += on_mid[index_bot]
print(ans)

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

long long primeFactors(int n)
{
    while(n%2==0)
    {
        cout<<" "<<2;
        n=n/2;
    }
    for(int i=3;i<=sqrt(n);i=i+2)
    {
        while(n%i==0)
        {
            cout<<" "<<i;
            n=n/i;
        }
    }
    if(n>2)
    {
        cout<<" "<<n;
    }
    cout<<endl;
}

int main()
{
    long long n;
    cin>>n;
    cout<<n<<":";
    primeFactors(n);
    return 0;
}

Measured memory_bytes: 1168
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define ull unsigned long long int
#define pb push_back
#define faster ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define mem(ara,n) memset(ara,n,sizeof(ara))
#define memb(ara) memset(ara,false,sizeof(ara))
#define all(x) (x).begin(),(x).end()
#define fr freopen("input.txt","r",stdin);
#define fw freopen("output.txt","w",stdout);
const double PI  =3.141592653589793238463;


int main()
{
    faster;
    ll a,b,c,d,e,f=0,ans=0,sum=0,m,n,p,q,r,t,w,x,y,z;
    string s;
    cin>>a>>b>>x;
    if(a==0){
        ans=(b/x)+1;
    cout<<ans<<endl;
    }
    else{
        m=(b/x);
        n=(a-1)/x;
        ans=m-n;
        cout<<ans<<endl;
    }
    return 0;
}







Measured memory_bytes: 384
#include <stdio.h>
#include <algorithm>
#include <assert.h>
#include <bitset>
#include <cmath>
#include <complex>
#include <deque>
#include <functional>
#include <iostream>
#include <limits.h>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <time.h>
//#include <unordered_map>
//#include <unordered_set>
#include <vector>

#pragma warning(disable:4996)
#pragma comment(linker, "/STACK:336777216")

using namespace std;

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

//typedef tuple<int, int, int> t3;
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ldb;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef pair <db, db> pdd;

const int INF = 0x3f3f3f3f;

int cnt[20];
int in[200050];
int main() {
	int N, i, j;
	scanf("%d", &N);
	for (i = 1; i <= N; i++) scanf("%d", &in[i]);

	ll ans = 0;
	int p = 0;
	for (i = 1; i <= N; i++) {
		while (p < N) {
			for (j = 0; j < 20; j++) {
				if (!cnt[j]) continue;
				if (in[p + 1] & (1 << j)) break;
			}
			if (j < 20) break;
			for (j = 0; j < 20; j++) if (in[p + 1] & (1 << j)) cnt[j]++;
			p++;
		}
		ans += p - i + 1;

		for (j = 0; j < 20; j++) if (in[i] & (1 << j)) cnt[j]--;
	}
	return !printf("%lld\n", ans);
}

Measured memory_bytes: 1024
//Author: Fuadul Hasan(fuadul202@gmail.com)
#include<bits/stdc++.h>
using namespace std;

#define ll long long
const int N   = 2e5 + 5;

int main(){
	
	int n;
	cin>>n;
	int a[n];
	for(int i =0;i<n;i++){
		cin>>a[i];
	}	

	sort(a,a+n);
	ll sum = 0;
	for(int i=0;i<n-1;i++){
		sum += (ll)a[i];
	}

	//cout<<sum<<endl;
	if(sum > a[n-1]){
		cout<<"Yes"<<endl;
	}else{
		cout<<"No"<<endl;
	}


	

	return 0;
}

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

int main(){
  int N; cin>>N;
  vector<int> ans(110);
  int a; bool fl=false;
  for(int i=0;i<N;i++){
    cin>>a;
    if(a>i+1){
      fl=true;
      break;
    }
    for(int j=105;j>=a;j--){
      ans[j]=ans[j-1];
    }
    ans[a-1]=a;
  }
  if(fl)
    cout<<"-1";
  else{
    for(int i=0;i<N;i++){
      cout<<ans[i]<<endl;
    }
  }
}

Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#include<algorithm>
using namespace std;
typedef long long ll;
const int maxn=5*1e4+10;
char s[maxn],a[maxn],b[maxn];
int main()
{
    char str[10];
    scanf("%s",str);
    if(str[2]==str[3]&&str[4]==str[5])
        cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    return 0;
}



Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>
#include <string.h>
#include <stdlib.h>
#include <time.h>

#define GYOU_MAX 256
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define s_pri(str) printf("%s\n",str);
#define PRINT(str) printf(#str "\n")
#define v_pri(val) printf("%d\n",val);
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define MIN(a, b) ((a) < (b) ? (a) : (b))
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define pi acos(-1.0)
#define sca(x) scanf("%d",&x);

typedef long long int ll;

/*
puts("aa");
//*/

int cmp(const void *a, const void*b) {
	return *(int*)b - *(int*)a;
}
int main(void) {




		int H, N;
		sca(H);
		sca(N);

		int A[100000];
		int sum = 0;
		rep(i, N) {
			sca(A[i]);
			sum += A[i];
		}
		if (sum >= H) {
			s_pri("Yes");
		}
		else {
			s_pri("No");
		}



	return 0;
}



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

long long dfs(long long num, long long n){
    if(num <= n){
    long long res=0;
    string s = to_string(num);
    if(s.find("3")+1 && s.find("5")+1 && s.find("7")+1){
        res = 1;
    }
    res += dfs(num*10+3,n);
    res += dfs(num*10+5,n);
    res += dfs(num*10+7,n);
    return res;
    }
    else{
        return 0;
    }
}

int main(){
    long long n,ans;
    cin >> n;
    ans = dfs(0,n);

    cout << ans<<endl;
}

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

int main()
{
    int H, W, h, w;
    cin >> H >> W;
    cin >> h >> w;

    cout << H * W - (h * W + H * w - h * w) << endl;

    return 0;
}

Measured memory_bytes: 256
//==========//============================================================================
// Name        : Hello5.cpp
// Author      :
// Version     :
// Copyright   : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================

#include <iostream>
#include <vector>
#include <bits/stdc++.h>
#include <numeric>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using p = pair<int,int>;//<key,value>


int main() {

	 int a, b;
	  cin >> a >> b;
	  int ans = a+b;
	  ans = max(ans, a-b);
	  ans = max(ans, a*b);
	  cout << ans << endl;
return 0;
}







Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int n,m,ans;
char mp[25][25];
bool bj[25][25];
struct node{
	int x,y,dis;
};
int fx[4][2]={{0,1},{1,0},{-1,0},{0,-1}};
void bfs(int nx,int ny){
	if(mp[nx][ny]=='#')return ;
	memset(bj,false,sizeof(bj));
	queue<node>q;
	q.push((node){nx,ny,0});
	bj[nx][ny]=1;
	while(!q.empty()){
		node now=q.front();
		q.pop();
//		cout<<now.x<<" "<<now.y<<endl;
		ans=max(ans,now.dis);
		for(int i=0;i<4;++i){
			int vx=now.x+fx[i][0],vy=now.y+fx[i][1];
			if(vx<=0||vx>n||vy<=0||vy>m||mp[vx][vy]=='#'||bj[vx][vy])continue;
			q.push((node){vx,vy,now.dis+1});
			bj[vx][vy]=true;
		}
	}
}
int main(){
	scanf("%d %d",&n,&m);
	for(int i=1;i<=n;++i)scanf("%s",mp[i]+1);
	for(int i=1;i<=n;++i)for(int j=1;j<=m;++j)bfs(i,j);
	cout<<ans;
	return 0;
}

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

using namespace std;

int len_lcs[3005][3005];
string s,t;

string backtrack(int i, int j){
	string ans;
	if(i==0 or j==0)
		ans="";
	else if(len_lcs[i][j]>max(len_lcs[i-1][j], len_lcs[i][j-1]))
		ans = s[i-1] +  backtrack(i-1,j-1);
	else if(len_lcs[i-1][j]>len_lcs[i][j-1])
		ans = backtrack(i-1,j);
	else
		ans = backtrack(i,j-1);
	return ans;

}

int main(){

	cin >> s >> t;
	for(int i=1;i<=s.length();i++){
		for(int j=1;j<=t.length();j++){
			len_lcs[i][j] = max(len_lcs[i-1][j],len_lcs[i][j-1]);
			if(s[i-1]==t[j-1])
				len_lcs[i][j] = max(len_lcs[i-1][j-1]+1, len_lcs[i][j]);
		}
	}

	// backtrack
	string ans = backtrack(s.length(), t.length());
	reverse(ans.begin(), ans.end());
	cout << ans;

}

Measured memory_bytes: 35840
#include<stdio.h>
#include<algorithm>
using namespace std;

typedef long long ll;

ll N,M;
ll ans = 0;

int main()
{
    scanf("%lld%lld",&N,&M);
    for(ll i = 1; i * i <= M; i++)
    {
        if(M % i)continue;
        if(i * N <= M)ans = max(ans,i);
        if((M / i) * N <= M)ans = max(ans,M / i);
    }

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


Measured memory_bytes: 128
import sys
input = sys.stdin.readline
# sys.setrecursionlimit(100000)


class Solver(object):
    def __init__(self):
        pass

    def solve(self):
        pass


def main():
    N = input().strip()
    if "7" in N:
        return "Yes"
    else:
        return "No"


if __name__ == "__main__":
    print(main())


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


int main() {

	int n;
	string s;
	cin >> n >> s;

	int ans = 1;

	rep(i, n-1) {
		if (s[i + 1] != s[i])ans++;
	}
	
	cout << ans;
}

Measured memory_bytes: 512
using System;
using System.Linq;
public class Hello{
    public static void Main(){
        // Your code here!
        
        var a = Console.ReadLine().Split().Select(x => int.Parse(x)).ToArray();
        int n = a[0] + a[1] + a[2];
        
        if(n<=21){
            Console.WriteLine("win");
        }else{
            Console.WriteLine("bust");
        }
        
    }
}


Measured memory_bytes: 13268
#include<bits/stdc++.h>
#define llong long long
#define mkpr make_pair
#define x first
#define y second
#define iter iterator
#define riter reverse_iterator
#define y1 Lorem_ipsum_
#define tm dolor_sit_amet_
using namespace std;

inline int read()
{
	int x = 0,f = 1; char ch = getchar();
	for(;!isdigit(ch);ch=getchar()) {if(ch=='-') f = -1;}
	for(; isdigit(ch);ch=getchar()) {x = x*10+ch-48;}
	return x*f;
}

struct Complex
{
	double x,y;
	Complex() {}
	Complex(double _x,double _y) {x = _x,y = _y;}
};
Complex operator +(Complex x,Complex y) {return Complex(x.x+y.x,x.y+y.y);}
Complex operator -(Complex x,Complex y) {return Complex(x.x-y.x,x.y-y.y);}
Complex operator *(Complex x,Complex y) {return Complex(x.x*y.x-x.y*y.y,x.y*y.x+x.x*y.y);}
namespace FFT
{
	const int N = 1<<20;
	const int lgN = 20;
	const double PI = acos(-1);
	int fftid[N+3];
	Complex sexp[N+3];
	Complex tmp1[N+3],tmp2[N+3];
	int getdgr(int n) {int ret = 1; while(ret<=n) ret<<=1; return ret;}
	void init_fftid(int dgr)
	{
		int len = 0; for(int i=1; i<=lgN; i++) {if(dgr==(1<<i)) {len = i; break;}}
		fftid[0] = 0; for(int i=1; i<dgr; i++) fftid[i] = (fftid[i>>1]>>1)|((i&1)<<(len-1));
	}
	void fft(int dgr,int coe,Complex poly[],Complex ret[])
	{
		init_fftid(dgr);
		if(poly!=ret) {for(int i=0; i<dgr; i++) ret[fftid[i]] = poly[i];}
		else {for(int i=0; i<dgr; i++) {if(i<fftid[i]) swap(ret[i],ret[fftid[i]]);}}
		for(int i=1; i<=(dgr>>1); i<<=1)
		{
			Complex tmp(cos(PI/i),coe*sin(PI/i));
			sexp[0] = Complex(1,0); for(int j=1; j<i; j++) {sexp[j] = sexp[j-1]*tmp;}
			for(int j=0; j<dgr; j+=(i<<1))
			{
				Complex *expn=sexp;
				for(Complex *k=ret+j; k<ret+i+j; k++,expn++)
				{
					Complex x = (*k),y = (k[i])*(*expn);
					(*k) = x+y; k[i] = x-y;
				}
			}
		}
		if(coe==-1) {for(int i=0; i<dgr; i++) ret[i].x/=dgr,ret[i].y/=dgr;}
	}
}

const int mxN = 1<<20;
const int P = 2e5+3;
const int G = 2;
llong a[mxN+3],b[mxN+3]; Complex a1[mxN+3];
llong pw[P+3],l[P+3];
int n;

int main()
{
	for(int i=0,x=1; i<P-1; i++,x=1ll*x*G%P) {pw[i] = x,l[x] = i;}
	n = read(); llong ans = 0ll;
	for(int i=1; i<=n; i++) {int x = read(); if(x) {a[l[x]]++;} ans -= 1ll*x*x%P;}
	int dgr = FFT::getdgr(P);
	for(int i=0; i<P; i++) a1[i] = (Complex){a[i],0};
	FFT::fft(dgr<<1,1,a1,a1);
	for(int i=0; i<(dgr<<1); i++) a1[i] = a1[i]*a1[i];
	FFT::fft(dgr<<1,-1,a1,a1);
	for(int i=0; i<(dgr<<1); i++)
	{
		b[i%(P-1)] += (llong)(a1[i].x+0.5);
	}
	for(int i=0; i<P-1; i++) {ans += (b[i])*pw[i];}
	printf("%lld\n",ans/2);
	return 0;
}

Measured memory_bytes: 24660
#include<stdio.h>
#include<algorithm>
using namespace std;
int dat[20][20];
int m,n;
int gx,gy;
int dfs(int a,int b,int c){
	if(a==10)return -1;
	int ret=999999;
	if(b&&dat[b-1][c]!=1){
		for(int i=b-1;i>=0;i--){
			if(dat[i][c]==1){
				dat[i][c]=0;
				int p=dfs(a+1,i+1,c);
				if(~p)ret=min(ret,p);
				dat[i][c]=1;
				break;
			}else if(dat[i][c]==3){
				return a+1;
			}
		}
	}
	if(b<m-1&&dat[b+1][c]!=1){
		for(int i=b+1;i<m;i++){
			if(dat[i][c]==1){
				dat[i][c]=0;
				int p=dfs(a+1,i-1,c);
				if(~p)ret=min(ret,p);
				dat[i][c]=1;
				break;
			}else if(dat[i][c]==3){
				return a+1;
			}
		}
	}
	if(c&&dat[b][c-1]!=1){
		for(int i=c-1;i>=0;i--){
			if(dat[b][i]==1){
				dat[b][i]=0;
				int p=dfs(a+1,b,i+1);
				if(~p)ret=min(ret,p);
				dat[b][i]=1;
				break;
			}else if(dat[b][i]==3){
				return a+1;
			}
		}
	}
	if(c<n-1&&dat[b][c+1]!=1){
		for(int i=c+1;i<n;i++){
			if(dat[b][i]==1){
				dat[b][i]=0;
				int p=dfs(a+1,b,i-1);
				if(~p)ret=min(ret,p);
				dat[b][i]=1;
				break;
			}else if(dat[b][i]==3){
				return a+1;
			}
		}
	}
	if(ret==999999)return -1;
	return ret;
}
int main(){
	int a,b;
	while(scanf("%d%d",&b,&a),a+b){
		int sx=0,sy=0;
		m=a;
		n=b;
		for(int i=0;i<a;i++){
			for(int j=0;j<b;j++){
				scanf("%d",&dat[i][j]);
				if(dat[i][j]==2){
					sx=i;
					sy=j;
				}
				if(dat[i][j]==3){
					gx=i;
					gy=j;
				}
			}
		}
		printf("%d\n",dfs(0,sx,sy));
	}
}

Measured memory_bytes: 0
#include <stdio.h>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <list>
#include <iterator>
#include <assert.h>
#pragma warning(disable:4996) 

typedef long long ll;
#define MIN(a, b) ((a)>(b)? (b): (a))
#define MAX(a, b) ((a)<(b)? (b): (a))
#define LINF 9223300000000000000
#define INF 2140000000
const long long MOD = 1000000007;
using namespace std;

int main(int argc, char* argv[])
{
    int n;
    scanf("%d", &n);
    ll sum=0, min=INF, max=-INF;
    int i;
    for(i=0; i<n; i++) {
        int tmp;
        scanf("%d", &tmp);
        sum +=tmp;
        max = MAX(max,tmp);
        min = MIN(min,tmp);
    }
    printf("%lld %lld %lld\n", min, max, sum);
    return 0;
}



Measured memory_bytes: 2760
#include <stdio.h>

int main(void)
{
	int bloodVal[4] = {0};
	int num;
	char bloodType;
	
	while( scanf("%d,%c", &num, &bloodType) != EOF )
	{
		switch( bloodType )
		{
			case 'A':
				scanf("%c", &bloodType);
				if( bloodType == '\n' )
				{
					bloodVal[0]++;
				}
				else
				{
					bloodVal[2]++;
				}
				break;
			case 'B':
				bloodVal[1]++;
				break;
			case 'O':
				bloodVal[3]++;
				break;
		}
	}
	
	printf( "%d\n%d\n%d\n%d\n", bloodVal[0], bloodVal[1], bloodVal[2], bloodVal[3] );
	
	return (0);
}

Measured memory_bytes: 596
import java.util.LinkedList;
import java.util.Queue;
import java.util.Scanner;

public class Main implements Runnable {

    private static Scanner sc = new Scanner(System.in);

    public static void main(String[] args) {
        new Thread(null, new Main(), "", 128 * 1024 * 1024).start();
    }

    public void run() {
        int h = sc.nextInt(), w = sc.nextInt();
        boolean[][] s = new boolean[h][w];
        int[][] d = new int[h][w];
        int countInitialBlack = 0;
        for (int i = 0; i < h; i++) {
            String str = sc.next();
            for (int j = 0; j < w; j++) {
                s[i][j] = str.charAt(j) == '.';
                d[i][j] = -1;
                if (!s[i][j]) {
                    countInitialBlack++;
                }
            }
        }

        Queue<Point> queue = new LinkedList<>();
        Point start = new Point(0, 0);
        Point goal = new Point(h - 1, w - 1);
        int tmpX, tmpY;

        queue.offer(start);
        d[start.y][start.x] = 0;
        int[] dx = {1, 0, -1, 0}, dy = {0, 1, 0, -1};

        while (queue.size() > 0) {
            Point p = queue.poll();
            if (p.y == goal.y && p.x == goal.x) {
                break;
            }
            for (int i = 0; i < 4; i++) {
                tmpY = p.y + dy[i];
                tmpX = p.x + dx[i];

                if (0 <= tmpY && tmpY < h && 0 <= tmpX && tmpX < w
                    && s[tmpY][tmpX] && d[tmpY][tmpX] == -1) {
                    queue.offer(new Point(tmpY, tmpX));
                    d[tmpY][tmpX] = d[p.y][p.x] + 1;
                }
            }
        }

        int minWhiteCell = d[h - 1][w - 1] + 1;
        if (d[h - 1][w - 1] != -1) {
            System.out.println(h * w - countInitialBlack - minWhiteCell);
        } else {
            System.out.println(-1);
        }
    }
}

class Point {

    public Point(int y, int x) {
        this.y = y;
        this.x = x;
    }

    int y, x;
}

Measured memory_bytes: 27604
#include<iostream>

using namespace std;

int main(){
    int a,b,c;
    
    cin>>a>>b>>c;
    if(a>b && a>c) cout<<"A"<<endl;
    else if(b>a && b>c) cout<<"B"<<endl;
    else if(c>a && c>b) cout<<"C"<<endl;
    
    return 0;
}


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

int main(){
  double x1, y1, x2, y2, distance;
  cin>>x1>>y1>>x2>>y2;
  distance = sqrt(pow(x1-x2, 2) + pow(y1-y2, 2));
  printf("%.5f\n", distance);
  return 0;
}



Measured memory_bytes: 3200
#include<iostream>
#include<sstream>
#include<vector>
#include<iterator>
#include<queue>
using namespace std;

int main(void)
{
    int N, M;
    cin >> N >> M;

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

    priority_queue<int> que;
    for (int i = 0; i < N; i++)
        que.push(A[i]);

    for (int i = 0; i < M; i++) {
        int cost = que.top();
        que.pop();

        que.push(cost / 2);
    }

    long long ans = 0;
    while (que.empty() != true) {
        ans += que.top();
        que.pop();
    }

    cout << ans << endl;

    return 0;
}


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

int main(){
  int N,X,Y; cin >> N >> X >> Y;
  int count[2800];
  for(int i=1; i<=N-1; i++){
    for(int j=i+1; j<=N; j++){
      count[min(j-i,abs(X-i)+1+abs(Y-j))]++;
    }
  }
  
  for(int k=1; k<=N-1; k++) cout << count[k] << endl;
}

Measured memory_bytes: 256
var obj = init();
Main();
function nextInt(){return myconv(next(),1);}
function nextStrArray(){return myconv(next(),2);}//半角スペース分割
function nextIntArray(){return myconv(next(),4);}//半角スペース + 数値化
function nextCharArray(){return myconv(next(),6);}//1文字分割
function next(){return obj.next();}
function hasNext(){return obj.hasNext();}
function myin(){return require("fs").readFileSync("/dev/stdin", "utf8").trim().split("\n");}
function init(){
  var inputFile = myin();
  var returnObj = {
    "list" : inputFile, "index" : 0, "max" : inputFile.length,
    "hasNext" : function(){return (this.index < this.max);},
    "next" : function(){if(!this.hasNext()){throw "ArrayIndexOutOfBoundsException これ以上ないよ";}else{var returnInput = this.list[this.index];this.index++;return returnInput;}}
  };
  return returnObj;
}
function myout(t){console.log(t);}//標準出力
function myerr(t){console.error(t);}//標準エラー出力
//[no]要素の扱い。数値型
//不明値、異常時:引数そのまま返す　1:数値へ変換
//2:半角SPで分割 4:半角SPで分割し、数値配列へ
//6:1文字で分割  7:1文字で分割し、数値配列へ
//8:半角SPで結合 9:改行で結合 0:文字なしで結合
function myconv(i,no){try{switch(no){case 1:return parseInt(i);case 2:return i.split(" ");case 4:return i.split(" ").map((a)=>Number(a));case 6:return i.split("");case 7:return i.split("").map((a)=>Number(a));case 8:return i.join(" ");case 9:return i.join("\n");case 0:return i.join("");default:return i;}}catch(e){return i;}}
function Main(){
  var N = nextInt();
	var keys = new Set();
	for(var i = 0; i < N; i++){
		var tmp = next();
		keys.add(tmp);
	}
	myout(keys.size);
	myerr(keys);
}


Measured memory_bytes: 96924
#include <bits/stdc++.h>
#pragma GCC optimize("unroll-loops,no-stack-protector")
#pragma GCC target("sse,sse2,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define watch(x) cout << (#x) << " is " << (x) << endl
#define debug cout << "hi" << endl

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;

ll gcd(ll a, ll b) {return (!b ? a : gcd(b, a % b));}
ll lcm(ll a, ll b) {return ((a*b)/gcd(a,b));}
bool cmp(int a,int b){return a>b;}

const ll mod = 1e9 + 7;
const int INF32 = 1<<30;
const ll INF64 = 1LL<<60;
const ld pi = 3.141592653589793;
const int N = 1e6 + 10;

long long modpow(long long n, long long k, long long mod)
{
if (k == 0) return 1;
long long r = modpow(n * n % mod, k >> 1, mod);
if (k & 1) r = r * n % mod;
return r;
}

void solve(){
    ll x,k,d;
    cin >> x >> k >> d;
    x = abs(x);
    ll c = x/d;
    if(k<=c){
        cout << x - (k*d);
        return;
    }
    k = k-c;
    if(k%2==0) cout << x%d;
    else cout << (d-x%d);
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);cout.tie(NULL);
    solve();
    return 0;
}

Measured memory_bytes: 3648
#include <stdio.h>
 
int main(){
 
    int n;		// 
  	int a;		// 
  	int b;		// 
  	int max;	// 
  	int min;	// 

    scanf("%d %d %d", &n, &a, &b);
 
  	if(a > b){
      max = b;
    }
    else{
	  max = a;
    }

    min = n - a - b;
  	if(min > 0){
    	min = 0;
    }
  	else{
        min *= -1;
    }
	 
    printf("%d %d", max, min);    
}

Measured memory_bytes: 128
#include <iostream>
#include <algorithm>
#include <math.h>
#include <stdio.h>
using namespace std;

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

    if(n<1200){
        cout<<"ABC"<<endl;
    }
    else{
        cout<<"ARC"<<endl;
    }
    return 0;
}


Measured memory_bytes: 256