akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

int main(){
	string S;
	cin >> S;
	sort(S.begin(), S.end());
	if(S.at(0) == S.at(1) && S.at(1) != S.at(2) && S.at(2) == S.at(3)) cout << "Yes" << endl;
	else cout << "No" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n)for(long long i=0;i<(n);i++)
using namespace std;
typedef long long ll;
const int MOD=1e9+7;
const int MAX = 1000000;
const ll INF = (1LL << 31) - 1;
const double pi=acos(-1);

int main(){
  string s;
  ll K;
  cin >> s >> K;
  int n = s.size();
  rep(i,n){
    if(s[i]=='a')continue;
    else{
      int num = s[i]-'a';
      if(26-num<=K){
        K-=26-num;
        s[i]='a';
      }
    }
  }
  K%=26;
  int res = (s[n-1]-'a'+K)%26;
  s[n-1]=char('a'+res);
  cout << s << endl;
}


Measured memory_bytes: 512
#include <stdio.h>
#include <math.h>
#include <string.h>
#include <stdlib.h>
#pragma warning( disable:4996 )
#define SWAP(a,b) (a += b,b = a - b,a -= b)
#define MIN(a, b) ((a) < (b) ? (a) : (b))


int main(void) {
	int n;
	scanf("%d", &n);
	printf("%d", (n - 2) * 180);
	return 0;
}

Measured memory_bytes: 128
// IO library
#include <cstdio>
#include <iomanip>
#include <ios>
#include <iostream>

// algorithm library
#include <algorithm>
#include <cmath>
#include <numeric>

// container library
#include <deque>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>

// namespace
using namespace std;

// typedef
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VL;
typedef vector<VL> VVL;
typedef vector<string> VS;
typedef vector<bool> VB;
typedef vector<VB> VVB;

// conversion
#define INT(c) static_cast<int>(c)
#define CHAR(n) static_cast<char>(n)
#define LL(n) static_cast<ll>(n)

// container
#define EACH(i, c) for (auto i = (c).begin(); i != (c).end(); i++)
#define SORT(c) sort((c).begin(), (c).end())
#define GSORT(c) sort((c).begin(), (c).end(), greater<decltype((c).front())>())
#define SZ(x) (INT((x).size()))
#define MEMSET(c, v) memset((c), v, sizeof(c))

// repetition
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
#define NREP(i, n) FOR(i, 1, n + 1)
#define RFOR(i, a, b) for (int i = (a); i >= (b); i--)
#define RREP(i, n) RFOR(i, n, 0)
#define RNREP(i, n) RFOR(i, n, 1)

// constant
// const ll MOD = 1e9 + 7;
// const int INF = 1<<25;
// const ll INF = 1LL<<50;
// const int dx[4] = {0, -1, 1, 0};
// const int dy[4] = {-1, 0, 0, 1};
// const int dx[8] = {-1, 0, 1, -1, 1, -1, 0, 1};
// const int dy[8] = {-1, -1, -1, 0, 0, 1, 1, 1};

// debug
#define test(x) cout << #x << " = " << x << endl

// answer output
#define Yes(c) cout << ((c) ? "Yes" : "No") << endl;
#define YES(c) cout << ((c) ? "YES" : "NO") << endl;
#define yes(c) cout << ((c) ? "yes" : "no") << endl;

#define possible(c) cout << ((c) ? "possible" : "impossible") << endl;
#define POSSIBLE(c) cout << ((c) ? "POSSIBLE" : "INPOSSIBLE") << endl;


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


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

  ll N, K;
  cin >> N >> K;
  ll pat = K;
  REP(i, N - 1) {
    pat *= K - 1;
  }
  cout << pat << endl;
  return 0;
}

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

using namespace std;

int n;
int cnt[5];
long double f[310][310][310];

inline long double dp(int a,int b,int c){//123
	if(a==0&&b==0&&c==0)return (long double)0.0;
	if(f[a][b][c]>(long double)0.0)return f[a][b][c];

	if(a>0)f[a][b][c]+=(long double)a/(long double)(a+b+c)*dp(a-1,b,c);
	if(b>0)f[a][b][c]+=(long double)b/(long double)(a+b+c)*dp(a+1,b-1,c);
	if(c>0)f[a][b][c]+=(long double)c/(long double)(a+b+c)*dp(a,b+1,c-1);
	f[a][b][c]+=(long double)n/(long double)(a+b+c);
	return f[a][b][c];
}
int main(){
	scanf("%d",&n);
	for(int i=1;i<=n;i++){
		int t;
		scanf("%d",&t);
		cnt[t]++;
	}
	printf("%.15lf\n",(double)dp(cnt[1],cnt[2],cnt[3]));

	return 0;
}

Measured memory_bytes: 450816
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <cassert>
#include <fstream>
#include <utility>
#include <functional>
#include <time.h>
#include <stack>
#include <array>
#define popcount __builtin_popcount
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;

int main()
{
	int n, a, b, c;
	cin>>n>>a>>b>>c;
	string s[100010];
	for(int i=0; i<n; i++) cin>>s[i];
	bool dp[3][3][3][100010]={};
	int p[3][3][3][100010];
	a=min(a, 2), b=min(b, 2), c=min(c, 2);
	dp[a][b][c][0]=1;
	for(int i=0; i<n; i++){
		for(int j=0; j<3; j++){
			for(int k=0; k<3; k++){
				for(int l=0; l<3; l++){
					if(!dp[j][k][l][i]) continue;
					int x=j+3*k+9*l;
					if(s[i]=="AB"){
						if(j){
							int j1=j-1, k1=min(k+1, 2), l1=l;
							dp[j1][k1][l1][i+1]=1;
							p[j1][k1][l1][i+1]=1+3*x;
						}
						if(k){
							int j1=min(j+1, 2), k1=k-1, l1=l;
							dp[j1][k1][l1][i+1]=1;
							p[j1][k1][l1][i+1]=0+3*x;
						}
					}else if(s[i]=="AC"){
						if(j){
							int j1=j-1, k1=k, l1=min(l+1, 2);
							dp[j1][k1][l1][i+1]=1;
							p[j1][k1][l1][i+1]=2+3*x;
						}
						if(l){
							int j1=min(j+1, 2), k1=k, l1=l-1;
							dp[j1][k1][l1][i+1]=1;
							p[j1][k1][l1][i+1]=0+3*x;
						}
					}else{
						if(k){
							int j1=j, k1=k-1, l1=min(l+1, 2);
							dp[j1][k1][l1][i+1]=1;
							p[j1][k1][l1][i+1]=2+3*x;
						}
						if(l){
							int j1=j, k1=min(k+1, 2), l1=l-1;
							dp[j1][k1][l1][i+1]=1;
							p[j1][k1][l1][i+1]=1+3*x;
						}
					}
				}
			}
		}
	}
	int ans[100010];
	for(int i=0; i<3; i++){
		for(int j=0; j<3; j++){
			for(int k=0; k<3; k++){
				if(dp[i][j][k][n]){
					cout<<"Yes"<<endl;
					int x=i, y=j, z=k;
					for(int l=n; l>=1; l--){
						int p1=p[x][y][z][l];
						ans[l-1]=p1%3; p1/=3;
						x=p1%3; p1/=3;
						y=p1%3; p1/=3;
						z=p1%3;
					}
					for(int l=0; l<n; l++){
						if(ans[l]==0) cout<<"A"<<endl;
						else if(ans[l]==1) cout<<"B"<<endl;
						else cout<<"C"<<endl;
					}
					return 0;
				}
			}
		}
	}
	cout<<"No"<<endl;
	return 0;
}


