akhauriyash/Code-Regression huggingface dataset:
import java.io.*;
import java.util.*;

//Main class start
public class Main {
    // solution starts here!!!
    public void solve() throws IOException {
        int n = in.ni();
        Set<String> a = new HashSet<>();
        for(int i=0 ; i<n ; i++)
        {
           a.add(in.next());
        }
        out.println(a.size());





    } //Solution ENDS Here !!!

    FastScanner in;
    FastWriter out;
    long maxLong = Long.MAX_VALUE  ,  minlong = Long.MIN_VALUE;
    int maxInt = Integer.MAX_VALUE ,  minInt = Integer.MIN_VALUE;
    double PI = 3.141592653589793238462643383279502884197169399;
    int digit(long s){int ans = 0;while(s>0){s/=10;ans++;}return ans;}
    long gcd(long a, long b){return (b==0)?a:gcd(b,a%b);}
    int gcd(int a, int b){return (b==0)?a:gcd(b,a%b);}
    int bit(long n){return (n==0)?0:(1+bit(n&(n-1)));}

    public void run() {
        try {
            in = new FastScanner();
            out = new FastWriter();

            solve();

            out.close();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }


    class FastWriter extends PrintWriter {
        FastWriter() throws FileNotFoundException {
            super(System.out);
        }

        void printNext(int i) {
            print(i);
            print(' ');
        }

        void printNext(long i) {
            print(i);
            print(' ');
        }

        void printNext(char ch) {
            print(ch);
            print(' ');
        }


        <T extends Iterable<Integer>> void printIterable(T o) {
            for (Integer t : o) {
                printNext(t);
            }
        }

        void printlnArray(int[] a) {
            for (int i : a) {
                printNext(i);
            }
            println();
        }

        void printlnArray(long[] a) {
            for (long i : a) {
                printNext(i);
            }
            println();
        }


    }

    class FastScanner {
        BufferedReader br;
        StringTokenizer st;


        boolean ready() throws IOException {
            return (br.ready() || st.hasMoreTokens());
        }

        FastScanner() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        String next() {
            while (st == null || !st.hasMoreTokens()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }
        char nc(){
            return next().charAt(0);
        }

        double nd(){
            return Double.parseDouble(next());
        }

        int ni() {
            return Integer.parseInt(next());
        }

        long nl() {
            return Long.parseLong(next());
        }

    }

    public static void main(String[] arg) {
        new Main().run();
    }
}


Measured memory_bytes: 71560
#include <bits/stdc++.h>
#define int long long int
#define endl "\n"
using namespace std;
void solve()
{
	
	//Enter your code here Tanmay:)
	deque<char> dq;

	int flag=0;
	string s;
	cin>>s;
	for(int i=0;i<s.size();i++)
		dq.push_back(s.at(i));

	/*for(auto x=dq.begin();x!=dq.end();x++)
		cout<<*x<<" ";*/
	int q;
	cin>>q;
	int count=0;
	while(q--)
	{
		int ch;
		cin>>ch;
		if(ch==1)
		{
			count++;
			if(flag==0)
				flag=1;
			else
				flag=0;
		}
		 else if(ch==2)
		 {
		 	//count=0;
		 	int f;
		 	char c;
		 	cin>>f>>c;
		 	if((f==1 && flag==0)||(f==2 && flag==1))
		 		dq.push_front(c);
		 	else if((f==2&&flag==0)||(f==1&&flag==1))
		 		dq.push_back(c);
		 }
	}
	if(count%2!=0)
	{
		for(auto x=dq.rbegin();x!=dq.rend();x++)
			cout<<*x;
	}
	
	else
	{
		for(auto x=dq.begin();x!=dq.end();x++)
		cout<<*x;
	}
}
signed main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	int t=1;
	//cin>>t;
	while(t--)
	{
		solve();
	}
	return 0;
}
/*
int eulortotent(int n)
     {
    //Enter your code here Tanmay:)
    int total=n;
        for(int p=2;p*p<=n;p++)
        {
            if (n%p==0)
        {
            total /= p;
            total *= (p-1);
            while ( n % p == 0 ) 
                n /= p;
        }
    }

    if(n>1)
    {
        total/=n;
        total*=(n-1);
    }

  return total;
}
*/

Measured memory_bytes: 976
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define MAX 1000000000
#define PI 3.14159265359
int dx[] = {1,0,-1,0};
int dy[] = {0,-1,0,1};
const ll INF = 10010010010001;
vector<vector<bool>> graph;
vector<bool> reached;
ll MOD = 1000000007;

int main(){
    ll n;
    cin >> n;
    ll ans = 1e18;
    for(ll i=1;i*i<=n;i++){
        if(n%i != 0) continue;
        ll j = n/i;
        ans = min(ans,i+j-2);
    }
    cout << ans << endl;
}


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

l = [s]
i = 0
while True:
  if l[i] % 2 == 0:
    l.append(l[i]//2)
  else:
  	l.append(l[i]*3+1)
  if l[i+1] in l[:-1]:
    print(i+2)
    break
  i += 1

Measured memory_bytes: 2940
n, W = map(int, input().split())
w, v = [], []
for _ in range(n):
    _w, _v = map(int, input().split())
    w.append(_w)
    v.append(_v)

sv = sum(v)
dp = [[float("inf")]*(sv+1) for _ in range(n+1)]
dp[0][0] = 0

for i in range(n):
    for j in range(sv+1):
        dp[i+1][j] = dp[i][j]
        if v[i] <= j:
            dp[i+1][j] = min(dp[i][j-v[i]]+w[i], dp[i][j])

ans = 0
for i, v in enumerate(dp[n]):
    if v <= W:
        ans = i
print(ans)


Measured memory_bytes: 307656
//import java.util.*;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Set;
import java.util.HashSet;

public class Main {
    static int[][] map;
    static boolean[][] visited;
    public static void main(String[] args) throws Exception {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String str_n = br.readLine();
        int n = Integer.parseInt(str_n);
        int digit_sum = 0;
        
        for (int i = 0; i < str_n.length(); i++) {
            digit_sum += Integer.parseInt(String.valueOf(str_n.charAt(i)));
        }
        
        System.out.println(n%digit_sum==0?"Yes":"No");
    }
}


Measured memory_bytes: 21076
from sys import exit

distance = [int(input()), int(input()), int(input()), int(input()), int(input())]

k = int(input())

for i in range(5):
    for j in range(i + 1, 5):
        if distance[j] - distance[i] > k:
            print(':(')
            exit()
print('Yay!')


Measured memory_bytes: 2940
A=[]
B=[False]*9
for i in range(3):
  A+=[int(i) for i in input().split()]
n=int(input())
for _ in range(n):
  b=int(input())
  for i in range(9):
    if b==A[i]:
      B[i]=True
C=[[1,2,3],[4,5,6],[7,8,9],[1,4,7],[2,5,8],[3,6,9],[1,5,9],[3,5,7]]
Chk=False
for a,b,c in C:
  if B[a-1] and B[b-1] and B[c-1]:
    Chk=True
print("Yes" if Chk else "No")

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define ll long long
#define rep(i, n) for (int i = 0; i < (n); i++)
#define INF (1 << 20)
using namespace std;
int main()
{
    int cost[10] = {8,
                    2,
                    5,
                    5,
                    4,
                    5,
                    6,
                    3,
                    7,
                    6};
    int n, m;
    cin >> n >> m;
    int use[m];

    rep(i, m) cin >> use[i];
    sort(use, use + m, greater<int>());
    int dp[n];
    dp[0] = 0;
    for (int i = 1; i <= n; i++)
    {
        dp[i] = -INF;
        rep(j, m)
        {
            if (i - cost[use[j]] >= 0)
            {
                dp[i] = max(dp[i], dp[i - cost[use[j]]] + 1);
            }
        }
    }
    int N = n;
    rep(i, dp[n])
    {
        int ans = -1;
        rep(j, m)
        {

            if ((N - cost[use[j]] >= 0) && (dp[N - cost[use[j]]] == dp[N] - 1))
            {

                ans = use[j];
                N -= cost[use[j]];
                break;
            }
        }
        cout << ans;
        }
    cout << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>//author::@whohet-->Het Patel
#define fasterthanlight ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define test int T; cin>>T; while(T--)
#define endl "\n"
#define int long long
#define uint unsigned long long
#define ld long double
#define pii pair<int,int>
#define vi vector<int>
#define vc vector<char>
#define vs vector<string>
#define vvi vector<vector<int>>
#define mii map<int,int>
#define msi map<string,int>
#define mis map<int,string>
#define pb push_back
#define mod 1000000007
#define PI 3.141592653589793238

using namespace std;

//author::@whohet-->Het Patel

signed main()
{
	fasterthanlight;
	int n;
	int s,w;
	cin>>s>>w;
	if(w>=s)
		cout<<"unsafe";
	else
		cout<<"safe";

}




Measured memory_bytes: 3652
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <vector>
#include <stack>#include <map>#define ll long long
using namespace std;

int main(void){
    int a, b ,c;
    cin >> a >> b >> c;

    if((b-a) == (c-b)){
        cout << "YES";
    } else {
        cout << "NO";
    }

    cout << endl;
    return 0;
}


Measured memory_bytes: 256
import numpy as np

N,X = map(int,(input().split()))
city_list = list(map(int,(input().split())))
city_list.append(X)
i = 0
#city_list = []
#city_list.append(list(map(int,(input().split()))))

def gcd(p,q):
	while q > 0:
		p,q = q, p%q
	return p
  
#print(city_list)
#print(np.diff(sorted(city_list)))
city_diff = np.diff(sorted(city_list))

if N == 1:
	gcd_val = city_diff[0]
elif N == 2:
	gcd_val = gcd(city_diff[0],city_diff[1])
else:
	gcd_val = gcd(city_diff[0],city_diff[1])
	for i in range(i+2,N):
		gcd_val = gcd(gcd_val,city_diff[i])

print(gcd_val)

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

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

    int a, b, c;
    cin >> a >> b >> c;
    int count = 0;
    for (int i = a; i <= b; i++) {
        if (c % i == 0)
            count++;
    }
    cout << count << endl;
}


Measured memory_bytes: 3212
#include<bits/stdc++.h>
#define int long long
#define rep(i, n) for(int i = 0; i < (int)n; i++)
#define repa(i, s, n) for(int i = s; i < (int)n; i++)
using namespace std;
using ll = long long;
typedef vector<int> vi;
typedef pair<int, int> P;
#define rrep(i,a,b) for(int i=a;i>=b;i--)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

int N, W;
int w[110], v[110];
int dp[110][100100] = {0};

signed main(){
    cin >> N >> W;
    rep(i, N) cin >> w[i] >> v[i];

    rep(i, N){
        for(int sum_w = 0; sum_w <= W; sum_w++){
            if(sum_w - w[i] >= 0){
                chmax(dp[i+1][sum_w], dp[i][sum_w - w[i]] + v[i]);
            }
            chmax(dp[i+1][sum_w], dp[i][sum_w]);
        }
    }

    cout << dp[N][W] << endl;
}

Measured memory_bytes: 81664
const main = input => {
    stack = input.split(' ').map(Number);
    A = stack[0];
    B = stack[1];
    K = stack[2];

    for (i = 0; i < K; i ++) {
        if (i % 2 == 0) {
            if (A % 2 > 0) A --;
            A /= 2;
            B += A;
        } else {
            if (B % 2 > 0) B --;
            B /= 2;
            A += B;
        }
    }

    console.log(A, B);
};

main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 21192
s=str(input())
t=str(input())
m=len(s)
n=len(t)
ct=n
for i in range (m-n+1):
    z=0
    for j in range(n):
        if s[i+j]!=t[j]:
            z+=1
    if z<ct:
        ct=z
print(ct)


Measured memory_bytes: 9044
import java.util.Scanner;

/**
 *
 * @author k16069kk
 */
public class Main {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int num = scan.nextInt();
        int i = 1;
        while (!(i == (num + 1))) {
            int x = i;
            if (x % 3 == 0) {
                System.out.print(" " + i);
            } else if (x % 10 == 3) {
                System.out.print(" " + i);
            } else if (x / 10 != 0) {
                while (x / 10 != 0) {
                    x /= 10;
                    if (x % 10 == 3) {
                        System.out.print(" " + i);
                        break;
                    }
                }
            }

            i++;
        }
        System.out.println();
    }

}



Measured memory_bytes: 28804
// C - Special Trains

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
// const int INF = 2147483647;
// const ll INF = 9223372036854775807;
// const ll MOD = 1e9 + 7;

int N;
int C[500];
int S[500];
int F[500];

int get_arrival_time(int i, int t) {
	if (i == N-1) return t;

	int departure_time = max(S[i], F[i] * ((t-1) / F[i] + 1));
	int next_t = departure_time + C[i];

	return get_arrival_time(i+1, next_t);
}

int main() {
	cin >> N;

	for (int i=0; i<N-1; i++) {
		cin >> C[i] >> S[i] >> F[i];
	}

	for (int i=0; i<N; i++) {
		cout << get_arrival_time(i, 0) << endl;
	}

	return 0;
}

Measured memory_bytes: 256
#include <inttypes.h>
#include <math.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int main(void)
{
    intmax_t K, A, B;

    scanf("%jd", &K);
    scanf("%jd%jd", &A, &B);

    for (size_t i = A; i <= B; i++) {
        if (i % K == 0) {
            puts("OK");
            return 0;
        }
    }

    puts("NG");

    return 0;
}


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

int ctoi(char s){
  if(s=='0') return 0;
  if(s=='1') return 1;
  if(s=='2') return 2;
  if(s=='3') return 3;
  if(s=='4') return 4;
  if(s=='5') return 5;
  if(s=='6') return 6;
  if(s=='7') return 7;
  if(s=='8') return 8;
  if(s=='9') return 9;
}

int main() {
  string s;
  cin>>s;
  int n=s.size();
  int a[6]={1,10,9,12,3,4};
  ll dp[n+1][13];
  rep(i,0,n+1){
    rep(j,0,13){
      dp[i][j]=0;
    }
  }
  dp[0][0]=1;
  rep(i,1,n+1){
    rep(j,0,13){
      char c=s.at(n-i);
      if(c=='?'){
        rep(k,0,10){
          int l=j-a[(i-1)%6]*k%13;
          if(l<0) l+=13;
          dp[i][j]+=dp[i-1][l];
          dp[i][j]%=mod;
        }
      }
      else{
        int l=j-a[(i-1)%6]*ctoi(c)%13;
        if(l<0) l+=13;
        dp[i][j]=dp[i-1][l];
      }
    }
  }
  cout<<dp[n][5]<<endl;
}


Measured memory_bytes: 10624
class Graph(): #non-directed
    def __init__(self,n,edge):
        self.n = n
        self.graph = [[] for _ in range(n)]
        for e in edge:
            self.graph[e[0] - 1].append(e[1] - 1)
            self.graph[e[1] - 1].append(e[0] - 1)

