akhauriyash/Code-Regression huggingface dataset:
import java.io.BufferedInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.Arrays;

public class Main {

	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();

		long count = 0;
		while (N > 0) {
			if (N % 10 == 2) {
				count++;
			}
			N /= 10;
		}

		System.out.println(count);
	}

	public static boolean valid(long x, int limit) {
		if (x > limit) {
			return false;
		}

		boolean three = false;
		boolean five = false;
		boolean seven = false;
		long temp = x;
		do {
			switch ((int) (temp % 10)) {
			case 3:
				three = true;
				break;
			case 5:
				five = true;
				break;
			case 7:
				seven = true;
				break;
			default:
				return false;
			}
			temp /= 10;
		} while (temp > 0);

		return three && five && seven;
	}

	private static boolean isDebug = System.getProperty("sun.desktop") != null;

	private static void debug(Object... o) {
		if (isDebug) {
			System.err.println(Arrays.deepToString(o));
		}
	}

	public static class Scanner {
		private BufferedInputStream inputStream;
		private StringBuilder buffer = new StringBuilder();

		public Scanner(InputStream in) {
			inputStream = new BufferedInputStream(in);
		}

		public int nextInt() throws IOException {
			int num = 0;
			int sign = 1;

			int read = skip();
			if (read == '-') {
				sign = -1;
				read = inputStream.read();
			}

			do {
				num = num * 10 + sign * (read - 0x30);
			} while ((read = inputStream.read()) > 0x20);

			return num;
		}

		public void fill(int[] a) throws IOException {
			for (int i = 0; i < a.length; i++) {
				a[i] = nextInt();
			}
		}

		public void fill(int[] a, int[] b) throws IOException {
			if (a.length != b.length) {
				throw new IllegalArgumentException();
			}

			for (int i = 0; i < a.length; i++) {
				a[i] = nextInt();
				b[i] = nextInt();
			}
		}

		public long nextLong() throws IOException {
			long num = 0;
			int sign = 1;

			int read = skip();
			if (read == '-') {
				sign = -1;
				read = inputStream.read();
			}

			do {
				num = num * 10 + sign * (read - 0x30);
			} while ((read = inputStream.read()) > 0x20);

			return num;
		}

		public void fill(long[] a) throws IOException {
			for (int i = 0; i < a.length; i++) {
				a[i] = nextLong();
			}
		}

		public void fill(long[] a, long[] b) throws IOException {
			if (a.length != b.length) {
				throw new IllegalArgumentException();
			}

			for (int i = 0; i < a.length; i++) {
				a[i] = nextLong();
				b[i] = nextLong();
			}
		}

		public long[] nextLong(int n) throws IOException {
			long[] array = new long[n];
			for (int i = 0; i < n; i++) {
				array[i] = nextLong();
			}

			return array;
		}

		public String next() throws IOException {
			int read = skip();
			do {
				buffer.append((char) read);
			} while ((read = inputStream.read()) > 0x20);

			String text = buffer.toString();
			buffer.delete(0, buffer.length());

			return text;
		}

		private int skip() throws IOException {
			int read;
			while ((read = inputStream.read()) <= 0x20)
				;

			return read;
		}
	}
}


Measured memory_bytes: 24660
#include<bits/stdc++.h>
using namespace std;
 
using ll = long long;
using ld=long double;
 
int main(){
    int n;
    cin>>n;
    int a[n];
    ll sum=0;
    for(int i=0;i<n;i++)
    cin>>a[i];
    for(int i=0;i<n;i++)
        for(int j=i+1;j<n;j++){
            sum+=a[i]*a[j];
        }
    cout<<sum;
    
    return 0;
}

Measured memory_bytes: 256
A,B,C = map(int,input().split())

two = [0,0,0]
mod = [0,0,0]
for i,a in enumerate([A,B,C]):
    while True:
        if a % 2 == 0:
            two[i] += 1
            a /= 2
        else:
            mod[i] = a
            break
flag = True
ans = 0
if two[0] == two[1] and two[1] == two[2] and two[0] != 0:
    if mod[0] == mod[1] == mod[2] :
        flag = False
    else:
        mod.sort()
        moddif = [int(mod[1]+mod[0]),int(mod[2]+mod[1]),int(mod[0]+mod[2])]
        two2 = [0,0,0]    
        for i,a in enumerate(moddif):
            while True:
                if a % 2 == 0:
                    two2[i] += 1
                    a /= 2
                else:
                    break
        ans = two[0] + min(two2) 
else:
    ans = min(two)

if flag:
    print(ans)
else:
    print(-1)    


Measured memory_bytes: 3064
#include "bits/stdc++.h"
using namespace std;
using Graph = vector<vector<int>>;
typedef long long ll;
typedef pair<ll, ll> P;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
const long long mod = 1e9 + 7;

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

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

ll powMod(ll n, ll k, ll m) {
	if (k == 0) {
		return 1;
	} else if (k % 2 == 1) {
		return powMod(n, k - 1, m) * n % m;
	} else {
		ll t = powMod(n, k / 2, m);
		return t * t % m;
	}
}

int main() {
	ll n, m;
	cin >> n >> m;

	ll sum=0;

	rep(i, m) {
		ll a;
		cin >> a;
		sum+=a;
	}
	
	ll ans=n-sum;

	if (ans < 0) {
		cout << -1 << endl;
		return 0;
	}

	cout << ans << endl;
}


Measured memory_bytes: 3596
#include<bits/stdc++.h>
#define rep(i,N) for(int i=0;i<(N);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
using namespace std;
const long long MOD = 1e9 + 7;
const long long INF = 1e12;
const int inf = 1e9;
typedef long long ll;
typedef pair<ll,int> P;

