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

typedef long long ll;
 
using tpl = tuple<int, int, int>;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

void fastStream(){cin.tie(0);std::ios_base::sync_with_stdio(0);}

const int mod = 1000000000 + 7;

const int MAX_FACT = 2000000;
ll fact[MAX_FACT];

ll pow_mod(ll a,ll n){
  ll cur=1;
  ll mul=a;
  while(n){
    if(n%2)cur=(cur*mul)%mod;
    mul=(mul*mul)%mod;
    n/=2;
  }
  return cur;
}

ll div_mod(int a){
  return pow_mod(a,mod-2);
}

// factを前計算
void calcFact(){
  fact[0]=1;
  for(int i=1;i<MAX_FACT;i++)
    fact[i]=(fact[i-1]*i)%mod;
}

// aCbのmodを計算
// 計算量はO(log(fact[a])+log(fact[a-b]))程度
ll comb(ll a,ll b){
  if(a<0||b<0)return 0;
  else if(a<b)return 0;
  else if(b==0)return 1;
  ll res=fact[a];
  res=(res*div_mod(fact[b]))%mod;
  res=(res*div_mod(fact[a-b]))%mod;
  return res;
}


int H, W, N;
int R[3010], C[3010];
ll dp[3010][2];
ll cache[3010][3010];

ll rec(int pos, int pari){
    if(dp[pos][pari] >= 0) return dp[pos][pari];
    ll res = 0;
    if(pos == N - 1){
        res = (pari == 0);
    }
    else{
        for(int to = 0; to < N; to++){ 
            if(to == pos) continue;
            int x1 = C[pos];
            int y1 = R[pos];
            int x2 = C[to];
            int y2 = R[to];
            if(x1 <= x2 && y1 <= y2 && !(pos == N - 2 && to == N - 1)){
                int diffx = x2 - x1;
                int diffy = y2 - y1;
                if(cache[pos][to] == -1)
                    cache[pos][to] = comb(diffx + diffy, diffx);
                ll c = cache[pos][to];
                (res += (c * rec(to, pari ^ 1)) % mod);
            }
        }
        res %= mod;
    }
    return dp[pos][pari] = res;
}



