akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<iostream>
#include<stdlib.h>
#include<queue>
#include<map>
#include<vector>
#include<cmath>
#include<fstream>
#include <set>
//freopen(".in","r",stdin);
//freopen(".out","w",stdout);
//freopen("input.txt","r",stdin);
//freopen("output.txt","w",stdout);
const int  MAXN =2e5+10;
const long long  mod = 1e14 ;
const long long INF = 0x7f7f7f7f7f7f7f7f;
const int inf= 0x3f3f3f3f;
#define eps 1e-8
#define PI 3.1415926535898
#define lowbit(x) (x&(-x))
using namespace std ;
//getline(cin,s);
//set<ll>::iterator it;
//map<int,int>::iterator it;
typedef long long ll;
typedef unsigned long long ull;
int vis[MAXN],a[MAXN],dist[MAXN];
int result[MAXN];
int main()
{
	int n,ans,need;
	ull k;
	scanf("%d %llu",&n,&k);
	for(int i=1;i<=n;i++) scanf("%d",&a[i]);
	queue<int>q;
	q.push(1);dist[1]=0;vis[1]=1;
	while(1)
	{
		int now=q.front();q.pop();
		int ne=a[now];
		vis[ne]++;
		int d=dist[now]+1;
		if(vis[ne]==2)
		{
			ans=d-dist[ne];
			need=ne;
			break;
		}
		dist[ne]=d;
		q.push(ne);
	}
	for(int i=0;i<ans;i++)
	{
		int now=need;
		result[i]=now;
	//	printf("re: %d \n",result[i]);
		need=a[now];
	}
	//printf("xunhuan: %d need: %d   %d\n",ans,need,dist[need]);
	if(k<dist[need])
	{
		int oo=0,ans1;
		queue<int>q1;q1.push(1);
		while(1)
		{
			int now=q1.front();q1.pop();
			int ne=a[now];
			oo++;
			if(oo==k)
			{
				ans1=ne;
				break;
			}
			q1.push(ne);
		} 
		printf("%d\n",ans1);
	}
	else
	{ 
    	int m=(k-dist[need])%ans;
    	//printf("%llu\n",m);
    	printf("%d\n",result[m]);
    } 
	return 0;
}

Measured memory_bytes: 6632
N = int(input())
a_list = list(map(int, input().split()))
r2 = 0
r4 = 0
for i in range(N):
    if a_list[i]%2==0:
        r2 += 1
    if a_list[i]%4==0:
        r4 += 1
r2 -= r4
r0 = N - r2 - r4
if N % 2==0:
    print("Yes") if r4 >= r0 else print("No")
else:
    print("Yes") if r4 >= r0-1 else print("No")


Measured memory_bytes: 14252
r,g,b,n=map(int,input().split())
nr=n//r
ans=0
for i in range(nr+1):
  ng=(n-i*r)//g
  for j in range(ng+1):
    res=n-r*i-g*j
    if res%b==0:
      ans+=1
print(ans)


Measured memory_bytes: 2940
#include<bits/stdc++.h>
#define range(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,b) for(int i = 0; i < (b); i++)
#define all(a) (a).begin(), (a).end()
#define debug(x) cout << "debug " << x << endl;
const int INF = 100000000;
using namespace std;

int main(){
    int n, w, h;
    while(cin >> n >> w >> h, n||w||h){
        int p, s;
        vector<pair<int, int>> v;
        v.emplace_back(make_pair(w, h));

        rep(i,n){
            int a[4], t, s;
            pair<int, int> p[2];
            cin >> t >> s;

            int wi = v[t - 1].first;
            int hi = v[t - 1].second;

            auto it = v.begin();
            rep(i,t - 1) it++;
            v.erase(it);
            while(s > wi + hi) s-=wi + hi;

            if(s < wi){
                p[0].first = s;
                p[0].second = hi;
                p[1].first = wi - s;
                p[1].second= hi;
            }else{
                p[0].first = wi;
                p[0].second = s - wi;
                p[1].first = wi;
                p[1].second = hi - p[0].second;
            }

            /*
            cout << endl;
            cout << p[0].first << ' ' << p[0].second << endl;
            cout << p[1].first << ' ' << p[1].second << endl;
            cout << endl;
            */

            if(p[0].first * p[0].second >= p[1].first * p[1].second){
                v.emplace_back(p[1]);
                v.emplace_back(p[0]);
            }else{
                v.emplace_back(p[0]);
                v.emplace_back(p[1]);
            }
        }

        vector<int> ans;
        rep(i,v.size()){
            ans.emplace_back(v[i].first * v[i].second);
        }
        sort(all(ans));
        bool re = 0;
        for(auto it:ans){
            if(re) cout << ' ';
            cout << it;
            re = 1;
        }
        cout << endl;
    }
}

Measured memory_bytes: 3088
#include <iostream>

using namespace std;

