akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
//#define int long long

using namespace std;
using LL = long long;
using P = pair<int, int>;

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

#define pb(a) push_back(a)
#define all(x) (x).begin(),(x).end()

const int INF = (int)1e9;
const LL INFL = (LL)1e15;
const int MOD = 1e9 + 7;

int dy[]={0, 0, 1, -1, 0};
int dx[]={1, -1, 0, 0, 0};

/*************** using variables **************/
int n, m;
vector<int> p, x, y;
/**********************************************/

template <typename T>
class UnionFind {
    private:
        vector<int> parent;  // 親
        vector<int> rank;    // 木の深さ

        // 重み付きUnionFindでのみ利用
        vector<T> diffWeight; // 親ノードとの値の差
    public:
        UnionFind(int n);          // n要素で初期化
        int Find(int x);           // 木の根を返す
        void Unite(int x, int y);  // xとyの属する集合を併合
        bool Same(int x, int y);   // xとyが同じ集合に属するか否か

        // 重み付きUnionFindでのみ利用
        void Unite(int x, int y, T w);
        T Weight(int x);      // xの重みを返す
        T Diff(int x, int y); // xとyの差を返す
};

    template <typename T>
UnionFind<T>::UnionFind(int n) : parent(n), rank(n), diffWeight(n, 0)
{
    for (int i = 0; i < n; i++) {
        parent[i] = i;
        rank[i] = 0;
    }
}

template <typename T>
int UnionFind<T>::Find(int x) {
    if (parent[x] == x) {
        return x;
    } else {
        int r = Find(parent[x]);
        diffWeight[x] += diffWeight[parent[x]];
        return parent[x] = r;
    }
}

template <typename T>
void UnionFind<T>::Unite(int x, int y) {
    x = Find(x);
    y = Find(y);
    if (x == y) return;

    if (rank[x] < rank[y]) {
        parent[x] = y;
    } else {
        parent[y] = x;
        if (rank[x] == rank[y]) rank[x]++;
    }
}

template <typename T>
bool UnionFind<T>::Same(int x, int y) { return Find(x) == Find(y); }

template <typename T>
void UnionFind<T>::Unite(int x, int y, T w){
    w += Weight(x); w -= Weight(y);
    x = Find(x); y = Find(y);
    if(x == y) return;

    if(rank[x] < rank[y]) swap(x, y), w = -w;

    if(rank[x] == rank[y]) rank[x]++;
    parent[y] = x;

    diffWeight[y] = w;
}

template <typename T>
T UnionFind<T>::Weight(int x){
    Find(x);
    return diffWeight[x];
}

template <typename T>
T UnionFind<T>::Diff(int x, int y){
    return Weight(y) - Weight(x);
}

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    cin >> n >> m;
    p.resize(n);
    x.resize(m);
    y.resize(m);
    REP(i, n){ cin >> p[i]; p[i]--;}
    REP(i, m){ cin >> x[i] >> y[i]; x[i]--, y[i]--;}
    
    UnionFind<int> uf(n);
    REP(i, m){
        uf.Unite(x[i], y[i]);
    }
    
    int ans = 0;
    REP(i, n){
        if(uf.Same(p[i], i)) ans++;
    }
    cout << ans << endl;

}


Measured memory_bytes: 2560
#include <stdio.h>

int main() {
	long N,ans;
	scanf("%ld",&N);
	ans = N + 1 - 2;
	for (long i = 1; i*i <= N; i++) {
		long double tmp = (long double)N/(long double)i;
		if (tmp == (long int)tmp) {
			long val = tmp + i - 2;
			if (val < ans) {
				ans = val;
			}
		}
	}
	printf("%ld\n",ans);
	return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<algorithm>
#include<bitset>
#include<vector>
#include<deque>
#include<queue>
#include<map>
#include<set>
#include<stack>
#include<cmath>
#include<iomanip>
#include <functional>
using namespace std;
typedef long long ll;
const int mod = 1000000007;
const int INF = 1 << 28;
const double EPS = 1e-10;
//cout << fixed << std::setprecision(9)
//memset(a, 0, sizeof(a));
//--------------------------

int n;
int a[100005];
int f[100005];

int main()
{
	cin >> n;
	for (int i = 1; i <= n; i++) {
		cin >> a[i];
	}

	int ans = 0;

	for (int i = 1; i <= n; i++) {
		if (i == a[a[i]]) {
			ans++;
		}
	}

	cout << ans/2 << endl;

	return 0;
}


Measured memory_bytes: 640
import sys

import numpy as np

input = sys.stdin.readline


def main():
    H, W, K = map(int, input().split())
    s = np.zeros(shape=(H, W), dtype=np.bool)
    for i in range(H):
        s[i] = tuple(map(lambda x: True if x == "#" else False, input().rstrip()))

    ans = np.zeros(shape=(H, W), dtype=np.int64)
    h_keep = 0
    k = 1
    for h in range(H):
        if s[h].sum() > 0:
            indices = np.where(s[h])[0]
            ans[h_keep:h + 1] = k
            k += 1
            for idx in reversed(indices[:-1]):
                ans[h_keep:h + 1, :idx + 1] = k
                k += 1
            h_keep = h + 1
        else:
            h_keep = min(h_keep, h)

    if h_keep < H:
        h_base = h_keep - 1
        for h in range(h_keep, H):
            ans[h] = ans[h_base]

    for h in range(H):
        print(" ".join(map(str, ans[h])))


if __name__ == "__main__":
    main()


Measured memory_bytes: 27796
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    int d;
    cin>>d;
    if(d==25){
        cout<<"Christmas"<<endl;
    }
    
    else if(d==24){
        cout<<"Christmas Eve"<<endl;
    }
    
    else if(d==23){
        cout<<"Christmas Eve Eve"<<endl;
    }
    
    else if(d==22){
        cout<<"Christmas Eve Eve Eve"<<endl;
    }
}

Measured memory_bytes: 256
N = int(input())
A = [-1] + [int(a) for a in input().split()]
B = [-1] + [int(b) for b in input().split()]

count = 0
for n in range(1, N+1):
    if B[n] >= A[n]:
        count += A[n]
        B[n] -= A[n]
        A[n] = 0
        if B[n] >= A[n+1]:
            count += A[n+1]
            B[n] -= A[n+1]
            A[n+1] = 0
        else:
            count += B[n]
            A[n+1] -= B[n]
    else:
        count += B[n]

print(count)


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

int main() {
    int k,x;
    string ans="No";

    cin>>k>>x;

    if (500*k>=x) {
        ans="Yes";
    }

    cout<<ans<<endl;
}


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

