akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <cstring>
using namespace std;
#define ll long long
const int MAXN = 2e5+5;
char mp[10][10];
int main()
{   
    int n,m,k;
    scanf("%d%d%d",&n,&m,&k);
    for(int i = 0;i<n;i++)
    {
        scanf("%s",&mp[i]);
    }
    int ans = 0;
    for(int i = 0;i<(1<<n);i++)
    {
        for(int j = 0;j<(1<<m);j++) 
        {
            int temp = 0;
            for(int ii =0;ii < n;ii++)
            {
                for(int jj = 0;jj<m;jj++){
                    if( ((i>>ii) & 1) == 0 && ((j >> jj) & 1) == 0 && mp[ii][jj] == '#') temp++;
                }
            }
            ans += (temp == k);
        }
    }
    printf("%d\n",ans);
}

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

char s[12] = "99999999999", c[12];
long long ans, n, l, r, mid, flag = 1;

int main(){
	for (int i=0; i<=9; i++){
		l = (i == 0); r = 9;
		while (l < r){
			mid = l + r >> 1;
			s[i] = mid + '0';
			printf("? %s\n", s);
			fflush(stdout); scanf("%s", &c);
			if (c[0] == 'Y') r = mid;
			else l = mid + 1;
		}
		ans = ans * 10 + l;
		printf("? %I64d\n", ans+1);
		fflush(stdout); scanf("%s", &c);
		if (l != 9) flag = 0;
		if (flag && c[0] == 'N' || !flag && c[0] =='Y'){
			printf("! %I64d\n", ans); 
			fflush(stdout); return 0;
		}
		s[i] = l + '0';
	}
	return 0;
}

Measured memory_bytes: 684
import std;
void main(string[] args){ if(args.length > 1) if(args[1] == "-debug") DEBUG = 1; solve(); } bool DEBUG = 0; 
void log(A ...)(lazy A a){ if(DEBUG) print(a); }
void print(){ writeln(""); } void print(T)(T t){ writeln(t); } void print(T, A ...)(T t, A a){ std.stdio.write(t, " "), print(a); }
string unsplit(T)(T xs){ return xs.array.to!(string[]).join(" "); }
string scan(){ static string[] ss; while(!ss.length) ss = readln.chomp.split; string res = ss[0]; ss.popFront; return res; }
T scan(T)(){ return scan.to!T; } T[] scan(T)(int n){ return n.iota.map!(i => scan!T()).array; }
T lowerTo(T)(ref T x, T y){ if(x > y) x = y; return x; } T raiseTo(T)(ref T x, T y){ if(x < y) x = y; return x; }

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

void solve(){
  int h = scan!int, w = scan!int, n = scan!int;
  U[] us;
  foreach(_; 0 .. n){
    int x = scan!int - 1, y = scan!int - 1;
    us ~= U(x, y);
  }
  foreach(y; 0 .. w) us ~= U(h, y);
  us.sort!"a.isLess(b)"();
  log("us:", us);
  
  int cnt = 0;
  foreach(u; us){
    log("u:", u, "x:", u.x, "y:", u.y, "cnt:", cnt);
    if(u.y > u.x - cnt) continue;
    else if(u.y == u.x - cnt) cnt += 1;
    else{
      u.x.writeln;
      return;
    }
  }
}
struct U{
  int x, y;
  bool isLess(U v){ return (x != v.x)? (x < v.x): (y < v.y); }
}

Measured memory_bytes: 7720
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <sstream>
#include <string>
#define _repargs(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _repargs(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define mod 1000000007
#define inf 2000000007
#define mp make_pair
#define pb push_back
typedef long long ll;
using namespace std;
template <typename T>
inline void output(T a, int p = 0) {
    if(p) cout << fixed << setprecision(p)  << a << "\n";
    else cout << a << "\n";
}

template <typename T> inline void voutput(T &v){
    rep(i, v.size()){
        if (i) cout << " " << v[i];
        else cout << v[i];
    }
    cout << endl;
}
// end of template
ll A[1010][1010];

int main() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    // source code
    ll big = 1000000000;
    ll H, W, h, w;
    cin >> H >> W >> h >> w;
    
    if(h * w == 1){
        output("No");
        return 0;
    }
    
    ll hh = H / h, ww = W / w;
    ll mul = (big - 1) / (h * w - 1);
    
//    vector<vector<ll>> A(H, vector<ll>(W, mul));
    rep(i, H) rep(j, W){
        A[i][j] = mul;
    }
    rep(i, hh) rep(j, ww){
        A[(i + 1) * h - 1][(j + 1) * w - 1] = -mul * (h * w - 1) - 1;
    }
    
    
    
    ll sum = 0;
    rep(i, H) rep(j, W){
        
        sum += A[i][j];
    }
    if(sum > 0){
        output("Yes");
        rep(i, H){
            rep(j, W){
                if (j) cout << " " << A[i][j];
                else cout << A[i][j];
            }
            cout << endl;
        }
    }
    else{
        output("No");
//        rep(i, H){
//            voutput(A[i]);
//        }
    }
    
    
    
    return 0;
}

Measured memory_bytes: 7040
#include<bits/stdc++.h>
using namespace std;
inline int read(){
	int x=0,f=1;char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9'){x=(x<<3)+(x<<1)+ch-'0';ch=getchar();}
	return x*f;
}
#define MN 100005
int n,b[MN],q;
long long ans[MN];
struct p{int num,id;}a[MN];
bool cmp(p a,p b){return a.num<b.num||(a.num==b.num&&a.id<b.id);}
int main(){
	n=read();
	for(int i=1;i<=n;i++) b[i]=a[i].num=read(),a[i].id=i;
	sort(a+1,a+n+1,cmp);
	for(int i=1;i<=n;i++)
		if(a[i].num!=a[i-1].num){
		while(b[q]<a[i].num) q++;
		ans[q]+=(long long)(n-i+1)*(long long)(a[i].num-a[i-1].num);
	}
	for(int i=1;i<=n;i++) printf("%lld\n",ans[i]);
	return 0;
}

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

public class Solver
{
    public void Solve()
    {
        string S = rs();
        string T = rs();
        int ans = 0;

        for (int i=0; i<S.Length; i++)
        {
            if (S[i] == T[i])
            {
                ans++;
            }
        }

        Console.WriteLine(ans);

    }

    int ri() { return int.Parse(Console.ReadLine()); }
    long rl() { return long.Parse(Console.ReadLine()); }
    double rd() { return double.Parse(Console.ReadLine()); }
    string rs() { return Console.ReadLine(); }

