akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
int n , q;
char s[200010];
int move[26];
pair<char, char> op[200010];
bool check(int pos, int flag) {
  for (int i = 1; i <= q; ++i) 
  {
    if (op[i].first == s[pos]) {

      if (op[i].second == 'L')
        --pos;
      else ++pos;
    }
    if (pos == 0){
      if (flag == 0) return true;
      return false;
    } 
    if (pos == n + 1) {
      if (flag) return true;
      return false;
    }
  }
  return false;
} 
int main() {
  ios::sync_with_stdio(false);
  cin >> n >> q >> (s + 1);
  // scanf("%s", s + 1);
  for (int i = 1; i <= q; ++i)
    cin >> op[i].first >> op[i].second;
  int l = 1, r = n, left = 0, right = n + 1;
  while (l <= r) {
    int mid = (l + r) >> 1;
    if (check(mid, 0))
      left = max(mid, left), l = mid + 1;
    else r = mid - 1;
  }
  l = 1, r = n;
  while (l <= r) {
    int mid = (l + r) >> 1;
    if (check(mid, 1))
      right = min(right, mid), r = mid - 1;
    else l = mid + 1;
  }
  cout << n - (left  + n + 1 - right);
}

Measured memory_bytes: 896
/**
   Solution by Abil
**/
# include <bits/stdc++.h>

# define fr first
# define sc second
# define pb push_back
# define mk make_pair
# define sz(s) s.size()
# define all(s) s.begin(),s.end()
# define int long long

using namespace std;

const long long N = (1e5 + 10);
const long long mod = (1e9 + 7);
const long long inf = (1e9 + 7);

int dp[N],arr[N];

main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);cout.tie(0);
    int n;
    cin >> n;
    for(int i = 1;i <= n; i++){
        cin >> arr[i];
    }
    dp[1] = 0;
    dp[2] = abs(arr[1] - arr[2]);
    for(int i = 3;i <= n; i++){
        dp[i] = min(abs(arr[i - 1] - arr[i]) + dp[i - 1],abs(arr[i - 2] - arr[i]) + dp[i - 2]);
    }
    cout << dp[n];
}


Measured memory_bytes: 1792
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)
n = int(input())
edges = [[]for _ in range(n)]
for _ in range(n-1):
    u, v, w = map(int, input().split())
    edges[u-1].append((w, v-1))
    edges[v-1].append((w, u-1))


color = [-1]*n


def dfs(v, d, parent):
    color[v] = d & 1
    for d2, v2 in edges[v]:
        if v2 == parent:
            continue
        dfs(v2, d+d2, v)


dfs(0, 0, -1)
print(*color, sep='\n')

Measured memory_bytes: 81332
import sys 
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
N = int(readline())
x,y,z = 0,0,0 #最後にやったものの幸福度最大値
for i in range(N):
  a,b,c = map(int, readline().split())
  x,y,z = max(y,z)+a,max(x,z)+b,max(x,y)+c

print(max(x,y,z))

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

int main()
{
  ll n;string s;cin>>n>>s;
  for(ll i=0;i<s.length();i++){
    ll offset=s[i]-'A';
    offset=(offset+n)%26;
    s[i]='A'+offset;
  }
  cout<<s<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <string>
#include <vector>
#include <algorithm>
#include <set>
#include <queue>
#include <deque>
#include <map>
#include <stack>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;

#define rep(i, up) for (ll i = 0; i < up; ++i)
#define repp(i, up) for (ll i = 0; i <= up; ++i)
#define rrep(i, lo, up) for (ll i = lo; i < up; ++i)
#define rrepp(i, lo, up) for (ll i = lo; i <= up; ++i)
#define eep(i, lo, up) for ((i) = (lo); (i) < (up); ++(i))
#define eepp(i, lo, up) for ((i) = (lo); (i) <= (up); ++(i))

#define rdi(i) ll i; scanf("%lld", &i)
#define rds(s) string s; cin >> s
#define rdc(c) char c; cin >> c

#define INF 10000000000
#define MOD 1000000007

ll gcd(ll a, ll b)
{
    if (a < b) {
        return gcd(b, a);
    }
    ll r;
    while (r = a % b) {
        a = b;
        b = r;
    }
    return b;
}

int main()
{
    ll n, k;
    cin >> n >> k;
    vector<ll> as(n);
    vector<ll> work(n);
    rep(i, n) {
        cin >> as[i];
        --as[i];
        work[i] = i;
    }
    stack<ll> bits;
    while (k > 0) {
        if (k % 2 == 0) {
            bits.push(0);
            k /= 2;
        } else {
            bits.push(1);
            --k;
        }
    }
    while (!bits.empty()) {
        ll top = bits.top();
        bits.pop();

        vector<ll> buff = work;
        if (top) {
            rep(i, n) {
                buff[i] = as[work[i]];
            }
        } else {
            rep(i, n) {
                buff[i] = work[work[i]];
            }
        }
        work = buff;
    }

    cout << work[0] + 1 << endl;
    return 0;
}

Measured memory_bytes: 7636
#include <stdio.h>

int main(void)
{
	int a[4];
	int b[4];
	int i;
	int j;
	int hit = 0;
	int blow = 0;
	
	while (scanf("%d", &a[0]) != EOF){
		for (i = 1; i < 4; i++){
			scanf("%d", &a[i]);
		}
		for (i = 0; i < 4; i++){
			scanf("%d", &b[i]);
		}
		for (i = 0; i < 4; i++){
			for (j = 0; j < 4; j++){
				if (b[i] == a[j]){
					if (i == j){
						hit++;
					}
					else {
						blow++;
					}
				}
			}
		}
		printf("%d %d\n", hit, blow);
		hit = 0;
		blow = 0;
	}
	
	return 0;
}

Measured memory_bytes: 596
#include<bits/stdc++.h>
#define rep(i, n) for(int (i) = 0; (i) < (n); (i)++)
#define printd(x) printf("%.12f\n", ans);
#define print(x) cout << (x) << endl;
#define Yes() cout << "Yes" << endl;
#define No() cout << "No" << endl;
#define YES() cout << "YES" << endl;
#define NO() cout << "NO" << endl;
#define all(x) (x).begin(),(x).end()
#define printa(x, n) for(ll i = 0; i < n; i++) {cout << (x[i]) << " ";} cout << endl;
template<class T> bool chmin(T& a, const T& b) {if (a > b) {a = b; return 1;} return 0;}
template<class T> bool chmax(T& a, const T& b) {if (a < b) {a = b; return 1;} return 0;}
using namespace std;
using ll = long long;
using pll = pair<ll, ll>;

int main(void) {
    int n;
    cin >> n;
    ll a[n + 1];
    rep (i, n) cin >> a[i + 1];

    vector<ll> l(n, 1), r(n + 2, 1);

    l[1] = a[1];
    for (int i = 2; i <= n - 1; i++) {
        l[i] = __gcd(l[i - 1], a[i]);
    }

    r[n] = a[n];
    for (int i = n - 1; i >= 2; i--) {
        r[i] = __gcd(r[i + 1], a[i]);
    }

    ll ans = 0;
    chmax(ans, r[2]);
    chmax(ans, l[n - 1]);
    for (int i = 2; i <= n - 1; i++) {
        chmax(ans, __gcd(l[i - 1], r[i + 1]));
    }
    
    cout << ans << endl;
    return 0;
}

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

using namespace std;

using ll = long long;

constexpr char newl = '\n';

template<typename T>
map<T, int> prime_factor(T n) {
    map<T, int> res;
    for (T i = 2; i * i <= n; i++) {
        while (n % i == 0) {
            ++res[i];
            n /= i;
        }
    }
    if (n != 1) res[n] = 1;
    return res;
}

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

    ll n;
    cin >> n;

    auto memo = prime_factor(n);
    int ans = 0;
    for (auto& p : memo) {
        int i = 1;
        while (p.second >= i) {
            p.second -= i;
            ++i;
            ++ans;
        }
    }
    cout << ans << newl;

    return 0;
}