int main(){

    cin >> H >> W >> N;
    for(int i = 0; i < N; i++){
        cin >> R[i] >> C[i];
        R[i]--; C[i]--;
    }
    calcFact();

    memset(dp, -1, sizeof(dp));
    memset(cache, -1, sizeof(cache));

    R[N] = 0, C[N] = 0;
    R[N + 1] = H - 1, C[N + 1] = W - 1;
    N += 2;

    ll sub = 0;
    sub = (rec(N - 2, 0) - rec(N - 2, 1) + mod) % mod;
    ll ans = (comb(H + W - 2, W - 1) - sub + mod) % mod;
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 86784
import sys
from itertools import permutations

input = sys.stdin.readline
def main():
    N = int(input())
    x, y = [], []
    
    for i in range(N):
        a, b = map(int, input().split())
        x.append(a)
        y.append(b)
        
    table = {}
    
    for i in range(N):
        for j in range(N):
            if i == j: continue
            
            table[(i, j)] = ((x[i]-x[j]) ** 2 + (y[i]-y[j]) ** 2) ** 0.5
            
    ans = 0
    
    for r in list(permutations([i for i in range(N)])):  
        for j in range(N-1):
            ans += table[(r[j], r[j+1])]
    
    cur = 1
    for i in range(1, N+1): cur *= i
        
    print(ans / cur)

if __name__ == '__main__':
    main()


Measured memory_bytes: 8100
import java.util.ArrayList;
import java.util.HashSet;
import java.util.Random;
import java.util.Scanner;

public class Main {
	static Scanner sc = new Scanner(System.in);
	static final int INF = 0xFFFFFFF;
	static long[][] hash = new long[32][32];
	static long finish;

	public static void main(String[] args) {
		Random rnd = new Random();
		for (int i = 0; i < 32; ++i) {
			for (int j = 0; j < 32; ++j) {
				hash[i][j] = rnd.nextLong();
			}
		}
		for (int i = 0; i < 4; ++i) {
			for (int j = 2; j <= 7; ++j) {
				finish ^= hash[i * 8 + j - 1][i * 8 + j];
			}
		}
		int T = sc.nextInt();
		for (int i = 0; i < T; ++i) {
			System.out.println(solve());
		}
	}

	static int solve() {
		ArrayList<Board> cur = new ArrayList<Board>();
		HashSet<Long> hashes = new HashSet<Long>(30000);
		cur.add(new Board());
		hashes.add(cur.get(0).h);
		int i = 0;
		for (; !cur.isEmpty(); ++i) {
			ArrayList<Board> next = new ArrayList<Board>(cur.size());
			for (Board b : cur) {
				if (b.h == finish) return i;
				for (int j = 1; j < 32; ++j) {
					if (b.f[j] == INF && (b.f[j - 1] & 7) != 7) {
						Board created = new Board(b, j);
						if (hashes.contains(created.h)) continue;
						hashes.add(created.h);
						next.add(created);
					}
				}
			}
			cur = next;
		}
		return -1;
	}

	static class Board {
		int[] f;
		long h;

		Board() {
			f = new int[32];
			for (int i = 0; i < 4; ++i) {
				for (int j = 1; j <= 7; ++j) {
					int v = sc.nextInt();
					int suit = v / 10 - 1;
					int num = v % 10;
					int card = suit * 8 + num;
					if (num == 1) {
						f[i * 8 + j] = INF;
						f[suit * 8] = card;
					} else {
						f[i * 8 + j] = card;
						h ^= hash[i * 8 + j][card];
					}
				}
			}
		}

		Board(Board orig, int pos) {
			this.f = orig.f.clone();
			this.h = orig.h;
			for (int i = 0; i < 32; ++i) {
				if (orig.f[i] == orig.f[pos - 1] + 1) {
					this.f[i] = INF;
					this.h ^= hash[i][orig.f[pos - 1] + 1];
					break;
				}
			}
			this.f[pos] = orig.f[pos - 1] + 1;
			this.h ^= hash[pos][orig.f[pos - 1] + 1];
		}
	}
}

Measured memory_bytes: 90580
bingo = [list(map(int,input().split())),list(map(int,input().split())),list(map(int,input().split()))]
N = int(input())
numbers = []
zeros = [[0,0,0],[0,0,0],[0,0,0]]
for i in range(N):
    numbers.append(int(input()))

for i in numbers:
    for y, row in enumerate(bingo):
        for x, elem in enumerate(row):
            if bingo[x][y] == i:
                zeros[x][y] = 1
ans = False
for i in range(3):
    if zeros[i][0] == 1 and zeros[i][1] == 1 and zeros[i][2] == 1:
        ans = True
    if zeros[0][i] == 1 and zeros[1][i] == 1 and zeros[2][i] == 1:
        ans = True
if zeros[0][0] == 1 and zeros[1][1] == 1 and zeros[2][2] == 1:
    ans = True
if zeros[0][2] == 1 and zeros[1][1] == 1 and zeros[2][0] == 1:
    ans = True
if ans:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 3064
s = input()
n = len(s)+1
A = [None]*n
flag = False
for i in range(n-1):
    if i==0 and s[i]=='<':
        A[0]=0
    elif 1<=i<=n-2 and s[i-1]=='>' and s[i]=='<':
        A[i]=0
    elif i==n-2 and s[i]=='>':
        A[n-1]=0
for i in range(n-1):
    if A[i]==0:
        flag = True
    if flag and s[i]=='<':
        A[i+1] = A[i]+1
    if flag and s[i]=='>':
        flag = False
for i in range(n-1):
    if A[-1-i]==0:
        flag = True
    if flag and s[-1-i]=='>':
        if A[-2-i] == None:
            A[-2-i] = A[-1-i]+1
        else:
            A[-2-i] = max(A[-2-i],A[-1-i]+1)
    if flag and s[-1-i]=='<':
        flag = False
print(sum(A))

Measured memory_bytes: 23348
require 'bigdecimal'
require 'bigdecimal/util'

n = gets.chomp.split("")
arr = gets.chomp.split(" ")

sum = 0
arr.each.with_index do |v, i|
  sum += 1.to_d / arr[i].to_d
end
sum = 1 / sum.to_d
puts sum.to_s('F')

Measured memory_bytes: 14452
import sys
h, w = map(int, sys.stdin.readline().split())
a = [input() for _ in range(h)]
ans_tmp = []
for i in range(h):
    if '#' in a[i]:
        ans_tmp.append(a[i])

not_hash_num = set()
cnt = 0
for i in range(w):
    for j in range(h):
        if a[j][i] == '#':
            break
        if j == h-1:
            cnt += 1
            not_hash_num.add(i)

# print(ans_tmp)
# print(not_hash_num)
ans = [ [] for _ in range(len(ans_tmp))]
# print(ans)

for i in range(w):
    if i in not_hash_num:
        continue
    for j in range(len(ans_tmp)):
        ans[j].append(ans_tmp[j][i])

for i in range(len(ans_tmp)):
    print(''.join(ans[i]))


Measured memory_bytes: 38768
N = int(input())
A,B=map(int, input().split())
hoge1=[]
hoge2=[]
hoge3=[]
hoge = [int(i) for i in input().split()]
for j in range(N):
    p=hoge[j]
    if(p<=A):
        hoge1.append(p)
    elif(B+1<=p):
        hoge3.append(p)
    else:
        hoge2.append(p)
print(min(len(hoge1),len(hoge2),len(hoge3)))

Measured memory_bytes: 3064
"""
無理な場合を考えてみよう
→全体の辺の本数が奇数なら絶対無理

それ以外は？
説1:辺が偶数なら絶対作れる説

辺を選択し、そのどちらか片方にのみ xor1する
→すべての辺の数字を0にできるか？？(初期値は0)
なんかできそう

辺の向きを変えることで1を伝播させることが出来る
→同じ点にぶつけられる！！
ので、偶数本なら絶対できる


どうやって構成する？
適当に置く→1の点を適当に2つ選び、パス上にある辺を全部反転させる
確かにできるけど…遅くね？

もっと簡単にできないか？
適当に木を取る→深い方から整合性を合わせていけば終わり(最終的には根に収束するので)
各点に関して動かすのは高々1辺だけだから、木を取った辺のみ考えて反転させる
(それ以外は適当に置いておく)

dfsで終わり→解けた！！！
"""
import sys
sys.setrecursionlimit(200000)
N,M = map(int,input().split())

lisN = [ [] for i in range(N) ]
xorlis = [0] * N
AB = []

if M % 2 == 1:
    print (-1)
    sys.exit()

for i in range(M):

    a,b = map(int,input().split())
    AB.append([a,b])
    a -= 1
    b -= 1

    lisN[a].append([b,i])
    lisN[b].append([a,i])
    xorlis[b] ^= 1

visited = [False] * N
def dfs(now):

    visited[now] = True

    for nex,eind in lisN[now]:
        if visited[nex]:
            continue
        cat = dfs(nex)
        if cat != 0:
            xorlis[nex] ^= 1
            xorlis[now] ^= 1
            t = AB[eind][1]
            AB[eind][1] = AB[eind][0]
            AB[eind][0] = t

    return xorlis[now]

dfs(0)
#print (xorlis)
if 1 in xorlis:
    print (-1)
    sys.exit()

else:
    for i,j in AB:
        print (j,i)

Measured memory_bytes: 223308
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, a, b) for(int i = a; i < b; i++)
#define  all(x) (x).begin(),(x).end()     // 昇順ソート
#define  rall(v) (v).rbegin(), (v).rend() // 降順ソート
#define  FastIO ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
typedef long long ll;
typedef long long int lli;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return true; } return false; }

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

int main(){
    int n;
    cin >> n;
    vector<int> a(n);
    map<int, int> mp;
    rep(i,n) cin >> a[i];
    rep(i,n){
        mp[a[i]]++;
        mp[a[i]+1]++;
        mp[a[i]-1]++;
    } 

    int ans = 0;
    for(auto m: mp){
        ans = max(ans, m.second);
    }
    cout << ans << endl;
}

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

