akhauriyash/Code-Regression huggingface dataset:
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.NoSuchElementException;
import java.util.StringTokenizer;

class Main{
	public static void main(String args[]) {

		BufferedReader bfr=new BufferedReader(new InputStreamReader(System.in));
		String str="";
		StringTokenizer stk;
		int sa=0;

		try {
			while(true) {
				str=bfr.readLine();
				if(str=="") {
					System.exit(0);
				}
				stk=new StringTokenizer(str," ");
				sa=(Integer.parseInt(stk.nextToken()))-(Integer.parseInt(stk.nextToken()));
				System.out.println(sa);
			}

		} catch (IOException e) {
			System.exit(0);
		}

		catch (NoSuchElementException e) {
			System.exit(0);
		}
		
		catch (NullPointerException e) {
			System.exit(0);
		}
	}
}


Measured memory_bytes: 24324
#include<bits/stdc++.h>
using namespace std;
int main () {
	int N , M ; cin >> N >> M ;
	vector <int > cnt (M , 0);
	for ( int i = 0; i < N ; ++ i ) {
		int K; cin >> K ;
		for ( int j = 0; j < K ; ++ j ) {
			int A; cin >> A ; --A ;
			++ cnt [ A ];
		}
	}
	int ans = 0;
	for ( int i = 0; i < M ; ++ i ) {
		if ( cnt [ i ] == N ) {
		++ ans ;
		}
	}
	cout << ans << endl ;
}

Measured memory_bytes: 256
import sys,heapq
n=int(sys.stdin.readline())
a=list(map(int,sys.stdin.readline().split()))
sa=sb=0
la=[]
lb=[]
for i in range(n):
	sa+=a[i]
	heapq.heappush(la,a[i])
ra=[sa]
for i in range(n,2*n):
	sa+=a[i]
	heapq.heappush(la,a[i])
	sa-=heapq.heappop(la)
	ra.append(sa)
for i in range(3*n-1,2*n-1,-1):
	sb+=a[i]
	heapq.heappush(lb,-a[i])
rb=[sb]
for i in range(2*n-1,n-1,-1):
	sb+=a[i]
	heapq.heappush(lb,-a[i])
	sb+=heapq.heappop(lb)
	rb.append(sb)
print(max(x-y for x,y in zip(ra,reversed(rb))))

Measured memory_bytes: 74556
#!/usr/bin/env python3
from collections import defaultdict
from collections import deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
import itertools
sys.setrecursionlimit(10**5)
stdin = sys.stdin
bisect_left = bisect.bisect_left
bisect_right = bisect.bisect_right
def LI(): return list(map(int, stdin.readline().split()))
def LF(): return list(map(float, stdin.readline().split()))
def LI_(): return list(map(lambda x: int(x)-1, stdin.readline().split()))
def II(): return int(stdin.readline())
def IF(): return float(stdin.readline())
def LS(): return list(map(list, stdin.readline().split()))
def S(): return list(stdin.readline().rstrip())
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007
inf = float('INF')

#A
def A():
    a, b = LI()
    if a <= 8 and b <= 8:
        print("Yay!")
    else:
        print(":(")
    return

#B
def B():
    d, n = LI()
    print(str(n * (n != 100) or n + 1) + "00" * d)
    return

#C
def C():
    II()
    ans = 0
    a = LI()
    for ai in a:
        while not ai % 2:
            ans += 1
            ai = ai // 2
    print(ans)
    return

#D
def D():
    n, m = LI()
    l = LIR(n)
    dp = [[-inf] * 8 for i in range(m+1)]
    for i in range(8):
        dp[0][i] = 0
    for i in range(n):
        for k in range(m, 0, -1):
            for x in range(8):
                t = 0
                for j in range(3):
                    t += l[i][j] if (x >> j) & 1 else -1 * l[i][j]
                dp[k][x] = max(dp[k][x], dp[k - 1][x] + t)
    print(max(dp[-1]))
    return

#Solve
if __name__ == '__main__':
    D()


Measured memory_bytes: 49756
n,x=map(int,raw_input().split())
a=map(int,raw_input().split())
s=[[10**12]*n for _ in xrange(n)]
for i in xrange(n):
    for j in xrange(n):
        if j==0:s[i][j]=a[i]
        else:s[i][j]=min(s[i][j-1],a[(i-j)%n])
ans=float("inf")
for j in xrange(n):
    tmp=x*j
    for i in xrange(n):
        tmp+=s[i][j]
    ans=min(ans,tmp)
print ans


Measured memory_bytes: 60908
using System;

namespace B___eeeee
{
    class Program
    {
        static void Main(string[] args)
        {
            var N = int.Parse(Console.ReadLine());
            var S = Console.ReadLine();
            var K = int.Parse(Console.ReadLine());
            string str = string.Empty;
            
            for (int i = 0; i < N; i++)
            {
                if (S[i] == S[K - 1])
                    str += S[K - 1];
                else
                    str += '*';
            }
            Console.WriteLine(str);
        }
    }
}


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