int main() {
	int n;
	cin>>n;
	vector<int>a(n);
	vector<int>b(n);
	vector<int>c(n);
	for(int i = 0 ; i < n ; i++) cin>>a[i]>>b[i]>>c[i];
	vector<vector<int>>dp(n,vector<int>(3));
	dp[0][0] = a[0];
	dp[0][1] = b[0];
	dp[0][2] = c[0];
	for(int i = 1 ; i < n ; i++){
	    dp[i][0] = max(dp[i-1][1],dp[i-1][2]) + a[i];
	    dp[i][1] = max(dp[i-1][0],dp[i-1][2]) + b[i];
	    dp[i][2] = max(dp[i-1][1],dp[i-1][0]) + c[i];
	}
	cout<<max(dp[n-1][0],max(dp[n-1][1],dp[n-1][2]))<<endl;
	return 0;
}


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

int main() {
  int n, s;
  cin>>n>>s;
  int a[n];
  for (int i=0; i<n; i++) cin>>a[i];
  long long mod = 998244353;
  long long dp[s+1];
  for (int i=0; i<=s; i++) dp[i] = 0;
  dp[0] = 2;
  if (a[0] <= s) {
    dp[a[0]] = 1;
  }
  for (int i=1; i<n; i++) {
    for (int j=s; j>=0; j--) {
      dp[j] = dp[j] * 2;
      dp[j] %= mod;
      if (j - a[i] >= 0) {
        dp[j] += dp[j-a[i]];
        dp[j] %= mod;
      }
    }
  }
  cout<<dp[s]<<endl;
}

Measured memory_bytes: 3624
#include<stdio.h>
#include<stdlib.h>
#include<string.h>

int main(){
	int sum=0,i,slen;
	char input[1002],c[2];
	
	while(1){
		fgets(input,sizeof input,stdin);
		
		slen=strlen(input);
		
		for(i=0;i<slen;i++){
			c[0]=input[i];
			sum+=atoi(c);
			
		}
		
		if(sum==0){
			break;
		}
		printf("%d\n",sum);
		sum=0;
	}
	
	return 0;
}

Measured memory_bytes: 528
#include<stdio.h>
int main(void){
    int n;
    long long int a[10001],i,m=1000000,M=-1000000,S=0;
    scanf("%d",&n);
       for(i=0;i<n;i++){
        scanf("%lld",&a[i]);
        if (a[i]<=m){m=a[i];}
        if (a[i]>=M){M=a[i];}
        S=S+a[i];
    }
    printf("%lld %lld %lld\n",m,M,S);
    return 0;
}

Measured memory_bytes: 680
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define REP(i,m,n) for(int i=(int)(m); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define rrep(i,n) RREP(i,n-1,0)
#define all(v) v.begin(), v.end()
const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;

map<ll, int> res;
void prime_factorization(ll N) {
  if(N == 1 || N == 0) return;
  ll n = N;
  ll i = 2;
  while(n >= i * i) {
    while(n % i == 0) {
      if(res.count(i)) res[i]++;
      else res[i] = 1;
      n /= i;
    }
    if(i == 2) i++;
    else i += 2;
  }
  if(n != 1) res[n] = 1;
}
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll N, P;
  cin >> N >> P;
  prime_factorization(P);
  ll ans = 1;
  for(auto d: res) {
    ans *= (ll)pow(d.first, d.second/N);
  }
  cout << ans << "\n";
  return 0;
}


Measured memory_bytes: 4072
import java.util.Scanner;

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

        int a, b, c;
        int divisor;
        int count = 0;

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

        for(divisor = a; divisor <= b; divisor++) {
            if(c % divisor == 0)
                count++;
        }
        System.out.println(count);
    }
}



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


class WeightedUnionFind:
    def __init__(self, n):
        self.par = [i for i in range(n+1)]
        self.rank = [0] * (n+1)
        self.weight = [0] * (n+1)

    # 検索
    def find(self, x):
        if self.par[x] == x:
            return x
        else:
            y = self.find(self.par[x])
            self.weight[x] += self.weight[self.par[x]]
            self.par[x] = y
            return y

    # 重さの検索
    def weighting(self, x):
        self.find(x)
        return self.weight[x]

    # 併合
    def union(self, x, y, w):
        px = self.find(x)
        py = self.find(y)
        if px != py:
            if self.rank[px] < self.rank[py]:
                self.par[px] = py
                self.weight[px] = w - self.weight[x] + self.weight[y]
            else:
                self.par[py] = px
                self.weight[py] = -w - self.weight[y] + self.weight[x]
                if self.rank[px] == self.rank[py]:
                    self.rank[px] += 1

    # 同じ集合に属するか
    def same(self, x, y):
        return self.find(x) == self.find(y)

    # 各頂点間の絶対距離
    def diff(self, x, y):
        return self.weight[x] - self.weight[y]

wuf = WeightedUnionFind(N)
for l, r, d in LRD:
    if wuf.same(l, r):
        if wuf.diff(l, r) != d:
            print("No")
            break
    else:
        wuf.union(l, r, d)
else:
    print("Yes")

Measured memory_bytes: 58444
import java.util.*;

class Main {
    public static void main(String args[]) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int shiftNum = 0;
        for (int i=0; i<N; i++) {
            shiftNum |= sc.nextInt();
        }

        int count = 0;
        while ((shiftNum & 1) == 0) {
            shiftNum = shiftNum >> 1;
            count++;
        }
        System.out.println(count);
    }
}


Measured memory_bytes: 23764
n = gets.chomp.to_i
v = gets.chomp.split(' ').map(&:to_i)
c = gets.chomp.split(' ').map(&:to_i)
sum = 0
for i in 0...n do
  sum += (v[i]-c[i]) if ((v[i]-c[i]) > 0)
end

puts sum

Measured memory_bytes: 1788
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin>>n;
  int count=0;
  for(int i=1;i<=n;i++){
    string s;
    s=to_string(i);
    if(s.length()%2!=0)count++;
  }
  cout<<count;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <algorithm>
#include <climits>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <iostream>
#include <math.h>
using namespace __gnu_pbds;
using namespace std;
#define ll long long
#define str string
#define deb_arr(arr,n) for(ll i=0;i<(n);i++){ cout << (arr)[i] << " ";}
#define in_arr0(arr,n) for(ll i=0;i<(n);i++){ cin >> (arr)[i]; }
#define in_arr1(arr,n) for(ll i=1;i<=(n);i++){ cin >> (arr)[i];}
typedef tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update> pbds;
#define vll vector<ll> 
#define fr(n) for(i=0;i<(n);i++)
#define fr1(n) for(i=1;i<=(n);i++)
#define pll pair<ll,ll>
#define f first
#define s second
#define vpll vector<pll>
#define ump unordered_map
#define YES cout << "YES" << endl
#define NO cout << "NO" << endl
#define Yes cout << "Yes" << endl
#define No cout << "No" << endl
#define yes cout << "yes" << endl
#define no cout << "no" << endl
#define debb(x) cout << (x) << endl
#define IN(a,b) ((a).find(b)!=(a).end())
#define pb push_back
#define mkp make_pair
#define PI M_PI
#define INF 1e18
#define deb(x) if(ON) cout << #x <<" : " << x << endl
#define fast ios_base::sync_with_stdio(false)
#define io cin.tie(NULL),cout.tie(NULL)
#define ON !false
ll dx[]={0,-1,0,1};
ll dy[]={1,0,-1,0};
const ll mod=1e9+7;
inline ll add(ll a,ll b){
    return  ((a%mod)+(b%mod)+mod)%mod;
}
inline ll mul(ll a,ll b){
    return ((a%mod)*(b%mod)+mod)%mod;
}
void pause(ll id){
    cout << "Waiting " << id << endl;
    cin >> id;
}