Measured memory_bytes: 17196
import java.util.Scanner;

public class Main{
	public static void main(String[] args) {
		try (Scanner sc = new Scanner(System.in)) {
			int n = sc.nextInt();
			int k = sc.nextInt();

			int ans = ((int) (k * Math.pow(k - 1, n - 1)));

			System.out.println(ans);
		}
	}
}


Measured memory_bytes: 21844
#include <iostream>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <numeric>
#include <climits>
#include <math.h>
#include <memory.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rrep(i, k, n) for(int i = (k); i < (int)(n); i++)
using namespace std;
using ll = long long;
int N, M;
int cnt = 0;
int ans = 0;
int main(){
    int A[3];
    rep(i, 3) cin >> A[i];
    while(!(A[0] == A[1] && A[1] == A[2])){
        sort(A, A + 3);
        if(A[2] - A[0] >= 2){
            A[0] += 2;
            cnt++;
        }
        else{
            A[0]++;
            A[1]++;
            cnt++;
        }
    }
    cout << cnt << endl;
    return 0;
}

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

#define pb push_back
#define ff first
#define ss second

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

ll n, a, b;

int main() {
	ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
	cin >> n >> a >> b;
	if (a % 2 == b % 2) cout << (b - a) / 2 << endl;
	else cout << min(n - b + 1, a) + (b - a) / 2 << endl;
	return 0;
}


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

using namespace std;

int main() 
{
  int n;
  cin >> n;
  set<int> p;
  for(int i = 1 ; i <= n; ++i)
    for(int j = 1 ; j <= n; ++j)
      for(int k = 1; k <= n; ++k){
       int x = i * 100 + j * 10 + k;
        p.insert(x);
      }
  cout << p.size() << endl;
}

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

int T[N+1],S[501];
int LinearSearch(int k, int n){
	T[n] = k;
	int i = 0;
	while(T[i] != k){
		i++;
	}
	return i != n;
}
int main(){
	int n,q,t,sum = 0;
	cin>>n;
	for(int i = 0; i < n; i++){
		cin>>T[i];
	}
	cin>>q;
	for(int i = 0; i < q; i++){
		cin>>t;if(LinearSearch(t, n))	sum++;
	}
	cout<<sum<<endl;
	return 0;
}


Measured memory_bytes: 3108
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;

#define REP(i,n) for(long long i = 0; i < (n); i++)
#define FOR(i, m, n) for(long long i = (m);i < (n); ++i)
#define ALL(obj) (obj).begin(),(obj).end()
#define SPEED cin.tie(0);ios::sync_with_stdio(false);

template<class T> using V = vector<T>;
template<class T, class U> using P = pair<T, U>;
template<class T> using PQ = priority_queue<T>;
template<class T> using PQR = priority_queue<T,vector<T>,greater<T>>;

constexpr long long MOD = (long long)1e9 + 7;
constexpr long long MOD2 = 998244353;
constexpr long long HIGHINF = (long long)1e18;
constexpr long long LOWINF = (long long)1e15;
constexpr long double PI = 3.1415926535897932384626433;

template <class T> vector<T> multivector(size_t N,T init){return vector<T>(N,init);}
template <class... T> auto multivector(size_t N,T... t){return vector<decltype(multivector(t...))>(N,multivector(t...));}
template <class T> void corner(bool flg, T hoge) {if (flg) {cout << hoge << endl; exit(0);}}
template <class T, class U>ostream &operator<<(ostream &o, const map<T, U>&obj) {o << "{"; for (auto &x : obj) o << " {" << x.first << " : " << x.second << "}" << ","; o << " }"; return o;}
template <class T>ostream &operator<<(ostream &o, const set<T>&obj) {o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr) o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;}
template <class T>ostream &operator<<(ostream &o, const multiset<T>&obj) {o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr) o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;}
template <class T>ostream &operator<<(ostream &o, const vector<T>&obj) {o << "{"; for (int i = 0; i < (int)obj.size(); ++i)o << (i > 0 ? ", " : "") << obj[i]; o << "}"; return o;}
template <class T, class U>ostream &operator<<(ostream &o, const pair<T, U>&obj) {o << "{" << obj.first << ", " << obj.second << "}"; return o;}
template <template <class tmp>  class T, class U> ostream &operator<<(ostream &o, const T<U> &obj) {o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr)o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;}
void print(void) {cout << endl;}
template <class Head> void print(Head&& head) {cout << head;print();}
template <class Head, class... Tail> void print(Head&& head, Tail&&... tail) {cout << head << " ";print(forward<Tail>(tail)...);}
template <class T> void chmax(T& a, const T b){a=max(a,b);}
template <class T> void chmin(T& a, const T b){a=min(a,b);}
void YN(bool flg) {cout << (flg ? "YES" : "NO") << endl;}
void Yn(bool flg) {cout << (flg ? "Yes" : "No") << endl;}
void yn(bool flg) {cout << (flg ? "yes" : "no") << endl;}

int main() {
	ll A,B,K; cin >> A >> B >> K;
	ll X = min(A,K);
	A -= X;
	K -= X;
	X = min(B,K);
	B -= X;
	cout << A << " " << B << endl;


}


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

