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

#define ALL(v) (v).begin(), (v).end()
#define rep(i, n) for (ll i = 0, __##i##_length = (n); i < __##i##_length; i++)
#define rep_reverse(i, n) for (ll i = (n)-1; 0 < i; i--)
#define FOR(i, from, to)                                                       \
  for (ll i = (from), __##i##_end = (to); i < __##i##_end; i++)
#define FOR_REVERSE(i, from, to)                                               \
  for (ll i = (to)-1, __##i##_end = (from); __##i##_end <= i; i--)
#define foreach(e, v) for (const auto e : (v))
#define vfree(v) std::vector<int>().swap(v)
#define DEBUG(x) cout << #x << " = " << (x) << endl

using namespace std;
typedef int64_t ll;
typedef vector<ll> llv;
typedef vector<llv> llvv;

#define MOD (ll)1000000007

int main() {
  ll n, m;
  cin >> n >> m;
  llv ans(n, -1);
  bool flag = true;
  rep(i, m) {
    ll s, c;
    cin >> s >> c;
    if (ans[s - 1] < 0) {
      ans[s - 1] = c;
    } else {
      flag = (ans[s - 1] == c);
    }
  }

  if (n == 1 && ans[0] < 1) {
    cout << 0 << endl;
    return 0;
  }
  if (flag && ans[0] != 0) {
    if (ans[0] == -1)
      ans[0] = 1;
    rep(i, n) cout << ((ans[i] == -1) ? 0 : ans[i]);
    puts("");
  } else {
    cout << -1 << endl;
  }
}

Measured memory_bytes: 256
# !/usr/bin/python3

"""
https://atcoder.jp/contests/abc179/tasks/abc179_a
A - Plural Form .
"""

def solve(s):
    if s[-1] == 's': print(s + "es")
    else: print(s + 's')

    return


if __name__ == "__main__":
    s = input()
    solve(s)


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

#define ll long long
#define str string
#define pii pair<int, int>
#define pll pair<ll, ll>
#define fi first
#define se second

#define vc vector<char>
#define vvc vector<vc>
#define vi vector<int>
#define vll vector<ll>
#define vvi vector<vi>
#define vvll vector<vll>
#define vvvll vector<vvll>
#define vs vector<str>
#define vvs vector<vs>
#define vpii vector<pii>
#define vvpii vector<vpii>
#define vpll vector<pll>
#define vvpll vector<vpll>
#define vb vector<bool>
#define vvb vector<vb>
#define rep(i, a, b) for (int i = (a); i < int(b); i++)
#define repi(i, a, b) for (int i = (a); i <= int(b); i++)


using namespace std;
ll INF = LONG_LONG_MAX;
ll mod = 1000000000 + 7;

template <typename T, typename L>
void read(vector<T> & _data, L & _size, bool _shift) {
    _data.resize(_size + (ll)_shift);
    for (ll i = (ll)_shift; i < _size + (ll)_shift; i++)
        cin >> _data[i];
}

template <typename T, typename L>
void read(vector<vector<T>> & _data, L & _rows, L & _cols, bool _shiftRows, bool _shiftCols) {
    _data.resize(_rows + (ll)_shiftRows);
    for (ll i = 0; i < _rows + (ll)_shiftRows; i++)
        _data[i].resize(_cols + (ll)_shiftCols);
    for (ll i = (ll)_shiftRows; i < _rows + (ll)_shiftRows; i++)
        for (ll j = (ll)_shiftCols; j < _cols + (ll)_shiftCols; j++)
            cin >> _data[i][j];
}

template <typename T>
void write(vector<T> & _data, bool _shift) {
    for (ll i = (ll)_shift; i < _data.size(); i++)
        cout << _data[i] << " ";
    cout << endl;
}


//TODO: SOLUTION


void solve() {
    str s; cin >> s;
    ll n = s.size();
    ll ans = n;
    rep(i, 0, n - 1) {
        if (s[i] != s[i + 1]) {
            ans = min(ans, max((ll)i + 1, n - i - 1));
        }
    }
    cout << ans << endl;
}


int main() {

    // TODO: Set value of this variable manually
    bool _multipleTestCases = false;

    if (_multipleTestCases) {
        ll t; cin >> t;
        while (t--)
            solve();
    }
    else {
        solve();
    }

    return 0;
}

Measured memory_bytes: 3692
#include <iostream>
#include <sstream>
#include <string>
#include <cmath>
#include <cstdio>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <functional>
#include <numeric>

using namespace std;
typedef unsigned int uint;
typedef long long ll;
typedef unsigned long long ull;

#define REP(i,n) for(int i = 0; i < (int)(n); ++i)
#define FOR(i,a,b) for(int i = (a); i < (int)(b); ++i)
#define ALL(c) (c).begin(), (c).end()
#define SIZE(v) ((int)v.size())

#define pb push_back
#define mp make_pair

ll gcd(ll a, ll b)
{
    while(1)
    {
        if (a == 0) return b;
        b %= a;
        if (b == 0) return a;
        a %= b;
    }
}

ll lcm(ll a, ll b)
{
    ll temp = gcd(a, b);
    return temp ? (a / temp * b) : 0;
}

int main(void)
{
    cin.sync_with_stdio(false);
    int a, b;
    while(cin >> a >> b){
        cout << gcd(a,b) << " " << lcm(a,b) << endl;
    }
    
    return 0;
}

Measured memory_bytes: 1180
import java.util.*;
public class Main{
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		int n = sc.nextInt();
		int m = sc.nextInt();
		int[][] data = new int[n][m];
		int[] ans = new int[m];
		int anscount = 0;

		for (int i = 0;i<m ;i++ ) {
			ans[i]= i+1;
		}

		for (int i = 0;i<n ;i++ ) {
			int k = sc.nextInt();
			for (int j = 0;j<k ;j++ ) {
				data[i][j] = sc.nextInt();
			}
		}

		for (int k = 0;k<m ;k++ ) {
			int count = 0;
			for (int i = 0;i<n ;i++ ) {
				for (int j = 0;j<m ;j++ ) {
					if (data[i][j]==ans[k]) {
						count++;
					}
				}
			}
			if (count==n) {
				anscount++;
			}
		}


		System.out.println(anscount);
	}
}


Measured memory_bytes: 22484
local x, y = io.read("n", "n")
local g1 = {1,3,5,7,8,10,12}
local g2 = {4,6,9,11}
local g3 = {2}
local function get(i)
    local groups = {g1,g2,g3}
    for k,v in ipairs(groups) do
        for kk,vv in ipairs(v) do
            if i == vv then
                return k
            end
        end
    end
    return -1
end
if get(x) == get(y) then print('Yes')
else print('No') end

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

using namespace std;

#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define rrep(i, n) for (ll i = (n - 1); i >= 0; --i)
#define blank(ans) cout << (ans) << " ";
#define mp(p, q) make_pair(p, q)
#define mt(p, q, r) make_tuple(p, q, r)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef string str;

typedef vector<ll> vll;
typedef vector<ld> vd;
typedef vector<bool> vb;
typedef vector<char> vc;
typedef vector<str> vs;
typedef vector<vector<ll>> vvll;
typedef vector<vector<ld>> vvd;
typedef vector<vector<bool>> vvb;
typedef vector<vector<char>> vvc;
typedef vector<vector<str>> vvs;
typedef vector<pair<ll, ll>> vpll;
typedef vector<tuple<ll, ll, ll>> vtlll;

const ld PI = acos(-1.0);
const ll MAX = 9000000000000000000;
const ll MIN = -9000000000000000000;
const ld DMAX = 4500;
const ld DMIN = -4500;
const ll MOD = 1000000007;

template <typename T>
void fin(T a)
{
  cout << a << endl;
  exit(0);
}

bool IsPrime(ll num)
{
  if (num < 2)
    return false;
  else if (num == 2)
    return true;
  else if (num % 2 == 0)
    return false;
  ld sqrtNum = sqrt(num);
  for (ll i = 3; i <= sqrtNum; i += 2)
  {
    if (num % i == 0)
      return false;
  }
  return true;
}

ll gcd(ll a, ll b)
{
  return b ? gcd(b, a % b) : a;
}

ll ngcd(vector<ll> a)
{
  ll res;
  res = a[0];
  for (ll i = 1; i < a.size() && res != 1; i++)
  {
    res = gcd(a[i], res);
  }
  return res;
}

vector<ll> enum_div(ll n)
{
  vector<ll> ret;
  for (ll i = 1; i * i <= n; ++i)
  {
    if (n % i == 0)
    {
      ret.push_back(i);
      if (i * i != n)
      {
        ret.push_back(n / i);
      }
    }
  }
  sort(begin(ret), end(ret));
  return ret;
}

//実行部
void Main()
{
  ll n; cin >> n;
  vll a(n);
  ll ans = 1;
  rep(i, n)
  {
    cin >> a[i];
  }
  sort(all(a));
  vll f = enum_div(a[0]);
  reverse(all(f));
  for(ll i = 0;i < f.size();i++)
  {
    ll flag = 0;
    for(ll j = 0;j < n;j++)
    {
      if(a[j] % f[i] != 0) flag++;
    }
    if(flag <= 1)
    {
      ans = f[i];
      break;
    }
  }
  vll F = enum_div(a[1]);
  reverse(all(F));
  for(ll i = 0;i < F.size();i++)
  {
    ll flag = 0;
    for(ll j = 0;j < n;j++)
    {
      if(a[j] % F[i] != 0) flag++;
    }
    if(flag <= 1)
    {
      ans = max(F[i], ans);
      break;
    }
  }
  fin(ans);
}

//前処理
int main()
{
  ifstream in("text.txt");
  cin.rdbuf(in.rdbuf());
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout << fixed << setprecision(20); //高精度少数表示
  Main();
  return 0;
}

/*
//test時
  g++ test.cpp -o test;./test
*/


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

int SumOfDigits(int n){
  int sum = 0;
  while(n>0){
    sum+= n % 10;
    n /= 10;
  }
  return sum;
}

int main(void){
  int N,A,B;
  cin >> N>>A>>B;
  int total=0;
  for(int i =1;i<=N;i++){
    //int sum = 4;
    int sum = SumOfDigits(i);
    if(A<=sum &&sum<=B)total+=i;
  }
  cout<<total<<endl;
  return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
#define rep(i, begin, n) for (int i = begin; i < n; i++)
#define repe(i, begin, n) for (int i = begin; i <= n; i++)
#define repr(i, begin, n) for (int i = begin; i > begin - n; i--)
#define repre(i, begin, end) for (int i = begin; i >= end; i--)

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;
}

const int inf = 1000000007;
const int MOD = 1000000007;
const long long INF = 1000000000000000007;

// -------------------------------------------------------
ll N, P;
string S;
ll sub[201010];

int main()
{
    cin >> N >> P;
    cin >> S;
    if (P == 2)
    {
        ll ans = 0;
        rep(i, 0, N)
        {
            if ((S[i] - '0') % 2 == 0)
            {
                ans += i + 1;
            }
        }
        cout << ans << endl;
        return 0;
    }
    if (P == 5)
    {
        ll ans = 0;
        rep(i, 0, N)
        {
            if (S[i] == '5' || S[i] == '0')
            {
                ans += i + 1;
            }
        }
        cout << ans << endl;
        return 0;
    }

    ll tenfactor = 1;
    vector<ll> cnt(P, 0);
    cnt[0]++;
    for (ll i = N - 1; i >= 0; i--)
    {
        ll num = S[i] - '0';
        sub[i] = (num * tenfactor + sub[i + 1]) % P;
        cnt[sub[i]]++;
        tenfactor = (tenfactor * 10) % P;
    }
    ll ans = 0;
    for (int i = 0; i < P; i++)
    {
        ll ci = cnt[i];
        if (ci >= 2)
        {
            ans += ci * (ci - 1) / 2;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 2180
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef pair<int,int> pii;
typedef pair<int,ll> pil;
typedef pair<ll,int> pli;
typedef pair<ll,ll> pll;

template<class T,class U>constexpr bool chmin(T&a,const U b){if(a<=b)return false;a=b;return true;}
template<class T,class U>constexpr bool chmax(T&a,const U b){if(a>=b)return false;a=b;return true;}
#define bit(n,k) ( (n>>k)&1 )

//デバッグ
template<class T>
void Vout(vector<T> &V){
    cout<<"\nstart\n";
    const int sz=V.size();
    for(int i=0;i<sz;i++){
        cout<<i<<" "<<V[i]<<'\n';
    }
    cout<<"end\n"<<endl;
}

template<class T>
void VPout(vector<T> &V){
    cout<<"\nstart\n";
    const int sz=V.size();
    for(int i=0;i<sz;i++){
        cout<<i<<" "<<V[i].first<<" "<<V[i].second<<'\n';
    }
    cout<<"end\n"<<endl;
}


//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++


constexpr int MAX=1<<30;
constexpr ll INF=1LL<<62;
constexpr int MOD=1e9+7;
int dx[]={1,-1,0,0},dy[]={0,0,-1,1};

//__builtin_popcount(S);
//#define int ll
//vector<vector<int>> data(3, vector<int>(4));
//vector.resize(a,vector<int>(b,-1));
//vector<vector<vector<要素の型>>> 変数名(要素数1, vector<vector<要素の型>>(要素数2, vector<要素の型>(要素数3, 初期値)));




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

    int N,K;
    cin>>N>>K;
    double p[210000];
    for(int i=1;i<=N;i++){
        cin>>p[i];
        p[i]=(1+p[i])*p[i]/2/p[i];
    }
    for(int i=1;i<=N;i++){
        p[i]+=p[i-1];
    }
    double sum=0;
    for(int i=1;i<=N;i++){
        if(i<K) continue;
        chmax(sum,p[i]-p[i-K]);
    }
    printf("%.10lf",sum);
}

Measured memory_bytes: 1792
r, c = map(int,input().split())
b=[]
for i in range(r):    
        a=list(map(int,input().split()))
        a.append(sum(a))
        b.append(a)
        a=map(str,a)
        print(" ".join(a))
d=[]
for i in range(c+1):
    cs=[]
    for j in range(r):
        cs.append(b[j][i])
    d.append(sum(cs))
d=map(str,d)
print(" ".join(d))

Measured memory_bytes: 7764
N = list(input())

if N[-1] == '2' or N[-1] == '4' or N[-1] == '5' or N[-1] == '7' or N[-1] == '9':
  print("hon")
elif N[-1] == '0' or N[-1] == '1' or N[-1] == '6' or N[-1] == '8':
  print("pon")
elif N[-1] == '3':
  print("bon")


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

constexpr int LEN = 55;
bool m[LEN][LEN];

int main(){
	while(true){
		int w, h; cin >> w >> h;
		if(!w && !h) break;
		rep(i, h)rep(j, w) cin >> m[i][j];

		int ans = 0;
		rep(i, h)rep(j, w){
			if(!m[i][j]) continue;
			ans++;
			queue<P> q;
			q.push(make_pair(i, j));
			while(q.size()){
				P now = q.front(); q.pop();
				loop(di, -1, 2)loop(dj, -1, 2){
					int ni = now.first + di, nj = now.second + dj;
					if(0 <= ni && ni < h && 0 <= nj && nj < w && m[ni][nj]){
						m[ni][nj] = false;
						q.push(make_pair(ni, nj));
					}
				}
			}
		}
		cout << ans << endl;
	}
	return 0;
}



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

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

  	int t = 0;
  	for (int i = 3; i <= n; i += 2) {
      	int c = 0;
      	for (int j = 1; j <= n; j += 2) {
          	if (i % j == 0) {
              	c++;
            }
        }
      	if (c == 8) {
          	t++;
        }
    }
  
  
  cout << t << endl;
}


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

int main() {
  int D, G;
  cin >> D >> G;
  int p[20], c[20];
  for (int i = 0; i < D; i++) cin >> p[i] >> c[i];

  int ans = 1000000000;
  for (int bit = 0; bit < (1 << D); bit++) {
    int score = 0, num = 0;
    
    for (int i = 0; i < D; i++) {
      if (bit & (1 << i)) {
        score += 100 * (i + 1) * p[i] + c[i];
        num += p[i];
      }
    }
    
    if (score < G) {
      for (int i = D - 1; i >= 0; i--) {
        if (bit & (1 << i)) continue;
        bool ok = false;
        for (int j = 0; j < p[i]; j++) {
          score += 100 * (i + 1);
          num++;
          if (score >= G) {
            ok = true;
            break;
          }
        }
        if (ok) break;
      }
    }
    ans = min(ans, num);
  }

  cout << ans << endl;
}

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

using ll = long long;
const int mod = 1e9+7;

void add(ll &a, ll b) {
  	a+=b; if (a>=mod) a-=mod;
}
void sub(ll &a, ll b) {
  	a-=b; if (a<0) a+=mod;
}

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
  int n,m; cin >> n >> m;
  int a[n],b[m];
  for (int i = 0; i < n; i++)cin>>a[i];
    for (int j = 0; j < m; j++)cin>>b[j];
  ll dp[n+1][m+1];
  for (int i = 0; i <= n; i++)
  for (int j = 0; j <= m; j++)
      dp[i][j]=0;
  dp[0][0]=1;
  for (int i = 0; i < n; i++)
    for (int j = 0; j < m; j++) if (dp[i][j]) {
    	 if (a[i] != b[j])
           	sub(dp[i+1][j+1],dp[i][j]);
      	add(dp[i+1][j],dp[i][j]);
      add(dp[i][j+1],dp[i][j]);
    }
  ll ans = 0;
  for (int i = 0; i <= n; i++)
    for (int j = 0; j <= m; j++)
      if (i==n||j==m)
        add(ans,dp[i][j]);
  cout << ans << endl;
	return 0;
}

Measured memory_bytes: 31616
#define _USE_MATH_DEFINES
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <complex>
#include <string>
#include <vector>
#include <array>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
#include <iterator>
#include <memory>
#include <regex>
using namespace std;

const int MAX = 200000;
const int MOD = 1000000007;

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

    vector<int> index(MAX, -1);
    vector<int> nextIndex(n, -1);
    for(int i=n-1; i>=0; --i){
        nextIndex[i] = index[c[i]];
        index[c[i]] = i;
    }

    vector<long long> dp(n+1, 0);
    dp[0] = 1;
    for(int i=0; i<n; ++i){
        if(i + 1 < nextIndex[i]){
            dp[nextIndex[i]] += dp[i];
            dp[nextIndex[i]] %= MOD;
        }
        dp[i+1] += dp[i];
        dp[i+1] %= MOD;
    }
    cout << dp[n] << endl;

    return 0;
}


