akhauriyash/Code-Regression huggingface dataset:
// AUTHOR - SANDEEP PRADHAN
#pragma GCC optimize("O3")
#define _CRT_SECURE_NO_WARNINGS
#include <fstream>
#include <iostream>
#include <string>
#include <complex>
#include <math.h>
#include <set>
#include <vector>
#include <map>
#include <queue>
#include <stdio.h>
#include <stack>
#include <algorithm>
#include <list>
#include <ctime>
#include <memory.h>
#include <assert.h>
#include<limits.h>


#define eps 1e-8
#define PI 3.141592653589793
#define bsize 512

#define ll long long
#define ull unsigned long long
#define pii pair<int,int>
#define vi vector<int>
#define vii vector<vector<int>>
#define pb push_back
#define bs 1000000007
const int INF = 1e9 + 5;

using namespace std;


int main()
{
    ios_base::sync_with_stdio(false) ;
    cin.tie(NULL) ;
    cout.tie(NULL) ;
    
    int n,k;
    scanf("%d%d", &n, &k);

    vector<int> h(n);
    for(int i = 0; i < n; i++) 
        scanf("%d", &h[i]);
    
    vector<int> dp(n, INF);
    dp[0] = 0;
    for(int i = 0; i < n; i++) 
    {
        for(int j = i + 1; j <= i + k && j < n; j++)
        {
            dp[j] = min(dp[j], dp[i] + abs(h[i] - h[j]));
        }
    }
    printf("%d\n", dp[n-1]);

    return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
#include<unordered_set>
#include<unordered_map>
using namespace std;
#define int long long
#define REP(i,m,n) for(int i=(m);i<(n);i++)
#define rep(i,n) REP(i,0,n)
#define pb push_back
#define all(a) a.begin(),a.end()
#define rall(c) (c).rbegin(),(c).rend()
#define mp make_pair
#define endl '\n'
typedef long long ll;
typedef pair<ll,ll> pll;
typedef long double ld;
const ll inf=1e9+7;
const ll mod=1e9+7;
signed main(){
    ll n;cin>>n;
    ll ans=0;
    rep(i,n){
        ll a;cin>>a;
        ans|=(a%2);
    }
    cout<<(ans?"first":"second")<<endl;
}

Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
#define hackcyborg shresth_walia
#define ll  long long
#define ld double
#define pb push_back
#define mod 1000000007
#define M_PI 3.141592653589
#define IO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
#define int long long
ll binpow(ll a,ll b,ll m=mod)
{
    a%=mod;
    ll res=1;
    while(b>0)
    {
        if(b&1)
        res=(a*res)%mod;
        a=(a*a)%mod;
        b/=2;
    }
    return res;
}
main()
{
    IO
    ll h,w;
    cin>>h>>w;
    ll k;
    cin>>k;
    ll t=1<<w;
    ll e=1<<h;
    string s[h];
    for(int x=0;x<h;x++)cin>>s[x];
    ll ans=0;
    for(int x=0;x<e;x++)
        for(int y=0;y<t;y++)
        {
            ll r=0;
            for(int i=0;i<h;i++)
                for(int j=0;j<w;j++)
                     if(s[i][j]=='#')
                    if(!(y&(1<<j)) && !(x&(1<<i)))
                       ++r;
            if(r==k)
                ++ans;
        }
        cout<<ans;
}


Measured memory_bytes: 3668
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int l = sc.nextInt();
		List<String> list = new ArrayList<String>();
		for(int i = 0; i < n; i++) {
			list.add(sc.next());
		}
		Collections.sort(list);
		StringBuilder sb = new StringBuilder();
		for(String str : list) {
			sb.append(str);
		}
		System.out.println(sb);
	}

}


Measured memory_bytes: 23380
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <cstdio>
#include <numeric>
#include <iomanip>

using namespace std;

using ll = long long;

ll N;
vector<ll> L;