Measured memory_bytes: 3632
(*
ocamlfind ocamlopt -package batteries -linkpkg main.ml -o a.out
*)
open Batteries

let lst = Str.split (Str.regexp "") (read_line ())
          |> List.sort compare
let lst2 = List.sort_uniq compare lst
let lst3 = 
        List.map (fun elmnt1 ->
                List.filter (fun elmnt2 ->
                        elmnt1 = elmnt2
                ) lst
        ) lst2
let lst4 = List.map (fun elst ->
        List.length elst
) lst3

let () =
        (
                if List.exists (fun elmnt -> elmnt mod 2 = 1) lst4 then
                        "No"
                else
                        "Yes"
        ) |> Printf.printf "%s\n"


Measured memory_bytes: 1152
#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>

//#include "All.h"

using namespace std;

#define EPS (1e-9)
#define INF (1e9)
#define PI (acos(-1))
#define REP(i,a,n) for(int i=a;i<n;i++)
#define rep(i, n) REP(i,0,n)

#define Yes(q) ((q) ? "Yes" : "No")
#define YES(q) ((q) ? "YES" : "NO")

using ll = long long int;

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

ll beki(ll a, ll b) {
    ll tmp = 1;
    rep(i, b) tmp *= a;
    return tmp;
}

ll A, B, N;

int main() {
    int a;
    cin >> a;
    cout << a + a * a + a * a * a << endl;
}

Measured memory_bytes: 3592
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp>
#include <functional>
#include <unistd.h>
using namespace std;
using namespace std::chrono;
using namespace __gnu_pbds;
#define ll  int
//mp.reserve(1024);
//mp.max_load_factor(0.25);
typedef tree<int, null_type, less<int>, rb_tree_tag,
                 tree_order_statistics_node_update>
          ordered_set;
struct custom_hash {
    static uint64_t splitmix64(uint64_t x) {
            x += 0x9e3779b97f4a7c15;
            x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
            x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
            return x ^ (x >> 31);
        }

        size_t operator()(uint64_t x) const {
            static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
            return splitmix64(x + FIXED_RANDOM);
        }
};

void addEdge(vector<ll> adj[], ll u, ll v)
{
   adj[u].push_back(v);
   adj[v].push_back(u);
}
vector<ll> z_function(string s) {
    ll n = s.length();
    vector<ll> z(n);
    for (ll i = 1, l = 0, r = 0; i < n; ++i) {
        if (i <= r)
            z[i] = min (r - i + 1, z[i - l]);
        while (i + z[i] < n && s[z[i]] == s[i + z[i]])
            ++z[i];
        if (i + z[i] - 1 > r)
            l = i, r = i + z[i] - 1;
    }
    return z;
}
ll mod=1e9+7;
ll power(ll x,ll y)
{
    ll res = 1; // Initialize result

    while (y > 0) {
        // If y is odd, multiply x with result
        if (y & 1)
            res = ((res%mod) * (x%mod))%mod;

        // n must be even now
        y = y >> 1; // y = y/2
        x = ((x%mod) * (x%mod))%mod; // Change x to x^2
    }
    return res;
}

int main()
{
 	ios_base::sync_with_stdio(false);
   	cin.tie(NULL);
   	cout.tie(NULL);
    //freopen("input.txt", "r", stdin);
    //freopen("output1.txt", "w", stdout);
	ll n,q;
	cin>>n>>q;
	string s;
	cin>>s;
	ll sum[n];
	sum[0]=0;
	for(ll i=0;i<n-1;i++){
		sum[i+1] =sum[i] + (s.substr(i,2) == "AC");
	}
	while(q--){
		ll l,r;
		cin>>l>>r;
		cout<<sum[r-1] -sum[l-1]<<endl;
	}
   return 0;
}


Measured memory_bytes: 1488
// ######      ###      #######    #######    ##     #     #####        ###     ##### //
// #     #    #   #          #        #       # #    #    #     #      #   #     ###  //
// #     #   #     #        #         #       #  #   #   #       #    #     #    ###  //
// ######   #########      #          #       #   #  #   #           #########    #   //
// #     #  #       #     #           #       #    # #   #    ####   #       #    #   //
// #     #  #       #    #            #       #     ##   #    #  #   #       #        //
// ######   #       #   #######    #######    #      #    #####  #   #       #    #   //


#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double lld;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> ppl;
#define ain(a,n) for(ll i=0;i<(n);++i)	cin>>(a)[i];
#define DEBUG(x) cout << '>' << #x << ':' << x << endl;
#define loop(i,n) for(ll i=0;i<(n);++i)
#define FOR(i,a,b) for(ll i=(a);i<=(b);++i)
#define FORD(i,a,b) for(ll i=(a);i>=(b);--i)
#define cases ll T=0;cin>>T;while(T--)
#define ff first
#define ss second
#define all(v) v.begin(),v.end()
#define END "\n"
#define pb push_back
#define mp make_pair
#define go(c,itr) for(auto itr=(c).begin(); itr!=(c).end(); ++itr)
// #define back(c,itr) for(auto itr=(c).rbegin(); itr!=(c).rend(); ++itr)
#define PI 3.14159265359
#define inf 9e18
#define MOD 1000000007
#define MODU 998244353
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define MAXN 200005
#define BLOCK 555
const string alpha = "abcdefghijklmnopqrstuvwxyz";
const ll N = 200005;
const long double epsilon = 1e-9;
ll binexp(ll a, ll b, ll m) {
	a %= m;
	ll res = 1;
	while (b > 0) {
		if (b & 1)
			res = res * a % m;
		a = a * a % m;
		b >>= 1;
	}
	return res;
}
ll modinvfermat(ll a, ll m)
{
	return binexp(a, m - 2, m);
}
void task(bool flag)
{
	if (flag)
		cout << "YES\n";
	else
		cout << "NO\n";
}
ll lcm(ll a, ll b)
{
	return ((1LL * a * b) / (__gcd(a, b)));
}