int main() {
	string s;
	cin >> s;
	int ans = 0;
	for(int i = 0; i < s.size()-1; i++) {
		ans += (s[i]!=s[i+1])?1:0;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 512
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <deque>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <vector>
#define Rep(i, n) for(int i=0;i<n;++i)
#define rep(i, n) for(int i=1;i<=n;++i)
#define ll long long int
#define INF 1e9
#define LINF 1e18
#define MOD 1000000007
#define PI 3.14159265359
#define All(a) (a).begin(), (a).end()

using namespace std;
using P = pair<ll, ll>;
 
int dx[4] = {0, 1, 0, -1};
int dy[4] = {1, 0, -1, 0};

/**
 * Usage:
 * 
 * G[from].push_back(Edge(to, weight));
 * using Graph = vector<vector<Edge>>;
 * 
 */ 
struct Edge {
  int to;     
  ll weight; 
  Edge(int t, ll w) : to(t), weight(w) { }
};

template<typename T>
void printv(vector<T>& v) {
  if (v.size() == 0) {
    cout << "\n";
    return;
  }

  Rep(i, v.size()) {
    cout << v[i] << ((i + 1 < v.size()) ? ' ' : '\n');
  }
}



int N;

int main () {
  cin >> N;
  cout << N * N * N << "\n";
}

Measured memory_bytes: 256
-- うおおおおお競プロでHaskell勉強してやるううううううう

import Data.Char
import Data.List
import System.IO
import Control.Applicative
import Control.Monad
-- https://hoogle.haskell.org で関数検索

{- お客様の中でHaskellを書ける方はいらっしゃいますか？
    と、Haskellの例がなくて困っていたところを @tanakh さんに助けて頂きました。本当にありがとうございました。-}
main :: IO ()
main = do 
    [a,b] <- getDoubleList
    print $ ceiling $  a / b
  
  
  -- print
pr [] = putStrLn ""
pr (x:xs) = do
    putStr $ (show x) ++ " "
    pr xs

or2 c1 c2 x 
    | c1 x ==True    = True
    | c2 x ==True    = True
    | otherwise        = False

same3 [a,b,c]
    | a==b && b==c = True
    | otherwise         = False       
      
diff3 [a,b,c] 
    | a==b = False
    | b==c = False
    | c==a = False
    | otherwise = True

yesno cond
    | cond         = putStrLn "Yes"
    | otherwise = putStrLn "No"
    
    
    
{-

 「/」はdouble同士でしか使えない

main = readLn >>= print . ceiling . (/2) 


(+) 3 $ (*) 4 4
-> 19
pure (+) <*> (Just 1) <*> ( Just 3)
-> Just 4

main = do 
    [a,b] <- getIntegerList 
    print $ (a*(a-1)+b*(b-1)) `div` 2
    -- / じゃなくて'div' ！！！！！

main = do
    s <- getLine    
    samecoffee s

samecoffee [x,y,a,b,c,d] 
    | a==b && c==d = do putStrLn "Yes"
    | otherwise         = do putStrLn "No"
samecoffee s = do putStrLn ""
         
putStrLn $ (show c) ++ " " ++ (show a) ++ " " ++ (show b)


main :: IO ()
main = do
    -- 整数の入力
    a <- readLn
    -- スペース区切り整数の入力
    [b, c] <- getIntegerList

    --[b, c] <- map read . words <$> getLine
    -- 文字列の入力
    s <- getLine
    -- 出力
    putStrLn $ show (a + b + c) ++ " " ++ s
-}

-- レイアウト規則

fac 0 = 1
fac n = n * fac (n-1)

-- FileName   : 164a
-- CreatedDate: 2020-04-26 20:56:13

--------------------------------------------  https://atcoder.jp/contests/abc164/submissions/12342628

getIntList        = map (read :: String -> Int) . words <$> getLine
getIntegerList    = map (read :: String -> Integer) . words <$> getLine
getIntegerListN m = map (read :: String -> Integer) <$> replicateM m getLine

getStringList    = words <$> getLine
getDoubleList    = map (read :: String -> Double) . words <$> getLine

base :: Integer
base = 1000000007

plus :: Integer -> Integer -> Integer
plus a b = (a+b) `mod` base

times :: Integer -> Integer -> Integer
times a b = a * b `mod` base

minus :: Integer -> Integer -> Integer
minus a b
   | a < b     = a-b + base
   | otherwise = a-b

power :: Integer -> Integer -> Integer
power n k
   | k == 0         = 1
   | k `mod` 2 == 0 = power (times n n) (k`div`2)
   | otherwise      = times n $! power n (k-1)

inv :: Integer -> Integer
inv n = power n $ base - 2

binom :: Integer -> Integer -> Integer
binom n m
   | (n-m) < m = times (foldr times 1 [m+1..n]) $ inv $ foldr times 1 [1..n-m]
   | otherwise = times (foldr times 1 [n-m+1..n]) $ inv $ foldr times 1 [1..m]



















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

class A {
    static void Main(string[] args) {
        int H = int.Parse(Console.ReadLine());
        int W = int.Parse(Console.ReadLine());
        int N = int.Parse(Console.ReadLine());



        //var st = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();





        Console.WriteLine(Math.Ceiling((double)N / Math.Max(H, W)));



    }
}

Measured memory_bytes: 11220
#include <iostream>
#include <sstream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <utility>
#include <map>
#include <list>
#include <climits>
#include <set>
#include <deque>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <iomanip>
#include <bitset>

// #define cerr if(false)cerr
#define watch(x) cerr << "> " << #x << ": " << x << "\n";

using namespace std;

template <typename T>
std::ostream &operator <<(std::ostream &out, vector<T> &v) {
	for (typename vector<T>::size_type i = 0; i < v.size(); ++i)
		out << v[i] << " ";
	out << "\n";
    return out;
}
template <typename T, typename N>
std::ostream &operator <<(std::ostream &out, vector<pair<T, N> > &v) {
	for (size_t i = 0; i < v.size(); ++i)
		out << "(" << v[i].first << ", " << v[i].second << ") ";
	out << "\n";
    return out;
}
template <typename T>
std::ostream &operator <<(std::ostream &out, vector<vector<T> > &v) {
	for (size_t i = 0; i < v.size(); ++i) {
		for (size_t j = 0; j < v[i].size(); ++j) {
			out << v[i][j] << " ";
		}
		out << "\n";
	}
   	return out;
}

int n, k;

int get_distance(int i, int j, int dir, vector<int> &a) {
	int dist = 0;
	if (dir == 1) {
		if (a[j] > a[i]) {
			dist = a[j] - a[i];
		} else {
			dist = k - a[i] + a[j]; 
		}
	} else {
		if (a[j] < a[i]) {
			dist = a[i] - a[j];
		} else {
			dist = a[i] + k - a[j];
		}
	}

	return dist;
}

int main() {

	std::ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);

	cin >> k >> n;

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

	int min_distance = INT_MAX;
	int i = 0, j = n - 1;
	while (i < n) {
		min_distance = min(min_distance, min(get_distance(i, j, 1, a), 
											 get_distance(i , (i + 1) % n, -1, a)));
		++i;
		j = (j + 1) % n; 
	}

	cout << min_distance << "\n";

	return 0;

}

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

#define for_(i,a,b) for(int i=a;i<b;++i)
#define ALL(a) a.begin(),a.end()
using lint = long long int;

int main() {
    int N, M;
    cin >> N >> M;
    cout << (N * (N-1) + M * (M-1)) / 2 << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using intl = long long;
using itnl = long long;//typo用
using itn = int;//typo用
using ld = long double;
using namespace std;
#define rep(i, n) for(intl i = 0; i < (intl)(n); i++)
#define rrep(i, n) for(intl i = (intl)(n) - 1; i >= 0; i--)
#define repi(i, a, b) for(intl i = (intl)(a); i < (intl)(b); i++)
#define rrepi(i, a, b) for(intl i = (intl)(a) - 1; i >= (intl)(b); i--)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define m0(x) memset(x,0,sizeof(x))
#define m1(x) memset(x,1,sizeof(x))
#define fill(x,y) memset(x,y,sizeof(x))
#define alength(a) (sizeof(a) / sizeof(a[0]))
#define debug(x) cout << #x << ":" << x << endl
#define rdebug(i,x) rep(i, alength(x))cout << #x << "[" << i << "]:" << x[i] << endl//1次元配列の出力
#define rrdebug(i, j, x) rep(i, alength(x))rep(j, alength(x[i]))cout << #x << "[" << i << "][" << j << "]:" << x[i][j] << endl//二次元配列の出力
#define pb push_back
#define mp make_pair
#define pii pair<intl,intl>
const intl INF = 1e9;
const intl MOD = 1e9+7;
const ld EPS = 1.0e-14;//-9
const ld PI = acos(-1);
void fp(bool f){cout << (f ? "Yes" : "No") << endl;}
void fp(bool f, string s, string t){cout << (f ? s : t) << endl;}
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; }
intl gcd(intl a, intl b){ if(!b)return a; return gcd(b, a % b); }
intl lcm(intl a,intl b){ return a / gcd(a, b) * b; }
intl kai(intl k){//k!を求める関数,
    intl a = 1;
    for(int i = 2; i <= k; i++){
        a *= i;
    }
    return a;
}
intl digit10(intl a){//aを10進数で表したときの桁数を求める関数
    intl b = 0;
    do{
        a /= 10;
        b++;
    }while(a);
    return b;
}

signed main(){
    cout << fixed << setprecision(10);
    intl n;
    cin >> n;
    intl a[n];
    rep(i,n)cin >> a[i];
    intl sum = 1;
    intl l = 1000000000000000000LL;
    bool f = true;
    rep(i,n)if(!a[i])f = false;
    if(!f){
        cout << 0 << endl;
        return 0;
    }
    intl num = 1;
    rep(i,n){
        sum *= a[i];
        if(sum < num)f = false;
        if(sum > l)f = false;
        num = sum;
    }
    if(!f)sum = -1;
    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 4420
#include<stdio.h>
#include<string.h>
int main(){
int i;
int c=0;
char s[101];
while(scanf("%s",s)!=-1){
for(i=0;i<strlen(s)/2;i++)
if(s[i]!=s[strlen(s)-i-1])
break;
if(i==strlen(s)/2)
c++;
}
printf("%d\n",c);
return 0;
}

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

#define llint long long int

using namespace std;

int main(){
    int N;

    cin >> N;

    int count = 0;

    for(int i = 1; i <= N; i ++){
        int temp;

        cin >> temp;

        if(temp != i){
            count ++;
        }
    }
    if(count <= 2){
        cout << "YES" << endl;
    }else{
        cout << "NO" << endl;
    }
}

Measured memory_bytes: 256
program main
   implicit none
   integer::le,cou(2)=0
   integer i
   character(100000):: s
   read(*,*)s
   le=len_trim(s)
   do i=1,le
      if(s(i:i)=="0")cou(1)=cou(1)+1
      if(s(i:i)=="1")cou(2)=cou(2)+1
   enddo
   write(*,*)minval(cou)*2
end program main


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

int main() {
	int X, Y, Z;
	cin >> X >> Y >> Z;
	cout << Z << " " << X << " " << Y << endl;
	return 0;
}

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

#define pb(n) push_back(n)
#define fi first
#define se second
#define all(r) begin(r),end(r)
#define vmax(ary) *max_element(all(ary))
#define vmin(ary) *min_element(all(ary))
#define debug(x) cout<<#x<<": "<<x<<endl
#define fcout(n) cout<<fixed<<setprecision((n))
#define scout(n) cout<<setw(n)
#define vary(type,name,size,init) vector< type> name(size,init)
#define vvl(v,w,h,init) vector<vector<ll>> v(w,vector<ll>(h,init))
#define mp(a,b) make_pair(a,b)

#define rep(i,n) for(int i = 0; i < (int)(n);++i)
#define REP(i,a,b) for(int i = (a);i < (int)(b);++i)
#define repi(it,array) for(auto it = array.begin(),end = array.end(); it != end;++it)
#define repa(n,array) for(auto &n :(array))

using ll = long long;
using pii = pair<int,int> ;
using pll = pair<ll,ll> ;

template<typename T>
void O(T t){
  cout << t << endl;
}

const ll mod = 1e9+7;
constexpr ll inf = ((1<<30)-1)*2+1 ;
constexpr double PI = acos(-1.0) ;
double eps = 1e-10 ;
const int dy[] = {-1,0,1,0,1,-1,1,-1};
const int dx[] = {0,-1,0,1,1,-1,-1,1};

inline bool value(int x,int y,int w,int h){
  return (x >= 0 && x < w && y >= 0 && y < h);
}

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll n,m;
  while (cin >> n >> m && n && m) {
    vector<ll> v(n+1);
    rep(i,n){
      cin >> v[i];
    }
    v[n] = 0;
    sort(all(v));
    ll ans = 0;
    vector<ll> k(n + n * n);
    rep(i,n){
      rep(j,n+1){
        if(v[i] + v[j] > m) continue ;
        k[i + j * n] = v[i] + v[j];
        ans = max(ans,k[i+j*n]);
      }
    }
    sort(all(k));
    rep(i,n){
      rep(j,n+1){
        auto it = upper_bound(all(k),m - (v[i] + v[j]));
        if(it != k.begin())
          ans = max(ans,*(it-1) + v[i]+v[j]);
      }
    }
    cout << ans << endl;
  }
  return 0;
}

Measured memory_bytes: 11424
#include <iostream>
using namespace std;
int main(){
  int N; cin >> N;
  if(N < 4){
    cout << "No" << endl;
    return 0;
  }
  for(int i = 0; i <= N;i+=4){
    for(int j = 0; j <= N; j+=7){
      if(i + j == N){
        cout << "Yes" << endl;
        return 0;
      }
    }
  }
  cout << "No" << endl;
}

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

int main(void){
    int H, W;
    cin >> H >> W;
    vector<string> s(H);
    for (int i = 0; i < H; i++)
        cin >> s[i];
    
    int max_dis = 0;
    int hoko[4][2] = {{1, 0}, {0, 1}, {-1, 0}, {0, -1}}; 
    for (int i = 0; i < H; i++) {
        for (int j = 0; j < W; j++) {
            queue<pair<int, int>> que;
            if (s[i][j] == '.')
                que.push(make_pair(j, i));
            vector<vector<int>> field(H, vector<int>(W, -1));
            field[i][j] = 0;
            while(!que.empty()) {
                pair<int, int> xy = que.front();
                que.pop();
                for (int k = 0; k < 4; k++) {
                    int n_x = xy.first+hoko[k][0];
                    int n_y = xy.second+hoko[k][1];
                    if (n_x < W && n_x >= 0 && n_y < H && n_y >= 0) {
                        if (s[n_y][n_x] == '.') {
                            if (field[n_y][n_x] == -1) {
                                field[n_y][n_x] = field[xy.second][xy.first]+1;
                                que.push(make_pair(n_x, n_y));
                            }
                            else
                                if (field[n_y][n_x] > field[xy.second][xy.first]+1)
                                    que.push(make_pair(n_x, n_y));
                                field[n_y][n_x] = min(field[xy.second][xy.first]+1, field[n_y][n_x]);
                        }
                    }
                }
            }
            for (int k = 0; k < H; k++) {
                for (int l = 0; l < W; l++) {
                    max_dis = max(max_dis, field[k][l]);
                    //cout << field[k][l] << " ";
                }
                //cout << endl;
            }
        }
    }
    cout << max_dis << endl;
}


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

typedef pair<int, int> P;
typedef pair<P, int> PP;

int main() {
    int N, M;
    cin >> N >> M;
    vector<PP> city(M);
    for (int i = 0; i < M; i++) {
        int p, y;
        cin >> p >> y;
        city[i] = PP(P(p, y), i);
    }
    sort(city.begin(), city.end());

    vector<P> res(M);
    int i = 0, prev = 0, cnt = 0;
    while (i < M) {
        if (prev != city[i].first.first) {
            prev = city[i].first.first;
            cnt = 0;
        } else {
            cnt++;
        }

        res[city[i].second] = P(city[i].first.first, cnt + 1);
        i++;
    }

    for (int i = 0; i < M; i++) {
        printf("%.6d%.6d\n", res[i].first, res[i].second);
    }
    return 0;
}

Measured memory_bytes: 3456
#include <iostream>
using namespace std;
int main() {
  int H[100], W[100];
  int counter =100;
  for (int i=0; i <= 100; i++) {
    cin >> H[i] >> W[i];
    if (H[i] ==0 && W[i] == 0) {
      counter =i;
      break;
    }
  }
  for (int i=0;i <= counter-1; i++) {
    for(int j=1; j <= H[i]; j++) {
      for (int k=1; k <= W[i]; k++) {
	if (j%2 == 1) {
          if (k%2 == 1)
            cout << "#";
	  else
            cout << ".";
        }
        else {
          if (k%2 == 0)
            cout << "#";
          else
            cout << ".";
	}
      } 
      cout << endl;
    }
    cout << endl;
  }
  return 0;
}



Measured memory_bytes: 3056
#include <stdio.h>
#include <stdlib.h>
#define NIL NULL
#define MAX 500001
struct node{
  struct node *right;
  struct node *left;
  struct node *parent;
  int key;
};
typedef struct node * Node;

Node root;

Node treeMinimum(Node x){
while(x->left!=NIL){
  x=x->left;
}
return x;
}

Node treeMaximum(Node x){
while(x->right!=NIL){
  x=x->right;
}
return x;
}

Node treeSearch(Node x, int k){
while ( x!=NIL && k!=x->key){
  if(k<x->key) x=x->left;
  else x=x->right;
}
return x;
}

Node treeSuccessor(Node x){
Node y;
if(x->right !=NIL) return treeMinimum(x->right);

y=x->parent;
while ( y !=NIL && x == y->right) {
  x=y;
  y=y->parent;
}
return y;

}

void treeDelete(Node z){
  Node y; // node to be deleted
  Node x; // child of y
if(z->left == NIL || z->right ==NIL){
  y=z;
}
else y= treeSuccessor(z);

if(y->left != NIL) x=y->left;
else x=y->right;

if(x !=NIL) x->parent=y->parent;
if(y->parent==NIL) root=x;
else if(y==y->parent->left) y->parent->left=x;
else y->parent->right=x;

if(y!=z) z->key=y->key;
}

void insert(int k){
  Node y = NIL;
  Node x = root;
  Node z;

  z = malloc(sizeof(struct node));
  z->key = k;
  z->left = NIL;
  z->right = NIL;

while( x!=NIL){
  y=x;
  if(z->key<x->key) x=x->left;
  else x=x->right;
}
z->parent=y;
if(y==NIL)root=z;
else{
  if(z->key<y->key) y->left=z;
  else y->right=z;
}
}

void inorder(Node u){
if(u==NIL) return;
inorder(u->left);
printf(" %d",u->key);
inorder(u->right);
}
void preorder(Node u){
  if(u==NIL) return;
  printf(" %d",u->key);
  preorder(u->left);
  preorder(u->right);
}


int main(){
  int n, i, x;
  char com[20];
  scanf("%d", &n);

  for ( i = 0; i < n; i++ ){
    scanf("%s", com);
    if ( com[0] == 'f' ){
      scanf("%d", &x);
      Node t = treeSearch(root, x);
      if ( t != NIL ) printf("yes\n");
      else printf("no\n");
    } else if ( com[0] == 'i' ){
      scanf("%d", &x);
      insert(x);
    } else if ( com[0] == 'p' ){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    } else if ( com[0] == 'd' ){
      scanf("%d", &x);
      treeDelete(treeSearch(root, x));
    }
  }

  return 0;
}


Measured memory_bytes: 20484
#include<stdio.h>
#define N 2

int main(void){
  	void battle(int *, int *);
  	int T[N],A[N];
  
  	scanf("%d %d %d %d",&T[0], &T[1], &A[0], &A[1]);
  	//printf("%d %d %d %d\n",T[0], T[1], A[0], A[1]); //OK
  
  	battle(T,A);
  
  	return 0;
}

void battle(int *p1,int *p2){
  	
  	//int C = 0;printf("%d %d %d %d\n",*p1, *(p1 + 1), *p2,*(p2 + 1)); //OK
  	
	while(1){
    	*p2 -=  *(p1 + 1); //p1の攻撃
      	//printf("p2's rest is %d\n",*p2);
      
      	if(*p2 <= 0){
        	printf("Yes\n");
          	break;
        }//C++;
      	*p1 -=  *(p2 + 1); //p2の攻撃
      	//printf("p1's rest is %d\n",*p1);	
      
      	if(*p1 <= 0){
        	printf("No\n");
          	break;
        }//C++; OK
    }
  	//printf("C = %d\n",C); //OK
}

Measured memory_bytes: 1644
#include <iostream>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <algorithm>
#include <numeric>
#include <fstream>
#include <iomanip>

typedef long double ld;
typedef long long ll;
const ll INF = (ll)1e18 + 1;
const ll MOD = 1e9 + 7;

// Split
namespace util {

std::vector< std::string > split(std::string s, char delimiter)
{
  std::vector< std::string > vs;
  std::string sub;
  for (auto c : s) {
    if (c == delimiter) vs.push_back(sub), sub.clear();
    else sub += c;
  }
  vs.push_back(sub);
  return vs;
}

} // namespace util

// Minimum, Maximum
template<class T> T minimum(T head, T tail) { return std::min(head, tail); }
template<class H, class... T> H minimum(H head, T... tail) { return std::min(head, minimum(tail...)); }
template<class T> T maximum(T head, T tail) { return std::max(head, tail); }
template<class H, class... T> H maximum(H head, T... tail) { return std::max(head, maximum(tail...)); }

// Output
template<class T> std::ostream& operator << (std::ostream& os, std::vector< T > v)
{
  for (ll i = 0; i < (ll)v.size(); i++){ os << " [" << i << "]" << v[i]; if (i % 10 == 0) os << std::endl; }
  return os;
}

template<class T, class S> std::ostream& operator << (std::ostream& os, std::vector< std::pair<T, S> > vp)
{
  ll i = 0;
  for (auto p : vp){os << " [" << i++ << "]" << p.first << " " << p.second; if (i % 10 == 0) os << std::endl;}
  return os;
}

void print(){ std::cout << std::endl; }
template<typename H> void print(H head) { std::cout << head << std::endl; }
template<typename H, typename... T> void print(H head, T... tail){ std::cout << head << " ", print(tail...); }

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

  ll N;
  std::cin >> N;
  std::vector<ll> va(N, 0);
  for (ll i = 0; i < N; i++) {
    std::cin >> va[i];
    va[i]--;
  }

  std::map<ll, ll> ma;
  ll i = 0;
  ll cnt = 0LL;
  while (ma[i] < 1) {
    ma[i] = cnt;
    i = va[i];
    cnt++;
  }

  bool judge = ma[1] > 0;
  if (judge) print(ma[1]);
  else print(-1);

  return 0;
}