int main()
{
    cin >> N;
    L.resize(N);
    for(int i = 0;i < N; i++)
    {
        cin >> L[i];
    }

    ll ans = 0;

    for(int i = 0;i < N; i++)
        for(int j = i+1;j < N; j++)
            for(int k = j+1;k < N; k++)
            {
                ll a[3] = {L[i], L[j], L[k]};
                sort(a, a+3);
                if(L[i] == L[j] || L[j] == L[k] || L[k] == L[i])
                {
                    continue;
                }
                if(a[2] < a[0] + a[1])
                {
                    ans++;
                }
            }

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

Measured memory_bytes: 3196
#include <iostream>
#include <cstdio>
#include <cmath>
#include <string>
#include <algorithm>
using namespace std;
#define ll long long int
#define abs(n) ((n>0)?(n):((n)*(-1)))
#define errln(v) cerr << (v) << endl;
#define println(v) cout << (v) << endl;

ll g(ll d,ll X){
	ll divider = (2LL<<d);
	ll ret = 0;
	ll block = (X+1)/divider*(divider/2);
	ll each = max( (X+1)%divider-divider/2 , 0LL);
//	printf("g(%lld %lld) : %lld : %lld %lld\n",d,X,divider,block,each);
	ret = (block + each);
	return ret;
}

int main(int argc, const char * argv[]) {
	ll A,B;
	cin >> A >> B;

	ll d_size=1,p = 1;
	while(p <= B){
		d_size++;
		p*=2;
	}
	ll ret = 0;

	for (ll i = 0; i < d_size; i++) {
		ll ga_1 = g(i,A-1);
		ll gb = g(i,B);
		cerr << (1LL<<i) << " " << ga_1 << " " << gb << endl;
		ret += (1LL<<i) * ((gb-ga_1)%2);
	}

	println(ret);

	return 0;
}


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

int main() {
    int N, K;
    cin >> N >> K;
    vector<long long> A(N);
    for (int i = 0; i < N; i++) {
        cin >> A.at(i);
    }
    sort(A.begin(), A.end());
    long long ans = 0;
    for (int i = 0; i < K; i++) {
        ans += A.at(i);
    }
    cout << ans << endl;
}

Measured memory_bytes: 3604
a ,b ,c = input().split()

ans = 0

for i in range( 1 , int(a)+1 ):
    
    o = str(i)
    
    count = 0
    
    for k in range( 0 , len(o)) :
        
        count += int(o[k])
    
    if count >= int(b) and count <= int(c):
        
        ans += i
        
print(ans)


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

int main(){
    int N;
    cin >> N;
    vector<int> A(N);
    rep(i,N){
        cin >> A[i];
    }
    // 配列のインデックス indiecs = {0, 1, 2, 3, 4} を作成する。
    std::vector<size_t> indices(A.size());
    std::iota(indices.begin(), indices.end(), 0);

    // ソートする。
    std::sort(indices.begin(), indices.end(), [&A](size_t i1, size_t i2) {
        return A[i1] < A[i2];
    });

    for (auto v : indices)
        std::cout << v+1 << " ";
    std::cout << std::endl;

}


Measured memory_bytes: 2048
import java.util.ArrayList;
import java.util.Scanner;
public class Main {
	public static Integer sum(ArrayList<Integer> M) {
		int sum = 0;
		for(int i = 0; i < M.size(); i++) {
			sum += (int)M.get(i);
		}
		return(sum);
	}

	public static void main(String[] args) {
		int A,B,N;
		int s = 0;
		Scanner scan = new Scanner(System.in);
		N = scan.nextInt();
		A = scan.nextInt();
		B = scan.nextInt();
		ArrayList<Integer> M = new ArrayList<Integer>();

		for(int i = 1; i <= N; i++) {
			String str = String.valueOf(i);
			for(int j = 0; j < str.length(); j++) {
				char ch = str.charAt(j);
				int k = Character.getNumericValue(ch);
				M.add(k);
			}
			if(A <= sum(M) && sum(M) <= B) {
				s += i;
			}
			M.clear();
		}
		System.out.println(s);
		scan.close();
	}
}


Measured memory_bytes: 21460
#include <stdio.h>
#include <string.h>
#define nax 4500
int Max(int a , int b){
	return a>b ? a:b;
}
int main(){
	char s1[nax];
	char s2[nax];
	int dp[nax][nax];
	scanf("%s",s1);
	scanf("%s",s2);


	for(int i=1; i<=strlen(s1);i++ ){
		for(int j=1;j<=strlen(s2);j++){
			int esIgual = 0;
			int noesIgualMax = 0;
			if(s2[j-1] == s1[i-1]){
					esIgual = dp[i-1][j-1] + 1;
			}
			else{
				noesIgualMax = Max(dp[i-1][j],dp[i][j-1]);
			}

			dp[i][j] = Max(esIgual,noesIgualMax);
		}

	}
	int index = dp[strlen(s1)][strlen(s2)];
	char lcs[index+1];
	int i = strlen(s1), j = strlen(s2);
	lcs[index] = '\0';
	while (i > 0 && j > 0)
	{
		// If current character in X[] and Y are same, then
		// current character is part of LCS
		if (s1[i-1] == s2[j-1])
		{
			lcs[index-1] = s1[i-1]; // Put current character in result
			i--; j--; index--;     // reduce values of i, j and index
		}

			// If not same, then find the larger of two and
			// go in the direction of larger value
		else if (dp[i-1][j] > dp[i][j-1])
			i--;
		else
			j--;
	}
	printf("%s",lcs);



}

Measured memory_bytes: 54528
#include<stdio.h>
int main(){
	int n,m;
	scanf("%d%d",&n,&m);
	int a,b;
	if(n==1)
		a=0;
	else{
		a=n*(n-1)/2;
	}
	if(m==1)
		b=0;
	else{
		b=m*(m-1)/2;
	}
	printf("%d",a+b);
} 

Measured memory_bytes: 128
#include <bits/stdc++.h>
#include <stdlib.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;
typedef pair<ll,ll> P;
typedef priority_queue<P,vector<P>,greater<P>> P_queue;

#define REP(i,a,b) for(int i=(int)a;i<(int)b;i++)
#define rep(i,n) REP(i,0,n)
#define pb push_back
#define mp make_pair
#define ALL(a) a.begin(),a.end()
#define SORT(a) sort(ALL(a))
#define U_ERASE(V) V.erase(unique(ALL(V)), V.end());
#define ADD(a,b) a=(a+b)%mod

const ll MOD=998244353;
const ll mod=1000000007;
const ll INF=1e15;
vec dx={1,0,-1,0};
vec dy={0,1,0,-1};
ll Count=0;

ll N; vec A,B;
ll ans=0;
bool able=true;
bool same[200010];
ll SAME=0;
bool Changed=false;


void Hiku(ll x){
    //Count++;
    //cout<<x<<':'<<B[x]<<':'<<A[x]<<endl;
    //if(Count>100) return;
    if(!able) return;
    if(same[x]) return;
    if(B[x]<A[x]) {able=false; return;}
    if(B[x]==A[x]) {same[x]=true; SAME++; return;}
    ll a=(x+1)%N, c=(x-1+N)%N;
    ll K=B[a]+B[c];
    if(K>=B[x]) return;
    if(B[x]-K<A[x]){able=false; return;}
    ll P=(B[x]-A[x])/K;
    Changed=true;
    //cout<<x<<' '<<B[x]<<' '<<B[x]-(P*K)<<endl;
    B[x]-=P*K;
    ans+=P;
    if(B[x]==A[x]) {same[x]=true; SAME++;}
    return;
}

ll Solve(){
    while(true){
        Changed=false;
        rep(i,N){
            if(!able) return -1;
            if(SAME==N) return ans;
            Hiku(i);
            //cout<<"SOLVING"<<' '<<able<<' '<<SAME<<endl;
            //if(Count>100) return -1;
        }
        if(!Changed) return -1;
    }
}

int main(){
    cin>>N;
    rep(i,N){
        ll x; cin>>x;
        A.pb(x);
    }
    rep(i,N){
        ll x; cin>>x;
        B.pb(x);
    }
    cout<<Solve()<<endl;
}

Measured memory_bytes: 5360
#include <bits/stdc++.h>
using namespace std;
#define f first
#define s second
#define ll long long
#define ld long double
#define pii pair <int,int>
#define pll pair <ll,ll>
#define pil pair <int,ll>
#define pli pair <ll,int>
#define ull unsigned long long
#define pdd pair <ld,ld>
#define pb push_back
#define mp make_pair
#define puu pair<ull,ull>
#define pvv pair<vector<int>, vector<int> >
#define _bp __builtin_popcount
#define ptt pair <Tree*,Tree*>
#define all(v) v.begin(),v.end()
#define en "\n"
//const long double pi = acos(-1);
void boos()
{
     ios_base :: sync_with_stdio(false);
     cin.tie(0);
     cout.tie(0);
}
void file()
{
   freopen("robot.in","r",stdin);
   freopen("robot.out","w",stdout);
}
const ll INF = (ll)1e9 + 7ll;
const ll INF1 = 998244353;
const ll INF2 = (ll)1e9 + 9ll;
const ll LLINF = (ll)1e18 + 1;
const ll INTmx = (int)2e9;
const ld EPS = (ld)1e-15;
const int N = 3e5 + 100;
ll a[N];
int main()
{
    //file();
    boos();
	int n,k;
	cin >> n >> k;
	for(int i = 1;i <= n;i++)
	{
		cin >> a[i];
	}
	for(int i = k + 1;i <= n;i++)
	{
		if(a[i] > a[i - k])
		{
			cout << "Yes" << en;
		}else {
			cout << "No" << en;
		}
	}
}

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

int main()
{
	long long a, b;

	cin >> a >> b;

	long long m = ((b + 1) / 2 - a / 2) % 2;

	for (int i = 1; (1ull << i) <= b; i++) {
		if (((1 + (b % (1ull << i))) * (b % (1ull << (i + 1)) / (1ull << i))
			- (1 + ((a - 1) % (1ull << i))) * ((a - 1) % (1ull << (i + 1)) / (1ull << i))) % 2 == 1)
			m += (1ull << i);
	}

	cout << m << endl;

	return 0;
}


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

int main() {
	int n;
	cin >> n;
	int a[n];
	int ans = 0;
	for (int i = 0;i < n;i++) {
		cin >> a[i];
		while (a[i] % 2 == 0) {
			a[i] /= 2;
			ans++;
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
        using namespace std;
   #define int long long
const int MAX = 510000;
const int MOD =  1000000007;
int sz[200000],zen[200000],c[200000],ans[200000];bool used[200000];
vector<int> hen[200000];
int dfssz(int a){
     
     sz[a]=1;
     for(auto&& i : hen[a])if(!sz[i])sz[a]+=dfssz(i);
     
     return sz[a];
}
void dfs(int a){
     used[a]=true;
     ans[c[a]]+=1+zen[c[a]]*(zen[c[a]]-1)/2;
     zen[c[a]]-=sz[a];
     ans[c[a]]-=(zen[c[a]]-1)*zen[c[a]]/2;
     int tmp=zen[c[a]];
     for(auto&& i : hen[a])if(!used[i]){
          
          ans[c[a]]-=sz[i]*(sz[i]-1)/2;
          zen[c[a]]=sz[i];
          dfs(i);
     }
     zen[c[a]]=tmp;
     return;
}

     signed main(){
       int n;
       cin>>n;
      for(int i=0;i<n;i++){
           cin>>c[i];c[i]--;
      }
      int a,b;
      for(int i=0;i<n-1;i++){
           cin>>a>>b;a--;b--;
           hen[a].push_back(b);
           hen[b].push_back(a);
      }
      fill(ans,ans+n,0);
      fill(sz,sz+n,0);
      fill(zen,zen+n,n);
      dfssz(0);
       fill(used,used+n,false);
      dfs(0);
      for(int i=0;i<n;i++)cout<<ans[i]<<endl;

      }

        


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

int main()
{
    long long N, A, B, C, D, E;
    cin >> N >> A >> B >> C >> D >> E;

    long long minMove = min({A, B, C, D, E});
    long long ans = ((N  + minMove - 1) / minMove) + 4;

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

Measured memory_bytes: 256
import java.io.File;
import java.io.FileReader;
import java.io.InputStreamReader;
import java.io.BufferedReader;
import java.io.IOException;
import java.util.*;

class Main
{
    public static char [][] transpose(char [][] p)  // p: m(rows) x n(columns)
    {
	int m = p.length;
	int n = p[0].length;
	char [][] q = new char [8][5];
	
	for (int i=0; i<5; i++){
	    for (int j=0; j<8; j++){
		q[j][i]=p[i][j];
	    }
	}

	return q;
    }

    public static char [][] conv(int n)
    {
	char [][] a = {    // char[9][8] a; 
	    {'*',' ','=',' ','*','*','*','*'}, 
	    {'*',' ','=','*',' ','*','*','*'}, 
	    {'*',' ','=','*','*',' ','*','*'}, 
	    {'*',' ','=','*','*','*',' ','*'}, 
	    {'*',' ','=','*','*','*','*',' '}, 
	    {' ','*','=',' ','*','*','*','*'}, 
	    {' ','*','=','*',' ','*','*','*'}, 
	    {' ','*','=','*','*',' ','*','*'}, 
	    {' ','*','=','*','*','*',' ','*'}, 
	    {' ','*','=','*','*','*','*',' '} };
	int[] p = new int[5];
	String s = String.format("%05d", n);
	for (int i=0; i<5; i++){
	    p[i]=Integer.parseInt(s.substring(i,i+1));
	}
	char [][] m = new char [5][8];
	for (int i=0; i<5; i++){
	    for (int j=0; j<8; j++){
		m[i][j] = a[p[i]][j];
	    }
	}
	
	return transpose(m);
    }

    public static void main(String[] args) throws IOException {
	BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); 
	/*
	  if true then
	  fh=STDIN
	  else
	  fh=open("in1_0128.txt")
	  end
	*/
	String line=null;
        boolean first = true;
	List<String> glyph = new ArrayList<String>();
	while ((line=br.readLine()) != null) {
	    int n=Integer.parseInt(line);
	    char [][] q = conv(n);
	    if (!first)
		System.out.println("");
	    for (int i=0; i<8; i++){
		System.out.println(q[i]);
	    }
	    first = false;
	}

	for  (int i=0; i<glyph.size()-1; i++){
	    System.out.println(glyph.get(i));
	    if (i != glyph.size()-1)
		System.out.println();
	}
    }

}

Measured memory_bytes: 33576
#include <bits/stdc++.h>
using namespace std;
const int MAX = 100005;
const int NIL = -1;

struct Node { int parent, left, right;};
struct Node T[MAX];
int n, D[MAX];

void print(int u) {
  cout << "node " << u << ": ";
  cout << "parent = " << T[u].parent << ", ";
  cout << "depth = " << D[u] << ", ";

  if (T[u].parent == NIL) cout << "root, ";
  else if (T[u].left == NIL) cout << "leaf, ";
  else cout << "internal node, ";

  cout << "[";
  int cur = T[u].left;
  while (cur != NIL) {
    cout << cur;
    cur = T[cur].right;
    if (cur == NIL) break;
    cout << ", ";
  }
  cout << "]" << endl;
}

void rec(int u, int p) {
  D[u] = p;
  if (T[u].right != NIL) rec(T[u].right, p);
  if (T[u].left != NIL) rec(T[u].left, p + 1);
}

int main() {
  cin >> n;

  for (int i = 0; i < n; i++) {
    T[i].parent = T[i].left = T[i].right = NIL;
  }

  for (int i = 0; i < n; i++) {
    int u, m;
    cin >> u >> m;
    int prev = NIL;
    for (int j = 0; j < m; j++) {
      int c;
      cin >> c;
      T[c].parent = u;
      if (prev == NIL) T[u].left = c;
      else T[prev].right = c;
      prev = c;
    }
  }
  
  int root = NIL;
  for (int i = 0; i < n; i++) {
    if (T[i].parent == NIL) {
      root = i;
      break;
    }
  }
  rec(root, 0);

  for (int i = 0; i < n; i++) {
    print(i);
  }
}


Measured memory_bytes: 7692
import java.util.Scanner;
public class Main {
	public static void main(String[] args) throws java.io.IOException {
		Scanner scan = new Scanner(System.in);
		while(scan.hasNext()){
			String n = scan.next();
			int m = scan.nextInt();
			int a = scan.nextInt();
			System.out.println(n + " " + (m+a) + " " + (200*m+300*a));
		}
	}
}

Measured memory_bytes: 15344
#include <iostream>
#include <vector>

using namespace std;

vector <vector <int> > sheet; 
vector <int> temp;
int r,c;
int main(){
    cin>>r>>c;
    for(int i=0;i<r;i++){
        int s=0;
        for(int j=0;j<c;j++){
            int a;
            cin>>a;
            temp.push_back(a);
            s+=a;
        }
        temp.push_back(s);
        s=0;
        sheet.push_back(temp);
        temp.clear();        
    }

    for(int i=0;i<c+1;i++){
        int s=0;
        for(int j=0;j<r;j++){
            s+=sheet[j][i];
        }
        temp.push_back(s);
        s=0;
    }
    sheet.push_back(temp);

    for(int i=0;i<r+1;i++){
        for(int j=0;j<c;j++){
            cout<<sheet[i][j]<<" ";
        }
        cout<<sheet[i][c]<<endl;
    }
}

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

int main(){
  string s;
  cin >> s;
  
  rep(i,s.size()){
    if(i%2==0)
      cout << s.at(i) ;
  }
      cout << endl; 
}

Measured memory_bytes: 512
#include <iostream>
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define lli long long int
using namespace std;
#define S second
#define F first
#define pb push_back 
#define M1 1000000007
#define M2 998244353
#define plli pair<lli,lli>
#define setit set<lli>::iterator seti
#define mapit map<lli,lli> ::iterator mapi
#define MP make_pair
#define MT make_tuple
// map      iterator->first  iterator.first
// map      mp[key]=value
// set      *s.begin()
// vector   v[j]=value
// pair     p.first p.second
// vector of pairs v[j].first v[j].second
// tuple    get<index>(tuple_name)
// vector of tuples get<index>(v[j])  sort(v.begin(),v.end())
//priority queue .top() .pop() .push()
// __gcd(x,y)
#define fr(j,a,b) for(j=a;j<b;j++)

int power(int x, unsigned int y, int p)  
{    int res = 1;    
     x = x % p;
     if (x == 0) return 0;
     while (y > 0)  
     {  if (y & 1)  
        res = (res*x) % p;  
        y = y>>1;
        x = (x*x) % p;  
     }  
    return res;  
}





















int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    lli b,w,sx,sy,t,i,j,n,x,l,r,u,d;
    string s;
    cin>>s;
    if(s[2]==s[3]&&s[4]==s[5]){
        cout<<"Yes";
    }
    else{
        cout<<"No";
    }
}



Measured memory_bytes: 256
from fractions import gcd
def f(n):
    tmp = n
    cnt = 0
    i = 2
    while i <= n**0.5 + 1:
        if tmp < i:
            break
        if tmp % i == 0:
            cnt += 1
            while tmp % i == 0:
                tmp //= i
        i += 1
    if tmp != 1:
        cnt += 1
    return cnt

A, B = map(int, input().split())
g = gcd(A, B)
ans = f(g) + 1
print(ans)

Measured memory_bytes: 5432
#include <bits/stdc++.h>
 
#define rep(...) overload_rep(__VA_ARGS__, rep_1, rep_0) (__VA_ARGS__)
#define rep_0(i, end) for (int i = 0; i < (end); ++i)
#define rep_1(i, fr, ba) for (int i = (fr); i <= (ba); ++i)
#define overload_rep(arg_0, arg_1, arg_2, name, ...) name
#define all(box) box.begin(), box.end()
 
template <class T, class U> inline bool chmax(T& lhs, const U& rhs) { if (lhs < rhs) { lhs = rhs; return 1; } return 0; }
template <class T, class U> inline bool chmin(T& lhs, const U& rhs) { if (lhs > rhs) { lhs = rhs; return 1; } return 0; }

template <class Ab>
struct fenwick_tree {
 
  int size;
  std::vector<Ab> node;

  fenwick_tree() { }
  fenwick_tree(const int& size_) { init(size_); }

  void init(const int& size_) {
    size = size_;
    node.assign(size + 1, 0);
  }

  void modify(const int& idx, const Ab& value) {
    int x = idx + 1;
    while (x <= size) {
      node[x] += value;
      x += x & -x;
    }
  }

  // [0, idx]
  Ab get(const int& idx) const {
    Ab result{};
    int x = idx + 1;
    while (x > 0) {
      result += node[x];
      x -= x & -x;
    }
    return result;
  }
    
};

using dbl = long double;
constexpr dbl inf = 1e10;

struct line {
  dbl a, b; 
  int id;
  line(dbl a = 0, dbl b = 0) : a(a), b(b), id(-1) { }
  dbl val(const dbl& x) const {
    return a * x + b;
  }
};

int N, count;
line L[40000];

dbl calc() {
  dbl ok = inf, ng = -inf;
  rep (steps, 100) {
    dbl md = (ok + ng) / 2;
    ([&]{
      std::sort(L, L + N, [&](line l, line m){
        return l.val(md) < m.val(md);
      });
      fenwick_tree<int> fen(N);
      int now = 0;
      rep (i, N) {
        now += fen.get(L[i].id);
        fen.modify(L[i].id, 1);
      }
      return now >= count;
    }() ? ok : ng) = md;
  }
  return ok;
}

void sort() {
  std::sort(L, L + N, [](line l, line m){
    return l.a < m.a;
  });
  rep (i, N) L[i].id = i;
}

void swap() {
  rep (i, N) {
    L[i].a = 1.0L / L[i].a;
    L[i].b = -L[i].a * L[i].b;
  }
}

void out() {
  rep (i, N) {
    std::cout << L[i].a << ' ' << L[i].b << ' ' << L[i].id << '\n';
  }
}

int main() {

  std::cin >> N;
  count = (N * (N - 1) / 2 + 1) / 2;
  rep (i, N) {
    dbl a, b, c;
    std::cin >> a >> b >> c;
    L[i].a = -a / b;
    L[i].b = c / b;
  }

  sort();
  dbl x = calc();
  swap();
  sort();
  dbl y = calc();

  std::cout << std::fixed << std::setprecision(20);
  std::cout << x << ' ' << y << '\n';
  return 0;

}


Measured memory_bytes: 2432
#include <stdio.h>

#define DENOM 1000000007LL
long long dp[22][1<<21] = {0LL};

int main(void) {
    int i, j, k, N, a[30][30];
    scanf("%d", &N);
    for (i=1;i<=N;i++) for (j=1;j<=N;j++) scanf("%d", &a[i][j]);

    dp[0][0] = 1;
    for (i=1;i<=N;i++) {
        for (j=0;j<(1<<N);j++) {
            if (__builtin_popcount(j) != i-1) continue;
            for (k=1;k<=N;k++) {
                if (a[i][k]) {
                    int m = 1 << (k-1);
                    if (!(j&m)) {
                        dp[i][j|m] += dp[i-1][j];
                        dp[i][j|m] %= DENOM;
                    }
                }
            }
        }
    }
    printf("%lld\n", dp[N][(1<<N)-1]);
    return 0;
}

Measured memory_bytes: 309376
#include<iostream>
#include<stdio.h>
#include<stdlib.h>
#include<bits/stdc++.h>
using namespace std;
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;
/*---------------------DEBUGGING--------------------------------------------*/
void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif
/*-------------------------------------------------------------------------------------*/
//#define mp make_pair
#define pb push_back
#define ll long long
#define pii pair<int,int>
#define pcc pair<char,char>
#define F first
#define S second
#define int long long
#define pi 3.141592653589793238462643383279502
#define M 1000000007
#define rep(i,a,n) for(int i=a;i<n;i++)
#define INF 10000000000000000
#define N 200005
#define vi vector<int>
#define all(v) v.begin(),v.end()
//#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
int power(int x,  int y, int p)
{
    int res = 1;     // Initialize result

    x = x % p; // Update x if it is more than or
                // equal to p

    if (x == 0) return 0; // In case x is divisible by p;

    while (y > 0)
    {
        // If y is odd, multiply x with result
        if (y & 1)
            res = (res*x) % p;

        // y must be even now
        y = y>>1; // y = y/2
        x = (x*x) % p;
    }
    return res;
}
signed main()
{
   ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
   int n;
   cin>>n;
   int a[n];
   rep(i,0,n)cin>>a[i];
   int ans=0;
   for(int i=59;i>=0;i--)
   {
       int cnt=0;
       for(int j=0;j<n;j++)
       {
           if(1LL<<i & a[j])cnt++;
       }
       int val=(cnt*(n-cnt));
       val%=M;
       val*=power(2,i,M);
       val%=M;
       ans+=val;
       ans%=M;
   }
   cout<<ans<<endl;
}


Measured memory_bytes: 2560
#include<stdio.h>
#include<algorithm>
#include <list>
#include <stack>
#include <queue>
#include <map>
#include <vector>
#include <iostream>
#include <string>
#include <time.h>
#include <functional>
using namespace std;

int dp[101][100001] = { 0 };
int N, v[100], w[100], W;

int main(void) {
	int sum = 0;
	scanf("%d %d", &N, &W);
	for (int i = 0; i < N; ++i) {
		scanf("%d %d", &v[i], &w[i]);
		sum += v[i];
	}
	for (int i = 1; i <= N; ++i) {
		for (int j = 1; j <= W; ++j) {
			if (j < w[i - 1]) {
				dp[i][j] = dp[i - 1][j];
			}
			else{
				dp[i][j] = max(dp[i - 1][j - w[i - 1]] + v[i - 1], dp[i - 1][j]);
			}
		}
	}
	printf("%d\n", dp[N][W]);
}

Measured memory_bytes: 7500
#include <cmath>
#include <vector>
#include <map>
#include <functional>
#include <queue>
#include <iostream>
#include <string.h>
#include <iomanip>
#include <algorithm>
#include <functional>
#include <cstdint>
#include <climits>
#include <unordered_set>
#include <sstream>

using namespace std;

#define ll long long int
#define pll pair<double,ll>

string s;
ll xs, ys, xt, yt;
int N;
string t[] = {"dream","dreamer","erase","eraser"};
int l[] = {5,7,5,6};

int main()
{
    string s;
    cin >> s;
    while(s.length() > 0)
    {
        bool found = false;
        for(int i = 0;i < 4;i++)
        {
            string ta = t[i];
            if(s.length() < ta.length())
            {
                continue;
            }
            bool match = true;
            for(int j = 0;j < ta.length(); j++)
            {
                if(s[s.length()-j-1] != ta[ta.length()-j-1])
                {
                    match = false;
                    break;
                }
            }
            if(!match)
            {
                continue;
            }
            s = s.substr(0, s.length() - l[i]);
            found = true;
            break;
        }
        if(found)
        {
            continue;
        }
        cout << "NO" << endl;
        return 0;
        
    }
    cout << "YES" << endl;
    return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#define mod 998244353
using namespace std;
int read();
int M(int x) { return x >= mod ? x - mod : x; }
void Add(int& x, int y) { (x += y) >= mod ? x -= mod : x; }
int n, len, sp;
int fsp(long long bs, int p) {
    int rt = 1;
    while (p) {
        if (p & 1) rt = bs * rt % mod;
        bs = bs * bs % mod, p >>= 1;
    }
    return rt;
}

struct Poly {
    int x[300005];
    int& operator[](int p) { return x[p]; }
    void fwt(int len) {
        for (int l = 2; l <= len; l <<= 1)
            for (int i = 0, m = l >> 1; i < len; i += l)
                for (int j = i, t; j < i + m; ++j)
                    t = x[j + m], x[j + m] = M(x[j] - t + mod), Add(x[j], t);
    }
    void ifwt(int len) {
        fwt(len);
        int ny = fsp(len, mod - 2);
        for (int i = 0; i < len; ++i) x[i] = 1ll * x[i] * ny % mod;
    }
} E, P, S;

int main() {
    n = read(), len = 1 << n;
    for (int i = 0; i < len; ++i) sp += (P[i] = read());
    sp = fsp(sp, mod - 2);
    for (int i = 0; i < len; ++i) P[i] = 1ll * P[i] * sp % mod;
    (--P[0]) < 0 ? P[0] += mod : 0, S[0] = len - 1;
    for (int i = 1; i < len; ++i) S[i] = mod - 1;
    P.fwt(len), S.fwt(len);
    for (int i = 1; i < len; ++i) E[i] = 1ll * S[i] * fsp(P[i], mod - 2) % mod;
    E.ifwt(len);
    int x = mod - E[0];
    for (int i = 0; i < len; ++i) printf("%d\n", M(x + E[i]));

    return 0;
}
const int _SIZE = 1 << 22;
char ibuf[_SIZE], *iS = ibuf, *iT = ibuf;
#define gc                                                         \
    (iS == iT ? iT = ((iS = ibuf) + fread(ibuf, 1, _SIZE, stdin)), \
     (iS == iT ? EOF : *iS++) : *iS++)
int read() {
    int x = 0, f = 1;
    char c = gc;
    while (!isdigit(c)) f = (c == '-') ? -1 : f, c = gc;
    while (isdigit(c)) x = x * 10 + c - '0', c = gc;
    return x * f;
}

Measured memory_bytes: 7040
use std::io::{stdin, Read, StdinLock};
use std::str::FromStr;

// reference: http://ir5.hatenablog.com/entry/20171209/1512821837

struct Scanner<'a> {
    cin: StdinLock<'a>,
}
 
impl<'a> Scanner<'a> {
    fn new(cin: StdinLock<'a>) -> Scanner<'a> {
        Scanner { cin: cin }
    }
 
    fn read1<T: FromStr>(&mut self) -> Option<T> {
        let token = self.cin.by_ref().bytes().map(|c| c.unwrap() as char)
            .skip_while(|c| c.is_whitespace())
            .take_while(|c| !c.is_whitespace())
            .collect::<String>();
        token.parse::<T>().ok()
    }
 
    fn read<T: FromStr>(&mut self) -> T {
        self.read1().unwrap()
    }
}

use std::mem;

fn main() {
    let cin = stdin();
    let cin = cin.lock();
    let mut sc = Scanner::new(cin);

    let n: u8 = sc.read();
    let s: String = sc.read();
    let mut ans: String = "".to_string();
    for c in s.chars() {
        let x: char = ((c as u8 - 65 + n) % 26 + 65) as char;
        ans.push(x);
    }
    println!("{}", ans);
}

Measured memory_bytes: 2124
#include <iostream>
#include <cmath>
#include <string>
#include <algorithm>
#include <set>
#include <vector>
#include <map>
#include <list>
#include <stack>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <queue>
#define mkp(a, b) make_pair(a, b)
#define pb(t) push_back(t)
#define ft first
#define sc second
#define pt(num) cout << num << "\n"
#define moC(a, s, b) (a)=((a)s(b)+MOD)%MOD
#define max(a, b) ((a)>(b) ? (a):(b))
#define min(a, b) ((a)<(b) ? (a):(b))
#define chmax(a, b) (a<b ? a=b : 0)
#define chmin(a, b) (a>b ? a=b : 0)
#define INF 1000000000000000000
#define MOD 1000000007LL
#define MAX 101010
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef map<ll, ll> Map;


int main(void) {
    ll N, M;
    cin >> N >> M;
    ll x[3][1111];
    ll i, j;
    
    for(i=0; i<N; i++) {
        cin >> x[0][i] >> x[1][i] >> x[2][i];
    }
    
    ll ans=0;
    for(i=0; i<8; i++) {
        ll sgn[3]={};
        for(j=0; j<3; j++) {
            if(1&i>>j) sgn[j]=1;
            else       sgn[j]=-1;
        }
        
        priority_queue<ll> q;
        for(j=0; j<N; j++)
            q.push(sgn[0]*x[0][j]+sgn[1]*x[1][j]+sgn[2]*x[2][j]);
        
        ll t=0;
        for(j=0; j<M; j++) {
            t+=q.top(); q.pop();
        }
        
        chmax(ans, t);
        
    }
    
    pt(ans);
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<n;i++)
using namespace std;
int main(){
    vector<int> A(3,0);
    REP(i,3)cin>>A[i];
    sort(A.begin(),A.end(),greater<int>());
    int N = 2*A[0]-A[1]-A[2];
    cout<<((N%2)?(N+3)/2:N/2)<<endl;
}

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

struct Point
{
  int x;
  int y;

  Point(int x, int y) : x(x), y(y) {}
};

struct Cell
{
  char c;
  int count;

  Cell() : c{' '}, count{std::numeric_limits<decltype(count)>::max()}
  {}

  bool update_count(int count)
  {
    if (count < this->count) {
      this->count = count;
      return true;
    } else {
      return false;
    }
  }
};

using Points = std::vector<Point>;
using Row = std::vector<Cell>;
using Board = std::vector<Row>;

bool update(Board& board, const Point& black, int r)
{
  const int y_max = board.size();
  const int x_max = board.front().size();

  bool is_updated = false;
  const auto x_first = std::max(black.x - r, 0);
  const auto x_last = std::min(black.x + r + 1, x_max);
  if (black.y - r >= 0) {
    for (int x = x_first; x < x_last; ++x) {
      if (board[black.y - r][x].update_count(r + std::abs(black.x - x))) {
        is_updated = true;
      }
    }
  }
  if (black.y + r < y_max) {
    for (int x = x_first; x < x_last; ++x) {
      if (board[black.y + r][x].update_count(r + std::abs(black.x - x))) {
        is_updated = true;
      }
    }
  }

  const auto y_first = std::max(black.y - r + 1, 0);
  const auto y_last = std::min(black.y + r, y_max);
  if (black.x - r >= 0) {
    for (int y = y_first; y < y_last; ++y) {
      if (board[y][black.x - r].update_count(r + std::abs(black.y - y))) {
        is_updated = true;
      }
    }
  }
  if (black.x + r < x_max) {
    for (int y = y_first; y < y_last; ++y) {
      if (board[y][black.x + r].update_count(r + std::abs(black.y - y))) {
        is_updated = true;
      }
    }
  }

  return is_updated;
}

int solve(Board& board, Points blacks)
{
  const auto first = blacks.begin();
  auto last = blacks.end();
  for (int i = 1; first != last; ++i) {
    last = std::remove_if(
      first,
      last,
      [&board, i](const Point& p) { return !update(board, p, i); });
  }

  int result = 0;
  for (const auto& v : board) {
    const auto it = std::max_element(
        v.begin(),
        v.end(),
        [](const Cell& lhs, const Cell& rhs) {
          return lhs.count < rhs.count;
        });
    result = std::max(result, it->count);
  }
  return result;
}

int main()
{
  int h, w;
  std::cin >> h >> w;

  Board board(h, Row(w));
  Points blacks;
  for (int i = 0; i < h; ++i) {
    for (int j = 0; j < w; ++j) {
      std::cin >> board[i][j].c;
      if (board[i][j].c == '#') {
        board[i][j].count = 0;
        blacks.emplace_back(j, i);
      }
    }
  }

  std::cout << solve(board, blacks) << std::endl;
}


Measured memory_bytes: 23920
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<cassert>
#include<complex>
#include<numeric>
using namespace std;

//#define int long long
typedef long long ll;

typedef unsigned long long ul;
typedef unsigned int ui;
constexpr ll mod = 1000000007;
const ll INF = mod * mod;
typedef pair<int, int>P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
#define all(v) (v).begin(),(v).end()
typedef pair<ll, ll> LP;
typedef long double ld;
typedef pair<ld, ld> LDP;
const ld eps = 1e-12;
const ld pi = acos(-1.0);

void chmin(int &a, int b) {
	a = min(a, b);
}
void chmax(int &a, int b) {
	a = max(a, b);
}
ll mod_pow(ll a, ll n, ll m = mod) {
	a %= m;
	ll res = 1;
	while (n) {
		if (n & 1)res = res * a%m;
		a = a * a%m; n >>= 1;
	}
	return res;
}

struct modint {
	ll n;
	modint() :n(0) { ; }
	modint(ll m) :n(m) {
		if (n >= mod)n %= mod;
		else if (n < 0)n = (n%mod + mod) % mod;
	}
	operator int() { return n; }
};
bool operator==(modint a, modint b) { return a.n == b.n; }
modint operator+=(modint &a, modint b) { a.n += b.n; if (a.n >= mod)a.n -= mod; return a; }
modint operator-=(modint &a, modint b) { a.n -= b.n; if (a.n < 0)a.n += mod; return a; }
modint operator*=(modint &a, modint b) { a.n = ((ll)a.n*b.n) % mod; return a; }
modint operator+(modint a, modint b) { return a += b; }
modint operator-(modint a, modint b) { return a -= b; }
modint operator*(modint a, modint b) { return a *= b; }
modint operator^(modint a, int n) {
	if (n == 0)return modint(1);
	modint res = (a*a) ^ (n / 2);
	if (n % 2)res = res * a;
	return res;
}

ll inv(ll a, ll p) {
	return (a == 1 ? 1 : (1 - p * inv(p%a, a)) / a + p);
}
modint operator/(modint a, modint b) { return a * modint(inv(b, mod)); }
const int max_n = 1 << 18;
modint fact[max_n], factinv[max_n];
void init_f() {
	fact[0] = modint(1);
	for (int i = 0; i < max_n - 1; i++) {
		fact[i + 1] = fact[i] * modint(i + 1);
	}
	factinv[max_n - 1] = modint(1) / fact[max_n - 1];
	for (int i = max_n - 2; i >= 0; i--) {
		factinv[i] = factinv[i + 1] * modint(i + 1);
	}
}
modint comb(int a, int b) {
	if (a < 0 || b < 0 || a < b)return 0;
	return fact[a] * factinv[b] * factinv[a - b];
}

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


void solve() {
	int n; cin >> n;
	ll x = 1;
	const ll sup = 1e+18;
	rep(i, n) {
		ll a; cin >> a;
		if (x == 0)continue;
		if (sup / x < a)x = sup+1;
		else x *= a;
	}
	if (x > sup)cout << -1 << "\n";
	else cout << x << "\n";
}

signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	//cout << fixed << setprecision(7);
	//init_f();
	//init();
	solve();
	stop
		return 0;
}


Measured memory_bytes: 7724
class Unionfind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * (n+1)
        
    def find(self, x):
        if(self.parents[x] < 0):
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]
        
    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)
        
        if(x == y):
            return
        
        if(self.parents[x] > self.parents[y]):
            x, y = y, x
            
        self.parents[x] += self.parents[y]
        self.parents[y] = x
    
    def size(self, x):
        return -self.parents[self.find(x)]
    
    def same(self, x, y):
        return self.find(x) == self.find(y)
    
    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]
    
    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]
    
    def group_count(self):
        return len(self.roots())
    
    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}
    
    def __str__(self):
        return '\n'.join('{}:{}'.format(r, self.members(r)) for r in self.roots())

