akhauriyash/Code-Regression huggingface dataset:
from math import floor,ceil,sqrt,factorial,log
from collections import Counter, deque
from functools import reduce
import numpy as np
def S(): return input()
def I(): return int(input())
def MS(): return map(str,input().split())
def MI(): return map(int,input().split())
def FLI(): return [int(i) for i in input().split()]
def LS(): return list(MS())
def LI(): return list(MI())
def LLS(): return [list(map(str, l.split() )) for l in input()]
def LLI(): return [list(map(int, l.split() )) for l in input()]
def LLSN(n: int): return [LS() for _ in range(n)]
def LLIN(n: int): return [LI() for _ in range(n)]

n, k = MI()

h = FLI()
h.sort(reverse = True)
print(sum(h[k:]))

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

int main(){
  long long A, B;
  cin >> A >> B;
  long long g = __gcd(A,B);
  int c = 1;
  for(long long i = 2; i*i <= g; ++i){
    if(g%i) continue;
    ++c;
    while(g%i == 0) g /= i;
  }
  if(g > 1) ++c;
  cout << c << endl;
}


Measured memory_bytes: 256
#include <iostream>
int whatPrice(int, int);

int main(){
	int n;
	while(std::cin >> n, n){
		int price = 0;
		while(n--){
			int x, y, h, w;
			std::cin >> x >> y >> h >> w;
			price += whatPrice(x+y+h, w);
		}
		std::cout << price << std::endl;
	}
}

int whatPrice(int size, int weight){
	int price = 0;
	//A size
	if(size <= 60 && weight <= 2){
		price = 600;
	}
	//B size
	else if(size <= 80 && weight <= 5){
		price = 800;
	}
	//C size
	else if(size <= 100 && weight <= 10){
		price = 1000;
	}
	//D size
	else if(size <= 120 && weight <= 15){
		price = 1200;
	}
	//E size
	else if(size <= 140 && weight <= 20){
		price = 1400;
	}
	//F size
	else if(size <= 160 && weight <= 25){
		price = 1600;
	}
	//FTCYð´¦êÎCifÉøÁ©©ç¸úlÌ0ÆÈéD

	return price;
}

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

pair<long, long> connected(int x, int y, int px, int py, vector<vector<int>>& s, vector<vector<int>>& t, int H, int W){
    if(x < 0 || y < 0 || x >= H || y >= W || s[x][y] != s[px][py] || t[x][y])return {0, 0};
    t[x][y] = 1;
    pair<long, long> ret({0, 0});
    vector<int> mv({0, 1, 0, -1, 0});
    for(int i = 0; i < 4; ++i){
        auto tmp = connected(x + mv[i], y + mv[i + 1], x, y, s, t, H, W);
        ret.first += tmp.first;
        ret.second += tmp.second;
    }
    ++((x ^ y) & 1 ? ret.first : ret.second);
    return ret;
}

int main(){
    int H, W;
    scanf("%d%d", &H, &W);
    vector<vector<int>> s(H, vector<int>(W)), t(H, vector<int>(W));
    {
        string S;
        for(int i = 0; i < H; ++i){
            cin >> S;
            for(int j = 0; j < W; ++j){
                s[i][j] = (S[j] ^ i ^ j) & 1;
            }
        }
    }
    long ans(0);
    for(int i = 0; i < H; ++i){
        for(int j = 0; j < W; ++j){
            auto tmp = connected(i, j, i, j, s, t, H, W);
            ans += tmp.first * tmp.second;
        }
    }
    printf("%lld\n", ans);
    return 0;
}

Measured memory_bytes: 24064
#include<bits/stdc++.h>
    #include<string.h>
    using namespace std;
    int main(){
        int a,b,z=1;
        cin>>a>>b;
        for(int i=0;i<a;i++){
            int x,y;
            x=z*2;
            y=z+b;
            if(y<x) z=y;
            else z=x;
        }
        cout<<z<<endl;
    }


Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
	"strconv"
)

func out(x ...interface{}) {
	fmt.Println(x...)
}

var sc = bufio.NewScanner(os.Stdin)

func getInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func getString() string {
	sc.Scan()
	return sc.Text()
}

// min, max, asub, absなど基本関数
func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func asub(a, b int) int {
	if a > b {
		return a - b
	}
	return b - a
}

func abs(a int) int {
	if a >= 0 {
		return a
	}
	return -a
}

func main() {
	sc.Split(bufio.ScanWords)
	N, K := getInt(), getInt()
	a := make(map[int]int)
	for i := 0; i < N; i++ {
		x := getInt()
		a[x]++
	}
	b := make([]int, len(a))
	idx := 0
	for _, v := range a {
		b[idx] = v
		idx++
	}
	sort.Ints(b)
	// out(b)
	sum := 0
	for i := len(b) - 1; i >= 0; i-- {
		// out(i, sum, K)
		if sum >= K {
			break
		}
		sum++
	}
	ans := 0
	for i := 0; i < len(b)-sum; i++ {
		ans += b[i]
	}
	out(ans)
}


Measured memory_bytes: 14532
def isSameThree(num_of_indices):
    same_count = 0
    for d1,d2 in num_of_indices:
        if(d1 == d2):
            same_count += 1
            if(same_count == 3):
                return "Yes"
        else:
            same_count = 0
    return "No"
N = int(input())
num_of_indices = [list(map(int,input().split())) for i in range(N)]
print(isSameThree(num_of_indices))

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

