akhauriyash/Code-Regression huggingface dataset:
// Template //
#include<bits/stdc++.h>
using namespace std;

// マクロ //
#define rep(i,N) for(int i = 0; i < N; i++)
#define all(x) x.begin(), x.end()
#define sort(x) sort(all(x))
#define uniq(x) x.erase(unique(all(x)), x.end())
#define vsum(x) accumulate(all(x), 0)
#define cou(x) cout << x << endl
#define y() cout << "Yes" << endl
#define n() cout << "No" << endl
#define Y() cout << "YES" << endl
#define N() cout << "NO" << endl
#define x2(x) (x) * (x)

// 型エイリアス //
using lint = long long;
using pii = pair<int, int>;
using vi = vector<int>;
using vli = vector<lint>;
using vc = vector<char>;
using vs = vector<string>;
using vb = vector<bool>;
using vvi = vector<vi>;
using vvb = vector<vb>;
using vvc = vector<vc>;
using vpii = vector<pii>;
using msi = map<string, int>;

// 関数 //
template<class T> lint gcd(T a, T b) {
    int t;
    while (b != 0) {
        t = a % b;
        a = b;
        b = t;
    }
    return a;
}

template<class T> lint lcm(T a, T b) {
    return a * b / gcd(a, b);
}

double distance(pii a, pii b) {
    double dist;
    dist = sqrt(x2(a.first - b.first) + x2(a.second - b.second));
    return dist;
}

lint perm(int a) {
    lint perm = 1;
    for (int i = a; i >= 1; i--) {
        perm *= i;
    }
    return perm;
}

lint combination(int n, int m) {
    long double c = 1;
    for (int i = n, k = 1; i > m; i--, k++) {
        c *= i;
        c /= k;
    }
    return (lint)c;
}

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

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

// 定数 //
#define pi acos(-1)
#define mod 1000000007
#define MOD 998244353

// End of Template //



int main() {

    cin.tie(0);
    ios::sync_with_stdio(false);

    int N;
    cin >> N;

    vi money;
    money.push_back(1);
    for (int i = 1; pow(6, i) <= N; i++) {
        money.push_back(pow(6, i));
        money.push_back(pow(9, i));
    }
    sort(money);
    while (money.back() > N) {
        money.pop_back();
    }
    vli dp(N + 1, 7979797979797);
    dp[0] = 0;
    rep(i, N) {
        for (auto x : money) {
            if (i + x > N) break;
            chmin(dp[i + x], dp[i] + 1);
        }
    }
    cou(dp[N]);
}

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

namespace ABC121
{
    class C
    {
        static void Main(string[] args)
        {
            int[] h = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
            int N = h[0], M = h[1];

            List<Drink> list = new List<Drink>();

            for (int i = 0; i < N; i++)
            {
                int[] g = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
                int A = g[0];
                int B = g[1];
                Drink d = new Drink(); d.price = A; d.num = B;
                list.Add(d);
            }

            list = list.OrderBy(x => x.price).ToList();

            long sum = 0;
            int count = 0;
            foreach (var v in list)
            {
                if (count + v.num > M)
                {
                    sum += (long)(M - count) * v.price;
                    count = M;
                }
                else
                {
                    sum += (long)v.num * v.price;
                    count += v.num;
                }

                if (count == M) break;
            }

            Console.WriteLine(sum);
        }

    }
    struct Drink
    {
        public int price;
        public int num;
    }
}


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

//C++14 (GCC 5.4.1)
int main() {
    int A,B;
    cin >>A>>B;
    
    bool is=false;
    
    if((A*B)%2==1){
        is=true;
    }
    cout << ((is) ? "Yes" : "No") <<endl;

    return (0);
}

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

using namespace std;

