akhauriyash/Code-Regression huggingface dataset:
//------------------------------------------
// C++ templete 
//------------------------------------------
#include <bits/stdc++.h>
#include <iomanip>
using namespace std;
using ll = long long;

#define endl "\n"

//typedef
//------------------------------------------
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef vector<PII> VP;

//REPEAT
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

//container util
//------------------------------------------
#define pb push_back
#define paired make_pair
#define ALL(a) (a).begin(),(a).end()
#define PRINT(V) for (auto v : (V)) cout << v << " "
#define SORT(V) sort((V).begin(),(V).end())
#define RSORT(V) sort((V).rbegin(), (V).rend())

//constant
//------------------------------------------
const int MOD = 1000000007;
const int INF = 1061109567;
const double EPS = 1e-10;
const double PI  = acos(-1.0);
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

//math
//------------------------------------------
int QP(int a,int b){int ans=1;do{if(b&1)ans=1ll*ans*a%MOD;a=1ll*a*a%MOD;}while(b>>=1);return ans;}
int QP(int a,int b,int MOD){int ans=1;do{if(b&1)ans=1ll*ans*a%MOD;a=1ll*a*a%MOD;}while(b>>=1);return ans;}
int GCD(int a,int b){return b?GCD(b,a%b):a;}

//debug
//------------------------------------------
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

//動的計画法で役に立つ関数
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

//最大公約数と最小公倍数
ll gcd(ll a, ll b) {
    if(b==0)return a;
    return gcd(b, a%b);
}

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

vector<vector<long long> > comb(int n) {
  vector<vector<long long> > v(n + 1,vector<long long>(n + 1, 0));
  for (int i = 0; i < v.size(); i++) {
    v[i][0] = 1;
    v[i][i] = 1;
  }
  for (int j = 1; j < v.size(); j++) {
    for (int k = 1; k < j; k++) {
      v[j][k] = (v[j - 1][k - 1] + v[j - 1][k]);
    }
  }
  return v;
}

int main() 
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    
    ll N; cin >> N; 
    vector<ll> T(5);

    cin >> T[0] >> T[1] >> T[2] >> T[3] >> T[4];
    
    SORT(T);

    cout << 4 + (N+T[0]-1) / T[0] << endl;
  
    return 0;
}



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

typedef string::const_iterator State;
class ParseError{};

string s;
int P, Q, R;

int formula( State & );
int factor( State & );

int main() {
    while ( cin >> s, s != "." ) {
        int ans = 0;
        rep ( i, 3 ) rep ( j, 3 ) rep ( k, 3 ) {
            P = i, Q = j, R = k;
            State begin = s.begin();
            int tmp = formula( begin );
            ans += (tmp == 2);
        }
        cout << ans << endl;
    }
    return 0;
}


int factor( State & begin ) {
    if ( *begin == '(' ) {
        begin++;
        int ret = formula( begin );
        begin++;
        return ret;
    }
    else if ( *begin == '-' ) {
        begin++;
        return ( 2 - factor( begin ) );
    }
    else {
        int ret = 0;
        if ( '0' <= *begin && *begin <= '2' ) {
            ret = *begin - '0';
            begin++;
        }
        else if ( 'P' <= *begin && *begin <= 'R' ) {
            if ( *begin == 'P' ) ret = P;
            if ( *begin == 'Q' ) ret = Q;
            if ( *begin == 'R' ) ret = R;
            begin++;
        }
        return ret;
    }
}

int formula( State & begin ) {
    int ret = factor( begin );
    if ( *begin == '*' ) {
        begin++;
        ret = min( ret, formula( begin ) );
    }
    else if ( *begin == '+' ) {
        begin++;
        ret = max( ret, formula( begin ) );
    }
    else {

    }
    return ret;
}


Measured memory_bytes: 3148
import sys

def main():
    stdin = sys.stdin
    n, m = map(int, stdin.readline().split())

    par = [i for i in range(n)]
    size = [1] * n
    rank = [1] * n

    def find(x, par):
        if par[x] == x:
            return x
        else:
            return find(par[x], par)

    def unite(x, y):
        x = find(x, par)
        y = find(y, par)

        if x != y:
            # xとyの属している集合が異なる時
            if rank[x] < rank[y]:
                par[x] = y
                size[y] += size[x]
            else:
                par[y] = x
                size[x] += size[y]
                if rank[x] == rank[y]:
                    rank[x] += 1

    for _ in range(m):
        a, b = map(int, stdin.readline().split())
        unite(a-1, b-1)


    print(max(size))

if __name__ == '__main__':
    main()

Measured memory_bytes: 20192
/*"Success isn't permanent, failure isn't fatal,
                                      it's the courage to continue that counts"*/
#include<bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;
using namespace std;
//typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
#define ll long long 
#define scn(n) scanf("%d",&n)
#define lscn(n) scanf("%lld",&n)
#define lpri(n) printf("%lld",n)
#define pri(n) printf("%d",n)
#define pln() printf("\n")
#define priln(n) printf("%d\n",n)
#define lpriln(n) printf("%lld\n",n)
#define rep(i,init,n) for(int i=init;i<n;i++)
#define pb push_back     
#define mp make_pair
#define F first
#define S second
#define gcd __gcd
#define inf INT_MAX
#define ninf INT_MIN
const int mod=1e9+7;         
const int N=2e5+4;

int main()
{
	double l; cin>>l;

	l=(l*l*l)/27.0;

	printf("%.8lf",l);
	
    return 0;
}

Measured memory_bytes: 256
S = list(input())

ac = False
if S[0] == "A":
    if S[2:len(S)-1].count("C") == 1:
        ac = True

upper = False
count = 0
for i in S:
    if i.isupper():
        count += 1

if count == 2:
    upper = True

if ac and upper:
    print("AC")
else:
    print("WA")


Measured memory_bytes: 3060
//aoj 0524 Searching Constellation

#include<iostream>

using namespace std;

int main(){
	while (1){
		int n, m, roop = 1, a[200][2], b[1000][2], star[199][2];
	
		cin >> n;

		if (n == 0){
			return 0;
		}

		for (int i = 0; i < n; i++){

			cin >> a[i][0] >> a[i][1];

		}

		for (int i = 0; i < n - 1; i++){

			star[i][0] = a[i + 1][0] - a[0][0];

			star[i][1] = a[i + 1][1] - a[0][1];
			
		}
	
		cin >> m;

		for (int i = 0; i < m; i++){

			cin >> b[i][0] >> b[i][1];
			
		}

		for (int i = 0; i < m; i++){

			for (int j = 0; j < n - 1; j++){
				
				for(int k = 0; k < m; k++){
				
					if (b[k][0]==(b[i][0] + star[j][0]) && b[k][1]==(b[i][1] + star[j][1])){

						roop++;
						
						if (n == roop){

							cout << b[i][0] - a[0][0] << ' ' << b[i][1] - a[0][1] << endl;
	
						}
					
					break;
					
					}
	
				}
				
			}
			roop=1;
		}

	}
	
	return 0;

}

