akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <numeric>
#include <string>
#include <cstdio>
#include <cstring>
#include <queue>
#include <stack>
#include <set>
#include <cmath>
#include <bitset>

typedef long long ll;
using namespace std;

#define FALSE printf("false\n");
#define TRUE printf("true\n");
#define all(x) (x).begin(),(x).end()
#define print(x) cout<<(x)<<endl
#define rep(i,n) for(int i = 0;i < ((int)(n));++i)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define SUM(vec) accumulate(all(vec),0LL)
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
#define test(a) cout<<"line:"<<__LINE__<<"["<<(#a)<<": "<<(a)<<"]"<<endl

const int INF = 1e9+7;
const ll INFL = 9*1e18;

ll inline digit(ll num){int tmp = 0;while(num){tmp++;num/=10;}return tmp;}
template<typename T>inline T digitSum(T num){T sum = 0;while(num){sum+=num%10;num/=10;}return sum;} // 各桁の和
template<typename T>inline T gcd(T a,T b){if(b == 0)return a;return gcd(b,a%b);}
template<typename T>inline T lcm(T a, T b){T g = gcd(a,b);return a/g*b;}
template<typename T>inline T power(T a,T b){T tmp=1;rep(i,b){tmp*=a;}return tmp;}


bool isOk(ll key,ll value){
  return key >= value;
}

ll binary_search(vector<ll> a,ll key){
  ll ok = a.size()-1;
  ll ng = 0;

  while(abs(ok - ng) > 1){
    ll mid = (ok + ng) / 2;
    if(isOk(key,a[mid]))ok = mid;
    else ng = mid;
  }
  return ok;
}

int main() {
  cin.tie(0); ios::sync_with_stdio(0);
  ll a,b,c;cin>>a>>b>>c;
  a -= c;
  b += min(a,0ll);
  b = max(b,0ll);
  a = max(a,0ll);
  cout<<a<<' '<<b<<endl;
  return 0;
}

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

int main() {
    int n, m,ans=0;
    cin>>n>>m;
    int a,b, h[n];
    vector<vector<int>> v(n);
    rep(i,n)cin>>h[i];
    rep(i,m){
        cin>>a>>b;
        v[a-1].push_back(b-1);
        v[b-1].push_back(a-1);
    }
    rep(i,n){
        int flag = 1;
        while(!v[i].empty()){
            if(h[v[i].back()]>=h[i])flag=0;
            v[i].pop_back();
        }
    ans+=flag;
    }
    cout << ans <<endl;
}


Measured memory_bytes: 8804
#

import itertools
from collections import Counter
from collections import defaultdict
from collections import deque
import bisect
from heapq import heappush, heappop

def main():
    n = int(input())
    ans = 0
    if n < 10:
        print(n)
        return

    ans = 9  # 1-9
    if n < 100:
        print(ans)
        return

    if n < 1000:
        ans += (n - 100 + 1)
        print(ans)
        return
    ans += 900  # 100-999

    if n < 10000:
        print(ans)
        return

    if n < 100000:
        ans += (n - 10000 + 1)
        print(ans)
        return
    ans += 90000  # 10000-99999

    print(ans)

if __name__ == '__main__':
    main()


Measured memory_bytes: 38384
n=int(input())
p=list(map(int,input().split()))
s=0
for i in range(1,n-1):
    if p[i-1]<p[i] and p[i]<p[i+1]:s+=1
    if p[i-1]>p[i] and p[i]>p[i+1]:s+=1
print(s)


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

using namespace std;
long long mod = 1e9+7;
int mod13[10][6]={
{0,0, 0, 0, 0, 0},
{1,10,9, 12,3, 4},
{2,7, 5, 11,6, 8},
{3,4, 1, 10,9, 12},
{4,1, 10,9, 12,3},
{5,11,6, 8, 2, 7},
{6,8, 2, 7, 5, 11},
{7,5, 11,6, 8, 2},
{8,2, 7, 5, 11,6},
{9,12,3, 4, 1, 10}
};
int main()
{
    vector<long long> a;
    vector<long long> starea;
    int pom = 1;
    int pod = 0;
    string s;
    cin>>s;
    a.assign(13,0);
    starea.assign(13,0);
    int kt=0;
    bool pierwsze=true;
    for(int i = s.size()-1;i>=0;i--)
    {
        if(s[i]=='?')
        {
            for(int j = 0;j<13;j++)a[j]=0;
            for(int j = 0;j<10;j++)
            {
                for(int k = 0;k<13;k++)
                {
                    a[(mod13[j][kt]+k)%13]=(a[(mod13[j][kt]+k)%13]+starea[k])%mod;
                }
                if(pierwsze)a[mod13[j][kt]]=(a[mod13[j][kt]]+1)%mod;
            }
            pierwsze=false;
            for(int j = 0;j<13;j++)starea[j]=a[j];

        }else{
            pod=(pod+(s[i]-'0')*pom)%13;
        }
        pom=(pom*10)%13;
        kt++;
        if(kt==6)kt=0;
    }
    if(pod==5&&a[0]==0){a[0]=1;}
    //cout<<pod<<"pod\n\n";
    //for(int i = 0;i<13;i++)cout<<a[i]<<"\n";
    cout<<a[(18-pod)%13];
}


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

inline int read(){
    char ch=getchar();
    int x=0,f=1;
    while(ch<'0'||ch>'9'){if(ch=='-') f=-1;ch=getchar();}
    while(ch>='0'&&ch<='9') x=x*10+(ch^48),ch=getchar();
    return x*f;
} 

int a, b, c; 

