akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <bitset>
#include <math.h>
#include <iomanip>
#include <queue>
#define inp(X) cin >> X
#define out(X) cout << X << endl
#define rep(i,n) for(int i=0;i<n;i++ )
#define rep2(i,f,n) for(int i=f;i<n;i++ )
#define MAX(A) *max_element(A.begin(),A.end())
#define MIN(A) *min_element(A.begin(),A.end())
#define SORT(A) sort(A.begin(),A.end())
using namespace std;

typedef long long int ll;
#define MOD 1000000007
#define INF 1000000001

ll gcd(ll x, ll y){
	if(y==0) return x;
	return gcd(y,x%y);
}

bool bfs(vector<vector<int>> g, vector<int> &dist, int sv)
{
	queue<int> q;
	q.push(sv);
	dist[sv]=0;
	while(!q.empty()){
		int now = q.front(); q.pop();
		for(auto v : g[now]){
			if(dist[v]!=-1) continue;
			dist[v] = dist[now]+1;
			q.push(v);
		}
	}
}

int main(void) {
	ll w,h; cin >> w >> h;
	ll x,y; cin >> x>> y;
	cout << (w*h)/2.0 << " ";
	if(x*2==w && y*2==h) cout << 1 << endl;
	else cout << 0 << endl;
}




Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define ll long long 
#define REP(i, a, b) for (ll i = a; i < b; i++)
#define REPI(i, a, b) for (ll i = b - 1; i >= a; i--)
#define i_os ios::sync_with_stdio(0);  cin.tie(0);  cout.tie(0);
#define INF (ll)1e18 + 100
#define endl "\n"
#define p0(a) cout << a << " "
#define p1(a) cout << a << endl
#define p2(a, b) cout << a << " " << b << endl
#define p3(a, b, c) cout << a << " " << b << " " << c << endl
#define p4(a, b, c, d) cout << a << " " << b << " " << c << " " << d << endl
#define MAX 1e6
/*SOME BITMASK KNOWLEDGE
1)x & (x - 1):sets the last one bit of x to zero
power of two exactly when x & (x − 1) = 0.
2)x & -x:sets all the one bits to zero, except last one bit
3)x | (x - 1):inverts all the bits after the last one bit*/
#define o_set tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>
#define o_setll tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update>
typedef tree<pair<ll, ll>,null_type,less<pair<ll, ll>>,rb_tree_tag,tree_order_statistics_node_update> indexed_set;
//1. order_of_key(k) : number of elements strictly lesser than k
//2. find_by_order(k) : k-th element in the set

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

	ll q;
	cin>>q;
	ll query[q] = {0};
	vector<ll> arr[q];
	ll sum = 0;

	REP(i,0,q){
		ll x;
		cin>>x;
		arr[i].push_back(x);
		if(x == 1){
			query[i]++;
			sum++;	
		} 

		if(x == 2){
			ll y; char z;
			cin>>y>>z;
			arr[i].push_back(y);
			arr[i].push_back(z-'a');
		} 
	}

	REPI(i,0,q-1){
		query[i] += query[i+1]; 
	}
	deque<char> d;

	if(sum % 2){
		reverse(s.begin(),s.end());
	}
	REP(i,0,s.size()){
		d.push_back(s[i]);
	}
	REP(i,0,q){
		if(arr[i].size() > 1){
			if(query[i] % 2){
				if(arr[i][1] == 1) d.push_back(arr[i][2] + 'a');
				else d.push_front(arr[i][2] + 'a');
			}
			else {
				if(arr[i][1] == 1) d.push_front(arr[i][2] + 'a');
				else d.push_back(arr[i][2] + 'a');	
			}
		}
	}
	REP(i,0,d.size()) cout<<d[i];
	cout<<endl;
	return 0;
}



Measured memory_bytes: 16512
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <map>
#include <set>
#include <string>
#include <cstring>
#include <sstream>
#include <cmath>
#include <functional>
#include <fstream>
#include <cstdlib>
typedef long long ll;

#define REP(i, N) for (int i = 0; i < (N); i++)
#define REPP(i, a, b) for (int i = (a); i < (b); i++)
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define VSORT(c) sort((c).begin(),(c).end())
#define SZ(x) ((int)(x).size())

using namespace std;

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

    cin >> H >> W;
    int h,w;

    cin >> h >> w;

    cout << (W-w)*(H-h) << endl;

    

    return 0;
}

Measured memory_bytes: 256
def main():
    N, K = map(int, input().split())
    ans = base10to(N, K)
    print(len(ans))

def base10to(n, b):
    if (int(n/b)):
       return base10to(int(n/b), b) + str(n%b)
    return str(n%b)

if __name__ == '__main__':
    main()


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

int main(){
  int N;
  cin >> N;
  vector<int> vec(N);
  for(int i = 1; i < N;i++){
    int n;
    cin >> n;
    vec.at(n-1)++;
  }
  for(auto &v : vec) cout << v << endl;
}

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

#define rep(i, a, b) for (int i = a; i < (b); ++i)
#define trav(a, x) for (auto& a : x)
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;

int main() {
	cin.sync_with_stdio(false); cin.tie(0);
	cin.exceptions(cin.failbit);
	
	int n; cin >> n;
	string s, t; cin >> s >> t;
	int ml = n * 2;

	rep(i, 1, n + 1) {
		if (s.substr(n - i) == t.substr(0, i))
			ml = n * 2 - i;
	}
	
	cout << ml << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;
using vi = vector<int>;
using vc = vector<char>;
using vs = vector<string>;
using vll = vector<long long>;
using vvi = vector<vector<int>>;
using vvc = vector<vector<char>>;
using vvll = vector<vector<long long>>;
template<class T> inline bool chmax(T &a, T b) { if (a<b) {a=b; return 1;} return 0;}
template<class T> inline bool chmin(T &a, T b) { if (b<a) {a=b; return 1;} return 0;}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int n;
    cin >> n;
    vi a(n);
    rep(i, n) cin >> a[i];

    ll ans = pow(3, n);
    ll odd = 1;
    rep(i, n) {
        if (~a[i]&1) odd *= 2;
        else odd *= 1;
    }
    ans -= odd;
    cout << ans << endl;
}

