akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i,n) for (int i=0; i<(int)(n); i++)
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;

int main() {
  int n; cin >> n;
  vector<ll> a(n), c(n), cr(n);
  rep(i,n) {
    cin >> a[i];
    if (i==0) {c[i] = a[i]; continue;}
    c[i] = c[i-1] + a[i];
  }
  cr[n-1] = a[n-1];
  for (int i = n-2; i>=0; i--) {
    cr[i] = a[i] + cr[i+1];
  }
  ll ans = 1e15+5;
  rep(i,n-1) {
    ll snk = c[i], ara = cr[i+1];
    ans = min(abs(snk - ara), ans);
  }
  cout << ans << endl;
  return 0;
}

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

using namespace std;

typedef long long ll;

const int INF = 1e9;
const ll LLINF = 1e18;
const ll MOD = (ll)1e9 + 7;

int main()
{
  int N, K; scanf("%d %d", &N, &K);
  int ans = K;
  for (int i = 1; i < N; ++i) {
    ans *= (K - 1);
  }
  printf("%d\n", ans);
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define maxn 100010*5
using namespace std;

bool flag;

int n,m,cnt,head[maxn],col[maxn];

ll sum[5],ans;

struct E{
	int to,nxt,w;
}edge[maxn<<1];

void read(int &x){
	char s=getchar();x=0;
	while(s<'0'||s>'9') s=getchar();
	while(s>='0'&&s<='9') x=(x<<3)+(x<<1)+s-48,s=getchar();
}

inline void add(int u,int v,int w){edge[++cnt]=(E){v,head[u],w};head[u]=cnt;}

void dfs(int u){
	sum[col[u]]++;
	for(int i=head[u];i;i=edge[i].nxt){
		if(edge[i].w==1) sum[3]++;
		if(col[edge[i].to]==-1){
			col[edge[i].to]=(col[u]+edge[i].w)%3;
			dfs(edge[i].to);
		}
		else if(col[edge[i].to]!=(col[u]+edge[i].w)%3) flag=true;
	}
}

int main(){
	read(n);read(m);
	for(int i=1,x,y;i<=m;i++){
		read(x);read(y);
		add(x,y,1);
		add(y,x,2);
	}
	memset(col,-1,sizeof(col));
	for(int i=1;i<=n;i++){
		if(col[i]==-1){
			memset(sum,0,sizeof(sum));
			flag=col[i]=0;
			dfs(i);
			if(flag){
				ans+=(sum[0]+sum[1]+sum[2])*(sum[0]+sum[1]+sum[2]);
				continue;
			}
			if(sum[0]==0||sum[1]==0||sum[2]==0){
				ans+=sum[3];
				continue;
			}
			ans+=sum[0]*sum[1]+sum[1]*sum[2]+sum[2]*sum[0];
		}
	}
	printf("%lld",ans);
	return 0;
}

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

struct RSQ {
	using type = int;
	static type id() { return 0; }
	static type op(const type& l, const type & r) { return l + r; }
};

struct seg_node {
	using M = RSQ;
	using T = typename M::type;
	using U = int;

	T val;

private:
	int size;
	bool flag;
	U lazy;

public:
	seg_node() : val(), size(0), flag(false) {}
	void init_leaf(const T& v) {
		val = v;
		size = 1;
	}
	void init_non_leaf(const seg_node& l, const seg_node& r) {
		val = M::op(l.val, r.val);
		size = l.size + r.size;
	}
	void update(U v) {
		val = v * size;
		lazy = v;
		flag = true;
	}
	void push(seg_node& l, seg_node& r) {
		if (!flag) return;
		l.update(lazy);
		r.update(lazy);
		flag = false;
	}
	bool is_updated() const {
		return flag;
	}

};

class lazy_segment_tree {
	using M = typename seg_node::M;
	using T = typename seg_node::T;
	using U = typename seg_node::U;
	const int h, n;
	vector<seg_node> data;
	void push(int node) {
		data[node].push(data[node << 1], data[(node << 1) | 1]);
	}
	void update(int node) {
		data[node].val = M::op(data[node << 1].val, data[(node << 1) | 1].val);
	}
public:
	lazy_segment_tree(int n_)
		: h(ceil(log2(n_))), n(1 << h), data(n * 2) {}
	lazy_segment_tree(int n_, T v1)
		: h(ceil(log2(n_))), n(1 << h), data(n * 2) {
		for (int i = 0; i < n_; i++)
			data[i + n].init_leaf(v1);
		for (int i = n - 1; i >= 1; i--)
			data[i].init_non_leaf(data[i << 1], data[(i << 1) | 1]);
	}
	lazy_segment_tree(const vector<T>& data_)
		: h(ceil(log2(data_.size()))), n(1 << h), data(n * 2) {
		for (int i = 0; i < (int)data_.size(); i++)
			data[i + n].init_leaf(data_[i]);
		for (int i = n - 1; i >= 1; i--)
			data[i].init_non_leaf(data[i << 1], data[(i << 1) | 1]);
	}
	void update(int l, int r, U val) {
		l += n, r += n;
		for (int i = h; i > 0; i--) push(l >> i), push(r >> i);
		int tl = l, tr = r;
		r++;
		while (l < r) {
			if (l & 1) data[l++].update(val);
			if (r & 1) data[--r].update(val);
			l >>= 1; r >>= 1;
		}
		while (tl >>= 1, tr >>= 1, tl) {
			if (!data[tl].is_updated()) update(tl);
			if (!data[tr].is_updated()) update(tr);
		}
	}
	T find(int l, int r) {
		l += n, r += n;
		for (int i = h; i > 0; i--) push(l >> i), push(r >> i);
		r++;
		T res1 = M::id(), res2 = M::id();
		while (l < r) {
			if (l & 1) res1 = M::op(res1, data[l++].val);
			if (r & 1) res2 = M::op(data[--r].val, res2);
			l >>= 1; r >>= 1;
		}
		return M::op(res1, res2);
	}
};

int main()
{
	ios::sync_with_stdio(false), cin.tie(0);
	int n, q;
	cin >> n >> q;
	lazy_segment_tree st(n, 0);
	while (q--) {
		int com;
		cin >> com;
		if (com == 0) {
			int s, t, x;
			cin >> s >> t >> x;
			st.update(s, t, x);
		}
		else {
			int s, t;
			cin >> s >> t;
			printf("%d\n", st.find(s, t));
		}
	}
	return 0;
}



Measured memory_bytes: 7236
N = int(input())
"""
f = [0]*(N + 1)
f[0] = 1
f[1] = 1
for i in range(2, N + 1):
    f[i] = i * f[i - 2]

count = 0
while f[N] % 10 == 0:
    count += 1
    f[N] = f[N] // 10
    #print(count, f[N])

print(count)
"""
if N % 2 == 1:
    print(0)
if N % 2 == 0:
    five_count = 0
    while N >= 5**five_count:
        five_count += 1
    
    num_5 = list()
    for i in range(1, five_count + 1):
        num = N // (5**i)

        num_5.append(num//2)
        
    sum_5 = sum(num_5)
    print(sum_5)

Measured memory_bytes: 38384
#include<bits/stdc++.h>
#define Imposter ios_base::sync_with_stdio(false);cin.tie(NULL);
#define pb push_back
#define ll long long int
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#pragma GCC optimize("O3")
using namespace __gnu_pbds;
#define ordered_set tree<ll, null_type,less_equal<ll>, rb_tree_tag,tree_order_statistics_node_update>//s.order_of_key(val) *s.find_by_order(ind)
using namespace std;
#define f(n) for(ll i=0;i<n;i++)
#define rep(i,a,b) for(i=a;i<b;i++)
#define input(arr,n) for(ll i1=0;i1<n;i1++ )cin>>arr[i1]
#define vll vector<ll>
#define vlll vector<vll>
#define all(x) x.begin(),x.end()
ll power(ll x, ll y, ll p) { 
    ll res = 1;    x = x % p;  
    while(y > 0) {
        if(y & 1) res = (res*x) % p; 
        y = y>>1;    x = (x*x) % p; 
    } return res; 
}
ll a[13];
void make(ll i)
{
    a[i]=a[i-1]+pow(26,i);
    if(i<13)
    make(i+1);
    else
    return;
}
int main()
{
    Imposter
    
    int t=1;
    //cin>>t;
    while(t--)
    {
     
       ll n;
       cin>>n;
       ll a[n];
       input(a,n);
       ll pataka=a[0];
       for(int i=1;i<n;i++)
       pataka^=a[i];
       f(n) {ll temp=pataka^a[i];cout<<temp<<" ";}
    }
    return 0;
}

Measured memory_bytes: 5144
using System;

namespace ABC110_B_Dimensinal_Worlds_Tale
{
	internal class Program
	{
		public static void Main(string[] args)
		{
			string[] inStrArr = Console.ReadLine().Split(' ');
			int N = int.Parse(inStrArr[0]);
			int M = int.Parse(inStrArr[1]);

			int APosition = int.Parse(inStrArr[2]);
			int BPosition = int.Parse(inStrArr[3]);

			string[] XPosition = Console.ReadLine().Split(' ');
			string[] YPosition = Console.ReadLine().Split(' ');

			int[] XPositionInt = new int[N];
			int[] YPositionInt = new int[M];

			for (int index = 0; index < N; index++)
			{
				XPositionInt[index] = int.Parse(XPosition[index]);
			}
			
			for (int index = 0; index < M; index++)
			{
				YPositionInt[index] = int.Parse(YPosition[index]);
			}

			for (int index = 0; index < N - 1; index++) {
				for (int j = index + 1; j < N; j++) {
					if (XPositionInt[index] < XPositionInt[j])
					{
						int value = XPositionInt[index];
						XPositionInt[index] = XPositionInt[j];
						XPositionInt[j] = value;
					}
				}
			}
			
			
			for (int index = 0; index < M - 1; index++) {
				for (int j = index + 1; j < M; j++) {
					if (YPositionInt[index] > YPositionInt[j])
					{
						int value = YPositionInt[index];
						YPositionInt[index] = YPositionInt[j];
						YPositionInt[j] = value;
					}
				}
			}

			int z = XPositionInt[0] + 1;
			
			if (z <= YPositionInt[0] && APosition < z && z <= BPosition)
			{
				Console.WriteLine("No War");
			}
			else
			{
				Console.WriteLine("War");
			}
		}
	}
}

Measured memory_bytes: 11092
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <map>
#include <stack>
#include <functional>

using namespace std;
using ll = long long;

int main()
{
	int d, g;
	cin >> d >> g;

	vector<ll> p(d);
	vector<ll> c(d);
	
	for (int i = 0; i < d; i++)
	{
		cin >> p.at(i) >> c.at(i);
	}

	ll res = 1 << 29;
	for (int bit = 0; bit < (1 << d); ++bit)
	{
		ll sum = 0;
		ll num = 0;
		for (int i = 0; i < d; ++i)
		{
			if (bit & (1 << i)) sum += c[i] + p[i] * 100 * (i + 1), num += p[i];
		}
		if (sum >= g) res = min(res, num);
		else
		{
			for (int i = d - 1; i >= 0; --i)
			{
				if (bit & (1 << i)) continue;
				for (int j = 0; j < p[i]; ++j)
				{
					if (sum >= g) break;
					sum += 100 * (i + 1);
					++num;
				}
			}
			res = min(res, num);
		}
	}
	cout << res << endl;
}

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

int main(){
    long long int s,b,c,a=753,d=1000;
    cin>>s;
    for(int i=0;s>100;i++){
    	c=abs(s%1000-a);
    	if(c<d){
    		d=c;
    	}
    	s=s/10;
    }
    cout<<d<<endl;

    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <tuple>
#include <utility>
#include <vector>
using namespace std;
using ll = long long;
const int INF = 1000000009;
const ll LINF = 1e18;

int n, m, q;
vector<int> a, b, c, d;
int ans;

void dfs(vector<int> A) {
  if (A.size() == n + 1) {
    int now = 0;
    for (int i = 0; i < q; ++i) {
      if (A[b[i]] - A[a[i]] == c[i]) now += d[i];
    }
    ans = max(ans, now);
    return;
  }

  A.push_back(A.back());
  while (A.back() <= m) {
    dfs(A);
    A.back()++;
  }
}

int main() {
  cin >> n >> m >> q;
  a.resize(q);
  b.resize(q);
  c.resize(q);
  d.resize(q);

  for (int i = 0; i < q; ++i) cin >> a[i] >> b[i] >> c[i] >> d[i];
  dfs(vector<int>(1, 1));
  cout << ans << endl;
}


Measured memory_bytes: 3176
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int x;
    cin >> x;
    int ans = 1;
    for(int i = 2; i * i <= x; i++)
    {
        int j = i;
        while(i * j <= x)
        {
            ans = max(ans, i*j);
            j *= i;
        }
    }
    cout << ans << endl;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
#define mod 1000000007
using namespace std;
typedef long long int ll;
typedef pair<int,int> pi;
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    int x,y;
    cin>>x>>y;
    cout<<(x+y/2);
}


Measured memory_bytes: 256
S = input()

max_cnt = 0
for i in range(len(S)):
    cnt = 0
    if S[i] == "A" or S[i] == "C" or S[i] == "G" or S[i] == "T":
        cnt += 1
        for j in range(len(S)-(1+i)):
            if S[j+i+1] == "A" or S[j+i+1] == "C" or S[j+i+1] == "G" or S[j+i+1] == "T":
                cnt += 1
            else:
                break
    if cnt >= max_cnt:
        max_cnt = cnt
print(max_cnt)

Measured memory_bytes: 9112
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int retu = scanner.nextInt();
        int gyou = scanner.nextInt();
        int[][] shuturyoku = new int[(retu + 1)][(gyou + 1)];

        for (int i = 1; retu >= i; i++) {
            for (int j = 1; gyou >= j; j++) {
                int a = scanner.nextInt();
                shuturyoku[i - 1][j - 1] = a;
            }
        }
        for (int i = 1; retu >= i; i++) {
            for (int j = 1; gyou >= j; j++) {
                shuturyoku[i - 1][gyou] += shuturyoku[i - 1][j - 1];
            }
        }
        for (int i = 1; retu >= i; i++) {
            for (int j = 1; gyou >= j; j++) {
                shuturyoku[retu][j - 1] += shuturyoku[i - 1][j - 1];
            }
        }
        for (int i = 1; retu >= i; i++) {
            shuturyoku[retu][gyou] += shuturyoku[i-1][gyou];
        }
        for (int i = 1; retu + 1 >= i; i++) {
            for (int j = 1; gyou + 1 >= j; j++) {
                if (j != gyou+1) {
                    System.out.print(shuturyoku[i - 1][j - 1] + " ");
                } else {
                    System.out.println(shuturyoku[i - 1][j - 1]);
                }
            }
        }
    }
}

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