int main()
{
	int n, m, yoko, tate, p, q, r, s;
	cin >> n;
	for (int i = 0; i < n; i++){
		cin >> yoko >> tate;
		int a[20][20] = {};
		int b[20][20] = {};
		cin >> m;
		if (m != 0) {
			for (int j = 0; j < m; j++){
				cin >> p >> q >> r >> s;
				if (p == r && q>s) a[q][p] = a[q][p] + 1;
				if (p == r && q<s) a[s][r] = a[s][r] + 1;
				if (q == s && p>r) a[q][p] = a[q][p] + 10;
				if (q == s && p<r) a[s][r] = a[s][r] + 10;
			}
		}
		for (int x = 1; x <= yoko+1; x++){
			for (int y = 1; y <= tate+1; y++){
				if (x == 1 && y == 1) {
					b[y][x] = 1;
				} else if (a[y-1][x-1]==0){
					b[y][x] = b[y-1][x]+b[y][x-1];
				} else if (a[y - 1][x - 1] == 1){
					b[y][x] = b[y][x - 1];
				} else if (a[y - 1][x - 1] == 10){
					b[y][x] = b[y - 1][x];
				} else if (a[y - 1][x - 1] == 11){
					b[y][x] = 0;
				}
			}
		}
		if (b[tate + 1][yoko + 1] == 0){
			cout << "Miserable Hokusai!" << endl;
		}
		else{
			cout << b[tate + 1][yoko + 1] << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 1164
# coding: utf-8
# Your code here!
n1=int(input())
n2=int(input())
n3=int(input())
n4=int(input())
n5=int(input())
n6=int(input())
n7=int(input())
n8=int(input())
n9=int(input())
n10=int(input())

n1,n2,n3,n4,n5,n6,n7,n8,n9,n10=sorted([n1,n2,n3,n4,n5,n6,n7,n8,n9,n10])

print(n10)
print(n9)
print(n8)


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


int main() {
    int a, b;
    cin >> a >> b;
    cout << a * b << " " << (a + b) * 2 << endl;
}


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

int main(){
  int N;
  cin>>N;
  vector<int> vec(N);
  for(int i=0;i<N;i++){
    cin>>vec.at(i);
  }
  sort(vec.begin(),vec.end());
  reverse(vec.begin(),vec.end());
  int sum=0;
  for(int i=0;i<N;i++){
    if(i%2==0){
      sum+=vec.at(i);
    }else{
      sum-=vec.at(i);
    }
  }
  cout<<sum<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define pb push_back
#define fi first
#define se second
using namespace std;
typedef long long ll;
const int maxn=1e5+233;
int n,m;
int a[5],vis[5],b[5],c[5]={0,1,2,3,4};
int ans=(int)1e9;
int calc(){
	int t=0;
	for(int i=0;i<4;i++){
		t+=ceil(1.0*b[i]/10)*10;
	}
	t+=b[4];
	return t;
}
int main()
{
	ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	for(int i=0;i<5;i++)cin>>a[i];
	do{
		for(int i=0;i<5;i++){
			b[i]=a[c[i]];
		}
		ans=min(ans,calc());
	}while(next_permutation(c,c+5));
	cout<<ans<<endl;
    return 0;
}


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

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)   FOR(i,0,n)
#define ALL(a)     (a).begin(),(a).end()
#define VI         vector<int>
#define MOD 1000000007

using ll = long long int;
using P = pair<int,int>;

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

//const ll INF=(ll)1e19;
const int INF=(1<<30);

int n,m;
int edge[15][15];
int dp[(1<<15)][15];

int dfs(int S, int v){
//  printf("%d %d\n", S, v);
  if(dp[S][v]>=0)return dp[S][v];

  if(S==((1<<n)-1) && v == 0)return dp[S][v] = 0;

  int tmp = INF;
  REP(i,n){
    if(edge[v][i]==INF)continue;

    if(!((S>>i) & 1)){
      chmin(tmp, dfs(S | (1<<i), i) + edge[v][i]);
    }

  }
//  cout << tmp << endl;
  return dp[S][v] = tmp;
}

int main(){
  cin >> n >> m;
  REP(i,15)REP(j,15)edge[i][j]=INF;
  REP(i,(1<<n))REP(j,n)dp[i][j]=-1;

  REP(i,m){
    int s,t,d;
    cin >> s >> t >> d;
    edge[s][t] = d;
  }

  int ans = dfs(0,0);
  cout << (ans == INF ? -1 : ans) << endl;



}



Measured memory_bytes: 4928
#include<iostream>
using namespace std;
long MOD=998244353,n,k,i,ans[2002],p2[4001]={1},C[4001][4001],p,q,s;
int f(long t){for(p=t/2-!(t%2),s=q=0;q<=p;q++)s=(s+p2[q]*C[p][q]%MOD*(n<q?0:C[k-2*p-!(t%2)+n-1][n-q])%MOD)%MOD;}
main(){
	cin>>k>>n;
	for(**C=i=1;i<=4000;i++)for(p2[i]=p2[i-1]*2%MOD,C[i][0]=s=1;s<=i;s++)C[i][s]=(C[i-1][s-1]+C[i-1][s])%MOD;
	for(i=1;i++<=k;cout<<ans[i]%MOD<<endl)f(i),ans[i]=s,i%2||(n--,f(i),ans[i]+=s,n++);
	for(--i;--i>1;)cout<<ans[i]%MOD<<endl;
}

Measured memory_bytes: 123648
<?php
//$n = 4;
//for ($i = 0; $i < $n; ++$i) {
//    $a[] = intval(trim(fgets(STDIN)));
//}
$input = fgets(STDIN);
// 取得した入力値を半角スペースで分解します
$a = explode(" ", $input);
$l = ($a[0] + $a[1]);
$r = ($a[3] + $a[2]);
//echo $l . $r;
if ($l == $r){
    $ans = 'Balanced';
}
if($l < $r){
$ans = 'Right';
}
if ($l > $r ){
    $ans = 'Left';
}


echo $ans . "\n";


Measured memory_bytes: 4604
n,m=map(int,input().split())
A=[]
for i in range(n):
    A.append(list(map(int,input().split())))
C=[0 for i in range(m+1)]

for i in range(n):
    for j in range(1,len(A[i])):
        #print(i)
        #print(j)
        C[A[i][j]]+=1
co=0
for i in range(m+1):
    if C[i]==n :
        co+=1
print(co)


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

#define ABS(x) ( (x)>0 ? x : -(x) )
#define MIN(x,y) ( (x) < (y) ? (x) : (y) )

#define INF 1000000000

void swap(int* x, int *y)
{
	int t;

	t = *x;
	*x = *y;
	*y = t;
}

int binary_search(int p[], int n, int key)
{
	int left, right, middle;

	left = 0;
	right = n-1;


	while (left <= right)
	{
		middle = (left + right) / 2;

		if (p[middle] == key)
			return middle;
		else if (p[middle] > key)
		{
			right = middle - 1;
		}
		else if (p[middle] < key)
		{
			left = middle + 1;
		}
	}

	return -1;

}

void bubble_sort(int p[], int n)
{
	int i, j;

	for (i = 0; i < n-1; i++)
	{
		for (j = 0; j < n - i - 1; j++)
		{
			if (p[j] > p[j + 1])
				swap(&p[i], &p[i + 1]);
		}
	}
}

int main()
{
	int a, b;

	scanf("%d%d", &a, &b);

	if (a < b)
		printf("a < b\n");
	else if (a > b)
		printf("a > b\n");
	else
		printf("a == b\n");

}


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

int main() {
  int N, M;
  cin >> N >> M;
  vector<int> A(N);
  for (int i = 0; i < A.size() ; i++)
  {
    cin >> A[i];
  }
  
  map<int, int> m;
  vector<int> SUM(N + 1);
  SUM[0] = 0;
  for (int i = 0; i < N; i++)
  {
    SUM[i + 1] = (SUM[i] + A[i]) % M;
  }
  
  long long ans = 0;
  
  for (int i = 0; i < SUM.size(); i++)
  {
    ans += m[SUM[i]];
    m[SUM[i]]++;
  }
  
  cout << ans << endl;
}

Measured memory_bytes: 3968
#include <bits/stdc++.h>
// atoi : atoi(変数名.c_str())
// to_string(数値)
// %0桁数d とすると表示桁数が「桁数」に満たない場合に0埋めされる
// find(): int i = 変数名.find(“文字列”) 何番目にあるかを得る
// cout << (条件 ? "Yes" : "No") << endl;
// printf("%02d:%02d:%02d",hour,minute,second);
// 降順 sort(a.begin(),a.end(),greater<int>());
// bitset<ビット数> 変数名;  // すべてのビットが0の状態で初期化される
// bitset<ビット数> 変数名("ビット列");  // 指定したビット列で初期化される
using namespace std;
using vi = vector<int>;
using vb = vector<bool>;
using vc = vector<char>;
using vs = vector<string>;
using vvi = vector<vector<int>>;
using vvc = vector<vector<char>>;
using pii = pair<int, int>;
#define fix10 cout << fixed << setprecision(10);
#define rep(i,n) for(int i=0; i<(int)(n);i++)

int main(){
  int n;
  cin >> n;
  vector<bool> color(8,false);
  int count = 0;
  rep(i,n){
    int a;
    cin >> a;
    if(a >= 3200) count++;
    else{
      color.at(a/400) = true;
    }
  }
  int ans = 0;
  rep(i,8) ans += color.at(i);
  if(ans == 0 && count != 0){
    cout << 1 << " " << count << endl;
    return 0;
  }
  cout << ans << " ";
  ans += count;
  cout << ans << endl;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
int n;
  cin>>n;
int   a[n];
  for(int i=0;i<n;i++){
  cin>>a[i];}
  int count =0;
  for(int i=0;i<n;i++){
  if((i+1)%2!=0&&a[i]%2!=0){
  count++;
  }
  }
  cout<<count<<endl;
  
  
}

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

using namespace std;
long long A,B,C,ans;
long long k;
int main()
{
    cin>>A>>B>>C;
    for(int i=0;i<A;i++)
    {
        cin>>k;
        if(k<B||k>=C)ans++;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
    int N;
    long long int x,a[2],ans=0;

    scanf("%d%lld%lld",&N,&x,&a[0]);

    if(a[0]>x) {
        ans=a[0]-x;
        a[0]=x;
    }

    for(int i=1;i<N;i++) {
        scanf("%lld",&a[1]);
        if(a[0]+a[1]>x){
            ans+=a[0]+a[1]-x;
            a[0]=x-a[0];
        } else {
            a[0]=a[1];
        }
    }

    printf("\n%lld",ans);

    return 0;
}


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

int main() {
    string s;
    cin >> s;
    int n = s.length();
    int ans_a=0; //0101010
    int ans_b=0; //10101010
    for(int i=0; i<n; i++){
        if(i%2==0){
            if(s[i]=='0'){
                ans_a++;
            }else{
                ans_b++;
            }
        }else{
            if(s[i]=='0'){
                ans_b++;
            }else{
                ans_a++;
            }
        }
    }
    cout << min(ans_a, ans_b) << endl;
    return 0;
}

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

if 1 == N:
	print(1)
	exit()

vsum = 0
for i, v in enumerate(range(1, N * 2, 2)):
	#print(i, v, vsum)
	vnext = vsum + v
	if N < vnext:
		print(i**2)
		break
	vsum = vnext


Measured memory_bytes: 2940
#include <bits/stdc++.h>
#define debug(x) cerr << #x << ": " << x << '\n';
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int INF = (int)1e9;
const int MOD = (int)1e9 + 7;

#ifndef MOD_INT
#define MOD_INT
template<int mod>
struct ModInt{
  int x;

  ModInt() : x(0){}
  ModInt(int64_t y) : x(y >= 0 ? y % mod : (mod - (-y) % mod) % mod){}

  ModInt &operator+=(const ModInt &p){
    if((x += p.x) >= mod) x -= mod;
    return *this;
  }
  ModInt &operator-=(const ModInt &p){
    if((x += mod - p.x) >= mod) x -= mod;
    return *this;
  }
  ModInt &operator*=(const ModInt &p){
    x = (int) (1LL * x * p.x % mod);
    return *this;
  }
  ModInt &operator/=(const ModInt &p){
    *this *= p.inverse();
    return *this;
  }

  ModInt operator-() const {return ModInt(-x);}
  ModInt operator+(const ModInt &p) const {return ModInt(*this) += p;}
  ModInt operator-(const ModInt &p) const {return ModInt(*this) -= p;}
  ModInt operator*(const ModInt &p) const {return ModInt(*this) *= p;}
  ModInt operator/(const ModInt &p) const {return ModInt(*this) /= p;}
  bool operator==(const ModInt &p) const {return x == p.x;}
  bool operator!=(const ModInt &p) const {return x != p.x;}

  ModInt inverse() const {
    int a = x, b = mod, u = 1, v = 0, t;
    while(b > 0) {
      t = a / b;
      swap(a -= t * b, b);
      swap(u -= t * v, v);
    }
    return ModInt(u);
  }

  ModInt pow(int64_t n) const {
    ModInt ret(1), mul(x);
    while(n > 0) {
      if(n & 1) ret *= mul;
      mul *= mul;
      n >>= 1;
    }
    return ret;
  }

  friend ostream &operator<<(ostream &os, const ModInt &p){
    return os << p.x;
  }

  friend istream &operator>>(istream &is, ModInt &a){
    int64_t t;
    is >> t;
    a = ModInt< mod >(t);
    return (is);
  }

  static int get_mod(){return mod;}
};

using mint = ModInt<MOD>;
#endif

mint dp[201][201];

int main(void){
    int n;
    cin >> n;
    vector<char> c(n);
    for(int i = 0; i < n; i++) cin >> c[i];

    dp[0][0] = 1;
    for(int i = 0; i < n; i++){
        for(int j = 0; j <= i; j++){
            if(c[i] == 'U'){
                { // 2
                    int nj = j;
                    mint x = j;
                    dp[i+1][nj] += dp[i][j] * x;
                }
                { // 3
                    int nj = j+1;
                    dp[i+1][nj] += dp[i][j];
                }
            }else if(c[i] == 'D'){
                { //2
                    int nj = j;
                    mint x = j;
                    dp[i+1][nj] += dp[i][j] * x;
                }
                if(j >= 1){ // 4
                    int nj = j-1;
                    mint x = j*j;
                    dp[i+1][nj] += dp[i][j] * x;
                }
            }else if(c[i] == '-'){
                { //1
                    int nj= j;
                    dp[i+1][nj] += dp[i][j];
                }
            }
        }
    }

    cout << dp[n][0] << '\n';

    return 0;
}


Measured memory_bytes: 3252
#!/usr/bin/env python3
from itertools import product, permutations, combinations
from bisect import bisect_right,bisect_left
INF = float('inf')

N=int(input())
dp = [[0 for i in range(3)] for j in range(N)]
h=[list(map(int, input().split())) for i in range(N)]
for i in range(N):
    if i == 0:
        dp[0] = h[0]
        continue
    for j in range(3):
        for k in range(3):
            if j == k:
                continue
            dp[i][j] = max(dp[i][j], dp[i-1][k]+h[i][j])
print(max(dp[-1]))


Measured memory_bytes: 52004
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        while(true){
            int a = sc.nextInt();
            int b = sc.nextInt();
            if(a == 0 && b == 0)break;
            for(int i = 0; i<a; i++){
                for(int j=0;j<b;j++){
                    if(i != 0 && i != a-1 && j != 0 && j != b-1){
                        System.out.print(".");
                    }else{
                        System.out.print("#");
                    }
                }
                System.out.println();
            }
            sc.nextLine();
            System.out.println();
        }
    }
}


Measured memory_bytes: 34528
#include<iostream>
#include<stdio.h>
#include<vector>//s1.erase(n)=文字列s1の、n文字目以降削除
#include<algorithm>//辞書順=next_permutation
#include<set>
#include<string>//char 小文字のほうが32大きい
#include<sstream>
#include<string.h>
#include<complex>
#include<time.h>
#include<random>
#include<cmath>
#include<math.h>
#include<queue>
#include<time.h>
#include<iomanip>
#include<locale>
#include<utility>//swap=数値交換
#define rt "\n"
#define rep(i,n) for(int i=0;i<n;i++)
#define rop(i,n) for(int i=1;i<=n;i++)
#define drep(i,n) for(int i=n-1;0<=i;i--)
#define drop(i,n) for(int i=n;0<i;i--)
#define yes(ans) if(ans)cout<<"yes"<<rt;else cout<<"no"<<rt;
#define Yes(ans) if(ans)cout<<"Yes"<<rt;else cout<<"No"<<rt;
#define YES(ans) if(ans)cout<<"YES"<<rt;else cout<<"NO"<<rt;
#define sec(a,b,ans) if(ans)cout<<a<<rt;else cout<<b<<rt;
#define vcin(s,n) rep(i,n)cin>>s[i];//vcin(配列名),(繰り返し回数)
#define sort(s) sort(s.begin(),s.end())//標準=昇順
#define reve(s) reverse(s.begin(),s.end())
#define asas int ans=0
#define llcncn llint cnt=0
#define llasas llint ans=0
#define str string
#define please return
#define AC 0
#define ic_a int a;cin>>a;
#define ic_b int b;cin>>b;
#define Rapid_pleaseAC_fast cin.tie(0);ios::sync_with_stdio(false)
#define Pi 3.1415926535897932384626
#define nine 1000000000

using namespace std;
typedef vector<int> vint;
typedef vector<string> vstr;
typedef vector<char> vchar;
typedef vector<double> vdou;
typedef long long int llint;
typedef pair<int, int> pint;
typedef pair<llint, llint> pllint;
typedef vector<llint> vllint;
typedef vector<pint> vpint;
typedef vector<pair<llint, llint>> vpllint;
typedef vector<vector<int>> vvint;
typedef vector<vector<char>> vvchar;
typedef vector<vector<llint>> vvllint;
typedef vector<vector<string>> vvstr;
typedef vector<vector<bool>> vvbool;
typedef vector<vector<pint>> vvpint;
typedef vector<bool> vbool;

long long GCD(long long a, long long b) {
	if (b == 0) return a;
	else return GCD(b, a % b);
}

long long LCM(long long a, long long b) {
	return a * b / GCD(a, b);
}

unsigned GetDigit(unsigned num) {
	return std::to_string(num).length();
}

int tow(int n) {//2のn乗
	if (n == 0)return 1;
	int x = tow(n / 2);
	x *= x;
	if (n % 2 == 1)x *= 2;
	return x;//@domino
}

/*

 (char)toupper(a[n])=文字列のn文字目を大文字で出力

  pow(a,b)=aのb乗

  */


int main(void) {
	Rapid_pleaseAC_fast;

	ic_a;
	if (a < 1200)cout << "ABC" << rt;
	else if (a < 2800)cout << "ARC" << rt;
	else cout << "AGC" << rt;

	please AC;
}

Measured memory_bytes: 256
import java.util.*;

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

        int n = sc.nextInt();
        int[] a = new int[n];
        int[] b = new int[n];
        int[] c = new int[n];
        for (int i = 0; i < n; i++) {
            a[i] = sc.nextInt();
        }
        for (int i = 0; i < n; i++) {
            b[i] = sc.nextInt();
        }
        for (int i = 0; i < n; i++) {
           c[i] = sc.nextInt();
        }
        Arrays.sort(a);
        Arrays.sort(b);
        Arrays.sort(c);
        
        int i = 0;        
        int j = 0;
        int k = 0;
        
        long ans = 0;
        long[] kek = new long[n];
        
        while (j < n) {
            while (k < n && c[k] <= b[j]) {
                k++;
            }
            kek[j] = n - k;
            j++;
        }

        for (int l = n - 2; l >= 0 ; l--) {
            kek[l] += kek[l + 1];
        }

        j = 0;
        
        while (i < n) {
            while (j < n && b[j] <= a[i]) {
                j++;
            }
            if (j < n)
            ans += kek[j];
            i++;
        }
        
        System.out.println(ans);       
                            
   }       
   

   
}