int main(){
    ios::sync_with_stdio(false);
	cin.tie(0);
    //freopen(".in","r",stdin);
	//freopen(".out","w",stdout); 
	
	cin >> a >> b >> c;
	
	cout << c << " " << a << " " << b;
	
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <tuple>
#include <algorithm>
#include <numeric>
#include <climits>
#include <map>
#include <functional>
#include <cmath>
#include <cassert>
#include <set>
#include <stack>

using namespace std;

template<typename T>inline T get(){T x;cin>>x;return x;}

int main()
{
    map<int,set<int>> xindex;
    map<int,set<int>> yindex;

    int n = get<int>();
    vector<int> a(n), b(n);
    vector<bool> visited(n);
    for (int i = 0; i < n; i++) {
        a[i] = get<int>(), b[i] = get<int>();
        xindex[a[i]].insert(i);
        yindex[b[i]].insert(i);
    }
    long ans = 0;
    for (int i = 0; i < n; i++) {
        if (visited[i]) continue;

        set<int> xset;
        set<int> yset;
        function<long(int)> dfs = [&](int j) {
            if (visited[j]) return 0L;
            xset.insert(a[j]);
            yset.insert(b[j]);
            visited[j] = true;
            long r = 1;
            for (int k : xindex[a[j]])
                r += dfs(k);
            for (int k : yindex[b[j]])
                r += dfs(k);
            return r;
        };
        long r = dfs(i);
        ans += xset.size() * yset.size() - r;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 33792
export class Main {
  static main(input): string {
    const tmp: string[] = input.split("\n");
    const [n, x]: number[] = tmp[0].split(" ").map(Number);
    const l: number[] = tmp[1].split(" ").map(Number);
    let d: number = 0;
    let result: number = 1;
    for (let i: number = 0; i < n; ++i) {
      d += l[i];
      if (d <= x) {
        ++result;
      } else {
        break;
      }
    }
    return `${result}`;
  }
}
console.log(Main.main(require("fs").readFileSync("/dev/stdin", "utf8")));

Measured memory_bytes: 7372
#include<bits/stdc++.h>
using namespace std;
#define vi vector<int>
#define sl set<ll>
#define vs vector<string>
#define vl vector<ll>
#define vi vector<int>
#define vpl vector<pair<ll,ll>>
#define pb push_back
#define PI 3.14159265358979323846
#define ll long long
#define ld long double
#define endl "\n"
#define rep(i,a,b) for (ll i = (a); i < (b); i++)
#define repp(i,a,b) for (ll i = (a); i >= (b); i--)
#define rop(i,a,b)  for(ll i=(a); i>(b); i--)
#define min3(a, b, c) min(c, min(a, b))
#define min4(a, b, c, d) min(d, min(c, min(a, b)))
#define tt long long t; cin>>t; while(t--)
#define IOS ios::sync_with_stdio(0);cin.tie(0);
const int maxn=1e5+100;


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

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

using int32 = int_fast32_t;
using int64 = int_fast64_t;

const int32 INF = 1e9;
const int32 MOD = 1e9+7;
const int64 LLINF = 1e18;

#define YES(n) cout << ((n) ? "YES\n" : "NO\n"  )
#define Yes(n) cout << ((n) ? "Yes\n" : "No\n"  )
#define ANS(n) cout << (n) << "\n"
#define REP(i,n) for(int64 i=0;i<(n);++i)
#define FOR(i,a,b) for(int64 i=(a);i<(b);i++)
#define FORR(i,a,b) for(int64 i=(a);i>=(b);i--)
#define ALL(obj) (obj).begin(),(obj).end()
#define pii pair<int32,int32>
#define pll pair<int64,int64>
#define pb(a) push_back(a)
#define mp make_pair

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int32 n,m;
    cin >> n >> m;
    map<int32,int32> x;
    REP(i,n){
        int32 xi;
        cin >> xi;
        x[xi]++;
    }
    map<int32,int32> xmodm;
    vector<int32> samepair(m,0);
    for(pii p : x){
        samepair[p.first%m] += p.second / 2;
        xmodm[p.first%m] += p.second;
    }
    int64 ans = 0;
    REP(i,m/2+1){
        if(i * 2 == m || i == 0){
            ans += xmodm[i] / 2;
        }else{
            if(xmodm[i] == xmodm[m-i]){
                ans += xmodm[i];
            }else if(xmodm[i] > xmodm[m-i]){
                ans += xmodm[m-i];
                xmodm[i] -= xmodm[m-i];
                ans += min(xmodm[i] / 2, samepair[i]);
            }else{
                ans += xmodm[i];
                xmodm[m-i] -= xmodm[i];
                ans += min(xmodm[m-i] / 2, samepair[m-i]);
            }
        }
    }
    // ostream_iterator<int32> out_it(cout, " ");
    // copy(ALL(samepair), out_it);
    // cout << endl;
    ANS(ans);
    return 0;
}

Measured memory_bytes: 13568
#include <algorithm>
#include <cmath>
#include <complex>
#include <cstdio>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
#define MOD 1000000007
#define MOD2 998244353
#define PRIM 3
#define INF (1 << 29)
#define LINF (1LL << 60)
#define EPS (1e-10)
#define PI 3.1415926535897932384626433832795028
typedef long long Int;
typedef pair<Int, Int> P;
typedef long double Real;
typedef complex<Real> CP;

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

Int inside(Int x1, Int y1, Int x2, Int y2)
{
    Int s = abs(x1 * y2 - x2 * y1);
    s += 2;
    s -= gcd(abs(x1), abs(y1));
    s -= gcd(abs(x2), abs(y2));
    s -= gcd(abs(x2 - x1), abs(y2 - y1));
    return s / 2;
}

Int cnt(Int w, Int h, Int k)
{
    Int ans = 0;
    for (Int x = 1; x < w; x++) {
        for (Int s = 0; s < h - 1; s++) {
            if (inside(1, x, -s, w) > 2 * k)
                break;
            if (inside(1, x, -s, w) > k)
                continue;
            Int R = 2 * k - x * s - 2 + gcd(w, s);
            Int bottom = max(1LL, R / w), top = min(h - s, R / w + 2);
            bottom = min(bottom, top - 1);
            while (top - bottom > 1) {
                Int mid = (top + bottom) / 2;
                if (inside(mid, x, -s, w) <= k)
                    bottom = mid;
                else
                    top = mid;
            }
            if (s == 0)
                ans += bottom;
            else
                ans += bottom * 2;
        }
    }
    return ans;
}

int main()
{
    Int w, h, k;
    cin >> w >> h >> k;
    cout << 2 * cnt(w, h, k) + 2 * cnt(h, w, k) << endl;
    return 0;
}

Measured memory_bytes: 3196
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
typedef long long ll;

constexpr ll mod=1e9+7;

ll mod_pow(ll a,ll b){
	a%=mod;
	if(b==0)return 1;
	if(b==1)return a;
	ll res=mod_pow(a,b/2)%mod;
	res*=res; res%=mod;
	if(b%2)res*=a;
	return res%mod;
}

struct perm{
private:
	int sz;
	vector<ll> p,invp;
public:
	perm(int n){
		sz=n+1;
		p.resize(sz),invp.resize(sz);
		p[0]=1;
		for(int i=1;i<=sz-1;i++){
			p[i]=p[i-1]*i%mod;
		}
		invp[sz-1]=mod_pow(p[sz-1],mod-2);
		for(int i=sz-2;i>=0;i--){
			invp[i]=invp[i+1]*(i+1)%mod;
		}
	}
	ll comb(ll x,ll y){
		if(x<y||y<0)return 0;
		return (p[x]*invp[x-y]%mod)*invp[y]%mod;
	}
};
perm p(1<<20);

int main(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	int s; cin >> s;
	ll res=0;
	for(int i=1;i<=s;i++){
		if(3*i>s)break;
		int t=s-3*i;
		(res+=p.comb(t+i-1,t))%=mod;
	}
	cout << res << endl;
}

Measured memory_bytes: 19428
#include <cstdio>
#include <vector>

using namespace std;

int n, k;
char s[111111];
pair<int, int> ps[111111];
int pl = 0;

int main(void) {
  scanf("%d%d%s", &n, &k, s);
  for (int i = 0; i < n; i++) {
    int j = i;
    while (s[i] == s[j]) ++j;
    ps[pl++] = {s[i], j - i};
    i = j - 1;
  }

  int res = 0;
  int a, b, c, d;
  a = b = c = d = 0;
  while (a < pl) {
    // printf("%d %d\n", a, b);
    while (b < pl && c + (ps[b].first == '0') <= k) {
      if (ps[b].first == '0') c += 1;
      d += ps[b].second;
      b++;
    }
    res = max(res, d);
    if (ps[a].first == '0') c -= 1;
    d -= ps[a].second;
    a += 1;
  }

  printf("%d\n", res);
  return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#include <vector>
#define ipair pair<int,int>
#define rep(I,N) for(int I=0; I<N; I++)
#define repj(i,j,n) for(int i=j;i<n;i++)

#define PB(a,i) (a).push_back(i)
#define ALL(a) (a).begin(),(a).end()

#define OK(i) cout<<"OK "<<i<<endl
#define Yes cout<<"Yes"<<endl
#define YES cout<<"YES"<<endl
#define No cout<<"No"<<endl
#define NO cout<<"NO"<<endl

using namespace std;

typedef long long int lli;
typedef long long ll;
typedef vector<int> vi;
typedef vector< vector<int> > Matrix;

int gcd (int a, int b)
{
  int tmp, r;
  if (a<b){
    tmp = a;
    a = b;
    b = tmp;
  }

  r = a % b;
  while(r!=0){
    a = b;
    b = r;
    r = a % b;
  }

  return b;
}

int main ()
{
  int N, X;
  cin >> N >> X;
  int *x = new int[N];
  rep(i, N) {
    cin >> x[i];
    x[i] = abs(X-x[i]);
  }

  int small_gcd = x[0];
  rep(i, N) {
    small_gcd = gcd(small_gcd, x[i]);
  }

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




Measured memory_bytes: 640
#include<iostream>
using namespace std;
int main()
{
int a,b,c;
scanf("%d/%d/%d",&a,&b,&c);
if((a>2019)||(a==2019&&b>4)||(a==2019&&b==4&&c>30))cout<<"TBD\n";
else cout<<"Heisei\n";
return 0;
}

Measured memory_bytes: 256
using System;
using System.Linq;

namespace _0027
{
    class Program
    {
        static void Main(string[] args)
        {
            while (true)
            {
                int[] x = Console.ReadLine().Split().Select(int.Parse).ToArray();
                if (x[0] == 0)
                {
                    break;
                }
                if (x[0] > 1)
                {
                    x[1] += 31;
                }
                if (x[0] > 2)
                {
                    x[1] += 29;
                }
                if (x[0] > 3)
                {
                    x[1] += 31;
                }
                if (x[0] > 4)
                {
                    x[1] += 30;
                }
                if (x[0] > 5)
                {
                    x[1] += 31;
                }
                if (x[0] > 6)
                {
                    x[1] += 30;
                }
                if (x[0] > 7)
                {
                    x[1] += 31;
                }
                if (x[0] > 8)
                {
                    x[1] += 31;
                }
                if (x[0] > 9)
                {
                    x[1] += 30;
                }
                if (x[0] > 10)
                {
                    x[1] += 31;
                }
                if (x[0] > 11)
                {
                    x[1] += 30;
                }
                if (x[1] % 7 == 0)
                {
                    Console.WriteLine("Wednesday");
                }
                else if (x[1] % 7 == 1)
                {
                    Console.WriteLine("Thursday");
                }
                else if (x[1] % 7 == 2)
                {
                    Console.WriteLine("Friday");
                }
                else if (x[1] % 7 == 3)
                {
                    Console.WriteLine("Saturday");
                }
                else if (x[1] % 7 == 4)
                {
                    Console.WriteLine("Sunday");
                }
                else if (x[1] % 7 == 5)
                {
                    Console.WriteLine("Monday");
                }
                else if (x[1] % 7 == 6)
                {
                    Console.WriteLine("Tuesday");
                }
            }
        }
    }
}

Measured memory_bytes: 9340
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0;i<int(N);++i)
#define rep1(i,N) for(int i=1;i<int(N);++i)
#define all(a) (a).begin(),(a).end()		//sort(all(vi S)) sort(all(string S))
#define print(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<_<<", "; cerr<<"]"<<endl; }
#define printpair(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<"{"<<_.first<<","<<_.second<<"}"<<", "; cerr<<"]"<<endl; }

using P = pair<int, int>;		//P.first, P.second
typedef long long ll;
typedef vector<int> vi;
typedef set<int> seti;
typedef vector<string> vs;

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

int main() {
	string S;
	cin>>S;
	// 全探索 --- bit は {0, 1, ..., n-1} の 2^n 通りの部分集合全体を動きます。
	for (int bit = 0; bit < (1<<3); ++bit){
		int res = S[0] - '0';
		string ans = "";
		ans.push_back(S[0]);
		/* bit で表される集合の処理を書く */
		for (int i = 0; i < 3; ++i){
			if(bit & 1<<i){
				res += S[i+1] - '0';
				ans.push_back('+');
				ans.push_back(S[i+1]);
			}
			else{
				res -= S[i+1] - '0';
				ans.push_back('-');
				ans.push_back(S[i+1]);
			}
		}
		if(res == 7){
			cout<<ans<<"=7"<<endl;
			break;
		}
	}	
}

Measured memory_bytes: 256
from collections import defaultdict
ans=defaultdict(int)
n=int(input())
ans["AC"]=0
ans["WA"]=0
ans["TLE"]=0
ans["RE"]=0
for i in range(n):
    ans[input()]+=1
print("AC x ",ans["AC"])
print("WA x ",ans["WA"])
print("TLE x ",ans["TLE"])
print("RE x ",ans["RE"])

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

using namespace std;

typedef long long ll;
const int N=2e5+100;
int mod=998244353;

ll fac[N],inv[N];
int n,m,k;
ll qpow(ll x,ll n)
{
   //if(x==0) return 0;
  //  x%=mod;
    ll sum=1;
    while(n){
        if(n&1) sum=sum*x%mod;
        x=x*x%mod;
        n>>=1;
    }
    return sum;
}
void init()
{
    fac[0]=1;
    for(int i=1;i<=N-1;i++) fac[i]=fac[i-1]*i%mod;
    inv[N-1]=qpow(fac[N-1],mod-2);
    for(int i=N-2;i>=0;i--) inv[i]=inv[i+1]*(i+1)%mod;
}
ll get(int x,int y)
{
    return fac[x]*inv[y]%mod*inv[x-y]%mod;
}
int main()
{
    scanf("%d%d%d",&n,&m,&k);
    init();
    ll ans=0;
    for(int i=0;i<=k;i++)
        ans=(ans+m*get(n-1,i)%mod*qpow(m-1,n-1-i))%mod;
    printf("%lld\n",ans);
    return 0;
}



Measured memory_bytes: 6936
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <climits>
#include <string>
#include <bitset>
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<ll> > vvll;
#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)
#define fin(ans) cout<<(ans)<<endl
#define STI(s) atoi(s.c_str())
#define mp(p,q) make_pair(p,q)
#define pb(n) push_back(n)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define Sort(a) sort(a.begin(),a.end())
#define Rort(a) sort(a.rbegin(),a.rend())
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 P = 1000000007;
const int INF = INT_MAX;
const ll LLINF = 1LL<<60;


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

    
    bool ch=true;
    int n;
    cin>>n;
    vi v(n);
    rep(i,n)cin>>v[i];
    int a=v[0];
    for(int i=1;i<n;i++){
        if(v[i]>a){
            v[i]--;
            a=v[i];
        }
        else if(v[i]==a){
            continue;
        }
        else{
            ch=false;
        }
    }
    if(ch)fin("Yes");
    else fin("No");




//////////////////////////////////////////////////////
return 0;}

Measured memory_bytes: 640
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <queue>
#include <map>
#include <cmath>
#include <numeric>
#include <iomanip>
#include <set>
#include <string.h>

using namespace std;

typedef long long ll;

#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)
#define REP3(i,st,en) for(ll (i)=(st);(i)<(en);(i)++)

using P = pair<ll, ll>;
const int MOD = 1e9+7;
const ll INF = 1e+14;
const double PI = 3.14159265349;

/*
Euclidean Algorithm
 */
ll euclid(ll a, ll b){
  while (b>0){
    a = a % b;
    swap(a, b);
  }
  return a;
}

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

  ll A, B;
  cin >> A >> B;
  

  ll ans = 1; // include 1
  ll gcd = euclid(A,B);
  
  ll d=2;
  while(d*d<=gcd){
    if (gcd%d==0){
      ans++;
      while (gcd%d==0){
        gcd /= d;
      }
    }
    d++;
  }
  if (gcd != 1) ans++;

  cout << ans <<  "\n";
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, begin, end) for(ll i=(begin);i<(end);i++)
#define REP(i, n) FOR(i,0,n)
#define IFOR(i, begin, end) for(ll i=(begin)-1;i>=(end);i--)
#define IREP(i, n) IFOR(i,n,0)
#define SORT(a) sort(a.begin(), a.end())	//昇順
#define ISORT(a) sort(a.begin(), a.end(),greater<ll>())	//降順
#define REVERSE(a) reverse(a.begin(), a.end())
#define debug(x) cout << #x << "=" << x << endl;
#define vdebug(v) cout << #v << "=(" << v[0]; FOR(i_debug, 1, v.size()){ cout << "," << v[i_debug]; } cout << ")" << endl;
#define mdebug(m) cout << #m << "=" << endl; REP(i_debug, m.size()){ REP(j_debug, m[i_debug].size()){ cout << m[i_debug][j_debug] << ","; } cout << endl;}
#define Lower_bound(v, x) distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) distance(v.begin(), upper_bound(v.begin(), v.end(), x))
#define Max(a, b) a = max(a, b)
#define Min(a, b) a = min(a, b)

#define ll long long
#define ld long double
#define f first
#define s second
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define INF 1000000000000000000


using vec = vector<ll>;
using mat = vector<vec>;
using Pii = pair<ll, ll>;
using PiP = pair<ll, Pii>;
using PPi = pair<Pii, ll>;
using bvec = vector<bool>;
using Pvec = vector<Pii>;


template<typename T> void readv(vector<T> &a) { REP(i, a.size()) cin >> a[i]; }
void readv_m1(vector<int> &a) { REP(i, a.size()) {cin >> a[i]; a[i]--;} }

ll mod = 1000000007;

int main()
{
	// 入力
	string S;
	cin >> S;

	ll N = S.length() + 1;
	vec a(N, -1);

	a[0] = 0;
	// ll sum = 0;
	// ll mina = a[0];
	FOR(i, 1, N ) {
		if (S[i - 1] == '<') a[i] = a[i - 1] + 1;
		else break;
	}
	// vdebug(a);

	REP(i, N - 2) {
		if (S[i] == '>' && S[i + 1] == '<') {
			ll minval = i + 1;
			a[minval] = 0;
			ll j = minval;
			while (j > 0 && S[j - 1] == '>') {
				a[j - 1] = a[j] + 1;
				j--;
				if (j > 0 && S[j - 1] == '<') a[j ] = max(a[j + 1] + 1, a[j - 1] + 1);
			}
			j = minval + 1;
			while (j < N && S[j - 1] == '<') {
				a[j] = a[j - 1] + 1;
				j++;
				if (j < N && S[j - 1] == '>') a[j ] = max(a[j + 1] + 1, a[j - 1] + 1);
			}
		}

	}
	// vdebug(a);

	if (S[N - 2] == '>') {
		ll j = N - 1;
		a[j] = 0;
		// j--;
		while (j > 0 && S[j - 1] == '>') {
			a[j - 1] = a[j] + 1;
			j--;
			if (j > 0 && S[j - 1] == '<') a[j] = max(a[j + 1] + 1, a[j - 1] + 1);
		}
	}

	ll sum = 0;
	REP(i, N) {
		sum += a[i];
	}

	ll ans = sum;
	// vdebug(a);
	cout << ans << endl;

	return 0;
}




Measured memory_bytes: 4740
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, gcd
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from functools import reduce
from bisect import bisect_left, insort_left
from heapq import heapify, heappush, heappop

INPUT = lambda: sys.stdin.readline().rstrip()
INT = lambda: int(INPUT())
MAP = lambda: map(int, INPUT().split())
S_MAP = lambda: map(str, INPUT().split())
LIST = lambda: list(map(int, INPUT().split()))
S_LIST = lambda: list(map(str, INPUT().split()))

sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7


def main():
    N = INT()
    S = INPUT()

    ans = 1
    for n in set(S):
        ans *= S.count(n) + 1

    print((ans - 1) % mod)


if __name__ == '__main__':
    main()


Measured memory_bytes: 10040
import java.io.BufferedWriter;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.util.*;

public class Main {



    public static void main(String[] args) {
       Scanner sc = new Scanner(System.in);
      int test = sc.nextInt();
        HashMap<String,Integer> hm = new HashMap<>();
        int max =0; int count=0;
      for(int ii=0; ii<test; ii++) {
          String s = sc.next();
          if (hm.containsKey(s)) {
              Integer x = hm.get(s);
              x++;
              hm.put(s, x);
              if (x == max)
                  count++;
              if (x > max)
                  max = x;
          } else {
              hm.put(s, 1);
              if (1 == max)
                  count++;
              if (1 > max)
                  max = 1;
          }
      }
    List<String> al = new ArrayList<>();
      for(Map.Entry<String,Integer> map : hm.entrySet()){
          int y = map.getValue();
          if(y == max)
            al.add(map.getKey());
      }
      Collections.sort(al);
      for(String xx : al)
          System.out.println(xx);

    }
}

Measured memory_bytes: 83716
#include <cstdio>
#include <cstring>
#include <algorithm>

const int N = 50 + 10;

int n;
char s[N][N];

int ans[N];

int main() {
  scanf("%d", &n);
  for (int i = 0; i < n; ++i) scanf(" %s", s[i]);
  memset(ans, 0x3f, sizeof ans);
  for (int i = 0; i < n; ++i) {
    static int cur[N];
    memset(cur, 0, sizeof cur);
    for (char *j = s[i]; *j; ++j) ++cur[*j - 'a'];
    for (int j = 0; j < 26; ++j) ans[j] = std::min(ans[j], cur[j]);
  }
  for (int j = 0; j < 26; ++j)
    for (int i = ans[j]; i--;)
      putchar(j + 'a');
  putchar('\n');
  return 0;
}


Measured memory_bytes: 128
#include <algorithm>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <tuple>
#include <vector>

using namespace std;

#define rep(i, n) for (int64_t i = 0; i < (n); i++)
#define irep(i, n) for (int64_t i = 0; i <= (n); i++)
#define rrep(i, n) for (int64_t i = (n)-1; i >= 0; i--)
#define rirep(i, n) for (int64_t i = n; i >= 0; i--)

int main()
{
    int n, k;
    cin >> n >> k;
    vector<int> h(n);
    rep(i, n)
    {
        cin >> h[i];
    }
    sort(h.begin(), h.end());

    int result = numeric_limits<int>::max();
    irep(i, n - k)
    {
        result = min(result, h[i + k - 1] - h[i]);
    }
    cout << result << endl;

    return 0;
}

Measured memory_bytes: 640
#include <stdio.h>
#include <stdlib.h>

struct C {
  char a;
  int b;
};

int N;

int isStable(struct C b[], struct C s[]){
  int i;

  for(i = 0; i < N; i++){
    if(b[i].a != s[i].a)  return 0;
  }
  return 1;
}

void BubbleSort(struct C c[]){ //??????
  int i, j;
  struct C k;

  for(i = 0; i < N; i++){
    for(j = N-1; j >= i+1; j--){
      if(c[j].b < c[j-1].b){
	k = c[j];
	c[j] = c[j-1];
	c[j-1] = k;
      }
    }
  }
}

void SelectionSort(struct C c[]){ //?????????
  int i, j, minj;
  struct C k;

  for(i = 0; i < N; i++){
    minj = i;
    for(j = i; j < N; j++){
      if(c[j].b < c[minj].b)  minj = j;
    }
    k = c[i];
    c[i] = c[minj];
    c[minj] = k;
  }
}

int main()
{
  struct C s[36], b[36];
  char x[2];
  int i;
  
  scanf("%d", &N);
  for(i = 0; i < N; i++){
    scanf("%s", x);
    b[i].a = x[0];
    b[i].b = atoi(&x[1]);
  }
  for(i = 0; i < N; i++)  s[i] = b[i];
  BubbleSort(b);
  SelectionSort(s);

  for(i = 0; i < N; i++){
    printf("%c%d", b[i].a, b[i].b);
    if(i < N - 1) printf(" ");
    else printf("\n");
  }
  printf("Stable\n");

  for(i = 0; i < N; i++){
    printf("%c%d", s[i].a, s[i].b);
    if(i < N - 1) printf(" ");
    else printf("\n");
  }
  if(isStable(b, s)) printf("Stable\n");
  else printf("Not stable\n");

  return 0;
}

Measured memory_bytes: 612
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define A first
#define B second
#define mod 1000000007
vector<ll> arr;
vector<ll> primes(1e6+7, 0);
set<ll> distinct;
void primeFactorization(ll num)
{
    int counter = 0;
    for (int i = 2; i * i<= num ; ++i) {
        counter = 0;
        while(num%i == 0)
        {
            num /= i;
            counter++;
        }
        if(counter > 0)
        {
            distinct.insert(i);
            if(counter > primes[i])
                primes[i] = counter;
        }
    }
    if(num > 1)
    {
        distinct.insert(num);
        if(primes[num] == 0)
            primes[num]++;
    }
}
ll fp(ll base, ll exp)
{
    if (exp == 0)
        return 1;
    ll ans = fp(base, exp / 2);
    ans = (ans * ans) % mod;
    if (exp % 2 != 0)
        ans = (ans * (base % mod)) % mod;
    return ans;
}
int main() {
    ll num;
    cin>>num;
    arr.resize(num);
    for (int i = 0; i < num; ++i) {
        cin>>arr[i];
        primeFactorization(arr[i]);
    }
    ll sum = 1;
    for(auto it : distinct)
    {
        sum = (sum % mod * (fp(it, primes[it]) % mod)) % mod;
    }
    ll result = 0;
    for (int i = 0; i < num; ++i) {
        result = (result % mod + (sum * (fp(arr[i], mod-2)) % mod) % mod) % mod;
    }
    cout<<result;
}


Measured memory_bytes: 8576
#include<stdio.h>

int main(void){
    int a[100];
    int N,M,i;
    double all=0;
    scanf("%d %d",&N,&M);
    for(i=0;i<N;i++){
        scanf("%d",&a[i]);
        all+=a[i];
    }
    int les=0;
    for(i=0;i<N;i++){
        if(a[i]*4*M >= all)
            les++;
    }
    if(les>=M){
        printf("Yes\n");
    }
    else{
        printf("No\n");
    }
    return 0;
}


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

import static java.lang.System.*;

public class Main {
    BufferedReader rd;

    Main() throws IOException {
        rd = new BufferedReader(new InputStreamReader(System.in));
        compute();
    }

    private void compute() throws IOException {
        char[] pat = rd.readLine().toCharArray();
        int n = pat.length;
        char[] sub = rd.readLine().toCharArray();
        int m = sub.length;
        for(int i=n-m;i>=0;i--) {
            boolean ok = true;
            for(int j=0;j<m;j++) {
                if(pat[i+j] != '?' && pat[i+j] != sub[j]) {
                    ok = false;
                    break;
                }
            }
            if(ok) {
                arraycopy(sub,0,pat,i,m);
                for(int k=0;k<n;k++) {
                    if(pat[k] == '?') {
                        pat[k] = 'a';
                    }
                }
                out(new String(pat));
                return;
            }
        }
        out("UNRESTORABLE");
    }

    private static void out(Object x) {
        System.out.println(x);
    }

    public static void main(String[] args) throws IOException {
        new Main();
    }
}


Measured memory_bytes: 22996
#include<iostream>
#include<stdio.h>
#include<vector>
#include<algorithm>
#include<set>
#include<string>
#include<map>
#include<string.h>
#include<complex>
#include<math.h>
#include<queue>
#include <functional>
#include<time.h>
#include <stack>
#include<iomanip>
#include<unordered_map>
using namespace std;
#define rep(i,a,n) for(int i=(a);i<(n);i++)
#define ll long long
#define llint long long int
#define sort(s) sort(s.begin(),s.end())
#define reverse(v)  reverse(v.begin(), v.end());
#define Yes(ans) if(ans)cout<<"Yes"<<endl; else cout<<"No"<<endl;
#define YES(ans) if(ans)cout<<"YES"<<endl; else cout<<"NO"<<endl;
#define hei(a) vector<a>
#define whei(a) vector<vector<a>>
#define UF  UnionFind
#define rt (a); return (a); 
#define Pint pair<int,int>
#define Pll pair<ll,ll>
#define keta(a)  fixed << setprecision(a)
constexpr auto INF = 1000000000;
constexpr auto mod = 1000000007;
ll gcd(ll a, ll b) {
	if (a < b)swap(a, b);
	if (b == 0)return a;
	return gcd(b, a % b);
}

struct UnionFind {
	vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2

	UnionFind(int N) : par(N) { //最初は全てが根であるとして初期化
		for (int i = 0; i < N; i++) par[i] = i;
	}
	int size(int a) {
		return par[root(a)];
	}

	int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
		if (par[x] == x) return x;
		return par[x] = root(par[x]);
	}

	void unite(int x, int y) { // xとyの木を併合
		int rx = root(x); //xの根をrx
		int ry = root(y); //yの根をry
		if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
		par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
	}

	bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
		int rx = root(x);
		int ry = root(y);
		return rx == ry;
	}
};
int gcd(int a, int b) {
	if (b > a)swap(b, a);
	if (b == 0)return a;
	return gcd(b, a % b);
}

