akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
int a[2005][2005],b[2005][2005],c[2005][2005];
char s[2005];
int main(){
	int n,m,q;
	scanf("%d%d%d\n",&n,&m,&q);
	for (int i=1;i<=n;i++){
		scanf("%s",s+1);
		for (int j=1;j<=m;j++){
			a[i][j]=s[j]=='1';
			b[i][j]=a[i][j]&a[i][j-1];
			c[i][j]=a[i][j]&a[i-1][j];
		}
	}
	for (int i=1;i<=n;i++)
		for (int j=1;j<=m;j++){
			a[i][j]+=a[i-1][j]+a[i][j-1]-a[i-1][j-1];
			b[i][j]+=b[i-1][j]+b[i][j-1]-b[i-1][j-1];
			c[i][j]+=c[i-1][j]+c[i][j-1]-c[i-1][j-1];
		}
	for (int i=1;i<=q;i++){
		int x1,y1,x2,y2,ans=0;
		scanf("%d%d%d%d\n",&x1,&y1,&x2,&y2);
		ans+=a[x2][y2]-a[x1-1][y2]-a[x2][y1-1]+a[x1-1][y1-1];
		ans-=b[x2][y2]-b[x1-1][y2]-b[x2][y1]+b[x1-1][y1];
		ans-=c[x2][y2]-c[x1][y2]-c[x2][y1-1]+c[x1][y1-1];
		printf("%d\n",ans);
	}
}

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

if N == 1:
    print(1)
    exit()