int main() {
    ll N;
    cin >> N;
    vector<ll> A(N);
    for(int i=0;i<N;i++){
        cin >> A[i];
    }
    sort(A.begin(),A.end());
    ll big=0;
    ll small =0;
    if(N%2==0){
        for(int i=0;i<N;i++){
            if(i<(N/2)){
                small += 2*A[i];
            }else{
                big += 2*A[i];
            }
        }
        small -= A[(N/2)-1];
        big -= A[(N/2)];
        cout << big -small << endl;
        return 0;
    }
    ll ans = 0;
    {
        for(int i=0;i<N;i++){
            if(i<(N/2)){
                small += 2*A[i];
            }else{
                big += 2*A[i];
            }
            
        }
        big -= (A[N/2] + A[(N/2) +1]);
        ans = big -small;
    }
    {
        big =small =0;
        for(int i=0;i<N;i++){
            if(i<(N/2)+1){
                small += 2*A[i];
            }else{
                big += 2*A[i];
            }
           
        }
         small -= (A[N/2] + A[(N/2) -1]);
        ans = max(ans,big -small);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1152
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <string>
#include <cstring>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <cmath>
#include <iomanip>
#include <cassert>
#include <bitset>
using namespace std;

typedef pair<int, int> P;
#define rep(i, n) for (int i=0; i<(n); i++)
#define all(c) (c).begin(), (c).end()
#define uniq(c) c.erase(unique(all(c)), (c).end())
#define _1 first
#define _2 second
#define pb push_back
#define INF 1145141919
#define MOD 1000000007

int W, H;
int S[1001][1001];
int TX[1001][1001], TY[1001][1001];
int dp[1001][1001];

signed main() {
  ios::sync_with_stdio(false); cin.tie(0);
  cin >> W >> H;
  rep(i, H) rep(j, W) cin >> S[j][i];
  rep(x, W) rep(y, H) {
    dp[x][y] = -INF;
  }
  rep(x, W) {
    for (int y=H-1; y>=0; y--) TY[x][y] = TY[x][y+1] + S[x][y];
  }
  rep(y, H) {
    for (int x=W-1; x>=0; x--) TX[x][y] = TX[x+1][y] + S[x][y];
  }

  W++, H++;
  dp[W-1][H-1] = 0;
  for (int x=W-1; x>=0; x--) {
    for (int y=H-1; y>=0; y--) {
      bool fp = (x+y)%2 == 0;
      int right = TY[x][y], down = TX[x][y];
      if (fp) right *= -1;
      if (!fp) down *= -1;
      if (x+1 < W) dp[x][y] = max(dp[x][y], -dp[x+1][y] + right);
      if (y+1 < H) dp[x][y] = max(dp[x][y], -dp[x][y+1] + down);
    }
  }
  cout << abs(dp[0][0]) << "\n";
  return 0;
}

Measured memory_bytes: 18784
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pi acos(-1)
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    ll n,m,sum=0;
    cin>>n>>m;
    int arr[n];
    for( ll i=0;i<n;i++){
        cin>>arr[i];
        sum+=arr[i];
    }

    double d = (double)sum/(4*m);
   //cout<<sum <<"   "<<d<<endl;
    sort(arr,arr+n);
   // for(ll i=n-1;i>=0;i--){
   //     cout<<arr[i]<<" ";
   // }
  //  cout<<endl;

    ll c=0;
    for(ll i=n-1;i>=0;i--){
        if(arr[i]>=d)
            c+=1;
        else
            break;
    }
   // cout<<c<<endl;
    if((double)c>=m)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;

return 0;
}


Measured memory_bytes: 256
n = int(input())
a = [int(i) for i in input().split()]
s = sum(a)
snuke = 0
raccoon = s
ans = 10**15

for i in range(n-1):
    snuke += a[i]
    raccoon -= a[i]
    ans = min(ans,abs(snuke-raccoon))
    
print(ans)

Measured memory_bytes: 24948
n,m=map(int,input().split())
lists=list(map(int,input().split()))
checklist=[]
count=0

for i in range(m):
    b,c=map(int,input().split())
    checklist.append((c,b))
checklist=sorted(checklist,reverse=True)
lists=sorted(lists)
uselist=[]
count=0

for i in checklist:
    for _ in range(i[1]):
        uselist.append(i[0])
    count+=i[1]

    if count>=n:
        break
answer=0
n=min(n,len(uselist))
for i in range(n):
    if lists[i]<uselist[i]:
            lists[i]=uselist[i]
    else:
        break
print(sum(lists))

Measured memory_bytes: 22088
//#include <bits/stdc++.h>
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstdlib>
#include <string>
#include <vector>
#include <map>
#include <queue>

using namespace std;

typedef long long ll;
typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<n;++i)
#define mod (ll)(1e9+7)
#define FIX(a) ((a)%mod+mod)%mod
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define fi first
#define se second
#define pb push_back
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    int ans;
    if(n%1000==0){
        ans = 0;
    }else{
        ans = 1000 -(n%1000);
    }
    cout  << ans << endl;

    return 0;
}

Measured memory_bytes: 3648
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<set>
#include<stack>
#include<cmath>
#include<sstream>
#include<string>
using namespace std;
typedef long long ll;
ll mod = 1e9+7;
#define rep(i,n) for(int i = 0; i < (n); ++i)

