akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define inf 1000000000
#define INF 1000000000000000
#define ll long long
#define ull unsigned long long
#define M (int)(1e9+7)
#define P pair<int,int>
#define PLL pair<ll,ll>
#define FOR(i,m,n) for(int i=(int)m;i<(int)n;i++)
#define RFOR(i,m,n) for(int i=(int)m;i>=(int)n;i--)
#define rep(i,n) FOR(i,0,n)
#define rrep(i,n) RFOR(i,n,0)
#define all(a) a.begin(),a.end()
#define IN(a,n) rep(i,n){ cin>>a[i]; }
const int vx[4] = {0,1,0,-1};
const int vy[4] = {1,0,-1,0};
#define PI 3.14159265
#define F first
#define S second
#define PB push_back
#define EB emplace_back
#define int ll
void init(){
  cin.tie(0);
  ios::sync_with_stdio(false);
}




template< typename T >
struct edge {
  int src, to;
  T cost;

  edge(int to, T cost) : src(-1), to(to), cost(cost) {}

  edge(int src, int to, T cost) : src(src), to(to), cost(cost) {}

  edge &operator=(const int &x) {
    to = x;
    return *this;
  }

  operator int() const { return to; }
};

template< typename T >
using Edges = vector< edge< T > >;
template< typename T >
using WG = vector< Edges< T > >;
using UG = vector< vector< int > >;
template< typename T >
using Matrix = vector< vector< T > >;



struct UnionFind
{

  vector<int> par;
  vector<int> sizes;

  UnionFind(int n) : par(n), sizes(n, 1) {
    rep(i,n) par[i] = i;
  }

  int find(int x) {
    if (x == par[x]) return x;
    return par[x] = find(par[x]); 
  }

  bool unite(int x, int y) {

    x = find(x);
    y = find(y);

    if (x == y) return false;

    if (sizes[x] < sizes[y]) swap(x, y);

    par[y] = x;
    sizes[x] += sizes[y];

    return true;
  }

  int size(int x) {
    return sizes[find(x)];
  }
};


template<typename T>
T kruskal(Edges<T> &es,int n) {
  sort(all(es),[](const edge<T> & a,const edge<T> &b){
      return (a.cost < b.cost);
      });

  UnionFind uf(n);
  T min_cost = 0;

  for(auto &e:es) {
    if(uf.unite(e.src,e.to)) 
      min_cost += e.cost;
  }

  return min_cost;
}



main(){
  int n;
  cin>>n;
  vector<P> x,y;

  rep(i,n){
    int a,b;
    cin>>a>>b;
    x.PB(P(a,i));
    y.PB(P(b,i));
  }

  sort(all(x));
  sort(all(y));

  Edges<int> es;
  rep(i,n-1){
    P p=x[i+1],q=x[i];
    es.PB(edge<int>(p.S,q.S,abs(p.F-q.F)));
    es.PB(edge<int>(q.S,p.S,abs(p.F-q.F)));
    p=y[i+1],q=y[i];
    es.PB(edge<int>(p.S,q.S,abs(p.F-q.F)));
    es.PB(edge<int>(q.S,p.S,abs(p.F-q.F)));
  }

  cout<<kruskal(es,n)<<endl;
}


Measured memory_bytes: 19164
def main():
    colors = ['R', 'G', 'B']
    N = int(input())
    S = input()
    
    ans = 0
    cnts = {'R': [], 'G': [], 'B': []}
    if S[-1] == 'R':
        cnts = {'R': [1], 'G': [0], 'B': [0]}
    elif S[-1] == 'G':
        cnts = {'R': [0], 'G': [1], 'B': [0]}
    else:
        cnts = {'R': [0], 'G': [0], 'B': [1]}

    for i, s in enumerate(S[::-1][1:]):
        for color in colors:
            if s == color:
                cnts[color].append(cnts[color][i] + 1)
            else:
                cnts[color].append(cnts[color][i])

    for color in colors:
        cnts[color] = cnts[color][::-1]

    for i in range(N-2):
        for j in range(i+1, N-1):
            if S[i] == S[j]:
                continue
            oth = colors[:]
            oth.remove(S[i])
            oth.remove(S[j])
            oth = oth[0]
            cnt = cnts[oth][j+1]
            ans += cnt
            if j + (j - i) < N:
                if S[j + (j - i)] == oth:
                    ans -= 1
            
    print(ans)


if __name__ == "__main__":
    main()

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

namespace _136C
{
    class Program
    {
        static public int n;
        static void Main(string[] args)
        {
            n = int.Parse(Console.ReadLine());
            int[] h = Console.ReadLine().Split(' ').Select(str => int.Parse(str)).ToArray();

            bool ans = true;
            int kijun=h[0];

            for (int a = 1; a < n; a++)
            {
                if (h[a]>kijun)
                {
                    kijun = h[a]-1;
                }else if (h[a] == kijun)
                {
                    kijun = h[a];
                }else if (h[a] < kijun)
                {
                    if (h[a] - kijun < 0)
                        ans = false;
                }
            }

            if (ans)
                Console.WriteLine("Yes");
            else Console.WriteLine("No");
        }
    }
}

Measured memory_bytes: 28252
#include<cstdio>

int n, m;

int main() {
	scanf("%d%d", &n, &m);
	for(int i = 1; i * 2 <= m; ++i)
		printf("%d %d\n", i, m - i + 1);
	for(int i = 1; i * 2 <= m + 1; ++i)
		printf("%d %d\n", m + i, 2 * m - i + 2);
}

Measured memory_bytes: 1736
#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;
int main()
{
	int a[6],b[6],c[6],asum,bsum,csum;
	for(int i=0;i<6;i++)
		cin>>a[i];
	for(int i=0;i<6;i++)
		cin>>b[i];
	for(int i=0;i<6;i++)
		cin>>c[i];
	asum=(a[3]*3600+a[4]*60+a[5])-(a[0]*3600+a[1]*60+a[2]);
	bsum=(b[3]*3600+b[4]*60+b[5])-(b[0]*3600+b[1]*60+b[2]);
	csum=(c[3]*3600+c[4]*60+c[5])-(c[0]*3600+c[1]*60+c[2]);
	cout<<asum/3600<<" "<<(asum%3600)/60<<" "<<asum%3600%60<<endl;
	cout<<bsum/3600<<" "<<(bsum%3600)/60<<" "<<bsum%3600%60<<endl;
	cout<<csum/3600<<" "<<(csum%3600)/60<<" "<<csum%3600%60<<endl;
	return 0;
}


