akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

// エイリアス
using  ll = long signed long;
using ull = long unsigned long;
using  ld = long double;
using   P = pair<int, int>;
using llP = pair<ll, ll>;
using DoP = pair<double, double>;

// 汎用マクロ
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define rep(i, n) for (int i = 0; i < n; ++i)
#define FOREACH(i,q) for (auto &i : q)
#define UNIQUE(v) do { sort((v).begin(), (v).end()); (v).erase(unique((v).begin(), (v).end()), (v).end()); } while (false)
#define SZ(x) ((int)(x).size())
template <class T>inline bool chmin(T &a, const T b) {if (a > b) { a = b; return true;} return false;}
template <class T>inline bool chmax(T &a, const T b) {if (a < b) { a = b; return true;} return false;}
template <class T>inline void line_out(const vector<T> vec) {int n = SZ(vec); rep(i, n) { cout << vec[i]; if(i < n-1) cout << " ";}cout << endl;}
const int di[] = {0, 1, 0, -1, 1, 1, -1, -1};
const int dj[] = {1, 0, -1, 0, 1, -1, 1, -1};
const int INF = 1 << 28;
const ll INF64 = 1ll << 62;
const int mod = 1000000007;
//const int mod = 998244353;
struct mint
{
  ll x; // typedef long long ll;
  mint(ll x = 0) : x((x % mod + mod) % mod) {}
  mint operator-() const { return mint(-x); }
  mint &operator+=(const mint a)
  {
    if ((x += a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator-=(const mint a)
  {
    if ((x += mod - a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator*=(const mint a)
  {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const
  {
    mint res(*this);
    return res += a;
  }
  mint operator-(const mint a) const
  {
    mint res(*this);
    return res -= a;
  }
  mint &operator++()
  {
    if ((x += 1) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator--()
  {
    if ((x += mod - 1) >= mod)
      x -= mod;
    return *this;
  }
  mint operator*(const mint a) const
  {
    mint res(*this);
    return res *= a;
  }
  mint pow(ll t) const
  {
    if (!t)
      return 1;
    mint a = pow(t >> 1);
    a *= a;
    if (t & 1)
      a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const
  {
    return pow(mod - 2);
  }
  mint &operator/=(const mint a)
  {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const
  {
    mint res(*this);
    return res /= a;
  }
};

int main()
{
  ll n; cin >> n;
  map<ll, int> mp;
  for(ll i = 2; i*i <= n; ++i) {
    while(n%i==0) {
      ++mp[i];
      n/=i;
    }
  }
  if(n != 1) ++mp[n];
  vector<ll> sum(21, 0);
  for(int i = 1; i <= 20; ++i) sum[i] = i*(i+1)/2;
  int ans = 0;
  for(auto x : mp) {
    auto it = upper_bound(ALL(sum), x.second);
    --it;
    ans += distance(sum.begin(), it);
  }
  cout << ans << endl;
}


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

typedef long long ll;
#define all(x) (x).begin(),(x).end()

template<typename T>
T mod(T a, T b){
    return (a + b) % b;
}

template<typename T>
T gcd(T a, T b){
    if (b == 0) return a;
    return gcd(b, a % b);
}

ll lcm(ll a, ll b){
    return a * b / gcd(a,b);
}

// n を素因数分解
map<ll, ll> factor(ll n){
    map<ll, ll> mp;
    for (ll i = 2; i*i <= n; i++) {
        while (n % i == 0) {
            mp[i]++;
            n /= i;
        }
    }

    if (n > 1) {
        mp[n]++;
    }

    return mp;
}

// 文字列に "hoge" が含まれているか
// string str = "hogepiyo";
// if (str.find("hoge") != string::npos) {
//     cout << "文字列が含まれています" << endl;
// }

// char to string
// char c = 'a';
// string str = {c};

void solve(){
    int N, K;
    cin >> N >> K;
    string S;
    cin >> S;

    int ans = 0;
    int x = 0, y = 0;
    vector<int> ori(N-1);
    for (int i = 0; i < N-1; i++) {
        if (S[i+1] == S[i]) {
            ori[i] = 0;
            ans++;
        } else if (S[i+1] < S[i]) {
            ori[i] = 1;
            x++;
        } else {
            ori[i] = -1;
            y++;
        }
    }

    if (K >= min(x,y)) {
        ans += 2 * min(x,y);
        K -= min(x,y);
        int t = x + y - 2*min(x,y);
        if (K >= t) {
            ans += t;
        } else {
            ans += K;
        }
    } else {
        ans += 2 * K;
    }

    cout << ans << endl;

    return;
}

int main(int argc, char const* argv[])
{
    solve();
    return 0;
}


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

int main(){
  int N; cin >> N;
  string s,t; cin >> s >> t;
  REP(i,N){
    cout << s[i] << t[i];
  }
  cout << '\n';
}
  

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
const int mod = 1000000007;
struct mint {
    ll x; // typedef long long ll;
    mint(ll x=0):x((x%mod+mod)%mod){}
    mint operator-() const { return mint(-x);}
    mint& operator+=(const mint a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator-=(const mint a) {
        if ((x += mod-a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator*=(const mint a) {
        (x *= a.x) %= mod;
        return *this;
    }
    mint operator+(const mint a) const {
        mint res(*this);
        return res+=a;
    }
    mint operator-(const mint a) const {
        mint res(*this);
        return res-=a;
    }
    mint operator*(const mint a) const {
        mint res(*this);
        return res*=a;
    }
    mint pow(ll t) const {
        if (!t) return 1;
        mint a = pow(t>>1);
        a *= a;
        if (t&1) a *= *this;
        return a;
    }
    
    // for prime mod
    mint fact(mint n) const {
        if(n.x==1) return 1;
        else return n*fact(n-1);
    }
    mint inv() const {
        return pow(mod-2);
    }
    mint& operator/=(const mint a) {
        return (*this) *= a.inv();
    }
    mint operator/(const mint a) const {
        mint res(*this);
        return res/=a;
    }
};
ll xORTrick(ll n) {
    if (n % 4 == 0) {
        return n;
    }
    
    if (n % 4 == 1) {
        return 1;
    }
    
    if (n % 4 == 2) {
        return n + 1;
    }
    
    return 0;
}
ll solution(ll M, ll N) {
    return xORTrick(N) ^ xORTrick(M - 1);
}
int main() {
    ll a, b;
    cin >> a >> b;
    cout << solution(a, b);
}


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

int main() {
  int N, K;
  cin >> N >> K;
  vector<int> x(N), y(N);
  for (int i = 0; i < N; ++i)
    cin >> x[i] >> y[i];

  vector<int> xx(N), yy(N);
  for (int i = 0; i < N; ++i)
    xx[i] = x[i], yy[i] = y[i];
  sort(xx.begin(), xx.end()), sort(yy.begin(), yy.end());

  long long ans = 1ll * (xx[N - 1] - xx[0]) * (yy[N - 1] - yy[0]);
  for (int xi = 0; xi < N; ++xi) {
    for (int xj = xi + 1; xj < N; ++xj) {
      for (int yi = 0; yi < N; ++yi) {
        for (int yj = yi + 1; yj < N; ++yj) {
          int k = 0;
          for (int i = 0; i < N; i++)
            if (x[i] >= xx[xi] && x[i] <= xx[xj] && y[i] >= yy[yi] &&
                y[i] <= yy[yj])
              k++;
          if (k >= K)
            ans = min(1ll * (xx[xj] - xx[xi]) * (yy[yj] - yy[yi]), ans);
        }
      }
    }
  }

  cout << ans << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <tuple>
#include <cmath>
#include <queue>
#include <vector>
#include <map>
using namespace std;

#define ll int64_t
const long MOD = 1e9 + 7;


// 自作のソート関数
// 5で割った余りの大小で比較
bool less_second(const pair<int, long>& lhs, const pair<int, long>& rhs) {
  return lhs.second > rhs.second;
}


int main()
{
  //#####  // 左上はmax4回 左2上はmax6回
  //#####  // 2段目はmax6回 2段目真ん中はmax9回
  //#####

  // 最終的にみたいな
  //###
  //#.#
  //#.#
  //###
  long n, m;

  cin  >> n >> m;
  long ans =0;
  if(m==1 && n==1){
    ans=1;
  }else if (m==1){
    ans = max(n-2,(long)0);
  }else if (n==1){
    ans = max(m-2,(long)0);
  }else if (m>=3 && n>=3){
    ans = (m-2) * (n-2);
  }






  cout << ans;

  return 0;
}


Measured memory_bytes: 256
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees, log2, gcd
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left, insort, insort_left
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def TUPLE(): return tuple(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7 
#mod = 998244353
from decimal import *
#import numpy as np
#decimal.getcontext().prec = 10

N = INT()
A = [INT() for _ in range(N)]

tmp = 0
cnt = 0
for i in range(N-1, -1, -1):
	tmp -= 1
	if i < A[i] or A[i] < tmp:
		print(-1)
		exit()
	elif tmp < A[i]:
		cnt += A[i]
		tmp = A[i]

print(cnt)


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


using namespace std;

#define ll long long

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	string s1,s2,s3;
	cin >> s1 >> s2 >> s3;
	char c1=toupper(s1[0]);
	char c2=toupper(s2[0]);
	char c3=toupper(s3[0]);
	cout << c1 << c2 << c3;
	return 0;
}




Measured memory_bytes: 3656
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    int alice = 0;
    int bob = 0;
    int a[100] = {};
    cin >> n;
    for (int i = 0; i < n; i++)
    {
        cin >> a[i];
    }
    sort(a, a + n);
    reverse(a, a + n);
    for (int i = 0; i < n; i++)
    {
        if (i % 2 == 0)
        {
            alice += a[i];
        }
        else
            bob += a[i];
    }
    cout << alice - bob << endl;
}


Measured memory_bytes: 256
#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<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds; 

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

    int n;
    cin>>n;
    long long s = 0, q;
    map<long long, long long>mp;
    vector<long long>v(n);
    for(auto &x:v)
    {
        cin>>x;
        s+=x;
        mp[x]++;
    }
    cin>>q;
    while(q--)
    {
        long long b,c;
        cin>>b>>c;
        s-=mp[b]*b;
        s+=mp[b]*c;
        mp[c]+=mp[b];
        mp[b] = 0;
        cout<<s<<'\n';
    }

    return 0;
}

Measured memory_bytes: 9916
package main

import "fmt"

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

	var h []int
	for range make([]struct{}, N) {
		var x int
		fmt.Scan(&x)
		h = append(h, x)
	}

	cnt := 0
	for len(h) > 0 {
		i := 0
		flg := false
		for i < len(h) && h[i] > 0 {
			h[i]--
			i++
			flg = true
		}
		if flg {
			cnt++
		}
		if h[0] == 0 {
			h = h[1:]
		}
	}
	fmt.Println(cnt)
}


Measured memory_bytes: 512
import java.util.*;
public class Main {
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    double keisan = (n/1.08);
    long x = Math.round(keisan);
    long sum = (long)(x*1.08);
    long sum2 = (long)((x+1)*1.08);
    long sum3 = (long)((x-1)*1.08);
    
    if(n == sum){
      System.out.println(x);
    }else if(n == sum2){
      System.out.println(x+1);
    }else if(n == sum3){
      System.out.println(x-1);
    }else{
      System.out.println(":(");
    }
  }
}

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

int main(void) {
	string s; cin >> s;
	int a = s.size(), m = 0, n = 0;
	int i,flag = 0;

	if (s[0] == 'A') {
		flag = 1;
	}
	for (i = 2; i < a - 1; i++) {
		if (s[i] == 'C') {
			m += 1;
		}
	}
	for (int j = 0; j < a; j++) {
		if ('a' <= s[j] && s[j] <= 'z') {
			n += 1;
		}
	}
	if (flag==1 &&m == 1 && n == a - 2) {
		cout << "AC" << endl;
	}
	else { cout << "WA" << endl; }
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define REPS(i,n) for(int i=1;i<=(int)(n);i++)
using namespace std;
using ll = long long;
using ld = long double;

int main(void) {
    int H, W;
    cin >> H >> W;
    char s[H][W];
    REP (i, H) {
        REP (j, W) {
            cin >> s[i][j];
        }
    }

    // DPテーブル初期化
    int dp[H][W] = {};
    if (s[0][0] == '#') {
        dp[0][0]++;
    }
    for (int i = 1; i < W; i++) {
        dp[0][i] = dp[0][i-1];
        if (s[0][i] == '#') {
            if (s[0][i-1] != '#') {
                dp[0][i]++;
            }
        }
    }
    for (int i = 1; i < H; i++) {
        dp[i][0] = dp[i-1][0];
        if (s[i][0] == '#') {
            if (s[i-1][0] != '#') {
                dp[i][0]++;
            }
        }
    }

    for (int i = 1; i < H; i++) {
        for (int j = 1; j < W; j++) {
            int up = dp[i-1][j];
            int left = dp[i][j-1];
            if (s[i][j] == '#') {
                if (s[i-1][j] != '#') {
                    up++;
                }
                if (s[i][j-1] != '#') {
                    left++;
                }
                if (up < left) {
                    dp[i][j] = up;
                } else {
                    dp[i][j] = left;
                }
            } else {
                dp[i][j] = min(up, left);
            }
        }
    }
    cout << dp[H-1][W-1] << endl;
}

Measured memory_bytes: 256
using System;

public class Hello
{
    public static void Main()
    {
        string[] line = Console.ReadLine().Trim().Split(' ');
        var n = int.Parse(line[0]);
        var k = int.Parse(line[1]);
        Console.WriteLine((k - 1) * 2 + 1 <= n ? "YES" : "NO");
    }
}

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

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

    vector<bool> flags(N, false);
    ll p, ac = 0;
    string S;
    vector<ll> was(N, 0);
    rep(i, M) {
        cin >> p >> S;
        p--;
        if (flags[p]) continue;
        if (S == "AC") {
            flags[p] = true;
            ac++;
        } else {
            was[p]++;
        }
    }
    ll wa = 0;
    rep(i, N) {
        if (flags[i]) wa += was[i];
    }
    cout << ac << ' ' << wa << endl;
    return 0;
}


Measured memory_bytes: 1024
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {	
		Scanner in = new Scanner(System.in);
		int n = in.nextInt();
		
		int[] alt = new int[n + 2];
                
		for (int i = 1; i <= n; i++) {
                    
			alt[i] = in.nextInt();
		}
		
		int[] dp = new int[n + 2];
                
                for(int i=0;i<n+2;i++){
                    
                }
		Arrays.fill(dp, Integer.MAX_VALUE);
                
		dp[1] = 0;
		
		for (int i = 1; i < n; i++) {
			dp[i + 1] = Math.min(dp[i + 1], dp[i] + Math.abs(alt[i] - alt[i + 1]));
			dp[i + 2] = Math.min(dp[i + 2], dp[i] + Math.abs(alt[i] - alt[i + 2]));
		}
                
		System.out.println(dp[n]);
	}

}

Measured memory_bytes: 48664
#include <cassert>
#include <cstdio>
#include <cmath>
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <map>
#include <queue>
#include <algorithm>

const int MOD = 1000000007, INF = 1111111111;
using namespace std;
using lint = long long;

template <class T>
ostream &operator<<(ostream &os, const vector<T> &vec) {
	for (int i = 0; i < (int)vec.size(); i++) {
		os << vec[i] << (i + 1 == vec.size() ? "" : " ");
	}
	return os;
}

#ifdef _DEBUG
template <class Head>
void dump(const char* str, Head &&h) { cerr << str << " = " << h << "\n"; };
template <class Head, class... Tail>
void dump(const char* str, Head &&h, Tail &&... t) {
	while (*str != ',') cerr << *str++; cerr << " = " << h << "\n";
	dump(str + 1, t...);
}
#define DMP(...) dump(#__VA_ARGS__, __VA_ARGS__)
#else 
#define DMP(...) ((void)0)
#endif

int main() {

	cin.tie(nullptr);
	ios::sync_with_stdio(false);

	int N, Z, W;
	cin >> N >> Z >> W;
	
	vector<lint> a(N);
	for (int i = 0; i < N; i++) cin >> a[i];

	cout << max(abs(W - a[N - 1]), N > 1 ? abs(a[N - 1] - a[N - 2]): 0) << "\n";

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i, n) for(int i=0; i<n; i++)
#define REP(i, n) for(int i=0; i<=n; i++)
#define repr(i, n) for(int i=n; i>0; i--)
#define REPR(i, n) for(int i=n; i>=0; i--)
typedef long long ll;
const ll INF = 1LL<<60;
const int INT_INF = 1e9;
const ll MOD = 1e9+7;
template<class T> void puts(T x) { std::cout << x << std::endl; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
using namespace std;

int n;
vector<ll> a, b, c;

int main() {
    cin >> n;
    a.resize(n); b.resize(n); c.resize(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(b.begin(), b.end());
    sort(c.begin(), c.end());

    ll ans = 0;
    rep(i, n) {
        ll pos = b[i];
        auto iter_a = lower_bound(a.begin(), a.end(), pos);
        auto iter_c = upper_bound(c.begin(), c.end(), pos);
        ll da = distance(a.begin(), iter_a);
        ll dc = distance(iter_c, c.end());
        ans += da * dc;
    }
    cout << ans << endl;
}


Measured memory_bytes: 2560
import java.util.*; 

class Main{
public static void main(String[] args){
	Scanner sc=new Scanner(System.in);
        
        String s=sc.next();
  		int a=Integer.parseInt(s.substring(0,2));
        int b=Integer.parseInt(s.substring(2,4));

 	if(a<13&&a>0&&b>0&&b<13){
    		System.out.println("AMBIGUOUS");
    	}else if(a<13&&a>0){
     		System.out.println("MMYY");
   	 }else if(b<13&&b>0){
    	System.out.println("YYMM");
    }else{

    	System.out.println("NA");
    }
    }
}



Measured memory_bytes: 23252
#include <algorithm>
#include <iostream>
#include <string>
#include <set>

using namespace std;

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

  while (m--) {
    set<string> ss;
    string s; cin >> s;
    int len = s.length();

    for (int i = 0; i < len-1; i++) {
      string head = s.substr(0, i+1);
      string tail = s.substr(i+1, len-i-1);

      for (int bit = 0; bit < 4; bit++) {
        string a = head;
        string b = tail;
        if ( (bit>>1) & 1 ) { reverse(a.begin(), a.end()); }
        if ( bit & 1 ) { reverse(b.begin(), b.end()); }
        ss.insert(a+b);
        ss.insert(b+a);
      }
    }
    cout << ss.size() << endl;
  }

  return 0;
}


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

using namespace std;

#define debug(n) cerr << #n << ':' << n << endl;
#define dline    cerr << __LINE__ << endl;

using ll = long long;
using ull = unsigned long long;
template<class T, class U> using P = pair<T,U>;
template<class T> using Heap = priority_queue<T>;
template<class T> using heaP = priority_queue<T,vector<T>,greater<T>>;
template<class T,class U> using umap = unordered_map<T,U>;
template<class T> using uset = unordered_set<T>;

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

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

template<class T, size_t N, class U>
void Fill(T (&a)[N], const U&v){
    fill((U*)a,(U*)(a+N),v);
}

template<class T>
istream& operator >> (istream&is, vector<T>&v){
  for(auto&e:v)is >> e;
  return is;
}

int main(){
  string s; cin >> s;
  string t; cin >> t;
  int sn = (int)s.size();
  int tn = (int)t.size();
  int pos = -1;
  for(int i = 0; i < sn; ++i){
    int len = 0;
    while(i+len < sn && (s[i+len] == t[len] || s[i+len] == '?') && len < tn)len++;
    if(len == tn)pos = i;
  }
  if(pos == -1){
    cout << "UNRESTORABLE" << endl;
  } else {
    for(int i = 0; i < sn; ++i){
      if(pos <= i && i < pos + tn){
	cout << t[i - pos];
      } else {
	if(s[i] == '?') cout << 'a';
	else cout << s[i];
      }
    }
    cout << endl;
  }
}



Measured memory_bytes: 3612
#include <stdio.h>
 
#define BIG ((long long) 1e18)

int main(void)
{
    int n;
    long long as[100000];
    scanf("%d", &n);
 
    long long ans = 1;
    for (int i = 0; i < n; i++)
    {
        scanf("%lld", &as[i]);
    }
 
    for (int i = 0; i < n; i++)
    {
        if (as[i] == 0)
        {
            printf("0\n");
            return 0;
        }
    }
 
        for (int i = 0; i < n; i++)
        {
            if (as[i] > BIG / ans)
            {
                printf("-1\n");
                return 0;
            }
            ans *= as[i];
        }
 
    printf("%lld\n", ans);
 
    return 0;
}


Measured memory_bytes: 2460
#include <stdio.h>
#define max(x, y) ((x)<(y) ? (y) : (x))

int main(){
  int n, m, k;  scanf("%d %d %d", &n, &m, &k);
  long a[200005] = {0}, b[200005] = {0}, now;
  for(int i=1; i<=n; i++){
    scanf("%ld", &now);
    a[i] = a[i-1] + now;
  }
  for(int i=1; i<=m; i++){
    scanf("%ld", &now);
    b[i] = b[i-1] + now;
  }

  long ans = 0;
  int pre = m;
  for(int i=0; i<=n; i++){
    while(a[i] + b[pre] > k)  pre--;
    ans = max(ans, i+pre);
  }
      
  printf("%ld\n", ans);

  return 0;
}


Measured memory_bytes: 4824
#include <cstdio>
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <queue>

using namespace std;

int main(){
	
	long long int N, Z, W;
	cin >> N >> Z >> W;
	
	long long int s_max[3000], s_min[3000], a[3000];
	
	for(int i = 1; i <= N; i++){
		cin >> a[i];
	}
	a[0] = W;
	
	s_max[N] = abs(a[N] - W);
	
	for(int i = N - 1; i >= 0; i--){
		s_max[i] = abs(a[i] - a[N]);
		s_min[i] = abs(a[i] - a[N]);
		for(int j = i + 1; j <= N - 1; j++){
			s_max[i] = max(s_min[j], s_max[i]);
		}
		for(int j = i + 1; j <= N - 1; j++){
			s_min[i] = min(s_max[j], s_min[i]);
		}
		//cout << s_max[i] << " " << s_min[i] << endl;
	}
	
	cout << s_max[0] << endl;
	
	return 0;
}

Measured memory_bytes: 256
n,m = [ int(v) for v in input().split() ]

food_list = [ 0 for i in range(m) ]
for i in range(n):
	food = [ int(v) for v in input().split() ]
	for j in range(food[0]):
		food_list[food[j+1]-1] += 1

print(food_list.count(n))

Measured memory_bytes: 3060
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
#define chmin(a, b) ((a)=min((a), (b)))
#define chmax(a, b) ((a)=max((a), (b)))
#define fs first
#define sc second
#define eb emplace_back
using namespace std;

typedef long long ll;
typedef pair<int, int> P;
typedef tuple<int, int, int> T;

const ll MOD=1e9+7;
const ll INF=1e18;
const double pi=acos(-1);
const double eps=1e-10;

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

int main(){
    int m; cin>>m;
    while(m--){
        string s; cin>>s;
        int n=s.size();
        set<string> st;

        for(int i=1; i<n; i++){
            string head = s.substr(0, i);
            string tail = s.substr(i, n-i);

            st.insert(head + tail);
            st.insert(tail + head);

            reverse(tail.begin(), tail.end());
            st.insert(head + tail);
            st.insert(tail + head);
            reverse(tail.begin(), tail.end());

            reverse(head.begin(), head.end());
            st.insert(head+tail);
            st.insert(tail + head);

            reverse(tail.begin(), tail.end());
            st.insert(head + tail);
            st.insert(tail + head);
        }

        cout << st.size() << endl;
    }
}


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

int main(){
  int N,K;
  cin >> N >> K;
  set<int> s;
  rep(i,K){
    int d;
    cin >> d;
    rep(j,d){
      int A;
      cin >> A;
      if(!(s.count(A))){
        s.insert(A);
      }
    }
  }
  cout << N - s.size() << endl;
}


Measured memory_bytes: 3640
#include<iostream>
using namespace std;
int main(void){
  int A,B,C;
  cin >> A >> B >> C;
  if(A == B){
    cout << C << endl;
  }else if(A == C){
    cout << B << endl;
  }else if(B == C){
    cout << A << endl;
  }
  
  return(0);
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
	long long a,b,c,d;
	cin>>a>>b>>c>>d;
 	long long ans = a*c , ans1 = a*d, ans2 = b*c,ans3 = d*b;
  	cout<<max(ans,max(ans1,max(ans2,ans3)));
  return 0;
}

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

#define REP(i, start, count) for(int i=(start); i<(int)(count); ++i)
#define rep(i, count) REP(i, 0, count)
#define ALLOF(c) (c).begin(), (c).end()

using ll = long long;
using ull = unsigned long long;
using veci = vector<int>;
using vecll = vector<ll>;
using vecull = vector<ull>;

string X;

int main(void) {
    cin >> X;

    stack<char> stk;

    ll ans = X.size();
    for (int i = 0;i < X.size(); ++i) {

        if (stk.size() == 0) {
            stk.push(X[i]);
            continue;
        }

        while (stk.size() >= 2) {
            char t = stk.top(); stk.pop();
            char s = stk.top(); stk.pop();

            if (s == 'S' && t == 'T') {
                ans -= 2;
                continue;
            }

            stk.push(s);
            stk.push(t);
            break;
        }

        if (X[i] == 'T' && stk.top() == 'S') {
            stk.pop();
            ans -= 2;
        }
        else {
            stk.push(X[i]);
        }

    }

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


Measured memory_bytes: 644
#include <bits/stdc++.h>
 
#define f(i,a,b) for( ll i = a; i < b ; i++ ) 
#define af(i,a,b) for( ll i = a; i >= b ; i--)
#define rep(i,a,b,k) for(ll i = a; i < b ; i+= k )
#define arep(i,a,b,k) for( ll i = a; i >= b ; i-= k)
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define sz(a) (ll) a.size()
#define all(a) a.begin(), a.end()
#define sor(a) sort( a.begin(), a.end() )
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL)
#define inter ios::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr)
 
// policy-based
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;	
 
 
using namespace std;
 
 
typedef long long ll; // int or long long
typedef long double ld;
typedef pair<ll,ll> ii ;
typedef vector<ll>  vi ;
typedef vector<ii> vii ;
 	
/*
typedef tree<
ll,
null_type,
less<ll>,
rb_tree_tag,
tree_order_statistics_node_update>
ordered_set;
*/
 
const ll MAX = 1e6+10;
const ll inf = 1e9;
 
ll a[MAX];
int main(){
	fastio;
	ll n,m,k;
	cin>>n;
	ll ans = 0,c = 0;
	f(i,0,n) cin>>a[i];
	sort(a,a+n);
	c++,ans += a[n-1];
	f(i,2,n){
		if(c == n-1) break;
		if(c == n-2) ans+=a[n-i],c++;
		if(c < n-2){
			c+=2;
			ans += 2*a[n-i];
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 5208
#include <iostream>
#include <vector>

using namespace std;

#define F first
#define S second
typedef long long ll;
typedef pair<char, ll> P;

int main()
{
    ll len[3];    
    vector<P> X[3];
    for (int i = 0; i < 3; i++) {
        char c;
        ll l;
        while (cin >> c, c != '$') {
            cin >> l;
            X[i].push_back(P(c, l));
        }
        len[i] = X[i].size();
    }
    for (int i = 0; i <= len[0]-len[1]; i++) {
        bool same = 1;
        for (int j = i; j < i+len[1]; j++) {
            if (X[1][j-i].F != X[0][j].F ||
                (i < j && j < i+len[1]-1 && X[1][j-i].S != X[0][j].S)) {
                same = 0;
                break;
            }
        }
        if (X[0][i].S < X[1][0].S || X[0][i+len[1]-1].S < X[1][len[1]-1].S) {
            continue;
        }

        if (same) {
            vector<P> v, res;
            for (int j = 0; j < i; j++) {
                v.push_back(X[0][j]);
            }
            ll diff = X[0][i].S - X[1][0].S;
            if (len[1] != 1) {
                if (diff > 0) {
                    v.push_back(P(X[0][i].F, diff));      
                }
                for (int j = 0; j < len[2]; j++) {
                    v.push_back(X[2][j]);
                }
                diff = X[0][i+len[1]-1].S - X[1][len[1]-1].S;
                if (diff > 0) {
                    v.push_back(P(X[0][i+len[1]-1].F, diff));
                }
            } else {
                for (int j = 0; j < len[2]; j++) {
                    v.push_back(X[2][j]);
                }                
                if (diff > 0) {
                    v.push_back(P(X[0][i].F, diff));   
                }
            }
            for (int j = i+len[1]; j < len[0]; j++) {
                v.push_back(X[0][j]);
            }
            
            for (int j = 0; j < (int)v.size(); ) {
                ll k = j, sum = 0;
                while (k < (ll)v.size() &&
                       v[j].F == v[k].F) {
                    sum += v[k].S;
                    k++;
                }
                res.push_back(P(v[j].F, sum));
                j = k;
            }
            X[0] = res;
            break;
        }
    }
    for (int i = 0; i < X[0].size(); i++) {
        cout << X[0][i].F << " " << X[0][i].S << " ";
    }
    cout << "$" << endl;
    return 0;
}

Measured memory_bytes: 3220
#include <stdio.h>

int main(void) {
	char input[3][12];
	int win;
	int i;
	while(1) {
		fgets(input[0],sizeof(input[0]),stdin);
		if(input[0][0]=='0')break;
		fgets(input[1],sizeof(input[1]),stdin);
		fgets(input[2],sizeof(input[2]),stdin);
		win=0;
		for(i=0;i<3;i++) {
			if(input[i][0]==input[i][1] &&
			   input[i][1]==input[i][2] &&
			   input[i][0]!='+') {
				printf("%c\n",input[i][0]);
				win=1;
				break;
			}
			if(input[0][i]==input[1][i] &&
			   input[1][i]==input[2][i] &&
			   input[0][i]!='+') {
				printf("%c\n",input[0][i]);
				win=1;
				break;
			}
		}
		if(!win) {
			if(input[0][0]==input[1][1] &&
			   input[1][1]==input[2][2] &&
			   input[0][0]!='+')printf("%c\n",input[0][0]);
			else if(input[0][2]==input[1][1] &&
			        input[1][1]==input[2][0] &&
			        input[0][2]!='+')printf("%c\n",input[0][2]);
			else puts("NA");
		}
	}
	return 0;
}

Measured memory_bytes: 0
#!/usr/bin/env ruby
require 'bigdecimal'

n, m = gets.chomp.split.map(&:to_i)
a = gets.chomp.split.map(&:to_i)

ans = 0
total_vote = a.sum

a.each do |a_i|
  ans += 1 if a_i >= BigDecimal(total_vote) / (4 * m)
end

puts ans >= m ? 'Yes' : 'No'


Measured memory_bytes: 14516
from collections import Counter

n = int(input())
l = list(map(int, input().split()))

l_counter = Counter(l)
l_set = sorted(list(l_counter.keys()))

length = len(l_set)
ans = 0
if n < 3:
    print(0)
else:
    for i in range(length - 2):
        for j in range(i + 1, length - 1):
            for k in range(j + 1, length):
                if l_set[k] < l_set[i] + l_set[j]:
                    ans += l_counter[l_set[i]] * l_counter[l_set[j]] * l_counter[l_set[k]]

    print(ans)

Measured memory_bytes: 9460
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
ll p=pow(10,9)+7;
ll phi(ll n) {
    ll result = n;
    for (ll i = 2; i * i <= n; i++) {
        if(n % i == 0) {
            while(n % i == 0)
                n /= i;
            result -= result / i;
        }
    }
    if(n > 1)
        result -= result / n;
    return result;
}
ll power(ll x, ll y, ll p) 
{ 
    ll res = 1;      
    x = x % p;  
   while (y > 0) 
    { 
        if (y & 1) 
            res = (res*x) % p; 
        y = y>>1; 
        x = (x*x) % p; 
    } 
    return res; 
} 

ll modInverse(ll n, ll p) 
{ 
    return power(n, p-2, p); 
}


int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n,i,j;
    cin>>n;
    ll arr[n];
    for(i=0;i<n;i++)
    cin>>arr[i];
    ll dp[n];
    dp[0]=0;
    dp[1]=abs(arr[1]-arr[0]);
    for(i=2;i<n;i++)
    dp[i]=std::min(dp[i-2]+abs(arr[i]-arr[i-2]),dp[i-1]+abs(arr[i]-arr[i-1]));
    cout<<dp[n-1]<<endl;
    
    

 
    return 0;
    
}
    



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

int  main()
{
	int n; cin >> n;
	printf("%d\n", (int)(floor(sqrt(n)) * floor(sqrt(n))));
	return (0);
}


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

typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll,ll> pll;
typedef vector<bool> vb;
const ll oo = 0x3f3f3f3f3f3f3f3f;
const double eps = 1e-9;
#define sz(c) ll((c).size())
#define all(c) begin(c), end(c)
#define FOR(i,a,b) for (ll i = (a); i < (b); i++)
#define FORD(i,a,b) for (ll i = (b)-1; i >= (a); i--)
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define xx first
#define yy second
#define TR(X) ({ if(1) cerr << "TR: " << (#X) << " = " << (X) << endl; })

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	
	ll a, b, c, n;
	cin >> a >> b >> c >> n;

	ll res = 0;
	FOR(i,0,n+1) FOR(j,0,n+1) {
		ll r = n - i*a - j*b;
		if (r < 0 || r%c != 0) continue;
		res++;
	}
	cout << res << endl;
}



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

using namespace std;

#define fastio ios::sync_with_stdio(false), cin.tie(0), cout.tie(0)
#define int long long

const int N = 5007, inf = 1e18;
int n, a[N], dp[N][N];

int rec(int l, int r)
{
    if (dp[l][r] != -inf)
        return dp[l][r];
    dp[l][r] = max(a[l] - rec(l + 1, r), a[r] - rec(l, r - 1));
    return dp[l][r];
}

void preset()
{
    for (int i = 0; i < N; ++i)
    {
        for (int j = 0; j < N; ++j)
        {
            dp[i][j] = -inf;
        }
    }
}

signed main()
{
    fastio;
    preset();
    cin >> n;
    int sum = 0;
    for (int i = 0; i < n; ++i)
    {
        cin >> a[i];
        sum += a[i];
    }
    for (int i = 0; i < n; ++i)
    {
        dp[i][i] = a[i];
    }
    cout << rec(0, n - 1);
    return 0;
}

/* input

*/

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

string s;
int ans;
int main()
{
	cin >> s;
	ans = 2e9;
	for(int i = 0; i < s.size()-2; i++){
		int num = 0;
		for(int j = i; j < i+3; j++)
			num = num * 10 + s[j] - 48;
		if(abs(753-num) < ans) ans = abs(753-num);
	}
	cout << ans << endl;
	return 0;
 } 

Measured memory_bytes: 256
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef map<int, int> mii;
typedef map<char,int> mci;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
typedef vector<pair<int,int>> vii;
typedef vector<char> vc;
typedef vector<vc> vcc;
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define pb push_back
#define F first
#define S second
#define in insert
#define mina(a,b) (a)=min((a),(b));
#define maxa(a,b) (a)=max((a),(b));
const int INF = 1e9 + 7;
void solve(){
    char c; cin>>c;
    if(c=='A') cout<<"T";
    if(c=='T') cout<<"A";
    if(c=='C') cout<<"G";
    if(c=='G') cout<<"C";

}
int main(){
    int T=1;
    //cin>>T;
    for(int i = 0; i < T; i++) solve(); 
}

Measured memory_bytes: 256
from collections import deque
n,q = map(int,input().split())
graph = [[] for _ in range(n)]
cnt = [0] * n
already = [False] * n

for i in range(n-1):
    a,b = map(int,input().split())
    a -= 1
    b -= 1
    graph[a].append(b)
    graph[b].append(a)
    
for i in range(q):
    p,x = map(int,input().split())
    cnt[p-1] += x
wait_q = deque()
wait_q.append(0)

while len(wait_q) > 0:
    parent = wait_q.popleft()
    already[parent] = True
    for child in graph[parent]:
        if child == 0:continue
        if already[child] == True:continue
        cnt[child] += cnt[parent]
        wait_q.append(child)
print(*cnt)


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

int64_t binomial(int64_t N, int64_t K) {
  if(K < 0 || N < K) return 0;
  int64_t ret = 1;
  for(int64_t i = 1; i <= K; ++i) {
    ret *= N--;
    ret /= i;
  }
  return ret;
}

int main(){

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

  sort(v.begin(),v.end(),greater<int64_t>());
  double av=0;
  for(int i=0;i<A;++i) av += v[i];
  av /= A;

  cout<<fixed<<setprecision(10);
  cout<<av<<endl;

  int n=0,m=0;
  for(int i=0;i<N;++i){
    if(v[i]==v[A-1]){
      ++n;
    if(i<A) ++m;
    }
  }
  int64_t ans=0;
  ans += binomial(n,m);
  if(m==A){
    for(int i=A+1;i<=B;++i) ans += binomial(n,i);
  }
  
  cout<<ans<<endl;
}


Measured memory_bytes: 256
// --------------------<optimizations>--------------------
#pragma GCC optimize("O3")
//(UNCOMMENT WHEN HAVING LOTS OF RECURSIONS)\
#pragma comment(linker, "/stack:200000000")
//(UNCOMMENT WHEN TRYING TO BRUTEFORCE WITH A LOT OF LOOPS)\
#pragma GCC optimize("unroll-loops")

#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimization ("unroll-loops")

#include<bits/stdc++.h>

using namespace std;

#define int long long
#define ll long long
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define pii pair<ll,ll>
#define vpii vector<pair<ll,ll> >
#define F first
#define S second
#define ld long double
#define built __builtin_popcountll
#define mst(a,i) memset(a,i,sizeof(a))
#define all(x) x.begin(),x.end()
#define itit(it,a) for(auto it=(a).begin(); it!=(a).end(); it++)
#define rep(i,a,b) for(ll i=a; i<b; i++)
#define repr(i,a,b) for(ll i=a; i>b; i--)
#define reprr(i,a,b) for(ll i=a; i>=b; i--)
#define pi 3.14159265358979323846264338327950288419716939937510582097494459230
ll max3(ll x,ll y,ll z) {return max(max(x,y),z);}
ll min3(ll x,ll y,ll z) {return min(min(x,y),z);}
const ll N=1e5+10,M=2e5+10,M2=1e6+10,mod=1e9+7,inf=1e17+10;
const int INF=1e9+7;
void add(int& a, int b) {a+=b;if(a>=mod){a-=mod;}}
#define trace1(x)            cerr<<#x<<": "<<x<<endl
#define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z)             cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define trace4(a, b, c, d)         cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define trace5(a, b, c, d, e)         cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
#define trace6(a, b, c, d, e, f)     cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl
int X[] = {0, 1, 0, -1};
int Y[] = {-1, 0, 1, 0};
ll power(ll x,ll n){ll result=1;while(n>0){if(n%2==1)result=(result*x)%mod; x=((x%mod)*(x%mod))%mod;n=n/2;}return result;}


int32_t main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    ll n;
    cin >> n;
    if(n%2==0) cout << n/2-1;
    else cout << n/2;
    return 0;
}
/* The judge is never wrong! Your code is buggy
   Look for:
 * * Read the problem carefully.
 * * Don't forget to sort(), mod, ll!!!!
 * * Initial value = +/- infinity instead of zero!!!
 * * an easier and alternate approach
 * * read the problem statement carefully
 * * if concept is correct and still WA, try with a different implementation
 * * special cases (n=1?)
 * * if you have no idea just guess the appropriate well-known algorithm instead of doing nothing :/
 */


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

ans = 1
prev = 0
for i in range(1, N + 1):
    count = 0
    tmp = i
    while i % 2 == 0 and 1 < i:
        count += 1
        i /= 2
    if prev < count:
        prev = count
        ans = tmp

print(ans)


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

int main()
{
  int n;
  cin >> n;
  vector<int> v(n);
  for (int i = 0; i < n; i++)
  {
    cin >> v.at(i);
  }
  
  sort(v.begin(), v.end());
  double tmp = (double)(v[0] + v[1]) / 2;
  for (int i = 2; i < n; i++)
  {
    //cout << v[i] << endl;
    tmp = (double)(tmp + v[i]) / 2;
    //cout << tmp << endl;
  }
  cout << tmp << endl;
}

Measured memory_bytes: 256
def gcd(a,b):
    while b!=0:
        a,b=b,a%b
    return a
def lcm(a, b):
    return (a * b)//gcd(a,b)

N = int(input())
a = list(map(int,input().split()))

ans = 0
l = 1

for i in range(N):
    l = lcm(l,a[i])
l -= 1
for i in range(N):
    ans += l%a[i] 

print(ans)

Measured memory_bytes: 3316
#include <iostream>
#include <cmath>
#include <vector>
#include <bitset>
#include <algorithm>
#include <stack>
#include <queue>
#include <map>
#include <climits>
#include <set>
#include <map>
#include <iomanip>
#include <cassert>
#include <functional>
#include <cstring>

using namespace std;

#define mp make_pair
#define FOR(i, a, b) for(int (i)=a;(i)<=(b);++(i))
#define rep(i, n)  FOR(i,0,n-1)
#define FFOR(i, a, b) for(int (i)=a;(i)>(b);--(i))
#define rrep(i,n) FFOR(i,0,n)
#define vsort(v) sort((v).begin(), (v).end());					//小さい順
#define rvsort(v) sort(v.begin(), v.end(),greater<>());		//大きい順
#define YES cout<<"YES"<< endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl  
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
#define all(c) (c).begin(),(c).end()
#define ll long long
#define lb long double
#define vi vector<int>
#define vvi vector<vector<int>>
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vb vector<bool>
#define vvb vector<vector<bool>>
#define vs vector<string>
#define vc vector<char>
#define vvc vector<vector<char>>
#define Print(p) cout<<(p)<<endl
#define F first
#define S second
#define pb push_back
#define ll long long
#define mod 1000000007LL
#define INF 123456789012345
typedef pair<int, int> P;
typedef pair<int, P> PP;

const int maxn =1e5 + 10;


int main() {
	
	long double n,m,d;cin>>n>>m>>d;
	long double ans = 2*(n-d)*(m-1)/n/n;
	if(d==0) ans = (m-1)/n;
	cout << fixed;
	cout << setprecision(10) << ans << endl;


	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
main()
{
  int A,B;
  scanf("%d%d",&A,&B);
  int a,b,i,c;
  for(i=1;i<=1250;i++)
  {
  	a=i*0.08;
  	b=i*0.1;
  	if((a==A)&&(b==B))
  	{
  		c=i;
  		break;
	  }
  	else
  	c=-1;
  }
  printf("%d",c);
}


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

void solve();

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

void solve() {
  string s, t;
  cin >> s >> t;
  {
    set<char> st;
    for (char si : s) st.emplace(si);
    for (char ti : t) if (st.count(ti) == 0) { cout << -1 << endl; return; }
  }
  s += s;
  vector<vector<int> > x(26);
  rep(i, sz(s)) x[s[i] - 'a'].eb(i);

  int it = -1;
  int r = 0;
  for (char ti : t) {
    it = ub(x[ti - 'a'], it); // debuged
    it = x[ti - 'a'][it];
    if (it >= sz(s) / 2) {
      it -= sz(s) / 2;
      r++;
    }
  }
  cout << r * 1LL * sz(s) / 2 + it + 1 << endl;
}
/*
abc
aaaa

x 1
*/


Measured memory_bytes: 2024
#include <ctime>
#include <iomanip>
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <cstdio>
#include <list>
#include <queue>
using namespace std;

#define int long long
#define INF 1e18
#define EPS 1e-9

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

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

signed main() {
    int n; cin >> n;
    vector<vector<int>> v(n, vector<int> (3));
    for(int i = 0; i < n; i++) for(int j = 0; j < 3; j++) cin >> v[i][j];
    vector<vector<int>> dp(n, vector<int> (3, 0));

    for(int i = 0; i < 3; i++) {
        dp[0][i] = v[0][i];
    }

    for(int i = 1; i < n; i++) {
        for(int j = 0; j < 3; j++) {
            for(int k = 0; k < 3; k++) {
                if(j == k) continue;
                chmax(dp[i][k], dp[i - 1][j] + v[i][k]);
            }
        }
    }

    int ans = 0;
    for(int i = 0; i < 3; i++) {
        ans = max(ans, dp[n - 1][i]);
    }
    cout << ans << endl;
}


Measured memory_bytes: 11136
#include<iostream>
#include<fstream>
#include<stdio.h>
#include<string>
#include<vector>
#include<map>
#include<math.h>
#include<algorithm>
#include<iomanip>
#include<set>
#include<utility>

using namespace std;

int main() {
  string s;
  cin >> s;
  int a, b, c, d;
  a = s[0] - '0';
  b = s[1] - '0';
  c = s[2] - '0';
  d = s[3] - '0';
  for(unsigned int i = 0; i < 8; i++) {
    int ret = a;
    if((i & 1) > 0) ret += b;
    else ret -= b;
    if((i & 2) > 0) ret += c;
    else ret -= c;
    if((i & 4) > 0) ret += d;
    else ret -= d;
    if(ret == 7) {
      cout << a << (((i & 1) > 0) ? '+' : '-') << b << (((i & 2) > 0) ? '+' : '-') << c << (((i & 4) > 0) ? '+' : '-') << d << "=7" << endl;
      break;
    }
  }
  return 0;
}


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

using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
typedef pair<ll, ll> Pll;
typedef vector<int> Vi;
//typedef tuple<int, int, int> T;
#define FOR(i,s,x) for(int i=s;i<(int)(x);i++)
#define REP(i,x) FOR(i,0,x)
#define ALL(c) c.begin(), c.end()
#define DUMP( x ) cerr << #x << " = " << ( x ) << endl

const int dr[9] = {-1, -1, -1, 0, 1, 1, 1, 0, 0};
const int dc[9] = {-1, 0, 1, 1, 1, 0, -1, -1, 0};

int main() {
  // use scanf in CodeForces!
  cin.tie(0);
  ios_base::sync_with_stdio(false);

  int H, W, N; cin >> H >> W >> N;
  vector<P> black(N);
  set<P> black_set;
  REP(i, N) {
    int a, b; cin >> a >> b; a--, b--;
    black[i] = P(a, b);
    black_set.insert(P(a, b));
  }

  vector<ll> cnt(10, 0LL);
  set<P> done;
  cnt[0] = (ll)(H-2) * (ll)(W-2);

  for (P p : black) {
    int r = p.first, c = p.second;
    REP(i, 9) {
      int cr = r+dr[i], cc = c+dc[i];
      if (cr <= 0 or cr >= H-1 or cc <= 0 or cc >= W-1 or done.find(P(cr, cc)) != done.end()) continue;
      done.insert(P(cr, cc));
      int r_cnt = 0;
      REP(i, 9) {
        int nr = cr + dr[i], nc = cc + dc[i];
        if (black_set.find(P(nr, nc)) != black_set.end()) r_cnt++;
      }
      cnt[r_cnt]++;
      cnt[0]--;
    }
  }
  for (ll c : cnt) cout << c << endl;

  return 0;
}


Measured memory_bytes: 47872