Measured memory_bytes: 384
#include <iostream>
#include <vector>
#include <cstring>
#include <string>
#include <algorithm>
#include <queue>
#include <map>
#include <math.h>
using namespace std;
using  std::string;
#define maxn 100005
string s;
int main(){
	cin >> s;
	int flag = 1;
	int n = s.length();
	while(n>0){
		if (n>=5 && s.substr(n- 5, 5) == "dream"){
			
			n -= 5;
			continue;
		}
		else if (n>=5 && s.substr(n - 5, 5) == "erase"){
			n -= 5;
			continue;
		}
		else if (n >= 7 && s.substr(n - 7, 7) == "dreamer"){
			n -= 7; continue;
		}
		else if (n>=6 && s.substr(n - 6, 6) == "eraser"){
			n -= 6; continue;
		}
		flag = 0; break;
	}
	if (flag)
		printf("YES\n");
	else
		printf("NO\n");

	return 0;
}

Measured memory_bytes: 512
# -*- coding: utf-8 -*-
import sys

def main():
	p, l = map(int, input().split(" "))
	
	lines = []
	for i in range(l):
		a, b = map(int, input().split(" "))
		a, b = a - 1, b - 1
		lines.append((a, b))
		
	result = 0
	for i, val in enumerate(lines):
		uf = UnionFind(p)
		for i, val2 in enumerate(lines):
			if val == val2:
				continue
			a, b = val2
			uf.union(a, b)
			
		aa, _ = lines[0]
		for i in range(p):
			if uf.is_same(aa, i) == False:
				result = result + 1
				break
				
	print(result)

class UnionFind(object):
	def __init__(self, n=1):
		self.par = [i for i in range(n)]
		self.rank = [0 for _ in range(n)]
		
	# x が属するグループを探索
	def find(self, x):
		if self.par[x] == x:
			return x
		else:
			self.par[x] = self.find(self.par[x])
			return self.par[x]
		
	# x と y のグループを結合
	def union(self, x, y):
		x = self.find(x)
		y = self.find(y)
		if x != y:
			if self.rank[x] < self.rank[y]:
				x, y = y, x
			if self.rank[x] == self.rank[y]:
				self.rank[x] += 1
			self.par[y] = x
	
	# x と y が同じグループがどうか
	def is_same(self, x, y):
		return self.find(x) == self.find(y)
		
if __name__ == "__main__":
	main()
	

Measured memory_bytes: 3064
N = int(input())

lst = []
for i in range(N):
  N, K = map(int, input().split())
  lst.append((K-N, N, K))

lst.sort()
lst.sort(key=lambda tup: tup[2])
count = 0
for ind, x in enumerate(lst):
  if count > x[0]:
    print("No")
    exit()
  count += x[1]

print("Yes")


Measured memory_bytes: 38224
s = input()
q = int(input())
for i in range(q) :
    order = input().split()
    a = int(order[1])
    b = int(order[2])
    if order[0] == "print" :
        print(s[a : b + 1])
    if order[0] == "replace" :
        s = s[:a] + order[3] + s[b + 1:]
    if order[0] == "reverse" :
        s_reverse = s[a : b + 1]
        s = s[:a] + s_reverse[::-1] + s[b + 1:]



Measured memory_bytes: 5612
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0;i<n;i++)
#define rep2(i,a,n) for(int i=a;i<n;i++)
#define been(ix) (ix).begin(),(ix).end()
using namespace std;
typedef long long ll; 
typedef vector<int> vi;
typedef vector<long long> vl;
const ll INFL = 1e18;
const int INF = 1001001001; 
typedef pair<int,int> P;
#define foreach(ix,i) for(auto& (ix) : (i))
typedef long double ld;
const int mod =1000000007;
const double PI = acos(-1);
std::vector<int> erato( const int N )
{
    std::vector<bool> is_prime( N + 1 );
    for( int i = 0; i <= N; i++ )
    {
        is_prime[ i ] = true;
    }
    std::vector<int> P;
    for( int i = 2; i <= N; i++ )
    {
        if( is_prime[ i ] )
        {
            for( int j = 2 * i; j <= N; j += i )
            {
                is_prime[ j ] = false;
            }
            P.emplace_back( i );
        }
    }
    return P;
}
int main(){
    int n;cin>>n;
    vi a =erato(55555);
    vi ans;
    rep(i,a.size()){
        int t =a[i];
        string s=to_string(t);
        if(s.back()=='1')ans.push_back(t);
    }
    rep(i,n-1)cout<<ans[i]<<' ';
    cout<<ans[n-1]<<endl;
}

Measured memory_bytes: 3688
from fractions import gcd

N,X=map(int,input().split())
x=list(map(int,input().split()))
x.append(X)
x.sort()

diff=[0]*N

for i in range(N):
    diff[i]=x[i+1]-x[i]

g=diff[0]
for i in range(N):
    g=gcd(g,diff[i])

print(g)

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

using ll = long long;

int main() {

    int n;
    cin >> n;

    vector<ll> a(n), b(n), c(n);

    for(int i = 0; i < n; ++i)
        cin >> a[i];
    for(int i = 0; i < n; ++i)
        cin >> b[i];
    for(int i = 0; i < n; ++i)
        cin >> c[i];

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

    ll sum = 0;

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

        auto a_itr = lower_bound(a.begin(), a.end(), b[i]);
        auto c_itr = upper_bound(c.begin(), c.end(), b[i]);

        ll aCount = a_itr - a.begin();
        ll cCount = c.end() - c_itr;

        sum += aCount * cCount;

    }

    cout << sum << endl;

    return 0;

}

Measured memory_bytes: 2688
#include<bits/stdc++.h>
using namespace std;
#define ll long long
ll compute(ll n){
    ll a = n%4;
    if(a==0)
        return n;
    else if(a == 1)
        return 1;
    else if(a == 2)
        return n+1;
    else
        return 0;
}
int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    ll A,B;
    cin>>A>>B;
    ll ans = compute(B)^ compute(A-1);
    cout<<ans<<'\n';
}


Measured memory_bytes: 256
using System;

