akhauriyash/Code-Regression huggingface dataset:
///   BISMILLAHIR RAHMANIR RAHEEM
///   ALLAH IS WATCHING ME
///   ALLAH save us from COVID-19.Amin.

///   █▀█─█──█──█▀█─█─█
///   █▄█─█──█──█▄█─█▄█
///   █─█─█▄─█▄─█─█─█─█

///   كُلُّ نَفْسٍ ذَآئِقَةُ الْمَوْت
///   Every soul shall taste death.

/// TODO::

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

///  order_of_key return number of elements less than x.
///  find_by_order return index.

using namespace std;
using namespace __gnu_pbds;


#define MOHAMMAD  ios::sync_with_stdio(0);cin.tie(0);
#define all(x)    (x).begin(), (x).end()
#define AE        cout << fixed << setprecision(10);

int dx8[] = {0, 0, 1, 1, 1, -1, -1, -1}; // 8-direction.......
int dy8[] = {1,-1, 1, -1, 0, 0, -1, 1};
int dx4[]= {1,-1,0,0}; // 4-direction...........
int dy4[]= {0,0,1,-1};

typedef tree< int, null_type, less<int>, rb_tree_tag,tree_order_statistics_node_update> ordered_set;
typedef tree<pair<int, int>,null_type,less<pair<int, int>>,rb_tree_tag,tree_order_statistics_node_update> ordered_multiset;

//debug
template<typename F,typename S>ostream&operator<<(ostream&os,const pair<F,S>&p){return os<<"("<<p.first<<", "<<p.second<<")";}
template<typename T>ostream&operator<<(ostream&os,const vector<T>&v){os<<"{";for(auto it=v.begin();it!=v.end();++it){if(it!=v.begin())os<<", ";os<<*it;}return os<<"}";}
template<typename T>ostream&operator<<(ostream&os,const set<T>&v){os<<"[";for(auto it=v.begin();it!=v.end();++it){if(it!=v.begin())os<<",";os<<*it;}return os<<"]";}
template<typename T>ostream&operator<<(ostream&os,const multiset<T>&v) {os<<"[";for(auto it=v.begin();it!=v.end();++it){if(it!=v.begin())os<<", ";os<<*it;}return os<<"]";}
template<typename F,typename S>ostream&operator<<(ostream&os,const map<F,S>&v){os<<"[";for(auto it=v.begin();it!=v.end();++it){if(it!=v.begin())os<<", ";os<<it->first<<" = "<<it->second;}return os<<"]";}
#define dbg(args...) do {cerr << #args << " : "; faltu(args); } while(0)
void faltu(){cerr << endl;}
template<typename T>void faltu(T a[],int n){for(int i=0;i<n;++i)cerr<<a[i]<<' ';cerr<<endl;}
template<typename T,typename...hello>void faltu(T arg,const hello&...rest){cerr<<arg<<' ';faltu(rest...);}
//#else
//#define dbg(args...)
//***********************************************  The END **********************************************************************************************************************************
using ll = long long;
const ll N = 1e5 + 1;
const ll INF = 1e18;
const ll mod = 1e9 + 7;


int main()
{

  MOHAMMAD

  ll n;
  cin >> n;

  n%=1000;

  if(!n) cout << 0;
  else cout << 1000 - n;

}


/*





  Alhamdulillah
*/



Measured memory_bytes: 3648
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define ld long double
#define ull unsigned long long
#define pii pair<int,int>
#define pll pair<ll,ll>
#define _h cout<<"here"<<endl;
#define fill(a,v) memset(a,v,sizeof(a));
#define all(v) v.begin(),v.end()
#define rep(i,n) for(int i=0;i<n;i+=1)
#define prd(a,n) rep(i,n) cout<<a[i]<<" \n"[i==n-1];// printf("%s\n"," " );
#define ff first
#define ss second
#define pu push_back
const int inf = 1e9+10;
const ll INF = 2e18+10;
const int Mod = 1e9+7;
const int MAXN = 1000010;
const int N=2e5+10;
const int M=210;
const int M1=1e9+7;
const int M2=1e9+9;
const int base=131;
int main()
{
  ios::sync_with_stdio(0), cin.tie(0); cout.tie(0);
  // freopen("input.txt","r",stdin);
  // freopen("output.txt","w",stdout);
  int n;
  cin>>n;
  int x=n/1000;
  int y=x*1000;
  if(y<n) y+=1000;
  // cout<<y<<endl;
  cout<<(y-n)<<endl;
  return 0;
}


Measured memory_bytes: 3600
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vint;
typedef pair<int, int> pint;
typedef vector<long long> vlong;
#define vpush(a,x) a.push_back(x);
#define rep(i, n) REP(i, 0, n)
#define all(v) v.begin(), v.end()
#define REP(i, x, n) for(int i = x; i < n; i++)
#define INF 2e9
signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int x;
  	cin>>x;
  	if(x<100){
      cout<<0<<'\n';
      return(0);
    }
  	vector<bool> dp(x+10);
  	REP(i,0,x+1){
      dp[i]=false;
    }
  	dp[0]=true;
  	REP(i,100,x+1){
      if(dp[i-100]){
        dp[i]=true;
      }
     else if(dp[i-101]){
       dp[i]=true;
     }
      else if(dp[i-102]){
        dp[i]=true;
      }
      else if(dp[i-103]){
        dp[i]=true;
      }
      else if(dp[i-104]){
        dp[i]=true;
      }
      else if(dp[i-105]){
        dp[i]=true;
      }
    }
  	if(dp[x]==true){
      cout<<1<<'\n';
    }
  	else{
      cout<<0<<'\n';
    }
    return(0);
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<cmath>
#include<algorithm>
#include<string>
int main(void)
{
	int n,q,b,e,com;
	int a[1000];
	std::cin >> n;//数列の個数を入力
	for (int i = 0; i < n; i++)
	{
		std::cin >> a[i];//与えられる数列を入力
	}
	std::cin >> q;//クエリ処理の個数

	for(int j = 0 ; j < q;j++)
	{
		std::cin >> com >> b >> e;
		switch(com)//comが0の時は最小値、1の時は最大値を出力
		{
		    case 0:
			    std::cout<< *std::min_element(a + b,a + e) <<std::endl;//min_element関数は指定範囲の数の最小値を求める
			    break;

			case 1:
			    std::cout << *std::max_element(a + b,a + e) <<std::endl;//max_element関数は指定範囲の数の最大値を求める
			    break;
		}
	}
}



Measured memory_bytes: 3108
#include <bits/stdc++.h>
using namespace std;
const int INF=1e9+5;
typedef long long ll;

int main() {
  int N;
  cin>>N;
  if(N%2==1){
    cout<<N/2*(N/2+1)<<endl;
  }
  else{
    cout<<N/2*N/2<<endl;
  }
  
}