N, M = map(int, input().split())
uf = Unionfind(N)

for i in range(M):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    uf.union(a, b)

print(-min(uf.parents))

Measured memory_bytes: 14524
gets.to_i
times = gets.split(' ').map(&:to_i)
m = gets.to_i
drinks = m.times.map do |_|
  gets.split(' ').map(&:to_i)
end

times_map = times.map.with_index(1) { |time, i|
  [i, time]
}.to_h

drinks.each do |d|
  p = d[0]
  x = d[1]
  hash = {}
  hash[p] = x
  sum = 0
  times_map.merge(hash).each do |d| sum += d[1] end
  print("#{sum}\n")
end

Measured memory_bytes: 2172
#include <bits/stdc++.h>
const long long INF = 1LL << 60;
const long long MOD = 1000000007;
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define rep1(i, n) for (ll i = 1; i <= (n); ++i)
#define rrep(i, n) for (ll i = (n - 1); i >= 0; --i)
#define perm(c) sort(ALL(c));for(bool c##p=1;c##p;c##p=next_permutation(ALL(c)))
#define ALL(obj) (obj).begin(), (obj).end()
#define RALL(obj) (obj).rbegin(), (obj).rend()
#define MAX max<ll>
#define MIN min<ll>
#define pb push_back
#define to_s to_string
#define len(v) (ll)v.size()
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
#define print(x) cout << (x) << '\n'
#define drop(x) cout << (x) << '\n', exit(0)
#define debug(x) cout << #x << ": " << (x) << '\n'
using namespace std;
using ll = long long;
typedef pair<ll, ll> P;
typedef vector<ll> vec;
typedef vector<vector<ll>> vec2;
typedef vector<vector<vector<ll>>> vec3;
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; }
ll devc(ll x, ll y) { return (x + y - 1) / y; }

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout << fixed << setprecision(20);

    ll N, K;
    cin >> N >> K;
    rep(i, N){
        ll a;
        cin >> a;
    }
    drop(devc(N - 1, K - 1));
    return 0;
}

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

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

    string s;
    cin >> s;

    if (s.size() < 3)
    {
        cout << 0 << endl;
        return 0;
    }

    long long ans = 0LL;
    int A_num = 0;
    for (int i = 0; i < s.size() - 1; i++)
    {

        if (s[i] == 'B' && s[i + 1] == 'C' && A_num > 0)
        {
            ans += A_num;
            i++;
        }
        else if (s[i] == 'A')
        {
            A_num++;
        }
        else
        {
            A_num = 0;
        }
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 720
#include <iostream>
#include <assert.h>
#include <vector>
#include <unordered_map>
#include <queue>
#include <climits>
#include <cmath>
#include <algorithm>
#include <unordered_set>
using namespace std;
constexpr int64_t MOD = 1e9 + 7;

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

  int32_t N;
  cin >> N;
  vector<int64_t> A(N);
  int64_t sum = 0;
  for (auto& a : A) {
    cin >> a;
    sum += a;
    sum %= MOD;
  }
  int64_t res = 0;
  for (int i = 0; i < N; i++) {
    sum -= A[i];
    if (sum < 0) sum += MOD;
    res += ((A[i] * sum) % MOD);
    res %= MOD;
  }



  cout << res << endl;
  
  return 0;
}