Measured memory_bytes: 1168
#include <bits/stdc++.h>
using namespace std;
#define fo(i,a,b) for(int i=a;i<=b;i++)
#define fod(i,a,b) for(int i=a;i>=b;i--)
#define me0(a) memset(a,0,sizeof(a))
#define me1(a) memset(a,-1,sizeof(a))
#define op freopen("in.txt","r",stdin);
#define mp(x,y) make_pair(x,y)
#define pii pair<int,int>
void read(int &val) { int x = 0; int bz = 1; char c; for (c = getchar(); (c<'0' || c>'9') && c != '-'; c = getchar()); if (c == '-') { bz = -1; c = getchar(); }for (; c >= '0' && c <= '9'; c = getchar()) x = x * 10 + c - 48; val = x * bz; }
const int INF = 0x3f3f3f3f;
const int maxn=1e6+7;
const int mod=1e9+7;
typedef long long LL;

int n,m;


int main(){
    int x;cin>>x;
    if(x>=30) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}

Measured memory_bytes: 3616
# -*- coding: utf-8 -*-
"""
http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0181

"""
import sys
from sys import stdin
input = stdin.readline


def Cond(m, n, mid, books):
    if max(books) > mid:
        return False

    rem = mid
    while books:
        while rem >= books[0]:
            rem -= books[0]
            books = books[1:]
            if len(books) == 0:
                break
        rem = mid
        m -= 1
        if m < 0:
            return False
        
    return True


def solve(m, n, books):
    ub = 1500000
    lb = max(books)
    min_width = float('inf')

    for i in range(30):
        mid = (ub + lb) // 2
        if Cond(m, n, mid, books):
            min_width = min(min_width, mid)
            ub = mid
        else:
            lb = mid
    return min_width


def main(args):
    while True:
        m, n = map(int, input().split())
        if m == 0 and n == 0:
            break
        books = [int(input()) for _ in range(n)]
        result = solve(m, n, books)
        print(result)


if __name__ == '__main__':
    main(sys.argv[1:])
    

Measured memory_bytes: 7744
#include <stdio.h>

int gcd(int,int);

int main(){
    int a,b;
    scanf("%d%d",&a,&b);
    printf("%d\n",gcd(a,b));
    
    return 0;
}
int gcd(int x,int y){
    return y ? gcd(y,x % y):x;
}




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

string order;
vector<int> num;
vector<char> word;
int n;
char button[9][5] = {{'.',',','!','?',' '},{'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'}};

int main()
{
  int but = 0,push = 0;
  cin >> n;
  for(int i=0;i<n;i++){
    cin >> order;
    for(int j=0;j<order.size();j++){
      num.push_back((int)(order[j]-'0'));
    }
    for(int j=0;j<num.size();j++){
      if(1<=num[j] && num[j]<=9){
	if(but==0){
	  but = num[j];
	}else{
	  push++;
	}
      }else if(num[j]==0){
	if(but==0){
	  continue;
	}
	
	const int mod = (but == 1 ? 5 : but == 7 || but == 9 ? 4 : 3);

	word.push_back(button[but-1][push%mod]);
	push = 0;
	but = 0;
      }
    }
    
    for(int k=0;k<word.size();k++){
      cout << word[k];
    }
    cout << endl;
    
    word.clear();
    num.clear();
  }
  
  return 0;
  
}

Measured memory_bytes: 1228
package main

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

var sc = bufio.NewScanner(os.Stdin)

func gets() string {
	sc.Scan()
	return sc.Text()
}

func toInt(value string) int {
	num, _ := strconv.Atoi(value)
	return num
}