Measured memory_bytes: 256
h,w=map(int,input().split())
g=[input() for _ in range(h)]
for x in range(1,h-1):
  for y in range(1,w-1):
    if g[x][y]=='#' and all(g[x+dx][y+dy]=='.' for dx,dy in ((1,0),(0,1),(-1,0),(0,-1))):
      print('No'); exit()
print('Yes')

Measured memory_bytes: 3064
#include <stdio.h>

int 
main(){
	int p[20];
	int n;
	int j;
	int cnt = 0;
	scanf("%d",&n);
	for(j=0;j<n;j++)scanf("%d",&p[j]);
	
	for(j=0;j<n-2;j++){
		if((p[j]-p[j+1])*(p[j+2]-p[j+1])<0) cnt++;
	}
	printf("%d\n",cnt);
		
	
 return 0;
}

Measured memory_bytes: 128
package main

import (
	"bufio"
	"fmt"
	"os"
)

var sc = bufio.NewScanner(os.Stdin)

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

func main() {
	S := nextString()

	i, j := 0, len(S)-1

	count := 0
	for {
		if S[i] != S[j] {
			count++
		}
		if len(S)%2 == 0 {
			if i+1 == j {
				break
			}
		} else {
			if i == j {
				break
			}
		}
		i++
		j--
	}
	fmt.Println(count)
}


Measured memory_bytes: 640
import collections 

n = int(input())
lst = list(map(int,input().split()))
lst_mode_odd = collections.Counter(lst[::2]).most_common()
l_odd = len(lst_mode_odd)
n_odd = lst_mode_odd[0][1]
num_odd = lst_mode_odd[0][0]
lst_mode_even = collections.Counter(lst[::-2]).most_common()
l_even = len(lst_mode_even)
n_even = lst_mode_even[0][1]
num_even = lst_mode_even[0][0]
if num_odd == num_even:
    if l_odd == l_even ==1:
        print(int(len(lst)/2))
        exit()
    elif l_odd == 1:
        n_even = lst_mode_even[1][1]
    elif l_even == 1:
        n_odd = lst_mode_odd[1][1]
    else:
        res_odd = lst_mode_odd[0][1]- lst_mode_odd[1][1]
        res_even = lst_mode_even[0][1]- lst_mode_even[1][1]
        if res_odd >= res_even:
            n_even = lst_mode_even[1][1]
        else:n_odd = lst_mode_odd[1][1]
    
ans = len(lst) - n_odd -n_even
print(ans)

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