signed main() {

	fast
	ll n, k;
	cin >> n >> k;
	vl a(n + 1);
	FOR(i, 1, n)	cin >> a[i];
	vvl dp(n + 1, vl(k + 1, 0));
	FOR(i, 1, n)	dp[i][0] = 1;
	FOR(j, 1, a[1])	dp[1][j] = 1;
	vl pref(k + 1, 0);
	FOR(i, 2, n)
	{
		pref = vl(k + 1, 0);
		pref[0] = dp[i - 1][0];
		FOR(j, 1, k)
		{
			pref[j] = (pref[j - 1] + dp[i - 1][j]) % MOD;
		}
		FOR(j, 0, k)
		{
			if (j > a[i])
			{
				dp[i][j] = (pref[j] + MOD - pref[j - a[i] - 1]) % MOD;
			}
			else
			{
				dp[i][j] = (pref[j]) % MOD;
			}
		}
	}
	// FOR(i, 1, n)
	// {
	// 	FOR(j, 1, k)
	// 	{
	// 		cout << dp[i][j] << " ";
	// 	}
	// 	cout << END;
	// }
	cout << dp[n][k] << END;




	return 0;
}


Measured memory_bytes: 83792
from collections import deque
h,w,n = map(int,input().split())
factrys = [None] * (n + 1)
ss = ["X" * (w + 2)]
append = ss.append
for i in range(h):
  s = "X" + input() + "X"
  if "S" in s:
    factrys[0] = (i + 1, s.index("S"))
  for j in range(len(s)):
    if s[j] != 'S' and s[j] != '.' and s[j] != 'X':
      factrys[int(s[j])] = (i + 1, j)
  append(s)
append("X" * (w + 2))

def bfs(i):
  mp = [[-1] * (w + 2) for j in range(h + 2)]
  x,y = factrys[i]
  que = deque()
  append = que.append
  popleft = que.popleft
  append((x, y))
  for count in range(10000000):
    sz = len(que)
    for loop in range(sz):
      (x,y) = popleft()
      if ss[x][y] == 'X' or not mp[x][y] is -1:
        continue
      if (x,y) == factrys[i + 1]:
        return count
      mp[x][y] = count
      append((x + 1, y))
      append((x - 1, y))
      append((x, y + 1))
      append((x, y - 1))

ans = 0
for i in range(n):
  ret = bfs(i)
  if ret is None:
    ans += 0
  else:
    ans += (ret)
print(ans)


Measured memory_bytes: 18152
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a,n) for(int i=(a); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it)
#define ALLOF(c) (c).begin(), (c).end()
typedef long long ll;
typedef unsigned long long ull;


int main(){
  vector<vector<int>> v(3, vector<int>(3,0));
  rep(i,3){
    rep(j,3){
      cin >> v[i][j];
    }
  }

  int N;
  cin >> N;
  rep(i,N){
    int a;
    cin >> a;

    rep(j,3) rep(k,3){
      if(v[j][k] == a) v[j][k] = -1;
    }
  }

  bool ok = false;
  rep(i,3){
    int cnt = 0;
    rep(j,3){
      if(v[i][j] == -1) cnt++;
    }
    if(cnt == 3) ok = true;
  }
  rep(i,3){
    int cnt = 0;
    rep(j,3){
      if(v[j][i] == -1) cnt++;
    }
    if(cnt == 3) ok = true;
  }

  if(v[0][0] == -1 && v[1][1] == -1 && v[2][2] == -1) ok = true;
  if(v[0][2] == -1 && v[1][1] == -1 && v[2][0] == -1) ok = true;

  if(ok) cout << "Yes" << endl;
  else cout << "No" << endl;
  
  return 0;
}


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

int main() {
  int N,A,B,C;
  cin >> N >> A >> B;
  
  C = N*A;
  
  if (C <= B) {
    cout << C << endl;
  }
  else {
    cout << B << endl;
  }
}

Measured memory_bytes: 3608
#include <iostream>
#include <cstdio>
#include <climits>
#include <cmath>
#include <vector>
#include <unordered_set>
#include <unordered_map>

using namespace std;