namespace _0039
{
    class Program
    {
        static void Main(string[] args)
        {
            while (true)
            {
                string s = Console.ReadLine();
                if (string.IsNullOrEmpty(s))
                {
                    break;
                }
                int sum = 0;
                int now = 0;
                for (int i = s.Length - 1; i >= 0; i--)
                {
                    switch (s[i])
                    {
                        case ('I'):
                            {
                                if (now > 1)
                                {
                                    sum--;
                                }
                                else
                                {
                                    sum++;
                                }
                                now = 1;
                                break;
                            }
                        case ('V'):
                            {
                                sum += 5;
                                now = 5;
                                break;
                            }
                        case ('X'):
                            {
                                if (now > 10)
                                {
                                    sum -= 10;
                                }
                                else
                                {
                                    sum += 10;
                                }
                                now = 10;
                                break;
                            }
                        case ('L'):
                            {
                                sum += 50;
                                now = 50;
                                break;
                            }
                        case ('C'):
                            {
                                if (now > 100)
                                {
                                    sum -= 100;
                                }
                                else
                                {
                                    sum += 100;
                                }
                                now = 100;
                                break;
                            }
                        case ('D'):
                            {
                                sum += 500;
                                now = 500;
                                break;
                            }
                        default:
                            {
                                sum += 1000;
                                now = 1000;
                                break;
                            }
                    }
                }
                Console.WriteLine(sum);
            }
        }
    }
}

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

int main(){
	int in,c,a,b;
	int n,m,w[1000];
	while(cin>>n>>m,n!=0&&m!=0){
	  c=a=0;
	  for(int i=0;i<n;i++)
	    cin>>w[i];
	  while(a+1<=n-1){
	    cin>>in;
	    a=a+in+w[in+a];
		c++;
	  }
	  
	  for(int i=c;i<m;i++)cin>>in;
	cout<<c<<endl;
	}
	
}

Measured memory_bytes: 1164
#include<cmath>
#include<cstdio>
#include<algorithm>
using namespace std;
int i,j,k,n,m,st,ans;
int main()
{
	scanf("%d%d",&n,&m);
	for (i=1,st=sqrt(m);i<=st;++i)
		if (!(m%i))
		{
			if (i<=m/n)
				ans=max(ans,i);
			if (m/i<=m/n)
				ans=max(ans,m/i);
		}
	printf("%d",ans);
	return 0;
}

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

template <typename T>
class BIT {
  int n;
  vector<T> bit;
public:
  BIT(int _n) {
    n = _n;
    bit = vector<T>(n+1,(T)0);
  }
  T sum(int i) {
    T s = 0;
    while(i > 0){
    s += bit[i];
    i -= i & -i;
  }
  return s;
  }
  void add(int i, T x) {
    while(i <= n){
    bit[i] += x;
    i += i & -i;
    }
  }
};

int main(){
  int n; ll k, a;
  cin >> n >> k;
  ll sum[n+1];
  sum[0] = 0;  
  vector<P> s(n+1);
  rep(i,n) {
    cin >> a;
    sum[i+1] = sum[i] + a; 
  }
  rep(i,n+1) s[i] = P(sum[i]-k*i,i); 
  sort(s.begin(),s.end());
  vector<int> v(n+1);
  rep(i,n+1) v[s[i].second] = i+1;
  BIT<ll> bit(n+1);
  ll ans = 0;
  rep(i,n+1) {
    ans += bit.sum(v[i]);
    bit.add(v[i],1);
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 7296
#include <iostream>
#include <string>
using namespace std;
typedef long long ll;

int main() {
  string n;
  cin >> n;
  int res = 0;
  for (int i = 0; i < (int)n.size(); i++) {
    res += int(n[i] - '0');
  }
  if (res % 9 == 0) cout << "Yes";
  else cout << "No";
  return 0;
}


Measured memory_bytes: 3700
#include <bits/stdc++.h>
 
#define int long long
 
// loop
#define FOR(i, a, b) for (int i = (a); i < (b); i++) 	// a ~ b-1	(ascending)
#define REP(i, n) FOR(i, 0, n)							// 0 ~ n-1
#define NREP(i, n) FOR(i, 1, n + 1)						// 1 ~ n
#define RFOR(i, a, b) for (int i = (a); i >= (b); i--)	// a ~ b	(descending)
#define RREP(i, n) RFOR(i, n, 0)						// n ~ 0
#define RNREP(i, n) RFOR(i, n, 1)						// n ~ 1
 
// container operation
#define EACH(i, c) for (auto i = (c).begin(); i != (c).end(); i++)
#define ASORT(c) std::sort((c).begin(), (c).end())
#define DSORT(c) std::sort((c).begin(), (c).end(), std::greater<typeof((c).front())>())
#define SIZE(x) ((int)(x).size())
 
// debug
#define check(x) std::cout << #x << " = " << x << '\n'
 
// print
#define cout(x) std::cout << x << '\n'
 
// typedef
typedef std::vector<int> VI;
typedef std::vector<VI> VII;
typedef std::vector<std::string> VS;

std::string yes = "Yes\n";
std::string no = "No\n";

void solve();

signed main() {
  solve();
  return 0;
}

void solve() {
  int x, a, b;
  std::cin >> x >> a >> b;
  cout((x - a) % b);
}

Measured memory_bytes: 256
N = int(input())  #数値入力
A = str(input())
B = str(input())
C = str(input())

count = 0
for i in range(N):
  if ( (A[i] != B[i]) & (A[i] != C[i]) & (B[i] != C[i])):
    count+=2
  else:
    if ( (A[i] != B[i]) & (A[i] == C[i]) & (B[i] != C[i]) ):
      count+=1
    if ( (A[i] != B[i]) & (A[i] != C[i]) & (B[i] == C[i]) ):
      count+=1
    if ( (A[i] == B[i]) & (A[i] != C[i]) & (B[i] != C[i]) ):
      count+=1

print(count)

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

int g[110][110];

signed main(){
    int h, w, n;
    cin >> h >> w >> n;
    vector<int> a(n);
    vector<P> d(n);
    rep(i, 0, n){
        cin >> a[i];
        d[i].first = a[i];
        d[i].second = i + 1;
    }
    sort(all(d));
    reverse(all(d));
    int ny = 0, nx = 0;
    rep(i, 0, n){
        int cnt = d[i].first;
        int now = d[i].second;
        while(cnt){
            g[ny][nx] = now;
            cnt--;
            if(ny % 2 == 0) nx++;
            else nx--;
            if(!(0 <= nx && nx < w)){
                if(ny % 2 == 0) nx = w - 1;
                else nx = 0;
                ny++;
            }
        }
    }
    rep(i, 0, h){
        rep(j, 0, w){
            cout << g[i][j];
            if(j != w - 1) cout << " ";
        }
        cout << endl;
    }
}

Measured memory_bytes: 640
X, Y, Z, K = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))