const int MAX = 100;
int main() {
	int N, t[MAX + 2], v[MAX + 2];
	cin >> N;
	for (int i = 1;i <= N;i ++) cin >> t[i];
	for (int i = 1;i <= N;i ++) cin >> v[i];
	
	t[0] = 0;
	t[N + 1] = 0;
	v[0] = 0;
	v[N + 1] = 0;
	
	int m[MAX + 2];
	m[N + 1] = 0;
	for (int i = N;i >= 0;i --) {
		m[i] = min(m[i + 1] + t[i], v[i]); // i～i+1の地点における出していい限界速度
	}
//	for (int i = 0;i <= N + 1;i ++) cout << m[i] << endl;
	int d = 0;
	
	int acc[MAX], con[MAX], dec[MAX], nowspd = 0;
	for (int i = 0;i < N;i ++) {
		acc[i] = min(min(2 * (m[i + 1] - nowspd), t[i + 1] + m[i + 2] - nowspd), t[i + 1] * 2); // i～i+1地点における加速時間の2倍
		dec[i] = max(nowspd * 2 + acc[i] - m[i + 2] * 2, 0); // i～i+1地点における減速時間の2倍
		con[i] = t[i + 1] * 2 - acc[i] - dec[i]; // i～i+1地点における等速時間の2倍
//		cout << nowspd << "  " << acc[i] / 2.0 << " " << con[i] / 2.0 << " " << dec[i] / 2.0 << endl;
		d += (nowspd * 2 + nowspd * 2 + acc[i]) * acc[i]
			+ (nowspd * 2 + acc[i]) * con[i] * 2
			+ (nowspd * 2 + acc[i] + nowspd * 2 + acc[i] - dec[i]) * dec[i]; // i～i+1地点における移動距離の8倍
		nowspd += (acc[i] - dec[i]) / 2; // 現在の速度
	}
	cout << d / 8;
	if (d % 8) {
		cout << '.' << 125 * (d % 8);
	}
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include <cmath>
#include <map>
#include <set>
#include <algorithm>
#include <string>
#define rep(i,n) for (int i= 0;i<(n);++i)
using namespace std;
typedef long long ll;
const ll maxSum = 50*50+1;
int main() {
    ll N,A;
    cin >> N >>A;
    vector<ll> x(N);
    for(int i=0;i<N;i++){
        cin >> x[i];
    }
  
    static ll dp[51][51][maxSum+5]={};
    dp[0][0][0] = 1;
    for(int i=0;i<N;i++)for(int j=0;j<N;j++)for(int k=0;k<maxSum;k++){
        dp[i+1][j][k] += dp[i][j][k];
        if(x[i]<=k){
            dp[i+1][j+1][k] +=dp[i][j][k-x[i]];
        }
    }
    ll ans =0;
    for(int i=1;i<=N;i++){
        
        ans += dp[N][i][A*i];
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 53504
import java.util.Scanner;

public class Main {
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		if (s.charAt(2) == s.charAt(3) && s.charAt(4) == s.charAt(5))
			System.out.println("Yes");
		else
			System.out.println("No");
		sc.close();
	}
}


Measured memory_bytes: 22740
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
#define INF 100000000
#define rep(i,s,n) for (int i = (int)(s); i < (int)(n); i++)
ll mod = 1000000007;
ll mod2 = 998244353;

ll modpow(ll a,ll b){
    ll ret = 1;
    while (b>0){
        if (b&1) ret = (ret*a)%mod;
        a = (a*a)%mod;
        b >>= 1;
    }
    return ret;
}

int main(){
    ll n; cin>>n;
    ll G=0,L=0,R=0;
    map<pair<ll,ll>,ll> M,P;
    rep(i,0,n){
        ll a,b;cin>>a>>b;
        if (a==0 && b==0){
            G++;
            continue;
        }else if(a==0){
            L++;
            continue;
        }else if(b==0){
            R++;
            continue;
        }
        ll g = __gcd(abs(a),abs(b));
        if (a<0){
            a*=-1; b*=-1;
        }
        a/=g; b/=g;
        M[make_pair(a,b)]++;
    }
    ll ans = 1;
    for (auto x:M){
        if (P[x.first]==1) continue;
        ll a = x.first.second<0?(-1)*x.first.second:x.first.second;
        ll b = x.first.second<0?x.first.first:x.first.first*(-1);
        ll num = (modpow(2,M[make_pair(a,b)])+modpow(2,x.second)-1+mod)%mod;
        ans = (ans*num)%mod;
        P[make_pair(a,b)] = 1;
    }
    ans = (ans*(modpow(2,L)+modpow(2,R)-1+mod)%mod)%mod;
    ans = (ans+G-1+mod)%mod;
    cout << ans%mod << endl;
}

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

namespace _0239
{
    class Program
    {
        class Sweets
        {
            public int ID { get; set; }
            public int Protein { get; set; }
            public int Lipid { get; set; }
            public int Carbohydrate { get; set; }
            public int Calorie { get; set; }
            public Sweets(int[] vs)
            {
                ID = vs[0];
                Protein = vs[1];
                Lipid = vs[2];
                Carbohydrate = vs[3];
                Calorie = (Protein + Carbohydrate) * 4 + Lipid * 9;
            }
        }

        static void Main(string[] args)
        {
            while (true)
            {
                int n = RInt();
                if (n == 0) break;

                Sweets[] sweets = new Sweets[n];
                for (int i = 0; i < n; i++) sweets[i] = new Sweets(RArInt());

                int[] limit = RArInt();
                bool flg = false;
                for (int i = 0; i < sweets.Length; i++)
                {
                    if (sweets[i].Protein <= limit[0] && sweets[i].Lipid <= limit[1] 
                         && sweets[i].Carbohydrate <= limit[2] && sweets[i].Calorie <= limit[3])
                    {
                        Console.WriteLine(sweets[i].ID);
                        flg = true;
                    }
                }
                if (!flg) Console.WriteLine("NA");
            }
        }
        static string RSt() { return Console.ReadLine(); }
        static int RInt() { return int.Parse(Console.ReadLine().Trim()); }
        static long RLong() { return long.Parse(Console.ReadLine().Trim()); }
        static double RDouble() { return double.Parse(Console.ReadLine()); }
        static string[] RArSt(char sep = ' ') { return Console.ReadLine().Trim().Split(sep); }
        static int[] RArInt(char sep = ' ') { return Array.ConvertAll(Console.ReadLine().Trim().Split(sep), e => int.Parse(e)); }
        static long[] RArLong(char sep = ' ') { return Array.ConvertAll(Console.ReadLine().Trim().Split(sep), e => long.Parse(e)); }
        static double[] RArDouble(char sep = ' ') { return Array.ConvertAll(Console.ReadLine().Trim().Split(sep), e => double.Parse(e)); }
        static string WAr<T>(IEnumerable<T> array, string sep = " ") { return string.Join(sep, array.Select(x => x.ToString()).ToArray()); }
    }
}



Measured memory_bytes: 22088
import java.util.*;
import java.io.*;
 
class Main{
    public static void main(String args[])throws IOException{
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        int x = Integer.parseInt(br.readLine());
        StringBuilder sb = new StringBuilder();
        int count=0;
        int a=1,b;
        if(x>=3 && x<=10000){
            for(; count<x; count++){
                 b = a/10;
                    if(a%3==0){
                        sb.append(" ");
                        sb.append(a);
                    }else{
                        b = a;
                        while(b!=0){
                            if(b%10==3){
                                sb.append(" ");
                                sb.append(a);
                                break;
                            }
                            b /= 10;
                        }
                    }
                    a++;
            }
        }
        System.out.println(sb);
    }
}

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

int main()
{
	int N; //the number of data sets
	int g_x,g_y;
	int n_mat; //the number of matatabi
	int mat_x1,mat_y1,mat_x2,mat_y2;
	int T[16][16];
	int Vert[16][16];
	int Horiz[16][16];

	cin>>N;

	for(int i=0;i<N;++i){

		//shokisettei OK
		for(int y=0;y<=15;++y){
			Horiz[0][y]=1;
			Vert[0][y]=0;
		}
		for(int x=0;x<=15;++x){
			Vert[x][0]=1;
			Horiz[x][0]=0;
		}
		Horiz[0][0]=1;
		for(int x=1;x<=15;++x){
			for(int y=1;y<=15;++y){
				Vert[x][y]=0;
				Horiz[x][y]=0;
			}
		}

		cin>>g_x>>g_y;
		cin>>n_mat;

		//dealing with matatabi
		for(int j=0;j<n_mat;++j){
			cin>>mat_x1>>mat_y1>>mat_x2>>mat_y2;
			if(mat_x1==mat_x2){
				Vert[mat_x2][max(mat_y1,mat_y2)]=1; //not able to move from the above
			}

			if(mat_y1==mat_y2){
				Horiz[max(mat_x1,mat_x2)][mat_y2]=1;
			}
		}

		T[0][0]=1;
		for(int x=0;x<=g_x;++x){
			for(int y=0;y<=g_y;++y){
				if(x!=0||y!=0){
					if(Vert[x][y]==0&&Horiz[x][y]==0) T[x][y]=T[x-1][y]+T[x][y-1];
					if(Vert[x][y]==0&&Horiz[x][y]==1) T[x][y]=T[x][y-1];
					if(Vert[x][y]==1&&Horiz[x][y]==0) T[x][y]=T[x-1][y];
					if(Vert[x][y]==1&&Horiz[x][y]==1) T[x][y]=0;
				}
			}
		}

		if(T[g_x][g_y]==0){
			cout<<"Miserable Hokusai!"<<endl;
		} else {
			cout<<T[g_x][g_y]<<endl;
		}
	}

	return 0;
}

Measured memory_bytes: 2964
#include<stdio.h>
#include<algorithm>
using namespace std;
int n,a[100010],q;
int main(){
    scanf("%d",&n);
    for(int i=0;i<n;i++) scanf("%d",&a[i]),a[i]=-a[i];
    sort(a,a+n);
    for(int i=0;i<n;i++){
        if(i%2) q+=a[i];
        else q-=a[i];
    }
    printf("%d\n",q);
}


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

int main() {
    int x, y;
    map<int, int> mp;
    mp[1] = 1;
    mp[2] = 2;
    mp[3] = 1;
    mp[4] = 3;
    mp[5] = 1;
    mp[6] = 3;
    mp[7] = 1;
    mp[8] = 1;
    mp[9] = 3;
    mp[10] = 1;
    mp[11] = 3;
    mp[12] = 1;

    cin >> x >> y;
    if(mp[x] == mp[y]) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
//{{{
#include <bits/stdc++.h>
using namespace std;
#define repX(a,b,c,x,...) x
#define repN(a) repX a
#define rep(...) repN((__VA_ARGS__,rep3,rep2,loop))(__VA_ARGS__)
#define rrep(...) repN((__VA_ARGS__,rrep3,rrep2))(__VA_ARGS__)
#define loop(n) rep2(i_,n)
#define rep2(i,n) rep3(i,0,n)
#define rep3(i,begin,end) for(int i=(int)(begin),i##_end=(int)(end);i<i##_end;++i)
#define rrep2(i,n) rrep3(i,n,0)
#define rrep3(i,begin,end) for(int i=(int)(begin-1),i##_end=(int)(end);i>=i##_end;--i)
#define foreach(x,a) for(auto&x:a)
using ll=long long;
const ll mod=(ll)1e9+7;
//}}}

int main(){
  string S;
  cin >> S;
  int x = (S[0] - '0') * 10 + S[1] - '0';
  int y = (S[2] - '0') * 10 + S[3] - '0';
  bool a = (0 <= x && x <= 99 && 1 <= y && y <= 12);
  bool b = (0 <= y && y <= 99 && 1 <= x && x <= 12);

  if(a){
    if(b){
      puts("AMBIGUOUS");
    }else{
      puts("YYMM");
    }
  }else{
    if(b){
      puts("MMYY");
    }else{
      puts("NA");
    }
  }
  return 0;
}


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

vector< int > z_algorithm(const string &s) {
    vector< int > prefix(s.size());
    for(int i = 1, j = 0; i < s.size(); i++) {
        if(i + prefix[i - j] < j + prefix[j]) {
            prefix[i] = prefix[i - j];
        } else {
            int k = max(0, j + prefix[j] - i);
            while(i + k < s.size() && s[k] == s[i + k]) ++k;
            prefix[i] = k;
            j = i;
        }
    }
    prefix[0] = (int) s.size();
    return prefix;
}

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

    int ans = 0;

    for(int i = 0;i < n;i++){
        string t;
        for(int j = i;j < n;j++){
            t.push_back(s[j]);
        }

        auto pre = z_algorithm(t);

        for(int j = 0;j < t.size();j++){
            ans = max(ans, min(pre[j], j));
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
require'date'

Week = ["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"];
while(0)
  a = gets;
  num = a.split(" ",2);
  if(num[0].to_i == 0)then
    break;
  end
  day = Date::new(2004,num[0].to_i,num[1].to_i);
  puts Week[day.wday];
end

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


int main(){
  long N;
  long sum = 0;

  cin >> N;
  for(long i = 1;i <= N;++i){
    if((i % 3) == 0 || (i % 5) == 0 ){
      sum += 0;
    }else{
      sum += i;
    }
  }

  cout << sum << endl;
}


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

#define BR "\n"
#define SP " "
#define SHOW(x) for(int i = 0; i < x.size(); i++) { cout << x[i] << SP; } cout << BR;
#define SHOW2(x) for(int j = 0; j < x.size(); j++) { SHOW(x[j]); } cout << BR;

int main() {
  ll N, D;
  cin >> N >> D;

  ll ans = N / (2*D+1);
  if (N % (2*D+1)) ans++;

  cout << ans << BR;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <bits/stdc++.h>
#include <vector>
#include <algorithm>
#include <cctype>
#include <string>

using namespace std;

int main(){
  int N, K, l;
  cin >> N >> K;
  int ans = 0;
  vector<int> vec(N);

  for (int i = 0; i < N; i++){
    cin >> l;
    vec.at(i) = l;
  }
  sort(vec.begin(), vec.end());
  reverse(vec.begin(), vec.end());

  for (int i = 0; i < K; i++){
    ans += vec.at(i);
  }

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


Measured memory_bytes: 384
#include<stdio.h>

#define MAX 1000
#define INFINITY 300000

int n;
int M[MAX][MAX], color[MAX], d[MAX], p[MAX];

enum Color {
    WHITE,
    GRAY,
    BLACK
};

void dijkstra() {
    for (int i = 0; i < n; ++i) {
        color[i] = WHITE;
        d[i] = INFINITY;
        p[i] = -1;
    }
    d[0] = 0;

    while (true) {
        int min = INFINITY;
        int target = -1;
        for (int i = 0; i < n; ++i) {
            if (d[i] < min && color[i] != BLACK) {
                min = d[i];
                target = i;
            }
        }
        if (target == -1) break;

        color[target] = BLACK;

        for (int v = 0; v < n; ++v) {
            if (color[v] != BLACK && M[target][v] != -1) {
                if(M[target][v] + d[target] < d[v]) {
                    d[v] = d[target] + M[target][v];
                    p[v] = target;
                    color[v] = GRAY;
                }
            }
        }
    }

    for (int i = 0; i < n; ++i) {
        printf("%d %d\n", i, d[i]);
    }
}

int main() {
    scanf("%d", &n);
    for (int i = 0; i < n; ++i) {
        for (int j = 0; j < n; ++j) {
            M[i][j] = -1;
        }
    }
    for (int i = 0; i < n; ++i) {
        int id, k;
        scanf("%d %d", &id, &k);
        for (int j = 0; j < k; ++j) {
            int t;
            scanf("%d", &t);
            scanf("%d", &M[id][t]);
        }
    }
    dijkstra();
    return 0;
}

Measured memory_bytes: 3068
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		int n = scanner.nextInt();
		int number[] = new int[n];
		for (int i = 0; i < n; i++) {
			int x = scanner.nextInt();
			number[i] = x;
		}
		int min = number[0];
		int max = number[1] - number[0];
		for (int i = 1; i < n; i++) {
			if (max < number[i] - min) {
				max = number[i] - min;
			}
			if (min > number[i]) {
				min = number[i];
			}
		}
		System.out.println(max);
	}
}


Measured memory_bytes: 100084
n=int(input())
s=list(input())
r=n-1
ans=0
for i in range(n):
    if s[i]=='W':
        while i<r:
            if s[r]=='R':
                s[i]='R'
                s[r]='W'
                ans+=1
                break
            r-=1
print(ans)  

Measured memory_bytes: 10768
#include <iostream>
#include <cstdlib>

using namespace std;

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

    int tmp = 0;
    for(int i = 0; i < n.size(); i++){
        tmp += n[i] - '0';
    }

    if(atoi(n.c_str()) % tmp == 0) cout << "Yes";
    else cout << "No";

}


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

string shuffle(string n, int h) {
    string top = n.substr(0,h);
    string bottom = n.substr(h, n.size()-h);
    return bottom + top;
}

int main() {
    string n;
    int m, h;

    while (1) {
        cin >> n;
        if (n == "-") break;
        cin >> m;
        rep(i,m) {
            cin >> h;
            n = shuffle(n,h);
        }
        cout << n << endl;
    }
}


Measured memory_bytes: 3208
import sys

stdin = sys.stdin
ns = lambda: stdin.readline().rstrip()
na = lambda: list(map(int, stdin.readline().split()))
ni = lambda: int(ns())

n = ni()
(s,t) = ns().split(" ")

ret = []
for i in range(0, n):
    ret.append(s[i])
    ret.append(t[i])

print("".join(ret))



Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
typedef long long LL;
int main(){
    int N,A,B;
    cin>>N>>A>>B;
    cout<<min(N*A,B)<<endl;
	return(0);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using lint = long long int;
using P = pair<int, int>;
using PL = pair<lint, lint>;
#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 ALL(a)  (a).begin(),(a).end()
constexpr int MOD = 1000000007;
constexpr lint B1 = 1532834020;
constexpr lint M1 = 2147482409;
constexpr lint B2 = 1388622299;
constexpr lint M2 = 2147478017;
constexpr int INF = 2147483647;
void yes(bool expr) {cout << (expr ? "Yes" : "No") << "\n";}
int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int N;
  cin >> N;
  vector<lint> A(N);
  REP(i, N) cin >> A[i];
  vector<lint> S(N);
  S[0] = A[0];
  FOR(i, 1, N) S[i] = (S[i-1] + A[i]) % MOD;
  lint ans = 0;
  REP(i, N) ans = (ans + A[i] * (S[N-1] - S[i] + MOD) % MOD) % MOD;
  cout << ans << endl;
}

Measured memory_bytes: 6360
<?php
  list($n, $sinsu) = explode(" ", fgets(STDIN));

  $keta = 1;
  while(1)
  {
    if(floor($n / $sinsu) == 0)
    {
      break;
    }
    $keta++;
    $n = floor($n / $sinsu);
  }
echo $keta;

Measured memory_bytes: 3700
#include <stdio.h>
#include <stdlib.h>
#include <string>
#include <vector>
#include <iostream>
#include <queue>
#include <unordered_map>

using namespace std;
class Problems{
public:
  unordered_map<int,queue<int> >dMap;
  
  string possible(int N, vector<int>dVec,int M,vector<int>tVec){
    setupDMap(N,dVec);
    string retStr = "YES";
    for(int i=0;i<M;i++){
      int tVal = tVec[i];
      if(dMap.find(tVal)==dMap.end()){
	retStr = "NO";
	break;
      }else if(dMap[tVal].empty()){
	retStr = "NO";
	break;
      }else{
	dMap[tVal].pop();
      }
    }
    return retStr;
  }
  
  void setupDMap(int N, vector<int>dVec){
    for(int i=0;i<N;i++){
      int dVal = dVec[i];
      if(dMap.find(dVal)==dMap.end()){
	queue<int>dq;
	dMap[dVal] = dq;
      }
      dMap[dVal].push(i);
    }
  }


};
vector<string>split(string s, char delim){
  int len = s.length();
  string currStr = "";
  vector<string>retVec;
  for(int i = 0;i<len;i++){
    char ch = s[i];
    if(ch==delim){
      retVec.push_back(currStr);
      currStr = "";
    }else{
      currStr += ch;
    }
  }
  retVec.push_back(currStr);
  return retVec;
}



vector<int>strToIntVec(string s){
  int len = s.length();
  //  s = s.substr(1,len-2);
  vector<string>strVec = split(s,' ');
  vector<int>retVec;
  for(int i=0;i<strVec.size();i++){
    int el = atoi(strVec[i].c_str());
    retVec.push_back(el);
  }
  return retVec;
}

  int main(int argc, const char*argV[]){
    string mLn,nLn,tLn,dLn;
    getline(cin,nLn);
    getline(cin,dLn);
    getline(cin,mLn);
    getline(cin,tLn);    
    int N = atoi(nLn.c_str());
    int M = atoi(mLn.c_str());
    vector<int>dVec = strToIntVec(dLn);    
    vector<int>tVec = strToIntVec(tLn);
    Problems probs;
    string posStr = probs.possible(N,dVec,M,tVec);
    cout<<posStr;
    return 0;
  }
  



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

using namespace std;

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	int N, X, tot = 0;
	map<int,int> m;
	cin >> N;
	for (int i = 1; i <= N; ++i){
		cin >> X;
		if (m.find(X) == m.end()){
			m[X] = 0;
		}
		m[X]++;
	}
	for (auto it : m){
		if (it.second >= it.first){
			tot += it.second-it.first;
		}
		else tot += it.second;
	}
	cout << tot << '\n';
	cout << flush;
	//for (int i = 0; i < 1e9; ++i){for (int j = 0; j < 1e9; ++j){}}
}

Measured memory_bytes: 4736
#include <stdio.h>

int main(){
	char ch;
	while((ch = getchar()) != EOF){
			if(ch >= 97 && ch <= 122)
				printf("%c",ch-32);
			else if(ch >= 65 && ch <= 90)
				printf("%c",ch+32);
			else
				printf("%c",ch);
	}
}



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

int main() {
	int n1,n2=0;
	cin>>n1;
	
	if(n1/100==1) n2+=900;
	else n2+=100;
	
	if((n1%100)/10==1) n2+=90;
	else n2+=10;
	
	if(n1%10==1) n2+=9;
	else n2+=1;
	
	cout<<n2<<endl;
	
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep1(i, n) for (int i = 1; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;
const double PI=acos(-1);
const int INF = numeric_limits<int>::max();

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

    if(isupper(n)) cout << "A" << endl;
    else cout << "a" << endl;

    return 0;
    
}

Measured memory_bytes: 3620
#define _USE_MATH_DEFINES
#define INF 0x3f3f3f3f
#include <cstdio>
#include <iostream>
#include <sstream>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <queue>
#include <stack>
#include <limits>
#include <map>
#include <string>
#include <cstring>
#include <set>
#include <deque>
#include <bitset>
#include <list>
#include <cctype>
#include <utility>

using namespace std;

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

int tx[] = {0,1,0,-1};
int ty[] = {-1,0,1,0};

static const double EPS = 1e-8;

static const int MAX_N = 1000000;
bool isPrime[MAX_N];

int Matsuzaki(int N,int P){
	vector<int> prime;
	for(int i=N+1;i<=N+100000;i++){
		if(isPrime[i]){
			prime.push_back(i);
			if(prime.size() >= 100) break;
		}
	}

	vector<int> compo;
	for(int i=0;i<prime.size();i++){
		for(int j=i;j<prime.size();j++){
			compo.push_back(prime[i]+prime[j]);
		}
	}

	sort(compo.begin(),compo.end());
	//unique(compo.begin(),compo.end());

	return compo[P-1];
}

int main(){
	int N,P;
	memset(isPrime,-1,sizeof(isPrime));

	isPrime[0] = false;
	isPrime[1] = false;

	for(int i=2;i<MAX_N;i++){
		if(!isPrime[i]) continue;

		for(int j=i+i;j<MAX_N;j+=i){
			isPrime[j] = false;
		}
	}

	while(~scanf("%d %d",&N,&P)){
		if(N==-1) break;
		printf("%d\n",Matsuzaki(N,P));
	}
}

Measured memory_bytes: 2248
// #include <bits/stdc++.h>
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <map>
#include <numeric>
#include <cmath>

#define rep(i,n) for (int i = 0; i < n; ++i)
#define repr(i,n) for (int i = n; i > 0; --i)
using namespace std;
using ll = long long;
using P = pair<int,int>;

const int MAX = 100;
const int INF = (1<<12);

int main() {
  int N, K, ans;
  cin >> N >> K;
  vector<int> p(N);
  rep(i,N) cin >> p[i];
  sort(p.begin(), p.end());
  ans = 0;
  rep(i,K) ans += p[i]; 
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3628
from sys import stdin
S = str(stdin.readline().rstrip())
#l = list(map(int, stdin.readline().rstrip().split()))
#A, B, C = map(int, stdin.readline().rstrip().split())
#S = [list(map(int, stdin.readline().rstrip().split())) for _ in range(h)]#hの定義を忘れずに

n = len(S)+1
sho = [0]*n
dai = [0]*n

for i,s in enumerate(S):
    i += 1
    if s ==">":
        sho[i] = 0
    else:
        sho[i] = sho[i-1] + 1

for i,s in enumerate(S[::-1]):
    i = n-i-2
    if s == "<":
        dai[i]=0
    else:
        dai[i] = dai[i+1] +1

seq = [max(x,y) for x,y in zip(sho,dai)]

print(sum(seq))


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

int n, m;
bool a[200001];

int main()
{
	cin >> n;

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

	for (int i = n; i > 0; i--) {
		for (int j = 2; j * i <= n; j++)
			a[i] = a[i] ^ a[i * j];

		m += a[i];
	}

	cout << m << endl;

	for (int i = 1; i <= n; i++)
		if (a[i])
			cout << i << endl;

	return 0;
}

Measured memory_bytes: 1280
/*
    NEVER GIVE UP!
    THE EXPERT IN ANYTHING WAS ONCE A BEGINNER
*/

#pragma GCC optimize("Ofast")

#include<bits/stdc++.h>
using namespace std;
#define FIO ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define ll long long int
#define ull unsigned long long int
#define ld long double
#define f(i,a,b) for(ll i=a; i<=b; i++)
#define fi(i,a,b) for(ll i=a; i>=b; i--)
#define fa(x,b) for(auto x:b)
#define TC ll test_case; cin>>test_case; for(ll number=1 ; number <= test_case ; number ++ )
#define vll vector<ll>
#define pb push_back
#define pll pair<ll,ll>
#define mp make_pair
#define ff first
#define ss second
#define sz(a) (ll)(a).size()
#define sp(x) cout << fixed << setprecision(x);
#define ReadFile freopen("input.txt","r",stdin)
#define WriteFile freopen("output.txt","w",stdout)
#define endl "\n"

const ld pi = acos(-1);
const ll M=1e9+7,N=1e7+5,INF=1e18;


void solve()
{
    ll k,n,s=0;
    cin >> n >> k;
    vll a(n);

    f(i,0,n-1)
        cin >> a[i];

    sort(a.begin(),a.end());
    reverse(a.begin(),a.end());

    f(i,k,n-1)
        s+=a[i];
    
    cout << s ;
}

int32_t main()
{
    FIO
    solve();
    return 0;
}

Measured memory_bytes: 1792
#!/usr/bin/env python3
from collections import defaultdict, Counter
from itertools import product, groupby, count, permutations, combinations
from math import pi, sqrt
from collections import deque
from bisect import bisect, bisect_left, bisect_right
from string import ascii_lowercase
from functools import lru_cache
import sys
sys.setrecursionlimit(10000)
INF = float("inf")
YES, Yes, yes, NO, No, no = "YES", "Yes", "yes", "NO", "No", "no"
dy4, dx4 = [0, 1, 0, -1], [1, 0, -1, 0]
dy8, dx8 = [0, -1, 0, 1, 1, -1, -1, 1], [1, 0, -1, 0, 1, 1, -1, -1]


def inside(y, x, H, W):
    return 0 <= y < H and 0 <= x < W


def ceil(a, b):
    return (a + b - 1) // b


def sum_of_arithmetic_progression(s, d, n):
    return n * (2 * s + (n - 1) * d) // 2


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


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


def solve():
    S, T = input().split()
    print(T + S)


def main():
    solve()


if __name__ == '__main__':
    main()


Measured memory_bytes: 9792
#include<bits/stdc++.h>
using namespace std;
#define LOCAL 0
#define lli long long int
const lli mod=1e9+7;
const lli pINF=LLONG_MAX;
const lli nINF=-LLONG_MAX;
void fast() {std::ios::sync_with_stdio(false);cin.tie(NULL);}
lli power(lli a,lli b){lli ans=1;while(b!=0){ if(b%2==1){ans*=a;}b/=2;a*=a;} return ans;}
lli invmod(lli a) {return pow(a,mod-2);}
#define vi vector<int>
#define vlli vector<lli>
#define pb push_back
#define mp make_pair
#define F first
#define S second
const int INT=1000000000;
const int INF=0x3f3f3f3f;
#define Pa pair<int,int>
#define si(n) scanf("%d",&n)
#define sli(n) scanf("%lld",&n)
#define printi(n) printf("%d\n",n)
#define ld long double
#define printli(n) printf("%lld\n",n)
#define all(v) v.begin(),v.end()
#define forn(i,n) for(int i=0;i<n;i++)
void print(int a[],int n){for(int i=0;i<n;i++) cout<<a[i]<<" ";}
int dis[105];
int ct1[26],ct2[26];

int main() 
{
    int n;
    si(n);
    
    string s;
    cin>>s;
    
    int ans=0;
    
    for(int i=0;i<n;i++){
        int cnt=0;
        memset(ct1,0,sizeof ct1);
        memset(ct2,0,sizeof ct2);
        string l=s.substr(0,i+1);
        string r=s.substr(i+1);
        
        for(int j=0;j<l.size();j++) ct1[l[j]-'a']++;
        for(int j=0;j<r.size();j++) ct2[r[j]-'a']++;
        
        for(int j=0;j<26;j++){
            if(ct1[j]>0 && ct2[j]>0){
                cnt++;
            }
        }
        ans=max(ans,cnt);
    }
    cout<<ans<<endl;
	return 0;
}

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

using ii = pair<long long, long long>;
using ll = long long;

#define REMOVE_REDUNDANT
struct pt {
	ll x, y;
	pt () {}
	pt (ll x, ll y) : x(x), y(y) {}
	bool operator < (const pt &o) const { return ii(y, x) < ii(o.y, o.x); }
	bool operator == (const pt &o) const { return ii(x, y) == ii(o.x, o.y); }
	pt operator + (const pt &o) const { return pt(x + o.x, y + o.y); }
};

ll cross(pt p, pt q) { return p.x * q.y - p.y * q.x; }
ll area2(pt a, pt b, pt c) { return cross(a,b) + cross(b,c) + cross(c,a); }

#ifdef REMOVE_REDUNDANT
bool between(const pt &a, const pt &b, const pt &c) {
	return (area2(a,b,c) == 0 && (a.x-b.x)*(c.x-b.x) <= 0 && (a.y-b.y)*(c.y-b.y) <= 0);
}
#endif

void ConvexHull(vector<pt> &pts) {
	sort(pts.begin(), pts.end());
	pts.erase(unique(pts.begin(), pts.end()), pts.end());
	vector<pt> up, dn;
	for(int i = 0; i < pts.size(); i++) {
		while (up.size() > 1 && area2(up[up.size()-2], up.back(), pts[i]) >= 0) up.pop_back();
		while (dn.size() > 1 && area2(dn[dn.size()-2], dn.back(), pts[i]) <= 0) dn.pop_back();
		up.push_back(pts[i]);
		dn.push_back(pts[i]);
	}
	pts = dn;
	for (int i = (int) up.size() - 2; i >= 1; i--) pts.push_back(up[i]);
  
#ifdef REMOVE_REDUNDANT
	if (pts.size() <= 2) return;
	dn.clear();
	dn.push_back(pts[0]);
	dn.push_back(pts[1]);
	for (int i = 2; i < pts.size(); i++) {
		if (between(dn[dn.size()-2], dn[dn.size()-1], pts[i])) dn.pop_back();
		dn.push_back(pts[i]);
	}
	if (dn.size() >= 3 && between(dn.back(), dn[0], dn[1])) {
		dn[0] = dn.back();
		dn.pop_back();
	}
	pts = dn;
#endif
}

const int maxn = 102;
int n;
ll x[maxn], y[maxn];

int main(int argc, char const *argv[])
{
	// freopen("in", "r", stdin);
	cin >> n;
	for(int i = 1; i <= n; i++) {
		cin >> x[i] >> y[i];
	}
	vector<pt> hull = {pt(0, 0)};
	for(int i = 1; i <= n; i++) {
		vector<pt> tmp;
		for(pt &p : hull) {
			tmp.emplace_back(p.x + x[i], p.y + y[i]);
		}
		vector<pt> all;
		merge(hull.begin(), hull.end(), tmp.begin(), tmp.end(), back_inserter(all));
		ConvexHull(all);
		hull = all;
	}
	ll mx = 0;
	for(pt &p : hull) {
		mx = max(mx, p.x * p.x + p.y * p.y);
	}
	printf("%.11lf\n", sqrt(double(mx)));
	return 0;
}

Measured memory_bytes: 256
/**
 *   author: Shubham Srivastava
 *   created: 27 January 2020  12:16:37
**/
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define MOD 1000000007
#define INF 0x7fffffff
#define sorti(v) sort(v.begin(),v.end())
#define sortd(v) sort(v.rbegin(),v.rend())
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vii;
ll parent[2000005];
vector <ll> arr;
vector <int> node[100005], vis(100005,false);
void dfs(ll n){
	vis[n] = 1;
	for(auto i : node[n]){
		if(!vis[i])
			dfs(i);
	}
	arr.push_back(n);
}

int main(){
    ios_base::sync_with_stdio(false); 
    cin.tie(NULL);
    ll n,m;cin>>n>>m;
    vector <int> dp(n+1,0);
    for(int i=0;i<m;i++){
    	ll a,b;cin>>a>>b;
    	node[a].push_back(b);
    }
    for(int i=1;i<=n;i++)
    	if(!vis[i])
    		dfs(i);
    reverse(arr.begin(),arr.end());
    for(int i=0;i<n;i++){
    	for(auto j : node[arr[i]]){
    		dp[j] = max(dp[j],dp[arr[i]]+1);
    	}
    }
    int ans = 0;
    for(int i=1;i<=n;i++)
    	ans = max(ans,dp[i]);
    cout<<ans;
return 0;
}

Measured memory_bytes: 11512
N = int(input())
A = list(map(int, input().split()))
f = True
for i in range(N):
  if A[i]%2==0:
    if A[i]%3!=0 and A[i]%5!=0:
      f = False
if f:
  print("APPROVED")
else:
  print("DENIED")

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

int main(){
	int hog,res=-1;
	cin>>hog;
	int n=0;
	for(int i=1;i<=60010;i++){
		n+=i;
		if(hog<=n){
			res=i;
			break;
		}
	}
	cout<<res<<endl;
	return 0;
}


Measured memory_bytes: 256
def main():
    S = input()
    N = len(S)
    ans = N
    for i in range(N - 1):
        if S[i] != S[i + 1]:
            ans = min([ans, max([i + 1, N - (i + 1)])])
    print(ans)


if __name__ == '__main__':
    main()

Measured memory_bytes: 3236
#include<bits/stdc++.h>
using namespace std;
int main(){
  int H,W,h,w,ans,all,out;
  //入力
  cin>>H;
  cin>>W;
  cin>>h;
  cin>>w;
  //処理
  all=H*W;
  out=h*W-h*w+w*H;
  ans=all-out;
  //出力
  cout<<ans<<endl;
}

Measured memory_bytes: 256
IDENTIFICATION DIVISION.
PROGRAM-ID. PROGRAM_ID.

DATA DIVISION.
WORKING-STORAGE SECTION.
01 ln         PIC X(400).
01 maxlen     PIC 9(10) VALUE 100 COMP.
01 cur        PIC 9(10) VALUE 1 COMP.
01 i          PIC 9(10) VALUE 1 COMP.
01 jidx       PIC 9(10) VALUE 1 COMP.
01 j          PIC 9(10) COMP.
01 k          PIC 9(10) COMP.
01 sidx       PIC 9(10) COMP VALUE 1.
01 eidx       PIC 9(10) COMP.
01 st         PIC 9(10) COMP.
01 len        PIC 9(10) COMP.
01 ans        PIC 9(10) VALUE ZERO.
01 pre        PIC 9(10)V9(10).
01 nxt        PIC 9(10)V9(10).
01 num        PIC 9(10).
01 zs         PIC Z(9)9.
01 N          PIC 9(10).
01 D          PIC 9(10).
01 X1.
   03 X11 OCCURS 100.
     05 X111 OCCURS 100.
        07 X PIC S9(10).

PROCEDURE DIVISION.
  ACCEPT ln.
  UNSTRING ln DELIMITED BY SPACE INTO N D.
  PERFORM VARYING i FROM 1 BY 1 UNTIL N < i
    ACCEPT ln
    MOVE D TO maxlen
    MOVE 1 TO cur
    MOVE 1 TO jidx
    PERFORM maxlen TIMES
      PERFORM VARYING j FROM cur BY 1 UNTIL ln(j:1) = SPACE
      END-PERFORM
      COMPUTE len = j - cur
      IF ln(cur:1) = "-"
        COMPUTE sidx = cur + 1
        COMPUTE eidx = len - 1
        MOVE ln(sidx:eidx) TO X(i jidx)
        COMPUTE X(i jidx) = -X(i jidx)
      ELSE
        MOVE ln(cur:len) TO X(i jidx)
      END-IF
      COMPUTE cur = j + 1
      ADD 1 TO jidx
    END-PERFORM
  END-PERFORM.
  PERFORM VARYING i FROM 1 BY 1 UNTIL N < i
    COMPUTE st = i + 1
    PERFORM VARYING j FROM st BY 1 UNTIL N < j
      MOVE ZERO TO num
      PERFORM VARYING k FROM 1 BY 1 UNTIL D < k
        COMPUTE num = num + (X(j k) - X(i k)) ** 2
      END-PERFORM
      COMPUTE pre = FUNCTION SQRT(num)
      MOVE pre TO num
      MOVE num TO nxt
      IF pre = nxt
        ADD 1 TO ans
      END-IF
    END-PERFORM
  END-PERFORM.
  MOVE ans TO zs.
  DISPLAY FUNCTION TRIM(zs).
  STOP RUN.


Measured memory_bytes: 3960
import java.util.Scanner;

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

        int N = scanner.nextInt();
        char[] S = scanner.next().toCharArray();
        char[] T = scanner.next().toCharArray();
        
        for (int i = 0 ; i < N ; i++) {
            System.out.print(S[i]);
            System.out.print(T[i]);
        }
        System.out.println();
    }
}


Measured memory_bytes: 35756
#include<bits/stdc++.h>
using namespace std;
int main()
{
long n,w;
  cin>>n>>w;
  vector<long > wt(n),val(n);
  for(int i=0;i<n;i++)
    cin>>wt[i]>>val[i];
  //knapsack
  vector<vector<long>> dp(n+1,vector<long>(w+1));
  for(int i=0;i<=n;i++)
  {
     for(int j=0;j<=w;j++)
     {
       if(i==0||j==0)
         dp[i][j]=0;
       else if(wt[i-1]<=j)
         dp[i][j]=max(val[i-1]+dp[i-1][j-wt[i-1]],dp[i-1][j]);
       else dp[i][j]=dp[i-1][j];
     }
  }
  cout<<dp[n][w];
  
}

Measured memory_bytes: 80256
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <stdlib.h>
#include <string.h>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <stdio.h>
#include <tuple>
#include <bitset>
#include <cfloat>
#include <fstream>
#include <limits.h>
#include <list>
#include <math.h>
#include <random>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <numeric>
#include <utility>
#include <sstream>

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;
}

using namespace std;
#define int long long
#define ll long long
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define FORR(i,a,b)for(ll i=(a);i<=(b);i++)
#define repr(i,n) for(ll i=n;i>=0;i--)
#define P pair<ll, ll>
#define sz(x) (ll)x.size()
#define ALL(x) (x).begin(),(x).end()
#define ALLR(x) (x).rbegin(),(x).rend()
#define VE vector<ll>
#define COUT(x) cout<<(x)<<endl
#define MA map<ll,ll>
#define SE set<ll>
#define PQ priority_queue<ll>
#define PQR priority_queue<ll,VE,greater<ll>>
#define COUT(x) cout<<(x)<<endl
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define EPS (1e-10)


const long long MOD = 1000000007;
//const long long MOD = 998244353;
const long long INF = 1LL << 60;


long long modinv(long long a, long long m) {
	long long b = m, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}
ll gcd(ll a, ll b) {
	if (a < b)swap(a, b);
	if (b == 0) return a;
	unsigned r;
	while ((r = a % b)) {
		a = b;
		b = r;
	}
	return b;
}
ll lcm(ll a, ll b) {
	ll g = gcd(a, b);
	return a * g / b;
}
bool prime(ll n) {
	for (ll i = 2; i <= sqrt(n); i++) {
		if (n%i == 0)return false;
	}
	return n != 1;
}




const long double PI = 3.14159265359;
const int MAX_N = 100010;



signed main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int k, x; cin >> k >> x;
	k--;
	for (int i = x - k; i <= x + k; i++) {
		cout << i << endl;
	}
	return 0;
}

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

using ll = long long;
using ull = unsigned long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;

#define REPS(i, a, n) for (int i = (a); i < (n); ++i)
#define REP(i, n) REPS(i, 0, n)
#define RREP(i, n) REPS(i, 1, n + 1)
#define DEPS(i, a, n) for (int i = (a); i >= n; --i)
#define DEP(i, n) DEPS(i, n, 0)

#define vint(v, n) vector<int> v(n); REP(i,n) cin >> v[i];
#define vvint(v, w, n) vector<int> v(n); vector<int> w(n); REP(i,n) cin >> v[i] >> w[i];
#define vlint(v, n) vector<ll int> v(n); REP(i,n) cin >> v[i];
#define vdouble(v, n) vector<double> v(n); REP(i,n) cin >> v[i];
#define vvdoube(v, n1, n2) vector<vector<double> > v(n1, vector<double>(n2, 0)); REP(i,n1) REP(j,n1) cin >> v[i][j];
#define string(x) string x; cin >> x;
#define vstring(v, n) vector<string> v(n); REP(i,n){string a; std::cin >> a; v.push_back(a); }

#define all(v) (v).begin(), (v).end()
#define rall(v) (v).begin(), (v).end(), std::greater<int>()
#define len(v) (v).length()
#define FIND(s, n) (s.find(n) != s.end())
#define SORT(a) sort(all(a))

static const string abet("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ");
static const long long MOD = 1000000007;
static const double PI=3.1415926535897932;
static const int INF = 0x3f3f3f3f;
static const int INFTY = (1 << 29);
static const long long LINFTY = (1LL << 32);

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

int N, M, res;
int G[100][100];
int c[100], m[100];

int dfs(int b, int n) {
	c[n] = 1;
	for (int i = 0; i < N; i++) {
		if (b == i || n == i) continue;
		if (G[n][i]) {
			if (c[i] == 1) return 0;
			if (!dfs(n, i)) return 0;
		}
	}
	return 1;
}

int isPrime(int x){
  int i;
  if(x < 2) return 0;
  else if(x == 2) return 1;
  if( x%2 == 0) return 0;
  for(i = 3; i*i <= x; i += 2){
    if(x%i == 0) return 0;
  }
  return 1;
}

const int pmax = 1000000;
bool isPrime_table[pmax];
//const is necessary;
void eratos(void){
  int i, j;
  double sqrtmax=sqrt(pmax);

  REP(k, pmax) isPrime_table[k] = true; /* Initialization */

  /* Sieve process  */
  isPrime_table[0] = false;
  isPrime_table[1] = false;
          /* 0 and 1 are not prime. */
  for (i=2; i <= sqrtmax; i++){
    if (isPrime_table[i]==true){   /* i is prime. */
      for (j=i; i*j<pmax; j++){
        isPrime_table[i*j] = false; /* multiples of i are not prime. */
      }
    }
  }
}

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

	long long int N, A, B;
	cin >> N >> A >> B;

	vint(X, N);

	long long tot = 0;
	REP(i, N-1) tot += min((X[i+1]-X[i])*A, B);

	cout << tot << endl;

	return 0;
}