ans = 10**12
for i in range(1, N):
    if i * i > N:
        break
    if N % i == 0:
        F = max(len(str(i)), len(str(N // i)))
        ans = min(ans, F)
print(ans)


Measured memory_bytes: 9040
#include <cstdio>
#include <iostream>
#include <cmath>
#include <iomanip>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;

const long double PI = (acos(-1));
const long double EPS = 0.0000000001;

long double a, b, x;

void input() {
	cin >> a >> b >> x;
}

long double f(long double a, long double b, long double theta) {

	long double ret;
	if (a * tan(theta) <= b) {
		ret = a*a*b-(0.5*a*a*a*tan(theta));
	}
	else {
		ret = b*a*0.5*b/tan(theta);
	}
	return ret;
}

void solve() {
	input();
	long double ok = PI / 2.0;
	long double ng = 0.0;
	for (int _ = 1; _ <= 100000; _++) {
		long double mid = (ok + ng) / 2.0;
		if (f(a, b, mid) < x) ok = mid;
		else ng = mid;
	}
	cout << fixed << setprecision(10) << ok / PI * 180 << endl;
	return;
}

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



Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <vector>

#define len(X) ((int)(X).size())

#ifdef __LOCAL
#define DBG(X) cout << #X << "=" << (X) << '\n';
#define SAY(X) cout << (X) << '\n';
#else
#define DBG(X)
#define SAY(X)
#endif

#define M_PI       3.14159265358979323846

using namespace std;

using ll = long long int;
using ull = unsigned long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

const int INT_INF = (int)(2e9);
const ll  LL_INF = (ll)(2e18);

const int NIL = -1;
static mt19937 _g(time(nullptr));

std::string pad(int num)
{
    char buffer[4];
    std::snprintf(buffer, sizeof(buffer), "%03d", num);
    return buffer;
}

inline ll randint(ll a, ll b) { ll w = (_g() << 31LL) ^ _g(); return a + w % (b - a + 1); }
inline void fast_io() { ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); };
template<typename T> inline T sign(T x) { return T(x > 0) - T(x < 0); }
template<typename T, typename S> inline ostream& operator<<(ostream& os, const pair<T, S> p) { cout << "[" << p.first << ";" << p.second << "]"; return os; }
template<typename T> inline ostream& operator<<(ostream& os, const vector<T>& v) { for (auto el : v) cout << el << " "; return os; }
template<typename T> inline T fetch() { T ret; cin >> ret; return ret; }
template<typename T> inline vector<T> fetch_vec(int sz) { vector<T> ret(sz); for (auto& elem : ret) cin >> elem; return ret; }

#ifdef _MSC_VER
#  include <intrin.h>
#  define __builtin_popcount __popcnt
#endif

struct Hashing {
    ull seed, mod;
    vector <ull> hs, pw;

    Hashing(ull seed = 31, ull mod = 1000173169) :
        seed(seed),
        mod(mod) {}

    void build(int n, const string& s) {
        hs.assign(n + 1, 0);
        pw.assign(n + 1, 1);
        pw[0] = 1;

        for (int i = 1; i <= n; ++i)
            pw[i] = pw[i - 1] * seed % mod;
        for (int i = 1; i <= n; ++i)
            hs[i] = (hs[i - 1] * seed + s[i]) % mod;
    }

    ull hash(int l, int r) {
        return (hs[r] - hs[l - 1] * pw[r - l + 1] % mod + mod) % mod;
    }
};

int solve()
{
    int n;

    std::cin >>n;

    bool ok = true;

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

        if (num % 2 == 0 && num % 3 != 0 && num % 5 != 0)
            ok = false;
    }

    if (ok)
        cout << "APPROVED" << endl;
    else
        cout << "DENIED" << endl; 

   
    return 0;
}

int main()
{
    solve();

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std::literals::string_literals;
using i64 = long long;
using std::cout;
using std::endl;
using std::cin;

template<typename T>
std::vector<T> make_v(size_t a){return std::vector<T>(a);}

template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
  return std::vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}

int main() {
	int n; scanf("%d", &n);
	std::vector<std::vector<int>> g(n);
	for(int i = 0; i < n - 1; i++) {
		int a, b; scanf("%d%d", &a, &b);

		g[a - 1].push_back(b - 1);
		g[b - 1].push_back(a - 1);
	}

	std::vector<std::map<int, double>> dp(n);
	auto dfs = [&](auto&& dfs, int v, int par, int f) -> double {
		if(dp[v].count(par)) return dp[v][par];

		int deg = 0;
		double tmp = 0;
		if(f or par == -1) {
			deg = g[v].size() - (par != -1);
			for(auto e: g[v]) {
				if(e == par) continue;
				tmp += dfs(dfs, e, v, f);
			}
		} else {
			deg = g[v].size() - 1;
			tmp = (dfs(dfs, v, -1, 0) - 1.) * g[v].size() - dfs(dfs, par, v, 0);
		}

		if(deg) tmp = tmp / deg + 1;
		return dp[v][par] = tmp;
	};
	dfs(dfs, 0, -1, 1);

	for(int i = 0; i < n; i++) printf("%.12lf\n", dfs(dfs, i, -1, 0));
	return 0;
}


Measured memory_bytes: 51328
package main

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

var sc = bufio.NewScanner(os.Stdin)

func nextLine() string {
    sc.Scan()
    return sc.Text()
}

func main() {
  var s string
  stack := []int{}
  s = nextLine()
  in := strings.Split(s, " ")


  for _, item := range in {
    var memo int
    if item == "+" {
      memo = stack[len(stack)-2] + stack[len(stack)-1]
      stack = stack[:len(stack)-2]
    } else if item == "-" {
      memo = stack[len(stack)-2] - stack[len(stack)-1]
      stack = stack[:len(stack)-2]
    } else if item == "*" {
      memo = stack[len(stack)-2] * stack[len(stack)-1]
      stack = stack[:len(stack)-2]
    } else {
      memo, _ = strconv.Atoi(item)
    }
    stack = append(stack, memo)
  }
  fmt.Println(stack[0])
}



Measured memory_bytes: 1144
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <map>

int main(int argc,char *argv[])
{
	int N,K;
	std::cin >> N >> K;
	
	int tmp, cnt = 0;
	for(int i = 0;i < N;i++)
	{
		std::cin >> tmp;
		if(tmp >= K) cnt++;
	}

	std::cout << cnt << std::endl;

	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(){


	int h, w, x, y;

	while(1){
		scanf( "%d %d", &h, &w );

		if( h==0 && w==0 ) break;


		for( y=0; y<h; y++ ){
			for( x=0; x<w; x++ ){
				printf("#");
			}
			printf( "\n" );
		}
		
		printf( "\n" );

	}


	return 0;

}

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

#define rep(i,s,n) for (int i = (ll)s; i < (ll)n; i++)
#define rrep(i,n,e) for (int i = (ll)n-1; i >= (ll)e; i--)
#define ll long long
#define ld long double
#define pb push_back
#define eb emplace_back
#define All(x) x.begin(), x.end()
#define Range(x, i, j) x.begin() + i, x.begin() + j
#define lbidx(x, y) lower_bound(x.begin(), x.end(), y) - x.begin()
#define ubidx(x, y) upper_bound(x.begin(), x.end(), y) - x.begin()
#define llbidx(x, y, z) lower_bound(x.begin(), x.end(), z) - lower_bound(x.begin(), x.end(), y)
#define deg2rad(deg) ((((double)deg)/((double)360)*2*M_PI))
#define rad2deg(rad) ((((double)rad)/(double)2/M_PI)*(double)360)
#define Find(set, element) set.find(element) != set.end()
#define Decimal(x) cout << fixed << setprecision(10) << x << endl;
#define debug(x) cerr << #x << ": " << (x) << "\n";
#define endl "\n"

typedef pair<int, int> PI;
typedef pair<ll, ll> PLL;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef vector<PI> vpi;
typedef vector<vector<PI>> vvpi;
typedef vector<PLL> vpl;
typedef vector<vector<PLL>> vvpl;

constexpr ll LINF = 1001002003004005006ll;
constexpr int INF = 1001001001;
constexpr int n_max = 2e5+10;

int powint(int x, int n) {
  int ret = 1;
  while (n > 0) {
    if (n & 1) ret *= x;
    x *= x; n >>= 1;
  }
  return ret;
};

ll powll(ll x, int n) {
  ll ret = 1;
  while (n > 0) {
    if (n & 1) ret *= x;
    x *= x; n >>= 1;
  }
  return ret;
};

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

void print() { cout << endl; };
template <class T>
void print(vector<T> &vec) {
  for (auto& a : vec) {
    cout << a;
    if (&a != &vec.back()) cout << " ";
  }
  cout << endl;
};
template <class T>
void print(vector<T> &vec, ll k){
   ll n = vec.size();
   k = min(k, n);
   rep(i, 0, k-1) cout << vec[i] << " ";
   cout << vec[k-1] << endl;
};
template <class T>
void print(vector<vector<T>> &df) {
  for (auto& vec : df) {
    print(vec);
  }
};
template<class T, class U>
void print(pair<T,U> &p){
  cout << p.first << " " << p.second << "\n";
};

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

  string T; cin >> T;
  rep(i, 0, T.size()) {
    if (T[i] == '?') T[i] = 'D';
  }

  cout << T << endl;

  return 0;
};


Measured memory_bytes: 3744
num = int(input())
scoreList = [input().split() for i in range(num)]
test = [[scoreList[i][0],int(scoreList[i][1])] for i in range(num)]
[test[i].append(i+1) for i in range(num)]
citySorted = sorted(test, key=lambda x:(x[0],-x[1]), reverse = False)
print(*[citySorted[i][2] for i in range(num)],sep='\n')

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

int main() {
	for (int i; i <=10000; i++){
		int x,y,tmp;
		cin >>x>>y;
		if(x>y){
			tmp=y;
			y=x;
			x=tmp;
		}
		if ( x == 0 && y == 0 )break;
		cout <<x<<" "<<y<<endl;
	}
	return 0;
}


Measured memory_bytes: 3096
// IlyM

#include <bits/stdc++.h>
#define pb push_back
#define sp " "
#define sl "\n"
#define fi first
#define se second
#define mp make_pair
#define sz(a) ((int)a.size())
#define tra(a,b) for (auto a:b) 
#define fo(a,b,c) for (int a=b;a<=c;a++) 
#define ms(a,b) memset(a,b,sizeof(a)) 
#define all(a) a.begin(),a.end()
#define rev(a) reverse(a.begin(),a.end())
#define bit(i,j) (i&(1<<j))

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> ii;
typedef vector<ii> vii;
typedef pair<int,ii> iii;

const int N=2e5+5,mod=998244353;
int n,a[N],x;
int main()
{
	cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);
	cin>>n;
	x=mod;
	fo(i,0,n-1) cin>>a[i];
	fo(i,1,100) {
		int c=0;
		fo(j,0,n-1) {
			int r=abs(a[j]-i);
			r*=r;
			c+=r;
		}
		x=min(c,x);
	}
	cout<<x;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using namespace std::chrono;
#define idfc ios_base::sync_with_stdio(false),cin.tie(nullptr),cout.tie(nullptr)
//:/
#define pb push_back
#define mp make_pair
#define nt _ll128
#define ld long double
long double PI =3.14159265358979323846;
using ll = long long;

const ll modo=1e9+7;
const ll ms=5010;
const ll inf=1e15;

int ar[3001][3001];
ll dp1[3001][4]={0};
ll dp2[3001][4]={0};
int main()
{
    idfc;

    int n,m,k;
    cin>>n>>m>>k;
    int i,j;

    for(i=1;i<=n;i++)
    {
        for(j=1;j<=m;j++)ar[i][j]=0;
    }
    int c;
    while(k--)
    {
        cin>>i>>j>>c;
        ar[i][j]=c;
    }
    ll ans=0;

    for(i=1;i<=n;i++)
    {
        for(j=1;j<=m;j++)
        {
            for(k=0;k<4;k++)
            {
                dp2[j][0]=max(dp2[j][0],dp1[j][k]);
                dp2[j][k]=max(dp2[j][k],dp2[j-1][k]);
            }
            dp2[j][1]=max(dp2[j][1],dp2[j][0]+ar[i][j]);
            for(k=0;k<3;k++)
            {
                dp2[j][k+1]=max(dp2[j][k+1],dp2[j-1][k]+ar[i][j]);
            }
        }

        for(j=1;j<=m;j++)
        {
            for(k=0;k<4;k++)
            {
              //  cout<<i<<" "<<j<<" "<<k<<" "<<dp2[j][k]<<"\n";
                dp1[j][k]=dp2[j][k];
                dp2[j][k]=0;
                ans=max(ans,dp1[j][k]);
            }
        }
    }
    cout<<ans;


    return 0;
}

Measured memory_bytes: 38916
#include <iostream>
#include <vector>
using namespace std;
using Graph = vector<vector<int>>;

// seen[v] := 頂点 v が行きがけ順で探索済みかどうかを表す
// visited[v] := 頂点 v が帰りがけ順で探索済みかどうかを表す
bool has_cycle(const Graph &G, int vertex,
               vector<bool> &seen, vector<bool> &visited)
{
    // vertex を行きがけ順で探索済みとする
    seen[vertex] = true;

    // 隣接頂点を順に見ていく
    for (auto next_vertex : G[vertex]) {
        // すでに訪問済みの場合
        if (seen[next_vertex]) {
            // もしその頂点がまだ帰りがけの状態でなかったならばサイクル検出
            if (!visited[next_vertex]) return true;

            // すでに帰りがけの状態であったならばサイクルではない
            continue;
        }

        // 再帰的に探索
        if (has_cycle(G, next_vertex, seen, visited)) return true;
    }

    // 帰りがけ順で探索済みとする
    visited[vertex] = true;
    return false;
}

int main() {
    // 入力
    int N, M;
    cin >> N >> M;
    Graph G(N);
    for (int i = 0; i < M; ++i) {
        int u, v;
        cin >> u >> v;
        G[u].push_back(v);
    }
    bool res = false;
    vector<bool> seen(N, false), visited(N, false);

    // 各連結成分ごとにサイクルをもつかどうかを判定する
    for (int vertex = 0; vertex < N; ++vertex) {
        if (seen[vertex]) continue;
        if (has_cycle(G, vertex, seen, visited)) res = true;
    }
    if (res) cout << "1" << endl;
    else cout << "0" << endl;
}



Measured memory_bytes: 3172
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <map>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)