A = sorted(A)[::-1]
B = sorted(B)[::-1]
C = sorted(C)[::-1]

import bisect, heapq

def myidx(x, y, z, X, Y, Z): return(x * (Y * X) + y * Z + z)

ans = 0
cnt = 0
score = A[0] + B[0] + C[0]
history = {}
q = [(0, 0, 0, 0)]
while len(q) > 0:
    penalty, x, y, z = heapq.heappop(q)
    # print("#", penalty, x, y, z, history)
    if x < X - 1:
        idx_tmp = myidx(x + 1, y, z, X, Y, Z)
        if history.setdefault(str(idx_tmp), 0) == 0:
            # print("##", x + 1, y, z)
            history[str(idx_tmp)] = 1
            #
            penalty_tmp = penalty + (A[x] - A[x + 1])
            heapq.heappush(q, (penalty_tmp, x + 1, y, z))
    if y < Y - 1:
        idx_tmp = myidx(x, y + 1, z, X, Y, Z)
        if history.setdefault(str(idx_tmp), 0) == 0:
            # print("##", x, y + 1, z)
            history[str(idx_tmp)] = 1
            #
            penalty_tmp = penalty + (B[y] - B[y + 1])
            heapq.heappush(q, (penalty_tmp, x, y + 1, z))
    if z < Z - 1:
        idx_tmp = myidx(x, y, z + 1, X, Y, Z)
        if history.setdefault(str(idx_tmp), 0) == 0:
            # print("##", x, y, z + 1)
            history[str(idx_tmp)] = 1
            #
            penalty_tmp = penalty + (C[z] - C[z + 1])
            heapq.heappush(q, (penalty_tmp, x, y, z + 1))
    #
    cnt += 1
    print(score - penalty)
    if cnt == K:
        break

