akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <sstream>
#include <vector>
#include <set>

typedef unsigned long long int ulli;

struct Point
{
    ulli a, b;
    Point(ulli a, ulli b) : a(a), b(b) {}
    bool operator<(const Point &p) const
    {
        return (b == p.b) ? a < p.a : b < p.b;
    }
    bool operator==(const Point &p) const
    {
        return a == p.a && b == p.b;
    }
};

std::ostream& operator<<(std::ostream &os, const Point &p)
{
    os << "(" << p.a << ", " << p.b << ")";
    return os;
}

template<typename T>
std::ostream& operator<<(std::ostream &os, const std::set<T> &s)
{
    const std::string delim = ", ";
    auto itr = s.begin();
    while(itr != s.end())
    {
        os << *itr;
        if(++itr != s.end()) os << delim;
    }
    return os;
}

template<typename T>
std::ostream& operator<<(std::ostream &os, const std::multiset<T> &s)
{
    const std::string delim = ", ";
    auto itr = s.begin();
    while(itr != s.end())
    {
        os << *itr;
        if(++itr != s.end()) os << delim;
    }
    return os;
}

struct Count
{
    Point p;
    ulli c;
    Count(Point p, ulli c = 1) : p(p), c(c) {}

    bool operator<(const Count &cnt) const
    {
        return p < cnt.p;
    }

    bool operator==(const Count &cnt) const
    {
        return p == cnt.p;
    }
};

std::ostream& operator<<(std::ostream &os, const Count &c)
{
    os << "[" << c.p << " : " << c.c << "]";
    return os;
}

int main(void)
{
    ulli H, W, N;
    std::cin >> H >> W >> N;

    std::multiset<Point> field;
    for(unsigned n=0; n<N; ++n)
    {
        ulli a, b;
        std::cin >> a >> b;
        //field.emplace(a-1, b-1);

        for(unsigned dy=0; dy<=2; ++dy)
        {
            for(unsigned dx=0; dx<=2; ++dx)
            {
                ulli p = a - dy - 1;
                ulli q = b - dx - 1;
                if(p < (H - 2) && q < (W - 2))
                {
                    field.emplace(q, p);
                }
            }
        }
    }
    //std::cerr << field << std::endl;
    
    std::set<Count> counter;
    for(auto &v : field)
    {
        auto itr = counter.find(Count(v));
        if(itr == counter.end())
        {
            counter.insert(Count(v));
        }
        else
        {
            Point p = itr->p;
            ulli c = itr->c + 1;
            counter.erase(itr);
            counter.insert(Count(p, c));
        }
    }
    //std::cerr << counter << std::endl;
   
    std::vector<ulli> t(10, 0);
    for(auto &v : counter)
    {
        ++t[v.c];
    }

    ulli s = 0;
    for(unsigned i=1; i<=9; ++i)
    {
        s += t[i];
    }
    std::cout << ((W - 2) * (H - 2) - s)  << std::endl;
    
    for(unsigned i=1; i<=9; ++i)
    {
        std::cout << t[i] << std::endl;
    }

    return 0;
}

Measured memory_bytes: 112768
#include<iostream>
#include<vector>
#include<queue>
#include<stack>
#include<algorithm>
#define vel vector<long long>
#define veb vector<bool>
#define vvel vector<vel>
#define int long long
#define pin pair<int,int>
#define ppin pair<int,pin>
#define mkp make_pair
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
void mmin(int &a, int b) { a = min(a, b); }
void mmax(int &a, int b) { a = max(a, b); }
signed main() {
	int ans = 0;
	int mx = 0;
	rep(i, 5) { 
		int x; cin >> x;
		int nex = ((x + 9) / 10) * 10;
		ans += nex;
		mmax(mx, nex - x);
	}
	cout << ans-mx << endl;
	return 0;
}

Measured memory_bytes: 256
//In the name of God
#include<bits/stdc++.h>

using namespace std;
typedef long long ll;

string s;


int main(){
        cin >> s;
        int t = (int)s.size()-1;
        ll res = 0;
        for(int mask=0 ; mask < 1<<t ; mask++){
                ll tot = 0 , now = 0;
                for(int i=0 ; i < t ; i++){
                        now *= 10;
                        now += (s[i]-'0');
                        if(mask>>i &1){
                                tot += now;
                                now = 0;
                        }
                }
                now *= 10;      now += (s[t] - '0');
                tot += now;
                res += tot;
        }
        cout << res;
        return 0;
}

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

public class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
		Scanner sc = new Scanner(br.readLine());
		int a=sc.nextInt();
		int b=sc.nextInt();
		int c=sc.nextInt();
		if(a<b&&b<c)System.out.println("Yes");
		else System.out.println("No");
	}
	

}

Measured memory_bytes: 17192
S = input()
if S == "SUN":
    print(7)
elif S == "MON":
    print(6)
elif S == "TUE":
    print(5)
elif S == "WED":
    print(4)
elif S == "THU":
    print(3)
elif S == "FRI":
    print(2)
elif S == "SAT":
    print(1)

Measured memory_bytes: 2940
//A
#include <iostream>
using namespace std;
string s;