Measured memory_bytes: 3076
/*
Author: CNYALI_LK
LANG: C++
PROG: abc.cpp
Mail: cnyalilk@vip.qq.com
*/
#include<bits/stdc++.h>
#define debug(...) fprintf(stderr,__VA_ARGS__)
#define DEBUG printf("Passing [%s] in LINE %d\n",__FUNCTION__,__LINE__)
#define Debug debug("Passing [%s] in LINE %d\n",__FUNCTION__,__LINE__)
#define all(x) x.begin(),x.end()
using namespace std;
const double eps=1e-8;
const double pi=acos(-1.0);
typedef long long ll;
typedef pair<int,int> pii;
template<class T>int chkmin(T &a,T b){return a>b?a=b,1:0;}
template<class T>int chkmax(T &a,T b){return a<b?a=b,1:0;}
template<class T>T sqr(T a){return a*a;}
template<class T>T mmin(T a,T b){return a<b?a:b;}
template<class T>T mmax(T a,T b){return a>b?a:b;}
template<class T>T aabs(T a){return a<0?-a:a;}
#define min mmin
#define max mmax
#define abs aabs
int read(){
	int s=0,base=1;
	char c;
	while(!isdigit(c=getchar()))if(c=='-')base=-base;
	while(isdigit(c)){s=s*10+(c^48);c=getchar();}
	return s*base;
}
char WriteIntBuffer[1024];
template<class T>void write(T a,char end){
	int cnt=0,fu=1;
	if(a<0){putchar('-');fu=-1;}
	do{WriteIntBuffer[++cnt]=fu*(a%10)+'0';a/=10;}while(a);
	while(cnt){putchar(WriteIntBuffer[cnt]);--cnt;}
	putchar(end);
}
int a[128];
int main(){
#ifdef cnyali_lk
	freopen("abc.in","r",stdin);
	freopen("abc.out","w",stdout);
#endif
	int n,d,x;
	n=read();d=read();x=read();
	for(int i=1;i<=n;++i){
		++x;
		a[i]=read();
		x+=(d-1)/a[i];
	}
	printf("%d\n",x);
	return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pb push_back
#define fst first
#define snd second
#define fore(i,a,b) for(int i=a,ggdem=b;i<ggdem;++i)
#define SZ(x) ((int)x.size())
#define ALL(x) x.begin(),x.end()
#define mset(a,v) memset((a),(v),sizeof(a))
#define FIN ios::sync_with_stdio(0);cin.tie(0);cout.tie(0)
using namespace std;
typedef long long ll;

ll a[3030];

ll MOD=998244353;

ll dp[3030][3030];

ll n,s,inv,nn; 

ll be(ll b, ll e, ll mod){
  ll r=1;
  while(e)if(e&1)r=(r*b)%mod,e^=1; else b=(b*b)%mod,e/=2;
  return r;
}

ll f(ll x, ll y){
	if(y<0)return 0;
	ll &r=dp[x][y];
	if(r>=0)return r;
	if(x==n)return r=(y==0);
	r=(2ll*f(x+1,y)+f(x+1,y-a[x]))%MOD;
	//cout<<x<<" "<<y<<" "<<r<<"\n";
	return r;
}

int main(){FIN;
	cin>>n>>s;
	fore(i,0,n)cin>>a[i];
	mset(dp,-1);
	inv=be(2,MOD-2,MOD),nn=be(2,n,MOD-2);
	cout<<f(0,s);
	
	return 0;
}

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

int main()
{
  string S;
  cin >> S;
  
  vector<char> vec(3);
  for(int i = 0; i < 3; i++)
    vec.at(i) = S.at(i);
  
  sort(vec.begin(), vec.end());
  vector<char> vec2 = {'a', 'b', 'c'};
  if(vec == vec2)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
const int M = 1000000007;
#define pb push_back
#define fs fist
#define sc second
#define forn(i,n) for(int i = 0; i < n; ++i)
#define nfor(i,n) for(int i = n; i >= 0; --i)
#define vi vector<int>
#define pii pair<int,int>
#define all(arr) arr.begin(), arr.end()
#define endl '\n'
ll freq[500001] = {0};
ll distinct = 0;
struct query{
	int L;
	int R;
	int id;
	int block;
	bool operator < (query & q2){
		if(block < q2.block) return 1;
		else if(block > q2.block) return 0;
		else return R < q2.R;
	}
};
void Add(ll elem){
	//distinct -= freq[elem] * freq[elem] * elem;
	if(freq[elem] == 0) distinct++;
	freq[elem]++;
//	distinct += freq[elem] * freq[elem] * elem;
}
void Remove(ll elem){
	//distinct -= freq[elem] * freq[elem] * elem;
	if(freq[elem] == 1) distinct--;
	freq[elem]--;
	//distinct += freq[elem] * freq[elem] * elem;
}
void adjust(int &curr_l,int &curr_r,query &q,vector<int> &arr){
	while(curr_l < q.L){
		Remove(arr[curr_l]);
		curr_l++;
	}
	while(curr_l > q.L){
		curr_l--;
		Add(arr[curr_l]);
	}
	while(curr_r < q.R){
		curr_r++;
		Add(arr[curr_r]);
	}
	while(curr_r > q.R){
		Remove(arr[curr_r]);
		curr_r--;
	}
}
void solve(vector<query> queries, vector<int> &arr){
	vector<ll> answer(queries.size());
	sort(queries.begin(),queries.end());
	int curr_l = queries[0].L;
	int curr_r = queries[0].R;
	for(int i = queries[0].L; i <= queries[0].R; ++i){
		Add(arr[i]);
	}
	answer[queries[0].id] = distinct;
	for(int i = 1; i < queries.size(); ++i){
		adjust(curr_l,curr_r,queries[i],arr);
		answer[queries[i].id] = distinct;
	}
	for(auto x : answer) cout << x << '\n';
}
int main(){
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    int n; cin >> n;
    int q; cin >> q;
    vector<int> arr(n);
    forn(i,n) cin >> arr[i];
    int rootN = sqrt(n);
    vector<query> queries(q);
    forn(i,q){
    	int u,v; cin >> u >> v;
    	queries[i].L = u - 1;
    	queries[i].R = v - 1;
    	queries[i].id = i;
    	queries[i].block = u/rootN;
	}
	solve(queries,arr);
    return 0;
}


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

namespace Practice
{
    class Program
    {
        static void Main(string[] args)
        {
            Solve();
        }
        private const int MOD = 1000000007;
        static void Solve()
        {
            int d = ReadAndParseInt();
            var list = new List<int>();
            for(int i=0;i<d;++i)
            {
                list.Add(ReadAndParseInt());
            }
            list.Sort();
            list[list.Count - 1] /= 2;
            int ans = list.Sum();
            Console.WriteLine(ans);
        }

        #region よく使う便利関数
        private static bool isPrime(long x)
        {
            if (x == 2) { return true; }
            if (x < 2 || x % 2 == 0) { return false; }
            long i = 3;
            while (i * i <= x)
            {
                if (x % i == 0) { return false; }
                i = i + 2;
            }
            return true;
        }
        private static long lcm(long x, long y)
        {
            return x / gcd(x, y) * y;
        }
        private static long gcd(long x, long y)
        {
            return y > 0 ? gcd(y, x % y) : x;
        }
        private static long pow(long x, long n)
        {
            if (n == 0) { return 1; }
            long res = pow(x * x % MOD, n / 2);
            if (n % 2 == 1)
            {
                res = res * x % MOD;
            }
            return res;
        }
        private static int ReadAndParseInt()
        {
            return int.Parse(Console.ReadLine());
        }
        private static int[] ReadAndParseIntArr()
        {
            return Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
        }
        private static long ReadAndParseLong()
        {
            return long.Parse(Console.ReadLine());
        }
        private static long[] ReadAndParseLongArr()
        {
            return Array.ConvertAll(Console.ReadLine().Split(' '), long.Parse);
        }
        #endregion
    }
}

Measured memory_bytes: 13268
#include <iostream>
#include <cstring>
#include <map>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <set>
#include <vector>
#include <queue>
#include <list>
#include <numeric>
#include <stdio.h>
#include <string>
#include <cstdlib>
#include <math.h>
#include <stack>
#include <climits>
#include <bitset>

using namespace std;
typedef long long ll;

int gcd(int x, int y) {
  if (x < y) swap(x, y);
  while (y > 0) {
    int r = x % y;
    x = y;
    y = r;
  }
  return x;
}

//for(int i = ; i < ; i++){}

int main(){
    int n;
    cin>>n;
    int a[n];
    int b[n];
    for(int i = 0; i<n; i++){
        cin>>a[i];
        b[i]=a[i]-(i+1);
    }
    sort(b,b+n);
    int mid;
    if(n%2!=0) mid=b[(n-1)/2];
    else mid = (b[n/2]+b[(n-2)/2])/2;
    ll sum = 0;
    for(int i = 0; i<n; i++){
        sum+=abs(b[i]-mid);
    }
    cout<<sum<<endl;
    return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define repb(i, a, b) for(int i = a; i >= b; i--)
#define all(a) a.begin(), a.end()
#define int long long
using namespace std;
typedef pair<int, int> P;

string change_to_s(int n){
    stringstream ss; ss<<n;
    return ss.str();
}

signed main(){
    int n, k;
    cin >> n >> k;
    vector<int> d(k);
    rep(i, 0, k) cin >> d[i];
    int ans = -1;
    rep(i, n, 100000){
        bool f = true;
        string s = change_to_s(i);
        rep(j, 0, s.size()){
            rep(l, 0, d.size()){
                if(s[j] - '0' == d[l]) f = false;
            }
        }
        if(f){
            ans = i;
            break;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(){
	int a,b,c;
	int ans=0;
	cin>>a>>b>>c;
	for(int i=a;i<=b;i++){
		if(c%i==0){
			ans++;
		}
	}
	cout<<ans<<endl;
	return 0;
}

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

int main(void)
{
	int n;
	int m;
	int data[1000];
	int ans;
	
	while (1){
		scanf("%d%d", &n, &m);
		if (n == 0){
			break;
		}
		
		for (int i = 0; i < n; i++){
			scanf("%d", &data[i]);
		}
		
		std::sort(data, data + n);
		std::reverse(data, data + n);
		
		ans = 0;
		for (int i = 0; i < n; i++){
			if (i % m != m - 1){
				ans += data[i];
			}
		}
		
		printf("%d\n", ans);
	}
	
	return (0);
}

Measured memory_bytes: 0
INF = 10 ** 9
import sys
sys.setrecursionlimit(100000000)
dy = (-1,0,1,0)
dx = (0,1,0,-1)
from  collections import deque

def main():
    n = list(input())
    for i in range(len(n)):
        if n[i] == '1':
            n[i] = '9'
        elif n[i] == '9':
            n[i] = '1'
    print(''.join(n))
if __name__ == '__main__':
    main()

Measured memory_bytes: 3316
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>
#include <boost/range/adaptor/reversed.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
typedef long long int ll;

#define PI (acos(-1))
#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)

#define dump(x)  cerr << #x << " = " << (x) << endl;
#define dumparr(x) cerr << #x ; for(auto elem: x){cerr << " " << elem;} cerr << endl;
#define dumppairs(x) cerr << #x ; for(auto elem: x){cerr << "(" << elem.first << " " << elem.second << ") ";} cerr << endl;
#define dumpline cerr << "**********************" << endl;
#define dumpwline(x) cerr << "******** " << #x << "=" << (x) << " ********" << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
#define ARRAY_LENGTH(array) (sizeof(array) / sizeof(array[0]))

int main(void){
    ll n; cin >> n;
    ll d; cin >> d;
    ll ans = 0;
    REP(i, n){
        ll x; ll y;
        cin >> x >> y;
        ans += (d*d >= x*x + y*y);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3628
#include <iostream>
#include <cstring>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <queue>
#include <string>
#include <utility>
#include <map>
#include <deque>

using namespace std;
#define rep(i,n) for(int i=1;i<=(int)(n);i++)
#define Rep(i,n) for(int i=0;i<=(int)(n-1);i++)
typedef long long ll;
typedef map<int,int> mint;
typedef pair<int,int> pint;
typedef pair<ll,ll> pll;
typedef deque<pair<ll,ll>> dep;

int inf=1e9+1000;
const int mod=1e9+7;
ll infi=1e18+100;

//x=10111;
//x<<2 = 1011100 (右シフト),x>>2 = 101 (左シフト)
//(x>>2)&1 = 101 & 001 = 1
//iビット目は、(x>>i) & 1 でわかる(x>>i)%2 でもよい


string s;



int main(){
	cin>>s;
	Rep(i,(s.size()+1)/2){
		cout<<s[2*i];
	}
	cout<<endl;

	
	return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MAXN = 1e3 + 5;
#define DEBUG(x) cout << x << '\n'

string s, ss;
int main(){
#ifdef Irene
    freopen("in.txt", "r", stdin);
#endif // Irene
    ios::sync_with_stdio(false);

    cin >> s >> ss;
    cout << (s == ss.substr(0, s.size()) ? "Yes" : "No");
}


Measured memory_bytes: 3644
#include<bits/stdc++.h>
#define IOS ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

int main() {
    IOS; string s, t;
    cin >> s >> t;
    bool moze=true;
    for(int i=0; i<(int)s.length(); ++i) {
        if(s[i]!=t[i]) {moze=false; break;}
    }
    if(moze) cout << "Yes";
    else cout << "No";
    return 0;
}


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

const int inf = 99999;

using namespace std;

int main()
{
	int a[11][11], n, s, t, u, v;
	
	while(1){
		cin >> n;
		if(n == 0){
			break;
		}
		fill(&a[0][0], &a[10][10], inf);
		for(int i = 0; i < 11; i++){
			a[i][i] = 0;
		}
		v = 0;
		for(int i = 0; i < n; i++){
			cin >> s >> t >> u;
			a[s][t] = a[t][s] = u;
			if(v < s){
				v = s;
			}
			if(v < t){
				v = t;
			}
		}
		
		for(int k = 0; k <= v; k++){
			for(int i = 0; i <= v; i++){
				for(int j = 0; j <= v; j++){
					a[i][j] = (a[i][j] > a[i][k]+a[k][j])? a[i][k]+a[k][j] : a[i][j];
				}
			}
		}
		
		t = inf;
		for(int i = 0; i <= v; i++){
			s = 0;
			for(int j = 0; j <= v; j++){
				s += a[i][j];
			}
			if(t > s){
				t = s;
				u = i;
			}
		}
		cout << u << " " << t << endl;
	}
	
	return 0;
}

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

#define int long long
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define rep(i, n) for (int i = 0; i < n; ++i)
#define REP(i, n) for (int i = 0; i < n; ++i)
#define range(i,a,b) ((a)<=(i) && (i)<(b))
#define debug(x) cout << #x << " = " << (x) << endl;
#define fs first
#define sc second
#define pb push_back
#define eb emplace_back
#define SP << " " <<

typedef long long ll;
typedef pair<int, int> P;
typedef tuple<int, int, int> T;
typedef vector<int> vec;
typedef vector<P> pvec;
typedef vector<vector<int>> vvec;
typedef vector<vector<P>> pvvec;
typedef priority_queue<int> PQI;
typedef priority_queue<P> PQP;
typedef priority_queue<int,vector<int>,greater<int>> PQIG;
typedef priority_queue<P,vector<P>,greater<P>> PQPG;

const vector<int> DX = {0, -1, 0, 1, 1, 1, -1, -1};
const vector<int> DY = {1, 0, -1, 0, 1, -1, 1, -1};
constexpr int MOD = (1000000007);
// const int MOD = (998244353);
// const int INF = (1 << 30); // 1073741824
const ll INF = (1LL << 60); // 1152921504606846976
const double PI = (3.141592653589794);
const double EPS = (0.0000000001); // 10^(-10)

template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return 1;} return 0;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return 1;} return 0;}
template<class T> inline T ceil(T a, T b) {return T((a + b - 1) / b);}
template<class T> inline T round(T a, T b) {return T(a / b);}
template< typename T1, typename T2 > istream &operator>>(istream &is, pair< T1, T2 > &p) { is >> p.first >> p.second; return is; }
template <class T> inline void out(T &a) { bool flag=true; for(auto&x:a){if(flag) {flag=false;} else{ cout << ' '; } cout<<x; } cout << endl; }



//----------------------------------------------------------------
int nmax=200000; // 2*(10^5)
vvec G(nmax);





void solve4ts()
{
    
    
    int n;
    cin>>n;
    vec a(nmax);
    
    rep(i,120){
        rep(j,120){
            rep(k,120){
                if(i==0||j==0||k==0) continue;
                int memo=(i+j)*(i+j)+(j+k)*(j+k)+(k+i)*(k+i);
                memo/=2;
                if(memo<nmax){
                    a[memo]++;
                }
            }
        }
    }
    rep(i,n){
        cout<<a[i+1]<<"\n";
    }
}
//-----------------------------------------------------------------

signed main(){ ios::sync_with_stdio(false); cin.tie(0); cout << fixed << setprecision(15);
    int repeat = 1;
    // cin >> repeat;
    while(repeat--) solve4ts();
}

Measured memory_bytes: 9508
// ABC120_C
#include <iostream>
#include <string>
#include <vector>
#include <iterator>
#include <tuple>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <stack>
#include <queue>
#include <algorithm>
#include <functional>  // std::greater<T>()
#include <utility>  // std::swap()
#include <numeric>  // accumulate(ALL(vec), 0)  0 は初期値
#include <bitset>  // static_cast<std::bitset<8>>
#include <sstream>  // std::stringstream
#include <cmath>
#include <climits>  // INT_MIN
#include <cctype>  // std::isdigit()
#include <iomanip>  // std::setprecision()
using namespace std;
using ll = long long;

#define REP(i, n) for (ll i=0; i < n; i++)  // 0 ~ n-1
#define MIN(vec) min_element(vec.begin(), vec.end())  // イテレータのため、値を取り出すときは * を先頭につける
#define MAX(vec) max_element(vec.begin(), vec.end())
#define IDX(vec, element_iter) distance((vec).begin(), element_iter)
#define SUM(vec) accumulate(vec.begin(), vec.end(), 0LL)  // 0 は初期値
#define pll pair<ll, ll>
#define F first
// #define S second

int main() {
    // input(sunippets: inpv, inpn)
    string S;
    cin >> S;
    
    // calculation
    stack<char> st;
    st.push(S[0]);
    ll res = 0;
    for (ll i = 1; i < S.size(); ++i) {
        if (st.empty()) {
            st.push(S[i]);
        } else if (st.top() != S[i]) {
            st.pop();
            res++;
        } else {
            st.push(S[i]);
        }
    }
    cout << res*2 << "\n";
    
    return 0;
}

Measured memory_bytes: 512
#include<iostream>
#define rep(i,n) for(int i=0;i<n;++i)
using namespace std;

int N, a[200000], all;

int main() {
    cin >> N;
    rep(i, N) {
        cin >> a[i];
        all ^= a[i];
    }
    rep(i, N) {
        cout << (all ^ a[i]) << endl;
    }
}

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

#ifdef LOCAL
#define debug(var) cerr << (#var) << " = " << (var) << endl;
#else
#define debug(var)
#endif

void init() {
  ios_base::sync_with_stdio(0);
  cin.tie(0); cout.tie(0);
}

int d[32][32], C[3][32];

void solve() {
  int n, c; scanf("%d%d", &n, &c);
  for (int i = 1; i <= c; ++i) {
    for (int j = 1; j <= c; ++j) {
      scanf("%d", d[i]+j);
    }
  }
  for (int i = 1; i <= n; ++i) {
    for (int x, j = 1; j <= n; ++j) {
      scanf("%d", &x);
      ++C[(i+j)%3][x];
    }
  }
  int ans = 2e9;
  for (int i = 1; i <= c; ++i) {
    for (int j = 1; j <= c; ++j) {
      for (int k = 1; k <= c; ++k) {
	if (i == j || j == k || i == k) continue;
	int cur = 0;
	for (int col = 1; col <= c; ++col) {
	  cur +=
	      C[0][col]*d[col][i]
	    + C[1][col]*d[col][j]
	    + C[2][col]*d[col][k];
	}
	ans = min(ans, cur);
      }
    }
  }
  printf("%d", ans);
}

int main() {
  init();
  int t = 1; //scanf("%d", &t);
  while (t--) {
    solve();
  }
  return 0;
}


Measured memory_bytes: 3812
a=list(input())
for i in range(4):
    a[i]=int(a[i])
if sum(a)==7:
    print(str(a[0])+'+'+str(a[1])+'+'+str(a[2])+'+'+str(a[3])+'='+'7')
elif a[0]+a[1]+a[2]-a[3]==7:#
    print(str(a[0])+'+'+str(a[1])+'+'+str(a[2])+'-'+str(a[3])+'='+'7')
elif a[0]+a[1]-a[2]+a[3]==7:#
    print(str(a[0])+'+'+str(a[1])+'-'+str(a[2])+'+'+str(a[3])+'='+'7')
elif a[0]-a[1]+a[2]+a[3]==7:#
    print(str(a[0])+'-'+str(a[1])+'+'+str(a[2])+'+'+str(a[3])+'='+'7')
elif a[0]+a[1]-a[2]-a[3]==7:#
    print(str(a[0])+'+'+str(a[1])+'-'+str(a[2])+'-'+str(a[3])+'='+'7')
elif a[0]-a[1]+a[2]-a[3]==7:#
    print(str(a[0])+'-'+str(a[1])+'+'+str(a[2])+'-'+str(a[3])+'='+'7')
elif a[0]-a[1]-a[2]+a[3]==7:#
    print(str(a[0])+'-'+str(a[1])+'-'+str(a[2])+'+'+str(a[3])+'='+'7')
elif a[0]-a[1]-a[2]-a[3]==7:#
    print(str(a[0])+'-'+str(a[1])+'-'+str(a[2])+'-'+str(a[3])+'='+'7')


Measured memory_bytes: 3192
import java.util.*;
public class Main{
	public static void main(String[] args){
    	Scanner sc = new Scanner(System.in);
      String s = sc.next();
      int cnt0 = 0;
      int cnt1 = 0;
      for(int i = 0;i < s.length();i++){
      	if(s.substring(i,i+1).equals("0"))cnt0++;
        else cnt1++;
      }
      System.out.println(Math.min(cnt0,cnt1)*2);
    }
}

Measured memory_bytes: 30316
import java.util.Scanner;
import java.util.function.Function;

public class Main {

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

    Scanner sc = new Scanner(System.in);

    void solve() {
        String str;
        while (true) {
            str = sc.nextLine();
            if (isFin(str))
                break;
            System.out.println(digitSum(str));
        }

    }

    int digitSum(String str) {
        int sum = 0;
        String[] strArr = str.split("");
        for (int i = 0; i < str.length(); ++i) {
            sum += Integer.parseInt(strArr[i]);
        }
        return sum;
    }

    boolean isFin(String str) {
        return str.equals("0");
    }
}






Measured memory_bytes: 27312
H,W = map(int, input().split())
M = 10**9 + 7
A = []
for _ in range(H):
  S = input()
  A.append(S)
L = [[0 for j in range(W)] for i in range(H)]
L[0][0] =  1
for i in range (H):
  for j in range (W):
    if A[i][j] == '.':
        if i > 0:
            L[i][j] += L[i-1][j] % M
        if j > 0:
            L[i][j] += L[i][j-1] % M
print(L[H-1][W-1] % M)

Measured memory_bytes: 50512
#include<bits/stdc++.h>
#define pb           push_back
#define pf           push_front
#define in           insert
#define ff           first
#define ss           second
#define mp           make_pair
#define int          long long
#define uint         unsigned long long
#define rep(i,x,m)   for(int i=x;i<m;i++)
#define repr(i,x,m)  for(int i=x;i>=m;i--)
#define MOD          1000000007
#define endl         "\n"
#define all(v)       v.begin(),v.end()
#define rall(v)      v.rbegin(),v.rend()
#define vi           vector<int>
#define vs           vector<string>
#define pi           pair<int,int>
#define di           deque<int>
#define sz(x)       (int)x.size()
#define pq           priority_queue<int>
#define pqs          priority_queue<int,vi,greater<int> >
#define fix(y)       fixed<<setprecision(y)
#define print(v)     for(int i=0;i<v.size();i++) cout<<v[i]<<" ";cout<<endl
#define noob         ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;

int fac[2000005]={0};
void factorial(){ fac[0]=1; fac[1]=1; for(int i=2;i<200005;i++) fac[i]=((i%MOD)*(fac[i-1]%MOD))%MOD;}
int power(int n,int m)
{int p=1;if(m==0)return 1;p=(power(n,m/2)%MOD);p=(p%MOD*p%MOD)%MOD;
return(m&1?((p%MOD*n%MOD)%MOD):(p%MOD));}
int ncr(int n,int r){return ((fac[n]*power(fac[r],MOD-2))%MOD*power(fac[n-r],MOD-2))%MOD;}

void ram5564()
{
    int n;
    cin>>n;
    int a[n];
    int dp[n];
    memset(dp,0,sizeof(dp));
    rep(i,0,n)
    {
        cin>>a[i];
    }
    rep(i,0,n)
    {
      if(i==0)
        continue;
      if(i==1)
      {
        dp[i]=abs(a[i]-a[i-1]);
        continue;
      }
      dp[i]=min(dp[i-2]+abs(a[i]-a[i-2]),dp[i-1]+abs(a[i]-a[i-1]));
    }
    cout<<dp[n-1];
}

signed main()
{
        noob
        // #ifndef ONLINE_JUDGE
        //  freopen("input.txt","r",stdin);
        //  freopen("output.txt","w",stdout);
        //  #endif   
        
        int t=1;
        //cin>>t;
        while(t--)
        ram5564();
        return 0;
}

Measured memory_bytes: 5160
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int sx,sy,tx,ty;
  cin>>sx>>sy>>tx>>ty;
  int dx=tx-sx,dy=ty-sy;
  //1st
  if(dx>=0){for(int i=0;i<dx;i++){cout<<'R';}}
  else{for(int i=0;i<abs(dx);i++){cout<<'L';}}
  if(dy>=0){for(int i=0;i<dy;i++){cout<<'U';}}
  else{for(int i=0;i<abs(dy);i++){cout<<'D';}}
  //2nd
  if(dx>=0){for(int i=0;i<dx;i++){cout<<'L';}}
  else{for(int i=0;i<abs(dx);i++){cout<<'R';}}
  if(dy>=0){for(int i=0;i<=dy;i++){cout<<'D';}}
  else{for(int i=0;i<=abs(dy);i++){cout<<'U';}}
  //3rd
  if(dx>=0){for(int i=0;i<=dx;i++){cout<<'R';}}
  else{for(int i=0;i<=abs(dx);i++){cout<<'L';}}
  if(dy>=0){for(int i=0;i<=dy;i++){cout<<'U';}}
  else{for(int i=0;i<=abs(dy);i++){cout<<'D';}}
  if(dx>=0){cout<<'L';}
  else{cout<<'R';}
  //4th
  if(dy>=0){cout<<'U';}
  else{cout<<'D';}
  if(dx>=0){for(int i=0;i<=dx;i++){cout<<'L';}}
  else{for(int i=0;i<=abs(dx);i++){cout<<'R';}}
  if(dy>=0){for(int i=0;i<=dy;i++){cout<<'D';}}
  else{for(int i=0;i<=abs(dy);i++){cout<<'U';}}
  if(dx>=0){cout<<'R';}
  else{cout<<'L';}
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
 
using namespace std;
 
int n,k,i,j;
int a[200005];
 
 
int possible(int w){
	
	long long int c=0,d=k;
	for(i=1;i<=n;i++){
		d-=(a[i]+w-1)/w-1;
	}
	return d>=0;
}
 
int main( ){
	int low,mid,high,ans;
	cin>>n>>k;
	for(i=1;i<=n;i++){
		cin>>a[i];
	}
	low=1,high=1e9+100;
	while(low<high){
		mid=low+(high-low)/2;
//		cout<<low<<" "<<mid<<" "<<high<<" "<<k<<" ";
		if(possible(mid)){
			high=mid;
          ans=mid;
		}
		else{
			low=mid+1;
		}
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 4336
#include <iostream>
#include <string>
#include <cmath>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<iomanip>
#define _USE_MATH_DEFINES
#include <math.h>
#include <functional>
using namespace std;

#define rep(i,x) for(ll i=0;i<x;i++)
#define repn(i,x) for(ll i=1;i<=x;i++)

typedef long long ll;
const ll INF = 1e17;
const ll MOD = 1000000007;
const ll MAX = 4000001;

ll max(ll a, ll b) {
	if (a > b) { return a; }
	return b;
}

ll min(ll a, ll b) {
	if (a > b) { return b; }
	return a;
}

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

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

struct edge {
	ll ind;
	ll fr;
	ll to;
	ll d;
};

class mint {
    long long x;
public:
    mint(long long x = 0) : x((x% MOD + MOD) % MOD) {}
    mint operator-() const {
        return mint(-x);
    }
    mint& operator+=(const mint& a) {
        if ((x += a.x) >= MOD) x -= MOD;
        return *this;
    }
    mint& operator-=(const mint& a) {
        if ((x += MOD - a.x) >= MOD) x -= MOD;
        return *this;
    }
    mint& operator*=(const  mint& a) {
        (x *= a.x) %= MOD;
        return *this;
    }
    mint operator+(const mint& a) const {
        mint res(*this);
        return res += a;
    }
    mint operator-(const mint& a) const {
        mint res(*this);
        return res -= a;
    }
    mint operator*(const mint& a) const {
        mint res(*this);
        return res *= a;
    }

    mint operator^(const ll& t)const {
        if (!t) return 1;
        mint a = pow(t >> 1);
        a *= a;
        if (t & 1) a *= *this;
        return a;
    }

    mint pow(ll t) const {
        if (!t) return 1;
        mint a = pow(t >> 1);
        a *= a;
        if (t & 1) a *= *this;
        return a;
    }
    // for prime MOD
    mint inv() const {
        return pow(MOD - 2);
    }
    mint& operator/=(const mint& a) {
        return (*this) *= a.inv();
    }
    mint operator/(const mint& a) const {
        mint res(*this);
        return res /= a;
    }

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

//////////////////////////

int main() {
    
    ll N, K;
    cin >> N >> K;

    vector<mint> cd(K + 1);

    repn(i, K)cd[i] = ((mint)(K / i)) ^ N;

    vector<mint>gcd(K + 1);

    for (ll i = K; i >= 1; i--) {
        gcd[i] = cd[i];
        for (ll j = 2 * i; j <= K; j += i) {
            gcd[i] -= gcd[j];
        }
    }

    mint ans = 0;
    repn(i, K) ans += (mint)i * gcd[i];

    cout << ans;
    

    system("PAUSE");
}

Measured memory_bytes: 4776
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		int N = sc.nextInt();
		int[] a  = new int[N];
		int[] b  = new int[1000000];
		
		for (int i=0; i<N; i++){
			a[i] = sc.nextInt();
		}
		
		for (int i=0; i<N; i++){
			b[a[i]+1]++;
			if (a[i] != 0){
				b[a[i]-1]++;
			}
			b[a[i]]++;
		}
		
		int ret =0;
		for (int i=0; i<1000000; i++){
			if (ret < b[i]){
				ret = b[i];
			}
		}
		
		System.out.println(ret);
		
	}

}


Measured memory_bytes: 63232
#include <iostream>
#include <bits/stdc++.h>
#include <time.h>
#include <sys/timeb.h>
#include <cstdio>
#include <sys/time.h>

using namespace std;
#define ll long long
#define uint unsigned int
#define ulong unsigned long long int

template<typename T> bool InRange(T t, T l, T r){ return l <= t && t < r; }

int main(){
	
	int A,B;
	string s;
	cin >> A >> B >> s;
	
	bool chk = true;
	for(int i=0;i<A+B+1;i++){
		if(i == A) chk &= s[i] == '-';
		else chk &= InRange(s[i], '0', (char)('9' + 1));
	}
	
	cout << ( chk ? "Yes" : "No") << endl;
	
	
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <string>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <string.h>
#include <vector>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <time.h>
#define int long long
#define ll long long
#define us unsigned
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, n) for (int i = (n)-1; i >= 0; ++i)
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define nin(ary, n) for (int i = 0; i < (n); i++) cin >> ary[i]
#define nnin(ary, h, w) for (int i = 0; i < (h); ++i) for (int j = 0; j < (w); ++j) cin >> ary[i][j]
#define opt(conditions, a, b) cout << ((conditions) ? #a : #b) << endl
using namespace std;
const double PI = acos(-1.0);
const int MOD = 1e9 + 9;

int max_n(int ary[], int length) {
	int max = ary[0];
	for (int i = 1; i < length; i++)
		if (max < ary[i]) max = ary[i];
	return max;
}

int max_o(int ary[], int length) {
	int max;
	max = max_n(ary, length);
	for (int i = 0; i < length; i++) {
		if (ary[i] == max) return i;
	}
	return -1;
}

int min_n(int ary[], int length) {
	int min = ary[0];
	for (int i = 1; i < length; i++)
		if (min > ary[i]) min = ary[i];
	return min;
}

int min_o(int ary[], int length) {
	int min;
	min = min_n(ary, length);
	for (int i = 0; i < length; i++) {
		if (ary[i] == min) return i;
	}
	return -1;
}

int gcm(int a, int b) {
	int result = a;
	int k = 0;
	int n = b;
	do {
		k = result % n;
		result = n;
		n = k;
	} while (k != 0);
	return result;
}

int gcm_n(int ary[], int length) {
	int g = ary[0];
	for (int i = 0; i < length; i++)
		g = gcm(g, ary[i]);
	return g;
}

int lcm(int a, int b) {
	int g, n;
	g = gcm(a, b);
	n = gcm(a, g);
	a = a / n;
	b = b / (g / n);
	return a*b;
}

int lcm_n(int ary[], int length) {
	int l = ary[0];
	for (int i = 0; i < length; i++)
		l = lcm(l, ary[i]);
	return l;
}

signed main() {
	int n, a[100000], mem;
	bool step = false;
	cin >> n;
	nin(a, n);

	sort(a, a + n);
	int p = n - 1, q = n - 1;
	while (p >= 0) {
		if (a[p] == a[q]) {
			while (a[p] == a[q-1]) {
				q--;
			}
			if (!step&&p - q + 1 >= 4) {
				cout << a[p] * a[p] << endl;
				return 0;
			}
			else if (p - q + 1 >= 2) {
				if (!step) {
					step = true;
					mem = a[p];
				}
				else {
					cout << mem*a[p] << endl;
					return 0;
				}
			}
			if (q > 0) {
				q--;
				p = q;
			}
			else {
				cout << 0 << endl;
				return 0;
			}
		}
	}
	return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define ALL(A) (A).begin(), (A).end()
#define ll long long
#define rep(i, n) for (int i = 0; i < (n); i++)

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; }

int dx[] = { 0, 1, -1, 0, 1, -1, 1, -1 };  // i<4:4way i<8:8way
int dy[] = { 1, 0, 0, -1, 1, -1, -1, 1 };

const ll mod = 1e9 + 7;
const ll INF = -1 * ((1LL << 63) + 1);
const ll inf = 1e18 + 7;

string s[1005];
ll dis[1005][1005];

int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);
    int h,w;
    int sx,sy,gx,gy;

    cin >> h >> w;
    cin >> sx >> sy;
    cin >> gx >> gy;
    rep(i,h)cin >> s[i];

    sx--;sy--;
    gx--;gy--;

    rep(i,1005)rep(j,1005)dis[i][j] = inf;

    dis[sx][sy] = 0;

    queue<pair<int,int>> q;
    queue<pair<int,int>> q2;
    q.push({sx,sy});
    while(!q.empty()){
        while(!q.empty()){
            auto now = q.front();
            q2.push(now);
            q.pop();
            // まずは現在地から歩いていける点を全て埋める
            for(int i=0;i<4;i++){
                int nx = dx[i] + now.first;
                int ny = dy[i] + now.second;
                if(nx < 0 || ny < 0 || nx >= h || ny >= w)continue;
                if(s[nx][ny] == '#')continue;
                if(dis[nx][ny] <= dis[now.first][now.second])continue;
                dis[nx][ny] = dis[now.first][now.second];
                q.push({nx,ny});
            }
        }
        // 歩いていった点からテレポートを使う
        while(!q2.empty()){
            auto now = q2.front();
            q2.pop();
            for(int i=0;i<5;i++){
                for(int j=0;j<5;j++){
                    int nx = now.first  - 2 + i;
                    int ny = now.second - 2 + j;
                    if(nx < 0 || ny < 0 || nx >= h || ny >= w)continue;
                    if(s[nx][ny] == '#')continue;
                    if(dis[nx][ny] <= dis[now.first][now.second] + 1)continue;
                    dis[nx][ny] = dis[now.first][now.second] + 1;
                    q.push({nx,ny});
                }
            }
        }
    }
    cout << (dis[gx][gy] == inf?-1:dis[gx][gy]) << endl;
}

Measured memory_bytes: 12648
#include<bits/stdc++.h>
using namespace std;
long n,m,r;
main(){
	cin>>n>>m;
	vector<long> a(m),b(m),c(m),d(n,-1e18),nc(n,0);
	for(int i=0;i<m;++i){
		cin>>a[i]>>b[i]>>c[i];
		--a[i];--b[i];
	}
	d[0]=0;
	for(int i=0;i<2*n-1;++i)for(int j=0;j<m;++j){
		if(d[a[j]]+c[j]>d[b[j]]){
			if(i>n-2)nc[b[j]]=1;
			d[b[j]]=d[a[j]]+c[j];
		}
		nc[b[j]]|=nc[a[j]];
		if(i==n-2)r=d[n-1];
	}
	nc[n-1]?cout<<"inf":cout<<r;
}

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

#define ll long long
#define endl '\n'
#ifndef _WINDOWS
// no getchar_unlocked on Windows so just call getchar
#define getchar getchar_unlocked
#endif

template <typename Func>
inline void loop(int e, Func&& f) {
    for (int i = 0; i < e; i++) {
        std::forward<Func>(f)(i);
    }
}
template <typename Func>
inline void loop(int s, int e, Func&& f) {
    for (int i = s; i < e; i++) {
        std::forward<Func>(f)(i);
    }
}
template <typename T>
inline void scanpn(T& num) {
    int c;
    num = 0;
    c = getchar();
    // bool negative = false;
    // if (c == '-') {
    // 	negative = true;
    // 	c = getchar();
    // }
    for (; (c > 47 && c < 58); c = getchar()) num = num * 10 + c - 48;
    // if (negative)
    //     number = -number;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll a, b, c, k;
    cin >> a >> b >> c >> k;
    if (a >= k) {
        cout << k << endl;
    } else if (a + b >= k) {
        cout << a << endl;
    } else if (a + b + c >= k) {
        cout << a - k + a + b << endl;
    }
    return 0;
}


Measured memory_bytes: 3640
#include <iostream>
#include <iomanip>
#include <math.h>
#include <stdlib.h>
using namespace std;
int main()
{
	int n, i, y,
		x[100] = {};

	double d[4] = {},
		   diff[100] = {};

	cin >> n;
	for( i = 0; i < n; ++i ) cin >> x[i];
	for( i = 0; i < n; ++i ){
		cin >> y;
		diff[i] = (double)abs( x[i] - y );
	}
	for( i = 0; i < n; ++i ) 
	for( i = 0; i < n; ++i ){
		d[0] += diff[i];
		d[1] += diff[i] * diff[i];
		d[2] += pow( diff[i], 3.0 );
		d[3] = max( d[3], diff[i] );
	}

	cout << fixed << setprecision(5) << d[0] << "\n";
	cout << fixed << setprecision(5) << sqrt(d[1]) << "\n";
	cout << fixed << setprecision(5) << pow( d[2], 1.0/3.0) << "\n";
	cout << fixed << setprecision(5) << d[3] << "\n";

	return 0;
}

Measured memory_bytes: 1304
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner stdIn=new Scanner(System.in);
		String S=stdIn.next();
		if(Integer.valueOf(S.substring(0,4))<2019)
			System.out.println("Heisei");
		else
			if(Integer.valueOf(S.substring(0,4))>2019)
				System.out.println("TBD");
			else
				if(Integer.valueOf(S.substring(5,7))<4)
					System.out.println("Heisei");
				else
					if(Integer.valueOf(S.substring(5,7))>4)
						System.out.println("TBD");
					else
						if(Integer.valueOf(S.substring(8,10))<=30)
							System.out.println("Heisei");
						else
							System.out.println("TBD");
	}

}

Measured memory_bytes: 21844
#include <bits/stdc++.h>
#define ll long long int
#define ld long double
#define f first
#define s second
#define pb push_back
#define eb emplace_back
#define mk make_pair
#define mt make_tuple
#define MOD 1000000007
#define fo(i,a,b) for(i=a;i<b;i++)
#define foe(i,a,b) for(i=a;i<=b;i++)
#define all(x) x.begin(), x.end()
#define vi vector<int>
#define vl vector <long long int>
#define pii pair <int,int>
#define pll pair <long long int, long long int>
#define vpii vector< pair<int,int> >
#define vpll vector < pair <long long int,long long int> > 
#define boost ios::sync_with_stdio(false); cin.tie(0)
using namespace std;
const int inf = 1e9 + 5;
const ll inf64 = 1e18 + 5;
int main()
{
	boost;
	int a, b, c;
	cin >> a >> b >> c;
	if(a == b && a != c)
	cout << "Yes\n";
	else if(a == c && a != b)
	cout << "Yes\n";
	else if(b == c && a != b)
	cout << "Yes\n";
	else
	cout << "No\n";	
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using vi = vector<int>;
using vl = vector<ll>;
#define rep(i, n) for(ll i = 0;i < n;i++)
#define all(i) i.begin(), i.end()
template<class T, class U> bool cmax(T& a, U b) { if (a<b) {a = b; return true;} else return false; }
template<class T, class U> bool cmin(T& a, U b) { if (a>b) {a = b; return true;} else return false; }

// http://noshi91.hatenablog.com/entry/2019/03/31/174006
template <uint_fast64_t Mod>
struct modint {
  using u64 = uint_fast64_t;

  u64 n;

  modint(const u64 x = 0) : n(x % Mod) {}
  modint operator+(const modint r) const { return modint(*this) += r; }
  modint operator-(const modint r) const { return modint(*this) -= r; }
  modint operator*(const modint r) const { return modint(*this) *= r; }
  modint operator/(const modint r) const { return modint(*this) /= r; }
  modint &operator+=(const modint r) {
    n += r.n;
    if (n >= Mod) n -= Mod;
    return *this;
  }
  modint &operator-=(const modint r) {
    if (n < r.n) n += Mod;
    n -= r.n;
    return *this;
  }
  modint &operator*=(const modint r) {
    n = n * r.n % Mod;
    return *this;
  }
  modint &operator/=(modint r) {
    n = n * inv();
    return *this;
  }
  modint pow(u64 x) const {
    modint<Mod> ret(1), tmp(*this);
    while (x) {
      if (x&1) ret *= tmp;
      tmp *= tmp;
      x >>= 1;
    }
    return ret;
  }
  modint inv() const {
    return pow(Mod-2);
  }
};

// T modint
template<class T>
struct Combination {
  vector<T> fact, inv_fact;
  Combination(ll n) : fact(n+1), inv_fact(n+1) {
    fact[0] = T(1);
    for (ll i = 1; i <= n; i++) fact[i] = fact[i-1] * static_cast<T>(i);
    inv_fact[n] = fact[n].inv();
    for (ll i = n; i > 0; i--) inv_fact[i-1] = inv_fact[i] * static_cast<T>(i);
  }

  T P(ll n, ll k) const {
    return fact[n] * inv_fact[n-k];
  }

  T C(ll n, ll k) const {
    return fact[n] * inv_fact[n-k] * inv_fact[k];
  }

  T H(ll n, ll k) const {
    cerr << "H: " << n+k-1 << " " << k << endl;
    return C(n+k-1, k-1);
  }
};

map<ll, ll> PrimeFactorization(ll n) {
  map<ll, ll> m;
  for (int i = 2; i*i <= n; i++) {
    while (n%i == 0) {
      m[i]++;
      n /= i;
    }
  }
  if (n != 1) m[n]++;
  return m;
}

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

  constexpr ll mod = 1e9+7;
  using mint = modint<mod>;

  mint n, m;
  cin >> n.n >> m.n;

  mint ans = 1;
  Combination<mint> c(1000000);
  auto ma = PrimeFactorization(m.n);

  for (auto &i : ma) {
    ans *= c.H(i.second, n.n);
  }

  cout << ans.n << endl;
}


Measured memory_bytes: 15872
N = int(input())
K = list(map(int, input().split()))
counter = dict()
for i in range(N):
  if K[i] not in counter:
  	counter[K[i]] = 1
  else:
   	counter[K[i]] += 1

results = 0
remove_counter = dict()
for key, value in counter.items():
  remove_counter[key] = (value * (value - 1) / 2) - ((value - 1) * (value - 2) / 2)
  results += value * (value - 1) / 2
for i in range(N):
  print(int(results - remove_counter[K[i]]))


Measured memory_bytes: 34848
#include <iostream>
#include <math.h>
using namespace std;

#define INF 1e9;
int dp[100005];
int nums[100005];



int solve(int n, int k) {
    for(int i = 0; i <= n; i++) {
        dp[i] = INF;
    }
    dp[0] = 0;

    for(int i = 1; i < n; i++) {
        for(int j = 1; j <= k; j++)
            if(i - j >= 0) dp[i] = min(dp[i - j] + abs(nums[i]-nums[i - j]), dp[i]);
    }
    
    return dp[n - 1];
}

int main()
{
    int n, k;
    cin >> n >> k;
    
    for(int i = 0; i < n; i++)
        cin >> nums[i];
        
    cout << solve(n, k) << endl;

    return 0;
}


Measured memory_bytes: 1024
#include <stdlib.h>
#include <iostream>
using namespace std;

int bubble_sort(int *array, int currentNum);
void print_array(int *array, int size);
int main(){
	int n;

	cin >> n;

	int* array = (int*)malloc(n * sizeof(int));
	int result = 0;

	if(n < 1){
		return 0;
	}

	for(int i = 0; i < n; i++){
		cin >> array[i];
	}
	result = bubble_sort(array, n);
	print_array(array, n);
	cout << result <<endl;
	return 0;
}

int bubble_sort(int *array, int n){
	int swapNum = 0;

	for(int i = n-1; i > 0; --i){
		bool isSwaped = false;
		for(int j = 0; j < i; ++j){
			if(array[j] > array[j+1]){
				swap(array[j], array[j+1]);
				++swapNum;
				isSwaped = true;
			}
		}
		if(!isSwaped){
			return swapNum;
		}
	}
	return swapNum;
}

void print_array(int *array, int size){
	for(int i = 0; i < size; i++){
		cout <<  array[i];
		if(i != size - 1){
		cout << " " ;
		}
	}
	cout << endl;
}

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

int main() {   
  int n;
  cin >> n;
  vector<int> a(n);
  for (int i = 0; i < n; i++) {
  	cin >> a.at(i);
  }
  int div = 0;
  for(int i = 0; i < n; i++) {
    while (a[i] == a[i+1]) {i++;}
    if ((i + 1 < n) && (a[i] < a[i+1])) {
    	while ((i + 1 < n) && (a[i] <= a[i+1])) {i++;}
    }
    else if ((i + 1 < n) && (a[i] > a[i+1])) {
    	while ((i + 1 < n) && (a[i] >= a[i+1])) {i++;}
    }
    else {i++;}
      div++;
  }
  cout << div << endl;
}

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

int main() {
  int N;
  cin >> N;
  string u;
  double x;
  double sum = 0.0;
  for (int i = 0; i < N; i++){
    cin >> x >> u;
    if (u == "JPY")
    sum += x;
    else if(u == "BTC")
    sum += x * 380000.0;
  }
  cout << sum << endl;
}


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

int main() {
  int n;

  cin >> n;

  int sum = 0;

  int tmp;

  vector<int> a(n+1);
  vector<int> b(n);
  vector<int> c(n-1);

  rep(i,n){
    cin >> a.at(i);
  }


  rep(i,n){
    cin >> b.at(i);
  }

  rep(i,n-1){
    cin >> c.at(i);
  }

  int j = 0;

  rep(i,n){
    // tmp;
    if(a.at(i)+1 == a.at(i+1)){
      sum += c.at(a.at(i)-1);
    }
    sum += b.at(a.at(i) - 1);
    }

    cout << sum;
}


Measured memory_bytes: 3632