Measured memory_bytes: 4780
#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;
int du[100010];
int n,m;
int main(){
	scanf("%d%d",&n,&m);
	for(int i=1;i<=m;i++){
		int x,y;
		scanf("%d%d",&x,&y);
		du[x]++;du[y]++;
	}
	for(int i=1;i<=n;i++){
		if(du[i]&1){
			printf("NO\n");
			break;
		}
		if(i==n)printf("YES\n");
	}
    return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  long n,m,ans=0;
  cin >> n >> m;
  vector<vector<long>> p(n,vector<long>(3)); 
  for(long i=0;i<n;i++) cin >> p[i][0] >> p[i][1] >> p[i][2];
  for(long i=0;i<8;i++) {
    vector<long> psum(n);
    for(long j=0;j<n;j++) {
      if(i&1) psum[j]+=p[j][0];
      else psum[j]-=p[j][0];
      if(i&2) psum[j]+=p[j][1];
      else psum[j]-=p[j][1];
      if(i&4) psum[j]+=p[j][2];
      else psum[j]-=p[j][2];
    }
    sort(psum.begin(),psum.end());
    reverse(psum.begin(),psum.end());
    long a=0;
    for(long j=0;j<m;j++) a+=psum[j];
    ans=max(ans,a);
  }
  cout << ans << endl;
}