Measured memory_bytes: 93524
package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
	"strconv"
	"strings"
)

var sc = bufio.NewScanner(os.Stdin)

func nextLine() string {
	sc.Scan()
	return sc.Text()
}

func main() {
	line := nextLine()
	nm := strings.Split(line, " ")
	N, _ := strconv.Atoi(nm[0])
	M, _ := strconv.Atoi(nm[1])

	ls := make([]int, M)
	rs := make([]int, M)

	for i := 0; i < M; i++ {
		line = nextLine()
		lr := strings.Split(line, " ")
		l, _ := strconv.Atoi(lr[0])
		r, _ := strconv.Atoi(lr[1])
		ls[i] = l
		rs[i] = r

	}

	var min_r, max_l int
	min_r = int(math.Pow(10, 9))
	max_l = 0

	for i := 0; i < M; i++ {
		if max_l < ls[i] {
			max_l = ls[i]
		}
		if min_r > rs[i] {
			min_r = rs[i]
		}
	}

	if max_l > N {
		max_l = N
	}

	if min_r-max_l+1 < 0 {
		fmt.Print(0)
	} else {
		fmt.Print(min_r - max_l + 1)
	}
}


Measured memory_bytes: 5504
#include <cstdint>
#include <iostream>
#include <vector>

using namespace std;