int main(void) {
  int a[3];
  int b[3];
  for (int i = 0; i < 3; i++)
    cin >> a[i] >> b[i];

  int deg[5] = {0};
  for (int i = 0; i < 3; i++) {
    deg[a[i]]++;
    deg[b[i]]++;
  }

  int c0 = 0;
  for (int i = 1; i <= 4; i++) {
    if (deg[i] > 2) {
      cout << "NO" << endl;
      return 0;
    }
    if (deg[i] == 1)
      c0++;
  }

  if (c0 == 2 || c0 == 0)
    cout << "YES" << endl;
  else
    cout << "NO" << endl;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
using ll = long long;
#define repl(i, l, r) for (ll i = l; i < r; i++)
#define rep(i, n) repl(i, 0, n)
int cnt[3][30], d[30][30];
int main() {
	int n, c;
	cin >> n >> c;
	rep(i, c) rep(j, c) cin >> d[i][j];
	rep(i, n) rep(j, n) {
		int a;
		cin >> a;
		cnt[(i + j + 2) % 3][a - 1]++;
	}
	int ans = 1e9;
	rep(i, c) {
		rep(j, c) {
			if (i == j) continue;
			rep(k, c) {
				if (i == k or j == k) continue;
				int now = 0;
				rep(l, c) {
					if (l != i) now += d[l][i] * cnt[0][l];
					if (l != j) now += d[l][j] * cnt[1][l];
					if (l != k) now += d[l][k] * cnt[2][l];
				}
				ans = min(ans, now);
			}
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

class Program
{
    static void Main(string[] args)
    {
        new Program().Calc();
    }

    Scanner cin;

    public Program() { }

    void Calc()
    {
        cin = new Scanner();

        string s = cin.next();

        int count0 = 0;

        for (int i = 0; i < s.Length; ++i)
        {
            if (s[i] == '0') { ++count0; }
        }

        int count1 = s.Length - count0;

        int count = 0;

        if (count0 < count1)
        {
            count = count0 * 2;
        }
        else
        {
            count = count1 * 2;
        }

        Console.WriteLine(count);
    }
}

class Scanner
{
    string[] s;
    int i;

    char[] cs = new char[] { ' ' };

    public Scanner()
    {
        s = new string[0];
        i = 0;
    }

    public string next()
    {
        if (i < s.Length) return s[i++];
        string st = Console.ReadLine();
        while (st == "") st = Console.ReadLine();
        s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
        if (s.Length == 0) return next();
        i = 0;
        return s[i++];
    }

    public int nextInt()
    {
        return int.Parse(next());
    }
    public int[] ArrayInt(int N, int add = 0)
    {
        int[] Array = new int[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextInt() + add;
        }
        return Array;
    }

    public long nextLong()
    {
        return long.Parse(next());
    }

    public long[] ArrayLong(int N, long add = 0)
    {
        long[] Array = new long[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextLong() + add;
        }
        return Array;
    }

    public double nextDouble()
    {
        return double.Parse(next());
    }


    public double[] ArrayDouble(int N, double add = 0)
    {
        double[] Array = new double[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextDouble() + add;
        }
        return Array;
    }
}


Measured memory_bytes: 13228
/*input
13 3
*/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
typedef tree<long long, null_type, less<long long>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;
#pragma GCC optimize("unroll-loops,no-stack-protector")
//order_of_key #of elements less than x
// find_by_order kth element
typedef long long int ll;
#define ld long double
#define pii pair<int,int>
#define f first
#define s second
#define pb push_back
#define REP(i,n) for(ll i=0;i<n;i++)
#define sz(_a) (ll)(_a.size())
#define FILL(n) memset(n,1,sizeof(n))
#define ALL(_a) _a.begin(),_a.end()
const ll maxn=505;
const ll maxlg=__lg(maxn)+2;
const ll INF64=8000000000000000000LL;
const int INF=0x3f3f3f3f;
const ll MOD=ll(1e9+7);
const ld PI=acos(-1);
const ld eps=1e-9;
ll mypow(ll a,ll b){
    ll res=1LL;
    while(b){
        if(b&1) res=res*a%MOD;
        a=a*a%MOD;
        b>>=1;
    }
    return res;
}
int main(){
    int a,b;
    cin>>a>>b;
    cout<<max(a+b,max(a-b,a*b));
}


Measured memory_bytes: 764
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
int main()
{
    int n, d;
    cin >> n >> d;
    d = d * 2 + 1;
    int ans = (n - 1) / d + 1;
    cout << ans << endl;
    
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
#define repr(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define invrepr(i,a,b) for(int i=b-1;i>=a;i--)
#define invrep(i,n) invrepr(i,0,n)
#define repitr(itr,a) for(auto itr=a.begin();itr!=a.end();++itr)
#define P pair<int,int>
const int MOD=1e9+7;
const ll INF=2e18;
const double PI=acos(-1);


int main() {
    ios_base::sync_with_stdio(false); 

    int h,w;
    cin >> h >> w;
    vector<vector<int>> c(10,vector<int>(10));
    rep(i,10){
        rep(j,10) cin >> c[i][j];
    } 
    rep(k,10) {
        rep(i,10) {
            rep(j,10) {
                int cc=c[i][k]+c[k][j];
                if (cc<c[i][j]) c[i][j]=cc;
            }
        }
    }
    ll ans=0;
    rep(i,h) {
        rep(j,w) {
            int a;
            cin >> a;
            if (a*a!=1) ans+=c[a][1];
        }
    }
    cout << ans << endl;
    
    return 0;
}


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

typedef long long ll;

#define INF 10e17 // 4倍しても(4回足しても)long longを溢れない
#define rep(i,n) for(int i=0; i<n; i++)
#define rep_r(i,n,m) for(int i=m; i<n; i++)
#define END cout << endl
#define MOD 1000000007
#define pb push_back
#define sorti(x) sort(x.begin(), x.end())
#define sortd(x) sort(x.begin(), x.end(), std::greater<int>())

void chmin(ll &a, ll b) { if (a > b) a = b; }

template<class T> int former(const vector<T> &v, T x) {
  return upper_bound(v.begin(), v.end(), x) - v.begin() - 1;
}

template<class T> int latter(const vector<T> &v, T x) {
  return lower_bound(v.begin(), v.end(), x) - v.begin();
}

int main() {
  int a,b,q; cin >> a >> b >> q;
  vector<ll> s(a), t(b);

  rep(i,a) cin >> s[i];
  rep(i,b) cin >> t[i];

  s.push_back(INF); s.push_back(-INF); sorti(s);
  t.push_back(INF); t.push_back(-INF); sorti(t);

  for (int tt = 0; tt < q; ++tt) {
    ll x; cin >> x;
    ll res = INF;

    for (int i = 0; i < 2; ++i) {
      ll first = (i ? s[former(s,x)] : s[latter(s,x)]);
      
      for (int j = 0; j < 2; ++j) {
        ll second = (j ? t[former(t,first)] : t[latter(t,first)]);
        chmin(res, abs(x - first) + abs(first - second));
      }
    }

    for (int i = 0; i < 2; ++i) {
      ll first = (i ? t[former(t,x)] : t[latter(t,x)]);

      for (int j = 0; j < 2; ++j) {
        ll second = (j ? s[former(s,first)] : s[latter(s,first)]);
        chmin(res, abs(x-first) + abs(first - second));
      }
    }
    cout << res << endl;
  }
}


Measured memory_bytes: 2912
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <assert.h>
#include <math.h>

int main(void)
{
	int A,B;
	scanf("%d %d\n",&A,&B);
	if (A+B>=10){
		printf("error\n");
	}
	else {
		printf("%d\n",A+B);
	}
	return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <cctype>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <functional>
using namespace std; 
#define DEBUG(x) cout << '>' << #x << ':' << x << endl;
#define REP(i,n) for(int i=0;i<(n);i++)
#define FOR(i,a,b) for(int i=(a);i<=(b);i++)
#define FORD(i,a,b) for(int i=(a);i>=(b);i--)
inline bool EQ(double a, double b) { return fabs(a-b) < 1e-9; }
const int INF = 1<<29;
typedef long long int ll;
inline int two(int n) { return 1 << n; }
inline int test(int n, int b) { return (n>>b)&1; }
inline void set_bit(int & n, int b) { n |= two(b); }
inline void unset_bit(int & n, int b) { n &= ~two(b); }
inline int last_bit(int n) { return n & (-n); }
inline int ones(int n) { int res = 0; while(n && ++res) n-=n&(-n); return res; }
template<class T> void chmax(T & a, const T & b) { a = max(a, b); }
template<class T> void chmin(T & a, const T & b) { a = min(a, b); }
const int MOD=1000000007;

bool isPowerOfTwo (ll x)  
{  
    return x && (!(x&(x-1)));  
}
bool isPrime(int n) 
{ 
    if (n <= 1)  return false; 
    if (n <= 3)  return true; 
    if (n%2 == 0 || n%3 == 0) return false; 
  
    for (int i=5; i*i<=n; i=i+6) 
        if (n%i == 0 || n%(i+2) == 0) 
           return false; 
  
    return true; 
}
int highestPowerof2(unsigned int n) 
{ 
    // Invalid input 
    if (n < 1) 
        return 0; 
  
    int res = 1;
    for (int i=0; i<8*sizeof(unsigned int); i++) 
    { 
        int curr = 1 << i; 
        if (curr > n) 
           break; 
  
        res = curr; 
    } 
  
    return res; 
} 
long long binpow(long long a, long long b) {
    long long res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a;
        a = a * a;
        b >>= 1;
    }
    return res;
}
const int dx[] = {1,0,-1,0,1,1,-1,-1};
const int dy[] = {0,-1,0,1,1,-1,-1,1};       
////////////////////////////////////////////////////////////////////
map<ll,ll> mp;
int main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);  
  cout.tie(NULL);
  ll t=1;
  while(t--)
  {
    int n;
    cin>>n;
    ll a;
    REP(i,n)
    {
        cin>>a;
        mp[a]++;
    }
    int m;
    cin>>m;
    REP(i,m)
    {
        cin>>a;
        if(mp[a])
        {
            mp[a]--;
        }
        else
        {
            cout<<"NO";
            return 0;
        }
    }
    cout<<"YES";
  }  
  return 0;
}

Measured memory_bytes: 12800
//Create Time: 2018-04-28 11:21:23
#include <iostream>
#include <cstdio>
#include <cstring>
#include <string>
#include <cmath>
#include <algorithm>
#include <vector>
#include <cstdlib>
#include <sstream>
#include <fstream>
#include <functional>
#include <list>
#include <deque>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <bitset>
#include <cctype>
#include <ctime>
#include <utility>
#include <complex>
#include <cassert>
#include <climits>
#include <iterator>
#include <tuple>
using namespace std;
#define snuke(i,x) for (__typeof((x).begin()) i = (x).begin(); i != (x).end(); ++i)
#define rep(i,a,n) for (int i=(a);i<(n);i++)
#define per(i,n,a) for (int i=(n)-1;i>=(a);i--)
// #define OUT(x) std::cout<<(#x)<<":"<<(x)<<std::endl
// #define TST(x) std::cout<<(#x)<<":"<<(x)<<" "
#define OUT(args...) {string _s=#args;replace(_s.begin(),_s.end(),',',' ');stringstream _ss(_s);istream_iterator<string> _it(_ss);OUT_TST("\n",_it,args);}
#define TST(args...) {string _s=#args;replace(_s.begin(),_s.end(),',',' ');stringstream _ss(_s);istream_iterator<string> _it(_ss);OUT_TST("",_it,args);}
#define SZ(v) ((int)(v).size())
#define all(v) (v).begin(), (v).end()
#define unq(x) sort(all(x)),(x).erase(unique(all(x)),(x).end())
#define mem(f,x) memset((f), (x), sizeof(f))
#define clr(f) mem(f,0)
#define x first
#define y second
#define mp make_pair
#define pb push_back
#define mt make_tuple
#define eb emplace_back
#define DEBUG
void OUT_TST(string s,istream_iterator<string> it) {cerr<<s;}
template<typename T, typename... Args> void OUT_TST(string s,istream_iterator<string> it,T a,Args... args){cerr<<*it<<"="<<a<<" ";OUT_TST(s,++it,args...);}
template<class T> void rd(T&ret){ret=0;bool ok=0,u=0;for(;;){int c=getchar();if(c>='0'&&c<='9')ret=(ret<<3)+(ret<<1)+c-'0',ok=1;else if(c=='-')u=1;else if(ok){if(u)ret*=-1;return;}}}
long long powmod(long long p,long long n,long long mod){long long ret=1;for(;n;n>>=1){if(n&1)ret=ret*p%mod;p=p*p%mod;}return ret;}
template <class T> bool chmin(T& a, const T &b) {return b < a? a = b, 1: 0;}
template <class T> bool chmax(T& a, const T &b) {return b > a? a = b, 1: 0;}
int gcd(int a,int b){return b?gcd(b,a%b):a;}
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii > vii;
typedef tuple<int,int,int> tp;
/****head****/
int main(){
    int n,m;cin>>n>>m;
    if(n>m)swap(n,m);
    ll ans=0;
    if(m==1)ans=1;
    else if(n==1)ans=m-2;
    else if(n==2)ans=0;
    else ans=(n-2ll)*(m-2ll);
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
import java.util.*;
public class Main{
public static void main(String args[]){
  Scanner sc = new Scanner(System.in);
  int a = sc.nextInt();
  int b = sc.nextInt();
  if((a * b) % 2 == 1){
    System.out.println("Odd");
  }else {
    System.out.println("Even");
  }
}
}

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

using namespace std;

#define FOR(i,a,b) for(int i=(a); i<(b); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
#define fi first
#define se second

template<typename A, typename B> inline bool chmax(A &a, B b) { if (a<b) { a=b; return 1; } return 0; }
template<typename A, typename B> inline bool chmin(A &a, B b) { if (a>b) { a=b; return 1; } return 0; }

typedef long long ll;
typedef pair<int, int> pii;
const ll INF = 1ll<<29;
const bool debug = 0;

int main() {
	int n;
	cin >> n;
	
	set<int> ss;
	REP(i, n) {
		int v[3];
		REP(j, 3) scanf("%d", v + j), v[j]--;
		sort(v, v + 3);
		ss.insert(v[0] * 1e6 + v[1] * 1e3 + v[2]);
	}
	
	cout << n - ss.size() << endl;
	return 0;
}

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

// Type alias
using ll=long long;
using ld=double;

using pi=pair<int,int>;
using pll=pair<ll,ll>;
using pld=pair<ld,ld>;
using ti3=tuple<int, int, int>;

using vi=vector<int>;
using vll=vector<ll>;
using vld=vector<ld>;
using vpi=vector<pi>;
using vpll=vector<ll>;
using vpld=vector<ld>;
using vti3=vector<ti3>;

// Constants
const double EPS = 1e-9;
const int inf = numeric_limits<int>::max();

// Macro
#define rep(i,n) for(int i=0;i<int(n);++i)
#define rrep(i,n) for(int i=int(n-1);i>=0;--i)
#define REP(i,a,b) for(int i=int(a);i<int(b);++i)
#define RREP(i,a,b) for(int i=int(b-1);i>=int(a);--i)
#define SHOW(a) cout << #a << " = " << a << endl
#define ARR(a,n) for(int i=0;i<int(n);++i) cout << #a << "[" << i << "]" << " = " << a[i] << endl

#define ALL(a) a.begin(),a.end()

// Funtcions
ll pow(ll base, ll i, ll mod){
  ll a = 1;
  while(i){
    if (i & 1) {
      a *= base;
      a %= mod;
    }
    base *= base;
    base %= mod;
    i >>= 1;
  }
  return a;
}
ll gcd(ll a, ll b){
  while(b){
    ll c = a % b;
    a = b;
    b = c;
  }
  return a;
}
ll lcm(ll a, ll b){
  return a / gcd(a, b) * b;
}
template<typename T> bool chmin(T& a, const T& b) {
  if (a > b) return a = b, true; else return false;
}

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


void solve(){
  int N;
  int A[2*100000+5];

  cin >> N;
  rep(i, N){
    cin >> A[i];
    A[i]--;
  }

  ll count[2*100000+5] = {};
  rep(i, N){
    count[A[i]]++;
  }

  ll sum = 0;
  rep(i, N){
    sum += count[i] * (count[i] - 1) / 2;
  }

  rep(i, N){
    cout << sum - count[A[i]] + 1 << endl;
  }
}

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

Measured memory_bytes: 4864
/* package whatever; // don't place package name! */

import java.util.*;
import java.lang.*;
import java.io.*;

/* Name of the class has to be "Main" only if the class is public. */
class Main
{
	public static void main (String[] args) throws java.lang.Exception
	{
		int xw, yw;
		String tmp;

		Scanner sc = new Scanner(System.in);

		while (sc.hasNext()) {
			yw = sc.nextInt();
			xw = sc.nextInt();
			
			if (yw==0 && yw ==0) {
				return;
			}
			//上
			prtLine(xw);	
			
			//中
			for (int j = 0 ; j <yw-2; j++) {
				System.out.print("#");
				for (int i = 0 ; i <xw-2; i++) {
					System.out.print(".");
				}
				System.out.println("#");
			}
				
			//下
			prtLine(xw);
			
			System.out.println("");
		}
		
	}
	
	static void prtLine(int length) 
	{
		for (int i = 0 ; i <length; i++) {
			System.out.print("#");
		}	
		System.out.println("");
		return;
		
	}
}


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

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n; cin >> n;
  int f = -n;
  for (int i = 0; i < n; i++) {
    int a; cin >> a;
    f += a;
  }
  cout << f << '\n';
  return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define print(x) cout<<x<<endl;
#define rep(i,a,b) for(int i=a;i<b;i++)
#define REP(i,a) for(int i=0;i<a;i++)
#define printall(n,array) {for(int i=0;i<n;i++){cout<<array[i]<<" ";}cout<<endl;}
#define U() cout<<endl;
typedef long long ll;
typedef pair<int, int> PI;
typedef pair<int, PI> V;
typedef vector<int> VE;
const ll mod = 1000000007; //10^9+7

int main(){
  int x;
  cin >> x;
  int ans = 0;
  int a = 2;
  while(sqrt(x) >= a){
    int i = 1;
    while(x >= pow(a, i + 1)) {
      i++;
    }
    ans = max(ans, int(pow(a, i)));
    a++;
  }
  if(ans == 0){
    print(1);
    return 0;
  }
  print(ans);
}

Measured memory_bytes: 256
def main():
    n, ls = get_params()
    print(to_answer(is_drawable(ls)))


def get_params():
    n = int(input())
    ls = [int(s) for s in input().split()]
    return n, ls


def to_answer(b):
    return "Yes" if b else "No"


def is_drawable(ls):
    ls_copy = ls.copy()
    maximum = max(ls_copy)
    ls_copy.remove(maximum)
    return maximum < sum(ls_copy)


if __name__ == "__main__":
    main()


Measured memory_bytes: 3060
s=input()

first_c=s[0]
last_c=s[-1]

if first_c==last_c:
  if len(s)%2==0:
    print('First')
  else:
    print('Second')
else:
  if len(s)%2==0:
    print('Second')
  else:
    print('First')

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

#ifdef LOCAL
#include "../lib/dump.hpp"
#else
#define dump(...)
#define dumpv(...)
#endif

typedef long long ll;
typedef pair<int, int> P;
const int MOD = 1e9 + 7;
const int INF = 1001001001;
const ll LINF = 1001002003004005006ll;

class UnionFind
{
public:
  // parentの番号。親だった場合は-(その集合のサイズ)
  vector<int> parent;
  // parentはすべて-1にする。全てバラバラになる。
  UnionFind(int N) { parent = vector<int>(N, -1); }
  // Aがどのグループに属しているかを調べる
  int root(int A)
  {
    if (parent[A] < 0)
      return A;
    return (parent[A] = root(parent[A]));
  }
  // 自分のいるグループの頂点数を調べる
  int size(int A) { return -parent[root(A)]; }
  // AとBをくっつける
  int connect(int A, int B)
  {
    // AとBを直接つなぐのではなくroot(A)とroot(B)をくっつける
    A = root(A);
    B = root(B);
    if (A == B) {
      // すでにくっついている
      return false;
    }
    // 大きい方(A)を小さい方(B)にくっつけたい
    // 大小が逆だったらひっくり返す
    if (size(A) < size(B))
      swap(A, B);
    // Aのサイズを更新する
    parent[A] += parent[B];
    // Bの親をAに変更する
    parent[B] = A;
    return true;
  }
};

int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  // freopen("temp.1", "r", stdin);

  int N, M;
  cin >> N >> M;
  vector<int> p(N + 1);
  for (int i = 1; i <= N; i++) {
    cin >> p[i];
  }
  UnionFind uf(N + 1);
  for (int i = 0; i < M; i++) {
    int x, y;
    cin >> x >> y;
    uf.connect(x, y);
  }
  int ans = 0;
  for (int i = 1; i <= N; i++) {
    if (uf.root(p[i]) == uf.root(i))
      ans++;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 1024
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int, int> pi;
#define debug(x) cerr << #x << ": " << x << endl;
#define debug2(x, y) debug(x) debug(y);
#define repn(i, a, b) for(int i = (int)(a); i < (int)(b); i++)
#define rep(i, a) for(int i = 0; i < (int)(a); i++)
#define all(v) v.begin(), v.end() 
#define mp make_pair
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#define sq(x) ((x) * (x))

template<class T> T gcd(T a, T b){ return ((b == 0) ? a : gcd(b, a % b)); }

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	//freopen("input.in", "r", stdin);
	//freopen("output.out", "w", stdout);
	int n;
	cin >> n;
	vi a(n);
	rep(i, n) cin >> a[i];
	vi l(n, 0), r(n, 0);
	l[0] = a[0];
	repn(i, 1, n) l[i] = gcd(l[i - 1], a[i]);
	r[n - 1] = a[n - 1];
	for(int i = n - 2; i >= 0; i--) r[i] = gcd(a[i], r[i + 1]);
	int ans = 0;
	repn(i, 1, n - 1) ans = max(ans, gcd(l[i - 1], r[i + 1]));
	cout << max({ans, l[n - 2], r[1]}) << endl;
	return 0;
}
/*
Things to look out for:
	- Integer overflows
	- Array bounds
	- Special cases
Be careful!
*/


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

int main() {
	int A, B, K;
	cin >> A >> B >> K;
	set<int> answer;

	for (int i = A; i < A + K; i++) {
		answer.insert(i);
		if (i == B)break;
	}
	for (int i = B - K + 1; i <= B; i++) {
		if (i < A) break;
		answer.insert(i);
	}
	for (auto itr = answer.begin(); itr != answer.end(); itr++) {
		cout << *itr << endl;
	}
	return 0;
}

Measured memory_bytes: 256
from heapq import heappop, heappush


class edge(object):
    def __init__(self, to, cost):
        self.to = to
        self.cost = cost


INF = float('inf')
N = int(input())
g = {i: []for i in range(N)}
for i in range(N - 1):
    a, b, c = map(int, input().split())
    g[a - 1].append(edge(b - 1, c))
    g[b - 1].append(edge(a - 1, c))
Q, K = map(int, input().split())
dist = {i: INF for i in range(N)}
dist[K - 1] = 0
hq = [(0, K - 1)]
done = [0] * N
done[K - 1] = 1
while hq:
    d, n = heappop(hq)
    dist[n] = d
    for eg in g[n]:
        if done[eg.to] == 0:
            heappush(hq, (d + eg.cost, eg.to))
            done[eg.to] = 1
for i in range(Q):
    x, y = map(int, input().split())
    print(dist[x - 1] + dist[y - 1])

Measured memory_bytes: 85232
using System;

public class Hello
{
    public static void Main()
    {
        string[] line = Console.ReadLine().Trim().Split(' ');
        var a = int.Parse(line[0]);
        var b = int.Parse(line[1]);
        Console.WriteLine((a > 9 | b > 9) ? -1 : a * b);
    }
}


Measured memory_bytes: 11092
#include <iostream>
#include <fstream>
#include <cstring>
#include <vector>
#include <queue>
using namespace std;
 
#define rep(a,b) for(int i=a;i<b;i++)
#define E	<<endl;
#define F freopen("in.txt","r",stdin);


int n,m;
std::vector<int> adj[1000005];
bool visit[1000005];


int BFS(int src)
{	
	

	if(visit[src])
		return 1;


	queue<int>q;
	q.push(src);
	visit[src]=true;
	int ans=1;


	while(!q.empty())
	{
		int u=q.front();
		q.pop();

		for(int i=0;i<adj[u].size();i++)
		{
			int v=adj[u][i];

			if(visit[v]==false)
			{
				//cout<<v<<" ";
				visit[v]=true;
				ans++;
				q.push(v);
			}
		}
	}
	return ans;



}

int main()
{
	//F;
	int n,m;
	cin>>n>>m;   
	memset(visit,0,sizeof(visit));
	rep(0,m)
	{
		int u,v;
		cin>>u>>v;
		adj[u].push_back(v);
		adj[v].push_back(u);
	}

	int ans=0;

	rep(1,n+1)
	{
		//cout<<i<<" --- "<<BFS(i)<<endl;
		ans=max(ans, BFS(i));
	}
	cout<<ans<<endl;

	return 0;
}

Measured memory_bytes: 34780
#include <cstdio>
#include <cmath>
#include <cstdint>
#include <cinttypes>
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main()
{
    int a,b;
    cin >> a >> b;
    
    int cost = 0;
    if(a > 12){
        cost = b;
    } else if ( a < 6){
        cost  = 0;
    } else {
        cost = b / 2;
    }

    cout << cost << endl;

    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int
main (void)
{
  int i, j;
  while (EOF != scanf ("%d %d", &i, &j))
    {
      int k = 0;
      int sum = i + j;
      while (sum > 0)
	{
	  sum /= 10;
	  k++;
	}
      printf ("%d\n", k);
    }
  return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <cstring>
#include <iomanip>

using namespace std;

typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vii;
typedef pair<int,int> pii;

#define FASTIO ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define pb push_back
#define ff it->first
#define ss it->second
#define all(v) (v).begin(),(v).end()
#define rep(i,n) for(auto i=0;i<n;++i)
#define LOOP_IT(it,s) for(auto it=(s).begin();it!=(s).end();++it)


#ifdef LOCAL
#define cerr cout
#else
#endif

#define TRACE

#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
	cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
	const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...)
#endif


void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif


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

    double pi = 3.141592653589793238;
    double r;
    cin>>r;
    r=2*r;
    double ans = static_cast<double>(pi*r);
    cout<<fixed<<setprecision(20)<<ans;



    return 0;
}



Measured memory_bytes: 3756
#include<cstdio>
#include<queue>
#include<algorithm>
#include<string.h>
#include<math.h>
#include<set>
#include<stack>
#include<queue>
#include<map>
#include<iostream>
using namespace std;
char s[1100],t[1100];
int dp[1100][1100]; 
int  main()
{
	int n,m;
	scanf("%d%d",&n,&m);
	printf("%d\n",n*(n-1)/2+m*(m-1)/2);
}


Measured memory_bytes: 256
{-# LANGUAGE TypeFamilies, BangPatterns, FlexibleContexts #-}
import Data.Array
import Data.Array.Unboxed
import Data.Array.IO
import Data.Array.Unsafe
import qualified Data.Map.Strict as M
import qualified Data.Set as S
import qualified Data.Vector.Unboxed as U
import Data.Int
import Control.Monad.State.Strict
import qualified Data.ByteString.Char8 as B
import Data.ByteString(ByteString)
import Data.Char

type Scanner a = StateT ByteString IO a
type family Freeze a where
  Freeze (IOUArray i v) = UArray i v
  Freeze (IOArray i v) = Array i v

foldM :: Monad m => (b -> a -> m b) -> b -> [a] -> m b
foldM f z0 xs = foldr c return xs z0
    where c x k = \z -> f z x >>= k
          {-# INLINE c #-}

scan :: Read a => Scanner a
scan = state $ \s ->
    let (s1, s2) = B.span (not . isSpace) s 
        !v = read (B.unpack s1)
    in (v, B.dropWhile isSpace s2)

scanInt :: Scanner Int
scanInt = scan

scanString :: Scanner B.ByteString
scanString = state $ \s ->
    let (s1, s2) = B.span (not . isSpace) s in
    (s1, B.dropWhile isSpace s2)

scanReal :: Scanner Double
scanReal = scan

main :: IO ()
main = B.getContents >>= \content -> flip evalStateT content $ do
    vA <- scanInt
    vB <- scanInt
    vC <- scanInt
    liftIO $ solve vA vB vC
solve :: Int -> Int -> Int -> IO ()
solve vA vB vC = putStrLn $ if vA == vB && vB == vC then "Yes" else "No"


Measured memory_bytes: 508
n = gets.chomp.to_i
a = gets.chomp.split(" ").map(&:to_i)
s = [0]
n.times do |i|
  s[i+1] = s[i] + a[i]
end
h = Hash.new(0)
s.each do |i|
  h[i] += 1
end

ans = 0

h.each do |k, v|
  if v == 1
    next
  elsif v == 2
    ans += 1
  else
    ans += (v * (v - 1) / 2)
  end
end

puts ans

Measured memory_bytes: 32588
#include <stdio.h>
#include <string.h>
#include <stdlib.h>

typedef struct {
    int time;
    int len;
    int no;
} ICICLE;

int mymax(int a, int b)
{
    if (a > b){
        return (a);
    }
    return (b);
}

int comp(const void *a , const void *b)
{
    ICICLE *x, *y;
    x = (ICICLE*) a;
    y = (ICICLE*) b;
    
    return ((y->len) - (x->len));
}

int main(void)
{
    static ICICLE t[100001], m[100001];
    int mlen;
    int n, r;
    int i, j;
    int ans;
    
    scanf("%d%d", &n, &mlen);
    
    for (i = 0; i < n; i++){
        scanf("%d", &t[i].len);
        t[i].no = i;
    }
    
    memcpy(m, t, sizeof(t));
    
    qsort(t, n, sizeof(ICICLE), comp);
    r = n;
    
    ans = 0;
    while (r){
        for (i = 0; i < n; i++){
            if (t[i].no != 0 && t[i].no != n - 1){
                if (t[i].time == 0 && (m[t[i].no - 1].len < t[i].len || m[t[i].no - 1].time != 0) && (m[t[i].no + 1].len < t[i].len || m[t[i].no + 1].time != 0)){
                    t[i].time = (mlen - t[i].len) + mymax(m[t[i].no - 1].time, m[t[i].no + 1].time);
                    ans = mymax(ans, t[i].time);
                    m[t[i].no].time = t[i].time;
                    r--;
                }
            }
            else if (t[i].no == 0){
                if (t[i].time == 0 && (m[t[i].no + 1].len < t[i].len || m[t[i].no + 1].time != 0)){
                    t[i].time = (mlen - t[i].len) + m[t[i].no + 1].time;
                    ans = mymax(ans, t[i].time);
                    m[t[i].no].time = t[i].time;
                    r--;
                }
            }
            else {
                if (t[i].time == 0 && (m[t[i].no - 1].len < t[i].len || m[t[i].no - 1].time != 0)){
                    t[i].time = (mlen - t[i].len) + m[t[i].no - 1].time;
                    ans = mymax(ans, t[i].time);
                    m[t[i].no].time = t[i].time;
                    r--;
                }
            }
        }
    }
    
    printf("%d\n", ans);
    
    return (0);
}

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

int main() {
  int n;
  scanf("%d", &n);

  if (n / 100 == 7) {
    printf("Yes\n");
  } else if (n / 10 % 10 == 7) {
    printf("Yes\n");
  } else if (n % 10 == 7) {
    printf("Yes\n");
  } else {
    printf("No\n");
  }
}

Measured memory_bytes: 3656
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define For(i,n,k) for(int i=(n);i<(k);i++)
#define ALL(a)  (a).begin(),(a).end()
ll ans=0;
void Main(){
    int sx,sy,gx,gy,n;
    cin >> sx >> sy >> gx >> gy >> n;
    vector<int> x(n+2),y(n+2);
    vector<double> r(n+2,0);
    For(i,1,n+1) cin >> x[i] >> y[i] >> r[i];
    x[0] = sx;
    x[n+1] = gx;
    y[0] = sy;
    y[n+1] = gy;
    vector<double> dist(n+2,1e10);
    vector<bool> flag(n+2,false);
    dist[0] = 0;
    flag[0] = true;
    n += 2;
    int now = 0;
    For(_,0,n-1){
        int next = -1;
        double nextdist = 1e10;
        For(i,0,n){
            dist[i] = min(dist[i],dist[now] + max(hypot(x[i] - x[now], y[i] - y[now]) - (r[i] + r[now]), 0.0));
            if(!flag[i]){
                if(nextdist > dist[i]){
                    next = i;
                    nextdist = dist[i];
                }
            }
        }
        //For(i,0,n) cout << dist[i] << " \n"[i==n-1];
        now = next;
        flag[now]=true;
    }
    cout << fixed << setprecision(12) << dist[n-1] << endl;
}
int main(){
    Main();
    /*
    東方風神録は神が出てくるので当然神ゲー
    */
    return 0;
}

Measured memory_bytes: 3840
#include <iostream>
#include <cmath>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <algorithm>

typedef long long ll;

using namespace std;

int main() {
    int a;
    cin >> a;
    cout << a + a * a + a * a * a << endl;
    return 0;
}



Measured memory_bytes: 3636
n ,a, b =  map(int, input().split())
dif = abs(a-b)
ans = 0
if dif%2 != 0:
  ans = min(a-1, n-b) + 1 + (b-a-1)//2
if dif%2 == 0:
  ans = dif//2
print(ans)

Measured memory_bytes: 2940
package main

import "fmt"
import "sort"

func main(){
	var n,k int;
  	fmt.Scan(&n,&k);
  	a := make([]int, n);
  for i:=0;i<n;i++{
  	fmt.Scan(&a[i])
  }
  sort.Ints(a);
  var ans int;
  for i:=0;i+k<n;i++{
  	ans+=a[i];
  }
  fmt.Println(ans);
}

Measured memory_bytes: 5632