akhauriyash/Code-Regression huggingface dataset:
import java.util.*;

class Main {
    public static void main(String[] args) {
        new Solver().run();
    }
}

class Solver {

    public void run() {
        Scanner sc = new Scanner(System.in);
        char[] S = sc.next().toCharArray();
        int[] A = new int[4];

        for (int i = 0; i < 4; i++) {
            A[i] = S[i] - '0';
        }

        for (int bit = 0; bit < (1 << 3); bit++) {
            List<Character> list = new ArrayList<Character>();

            //System.out.println(String.format("%4s",Integer.toBinaryString(bit)));
            int k = 0;
            int sum = A[0];
            for (int i = 0; i < 3; i++, k++) {
                //System.out.println("\t" + String.format("%4s", Integer.toBinaryString((1 << i))) + " ");
                if ((bit & (1 << i)) > 0) {
                    sum += A[i+1];
                    list.add('+');
                } else {
                    sum -= A[i+1];
                    list.add('-');
                }
            }

            //for (Character c : list) System.out.print(c);
            //System.out.println(" "+ sum);
            if (sum == 7) {
                StringBuilder sb = new StringBuilder();
                sb.append(S[0]);
                for (int i = 0; i < 3; i++) {
                    sb.append(list.get(i));
                    sb.append(S[i + 1]);
                }
                sb.append("=7");
                System.out.println(sb.toString());
                return;
            }

        }

        return;
    }

}

Measured memory_bytes: 21844
#include <stdio.h>
#include <string.h>
int main()
{
    char a[100],b[100],c[100];
    int i,j,k,t,r;
    gets(a);gets(b);
    {
    k=strlen(a);t=strlen(b);
    if(k==t) r=0;
    else r=1;
    j=0;
    for(i=0;a[i];i++)
    {
        c[j]=a[i];j+=2;
    }
    j=1;
    for(i=0;b[i];i++)
    {
        c[j]=b[i];j+=2;
    }
     c[j-1+r]='\0';
    puts(c);
    return 0;
}
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

int main() {
    ll x,k,d;
    cin >> x >> k >> d;
    if (x < 0) x = -x;
    if (x / d >= k) {
        cout << x - k * d << endl;
        return 0;
    }
    k -= x / d;
    x = x - (x / d) * d;
    if (k & 1) cout << d - x << endl;
    else cout << x << endl;
    return 0;
}

Measured memory_bytes: 3628
#include<iostream>
#include<cmath>
#include<cstdio>
using namespace std;

int main(){
  double x1, x2, y1, y2;
  cin >> x1 >> y1 >> x2 >>  y2;
  printf("%.7f\n", sqrt((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2)));

  return 0;
}


Measured memory_bytes: 3212
N, M = gets.split.map(&:to_i)
students = N.times.map { gets.split.map(&:to_i) }
check_points = M.times.map { gets.split.map(&:to_i) }

students.each do |sy, sx|
  point = -1
  min_dist = Float::INFINITY

  check_points.each.with_index(1) do |(cy, cx), i|
    dist = (sy - cy).abs + (sx - cx).abs

    if min_dist > dist
      point = i
      min_dist = dist
    end
  end

  puts point
end


Measured memory_bytes: 1788
#include <cstdio>
#include <vector>
#include <algorithm>
#include <unordered_map>
#include <string>
#include <cstdlib>
#include <iostream>
#include <cmath>

using namespace std;

int main() {
  long a, b, c, k;
  cin >> a >> b >> c >> k;
  long ans = k%2==0 ? a-b : b-a;
  cout << ans << endl;
}


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

int main(){
    string s,a(""),b("");
    cin >> s;

    rep(i,s.size()){
        if(i%2==0){
            a += '0';
            b += '1';
        }else{
            a += '1';
            b += "0";
        }
    }

    int sum_a(0),sum_b(0);
    rep(i,s.size()){
        if(a[i]==s[i]){
            sum_a++;
        }else{
            sum_b++;
        }
    }

    cout << s.size()-max(sum_a,sum_b) << endl;

    return 0;
}

Measured memory_bytes: 3968
/* This code is written by Nemlit */
#include<bits/stdc++.h>
using namespace std;
#define il inline
#define re register
#define debug printf("Now is Line : %d\n",__LINE__)
#define file(a) freopen(#a".in","r",stdin);freopen(#a".out","w",stdout)
#define rep(i, a, b) for(re int i = (a); i <= (b); ++ i)
#define drep(i, a, b) for(re int i = (b); i >= (a); -- i)
#define Next(i, u) for(re int i = head[u]; i; i = e[i].next)
#define mem(k, p) memset(k, p, sizeof(k))
#define int long long
#define D double
#define inf 1023456789
#define mod 1000000007
#define lb(x) (x)&(-(x))
il int read() {
    re int x = 0, f = 1; re char c = getchar();
    while(c < '0' || c > '9') { if(c == '-') f = -1; c = getchar();}
    while(c >= '0' && c <= '9') x = x * 10 + c - 48, c = getchar();
    return x * f;
}
il int Mul(int a, int b) { return 1ll * a * b % mod; }
il int Inc(int a, int b) { return (a += b) >= mod ? a - mod : a; }
il int Dec(int a, int b) { return (a -= b) < 0 ? a + mod : a; }
il int qpow(int a, int b) { int r = 1; while(b) { if(b & 1) r = Mul(r, a); a = Mul(a, a), b >>= 1; } return r; }
#define ls k * 2
#define rs k * 2 + 1
#define maxn 100005
namespace Graph {
	int head[maxn], cnt;
	struct edge { int v, next; }e[maxn << 1];
	il void add(int u, int v) { e[++ cnt] = (edge){v, head[u]}, head[u] = cnt; }
}
//using namespace Graph;
int n, m, ans, a[maxn];
char c[maxn];
signed main() {
	n = ans = read(), m = read();
	rep(i, 1, m) {
		int x = read();
		rep(j, 1, x) {
			int y = read();
			if(!a[y]) a[y] = 1, -- ans;
		}
	}
	cout << ans;
	return 0;
}

Measured memory_bytes: 3640
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define F first
#define S second
#define pii pair<int, int>
#define pli pair<ll, int>
#define pil pair<int, ll>
#define pll pair<ll, ll>
#define eb emplace_back
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep3(i, l, n) for (int i = l; i < (n); ++i)
#define sz(v) (int)v.size()
#define endl '\n'
const int inf = 1000000007;
const ll INF = 1e18;
// int mod = 998244353;
int mod = 1000000007;
const double eps = 1e-8;
#define abs(x) (x >= 0 ? x : -(x))
#define lb(v, x) (int)(lower_bound(all(v), x) - v.begin())
#define ub(v, x) (int)(upper_bound(all(v), x) - v.begin())
template<typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { if (a < b) { a = b; return 1; } return 0; }
ll gcd(ll a, ll b) { if (b == 0) return a; return gcd(b, a % b); }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
template<typename T, typename U> T pow_(T a, U b) { return b ? pow_(a * a, b / 2) * (b % 2 ? a : 1) : 1; }
ll modpow(ll a, ll b, ll _mod) { return b ? modpow(a * a % _mod, b / 2, _mod) * (b % 2 ? a : 1) % _mod : 1; }
template<class T, class U> ostream& operator << (ostream& os, const pair<T, U>& p) { os << p.F << " " << p.S; return os; }
template<class T> ostream& operator << (ostream& os, const vector<T>& vec) { rep(i, sz(vec)) { if (i) os << " "; os << vec[i]; } return os; }
template<class T> ostream& operator << (ostream& os, const set<T>& s) { for (auto si : s) os << si << " "; return os; }
template<typename T> inline istream& operator >> (istream& is, vector<T>& v) { rep(j, sz(v)) is >> v[j]; return is; }
template<class T, class T2> inline void add(T &a, T2 b) { (a += (b % mod + mod)) %= mod; }
template<class T> void operator += (vector<T>& v, vector<T> v2) { rep(i, sz(v2)) v.eb(v2[i]); }

void solve();

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cout << fixed << setprecision(12);
    int T;
    T = 1;
    while (T--) solve();
}