constexpr int64_t kMod = 1e9 + 7;
constexpr int64_t kMax = 2e5 + 10;

vector<int64_t> AllFactorials(int64_t limit)
{
    vector<int64_t> fact(limit + 1, 1);
    for (int64_t i = 2; i <= limit; i += 1) {
        fact[i] = (fact[i - 1] * i) % kMod;
    }
    return fact;
}

pair<int64_t, int64_t> Euclid(int64_t a, int64_t b)
{
    if (b == 0) {
        return {1, 0};
    }

    auto p = Euclid(b, a % b);
    return {p.second, p.first - a / b * p.second};
}

int64_t Inverse(int64_t num)
{
    auto inv = Euclid(num, kMod).first;
    while (inv < 0) {
        inv += kMod;
    }
    return inv;
}

vector<int64_t> AllInverseFactorials(int64_t limit)
{
    vector<int64_t> inv_fact(limit + 1, 1);
    for (int64_t i = 2; i <= limit; i += 1) {
        inv_fact[i] = (inv_fact[i - 1] * Inverse(i)) % kMod;
    }
    return inv_fact;
}

int64_t Comb(int64_t n, int64_t k)
{
    static auto fact = AllFactorials(kMax);
    static auto inv_fact = AllInverseFactorials(kMax);

    auto res = (inv_fact[k] * inv_fact[n - k]) % kMod;
    res = (res * fact[n]) % kMod;

    return res;
}