Measured memory_bytes: 4712
{-# OPTIONS_GHC -O2 -funbox-strict-fields #-}
{-# LANGUAGE BangPatterns      #-}
{-# LANGUAGE CPP               #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE TupleSections     #-}

import           Control.Applicative
import           Control.Monad
import           Control.Monad.Primitive
import           Control.Monad.ST
import           Control.Monad.State.Strict
import           Data.Bool
import qualified Data.ByteString.Char8       as B
import qualified Data.ByteString.Unsafe      as B
import           Data.Char
import           Data.Function
import qualified Data.IntMap.Strict          as IM
import qualified Data.IntSet                 as IS
import           Data.List
import qualified Data.Map.Strict             as M
import           Data.Monoid
import           Data.Ord
import           Data.Primitive.MutVar
import qualified Data.Set                    as S
import           Data.Tuple
import qualified Data.Vector                 as V
import qualified Data.Vector.Generic         as G
import qualified Data.Vector.Generic.Mutable as GM
import qualified Data.Vector.Unboxed         as U
import qualified Data.Vector.Unboxed.Mutable as UM
import           Debug.Trace
import           Foreign                     hiding (void)
import           Unsafe.Coerce

main :: IO ()
main = do
    !n <- readLn :: IO Int
    xs <- U.unfoldrN n (B.readInt.B.dropWhile isSpace) <$> B.getLine
    print $ solve xs

solve :: U.Vector Int -> Int
solve xs = head $ filter (testBit set) [div (U.sum xs + 1) 2..]
  where
    step :: Integer -> Int -> Integer
    step s x = s .|. unsafeShiftL s x
    !set = U.foldl' step 1 xs

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

long int gcd(long int a,long int b){
	if(b==0){
		return a;
	}else{
		return gcd(b,a%b);
	}
}

int main(void){
  long int a,b,i;
  int t=0,ans=1;
  scanf("%ld %ld",&a,&b);
  a=gcd(a,b);
  if(a!=1){
	  for(i=2;i<=a;i++){
	  	if(i>sqrt(a)){
	  		ans++;
	  		break;
	  	}
	  	t=0;
	  	while(a%i==0){
	  		a/=i;
	  		t=1;
	  	}
	  	ans+=t;
	  }
  }
  printf("%d",ans);
  return 0;
}

Measured memory_bytes: 128
n, k = map(int, input().split())
s = input().rstrip()


#n, k = 5, 3
#s = "00010"

m = 0
cur_s = cur_e = 0

while True:
  while cur_e < n and s[cur_e] == '1':
    cur_e+=1
  
  if k <= 0 or cur_e >= n:
    wm = cur_e - cur_s
    if wm > m:
      m = wm
      
    if cur_e >= n:
      break
 
    while cur_s < n and s[cur_s] == '1':
      cur_s+=1
    while cur_s < n and s[cur_s] == '0':
      cur_s+=1
    k+=1

  if k > 0:
    while cur_e < n and s[cur_e] == '0':
      cur_e+=1
    k-=1
    
print(m)


Measured memory_bytes: 3316
#include <stdio.h>


int main(){
    int a, b, num;
    char num1[6];

    int total = 0;

    scanf("%d %d", &a, &b);

    for(int i = a; i <= b; ++i){
        int k = 0;
        num = i;
        while(num > 0){
            num1[k] = (num%10);
            num = num/10;
            ++k;
        }
        if(num1[0] == num1[4] && num1[1] == num1[3])
            ++total;

    }
    printf("%d\n", total);

    return 0;
}


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

int main(){
  char c;
  cin >> c;
  if(c == 'a' || c=='i' || c == 'u' || c == 'e' || c == 'o') cout << "vowel" << endl;
  else cout << "consonant" << endl;
  
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> pll;
typedef pair<string, string> pss;
typedef vector<ll> vll;
typedef vector<pll> vpll;
typedef vector<vll> vvll;
typedef vector<vpll> vvpll;
typedef unordered_map<ll, ll> um;
typedef unordered_set<ll> us;

#define fastio ios::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL);
#define ts ll t; in(t) while (t--) solve();
#define ks ll t; in(t) FOR(i, 1, t+1) out("Case #" << i << ": " << solve());
#define endl '\n'
#define ln cout << endl;
#define in(x) cin >> x;
#define out(x) cout << x << endl;
#define flush cout << flush;
#define reset(a, b) memset(a, b, sizeof(a));
#define ordered_set tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>
#define FOR(i, a, b) for (ll i = a; i < b; ++i)
#define FORI(i, a, b, c) for (ll i = a; i < b; i += c)
#define FORD(i, a, b) for (ll i = a; i > b; --i)
#define FOREACH(it, v, r) for (auto it = v.begin() + r; it != v.end(); it++)
#define FORALL(it, v) for (auto it : v)
#define F first
#define S second
#define mp make_pair
#define pb push_back
#define vin(v, x) vll v(x); FOR(i, 0, x) in(v[i])
#define all(v) v.begin(), v.end()
#define allr(v, r) v.begin(), v.begin() + r
#define showv(v) FORALL(it, v) cout << it << ' '; ln
#define printv(v) FORALL(it, v) out(it)
#define show2d(v) FORALL(it, v) { FORALL(j, it) cout << j << ' '; ln}
#define showm(v) FORALL(it, v) cout << it.F << ": " << it.S << ' '; ln
#define sortv(v) sort(all(v));
#define revv(v) reverse(all(v));
#define maxv(v) *max_element(all(v))
#define minv(v) *min_element(all(v))
#define gcd __gcd
#define checkbit(n, i) (n >> i) & 1               // check ith bit
#define bitcount __builtin_popcount               // count set bits
#define firstbitindex __builtin_ctz               // count trailing zeros
#define lastbitindex __builtin_clz                // count leading zeros
#define bitparity __builtin_parity                // check set bits are even or odd
#define findv(v, x) (find(all(v), x) != v.end())  // find in a vector
#define findsm(u, x) (u.find(x) != u.end())       // find in a set / map
#define findstr(s, x) (s.find(x) != string::npos) // find in a string
#define sz(a) a.size()
#define precise(x) cout << fixed << setprecision(x);

const ll MAXN = 1e5, MOD = 998244353, SIZE = 2e7;//, INF = 0x7f7f7f7f7f7f7f7f;
const double EPS = 1e-9, PI = acos(-1);
const int INFi = 0x7f7f7f7f;

//<<------Declare Variables Here----->>//
ll n;
char c[26] = {'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z'};
string s;

//<<-----Implement Functions Here---->>//
void solve()
{
    in(n)
    while (n)
        --n, s = c[n % 26] + s, n /= 26;
    out(s)
}

//<<----------Start of Main---------->>//
int main()
{
    fastio
    //ts
    solve();
    return 0;
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
#define fio ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
#define Mod 1000000007
#define ll long long
#define dd double
#define pb push_back
#define ff first
#define ss second
#define Mp make_pair
#define INF (ll)(1e17+5)
#define NN (ll)(1e6+5)
int mod(string s,int a) 
{ 
    int ans=0; 
    for (int i=0;i<s.length();i++) 
         ans=(ans*10+(int)s[i]-'0')%a; 
    return ans; 
}
ll min(ll x,ll y){if(x<y) return x;return y;}
ll max(ll x,ll y){if(x>y) return x;return y;}
ll power(ll x,unsigned ll y) 
{ 
    if (y==0) 
        return 1; 
    else if (y%2==0) 
        return power(x,y/2)*power(x,y/2); 
    else
        return x*power(x,y/2)*power(x,y/2); 
}
ll hcf(ll a,ll b) 
{ 
    if(b==0) 
        return a; 
    return hcf(b,a%b);  
}
ll N,W;
vector <pair<ll,ll>> v;
ll dp[105][100005];
ll fn(ll ind,ll sum)
{
    if(dp[ind][sum]!=-1)
     return dp[ind][sum];
    if(sum==0)
     return dp[ind][sum]=0;  
    if(ind==N-1)
    {
        if(v[ind].ss==sum) 
         return dp[ind][sum]=v[ind].ff; 
        return dp[ind][sum]=INF; 
    }   
    if(v[ind].ss<=sum)
     return dp[ind][sum]=min(fn(ind+1,sum),v[ind].ff+fn(ind+1,sum-v[ind].ss));
    return dp[ind][sum]=fn(ind+1,sum); 
}
int main()
{
   fio;
   /*#ifndef ONLINE_JUDGE 
    	freopen("input.txt", "r", stdin); 
    	freopen("output.txt", "w", stdout); 
    	freopen("error.txt", "w", stderr); 
   #endif*/
   ll TT=1;
   memset(dp,-1,sizeof(dp));
   //cin>>TT;
   while(TT--)
   {   
       cin>>N>>W;
       ll i,x,y,ans=0;
       for(i=0;i<N;i++)
       {
           cin>>x>>y;
           v.pb(Mp(x,y));
       } 
       for(i=1;i<100005;i++)
       {
           x=fn(0,i);
           if(x<=W)
            ans=i;
       }
       //cout<<dp[0][90]<<" ";
       cout<<ans<<"\n";
   }
}

Measured memory_bytes: 82304
#include <iostream>

int main() {
    int n;
    std::cin >> n;
    int hotels[n];
    for (int i = 0; i < n; ++i) {
        std::cin >> hotels[i];
    }
    int c = 0;
    int height = hotels[0];
    for (int i = 1; i < n; ++i) {
        if (hotels[i] >= height) {
            c++;
            height = hotels[i];
        }
    }
    std::cout << c + 1 << std::endl;
    
}


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

int main(){
    int n;
    cin >> n;
    vector<int> p(n), q(n);
    for(int i = 0; i < n; i++) cin >> p[i];
    for(int i = 0; i < n; i++) cin >> q[i];

    vector<int> r(n);
    for(int i = 0; i < n; i++) r[i] = i+1;

    int count = 0;
    int pcount, qcount;
    do{
        bool ismatch = true;
        for(int i = 0; i < n; i++){
            if(p[i] != r[i]) ismatch = false;
        }
        if(ismatch) pcount = count;

        ismatch = true;
        for(int i = 0; i < n; i++){
            if(q[i] != r[i]) ismatch = false;
        }
        if(ismatch) qcount = count;
        count++;
    }while(next_permutation(r.begin(), r.end()));

    cout << max(pcount-qcount, qcount-pcount) << endl;
    return 0;
}

Measured memory_bytes: 256
maxscore = 0



def solve():
    ans = [-1]*n
    ans[-1] = m
    rek(ans, m, 1)
    return

def rek(ans, m, rekdepth):
    global maxscore
    curr_ans = ans.copy()
    for i in range(1, m+1):
        curr_ans[-rekdepth-1] = i
        if rekdepth == n-1:
            score = get_score(curr_ans)
            maxscore = max(maxscore, score)
        else:
            rek(curr_ans.copy(), i, rekdepth + 1)


def get_score(arr):
    score = 0
    for (a, b, c, d) in abcd:
        if (arr[b-1] - arr[a-1] == c):
            score += d
    return score



# n = int(input())
n, m, q = [int(s) for s in input().split(" ")]
abcd = []
for i in range(q):
    abcd.append([int(s) for s in input().split(" ")])

solve()
print(maxscore)


Measured memory_bytes: 70512
//  RAKSHIT KADAM
//ALWAYS USE &IT FOR ITERATING USING AUTO ...
//USE COUNT(STARTING ADDRESS, ENDING ADRESS ,VALUE) FOR FINDING THE COUNT IN THE RESPECTIVE DATA STRUCTURE
//NOTE THAT MEMSET CANT FILL THE DOUBLE VALUES;
//ACCUMULATE DOES NOT WORK PROPERLY IF VALUES START SUMMING BEYOND 1E9...
 #include <bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
// using namespace __gnu_pbds;
// #define ordered_set tree< int ,  null_type ,  less<int> ,  rb_tree_tag ,  tree_order_statistics_node_update>
#warning !!!check the size of arrayss!!!

// NUMERIC DEFINITIONS :
    #define INF 100000000000000005
    #define inf 1000000000
    #define MOD  1000000007
    #define newMOD  998244353
    #define MAX 300006
    #define pi 3.1415926535897932384626433832795
#define ld long double
 #define ll long long
 #define int long long

 #define P(gg) for(auto rax:gg){cout<<rax<<" ";}cout<<endl;
 #define Need_for_speed(activated) ios_base :: sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL)
 #define satisfy ll t; cin>> t; while(t--)
 #define inp(n) int n;cin >> n
 #define mp make_pair
 #define pb push_back
 #define endl "\n"
 #define x first
 #define y second
 #define fore(i,a,b) for(ll i=a;i<b;i++)
 #define forci(i,n) for(ll i=0;i<n;i++)
 #define vi vector<ll>
 #define Endl endl
 #define lb lower_bound
 #define ub upper_bound
#define pii pair<ll,ll>

 #define input freopen("input.txt", "r", stdin),freopen("output.txt", "w", stdout)
 #define time        cerr << "\nTime elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << "ms\n";
using namespace std;

ll gcd(ll a, ll b){if (b == 0)return a;return gcd(b, a % b);}
int power(int x, unsigned int y, unsigned int m){ if (y == 0) return 1;int p = power(x, y/2, m) % m;  p = (p * p) % m;return (y%2 == 0)? p : (x * p) % m;}
ll modInverse(int a, int m){{ return power(a, m-2, m);}}
const int maxn = 500003;
 
void solve()
{
    string s;cin>>s;
    cout<<s.substr(0,3)<<endl;
}

signed main()
{
   Need_for_speed(activated);
//
//satisfy
//    {
//  solve();
//   }

    solve();
    
    return 0;
}


Measured memory_bytes: 3656
#!/usr/bin/env python3
from collections import defaultdict, Counter
from itertools import product, groupby, count, permutations, combinations
from math import pi, sqrt
from collections import deque
from bisect import bisect, bisect_left, bisect_right
from string import ascii_lowercase
from functools import lru_cache
import sys
sys.setrecursionlimit(10000)
INF = float("inf")
YES, Yes, yes, NO, No, no = "YES", "Yes", "yes", "NO", "No", "no"
dy4, dx4 = [0, 1, 0, -1], [1, 0, -1, 0]
dy8, dx8 = [0, -1, 0, 1, 1, -1, -1, 1], [1, 0, -1, 0, 1, 1, -1, -1]


def inside(y, x, H, W):
    return 0 <= y < H and 0 <= x < W


def ceil(a, b):
    return (a + b - 1) // b


def sum_of_arithmetic_progression(s, d, n):
    return n * (2 * s + (n - 1) * d) // 2


def gcd(a, b):
    if b == 0:
        return a
    return gcd(b, a % b)


def lcm(a, b):
    g = gcd(a, b)
    return a / g * b


def solve():
    S = input()
    T = input()

    ans = 0
    for i in range(len(S)):
        ans += S[i] != T[i]
    print(ans)


def main():
    solve()


if __name__ == '__main__':
    main()


Measured memory_bytes: 10120
#include <chrono>

#include <iostream>
#include <iomanip>
#include <algorithm>
#include <bitset>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <cmath>
#include <time.h>
#include <random>
#include <string>
#include <cassert>
#include <vector>
#include <ostream>
#include <istream>
#include <stack>
#include <deque>
#include <queue>
#include <functional>

using namespace std;

#define int long long
#define pb push_back
#define all(a) (a).begin(), (a).end()
#define pii pair<int, int>
#define ld long double

ostream& operator << (ostream &a, const vector<int> &b) {
    for (auto k : b) cout << k << " ";
    return a;
}

#ifdef LOCAL
    #define dbg(x) cout << #x << " : " << (x) << "\n";
    const int INF = 1e18;
//    const int mod = 2600000069;
//    const int p = 10;
//    const ld PI = 3.1415926535;
#else
    #define dbg(x)
    const int INF = 1e18;
//    const int mod = 2600000069;
//    const int p = 179;
//    const ld PI = 3.1415926535;
#endif

//#pragma GCC optimize("Ofast,no-stack-protector")
//#pragma GCC target("sse,sse2,sse3,sse3,sse4")
//#pragma GCC optimize("unroll-loops")
//#pragma GCC optimize("fast-math")
//#pragma GCC target("avx2")
//#pragma GCC optimize("section-anchors")
//#pragma GCC optimize("profile-values,profile-reorder-functions,tracer")
//#pragma GCC optimize("vpt")
//#pragma GCC optimize("rename-registers")
//#pragma GCC optimize("move-loop-invariants")
//#pragma GCC optimize("unswitch-loops")
//#pragma GCC optimize("function-sections")
//#pragma GCC optimize("data-sections")

signed main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    #ifdef LOCAL
    #else
//        freopen("capitals.in", "r", stdin);
//        freopen("capitals.out", "w", stdout);
    #endif
    int n, m, l;
    cin >> n >> m >> l;
    vector<vector<int>> g(n, vector<int>(n, INF));
    int u, v, c;
    for (int i = 0; i < m; i++) {
        cin >> u >> v >> c;
        u--, v--;
        g[u][v]  = g[v][u] = c;
    }
    for (int k = 0; k < n; k++) {
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < n; j++) {
                g[i][j] = min(g[i][k] + g[k][j], g[i][j]);
            }
        }
    }
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < n; j++) {
            if (g[i][j] <= l) {
                g[i][j] = 1;
            } else g[i][j] = INF;
        }
    }
    for (int k = 0; k < n; k++) {
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < n; j++) {
                g[i][j] = min(g[i][j], g[i][k] + g[k][j]);
            }
        }
    }
    int q;
    cin >> q;
    for (int i = 0; i < q; i++) {
        cin >> u >> v;
        u--, v--;
        if (g[u][v] == INF) cout << "-1\n";
        else cout << g[u][v] - 1 << "\n";
    }
}
/*

*/


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

 #define   ll      long long 
 #define   pb      push_back
 #define   mp      make_pair

 typedef vector<int> vi;
 typedef vector<ll> vl;
 typedef pair<int,int> pii;
 typedef map<int,int> mii;

 int main()
 {
      ios_base::sync_with_stdio(false);
      cin.tie(NULL);

      ll t;
      t=1;
      //cin>>t;

      while(t--)
      {
         
         string s;
         cin>>s;
          
          int n=s.length();
          cout<<s;
         if(s[n-1]=='s')
         {
         	cout<<'e';
         	cout<<'s'<<endl;
         }
         else
         	cout<<'s'<<endl;


      }

      return 0;
 }