const int mxn=2e5+10;

ll arr[mxn];
ll pre[mxn];

void init(){

    return ;
}


signed main(){
    fast;
    io;
    if(!true){
        freopen("in.txt","r",stdin);
        freopen("out.txt","w",stdout);
    }
    init();
    ll i,j;
    // iota(itf,its) ;
    // n=unique(a+1,a+1+n,n)-(a+1);

    ll n;
    cin >> n;
    for(i=1;i<=n;i++){
    	cin >> arr[i];
    }
    for(i=n;i>=1;i--){
    	pre[i]=arr[i];
    	pre[i]=add(pre[i],pre[i+1]);
    	pre[i]%=mod;
    }
    ll ans=0;
    for(i=1;i<=n;i++){
    	 ll temp=0;
    	 temp=mul(arr[i],pre[i+1]);
    	 ans=add(ans,temp);
    }

    debb(ans);
    return 0;
}


Measured memory_bytes: 6708
#include<bits/stdc++.h>
using namespace std;
#define ll long long 
#define pb push_back 
#define fr first
#define sc second
#define Rep(i,n) for(int i=0;i<(n);i++)
#define All(v) v.begin(),v.end()
#define Uniq(v) v.erase(unique(All(v)),v.end())
typedef pair<int, int> Pii; 
typedef pair<int, Pii> Pip;
typedef pair<string, int> Psi;
const int INF = (1<<30);
const int dx[]={1,0,-1,0}, dy[]={0,-1,0,1};

int main()
{
  ll data[3];
  Rep(i, 3) cin >> data[i];
  sort(data, data+3, greater<ll>());
  cout << ((data[0]-data[0]/2) * data[1] * data[2]) - (data[0]/2 * data[1] * data[2]) << endl;
}

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

int main(){
  int n;
  while(cin>>n){
    int a[n];
    for(int i=0;i<n;i++){
      cin>>a[i];
    }
    long long max=-10000000,min=10000000,sum=0;
    for(int j=0;j<n;j++){
      if(max<a[j])
	max=a[j];
      if(min>a[j])
	min=a[j];
      sum=sum+a[j];
    }
    cout<<min<<" "<<max<<" "<<sum<<endl;
  }
  return 0;
}



Measured memory_bytes: 3112
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))

ans = 0
for i in range(n):
  ans += b[a[i]-1]
  if i != n-1 and a[i+1] == a[i]+1:
    ans += c[a[i]-1]

print(ans)

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

using namespace std;

int main() {
    int t;
    cin >> t;
    int h = t / 3600;
    t -= h*3600;
    int m = t / 60;
    t -= m*60;
    int s = t;
    cout << h << ":" << m << ":" << s << endl;
}


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

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int N;
  string S;
  cin >> N >> S;
  vector<int> left(10, 0), right(10, 0);
  left[S[0] - '0']++;
  for (int i = 2; i < N; i++) {
    right[S[i] - '0']++;
  }
  vector<int> cnts(1000, 0);
  for (int i = 1; i < N - 1; i++) {
    int b = S[i] - '0';
    for (int a = 0; a < 10; a++) {
      for (int c = 0; c < 10; c++) {
        if (left[a] == 0 || right[c] == 0) continue;
        cnts[100 * a + 10 * b + c]++;
      }
    }
    left[S[i] - '0']++;
    right[S[i + 1] - '0']--;
  }
  int res = 0;
  for (int i = 0; i < 1000; i++) {
    if (cnts[i] != 0) res++;
  }
  cout << res << '\n';
  return 0;
}


Measured memory_bytes: 384
N = int(input())
SP = []
for i in range(N):
    s, p = [s for s in input().split()]
    p = int(p)
    SP.append((s, p, i + 1))

SP.sort(key=lambda x: x[1], reverse=True)
SP.sort(key=lambda x: x[0])
for sp in SP:
    print(sp[2])


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

#define f first
#define s second
#define pb push_back
#define mp make_pair
#define all(v) v.begin(), v.end()
#define sz(v) (int)v.size()

#define MOO(i, a, b) for(int i=a; i<b; i++)
#define M00(i, a) for(int i=0; i<a; i++)
#define MOOd(i,a,b) for(int i = (b)-1; i >= a; i--)
#define M00d(i,a) for(int i = (a)-1; i>=0; i--)

#define FAST ios::sync_with_stdio(0); cin.tie(0);
#define finish(x) return cout << x << '\n', 0;
#define dbg(x) cerr << ">>> " << #x << " = " << x << "\n";
#define _ << " _ " <<

template<class T> bool ckmin(T& a, const T& b) {return b < a ? a = b, 1 : 0;}
template<class T> bool ckmax(T& a, const T& b) {return a < b ? a = b, 1 : 0;}

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int,int> pi;
typedef pair<ld,ld> pd;
typedef complex<ld> cd;

struct tnode {
    char val;
    int freqs[26];
    tnode* ch[26];
    tnode(char c) {
        val = c;
        M00(i, 26) {
            freqs[i] = 0;
            ch[i] = nullptr;
        }
    }
};

tnode* root = new tnode(' ');
const int MAX_N = 200010;
int n;
string arr[MAX_N];

int ins(string& s) {
    int res = 0;
    vi ctr(26, 0);
    M00(i, sz(s)) ctr[s[i]-'a']++;
    tnode* cur = root;
    M00(i, 26) cur->freqs[i] += (ctr[i] > 0);
    M00d(i, sz(s)) {
        int idx = s[i] - 'a';
        if(cur->ch[idx] == nullptr) {
            cur->ch[idx] = new tnode(s[i]);
        }
        if(i == 0) {
            res = cur->freqs[idx]-1;
        }
        cur = cur->ch[idx];
        ctr[idx]--;
        M00(j, 26) cur->freqs[j] += (ctr[j] > 0);
    }
    assert(res >= 0);
    return res;
}