void solve() {
    int n, k;
    cin >> n >> k;
    vector<int> a(n);
    cin >> a;
    
    int cnt = 0;
    double ans = 0, tmp = 0;
    auto calc = [&](int i) { return (a[i] + 1) / 2.0; };
    rep(i, n) {
        if (cnt < k) {
            ++cnt;
            tmp += calc(i);
            if (cnt == k) chmax(ans, tmp);
        } else {
            tmp -= calc(i - k);
            tmp += calc(i);
            chmax(ans, tmp);
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 3960
#include <stdio.h>
#include <stdlib.h>
#include <math.h>

#define lli long long int
#define min(a,b) ((a)<(b)?(a):(b))
#define max(a,b) ((a)>(b)?(a):(b))
#define true 1
#define false 0



int main(void){
	int i;
	int n;
	lli t,a;
	lli mltt,mlta,mlt;
	lli anst,ansa;
	scanf("%d",&n);
	scanf("%lld%lld",&t,&a);
	anst = t;ansa = a;
	for(i=1;i<n;i++){
		scanf("%lld%lld",&t,&a);
		mlt = t < a ? anst / t : ansa / a;
		mltt = anst / t;
		if(anst % t)mltt++;
		mlta = ansa / a;
		if(ansa % a)mlta++;
		mlt = max(mltt,mlta);
		anst = t*mlt;ansa = a*mlt;
	}
	printf("%lld\n",anst + ansa );
	return 0;
}

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

typedef long long ll;

int main()
{
    int n;
    cin >> n;
    if(n%2==0)
        cout << n << endl;
    else
        cout << n * 2 << endl;
    return 0;
}


Measured memory_bytes: 256
#include <sstream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <iostream>
#include <utility>
#include <set>
#include <list>
#include <cctype>
#include <queue>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <iomanip>
#include <iterator> 
#include <limits>

#define REP(i,n) for (int i=0;i<(n);i++)
#define FOR(i,a,b) for (int i=(a); i<(b); i++)
#define ALL(a) (a).begin(),(a).end()
#define RALL(A) (a).rbegin(),(a).rend()
#define PB push_back
#define MP make_pair

#define dump(x) cerr << #x << " = " << (x) << endl;

using namespace std;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const int INF = numeric_limits<int>::max() / 2;
const int NEG_INF = numeric_limits<int>::min() / 2;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

int N, Q;

int pre(int x) {
    return (x + N - 2) / N;
}

int main(int argc, char const* argv[])
{
    cin >> N >> Q;
    REP(q, Q) {
        int v, w;
        cin >> v >> w;
        if (N == 1) {
            cout << min(v, w) << endl;
            continue;
        }
        while (v != w) {
            if (v < w) {
                w = pre(w);
            } else {
                v = pre(v);
            }
        }
        cout << v << endl;
    }
    return 0;
}


Measured memory_bytes: 1280
N = int(input())
S = input()
ans = 0
for i in range(1000):
    num = i
    a = num//100
    b = (num-a*100)//10
    c = num-a*100-b*10
    flag1,flag2 = False,False
    for j in range(N):        
        if not flag1 and not flag2 and S[j]==str(a):
            flag1 = True
            continue
        if not flag2 and flag1 and S[j]==str(b):
            flag2 = True
            continue
        if flag2 and S[j]==str(c):
            ans += 1
            break
print(ans)

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

int main() {
  int N, A, B;
  cin >> N >> A >> B;

  if (N * A < B) {
    cout << N * A << endl;
  }
  else if (N * A > B) {
    cout << B << endl;
  }
  else {
    cout << N * A << endl;
  }
}


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

#define _CRT_SECURE_NO_WARNINGS

#define REP(i, n) for(decltype(n) i = 0; i < (n); i++)
#define REP2(i, x, n) for(decltype(x) i = (x); i < (n); i++)
#define REP3(i, x, n) for(decltype(x) i = (x); i <= (n); i++)
#define RREP(i, n) for (decltype(n) i = (n) - 1; i >= 0; i--)

#define ALL(a) (a).begin(),(a).end()
#define SORT(c) sort((c).begin(),(c).end())
#define DESCSORT(c) sort(c.begin(), c.end(), greater<int>())

using namespace std;

const int INF = 1000000000;
const double PI = 3.1415926535897932384626433832795;

// N, E, S, W
const int dx[4] = { -1, 0,  1,  0 };
const int dy[4] = { 0, 1,  0, -1 };

using LL = long long int;
using LD = long double;
using pii = pair<int, int>;
using pdd = pair<double, double>;
using pll = pair<LL, LL>;
using vi = vector<int>;
using vd = vector<double>;
using vs = vector<string>;
using vvi = vector<vi>;
using vll = vector<LL>;

//==============================================
int n, tt = 0;
vvi M;
vi D, F, searchStatus;

// ??±???????????¢?´¢
void antDfs(int u) {
	searchStatus[u] = 1;

	// ?????????(??????)??????????????????
	D[u] = ++tt;
	REP3(i, 1, n) {
		if (M[u][i] == 0) continue;

		if (searchStatus[i] == -1) {
			antDfs(i);
		}
	}
	// ?????????(??????)???????????????
	F[u] = ++tt;

	// ??¢?´¢??????
	searchStatus[u] = 1;
}

void print() {
	REP3(i, 1, n) {
		cout << i << " " << D[i] << " " << F[i] << "\n";
	}
}

void solve() {

	REP3(i, 1, n) {
		if (searchStatus[i] == -1) {
			//????¨???????i????§??????¨????????±???????????¢?´¢?????????
			antDfs(i);
		}
	}

	// ??????
	print();
}

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

	cin >> n;
	
	M.resize(n + 1, vi(n + 1));
	D.resize(n + 1);
	F.resize(n + 1);

	// ??¢?´¢??¶??????????????? (?????¢?´¢)
	searchStatus.resize(n + 1, -1);

	
	int u, k, v;
	REP3(i, 1, n) {
		cin >> u >> k;
		REP3(j, 1, k) {
			cin >> v;
			M[u][v] = 1;
		}
	}

	solve();
	return 0;
}

Measured memory_bytes: 3252
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)

from collections import Counter

n, *a = map(int, read().split())
ans = 0
for k, v in Counter(a).items():
    if k > v:
       ans += v
    elif k < v:
        ans += v - k
print(ans)


Measured memory_bytes: 18392
import java.util.Scanner;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a;
        int b;
        int sum;
        int digits = 0;
        List<Integer> list = new ArrayList<>();
       
        while(sc.hasNext()) {
        	a = sc.nextInt();
        	b = sc.nextInt();
        	sum = a + b;
        	digits = 0;
        	//System.out.println(sum);
        	for(;sum>=1;sum=sum/10) {
            	digits = digits+1;
                }
            //System.out.println(digits);
        	list.add(digits);
        }
               
        for(Iterator it = list.iterator(); it.hasNext();) {
            System.out.println(it.next());
        }

        sc.close();
    }
} 