int main(){
    ll n, p;
    cin >> n >> p;
    ll tmp_num = p;
    vector<pair<ll, ll>> v_cnt;
    ll cnt_max = 0;
    if ( n == 1 ) {
        cout << p << endl;
        return 0;
    }
    for ( ll i = 2; i * i <= p; ++i ) {
        if ( tmp_num <= 1 ) {
            break;
        }
        ll cnt = 0;
        while(1) {
            if ( tmp_num % i != 0 ) {
                break;
            }
            tmp_num /= i;
            ++cnt;
        }
        if ( cnt < n ) {
            continue;
        }
        v_cnt.emplace_back(i, cnt/n);
    }
//    for ( auto tmp_num : v_cnt ) {
//        cout << tmp_num.first << " " << tmp_num.second << " " << endl;;
//    }
//    cout << endl;
    if ( v_cnt.empty() ) {
        cout << 1 << endl;
        return 0;
    }
    ll ans = 1;
    for ( auto tmp_num : v_cnt ) {
        ll tmp_ans = 1;
        rep(ri, tmp_num.second) {
            tmp_ans *= tmp_num.first;
        }
//        cout << tmp_ans << " " << loop_num << endl;
        ans *= tmp_ans;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h> 
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define all(vec) vec.begin(), vec.end()
#define tmax(x,y,z) max((x),max((y),(z)))
#define tmin(x,y,z) min((x),min((y),(z)))
typedef long long ll;ll MM = 1000000000;ll mod = MM + 7; ll MMM=9223372036854775807;//2^63 -1
ll GCD(ll x, ll y) {if (y == 0) return x;else return GCD(y, x % y);}
ll LCM(ll x, ll y) { return x / GCD(x, y) * y;}
//cout << fixed << setprecision(10);

int main(){
  string s;
  while(cin>>s){
   //string s; cin>>s;
    if(s=="EOF") break;
    else if(s.size()<=2){
    cout<<0<<endl;
      cout<<0<<endl;
      continue;
    }
    ll a=0,b=0;
    rep(i,s.size()-2){
    if(s.substr(i,3)=="JOI"){a++;i++;}
      else if(s.substr(i,3)=="IOI"){b++;i++;}
    
    }
    cout<<a<<endl;
    cout<<b<<endl;
    
  }
  
  
}


Measured memory_bytes: 3164
#include<iostream>
#include<string>
using namespace std;
int main(){
  string cc,c;
  string base[2]={"Hoshino","Hoshina"};
  int n,x;
  cin >> n;
  getline(cin,c);
  for(int i=0;i<n;i++){
    getline(cin,cc);
    x = 0;
    while(1){
      if(x==0) x = cc.find(base[0],x);
      else if(x>0) x = cc.find(base[0],x+7);
      if(x==-1) break;
      cc.replace(x,7,base[1]);
    }
    cout << cc << endl;
  }
    return 0;
}

Measured memory_bytes: 1216
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<set>
#include<stack>
#include<cmath>
using namespace std;
typedef long long ll;
ll mod = 1e9+7;
#define rep(i,n) for(int i = 0; i < (n); ++i)
int main(){
    string s;
    cin >> s;
    int a = s[0] - '0';
    int b = s[1] - '0';
    int c = s[2] - '0';
    int d = s[3] - '0';
    int num[3] = {b, c, d};
    rep(i, (1<<3)) {
        int sum = a;
        string tmp_op = "";
        int tmp_num = i;
        rep(j, 3) {
            if ( tmp_num&1 ) {
                sum += num[j];
                tmp_op += "+";
            }
            else if ( !(tmp_num&1) ) {
                sum -= num[j];
                tmp_op += "-";
            }
            tmp_num >>= 1;
        }
        if ( sum == 7 ) {
            cout << a;
            rep(j, 3) cout << tmp_op[j] << num[j];
            cout << "=7" << endl;
            return 0;
        }
    }
    return 0;
}

Measured memory_bytes: 256
/*
[agc037] A - Dividing a String
*/

#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;
typedef pair<ll, ll> pll;
#define ALL(c) (c).begin(), (c).end()

const int MAX_N = 2e5;

int N;
string S;
int dp[3][MAX_N + 1];

ll solve() {
    for (int i = 1; i <= N; i++) {
        for (int j = 1; j <= 2; j++) {
            if (i - j < 0) {
                continue;
            }
            dp[j][i] = dp[3 - j][i - j] + 1;
            if (i - 2 * j >= 0 &&
                S.substr(i - 2 * j, j) != S.substr(i - j, j)) {
                dp[j][i] = max(dp[j][i], dp[j][i - j] + 1);
            }
        }
    }

    return max(dp[1][N], dp[2][N]);
}

int main() {
    cin >> S;
    N = S.length();

    cout << solve() << endl;

    return 0;
}


Measured memory_bytes: 2180
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  for(int i=0;i<(n);++i)
#define REPr(i,n) for(int i=(n)-1;i>=0; --i)
#define FORq(i, m, n) for(int i = (m);i <= (n);++i)
#define rFORq(i, m , n) for(int i = (n);i >=(m);--i)
#define SCD(n) scanf("%d",&n)
#define SCD2(m,n) scanf("%d%d",&m,&n)
#define SCD3(m,n,k) scanf("%d%d%d",&m,&n,&k)
#define SCLLD(n) scanf("%lld",&n)
#define SCLLD2(m,n) scanf("%lld%lld",&m,&n)
#define SCLLD3(m,n,k) scanf("%lld%lld%lld",&m,&n,&k)
#define PB push_back
#define MP make_pair
#define ARSCD(A,N) REP(i,N){SCD(A[i]);}
#define ARSCD1(A,N) FORq(i,1,N){SCD(A[i]);}
#define VSCD(v,N) REP(i,N){int x; SCD(x); v.PB(x);}
#define VSCLLD(v,N) REP(i,N){long long x; SCLLD(x); v.PB(x);}
#define PRINTD(n) printf("%d\n",n)
#define PRINTLLD(n) printf("%lld\n",n)
#define DEBUG printf("%s\n","debug")
#define fst first
#define snd second
#define SIN(x,S) (S.count(x) != 0)
using namespace std;
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector < VI > VVI;
typedef vector<long long> VL;
typedef long long ll;
typedef long long integer;
////////////////////////////////////////////////////////////////////
int main(){
    string S; cin >> S;
    int len = S.length();
    int ind = 0;
    int ans = 999999999;
    while(true){
        int bg = ind;
        int en = ind + 3 - 1;
        if (en >= len) break;
        int nans = stoi(S.substr(bg,3));
        //printf("nans = %d\n",nans);
        ans = min(ans,abs(753-nans));

        ind++;
    }
    PRINTD(ans);
}

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

int main() {
  int S;
  cin >> S;
  int a, b;
  b=S%100; /*simo*/
  a=(S-b)/100; /*kami*/
  if ((b>0 && b<13) && (a>0 && a<13)) {
    cout << "AMBIGUOUS" << endl;
  }
/*  else if (((b>0 && b<13) && a==0) || (b==0 && (a>0 && a<13))) {
    cout << "NA" << endl;
  }*/
  else if (a>0 && a<13) {
    cout << "MMYY" << endl;
  }
  else if (b>0 && b<13) {
    cout << "YYMM" << endl;
  }
  else {
   cout << "NA" << endl;
  } 
  }


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
   int n;cin>>n;
   long int s=0;
   for(int i=1;i<=n;i++)
   {
       if(i%3 !=0 && i%5 !=0)
       {

       
       s+=i;


   }}
   cout<<s<<endl;
return 0;
}


Measured memory_bytes: 3648
#include <bits/stdc++.h>
using namespace std;
typedef vector<int> VI;
typedef pair <int,int> ii;
typedef long long LL;
#define pb push_back
const int INF = 2147483647;
const int N = 100005;

set<ii> ls, rs, ls2, rs2;
int res, l[N], r[N], i, n, ind, ind2;

int get() {
	set<ii>::iterator it = ls.end();
	it--;
	int v1 = max(0, rs.begin()->first - it->first + 1);
	//printf("%d ", v1);
	it = ls2.end();
	it--;
	v1 += max(0, rs2.begin()->first - it->first + 1);
	//printf("%d\n", v1);
	return v1;
}

int main() {
scanf("%d", &n);
ls.clear();
rs.clear();
res = 0;
for (i=0;i<n;i++) {
	scanf("%d %d", &l[i], &r[i]);
	ls.insert(ii(l[i], i));
	rs.insert(ii(r[i], i));
}
for (i=0;i<n;i++) {
	ls.erase(ii(l[i], i));
	rs.erase(ii(r[i], i));
	ls2.insert(ii(l[i], i));
	rs2.insert(ii(r[i], i));
	res = max(res, get());
	ls2.erase(ii(l[i], i));
	rs2.erase(ii(r[i], i));
	ls.insert(ii(l[i], i));
	rs.insert(ii(r[i], i));
}
ind = rs.begin()->second;
ls.erase(ii(l[ind], ind));
rs.erase(ii(r[ind], ind));
ls2.insert(ii(l[ind], ind));
rs2.insert(ii(r[ind], ind));
res = max(res, get());
while (ls.size() > 0) {
	ind = ls.begin()->second;
	while (ls.size() > 0 && ls.begin()->first == l[ind]) {
		ind2 = ls.begin()->second;
		ls.erase(ii(l[ind2], ind2));
		rs.erase(ii(r[ind2], ind2));
		ls2.insert(ii(l[ind2], ind2));
		rs2.insert(ii(r[ind2], ind2));
	}
	if (ls.size() > 0) res = max(res, get());
}
printf("%d\n", res);
}





Measured memory_bytes: 10368
import java.io.BufferedReader
import java.io.InputStream
import java.io.InputStreamReader
import java.io.PrintWriter
import java.lang.StringBuilder
import java.util.*

fun PrintWriter.solve(sc: FastScanner) {
    val h = sc.nextInt()
    val w = sc.nextInt()
    val n = sc.nextInt()
    val a = Array(n) { sc.nextInt() }
    var c = 0
    val ans = Array(h) { Array(w) { 0 } }
    for (i in 0 until h) {
        for (_j in 0 until w) {
            val j = if (i % 2 == 0) _j else w - 1 - _j
            ans[i][j] = c + 1
            a[c]--
            if (a[c] == 0) c++
        }
    }
    for (b in ans) {
        println(b.joinToString(" "))
    }
}

fun main(args: Array<String>) {
    val writer = PrintWriter(System.out, false)
    writer.solve(FastScanner(System.`in`))
    writer.flush()
}

class FastScanner(s: InputStream) {
    private var st = StringTokenizer("")
    private val br = BufferedReader(InputStreamReader(s))

    fun next(): String {
        while (!st.hasMoreTokens()) st = StringTokenizer(br.readLine())

        return st.nextToken()
    }

    fun nextInt() = next().toInt()
    fun nextLong() = next().toLong()
    fun nextLine() = br.readLine()
    fun nextDouble() = next().toDouble()
    fun ready() = br.ready()
}


Measured memory_bytes: 34176
use std::io;

fn main(){
    let mut line = String::new();
    io::stdin().read_line(&mut line).unwrap();
    let mut iter = line.split_whitespace().map(|s| s.parse::<i32>().unwrap());
    let (a,b) = (iter.next().unwrap(),iter.next().unwrap());

    if a < b {
        println!{"{}","a < b"};

    } else if a > b{
        println!{"{}","a > b"};
    } else {
        println!{"{}","a == b"};
    }



}



Measured memory_bytes: 5024
#include<bits/stdc++.h>
//using namespace std;
#define rep(i,j,n) for(ll i=(ll)(j);i<(ll)(n);i++)
#define REP(i,j,n) for(ll i=(ll)(j);i<=(ll)(n);i++)
#define per(i,j,n) for(ll i=(ll)(j);(ll)(n)<=i;i--)
#define ll long long
#define ALL(a) (a).begin(),(a).end()
#define disup(A,key) distance(A.begin(),upper_bound(ALL(A),(ll)(key)))
#define dislow(A,key) distance(A.begin(),lower_bound(ALL(A),(ll)(key)))
#define pb push_back
#define mp std::make_pair
#define endl "\n"
using std::cin;
using std::cout;
using std::vector;
using std::string;
using std::upper_bound;
using std::lower_bound;
using vi=vector<ll>;
using vii=vector<vi>;
using pii=std::pair<ll,ll>;
//const ll MOD=1e9+7;
const ll MOD=998244353;
//const ll MOD=100000;
const ll MAX=1e7;
const ll INF=(1ll<<55);
template<class T>
class prique :public std::priority_queue<T, std::vector<T>, std::greater<T>> {};
struct Binary_indexed_tree{
    int N;
    vi bit;
    Binary_indexed_tree(int n):N(n){
        bit.resize(N+1,0);
    }
    void add(int x,int a){
        for(x;x<=N;x+=(x&-x)) bit[x]+=a;
    }
    ll sum(int x){
        ll ret=0;
        for(x;x>0;x-=(x&-x)) ret+=bit[x];
        return ret;
    }
};
struct Union_Find{
    ll N;
    vi par;
    vi siz;
    Union_Find(int n):N(n){
        par.resize(N);
        siz.resize(N,1);
        rep(i,0,N) par[i]=i;
    }
    ll root(ll X){
        if(par[X]==X) return X;
        return par[X]=root(par[X]);
    }
    bool same(ll X,ll Y){
        return root(X)==root(Y);
    }
    void unite(ll X,ll Y){
        X=root(X);
        Y=root(Y);
        if(X==Y) return;
        par[X]=Y;
        siz[Y]+=siz[X];
        siz[X]=0;
    }
    ll size(ll X){
        return siz[root(X)];
    }
};
ll modpow(ll X,ll Y){
    ll sum=X,cnt=1;
    vi A;
    while(cnt<=Y){
        A.pb(sum);
        sum*=sum;
        sum%=MOD;
        cnt*=2;
    }
    int M=A.size();
    ll ret=1;
    REP(i,1,M){
        if(Y>=(1ll<<M-i)){
            Y-=(1ll<<M-i);
            ret*=A[M-i];
            ret%=MOD;
        }
    }
    return ret;
}
ll fac[MAX],finv[MAX],inv[MAX];
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}
ll COM(ll n,ll r){
    if(n<r||n<0||r<0) return 0;
    return fac[n]*finv[r]%MOD*finv[n-r];
}
signed main(){
    std::ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    ll N; cin>>N;
    vi A(N);
    rep(i,0,N) cin>>A[i];
    sort(ALL(A));
    ll ans=1;
    ll M=1e18;
    if(A[0]==0){
        cout<<0<<endl;
        return 0;
    }
    rep(i,0,N){
        if(M/A[i]<ans){
            cout<<-1<<endl;
            return 0;
        }
        ans*=A[i];
    }
    if(ans>M) ans=-1;
    cout<<ans<<endl;
}


