akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <bits/stdc++.h>
using namespace std;
 
typedef vector< int > vi;
typedef vector< vi > vvi;
typedef pair< int,int > ii;
typedef pair< long long int ,long long int > iil;
typedef long long ll;
typedef vector< ll > vl;
 
 
#define sz(a) int((a).size())
#define pb push_back
#define all(c) (c).begin(),(c).end()
#define tr(c,i) for( auto i = (c).begin(); i != (c).end(); i++)
#define present(c,x) ((c).find(x) != (c).end())
#define edl '\n'
#define ll long long int
#define forn(i,n) for ( int i=0 ; i<n ; i++ )
#define fornl(i,n) for(ll i=0;i<n;i++)
#define forni(i,j,n) for ( int i=j ; i<n ; i++ )
#define filecode ifstream cin("input.txt");ofstream cout("output.txt");
#define IOFAST ios::sync_with_stdio(false);cin.tie(0); cout.tie(0);
#define setPrecision(n) cout << std::setprecision(n) << std::fixed;
#define MOD 998244353
#define PI 3.14159265
#define DEBUG 0
#define g(a,b) a>b?a:b
#define l(a,b) a<b?a:b
bool comp ( ii a, ii b ){ return (a.first==b.first)?a.second<b.second:a.first<b.first; }
ll modInverse(ll a) { ll m = MOD;ll y = 0, x = 1;while (a > 1) {ll q = a / m;ll t = m;m = a % m, a = t;t = y;y = x - q * y;x = t;}if (x < 0) x += MOD;return x; }

int main(){
    ll k,n;
    cin>>k>>n;
    vl A(n);
    forn(i,n){
        cin>>A[i];
    }
    int m=1e7;
    forn(i,n){
        if(i==0){
            m=l(m,(k-abs(A[1]-A[0])));
            m=l(m,(A[n-1]-A[0]));            
        }
        else if(i==n-1){
            m=l(m,(k-abs(A[n-1]-A[n-2])));
            m=l(m,(A[n-1]-A[0]));
            
        }
        else{
            m=l(m,(k-abs(A[(i+1)]-A[i])));
            m=l(m,(k-abs(A[i]-A[(i-1)])));
        }
        
    }
    cout<<m<<endl;
}



















Measured memory_bytes: 1792
#include <stdio.h>

int main() {
    int i,a,b,c,cnt=0;
    scanf("%d %d %d",&a,&b,&c);
    for(i=a;i<=b;i++){
        if(c%i==0){
            cnt++;
        }
    }
    printf("%d\n",cnt);
    return 0;
}

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

int main() {
    int n;
    string s;
    cin >> n >> s;
    if (n%2 == 1) {
        cout << "No" << endl;
        return 0;
    }
    string p1, p2;
    p1 = s.substr(0, n/2);
    p2 = s.substr(n/2);
    if (p1 == p2) cout << "Yes" << endl;
    else cout << "No" << endl;
}

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

int main()
{
        string s;
        int l, i, a;
        cin >> s;
        while(s!="0"){
                l=s.length();
                int sum=0;
                for(i=0; i<l; i++){
                        string s0(1, s[i]);
                        a=stoi(s0);
                        sum=a+sum;
                }
                cout<<sum<<endl;
                cin >> s;
        }
}



Measured memory_bytes: 3208
#include<iostream>
using namespace std;
#define NIL -1

int Depth[100005], n;

struct Node {
	int parent, left, right;
};

Node c[100005];

void print(int i) {
	int nod, j;
	cout << "node " << i << ": parent = " << c[i].parent << ", depth = " << Depth[i] << ", ";
	if (c[i].parent == NIL) cout << "root, [";
	else if (c[i].left == NIL) cout << "leaf, [";
	else cout << "internal node, [";
	for (j = 0, nod = c[i].left;nod != NIL;j++, nod = c[nod].right) {
		if (j > 0) cout << ", ";
		cout << nod;
	}
	cout << "]" << endl;
}

void calcdepth(int curnode, int dep) {
	Depth[curnode] = dep;
	if (c[curnode].right != NIL) calcdepth(c[curnode].right, dep);
	if (c[curnode].left != NIL) calcdepth(c[curnode].left, dep + 1);
}

int main() {
	int id, k, a, prenode, root;

	cin >> n;

	for (int i = 0;i <= n - 1;i++) c[i].parent = c[i].left = c[i].right = NIL;

	for (int i = 0;i <= n - 1;i++) {
		cin >> id >> k;
		for (int j = 0;j <= k - 1;j++) {
			cin >> a;
			if (j == 0) c[id].left = a;
			else c[prenode].right = a;
			prenode = a;
			c[a].parent = id;
		}
	}

	//root??????????????¢???
	for (int i = 0;i <= n - 1;i++) {
		if (c[i].parent == NIL) root = i;
	}

	calcdepth(root, 0);

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

	return 0;
}

Measured memory_bytes: 7644
n = int(input())
d = list(map(int, input().split()))
d_sorted = sorted(d)

ans = d_sorted[int(n/2)] - d_sorted[int(n/2)-1]

#print(d_sorted)
#print(d_sorted[int(n/2)], d_sorted[int(n/2)-1])

print(ans)