Measured memory_bytes: 3660
Imports System

Class Sample
  Shared Sub Main()
    ' 以下の2つはどちらも同じ動作・同じ結果となる

    ' Consoleクラスのメソッドを使って標準入力から読み込む
    Dim line1 As String = Console.ReadLine()
    If line1 = "25" Then
      Console.Write("Christmas") 
    End If
    If line1 = "24" Then
      Console.Write("Christmas Eve") 
    End If
    If line1 = "23" Then
      Console.Write("Christmas Eve Eve") 
    End If
    If line1 = "22" Then
      Console.Write("Christmas Eve Eve Eve") 
    End If
  End Sub
End Class

Measured memory_bytes: 19792
#include <iostream>
#include <algorithm>
#include <string>
#include <cmath>

using namespace std;
typedef long long ll;

#define INF (long long)(10e9+7)
#define REP(i,n) for(ll i = 0; i < n; i++)

int main(void)
{
    string s;
    cin >> s;
    cout << s[0] << (s.length()-2) << s[s.length()-1] << endl;
}


Measured memory_bytes: 256
import sys
INFTY=sys.maxsize

def readinput():
    n=int(input())
    return n

def main(n):
    dp=[INFTY]*(n+1)
    dp[0]=0
    dp[1]=1
    for i in range(2,n+1):
        dp[i]=min(dp[i],dp[i-1]+1)  # 1円
        k=1
        while(i-6**k>=0):
            dp[i]=min(dp[i],dp[i-6**k]+1)
            k+=1
        k=1
        while(i-9**k>=0):
            dp[i]=min(dp[i],dp[i-9**k]+1)
            k+=1
    return dp[n]