Measured memory_bytes: 3992
import java.util.*;
class Main{
public static void main(String[] args) {
  Scanner reader =new Scanner (System.in);
  int i=reader.nextInt();
  int d=reader.nextInt();
  if(i<=d)
  {
    System.out.println("unsafe");
  }else
    System.out.println("safe");
}
}


Measured memory_bytes: 35772
#include<stdio.h>
#include<stdlib.h>
#define MAX 100

main()
{
  int S[MAX], i=0, x, a;
  char input[MAX];

  while(scanf("%s", input) != EOF)
    {
      if(input[0] == '+')
	{
	  S[i-2] = S[i-1] + S[i-2];
	  i--;
	}
      else if(input[0] == '-')
	{
	  S[i-2] = S[i-2] - S[i-1];
	  i--;
	}
      else if(input[0] == '*')
	{
	  S[i-2] = S[i-2] * S[i-1];
	  i--;
	}
      else
	{
	  x = atoi(input);
	  S[i] = x;
	  i++;
	}

    }

  printf("%d\n", S[i-1]);
  return 0;
}

Measured memory_bytes: 548
#include <bits/stdc++.h>
#define ll long long
#define endl "\n"
#define the_flash ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define input_output freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout)

using namespace std;

int main()
{
	//input_output;
	the_flash;
	int n, count = 1;
	cin >> n;
	int arr[n];

	for (int i = 0; i < n; i++)
		cin >> arr[i];

	for (int i = 0; i < n - 1; i++)
	{
		if (arr[i] > arr[i + 1])
			count++;

		else
			arr[i + 1] = arr[i];
	}

	cout << count << endl;
	return 0;
}