func main() {
  N := toInt(gets())
  var c int
  for c = 1; c <= N; c *= 2 {}
  fmt.Println(c / 2)
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
const long long inf = 0x3f3f3f3f;
int main(){
	//freopen("in.txt","r",stdin);
	int n,m,x;
	cin>>n>>m>>x;
	int ans=inf;
	int dat[n+1][m+1+1];
	for(int i=0;i<n;i++){
		cin>>dat[i][0];
		for(int j=1;j<=m;j++) cin>>dat[i][j];
	}
	for(int i=0;i<=(1<<n)-1;i++){
		int e[m+1+1]={0};
		int foo=0;
		for(int j=0;j<n;j++){
			if(i>>j&1){
				for(int k=1;k<=m;k++){
					e[k]+=dat[j][k];
				}
				foo+=dat[j][0];
			}
		}
		bool ok=true;
		for(int i=1;i<=m;i++) if(e[i]<x) ok=false;
		if(ok) ans=min(ans,foo);
		//for(int i=1;i<=m;i++) cout<<e[i]<<" "; cout<<endl;
	}
	cout<<(ans==inf?-1:ans)<<endl;
	return 0;
}

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

d1=[]
d2=[]

cont=0
for i in range(N):
    D1,D2=map(int,input().split())

    d1.append(D1)
    d2.append(D2)

for i in range(len(d1)):
    if d1[i]==d2[i]:
        cont+=1
    else:
        cont=0

    if cont==3:
        break
    
if cont>=3:
    print("Yes")
else:
    print("No")

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

using namespace std;

typedef long long ll;

const int MAX_N = 3010;
const ll MOD = 1e9 + 7, INV2 = (MOD + 1) / 2;

int N, Q, A[MAX_N];
ll dp[MAX_N][MAX_N];
pair<int, int> oper[MAX_N];

int main() {
    scanf("%d%d", &N, &Q);
    for (int i = 1; i <= N; i++) scanf("%d", &A[i]);
    for (int i = 1; i <= Q; i++) scanf("%d%d", &oper[i].first, &oper[i].second);
    for (int i = 1; i <= N; i++)
        for (int j = 1; j <= N; j++)
            dp[i][j] = i > j;
    for (int i = Q; i; i--) {
        int a = oper[i].first, b = oper[i].second;
        vector<pair<ll *, ll>> modify;
        modify.emplace_back(&dp[a][b], INV2);
        modify.emplace_back(&dp[b][a], INV2);
        for (int j = 1; j <= N; j++) {
            if (j == a || j == b) continue;
            modify.emplace_back(&dp[a][j], (dp[a][j] + dp[b][j]) * INV2 % MOD);
            modify.emplace_back(&dp[j][a], (dp[j][a] + dp[j][b]) * INV2 % MOD);
        }
        for (int j = 1; j <= N; j++) {
            if (j == a || j == b) continue;
            modify.emplace_back(&dp[b][j], (dp[b][j] + dp[a][j]) * INV2 % MOD);
            modify.emplace_back(&dp[j][b], (dp[j][b] + dp[j][a]) * INV2 % MOD);
        }
        for (auto i : modify)
            *(i.first) = i.second;
    }
    ll ans = 0;
    for (int i = 1; i <= N; i++)
        for (int j = i + 1; j <= N; j++) {
            if (A[i] > A[j]) (ans += dp[j][i]) %= MOD;
            if (A[i] < A[j]) (ans += dp[i][j]) %= MOD;
        }
    for (int i = 1; i <= Q; i++) (ans *= 2) %= MOD;
    printf("%lld\n", ans);
}


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

class Test
{
    static void Main()
    {
        string[] ss = Console.ReadLine().Split();
        int r = int.Parse(ss[0]);
        int c = int.Parse(ss[1]);

        int[][] dd = new int[r][];
        for (int i = 0; i < r; i++)
        {
            dd[i] =Console.ReadLine().Split().Select(int.Parse).ToArray();
        }

        int sum = 0;
        for (int i = 0; i < r; i++)
        {
            Console.WriteLine(string.Join(" ", dd[i]) + " " + dd[i].Sum());
        }

        int sum2 = 0;
        int total = 0;
        for (int i = 0; i < c; i++)
        {
            for (int j = 0; j < r; j++)
            {
                sum2 += dd[j][i];
            }
            Console.Write(sum2 + " ");
            total += sum2;
            sum2 = 0;
        }
        Console.WriteLine(total);
    }
}


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

#define lowbit(x) ((x) & (-(x)))

const int N = 10000010;
const int moder = 1e9 + 7;

int c[N], n;

void add(int sit, int value){
	while (sit < N){
		c[sit] = (c[sit] + value) % moder;
		sit += lowbit(sit);
	}
}

int query(int sit){
	int ret = 0;
	while (sit){
		ret = (ret + c[sit]) % moder;
		sit -= lowbit(sit);
	}
	return ret;
}

int main(){
	scanf("%d", &n);
	add(1, moder - 1);
	int ans = 0;
	for (int i = 0; i < n; ++ i){
		int x = !i ? 1 : (query(i) + 1) % moder;
		add(i + 1, x);
		add(i + 2, (moder - x) % moder);
		if (i == n - 1){
			ans = (ans + 1ll * x * n) % moder;
			continue;
		}
		else{
			ans = (ans + 1ll * (n - 1) * (n - 1) % moder * x) % moder;
		}
		if (i + 3 >= n){
			ans = (ans + 1ll * x * (n - 1)) % moder;
			continue;
		}
		add(i + 3, x);
		add(n, (moder - x) % moder);
		ans = (ans + 1ll * (i + 2) * x) % moder;
	}
	return printf("%d\n", ans), 0;
}

Measured memory_bytes: 12544
#include <bits/stdc++.h>
using namespace std;
#define IOS ios_base::sync_with_stdio(0); cin.tie(0);

const int MAXN = 100 + 5;
const int MAXW = 1e5 + 5;

int N, W, we[MAXN], vl[MAXN];
long long dp[MAXW];

int main() {
    IOS
    
    cin >> N >> W;
    for (int i = 1; i <= N; i++) {
        cin >> we[i] >> vl[i];
    }

    for (int i = 1; i <= N; i++) {
        for (int j = W; j >= we[i]; j--) {
            dp[j] = max(dp[j], dp[j - we[i]] + vl[i]);
        }
    }

    cout << dp[W] << '\n';
}

Measured memory_bytes: 4368
#include <stdio.h>

int main(void){

  int i,j,  A[3][3];
  for(i=0;i<3;i++){
    for(j=0;j<3;j++){
      scanf("%d",&A[i][j]);
    }
  }
  int N,k;
  scanf("%d",&N);
  int b[N];
  for(i=0;i<N;i++){
    scanf("%d",&b[i]);
  }

  for(i=0;i<3;i++){
    for(j=0;j<3;j++){
      for(k=0;k<N;k++){
	if(A[i][j]==b[k]){
	  A[i][j]=0;
	}
      }
    }
  }
  for(i=0;i<3;i++){
    if(A[0][i]==0&&A[1][i]==0&&A[2][i]==0){
      printf("Yes");
      return 0;
}
  }
 for(i=0;i<3;i++){
    if(A[i][0]==0&&A[i][1]==0&&A[i][2]==0){
      printf("Yes");
      return 0;
    }
  }
 if(A[0][0]==0&&A[1][1]==0&&A[2][2]==0){
   printf("Yes");
   return 0;
 }
 else if(A[0][2]==0&&A[1][1]==0&&A[2][0]==0){
   printf("Yes");
   return 0;
 }

 printf("No");

    
  
  return 0;
}


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

int main() {
  string n;
  cin >>n;
  
  if((n[0] == n[1] && n[1] == n[2])||(n[1] == n[2] && n[2] == n[3])){
    cout <<"Yes" <<endl;
  }
 
  else {
    cout <<"No" <<endl;
  }

}

Measured memory_bytes: 256
N = int(input())
A = list(map(int,input().split()))
if N==2: print(max(A));exit()
from math import gcd
L = {}
R = {}
L[0] = A[0]
R[N-1] = A[-1]
ans = 0
for i in range(1,N):
    L[i] = gcd(L[i-1],A[i])
    R[N-i-1] = gcd(R[N-i],A[N-i-1])
for i in range(2,N):
    ans = max(ans,gcd(L[i-2],R[i]))
ans = max(ans,R[1])
ans = max(ans,L[N-2])
ans = max(ans,R[0])
print(ans)

Measured memory_bytes: 106520
//25, 08, 2018, 09:03:20 Rafaelcs cpp
#include <bits/stdc++.h>

using namespace std;
typedef pair<int, int> pii;
typedef long double ld;
typedef long long ll;
typedef unsigned long long ull;

const int N = int(2e5);
int x[N];

int main(){
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    
    int n, k;

    scanf("%d %d", &n, &k);

    for(int i = 0 ; i < n ; i++){
        scanf("%d", &x[i]);
    }

    int best = 1e9;
    
    for(int j = 0 ; j <= n - k ; j++){
        int rg = x[j + k - 1];

        if(x[j] < 0){
            if(rg <= 0){
                best = min(best, abs(x[j]));
            }else{
                best = min(best, min(abs(x[j]) * 2 + rg, rg * 2 + abs(x[j])));
            }
        }else{
            best = min(best, x[j + k - 1]);
        }
    }

    printf("%d\n", best);

    return 0;
}

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

// Define
using ll = int64_t;
using ul = uint64_t;
using ld = long double;
const ll MOD = 1e9 + 7;
const ll INF = LONG_MAX;
const ul MAX = ULONG_MAX;
const char nl = '\n';

#define elif else if
#define def inline auto
#define run __attribute__((constructor)) def _

// Debug
#define debug(x) cerr << (x) << " (L:" << __LINE__ << ")" << '\n'

// Loop
#define inc(i, a, n) for (ll i = (a), _##i = (n); i < _##i; ++i)
#define dec(i, a, n) for (ll i = (a), _##i = (n); i > _##i; --i)
#define rep(i, n) inc(i, 0, n)
#define be(c) begin(c), end(c)

// Stream
#define fout(n) cout << fixed << setprecision(n)
#define fasten cin.tie(0), ios::sync_with_stdio(0)

// Speed
run() { fasten, fout(10); }
#pragma GCC optimize("-O3")
#pragma GCC target("avx")

signed main() {
    int a, b, c;
    cin >> a >> b >> c;
    cout << min(b / a, c) << endl;
}


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

#define uni(x)      (x).resize(unique(ALL(x)) - (x).begin())
#define fprint(v)   for(auto x : v) cout << x << ' '
#define ALL(x)      (x).begin(), (x).end()
#define MP(x, y)    make_pair(x, y)
#define SZ(x)       int((x).size())
#define PB(x)       push_back(x)
#define ll          long long
#define S           second 
#define F           first
#define nl          '\n'

using namespace std;
void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif
mt19937_64 rnd;

const int N = 2e5 + 5;

int main() {
    ios_base::sync_with_stdio(0);cin.tie(0);
    int n;
    cin >> n;
    vector<int> a(n);
    int sum = 0;
    cin >> a[0];
    sum += abs(a[0]);
    for(int i = 1; i < n; i++){
        cin >> a[i];
        sum += abs(a[i] - a[i - 1]);
    }
    debug(sum);
    sum += abs(a[n - 1]);
    for(int i = 0; i < n; i++){
        if(i == 0){
            cout << sum - (abs(a[1] - a[0]) + abs(a[0])) + (abs(a[1])) << nl;
        }else if(i == n - 1){
            cout << sum - abs(a[n - 2] - a[n - 1]) - abs(a[n - 1]) + abs(a[n - 2]) << nl;
        }else{
            cout << sum - (abs(a[i] - a[i - 1]) + abs(a[i] - a[i + 1])) + (abs(a[i - 1] - a[i + 1])) << nl;
        }
    }
    return 0;
}
/*
    *** Most Impo.. -> check base case always
    1. Overflow Check (*, +)
    2. Index check (0 - based or 1 - based)
    3. Check for n = 1, 2, 3, 4....
    4. Corner Cases
*/

Measured memory_bytes: 1664
L=[]
L2=[]
for i in range(5):
    I=int(input())
    L.append(I)
    L2.append(I%10)

result=0
for i in L:
    result+=i
    if result%10==0:
        continue
    for j in range(10):
        result+=1
        if result%10==0:
            break

if max(L2)==0:
    print(sum(L))
else:
    if min(L2)==0:
        for t in sorted(L2):
            if t==0:
                pass
            else:
                mn=t
                break
    else:
        mn=min(L2)

    print(result-(10-mn))


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

using namespace std;

const int M = 2e5 + 5;

int n, k, ps[M];
long long int sm = 0, res = 0;
map<int, int> c; // Maintain count
vector<long long int> s;

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

    cin >> n >> k;
    s.resize(n);
    for (auto& i : s) {
        cin >> i;
        i = (i + k - 1) % k; // Precalc Value
    } c[0]++;
    for (int i = n - 1; i >= 0; i--) {
        sm = (sm + s[i]) % k; ps[i] = sm;
        if (i + k <= n) c[ps[i + k]]--;
        res += c[sm]; c[sm]++;
    } cout << res << '\n';

    return 0;
}

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

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

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

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

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