int main(){
  cin >> s;
  
  if (s.length() == 2){
    cout << s.at(0) << s.at(1) << endl;
  }else {
    cout << s.at(2) << s.at(1) << s.at(0) <<  endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<climits>
#include<cmath>
#include<cstdio>
#include<cstdlib>
#include<ctime>
#include<string>
#include<cstring>
#include<vector>
#include<stack>
#include<queue>
#include<set>
#include<map>
#include<bitset>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> i_i;
typedef pair<long long, int> ll_i;

#define PI 3.141592653589793238462643383279
#define mod 1000000007LL
#define rep(i, n) for(i = 0;i < n;++i)
#define rep1(i, n) for(i = 1;i < n;++i)
#define per(i, n) for(i = n - 1;i > -1;--i)
#define int(x) int x; scanf("%d",&x)
#define int2(x, y) int x, y; scanf("%d%d",&x, &y)
#define int3(x, y, z) int x, y, z; scanf("%d%d%d",&x, &y, &z)
#define int4(v, x, y, z) int v, x, y, z; scanf("%d%d%d%d", &v, &x, &y, &z)
#define int5(v, w, x, y, z) int v, w, x, y, z; scanf("%d%d%d%d%d", &v, &w, &x, &y, &z)
#define pri(x) cout << (x) << "\n"
#define pri2(x, y) cout << (x) << " " << (y) << "\n"
#define pri3(x, y, z) cout << (x) << " " << (y) << " " << (z) << "\n"
#define pb push_back
#define mp make_pair
#define all(a) (a).begin(),(a).end()
#define kabe puts("---------------------------")
#define kara puts("")
#define debug(x) cout << " --- " << (x) << "\n"
#define debug2(x, y) cout << " --- " << (x) << " " << (y) << "\n"
#define debug3(x, y, z) cout << " --- " << (x) << " " << (y) << " " << (z) << "\n"
#define X first
#define Y second
#define eps 0.0001
#define prid(x) printf("%.15lf\n", x)


signed main(void){
  int i, j;
  for(int testcase = 0;testcase >= 0;testcase++){
    ll a, b, res = 123451234512345LL;
    cin >> a >> b;
    if(a * b > 0){
      if(a < 0){
        if(a > b)res = a - b + 2LL;
        else res = b - a;
      }else{
        if(a <= b)res = min(res, b - a);
        else res = min(res, 2 + a - b);
      }
    }else if(a * b == 0){
      if(a == 0){
        if(b >= 0)res = b;
        else res = 1 - b;
      }else{
        if(a > 0)res = 1 + a;
        else res = -a;
      }
    }else{  //ab < 0
      if(a < b){
        res = b - a;
        if(abs(a) <= abs(b))res = min(res, abs(b) - abs(a) + 1);
        else res = min(res, abs(a) - abs(b) + 1);
      }else{
        if(abs(a) <= abs(b))res = 1LL + abs(b) - abs(a);
        else res = 1LL + abs(a) - abs(b);
      }
    }
    pri(res);

/*/

//*/ break;
  }
  return 0;
}


Measured memory_bytes: 384
n, k = map(int, input().split())

ans = 0
if k == 0:
  print (n**2)
  exit()
for i in range(1,n+1):
  if i <= k:
    continue
  ans += max(i-k,0)*(n//i) + max(n%i-(k-1),0)
print (ans)

Measured memory_bytes: 9188
#include<iostream>
#include<algorithm>
#include<functional>
#include<cmath>
#include<string>
#include<vector>
#include<queue>
using namespace std;
#define ll long long
const int mod = 1000000007;
const ll INF = 1000000000000000000;
typedef pair<int, int> P;

ll A[100010];
ll cnt[100010];

int main()
{
	int N; cin >> N;
	for (int i = 0; i < N; i++) {
		cin >> A[i];
	}
	ll ans = 1;
	for (int i = 0; i < N; i++) {
		if (A[i] == 0) {
			ans *= (3 - cnt[0]);
		}
		else {
			ans *=  cnt[A[i] - 1] - cnt[A[i]];
		}
		ans %= mod;
		cnt[A[i]]++;
	}
	cout << ans % mod << endl;
}


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

using namespace std;

int main (void){
    int N;
    int t[100010];
    int x[100010];
    int y[100010];
    bool flag = true;

    cin>>N;
    for(int i=0;i<N;i++){
        cin>>t[i]>>x[i]>>y[i];
    }

    for(int i=0;i<N;i++){
       if(t[i]>=(x[i]+y[i])){
            if(t[i]%2==0){
                if((x[i]+y[i])%2==1)
                    flag=false;
            }  

            if(t[i]%2==1){
                if((x[i]+y[i])%2==0)
                    flag=false;
            }  
        }else{
            flag=false;
        }    
    }

    if(flag==true){
        cout<<"Yes"<<endl;
    }else{
        cout<<"No"<<endl;
    }

    return 0;
}

Measured memory_bytes: 1408
read S
N=${#S}
(
diff -s <(echo $S) <(rev <<<$S) &&
diff -s <(echo ${S::(N-1)/2}) <(rev <<<${S::(N-1)/2}) &&
diff -s <(echo ${S:((N+3)/2)-1}) <(rev <<<${S:((N+3)/2)-1}) 
) >/dev/null&&
echo Yes||echo No

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

int main(){
    int n;
    cin >> n;
    vector<int> a(n);
    for (int i = 0; i < n; i++) cin >> a[i];
    int mode = - 1;
    int ans = 1;
    for (int i = 1; i < n; i++){
        if (a[i] == a[i - 1]) continue;
        if (a[i] > a[i - 1]){
            if (mode == 0) continue;
            else if (mode == - 1) mode = 0;
            else {
                mode = - 1;
                ans++;
            }
        }
        else {
            if (mode == 1) continue;
            else if (mode == - 1) mode = 1;
            else {
                mode = - 1;
                ans++;
            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define fi first
#define se second

const int N=5005;

int v[N][N]={}, d[N][N]={}, s[N][N];

int main()
{
    int n,m;
    scanf(" %d %d", &n, &m);
    while(m--)
    {
        int a,b,x;
        scanf(" %d %d %d", &a, &b, &x);
        --a;
        --b;

        ++v[a][b];
        --v[a+x+1][b];
        --d[a][b+1];
        ++d[a+x+1][b+x+2];
    }

    rep(i,N)for(int j=1; j<N; ++j) v[j][i] += v[j-1][i];
    rep(i,N)for(int j=1; i+j<N; ++j) d[i+j][j] += d[i+j-1][j-1];
    for(int j=1; 1+j<N; ++j) d[j][1+j] += d[j-1][1+j-1];

    rep(i,N)rep(j,N) s[i][j] = v[i][j]+d[i][j];
    rep(i,N)for(int j=1; j<N; ++j) s[i][j] += s[i][j-1];

    int ans=0;
    rep(i,n)rep(j,i+1) ans+=s[i][j]>0;
    printf("%d\n", ans);
    return 0;
}

Measured memory_bytes: 265800
MOD = 10 ** 9 + 7
INF = 10 ** 11
import sys
sys.setrecursionlimit(100000000)

def main():
    a,b,n = map(int,input().split())
    x = -INF
    if b - 1 <= n:
        x = a*(b - 1)//b - a*((b - 1)//b)
    y = a*n//b - a*(n//b)
    print(max(x,y))
if __name__ == '__main__':
    main()


Measured memory_bytes: 9120
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
ll mod=1e9+7;

int main()
{
  int n;
  cin>>n;
  vector<ll> h(n),b(n),dp(n);
  for(ll& x:h)
  cin>>x;
  for(ll&x: b)
  cin>>x;
  dp[0]=b[0];
  map<ll,ll> mp;
  mp[h[0]]=dp[0];
  for(int i=1;i<n;i++)
  {
    dp[i]=b[i];
    auto it=mp.lower_bound(h[i]);
    if(it!=mp.begin())
    {
      it--;
      dp[i]+=it->second;
    }
    mp[h[i]]=dp[i];
    it=mp.upper_bound(h[i]);
    while(it!=mp.end()&&it->second<=dp[i])
    {
      auto temp=it;
      it++;
      mp.erase(temp);
    }
  }
  cout<<*max_element(dp.begin(),dp.end())<<endl;
  return 0;
}

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

int main(){
    string s; cin >> s;
    int n = s.size() - 2;
    for (int i = 0; i < s.size(); i++) {
        for (int j = 0; j < n / 2; j++) {
            if (s[j] != s[n / 2 + j]) {n -= 2; break;}
            if (j == n / 2 - 1) {cout << n << endl; return 0;}
        }
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
#define chmin(a, b) ((a)=min((a), (b)))
#define chmax(a, b) ((a)=max((a), (b)))
#define fs first
#define sc second
#define eb emplace_back
using namespace std;

typedef long long ll;
typedef pair<int, int> P;
typedef tuple<int, int, int> T;

const ll MOD=1e9+7;
const ll INF=1e18;
const double pi=acos(-1);
const double eps=1e-10;

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

int main(){
    while(1){
        int w, h; cin>>w>>h;
        if(w == 0) return 0;

        vector<vector<int>> bo(2*h-1, vector<int>(2*w-1, -1)); 
        for(int i=0; i<2*h-1; i++){
            for(int j=0; j<2*w-1; j++){
                if(i % 2 == 0 && j % 2 == 1) cin>>bo[i][j];
                if(i % 2 == 1 && j % 2 == 0) cin>>bo[i][j];
            }
        }

        queue<T> que;
        que.push(T(0, 0, 0));
        while(que.size()){
            int cy, cx, cost;
            tie(cy, cx, cost) = que.front();
            que.pop();

            if(cy == 2 * h - 2 && cx == 2 * w - 2){
                cout << cost + 1 << endl;
                goto END;
            }

            for(int i=0; i<4; i++){
                int ny = cy + dy[i];
                int nx = cx + dx[i];

                if(0 <= ny && ny < 2 * h - 1 && 0 <= nx && nx < 2 * w - 1){
                    if(i == 0 && nx + 1 < 2 * w - 1 && bo[ny][nx] == 0 && bo[ny][nx+1] == -1){
                        bo[ny][nx] = 2;
                        bo[ny][nx+1] = 2;
                        que.push(T(ny, nx+1, cost+1));
                    }
                    if(i == 1 && 0 <= ny - 1 && bo[ny][nx] == 0 && bo[ny-1][nx] == -1){
                        bo[ny][nx] = 2;
                        bo[ny-1][nx] = 2;
                        que.push(T(ny-1, nx, cost+1));
                    }
                    if(i == 2 && 0 <= nx - 1 && bo[ny][nx] == 0 && bo[ny][nx-1] == -1){
                        bo[ny][nx] = 2;
                        bo[ny][nx-1] = 2;
                        que.push(T(ny, nx-1, cost+1));
                    }
                    if(i == 3 && ny + 1 < 2 * h - 1 && bo[ny][nx] == 0 && bo[ny+1][nx] == -1){
                        bo[ny][nx] = 2;
                        bo[ny+1][nx] = 2;
                        que.push(T(ny+1, nx, cost+1));
                    }
                }
            }
        }

        cout << 0 << endl;
        END:;
    }
}


Measured memory_bytes: 3092
# B - Five Dishes(ABC123)
B=[]
C=[]
for i in range(5):
    S=int(input())
    if S%10==0:
        C.append(S)
    else:
        C.append(S+(10-S%10))
    if S%10!=0:
        B.append(S%10)
if B==[]:
    print(sum(C))
else:
    print(sum(C)-(10-min(B)))

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
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;
}
typedef long long int ll;

#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define endl "\n"
const double EPS = 1e-7;
const int INF = 1 << 30;
const ll LLINF = 1LL << 60;
const double PI = acos(-1);
const int MOD = 1000000007;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

using State = string::const_iterator;

//-------------------------------------

string s;

char pre(char c) {
    if(c == '?') {
        return c;
    } else {
        return (c == 'A' ? 'Z' : c - 1);
    }
}

char nxt(char c) {
    if(c == '?') {
        return c;
    } else {
        return (c == 'Z' ? 'A' : c + 1);
    }
}

string Cipher(State &);
string String(State &);
char Letter(State &);

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    while(1) {
        cin >> s;
        if(s == ".") {
            break;
        }
        State now = s.begin();
        string ans = Cipher(now);
        for(int i = 0; i < ans.size(); i++) {
            if(ans[i] == '?') {
                ans[i] = 'A';
            }
        }
        cout << ans << endl;
    }
}

string Cipher(State &now) {
    string res = String(now);
    while(now != s.end() && *now != ']') {
        res += String(now);
    }
    return res;
}

string String(State &now) {
    string res;
    if(*now == '[') {
        res = Cipher(++now);
        reverse(ALL(res));
        now++;
        return res;
    } else {
        res = Letter(now);
        return res;
    }
}

char Letter(State &now) {
    char res;
    if(*now == '+') {
        return nxt(Letter(++now));
    } else if(*now == '-') {
        return pre(Letter(++now));
    } else {
        return *(now++);
    }
}


Measured memory_bytes: 3152
#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(){
    string s,t;
    cin >> s >> t;
    int cnt = 0;
    rep(i, s.size()){
        if(s[i]!=t[i]) cnt++;
    }
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 3912
fun main(args: Array<String>) {
    val n = readLine()?.toInt() ?: return
    val sList = (0 until n).map {
        readLine()?.toInt()!!
    }.sorted()

    val total = sList.sum()
    var result = total

    for (s in sList) {
        if (result % 10 != 0) {
            println(result)
            return
        }
        if (s % 10 == 0) {
            continue
        }
        result -= s
    }

    println(0)
}

Measured memory_bytes: 34272
import sys
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))  #空白あり
def LI2(): return list(map(int,sys.stdin.readline().rstrip()))  #空白なし
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split())  #空白あり
def LS2(): return list(sys.stdin.readline().rstrip())  #空白なし

N,P = map(int,S().split())
S = LI2()

if P == 2 or P == 5:  #10と素でない場合一番右の桁で決まる
    ans = 0
    for i in range(N):
        if S[i] % P == 0:
            ans += i+1
    print(ans)
    exit()

A = [0]  #A[i] = 下i桁をPで割った余り
for i in range(1,N+1):
    A.append((A[i-1]+pow(10,i,P)*S[N-i]) % P)

from collections import Counter

c = Counter(A)
B = c.values()

ans = 0

for i in B:
    ans += (i*(i-1)//2)

print(ans)

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

using namespace std;
using ll = long long;
using ld = long double;

const int MOD = 1e9 + 7;

template <int mod>
struct ModInt {
  int x;

  ModInt() : x(0) {}

  ModInt(int64_t y) : x(y >= 0 ? y % mod : (mod - (-y) % mod) % mod) {}

  ModInt &operator+=(const ModInt &p) {
    if ((x += p.x) >= mod) x -= mod;
    return *this;
  }

  ModInt &operator-=(const ModInt &p) {
    if ((x += mod - p.x) >= mod) x -= mod;
    return *this;
  }

  ModInt &operator*=(const ModInt &p) {
    x = (int)(1LL * x * p.x % mod);
    return *this;
  }

  ModInt &operator/=(const ModInt &p) {
    *this *= p.inverse();
    return *this;
  }

  ModInt operator-() const { return ModInt(-x); }

  ModInt operator+(const ModInt &p) const { return ModInt(*this) += p; }

  ModInt operator-(const ModInt &p) const { return ModInt(*this) -= p; }

  ModInt operator*(const ModInt &p) const { return ModInt(*this) *= p; }

  ModInt operator/(const ModInt &p) const { return ModInt(*this) /= p; }

  bool operator==(const ModInt &p) const { return x == p.x; }

  bool operator!=(const ModInt &p) const { return x != p.x; }

  ModInt inverse() const {
    int a = x, b = mod, u = 1, v = 0, t;
    while (b > 0) {
      t = a / b;
      swap(a -= t * b, b);
      swap(u -= t * v, v);
    }
    return ModInt(u);
  }

  ModInt pow(int64_t n) const {
    ModInt ret(1), mul(x);
    while (n > 0) {
      if (n & 1) ret *= mul;
      mul *= mul;
      n >>= 1;
    }
    return ret;
  }

  friend ostream &operator<<(ostream &os, const ModInt &p) { return os << p.x; }

  friend istream &operator>>(istream &is, ModInt &a) {
    int64_t t;
    is >> t;
    a = ModInt<mod>(t);
    return (is);
  }

  static int get_mod() { return mod; }
};

using modint = ModInt<MOD>;

template <typename T>
struct Combination {
  vector<T> _fact, _rfact, _inv;

  Combination(int sz) : _fact(sz + 1), _rfact(sz + 1), _inv(sz + 1) {
    _fact[0] = _rfact[sz] = _inv[0] = 1;
    for (int i = 1; i <= sz; i++) _fact[i] = _fact[i - 1] * i;
    _rfact[sz] /= _fact[sz];
    for (int i = sz - 1; i >= 0; i--) _rfact[i] = _rfact[i + 1] * (i + 1);
    for (int i = 1; i <= sz; i++) _inv[i] = _rfact[i] * _fact[i - 1];
  }

  inline T fact(int k) const { return _fact[k]; }

  inline T rfact(int k) const { return _rfact[k]; }

  inline T inv(int k) const { return _inv[k]; }

  T P(int n, int r) const {
    if (r < 0 || n < r) return 0;
    return fact(n) * rfact(n - r);
  }

  T C(int p, int q) const {
    if (q < 0 || p < q) return 0;
    return fact(p) * rfact(q) * rfact(p - q);
  }

  T H(int n, int r) const {
    if (n < 0 || r < 0) return (0);
    return r == 0 ? 1 : C(n + r - 1, r);
  }
};

void solve() {
  int S;
  cin >> S;

  const int n = S / 3;
  modint ans = modint(0);

  Combination<modint> comb(3000);

  for (int i = 1; i <= n; i++) {
    int s = S - 3 * i;

    ans += comb.C(s + i - 1, s);
  }
  cout << ans << endl;
}

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  std::cout << std::fixed << std::setprecision(15);

  solve();
  return 0;
}


Measured memory_bytes: 3660
#include <bits/stdc++.h>
#define DUMP(x)  cout << #x << " = " << (x) << endl;
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define IFOR(i, m, n) for(int i = n - 1; i >= m; i-- )
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
#define FOREACH(x,a) for(auto& (x) : (a) )
#define ALL(v) (v).begin(), (v).end()
using namespace std;
typedef long long ll;
const ll INF = 1LL << 60;
const int MOD = 1000000007;
/* テンプレートここまで */

int main() {
  int N, L;

  cin >> N >> L;
  vector<string> s(N);

  REP(i,N){
    cin >> s[i];
  }

  sort(ALL(s));

  REP(i, N){
    cout << s[i];
  }

  cout << endl;
}


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

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

using namespace std;

int main(){
  int n;cin>>n;
  ll result=1;
  rep(i, n){
    int t;cin>>t;
    if(t%2==0)result*=2;
  }
  cout<<pow(3,n)-result;
  return 0;
}

Measured memory_bytes: 640
import sys
from itertools import product as prd
sys.setrecursionlimit(10**7)
INTMAX = 9223372036854775807
INTMIN = -9223372036854775808
MOD = 1000000007
def POW(x, y): return pow(x, y, MOD)
def INV(x, m=MOD): return pow(x, m - 2, m)
def DIV(x, y, m=MOD): return (x * INV(y, m)) % m
def LI(): return [int(x) for x in input().split()]
def LF(): return [float(x) for x in input().split()]
def LS(): return input().split()
def II(): return int(sys.stdin.readline())
def SI(): return input()

S = input()
X,Y=LI()

while S and S[0] == 'F':
    S = S[1:]
    X -= 1
isX = True
cur = 0
xs = []
ys = []
for i in range(len(S)):
    if S[i] == 'T':
        if cur:
            if isX: xs.append(cur)
            else: ys.append(cur)
        isX = not isX
        cur = 0
    elif S[i] == 'F': cur += 1

if cur:
    if isX: xs.append(cur)
    else: ys.append(cur)
sumxs = sum(xs)
sumys = sum(ys)

if abs(X) > sumxs or abs(Y) > sumys:
    print('No')
    exit()

memo1 = [[0]*(sumxs*2+1) for i in range(len(xs)+1)]
memo2 = [[0]*(sumys*2+1) for i in range(len(ys)+1)]

memo1[0][0] = 1
memo2[0][0] = 1
for i, j in prd(range(1, len(xs)+1), range(-sumxs, sumxs+1)):
    memo1[i][j] = memo1[i-1][j+xs[i-1]] or memo1[i-1][j-xs[i-1]]

for i, j in prd(range(1, len(ys)+1), range(-sumys, sumys+1)):
    memo2[i][j] = memo2[i-1][j+ys[i-1]] or memo2[i-1][j-ys[i-1]]

print('Yes' if memo1[len(xs)][X] and memo2[len(ys)][Y] else 'No')


Measured memory_bytes: 166108
// http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=1153&lang=jp
#include <bits/stdc++.h>
using namespace std;
int n, m;
int s0[100], s1[100];
int main() {
    while(scanf("%d%d",&n,&m)) {
        if (n==0&&m==0) break;
        int hanako = 0, tarou = 0;
        for (int i=0; i<n; i++) {
            scanf("%d", &s0[i]);
            hanako += s0[i];
        }
        for (int i=0; i<m; i++) {
            scanf("%d", &s1[i]);
            tarou += s1[i];
        }
        int r0 = 0, r1 = 0, res = -1;
        for (int i=0; i<n; i++) {
            // ??¢???????????§????´???°???
            for (int j=0; j<m; j++) if (hanako - s0[i] + s1[j] == tarou - s1[j] + s0[i]) {
                if (res == -1 || res > s0[i] + s1[j]) {
                    res = s0[i] + s1[j];
                    r0 = s0[i]; r1 = s1[j];
                }
            }
        }
        if (res == -1) puts("-1");
        else printf("%d %d\n", r0, r1);
    }
}

Measured memory_bytes: 1196
#include <iostream>
using namespace std;
int main(){
  string s;
  cin >> s;
  if(s[0]==s[1]&&s[1]==s[2]&&s[2]==s[3]){
    cout << "No" << endl;
    return 0;
  }
  for(int i=0;i<3;i++){
    for(int j=i+1;j<4;j++){
      if(s[i]==s[j]){
        string ss = (s.erase(i,1)).erase(j-1,1);
        if(ss[0]==ss[1]){
          cout << "Yes" << endl;
          return 0;
        }else{
          break;
        }
      }
    }
  }
  cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;

typedef long long ll;
typedef pair<int, int> P;
typedef pair<int, char> Pc;
typedef pair<int, string> Ps;

const int dx[4] = {-1, 0, 0, 1};
const int dy[4] = {0, -1, 1, 0};
const int dx8[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int dy8[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
const string dir8[8] = {"U", "RU", "R", "RD", "D", "LD", "L", "LU"};

// Self settings
// clang-format off
#define MAX_N 100000
#define MAX 100000
#define INFTY (1<<30)
#define EPS (1e-10)
#define equals(a, b) (fabs((a) - (b)) < EPS)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i, N) for (int i = 0; i < (int)(N); ++i)
#define SLN(i,N) (i == N-1 ? "\n" : " ")
ll fact(ll n) { ll res = 1; for(ll i=2;i<=n;++i) res = res * i; return res;}
ll nCr(ll n, ll r) {return (fact(n)/fact(n-r)*fact(r)) ;}
ll gcd(ll a,ll b){if(b==0)return a;return gcd(b,a%b);}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
const ll MOD = 1e9+7;
const ll INF = 1LL << 60;
const int inf = 1000100011;
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 a) { return Point(a * x, a * y); } Point operator/(double a) { return Point(x / a, y / a); } double abs() { return sqrt(norm()); } double norm() { return x * x + y * y; } bool operator<(const Point& p) const { return x != p.x ? x < p.x : y < p.y; } bool operator==(const Point& p) const { return fabs(x - p.y) < EPS && fabs(y - p.y) < EPS; } };
typedef Point Vector;
double norm(Vector a) { return a.x * a.x + a.y * a.y; }
double abs(Vector a) { return sqrt(norm(a));}
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; }
struct Segment { Point p1, p2; };
typedef Segment Line;
// clang-format on

ll gcd(int a, int b, int c) { return gcd(gcd(a, b), c); }

int main(void) {
  cin.tie(0);
  ios::sync_with_stdio(false);
  std::cout << std::fixed << std::setprecision(15);
  ll K;
  cin >> K;
  ll sum = 0;
  FOR(i, 1, K + 1) {
    FOR(j, 1, K + 1) {
      FOR(k, 1, K + 1) { sum += gcd(i, j, k); }
    }
  }
  cout << sum << endl;

  return 0;
}


Measured memory_bytes: 3196
#include <bits/stdc++.h>
#define rep(i,n)for(int i=0;i<(n);i++)
#define chmax(x,y) x = max(x,y)
#define chmin(x,y) x = min(x,y)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef tuple<ll,ll,ll> T;
const long long INF = 1LL<<60;
const int MOD = 1000000000+7;
#define rev(s) (string((s).rbegin(), (s).rend()))
template < typename T > inline string toString( const T &a ) { ostringstream oss; oss << a; return oss.str(); };
// cout << fixed << setprecision(10) << ans << endl;
// *min_element(c + l, c + r) *max_element(c + l, c + r)
// int dx[8]={1,1,0,-1,-1,-1,0,1};
// int dy[8]={0,1,1,1,0,-1,-1,-1};
// int dx[4]={1,0,-1,0};
// int dy[4]={0,1,0,-1};
// struct Edge {
//   int to, id;
//   Edge(int to, int id): to(to), id(id) {}
// };

int main() {
  int K;cin>>K;
  if(K <= 9) {
    cout << K << endl;
    return 0;
  }
  int cnt = 0;
  queue<ll> qu;
  rep(i,9){
    qu.push(i+1);
  }
  while(1) {
    ll now = qu.front();
    qu.pop();
    cnt++;
    if(cnt == K) {
      cout << now << endl;
      return 0;
    }
    ll last = now % 10;
    if(last == 0) {
      qu.push(now * 10);
      qu.push(now * 10 + 1);
    } else if(last == 9) {
      qu.push(now * 10 + 8);
      qu.push(now * 10 + 9);
    } else {
      rep(i,3) {
	qu.push(now * 10 + (last - 1 + i));
      }
    }
  }
}


Measured memory_bytes: 5024
/*input
6
8 6 9 1 2 1
*/

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

#define rep(i,j,n) for(i=j;i<n;i++)
#define repi(i,j,n) for(i=j;i>n;i--)
#define inf 100001
#define M 1000000007
#define ll long long
#define ld long double
#define vll vector<long long>
#define vi vector<int>
#define pll pair<long long,long long>
#define pii pair<int,int>
#define vpii vector<pair<int,int> >
#define vpll vector<pair<long long,long long> >
#define pb push_back
#define pf pop_front
#define F first
#define S second
#define endl '\n'

using namespace std;
using namespace __gnu_pbds; 

template<typename T>
using ordered_set=tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;


ll power(ll a,ll m,ll mod){
	ll ans=1;
	while(m){
		if(m%2){
			ans*=a;
			ans%=(mod);
		}
		a=(a*a)%(mod);
		m>>=1;
	}
	return ans;
}


void init(ll* a,ll n,ll val){
	for(ll i=0;i<n;i++)
		a[i]=val;
}



int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);	
	ll t=1,i,j;
	ll n;
	cin>>n;
	ll dp[n+2][n+2];
	memset(dp,0,sizeof(dp));
	ll a;
	vpll v;
	rep(i,0,n)cin>>a,v.pb({a,i});
	sort(v.begin(),v.end());
	reverse(v.begin(),v.end());

	rep(i,0,n){
		rep(j,1,i+2){
			dp[j][n-(i+1-j)+1]=max(dp[j][n-(i+1-j)+1],dp[j-1][n-(i+1-j)+1]+(abs(v[i].S-(j-1)))*v[i].F);
		}
		repi(j,n,n-i-1){
			dp[i+j-n][j]=max(dp[i+j-n][j],dp[i+j-n][j+1]+abs(v[i].S-j+1)*v[i].F);
		}
	}
	ll ans=0;
	rep(i,0,n+1)ans=max(ans,dp[i][i+1]);
	cout<<ans<<endl;
	return 0;
}




Measured memory_bytes: 34976
import core.bitop, std.algorithm, std.ascii, std.bigint, std.conv, std.math,
    std.functional, std.numeric, std.range, std.stdio, std.string, std.random,
    std.typecons, std.container, std.format;

// dfmt off
T lread(T = long)(){return readln.chomp.to!T();}
T[] aryread(T = long)(){return readln.split.to!(T[])();}
void scan(TList...)(ref TList Args){auto line = readln.split();
foreach (i, T; TList){T val = line[i].to!(T);Args[i] = val;}}
alias sread = () => readln.chomp();enum MOD = 10 ^^ 9 + 7;
alias PQueue = BinaryHeap!(Array!long, "a<b");
// dfmt on

void main()
{
    auto S = sread() ~ "XXXX";
    writeln(S[0 .. 4] == "YAKI" ? "Yes" : "No");
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <unordered_map>
#include <queue>
#include <set>
#include <algorithm>
#include <string>
#include <math.h>
#include <limits.h>

using namespace std;

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


int main(){
    ll x, y; cin >> x >> y;
    if(-1 <= x - y &&  x - y <= 1){
        cout << "Brown" << endl;
    }
    else{
        cout << "Alice" << endl;
    }


    return 0;
}

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

#define pb push_back
#define eb emplace_back
#define all(v) (v).begin(), (v).end() 
#define sz(v) (int)((v).size())
#define fs first
#define sd second

typedef long long ll;

typedef pair < int, int > pi;
typedef pair < pi, int > ppi;

typedef vector < int > vi;
typedef vector < vector < int > > vvi;
typedef vector < pi > vpi;
typedef vector < vpi > vvpi;
typedef vector < ppi > vppi;

void fast() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
}

vector<string> vec_splitter(string s) {
	s += ',';
	vector<string> res;
	while(!s.empty()) {
		res.push_back(s.substr(0, s.find(',')));
		s = s.substr(s.find(',') + 1);
	}
	return res;
}

void debug_out(
vector<string> __attribute__ ((unused)) args,
__attribute__ ((unused)) int idx, 
__attribute__ ((unused)) int LINE_NUM) { cerr << endl; } 
template <typename Head, typename... Tail>
void debug_out(vector<string> args, int idx, int LINE_NUM, Head H, Tail... T) {
	if(idx > 0) cerr << ", "; else cerr << "Line(" << LINE_NUM << ") ";
	stringstream ss; ss << H;
	cerr << args[idx] << " = " << ss.str();
	debug_out(args, idx + 1, LINE_NUM, T...);
}

#ifdef LOCAL
#define debug(...) debug_out(vec_splitter(#__VA_ARGS__), 0, __LINE__, __VA_ARGS__)
#else
#define debug(...) 42
#endif

double get_time() {
	return 1.0 * clock() / CLOCKS_PER_SEC;
}

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

	if(s.back() == 's')
		cout << s + "es" << '\n';
	else
		cout << s + "s" << '\n';
}


Measured memory_bytes: 3632
import java.util.Scanner;

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

  public static void main(String[] args)  {
    char[] S = sc.next().toCharArray();
    int ans = 0;
    for (int i = 0; i < S.length - 1; i++) {
      if (S[i] != S[i + 1]) ++ans;
    }
    System.out.println(ans);
  }
}


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

typedef pair<int,int> P;
#define ll long long
#define ld long double
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define PI 3.14159265358979323846
#define sz(x) ((int)(x).size())
#define chmin(x,y) x = min(x,y)
#define chmax(x,y) x = max(x,y)

const int INF = 1e9;
const int MOD = 1e9 + 7;
const ll LINF = 1e18;
ll dp[100005];
vector<int> graph[100005];

ll rec(int v)
{
    if(dp[v]!=-1) return dp[v];
    ll res = 0;
    for (auto s : graph[v])
    {
        chmax(res, rec(s)+1);
    }
    dp[v] = res;
    return res;
    
}
int main()
{
    int n,m;
    cin >> n >> m;
    
    rep(i,m)
    {
       int x,y;
       cin >>x  >>y ;
       --x; --y;
       graph[x].push_back(y);
    }
    rep(i, 100005)
    {
        dp[i] = (ll)-1;
    }
    ll ans =0;
    rep(i,n) chmax(ans, rec(i));

    cout << ans << endl;
    
}

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

int n, m, i, j, out;
int dp [100001];
int deg [100001];
vector <int> e [100001];
queue <int> Q;

int main ()
    {
    scanf ("%d%d",&n,&m);
    while (m--)
        {
        scanf ("%d%d",&i,&j);
        e[i].push_back(j);
        deg[j]++;
        }
    for (i=1; i<=n; i++)
        if (deg[i]==0)
            Q.push(i);
    while (!Q.empty())
        {
        i = Q.front();
        Q.pop();
        for (int v : e[i])
            {
            out=max(out,dp[v]=max(dp[v],dp[i]+1));
            if (--deg[v]==0)
                Q.push(v);
            }
        }
    printf ("%d\n",out);
    return 0;
    }


Measured memory_bytes: 6528
#include <bits/stdc++.h>
using namespace std;
#define min(a,b) ((a)<(b)?(a):(b))
#define max(a,b) ((a)>(b)?(a):(b))
#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,n1,n2) for(int i=n1;i<n2;i++)
#define speed_up    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
typedef pair<int,int> Pi;
typedef long long int ll;
const int INF=(ll)(1<<30)-1;
const ll INFl=(ll)9223372036854775807;
const int MAX=10000;
const ll MOD=(ll)1e9+7;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a, b)*b;}
int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};