int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  rep(i, n) cin >> a[i];

  ll nowa = 0;
  ll sum = 0;
  rep(i, n) {
    sum += a[i];
    if (i%2==0) {
      if (sum <= 0) {
        nowa += 1 - sum;
        sum = 1;
      }
    }
    else {
      if (sum >= 0) {
        nowa += sum + 1;
        sum = -1;
      }
    }
  }
  ll ans = nowa;
  nowa = 0;
  sum = 0;
  rep (i, n) {
    sum += a[i];
    if (i % 2 == 1) {
      if (sum <= 0) {
        nowa += 1 - sum;
        sum = 1;
      }
    }
    else {
      if (sum >= 0) {
        nowa += sum + 1;
        sum = -1;
      }
    }
  }
  ans = min(ans, nowa);
  printf("%lld\n", ans);
}


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

int main(){
  int N;
  cin >> N;
  if(N == 25) cout << "Christmas" << endl;
  else if(N == 24) {
    cout << "Christmas" << endl;
    cout << "Eve" << endl;
  } 
  else if(N == 23) {
    cout << "Christmas" << endl;
    cout << "Eve" << endl;
    cout << "Eve" << endl;
  }
  else if(N == 22) {
    cout << "Christmas" << endl;
    cout << "Eve" << endl;
    cout << "Eve" << endl;
    cout << "Eve" << endl;
  }
}
    
      

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i = 0; i < (n); ++i)
int main() {
    int n;
    cin >> n;
    vector<string> s_enda;
    vector<string> s_beginb;
    vector<string> s_endabeginb;
    int ans = 0;
    rep(i, n) {
        string tmp_s;
        cin >> tmp_s;
        rep(j, tmp_s.length()-1) {
            if ( tmp_s[j] == 'A' && tmp_s[j+1] == 'B' ) ++ans;
        }
        if ( tmp_s[tmp_s.length()-1] == 'A' && tmp_s[0] == 'B' ) {
            s_endabeginb.push_back(tmp_s);
        }
        else if ( tmp_s[tmp_s.length()-1] == 'A') s_enda.push_back(tmp_s);
        else if ( tmp_s[0] == 'B' ) s_beginb.push_back(tmp_s);
    }
    int endanum = s_enda.size();
    int beginbnum = s_beginb.size();
    if ( s_endabeginb.size() > 0 ) {
        if ( endanum > 0 ) {
            ++ans;
            --endanum;
        }
        if ( beginbnum > 0 ) {
            ++ans;
            --beginbnum;
        }
    }
    int endabeginbnum = s_endabeginb.size();
    if ( endabeginbnum > 0 ) {
        --endabeginbnum;
    }
    cout << ans + endabeginbnum + min(endanum, beginbnum) << endl;
    return 0;
}