Measured memory_bytes: 26388
import fractions
import math
from collections import Counter
a, b = map(int, input().split())
n = fractions.gcd(a, b)

prime_count = Counter()
for i in range(2, math.ceil(math.sqrt(n))+1):
  while n % i == 0:
    n /= i
    prime_count[i] += 1
if n > 1:
  prime_count[int(n)] += 1

print(len(prime_count)+1)

Measured memory_bytes: 5044
#include <cstdio>
#include <cstring>
#include <iostream>
using namespace std;

const int maxn=1010;

char s[maxn];

int main()
{
	int len;
	
	scanf ("%s",s);
	len=strlen(s);
	if (s[len-1]!='s') printf("%ss\n",s);
	else printf("%ses\n",s);
	return 0;
 } 

Measured memory_bytes: 3828
#include<stdio.h>
#include<math.h>
#include<stdlib.h>
#include<algorithm>
using namespace std;
#define fo(i,a,b) for(int i=a;i<=b;i++)
#define fd(i,a,b) for(int i=a;i>=b;i--)
int n,a,ans;
int main(){
	scanf("%d",&n);
	ans=-n;
	fo(i,1,n){
		scanf("%d",&a);
		ans+=a;
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 128
# 2019/08/15

n=int(input())
s=input()
t=input()

def solve():
    for i in range(n):
        for j in range(n):
            if s[i]!=t[j]:continue
            m=s[i:]
            if m==t[:len(m)]:
                res=len(s[:i])+n
                return res
ans=solve()
if ans:print(ans)
else:print(2*n)

Measured memory_bytes: 3060
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
        String s = sc.next();
        String t = sc.next();

        System.out.println(solve(s, t));

    }

	private static String solve(String s, String t) {

		int sLength = s.length();
		int tLength = t.length();

		int[][] dp = new int[sLength+1][tLength+1];

		for(int i = 1; i <= sLength; i++) {
			for(int j = 1; j <= tLength; j++) {
				if(s.charAt(i-1) == t.charAt(j-1))
					dp[i][j] = dp[i-1][j-1]+1;

				dp[i][j] = Math.max(dp[i-1][j], dp[i][j]);
				dp[i][j] = Math.max(dp[i][j-1], dp[i][j]);
			}
		}

		String re="";

		int i = sLength, j = tLength;
		while(dp[i][j] != 0) {
			if(dp[i][j] == dp[i-1][j]) {
				i--;
			}else if(dp[i][j] == dp[i][j-1]) {
				j--;
			}else {
				re = s.charAt(i-1) + re;
				i--;
				j--;
			}
		}

		return re;

	}
}

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

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

  int n;
  long long a[200200] = {0};
  cin >> n;
  for (int i = 1; i <= n; i++)
  {
    int x;
    cin >> x;
    a[i] = a[i - 1] + x;
  }

  long long ans = a[n];
  for (int i = 1; i < n; i++)
    ans = min(ans, abs(a[n] - a[i] * 2));
  cout << ans << endl;
}


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

int main(void){
    int n;
    cin >> n;
    int P[n];
    for(int i = 0;i<n;i++){
      cin >> P[i];
    }
    int cnt = 0;
    for(int i = 0;i<n-2;i++){
       if(P[i] < P[i+1] && P[i+1] < P[i+2]){
         cnt++;
       }else if(P[i] > P[i+1] && P[i+1] > P[i+2]){
         cnt++;
       }
    }
    cout << cnt <<endl;
   return 0;
}

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

int main() {
    long num, i, min=10000000, max=-10000000, sum=0;
    long *a;

    cin >> num;
    a = new long[num];
    for(i=0;i<num;i++){
        cin >> a[i];
        if(min>a[i]) {
            min = a[i];  
        }
        if(max<a[i]){
            max = a[i];
        }
        sum = a[i]+sum;
    }
    cout << min << " " << max << " " << sum << endl;
    return 0;
}