constexpr double EPS = 1e-10;
//constexpr double PI  = acos(-1.0);
//constexpr int INF = INT_MAX;

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

void solve() {
    int n,k;
    cin >> n >> k;
    LL d0 = n / k;
    LL ans = d0 * d0 * d0;
    //dump(ans);
    if (k % 2 == 0) {
        LL d1 = (n + k/2) / k;
        ans += d1 * d1 * d1;
        //dump(ans);
    }
    cout << ans << endl;
}

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

Measured memory_bytes: 256
using System;
using System.Collections.Generic;

namespace oasobi
{
    static class MainClass
    {
        public static void Main()
        {
            int N = int.Parse(Console.ReadLine()); //Nを受け取るよ
            string[] input = Console.ReadLine().Split(' '); //区切って格納

            var intlist = new List<int>();

            for (int i = 0; i < N; ++i)
            {
                intlist.Add(int.Parse(input[i])); //intlistにinputのやつを移し替えるよ！
            }

            int act = 0;

            bool odd_aruyo = false;

            while(odd_aruyo == false)
            {
                for(int r = 0; r < N; ++r) //N個の数字の偶奇を調べるよ！
                {
                    if( intlist[r] % 2 == 1) //奇数があったら
                    {
                        odd_aruyo = true; //フラグをtrueにするよ
                    }

                }

                if(odd_aruyo == true) //フラグが立った！
                {
                    break; //繰り返しやめるよ
                }

                for (int i = 0; i < N; ++i)
                {
                    intlist[i] = intlist[i] / 2;
                }

                ++act;
            }

            Console.WriteLine(act);

        }
    }
}

Measured memory_bytes: 13140
#include<iostream>
#include<cmath>
#include<cstdio>
#define eps (1e-11)
#define equals(a,b) (fabs((a)-(b))<eps)
using namespace std;

class Point{
public:
  double x,y;
  Point(double x=0,double y=0):x(x),y(y){}

