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

using namespace std;

#define range(i, m, n) for(int i = m; i < n; i++)
#define husk(i, m, n) for(int i = m; i > n; i--)

int n;

int main() {
  cin >> n;
  n -= 2;
  long long res;
  cin >> res;
  vector<int> a(n);
  range(i, 0, n) cin >> a[i];
  int foo;
  cin >> foo;
  res += foo;
  if(n == 0) {
    cout << res;
    return 0;
  }
  vector<pair<long long, long long>> cur;
  vector<pair<int, int>> to((1 << (n + 1)) - 1, make_pair(-1, -1));
  function<void(int, int, int)> dfs = [&](int u, int v, int dep) {
    cur.emplace_back(u, v);
    if(dep == n) return;
    int pos = cur.size() - 1;
    to[pos].first = cur.size();
    dfs(u, u + v, dep + 1);
    to[pos].second = cur.size();
    dfs(u + v, v, dep + 1);
  };
  dfs(1, 1, 0);
  vector<vector<vector<long long>>> dp(n, vector<vector<long long>>(n, vector<long long>((1 << (n + 1)) - 1, LLONG_MAX / 3)));
  range(s, 0, n) {
    range(x, 0, n - s) {
      int y = x + s;
      if(x == y) {
        range(z, 0, (1 << (n + 1)) - 1) dp[x][y][z] = cur[z].first * a[x] + cur[z].second * a[y];
        continue;
      }
      range(z, 0, (1 << (n + 1)) - 1) {
        int u = to[z].first, v = to[z].second;
        if(u == -1) continue;
        range(d, x, y + 1) {
          long long l = (d == x ? 0 : dp[x][d - 1][u]), r = (d == y ? 0 : dp[d + 1][y][v]);
          dp[x][y][z] = min(dp[x][y][z], l + r + (cur[z].first + cur[z].second) * a[d]);
        }
      }
    }
  }
  res += dp[0][n - 1][0];
  cout << res;
  return 0;
}


Measured memory_bytes: 284912
#include <bits/stdc++.h>
 
#define FOR(i, a, b) for(int i = a;i < b;i++)
#define For(i, a) FOR(i, 0, a)
#define REV(i, a, b) for(int i = b-1;i >= a;i--)
#define Rev(i, a) REV(i, 0, a)
#define REP(a) For(i, a)
#define DEBUG_PRINT(...) fprintf(stderr, __VA_ARGS__)
 
using namespace std;
typedef long long ll;
typedef pair<int, int> pi;
typedef vector<int> vi;
void print_pair(pi a){
  cerr<<"("<<a.first<<", "<<a.second<<") ";
}
template<int T1, int T2>
void print_2d(int a[T1][T2], int x, int y){
  For(i, x){
    For(j, y){
      cerr<<a[i][j]<<" ";
    }
    cerr<<endl;
  }
}
 
template<typename T>
int sgn(T val){
  return (T(0)<val)-(val<T(0));
}
 
tuple<long long,long long,long long> egcd(long long a,long long b){
  if(a==0||b==0)return std::make_tuple(0LL,0LL,0LL);
  long long sa=sgn(a),sb=sgn(b);
  a=std::abs(a);b=std::abs(b);
  long long p=1,q=0,r=0,s=1;
  while(b>0){
    long long c=a/b;
    long long d;
    d=a;a=b;b=d%b;
    d=p;p=q;q=d-c*q;
    d=r;r=s;s=d-c*s;
  }
  return std::make_tuple(a,p*sa,r*sb);
}
 
long long inverse(long long a,long long m){
  auto b=egcd(a,m);
  if(std::get<0>(b)!=1)return 0;
  return (std::get<1>(b)<0)?std::get<1>(b)+m:std::get<1>(b);
}
 
long long factorial(long long a,long long m){
  long long ret=1;
  for (long long i = 1; i <= a; i++) {
    ret*=(i%m);
    ret%=m;
  }
  return ret;
}
long long partial_factorial(long long a,long long n,long long m){
  long long ret=1;
  for (long long i = 0; i < n; i++) {
    ret*=(a-i)%m;
    ret%=m;
  }
  return ret;
}
long long combination_prime(long long n,long long r,long long m){
  long long ret;
  long long fact_r=factorial(r,m);
  ret=inverse(fact_r,m);
  long long pfact_n=partial_factorial(n,r,m);
  ret*=pfact_n;
  ret%=m;
  return ret;
}
long long cache_cmb[1000000],cache_inv_fact[1000000];
bool cached=false;
long long combination_cached(long long n,long long r,long long m){
  if(cached==false){
    cached=true;
    cache_inv_fact[1]=1;
    for (long long i = 2; i <= n; i++) {
      cache_inv_fact[i]=(m-m/i)*cache_inv_fact[m%i]%m;
    }
    cache_cmb[0]=1;
    for (long long i = 1; i <= n/2; i++) {
      cache_cmb[i]=cache_cmb[i-1]*(n-i+1)%m*cache_inv_fact[i]%m;
    }
  }
  r=min(r,n-r);
  return cache_cmb[r];
}
 
ll N,A,B,K;
vector<pair<ll,ll> > pat;
const long long mod=998244353;
int main()
{
        ll n,a,b,k,ans=0;
  cin>>n>>a>>b>>k;
  for (ll i = 0; i <= n; i++) {
    if(a*i>k)break;
    if((k-a*i)%b!=0)continue;
    ll j=(k-a*i)/b;
    if(j>n)continue;
    ans+=combination_cached(n,i,mod)*combination_cached(n,j,mod)%mod;
    ans%=mod;
  }
        printf("%lld\n",ans);
        return 0;
}

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

const int INF = pow(2, 31) - 1;
#define ll long long
#define DEBUG(x) cout << "DEBUG>" << #x << ":" << x << endl;
#define REP(i,n) for(ll i=0;i<(n);i++)
#define FOR(i,a,b) for(ll i=(a);i<=(b);i++)
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}

int main() {
  int N;
  cin >> N;
  vector<int> X(N);
  vector<int> X_sorted(N);
  REP(i, N) {
    cin >> X[i];
  }
  X_sorted = X;
  sort(X_sorted.begin(), X_sorted.end());
  REP(i, N) {
    if(X[i] < X_sorted[N / 2]) {
      cout << X_sorted[N / 2] << endl;
    } else {
      cout << X_sorted[N / 2 - 1] << endl;
    }
  }
  return 0;
}


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



int main(){
	string S;
	cin >> S;
	for(int i = 0; i<S.size(); i++){
		cout << "x";
	}
	cout << endl;
	return 0;
}


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