Measured memory_bytes: 768
#include<bits/stdc++.h>
#include <iostream>
#include <numeric>
#include <math.h>
#define ll long long 
#define ull long
#define mpa make_pair
#define pb push_back
#define ff first
#define pii pair<ll,ll>
#define dd long long
#define trace(x) cerr << #x << " : " << x << endl
#define ss second
#define boost ios_base::sync_with_stdio(0)
#define forp(i,a,b) for(ll i=a;i<=b;i++)
#define rep(i,n)    for(ll i=0;i<n;++i)
#define ren(i,n)    for(ll i=n-1;i>=0;i--)
#define forn(i,a,b) for(ll i=a;i>=b;i--)
#define all(c) (c).begin(),(c).end()
#define tr(c,i) for(typeof((c).begin()) i = (c).begin(); i != (c).end();
#define sc(x) scanf("%lld",&x)
#define clr(x,val) memset(x,val,sizeof(x))
#define pr(x) printf("%lld\n",x) 
#define gc getchar
#define pdd pair<dd,dd>
#define prec(x) cout<<fixed<<setprecision(x)
#define fre freopen("input.txt","r",stdin),freopen("output.txt","w",stdout)
using namespace std;
char s[1005],t[1005];
int main(){
	ll n,m,ans=1e9;
	cin>>(s+1)>>(t+1);
	
	n=strlen(s+1);
	m=strlen(t+1);
	
	ans=m;
	
	for(ll i=1;i<=n;i++){
		if(i+m-1>n)continue;
		ll ch=0;
		
		
		for(ll j=i;j<=i+m-1;j++) ch+=(t[j-i+1]!=s[j]);
		
		ans=min(ans,ch);
		
	}
	cout<<ans;
}
  
  
  
   


    

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef vector<ll> vl;
typedef pair<ll, ll> PP;
#define rep(i, n) for(ll i = 0; i < ll(n); i++)
#define all(v) v.begin(), v.end()
#define inputv(v, n)                                                           \
    vl v;                                                                      \
    rep(i, n) {                                                                \
        ll x;                                                                  \
        cin >> x;                                                              \
        v.push_back(x);                                                        \
    }
bool chmin(ll& a, ll& b) { if (b < a) { a = b; return 1; } return 0; }
bool chmax(ll& a, ll& b) { if (b > a) { a = b; return 1; } return 0; }
const ll INF = 999999999999999;
const ll MOD = 1000000007;
const ll MAX_N = 500010;
ll a, b, c, d, e, f, p, t, x, y, z, q, m, n, r, h, k, w, l, ans;
int main() {
    cin >> n;
    char A[n][n], B[n][n];

    rep(i, n) {
        rep(j, n) {
            cin >> A[i][j];
        }
    }

    rep(_, n) {
        rep(i, n) {
            rep(j, n) {
                B[i][j] = A[i][(j + _) % n];
            }
        }

        k = 1;
        rep(i, n) {
            rep(j, i) {
                if (B[i][j] != B[j][i])k = 0;
            }
        }

        ans += k;
    }

    cout << ans * n << endl;
}