def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n//i:
                divisors.append(n//i)

    divisors.sort()
    return divisors

for x in range(X, 10**6+1):
    divisors = make_divisors(x)
    if len(divisors)==2:
        print(x)
        exit()


Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
signed main(){
  int y1,m1,d1;
  cin>>y1>>m1>>d1;
  int y2,m2,d2;
  cin>>y2>>m2>>d2;
  auto sw=[&](){
    swap(y1,y2);swap(m1,m2);swap(d1,d2);
  };
  if(m1>m2) sw();
  if(m1==m2&&d1>d2) sw();
  if(m1==m2&&d1==d2){
    cout<<abs(y1-y2)<<endl;
    return 0;
  }
  cout<<abs(y2-y1)+(y1<=y2)<<endl;
  return 0;
}

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

int main(){
  string S,T;
  cin>>S>>T;
  map<char,char>X;
  bool ans=true;

  for(int i=0;i<S.size();++i){
  if(!X.count(S.at(i))){
    X[S.at(i)]=T.at(i);
  }
  else{
    if(X[S.at(i)]!=T.at(i)){
      ans=false;
      break;
    }
  }
  }

  set<char> Y;
  for(auto p:X){
    Y.insert(p.second);
  }
  if(Y.size()!=X.size()){
    ans=false;
  }


  if(ans){cout<<"Yes"<<endl;}
  else{cout<<"No"<<endl;}
}

Measured memory_bytes: 776
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;

int main() {
  int h, w;
  cin >> h >> w;
  vector<string> v(h);
  
  for (int i=0; i<h; i++){
      cin >> v[i];
  }
 
  set<int> sh, sw;
  for (int i=0; i<h; i++){
    for (int j=0; j<w; j++){
      if (v[i][j] == '#'){
        sh.insert(i);
      }
    }
  }
  
  
  for (int i=0; i<w; i++){
    for (int j=0; j<h; j++){
      if (v[j][i] == '#'){
        sw.insert(i);
      }
    }
  }
  
  
  for (int i=0; i<h; i++){
    bool kaigyou = false;
    if(sh.count(i) == 0){
      continue;
    }
    for (int j=0; j<w; j++){
      if (sw.count(j) != 0){
        cout << v[i][j];
        kaigyou = true;
      }  
    }
    if(kaigyou){
      cout << endl;
    }
  }
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>

using namespace std;

#define ll long long
#define ld long double
#define EPS 0.0000000001
#define INF 1e9
#define MOD 1000000007
#define rep(i,n) for(i=0;i<n;i++)
#define loop(i,a,n) for(i=a;i<n;i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
#define int ll
typedef vector<int> vi;
typedef pair<int,int> pii;

signed main(void) {
  int i,j;
  int n,k;
  cin>>n>>k;
  vi a(100005,0);
  rep(i,n){
    int x,y;
    cin>>x>>y;
    a[x]+=y;
  }
  int sum=0;
  rep(i,100005){
    sum+=a[i];
    if(sum>=k){
      cout<<i<<endl;
      return 0;
    }
  }
}


Measured memory_bytes: 1024
def f(n, x):
    if n == 0:
        return 0 if x <= 0 else 1
    elif x <= (a[n-1] + 1):
        return f(n - 1, x - 1)
    else:
        return p[n - 1] + 1 + f(n - 1, x - 2 - a[n - 1])


n, x = map(int, input().split())

a, p=[1],[1]
for i in range(n):
    a.append(a[i] * 2 + 3)
    p.append(p[i] * 2 + 1)
    
print(f(n, x))

Measured memory_bytes: 3064
//ΔARC 078D
#include<iostream>
#include<cstdio>
#include<fstream>
#include<algorithm>
#include<vector>
#include<map>
#include<set>
#include<queue>
#include<cmath>
#include<cstring>
#include<cstdlib>
using namespace std;
typedef long long LL;
vector<int> v[111111];
int f[111111],t[111111],a[111111];
void dfs(int u,int fa){
	int i;
	f[u]=fa;
	t[u]=1;
	for(i=0;i<v[u].size();i=i+1)
		if(v[u][i]!=fa){
			dfs(v[u][i],u);
			t[u]+=t[v[u][i]];
		}
}
int main()
{
	int n,i,x,y;
	scanf("%d",&n);
	for(i=1;i<n;i=i+1){
		scanf("%d%d",&x,&y);
		v[x].push_back(y);
		v[y].push_back(x);
	}
	dfs(1,0);
	x=n;
	i=0;
	while(x){
		i++;
		a[i]=x;
		x=f[x];
	}
	y=a[i/2];
	x=t[y];
	y=n-x;
	if(x<y)
		cout<<"Fennec\n";
	else
		cout<<"Snuke\n";
	return 0;
}

Measured memory_bytes: 13440
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <string>
#include <ctime>
#include <algorithm>
#include <vector>
#include <cstring>
#include <stack>
#include <queue>
#include <utility>
#include <cmath>
#include <functional>
#include <map>
#include <set>
const int INF = 1000000009;

int n;
std::priority_queue<int> que;

int main(){
	scanf("%d", &n);
	for(int i = 0; i < n; i++){
		int a;
		scanf("%d", &a);
		que.push(a);
	}
	int vis = 0;
	int cnt = 0;
	int ans = 0;
	while(!que.empty()){
		int a = que.top();
		que.pop();
		if(vis == a){
			cnt++;
		}else{
			if(vis > cnt){
				ans += cnt;
			}else{
				ans += cnt-vis;
			}
			cnt = 1;
			vis = a;
		}
	}
	if(vis > cnt){
		ans += cnt;
	}else{
		ans += cnt-vis;
	}
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 892
using System;

class C
{
	static void Main()
	{
		var words = new[] { "dream", "dreamer", "erase", "eraser" };
		var s = Console.ReadLine();
		Dfs(0);
		Console.WriteLine("NO");

		void Dfs(int i)
		{
			foreach (var w in words)
			{
				if (!Contains(s, i, w)) continue;
				var ni = i + w.Length;
				if (ni == s.Length) { Console.WriteLine("YES"); Environment.Exit(0); }
				Dfs(ni);
			}
		}
	}

	static bool Contains(string s, int start, string w)
	{
		for (int i = 0; i < w.Length; i++)
			if (start + i >= s.Length || s[start + i] != w[i]) return false;
		return true;
	}
}


Measured memory_bytes: 27952
import std.algorithm;
import std.array;
import std.conv;
import std.math;
import std.range;
import std.stdio;
import std.string;
import std.typecons;

int readint() {
    return readln.chomp.to!int;
}

int[] readints() {
    return readln.split.map!(to!int).array;
}

void main() {
    readint();
    auto ss = readints();

    bool[int] map;
    foreach (s; ss)
        map[s] = true;

    readint();
    auto ts = readints();
    auto ans = ts.count!(e => (e in map) != null);
    writeln(ans);
}

Measured memory_bytes: 2524
#include<iostream>
#include<stdio.h>
#include<cstring>
#include<cmath>
#include<vector>
#include<set>
#include<map>
#include<algorithm>
#include<unordered_map>
#include<bits/stdc++.h>
#define ll long long 
#define dd double
using namespace std;
const ll MOD = 1e9 + 7; 
 
int main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  
  int a,b,t;
  cin>>a>>b>>t;
  t=t+0.5;
  
  if(a>t){
  	cout<<"0"<<endl;
  }
  else{
  	int p=t/a;
  	cout<<p*b<<endl;
    
  }
  return 0;
}

Measured memory_bytes: 3640
#!/usr/bin/env python3
import sys
import itertools
import math
def input():
    return sys.stdin.readline()[:-1]

def main():
    N = int(input())
    x = [0] * N
    y = [0] * N
    for i in range(N):
        x[i], y[i] = map(int, input().split())

    l = [i for i in range(N)]
    p = [i for i in itertools.permutations(l, N)]
    d = 0
    for i in range(len(p)):
        t = p[i]
        for j in range(N - 1):
            d += math.sqrt(((x[t[j]] - x[t[j + 1]]) ** 2) + ((y[t[j]] - y
            [t[j + 1]])) ** 2)
    ans = d / math.factorial(N)
    print(ans)

if __name__ == '__main__':
    main()


Measured memory_bytes: 80008
n = int(input())
T,a = map(int, input().split())
A = list(map(int, input().split()))
ANS = []
for i in range(len(A)):
  t = T - A[i] * 0.006
  ANS.append(abs(t-a))
  
for i in range(len(ANS)):
  if ANS[i] == min(ANS):
    print(i+1)
    exit()

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

int gcd(int a, int b){
    
    if(a==0)return b;
    if(b==0)return a;
    
    if(a<b)
        swap(a,b);
    
    while(a%b!=0){
        a %= b;
        swap(a,b);
    }
    return b;
}

int main() {
    int n;cin>>n;
    vector<int> a(n);
    rep(i,n)cin>>a[i];
    
    vector<int> lg(n,0), rg(n,0);
    
    for(int i=1; i<n; i++){
        lg[i] = gcd(lg[i-1], a[i-1]);
    }
    for(int i=n-2; i>=0; i--){
        rg[i] = gcd(rg[i+1], a[i+1]);
    }
    
    int ans = 0;
    
    for(int i=0; i<n; i++){
        ans = max(ans, gcd(lg[i], rg[i]));
    }
    
    cout << ans << endl;
    
    return 0;
}

Measured memory_bytes: 1408
N, K = map(int, input().split())
S = input()

score = 0
preS_i = S[0]
mukiatteru = 0
hanareatteru = 0

for i in range(1,N):
  if S[i] == preS_i:
    score += 1
  else:
    if S[i] == "L":
      mukiatteru += 1
    else:
      hanareatteru += 1
    preS_i = S[i]

if min(mukiatteru, hanareatteru) >= K:
  score += 2*K
else:
  score += min(mukiatteru, hanareatteru) + min(K, max(mukiatteru, hanareatteru))
print(score)
  
    

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

int main()
{
    int n;
    cin >> n;
    map<string, int> mp;
    rep(i,n){
        string s;
        cin >> s;
        mp[s]++;
    }
    int mx = 0;
    for(auto p : mp) mx = max(mx, p.second);
    for(auto p : mp){
        if(p.second != mx) continue;
        cout << p.first << endl;
    }
    return 0;
}

Measured memory_bytes: 17664
#include <stdio.h>

#define N 100

int p[N],m[N][N],n;

int min(int x,int y){

  int mini=0;

  if(x<y) {mini=x;}

  else mini=y;

  return mini;

}

void matrixChainOrder(){

  int i,j,l,k,q;

  for(i=1;i<=n;i++){

    m[i][i]=0;

  }

  for(l=2;l<=n;l++){

    for(i=1;i<=n-l+1;i++){

      j=i+l-1;

      m[i][j]=100000000;

      for(k=i;k<=j-1;k++){

	q=m[i][k]+m[k+1][j]+p[i-1]*p[k]*p[j];

	m[i][j]=min(m[i][j],q);
      }
    }
  }
}


int main()
{
  int i,j,r,c;

  scanf("%d",&n);

  for(i=0;i<n;i++){

    scanf("%d%d",&r,&c);

    p[i]=r;
    p[i+1]=c;

  }

  matrixChainOrder();

  printf("%d\n",m[1][n]);

  return 0;

}

Measured memory_bytes: 636
#include <iostream>
using namespace std;
int main(void){
    int n,a;
    cin >> n;
    a=n%10;
    if(a==2||a==4||a==5||a==7||a==9){
        cout << "hon";
    }else if(a==0||a==1||a==6||a==8){
        cout << "pon";
    }else if(a==3){
        cout <<  "bon";
    }
    
}


Measured memory_bytes: 3592
S = gets.chomp
N = S.size
leftS = S[0..(N-1)/2-1]
rightS = S[(N+3)/2-1..N]

result = "No"
if S == S.reverse then
    if leftS == leftS.reverse then
        if rightS == rightS.reverse then
            result = "Yes"
        end
    end
end
puts result

Measured memory_bytes: 3836
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n,m;	cin >> n >> m;
  vector<int>	s(m);
  vector<char>	c(m);
  for(int i=0;i<m;i++){
    cin >> s.at(i) >> c.at(i);
    s.at(i)--;
  }
  
  for(int i=0;i<1000;i++){
    bool ok=true;
    string num=to_string(i);
    if(num.size()!=n){
      ok=false;
    }else{
      for(int x=0;x<m;x++){
        if(s.at(x)<n){
          if(num.at(s.at(x))!=c.at(x)){
            ok=false;
          }
        }
      }
    }
    if(ok){
      cout << num;
      return 0;
    }
  }
  cout << -1;
}

Measured memory_bytes: 3592
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;
import java.util.stream.IntStream;

public class Main {

    public static void main(String[] args) throws NumberFormatException, IOException {
        Stdin stdin = new Stdin();
        int n = stdin.nextInt();
        int m = stdin.nextInt();

        // key=言語 vals=使用者
        List<List<Integer>> d = IntStream.range(0, m).mapToObj(unused -> new ArrayList<Integer>()).collect(Collectors.toList());
        for (int i = 0; i < n; i++) {
            int k = stdin.nextInt();
            for (int j = 0; j < k; j++) {
                int l = stdin.nextInt() - 1;
                d.get(l).add(i);
            }
        }

        UnionFind uf = new UnionFind(n);
        for (int i = 0; i < m; i++) {
            List<Integer> vals = d.get(i);
            for (int j = 1; j < vals.size(); j++) {
                uf.union(vals.get(0), vals.get(j));
            }
        }

        long count = IntStream.range(0, n).map(uf::find).distinct().count();
        String ans = (count == 1) ? "YES" : "NO";
        System.out.println(ans);
    }

    private static class UnionFind {
        private int[] parents;

        public UnionFind(int size) {
            parents = IntStream.range(0, size).toArray();
        }

        public int find(int x) {
            if (x == parents[x]) {
                return x;
            } else {
                parents[x] = find(parents[x]);
                return parents[x];
            }
        }

        public void union(int x, int y) {
            x = find(x);
            y = find(y);
            if (x != y) {
                parents[x] = y;
            }
        }

    }

    private static final class Stdin {
        private BufferedReader stdin;
        private ArrayDeque<String> tokens;

        public Stdin() {
            this.stdin = new BufferedReader(new InputStreamReader(System.in));
            this.tokens = new ArrayDeque<>();
        }

        public String nextToken() throws IOException {
            if (tokens.isEmpty()) {
                for (String token : stdin.readLine().split(" ")) {
                    tokens.add(token);
                }
            }
            return tokens.poll();
        }

        public int nextInt() throws NumberFormatException, IOException {
            return Integer.parseInt(nextToken());
        }

        public int nextLong() throws NumberFormatException, IOException {
            return Integer.parseInt(nextToken());
        }
    }
}


Measured memory_bytes: 56340
#include <iostream>
#include <queue>
using namespace std;
using ll = long long;
#define rep(i,n) for(int i=0;i<(n);++i)
#define in(v) cin>>v;
#define out(v) cout<<v<<"\n"

int main() {
  cin.tie(0); ios::sync_with_stdio(false);
  int N, M; in(N); in(M);

  priority_queue<int> A;
  rep(i, N) {
    int a; in(a);
    A.push(a);
  }
  rep(i, M) {
    int p = A.top(); A.pop();
    A.push(p / 2);
  }
  ll sum = 0;
  while (!A.empty()) {
    int p = A.top(); A.pop();
    sum += p;
  }
  out(sum);

  return 0;
}


Measured memory_bytes: 892
#include<iostream>
#include<algorithm>
#define REP(i,n) for(int i=0;i<n;i++)
using namespace std;

int main() {
    int W, H, x, y, r;
    cin >> W >> H >> x >> y >> r;
    if ((r <= x && x <= W-r) && (r <= y && y <= H-r)) cout << "Yes" << endl;
    else cout << "No" << endl;
    
    return 0;
}


Measured memory_bytes: 3096
#include <stdio.h>
#include <math.h>
int isprime(int);

int main(){
  int i, count=0, n, x;
  scanf("%d", &n);
  for(i = 0; i < n; i++){
    scanf("%d", &x);
    if(isprime(x) == 0) count++;
    else continue;
  }
  printf("%d\n", count);
  return 0;
}

int isprime(int x){
  int i=3;
  if(x == 2) return 0;

  if(x < 2 || x % 2 == 0)return 1;

  while(i <= sqrt(x)){
    if (x % i == 0) return 1;
    i = i + 2;
  }
  return 0;
}


Measured memory_bytes: 2024
//#include <bits/stdc++.h>
//#include <stdio.h>
#include<iostream>
#include<cstdio>
#include<bitset>
#include<algorithm>
#include<vector>
#include<list>
#include<queue>
#include<stack>
#include<string>
#include<string.h>
#include<cmath>
#include<utility>
#include<functional>
#include<map>
#include<set>
#include<cctype>
#include<fstream>


#define FOR(i, a, b) for( int i=(a);i<=(b);i++)
#define RFOR(i, a, b) for( int i=(a);i>=(b);i--)
#define LFOR(i, a, b) for( long long int i=(a);i<=(b);i++)
#define LRFOR(i, a, b) for(long long int i=(a);i>=(b);i--)
#define MOD 1000000007
#define INF 1000000000 //2000000000
#define LLINF 1000000000000000000 //9000000000000000000
#define PI 3.14159265358979
#define MAXI 7500000

using namespace std;
typedef long long int ll;
typedef pair< long long int, long long  int> P;

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



int main(void) {
	int s;
	int res;

	vector<bool> flag(1000001, false);

	cin >> s;

	flag[s] = true;

	FOR(i, 2, INF) {
		if (s % 2 == 0) {
			s /= 2;
		}
		else {
			s = 3 * s + 1;
		}
		if (flag[s] == true) {
			res = i;
			break;
		}
		else {
			flag[s] = true;
		}
	}

	cout << res << endl;

	return 0;
}

Measured memory_bytes: 384
import bisect,collections,copy,heapq,itertools,math,numpy,string
import sys
def S(): return sys.stdin.readline().rstrip()
def I(): return int(sys.stdin.readline().rstrip())
def SS(): return map(str,sys.stdin.readline().rstrip().split())
def II(): return map(int,sys.stdin.readline().rstrip().split())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def LS(): return list(sys.stdin.readline().rstrip().split())

N = I()
D,X = II()
A = [I() for _ in range(N)]

for a in A:
  cnt = 0
  d = 1
  while True:
    if D >= d:
      cnt += 1
      d += a
    else:
      break
  X += cnt
print(X)

Measured memory_bytes: 12228
#include <iostream>
#include <cmath>
#include <cstdio>
#include <algorithm>
#include <cstring>
using namespace std;

int t[100005],x[100005],y[100005];
int main()
{
	int n;
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		cin>>t[i]>>x[i]>>y[i];
	}
	for(int i=1;i<=n;i++)
	{
		if(int(fabs(t[i]-t[i-1]))<int(fabs(x[i]-x[i-1])+fabs(y[i]-y[i-1])))
		{
			cout<<"No";
			return 0;
		}
		if(int(fabs(t[i]-t[i-1]))%2!=int(fabs(x[i]-x[i-1])+fabs(y[i]-y[i-1]))%2)
		{
			cout<<"No";
			return 0;
		}
	}
	cout<<"Yes";
	return 0;
}