int64_t Ways(int64_t start_x, int64_t start_y, int64_t dest_x, int64_t dest_y)
{
    auto rows = dest_x - start_x + 1;
    auto cols = dest_y - start_y + 1;
    auto len = rows + cols - 2;

    return Comb(len, rows - 1);
}

int main()
{
    int64_t rows, cols;
    cin >> rows >> cols;

    int64_t x, y;
    cin >> x >> y;

    int64_t total = 0;
    for (int64_t i = y + 1; i <= cols; i += 1) {
        int64_t ways = Ways(1, 1, rows - x, i);
        ways = (ways * Ways(rows - x + 1, i, rows, cols)) % kMod;
        total = (total + ways) % kMod;
    }

    cout << total << "\n";
    return 0;
}


Measured memory_bytes: 3328
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx")
#pragma GCC optimize("unroll-loops")
//#pragma warning(disable : 4996)

#ifdef _MSC_VER
#include <intrin.h>
#define __builtin_popcount __popcnt
#define __builtin_popcountll __popcnt64

#endif

#include <limits.h>
#include <math.h>
#include <time.h>

#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <complex>
#include <cstdio>
#include <cstring>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>

using namespace std;

#define REP(i, n) for (int i = 0; i < (n); ++i)
#define REPR(i, n) for (int i = n - 1; i >= 0; --i)
#define FOR(i, m, n) for (int i = m; i < n; ++i)
#define FORR(i, m, n) for (int i = m - 1; i >= n; --i)
#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define REVERSE(v, n) reverse(v, v + n);
#define VREVERSE(v) reverse(v.begin(), v.end())
#define ll long long
#define print(x) cout << (x) << '\n'
#define pe(x) cout << (x) << " "
#define DEBUG(x) cout << #x << ": " << x << endl
#define lb(v, n) lower_bound(v.begin(), v.end(), (n))
#define ub(v, n) upper_bound(v.begin(), v.end(), (n))
#define int long long
//#define double long double
#define all(x) (x).begin(), (x).end()
#define print_space(v) REP(i, v.size()) cout << v[i] << " \n"[i==(int)v.size()-1]
template <typename T1, typename T2> inline void chmin(T1& a, T2 b) { if (a > b) a = b; }
template <typename T1, typename T2> inline void chmax(T1& a, T2 b) { if (a < b) a = b; }
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;
std::random_device rd;
std::mt19937 mt(rd());
constexpr ll MOD = 1e9 + 7;
constexpr int MAX = 500050;
const double pi = acos(-1);
constexpr double EPS = 1e-8;
constexpr ll LINF = 1e18 + 1;
constexpr int INF = 1e9 + 1;
//int dx[4] = { 0,0,-1,1 }, dy[4] = { 1,-1,0,0 };


void solve() {
	int N; cin >> N;
	vector<int>A(N);
	REP(i, N)cin >> A[i];
	VSORT(A);
	int ans = 0;
	REP(i, N) {
		FOR(j, i + 1, N) {
			FOR(k, j + 1, N) {
				if (A[i]!=A[j]&&A[j]!=A[k]&&A[k] < A[i] + A[j])ans++;
			}
		}
	}
	print(ans);
}



signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	//int q;
	//cin >> q;
	//while (q--)
	solve();

}


Measured memory_bytes: 3668
import java.util.*;

public class Main{
	private static int[] dp = new int[1000010];
	private static int[] dp2 = new int[1000010];

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

		//ツスツタツッツクツオツーツバツーツフツδ債ーツ妥開ツ用
		for(int i=1;i<=1000000;i+=100){
			solve(i);
			solve2(i);
		}

		while(true){
			int n = sc.nextInt();
			if(n == 0) break;

			System.out.println(dp[n]+" "+dp2[n]);
		}
	}

	private static int solve(int n){
		if(n == 0) return 0;
		if(dp[n] != 0) return dp[n];

		int tmp = 0, res = Integer.MAX_VALUE;
		for(int i=1;(tmp=i*(i+1)*(i+2)/6)<=n;i++){
			res = Math.min(res,solve(n-tmp));
		}

		return dp[n]=(res+1);
	}

	private static int solve2(int n){
		if(n == 0) return 0;
		if(dp2[n] != 0) return dp2[n];

		int tmp = 0, res = Integer.MAX_VALUE;
		for(int i=1;(tmp=i*(i+1)*(i+2)/6)<=n;i++){
			if(tmp % 2 == 1)
				res = Math.min(res,solve2(n-tmp));
		}

		return dp2[n]=(res+1);
	}
}

Measured memory_bytes: 20000
import sys

def partition(A, p, r):
    x = A[r]
    i = p-1
    for j in range(p,r):
        if A[j][1] <= x[1]:
            i = i+1
            A[i], A[j] = A[j], A[i]
    A[i+1], A[r] = A[r], A[i+1]
    return A, i+1

def quickSort(A, p, r):
    if p < r:
        A, q = partition(A, p, r)
        A = quickSort(A, p, q-1)
        A = quickSort(A, q+1, r)
    return A