Measured memory_bytes: 3688
/******************************************************************************

рассвет.

*******************************************************************************/
#include <bits/stdc++.h>
typedef long long int lli;
typedef unsigned long long int ulli;
typedef long double ld;
#define rapgame ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define pb push_back
#define eb emplace_back
#define vi vector <int>
#define vlli vector <lli>
#define vulli vector <ulli>
#define vchar vector <char>
#define vstr vector <string>
#define vb vector <bool>
#define fst first
#define sec second
#define all(a) (a).begin(),(a).end()
#define srt(a) sort(a.begin(),a.end())
#define rev(a) reverse(a.begin(),a.end())
#define vpii vector <pair <int,int> >
#define pii pair <int,int>
#define vplli vector <pair <lli,lli> >
#define vvi vector <vector <int> >
#define vvlli vector <vector <lli> >
#define vvpii vector <vector <pair <int,int>> >
#define fr(i,n) for (int i = 0; i < (n); ++i)
#define frbig(i,n) for (lli i = 0; i < (n); ++i)
#define fra(i,a,n) for (lli i = a; i < (n); ++i)
#define run(c,s) for(auto c:s)
#define read(n) int n; cin >> n;
#define readchar(n) char n; cin >> n;
#define readstr(n) string n; cin >> n;
#define readarr(a,n) fr(i,n) cin >> a[i];
#define read2(x,y) int x,y; cin >> x >> y;
#define read2ll(x,y) long long int x,y; cin >> x >> y;
#define readll(n) lli n; cin >> n;
#define watch(x) cout << (#x) << " is " << (x) << endl
#define print_array(x) fr(i,x.size()) cout << x[i];
using namespace std;

