akhauriyash/Code-Regression huggingface dataset:
#ifndef LOCAL
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimization ("unroll-loops")
#endif
#include "bits/stdc++.h"
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
#include <ext/pb_ds/detail/standard_policies.hpp>
using namespace std;
using namespace __gnu_pbds;
#define sim template < class c
#define int long long
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << '\n'; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);
typedef tree< pair<int,int>, null_type, less<pair<int,int> >, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
typedef long long ll;
const ll MOD = 1e9 + 7 ;
const ll N = 2e5 + 10 ;
const ll INF = 1e18 + 10 ;
signed main(){
    fastio
    int d , t , s ;
    cin >> d >> t >> s ;
    if ( s * t >= d ) {
        cout << "Yes" << endl;
    }
    else cout << "No" << endl;
    return 0; 
}

Measured memory_bytes: 3612
s = gets.chomp

h = Hash.new {[-1, 0]}
s.each_char.with_index do |c, i|
    h[c] = [i, [h[c][1], i - h[c][0] - 1].max]
end

puts h.values.map{|x, y| [y, s.size - x - 1].max}.min

Measured memory_bytes: 3836
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pll = pair<ll, ll>;
using vl = vector<ll>;

/* short */
#define pb push_back
#define mp make_pair
#define Fi first
#define Se second
#define ALL(v) begin(v), end(v)
#define RALL(v) rbegin(v), rend(v)

/* REPmacro */
#define FOR(i, a, b) for(int i = (a); i < (b); i++)
#define FORR(i, a, b) for(int i = (a); i >= (b); i--)
#define REP(i, n) for(int i = 0; i < (n); i++)
#define FOREACH(x, a) for(auto x : a)

/* exchange */
#define CHMIN(a, b) (a) = min((ll)(a), (ll)(b))
#define CHMAX(a, b) (a) = max((ll)(a), (ll)(b))

/* function */
#define IN(x) cin >> x
#define DEBUG(x) cerr << (x) << " "
#define LN() cerr << "\n"
#define PRINT(x) cout << (x) << endl
#define BR cout << endl

/* const */
const int ARRAY = 100005;
const int INF = 1001001001; // 10^9
const ll LINF = 1001001001001001001; // 10^18
const int MOD = 1e9 + 7;

ll N = 0;
ll M = 0;
ll t;
ll ret = 0;
ll A = 0, B = 0, C = 0;
string s;


void input() {
  IN(N);
  IN(M);
}

void solve() {
  ret = N * (N-1) / 2 + M * (M-1) / 2;
  PRINT(ret);
}

int main(void){
  input();
  solve();
}


Measured memory_bytes: 256
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Tue Feb 26 17:52:43 2019