Measured memory_bytes: 1408
N, M, X=map(int, input().split())
C=[0]*N
A=[]
for i in range(N):
  tmp=list(map(int, input().split()))
  C[i]=tmp[0]
  A.append(tmp[1:])
  
def num2bi(x, k):
  out=format(x, '0'+str(k)+'b')
  return out

cand=[]

tmp=2**N
for i in range(tmp):
  kau=num2bi(i, N)
  nouryoku=[0]*M
  kane=0
  for j in range(N):
    if kau[j]=='1':
      kane+=C[j]
      for k in range(M):
        nouryoku[k]+=A[j][k]
        
  if sum([1 if nouryoku[k]>=X else 0 for k in range(M)])==M:
    cand.append(kane)
    
if len(cand)==0:
  print(-1)
else:
  print(min(cand))

Measured memory_bytes: 9324
var GET=(function(){function f(s){return new g(s);}function g(s){this._s=s.trim().split("\n");this._y=0;}g.prototype.a=function(f){var s=this._s, y=this._y, r;if(typeof s[y]==="string")s[y]=s[y].split(" ").reverse();r=s[y].pop();if(!s[y].length)this._y++;return f?r:+r;};g.prototype.l=function(f){var s=this._s[this._y++].split(" ");return f?s:s.map(a=>+a);};g.prototype.m=function(n,f){var r=this._s.slice(this._y,this._y+=n).map(a=>a.split(" "));return f?r:r.map(a=>a.map(a=>+a));};g.prototype.r=function(n,f){var r=this._s.slice(this._y,this._y+=n);return f?r:r.map(a=>+a);};return f;})();
var o=GET(require("fs").readFileSync("/dev/stdin","utf8"));
function xArray(v){var a=arguments,l=a.length,r="Array(a["+--l+"]).fill(0).map(x=>{return "+v+";})";while(--l)r="Array(a["+l+"]).fill(0).map(x=>"+r+")";return eval(r);}
function unionFind(n){this.a=Array(n+1).fill(-1);this.w=Array(n+1).fill(0);}
unionFind.prototype={
  root:function(i){if(this.a[i]<0)return i;var r=this.root(this.a[i]);this.w[i]+=this.w[this.a[i]];return this.a[i]=r;},
  same:function(x,y){return this.root(x)===this.root(y);},
  unite:function(x,y,w){w+=this.weight(x);w-=this.weight(y);x=this.root(x);y=this.root(y);if(x===y)return false;if(this.a[y]<this.a[x]){this.a[y]+=this.a[x];this.a[x]=y;return this.w[x]=-w;}this.a[x]+=this.a[y];this.a[y]=x;return this.w[y]=w;},
  size:function(i){return -this.a[this.root(i)];},
  weight:function(i){this.root(i);return this.w[i];},
  diff:function(x,y){return this.weight(x)-this.weight(y);},
}