  Point operator+(Point p){return Point(x+p.x,y+p.y);}
  Point operator-(Point p){return Point(x-p.x,y-p.y);}
  Point operator*(double k){return Point(x*k,y*k);}
  Point operator/(double k){return Point(x/k,y/k);}

  double abs(){return sqrt(norm());}

  double norm(){return (x*x+y*y);}
};
typedef Point Vector;

class Segment{
public:
  Point p1,p2;
  Segment(Point p1,Point p2):p1(p1),p2(p2){}
};
typedef Segment Line;

double dot(Vector a,Vector b){return (a.x*b.x+a.y*b.y);}
double cross(Vector a,Vector b){return (a.x*b.y-a.y*b.x);}

Point project(Segment s,Point p){
  Vector base=(s.p2-s.p1);
  double r=(dot(p-s.p1,base)/base.norm());
  return (s.p1+base*r);
}

Point reflect(Segment s,Point p){
  return p+(project(s,p)-p)*2;
}

bool isOrthogonal(Vector a,Vector b){
  return equals(dot(a,b),0.0);
}

bool isParallel(Vector a,Vector b){
  return equals(cross(a,b),0.0);
}

static const int COUNTER_CLOCKWISE=1;
static const int CLOCKWISE=-1;
static const int ONLINE_BACK=2;
static const int ONLINE_FRONT=-2;
static const int ON_SEGMENT=0;

int ccw(Point p0,Point p1,Point p2){
  Vector a=p1-p0;
  Vector b=p2-p0;
  if(cross(a,b)>eps)return COUNTER_CLOCKWISE;
  if(cross(a,b)<-eps)return CLOCKWISE;
  if(dot(a,b)<-eps)return ONLINE_BACK;
  if(a.norm()<b.norm())return ONLINE_FRONT;
  return ON_SEGMENT;
}

bool intersect(Point p1,Point p2,Point p3,Point p4){
  return (ccw(p1,p2,p3)*ccw(p1,p2,p4)<=0 &&
          ccw(p3,p4,p1)*ccw(p3,p4,p2)<=0);
}

bool intersect(Segment s1,Segment s2){
  return intersect(s1.p1,s1.p2,s2.p1,s2.p2);
}

Point getCrossPoint(Segment s1,Segment s2){
  Vector base=s2.p2-s2.p1;
  double d1=abs(cross(base,s1.p1-s2.p1));
  double d2=abs(cross(base,s1.p2-s2.p1));
  double t=d1/(d1+d2);
  return (s1.p1+(s1.p2-s1.p1)*t);
}

int main()
{
  Point A,B,C,D,E;
  int q;

  cin>>q;
  for(int i=0;i<q;i++){
    cin>>A.x>>A.y>>B.x>>B.y>>C.x>>C.y>>D.x>>D.y;
    E=getCrossPoint(Segment(A,B),Segment(C,D));
    printf("%.10f %.10f\n",E.x,E.y);
  }
  return 0;
}

Measured memory_bytes: 1248
def reconciled():
	n, m = map(int, raw_input().split(" "))
	if abs(n - m) > 1:
		print 0
		return
	mod = 10 ** 9 + 7
	mod_n = 1
	mod_m = 1
	for i in reversed(range(1, n + 1)):
		mod_n = (mod_n * i) % mod
	for j in reversed(range(1, m + 1)):
		mod_m = (mod_m * j) % mod
	if n != m:
		print (mod_n * mod_m) % mod
	else:
		print (2 * mod_n * mod_m) % mod


if __name__ == "__main__":
	reconciled()

Measured memory_bytes: 5764
#include<stdio.h>
int main(void){
    int a,b,c,x,ans;
    scanf("%d %d %d",&a,&b,&c);
    for(x=a;x<=b;x++){
        if((c%x)==0){
            ans++;
        }
    }
    printf("%d\n",ans);
    return 0;
}


Measured memory_bytes: 2148
#include"bits/stdc++.h"
using namespace std;
using ll=long long;
using ull=unsigned long long;
constexpr auto inf=static_cast<ll>(1e18);
template<typename T=ll>inline T in(){T ret;cin>>ret;return ret;}
template<typename T=ll>inline auto vec2(size_t h,size_t w,T v=T()){return vector<vector<T>>(h,vector<T>(w,v));}
inline void setp(int n){cout<<fixed<<setprecision(n);}
inline void delnl(){cin.ignore(numeric_limits<streamsize>::max(),'\n');}

int main()
{
    ll n=in();vector<ll>a(n);
    for(ll i=0;i<n;++i)a[i]=in()-(i+1);
    sort(a.begin(),a.end());
    ll b=a.size()%2==1?a[a.size()/2]:(a[(a.size()-1)/2]+a[a.size()/2])/2;
    ll ans=0;
    for(ll i=0;i<n;++i)ans+=abs(a[i]-b);
    cout<<ans<<endl;
}


Measured memory_bytes: 1792
#include <vector>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <iostream>
#include <string>

using namespace std;
#define vi vector<int>
#define pii pair<int,int>
#define pb push_back
#define mp make_pair
#define all(x) x.begin(),x.end()
#define SZ(x) (int)(x.size())
#define rep(i,a,b) for(int i=a;i<b;i++)
#define per(i,a,b) for(int i=b-1;i>=a;i--)
#define inf 1000000007
#define mod 1000000007
#define ull unsigned long long
#define ll long long
template <class T,class U>inline void Max(T &a,U b){if(a<b)a=b;}
template <class T,class U>inline void Min(T &a,U b){if(a>b)a=b;}

bool isPal(string s) {
	int n = s.length();
	if(n<=1) return true;
	for(int i=0;i<=n/2;++i) {
		if(s[i] != s[n-1-i]) return false;
	}
	return true;
}

int pos[100005];

int main(){
	ios_base::sync_with_stdio(false);cin.tie(NULL);
	string s;
	cin >> s;
	if(isPal(s)) {cout << 0 << endl; return 0;}

	int n = s.length();
	string w;
	for(int i=0;i<n;++i) {
		if(s[i] != 'x') {
			pos[w.length()] = i; 
			w += s[i];
		}
	}
	if(!isPal(w)) {cout << -1 << endl; return 0;}
	int m=w.length();

	int l,r;
	l = r = (m-1)/2;
	if(m % 2 == 0) {r++;}
	
	int res = 0;
	for(;l>0; l--,r++) {
		int lgap = pos[l] - pos[l-1];
		int rgap = pos[r+1] - pos[r];
		res += abs(lgap-rgap);
	}
	res += abs( (n-1-pos[m-1])-pos[0] );
	cout << res << endl;

}