int main() {
    int a, b;
    cin >> a >> b;
    if(a==1) a+=13;
    if(b==1) b+=13;
    if(a>b) cout << "Alice" << endl;
    else if(b>a) cout << "Bob" << endl;
    else cout << "Draw" << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<ll,ll> l_l;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
typedef pair<l_l,ll> lll;
typedef vector<string> vs;
const ll dx[4]={1,-1,0,0};
const ll dy[4]={0,0,1,-1};
#define pb push_back
#define sz(x) (int)(x).size()
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
const int INF=1001001000;
const int mINF=-1001001000;
const ll LINF=1010010010010010000;
template<class T> inline bool chmin(T& a, T b) {
if (a > b) {
a = b;
return true;
}
return false;
}
template<class T> inline bool chmax(T& a, T b) {
if (a < b) {
a = b;
return true;
}
return false;
}
//グリッド：（典型）dp,dfs,bfs,最短経路,その他
ll dp[3300][3300];
int main(){
    string s,t;cin>>s>>t;
    ll n=sz(s),m=sz(t);
    memset(dp,0,sizeof(dp));
    rrep(i,n){
        rrep(j,m){
            //cout<<i<<" "<<j<<" "<<s[i-1]<<" "<<t[j-1]<<endl;
            dp[i][j]=max(dp[i][j-1],dp[i-1][j]);
            if(s[i-1]==t[j-1])dp[i][j]=max(dp[i][j],dp[i-1][j-1]+1);
        }
    }
    string ans="";
    while(n>0&&m>0){
        if(s[n-1]==t[m-1]){
            ans=s[n-1]+ans;
            n--;
            m--;
        }
        else if(dp[n][m]==dp[n][m-1]){
            m--;
        }
        else n--;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 88740
;;; body

(defconstant +inf+ 10000000)

(defun main ()
  (let ((n (read)))
    (declare ((unsigned-byte 8) n))
    (let ((a (loop repeat n collect (read))))
      (declare (list a))
      (princ
       (reduce #'min
               (mapcar (lambda (y)
                         (reduce #'+
                                 (mapcar (lambda (x)
                                           (expt (- x y) 2))
                                         a)))
                       (loop for y of-type (signed-byte 16) from -100 to 100 collect y))))
      (fresh-line))))

#-swank (main)


Measured memory_bytes: 24840
#include <bits/stdc++.h>
int main()
{
  	int ans=0;
  	int n;
  	scanf("%d",&n);
	for(int i=0;i<100;i++){
    	if(i*1000>=n){
          		ans=i*1000-n;
          break;
        }
    }
  	printf("%d",ans);
}

Measured memory_bytes: 3816
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>

#include <cmath>
#include <cstdlib>
#include <climits>

//#include <stdio.h>
//#include <stdlib.h>


using namespace std;

#define debug false

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

  string S;
  cin >> S;
  S[3] = '8';
  cout  << S << endl;


  return 0;
}


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

using namespace std;
#define rep(i, n) for (ll i = 0; i < (n); ++i)
//#define rep(i, n) for (int i = 0; i < (n); ++i)
#define sz(x) ll(x.size())
//typedef long long ll;
typedef long long ll;
//typedef pair<int, int> P;
typedef pair<ll, ll> P;
//const double INF = 1e10;
//const ll INF = 10e15;
const ll MINF = -10e10;
const int INF = INT_MAX / 100;
#define cmin(x, y) x = min(x, y)
#define cmax(x, y) x = max(x, y)


//ifstream myfile("~/Downloads/02.txt");
//ofstream outfile("log.txt");
//outfile << setw(6) << setfill('0') << prefecture << setw(6) << setfill('0') << rank << endl;
// std::cout << std::bitset<8>(9);

typedef priority_queue<P, vector<P>, greater<P> > PQ_ASK;
const int mod = 1000000007;
const double PI = 3.14159265358979323846;

string to_upper(string str) {
    int diff = 'a' - 'A';
    for (int i = 0; i < str.size(); i++) {
        char c = str[i];
        if ('A' <= c && c <= 'Z') {
            c += diff;
            str[i] = c;
        }
    }
    return str;
}

int main() {

    while (true) {
        int n;
        cin >> n;
        if (n == 0) return 0;
        vector<double> exams(n);
        rep(i, n) cin >> exams[i];

        double sum = accumulate(exams.begin(), exams.end(), 0.0);
        double ave = sum / n;

        vector<double> diff(n);
        rep(i, n) diff[i] = ave - exams[i];
        rep(i, n) diff[i] *= diff[i];

        double diff_sum = accumulate(diff.begin(), diff.end(), 0.0);
        double dispersion = diff_sum / n;

        double sd = sqrt(dispersion);
        printf("%.20f\n", sd);
    }
}



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

const int INF = 40;
int sx, sy;
int gx, gy;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
int h, w, ans = 0;
typedef pair<int, int> P;

int main() {
  cin >> h >> w;
  char maze[w][h];
  int d[w][h];
  string S;

  for (int i = 0; i < h; i++) {
    cin >> S;
    for (int j = 0; j < w; j++) {
      maze[j][i] = S[j];
    }
  }

  queue<P> que;

  for (int sy = 0; sy < h; ++sy) {
    for (int sx = 0; sx < w; ++sx) {
      if (maze[sx][sy] == '#') continue;

      for (int initi = 0; initi < h; initi++)
        for (int initj = 0; initj < w; initj++) d[initj][initi] = INF;

      que.push(P(sx, sy));
      d[sx][sy] = 0;

      while (que.size()) {
        P p = que.front();
        que.pop();

        for (int i = 0; i < 4; i++) {
          int nx = p.first + dx[i], ny = p.second + dy[i];

          if (0 <= nx && nx < w && 0 <= ny && ny < h && maze[nx][ny] != '#' &&
              d[nx][ny] == INF) {
            que.push(P(nx, ny));
            d[nx][ny] = d[p.first][p.second] + 1;
          }
        }
      }

      rep(i, w) rep(j, h) if (maze[i][j] != '#') ans = max(ans, d[i][j]);
    }
  }

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


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);i++)
#define ALL(v) (v).begin(),(v).end()
#define int long long
using namespace std;
typedef vector<int>   vint;
typedef pair<int,int> pint;

signed main()
{
    int N; cin>>N;
    vint L(N+1);
    L[0]=2; 
    L[1]=1;
    for(int i=2;i<=N;i++){
        L[i]=L[i-1]+L[i-2];
    }
    cout<<L[N]<<endl;
}


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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define FOR(i,n,m) for(int i=(int)(n); i<=(int)(m); i++)
#define RFOR(i,n,m) for(int i=(int)(n); i>=(int)(m); i--)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define RITR(x,c) for(__typeof(c.rbegin()) x=c.rbegin();x!=c.rend();x++)
#define setp(n) fixed << setprecision(n)

template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }

#define ll long long
#define vll vector<ll>
#define vi vector<int>
#define pll pair<ll,ll>
#define pi pair<int,int>

#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define ins insert

#define debug(a) cerr<<(a)<<endl
#define dbrep(a,n) rep(_i,n) cerr<<(a[_i])<<" "; cerr<<endl
#define dbrep2(a,n,m) rep(_i,n){rep(_j,m) cerr<<(a[_i][_j])<<" "; cerr<<endl;}

using namespace std;

template<class A, class B>
ostream &operator<<(ostream &os, const pair<A,B> &p){return os<<"("<<p.fi<<","<<p.se<<")";}
template<class A, class B>
istream &operator>>(istream &is, pair<A,B> &p){return is>>p.fi>>p.se;}

/* Some Libraries */

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

int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N; cin>>N;
    vi A(N);
    rep(i,N){
        int a; cin>>a;
        A[a-1]++;
    }
    sort(all(A));
    vi sum(N+1);
    rep(i,N) sum[i+1]=sum[i]+A[i];
    auto maxsum = [&](int x){
        auto itr = upper_bound(all(A),x);
        return sum[itr-A.begin()]+x*(A.end()-itr);
    };
    FOR(i,1,N){
        int l=0, r=N+1;
        while(r-l>1){
            int c = (l+r)/2;
            ((ll)c*i<=maxsum(c))?l=c:r=c;
        }
        cout<<l<<"\n";
    }
    return 0;
}