int main(){
    string s;
    cin>>s;
    int min=999;
    for(int i=0;i<s.size()-2;i++){
        int n=(s[i]-'0')*100+(s[i+1]-'0')*10+(s[i+2]-'0');
        //cout<<s[i]-0<<endl;
        //c//out<<n<<endl;

        if(min>abs(n-753)) min=abs(n-753);
    }
    cout<<min<<endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const ll INF = 100000000;
#define rep1(i, n) for (ll i=0; i<(n); i++) 
#define rep2(i, k, n) for (ll i=k; i<(n); 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; }


int main() {
    ll n, cnt, sum=0;
    cin >> n;
    vector<ll> a(n);
    map<ll, ll> ball;
    rep1(i, n){
        cin >> a[i];
        ball[a[i]]++;
    }
    for (auto& i : ball){
        cnt = i.second;
        sum += cnt * (cnt-1) / 2;
    }
    ll ans = 0; 
    rep1(i, n){
        cnt = ball[a[i]];
        ans = sum - (cnt - 1);
        cout << ans << endl;
    }
}

Measured memory_bytes: 12700
import java.util.*;
import java.util.function.*;
import java.util.stream.*;

public class Main{
	Scanner s=new Scanner(System.in);

	void solve(){
		int h=s.nextInt(),n=s.nextInt();
		int a=INTS(n).sum();
		System.out.println(h<=a?"Yes":"No");
	}

	public static void main(String[] A){
		new Main().solve();
	}

	int gInt(){
		return Integer.parseInt(s.next());
	}
	long gLong(){
		return Long.parseLong(s.next());
	}
	double gDouble(){
		return Double.parseDouble(s.next());
	}

	SupplyingIterator<Integer> ints(int n){
		return new SupplyingIterator<>(n,this::gInt);
	}
	SupplyingIterator<Long> longs(int n){
		return new SupplyingIterator<>(n,this::gLong);
	}
	SupplyingIterator<Double> doubles(int n){
		return new SupplyingIterator<>(n,this::gDouble);
	}
	SupplyingIterator<String> strs(int n){
		return new SupplyingIterator<>(n,s::next);
	}

	Range rep(int i){
		return Range.rep(i);
	}
	Range rep(int f,int t,int d){
		return Range.rep(f,t,d);
	}
	Range rep(int f,int t){
		return rep(f,t,1);
	}
	Range rrep(int f,int t){
		return rep(t,f,-1);
	}

	IntStream REP(int v){
		return IntStream.range(0,v);
	}
	IntStream REP(int l,int r){
		return IntStream.rangeClosed(l,r);
	}

	IntStream INTS(int n){
		return IntStream.generate(this::gInt).limit(n);
	}
	LongStream LONGS(int n){
		return LongStream.generate(this::gLong).limit(n);
	}
	Stream<String> STRS(int n){
		return Stream.generate(s::next).limit(n);
	}

}

class SupplyingIterator<T> implements Iterable<T>,Iterator<T>{
	int			t;
	Supplier<T>	supplier;

	SupplyingIterator(int t,Supplier<T> supplier){
		this.t=t;
		this.supplier=supplier;
	}

	@Override
	public Iterator<T> iterator(){
		return this;
	}

	@Override
	public boolean hasNext(){
		return t>0;
	}

	@Override
	public T next(){
		--t;
		return supplier.get();
	}

}

class Range implements Iterable<Integer>,PrimitiveIterator.OfInt{
	int to,cur,d;

	Range(int from,int to,int d){
		this.cur=from-d;
		this.to=to;
		this.d=d;
	}

	Range(int n){
		this(0,n-1,1);
	}

	@Override
	public Iterator<Integer> iterator(){
		return this;
	}

	@Override
	public boolean hasNext(){
		return cur+d==to||(cur!=to&&(cur<to==cur+d<to));
	}

	@Override
	public int nextInt(){
		return cur+=d;
	}
	static Range rep(int i){
		return new Range(i);
	}
	static Range rep(int f,int t,int d){
		return new Range(f,t,d);
	}
	static Range rep(int f,int t){
		return rep(f,t,1);
	}
	static Range rrep(int f,int t){
		return rep(f,t,-1);
	}
}

Measured memory_bytes: 49120
# include <iostream>
# include <algorithm>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <utility>
# include <stack>
# include <queue>
# include <list>
# include <tuple>
using namespace std;
using LL = long long;
using ULL = unsigned long long;

constexpr int INF = 2000000000;
constexpr int HINF = INF / 2;
constexpr double DINF = 100000000000000000.0;
constexpr long long LINF = 9223372036854775807;
constexpr long long HLINF = 4500000000000000000;
const double PI = acos(-1);
int dx[4] = { 0,1,0,-1 }, dy[4] = { 1,0,-1,0 };
#define ALL(x)    (x).begin(),(x).end()
#define UNIQ(c)   (c).erase(unique(ALL((c))), end((c)))
#define mp        make_pair
#define eb        emplace_back
#define REP(i, a) for (int i = 0; i < (a); i++)

int main() {
	int sx, sy, tx, ty;
	cin >> sx >> sy >> tx >> ty;
	for (int i = sy; i < ty; i++) {
		cout << "U";
	}
	for (int i = sx; i < tx; i++) {
		cout << "R";
	}
	for (int i = sy; i < ty; i++) {
		cout << "D";
	}
	for (int i = sx; i < tx; i++) {
		cout << "L";
	}
	cout << "L";
	for (int i = sy; i < ty+1; i++) {
		cout << "U";
	}
	for (int i = sx-1; i < tx; i++) {
		cout << "R";
	}
	cout << "D";
	cout << "R";
	for (int i = sy; i < ty+1; i++) {
		cout << "D";
	}
	for (int i = sx-1; i < tx; i++) {
		cout << "L";
	}
	cout << "U" << endl;
	//system("pause");
}

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <cstdlib>
#include <unordered_map>
#include <map>
#include <unordered_set>
#include <set>
#include <vector>
#include <string>
#include <sstream>
#include <algorithm>
#include <cmath>
#include <queue>
#include <stack>
#include <list>
#include <array>
#include <deque>
#include <bitset>
typedef long long ll;
using namespace std;
#define trace(x) cerr << #x << " is " << x << endl;

const ll INF = 1e18L + 5;

string solve(vector<int>& a, int k) {
    // dp[i] 还剩下i个石头的时候，是否能获胜
    vector<int> dp(k + 1);
    for (int i = 0; i <= k; i++) {
        for(auto x : a) {
            if (i >= x && !dp[i - x]) {
                dp[i] = true;
            }
        }
    }
    return dp[k] ?  "First" : "Second";
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n, k;
    cin >> n >> k;
    vector<int> a(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }
    cout << solve(a, k) <<endl;
    return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <cstring>
#include <vector>
#include <iostream>
#include <queue>
#include <unordered_map>
#include <cmath>
#include <queue>
#include <string>
#include <random>
#include <stack>
#include <set>
#include <unordered_set>

#define bug(x) cout<<"zdongdebug: "<<x<<endl;
#define bug2(x, y) cout<<"zdongdebug: "<<x<<" "<<y<<endl;
using namespace std;
typedef long long ll;
const int maxn = 100005;



int main() {
#ifdef suiyuan2009
  freopen("/Users/suiyuan2009/CLionProjects/icpc/input.txt", "r", stdin);
#endif
  int n,k;
  cin>>n>>k;
  cout<<n-k+1<<endl;
  return 0;
}

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

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	ll n;
	string s;
	cin >> n >> s;
	ll cntw = 0, cntr = 0;
	for(ll i = 0; i < n; i++)
		if(s[i] == 'W') cntw++;
		else cntr++;
	ll sub = 0;
	for(ll i = 0; i < cntr; i++) if(s[i] == 'R') sub++;
	cout << cntr - sub << '\n';
}


Measured memory_bytes: 3756
s = input().strip()
t = input().strip()

d1 = {}
d2 = {}

re = "Yes"
co = 0
for c1,c2 in zip(s,t):
    if (c1 not in d1) and (c2 not in d2):
        d1[c1] = co
        d2[c2] = co
    else:
        if (c1 not in d1) or (c2 not in d2):
            re = "No"
            break
        if d1[c1] != d2[c2]:
            re = "No"
            break
    co += 1

print(re)


Measured memory_bytes: 3632
#include<bits/stdc++.h>
#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL) ;
#define MOD 1000000007
#define int long long 
#define pb push_back
#define pii pair<int,int>
#define vi vector<int>
#define vvi vector<vector<int>>
#define vpii vector<pair<int,int>>
#define ff first
#define ss second
#define INF (1LL<<61)

using namespace std;

string s , t;
int dp[3010][3010];

int solve(int i , int j ){

	if(i==s.size() || j==t.size()) return dp[i][j] = 0;

	if(dp[i][j]!= -1)return dp[i][j];

	if(s[i]==t[j])return dp[i][j] = 1+solve(i+1 , j+1);

	return dp[i][j] = max(solve(i+1, j ) , solve(i , j+1));
}

int32_t main(){   

fastio
// #ifndef ONLINE_JUDGE
// freopen("input.txt", "r", stdin);
// freopen("output.txt","w", stdout);
// #endif

cin>>s>>t;
memset(dp , -1, sizeof(dp));

solve(0,0);


//path reconstruction using dp table
string ans = "";
int i  =0 , j =0;
while(i<s.size() && j<t.size()){
	if(s[i]==t[j]){
		ans+=s[i];
	    i++ ; j++;
	}
	else if(dp[i+1][j]>dp[i][j+1])i++;
	else j++;
}

cout<<ans<<'\n';

return 0;
}


Measured memory_bytes: 74692
// 有點不耐煩會破壞偉大的計劃

#include <bits/stdc++.h>

#define append push_back

using namespace std;
using ll = long long;

const int N = 1e5 + 3;
const int M = 1e6 + 7;
const long long MOD = 1e9 + 7;
const long long INF = 1e14 + 9;
const int SM = 1e3 + 5;
const int logN = 22, BL = 400;
const double EPS = 1e-9, PI = acos(-1);
const int dx[] = {1, 0, 0, -1, -1, 1, -1, 1};
const int dy[] = {0, 1, -1, 0, -1, 1, 1, -1};

void debug() {
	cerr << "\n";
}
template<typename Type1, typename... Type2>
void debug(Type1 a, Type2... b) {
    cerr << a << " ";
    debug(b...);
}

int main() {
//    freopen(".in", "r", stdin);
//    freopen(".out", "w", stdout);
    ios_base::sync_with_stdio(false);
    cin.tie(0), cout.tie(0);

    long long n, ans = INF; cin >> n;

    vector<long long> a(n);

    for(long long i = 0; i < n; i++) {
        cin >> a[i];
        long long cnt = 0;
        while(a[i] % 2 == 0) {
            cnt++;
            a[i] /= 2;
        }
        ans = min(ans, cnt);
    }

    cout << ans;

    return 0;
}


Measured memory_bytes: 3604
import java.util.*;

public class Main {

    public static void main(String args[]) {

        // 入力
        Scanner sc = new Scanner(System.in);
        String s = sc.next();

        // 主処理
        boolean judge = s.startsWith("keyence") || s.endsWith("keyence");
        if (!judge) {
            if ((s.startsWith("k") && s.endsWith("eyence")) || (s.startsWith("ke") && s.endsWith("yence"))
                    || (s.startsWith("key") && s.endsWith("ence")) || (s.startsWith("keye") && s.endsWith("nce"))
                    || (s.startsWith("keyen") && s.endsWith("ce")) || (s.startsWith("keyenc") && s.endsWith("e"))
                    || (s.startsWith("k") && s.endsWith("eyence"))) {
                judge = true;

            }
        }
        String result = judge ? "YES" : "NO";

        // 出力
        System.out.println(result);
        sc.close();
    }
}


Measured memory_bytes: 24912
#include <stdio.h>
#include <algorithm>

using namespace std;

int disp(int block[], int c, int n)
{
	int p, q;
	int i, j;
	
	for (i = 1; block[c + i] == block[c]; i++);
	for (j = 1; block[c - j] == block[c]; j++);
	
	if (i + j - 1 >= 4){
		p = c + i;
		q = c - j;
	}
	else {
		return (n);
	}
	
	while (block[p] != -1 && block[q] != -1){
		if (block[p] != block[q]){
			break;
		}
		for (i = 1; block[p + i] == block[p]; i++);
		for (j = 1; block[q - j] == block[q]; j++);
		
		if (i + j >= 4){
			p += i;
			q -= j;
		}
		else {
			break;
		}
	}
	
	int ret = 0;
	for (int i = p; block[i] != -1; i++){
		ret++;
	}
	for (int i = q; block[i] != -1; i--){
		ret++;
	}
	
	return (ret);
}

int main(void)
{
	int block[10002];
	int n;
	int ans;
	
	while (1){
		scanf("%d", &n);
		
		if (n == 0){
			break;
		}
		
		block[0] = block[n + 1] = -1;
		for (int i = 1; i <= n; i++){
			scanf("%d", &block[i]);
			block[i]--;
		}
		
		ans = 10000;
		for (int i = 1; i <= n; i++){
			block[i] = (block[i] + 1) % 3;
			ans = min(disp(block, i, n), ans);
			block[i] = (block[i] + 1) % 3;
			ans = min(disp(block, i, n), ans);
			block[i] = (block[i] + 1) % 3;
		}
		
		printf("%d\n", ans);
	}
	
	return (0);
}

Measured memory_bytes: 796
#include <bits/stdc++.h>
using namespace std;
#define pb emplace_back
#define fi first
#define se second
#define mp make_pair
#define SZ(x) ((int)(x.size()))
#define FOI(i,a,n) for(int (i)=int(a);(i)<=int(n);++(i))
#define FOD(i,a,n) for(int (i)=int(a);(i)>=int(n);--(i))
#define IN(x,y) ((y).find((x))!=(y).end())
#define ALL(t) t.begin(),t.end()
#define MSET(tabl,i) memset(tabl, i, sizeof(tabl))
#define PSET(x,y) fixed<<setprecision(y)<<lf(x)
#define DBG(c) cout<<#c<<" = "<<c<<endl;
#define RTIME ((double)clock()/(double)CLOCKS_PER_SEC)

template<typename T,typename S>inline bool REMIN(T&a,const S&b){return a>b?a=b,1:0;}
template<typename T,typename S>inline bool REMAX(T&a,const S&b){return a<b?a=b,1:0;}

typedef long long ll;
typedef long double lf;
typedef pair<int, int> pi;
typedef vector<pi> vpi;
typedef vector<int> vi;
typedef vector<vi> vvi;

int bit(ll x, int pos){ return (x >> pos) & 1; }
ll power(ll base, ll exp, ll c = 1e9 + 7) { if(!exp) return 1; ll r = power(base, exp >> 1, c); r=(r*r)%c; if(exp&1) r=(r*base)%c; return r; }

ll T,N,M,K;  
int a,b,c;
string s1,s2;

const lf PI = 2*acos(0);
const ll INF = 1e9 + 4;
const int NMAX = 3e5+5;
const ll MOD = 1000000007;

int ar[NMAX];

int main(){
	ios_base::sync_with_stdio(false); cin.tie(0);
	
	cin >> N >> M;
	int o = 0, e = 0;
	while(N --) {
		cin >> a;
		e += (a % 2 == 0);
		o += (a % 2 == 1);
	}

	M %= 2;
	ll ret = power(2, e, 1e18);
	if(o == 0 && M) {
		ret = 0;
	} else if(M) {
		ret *= power(2, o - 1, 1e18);
	} else if(M == 0 && o == 0) {
		;
	} else if(M == 0 && o) {
		ret *= power(2, o - 1, 1e18);
	}

	cout << ret;

	return 0;
}


Measured memory_bytes: 256
N,M = STDIN.gets.split(' ').map{|s| s.to_i}

SC = []
while line = STDIN.gets
  SC << line.split(' ').map{|str|str.to_i}
end

t = Array.new(N + 1, -1)
SC.each do |a|
  if t[a[0]] != -1 and t[a[0]] != a[1]
    puts '-1'
    exit 0
  end
  t[a[0]] = a[1]
end

a = t[1..N]

if N == 1
  puts a[0] == -1 ? 0 : a[0]
else
  if a[0] == 0
    puts '-1'
  elsif a[0] == -1
    a[0] = 1
    puts a.map{|i| i == -1 ? 0 : i}.join
  else
    puts a.map{|i| i == -1 ? 0 : i}.join
  end
end




Measured memory_bytes: 1788
#include<bits/stdc++.h>
#define ll long long int
using namespace std;

const int mod=1e9+7;
int main()
{
	//#i//fndef ONLINE_JUDGE
//freope/n("input.txt","r",stdin);
	//	freopen("output.txt","w",stdout);
	//#endif
	ll n,k;
	cin>>n>>k;
	vector<ll> in(n);
	for(ll i=0;i<n;i++)
		cin>>in[i];
	vector<bool> dp(k+1);
	for(ll i=0;i<=k;i++)
	{
		for(auto j:in)
		{
			if(j<=i&&!dp[i-j])
				dp[i]=true;
		}
	}
	if(dp[k])
		cout<<"First\n";
	else
		cout<<"Second\n";
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<math.h>
int main()
{
	int a,b,x,y,z;
	scanf("%d%d",&a,&b);
	x=a+b;
	y=a-b;
	z=a*b;
	if(x>=y &&x>=z)
		printf("%d\n",x);
	else if(y>=z && y>=x)
		printf("%d\n",y);
	else 
		printf("%d\n",z);
	
	return 0;
}

Measured memory_bytes: 128
from itertools import combinations
n = int(input())
l_ls = list(map(int, input().split()))
ans = 0
for a,b,c in combinations(l_ls,3):
    if a != b and b != c and c != a and a < b+c and b < a+c and c < a+b:
        ans += 1
print(ans)



Measured memory_bytes: 9176
#include <iostream>
#include <queue>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <cctype>

using namespace std;

#define REP(i,n) for(ll (i) = (0); (i) < (n); ++i)
#define PB push_back
#define MP make_pair
#define FI first
#define SE second
#define ALL(v) v.begin(),v.end()
#define Decimal fixed << setprecision(20)
#define SHOWP(x) cerr<<"["<<(x).FI<<", "<<(x).SE<<"]";
#define SHOWX(x) cerr<<#x<<": "<<x<<endl;
#define SHOWVEC(v, e) REP(i, e) cerr << (v[i]) << ' '; cerr << endl;
#define SHOW2D(a, h, w) REP(i, h){REP(j, w)cerr<<setw(3)<<(a[i][j])<<' ';cerr<<endl;}
constexpr int INF = 1 << 30 - 1;
constexpr long long LLINF = 1LL << 60;
constexpr long long MOD = 1000000007;

typedef long long ll;
typedef pair<ll, ll> P;

bool check(ll N, ll d)
{
  ll m = N/d - 1;
  return m > 0 && N/m == N%m;
}

int main()
{
  ll N; cin >> N;
  ll ans = 0;
  for (ll i = 1; i * i <= N; i++) {
    if (N % i > 0) continue;
    ll d1 = i, d2 = N/i;
    if (check(N, d1)) ans += N/d1 - 1;
    if (d1 != d2 && check(N, d2)) ans += N/d2 - 1;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<cstring>

char ab(char c){
	if(c == 'z'){
		return 'a';
	}
	if(c == ' ' || c == '.' || c == '\n'){
		return c;
	}
	return c + 1;
}

char ba(char c){
	if(c == 'a'){
		return 'z';
	}
	if(c == ' '|| c == '.' || c == '\n'){
		return c;
	}
	return c - 1;
}

int main(){
	char s[82];
	char *f;
	char c;
	int sh, a;

	while(scanf("%c", &s[0]) + 1){
		char th[3][5] = {"the", "this", "that"};

		a = 0;
		while(s[a] - 10){
			a++;
			scanf("%c", &s[a]);
		}
	
		a++;
		s[a] = '\0';
		f = 0;
		for(int i = 0; i < 26; i++){
			f = 0;
			for(int j = 0; j < 3; j++){
				f = strstr(s, th[j]);
				if(f){
					j += 3;
					sh = i;
					i += 26;
				}
			}

			for(int j = 0; j < 3; j++){
				int t = 0;
				while(th[j][t]){
					th[j][t] = ab(th[j][t]);
					t++;
				}
			}
		}

		a = 0;
		while(s[a]){
			char shc = s[a];
			for(int i = 0; i < sh; i++){
				shc = ba(shc);
			}
			printf("%c", shc);
			a++;
		}
	}
}

Measured memory_bytes: 948
using System;
using System.Text;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Threading.Tasks;
using System.IO;

class Solve
{
	const int mod = 1000000007;
	static void Main(string[] args)
	{
		var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
		Console.SetOut(sw);

		int N = int.Parse(Console.ReadLine());
		int[] A = new int[N];
		int[] Acopy = new int[N];
		int Max = 0;
		int index = -1;
		for (var i = 0; i < N; i++)
		{

			A[i] = int.Parse(Console.ReadLine());
			Acopy[i] = A[i];
			if (A[i] > Max)
			{
				Max = A[i];
				index = i;

			}
		}
		Array.Sort(Acopy);

		for (var i = 0; i < N; i++)
		{
			if (i == index)
			{
				Console.WriteLine(Acopy[N - 2]);
			}
			else { Console.WriteLine(Max); }
		}

		Console.Out.Flush();
	}
}

Measured memory_bytes: 17876
#include <stdio.h>

int main(){
  int sum,i;
  char num[1001];

  while(1){
    scanf("%s",num);
    if(num[0]=='0') break;
    for(sum=0,i=0;num[i]!='\0';i++){
      sum+=(num[i]-'0');
    }
    printf("%d\n",sum);
  }
    
  return 0;
}

Measured memory_bytes: 536
#include<bits/stdc++.h>
#define mod 998244353
using namespace std;
int C[4005][4005],Pow[4005],k,n;
int solve(int x,int y,int z){
    int res=0;
    for(int i=0;i<=z&&i<=x;++i)
        if(y+i-1>=0)res=(res+1ll*Pow[i]*C[x][i]%mod*C[z+y-1][y+i-1]%mod)%mod;
    return res;
}
int main(){
	C[0][0]=1,Pow[0]=1;
	for(int i=1;i<=4000;++i){
		C[i][0]=1; 
		for(int j=1;j<=i;++j)C[i][j]=(C[i-1][j]+C[i-1][j-1])%mod;
		Pow[i]=Pow[i-1]*2%mod;
	}
	scanf("%d%d",&k,&n);
	for(int i=2;i<=2*k;++i){
		int cnt=min(i-1,k)-max(0,i-k-1);
		if(i&1)printf("%d\n",solve(cnt/2,k-cnt,n));
        else printf("%d\n",(solve((cnt-1)/2,k-cnt,n)+solve((cnt-1)/2,k-cnt,n-1))%mod);
	}
}

Measured memory_bytes: 61440
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep2(i, x, n) for(int i = x; i <= n; i++)
#define rep3(i, x, n) for(int i = x; i >= n; i--)
#define elif else if
#define sp(x) fixed << setprecision(x)
#define pb push_back
#define eb emplace_back
#define all(x) x.begin(), x.end()
#define sz(x) (int)x.size()
using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using pil = pair<int, ll>;
using pli = pair<ll, int>;
using pll = pair<ll, ll>;
const ll MOD = 1e9+7;
//const ll MOD = 998244353;
const int inf = (1<<30)-1;
const ll INF = (1LL<<60)-1;
const ld EPS = 1e-10;
template<typename T> bool chmax(T &x, const T &y) {return (x < y)? (x = y, true) : false;};
template<typename T> bool chmin(T &x, const T &y) {return (x > y)? (x = y, true) : false;};

int main(){
    int N;
    cin >> N;
    string a[N];
    ll A[N];
    rep(i, N){
        cin >> a[i];
        bool flag = false;
        int n = sz(a[i]);
        int cnt = 9;
        A[i] = 0;
        rep(j, n){
            if(a[i][j] == '.') {flag = true; continue;}
            ll x = a[i][j]-'0';
            A[i] *= 10, A[i] += x;
            if(flag) cnt--;
        }
        rep(j, cnt) A[i] *= 10;
    }
    ll cnt[19][19];
    rep(i, 19) rep(j, 19) cnt[i][j] = 0;
    int c[N], d[N];
    rep(i, N){
        c[i] = d[i] = 0;
        while(A[i]%2 == 0) A[i] /= 2, c[i]++;
        while(A[i]%5 == 0) A[i] /= 5, d[i]++;
        chmin(c[i], 18), chmin(d[i], 18);
        cnt[c[i]][d[i]]++;
    }
    ll ans = 0;
    rep(i, N){
        rep(j, 19) rep(k, 19){
            if(c[i]+j >= 18 && d[i]+k >= 18) ans += cnt[j][k];
        }
        if(c[i]*2 >= 18 && d[i]*2 >= 18) ans--;
    }
    cout << ans/2 << endl;
}

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

int main() {
  char c;
  
  cin >> c;
  
  if(c == 'a' || c == 'i' || c == 'u' || c == 'e' || c == 'o'){
    cout << "vowel" << endl;
  }
  
  else{
    cout << "consonant" << endl;
  }
}


Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#define rep(i,N) for(int i=0;i<(int)N;i++)
const int sz=1e5;
int qLen,qHead,Q[sz],*cave[sz];
void PUSH(int n){Q[(qHead+qLen)%sz]=n;qLen++;}
int POP(void){int q=Q[qHead];qLen--;qHead=(qHead+1)%sz;return q;}
int main(void)
{
  int A,B,N,M,x,y;
  x=scanf("%d %d",&N,&M);
  int room[N],path[N];
  rep(i,N)path[i]=0,room[i]=-1;
  while(~scanf("%d %d",&A,&B))
  {
    A--,B--;
    cave[A]=(int*)realloc(cave[A],sizeof(int)*(path[A]+1));cave[A][path[A]]=B;path[A]++;
    cave[B]=(int*)realloc(cave[B],sizeof(int)*(path[B]+1));cave[B][path[B]]=A;path[B]++;
  }
  room[0]=0;PUSH(0);
  while(qLen)
  {
    x=POP();rep(i,path[x]){y=cave[x][i];if(!(room[y]<0))continue;room[y]=x,PUSH(y);}
  }
  puts("Yes");rep(i,N-1)printf("%d\n",room[i+1]+1);
}

Measured memory_bytes: 8484
#include <iostream>
#include <sstream>
#include <string>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cassert>

using namespace std;

#define FOR(i,k,n) for(int i=(k); i<(int)n; ++i)
#define REP(i,n) FOR(i,0,n)

vector<int> M;
int N;
int memo[20][(1<<13) + 1];
bool dfs(int idx, int s){
  int& res = memo[idx][s];
  if(res != -1) return res;
  if(idx % 2 == 0){
    if(s == 1) return false;
    if(s - M[idx] <= 1) return true;
    for(int x = 1; x <= M[idx]; x++){
      if(dfs((idx + 1) % (2*N), s - x)) return res = true;
    }
    return res = false;
  }else{
    if(s == 1) return true;
    if(s - M[idx] <= 1) return false;
    for(int x = 1; x <= M[idx]; x++){
      if(!dfs((idx + 1) % (2*N), s - x)) return res = false;
    }
    return res = true;
  }
}

int main(){
  while(cin>>N && N){
    int S; cin>>S;
    M = vector<int>(2 * N);
    REP(i, 2 * N) cin>>M[i];
    memset(memo, -1, sizeof(memo));
    if(dfs(0, S)) cout<<1<<endl;
    else cout<<0<<endl;
  }
  return 0;
}

Measured memory_bytes: 2196
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(i, n) for (ll i = 0; i < n; i++)
#define FOR(i, a, b) for (ll i = a; i < b; i++)
#define len(v) ll(v.size())
#define fi first
#define se second

template <class T>
void cout_vec(const vector<T> &vec){
  for(auto itr:vec) cout<<itr<<' ';
  cout<<endl;
}

typedef pair<ll,ll> P;
const ll mod=1e9+7;
const ll inf=1e15;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin>>n;
    vector<ll> a(n);
    bool flag=true;
    rep(i,n){
      cin>>a[i];
      if(!flag) continue;
      if(i==0) flag=(a[i]==0);
      else flag=(a[i]<=a[i-1]+1);
    }
    if(!flag){
      cout<<-1<<endl;
      return 0;
    }
    ll ans=0;
    for(int i=n-1;i>=0;i--){
      if(i!=n-1 && a[i]==a[i+1]-1) continue;
      ans+=a[i];
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 1792
//的場梨沙★担当
//結城晴★副担当
//日野茜★副担当
#include <vector>
#include <list>
#include <map>
#include <climits>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string.h>
#include <string>
#include <cstring>
#include <ctime>
#include <queue>
#include <random>
#include <cctype>
#include <complex>
#include <regex>
#include <unordered_map>
#include <string>
#include <algorithm>
#include <cctype>
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <iomanip>
#include <iostream>
#include <stdio.h>
#include <string.h>
#include <vector>
#include <stdio.h>


using namespace std;

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

      if(S[0]=='A'){
        cout<<"T"<<endl;
      }
      else if(S[0]=='C'){
        cout<<"G"<<endl;
       }
      else if(S[0]=='T'){
          cout<<"A"<<endl;
      }
      else if(S[0]=='G'){
          cout<<"C"<<endl;
      }
}


Measured memory_bytes: 256
#include <cstdio>


using ll=long long int;

const int MAXN=2e5+3;
const ll MOD=1e9+7;

int N;
ll A[MAXN]
;
ll power(ll base,int exp){
    if (exp==0) return 1ll;
    auto temp=power(base,exp/2);
    return exp%2?temp*temp%MOD*base%MOD:temp*temp%MOD;
}


int main(){
    ll ans=0ll;
    scanf("%d",&N);
    ll sum=0;
    for(int i=0;i<N;i++){
        scanf("%lld",A+i);
        sum=(sum+A[i])%MOD;
    }

    for(int i=0;i<N;i++){
        ans=(ans+A[i]*((sum+(MOD-A[i]))%MOD)%MOD)%MOD;
    }

    printf("%lld\n",ans*power(2,MOD-2)%MOD);
    return 0;
}

Measured memory_bytes: 3272
num = int(input())
order = [int(s) for s in input().split()]
utility = [int(s) for s in input().split()]
add = [int(s) for s in input().split()]
point = 0
for i in range(num - 1):
  if order[i] + 1 == order[i + 1]:
    point += add[order[i] - 1]
    
print(sum(utility) + point)



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

#define ll long long
#define ld long double
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define PI 3.14159265358979323846
#define sz(x) ((int)(x).size())

const int INF = 1e9;
const int MOD = 1e9 + 7;
const ll LINF = 1e18;

template <class T, class S>
T PowMod(S n, T m)
{
    if (m == 0)
    {
        return 1;
    }
    if (m % 2 == 0)
    {
        T temp = PowMod(n, m / 2);
        return temp * temp;
    }
    return n * PowMod(n, m - 1);
}

ll my_Pow(ll a,ll b)
{
    ll r = 1;
    while(b--)
    {
        r*=(ll)a;
    }
    return r;
}

int main()
{
    ll n;
    cin >> n;
    int dev = 1;
    vector<int> s;
    if (n==0)
    {
        cout << 0 << endl;
        return 0;
    }
    

    while(n!=0 && dev < 42)
    {
       if (n%(1ull<<dev)==0)
       {
           s.push_back(0);
       }else
       {
           s.push_back(1);
           n -= my_Pow((ll)-2, dev-1);
           
       }
       //for(auto u: s)cout << u;
       //cout << endl;
       //cout << dev <<' ' << n << endl;
       dev++;
    }
    
    int len = sz(s);
    for (int i = len-1; i >=0; i--)
    {
        cout << s[i];
    }
    cout << endl;
    
}

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

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

  vector<int> V(N);
  vector<int> C(N);

  for (int i = 0; i < N; i++)
    cin >> V.at(i);
  for (int i = 0; i < N; i++)
    cin >> C.at(i);

  int ans = 0;
  for (int i = 0; i < N; i++)
  {
    if (V.at(i) - C.at(i) > 0)
      ans += V.at(i) - C.at(i);
  }

  cout << ans << endl;
}


Measured memory_bytes: 3600
import java.util.*;
public class Main{
  public static void main(String [] args){
    Scanner sc = new Scanner(System.in);
    int a,b,sum,digits;
    while(sc.hasNext()){
      digits = 0;
      a = sc.nextInt();
      b = sc.nextInt();
      sum = a + b;
      while(sum >= 1){
        sum /= 10;
        digits++;
      }
      System.out.println(digits);
    }
  }
}

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

int main () {
  int a,b,c;
  cin >> a >> b >> c;
  if(a+b==c){
    cout << "Yes" << endl;
  }
  else if(a+c==b){
    cout << "Yes" << endl;
  }
  else if(b+c==a){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
import sys

if sys.subversion[0] == "PyPy":
    import io, atexit

    sys.stdout = io.BytesIO()
    atexit.register(lambda: sys.__stdout__.write(sys.stdout.getvalue()))

    sys.stdin = io.BytesIO(sys.stdin.read())
    input = lambda: sys.stdin.readline().rstrip()
RS = raw_input
RA = lambda x=int: map(x, RS().split())
RN = lambda x=int: x(RS())


def solve():
    rm = k
    i = 0
    books_read = 0
    while i<n and rm - a[i] >= 0:
        rm -= a[i]
        books_read += 1
        i += 1
    i -= 1
    max_read = books_read
    j = 0
    while (j<m and i>=0):
        while j < m and rm - b[j] >= 0:
            rm -= b[j]
            books_read += 1
            j += 1
            max_read = max(max_read, books_read)
        rm += a[i]
        i -= 1
        books_read -= 1
        while j<m and rm - b[j] >= 0:
            rm -= b[j]
            books_read += 1
            j += 1
            max_read = max(max_read, books_read)
    print(max_read)

    return




n,m,k = RA()
a = RA()
b = RA()
solve()


Measured memory_bytes: 126664
#include <bits/stdc++.h>
using namespace std;
int main () {
	int N,M;
	cin >> N >> M;
	std::vector<int>  x(M);
	if(N > M){
		cout << 0 << endl;
	}else{
		for (int i = 0; i < M; ++i)
		{
			cin >> x[i];
		}
		sort(x.begin(), x.end());
		std::vector<int> dist(M-1);
		for (int i = 0; i < M-1; ++i)
		{
			dist[i] = x[i+1] - x[i];
		}
		sort(dist.begin(), dist.end());
		int difference = M - N;
		int result = 0;
		for(int i = 0; i < difference; i++){
			result += dist[i];
		}
		cout << result << endl;
	}



}

Measured memory_bytes: 1024
#include<vector>
class mod_int{
private:
    unsigned long long num;
public:
    static constexpr auto mod=static_cast<unsigned long long>(1e9+7);
    static mod_int pow(mod_int x,unsigned long long y)
    {
        return y==0?1:y%2==0?pow(x*x,y/2):x*pow(x,y-1);
    }
    mod_int()=default;
    mod_int(unsigned long long n):num(n%mod)
    {
    }
    explicit operator unsigned long long()const
    {
        return num;
    }
    bool operator==(const mod_int&mi)const
    {
        return num==mi.num;
    }
    bool operator!=(const mod_int&mi)const
    {
        return !operator==(mi);
    }
    mod_int operator~()const
    {
        return pow(*this,mod-2);
    }
    mod_int operator+(const mod_int&mi)const
    {
        return num+mi.num;
    }
    mod_int operator-(const mod_int&mi)const
    {
        return num+mod-mi.num;
    }
    mod_int operator*(const mod_int&mi)const
    {
        return num*mi.num;
    }
    mod_int operator/(const mod_int&mi)const
    {
        return num*(~mi).num;
    }
    mod_int&operator+=(const mod_int&mi)
    {
        return*this=operator+(mi);
    }
    mod_int&operator-=(const mod_int&mi)
    {
        return*this=operator-(mi);
    }
    mod_int&operator*=(const mod_int&mi)
    {
        return*this=operator*(mi);
    }
    mod_int&operator/=(const mod_int&mi)
    {
        return*this=operator/(mi);
    }
};
class combination_modulo:mod_int{
private:
    std::vector<mod_int>factorial_mod;
public:
    combination_modulo(unsigned long long max_n):factorial_mod(max_n+1)
    {
        factorial_mod[0]=1;
        for(unsigned long long i=1;i<=max_n;++i)factorial_mod[i]=factorial_mod[i-1]*i;
    }
    mod_int operator()(unsigned long long n,unsigned long long r)
    {
        return n<r?0:factorial_mod[n]/(factorial_mod[r]*factorial_mod[n-r]);
    }
};
#include<iostream>
int main()
{
    long long x,y;
    std::cin>>x>>y;
    if((2*y-x)%3!=0||(2*x-y)%3!=0){
        std::cout<<0<<std::endl;
    }else{
        long long a=(2*y-x)/3,b=(2*x-y)/3;
        if(a<0||b<0){
            std::cout<<0<<std::endl;
        }else{
            combination_modulo cm(a+b);
            std::cout<<(unsigned long long)cm(a+b,a)<<std::endl;
        }
    }
}


Measured memory_bytes: 5504
def main():
    frames = int(input())
    integer = list(map(int, input().split()))
    average = sum(integer) / frames
    answer = 0
    target = abs(average - integer[0])
    for i in range(1, frames):
        if abs(average - integer[i]) < target:
            target = abs(average - integer[i])
            answer = i
    print(answer)


if __name__ == '__main__':
    main()



Measured memory_bytes: 3060
import Data.Maybe
import Control.Monad
import qualified Data.ByteString.Char8 as C

readInt' = fst.fromJust.C.readInt
readLnInt = map readInt'.C.words<$>C.getLine
readCsInt n = concat<$>replicateM n readLnInt

x ? (a,b) = if x then a else b
a~>(f,x) = [a] ++ (null x)?([],f x)
half = flip div 2
aliq = ((0==).).mod

main = do
 inputs <- readLnInt
 print $ solve inputs

solve [a,b] = (a>b2)?(a-b2,0) where
  b2 = 2 * b


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

int main() {
    string s;
    cin>>s;
    string ans = s == "ABC" ? "ARC" : "ABC";
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 3608
#include<bits/stdc++.h>
#define in std::cin
#define out std::cout
#define rep(i,N)for(LL i=0;i<N;i++)
typedef long long int LL;

const LL mod=1000000007;

LL extgcd(LL a,LL b,LL &x,LL&y){
    LL g=a;x=1,y=0;
    if(b!=0){
        g=extgcd(b,a%b,y,x);
        y-=(a/b)*x;

    }
    return g;
}

LL mod_inverse(LL a,LL m){
    LL x,y;
    extgcd(a,m,x,y);
    return (m+x%m)%m;
}

std::vector<LL>fact;
void mod_fact(LL n,LL m){
    fact.resize(n+1);
    fact[0]=1;
    for(LL i=1;i<=n;i++)fact[i]=fact[i-1]*i%m;
}

LL mod_comb(LL n,LL k,LL m){
    if(n<k)return 0;
    return fact[n]*mod_inverse(fact[k]*fact[n-k]%m,m)%m;
}

int main(){
    LL X,Y;
    in>>X>>Y;
    if((X+Y)%3!=0){
        out<<0<<std::endl;
        return 0;
    }
    LL n=(X+Y)/3,k=-1;
    if(n%2==std::abs(X-Y)%2)k=(n-std::abs(X-Y))/2;
    if(k<0)out <<0<<std::endl;
    else{
        mod_fact(n,mod);
        out<<mod_comb(n,k,mod)<<std::endl;
    }

}

Measured memory_bytes: 5504
#include<iostream>
using namespace std;
int main(){
long N,M;
  cin>>N>>M;
  long A[10005];
  for (long i=0; i<M; i++){
    cin>>A[i];
  }
  long sum=0;
  for (long i=0; i<M; i++){
    sum+=A[i];
  }
  if ((N-sum)>=0) cout<<N-sum<<endl;
  else cout<<"-1"<<endl;
}

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

int main(void) {
  int N, L, ans = 0;
  cin >> N >> L;
  vector<int> smell(N, 0);
  vector<int> abs_smell(N, 0);
  for (int i = 0; i < N; i++) {
    ans += L + i;
    smell[i] = L + i;
    abs_smell[i] = abs(L + i);
  }
  cout << ans - smell[min_element(abs_smell.begin(), abs_smell.end()) -
                      abs_smell.begin()]
       << endl;
  return 0;
}

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

#define int            long long int
#define float          long double
#define setbits(x)     __builtin_popcountll(x)
#define zrobits(x)     __builtin_ctzll(x)
#define mod            1000000007
#define inf            1e18
#define set_pre(x,y)   fixed<<setprecision(y)<<x
#define w(t)           int t; cin>>t; while(t--)
using namespace std;
int power(int x, int y, int p)
{
    int res = 1;
    x = x % p;
    while (y > 0)
    {
        if (y & 1)
            res = (res * x) % p;
        y = y >> 1;
        x = (x * x) % p;
    }
    return res;
}
int modi(int a, int m)
{
    return power(a, m - 2, m);
}
int32_t main()
{
    int n;
    cin>>n;
    int w;
    cin>>w;
    vector<int>wt(n,0);
    vector<int>v(n,0);
    int val=0;
    for(int i=0;i<n;i++){
        cin>>wt[i]>>v[i];
        val=max(val,v[i]);
    }
    vector<vector<int>>dp(n+1,vector<int>(val*n+1,INT_MAX));
    dp[0][0]=0;
    for(int i=1;i<=n;i++)
    {
        dp[i][0]=0;
        for(int j=1;j<=val*n;j++)
        {
            dp[i][j]=min(dp[i][j],dp[i-1][j]);
            if(j>=v[i-1])
                dp[i][j]=min(dp[i][j],dp[i-1][j-v[i-1]]+wt[i-1]);
        }
    }
    int ans=0;
    for(int i=0;i<=val*n;i++)
    {
        if(dp[n][i]<=w)
        {
            ans=i;
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 80256
#include<bits/stdc++.h>
#define INF 2147483647
#define inf 1000000007
#define SYOU(x) setprecision(x)
#define abs(x,y) (max(x,y)-min(x,y))
#define mp make_pair
#define fi first
#define se second
using namespace std;
long long i[3000000];
bool o;
bool ans[5];
signed main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  long long a,b,c,d=0,e=0,f=0,g=0,h=0,j=0;
  cin >>a>>b;
  a=a+b;
  if(a%2!=0) cout <<a/2+1<<'\n';
  else cout <<a/2<<'\n';
  return (0);
}


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

/* short names and const
using ll = long long;
using vll = vector<long long>;
using df = vector<vector<long long>>;
df data(n, vector<long long>(m));
const int MOD = 1e9 + 7;
int INF = numeric_limits<int>::max();
*/

/* Boost!
#include <boost/algorithm/string/classification.hpp> // is_any_of
#include <boost/algorithm/string/split.hpp>
using boost::algorithm::split; // split(result, s, boost::is_any_of(","));
#include <boost/algorithm/string/join.hpp>
using boost::algorithm::join; // string s = join(arr, "");
#include <boost/algorithm/string/replace.hpp>
using boost::algorithm::replace_all; // replace_all(s, "AtCoder", "A");
#include <boost/range/algorithm.hpp> // boost::sort(arr)
#include <boost/multiprecision/cpp_int.hpp>
using boost::multiprecision::cpp_int;
*/

/* print(arr)
template <class T>
void print(vector<T> &vec) {
  for (auto& a : vec) {
    cout << a;
    if (&a != &vec.back()) cout << " ";
  }
  cout << endl;
}
*/

/* fast cin and precise cout
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  getline(cin, s);
  cout << fixed << setprecision(15);
*/

/* sum function
int sum(vector<int> &arr) {
  int res = accumulate(arr.begin(), arr.end(), 0);
  return res;
}
*/

/* if in function
template <class T>
bool contain(vector<T> &vec, T find_it) {
  auto it = find(vec.begin(), vec.end(), find_it);
  return it != vec.end();
}

bool contain(string &str, char c) {
  auto it = find(str.begin(), str.end(), c);
  return it != str.end();
}
*/

bool contain(string &str, char c) {
  auto it = find(str.begin(), str.end(), c);
  return it != str.end();
}

int main() {
  string n, s;
  getline(cin, n);
  getline(cin, s);
  cout << (contain(s, 'Y') ? "Four" : "Three") << endl;
}


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

namespace ConsoleApplication7
{
    class Program
    {
        static void Main(string[] args)
        {
            long[] vals = Console.ReadLine().Split(' ').Select(tmp => long.Parse(tmp)).ToArray();

            Console.WriteLine(vals[0] * vals[1]);
        }
    }
}


Measured memory_bytes: 28200
using System;
using System.Linq;

class Test
{
    static void Main()
    {
        int count = 0;
        string W = Console.ReadLine();

        string T;
        while ((T = Console.ReadLine()) != "END_OF_TEXT")
        {
            string[] Ti = T.Split();
            foreach (string s in Ti)
            {
                if (s.ToLower().CompareTo(W) == 0 ) count++;
            }
        }
        Console.WriteLine(count);
    }
}


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

#define repd(i, a, b) for (ll i = (a); i < (b); i++)
#define repb(i, n) for (ll i = (n)-1; i >= 0; i--)
#define rep(i, n) repd(i, 0, n)

using namespace std;

using ll = long long;
using ul = unsigned long long;
using ld = long double;
const ul mod = 1000000007;

struct edge {
    ll to, cost;
    edge(ll to = 0, ll cost = 0) : to(to), cost(cost) {}
};

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n, k;
    cin >> n >> k;
    vector<ll> p(n), c(n);
    rep(i, n) {
        cin >> p[i];
        p[i]--;
    }
    rep(i, n) { cin >> c[i]; }
    ll cost_max = c[0];
    rep(i, n) { cost_max = max(cost_max, c[i]); }
    if (cost_max < 0) {
        cout << cost_max << endl;
        return 0;
    }

    vector<edge> g(n);
    rep(i, n) { g[i] = edge(p[i], c[p[i]]); }

    vector<bool> seen(n);
    vector<ll> cost(n), length(n);
    auto dfs_first = [&](auto self, size_t x, ll start, ll depth) -> ll {
        seen[x] = true;
        if (g[x].to == start) {
            length[g[x].to] = depth + 1;
            return g[x].cost;
        } else {
            return self(self, g[x].to, start, depth + 1) + g[x].cost;
        }
    };

    auto dfs_second = [&](auto self, size_t x, ll value, ll depth) -> void {
        cost[x] = value;
        length[g[x].to] = depth;
        if (cost[g[x].to] == value) {
            return;
        } else {
            self(self, g[x].to, value, depth);
        }
    };

    rep(i, n) {
        if (!seen[i]) {
            ll value = dfs_first(dfs_first, i, i, 0);
            dfs_second(dfs_second, i, value, length[i]);
        }
    }

    auto dfs = [&](auto self, size_t x, ll remain) -> ll {
        if (remain == 0) {
            return 0;
        } else {
            return max(0LL, self(self, g[x].to, remain - 1) + g[x].cost);
        }
    };

    vector<ll> ans(n);
    rep(i, n) {
        ll temp = 0;
        if (cost[i] > 0) {
            temp = cost[i] * (k / length[i] - 1);
        }
        ans[i] = temp + dfs(dfs, i, k % length[i] + length[i]);
    };

    ll temp = ans[0];
    rep(i, n) { temp = max(temp, ans[i]); }
    cout << temp << endl;
    return 0;
}



Measured memory_bytes: 4188
package main

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

func getScanner(fp io.Reader) *bufio.Scanner {
	sc := bufio.NewScanner(fp)
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 500001), 500000)
	return sc
}

func getHugeScanner(fp io.Reader, size int) *bufio.Scanner {
	sc := bufio.NewScanner(fp)
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, size), size)
	return sc
}

func getNextString(sc *bufio.Scanner) string {
	sc.Scan()
	return sc.Text()
}

func getNextInt(sc *bufio.Scanner) int {
	i, _ := strconv.Atoi(getNextString(sc))
	return i
}

func getNextInt64(sc *bufio.Scanner) int64 {
	i, _ := strconv.ParseInt(getNextString(sc), 10, 64)
	return i
}

func getNextFloat64(sc *bufio.Scanner) float64 {
	i, _ := strconv.ParseFloat(getNextString(sc), 64)
	return i
}

func Solve(stdin io.Reader, stdout io.Writer) {
	sc := getScanner(stdin)

	a := getNextInt(sc)
	p := getNextInt(sc)

	_, _ = fmt.Fprintf(stdout, "%v\n", (a * 3 + p) / 2)
}

func main() {
	Solve(os.Stdin, os.Stdout)
	return
}

Measured memory_bytes: 640