if __name__=='__main__':
    n=readinput()
    ans=main(n)
    print(ans)


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

int main() {
  string S,T;
  cin >> S >> T;
  int a = S.size();
  char b = T.at(a);
  if(T == S + b) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}


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



namespace CSharpSample01
{

    
    
    class Program
    {

        static List<string> h_posi;
        const int MOD = 1000000007;
        static int[] h_posi_case;
        static int[] stay_case;

        
        static void H_Posi(int W, bool left, int w, string str)
        {
            
            if(w >= W)
            {
                h_posi.Add(str);
                return;
            }

            if (!left) H_Posi(W, true, w + 1, str + "1");
            H_Posi(W, false, w + 1, str + "0");
        }

        static long DP(int H, int W, int K)
        {
            long[,] dp = new long[H + 2, W + 1];

            dp[0, 1] = 1;
            
            
            for(int h = 0; h <= H - 1; h++)
            {
                for(int w = 1; w <= W; w++)
                {
                    dp[h + 1, w] += dp[h, w] * stay_case[w] % MOD;
                    dp[h + 1, w] %= MOD;
                    if (w - 1 >= 1)
                    {
                        dp[h + 1, w - 1] += (dp[h, w] * h_posi_case[w - 1]) % MOD;
                        dp[h + 1, w - 1] %= MOD;
                    }
                    if (w + 1 <= W)
                    {
                        dp[h + 1, w + 1] += (dp[h, w] * h_posi_case[w]) % MOD;
                        dp[h + 1, w + 1] %= MOD;
                    }

                }
            }

            
            return dp[H, K];
        }

        static void Get_h_case(int W)
        {
            foreach(string str in h_posi)
            {
                for(int j = 0; j <= W - 2; j++)
                {                
                    if (str[j] == '1') h_posi_case[j + 1]++;
                }
            }
            
        }

        static void Get_stay_case(int W)
        {
            foreach(string str in h_posi)
            {
                for(int j = 0; j <= W - 1; j++)
                {
                    if(j == 0)
                    {
                        if(str[j] == '0') stay_case[j + 1]++;
                    }
                    else if(j == W - 1)
                    {
                        if(str[j - 1] == '0') stay_case[j + 1]++;
                    }
                    else
                    {
                        if(str[j - 1] == '0' && str[j] == '0')
                        {
                            stay_case[j + 1]++;
                        }
                    }
                }
            }

        }
        
        
        static void Main(string[] args)
        {
            string[] input = Console.ReadLine().Split(' ');
            int H = int.Parse(input[0]);
            int W = int.Parse(input[1]);
            int K = int.Parse(input[2]);

            h_posi = new List<string>();
            h_posi_case = new int[W];
            stay_case = new int[W + 1];

            H_Posi(W, true, 2, "1");  
            H_Posi(W, false, 2, "0");  

            Get_h_case(W);
            Get_stay_case(W);

            Console.WriteLine(DP(H, W, K));

            
        }
    }
}

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