    int[] ria() { return Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray(); }
    long[] rla() { return Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToArray(); }
    double[] rda() { return Console.ReadLine().Split(' ').Select(x => double.Parse(x)).ToArray(); }
    string[] rsa() { return Console.ReadLine().Split(' '); }

}

public class Program
{
    static void Main()
    {
        var solver = new Solver();
        solver.Solve();
    }
}

Measured memory_bytes: 11092
#include <iostream>
using namespace std;
int calc(int n){
    signed long ans = 1;
    const signed long BIGNUM = 1000000007;
    
    for (int i = 0; i < n; i++) {
      ans *= i + 1;
      ans %= BIGNUM;
    }
    
    return ans;
}

int main(void){
    int n;
    std::cin >> n;
    std::cout << calc(n) << std::endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define COUT(x) cout<<(x)<<endl
typedef long long ll;
template<class T> inline void chmax(T& a, T b) {
  if (a < b) a = b;
}

template<class T> inline void chmin(T& a, T b) {
  if (a > b) a = b;
}

const long long INF = 1LL << 60;
int main() {
  ll K,a,b;
  cin >> K >> a >> b;
  bool isok = false;
  for (int i = a; i <= b; ++i) {
    if (i % K == 0) {
        isok = true;
        break;
    }
  }
  if (isok == true) COUT("OK");
  else COUT("NG");
  return 0;
}

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

#define debug(x) cout <<"DEBUG"<<" "<< #x << ":" << x << '\n'

//↓0-originか1-originでn回繰り返し
#define rep(i,n) for(int i = 0; i < ((int)(n)); i++)   //0-origin昇順
#define rep1(i,n) for(int i = 1; i <= ((int)(n)); i++) //1-origin昇順
#define rrep(i,n) for(int i = ((int)(n)-1); i >= 0; i--)  //0-origin降順
#define rrep1(i,n) for(int i = ((int)(n)); i >= 1; i--)   //1-origin降順
//rep2 -> 第二引数 m から n 回繰り返し ex) m=5 n=3 なら i=5,i=6,i=7 まで
#define rep2(i,m,n) for(int i = ((int)(m)); i < ((int)(n))+((int)(m)); i++)
#define SIZE(x) ((int)((x).size()))
#define all(x) (x).begin(),(x).end()
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<vi> vii; //2次元配列
typedef vector<ll> vll;
typedef vector<string> vs;
template<class T,class U> inline bool chmax(T &a, const U &b){if(a<b){a=b;return 1;}return 0;}
template<class T,class U> inline bool chmin(T &a, const U &b){if(a>b){a=b;return 1;}return 0;}

/* 円周率は M_PI を使おうね */
const ll infll = (1LL<<62)-1;
const int inf = (1<<30)-1;

/*FUNCs=================================================*/


/*MAIN==================================================*/
signed main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);   //cin cout 高速化
    //cout << fixed << setprecision(10);

    int n; cin >> n;
    string s; cin >> s;
    if(s.size()%2==1) {
        cout << "No" << '\n';
    }
    else {
        bool can = true;
        for(int i = 0; i < s.size()/2; i++) {
            if(s[i]!=s[i+s.size()/2]) can = false;
        }
        cout << (can?"Yes": "No") << '\n';
    }
    
}




Measured memory_bytes: 256
card_count = gets.chomp.to_i
cards = gets.chomp.split(' ').map(&:to_i)

alice_cards = []
bob_cards = []

for i in 1..card_count do
  if i.odd?
    alice_cards << cards.max unless cards.empty?
  else
    bob_cards << cards.max unless cards.empty?
  end
  cards.delete_at(cards.find_index(cards.max)) 
end

p alice_cards.sum - bob_cards.sum


Measured memory_bytes: 14352
#include <iostream>
#include <algorithm>
#include <cstdio>

long long int N;
long long int A[100000 + 1], B[100000 + 1], C[100000 + 1];
long long int p[100000 + 1];

int main() {
  std::cin >> N;
  for (int i = 1; i <= N; i++) {
    std::cin >> A[i];
  }
  for (int i = 1; i <= N; i++) {
    std::cin >> B[i];
  }
  for (int i = 1; i <= N; i++) {
    std::cin >> C[i];
  }

  std::sort(A, A + (N + 1));
  std::sort(B, B + (N + 1));

  for (int i = 1; i <= N; i++) {
    long long int *iter = std::lower_bound(A, A + (N + 1), B[i]);

    p[i] = (iter - 1 - A);

    p[i] += p[i - 1];
  }

  long long int ans = 0;
  for (int i = 1; i <= N; i++) {
    long long int *iter = std::lower_bound(B, B + (N + 1), C[i]);
    if (iter > B) {
      ans += p[iter - 1 - B];
    }
  }

  std::cout << ans << std::endl;

  return 0;
}

Measured memory_bytes: 3328
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int inf=0x3f3f3f3f;
const ll INF=0x3f3f3f3f3f3f3f;
const double pi=3.1415926535897932384626;
inline ll read(){
	ll x=0,f=1;
	char ch=getchar();
	while(ch<'0'||ch>'9'){
		if(ch=='-') f=-1;
		ch=getchar();
	}
	while(ch>='0'&&ch<='9'){
		x=(x<<1)+(x<<3)+(ch^48);
		ch=getchar();
	}
	return x*f;
}
const int maxn=1e5+5;
ll n,x,m,now,cnt,l,r,ans,idx[maxn],sum[maxn];
int main(){
	n=read(),x=read(),m=read();
	for(cnt=1,now=x;;now=now*now%m,cnt++){
		if(!idx[now]) idx[now]=cnt;
		else{
			l=idx[now];
			r=cnt-1;
			break;
		}
		sum[cnt]=sum[cnt-1]+now;
	}
	ll len=r-l+1;
	ans+=sum[min(n,l-1)];
	n=max(0ll,n-l+1);
	if(n) ans+=(sum[r]-sum[l-1])*(n/len)+sum[n%len+l-1]-sum[l-1];
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 4900
from sys import stdin
def ip(): return [int(i) for i in stdin.readline().split()]
def sp(): return [str(i) for i in stdin.readline().split()]


n = int(input())
A = ip()
k = A[0]
ans = 0
for i in range(len(A)):
    k = max(k, A[i])
    ans += (k - A[i])
print(ans)


Measured memory_bytes: 31460
#include<bits/stdc++.h>
using namespace std;
#define F(i,s,e) for(int i=s;i<e;++i)

int main(){
    int n;
    cin >> n;
    const int N=n;
    long int a[N];
    F(i,0,n){
        cin >> a[i];
    }
    sort(a,a+N);
    F(i,0,n-1){
        if(a[i]==a[i+1]){
            cout << "NO" << endl;
            return 0;
        }
    }
    cout << "YES" << endl;
    return 0;
}

Measured memory_bytes: 1792
use std::io::*;
use std::str::FromStr;

fn main(){
    let n: i64 = read();
    let mut ans: Vec<i32> = Vec::new();
    let mut sum: i64 = 0;
    let mut now: i64 = 1;
    while sum != n || ans.is_empty() {
        if (sum - n) % (now * -2) != 0 {
            sum += now;
            ans.push(1);
        } else {
            ans.push(0);
        }
        now *= -2;
    }
    ans.reverse();
    for i in &ans {
        print!("{}", i);
    }
    println!();
}

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char) 
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