Measured memory_bytes: 976
n,c,k=map(int,input().split())
t=[]
for _ in range(n):
    t.append(int(input()))
t.sort()

def bus(M):
    j=1
    count=0
    I=t[0]
    for i in range(n):
        if I+k>=t[i] and count<c: 
            count+=1
        else:
            I=t[i]
            count=1
            j+=1
    if j<=M:
        return True
    else:
        return False

start=0
end=n
while end-start>1:
    ty=(start+end)//2
    if bus(ty):
        end=ty
    else:
        start=ty
print(end)

Measured memory_bytes: 50904
#include <iostream>
#include <stdio.h>
#include <string>
#include <math.h>
#include <vector>
#include <algorithm>
#include <functional>
#include <map>
#include <climits>
#include <memory>
#include <sstream>
#include <iomanip>

using namespace std;

long long euclid(long long a, long long b) {
	long long tmp = a % b;
	if (tmp == 0) {
		return b;
	}
	else {
		return euclid(b, tmp);
	}
}


int main() {
	int n;
	cin >> n;
	long long ans = 1;
	for (int i = 0; i < n; i++) {
		long long t;
		cin >> t;
		ans = ans / euclid(max(ans, t), min(ans, t)) * t;
	}

	cout << ans << endl;

	return 0;
}


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

void solve(){
  long long x, a, b, y; cin >> x;
  bool ok = false;
  pair<long long, long long> ans;
  for(int i = 1; ; i++){
    a = pow(i, 5);
    y = a;
    if(y == x){
      ans.first = i;
      ans.second = 0;
      ok = true;
    }
    else if(y > x){
      for(int j = 1; y > x; j++){
        b = pow(j, 5);
        y = a - b;
        if(y == x){
          ans.first = i;
          ans.second = j;
          ok = true;
          break;
        }
      }
    }
    else{
      for(int j = -1; y < x; j--){
        b = pow(j, 5);
        y = a - b;
        //cout << a << " - " << b << " = " << y << endl;
        if(y == x){
          ans.first = i;
          ans.second = j;
          ok = true;
          break;
        }
      }
    }
    if(ok == true){
      cout << ans.first << " " << ans.second << endl;
      return;
    }
  }
  return;
}

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


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

// input
int R, G;


void input() {
    cin >> R >> G;
}


int main() {
    input();
    int ans = 2 * G - R;
    cout << ans << endl;
}


Measured memory_bytes: 3560
// vvvvvvvvvvvv TEMPLATE vvvvvvvvvvvv
#include <bits/stdc++.h>
using namespace std; using ll = long long; using P = pair<ll, ll>;
const ll linf = 1e18; const double eps = 1e-12, pi = acos(-1);
#define FOR(i,a,b) for (ll i=(a),__last_##i=(b);i<__last_##i;i++)
#define RFOR(i,a,b) for (ll i=(b)-1,__last_##i=(a);i>=__last_##i;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define __GET_MACRO3(_1, _2, _3, NAME, ...) NAME
#define each(i,a) for (auto&& i : a)
#define rep(...) __GET_MACRO3(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define rrep(...) __GET_MACRO3(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)
#define pb push_back
#define eb emplace_back
#define all(a) begin(a),end(a)
#define chmin(x,v) x = min(x, v)
#define chmax(x,v) x = max(x, v)
template<typename Head> void out(Head h) { cout << h << endl; } template<typename Head, typename... Tail>void out(Head h, Tail... t) { cout << h << " "; out(t...); }
template<typename T> istream& operator>>(istream& is, vector<T>& v) { each(x,v) is >> x; return is; }
template<typename T> ostream& operator<<(ostream& os, const vector<T>& v) { rep(i,v.size()) { if (i) os << " "; os << v[i]; } return os; }
ostream& operator<<(ostream& os, const vector<string>& v) { rep(i,v.size()) { if (i) os << endl; os << v[i]; } return os; }
template<typename T> ostream& operator<<(ostream& os, const vector<vector<T>>& v) { rep(i,v.size()) { if (i) os << endl; os << v[i]; } return os; }
template<typename T1, typename T2> ostream& operator<<(ostream& os, const pair<T1, T2>& p) { return os << "(" << p.first << ", " << p.second << ")"; }
struct yes_no : std::numpunct<char> { string_type do_truename() const { return "Yes"; } string_type do_falsename() const { return "No"; } };
void solve(); int main() {
  ios::sync_with_stdio(false); cin.tie(0); locale loc(locale(), new yes_no); cout.imbue(loc); cout << fixed << setprecision(10) << boolalpha;
  solve();
}
// ^^^^^^^^^^^^ TEMPLATE ^^^^^^^^^^^^

ll days[] = {0,31,30,31,30,31,30,31,31,30,31,30,31};

void solve() {
  ll m1, d1, m2, d2; cin >> m1 >> d1 >> m2 >> d2;
  if (m1 != m2) {
    cout << 1 << endl;
  }
  else {
    cout << 0 << endl;
  }
}


Measured memory_bytes: 256
A = int(input())
B = int(input())
C = int(input())
X = int(input())
count = 0
for i in range(A+1):
    for j in range(B+1):
        for k in range(C+1):
            if (500*i) + (100*j) + (50*k) == X:
                count += 1
print(count)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define dump(x) cout << #x << " = " << (x) << endl;
using namespace std;
using ll = long long;
using P = pair<ll, ll>;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N;
  cin >> N;
  vector<tuple<string, int, int>> a;
  for(int i = 1; i <= N; i++) {
    string s;
    int p;
    cin >> s >> p;
    p = -p;
    a.push_back(tie(s, p, i));
  }
  sort(a.begin(), a.end());
  for(auto x : a) {
    string s;
    int p, id;
    tie(s, p, id) = x;
    cout << id << endl;
  }
  return 0;
}

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

int main(){
  int d,t,s;
  cin >> d >> t >> s;

  if(d<=t*s) cout << "Yes" << endl;
  else cout << "No" << endl;
  
  return 0;
}

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

int main() {

	int n,a;
  	cin >> n;
  
  	for ( int i = 0; i < 3; i++){
      a = n % 10;
      if ( a == 7 ){
        cout << "Yes" << endl;
        return 0;
      }
      n /= 10;
    }
  
  	cout << "No" << endl;

}


Measured memory_bytes: 3620
#include <bits/stdc++.h>
#define ll long long int
#define MOD 1000000007
#define INF 1e18
#define PI 3.14159265358979