int main(){
  int n;
  vector< string > words( 110 );

  cin >> n;
  cin >> words.at( 0 );

  for ( int i = 1; i < n; i++ ){
    cin >> words.at( i );
    string a = words.at( i - 1 );
    string b = words.at( i );
    if ( a.at( a.size() - 1 ) != b.at( 0 ) ){
      cout << "No" << endl;
      return 0;
    }
    
    for ( int j = 0; j < i; j++ ){
      if ( words.at( i ) == words.at( j ) ){
        cout << "No" << endl;
        return 0;
      }
    }
  
  }

  cout << "Yes" << endl;
  
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <stdlib.h>
#include <string.h>
#include <cmath>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <stdio.h>
#include <tuple>
#define int long long
#define rep(i, n) for (int i = 0; i < (n); i++)
#define P pair<long long,long long>
#define INF 1000000000000000000
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const long long MOD = 1000000007;
using namespace std;
typedef long long ll;
map<int, int> mp;
//最大公約数
ll gcd(ll a, ll b) {
	if (a < b)swap(a, b);
	if (b == 0) return a;
	return gcd(b, a % b);
}
//最小公倍数
ll lcm(ll a, ll b) {
	ll g = gcd(a, b);
	return a / g * b;
}


signed main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int n, m; cin >> n >> m;
	if (n >= m) { cout << 0 << endl; return 0; }
	vector<int>x(m); rep(i, m)cin >> x.at(i);
	sort(x.begin(), x.end());
	vector<int>l(m - 1);
	rep(i, m - 1)l.at(i) = x.at(i + 1) - x.at(i);
	sort(l.begin(), l.end());
	int ans = 0;
	rep(i, m - n) { ans += l.at(i); }
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1792
d=input().split()
for _ in range(int(input())):
 t,f=[int(d.index(s))for s in input().split()]
 n={0:(1,2,4,3,1),1:(0,3,5,2,0),2:(0,1,5,4,0),3:(1,0,4,5,1),4:(0,2,5,3,0),5:(1,3,4,2,1)}[t]
 print(d[n[n.index(f)+1]])


Measured memory_bytes: 5608
#include <stdio.h>
#include <math.h>
#include <stdlib.h>

#define d double

double s_of_triangle( d ax, d ay, d bx, d by, d cx, d cy ){
	double a1, a2, b1, b2;

	a1 = ax - cx;
	a2 = ay - cy;
	b1 = bx - cx;
	b2 = by - cy;

	return abs((1/2.0)*(a1*b2-a2*b1));
}
	

int main(){
	double ax, ay, bx, by, cx, cy, px, py;
	double s, s1, s2, s3;

	while( scanf("%lf %lf %lf %lf %lf %lf %lf %lf",
					 &ax, &ay, &bx, &by, &cx, &cy, &px, &py ) != EOF ){

		s  = s_of_triangle( ax, ay, bx, by, cx, cy );
		
		s1 = s_of_triangle( px, py, bx, by, cx, cy );
		s2 = s_of_triangle( ax, ay, px, py, cx, cy );
		s3 = s_of_triangle( ax, ay, bx, by, px, py );

		if( s1+s2+s3 > s )
			printf("NO\n");
		else
			printf("YES\n");
	}

	return 0;
}

Measured memory_bytes: 612
# coding: UTF-8
import sys
#sys.setrecursionlimit(n)
import heapq
import re
import bisect
import random
import math
import itertools
from collections import defaultdict, deque
from copy import deepcopy
from decimal import *

a, b, c = map(int, input().split())

b = list(map(int, input().split()))

count = 0
for i in range(a):
    d = list(map(int, input().split()))
    s = 0
    for j in range(len(d)):
        s += d[j] * b[j]
    s += c
    if s > 0:
        count += 1
print(count)

Measured memory_bytes: 7752
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <unordered_map>
#include <set>
#include <climits>
using namespace std;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    long long N;
    cin >> N;
    vector<long long> A(N), B(N);
    for(int i=0; i<N; i++) cin >> A[i];
    for(int i=0; i<N; i++)
        B[i] = -(A[(i+1)%N] - A[i]);

    long long sum = 0;
    for(int i=0; i<N; i++)
        sum += A[i];

    long long tmp = N*(N+1)/2;
    if(sum % tmp != 0){
        cout << "NO" << endl;
        return 0;
    }
    long long cc = sum / tmp;

    for(int i=0; i<N; i++)
        B[i] += cc;

    long long cnt = 0;
    for(int i=0; i<N; i++){
        if(B[i] < 0 || B[i] % N != 0){
            cout << "NO" << endl;
            return 0;
        }
        cnt += B[i] / N;
    }
    if(cnt == cc)
        cout << "YES" << endl;
    else
        cout << "NO" << endl;
    return 0;
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
//#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<n;i++)
#define rev(i,n) for(int i=n-1;i>=0;i--)
#define all(v) v.begin(),v.end()
#define P pair<int,int>
#define len(s) (int)s.size()
#define pb push_back

template<class T> inline bool chmin(T &a, T b){
	if(a>b){a=b;return true;}
	return false;
}
template<class T> inline bool chmax(T &a, T b){
	if(a<b){a=b;return true;}
	return false;
}
constexpr int mod = 1e9+7;
//constexpr int inf = 3e18;

int D;
int C[26];
int A[365][26];
int con[365];
set<int>st[26];
int score(){
	vector<int>last(26,-1);
	int res=0;
	rep(i,D){
		last[con[i]]=i;
		res+=A[i][con[i]];
		rep(j,26){
			res-=C[j]*(i-last[j]);
		}
	}
	return res;
}
int change(int x,int y){
	int res=A[x][y]-A[x][con[x]];
	auto pre_old=--st[con[x]].lower_bound(x);
	auto next_old=st[con[x]].upper_bound(x);
	res+=(*next_old-x-1)*(*next_old-x)/2*C[con[x]];
	res-=(x-*pre_old+*next_old-*pre_old-1)*(*next_old-x)/2*C[con[x]];
	auto pre_new=--st[y].lower_bound(x);
	auto next_new=st[y].lower_bound(x);
	res+=(x-*pre_new+*next_new-*pre_new-1)*(*next_new-x)/2*C[y];
	res-=(*next_new-x-1)*(*next_new-x)/2*C[y];
	return res;
}
double rand_double(){
	return (double)rand()/RAND_MAX;
}
signed main(){
	cin>>D;
	rep(i,26){
		cin>>C[i];
		st[i].insert(-1);st[i].insert(D);
	}
	vector<int>last(26,-1);
	rep(i,D){
		int mx=-mod,idx;
		rep(j,26){
			cin>>A[i][j];
			if(chmax(mx,A[i][j]+C[j]*(i-last[j])))idx=j;
		}
		con[i]=idx;st[idx].insert(i);
       last[idx]=i;
	}
	int score_=score();
	cerr<<score_<<endl;
	double C=1970*100000;
	while(1000.*clock()/CLOCKS_PER_SEC<=1970){
		int x=rand()%D,y;
		do{
			y=rand()%26;
		}while(con[x]==y);
		int diff=change(x,y);
		double ti=1970-1000.*clock()/CLOCKS_PER_SEC;

		if(diff>=0/*||ti/C>rand_double()*/){
			score_+=diff;
			st[con[x]].erase(x);
			con[x]=y;
			st[y].insert(x);
		}
	}
	rep(i,D)cout<<con[i]+1<<"\n";
	cerr<<score_<<" "<<score()<<endl;
}


Measured memory_bytes: 3732
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using vl = vector<ll>;
using vll = vector<vl>;
using Pll = pair<ll, ll>;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(v) v.begin(), v.end()
#define sz(x) ((int) x.size())
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define F first
#define S second
const int MOD = 1e9+7;
const ll INF = 2e15;
template<class T> void print(const T& t){ cout << t << endl; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}

int main(){
  ll n,m;
  cin >> n >> m;
  bool possible = false;
  vl dp1;
  vl dpn;
  rep(i,m){
    ll a, b;
    cin >> a >> b;
    if(a==1){
      dp1.pb(b);
    }
    else if(b==1){
      dp1.pb(a);
    }
    if(a==n){
      dpn.pb(b);
    }
    else if(b==n){
      dpn.pb(a);
    }
  }
  sort(all(dpn));
  rep(i, sz(dp1)){
    if(binary_search(all(dpn),dp1[i])){
      possible = true;
    }
  }
  if(possible){
    print("POSSIBLE");
  }
  else{
    print("IMPOSSIBLE");
  }
}

Measured memory_bytes: 5080
// Problem : 
// 			A - Rainy Season
// 			
// 		
// Contest : AtCoder - AtCoder Beginner Contest 175
// URL : https://atcoder.jp/contests/abc175/tasks/abc175_a
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include <bits/stdc++.h>
#pragma GCC target("avx,avx2,fma")
//#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize("Ofast")  // disable
using namespace std;
#define ll long long
#define ull unsigned long long
#define ld long double
#define lll __int128
#define lp(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define vec(v, type, sz) vector<type> v(sz)
#define in(v) \
    for (auto &i : v) cin >> i
#define all(v) v.begin(), v.end()
#define prv(v)                         \
    for (auto i : v) cout << i << " "; \
    cout << "\n"
#define MOD 1000000007
#define INF 1000000000
#define INFL 1000000000000000000ll
#define fast_io                       \
    ios_base::sync_with_stdio(false); \
    cin.tie(NULL);                    \
    cout.tie(NULL);
#define vi vector<int>
#define vl vector<ll>
#define vii(v, n, m, val) vector<vector<int>> v(n, vector<int>(m, val))
#define viii(v, i, j, k, val)        \
    vector<vector<vector<int>>> v(i, \
                                  vector<vector<int>>(j, vector<int>(k, val)))
#define pii pair<int, int>
#define pb push_back
#define tos(x) string(1,x)
#define file_io                       \
    freopen("input.txt", "r", stdin); \
    freopen("output.txt", "w", stdout);
#define testc   \
    int tcc;    \
    cin >> tcc; \
    for (int tc = 1; tc <= tcc; tc++)
vector<string> vec_splitter(string s) {
    s += ',';
    vector<string> res;
    while (!s.empty()) {
        res.push_back(s.substr(0, s.find(',')));
        s = s.substr(s.find(',') + 1);
    }
    return res;
}
void debug_out(vector<string> __attribute__((unused)) args,
               __attribute__((unused)) int idx,
               __attribute__((unused)) int LINE_NUM) {
    cerr << endl;
}
template <typename Head, typename... Tail>
void debug_out(vector<string> args, int idx, int LINE_NUM, Head H, Tail... T) {
    if (idx > 0)
        cerr << ", ";
    else
        cerr << "Line(" << LINE_NUM << ") ";
    stringstream ss;
    ss << H;
    cerr << args[idx] << " = " << ss.str();
    debug_out(args, idx + 1, LINE_NUM, T...);
}
#ifdef DB
#define debug(...) \
    debug_out(vec_splitter(#__VA_ARGS__), 0, __LINE__, __VA_ARGS__)
#else
#define debug(...) 42
#endif
//#define int ll

signed main() {
	fast_io;
	string s; cin>>s;
	int n=0;
	bool r=false;
	lp(i,0,3) if(s[i]=='R') r=true;
	if(r) n++;
	lp(i,0,2) if(s[i]==s[i+1] && s[i]=='R') n++;
	cout<<n;
}
// code!=think
// least efficient code to get ac


Measured memory_bytes: 3652
#include <algorithm>
#include <cstdio>
#include <vector>
#define fs first
#define sc second
#define mp make_pair
using namespace std;
pair <int,int> list[100005];
vector <int> v[100005];
int n,k,idx[100005],ans,ctr,p[100005],temp;
void jalan (int x,int s,int sblm)
{
	list[x]=mp(s,x);
	for(int i=0;i<v[x].size();i++)
	{
		jalan(v[x][i],s+1,x);
	}
	return;
}
bool cmp(pair<int,int> a,pair<int,int> b)
{
	return a>b;
}
void update(int x,int z)
{
	if(z>k)
	{
		return;
	}
	list[idx[x]].fs=z;
	for(int i=0;i<v[x].size();i++)
	{
		update(v[x][i],z+1);
	}
	return;
}
int main ()
{
	scanf("%d%d",&n,&k);
	for(int i=1;i<=n;i++)
	{
		scanf("%d",&p[i]);
		if(i!=1)
		v[p[i]].push_back(i);
	}
	if(p[1]!=1)
	{
		ans++;
		p[1]=1;
	}
	jalan(1,0,0);
	sort(list+1,list+1+n,cmp);
	for(int i=1;i<=n;i++)
	{
		idx[list[i].sc]=i;
//		printf("-- %d %d --\n",list[i].fs,list[i].sc);
	}
	for(int i=1;i<=n;i++)
	{
		if(list[i].fs>k)
		{
			temp=list[i].sc;
			for(int j=1;j<k;j++)
			{
				temp=p[temp];
			}
			update(temp,1);
			ans++;
		}
	}
	printf("%d\n",ans);
	return 0;
}

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

// types
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pdd;
typedef vector<ll> vll;

// macros
#define ALL(a) a.begin(),a.end()
#define SZ(a) ((int)a.size())
#define FI first
#define SE second
#define REP(i,n) for(int i=0;i<((int)n);i++)
#define REP1(i,n) for(int i=1;i<((int)n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define PB push_back
#define EB emplace_back
#define MP(a,b) make_pair(a,b)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL

// constants
const int inf = 1e9;
const ll linf = 1LL << 50;
const double eps = 1e-10;
const int MOD = 1e9 + 7;
const int dx[4] = {-1, 0, 1, 0};
const int dy[4] = {0, -1, 0, 1};

int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);

  ll n;
  cin >> n;
  vll l(n);
  REP(i, n)
    cin >> l[i];

  sort(l.begin(), l.end());
  ll ans = 0;


  REP(a, n){
    for(int b = a+1; b < n; b++){
      decltype(l)::iterator it = lower_bound(l.begin(), l.end(), l[n-1-a]-l[n-1-b]+1);
      ll index = it - l.begin();
      if(index >= n-1-b)
        ans += 0;
      else
        ans += n-1-b-index;
    }
  }

  cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
void ABC90(void);
void ABC91(void);
void ABC92(void);
void ABC93(void);
void ABC94(void);
void ABC95(void);
void ABC96(void);
void ABC97(void);
void ABC98(void);
void ABC99(void);

int main(void){
    ABC98();
}

void ABC98(){
    int n,i,j,c=0,max=0;
    string s;
    char cha='\0';
    cin>>n>>s;
    for(i=1;i<n;i++){
        string a=s.substr(0,i);
        string b=s.substr(i,n);
        sort(a.begin(),a.end());
        for(j=0;j<a.size();j++){
            if(a[j]!=cha){
                cha=a[j];
                if(count(b.begin(),b.end(),cha)>=1)c++;
            }
        }
        if(c>max)max=c;
        c=0;
        cha='\0';
    }
    cout<<max<<endl;
}

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

// @@ !! LIM()

int main(int argc, char *argv[]) {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cout << setprecision(20);

  ll N; cin >> N;
  cout << N / 3 << endl;

  return 0;
}



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



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

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

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














int main(){
    ll n;
    cin >> n;
    if(n == 0) cout << 1 << endl;
    else if(n == 1) cout << 2 << endl;
    else if(n == 2) cout << 1 << endl;
    else cout << 0 << endl;
}


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

#define db double
#define RG register
#define ll long long

inline ll gi()
{
	RG ll r=0; RG bool b=true; RG char c=getchar();
	while (c < '0' || c > '9')
		c == '-' ? b=false : 0, c=getchar();
	while (c >= '0' && c <= '9')
		r=(r<<1)+(r<<3)+c-'0', c=getchar();
	return b ? r : -r;
}

const int N=142857,inf=1<<30;

struct bottle
{
	ll cst;
	db val,lit;
	bool operator < (const bottle &B) const { return val < B.val; }
}b[5];
int n,er[]={0,1,2,4,8};
ll ans;

int main()
{
	for (int i=1; i<=4; ++i)
		b[i].cst=gi(), b[i].val=(db)b[i].cst/er[i], b[i].lit=er[i]*0.25;
	n=gi();
	sort(b+1,b+5);
	if (b[1].lit <= 1)
		printf("%lld\n",b[1].cst*(int)(n/b[1].lit));
	else
		{
			ans=(int)n/b[1].lit, n-=(int)ans*b[1].lit, ans*=b[1].cst;
			ans+=(int)(n/b[2].lit)*b[2].cst;
			printf("%lld\n",ans);
		}
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include <string>
#include <algorithm>

using namespace std;
int main()
{
    int n,a,b,i;
    int h[120000];
    cin >> n >> a >> b;
    int diff = a-b;
    int left,right,current;
    int maxh = -1;
    long count = 0;
    for (i=0;i<n;i++){
        cin >> h[i];
        if (maxh < h[i]) maxh = h[i];
    };
    int maxt = maxh / b + 1;
    left = 1;
    right = maxt;
    while (left<right){
        current = (left + right) / 2;
        count = 0;
        for  (i=0;i<n;i++){
            count += max (0,(h[i] - current * b + diff - 1) / diff);
        };
        if (count > current){
            left = current;
            if (right - left == 1){
              cout << right;
              return 0;
            };
        }
        else if (count < current){
            right = current;
        }
        else {
            cout << current; 
            return 0;
        };
    };
    cout << left;
    return 0;
}

Measured memory_bytes: 640
N, K = map(int, input().split())
H = [int(i) for i in input().split()]

inf = float('inf')
dp = [inf] * N
dp[0] = 0
dp[1] = abs(H[1] - H[0])

for i in range(2, N):
    for k in range(1, K + 1):
        dp[i] = min(dp[i], dp[i - k] + abs(H[i] - H[i - k]))
    
print(dp[-1])

Measured memory_bytes: 55392
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;
typedef long long ll;
#define rep(i,n) for (int i=0;i < (int)(n);i++)

int main(){
 int a=0,b=0;
 string s;
 cin >> s;
 rep(i,3){
   if (s[i]=='A') a++;
   else b++;
 }
 if ( a > 0 && b > 0) cout << "Yes" <<endl;
 else cout << "No" << endl;
 return 0; 
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#ifdef LOCAL
#include "debug.h"
#else
#define dump(...)
#endif
#define endl '\n'
#define ll long long
#define FOR(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define REP(i, x) for (int i = 0; i < (int)(x); i++)
#define REPS(i, x) for (int i = 1; i <= (int)(x); i++)
#define RREP(i, x) for (int i = ((int)(x)-1); i >= 0; i--)
#define RREPS(i, x) for (int i = ((int)(x)); i > 0; i--)
#define INF 2147483647
#define LLINF 9223372036854775807LL
#define vi vector<int>
#define vvi vector<vector<int>>
#define pi pair<int, int>
#define ALL(a) (a).begin(), (a).end()
#define BIT(n) (1LL << (n))
#define TOUPPER(s) transform(s.begin(), s.end(), s.begin(), ::toupper)
#define TOLOWER(s) transform(s.begin(), s.end(), s.begin(), ::tolower)
#define FILLZERO(s, n)                      \
    do {                                    \
        ostringstream os;                   \
        os << setw(n) << setfill('0') << s; \
        s = os.str();                       \
    } while (0);
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end()) //sortしてからつかうこと
#define INIT                               \
    std::cin.tie(nullptr);                 \
    std::ios_base::sync_with_stdio(false); \
    cout << std::fixed << std::setprecision(10);

template <typename T>
vector<T> make_vec(size_t a, T n) { return vector<T>(a, n); }
template <typename T, typename... Ts>
auto make_vec(size_t a, Ts... ts) { return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...)); }
template <class T>
inline bool chmax(T &a, T b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
inline bool chmin(T &a, T b) {
    if (a > b) {
        a = b;
        return 1;
    }
    return 0;
}
template <typename T>
istream &operator>>(istream &is, vector<T> &vec) {
    for (T &x : vec)
        is >> x;
    return is;
}

constexpr ll MOD = 1e9 + 7;
int dx[8] = {1, 0, -1, 0, 1, 1, -1, -1};
int dy[8] = {0, 1, 0, -1, 1, -1, 1, -1};
ll A, B, C, D, E, F, G, H, N, M, L, K, P, Q, R, W, X, Y, Z;
string S, T;
ll ans = 0;

signed main() {
    INIT;
    cin >> A >> B >> C;
    map<int, int> mp;
    mp[A]++, mp[B]++, mp[C]++;
    cout << mp.size() << endl;
}

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

#define PI 3.1415926535897932
#define MOD 1000000007
#define INF 1e9

#define REP(i, n) for(int i = 0; i < (n); i++)
#define REP1(i, n) for(int i = 1; i <= (n); i++)
#define ALL(v) (v).begin(), (v).end()

using namespace std;

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


void solve()
{
    int N; cin >> N;
    string S = "";
    if(N == 0)
    {
        cout << 0 << endl;
        return;
    }
    while(abs(N) > 0)
    {
        int r = N % 2;
        if(r < 0) r += 2;
        N -= r;
        S.push_back('0' + r);
        N /= -2;
    }
    reverse(ALL(S));
    cout << S << endl;
}

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

    solve();

    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ

		Scanner sc1 = new Scanner(System.in);

		String n = sc1.next();
		int intn = Integer.parseInt(n);
		int sn = 0;

		for (int i = 0 ; i < n.length() ; i++) {
			sn += Character.getNumericValue(n.charAt(i));
		}

		//System.out.println(sn);

		if ( intn % sn == 0) {
			System.out.println("Yes");
		}
		else {
			System.out.println("No");
		}

		sc1.close();
	}
}