Measured memory_bytes: 5512
#include <bits/stdc++.h>
using namespace std;
#define mod 1000000007
#define pb push_back
#define mp make_pair
#define fi first
#define sec second
typedef long long ll;
typedef long double  ld;
#define pii pair<ll,ll> 
#define pic pair<ll,char>
#define vi vector< ll > 
#define vvi vector< vi > 
#define vpi vector< pii > 
#define vvpi vector< vpi > 
#define st  set <ll, greater <ll> >
#define mst  multiset <ll, greater <ll> >
#define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define mapp  unordered_map <ll, ll>
#define ppii pair< pii, pii > 
#define test(t) ll t;cin>>t;while(t--)
#define inarr(n) ll arr[n];for(ll i=0;i<n;i++)cin>>arr[i];
#define ingra(m) vvi arr(100005);for(ll i=0;i<m;i++){ll u,v;cin>>u>>v;arr[u].pb(v);arr[v].pb(u);}
#define mem(a,b) memset(a,b,sizeof(a))
#define inn freopen("input.txt", "r", stdin)
#define outt freopen("output.txt", "w", stdout)
#define all(arr) arr.begin(),arr.end()
ll power(ll x,ll y){ll res = 1;while(y){if(y&1) res = (res*x)%mod;y=y/2,x=(x*x)%mod;}return res%mod;}
signed main()
{
    fast;
    ll n,i,k;
    cin>>n>>k;
    ll arr[n+1];
    for(i=1;i<=n;i++)
        cin>>arr[i];
    ll dp[n+1];
    dp[1] = 0;
    dp[2] = abs(arr[2]-arr[1]);
    for(i=3;i<=n;i++)
    {
        dp[i] = 1e18;
        ll j;
        for(j=max(1LL,i-k);j<i;j++)
            dp[i] = min(abs(arr[i]-arr[j])+dp[j],dp[i]);
    }
    cout<<dp[n];
}

Measured memory_bytes: 1792
import java.io.InputStream;
import java.util.NoSuchElementException;
public class Main {
	public static void main(String[] args)throws Exception{
		String S=next();
		System.out.println(S.substring(0,3));
	}
	//FastScanner
	static InputStream in = System.in;
	static  byte[] buffer = new byte[1024];
	static int length = 0, p = 0;
	public static boolean hasNextByte () {
		if (p < length) return true;
		else {
			p = 0;
			try {length = in.read(buffer);}
			catch (Exception e) {e.printStackTrace();}
			if (length == 0) return false;
		}
		return true;
	}
	public static int readByte () {
		if (hasNextByte() == true) return buffer[p++];
		return -1;
	}
	public static boolean isPrintable (int n) {return 33<=n&&n<=126;}
	public static void skip () {
		while (hasNextByte() && !isPrintable(buffer[p])) p++;
	}
	public static boolean hasNext () {skip(); return hasNextByte();}
	public static String next () {
		if (!hasNext()) throw new NoSuchElementException();
		StringBuilder sb = new StringBuilder();
		int temp = readByte();
		while (isPrintable(temp)) {
			sb.appendCodePoint(temp);
			temp = readByte();
		}
		return sb.toString();
	}
	public static int nextInt () {return Math.toIntExact(nextLong());}
	public static int[] nextInts (int n) {
		int[] ar = new int[n];
		for (int i=0; i<n; i++) ar[i] = nextInt();
		return ar;
	}
	public static long nextLong () {
		if (!hasNext()) throw new NoSuchElementException();
		boolean minus = false;
		int temp = readByte();
		if (temp == '-') {
			minus = true;
			temp = readByte();
		}
		if (temp<'0' || '9'<temp) throw new NumberFormatException();
		long n = 0;
		while (isPrintable(temp)) {
			if ('0'<=temp && temp<='9') {
				n *= 10;
				n += temp - '0';
			}
			temp = readByte();
		}
		return minus? -n : n;
	}
}


Measured memory_bytes: 32396
#include<iostream>
#include<string>
#include<complex>
#include<vector>
#include<algorithm>
#include<functional>
#include<array>
#include<map>
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
#define INF 1e+9


int main() {
	int a, b;
	cin >> a >> b;
	cout << (a*b) - a - b + 1 << endl;


	return 0;
}

Measured memory_bytes: 256
#include <fstream>
#include <iostream>
#include <algorithm>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <sstream>
#include <map>
#include <set>
#include <vector>
#include <stack>
#include <cmath>
#include <queue>
#include <random>

using namespace std;

#define INT_MAX_VALUE 2147483647
#define LONG_LONG_MAX_VALUE 9223372036854775807
#define ll long long

template <class T>
T mymax(T a,T b){
    if(a>=b) return a;
    return b;
}
template <class T>
T mymin(T a,T b){
    if(a<=b) return a;
    return b;
}

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

ll lcm(ll a, ll b){
    return (a*b)/gcd(a,b);
}

struct XX{
    long long x;
    long long jun;
    long long z;
    long long ix;
};

class xxGreater {
public:
    bool operator()(const XX& riLeft, const XX& riRight) const {
        //第2条件
        if((riLeft.x) == (riRight.x)){
            return riLeft.ix < riRight.ix;//<:昇順(小さいものから順番)、>:降順(大きいものから順番)
            //プライオリティキューの場合は > で、top()すると値の小さいものがとれる
        }
        //第1条件
        return (riLeft.x) < (riRight.x);
    }
};

//map<long long,long long> prime_f(long long n){
//    map<long long,long long>res;
//    for(int i=2;i*i<=n;i++){
//        while(n%i==0){
//            ++res[i];
//            n/=i;
//        }
//    }
//    if(n!=1)res[n]=1;
//    return res;
//}


int main(int argc, const char * argv[])
{
    //std::ios::sync_with_stdio(false);
    //scanf("%s",S);
    //scanf("%d",&N);
    //sscanf(tmp.c_str(),"%dd%d%d",&time[i], &dice[i], &z[i]);
    //getline(cin, target);
    //cin >> x >> y;
    //テスト用
    //ifstream ifs( "1_06.txt" );
    //ifs >> a;
    //ここから
    
    //入力高速化
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    string s;
    cin >> s;
    
    cout << "2018" << s.substr(4,6) << endl;
    
    //ここまで
    //cout << "debug" << endl;
    //cout << "ans" << endl;改行含む
    //printf("%.0f\n",ans);//小数点以下表示なし
    //printf("%.7f\n",p);
    //printf("%f\n",pow(2,ans.size()));
    
    return 0;
}



Measured memory_bytes: 768
#include<iostream>
#include<string>
#include<vector>
#include<queue>
#include<algorithm>
typedef long long ll;
#define rep(i,n) for(int i=0;i<(n);i++)
using namespace std;

int main() {
	int a, b, c;
	cin >> a >> b >> c;
	int ab = abs(a - b);
	int bc = abs(b - c);
	int ca = abs(a - c);
	cout << ab + bc + ca - max(ab, max(bc, ca)) << endl;
}

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

int n;
int c[1252];
int v[1252];