const lli MOD=1e9+7;
const lli MAXN=5e4+1;
const ld PI=acos(-1);

int main(){
    rapgame
    //freopen("bridges.in", "r", stdin);
    //freopen("bridges.out", "w", stdout);
    int t=1;
    //cin>>t;
    while(t--){
         read(n);
         char x='A';
         int ans=0;
         fr(i,n) {
             readchar(y);
             if(y!=x) ++ans;
             x=y;
         }
         cout << ans;
    }
    return 0;
}

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

#define int long long
#define vvi vector<vector<int>>
#define vec vector
#define pq priority_queue
#define all(v) (v).begin(), (v).end()
#define uniqueV(x) sort(x.begin(), x.end()); x.erase(unique(x.begin(), x.end()), x.end());
#define rep(i, n) for (int (i) = (0); (i) < (n); ++(i))
#define repp(i, m, n) for (int (i) = (m); (i) < (n); ++(i))
#define dbg(x) cerr << #x << ": " << x << endl;
#define dbg2(x, y) cerr<<"("<<#x<<", "<<#y<<") = "<<"("<<x<<", "<<y<<")"<<endl;
#define dbg3(x, y, z) cerr<<"("<<#x<<", "<<#y<<", "<<#z<<") = "<<"("<<x<<", "<<y<<", "<<z<<")"<<endl;
#define dbgB(value, size) cerr<<#value<<": "<<bitset<size>(value) << endl;
#define line() cerr << "---------------" << endl;