Measured memory_bytes: 21844
#include<bits/stdc++.h>
using namespace std;
using ll = int64_t;
bool po(ll n){
    for(ll i = 2; i <= sqrt(n) + 1; i++) if(n % i == 0) return false;
    return true;
}
int main(){
    ll N;
    cin >> N;
    ll yo = 11;
    for(ll i = 0; i < N; i++){
        while(!po(yo) || yo % 5 != 1) yo++;
        cout << yo++ << ' ';
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ALL(c) (c).begin(),(c).end()
#define EACH(i,c) for(auto i=(c).begin();i!=(c).end();++i)
using namespace std;
typedef long long ll;
#define int long long

bool possible(const vector<int> &A, int K, int Q, int l, int u) {
	int p = 0;
	int sum = 0;

	while(p < A.size()) {
		int q = p;
		int cnt = 0;
		while(q < A.size() && l <= A[q]) {
			if (A[q] <= u) {
				++cnt;
			}
			q++;
		}
		if (q - p >= K) sum += min(cnt, (q - p) - K + 1);

		p = q + 1;
	}

	return sum >= Q;
}

signed main(){
	int N, K, Q;
	cin >> N >> K >> Q;
	vector<int> A(N);
	for(int i = 0; i < N; ++i) {
		cin >> A[i];
	}

	int res = (int)(1e9 + 10);
	for(int i = 0; i < N; ++i) {
		int l = 0, u = (int)1e+9 + 10;
		while(u - l > 1) {
			int c = (u + l) / 2;
			if(possible(A, K, Q, A[i], c)) {
				u = c;
			} else {
				l = c;
			}
		}
		if (u < 1e+9 + 5) res = min(res, u - A[i]);
	}
	cout << res << endl;
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define pb push_back
#define IO ios_base::sync_with_stdio(false);  cin.tie(NULL);
#define ll long long int
const ll MOD=1e9+7;
using namespace std;
int main()
{
	IO;
	string a;
	cin>>a;
	if(a[2]==a[3]&&a[4]==a[5])
	{
		cout<<"Yes";
	}
	else
	{
		cout<<"No";
	}
}

Measured memory_bytes: 256
using System;
using System.Linq;//リストの使用
using System.Collections.Generic;
using System.Text;//テキストの高速出力に必要
class Program
{
	static void Main()
  {
		int[] s = Array.ConvertAll(Console.ReadLine().Split(),int.Parse);
		long[,] h = new long[s[0]*s[1]+1, 2];//1~h*wの(x,y)
		long[] a = new long[s[0]*s[1]+1];//0~h*w
		long[][] arr = new long[s[0]][];//h
		for(int i = 0; i < s[0]; i++)//h
    {
			arr[i] = Array.ConvertAll(Console.ReadLine().Split(),long.Parse);
			for(int j = 0; j < s[1]; j++)//w
      {
				h[arr[i][j],0] = i;
				h[arr[i][j],1] = j;
			}
		}
		for(int i = 1; i <= s[0]*s[1]-s[2]; i++)//1~h*w-d
    {
			a[i+s[2]] = Math.Abs(h[i+s[2],0] - h[i,0]) + 
        Math.Abs(h[i+s[2],1] - h[i,1]) + a[i];//d前からDP
		}
		int n = int.Parse(Console.ReadLine());//q
		for(int i = 0; i < n; i++)//q
    {
			int[] q = Array.ConvertAll(Console.ReadLine().Split(),int.Parse);
			Console.WriteLine(a[q[1]] - a[q[0]]);
		}
	}
}


Measured memory_bytes: 18496
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <unordered_map>
#include <queue>
#include <algorithm>

#include <bits/stdc++.h>
#include <cmath>
#include <limits>

using namespace std;
typedef long long LL;
using Graph = vector<vector<int>>;

static long long INF = (1LL<<62);

LL N, M;
int main(int argc, char* argv[]){
	cin.tie(0);
	ios::sync_with_stdio(false);

	cin >> N >> M;

	if(N == 1){
		printf("%lld\n", M);
		return 0;
	}

	vector<LL> D;
	for(LL d = 2; d * d <= M; d++){
		if((M % d) == 0){
			D.push_back(d);
			D.push_back(M/d);
		}
	}
	sort(D.begin(), D.end());

	long long ans = 1;
	for(int i=D.size()-1; i>=0; i--){
		if( (M / D[i]) >= N && D[i] > ans){
			ans = D[i];
		}
	}

	printf("%lld\n", ans);
	return 0;
}


Measured memory_bytes: 3732
n,k=map(int,input().split())
r,s,p=map(int,input().split())
t=input()
d={'r':p,'s':r,'p':s}
d_={'r':'p','s':'r','p':'s'}
s=0
for i in range(k):
  a=0
  z='0'
  t_=t[i::k]
  for a in range(len(t_)):
    if a==0:
      s+=d[t_[a]]
      z=d_[t_[a]]
      a+=1
    else:
      if z==d_[t_[a]]:
        z='0'
        a+=1
      else:
        s+=d[t_[a]]
        z=d_[t_[a]]
        a+=1
print(s)   


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

int main() {
    int n,m,q;
    cin >> n >> m >> q;
    vector<int> a(q);
    vector<int> b(q);
    vector<int> c(q);
    vector<int> d(q);
    for (int i=0; i<q; i++)
        cin >> a[i] >> b[i] >> c[i] >> d[i];

    vector<int> vec(10);
    ll ans = 0;
    for (int x1=1; x1<=m; x1++) {
        vec[0] = x1;
        for (int x2=x1; x2<=m; x2++) {
            vec[1] = x2;
            for (int x3=x2; x3<=m; x3++) {
                vec[2] = x3;
                for (int x4=x3; x4<=m; x4++) {
                    vec[3] = x4;
                    for (int x5=x4; x5<=m; x5++) {
                        vec[4] = x5;
                        for (int x6=x5; x6<=m; x6++) {
                            vec[5] = x6;
                            for (int x7=x6; x7<=m; x7++) {
                                vec[6] = x7;
                                for (int x8=x7; x8<=m; x8++) {
                                    vec[7] = x8;
                                    for (int x9=x8; x9<=m; x9++) {
                                        vec[8] = x9;
                                        for (int x10=x9; x10<=m; x10++) {
                                            vec[9] = x10;
                                            ll sum = 0;
                                            for (int i=0; i<q; i++) {
                                                if (vec[b[i]-1] - vec[a[i]-1] == c[i])
                                                    sum += d[i];
                                            }
                                            ans = max(ans, sum);
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3604
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define llu unsigned long long int
#define Endl endl
#define mod  998244353
#define mkp make_pair
#define pb push_back
#define cin(n) scanf("%d",&n)
#define cout(n) printf("%d ",n)
#define sf(n) scanf("%d",&n)
#define pf(n) printf("%d ",n)
#define bitget(n) __builtin_popcountll(n)
ll dx[] = {1,1,0,-1,-1,-1,0,1};
ll dy[] = {0,-1,-1,-1,0,1,1,1};
ll dxx[] = {1,-1,0,0};
ll dyy[] = {0,0,-1,1};
ll modexpo(ll x,ll y){if(y==0)return 1;if(y%2){ll viky=modexpo(x,y/2);
return (((x*viky)%mod)*viky)%mod;}else{ll viky=modexpo(x,y/2);return (viky*viky)%mod;
}}
bool isvalid(ll x,ll y,ll n, ll m) { return (x>=0&&x<n&&y>=0&&y<m); }
ll ans[10001];

int main() {
    // #ifndef ONLINE_JUDGE
    //     freopen("input.txt", "r", stdin);
    //     freopen("output.txt", "w", stdout);
    // #endif
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    ll n;

    cin>>n;

    for(ll i = 1; i <= 200; i++){

        for(ll j = 1; j <= 200; j++){

            for(ll k = 1; k <= 200; k++){

                ll val = i*i + j*j + k*k + i*j + i*k + j*k;
                if(val <= 10000){

                    ans[val]++;
                }
            }
        }
    }

    for(ll i = 1; i <= n; i++){
    
        cout<<ans[i]<<"\n";
    }

    return 0;
}

Measured memory_bytes: 3676
#include<bits/stdc++.h>
#define int long long
#define f(i,n) for(int i=0;i<n;i++)
#define F first
#define S second
#define mod 1000000007
#define P pair<int,int>
using namespace std;
signed main(){
	int a,b,c,d,e,ans=0;
	cin>>a>>b>>c;
	f(i,a){
		cin>>d;
		if(i){
			ans+=min((d-e)*b,c);
		}
		e=d;
	}
	cout<<ans<<endl;
	return 0;
}


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

d = {}
for _ in range(N):
  s = input()
  if s in d:
    d[s] += 1
  else:
    d[s] = 1
    
d = {k: v for k, v in sorted(d.items(), key=lambda item: item[1], reverse=True)}

max_count = -1
values = []
for k, v in d.items():
  if max_count < v:
    max_count = v
  if v != max_count:
    break
  values.append(k)

print("\n".join(sorted(values)))

Measured memory_bytes: 66360
import string
import itertools
n = int(input())
s = n
l = list(string.ascii_lowercase)
count = 1
for i in range(1, 100):
    s -= 26 ** i
    if s <= 0:
        break
    else:
        count += 1
n_list = []
answer = []
for i in reversed(range(1, count+1)):
    number = min(26, n // 26 ** (i-1))
    n -= number * 26 ** (i-1)
    n_list.append(number)
n_l = []
for i, x in  enumerate(reversed(n_list)):
    if x <= 0:
        n_l.append(x + 26)
        n_list[-(i+2)] -= 1
    else:
        n_l.append(x)
for i in reversed(n_l):
    answer.append(l[i-1])
print(''.join(answer))


Measured memory_bytes: 9920
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define rrep(i,n) for(int i=1;i<=n;i++)
#define dpb push_back
#define fi first
#define se second
typedef pair<int,int> P;
typedef pair<int, P> PP;
const int inf = 1e9;

#define int long long
signed main(){
	int n, k;
	scanf("%lld%lld", &n, &k);
	int ans = 0;
	for(int b = 1;b <= n;b++){
		if(k >= b)continue;
		int a = n;
		int x = (b-k)*(a/b);
		//int y = 0;
		int y = max((int)0, (a%b-k+1));
		if(k == 0)y = max((int)0, (a%b-k));
		ans += x+y;
		//printf("%lld %lld %lld\n", b, x, y);
	}
	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int i = sc.nextInt();
        long l = 0;
        for(int j=0;j<i;j++){
            if((j+1)%3 != 0 && (j+1)%5 != 0){
                l += j+1;
            }
        }
        System.out.println(l);
    }
}


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

int main() {
    int n, k;
    long long cnt = 0;
    cin >> n >> k;
    vector<int> h(n);
    rep(i, n){
        cin >> h[i];
    }
    sort(h.begin(), h.end());
    rep(i,(n-k)) {
        cnt += h[i];
    }
    cout << cnt << endl;
    return 0;
}


Measured memory_bytes: 1024
#include <stdio.h>
int main()
{
    int r,x,xnew[100],i,d,sum=0;
    scanf("%d%d%d",&r,&d,&x);

    for(i=0;i<10;i++)
    {
        {
        sum=(r*x-d);
        printf("%d\n",sum);
        x=sum;
        }
    }
}



Measured memory_bytes: 1704
def main():
    N, M, Q = map(int, input().split())
    LR = [[0] * (N + 1) for _ in range(N + 1)]

    for _ in range(M):
        l, r = map(int, input().split())
        l, r = l - 1, r - 1
        LR[0][r] += 1
        LR[l + 1][r] -= 1
    for r in range(N):
        t = 0
        for l in range(N):
            t += LR[l][r]
            LR[l][r] = t
    for l in range(N):
        t = 0
        for r in range(N):
            t += LR[l][r]
            LR[l][r] = t
    for _ in range(Q):
        p, q = map(int, input().split())
        p, q = p - 1, q - 1
        print(LR[p][q])
main()


Measured memory_bytes: 9332
#include <stdio.h>
#include <ctype.h>
#include <string.h>
int main(void)
{
  char str[1500];
  int n;
  int i;
  
  fgets(str,1200,stdin);
  n=strlen(str);
  for (i=0; i<n; i++) {
    if ('a'<=str[i] && str[i]<='z') {
      str[i]=toupper(str[i]);
    }
    else if ('A'<=str[i] && str[i]<='Z') {
      str[i]=tolower(str[i]);
    }
  }
  printf("%s",str);
  return 0;
}

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

vector<int> C(26, 0); // C[i]
vector<vector<int> > S(365, vector<int>(26, 0)); // S[d][i]
int D;
int N;

int score(vector<int> V) {
	vector<int> c = C;
	int s = 0;
	for (int d = 0; d < D; d++) {
		c[V[d]] = 0;
		s += S[d][V[d]];
		s -= accumulate(c.begin(), c.end(), 0);
		for (int i = 0; i < N; i++) {
			c[i] += C[i];
		}
	}
	return s;
}

int ls1(int d, int i, int ci, int Ci) {
	return S[d][i] + 5 * ci;
}

int ls(int a, int b, int x, int d, int i, int ci, int Ci) {
	return S[d][i] - x * (S[min(D-1,d+1)][i] + S[min(D - 1, d + 2)][i])/100 + a * ci - b * Ci;
}

vector<int> findmin(int a, int b, int x) {
	vector<int> V(D, 0);
	vector<int> c = C;
	int s = 0;
	for (int d = 0; d < D; d++) {
		int mi = 0;
		for (int i = 0; i < N; i++) {
			if (ls(a, b, x, d,mi,c[mi],C[mi]) < ls(a, b, x, d, i, c[i], C[i])) mi = i;
		}
		V[d] = mi;
		c[V[d]] = 0;
		s += S[d][V[d]];
		s -= accumulate(c.begin(), c.end(), 0);
		for (int i = 0; i < N; i++) {
			c[i] += C[i];
		}
	}
	return V;
}

int main() {
	cin >> D;
	N = 26;
	for (int i = 0; i < N; i++) {
		cin >> C[i];
	}
	for (int d = 0; d < D; d++) {
		for (int i = 0; i < N; i++) {
			cin >> S[d][i];
		}
	}
	vector<int> V(D, 0);
	for (int d = 0; d < D; d++) {
//		cin >> V[d];
//		V[d]--;
		int i = 0;
		for (int j = 1; j < N; j++) {
			if (S[d][i] < S[d][j]) i = j;
		}
		V[d] = i;
	}

	vector<int> sV = findmin(0,0,0);
	if (score(V) < score(sV)) V = sV;

	for (int a = 0; a < 10; a++) {
		for (int b = 0; b < 50; b++) {
			for (int x = 0; x <= 20; x++) {
				sV = findmin(a, b, x);
				if (score(V) < score(sV)) {
					V = sV;
//					cerr << "a = " << a << ", b = " << b << ", x = " << x << ", s = " << score(V) << endl;
				}
			}
		}
	}


	/*
	random_device seed_gen;
	mt19937 engine(seed_gen());
	uniform_real_distribution<> dist1(0.0, 1.0);
	vector<int> newV = V;
	int ms = score(V);
	for (int j = 0; j < 100000; j++) {
		newV = V;
		for (int k = 0; k < 1; k++) {
			int d1 = int(dist1(engine) * D);
			int d2 = min(D-1, d1 + int(dist1(engine) * 3));
			newV[d1] = V[d2];
			newV[d2] = V[d1];
		}
		int ns = score(newV);
		if (ms < ns) V = newV;
	}
	*/

	for (int d = 0; d < D; d++) {
		cout << V[d] + 1 << endl;
	}
	cerr << score(V) << endl;
  	return(0);
}


Measured memory_bytes: 3688
N = int(input())
S = []
for i in range(N):
    s = list(input())
    S.append(s)
ans = []
for az in "abcdefghijklmnopqrstuvwxyz":
    cnt_min = float("inf")
    for i in range(N):
        cnt = S[i].count(az)
        if cnt < cnt_min:
            cnt_min = cnt
    for i in range(cnt_min):
        ans.append(az)
print("".join(ans))

Measured memory_bytes: 3064
n,m,k=map(int,input().split())

import sys
sys.setrecursionlimit(10**9) #再帰の上限をあげる

root=[-1 for i in range(n+1)] #自分が親ならグループの人数のマイナス倍を、そうでないなら（元）親の番号を示す

def r(x):   #親は誰？
    if root[x]<0:
        return x
    else:
        root[x]=r(root[x])
        return root[x]

def unite(x,y):
    x=r(x)
    y=r(y)
    if x==y:
        return
    if x>y:
        x,y=y,x
    root[x]+=root[y]
    root[y]=x


fre=[[] for _ in range(n+1)]
bro=[[] for _ in range(n+1)]

for i in range(m):
    a,b=map(int,input().split())
    unite(a,b)
    fre[a].append(b)
    fre[b].append(a)

for i in range(k):
    a, b = map(int, input().split())
    bro[a].append(b)
    bro[b].append(a)

ans=[]
for i in range(1,n+1):
    anser=-root[r(i)]-1
    anser-=len(fre[i])
    for j in bro[i]:
        if r(i)==r(j):
            anser-=1
    ans.append(str(anser))
print(" ".join(ans))




Measured memory_bytes: 113516
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
import math


def inputIntList():
  return [int(s) for s in input().split()]


def inputInt():
  return int(input())


def main():
  H, N = inputIntList()
  A = inputIntList()
  ans = 'Yes' if sum(A) >= H else 'No'
  return ans


if __name__ == "__main__":
  print(main())


Measured memory_bytes: 14012
parseInt(x) = parse(Int, x)
parseMap(x::Array{SubString{String},1}) = map(parseInt, x)

function main()
S = chomp(readline())
K = parseInt(readline())
one_flag = true
one_count = 0
for i in S
    if i != '1'
        one_flag = false
    end
    if i != '1' 
        return i
    elseif one_flag
        one_count += 1
        if one_count >= K
            return 1
        end
    end            
end    
end

println(main())

Measured memory_bytes: 109696
N, M = map(int, input().split())

def make_yakusuu(n):
  yakusuu=[]
  for i in range(1,int(n**0.5)+1):
    if n%i == 0:
      yakusuu.append(i)
      if i != n//i:
        yakusuu.append(n//i)      
  yakusuu.sort(reverse = True)
  return yakusuu

list=make_yakusuu(M)
A=list[0]
result=1
i=0
while(A>1):
  if (N<=M/A):
    result=A
    break
  else:
    i+=1
    A=list[i]
    
print(result)

Measured memory_bytes: 3064
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

public class AtCoderA
{
    static void Main()
    {
        var sc = new Scanner();

        long h = sc.NextLong();
        long w = sc.NextLong();

        string answer = "";
        for (int i = 0; i < h; i++)
        {
            for (int j = 0; j < w; j++)
            {
                string str = sc.Next();
                if (str == "snuke")
                {
                    answer = ((char)('A' + j)).ToString() + (i + 1);
                }
            }
        }

        Console.WriteLine(answer);
    }

    class Scanner
    {
        private string[] _line;
        private int _index;
        private const char Separator = ' ';

        public Scanner()
        {
            _line = new string[0];
            _index = 0;
        }

        public string Next()
        {
            while (_index >= _line.Length)
            {
                _line = Console.ReadLine().Split(Separator);
                _index = 0;
            }

            return _line[_index++];
        }

        public int NextInt() => int.Parse(Next());
        public long NextLong() => long.Parse(Next());
        public double NextDouble() => double.Parse(Next());
        public decimal NextDecimal() => decimal.Parse(Next());
        public char NextChar() => Next()[0];
        public char[] NextCharArray() => Next().ToCharArray();

        public string[] Array()
        {
            _line = Console.ReadLine().Split(Separator);
            _index = _line.Length;
            return _line;
        }

        public int[] IntArray() => Array().Select(int.Parse).ToArray();
        public long[] LongArray() => Array().Select(long.Parse).ToArray();
        public double[] DoubleArray() => Array().Select(double.Parse).ToArray();
        public decimal[] DecimalArray() => Array().Select(decimal.Parse).ToArray();
    }
}


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

using namespace std;

typedef long long ui;

char s[100005];

int main() {
	scanf("%s", s + 1);
	int n = strlen(s + 1);
	int m = (n - 1) / 2;
	bool flag = true;
	for (int i = 1; i <= m; i++)
		if (s[i] != s[n - i + 1])
			flag = false;
	for (int i = 1; i + i <= m; i++)
		if (s[i] != s[m - i + 1])
		 flag = false;
	for (int i = 1; i + i <= m; i++)
		if (s[m + 1 + i] != s[n - i + 1])
			 flag = false;
	if (flag == true)
		printf("Yes\n");
	else
		printf("No\n");
	return 0;
}

Measured memory_bytes: 256
a, b = map(int, input().split())
c = [True] * a
d = [True] * b
f = []
for i in range(a):
    e = input()
    g = []
    for j in range(b):
        g.append(e[j])
        if e[j] == "#":
            if c[i]:
                c[i] = not c[i]
            if d[j]:
                d[j] = not d[j]
    f.append(g)
for i in range(len(c)):
    if not c[i]:
        h = ""
        for j in range(len(d)):
            if not d[j]:
                h += f[i][j]
        print(h)


Measured memory_bytes: 3188
#include <bits/stdc++.h>
#define forn(i, n) for (long long i = 0; i < (long long)(n); ++i)
#define for1(i, n) for (long long i = 1; i <= (long long)(n); ++i)
#define fore(i, l, r) for (long long i = (long long)(l); i <= (long long)(r); ++i)
#define fordn(i, n) for (long long i = (long long)(n) - 1; i >= 0; --i)
#define ford1(i, n) for (long long i = (long long)(n); i >= 1; --i)
#define all(x) (x).begin(), (x).end()
#define PI 3.141592653589793
using namespace std;
using ll = long long;
using ld = long double;

int main(){
    ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    ll n, m;
    cin >> n >> m;
    vector<pair<ll, ll>> vp(n);
    forn(i, n) cin >> vp[i].first >> vp[i].second;
    sort(all(vp));
    ll mm = m, ans = 0;
    forn(i, n){
        if(mm){
            int t = min(mm, vp[i].second);
            ans += vp[i].first * t;
            mm -= t;
        }
    }
    cout << ans << endl;
}

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

using namespace std;

#define int long long
#define endl "\n"

const long long INF = (long long)1e18;
const long long MOD = (long long)1e9 + 7; 

string yn(bool f){return f?"Yes":"No";}
string YN(bool f){return f?"YES":"NO";}

#define MAX

signed main(){
	// cin.tie(0);
	// ios::sync_with_stdio(false);
	// cout<<fixed<<setprecision(10);
	
	int N, R;
	vector<int> P, used, dp;
	vector<pair<int,int>> num;
	map<int,int> mp;
	
	cin>>N>>R;
	
	P.resize(N+1);
	used.resize(N+10,false);
	
	for(int i = 1; i <= N; i++){
		cin>>P[i];
	}
	
	for(int i = 1; i <= N; i++){
		if(used[i]) continue;
		int con = 0, now = P[i];
		while(true){
			if(used[now])break;
			used[now] = true;
			now = P[now];
			con++;
		}
		mp[con]++;
		// num.push_back(con);
	}
	
	for(pair<int,int> p : mp){
		num.push_back(p);
	}
	
	dp.resize(min(R,N-R)+10,false);
	dp[0] = true;
	
	for(int i = 0; i < num.size(); i++){
		for(int j = dp.size()-1; j >= 0; j--){
			if(dp[j]){
				for(int k = j + num[i].first, l = 0; l < num[i].second &&  k < dp.size(); k += num[i].first, l++){
					if(dp[k]) break;
					dp[k] = true;
				}
			}
		}
	}
	cout<<yn(dp[min(R,N-R)])<<endl;
	
	return 0;
}


Measured memory_bytes: 8648
#include<iostream>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
using namespace std;
#define INF 1e9
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep2(i, n) for(int i = 0; i < n; i = i + 2)
#define repv(i, n, v) for(int i = 0; i < n; i = i + v)
#define rrep(i, n) for(int i = n; i >= 0; i--)
#define sortI(a, b, c) c == 0 ? sort(a, a + b) : sort(a, a + b, greater<int>())
#define sortS(s, a) a == 0 ? sort(s.begin(), s.end()) : sort(s.begin(), end(), greater<char>)
#define vi vector<int>
#define vf vector<float>
#define vc vector<char>
#define vs vector<string>
#define ll long long
#define lint long int
#define llint long long int

int digit(int n){
  int res = 0;
  while(n > 0){
    res += n%10;
    n /= 10;
  }
 
  return res;
}

int main(void){

  //入力
  int N;
  cin >> N;
  N *= 3;
  
  //配列
  int a[N];
  rep(i, N) cin >> a[i];
  
  //大きい順にソート
  sortI(a, N, 1);
  
  //3人の中の2人までをめっちゃ強いやつで固めて、あとはどうでもいい
  lint ans = 0;
  for(int i = 1; i < N * 2 / 3; i += 2){
    ans += a[i];
  }
  
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 1408
import java.util.*;
public class Main {

    public static void main(String[] args) {
        //data input
        Scanner sc = new Scanner(System.in);

        final int N = sc.nextInt();

        String S = sc.next();

        //logic
        if (N % 2 == 1) {
            System.out.println("No");
        } else {
            String T = S.substring(0, N/2);
            if (T.contains(S.substring(N/2, S.length()))) {
                System.out.println("Yes");
            }else {
                System.out.println("No");
            }
        }
    }
}

Measured memory_bytes: 23252
#include<bits/stdc++.h>
#define ll long long
#define all(s0) s0.begin(),s0.end()
#define ins(s0) inserter(s0,s0.begin())
using namespace std;
ll read()
{
    char ch=getchar();
    ll x=0,f=1;
    while(ch<'0' || ch>'9')
    {
        if(ch=='-')
            f=-1;
        ch=getchar();
    }
    while(ch>='0' && ch<='9')
    {
        x=x*10+ch-'0';
        ch=getchar();
    }
    return x*f;
}
int main()
{
    double pi=3.1415926;
    int n;
    cin>>n;
    cout<<2*n*pi<<endl;
    return 0;
}


Measured memory_bytes: 3764
import sys
a=[1]*500000
for i in range(3,999,2):
 if a[i//2]:a[(i*i)//2::i]=[0]*len(a[(i*i)//2::i])
[print([e-1,sum(a[:(e+1)//2])][e>3])for e in map(int,sys.stdin)]


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

int main() {
  int N;
  string S;
  cin >> N >> S;
  
  for (int i = 0; i < S.size(); ++i) {
    S[i] += N;
    if (S[i] > 'Z') S[i] -= 26;
  }
  
  cout << S << endl;
  return 0;
}

Measured memory_bytes: 256