Measured memory_bytes: 3176
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define FOR(i,s,n) for(int i = s; i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(n) (n).begin(), (n).end()
#define RALL(n) (n).rbegin(), (n).rend()
#define ATYN(n) cout << ( (n) ? "Yes":"No") << '\n';
#define CFYN(n) cout << ( (n) ? "YES":"NO") << '\n';
#define OUT(n) cout << (n) << '\n';
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;
using pll = pair<ll,ll>;

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

    ll ans = 0;
    if (a+1 >= b) ans = k+1;
    else {
        ll k1 = 0;
        ans = 1;
        while(k1 < k) {
            if (ans < a) {
                ll x = min(k-k1,a-ans);
                //cerr << x << endl;
                k1 += x;
                ans += x;
            }
            
            if (k-k1 == 1) {
                ans++;
                k1++;
            } else if (k-k1 >= 2) {
                k1 += 2;
                ans += b-a;
            }
            //cerr << ans << endl;
        }
    }

    cout << ans << '\n';

    return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LINF = 1e18;

/*
<url:https://agc011.contest.atcoder.jp/tasks/agc011_b>
問題文============================================================
 すぬけ君は，N 匹の変わった生き物を見つけました．
 それぞれの生き物には色と大きさが定まっており，i 番目の生き物の色は i，大きさは Ai で表されます．
 
 どの生き物も，大きさが自分の 2 倍以下であるような他の生き物を吸収することができます．
 大きさ A，色 B の生き物が大きさ C，色 D の生き物を吸収すると (C≤2×A)，合体して大きさ A+C，
 色 B の生き物になります．
 ここで，2 匹の生き物の大きさによっては，どちらも他方を吸収することが可能な場合があります．
 
 すぬけ君がこの生き物たちを観察していると，合体を繰り返して，最終的に 1 匹になりました．
 このとき，残った生き物の色として考えられるものは何種類あるかを求めてください．
=================================================================

解説=============================================================

 N匹のサイズを昇順に並べた時
     i番目の生き物がi+1番目の生き物を食べることができるには
     i+1番目の生き物のサイズ <= 1...i までのサイズの合計*2
     であれば良い
 
 よって累積和で1..iまでの総和を求めておき,大きい順に見ていった時何匹連続して
 上の式を満たすかどうかで判断すれば良い
================================================================
*/
int main(void) {
	cin.tie(0); ios::sync_with_stdio(false);
    ll N; cin >> N;
    vector<ll> A(N);
    for(auto &in:A) cin >> in;
    sort(A.begin(),A.end());
    vector<ll> cusum(N+1,0);
    for(int i = 0; i < N;i++) cusum[i+1] = cusum[i] + A[i];
    ll ans = 0;
    A[0] = LINF;
    for(ll i = N - 1; i >= 0; i--){
       if(A[i] <= 2*cusum[i]) continue;
        ans = N - i;
        break;
    }
    cout << ans << endl;
	return 0;
}


Measured memory_bytes: 1792
using System;
using System.IO;
using System.Linq;
using System.Collections.Generic;
using System.Text;
using System.Numerics;

namespace abc159
{
    class Program
    {
        static void Main(string[] args)
        {
            if (File.Exists("input.txt"))
            {
                Console.SetIn(new StreamReader("input.txt"));
            }
			solve_abc159A();
        }

        public static void solve_abc159B()
        {
        }

        public static void solve_abc159A()
        {
            int[] nm = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
            long even = 0;
            if (nm[0] > 1)
            {
                even = combs(nm[0], 2);
            }
            long odd = 0;
            if (nm[1] > 1)
            {
                odd = combs(nm[1], 2);
            }
            Console.WriteLine(even + odd);
        }
        public static long combs(int n, int k)
        {
	        int res = 1;
	        for (int i = n - k + 1; i <= n; i++)
            {
		        res *= i;
            }
	        for (int i = 2; i <= k; i++)
            {
		        res /= i;
            }
            return res;
            /*double res = 1;
	        for (int i = 1; i <= k; i++)
            {
		        res = res * (n - k + i) / i;
            }
	        return (long) (res + 0.01);
            */
        }
    }
}


Measured memory_bytes: 11220
#include<bits/stdc++.h>
using namespace std;
#define lli long long int
const lli mod=1e9+7;
const lli pINF=LLONG_MAX;
const lli nINF=-LLONG_MAX;
void fast() {std::ios::sync_with_stdio(false);cin.tie(NULL);}
lli power(lli a,lli b){lli ans=1;while(b!=0){ if(b%2==1){ans*=a;}b/=2;a*=a;} return ans;}
lli invmod(lli a) {return pow(a,mod-2);}
#define vi vector<int>
#define vlli vector<lli>
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define si(n) scanf("%d",&n)
#define sli(n) scanf("%lld",&n)
#define printi(n) printf("%d\n",n)
#define printli(n) printf("%lld\n",n)
#define all(v) v.begin(),v.end()
#define forn(i,n) for(int i=0;i<n;i++)
void print(int a[],int n){for(int i=0;i<n;i++) cout<<a[i]<<" ";}
pair< pair<lli,lli>, int > point[100005];
vector< pair< lli, pair<int,int> > > edge;
int par[100005];

int find(int u){
    return (par[u]==u)?u:(par[u]=find(par[u]));
}

bool by_x(pair< pair<lli,lli>, int > x, pair< pair<lli,lli>, int >y){
    return x.F.F<y.F.F;
}

bool by_y(pair< pair<lli,lli>, int > x, pair< pair<lli,lli>, int >y){
    return x.F.S<y.F.S;
}

void pre()
{
    for(int i=0;i<100005;i++) par[i]=i;
}

bool ok(int u,int v){
    u=find(u);
    v=find(v);
    
    if(u!=v){
        par[u]=v;
        return true;
    }
    return false;
}

int main() 
{
    int n;
    si(n);
    
    for(int i=0;i<n;i++){
        sli(point[i].F.F);sli(point[i].F.S);
        point[i].S=i;
    }
    
    sort(point,point+n,by_x);
    
    for(int i=1;i<n;i++){
        edge.pb(mp(point[i].F.F-point[i-1].F.F,mp(point[i].S,point[i-1].S)));
    }
    
    sort(point,point+n,by_y);
    
    for(int i=1;i<n;i++){
        edge.pb(mp(point[i].F.S-point[i-1].F.S,mp(point[i].S,point[i-1].S)));
    }
    
    sort(all(edge));
    
    pre();
    
    lli ans=0;
    for(auto i:edge){
        lli cost=i.F;
        int u=i.S.F;
        int v=i.S.S;
        
        if(ok(u,v)) ans+=cost;
    }
    
    cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 8816
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define REP(i,n) for(int i = 0; i < (int)(n); ++i)
 
signed main() {
  ios::sync_with_stdio(false);
  int N; cin >> N;
  int a = 0;
  bool ok = true;
  while(N--) {
    string s; cin >> s;
    if(s == "A") {
      ++a;
    }
    else {
      if(a == 0) ok = false;
      --a;
    }
  }
  if(a != 0) ok = false;
  cout << (ok ? "YES" : "NO") << endl;
}

Measured memory_bytes: 3220
import java.util.Scanner;

public class Main{
  public static void main(String[] args){
    Scanner sc=new Scanner(System.in);
    int n=sc.nextInt();
    int[] a=new int[n];
    int[] b=new int[n];
    for(int i=0;i<n;i++){
      a[i]=sc.nextInt();
      b[a[i]-1]=i+1;
    }
    for(int i=0;i<n;i++){
      System.out.println(b[i]+" ");
    }
  }
}

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

int main() {
  int N;
  cin >> N;
  vector<int>V(N);
  vector<int>C(N);
  for(int i=0; i<N; i++){
    cin >> V[i];
  }
  for(int  i=0; i<N; i++){
    cin >> C[i];
  }
  int ans = 0;
  for(int i=0; i<N; i++){
    int s = V[i] -C[i];
    if(s > 0){
      ans += s;
    }
  }
  cout << ans << endl;    
}


Measured memory_bytes: 3616
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn = 2e3 + 5, mod = 1e9 + 7;
ll CC[maxn][maxn];

int main()
{
    ios::sync_with_stdio(0); cin.tie(0);
    for(int i = 0; i < maxn; ++i){
        CC[i][0] = CC[i][i] = 1;
        for(int j = 1; j < i; ++j){
            CC[i][j] = (CC[i - 1][j] + CC[i - 1][j - 1]) % mod;
        }
    }
    int n, k;
    cin >> n >> k;
    for (int i = 1; i <= k; ++i){
        cout << (ll)CC[n - k + 1][i] * CC[k - 1][i - 1] % mod << '\n';
    }
    return 0;
}


Measured memory_bytes: 30208
# -*- coding: utf-8 -*-
#ABC088C
import sys

n = int(input())
num_m = 0
num_a = 0
num_r = 0
num_c = 0
num_h = 0
for i in range(0,n):
	tmp = input()
	if(tmp[0]=='M'):
		num_m += 1
	if(tmp[0]=='A'):
		num_a += 1
	if(tmp[0]=='R'):
		num_r += 1
	if(tmp[0]=='C'):
		num_c += 1
	if(tmp[0]=='H'):
		num_h += 1

sum=0
sum+=num_m*num_a*num_r
sum+=num_m*num_a*num_c
sum+=num_m*num_a*num_h
sum+=num_m*num_r*num_c
sum+=num_m*num_r*num_h
sum+=num_m*num_c*num_h
sum+=num_a*num_r*num_c
sum+=num_a*num_r*num_h
sum+=num_a*num_c*num_h
sum+=num_r*num_c*num_h

print(sum)
#print(num_m)
#print(num_a)
#print(num_r)
#print(num_c)
#print(num_h)



Measured memory_bytes: 3064
fun main(args: Array<String>) {
    var n = readLine()!!.toInt()
    var vs = readLine()!!.split(" ").map(String::toInt)
    var cs = readLine()!!.split(" ").map(String::toInt)
    var ans = -10000000
    for (S in 0..(1 shl n)) {
        val vsum = vs.filterIndexed { index, i -> ((S shr index) and 1) != 0 }.sum()
        val csum = cs.filterIndexed { index, i -> ((S shr index) and 1) != 0 }.sum()
        val t = vsum - csum
        if (ans < t) {
            ans = t
        }
    }
    println(ans)
}

Measured memory_bytes: 112448
s = input()
n = len(s)

def kaibun(y):
    m = len(y)
    for i in range(int((m+1)/2)):
        if y[i]==y[-1-i]:
            pass
        else:
            return False
    return True


if kaibun(s):
    if kaibun(s[:int((n-1)/2)]):
        print('Yes')
    else:
        print('No')
else:
    print('No')


Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define ll long long
#define endl '\n'
using namespace std;
const ll mod = (ll)1e9+7;
const int INF = 0x3f3f3f3f;

vector<int> v(105);
ll dp[105][100010]; //dp[child #][number of candies left] = possibilities up to this point

int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0);
    #ifndef ONLINE_JUDGE
    //freopen("B.txt", "r", stdin);
    #endif
    int n, k;
    cin >> n >> k;
    for(int i=1; i<=n; i++)
        cin >> v[i];
    dp[0][0]=1;
    for(int i=1; i<=n; i++)
    {
        dp[i][0] = 1;
        for(int j=1; j<=100000; j++)
        {
            if(j>v[i])
            {
                dp[i][j] = (dp[i][j-1]+dp[i-1][j]-dp[i-1][j-v[i]-1])%mod;
                if(dp[i][j]<0) dp[i][j]+=mod;
            }
            else dp[i][j] = (dp[i][j-1]+dp[i-1][j])%mod;
        }
    }
    cout << dp[n][k];
}