int main(){
  scanf("%d",&n);
  REP(i,n)scanf("%d",c+i);
  int q;
  scanf("%d",&q);
  REP(tim,q){
    int t,x,d;
    scanf("%d%d%d",&t,&x,&d);
    x--;
    if(t==1){
      v[x]+=d;
      if(v[x]>c[x]){
        printf("%d\n",x+1);
        return 0;
      }
    }else{
      v[x]-=d;
      if(v[x]<0){
        printf("%d\n",x+1);
        return 0;
      }
    }
  }
  puts("0");
  return 0;
}


Measured memory_bytes: 3232
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
void push (int);
int pop (void);

int stack[100],top=0;

int main(){
  int x,b,c,d;
  char s[100];

  while( scanf("%s", s) != EOF ){
    if ( s[0] == '+' ){
      b=pop();
      c=pop();
      d=b+c;
      push(d);

    } else if ( s[0] == '-' ){
      c=pop();
      b=pop();
      d=b-c;
      push(d);
    } else if ( s[0] == '*' ){
      b=pop();
      c=pop();
      d=b*c;
      push(d);
    } else {
      x = atoi(s);
      push(x);
    }
  }
  printf("%d\n",stack[0]);

  return 0;
}

void push (int a){

  stack[top]=a;
  top++;

}

int pop (void){

  top--;
  return stack[top];
}



Measured memory_bytes: 2048
#!/usr/bin/env python3

from pprint import pprint
from collections import deque, defaultdict
import sys

sys.setrecursionlimit(10 ** 6)
inf = float("inf")

a, b, c, d = map(int, input().split())

i = 0
while a > 0 and c > 0:
    if i % 2 == 0:
        c -= b
    else:
        a -= d
    i += 1

if a > 0:
    print('Yes')
else:
    print('No')


Measured memory_bytes: 68432
//=template==================================================================//
// include
#include <vector>
#include <list>
#include <algorithm>
#include <sstream>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <string>

// namespace
using namespace std;

// define
#define FOR(i,a,b) for(int (i)=(a); (i)<(b); (i)++)
#define REP(i,n) FOR(i,0,n)
#define MIN_V(v) *min_element(v.begin(), v.end())
#define MAX_V(v) *max_element(v.begin(), v.end())

// typedef
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<long> VL;
typedef vector<VL> VVL;
typedef vector<string> VS;
typedef long long LL;
typedef unsigned long long ULL;

// conversion
inline int toInt(string s) {int v; istringstream sin(s); sin>>v; return v;}
inline int countChar(string s, char c) {int cnt,i; cnt=0; REP (i,s.size()) {if (s[i]==c) cnt++;} return cnt;}
template<class T> inline string toString(T x) {ostringstream sout; sout<<x; return sout.str();}
//===========================================================================//

//=function prototype========================================================//

//===========================================================================//

//=variables=================================================================//

//===========================================================================//
int main(void)
{
  // Scan begin.
  string s;
  cin >> s;
  // Scan done.

  // Code begin.
  int cnt = countChar(s, '-');
  cout << 4-cnt*2 << endl;
  // Code done.

  return 0;
}

//=functions=================================================================//

//===========================================================================//

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace AtCoder
{
	class Program
	{
		static void Main(string[] args)
		{
			var Instance = new Question();
			Instance.Exec();
		}
	}

	public class Question
	{
		public void Exec()
		{
			List<string> answer = new List<string>();
			while (true) {
				string str = Console.ReadLine();
				if (str == "-") {
					break;
				}

				int m = int.Parse(Console.ReadLine());
				for (int i = 0; i < m; ++i) {
					int shuffle = int.Parse(Console.ReadLine());
					str = str.Substring(shuffle, str.Length - shuffle) + str.Substring(0, shuffle);
				}

				answer.Add(str);
			}

			foreach (var item in answer) {
				Console.WriteLine($"{item}");
			}

			Console.ReadKey();
		}
	}
}


Measured memory_bytes: 15916
/*
このコード、と～おれ!
Be accepted!
∧＿∧　
（｡･ω･｡)つ━☆・*。
⊂　　 ノ 　　　・゜+.
　しーＪ　　　°。+ *´¨)
 　　　　　　　　　.· ´¸.·*´¨) ¸.·*¨)
		  　　　　　　　　　　(¸.·´ (¸.·'* ☆
					*/

#include <iostream>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <string>
#include <climits>
#include <tuple>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <cmath>
#include <algorithm>
#define rep(i, n) for(Int (i) = 0; (i) < (n); (i)++)
#define debug(var) cout << #var << ": " << var << endl
using namespace std;
using Int = int64_t;
using Uint = uint64_t;
constexpr Uint mod = 1e9 + 7;
constexpr Int INF = LLONG_MAX;
constexpr Int Int_max = LLONG_MAX;
constexpr Int Int_min = LLONG_MIN;
using Container = vector<Int>;
template<typename T>
using Grid = vector<vector<T>>; // 二次元配列。[y][x]
template<typename T, typename U>
using Umap = unordered_map<T, U>;
template<typename T>
using Uset = unordered_set<T>;
template<typename T>
using P = pair<T, T>;


int main() {

	Int N; cin >> N;
	Grid<Int> satisfaction(N, vector<Int>{-INF, -INF, -INF});
	rep(i, N) {
		cin >> satisfaction[i][0] >> satisfaction[i][1] >> satisfaction[i][2];
	}
	Int except[3][2] = { {1, 2}, {0, 2}, {0, 1} };
	Grid<Int> dp(N, vector<Int>(3));
	dp[0][0] = satisfaction[0][0], dp[0][1] = satisfaction[0][1], dp[0][2] = satisfaction[0][2];
	rep(i, N - 1) {
		rep(j, 3) {
			dp[i + 1][except[j][0]] = max(dp[i + 1][except[j][0]], dp[i][j] + satisfaction[i + 1][except[j][0]]);
			dp[i + 1][except[j][1]] = max(dp[i + 1][except[j][1]], dp[i][j] + satisfaction[i + 1][except[j][1]]);
		}
	}
	cout << max({ dp[N - 1][0], dp[N - 1][1], dp[N - 1][2] }) << endl;

}

Measured memory_bytes: 11136
// 2020-07-25 11:08:48
#include<bits/stdc++.h>
#ifdef LOCAL
#include "lib/debug.hpp"
#else
#define debug(...) 1
#endif
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define rep(i, n) REP(i, 0, (n))
#define repc(i, n) REPC(i, 0, (n))
#define REP(i, n, m) for (int i = (int)(n); i < (int)(m); i++)
#define REPC(i, n, m) for (int i = (int)(n); i <= (int)(m); i++)
#define REPCM(i, n, m) for (int i = (int)(n); i >= (int)(m); i--)
using namespace std;
using ll = long long;
using ld = long double;
using pr = pair<ll, ll>;
using vll = vector<ll>;
using vpr = vector<pr>;
using P = pair<int, int>;
template<class T> inline bool chmin(T& a, const T& b) { if (a > b) { a = b; return true; } else return false; }
template<class T> inline bool chmax(T& a, const T& b) { if (a < b) { a = b; return true; } else return false; }