int main() {
	string s;
	int k;
	cin >> s;
	cin >> k;
	rep(i, 0, s.size()) {
		if (s[i] == 'a')continue;
		if (s[i] + k >= 123){
			k -= (123 - s[i]);
			s[i] = 'a';
		}
	}
	s[s.size() - 1] += k % 26;
	cout << s << endl;

	return 0;
}

Measured memory_bytes: 3752
def main():
    from collections import defaultdict
    import sys
    input = sys.stdin.readline

    N = int(input())

    d = defaultdict(int)

    def string_sort(s):
        return ''.join(sorted(s))

    ans = 0
    for _ in range(N):
        s = string_sort(input().rstrip())
        ans += d[s]
        d[s] += 1
    print(ans)


if __name__ == '__main__':
    main()

# import sys
#
# sys.setrecursionlimit(10 ** 7)
#
# input = sys.stdin.readline
# rstrip()
# int(input())
# map(int, input().split())


Measured memory_bytes: 18188
import java.util.*;

class Main {
    static Scanner sc = new Scanner(System.in);
    static int w,h;
    static char[][] map;
    static int[] dx = {-1, 0, 0, 1};
    static int[] dy = { 0,-1, 1, 0}; 
    
    
    public static void main(String[] args){
        while(true){
            w = sc.nextInt();
            h = sc.nextInt();
            if(w==0&&h==0)break;
            
            map = new char[h][w];
            
            for(int i=0;i<h;i++){
                map[i] = sc.next().toCharArray();
            }
            loop:
            for(int i=0;i<h;i++){
                for(int j=0;j<w;j++){
                    if(map[i][j]=='@'){
                        dfs(j,i);
                        break loop;
                    }
                }
            }
            
            int ans=0;
            for(int i=0;i<h;i++){
                for(int j=0;j<w;j++){
                    if(map[i][j]=='*'){
                        ans++;
                    }
                }
            }
            
            System.out.println(ans);
            
        }
        
    }
    
