akhauriyash/Code-Regression huggingface dataset:
# coding UTF-8
# 
# problem C
# 

import itertools

N = int(input())
P = tuple(map(int, input().split()))
Q = tuple(map(int, input().split()))

seq = tuple(range(1,N+1))
seqlist = list(itertools.permutations(seq))

#print(seqlist)
#print(seqlist.index(P))
#print(seqlist.index(Q))

print(abs(seqlist.index(P)-abs(seqlist.index(Q))))


Measured memory_bytes: 8052
#include<stdio.h>
#include<iostream>
#include<string.h>
#include<string>
#include<queue>
#include<utility>
#include<vector>
#include<map>
#include<functional>
#include<math.h>
#include<algorithm>
typedef long long ll;
using namespace std;

int main(){
  int i,j,k;
  int a,b;
  cin >> a >> b;
  int d = (a == b ? max(a,b) :max(a,b)-1);
  cout << max(a,b)+d << endl;
  return 0;
}


Measured memory_bytes: 256
n = int(input())
a_list = list(map(int, input().split()))
b_list = list(map(int, input().split()))

ans = 0

for i in range(n):
    if b_list[i] > a_list[i]:
        ans += a_list[i]
        b_list[i] -= a_list[i]
        if b_list[i] > a_list[i + 1]:
            ans += a_list[i + 1]
            a_list[i + 1] = 0
        else:
            ans += b_list[i]
            a_list[i + 1] -= b_list[i]
    else:
        ans += b_list[i]

print(ans)

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

int main() {
  int a,b;
  cin>>a>>b;
  if(a+b==3){
    cout<<"3"<<endl;
  }
  else if(a+b==4){
    cout<<"2"<<endl;
  }
  else{
    cout<<"1"<<endl;
  }
  
}


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

int main()
{
  int n, ans = 0;
  cin >> n;
  vector<int> a(n);
  for (int i = 0; i < n; i++) cin >> a[i];
  for(int i = 1; i < n - 1; i++) {
  if(((a[i - 1] < a[i]) && (a[i] < a[i + 1])) || ((a[i - 1] > a[i]) && (a[i] > a[i + 1]))) ans++;
  }
  
  cout << ans << endl;
  return 0;
}


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