@author: nakamuratakayuki
"""

N, K = tuple(map(int,input().split()))
S = input()

S2 = list(S)
S2[K-1] = S2[K-1].lower()
S = ''.join(S2)
print(S)

Measured memory_bytes: 2940
H, W = map(int, input().split())
s = [list(input()) for i in range(H)]

fail = 0

for i in range(H):
  for j in range(W):
    if i == 0:
      if j == 0:
        if s[i][j] == '.':
          pass
        elif s[i][min(W-1,j+1)] == '#' or s[min(H-1,i+1)][j] == '#':
          pass
        else:
          fail += 1
      elif j == W - 1:
        if s[i][j] == '.':
          pass
        elif s[i][max(0,j-1)] == '#' or s[min(H-1,i+1)][j] == '#':
          pass
        else:
          fail += 1
      else:
        if s[i][j] == '.':
          pass
        elif s[i][j-1] == '#' or s[i][j+1] == '#' or s[min(H-1,i+1)][j] == '#':
          pass
        else:
          fail += 1
    elif i == H - 1:
      if j == 0:
        if s[i][j] == '.':
          pass
        elif s[i][min(W-1,j+1)] == '#' or s[max(0,i-1)][j] == '#':
          pass
        else:
          fail += 1
      elif j == W - 1:
        if s[i][j] == '.':
          pass
        elif s[i][max(0,j-1)] == '#' or s[max(0,i-1)][j] == '#':
          pass
        else:
          fail += 1
      else:
        if s[i][j] == '.':
          pass
        elif s[i][j-1] == '#' or s[i][j+1] == '#' or s[max(0,i-1)][j] == '#':
          pass
        else:
          fail += 1
    else:
      if j == 0:
        if s[i][j] == '.':
          pass
        elif s[i-1][j] == '#' or s[i+1][j] == '#' or s[i][min(H-1,j+1)] == '#':
          pass
        else:
          fail += 1
      elif j == W - 1:
        if s[i][j] == '.':
          pass
        elif s[i-1][j] == '#' or s[i+1][j] == '#' or s[i][max(0,j-1)] == '#':
          pass
        else:
          fail += 1
      else:
        if s[i][j] == '.':
          pass
        elif s[i-1][j] == '#' or s[i+1][j] == '#' or s[i][j-1] == '#' or s[i][j+1] == '#':
          pass
        else:
          fail += 1
          
isAllWhite = False
count = 0
for i in range(H):
  for j in range(W):
    if s[i][j] == '.':
      count += 1
else:
  if count == H * W:
    isAllWhite = True
    
  if isAllWhite or fail == 0:
    print('Yes')
  else:
    print('No')

Measured memory_bytes: 9204
import java.util.*;
import java.lang.*;
import java.io.*;

public class Main{
    public static void main(String[] args) throws IOException{
        FastReader sc = new FastReader();
        String n = sc.nextLine();
        System.out.println(Character.isUpperCase(n.charAt(0)) ? "A" : "a");
    }
}

class FastReader{ 
    BufferedReader br; 
    StringTokenizer st; 
    public FastReader() { 
        br = new BufferedReader(new InputStreamReader(System.in)); 
    } 
    String next(){ 
        while (st == null || !st.hasMoreElements()) { 
            try{ 
                st = new StringTokenizer(br.readLine()); 
            }catch (IOException  e){ 
                e.printStackTrace(); 
            } 
        } 
        return st.nextToken(); 
    } 
    int nextInt(){ 
        return Integer.parseInt(next()); 
    } 
    long nextLong(){ 
        return Long.parseLong(next()); 
    } 
    double nextDouble(){ 
        return Double.parseDouble(next()); 
    } 
    String nextLine(){ 
        String str = ""; 
        try{ 
            str = br.readLine(); 
        } 
        catch (IOException e){ 
            e.printStackTrace(); 
        } 
        return str; 
    } 
}



Measured memory_bytes: 32712
from collections import defaultdict, Counter
from heapq import heapify, heappop, heappush
from sys import stdin

def main():
    n = int(input())
    _t = 0
    _x = 0
    _y = 0
    reachable = True
    for _ in range(n):
        t, x, y = map(int, input().split())
        if reachable:
            diff = t-_t
            distance = abs(x-_x)+abs(y-_y)
            if diff >= distance and (distance-diff)%2==0:
                continue
            else:
                reachable = False
    print("Yes" if reachable else "No")

input = lambda: stdin.readline().rstrip()
main()

Measured memory_bytes: 3316
A, B, C = map(int, input().split())
ans = 0
while True:
    if A % 2 == 1 or B % 2 == 1 or C % 2 == 1:
        break
    if A == B and B == C and C == A:
        ans = -1
        break
    A, B, C = B // 2 + C // 2, A // 2 + C // 2, A // 2 + B // 2
    ans += 1
print(ans)

Measured memory_bytes: 38256
#include<bits/stdc++.h>
using namespace std;
#define io ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
int main()
{
io
int n;
cin >> n;
int v = n % 10;
if(v == 3)cout<<"bon";
else if(v == 0 or v == 6 or v == 1 or v == 8)cout<<"pon";
else cout<<"hon";
}


Measured memory_bytes: 3640
import java.util.*;

class Main{
  public static void main(String[] args){
    Scanner scan=new Scanner(System.in);
    int a=scan.nextInt();
    int b=scan.nextInt();
    int c=scan.nextInt();
    if((a==b && a!=c) || (a==c && a!=b) || (b==c && b!=a)){
      System.out.println("Yes");
    }else{
      System.out.println("No");
    }
  }
}

Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
string A, B, C; 
bool checkAB(int a, int b){
	if(a < 0 || a >= A.size() || b < 0 || b >= B.size()) return true; 
	if(A.at(a) == '?' || B.at(b) == '?') return true; 
	if(A.at(a) == B.at(b)) return true; 
 	return false; 
}
bool checkBC(int b, int c){
	if(b < 0 || b >= B.size() || c < 0 || c >= C.size()) return true; 
	if(B.at(b) == '?' || C.at(c) == '?') return true; 
	if(B.at(b) == C.at(c)) return true; 
 	return false; 
}
bool checkCA(int c, int a){
	if(c < 0 || c >= C.size() || a < 0 || a >= A.size()) return true; 
	if(C.at(c) == '?' || A.at(a) == '?') return true; 
	if(C.at(c) == A.at(a)) return true; 
 	return false; 
}
int main(){
    cin >> A >> B >> C; 
	bool AB[20010] = {}; // Aを0始点にしたときのBの始点の位置+10000
	bool BC[20010] = {}; // Bを0始点にしたときのCの始点の位置+10000
	bool CA[20010] = {}; // Cを0始点にしたときのAの始点の位置+10000
	fill(AB, AB+20010, true); 
	fill(BC, BC+20010, true); 
	fill(CA, CA+20010, true); 	
	for(int i = -4100; i <= 4100; i++){
		for(int j = 0; j < A.size(); j++){
			AB[i+10000] &= checkAB(j, -i+j); 
			if(!AB[i+10000]) break; 
		}
	}
	for(int i = -4100; i <= 4100; i++){
		for(int j = 0; j < B.size(); j++){
			BC[i+10000] &= checkBC(j, -i+j); 
			if(!BC[i+10000]) break; 
		}
	}
	for(int i = -4100; i <= 4100; i++){
		for(int j = 0; j < C.size(); j++){
			CA[i+10000] &= checkCA(j, -i+j); 
			if(!CA[i+10000]) break; 
		}
	}
	int ans = 114514; 
	for(int b = -4010; b <= 4010; b++){
		if(!AB[b+10000]) continue; 
		for(int c = -4010; c <= 4010; c++){
			if(!CA[-c+10000]) continue; 
			if(!BC[c-b+10000]) continue; 
			int l = 0; int r = (int) A.size() - 1; 
			l = min(l, b); l = min(l, c); 
			r = max(r, b + (int) B.size() - 1); r = max(r, c + (int) C.size() - 1); 
			ans = min(ans, r - l + 1);
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
/*
 *
 *    I am o0o0oo00.
 *
 */
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define ll          long long
#define p7          1000000007
#define p9          998244353
#define pb          push_back
#define ff          first
#define ss          second
#define vll         vector<ll>
#define pll         pair<ll,ll>
#define vpll        vector<pll>
#define mll         map<ll,ll>
#define test        ll T;cin>>T;while(T--)
#define ad(a,n)     vll a;a.resize(n);for(ll i=0;i<n;i++)cin>>a[i];
#define as(a,n)     for(ll i=0;i<n;i++){cout<<a[i]<<" ";}cout<<endl;
#define all(x)      x.begin(),x.end()

typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> pbds;

ll powm(ll x, ll y, ll m = p7) {
    x = x % m; ll res = 1; while (y)
    {if (y & 1)res = res * x; res %= m; y = y >> 1; x = x * x; x %= m;} return res;
}
ll modi(ll a, ll m = p7) {return powm(a, m - 2, m);}
void yesno(bool f) {f ? cout << "YES" << endl : cout << "NO" << endl;}


void ss99()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
}

struct fenwick
{
    vll fn;
    ll n;
    fenwick() {}
    fenwick(ll n)
    {
        init(n);
    }
    void init(ll _n)
    {
        n = _n + 10;
        fn.clear(); fn.resize(n, 0);
    }
    void update(ll x, ll val)
    {
        x++;
        while (x < n)
        {
            fn[x] = max(fn[x], val);
            x += (x & (-x));
        }
    }
    ll query(ll x)
    {
        ll ans = 0;
        while (x)
        {
            ans = max(ans, fn[x]);
            x -= (x & (-x));
        }
        return ans;
    }
    ll query(ll l, ll r)
    {
        return query(r) - query(l - 1);
    }
};


int32_t main()
{
    ss99();
//    test
    {
        ll n; cin >> n;
        ad(h, n);
        ad(b, n);
        ll dp[n + 1] = {0};
        fenwick bit(n);
        ll ans = 0;
        for (ll i = 0; i < n; i++)
        {
            ll val = bit.query(h[i]);
            dp[i] = b[i] + val;
            bit.update(h[i], dp[i]);
            ans = max(ans, dp[i]);
        }
        cout << ans << endl;
    }
    return 0;
}

Measured memory_bytes: 6528
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef std::vector<vector<int> > vvi;
typedef pair<int, int> pi;
typedef pair<ll, ll> pll;
typedef vector<ll> vll;
typedef vector<pi> vpi;
typedef vector<pll> vpll;
typedef vector<vll> vvll;
typedef vector<vi> vvi;
#define debugone(x) cerr << #x << " " << x << "\n"; cerr.flush();
#define debugtwo(x) cerr << #x << "-------------" << "\n";for(auto &it: x) cerr << it << " ";cerr << "\n"; cerr.flush();
#define debugthree(x_, i_, j_) cerr << #x_ << "------------" << "\n";cerr << "from " << i_ << " to " << j_ << "\n";for(ll k_=i_; k_<=j_; k_++) cerr << x_[k_] << " ";cerr << "\n"; cerr.flush();
#define trace1(x)                cerr << #x << ": " << x << endl;
#define trace2(x, y)             cerr << #x << ": " << x << " | " << #y << ": " << y << endl;
#define trace3(x, y, z)          cerr << #x << ": " << x << " | " << #y << ": " << y << " | " << #z << ": " << z << endl;
#define trace4(a, b, c, d)       cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << endl;
#define trace5(a, b, c, d, e)    cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << " | " << #e << ": " << e << endl;
#define trace6(a, b, c, d, e, f) cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << " | " << #e << ": " << e << " | " << #f << ": " << f << endl;

const ll MOD = 1e9 + 7;
const int INF = 2e9;
const int MAX_LOG = 21;
const int MAX_N = 5005;

int dp[MAX_N][MAX_N];
int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);cout.tie(0);

	int a, b, c;
	cin >> a >> b >> c;
	if(a + b + c >= 22){
		cout << "bust";
	}
	else{
		cout << "win";
	}
	cout << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <iomanip>
#include <queue>
#include <deque>
#include <map>
#include <unordered_map>
#define rep(i,n) for(int i=0;i<n;i++)
#define repn(i,n) for(int i=1;i<=n;i++)
using namespace std;
typedef long long ll;

ll X;

int main(){
    cin>>X;

    ll m=100;
    ll ans=0;
    while(m<X){
        m*=1.01;
        ans++;
    }

    cout<<ans<<endl;
}

Measured memory_bytes: 3624
import java.util.*;

public class Main {
    public static void main(String[] args) {
      Scanner s = new Scanner(System.in);
        String X = s.next();
        final int N = s.nextInt();
        List<String> pList = new ArrayList<String>();

        for (int i = 0 ; i < N ; i++) {
            pList.add(s.next());
        }

        if (pList.size() == 0 || !pList.contains(X)) {
            System.out.println(X);
            return;
        }

        int idx = 1;
        while (true) {
            String minus = String.valueOf(Integer.parseInt(X) - idx);
            String plus = String.valueOf(Integer.parseInt(X) + idx);
          
          if (pList.contains(minus) && pList.contains(plus)) {
                idx++;
                continue;
            }

            if (!pList.contains(minus) && !pList.contains(plus)) {
                System.out.println(minus);
                break;
            } else if (!pList.contains(minus)) {
                System.out.println(minus);
                break;
            } else {
                System.out.println(plus);
                break;
            }
        }
    }
}

Measured memory_bytes: 27260
N,X=map(int,input().split())
y=list(map(int,input().split()))
	
bet=[] # length from X to y[i]
for i in range(N):
	bet.append(abs(y[i]-X))
bet.append(0)
bet.sort()

#length from bet to bet
bet2=[]
for i in range(len(bet)-1):
	if 	bet[i+1] != bet[i]:
		bet2.append(bet[i+1]-bet[i])
bet2.sort()

#delete same
key=bet2[0]
keylen=[key]
i=0
while i < len(bet2):
	if bet2 [i]!=key:
		keylen.append(bet2[i])
		key=bet2[i]
	else:
		i+=1


#take out multiple
def multiple(num,k):
	if num %k==0:
		return k
	else:
		return multiple(k,num%k)

while len(keylen) != 1:
	mult=[]
	for i in keylen:
		for j in keylen[keylen.index(i)+1:]:
			if j % i != 0:
				mult.append(multiple(i,j))
			else:
				keylen.remove(j)
	keylen.extend(mult)
	keylen.sort()

print(keylen[0])

Measured memory_bytes: 15504
//#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//#pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>

#define pb push_back
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define ll long long

using namespace std;

void file(){
	#ifndef ONLINE_JUDGE
    	freopen("in.txt", "r", stdin);
	#endif
}
int tc;
const int N=2e5+5,M=2e6+5,MOD=1e9+7,OO=1e9;

int main(){
	ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	//file();
	string a;
	cin>>a;
	if(a[2]==a[3] && a[4]==a[5])cout<<"Yes\n";
	else	cout<<"No\n";
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
//g++ -std=c++0x templates.cpp
//./a.out

#define rep(i,n) for (i = 0; i < n; ++i)
#define repI(i,k,n) for (i = k; i <= n; ++i)
#define repD(i,k,n) for (i = k; i >= n; --i)
#define trav(a, x) for(auto& a : x)
#define sz(x) (int)(x).size()
#define max(a,b) (a<b?b:a)
#define min(a,b) (a<b?a:b)
#define mp make_pair
#define pb push_back
#define pf push_front
#define fill(a) memset(a, 0, sizeof(a));

typedef long double ld;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;

const double EPS = 1e-8;
const int mod = 1e9+7;
const int N = 1e5+10;
const ll INF = 1e18;


ll power(ll x,ll y){
  ll t=1;
  while(y>0){
    if(y%2) y-=1,t=t*x%mod;
    else y/=2,x=x*x%mod;
  }
  return t;
}

int main()
{
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
 	ll n, i, j;cin>>n;
 	ll a[N], b[N], c[N], dp[3][N];
 	repI(i, 1, n)cin>>a[i]>>b[i]>>c[i];
 	dp[0][1]=a[1];
 	dp[1][1]=b[1];
 	dp[2][1]=c[1];
 	repI(i, 2, n)
 	{
 		dp[0][i]=max(dp[1][i-1], dp[2][i-1]) + a[i];
 		dp[1][i]=max(dp[2][i-1], dp[0][i-1]) + b[i];
 		dp[2][i]=max(dp[0][i-1], dp[1][i-1]) + c[i];
 	}
 	cout<<max(dp[0][n], max(dp[1][n], dp[2][n]))<<endl;   
	return 0;
}

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

using namespace std;

int n;
int arr[210];

int main() {
    int i;

    scanf("%d",&n);
    for (i=0;i<2*n;i++)scanf("%d",&arr[i]);
    sort(arr,arr+2*n);
    int s = 0;
    for (i=0;i<2*n;i+=2) s += arr[i];
    printf("%d\n",s);

    return 0;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
#include<bits/stdc++.h>
#include<string.h>
#define ll long long
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);
#define mod 1000000007
const int nax = 405;
ll dp[nax][nax];
ll a[nax];
ll prefix[nax];

ll sum(int l,int r){
	return prefix[r] - ((l-1)>=0?prefix[l-1]:0);
}

ll min(ll a, ll b){
	return a<=b?a:b;
}

ll rec(int i , int j){
	if(i==j)return 0;
	if(j==i+1)return a[i]+ a[j];	

	ll& ans = dp[i][j];
	if(ans!=-1)return ans;
	ans = 1e18;

	for(int idx = i; idx < j ; ++idx){
		ans = min(ans, rec(i,idx) + rec(idx+1,j) + sum(i,j));
	}
	return ans;
}


int main(){
	memset(dp,-1,sizeof(dp));
	IOS;
	int n;
	cin >> n;
	for(int i= 0 ; i < n ; ++i){
		cin >> a[i];
		if(i==0) prefix[i] = a[i];
		else prefix[i] = prefix[i-1] + a[i];
	}

	cout << rec(0,n-1) << endl;
}

Measured memory_bytes: 1536
#include <algorithm>
#include <cmath>
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <set>
#include <iomanip>
#include <sstream>

using namespace std;
using ll = long long;

// inf
constexpr ll infl = 1LL << 60;
constexpr int inf = 1 << 30;

int main() {
    int N; cin >> N;
    int a = N / 1000;
    int b = N / 100 % 10;
    int c = N / 10 % 10;
    int d = N % 10;
    int ans = 0;
    for (int i = 0; i < (1 << 3); ++i) {
        int k = a;
        k += (((i & 1) << 1) - 1) * b;
        k += (((i & 2)) - 1) * c;
        k += (((i & 4) >> 1) - 1) * d;

        if (k == 7) {
            ans = i;
            break;
        }
    }
    string s = "";
    s += a + '0'; 
    s += ans & 1 ? '+' : '-';
    s += b + '0';
    s += ans & 2 ? '+' : '-';
    s += c + '0';
    s += ans & 4 ? '+' : '-';
    s += d + '0';
    s += "=7";
    cout << s << endl;
    return 0;
}

Measured memory_bytes: 256
n,x,m=map(int,input().split())

if x==0:
    print(0)
elif x==1:
    print(n)
elif m==1:
    print(0)
elif n<=m*2:
    asum=x
    ai=x
    for i in range(1,n):
        ai=(ai*ai)%m
        asum+=ai
    print(asum)
    
else:
    aa=[]
    ai=x
    icnt=0
    asum=0
    while not ai in aa:
        asum+=ai
        aa.append(ai)
        ai=(ai*ai)%m
        icnt+=1
    asum0=0
    ai0=x
    icnt0=0
    if ai!=x:
        for i in range(icnt+1):
            asum0+=ai0
            ai0=(ai0*ai0)%m
            icnt0+=1
            if ai0==ai:
                break
    icntk=icnt-icnt0
    if icntk==0:
#        print("0:",ai,asum,icnt,ai0,asum0,icnt0)
        icntk=1
        n0=n-1
        nk=n0//icntk
        nr=0
        asumk=ai0
        asumr=0
        ans=asum0+x*(n-icnt0)
        print(ans)       
    else:
#        print("1:",ai,asum,icnt,ai0,asum0,icnt0)
        n0=n-1-icnt0
        nk=n0//icntk
        nr=n0%icntk
        asumk=asum-asum0
        asumr=0
        air=ai
        for i in range(nr):
            asumr+=air
            air=(air*air)%m
        asumr+=air
       
        ans=asum0+asumk*nk+asumr    
        print(ans)       
        


Measured memory_bytes: 67444
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
using ll = long long;
const int INF = (1<<30)-1;
const long long LINF = (1LL<<62)-1;
const long double PI = acos(-1.0L);
const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, 1, 0, -1};
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; }

signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n, m;
  cin >> n >> m;
  if (m < n)
    cout << "No" << endl;
  else
    cout << "Yes" << endl;
  return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        
        Scanner sc = new Scanner(System.in);
        String S = sc.nextLine();
        String T = sc.nextLine();
        
        int Total = 0;
        
        for(int i = 0; i < 3; i++){
            char Schar = S.charAt(i);
            char Tchar = T.charAt(i);
            
            if(Schar == Tchar){
                Total++;
            }
        }
        
        System.out.println(Total);
    }
}


Measured memory_bytes: 21844
import scala.math._

// longでrangeの作り方

object Main extends App {

  val YES = "YES"
  val Yes = "Yes"
  val NO = "NO"
  val No = "No"
  ///////////////////////////////////////////

  val sc = new java.util.Scanner(System.in)
  val a, b = sc.nextInt
//  val list = List.fill(3)(sc.next)

  val strength = Seq(2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 1)

  val ans =
    if (strength.indexOf(a) < strength.indexOf(b)) "Bob"
    else if (strength.indexOf(b) < strength.indexOf(a)) "Alice"
    else "Draw"

  println(ans)


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

  def bigIterator(start: BigInt, end: BigInt, step: BigInt = 1) =
    Iterator.iterate(start)(_ + step).takeWhile(_ <= end)

  def lcm(a :Int, b :Int): Int =
    a / gcd(a, b) * b

  def lcm(a :Long, b :Long): Long =
    a / gcd(a, b) * b

  def gcd(a: Int, b: Int): Int =
    if (b == 0) a else gcd(b, a % b)

  def gcd(a: Long, b: Long): Long =
    if (b == 0) a else gcd(b, a % b)

  def setOrUpdated[A, B](a: Map[A, B], key: A, value: B, f: (B, B) => B) =
    a.get(key) match {
      case Some(v) => a.updated(key, f(value, v))
      case _ => a + (key -> value)
    }
}

Measured memory_bytes: 27332
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <array>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;
using ll = long long;

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

    cout << (n % 2 == 0 ? n : n * 2) << endl;

    return 0;
}

Measured memory_bytes: 256
import std.stdio;
import std.conv;
import std.string;
import std.typecons;
import std.algorithm;
import std.array;
import std.range;
import std.math;
import std.regex : regex;
import std.container;
import std.bigint;
import std.ascii;


void main()
{
  int n, m;
  readf("%s %s\n", &n, &m);
  if (n - m) {
    writeln("No");
  } else {
    writeln("Yes");
  }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define SZ(x) ((int)x.size())
#define FOR(i,a,b) for (int i=a;i<=b;++i)
#define FORD(i,a,b) for (int i=a;i>=b;--i)
using namespace std;
typedef long long LL;
typedef pair<int,int> pa;
typedef vector<int> vec;
void getint(int &v){
    char ch,fu=0;
    for(ch='*'; (ch<'0'||ch>'9')&&ch!='-'; ch=getchar());
    if(ch=='-') fu=1, ch=getchar();
    for(v=0; ch>='0'&&ch<='9'; ch=getchar()) v=v*10+ch-'0';
    if(fu) v=-v;
}
char c[666],s[666];
int L,R,n;
int main(){
	scanf("%s",s+1);
	n=strlen(s+1);
	c[1]='k';
	c[2]='e';
	c[3]='y';
	c[4]='e';
	c[5]='n';
	c[6]='c';
	c[7]='e';
	FOR(i,1,7)
		if (s[i]==c[i]) ++L; else break;
	R=8;
	FORD(i,n,n-6)
		if (s[i]==c[i-n+7]) R=i-n+7; else break;
	if (L+1>=R) puts("YES");
	else puts("NO");
	return 0;
}

Measured memory_bytes: 256
N, Q = gets.split.map(&:to_i)

hash = Hash.new {0}
parents = Hash.new {1}
parents[1] = 0

(N-1).times do
  a, b = gets.split.map(&:to_i)
  parents[b] = a
end

Q.times do
  p, x = gets.split.map(&:to_i)
  hash[p] += x
end

ans = Hash.new {0}
ans[1] = hash[1]

(1..N).to_a.each do |i|
  ans[i] = hash[i] + ans[parents[i]]
  if i == N
    puts ans[i]
  else
    print "#{ans[i]} "
  end
end


Measured memory_bytes: 44280
#!/usr/bin/env python3
import sys
import queue


def solve(N: int, adjacent):
    color = [0] * N
    visited = [False] * N

    visited[0] = True
    
    Q = queue.Queue()
    Q.put(0)
    while not Q.empty():
        u = Q.get()
        for v, w in adjacent[u]:
            if visited[v]:
                continue
            visited[v] = True
            if w == 0:
                color[v] = color[u]
            else:
                color[v] = (color[u] + 1) % 2
            Q.put(v)
    for c in color:
        print(c)


# Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    adjacent = [[] for _ in range(N)]
    for i in range(N-1):
        u = int(next(tokens)) - 1
        v = int(next(tokens)) - 1
        w = int(next(tokens)) % 2
        adjacent[u].append((v, w))
        adjacent[v].append((u, w))
    solve(N, adjacent)

if __name__ == '__main__':
    main()


Measured memory_bytes: 84892
import java.util.*;

class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);

        int n = sc.nextInt();
        int[] a = new int[n];
        for(int i = 0;i < n;i++){
            a[i] = sc.nextInt();
        }

        int q = sc.nextInt();
        for(int i = 0;i < q;i++){
            int com = sc.nextInt();
            int b = sc.nextInt();
            int c = sc.nextInt();
            int max = Integer.MIN_VALUE;
            int min = Integer.MAX_VALUE;
            switch(com){
                case 0:
                    for(int j = b;j < c;j++){
                        if(min > a[j])  min = a[j];
                    }
                    System.out.println(min);
                    break;
                case 1:
                    for(int j = b;j < c;j++){
                        if(max < a[j])  max = a[j];
                    }
                    System.out.println(max);
                    break;
            }
        }
    }
}


Measured memory_bytes: 33920
// ConsoleApplication3.cpp : コンソール アプリケーションのエントリ ポイントを定義します。
//

//#include "stdafx.h"
#include <iostream>
using namespace std;
int main()
{
	int a, b;
	cin >> a >> b;
	if (a > b) {
		cout << "a > b" << endl;
	}
	else if (a == b) {
		cout << "a == b" << endl;
	}
	else {
		cout << "a < b" << endl;
	}
    return 0;
}




Measured memory_bytes: 3120
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N, Sum;
  cin >> N;
  Sum = 0;
  for(int i = 0; i < N ; i++){
    int l, r;
    cin >> l >> r;
    Sum += r-l+1;
  }
  cout << Sum << endl;
}

Measured memory_bytes: 3628
# -*- coding: utf-8 -*-
D, G = map(int, input().split())
p = []
c = []
for i in range(D):
    p_i,c_i = map(int, input().split())
    p.append(p_i)
    c.append(c_i)

min_problem = sum(p)
# コンプリートする・しないでbinary
for bit in range(2**D):
    base_score = 0
    base_problem = 0
    non_completed_index = []
    for shift in range(D):
        if (bit>>shift)&1:
            base_score += c[shift]
            base_score += 100*(shift+1)*p[shift]
            base_problem += p[shift]
        else:
            non_completed_index.append(shift)

    if base_score >= G:
        if base_problem < min_problem:
            min_problem = base_problem
    else:
        add_score = 0
        add_problem = 0
        # 上から順に埋めていく
        non_completed_index = non_completed_index[::-1]
        for idx in non_completed_index:
            max_add_score_idx = 100*(idx+1)*(p[idx]-1)
            if base_score+add_score+max_add_score_idx >= G:
                # 埋め終了
                if (G-base_score-add_score) % (100*(idx+1)) == 0:
                    idx_problem = int((G-base_score-add_score)/(100*(idx+1)))
                else:
                    idx_problem = int((G-base_score-add_score)/(100*(idx+1)))+1
                if idx_problem+add_problem+base_problem < min_problem:
                    min_problem = idx_problem+add_problem+base_problem
                break
            else:
                add_score += max_add_score_idx
                add_problem += p[idx]-1


print(min_problem)                    
        

Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main()
{
    int h, w;
    cin >> h >> w;
    vector<vector<char>> c(2 * h, vector<char>(2 * w));
    for (int i = 0; i < h; i++) {
        for (int j = 0; j < w; j++) {
            cin >> c[i][j];
        }
    }

    vector<vector<int>> l(2 * h, vector<int>(2 * w));
    vector<vector<int>> r(2 * h, vector<int>(2 * w));
    vector<vector<int>> d(2 * h, vector<int>(2 * w));
    vector<vector<int>> u(2 * h, vector<int>(2 * w));
    for (int i = 0; i < h; i++) {
        for (int j = 0; j < w; j++) {
            if (c[i][j] == '#') l[i][j] = 0;
            else if (j == 0) l[i][j] = 1;
            else l[i][j] = l[i][j-1] + 1;
        }
    }
    for (int i = 0; i < h; i++) {
        for (int j = w-1; j >= 0; j--) {
            if (c[i][j] == '#') r[i][j] = 0;
            else if (j == w-1) r[i][j] = 1;
            else r[i][j] = r[i][j+1] + 1;
        }
    }
    for (int j = 0; j < w; j++) {
        for (int i = 0; i < h; i++) {
            if (c[i][j] == '#') u[i][j] = 0;
            else if (i == 0) u[i][j] = 1;
            else u[i][j] = u[i-1][j] + 1;
        }
    }
    for (int j = 0; j < w; j++) {
        for (int i = h-1; i >= 0; i--) {
            if (c[i][j] == '#') d[i][j] = 0;
            else if (i == h-1) d[i][j] = 1;
            else d[i][j] = d[i+1][j] + 1;
        }
    }

    int max_c = 0;
    for (int i = 0; i < h; i++) {
        for (int j = 0; j < w; j++) {
            max_c = max(max_c, l[i][j] + r[i][j] + d[i][j] + u[i][j] - 3);
        }
    }

    cout << max_c << endl;
}

Measured memory_bytes: 266752
#include <iostream>
using namespace std;
int main(int argc, char const *argv[]) {
  int n,t;
  cin>>n>>t;
  int cost=1001;
  for(int i=0;i<n;i++){
    int tmp_cost,tmp_time;
    cin>>tmp_cost>>tmp_time;
    if(tmp_cost<cost&&tmp_time<=t){
      cost=tmp_cost;
    }
  }
  if(cost==1001){
    cout<<"TLE"<<endl;
  }else{
    cout<<cost<<endl;
  }
  return 0;
}


Measured memory_bytes: 256
N, K = gets.split(" ").map(&:to_i)
R, S, P = gets.split(" ").map(&:to_i)
T = gets.chomp.split("")
ans = 0
ary = []
N.times do |i|
    if T[i] =="r"
        ans += P
        ary << "p"
    elsif T[i] =="s"
        ans += R
        ary << "r"
    else
        ans += S
        ary << "s"
    end
end
(N - K).times do |i|
    if i + K < N && ary[i + K] == ary[i]
        if ary[i + K] =="r"
            ary[i + K] = "x"
            ans -= R
        elsif ary[i + K] =="s"
            ary[i + K] = "x"
            ans -= S
        elsif ary[i + K] == "p"
            ary[i + K] = "x"
            ans -= P
        end 
    end
end        

puts ans 

Measured memory_bytes: 18044
#include <iostream>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <functional>
#include <bitset>

using namespace std;
#define int long long int
const int INF = 1001001001001001LL;
const int MOD = 1000000007;

int di[] = {-1, 0, 1, 0, -1, 1, 1, -1};
int dj[] = {0, 1, 0, -1, 1, 1, -1, -1};

signed main(){
   
    while(true){
        int n;
        cin >> n;

        if(n == 0) break;

        int a[200000] = {};
        int s = 0;

        long long sum = 0;
        for(int i = 0; i < n; ++i){
            int tmp;
            cin >> tmp;
            a[i] = tmp;
            sum += tmp;
        }
        bool f = false;
        int K;
        for(long long k = 1; k * (k + 1) / 2 <= sum; ++k){
            if(k * (k+1) / 2 == sum){
                f = true;
                K = k;
                break;
            }
        }
        if(!f){
            cout << -1 << endl;
            continue;
        }

        bool ok = true;
        for(int i = 0; i < K; ++i){
            if(a[i] != i + 1){
                ok = false;
                break;
            }   
        }
        if(ok){
            cout << 0 << endl;
            continue;
        }

        int idx = n - 1;
        int ans;
        ok = false;
        for(int ii = 0; ii < 10000; ++ii){
            long long sum = 0;
            for(int i = s; i <= idx; ++i){
                if(a[i] != 0){
                    a[i]--;
                    sum++;
                }
            }
            idx++;
            a[idx] = sum;

            //判定
            while(a[s] == 0){
                s++;
            }
            int cnt = 0;
            for(int i = 0; i < K; ++i){
                if(a[s + i] == i + 1){
                    cnt++;
                }else{
                    break;
                }
            }
            if(cnt == K){
                ok = true;
                ans = ii;
                break;
            }
        }
        if(ok){
            cout << ans << endl;
        }else{
            cout << -1 << endl;
        }
    }
    return 0;
}



Measured memory_bytes: 4620
N,M=map(int,input().split())
a = [0 for i in range(N)]
b = [0 for i in range(N)]
for i in range(M):
    link=list(map(int,input().split()))
    link.sort()
    if link[0] == 1:
        a[link[1]-1] = 1
    if link[1] == N:
        b[link[0]-1] = 1
for i in range(N):
    if a[i]*b[i] == 1:
        print("POSSIBLE")
        exit()
print("IMPOSSIBLE")

Measured memory_bytes: 6320
#include<bits/stdc++.h>
using namespace std;
#define MOD 1000000007
//#define MOD 998244353
#define INF 1000000010
#define EPS 1e-9
#define F first
#define S second

#define debug(x) cout<<x<<endl;
#define repi(i,x,n) for(int i=x;i<n;i++)
#define rep(i,n) repi(i,0,n)
#define lp(i,n) repi(i,0,n)
#define repn(i,n) for(int i=n;i>=0;i--)
#define int long long
#define endl "\n"

typedef pair<int,int> PII;
typedef pair<int,string> PIS;
typedef pair<string,int> PSI;


signed main(){
  cin.tie(0);	
  ios::sync_with_stdio(false);
  int a;
  long double b;
  cin>>a>>b;
  
  
  int c=a*b;
  
  cout<<c<<endl;
  return 0;
}


Measured memory_bytes: 3744
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.*;

public class Main {
    private static final int MOD = (int) Math.pow(10, 9);
    private static final int[][] DIRECTIONS = {{1, 1}, {0, 1}, {-1, 1}, {1, 0}, {-1, 0}, {0, -1}};

    public static void main(String[] args) {
        FastReader sc = new FastReader();
        int a = sc.nextInt();
        int b = sc.nextInt();

        if (a > b) {
            int tmp = a;
            a = b;
            b = tmp;
        }

        String res = "";

        for (int i = 0; i < b; i++) {
            res = res + a;
        }

        System.out.println(res);
        System.exit(0);
    }

    static class FastReader {
        BufferedReader br;
        StringTokenizer st;

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

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

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

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

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

        String nextLine() {
            String str = "";
            try{
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }
    }
}


Measured memory_bytes: 22100
#include<bits/stdc++.h>
#include<iostream>
#include<vector>
using namespace std;
 
/****************************************\
| Thank you for viewing my code:)        |
| Written by RedSpica a.k.a. RanseMirage |
| Twitter:@asakaakasaka                  | 
\****************************************/
  
signed main() {
  int q;
    cin>>q;
  vector<bool> A(100100,true);
  for(int i=2;i<=100010;i++){
    int up=sqrt(i)+1;
    for(int j=2;j<up;j++){
      if(i%j==0){
         A[i]=false;
        break;
      }
    }
  }

  vector<int> B(100100);
  for(int i=3;i<=100010;i+=2){
    B[i]=B[i-2];
    if(A[i]&&A[(i+1)/2]){
      B[i]++;
    }
  }
  for(int i=0;i<q;i++){
    int l,r;
      scanf("%d%d",&l,&r);
    if(l==1){
      l+=2;
    }
    printf("%d\n",B[r]-B[l-2]);
  }
}

Measured memory_bytes: 1024
/*
 * 2299.cc: Tiles are Colorful
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
 
using namespace std;

/* constant */

const int MAX_M = 500;
const int MAX_N = 500;

typedef long long ll;

const int INF = 1 << 30;
const ll LINF = 1LL << 60;

/* typedef */

typedef vector<int> vi;
typedef queue<int> qi;
typedef pair<int,int> pii;

/* global variables */

int flds[MAX_M][MAX_N];
pii ps[26], as[26];
vi msks[26];
bool used[26];

/* subroutines */

string b2s(int bits) {
  string s;
  for (int i = 0, bi = 1; i < 26; i++, bi <<= 1)
    if (bits & bi) s += (char)('A' + i);
  return (s.empty() ? "." : s);
}

/* main */

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

  for (int i = 0; i < 26; i++) ps[i].first = -1;
  
  for (int y = 0; y < m; y++) {
    string s;
    cin >> s;
    for (int x = 0; x < n; x++)
      flds[y][x] = (s[x] == '.') ? -1 : s[x] - 'A';
  }
  
  for (int y = 0; y < m; y++)
    for (int x = 0; x < n; x++) {
      int k = flds[y][x];
      if (k < 0) continue;

      if (ps[k].first < 0) {
	ps[k] = pii(x, y);
	continue;
      }

      int x0 = ps[k].first, y0 = ps[k].second;
      if (x != x0 && y != y0) {
	int msk0 = 0, msk1 = 0;
	int dx = (x > x0) ? 1 : -1;

	for (int x1 = x; x1 != x0; x1 -= dx)
	  if (flds[y0][x1] >= 0) msk0 |= (1 << flds[y0][x1]);
	for (int y1 = y0; y1 != y; y1++)
	  if (flds[y1][x] >= 0) msk0 |= (1 << flds[y1][x]);

	for (int x1 = x0; x1 != x; x1 += dx)
	  if (flds[y][x1] >= 0) msk1 |= (1 << flds[y][x1]);
	for (int y1 = y; y1 != y0; y1--)
	  if (flds[y1][x0] >= 0) msk1 |= (1 << flds[y1][x0]);

	if (msk0 == msk1)
	  msks[k].push_back(msk0);
	else {
	  msks[k].push_back(msk0);
	  msks[k].push_back(msk1);
	}
      }
      else if (x == x0) {
	if (y0 + 1 < y) {
	  int msk0 = 0;
	  for (int y1 = y0 + 1; y1 < y; y1++)
	    if (flds[y1][x] >= 0) msk0 |= (1 << flds[y1][x]);
	  msks[k].push_back(msk0);
	}
      }
      else {
	if (x0 + 1 < x) {
	  int msk0 = 0;
	  for (int x1 = x0 + 1; x1 < x; x1++)
	    if (flds[y][x1] >= 0) msk0 |= (1 << flds[y][x1]);
	  msks[k].push_back(msk0);
	}
      }
    }

  if (false) {
    for (int i = 0; i < 26; i++)
      if (msks[i].size()) {
	printf("%c:(%lu)", 'A' + i, msks[i].size());
	for (int j = 0; j < msks[i].size(); j++)
	  cout << ' ' << b2s(msks[i][j]);
	putchar('\n');
      }
  }
  
  int msk = 0;
  int ans = 0;
  
  for (bool changed = true; changed;) {
    changed = false;
    for (int i = 0, bi = 1; i < 26; i++, bi <<= 1)
      if (! used[i] && msks[i].size()) {
	for (int j = 0; j < msks[i].size(); j++)
	  if ((msk & msks[i][j]) == msks[i][j]) {
	    used[i] = true;
	    msk |= bi;
	    ans++;
	    changed = true;
	    break;
	  }
      }
  }

  printf("%d\n", ans * 2);
  return 0;
}

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

int main(void){
	ll N,M;
	cin >> N >> M;
	ll s = M/N;
	ll ans = 1;
	//約数の片方のペアを求めて、それともう片方が条件を満たすかどうか調べる
	for(ll i=1;i*i<=M;i++){
		if(M%i==0){
			ll o = M/i;
			if( M>=N*i)ans = max(ans,i);
			if( M>=N*o)ans = max(ans,o);
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using p=pair<int,int>;
#define int long long
#define rep(i,N) for(int i=0;i<N;i++)
 
signed main(){
  int N,M;
  cin>>N>>M;
  vector<int> H(N);
  rep(i,N)cin>>H[i];
  vector<bool> check(N,true);
  rep(i,M){
    int A,B;
    cin>>A>>B;
    A-=1;
    B-=1;
    if(H[A]<=H[B])check[A]=false;
    if(H[B]<=H[A])check[B]=false;
  }
  int ans=0;
  rep(i,N)if(check[i])ans+=1;
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 4008
// B - Buffet

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

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

	int A[20];
	int B[20];
	int C[20];

	for (int i=0; i<N; i++) {
		cin >> A[i];
		A[i]--;
	}

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

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

	int prev_A = -99;
	int ans = 0;
	for (int i=0; i<N; i++) {
		ans += B[A[i]];
		if (A[i] == prev_A + 1) {
			ans += C[prev_A];
		}
		prev_A = A[i];
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main()
{
    int a,b,c,d,e,k;
    cin>>a>>b>>c>>d>>e>>k;
    int x[20];
    int ture=0;
    x[0]=b-a,x[1]=c-a,x[2]=d-a,x[3]=e-a,x[4]=c-b,x[5]=d-b,x[6]=e-b,x[7]=d-c,x[8]=e-c;x[9]=e-d;
    for(int i=0;i<10;i++)
    {
        if(x[i]>k)
            ture=1;
    }
    if(ture==0)
        cout<<"Yay!"<<endl;
    else
        cout<<":("<<endl;
    return 0;

}


Measured memory_bytes: 256
/// kazuki08
/*
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")
*/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define int long long
typedef long long ll;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>ordered_set;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int,int> pi;
typedef vector<pi> vpi;
//#define inf 1000000000
#define mod 1000000007
#define dmp(x) cerr<<"line "<<__LINE__<<" "<<#x<<":"<<x<<endl
#define fs first
#define sc second
#define pb push_back
#define all(c) (c).begin(),(c).end()
#define mt make_tuple
#define IOS ios::sync_with_stdio(0);cin.tie(0);cout.tie(0)
template<class S,class T> ostream& operator<<(ostream& o,const pair<S,T> &p){
    return o<<"("<<p.fs<<","<<p.sc<<")";
}
template<class T> ostream& operator<<(ostream& o,const vector<T> &vc){
    o<<"{";
    for(const T& v:vc) o<<v<<",";
    o<<"}";
    return o;
}
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

signed main(){
IOS;
//freopen("input.txt", "r", stdin);
//freopen("output.txt", "w", stdout);


  int n,k;
  cin >> n >> k;
  ld sum = 0;
  int a[n+1]={0};
  for(int i=1;i<=n;i++)cin>>a[i];
  for(int i=1;i<=k;i++){
    sum+=a[i]+1;
  }
  ld ans = sum/2.00;
  for(int i=k+1;i<=n;i++){
    sum+=a[i]+1-a[i-k]-1;
    ans = max(ans, sum/2.00 );
  }
  cout << fixed << setprecision(10);
  cout << ans << endl;
  


return 0;
}
///....


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

int main()
{
	string S;
	int len, check = 0;
	cin >> S;
	len = S.length();
	if (S[0] == 'A') check++;
	for (int a = 2; a < len - 1; a++) {
		if (S[a] == 'C')check++;
	}
	for (int a = 0; a < len; a++) {
		if (S[a] >= 'A'&&S[a] <= 'Z')check++;
	}
	if (check == 4) cout << "AC";
	else cout << "WA";
    return 0;
}

Measured memory_bytes: 256
//Solution By SlavicG
#include "bits/stdc++.h"
using namespace std;

#define ll                          long long

#define forn(i,n)                   for(int i=0;i<n;i++)
#define all(v)                      v.begin(), v.end()
#define rall(v)                     v.rbegin(),v.rend()
	
#define pb                          push_back
#define sz(a)                       (int)a.size()
 
#define   endl                       "\n"
#define fastio                       ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);

int  main()
{
	ll n,k;
	cin >> n >> k;
	if(k==n){
		cout <<0;
		return 0;
	}
	if(k > n){
		cout << min(n,abs(k-n));
		return 0;
	}
	ll moves = n / k;
	n  = n - moves * k;
	if(n==0){
		cout << n;
		return 0;
	}
	cout << min(n,abs(n-k));
	return 0;
}

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

int main(){
    int n, k; cin >> n >> k;
    int a = (n-1)*(n-2)/2; 
    if(k > a){
        cout << -1 << endl; return 0;
    }
    a -= k;
    cout << a + n -1 << endl;
    for(int i = 2; i <= n; i++){
        cout << "1 " << i << endl;
    }
    for(int i = 2; i < n && a; i++){
        for(int j = i+1; j <= n && a; j++){
            cout << i << " " << j << endl;
            a--;
        }
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using i64 = int64_t;
using f80 = __float80;

constexpr i64 INF = 1'010'000'000'000'000'017LL;
constexpr i64 MOD = 1'000'000'007LL;
static const int dy[4] = {0,1,0,-1}, dx[4] = {1,0,-1,0};

#define _overload3(_1,_2,_3,name,...) name
#define repi(i,start,end) for(i64 i=(start);i<(end);++i)
#define _rep(i,n) repi(i,0,n)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define rrep(i,start,end) for(i64 i=(start);i>end;--i)
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define rng(a) a.begin(),a.end()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define sz(x) (i64)(x).size()
#define v(T) vector<T>
#define vv(T) v(v(T))
#define bit(n) (1LL<<(n))

typedef pair<i64,i64> P;
typedef vector<i64> vi;
typedef vector<vi> vvi;
typedef vector<P> vp;

void Main()
{
  i64 N,W;
  cin >> N >> W;

  vi dp(1000*N+1,INF);
  dp[0] = 0;

  i64 w,v;
  rep(i,N){
    cin >> w >> v;
    rrep(ii,1000*N,v-1)
      mins(dp[ii],dp[ii-v]+w);
  }

  rrep(ii,1000*N,-1)
    if(dp[ii]<=W){
      cout << ii << endl;
      return;
    }
}

int main()
{
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(15);
  Main();
}


Measured memory_bytes: 1024