int main(){
    int num[5] = {};
    int k;
    int ans = 0;
    for (int i = 0; i < 5; i++) {
        cin >> num[i];
    }

    cin >> k;

    for (int i = 0; i < 4; i++) {
        for (int j = i+1; j < 5; j++){
            if ( num[j] - num[i] > k) {
                ans = 1;
            }
        }
    }

    if ( ans == 1 ) {
        cout << ":(" << endl;
    } else {
        cout << "Yay!" << endl;
    }
}

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

int main(void){
    int n,c;
    long long ans = 5000000000000000;
    cin >> n >> c;
    int d[c][c];
    rep(i,c) rep(j,c)cin >>d[i][j];
    int c2[n][n];
    rep(i,n) rep(j,n)cin >>c2[i][j];
    long long iwakan[c][3];
    rep(i,c)rep(j,3)iwakan[i][j] = 0;
    rep(i,c)rep(j,n)rep(k,n){
        iwakan[i][(j+k)%3] += d[c2[j][k]-1][i];
    }
    rep(i,c) rep(j,c) rep(k,c){
        if(i == j || j == k ||k == i)continue;
        long long ans2 = iwakan[i][0]+iwakan[j][1]+iwakan[k][2];
        if(ans2 < ans)ans = ans2;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1280
#include <stdio.h>
int main () {
	char str[5];
	scanf ("%s", str);
	char t = str[0];
	for (int i=1; i<4; i++) {
		char t2 = str[i];
		if (t==t2) {
			printf ("Bad\n");
			return 0;
		}
		t = t2;
	}
	printf ("Good\n");
	return 0;
}


Measured memory_bytes: 128
// In the name of God

#include <iostream>
#include <algorithm>
#include <fstream>
#include <vector>
#include <deque>
#include <assert.h>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <stdio.h>
#include <string.h>
#include <utility>
#include <math.h>
#include <bitset>
#include <iomanip>
#include <complex>

using namespace std;

#define rep(i, a, b) for (int i = (a), i##_end_ = (b); i < i##_end_; ++i)
#define debug(...) fprintf(stderr, __VA_ARGS__)
#define mp make_pair
#define x first
#define y second
#define pb push_back
#define SZ(x) (int((x).size()))
#define ALL(x) (x).begin(), (x).end()

template<typename T> inline bool chkmin(T &a, const T &b) { return a > b ? a = b, 1 : 0; }
template<typename T> inline bool chkmax(T &a, const T &b) { return a < b ? a = b, 1 : 0; }
template<typename T> inline bool smin(T &a, const T &b)   { return a > b ? a = b : a;    }
template<typename T> inline bool smax(T &a, const T &b)   { return a < b ? a = b : a;    }

typedef long long LL;

const int N = (int) 0, mod = (int) 0;
int cnt[3];
int main() {
	string s;
	cin >> s;
	for (auto c : s) cnt[c - 'a']++;
	int mx = max(max(cnt[0], cnt[1]), cnt[2]);
	int mn = min(min(cnt[0], cnt[1]), cnt[2]);
	if (mx - mn <= 1) {
		cout << "YES\n";	
	} else {
		cout << "NO\n";
	}
}




Measured memory_bytes: 512
taro = 0
hanako = 0
n = int(input())
for _ in range(n):
    taro_card, hanako_card = input().split()
    if taro_card > hanako_card:
        taro += 3
    elif taro_card < hanako_card:
        hanako += 3
    else:
        taro += 1
        hanako += 1
print(taro, hanako)

Measured memory_bytes: 7664
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
	
//	static class AllocStatus {
//		int startIdx = 0;
//		int startWeight = 0;
//	}
	
	public static void main(String[] args) throws IOException {
		
		BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
		
		String[] inputs = reader.readLine().split(" ");
		int n = Integer.parseInt(inputs[0]);
		int k = Integer.parseInt(inputs[1]);
		
		int[] weights = new int[n];
		int capacity = 0;
		for (int i = 0; i < n; i++) {
			int weight = Integer.parseInt(reader.readLine());
			weights[i] = weight;
			capacity += weight;
		}

		capacity /= k;
//		AllocStatus allocStatus = new AllocStatus();
		while (true) {
			boolean canAllocate = checkAllocation(weights, k, capacity/*, allocStatus*/);
			if (canAllocate) {
				break;
			}
			capacity++;			
		}		
		System.out.println(capacity);		
	}

	private static boolean checkAllocation(int[] weights, int k, int capacity/*, AllocStatus allocStatus*/) {
		
		int num = 1;
//		int current = allocStatus.startWeight;
		int current = 0;

//		for (int i = allocStatus.startIdx; i < weights.length; i++) {
		for (int i = 0; i < weights.length; i++) {
			int weight = weights[i];
			if (current + weight > capacity) {
//				if (num == 1) {
//					allocStatus.startIdx = i;
//					allocStatus.startWeight = current;
//				}
				current = weight;
				num++;
				
				if (num > k || current > capacity) {
					return false;
				}
			} else {
				current += weight;
			}
		}
		return true;
	}
}



Measured memory_bytes: 35236
inputs = readlines
# inputs = "3\n200 200 200\n".split("\n")

n = inputs[0].to_i
as = inputs[1].split(' ').map(&:to_i)

def solve(n, as)
  asum = as.inject(0) do |sum, a|
    sum + (1.0 / a)
  end
  1.0 / asum
end

puts solve(n, as)


Measured memory_bytes: 1788
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
//template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
 
/* attention
    long longのシフト演算には気をつけよう
    タイポした時のデバッグが死ぬほどきつくなるので変数名は最低3字くらい使った方がいいかも
*/

int main(){
    int N, M; cin >> N >> M;
    map<int, int> mp;
    for(int i=0; i<N; i++){
        int k; cin >> k;
        for(int j=0; j<k; j++){
            int a; cin >> a;
            mp[a]++;
        }
    }

    int ans = 0;
    for(auto itr=mp.begin(); itr!=mp.end(); itr++) if(itr->second == N) ans++;

    cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
using namespace std;
typedef long long int ll;

int n;
string s;

int a[11][11][11];
int b[11][11][11];

int main(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
 	cin >> n >> s;
 	a[0][0][0]=1;
 	for(int i=0;i<n;i++){
 		for(int j=0;j<11;j++){
 			for(int k=0;k<11;k++){
 				for(int l=0;l<11;l++){
 					b[j][k][l]=a[j][k][l];
 				}
 			}
 		}
 		for(int j=0;j<11;j++){
 			for(int k=0;k<11;k++){
 				int l=s[i]-'0'+1;
 				if(j==0&&k>0)continue;
 				if(a[j][k][0]==0)continue;
 				if(k>0){
 					b[j][k][l]=1;
 				}
 				else if(k==0){
 					if(j>0){
 						b[j][l][0]=1;
 					}
 					else{
 						b[l][0][0]=1;
 					}
 				}
 			}
 		}
 		for(int j=0;j<11;j++){
 			for(int k=0;k<11;k++){
 				for(int l=0;l<11;l++){
 					a[j][k][l]=b[j][k][l];
 				}
 			}
 		}
 	}
 	int ans=0;
 	for(int i=1;i<11;i++){
 		for(int j=1;j<11;j++){
 			for(int k=1;k<11;k++){
 				if(a[i][j][k]){
 					ans++;
 				}
 			}
 		}
 	}
 	cout << ans << endl;
}

Measured memory_bytes: 384
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<stdint.h>
#include<malloc.h>
#include<math.h>
#include<x86intrin.h>


int my_gets(char *buf,int nBuf,FILE *fp){
    int ch;

    while(--nBuf >0){
        ch=getc(fp);
        if(ch==EOF || ch=='\n')
            break;
        *(buf++)=(char)ch;
    }
    *(buf)='\0';

    return nBuf;
}

void InputIntAry(int *a,int nDigit,int N){      //nDigitは想定される最大桁数
    char *buf,*ptr;

    buf=(char*)malloc( (N*(nDigit+2)) * sizeof(char) );
    my_gets(buf,N*(nDigit+2),stdin);

    ptr=strtok(buf," ");
    while(ptr!=NULL && N-->0){
        *(a++)=atoi(ptr);
        ptr=strtok(NULL," ");
    }
    free(buf);
}

int CmpInt(const void *a, const void *b){        //b-aを返す(qsortなら4321)
    return *((int*)b)- *((int*)a);
}

int main(){
    uint64_t N;

    scanf("%llu%*c",&N);
    printf("%llu\n", N*(N-1)/2);
    return 0;
} 


Measured memory_bytes: 128
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Diagnostics;
using System.IO;
using static System.Console;
using static System.Math;

class Program
{
    static void Main()
    {
        var c = new int[3, 3];
        for (int i = 0; i < 3; i++)
        {
            var inp = ReadLine().Split(' ');
            for (int j = 0; j < 3; j++)
            {
                c[i, j] = int.Parse(inp[j]);
            }
        }
        var b = true;
        if (c[1, 0] - c[0, 0] == c[1, 1] - c[0, 1] && c[1, 0] - c[0, 0] == c[1, 2] - c[0, 2]) { }
        else b = false;
        if (c[2, 0] - c[0, 0] == c[2, 1] - c[0, 1] && c[2, 0] - c[0, 0] == c[2, 2] - c[0, 2]) { }
        else b = false;
        if (c[0, 2] - c[0, 1] == c[1, 2] - c[1, 1] && c[0, 2] - c[0, 1] == c[2, 2] - c[2, 1]) { }
        else b = false;
        if (c[0, 1] - c[0, 0] == c[1, 1] - c[1, 0] && c[0, 1] - c[0, 0] == c[2, 1] - c[2, 0]) { }
        else b = false;
        if (b) WriteLine("Yes");
        else WriteLine("No");
    }
}

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

int main() {
    cin.tie(0), ios::sync_with_stdio(0);
    
    long long d,t,s;
    while(cin>>d>>t>>s){
        if(t*s>=d)cout<<"Yes"<<endl;
        else cout<<"No"<<endl;
    }
    
    return 0;
}

Measured memory_bytes: 3648
# https://atcoder.jp/contests/arc061/tasks/arc061_a
def solve(S):
    a = _iter(S, '')
    return a


def _iter(s, t):
    if s == '':
        if t.endswith('+'):
            return 0
        return eval(t)
    a = s[0]
    b = s[1:]
    return _iter(b, t+a) + _iter(b, t+a+'+')


if __name__ == '__main__':
    S = input()
    print(solve(S))


Measured memory_bytes: 3064
#include <iostream>
#include <algorithm>

int main()
{
	int n, a[110], sum = 0;
	std::cin >> n;

	for (int i = 0; i < n; ++i)
		std::cin >> a[i];

	std::sort(a, a + n);

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

	if (sum % 10 != 0)
	{
		std::cout << sum;
		return 0;
	}

	for (int i = 0; i < n; ++i)
		if ((sum - a[i]) % 10 != 0)
		{
			std::cout << sum - a[i];
			return 0;
		}

	std::cout << 0;

}

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

int main(){
    int n, m;
    cin >> n >> m;
    map<int,int> x[m];
    vector<int> cnt(m, 0);
    while(n-- > 0){
        int k;  cin >> k;
        x[k%m][k]++;
        cnt[k%m]++;
    }
    vector<int> pa(m, 0);
    int ans = 0;
    for(int i = 0; 2*i <= m; i++){
        if((i+i)%m == 0){
            pa[i] = cnt[i]/2;
            cnt[i] -= pa[i];    // 後の処理を楽にするために
        }else{
            pa[i] = pa[m-i] = min(cnt[i], cnt[m-i]);
        }
        ans += pa[i];
    }
    for(int i = 0; i < m; i++){
        int aff = (cnt[i]-pa[i])/2;
        for(auto p : x[i]){
            ans += min(aff, p.second/2);
            aff -= min(aff, p.second/2);
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 10368
#include <algorithm>
#include <cassert>
#include <climits>
#include <cstdio>
#include <deque>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <unordered_map>
#include <utility>
#include <vector>

using namespace std;

const int INF = 1e9;
const long long LINF = 1e18;
const double PI=3.14159265358979323846;

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

    int cnt = 0;
    for (int i = 0; i < S.size(); i++) {
        if (S[i] == '0') {
            ++cnt;
        } else {
            --cnt;
        }
    }

    cout << S.size() - abs(cnt) << endl;

    return 0;
}


Measured memory_bytes: 512
package main

import (
	"fmt"
)

func min(a, b int) int {
	if a > b {
		return b
	}
	return a
}

func main() {
	// Code for A - Divide a Cuboid
	var A, B, C int
	fmt.Scanf("%d %d %d", &A, &B, &C)

	if A%2 == 0 || B%2 == 0 || C%2 == 0 {
		fmt.Println("0")
	} else {
		fmt.Println(min(A*B, min(B*C, C*A)))
	}
}


Measured memory_bytes: 1832
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double D;
typedef pair<ll,ll> P;
#define M 1000000007
#define F first
#define S second
#define PB push_back
#define INF 100000000000000000
int n,k;
int main(void){
    
    cin>>n>>k;
    cout<<n-k+1<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include<bits/stdc++.h>
#define ll long long int
#define lld long double
#define F first
#define S second
#define f(i,a,b) for(int i=a;i<=b;i++)
#define g(i,a,b) for(int i=a;i>=b;i--)
#define pb push_back
#define mh make_heap
#define ph push_heap
#define pq priority_queue
#define bits(x) __builtin_popcountll(x)
#define op(x) cout<<"Case #"<<x<<": "
#define op1(x) cout<<"Scenario #"<<x<<": "
#define endl "\n"
using namespace std;
const ll mod = 1000000007;
const ll INF = LLONG_MAX;
const ll NEGINF = LLONG_MIN;
const int N = 18;
const ll MAXN = 1000001;





void solve(int t)
{

	ll n, x, m;

	cin >> n >> x >> m;
	map<ll, ll> mp;

	ll d = x;
	vector<ll> v;
	while (true)
	{
		d %= m;
		if (mp[d] > 0) break;
		v.pb(d);
		mp[d]++;
		d = (d * d);
	}

	//cout << d << endl;

	ll idx = 0;

	ll k = 0;
	for (auto i : v)
	{
		if (i == d) { idx = k; break; }
		k++;
	}

	//cout << idx << " " << v[idx] << " " << d << endl;

	ll sum = 0;

	for (int i = 0; i < min(n, (ll)v.size()); i++) sum += v[i];
	ll sz = v.size();




	if (n > sz)
	{
		n -= sz;
		vector<ll> vv;
		ll ss = 0;
		for (int i = idx; i < v.size(); i++)
		{
			ss += v[i];
			vv.pb(ss);
		}

		ll z = vv.size();
		sum += (n / z) * ss;
		if (n % z != 0)
			sum += vv[n % z - 1];
	}

	cout << sum << endl;


}



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





	int t = 1;
	//cin >> t;



	for (int i = 1; i <= t; i++)
	{
		solve(i);

	}
}

Measured memory_bytes: 7408
#include <iostream>
using namespace std;
int main(){
	string s;
	while(getline(cin,s)){
		string ans="";
		if(s=="END OF INPUT")break;
		if(s==""){ans="0";break;}
		bool backsp = true;
		int count = 0;
		for(int i=0;i<s.size();++i){
			if(('A'<=s[i]&&s[i]<='Z')||('a'<=s[i]&&s[i]<='z')){
				if(backsp){
					backsp=false;
					count=1;
				}else{
					count++;
				}
				if(i==s.size()-1)ans+=('0'+count);
			}else if(s[i]==0x20){
				if(!backsp){
					backsp=true;
					ans+=('0'+count);
				}else{
					ans+="0";
				}
			}
		}
		cout<<ans<<"\n";
	}
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
int main() {
  int n,m,max=0,sum=0;
  cin >> n;
  vector<string> blue(n);
  for(int i=0;i<n;i++){
    cin >> blue.at(i);
  }
  cin >> m;
    vector<string> red(m);
  for(int i=0;i<m;i++){
    cin >> red.at(i);
  }
  for(int i=0;i<n;i++){
    sum=0;
    string word = blue.at(i);
    for(int j=0;j<n;j++){
      if(blue.at(j)==word)
        sum++;
    }
    for(int j=0;j<m;j++){
      if(red.at(j)==word)
        sum--;
    }
    if(sum>max)
      max=sum;
  }
  cout << max << endl;
}

Measured memory_bytes: 3576
#include <iostream>
#include <vector>
using namespace std;
long long getDist(long long A,long B,long long C,long long D)
{
	long long d1,d2;
	d1=A-C;
	if (d1<0){
		d1=-d1;
	}
	d2=B-D;
	if (d2<0){
		d2=-d2;
	}
	return d1+d2;
}
int main(int argc, char* argv[])
{
	int N,M;
	cin>>N>>M;
	vector<long long> A(N,0),B(N,0),C(M,0),D(M,0);
	int i,j;
	for (i=0;i<N;i++){
		cin>>A[i]>>B[i];
	}
	for (j=0;j<M;j++){
		cin>>C[j]>>D[j];
	}
	int minJ=1;
	long long minDist;
	long long dist;
	for (i=0;i<N;i++){
		minDist=1e+9;
		for (j=0;j<M;j++){
			dist=getDist(A[i],B[i],C[j],D[j]);
			if (minDist>dist){
				minDist=dist;
				minJ=j+1;
			}
		}
		cout<<minJ<<endl;
	}

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
int main() {
  int n,m=0;
  cin >> n;
  int a[n+1],b[n+1];
  rep(i,n)
  cin>>a[i+1];
  for(int i=n;i>0;i--){
     int f=a[i];
     for(int j=i+i;j<=n;j+=i)
       if(b[j])
         f^=1;
     m+=f;
     b[i]=f; 
  }
  cout<<m<<endl;
  if(m)
    rep(i,n)
    if(b[i+1])
      cout<<i+1<<" ";
  return 0;
}

Measured memory_bytes: 2432
#include<cstring>
#include<string>
#include<vector>
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<stack>
#include<queue>
#include<cmath>
#include<algorithm>
#include<list>
#include<set>
#include<map>
#include<complex>
#include<sstream>
#include<climits>
#define rep(X,Y) for (int (X) = 0;(X) < (Y);++(X))
#define rrep(X,Y) for (int (X) = (Y)-1;(X) >=0;--(X))
#define all(X) (X).begin(),(X).end()
#define pb push_back
#define mp make_pair
#define fi first
#define sc second
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};

int main() {
  string s;
  cin >> s;

  ll ans = 0;
  int sl = s.length();
  for (int i = 0; i < 1 << (sl-1); ++i) {
    ll t = 0;
    for (int k = 0; k < sl; ++k) {
      if (k == sl-1) {
        t *= 10;
        t += s[k]-'0';
        ans += t;
      } else if (i & 1 << k) {
        t *= 10;
        t += s[k]-'0';
        ans += t;
        t = 0;
      } else {
        t *= 10;
        t += s[k]-'0';
      }
    }
  }

  cout << ans << endl;

  return 0;
}


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

int main() {
	int x;
	int count=0;
	cin >> x;
	int n[20];
	for (int i = 0; i < x; i++) cin >> n[i];
	for (int i = 0; i < x-2; i++) {
		if (n[i] < n[i + 1] && n[i + 1] < n[i + 2]) count++;
		if (n[i] > n[i + 1] && n[i + 1] > n[i + 2])count++;
	}
	cout << count << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<math.h>
#include<queue>
#include<deque>
#include<stack>
#include<cstdio>
#include<utility>
#include<set>
#include<list>
#include<cmath>
#include<stdio.h>
#include<string.h>
#include<iomanip>
#include<cstdio>
#include<cstdlib>
#include<cstring>
using namespace std;
#define FOR(i, a, b) for (ll i = (a); i <= (b); i++)
#define REP(i, n) FOR(i, 0, n - 1)
#define NREP(i, n) FOR(i, 1, n)
using ll = long long;
using pii = pair<int, int>;
using piii = pair<pii, pii>;
const ll dx[4] = { 0, -1, 1, 0 };
const ll dy[4] = { -1, 0, 0, 1 };
const int INF = 1e9 + 7;
int gcd(int x, int y) {
	if (x < y)swap(x, y);
	if (y == 0)return x;
	return gcd(y, x%y);
}
void mul(ll a, ll b) {
	a = a * b % INF;
}
using Graph = vector<vector<int>>;
ll mypow(ll x, ll n, ll m) {
	if (n == 0) {
		return 1;
	}
	if (n % 2 == 0) {
		return mypow(x*x%m, n / 2, m);
	}
	else {
		return x * mypow(x, n - 1, m) % m;
	}
}
long long modinv(long long a, long long m) {
	long long b = m, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}
const int MAX = 510000;
ll fac[MAX], finv[MAX], inv[MAX];
//テーブルをつくる前処理
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;//mod pにおける1,2,,,nの逆元
	for (int i = 2; i < MAX; ++i) {
		fac[i] = fac[i - 1] * i%INF;
		inv[i] = INF - inv[INF%i] * (INF / i) % INF;
		finv[i] = finv[i - 1] * inv[i] % INF;
	}
}

ll COM(int n, int k) {
	if (n < k)return 0;
	if (n < 0 || k < 0)return 0;
	return fac[n] * (finv[k] * finv[n - k] % INF) % INF;
}
///////////////////////////////////////


int main() {
	int k; cin >> k;
	int sum = 0;
	for (int i = 1; i <= k; ++i) {
		for (int j = 1; j <= k; ++j) {
			for (int l = 1; l <= k; ++l) {
				sum += gcd(i, gcd(j, l));
			}
		}
	}
	cout << sum << endl;
	return 0;
}


Measured memory_bytes: 3640
#include <bits/stdc++.h>
#define int long long
#define ALL(v) (v).begin(),(v).end()
#define Vi vector<int>
#define pb push_back
#define rep(i,a,b) for(int i=a;i<b;i++)
#define repeq(i,a,b) for(int i=a;i<=b;i++)
#define repr(i,a,b) for(int i=a;i>b;i--)
#define repreq(i,a,b) for(int i=a;i>=b;i--)
#define leng(n) (int)(log10(n)+1)
#define INF 9000000000000000000
#define MOD 1000000007
#define PAI 3.14159265358979
// ver1.6
using namespace std;

int gcd(int a,int b){return b?gcd(b,a%b):a;}  //  最大公約数gcd
int lcm(int a,int b){return a/gcd(a,b)*b;}  //  最小公倍数lcm

signed main() {
  cout << fixed << setprecision(14);
  int n,m;
  cin >> n >> m;
  int pre,now,sum,ans = 0;
  cin >> now;
  
  rep(i,0,n-1){
    
    pre = now;
    cin >> now;
    sum = pre + now;
    
    if(sum > m){
      
      if(sum-m >= now){
        ans += sum - m;
        now = 0;
      }
      
      else {
        ans += sum - m;
        now -= sum - m;
      }
    }
    
  }
//  cout << pre << ' ' << now << endl;
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.Comparator;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Main main = new Main();
        main.solve();
    }
    public void solve() {
        Scanner scan = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        int N = scan.nextInt();
        int M = scan.nextInt();
        Shop[] shoplist = new Shop[N];
        for (int i = 0; i < N; i++) {
            Shop shop = new Shop();
            shop.A = scan.nextInt();
            shop.B = scan.nextInt();
            shoplist[i] = shop;
        }
        Arrays.sort(shoplist, new ShopComparator());
        long answer = 0;
        int remain = M;
        for (int i = 0; i < N && 0 < remain; i++) {
            int number = Math.min(remain, shoplist[i].B);
            remain -= number;
            answer += (long) number * (long) shoplist[i].A;
        }
        System.out.println(answer);
    }
    class Shop {
        int A = 0;
        int B = 0;
    }
    class ShopComparator implements Comparator<Shop> {

        @Override
        public int compare(Shop o1, Shop o2) {
            if (o1.A < o2.A) {
                return -1;
            }
            if (o1.A > o2.A) {
                return 1;
            }
            return -Integer.compare(o1.B, o2.B);
        }
    }
}


Measured memory_bytes: 83080
[N, L] = [int(i) for i in input().split()]

apples = []

m = abs(L)
ind = 0

for i in range(N):
    apples.append(L+i)
    if m > abs(L+i):
        m = abs(L+i)
        ind = i
        
apples.remove(apples[ind])

print(sum(apples))


Measured memory_bytes: 3060
#include <stdio.h>

int main()
{
    int a, b;
    char op = '+';
    while (op != '?')
    {
        scanf ("%d %c %d", &a, &op, &b);
        if (op == '+')
        {
            printf("%d\n", a + b);
        }
        else if (op == '-')
        {
            printf("%d\n", a - b);
        }
        else if (op == '*')
        {
            printf("%d\n", a * b);
        }
        else if (op == '/')
        {
            printf("%d\n", a / b);
        }
        else
        {
            break;
        }
    }
}


Measured memory_bytes: 2052
#include<stdio.h>
int main(){
  int n,i,a=0;
  char x;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%c",&x);
    if(x=='Y'){a=1;}
  }
  if(a==0){printf("Three\n");}
  else{printf("Four\n");}
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
 
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 (a>b) { a=b; return 1; } return 0; }
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)

int main(){
  string s,t;cin>>s>>t;
  int q;cin>>q;
  int sa[(int)s.size()+1]={};
  int ta[(int)t.size()+1]={};
  rep(i,s.size()){
    sa[i+1]=sa[i]+(s[i]=='A'?1:2);
  }
  rep(i,t.size()){
    ta[i+1]=ta[i]+(t[i]=='A'?1:2);
  }
  rep(i,q){
    int a,b,c,d;cin>>a>>b>>c>>d;
    if((sa[b]-sa[a-1])%3==(ta[d]-ta[c-1])%3)cout<<"YES"<<endl;
    else cout<<"NO"<<endl;
  }
}
  

Measured memory_bytes: 1664
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;

#define repr(i, n) for(int i = n; i >= 0; i--)
#define reprl(i, n) for(ll i = n; i >= 0; i--)
#define all(v) v.begin(), v.end()

const ll mod=1000000007;

int countBits(int in){
  int res=0;
  for(int i=0;i<10;i++){
    int msk=1<<i;
    if((in&msk)!=0){
      res++;
    }
  }
  return res;
}

template<typename T>
void show2dVector(vector<vector<T>>& v){
  for(int i=0;i<v.size();i++){
    int m=v[i].size();
    cout<<i<<" : ";
    for(int j=0;i<m;i++){
      cout<<v[i][j]<<" ";
    }
    cout<<endl;
  }
}

void bfs(const vector<vector<int>>&g, int v, vector<bool>& seen){
  seen[v]=true;
  cout<<v<<" ";
  for(auto next: g[v]){
    if(seen[next]){
      continue;
    }
    bfs(g,next,seen);
  }
}

bool dfs(vector<vector<int>> &g,int start,int goal,vector<bool>&seen){
  bool res=false;
  seen[start]=true;
  if(start==goal){
    return true;
  }
  for(auto next: g[start]){
    if(seen[next]){
      continue;
    }
    res=dfs(g,next,goal,seen);
    if(res){
      break;
    }
  }
  return res;
}

ll gcd(ll a,ll b) {
  return b? gcd(b,a%b): a;  
}
ll lcm(ll a,ll b) {
  return a*b/gcd(a,b);
}
bool isLowerCase(char c){
  return (c>='a'&&c<='z');
}
const string outputYesNo(bool ans){
  return (ans?"Yes":"No");
}
int main() {
  int x;cin>>x;
  string ans;
  if(x<1200)ans="ABC";
  else ans="ARC";
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
#define Rep(i,n) for(int i=0;i<n;i++)
#define For(i,n1,n2) for(int i=n1;i<n2;i++)
#define REP(i,n) for(ll i=0;i<n;i++)
#define FOR(i,n1,n2) for(ll i=n1;i<n2;i++)
#define put(a) cout<<a<<endl;
#define all(a)  (a).begin(),(a).end()
#define SORT(c) sort((c).begin(),(c).end())
#define TDARRAY(int,a,n,m) vector<vector<int>> a(n,vector<int>(m,0));
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
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 n;
string a,b,c;

int main() {
    cin >> n >> a >> b >> c;
    int res = 0;
    REP(i,n){
        if(a[i]==b[i]){
            if(b[i]==c[i]){
                
            }else{
                res += 1;
            }
        }else{
            if(a[i]==c[i]){
                res+=1;
            }else{
                if(b[i]==c[i]){
                    res+=1;
                }else{
                    res+=2;
                }
            }
        }
    }
    put(res);
    return 0;
}




Measured memory_bytes: 256
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int h,w;
		while(true) {
			h=scan.nextInt();
			w=scan.nextInt();
			if(h==0&&w==0)break;
			int icheck=1,j_check;
			for(int i=0;i<h;i++) {
				j_check=icheck;
				for(int j=0;j<w;j++) {
					if(j_check==0) {
						System.out.print(".");
						j_check=1;
					}else {
						System.out.print("#");
						j_check=0;
					}
				}
				if(icheck==1)icheck=0;
				else icheck=1;
				System.out.println();
			}
			System.out.println();
		}
		scan.close();
	}

}


Measured memory_bytes: 34460
//g++ -std=c++14 test.cpp -o test.out
//問題URL
//https://atcoder.jp/contests/abc154/tasks/abc154_e

#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iostream>
#include <iomanip>
#include <vector>
#include <queue>
#include <map> 
#include <unordered_map> 
#include <utility>
#include <limits.h>
#include <bitset>
#include <set>
using namespace std;
 
#define LL long long int
const LL INF = (1LL<<60);
const int INF_INT = 2147483647-1e6-1;
const LL mod = 1000000007ll;
const int mod_int = 1000000007;

LL A,B,C,K;

LL ans = 0;

void solve(){
	if(K>=A){
		ans += A;
		K -= A;
	}else{
		ans += K;
		return;
	}

	K -= B;
	if(K<=0) return;
	ans -= K;
}

int main(){
    cin >> A >> B >> C >> K;

    solve();

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

Measured memory_bytes: 3164
n = int(input())
l = ["a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z"]
answer = []
while n >= 1:
    n -= 1
    answer.append(l[n % 26])
    n = n//26
ans = ''.join(list(reversed(answer)))
print(ans)

Measured memory_bytes: 9204
#include <iostream>
#include <vector>
#include <string>
#include <sstream>
#include <algorithm>
#include <map>
#include <set>
#include <cstdio>
#include <cmath>
#define rep(i,l,n) for(lint i=l;i<n;i++)
#define rer(i,l,n) for(lint i=l;i<=n;i++)
#define all(a) a.begin(),a.end()
#define o(a) cout<<a<<endl
#define pb(a) push_back(a)
#define mk(a,b) make_pair(a,b)
#define fi first
#define se second
using namespace std;
typedef long long lint;
typedef vector<int> vi;
typedef vector<lint> vli;
typedef vector<vi> vvi;
typedef pair<int,int> pii;

int main(){
	int n,m,f=-1;
	cin>>n;
	set<string> str;
	string u,t;
	rep(i,0,n){
		cin>>u;
		str.insert(u);
	}
	cin>>m;
	rep(i,0,m){
		cin>>t;
		if(str.count(t)){
			cout<<(f==-1?"Opened by ":"Closed by ");
			cout<<t<<endl;
			f*=-1;
		}else{
			cout<<"Unknown "<<t<<endl;
		}
	}
}
/*
int main(){
	int n,m,f=-1;
	cin>>n;
	vector<string> u(n);
	string t;
	rep(i,0,n) cin>>u[i];
	cin>>m;
	sort(all(u));
	rep(i,0,m){
		cin>>t;
		if(binary_search(all(u),t)){
			cout<<(f==-1?"Opened by ":"Closed by ");
			cout<<t<<endl;
			f*=-1;
		}else{
			cout<<"Unknown "<<t<<endl;
		}
	}
}*/

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

#define fi first
#define se second
#define pb push_back
#define sz(a) (int)(a).size()
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;

const ll MOD = 1e9 + 7;
const ll INF = 1e18;
const ll IINF = INT_MAX;

bool eval(vector<pii> pos, vector<pii> neg) {
    int bal = 0;
    for (auto& u: pos) {
        bal -= u.fi;
        if (bal < 0) return false;
        bal += u.se;
    }
    for (auto& u: neg) {
        bal -= u.fi;
        if (bal < 0) return false;
        bal += u.se;
    }
    return bal == 0;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int n;
    cin >> n;
    vector<pii> pos, neg;
    for (int i = 0; i < n; i++) {
        string s;
        cin >> s;
        string kompres;
        for (char c: s) {
            if (c == '(') {
                kompres.pb('(');
            } else {
                if (kompres.size() && kompres.back() == '(') kompres.pop_back();
                else kompres.pb(')');
            }
        }
        int tutup = 0;
        for (char c: kompres) {
            if (c == '(') break;
            tutup++;
        }
        int buka = kompres.size() - tutup;
        if (tutup < buka) {
            pos.pb({tutup, buka});
        } else {
            neg.pb({tutup, buka});
        }
    }
    sort(pos.begin(), pos.end(), [](const pii& a, const pii& b) {
        return a.fi < b.fi || (a.fi == b.fi && a.se > b.se);
    });
    sort(neg.begin(), neg.end(), [](const pii& a, const pii& b) {
        return a.se > b.se || (a.se == b.se && a.fi < b.fi);
    });
    cout << (eval(pos, neg) ? "Yes" : "No") << '\n';
    return 0;
}

Measured memory_bytes: 18960
#include <bits/stdc++.h>
using namespace std;
#define MAX 1000000
#define INF INT_MAX
#define LL long long
#define ULL unsigned LL
#define EPS 0.00000001
#define PI acos(-1.0)
#define MOD 100000007LL
#define pii pair<int,int>
#define pll pair<LL,LL>
#define ck(XX) cout<<XX<<endl
#define Set(XX,PS) XX|(1<<PS)
#define Reset(XX,PS) XX&(~(1<<PS))
#define Toggle(XX,PS) (XX^(1<<PS))
#define Check(XX,PS) (bool)(XX&(1<<PS))
#define SORT(v) sort(v.begin(),v.end())
#define REVERSE(V) reverse(v.begin(),v.end())
#define Fin freopen("input.txt","r",stdin)
#define Fout freopen("output.txt","w",stdout)
#define VALID(X,Y,R,C) X>=0 && X<R && Y>=0 && Y<C
#define SIZE(ARRAY) sizeof(ARRAY)/sizeof(ARRAY[0])
#define MS(ARRAY,VALUE) memset(ARRAY,VALUE,sizeof(ARRAY))
#define FAST ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define RT printf("Run Time : %0.3lf seconds\n", clock()/(CLOCKS_PER_SEC*1.0))
#define ck2(XX,YY) cout<<XX<<"->"<<YY<<endl

int main()
{
    FAST;
    int n;
    cin >> n;
    
    if(n>=1 && n<=999) cout<<"ABC\n";
    else cout<<"ABD\n";

    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		int r, c, i, j;
		try (Scanner sc = new Scanner(System.in)) {
			r = sc.nextInt();
			c = sc.nextInt();
			int pict[][] = new int[r + 1][c + 1]; //表の配列
			for(i = 0; i < r; i++) {
				for(j = 0; j < c; j++) {
					pict[i][j] = sc.nextInt();
					pict[r][j] += pict[i][j];
					pict[i][c] += pict[i][j];
					pict[r][c] += pict[i][j];
				}
			}
			for(i = 0; i < r + 1; i++) {
				for(j = 0; j < c + 1; j++) {
					System.out.print(pict[i][j]);
					if(j < c){
					    System.out.print(" ");
					}
				}
				System.out.println();
			}
		}
	}
}



Measured memory_bytes: 41316
#include <bits/stdc++.h>
 
using namespace std;
 
 
int main(){
 
 int a,b;
 cin>>a>>b;
 
  for(int i=1;i<=1e4;i++){
 
    int a2 = i*0.08;
    int b2 = i*0.1;
    if(a2 == a && b2 == b){
        cout<<i<<endl;
        return 0; }
  }
 
 cout<<"-1"<<endl;
 
return 0;
}

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

int main(void)
{
    int a,b,c;
    scanf("%d %d",&a,&b);
    c=a*b;
    if(c%2==0)
        printf("Even");
    else
        printf("Odd");
    return 0;
}


Measured memory_bytes: 128
#include <stdio.h>

int main(void)
{
	char a,b,c,d,e,f;
	
	scanf("%c%c%c\n%c%c%c",&a,&b,&c,&d,&e,&f);

	if(a==f&&c==d&&b==e){
		printf("YES\n");
	}else{
		printf("NO\n");
	}
	
	return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<string>
#include<cmath>
#include<map>
#include<stack>
#include<vector>
#include<queue>
#include<set>
#include<algorithm>
#define INF 0x3f3f3f3f
#define mod 1000000009
#define e  2.718281828459045
#define eps 1.0e18
#define PI acos(-1)
#define lowbit(x) (x&(-x))
#define memset(x,y) memset(x,y,sizeof(x))
#define lson i << 1,l,m
#define rson i << 1 | 1,m + 1,r
#define ll long long
using namespace std;
map <ll,int> mp;
int main(){
	ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	//freopen("text1.in","r",stdin);
	//freopen("text1.out","w",stdout);
	ll n;
	cin>>n;
	ll sum=(1+n)*n/2;
	vector <ll> v1;
	ll a=3;
	while(a<=n){
		mp[a]=1;
		sum-=a;
		a=a+3;
	}
	a=5;
	while(a<=n){
		if(!mp[a]) 
		sum-=a;
		a+=5;
	}
	cout<<sum<<endl;
	return 0;
}


Measured memory_bytes: 32784
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            string s = Console.ReadLine();
            string t = Console.ReadLine();
            string[] sList = new string[s.Length];
            string[] tList = new string[t.Length];
            for(int i = 0; i < s.Length; i++)
            {
                sList[i] = s.Substring(i, 1);
            }
            for (int i = 0; i < t.Length; i++)
            {
                tList[i] = t.Substring(i, 1);
            }
            Array.Sort(sList);
            Array.Sort(tList);
            Array.Reverse(tList);

            int len = Math.Min(s.Length, t.Length);

            string ans = "No";
            for(int i = 0;i < len; i++)
            {
                if(sList[i].CompareTo(tList[i]) == -1)
                {
                    ans = "Yes";
                    break;
                }
                else if(sList[i].CompareTo(tList[i]) == 0 && len -1 == i && s.Length < t.Length)
                {
                    ans = "Yes";
                }
            }
            Console.WriteLine(ans);
        }
    }
}
// 文字列の入力
//string s = Console.ReadLine();