N = int(input())
A = []
D = {}
for i in range(N):
    v, d = sys.stdin.readline().split()
    A.append((v, int(d)))
    D.setdefault(int(d), []).append(v)
    
out_A = quickSort(A,0,N-1)

D = {k: iter(v).__next__ for k, v in D.items()}

ok = 1
for v, d in A:
    if D[d]() != v:
        ok = 0
                
if ok:
    print("Stable")
else:
    print("Not stable")

for i in range(N):
    print(*out_A[i],sep=" ")


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

int main() {
  int R;
  cin >> R;
  if ( R >=2800 ) {
    cout << "AGC" << endl;
  } else if ( R >= 1200 ) {
    cout << "ARC" << endl;
  } else {
    cout << "ABC" << endl;
  }

  return 0;
}


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

int main() {
  int order,i;
  int syako[1000];
  i=0;
  while(cin >> order) {
    if(order != 0) {
      syako[i] = order;
      i++;
    }
    else {
      cout << syako[i-1] << endl;
      i--;
    }
  }
}

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

int main(){
    int h1, h2, m1, m2, k;

    cin >> h1 >> m1 >> h2 >> m2 >> k;

    if((60*h2 + m2) - (60*h1 + m1) - k <= 0){
        cout << 0 << endl;
    }
    else{
        cout <<  (60*h2 + m2) - (60*h1 + m1) - k<< endl;
    }
}

Measured memory_bytes: 3636
//A.cpp
#include <iostream>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <vector>
#include <queue>
#include <stack>
#include <math.h>
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;

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

  int num;
  int ans;
  vector<vector<int>> v(n,vector<int>(n,0));
  rep(i,n){
    cin >> a;
    rep(j,a){
      cin >> num >> ans;
      if(ans == 0) v.at(i).at(num-1) = -1;
      else v.at(i).at(num-1) = 1;
    }
  }

  bool rA[n] = {false};
  int cnt = 0;
  int ansmax = 0;
  bool flag = true;

  for(int i = 0; i < (1<<n); i++){
    for(int j = 0; j < n; j++){
      if(i & (1<<j)){
        rA[j] = true;
        cnt++;
      }
    }
    for(int j = 0; j < n; j++){
      if(!flag) break;
      if(!rA[j]) continue;
      for(int k =0; k < n; k++){
        if(v.at(j).at(k) == 1 && !rA[k]){
          flag  = false;
          break;
        }else if(v.at(j).at(k) == -1 && rA[k]){
          flag  = false;
          break;
        }
      }
    }
      if(flag){
        ansmax = max(ansmax,cnt);
      }
      cnt = 0;
      rep(i,n) rA[i] = false;
      flag = true;
  }


  // for(int i = 0; i < (1<<n); i++){
  //   for(int j = 0; j < n; j++){
  //     if(i & (1<<j)){
  //       rA[j] = true;
  //       for(int k = 0; k < n; k++){
  //         if(v.at(j).at(k) == 1 && v.at(k).at(j) == -1){
  //           flag = false;
  //           break;
  //         }
  //       }
  //       cnt++;
  //     }
  //   }
    // for(int j = 0; j < n; j++){
    //   if(!flag) break;
    //   if(rA[j]){
    //     for(int k = 0; k < n; k++){
    //       if(v.at(j).at(k) == 1 && !rA[k]){
    //         rA[k] = true;
    //       }
    //       if(v.at(j).at(k) == -1){
    //         if(rA[k]){
    //           flag = false;
    //           break;
    //         }
    //       }
    //     }
    //   }
    // }
    // for(int j = 0; j < n; j++){
    //   int memo = 0;
    //   if(!flag) break;
    //   for(int k = 0; k < n; k++){
    //     if(!rA[k]) continue;
    //     if(v.at(k).at(j) == 0) continue;
    //     if(memo == 0){
    //       memo = v.at(k).at(j);
    //     }else{
    //       if(v.at(k).at(j) != memo){
    //         flag = false;
    //         break;
    //       }
    //     }
    //
    //   }
    // }
    //
    // for(int j = 0; j < n; j++){
    //   if(!flag) break;
    //   if(!rA[j]) continue;
    //   for(int k = 0; k < n; k++){
    //     if(v.at(j).at(k) == -1 && rA[k]){
    //       flag = false;
    //       break;
    //     }
    //   }
    // }
  //
  //   if(flag){
  //     ansmax = max(ansmax,cnt);
  //   }
  //   cnt = 0;
  //   rep(i,n) rA[i] = false;
  //   flag = true;
  // }
  printf("%d\n", ansmax);
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll INF = 1LL << 60;

int main() {
    int n;
    cin >> n;
    vector<tuple<string, int, int>> a(n);
    for (int i = 0; i < n; i++) {
        cin >> get<0>(a[i]) >> get<1>(a[i]);
        get<1>(a[i]) = -get<1>(a[i]);
        get<2>(a[i]) = i + 1;
    }
    sort(a.begin(), a.end());
    for (int i = 0; i < n; i++) {
        cout << get<2>(a[i]) << endl;
    }
    return 0;
}

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

using namespace std;
using ll = long long;

const int INF = 1e9;
const double PI = acos(-1.0);
const ll MOD = 1e9 + 7;

#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define debug(x) cout << #x << ": " << x << endl;
#define popcnt __builtin_popcount