template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

int k;
vector<string> s;
string ss;

int main(){
	cin>>ss;
	cin>>k;
	for(int i=0;i<ss.size();i++){
		for(int j=1;j<=k;j++){
			if(i+j-1<ss.size())
			s.push_back(ss.substr(i,j));
		}
	}
	sort(s.begin(),s.end());
	s.erase(unique(s.begin(),s.end()),s.end());
	cout<<s[k-1]<<endl;
	return 0;
}

Measured memory_bytes: 1660
import qualified Data.ByteString.Char8 as B
import Data.Maybe
main = putStrLn.solve.map(fst.fromJust.B.readInt).B.words=<<B.getLine
solve (a:b:_)
    | or [x`mod`3==0 |x<-[a,b,a+b]] = "Possible"
    | otherwise = "Impossible"

Measured memory_bytes: 380
import collections
import sys
l = int(input())
inputs = [int(j) for j in input().split(' ')]
cs = collections.Counter(inputs)
if l % 2 == 0:
  for v,c in cs.items():
    if v % 2 == 0 or c != 2:
      print(0)
      sys.exit()
else:
  for v,c in cs.items():
    if v % 2 != 0 or (c != 2 and v != 0):
      print(0)
      sys.exit()
print(2**int(l/2)%(10**9+7))