Measured memory_bytes: 640
# coding:utf-8


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


N, M = inpl()

A = 1
ans = 1
while A * A <= M:
    # 約数判定
    if M % A != 0:
        A += 1
        continue
    B = M // A

    # dはM // N以下
    if A * N <= M:
        ans = max(ans, A)
    # M = A * BでAはsqrt(M)までしか探索しない
    # 答えがsqrt(M)以上M // N以下のときWAになるので
    # AだけではなくBでも判定を行う
    # だから全探索の時は必要なかったのか...
    if B * N <= M:
        ans = max(ans, B)

    A += 1

print(ans)


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

const int inf = 1e9;

const int lst[] = {
    1,
    6, 6*6, 6*6*6, 6*6*6*6, 6*6*6*6*6, 6*6*6*6*6*6,
    9, 9*9, 9*9*9, 9*9*9*9, 9*9*9*9*9
};

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

    vector<int> dp(n + 1, inf);
    dp[0] = 0;

    for (int i = 0; i < n; i++) {
        for (auto& e: lst) {
            if (i + e > n) continue;
            dp[i+e] = min(dp[i+e], dp[i] + 1);
        }
    }
    cout << dp[n] << endl;
    return 0;
}

Measured memory_bytes: 640
#pragma GCC target("avx2")
#pragma GCC optimization("O3")
#pragma GCC optimization("unroll-loops")
#include <algorithm>
#include <assert.h>
#include <bitset>
#include <cfloat>
#include <complex>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits.h>
#include <list>
#include <map>
#include <math.h>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <string.h>
#include <time.h>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,n) for(int i=1;i<=(n);i++)
#define int long long
#define ll long long
#define mod (int)1000000007
#define P pair<int,int>
#define prique(T) priority_queue<T,vector<T>,greater<T>>
#define all(V) V.begin(),V.end()
#ifdef int
constexpr int INF = LLONG_MAX / 10;
#else
constexpr int INF = INT_MAX / 10;
#endif
constexpr double eps = DBL_EPSILON;
template <class T, class U>
inline bool chmax(T& lhs, const U& rhs) {
	if (lhs < rhs) {
		lhs = rhs;
		return 1;
	}
	return 0;
}
template <class T, class U>
inline bool chmin(T& lhs, const U& rhs) {
	if (lhs > rhs) {
		lhs = rhs;
		return 1;
	}
	return 0;
}
using namespace std;
inline int gcd(int a, int b) {
	while (b) {
		int c = a;
		a = b; b = c % b;
	}
	return a;
}
inline int lcm(int a, int b) {
	return a / gcd(a, b) * b;
}
bool isprime(int n) {
	if (n == 1)return false;
	for (int i = 2; i * i <= n; i++) {
		if (n % i == 0)return false;
	}
	return true;
}
int mypow(int a, int b) {
	if (!b)return 1;
	if (b & 1)return mypow(a, b - 1) * a;
	int memo = mypow(a, b >> 1);
	return memo * memo;
}
int modpow(int a, int b, int m = mod) {
	if (!b)return 1;
	if (b & 1)return modpow(a, b - 1, m) * a % m;
	int memo = modpow(a, b >> 1, m);
	return memo * memo % m;
}
class BIT {
	int n;
	int* bit;
public:
	BIT(int n) :n(n) {
		bit = new int[n + 1];
		fill(bit + 1, bit + n + 1, 0);
	}
	void add(int a, int x) {
		while (a < n) {
			bit[a] += x;
			a += a & -a;
		}
	}
	int query(int a) {
		int cnt = 0;
		while (a > 0) {
			cnt += bit[a];
			a -= a & -a;
		}
		return cnt;
	}
};
int n, q, t, a, b;
string s;
char c;
signed main() {
	cin >> n >> s >> q;
	vector<BIT> vec;
	rep(i, 26) {
		vec.emplace_back(n + 1);
	}
	rep(i, n) {
		vec[s[i] - 'a'].add(i + 1, 1);
	}
	rep(i, q) {
		cin >> t;
		if (t == 1) {
			cin >> a >> c;
			vec[s[a - 1] - 'a'].add(a, -1);
			vec[c - 'a'].add(a, 1);
			s[a - 1] = c;
		}
		else {
			cin >> a >> b;
			int ans = 0;
			rep(j, 26) {
				if (a > 1) {
					if (vec[j].query(b) - vec[j].query(a - 1))ans++;
				}
				else if (vec[j].query(b)) {
					ans++;
				}
			}
			cout << ans << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 102532