int main() {
    int n, res=0;
    string a, b, c;
    cin >> n >> a >> b >> c;
    for(int i = 0; i < n; i++)
    {
        if(a[i]==b[i]&&b[i]==c[i]){
            continue;
        }else if((a[i]==b[i]&&b[i]!=c[i]&&a[i]!=c[i])||(a[i]==c[i]&&b[i]!=c[i]&&b[i]!=a[i])||(c[i]==b[i]&&b[i]!=a[i]&&a[i]!=c[i])){
            res++;
        }else{
            res+=2;
        }
    }
    cout << res << endl;

    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstdint>
#include <cstdio>
#include <cstring>
#include <deque>
#include <fstream>
#include <functional>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <vector>
using namespace std;
using ll = long long;
#define fst first
#define snd second

/* clang-format off */
template <class T, size_t D> struct _vec { using type = vector<typename _vec<T, D - 1>::type>; };
template <class T> struct _vec<T, 0> { using type = T; };
template <class T, size_t D> using vec = typename _vec<T, D>::type;
template <class T> vector<T> make_v(size_t size, const T& init) { return vector<T>(size, init); }
template <class... Ts> auto make_v(size_t size, Ts... rest) { return vector<decltype(make_v(rest...))>(size, make_v(rest...)); }
template <class T> inline void chmin(T &a, const T& b) { if (b < a) a = b; }
template <class T> inline void chmax(T &a, const T& b) { if (b > a) a = b; }
/* clang-format on */

int main() {
#ifdef DEBUG
  ifstream ifs("in.txt");
  cin.rdbuf(ifs.rdbuf());
#endif
  int H, W, K;
  while (cin >> H >> W >> K) {
    vector<string> grid(H);
    for (auto& line : grid) cin >> line;
    vec<int, 2> res = make_v(H, W, 0);
    int color = 1;
    for (int y = 0; y < H; y++) {
      for (int x = 0; x < W; x++) {
        if (grid[y][x] == '#') res[y][x] = color++;
      }
    }
    vector<int> d{1, -1};
    for (int dx : d) {
      for (int y = 0; y < H; y++) {
        int v = 0;
        for (int x = dx < 0 ? W - 1 : 0; x >= 0 && x < W; x += dx) {
          if (res[y][x]) v = res[y][x];
          res[y][x] = v;
        }
      }
    }
    for (int dy : d) {
      for (int x = 0; x < W; x++) {
        int v = 0;
        for (int y = dy < 0 ? H - 1 : 0; y >= 0 && y < H; y += dy) {
          if (res[y][x]) v = res[y][x];
          res[y][x] = v;
        }
      }
    }
    for (int y = 0; y < H; y++) {
      for (int x = 0; x < W; x++) {
        cout << res[y][x] << " ";
      }
      cout << endl;
    }
  }
  return 0;
}


Measured memory_bytes: 1280
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <cmath>
using namespace std;

#define rep(i,n) for(int i=0; i<n; i++)

double sun_h(double x, int r) {
	return -1.*r + sqrt(1.*r*r-x*x);
}

int main() {
	int r, n;
	while(cin >> r >> n, r||n) {
		int height[40] = {};
		rep(i, n) {
			int l, r, h;
			cin >> l >> r >> h;
			for(int i=l+20; i<r+20; i++) {
				height[i] = max(height[i], h);
			}
		}
		double mini = 100;
		for(int x=-r+20; x<20; x++) {
			mini = min(mini, height[x]-sun_h(x-19,r));
		}
		for(int x=20; x<r+20; x++) {
			mini = min(mini, height[x]-sun_h(x-20,r));
		}
		cout << mini << endl;
	}
	return 0;
}

Measured memory_bytes: 1236
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <queue>
#include <stack>
#include <map>
#include <algorithm>
#include <math.h>
#include <cassert>
#define rep(i,n) for(int i = 0; i < n; ++i )
using namespace std;
using ll = long long;
using P = pair<int,int>;

int main() {
  ll a; string b;
  cin >> a >> b;
  ll b1 = b[0]-'0', b2 = b[2]-'0', b3 = b[3]-'0';
  ll ans = a*b1*100;
  ans += a*b2*10;
  ans += a*b3;
  ans /= 100;
  printf("%lld\n",ans);
}


Measured memory_bytes: 3692
#include<iostream>
using namespace std;
int main() {
	int Ans=0,a=0;
	string s;
	cin >> s;
	for (int i = 0; i < 3; i++) {
		if (s[i] == 'R') {
			a++;
			if (Ans < a) {
				Ans = a;
			}

		}
		else {
			a = 0;
		}
	}
	cout << Ans;
	return 0;
}

Measured memory_bytes: 3568
#include <bits/stdc++.h>
#define ll long long
using namespace std;
const int N = 2e5 + 3;

void solve()
{
    int n, ans = 0; cin >> n;
    vector<int> v(n);
    for(int i = 0; i < n; i++)
        cin >> v[i];

    for(int i = 0; i < n; i++)
    {
        for(int j = i + 1; j < n; j++)
        {
            for(int k = j + 1; k < n ; k++)
            {
                if((v[i] + v[j] > v[k]) && (v[j] + v[k] > v[i]) && (v[i] + v[k] > v[j]))
                    if((v[i] != v[j]) && (v[j] != v[k]) && (v[i] != v[k]))
                        ans++;
            }
        }
    }

    cout << ans << '\n';
}

int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0);
    // freopen("input.txt", "r", stdin);

    // int t; cin >> t;
    // while(t--)
        solve();

    return 0;
}

Measured memory_bytes: 3656
#include <iostream>
#include <iomanip>
#include <cmath>
#include <vector>
#include <queue>
#include <limits>
#include <algorithm>
#include <string>
#include <cstring>
#include <map>

#include <inttypes.h>
using namespace std;

struct edge {
	int32_t from;
	int32_t to;
	int64_t cost;
};
static vector<struct edge> edges;
static vector<int64_t> d;
static vector<bool> negative;

// bellman ford
static void bellmanFord(int32_t start, int32_t nodeCnt, int32_t edgeCnt)
{
	for (int32_t i = 0; i < nodeCnt; i++)
		d[i] = numeric_limits<int64_t>::max();

	d[start] = 0;
	for (int32_t i = 0; i < nodeCnt - 1; i++) {
		for (int32_t j = 0; j < edgeCnt; j++) {
			struct edge e = edges[j];
			if (d[e.from] == numeric_limits<int64_t>::max())
				continue;

			if (d[e.to] > d[e.from] + e.cost)
				d[e.to] = d[e.from] + e.cost;
		}
	}

	// 閉路を探す
	vector<int64_t> d_temp(nodeCnt);
	for (int32_t i = 0; i < nodeCnt; i++)
		d_temp[i] = d[i];
	negative.resize(nodeCnt, false);
	for (int32_t i = 0; i < nodeCnt; i++) {
		for (int32_t j = 0; j < edgeCnt; j++) {
			struct edge e = edges[j];
			if (d_temp[e.from] == numeric_limits<int64_t>::max())
				continue;

			if (d_temp[e.to] > d_temp[e.from] + e.cost) {
				d_temp[e.to] = d_temp[e.from] + e.cost;
				negative[e.to] = true;
			}
		}
	}
}

int main()
{
	int32_t nodeCnt, edgeCnt;
	scanf("%d%d", &nodeCnt, &edgeCnt);

	d.resize(nodeCnt);
	edges.resize(edgeCnt);
	for (int32_t i = 0; i < edgeCnt; i++) {
		int32_t a, b;
		int64_t c;
		scanf("%d%d%" PRId64, &a, &b, &c);
		a--;
		b--;
		c = -c;

		edges[i].from = a;
		edges[i].to = b;
		edges[i].cost = c;
	}

	bellmanFord(0, nodeCnt, edgeCnt);
	if (negative[nodeCnt - 1])
		printf("inf\n");
	else
		printf("%" PRId64 "\n", -d[nodeCnt - 1]);

	return 0;
}