int main() {
  int A,B,C;
  cin >> A >> B >> C;
  cout << max(0, C - (A - B)) << endl;
}


Measured memory_bytes: 888
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n,m,k;
	cin>>k>>n>>m;
	for(int i=n;i<=m;i++){
		if(i%k==0)
		{
			cout<<"OK\n";
			return 0;
		}
	}
	cout<<"NG\n";
	return 0;
}

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

typedef    long long          ll;
typedef    vector<long long>    vi; 
typedef    vector<vi>         vvi; 
typedef    pair<long,long>      ii; 
#define    sz(a)              long((a).size()) 
#define    pb                 push_back 
#define    mp                   make_pair
#define    all(c)             (c).begin(),(c).end() 
#define    tr(c,i)            for(typeof((c).begin() i = (c).begin(); i != (c).end(); i++) 
#define    present(c,x)       ((c).find(x) != (c).end()) 
#define    cpresent(c,x)      (find(all(c),x) != (c).end())  
#define    input(v,n)           for(ll i = 0 ; i<n ; i++) cin>>v[i]
#define    output(v,n)          for(ll i = 0 ; i<n ; i++) cout<<v[i]<<" "

ll n,m;
char a[1100][1100];
ll vis[1100][1100];
ll dist[1100][1100];
queue<pair<pair<ll,ll>,ll> > q;

void bfs()
{
  
  while(q.empty()==0)
  {
    pair<pair<ll,ll>,ll> p=q.front();
    q.pop();
    ll x=p.first.first;
    ll y=p.first.second;
    ll d=p.second;
    if(x>1)
    {
      if(vis[x-1][y]==0)
      {
        vis[x-1][y]=1;
        q.push(mp(mp(x-1,y),d+1));
        dist[x-1][y]=d+1;
      }
    }
    if(y>1)
    {
      if(vis[x][y-1]==0)
      {
        vis[x][y-1]=1;
        q.push(mp(mp(x,y-1),d+1));
        dist[x][y-1]=d+1;
      }
    }
     
    if(x<n)
    {
      if(vis[x+1][y]==0)
      {
        vis[x+1][y]=1;
        q.push(mp(mp(x+1,y),d+1));
        dist[x+1][y]=d+1;
      }
    }
    if(y<m)
    {
      if(vis[x][y+1]==0)
      {
        vis[x][y+1]=1;
        q.push(mp(mp(x,y+1),d+1));
        dist[x][y+1]=d+1;
      }
    }
     
    

  }
}

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

  ll i,j;
  cin>>n>>m;

  for(i=1;i<=n;i++)
  {
    for(j=1;j<=m;j++)
    {
      cin>>a[i][j];
      if(a[i][j]=='#'){dist[i][j]=0;q.push(mp(mp(i,j),0));vis[i][j]=1;}
      else dist[i][j]=100000;
    }
  }

  bfs();

ll ans=0;
  for(i=1;i<=n;i++)
  {
    for(j=1;j<=m;j++)
    {
      ans=max(ans,dist[i][j]);
    }
  }

  cout<<ans;







  return 0;
 }

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

#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define ALL(x) (x).begin(), (x).end()

typedef long long ll;
typedef long double ld;

const int INF = 1e9;
const ld EPS = 1e-8;

int main(){
  int N;
  cin >> N;
  vector<int> T(N), A(N);
  REP(i,N) cin >> T[i] >> A[i];

  ll a = T[0], b = A[0];
  for(int i = 1; i < N; ++i) {
    ll tmp1 = (a + T[i] - 1) / T[i];
    ll tmp2 = (b + A[i] - 1) / A[i];
    a = T[i] * max(tmp1, tmp2);
    b = A[i] * max(tmp1, tmp2);
  }
  cout << a + b << endl;
  return 0;
}



Measured memory_bytes: 256
term = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
k = int(input())
print(term[k - 1])

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(signed i=0;i<n;++i)
#define repi(n) rep(i,n)
#define repvin(n) vint a(n);r(i,n)cin>>a[i];
#define int long long
#define str string
#define vint vector<signed>
#define pint pair<signed,signed>
#define pb(a) push_back(a)
#define all(v) v.begin(),v.end()
#define yn(b) cout<<((b)?"Yes":"No")<<endl
#define YN(b) cout<<((b)?"YES":"NO")<<endl
#define call(a) for(auto t:a)cout<<t<<" ";cout<<endl
#define ENDL printf("\n");
#define debg(a) cout<<#a<<":"<<a<<endl;
#define SORT(a) sort(all(a));
#define INF 1LL<<60