Measured memory_bytes: 4224
extension String: CollectionType {}

let line1 = readLine()!
var line2 = readLine()!

var N = Int(line1)!
let L = line2.split(" ").map{ Int($0)! }

let sorted = L.sort({ (first, second) -> Bool in
    return first < second                     
})
var sum = 0
var i = 0
while i < sorted.count {
  sum += min(sorted[i], sorted[i + 1])
  i += 2
}
print(sum)

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

// template {{{
#define  range(i, l, r) for (int i = (int)(l); i < (int)(r); (i) += 1)
#define rrange(i, l, r) for (int i = (int)(r) - 1; i >= (int)(l); (i) -= 1)

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

#define debug(x) cerr << "(" << __LINE__ << ")" << #x << ": " << (x) << endl

using i32 = int;
using u32 = unsigned int;
using i64 = long long;
using u64 = unsigned long long;

// constexpr i32 mod   = 998244353;
constexpr i32 mod   = 1e9 + 7;
constexpr i32 inf   = 1001001001;
constexpr i64 infll = 1001001001001001001ll;

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

struct IoSetup { IoSetup(int x = 15){ cin.tie(0); ios::sync_with_stdio(0); cout << fixed << setprecision(x); cerr << fixed << setprecision(x); } } iosetup;

template <typename T = i64> T input() { T x; cin >> x; return x; }