Measured memory_bytes: 4432
/*
 ╔═══╦═══╦═══╗
 ║╔═╗║╔══╩╗╔╗║
 ║║░║║╚══╗║║║║
 ║║░║║╔══╝║║║║
 ║╚═╝║╚══╦╝╚╝║
 ╚══╗╠═══╩═══╝
 ░░░╚╝░░░░░░░░
 */

#include <bits/stdc++.h>
#define ll					long long
#define MOD					1000000007
#define MAX					1e9
#define MIN                 -1e9
#define PI					acos(-1.0)
#define vi					vector<int>
#define vii					vector<vi>
#define vll					vector<ll>
#define mid(s,e)			(s+(e-s)/2)
#define clz(n)				__builtin_clzll(n))

using namespace std;

void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
template<typename T>
void printVec(const T &v, char sep=' ') {for (auto &i: v) cout << i << sep;}
template<typename T>
void printVecPair(const T &v, char sep=' ') {for (auto &i: v) cout << i.first <<" " << i.second<< sep;}


#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif

int main() {
	ios::sync_with_stdio(false);
 	cin.tie(0);
	ll a,b;
	cin>>a>>b;
	if(a==b) cout<<0;
	if(abs(a-((a+b)/2)) == abs(b-((a+b)/2))) {
			cout<<(a+b)/2;
	}else {
			cout<<"IMPOSSIBLE";
	}
	return 0;
}





Measured memory_bytes: 256
n,m = gets.chop.split.map(&:to_i)
l=Array.new(m)
r=Array.new(m)

for i in 0...m
  l[i], r[i]=gets.chop.split.map(&:to_i)
end
  
high_l=l.max
low_r=r.min

if low_r-high_l+1 <0
  result=0
else
  result=[n, low_r-high_l+1].min
end

puts result


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

struct UnionFind{
  vector<int> d; //子なら親のID,根なら-サイズを保存
  UnionFind(int n=0) : d(n,-1) {} //最初はみんな根でサイズ1 (コンストラクタ :と{}の間には初期化子が入る)
  int find(int x){
    //自分が根なら自分を、そうでなければ親のfind結果を返す(再帰)
    if( d.at(x) < 0 )  return x;
    return d.at(x) = find(d.at(x)); //親のfindの結果で上書き(メモ化で木のサイズを小さくする)
  }
  bool unite(int x,int y){
    x = find(x); y = find(y);
    if( x == y ) return false; //元々同じグループなら、やることはない (falseはminimun spaning treeで使えるので便利)
    if( -d.at(x) < -d.at(y) ) swap(x,y); //サイズが大きい方に小さい方をくっつけたい
    d.at(x) += d.at(y); //xにyをくっつける
    d.at(y) = x;
    return true;
  }
  //同じ集合に属しているか判定する関数
  bool same(int x,int y){ return find(x) == find(y); }
  //要素の属する集合のサイズを返す関数
  int size(int x){ return -d.at( find(x) ); }
};

int main(){
  vector<int> deg(100005);
  vv to(100005,vector<int>(0));
  int n,m,k;
  cin >> n >> m >> k;
  UnionFind uf(n);
  //友達関係
  rep(i,m){
    int a,b;
    cin >> a >> b;
    a--; b--;
    deg.at(a)++;
    deg.at(b)++;
    uf.unite(a,b);
  }
  //ブロック関係
  rep(i,k){
    int a,b;
    cin >> a >> b;
    a--; b--;
    to.at(a).push_back(b);
    to.at(b).push_back(a);
  }
  rep(i,n){
    int ans = uf.size(i) - 1 - deg.at(i);
    for(int u : to.at(i) ){
      if(uf.same(i,u) ) ans--;
    }
    printf("%d%c",ans, i==n-1?'\n' : ' ');
  }
}


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

int main(){
    int r,g,b,n;
    cin>>r>>g>>b>>n;
    long long int counter = 0;
    for(int i=0;i<=(int)n/r;i++){
        for(int j=0;j<=(int)n/g;j++){
            if((n - r*i -g*j)%b==0 && (r*i + g*j)<=n){
                counter++;
            }
        }
    }
    cout<<counter<<endl;
}

Measured memory_bytes: 256
import math

N, K = map(int, input().split(" "))
A = list(map(int, input().split(" ")))

for i in range(min(41, K)):
  B = [0] * N
  for n, A_n in enumerate(A):
    B_min = max(0, n-A_n)
    b_max = min(N-1, n+A_n)
    B[B_min] += 1
    if b_max+1 < N:
      B[b_max+1] -= 1
  
  sum = 0
  for n in range(len(A)):
    sum += B[n]
    A[n] = sum

print(" ".join(list(map(str, A))))

Measured memory_bytes: 169008
#入力 人数N 入った順番A[i]
N = int(input())
A = list(map(int, input().split()))
#[入った順番 出席番号]のリストを作製
B = [[] for i in range(N)]
for i in range(N):
    B[i] = [A[i], i+1]
#入った順番(=最初の要素)早い順に並べる
B.sort()
#出席番号だけのリストを作製
ans = [0 for i in range(N)]
for i in range(N):
    ans[i] = B[i][1]
#リストの要素をスベース付きで全て表示
print(*ans)

Measured memory_bytes: 23628
// Author : Chi
// created :

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