console.log(main());
function main(){
  var n = o.a();
  var uf = new unionFind(n);
  for(var i = 1; i < n; i++){
    var t = o.l();
    var v1 = t[0]-1;
    var v2 = t[1]-1;
    var w = t[2];
    uf.unite(v1,v2,w&1);
  }

  var ans = [0];
  for(var i = 1; i < n; i++){
    ans[i] = 0;
    if(uf.diff(0,i) & 1)ans[i] = 1;
  }
  return ans.join("\n");
}

Measured memory_bytes: 32172
n = int(input())
taro=0
hanako=0
for _ in range(n):
    s1,s2 = input().split( )
    #print(s1>s2,s1<s2,s1==s2)
    
    if s1 > s2:
        taro += 3
        #print("tr")
        
    elif s1 < s2:
        hanako += 3
        #print("hn")
    
    elif s1 == s2:
        taro += 1
        hanako += 1
        #print("drw")
print(taro, hanako)
    


Measured memory_bytes: 5600
#include "bits/stdc++.h"
 
typedef long long ll;
#define int ll
#define fi first
#define se second
#define SORT(a) sort(a.begin(),a.end())
#define rep(i,n) for(int i = 0;i < (n) ; i++) 
#define REP(i,n) for(int i = 0;i < (n) ; i++) 
#define MP(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define INF LLONG_MAX/2
 
using namespace std;
int MOD = 1000000007;
   
signed main(){
    
    int n,m;
    cin >> n >> m;
    int x[100010] = {0};
    rep(i,m){
        int a,b;
        cin >> a >> b;
        x[a]++;
        x[b]++;
    }
    for(int i = 1;i <= n;i++){
        if(x[i]%2){
            cout << "NO" << endl;
            return 0;
        }
    }
    cout  << "YES" << endl;

    return 0;   
}
// g++ -std=c++14 code1.cpp
// rm -r -f test;oj dl https://ddcc2019-final.contest.atcoder.jp/tasks/ddcc2019_final_a
// rm -r -f test;oj dl http://agc013.contest.atcoder.jp/tasks/agc013_b

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