using namespace std;

ll gcd(ll a, ll b);
ll power(ll n, ll k);
ll inv(ll n);
ll genfact(ll n, ll k);
ll fact(ll n);
ll nck(ll n, ll k);

int main(void){
  int n, K;
  cin >> n >> K;
  vector<ll> x(n), y(n), x2(n), y2(n);
  for (int i = 0; i < n; i++){
    cin >> x[i] >> y[i];
    x2[i] = x[i];
    y2[i] = y[i];
  }
  sort(x2.begin(), x2.end());
  sort(y2.begin(), y2.end());
  ll m = 4*INF + 10;
  for (int i = 0; i < n; i++){
    for (int j = i + 1; j < n; j++){
      for (int k = 0; k < n; k++){
        for (int l = k + 1; l < n; l++){
          int num = 0;
          for (int a = 0; a < n; a++){
            if (x2[i] <= x[a] && x[a] <= x2[j] && y2[k] <= y[a] && y[a] <= y2[l])
              num++;
          }
          ll t = (x2[j] - x2[i]) * (y2[l] - y2[k]);
          if (num >= K){
            m = min(m, t);
          }
        }
      }
    }
  }

  cout << m << endl;

  return 0;
}

ll gcd(ll a, ll b){
  if (a < b)
    return gcd(b, a);
  if (b == 0)
    return a;
  else
    return gcd(b, a % b);
}

ll power(ll n, ll k){
  ll res = 1;
  while(k > 0){
    if (k & 1) 
      res = res * n % MOD;
    n = n * n % MOD;
    k >>= 1;
  }
  return res;
}

ll genfact(ll n, ll k){

  ll res = 1;
  while (k >= 0){
    res = (res * (n - k)) % MOD;
    k--;
  }

  return res;
}

ll inv(ll n){
  return power(n, MOD - 2);
}

ll fact(ll n){
  return genfact(n, n - 1);
}