// 整数の入力
//long n = long.Parse(Console.ReadLine());

// 文字列配列の入力
//string[] inputStrArray = Console.ReadLine().Split(' ');

// 整数配列の入力
//long[] inputLongArray = Console.ReadLine().Split(' ').Select(i => long.Parse(i)).ToArray();

//Console.WriteLine(ans);

Measured memory_bytes: 25928
#include<iostream>
#include<sstream>
#include<string>
using namespace std;
int main(){
  string s;
  int id,k,i;
  int d[1005][2]={};
  while(getline(cin,s),s!=""){
    for(i=0;i<s.size();i++) if(s[i]==',') s[i]=' ';
    stringstream ss(s);
    ss>>id>>k;
    d[id][0]++;
  }
  while(getline(cin,s),s!=""){
    for(i=0;i<s.size();i++) if(s[i]==',') s[i]=' ';
    stringstream ss(s);
    ss>>id>>k;
    d[id][1]++;
  }
  for(i=0;i<1005;i++){
    if(d[i][0]>0&&d[i][1]>0) cout << i << " " << d[i][0]+d[i][1] << endl;
  }
}

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

    deque<int> cnt(26, 0);
    rep(i, s.length())
    {
        cnt[s[i] - 'a']++;
    }
    rep(i, 26)
    {
        // cout << cnt[i] << endl;
        if (cnt[i] % 2 != 0)
        {
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;	
 
	int main(){
		int goke;
		int hon;
		int count=0;

	while(1){
		if(count==0){
		cin>>goke;
		if(goke==0){
		break;
		}
	count++; 
		}else{
		cin>>hon;
		goke-=hon;
		count++;
		}
		if(count==10){
		cout<<goke<<'\n';
		count=0;
		}
	}
	return 0;
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
typedef long long ll;
typedef long double ld;
using namespace std;

const ll infll=9223372036854775806;
const int inf=2147483646;

int main()
{
	//freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
	ios_base::sync_with_stdio(false); cin.tie(0);
	char a;
	cin>>a;
	if (a=='A'){
		cout<<"T";
	}
	else if (a=='T'){
		cout<<"A";
	}
	else if (a=='G'){
		cout<<"C";
	}
	else {
		cout<<"G";
	}
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cmath>
#include <string>
#include <algorithm>
using namespace std;
#define mp  std::make_pair
#define ll long long int
#define abs(n) ((n>0)?(n):((n)*(-1)))
#define FOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n) FOR(i,0,(n)-1)
#define VREP(v) for(std::vector<ll>::iterator itr = (v).begin(); itr != (v).end();itr++)
#define VALL(v) ((v).begin(),(v).end())
#define errln(v) cerr << (v) << endl;
#define println(v) cout << (v) << endl;

int main(int argc, const char * argv[]) {
	int N,h[100010],dp[100010];
	cin >> N;
	REP(i,N) cin >> h[i];

	dp[0] = 0;
	dp[1] = abs(h[1]-h[0]);
	for (int i = 2; i < N; ++i) {
		dp[i] = min(dp[i-2]+abs(h[i]-h[i-2]),
				dp[i-1]+abs(h[i]-h[i-1]));
	}
	println(dp[N-1]);
}


Measured memory_bytes: 1024
#-*-coding:utf-8-*-
import sys
input=sys.stdin.readline

def main():
    a,b = map(int,input().split())
    if a == 0 or b ==0 or (a<0 and b>0):
        print("Zero")
        exit()
    else:
        if a > 0 and b > 0:
            print("Positive")
        elif abs(a-b)%2!=0:
            print("Positive")
        else:
            print("Negative")

if __name__=="__main__":
    main()

Measured memory_bytes: 9056
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <cmath>
#include <iomanip>
#include <complex>
#include <set>
using namespace std;
#define REP(i,n) for (int i=0;i<(n);++i)
#define rep(i,a,b) for(int i=a;i<(b);++i)
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;}
using ll = long long;
constexpr long long INF = 1LL << 62;
constexpr int MOD = 1e9 + 7;

struct RollingHash {
    vector<unsigned long long> hash, power;
    const unsigned int seed = 10007, mod  = 1e9 + 7;

    RollingHash(const string &s) {
        int n = (int)s.size();
        hash.assign( n + 1, 0);
        power.assign(n + 1, 1);
        for(int i = 0; i < n; ++i) power[i+1] = power[i] * seed % mod;

        for(int i = 0; i < n; ++i) {
            hash[i+1]  = (hash[i] * seed + s[i]) % mod;
            power[i+1] = power[i] * seed % mod;
        }
    }

    // [l, r)
    unsigned long long get_hash(int l, int r) {
        unsigned long long ret = (hash[r] - hash[l] * power[r-l] % mod + mod) % mod;
        return ret;
    }
};

int main() {
    cin.tie(0); ios_base::sync_with_stdio(false);
    string s,t; cin >> s >> t;
    RollingHash rh1(s), rh2(t);
    unsigned long long thash = rh2.get_hash(0, t.size());
    for(int i=0; i < s.size(); ++i) 
        if(rh1.get_hash(i, i + t.size()) == thash) cout << i << '\n';
    return 0;
}



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

int main(){
  string str;
  cin>>str;
  int n,s,e,w;
  n=s=e=w=0;
  for(int i=0;i<str.size();i++){
    if(str[i]=='N') n++;
    if(str[i]=='S') s++;
    if(str[i]=='E') e++;
    if(str[i]=='W') w++;
  }
  if((n&&!s)||(!n&&s)||(e&&!w)||(!e&&w))cout<<"No"<<endl;
  else cout <<"Yes"<<endl;

  return 0;
}


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

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

	int N;
	int p[60], a[60];
	cin >> N;
	for (int i = 0; i < N; i++) {
		cin >> p[i];
		a[i] = p[i];
	}
	sort(a, a + N);
	int sum = 0;
	for (int i = 0; i < N; i++) {
		if (a[i] != p[i]) {
			sum++;
		}
	}
	if (sum < 3) {
		cout << "YES";
	}
	else cout << "NO";
}

Measured memory_bytes: 256
A,B,Q=gets.split.map(&:to_i)
INF = 10**22
s,t=[-INF],[-INF]
ans = []
A.times do
  s << gets.to_i
end
B.times do
  t << gets.to_i
end
s << INF
t << INF
Q.times do
  x = gets.to_i
  a = s.bsearch_index{|pos| x <= pos}.to_i
  b = t.bsearch_index{|pos| x <= pos}.to_i
  res = INF
  [s[a-1], s[a]].each do |si|
    [t[b-1], t[b]].each do |ti|
      d1 = (si-x).abs + (si-ti).abs
      d2 = (ti-x).abs + (si-ti).abs
      res = d1 if d1 < res
      res = d2 if d2 < res
    end
  end
  ans << res
end
puts ans


Measured memory_bytes: 5684
#include <bits/stdc++.h>
#define X first
#define Y second
#define sz(x) (int)x.size()
#define all(x) x.begin(), x.end()
#define ini(x, y) memset(x, y, sizeof(x))
#define endl '\n'
#define fastio cin.sync_with_stdio(false); cin.tie(nullptr)
using namespace std;

using ll = long long;
using pii = pair<int, int>;
const int MOD = 1e9 + 7;
const int dx[] = { -1, 0, 1, 0, -1, 1, 1, -1 };
const int dy[] = { 0, 1, 0, -1, 1, 1, -1, -1 };

int main() {
	fastio;
	int arr[3];
	for (int i = 0; i < 3; ++i) cin >> arr[i];

	sort(arr, arr + 3);

	if (arr[0] == arr[2]) cout << "No";
	else if (arr[0] == arr[1] || arr[1] == arr[2]) cout << "Yes";
	else cout << "No";

	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>

using namespace std;

string IsOpen(int& a, int& b, int& c){
  if((a == 1 && b == 1 && c == 0) ||
     (a == 0 && b == 0 && c == 1)) return "Open";
  else return "Close";
}

int main(){
  int a, b, c;
  cin >> a >> b >> c;
  cout << IsOpen(a, b, c) << endl;
  return 0;
}

Measured memory_bytes: 1192