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

# define REP(i,n) for (int i=0;i<(n);++i)
# define rep(i,a,b) for(int i=a;i<(b);++i)
# define p(s) std::cout << s ;
# define pl(s)  std::cout << s << endl;
# define printIf(j,s1,s2) cout << (j ? s1 : s2) << endl;
# define YES(j) cout << (j ? "YES" : "NO") << endl;
# define Yes(j) std::cout << (j ? "Yes" : "No") << endl;
# define yes(j) std::cout << (j ? "yes" : "no") << endl;
# define all(v) v.begin(),v.end()
# define showVector(v) REP(i,v.size()){p(v[i]);p(" ")} pl("")
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;}
typedef long long int ll;
typedef pair<ll,ll> P_ii;
typedef pair<double,double> P_dd;

template<class T>
vector<T> make_vec(size_t a){
    return vector<T>(a);
}

template<class T, class... Ts>
auto make_vec(size_t a, Ts... ts){
  return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}

template<typename T,typename V>
typename enable_if<is_class<T>::value==0>::type
fill_v(T &t,const V &v){t=v;}

template<typename T,typename V>
typename enable_if<is_class<T>::value!=0>::type
fill_v(T &t,const V &v){
  for(auto &e:t) fill_v(e,v);
}


const int MOD = 1000000007;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;

void addM(long long &a, long long b) {
    a += b;
    if (a >= MOD) a -= MOD;
}

void mulM(long long &a, long long b) {
    a = ((a%MOD)*(b%MOD))%MOD ;
}

// a^b mod M
long myPow(long a,long b,int M) {
    long ret = 1;
    long tmp = a;
    while(b>0) {
        if((b&1)==1) ret = (ret * tmp) % M;
        tmp = (tmp * tmp) % M;
        b = b>>1;
    }
    return ret;
}

 // nCk mod M
int nCk(int n,int k,int M) {
    long ret = 1;
    int mi = min(k, n-k);
    for(int i=1;i<=mi;i++) {
        ret = (ret * myPow(i,M-2,M)) % M;
    }
    for(int i=n-mi+1;i<=n;i++) {
        ret = (ret * i) % M;
    }
    return (int)ret;
};

vector<pair<long long, long long> > prime_factorize(long long n) {
    vector<pair<long long, long long> > res;
    for (long long p = 2; p * p <= n; ++p) {
        if (n % p != 0) continue;
        int num = 0;
        while (n % p == 0) { ++num; n /= p; }
        res.push_back(make_pair(p, num));
    }
    if (n != 1) res.push_back(make_pair(n, 1));
    return res;
}


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

    YES(N >= 2*K-1)

    return 0;
}

Measured memory_bytes: 384
#include<stdio.h>