Measured memory_bytes: 79488
//#include "IntMod.h"
//typedef IntMod<1000000007> MInt;

#include <iostream>
#include <string>
#include <vector>
#include <utility>
#include <algorithm>
#include <functional>
#include <cmath>
#include <stack>
#include <set>
using namespace std;
#define REP(i,a,n) for(int i = a; i < n; ++i)
#define EPS 0.0001
#define INF 0x3FFFFFFF
typedef long long LL;

int N;
LL a = 1, b = 1;

int main() {
	cin >> N;
	REP(i, 0, N) {
		LL bufa, bufb;
		cin >> bufa >> bufb;
		LL mul;
		if (a / bufa > b / bufb || (a / bufa == b / bufb && a % bufa * bufb >= b % bufb * bufa)) {
			mul = (a - 1) / bufa + 1;
		} else {
			mul = (b - 1) / bufb + 1;
		}
		a = mul * bufa;
		b = mul * bufb;
	}
	cout << a + b << endl;
	return 0;
}

Measured memory_bytes: 256
<?php
define("MAX", 1e6);

// sieve
for ($i = 0; $i < MAX; $i++) {
  $isPrime[] = 1;
}
$isPrime[0] = $isPrime[1] = 0;
for ($i = 2; $i < MAX; $i++) {
  if (!$isPrime[$i]) continue;
  for ($j = 2 * $i; $j < MAX; $j += $i) {
    $isPrime[$j] = 0;
  }
}

while (fscanf(STDIN, "%d %d %d", $a, $d, $n) && ($a | $d | $n)) {
  $count = 0;
  while (1) {
    if ($isPrime[$a]) {
      $count++;
    }
    if ($count == $n) {
      break;
    }
    $a += $d;
  }
  print $a . "\n";
}

Measured memory_bytes: 147528
#include <stdio.h>
#include <stdbool.h>

#define N 8
#define FREE -1
#define NOT_FREE 1

int row[N],col[N],dpos[2*N-1],dneg[2*N-1];
int X[N][N];

void initialize(){
  int i;
  for(i = 0;i < N;i++){ row[i] = FREE; col[i] = FREE; }
  for(i = 0;i < 2*N-1;i++){ dpos[i] = FREE; dneg[i] = FREE; }
}

void printBoard(){
  int i,j;
  for(i = 0;i < N;i++){
    for(j = 0;j < N;j++){
      if(X[i][j]){
	if(row[i] != j) return ;
      }
    }
  }
  for(i = 0;i < N;i++){
    for(j = 0;j < N;j++){
      if(row[i] == j) printf("Q");
      else printf(".");
    }
    printf("\n");
  }
}

void recursive(int i){
  int j;
  if(i == N){
    printBoard();
    return ;
  }
  for(j = 0;j < N;j++){
    if(NOT_FREE == col[j] ||
       NOT_FREE == dpos[i + j] ||
       NOT_FREE == dneg[i - j + N - 1]) continue;
    row[i] = j;
    col[j] = dpos[i + j] = dneg[i - j + N - 1] = NOT_FREE;
    recursive(i + 1);
    row[i] = col[j] = dpos[i + j] = dneg[i - j + N - 1] = FREE;
  }
}