using namespace std;

const long long inf = (1LL << 62);
vector < pair < int, long long > > G[305];
int N, last[305][305], m[305][305];
long long D[305][305], sol, a[305][305], dist[305];

struct asd {
    int x, y;
    long long cost;
};

struct cmp {
    bool operator()(const asd &a, const asd &b) const {
        return a.cost > b.cost;
    }
};

priority_queue < asd, vector < asd >, cmp > Q;

int main() {
    cin >> N;
    for (int i = 1; i <= N; ++i) {
        for (int j = 1; j <= N; ++j) {
            cin >> D[i][j];
            a[i][j] = D[i][j];
            last[i][j] = i;
            
            G[i].emplace_back(j, a[i][j]);
            G[j].emplace_back(i, a[i][j]);
        }
    }
    
    for (int k=1; k<=N; ++k)
        for (int i=1; i<=N; ++i)
            for (int j=1; j<=N; ++j)
                if (i!=j && D[i][k]*D[k][j] && (!D[i][j] || D[i][k]+D[k][j]<D[i][j]))
                    D[i][j]=D[i][k]+D[k][j] , last[i][j]=last[k][j];
                    
    for (int i = 1; i <= N; ++i) {
        for (int j = 1; j <= N; ++j) {
            if (a[i][j] != D[i][j]) {
                cout << -1 << '\n';
                return 0;
            }
        }
    }
    
    map < asd, int > H;
    for (int k=1; k<=N; ++k) {
        for (int i=1; i<=N; ++i) {
            for (int j=1; j<=N; ++j) {
                if (i != j && i != k && k != j && a[i][k] + a[k][j] == a[i][j]) {
                    m[i][j] = 1;
                }
            }
        }
    }
    
    for (int i = 1; i <= N; ++i) {
        for (int j = 1; j < i; ++j) {
            if (m[i][j] == 0) {
                sol += a[i][j];
            }
        }
    }
    
    cout << sol << '\n';
    return 0;
}

Measured memory_bytes: 6784
package main

import "fmt"

const inf = 1 << 60

func reverse(a []int) {
	for i, j := 0, len(a)-1; i < j; i, j = i+1, j-1 {
		a[i], a[j] = a[j], a[i]
	}
	return
}
func chmin(a *int, b int) bool {
	if *a > b {
		*a = b
		return true
	}
	return false
}
func main() {
	var n int
	var s string
	fmt.Scan(&n, &s)
	w := make([]int, n)
	e := make([]int, n)
	for i := 0; i < n; i++ {
		if s[i] == 'W' {
			w[i] = 1
		} else {
			e[i] = 1
		}
	}
	w = append([]int{0}, w...)
	for i := 1; i < len(w); i++ {
		w[i] += w[i-1]
	}
	e = append(e, 0)
	reverse(e)
	for i := 1; i < len(e); i++ {
		e[i] += e[i-1]
	}
	reverse(e)
	minCost := inf
	for i := 0; i < n; i++ {
		cost := (w[i] - w[0]) + (e[i+1] - e[n])
		chmin(&minCost, cost)
	}
	fmt.Println(minCost)
}


Measured memory_bytes: 12672
#include <bits/stdc++.h> 
using namespace std;
int main() {
    string S;
    cin >> S;
    int num = atoi(S.c_str());
    int sum = 0;
    for(int i=0;i<S.size();i++){
        sum += (S[i]-'0');
    } 
    if (num%sum==0)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

long long diff_dim(long long d1, long long d2, long long d3)
{
    return max(max(abs(d1 - d2), abs(d1 - d3)), abs(d2 - d3));
}

long long solve(long long H, long long W)
{
    long long ans = H * W;
    for (long long h = 1; h < H; ++h) {
        long long d1 = h * W;
        long long remain_h = H - h;
        long long w2 = W / 2;
        long long w3 = W - w2;
        long long d2 = w2 * remain_h;
        long long d3 = w3 * remain_h;
        long long cand = diff_dim(d1, d2, d3);
        ans = min(cand, ans);

        if (remain_h == 1) {
            continue;
        }
        long long h2 = remain_h / 2;
        long long h3 = remain_h - h2;
        d2 = h2 * W;
        d3 = h3 * W;
        cand = diff_dim(d1, d2, d3);
        ans = min(cand, ans);
    }

    return ans;
}

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

    if (H % 3 == 0 || W % 3 == 0) {
        cout << 0 << endl;
        return 0;
    }

    long long ans1 = solve(H, W);
    long long ans2 = solve(W, H);
    cout << min(ans1, ans2) << endl;

    return 0;
}


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

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

  const int NMMAX = 50;
  int a[NMMAX],b[NMMAX];

  for (int i=0; i < M; ++i) cin >> a[i] >> b[i];

  int road[NMMAX];
  for (int i=0; i < N; i++)  road[i] = 0;
  
  for (int i=0; i < M; ++i){
    ++road[a[i] -1];
    ++road[b[i] -1];
  }

  for (int i=0; i < N; ++i){
    cout << road[i] << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(){
	double W, H;
	int N;
	double *posX = NULL;
	double *posY = NULL;
	double *a = NULL;

	cin >> W >> H >> N;

	double max_1 = 0;
	double max_2 = W;
	double max_3 = 0;
	double max_4 = H;

	posX = new double[N];
	posY = new double[N];
	a = new double[N];
	double result;

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

	for(int i = 0; i < N; i++){
		int num = a[i];
		switch(num){
		case 1:
			if(max_1 < posX[i]){
				max_1 = posX[i];
			}
			break;
		case 2:
			if(max_2 > posX[i]){
				max_2 = posX[i];
			}
			break;
		case 3:
			if(max_3 < posY[i]){
				max_3 = posY[i];
			}
			break;
		case 4:
			if(max_4 > posY[i]){
				max_4 = posY[i];
			}
			break;
		default:
			break;
		}
	}

	if((max_2 - max_1 > 0) && (max_4 - max_3 > 0)){
		result = (max_2 - max_1) * (max_4 - max_3);
	}else{
		result = 0;
	}

	cout << result << endl;

	delete[] posX;
	delete[] posY;
	delete[] a;

	return 0;
}


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

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------


string T;

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>T;
	
	vector<int> num;
	num.push_back(0);
	int C1=0;
	ll ret=0;
	int cur=0;
	int fix=0;
	FOR(i,T.size()) {
		if(T[i]=='0') {
			if(cur%2) num.push_back(0);
			fix+=cur/2;
			num.back()++;
			cur=0;
		}
		else {
			C1++;
			cur++;
			ret+=(C1+1)/2;
		}
	}
	fix+=cur/2;
	if(cur%2) num.push_back(0);
	
	ret+=1LL*count(ALL(T),'0')*fix;
	
	
	FOR(i,num.size()-1) if(i && num[i]) {
		num[i]--;
		ret+=i+(num.size()-1-i+1)/2;
	}
	fix=num.size()-1;
	int CC[2]={};
	for(i=num.size()-1;i>=0;i--) {
		while(num[i]) {
			swap(CC[0],CC[1]);
			ret+=fix+CC[1];
			num[i]--;
		}
		CC[1]++;
		fix--;
	}
	
	
	cout<<ret<<endl;
	
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}