Measured memory_bytes: 14820
#include <stdio.h>
int main(void){
    int n,i,ans=0;
    scanf("%d",&n);
    int v[n],c[n];
    for(i=0;i<n;i++) scanf("%d",&v[i]);
    for(i=0;i<n;i++) scanf("%d",&c[i]);
    for(i=0;i<n;i++){
        if(v[i]>c[i]) ans+=v[i]-c[i];
    }
    printf("%d",ans);
}

Measured memory_bytes: 128
#include <iostream>
#include <sstream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <memory>
#include <complex>
#include <numeric>
#include <cstdio>
#include <iomanip>
 
#define REP(i,m,n) for(int i=int(m);i<int(n);i++)
#define RREP(i,m,n) for(int i=int(n)-1;i>=int(m);--i)
#define EACH(i,c) for (auto &(i): c)
#define all(c) begin(c),end(c)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort(begin(c),end(c))
#define pb emplace_back
#define MP make_pair
#define SZ(a) int((a).size())
 
#ifdef LOCAL
#define DEBUG(s) cout << (s) << endl
#define dump(x)  cerr << #x << " = " << (x) << endl
#define BR cout << endl;
#else
#define DEBUG(s) do{}while(0)
#define dump(x) do{}while(0)
#define BR 
#endif
using namespace std;
 