int main(){
  int i,j,k,r,c;
  initialize();
  for(i = 0;i < N;i++){
    for(j = 0;j < N;j++){
      X[i][j] = false;
    }
  }
  scanf("%d",&k);
  for(i = 0;i < k;i++){
    scanf("%d %d",&r,&c);
    X[r][c] = true;
  }
  recursive(0);
  return 0;
}

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

const int INF = 1e+8;

// s[k] から座っている人までの距離
int dist(vector<char>& s, int k){
	int a=0, b=0;
	for(int i=k ; i >= 0 ; i-- , a++ ){
		if( i == 0 && s[i] == '#' ){
			a = INF;
			break;
		}
		if( s[i] != '#' ) break;
	}
	for(int i=k ; i < s.size() ; i++ , b++ ){
		if( i+1 == s.size() && s[i] == '#' ){
			b = INF;
			break;
		}
		if( s[i] != '#' ) break;
	}
	return min(a-1,b-1);
}

void f(vector<char>& s , char a ){
	if( a == 'A' ){
		// 一番最初に見つかった空席に座る
		for(int i=0 ; i < s.size() ; i++ ){
			if( s[i] == '#' ){
				s[i] = 'A';
				return ;
			}
		}
	}else if( a == 'B' ){
		// 隣が'A'でない空席に座る
		for(int i=s.size()-1 ; i >= 0  ; i-- ){
			if( s[i] != '#' ) continue;
			
			if( i == 0 ){
				if( i+1 == s.size() || s[i+1] != 'A' ){
					s[i] = 'B';
					return;
				}
			}else if( i == s.size()-1 ){
				if( i-1 < 0 || s[i-1] != 'A' ){
					s[i] = 'B';
					return;
				}
			}else{
				if( s[i-1] != 'A' && s[i+1] != 'A' ){
					s[i] = 'B';
					return;
				}
			}
		}
		// 座れる場所がなかった場合一番最初の空席に座る
		for(int i=0 ; i < s.size() ; i++ ){
			if( s[i] == '#' ){
				s[i] = 'B';
				return;
			}
		}
	}else if( a == 'C' ){
		// 人がいる左の空席に座る. 埋まっているときはその右に座る 
		for(int i=0 ; i < s.size() ; i++ ){
			if( s[i] != '#' ){
				if( i+1 < s.size() && s[i+1] == '#' ){
					s[i+1] = 'C';
					return;
				}else if( i-1 >= 0 && s[i-1] == '#' ){
					s[i-1] = 'C';
					return;
				}
			}
		}
		// 全部空席のときは真ん中に座る.
		s[s.size()/2] = 'C';
		return;
	}else if( a == 'D' ){
		// 空席の数をチェック.
		int cnt = 0;
		for(int i=0 ; i < s.size() ; i++ ){
			if( s[i] == '#' ) cnt++;
		}
		if( cnt == s.size() ){ // 全部空席のとき
			s[0] = 'D';
			return;
		}
		
		// 一番距離の遠い席を探す.
		int m = dist(s,0);
		for(int i=1 ; i < s.size() ; i++ ){
			m = max( m , dist(s,i) );
		}
		for(int i=0 ; i < s.size() ; i++ ){
			if( m == dist(s,i) ){
				s[i] = 'D';
				return;
			}
		}
	}
}

int main(){
	int n, m;
	while( cin >> n >> m , n || m ){
		vector<char> s(n,'#');
		for(int i=0 ; i < m ; i++ ){
			char a;
			cin >> a;
			f( s , a );
		}
		for(int i=0 ; i < s.size() ; i++ ){
			cout << s[i];
		}
		cout << endl;
	}
}

Measured memory_bytes: 1196
#include <stdio.h>
#include <stdlib.h>

#define MAX 2000001
#define VMAX 10000

int main(){
//	unsigned short *A, *B;
	int C[VMAX+1];
	int n,i,j;
	unsigned short *A,*B;
	scanf("%d",&n);
	A = malloc(sizeof(short)*n+1);
	B = malloc(sizeof(short)*n+1);
	
	for(i=0;i<=VMAX;i++) C[i]=0;
	for(i=0;i<n;i++){
		scanf("%hu",&A[i+1]);
		C[A[i+1]]++;
	}
	for(i = 1;i<=VMAX;i++){
		C[i] = C[i]+C[i-1];
	}
	
	for(j=n;j>=1;j--){
	B[C[A[j]]]=A[j];
	C[A[j]]--;
}

	for(i=1;i<=n;i++){
		if(i>=2) printf(" ");
		printf("%d",B[i]);
	}
	printf("\n");
	return 0;

}

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

typedef long long ll;
using namespace std;

int main() {
    ll N, A[5], m = 10000000000000000;
    cin >> N;
    for (int i = 0; i < 5; i++) {
        cin >> A[i];
        m = min(m, A[i]);
    }
    ll k = 1 + (N - 1) / m;
    cout << 5 + k - 1 << endl;
}

Measured memory_bytes: 256
N = gets.to_i
H = gets.split.map!(&:to_i)

max = 0
cur = 0
0.upto(N-2) do |i|
  if H[i] >= H[i+1]
    cur += 1
  else
    max = cur if max < cur
    cur = 0
  end
end

puts [max, cur].max

Measured memory_bytes: 7812
//include
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <iomanip>
#include <map>
#include <sstream>
#include <utility>
//マクロとか
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i < (int)(n) + 1; i++)
#define all(vecto) vecto.begin(), vecto.end()
#define max3(a, b, c) max(a, max(b, c))
#define min3(a, b, c) min(a, min(b, c))
using ll = long long;

//自前の関数たち
//最大公約数
ll GCD(ll a, ll b)
{
    if (b == 0)
        return a;
    else
        return GCD(b, a % b);
}

//最小公倍数
ll LCM(ll a, ll b)
{
    return (a * b) / GCD(a, b);
}

//namespace my
namespace my
{
//配列の最大値or最小値を数値で返す関数
int max_element(std::vector<int> vec)
{
    std::sort(vec.begin(), vec.end());
    return vec.at(vec.size() - 1);
}
int min_element(std::vector<int> vec)
{
    std::sort(vec.begin(), vec.end());
    return vec.at(0);
}
} // namespace my

//yes,noを出力するやつ
void ans(bool qus)
{
    if (qus == true)
        std::cout << "Yes" << std::endl;
    else
        std::cout << "No" << std::endl;
}

void Ans(bool qust)
{
    if (qust == true)
        std::cout << "YES" << std::endl;
    else
        std::cout << "NO" << std::endl;
}

//std名前空間を使用
using namespace std;

////////////////////////////////////////////////////////////////////////////////
//スタート