ll nck(ll n, ll k){
  if (k == 0)
    return 1;
  if (n <= 0)
    return 0;

  return ((genfact(n, k) % MOD) * inv(fact(k))) % MOD;
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-

# AtCoder Beginner Contest
# Problem C

if __name__ == '__main__':
    from bisect import bisect_left
    from bisect import bisect_right

    n = int(input())
    a = sorted(list(map(int, input().split())))
    count = 0

    for i in range(max(a) + 1):
        left = bisect_left(a, i - 1)
        right = bisect_right(a, i + 1)
        count = max(count, max(0, right - left))

    print(count)


Measured memory_bytes: 14092
N,M=map(int,input().split())
a=[list(map(int,input().split())) for _ in range(N)]
c=[list(map(int,input().split())) for _ in range(M)]
for i in range(N):
  p,q=0,10**9
  for j in range(M):
    if q>abs(c[j][0]-a[i][0])+abs(c[j][1]-a[i][1]):
      q=abs(c[j][0]-a[i][0])+abs(c[j][1]-a[i][1])
      p=j+1
    elif q==abs(c[j][0]-a[i][0])+abs(c[j][1]-a[i][1]):
      if abs(p-i)>abs(j+1-i):
        p=j+1
  print(p)

Measured memory_bytes: 9192
#include <bits/stdc++.h>
using namespace std;
using ll = long long ;
using P = pair<ll, ll>;
using Vec = vector<ll>;
using VecP = vector<P>;
#define FOR(i, m, n) for(ll (i) = (m); (i) < (n); (i)++)
#define FORN(i, m, n) for(ll (i) = (m); (i) <= (n); (i)++)
#define FORR(i, m, n) for(ll (i) = (m); (i) >= (n); (i)--)
#define rep(i, n) FOR(i, 0, n)
#define repn(i, n) FORN(i, 1, n)
#define repr(i, n) FORR(i, n, 0)
#define repnr(i, n) FORR(i, n, 1)
#define co(n) cout << (n) << endl
#define cosp(n) cout << (n) << ' '
#define setp(n) cout << fixed << setprecision(n);
#define all(s) (s).begin(), (s).end()
#define pb push_back
#define mp make_pair
#define fs first
#define sc second

const ll INF = 1e9+1;
const ll LINF = 1e18+1;
const ll MOD = 1e9+7;
//const ll MOD = 998244353;
const double PI = acos(-1);
const double EPS = 1e-9;

int main(void){
	ll n, m;
	cin >> n >> m;
	if(abs(n-m) > 1){
		co(0);
		return 0;
	}

	if(n < m) swap(n, m);

	ll ans = 1;
	repn(i, n){
		ans *= i;
		ans %= MOD;
	}
	repn(i, m){
		ans *= i;
		ans %= MOD;
	}
	if(n == m) ans *= 2;
	ans %= MOD;
	co(ans);

	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>          // printf(), scanf()
#define MAX_N 4000

int
main(int argc, char **argv)
{
	int cmbi[MAX_N + 1];
	int n, s;
	int i;

	int count = 0;
	for (i = 0; i <= 1000; ++i)
	{
		count += (i + 1) * (i + 2) / 2;
		cmbi[i] = cmbi[MAX_N - i] = count;
	}

	int minus = 0;
	n = 0, s = 0;
	for (i = 1001; i <= 2000; ++i)
	{
		count += (i + 1) * (i + 2) / 2;
		n++;
		s += n;
		minus += 4 * s;
		cmbi[i] = cmbi[MAX_N - i] = count - minus;
	}

	while (scanf("%d", &n) != EOF)
		printf("%d\n", cmbi[n]);

	return 0;
}

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

using namespace std;

typedef long long ll;
typedef long double Double;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

// chmax, chmin
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;
}

void solve(std::string s) {
    int ans = 0;
    for (int i = 1; i <= s.size(); i++) {
        set<char> S;
        for (int j = 0; j < 26; j++) S.insert('a' + j);

        for (int j = 0; j < i; j++) {
            set<char> T;
            for (int k = 0; k < s.size() - i + 1; k++) {
                assert(j + k < s.size());
                T.insert(s[j + k]);
            }
            set<char> X;
            for (auto i : S) {
                if (T.count(i)) X.insert(i);
            }
            S = X;
        }
        if (S.size() > 0) {
            ans = i;
        }
    }
    cout << s.size() - ans << endl;
}

int main() {
    std::string s;
    std::cin >> s;
    solve(s);
    return 0;
}


Measured memory_bytes: 256
n, m = map(int, input().split())

x = list(map(int, input().split()))

gap = []


if( n >= m):
    print(0)
    exit()
else:
    x = sorted(x)
    for i in range(m-1):
        gap.append(x[i+1] - x[i])
    gaps = sorted(gap)

print(sum(gaps[:m-n]))


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

using namespace std;

int main() {
	int N;
	char s;
	int cnt = 0, ans = 0;
	cin >> N;
	for(int i = 0; i < N; ++i) {
		cin >> s;
		if(s == 'I') {
			++cnt;
			if(ans < cnt) ans = cnt;
		}
		else --cnt;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
import collections

def main():
    N = int(input())
    A = list(map(int, input().split()))
    c = collections.Counter(A)
    ans = 0
    for num, freq in c.items():
        if num < freq:
            ans += freq - num
        elif num > freq:
            ans += freq
    print(ans)


if __name__ == '__main__':
    main()


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

using ll = long long;
using vi = vector<int>;
using vi2 = vector<vector<int>>;
#define MP(a,b) make_pair((a),(b))
#define MT(...) make_tuple(__VA_ARGS__)

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,x) for(int i=0;i<(int)(x);i++)
#define REPS(i,x) for(int i=1;i<=(int)(x);i++)
#define RREP(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define RREPS(i,x) for(int i=((int)(x));i>0;i--)

#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl;
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl;
#define gcda(x,y) gcd(abs(x),abs(y))

#define DCOUT(x,n) cout << fixed << setprecision(n) << (x) << endl;

#define sz(x) (int)(x).size()
#define HOGE cout << "hoge" << endl;
using P = pair<ll,ll>;

template<typename T>inline istream& operator>>(istream&i,vector<T>&v)
{REP(j,sz(v))i>>v[j];return i;}

const int INF = 1e9;

int main(){
    REP(i,5){
        int x;
        cin >> x;
        if(x==0){
            cout << i+1 << endl;
            break;
        }
    }
}


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

using namespace std;
const long long MOD = 1000000007LL;

int main() {
    long long n, k; cin >> n >> k;
    vector<long long> a(n);
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
    }
    long long ans = 0;
    for (int i = n-1; i >= 0; --i) {
        long long num = 0;
        for (int j = n-1; j > i; --j) {
            if (a[i] > a[j]) {
                ++num;
            }
        }
        ans = (ans + num * k) % MOD;
    }
    const long long p = (k-1) * k / 2 % MOD;
    for (int i = 0; i < n; ++i) {
        long long num = 0;
        for (int j = 0; j < n; ++j) {
            if (a[i] > a[j]) {
                ++num;
            }
        }
        ans = (ans + num * p) % MOD;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>

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

	for (int i = 1; i <= 50000; ++i) {
		if (n == static_cast<int>(i * 1.08)) {
			std::cout << i << std::endl;
			return 0;
		}
	}

	std::cout << ":(" << std::endl;
}

Measured memory_bytes: 256
MONEY = 5001

NONE, MOVE, GAIN, LOSE = (0..3).to_a
EVENT, VALUE = 0, 1

until (x, y, z = gets.split.map(&:to_i)).all?(&:zero?)
  roulette = gets.split.map(&:to_i)
  event = Array.new(y + 1){[NONE]}
  z.times do
    n, e, a = gets.split.map(&:to_i)
    event[n] = [e, a]
  end

  answer = 0.0
  dp = Array.new(y + 1){Array.new(MONEY){0.0}}
  dp[0][0] = 1
  y.times do |current|
    MONEY.times do |money|
      next if dp[current][money] == 0.0
      p = dp[current][money] / roulette.size.to_f
      roulette.each do |spot|
        nex = current + spot
        unless nex < y
          dp[y][money] += p
        else
          case event[nex][EVENT]
            when NONE
              dp[nex][money] += p
            when MOVE
              nex += event[nex][VALUE]
              if nex < y
                dp[nex][money] += p
              else
                dp[y][money] += p
              end
            when GAIN
              dp[nex][money + event[nex][VALUE]] += p
            when LOSE
              dp[nex][[0, money - event[nex][VALUE]].max] += p
          end
        end
      end
    end
  end
  p MONEY.times.map.inject(0.0){|result, money| result + money.to_f * dp[y][money]}.to_i
end

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

int main(){

    long long n = 50;
    long long k; cin >> k;
    long long a = k / n;
    long long b = k % n;
    vector<long long> ans(n, a + n - 1);
    for(long long i = 0; i < b; i++){
        //i番目を50増やす
        //その他を-1する
        for(long long j = 0; j < n; j++){
            if(i == j){
                ans[j] += n;
            }else{
                ans[j]--;
            }
        }
    }

    cout << n << endl;
    for(int i = 0; i < n-1; i++){
        cout << ans[i] << " ";
    }
    cout << ans[n-1] << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
// #include<atcoder/all>
using namespace std;
// using namespace atcoder;
typedef long long ll;
using P = pair<int,int>;

const int mod = 1000000007;

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

    int dp[2020];
    memset(dp, 0, sizeof(dp));
    dp[0] = 0;
    dp[1] = 0;
    dp[2] = 0;
    dp[3] = 1;
    for(int i = 4; i <= s; i++){
        dp[i] = dp[i - 3] + dp[i - 1];
        dp[i] %= mod;
    }
    cout << dp[s] << endl;
    return 0;
}

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

using namespace std;

int main() {
	int n;
	scanf("%d", &n);
	for (int i = 0; i < n; ++i) {
		int x = i * 4;
		int y = n - x;
		if (y < 0) continue;
		if (y % 7 == 0) {
			printf("Yes\n");
			return 0;
		}
	}
	printf("No\n");
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
const int maxn=1e5+10;
int arr[maxn],brr[maxn],crr[maxn],ans[maxn]; 
int main()
{
	int a,b,c;
	scanf("%d%d%d",&a,&b,&c);
	const int inf=0x3f3f3f3f;
	int min1=inf,min2=inf;
	for (int i=1;i<=a;i++)
	{
		scanf("%d",&arr[i]);
		if (min1>arr[i])
			min1=arr[i];
	}
	for (int i=1;i<=b;i++)
	{
		scanf("%d",&brr[i]);
		if (min2>brr[i])
			min2=brr[i];
	}
	int ans=min1+min2;
	int x,y,z;
	for (int i=1;i<=c;i++)
	{
		scanf("%d%d%d",&x,&y,&z);
		int temp=arr[x]+brr[y]-z;
		if (temp<ans)
			ans=temp;
	}
	printf("%d\n",ans);
}

Measured memory_bytes: 1024