    def is_bipartite(self):
        group = [None for _ in range(self.n)]
        stack = [(0, 1)]
        while stack:
            node, nodecolor = stack.pop()
            group[node] = nodecolor
            for adj in self.graph[node]:
                if group[adj] == nodecolor:
                    return False
                if group[adj] is None:
                    adjcolor = 1 - nodecolor
                    stack.append((adj, adjcolor))
        return True

    def warshall_floyd(self, INF=10**18):
        dist = [[INF for j in range(self.n)] for i in range(self.n)]
        for i in range(self.n):
            dist[i][i] = 0
        for i in range(self.n):
            for j in self.graph[i]:
                dist[i][j] = 1
        for k in range(self.n):
            for i in range(self.n):
                for j in range(self.n):
                    if dist[i][k] != INF and dist[k][j] != INF:
                        dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j])
        return dist

    def diam(self):
        res = 0
        dist = self.warshall_floyd()
        for i in range(self.n):
            for j in range(self.n):
                res = max(res, dist[i][j] + 1)
        return res

N = int(input())
E = []

for i in range(N - 1):
    S = list(map(int,input()))
    for j in range(i + 1, N):
        if S[j]:
            E.append((i + 1, j + 1))

G = Graph(N, E)

if G.is_bipartite():
    print(G.diam())