using UI = unsigned int;
using UL = unsigned long;
using LL = long long int;
using ULL = unsigned long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VLL = vector<LL>;
using VVLL = vector<VLL>;
using VS = vector<string>;
using PII = pair<int,int>;
using VP = vector<PII>;
 
//struct edge {int from, to, cost;};
 
constexpr double EPS = 1e-10;
//constexpr double PI  = acos(-1.0);
//constexpr int INF = INT_MAX;
constexpr int MOD = 1'000'000'007;
//inline void modAdd(LL &l, LL &r) {l = (l + r) % MOD;}
 
template<class T> inline T sqr(T x) {return x*x;}
 
void solve() {
    int n,m;
    cin >> n >> m;
    VVI ks(m);
    VI p(m);
    int k,in;
    REP(i,0,m) {
        cin >> k;
        REP(j,0,k) {
            cin >> in;
            ks[i].push_back(in-1);
        }
    }
    REP(i,0,m) cin >> p[i];
    int ans = 0;
    REP(i,0,1<<n) {
        bool b = true;
        REP(j,0,m) {
            int sum = 0;
            REP(k,0,ks[j].size()) {
                if ((i & (1<<ks[j][k])) != 0) ++sum;
            }
            if (sum % 2 != p[j]) {
                b = false;
                break;
            }
        }
        if (b) ++ans;
    }
    cout << ans << endl;
}
 