int main(void){
    int N;
    scanf("%d", &N);
    int L[2*N];
    for(int i=0;i<2*N;i++){
        scanf("%d", &L[i]);
    }
    int M=0;
    for(int i=0;i<2*N-1;i++){
        for(int j=0;j<2*N-1;j++){
            if(L[j]>L[j+1]){
                int z;
                z = L[j+1];
                L[j+1] = L[j];
                L[j] = z;
            }
        }
    }
    for(int i=0; i<N; i++){
        M += L[2*i];
    }
    printf("%d\n", M);
    return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include <algorithm>
#include <stdlib.h>
#include <string>
#include <vector>
#include <map>
#include <functional>
#include <iomanip>
#include <queue>

#define PI 3.14159265358979
#define MOD 1000000007

//fixed << setprecision(15) <<

using namespace std;

int main(void) {
	long long int a, b, l, m, n;
	int x[100000], y[100000];
	string s, t;
	char u;
	int i, j, k;
	bool flag = true;
	cin >> a >> b >> n;
	if (b - 1 > n)
	{
		cout << a * n / b << endl;
	}

	else cout << a * (b - 1) / b << endl;
	return 0;
}

Measured memory_bytes: 3624
#include <iostream>
using namespace std;
void f(int c[],int r) {
	if (r < 400) c[0]++;
	else if (r < 800) c[1]++;
	else if (r < 1200) c[2]++;
	else if (r < 1600) c[3]++;
	else if (r < 2000) c[4]++;
	else if (r < 2400) c[5]++;
	else if (r < 2800) c[6]++;
	else if (r < 3200) c[7]++;
	else c[8]++;
}
int main() {
	int n, c[9],r[101];
	cin >> n;
	for (int i = 0; i < 9; i++) {
		c[i] = 0;
	}
	for (int i = 0; i < n; i++) {
		cin >> r[i];
		f(c, r[i]);
	}
	int min, max;
	min = 0; max = 0;
	for (int i = 0; i < 8; i++) {
		if (c[i] != 0) min++;
	}
	max = min + c[8];
	if (min == 0)min++;
	cout << min << ' ' << max << endl;
	return 0;
}

Measured memory_bytes: 256
import sys
import copy
import math
import bisect
import pprint
import bisect
from functools import reduce
from copy import deepcopy
from collections import deque
from decimal import *


def lcm(x, y):
    return (x * y) // math.gcd(x, y)


if __name__ == '__main__':
    a = [int(i) for i in input().split()]
    print(str(a[2]) +" " + str(a[0])+" "+str(a[1]))


Measured memory_bytes: 5784
#include<bits/stdc++.h>
using namespace std; 
using lint  =                           long long int;
using pint  =                           pair<int, int>;
using plint =                           pair<lint, lint>;
#define vli                             vector<lint>
#define pb                              push_back
#define ALL(x)                          begin(x),end(x)
#define inf                             (1LL<63)-1
#define MOD                             1000000007
#define SZ(x)                           ((lint)(x).size())
#define                                 FOR(i, begin, end) for(int i=(begin),i##_end_=(end);i<i##_end_;i++)
#define                                 IFOR(i, begin, end) for(int i=(end)-1,i##_begin_=(begin);i>=i##_begin_;i--)
#define                                 REP(i, n) FOR(i,0,n)
#define                                 IREP(i, n) IFOR(i,0,n)
#define                                 f_ip   ios_base::sync_with_stdio(false); cin.tie(NULL);
#define                                 debug(x) cerr << #x << " " << (x) << endl
struct fast_ios                         { fast_ios(){ cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;
template<typename T>                    istream &operator>>(istream &is, vector<T> &vec){ for (auto &v : vec) is >> v; return is; }
template<typename T>                    bool mmax(T &m, const T q) { if (m < q) {m = q; return true;} else return false; }
template<typename T>                    bool mmin(T &m, const T q) { if (q < m) {m = q; return true;} else return false; }


/* -------
         |
    **   |
   -------      
   |
   ---------------------------------------------------------------------------------------------------------------------------------*/

void solve(){  
    int K;
    cin >> K;

    int _G = 1;
    int ret = 0;
    REP(i,K) {
        REP(j,K) {
            REP(k,K){
                 int one = i + 1;
                 int two = j + 1;
                 int three = k + 1;

                 int temp = __gcd(__gcd(one,two),three);
                 ret += temp;
            }
        }
    }
    cout << ret << endl;
}

int main(){   
  
 solve();

 return 0;
}


Measured memory_bytes: 3648
#include<stdio.h>
int main(void)
{
  int S;
  scanf("%d",&S);
  
  int mae,ushiro;
  
  mae=((S/1000)*10)+(S/100)%10;
  ushiro=(S%1000)%100;
  
  if((1<=mae && mae<=12) && (!(1<=ushiro&& ushiro<=12))){
    printf("MMYY");
  }else if(!(1<=mae && mae<=12) && (1<=ushiro&& ushiro<=12)){
    printf("YYMM");
  }else if((1<=mae && mae<=12) && (1<=ushiro&& ushiro<=12)){
    printf("AMBIGUOUS");
  }else{
    printf("NA");
  }
  
  return 0;
}

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

int main(){

  int n, m;
  cin >> n >> m;
  int sum = 0;
  vector<int> v(n);
  for(int i = 0; i < n; i++){
    cin >> v.at(i);
    sum += v.at(i);
  }
  int cnt = 0;
  sort(v.rbegin(), v.rend());
  for(int i = 0; i < m; i++){
    int num = v.at(i) * 4 * m;
    if(num >= sum){
      cnt++;
    }
  } 
  if(cnt == m){
	cout << "Yes";
  }else{
  	cout << "No";
  }
}

Measured memory_bytes: 256
from fractions import gcd

def check(A):
    g = reduce(gcd, A)
    if g != 1:
        return False
    s = sum(A)
    for a in A:
        if gcd(a, s - a) == 1:
            print a, s - a, gcd(a, s - a)

N = input()
M = 30000

if N == 3:
    print "2 5 63"
elif N == 4:
    print "2 5 20 63"
elif N == 5:
    print "2 3 4 9 12"
else:
    ans = [2, 4, 3, 9]
    a = 8
    b = 6
    c = 15
    while len(ans) < N:
        if N - len(ans) == 1:
            ans.append(b)
        elif a + 2 <= M:
            ans.append(a)
            ans.append(a+2)
            a += 6
        elif c + 6 <= M:
            ans.append(c)
            ans.append(c+6)
            c += 12
        else:
            ans.append(b)
            b += 6
    print ' '.join(map(str, ans))


Measured memory_bytes: 35176
#include "bits/stdc++.h"
using namespace std;

string st;
bitset<19>abitset;
bool get(int a, int b, int c, int d, int e, int f, int g) {
	a = abitset[a];
	b = abitset[b];
	c = abitset[c];
	d = abitset[d];
	e = abitset[e];
	f = abitset[f];
	g = abitset[g];
	return st[a + b * 2 + c * 4 + d * 8 + e * 16 + f * 32 + g * 64]-'0';
}

int main() {
	while (1) {
		 cin >> st;
		if (st == "#")break;
		else {
			
			bool ok = true;
			for (int i = 0; i < 1 << 19; ++i) {
				bitset<19>bs(i);
				
				bitset<19>nbs;
				abitset = bs;
				nbs[4] = get(9, 7, 6, 4, 2, 1, 0);
				nbs[6] = get(11, 9, 8, 6, 4, 3, 1);
				nbs[7] = get(12, 10, 9, 7, 5, 4, 2);
				nbs[9] = get(14, 12, 11, 9, 7, 6, 4);
				nbs[11] = get(16, 14, 13, 11, 9, 8, 6);
				nbs[12] = get(17, 15, 14, 12, 10, 9, 7);
				nbs[14] = get(18, 17, 16, 14, 12, 11, 9);
				bool aa = nbs[9];
				abitset = nbs;
				bitset<19>nnbs;
				nnbs[9] = get(14, 12, 11, 9, 7, 6, 4);
				bool ab = nnbs[9];
				if (aa != ab) {
					ok = false;
					break;
				}
			}
			if (ok)cout << "yes" << endl;
			else cout << "no" << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 3192
#include<iostream>
#include<vector>
#include<cmath>
#include<algorithm>
#include<utility>
#include<map>
#include<set>
#include<string>

using namespace std;

#define ll long long
ll H,W;
ll d[105][105];

int main(){
    ll n;
    cin >> H >> W;
    cin >> n;
    vector<ll> a(n);
    for(int i = 0; i < n; i++) cin >> a[i];

    int tmp = 0, k = 0;
    int c = 1;
    for(int i = 0; i < H; i++){
        for(int j = 0; j < W; j++){
            if(i % 2 == 0){
                d[i][j] = c;
                tmp++;
            }else{
                d[i][W - j - 1] = c;
                tmp++; 
            }
            // cout << a[k];
            if(a[k] == tmp){
                k++;
                tmp = 0;
                c++;
            }
        }
    }
    for(int i = 0; i < H; i++){
        for(int j = 0; j < W; j++){
            cout << d[i][j] << " ";
        }
        cout << endl;
    }
}


Measured memory_bytes: 512
import java.io.InputStream;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        Solver solver = new Solver();
        solver.solve(in, out);
        out.close();
    }

    static class Solver {
        public void solve(Scanner in, PrintWriter out) {
            int N = in.nextInt();
            int R = in.nextInt();

            out.println(N <= 10 ? 100 * (10 - N) + R : R);
        }
    }
}

Measured memory_bytes: 21972
#include<bits/stdc++.h>
using namespace std;
const int N=1e5+444;
int ddl,n;
vector<int>d[N];
priority_queue<int>q;
long long ans;	
int main(){
	ios::sync_with_stdio(0);
//	freopen("p.in","r",stdin);
//	freopen("p.out","w",stdout);
	cin>>n>>ddl;
	for(int i=1;i<=n;i++){
		int a,b;
		cin>>a>>b;
		d[a].push_back(b);
	}
	for(int i=ddl;i>=1;i--){
			int zl=q.size();
		if(d[ddl-i+1].size()){
			for(int j=0;j<d[ddl-i+1].size();j++){
				int dot=d[ddl-i+1][j];
				dot=dot;
				q.push(dot);
			}
		}
		if(q.size()){
			int az=q.top();
			q.pop();
			az=az;
			ans+=az;
		}
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 5632
#include<bits/stdc++.h>
using namespace std;
#define F(a,b,c) for(int a=b;a<c;++a) 
int main(){
	int n;cin>>n;
	map<string,int> mp;
	while(n--){
		string s;cin>>s;
		mp[s]++;}
	cout<<"AC"<<" x "<<mp["AC"]<<"\n";
	cout<<"WA"<<" x "<<mp["WA"]<<"\n";
	cout<<"TLE"<<" x "<<mp["TLE"]<<"\n";
	cout<<"RE"<<" x "<<mp["RE"]<<"\n";
}


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

int main(){
  int n;
  cin >> n;
  int a;
  a = n%10;
  if(a == 3){
    cout << "bon" << endl;
  }
  else if(a == 0 || a == 1 || a == 6 || a == 8){
    cout << "pon" << endl;
  }
  else{
    cout << "hon" << endl;
  }
}

Measured memory_bytes: 3636
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc=new Scanner(System.in);
		
		int x=sc.nextInt();
		while (!Prime(x)) {
			x++;
		}
		System.out.println(x);
		sc.close();
	}
 
	//素数判定
	public static boolean Prime(int n) {
		if(n==1){
			return false;
		}
		for(long i= 2;i*i<=n;i++) {
			if (n%i==0) {
				return false;
			}
		}
		return true;
	}
}

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

int desc(const void *a, const void *b) {
  return *(int *)b - *(int *)a;
}

int main() {
  int number_k;
  int number[3];
  scanf("%d %d %d", &number[0], &number[1], &number[2]);
  qsort(number, 3, sizeof(int), desc);
  scanf("%d", &number_k);
  printf("%d\n", (int)pow(2, number_k) * number[0] + number[1] + number[2]);
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <math.h>
#include <algorithm>
using namespace std;
int main() {
	int a, b, c, d;
	cin >> a >> b >> c >> d;
	if (a != c)cout << 1 << endl;
	else cout << 0 << endl;
	return 0;
}

Measured memory_bytes: 3632
# /usr/bin/python
# -*- coding: utf-8 -*-
#
import sys
 

H,W,D = map(int, input().split())
An = [[0 for j in range(2)] for i in range(H*W+1)]
for i in range(H):
  s = list(map(int, input().split()))
  for j in range(W):
    An[s[j]] = [i,j]

Q = int(input())
csum = [0] * (H*W+1) # cumA[i] := i%D -> i に向かう累積和
for i in range(D+1,H*W+1):
  csum[i] = csum[i-D] + abs(An[i][0]-An[i-D][0]) + abs(An[i][1]-An[i-D][1])


ans = [0] * Q
for i in range(Q):
  l,r = map(int, input().split())
  ans[i] = csum[r] - csum[l]

for i in range(Q):
  print(ans[i])




Measured memory_bytes: 75100
#include <bits/stdc++.h>
using namespace std;
int main() {
  int N;
  cin >> N;
  vector <int> H(N);
  for (int i = 0; i < N; i++) {
    cin >> H.at(i);
  }
  int answer = 0;
  for (int i = 0; i < N; i++) {
    bool ok = true;
    for (int j = 0; j < i; j++){
      if (H.at(j) > H.at(i)){
        ok = false;
      }
    }
    if (ok) {
      answer++;
    }
  }
  cout << answer << endl;
}


Measured memory_bytes: 256
N = int(input())
A = [0]*(N)
H = list(map(int, input().split()))
ans = "Yes"

hmax = max(H)
k = H.index(hmax)
Hd = [0]*k
Hdmax=int(0)
for i in range(k):
    Hd[i] = H[i]
    Hdmax = max(Hdmax,Hd[i])
    if H[i] < Hdmax - 1:
        ans = "No"

for i in range(k,N,1):
    if H[i]<hmax-1:
        ans = "No"


print(ans)


Measured memory_bytes: 15020
#include <iostream>
#include <algorithm>
#include <vector>
#include <math.h>
using namespace std;
typedef long long ll;

int main(void){
    ll n, k, a[100010], b[100010];
    cin >> n >> k;
    for (int i = 0; i < n; i++) cin >> a[i] >> b[i];
    
    vector<int> bit;
    bool d[35] = {};
    ll ans = 0;
    int up = -1;
    for (int i = 30; i >= 0; i--) {
        if (k & (1 << i)) {
            bit.push_back(i);
            d[i] = true;
            up = max(up, i);
        }
    }
    
    for (int i = 0; i < bit.size(); i++) {
        ll tmp = 0;
        for (int j = 0; j < n; j++) {
            bool can = true;
            if (a[j] > k) can = false;
            for (int l = up; l > bit[i]; l--) {
                if (!d[l] && a[j] & (1 << l)) can = false;
            }
            if (a[j] & (1 << bit[i])) can = false;
            if (can) tmp += b[j];
        }
        ans = max(ans, tmp);
        //cout << bit[i] << " " << tmp << endl;
    }
    
    ll last = 0;
    for (int j = 0; j < n; j++) {
        bool can = true;
        if (a[j] > k) can = false;
        for (int l = up; l >= 0; l--) {
            if (!d[l] && a[j] & (1 << l)) can = false;
        }
        if (can) last += b[j];
    }
    ans = max(ans, last);
    //cout << -1 << " " << last << endl;
        
    cout << ans << endl;
    
    
}


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

int n;
vector<int> a;
int main() {
    while (cin >> n) {
        if (n == 0) break;
        a.resize(n);
        for (int i = 0; i < n; ++i) cin >> a[i];
        sort(a.begin(), a.end());
        int res = 1<<29;
        for (int i = 0; i < n-1; ++i) res = min(res, a[i+1] - a[i]);
        cout << res << endl;
    }
}


Measured memory_bytes: 3112
n,a,b=map(int,input().split())
s=input()
r = 0
f=0
for i in range(n):
  if s[i]=="a":
    if r<a+b:
      print("Yes");r+=1
    else:print("No")
  elif s[i]=="b":
    if r<a+b and f<b:
      print("Yes");r+=1
    else:print("No")
    f+=1
  else:print("No")


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

int main(){
	int N;
	int count = 0;

	cin >> N;
	for (int i = 1; i <= N; i++)
	{
		int p;
		cin >> p;

		if (p != i) count++;
	}

	if(count == 0 || count == 2) cout << "YES" << endl;
	else cout << "NO" << endl;

cin >> N;
	return 0;

	
}

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

using namespace std;

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

const int N = 1e5 + 5;

int n,a[N],b[N];
map <int,int> c;

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL); cout.tie(NULL);
  cin >> n;
  int ans = 0;
  for (int i = 1 ; i <= n ; i++) {
    cin >> a[i];
    c[a[i]] = i;
    b[i] = a[i];
  }
  sort(b + 1,b + n + 1);
  for (int i = 1 ; i <= n ; i++)
    if ((i - c[b[i]]) % 2)
      ans++;
  cout << ans / 2 << endl;
}

Measured memory_bytes: 5760
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define str string
#define all(x) (x).begin(),(x).end()
#define rep(x,b,c) for(int x=b;x<c;x++)
#define  pb(x) push_back(x)
int main(){
    vector<int>v;
	vector<int>s;
	int n;
	cin>>n;
	rep(i,0,n){
		int a;
		cin>>a;
		v.pb(a);
	}
	sort(all(v));
	rep(i,v[0],v[v.size()-1]+1){
		int nas=0;
		rep(j,0,n){
		    nas+=(v[j]-i)*(v[j]-i);
		}
		s.pb(nas);
	}
	sort(all(s));
	cout<<s[0];
	return 0;
}

Measured memory_bytes: 256
import java.util.*;


public class Main {
     public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String n = sc.next();
        sc.close();
        String[] arr =  n.split("");
        int num = Integer.parseInt(arr[arr.length - 1]);
//        System.out.println(num);
        switch(num){
            case 3:
                System.out.println("bon");
                break;
            case 0:
            case 1:
            case 6:
            case 8:
                System.out.println("pon");
                break;
            default:
                System.out.println("hon");
                break;
        }
    }
}

Measured memory_bytes: 26944
#!/usr/bin/env python3
import math
N,M = list(map(int,input().split()))

def comb(n, r):
    if n > 1:
        return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))
    else:
        return 0