    static void dfs(int x,int y){
        map[y][x]='*';
        for(int i=0;i<4;i++){
            int nx = x + dx[i];
            int ny = y + dy[i];
            
            if(nx>=0 && nx<w && ny>=0 && ny<h && map[ny][nx]=='.'){
                dfs(nx,ny);
            }
        }
    }
}

Measured memory_bytes: 27136
#include<bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i) 
#define rrep(i, a, b) for (int i = (a); i < (b); ++i)
#define PI acos(-1)
#define pcnt __builtin_popcountll
#define rng(a) a.begin(), a.end()
#define rrng(a) a.rbegin(), a.rend()
#define sz(x) (int)(x).size()
#define v(T) vector<T>
#define vv(T) v(v(T))
#define fi first
#define se second

using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;
using LP = pair<ll, ll>;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;
using tl = tuple<ll, ll, ll>;

template<typename T>inline istream& operator>>(istream&i,v(T)&v)
{rep(j,sz(v))i>>v[j];return i;}
template<typename T1,typename T2>inline istream& operator>>(istream&i,pair<T1,T2>&v)
{return i>>v.fi>>v.se;}
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; }

const int mod = 998244353;
struct mint {
    ll x; // using long long ll;
    mint(ll x=0):x((x%mod+mod)%mod){}
    mint operator-() const { return mint(-x);}
    mint& operator+=(const mint a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator-=(const mint a) {
        if ((x += mod-a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
    mint operator+(const mint a) const { return mint(*this) += a;}
    mint operator-(const mint a) const { return mint(*this) -= a;}
    mint operator*(const mint a) const { return mint(*this) *= a;}
    mint pow(ll t) const {
        if (!t) return 1;
        mint a = pow(t>>1);
        a *= a;
        if (t&1) a *= *this;
        return a;
    }
    
    // for prime mod
    mint inv() const { return pow(mod-2);}
    mint& operator/=(const mint a) { return *this *= a.inv();}
    mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}

ll INF = 1001001001;
ll LINF = 1001001001001001001ll;

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

    ll n, s; cin>>n>>s;
    vl as(n); cin>>as;

    mint base = 1;
    rep(i, n) base *= 2;

    vector<vector<mint>> dp(n + 1, vector<mint>(s + 1));
    dp[0][0] = base;
    rep(i, n) rep(j, s + 1) {
        dp[i + 1][j] += dp[i][j];
        if (j + as[i] <= s) dp[i + 1][j + as[i]] += dp[i][j] / 2;
    }
    cout<<dp[n][s]<<endl;
}

Measured memory_bytes: 73688
n = int(input())
xy = []
for _ in range(n):
  a = int(input())
  xy.append([[int(i) for i in input().split()] for __ in range(a)])

ans = 0
for i in range(2**n):
  flag = True
  for j in range(n):
    if i >> j & 1:
      for x,y in xy[j]:
        if (i >> (x-1)&1) != y:
          flag = False
          break
  if flag:
    ans = max(ans, sum(map(int, bin(i)[2:])))
print(ans)

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


template <typename T>
std::ostream &operator<<(std::ostream &out, const std::vector<T> &v){
    if(!v.empty()) {
        out << '[';
        std::copy(v.begin(), v.end(), std::ostream_iterator<T>(out, ", "));
        out << "\b\b]";
    }
    return out;
}

template <typename T1, typename T2>
std::ostream &operator<<(std::ostream &out, const std::pair<T1, T2> &p) {
    out << "[" << p.first << ", " << p.second << "]";
    return out;
}
//---------

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int k, t;
    cin >> k >> t;
    vector<int> a(k);
    for(int i = 0; i < k; i++){
        cin >> a[i];
    }

    //sort(a.begin(), a.end());
    int ma = 0;
    int idx = 0;
    int i = 0;
    int before = 10000000;
    int ans = 0;
    bool changeFlag = false;
    for(int i = 0; i < k; i++){
        for(int j = 0; j < t; j++){
            if(ma < a[j] && before != j){
                ma = a[j];
                idx = j;
                changeFlag = true;
            } 
        }
        if(changeFlag == false){
            for(int n = 0; n < t; n++){
                if(a[n]){
                    cout << a[n] << endl;
                    return 0;
                } 
            }
        }
        //cout << "before" << before << endl;
        before = idx;
        a[idx]--;
        ma = 0;
        changeFlag = false;
    }
    cout << "0" << endl;
    return 0;
}

Measured memory_bytes: 256
N, M = map(int, input().split())
pS = [input().split() for _ in range(M)]

p = [int(i[0]) for i in pS]
S = [i[1] for i in pS]

aced = [False for _ in range(N)]
penalty = [0 for _ in range(N)]
# pena = 0

for i in range(M):
    if not aced[int(pS[i][0])-1]:
        if pS[i][1] == 'WA':
            penalty[int(pS[i][0])-1] += 1
            # pena += 1
        if pS[i][1] == 'AC':
            aced[int(pS[i][0])-1] = True

# print(aced.count(True), pena)
penaltyCount = 0
for i in range(N):
    if aced[i]:
        penaltyCount += penalty[i]

print(aced.count(True), penaltyCount)


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

int par[100000];
int ran[100000];

void init(int n){
  rep(i,0,n){
    par[i]=i;
    ran[i]=0;
  }
}

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

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

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

int main(){
  int n,k;
  cin>>n>>k;
  int a[n];
  rep(i,0,n) cin>>a[i];
  rep(i,0,n) a[i]--;
  init(n);
  rep(i,0,k){
    int b,c;
    cin>>b>>c;
    unite(b-1,c-1);
  }
  vector<int> d[n];
  rep(i,0,n){
    int e=find(i);
    d[e].push_back(i);
  }
  int ans=0;
  rep(i,0,n){
    set<int> f;
    rep(j,0,d[i].size()) f.insert(a[d[i][j]]);
    rep(j,0,d[i].size()){
      if(f.count(d[i][j])) ans++;
    }
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 8824
# -*- coding: utf-8 -*-
'import sys'
'import math'
n=int(input())
while n:
    h,m=map(int,input().split(":"))
    s=l=float(0.0)
    l=m*6.0
    s=30.0*(h+(m/60.0))
    if l<s:l,s=s,l
    if l-s>180.0:d=360-l+s
    else:d=l-s
    if d<30: print("alert")
    elif d<90: print("warning")
    else: print("safe")
    n-=1

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

X = []
Y = []

P = []
Q = []

for i in range(N):
    x, y = map(int, input().split())
    X.append(x)
    Y.append(y)
    P.append(x + y)
    Q.append(x - y)

print(max(max(P) - min(P), max(Q) - min(Q)))

Measured memory_bytes: 122892
#include <bits/stdc++.h>
#pragma GCC optimize("O3")

#define fi first
#define se second
#define em emplace
#define eb emplace_back
#define mp make_pair
#define pi pair<int,int>
#define vi vector<int>
#define vpi vector<pair<int,int>>
#define vll vector<ll>
#define vpll vector<pair<ll,ll>>
#define endl '\n'

#define si(v) int(v.size())
#define all(v) v.begin(), v.end()
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define rep2(i, n, m) for (ll i = n; i <= (m); ++i)
#define rep3(i, n, m) for (ll i = n; i >= (m); --i)

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

using ll = long long;
using ld = long double;
using namespace std;

constexpr ll MOD = 1000000007;

signed main()
{
  cout << fixed << setprecision(20);
  ios::sync_with_stdio(false);
  cin.tie(0);
  
  ll n; cin >> n;
  string s;

  do {
    --n;

    s += 'a' + (n % 26);
    n /= 26;

  } while (n >= 1);

  reverse(all(s));
  cout << s << endl;
  
  return (0);
}

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

int main(){
	int n,q;
	string s;
	cin >>n>>q;
	cin >>s;
	vector<long long int>cnt(n,0);
	rep(i,n-1){
		cnt[i+1]=cnt[i];
	if (s[i]=='A' && s[i+1] == 'C')
		cnt[i+1]+=1;
	}
	rep(j,q){
		int l,r;
		cin >>l>>r;l--;r--;
		cout <<cnt[r]-cnt[l]<<endl;
	}
}

Measured memory_bytes: 1792
//#pragma GCC optimize("Ofast")
//#pragma GCC target("avx2,tune=native")
//#pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define pb push_back
using namespace std;
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vvi = vector<vi>;
using pi = pair<ll, ll>;
const ll mod = 1e9 + 7;
ll dp[3030][3030];
ll n, t;
vector<pair<ll, ll>> a;
int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	cin >> n >> t;
	a.resize(n);
	for(int i = 0; i < n; i++) {
		cin >> a[i].first >> a[i].second;
	}
	sort(all(a));
	ll ans = 0;
	for(int i = 0; i < n; i++) {
		for(int j = 0; j < t; j++) {
			ans = max(ans, dp[i][j] + a[i].second);
			dp[i+1][j] = max(dp[i+1][j], dp[i][j]);
			if(j+a[i].first<t) {
				dp[i+1][j+a[i].first] = max(dp[i+1][j+a[i].first], dp[i][j] + a[i].second);
			}
		}
	}
	cout << ans << "\n";
}


Measured memory_bytes: 71936
#include <stdio.h>
#include <limits.h>
#include <algorithm>

using namespace std;

int cmp_count = 0;


void merge(int A[],int left,int mid, int right){
	int n1 = mid - left;
	int n2 = right - mid;
	int L[n1+1],R[n2+1];
	for(int i = 0; i < n1; i++) L[i] = A[left + i];
	for(int i = 0; i < n2; i++) R[i] = A[mid + i];
	L[n1] = R[n2] =  INT_MAX;

	int i = 0, j = 0;
	for(int k = left;k < right; k++){
		if(L[i] <= R[j]){
			A[k] = L[i++];
			cmp_count++;
		}else{
			A[k] = R[j++];
			cmp_count++;
		}
	}
}

void mergeSort(int A[],int left,int right){
	if(left+1 < right){
		int mid = (left+right)/2;
		mergeSort(A,left,mid);
		mergeSort(A,mid,right);
		merge(A,left,mid,right);
	}
}

int main(){
	int n;
	scanf("%d",&n);
	int S[n];
	for(int i = 0; i < n; i++) scanf("%d",&S[i]);

	mergeSort(S,0,n);

	for(int i = 0; i < n-1; i++) printf("%d ",S[i]);
	printf("%d\n",S[n-1]);
	printf("%d\n",cmp_count);

}



Measured memory_bytes: 6500
use std::io;

macro_rules! parse_input {
   ($x:expr, $t:ident) => ($x.trim().parse::<$t>().unwrap())
}

macro_rules! parse_inputs {
   ($x:expr, $t:ident) => (
       $x.trim()
       .split_whitespace()
       .map(|s| s.parse::<$t>().unwrap())
       .collect::<Vec<$t>>()
   )
}

macro_rules! print_err {
   ($($arg:tt)*) => (
       {
           use std::io::Write;
           writeln!(&mut ::std::io::stderr(), $($arg)*).ok();
       }
   )
}

fn main() {
    let mut input_line = String::new();
    io::stdin().read_line(&mut input_line).unwrap();
    let ss = input_line.trim().chars().collect::<Vec<char>>();
    let sslen = ss.len();

    let mut count = 0;
    let mut c = ss[0];
    for s in &ss[1..] {
        if c != *s {
            count += 1;
            c = *s;
        }
    }
    println!("{}", count);


}


Measured memory_bytes: 892
#include <iostream>
#include <string>
#include<algorithm>
#include <cstdlib>

using namespace std;

int main()
{
	string a, b, c;
	char z[3];
	cin >> a >> b >> c;
	int x = 'A' - 'a';
	z[0] = a[0] + x;
	z[1] = b[0] + x;
	z[2] = c[0] + x;
	cout << z[0]<<z[1]<<z[2] << endl;
    return 0;
}

Measured memory_bytes: 256
while True:
	try:
		n = map(int, raw_input().split())
		a = max(n) 
		b = min(n)
		ab = a * b
		while b != 0 :
			c = a % b
			a = b
			b = c
		print str(a) + " " + str(ab / a)
	except EOFError:
		break

Measured memory_bytes: 4224
while 1:
	m,n = map(int,raw_input().split())
	if m == 0: break
	x = y = 1
	dx,dy = 0,1
	while 1:
		com = raw_input().split()
		s = com[0][0]
		if   s == "S": break
		elif s == "R":
			dx,dy = dy,-dx
		elif s == "L":
			dx,dy = -dy,dx
		else:
			d = 1 if s == "F" else -1
			l = d*int(com[1])
			x,y = min(m,max(1,x+l*dx)),min(n,max(1,y+l*dy))
	print x,y

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

#define REP(i, n) for(long long i = 0; i < n; i++)
#define REPR(i, n) for(long long i = n - 1; i >= 0; i--)
#define FOR(i, m, n) for(long long i = m; i <= n; i++)
#define FORR(i, m, n) for(long long i = m; i >= n; i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define VSORTR(v) sort(v.rbegin(), v.rend());
#define ALL(v) (v).begin(),(v).end()
using namespace std;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<ll, ll>;
const ll mod = 1e9+7;


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

    ll a,b,c,d; cin>>a>>b>>c>>d;
    ll a1 = c / b + (c%b==0 ? 0:1);
    ll a2 = a / d + (a%d==0 ? 0:1);

    if (a1<=a2){
        cout<<"Yes"<<endl;
        return 0;
    }
    else cout<<"No"<<endl;
    
    return 0;
}

Measured memory_bytes: 3668
def main():
    n = int(input())
    a = list(map(int, input().split()))
    ans = 0
    for i in range(n-1):
        if i < n-2 and a[i] == a[i+1] == a[i+2]:
            a[i+1] = -1
            ans += 1
        if a[i] == a[i+1]:
            a[i] = -1
            ans += 1
    print(ans)

if __name__ == "__main__":
    main()

Measured memory_bytes: 3060