template <typename T> ostream &operator<<(ostream &os, vector<T> &v) { range(i, 0, v.size()) { os << v[i] << (i + 1 != v.size() ? " " : ""); } return os; }
template <typename T> istream &operator>>(istream &is, vector<T> &v) { for (T &in : v) is >> in; return is; }

template <typename T1, typename T2> ostream &operator<<(ostream &os, pair<T1, T2> p) { os << "(" << p.first << ", " << p.second << ")"; return os; }
template <typename T1, typename T2> istream &operator>>(istream &is, pair<T1, T2> &p) { is >> p.first >> p.second; return is; }

template <typename T> vector<T> make_vector(size_t a, T b) { return vector<T>(a, b); }
template <typename... Ts> auto make_vector(size_t a, Ts... ts) { return vector<decltype(make_vector(ts...))>(a, make_vector(ts...)); }

template <typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template <typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }
// }}}

void solver() {
    int n = input();
    vector< pair< int, int > > ps(n);
    for (auto &p: ps) cin >> p;

    i64 l, r;

    whole(sort, ps);
    l = ps[n / 2].first;
    if ((n & 1) == 0) l += ps[n / 2 - 1].first;

    whole(sort, ps, [&](auto a, auto b) { swap(a.first, a.second); swap(b.first, b.second); return a < b; });
    r = ps[n / 2].second;
    if ((n & 1) == 0) r += ps[n / 2 - 1].second;

    cout << r - l + 1 << endl;
}