void answer() {
  int n, m;
  cin >> n >> m;
  priority_queue<ll> que;
  rep(i, n) {
    ll a;
    cin >> a;
    que.push(a);
  }
  rep(i, m) {
    ll a = que.top(); que.pop();
    que.push(a / 2);
  }
  ll ans = 0;
  while(!que.empty()) {
    ans += que.top(); que.pop();
  }
  cout << ans << '\n';
}
int main() {
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);
  answer();
  return 0;
}

Measured memory_bytes: 4268
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>

using std::cin;
using std::cout;
using std::endl;

using std::string;
using std::pair;

using std::vector;
using std::sort;

int main(){
    int h,w;
    cin >> h >> w;
    vector<vector<int>> s(h+2,vector<int>(w+2,0));

    for(int i=1;i<=h;i++){
        string str;
        cin >> str;
        for(int j=1;j<=w;j++){
            s[i][j] = str[j-1]=='#';
        }
    }

    for(int i=1;i<=h;i++){
        for(int j=1;j<=w;j++){
            if(s[i][j]==1&&
            s[i-1][j]==0&&
            s[i+1][j]==0&&
            s[i][j-1]==0&&
            s[i][j+1]==0){
                cout << "No" << endl;
                return 0;
            }
        }
    }

    cout << "Yes" << endl;

    return 0;
}



Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(){
	int l;
	while(cin>>l,l){
		int ans=0;
		for(int i=0,m,n;i<12;++i){
			cin>>m>>n;
			l-=m-n;
			if(ans==0&&l<=0){
				ans=i+1;
			}
		}
		if(ans==0) cout<<"NA\n";
		else cout<<ans<<"\n";
	}
	return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
#ifdef LOCAL
#include "debug.h"
#else
#define dump(...)
#endif
#define endl "\n"
#define ll long long
#define FOR(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define REP(i, x) for (int i = 0; i < (int)(x); i++)
#define REPS(i, x) for (int i = 1; i <= (int)(x); i++)
#define RREP(i, x) for (int i = ((int)(x)-1); i >= 0; i--)
#define RREPS(i, x) for (int i = ((int)(x)); i > 0; i--)
#define INF (1 << 30 - 1)
#define LLINF (1LL << 60)
#define vi vector<int>
#define vvi vector<vector<int>>
#define pi pair<int, int>
#define ALL(a) (a).begin(), (a).end()
#define BIT(n) (1LL << (n))
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end()) //sortしてからつかうこと
constexpr ll MOD = 1e9 + 7;
int dx[8] = {1, 0, -1, 0, 1, 1, -1, -1};
int dy[8] = {0, 1, 0, -1, 1, -1, 1, -1};
ll A, B, C, D, E, F, G, H, N, M, L, K, P, Q, R, W, X, Y, Z;
string S, T;
ll ans = 0;

template <typename T>
istream &operator>>(istream &is, vector<T> &vec) {
    for (T &x : vec)
        is >> x;
    return is;
}

signed main() {
    cin >> N >> K >> C;
    cin >> S;
    set<int> set;
    REP(i, N) {
        if (S[i] == 'x') {
            continue;
        }
        set.insert(i);
        i += C;
    }
    if (set.size() != K) {
        return 0;
    }
    vi res;
    RREP(i, N) {
        if (S[i] == 'x') {
            continue;
        }
        if (set.count(i)) {
            res.push_back(i);
        }
        i -= C;
    }
    sort(ALL(res));
    REP(i, res.size()) {
        cout << res[i] + 1 << endl;
    }
}

Measured memory_bytes: 12028
#include<vector>
#include<iostream>
#include<stdio.h>
#include<stdlib.h>
#include <iostream>
#include <algorithm>
#include <map>
#include <cmath>
#include<queue>
#include <sstream>
#include <set>
#include<stack>

const long long MOD = 1000000007;
using namespace std;
typedef long long llong;

//int isalpha(char ch): ch がアルファベットなら true を返す
//int isdigit(char ch): ch が数字なら true を返す
//int islower(char ch): ch が小文字なら true を返す
//int isupper(char ch): ch が大文字なら true を返す
//int tolower(char ch): ch の小文字を返す
//int toupper(char ch): ch の大文字を返す

//string型
//size()	文字数を返す
//Insert()	（指定した場所に）文字・文字列を挿入する
//erase()	（指定した場所の）文字・文字列を削除する
//clear()	すべての文字を削除する
//substr()	文字列の（指定した）部分文字列を返す
//replace()	（指定した）部分文字列を新しい文字列に置換する
//c_str()変換
//文字列の比較は、<=や==などを使え
//replace関数を使い、簡単に文字列を置換
//リバース関数：reverse(str.begin(), str.end());
//map<type, type> dict;で宣言
//グラフ理論用変数
//vector<vector<llong> > graph(N);

//ソート
//降順sort(v.begin(), v.end(), std::greater<Type>());

//大文字から小文字へんかん
//w[i] = w[i]-'A'+'a';

//vector
//assignメソッド　引数：サイズ、値
//与えられたサイズと値でvectorを初期化する

//queueクラス
//find()次に取り出す値の表示をする。
//pop()値を取り出す。戻り値はなし
//push()キューに値をプッシュする

//priority_queueクラス

//切り上げ
//ceil
//floor

void dfs(vector<vector<llong> > &graph, vector<llong> &color, llong node, llong c, llong &sum){
    if(color[node]!=-1){
        return;
    }
    color[node] = c;
    sum = sum + 1;
    for(int i=0; i<graph[node].size(); i++){
        dfs(graph, color, graph[node][i], c, sum);
    }
}

int main(){

    llong N,M;
    llong A,B;

    cin >> N >> M;
    vector<vector<llong> > graph(N);
    vector<llong> color(N, -1);
    llong c=0;
    llong maxv = -1;
    llong sum;
    for(int i=0; i<M; i++){
        cin >> A >> B;
        graph[A-1].push_back(B-1);
        graph[B-1].push_back(A-1);
    }

    for(int i=0; i<N; i++){
        sum = 0;
        if(color[i]!=-1){
            continue;
        }
        dfs(graph, color, i, c, sum);
        maxv = max(sum, maxv);
        c++;
    }
    cout << maxv << endl;
    return 0;
}


Measured memory_bytes: 27724
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)  FOR(i,0,n)
#define req(i,n) for(int i = 1;i <=n;i++)
#define pai 3.14159265358979323846
const int INF = 1001001001;
typedef long long ll;
int A[3][3], N;
bool punched[3][3];
bool ok[3][3];
using Graph = vector<vector<int>>;
vector<vector<int>> field;
vector<bool> seen;