int main() { FAST
    cin >> n;
    M00(i, n) cin >> arr[i];
    sort(arr, arr+n, [&](const string& s1, const string& s2) { return sz(s1) < sz(s2); });
    ll ans = 0;
    M00d(i, n) {
        int x = ins(arr[i]);
        //dbg(i _ arr[i] _ x);
        ans += x;
    }
    finish(ans);
}



Measured memory_bytes: 338404
#include <algorithm>
#include <iterator>
#include <iostream>
#include <sstream>
#include <bitset>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <list>
#include <map>
#include <set>
#include <time.h>
#include <limits>
#include <math.h>
#include <climits>
#include <numeric>
#include <utility>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <assert.h>
#include <functional>


using namespace std;
const double pi=acos(-1.0);
#define boost  ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define endl '\n'
#define sl(n) scanf("%lld",&n)
#define mp make_pair
#define pb push_back
#define ppb pop_back
#define fi first
#define se second
#define ll long long
#define ull unsigned long long
#define pii pair<ll, ll>
#define f(i,a,b) for(ll i = (ll)(a); i < (ll)(b); i++)
#define rf(i,a,b) for(ll i = (ll)(a); i > (ll)(b); i--)
#define ms(a,b) memset((a),(b),sizeof(a))
#define max(a,b) ((a>b)?(a):(b))
#define min(a,b) ((a<b)?(a):(b))
#define vec(g1) int temp;cin>>temp;g1,push_back(temp);
#define abs(x) ((x<0)?(-(x)):(x))
#define MAX 1000005
#define inf LLONG_MAX
#define MIN INT_MIN
//typedef
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<PII> VII;
typedef vector<VI> VVI;
typedef map<int,int> MPII;
typedef set<int> SETI;
typedef multiset<int> MSETI;
typedef long int int32;
typedef unsigned long int uint32;
typedef long long int int64;
typedef unsigned long long int  uint64;

int mod = 1e9 + 7 ;
ll gcd(ll a , ll b){return b==0?a:gcd(b,a%b);}
ll powmod(ll a,ll b) {ll res=1;if(a>=mod)a%=mod;for(;b;b>>=1){if(b&1)res=res*a;if(res>=mod)res%=mod;a=a*a;if(a>=mod)a%=mod;}return res;}
// ll fac[200005];
// ll inverse(ll n){return powmod(n, mod-2);}
// ll nCr(ll n, ll r){return (fac[n] * inverse(fac[r]) % mod * inverse(fac[n-r]) % mod) % mod;}

/**.................................................................................................................................*/
int main(){
	boost;
    int n;
    cin>>n;
    int a[n];
    f(i,0,n)cin>>a[i];
    int ans=0;
    for(int i=1;i<n-1;i++){
    	 if(a[i-1]>a[i]&& a[i]>a[i+1])ans++;
    	 else if(a[i+1]>a[i] && a[i-1]<a[i])ans++;
    
    }
    cout<<ans<<endl;
   	return 0;
}


Measured memory_bytes: 256
// AOJ Volume 1 Problem 0188 Search

#include <stdio.h>

int main(void)
{
    int d[100];
    int n;
    int value;
    int step;
    int i;
    int right, left;
    
    while (1){
        scanf("%d", &n);
        if (n == 0){
            break;
        }
        
        for (i = 0; i < n; i++){
            scanf("%d", &d[i]);
        }
        scanf("%d", &value);

        step = 0;
        right = n - 1;
        left = 0;
        do {
            step++;

            if (d[(right + left) / 2] < value){
                left = (right + left) / 2 + 1;
            }
            else if (d[(right + left) / 2] > value){
                right = (right + left) / 2 - 1;
            }
            else {
                break;
            }
            
        } while (right >= left);
        
        printf("%d\n", step);
    }
    
    return (0);
}

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

#define DB	double
#define lf	else if
#define	I64	long long
#define Rd()	(rand() << 15 | rand())
#define For(i,a,b)	for(int i=a;i<=b;i++)
#define Rep(i,a,b)	for(int i=a;i>=b;i--)
	
#define fi	first
#define se	second
#define MK	make_pair
#define PA	pair<int, int>

#define CH	(ch=getchar())
int		IN()	{
		int x= 0, f= 0, ch;
		for (; CH < '0' || ch > '9';)	f= (ch == '-');
		for (; ch >= '0' && ch <= '9'; CH)	(x*= 10)+= ch - '0';
		return	f ? -x : x;
}

#define n	100005

int		N, X[n], Y[n], t[n];

int		main()	{
		N= IN();
		For(i, 1, N)	t[i]= IN(), X[i]= IN(), Y[i]= IN();
		
		For(i, 1, N)	{
			if	(abs(X[i] - X[i-1]) + abs(Y[i] - Y[i-1]) > t[i] - t[i-1] || (t[i] - t[i-1] - abs(X[i] - X[i-1]) + abs(Y[i] - Y[i-1])) % 2)	return	puts("No"), 0;
		}
		
		puts("Yes");
}


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


using namespace std;
typedef long long ll;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
// const ll INF = 1LL <<60;
const int INF = 10000;

//最大公約数
ll gcd(ll x, ll y) {
  ll tmp = 0;
  if (x < y){
    tmp=x;
    x=y;
    y=tmp;
  }
  while (y > 0) {
    ll r = x % y;
    x = y;
    y = r;
  }
  return x;
}

//最大公倍数
ll lcm(ll x,ll y){
  return x/gcd(x,y)*y;
}

const int MAX = 510000;
const int MOD = 1000000007;

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

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}


//階乗
ll kaijo(ll k){
    ll sum = 1;
    for (ll i = 1; i <= k; ++i)
    {
        sum *= i;
        sum%=1000000000+7;
    }
    return sum;
}

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

ll lmax(ll s,ll t){
  if(s>t){
    return s;
  }
  else{
    return t;
  }
}

ll lmin(ll s,ll t){
  if(s<t){
    return s;
  }
  else{
    return t;
  }
}
// ここから開始

int main(){
  int n,m;
  cin>>n>>m;
  vector<int> a,d;
  for(int i = 0; i < n; i++){
    int x;
    cin>>x;
    a.push_back(x);
  } 
  sort(a.begin(),a.end());
  reverse(a.begin(),a.end());
  vector<pair<int,int> > v;
  for(int i = 0;i < m; i++){
    int b,c;
    cin>>b>>c;
    v.push_back(make_pair(c,b));
  }
  sort(v.begin(),v.end());
  reverse(v.begin(),v.end());
  int counter=0;
  for(int i = 0; i < m; i++){
    for(int j = 0; j < v[i].second; j++){
      if(counter>n){
        break;
        break;
      } 
      else{
        d.push_back(v[i].first);
        // cout<<d[counter]<<" ";
      }
      counter++;
    }
  }
  // cout<<endl;
  counter = 0;
  int a_flag = 0;
  int d_flag = 0;
  ll ans = 0;
  while(counter<n){
    if(a[a_flag]<d[d_flag]&&d_flag<d.size()){
      // cout<<d[d_flag]<<" ";
      ans+=d[d_flag];
      d_flag++;
      
    }
    else{
      // cout<<a[a_flag]<<" ";
      ans+=a[a_flag];
      a_flag++;
    }
    counter++;
  }
  cout<<ans<<endl;
  return 0;
}