//macros
#define ll 		    long long
#define ss          second
#define ff          first
#define vi          vector<int>
#define vll         vector<long long>
#define pb          push_back
#define TEST  	    int TesT;cin>>TesT;while(TesT--)solve();
#define TEST1       solve();
#define mod         998244353
#define r0n(i,n)    for(ll i = 0; i < n; ++i)
#define r1n(i,n)    for(ll i = 1; i <= n; ++i)
#define CHI         ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
//namespaces
using    namespace __gnu_pbds;
using    namespace std;

typedef tree <int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update > ordered_set;
void solve(){
    int n,k;
    cin>>n>>k;
    int a[n];
    for(int i=0;i<n;i++)cin>>a[i];
    int ans[n]={0};
    for(int i=1;i<n;i++){
        ans[i]=INT_MAX;
        r1n(j,k)
            if(i-j>=0){
                ans[i]=min(ans[i],ans[i-j]+abs(a[i]-a[i-j]));
                }
    }
    cout<<ans[n-1];
}
// Driver Code
int main()
{
    TEST1
    return 0;
}


Measured memory_bytes: 1024
#include<stdio.h>
 
int main()
{   
    int a, b;
    int count = 1;
    while(scanf("%d %d", &a, &b) != EOF){
 
        a= a + b;
        while(a>= 10){
            a/= 10;
            count++;
        }
        printf("%d\n", count);
        count = 1;
    }
 
 
    return 0;
}

Measured memory_bytes: 1760
import sys
input = sys.stdin.readline
from collections import deque
import bisect

N = int(input())
A = [int(input()) for _ in range(N)]
A.reverse()

d = []
for i in range(N):
    p = bisect.bisect_right(d, A[i])
    if p==len(d):
        d.append(A[i])
    else:
        d[p] = A[i]
ans = len(d)
print(ans)


Measured memory_bytes: 8188
#include<stdio.h>
#include<math.h>

int main()
{
 int j,s[1001],sum;
 double n,m,a,shiguma,kake;

for(;;){
        scanf("%lf",&n);
        if(n==0)break;
        sum=0;
        shiguma=0;
        for(j=0;j<n;j++){
                         
                         scanf("%d",&s[j]);
                         sum+=s[j];
                         }
        m=sum/n;
        for(j=0;j<n;j++){
                         
                         shiguma+=pow(s[j]-m,2);
                         }
        a=sqrt(shiguma/n);
        printf("%lf\n",a);
                }
 return 0;
}



Measured memory_bytes: 2044
/*Function Template*/
#include<bits/stdc++.h>
using namespace std;
const int mod = 1000000007;
#define rep(i, n) for(int i = 0; i < (n); i++)


int Len(int n) {
  int s=0;
  while(n!=0) s++, n/=10;
  return s;
}


int Sint(int n) {
  int m=0,s=0,a=n;
  while(a!=0) s++, a/=10;
  for(int i=s-1;i>=0;i--) m+=n/((int)pow(10,i))-(n/((int)pow(10,i+1)))*10;
  return m;
}


int Svec(vector<int> v){
  int n=0;
  for(int i=0;i<v.size();i++) n+=v[i];
  return n;
}


int GCD(int a,int b){
  int r,tmp;
/*自然数 a > b を確認・入替*/
  if(a<b){
    tmp=a,a=b,b=tmp;
  }
/*ユークリッドの互除法*/
  r=a%b;
  while(r!=0){
    a=b,b=r,r=a%b;
  }
  return b;
}


int LCM(int a,int b){
  int c=a,d=b,r,tmp;
/*自然数 a > b を確認・入替*/
  if(a<b){
    tmp=a,a=b,b=tmp;
  }
/*ユークリッドの互除法*/
  r=a%b;
  while(r!=0){
    a=b,b=r,r=a%b;
  }
  return c/b*d;
}


int Factorial(int n){
  int m=1;
  while(n>=1) m*=n,n--;
  return m;
}


/*↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓*/
int main() {
  long long int n;
  cin>>n;
  vector<long long int> v(n+2);
  v[0]=0;
  v[n+1]=0;
  rep(i,n) cin>>v[i+1];
  long long int ans=0;
  for(int i=0;i<n+1;i++){
    ans+=abs(v[i+1]-v[i]);
  }
  
  int cnt=ans;
  for(int i=1;i<n+1;i++){
    cnt=ans;
    cnt=cnt-abs(v[i]-v[i-1])-abs(v[i+1]-v[i])+abs(v[i+1]-v[i-1]);
    cout<<cnt<<endl;
  }
  
  
}

Measured memory_bytes: 2048
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define REP(i,n) for(int i=0;i<n;++i)
#define REP1(i,n) for(int i=1;i<=n;++i)
#define SZ(i) int(i.size())
#define eb emplace_back
#define ALL(i) i.begin(),i.end()
#define X first
#define Y second
#ifdef tmd
#define IOS()
#define debug(...) fprintf(stderr,"#%d: %s = ",__LINE__,#__VA_ARGS__),_do(__VA_ARGS__);
template<typename T> void _do(T &&x){cerr<<x<<endl;}
template<typename T, typename ...S> void _do(T &&x, S &&...y){cerr<<x<<", ";_do(y...);}
template<typename It> ostream& _printRng(ostream &os,It bg,It ed)
{
    os<<"{";
    for(It it=bg;it!=ed;it++) {
        os<<(it==bg?"":",")<<*it;
    }
    os<<"}";
    return os;
}
template<typename T> ostream &operator << (ostream &os,vector<T> &v){return _printRng(os,v.begin(), v.end());}
template<typename T> void pary(T bg, T ed){_printRng(cerr,bg,ed);cerr<<endl;}
#else
#define IOS() ios_base::sync_with_stdio(0);cin.tie(0);
#define endl '\n'
#define debug(...)
#define pary(...)
#endif

const int MAXN = 100005;
const ll MOD = 1000000007;

int n, d;
/*********************GoodLuck***********************/
int main () {
    IOS();

    cin >> n >> d;

    cout << d + max(0,10-n) * 100 << endl;
}


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

int main() {
    int n,x;
    cin >> n >> x;

    int ans = 1,d = 0;
    for(int i = 0; i < n; ++i){
        int l;
        cin >> l;

        d += l;
        if(d <= x) ans++;
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
import java.util.*;

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

		String str = sc.next();
		
		char[] charStr = str.toCharArray();
		
		for(int i = charStr.length - 1; i >= 0; i--) {
			System.out.print(charStr[i]);
		}
		
		System.out.println();
	}
}

Measured memory_bytes: 25736
# -*- coding: utf-8 -*-
import sys
from functools import reduce
import sys
input = sys.stdin.readline
n = int(input())
A = list(map(int, input().split()))

def gcd(a, b):
	while (b):
		a, b = b, a % b
	return a