Measured memory_bytes: 4352
#include <cstdlib>
#include <iostream>
#include <algorithm>
#include <cstring>
#include <numeric>
#include <list>
#include <set>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <math.h>
#include <unordered_map>
#include <string>

typedef long long ll;
typedef double db;
const ll mod=1000000007;

#pragma GCC optimize("Ofast")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

/* author : hey_it_works(kunal)
 It works, idk how exactly*/

using namespace std;
int main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);

  int a;
  cin>>a;
  cout<<a+a*a+a*a*a<<endl;

}


Measured memory_bytes: 3616
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <vector>
#include <algorithm>
#include <functional>

using namespace std;

int main()
{
    int K,X,l=-1000000,r=1000000;
    scanf("%d %d\n",&K,&X);

    l=max(X-(K-1),l);
    r=min(X+(K-1),r);

    for(int i=l;i<=r;i++) printf("%d ",i);
    return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define MAX 1000000007
#define MAXN 100005
bool sortby1column(vector<ll> &v1,vector<ll> &v2){
 return v1[0]<v2[0];
}


int main(){
	ios_base::sync_with_stdio(false);
  	cin.tie(NULL);
  	int t=1;
	//cin>>t;
	while(t--){
        string s;
        cin>>s;
        if(s[2]==s[3]&&s[4]==s[5])
            cout<<"Yes\n";
        else        
            cout<<"No\n";
	}
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

/**
 * Intersection of Rectangles
 */
public class Main {

	static Main main = new Main();

	public static void main(String[] args) throws IOException {

		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String line = "";

		while ((line = br.readLine()) != null && !line.isEmpty()) {

			StringTokenizer st = new StringTokenizer(line);

			Point pa1 = main.new Point();
			Point pa2 = main.new Point();
			Point pb1 = main.new Point();
			Point pb2 = main.new Point();

			pa1.x = Double.parseDouble(st.nextToken());
			pa1.y = Double.parseDouble(st.nextToken());
			pa2.x = Double.parseDouble(st.nextToken());
			pa2.y = Double.parseDouble(st.nextToken());
			pb1.x = Double.parseDouble(st.nextToken());
			pb1.y = Double.parseDouble(st.nextToken());
			pb2.x = Double.parseDouble(st.nextToken());
			pb2.y = Double.parseDouble(st.nextToken());

			Rectangle r1 = main.new Rectangle(pa1, pa2);
			Rectangle r2 = main.new Rectangle(pb1, pb2);

			if (r1.intersect(r2)) {
				System.out.println("YES");
			} else {
				System.out.println("NO");
			}

		}

	}

	class Point {
		double x, y;

		Point() {

		}

		Point(double x, double y) {
			this.x = x;
			this.y = y;
		}
	}

	class Rectangle {

		Point[] points = new Point[4];

		Rectangle(Point p1, Point p3) {

			Point p2 = new Point(p3.x, p1.y);
			Point p4 = new Point(p1.x, p3.y);

			points[0] = p1;
			points[1] = p2;
			points[2] = p3;
			points[3] = p4;
		}

		boolean intersect(Rectangle other) {
			boolean result = false;
			if (!(result = intersect(this, other))) {
				result = intersect(other, this);
			}
			return result;
		}

		boolean intersect(Rectangle r1, Rectangle r2) {
			boolean result = false;
			for (Point p : r2.points) {
				if (r1.points[0].x <= p.x && p.x <= r1.points[2].x
						&& r1.points[0].y <= p.y && p.y <= r1.points[2].y) {
					result = true;
					break;
				}
			}
			if (!result) {
				if (r1.points[0].x <= r2.points[0].x
						&& r2.points[2].x <= r1.points[2].x
						&& r2.points[0].y <= r1.points[0].y
						&& r1.points[2].y <= r2.points[2].y) {
					result = true;
				}
			}
			if (!result) {
				if (r2.points[0].x <= r1.points[0].x
						&& r1.points[2].x <= r2.points[2].x
						&& r1.points[0].y <= r2.points[0].y
						&& r2.points[2].y <= r1.points[2].y) {
					result = true;
				}
			}
			return result;
		}

	}

}

Measured memory_bytes: 16960
N = int(input())
a = list(map(int, input().split()))

a_dic = dict()
for i in range(N):
    if a[i] + 1 in a_dic:
        a_dic[a[i] + 1] += 1
    else:
        a_dic[a[i] + 1] = 1
    if a[i] in a_dic:
        a_dic[a[i]] += 1
    else:
        a_dic[a[i]] = 1
    if a[i] - 1 in a_dic:
        a_dic[a[i] - 1] += 1
    else:
        a_dic[a[i] - 1] = 1
        
ans = 0
for v in a_dic.values():
    if ans < v:
        ans = v
        
print(ans)

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

using namespace std;

int main(int argc, char const *argv[])
{
    int n, k, q;
    cin >> n >> k >> q;
    int player;
    vector<int> scores(n + 1, k);
    for (int i = 1; i <= q; i++)
    {
        cin >> player;
        scores[player] += 1;
    }
    for (int i = 1; i <= n; i++)
    {
        scores[i] -= q;
        if (scores[i] > 0)
            cout << "Yes" << endl;
        else
            cout << "No" << endl;
    }
    return 0;
}


Measured memory_bytes: 1024
#include <stdio.h>

int main(int argc, char *argv[]){
   int d, n;
   long long int x = 1;
   int i;

   scanf("%d %d", &d, &n);

   if(d == 0){
     x = 1;
   }else{
     for(i=1; i<=d; i++){
       x = x * 100;
     }
   }

   if(n == 100){
     x = x * n + x;
   }else{
     x = x * n;
   }

   printf("%lld\n",x);

   return 0;
}


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

#define ll long long 
#define pb push_back
int main()
{
    ll n,x,m;
    cin>>n>>x>>m;

    vector<ll> v;

    map<ll,ll> mp;
    v.pb(x);
    ll next;
    while(true)
    {
        next=v[v.size()-1]*v[v.size()-1];

        next%=m;
        if(mp.count(next))
            break;
        mp[next]=v.size();
        v.pb(next);
    }

    ll sum=0;
    for(int i=0;i<min(n,mp[next]);i++)
    {
        sum+=v[i];
    }
    n-=mp[next];


    ll cycsum=0;

    for(int i=mp[next];i<v.size();i++)
    {
        cycsum+=v[i];
    }

    sum+=(n/(v.size()-mp[next]))*cycsum;
    n%=(v.size()-mp[next]);

    for(int i=mp[next];i<mp[next]+n;i++)
    {
        sum+=v[i];
    }

    cout<<sum;

}

Measured memory_bytes: 6692
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <map>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double LD;
using namespace std;
const int INF = 2147483647;
const int INF2 = 0x3f3f3f3f;
const ll INF64 = 4e18;
const double INFD = 1e30;
const double EPS = 1e-10;
const long double PI = acosl(-1);
const int MOD = 1e9 + 7;
template <typename T>
inline T read() {
    T X = 0, w = 0;
    char ch = 0;
    while (!isdigit(ch)) {
        w |= ch == '-';
        ch = getchar();
    }
    while (isdigit(ch)) X = (X << 3) + (X << 1) + (ch ^ 48), ch = getchar();
    return w ? -X : X;
}
const int MAXN = 117777;
const int MAXV = 100005;
int n, m, k;
int dr[4] = {1, 0, -1, 0};
int dc[4] = {0, 1, 0, -1};
int dr2[8] = {1, 1, 1, -1, -1, -1, 0, 0};
int dc2[8] = {1, 0, -1, 1, 0, -1, 1, -1};
int CASE = 1;

int rem[MAXN];
int app[MAXV];
ll pref[MAXN];
int main() {
#ifdef LOCALLL
    freopen("in", "r", stdin);
    freopen("out", "w", stdout);
#endif
    ll a = read<ll>();
    int x = read<int>();
    int m = read<int>();
    rem[1] = x % m;
    app[rem[1]] = 1;
    int base = 1;
    int length = 0;
    for (ll i = 2; i <= a; i++) {
        rem[i] = (ll)rem[i - 1] * rem[i - 1] % m;
        if (app[rem[i]]) {
            base = app[rem[i]];
            length = i - base;
            break;
        }
        app[rem[i]] = i;
    }
    if (!length) length = a;
    for (int i = 1; i < base + length; i++) {
        pref[i] = pref[i - 1] + rem[i];
    }
    ll ans = 0;
    if (a >= base - 1) {
        ans += pref[base - 1];
        a -= base - 1;
    }
    ll cyc = pref[base + length - 1] - pref[base - 1];
    ans += cyc * (a / length);
    ans += (pref[(a % length) + base - 1] - pref[base - 1]);
    printf("%lld\n", ans);
    return 0;
}

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

const int P = 1e9 + 7;

int n, a[22], *p = a, *q = a + 9;
char ch;
void $(int& x) { x += x >> 31 & P; }
int main() {
	for (p[0] = 1; (ch = getchar()) != '\n'; std::swap(p, q), memset(q, 0, 36))
		for (int i = 0; i < 9; i++) {
			if (ch != '1')
				if (i % 3 == 2)
					$(q[i - 1] += p[i] - P);
				else
					$(q[i + 1] += p[i] - P);
			if (ch != '0')
				if (i % 3 == 0)
					$(q[std::min(i + 3, 6)] += p[i] - P);
				else
					$(q[i - 1] += p[i] - P);
		}
	printf("%d", n == 2 ? p[3] : (1ll * p[0] + p[3] + p[4] + p[6] + p[7] + p[8]) % P);
}

Measured memory_bytes: 128
import sys
stdin = sys.stdin
sys.setrecursionlimit(10**6)
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
nn = lambda: list(stdin.readline().split())
ns = lambda: stdin.readline().rstrip()

i = ni()

for j in range(1,360):
    if (360*j)%(360-i) == 0:
        n = (360*j)//(360-i)
        print(n)
        break

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

int main(int argc, char const *argv[]) {
  int n;
  cin>>n;
  if(n%10==2 || n%10==4 || n%10==5 || n%10==7 || n%10==9){
    cout<<"hon";

  }
  else if(n%10==0 || n%10==1 || n%10==6 || n%10==8){
    cout<<"pon";
  }
  else{
    cout<<"bon";
  }
  return 0;
}


Measured memory_bytes: 3636
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <iomanip>
using namespace std;
typedef long long unsigned int ll;
template<typename T> using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;

#define EPS (1e-7)
#define INF (1e15)
#define PI (acos(-1))
#define MOD 1000000007

#define REP(i,n) for(int i=0;i<n;i++)
#define REPS(i,f,n) for(int i=(f);i<(n);i++)
#define EACH(it,v) for(__typeof((v).begin()) it=(v).begin();it!=(v).end();it++)

#define dump(x)  cout << #x << " = " << (x) << endl;
#define debug(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

int dy4[]={0, 0, 1, -1};
int dx4[]={1, -1, 0, 0};
int dx8[]={0, 0, 1, -1, 1, 1, -1, -1};
int dy8[]={1, -1, 0, 0, 1, -1, -1, 1};

// https://atcoder.jp/contests/abc079/tasks/abc079_c

string OP;
string abcd;

bool dfs(string op, int sum) {
    if (op.length() == 3) {
        OP = op;
        return sum == 7;
    }

    if (dfs(op+"+", sum + (abcd[op.length()+1] - '0'))) return true;
    if (dfs(op+"-", sum - (abcd[op.length()+1] - '0'))) return true;

    return false;
}

int main() {
    cin >> abcd;

    if (dfs("", abcd[0]-'0')) {
        printf("%c%c%c%c%c%c%c=7\n", abcd[0], OP[0], abcd[1], OP[1], abcd[2], OP[2], abcd[3]);
    }

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i=0; i<(int)(n); i++)
#define all(v) v.begin(), v.end()
#define allR(v) v.rbegin(), v.rend()
#define PRINT(v) for (auto x : (v)) cout <<x <<" " ; cout <<endl;
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
typedef pair<int,int> Pi;
const ll MOD = 1000000007;
const ll INF = 10000000000000000;
const int inf = 1001001001;
vector<int> x4 = {0, 1, 0, -1}, x8 = {0, 1, 1, 1, 0, -1, -1, -1};
vector<int> y4 = {1, 0, -1, 0}, y8 = {1, 1, 0, -1, -1, -1, 0, 1};
template<class T> inline bool chmin(T& a, T b){if (a>b){a = b; return true;}return false;}
template<class T> inline bool chmax(T& a, T b){if (a<b){a = b; return true;}return false;}
template<class T> inline T powerM(T a,T b){if (b==0) return 1;
T tmp = powerM(a,b/2); if (b%2==0) return tmp*tmp%MOD; else return tmp*tmp%MOD*a%MOD; }
template<class T> inline T power(T a,T b,T m=numeric_limits<T>::max()){ if (b==0) return 1;
  T tmp = power(a,b/2,m); if (b%2==0) return tmp*tmp%m; else return tmp*tmp%m*a%m; }
template<class T> inline T gcd(T a, T b){if (b==0) return a; return gcd(b, a%b);}
template<class T> inline T lcm(T a, T b){return a / gcd(a,b) * b;}
// ax+by=gcd(a,b)を解く
template<class T> inline T extgcd(T a,T b,T &x,T &y){if (b==0){x=1; y=0; return a;} T d=extgcd(b,a%b,y,x); y -= a/b*x; return d;}
void hey(){ cout <<"hey" <<endl; }

template<class T> struct edge { int to; T cost;};


int main() {
  int N; cin >>N;
  vector<int> A(N); rep(i, N) cin >>A[i];
  vector<int> B(100001);
  rep(i, N) B[A[i]]++;
  ll res = 0;
  rep(i, N) res += A[i];
  int Q; cin >>Q;
  rep(qq, Q){
    int b,c; cin >>b >>c;
    res += -b * B[b] + c * B[b];
    cout <<res <<endl;
    B[c] += B[b];
    B[b] = 0;
  }
}


Measured memory_bytes: 4048
#include <stdio.h>
int main(void){
    int n;
    scanf("%d",&n);
    
    char contest_name[3] = {'A', 'B', 'C'};
    
    if(n >= 1000){
        contest_name[2] = 'D';
    }
    
    printf("%c%c%c", contest_name[0], contest_name[1], contest_name[2]);
    return 0;
}


Measured memory_bytes: 128
#include <cctype>
#include <cfloat>
#include <climits>
#include <cmath>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <ios>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <valarray>
#include <vector>

#if __cplusplus >= 201103L
#include <array>
#include <forward_list>
#include <random>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <unordered_map>
#include <unordered_set>
#endif

#define F first
#define S second
#define MP make_pair
#define pb push_back
#define all(a) a.begin(), a.end()
#define lcm( a, b ) (a)/__gcd((a),(b))*(b)
#define endl '\n'

using namespace std;

typedef long long LL;
typedef pair< int, int > P;
typedef pair< LL, LL > LP;
typedef pair< int, P > iP;
typedef pair< P, P > PP;

static const int INF = INT_MAX;
static const LL LINF = LLONG_MAX;
static const int MIN = INT_MIN;
static const LL LMIN = LLONG_MIN;
static const int MOD = 1000000007;
static const int SIZE = 100005;

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

vector< int > Div( int n ) {
    vector< int > ret;
    for( int i = 1; i * i <= n; ++i ) {
        if( n % i == 0 ) {
            ret.pb( i );

            if( i * i != n ) ret.pb( n / i );
        }
    }
    sort( all( ret ) );
    return ret;
}

int Root( int x );
void Unite( int x, int y );

int root[SIZE];

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

    int n, m;
    cin >> n >> m;
    int a[n + 1];
    for( int i = 1; i <= n; ++i ) cin >> a[i];

    for( int i = 0; i < SIZE; ++i ) root[i] = i;
    for( int i = 0; i < m; ++i ) {
        int x, y;
        cin >> x >> y;
        Unite( x, y );

    }

    int res = 0;
    for( int i = 1; i <= n; ++i ) {
        if( Root( a[i] ) == Root( i ) ) ++res;

    }
    cout << res << endl;

    return 0;
}

int Root( int x ) {
    if( root[x] == x ) return x;
    return root[x] = Root( root[x] );

}

void Unite( int x, int y ) {
    int rx, ry;
    rx = Root( x );
    ry = Root( y );

    if( rx < ry ) {
        root[ry] = rx;

    } else {
        root[rx] = ry;

    }
}


Measured memory_bytes: 1024
import std.stdio, std.string, std.conv;
import std.range, std.algorithm, std.array, std.typecons;
import std.math, std.numeric;

alias Pair = Tuple!(int, "x", int, "c");
enum mod = 10^^9 + 7;

void main() {
    int n; scan(n);
    auto a = iota(n).map!(i => Pair(readln.chomp.to!int, 0)).array;
    auto b = iota(n).map!(i => Pair(readln.chomp.to!int, 1)).array;
    auto ab = (a ~ b).sort!"a.x < b.x"();

    long ans = 1;
    long cnt;
    int  col;

    foreach (abi ; ab) {
        if (cnt == 0) {
            col = abi.c;
        }

        if (abi.c == col) {
            cnt++;
        }
        else {
            ans *= cnt;
            ans %= mod;
            cnt--;
        }
    }

    writeln(ans);
}






void scan(T...)(ref T args) {
    import std.stdio : readln;
    import std.algorithm : splitter;
    import std.conv : to;
    import std.range.primitives;

    auto line = readln().splitter();
    foreach (ref arg; args) {
        arg = line.front.to!(typeof(arg));
        line.popFront();
    }
    assert(line.empty);
}



void fillAll(R, T)(ref R arr, T value) {
    static if (is(typeof(arr[] = value))) {
        arr[] = value;
    }
    else {
        foreach (ref e; arr) {
            fillAll(e, value);
        }
    }
}


Measured memory_bytes: 5244
fun main(args: Array<String>) {
    val lineOne = readLine()!!.split(" ").map { it.toInt() }
    val lineTwo = readLine()!!.split(" ").map { it.toInt() }
    val lineThree = readLine()!!.split(" ").map { it.toInt() }
    val number = readLine()!!.toInt()
    val numberList: MutableList<Int> = mutableListOf()
    for (i in 1..number){
        numberList.add(readLine()!!.toInt())
    }
    val cardList: MutableList<Int> = mutableListOf()
    lineOne.forEach {
        cardList.add(it)
    }
    lineTwo.forEach {
        cardList.add(it)
    }
    lineThree.forEach {
        cardList.add(it)
    }
    val isBingo: MutableList<Boolean> = mutableListOf()
    cardList.forEach { it ->
        val n = it
        var isB = false
        numberList.forEach {
            if (n == it) {
                isB = true
            }
        }
        if (isB) {
            isBingo.add(true)
        }else{
            isBingo.add(false)
        }
    }
    if (isBingo[0] && isBingo[1] && isBingo[2]){
        println("Yes")
        return
    }else if (isBingo[3] && isBingo[4] && isBingo[5]){
        println("Yes")
        return
    }else if (isBingo[6] && isBingo[7] && isBingo[8]){
        println("Yes")
        return
    }else if (isBingo[0] && isBingo[3] && isBingo[6]){
        println("Yes")
        return
    }else if (isBingo[1] && isBingo[4] && isBingo[7]){
        println("Yes")
        return
    }else if (isBingo[2] && isBingo[5] && isBingo[8]){
        println("Yes")
        return
    }else if (isBingo[0] && isBingo[4] && isBingo[8]){
        println("Yes")
        return
    }else if (isBingo[2] && isBingo[4] && isBingo[6]){
        println("Yes")
        return
    }else{
        println("No")
    }



}

Measured memory_bytes: 37564
object Main extends App {
  val in = new java.util.Scanner(System.in)
  val N, M = in.nextInt
  val cakes = Array.fill(N)(Array(in.nextLong, in.nextLong, in.nextLong))

  println(
    (0 until 8).map { mask =>
      cakes.map { c =>
        (0 to 2).map { i =>
          c(i) * (if ((mask & (1 << i)) == 0) 1 else -1)
        }.sum
      }.sorted.reverse.take(M).sum
    }.max
  )
}

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

int int_compare(const int* a, const int* b)
{
    if (*a < *b) {
        return 1;
    }
    if (*a > *b) {
        return -1;
    }
    return 0;
}

int main(void)
{
    int n;
    scanf("%d", &n);

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

    qsort(sorted, n, sizeof(int), (int (*)(const void*, const void*))(*int_compare));

    int max = sorted[0];
    int second_max = sorted[1];
    for (int i = 0; i < n; i++) {
        printf("%d\n", a[i] == max ? second_max : max);
    }
    return 0;
}


Measured memory_bytes: 3120
#include<iostream>


#define ll long long

using namespace std;

ll gcd(ll a, ll b) {
    if (a < b) swap(a, b);
    return b == 0 ? a : gcd(b, a % b);
}

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


void solver() {
    ll a, b;
    while (cin >> a >> b) {
        cout << gcd(a, b) << " " << lcm(a, b) << endl;
    }
}

int main() {
    solver();
    return 0;
}

Measured memory_bytes: 3096
fun main(args: Array<String>) {
    val (n, l) = readLine()!!.split(" ").map { it.toInt() }
    val azi = (1..n).map { it + l - 1 }
    val abs = azi.map { if (it > 0 ) it else -it }
    print(azi.sum() - azi[abs.indexOf(abs.min())])
}

Measured memory_bytes: 37988
/**
            C++14 (GCC 5.4.1)
**/
#include <iostream>
#include <cmath>
#include <algorithm>
#include <string>
#include <vector>
#include <set>
using namespace std;

int main() {
    int N, M;

    cin >> N >> M;


    int a = N * (N - 1) / 2;
    int b = M * (M - 1) / 2;
    cout << a + b << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int A,B,C;
  int D;
  int E,F;
  int G;
  
  cin >> A >> B >> C;
  G=C;
  E = B+A+1;
  if(C<E)F=C;
  else{
  D= C-E;
  F= C-D;
  }
  F = (F+B);
  cout << F << endl;
}

Measured memory_bytes: 3528
#include<cstdio>
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<cmath>
#include<cstdlib>
#include<bitset>
#include<utility>
using namespace std;


int main(void) {
	int n,k,ans;
	cin>>n>>k;

	ans = n-k+1;

	cout<<ans<<"\n";

	return 0;
}


Measured memory_bytes: 256
def LCS():
    str1 = raw_input()
    str2 = raw_input()
    
    after = [0] * (len(str2) + 1)
    
    for i in xrange(1, len(str1) + 1):
        before = after + []
        for j in xrange(1, len(str2) + 1):
             if str1[i - 1] == str2[j - 1]:
                 after[j] = before[j - 1] + 1
             elif after[j - 1] > before[j]:
                 after[j] = after[j - 1]
    return after[j]

n = input()
for k in xrange(n):
    print LCS()

Measured memory_bytes: 6504
#include <iostream>
using namespace std;
int main() {
  int i=0;
  int x;
  int num[10000];
  for(i=0; i<10000; i++){
    cin >> x;
    if (x == 0)break;
    num[i] = x;
  }

  for(int h=0; h<i; h++){
  cout << "Case " << h+1 << ": " << num[h] << endl;
  }
  return 0;
}

Measured memory_bytes: 3128
#include <iostream>
#define int long long
#define ll long long
using namespace std;

const int MOD = (int)1e9 + 7;
int n, a, b;

int qpow(int x, int k) {
    int ret = 1;
    while(k) {
        if(k & 1) ret *= x;
        x *= x, k >>= 1;
        ret %= MOD, x %= MOD;
    }
    return ret;
}

int inv(int x) {
    return qpow(x, MOD - 2);
}

int C(int x, int n) {
    int t1 = 1, t2 = 1;
    if(x < n - x) x = n - x;
    for(int i = x + 1; i <= n; ++i)
        t1 *= i, t1 %= MOD;
    for(int i = 1; i <= n - x; ++i)
        t2 *= i, t2 %= MOD;
    return t1 * inv(t2) % MOD;
}

signed main() {
    cin >> n >> a >> b;
    cout << ((qpow(2, n) - C(a, n) - C(b, n) - 1) % MOD + MOD) % MOD;
    return 0;
}

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

int main(void){

  int n;
  while(cin >> n, n){
    vector<string> a(n);
    int cnt=0;
    
    for(int i=0;i<n;i++)cin >> a[i];
    for(int i=0;i+1<n;i++)
      cnt += a[i][1]==a[i+1][1];
    cout << cnt << endl;
  }
  
  return 0;
}

Measured memory_bytes: 3084
x = int(input())

ans = 1
if x <= 1799: ans = 2
if x <= 1599: ans = 3
if x <= 1399: ans = 4
if x <= 1199: ans = 5
if x <= 999: ans = 6
if x <= 799: ans = 7
if x <= 599: ans = 8

print( ans )


Measured memory_bytes: 9184
using System;

namespace atCoder
{
    class Program
    {

        static void Main()
        {
            string[] temp = Console.ReadLine().Split(' ');
            int a = int.Parse(temp[0]);
            int b = int.Parse(temp[1]);
            int c = int.Parse(temp[2]);
            int x = int.Parse(temp[3]);
            int y = int.Parse(temp[4]);
            long result = long.MaxValue;

            if (2 * c < a + b)
            {
                for (int i = 1; i <= 1000000; i++)
                {
                    int count = i * 2 * c + Math.Max(0, x - i) * a + Math.Max(0, y - i) * b;

                    if (count < result)
                    {
                        result = count;
                    }

                    if (x - i <= 0 && y - i <= 0)
                    {
                        break;
                    }
                }
            }
            else
            {
                result = a * x + b * y;
            }

            Console.WriteLine(result);
        }
    }
}

Measured memory_bytes: 13140
#include <bits/stdc++.h>
typedef long long lint;
using namespace std;

//ただの辺
struct edge {
    using lint = long long int;
    int to;
    lint cost;
    //引数一つの時は距離1
    edge(int t, lint c = 1) : to(t), cost(c) {
    }
};

lint mod = 1e+9 + 7;
lint n;
vector<lint> p, inv;
vector<vector<edge>> g;
map<pair<int, int>, int> weight;

int dfs(int now, int direction) {
    int res = 1;
    for (auto e : g[direction]) {
        if (e.to == now) continue;
        res += dfs(direction, e.to);
    }
    weight[{now, direction}] = res;
    return res;
}

int main() {
    cin >> n;
    g.resize(n);
    for (int i = 0; i < n - 1; i++) {
        int a, b;
        cin >> a >> b;
        a--, b--;
        g[a].push_back(b);
        g[b].push_back(a);
    }
    // weight辞書を作る
    for (auto e : g[0]) {
        dfs(0, e.to);
    }
    // weightに基づき、cost=(頂点からto方向に何個頂点があるか)を代入
    for (int i = 0; i < n; i++) {
        for (auto &e : g[i]) {
            if (weight[{i, e.to}] > 0) {
                e.cost = weight[{i, e.to}];
            } else {
                e.cost = n - weight[{e.to, i}];
            }
        }
    }
    // 2冪の前計算
    p.resize(n + 1), inv.resize(n + 1);
    p[0] = 1, p[1] = 2, inv[0] = 1, inv[1] = (mod + 1) / 2;
    for (int i = 1; i < n; i++) {
        p[i + 1] = (p[i] * p[1]) % mod;
        inv[i + 1] = (inv[i] * inv[1]) % mod;
    }
    lint ans = 0;
    for (int i = 0; i < n; i++) {
        lint temp = p[n - 1] - 1;
        for (auto e : g[i]) {
            temp = (temp - (p[e.cost] - 1)) % mod;
        }
        temp = (temp * inv[n]) % mod;
        ans = (ans + temp) % mod;
    }
    if (ans < 0) ans += mod;
    cout << ans << endl;
}

Measured memory_bytes: 57088
import java.util.*;
public class Main {
	public static void main(String args[]){
		Scanner sc=new Scanner(System.in);
		while(sc.hasNext()){
			double x=sc.nextDouble();
			double h=sc.nextDouble();
			if(x==0&&h==0)break;
			System.out.printf("%6f\n",x*x+2*x*Math.sqrt(h*h+x*x/4));
		}
	}
}

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

int N;
string S;
long long counting[100005];
long long ans=1;
int order;
int n;

int main()
{
    cin>>N;
    cin>>S;

    for (int i=0; i<N; i++)
    {
        order=S[i]-'a';
        counting[order]++;
    }

    for (int i=0; i<26; i++)
    {
        if (counting[i]>0)
        {
            n=(counting[i]+1)%1000000007;
            ans=(ans*n)%1000000007;
        } 
    }

    ans=(ans-1)%1000000007;

    cout<<ans<<endl;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rrep(i,n) for(int i=(int)(n-1);i>=0;i--)
#define FOR(i,n,m) for(int i=n;i<=(int)(m);i++)
#define RFOR(i,n,m) for(int i=(int)(n);i>=m;i--)
#define all(x) (x).begin(),(x).end()
#define sz(x) int(x.size())
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;
using namespace std;
vector<int> dy={1,0,-1,0};
vector<int> dx={0,1,0,-1};
template<class T>
vector<T> make_vec(size_t a){
    return vector<T>(a);
}
template<class T, class... Ts>
auto make_vec(size_t a, Ts... ts){
    return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}
int main(){
    int n;
    cin>>n;
    vector<vector<char>> s(n,vector<char>(n));
    rep(i,n) rep(j,n) cin>>s[i][j];
    
    vector<vector<char>> t(n,vector<char>(n));
    int a=0;
    int ans=0;
    rep(b,n){
        rep(i,n){
            rep(j,n){
                t[i][j]=s[(i+a)%n][(j+b)%n];
            }
        }
        
        bool now=true;
        rep(i,n){
            rep(j,n){
                if(t[i][j]!=t[j][i]) now=false;
            }
        }
        ans+=now;
    }
    cout<<ans*n<<endl;
}


Measured memory_bytes: 512
import math


def divisor(x):
    d = {}
    for i in range(1, math.ceil(math.sqrt(x)) + 1):
        q, r = divmod(x, i)
        if r == 0:
            d[i] = 1
            if q != i:
                d[q] = 1
    d = list(d.keys())
    d.sort()
    return d
    


def submit():
    n, m = map(int, input().split())

    # Mの約数を求める
    d = divisor(m)
    nd = len(d)

    # 二分探索で条件を満たすdを求める
    l = 0
    r = nd - 1
    while l <= r:
        mid = (l + r) // 2
        if n * d[mid] <= m:
            l = mid + 1
        else:
            r = mid - 1
    print(d[l - 1])


submit()        

Measured memory_bytes: 3064
#include <cstdio>
#include <climits>
#include <cstdlib>
#include <cmath>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <list>
#include <set>
#include <bitset>
#include <iterator>
#define loop(i, a, b) for(int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) for(long long i = 0; i < (long long)(n); i++)
#define debug(x)  cout << #x << " = " << (x) << endl;

using namespace std;
using LL = long long int;
using ULL = unsigned long long;

int main() {
    int y, m, d;
    char c;
    cin >> y >> c >> m >> c >> d;
    if (m >= 5) {
        cout << "TBD" << endl;
    } else {
        cout << "Heisei" << endl;
    }
    return 0;
}


Measured memory_bytes: 384
import java.util.Scanner;
import java.lang.Math;

// ALDS1_1_C
public class Main {
	public static boolean primeJudge(int a) {
		double sqrt = Math.sqrt(a) + 1;
		if (a < 2) return false;
		if (a == 2) return true;
		if (a % 2 == 0) return false;
		for (int i = 3; i < sqrt; i+=2) {
			if (a % i == 0) return false;
		}
		return true;
	}
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int count = 0;
		for (int i = 0; i < n; i++) {
			if (primeJudge(sc.nextInt())) count++;
		}
		System.out.println(count);
	}
}



Measured memory_bytes: 41120
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author
 */

#include <iostream>
#include <fstream>

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

typedef long long ll;
#define tr(container, it) \
        for (auto it = container.begin(); it != container.end(); it++)
#define scontains(c, x) ((c).find(x) != (c).end())   //O(log n)
#define contains(c, x) (find((c).begin(),(c).end(),x) != (c).end()) //O(n)
#define pll pair<ll,ll>
#define pii pair<int,int>
#define mll map<ll,ll>
#define intv(x, a, b)((x)>=a && (x)<=b)
#define  rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define  _for(i, end) for (__typeof(end) i = 0; i < (end); i += 1)
#define all(x) (x).begin(),(x).end()
//#define len(array)  (sizeof(array)/sizeof((array)[0]))
#define what_is(x) cerr << #x << " is " << x << endl;
#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
#define mod(x, m) ((((x) % (m)) + (m)) % (m))

const double PI = 2 * acos(.0);
const int INF = 0x3f3f3f3f;
const ll LLINF = 1000000000000000005LL;;
const ll MOD = (ll) (1e9) + 7;
void _mod(ll &x){x = mod(x, MOD);}
//const ll MOD = (ll) 998244353 ;
const double EPS = 1e-10;
int readint(){int t;cin >> t;return t;}

template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val) {
    std::fill((T *) array, (T *) (array + N), val);
}