Measured memory_bytes: 384
#!/usr/bin/python

import re
import sys

def main(argv):
    line = sys.stdin.readline()
    while line:
        A, B = map(lambda x: int(x), line.rstrip("\n").split(" "))
        S = sys.stdin.readline().rstrip("\n")
        pattern = "\d{{{0}}}-\d{{{1}}}$".format(A, B)
        if re.match(pattern, S):
            print "Yes"
        else:
            print "No"

        line = sys.stdin.readline()

if __name__ == "__main__":
    main(sys.argv)

Measured memory_bytes: 2568
#include <ctype.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int main(void) {
  int a, b, t;

  if (scanf("%d %d %d", &a, &b, &t) == 1) {
    printf("入力エラー");
    return 0;
  }

  printf("%d", t / a * b);

  return 0;
}

Measured memory_bytes: 128
#include <iostream>
using namespace std;
int a,b,c;
int main(){
	while(cin>>a>>b>>c){
	int N,data[1100][5]={},ad[110]={},bd[110]={},cd[110]={};
	if(a==0 && b==0 && c==0){
		break;
	}
	cin>>N;
	for(int i=1;i<=N;i++){
		for(int j=1;j<=4;j++){
			cin>>data[i][j];
		}
	}
	for(int i=1;i<110;i++){
		ad[i]=2;
		bd[i]=2;
		cd[i]=2;
	}
	for(int i=1;i<=N;i++){
		if(data[i][4]==1){
			ad[data[i][1]]=1;
			bd[data[i][2]-a]=1;
			cd[data[i][3]-a-b]=1;
		}
	}
	for(int i=1;i<=N;i++){
		if(ad[data[i][1]]==1 && bd[data[i][2]-a]==1){
			if(cd[data[i][3]-a-b]!=1){
				cd[data[i][3]-a-b]=0;
			}
		}
		if(ad[data[i][1]]==1 && cd[data[i][3]-a-b]==1){
			if(bd[data[i][2]-a]!=1){
				bd[data[i][2]-a]=0;
			}
		}
		if(bd[data[i][2]-a]==1 && cd[data[i][3]-a-b]==1){
			if(ad[data[i][1]]!=1){
				ad[data[i][1]]=0;
			}
		}
	}
	for(int i=1;i<=a;i++){
		cout<<ad[i]<<endl;
	}
	for(int i=1;i<=b;i++){
		cout<<bd[i]<<endl;
	}
	for(int i=1;i<=c;i++){
		cout<<cd[i]<<endl;
	}
	}
	return 0;
}

Measured memory_bytes: 1188
#include <bits/stdc++.h>
#define ll long long
#define ALL(x) x.begin(),x.end()
#define MOD (1000000000+7)
using namespace std;
#define PI 3.14159265359
#define tMOD 998244353
#define mkpr(x,y) make_pair(x,y)
 int N,M;
   int v[200400];
   int vs[203000]={0};
   
int root(int i){
    if(v[i]==i){
        return i;
    }
    else{
        return root(v[i]);
    }
}

int margego(int tibi,int deka){
    int rtibi =root(tibi),rdeka = root(deka);
if(rtibi==rdeka){
return 0;
}
else
{   
    if(vs[rtibi]<vs[rdeka]) swap(rtibi,rdeka);
    vs[rtibi]=vs[rdeka]+vs[rtibi];
    v[rdeka]=rtibi;
}
return 0;
}




int main(){

    cin>>N>>M;
    for(int i=0;i<N;i++){
        v[i]=i;
        vs[i]=1;
    }

    for(int i=0;i<M;i++){
        int tmp,tmp1;
        cin>>tmp>>tmp1;
        margego(tmp-1,tmp1-1) ;
    }
    int ans=0;
    for(int i=0;i<N;i++){
        ans =max(ans,vs[i]);
    }

    cout<<ans<<endl;
   

    
}





