akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using vl = vector<ll>;
template<class T> using vc = vector<T>;
template<class T> using vvc = vector<vector<T>>;

#define eb emplace_back
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define repr(i, n) for (ll i = (n)-1; i >= 0; i--)
#define repe(i, l, r) for (ll i = (l); i < (r); i++)
#define reper(i, l, r) for (ll i = (r)-1; i >= (l); i--)
#define repa(i,n) for (auto& i: n)

template<class T> inline bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> inline bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
void init() {cin.tie(0);ios::sync_with_stdio(false);cout << fixed << setprecision(15);}

#ifdef DEBUG
template <class T, class N> void verr(const T& a, const N& n) { rep(i, n) cerr << a[i] << " "; cerr << "\n" << flush; }
ll dbgt = 1; void err() { cerr << "passed " << dbgt++ << "\n" << flush; }
template<class H, class... T> void err(H&& h,T&&... t){ cerr<< h << (sizeof...(t)?" ":"\n") << flush; if(sizeof...(t)>0) err(forward<T>(t)...); }
#endif

const ll INF = 4e18;
const ld EPS = 1e-11;
const ld PI = acos(-1.0L);
const ll MOD = 1e9 + 7;
// const ll MOD = 998244353;
//--------------------------------------------------------------------------------//
ll modpow(ll a, ll n, ll mod) {
    ll res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
int main() {
    init();
    ll N,K;
    cin >> N >> K;
    cout << modpow(K, N, MOD) << endl;
}


Measured memory_bytes: 3216
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
template<class T> using V = vector<T>;
template<class T, class U> using P = pair<T, U>;
using vll = V<ll>;
using vvll = V<vll>;
#define rep(i, k, n) for (ll i=k; i<(ll)n; ++i)
#define REP(i, n) rep(i, 0, n)

const ll MOD = (ll)1e9 + 7;
const ll HIGHINF = (ll)1e18;

int main() {
  ll n; cin >> n;
  vvll nodes(n, vll());
  REP(i, n-1) {
    ll a, b; cin >> a >> b;
    nodes.at(a-1).push_back(b-1);
    nodes.at(b-1).push_back(a-1);
  }
  vll c(n);
  REP(i, n) cin >> c.at(i);
  sort(c.begin(), c.end(), greater<ll>());
  ll leaf = -1;
  REP(i, n) if (nodes.at(i).size() == 1) {leaf = i; break;}
  queue<ll> que; que.push(leaf);
  vll scores(n, -1);
  ll ci = 0;
  while (!que.empty()) {
    ll nod = que.front(); que.pop();
    if (scores.at(nod) == -1) {
      scores.at(nod) = c.at(ci++);
      REP(i, nodes.at(nod).size()) {
        if (scores.at(nodes.at(nod).at(i)) == -1) que.push(nodes.at(nod).at(i));
      }
    }
  }
  ll ans = 0;
  rep(i, 1, n) ans += c.at(i);
  cout << ans << endl;
  REP(i, n) {
    cout << scores.at(i);
    if (i != n-1) cout << ' ';
  }
  cout << endl;
  return 0;
}


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

int main(){
    string a,b,c;
    cin >> a >> b >> c;
    
    a+='0';
    b+='0';
    c+='0';
    
    char i = 'a';
    char d = '0';
    
    while(i!='0'){
        if(i == 'a'){
            i = a[0];
            a.erase(a.begin());
            d = 'A';
        }
        if(i == 'b'){
            i = b[0];
            b.erase(b.begin());
            d = 'B';
        }
        if(i == 'c'){
            i = c[0];
            c.erase(c.begin());
            d = 'C';
        }
    }
    cout << d << endl;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
int main(){
  ll n,m,ans=0;
  cin>>n>>m;
  if (n<m) {
    vll x(m);
    for (ll i=0;i<m;i++) cin >> x[i];
    sort(x.begin(),x.end());
    vll dif(m-1);
    for (ll i=0;i<m-1;i++) dif[i]=x[i+1]-x[i];
    sort(dif.begin(),dif.end());
    for (ll i=0;i<m-n;i++) ans += dif[i];
  }
  cout << ans;
}

Measured memory_bytes: 1792
# パナソニックプログラミングコンテスト2020: B – Bishop
H, W = [int(i) for i in input().split()]

can_reach = 0
if H == 1 or W == 1:
    can_reach = 1
elif (H % 2 == 0 and W % 2 == 0) or (H % 2 == 0 and W % 2 == 1):
    can_reach = W * (H // 2)
elif H % 2 == 1 and W % 2 == 0:
    can_reach = W * (H // 2) + W // 2
else:
    can_reach = W * (H // 2) + W // 2 + 1

print(can_reach)

Measured memory_bytes: 9184
S = str(input())
l = ["A", "C", "G", "T"]
ans = 0
for i in range(len(S)):
    cnt = 0
    for j in range(i, len(S)):
        if S[j] in l:
            cnt += 1
        else:
            break
    if ans < cnt:
        ans = cnt
print(ans)


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

using namespace std;

typedef long long ll;

const ll INF = 1LL << 60;
const ll MOD = 1000000007LL;


ll mod_pow(ll m, ll n, ll mod) {
    if (n == 0) {
        return 1;
    }

    ll rv = mod_pow(m * m % mod, n/2, mod);

    if (n % 2) {
        return (rv * m) % mod;
    } else {
        return rv;
    }
}


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

    ll N;
    ll C;
    cin >> N >> C;

    vector<ll> A;
    vector<ll> B;

    A.resize(N+1);
    B.resize(N+1);

    for (ll i = 1; i <= N; ++i) {
        cin >> A[i];
    }
    for (ll i = 1; i <= N; ++i) {
        cin >> B[i];
    }


    vector< vector<ll> > T;
    T.resize(401);
    // T[i][j] == mod_pow(i, j, MOD)

    for (ll i = 0; i < 401; ++i) {
        T[i].resize(401);

        T[i][0] = 1;

        for (ll j = 1; j < 401; ++j) {
            T[i][j] = mod_pow(i, j, MOD);
        }
    }


    vector< vector<ll> > U;
    U.resize(N+1);

    for (ll i = 0; i <= N; ++i) {
        U[i].resize(C+1);

        for (ll j = 0; j <= C; ++j) {
            U[i][j] = 0;

            for (ll x = A[i]; x <= B[i]; ++x) {
                U[i][j] = (U[i][j] + T[x][j]) % MOD;
            }
        }
    }


    //for (ll i = 0; i <= N; ++i) {
    //    for (ll j = 0; j <= C; ++j) {
    //        cout << U[i][j] << " ";
    //    }
    //    cout << endl;
    //}
    //cout << endl;


    vector< vector<ll> > dp; // N, C
    dp.resize(N+1);
    for (ll i = 0; i <= N; ++i) {
        dp[i].resize(C+1);
    }

    dp[0][0] = 1;
    for (ll j = 1; j <= C; ++j) {
        dp[0][j] = 0;
    }

    for (ll i = 1; i <= N; ++i) {
        for (ll j = 0; j <= C; ++j) {
            dp[i][j] = 0;

            for (ll k = 0; k <= j; ++k) {
                dp[i][j] = (dp[i][j] + dp[i-1][j-k] * U[i][k]) % MOD;
            }
        }
    }


    //for (ll i = 0; i <= N; ++i) {
    //    for (ll j = 0; j <= C; ++j) {
    //        cout << dp[i][j] << " ";
    //    }
    //    cout << endl;
    //}


    cout << dp[N][C] << endl;

    return 0;
}


Measured memory_bytes: 4096
//
//  main.cpp
//  Study
//
//  Created by 佐々木勇星 on 2020/03/12.
//  Copyright © 2020 佐々木勇星. All rights reserved.
//

#include <iostream>
#include <vector>
#include <cmath>
#include <sstream>
#include <iomanip>
#include <algorithm>

using namespace std;


int main(int argc, const char * argv[]) {
    

    int n, m, sum = 0,  b = 0;
    int rec = 0;
    string ans = "No";
    cin >> n >> m;
    
    int a[n];
    
    for(int i=0; i<n; i++)
    {
        cin >> a[i];
        sum += a[i];
    }
    
    rec = (sum + 4 * m - 1) / (4 * m);
    
    for(int i=0; i<n; i++)
    {
        if(rec <= a[i]) b++;
    }
    
    if(b >= m) ans = "Yes";
//    cout << rec << endl;
//    cout << b << endl;
    cout << ans << endl;
    
    
    
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, a, n) for (int i = (int)(a); i <= (int)(n); ++i)
#define rrep(i, a, n) for (int i = (int)(a); i >= (int)(n); --i)
#define debug(x) cerr << #x << " = " << x << "\n"
#define debugv(x) \
  rep(f, 0, (x.size() - 1)) cerr << x[f] << (f == (x.size() - 1) ? "\n" : " ")
#define debug2(x, y)                       \
  cerr << "(" << #x << "," << #y << ") = " \
       << "(" << x << "," << y << ")\n"
#define all(x) x.begin(), x.end()
#define each(a, x) for (auto& a : (x))
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define int long long
using namespace std;
using pii = pair<int, int>;
using vi = vector<int>;
const int MX = 1e5 + 5, INF = 5LL << 57, MOD = 1e9 + 7;

int N, M;
string S, T, U;
vi va, vb;

void input() {
  cin >> S >> T;
  cin >> N >> M;
  cin >> U;
  ;
  ;
}
void solve() {
  ;
  ;
  if (S == U) {
    cout << N - 1 << " " << M << endl;
  } else {
    cout << N << " " << M - 1 << endl;
  }
}
signed main() {
  input();
  solve();
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int Nmax = 100;
const ll INF=1e16;
int N;
ll W, Ws[Nmax], Vs[Nmax];
ll dp[Nmax+1][Nmax+1][4*Nmax];

int main(){
	cin >> N >> W;
	for(int i=0; i<N; i++) cin >> Ws[i] >> Vs[i];

	for(int i=0; i<=N; i++){
		for(int k=0; k<=N; k++){
			for(int w=0; w<4*N; w++){
				dp[i][k][w] = -INF;
			}
		}
	}
	dp[0][0][0] = 0;

	for(int i=0; i<N; i++){
		for(int k=0; k<=N; k++){
			for(int w=0; w<4*N; w++){
				dp[i+1][k][w] = dp[i][k][w];
				if(w>0) dp[i+1][k][w] = max(dp[i+1][k][w-1], dp[i+1][k][w]);
				if(k>0&&w-(Ws[i]-Ws[0])>=0){
					dp[i+1][k][w] = max(dp[i+1][k][w], dp[i][k-1][w-(Ws[i]-Ws[0])]+Vs[i]);
				}
				//cout << i << " " << k << " " << w << " " << dp[i+1][k][w] << endl;
			}
		}
	}

	ll ans = 0;
	for(int k=0; k<=N; k++){
		//cout << min(4ll*N, max(0ll, W-k*Ws[0])) << endl;
		if(W-k*Ws[0]>=0) ans = max(ans, dp[N][k][min(4ll*N-1, W-k*Ws[0])]);
	}
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 32128
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1LL<<62
#define inf 1000000007

ll a[52],b[52];
map<pair<ll,ll>,ll>c;
int main() {
	ll n;
	cin>>n;
	for(int i=0;i<n;i++){
		ll x,y;
		cin>>x>>y;
		a[i]=x;b[i]=y;
	}
	for(int i=0;i<n;i++){
		ll nowx=a[i],nowy=b[i];
		for(int j=0;j<n;j++){
			if(i==j){
				continue;
			}
			ll nex=a[j],ney=b[j];
			c[make_pair(nowx-nex,nowy-ney)]++;
		}
	}
	ll ans=0;
    for(auto itr = c.begin(); itr != c.end(); ++itr) {
        ll val =itr->second ;
        ans=max(ans,val);
    }
    cout<< n-ans;
	// your code goes here
	return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define int long long

int32_t main() {
  int n;
  cin >> n;
  vector<int> x(n);
  vector<int> y(n);
  for (int i = 0; i < n; i++) {
    cin >> x[i] >> y[i];
  }
  double a = 2.0/n;
  double res = 0;
  for (int i = 0; i < n; i++) {
    for (int j = i + 1; j < n; j++) {
      double d1 = x[i] - x[j];
      double d2 = y[i] - y[j];
      double dist = pow(d1*d1 + d2*d2, 0.5);
      res += a * dist;
    }
  }
  cout << fixed << setprecision(10);
  cout << res;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>

#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define int long long int
#define mod 1000000007
#define inf 1e18+42
#define endl "\n"
#define pi 3.1415926535897932384626433832795028841971693993751058
#define maxn 100005

#define out1(a) cout<<#a<<" "<<a<<endl
#define out2(a,b) cout<<#a<<" "<<a<<" "<<#b<<" "<<b<<endl
#define out3(a,b,c) cout<<#a<<" "<<a<<" "<<#b<<" "<<b<<" "<<#c<<" "<<c<<endl

#define rep(i,a,b) for(int i=a;i<b;i++)
#define repr(i,a,b) for(int i=a;i>=b;i--)
#define fori(it,A) for(auto it=A.begin();it!=A.end();it++)

#define ft first
#define sd second
#define pb push_back
#define mp make_pair
#define pq priority_queue
#define all(x) (x).begin(),(x).end()
#define zero(x) memset(x,0,sizeof(x));
#define ceil(a,b) (a+b-1)/b
 
using namespace std;

int binpow(int a, int b) {
    int res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a;
        a = a * a;
        b >>= 1;
    }
    return res;
}

//START OF CODE ->->->->->->->

void solve()
{
    string s;
    cin>>s;
    string t;
    cin>>t;
    int cnt = 0;
    rep(i,0,s.length()){
        if ( s[i] != t[i] ){
            cnt++;
        }
    }
    cout<<cnt<<endl;
}

//END OF CODE ->->->->->->->->

signed main()
{
    fast;
    int t = 1;
    // cin>>t;

    while(t--)
    {
        solve();
    }
    return 0;
}



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

int main(){
    int n,tmp=0,i=0;
    cin >> n;
    bool ok=false;
    while(true){
        tmp=i*4;
        while(true){
            if(tmp==n)ok=true;
            tmp+=7;
            if(tmp>100)break;
        if(ok)break;
        }
        i++;
        if(i==26)break;
    }
    if(ok)cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

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

int main() {
	ll n,cnt=0;
	cin>>n;
	ll arr[n];
	for(ll i=0;i<n;i++)
	{
		cin>>arr[i];
		if(arr[i]!=i+1)
		++cnt;
	}
	if(cnt==2 || cnt==0)
	cout<<"YES";
	else
	cout<<"NO";
	return 0;
}

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

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

int main() {
  int X, Y;
  cin >> X >> Y;
  for(int i=0; i<X; i++) cin >> board[i];

  for(int i=0; i<X; i++){
    for(int j=0; j<Y; j++){
      int count = 0;
      if(board[i][j] == '.'){
        for(int k=0; k<8; k++){
          int x = i + dx[k];
          int y = j + dy[k];
          if(x >= 0 && x < X && y >= 0 && y < Y){
            if(board[x][y] == '#') count++;
          }
        }
        board[i][j] = '0' + count;
      }
    }
  }

  for(int i=0; i<X; i++) cout << board[i] << endl;
  
  return 0;
}


Measured memory_bytes: 256
#![allow(unused_imports)]
use std::cmp::*;
use std::collections::*;
use itertools::Itertools;
use proconio::{input, marker::*};
use superslice::*;
fn main() {
    input! {
        n: usize
    }
    let n1 = n%10;
    let n2 = (n/10)%10;
    let n3 = (n/100);
    if n1==7 || n2==7 ||n3==7 {
        println!("Yes");
    } else {println!("No")};
}


Measured memory_bytes: 2124
import java.util.*;

class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int[] a = new int[N];
        for(int i=0;i<N;i++) a[i]=sc.nextInt();
        int[] rec = new int[9];
        for(int i=0;i<N;i++){
            if(a[i]>=3200) rec[8]++;
            else rec[a[i]/400]++;
        }
        int ans1 = 0;
        for(int i=0;i<=7;i++){
            if(rec[i]>0) ans1++;
        }
        int ans2 = ans1+rec[8];
        System.out.print(Math.max(1,ans1));
        System.out.print(" ");
        System.out.print(ans2);
    }
}
 

Measured memory_bytes: 21844
#include<iostream>
#include<cstring>
#include<cstdio>
#include<algorithm>
using namespace std;
int n,len,sumv,maxv;
int main(){
	scanf("%d",&n);
	while(n--){
		scanf("%d",&len);
		maxv=max(maxv,len);
		sumv+=len;
	}
	if(sumv>2*maxv)puts("Yes");
	else puts("No");
	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <cassert>
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;

int main()
{
	int n, m; cin>>n>>m;
  ll a[100001]; int b[100001];
  int ind[100001];
  for(int i=0; i<n; i++){
    cin>>a[i]>>b[i]; ind[i]=i;
  }
  ll ans=0;
  sort(ind, ind+n, [&](int i, int j){ return a[i]<a[j];});
  for(int i=0; i<n; i++){
    int t=ind[i];
    if(b[t]>=m){
      ans+=(ll)m*a[t];
      break;
    }else{
      m-=b[t];
      ans+=(ll)b[t]*a[t];
    }
  }
  cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 1792
#include <iostream>
#include <iomanip>
typedef long long ll;
using namespace std;
const  ll INF = 1e9;
const  ll MOD = 1e9 + 7;
#define repi(i,n,init) for(ll i=init;i<(n);i++)

int main()
{
    int a,b;
    cin >> a >> b;
    cout << (b%a?b-a:a+b) << endl;
    return 0;
}

Measured memory_bytes: 256
N = int(input())
A = list(map(int,input().split()))
Sum = 0

for i in range(N-1):
  if(A[i] - A[i+1] > 0):
    Sum += A[i] - A[i+1]
    A[i+1] += A[i] - A[i+1]
 
print(Sum)

Measured memory_bytes: 32240
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
template<class T,class U> using P = pair<T,U>;
template<class T> using vec = vector<T>;
template<class T> using vvec = vector<vec<T>>;
 
int main(){
    int H, W;
    cin >> H >> W;
    vec<string> s(H);
    for(int h=0; h<H; h++) cin >> s[h];
    int num_blocks = 0;
    for(int h=0; h<H; h++) for(int w=0; w<W; w++) if(s[h][w]=='#') num_blocks++;

    queue<tuple<int, int, int>> que;
    que.push(tuple<int, int, int>(1, 0, 0));

    vec<vec<bool>> seen(H, vec<bool>(W, false));
    int move[] = {1, 0, -1, 0, 1};
    int ans = -1;
    while(!que.empty() && ans==-1){
        tuple<int, int, int> curr = que.front();
        que.pop();
        for (int dir=0; dir<4; dir++){
            tuple<int, int, int> new_pos(get<0>(curr)+1, get<1>(curr)+move[dir], get<2>(curr)+move[dir+1]);
            if (get<1>(new_pos)<0 || get<1>(new_pos)>=H || get<2>(new_pos)<0 || get<2>(new_pos)>=W) continue;
            if (s[get<1>(new_pos)][get<2>(new_pos)]=='#') continue;
            if (seen[get<1>(new_pos)][get<2>(new_pos)]==true) continue;
            if (get<1>(new_pos)==H-1 && get<2>(new_pos)==W-1) {
                ans = get<0>(new_pos);
                break;
            }
            seen[get<1>(new_pos)][get<2>(new_pos)] = true;
            que.push(new_pos);
        }
    }
    if (ans==-1) cout << -1 << endl;
    else cout << H*W - num_blocks - ans << endl;
    
}

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

using namespace std;

typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> VI;
typedef vector<VI> VVI;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const int INF = numeric_limits<int>::max() / 2;
const int NEG_INF = numeric_limits<int>::min() / 2;

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

  int e;
  while(cin >>e,e){
    int ans=1000000;
    for(int y=0;y*y<=e;y++){
      for(int z=0;z*z*z<=e-y*y;z++){
        int x=e-z*z*z-y*y;
        ans = min(ans,x+y+z);
      }
    }
    cout << ans << endl;
  }
}

Measured memory_bytes: 3132
import java.util.*;

public class Main {

	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		
		int a = scanner.nextInt();
		int b = scanner.nextInt();
		if(a==1) {a+=13;}
		if(b==1) {b+=13;}
		
		if(a==b) {
			System.out.println("Draw");
		}else if(a>b){
			System.out.println("Alice");
		}else {
			System.out.println("Bob");
		}

	}

}

Measured memory_bytes: 21716
#include <bits/stdc++.h>
using namespace std;
#define int long long

int32_t main()
{
    int n;
    cin>>n;
    double dp[n+100][n+100],p[n];
    for(int i=0; i<n; i++) cin>>p[i];
    memset(dp,0.0,sizeof(dp));
    dp[1][0] = 1-p[0];
    dp[1][1] = p[0];
    for(int i=1; i<n; i++)
    {
        for(int j=0; j<=(i+1); j++)
        {
            dp[i+1][j] += dp[i][j]*(1-p[i]);
            if(j>=1)
            dp[i+1][j] += dp[i][j-1]*p[i];
        }
    }
    double ans=0.0;
    for(int i=n/2+1; i<=n; i++)
        ans+=dp[n][i];
    cout<<fixed<<setprecision(9)<<ans<<endl;
    return 0;
}

Measured memory_bytes: 75264
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

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

    static class ABC148_a {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int A = in.nextInt();
            int B = in.nextInt();

            if ((A == 1 && B == 2) || (A == 2 && B == 1)) {
                out.println(3);
            } else if ((A == 2 && B == 3) || (A == 3 && B == 2)) {
                out.println(1);
            } else if ((A == 1 && B == 3) || (A == 3 && B == 1)) {
                out.println(2);
            }
        }

    }
}



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

int main(){
    int a,b,c,d,e,k,i;
    cin>>a;
    cin>>b;
    cin>>c;
    cin>>d;
    cin>>e;
    cin>>k;

    if(e-a>k){
        cout<<":("<<endl;
    }else{
        cout<<"Yay!"<<endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll>Vl;
typedef pair<ll,ll>PII;
typedef vector<PII>Vll;
typedef vector<pair<ll,pair<ll,ll> > >Vlll;
typedef priority_queue<ll>PQL;
typedef map<ll,ll>MP;
#define S second;
#define F first;
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end));i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define mp make_pair
#define ms(x,y) memset(x,y,sizeof(x))
#define pb push_back
#define mod 1000000009
#define MAX 100005
#define f(i,a,b) for(int i=(a);i<(b);i++)
#define rf(i,a,b) for(int i=(a);i>=b;i--)
#define sl(n) scanf("%lld",&n)
#define pl(n) printf("%lld",n)
#define vpshVar() int main()
vpshVar(){
    ll N=15;
    ll i=0;
    string str;
    cin>>str;
    ll len=str.length();
    ll cnt=0;
    while(str[i]!='\0'){
        if(str[i]=='o')cnt++;
        i++;
    }

    if((15-len)>=(8-cnt))cout<<"YES"<<endl;
    else cout<<"NO"<<endl;
return 0;
}


Measured memory_bytes: 256
#pragma comment(linker, "/stack:20000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx")

#include<bits/stdc++.h>
/*#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#include<ext/pb_ds/detail/standard_policies.hpp>*/

#define sz(s) (int)(s.size())
#define all(s) s.begin(), s.end()
#define rep(a, b, c) for(int a = b; a <= c; ++a)
#define per(a, b, c) for(int a = b; a >= c; --a)
#define _ ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

using namespace std;
//using namespace __gnu_pbds;

typedef unsigned long long ull;
typedef long long ll;
/*typedef tree<pair<int, int>, 
null_type, less<pair<int, int>>, 
rb_tree_tag, tree_order_statistics_node_update>
ordered_set;*/
//find_by_order() order_of_key()

const double eps = 1e-7;
const int mod = 1e9+7, MXN = 5e5+17;
const int dx[] = {0,0,1,-1}, dy[] = {1,-1,0,0};

template<typename T>inline bool updmin(T &a, const T &b) {return a > b ? a = b,1 : 0;}
template<typename T>inline bool updmax(T &a, const T &b) {return a < b ? a = b,1 : 0;}

int32_t main() { _
#ifdef DanQQQQQ
	freopen(".in","r",stdin);
	freopen(".out","w",stdout);
#endif
	string s; cin >> s;
	int ans = 0, p = 0, g = 0;
	rep(i,0,sz(s)-1) {
		if (g>p) ++p, ans += (s[i] == 'g');
		else ++g, ans -= (s[i] == 'p');
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 512
#include<stdio.h>
int main(void)
{
	int n,a[100],i;
	scanf("%d",&n);
	
	for(i=n;i>0;i--){
		scanf("%d",&a[i]);
	}
	for(i=1;i<=n;i++){
		printf("%d",a[i]);
		if(i!=n){
			printf(" ");
		}
		if(i==n){
			printf("\n");
		}
	}
	return 0;
	}

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

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

    int num = 0;
    bool flag = false;
    if (b / 10 == 0) {
        num = a * 10 + b;
        for (int i = 0; i < 334; i++) {
            if (i * i == num) {
                flag = true;
                break;
            }
        }
    }
    else if (b / 100 == 0) {
        num = a * 100 + b;
        for (int i = 0; i < 334; i++) {
            if (i * i == num) {
                flag = true;
                break;
            }
        }
    }
    else if (b / 1000 == 0) {
        num = a * 1000 + b;
        for (int i = 0; i < 334; i++) {
            if (i * i == num) {
                flag = true;
                break;
            }
        }
    }
    
    if (flag) {
        cout << "Yes" << endl;
    }
    else {
        cout << "No" << endl;
    }
}

Measured memory_bytes: 256
import java.util.*;

class Main{
	int a,b;

  public static void main(String[] ar){
    new Main();
  }
  public Main(){
  	Scanner sc=new Scanner(System.in);
  	String line=sc.nextLine();
    String[] elestr=line.split(" ");
  	a=Integer.parseInt(elestr[0]);
    b=Integer.parseInt(elestr[1]);	
  	int x[]=new int[3];
    x[0]=a+b; x[1]=a-b; x[2]=a*b;
    Arrays.sort(x);

    System.out.println(x[2]);
  }
}

Measured memory_bytes: 21844
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <vector>
#include <algorithm>
#include <set>
#include <queue>
#include <map>
#include <climits>
#include <complex>
#include <numeric>
using namespace std;

#define REP(i,n) for(int i=0; i<(int)(n); i++)
#define RREP(i,n) for(int i=(int)n-1; i>=0; i--)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define RFOR(i,c) for(__typeof((c).rbegin())i=(c).rbegin();i!=(c).rend();++i)
#define ALL(c) (c).begin(), (c).end()

typedef long long int ll;
typedef pair<int, int> pii;
typedef pair<int, pair<int, int> > pipii;
typedef vector<int> vi;

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

int main(void){
  int n;
  cin >> n;
  string s;
  int left = 0, right = n;
  cout << 0 << endl;
  fflush(stdout);
  cin >> s;
  if(s == "Vacant") {
    return 0;
  }
  string ls = s;
  while(1) {
    int med = (right + left) / 2;
    cout << med << endl;
    fflush(stdout);
    cin >> s;
    if(s == "Vacant") {
      return 0;
    } else {
      if((med - left) % 2) {
        if(s != ls){
          left = med;
          ls = s;
        }
        else right = med;
      } else {
        if(s != ls) right = med;
        else {
          left = med;
          ls = s;
        }
      }
    }
  }

	return 0;
}

Measured memory_bytes: 852
k,n = map(int, input().split())
l = list(map(int, input().split()))
d = []
for i in range(n):
  if i + 1 < n:
    d.append(l[i+1]-l[i])
  else:
    if 0 in l:
      d.append(k - l[i])
    else:
      d.append(k - l[i] + l[0])
sum = sum(d)
a = []
for i in range(n):
  a.append(sum - d[i])
print(min(a))

Measured memory_bytes: 26444
#include <iostream>
#include <vector>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0;i<n;i++)
// C 81
int main(){
    int n, y; cin >> n >> y;
    for (int i = 0; i <= n; ++i) {
        for (int j = 0; j <= n; ++j) {
            int c = n-i-j;
            int total = 10000*i + 5000*j + 1000* c;
            if(c == n-i-j && total==y && c >= 0){
                cout << i << ' ' << j << ' ' << c << endl;
                return 0;
            }
        }
    }
    cout << "-1 -1 -1" << endl;
    return 0;
}


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

LL A, B, C, D;
map<LL, LL> memo;
LL solve(LL N) {
    if (N == 0) return 0;
    if (N == 1) return D;
    if (memo.count(N)) return memo[N];
    LL l2 = (N/2)*2;
    LL r2 = ((N+1)/2)*2;
    LL l3 = (N/3)*3;
    LL r3 = ((N+2)/3)*3;
    LL l5 = (N/5)*5;
    LL r5 = ((N+4)/5)*5;

    LL res = 1e18;
    if (N < res/D) res = N*D;
    res = min(res, llabs(l2-N)*D + A + solve(l2/2));
    res = min(res, llabs(r2-N)*D + A + solve(r2/2));

    res = min(res, llabs(l3-N)*D + B + solve(l3/3));
    res = min(res, llabs(r3-N)*D + B + solve(r3/3));

    res = min(res, llabs(l5-N)*D + C + solve(l5/5));
    res = min(res, llabs(r5-N)*D + C + solve(r5/5));

    memo[N] = res;

    return res;
}

int main() {
    int T;
    cin >> T;
    for (int t = 0; t < T; t++) {
        memo.clear();
        LL N;
        cin >> N;
        cin >> A >> B >> C >> D;
        cout << solve(N) << "\n";
    }
}


Measured memory_bytes: 4356
#include<stdio.h>



long long solve(int x){
    int ans[] = {9, 0, 9, 0, 9, 0, 9, 0, 9, 0, 9, 0};
    long long now = -909090909090;
    now = (long long)x - now;
    int p = 11, i;
    while(now){
	ans[p] = abs(ans[p] - (now % 10));
	p--;now/=10;
    }
    char res[100];
    for(i = 0;i < 12;i++)res[i] = ans[i] + '0';
    res[12] = 0;
    sscanf(res, "%lld", &now);
    return now;
}


int main(){
    int n;
    while(scanf("%d", &n), n)
	printf("%lld\n", solve(n));
    return 0;
}

Measured memory_bytes: 604
#include<bits/stdc++.h>
using namespace std;
const int Mod=1e9+7,N=1e5+10;
#define pb push_back
#define f first
#define s second
int n,a[N][4],dp[N][4];
int main()
{
  cin>>n;
  for(int i=1;i<=n;i++) cin>>a[i][0]>>a[i][1]>>a[i][2];
  dp[1][0]=a[1][0],dp[1][1]=a[1][1],dp[1][2]=a[1][2];
  for(int i=2;i<=n;i++)
  {
    for(int j=0;j<3;j++) dp[i][j]=INT_MIN;
    for(int j=0;j<3;j++) dp[i][j]=max(dp[i-1][(j+1)%3],dp[i-1][(j+2)%3])+a[i][j];
  }
  cout<<max(dp[n][0],max(dp[n][1],dp[n][2]))<<endl;
  return 0;
}


Measured memory_bytes: 3328
let ($) f g = fun x -> g (f x)
let split_string ?(pattern="") = Str.split @@ Str.regexp pattern
let n = Scanf.sscanf (read_line ()) "%d" @@ fun n -> n
let bs = read_line () |> split_string ~pattern:" " |> List.map int_of_string

let rec loop ans = function
  | [] -> ans |> List.map string_of_int |> String.concat "\n" |> print_endline
  | bs -> 
    let bs = List.mapi (fun i v -> (i + 1, v)) bs in
    let xs = bs |> List.filter (fun (i, v) -> i = v) in
    if List.length xs = 0 then print_endline "-1"
    else
      let (idx, v) = (List.rev $ List.hd) xs in
      loop (v :: ans) (bs |> List.filter (fun (i, _) -> i <> idx) |> List.map snd)

let () = loop [] bs

Measured memory_bytes: 4448
strs = [input() for _ in range(3)]
idxs = [0,0,0]
turn = 0
while True:
    idx = idxs[turn]
    if idx >= len(strs[turn]):
        break
    card = strs[turn][idxs[turn]]
    idxs[turn] += 1
    
    if card == 'a':
        turn = 0
    elif card == 'b':
        turn = 1
    else:
        turn = 2

print(['A','B','C'][turn])

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
// type alias
typedef long long LL;
typedef pair<int,int> II;
typedef tuple<int,int,int> III;
typedef vector<int> VI;
typedef vector<string> VS;
typedef unordered_map<int,int> MAPII;
typedef unordered_set<int> SETI;
template<class T> using VV=vector<vector<T>>;
// minmax
template<class T> inline T SMIN(T& a, const T b) { return a=(a>b)?b:a; }
template<class T> inline T SMAX(T& a, const T b) { return a=(a<b)?b:a; }
// repetition
#define FORE(i,a,b) for(int i=(a);i<=(b);++i)
#define REPE(i,n)  for(int i=0;i<=(n);++i)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  for(int i=0;i<(n);++i)
#define FORR(x,arr) for(auto& x:arr)
#define SZ(a) int((a).size())
// collection
#define ALL(c) (c).begin(),(c).end()
// DP
#define MINUS(dp) memset(dp, -1, sizeof(dp))
#define ZERO(dp) memset(dp, 0, sizeof(dp))
// stdout
#define println(args...) fprintf(stdout, ##args),putchar('\n');
// debug cerr
template<class Iter> void __kumaerrc(Iter begin, Iter end) { for(; begin!=end; ++begin) { cerr<<*begin<<','; } cerr<<endl; }
void __kumaerr(istream_iterator<string> it) { (void)it; cerr<<endl; }
template<typename T, typename... Args> void __kumaerr(istream_iterator<string> it, T a, Args... args) { cerr<<*it<<"="<<a<<", ",__kumaerr(++it, args...); }
template<typename S, typename T> std::ostream& operator<<(std::ostream& _os, const std::pair<S,T>& _p) { return _os<<"{"<<_p.first<<','<<_p.second<<"}"; }
#define __KUMATRACE__ true
#ifdef __KUMATRACE__
#define dump(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); __kumaerr(_it, args); }
#define dumpc(ar) { cerr<<#ar<<": "; FORR(x,(ar)) { cerr << x << ','; } cerr << endl; }
#define dumpC(beg,end) { cerr<<"~"<<#end<<": "; __kumaerrc(beg,end); }
#else
#define dump(args...)
#define dumpc(ar)
#define dumpC(beg,end)
#endif

// $ cp-batch EntranceExamination | diff EntranceExamination.out -
// $ g++ -std=c++14 -Wall -O2 -D_GLIBCXX_DEBUG -fsanitize=address EntranceExamination.cpp && ./a.out

/*
 
 2/10/2019
 
 18:06-
 
 */

int T,X;

void solve() {
  cout<<1.0*T/X<<endl;
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout<<setprecision(12)<<fixed;
  
  cin>>T>>X;
  solve();
  
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define double long double
#define rep(i,n) for(int i=0;i<n;i++)
#define mod 1000000007 // 10^9+7
#define INF 99999999999 //10^12-1
#define dev 998244353 //tenka1
#define P pair<int,int>
#define F first
#define S second
int n,a,b;
signed main(){
    cin>>n>>a>>b;
    int ans=min(b,n*a);
    cout<<ans<<endl;
    return 0;
}




Measured memory_bytes: 256
N, H = map(int, input().split())
a, b = [], []
for i in range(N):
    _a, _b = map(int, input().split())
    a.append(_a)
    b.append(_b)
maxa = max(a)
b.sort(reverse=True)
ans = 0
tmp = 0
for i in range(N):
    if b[i] <= maxa:
        break
    ans += 1
    tmp += b[i]
    if tmp >= H:
        break
if tmp < H:
    ans += -(-(H-tmp) // maxa)

print(ans)


Measured memory_bytes: 11352
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
#define rep(i,s,e) for(int (i) = (s);(i) <= (e);(i)++)
#define all(x) x.begin(),x.end()

int main(){
  i64 N,x;
  cin >> N >> x;
  vector<i64> a(N);
  rep(i,0,N - 1) cin >> a[i];
  sort(all(a));
  int cnt = 0;
  for(int i = 0;i < N;i++){
    if(a[i] <= x){
      cnt++;
      x -= a[i];
    }
  }
  if(cnt == N){
    cout << cnt - (x != 0) << endl;
  }
  else{
    cout << cnt << endl;
  }
}


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

int main(){
	ll A;
	string b;
	cin >> A >> b;

	ll B;
	B = (b.at(0) - 48) * 100;
	B += (b.at(2) - 48) * 10;
	B += (b.at(3) - 48);
	ll ans = A * B / 100;
	cout << ans << endl;
}

Measured memory_bytes: 3608
#include <algorithm>
#include <bits/stdc++.h>
#include <cassert>
#include <functional>

typedef long long ll;
using namespace std;

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

  int N, D;
  cin >> N >> D;

  int ans = 1;
  while (2 * D * ans + (ans - 1) < N - 1) {
    ans++;
  }

  cout << ans << endl;
  //   int ans = static_cast<int>(ceil((N - 1) / (2.0 * D + 1)));

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <string>
#include <algorithm>
#include <set>
#include <bits/stdc++.h>
using namespace std;

int main(){
    int N;
    int d[100000]={};
    cin >> N;
    for(int i=0;i<N;i++){
        cin >> d[i];
    }
    sort(d, d+N);
    cout << d[N/2] - d[N/2 - 1] << endl;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
int main()
{
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
int n;
cin>>n;

int a[n][2];

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

int f=0,flag;
for(int i=0;i<n;i++)
{
  int j=i;
  flag=0;
  while(j<n && a[j][0]==a[j][1])
  {
  j++;
  flag=1;
  }
  
  if(j-i>=3)
  {
  f=1;
  break;
  }
  
  if(flag==1)
  i=j-1;
  
}

if(f==0)
cout<<"No\n";

else
cout<<"Yes\n";

return 0;
}



Measured memory_bytes: 3644
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Text;
using System.Globalization;
namespace ant
{
    class MainClass
    {
        
        public static void Main(string[] args)
        {
            new MainClass().solve();
        }

        Scanner cin;

        //1<=|s|<=100
        string s;

        void solve(){
            
            cin = new Scanner();
            s = cin.next();

            int ans = 101;
            //全探索
            for (char c = 'a'; c <= 'z';c++){
                string w = s;
                for (int i = 0; ; i++){
                    if (w == "")
                        break;
                    if (w == new string(c, w.Length)){
                        ans = Math.Min(ans, i);
                        break;
                    }

                    string tmp = "";
                    for (int j = 0; j < w.Length-1; j++){
                        if (w[j] == c || w[j+1] == c)
                            tmp += c;
                        else
                            tmp += w[j];
                    }
                    w = tmp;
                }
            }
            Console.WriteLine(ans);
        }
    }

    class Scanner{
        string[] nextBuffer;
        int BufferCnt;
        char[] cs = new char[] { ' ' };
        public Scanner(){
            nextBuffer = new string[0];
            BufferCnt = 0;
        }
        public string next()
        {
            if (BufferCnt < nextBuffer.Length)
                return nextBuffer[BufferCnt++];
            string st = Console.ReadLine();
            while (st == "")
                st = Console.ReadLine();
            nextBuffer= st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
            BufferCnt=0;
            return nextBuffer[BufferCnt++];
        }
        public int nextInt(){
            return int.Parse(next());
        }
        public long nextLong(){
            return long.Parse(next());
        }
        public double nextDouble(){
            return double.Parse(next());
        }
    }
}

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

#define ll long long

void solve(){
    int a,b;
    cin >> a >> b;
    int ans = 1;
    while(ans <= 1009){

        if (ans * 8 / 100 == a && ans * 10 / 100 == b)
            break;

        ans++;
    }
    cout << (ans <= 1009 ? ans : -1) << endl;
}

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

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

using namespace std;

int main(){
    int X; cin >> X;
    int ans;
    if( 400 <= X && X <= 599){
        ans = 8;
    }else if(600 <= X && X <= 799){
        ans = 7;
    }else if(800 <= X && X<= 999){
        ans = 6;
        
    }else if(1000 <= X && X<= 1199){
        ans = 5;
        
    }else if(1200 <= X && X<= 1399){
        ans = 4;
        
    }else if(1400 <= X && X<= 1599){
        ans = 3;
        
    }else if(1600 <= X && X<= 1799){
        ans = 2;
        
    }else if(1800 <= X && X<= 1999){
        ans = 1;
    };

    cout << ans << endl;
}

Measured memory_bytes: 3612
x = input()
a = []
check = []
for i in range(int(x)):
    a.append(int(input()) - 1)
    check.append(1)

index = 0
count = 0


while True:
    count += 1
    check[index] = 0
    index = a[index]

    if check[index] == 0:
        print(-1)
        break
    if index == 1:
        print(count)
        break


Measured memory_bytes: 7848
def gcd_two(a, b) # assume b <= a
  return a if b % a == 0
  return gcd_two(b % a, a)
end

def gcd(arr) # arr: Array of non-negative integers
  if arr.size < 2
    raise "array (#{arr}) size is less than 2."
  end
  g = arr[0]
  for i in 1..arr.size - 1 do
    g = gcd_two([g, arr[i]].min, [g, arr[i]].max)
  end
  return g
end

# debug
$debugFlag = ( ARGV[0] != nil )
p "==== DEBUG MODE ====" if $debugFlag

def pd(str)
  p str if $debugFlag
end

# input
inputs = []
lc = 0
while l = $stdin.gets do
  if false
    inputs << l.chomp.split(" ").map(&:to_s)
  else
    inputs << l.chomp.split(" ").map(&:to_i)
  end
  lc += 1
end

# input check
if $debugFlag
  p "--- INPUT (begin) ---"
  inputs.each do |l_i|
    p l_i
  end
  p "--- INPUT (end) ---"
  print "\n"
end

arr = inputs[1]

# body
if $debugFlag
  p arr
end

nn = arr.size
ls = []
rs = []
(arr.size-1).times do |i|
  if i == 0
    ls << arr[0]
    rs << arr[nn-1]
  else
    ls << gcd_two(ls[i-1], arr[i])
    rs << gcd_two(rs[i-1], arr[nn - i - 1])    
  end
end

max = 0
curs = []
arr.size.times do |i|
  if i == 0
    curval = rs[nn-2]
  elsif i == nn - 1
    curval = ls[nn-2]
  else
    curval = gcd_two(ls[i - 1], rs[nn - i - 2])
  end
  max = curval if max < curval
  curs << curval
end

pd ls
pd rs
pd curs
puts max


Measured memory_bytes: 12164
import sys
readline = sys.stdin.buffer.readline


class SegmentTree:
    def __init__(self, N, func, I):
        self.N = N
        self.sz = 2**(N-1).bit_length()
        self.func = func
        self.I = I
        self.seg = [I] * (self.sz * 2)

    def assign(self, k, x):
        self.seg[k + self.sz] = x

    def build(self):
        for i in reversed(range(1, self.sz)):
            self.seg[i] = self.func(self.seg[2 * i], self.seg[2 * i + 1])

    def update(self, k, x):
        k += self.sz
        self.seg[k] = x
        while k > 1:
            k >>= 1
            self.seg[k] = self.func(self.seg[2 * k], self.seg[2 * k + 1])

    def query(self, a, b):
        if a >= b:
            return self.I
        L = self.I
        R = self.I
        a += self.sz
        if b == self.N:
            b = self.sz
        b += self.sz
        while a < b:
            if a & 1:
                L = self.func(L, self.seg[a])
                a += 1
            if b & 1:
                b -= 1
                R = self.func(self.seg[b], R)
            a >>= 1
            b >>= 1
        return self.func(L, R)


def main():
    def gcd(a, b):
        while b:
            a, b = b, a % b
        return a
    N = int(readline())
    L = map(int, readline().split())
    seg = SegmentTree(N, gcd, 0)
    for i, n in enumerate(L):
        seg.assign(i, n)
    seg.build()
    ans = 1
    for i in range(N):
        ans = max(ans, gcd(seg.query(0, i), seg.query(i+1, N)))
    print(ans)


main()


Measured memory_bytes: 60528
#include<iostream>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<cmath>
#include<map>

using namespace std;

#define rep(i,N) for(int i=0;i<N;i++) //0から


typedef long long ll;




ll binary_search(vector<ll> a, ll n, ll key){
    ll right = n, left = -1;
    ll md = (right + left) / 2;

    while(right - left > 1){
        if(a[md] <= key){
            right = md;
        }else{
            left = md;
        }
        md = (right + left) / 2;
    }
    if(left == -1) return -1; //無い場合
    return right;
}

vector<ll> prime;
void Prime(ll n){ //線形篩,素数列挙
    vector<ll> p(n,0);
    p[0]=1;
    p[1]=1;
    for(ll i=2;i<n;i++){
        if(p[i]==0){
            prime.push_back(i);
            p[i]=i;
        }
        ll k=prime.size();
        for(ll j=0;j<k && i*prime[j]<n && prime[j]<=p[i];j++){
            p[i*prime[j]]=prime[j];
        }
    }
}

ll gcd(ll a,ll b){
    if(a<b){
        swap(a,b);
    }
    //a>=b
    ll r=a%b;
    while(r!=0){
        a=b;
        b=r;
        r=a%b;
    }
    return b;
}

#define MOD ((ll)1e+9 + 7)



//cout<<fixed<<setprecision(10);
int main(){
    int a,b;
    cin>>a>>b;
    cout<<a*b<<endl;


    return 0;
}



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

using namespace std;

int main(void)
{
    string S;
    int i, count=0;

    cin >> S;

    for(i=0; i<=2; i++){
        if(S[i] == 'o'){
            count++;
        }
    }

    cout << 700+count*100 << endl;

    return 0;
}

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

typedef long long ll;
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef vector<vector<int>> mi;
typedef vector<vector<pair<int, int>>> w_graph;
typedef vector<vector<int>> uw_graph;

double p[(int)3e3 + 5];
double dp[(int)3e3 + 5][(int)3e3 + 5];
int n;

double solve(int i, int h) {
	if (i == n) {
		if (h > (n - h)) return 1;
		return 0;
	}
	if (dp[i][h] != -1) return dp[i][h];
	return dp[i][h] = p[i] * solve(i + 1, h + 1) + (1.0 - p[i]) * solve(i + 1, h);

}

void init() {
	for (int i = 0; i < 3e3 + 5; i++) {
		for (int j = 0; j < 3e3 + 5; j++) {
			dp[i][j] = -1;
		}
	}
}

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
#ifdef DEBUG
	freopen("out.txt", "w", stdout);
#endif
	init();
	cin >> n;
	for (int i = 0; i < n; i++) cin >> p[i];

	double ans = solve(0, 0);
	cout << setprecision(12) << fixed << ans << endl;

	return 0;
	
}






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

#define int long long
typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,f,n) for(int i=(f);i<(n);i++)
#define all(v) (v).begin(),(v).end()
#define each(it,v) for(__typeof((v).begin()) it=(v).begin();it!=(v).end();it++)
#define pb push_back
#define fi first
#define se second
template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

int H,W;
int A[222][222];
int dp[222][222][444];
int solve(int x1,int x2,int t){
    int y1=t-x1;
    int y2=t-x2;
    int &ret=dp[x1][x2][t];
    if(ret!=-1)return ret;
    ret=0;
    if(t==H+W-2)return A[H-1][W-1];
    rep(i,2)rep(j,2){
        x1+=i;y1+=1-i;x2+=j;y2+=1-j;
        if(x1==W||x1==W||y1==H||y2==H||(x1==x2&&y1==y2));
        else{
            chmax(ret,solve(x1,x2,t+1));
        }
        x1-=i;y1-=1-i;x2-=j;y2-=1-j;
    }
    if(t==0)ret+=A[0][0];
    else ret+=A[y1][x1]+A[y2][x2];
    return ret;
}

signed main(){
    cin>>H>>W;
    rep(i,H)rep(j,W)cin>>A[i][j];
    memset(dp,-1,sizeof(dp));
    cout<<solve(0,0,0)<<endl;
    return 0;
}


Measured memory_bytes: 171648
#include<stdio.h>
#define N 101
#define W 0
#define B 1
#define INF 2001
int n,a[N][N],d[N];
 
void mst(){
  int i,j;
  int u,v;
  int pi[N],c[N];
  int mincost;
  for(u=1;u<=n;u++){
    d[u]=INF;
    pi[u]=NULL;
    c[u]=W;
  }
  d[1]=0;
  for(i=1;i<=n;i++){
    mincost = INF;
    for(j=1;j<=n;j++){
      if(c[j]!=B&&d[j]<=mincost){
    u = j;
    mincost = d[j];
      }
    }
    for(v=1;v<=n;v++){
      if(a[u][v]!=-1&&c[v]!=B &&a[u][v]<d[v]){
    pi[v] = u;
    d[v] = a[u][v];
      }
    }
     c[u]=B;
  }
}
 
int main(){
  int i,j;
  int sum = 0;
  scanf("%d",&n);
  for(i=1;i<=n;i++){
    for(j=1;j<=n;j++){
      scanf("%d",&a[i][j]);
    }
  }
  mst();
  for(i=1;i<=n;i++) sum += d[i];
  printf("%d\n",sum); 
  return 0;
}

Measured memory_bytes: 640
import bisect, collections, copy, heapq, itertools, math, string, sys
input = lambda: sys.stdin.readline().rstrip() 
sys.setrecursionlimit(10**7)
INF = float('inf')
def I(): return int(input())
def F(): return float(input())
def SS(): return input()
def LI(): return [int(x) for x in input().split()]
def LI_(): return [int(x)-1 for x in input().split()]
def LF(): return [float(x) for x in input().split()]
def LSS(): return input().split()

def resolve():
    a, b = LI()

    if a + b  == 15:
        print('+')
    elif a * b == 15:
        print('*')
    else:
        print('x')

if __name__ == '__main__':
    resolve()


Measured memory_bytes: 10068
import math
n = int(input())
x = [0]*n
y = [0]*n
s = 1
for i in range(n):
    x[i], y[i] = map(int, input().split())
    s *= (i+1)
l = 0
for i in range(n):
    for j in range(n):
        if i > j:
            l += math.sqrt((x[i]-x[j])**2+(y[i]-y[j])**2)
s2 = s//n

print(l*s2*2/s)

Measured memory_bytes: 3064
N,M = [int(i) for i in input().split()]
A = [int(i) for i in input().split()]
import heapq
heapA = []
for a in A:
    heapq.heappush(heapA,-a)
for m in range(M):
    tmp = -heapq.heappop(heapA)
    tmp = tmp//2
    tmp = -1 * tmp
    heapq.heappush(heapA,tmp)
print(-sum(heapA))

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

int main() {
	int n, a, b;
	cin >> n;
	if (n == 1) {
		cout << "Hello World" << endl;
	}
	if (n == 2) {
		cin >> a >> b;
		cout << a + b << endl;
	}
	return 0;
}

Measured memory_bytes: 256
N, P = map(int, input().split())
S = input()
if 10 % P == 0:
    ans = 0
    for r in range(N):
        if int(S[r]) % P == 0:
            ans += r + 1
    print(ans)
    exit()

d = [0] * (N + 1)
ten = 1
for i in range(N - 1, -1, -1):
    a = int(S[i]) * ten % P
    d[i] = (d[i + 1] + a) % P
    ten *= 10
    ten %= P

cnt = [0] * P
ans = 0
for i in range(N, -1, -1):
    ans += cnt[d[i]]
    cnt[d[i]] += 1
print(ans)

Measured memory_bytes: 11080
#include<stdio.h>
int main(){
  int n;
  scanf("%d", &n);
  int a[n],i,min=1000000000,minus=0,zero=0;
  long long int sum=0;
  for(i=0;i<n;i++){
    scanf("%d", &a[i]);
    if(a[i]<0){
      a[i]*=-1;
      minus++;
    }
    if(min>a[i]) min=a[i];
    if(a[i]==0) zero++;
    sum+=a[i];
  }
  int c=0;
  if(minus%2!=0) c=1;
  if(zero>0) c=0;
  if(c==1) sum-=min*2;
  printf("%lld", sum);
  return 0;
}

Measured memory_bytes: 512