const int MOD = 1000000007;
typedef pair<int,int> P;

//最大公約数
ll gcd(ll a,ll b){
	if (a%b == 0){
		return b;
	}
	else{
		return gcd(b,a%b);
	}

}

//最小公倍数
ll lcm(ll a,ll b){
	return a /gcd(a,b) * b;
}

//素数判定
bool is_prime(long long N) {
    if (N == 1) return false;
    for (long long i = 2; i * i <= N; ++i) {
        if (N % i == 0) return false;
    }
    return true;
}

// 素因数分解
vector<pair<long long, long long> > prime_factorize(long long n) {
    vector<pair<long long, long long> > res;
    for (long long p = 2; p * p <= n; ++p) {
        if (n % p != 0) continue;
        int num = 0;
        while (n % p == 0) { ++num; n /= p; }
        res.push_back(make_pair(p, num));
    }
    if (n != 1) res.push_back(make_pair(n, 1));
    return res;
}

// 10進数から2進数
int binary(int bina){
    int ans = 0;
    for (int i = 0; bina>0 ; i++)
    {
        ans = ans+(bina%2)*pow(10,i);
        bina = bina/2;
    }
    return ans;
}








int main (){
  ll n,m;
  cin >> n >> m;
  vector <int> num(n,1),can(n,0);
  can[0]=1;
  for (int i = 0;i < m;i++){
    int a,b;cin >> a >> b;--a,--b;
    if (can[a]) can[b] = 1; 
    if (num[a] == 1) can[a] = 0;
    num[a]--;
    num[b]++;
  }
  int res = 0;
  for (int i = 0;i < n;i++){
    if (can[i] && num[i]) ++res;
  }
  cout << res << endl;
  
}

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

// 多次元 vector 生成
template<class T>
vector<T> make_vec(size_t a){
    return vector<T>(a);
}
template<class T, class... Ts>
auto make_vec(size_t a, Ts... ts){
  return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}

// mod add
const int MOD = 1000000007;
void add(long long &a, long long b) {
    a += b;
    if (a >= MOD) a -= MOD;
}

// 0: dammy, 1: 'A', 2: 'G', 3: 'C', 4: 'T'
// "AGC, GAC, ACG", "A*GC", "AG*C" を含まない (012, 102, 021 を禁止)
long long solve(int N) {
    auto dp = make_vec<long long>(N+1, 5, 5, 5); // dp[i文字][3文字前][2文字前][1文字前]
    dp[0][0][0][0] = 1;
    for (int n = 0; n < N; ++n) {
        for (int i = 0; i < 5; ++i) {
            for (int j = 0; j < 5; ++j) {
                 for (int k = 0; k < 5; ++k) {
                     for (int l = 1; l < 5; ++l) {
                         if (i == 1 && j == 2 && l == 3) continue;
                         if (i == 1 && k == 2 && l == 3) continue;
                         if (j == 1 && k == 2 && l == 3) continue;
                         if (j == 2 && k == 1 && l == 3) continue;
                         if (j == 1 && k == 3 && l == 2) continue;
                         add(dp[n+1][j][k][l], dp[n][i][j][k]);
                     }
                }
            }
        }
    }
    long long res = 0;
    for (int i = 1; i < 5; ++i)
        for (int j = 1; j < 5; ++j)
            for (int k = 1; k < 5; ++k)
                add(res, dp[N][i][j][k]);
    return res;
}

int main() {
    int N;
    while (cin >> N) cout << solve(N) << endl;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define start_routine() int begtime = clock();
#define end_routine() int endtime = clock(); \
                      cerr << "\n\n" << "Time elapsed: " << \
                      (endtime - begtime)*1000/CLOCKS_PER_SEC << " ms\n\n"; \
                      return 0
#define ll long long int
#define ull unsigned long long int
#define db long double
#define ff first
#define ss second
#define mp make_pair
#define pb push_back
#define lb lower_bound
#define ub upper_bound 
#define pii pair<int , int>
#define pdd pair<db , db>
#define pll pair<ll , ll>
#define vpl vector<pll >
#define vll vector<ll >
#define mod 1000000007
#define mod1 998244353 
#define inf 1000000000000000007
#define eps 0.000001
#define stp fixed<<setprecision(20)
#define endl '\n'



int main()
{
    fastio;
    #ifdef APNA_IO
        start_routine();
        freopen("input.txt", "rt", stdin);
        freopen("output.txt", "wt", stdout);    
    #endif
    
    ll n;cin>>n;
    multiset<ll> m;

    ll a[n];
    for(ll i=0;i<n;i++)
        cin>>a[i],m.insert(a[i]);

    for(ll i=0;i<n;i++)
    {
        m.erase(m.find(a[i]));
        ll x=*(m.rbegin());
        cout<<x<<endl;
        m.insert(a[i]);
    }


    #ifdef APNA_IO
        end_routine();
    #endif
}


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

int main ()

{
    int a,c,N,A,B,i,x,y,z,k,j;
    j=0;
    scanf("%d%d%d",&N,&A,&B);
    c=N;
    for(i=1;i<=c;i++){
        N=i;
        x=N/10000.0;
        N=N-10000*x;
        y=N/1000.0;
        N=N-1000*y;
        z=N/100.0;
        N=N-z*100;
        a=N/10.0;
        N=N-a*10;

        k=a+z+x+y+N;
        if(k>=A && k<=B){
            j=i+j;
        }


    }
    printf("%d",j);
}


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

int main() {
  ll n;
  cin>>n;
  vector<ll> v(n);
  rep(i,n){
    cin>>v.at(i);
  }
  sort(v.begin(),v.end());
  ll a = v.at(n/2 - 1),b = v.at(n/2);
  cout << b-a << endl;
}

Measured memory_bytes: 1024
import itertools

N = int(input())
P = tuple([ int(v) for v in input().split(" ") ])
Q = tuple([ int(v) for v in input().split(" ") ])

p_list = list(itertools.permutations(range(1, N+1), N))

a = 0
b = 0
for i in range(len(p_list)):
  if p_list[i] == P:
    a = i+1
  if p_list[i] == Q:
    b = i+1

#print(a,b)
print(abs(a-b))


Measured memory_bytes: 13788
import sys

stdin = sys.stdin
inf = 1 << 60
mod = 1000000007

sys.setrecursionlimit(10 ** 7)

ni      = lambda: int(ns())
nin     = lambda y: [ni() for _ in range(y)]
na      = lambda: list(map(int, stdin.readline().split()))
nan     = lambda y: [na() for _ in range(y)]
nf      = lambda: float(ns())
nfn     = lambda y: [nf() for _ in range(y)]
nfa     = lambda: list(map(float, stdin.readline().split()))
nfan    = lambda y: [nfa() for _ in range(y)]
ns      = lambda: stdin.readline().rstrip()
nsn     = lambda y: [ns() for _ in range(y)]
ncl     = lambda y: [list(ns()) for _ in range(y)]
nas     = lambda: stdin.readline().split()

from collections import deque

n, m = na()
ab = nan(m)

g = [[] for _ in range(n)]
for i in range(m):
    a, b = ab[i]
    a -= 1
    b -= 1
    g[a].append(b)
    g[b].append(a)

ans = [-1 for _ in range(n)]
def bfs():
    q = deque()
    q.append((0, 0))
    while len(q):
        p, l = q.popleft()
        if ans[p] != -1:
            continue
        ans[p] = l
        for v in g[p]:
            q.append((v, p))

bfs()
print("Yes")
for i in range(1, n):
    print(ans[i] + 1)

Measured memory_bytes: 85500
package main

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

const mod int64 = 1000000007
const size int64 = 50

func main() {
  var m int64
  var n int = NextInt()
  var a []int64 = NextInt64Array()
  var p []int64 = make([]int64,n+1)
  for i:=1;i<n+1;i++ { p[i] = (p[i-1]+inv(int64(i)))%mod }
  for i:=1;i<n+1;i++ { m = (m+(p[i]+p[n-i+1]-1)*a[i-1])%mod }
  for i:=1;i<n+1;i++ { m = (m*int64(i))%mod }
  fmt.Println(m)
}

func inv(n int64) int64 {
  if n == 1 { return 1 }
  var k []int64 = make([]int64,size)
  var t,a,b,u,i,y0,y1 int64
  a,b,t = mod,n,n
  for i=0;i<size;i++ {
    k[i],t = a/b,a%b
    if t == 0 {
      u = i
      break
    }
    a,b = b,t
  }
  y0,y1 = 1,-k[0]
  for i=1;i<u;i++ { y0,y1 = y1,y0-k[i]*y1 }
  for y1 < 0 { y1 += mod }
  return y1%mod
}

var reader = bufio.NewReaderSize(os.Stdin,1000000)
func NextLine() string {
  var line,buffer []byte
  var isPrefix bool = true
  var err error
  for ;isPrefix; {
    line,isPrefix,err = reader.ReadLine()
    if err != nil { panic(err) }
    buffer = append(buffer,line...)
  }
  return string(buffer)
}
func NextInt() int {
  n,_ := strconv.Atoi(NextLine())
  return n
}
func NextInt64Array() []int64 {
  var s []string = strings.Split(NextLine()," ")
  var a []int64 = make([]int64,len(s))
  for i:=0;i<len(s);i++ { a[i],_ = strconv.ParseInt(s[i],10,64) }
  return a
}

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

int main() {
	int a, b, c, k;
	cin >> a >> b >> c >> k;
	int output = 0;

	if (a >= k) {
		output = k;
	} else {
		if (b + a >= k) {
			output = a;
		} else {
			output = a - (k - a - b);
		}
	}
	cout << output << endl;
	return 0;
}

Measured memory_bytes: 3624
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		if (a < b) {
			System.out.println("a < b");
		} else if (a > b) {
			System.out.println("a > b");
		} else {
			System.out.println("a == b");
		}

	}
}

