akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
 
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
#define FOR(i, m, n) for (int i = (m); i < (n); i++)
#define FORR(i, m, n) for (int i = (m); i >= (n); i--)
#define REP(i, n) FOR(i, 0, (n))
#define REPR(i, n) FORR(i, (n) - 1, 0)
#define REP1(i, n) FOR(i, 1, (n) + 1)
#define REPS(c, s) for (char c : s)
#define ALL(c) (c).begin(), (c).end()
#define SORT(c) sort(ALL(c))
#define REV(c) reverse(ALL(c))
#define sz(v) (int)v.size()
#define endl '\n'
template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return false;}
template<class T> inline void printv(vector<T>& v) {int n = sz(v); REP(i, n) cout << v[i] << (i == n - 1 ? endl : ' ');}
template<class T> inline void printlnv(vector<T>& v) {int n = sz(v); REP(i, n) cout << v[i] << endl;}
const int MOD = 1000000007;
const int INF = 1000000001;
const ll LINF = 1000000001000000001LL;
 
void solve();
 
int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(numeric_limits<double>::max_digits10);
    solve();
    return 0;
}

void solve() {
    int n, k;
    cin >> n >> k;
    vl a(n);
    REP(i, n) cin >> a[i];

    ll ans = LINF;
    REP(i, 1 << n) {
        ll c = 0;
        ll t = 0;
        ll p = 0;
        REP(j, n) {
            if ((1 & i >> j) == 1) {
                c++;
                if (p >= a[j]) {
                    t += p - a[j] + 1;
                    p++;
                }
            }
            chmax(p, a[j]);
        }
        if (c < k) continue;
        chmin(ans, t);
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
#include <iostream>
#include <string.h>
#include <stdio.h>
#include <map>
#include <vector>
#include <math.h>
#include <algorithm>
#include <queue>
#include <set>
#include <tuple>
using namespace std;

#define FOR(i,init,a) for(int i=init; i<a; i++)
#define rep(i,a) FOR(i,0,a)
#define rrep(i,a) for(int i=a; i>=0; i--)
#define rep1(i,a) for(int i=1; i<=a; i++)
#define cout1(a) cout << a << endl;
#define cout2(a,b) cout << a << " " << b << endl;
#define cout3(a,b,c) cout << a << " " << b << " " << c << endl;
#define cout4(a,b,c,d) cout << a << " " << b << " " << c << " " << d << endl;
#define mem(a,n) memset( a, n, sizeof(a))
#define all(a) a.begin(),a.end()
#define chmin(a,b) a=min(a,b);
#define chmax(a,b) a=max(a,b);

typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef vector<int> V;
typedef vector<V> VV;
typedef vector<VV> VVV;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LLINF = 1e18;
static const double pi = 3.141592653589793;

int len[200009], chr[200009], nxt[200009][26];

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    string s;
    cin>>s;
    int N=s.size();
    
    rep(i,26) nxt[N+1][i]=N+1;
    int now=-1;
    rrep(i,N){
        len[i]=INF;
        rep(j,26){
            int n=(j==now?i+1:nxt[i+1][j]);
            nxt[i][j]=n;
            if(len[i]>len[n]){
                len[i]=len[n];
                chr[i]=j;
            }
        }
        len[i]++;
        if(i) now=s[i-1]-'a';
    }
    
    string ans;
    int cur=0;
    while(cur<N){
        int j=chr[cur];
        ans+='a'+j;
        cur=nxt[cur][j];
    }
    cout1(ans)
}

Measured memory_bytes: 22548
#include <bits/stdc++.h>
#define sz(arr) (int)arr.size()
#define all(arr) arr.begin(), arr.end()

using namespace std;

void _cin() {}
template <class Head, class... Tail>
void _cin(Head&& head, Tail&&... tail) {
  cin >> head;
  _cin(forward<Tail>(tail)...);
}

#define Cin(T, ...) \
  T __VA_ARGS__;    \
  _cin(__VA_ARGS__)

int main() {
  Cin(string, n);

  int two = 0;
  for (auto e : n) {
    if (e == '2') two++;
  }

  cout << two << endl;

  return 0;
}

Measured memory_bytes: 256
def chooseBig(x, y):
    if x > y:
        return x, x - 1, y
    else:
        return y, x, y - 1

A, B = input().split(' ')
A = int(A)
B = int(B)

sum1, A, B = chooseBig(A, B)
sum2, A, B = chooseBig(A, B)
print(sum1 + sum2)




Measured memory_bytes: 3060
MOD = 10**9 + 7
INF = 10**20
I = lambda:list(map(int,input().split()))
from collections import defaultdict as dd

s = input()
n = len(s)
ans = 0
for i in range(n//2):
    ans += (s[i] != s[n-i-1])
print(ans)

Measured memory_bytes: 3316
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

public class MainClass
{
	public const long Giri = 1000000007;

	public static void Main(string[] args)
	{
		var n = Console.ReadLine().ToInt();
		Console.WriteLine(24 - n + 24);
	}

	static long GCD(long a, long b)
	{
		var v = new[] { a, b };
		while (v[1] != 0) { v = new[] { v[1], v[0] % v[1] }; }
		return v[0];
	}
	public static string[] Input() { return Console.ReadLine().Split(' '); }
	public static int Clamp(int val, int max, int min = 0) { return Math.Min(max, Math.Max(min, val)); }
}

public static class Smarter
{
	public static int ToInt(this string str) { return int.Parse(str); }
	public static long ToLong(this string str) { return long.Parse(str); }
	public static int[] ToInt(this string[] str)
	{
		var r = new int[str.Length];
		for(int i = 0; i < str.Length; i++) r[i] = str[i].ToInt();
		return r;
	 }
}


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

#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 all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fst first
#define snd second

template<class T> bool ckmin(T& a, const T& b) { return b < a ? a = b, 1 : 0; }
template<class T> bool ckmax(T& a, const T& b) { return a < b ? a = b, 1 : 0; }

typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<pii> vii;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

int main() {
  cin.tie(0)->sync_with_stdio(0);
  cin.exceptions(cin.failbit);

  int h, w, m;
  cin >> h >> w >> m;

  set<pii> b;
  vi rows(h), cols(w);
  rep(i,0,m) {
    int r, c;
    cin >> r >> c;
    --r; --c;
    b.emplace(r,c);
    rows[r]++;
    cols[c]++;
  }

  int mi = 0, mj = 0;
  rep(i,0,h) if (rows[i] > rows[mi]) mi = i;
  rep(j,0,w) if (cols[j] > cols[mj]) mj = j;

  vi mis, mjs;
  rep(i,0,h) if (rows[i] == rows[mi]) mis.pb(i);
  rep(j,0,w) if (cols[j] == cols[mj]) mjs.pb(j);

  if (ll(sz(mis)) * ll(sz(mjs)) > ll(m)) return cout << (rows[mi] + cols[mj]) << '\n', 0;

  int ans = 0;
  for (auto i: mis) for (auto j: mjs) {
    ckmax(ans, rows[i] + cols[j] - (b.find(mp(i, j)) != b.end()));
  }
  cout << ans << '\n';
}

Measured memory_bytes: 23836
import sys
import numpy as np
input = sys.stdin.readline

N, K = map(int, input().split())
H = np.array(input().split(), dtype='int32')
dp = np.zeros(N, dtype='int32')
dp[0], dp[1] = 0, np.abs(H[0]-H[1])

for i in range(2, N):
  start = 0  if i<K else i-K # start ~ Kまで
  # numpyなので [start:iの個数]を出力
  dp[i] = np.min(dp[start:i] + np.abs(H[i]-H[start:i]))
print(dp[-1])    

Measured memory_bytes: 21032
#include<stdio.h>
int main(){
  int n;
  int a[100];
  int count=0;
  int i;
  int j;
  int tmp;
  
  scanf("%d",&n);
  
  for(i=0;i<n;i++){
    scanf(" %d",&a[i]);
  }

  for(i=0;i<n;i++){
    for(j=n-1;j>i;j--){
      if(a[j] < a[j-1]){
	tmp = a[j];
	a[j] = a[j-1];
	a[j-1] = tmp;
	count++;
      }
    }
  }
  for(i=0;i<n;i++){
    printf("%d",a[i]);
    if(i != n-1) printf(" ");
  }
  printf("\n");
  printf("%d\n",count);
  return 0;
}



Measured memory_bytes: 2136
#include<bits/stdc++.h>
using namespace std;
string S; int x, y, cnt, flag; bool dp[8009][32009]; vector<int> v1, v2, v3;

bool solve(vector<int>vec,int g ) {
	for (int i = 0; i <= vec.size(); i++) {
		for (int j = 0; j <= 32000; j++) { dp[i][j] = false; }
	}
	dp[0][16000] = true;
	for (int i = 0; i < vec.size(); i++) {
		for (int j = 0; j <= 32000; j++) {
			if (dp[i][j] == false) continue;
			dp[i + 1][j + vec[i]] = true;
			dp[i + 1][j - vec[i]] = true;
		}
	}
	return dp[vec.size()][16000 + g];
}
int main() {
	cin >> S >> x >> y;
	for (int i = 0; i <= S.size(); i++) {
		if (i != S.size() && S[i] == 'F') cnt++;
		else {
			if (flag == 0) v1.push_back(cnt);
			if (flag == 1) v2.push_back(cnt);
			cnt = 0; flag ^= 1;
		}
	}
	x -= v1[0];
	for (int i = 1; i < (int)v1.size(); i++) { v3.push_back(v1[i]); }

	if (solve(v3, x) == true && solve(v2, y) == true) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
}


Measured memory_bytes: 125312
#include<cstdio>
#include<algorithm>
using namespace std;

const int nil=-1;
struct node{
	int parent;
	int degree;
	int left;
	int right;
	int depth;
	int height;
};
node *nodes;int n;

int height_setd(int id, int d) //????????????height, ????????¨??¨??????depth????¨????
{
	int res;
	if( id==nil ){
		res=-1;
	}else{
		nodes[id].depth=d;
		res= nodes[id].height=max(
			1 +height_setd(nodes[id].left, d+1),
		 	1 +height_setd(nodes[id].right, d+1)
		);
	}
	return res;

}
int trackroot(int start){
	int prt=nodes[start].parent;
	if( prt==nil )
		return start;
	else
		return trackroot(prt);
}
int getsib(int id)
{
	int p=nodes[id].parent;
	if( p==nil ){
		return nil;
	}else{
		return nodes[p].left+nodes[p].right-id;
	}
}
void show_preorder(int id)
{
	if(id==nil){
		return;
	}else{
		printf(" %d",id);
		show_preorder(nodes[id].left);
		show_preorder(nodes[id].right);
	}
}
void show_inorder(int id)
{
	if(id==nil){
		return;
	}else{
		show_inorder(nodes[id].left);
		printf(" %d",id);
		show_inorder(nodes[id].right);
	}
}
void show_postorder(int id)
{
	if(id==nil){
		return;
	}else{
		show_postorder(nodes[id].left);
		show_postorder(nodes[id].right);
		printf(" %d",id);
	}
}

int main()
{
	scanf("%d",&n);nodes=new node[n];

	for(int i=0;i<n;i++)
		nodes[i].parent=nodes[i].left=nodes[i].right=nil;
	

	for(int i=0,id,l,r; i<n; i++){
		scanf("%d %d %d",&id,&l,&r);
		if( l!=nil ){
			nodes[id].left=l;
			nodes[l].parent=id;
		}
		if( r!=nil ){
			nodes[id].right=r;
			nodes[r].parent=id;
		}
		if( r!=nil && l!=nil ){
			nodes[id].degree=2;
		}else if( r==nil && l==nil ){
			nodes[id].degree=0;
		}else{
			nodes[id].degree=1;
		}
		l=r=nil;
	}
	int root=trackroot(0);
	height_setd(root, 0);

	printf("Preorder\n");show_preorder(root);printf("\n");
	printf("Inorder\n");show_inorder(root);printf("\n");
	printf("Postorder\n");show_postorder(root);printf("\n");
	
}

Measured memory_bytes: 1044
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define all(c) c.begin(), c.end()
#define FAST ios_base::sync_with_stdio(false) , cin.tie(NULL);
#define pii pair<int,int>
#define pb push_back
#define F first
#define S second
#define endl "\n"
#define bitcnt(n) __builtin_popcountll(n)
#define setpre(n) cout << fixed << setprecision(n)
#define tr(c) for(const auto& x : c )cout << x << " "; cout << "\n";
#define PI acos(-1LL)


#ifdef LOCAL
string to_string(const string& s){
    return '"' + s + '"';
}
string to_string(const char* s) {
    return to_string((string) s);
}
string to_string(bool b) {
    return (b ? "true" : "false");
}
template <typename A, typename B>
string to_string(pair<A, B> p) {
    return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}
template <typename T>
string to_string(T v){
    bool first = true;
    string res = "{";
    for(const auto& x: v){
        if(!first) res+=", ";
        first = false;
        res+=to_string(x);
    }
    res+="}";
    return res;
}
void bug() { cerr << endl; }
template<typename Head, typename... Tail>
void bug(Head H, Tail... T) {
    cerr << " " << to_string(H);
    bug(T...);
}
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", bug(__VA_ARGS__);
#else
#define debug(...) 11
#endif


const int M = 1000000007;
const int N = 2e6 + 5;
const long long INF = 2e9 + 12;


void solve(){
    int x, k , d;
    cin >> x >> k >> d;
    int p1 = min(abs(x)/d, k), p2 = min(k, (abs(x) + d -1 )/d);
    int f1 = x - p1*d, f2 = x - p2*d, f3 = x + p1*d , f4 = x + p2*d;
    if((k - p1)&1LL){
        f1-=d;
        f3+=d;
    }
    if((k - p2)&1LL){
        f2+=d;
        f4-=d;
    }
    cout << min({abs(f1) , abs(f2), abs(f3) , abs(f4)}) << endl;

}
signed main(){
    FAST
#ifdef LOCAL
    clock_t start;
    double duration;
    start = clock();
#endif
    int tc = 1;
//    TODO: check for tc
//    cin >> tc;
    for (int t = 1; t <= tc; t++) {
        solve();
    }
#ifdef LOCAL
    duration = (clock() - start) / (double) CLOCKS_PER_SEC;
    cerr <<"\nTotal time elapsed: "<< duration <<"sec\n";
#endif
}

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

int main() {
  int N;
  cin >> N;
  vector<string> a(N);
  for (int i = 0; i < N; i++) {
    cin >> a.at(i);
  }
  int ans = 0;
  map<string,int> m;
  for (string x : a) {
    if (m.count(x)) {
      ans += 0;
    }
    else {
      m[x] = 1;
      ans++;
    }
  }
  cout << ans <<endl;
}


Measured memory_bytes: 25120
#include<bits/stdc++.h>
#define pb push_back
#define inf 0x3f3f3f3f
#define ll unsigned long long
#define endl '\n'
#define pii pair<int,int>
#define mem(a,val) memset(a,val,sizeof(a))
#define mkp make_pair
#define all(n) (n).begin(),(n).end()
#define speed ios_base::sync_with_stdio(0);cin.tie(0);
using namespace std;
int main(){
	ll h,w;
	cin>>h>>w;
	if(h==1 || w==1) cout<<1<<endl;
	else cout<<((h*w+1)>>1)<<endl;
}

Measured memory_bytes: 3600
#include<iostream>
#include<string>
#include<algorithm>
#include<math.h>
#include<vector>
#include<map>
#include<stack>
#include<queue>

using namespace std;

map<int,int> mp;
map<int,int> color;
    int n,m;
    int a,b;
    int highest[100000];
    int h[100000];
    int nil = 1000000;
    vector<int> G[100000];

void dfs(int u,int hig){
    queue<int> s;
    s.push(u);
    int flag = 1;
    while(!s.empty()){
        int x = s.front();s.pop();
        for(int i=0;i<G[x].size();i++){
            //cout << i << " " << endl;
            int v = G[x][i];
            if(hig <= h[v]){
                flag = 0;
            }
            
            
        }
        if(flag){
            mp[u] ++;
        }
    }


}

int main(){
    cin >> n >> m;
    for(int i=0;i<n;i++) {
        cin >> h[i];
        h[i] = h[i] -1;
    }
    for(int i=0;i<m;i++) {
        cin >> a >> b;
        G[a-1].push_back(b-1);
        G[b-1].push_back(a-1);
    }
    
    int idx = 1;
    for(int i=0;i<n;i++){
        dfs(i,h[i]);
    }
    int ans=0;
    for(int i=0;i<n;i++){
        if(mp[i]!=0) ans++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 13816
#include <iostream>
#include <cassert>

using namespace std;

int main()
{
    int w, h, n;
    cin >> w >> h >> n;

    bool rect[w+1][h+1];
    for (auto i = 1; i <= w; ++i) {
        for (auto j = 1; j <= h; ++j) {
            rect[i][j] = false;
        }
    }

    int x, y, a;
    for (auto i = 0; i < n; ++i) {
        cin >> x >> y >> a;
        switch (a) {
            case 1:
              for (auto j = 1; j <= x; ++j) {
                  for (auto k = 1; k <= h; ++k) {
                    rect[j][k] = true;
                  }
              }
              break;
            case 2:
              for (auto j = x + 1; j <= w; ++j) {
                  for (auto k = 1; k <= h; ++k) {
                    rect[j][k] = true;
                  }
              }
              break;
            case 3:
              for (auto j = 1; j <= w; ++j) {
                  for (auto k = 1; k <= y; ++k) {
                    rect[j][k] = true;
                  }
              }
              break;
            case 4:
              for (auto j = 1; j <= w; ++j) {
                  for (auto k = y + 1; k <= h; ++k) {
                    rect[j][k] = true;
                  }
              }
              break;
            default:
              assert(false);
        }
    }
    int total = 0;
    for (auto i = 1; i <= w; ++i) {
        for (auto j = 1; j <= h; ++j) {
            if (rect[i][j] == false) {
                ++total;
            }
        }
    }
    cout << total << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ld long double
#define sf scanf
#define pf printf
#define pb push_back
#define mp make_pair
#define PI ( acos(-1.0) )
#define pmod 1000000007
#define maxn 100005
#define IN freopen("input.txt","r",stdin)
#define OUT freopen("output.txt","w",stdout)
#define FOR(i,a,b) for(int i=a ; i<=b ; i++)
#define INF 1000000000
#define ll long long int
#define eps (1e-8)
#define sq(x) ( (x)*(x) )

using namespace std;

typedef pair < int, int > pii;
typedef pair < ll, ll > pll;

struct bb{
    int x,y,z;
    double r;
};
struct dt{
    int a,b,c;
};
long double dist(bb a, bb b){
    return sq(a.x-b.x)+sq(a.y-b.y)+sq(a.z-b.z);
}

bool check(bb a,bb b, bb s){
    if (dist(a,s)<sq(s.r)){
        if (dist(b,s)<sq(s.r)) return 0;
        else{
            return 1;
        }
    }
    else{
        if (dist(b,s)<sq(s.r)) return 1;
        else{
            ld m=sqrt(dist(a,b));
            ld n=sqrt(dist(a,s));
            ld p=sqrt(dist(b,s));
            ld S=sqrt((m+n+p)*(m+n-p)*(n+p-m)*(m+p-n)/16);
            ld h=2*S/m;
            if (h>s.r) return 0;
            else{
                ld u=(sq(m)+sq(p)-sq(n));
                ld v=(sq(m)+sq(n)-sq(p))
                ;
                if(v<=0 || u<=0) return 0;
                else return 1;

            }
        }
    }
}
int c[20];
void it(int c[20],ll n){
        FOR (i,0,19) c[i]=0;
        ll ii=1;
        while (n) {
            c[ii]=n%2;n/=2;ii++;
        }
    }
ll mu[20];

int dd[2005];
//ld res=0;
bb s[2005];
bb t[20];
bb e;
vector <int> v[20];
long double f[20];
int l=0;
void th(int n, int m,int k){
  ld  res=0;
         ld q; int u;
        FOR (p,0,mu[m]-1){q=0;u=0;
        //memset(dd,0,sizeof(dd));
        FOR (j,1,2001) {dd[j]=0;}
            it (c,p);
            FOR (j,1,m){
                if (c[j]==1){
                    //s[i]=(s[i]+a[j])%m;
                   if (!v[j].empty()){ FOR (k,0,v[j].size()-1){
                        //if (i==22 && dd[v[j][k]]==0) cout<<v[j][k]<<" ";
                        if (dd[v[j][k]]==0){u++;dd[v[j][k]]++;}
                        }
                    }
                    q+=f[j];
                }
            }
            //cout<<u<<1<<endl;
            //FOR(z,1,n) if (dd[z]==1) {u++;}
            //if (l==2) cout<<p<<" "<<u<<endl;
            if (u<=k) res=max(res,q);
        }
        cout<<fixed<<setprecision(5)<<res<<endl;
    }
int main()
{
cin.tie(NULL);
   mu[0]=1;
    FOR (i,1,20){
        mu[i]=mu[i-1]*2;
    }

while(1){ l++;int n,m,k;
cin>>n>>m>>k;
if (n==0) return 0;
//if (l>=3) return 0;
else { //memset(f,0,sizeof(f));
       // memset(s,0,sizeof(s));
       // memset(t,0,sizeof(t));
        FOR (i,0,19) v[i].clear();
    FOR (i,1,n){
        cin>>s[i].x>>s[i].y>>s[i].z>>s[i].r;
    }
    FOR (i,1,m){
        cin>>t[i].x>>t[i].y>>t[i].z>>t[i].r;

    }
    cin>>e.x>>e.y>>e.z;
    FOR (i,1,m){
        f[i]=(t[i].r)/dist(e,t[i]);
     //   cout<<f[i]<<endl;
    }
    FOR (i,1,n){
        FOR (j,1,m){
            if (check(e,t[j],s[i])==1) {v[j].pb(i);}
         }
    }
th(n,m,k);
//cout<<res<<endl;
}
}
         return 0;
}

Measured memory_bytes: 3360
#include <stdio.h>
#include <iostream>
#include <cassert>
#include <algorithm>
#include <vector>
#include <map>
#include <stack>
#include <queue>
#include <deque>

#define rep(i,a,b) for(int i=(a);i<=(b);i++)
#define irep(i,a,b) for(int i=(a);i>=(b);i--)

using namespace std;
using ll=long long;
using vi=vector<int>;
using vl=vector<ll>;
using pii=pair<int,int>;


const ll MOD = 1000*1000*1000 + 7;
int main(){
  ios::sync_with_stdio(0);
  cin.tie(0);


  ll N, M;
  cin >> N >> M;
  vl tt(N+1, 0);
  rep(i, 0, M-1) {
    ll ai;
    cin >> ai;
    tt[ai] = 1;
  }

  vl dp(N+1);
  dp[0] = 1;
  rep(i, 1,N) {
    dp[i] = 0;
    if (tt[i] == 1) continue;
    if (i>=1 && tt[i-1] == 0) dp[i] = (dp[i] + dp[i-1])  % MOD;
    if (i>=2 && tt[i-2] == 0) dp[i] = (dp[i] + dp[i-2])  % MOD;
  }

  cout << dp[N] << endl;

}


Measured memory_bytes: 1792
//#pragma GCC target ("avx2")
//#pragma GCC optimization ("O3")
//#pragma GCC optimization ("unroll-loops")
#include <bits/stdc++.h>
using namespace std;

#define mem(arr, i) fill(arr, arr + sizeof(arr), i)
#define MEM(arr, i) memset(arr, i, sizeof(arr))
#define Push push_back
#define Pair make_pair
#define ALL(x) x.begin(), x.end()
#define X first
#define Y second
#define ACCEL \
	ios_base::sync_with_stdio(false); \
	cin.tie(NULL); \
	cout.tie(NULL)
typedef unsigned long long ull;
typedef long long lli;
typedef pair<int,int> pii;
typedef pair<lli,lli> pll;
typedef pair<pll,lli> p3l;
typedef vector<int> vcI;
typedef vector<lli> vcL;
typedef vector<pii> vPI;
typedef vector<pll> vPL;
typedef vector<p3l> v3L;
typedef vector<vcL> vvL;
//typedef priority_queue<T> prior_S<T>;
//typedef priority_queue< T, vector<T>, greater<T> > prior_B<T>;
const double PI = 3.141592653589793;
const lli I_MAX = 1LL << 60;
      lli   mod = 1000000007;

/// templates ///

const lli maxN = 2E5;

vcL inv(maxN+5, 1);
vcL fac(maxN+5, 1);

void ADD(lli &x, lli y) {
	x += y;
	if (x >= mod) x -= mod;
	if (x < 0) x += mod;
}

void MUL(lli &x, lli y) {
	x *= y;
	x = (x % mod + mod) % mod;
}

lli mypow(lli b, lli e) {
	lli ans = 1;
	while (e) {
		if (e & 1) MUL(ans, b);
		MUL(b, b);
		e >>= 1;
	}
	return ans;
}

lli modinv(lli n) {
	return mypow(n, mod - 2);
}

void calcInv(lli n) {
	for (int i = 2; i <= n; ++i) {
		inv[i] = (mod - mod / i) * inv[mod % i] % mod;
	}
}

void calcFac(lli n) {
	for (int i = 2; i <= n; ++i) {
		fac[i] = fac[i - 1] * i % mod;
	}
}

lli cm(lli a, lli b) {
	lli ans = 1;
	if (a < b) return 0;

	MUL(ans, inv[fac[a - b]]);
	MUL(ans, inv[fac[b]]);
	MUL(ans, fac[a]);

	return ans;
}

lli Lucas(lli n, lli m) {
	if (m == 0) return 1;
	return cm(n % mod, m % mod) * Lucas(n / mod, m / mod) % mod;
}

lli doLucas(lli n, lli m) {
	calcInv(mod);
	calcFac(mod);
	return Lucas(n, m);
}

/// coding area ///

const lli maxn = 1E5;

void precal() {

	return;
}

void solve() {
	lli n, k, ans = 0;
	cin >> n >> k;
	
	vcL num(n), cal(2005, 0);
	for (int i = 0; i < n; ++i) {
		cin >> num[i];
	}
	
	for (int i = 0; i < n; ++i) {
		++cal[num[i]];
		for (int j = i+1; j < n; ++j) {
			if (num[i] > num[j]) ans += k;
		}
	}
	
	ans %= mod;
	
	lli nowC = 0;
	for (int i = 1; i <= 2000; ++i) {
		ans = (ans + (k * (k - 1) / 2) % mod * cal[i] * nowC) % mod;
		nowC += cal[i];
	}
	
	cout << ans << '\n';
}

int main() {
	precal();
	int t = 1;
	#ifdef LOCAL
		t = INT_MAX;
	#else
		ACCEL;
	#endif
//	cin >> t;
	for (int i = 1; i <= t; ++i) {
//		printf("Case #%d: ", i );
		solve();
	}
	return 0;
}



Measured memory_bytes: 3456
#include<stdio.h>
#define MAX 10000
#define NIL -1
struct Node{
  int p,l,r;
};
struct Node T[MAX];
int n;
void preParse(int a){
  if(a == NIL)return;
  printf(" %d",a);
  preParse(T[a].l);
  preParse(T[a].r);
}
void inParse(int a){
  if(a == NIL)return;
  inParse(T[a].l);
  printf(" %d",a);
  inParse(T[a].r);
}
void postParse(int a){
  if(a == NIL)return;
  postParse(T[a].l);
  postParse(T[a].r);
  printf(" %d",a);
}
int main(){
  int i,v,l,r,root;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    T[i].p = NIL;
  }
  for(i=0;i<n;i++){
    scanf("%d %d %d",&v,&l,&r);
    T[v].l = l;
    T[v].r = r;
    if(l != NIL)T[l].p = v;
    if(r != NIL)T[r].p = v;
  }
  for(i=0;i<n;i++)if(T[i].p == NIL)root = i;
  printf("Preorder\n");
  preParse(root);
  printf("\nInorder\n");
  inParse(root);
  printf("\nPostorder\n");
  postParse(root);
  printf("\n");

  return 0;
}





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

using namespace std;

class BipartiteMatch {
public:
    explicit BipartiteMatch(int N, int M) :
        N(N), M(M), g(N+M), match(N+M, -1), visit(N+M, 0)
    {}
public:
    void addEdge(int a, int b){
        g[a].push_back(b+N);
        g[b+N].push_back(a);
    }
    int maximumMatch(){
        int res = 0;
        fill(match.begin(), match.end(), -1);
        for(int i=0;i<N;i++){
            fill(visit.begin(), visit.end(), 0);
            if(search_(i)) ++res;
        }
        return res;
    }
    int getMatch(int t) const { return t < N ? match[t] - N : match[t]; }
private:
    bool search_(int u){
        if(u < 0) return true;
        for(auto next : g[u]){
            if(visit[next]) continue;
            visit[next] = 1;
            if(search_(match[next])){
                match[u] = next, match[next] = u;
                return true;
            }
        }
        return false;
    }
private:
    const int N, M;
    vector<vector<int>> g;
    vector<int> match;
    vector<int> visit;
};

int main(){
    int N, M; cin >> N >> M;
    vector<vector<int>> A(N, vector<int>(M));
    vector<vector<vector<int>>> val(N, vector<vector<int>>(N));
    for(int i=0;i<N;i++){
        for(int j=0;j<M;j++){
            int a; cin >> a;
            val[i][(a-1)/M].push_back(a);
        }
    }
    vector<vector<int>> B(N);
    vector<vector<int>> C(N);
    for(int i=0;i<M;i++){
        BipartiteMatch bm(N, N);
        for(int j=0;j<N;j++){
            for(int k=0;k<N;k++){
                if(!val[j][k].empty()) bm.addEdge(j, k);
            }
        }
        bm.maximumMatch();
        for(int j=0;j<N;j++){
            int m = bm.getMatch(j);
            int b = val[j][m].back();
            val[j][m].pop_back();
            B[j].push_back(b);
            C[(b-1)/M].push_back(b);
        }
    }
    for(auto& v : B){
        cout << v[0];
        for(int i=1;i<v.size();i++) cout << " " << v[i];
        cout << endl;
    }
    for(auto& v : C){
        cout << v[0];
        for(int i=1;i<v.size();i++) cout << " " << v[i];
        cout << endl;
    }
}

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

#define F first
#define S second
typedef double db;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;


int main(){
  string s;
  cin>>s;
  if(s=="Sunny")cout<<"Cloudy"<<endl;
  else if(s=="Cloudy")cout<<"Rainy"<<endl;
  else cout<<"Sunny"<<endl;
return 0;
}

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

#define pout(n)  printf ("%d\n", n)

#define rep(i,a,n) for (int i = a;i < n;i++)
#define per(i,n,a) for (int i = n-1;i >= a;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());

const int d4x[4] = {1, 0, -1, 0};
const int d4y[4] = {0, 1, 0, -1};
const int d8x[8] = { 1,1,0,-1,-1,-1,0,1 };
const int d8y[8] = { 0,1,1,1,0,-1,-1,-1 };

#define MAX_N (int)2e5+20
#define INF 1e12+20

typedef long long ll;
using namespace std;

int n,a = 0;
string s,t;
int main() {
    cin >> n >> s >> t;
    rep(i,0,n){
        if(s.substr(i) == t.substr(0,n-i)){
            a = n-i;
            break;
        }
    }
    pout(2*n-a);
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <unordered_map>
#include <utility>
#include <algorithm>
#include <cmath>
using namespace std;

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

  double m = sum / n, t = 1000000;

  int ans = -1;
  for(int i=0; i<n; i++){
    if(abs(a[i]-m) < t){
      t = abs(a[i]-m);
      ans = i;
    }
  }

  cout << ans << endl; 

  return 0;
}


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

using namespace std;

constexpr int MX=10000;

int main(){
  int H, W;
  cin >> H >> W;
  
  std::vector<std::vector<bool>> cond(H, std::vector<bool>(W, false));
  for(int i = 0; i < H; i++){
    string s;
    cin >> s;
    for(int j = 0; j < W; j++) cond[i][j] = (s[j] == '.') ? true : false;
  }
  
  std::vector<std::vector<int>> dp(H, std::vector<int>(W, MX));
  dp[0][0] = (cond[0][0] == true) ? 0 : 1;
  
  for(int i = 0; i < H; i++){
    for(int j = 0; j < W; j++){
       if(i == 0 && j == 0) continue;      
       int dpUp   = (i == 0) ? MX : dp[i-1][j];
       int dpLeft = (j == 0) ? MX : dp[i][j-1];                 
       if (cond[i][j] == false){
         if (i != 0 && cond[i-1][j] == true) ++dpUp;
         if (j != 0 && cond[i][j-1] == true) ++dpLeft;         
       }
       dp[i][j] = min(dpUp, dpLeft);
    }
  }
  cout << dp[H-1][W-1];
  return 0;
}

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

using namespace std;

#define rep(i,n) for(int i=0;i<(n);i++)
#define repa(i,a,n) for(int i=(a);i<(n);i++)
#define rrep(i,n) for(int i=n;i>=0;i--)
#define rrepa(i,a,n) for(int i=n;i>=(a);i--)
#define all(a) (a).begin(),(a).end()
#define MOD 1000000007
#define cmax(a,b) a=max(a,b)
#define cmin(a,b) a=min(a,b)
#define vc vector

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<int,int> pi;

int main(){

    int h,w;cin>>h>>w;
    vc<string> s(h);
    rep(i,h)cin>>s[i];

    vvi c(h,vi(w));
    if(s[0][0]=='#')c[0][0]=1;
    repa(i,1,w)(s[0][i]==s[0][i-1])?c[0][i]=c[0][i-1]:c[0][i]=c[0][i-1]+1;
    repa(i,1,h)(s[i][0]==s[i-1][0])?c[i][0]=c[i-1][0]:c[i][0]=c[i-1][0]+1;

    repa(i,1,h){
        repa(j,1,w){
            c[i][j]=min(
                ((s[i-1][j]==s[i][j])?c[i-1][j]:c[i-1][j]+1),
                ((s[i][j-1]==s[i][j])?c[i][j-1]:c[i][j-1]+1)
                );
        }
    }

    cout<<(c[h-1][w-1]+1)/2<<"\n";

    return 0;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
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

#define int long long
#define pii pair<int, int>
#define ff first
#define ss second
#define MP make_pair
#define PB emplace_back
#define all(x) (x).begin(), (x).end()
#define IOS ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

const int INF = 1e18L;
const double eps = 1e-9;
const int mod = 1e9 + 7;

int32_t main()
{
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    IOS;
    string s;
    cin>>s;
    if(s[2] == s[3] && s[4] == s[5]) cout<<"Yes\n";
    else cout<<"No\n";
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

void Answer(int A[], int N, int count){
    int i;
    for ( i = 0; i < N; i++ ){
        if ( i > 0 ) printf(" ");
        printf("%d", A[i]);
    }
    printf("\n%d\n", count);
}

void bubbleSort(int A[], int N){
    int i, j, temp, count;
    count = 0;
    for (i = N - 1; i >= 0; i-- ){
        for ( j = 0; j < i; j++ ){
            if (A[j] > A[j + 1]) {
                temp = A[j];
                A[j] = A[j + 1];
                A[j + 1] = temp;
                count++;
            }
        }
    }
    Answer(A, N, count);
}

int main(){
    int N, i;
    int A[100];
    scanf("%d", &N);
    for (i = 0; i < N; i++) scanf("%d", &A[i]);
    bubbleSort(A, N);
    return 0;
}


Measured memory_bytes: 2692
#include <bits/stdc++.h>
#define GET_REP(_1, _2, _3, NAME, ...) NAME
#define rep(...) GET_REP(__VA_ARGS__, irep, _rep)(__VA_ARGS__)
#define rep1(...) GET_REP(__VA_ARGS__, irep1, _rep1)(__VA_ARGS__)
#define _rep(i, n) irep (i, 0, n)
#define _rep1(i, n) irep1(i, 1, n)
#define irep(i, a, n) for (int i = a; i < (int)(n); ++i)
#define irep1(i, a, n) for (int i = a; i <= (int)(n); ++i)
#define rrep(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define rrep1(i, n) for (int i = (int)(n); i >= 1; --i)
#define allrep(X, x) for (auto &&X : x)
#define all(x) begin(x), end(x)
#ifdef LOCAL
  #include "../../Lib/cout_container.hpp"
  #define debug(x) cout << #x " => " << (x) << endl
#else
  #define debug(x) 0
#endif
using lint = long long;
constexpr int    INF  = 1 << 28;
constexpr lint   INFL = 1LL << 60;
constexpr int    MOD  = (int)1e9 + 7;
constexpr double EPS  = 1e-9;
using namespace std;
namespace { struct INIT { INIT() { cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(15); } } INIT; }

int main(void) {
  int n;
  cin >> n;
  vector<double> x(n), y(n);
  rep (i, n) cin >> x[i] >> y[i];
  int fac = 1;
  rep1 (i, n) fac *= i;
  double ans = 0;
  rep (i, n) {
    double sum = 0;
    rep (j, n) {
      if (i == j) continue;
      sum += hypot(x[i] - x[j], y[i] - y[j]);
    }
    ans += sum / n;
  }
  cout << ans << endl;
  return 0;
}

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

using namespace std;

using ll = long long;
using ld = long double;
using vl = vector<ll>;
using vvl = vector<vl>;
using vb = vector<bool>;
using P = pair<ll, ll>;
template<typename T> using pq = priority_queue<T>;
template<typename T> using minpq = priority_queue<T, vector<T>, greater<T>>;
template<typename T, typename K> using ump = unordered_map<T, K>;
const ll dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
const ll mod = 1000000007;
const ll inf = ll(1e9);
const ll e5 = ll(1e5);
const ll ll_inf = ll(1e9) * ll(1e9);

#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define repr(i, n) for (ll i = ll(n - 1); i >= 0; i--)
#define each(i, mp) for (auto &i : mp)
#define eb emplace_back
#define F first
#define S second
#define all(obj) (obj).begin(), (obj).end()

template<class T>
ostream &operator<<(ostream &out, const vector<T> &list) {
    ll n = list.size();
    rep(i, n) out << list[i] << ' ';
    return out;
}

template<class T>
istream &operator>>(istream &in, vector<T> &list) {
    ll n = list.size();
    rep(i, n) in >> list[i];
    return in;
}

template<class T>
ostream &operator<<(ostream &out, const vector<vector<T>> &list) {
    ll n = list.size();
    rep(i, n) out << list[i] << '\n';
    return out;
}

/* ------------- ANSWER ------------- */
/* ---------------------------------- */

void solve() {
    ll x, y;
    cin >> x >> y;
    rep(i, x + 1) {
        ll kame = i;
        ll tsuru = x - i;
        if (i * 4 + (x - i) * 2 == y) {
            cout << "Yes" << '\n';
            return;
        }
    }
    cout << "No" << '\n';
}

int main() {
#ifdef MY_DEBUG
    while (true) {
#endif
        solve();
#ifdef MY_DEBUG
    }
#endif
    return 0;
}


Measured memory_bytes: 3592
#include<iostream>
using namespace std;
int dp[10][2][8];
int main(){
	string n;
	cin >> n;
	dp[0][0][0]=1;
	for(int i=1;i<n.length();i++)dp[i][1][0]=1;
	int flag[8]={};
	int bit[8];
	bit[3]=1,bit[5]=2,bit[7]=4;
	flag[0]=1;
	for(int i=1;i<=n.length();i++){
		for(int j=0;j<2;j++){
			for(int k=0;k<8;k++){
				for(int l=3;l<=7;l+=2){
					if(!(j||(n[i-1]-'0')>=l)) continue;
					if(flag[k]){
						dp[i][j||((n[i-1]-'0')>l)][k|bit[l]]+=dp[i-1][j][k];
					}
				}
			}
		}
		for(int j=0;j<8;j++) if(flag[j]) flag[j|1]=1,flag[j|2]=1,flag[j|4]=1;
	}
	cout << dp[n.length()][0][7]+dp[n.length()][1][7] << endl;
	return 0;
}


Measured memory_bytes: 256
S1_str = str(input())
S1 = list(S1_str)
S2 = list(S1_str)

num1 = 0

for i in range(len(S1) - 1):
    if S1[i] == S1[i + 1]:
        S1[i + 1] = str((int(S1[i]) + 1) % 2)
        num1 += 1

num2 = 1
S2[0] = str((int(S2[0]) + 1) % 2)
for i in range(len(S2) - 1):
    if S2[i] == S2[i + 1]:
        S2[i + 1] = str((int(S2[i]) + 1) % 2)
        num2 += 1

if num1 > num2:
    print(num2)
else:
    print(num1)



Measured memory_bytes: 59760
#include <stdio.h>
long long a [100010];
int main (){
int n;
scanf("%d",&n);
for(int i=0;i<n;i++) scanf("%lld",&a[i]);
int zero =0;

for(int i=0;i<n;i++)if(a[i]==0) zero ++;
if(zero >0){
// a[i] contains 0
printf("0\n");
return 0;
}
long long prod =1;
for(int i=0;i<n;i++){
if(a[i ] <=1000000000000000000/ prod ){
// This condition is equivalent to prod*a[i] <=10ˆ18
prod *=a[i];
}else{
printf("-1\n");
return 0;
}
}
printf("%lld\n",prod );
}


Measured memory_bytes: 2488
#include <iostream>

using namespace std;

int main()
{
	int A, B, C, D;
	cin >> A >> B >> C >> D;

	for (;;) {
		C -= B;
		if (C <= 0) {
			cout << "Yes" << endl;
			break;
		}
		A -= D;
		if (A <= 0) {
			cout << "No" << endl;
			break;
		}
	}
}


Measured memory_bytes: 3636
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <cmath>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <stdlib.h>
#include <stdio.h>
#include <bitset>
#include <cstring>
#include <deque>
using namespace std;
#define FOR(I,A,B) for(int I = (A); I < (B); ++I)
#define CLR(mat) memset(mat, 0, sizeof(mat))
typedef long long ll;
const int N = 2002 * 2002;
bitset<N> bs;
int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  int sum = 0;
  bs.set(0);
  FOR(i,0,n) {
    int a; cin >> a;
    bs |= bs << a;
    sum += a;
  }
  FOR(i,(sum+1)/2,N) {
    if(bs[i]) {
      cout << i << endl;
      return 0;
    }
  }
}

Measured memory_bytes: 1792
#include <iostream>

using namespace std;

int main() {
    int n;
    cin >> n;
    int s = 0, m = 0;
    for (int i = 0; i < n; i++) {
        int l;
        cin >> l;
        s += l;
        if (l > m) {
            m = l;
        }
    }

    cout << (m * 2 < s ? "Yes" : "No") << endl;

    return 0;
}

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

int main() {
	string O, E;
	cin >> O >> E;
	for (int i = 0; i < E.size(); i++) {
		cout << O[i] << E[i];
	}
	if (O.size() == E.size() + 1) {
		cout << O[O.size()-1];
	}
	cout << endl;
}


Measured memory_bytes: 256
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}
fn main(){
    input!{
        an:[i64;5],
        ka:i64,
    }
    for j in 0..5{
        for k in j..5{
            if (an[k]-an[j]) > ka{
                println!(":(");
                return;
            }
        }
    }
    println!("Yay!");
}

Measured memory_bytes: 4352
N, M = map(int, input().split())
kv = {}
lst = []
for _ in range(M):
    x, y = map(int, input().split())
    lst.append("{0} {1}".format(x, y))
    if x in kv:
        kv[x][y] = 1
    else:
        kv[x] = {y:1}

for k1 in sorted(kv.keys()):
    keys = sorted(kv[k1].keys())
    for idx, k2 in enumerate(keys, 1):
        kv[k1][k2] = idx

for s in lst:
    x, y = map(int, s.split())
    print("{0:06d}{1:06d}".format(x,kv[x][y]))

Measured memory_bytes: 54348
#include<bits/stdc++.h>
using namespace std;
#define int long long
signed main(){
  int n;
  cin>>n;
  int s[n][3];
  map<int,int> m[3];
  for(int i=0;i<n;i++){
    for(int j=0;j<3;j++){
      cin>>s[i][j];
      m[j][s[i][j]]++;
    }
  }
  
  for(int i=0;i<n;i++){
    int tmp=0;
    for(int j=0;j<3;j++){
      if(m[j][s[i][j]]==1) tmp+=s[i][j];
    }
    cout<<tmp<<endl;
  }
  
  return 0;
}

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

int main( int argc, char** argv )
{
  size_t n;
  int minh;
  size_t sum = 0;
  std::cin >> n;
  std::cin >> minh;
  for( size_t i = 1; i < n; ++i ) {
    int x;
    std::cin >> x;
  	if( x < minh ) {
    	sum += ( minh - x );
    } else if( x > minh ) {
    	minh = x;
    }
  }
  std::cout << sum << "\n";
  return 0;
}

Measured memory_bytes: 3108
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define zero_pad(num) setfill('0') << std::right << setw(num)
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;

int main() {
    int k;
    cin >> k;
    vector<vector<int>> dp(10, vector<int>(10, 0));
    rep(i, 10)rep(j, 10){
        if(i == 0){
            dp[i][j] = 1;
        }else{
            if(j == 0) {
                dp[i][j] = dp[i - 1][0] + dp[i - 1][1];
            }else if(j == 9){
                dp[i][j] = dp[i - 1][8] + dp[i - 1][9];
            }else{
                dp[i][j] = dp[i - 1][j - 1] + dp[i-1][j] + dp[i-1][j+1];
            }
        }
    }

    int sum = 0;
    string ans = "";
    rep(i, 10){
        for(int j = 1; j < 10; j++){
            if(sum < k && sum + dp[i][j] >= k){
                while(i >= 0){
                    ans += to_string(j);
                    i--;
                    if(i < 0) {
                        cout << ans << endl;
                        return 0;
                    }
                    for(int l = max(0, j - 1); l <= min(9, j + 1); l++){
                        if(sum + dp[i][l] < k) sum += dp[i][l];
                        else {
                            j = l;
                            break;
                        }
                    }
                }
            }else{
                sum += dp[i][j];
            }
        }
    }
}

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

int a, b, c;

int main(){
  cin >> a >> b >> c;
  cout << a * b / 2 << endl;
}


Measured memory_bytes: 3608
#include <iostream>

using namespace std;

int main(int argc, char *argv[])
{
  int a, b, c;
  cin >> a >> b >> c;
  bool kawaisou = !(a == b && b == c && c == a) && !(a != b && b != c && c != a);
  if (kawaisou) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,x,y) for(int i=x,i##end=y;i<=i##end;++i)
#define _rep(i,x,y) for(int i=x,i##end=y;i>=i##end;--i)
#define ll long long
typedef std::pair<int,int> pii;
inline bool up(int&x,const int y){return x<y?x=y,1:0;}
inline bool down(int&x,const int y){return x>y?x=y,1:0;}
const int mod=998244353;
#define N 200005
int n,q;
ll pw[N],sum[N];
inline void reduce(ll&x){
	x-=mod,x+=x>>31&mod;
}
struct node{
	int l,r; mutable int v;
	inline node(int L,int R=-1,int V=0):l(L),r(R),v(V){}
	inline bool operator<(const node&x)const{
		return l<x.l;
	}
};
#define It std::set<node>::iterator
std::set<node> s;
inline It split(int p){
	It it=s.lower_bound(node(p));
	if(it!=s.end()&&it->l==p) return it;
	--it;
	int l=it->l,r=it->r,v=it->v;
	s.erase(it);
	s.insert(node(l,p-1,v));
	return s.insert(node(p,r,v)).first;
}
ll ret=0;
inline void assign(int L,int R,int val){
	It r=split(R+1),l=split(L);
	for(It i=l;i!=r;++i){
		int v=i->v,_l=i->l,_r=i->r;
		reduce(ret+=mod-(sum[_r]-sum[_l-1]+mod)*v%mod);
//		std::cerr<<"C: "<<(i->l)<<' '<<(i->r)<<' '<<v<<'\n';
	}
	s.erase(l,r);
	reduce(ret+=(sum[R]-sum[L-1]+mod)*val%mod);
	s.insert(node(L,R,val));
}
int main(){
	std::ios::sync_with_stdio(0);
	std::cin>>n>>q;
	pw[n]=1;
	_rep(i,n-1,1) pw[i]=pw[i+1]*10%mod;
	rep(i,1,n) reduce(sum[i]=sum[i-1]+pw[i]);
	ret=sum[n];
	s.insert(node(1,n,1));
	while(q--){
		int l,r,d; std::cin>>l>>r>>d;
		assign(l,r,d);
		std::cout<<ret<<'\n';
	}
	return 0;
}

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

typedef struct Node {
    int key;
    struct Node *prev, *next;
} Node;

Node *nil;

void init(){
    nil = (Node *)malloc(sizeof(Node));
    nil->next = nil;
    nil->prev = nil;
}

void insert(int val){
    Node *x = (Node *)malloc(sizeof(Node));
    x->key = val;
    x->next = nil->next;
    nil->next->prev = x;
    x->prev = nil;
    nil->next = x;
}

Node* listSearch(int val){
    Node *cur=nil->next;
    while(cur != nil && cur->key != val){
        cur=cur->next;
    }
    return cur;
}

void deleteNode(Node *cur){
    if(cur==nil) return;
    cur->prev->next=cur->next;
    cur->next->prev=cur->prev;
    free(cur);
}

void deleteFirst(){
    deleteNode(nil->next);
}

void deleteLast(){
    deleteNode(nil->prev);
}

void deleteKey(int val){
    deleteNode(listSearch(val));
}


void trace(){
    int i=0;
    Node *cur=nil->next;
    while(cur != nil){
        if(i>0) printf(" ");
        printf("%d", cur->key);
        i++;
        cur=cur->next;
    }
    printf("\n");
}
int main(){
    int num, i, value;
    char s[100];
    scanf("%d", &num);
    init();
    for(i=0; i<num; i++){
        scanf("%s%d", s, &value);
        if(!strcmp(s, "deleteFirst")) deleteFirst();
        else if(!strcmp(s, "deleteLast")) deleteLast();
        else if(!strcmp(s, "insert")){
            insert(value);
        }else{
            deleteKey(value);
        }
    }
    trace();
    return 0;
}

Measured memory_bytes: 32992
N=int(input())
A = [int(i) for i in input().split()]
Rzero = sum(A)
#雨[0]を求める
for i in range(1,N,2):
    Rzero -= A[i]*2
Rain = [0]*N
Rain[0] = Rzero
for i in range(1,N):
    Rain[i] = (2*A[i-1] - Rain[i-1])
print(*Rain)

Measured memory_bytes: 64612