int main()
{
    vector<int> v(6);
    for (int i=0; i<6; i++){
        cin >> v.at(i);
    }
    sort(v.begin(),v.end());
    
    if (v.at(0) == 1 && v.at(1) == 2 && v.at(2) == 2 && v.at(3) == 3 && v.at(4) == 3 && v.at(5) == 4 )
        cout << "YES";
    else if (v.at(0) == 1 && v.at(1) == 1 && v.at(2) == 2 && v.at(3) == 3 && v.at(4) == 3 && v.at(5) ==  4)
        cout << "YES";
    else if (v.at(0) == 1 && v.at(1) == 1 && v.at(2) == 2 && v.at(3) == 2 && v.at(4) == 3 && v.at(5) ==  4 )
        cout << "YES";
    else if (v.at(0) == 1 && v.at(1) == 2 && v.at(2) == 3 && v.at(3) == 3 && v.at(4) ==4  && v.at(5) ==  4)
        cout << "YES";
    else if (v.at(0) == 1 && v.at(1) == 2 && v.at(2) == 2 && v.at(3) == 3 && v.at(4) == 4 && v.at(5) == 4  )
        cout << "YES";
    else if (v.at(0) == 1 && v.at(1) ==1  && v.at(2) ==  2&& v.at(3) == 3 && v.at(4) == 4 && v.at(5) == 4  )
        cout << "YES";
    else
        cout << "NO";
}


Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
#include<algorithm>
using namespace std;

int a[100005];

int main(){
    int n;
    long long s = 0;
    cin >> n;

    a[0] = 0; a[n+1] = 0;
    for(int i=1; i<n+1; ++i) {scanf("%d", &a[i]); s += abs(a[i] - a[i-1]);};
    s += abs(a[n]);

    for(int i=1; i<n+1; ++i){
        if((a[i] - a[i-1] >= 0 && a[i+1] - a[i] >= 0) || (a[i] - a[i-1] < 0 && a[i+1] - a[i] < 0)){
            cout << s << endl;
        }else{
            if(abs(a[i-1] - a[i]) >= abs(a[i+1] - a[i])){
                cout << s - 2*abs(a[i+1] - a[i]) << endl;
            }else{
                cout << s - 2*abs(a[i-1] - a[i]) << endl;
            }
        }
    }
}



Measured memory_bytes: 1664
#include<iostream>
#include<set>
#include<string>
#include<cassert>
 
struct Meirei{
    std::string mei;
    std::string str;
};
/*

struct Node{
	Node(){
		umu=false;
		a=NULL;
		c=NULL;
		g=NULL;
		t=NULL;
	}
	~Node(){
		if(a)delete a;
		if(c)delete c;
		if(g)delete g;
		if(t)delete t;
//		std::cout << "a::" << a << ",g::" << g << ",c::" << c << ",t::" << t << std::endl;
	}
	bool umu;
	Node* a,*c,*g,*t;//?????°???????????°????????????????????????????????§?????????????????°????????????
};
class Tree
{
public:
	Tree(){
		m_root=new Node();
	}
	~Tree(){
		delete m_root;
	}
	void insert(std::string moji);
	bool find(std::string moji);
	
private:
	Node* m_root;
};

void Tree::insert(std::string moji)
{
//	m_root=new Node();
	Node* node = m_root;
	for(int i =0; i < moji.size(); i++){
		if(moji[i]=='A'){
			if(node->a == NULL)	node->a = new Node();
			node = node->a;
		}else if(moji[i]=='C'){
			if(node->c == NULL)	node->c = new Node();
			node = node->c;
		}else if(moji[i]=='G'){
			if(node->g == NULL) node->g = new Node();
			node = node->g;
		}else if(moji[i]=='T'){
			if(node->t == NULL)	node->t = new Node();
			node = node->t;
		}else {
			assert(true);
		}
	}
	node->umu=true;
}
//---------------------------------
bool Tree::find(std::string moji)
{
	Node* node = m_root;
	for(int i =0; i < moji.size(); i++){
		if(moji[i]=='A'){
			if(node->a == NULL)	return false;
			node = node->a;
		}else if(moji[i]=='C'){
			if(node->c == NULL)	return false;
			node = node->c;
		}else if(moji[i]=='G'){
			if(node->g == NULL)	return false;
			node = node->g;
		}else if(moji[i]=='T'){
			if(node->t == NULL)	return false;
			node = node->t;
		}else {
			assert(true);
		}
	}
	if(node->umu)return true;
	return false;
}
*/
//typedef std::vector<MEIREI> VecMeirei;
//typedef std::vector<std::string> WORDS;
//typedef std::vector<bool> ARINASHI;
//void input();
//bool find(WORDS jisho, std::string str);
void output(bool result);
//-------------------------------------------------------------------
int main()
{
    long n;
    std::cin >> n;
    std::set<std::string> st;
	for(int i=0; i<n; i++){
		std::string meirei;
	    std::cin >> meirei;
		std::string moji;
		std::cin >> moji;
		if(meirei=="insert"){
		    st.insert(moji);
	    }else if(meirei=="find"){
	     	output(st.find(moji)!=st.end());
	    }
	}
    return 0;
}
//-------------------------------------------------------------------
void output(bool result)
{
    if(result){
        std::cout << "yes" << std::endl;
    }else{
        std::cout << "no" << std::endl;
    }
    return;
}
//-------------------------------------------------------------------

Measured memory_bytes: 32140
#include<stdio.h>
long long gcd(long long x,long long y)
{
    return x%y==0?y:gcd(y,x%y);
}
int main()
{
    int n,i;
    long long s,sum=1,x;
    scanf("%d",&n);
    for(i=0;i<n;i++)
    {
        scanf("%lld",&x);
        s=gcd(sum,x);
        sum=sum/s*x;
    }
    printf("%lld\n",sum);
    return 0;
}


Measured memory_bytes: 128
package main

import (
	"bufio"
	"os"
	"strconv"
	"math"
	"fmt"
)

var sc = bufio.NewScanner(os.Stdin)

func init() {
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 1024*1024), bufio.MaxScanTokenSize)
}

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func main() {
	a := nextInt()
	b := nextInt()
	h := nextInt()
	m := nextInt()

	var rad float64 = 2 * math.Pi * (math.Abs( (float64(h) + (float64(m)) / 60)) / 12 - float64(m) / 60)

	if rad > math.Pi {
		rad = 2 * math.Pi - rad
	}

	var ans float64 = math.Sqrt(float64(a * a + b * b) - float64(2 * a * b) * math.Cos(rad))

	fmt.Printf("%.15f\n", ans)
}


Measured memory_bytes: 1788
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        double n = sc.nextDouble();
        int r = (int)n - (int)Math.floor(n / 108 * 8);
        if(n == Math.floor(r * 1.08)){
            System.out.println(r);
        }else{
            System.out.println(":(");
        }
    }
}

Measured memory_bytes: 24020