int main() {
    solve();
    
    return 0;
}

Measured memory_bytes: 256
<?php
fscanf(STDIN, "%d", $n);
$list = trim(fgets(STDIN));
$list = explode( " ", $list );

$ans = 0;
$max = $list[0];
$i=1;
while($i<$n)
{
  if( $list[$i] >= $max )
  { $max = $list[$i];}
  else
  {
    $ans += $max-$list[$i];
    $max = $list[$i];
  }
  $i++;
}

echo $ans+$max;

Measured memory_bytes: 4728
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int a[100005];
int main()
{
    int n,tot=0,f=0;
    cin>>n;
    for(int i=0;i<n;i++)
    {
        scanf("%d",&a[i]);
    }
    for(int i=0;i<n;i++)
    {
        tot+=abs(f-a[i]);
        f=a[i];
    }
    tot+=abs(f-0);
    for(int i=0;i<n;i++)
    {
        int ans=tot;
        if(i==0)
        {
            ans-=abs(0-a[i]);
            ans-=abs(a[i]-a[i+1]);
            ans+=abs(0-a[i+1]);
        }
        else if(i==n-1)
        {
            ans-=abs(a[i-1]-a[i]);
            ans-=abs(a[i]-a[i+1]);
            ans+=abs(a[i-1]);
        }
        else
        {
            ans-=abs(a[i-1]-a[i]);
            ans-=abs(a[i]-a[i+1]);
            ans+=abs(a[i-1]-a[i+1]);
        }
        cout<<ans<<endl;
    }
    return 0;
}