int main(){
    int n;
    cin>>n;
    vector<int> vec(n);
    rep(i,n){
        cin >> vec.at(i);
    }
    int count = 0;
    rep(i,n){
        int minj = i;
        for (int j = i; j < n;j++){
            if(vec.at(j)<vec.at(minj)){
                minj = j;
            }
        }
        swap(vec.at(i), vec.at(minj));
      	if(i!=minj) count++;
    }
    rep(i,n-1){
        cout << vec.at(i) << ' ';
    }
    cout << vec.at(n - 1) << endl;
    cout << count << endl;
}


Measured memory_bytes: 3116
object Main {
  def main(args: Array[String]): Unit = {
    val s = new Main()
    s.solve()
    s.out.flush()
  }
}

class Main {
  import java.io._
  import java.util.StringTokenizer

  import scala.collection.mutable
  import scala.util.Sorting
  import math.{abs, max, min}
  import mutable.{ArrayBuffer, ListBuffer}
  import scala.reflect.ClassTag

  val MOD = 1000000007
  val out = new PrintWriter(System.out)

  def solve(): Unit = {
    val a, b = ni()
    val ans = 1 to a count { m =>
      1 to (if (a == m) b else 12)  contains m
    }

    out.println(ans)

  }


  class InputReader(val stream: InputStream) {
    private val reader = new BufferedReader(new InputStreamReader(stream), 32768)
    private var tokenizer: StringTokenizer = _

    def next(): String = {
      while (tokenizer == null || !tokenizer.hasMoreTokens)
        tokenizer = new StringTokenizer(reader.readLine)
      tokenizer.nextToken
    }

    def nextInt(): Int = next().toInt
    def nextLong(): Long = next().toLong
    def nextChar(): Char = next().charAt(0)
  }
  val sc = new InputReader(System.in)
  def ni(): Int = sc.nextInt()
  def nl(): Long = sc.nextLong()
  def nc(): Char = sc.nextChar()
  def ns(): String = sc.next()
  def ns(n: Int): Array[Char] = ns().toCharArray
  def na(n: Int): Array[Int] = map(n)(_ => ni())
  def nal(n: Int): Array[Long] = map(n)(_ => nl())
  def nm(n: Int, m: Int): Array[Array[Char]] = map(n) (_ => ns(m))
  def rep(n: Int, offset: Int = 0)(f: Int => Unit): Unit = {
    var i = offset
    val N = n + offset
    while(i < N) { f(i); i += 1 }
  }
  def rep_r(n: Int, offset: Int = 0)(f: Int => Unit): Unit = {
    var i = n - 1 + offset
    while(i >= offset) { f(i); i -= 1 }
  }

  def map[@specialized A: ClassTag](n: Int)(f: Int => A): Array[A] = {
    val res = Array.ofDim[A](n)
    rep(n)(i => res(i) = f(i))
    res
  }

  def sumL(as: Array[Int]): Long = {
    var s = 0L
    rep(as.length)(i => s += as(i))
    s
  }
}

Measured memory_bytes: 25536
#include<bits/stdc++.h>
using namespace std;
int main(){
    int sx,sy,tx,ty;
    cin>>sx>>sy>>tx>>ty;
    for(int i=sy;i!=ty;i++){
        cout<<"U";
    }
      for(int i=sx;i!=tx;i++){
        cout<<"R";
    }
     for(int i=ty;i!=sy;i--){
        cout<<"D";
    }
      for(int i=tx;i!=sx;i--){
        cout<<"L";
    }
    cout<<"L";
     for(int i=sy;i!=ty+1;i++){
        cout<<"U";
    }
     for(int i=sx-1;i!=tx;i++){
        cout<<"R";
    }
    cout<<"D";
    cout<<"R";
    for(int i=ty;i!=sy-1;i--){
        cout<<"D";
    }
     for(int i=tx+1;i!=sx;i--){
        cout<<"L";
    }
    cout<<"U";



}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define endl '\n'
using namespace std;
const ll mod = (ll)1e9+7;
const int INF = 0x3f3f3f3f;

int a[100001][3];

int mpow(int b, int e)
{
    int ret=1;
    for(int i=0; i<e; i++)
    {
        ret=ret*b%mod;
    }
    return ret;
}

int dp[100001][3];

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int n;
    cin >> n;
    for(int i=1; i<=n; i++)
    {
        int aa, b, c;
        cin >> aa >> b >> c;
        a[i][0]=aa;
        a[i][1]=b;
        a[i][2]=c;
    }
    for(int i=1; i<=n; i++)
    {
        dp[i][0]=max(dp[i-1][1]+a[i][0], dp[i-1][2]+a[i][0]);
        dp[i][1]=max(dp[i-1][0]+a[i][1], dp[i-1][2]+a[i][1]);
        dp[i][2]=max(dp[i-1][1]+a[i][2], dp[i-1][0]+a[i][2]);
    }
    int ans = max(dp[n][1], dp[n][2]);
    cout << max(ans, dp[n][0]);
}
//TODO: 56
//come back to 50D, 55D


Measured memory_bytes: 2560
#include <bits/stdc++.h>
#define int long long
using namespace std;

signed main() {
  string S;
  cin >> S;
  
  string alfa = "abcdefghijklmnopqrstuvwxyz";
  
  set<char> A;
  for( int i = 0; i < S.size(); i++ ){
    A.insert(S.at(i));
  }
  
  for( int i = 0; i < alfa.size(); i++ ){
    if( A.count(alfa.at(i)) ){
      continue;
    }else{
      cout << alfa.at(i) << endl;
      return 0;
    }
  }
  cout << "None" << endl;
}


Measured memory_bytes: 512
#include<iostream>
#include<cstring>
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<queue>

using namespace std;

char s[1005][1005]= {'\0'};

int n, m, num;
int a[10][2]= {0};

int mov1[4]= {-1,0,1,0};
int mov2[4]= {0,1,0,-1};

struct node
{
    int x;
    int y;
    int ans;
    node()
    {
        x=0;
        y=0;
        ans=0;
    }
    node(int a,int b,int c)
    {
        x=a;
        y=b;
        ans=c;
    }
};

queue<node>q;

node t;

void bfs(node temp,int type)
{
    if(type>num)return;
    if(a[type][0]==temp.x&&a[type][1]==temp.y)
    {
        //printf("*****\n");
            //printf("type is %d\n",type);
            for(int i=1; i<=n; i++)
                for(int j=1; j<=m; j++)
                    if(s[i][j]=='*')
                        s[i][j]='.';
            while(!q.empty())q.pop();
            bfs(temp,type+1);
    }
    else
    {
        q.push(temp);
        while(!q.empty())
        {
            t=q.front();
            q.pop();
            if(a[type][0]==t.x&&a[type][1]==t.y)
            {
                bfs(t,type);
                break;
            }
            s[t.x][t.y]='*';
            for(int i=0;i<4;i++)
            {
                int tx=t.x+mov1[i];
                int ty=t.y+mov2[i];
                if(tx<1||ty<1||tx>n||ty>m||s[tx][ty]=='X'||s[tx][ty]=='*')continue;
                node p(tx,ty,t.ans+1);
                s[tx][ty]='*';
                //printf("jiezhi %d %d %d\n",tx,ty,t.ans+1);
                q.push(p);
            }
        }

    }
}