Measured memory_bytes: 256
import sys
import math
from decimal import Decimal, ROUND_HALF_UP, ROUND_HALF_EVEN
from collections import deque
from bisect import bisect_left
from itertools import product
def I(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LI2(N): return [list(map(int, sys.stdin.readline().split())) for i in range(N)]
#文字列を一文字ずつ数字に変換、'5678'を[5,6,7,8]とできる
def LSI(): return list(map(int, list(sys.stdin.readline().rstrip())))
def LSI2(N): return [list(map(int, list(sys.stdin.readline().rstrip()))) for i in range(N)]
#文字列として取得
def ST(): return sys.stdin.readline().rstrip()
def LST(): return sys.stdin.readline().rstrip().split()
def LST2(N): return [sys.stdin.readline().rstrip().split() for i in range(N)]
def FILL(i,h): return [i for j in range(h)]
def FILL2(i,h,w): return [FILL(i,w) for j in range(h)]
def FILL3(i,h,w,d): return [FILL2(i,w,d) for j in range(h)]
def FILL4(i,h,w,d,d2): return [FILL3(i,w,d,d2) for j in range(h)]
def sisha(num,digit): return Decimal(str(num)).quantize(Decimal(digit),rounding=ROUND_HALF_UP)
#'0.01'や'1E1'などで指定、整数に戻すならintをかます
MOD = 1000000007
INF = float("inf")
sys.setrecursionlimit(10**6+10)

N, W = MI()
inp = LI2(N)
w = [inp[i][0] for i in range(N)]
v = [inp[i][1] for i in range(N)]
dp = FILL2(0,N+1,W+1)
for i in range(N):
    for j in range(W+1):
        if j+w[i]<=W:
            dp[i+1][j+w[i]] = max(dp[i+1][j+w[i]],dp[i][j]+v[i])
        dp[i+1][j] = max(dp[i+1][j],dp[i][j])
print(max(dp[N]))


Measured memory_bytes: 178420
#include <algorithm>
#include <bitset>
#include <complex>
#include <cstdio>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif

using namespace std;

#define rep(i, n) for(int i = 0; i < (int)n; ++i)
#define FOR(i, a, b) for(int i = a; i < (int)b; ++i)

typedef long long ll;

const int Inf = 1e9;
const double EPS = 1e-9;

int gcd(int a, int b) {
    if (b == 0) {
        return a;
    } else {
        return gcd(b, a % b);
    }
}

int lcm(int a, int b) {
    return a * b / gcd(a, b);
}

int bitCount(long bits) {
    bits = (bits & 0x55555555) + (bits >> 1 & 0x55555555);
    bits = (bits & 0x33333333) + (bits >> 2 & 0x33333333);
    bits = (bits & 0x0f0f0f0f) + (bits >> 4 & 0x0f0f0f0f);
    bits = (bits & 0x00ff00ff) + (bits >> 8 & 0x00ff00ff);
    return (bits & 0x0000ffff) + (bits >>16 & 0x0000ffff);
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;  cin >> n;
    int a[2][n];
    int ans = -1;

    rep(i, 2) {
      rep(j, n) {
        cin >> a[i][j];
      }
    }
    rep(i, n) {
      int c = 0;
      rep(j, i + 1) {
        c += a[0][j];
      }
      FOR(j, i, n) {
        c += a[1][j];
      }
      ans = max(ans, c);
    }
    cout << ans << '\n';

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1LL<<62
#define inf 1000000007

ll n,m,k;
vector<ll>f[100010],b[100010];
ll gr[100010];
void dep(ll now,ll g){
	for(ll i=0;i<f[now].size();i++){
		ll nex=f[now][i];
		if(gr[nex]!=0){
			continue;
		}
		gr[nex]=g;
		dep(nex,g);
	}
}
int main() {
	cin>>n>>m>>k;
	for(ll i=0;i<m;i++){
		ll x,y;
		cin>>x>>y;
		x--;y--;
		f[x].push_back(y);
		f[y].push_back(x);
	}
	for(ll i=0;i<k;i++){
		ll x,y;
		cin>>x>>y;
		x--;y--;
		b[x].push_back(y);
		b[y].push_back(x);
	}
	ll now=1;
	for(ll i=0;i<n;i++){
		if(gr[i]!=0){
			continue;
		}
		gr[i]=now;
		dep(i,now);
		now++;
	}
	ll cnt[100010]={};
	for(ll i=0;i<n;i++){
		ll no=gr[i];
		cnt[no]++;
	}
	for(ll i=0;i<n;i++){
		ll cnt2=cnt[gr[i]];
		ll mi=f[i].size()+1;
		for(ll j=0;j<b[i].size();j++){
			if(gr[i]==gr[b[i][j]]){
				mi++;
			}
		}
		cout << cnt2-mi<<" ";
	}
	// your code goes here
	return 0;
}

Measured memory_bytes: 18012
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; 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 sz(x) (int)(x).size()
#define uni(x) x.erase(unique(rng(x)),x.end())
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
typedef set<int> S;
typedef queue<int> Q;
typedef queue<P> QP;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
const int MOD = 1000000007;

class Combi {
private:
  v(ll) fac, inv, finv;
  void init(int N) {
    fac[0] = fac[1] = 1; inv[1] = 1; finv[0] = finv[1] = 1;
    for (int i = 2; i < N; i++) {
      fac[i] = fac[i - 1] * i % MOD;
      inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
      finv[i] = finv[i - 1] * inv[i] % MOD;
    }
  }
public:
  Combi(int N) : fac(N + 1), inv(N + 1), finv(N + 1) { init(N + 1); }
  ll Cmod(int n, int k) {
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
  }
  ll Pmod(int n, int k) {
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * finv[n - k] % MOD;
  }
};
  
int main() {
  int X,Y;
  cin >> X >> Y;
  if(2*X-Y < 0) {
    cout << 0 << endl;
    return 0;
  }
  if((2*X-Y) % 3 != 0) {
    cout << 0 << endl;
    return 0;
  }
  int cnty = (2*X-Y)/3;
  int cntx = X - 2 * cnty;
  if(cntx < 0) {
    cout << 0 << endl;
    return 0;
  }
  Combi C = Combi(cntx+cnty);
  cout << C.Cmod(cntx+cnty,cntx) << endl;
  return 0;
}

Measured memory_bytes: 15872
def divisor(n):
    ass = []
    for i in range(1,int(n**0.5)+1):
        if n%i == 0:
            ass.append(i)
            if i**2 == n:
                continue
            ass.append(n//i)
    ass.sort()
    return ass #sortされていない

N,M = map(int,input().split())

A = divisor(M)

b = M//N

ans = A[0]

for a in A:
    if a <= b:
        ans = a
    else:
        break
print(ans)


Measured memory_bytes: 3064