signed main(int argc, char *argv[]) {
    solver();
}


Measured memory_bytes: 4788
#include <iostream>
#include <sstream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <memory>
#include <complex>
#include <numeric>
#include <cstdio>
#include <iomanip>

#define REP(i,m,n) for(int i=int(m);i<int(n);i++)
#define RREP(i,m,n) for(int i=int(n)-1;i>=int(m);--i)
#define EACH(i,c) for (auto &(i): c)
#define all(c) begin(c),end(c)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort(begin(c),end(c))
#define pb emplace_back
#define MP make_pair
#define SZ(a) int((a).size())

#ifdef LOCAL
#define DEBUG(s) cout << (s) << endl
#define dump(x)  cerr << #x << " = " << (x) << endl
#define BR cout << endl;
#else
#define DEBUG(s) do{}while(0)
#define dump(x) do{}while(0)
#define BR 
#endif
using namespace std;

using UI = unsigned int;
using UL = unsigned long;
using LL = long long int;
using ULL = unsigned long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VLL = vector<LL>;
using VVLL = vector<VLL>;
using VS = vector<string>;
using PII = pair<int,int>;
using VP = vector<PII>;

//struct edge {int from, to, cost;};

constexpr double EPS = 1e-10;
//constexpr double PI  = acos(-1.0);
//constexpr int INF = INT_MAX;
constexpr int MOD = 1'000'000'007;
//inline void modAdd(LL &l, LL &r) {l = (l + r) % MOD;}

template<class T> inline T sqr(T x) {return x*x;}

void solve() {
    int n,l;
    cin >> n >> l;
    int sum = 0;
    REP(i,0,n) sum += l + i;
    if (l >= 0) cout << sum - l << endl;
    else if (l + n - 1 <= 0) cout << sum - (l + n - 1) << endl;
    else cout << sum << endl;
}

int main() {
    solve();
    
    return 0;
}

Measured memory_bytes: 256
from collections import Counter

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

X = Counter(V[::2]).most_common(2)
Y = Counter(V[1::2]).most_common(2)

if X[0][0] != Y[0][0]:
    print(n - X[0][1] - Y[0][1])
else:
    x = 0 if len(X) < 2 else X[1][1]
    y = 0 if len(Y) < 2 else Y[1][1]
    if X[0][1] + y > x + Y[0][1]:
        print(n - X[0][1] - y)
    else:
        print(n - x - Y[0][1])


Measured memory_bytes: 15588
#include <iostream>
#include <string>
#include <sstream>
#include <vector>
#include <tuple>
using namespace std;

int main() {
	int N,A,B;
	cin >> N;
	if (N == 1) {
		cout << "Hello World";
	}
	else {
		cin >> A >> B;
		cout << (A + B);
	}
	return 0;
}

Measured memory_bytes: 256
/*****************************************************

@author: vichitr
Compiled On: 1st Sept 2019

*****************************************************/
#include<bits/stdc++.h>
#define MAX 9223372036854775807
#define endl "\n"
#define ll long long
#define int long long
#define double long double
#define pb push_back
#define pf pop_front
#define mp make_pair
#define ip pair<int, int>

#define loop(i,n) for(int i=0;i<n;i++)
#define loops(i,s,n) for(int i=s;i<=n;i++)
#define fast ios::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL)
using namespace std;

const ll MOD = 1009;
const ll SZ = 107;
const ll N = 5e5+7;

ll pwr(ll x, ll y)
{
    ll r = 1LL;
    while(y)
    {
        if(y&1)
            r = (r * x) % MOD;
        y >>= 1;
        x = (x * x) % MOD;
    }
    return r;
}

int inv(int x)
{
	return pwr(x, MOD-2ll);
}

int n, m; 

void solve()
{
	string s, t; cin>>s>>t;
	int c = 0;
	for(int i=0;i<3;i++)
	{
		if(s[i]==t[i])
			c++;
	}
	cout<<c;
}

signed main()
{
    fast;
    int t=1;
    // cin >>t;
    while(t--){
        solve();
        
    }
    return 0;
}

/*****************************


****************************/


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

typedef long long ll;