signed main(){
  int n;
  cin>>n;
  vint a(n);
  repi(n)cin>>a[i];
  map<int,int> m;
  repi(n)m[a[i]]++;
  SORT(a);
  a.erase(unique(all(a)),a.end());
  int res=0;
  repi(a.size())res+=m[a[i]]%2;
  cout<<res<<endl;
  
  return 0;
}


Measured memory_bytes: 6912
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0,i##_max=(N);i<i##_max;++i)
#define repp(i,l,r) for(int i=(l),i##_max=(r);i<i##_max;++i)
#define per(i,N) for(int i=(N)-1;i>=0;--i)
#define perr(i,l,r) for(int i=r-1,i##_min(l);i>=i##_min;--i)
#define all(arr) (arr).begin(), (arr).end()
#define SP << " " <<
#define SPF << " "
#define SPEEDUP cin.tie(0);ios::sync_with_stdio(false);
#define MAX_I INT_MAX //1e9
#define MIN_I INT_MIN //-1e9
#define MAX_UI UINT_MAX //1e9
#define MAX_LL LLONG_MAX //1e18
#define MIN_LL LLONG_MIN //-1e18
#define MAX_ULL ULLONG_MAX //1e19
  typedef long long ll;
  typedef pair<int,int> PII;
  typedef pair<char,char> PCC;
  typedef pair<ll,ll> PLL;
  typedef pair<char,int> PCI;
  typedef pair<int,char> PIC;
  typedef pair<ll,int> PLI;
  typedef pair<int,ll> PIL; 
  typedef pair<ll,char> PLC; 
  typedef pair<char,ll> PCL; 

inline void YesNo(bool b){ cout << (b?"Yes" : "No") << endl;}
inline void YESNO(bool b){ cout << (b?"YES" : "NO") << endl;}
inline void Yay(bool b){ cout << (b?"Yay!" : ":(") << endl;}

int main(void){
  SPEEDUP
  cout << setprecision(15);
  int a,b;cin >> a >> b;
  if(a+b==15)cout << '+' << endl;
  else if(a*b==15) cout << '*' << endl;
  else cout << 'x' << endl;
  return 0;
}


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

using ll = long long;
ll mod = 1e9 + 7;