Measured memory_bytes: 26056
#include<bits/stdc++.h>
#define M 1000005
#define P 1000000007
#define LL long long
using namespace std;
int A[M],B[M],n,K;
char str[M];
vector<int>s; 
int p[M];
LL L[M],R[M];
bool check(int d){
	long long t=0;
	for(int i=1;i<=n;i++){
		int x=A[i]%d; 
		p[i]=x;
		t+=x;
	}
	sort(p+1,p+n+1); 
	LL sum=0;
	for(int i=1;i<=n;i++){
		sum+=p[i];
		if(sum==(n-i)*1LL*d-(t-sum))break;
	}
	return sum<=K;
	
}
int main(){
	int sum=0;
	cin>>n>>K;
	for(int i=1;i<=n;i++)scanf("%d",&A[i]),sum+=A[i];
	s.clear();
	for(int i=1;i*i<=sum;i++){
		if(sum%i==0){
			s.push_back(i);
			if(i*i!=n)s.push_back(sum/i);
		}
	}
	sort(A+1,A+n+1);
	sort(s.begin(),s.end());
	int ans=1;
	for(int i=s.size()-1;i>=1;i--){
		if(check(s[i])){
			ans=s[i];break;
		}
	} 
	printf("%d\n",ans);
	return 0;
}

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

int main(){
    int i,j,k;
    int N,M,W,H,A,B,C;
    int a,b,c;

    string S;

    cin >> a >> S >> b;

    if(S[0]=='+')cout << a+b << endl;
    else cout << a-b << endl;

}

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

using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<pair<int, int> > vpi;

ll gcd(ll a, ll b){
    ll c = a % b;
    if (c == 0)
        return b;
    return gcd(b, c);
}