Measured memory_bytes: 3940
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int n,m;
int c[15][15];
int cost[1<<15];
int dp[2][1<<15][15];
int main(){
    //cout<<(1|1<<4)<<endl;
    scanf("%d%d",&n,&m);
    for(int i=1;i<=m;i++){
        int u,v,w;scanf("%d%d%d",&u,&v,&w);
        u--,v--;
        c[u][v]=c[v][u]=w;
    }
    for(int s=0;s<(1<<n);s++){
        for(int i=0;i<n;i++){
            if((s>>i&1)==0)continue;
            for(int j=i+1;j<n;j++){
                if((s>>j&1)==0)continue;
                cost[s]+=c[i][j];
            }
        }
    }
    for(int i=0;i<2;i++){
        for(int s=0;s<(1<<n);s++){
            for(int u=0;u<n;u++)dp[i][s][u]=-1;
        }
    }
    dp[0][1][0]=dp[1][1][0]=0;
    for(int s=0;s<(1<<n);s++){
        for(int u=0;u<n;u++){
            if(~dp[1][s][u]){
                dp[0][s][u]=max(dp[0][s][u],dp[1][s][u]);
                int mask=(1<<n)-1-s;
                for(int ns=mask;ns;ns=(ns-1)&mask){
                    dp[0][s|ns][u]=max(dp[0][s|ns][u],dp[1][s][u]+cost[ns|1<<u]);
                }
            }
            if(~dp[0][s][u]){
                for(int v=0;v<n;v++){
                    if(s>>v&1)continue;
                    if(c[u][v])dp[1][s|1<<v][v]=max(dp[1][s|1<<v][v],dp[0][s][u]+c[u][v]);
                }
            }
        }
    }
    printf("%d\n",cost[(1<<n)-1]-dp[0][(1<<n)-1][n-1]);
    return 0;
}

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

int a, b, c;