ans = comb(N,2)
ans += comb(M,2)
print(ans)




Measured memory_bytes: 3060
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <deque>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#define p(s) cout<<(s)<<endl
#define REP(i,n,N) for(int i=n;i<N;i++)
#define RREP(i,n,N) for(int i=N-1;i>=n;i--)
#define CK(n,a,b) ((a)<=(n)&&(n)<(b))
#define F first
#define S second
typedef long long ll;
using namespace std;
const ll mod = 1e9+7;

int N;
int c[510],f[510],s[510];
int main() {
    cin>>N;
    REP(i,0,N-1){
        cin>>c[i]>>s[i]>>f[i];
    }
    REP(i,0,N){
        int ans=0;
        REP(j,i,N-1){
            if(ans<s[j]) ans=s[j];
            else if(ans%f[j]!=0){
                ans+=f[j]-ans%f[j];
            }
            ans+=c[j];
        }
        p(ans);
    }
    return 0;
}

Measured memory_bytes: 256
N = int(input())
Vs = list(map(int, input().split()))
Cs = list(map(int, input().split()))

diffs = [V - C for V, C in zip(Vs, Cs)]
diffs = sorted(diffs)

ans = 0
for diff in diffs[::-1]:
    if diff >= 0:
        ans += diff

print(ans)