Measured memory_bytes: 7296
#include <iostream>
using namespace std;
int main(void){
  int n,s[10000],q,t,ans=0;
  cin>>n;
  for(int i=0;i<n;i++)
    cin>>s[i];
  cin>>q;
  for(int i=0;i<q;i++){
    cin>>t;
    for(int j=0;j<n;j++){
      if(t==s[j]){
    ans++;
    break;
      }
    }
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 3100
#include <bits/stdc++.h>
#define ll long long
#define MODV 1000000007
#define INFLL LLONG_MAX // 9223372036854775807
#define EPS 1e-9
#define rep(i, n) for(ll i=0, i##_len=(ll)(n); i<i##_len; i++)
#define repf(i, n) for(ll i=1, i##_len=(ll)(n+1); i<i##_len; i++)
#define all(v) v.begin(), v.end()
#define endl "\n"
#define vi vector<ll>
#define vvi vector<vector<ll>>
#define Yes() cout << "Yes" << endl
#define YES() cout << "YES" << endl
#define No() cout << "No" << endl
#define NO() cout << "NO" << endl
#define Init() std::ios::sync_with_stdio(false); std::cin.tie(0); std::cout<<fixed<<setprecision(15);
template<class T>bool chmax(T &a, const T &b){ if(a<b){ a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b){ if(b<a){ a=b; return 1; } return 0; }
using namespace std;

int main(){
    Init();
    string s; cin >> s;
    ll ans = 0;
    string pre = "";
    for(ll i=0; i<s.size(); i++){
        if(s.substr(i, 1) == pre){
            if(i != s.size()-1){
                ans++;
                pre = s.substr(i, 2);
                i++;
            }
        }
        else{
            ans++;
            pre = s.substr(i, 1);
        }
    }
    cout << ans << endl;
}

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

int main(){
  int N;
  cin >> N;
  vector<int> v(N);
  for (int i=0;i<N;i++){
    cin >> v.at(i);
  }
  bool flag=true;
  for (int i=0;i<N-1;i++){
    if (v.at(i)>v.at(i+1)){
      v.at(i+1)=v.at(i+1)+1;
      if (!( v.at(i) == v.at(i+1) ))
        flag=false;
    }
  }
  if (flag)     
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}


Measured memory_bytes: 640
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
#include <queue>
#include <string>
#define REP(i,a,b) for (int i = a; i < (b); i++)
#define sz(t) int(t.size())
#define INF 1000000000
const int DIV = 1000000000 + 7;
using namespace std;
typedef long long ll;

int solve(string x, string y) {
    int dp[1050][10050];
    x = ' ' + x;
    y = ' ' + y;
    int lx = x.size();
    int ly = y.size();
    REP(i, 0, lx) dp[0][i] = 0;
    REP(i, 0, ly) dp[i][0] = 0;
    int ans = 0;
    REP(i, 1, ly) {
        REP(j ,1, lx) {
            if (y[i] == x[j]) {
                dp[i][j] = dp[i - 1][j - 1] + 1;
            } else {
                dp[i][j] = max(dp[i][j - 1], dp[i - 1][j]);
            }  
            ans = max(ans, dp[i][j]);
        }
    }

    return ans;
}

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

    REP(i, 0, n) {
        string x, y;
        cin >> x;
        cin >> y;
        cout << solve(x, y) << endl;
    }
}



Measured memory_bytes: 11072
#include <bits/stdc++.h>
#define maxn 100005
#define fto(i,j,h)   for (int i=j; i<=h; ++i)
#define fdto(i,j,h) for (int i=j; i>=h;  --i)
#define ll long long
#define pii pair<int, int>
#define fi first
#define se second
using namespace std;

int n, m, a[maxn];
int F[maxn][3];
int main()
{
    ios_base::sync_with_stdio(0);
    cin >> n >> m;
    fto(i,1,n)    cin >> a[i];
    sort(a+1, a+n+1);
    fto(i,1,m)    F[i][0] = F[i][1] = -1e9;
    fto(i,0,a[1]-1)    F[i][0] = F[i][1] = 0;
    fto(i,a[1],m){
       fto(j,1,n){
          if (a[j] > i)    break;
          F[i][0] = max(F[i][0], 1 - F[i-a[j]][1]);
          F[i][1] = max(F[i][1], 1 - F[i-a[j]][0]);
       }
    }
    if (F[m][0] > 0)    cout << "First";
    else cout << "Second";
}


Measured memory_bytes: 4796
a, b = map(int, input().split())
s = input()
ans = 'Yes'
for i in range(len(s)):
    if i > a + b:
        ans = 'No'
        break
    if i == a:
        if s[i] != '-':
            ans = 'No'
            break
    elif not s[i].isdigit(): 
        ans = 'No'
        break
print(ans)

Measured memory_bytes: 9144
#include <iostream>
#include <unordered_map>
#include <vector>
#include <algorithm>
#include <stdio.h>
#include <stdlib.h>
#include <cstring>

using namespace std;

int main(){
    int A, B, C;
    cin>>A>>B>>C;
    cout<<C-min(C,(A-B))<<endl;

    return 0;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define lower(s) transform(s.begin(), s.end(), s.begin(), ::tolower)
using namespace std;
using ll = long long;
int INF = 1001001001;

int main()
{
  int a;
  cin >> a;
  string s;
  cin >> s;
  if(a >= 3200) cout << s << endl;
  else cout << "red" << endl;
  return 0;
}

Measured memory_bytes: 3604
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define snuke srand((unsigned)clock()+(unsigned)time(NULL));
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
inline int in() { int x; scanf("%d",&x); return x;}
template<typename T>inline istream& operator>>(istream&i,v(T)&v)
{rep(j,sz(v))i>>v[j];return i;}
template<typename T>string join(const v(T)&v)
{stringstream s;rep(i,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template<typename T>inline ostream& operator<<(ostream&o,const v(T)&v)
{if(sz(v))o<<join(v);return o;}
template<typename T1,typename T2>inline istream& operator>>(istream&i,pair<T1,T2>&v)
{return i>>v.fi>>v.se;}
template<typename T1,typename T2>inline ostream& operator<<(ostream&o,const pair<T1,T2>&v)
{return o<<v.fi<<","<<v.se;}
template<typename T>inline ll suma(const v(T)& a) { ll res(0); for (auto&& x : a) res += x; return res;}
const double eps = 1e-10;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
#define dame { puts("-1"); return 0;}
#define yn {puts("YES");}else{puts("NO");}
const int MX = 20005;
typedef pair<int,P> Q;
typedef vector<Q> vq;

ll dp[MX];

int main() {
  int n;
  scanf("%d",&n);
  vq a(n);
  cin>>a;
  rep(i,n) {
    swap(a[i].fi, a[i].se.fi);
    a[i].fi += a[i].se.fi;
  }
  sort(rng(a));
  rep(i,n) {
    int s = a[i].fi, w = a[i].se.fi, x = a[i].se.se;
    drep(j,s+1) {
      if (j >= w) maxs(dp[j], dp[j-w]+x);
    }
    // rep(j,MX-1) maxs(dp[j+1], dp[j]);
  }
  ll ans = *max_element(dp, dp+MX);
  cout<<ans<<endl;
  return 0;
}






















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

int main() {
    string s;
    cin>>s;
    int n=s.length();
    if(s[n-1]=='s')
    s=s+'e'+'s';
    else
    s=s+'s';
    cout<<s<<endl;
	return 0;
}


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

// macros
#define int long long 
#define TIME clock() * 1.0 / CLOCKS_PER_SEC
#define all(c) c.begin(), c.end()
#define PB push_back
#define MP make_pair
#define bitcount __builtin_popcount
#define watch(x) cerr<< (#x) << " is " << (x) <<"\n";
#define sz(x) ((int)((x).size()))
#define UNIQUE(c) (c).resize(unique(all(c)) - (c).begin())
#define pii2ll(p) ((ll)(p).first<<32 | (p).second)

// type definitions
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector< vi > vvi;
typedef pair<int, int> pii;
typedef vector<pii> vpii;
typedef long double ld;

// template functions
template < typename A, typename B >
ostream& operator << ( ostream& os, const pair< A, B > & p ) {
    return os << "(" << p.first << ", " << p.second << ")";
}
template < typename T >
ostream &operator << ( ostream & os, const vector< T > &v ) {
    os << "[";
    typename vector< T > :: const_iterator it;
    for( it = v.begin(); it != v.end(); it++ ) {
        if( it != v.begin() ) os << ", ";
        os << *it;
    }
    return os << "]";
}
template < typename T >
ostream &operator << ( ostream & os, const set< T > &v ) {
    os << "{";
    typename set< T > :: const_iterator it;
    for ( it = v.begin(); it != v.end(); it++ ) {
        if( it != v.begin() ) os << ", ";
        os << *it;
    }
    return os << "}";
}
template < typename A, typename B >
ostream &operator << ( ostream & os, const map< A, B > &v ) {
    os << "[";
    typename map< A, B >::const_iterator it;
    for( it = v.begin(); it != v.end(); it++ ) {
        if( it != v.begin() ) os << ", ";
        os << it -> first << " -> " << it -> second ;
    }
    return os << "]";
}
template <typename T>
inline void printV(vector<T>& a, int n) { for(int i=0; i<n; i++) { cerr<<a[i]<<" "; } cerr<<"\n"; }
template <typename T>
inline void printVV(vector<vector<T>>& a) { for(int i=0; i<sz(a); i++) { cerr<<a[i]<<"\n"; } cerr<<"\n"; }
template <typename T>
inline void clearVV(vector<vector<T>>& a) { for(auto &x : a) { x.clear(); } a.clear(); }
template <typename T>
inline void assignVV(vector<vector<T>> &a, T val) { for(int i=0; i<sz(a); i++) { a[i].assign(sz(a[i]), val); } }
template<typename T>
T gcd(T a, T b) { if(a==0 or b==0) return a+b; return gcd(b, a%b) ; }

// random number generation
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

// constants
const long double eps = LDBL_EPSILON;
const int inf = 5e8;
const int modn = 1e9+7;
const int MAX = 1e5;


int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    // Your code here
	int n, l;
	cin>>n>>l;
	int totalsum = (l-1)*n + n*(n+1)/2;
	int dif = inf;
	int ans = 0;
	for(int i=1; i<=n; i++) {
		int curval = abs(l-1+i);
		if(curval < dif) {
			dif = curval;
			ans = totalsum - (l-1+i);
		}
	}
	cout<<ans<<"\n";
    return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long n;
    cin >> n;
    vector<long long> S(n);
    for(int i=0; i<n; i++){
        cin >> S[i];
    }
    sort(S.begin(),S.end());
    long long q;
    cin >> q;
    vector<long long> T(q);
    long long count=0;
    for(int i=0; i<q; i++){
        cin >> T[i];
        if(binary_search(S.begin(),S.end(),T[i])){
            count++;
        }
    }
    cout << count << endl;
}


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

int main()
{
	ll N;
	cin >> N;
	int res = 1000;
	for (ll i = 1; i * i <= N; i++) {
		if (N % i == 0) {
			ll v = N / i;
			int cnt = 0;
			while (v) {
				v /= 10;
				cnt++;
			}
			res = min(res, cnt);
		}
	}
	cout << res << endl;
	return 0;
}


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

int main(){
    ll N;
    cin >> N;
    vector<ll> pre;
    ll mx = 55555;
    vector<bool> v(mx+1, false);
    rep(i, 2, mx+1){
        if(v[i]) continue;
        if(i % 5 == 2) pre.push_back(i);
        for(ll j = i; j <= mx; j += i) v[j] = true;
    }
    cerr << pre.size() << endl;
    rep(i, 0, N) cout << pre[i] << " ";
    cout << endl;
    return 0;
}

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

int main() {
  int A, B, C, D;
  cin >> A >> B >> C >> D;
  if (A + B == C + D) {
    cout << "Balanced" << endl;
  }
  else if (A + B > C + D) {
    cout << "Left" << endl;
  }
  else {
   cout << "Right" << endl; 
  }
}

Measured memory_bytes: 3604
#include <iostream>
#include <vector>
#include <string>
#include <numeric>
#include <cmath>

using namespace std;

const int INF = 1e6;

int main(){
    long long x; cin >> x;
    long long ans = (x/11)*2;
    int r=x%11;
    ans += r>0 ? (r>6 ? 2 : 1) : 0;

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string b;
  cin >> b;
  if (b == "A") {
  cout << 'T' << endl;
  }
  if (b == "T") {
  cout << 'A' << endl;
  }
  if (b == "C") {
  cout << 'G' << endl;
  }
  if (b == "G") {
  cout << 'C' << endl;
  }
}

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

using namespace std;

/*
int chmax(int a, int b){
    if(a<b)a=b;
}

void chmin(int a, int b){
    if(a>b)a=b;
}
*/

int main(int argc, char** argv) {
    int n;
    cin >> n;
    int hight[n];
    int cost[n];
    
    for(int i=0; i<n; i++){
        int k;
        cin >> k;
        hight[i]=k;
    }
    int a;
    int b;
    cost[0]=0;
    cost[1]=abs(hight[1]-hight[0]);
    
    for(int i=2; i<n; i++){
        a=abs(hight[i]-hight[i-1]);
        b=abs(hight[i]-hight[i-2]);
        cost[i]=min(cost[i-1]+a, cost[i-2]+b);
    }
    
    cout << cost[n-1] << endl;

    return 0;
}

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

int main(void) {
    int64_t N;
    string S;
    cin >> N >> S;

    for(int i=0;i<S.size();i++) {
        cout << (char)('A' + ((S[i] - 'A' + N) % 26));
    }
    cout << "\n";
    return 0;
}


Measured memory_bytes: 256
n, q = map(int, input().split())
s = str(input())
ac = [0] * n
for i in range(1, n):
    ac[i] = ac[i-1]
    if(s[i-1] == "A" and s[i] == "C"):
        ac[i] += 1
for i in range(q):
    l, r = map(int, input().split())
    print(ac[r-1] - ac[l-1])

Measured memory_bytes: 6060
import java.util.Scanner;

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int[] x = new int[3];
        x[0] = sc.nextInt();
        x[1] = sc.nextInt();
        x[2] = sc.nextInt();

        int sub1 = 0, sub2 =0;
        for(int i = 0; i < 3; i++){
            for(int ii = i+1; ii < 3; ii++ ){
                if(x[i] > x[ii]){
                    sub1 = x[i];
                    sub2 = x[ii];
                    x[i] = sub2;
                    x[ii] = sub1;
                }
            }
        }

        System.out.println(x[0] + " " + x[1] + " " + x[2]);

        sc.close();
    }
}


Measured memory_bytes: 26172
#include <stdio.h>

int main(void)
{
	int n;
	int men[2];
	int king[2];
	int i;
	
	scanf("%d", &n);
	
	for (i = 0; i < n; i++){
		scanf("%d %d", &men[0], &men[1]);
		if (i == 0){
			king[0] = men[0];
			king[1] = men[1];
		}
		else if (king[1] < men[1]){
			king[0] = men[0];
			king[1] = men[1];
		}
		else if (king[1] == men[1] && king[0] > men[0]){
			king[0] = men[0];
			king[1] = men[1];
		}
	}
	
	printf("%d %d\n", king[0], king[1]);
	
	return (0);
}

Measured memory_bytes: 600
#include <bits/stdc++.h>
using namespace std;
int main(){
    int n,l;
    cin >> n >>l;
    vector<int>a(n);
    int sum=0;
    int min_a=100000;
    int min_b=0;

    for(int i=0; i<n; i++){
        a[i]=l+(i+1)-1;
        sum+=a[i];
    }

    for (int i=0;i<n;i++) {
        if(abs(a[i])<min_a){
            min_b=a[i];
            min_a=abs(a[i]);
        }
    }

    cout <<sum-min_b <<endl;
}


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

int ans=0;
vector<int> result;
vector<int> amida(const vector<int>& vec) {
    vector<int> ret;
    rep(i,N) ret.push_back(i+1);
    rep(i,vec.size()) {
        swap(ret[vec[i]-1],ret[vec[i]]);
    }

    return ret;
}

bool check(const vector<int>& vec1,const vector<int>& vec2) {
    if(vec1.size()!=vec2.size()) return false;
    rep(i,vec1.size()) if(vec1[i]!=vec2[i]) return false;
    return true;
}
int cnt(const vector<int>& vec) {
    int ret=1;
    int prev=0;
    rep(i,vec.size()) {
        if(!i) continue;
        for(int j=prev;j<i;j++) {
            if(abs(vec[i]-vec[j])<=1){
                ret++;
                prev=i;
                break;
            }
        }
    }
                    
    return ret;

}

int main() {
    cin>>N>>M;
    vector<int> yoko;
    yoko.resize(M);
    rep(i,M) {
        int a; cin>>a;
        yoko[i]=a;
    }
    result = amida(yoko);
    sort(yoko.begin(), yoko.end());
    ans=M;

    do {
        vector<int> t = amida(yoko);

        //cout<<t.size()<<" : "<<endl;
        //rep(i,t.size()) cout<<t[i]<<" ";
        //cout<<endl;

        if(check(result,t)) {
            /*
            cout<<"find : ";
            rep(i,yoko.size()) cout<<yoko[i]<<" ";
            cout<<endl;
            cout<<cnt(yoko)<<endl;
            */
            ans=min(ans,cnt(yoko));
        }

    } while(next_permutation(yoko.begin(), yoko.end()));
    cout<<ans<<endl;


    return 0;
}

Measured memory_bytes: 1216
import numpy as np
import sys
read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines

N = int(input())
X, Y = [], []
for _ in range(N):
    tx, ty = map(int, input().split())
    X.append(tx)
    Y.append(ty)
X = np.array(X)
Y = np.array(Y)

def dist(cx, cy):
    tmp = ((X - cx) ** 2 + (Y - cy) ** 2) ** .5
    return max(tmp)

def g(cx):
    ll, rr = 0, 1000

    for _ in range(80):
        cll = (ll * 2 + rr) / 3
        crr = (ll + rr * 2) / 3
        if dist(cx, cll) >= dist(cx, crr):
            ll = cll
        else:
            rr = crr
    return dist(cx, ll)

l, r = 0, 1000

for _ in range(80):
    cl = (l * 2 + r) / 3
    cr = (l + r * 2) / 3
    if g(cl) >= g(cr):
        l = cl
    else:
        r = cr

ans = g(l)

print(ans)



Measured memory_bytes: 12504