int mcxi2int(string mcxi) {
    int ret = 0;
    int i = 0;
    while(i < mcxi.length()) {
        int c = 1;
        if('2' <= mcxi[i] && mcxi[i] <= '9') {
            c = mcxi[i]  - '0';
            i++;
        }
        switch(mcxi[i]) {
            case 'm':
            ret += c*1000;
            break;
            case 'c':
            ret += c*100;
            break;
            case 'x':
            ret += c*10;
            break;
            case 'i':
            ret += c;
            break;
        }
        i++;
    }
    return ret;
}

string int2mcxi(int n) {
    string ret;
    int d = 1000;
    while(n) {
        char x = d == 1000? 'm' : (d == 100? 'c' : (d == 10? 'x' : 'i'));
        int c = n / d;
        if(c == 0){

        } else if(c == 1) {
            ret.push_back(x);
        } else {
            ret.push_back(c + '0');
            ret.push_back(x);
        }
        n %= d;
        d /= 10;
    }
    return ret;
}

int main() {
    int n;
    cin >> n;
    for(int i = 0; i < n; i++) {
        string s1, s2; cin >> s1 >> s2;
        cout << int2mcxi(mcxi2int(s1) + mcxi2int(s2)) << endl;
    }
}



Measured memory_bytes: 3132
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,l,r) for(long long i=(l);i<(r);++i)
#define REP(i,n) FOR(i,0,n)
#define REPS(i,n) FOR(i,1,n+1)
#define RFOR(i,l,r) for(long long i=(l);i>=(r);--i)
#define RREP(i,n) RFOR(i,n-1,0)
#define RREPS(i,n) RFOR(i,n,1)
#define int long long
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define SZ(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
const int INF=1e18;
const int MOD=1e9+7;
int divup(int x,int y){
    if(x%y==0)return x/y;
    else return x/y+1;
}

signed main(){
    int h,w;cin>>h>>w;
    if(h%3==0||w%3==0){
        cout<<0<<endl;
        return 0;
    }
    int ans=INF;
    REPS(i,h-1){
        int a=w*i;
        int b=(h-i)*(w/2);
        int c=(h-i)*divup(w,2);
        chmin(ans,max({a,b,c})-min({a,b,c}));
    }
    REPS(j,w-1){
        int a=h*j;
        int b=(w-j)*(h/2);
        int c=(w-j)*divup(h,2);
        chmin(ans,max({a,b,c})-min({a,b,c}));
    }
    chmin(ans,h);
    chmin(ans,w);
    cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std ;
typedef int Read ; // Here to change the type of numbers
inline Read Readin() {
	Read K = 0 , F = 1 ; char C = ' ' ;
	while( C < '0' or C > '9' ) F = C == '-' ? -1 : 1 , C = getchar() ;
	while( C <= '9' and C >= '0' ) K = ( K << 1 ) + ( K << 3 ) + C - '0' , C = getchar() ;
	return F * K ;
}
inline Read Min( Read A , Read B ) { return A < B ? A : B ; }
inline Read Max( Read A , Read B ) { return A > B ? A : B ; }
inline Read Abs( Read A ) { return A < 0 ? -A : A ; }
inline bool Check( int Num ) {
	int A = 0 ;
	while( Num ) {
		A |= 1 << ( Num % 10 ) ;
		Num /= 10 ;
	}
	return A == ( ( 1 << 3 ) | ( 1 << 5 ) | ( 1 << 7 ) ) ;
}
inline bool Simcheck( int Num ) {
	while( Num ) {
		if( Num % 10 != 3 and Num % 10 != 5 and Num % 10 != 7 ) return false ;
		Num /= 10 ;
	}
	return true ;
}
int A[100005] , Top = 1 , Ans ;
int main() {
	int N = Readin() ;
	for(register int i = 1 ; i <= 100000 ; ++i )
		if( Simcheck( i ) ) A[++Top] = i ;
	for(register int i = 1 ; i <= Top and A[i] <= 10000 ; ++i )
		for(register int j = 1 ; j <= Top ; ++j )
			if(  A[j] * 10000 + A[i] <= N )
				if( Check( A[j] * 10000 + A[i] ) )
					++Ans ;
	printf( "%d\n" , Ans ) ;
	return 0 ;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define rep2(i,x,n) for(int i=x; i<(n); i++)
#define ALL(n) begin(n),end(n)
using namespace std;
using P = pair<int, int>;
using ll = long long;

int main()
{
    int l,r;
    cin >> l >> r;
    ll ans = 0;
    if(r - l + 1 >= 2019){
        cout << ans << endl;
    }
    else{
        ans = 2019;
        for(ll i=l; i<r; i++){
            for(ll j=i+1; j<=r; j++){
                ans=min(ans, ((i%2019)*(j%2019))%2019);
            }
        }
        cout << ans % 2019 << endl;
    }
    return 0;
}

Measured memory_bytes: 3604
#include <bits/stdc++.h>
using namespace std;
int a[10005];
int b[10005];
int dp[10005][10005];
int H,N;


int main(){
  cin >> H >> N;
  for (int n=0;n<N;n++){
    int i,j;
    cin >> a[n] >> b[n];
  }
  for (int i = 0;i<10005;i++){
    for(int j = 0;j<10005;j++){
      dp[i][j] = 10000000005;
    }
  }
  for (int i = 0;i<10001;i++){
    dp[i+1][0] = 0;
    for (int j = 1;j<10001;j++){
      if (j >= a[i]){
        dp[i+1][j] = min ({dp[i][j],dp[i+1][j-a[i]] + b[i]});
      }
      else{
        dp[i+1][j] = dp[i][j];
      }
    }
    
  }
  int ans=1000000005;
  for (int i=H;i<10001;i++){
    if(ans>dp[N][i]){
      ans = dp[N][i];
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 391296
#include<cstdio>

typedef long long ll;

int main() {
	ll a, b, c, ans;

	scanf("%lld%lld%lld", &a, &b, &c);

	if (b >= c) ans = b + c;
	if (b < c) {
		if (a + b >= c) ans = b + c;
		else ans = b + a + b + 1;
	}
	printf("%lld", ans);
}

Measured memory_bytes: 128
import sys
from collections import defaultdict
N, K = map(int, input().split())
a = list(map(int, input().split()))

seta = set(a)
cntK = len(seta)
cnta = [0] * cntK
if cntK <= K:
    print(0)
    sys.exit()

d = defaultdict(int)
for key in a:
    d[key] += 1

dtmp = sorted(d.items(), key=lambda x: x[1])
cnt = 0
for i in range(cntK - K):
    cnt += dtmp[i][1]
print(cnt)

Measured memory_bytes: 52152
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define repone(i,n) for(int i=1;i<(int)(n);++i)
#define repo(i,o,n) for(int i=o;i<(int)(n);++i)
#define Rep(j,n) for(int j=0;j<(int)(n);++j)
#define Repo(j,o,n) for(int j=o;j<(int)(n);++j)
#define Repone(j,n) for(int j=1;j<(int)(n);++j)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define int long long
#define pb(a) push_back(a)
#define eraser(v,i) (v).erase(v.begin()+(i))
#define pbpair(a,b) push_back(make_pair(a,b))
#define MOD 1000000007
#define INF 9223372036854775807
#define pairint pair<int,int>
signed main()
{
int x=0,y=0,z=0,w=0,n=0,m=0,a=0,b=0;
std::cin >> x>>y>>z>>w;
rep(i,x){
  std::cin >> n;
  if(i==0)a=n;
  else if(a<n)a=n;
}
rep(i,y){
  std::cin >> n;
  if(i==0)b=n;
  else if(b>n)b=n;
}
if(a<b&&b>z&&a<w)std::cout << "No War" << '\n';
else std::cout << "War" << '\n';
}


Measured memory_bytes: 256
using System;
using System.Text;
class Program
{
  static void Main(string[] args)
  {
    string input = Console.ReadLine();
    StringBuilder sb = new StringBuilder();
    for(var i = 0;i < input.Length; i++)
      if (i % 2 == 0) sb.Append(input[i]);
    Console.WriteLine(sb.ToString());
  }
}

Measured memory_bytes: 11616
import java.util.Scanner;

public class Main{
  public static void main(String[] args){
    Scanner scan = new Scanner(System.in);
    int a = scan.nextInt();
    int b = scan.nextInt();
    int c = scan.nextInt();
    int temp = 0;
    if(a > b){
      temp = a;
      a = b;
      b = temp;
    }
    if(b > c){
      temp = b;
      b = c;
      c = temp;
    }
    if(a > b){
      temp = a;
      a = b;
      b = temp;
    }
    System.out.println(a+" "+b+" "+c);
  }
}



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

int main(){
  int sx,sy,tx,ty;
  cin >> sx >> sy >> tx >> ty;
  int x = tx- sx, y = ty - sy;
  for(int i = 0; i < y; i++)cout<<'U';
  for(int i = 0; i < x; i++)cout<<'R';
  for(int i = 0; i < y; i++)cout<<'D';
  for(int i = 0; i < x; i++)cout<<'L';
  cout<<'L';
  for(int i = 0; i <= y; i++)cout<<'U';
  for(int i = 0; i <= x; i++)cout<<'R';
  cout<<'D';
  cout<<'R';
  for(int i = 0; i <= y; i++)cout<<'D';
  for(int i = 0; i <= x; i++)cout<<'L';
  cout<<'U';
  return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")

#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/rope>

using namespace std ;
using namespace  __gnu_pbds ;
using namespace __gnu_cxx ;

typedef long long ll ;
typedef long double ld ;

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

typedef vector<int> vi ;
typedef vector<ll> vll ;
typedef vector<pii> vpi ;
typedef vector<pll> vpl ;
typedef vector<vi> vvi ;

template <class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define rep(i,a,b) for (int i = (a); i <= (b); i++)
#define per(i,b,a) for (int i = (b); i >= (a); i--)

#define mp make_pair
#define eb emplace_back
#define pb push_back
#define fi first
#define se second

#define sz(x) (int)x.size()
#define all(x) begin(x), end(x)

const int MOD1 = 1000000007 ;
const int MOD2 = 998244353 ;
const ll INFL = 1e18 ;
const int INFI = 2e9 ;
const int MAXN = 205 ;
const int LOGN = 22 ;
const int MAXM = (1 << LOGN) ;
const int ALPHA = 30 ;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()) ;

ll modpow(ll a, ll b, int MOD) {
    ll res = 1 ;
    while(b) {
        if(b&1) {
            res = res*a ;
            res %= MOD ;
        }
        a *= a ;
        a %= MOD ;
        b >>= 1 ;
    }
    return res%MOD ;
}
void upmin(int &a, int b) {
    if(a < b) {
        a = b ;
    }
}
void relax(int &a, int b) {
    if(a > b) {
        a = b ;
    }
}
ll add(ll a, ll b, int MOD) {
    a += b ;
    if(a >= MOD) {
        a -= MOD ;
    }
    return  a ;
}
ll subtract(ll a, ll b, int MOD) {
    a -= b ;
    if(a < 0) {
        a += MOD ;
    }
    return a ;
}
ll multiply(ll a, ll b, int MOD) {
    a *= b ;
    a %= MOD ;
    return a ;
}
string s ;
int n;
ll k ;
int main() {
    ios::sync_with_stdio(false) ;
    cin.tie(NULL) ;
    cin >> s >> k ;
    bool good = true ;
    n = sz(s) ;
    rep(i,1,n-1) {
       if(s[i] != s[i-1]) {
           good = false ;
       }
    }
    if(good) {
        ll tot = k*n ;
        ll res = tot/2 ;
        cout << res << endl ;
        return 0 ;
    }
    int l = 1, r = n-1 ;
    int c = s[0] ;
    rep(i,1,n-1) {
       if(s[i] == c) l++ ;
       else break ;
    }
    per(i,n-1,0) {
       if(s[i] == c) r-- ;
       else break ;
    }
    int cnt = 1 ;
    ll res = 0 ;
    if(r == n-1) s.pb('0') ;
    else s[r+1] = '0' ;
    rep(i,l+1,r+1) {
       if(s[i] == s[i-1]) {
          cnt++ ;
       }
       else {
           int x = cnt/2 ;
           res += k*x ;
           cnt = 1 ;
       }
    }
    cnt = (l) + (n-r-1) ;
    cnt /= 2 ;
    res += (k-1)*cnt ;
    cnt = (n-r-1)/2 ;
    res += cnt ;
    cnt = l ;
    cnt /= 2 ;
    res += cnt ;
    cout << res << endl ;
    return 0 ;
}


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

if n <= 599:
    print(8)
elif n <= 799:
    print(7)
elif n <= 999:
    print(6)
elif n <= 1199:
    print(5)
elif n<= 1399:
    print(4)
elif n <= 1599:
    print(3)
elif n <= 1799:
    print(2)
else:
    print(1)

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

int main() {
  int a, b, c, d, e, f;
  cin >> a >> b >> c >> d >> e >> f;

  vector<int> w(5000, 0), s(5000, 0);

  w[0] = 1;
  for (int i = 0; i <= f; i += 100) {
    if (!w[i]) continue;
    w[i + a * 100] = w[i + b * 100] = 1;
  }

  s[0] = 1;
  for (int i = 0; i <= f; ++i) {
    if (!s[i]) continue;
    // cout << i << " ";
    s[i + c] = s[i + d] = 1;
  }
  // cout << endl;

  int u = a * 100, v = 0;
  for (int i = 100; i <= f; i += 100) {
    if (!w[i]) continue;
    int j = min(i / 100 * e, f - i);
    // cout<< i << " " << j << endl;
    while (!s[j]) j--;

    if ( (100 * j * (u + v)) > (100 * v * (i + j)) ) {
      u = i; v = j;
    }

    // cout << j << " " << u << " " << v << endl;
  }

  cout << u + v << " " << v << endl;
}


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

int main() {
    int N;
    cin>>N;
    long DP[3][N];
    int a, b, c;
    for(int i=0;i<N;++i){
        cin>>a>>b>>c;
        if(i==0){
            DP[0][0] = a;
            DP[1][0] = b;
            DP[2][0] = c;
        }
        else {
            DP[0][i] = max(DP[1][i-1] + a, DP[2][i-1] + a);
            DP[1][i] = max(DP[0][i-1] + b, DP[2][i-1] + b);
            DP[2][i] = max(DP[0][i-1] + c, DP[1][i-1] + c);
        }
    }
    /**
    for(int i=0;i<3;++i){
        for(int j=0;j<N;++j){
            cout<<DP[i][j]<<" ";
        }
        cout<<endl;
    }
    cout<<endl;
    **/
    cout<<max(DP[0][N-1], max(DP[1][N-1], DP[2][N-1]))<<endl;
}


Measured memory_bytes: 2560
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stdlib.h>
#include <math.h>
#include <numeric>
#include <functional>
#include <stack>
#include <map>

bool func(std::pair<std::pair<std::string, int>, int> a, std::pair<std::pair<std::string, int>, int> b) {
	if (a.first.first > b.first.first) {
		return false;
	}
	else if (a.first.first < b.first.first) {
		return true;
	}
	else if (a.first.second > b.first.second) {
		return true;
	}
	else {
		return false;
	}
}

int main (){
	int n;

	std::cin >> n;

	std::vector<std::pair<std::pair<std::string, int>, int> > v(n);

	for (size_t i = 0; i < n; i++)
	{
		std::string s;
		int a;
		std::cin >> s >> a;

		v[i] = { {s, a }, (int)i };
	}

	std::sort(v.begin(), v.end(), func);

	for (size_t i = 0; i < n; i++)
	{
		std::cout << v[i].second + 1 << std::endl;
	}

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define vsort(v) sort(v.begin(), v.end())
#define ll long long
#define rep(i, s, g) for (ll i = (s); i < (g); i++)
#define MOD 1000000007
using namespace std;
using Graph = vector<vector<ll>>;

ll N, X, Y, ans; 

ll dist(ll i, ll j)
{	
	return min(abs(j - i), abs(X - i) + 1 + abs(Y - j));
}

int main()
{
  cin >> N >> X >> Y;
  vector<ll> K(N, 0);
  for (ll i = 1; i < N; i++) {
  	for (ll j = i + 1; j <= N; j++) {
    	K[dist(i, j)]++;
    }
  }
  for (ll i = 1; i < N; i++) {
  	cout << K[i] << endl;
  }
}

Measured memory_bytes: 256
// D.

#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <queue>
#include <vector>

using namespace std;

typedef pair<int, int> II;

int main(int argc, char *argv[])
{
	int k;
	cin >> k;
	deque<II> q;
	q.push_back(II(1, 1));
	vector<int> vis(k + 1, 1 << 30);
	while (!q.empty()) {
		II top = q.front();
		q.pop_front();
		int x = top.first, y = top.second;
		if (y < vis[x]) {
			vis[x] = y;
			q.push_front(II((x * 10) % k, y));
			q.push_back(II((x + 1) % k, y + 1));
		}
	}
	cout << vis[0] << endl;
}


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

int main()
{
	string s;
	cin >> s;
	int count = 0;
	int ans = 0;
	for (int i = 0; i < s.size(); i++) {
		count = 0;
		for(int j=i; j<s.size(); j++){
			if (s.at(j) == 'A' || s.at(j) == 'C' || s.at(j) == 'T' || s.at(j) == 'G') {
				count += 1;
			}
			else {
				break;
			}
		}
		if (count > ans) {
			ans = count;
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#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 di2[] = {1, 1, -1, -1, 0, 1, 2, 2, 2, 2, 2, 1, 0, -1, -2, -2, -2, -2, -2, -1};
const int dj2[] = {1, -1, 1, -1, 2, 2, 2, 1, 0, -1, -2, -2, -2, -2, -2, -1, 0, 1, 2, 2};
const int INF = 1 << 28;
const ll INF64 = 1ll << 55;
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;
  }
};

ll modpow(ll a, ll n) {
  ll res = 1;
  while (n > 0) {
    if (n & 1) res = res * a % mod;
    a = a * a % mod;
    n >>= 1;
  }
  return res;
}

mint c(ll n, ll r) {
  mint res = 1;
  rep(i, r) res *= n-i;
  rep(i, r) res /= r-i;

  return res;
}

int main(){
  ll n, a, b;
  cin >> n >> a >> b;
  mint ans = modpow(2, n) - 1;

  ans -= c(n, a) + c(n, b);

  cout << ans.x << endl;
}


Measured memory_bytes: 3644
// include
// ------------------------------------------------
#include <bits/stdc++.h>
#include <vector>
#include <algorithm>
#include <math.h>

using namespace std;

// func
// ------------------------------------------------
int CalcSumOfDigit(int n);      // 各桁の和を計算する。
long long getDigit(long long n);      // 数字の桁数を取得する。
string upper(string str);       // 英字を大文字に変換する。
string lower(string str);       // 英字を小文字に変換する。

// define
// ------------------------------------------------
#define all(a)        (a).begin(),(a).end()
#define rall(a)       (a).rbegin(),(a).rend()
#define sz(a)         int((a).size())
#define rep(i,n)      for(int(i)=0;(i)<(n);(i)++)
#define repe(i,n)     for(int(i)=0;(i)<=(n);(i)++)
#define vsort(v)      sort((v).begin(),(v).end())
#define rvsort(v)     sort(rall((v)))
#define vi            vector<int>
#define GCD(a,b)      __gcd((a),(b))
#define LCM(a,b)      ((a)/GCD((a),(b))*(b))
#define kiriage(a,b)  ((a)+(b)-1)/(b)

const int INF = 1e9;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<ll> vll;

// code
// ------------------------------------------------
int main()
{

  ll n;
  cin >> n;

  vll a(n);
  rep(i,n) cin >> a[i];

  map<ll,ll> m;
  rep(i,n) m[a[i]]++;

  ll ans = 0;
  for(auto it:m)
  {
    ans += it.second * (it.second - 1) / 2;
  }

  rep(i,n)
  {
    ll buf = 0;
    buf = ans;
    buf -= m[a[i]] * (m[a[i]] - 1) / 2;
    buf += (m[a[i]] - 1) * (m[a[i]] - 2 ) / 2;
    cout << buf << endl;
  }

  return 0;
}
// funcの実体
// ------------------------------------------------
ll getDigit(ll n)
{
  int i = 1;
  while(1)
  {
    n = n / 10;
    if(n == 0)
      break;
    i++;
  }
  return i;
}
ll CalcSumOfDigit(ll n)
{
  ll s = 0;
  while(n)
  {
    s += n % 10;
    n = n / 10;
  }
  return s;
}

string upper(string str)
{
  for(auto itr = str.begin();itr != str.end() ; itr++)
  {
    if(97 <= *itr && *itr <= 122)
    {
      *itr = *itr - 32;
    }
  }
  return str;
}

string lower(string str)
{
  for(auto itr = str.begin();itr != str.end() ; itr++)
  {
    if(65 <= *itr && *itr <= 90)
    {
      *itr = *itr + 32;
    }
  }
  return str;
}


Measured memory_bytes: 12928
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#define rep(i, n) for(int i = 0; i < n; ++i)
using namespace std;

int factorial(int n){
    if(n == 0) return 1;
    else return n*factorial(n-1);
}

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

    int num = factorial(n - 1);

    vector<int> x(n), y(n);
    rep(i, n){
        cin >> x[i] >> y[i];
    }

    double sum = 0;
    for(int i = 0; i < n; i++){
        for(int j = i + 1; j < n; j++){
            double dis = sqrt((x[i] - x[j])*(x[i] - x[j]) + (y[i] - y[j])*(y[i] - y[j]));
            sum += 2*num*dis;
        }
    }

    double ans = sum / factorial(n);
    printf("%.10f\n", ans);

    
    return 0;
}

Measured memory_bytes: 384
import sys

# import bisect
# from collections import Counter, deque, defaultdict
# import copy
# from heapq import heappush, heappop, heapify
# from fractions import gcd
# import itertools
# from operator import attrgetter, itemgetter

# import math

# import numpy as np

readline = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)


def main():
    h, w = list(map(int, readline().split()))
    s = [input() for _ in range(h)]

    possible = False

    for row in range(h):
        for col in range(w):
            if s[row][col] == "#":
                possible = False
                for i in [-1, 1]:
                    nr = row + i
                    nc = col + i
                    if 0 <= nr < h and s[nr][col] == "#":
                        possible = True
                    if 0 <= nc < w and s[row][nc] == "#":
                        possible = True
                if not possible:
                    print('No')
                    sys.exit()

    print('Yes')


if __name__ == '__main__':
    main()


Measured memory_bytes: 39152
#include <bits/stdc++.h>
#define rep(i, a, b) for (int i = a; i < (b); i++)
#define rrep(i, a, b) for (int i = a; i >= (b); i--)
#define all(x) (x).begin(), (x).end()
using namespace std;
using ll = long long;
using P = pair<int, int>;
template <class T>
inline bool chmin(T& a, T b) {
   if (a > b) {
      a = b;
      return true;
   }
   return false;
}
template <class T>
inline bool chmax(T& a, T b) {
   if (a < b) {
      a = b;
      return true;
   }
   return false;
}
void hr() {
   cerr << "--------------" << endl;
}
const int INF = 1001001001;
const int MOD = 1000000007;
// const int MOD = 998244353;

vector<int> to[100005];
int dist[100005], ans[100005];

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

   int n, m;
   cin >> n >> m;
   rep(i, 0, 100005) { dist[i] = INF; }
   rep(i, 0, m) {
      int a, b;
      cin >> a >> b;
      a--, b--;
      to[a].push_back(b);
      to[b].push_back(a);
   }

   queue<int> que;
   que.push(0);
   dist[0] = 0;
   while (que.size()) {
      int v = que.front();
      que.pop();
      for (int u : to[v]) {
         if (dist[u] != INF) continue;
         // printf("v:%d u:%d\n", v + 1, u + 1);
         dist[u] = dist[v] + 1;
         ans[u] = v + 1;
         que.push(u);
      }
   }
   bool ok = true;
   rep(i, 0, n) if (dist[i] == INF) ok = false;
   if (!ok) {
      cout << "No" << endl;
   } else {
      cout << "Yes" << endl;
      rep(i, 1, n) cout << ans[i] << endl;
   }
   return 0;
}


Measured memory_bytes: 10928
S=str(input())
T=str(input())
n=len(S)
m=len(T)
ans=n

for i in range(n-m+1):
    count=0
    for j in range(m):
        if S[i+j] != T[j]:
            count += 1

    ans = min(ans,count)

print(ans)


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

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

  P = N % 500;
//Pは支払額を５００で割ったあまり。（必要一円玉の枚数）
  
  if(A<P){
    cout << "No" << endl;
  }
  else{
    cout << "Yes" << endl;
  }
}

Measured memory_bytes: 256
#include <cstdio>
#include <string>
#include <iostream>
#include <cmath>
#include <vector>
#include <stack>
#include <algorithm>
//#pragma warning(disable:4996)

using namespace std;
typedef long long LL;

int main(void) {

	int H, i;
	int W, j;
	int result = 0, flg = 0;

	vector <string> maps(50);

	cin >> H >> W;

	for (int i = 0; i < H; i++) {
		cin >> maps[i];
	}


	for (i = 0; i < H; i++) {
		for (j = 0; j < W; j++) {
			if (maps[i][j] == '#') {
				if ((j + 1) < W && maps[i][j + 1] == '#')		continue;
				if ((j - 1) >= 0 && maps[i][j - 1] == '#')		continue;
				if ((i + 1) < H && maps[i + 1][j] == '#')		continue;
				if ((i - 1) >= 0 && maps[i - 1][j] == '#')		continue;

				flg = 1;
				break;
			}
		}
	}

	if (flg == 1)
		cout << "No" << endl;
	else
		cout << "Yes" << endl;


	return 0;
}

Measured memory_bytes: 256