akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <fstream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <numeric>
#include <type_traits>
#include <map>
using namespace std;

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

  string s, t;
  cin >> s >> t;

  map<int, int> mp1;
  map<int, int> mp2;
  for(int i = 0; i < s.size(); i++){
    if(mp1[t[i]] == 0){
      mp1[t[i]] = s[i];
    }else{
      if(mp1[t[i]] != s[i]){
        cout << "No" << endl;
        return 0;
      }
    }
    if(mp2[s[i]] == 0){
      mp2[s[i]] = t[i];
    }else{
      if(mp2[s[i]] != t[i]){
        cout << "No" << endl;
        return 0;
      }
    }

  }
  cout << "Yes" << endl;
  return 0;
}


Measured memory_bytes: 776
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>

using namespace std;

#define ll long long
#define ld long double
#define EPS 0.0000000001
#define INF 1e9
#define MOD 1000000007
#define rep(i,n) for(i=0;i<n;i++)
#define loop(i,a,n) for(i=a;i<n;i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)

typedef vector<int> vi;
typedef pair<int,int> pii;

int main(void) {
  int i,j;
  int n,k;
  cin>>n>>k;
  vector<bool> d(10,false);
  rep(i,k){
    int t;
    cin>>t;
    d[t]=true;
  }
  while(1){
    string s=to_string(n);
    int size=s.size();
    rep(i,size)
      if(d[s[i]-'0'])break;
    if(i==size)break;
    n++;
  }
  cout<<n<<endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<stack>

int main(void){
    int no;
    std::stack<int> st;
    while(std::cin>>no){
        if(no==0){
            std::cout<<st.top()<<std::endl;
            st.pop();
        }else{
            st.push(no);
        }
    }
    return 0;
}


Measured memory_bytes: 3064
#!/usr/bin/env python3
import sys

YES = "Yes"  # type: str
NO = "No"  # type: str


def solve(N: int, a: "List[int]"):
    from collections import Counter
    ma, mi = max(a), min(a)
    if ma >= N or mi < 1:
        raise
    if ma - mi > 1:
        return False
    # 全員aloneか、全員pair以上（pairもしくはcrowd）
    if ma == mi:
        return ma == N - 1 or  2 * ma <= N
    c = Counter(a)
    # pairがpairでない
    if c[ma] % 2 != 0:
        return False
    x = ma - c[ma] // 2
    # pair以外、すべてalone(crowdが0個)
    if x == c[mi]:
        return True
    # crowdを1つ以上作れるなら1以上c[mi]-2以下の好きな數を作れる
    return 1 <= x <= c[mi] - 2

# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    a = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    print(YES if solve(N, a) else NO)

if __name__ == '__main__':
    main()


Measured memory_bytes: 14256
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func main() {
	sc := NewScanner()

	n = sc.ReadInt()
	m = sc.ReadInt()
	q = sc.ReadInt()
	abcds := make([]ABCD, q)
	for i := 0; i < q; i++ {
		abcds[i] = ABCD{sc.ReadInt(), sc.ReadInt(), sc.ReadInt(), sc.ReadInt()}
	}

	as = make([]A, 0, 200000)
	fillAs(1, m, 0, make(A, n))

	maxD := 0
	for _, a := range as {
		d := totalD(abcds, a)
		if d > maxD {
			maxD = d
		}
	}

	fmt.Println(maxD)
}

var n, m, q int
var as []A

type ABCD struct {
	A int
	B int
	C int
	D int
}

type A []int

func fillAs(min int, m int, digit int, cur A) {
	if digit == n-1 {
		for i := min; i <= m; i++ {
			a := make(A, n)
			copy(a, cur)
			a[digit] = i
			as = append(as, a)
		}
	} else {
		for i := min; i <= m; i++ {
			cur[digit] = i
			fillAs(i, m, digit+1, cur)
		}
	}
}

func totalD(abcds []ABCD, a A) int {
	total := 0
	for _, abcd := range abcds {
		if a[abcd.B-1]-a[abcd.A-1] == abcd.C {
			total += abcd.D
		}
	}
	return total
}

// util
// *   math/simple

func Abs(x int) int {
	if x >= 0 {
		return x
	}
	return -x
}

func Min(values ...int) int {
	if len(values) == 0 {
		panic("no values")
	}
	min := values[0]
	for _, v := range values {
		if v < min {
			min = v
		}
	}
	return min
}

func Max(values ...int) int {
	if len(values) == 0 {
		panic("no values")
	}
	max := values[0]
	for _, v := range values {
		if v > max {
			max = v
		}
	}
	return max
}

func Pow(base int, exponent uint) int {
	answer := 1
	for i := uint(0); i < exponent; i++ {
		answer *= base
	}
	return answer
}

// *   io

type Scanner struct {
	bufScanner *bufio.Scanner
}

func NewScanner() *Scanner {
	bufSc := bufio.NewScanner(os.Stdin)
	bufSc.Split(bufio.ScanWords)
	bufSc.Buffer(nil, 100000000)
	return &Scanner{bufSc}
}

func (sc *Scanner) ReadString() string {
	bufSc := sc.bufScanner
	bufSc.Scan()
	return bufSc.Text()
}

func (sc *Scanner) ReadInt() int {
	bufSc := sc.bufScanner
	bufSc.Scan()
	text := bufSc.Text()

	num, err := strconv.Atoi(text)
	if err != nil {
		panic(err)
	}
	return num
}


Measured memory_bytes: 11756
#include <stdio.h>

long long Euclid(long long x,long long y){
    if(x < y){
        long long tmp = x;
        x = y;
        y = tmp;
    }
    while(y){
        long long tmp = x % y;
        x = y;
        y = tmp;
    }
    return x;
}
int main(void){
    long long a,b;
    scanf("%lld %lld",&a,&b);
    printf("%lld\n",Euclid(a,b));
    return 0;
}


Measured memory_bytes: 2112
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define mp make_pair
#define pb push_back
#define x first
#define y second
#define pii pair<int, int>
#define p3i pair<pii, int>
#define pll pair<ll, ll>
#define p3l pair<pll, ll>
#define lseg L, (L+R)/2, N*2+1
#define rseg (L+R)/2+1, R, N*2+2
#define ub upper_bound
#define lb lower_bound
#define pq priority_queue
#define MN 1000000007
#define fox(k, x) for (int k=0; k<x; ++k)
#define fox1(k, x) for (int k=1; k<=x; ++k)
#define foxr(k, x) for (int k=x-1; k>=0; --k)
#define fox1r(k, x) for (int k=x; k>0; --k)
#define ms multiset
#define flood(x) memset(x, 0x3f3f3f3f, sizeof x)
#define drain(x) memset(x, 0, sizeof x)
#define rng() ((rand() << 14)+rand())
#define scan(X) do{while((X=getchar())<'0'); for(X-='0'; '0'<=(_=getchar()); X=(X<<3)+(X<<1)+_-'0');}while(0)
char _;
#define pi 3.14159265358979323846

int n;
vector<int> f2, f3, f6;
vector<int> res;
int main(){
    cin >> n;
    if (n==3){
        cout << "2 5 63";
        return 0;
    }
    fox1(l, 30000){
        if (l%6==0) f6.pb(l);
        else if (l%2==0) f2.pb(l);
        else if (l%3==0) f3.pb(l);
    }
    //cout << f2.size() << ' ' << f3.size() << ' ' << f6.size();
    reverse(f2.begin(), f2.end());
    reverse(f3.begin(), f3.end());
    reverse(f6.begin(), f6.end());
    res.pb(2); res.pb(3);
    res.pb(4); res.pb(9);
    f2.pop_back();
    f2.pop_back();
    f3.pop_back();
    f3.pop_back();
    n-=4;
    while(f2.size()>1 && n>1){
        n-=2;
        res.pb(f2.back()); f2.pop_back();
        res.pb(f2.back()); f2.pop_back();
    }
    while(f3.size()>1 && n>1){
        n-=2;
        res.pb(f3.back()); f3.pop_back();
        res.pb(f3.back()); f3.pop_back();
    }
    while(f6.size() && n){
        n--;
        res.pb(f6.back()); f6.pop_back();
    }
    fox(l, res.size()){
        cout << res[l] << ' ';
    }
    return 0;
}



Measured memory_bytes: 640
#include<cstdio>
#include<iostream>
#include<queue>
#include<algorithm>
#include<vector>
#include<string>
using namespace std;

//const int maxn(10086);

int main(){
	ios::sync_with_stdio(false);
	string s1,s2;
	cin>>s1>>s2;
	reverse(s1.begin(),s1.end());
	if(s1==s2) printf("YES\n");
	else printf("NO\n"); 
	return 0;
}


Measured memory_bytes: 256
def comb_once(n,k,MOD):
    ans = 1
    for i in range(k):
        ans*=n-i
        ans*=pow(i+1,-1,MOD)
        ans%=MOD
    return ans
  
MOD=10**9+7  
n,a,b = map(int,input().split())
print((pow(2,n,MOD)-1-comb_once(n,a,MOD)-comb_once(n,b,MOD))%MOD)

Measured memory_bytes: 9084
n = int(input())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
c = list(map(int,input().split()))
ans = 0
x = -1
for i in a:
    ans += b[i-1]
    if i == x + 1:
        ans += c[i-2]
    x = i
print(ans)

Measured memory_bytes: 3064
n, m, q = map(int, input().split())
ABCD = [list(map(int, input().split())) for _ in range(q)]
ans = 0
for i1 in range(1, m+1):
    for i2 in range(i1, m+1):
        for i3 in range(i2, m+1):
            for i4 in range(i3, m+1):
                for i5 in range(i4, m+1):
                    for i6 in range(i5, m+1):
                        for i7 in range(i6, m+1):
                            for i8 in range(i7, m+1):
                                for i9 in range(i8, m+1):
                                    for i10 in range(i9, m+1):
                                        temp = 0
                                        A = [i1, i2, i3, i4, i5, i6, i7, i8, i9, i10]
                                        for a, b, c, d in ABCD:
                                            if A[b-1] - A[a-1] == c:
                                                temp += d
                                        ans = max(ans, temp)
print(ans)

Measured memory_bytes: 71984
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ll long long int
const int INF = 2147483647;

using namespace std;

int main()
{
  int n;
  cin >> n;
  int a[200000];
  int b[200000];
  int m = 0;
  REP(i, n)
  {
    cin >> a[i];
    b[i] = a[i];
  }

  sort(a, a + n, greater<int>());

  REP(i, n)
  {
    if (a[0] != b[i])
    {
      cout << a[0] << endl;
    }
    else
    {
      cout << a[1] << endl;
    }
  }
}


Measured memory_bytes: 3200
#include <bits/stdc++.h>
#define INF 1000000000
#define LINF 1000000000000000000
#define MOD 1000000007
#define mod 1000007
#define INF63 1061109567
#define INF127 9187201950435737471
#define UINF 18446744073709551615
#define F first
#define S second
#define ll long long
using namespace std;
ll a,b,c,d;
int main(){
	cin>>a>>b>>c>>d;
	while(a>0)
	{
		c-=b;
		if(c<=0)
		{
			break;
		}
		a-=d;
	}
	if(c>0)
	{
		puts("No");
	}
	else
	{
		puts("Yes");
	}
	return 0;
}

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

#define whole(f, x, ...)                                 \
  ([&](decltype((x)) whole) {                            \
    return (f)(begin(whole), end(whole), ##__VA_ARGS__); \
  })(x)

using namespace std;
using ll = long long;

void solve() {
  vector<int> a(9);
  int n;
  for (int i = 0; i < 3; i++) {
    cin >> a[3 * i] >> a[3 * i + 1] >> a[3 * i + 2];
  }
  cin >> n;
  for (int i = 0; i < n; i++) {
    int b;
    cin >> b;
    auto it = find(a.begin(), a.end(), b);
    if (it != a.end()) {
      *it = 0;
    }
  }

  for (int i = 0; i < 3; i++) {
    if (a[3 * i] + a[3 * i + 1] + a[3 * i + 2] == 0 ||
        a[i] + a[i + 3] + a[i + 6] == 0) {
      cout << "Yes\n";
      return;
    }
  }
  if (a[0] + a[4] + a[8] == 0 || a[2] + a[4] + a[6] == 0) {
    cout << "Yes\n";
    return;
  }
  cout << "No\n";
}

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  std::cout << std::fixed << std::setprecision(15);

  solve();
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < n; i++)
#define vi vector<int>
#define vvi vector<vi>
#define pii pair<int, int>
#define mod 1000000007
using ll = long long;
using namespace std;
int main(){
  int n;
  cin >> n;
  vi a(n), b(n), c(n);
  rep(i, n) cin >> a[i];
  rep(i, n) cin >> b[i];
  rep(i, n) cin >> c[i];
  sort(a.begin(), a.end());
  sort(c.begin(), c.end());
  ll ans = 0;
  rep(i, n){
    int num = b[i];
    ll cntTop = distance(a.begin(), lower_bound(a.begin(), a.end(), num));
    ll cntBottom = n - distance(c.begin(), upper_bound(c.begin(), c.end(), num));
    ans += cntTop * cntBottom;
  }
  cout << ans << endl;
}

Measured memory_bytes: 1408
def solve(field):
    for i in range(1, h + 1):
        for j in range(1, w + 1):
            if field[i][j] == '.':
                continue
            if field[i - 1][j] == field[i + 1][j] == field[i][j - 1] == field[i][j + 1] == '.':
                return False
    return True


h, w = list(map(int, input().split()))
field = ['.' + input() + '.' for _ in range(h)]
field = ['.' * (w + 2)] + field + ['.' * (w + 2)]
print('Yes' if solve(field) else 'No')


Measured memory_bytes: 3064
from collections import defaultdict
#from math import factorial
from math import sqrt

S=input()
T=input()
ds=defaultdict(str)
dt=defaultdict(str)
for s,t in zip(S,T):
    if not(s in ds.keys()):
        ds[s]=t
        continue
    elif ds[s]==t:
        continue
    else:
        print("No")
        quit()
for s,t in zip(S,T):
    if not(t in dt.keys()):
        dt[t]=s
        continue
    elif dt[t]==s:
        continue
    else:
        print("No")
        quit()
print("Yes")


Measured memory_bytes: 42548
n = int(input())
p = list(map(int,input().split()))

m = [False] * n
for i in range(n):
    if p[i] == i+1:
        m[i] = True

ans = 0
flag = False
for i in range(n):
    if flag:
        flag = False
        continue
    if m[i]:
        flag = True
        ans += 1
print(ans)

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

using namespace std;

#define debug(x,y) cout<<(#x)<<" " <<(#y)<<" is " << (x) <<" "<< (y) << endl
#define watch(x) cout<<(#x)<<" is " << (x) << endl
#define fast ios_base::sync_with_stdio(false)
#define fie(i,a,b) for(i=a;i<b;i++)
#define MOD 1000000007
#define mod 998244353
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define ll long long
#define lld long long int
#define ALL(x) (x).begin(),(x).end()

typedef vector<lld> vi;
typedef vector<vector<lld>> vii;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<pair<lld, lld>> vpi;
typedef long long LL;

//lld n, i, j, k, a[200001];

/*lld maxHalf(lld i, lld half, bool flag) {
	lld sum = 0;
	if (i < 0 || half == 0) return 0;
	if (flag) {
		sum = max(sum, max(maxHalf(i - 1, half - 1, false) + a[i], maxHalf(i - 1, half, true)));
	}
	else {
		sum = max(sum, maxHalf(n - 1, half, true));
	}
	return sum;
}*/


int main() {
	fast;
	cin.tie(0);
/*#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif*/
	lld n, i, j;
	cin >> n;
	string s;
	cin >> s;

	vi r_so_far(n, 0);
	vi g_so_far(n, 0);
	vi b_so_far(n, 0);

	for (i = 0; i < n; i++) {
		if (i != 0) {
			r_so_far[i] = r_so_far[i - 1];
			b_so_far[i] = b_so_far[i - 1];
			g_so_far[i] = g_so_far[i - 1];
		}
		if (s[i] == 'R') r_so_far[i] += 1;
		if (s[i] == 'G') g_so_far[i] += 1;
		if (s[i] == 'B') b_so_far[i] += 1;


	}
	lld count = 0;
	for (i = 0; i < n; i++) {
		for (j = i + 2; j < n; j++) {
			if (s[i] != s[j]) {
				if (s[i] == 'R' && s[j] == 'G') {
					count += b_so_far[j - 1] - b_so_far[i];
					if ((j - i + 1) & 1) {
						if (s[(i + j) / 2] == 'B') count--;
					}
				}
				if (s[i] == 'G' && s[j] == 'R') {
					count += b_so_far[j - 1] - b_so_far[i];
					if ((j - i + 1) & 1) {
						if (s[(i + j) / 2] == 'B') count--;
					}
				}
				if (s[i] == 'R' && s[j] == 'B') {
					count += g_so_far[j - 1] - g_so_far[i];
					if ((j - i + 1) & 1) {
						if (s[(i + j) / 2] == 'G') count--;
					}
				}
				if (s[i] == 'B' && s[j] == 'R') {
					count += g_so_far[j - 1] - g_so_far[i];
					if ((j - i + 1) & 1) {
						if (s[(i + j) / 2] == 'G') count--;
					}
				}
				if (s[i] == 'B' && s[j] == 'G') {
					count += r_so_far[j - 1] - r_so_far[i];
					if ((j - i + 1) & 1) {
						if (s[(i + j) / 2] == 'R') count--;
					}
				}
				if (s[i] == 'G' && s[j] == 'B') {
					count += r_so_far[j - 1] - r_so_far[i];
					if ((j - i + 1) & 1) {
						if (s[(i + j) / 2] == 'R') count--;
					}
				}
			}

		}
	}
	cout << count << endl;
}






Measured memory_bytes: 3760
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <array>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <sstream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <list>
#include <numeric>
#include <stack>
#include <iomanip>
#include <random>
#include <complex>
#include <functional>
#include <tuple>

using namespace std;

#define Rep(i,a,b) for(ll i = a; i < b; ++i)
#define rep(i,b) Rep(i,0,b)
#define allof(a) (a).begin(), (a).end()

#define Yes(q) ((q) ? "Yes" : "No")
#define YES(q) ((q) ? "YES" : "NO")
#define Possible(q) ((q) ? "Possible" : "Impossible")
#define POSSIBLE(q) ((q) ? "POSSIBLE" : "IMPOSSIBLE")

using ll = long long;

constexpr int inf = 1e9 + 7;
constexpr ll infll = 1ll << 60ll;
constexpr ll mod = 1e9 + 7;
// 0~3までは右左下上 4~7までは斜め
constexpr int dx[] = { 1, 0, -1, 0, 1, 1, -1, -1 };
constexpr int dy[] = { 0, -1, 0, 1, 1, -1, -1, 1 };

namespace {
    template<typename T> void chmax(T& a, T b) { a = std::max(a, b); }
    template<typename T> void chmin(T& a, T b) { a = std::min(a, b); }
    template<typename T> void chadd(T& a, T b) { a = a + b; }

    void Cout(long long x, const char* end = "\n") { std::cout << x << end; }
    template <typename T> void Cout(const T& x, const char* end = "\n") { std::cout << x << end; }
    template <typename T> void Cout(const std::vector<T>& x, const char* sep = " ", const char* end = "\n") { for (std::size_t i = 0, sz = x.size(); i < sz; i++) { std::cout << x[i] << (i == sz - 1 ? end : sep); } }

    // 標準入出力
    struct inp {
        std::size_t sz;
        inp(std::size_t _sz = 1) : sz(_sz) {}
        template <typename T> operator T () const { T a; std::cin >> a; return a; }
        template <typename T> operator std::vector<T>() const { std::vector<T> a(sz); for (std::size_t i = 0; i < sz; i++) std::cin >> a[i]; return a; }
    };

    // 2次元用の標準入出力
    template<typename T>
    struct inpn {
        std::size_t szi, szj;
        inpn(std::size_t _szi, std::size_t _szj) : szi(_szi), szj(_szj) {}
        operator std::vector<std::vector<T>>() const {
            std::vector<std::vector<T>> a(szi, std::vector<T>(szj));
            for (std::size_t i = 0; i < szi; ++i)
                for (std::size_t j = 0; j < szj; ++j) cin >> a[i][j];
            return a;
        }
    };

    inp inp1; // input one
}

int main() {

    string s;
    cin >> s;

    string ans = "";
    rep(i, s.length()) {
        char c = s[i] - 3;
        if (c < 'A') c += 26;
        ans += c;
    }

    Cout(ans);

    return 0;
}



Measured memory_bytes: 3052
#include <iostream>
#include <string>
#include <iomanip>
#include <math.h>
#include <vector>
#include <map>
#include <set>
#include <algorithm>

using namespace std;

int main()
{
  char c;
  cin >> c;

  if (c >= 'A')
  {
    if (c <= 'Z') cout << "A";
  }
  if(c >= 'a')
  {
    if(c <= 'z') cout << "a";
  }
}

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

char a[110][110];

int main(){
	int n,m;
	cin>>n>>m;
	for(int i=1;i<=n;i++){
		for(int j=1;j<=m;j++){
			cin>>a[i][j];
		}
	}
	for(int i=1;i<=n;i++){
		for(int j=1;j<=m;j++){
			if(a[i][j]=='#'){
				cout<<"#";
			}
			else{
				int cnt=0;
				if(a[i-1][j-1]=='#'){
					cnt++;
				}
				if(a[i-1][j]=='#'){
					cnt++;
				}
				if(a[i-1][j+1]=='#'){
					cnt++;
				}
				if(a[i][j-1]=='#'){
					cnt++;
				}
				if(a[i][j+1]=='#'){
					cnt++;
				}
				if(a[i+1][j-1]=='#'){
					cnt++;
				}
				if(a[i+1][j]=='#'){
					cnt++;
				}
				if(a[i+1][j+1]=='#'){
					cnt++;
				}
				cout<<cnt;
			}
		}
		cout<<endl;
	}
	return 0;
}


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


int main() {
  int a;
  cin >> a;
  if(30<=a){
    cout << "Yes";
  }else{
    cout << "No";
  }
  
}

Measured memory_bytes: 3616
def MI():return map(int,input().split())
def LI():return list(MI())
def ok():print("Yes");return 1
def ng():print("No");return 1


# n=int(input())

# n,m=MI()
# ans=n*(n-1)//2+m*(m-1)//2
s=input()
n=len(s)

s1=s[0:(n-1)//2]
s2=s[(n+3)//2-1:]
n1=len(s1)
n2=len(s2)


for i in range(n):
    if s[i]!=s[n-i-1]:
         ng()
         exit()
for i in range(n1):
    if s1[i]!=s1[n1-i-1]:
         ng()
         exit()
for i in range(n2):
    if s2[i]!=s2[n2-i-1]:
         ng()
         exit()
ok()


Measured memory_bytes: 3064
n,m = map(int, input().split())
A = list(map(int, input().split()))

C = [0,2,5,5,4,5,6,3,7,6]
dp = [-1]*(n+1)
dp[0] = 0

for n_i in range(n):
  for a_i in A:
    if n_i+C[a_i]<=n:
      dp[n_i+C[a_i]] = max(dp[n_i+C[a_i]], dp[n_i]*10+a_i)
      
print(dp.pop())

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

main() {
  int N, M, x;
  cin >> N >> M;
  vector<int> road(N,0);
  for(int i=0; i<M*2; i++){
    cin >> x;
    road.at(x-1)++;
  }
  for(int y=0; y<N; y++){
    cout << road.at(y) << endl;
  }    
}

Measured memory_bytes: 256
N, A = map(int, input().split())
X = list(map(int, input().split()))
sumX = 2501

dp = [[[0 for _ in range(sumX)] for _ in range(N+1)] for _ in range(N+1)]
dp[0][0][0] = 1

for j in range(N):
    for k in range(N):
        for s in range(sumX):
            if dp[j][k][s]==0:
                continue
            dp[j+1][k][s] += dp[j][k][s]
            dp[j+1][k+1][s+X[j]] += dp[j][k][s]
ans = 0

for i in range(N+1):
    ans += dp[N][i][i*A]
print(ans-1)

Measured memory_bytes: 71620
#include <bits/stdc++.h>
using namespace std;
#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#define all(x) (x).begin(), (x).end()
#define Sort(x) sort((x).begin(), (x).end())
#define Reverse(x) reverse((x).begin(), (x).end())
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i, m, n) for (int i = m; i < n; i++)
#define INF INT_MAX
#define fcout cout << fixed << setprecision(15) // 15桁まで表示
#define en '\n'
using str = string;
using ll = long long;
using ull = unsigned long long;
using ui = unsigned int;
using puu = pair<ui, ui>;
using P = pair<int, int>;
using vi = vector<int>;
int gcd(int a, int b) {
  return b ? gcd(b, a % b) : a;
};
int lcm(int a, int b) {
  return a / gcd(a, b) * b;
};
int floor(int a, int b) {
  return (a + b - 1) / b;
};
int month[12] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
template <class T> inline bool chmax(T &a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
};
template <class T> inline bool chmin(T &a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
};
const ll mod = 1000000007;
const double PI = acos(-1.0);
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << setprecision(20) << setiosflags(ios::fixed);
  int n, m;
  cin >> n>>m;
  vector<vector<P>> a(n);
  vector<P> p(m);
  rep(i,m){
    cin >> p[i].first>>p[i].second;
    a[p[i].first - 1].push_back(P(p[i].second, i));
  }
  vector<P> ans(m);
  rep(i,n){
    Sort (a[i]);
    rep(j, a[i].size()) {
      ans[a[i][j].second].second = j + 1, ans[a[i][j].second].first = i + 1;
    }
  }
  rep(i,m){
    ostringstream ss,tt;
    ss << setw(6) <<setfill('0') << ans[i].first;
    tt << setw(6) << setfill('0') << ans[i].second;
    string s(ss.str()),t(tt.str());
    cout << s << t << en;
  }
}

Measured memory_bytes: 10176
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <queue>
using namespace std;
#define LL long long
#define inf 0x3f3f3f3f
#define test freopen("in.txt","r",stdin);freopen("out.txt","w",stdout);
int main()
{
    //test
    int n;
    cin>>n;
    int ans=n>>1;
    if(n%2==0) ans--;
    cout<<ans;
    return 0;
}

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

int main() {
  long long n, k, l, ans, buff;
  buff = 1000000000000000000;
//  bool judge = 0;
  cin >> n >> k;
  if((n == 0) || (n == k)){
    ans = 0;
  }
  else{
    n = n % k;
    while(1){
      n = abs(n - k);
	  if(buff <= n){
        break;
      }
      buff = n;
    }
    ans = buff;
  }  
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>
#include <math.h>
#include <iomanip>
#include <limits>
#include <list>
#include <queue>
#include <tuple>
#include <map>
using namespace std;
#define MOD (long long int)(1e9+7)
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define INF (int)(1123456789)
#define LINF (long long int)(112345678901234567)
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define PB push_back
#define SP << " " <<

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VL;
typedef vector<VL> VLL;

__attribute__((constructor))
void initial(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed <<setprecision(15);
}


int main(void){
	int N;
    VL A;
    cin >> N;
    rep(i,N){
        ll a;
        cin >> a;
        A.PB(a);
    }

    sort(all(A));
    
    string ans = "YES";

    rep(i,N){
        if(i>0){
            if(A[i-1]==A[i]){
                ans = "NO";
            }
        }
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 2420
#include<stdio.h>
int main(){
  int a;
  double b=0;
  scanf("%d",&a);
  for(int i=0; i<a; i++){
    double c;
    char s[4];
    scanf("%lf %s",&c,s);
    if(s[0]=='J'){
      b+=c;
    }else{
      b+=c*380000;
    }
  }
  printf("%.6lf",b);
  return 0;}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
int main(){
  int a,b,c,k;
  cin >>a>>b>>c>>k;
  long ans=0;
  if (k <= a){
    cout << k;
    return 0;
  }
  else if(k <= a+b){
    cout << a;
    return 0;
  }
  else{
    ans = 2*a+b-k;
    cout << ans;
    return 0;
  }
}

Measured memory_bytes: 3584
let sentinel = ('Z', 1000000001)

let merge_sort a cmp =
  let merge l m r =
    let ni = m - l in
    let nj = r - m in
    let init_ary n p =
      Array.init (n + 1) (fun i -> if i = n then sentinel else a.(p + i))
    in
    let ai = init_ary ni l in
    let aj = init_ary nj m in
    let rec doit i j k =
      if k = r then ()
      else begin
        if cmp ai.(i) aj.(j) <= 0 then (a.(k) <- ai.(i); doit (i + 1) j (k + 1))
        else (a.(k) <- aj.(j); doit i (j + 1) (k + 1))
      end
    in
    doit 0 0 l
  in
  let rec doit l r =
    if (l + 1) < r then begin
      let m = (l + r) / 2 in
      doit l m;
      doit m r;
      merge l m r
    end
  in
  doit 0 (Array.length a)

let quick_sort a cmp =
  let partition p r =
    let x = a.(r) in
    let swap i j =
      let t = a.(i) in a.(i) <- a.(j); a.(j) <- t
    in
    let rec doit i j =
      if j >= r then i
      else begin
        if cmp a.(j) x <= 0 then (swap (i + 1) j; doit (i + 1) (j + 1))
        else doit i (j + 1)
      end
    in
    let i = doit (p - 1) p in
    swap (i + 1) r;
    i + 1
  in
  let rec doit p r =
    if p < r then begin
      let q = partition p r in
      doit p (q - 1);
      doit q r
    end
  in
  doit 0 (Array.length a - 1)

let stable_p a b equal =
  let n = Array.length a in
  let rec doit i =
    if i = n then true
    else if equal a.(i) b.(i) then doit (i + 1)
    else false
  in
  doit 0

let () =
  let n = read_int () in
  let a = Array.init n (fun _ -> Scanf.scanf "%c %d\n" (fun c d -> (c, d))) in
  let b = Array.copy a in
  merge_sort a (fun (_, x) (_, y) -> compare x y);
  quick_sort b (fun (_, x) (_, y) -> compare x y);
  Printf.printf "%s\n" (if stable_p a b (fun (xc, xd) (yc, yd) -> xc = yc && xd = yd) then "Stable" else "Not stable");
  Array.iter (fun (c, d) -> Printf.printf "%c %d\n" c d) b

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

using namespace std;

typedef long long llint;

const int MAXN = 100005;

llint n;
llint a[MAXN], dp[2][MAXN];

int main () {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cin >> n;
    for (int i=1; i<=n; i++) {
        cin >> a[i];
        dp[0][i] = dp[0][i-1] + a[i]/2;
        if (a[i] > 0 && a[i-1] > 0) dp[0][i] = max(dp[0][i], dp[1][i-1] + 1 + (a[i] - 1)/2);
        dp[1][i] = dp[0][i-1] + (a[i] - 1)/2;
        if (a[i]-1 > 0 && a[i-1] > 0) dp[1][i] = max(dp[1][i], dp[1][i-1] + 1 + (a[i] - 2)/2);
    }
    cout << dp[0][n];
    return 0;
}


Measured memory_bytes: 2560
S = input()
Q = int(input())
reverse = False
front = ""
end = S

for _ in range(Q):
    I = input().split()
    if I[0] == "1":
        reverse = not reverse
    else:
        if (I[1] == "1") ^ reverse:
            front =front + I[2]
        else:
            end = end + I[2]


if reverse:
    print("".join(list(reversed(end)))+front)
else:
    print("".join(list(reversed(front)))+end)


Measured memory_bytes: 5164
#include <bits/stdc++.h>
using namespace std;
struct Node {
  int key;
  Node *parent = nullptr, *left = nullptr, *right = nullptr;
};
void insert(Node *root, int key) {
  auto x = root;
  auto *parent = x->parent;

  while (x != nullptr) {
    parent = x;
    if (x->key > key) {
      x = x->left;
    } else {
      x = x->right;
    }
  }

  if (parent->key > key) {
    parent->left = new Node{key, parent, nullptr, nullptr};
  } else {
    parent->right = new Node{key, parent, nullptr, nullptr};
  }
}
void printNodePreOrder(Node *root) {
  if (root == nullptr) return;
  cout << ' ' << root->key;
  printNodePreOrder(root->left);
  printNodePreOrder(root->right);
}
void printNodeInOrder(Node *root) {
  if (root == nullptr) return;
  printNodeInOrder(root->left);
  cout << ' ' << root->key;
  printNodeInOrder(root->right);
}
int main() {
  string op;
  int m, k;
  Node *root = nullptr;
  cin >> m;
  for (size_t i = 0; i < m; i++) {
    cin >> op;
    if (op == "insert") {
      cin >> k;
      if (root == nullptr) {
        root = new Node{k};
      } else {
        insert(root, k);
      }

    } else if (op == "print") {
      printNodeInOrder(root);
      cout << endl;
      printNodePreOrder(root);
      cout << endl;
    }
  }
}



Measured memory_bytes: 26512
//
// Created by 李青坪 on 2018/10/23.
//

#include <cstdio>
#include <string>
#include <iostream>

using namespace std;

struct Node{
    int value;
    Node *parent, *left, *right;
};
Node *head, *NIL;

void insertNode(int value){
    Node *x = head;
    Node *y = NIL;  //表示父节点
    while (x != NIL){
        y = x;
        if (value < x->value){
            x = x->left;
        }
        else{
            x = x->right;
        }
    }
    Node *z = new(Node);
    z->value = value;
    z->left = NIL;
    z->right = NIL;
    if (y != NIL){
        if (z->value < y->value){
            y->left = z;
        }
        else{
            y->right = z;
        }
        z->parent = y;
    } else{
        head = z;
    }
}

bool findNode(Node *root, int value ){
    if (root == NIL) return false;
    if (root->value == value) return true;
    bool left= false, right= false;
    if (root->value < value)
        right = findNode(root->right, value);
    if (root->value > value)
        left = findNode(root->left, value);
    return left || right;
}

void inOrder(Node *x){
    if (x != NIL){
        inOrder(x->left);
        printf(" %d", x->value);
        inOrder(x->right);
    }
}

void preOrder(Node *x){
    if (x != NIL){
        printf(" %d", x->value);
        preOrder(x->left);
        preOrder(x->right);
    }
}

int main(){
    int n;
    scanf("%d", &n);
    head = NIL;
    char command[10];
    int value;
    for (int i = 0; i < n; ++i) {
        scanf("%s", command);
        if (command[0] == 'i'){
            scanf("%d", &value);
            insertNode(value);
        } else if(command[0] == 'f'){
            scanf("%d", &value);
            if (findNode(head, value)) printf("yes\n");
            else printf("no\n");
        }
        else{
            inOrder(head);
            printf("\n");
            preOrder(head);
            printf("\n");
        }
    }
    return 0;
}
/*
8
insert 30
insert 88
insert 12
insert 1
insert 20
insert 17
insert 25
print
 */


Measured memory_bytes: 21972
n = int(input())
d = [int(v) for v in input().split()]

d.sort()
cnt = 0
if d[n//2] - d[n//2-1] > 1:
    cnt += d[n//2] - d[n//2-1] - 1
if d[n//2] > d[n//2-1]:
    cnt += 1
print(cnt)


Measured memory_bytes: 52780
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <climits>
#include <algorithm>
#include <string>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <numeric>
#include <iostream>

using namespace std;

#define FOR(i, a, b)   for(int i = (a); i < (b); ++i)
#define RFOR(i, a, b)  for(int i = (a); i > (b); --i)
#define rep(i, n)      for(int i = 0; i < (n); ++i)
#define all(c)         begin(c), end(c)
#define rall(c)        rbegin(c), rend(c)
#define SZ(a)          ((ll) a.size())

typedef long long ll;
typedef unsigned long long ull;


int main(){
	ll N;
	cin >> N;
	vector<ll> A(N);
	rep(i,N) cin >> A[i];
	ll ans=0;
	bool flag=false;
	while(1){
		rep(i,N){
			if(A[i]%2==1) flag = true;
		}
		if(flag){
			printf("%lld",ans);
			break;
		}
		ans++;
		rep(i,N){
			A[i]=A[i]/2;
		}
	}
  return 0;
}


Measured memory_bytes: 256
import sys
input = sys.stdin.readline

def main():
    a,b,c = map(int, input().split())
    from decimal import Decimal
    if Decimal(a).sqrt() + Decimal(b).sqrt() < Decimal(c).sqrt():
        print("Yes")
    else:
        print("No")

if __name__ == '__main__':
    main()


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

using int64 = long long;
const int64 kMod = 1000000007;

enum Previous {
  Vertical,
  Horizontal,
};

int main() {
  int64 n;
  cin >> n;
  string s1, s2;
  cin >> s1 >> s2;

  int64 ret = 1;
  Previous prev = Vertical;
  for (int64 i = 0; i < n; ++i) {
    if (i == 0) {
      if (s1[i] == s2[i]) {
        ret = 3;
        prev = Vertical;
      } else {
        ret = 3 * 2;
        prev = Horizontal;
        ++i;
      }
      continue;
    }

    if (s1[i] == s2[i]) {
      if (prev == Vertical) {
        ret = ret * 2 % kMod;
      }
      prev = Vertical;
    } else {
      if (prev == Vertical) {
        ret = ret * 2 % kMod;
      } else {
        ret = ret * 3 % kMod;
      }
      prev = Horizontal;
      ++i;
    }
  }
  cout << ret << "\n";

  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>

using namespace std;

int main(){
    int X;
    cin >> X;
    for(long long i=-200; i<200; i++){
        for(long long j=-200; j<200; j++){
            if (i*i*i*i*i - j*j*j*j*j == X){
                cout << i << ' ' << j << endl;
                return 0;
            }
        }   
    }
}

Measured memory_bytes: 3648
#include <iostream>
   
inline bool isRightTriangle(const u_int a, const u_int b, const u_int c){
    return (a*a == b*b + c*c || b*b == c*c + a*a || c*c == a*a + b*b);
}
   
int main(){
    u_int n;
    std::cin >> n;
      
    for (u_int i = 0; i < n; ++i){
        u_int a, b, c;
        std::cin >> a >> b >> c;
        std::cout << (isRightTriangle(a, b, c) ? "YES" : "NO") << std::endl;
    }
   
    return 0;
}

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

int main () {
    int n;
    cin >> n;
    for (int i = 1; i <= n; i++) {
        if (i %  3 == 0) {
            cout << " " << i;
            continue;
        } else if (i % 10 == 3) {
            cout << " " << i;
            continue;
        }
        int x = i;
        while (x > 3) {
            x /= 10;
            if (x % 10 == 3) {
                cout << " " << i;
                break;
            }
        } 
    }
    cout << endl;
    return 0;
}


Measured memory_bytes: 3116
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define inf 1001001001
#define mod 1000000007
#define pi 3.141592653589793
#define all(v) v.begin(),v.end()
typedef vector<int> vi;
typedef vector<ll> vl;
ll gcd(ll a,ll b){
    if(b>a) swap(a,b);
    if(b==0) return a;
    return gcd(b,a%b);
}
ll lcm(ll a,ll b){
    ll g=gcd(a,b);
    return a/g*b;
}
ll rep_jijo(ll n,ll x){
    if(x==0) return 1;
    if(x%2==0){
        ll t=rep_jijo(n,x/2);
        return t*t%mod;
    }
    return n*rep_jijo(n,x-1)%mod;
}
ll com(ll n,ll r){
    ll x=1,y=1;
    ll tmp=n;
    while(tmp>=n-r+1){
        x=x*tmp%mod;
        tmp--;
    }
    while(r>0){
        y=y*r%mod;
        r--;
    }
    return x*rep_jijo(y,mod-2)%mod;
}

int main(){
    int a,b,c,d;
    int x;
    cin >> a >> b >> c >> d;
    bool flag=true;
    while(1){
        if(a<=0) {
            x=1;
            break;
        }
        if(c<=0){
            x=2;
            break;
        }
        if(flag){
            c-=b;
            flag=false;
        }
        else if(!flag){
            a-=d;
            flag=true;
        }
    }
    if(x==1) cout << "No" <<endl;
    else cout << "Yes" <<endl;

    return 0;
}


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

#define pb push_back
using ll = long long;

const int mx = 2e3+5;
const int inf = 1e9+9;
const int mod = 1e9+7;

int n, ans[mx];
vector<int> adj[mx];

void bfs(int s){
    vector<int> vis(n+5, 0);
    vector<int> dis(n+5, inf);

    vis[s] = 1; dis[s] = 0;
    queue<int> q; q.push(s);
    while(q.size()){
        int u = q.front(); q.pop();
        for(int &v:adj[u]){
            if(!vis[v]){
                vis[v] = 1;
                dis[v] = dis[u]+1;
                if(v>s) ans[dis[v]]++;
                q.push(v);
            }
        }
    }
}

int main(int argc, const char** argv) {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);

    int x, y;

    cin >> n;
    for(int i=1; i<n; i++){
        adj[i].pb(i+1);
        adj[i+1].pb(i);
    }
    cin >> x >> y;
    adj[x].pb(y);
    adj[y].pb(y);

    for(int i=1; i<n; i++)
        bfs(i);

    for(int i=1; i<n; i++)
        cout << ans[i] << '\n';
    return 0;
}

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

int main() {
    int N, Q;
    cin >> N;
    long long sum = 0;
    vector<long long> num(110000, 0);
    for (int i = 0; i < N; ++i) {
        long long A; cin >> A;
        sum += A;
        num[A]++;
    }

    cin >> Q;
    for (int i = 0; i < Q; ++i) {
        long long B, C; cin >> B >> C;
        sum += (C - B) * num[B];
        num[C] += num[B];
        num[B] = 0;
        cout << sum << endl;
     }
}


Measured memory_bytes: 4004
#include <bits/stdc++.h>  // g++ -std=c++14 -o a a.cpp

using namespace std;

typedef pair<int, int> P;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define repto(i, n) for(int i = 0; i <= (n); i++)
#define all(c) (c).begin(), (c).end()
#define uniq(c) c.erase(unique(all(c)), (c).end()) // ユニークなvectorにする。連続した値を除去して切り出す。
#define _1 first
#define _2 second
#define pb push_back
#define INF 1145141919
#define MOD 1000000007
#define DEBUG(x) cout << #x << ": " << x << endl;

__attribute__((constructor))
void initial() {
  cin.tie(0);
  ios::sync_with_stdio(false);
}

int main() {
  int N;
  cin >> N;
  vector<int> X;
  rep(i, N) {
    int xi;
    cin >> xi;
    X.pb(xi);
  }
  vector<int> sortedX = X;
  sort(all(sortedX));

  // rep(i, N) {
  //   DEBUG(sortedX[i]);
  // }

  int medianIndex = N / 2;
  int median1 = sortedX[medianIndex - 1];
  int median2 = sortedX[medianIndex];

  rep(i, N) {
    if (X[i] <= median1) {
      cout << median2 << endl;
    } else if (X[i] >= median2) {
      cout << median1 << endl;
    } else {
      cout << median1 << endl;
    }
  }
}


Measured memory_bytes: 3956
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <limits>
#include <numeric>
using namespace std;


int main()
{
	long hi;
	cin >> hi;

	long h = hi;
	long d = 0;
	while (h > 1) {
		h /= 2;
		d++;
	}

	unsigned long long int a = pow(2, d + 1) - 1;

	cout << a;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		while(sc.hasNext()){
			int n = sc.nextInt();
			int q = sc.nextInt();
			
			int[] p = new int[300001];
			for(int i=0;i<n;i++){
				p[sc.nextInt()]++;
			}
			
			int a = 0;
			int k = 0;
			int ans = 0;
			for(int i=0;i<q;i++){
				a = sc.nextInt();
				for(int j=1;j<300001;j++){
					k = 1;
					while(a*k-j<300001){
						if(p[a*k-j]!=0){
							ans = a-j;
							j = 300001;
							break;
						}
						k++;
					}
				}
				System.out.println(ans);
			}
		}
	}	
}

Measured memory_bytes: 144436
#include <bits/stdc++.h>
using namespace std;
#define endl "\n"
#define watch(x) cout << #x << " is " << x << endl;
#define print(a, l, r) \
    for (int i = l; i < r; i++) cout << a[i] << (i == (r - 1) ? endl : " ");
const long long M = 1000000007;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    long long n, m;
    cin >> n >> m;

    long long ans = (n * (n - 1)) / 2 + (m * (m - 1)) / 2;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 384
import java.util.ArrayDeque;
import java.util.Deque;
import java.util.Scanner;

public class Main {
//	static int top;
//	static int MAX;
//	static int S[] = new int[MAX];
//	
//	static void initialize() {
//		top = 0;
//	}
//	
//	static boolean isEmpty() {
//		return top == 0;
//	}
//	
//	static boolean isFull() {
//		return top >= MAX - 1;
//	}
//	
//	static void push(int x) {
//		if(! isFull()) {
//			top++;
//			S[top] = x;
//		}
//	}
//	
//	static int pop(){
//		if(! isEmpty()) {
//			top--;
//			return S[top + 1];
//		}
//		return MAX;
//	}
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		Deque<Integer> s = new ArrayDeque<>();
		String[] t = sc.nextLine().split(" ");
		for(int i = 0; i < t.length; i++) {
			String a = t[i];
			if(a.equals("+")) {
				int x = s.pop();
				int y = s.pop();
				s.push(x + y);
			}
			else if(a.equals("-")) {
				int x = s.pop();
				int y = s.pop();
				s.push(y - x);
			}
			else if(a.equals("*")) {
				int x = s.pop();
				int y = s.pop();
				s.push(x * y);
			}
			else {
				int x = Integer.parseInt(a);
				s.push(x);
			}
		}
		System.out.println(s.pop());
	}
}



Measured memory_bytes: 26308
#include <bits/stdc++.h>
using namespace std;
int main(){
    int r,D,x;
    int a;
    vector<int> ans ;
    cin >> r >> D >> x;
    a = x*r -D;
    ans.push_back(a);
    
    for(int i=1; i<10; i++){
        a = a*r -D;
        ans.push_back(a);
        
    }

    for(int i=0; i<10; i++){
        cout << ans.at(i) << endl;
    }
}

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

int main(int argc, char *argv[]) {
  ios::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr);

  ll n,k;cin>>n>>k;
  ll ans=1;
  ll mod=pow(10,9)+7;

  ll l=0, lv=0;
  ll r=0, rv=0;
  for(ll i=0;i<k;i++){l=i;lv+=i;r=n-i;rv+=n-i;}
  for(ll i=k;i<=n;i++){
    ans += (rv-lv+1ll) % mod;
    ans %= mod;
    lv += (++l);
    rv += (--r);
  }
  cout<<ans<<endl;

  return 0;
}


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

#define ntest 0

using namespace std;

int n;
long long a[200005];
long long res, mx;
void solve() {
    cin >> n;
    for (int i = 1; i <= n; ++i) cin >> a[i];
    mx = a[1];
    for (int i = 1; i <= n; ++i) {
        res += max(0LL, mx - a[i]);
        mx = max(mx, a[i]);
    }
    cout << res << '\n';
}
int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    if(ntest){
        int t;
        cin >> t;
        while(t--) solve();
    } else {
        solve();
    }

}




Measured memory_bytes: 5144
#include<bits/stdc++.h>
using namespace std;
const int INF = 1 << 28;


void Floyd_Warshall(vector< vector< int > >& graph){
  for(int k = 0; k < graph.size(); k++){
    for(int i = 0; i < graph.size(); i++){
      for(int j = 0; j < graph.size(); j++){
        graph[i][j] = min( graph[i][j], graph[i][k] + graph[k][j]);
      }
    }
  }
  return ;
}

int main() {
  int n, m;
  vector< vector< int > > graph1, graph2;

  while(cin >> n >> m, n){
    graph1.assign(m, vector< int >(m, INF));
    graph2.assign(m, vector< int >(m, INF));
    for(int i = 0; i < n; i++){
      int a, b, cost, time;
      cin >> a >> b >> cost >> time;
      --a, --b;
      graph1[a][b] = graph1[b][a] = cost;
      graph2[a][b] = graph2[b][a] = time;
    }
    Floyd_Warshall(graph1);
    Floyd_Warshall(graph2);

    int k;
    cin >> k;
    while(k--){
      int p, q, r;
      cin >> p >> q >> r;
      --p, --q;
      if(r == 0) cout << graph1[p][q] << endl;
      else cout << graph2[q][p] << endl;
    }
  }
}

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

using namespace std;

#define rep(i, a) for (int (i) = 0; (i) < (a); (i)++)
#define reps(i, a, b) for (int (i) = (a); (i) < (b); (i)++)
#define MP(a, b) make_pair((a), (b))
#define pb(a) push_back((a))
#define all(v) (v).begin(), (v).end()

int N, K;

int main()
{
	cin >> N >> K;
	int res = 0;
	rep(i, N) {
		int x;
		cin >> x;
		res += min(x, K-x);
	}
	cout << res * 2 << endl;
}




Measured memory_bytes: 256
program therefore
 implicit none
 character s*10,t*11
 integer a,b,c
 read *, s
 read *, t
 
 b = len_trim(s)
 c = len_trim(t)
 if ( c-b == 1 .and. s== t(:b) ) then
 print *,"Yes"
 else
 print *,"No"
 end if
end program therefore
 


Measured memory_bytes: 2784
import sys
import os
import math

ii = lambda: int(sys.stdin.buffer.readline().rstrip())
il = lambda: list(map(int, sys.stdin.buffer.readline().split()))
fl = lambda: list(map(float, sys.stdin.buffer.readline().split()))
iln = lambda n: [int(sys.stdin.buffer.readline().rstrip()) for _ in range(n)]

iss = lambda: sys.stdin.buffer.readline().decode().rstrip()
sl = lambda: list(map(str, sys.stdin.buffer.readline().decode().split()))
isn = lambda n: [sys.stdin.buffer.readline().decode().rstrip() for _ in range(n)]

MOD = 10 ** 9 + 7


def main():
    if os.getenv("LOCAL"):
        sys.stdin = open("input.txt", "r")

    N = iss()
    print('Yes' if N.find('7') != -1 else 'No')



if __name__ == '__main__':
    main()


Measured memory_bytes: 9152
package main

import (
	"fmt"
	"strconv"
)

func main() {
	var n int
	fmt.Scan(&n)

	c := make([][]int64, 10, 10)
	for i := 0; i < 10; i++ {
		c[i] = make([]int64, 10, 10)
	}

	for i := 1; i <= n; i++ {
		s := strconv.Itoa(i)
		c[s[0] - '0'][i % 10]++
	}

	var answer int64 = 0
	for i := 1; i <= 9; i++ {
		for j := 1; j <= 9; j++ {
			answer += c[i][j] * c[j][i]
		}
	}
	fmt.Println(answer)
}

Measured memory_bytes: 1792
A, B = (int(x) for x in input().split())
A_min = A / 0.08
A_max = (A + 1) / 0.08
B_min = int(B / 0.10)
B_max = int((B + 1) / 0.10)
ans = '-1'

for i in range(B_min, B_max):
    if i >= A_min and i < A_max:
        ans = i
        break

print(ans)

Measured memory_bytes: 3060
program name
    use,intrinsic :: iso_fortran_env
    implicit none
    character(100000):: s
    integer(int32):: cnt(3),l,i

    read*, s
    l= len_trim(s)
    cnt(:) = 0
    do i=1,l
        cnt(ichar(s(i:i))-ichar('a')+1)=cnt(ichar(s(i:i))-ichar('a')+1)+1
    end do

    if (maxval(cnt) - minval(cnt) <= 1) then
        print'(a)', 'YES'
    else
        print'(a)', 'NO'
    end if
end program name

Measured memory_bytes: 700
habitant_dictionary = {}
for building in range(1, 4 + 1):
    habitant_dictionary[building] = [0] * 30

information_number = int(raw_input())
while 0 < information_number:
    data = [int(x) for x in raw_input().split()]
    habitant_dictionary[data[0]][(int(data[1]) - 1) * 10 + (int(data[2]) - 1)] += int(data[3])
    information_number -= 1

for building in range(1, 4 + 1):
    for i in range(0, 30, 10):
        print(' ' + ' '.join([str(x) for x in habitant_dictionary[building][i:i + 10]]))
    if building is not 4:
        print('#' * 20)

Measured memory_bytes: 6420
#include <stdio.h>
 
int main(void)
{
  int m,n;
  int a[1000];
  int i,sum=0;
  int flag=0;
  
  do{
    scanf("%d %d",&n,&m);
  } while((n<1 || n>100) || ((m<1 || m>100) || m>n));
  
  for(i=1; n>=i; i++){
    do{
      scanf("%d ",&a[i]);
    } while(a[i]<1 || a[i]>1000);
    sum += a[i];
  }
  for(i=1; n>=i; i++)
    if(a[i]*(4*m)>=sum)
      flag++;
  
  if(m<=flag)
    puts("Yes");
  else
    puts("No");
  
  return 0;
}

Measured memory_bytes: 1632