else:
    print(-1)

Measured memory_bytes: 44508
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
  ll n;cin>>n;
  ll a[n],b[n];
  ll suma=0,sumb=0;
  ll ans=0;
  for(ll i=0;i<n;i++){cin>>a[i];suma+=a[i];}
  for(ll j=0;j<n;j++){
    cin>>b[j];
    sumb+=b[j];
  }
  if(suma<sumb){
    cout<<-1<<endl;
    return 0;
  }
  vector<ll> v;
  ll summ=0;
  ll num=0;
  for(ll i=0;i<n;i++){
    if(a[i]>b[i])v.push_back(a[i]-b[i]);
    if(b[i]>a[i]){
      summ+=b[i]-a[i];
      num++;
    }
  }
  sort(v.begin(),v.end(),greater<ll>());
  ll sum=0;
  for(ll i=0;i<v.size();i++){
    if(sum>=summ){
      cout<<num+i<<endl;
      return 0;
    }
    sum+=v[i];
  }
  cout<<num+v.size()<<endl;
}

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

int main() {
    int h, w; cin >> h >> w;
    vector<string> s(h);
    for (auto &e: s) cin >> e;
    vector<int> k(w, 0);
    int r = 0;
    for (int i = 0; i < h; i++) {
        int l = 0;
        for (int j = 0; j < w; j++) {
            if (s[i][j] == '.') {
                if (k[j] == 0) {
                    int t = i + 1;
                    while (t < h && s[t][j] == '.') t++;
                    k[j] = t - i;
                }
                if (l == 0) {
                    int t = j + 1;
                    while (t < w && s[i][t] == '.') t++;
                    l = t - j;
                }
                r = max(r, k[j] + l);

            } else {
                k[j] = 0;
                l = 0;
            }
        }
    }

    cout << r - 1 << endl;
    return 0;
}

Measured memory_bytes: 4352
import math
import string
import collections
from collections import Counter


def readints():
    return list(map(int, input().split()))


def nCr(n, r):
    return math.factorial(n)//(math.factorial(n-r)*math.factorial(r))


def has_duplicates2(seq):
    seen = []
    for item in seq:
        if not(item in seen):
            seen.append(item)
    return len(seq) != len(seen)


def divisor(n):
    divisor = []
    for i in range(1, n+1):
        if n % i == 0:
            divisor.append(i)
    return divisor


# coordinates
dx = [-1, -1, -1, 0, 0, 1, 1, 1]
dy = [-1, 0, 1, -1, 1, -1, 0, 1]
n = int(input())
tmp = [None]*n
for i in range(n):
    tmp[i] = [None]*2
# print(tmp)
for i in range(n):
    tmp[i][0], tmp[i][1] = map(int, input().split())