const int dx[] = {1, -1, 0, 0};
const int dy[] = {0, 0, -1, 1};
const double PI = 3.14159265358979323846;

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

template<typename T>
void print1(T begin, T end) {
	while (begin != end) {
		cerr << (*begin) << " ";
		*begin++;
	}
	cerr << endl;
}

template<typename T>
void print2(T Array, int height, int width) {
	for (int i = 0; i < height; i++) {
		for (int j = 0; j < width; j++) {
			cerr << " " << Array[i][j];
		}
		cerr << endl;
	}
}

void print() { std::cerr << endl; }
template <class Head, class... Tail>
void print(Head&& head, Tail&&... tail) {
	std::cerr << head << " ";
	print(std::forward<Tail>(tail)...);
}

template<class T>
void Add(T &a, const T &b, const T &mod=1000000007) {
	int val = ((a % mod) + (b % mod)) % mod;
	if (val < 0) { val += mod; }
	a = val;
}

template <typename X, typename T> auto vectors(X x, T a) { return vector<T>(x, a); }
template <typename X, typename Y, typename Z, typename... Zs> auto vectors(X x, Y y, Z z, Zs... zs) { auto cont = vectors(y, z, zs...); return vector<decltype(cont)>(x, cont); }

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

signed main() {
	string s, t;
	cin >> s >> t;

	cout << (s == t.substr(0, s.size()) ? "Yes" : "No") << endl;

	return 0;
}

Measured memory_bytes: 3560