Measured memory_bytes: 5188
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
using namespace std;
static const int MAX = 200000;

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

	if (s[0] == '9' || s[1] == '9') {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include<iomanip>
#include <string>
#include<vector>
#include<algorithm>
#include<utility>
#include<queue>
#include<math.h>
#include<stack>
#include<set>
#include<map>
#include<cstdlib>
#define INF 1001001001001001001
#define MAX 2001001

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

using namespace std;

int main() {
	int n, x, t;
	cin >> n >> x >> t;
	cout << ((n - 1) / x + 1) * t << endl;
}

Measured memory_bytes: 3600
#include<stdio.h>
int main()
{
  int N;
  double y,x;
  scanf("%d",&N);
  if(N%2==0)printf("0.5");

  if(N%2==1){
    x=(double)N/2+0.5;
    y=x/(double)N;
    printf("%f",y);
  }
  return 0;
}



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

int K, a, t;

int main(){
    while(scanf("%d", &K), K){
        a = 0;
        for(int x = 0; x < K*(K-1)/2; ++x){
            scanf("%d", &t);
            a += t;
        }
        printf("%d\n", a/(K-1));
    }
    return 0;
}

Measured memory_bytes: 1188
import java.util.Scanner;

public class Main { 

	public static void main(String[] args) {
    	Scanner sc = new Scanner(System.in);
    	String[] line = sc.nextLine().split(" ");
    	long firstNumber = Long.parseLong(line[0]);
    	long secoundNumber = Long.parseLong(line[1]);
    	String result = "";
    	if(firstNumber % 2 != secoundNumber % 2 ) {
    		result = "IMPOSSIBLE";
    	}else {
    		long tmp = (firstNumber + secoundNumber)/2;
    		result = String.valueOf(tmp);
    	}
    	
    	
    	System.out.println(result);
    	
	}
}

Measured memory_bytes: 22228
import java.util.Scanner;

public class Main {

	static Scanner scanner;
	public static void main(String[] args) {
	    scanner = new Scanner(System.in);

	    int n=gi();
	    int k=gi();

	    
	    //System.out.print(a-b+1);
	    if (Math.floorDiv(n+1, 2) >=k) {
	    	System.out.print("YES");
	    }else {
	    	System.out.print("NO");
	    }



	}

	public static long d(long n) {
		String a=String.valueOf(n);
		return (long)a.length();
	}

	// 文字列として入力を取得
	public static String gs() {
		return scanner.next();
	}

	// intとして入力を取得
	public static int gi() {
		return Integer.parseInt(scanner.next());
	}

	// longとして入力を取得
	public static long gl() {
		return Long.parseLong(scanner.next());
	}

	// doubleとして入力を取得
	public static double gd() {
		return Double.parseDouble(scanner.next());
	}
}

Measured memory_bytes: 35580
input = input().split()
s = input[0]
t = input[1]

s_letter = list(s)
t_letter = list(t)

if(len(s_letter) > 100 or len(s_letter) == 0):
  raise ValueException("the length of S must be over 1 and under 100")
  
if(len(t_letter) > 100 or len(t_letter) == 0):
  raise ValueException("the length of T must be over 1 and under 100")  

for sl in s_letter:
  if(sl.isupper()):
    raise ValueException("the letter must be lowercase")
    
for tl in t_letter:  
  if(tl.isupper()):
    raise ValueException("the letter must be lowercase")
    
str = t + s
print(str)


Measured memory_bytes: 3064
#include <iostream>
#include <math.h>
using namespace std;
int main(){
  int n,d;
  cin >>n >>d;
  double a;
  int count=0;
  int i,j;
  int l;
  int x[n][d];
  for( i = 0; i<n; i++){
    for( j = 0; j < d; j++){
      cin >>x[i][j];
    }
  }
  for(int i = 0; i<n; i++){
    for(int j = i; j < n-1; j++){
      a = 0;
      for(int k = 0; k<d; k++){
          a += (x[i][k]-x[j+1][k])*(x[i][k]-x[j+1][k]);
        //  cout <<a <<x[i][k]+x[j+1][k] <<endl;
        }
        a= sqrt(a);
        if(ceil(a) == floor(a)){
          count++;
        }
      }
    }
    cout <<count;

  }



Measured memory_bytes: 256
#include<bits/stdc++.h>
#define del(a,i) memset(a,i,sizeof(a))
#define ll long long
#define inl inline
#define il inl void
#define it inl int
#define ill inl ll
#define re register
#define ri re int
#define rl re ll
#define mid ((l+r)>>1)
#define lowbit(x) (x&(-x))
#define INF 0x3f3f3f3f
using namespace std;
template<class T>il read(T &x){
	int f=1;char k=getchar();x=0;
	for(;k>'9'||k<'0';k=getchar()) if(k=='-') f=-1;
	for(;k>='0'&&k<='9';k=getchar()) x=(x<<3)+(x<<1)+k-'0';
	x*=f;
}
template<class T>il _print(T x){
	if(x/10) _print(x/10);
	putchar(x%10+'0');
}
template<class T>il print(T x){
	if(x<0) putchar('-'),x=-x;
	_print(x);
}
ll mul(ll a,ll b,ll mod){long double c=1.;return (a*b-(ll)(c*a*b/mod)*mod)%mod;}
it qpow(int x,int m,int mod){
	int res=1,bas=x%mod;
	while(m){
		if(m&1) res=(1ll*res*bas)%mod;
		bas=(1ll*bas*bas)%mod,m>>=1;
	}
	return res%mod;
}
int n,k,val,ans;
int main(){
//	freopen(".in","r",stdin);
//	freopen(".out","w",stdout);
	read(n),read(k);
	for(ri i=1;i<=n;++i) read(val),ans+=(val>=k);
	print(ans);	
	return 0;
}

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

#define rep(i, n) for (int i = 0; i < (n); i++)
#define pb push_back
#define all(v) (v).begin(), (v).end()

typedef long long ll;

template <class T = int>
T in() { T x; cin >> x; return x; }
#define output(e) cout << e << '\n'

#ifdef LOCAL
#define dr(x) cout << "L" << __LINE__ << ": " << #x << " -> " << x << "\n"
#else
#define dr(x)
#endif

//
// Implementation
//

int main() {
  int A = in();
  int B = in();
  int C = in();

  for (int i = A; i <= 10000; i += A) {
    if (i % B == C) {
      output("YES");
      return 0;
    }
  }

  output("NO");
  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<stdint.h>
#include<inttypes.h>

typedef struct segment_tree_void {
  void *array;
  int32_t size;
  size_t val_size;
  void (*func) (void *, const void *, const void *);
} segment_tree;

static inline void segment_tree_memcpy (void *dst, const void *src, size_t size) {
  uint8_t *p = dst;
  const uint8_t *q = src;
  while (size--) {
    *p++ = *q++;
  }
}

segment_tree* new_segment_tree (const void *ini, const int32_t n, const size_t val_size, void (*func) (void *, const void *, const void *)) {
  int32_t k = 1;
  while (k < n) k *= 2;
  segment_tree *s = (segment_tree *) calloc (1, sizeof (segment_tree));
  s->array = calloc (2 * k, val_size);
  s->size = k;
  s->val_size = val_size;
  s->func = func;
  for (int32_t i = k; i < 2 * k; ++i) {
    segment_tree_memcpy ((uint8_t *)s->array + i * val_size, ini, val_size);
  }
  uint8_t *a = s->array;
  for (int32_t i = k - 1; i > 0; --i) {
    func (a + i * val_size, a + (2 * i) * val_size, a + (2 * i + 1) * val_size);
  }
  return s;
}

void update (segment_tree * const s, int32_t k, const void *val) {
  k += s->size;
  uint8_t * const p = s->array;
  const size_t size = s->val_size;
  segment_tree_memcpy (p + k * size, val, size);
  for (k >>= 1; k > 0; k >>= 1) {
    s->func (p + k * size, p + 2 * k * size, p + (2 * k + 1) * size);
  }
}

void update_tmp (segment_tree * const s, int32_t k, const void *val) {
  k += s->size;
  uint8_t * const p = s->array;
  const size_t size = s->val_size;
  segment_tree_memcpy (p + k * size, val, size);
}

void update_all (segment_tree * const s) {
  uint8_t * const a = s->array;
  const size_t size = s->val_size;
  for (int32_t i = s->size - 1; i > 0; --i) {
    s->func (a + i * size, a + (2 * i) * size, a + (2 * i + 1) * size);
  }
}

void find (const segment_tree *s, int32_t l, int32_t r, void *res) {
  int32_t lindex[64];
  int32_t rindex[32];
  int32_t llen = 0;
  int32_t rlen = 0;
  for (l += s->size, r += s->size; l < r; l >>= 1, r >>= 1) {
    if (l & 1) lindex[llen++] = l++;
    if (r & 1) rindex[rlen++] = --r;
  }
  while (rlen > 0) {
    lindex[llen++] = rindex[--rlen];
  }
  const uint8_t *p = s->array;
  segment_tree_memcpy (res, p + lindex[0] * s->val_size, s->val_size);
  for (int32_t i = 1; i < llen; ++i) {
    s->func (res, res, p + lindex[i] * s->val_size);
  }
}

typedef int32_t i32;

void func_max (void *c, const void *a, const void *b) {
  i32 p = *(i32 *)a;
  i32 q = *(i32 *)b;
  *(i32 *)c = p > q ? p : q;
}

void run (void) {
  i32 n;
  scanf ("%" SCNi32, &n);
  const i32 ini = -1;
  segment_tree *s = new_segment_tree (&ini, n + 2, sizeof (i32), func_max);
  for (i32 i = 1; i <= n; ++i) {
    i32 a;
    scanf ("%" SCNi32, &a);
    update_tmp (s, i, &a);
  }
  update_all (s);
  for (i32 i = 1; i <= n; ++i) {
    i32 x, y;
    find (s, 0, i, &x);
    find (s, i + 1, n + 2, &y);
    i32 z = x > y ? x : y;
    printf ("%" PRIi32 "\n", z);
  }
}

int main (void) {
  run();
  return 0;
}


Measured memory_bytes: 3584
#include <bits/stdc++.h>
#define FI first
#define SE second
#define PB push_back
#define ll long long
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define ROF(i,a,b) for(int i=b-1;i>=a;i--)
#define YES(i) cout<<(i?"YES":"NO")<<endl
#define Yes(i) cout<<(i?"Yes":"No")<<endl
#define co(i) cout<<(i)<<endl
#define fcout cout<<fixed<<setprecision(10)
#define uni(i) i.erase(unique(i.begin(), i.end()), i.end());
#define all(i) i.begin(),i.end()
#define pint pair<int, int>
#define vint vector<int>
using namespace std;

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

int main(){
	string s; cin>>s;
	ll ans=0;
	int f=1;
	ll c=0;
	FOR(i,0,s.size()){
		if(s[i]=='B'){
			ans+=(s.size()-i-1-c);
			c++;
		}else{
			f=0;
		}
	}
	if(f) co(0);
	else co(ans);
}


Measured memory_bytes: 640
#include"algorithm"
#include"iostream"
#include"stdlib.h"
#include"string.h"
#include"stdio.h"
#include"math.h"
#include"vector"
#include"set"
#include"map"

using namespace std;

const int N=1000005;
int n,ans,m,L[N][26],match[N];
char S[N],T[N];

struct node{
	int u,v;
	node(int _u=0,int _v=0){
		u=_u,v=_v;
	}
}a[N],b[N];

int main(){
	scanf("%d%s%s",&n,S+1,T+1);
	register int p=n,q,last=n+1;
	for(int i=1;i<=n;i++){
		memcpy(L[i],L[i-1],104);
		L[i][S[i]-'a']=i;
	}
	for(int i=n;i>=1;i--)
		match[i]=S[i]==T[i]?match[i+1]+1:0;
	while(p){
		for(q=p;T[q]==T[p]&&q;q--);q++;
		int pos=L[min(last-1,q)][T[q]-'a'];
		if(!pos)puts("-1"),exit(0);
		else if(pos!=q||match[q]<p-q+1)a[++m]=node(pos,p),last=pos;
		p=q-1;
	}
	for(int i=1;i<=m;i++)b[i]=a[m+1-i];
	b[m+1].u=2E9;
	for(int i=1;i<=m;i++){
		int l=i,r=m+1,mid=(l+r)>>1;
		while(l<r){
			if(b[mid].u-(mid-i)>=b[i].v)r=mid;
			else l=mid+1;
			mid=(l+r)>>1;
		}
		ans=max(ans,mid-i);
	}
	printf("%d\n",ans);
	return 0;
}

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

#define REP(i, n) for(int i = 0; i < (int)(n); ++i)
#define FOR(i, m, n) for(int i = (int)(m); i < (int)(n); ++i)


const int MOD = 1e+9 + 7;

// MOD を取りながら nCm を計算する方法
// フェルマーの小定理を使って逆元を使う
template <typename T>
T pow_mod(T n, T p, T m)  // (n^p) % m
{
    if( p == 0 ) return 1;
    if( p%2 == 1 ) return pow_mod<T>(n, p-1, m) * n % m;
    else{
        T tmp = pow_mod<T>(n, p/2, m) % m;
        return tmp * tmp % m;
    }
}

template <typename T=long long>
T nCk_mod(T n, T k, T m)
{
    if( n < 0 or k < 0 || n < k ) return 0;
    T numerator = 1, denominator = 1;
    for(int i = 1; i <= min(k, n-k); ++i){
        numerator = numerator*(n-i+1) % m;
        denominator = denominator*i % m;
    }
    return numerator * pow_mod<T>(denominator, m-2, m) % m;
}


int main()
{
    long long n, a, b;
    cin >> n >> a >> b;

    long long ans = pow_mod<long long>(2, n, MOD) - 1;
    ans -= nCk_mod<long long>(n, a, MOD) + nCk_mod<long long>(n, b, MOD);
    cout << (ans+2*MOD)%MOD << endl;

    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#define rep(i,r) for(int i=0;i<r;i++)

int main() {
	int N;
	scanf("%d", &N);
	char S[N];
	scanf("%s", &S);
	long R = 0, G = 0, B = 0;
	rep(i,N) {
		if (S[i] == 'R') R++;
		else if (S[i] == 'G') G++;
		else B++;
	}
	
	long count = R * G * B;
	for (int i = 0; i < N - 2; i++) {
		for (int j = 1; i + j * 2 < N; j++) {
			if (S[i] != S[i + j]
				&& S[i] != S[i + j * 2]
				&& S[i + j] != S[i + j * 2]) count--;
		}
	}
	
	printf("%ld", count);
	return 0;
}


Measured memory_bytes: 1696
#include <bits/stdc++.h>
using namespace std;
int main()
{
    long long n;
    cin >> n;
    vector< long long > fac;
    for (long long i = 1; i <= n / i; i++) {
        if (n % i == 0) {
            fac.push_back(i);
            fac.push_back(n / i);
        }
    }
    sort(fac.begin(), fac.end());
    long long Min = LLONG_MAX;
    for (int i = 0; i < fac.size(); i++) {
        Min = min(Min, fac[i] + n / fac[i] - 2);
    }
    cout << Min << endl;
    return 0;
}

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

sa = list(str(input()))
sb = list(str(input()))
sc = list(str(input()))

t = 'a'
winner = ''

while True:
    if t == 'a':
        if len(sa) == 0:
            winner = 'A'
            break  
        t = sa.pop(0)
    elif t == 'b':
        if len(sb) == 0:
            winner = 'B'
            break  
        t = sb.pop(0)
    else:
        if len(sc) == 0:
            winner = 'C'
            break  
        t = sc.pop(0)

print(winner)

Measured memory_bytes: 8996
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define FOR(i,s,n) for(int i = s; i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(n) (n).begin(), (n).end()
#define RALL(n) (n).rbegin(), (n).rend()
#define ATYN(n) cout << ( (n) ? "Yes":"No") << endl;
#define CFYN(n) cout << ( (n) ? "YES":"NO") << endl;
#define out(n) cout << (n) << endl;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;

int main(void)
{
    IOS
    constexpr int N = 8100;
    string s; cin >> s;
    int x, y;
    cin >> x >> y;

    vector<int> vx,vy;
    int tcount = 0;
    int fcount = 0;
    REP(i,s.size()+1) {
        if (i == s.size() || s[i] == 'T') {
            if (tcount % 2 == 0) vx.push_back(fcount);
            else vy.push_back(fcount);
            tcount++;
            fcount = 0;
        } else {
            fcount++;
        }
    }

    bitset<N*2> dpx,dpy;
    dpx[N] = true;
    dpy[N] = true;
    
    REP(i,vx.size()) {
        bitset<N*2> tmp;
        swap(dpx,tmp);
        for(int j = 0; j < N*2 ;j++) {
            if (j+vx[i] < N*2) dpx[j+vx[i]] = dpx[j+vx[i]] | tmp[j];
            if (i != 0 && j-vx[i] >= 0) dpx[j-vx[i]] = dpx[j-vx[i]] | tmp[j];
        }
    }

    REP(i,vy.size()) {
        bitset<N*2> tmp;
        swap(dpy,tmp);
        for(int j = 0; j < N*2;j++) {
            if (j+vy[i] < N*2) dpy[j+vy[i]] = dpy[j+vy[i]] | tmp[j];
            if (j-vy[i] >= 0) dpy[j-vy[i]] = dpy[j-vy[i]] | tmp[j];
        }
    }
    
    ATYN(dpx[x+N] && dpy[y+N])

    return 0;
}

Measured memory_bytes: 384
S = input()

T = input()

ans = float("inf")
for i in range(len(S) - len(T)+1):
    tmp = 0
    for j in range(len(T)):
        # print(S[i+j], T[j])
        if S[i+j] != T[j]:
            tmp += 1
    ans = min(tmp, ans)
print(ans)


Measured memory_bytes: 67544
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.io.PrintStream;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author Eric
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        FastReader in = new FastReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        AWeLoveGolf solver = new AWeLoveGolf();
        solver.solve(1, in, out);
        out.close();
    }

    static class AWeLoveGolf {
        public void solve(int testNumber, FastReader in, PrintWriter out) {
            int k = in.nextInt();
            int a = in.nextInt();
            int b = in.nextInt();
            for (int i = a; i <= b; i++) {
                if (i % k == 0) {
                    out.println("OK");
                    return;
                }
            }
            out.print("NG");
        }

    }

    static class FastReader {
        public BufferedReader br;
        public StringTokenizer st;
        String context = null;

        public FastReader(InputStream in) {
            this(new InputStreamReader(in));
        }

        public FastReader(InputStreamReader input) {
            br = new BufferedReader(input);
        }

        public String next() {
            if (context != null) {
                System.err.print("[" + context + "] Wait for input ...");
            }
            while (st == null || !st.hasMoreElements()) {
                try {
                    String s = br.readLine();
                    if (s == null)
                        return null;
                    st = new StringTokenizer(s);
                } catch (IOException e) {
                    e.printStackTrace();
                    throw new RuntimeException("Could not read");
                }
            }
            String res = st.nextToken();
            if (context != null) {
                System.err.println("[" + context + "] ... received : " + res);
            }
            return res;
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

    }
}



Measured memory_bytes: 32816
#include <stdio.h>
#include <stdlib.h>

int main()
{
    int n,d,x,s;

    while(scanf("%d%d%d",&n,&d,&x)!=EOF)
    {
        int a[105];
        int k,j,i,sum=0;
        for(i=0; i<n; i++)
            scanf("%d",&a[i]);
        for(j=0; j<n; j++)
        {
            s=a[j];
            for(k=1; k<=d;)
            {
                sum++;
                k=k+s;
            }
        }
        printf("%d\n",sum+x);
    }
    return 0;
}


Measured memory_bytes: 128
import java.io.*;
import java.util.*;

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

    public static void solve(){
        Scanner sc = new Scanner(System.in);
        long n = sc.nextLong();
        long[] list = new long[5];
        for(int i=0;i<5;i++){
        	list[i] = sc.nextLong();
        }
        Arrays.sort(list);
        
        if(n%list[0]==0){
        	System.out.println(n/list[0]+4);
        }
        else{
        	System.out.println(n/list[0]+5);
        }
    }
}

Measured memory_bytes: 23124
#include <iostream>

int main(void)
{
    while(true) {
        int a, b;
        char op;
        std::cin >> a >> op >> b;
        if(op == '?') { break; }
        int result = 0;
        switch(op) {
        case '+':
            result = a + b;
            break;
        case '-':
            result = a - b;
            break;
        case '*':
            result = a * b;
            break;
        case '/':
            result = a / b;
            break;
        default:
            break;
        }
        std::cout << result << std::endl;
    }
    return 0;
}

Measured memory_bytes: 1160
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();

		int sum = 0;

		for(int i = a; i <= b; i++){
			if(c%i == 0)
			sum++;
		}

		System.out.printf("%d\n",sum);
	}
}