//#define int ll

class CIrohasObsession {
public:
        int A[11];
        int N,K;
        bool ok(int n){
            while(n){
                if(A[n%10])return 0;
                n /= 10;
            }
            return 1;
        }
void solve(std::istream& cin, std::ostream& cout) {
    cin >> N >> K;
     memset(A, 0, sizeof(A));
    _for(i,K){
        int t;
        cin >> t;
        A[t] ++;
    }
    while(1){
        if(ok(N)){cout << N << endl;return;}
        N++;
    }
}
};


#undef int
int main() {
	CIrohasObsession solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<vector>
#include<iostream>
#include<functional>

using namespace std;
typedef long long ll;
#define REP(i,n) for(int i=0;i<(int)(n);i++)

int main(){
    ll n,s,x;
    vector<ll> list;
    cin >> n >> s;
    REP(i,n){
        cin >> x;
        list.push_back(x);
    }
    ll l=0, r=0;
    ll ans = 1<<30;
    ll stat = 0;
    for(l=0; l<n; l++){
        if(l!=0) stat -= list[l-1];
        if(r<l){ r=l; stat=0; }
        while(stat < s && r<n) stat += list[r++];
        //cout << "###" << l << " " << r << " " << stat << " " << ans << endl;
        if(stat >= s)if(ans > r-l) ans = r-l;
    }
    if(ans == 1<<30) cout << "0" << endl;
    else cout << ans << endl;
}


Measured memory_bytes: 3916
#include <iostream>
#include <string>
#include <cmath>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<iomanip>
#define _USE_MATH_DEFINES
#include <math.h>
#include <functional>
using namespace std;

#define rep(i,x) for(ll i=0;i<x;i++)
#define repn(i,x) for(ll i=1;i<=x;i++)

typedef long long ll;
const ll INF = 1e17;
const ll MOD = 1000000007;
const ll MAX = 1000001;

ll max(ll a, ll b) {
	if (a > b) { return a; }
	return b;
}

ll min(ll a, ll b) {
	if (a > b) { return b; }
	return a;
}

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

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

struct edge {
	ll ind;
	ll to;
	ll d;
};


///////////////////////////

ll dv(ll h, ll w) {
	if (h % 2 == 0 || w % 2 == 0) { return 0; }
	else { return min(h, w); }
}

int main() {

	ll x, y;
	cin >> x >> y;

	ll a[13] = { 0,1,3,1,2,1,2,1,1,2,1,2,1 };

	if (a[x] == a[y]) { cout << "Yes"; }
	else { cout << "No"; }

	
	system("PAUSE");
}


Measured memory_bytes: 504
#include <iostream>
#include <algorithm>

int count[200000];

int main() {
	int n, k;
	std::cin >> n >> k;

	int kind = 0;
	for (int i = 0; i < n; ++i) {
		int a;
		std::cin >> a;
		--a;

		if (count[a] == 0)
			++kind;

		++count[a];
	}

	std::sort(count, std::end(count));

	int ans = 0;
	for (int i = 0; kind > k; ++i) {
		if (count[i] >= 1) {
			ans += count[i];
			--kind;
		}
	}

	std::cout << ans << std::endl;
}

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

int n, k;
int h[100005] = {0};
int dp[100005] = {0};

int solve();

int main() {
  cin >> n >> k;
  for(int i = 0; i < n; ++i) cin >> h[i];
  cout << solve() << endl;
  return 0;
}

int solve() {
  for(int i = 1; i < n; ++i) dp[i] = 2000000000;
  for(int i = 0; i < n; ++i) {
    for(int j = 1; j + i < n && j <= k; ++j) {
      int cost = max(h[i] - h[i + j], h[i + j] - h[i]);
      dp[i + j] = min(dp[i + j], dp[i] + cost);
    }
  }
  return dp[n - 1];
}

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

#define ll long long
#define vi vector<int>
#define vl vector<ll>
#define pii pair<int,int>
#define pll pair<ll,ll>
// pll pp; -> (pp.first,pp.second)
// vector<vl> pp(n,vl(2)); sort(pp.begin(),pp.end(),[](vl a,vl b){return a[0]<b[0];});

#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)
#define RREP(i,n) for(ll (i)=(n)-1;(i)>=0;(i)--)
#define FOR(i,a,b) for(ll (i)=(a);(i)<(b);(i)++)
#define FORR(i,a,b) for(ll (i)=(b)-1;(i)>=(a);(i)--)
#define DEBUG(x) cout << #x << ": " << x << endl
#define CHMAX(a,b) a=max((a),(b))
#define CHMIN(a,b) a=min((a),(b))
/*}}}*/
int main() {
  ll n;
  cin >> n;
  ll ans = n*n;
  cout << ans<< endl;
  return 0;
}


Measured memory_bytes: 256