Measured memory_bytes: 14556
#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
#include <unordered_map>
//#include"testlib.h"
#define endl "\n"
#define all(v) v.begin(),v.end()
#define allr(s) s.rbegin(),s.rend()
#define RT(s) return cout<<s,0
#define sz(s)    (int)(s.size())
#define PI acos(-1)
#define EPS 1e-8
#define watch(x) cout << (#x)<<" = "<<x<<endl
using namespace std;
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
int dy[] = { 1, -1, 0, 0, -1, 1, 1, -1 };
int dx[] = { 0, 0, 1, -1, 1, -1, 1, -1 };
void file() {
#ifndef ONLINE_JUDGE
	freopen("in.txt", "r", stdin);
	//freopen("out.txt", "w", stdout);
#else
	//freopen("street.in", "r", stdin);
	//freopen("out.txt", "w", stdout);
#endif
}
void fast() {
	std::ios_base::sync_with_stdio(0);
	cin.tie(NULL);
}
const int N = 1e7 + 9;
int arr[N];
int main() {
	file();
	fast();
	for (int i = 1; i < N; i++)
		for (int j = i; j < N; j += i)
			arr[j]++;
	int n; cin >> n;
	ll ans = 0;
	for (int i = 1; i <= n; i++) {
		ans += 1LL * i * arr[i];
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 42692
from collections import Counter,defaultdict
import sys,heapq,bisect,math,itertools,string,queue,fractions
mod = 10**9+7
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpln(n): return list(int(sys.stdin.readline()) for i in range(n))
def inpl_str(): return list(sys.stdin.readline().split())
def lcm(x, y):
    return (x * y) // fractions.gcd(x, y)

n = inp()
a = inpl()
acc = list(itertools.accumulate(a))
#+-+-+-
cnt = 0
tmp = 0
for i in range(n):
    if i%2==0:
        tt = acc[i] + tmp
        if tt <= 0:
            cnt += 1 - tt
            tmp += 1 - tt
    else:
        tt = acc[i] + tmp
        if tt >= 0:
            cnt += tt + 1
            tmp -= tt + 1
ans = cnt
#-+-+-+
cnt = 0
tmp = 0
for i in range(n):
    if i%2:
        tt = acc[i] + tmp
        if tt <= 0:
            cnt += 1 - tt
            tmp += 1 - tt
    else:
        tt = acc[i] + tmp
        if tt >= 0:
            cnt += tt + 1
            tmp -= tt + 1
    # print(i,cnt,tmp,tt)
print(min(ans,cnt))

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

typedef long long int64;
int n;
int64 a[55];

int main() {
	scanf("%d", &n);

	int64 t = 0;
	for(int i = 1; i <= n; i++) {
		scanf("%lld", &a[i]);
		t += a[i];
	}

	for(int64 s = max(0LL, t - n * (n - 1)); s <= t; s++) {
		int64 tot = 0;
		int bad = 0;

		for(int i = 1; i <= n; i++) {
			int64 x = (a[i] + s + 1) / (n + 1);
			int64 y = (a[i] + s) / (n + 1);

			if(x > y) {
				bad = 1;
				break;
			}

			tot += x;
		}

		if(bad)
			continue;

		if(tot <= s) {
			printf("%lld\n", s);
			break;
		}
	}

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdint>

using std::cin;
using std::cout;
using std::endl;

using std::string;
using std::pair;

using std::vector;
using std::sort;
using std::lower_bound;
using std::upper_bound;
using std::find_if;
using std::copy;
using std::copy_if;

int main(){
    int N,M;
    cin >> N >> M;
    vector<int> a(N);
    vector<int> b(N);
    vector<int> c(M);
    vector<int> d(M);
    for(int i=0;i<N;i++){
        cin >> a[i];
        cin >> b[i];
    }
    for(int i=0;i<M;i++){
        cin >> c[i];
        cin >> d[i];
    }

    for(int i=0;i<N;i++){
        int p=1;
        int min=std::abs(a[i]-c[0])+std::abs(b[i]-d[0]);

        for(int j=2;j<=M;j++){
            int m=std::abs(a[i]-c[j-1])+std::abs(b[i]-d[j-1]);
            if(m<min){
                p=j;
                min=m;
            }
        }

        cout << p << endl;
    }
    return 0;
}



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

using namespace std;

const static int N = 100;
static const int  WHITE = 0;
static const int GRAY = 1;
static const int BLACK = 2;

int n,M[N][N];
int color[N], d[N] ,f[N],tt;
int nt[N];

int next(int u)
{
    for(int v=nt[u];v<n;v++){
        nt[u]=v+1;
        if(M[u][v]) return v;
    }
    return -1;
}

void dfs_visit(int r)
{
    for(int i=0;i<n;i++) nt[i]=0;
    stack <int > S;
    S.push(r);
    color[r]=GRAY;
    d[r]=++tt;

    while(!S.empty()){
        int u=S.top();
        int v=next(u);
        if(v!=-1){
            if(color[v]==WHITE){
                color[v]=GRAY;
                d[v]=++tt;
                S.push(v);
            }
        }
        else{
            S.pop();
            color[u]=BLACK;
            f[u]=++tt;
        }
    }
}

void dfs()
{
    for(int i=0;i<n;i++){
        color[i]=WHITE;
        nt[i]=0;
    }
    tt=0;
    for(int u=0;u<n;u++){
        if(color[u]==WHITE) dfs_visit(u);
    }
    for(int i=0;i<n;i++){
        cout<<i+1<< " " << d[i] << " " << f[i] <<endl;
    }
}



int main()
{

    int u,k,v;
    cin>>n;
    for(int i=0;i<n;i++){
        for(int j=0;j<n;j++) M[i][j]=0;
    }

    for(int i=0;i<n;i++) {
        cin>>u>>k;
        u--;
        for(int j=0;j<k;j++){
            cin>>v;
            v--;
            M[u][v]=1;
        }
    }
    dfs();

    return 0;
}



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

int main() {
    int N, M;
    cin >> N >> M;
    vector<int> a(M), b(M);
    for (int i=0; i<M; i++) cin >> a.at(i) >> b.at(i);
    vector<int> out(N);
    for (int i=0; i<M; i++){
        out.at(a.at(i)-1) += 1;
        out.at(b.at(i)-1) += 1;
    }
    for (int i=0; i<N; i++) cout << out.at(i) << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include<cmath>
using namespace std;
long long a[200000];

int main()
{
	int num;
	long long min, carnum;
	int i = 0;
	cin >> num;
	while ((i <= num - 1)&&cin >> carnum)
	{
		a[i + 1] = a[i] + carnum;
		++i;
	}
	min = abs(a[num] - a[1] - a[1]);
	for (int j = 2; j < num; j++)
	{
		if (abs(a[num] - a[j] - a[j])<min)
		min = abs(a[num] - a[j] - a[j]);
	}
	cout << min;
    return 0;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
#define ll long long 
using namespace std;
const int maxn=200005;
ll sum[maxn],a[maxn];
ll n,b,c,d,e;
ll ans=1e15+7;
bool check(ll x,ll y,int i)
{
    if(abs((x+a[i])-(y-a[i]))<abs(x-y))
    return 1;
    return 0;
}
int main()
{
    cin>>n;
    ll s=0;
    for(int i=0;i<n;i++)
    {
        cin>>a[i];
        s+=a[i];
        sum[i]=s;
    }
    int j=0,k=2;
    for(int i=1;i<n-2;i++)
    {
        b=sum[j];
        c=sum[i]-sum[j];
        d=sum[k]-sum[i];
        e=sum[n-1]-sum[k];
        while(check(b,c,j+1) && j+1<i)
        {
            j++;
            b=sum[j];
            c=sum[i]-sum[j];
        }
        while(check(d,e,k+1) && k+1<n-1)
        {
            k++;
            d=sum[k]-sum[i];
            e=sum[n-1]-sum[k];
        }
        ll test[10];
        test[0]=b;test[1]=c;
        test[2]=d;test[3]=e;
        sort(test,test+4);
        ans=min(ans,test[3]-test[0]);
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 3328
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using db = double;
using ld = long double;
template<typename T> using V = vector<T>;
template<typename T> using VV = vector<vector<T>>;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define eb emplace_back
#define all(v) (v).begin(),(v).end()
#define siz(v) (ll)(v).size()
#define rep(i,a,n) for(ll i=a;i<(ll)(n);++i)
#define repr(i,a,n) for(ll i=n-1;(ll)a<=i;--i)
#define lb lower_bound
#define ub upper_bound
#define ENDL '\n'
typedef pair<int,int> Pi;
typedef pair<ll,ll> PL;
const ll mod = 1000000007;
const ll INF = 1000000099;
const ll LINF = (ll)(1e18 +99);
const vector<ll> dx={-1,1,0,0},dy={0,0,-1,1};
template<typename T,typename U> inline bool chmin(T& t, const U& u){if(t>u){t=u;return 1;}return 0;}
template<typename T,typename U> inline bool chmax(T& t, const U& u){if(t<u){t=u;return 1;}return 0;}
template<typename T> inline T gcd(T a,T b){return b?gcd(b,a%b):a;}
template<typename T,typename Y> inline T mpow(T a, Y n) {
  T res = 1;
  for(;n;n>>=1) {
    if (n & 1) res = res * a;
    a = a * a;
  }
  return res;
}

ll dp[410][410]={};

signed main(){
  cin.tie(0);ios::sync_with_stdio(false);
  cout<<fixed<<setprecision(20);
  ll n;cin>>n;
  V<ll> v(n),sum(n+1,0);
  rep(i,0,n){
    cin>>v[i];
    sum[i+1]=v[i]+sum[i];
  }
  
  rep(i,2,n+1){//interval
    rep(j,0,n-i+1){//left
      dp[j][j+i]=LINF;
      rep(k,1,i){//mid
        chmin(dp[j][j+i],dp[j][j+k]+dp[j+k][j+i]+sum[j+i]-sum[j]);
      }
    }
  }

  cout<<dp[0][n]<<ENDL;
}
//( ・ __ ・ ) KEEP BEING ORGANIZED
//CHECK overflow,vector_size,what to output?

Measured memory_bytes: 1536
N = gets.to_i
A = gets.split.map(&:to_i)

A.push(0)
A.insert(0, 0)

sum = 0
for i in (0..N)
  sum += (A[i] - A[i+1]).abs
end

1.upto(N) do |i|
  puts sum - (A[i-1] - A[i]).abs - (A[i] - A[i+1]).abs + (A[i-1] - A[i+1]).abs
end


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

#define int long long int
#define vi vector<int>

signed main() {
    int n;
    cin >> n;
    vi a(n);
    map<int, int> mp;
    for(int i = 0; i < n; i++) {
        cin >> a[i];
        mp[a[i]]++;
    }
    int ans = 0;
    for(auto& i : mp) {
        ans += ((i.second) * (i.second - 1)) / 2;
    }
    for(int i = 0; i < n; i++) {
        int curr = ans;
        int val = mp[a[i]];
        curr -= ((val) * (val - 1)) / 2;
        curr += ((val - 1) * (val - 2)) / 2;
        cout << curr << endl;
    }
}


Measured memory_bytes: 12716
#include<iostream>

using namespace std;

typedef long long ll;

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

ll N,K,a[100000],cou[100000];

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

    rep(i,N)cin >> a[i];
    rep(i,N)a[i]--;

    ll ans = N + 1;

    ll l = 0,r = 0,used = 0;

    for(;;) {
        while(r < N && used < K) {
            if(a[r] < K && cou[a[r]] == 0)used++;
            cou[a[r]]++;
            r++;
        }

        if(used < K)break;//rが後ろまで到達して勝つ条件を満たしていない

        ans = min(ans,r - l);

        if(a[l] < K && --cou[a[l]] == 0) {
            used--;
        }
        l++;
    }

    if(ans == N + 1) {
        cout << 0 << endl;
    }else {
        cout << ans << endl;
    }
    return 0;
}


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

using namespace std;

int main()
{
  string s;
  cin >> s;
  char c = s[s.length() -1];
  char pon[4] = {'0','1','6','8'};
  string ans = "hon";
  if(c == '3')
    ans = "bon";
  for(int i = 0; i < 4; ++i)
  {
    if(c == pon[i])
      ans = "pon";
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 3524
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using db = double;
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define all(v) (v).begin(), (v).end()
#define siz(v) (ll)(v).size()
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define repi(i, x, n) for (ll i = x; i < (ll)(n); i++)
#define lb lower_bound
#define ub upper_bound
typedef pair<int, int> P;
typedef pair<ll, ll> PL;
const ll mod = 1000000007;
const ll INF = 1000000099;
vector<ll> dx = {-1, 1, 0, 0}, dy = {0, 0, -1, 1};
//cin.tie(0);ios::sync_with_stdio(false);

signed main()
{
    int n, m, ans = 1000;
    cin >> n >> m;
    vector<int> nofh(m, 0), ind(n, 0);
    vector<vector<int>> v(n, vector<int>(m));
    vector<bool> use(m,true);

    rep(i, n) rep(j, m)
    {
        cin >> v[i][j];
        v[i][j]--;
        if (j == 0)
        {
            nofh.at(v[i][0])++;
        }
    }

    int mx = 0,mxi=-1;
    rep(k, m)
    {
        mx=0;
        rep(i, m)
        {
            if(mx<nofh[i]){
                mxi=i;
            }
            mx = max(mx, nofh[i]);
        }
        ans = min(ans, mx);
        
        use[mxi]=false;
        rep(i,n){   
            if(v[i][ind[i]]==mxi){
                nofh[mxi]--;
                while(ind[i]<m-1 && !use[v[i][ind[i]]])ind[i]++;
                nofh[v[i][ind[i]]]++;
            }
        }
        //cout<<ans<<endl;
    }
    cout<<ans<<endl;
}

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

#define mainspring cout<<"mainspring\n";
#define barrel cout<<"barrel\n";
#define escapement cout<<"escapement\n";

#define pb push_back
#define eb emplace_back
#define all(v) (v).begin(), (v).end() 
#define sz(v) (int)((v).size())
#define INF INT_MAX
#define NINF INT_MIN
#define fs first
#define sd second
#define tik(i,a,b) for(int i = a; i < b; i++)
#define tok(i,a,b) for(int i = a; i >= b; i--)
#define error(args...) {string _s = #args; replace(_s.begin(), _s.end(), ',',' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it,args);}

typedef long long ll;
typedef unsigned long long ull;

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

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

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

void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
    cerr << *it << " = " << a << "\n";
    err(++it, args...);
}

const int MAX_D = 1000+10;
const int MOD = 1e9+7;

int H, W;
int dp[MAX_D][MAX_D];
char maze[MAX_D][MAX_D];
int main() {

	cin >> H >> W;

	tik(i,1,H+1) {
		tik(j,1,W+1) {
			cin >> maze[i][j];
		}
	}

	dp[H][W] = 1;

	tok(i,H-1,1) {
		if(maze[i][W] == '#')
			dp[i][W] = 0;
		else
			dp[i][W] = dp[i+1][W];
	}

	tok(i,W-1,1) {
		if(maze[H][i] == '#')
			dp[H][i] = 0;
		else
			dp[H][i] = dp[H][i+1];
	}

	tok(i,H-1,1) {
		tok(j,W-1,1) {
			if(maze[i][j] == '#')
				dp[i][j] = 0;
			else {
				dp[i][j] = dp[i+1][j] + dp[i][j+1];
				dp[i][j] %= MOD;
			}
		}
	}

	cout << dp[1][1];
}

Measured memory_bytes: 5120
import heapq

n,m = map(int,input().split())
a_list = list(map(int,input().split()))
move = [list(map(int,input().split())) for _ in range(m)]

heapq.heapify(a_list)
move = sorted(move, key=lambda x: x[1],reverse=True)

for elem in move:
    for i in range(elem[0]):
        _min = heapq.heappop(a_list)
        if _min < elem[1]:
            heapq.heappush(a_list,elem[1])
        else:
            heapq.heappush(a_list,_min)
            break

print(sum(a_list))

Measured memory_bytes: 33784
#include<iostream>
#include<algorithm>
#include<cmath>
#include<cstdlib>
#include<string>
#include<vector>
using namespace std;

int main(void){
	char a[3],b[3];
	cin >> a[0] >> a[1] >> a[2] >> b[0] >> b[1] >> b[2];
	if (a[0] == b[2] && a[1] == b[1] && a[2] == b[0]) {
		cout << "YES";
	}else{
		cout << "NO";
	}
	return 0;
}

Measured memory_bytes: 256
s=input()
l=0
r=len(s)-1
x=0
while l<r:
  if s[l]==s[r]:
    l+=1
    r-=1
  elif s[l]=='x':
    x+=1
    l+=1
  elif s[r]=='x':
    x+=1
    r-=1
  else:
    x=-1
    break
print(x)

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

using namespace std;

int main() {

	long long a, b, c;
	cin >> a >> b >> c;
	long long tmpa, tmpb,tmpc;
	int counter = 0;
	while (a % 2 == 0 && b % 2 == 0 && c % 2 == 0) {
		counter++;
		tmpa = a;
		tmpb = b;
		tmpc = c;
		a = tmpb / 2 + tmpc / 2;
		b = tmpa / 2 + tmpc / 2;
		c = tmpa / 2 + tmpb / 2;
		if (counter > 1000){
			cout << -1 << endl;
				return 0;
		}
	}

	cout << counter << endl;
	return 0;
}

Measured memory_bytes: 3624
#include<iostream>
#include<string>
#include<algorithm>
using namespace std;
int soed(int i) {
	int sum = 0;
	string s = to_string(i);
	for (int j = 0; j < s.length(); j++) {
		sum += s[j] - '0';
	}
	return sum;
}
int main() {
	int n; cin >> n;
	if (n%soed(n) == 0) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES

#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cmath>
#include <atcoder/all>
using namespace std;
using namespace atcoder;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef tuple<ll, ll, ll> tl3;

typedef modint998244353 mint;

const int BIG_NUM = 1e9;
const ll INF = 1000000000000000000;
//const ll MOD = 1e9 + 7;
//const ll MOD = 998244353;

const int MAX = 200000 + 5;

struct S {
    
    mint val;
    int size;
};

struct F
{
    int v;
    bool id;
};

vector<mint> p10(MAX);
vector<vector<mint>> succ(10, vector<mint>(MAX));

S op(S x, S y) {
    return { x.val * p10[y.size] + y.val,x.size + y.size };
}

S e() { 
    return {0,0};
}

S mapping(F f, S s) {
    if (f.id) {
        return s;
    }
    
    return { succ[f.v][s.size],s.size };
}

F composition(F f, F g) {
    if (f.id) {
        return g;
    }
    return f; 
}

F id() { 
    return { 1,true };
}
int main() {
    int n, q;
    cin >> n >> q;

    p10[0] = 1;
    for (int i = 1; i < MAX; i++) {
        p10[i] = p10[i - 1] * 10;
    }

    for (int i = 1; i <= 9; i++) {
       
        for (int j = 1; j < MAX; j++) {
            succ[i][j] = succ[i][j - 1] * 10 + i;
        }
    }
    vector<S> ini(n, { 1,1 });

    lazy_segtree<S, op, e, F, mapping, composition, id> seg(ini);
    //cout << seg.all_prod().val.val() << endl;
    for (int i = 0; i < q; i++) {
        int l, r, d;
        cin >> l >> r >> d;
        l--;
        seg.apply(l, r, F{ d,false });
        cout << seg.all_prod().val.val() << endl;
    }
}

Measured memory_bytes: 19704
N = input()
S = raw_input()

max_n = 0

for i in range(N-1):
    x = S[0:i+1]
    y = S[i+1:N]
    x1 = list(set(x))
    y1 = list(set(y))
    rx = len(x1)
    ry = len(y1)
    count = 0
    for j in range(rx):
        for k in range(ry):
            if y1[k] in x1[j]:
                count = count + 1
    if count > max_n:
        max_n = count

print(max_n)

Measured memory_bytes: 2568
// Created by code_sm
//
#include<bits/stdc++.h>
using namespace std;
//#include <ext/pb_ds/assoc_container.hpp> 
//using namespace __gnu_pbds;
//typedef tree<int,null_type,less<int>,rb_tree_tag, tree_order_statistics_node_update> pseudo_set;
#define ll long long
#define vi vector<int>
#define si set<int> 
#define mii map<int,int>
#define pb push_back
#define pf push_front
#define pii pair<int,int>
#define extract_word(s)  stringstream str(s); while(str>>word)
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define SET(s) cout<<fixed<<setprecision(s)
#define chotu 1000000007
#define set0(a) memset(a,0,sizeof(a))
#define endl "\n"
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define lower_string(s) transform(all(s),s.begin(),::tolower())
#define upper_string(s) transform(all(s),s.begin(),::toupper())
#define size(s) s.size()
template<class T> bool umin(T &a, T b) { return a > b ? (a = b, true) : false; }
template<class T> bool umax(T &a, T b) { return a < b ? (a = b, true) : false; }
template<typename T,typename U>
bool compare(T x,U y){return(abs(x-y)<=1e-9);}
void solve()
{
fastio
int a[32]={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
int k;
cin>>k;
cout<<a[k-1];

}
int main()
{
//code
	
fastio	
int t;
t=1;
while(t--)
{
	solve();
	cout<<endl;
}
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <iomanip>
#include <utility>
#include <tuple>
#include <functional>
#include <bitset>
#include <cassert>
#include <complex>
#include <stdio.h>
#include <time.h>
#include <numeric>
#include <random>
#include <unordered_map>
#include <unordered_set>
#define all(a) a.begin(),a.end()
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define pb push_back
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<ll, ll> P;
typedef complex<ld> com;
constexpr int inf = 1000000010;
constexpr ll INF = 1000000000000000010;
constexpr ld eps = 1e-12;
constexpr ld pi = 3.141592653589793238;
template<class T, class U> inline bool chmax(T &a, const U &b) { if (a < b) { a = b; return true; } return false; }
template<class T, class U> inline bool chmin(T &a, const U &b) { if (a > b) { a = b; return true; } return false; }


signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(20);

	string s, t;
	cin >> s >> t;
	cout << (s == t.substr(0, t.size() - 1) ? "Yes" : "No") << '\n';
}

Measured memory_bytes: 3616
Max = 1000000
def digit_sum(n):
	res = 0
	while n>0:
		res += int(n%10)
		n /= 10
	return res

N = int(input())
if N==10 or N==100 or N==1000 or N==10000 or N==100000:
	print(10)
else:
	print(digit_sum(N))

Measured memory_bytes: 9040
local n,k=io.read("n","n")
local t={}
for i=0,k-1 do
    t[i]=0
end
for i=1,n do
    t[i%k]=t[i%k]+1
end

local counter=0
for a=0,k-1 do
    local b=(k-a)%k
    local c=(k-a)%k
    if (b+c)%k==0 then
        counter=counter+t[a]*t[b]*t[c]
    end
end
print(string.format("%d",counter))

Measured memory_bytes: 4584
N = int(input())
xy = [list(map(int, input().split())) for i in range(N)]

ans = 0
for i in range(N):
  for j in range(i+1, N):
    ans += ((xy[i][0] - xy[j][0]) ** 2 + (xy[i][1] - xy[j][1]) ** 2) ** 0.5

ans *= 2 / N

print(ans)

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

int main() {
    int H, W, K;
    std::cin >> H >> W >> K;

    char c[H][W];
    for (int i = 0; i < H; ++i) {
        for (int j = 0; j < W; ++j) {
            std::cin >> c[i][j];
        }
    }

    int ans = 0;
    for (int i = 0; i < (1 << H); ++i) {
        for (int j = 0; j < (1 << W); ++j) {

            int cnt = 0;
            for (int k = 0; k < H; ++k) {
                if ((i >> k) & 1) {
                    continue;
                }

                for (int l = 0; l < W; ++l) {
                    if ((j >> l) & 1) {
                        continue;
                    }

                    if (c[k][l] == '#') {
                        ++cnt;
                    }
                }
            }

            if (cnt == K) {
                ++ans;
            }
        }
    }
    
    std::cout << ans << std::endl;

    return 0;
}


Measured memory_bytes: 3620
#include <iostream>
#include <string.h>
#include <stdio.h>
using namespace std;
int main()
{
    int flag[14];
    memset(flag, 0, sizeof(flag));
    int n, m, k;
    cin >> n >> m >> k;
    flag[n]++;
    flag[m]++;
    flag[k]++;
    if (flag[5] == 2 && flag[7] == 1) {cout << "YES" << endl;
     }
    else cout << "NO" << endl;
    return 0;
}


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

long long int gcd(long long int a, long long int b) {
	while (b) {
		a %= b;
		swap(a, b);
	}
	return a;
}

int main() {
	long long int N,ans,first,A;
	cin >> N;
	cin >> first;
	ans = first;
	for (long long int i = 1; i <= N ; i++) {
		cin >> A;
		ans = gcd(ans, A);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  string s;
  cin >> s;
  for (int i = 0; i < s.size(); i++)
    cout << 'x';
  cout << '\n';
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<utility>
#include<vector>
#include<cmath>
#include<cstring>
#include<cstdio>
#include<time.h>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define mp make_pair
#define all(in) in.begin(),in.end()
const double PI=acos(-1);
const double EPS=1e-10;
const int inf=1e8;
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
int main(){
	map<string,string>q;
	q["bg"]=q["gb"]="rr";
	q["gr"]=q["rg"]="bb";
	q["rb"]=q["br"]="gg";
	string s;
	while(cin>>s,s!="0"){
		char qqq=s[0];
		bool h=true;
		rep(i,s.size())if(s[i]!=qqq)h=false;
		if(h){cout<<0<<endl;continue;}
		vector<string>in;
		map<string,bool>tmp;
		in.pb(s);
		int co=0;
		while(1){
			vector<string>out;
			bool h=false;
			rep(i,in.size()){
				string s=in[i];
				tmp[s]=true;
				//h=true;
				//char qq=in[i][0];
				//rep(j,s.size())if(qq!=in[i][j])h=false;
				//if(h)break;
				rep(j,s.size()-1)if(s[j]!=s[j+1]){
					string www=s.substr(j,2);
					string w=q[www];
					string ww=s;
					ww[j]=w[0];ww[j+1]=w[1];
					h=true;
					char qq=ww[0];
					rep(k,ww.size())if(qq!=ww[k])h=false;
					if(h)break;
					if(!tmp[ww]){out.pb(ww);tmp[ww]=true;}
				}
				if(h)break;
			}
			//cout<<endl;
			//rep(i,out.size())cout<<out[i]<<endl;
			//cout<<tmp.size()<<endl;
			//cout<<out.size()<<endl;
			if(h)break;
			co++;
			in=out;
			//cout<<" "<<in.size()<<endl;
			if(co==100)break;
		}
		if(co==100)cout<<"NA"<<endl;
		else cout<<co+1<<endl;
	}
}

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

int main()
{
    long long N, M;
    cin>>N>>M;
    vector<long long> A(N);
    for (long long &a: A)
        cin>>a;

    sort(A.begin(), A.end());

    auto f = [&](long long x)
    {
        long long n = 0;
        for (long long i=0; i<N; i++)
            n += A.end() - lower_bound(A.begin(), A.end(), x-A[i]);
        return n;
    };

    long long a = 0;
    for (long long b=262144; b>0; b/=2)
        if (f(a+b) > M)
            a += b;

    vector<long long> S(N+1);
    S[N] = 0;
    for (long long i=N-1; i>=0; i--)
        S[i] = S[i+1]+A[i];
    long long ans = 0;
    for (long long i=0; i<N; i++)
    {
        long long p = lower_bound(A.begin(), A.end(), a+1-A[i])-A.begin();
        ans += (N-p)*A[i] + S[p];
    }
    ans += (M-f(a+1))*a;
    cout<<ans<<endl;
}


Measured memory_bytes: 1792
#include <cstddef>
#include <iostream>
#include <iomanip>
#include <string>
#include <sstream>
#include <vector>
#include <array>
#include <unordered_map>
#include <algorithm>
#include <numeric>
#include <limits>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <bitset>
#include <valarray>
#include <utility>
#include <tuple>
#include <cmath>
#include <memory>
#include <random>
#include <fstream>
#include <locale>

#ifndef __has_include
#define __has_include(x) (false)
#endif

#if __has_include(<filesystem>)
#include <filesystem>
namespace fs = std::filesystem;
#endif



using ll = long long;
using ull = unsigned long long;

//vector
template <class T>
using vec = std::vector<T>;

template <class T>
using vv = vec<vec<T>>;

constexpr std::size_t operator""_sz(ull n) { return std::size_t(n); }

template <class T, class BinaryOperation>
constexpr T fold(std::initializer_list<T> args, T init, BinaryOperation op)
{
	return std::accumulate(args.begin(), args.end(), init, op);
}

// numeric_low
namespace numeric
{
	template<typename T>
	constexpr bool isOdd(T x)
	{
		return x % 2 != 0;
	}

	template<typename T>
	constexpr bool isEven(T x)
	{
		return x % 2 == 0;
	}

	// 最大公約数
	template<class T>
	constexpr T gcd(const T x, const T y)
	{
		if (x < 0)return gcd(-x, y);
		if (y < 0)return gcd(x, -y);
		return (!y) ? x : gcd(y, x % y);
	}

	// 最小公倍数
	template<class T>
	constexpr T lcm(const T x, const T y)
	{
		if (x < 0)return lcm(-x, y);
		if (y < 0)return lcm(x, -y);
		return x * (y / gcd(x, y));
	}

	// 素数判定
	template<class T>
	constexpr bool isPrime(const T x)
	{
		if (x <= 1)return false;
		for (T i = 2; i * i <= x; ++i)
			if (x % i == 0)
				return false;
		return true;
	}
}

// argsからハッシュ値を作成
template <class... Args>
std::size_t hash(Args... args)
{
	return fold({ static_cast<std::size_t>(args)... }, 0_sz,
		[](std::size_t seed, std::size_t x)
	{
		// uses magic number from boost
		return seed ^= x + 0x9e3779b9 + (seed << 6) + (seed >> 2);
	});
}

template <class Begin, class End>
void printAll(Begin beginIter, End endIter, std::string delimiter)
{
	for (auto iter{ beginIter }; iter != endIter; ++iter)
	{
		std::cout << *iter;
		if (std::distance(iter, endIter) != 1)
			std::cout << delimiter;
	}
}

template <class Container>
void printAll(const Container& c, std::string delimiter)
{
	printAll(std::cbegin(c), std::cend(c), delimiter);
}

template<class T>
void printAll(const std::initializer_list<T>& ini, std::string delimiter)
{
	printAll(ini.begin(), ini.end(), delimiter);
}

using ld = long double;

template <class T>
constexpr T nil = static_cast<T>(-1);

int main()
{
    using namespace std;

    ll n, x;
    cin >> n >> x;

    vec<ll> a(n);
    for (auto& e : a)
        cin >> e;

    sort(a.begin(), a.end());

    ll ans{};

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

        auto result = x -= a[i];
        if (result >= 0)
            ++ans;
    }
    if (x > 0)
        --ans;

    cout << ans << endl;
    
    

	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define mp make_pair
#define ss second
#define ff first
#define ll long long
#define tcase ll t;cin>>t;while(t--)
#define sz(a) int((a).size())
#define pb push_back
#define YES cout<<"YES\n";
#define NO cout<<"NO\n";
#define Yes cout<<"Yes\n";
#define No cout<<"No\n";
#define yes cout<<"yes\n";
#define no cout<<"no\n";
#define f(i,a,b) for(int i=a;i<b;i++)
#define in insert
#define matrix vector<vector<ll> >
#define E cout<<"\n";
#define I(x) cin>>x;
#define O(x) cout<<x;
#define all(a) a.begin(),a.end()
#define vi vector<int>
const ll M=1000000007;
const double pi=3.1415926;

using namespace std;

//ll modexpo(ll a,ll b,ll p)
//{
//    ll ans=1;
//      a=a%p;  // update a if(a>=p)
//
//        if(a==0)
//            return 0;
//
//                while(b!=0)
//                {
//                    if(b%2==1)
//                        ans=(ans*a)%p;
//
//                    a=a*a;
//                    b=b/2;
//
//                }
//                return ans;
//}

//ll countbit(ll n)
//{
//    ll c=0,x=0;
//    while(n!=0)
//    {
//        c+=n&1;
//        n>>=1;
//        x++;
//    }
//    return c==x;
//}



/*  vector<int> prime1;
  int prime[10000001];

void sieve(int n)
{
       for(long long i=2;i<=n;i++)
       {
         if(prime[i]==0)
         {  prime[i]=i;
            prime1.pb(i);
         }

            for(long long j=0;j<sz(prime1) && prime1[j]<=prime[i] && i*prime1[j]<=n;j++)
            {

                   prime[i*prime1[j]]=prime1[j];


            }


      }

 return ;
}*/

void fastio()
{
       ios_base::sync_with_stdio(false);
   cin.tie(NULL);
   cout.tie(NULL);

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



int main()
{
    fastio();
     ll n,d;
     cin>>n>>d;
     ll x,y;
     int c=0;
     while(n--)
     {
         cin>>x>>y;
         x=x*x;
         y=y*y;
         ll a=x+y;
         double l=(double)sqrt(a);
         double j=(double)d;
         if(l<=j)
            c++;

     }
     cout<<c;
    return 0;
}


Measured memory_bytes: 3692
import java.util.Scanner;

class Main {
   public static void main(String[] args){
        Scanner scanner = new Scanner(System.in);
        while (scanner.hasNext()){
           String[] s = scanner.nextLine().split(",");
           int si = Integer.parseInt(s[0]);
           double wi = Double.parseDouble(s[1]);
           double hi = Double.parseDouble(s[2]);

            if (wi/Math.pow(hi,2) >= 25){
                System.out.println(si);
            }
        }
    }
}



Measured memory_bytes: 25868
import sys

sys.setrecursionlimit(10 ** 7)
input = sys.stdin.readline
f_inf = float('inf')
mod = 10 ** 9 + 7


def resolve():
    A, B, C, D, E, F = map(int, input().split())
    W = set()
    for a in range(F // (100 * A) + 1):
        for b in range(F // (100 * B) + 1):
            if 0 < 100 * A * a + 100 * B * b <= F:
                W.add(100 * A * a + 100 * B * b)
    W = sorted(list(W))
    kouho = []
    for w in W:
        max_S = (w // 100) * E
        tmp = 0
        for c in range(0, max_S + 1, C):
            for d in range(0, max_S + 1 - c, D):
                s = c + d
                if s + w <= F:
                    tmp = max(tmp, s)
        kouho.append([w + tmp, tmp])

    ma = 0
    res = [W[0], 0]
    for total, sugar in kouho:
        noudo = (sugar * 100) / total
        if ma < noudo:
            ma = noudo
            res = [total, sugar]

    print(*res)


if __name__ == '__main__':
    resolve()


Measured memory_bytes: 3064
import java.util.Arrays;
import java.util.*;
public class Main{
  public static void main(String args[]){
    Scanner sc = new Scanner(System.in);
      int a = sc.nextInt();
      int b = sc.nextInt();
      String A = String.valueOf(a);
      String B = String.valueOf(b);
      int i = 0;
      String str_a = "";
      String str_b = "";
      for(i=0;i<b;i++){
        str_a = str_a + A;
      }
      for(i=0;i<a;i++){
        str_b = str_b + B;
      }
      if(a!=b){
        if(a>b){
          System.out.println(str_b);
        }else{
          System.out.println(str_a);
        }
      }else{
        if(str_a.length()>str_b.length()){
          System.out.println(str_b);
        }else{
          System.out.println(str_a);
        }
      }
      
    }
}


Measured memory_bytes: 20820
#include <iostream>
#include <algorithm>
#include <string>
#include <cmath>
#include <vector>

#define ll long long
#define endl endl
using namespace std;

const int INF = 0x3f3f3f3f;
int arr[200001];

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int n;
    int ans=0;
    cin >> n;
    for(int i=0; i<n; i++)
    {
        cin >> arr[i];
    }
    int m = arr[0];
    for(int i=0; i<n; i++)
    {
        m = max(m, arr[i]);
        if(arr[i] >= m) ans++;
    }
    cout << ans;

}



Measured memory_bytes: 256
#include<cstdio>
#include<cstring>

char s[111];
int len, flag;

int main() {
	scanf("%s", s);
	len = strlen(s);
	flag = 0;
	for(int i=0;i<len;i++) {
		if(flag == 0 && s[i] == 'C') flag ++;
		else 
		if(flag == 1 && s[i] == 'F') flag ++;
	}
	printf("%s\n", (flag==2) ? "Yes" : "No");
	
	return 0;
}

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

#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define ANS(ans) cout << ans << endl
#define FLG(flg) if(flg) cout << "Yes" << endl; else cout << "No" << endl;
#define YES cout << "Yes" << endl;
#define NO cout << "No" << endl;
#define COUT(s) cout << s << endl;
#define AN vector<int> a(n); for(int i = 0; i < n; i++) cin >> a[i];
#define IN  int n;  cin >> n;
#define VI  vector<int> 
#define SS stringstream ss;
#define SOLVE cout << solve() << endl;

int main() {
    int n;
    string s; 
    cin >> n;
    cin >> s;
    int sum = 1;
    char a = s[0];
    REP(i,n) {
        if (s[i] != a) {
            sum += 1;
            a = s[i];
        }
    }
    COUT(sum)
}


Measured memory_bytes: 512
#include <iostream>
#include <cstdio>

using namespace std;

#define ll long long

ll sum(ll arg){
	return arg * (arg+1) / 2;
}

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

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

int main(){
	int n,m;
	
	while(cin>>n>>m){
		ll a[m];
		double ret = 0;
		long long s = sum(n);
		long long allnum = n;
		
		if((n|m) == 0) break;
		for(int i=0;i<m;i++) cin >> a[i];
		
		//ï´
		for(ll i=1;i < (1 << m); i++){
			int bitnum = 0;
			ll lc=1;
			for(int j=0;j<m;j++){
				if(i&(1<<j)){ //jÔÚvfªÜÜêÄ¢é
					bitnum++;
					lc = lcm(lc, a[j]);
				}
			}
			//cout << lc << endl;
			if(bitnum%2 == 1){
				s -= lc * sum(n / lc);
				allnum -= n / lc;
			}else{
				s += lc * sum(n / lc);
				allnum += n / lc;
			}
		}
		if(allnum == 0){
			ret = 0;
		}else{
			ret = (double)s / allnum;
		}
		//cout << sum << " " << allnum << endl;
		printf("%.7f\n",ret);
	}
}

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

namespace BeginnerCont92
{
    class Program
    {
        static void Main(string[] args)
        {
            var n = int.Parse(Console.ReadLine());
            var an = Console.ReadLine().Split().Select(d => int.Parse(d)).ToList();
            var cost = new List<int>();
            for(int i = 0; i < n - 1; i++)
            {
                cost.Add(Math.Abs(an[i]-an[i+1]));
            }
            var all = cost.Sum();
            for (int i = 0; i < n; i++)
            {
                var sum = all;
                if (i != 0)
                {
                    sum += Math.Abs(an[0]);
                    sum -= cost[i - 1];
                }
                else
                {
                    sum += Math.Abs(an[1]);
                }
                if (i != n-1)
                {
                    sum += Math.Abs(an[n - 1]);
                    sum -= cost[i];
                }
                else
                {
                    sum += Math.Abs(an[n - 2]);
                }
                if (i != 0 && i != n-1)
                {
                    sum += Math.Abs(an[i - 1] - an[i + 1]);
                }
                Console.WriteLine(sum.ToString());
            }
        }
    }
}


Measured memory_bytes: 29540
N = int(input())
[a,b] = [N // 15,N % 15]
S = 60*a*a
if b == 0:
  print(S)
else:
  for i in range(1,b+1):
    if i % 3 != 0 and i % 5 != 0:
      S += 15*a+i
  print(S)

Measured memory_bytes: 9184
#include <stdio.h>

int main(void)
{
	int a, b;
	
	scanf("%d %d", &a, &b);
	
	if(a < b)
	{
		printf("a < b\n");
	}
	else if(a > b)
	{
		printf("a > b\n");
	}
	else if(a == b)
	{
		printf("a == b\n");
	}

	return 0;
	
}

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

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

const int INF = 1001001001;

int main(){
    fastio;
    int h, n;
    cin >> h >> n;
    vector<int> dp(h+1, INF);
    dp[0] = 0;
    rep(i,n) {
        int a, b;
        cin >> a >> b;
        rep(j,h) {
            int nj = min(j+a,h);
            dp[nj] = min(dp[nj], dp[j]+b);
        }
    }
    cout << dp[h] << "\n";
    #ifdef TIMER_
    cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
    #endif
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
using namespace std;
const int MAX = 9;

char field[MAX][MAX];

void dfs(int x, int y) {
  field[y][x] = '0';
  //cout << x << ' ' << y << endl;

  for(int dy = -3 ; dy <= 3 ; dy++) {
    int ny = y + dy;
    if(1 <= ny && ny < MAX && field[ny][x] == '1') dfs(x, ny);
  }
  for(int dx = -3 ; dx <= 3 ; dx++) {
    int nx = x + dx;
    if(1 <= nx && nx < MAX && field[y][nx] == '1') dfs(nx, y);
  }
}

int main(void) {
  int N;
  int x, y;
  cin >> N;
  for(int d = 0 ; d < N ; d++) {
    for(int i = 1 ; i < MAX ; i++)
      for(int j = 1 ; j < MAX ; j++) cin >> field[i][j];
    cin >> x >> y;
    //printf("field[i][j], i = %d, j = %d\n", x, y);
    //cout << field[x][y] << endl;
    dfs(x, y);
   
    printf("Data %d:\n", d+1);
    for(int i = 1 ; i < MAX ; i++) {
      for(int j = 1 ; j < MAX ; j++) { 
	cout << field[i][j];
      }
      cout << endl;
    }
  }
  return 0;
}

Measured memory_bytes: 0
#include "bits/stdc++.h"
using namespace std;

long long dp[60][2600][60];
int main() {
    int N, A;
    cin >> N >> A;
    vector<int> X(N);
    int sum = 0;
    for (int i = 0; i < N; i++) {
        cin >> X[i];
        sum += X[i];
    }

    for (int i = 0; i < N; i++) dp[i][0][0] = 1;
    for (int i = 0; i < N; i++) {
        for (int cnt = 1; cnt <= 2500; cnt++) {
            for (int k = 0; k <= N; k++) {
                if (cnt >= X[i] && k > 0) {
                    dp[i + 1][cnt][k] += dp[i][cnt - X[i]][k - 1];
                }
                dp[i + 1][cnt][k] += dp[i][cnt][k];
            }
        }
    }

    long long ans = 0;
    for (int cnt = 1; cnt <= 2500; cnt++) {
        for (int k = 1; k <= N; k++) {
            if (cnt % k == 0 && cnt / k == A) ans += dp[N][cnt][k];
        }
    }
    cout << ans << endl;
}

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

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

const int INF = 100000000;
const double PI=acos(-1);

int main(){
    int N,M;
    cin >> N >> M;
    int s[M];
    char c[M];
    string ans;

    rep(i,M) {
        cin >> s[i] >> c[i];
        s[i]--;
    }
    rep(i,N) {
        ans.push_back('X');
    }

    rep(i,M) {
        if (ans[s[i]]=='X' || ans[s[i]]==c[i]) {
            ans[s[i]] = c[i];
        }
        else {
            ans = "-1";
            break;
        }
    }

    if (ans == "-1") {
        cout << -1 << endl;
    }
    else if (N>1 && ans[0]=='0') {
        cout << -1 << endl;

    }
    else if (N==1 && M==0) {
        cout << 0 << endl;
    }
    else {
        rep(i,N) {
            if (ans[i]=='X' && i==0) {
                ans[i] = '1';
            }
            else if (ans[i]=='X') {
                ans[i] = '0';
            }
        }
        cout << ans << endl;
    }

}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <cstdlib>

using namespace std;

/*
//Boost C++ Libraries
#include <boost/multiprecision/cpp_int.hpp>
#include <boost/numeric/ublas/io.hpp>
#include <boost/numeric/ublas/matrix.hpp>
#include <boost/numeric/ublas/vector.hpp>

namespace ublas = boost::numeric::ublas;
*/

int main(void){
    //
    string w;
    cin >> w;

    vector<int> arr(26);

    for(int i=0;i<w.length();i++){
        arr[ w.at(i) -'a'] += 1;
    }
    for(int i=0;i<arr.size();i++){
        if(arr[i]%2==1){
            cout << "No" << endl;
            return 0;
            break;
            
        }
    }
    cout << "Yes" << endl;
    return 0;
}

Measured memory_bytes: 888
#include <bits/stdc++.h>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define all(x) (x).begin(),(x).end()
#define INF 10000000
using ll = long long ;
ll gcd(ll a, ll b) {
  if(b == 0) return a;
  return gcd(b, a % b);
}
template< int id > struct CompTupleBy
{
  template<class T> 
  bool operator()( const T& a, const T& b ) const {
    return std::get<id>(a) < std::get<id>(b);
  }
};

using namespace std;

int main(){
    int n;
    cin >> n;
    int t,x,y;
    cin >> t >> x >> y;
    bool ok = true;
    if ((t % 2 == 0 && (x+y)%2 != 0) || (t % 2 != 0 && (x+y)%2 == 0)){
        ok = false;
    }
    if (t < x+y){
        ok = false;
    }
    rep(i,n-1){
        int t2,x2,y2;
        cin >> t2 >> x2 >> y2;
        if (((t2 - t) % 2 == 0 && (x2+y2-x-y)%2 != 0) || ((t2 - t) % 2 != 0 && (x2+y2-x-y)%2 == 0)){
            ok = false;
        }
        if ((t2-t) < (x2+y2-x-y)){
            ok = false;
        }
        t = t2;
        x = x2;
        y = y2;
    }
    if (ok){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    
    
}

Measured memory_bytes: 256