int main()
{
    //freopen("in.in","r",stdin);
    while(scanf("%d%d%d",&n,&m,&num)!=EOF)
    {
        char c=getchar();
        memset(s,'\0',sizeof(s));
        memset(a,0,sizeof(a));
        int x=0, y=0;
        for(int i=1; i<=n; i++)
        {
            for(int j=1; j<=m; j++)
            {
                scanf("%c",&s[i][j]);
                if(s[i][j]=='S')
                {
                    x=i;
                    y=j;
                }
                if(s[i][j]>='0'&&s[i][j]<='9')
                {
                    a[s[i][j]-'0'][0]=i;
                    a[s[i][j]-'0'][1]=j;
                }
            }
            c=getchar();
        }
        //for(int i=1;i<=num;i++)
        //    printf("%d %d\n",a[i][0],a[i][1]);
        while(!q.empty())q.pop();
        /*for(int i=1;i<=n;i++)
        {
            for(int j=1;j<=m;j++)
                printf("%c",s[i][j]);
            printf("\n");
        }*/
        node temp;
        temp.x=x;
        temp.y=y;
        bfs(temp,1);
        printf("%d\n",t.ans);
    }
    return 0;
}

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


int main () {
  int h, n, temp;
  int ans = 0;
  cin >> h >> n;
  for (int i = 0; i < n; i++) {
    cin >> temp;
    ans += temp;
  }
  if (h <= ans) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
}
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

int main(void){
    
    ll n, r=0, g=0, b=0;
    char s[4009];
    ll ans=0;
    
    cin >> n;
    
    for(ll i=1; i<=n; i++){
        
        cin >> s[i];
        
        if(s[i]=='R'){
            
            r += 1;
            
        } else if(s[i]=='G'){
            
            g += 1;
            
        } else {
            
            b += 1;
            
        }
        
    }
    
    ans = r * g * b;
    
    for(ll i=1; i<=n; i++){
        
        for(ll j=1; j<=n; j++){
            
            if(i+2*j>n){
                
                break;
                
            }
            
            if(s[i]!=s[i+j]&&s[i]!=s[i+2*j]&&s[i+j]!=s[i+2*j]){
                
                ans -= 1;
                
            }
            
        }
        
    }
    
    cout << ans << endl;
    
    return 0;
    
}

Measured memory_bytes: 3656
//****** @mdazmat9 **********
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define UB upper_bound
#define LB lower_bound
#define BS binary_search
#define EB emplace_back
#define PB push_back
#define endl "\n"
#define MOD 1000000007
#define MOD2 998244353
#define F first
#define S second
#define ALL(a) (a).begin(),(a).end()
typedef pair<int, int> pr;
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
int fast_pow(int x, int y, int p);


void solve() {
    int n,k;cin>>n>>k;
    n++;
    int dp[n+1];
    memset(dp,0, sizeof(dp));

    for(int i=n-1;i>=0;i--){
        if(i==n){
            dp[i]=n;
        } else{
            dp[i]=i+dp[i+1];
        }
        dp[i]%=MOD;
    }
    int ans=0;
    for(int i=k;i<=n;i++){
        int sub=i*(i-1);
        sub/=2;
        sub%=MOD;
//        cout<<dp[n-i]<<" "<<sub<<endl;
        ans=((ans+dp[n-i]-sub+1)%MOD+MOD)%MOD;
    }
    cout<<ans<<endl;
}
int32_t main() {
    IOS;
    int test = 1;
//    cin >> test;
    for(int i=1;i<=test;i++){
//        cout<<"Case #"<<i<<": ";
        solve();
    }
    return 0;
}
int fast_pow(int x, int y, int p) {
    int res = 1;
    x = x % p;
    while (y > 0) {
        if (y & 1)
            res = (res * x) % p;
        y = y >> 1;
        x = (x * x) % p;
    }
    return res;
}

Measured memory_bytes: 5172
public class Main {
    public static void main(String args[]) {
        for(int i = 1; i <= 9; i++) {
            for(int j = 1; j <= 9; j++) {
                // ?¨?????????????????????????
                System.out.println(""+i+'x'+j+'='+(i*j));
            }
        }
    }
}

Measured memory_bytes: 24012
import java.io.*;
import java.lang.*;
import java.util.*;

 public class Main{
  
 public static void main(String args[]){
   
  Scanner s = new Scanner(System.in);
   
   int x =s.nextInt();
  s.nextLine();
   int ac=0,wa=0,tle=0,re=0;
   while(x-- >0){
       String g = s.nextLine();
     if(g.equals("AC"))
       ac++;
     else if(g.equals("WA"))
       wa++;
     else if(g.equals("TLE"))
       tle++;
     else if(g.equals("RE"))
       re++;
         
   }
   
   System.out.println("AC x "+ac);
   System.out.println("WA x "+wa);
   System.out.println("TLE x "+tle);
   System.out.println("RE x "+re);
 }
  
}

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

int main(){
	cin.tie(0),ios::sync_with_stdio(false);
	string s; cin>>s;
	int ans=0;
	for(int i=0;i<s.size();++i){
		int cnt=0;
		while(i<s.size()&&(s.at(i)=='A'||s.at(i)=='C'||s.at(i)=='G'||s.at(i)=='T'))++i,++cnt;
		ans=max(ans,cnt);
	}
	cout<<ans<<"\n"s;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string>
#include <iostream>
#include <iomanip>
#include <map>
#include <algorithm>
#include <vector>
#include <math.h>
#define MOD (long long)1000000007
using namespace std;

int main(void){
    char c;
    cin >> c;
    if(c=='A')c='T';
    else if(c=='T')c='A';
    else if(c=='G')c='C';
    else if(c=='C')c='G';
    cout << c << endl;
    return 0;
}

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

const int MOD = 1e9 + 7;

int main() {
    int N, M;
    cin >> N >> M;
    vector<int64_t> dp(M + 1, 1);

    for (int i = 0; i < N; i++)
        for (int m = 0, sum = 0; m <= M; m++) {
            int extra = (sum + m * dp[m]) % MOD;
            dp[m] = (dp[m] + extra) % MOD;
            sum = (sum + extra) % MOD;
        }

    cout << dp[M] << '\n';
}


Measured memory_bytes: 3652