Measured memory_bytes: 1664
#define _USE_MATH_DEFINES
#include <iostream>
#include <stdio.h>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <cstring>
#include <queue>
#include <functional>
#include <set>
#include <map>
#include <string>
#include <cmath>
#include <math.h>
#include <complex>
#include <cassert>
#define rep(i,a,b) for (int i = (a); i < (b); i++)
#define case(i) cout<<"Case #"<<i<<": "
using namespace std;
typedef long long int ll;
typedef complex<double> com;
const int mod = 1e9 + 7;
const int MOD = 998244353;
const ll INF = 4e18;



int main() {
	int n, k; scanf("%d %d",&n, &k);
	vector<int> a(n,0),b;
	rep(i, 0, n) {
		int p; scanf("%d", &p);
		p--; a[p]++;
	}
	rep(i, 0, n) {
		if (a[i] > 0) b.push_back(a[i]);
	}
	sort(b.begin(), b.end(), greater<int>());
	if (b.size() <= k) {
		printf("0");
		return 0;
	}
	ll ans = 0;
	rep(i, k, (int)b.size()) {
		ans += b[i];
	}
	printf("%d", ans);
	return 0;
}

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

int main(){
    int n,m;
    cin >> n >> m;
    int s[m],c[m];
    int ans=-1;
    rep(i,m) cin >> s[i] >> c[i];
    bool z=false;
    rep(i,1000){
        if(to_string(i).length()==n){
            z=false;
            //printf("%d\n",i);
            rep(j,m){
                if(to_string(i).length()<s[j]){
                    z=true;
                    break;
                }
                if(to_string(i)[s[j]-1]-'0'==c[j]){
                    continue;
                }
                else{
                    z=true;
                    break;
                }
            }
            if(!z){
                ans=i;
                break;
            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> iint;
typedef pair<ll,ll> llll;
#define ALL(x) (x).begin(),(x).end()
const ll zero = 0;
const ll one = 1;
const ll INF = 9223372036854775807; //10^18
const int inINF = 2147483647; //10^9
const ll MOD = 1000000007; //10^9+7
const ll MOD2 = 998244353;
void Yes() {printf("Yes\n");}
void No() {printf("No\n");}
void YES() {printf("YES\n");}
void NO() {printf("NO\n");}

int main(){
    int N;
    cin >> N;
    vector<queue<int>> q(N);
    int a;
    for (int i = 0; i < N; i++) {
        for (int j = 0; j < N-1; j++) {
            cin >> a; a--;
            q[i].push(a);
        }
    }
    int d = 0;
    int cnt = 0;
    queue<int> dq;
    set<int> se;
    for (int i = 0; i < N; i++) {
        if(!q[i].empty() && !q[q[i].front()].empty() && !q[q[q[i].front()].front()].empty() && q[q[q[i].front()].front()].front() == q[i].front() && q[q[i].front()].front() == i){
            se.insert(i);
        }
    }
    while(cnt < N*(N-1)){
        if(se.size() == 0){
            printf("%d\n", -1);
            return 0;
        }
        for (int v : se){
            q[v].pop(); dq.push(v); cnt++;
        }
        d++;
        se.clear();
        while(!dq.empty()){
            int v = dq.front(); dq.pop();
            if(!q[v].empty() && !q[q[v].front()].empty() && !q[q[q[v].front()].front()].empty() && q[q[q[v].front()].front()].front() == q[v].front() && q[q[v].front()].front() == v){
                se.insert(v); se.insert(q[v].front());
            }
        }
    }

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

}

Measured memory_bytes: 8068
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cstdio>
#include <cmath>
#include <tuple>


using namespace std;


int main(int argc, const char *argv[])
{

    int N;
    cin>>N;

    vector<int> vec(N,0);

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

    int count = 0;
    // if(vec[0] < vec[1]) count++;
    // if(vec[N-1] < vec[N-2]) count++;

    for(int i = 1; i < N-1 ; i ++)
    {
        if((vec[i-1]-vec[i])*(vec[i+1]-vec[i]) < 0)
        {
            count++;
            // cout<<vec[i]<<endl;
        }
    }

    cout<<count;
    return 0;
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
#include<sstream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<climits>
#include<cmath>
#include<string>
#include<vector>
#include<set>
#include<map>
#include<queue>
#include<numeric>
#include<functional>
#include<algorithm>
#include<bitset>
#include<tuple>
#include<unordered_set>
#include<random>
#include<array>
#include<cassert>
using namespace std;
#define INF (1<<29)
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(v) v.begin(),v.end()
#define uniq(v) v.erase(unique(all(v)),v.end())


#define MOD 1000000007


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

	int n;
	string s;
	cin >> n >> s;
	
	int cnt[26] = {};
	for (char c: s) {
		cnt[c - 'a']++;
	}
	int ans = 1;
	rep(i,26) {
		ans = (ans * (cnt[i] + 1LL)) % MOD;
	}
	cout << (ans - 1 + MOD) % MOD << endl;


	return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#define ll long long
#define INF INT_MAX 
#define mod 1000000007
using namespace std;
int main(){
    int N;
    cin >> N;
    int H[N];
    for(int i=0;i<N;i++){
        cin >> H[i];
    }
    int ans=0;
    int maxH=0;
    for(int i=0;i<N;i++){
        if(H[i]>=maxH){
            maxH = H[i];
            ans++;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>

int lastIndex(char*);
void charAdd(char*, char*,char*, const int&, const int&);
void outputNumber(char*);

int main(){
	int datasetNumber;
	std::cin >> datasetNumber;
	for (int i = 0; i < datasetNumber; ++i){
		char number1[101];
		char number2[101];
		char sumNumber[102];

		for (int j = 0; j < 101; j++){
			sumNumber[j] = '0';
		}

		std::cin >> number1 >> number2;

		int lastIndex1 = lastIndex(number1);
		int lastIndex2 = lastIndex(number2);

		charAdd(number1, number2, sumNumber, lastIndex1, lastIndex2);
		outputNumber(sumNumber);
	}
}

int lastIndex(char* charNumber){
	int index;
	for (index = 0; charNumber[index + 1] != '\0'; ++index);
	return index;
}

void charAdd(char* number1, char* number2,char* sumNumber,
	const int& lastIndex1, const int& lastIndex2){

	int index1, index2;
	if (lastIndex1 > lastIndex2){
		index1 = lastIndex1;
		index2 = lastIndex2;
	}
	else{
		index1 = lastIndex1;
		index2 = lastIndex2;
	}

	sumNumber[101] = '\0';
	for (int i = lastIndex1, sumIndex = 100;
		i >= 0; --i, --sumIndex){

		sumNumber[sumIndex] += number1[i] - '0';
	}
	for (int j = lastIndex2, sumIndex = 100;
		j >= 0; --j, --sumIndex){

		sumNumber[sumIndex] += number2[j] - '0';
		for (int index = sumIndex; sumNumber[index] > '9'; --index){
			sumNumber[index] -= 10;
			sumNumber[index - 1] += 1;
		}
	}
}

void outputNumber(char* sumNumber){
	int i;
	for (i = 0; sumNumber[i] == '0'; ++i);
	
	if (i <= 20){
		std::cout << "overflow" << std::endl;
	}
	else if (sumNumber[i] == '\0'){
		std::cout << 0 << std::endl;
	}
	else{
		for (int j = i; sumNumber[j] != '\0'; ++j){
			std::cout << sumNumber[j];
		}
		std::cout << std::endl;
	}
}


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

int main() {
	int a,b;cin >>a >>b;
	stringstream ss1,ss2;
	for(int i=0;i<b;++i) ss1 << a;
	for(int j=0;j<a;++j) ss2 << b;
	string s1,s2;
	s1 = ss1.str();
	s2 = ss2.str();
	if(s1>=s2){
		cout << s2 << endl;
	} else {
		cout << s1 << endl;
	}
	return 0;
}

Measured memory_bytes: 256