int main() {
  int N;
  cin >> N;

  map<int, int> fs;
  for(int i = 2; i <= N; ++i) {
    int n = i;
    for(int j = 2; j <= i; ++j) {
      while(n % j == 0) {
        fs[j]++;
        n /= j;
      }
    }
  }
  ll ans = 1LL;
  for(auto f : fs) {
    ans *= (f.second + 1) % mod;
    ans %= mod;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
package main

import (
	"fmt"
)

func solution(n, m int, r []result) ans {
	memo := make(map[int]int, n)
	var c, p int
	for i := 0; i < m; i++ {
		if memo[r[i].p] == -1 {
			continue
		} else if r[i].s == "AC" {
			c++
			p += memo[r[i].p]
			memo[r[i].p] = -1
		} else {
			memo[r[i].p]++
		}
	}
	return ans{c: c, p: p}
}

type result struct {
	p int
	s string
}

type ans struct {
	c, p int
}

func main() {
	var n, m, p int
	var s string
	r := make([]result, 0, m)
	fmt.Scan(&n, &m)
	for i := 0; i < m; i++ {
		fmt.Scan(&p, &s)
		r = append(r, result{p: p, s: s})
	}
	ans := solution(n, m, r)
	fmt.Printf("%d %d", ans.c, ans.p)
}


Measured memory_bytes: 16128
#include <iostream>
#include <cstdio>
#include <math.h>
#include <algorithm>
using namespace std;
int A,B;
int main(){
    cin >> A >> B;
    if(B%A==0){
        cout << A+B << "\n";
    }else{
        cout << B-A << "\n";
    }
}

Measured memory_bytes: 3660
// AtCoder Beginner Contest 064
// D - Insertion
// https://atcoder.jp/contests/abc064/tasks/abc064_d
#include <bits/stdc++.h>
using namespace std;

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

int main(void)
{
    int N; cin >> N;
    string S; cin >> S;

    int l_short = 0,  r_short = 0;
    rep(i, N) {
        if (S[i] == '(') {
            r_short++;
        } else {
            if (r_short > 0) {
                r_short--;
            } else {
                l_short++;
            }
        }
    }

    cout << string(l_short, '(') << S << string(r_short, ')') << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;;
#define rep(i, n) for(int i = 0;i < n;i++)
#define repr(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define INF 1<<30
#define LINF 1LL<<62
#define all(x) (x).begin(), (x).end()
#define F first
#define S second
#define mp make_pair
#define pb push_back
const int MOD = 1000000007;
 
typedef long long ll;
typedef long double ld;
typedef vector<ll> vl;
typedef pair<ll, ll> P;
typedef pair<ll, P> PP;


int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll h,w;cin >> h >> w;
  if(h==1||w==1){
    cout << 1<<endl;
    return 0;
  }
  cout << (h * w + 1) / 2 << endl;
}

Measured memory_bytes: 256
#include<cstring>
#include<iostream>
#include<cstdio>
using namespace std;
int main()
{
    string s;
    int h,w;
    scanf("%d%d",&h,&w);
    for(int i=0;i<h;i++)
        for(int j=0;j<w;j++)
        {
            cin>>s;
            if(s=="snuke"){printf("%c%d\n",j+'A',i+1);return 0;}
        }
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<long long, long long>;
constexpr char ln =  '\n';
constexpr long long MOD = 1000000007LL;
constexpr long long INF = 1001001001LL;
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define rept(i, j, n) for(int i=(j); i<(n); i++)
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; }

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

  ll res = k;
  queue<pii> que; //v, p
  que.push({0, -1});
  while(!que.empty()){
    auto tmp = que.front(); que.pop();
    int v = tmp.first, p = tmp.second;
    ll c = v==0? k-1 : k-2;
    for(auto e: G[v]){
      if(e == p) continue;
      res = res * c % MOD;
      c--;
      que.push({e,v});
    }
  }
  cout << res << ln;
}


Measured memory_bytes: 6904
import itertools
import statistics
N = int(input())
place_list = [list(map(int, input().split())) for i in range(N)]
all_place_list = list(itertools.permutations(place_list))
dist_list =[]
for place_list_iter in all_place_list:
    dist_sum = 0
    for i, (x, y) in enumerate(place_list_iter):
        if i == 0:
            pre_x, pre_y = x, y
        else:
            dist = ((x-pre_x)**2+(y-pre_y)**2)**(1/2)
            dist_sum += dist
    dist_list.append(dist_sum)
print(statistics.mean(dist_list))

Measured memory_bytes: 11656
#include<iostream>
#include<cstdio>
#include<cctype>
#include<string>

using namespace std;
string toUpper(string z){
    string a=z;
    for(int i=0; i<z.size(); i++){a[i]=toupper(z[i]);}
    return a;
}
int main(){
    string word,text;
    int count=0;
    cin >> word;
    word=toUpper(word);
    while(1){
        cin >> text;
        if(text=="END_OF_TEXT")break;
        text=toUpper(text);
        if(word==text)count++;
    }
    cout << count << endl;
    
    return 0;
}   
    



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

using namespace std;

int main(){
	int x,y;
	cin >> x >> y;
	if(y&1){
		cout << "No\n";
		return 0;
	}
	y /= 2;
	for(int i = 0; i < 200; i++){
		for(int j = 0; j < 200; j++){
			if(i + j == x &&  (i + 2 * j == y)){
				cout << "Yes\n";
				return 0;
			}
		}
	}
	cout << "No\n";
	return 0;
}


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

using namespace std;

void hawawa()
{
	int n, m;
	int mod = 1e9 + 7;
	cin >> n >> m;
	vector<long long> x(n);
	vector<long long> y(m);
	for (auto&& i : x) {
		cin >> i;
	}
	for (auto&& i : y) {
		cin >> i;
	}
	long long xsize = 0;
	for (int i = 0; i < n; i++) {
		xsize += i * x[i];
		xsize %= mod;
		xsize -= (n - 1 - i) * x[i];
		xsize %= mod;
	}
	long long ysize = 0;
	for (int i = 0; i < m; i++) {
		ysize += i * y[i];
		ysize %= mod;
		ysize -= (m - 1 - i) * y[i];
		ysize %= mod;
	}
	long long ans = xsize * ysize;
	ans %= mod;
	cout << ans << "\n";

}

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


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define each(itr,v) for(auto itr:v)
#define pb(s) push_back(s)
#define maxch(x,y) x=max(x,y)
#define minch(x,y) x=min(x,y)
#define mp(a,b) make_pair(a,b)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define maxch(x,y) x=max(x,y)
#define minch(x,y) x=min(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
template<class T,class U>inline void chmin(T &t,U f){if(t>f)t=f;}
template<class T,class U>inline void chmax(T &t,U f){if(t<f)t=f;}
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define MIN(a, b) ((a) > (b) ? (b) : (a))

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;
typedef pair<P, int> PPI;

#define INF INT_MAX/3
#define MAX_N 1000
ll a,b;
void solve(){
   cin.tie(0);
  ios::sync_with_stdio(false);
  cin>>a>>b;
  ll ans =0;
  repl(i,a,b+1){
    string s = to_string(i);
    if(s[0]==s[4] && s[1] == s[3]) ans++;
  }

  cout<<ans<<endl;
}
int main(){
  solve();
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF = 1LL<<45;
ll Sum[100],n,m,a,b,p,q;

ll calc(ll k){
  ll A = 1,B = 1,res=p+q;
  while(res>0&&res<=INF&&k--)A*=a,B*=b,res=p*A+q*B;
  if(res<0) res = INF;
  return min(INF,res);
}

ll ans = INF;
set<ll> used[101];
void dfs(ll pos,ll sum){
  ans = min(ans,(ll)abs(m-sum));
  if(m<sum||pos==-1||sum>INF||used[pos].count(sum)) return;
  used[pos].insert(sum);
  
  if(Sum[pos]+sum<m){ans=min(ans,m-(Sum[pos]+sum));return;}
  dfs(pos-1,sum+calc(pos));  
  dfs(pos-1,sum);
}

int main(){
  cin>>n>>m>>a>>b>>p>>q;
  Sum[0] = calc(0);
  for(int i=1;i<60;i++)Sum[i]=min(INF,calc(i)+Sum[i-1]);

  if(max(a,b)==1) {
    ll s = abs(m - (m/(p+q))*(p+q));
    ll t = abs(m - (m/(p+q))*(p+q) - (p+q));
    if(m/(p+q)==n) t = INF;
    if(m/(p+q)<=n) cout<<min(s,t)<<endl;
    else cout<< m-(p+q)*n <<endl;
    return 0;
  }
  dfs(min(n-1,50LL),0);
  cout<<ans<<endl;
  return 0;
}

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

using ll = long long int;
using ull = unsigned long long int;
using P = pair<int, int>;
using P3 = pair<P,int>;
using PP = pair<P, P>;
constexpr int INF = 1 << 28;
constexpr ll MOD = ll(1e9)+7;
constexpr int di[] = {0, 1, 0, -1};
constexpr int dj[] = {1, 0, -1, 0};
constexpr int di8[] = {0, 1, 1, 1, 0, -1, -1, -1};
constexpr int dj8[] = {1, 1, 0, -1, -1, -1, 0, 1};
constexpr double EPS = 1e-9;

template <typename T>
struct BIT {
    int N;
    std::vector<T> bit;

    BIT() = default;
    BIT(int n) {init(n);}
    void init(int n){
        N = n;
        bit.assign(n+1, 0);
    }
    T getSum(int i) {  // i番目までの要素の和を求める(1-index)
        T sum = 0;
        while (i > 0) {
            sum += bit[i];
            i -= i & -i;
        }
        return sum;
    }
    void add(int i, T x) {  // i番目の要素にxを加算
        while (i <= N) {
            bit[i] += x;
            i += i & -i;
        }
    }
};

constexpr int MAX_N = 100000;
int main(){
    vector<ll> fact(MAX_N+1);
    fact[0] = 1;
    for(int i=1;i<=MAX_N;i++){
        fact[i] = fact[i-1]*i%MOD;
    }
    int n;
    while(cin >> n, n){
        int r;
        cin >> r;
        vector<int> a(n);
        BIT<ll> bit(n);
        for(int i=0;i<n;i++){
            a[i] = i+1;
            bit.add(i+1,1);
        }
        for(int i=0;i<r;i++){
            int s, t;
            cin >> s >> t;
            s--; t--;
            swap(a[s],a[t]);
        }
        ll ans = 0;
        for(int i=0;i<n;i++){
            bit.add(a[i],-1);
            ans += bit.getSum(a[i])*fact[n-1-i]%MOD;
            ans %= MOD;
        }
        cout << ans << endl;
    }
    return 0;
}


Measured memory_bytes: 4716
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<pii> vii;
typedef vector<pll> vll;
typedef vector<vl> vvl;
typedef vector<vi> vvi;
typedef vector<bool> vb;
typedef vector<vb> vvb;
#define fi first
#define se second
const ll INFLL=LLONG_MAX;
const int INF=INT_MAX;
const ll MAXLL=0x3f3f3f3f3f3f3f3f;
const int MAX=0x3f3f3f3f;
#define eb emplace_back
#define emp emplace
#define mp(a,b) make_pair(a,b)
template<class T> using min_heap=priority_queue<T,vector<T>,greater<T> >;
template<class T>
void sort(vector<T>& v){
	sort(v.begin(),v.end());
}
template <class T, class U>
void sort(vector<T>& v,U func){
	sort(v.begin(),v.end(),func);
}
template <class T>
int lb_index(vector<T>& v,T k){
	return lower_bound(v.begin(),v.end(),k)-v.begin();
}
template <class T>
int ub_index(vector<T>& v,T k){
	return upper_bound(v.begin(),v.end(),k)-v.begin();
}

void solve(){
	int n,q;
	cin>>n;
	vl v(100001);
	int k;
	ll ans=0;
	for(int i=0;i<n;i++){
		cin>>k;
		ans+=k;
		v[k]++;
	}
	cin>>q;
	while(q--){
		ll a,b;
		cin>>a>>b;
		ans-=v[a]*a;
		ans+=v[a]*b;
		v[b]+=v[a];
		v[a]=0;
		cout<<ans<<endl;
	}
}

int main(){
	ios::sync_with_stdio(0);
	int numberofsubtestcases=1;
//	cin>>numberofsubtestcases;
	while(numberofsubtestcases--){
		solve();
	}
}



Measured memory_bytes: 4052
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		double x = (a+b)/2.;
	
		if((x-(int)x)>=0.5){
			x++;
		}
		System.out.println((int)x);
	}
}

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