# print(tmp)
ans = 0
for i in range(n):
    for j in range(n):
        ans += ((tmp[i][0]-tmp[j][0])**2+(tmp[i][1]-tmp[j][1])**2)**0.5
print(ans/n)


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

int main() {
    int n;
    cin >> n;
    vector<int> x(n), y(n), p(n);
    rep(i,n) {
        cin >> x[i];
        cin >> y[i];
    }
    rep(i,n) p[i] = i ;

    auto distance = [&](int i, int j) {
        double dx = x[i] - x[j];
        double dy = y[i] - y[j];
        return sqrt(dx*dx + dy*dy);
    };

    int ct = 0;
    double tmp = 0;
    do {
        rep(i,n-1) {
            tmp += distance(p[i], p[i+1]);
        }
        ct++;
    } while (next_permutation(p.begin(),p.end()));
    
    double ans = tmp / ct;

    printf("%.10f\n", ans);
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <cmath>
#include <utility>
#include <iostream>
#include <functional>
#include <bitset>
#include <algorithm>
#include <vector>
#include <forward_list>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <tuple>
#include <numeric>
#define rep(i, s, g) for ((i) = (s); (i) < (g); ++(i))
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
const ll MOD = 1e9 + 7;
const ll INF = (1ll << 60);

int main(void)
{
    int n;
    string s;

    cin >> s;

    ll count = 0;

    for (int i = 0; i < s.size(); i++)
    {
        if (s[i] == '0')
        {
            count++;
        }
    }

    cout << min(count, (ll)s.size() - count) * 2 << endl;
}


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

void two(int arr[], int n) 
{ 
    // Current indexes from left and right 
    int l = 0, r = n-1; 
  
    // Count of odd numbers 
    int k = 0; 
  
    while (l < r) 
    { 
        // Find first odd number from left side. 
        while (arr[l]%2 != 0) 
        { 
            l++; 
            k++; 
        } 
  
        // Find first even number from right side. 
        while (arr[r]%2 == 0  && l<r) 
            r--; 
  
        // Swap odd number present on left and even 
        // number right. 
        if (l < r) 
            swap(arr[l], arr[r]); 
    } 
}

int main() {
	int n;
	cin>>n;
	long double sum=0;
	int arr[n];
	for(ll i=0;i<n;i++)
	{
		cin>>arr[i];
	}
	sort(arr,arr+n);
	sum=arr[0];
	for(ll i=1;i<n;i++)
	{
		sum=(long double)(sum+arr[i])/2;
	}
	cout<<sum;
	return 0;
}

Measured memory_bytes: 256
import sys

def make_all_cards():
    mark = ['S', 'H', 'C', 'D']
    cards = []
    
    for i in mark:
        for n in range(1, 14):
            cards.append(i + ' ' + str(n))

    return cards

if __name__ == '__main__':
    all_cards = make_all_cards()
    n = int(sys.stdin.readline().strip())

    for _ in range(n):
        card = sys.stdin.readline().strip()
        all_cards.remove(card)

    for i in all_cards:
        print(i)


Measured memory_bytes: 5596
n, limit = list(map(int, input().split()))
permute = list(map(int, input().split()))
score = list(map(int, input().split()))

visited = [False] * n

ans = -10 ** 16

for i in range(n):
    if visited[i]:
        continue

    score_circle = []
    now = i
    while True:
        visited[now] = True
        score_circle.append(score[now])

        next_ = permute[now] - 1
        if visited[next_]:
            # 円環のできあがり
            break
        now = next_
    
    period = len(score_circle)

    score_circle *= 2
    # 累積和
    cumsum = [0] * (2 * period + 1)
    for j in range(1, 2*period+1):
        cumsum[j] = cumsum[j-1] + score_circle[j-1]
    
    p_sum_max = [-(10**15)] * (period + 1)
    for k in range(period):
        for ll in range(period):
            p_sum_max[ll] = max(p_sum_max[ll], cumsum[k+ll] - cumsum[k])
    
    ans = max([ans] + p_sum_max[1:min(period+1, limit+1)])

    q, resi = divmod(limit, period)

    if q >= 1:
        ans = max(ans, cumsum[period] * (q-1) + max(p_sum_max[1:]))
        ans = max(ans, cumsum[period] * (q) + max(p_sum_max[:resi + 1]))

        # print(p_sum_max[:resi + 1])

print(ans)


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

int gcd(int x, int y);
int main(){
    int a,b,c;
    cin >> a >> b >> c;
    int x=gcd(a,b);
    if(c%x==0)
    puts("YES");
    else
    puts("NO");
}

int gcd(int x, int y){
    int tmp,r;
    if(x<y){
        tmp=x;
        x=y;
        y=tmp;
    }
    r=x%y;
    while(r!=0){
        x=y;
        y=r;
        r=x%y;
    }
    return y;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define dump(x) cout << (x) << endl;
typedef int64_t Int;
Int mod = 1e9+7;

int main() {
  string s;
  cin >> s;
  if (s.size() == 2) {
    dump(s);
  }
  else {
    reverse(s.begin(), s.end());
    dump(s);
  }
  return 0;
}


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

int main()
{
  string s,t;
  int ans = 0;
  cin >> s >> t;
  rep(i,3){
    if(s[i] == t[i]) ans++;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3620
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
int main()
{
    int n;
    cin>>n;
    ll a[n];
    int cnt=0;
    for(int i=0;i<n;i++)
    {cin>>a[i];
      if(i%2==0&&a[i]%2==1) cnt++;
    }
    cout<<cnt<<endl;

    


}

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

int n, m, k;

int main() {
    string ans = "No";
    cin >> n >> m >> k;
    rep(i, n+1) rep(j, m+1) {
        if (k == i * (m - j) + j * (n - i)) ans = "Yes";
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int main()
{
    int n;
    scanf("%d",&n);
    int a[100];
    int i=0;

    while(n>=0)
    {
        a[i]=n%10;
        n=n/10;
        i++;
        if(n==0) break;
    }
    for(int j=0;j<i;j++)
    {
        if(a[j]==9)
        {
            printf("Yes\n");

            return 0;
        }
    }
    printf("No\n");

    return 0;
}


Measured memory_bytes: 1660
#include<iostream>
#include<vector>
#include<bitset>
#include<string>
#include<cmath>
#include<algorithm>
#include<stack>
#include<list>
#include<queue>
#include<map>
using namespace std;

int INF=1e9;
int main(){
    int N,M;
    cin>>N>>M;
    vector<int>a(N),b(N),c(M),d(M);
    for(int i=0;i<N;i++){
        cin>>a[i]>>b[i];
    }
    for(int i=0;i<M;i++){
        cin>>c[i]>>d[i];
    }
    int ANS;
    for(int i=0;i<N;i++){
        int dis,ans=INF;
        for(int j=0;j<M;j++){
            dis=abs(a[i]-c[j])+abs(b[i]-d[j]);
            if(ans>dis){
              ans=dis;
              ANS=j;
            }
        }
        cout<<ANS+1<<endl;
    }
    return 0;
}

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

int main() {
    int n, k;
    cin >> n >> k;
    int a[n + 1];
    for(int i = 0; i < n; i++)
    {
        cin >> a[i];
    }
    int mx = max(0, (n - k));
    long long int s = 0;
    sort(a, a + n);
    for(int i = 0; i < mx; i++){
        s += a[i];
    }
    cout << s << endl;

	return 0;
}


Measured memory_bytes: 1024
#include<iostream>
#include<string>

using namespace std;

int main(){
	int alpha[26];
	string sen;
	char abc[26]={'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
	for(int i=0;i<26;i++) alpha[i]=0;

	while(1){
		getline(cin,sen);
		if(sen.empty()) break;
		for(int i=0;i<sen.size();i++){
			for(int j=0;j<26;j++){
				if(isupper(sen[i])) sen[i]=tolower(sen[i]);
				if(sen[i]==abc[j]) alpha[abc[j]-'a']++;
			}
		}
	}
	for(int i=0;i<26;i++){
		cout<<abc[i]<<" : "<<alpha[i]<<endl;
	}

	return 0;
}

Measured memory_bytes: 3168
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repi(i, s, n) for (int i = (s); i < (n); i++)
#ifdef LOCAL
#define INPUT_FILE                   \
  ifstream in("atcoder-problems/abc139_b.txt"); \
  cin.rdbuf(in.rdbuf());
#else
#define INPUT_FILE
#endif
#define CIN_OPTIMIZE \
  cin.tie(0);        \
  ios::sync_with_stdio(false);
typedef pair<int, int> P;
typedef long long ll;
const int INF = 100100100;
const ll LINF = 1e18+100;
const int MOD = 1e9 + 7;

int main() {
  INPUT_FILE CIN_OPTIMIZE;

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

  int cnt = 1;
  int ans = 0;
  while (cnt < b) {
    cnt--;
    cnt += a;
    ans++;
  }

  cout << ans << endl;
}

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

using namespace std;

typedef pair<int,int> P;
typedef long long ll; 

#define int ll

const ll mod = 1e9 + 7;


main(){
	int n,m;
	cin >> n >> m;

	cout << n*(n-1)/2 + m*(m-1)/2 << endl;

	return 0;
}


Measured memory_bytes: 3600
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <math.h>
#include <vector>
#include <map>
#include <queue>
#include <utility>
#include <algorithm>
#include <string>
using namespace std;
#define MAX_N 100000
vector <int> par(MAX_N + 1);
vector <int> ran(MAX_N + 1, 1);
int root(int x) {
  while (par[x] != x) {
	  x = par[x] = par[par[x]];
	}
  return x;
}

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

bool isSame(int x, int y) {
  return root(x) == root(y);
}

int main() {
  int n, m;
  cin >> n >> m;
  for (int i = 0; i <= n; i++) {
	  par[i] = i;
	}
  for (int i = 0; i < m; i++) {
	  int x, y, z;
	  cin >> x >> y >> z;
	  unite(x, y);
	}
  int ans = 0;
  for (int i = 1; i <= n; i++) {
	  if (i == root(i)) {
		  ans++;
		}
	}
  cout << ans << endl;
  return 0;
}


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

template<class Type>
Type modpow(Type a, Type n, Type mod)
{
	Type res = 1;
	while (0 < n) {
		if (n & 1) {
			res = res * a % mod;
		}
		a = a * a % mod;
		n >>= 1;
	}
	return res;
}

template<class Type>
Type gcd(Type x, Type y)
{
	Type r;
	if (x < y) swap(x, y);

	while (0 < y) {
		r = x % y;
		x = y;
		y = r;
	}
	return x;
}

template<class Type>
Type lcm(Type x, Type y)
{
	return x * y / gcd(x, y);
}

template<class Type>
bool is_prime(Type x)
{
	if (x == 2) return true;
	if (x < 2 || x % 2 == 0) return false;

	for (Type i = 3; i <= sqrt(x); i += 2) {
		if (x % i == 0) return false;
	}
	return true;
}

template<class Type>
vector<bool> eratos(Type n)
{
	vector<bool> isPrime(n + 1, true);
	isPrime[0] = isPrime[1] = false;
	for (Type i = 2; i <= n; i++) {
		if (isPrime[i]) {
			Type j = i + i;
			while (j <= n) {
				isPrime[j] = false;
				j = j + i;
			}
		}
	}
	return isPrime;
}

bool binary_search_judge(vector<int> a, int index, int key)
{
	if (key <= a[index]) return true;
	else return false;
}

int binary_search(vector<int> a, int key)
{
	int ng = -1;
	int ok = a.size();
	while (1 < abs(ng - ok)) {
		int mid = (ng + ok) / 2;
		if (binary_search_judge(a, mid, key)) ok = mid;
		else ng = mid;
	}
	return a[ok] == key;
}

int main()
{
	string s;
	cin >> s;
	int ans = 0;
	for (int i = 0; i < s.size(); i++) {
		if (s[i] == '1') ans++;
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <utility>

using namespace std;
using pii = pair<int,int>;
int n,used[700][700];
pii color[700][700];
vector<pii> v,w;
int dx[4] = {1,1,-1,-1};
int dy[4] = {1,-1,-1,1};

//addを使うとTLE
/*void add(int i, int j, int x, int y){
	if(x>=0 && x<2*n && y>=0 && y<2*n){
		G[i][j].push_back({x,y});
		G[x][y].push_back({i,j});
	}
}*/

void dfs1(int s,int t, int c,int x){
    used[s][t] = 1;
    if(x==1) color[s][t].first = c;
    if(x==2) color[s][t].second = c;
	if(x==1){
    for(auto&& p :v){
    	for(int i=0;i<4;i++){
    		int nx = s + dx[i]*p.first, ny = t + dy[i]*p.second;
        	if(nx<0 || nx>=2*n || ny<0 || ny>=2*n || used[nx][ny]!=-1) continue;
        	dfs1(nx,ny,3-c,x);
    	}
    }
	}
	if(x==2){
		for(auto&& p :w){
    	for(int i=0;i<4;i++){
    		int nx = s + dx[i]*p.first, ny = t + dy[i]*p.second;
        	if(nx<0 || nx>=2*n || ny<0 || ny>=2*n || used[nx][ny]!=-1) continue;
        	dfs1(nx,ny,3-c,x);
    	}
    }
	}
}

void dfs2(int d,int x){
    //vector<vector<vector<pii>>> G(2 * n, vector<vector<pii>>(2 * n));
	if(x==1){
    for(int i = 0;i*i<=d;i++){
        int k = d - i*i;
        for(int j = 0;j*j<=k;j++){
            if(j*j==k){
                v.push_back({i,j});
                if(i!=j) v.push_back({j,i});
            }
        }
    }
	}
	if(x==2){
		for(int i = 0;i*i<=d;i++){
        int k = d - i*i;
        for(int j = 0;j*j<=k;j++){
            if(j*j==k){
                w.push_back({i,j});
                if(i!=j) w.push_back({j,i});
            }
        }
    }
	}
    /*for(int i=0;i<2*n;i++){
        for(int j=0;j<2*n;j++){
            for(int k = 0;k<v.size();k++){
                int y = i+v[k].first, z = j+v[k].second; add(i,j,y,z,G);
                y = i-v[k].first; add(i,j,y,z,G);
                z = j-v[k].second; add(i,j,y,z,G);
                y = i+v[k].first; add(i,j,y,z,G);
            }
        }
    }*/
    for(int i=0;i<2*n;i++){
        for(int j=0;j<2*n;j++){
            used[i][j] = -1;
        }
    }
    for(int i=0;i<2*n;i++){
        for(int j=0;j<2*n;j++){
            if(used[i][j]==-1) dfs1(i,j,1,x);
        }
    }
	v.clear();
}

int main(){
	ios_base::sync_with_stdio(false); cin.tie(0);
    int i,j,d,e;
    cin >> n >> d >> e;
    dfs2(d,1);
    dfs2(e,2);
    vector<pii> sum[4];
    for(i=0;i<2*n;i++){
        for(j=0;j<2*n;j++){
            int x = color[i][j].first,y = color[i][j].second;
        	int z =  max(y*y-x,x-y*y);
        	sum[z].push_back({i,j});
        }
    }
	for(i=0;i<4;i++){
		if(sum[i].size()>=n*n){
			for(j=0;j<n*n;j++){
				cout << sum[i][j].first << " " << sum[i][j].second << endl;
			}
			return 0;
		}
	}
}


Measured memory_bytes: 31860
<?php  
fscanf(STDIN,"%d%d",$x,$y);
//$x = explode(" ",trim(fgets(STDIN)));
$min = 2*$x;
$max = 4*$x;

if($y%2==0 && $min<=$y && $max>=$y){
  echo "Yes";
}else{
  echo "No";
}

Measured memory_bytes: 16144
''' This is AOJ Practice. '''


class Dice:
    ''' Dice
    6??¢????????????????????¨??????????????§??????
    NWSE?????????????????????????????¨????????\?????????
    ?????????Top??????????????????????????¢??????????????????????????¨????????\?????????
    '''

    def __init__(self):
        ''' ????????????????????? '''
        self.axis1 = list()
        self.axis2 = list()
        self.init()

    def control_n(self):
        ''' ????????¢?????? '''
        bottom_value = self.axis2[3]
        top_value = self.axis2[1]
        self.axis2 = [bottom_value, self.axis2[0], top_value, self.axis2[2], bottom_value]
        self.axis1 = [bottom_value, self.axis1[1], top_value, self.axis1[3], bottom_value]

    def control_w(self):
        ''' ????????¢?????? '''
        bottom_value = self.axis1[1]
        top_value = self.axis1[3]
        self.axis2 = [bottom_value, self.axis2[1], top_value, self.axis2[3], bottom_value]
        self.axis1 = [bottom_value, self.axis1[2], top_value, self.axis1[4], bottom_value]

    def control_s(self):
        ''' ????????¢?????? '''
        bottom_value = self.axis2[1]
        top_value = self.axis2[3]
        self.axis2 = [bottom_value, self.axis2[2], top_value, self.axis2[4], bottom_value]
        self.axis1 = [bottom_value, self.axis1[1], top_value, self.axis1[3], bottom_value]

    def control_e(self):
        ''' ????????¢?????? '''
        bottom_value = self.axis1[3]
        top_value = self.axis1[1]
        self.axis2 = [bottom_value, self.axis2[1], top_value, self.axis2[3], bottom_value]
        self.axis1 = [bottom_value, self.axis1[0], top_value, self.axis1[2], bottom_value]

    def top(self):
        ''' ????????¢??????????????? '''
        return self.axis1[2]

    def control(self, word):
        ''' ?????????????????????
        Args
            word    ????????????
                N   ????????¢??????
                W   ????????¢??????
                S   ????????¢??????
                E   ????????¢??????
        '''
        if word == 'N':
            self.control_n()
        elif word == 'W':
            self.control_w()
        elif word == 'S':
            self.control_s()
        elif word == 'E':
            self.control_e()
        else:
            Exception()

    def show(self):
        ''' ?????¨?????±????¨???????????????? '''
        print(self.axis1)
        print(self.axis2)

    def init(self):
        ''' ??????????????? '''
        self.axis1 = [6, 4, 1, 3, 6]
        self.axis2 = [6, 2, 1, 5, 6]

if __name__ == '__main__':
    input_value = input()
    control_value = input()
    dice = Dice()

    for word in list(control_value):
        dice.control(word)

    print(input_value.split(" ")[dice.top()-1])

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

int main(){
  int n,k;
  int x;
  int a[N]={0};
  int cnt=0;
  cin >> n >> k;
  rep(i,n){
    scanf("%d",&x);
    if(a[x]==0)cnt++;
    a[x]++;
  }
  sort(a,a+N);
  if(cnt<=k){
    cout << 0 << endl;
    return 0;
  }
  int sum=0;
  for(int i=N-cnt;i<N-k;i++)sum+=a[i];
  cout << sum << endl;

  return 0;
}


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


int main()
{
	int A, B, C;
	cin >> A >> B >> C;
	if (A + B == C || B + C == A || C + A == B) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
    return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
  public static void main(String[] args) {
    @SuppressWarnings("resource")
    Scanner sc = new Scanner(System.in);
    int K = sc.nextInt();
    int X = sc.nextInt();// X +- (K -1)

    StringBuilder sb = new StringBuilder();
    for (int i = X - (K - 1); i <= X + (K - 1); i++ ) {
      sb.append(i).append(' ');
    }
    System.out.println(sb.toString().trim());
  }
}


Measured memory_bytes: 23124
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
#pragma comment(linker, "/stack:200000000")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
typedef string str;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector <pii> vpii;
typedef vector <pll> vpll;
typedef map <str,int> mapsi;
typedef map <str,int> :: iterator mapsitr;
typedef map <int , int> mint;
typedef map <ll , ll> mll;
typedef set <int> si;
typedef set <ll> sll;
typedef si :: iterator sitr;
typedef si :: reverse_iterator rsitr;
typedef sll :: iterator sltr;
typedef sll :: reverse_iterator rsltr;
#define mset multiset

typedef mset <int> msi;
typedef mset <ll> msll;
typedef msi :: iterator msitr;
typedef msi :: reverse_iterator msritr;
typedef msll :: iterator msltr;
typedef msll :: reverse_iterator mslritr;

#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
#define mp make_pair
#define pb push_back
#define pob pop_back
#define pf push_front
#define pof pop_front
#define fi first
#define se second
#define fs first.second
#define ss second.second
#define ff first.first
#define sf second.first
#define newl '\n'
#define fbo find_by_order
#define ook order_of_key

char to_upper (char x){
    if( 97 <= int(x) && int(x) <= 122)return char(x-32);
    else if( 65 <= int(x) && int(x) <= 90)return x;
}
char to_lower (char x){
    if( 97 <= int(x) && int(x) <= 122)return x;
    else if( 65 <= int(x) && int(x) <= 90)return char(x+32);
}
int numerize (char x){
    if(48 <= int(x) && int(x) <= 57)return int(x-'0');
    else if( 97 <= int(x) && int(x) <= 122)return int(x-96);
    else if( 65 <= int(x) && int(x) <= 90)return int(x-64);
}
bool isect (int l1, int r1, int l2, int r2){
    pii p1,p2;
    p1 = mp(l1,r1); p2 = mp(l2,r2);
    if(p1>p2)swap(p1,p2);
    if(p2.fi <= p1.se)return true;
    else return false;
}
ll quickpow (ll num1, ll num2, ll MOD){
    if(num2==0)return 1;
    else if(num2==1)return num1;
    else{
        ll temp = quickpow (num1,num2/2,MOD); ll res = ((temp%MOD) * (temp%MOD))%MOD;
        if(num2%2==1) res = ((res%MOD)*(num1%MOD))%MOD; return res;
    }
}
ll invmod (ll num, ll MOD){return quickpow (num,MOD-2,MOD);}
ll gcd (ll num1, ll num2){
    if(num1 < num2) swap(num1,num2); ll num3 = num1 % num2 ;
    while(num3 > 0){ num1 = num2; num2 = num3; num3 = num1 % num2;}
    return num2;
}
ll lcm (ll num1 , ll num2){return (ll) (num1/__gcd(num1,num2))*num2;}
// end of Template
str o,e;
int main(){

//    freopen("input.txt", "r", stdin);
//    freopen("output.txt", "w", stdout);

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);

    cin>>o>>e;
    str res = "";
    for(int i=0;i<e.size();i++){
        res += o[i];
        res += e[i];
    }
    if(o.size() > e.size()) res+=o[o.size()-1];
    cout<<res<<newl;
}


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

int main() {
    string s;
    cin >> s;
    sort(s.begin(), s.end());
    if (s[0] == s[1] && s[1] != s[2] && s[2] == s[3]) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
while True:
    x,op,y = [x for x in input().split()]
    a = int(x)
    b = int(y)
    if op == '+':
        print(a+b)
    elif op == '-':
        print(a-b)
    elif op == '*':
        print(a*b)
    elif op == '/':
        print(int(a/b))
    elif op == '?':
        break
    else:
        pass



Measured memory_bytes: 5604
#include <iostream>
#include <vector>
#include <algorithm>
#include <cstring>
#include <map>
#include <set>
#include <unordered_map>
#include <queue>
#include <stack>
#include <cmath>
#include <functional>
#include <deque>
#include <bitset>
#include <climits>
#include <cstdio>
#include <list>
#include <iomanip>
using namespace std;

#define ll long long int
#define mp make_pair
#define pb push_back
#define fi first
#define si second
#define fastIO ios_base::sync_with_stdio(false); cin.tie(NULL);
#define F(a,n) for(int i=0;i<n;i++){cin>>a[i];}
#define F1(a,n) for(int i=1;i<=n;i++){cin>>a[i];}
#define P(a,n) for(int i=0;i<n;i++){cout<<a[i]<<' ';}cout<<endl;
#define P1(a,n) for(int i=1;i<=n;i++){cout<<a[i]<<' ';}cout<<endl;
#define NF(a,n,m) for(int i=0;i<n;i++){for(int j=0;j<m;j++){cin>>a[i][j];}}
#define NF1(a,n,m) for(int i=1;i<=n;i++){for(int j=1;j<=m;j++){cin>>a[i][j];}}
#define PNF(a,n,m) for(int i=0;i<n;i++){for(int j=0;j<m;j++){cout<<a[i][j]<<' ';}cout<<endl;}cout<<endl;
#define PNF1(a,n,m) for(int i=1;i<=n;i++){for(int j=1;j<=m;j++){cout<<a[i][j]<<' ';}cout<<endl;}cout<<endl;
#define AS 200001
#define mod 1000000007
ll x[110000];
ll dp[110000];
ll ABS(double a) {return max(a, -a);}
int main() {
	fastIO
	int n;
	cin >> n;
	F(x, n);
	memset(dp, mod, sizeof dp);
	dp[0] = 0;
	for (int i = 0; i < n; i++) {
		if (i + 1 < n) dp[i + 1] = min(dp[i + 1], dp[i] + ABS(x[i] - x[i + 1]));
		if (i + 2 < n) dp[i + 2] = min(dp[i + 2], dp[i] + ABS(x[i] - x[i + 2]));
	}
	cout << dp[n - 1] << endl;
}

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

ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}

int main(){
    int n;
    ll m;
    cin >> n >> m;

    vector<ll> s;
    ll t = m / n;

    for(ll i = 1; i * i <= m; i++){
        if(m % i == 0){
            if(t >= i){
                s.push_back(i);
            }
            
            if(t >= (m / i)){
                s.push_back(m / i);
            }
        }
    }

    sort(s.begin(), s.end());

    cout << s[s.size() - 1] << endl;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pb push_back
#define int long long
#define mp make_pair
#define inf 998244353
#define LINF 1000000000000000007LL
#define ll long long
using namespace std;
int field[314][314];
int rsum[650][650], lsum[650][650];
vector< pair<int,int> > rup[650],lup[650];
signed main(){
	int h,w;
	cin>>h>>w;
	for(int i=0;i<h;i++){
		string s;
		cin>>s;
		for(int j=0;j<w;j++){
			if( s[j] == '#' ) field[i+1][j+1] = 1;
		}
	}
	for(int i=0;i<=h+1;i++){
		for(int j=0;j<=w+1;j++){
			if( field[i][j] == 1 ){
				rup[i+j].pb( mp(i,j) );
				lup[j-i+h+1].pb( mp(i,j) );
				rsum[i+j][i] = rsum[i+j][i-1]+1;
				lsum[j-i+h+1][i] = lsum[j-i+h+1][i-1]+1;
			}
			else{
				rsum[i+j][i] = rsum[i+j][i-1];
				lsum[j-i+h+1][i] = lsum[j-i+h+1][i-1];
			}
		}
	}
	for(int i=2;i<=600;i++){
		for(int j=1;j<=h+w;j++){
			if( rsum[i][j-1] > 0 && rsum[i][j] == 0 ) rsum[i][j] = rsum[i][j-1];
			if( lsum[i][j-1] > 0 && lsum[i][j] == 0 ) lsum[i][j] = lsum[i][j-1];
		}
	}
	int ans = 0;
	for(int i=2;i<=600;i++){
		for(int j=0;j<rup[i].size();j++){
			for(int k=j+1;k<rup[i].size();k++){
				pair<int,int> p1 = rup[i][j], p2 = rup[i][k];
				int ax = p1.first, ay = p1.second, bx = p2.first, by = p2.second;
				int mdis = abs(ax-bx)+abs(ay-by);
				if( i - mdis >= 2 ){
					ans += max(0LL ,rsum[ i-mdis ][ max( bx - mdis/2 - 1 , 0LL) ] - rsum[ i-mdis ][ max(ax - mdis/2 ,0LL)]);
					//if(rsum[ i-mdis ][ bx - mdis/2 ] - rsum[ i-mdis ][ ax - mdis/2 - 1])cout<<ax<<" "<<ay<<" "<<bx<<" "<<by<<endl;
				}
				if( i + mdis <= h+w ){
					ans += max(0LL, rsum[ i+mdis][min( bx + mdis/2 - 1, h+w) ] - rsum[ i+mdis ][min( ax + mdis/2, h+w)]);
					//if(rsum[ i + mdis][ bx + mdis/2] - rsum[ i+mdis ][ ax + mdis/2 - 1])cout<<ax<<" "<<ay<<" "<<bx<<" "<<by<<endl;
				}
			}
		}
	}
	int ans2 = 0;
	for(int i=2;i<=600;i++){
		for(int j=0;j<lup[i].size();j++){
			for(int k=j+1;k<lup[i].size();k++){
				pair<int,int> p1 = lup[i][j], p2 = lup[i][k];
				int ax = p1.first, ay = p1.second, bx = p2.first, by = p2.second;
				int mdis = abs(ax-bx)+abs(ay-by);
				//cout<<i<<" "<<mdis<<endl;
				if( i - mdis >= 2 ){
					ans2 += lsum[ i-mdis ][min( bx + mdis/2 , h+w)] - lsum[ i-mdis ][ min(ax + mdis/2 - 1 ,h+w)];
					//cout<<i-mdis<<" "<<bx + mdis/2<<" "<<ax + mdis/2<<endl;
				}
				if( i + mdis <= h+w ){
					ans2 += lsum[ i + mdis][ max( bx - mdis/2 , 0LL) ] - lsum[ i+mdis ][max( ax - mdis/2 - 1 , 0LL)];
					//cout<<i+mdis<<" "<<bx - mdis/2<<" "<<ax - mdis/2<<endl;
				}
			}
		}
	}
	cout<< ans + ans2 <<endl;
	return 0;
}

Measured memory_bytes: 11520
#include<bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")
#define rgt register
#define open(s) freopen( s".in", "r", stdin ), freopen( s".out", "w", stdout )
#define fp( i, b, e ) for ( rgt int i(b), i##end(e); i <= i##end; ++i )
#define fd( i, b, e ) for ( rgt int i(b), i##end(e); i >= i##end; --i )
template<class T> inline bool cmin( T &x, T y ){ return x > y ? x = y, 1 : 0; }
template<class T> inline bool cmax( T &x, T y ){ return x < y ? x = y, 1 : 0; }
#define getchar() ( p1 == p2 && ( p1 = bf, p2 = bf + fread( bf, 1, 1 << 21, stdin ), p1 == p2 ) ? EOF : *p1++ )
char bf[1 << 21], *p1, *p2;
template<class T> inline void read( T &x ){
	x = 0; char t(getchar()), flg(0);
	while( t < 48 || t > 57 ) flg = t == '-', t = getchar();
	while( t > 47 && t < 58 ) x = x * 10 + ( t & 15 ), t = getchar();
	flg ? x = -x : x;
}

const int MAXN = 1e5 + 5;
int N, M;
int a[MAXN << 1];

bool check( int x ){
	fp( i, 0, N - 2 ){
		if ( ( a[N - i] >= x && a[N - i - 1] >= x ) || ( a[N + i] >= x && a[N + i + 1] >= x ) ) return 1;
		if ( ( a[N - i] < x && a[N - i - 1] < x ) || ( a[N + i] < x && a[N + i + 1] < x ) ) return 0;
	} return a[1] >= x;
}

int main(){
//	open("soul"); fprintf(stderr, "Venus AK IOI.\n");
	read(N); fp( i, 1, M = N * 2 - 1 ) read(a[i]);
	int mid, l(1), r(2 * N - 1), ans(-1);
	while( l <= r ) check(mid = (l + r) >> 1) ? l = mid + 1, ans = mid : r = mid - 1;
	printf( "%d\n", ans );
	return 0;
}

Measured memory_bytes: 2304