Measured memory_bytes: 2292
#include <iostream>
#include <cstdio>
#include <vector>
#include <map>
#include <algorithm>
#include <set>
using namespace std;

#define int long long

int N;

long calcNumOfCombination(int n, int r){
    if (n<2) return 0;
    
    long num = 1;
    for(int i = 1; i <= r; i++){
        num = num * (n - i + 1) / i;
    }
    return num;
}


signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin>>N;
    vector<int> balls;
    // std:multiset<int> ms;
    std::map<int, int> dict;
    for(int i=0; i<N; ++i){
        int h;
        std::cin>>h;
        balls.push_back(h);
        dict[h]++;
    }


    std::map<int, int> memo;
    // cout<<"====="<<endl;

    int base_res = 0;

    for(int i=0; i<N; ++i){
        int c = dict[i];
        memo[c] = calcNumOfCombination(c, 2);
    }

    for(int i=0; i<N+1; ++i){
        base_res += memo[dict[i]];
    }


    for (int i=0; i<N; ++i) {
        int c = dict[balls[i]];
        int diff = memo[c] - calcNumOfCombination(c-1, 2);
        cout<<base_res - diff<<endl;
    }

    return 0;


}

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

#define watch(x) cerr << (#x) << ": " << (x) << endl
#define int long long



int32_t main() {

    int n, m; cin >> n >> m;
    if(n >= m) {
        cout << 0 << endl;
        return 0;
    }
    vector<int> x(m);
    for(int i = 0; i < m; ++i) cin >> x[i];
    sort(x.begin(), x.end());
    vector<int> diffs(m-1);
    for(int i = 1; i < m; ++i) {
        diffs[i-1] = x[i] - x[i-1];
    }
    sort(diffs.begin(), diffs.end());

    int ret = 0;
    for(int i = 0; i < m-n; ++i) {
        ret += diffs[i];
    }
    cout << ret << endl;
    
    return 0;
}


Measured memory_bytes: 1792
#include<stdio.h>
int main ()
{
    int x,i,j,flag;
    scanf("%d", &x);
    for(i=x; i<x+100; i++){
        flag=0;
        for(j=2; j<=i/2; j++){
            if(i%j==0)
            {flag=1;
             break;}
    }
    if(flag==0){break;}
    }
    printf("%d", i);}


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

#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define debug(x) cerr << #x << ": " << x << ", "
#define debugln(x) cerr << #x << ": " << x << '\n'

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

using namespace std;
using ll = long long;
using P = pair<ll, ll>;

//constexpr ll mod = 998244353;
constexpr ll mod = 1e9+7;
const double PI = acos(-1.0);
mt19937_64 engine(chrono::steady_clock::now().time_since_epoch().count());

std::vector<int> par;
std::vector<int> rak; // number of the vertices

void init(int n) {
  par.resize(n+1);
  rak.resize(n+1, 1);
  for(int i=1; i<=n; i++) {
    par[i] = i;
  }
}

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

void unite(int x, int y) {
  x = find(x);
  y = find(y);
  if (x==y) return;
  if (rak[x] < rak[y]) {
    rak[y] += rak[x];
    par[x] = y;
  } else {
    rak[x] += rak[y];
    par[y] = x;
  }
}

bool same(int x, int y) {
  return find(x) == find(y);
}

signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);

  int n, m; cin >> n >> m;
  init(n);
  rep(i, m) {
    int x, y, z; cin >> x >> y >> z;
    unite(x, y);
  }

  int ans = 0;
  for(int i=1; i<=n; i++) {
    if (find(i)==i) ans++;
  }

  cout << ans << endl;
}

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