struct Point{
  double x, y;
};

void koch(int n, Point a, Point b) {
  if(n == 0) return;
  Point s, t, u;
  double th = M_PI * 60.0 / 180.0; //弧度法への変換
  s.x = (2.0 * a.x + 1.0 * b.x) / 3.0;
  s.y = (2.0 * a.y + 1.0 * b.y) / 3.0;
  t.x = (1.0 * a.x + 2.0 * b.x) / 3.0;
  t.y = (1.0 * a.y + 2.0 * b.y) / 3.0;
  u.x = (t.x - s.x) * cos(th) - (t.y - s.y) * sin(th) + s.x;
  u.y = (t.x - s.x) * sin(th) + (t.y - s.y) * cos(th) + s.y;

  koch(n - 1, a, s);
  printf("%.8f %.8f\n", s.x, s.y);
  koch(n - 1, s, u);
  printf("%.8f %.8f\n", u.x, u.y);
  koch(n - 1, u, t);
  printf("%.8f %.8f\n", t.x, t.y);
  koch(n - 1, t, b);
}

main(){
  Point a, b;
  int n;
  cin >> n;
  a.x = 0;
  a.y = 0;
  b.x = 100;
  b.y = 0;
  printf("%.8f %.8f\n", a.x, a.y);
  koch(n, a, b);
  printf("%.8f %.8f\n", b.x, b.y);
  return 0;
}


Measured memory_bytes: 3228
#include <string>
#include <iostream>
#include <vector>
#include <stack>
#include <stdio.h>
#include <math.h>
#include <utility>
#include <algorithm>

using namespace std;

int main() {
	int n;
	cin >> n;
	vector<string> s(n);
	int cnt = 0;
	int fBlist = 0;
	int bAlist = 0;
	int vlist = 0;
	for (int i = 0; i < n; i++) {
		cin >> s[i];
		for (int j = 0; j < s[i].size() - 1; j++) {
			if (s[i][j] == 'A') {
				if (s[i][j + 1] == 'B') {
					cnt++;
				}
			}
		}
		if (s[i][0] == 'B' && s[i][s[i].size() - 1] == 'A') vlist++;
		else if (s[i][0] == 'B')fBlist++;
		else if (s[i][s[i].size() - 1] == 'A')bAlist++;
	}
	if (vlist != 0) {
		cnt += vlist;
	}
	cnt += fBlist < bAlist ? fBlist : bAlist;
	if (fBlist + bAlist == 0&&vlist!=0) {
		cnt--;
	}
	cout << cnt;
	return 0;
}


Measured memory_bytes: 768
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		long a = sc.nextLong();
		long b = sc.nextLong();
		long c = sc.nextLong();
		long d = sc.nextLong();
		sc.close();

		System.out.print(Math.max(a * c, Math.max(a * d, Math.max(b * c, b * d))));

	}
}


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