int main(){
	int N;
	long T;
	cin >> N >> T;
	long ans = T;
	long back;
	cin >> back;
	for(int i = 1; i < N; i++){
		long timing;
		cin >> timing;
		ans += min(timing - back, T);
		back = timing;
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
h = int(input())

ans = 0
x = 0

def dfs(h,x):
    global ans
    if h == 1:
        ans += 2**x
        return
    else:
        ans += 2**x
        h //= 2
        x += 1
        dfs(h, x)
        
dfs(h,x)

print(ans)

Measured memory_bytes: 2940
#include <stdio.h>
#include <algorithm>
typedef long long ll;
using namespace std;

int main(void) {
  ll i, j, k, n, ans = 0, min = 10e18;
  scanf("%lld", &n);
  ll a[n], sum[n];
  for(i = 0; i < n; ++i) {
    scanf("%lld", &a[i]);
    if(i) sum[i] = sum[i - 1] + a[i];
    else sum[i] = a[i];
  }
  for(i = 2; i < n - 1; ++i) {
    ll t = sum[i - 1];
    ll p[4];
    if(lower_bound(sum, sum + i, t / 2) != sum + i - 1) {
      p[0] = *(lower_bound(sum, sum + i, t / 2));
      p[1] = t - *(lower_bound(sum, sum + i, t / 2));
    } else {
      p[0] = sum[i - 2];
      p[1] = a[i - 1];
    }
    if(lower_bound(sum + i, sum + n, (sum[n - 1] - t) / 2 + t) != sum + n - 1) {
      p[2] = *(lower_bound(sum + i, sum + n, (sum[n - 1] - t) / 2 + t)) - t;
      p[3] = sum[n - 1] - *(lower_bound(sum + i, sum + n, (sum[n - 1] - t) / 2 + t));
    } else {
      p[2] = sum[n - 2] - t;
      p[3] = a[n - 1];
    }
    sort(p, p + 4);
    ll tmp = p[3] - p[0];
    if(min > tmp) {
      min = tmp;
      //printf("%lld %lld 0\n", min, i);
    }
    if(lower_bound(sum, sum + i, t / 2) != sum) {
      p[0] = *(lower_bound(sum, sum + i, t / 2) - 1);
      p[1] = t - *(lower_bound(sum, sum + i, t / 2) - 1);
    } else {
      p[0] = sum[0];
      p[1] = t - sum[0];
    }
    if(lower_bound(sum + i, sum + n, (sum[n - 1] - t) / 2 + t) != sum + n - 1) {
      p[2] = *(lower_bound(sum + i, sum + n, (sum[n - 1] - t) / 2 + t)) - t;
      p[3] = sum[n - 1] - *(lower_bound(sum + i, sum + n, (sum[n - 1] - t) / 2 + t));
    } else {
      p[2] = sum[n - 2] - t;
      p[3] = a[n - 1];
    }
    sort(p, p + 4);
    tmp = p[3] - p[0];
    if(min > tmp) {
      min = tmp;
      //printf("%lld %lld 1\n", min, i);
    }
    if(lower_bound(sum, sum + i, t / 2) != sum + i - 1) {
      p[0] = *(lower_bound(sum, sum + i, t / 2));
      p[1] = t - *(lower_bound(sum, sum + i, t / 2));
    } else {
      p[0] = sum[i - 2];
      p[1] = a[i - 1];
    }
    if(lower_bound(sum + i, sum + n, (sum[n - 1] - t) / 2 + t) != sum + i) {
      p[2] = *(lower_bound(sum + i, sum + n, (sum[n - 1] - t) / 2 + t) - 1) - t;
      p[3] = sum[n - 1] - *(lower_bound(sum + i, sum + n, (sum[n - 1] - t) / 2 + t) - 1);
    } else {
      p[2] = sum[i] - t;
      p[3] = sum[n - 1] - sum[i];
    }
    sort(p, p + 4);
    tmp = p[3] - p[0];
    if(min > tmp) {
      min = tmp;
      //printf("%lld %lld 2\n", min, i);
    }
    if(lower_bound(sum, sum + i, t / 2) != sum) {
      p[0] = *(lower_bound(sum, sum + i, t / 2) - 1);
      p[1] = t - *(lower_bound(sum, sum + i, t / 2) - 1);
    } else {
      p[0] = sum[0];
      p[1] = t - sum[0];
    }
    if(lower_bound(sum + i, sum + n, (sum[n - 1] - t) / 2 + t) != sum + i) {
      p[2] = *(lower_bound(sum + i, sum + n, (sum[n - 1] - t) / 2 + t) - 1) - t;
      p[3] = sum[n - 1] - *(lower_bound(sum + i, sum + n, (sum[n - 1] - t) / 2 + t) - 1);
    } else {
      p[2] = sum[i] - t;
      p[3] = sum[n - 1] - sum[i];
    }
    sort(p, p + 4);
    tmp = p[3] - p[0];
    if(min > tmp) {
      min = tmp;
      //printf("%lld %lld 3\n", min, i);
    }
  }
  printf("%lld", min);
  return 0;
}

Measured memory_bytes: 3456
#include <bits/stdc++.h> 
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define size_of_array(array) (sizeof(array)/sizeof(array[0]))
#define MAX 100005
#define NIL -1
using ll =long long;
using namespace std;
using Graph=vector<vector<int>>;
using Field=vector<vector<int>>;

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

const double PI=(acos(-1));

int main(){
    int t,x;
    cin>>t>>x;
    double ans=(double)t/x;
    cout<<fixed<<setprecision(3)<<ans<<endl;
}


Measured memory_bytes: 3748
#include <bits/stdc++.h>
#define clr(x) memset(x,0,sizeof (x))
#define For(i,a,b) for (int i=(a);i<=(b);i++)
#define Fod(i,b,a) for (int i=(b);i>=(a);i--)
#define fi first
#define se second
#define kill _z_kill
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
#define outval(x) cerr<<#x" = "<<x<<endl
#define outv(x) cerr<<#x" = "<<x<<"  "
#define outtag(x) cerr<<"--------------"#x"---------------"<<endl
#define outarr(a,L,R) cerr<<#a"["<<L<<".."<<R<<"] = ";\
	For(_x,L,R) cerr<<a[_x]<<" ";cerr<<endl;
#define User_Time ((double)clock()/CLOCKS_PER_SEC)
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
typedef unsigned uint;
typedef long double LD;
typedef vector <int> vi;
typedef pair <int,int> pii;
LL read(){
	LL x=0,f=0;
	char ch=getchar();
	while (!isdigit(ch))
		f=ch=='-',ch=getchar();
	while (isdigit(ch))
		x=(x<<1)+(x<<3)+(ch^48),ch=getchar();
	return f?-x:x;
}
//int Pow(int x,int y){
//	int ans=1;
//	for (;y;y>>=1,x=(LL)x*x%mod)
//		if (y&1)
//			ans=(LL)ans*x%mod;
//	return ans;
//}
//void Add(int &x,int y){
//	if ((x+=y)>=mod)
//		x-=mod;
//}
//void Del(int &x,int y){
//	if ((x-=y)<0)
//		x+=mod;
//}
//int Add(int x){
//	return x>=mod?x-mod:x;
//}
//int Del(int x){
//	return x<0?x+mod:x;
//}
void ckmax(int &x,int y){
	if (x<y)
		x=y;
}
void ckmin(int &x,int y){
	if (x>y)
		x=y;
}
const int N=1030;
int n,m;
int ans[N][N];
int main(){
	n=read(),m=read();
	n=(1<<n)-1,m=(1<<m)-1;
	int t=min(n,m)+1;
	t/=2;
	For(i,1,n)
		For(j,1,m){
			ans[i][j]=(i&-i)==(j&-j);
		}
	For(i,1,n){
		For(j,1,m)
			putchar(ans[i][j]?'1':'0');
		puts("");
	}
	return 0;
}

Measured memory_bytes: 5376
a, b, c, k = map(int, input().split())

if a == b and b == c:
    ans = 0
elif a - b > 10 ** 18:
    ans = 'Unfair'
else:
    if k % 2 == 0:
        ans = a - b
    else:
        ans = b - a
print(ans)

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

int main(){
    int N,M,C;
    cin >> N >> M >> C;
    
    vector<int> B(M);
    for( int i = 0; i < M; i++){
      cin >> B[i];
    }
        
	vector<vector<int>> A(N, vector<int>(M));
	for(int i = 0; i < N; i++){
      for(int j = 0; j < M; j++){
        cin >> A[i][j];
      }
    }
      
    int ans = 0;
    for(int i = 0; i < N; i++){
      int sum = 0;
      for(int j = 0; j < M; j++){
        sum += A[i][j] * B[j];
      }
      if(sum + C > 0){
        ans++;
      }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
typedef long long ll;
int main() {
  int n,x,ans=0;
  map<int,int> a;
  cin>>n;
  rep(i,n){
    cin>>x;
    a[x]++;
  }
  for(auto it=a.begin();it!=a.end();it++){
    if(it->first > it->second){
      ans+=it->second;
    }
    else{
      ans+=it->second-it->first;
    }
  }
  cout<<ans;
}

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

int main() {
	char S[20];
	string T;
	string p;
	string Q;
	int a = 0;
	int A = 0;
	int b = 0;
	int B = 0;
	int c = 0;
	int C = 0;
	int q, w, z;
	int n = 0;
	int x = 0;
	int y = 0;
	int ans = 0;
	cin >> T>>p>>Q;
	a = T.size();
	b = p.size();
	if (T[a-1] == p[0] && p[b-1] == Q[0]) {
		cout << "YES";
	}
	else {
		cout << "NO";
	}
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-

digest_limit, days_ago, after_days = map(int, input().rstrip().split())

days_to_limit = after_days - days_ago

if days_to_limit <= 0:
    print('delicious')
elif days_to_limit < digest_limit + 1:
    print('safe')
else:
    print('dangerous')

Measured memory_bytes: 2940
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace jugyo1024
{
    class Program
    {
        static void Main(string[] args)
        {
            var _ = Console.ReadLine();
            var arr = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).OrderBy(x => x).ToArray();

            int cnt = 0;
            for (int i = 0; i < arr.Length; i++)
                for (int j = i + 1; j < arr.Length; j++)

                {
                    int c = arr[i] + arr[j];
                    int n = LowerBound(arr, j + 1, arr.Length, c, Comparer<int>.Default) - j - 1;
                    if (n > 0)
                        cnt += n;
                }
            Console.WriteLine(cnt);
        }

        static int LowerBound<T>(T[] arr, int start, int end, T value, IComparer<T> comparer)
        {
            int low = start;
            int high = end;
            int mid;
            while (low < high)
            {
                mid = ((high - low) >> 1) + low;
                if (comparer.Compare(arr[mid], value) < 0)
                    low = mid + 1;
                else
                    high = mid;
            }
            return low;
        }
    }
}


Measured memory_bytes: 13408
#include <cstdio>
#include <iostream>
#include <vector>
#include <list>
#include <cmath>
#include <fstream>
#include <algorithm>
#include <string>
#include <queue>
#include <set>
#include <map>
#include <complex>
#include <iterator>
#include <cstdlib>
#include <cstring>
#include <sstream>
#include <stack>
#include <climits>
#include <deque>

using namespace std;

typedef long long ll;
typedef pair<int,int> pii;
double EPS=1e-10;
double EQ(double a,double b){
    return abs(a-b)<EPS;
}
void fast_stream(){
  std::ios_base::sync_with_stdio(0);
}
template<class T>
string IntToString(T num){
  string res;stringstream ss;ss<<num;
  return ss.str();
}
ll StringToInt(string &str){
  ll res=0;
  for(int i=0;i<(int)str.size();i++)
    res=(res*10+str[i]-'0');
  return res;
}

struct Node{
  string str;
  string property;
  vector<Node*> nodes;
};
vector<Node*> tree;
vector<string> yaml;

vector<Node*> dfs(int &pos,const int nowWsp){
  vector<Node*> res;
  int cnt=0;
  while(pos<(int)yaml.size()){
    cnt++;
    Node *now=new Node();
    int wsp=0;
    string &s=yaml[pos];
    for(int i=0;i<(int)s.size();i++)
      if(s[i]==' ')wsp++;
      else break;
    int ps=0;
    for(int i=0;i<(int)s.size();i++){
      if(s[i]==':'){
	ps=i+1;
	break;
      }
    }
    string name=s.substr(wsp,ps-wsp-1);
    string property="";
    if(ps!=(int)s.size())property=s.substr(ps+1);
    now->str=name;
    now->property=property;
    if(wsp<nowWsp){
      return res;
    }
    else if(property==""){
      pos++;
      int p=0;
      for(int i=0;i<(int)yaml[pos].size();i++)
	if(yaml[pos][i]==' ')p++;
	else break;
      now->nodes=dfs(pos,p);
    }
    else pos++;
    res.push_back(now);
  }
  return res;
}
const string nsp="no such property";
const string obj="object";
string search(Node *now,int pos,vector<string>&vs){
  for(int i=0;i<(int)now->nodes.size();i++){
    //cout<<now->nodes[i]->str<<endl;
    if(now->nodes[i]->str==vs[pos]){
      if((int)vs.size()-1==pos){
	if(now->nodes[i]->property=="")return obj;
	return now->nodes[i]->property;
      }
      return search(now->nodes[i],pos+1,vs);
    }
  }
  return nsp;
}

int main(){
  string order;
  getline(cin,order);
  order=order.substr(1);
  vector<string> os;
  int spos=0;
  for(int i=0;i<(int)order.size();i++){
    if(order[i]=='.'){
      os.push_back(order.substr(spos,i-spos));
      spos=i+1;
    }
  }
  os.push_back(order.substr(spos));
  string st;
  while(getline(cin,st))
    yaml.push_back(st);
  int a=0;
  vector<Node*> root=dfs(a,0);
  Node *rt=new Node();
  rt->nodes=root;
  string s=search(rt,0,os);
  if(s==obj||s==nsp)cout<<s<<endl;
  else cout<<"string \""<<s<<"\""<<endl;
  
  return 0;
}

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

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

Measured memory_bytes: 256
import sys


def solve():
    readline = sys.stdin.buffer.readline
    mod = 10 ** 9 + 7
    n, m = list(map(int, readline().split()))
    s = str(readline().rstrip().decode('utf-8'))
    res = []
    start = n
    while True:
        b = False
        for j in range(max(0, start - m), start):
            if s[j] == "0":
                res.append(start - j)
                start = j
                b = True
                break
        if not b:
            print(-1)
            exit()
        else:
            if j == 0:
                res.reverse()
                print(*res)
                exit()


if __name__ == '__main__':
    solve()


Measured memory_bytes: 49776
#include <iostream>

using namespace std;

/*	MaxNum以下のnHmNum個の数字でnNumToMakeを作るとき
	何通りの答えがあるかを返す							*/
int dfs(int nhmNum,int nNumToMake,int MaxNum){
	if(nhmNum == 0){
		if(nNumToMake == 0){
			return 1;
		}else{
			return 0;
		}
	}
	if(nNumToMake < 0)
		return 0;
		
	int ans = 0;
	for(int i = 0;i < MaxNum;i++){
		ans += dfs(nhmNum - 1,nNumToMake - i,i);
	}
	return ans;
}

int main() {
	int hmNum,Sum;
	while(1){
		cin >> hmNum;
		cin >> Sum;
		if(hmNum == 0 && Sum == 0)
			break;
		cout << dfs(hmNum,Sum,10) << endl;
	}
	return 0;
}

Measured memory_bytes: 1160
S = input()
N = len(S)

ans1 = 0
ans2 = 0

for i in range(N):
  if i%2 == 0:
    if S[i] != "0":
      ans1 += 1
    else:
      ans2 += 1
  else:
    if S[i] != "1":
      ans1 += 1
    else:
      ans2 += 1

print(min(ans1, ans2))

Measured memory_bytes: 9144
#include<bits/stdc++.h>
using namespace std;
int main()
{
    string x,y,a;
    cin>>x>>y;
    a=x+y;
    int p=stoi(a);
    int b=sqrt(p);
    if(b*b==p)
    {
        cout<<"Yes"<<endl;
    }
    else
    {
        cout<<"No"<<endl;
    }
    return 0;
}


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

#define mem(arr, i) fill(arr, arr + sizeof(arr), i)
#define MEM(arr, i) memset(arr, i, sizeof(arr))
#define Push push_back
#define Pair make_pair
#define ALL(x) x.begin(), x.end()
#define X first
#define Y second
#define ACCEL ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
typedef unsigned long long ull;
typedef long long lli;
typedef pair<int,int> pii;
typedef pair<lli,lli> pll;
typedef pair<pll,lli> p3l;
typedef vector<int> vcI;
typedef vector<lli> vcL;
typedef vector<pii> vPI;
typedef vector<pll> vPL;
typedef vector<p3l> v3L;
typedef vector<vcL> vvL;
//typedef priority_queue<T> prior_S<T>;
//typedef priority_queue< T, vector<T>, greater<T> > prior_B<T>;
const double PI = 3.141592653589793;
const lli I_MAX = 1LL << 60;
      lli   mod = 1000000007;

/// templates ///

const lli maxN = 2E5;

vcL inv(maxN+5, 1);
vcL fac(maxN+5, 1);

void ADD(lli &x, lli y) {
	x += y;
	if (x >= mod) x -= mod;
	if (x < 0) x += mod;
}

void MUL(lli &x, lli y) {
	x *= y;
	x = (x % mod + mod) % mod;
}

lli mypow(lli b, lli e) {
	lli ans = 1;
	while (e) {
		if (e & 1) MUL(ans, b);
		MUL(b, b);
		e >>= 1;
	}
	return ans;
}

lli modinv(lli n) {
	return mypow(n, mod - 2);
}

void calcInv(lli n) {
	for (int i = 2; i <= n; ++i) {
		inv[i] = (mod - mod / i) * inv[mod % i] % mod;
	}
}

void calcFac(lli n) {
	for (int i = 2; i <= n; ++i) {
		fac[i] = fac[i - 1] * i % mod;
	}
}

lli cm(lli a, lli b) {
	lli ans = 1;
	if (a < b) return 0;

	MUL(ans, inv[fac[a - b]]);
	MUL(ans, inv[fac[b]]);
	MUL(ans, fac[a]);

	return ans;
}

lli Lucas(lli n, lli m) {
	if (m == 0) return 1;
	return cm(n % mod, m % mod) * Lucas(n / mod, m / mod) % mod;
}

lli doLucas(lli n, lli m) {
	calcInv(mod);
	calcFac(mod);
	return Lucas(n, m);
}

/// coding area ///

const lli maxn = 1E5;

void precal() {

	return;
}

void solve() {
	lli n, d;
	cin >> n >> d;
	
	lli pnt[n][d];
	for (int i = 0; i < n; ++i) {
		for (int j = 0; j < d; ++j) {
			cin >> pnt[i][j];
		}
	}
	
	lli ans = 0;
	
	for (int i = 0; i < n; ++i) {
		for (int j = i+1; j < n; ++j) {
			lli dis = 0;
			for (int k = 0; k < d; ++k) {
				dis += (pnt[j][k] - pnt[i][k]) * (pnt[j][k] - pnt[i][k]);
			}
			
			if (floor(sqrt(dis + 0.5)) * floor(sqrt(dis + 0.5)) == dis) ++ans;
		}
	}
	
	cout << ans << '\n';
}

int main() {
	precal();
	int t = 1;
	#ifdef LOCAL
		t = INT_MAX;
	#else
		ACCEL;
	#endif
//	cin >> t;
	for (int i = 1; i <= t; ++i) {
//		printf("Case #%d: ", i );
		solve();
	}
	return 0;
}



Measured memory_bytes: 3328
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define all(v) v.begin(),v.end()

using namespace std;
typedef long long ll;




int main()
{
    int N;
    cin >> N;
    
    int ans = 0;
    rep(i,N+1){
        if (i%2==1) {
            int a = 0;
            for (int j = 1; j <= i; j++) if(i%j==0) a++;
            if(a==8) ans++;
        }
    }
    cout << ans << endl;
    
    return 0;
}



Measured memory_bytes: 256
N, K = map(int, input().split())
A = list(map(int, input().split()))
MOD = 10**9 + 7

B = []
for a in A:
    B.append([abs(a), a])

B.sort(reverse=True)
ans =  1
pre_nega = 0
pre_posi = 0
num_posi = num_nega = 0
for count, (b, a) in enumerate(B, 1):
    ans *= b
    ans %= MOD
    if a < 0:
        pre_nega = a
        num_nega += 1
    if a > 0:
        pre_posi = a
        num_posi += 1
    if count == K:
        break

if num_nega % 2 == 0:
    print(ans)
    quit()

flag_nega = True
flag_posi = True
next_nega = next_posi = 0
for b, a in B[K:]:
    if flag_nega and a < 0:
        next_nega = a
        flag_nega = False
    elif flag_posi and a > 0:
        next_posi = a
        flag_posi = False

if next_nega != 0 and num_posi > 0:
    if next_posi != 0 and num_nega > 0:
        if next_nega * pre_nega > next_posi * pre_posi:
            ans *= abs(next_nega)
            ans *= pow(pre_posi, MOD-2, MOD)
            ans %= MOD
        else:
            ans *= next_posi
            ans *= pow(abs(pre_nega), MOD-2, MOD)
            ans %= MOD
    else:
        ans *= abs(next_nega)
        ans *= pow(pre_posi, MOD-2, MOD)
        ans %= MOD
else:
    if next_posi != 0 and num_nega > 0:
        ans *= next_posi
        ans *= pow(abs(pre_nega), MOD-2, MOD)
        ans %= MOD
    else:
        if 0 in A:
            ans = 0
        else:
            ans = 1
            B.sort()
            for count, (b, a) in enumerate(B, 1):
                ans *= a
                ans %= MOD
                if count == K:
                    break

print(ans)

Measured memory_bytes: 41264
#include <cstdio>
int main()
{
    int n;
    while (scanf("%d",&n)!=EOF) {
        if (n%39==0) printf("3C39\n");
        else if (n%39<10) printf("3C0%d\n",n%39);
        else printf("3C%d\n",n%39);
    }
}

Measured memory_bytes: 0
#include<iostream>
#include<string>
#include<algorithm>
using namespace std;

int main(){
	string s;
	int n;
	int r=0,l=0;

	cin>>n>>s;
	
	for(int i=0;i<n;i++){
		if(s[i]=='(')r++;
		else if(s[i]==')'){
			r--;
			l=min(l,r);
		}
	}
	l=abs(l);
	while(l!=0){
		l--;
		s.insert(0,"(");
		r++;
	}
	if(r>0) for(int i=0;i<r;i++)s.append(")");
	else if(r<0) for(int i=0;i<abs(r);i++)s.insert(0,"(");
	

	cout<<s<<endl;
}

Measured memory_bytes: 256
import numpy as np
N,M=map(int, input().split())
human=[]
for i in range(N):
  a,b=map(int, input().split())
  human.append((a,b))
C=[]
for i in range(M):
  c,d=map(int, input().split())
  C.append((c,d))
  
for h in human:
  a,b=h
  now=0
  mini=np.inf
  for i,ch in enumerate(C):
    c,d=ch
    L=abs(a-c)+abs(b-d)
    if mini>L:
      mini=L
      now=i+1
  print(now)

Measured memory_bytes: 12448
/* Alohomora */
#include<bits/stdc++.h>
#define ll         long long
#define fl(i,n)    for(i=0;i<n;i++)
#define fld(i,a,b) for(i=a;i>b;i--)
#define fli(i,a,n) for(i=a;i<n;i++)
#define inp(i,a,n) for(i=0;i<n;i++) {cin>>a[i];}
#define op(i,a,n)  for(i=0;i<n;i++) {cout<<a[i]<<" ";}
#define pb         push_back
#define mp         make_pair
#define F          first 
#define S          second
#define mod        998244353
#define all(x) 	   x.begin(),x.end()	
#define speedup    ios_base::sync_with_stdio(false),cin.tie(0)
using namespace std;
void comp() {
	ll i,j,k,n,m,p,ind;
	cin>>n>>m;
	vector<ll>v1;
	ll sum=0;
	fl(i,m){
		cin>>j;
		sum+=j;
		v1.pb(j);
	}
	if(sum>n) {
		cout<<-1<<endl;
	}
	else {
		cout<<n-sum<<endl;
	}
}

int main() {
    speedup;
    ll i=0,t;
    //cin>>t;
    t=1;
    while(t--) {
        comp();
    }
    return 0;
}


Measured memory_bytes: 3796
# coding: utf-8

n = gets.to_i

a = {}

ret = 0
for i in 0..n-1 do
  s=gets.chomp

  ary = s.unpack("C*")
  ary = ary.sort
  ary = ary.pack("U*")

  if a.has_key?(ary) then
    a[ary]+=1
    ret += a[ary]
  else
    a[ary]=0
  end

end

print(ret)

Measured memory_bytes: 19196
// C++ 14
#include <bits/stdc++.h>
using namespace std;
template <typename T>  ostream& operator<<(ostream& os, const vector<T>& v)  {  os << "[";  for (int i = 0; i < v.size(); ++i) {  os << v[i];  if (i != v.size() - 1)  os << ", ";  }  os << "]";  return os;  }
template <typename T> void print(T v, string s = "\n") { cout << v << s; }
template <typename T> void in(T &v) { cin >> v; }
#define ll long long
#define loop(__x, __start, __end) for(int __x = __start; __x < __end; __x++)

int main() {
  int n; ll m; in(n),in(m);
  vector<ll> A(n);
  loop(i,0,n) in(A[i]);
  loop(i,0,n) A[i]%=m;
  ll rem = 0;
  map<ll, ll> C;
  C[rem]++;
  loop(i,0,n) {
    rem = (rem + A[i]) % m;
    C[rem]++;
  }
  ll ans = 0;
  for (auto &&c: C) {
    ans += (c.second * (c.second - 1)) / 2;
  }
  print(ans);
  return 0;
}


Measured memory_bytes: 7928
#include <cstdio>
#include <algorithm>
using namespace std;
const int Maxn=200000;
int n,k;
int p[Maxn+5];
double s[1005];
double sum[Maxn+5];
bool cmp(int p,int q){
	return p>q;
}
int main(){
	scanf("%d%d",&n,&k);
	for(int i=1;i<=n;i++){
		scanf("%d",&p[i]);
	}
	for(int i=1;i<=1000;i++){
		s[i]=(i+1)*i/2*1.0/i;
	}
	for(int i=1;i<=n;i++){
		sum[i]=sum[i-1]+s[p[i]];
	}
	double ans=0.0;
	for(int i=k;i<=n;i++){
		ans=max(ans,sum[i]-sum[i-k]);
	}
	printf("%.7lf\n",ans);
	return 0;
}


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

#define rng(i, a, b) for (int i = int(a); i < int(b); i++)
#define rep(i, b) rng(i, 0, b)
#define gnr(i, a, b) for (int i = int(b) - 1; i >= int(a); i--)
#define per(i, b) gnr(i, 0, b)

using namespace std;

using ll = long long;
using P = pair<int, int>;

static const ll MOD = 998244353;

int main() {
  int n;
  cin >> n;
  vector<int> d(n);
  rep(i, n) {
    int dd;
    cin >> dd;
    // 0番目は必ず0
    // 0番目以外は0でない
    if ((i == 0 && dd != 0) || (i != 0 && dd == 0)) {
      cout << 0 << endl;
      return 0;
    }
    d.at(i) = dd;
  }
  map<int, int> mp;
  for (int dd : d) {
    mp[dd]++;
  }
  ll res = 1;
  rep(i, mp.size()) {
    if (i == 0) {
      continue;
    }
    ll x = (ll) mp[i];
    ll parent = (ll) mp[i - 1];
    rep(j, x) {
      res *= parent;
      res %= MOD;
    }
  }
  cout << res << endl;
  return 0;
}


Measured memory_bytes: 8148
#include<iostream>
#include <stdio.h>
#include <vector>
#include<string>
using namespace std;
int ha(string);
void saga(void);

struct L{
	string name;
	int cost;
};
struct  R{
	string name;
	string zairyo[101];
	int size;
};
int q,m,n;
L list[101];
R resipi[101];

int main()
{	
	int i,j,k,b=0,s,a;
	string S;
	cin>> n;
	while(n!=0){
	q=n;
	for(i=0;i<n;i++){
		cin  >> list[i].name>> list[i].cost;
	}


	cin>>m;
	for(i=0;i<m;i++){
		cin>>resipi[i].name>>b;
		resipi[i].size=b;
		for(j=0;j<b;j++){
		cin>>resipi[i].zairyo[j];
		}
		
	}
	cin>>S;

	
	/*for(i=0;i<n;i++){
		cout <<list[i].name<< list[i].cost<<endl;
	}
	for(i=0;i<m;i++){
		cout<<resipi[i].name;
		for(j=0;j<resipi[i].size;j++){
			cout<<resipi[i].zairyo[j];
		}
		cout<<endl;
	}
	*/
	cout<<ha(S)<<endl;
	cin>>n;
	}
	return 0;

}
int ha(string S)
{
	int  i,j,f=0,sum=0;
	for(i=0;i<m;i++){
		//cout<<S<<endl<<resipi[i].name;	
	if(S==resipi[i].name){
		f=1;
		break;
	}
	}
	if(f==1){
		for(j=0;j<resipi[i].size;j++){
			sum=sum+ha(resipi[i].zairyo[j]);
			}
		//printf("%d\n",sum);
		for(i=0;i<n;i++){
		if(S==list[i].name){
		if(sum<list[i].cost){
		return sum;
		}
		else return list[i].cost;
		}
	}
		
		}

	for(i=0;i<n;i++){
		if(S==list[i].name){
		return list[i].cost;
		}
	
	}

	
}

Measured memory_bytes: 1304
import java.util.*;

public class Main {

    public static void main(String args[]) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int m = sc.nextInt();

        List<Integer> fromList = new ArrayList<>();
        List<Integer> toList = new ArrayList<>();
        for(int i = 0;i < m;i++){
            fromList.add(sc.nextInt());
            toList.add(sc.nextInt());
        }



        List<Long> ans = new ArrayList<>();
        ans.add((long)n*(n-1)/2);
        UnionFindTree uft = new UnionFindTree(n+1);
        for(int i = m-1;i >= 1;i--){
            int from = fromList.get(i);
            int to = toList.get(i);
            if(uft.same(from, to)){
                ans.add(ans.get(m-i-1));
            } else {
                ans.add(Math.max(ans.get(m - i - 1) - (long)uft.size(from) * uft.size(to), 0));
                uft.union(from, to);
            }
        }

        for(int i = m-1;i >= 0;i--){
            System.out.println(ans.get(i));
        }
    }

    public static class UnionFindTree {

        int[] parent;
        int[] size;
        int[] rank;

        public UnionFindTree(int size) {
            this.parent = new int[size];
            this.rank = new int[size];
            this.size = new int[size];

            for (int i = 0; i < size; i++) {
                makeSet(i);
            }
        }

        public void makeSet(int i) {
            parent[i] = i;
            rank[i] = 0;
            size[i] = 1;
        }

        public void union(int x, int y) {
            int xRoot = find(x);
            int yRoot = find(y);

            if (rank[xRoot] > rank[yRoot]) {
                parent[yRoot] = xRoot;
                size[xRoot] += size[yRoot];
            } else if (rank[xRoot] < rank[yRoot]) {
                parent[xRoot] = yRoot;
                size[yRoot] += size[xRoot];
            } else if (xRoot != yRoot) {
                parent[yRoot] = xRoot;
                size[xRoot] += size[yRoot];
                rank[xRoot]++;
            }
        }

        public int find(int i) {
            if (i != parent[i]) {
                parent[i] = find(parent[i]);
            }
            return parent[i];
        }

        public int size(int i){
            return size[find(i)];
        }

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

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

int main(){
    int n;
    cin >> n;
    vector<long long int> a(n);
    for(int i = 0 ; i < n ; i++){
        cin >> a[i];
    }
    sort(a.begin(), a.end());
    long long int x = 0, y = 0;
    for(int i = n - 1 ; i > 0 ; i--){
        if(a[i] == a[i-1]){
            if(x == 0){
                x = a[i];
            }else{
                y = a[i];
            }
            if(x != 0 && y != 0){
                break;
            }
            i--;
        }
    }
    cout << x * y << endl;
    return 0;
}

Measured memory_bytes: 1024
/** 
 * Dont raise your voice, improve your argument.
 * --Desmond Tutu
 */

#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
#define endl "\n"
#define fori(n) for(ll i=0; i<(n); i++)

#define cins(s) string s; cin>>s;
#define cini(i) int i; cin>>i;
#define cinll(l) ll l; cin>>l;
#define cinai(a, n) vi a(n); fori(n) { cin>>a[i]; }
#define cinall(a, n) vll a(n); fori(n) { cin>>a[i]; }
#define cinas(s, n) vs s(n); fori(n) { cin>>s[i]; }

typedef pair<int, int> pii;
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<string> vs;
typedef vector<ll> vll;

int main() {
cin.tie(nullptr);
std::ios::sync_with_stdio(false);
    cinll(n);

    ll ans=((n-1)*n)/2;
    cout<<ans<<endl;

}



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

int main(){
	int a,b;
	cin >> a >> b;
	int ans = (b-1+a-2)/(a-1);
	cout << ans << endl;
    return 0;
}

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

#define pii pair<int,int>
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define pf push_front
#define pb2 pop_back
#define pf2 pop_front
#define line printf("\n")
#define pq priority_queue
#define rep(k,i,j) for(int k = (int)i;k<(int)j;k++)
#define repd(k,i,j) for(int k = (int)i;k>=(int)j;k--)
#define ll long long

using namespace std;

double EPS = 1e-9;
int INF = 1e9+7;;
long long INFLL = 1e17;
double pi = acos(-1);
int dirx[8] = {-1,0,0,1,-1,-1,1,1};
int diry[8] = {0,1,-1,0,-1,1,-1,1};

inline void OPEN (string s) {
  freopen ((s + ".in").c_str (), "r", stdin);
  freopen ((s + ".out").c_str (), "w", stdout);
}

//end of template

const int maxn = 105;
int N,W,X;

int w[maxn],v[maxn];

int DP[maxn][3*maxn][2];
int dp(int pos,int rem,int pick){
	if(rem<0 || pick<0)return -INF;
	if(pos<0)return 0;
	return DP[pos][rem][pick&1];
}
int main(){
	scanf("%d%d",&N,&W);
	
	rep(k,0,N){
		scanf("%d%d",&w[k],&v[k]);
		if(!k)X = w[k];
		w[k] -= X;
	}
	
	int ans = 0;
	rep(pick,1,N+1){
		ll cw = W - (ll)pick*X;
		cw = min(cw,3ll*pick);
		rep(pos,0,N)for(ll rem = 0;rem<=cw;rem++){
			int &ret = DP[pos][rem][pick&1];
			
			ret= max(dp(pos-1,rem,pick),dp(pos-1,rem-w[pos],pick-1) + v[pos]);
			ans = max(ret,ans);
		}
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 512
function main(input) {
  const args = input.split('\n')
  const n = Number(args[0].split(' ')[0])
  const m = Number(args[0].split(' ')[1])
  const tall = args[1].split(' ').map(v => Number(v))
  const data = args.slice(2, args.length)
  let good = Array(n).fill(true)
  let d = []
  for (let i = 0; i < m; i++) {
    d = data[i].split(' ').map(v => Number(v))
    if (tall[d[0] - 1] < tall[d[1] - 1]) {
      good[d[0] - 1] = false
    } else if (tall[d[0] - 1] === tall[d[1] - 1]) {
      good[d[0] - 1] = false
      good[d[1] - 1] = false
    } else {
      good[d[1] - 1] = false
    }
    d = []
  }
  console.log(good.filter(v => v).length)
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'))

Measured memory_bytes: 63276
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a,n) for(int i=(a); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it)
#define ALLOF(c) (c).begin(), (c).end()
typedef long long ll;
typedef unsigned long long ull;

#define MAX 100005

class BIT{
  static const int MAX_N = 1 << 18;
  int n, bit[MAX_N+1];
public:
  BIT(int n_){
    n = n_;
    for(int i=0; i<n+1; i++) bit[i] = 0;
  }
  int sum(int i){
    int s = 0;
    while(i>0){
      s+=bit[i];
      i-=i&(-i);
    }
    return s;
  }
  void add(int i, int x){
    while(i<=n){
      bit[i]+=x;
      i+=i&(-i);
    }
  }
};
 
struct ST {
  int type;
  int l, r;
};
bool operator<(const ST& a, const ST& b){
  if(a.l == b.l) return a.type < b.type;
  return a.l < b.l;
}
 
map<int,int> query[MAX];
 
int main(){
  ios::sync_with_stdio(false);
 
  int N, M;
  cin >> N >> M;
 
  vector<ST> pts;
  rep(i,N){
    int l, r;
    cin >> l >> r;
    pts.push_back((ST){0,l,r});
  }

  for(int d=2; d<=M; d++){
    for(int p=1; d*(ll)p<=M; p++){
      int X = d*(p-1);
      int Y = d*p;
 
      if(query[X].count(Y-1)==0){
        query[X][Y-1] = 1;
        pts.push_back((ST){1,X,Y-1});
      }
      if(query[X].count(MAX)==0){
        query[X][MAX] = 1;
        pts.push_back((ST){1,X,MAX});
      }
      if(query[Y].count(Y-1)==0){
        query[Y][Y-1] = 1;
        pts.push_back((ST){1,Y,Y-1});
      }
      if(query[Y].count(MAX)==0){
        query[Y][MAX] = 1;
        pts.push_back((ST){1,Y,MAX});
      }
    }
  }

  sort(ALLOF(pts));
 
  BIT bit(1<<18);
 
  rep(i,pts.size()){
    if(pts[i].type == 0){
      bit.add(pts[i].r+1, 1);
    }else{
      query[pts[i].l][pts[i].r] = bit.sum(pts[i].r+1);
    }
  }

  for(int d=1; d<=M; d++){
    if(d==1){
      cout << N << endl;
    }else{
      int ret = 0;
      for(int p=1; d*(ll)p<=M; p++){
        int X = d*(p-1);
        int Y = d*p;
 
        ret += query[Y][MAX] - query[Y][Y-1] - query[X][MAX] + query[X][Y-1];
      }
      cout << ret << endl;
    }
  }
 
  return 0;
}

Measured memory_bytes: 84452
# coding: utf-8
from itertools import *
import sys
import time


#################### library ####################


#################### naive ####################


#################### process ####################

def read_input():
	N = int(raw_input())
	A = map(int, raw_input().split())
	B = map(int, raw_input().split())
	C = map(int, raw_input().split())
	return (N, A, B, C)


#################### main ####################

#t0 = time.clock()
N, A, B, C = read_input()
s = sum(B)
for k1, k2 in zip(A, A[1:]):
	if k1 == k2-1:
		s += C[k1-1]
print s


Measured memory_bytes: 27884
#include <iostream>
#include <algorithm>
#include <utility>
#include <vector>
#include <string>

using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define REP(i, n) for (int i = 0; i < (n); i++)
#define RREP(i, n) for (int i = (n) - 1; i >= 0; i--)
#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 ALL(a) (a).begin(), (a).end()

int main() {
    int A, B, C;
    cin >> A >> B >> C;

    FOR(i, 1, 101) {
        if (i * A % B == C) {
            cout << "YES" << endl;
            return 0;
        }
    }
    cout << "NO" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <typeinfo>
#include <numeric>
#include <functional>
#include <unordered_map>
#include <bitset>
#include <stack>
#include <assert.h>
#include <unordered_set>
#include <random>



using namespace std;
using ll = long long;
using ull = unsigned long long;

const ll INF = 1e18;
const ll MOD = 1e9 + 7;

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














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

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

int main(void){
    char c;
    int b,ans;
    
    cin >> ans;
    while(true){
        cin >> c;
        
        if(c == '=') break;
        cin >> b;
        switch(c){
            case '+':
                ans += b;
                break;
                
            case '-':
                ans -= b;
                break;
                
            case '*':
                ans *= b;
                break;
                
            case '/':
                ans /= b;
                break;
        }
    }
    cout << ans << endl;
    
    return 0;
}

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

#define ll long long
#define REP(i,n) for(int i = 0; i < n; i++)
#define PI 3.141592653589

using namespace std;

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

void solve_C(){
    int n;
    cin >> n;
    int a[n];
    int ans[n];
    REP(i,n) ans[i] = 0;
    a[0] = 0;
    for(int i = 1; i < n; i++){
        cin >> a[i];
        ans[a[i]-1]++;
    }

    REP(i,n) cout << ans[i] << endl;

}

int main(void){
    solve_C();
    
    return 0;
}

Measured memory_bytes: 5128
#include<bits/stdc++.h>
using namespace std;
int main(void){
	ios::sync_with_stdio(0);
	cin.tie(0),cout.tie(0);
	int n;
	cin >> n;
	for(int i=1;i<10;i++){
		for(int j=1;j<10;j++){
			if(i*j == n){
				cout << "Yes";
				return 0;
			}
		}
	}
	cout << "No";
	return 0; 
}

Measured memory_bytes: 256
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		int n = s.length();
		StringBuffer sb = new StringBuffer(s);
		if(!sb.toString().equals(sb.reverse().toString())){
			System.out.println("No");
			return;
		}
		StringBuffer sb1 = new StringBuffer(s.substring(0,(n-1)/2));
		if(!sb1.toString().equals(sb1.reverse().toString())){
			System.out.println("No");
			return;
		}
		StringBuffer sb2 = new StringBuffer(s.substring((n+1)/2,n));
		if(!sb2.toString().equals(sb1.reverse().toString())){
			System.out.println("No");
			return;
		}
		System.out.println("Yes");
	}
}

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

#define N 200009

using namespace std;

long long int val[N];

int main(){
	int i,j,t1,t2,t3,t4,n,k;
	long long int buf1,buf2,buf3,ans;
	scanf("%d %d",&n,&k);
	for(i=1;i<=n;i++){
		val[i%k]++;
	}
	ans=val[0];
	buf1=val[0]*(val[0]-1);
	buf1*=3;
	ans+=buf1;
	buf1=val[0]*(val[0]-1)*(val[0]-2);
	ans+=buf1;
	//printf("wow=%lld\n",ans);
	if(k%2==0){
		ans+=val[k/2];
		//printf("ok=%lld\n",ans);
		buf1=val[k/2]*(val[k/2]-1);
		buf1*=3;
		ans+=buf1;
		//printf("wow=%lld\n",ans);
		buf1=val[k/2]*(val[k/2]-1)*(val[k/2]-2);
		ans+=buf1;
	}
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 1024
def main():
    import sys
    input = sys.stdin.readline
    sys.setrecursionlimit(10**7)
    from collections import Counter, deque
    #from collections import defaultdict
    from itertools import combinations, permutations, accumulate, groupby
    #from itertools import product
    from bisect import bisect_left,bisect_right
    from heapq import heapify, heappop, heappush
    from math import floor, ceil
    #from operator import itemgetter

    #inf = 10**17
    #mod = 10**9 + 7

    n,m = map(int, input().split())
    a = m // n
    for i in range(a, 0, -1):
        if m % i == 0:
            print(i)
            break

if __name__ == '__main__':
    main()

Measured memory_bytes: 3316
#include <algorithm>
#include <bitset>
#include <cassert>
#include <chrono>
#include <climits>
#include <cmath>
#include <complex>
#include <cstring>
#include <deque>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <cstdint>
using namespace std;
typedef long long ll;
#define MP make_pair
#define PB push_back
#define inf 1000000007
#define mod 1000000007
#define rep(i,n) for(int i = 0; i < (int)(n); ++i)

int main(){
    int a,b;
    cin >> a >> b;
    int s = 0;
    s += max(0,(4-a)*100000);
    s += max(0,(4-b)*100000);
    if(a==1&&b==1){
        s += 400000;
    }
    cout << s << endl;
    return 0;
}

Measured memory_bytes: 888
#include <stdio.h>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <queue>
#include <stack>
#include <cmath>
#include <ctime>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <numeric>
#include <complex>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <iostream>
#include <iterator>
#include <algorithm>
#include <functional>
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
typedef vector<int> vint;
typedef vector<vector<int>> v2int;
typedef vector<vector<vector<int>>> v3int;
typedef vector<ll> vll;
typedef vector<vector<ll>> v2ll;
typedef vector<vector<vector<ll>>> v3ll;
typedef list<int> liint;
typedef pair<int, int> pint;
typedef vector<pair<int, int>> vpint;
typedef vector<pair<ll, ll>> vpll;
typedef vector<pair<ll, int>> vpll_int;
typedef vector<pair<int, ll>> vpint_ll;
typedef set<pair<int, int>> spint;
typedef set<pair<ll, int>> spll;
typedef unordered_map<int, unordered_set<int>> Graph;
const int INF = int(2e9);
const ll LINF = ll(2e9) * ll(2e9);
#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
template<class T, class C> void chmax(T& a, C b) { a > b ? : a = b; }
template<class T, class C> void chmin(T& a, C b) { a < b ? : a = b; }



int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int H, W, M;
    cin >> H >> W >> M;
    vint h(M), w(M);
    rep(i, M) cin >> h[i] >> w[i];
    map<int, int> h_num, w_num;
    rep(i, M) {
        h_num[h[i]]++;
        w_num[w[i]]++;
    }
    int max_h_num = 0, max_w_num = 0;
    for(auto& h_pair : h_num)  {
        max_h_num = max(max_h_num, h_pair.second);
    }
    for (auto& w_pair : w_num) {
        max_w_num = max(max_w_num, w_pair.second);
    }

    set<int> h_max_idx, w_max_idx;
    for (auto& h_pair : h_num) {
        if (max_h_num == h_pair.second) h_max_idx.insert(h_pair.first);
    }
    for (auto& w_pair : w_num) {
        if (max_w_num == w_pair.second) w_max_idx.insert(w_pair.first);
    }

    ll ans = max_h_num + max_w_num - 1;
    ll cnt = 0;
    rep(i, M) {
        if (h_max_idx.count(h[i]) == 1 && w_max_idx.count(w[i]) == 1) cnt++;
    }
    if(cnt < ll(w_max_idx.size()) * ll(h_max_idx.size())) ans = max_h_num + max_w_num;
   
  
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 61776
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<utility>
#include<cmath>
#include<climits>
#include<queue>
#include<stack>
#include<numeric>
#include<set>
#include<iomanip>
#include<map>
#include<type_traits>
#include<tuple>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
#define rep(i,N) for(ll (i)=0;(i)<(N);(i)++)
const int mod = 1000000007;

int main(){
  int n, k;
  cin >> n >> k;
  vector<int> l(n);
  rep(i, n) cin >> l[i];
  sort(l.begin(), l.end());
  reverse(l.begin(), l.end());
  int ans = 0;
  rep(i, k) ans += l[i];
  cout << ans << endl;
}


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

using namespace std;

#define EACH(i,a) for (auto& i : a)
#define FOR(i,a,b) for(int i=(int)a;i<(int)b;++i)
#define RFOR(i,a,b) for(int i=(int)b-1;i>=(int)a;--i)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define ALL(a) (a).begin(),(a).end()
#define debug(x) cerr << #x << ":" << x << endl;
#define OK(ok) cout << (ok ? "Even" : "Odd") << endl;
typedef long long ll;

void CINT(){}
template <class Head,class... Tail>
void CINT(Head&& head,Tail&&... tail) {
  cin >> head; CINT(move(tail)...);
}
#define CIN(...) int __VA_ARGS__;CINT(__VA_ARGS__)
#define LCIN(...) ll __VA_ARGS__;CINT(__VA_ARGS__)
#define SCIN(...) string __VA_ARGS__;CINT(__VA_ARGS__)

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

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

  CIN(A, B);
  OK((A * B) % 2 == 0);

  return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ios ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
int main()
{
   string a;
   string str="ACL";
   int k;
   cin>>k;
   for (int i=0;i<k;i++)
   {
   	a+=str;
   }
   cout<<a;
}


Measured memory_bytes: 3628
#include <iostream>
#include <vector>
#include <utility>
#include <map>
#include <algorithm>
#include <queue>
#include <cmath>

using namespace std;

const int mod = 1000000007;

int main() {
  int n,m;
  cin >> n >> m;
  vector<long> dp(n+1,-1);

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

  dp[0] = 1;

  for (int i=1; i<=n; i++) {
    if(dp[i] == -1) {
      dp[i] = dp[i-1];
      if(i>1) dp[i]+=dp[i-2];
      dp[i] %= mod;
    }
  }

  cout << dp[n] << endl;
}


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

constexpr int inf = 1e9;
constexpr ll linf = 1e18;

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

    int A, B, C, D, E, F;
    cin >> A >> B >> C >> D >> E >> F;

    int M = 0, m = 0; double mconc = -1;
    for (int a = 0; 100 * A * a <= F; a++) {
        for (int b = 0; 100 * B * b <= F; b++) {
            int water = 100 * A * a + 100 * B * b;
            if (water > F) break;
            if (water == 0) continue;

            for (int c = 0; C * c <= F; c++) {
                for (int d = 0; D * d <= F; d++) {
                    int sugar = C * c + D * d;
                    if (water + sugar > F) break;
                    if (sugar * 100 > E * water) continue;

                    double conc = (double)sugar / (sugar + water);
                    if (conc > mconc) {
                        mconc = conc;
                        M = water + sugar;
                        m = sugar;
                    }
                }
            }
        }
    }

    cout << M << " " << m << endl;
    return 0;
}

Measured memory_bytes: 256
using System;

public class Program
{
  const int NMAX = 100005;
  private static int[] dp;
  private static int dfs(int n){
    if(n == 0) return 0;
    if(dp[n] != 0) return dp[n];
    int max9 = 9;
    while(max9 * 9 <= n) max9 *= 9;
    int max6 = 6;
    while(max6 * 6 <= n) max6 *= 6;
    int cand = NMAX;
    if(n >= max9) cand = Math.Min(cand, dfs(n - max9) + 1);
    if(n >= max6) cand = Math.Min(cand, dfs(n - max6) + 1);
    cand = Math.Min(cand, dfs(n - 1) + 1);
    return dp[n] = cand;
  }
  static public void Main ()
  {
    dp = new int[NMAX];
    int n = int.Parse(Console.ReadLine());
    int ans = dfs(n);
    Console.WriteLine (ans);
  }
}

Measured memory_bytes: 15700
#include<cstdio>
using namespace std;
typedef long long ll;
const int N=22,M=1<<15,P=1000000007;
int i,j,k,n,m,x,y,sum;
int a[N],f[M],cnt[M];
int main() {
	scanf("%d%d",&n,&m);
	sum=1;
	for (i=0;i<m;i++) {
		sum=(sum+sum)%P;
		scanf("%d%d",&x,&y);
		x--;y--;
		a[x]|=1<<y;
	}
	m=1<<n;
	for (i=0;i<m;i++)
		for (j=0;j<n;j++) if (i&1<<j) cnt[i]++;
	f[0]=1;
	for (i=0;i<m;i++) if (((i&2)>>1)==(i&1)) {
		for (j=i;j;j=(j-1)&i) {
			int A=j,B=i^j;
			int ans=f[B];
			for (k=0;k<n;k++) {
				if (B&1<<k) ans=(ll) ans*((1<<cnt[a[k]&A])-1)%P;
				if (A&1<<k) ans=(ll) ans*(1<<cnt[a[k]&B])%P;
			}
			f[i]=(f[i]+ans)%P;
		}
	}
	printf("%d\n",(sum+P-f[m-1])%P);
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N,T,A;
  cin>>N>>T>>A;
  int H[N],X[N];
  for(int i=0;i<N;i++){
    cin>>H[i];
    X[i]=abs((A-T)*1000+H[i]*6);
  }
  sort(X,X+N);
  for(int i=0;i<N;i++){
    if(H[i]==((T-A)*1000+X[0])/6||H[i]==((T-A)*1000-X[0])/6) cout<<i+1<<endl;
  }
}

Measured memory_bytes: 256