int main(){
  int n,ans=0,f=1;cin>>n;
  vector<int> a(n,0);
  REP(i,n) cin>>a.at(i);
  REP(i,n){
    if(a.at(i)==f){
      f++;
    }else{
      ans++;
    }
  }
  if(f==1) ans=-1;
  cout<<ans;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define rep(i, n) for(int (i)=0 ;i <(n); ++(i))
#define REP(i,m,n) for(int (i) = (m); (i) <= (n); ++(i))
#define yorn(f) puts((f)?"Yes":"No")
#define YORN(f) puts((f)? "YES":"NO")
typedef long long ll;
using namespace std;

int main() {
  string s;
  cin >> s;
  cout << s[0] + to_string(s.size() - 2) + s[s.size()-1] << endl;
  
  return 0;
}

Measured memory_bytes: 256
data = input().split()
A = int(data[0])
B = int(data[1])
S = input()
s1 = S[:A]
s2 = S[A:A+1]
s3= S[len(S)-B:]
if s1.isdigit() == True:
    if s2 == "-":
        if s3.isdigit() == True:
            print("Yes")
        else : 
            print("No")
    else:
        print("No")
else :
    print("No")

Measured memory_bytes: 3064
n = gets.to_i

ans = 0
count = 0

(1..n).each do |i|
	if i.odd?
		(1..i).each do |j|
		if (i % j) == 0
			count += 1
			end
		end
	end
	if count == 8
		ans += 1
	end
	count = 0
end
puts ans

Measured memory_bytes: 1788
/*
 *
 *	Author: r3gz3n
 *	Description: 
 *	Difficulty: 
 *
 */

#include <bits/stdc++.h>

#define ll long long
#define ull unsigned long long
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define be begin()
#define en end()
#define all(x) (x).begin(),(x).end()
#define alli(a, n, k) (a+k),(a+n+k)
#define REP(i, a, b, k) for(__typeof(a) i = a;i < b;i += k)
#define REPI(i, a, b, k) for(__typeof(a) i = a;i > b;i -= k)
#define REPITER(it, a) for(__typeof(a.begin()) it = a.begin();it != a.end(); ++it)

#define y0 sdkfaslhagaklsldk
#define y1 aasdfasdfasdf
#define yn askfhwqriuperikldjk
#define j1 assdgsdgasghsf
#define tm sdfjahlfasfh
#define lr asgasgash
#define norm asdfasdgasdgsd
#define have adsgagshdshfhds

#define eps 1e-6
#define pi 3.141592653589793

using namespace std;

template<class T> inline T gcd(T x, T y) { if (!y) return x; return gcd(y, x%y); }
template<class T> inline T mod(T x) { if(x < 0) return -x; else return x; }

typedef vector<int> VII;
typedef vector<ll> VLL;
typedef pair<int, int> PII;
typedef vector< pair<int, int> > VPII;
typedef vector< pair<int, PII > > VPPI;

const int MOD = 1e9 + 7;
const int INF = 1e9;
const int MAX = 1e2 + 5;
VPII adj[MAX];
int A[MAX][MAX];
int dist[MAX];
int par[MAX];

void dijstra(int x)
{
	priority_queue <PII, VPII, greater<PII> > pq;
	int y, z, to, dis;
	PII p;
	pq.push(mp(0, x)); 
	dist[x] = 0;
	while(!pq.empty())
	{
		p = pq.top();
		pq.pop();
		y = p.se;
		z = p.fi;
		REP(i, 0, adj[y].size(), 1)
		{
			to = adj[y][i].fi;
			dis = adj[y][i].se;
			if(dis + z < dist[to])
			{
				dist[to] = dis+z;
				par[to] = y;
				pq.push(mp(dist[to], to));
			}
		}

	}
}


int main(int argc, char* argv[])
{
	if(argc == 2 or argc == 3) freopen(argv[1], "r", stdin);
	if(argc == 3) freopen(argv[2], "w", stdout);
	ios::sync_with_stdio(false);
	int n, m, x, y, c;
	cin >> n >> m;
	REP(i, 0, MAX, 1)
		REP(j, 0, MAX, 1)
			A[i][j] = -1;
	REP(i, 0, m, 1)
	{
		cin >> x >> y >> c;
		adj[x].pb(mp(y, c));
		adj[y].pb(mp(x, c));
		A[x][y] = c;
		A[y][x] = c;
	}
	REP(i, 1, n+1, 1)
	{
		REP(j, 1, n+1, 1)
			dist[j] = INF;
		dijstra(i);
		REP(j, 1, n+1, 1)
		{
			A[par[j]][j] = 0;
			A[j][par[j]] = 0;
		}
	}
	int ans = 0;
	REP(i, 1, n+1, 1)
	{
		REP(j, 1, n+1, 1)
		{
			if(A[i][j] > 0) ans++;
		}
	}
	cout << (ans / 2) << endl;
	return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <vector>
using namespace std;
//
struct BIT{
	//
	int n;
	vector<long long> dat;
	//
	BIT(int n_){
		init(n_);
	}
	//
	void init(int n_){
		n=n_;
		dat=vector<long long>(n+1,0);
	}
	//
	void add(int k,int a){
		k++;
		while(k<=n){
			dat[k]+=a;
			k+=k&-k;
		}
	}
	//[0,k]
	long long query(int k){
		k++;
		long long res=0;
		while(k){
			res+=dat[k];
			k-=k&-k;
		}
		return res;
	}
	//
};
//
int main(){
	int N,Q;
	cin>>N>>Q;
	BIT bit(N);
	while(Q--){
		int C;
		cin>>C;
		if(C==1){
			int X,Y;
			cin>>X>>Y;
			X--;Y--;
			cout<<bit.query(Y)-bit.query(X-1)<<endl;
		}else{
			int K,A;
			cin>>K>>A;
			K--;
			bit.add(K,A);
		}
	}
	return 0;
}


Measured memory_bytes: 4468
def solve(w,h,row,col):
    check_map = [[False for i in range(w)] for j in range(h)]
    search_list = [[0, 0, 1]]
    check_map[0][0] = True
    ok = False
    while len(search_list) > 0:
        x, y, step = search_list.pop(0)
        if x == w-1 and y == h-1:
            return step
            ok = True
            break
        # 左
        if x > 0:
            if row[y][x-1] == "0" and not check_map[y][x-1]:
                search_list.append([x-1, y, step+1])
                check_map[y][x-1] = True
        # 右
        if x < w-1:
            if row[y][x] == "0" and not check_map[y][x+1]:
                search_list.append([x+1, y, step+1])
                check_map[y][x+1] = True
        # 上
        if y > 0:
            if col[y-1][x] == "0" and not check_map[y-1][x]:
                search_list.append([x, y-1, step+1])
                check_map[y-1][x] = True
        # 下
        if y < h-1:
            if col[y][x] == "0" and not check_map[y+1][x]:
                search_list.append([x, y+1, step+1])
                check_map[y+1][x] = True
    if not ok:
        return 0

while True:
    w, h = map(int, input().split())
    if w == 0:
        break
    row = []
    col = []
    for i in range(h-1):
        row.append(input().split())
        col.append(input().split())
    row.append(input().split())
    print(solve(w,h,row,col))


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

int n, m;
vector<vector<int> > G;
vector<int> used;
vector<int> pre;

void dijkstra(int s){
    queue<int> q;
    q.push(s);
    used[s] = 1;
    pre[s] = -1;
    while(!q.empty()){
        int u = q.front(); q.pop();
        for(int i = 0; i < G[u].size(); i++){
            int v = G[u][i];
            if(used[v] == 1) continue;
            q.push(v);
            used[s] = 1;
            pre[s] = v;
        }
    }
}

int main(){
    int n, m;
    cin >> n >> m;
    vector<vector<int> > G(n);
    vector<int> used(n);
    vector<int> pre(n, -1);
    
    rep(i,m){
        int a, b;
        cin >> a >> b;
        a--; b--;
        G[a].push_back(b);
        G[b].push_back(a);
    }

    queue<int> q;
    q.push(0);
    used[0] = 1;
    pre[0] = -1;
    while(!q.empty()){
        int u = q.front(); q.pop();
        for(int i = 0; i < G[u].size(); i++){
            int v = G[u][i];
            if(used[v] == 1) continue;
            q.push(v);
            used[v] = 1;
            pre[v] = u+1;
        }
    }

    rep(i,n){
        if(used[i] != 1){
            cout << "No" << endl;
            return 0;
        }
    }

    cout << "Yes" << endl;
    for(int i = 1; i < n; i++){
        cout << pre[i] << endl;
    }
}

Measured memory_bytes: 10588
#include<bits/stdc++.h>
#define mxn 100010
using namespace std;
const int mod=1e9+7;
int n,sl,fh,a[mxn],dp[mxn][2];
char s[mxn];
int rd()
{
	sl=0;fh=1;
	char ch=getchar();
	while(ch<'0'||'9'<ch) {if(ch=='-') fh=-1; ch=getchar();}
	while('0'<=ch&&ch<='9') sl=sl*10+ch-'0',ch=getchar();
	return sl*fh;
}
void upd(int &x,int y) {x+=y; if(x>=mod) x-=mod;}
int dfs(int pos,int flg)
{
	if(pos>n) return 1;
	if(~dp[pos][flg]) return dp[pos][flg];
	int ed=1,ret=0;if(flg) ed=a[pos];
	upd(ret,dfs(pos+1,flg&&0==ed));
	if(ed==1) ret=(ret+2ll*dfs(pos+1,flg&&1==ed))%mod;
	return dp[pos][flg]=ret;
}
int main()
{
	scanf("%s",s+1);n=strlen(s+1);
	for(int i=1;i<=n;++i) a[i]=s[i]-'0';
	memset(dp,-1,sizeof(dp));
	printf("%d\n",dfs(1,1));
	return 0;
}

Measured memory_bytes: 7808
//#include <bits/stdc++.h>
#include <iostream>
#include <fstream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <stdio.h>
#include <queue>
#include <deque>
#include <set>
#include <stack>
#include <time.h>
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef pair<int, int> Pii;
typedef pair<int, ll> Pil;
typedef pair<ll, ll> Pll;
typedef pair<ll, int> Pli;

#define fi first
#define se second

const ll MOD = 1e9 + 7;
const ll MOD2 = 998244353;
const ll MOD3 = 1812447359;
const ll INF = 1ll << 62;
const double PI = 2 * asin(1);

void yes() {printf("yes\n");}
void no() {printf("no\n");}
void Yes() {printf("Yes\n");}
void No() {printf("No\n");}
void YES() {printf("YES\n");}
void NO() {printf("NO\n");}

int N, Q;
ll X[int(1e5 + 5)], L;
int Table[40][int(1e5 + 5)];
ll Bit[40];

int main(){
  scanf("%d", &N);
  for (int i = 0; i < N; i++) scanf("%lld", X + i);
  scanf("%d", &L);

  int now = 0;
  for (int i = 0; i < N; i++){
    while (now < N - 1){
      if (X[now + 1] - X[i] > L) break;
      now++;
    }
    Table[0][i] = now;
  }

  Bit[0] = 1;
  for (int i = 1; i < 40; i++){
    Bit[i] = Bit[i-1] * 2;
    for (int j = 0; j < N; j++){
      Table[i][j] = Table[i-1][Table[i-1][j]];
    }
  }

  scanf("%d", &Q);
  while (Q > 0){
    Q--;
    int A, B; scanf("%d%d", &A, &B);
    A--; B--;
    if (A > B) swap(A, B);

    ll ans = 0; int now = A;
    while (now < B){
      if (Table[0][now] == B){
        ans++; now = B;
        break;
      }
      for (int i = 1; i < 40; i++){
        int next = Table[i][now];
        if (next >= B){
          now = Table[i-1][now];
          ans += Bit[i-1];
          break;
        }
      }
    }
    printf("%lld\n", ans);
  }

  return 0;
}


Measured memory_bytes: 20220
from sys import stdin
from collections import deque
def main():
  _map, _readline, _int = map, stdin.readline, int
  n, q = _map(_int, _readline().split())
  values = [0] * n
  links = [[] for _ in range(n)]
  for _ in range(n - 1):
    a, b = _map(_int, _readline().split())
    links[a - 1].append(b - 1)
    links[b - 1].append(a - 1)
  for _ in range(q):
    p, x = _map(_int, _readline().split())
    values[p - 1] += x
  d = deque()
  d.append((0, -1))
  while len(d) != 0:
    i, p = d.popleft()
    for j in links[i]:
      if j == p:
        continue
      values[j] += values[i]
      d.append((j, i))
  print(*values)
main()

Measured memory_bytes: 62132
s = input()
n = len(s)

sr = s.replace("x", "")

if sr != "".join(reversed(sr)):
    print(-1)
else:
    ans = 0
    l = 0
    r = -1
    while l - r < n:
        if s[l] == s[r]:
            l += 1
            r -= 1
            continue
        elif s[l] == "x" and s[r] != "x":
            ans += 1
            l += 1
        elif s[l] != "x" and s[r] == "x":
            ans += 1
            r -= 1
        
    print(ans)


Measured memory_bytes: 3956
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) FOR(i,0,n)
#define ROF(i,a,b) for(int i=a;i>=b;i--)
#define per(i,a) ROF(i,a,0)
#define pb push_back
using namespace std;
using ll=long long;
using ld=long double;
typedef pair<ll,ll> P;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<P> vP;
typedef vector<char> vc;
typedef vector<vc> vvc;
const ll MOD=1000000007;
const ll MOD2=998244353;
const ld PI=acos(-1);
const ll INF=1e18;
struct edge{ll to,cost;};
struct edge2{ll from,to,cost;};

template <typename T>
bool chmax(T &a, const T& b) {
    if (a < b) {
      a = b;
        return true;
    }
    return false;
}

template <typename T>
bool chmin(T &a, const T& b) {
    if (a > b) {
      a = b;
      return true;
    }
    return false;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    string s,t;
    cin >> s >> t;
    string x;
    rep(i,s.size()+t.size()){
        if(i%2==0){
            x+=s[i/2];
        }
        else{
            x+=t[i/2];
        }
    }
    cout << x << endl;
}
/*
overflow checked?
corner case checked?
boundary checked?
not TLE in worst case checked?
*/

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

#define rep(i,n) for(long long int (i)=0;(i)<(int)(n);(i)++)
#define rrep(i,a,b) for(long long int i=(a);i<(b);i++)
#define rrrep(i,a,b) for(long long int i=(a);i>=(b);i--)
#define all(v) (v).begin(), (v).end()
#define pb(q) push_back(q)
#define Abs(a,b) max(a,b)-min(a,b)
#define YES(condition) if(condition){cout << "YES" << endl;}else{cout << "NO" << endl;}
#define Yes(condition) if(condition){cout << "Yes" << endl;}else{cout << "No" << endl;}
#define Cout(x) cout<<(x)<<endl
#define POSSIBLE(condition) if(condition){cout << "POSSIBLE" << endl;}else{cout << "IMPOSSIBLE" << endl;}
#define Possible(condition) if(condition){cout << "Possible" << endl;}else{cout << "Impossible" << endl;}
#define possible(condition) if(condition){cout << "possible" << endl;}else{cout << "impossible" << endl;}
#define Size(n) (n).size()

typedef long long ll;


using namespace std;

const int INF = 1e9,MOD = 1e9 + 7,ohara = 1e6;
const ll LINF = 1e18;


long long int n,cnt=0,ans=0,a,b,c,d,cmp,cmpp,m,h,w,x,y,sum=0,pos;
int dy[]={1,0,-1,0};
int dx[]={0,1,0,-1};
string alph("abcdefghijklmnopqrstuvwxyz"),s;
bool fl;
struct edge{int to,cost;};

//-------------------------↓↓↓↓↓↓------------------------

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

      
      cin>>a>>b;
      rrep(i,1,4){
        pos=a*b*i;
        if(pos%2!=0){
          Cout("Yes");
          return 0;
        }
      }
     Cout("No");

       
return 0;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        int x = Integer.parseInt(br.readLine());
        System.out.println(problem174a(x));
    }

    private static String problem174a(int x) {
        return (x >= 30) ? "Yes" : "No";
    }
}