int main(){
	while(~scanf("%d %d %d", &a, &b, &c)){
		if(a<=c && c<=b){
			puts("Yes");
		} else {
			puts("No");
		}
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pb push_back
#define fst first
#define snd second
#define fore(i,a,b) for(int i=a,ggdem=b;i<ggdem;++i)
#define SZ(x) ((int)x.size())
#define ALL(x) x.begin(),x.end()
#define mset(a,v) memset((a),(v),sizeof(a))
#define FIN ios::sync_with_stdio(0);cin.tie(0);cout.tie(0)
using namespace std;
typedef long long ll;

ll dp[3030][3030],MOD=998244353;

ll a,b,c,d; 

ll f(ll x, ll y){
	ll &r=dp[x][y];
	if(r>=0)return r;
	if(x==a&&y==b)return r=1;
	if(x==a){
		r=f(x,y-1)*x%MOD;
		return r;
	}
	if(y==b){
		r=f(x-1,y)*y%MOD;
		return r;
	}
	r=((f(x,y-1)*x+f(x-1,y)*y-f(x-1,y-1)*((x-1)*(y-1)%MOD))%MOD+MOD)%MOD;
	return r;
	
}

int main(){FIN;
	cin>>a>>b>>c>>d;
	mset(dp,-1);
	ll res=f(c,d);
/*	fore(i,0,c-a+1){
		fore(j,0,d-b+1){
			//if((i+j)&1)res=(res-f(a+i,b+j)+MOD)%MOD;
			//else res=(res+f(a+i,b+j))%MOD;
			//res=(res+f(a+i,b+j))%MOD;
			cout<<a+i<<" "<<b+j<<" "<<f(a+i,b+j)<<"\n";
		}
	}*/
	cout<<res;
	return 0;
}

Measured memory_bytes: 75616
#include <cstdio>
#include <algorithm>
#include <queue>
#define file(x) freopen(#x".in", "r", stdin), freopen(#x".out", "w", stdout)

const int N(2010);
struct edge { int next, to; } e[N];
int head[N], e_num, n, A[N], vis[N], G[N][N], deg[N];
inline void add_edge(int from, int to)
{
	e[++e_num] = (edge) {head[from], to};
	head[from] = e_num;
}

void dfs(int x)
{
	for (int i = vis[x] = 1; i <= n; i++) if (!vis[i] && G[x][i])
		++deg[i], add_edge(x, i), dfs(i);
}

void TopSort()
{
	std::priority_queue<int> Q;
	for (int i = 1; i <= n; i++) if (!deg[i]) Q.push(i);
	while (!Q.empty())
	{
		int x = Q.top(); Q.pop(); printf("%d ", A[x]);
		for (int i = head[x]; i; i = e[i].next) Q.push(e[i].to);
	}
}

int main()
{
	scanf("%d", &n);
	for (int i = 1; i <= n; i++) scanf("%d", A + i);
	std::sort(A + 1, A + n + 1);
	for (int i = 1; i <= n; i++) for (int j = i + 1; j <= n; j++)
		if (std::__gcd(A[i], A[j]) != 1) G[i][j] = G[j][i] = 1;
	for (int i = 1; i <= n; i++) if (!vis[i]) dfs(i);
	TopSort();
	return 0;
}


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

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

#define fi first
#define se second
#define repl(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define rep(i,n) repl(i,0,n)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define mmax(x,y) (x>y?x:y)
#define mmin(x,y) (x<y?x:y)
#define maxch(x,y) x=mmax(x,y)
#define minch(x,y) x=mmin(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt __builtin_popcount

#define INF 1e16

vector<ll> z_algorithm(string S){
  const ll n=S.length();
  vector<ll> A(n);
  A[0] = n;
  int i = 1, j = 0;
  while (i < n) {
    while (i+j < n && S[j] == S[i+j]) ++j;
    A[i] = j;
    if (j == 0) { ++i; continue;}
    ll k = 1;
    while (i+k < n && k+A[k] < j) A[i+k] = A[k], ++k;
    i += k; j -= k;
  }
  return A;
}

string s;
bool g[501010],rg[501010];

int main(){
	cin>>s;
  ll n=s.size();
  {
    bool same=true;
    rep(i,n-1)if(s[i]!=s[i+1])same=false;
    if(same){
      cout<<n<<endl;
      cout<<1<<endl;
      return 0;
    }
  }
  vector<ll> ds;
  for(ll i=1;i*i<=n;i++){
    if(n%i==0){
      ds.push_back(i);
      if(n/i!=i)ds.push_back(n/i);
    }
  }
  sort(all(ds));
  ll minc=-1;
  for(ll len : ds){
    set<string> st;
    for(ll i=0;i<=n-len;i+=len){
      st.insert(s.substr(i,len));
    }
    if(st.size()==1){
      minc=len;
      break;
    }
  }
  if(minc==n){
    cout<<1<<endl;
    cout<<1<<endl;
    return 0;
  }
  cout<<2<<endl;
  string rs=s;
  reverse(all(rs));
  vector<ll> z=z_algorithm(s),rz=z_algorithm(rs);
  ll res=0;
  repl(i,1,n+1)g[i]=true;
  repl(i,1,n){
    for(ll k=2;(k-1)*i<=z[i];k++)g[i*k]=false;
  }
  repl(i,1,n+1)rg[i]=true;
  repl(i,1,n){
    for(ll k=2;(k-1)*i<=rz[i];k++)rg[i*k]=false;
  }
  repl(i,1,n+1)if(g[i]&&rg[n-i])res++;
  cout<<res<<endl;
  return 0;
}


Measured memory_bytes: 10576
using System;
using System.Linq;
using System.Collections.Generic;

public static class Program {
    static int mod=1000000007;
    public static void Main() {
        int[]nk=Console.ReadLine().Split().Select(int.Parse).ToArray();
        int n=nk[0],k=nk[1];
        int[]a=Console.ReadLine().Split().Select(int.Parse).ToArray();

        int[]dp=new int[k+1];
        for(int i=0;i<=k;i++){
            dp[i]=1;
        }
        for(int i=0;i<n;i++){
            if(a[i]==0)continue;
            int[]dp_swp=dp.ToArray();

            // Console.Write($"[i{i}] {dp_swp[0]}");

            for(int j=1;j<=k;j++){
                Add(ref dp_swp[j],dp_swp[j-1]);
                if(0<=j-1-a[i])Sub(ref dp_swp[j],dp[j-1-a[i]]);
                // Console.Write($" {dp_swp[j]}");
            }
            dp=dp_swp;
            // Console.Write("\n");
        }
        int ans=dp[k];
         if(0<k)Sub(ref ans, dp[k-1]);
        Console.WriteLine(ans);
    }
    public static void Add(ref int x, int y){
        x+=y;
        if(mod<=x)x-=mod;
    }
    public static void Sub(ref int x, int y){
        x-=y;
        if(x<0)x+=mod;
    }
}


Measured memory_bytes: 30840
import org.omg.CORBA.INTERNAL;

import java.io.*;
import java.util.*;

public class Main {
    public static final long mod = (long)1e9+7;
    public static final long INF = Long.MAX_VALUE/2;
    public static final int inf = Integer.MAX_VALUE/2;
    //abc112 d
    static void solve(InputReader in, PrintWriter out){
        int n = in.ni(), m = in.ni();
        int ans = 1;
        TreeSet<Integer> set = new TreeSet<>();
        for (int i = 1; i*i <= m; i++) {
            if(m%i==0){
                set.add(i);
                set.add(m/i);
            }
        }
        for(Integer x: set){
            if(x>=n){
                ans = m/x;
                break;
            }
        }
        out.println(ans);
    }

    public static void main(String[] args){
        InputReader in = new InputReader(System.in);
        PrintWriter out = new PrintWriter(System.out);
        solve(in, out);
        out.close();
    }
    public static class InputReader{
        private BufferedReader br;
        private StringTokenizer st;
        public InputReader(InputStream is){
            br = new BufferedReader(new InputStreamReader(is));
            st = null;
        }
        public String ns(){
            if(st == null || !st.hasMoreTokens()){
                try{
                    st = new StringTokenizer(br.readLine());
                }catch (Exception e){
                    throw new RuntimeException(e);
                }
            }
            return st.nextToken();
        }
        public int ni(){
            return Integer.parseInt(ns());
        }
        public long nl(){
            return Long.parseLong(ns());
        }
        public double nd(){
            return Double.parseDouble(ns());
        }
        public char nc(){
            return ns().toCharArray()[0];
        }
        public int[] ni(int n){
            int[] a = new int[n];
            for (int i = 0; i < n; i++) {
                a[i] = ni();
            }
            return a;
        }
        public long[] nl(int n){
            long[] a = new long[n];
            for (int i = 0; i < n; i++) {
                a[i] = nl();
            }
            return a;
        }
        public double[] nd(int n){
            double[] a = new double[n];
            for (int i = 0; i < n; i++) {
                a[i] = nd();
            }
            return a;
        }
    }
}

Measured memory_bytes: 23252
#include<iostream>
#include<cstring>
#include<string>
#include<cmath>
#include<algorithm>
#include<cstdio>
using namespace std;
int main(){
	long long a,b;
	cin>>a>>b;
	  if(a>0&&b>0){
	 	cout<<"Positive"<<endl;
	 }
	 else if(a<=0&&b>0){
	 	cout<<"Zero"<<endl;
	 }else if(b==0){
	 	cout<<"zero"<<endl;
	 }
	 else if(a<0&&b<0){
	 	if((b-a+1)%2==0)cout<<"Positive"<<endl;
	 	else cout<<"Negative"<<endl;
	 }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define pi 2*acos(0.0)
using namespace std;
typedef long long ll;
int main ()
{

         int a,b,c;
         cin>>a>>b>>c;

      swap(a,b);
      swap(a,c);
      cout<<a<<" "<<b<<" "<<c<<endl;
    return 0;
}


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

typedef long long int ll;
ll MOD = 1000000007;
ll INFL = 1ll << 60;
ll INF = 1 << 28;

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

int main() {
  int n;
  cin >> n;
  vector<int> v(n);
  for (int i = 0; i < n; i++) { cin >> v[i]; }
  int count = 0;
  for (int i = 0; i < n; i++) {
    count += v[i] % 2;
  }
  cout << ((count % 2) ? "NO" : "YES") << endl;
}


Measured memory_bytes: 640
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <cassert>
#include <fstream>
#include <utility>
#include <functional>
#include <time.h>
#include <stack>
#include <array>
#define popcount __builtin_popcount
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;

int main()
{
	string s;
	cin>>s;
	if(s[0]=='7' || s[1]=='7' || s[2]=='7') cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
	return 0;
}


Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
int main(void){
  int a,b,c,d;
  cin>>a>>b>>c>>d;
  if(((a-b>=0&&a-b<=d)||(a-b<0&&b-a<=d))&&((b-c>=0&&b-c<=d)||(b-c<0&&c-b<=d)))
    cout<<"Yes"<<endl;
  else if((a-c>=0&&a-c<=d)||(a-c<0&&c-a<=d))
    cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}


Measured memory_bytes: 256