int main() {
  int n,x;
  cin >> n >> x;
  std::vector<int> d(n+1);
  for (int i = 0; i < n; i++) {
    int x; cin >> x;
    d[i+1] = d[i] + x;
  }
  int ans = 0;
  for (int i = 0; i <= n; i++) {
    if (d[i] <= x) {
      ans++;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 3572
#include<stdio.h>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <algorithm>
#include <sstream>
#include <iostream>
#include <string>

using namespace std;

int main() {

	int N, a[105];

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

	int m = 50000000;
	for (int i = -100; i <= 100; i++) {
		int sum = 0;
		for (int j = 0; j < N; j++) {
			sum += (a[j] - i)*(a[j] - i);
		}
		m = min(m, sum);
	}

	cout << m << endl;

	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<stdlib.h>
#include<math.h>
using namespace std;
 
 
int main() {
	int a, b, c, d;
	cin >> a >> b >> c >> d;

	if (d >= abs(c - a)) {
		cout << "Yes" << endl;
	}
	else if (d >=abs( b - a) && d >=abs( c - b)) {
		cout << "Yes" << endl;
	}
	else { cout << "No" << endl;
	}
	system("pause");
}

Measured memory_bytes: 504
#include<iostream>
#include <algorithm>
#include <vector>
#include <string>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;

int main(){
  ll N, M;
  cin >> N >> M;

  ll ans = 0;
  if(2*N>=M){
    ans = M/2;
  }else{
    ans += N;
    ans += (M-2*N)/4;
  }
  cout << ans <<endl;


    
  return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.IOException;
import java.io.InputStreamReader; 
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.util.StringTokenizer;

public class Main {
    public static void main(String[] args) throws IOException {
        BufferedReader sc = new BufferedReader(new InputStreamReader(System.in));
        PrintWriter pw = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)));
        StringTokenizer st;
        String a=sc.readLine();
        st=new StringTokenizer (a);
        String a1=st.nextToken();
        String a2=st.nextToken();
        pw.println(a2+a1);
        pw.close();
    }
}

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

int main() {
  int N,AC=0,WA=0,TLE=0,RE=0;
  cin>>N;
  
  for(int i=0;i<N;i++){
    string s;
    cin>>s;
    
    if(s=="AC"){
      AC++;
    }
    else if(s=="WA"){
      WA++;
    }
    else if(s=="TLE"){
      TLE++;
    }
    else{
      RE++;
    }
  }
  
  
  cout << "AC x " << AC<<endl;
  cout << "WA x " << WA<<endl;
  cout << "TLE x " << TLE<<endl;
  cout << "RE x " << RE<<endl;
}




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

using namespace std;
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VL;
typedef vector<VL> VVL;
typedef pair<int, int> PII;

#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
#define MOD 1000000007
#define INF (1LL<<25)     //33554432
#define PI 3.14159265359
#define EPS 1e-12
//#define int ll

signed main(void)
{
  string s;
  cin >> s;
  string t = s;

  REP(i, s.size()/2) swap(s[i], s[s.size()-i-1]);
  REP(i, s.size()) {
    if(s[i] == 'b') s[i] = 'd';
    else if(s[i] == 'd') s[i] = 'b';
    else if(s[i] == 'p') s[i] = 'q';
    else if(s[i] == 'q') s[i] = 'p';
  }
  if(s == t) cout << "Yes" << endl;
  else cout << "No" << endl;

  return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
typedef long long ll; //10^19 < 9223372036854775807
typedef unsigned long long ull; //10^20 < 18446744073709551615

#define REP(i,n) for(ll i=0;i<ll(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=ll(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=ll(b);i--)
#define FORA(i,I) for(const auto& i:I)
#define ALL(x) x.begin(),x.end() 
#define SIZE(x) ll(x.size()) 

#define MOD 1000000007

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

    ll ans = 0;
    for (int a = 1; a < N; a++) {
        for (int b = 1; b <= N/a; b++) {
            int c = N-a*b;
            if (c > 0) {
                ans++;
            }
        }
    }
    cout << ans << endl;

    return 0;
}


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

#define PI 3.14159265359
#define rep(i,a,n) for(int i=a;i<(int)n;++i)
#define SZ(x) ((int)(x).size())	//size() unsigned -> int
#define descSort(a) sort(a.begin(),a.end(),std::greater<int>())
using namespace std;
typedef long long ll;
const ll INF = 1e9 + 7;
ll GCD(ll x,ll y){
    if(x%y==0)return y;
    return GCD(y,x%y);
}
ll LCM(int a, int b){
    return a*b/GCD(a,b);
}

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

    ll g=gcd(a,b);

    ll ans=1;
    for(ll i=2;i*i<=g;i++){
        if(g%i==0){
            ans++;
            while(g%i==0){
                g/=i;
            }
        }
    }
    if(g !=1)ans++;

    cout<<ans<<endl;
    return 0;
}



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


int main(){
  int d,g;
  cin >> d >> g;
  vector<pair<int,int>> a(d);
  REP(i,d) cin >> a[i].first >> a[i].second;
  int ans=1000;
  REP(bit,1<<d) {
    ll score=0;
    int toita=0;
    REP(i,d){
      if (bit&(1<<i)) {
	score += ((a[i].first*100*(i+1)) + a[i].second);
	toita += a[i].first;
      }
    }
    if (score < g){
      int nokori=g-score;
      for (int i=d-1; i>=0;i--) {
	if (!(bit&(1<<i))) {
	  if (nokori < (a[i].first*100*(i+1))+a[i].second) {
	    toita += (nokori + (100*(i+1)-1))/(100*(i+1));
	    break;
	  }
	  else {
	    nokori -= ((a[i].first*100*(i+1))+a[i].second);
	    toita += a[i].first;
	  }
	}
      }
      ans = min(ans,toita);
    }
    else{
      ans = min(ans,toita);
    }
  }
  cout << ans << endl;
  return 0;
}


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

ll solve() {
    ll N, a, s = 0, ans = 0;
    cin >> N;
    map<ll, ll> m;
    m[s]++;
    for ( int i = 0; i < N; i++ ) {
        cin >> a;
        s += a;
        ans += m[s];
        m[s]++;
    }
    return ans;
}

int main() {
    auto ans = solve();
    cout << ans << "\n";
    return 0;
}

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

int main(){
	int i,j,k,n,m,l,f,x,y,z; string s;
	cin >> s;
	n = s.size();
	int a[26] = {0};
	rep(i, n){
		a[s[i] - 'a'] = 1;
	}
	char t = 'a';
	x = 0;
	rep(i, 26){
		if(a[i] == 0){
			t += i;
			x = 1;
			break;
		}
	}
	if(x == 0) cout << "None" << endl;
	else cout << t << endl;
}

Measured memory_bytes: 512
open System.IO
open System
open System.Linq
open System.Collections.Generic

let sw = new StreamWriter(Console.OpenStandardOutput())
sw.AutoFlush <- false

let _n = stdin.ReadLine()
let _a = stdin.ReadLine().Split() 

//let memoize fn = 
//    let cache = new System.Collections.Generic.Dictionary<_,_>()
//    (fun x ->
//    match cache.TryGetValue x with
//    | true, v -> v
//    | false, _ -> 
//        let v = fn (x)
//        cache.Add(x,v)
//        v)

/// nC2
let c2 n = n * (n - 1L) / 2L
//let memC2 = memoize c2

//let countByA = _a |> Array.countBy id |> Map.ofSeq
//let countByA =  _a |> Array.countBy id |> dict
let countByA =  _a |> Array.countBy id |>fun x -> x.ToDictionary(fst,snd)

// 全部の答えを出して余分な数を引く方針
let ansWhole = 
    countByA
    |> Seq.map (fun x -> c2 (int64 x.Value))
    |> Seq.sum

let unNeeded aNum = 
    let x = int64 countByA.[aNum]
    // xC2 - (x-1)C2 = x-1
    x-1L

//let memUnNeeded = memoize unNeeded
/// それぞれの答え
let ansEach aNum = ansWhole - unNeeded aNum |> string

_a
|> Seq.map ansEach
|> Seq.iter stdout.WriteLine

stdout.Flush()
stdout.Close()


Measured memory_bytes: 55380
import sys

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readline_s = sys.stdin.readline
readlines = sys.stdin.buffer.readlines


def main():

    N = int(readline())
    num = []
    for i in range(5):
        num.append(int(readline()))

    q, r = divmod(N, min(num))
    ans = q + (not (not r)) + 4
    print(ans)


if __name__ == '__main__':
    main()


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

class team
{
	public:

		team(){c=w=l=0;}

		char c;
		int w,l;

		bool operator<(const team& t) const
		{
			return w!=t.w ? w>t.w : l<t.l;
		}
};

int main()
{
	int n,s;
	while(cin >> n, n)
	{
		vector<team> v;

		for(int j=0; j<n; j++)
		{
			team t;
			cin >> t.c;

			for(int i=0; i<n-1; i++)
			{
				cin >> s;
				if(s==0) { t.w++; }
				if(s==1) { t.l++; }
			}
			v.push_back(t);
		}
		stable_sort(v.begin(), v.end());
		for(int i=0; i<v.size(); i++)
		{
			cout << v[i].c << endl;
		}
	}

	return 0;
}

Measured memory_bytes: 0
package main

import "fmt"

func main() {
	var c [4]rune
	var a [4]int
	fmt.Scanf("%c%c%c%c", &c[0], &c[1], &c[2], &c[3])
	for i := 0; i < 4; i++ {
		a[i] = int(c[i] - '0')
	}
	for i := 0; i < 8; i++ {
		x := a[0]
		var op [4]rune
		for j := uint(0); j < 3; j++ {
			if uint(i)&(1<<j) >= 1 {
				x -= a[j+1]
				op[j] = '-'
			} else {
				x += a[j+1]
				op[j] = '+'
			}
		}
		if x == 7 {
			fmt.Printf("%d%c%d%c%d%c%d=7\n", a[0], op[0], a[1], op[1], a[2], op[2], a[3])
			return
		}
	}
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#define REP(i,s,e) for(int i=(s); i<(e);i++)
#define rep(i,n) REP(i,0,n)
#define rep1(i,n) REP(i,1,n)
#define repe(i,n) for(auto &&i:n)
#define all(v) (v).begin(),(v).end()
#define decimal fixed<<setprecision(20)
#define fastcin() cin.tie(0);ios::sync_with_stdio(false)
#define int long long
using namespace std;
using LL = long long;
using Graph = vector<vector<int>>;
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 int INF = 1e9;
const LL LLINF = 1e16;
const int dx[] = {0, 1, 0, -1}, dy[] = {1, 0, -1, 0};


signed main(){
    fastcin();
    int n;
    cin >> n;
    vector<LL> a(n);
    rep(i, n) cin >> a[i];
    vector<LL> tmp;
    rep(i, n){
        tmp.push_back(a[i]+i);
    }
    sort(all(tmp));
    int ans = 0;
    rep(i, n){
        LL k = -a[i]+i;
        ans += upper_bound(all(tmp), k) - lower_bound(all(tmp), k);
    }
    cout << ans << endl;
}


Measured memory_bytes: 6892
#[allow(unused_imports)]
use std::{cmp::Reverse, collections::*};

#[allow(unused_imports)]
use proconio::{
    fastout, input,
    marker::{Chars, Usize1},
};

#[allow(unused_imports)]
use itertools::Itertools;

#[allow(unused_imports)]
use num::Integer;

#[fastout]
pub fn main() {
    input! {
        w: Chars,
    }
    let mut map = HashMap::new();
    for c in w {
        *map.entry(c).or_insert(0) += 1;
    }
    println!(
        "{}",
        if map.iter().all(|(_, &v)| v % 2 == 0) {
            "Yes"
        } else {
            "No"
        }
    );
}


Measured memory_bytes: 2192
import sys
sys.setrecursionlimit(1 << 25)
read = sys.stdin.readline
ra = range
enu = enumerate


def exit(*argv, **kwarg):
    print(*argv, **kwarg)
    sys.exit()


def mina(*argv, sub=1): return list(map(lambda x: x - sub, argv))
# 受け渡されたすべての要素からsubだけ引く.リストを*をつけて展開しておくこと


def a_int(): return int(read())


def ints(): return list(map(int, read().split()))


def read_col(H):
    '''H is number of rows
    A列、B列が与えられるようなとき
    ex1)A,B=read_col(H)    ex2) A,=read_col(H) #一列の場合'''
    ret = []
    for _ in range(H):
        ret.append(list(map(int, read().split())))
    return tuple(map(list, zip(*ret)))


def read_tuple(H):
    '''H is number of rows'''
    ret = []
    for _ in range(H):
        ret.append(tuple(map(int, read().split())))
    return ret


def read_matrix(H):
    '''H is number of rows'''
    ret = []
    for _ in range(H):
        ret.append(list(map(int, read().split())))
    return ret
    # return [list(map(int, read().split())) for _ in range(H)] # 内包表記はpypyでは遅いため


MOD = 10**9 + 7
INF = 2**31  # 2147483648 > 10**9
# default import
from collections import defaultdict, Counter, deque
from operator import itemgetter, xor, add
from itertools import product, permutations, combinations
from bisect import bisect_left, bisect_right  # , insort_left, insort_right
from functools import reduce
from math import gcd


def lcm(a, b):
    # 最小公倍数
    g = gcd(a, b)
    return a // g * b


a = a_int()
print(a + a**2 + a**3)


Measured memory_bytes: 68744
#include<iostream>
#include<vector>
#include<cstdint>
#include<cstdlib>
template<typename T>
void fin(T const& t){ std::cout << t << std::endl; exit(0); }

int main() {
  std::cin.tie(0); std::ios::sync_with_stdio(false);
  int const M = 1000*1000;
  std::vector<bool> isprime(M, true);
  std::vector<int64_t> prime;
  for(int p = 2; p < M; ++p) if(isprime[p]) {
    prime.push_back(p);
    for(int j = p*2; j < M; j += p) isprime[j] = false;
  }
  int64_t N; std::cin >> N;
  std::vector<int> e(prime.size());
  for(int i = 0; i < prime.size(); ++i) {
    int64_t p = prime[i];
    while(N%p == 0) { N /= p; ++e[i]; }
  }
  int ans = (N>1? 1: 0);
  for(int i: e) {
    int c = 1;
    while(i >= c) { ++ans; i -= c; ++c; }
  }
  fin(ans);
  return 0;
}


Measured memory_bytes: 4708
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define pf push_front
#define ppb pop_back
#define ppf pop_front
#define f first
#define s second
#define mp make_pair
#define sz size()
int n;
long long sum, a[200101];
int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	cin >> n;
	for(int i = 1; i <= n; ++i) cin >> a[i], sum += a[i];
	long long l = 0, r = sum, ans = sum;
	for(int i = 1; i < n; ++i) {
		l += a[i], r -= a[i];
		ans = min(ans, 1ll * abs(r - l));
	}
	cout << ans;
	return 0;
}

Measured memory_bytes: 1920
use std::io::stdin;

fn main() {
    let mut s = String::new();
    stdin().read_line(&mut s).ok();
    let mut vsa: Vec<u32> = s.trim().split_whitespace().map(|token| token.parse().ok().unwrap()).collect();

    let mut s = String::new();
    stdin().read_line(&mut s).ok();
    let vs: Vec<u32> = s.trim().split_whitespace().map(|token| token.parse().ok().unwrap()).collect();
    vsa.push(vs[0]);
    vsa.push(vs[1]);

    let mut s = String::new();
    stdin().read_line(&mut s).ok();
    let vs: Vec<u32> = s.trim().split_whitespace().map(|token| token.parse().ok().unwrap()).collect();
    vsa.push(vs[0]);
    vsa.push(vs[1]);

    let condvec = vec![
        vsa.iter().filter(|x| {**x == 1}).count(),
        vsa.iter().filter(|x| {**x == 2}).count(),
        vsa.iter().filter(|x| {**x == 3}).count(),
        vsa.iter().filter(|x| {**x == 4}).count()
    ];
    let cond =
        condvec.iter().filter(|x| {**x == 1}).count() == 2
        && condvec.iter().filter(|x| {**x == 1}).count() == 2;
    if cond {
        println!("YES");
    } else {
        println!("NO");
    }
}


Measured memory_bytes: 4476
<?php
fscanf(STDIN, '%d %d %d %d', $a, $b, $c, $d);
$nums = [$a, $b, $c, $d];
sort($nums);
if ($nums[0] === 1 && $nums[1] === 4 && $nums[2] === 7 && $nums[3] === 9) {
    echo 'YES';
} else {
    echo 'NO';
}
echo "\n";

Measured memory_bytes: 4856