Measured memory_bytes: 25216
#include <bits/stdc++.h>
using namespace std;
bool dp[100 * 1000];
int main() {
	string st;
	cin >> st;
	set <char> S;
	for (auto i: st) {
		if (S.count(i)) {
			cout << "no";
			return 0;
		}
		S.insert(i);
	}
	cout << "yes";
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <math.h>
#include <sstream>
#include <numeric>

using namespace std;

const long long kModulo = 1000000007LL;

int main()
{
  int N;
  cin >> N;
  long long ans = 1;
  for (int i = 1; i <= N; ++i) {
    ans *= i;
    ans %= kModulo;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
l=input().split()
n=int(l[0])
W=int(l[1])
lweight=[]
lvalue=[]
for i in range(n):
	l=input().split()
	u=int(l[0])
	v=int(l[1])
	lweight.append(u)
	lvalue.append(v)
dp=[[0 for i in range(W+1)] for i in range(n+1)]
for i in range(n+1):
	dp[i][0]=0
for j in range(W+1):
	dp[0][j]=0
for i in range(1,n+1):
	for j in range(1,W+1):
		if(j>=lweight[i-1]):
			dp[i][j]=max(dp[i-1][j],dp[i-1][j-lweight[i-1]]+lvalue[i-1])
		else:
			dp[i][j]=dp[i-1][j]
print(dp[n][W])


Measured memory_bytes: 171528
#include <bits/stdc++.h>
using namespace std;
const int MOD = 1000000007;
int main(void){
    int n, k; cin>>n>>k;
    vector <vector<int>> graph(n ,vector <int>( ));
    //cout<<n-1<<endl;
    for(int i=0;i<n-1;i++){
        int a,b; cin>>a>>b;
        a--; b--;
        graph[a].push_back(b);
        graph[b].push_back(a);
    }
    //それぞれの頂点の次数について調べていくよ!
    vector <int> order(n);
    queue <int> q;
    q.push(0);
    vector <bool>  done(n) ;
    done[0] = true;
    while(!q.empty()){
        int now = q.front(); q.pop();
        int cnt = 0;
        for(int i=0;i<graph[now].size();i++){
            if(done[graph[now][i]]) continue;
            cnt++;
            q.push(graph[now][i]);
            done[graph[now][i]] = true;
        }
        order[now] = cnt;
    }
    /*for(int i=0;i<n;i++){
        cout<<order[i]<<endl;
    }*/
    long long ans = k;
    int cone0 = order[0];
    //cout<<cone0<<'*'<<endl;
    for(int i=0;i<cone0;i++){
        ans*= k-1-i;
        ans %= MOD;
    }
    for(int i=1;i<n;i++){
        int cone = order[i];
        for(int j=0;j<cone;j++){
        ans*= k-2-j;
        ans %= MOD;
        }
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 6904
#include <bits/stdc++.h>
#define fin freopen("input", "r", stdin)
#define fout freopen("output", "w", stdout)
#define wt(x) cerr << #x << ": " << x << " ";
#define whatis(x) cerr << #x << ": " << x << endl;
#define whatis2(x, y) wt(x); wt(y); cout << endl;
#define whatis3(x, y, z) wt(x); wt(y); wt(z); cout << endl;
#define whatis4(x, y, z, a) wt(x); wt(y); wt(z); wt(a); cout << endl;
using namespace std;

typedef long long ll; typedef unsigned long long ull; typedef long double ld;
const ll MOD = 1000000007; const ld PI = acos(-1.0);

template <typename T> inline T bigMod(T A,T B,T M = MOD){A %= M;T ret = 1;while(B){if(B & 1) ret = (ret * A) % M;A = (A * A) % M;B = B >> 1;}return ret;}
template <typename T> inline T invMod (T A,T M = MOD){return bigMod(A,M-2,M);}

int gcd (int a, int b) { if (b == 0) return a; return gcd (b, a%b); }
int ar[300][300];

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

    int n = 210;
    for (int i = 0; i < n; ++i) {
        for (int j = 0; j < n; ++j) {
            ar[i][j] = gcd(i, j);
        }
    }

    cin >> n;
    ll sum = 0;
    for (int i = 1; i <= n; ++i) {
        for (int j = 1; j <= n; ++j) {
            for (int k = 1; k <= n; ++k) {
                sum += ar[ar[i][j]][k];
            }
        }
    }


    cout << sum << endl;
    


    return 0;
}


Measured memory_bytes: 3880
#include<cstdio>
#include<cstring>
#include<algorithm>
#include <numeric>
using namespace std;

int main()
{	
	long long int N, c;
	long long int ka, kb, kc;
	ka=0;
	scanf("%lld", &N);
	
	for(long long int a=1;a<=3500;a++){
		for(long long int b=1;b<=3500;b++){
			if(4*a*b-N*a-N*b>0){
			if( (N*a*b)%(4*a*b-N*a-N*b) ==0){
				ka=a; kb=b; kc=(N*a*b) /(4*a*b-N*a-N*b);
			}
			}
		}
	}
	printf("%lld %lld %lld", ka, kb, kc);

}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES

#include <iostream>
#include <iomanip>
#include <stdio.h>

#include <sstream>
#include <algorithm>
#include <iterator>
#include <cmath>
#include <complex>

#include <string>
#include <cstring>
#include <vector>
#include <bitset>

#include <queue>
#include <set>
#include <map>
#include <stack>
#include <list>

#include <ctime>
////
//#include <random>//
/////////

typedef long long LL;
typedef long double LD;
typedef unsigned long long ULL;

////定数
const int INF = (int)1e9 + 10;
const LL MOD = (LL)1e9 + 7;
const LL LINF = (LL)4e18 + 20;
const LD PI = acos(-1.0);
const double EPS = 1e-9; 
/////////
using namespace::std;
template<typename T>
void chmax(T& a, T b) {
	a = max(a, b);
}

template<typename T>
void chmin(T& a, T b) {
	a = min(a, b);
}

template<typename T>
void IN(vector<T> &A,int N=-1) {
	if (N == -1) {
		N = A.size();
	}
	for (int i = 0; i < N; ++i) {
		cin >> A[i];
	}
}

template<typename T>
void SO(vector<T> &A,bool F=false) {
	sort(A.begin(), A.end());
	if (F) {
		reverse(A.begin(), A.end());
	}
}
//////////////

void solve() {
	int A, B;
	cin >> A >> B;
	if (B % A == 0) {
		cout << A + B << endl;
	}
	else {
		cout << B - A << endl;
	}
}

signed main(void) {
	std::cin.tie(0);
	std::ios::sync_with_stdio(false);
	std::cout << std::fixed;//小数を10進数表示
	cout << setprecision(16);//小数点以下の桁数を指定//coutとcerrで別	

	solve();
}


Measured memory_bytes: 256