int main() {
    ios::sync_with_stdio(0); cin.tie(0);
    ll a, b, i;
    cin >> a >> b;
    if (a < b){
        swap(a, b);
    }
    ll g = gcd(a, b);
    ll _g = g;
    int cnt = 1;
    for (i=2;i*i<g;i++){
        if (_g%i == 0){
            cnt++;
            while (_g%i == 0) _g /= i;
        }
    }
    if (_g!= 1) cnt++;
    cout << cnt << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vvvll = vector<vvll>;
using vs = vector<string>;
using pll = pair<ll, ll>;
using vp = vector<pll>;
#define rep(i, n) for(ll i = 0; i < (n); i++)
#define repr(i, a, b) for(ll i = (a); i < (b); i++)
#define ALL(a) (a).begin(), (a).end()
#define SZ(x) ((ll)(x).size())
const ll MOD = 1000000007;
const ll INF = 100000000000000000LL;
inline ll GCD(ll a, ll b){ return b?GCD(b, a % b):a; }
inline ll LCM(ll a, ll b){ return a/GCD(a, b)*b; }
inline ll powint(unsigned long long x, ll y){ ll r=1; while(y){ if(y&1) r*=x; x*=x; y>>=1; } return r; }
inline ll powmod(ll x, ll y, ll m = MOD){ ll r=1; while(y){ if(y&1) r*=x; x*=x; r%=m; x%=m; y>>=1; } return r; }
template<class T>bool chmax(T &a, const T &b){ if(a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b){ if(b<a) { a=b; return 1; } return 0; }
#ifdef OJ_LOCAL
#include "dump.hpp"
#else
#define dump(...) ((void)0)
#endif

void pr(){
    cout << -1 << endl;
    exit(0);
}

int main(){
    cin.tie(0); ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    ll n;
    cin >> n;
    vvll a(n+1, vll(n, 0));
    repr(i, 1, n+1){
        repr(j, 1, n){
            cin >> a[i][j];
        }
    }
    
    vll day(n+1, 0);
    vll p(n+1, 1);
    vll battle;
    ll idx = 1;
    ll cnt = 0;
    battle.emplace_back(1);
    while(!battle.empty()){
        //dump(battle);
        ll sz = SZ(battle);
        ll t = battle[sz-1];
        if(p[t] >= n){
            while(p[t] >= n){
                t++;
                if(t > n) t = 1;
            }
            battle.emplace_back(t);
        }
        idx = a[t][p[t]];
        battle.emplace_back(idx);
        if(sz >= 2 && battle[sz-2] == idx){
            ll d = max(day[battle[sz-2]], day[battle[sz-1]])+1;
            day[battle[sz-2]] = d;
            day[battle[sz-1]] = d;
            p[battle[sz-2]]++;
            p[battle[sz-1]]++;
            battle.pop_back();
            battle.pop_back();
            //dump(day);
            cnt++;
            if(cnt >= n*(n-1)/2){
                break;
            }
        }
        if(sz >= 2000000){
            pr();
        }
    }
    ll ans = 0;
    repr(i, 1, n+1){
        chmax(ans, day[i]);
    }
    cout << ans << endl;
    return 0;
}

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

const long long mod = 1e9 + 7;

using ll = long long;
using pii  = pair<int, int>;
using pll = pair<ll, ll>;
#define ull unsigned long long
#define ld long double
#define vi vector<int>
#define vll vector<ll>
#define vc vector<char>
#define vs vector<string>
#define vpii vector<pii>
#define vpll vector<pll>

#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; i++)
#define rep1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; i++)
#define repr(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rep1r(i, n) for (int i = ((int)(n)); i >= 1; i--)

#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define RSORT(x) sort(rall(x));
#define pb push_back
#define mp make_pair

#define INF (1e9)
#define PI (acos(-1))
#define EPS (1e-7)

ull gcd(ull a, ull b) { return b ? gcd(b, a % b) : a; }
ull lcm(ull a, ull b) { return a / gcd(a, b) * b; }

int main(){
    int hi, wi, m;
    cin >> hi >> wi >> m;
    vi h(m), w(m);
    set<pii> st;
    rep(i, m) {
        cin >> h[i] >> w[i];
        h[i]--; w[i]--;
        st.emplace(h[i], w[i]);
    }
    vi cnth(hi), cntw(wi);
    rep(i, m) {
        cnth[h[i]]++;
        cntw[w[i]]++;
    }
    vi lsh, lsw;
    int mxh = 0, mxw = 0;
    rep(i, hi) mxh = max(mxh, cnth[i]);
    rep(i, wi) mxw = max(mxw, cntw[i]);
    rep(i, hi) if (cnth[i] == mxh) lsh.pb(i);
    rep(i, wi) if (cntw[i] == mxw) lsw.pb(i);
    int tms = 0;
    bool ok = false;
    rep(i, sz(lsh)) rep(j, sz(lsw)) {
        ++tms;
        if (st.find({lsh[i], lsw[j]}) == st.end()) {
            ok = true;
        }
        if (tms > (int)3e5) {
            if (ok) cout << (mxh+mxw) << endl;
            else cout << (mxh+mxw-1) << endl;
            return 0;
        }
    }
    if (ok) cout << (mxh+mxw) << endl;
    else cout << (mxh+mxw-1) << endl;
    return 0;
}


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

using namespace std;

int main(){
  int h,w;
  cin >> h >> w;
  
 string a[h];
  for(int i=0;i<h;i++) cin >> a[i];
  
  string res="##";
  for(int i=0;i<w;i++) res+='#';
  
  
  cout << res << endl;
  for(int i=0;i<h;i++) cout << "#" << a[i] << "#" << endl;  
  cout << res << endl;
}

Measured memory_bytes: 256
from collections import Counter,defaultdict,deque
import sys,heapq,bisect,math,itertools,string,queue
sys.setrecursionlimit(10**8)
mod = 10**9+7
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpl_str(): return list(sys.stdin.readline().split())
def inpln(n): return list(int(sys.stdin.readline()) for i in range(n))

s = input()
n = len(s)
ans = 0
for flag in itertools.product([0,1], repeat=n-1):
    cnt = int(s[-1])
    c = 0
    for i,ff in enumerate(flag):
        if ff:
            cnt += int(s[n-i-2])
            c = 0
        else:
            cnt += int(s[n-i-2]) * 10 ** (c+1)
            c += 1
    # print(cnt)
    ans += cnt
print(ans)


Measured memory_bytes: 44780
X = int(input())

y = int((X**0.2) //1 + 1)

def array(y):
    a = [0]
    for i in range(1,y+1):
        a.append(i**5)
        a.append(-i**5)
    a.sort()
    return a

y = y*2
a = array(y)

N = len(a)
for i in range(N-1):
    for j in range(i+1,N):
        if a[j] - a[i] == X:
            A,B = -y+j, -y+i

print(A,B)

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

int main(){
  int n,k,q; cin >> n >> k >> q;
  vector<int> A(n+1, 0);
  for(int i=1;i<=q;i++){
    int a; cin >> a;
    A[a]++;
  }
  
  for(int i=1;i<=n;i++){
    if(k - q + A[i] > 0) cout << "Yes" << endl;
    else cout << "No" << endl;
  }
  return 0;
}

Measured memory_bytes: 1024
#include <stdio.h>
typedef long long ll;

int main(void) {
  ll n, i, j;
  scanf("%lld", &n);
  for(i = 1; i <= 3500; ++i) for(j = 1; j <= 3500; ++j) if(4 * i * j - i * n - j * n > 0 && !((n * i * j) % (4 * i * j - i * n - j * n))) {
    printf("%lld %lld %lld", i, j, (n * i * j) / (4 * i * j - i * n - j * n));
    return 0;
  }
}

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

int main()
{
    long long N, W;
    cin >> N >> W;

    long long V = 100000;

    long long w[N+1], v[N+1];
    for(long long i = 1; i <= N; i++) cin >> w[i] >> v[i];

    long long DP[V+1]; //minimum weight required to get objects of collective value >= i
    DP[0] = 0;
    for(long long j = 1; j <= V; j++) DP[j] = 2000000000;

    for(long long i = 1; i <= N; i++)
    {
        for(long long j = V; j >= v[i]; j--) DP[j] = min(DP[j], DP[j - v[i]] + w[i]);
        for(long long j = V-1; j >= 0; j--) DP[j] = min(DP[j], DP[j+1]);
    }
    long long res = 0;
    for(long long j = 0; j <= V; j++) if(DP[j] <= W) res = j;
    cout << res << '\n';
    return 0;
}


Measured memory_bytes: 1152