L = [0] + [None] * (n - 1)
R = [0] + [None] * (n - 1)
for i in range(1, n):
	L[i] = gcd(L[i - 1], A[i - 1])
	R[i] = gcd(R[i - 1], A[-i])

M = [None] * n
R = R[::-1]
for i in range(n):
	M[i] = gcd(L[i], R[i])

print(max(M))

Measured memory_bytes: 14636
#include <iostream>
#include <numeric>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <iterator>
#include <math.h>
#include <cmath>
#include <set>   

using namespace std;


int main() {
	int a, b, c, x;
	int count = 0;

	cin >> a >> b >> c >> x;

	for (int i = 0; i <= a; i++) {
		for (int j = 0; j <= b; j++) {
			for (int k = 0; k <= c; k++) {
				if (500 * i + 100 * j + 50 * k == x) {
					count++;
				}

			}
		}
	}

	cout << count << endl;

}

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

int main(){
  int n;
  cin >> n;
  vector<int> p(n);
  for(int i=0; i<n; i++){
    cin>>p.at(i);
  }
  int count = 0;
  for(int i=1; i<n-1; i++){
    if((p.at(i-1)<p.at(i)&&p.at(i)<p.at(i+1))||(p.at(i-1)>p.at(i)&&p.at(i)>p.at(i+1))){
      count++;
    }
  }
  cout << count << endl;
      
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i,a,b) for(int i=a;i<b;i++)
using namespace std;
int main()
{
    int a, b;
    cin >> a >> b;
    if (a == 1) a += 13;
    if (b == 1) b += 13;
    if (a == b) cout << "Draw" << endl;
    else if (a < b) cout << "Bob" << endl;
    else cout << "Alice" << endl;
}


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

int main() {
    int n;
    cin >> n;
    int a[n], b[n], c[n];
    for (int i = 0; i < n; i++) scanf(" %d", &a[i]);
    for (int i = 0; i < n; i++) scanf(" %d", &b[i]);
    for (int i = 0; i < n; i++) scanf(" %d", &c[i]);
    sort(a, a + n);
    sort(c, c + n);
    
    ll ans = 0;
    for (int i = 0; i < n; i++) {
        ll numA = lower_bound(a, a + n, b[i]) - a;
        ll numC = upper_bound(c, c + n, b[i]) - c;
        numC = (ll)n - numC;
        ans += numA * numC;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1408
N = int(input())
A = 0
B = 0
ls1 = list(map(int,input().split()))
ls1.sort()
ls1.reverse()
for i in range(N):
    if i%2 == 0:
        A += ls1[i]
    else:
        B += ls1[i]
print(A-B)

Measured memory_bytes: 3060
// AUTHOR:: MOHAMMAD FAISAL
#include<bits/stdc++.h>
using namespace std;

int main()
{
  int n;
  cin >>n;
  set<int> s;
  for(int i=0;i<n;i++)
  {
    int x;
    cin >> x;
    s.insert(x);
  }
  if(s.size()==n) 
    cout<<"YES";
  else
    cout<<"NO";
  return 0;
}

Measured memory_bytes: 9600
n,k = map(int, input().split())
r,s,p = map(int, input().split())
t = input()

score=0

def point(c):
    if c == 'r':
        return p
    if c == 's':
        return r
    if c == 'p':
        return s
    

draw = [False for i in range(n)]

for i in range(n):
    if i < k or t[i] != t[i-k]:
        score += point(t[i])
    elif t[i] == t[i-k]:
        if draw[i-k]:
            score += point(t[i])
        else:
            draw[i] = True    
    
print(score)

Measured memory_bytes: 45424
import sys

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


def resolve():
    n = int(input())
    s = input()
    num = list(set(s))
    res = 0
    for i in num:
        for j in num:
            for k in num:
                ss = i + j + k
                pos = 0
                for l in range(len(s)):
                    if ss[pos] == s[l]:
                        pos += 1
                        if pos == 3:
                            res += 1
                            break
    print(res)


if __name__ == '__main__':
    resolve()


Measured memory_bytes: 9288
#include<cstdio>
#include<iostream>
#include<cmath>
using namespace std;
void print(int a[],int n){
	for(int i = 0; i< n;i++)
	 printf("%d%c",a[i],i == n-1?'\n':' ');
	 
}
void insertsort(int a[],int n){
	for(int i = 1;i<n;i++){
		int j = i -1;
		int v = a[i];
		while(j>=0 && a[j] > v){
			a[j+1] = a[j];
			j--;
		}
		a[j+1] = v;
		print(a,n);
	}
}
int main(){
	int n, a[110];
	scanf("%d",&n);
	for(int i = 0; i< n;i++)
	scanf("%d",&a[i]);
	print(a,n);
	insertsort(a,n);
	return 0;
}


Measured memory_bytes: 3212
#include <stdio.h>
int main(void){

    int i, A, B, K ;

    scanf("%d%d%d" ,&K, &A, &B);

    i=A/K;
    if( K*(i+1)>=A && K*(i+1)<=B){
        printf("OK");

    }else if(K*i==A){
        printf("OK");
    }else{
        printf("NG");
    };

    return 0;
}


Measured memory_bytes: 1732
def div2time(n):
    if n % 2 == 1:
        return 0
    return 1 + div2time(n // 2)

if __name__ == "__main__":
    n = int(input())
    array = [int(s) for s in input().split()]
    print(sum(div2time(n) for n in array))



Measured memory_bytes: 4148
def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a
  
def gcd(a, b):
    while b != 0:
        a, b = b, a % b
    return a
  
def main():
  A,B=map(int,input().split())
  C=gcd(A,B)
  t=prime_factorize(C)
  print(len(set(t))+1)
  
main()

Measured memory_bytes: 3064
import sys
stdin = sys.stdin
 
sys.setrecursionlimit(10**5) 
 
def li(): return map(int, stdin.readline().split())
def li_(): return map(lambda x: int(x)-1, stdin.readline().split())
def lf(): return map(float, stdin.readline().split())
def ls(): return stdin.readline().split()
def ns(): return stdin.readline().rstrip()
def lc(): return list(ns())
def ni(): return int(stdin.readline())
def nf(): return float(stdin.readline())

n,h = li()

def extract_gt_maxa(b: list, maxa: int) -> list:
    b.sort(reverse=True)
    ret = []
    for bi in b:
        if bi < maxa:
            break
        
        ret.append(bi)
        
    return ret

alist = []
blist = []
for _ in range(n):
    a,b = li()
    alist.append(a)
    blist.append(b)
    
b_gt_maxa = extract_gt_maxa(blist, max(alist))

ans = 0
for bi in b_gt_maxa:
    if h <= 0:
        break
    
    h -= bi
    ans += 1
    
if h > 0:
    ans += -(-h // max(alist))

print(ans)

Measured memory_bytes: 11984