Measured memory_bytes: 3064
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <fstream>
using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<long, long> PLL;
typedef long long LL;
//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);

//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))
#define INF 10000000

int a[100003];
int main(){
	int n,k;
	while(cin>>n>>k){
		if(n==0&&k==0)break;
		REP(i,n)cin>>a[i];
		LL sum=0,ans=0;
		REP(i,k)sum+=a[i];
		FOR(i,k,n){
			sum=sum-a[i-k]+a[i];
			ans=max(sum,ans);
		}
		cout<<ans<<endl;
	}
	return 0;
}

Measured memory_bytes: 1544
a, b, c, d = list(map(int, input().split(' ')))
a = a - 1
def gcd(a, b):
    return b if a % b == 0 else gcd(b, a%b)

cd = d * (c // gcd(c, d))

right_c = b // c
right_d = b // d
right = b - right_c - right_d + (b // (cd))
left_c = a // c
left_d = a // d
left = a - left_c - left_d + (a // (cd))
print(right - left)


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

using namespace std;
using namespace __gnu_pbds;

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define fbo find_by_order
#define ook order_of_key

typedef long long ll;
typedef pair<int,int> ii;
typedef vector<int> vi;
typedef long double ld; 
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;
typedef set<int>::iterator sit;
typedef map<int,int>::iterator mit;
typedef vector<int>::iterator vit;

int solve(string &s1, string &s2)
{
	int n=s1.length();
	int ans=0;
	int ptr=n-1;
	vector<ii> vec;
	for(int i=n-1;i>=0;i--)
	{
		if(s1[ptr]==s2[i])
		{
			if(ptr==i)
			{
				ptr--;
			}
			continue;
		}
		ptr--;
		while(ptr>=0)
		{
			if(s1[ptr]==s2[i])
			{
				break;
			}
			ptr--;
		}
		if(ptr<0)
		{
			return -1;
		}
		vec.pb(mp(ptr,i));
	}
	int C = 0;
	vi L; deque<int> R;
	for(int i=0;i<n;i++) L.pb(0);
	for(int i=0;i<vec.size();i++)
	{
		int l=vec[i].fi; int r=vec[i].se;
		while(L.size()+R.size()>r+1)
		{
			if(!R.empty()) 
			{
				ans=max(ans,R.back()+C); R.pop_back();
			}
			else
			{
				ans=max(ans,L.back()); L.pop_back();
			}
		}
		//element l must be in L. pick r - l + 1 - R.size() elements from left side
		for(int i=int(L.size()) - 1; i > int(L.size()) - (r - l + 1 - int(R.size())); i--)
		{
			R.push_front(L.back()-C);
			L.pop_back();
		}
		L.pop_back();
		R.pb(R.back());
		C++;
	}
	for(int i=0;i<L.size();i++) ans=max(ans,L[i]);
	for(int i=0;i<R.size();i++) ans=max(ans,R[i]+C);
	return ans;
}

int main()
{
	ios_base::sync_with_stdio(0); cin.tie(0);
	int n; string s1,s2;
	cin>>n>>s1>>s2;
	cout<<solve(s1,s2)<<'\n';
}


Measured memory_bytes: 18192
{-# OPTIONS_GHC -O #-}
{-# LANGUAGE ViewPatterns #-}

import Control.Monad
import Data.List
import Data.Char
import qualified Data.ByteString.Char8 as B

main=do
    [n,k]<-map read.words<$>getLine :: IO [Int]
    as <- unfoldr (B.readInt.B.dropWhile (==' ')) <$> B.getLine
    --
    print $ if n<=k
        then 1
        else let (c,bs) = lchk k as in (+) c $ fst $ lchk k (reverse bs)

lchk k ar =
    let
        n = ((f1 ar) + k-2) `div` (k-1)
    in
        (n, (1:(drop (n*(k-1)+1) ar)))

f1 as = case findIndex (==1) as of
            Just i -> i
            Nothing -> undefined


Measured memory_bytes: 6524
//file_name:ABC96_A.cpp
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define snuke srand((unsigned)clock()+(unsigned)time(NULL));
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
inline int in() { int x; scanf("%d",&x); return x;}
template<typename T>inline istream& operator>>(istream&i,v(T)&v)
{rep(j,sz(v))i>>v[j];return i;}
template<typename T>string join(const v(T)&v)
{stringstream s;rep(i,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template<typename T>inline ostream& operator<<(ostream&o,const v(T)&v)
{if(sz(v))o<<join(v);return o;}
template<typename T1,typename T2>inline istream& operator>>(istream&i,pair<T1,T2>&v)
{return i>>v.fi>>v.se;}
template<typename T1,typename T2>inline ostream& operator<<(ostream&o,const pair<T1,T2>&v)
{return o<<v.fi<<","<<v.se;}
template<typename T>inline ll suma(const v(T)& a) { ll res(0); for (auto&& x : a) res += x; return res;}
const double eps = 1e-10;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
#define dame { puts("-1"); return 0;}
#define yn {puts("Yes");}else{puts("No");}
const int MX = 200005;

    // int scan
    /*
    int x;
    scanf("%d",&x);
    int y;
    scanf("%d",&y);
    int z;
    scanf("%d",&z);

    // matrix scan
    /*
    ll a[n] = {};
    rep(i,n){
        scanf("%lld",&a[i]);
    }
    */

    // string scan
    /*
    string s;
    cin >> s;
    */


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


    int ans = n-1;
    if(m>=n){
        ans++;
    }

    cout << ans << endl;
    return 0;
}



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

using ll = long long;

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

    int N;
    cin >> N;
    // 0: ba, 1: xa, 2: bx;
    int ab[3] = {};
    int count = 0;
    for (int i = 0; i < N; ++i) {
        string s;
        cin >> s;
        for (int j = 0; j < s.length() - 1; ++j) {
            count += s.substr(j, 2) == "AB";
        }
        if (s[0] == 'B' && s[s.length() - 1] == 'A') {
            ab[0]++;
        } else if (s[s.length() - 1] == 'A') {
            ab[1]++;
        } else if (s[0] == 'B') {
            ab[2]++;
        }
    }
    if (ab[0] > 0) {
        count += ab[0] - 1;
    }
    if (ab[0] > 0) {
        if (ab[1] > 0) {
            count++;
            ab[1]--;
        }
        if (ab[2] > 0) {
            count++;
            ab[2]--;
        }
    }
    count += min(ab[1], ab[2]);

    cout << count << '\n';

    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
#include<utility>
#include<iostream>
#include<queue>
#include<math.h>
#include<algorithm>
#include<vector>
#include<map>
#include<stack>

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

int main()
{
    long int n;
    char s[100005]={};
    scanf("%ld\n%s",&n,s);
    int ch[27]={};
    REP(i,n){
        ch[s[i]-'a']++;
    }
    long long int ans=1;
    REP(i,26){
        ans*=ch[i]+1;
        ans%=1000000007;
    }
    ans-=1;
    if(ans<0)ans+=1000000007;
    printf("%lld\n",ans);
    return 0;
}

Measured memory_bytes: 384
N = int(input())
A = sorted([int(x) for x in input().split()])
ans = []

if A[-1] <= 0:
    print(A[-1] - sum(A[:-1]))
    a = A[-1]
    for i in range(N-1):
        print(a,A[i])
        a -= A[i]

elif A[0] >= 0:
    print(sum(A[1:])-A[0])
    a = A[0]
    for i in range(1,N-1):
        print(a,A[i])
        a -= A[i]
    print(A[N-1],a)

else:
    i = 0
    while A[i] < 0:
        i += 1
    print(sum(A[i:]) - sum(A[:i]))
    a,b = A[i-1],A[i]

    if i != N-1:
        for j in range(N-i-1):
            print(a,A[i+j+1])
            a -= A[i+j+1]
    if i != 1:
        for j in range(i-1):
            print(b,A[j])
            b -= A[j]

    print(b,a)


Measured memory_bytes: 14620
#include <bits/stdc++.h>
using namespace std;
 
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define int long long

const int N = 1e5 + 5;

bool check(int n, int i)
{
	if(i == 1)
		return 0;
	while(n % i == 0)
		n /= i;
	n %= i;
	return n == 1;
}

int32_t main()
{
	IOS;
	int n;
	cin >> n;
	set<int> s;
	int x = n - 1;
	for(int i = 2; i * i <= x; i++)
	{
		if(x % i == 0)
		{
			s.insert(i);
			s.insert(x / i);
		}
	}
	s.insert(x);
	for(int i = 1; i * i <= n; i++)
	{
		if(n % i == 0)
		{
			if(check(n, i))
				s.insert(i);
			if(check(n, n / i))
				s.insert(n / i);
		}
	}
	s.erase(1);
	cout << s.size();
	return 0;
}


Measured memory_bytes: 256
#include"bits/stdc++.h"
#include<boost/multi_array.hpp>
#include<boost/optional.hpp>
#include<boost/range/irange.hpp>
#include<boost/range/algorithm.hpp>
#include<boost/range/adaptors.hpp>
#include<boost/operators.hpp>
#include<boost/dynamic_bitset.hpp>

namespace adaptor = boost::adaptors;
using index_t = std::size_t;

template<class T>struct min_value
{
	T v;
	min_value(T u = std::numeric_limits<T>::max()) :v(u)
	{

	}
	auto& operator=(T const& u)
	{
		v = std::min(v, u);
		return *this;
	}
	T operator*()const
	{
		return v;
	}
	void reset()
	{
		v = std::numeric_limits<T>::max();
	}
};

void Main()
{
	int N;
	std::cin >> N;
	std::vector<std::int64_t> vec(N);
	std::int64_t sum = 0;
	for (auto& v : vec)
	{
		std::cin >> v;
		sum += v;
	}
	min_value<std::int64_t> min;
	std::int64_t s = 0;
	for (auto i : boost::irange(0, N - 1))
	{
		s += vec[i];
		min = std::abs(sum - 2 * s);
	}
	std::cout << *min << std::endl;
}

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

Measured memory_bytes: 1792
n,k=map(int,input().split())
plist=list(map(int,input().split()))

summax=sum(plist[:k])


for i in range(n-k+1):
	if i == 0:
		temp=summax
	else:
		temp=temp+plist[i+k-1]-plist[i-1]
		if temp>summax:
			summax=temp

print((summax+k)/2)



Measured memory_bytes: 25060
#include  <functional>
#include  <algorithm>
#include  <exception>
#include  <stdexcept>
#include  <streambuf>
#include  <iterator>
#include  <string.h>
#include  <stdlib.h>
#include  <typeinfo>
#include  <valarray>
#include  <iostream>
#include  <sstream>
#include  <istream>
#include  <stdio.h>
#include  <climits>
#include  <clocale>
#include  <complex>
#include  <csetjmp>
#include  <csignal>
#include  <cstdarg>
#include  <cstddef>
#include  <ctype.h>
#include  <cassert>
#include  <cstdlib>
#include  <utility>
#include  <cstring>
#include  <numeric>
#include  <ostream>
#include  <cwctype>
#include  <fstream>
#include  <iomanip>
#include  <math.h>
#include  <bitset>
#include  <cctype>
#include  <string>
#include  <vector>
#include  <limits>
#include  <locale>
#include  <memory>
#include  <cerrno>
#include  <iosfwd>
#include  <cfloat>
#include  <cstdio>
#include  <cwchar>
#include  <cmath>
#include  <ctime>
#include  <deque>
#include  <queue>
#include  <stack>
#include  <list>
#include  <ios>
#include  <map>
#include  <set>
#include  <new>
#define fi first
#define se second
#define pb push_back
#define ll long long
#define pii pair<int,int>
using namespace std;
int n,a[100005],sum,sum2;
int main()
{
    cin>>n;
    for(int i=0;i<n;i++)
    {
        cin>>a[i];
        if(a[i]%4==0)
        sum++;
        else{
            if(a[i]%2==0)
            sum2++;
        }
    }
    sum2/=2;
    if(sum+sum2>=(n/2))
    cout<<"Yes";
    else
    cout<<"No";
    return 0;
}


Measured memory_bytes: 640
#include<stdio.h>
int main(){
    int x,y,z;
    while(1){
        scanf("%d %d\n",&x,&y);
        if(x==0&&y==0){
            break;
        }
        if(x<y){
            printf("%d %d\n",x,y);
        }else{
            z=x;
            x=y;
            y=z;
            printf("%d %d\n",x,y);
        }
    }
    return 0;
}


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

using namespace std;
using ll=long long;
using ull=unsigned long long;
using pii=pair<int,int>;

#define INF LONG_MAX
#define MOD 1000000007
#define rng(a) a.begin(),a.end()
#define rrng(a) a.end(),a.begin()
#define rep(i,N) for(int i=0;i<N;i++)

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

  int N;
  cin>>N;
  vector<int>X(N);
  for(int i=0;i<N;i++)cin>>X[i];
  ll ans=LONG_MAX;
  for(int i=0;i<=100;i++){
    ll res=0;
    for(int j=0;j<N;j++){
      res+=(i-X[j])*(i-X[j]);
    }
    ans=min(ans,res);
  }
  cout<<ans<<endl;
  return 0;
}


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

int main( void )
{
    int a,b,c;
    cin >> a >> b >> c;
    
    int ans = min(a,b) + min(max(a,b),c);
    cout << ans << endl;
}


Measured memory_bytes: 256
#include<iostream>
#define _USE_MATH_DEFINES
#include<math.h>
#include<vector>
#include<array>
#include<algorithm>
#include<numeric>
#include<map>
#include<stack>
#include<queue>
#include<deque>
#include<set>
#include<cstdio>
#include<cstring>
#include<string>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<ll> vec;
typedef vector<vector<ll>> mat;
typedef pair<ll,ll> P;
typedef map<ll,ll> MP;
typedef priority_queue<ll> PQ;
typedef stack<ll> ST;
typedef queue<ll> QUE;
#define pb push_back
#define st first
#define nd second
#define SZ(x) ((int)(x).size())
#define FOR(i,s,n) for(int i=(int)(s); i< (int)(n); i++)
#define rep(i,n) FOR(i,0,n)
#define all(x) (x).begin(),(x).end()
#define each(x,c) for(auto x: (c))
#define LB(x,a) lower_bound(all(x), a)
#define UB(x,a) upper_bound(all(x), a)
const ll mod=1e9+7;
const ll INF=1e18;
const double EPS=1.0e-10;
const double PI=M_PI;

int main(){
    int N; cin>>N;
    vec A(N);
    rep(i,N) cin>>A[i];
    ll ans=1;
    MP mp; mp[0]=3;
    rep(i,N){
        if(mp[A[i]]==0){
            cout<<0<<endl;
            return 0;
        }
        ans=(ans*mp[A[i]])%mod;
        mp[A[i]]--; mp[A[i]+1]++;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 7296
#include <iostream>
#include <algorithm>
#include <set>
#include <vector>
#include <queue>

#define MAXN 55
#define MAXSILVER 2500

using ll = long long int;
std::vector< std::vector< std::pair<int, std::pair<int, ll> > > > g(MAXN);
//silver, transaction time for each gold
std::pair<ll, ll> trans[MAXN];
ll dist[MAXN][MAXSILVER];

std::pair<ll, std::pair<int, int> > mp(ll x, int y, int z)
{
    return std::make_pair(x, std::make_pair(y, z));
}

void solve(int start, int silver)
{
    std::priority_queue< std::pair<ll, std::pair<int, int> >,
                        std::vector< std::pair<ll, std::pair<int, int> > >,
                            std::greater<std::pair<ll, std::pair<int, int> > > > s;
    s.push(mp(0, start, silver));
    dist[start][silver] = 0;

    while (!s.empty())
    {
        std::pair<ll, std::pair<int, int> > top = s.top();
        s.pop();
        ll curdist = top.first;
        int v = top.second.first, silv = top.second.second;
        if (curdist > dist[v][silv]) continue;
//        if (s.size() > 100000) std::cout << s.size() << "\n";

        if (trans[v].first + silv <= MAXSILVER-2)
        {
            ll t = trans[v].second;
            int nextsilv = silv + trans[v].first;
            if (dist[v][silv] + t < dist[v][nextsilv])
            {
                dist[v][nextsilv] = dist[v][silv] + t;
                s.push(mp(curdist + t, v, nextsilv));
            }
        }

        for (std::pair< int, std::pair<int, int> > nxtpr : g[v])
        {
            int nxt = nxtpr.first;
            int silvtaken = nxtpr.second.first;
            ll timetaken = nxtpr.second.second;

            if (silv - silvtaken < 0) continue;
            int nxtsilver = silv - silvtaken;

            if (dist[v][silv] + timetaken < dist[nxt][nxtsilver])
            {
                dist[nxt][nxtsilver] = dist[v][silv] + timetaken;
                s.push(mp(curdist + timetaken, nxt, nxtsilver));
            }
        }
    }
}

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

    s = std::min(s, MAXSILVER-3);
    int x, y, a, b;
    while (m--)
    {
        std::cin >> x >> y >> a >> b; --x; --y;
        g[x].push_back(std::make_pair(y, std::make_pair(a, b)));
        g[y].push_back(std::make_pair(x, std::make_pair(a, b)));
    }

    for (int i = 0; i < n; ++i)
        std::cin >> trans[i].first >> trans[i].second;

    for (int i = 0; i < n; ++i)
        for (int j = 0; j < MAXSILVER-2; ++j)
            dist[i][j] = 1e15;
    solve(0, s);

    for (int i = 1; i < n; ++i)
    {
        ll ans = 1e15;
        for (int j = 0; j < MAXSILVER-2; ++j)
        {
            ans = std::min(ans, dist[i][j]);
        }

        std::cout << ans << "\n";
    }
}


Measured memory_bytes: 6204
import sys
import numpy as np
from scipy.sparse.csgraph import floyd_warshall
from itertools import permutations

def main():
    input = sys.stdin.readline
    N, M, R = map(int, input().split())
    r = list(map(int, input().split()))

    INF = float('inf')
    A = [[INF for _ in range(N)] for _ in range(N)]
    for _ in range(M):
        a, b, c = map(int, input().split())
        A[a-1][b-1] = c
        A[b-1][a-1] = c

    G = floyd_warshall(np.array(A))

    ans = INF
    for root in permutations(r):
        cur = 0
        for i in range(R-1):
            s, g = root[i] -1, root[i+1] - 1
            cur += G[s][g]

        ans = min(ans, cur)

    return int(ans)


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


Measured memory_bytes: 22264
#include<iostream>
#include<stdlib.h>
using namespace std;


bool binary_search(int *seq, int n, int key)
{
	int left = 0, right = n, mid;
	int flag = false;
	while(left < right)
	{
		mid = (left + right)/2;
		if(seq[mid] == key) 
		{
			flag = true;
			break;
		}
		else if(seq[mid] > key) right = mid;
		else left = mid + 1;
	} 
	return flag;
}



int main()
{
	int seq[100000];
	int n;
	cin >> n;
	int i = 0;
	for(i; i < n; i++)
	{
		cin >> seq[i];
	}
	
	int q;
	cin >> q;
	

	int num = 0;
	int key = 0;
	for(i = 0; i < q; i++)
	{
		cin >> key;
		if(binary_search(seq, n, key)) num += 1;
	}
	
	cout << num << endl;
//	system("pause");
	return 0;
}



Measured memory_bytes: 3396
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define pf push_front

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

#define mp make_pair
#define fi first
#define se second
typedef pair<int,int> pint;
#define All(s) s.begin(),s.end()
#define rAll(s) s.rbegin(),s.rend()
#define REP(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
double pi = 3.141592653589793;
ll mod = 1000000007;
ll INF = 1000000001;
int intmax = 2147483647;
int intmin = -2147483648;
ll llmax = 9223372036854775807;
ll llmin = -9223372036854775807;



int main(){
	int n;cin>>n;
	vi v(n);
	
	int cnt=0;
	rep(i,n){
		cin>>v[i];
	}
	int m=0;
	rep(i,n){
		m = max(m,v[i]);
		if(m==v[i]){
			cnt+=1;
		}
	}
	cout<<cnt<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include <string> 
#include <vector>  
#include<math.h>
#include <algorithm>
#include<iomanip>
#include<map>
#define INF 1000000000
#define LM 55555
#define LL long long
using namespace::std;

long long now,D,H,a,p,t,A,T,x[101],y[101],h[101],num, N, K, M, ans;
string S;
bool xy[100][100][100],hh;
char cc;


int main() {
	cin >> N >> M;
	if (N == 1) {
		cout << M << endl;
		return 0;
	}
	a = M / N;
	if (M%N == 0) {
		cout << a << endl;
		return 0;
	}

			for (int i = M / N; i > 0; i--) {
				if (M%i == 0) {
					cout << i << endl;
					return 0;
				}
			}

	cout << 1 << endl;
	return 0;


	
}

Measured memory_bytes: 256
import sys
from operator import itemgetter
input = sys.stdin.readline

N, M = map(int, input().split())
AB = [list(map(int, input().split())) for _ in range(M)]
AB.sort(key=itemgetter(1))
ans, right = 1, 10 ** 5 + 1
for a, b in AB:
    if a < right:
        right = min(b, right)
    else:
        ans += 1
        right = b
print(ans)


Measured memory_bytes: 29124
#include<bits/stdc++.h>
using namespace std;
int main()
{
       int k;
    cin>>k;

    string s;
    vector<string>v;
    cin>>s;
       int p=s.length()-k;

    if (s.length()<=k)
    {
                cout<<s<<endl;

    }


else
{
    s.erase(k,p);
    s.append("...");
cout<<s<<endl;

}


    return 0;
}


Measured memory_bytes: 3632
#include<iostream>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<utility>
#include<vector>
#include<cmath>
#include<cstring>
#include<cstdio>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define rp(a) while(a--)
#define pb push_back
#define mp make_pair
#define all(in) in.begin(),in.end()
const double PI=acos(-1);
const double EPS=1e-10;
using namespace std;
typedef long long ll;
typedef vector<int> vi;
bool h[1000010]={false};
int main(){
	ll a,b;
	while(cin>>a>>b){
		cout<<__gcd(a,b)<<" "<<a*b/__gcd(a,b)<<endl;
	}
}

Measured memory_bytes: 1156
#include <iostream>
#include <vector>
#include <cmath>
#include <string>
#include <algorithm>
#include <numeric>
#include <climits>
#define ll long long
#define LIM 100000
using namespace std;
vector<ll> v;
int main() {
  for (int i = 0; i < 3; i++) {
    ll a;
    cin >> a;
    v.push_back(a);
  }
  sort(v.begin(), v.end());
  cout << (v[2] % 2 == 0 ? 0 : v[0] * v[1]) << endl;
  return 0;
}


Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int length = sc.nextInt();
		int[] nums = new int[length];
		for (int i = 0; i < nums.length; i++) {
			nums[i] = sc.nextInt();
		}
		
		//探索リストを作る
		int[] targets = new int[1000001];
		Arrays.fill(targets, 0);
		
		//入力配列をなめて、探索リストに対して、要素の倍数のインデックスに対してインクリメント
		//上記操作が終わったら、探索リストの要素が1のものが対象の数値
		for (int i = 0; i < nums.length; i++) {
			int num = nums[i];
			if(targets[num] != 0) {
				targets[num] = 2;
				continue;
			}
			for(int j = num; j <= 1000000; j+=num) {
				targets[j]++;
			}
		}
		int count = 0;
		for (int i = 0; i < nums.length; i++) {
			if(targets[nums[i]] == 1) {
				count++;
			}
		}
		System.out.println(count);
	}
}

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

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

Measured memory_bytes: 2944
#include <bits/stdc++.h>
#define c1 s[i]
#define c2 s[i + d]
#define c3 s[i + d + d]
using ll = long long;
using namespace std;
int main() {
    int n; cin >> n;
    string s; cin >> s;
    int a[3] = {};
    for (char c : s) {
        if (c == 'R') ++a[0];
        else if (c == 'G') ++a[1];
        else ++a[2];
    }
    ll ans = 1LL * a[0] * a[1] * a[2];
    for (int i = 0; i < n - 2; i++) {
        for (int d = 1; i + d + d < n; d++) {
            if (c1 != c2 and c1 != c3 and c2 != c3)
                --ans;
        }
    }
    cout << ans;
}


Measured memory_bytes: 3572
// Problem : D - Restoring Road Network
// Contest : AtCoder Regular Contest 083
// URL : https://atcoder.jp/contests/arc083/tasks/arc083_b
// Memory Limit : 256 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include "bits/stdc++.h"
using namespace std;
using ll = long long;
#define size(x) (int)x.size()

const int N = 303, mod = 1e9 + 7, inf = 2e9;

int n, a[N][N], dp[N][N];
ll sum = 0;

int main() { cin.tie(0)->sync_with_stdio(0);
	cin >> n;
	for (int i = 1; i <= n; i++) {
		for (int j = 1; j <= n; j++) {
			cin >> a[i][j];
		}
	}
	for (int i = 1; i <= n; i++) {
		for (int j = 1; j <= n; j++) {
			if (i == j) {
				dp[i][j] = 0;
				continue;
			}
			dp[i][j] = inf;
		}
	}
	for (int i = 1; i <= n; i++) {
		for (int j = 1; j <= n; j++) {
			if (a[i][j]) {
				bool direct = 1;
				for (int k = 1; k <= n; k++) {
					if (a[i][k] && a[k][j] && a[i][j] == a[i][k] + a[k][j]) {
						direct = 0;
					}
				}
				if (direct) {
					dp[i][j] = a[i][j];
					sum += a[i][j];
				}
			}
		}
	}
	for (int k = 1; k <= n; k++) {
		for (int i = 1; i <= n; i++) {
			for (int j = 1; j <= n; j++) {
				if (dp[i][k] != inf && dp[k][j] != inf && dp[i][j] > dp[i][k] + dp[k][j]) {
					dp[i][j] = dp[i][k] + dp[k][j];
				}
			}
		}
	}
	bool no = 0;
	for (int i = 1; i <= n; i++) {
		for (int j = 1; j <= n; j++) {
			if (!dp[i][j]) {
				if (a[i][j]) {
					no = 1;
				}
			} else if (dp[i][j] != a[i][j]) {
				no = 1;
			}
		}
	}
	cout << (no ? -1 : sum / 2);
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
int main(){
int n;
cin >> n;
int a[n] = {};
for(int i=0;i<n-1;i++){
    int temp;
    cin >> temp;
    a[temp-1]++;
}
for(int i=0;i<n;i++){
    cout << a[i];
    cout << endl;
}
return 0;
}

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

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

    int MOD = 1000000007;
    int n;
    cin >> n;
    vector<int> a(n);
    ll sum = 0;
    ll ans = 0;
    rep(i,n) {
        cin >> a[i];
        sum += a[i];
        sum %= MOD;
    }

    rep(i,n) {
        sum -= a[i];
        if(sum < 0) sum += MOD;
        ans += a[i] * sum;
        ans %= MOD;
    }
    cout << ans << endl;
    return 0;
}

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

int main(){
  int miny=9999,imin,lst[1000],cnt=0,N;
  char t;
  
  cin >> N;
  for (int i=0;i<N;i++){
    cin >> t;
    cin >> lst[i];
    if (t=='n') lst[i]*=-1;
  }
  
  while(1){
    miny=9999;
    for (int i=0;i<N;i++){
      if (lst[i]>0&&lst[i]<miny) miny=lst[i],imin=i;
    }
    if (miny==9999) break;
    cnt++;
    for (int i=imin;i<N;i++){
      if (lst[i]==0)continue;
      if (lst[i]<0&&-lst[i]>=miny)break;
      lst[i]=0;
    }
    for (int i=imin;i>=0;i--){
      if (lst[i]==0)continue;
      if (lst[i]<0&&-lst[i]>=miny) break;
      lst[i]=0;
    }
  }
  
  cout << cnt << endl;
  return 0;
}

Measured memory_bytes: 3108