Measured memory_bytes: 26356
using System;
using System.Linq;
using System.Collections.Generic;

public class Program
{
    static void Main()
    {
        int n = int.Parse(Console.ReadLine());
        int[] a = new int[n];
        int[] input = new int[n];
        int tmp;
        for (int i = 0; i < n; i++)
        {
            tmp = int.Parse(Console.ReadLine());
            a[i] = tmp;
            input[i] = tmp;
        }
        Array.Sort(a);
        a = a.Reverse().ToArray();
        for (int i = 0; i < n; i++)
        {
            if (input[i] == a[0])
            {
                Console.WriteLine(a[1]);
            }
            else
                Console.WriteLine(a[0]);
        }
    }
}

Measured memory_bytes: 21460
n=int(input())
#a,b=map(int,input().split())
al=list(map(int,input().split()))
#l=[list(map(int,input().split())) for i in range(n)]
d=[0]
d=d+al
d.append(0)
totald=0
for i in range(1,n+2):
    totald+=abs(d[i]-d[i-1])

for i in range(1,n+1):
    minus=abs(d[i]-d[i-1])+abs(d[i+1]-d[i])
    add=abs(d[i+1]-d[i-1])
    print(totald-minus+add)


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

int main(void){
    int n,a[105],b[10],ans=0,judge=0;
    cin >> n;
    for(int i=0;i<9;i++){
        b[i] = 0;
    }
    for(int i=0;i<n;i++){
       cin >> a[i];
       if(1 <= a[i] && a[i] < 400){
           b[0]++;
       } 
       if(400 <= a[i] && a[i] < 800){
           b[1]++;
       }
       if(800 <= a[i] && a[i] < 1200){
           b[2]++;
       }
       if(1200 <= a[i] && a[i] < 1600){
           b[3]++;
       }
       if(1600 <= a[i] && a[i] < 2000){
           b[4]++;
       }
       if(2000 <= a[i] && a[i] < 2400){
           b[5]++;
       }
       if(2400 <= a[i] && a[i] < 2800){
           b[6]++;
       }
       if(2800 <= a[i] && a[i] < 3200){
           b[7]++;
       }
       if(3200 <= a[i]){
       		b[8]++;
       }

    }
    for(int i=0;i<8;i++){
        if(b[i] > 0){
            ans++;
        }
        if(b[i] == 0){
            judge++;
        }
    }
    if(judge == 8){
        cout << "1" << " " << b[8] << endl;
    }else{
        cout << ans << " " << ans + b[8] << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include<iostream> 
#include<vector> 
#include<string> 
#include<algorithm> 
using namespace std; 
int main()
{
	int n; 
	cin >> n;
	vector<int> a(n); 
	for (int i = 0; i < n; i++)
	{
		cin >> a.at(i);
	}
	int t = 0; 
	int ans = 0;
	
	for(;;)
	{
		ans++; 
		t = a.at(t)-1;
		if (t==1)
		{ 
			cout << ans << endl;
			break;
		}
		if (ans>n)
		{
			cout << -1 << endl; 
			break;
		}
	}
}

Measured memory_bytes: 640
#include<iostream>
#include<vector>
#include<map>
#include<string>
#include<algorithm>
#include<deque>

using namespace std;
typedef long long ll;

int main(void)
{
    ll N, X;
    cin >> N >> X;

    vector<ll> L;

    ll currentPos = 0;
    ll ans = 1;

    for(int i = 0; i < N; i++)
    {
        ll _L;
        cin >> _L;

        currentPos += _L;
        if(currentPos <= X)
        {
            ans++;
        }
        else
        {
            break;
        }
        

        //L.push_back(_L);
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
use proconio::input;
use std::cmp::Ordering::*;

#[allow(dead_code)]
fn dump(a: &Vec<bool>) -> String {
    a.iter().map(|&c| if c { 'W' } else { 'R' } ).collect()
}

#[allow(dead_code)]
fn type_of<T>(_: T) -> &'static str {
    std::any::type_name::<T>()
}

fn main() {
    input!{
        n: usize,
        k: usize,
        mut a: [usize; n],
    }

    a.sort_by(|x, y| match x.cmp(y) {
        Equal => Equal,
        Greater => Less,
        Less => Greater,
    });

    let mut l = 0;
    let mut r = a[0];
    while l < r {
        let mut kc = 0;
        let m = (l+r)/2;
        if m == 0 { l = m+1; continue; }
        let c = a.iter().take_while(|&&x| x > m);
        //eprintln!("{} {}", l, r);
        for i in c {
            kc += i/m;
            if kc > k {
                break;
            }
        }
        if kc <= k {
            r = m;
        } else {
            l = m+1;
        }
        //input!{_: String}
    }
    println!("{}", r);
}


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

int main()
{
	vector<int> data(5);
	cin >> data[0] >> data[1] >> data[2] >> data[3] >> data[4];

	vector<int> amariMinus1(5);
	for (int i = 0; i < 5; i++)
	{
		amariMinus1[i] = (data[i] - 1) % 10;
	}
	size_t minIndex = distance(amariMinus1.begin(), min_element(amariMinus1.begin(), amariMinus1.end()));

	int ans = 0;
	for (int i = 0; i < 5; i++)
	{
		if (i == minIndex)
		{
			ans += data[i];
		}
		else
		{
			ans += ceil(data[i] / 10.0) * 10;
		}
	}

	cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;
char f(int i) {
    if (i == 0) return '+';
    else return '-';
}

int main()
{
    char q, w, e, r;
    cin >> q >> w >> e>> r;
    int a = q - '0';
    int b = w - '0';
    int c = e - '0';
    int d = r - '0';
    //cout << a, b, c, d;
    int ans1, ans2, ans3;
    for(int i = 0; i < 2; i++) {
        if (i == 0) ans1 = a + b;
            else ans1  = a - b;
        for(int j = 0; j < 2; j++) {
            if (j == 0) ans2 = ans1 + c;
                else ans2 = ans1 - c;
            for(int k = 0; k < 2; k++) {
                if(k == 0) ans3 = ans2 + d;
                    else ans3 = ans2 - d;
                if(ans3 == 7){
                    cout << a << f(i) << b << f(j) << c << f(k) << d << "=7";
                    return 0;
                }
            }
        }
    }
    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#define LEN 100005

/* queue struction */
unsigned int time[LEN], head, tail;
char name[LEN][10];

int main()
{
	int n, runtime;
	head = tail = 0;

	scanf("%d %d", &n, &runtime);
	for (int i = 0; i < n; i++) {
		scanf("%s %d", name[i], &time[i]);
		tail++; // always point to empty
	}

	int timer = 0; // timer
	while (tail != head) { // Not empty <- Important, different between "tail != head" and "tail - head > 0"
		// Process - not finished
		if (time[head % LEN] > runtime) {
			timer += runtime;
			strcpy(name[(tail) % LEN], name[(head) % LEN]); // str copy
			time[(tail) % LEN] = time[(head) % LEN] -= runtime;
			tail++, head++;
		}
		else {
			timer += time[(head) % LEN];
			printf("%s %d\n", name[(head) % LEN], timer);
			head++;
		}
	}

	return 0;
}

Measured memory_bytes: 3924
#include "bits/stdc++.h"
using namespace std;
///////////////////////////////////////////
const long long int INF = 1LL<<60;
const long long int Mod = 1000000007;
using ll = long long int; using ci = const int;
using vi = vector<int>;  using Vi = vector<long long int>;
using P = pair<int, int>;  using PLL = pair<ll, ll>;
using matrix = vector<vector<ll>>;
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
#define all(x) (x).begin(),(x).end()
#define rep(i,N) for(ll i = 0; i < (ll)N; i++)
#define repi(i,a,b) for(ll i = ll(a); i < ll(b); ++i)
template<class T>bool chmax(T &former, const T &b) { if (former<b) { former=b; return true; } return false; }
template<class T>bool chmin(T &former, const T &b) { if (b<former) { former=b; return true; } return false; }
template<class T>T sqar(T x){ return x*x; }//sqrt(x)は平方根;
#define Sort(v) std::sort(v.begin(), v.end(), std::greater<decltype(v[0])>()) //降順でVをソート
#define p_queue(v) priority_queue<v, vector<v>, greater<v> >
template<class T> inline void princ(T x){cout<<x<<" ";}; 
template<class T> inline void print(T x){cout<<x<<"\n";};
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T> inline void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
///////////////////////////////////////////////////////////////////////////////////

string x;

int main(){
	cin.tie(0);ios::sync_with_stdio(false);
	std::cout<<std::fixed<<std::setprecision(30);
	cin>>x;
	ll ans = 0;
	ll cts = 0;
	rep(i,x.size()){
		if(x[i]=='S'){
			cts++;
		}else{
			if(cts>0){
				cts--;
				ans++;
			}
		}
	}
	print(x.size()-ans*2);
	return 0;
}

Measured memory_bytes: 720