akhauriyash/Code-Regression huggingface dataset:
import numpy as np
 
K = int(input())
ans = 0

gcd2 = np.zeros((K+1, K+1), dtype=int)

for i in range(1, K):
    for j in range(i+1,K+1):
        gcd2[i,j] = gcd2[j,i] = np.gcd(i,j)
for i in range(1, K+1):
    gcd2[i,i] = i

for i in range(1,K+1):
    ans += i

for i in range(1, K):
    for j in range(i+1, K+1):
        ans += 3 * gcd2[i,j]
for i in range(1, K+1):
    for j in range(1, i):
        ans += 3 * gcd2[i,j]
        
for i in range(1, K-1):
    for j in range(i+1, K):
        for k in range(j+1, K+1):
            ans += 6 * gcd2[i,gcd2[j,k]]
            
print(ans)

Measured memory_bytes: 27184
(defun get-conditions (num)
  ;; 条件を取得するLoop
  (loop as i 
        below num 
        collect (list (read) (read))))

(defun get-list (s e)
  (loop as i
        from s
        to e
        collect (write-to-string i)))

(defun get-candidates (n)
  (case n
    (1 (get-list 0 9))
    (2 (get-list 10 99))
    (3 (get-list 100 999))))

(defun is-pass (n r v) ; str int int
  (string= (subseq n (- r 1) r) (write-to-string v)))

(defun candidate-filter (candidates r v)
  (loop as candidate 
        in candidates
        when (is-pass candidate r v)
        collect candidate))

(defun apply-conditions (candidates conditions)
  (if (null conditions)
      (if (null candidates)
          -1
          (car candidates))
      (apply-conditions (candidate-filter candidates 
                                          (car (car conditions)) 
                                          (cadr (car conditions)))
                        (cdr conditions))))

(let ((n (read))
      (conditions (get-conditions (read)))
      )
  (princ (apply-conditions (get-candidates n) conditions)))

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

x1 = max([int(i) for i in input().split()]) + 1
y1 = min([int(i) for i in input().split()])

if x1 <= y1 and x1 <= y and y1 > x:
    print('No War')
else:
    print('War')

Measured memory_bytes: 3060
import java.util.Scanner;


public class Main {

    public static void main(String[] args) {

    	Main main=new Main();

    	main.run();

    }

    void run() {

    	Scanner sc=new Scanner(System.in);
    	
    	int N=sc.nextInt();
    	
    	int a=N/100;
    	int b=N%10;
    	
    	if(a==b) {
    		System.out.println("Yes");
    	}else {
    		System.out.println("No");
    	}
    }
}


Measured memory_bytes: 21844
#include <iostream>
#include <string>

using namespace std;

int main(void) {
  string str;
  int n;

  while (cin >> str) {
    if (str == "-")
      break;
    cin >> n;
    for (int i = 0; i < n; i++){
      int h;
      cin >> h;
      string first = str.substr(0, h);
      //cout << "first: " << first << endl;
      string second = str.substr(h, str.size() - h);
      //cout << "second: " << second << endl;
      str = second + first;
      //cout << "str:" << str << endl;
    }
    cout << str << endl;
  }
}


Measured memory_bytes: 3172
#include<bits/stdc++.h>
using namespace std;
#define se second
#define fi first
#define ll long long
#define ld long double
#define pll pair<ll ,ll >
#define plll pair<ll,pll>
#define ppll pair<pll, pll>
#define pii pair<int, int> 
#define pb push_back
#define mod 1000000007
#define N 1000007
ll power(ll a,ll b){
    ll res=1ll;
    while(b>0){
        if(b%2!=0) res=(res*a)%mod;
        a=(a*a)%mod;
        b/=2;
    }
    return res%mod;
}
ll ncr(ll n,ll k){
    if(k>n-k) k=n-k;
    ll pro=1;
    for(ll i=0;i<k;i++){
        pro=(pro*(n-i))%mod;
        pro/=(i+1);
    }
    return (pro)%mod;
}

void swap(ll *a,ll *b) {
    ll temp=*a;
    *a=*b;
    *b=temp;
}
vector<ll> prime;
void seive(){
    vector<bool > isprime(1000001,true);
    for(int i=2;i*i<=1000000;i++){
        if(isprime[i]){
            for(int j=i*i;j<=1000000;j+=i){
                isprime[j]=false;
            }
        }
    }
    for(int i=2;i<=1000000;i++){
        if(isprime[i]) prime.push_back(i);
    }
}
vector<ll> parent;
ll find(ll p) {
    if(parent[p]==p) return parent[p];
    return parent[p]=find(parent[p]); 
}
void unun(ll a,ll b) {
    ll r1=find(a);
    ll r2=find(b);
    if(r1!=r2) parent[r2]=r1;
}
void solve() {   
    ll a,b,n;
    cin>>a>>b>>n;
    ll minn=min(b-1,n);
    ll ans=(a*minn)/b;
    cout<<ans;
    return ;
}   


int main(void){
    ios_base::sync_with_stdio(false); 
    cin.tie(NULL);
    cout.tie(NULL);
    int t;
    t=1;
    // cin>>t;
    while(t--) {
        solve();
        // cout<<endl;
    }
    return 0; 

}


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

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

  for (int i = 0; i <s.size(); i++) {
    cout << s[i];
    if (i == 3) cout << " ";
  }
  cout << "\n";
  return 0;
}

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

typedef long long ll;
typedef unsigned long long ull;

#define PrintLn(X) cout << X << endl
#define Loop(n) for(int loop_ = n; loop_; --loop_)
#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)

int main(void)
{
	ll N, A, B;
	cin >> N >> A >> B;
	ll ans = 0;
	ll x1;
	cin >> x1;
	Rep(i, N - 1){
		ll x2;
		cin >> x2;
		ll x = x2 - x1;
		if(x * A < B){
			ans += x * A;
		}else{
			ans += B;
		}
		x1 = x2;
	}
	PrintLn(ans);
	return 0;
}


Measured memory_bytes: 256
fn main() {
    proconio::input! {
        sa: proconio::marker::Chars,
        sb: proconio::marker::Chars,
        sc: proconio::marker::Chars,
    }
    let mut cur = 'a';
    let mut saiter = sa.iter();
    let mut sbiter = sb.iter();
    let mut sciter = sc.iter();
    loop {
        match cur {
            'a' => match saiter.next() {
                Some(next) => {
                    cur = *next;
                }
                None => {
                    println!("A");
                    return;
                }
            },
            'b' => match sbiter.next() {
                Some(next) => {
                    cur = *next;
                }
                None => {
                    println!("B");
                    return;
                }
            },
            'c' => match sciter.next() {
                Some(next) => {
                    cur = *next;
                }
                None => {
                    println!("C");
                    return;
                }
            },
            _ => unreachable!(),
        }
    }
}


Measured memory_bytes: 2196
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <bitset>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <numeric>
#include <iostream>
#include <iomanip>
#include <string>
#include <chrono>
#include <random>
#include <cmath>
#include <cassert>
#include <climits>
#include <cstring>
#include <cstdlib>
#include <functional>
#include <sstream>

using namespace std;


int main(int argc, char** argv) {
    ios::sync_with_stdio(false);
    cin.tie(0);

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

    for (int i = n - 1; i >= 0; --i) {
        int x = i + 1;
        for (int j = x + x; j <= n; j += x) {
            A[i] ^= A[j - 1];
        }
    }

    int cnt = 0;
    for (int i = 0; i < n; ++i) {
        if (A[i]) {
            ++cnt;
        }
    }    
    cout << cnt << "\n";
    for (int i = 0; i < n; ++i) {
        if (A[i]) {
            cout << (i + 1) << (--cnt == 0 ? '\n' : ' ');
        }
    }

    return 0;
}

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

using namespace std;

long MOD = 1000000007;

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

    if(s.length() < 8){
        cout<<"YES"<<endl;
        return 0;
    }
    int c = 0;
    for(int i=0; i<s.length(); ++i){
        if(s[i] == 'o'){
            c++;
        }
    }
    if(c + 15 - s.length() >= 8){
        cout<<"YES"<<endl;
        return 0;
    }else{
        cout<<"NO"<<endl;
        return 0;
    }

    return 0;
}

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

static const int N = 100;

int main() {
  int n, p[N+1], m[N+1][N+1];
  cin >> n;
  for (int i = 1; i <= n; i ++) {
    cin >> p[i-1] >> p[i];
  }

  for (int i = 1; i <= n; i ++) m[i][i] = 0;
  for (int l = 2; l <= n; l ++) {
    for (int i = 1; i <= n-l+1; i ++) {
      int j = i + l - 1;
      m[i][j] = (1 << 21);
      for (int k = i; k <= j; k ++) {
        m[i][j] = min(m[i][j], m[i][k] + m[k+1][j] + p[i-1]*p[k]*p[j]);
      }
    }
  }

  cout << m[1][n] << endl;
}



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

#define debug(x) cout << #x << " = " << x << endl
#define fori(i, ini, lim) for(int i = int(ini); i < int(lim); i++)
#define ford(i, ini, lim) for(int i = int(ini); i >= int(lim); i--)

using namespace std;

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

const int MAX = 1e5 + 5;
ll arr[MAX];
ll n, a, b;

int main() {
	scanf("%lld %lld %lld", &n, &a, &b);
	fori(i, 1, n + 1) {
		scanf("%lld", arr + i);
	}

	ll ans = 0;
	fori(i, 2, n + 1) {
		ans += min((arr[i] - arr[i - 1]) * a, b);
	}

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

	return 0;
}


Measured memory_bytes: 1024
#include<iostream>
#include<cstdio>
#include<cstring>
#include <cstdlib>  
#include <cmath>   
#include<cctype>
#include<string>
#include<set>
#include <map>
#include<algorithm>
#include <functional>
#include<vector>
#include<climits>
#include<stack>
#include<queue>
#include <deque>
#include <climits>
#include <typeinfo>
#include <utility> 
#define all(x) (x).begin(),(x).end()
#define rep(i,m,n) for(int i = m;i < n;++i)
#define pb push_back
#define fore(i,a) for(auto &i:a)
#define rrep(i,m,n) for(int i = m;i >= n;--i)
#define INF INT_MAX/2
using namespace std;
using ll = long long;
using R = double;
const ll inf = 1LL << 50;
const ll MOD = 1e9 + 7;
struct edge { ll from; ll to; ll cost; };


void chmin(int &a, int b) {
	if (a == -1)a = b;
	else if (a > b)a = b;
}


int main(){
	int n, ma, mb;
	cin >> n >> ma >> mb;

	//i個目まで見てaがjg,bがkgの時の最小予算
	int dp[45][500][500];
	int a[45], b[45], c[45];
	rep(i, 0, n) {
		cin >> a[i] >> b[i] >> c[i];
	}

	rep(i, 0, 45)rep(j, 0, 500)rep(k, 0, 500)dp[i][j][k] = -1;
	dp[0][0][0] = 0;

	rep(i, 0, n)rep(j, 0, 450)rep(k, 0, 450) {
		if (dp[i][j][k] == -1)continue;
		chmin(dp[i+1][j+a[i]][k+b[i]],dp[i][j][k]+c[i]);
		chmin(dp[i + 1][j][k], dp[i][j][k]);
	}

	int i = 1;
  	int ans = 101010;
	while (ma*i <= 450 && mb*i <= 450) {
		if (dp[n][ma*i][mb*i] != -1) {
			ans = min(ans,dp[n][ma*i][mb*i]);
		}
      i++;
	}
	if (ans == 101010)cout << -1 << endl;
  	else cout << ans << endl;

	return 0;
}

Measured memory_bytes: 44288
program Tax_Increase
    implicit none
    real(8):: a,b
    integer(8):: amax, bmax, amin, bmin

    read*, a,b


    amin = ceiling((a)/8d-2)
    amax = ceiling((a+1)/8d-2)-1
    bmin = ceiling((b)/10d-2)
    bmax = ceiling((b+1)/1d-1)-1

    if (amax < bmin .or. bmax < amin) then
        print*, -1
    else
        print*, max(amin,bmin)
    end if

end program Tax_Increase

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

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

constexpr ll LLINF {1001002003004005006};//ll = 9*LLINF
constexpr int INTINF {1000000000};//int = 2*INTINF

#define  rep(i,n)   for(int i = 0; i < (n); ++i)
#define rrep(i,n)   for(int i = 1; i <= (n); ++i)
#define drep(i,n)   for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for(int i = s; i < t;  ++i)

template<typename T>
void maxs(T& x, T&& y) {
  x=std::max(x,y);
}
template<typename T>
void maxs(T& x, T& y) {
  x=std::max(x,y);
}

template<typename T>
void mins(T& x, T&& y) {
  x=std::min(x,y);
}
template<typename T>
void mins(T& x, T& y) {
  x=std::min(x,y);
}

int main() {
  ios::sync_with_stdio(false);
  std::cin.tie(nullptr);
  int A, B;
  cin >> A >> B;
  int c = max(A, B);
  int d = min(A, B);
  cout << (c+max(c-1, d)) << '\n';
}


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

int main() {
  int n;
  cin>>n;
  long long l=0,r=1e9+1;
  while (r-l>1){
    long long m = (l+r)/2;
    if(m*m>n) r=m; else l = m;
  }
  cout<<l*l<<endl;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int x = sc.nextInt();
        sc.close();
        int ans = 0;
        int work = 0;

        for (int i = 1; i <= x; i++) {
            for (int j = 2; j < 1000; j++) {
                work = (int) Math.pow(i, j);
                if (work <= x) {
                    ans = Math.max(ans, work);
                }
            }
        }

        System.out.println(ans);
    }
}

Measured memory_bytes: 21844
#include <iostream>
#include <sstream>
#include <cmath>
#include <algorithm>
#include <utility>
#include <functional>
#include <iomanip>
#include <typeinfo>
#include <iterator>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <tuple>
#include <map>
#include <set>
using namespace std;


typedef long long       ll;
struct edge { ll to; ll cost; };
typedef vector<int>     vi;
typedef vector<ll>      vll;
typedef vector<double>  vd;
typedef vector<bool>    vb;
typedef vector<string>  vs;
typedef vector<char>    vc;
typedef vector<edge>    ve;
typedef pair<int, int>  pii;
typedef pair<ll, ll>    pll;
typedef vector<pii>     vpii;
typedef vector<pll>     vpll;
typedef vector<vll>		vvll;
typedef vector<vi>		vvi;
typedef vector<ve>      vve;
typedef vector<vc>		vvc;

// マクロ
#define repr(itr, bgn, end) for (ll itr = (ll)bgn; itr < (ll)end; ++itr)
#define rep(itr, end) repr(itr, 0, end)
#define reprrev(itr, bgn, end) for (ll itr = (ll)end - 1; itr >= (ll)bgn; --i)
#define reprev(itr, end) reprrev(itr, 0, end)
#define all(container) container.begin(), container.end()
#define sortall(container) sort(all(container))
#define yn(cond) cond ? (cout << "Yes" << endl) : (cout << "No" << endl)
#define YN(cond) cond ? (cout << "YES" << endl) : (cout << "NO" << endl)

// 定数
#define LLONG_MAX 9223372036854775807
constexpr double PI = 3.14159265358979323846;
constexpr ll INF = 1 << 15;
constexpr ll MOD = (ll)1e9 + 7;
constexpr double EPS = 1e-7;

// よく使うもの
constexpr int dy[4] = { 0, 1, 0, -1 };
constexpr int dx[4] = { 1, 0, -1, 0 };


// vector入力
template<typename T>
istream& operator >> (istream& is, vector<T>& vec) {
	for (T& x : vec) is >> x;
	return is;
}

// vector出力
template<typename T>
ostream& operator << (ostream& os, vector<T>& vec) {
	for (T& x : vec) os << x << " ";
	return os;
}

// ***<ここから>****************************************************************

long long Pow(long long a, long long n) {
	long long x = 1;
	while (n > 0) {
		if (n & 1) x = x * a;
		a = a * a;
		n = n >> 1;
	}
	return x;
}

int main(void) {

	int n;
	cin >> n;

	for (int i = n; i <= 999; i++) {
		if (i / 100 == (i % 100) / 10 && i / 100 == i % 10) {
			cout << i << endl;
			return 0;
		}
	}

	return 0;
}


Measured memory_bytes: 256
// I SELL YOU...! 
#include<iostream>
#include<vector>
#include<algorithm>
#include<functional>
#include<queue>
#include<chrono>
#include<iomanip>
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
void init_io(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << setprecision(10);
}
signed main(){
  init_io();
  ll n,cnt=0,l;
  cin >> n;
  vector<P> xl(n);
  for(int i=0;i<n;i++){
    cin >> xl[i].first >> xl[i].second;
    xl[i].first += xl[i].second;
  }
  cnt++;
  sort(xl.begin(),xl.end());
  l = xl[0].first;
  for(int i=1;i<n;i++){
    if(l<=xl[i].first-2*xl[i].second){
      cnt++;
      l = xl[i].first;
    }
  }
  cout << cnt << endl;
}


Measured memory_bytes: 1792
ref=[63,6,91,79,102,109,125,39,127,111]
while 1:
	try:
		n=int(raw_input())
		if n==-1:break
		e=0
		for i in range(n):
			a=ref[int(raw_input())]
			print "{:07b}".format(a^e)
			e=a
	except:
		pass

Measured memory_bytes: 4216
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;

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

	BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
	String numberArray[] = br.readLine().split(" ");
	int N = Integer.parseInt(numberArray[0]);
	int K = Integer.parseInt(numberArray[1]);

	String inputArray[] = br.readLine().split(" ");
	int priceArray[] = new int[N];
	for (int i = 0; i < N; i++) {
	    priceArray[i] = Integer.parseInt(inputArray[i]);
	}

	Arrays.sort(priceArray);
	int result = 0;
	for (int j = 0; j < K; j++) {
	    result += priceArray[j];
	}
	System.out.println(result);
    }
}


Measured memory_bytes: 33048
import std.stdio;
import std.range;
import std.array;
import std.algorithm;
import std.string;

void main(){
    auto input_1 = readln.chomp;
    auto input_2 = readln.chomp;
    auto input_3 = readln.chomp;
    auto answer = "" ~ input_1[0] ~ input_2[1] ~ input_3[2];
    writeln(answer);
}

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

int main() {
  string S,T;
  cin >> S >> T;
  int cnt = 0;
  rep(i,S.size()){
    if(S.at(i) == T.at(i)){
      cnt++;
    }
  }
  cout << S.size()-cnt << endl;
}

Measured memory_bytes: 3848
#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 k;
  cin >> k;
  if (k <= 9) {
    cout << k << endl;
    return 0;
  }

  queue<ll> q;
  for (int i = 1; i <= 9; i++) q.push(i);
  ll x;
  while (k != 0) {
    x = q.front();
    q.pop();
    k--;

    for (int j = -1; j <= 1; j++) {
      int d = x % 10 + j;
      if (d < 0 || d > 9) continue;
      q.push(x * 10 + d);
    }
  }

  cout << x << endl;
  return 0;
}

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

using namespace std;
using ll = long long;
inline int ri() { int n; cin >> n; return n;}

//経路復元なしDijkstra法
template<class T> 
vector<T> dijkstra(int start, const vector<vector<pair<int,T>>>& Hen){
	T INF = numeric_limits<T>::max();
	int N = Hen.size();
	vector<T> dist(N, INF);
	dist[start] = 0;
	priority_queue<pair<T,int>, vector<pair<T,int>>, greater<pair<T,int>>> que;
	que.emplace(0, start);
	while(que.size()) {
		int ver = que.top().second;
		T cost = que.top().first; que.pop();
		if(cost != dist[ver])continue;
		for(auto i : Hen[ver]) {
			if(dist[i.first] > cost + i.second) {
				dist[i.first] = cost + i.second;
				que.emplace(dist[i.first], i.first);
			}
		}
	}
	return dist;
}


int main()
{
    vector<tuple<double, double, double>> pos;
    {
        double xa, ya, xb, yb; cin >> xa >> ya >> xb >> yb;
        pos.push_back({xa, ya, 0}), pos.push_back({xb, yb, 0});
    }
    int n; cin >> n;
 
    for(int i = 0; i < n; i++) {
        double x, y, r; cin >> x >> y >> r;
        pos.push_back({x, y, r});
    }
 
    vector<vector<pair<int,double>>> hen(n + 2);
    for(int i = 0; i < n + 2; i++) {
        for(int j = i + 1; j < n + 2; j++) {
            double xa, ya, ra, xb, yb, rb, dist;
            tie(xa, ya, ra) = pos[i], tie(xb, yb, rb) = pos[j];
            dist =  sqrt((xa - xb) * (xa - xb) + (ya - yb) * (ya - yb)) - (ra + rb);
            dist = max(dist, 0.0);
            hen[i].push_back({j, dist});
            hen[j].push_back({i, dist});
        }
    }
 
    cout << fixed <<setprecision(12) << dijkstra(0,hen)[1] << '\n';
 
 
}

Measured memory_bytes: 23780
import java.util.*;
class Main {
    public static void main (String[] args) throws java.lang.Exception {
        Scanner sc = new Scanner(System.in);
        double x1 = sc.nextDouble(), y1 = sc.nextDouble(), x2 = sc.nextDouble(), y2 = sc.nextDouble();
        System.out.printf("%.9f\n", Math.sqrt((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2)));
    }
}


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

int N, M, Q;
int A[55], B[55], C[55], D[55];
int ans = 0;

void dfs(int m, vector<int> &a) {
  if (a.size() == N) {
    int sc = 0;
    for (int i = 0; i < Q; i++) {
      if (a[B[i]] - a[A[i]] == C[i]) {
        sc += D[i];
      }
    }
    ans = max(ans, sc);
    return;
  }

  for (int nxt = m; nxt <= M; nxt++) {
    a.emplace_back(nxt);
    dfs(nxt, a);
    a.pop_back();
  }
}

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

  cin >> N >> M >> Q;
  for (int i = 0; i < Q; i++) {
    cin >> A[i] >> B[i] >> C[i] >> D[i];
    A[i]--, B[i]--;
  }

  vector<int> a;
  dfs(1, a);

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


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

int main(){
  int64_t A, ans;
  string B;
  cin>>A>>B;
  
  int b1 = B.at(0)-'0';
  int b2 = stoi(B.substr(2,3));
  
  // cout<<b1<<' '<<b2<<endl;
  ans=A*b1+ A*b2/100;
  cout<<ans<<endl;
}

Measured memory_bytes: 3624
#include <iostream>
#include <vector>

constexpr int min(int a, int b) {
  return (a<b)?a:b;
}

int main(int argc, char** argv) {
  int N;
  std::cin >> N;
  std::vector<int> P(N);
  for (auto& e : P) std::cin >> e;
  std::vector<int> dp(N, P[0]);
  for (auto i = 1;i < N;++i) {
    dp[i] = min(dp[i-1], P[i]);
  }
  int cnt {};
  for (auto i = 0;i < N;++i) {
    if (P[i] <= dp[i]) ++cnt;
  }
  std::cout << cnt << '\n';
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
#define fuckit(){	\
	ios_base::sync_with_stdio(false); \
	cin.tie(NULL); \
}
using namespace std;
typedef long long ll;
int main()
{
	fuckit();
	ll k,s,i,cnt=0,x,j;
	cin>>k>>s;
	for(i=0;i<=k;i++){
		for(j=0;j<=k;j++){
			x=s-i-j;
			if(x>=0&&x<=k){
				cnt++;
			}
		}
	}
	cout<<cnt<<endl;
	return 0;	
}


Measured memory_bytes: 256
#include <stdio.h>
#define false 0
#define true 1

int main(){
  char is_prime[1000000];
  int n;
  int n_prime[1000000];

  is_prime[0]=is_prime[1]=false;
  for(int i=2;i<1000000;i++){
    is_prime[i] = true;
  }

  for(int i=2;i*i<1000000;i++){
    if(is_prime[i]){
      for(int j=i*i;j<1000000;j=j+i){
        is_prime[j] = false;
      }
    }
  }
  int cnt = 0;
  for(int i=0;i<1000000;i++){
    if(is_prime[i]){
      cnt++;
    }
    n_prime[i] = cnt;
  }

  while(scanf("%d",&n) != EOF){
    printf("%d\n",n_prime[n]);
  }

  return 0;
}



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

public class Main {

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

		int N = Integer.parseInt(line[0]);
		int D = Integer.parseInt(line[1]);

		int[][] X = new int[N][D];
		for (int i = 0; i < N; i++) {
			X[i] = Arrays.stream(sc.nextLine().split(" ")).mapToInt(s -> Integer.parseInt(s)).toArray();
		}

		long cnt = 0;
		double dist = 0;
		int yk, zk;
		for (int i = 0; i < N; i++) {
			for (int j = i + 1; j < N; j++) {
				if (i == j) continue;
				dist = 0;
				for (int k = 0; k < D; k++) {
					yk = X[i][k];
					zk = X[j][k];
					dist += Math.pow(yk - zk, 2);
				}
				dist = Math.sqrt(dist);
				if ((int) dist == dist) cnt++;
			}
		}
		System.out.println(cnt);
	}
}

Measured memory_bytes: 28372
#include<cstdio>
#include<cstring>
#include<vector>
#include<queue>
#include<algorithm>
#include<cmath>
#include<climits>
#include<string>
#include<set>
#include<map>
#include<iostream>
using namespace std;
#define rep(i,n) for(int i=0;i<((int)(n));i++)
#define reg(i,a,b) for(int i=((int)(a));i<=((int)(b));i++)
#define irep(i,n) for(int i=((int)(n))-1;i>=0;i--)
#define ireg(i,a,b) for(int i=((int)(b));i>=((int)(a));i--)
typedef long long int lli;
typedef pair<int,int> mp;
#define fir first
#define sec second
#define IINF INT_MAX
#define LINF LLONG_MAX
#define eprintf(...) fprintf(stderr,__VA_ARGS__)
#define pque(type) priority_queue<type,vector<type>,greater<type> >
#define memst(a,b) memset(a,b,sizeof(a))
#define iter(v,ite) for(auto ite=(v).begin();ite!=(v).end();ite++)
#define mimunum(v,x) distance((v).begin(),lower_bound((v).begin(),(v).end(),x))

lli n,m;

int main(void){
	lli ans;
	scanf("%lld%lld",&n,&m);
	if(m<n)swap(n,m);
	if(n==1){
		if(m==1)ans=1;
		else ans=m-2;
	}
	else if(n==2)ans=0;
	else ans=(m-2)*(n-2);
	printf("%lld\n",ans);
	return 0;
}






Measured memory_bytes: 256
#include <bits/stdc++.h>
#include<iostream>
#include <string>
using namespace std;
 
int main() {
    string a,b;
    int x,y,ans(0);

    cin >> a >> b;

   	a +=b;
    x = stol(a);

    for(int i = 0;i < x;i++){
        y = i*i;
        if(y == x){
            ans++;
            break;
        }
    }
    if(ans == 1){
        cout << "Yes";
    }else{
        cout << "No";
    }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int ans[100003],n,m,q,do1[100003],do2[100003],do3[100003];
vector<int>v[100005];
int vis[100003];
void dfs(int a,int b,int c){
	if(b==-1)return;
	if(b<=vis[a])return;
	vis[a]=b;
	if(!ans[a])ans[a]=c;
	for(int i=0;i<v[a].size();i++)
		dfs(v[a][i],b-1,c);
}
int main(){
	cin>>n>>m;
	for(int i=0;i<=100002;i++)vis[i]=-1;
	for(int i=0;i<m;i++)
	{
		int a,b;
		cin>>a>>b;
		v[a].push_back(b);
		v[b].push_back(a);
	}
	cin>>q;
	for(int i=1;i<=q;i++)
		cin>>do1[i]>>do2[i]>>do3[i];
	for(int i=q;i>0;i--){
		dfs(do1[i],do2[i],do3[i]);
	}
	for(int i=1;i<=n;i++)cout<<ans[i]<<endl;
}

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

bool queen_range(vector< vector<char> > &b, int r, int c){
	if(b[r][c] != '.') {
		return 0;
	}
	// 縦
	rep(i, 8) {
		if(i == r) continue;
		if(b[i][c] == 'Q'){
			return 0;
		}
	}
	// 横
	rep(i, 8) {
		if(i == c) continue;
		if(b[r][i] == 'Q'){
			return 0;
		}
	}
	
	// 斜め
	int dr[4] = {+1, +1, -1, -1};
	int dc[4] = {+1, -1, -1, +1};
	rep(dir, 4) {
		int next_r = r + dr[dir];
		int next_c = c + dc[dir];
		while(next_r >= 0 && next_r < 8 && next_c >= 0 && next_c < 8) {
			if(b[next_r][next_c] == 'Q'){
				return 0;
			}
			next_r += dr[dir];
			next_c += dc[dir];
		}
	}
	// Queenの移動可能範囲にxを記入
	b[r][c] = 'Q';
	rep(i, 8) {
		if(i == r) continue;
		b[i][c] = 'x';
	}
	// 横
	rep(i, 8) {
		if(i == c) continue;
		b[r][i] = 'x';
	}
	
	// 斜め
	rep(dir, 4) {
		int next_r = r + dr[dir];
		int next_c = c + dc[dir];
		while(next_r >= 0 && next_r < 8 && next_c >= 0 && next_c < 8) {
			b[next_r][next_c] = 'x';
			next_r += dr[dir];
			next_c += dc[dir];
		}
	}
	return 1; // 1は正常終了。0は被りあり
}

int main() {
	int k;
	cin >> k;
	vector<pair<int, int>> q(k);
	rep(i, k) {
		int r, c;
		cin >> r >> c;
		q[i] = make_pair(r, c);
	}
	set<int> sr;
	set<int> sc;
	rep(i, k) {
		sr.insert(q[i].first);
		sc.insert(q[i].second);
	}
	vector< vector<char> > b(8, vector<char>(8, '.'));
	rep(i, k){
		queen_range(b, q[i].first, q[i].second);
	}
	vector<int> per(8);
	rep(i, 8) {
		per[i] = i;
	}
	do{
		vector< vector<char> > now = b;
		bool ok = true;
		rep(i, 8) {
			if(sr.count(i) && sc.count(per[i])) {
				continue;
			}
			if(!queen_range(now, i, per[i])) {
				ok = false;
				break;
			}
		}
		if(ok){
			b = now;
			break;
		}
	}while(next_permutation(all(per)));
	
	rep(i, 8){
		rep(j, 8) {
			printf("%c", (b[i][j] == 'Q') ? 'Q' : '.');
		}
		printf("\n");
	}
	return 0;
}


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

using namespace std;

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

typedef int _loop_int;
#define REP(i,n) for(_loop_int i=0;i<(_loop_int)(n);++i)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1;i>=(_loop_int)(a);--i)

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG2(x,y) cout<<#x<<": "<<x<<" "<<#y<<": "<<y<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define DEBUG_ARR(v,n) cout<<#v<<":";REP(i,n)cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

const ll MOD = 1000000007ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

int n;

int main() {
    ios::sync_with_stdio(false); cin.tie(0);
    cin>>n;
    n++;
    vi a(n);
    vector<bool> visited(n);
    FOR(i,1,n) cin>>a[i];
    
    int pos = 1;
    int ans = 0;
    while(pos!=2){
        if(visited[pos]){
            cout << "-1" << endl;
            return 0;
        }
        visited[pos] = true;
        pos = a[pos];
        ans++;
    }

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

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

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

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

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

//main code

int main(int argc, char const* argv[])
{
    int h,w;
    cin >> h >> w;
    vector<vector<char>> mass(h,vector<char>(w));
    for (int i = 0; i < h; i++) {
        bool erase = true;
        for (int j = 0; j < w; j++) {
            cin >> mass[i][j];
            if (mass[i][j] == '#') {
                erase = false;
            }
        }
        if (erase == true) {
            mass.erase(mass.begin() + i);
            h--;
            i--;
        }
    }

    for (int i = 0; i < w; i++) {
        bool erase = true;
        for (int j = 0; j < h; j++) {
            if (mass[j][i] == '#') {
                erase = false;
            }
        }
        if (erase) {
            for (int j = 0; j < h; j++) {
                mass[j].erase(mass[j].begin() + i);
            }
            i--;
            w--;
        }
    }

    for (int i = 0; i < h; i++) {
        for (int j = 0; j < w; j++) {
            cout << mass[i][j];
        }
        cout << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define each(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)
#define all(obj) (obj).begin(),(obj).end() 
#define dump(x)  cout << #x << " = " << (x) << endl;
typedef long long lint;
using namespace std;
int main(){
	int a,b;
	cin>>a>>b;
	cout<<(b<a?a-1:a)<<endl;
}


Measured memory_bytes: 256
import fractions

inputs = [int(i) for i in input().split()]

a = inputs[0]
b = inputs[1]
c = inputs[2]
d = inputs[3]

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

l = lcm(c, d)

c1 = b // c
c2 = (a-1) // c
c3 = c1 - c2

d1 = b // d
d2 = (a-1) // d
d3 = d1 - d2

l1 = b // l
l2 = (a-1) // l
l3 = l1 - l2

ans = (b-a+1) - (c3 + d3 - l3)
print(ans)

Measured memory_bytes: 5076
#include  <bits/stdc++.h>
using namespace std;
 
#define IOS         ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); 
#define mem(a,v)    memset((a), (v), sizeof (a))
#define FOR(i,a,n)  for(int i = (a); i<(n); ++i) 
#define FORE(i,a,n) for(int i = (a); i<=(n); ++i)
#define mp(a , b)   make_pair(a , b)
#define eb(a)       emplace_back(a)

#define anal         '\n'

#define mod 1000000007


typedef long long ll;

vector<int> v;

int main(){
     
 IOS;
 
//#ifndef ONLINE_JUDGE  
   // freopen("input.in", "r", stdin);
   // freopen("output.in", "w", stdout);
//#endif 

 // -_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-
  
  string s, t;
  cin >> s >> t;
  t.pop_back();
  if(s == t) {
  	cout << "Yes";
  }
  else cout << "No";
 return  0 ;      
}        





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

int main(){
	cout << fixed << setprecision(3);
	double a,b,c,d,e,f;
	double x,y;
	while(cin >> a >> b >> c >> d >> e >> f){
		y = ((d * c) - (a * f)) / ((d * b) - (a * e)) ;
		x = (c - (b * y)) / a;
		if(x == 0) x = 0;
		if(y == 0) y = 0;

		cout << x << " " << y << "\n";
	}

}

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

int main(){
    string s;
    cin>>s;
    int ans=0;
    int cnt=0;
    for(int i=0;i<s.size();i++){
        if(s[i]=='A'||s[i]=='T'||s[i]=='G'||s[i]=='C'){
            cnt++;
            if(i==s.size()-1){ans=max(ans,cnt);}
        }else{
            ans=max(cnt,ans);
            cnt=0;
        }
    }
    cout<<ans<<endl;

    return 0;
}

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

// s[i]とs[i+1]を入れ替えた文字列を出力
string trans(string s, int i) {
    swap(s[i], s[i + 1]);
    return s;
}

//長さ3の文字列が"AGC"か判定
bool notAGC(string s) {
    string a = "agc";
    if (s == a || trans(s, 0) == a || trans(s, 1) == a) return false;
    return true;
}

int main() {
    int n;
    cin >> n;
    long long int p = 1e+9 + 7;
    // dp[i][s]:長さiのnotAGCで右3つがsなるものの数
    vector<unordered_map<string, long long int>> dp(n + 1);
    vector<string> c = {"a", "c", "g", "t"};
    // dp[3]を完成させる
    for (int i = 0; i < 4; i++) {
        for (int j = 0; j < 4; j++) {
            for (int k = 0; k < 4; k++) {
                string temp = c[i] + c[j] + c[k];
                if (notAGC(temp)) {
                    dp[3][temp]++;
                }
            }
        }
    }
    // dp[i(>3)]を完成させる
    for (int i = 3; i < n; i++) {
        for (auto itr = dp[i].begin(); itr != dp[i].end(); itr++) {
            for (int j = 0; j < 4; j++) {
                string temp1 = (*itr).first.substr(1) + c[j];
                string temp2 = (*itr).first.substr(0, 2) + c[j];
                string temp3 = trans((*itr).first, 0).substr(1) + c[j];
                if (notAGC(temp1) && temp2 != "agc" && temp3 != "agc") {
                    dp[i + 1][temp1] += (*itr).second;
                    dp[i + 1][temp1] %= p;
                }
            }
        }
    }
    long long int ans = 0;
    for (auto itr = dp[n].begin(); itr != dp[n].end(); itr++) {
        ans += (*itr).second;
        ans %= p;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 896
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp> 
#include <ext/pb_ds/assoc_container.hpp> 
using namespace std; using namespace __gnu_pbds;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> pii;

template <class T> using ordered_set = tree<T, null_type, less_equal<T>, rb_tree_tag, tree_order_statistics_node_update>;
typedef tree<int, null_type, less_equal<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_mset;

#define FOR(i,a,b) for(int i = a; i < b; i++)
#define F0R(i,a) for(int i = 0; i < a; i++)
#define F0Rd(i,a) for (int i = a - 1; i >=0 ; i--)
#define FORd(i,a,b) for (int i = b - 1; i >= a; i--)
#define pb push_back
#define all(x) x.begin(), x.end()
#define sz(x) int((x).size())
#define newl '\n'

#define FAST ios::sync_with_stdio(0); cin.tie(0);
#define print(x) cout << x << newl;
#define finish(x) return cout << x << "\n", 0;
#define bug(x) cerr << ">>> " << #x << " = " << x << "\n";
#define _ << " " << 

const int MXN = 2e5 + 5;
//const int MXN = 1e6 + 5;
const ll MOD = 998244353;
const ll INF = 1e9 + 7;

int N, W, weights[105];
ll vals[105], dp[105][100001];


int main(){ FAST
	//ifstream cin("/Users/konwoo/input.txt");
	//ofstream cout("/Users/konwoo/output.txt");

    cin >> N >> W;
    F0R(i,N) cin >> weights[i+1] >> vals[i+1];

    FOR(i,1,N+1){
        FOR(j,1,W+1){
            dp[i][j] = max(dp[i][j],dp[i-1][j]);
            if (j >= weights[i]){
                dp[i][j] = max(dp[i][j],dp[i-1][j-weights[i]] + vals[i]);
            }
        }
    }
    cout << dp[N][W] << newl;










	return 0;
}


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

using namespace std;

#define rep(i, n) for (int i = 0; i < n; ++i)
#define stl_rep(itr, x) for (auto itr = x.begin(); itr != x.end(); ++itr)
#define stl_repr(itr, x) for (auto itr = x.rbegin(); itr != x.rend(); ++itr)
#define all(x) x.begin(), x.end()
#define allr(x) x.rbegin(), x.rend()

using llong = long long int;

const static int MOD = 1000000000 + 7;
const static int inf = INT_MAX / 2;
const static llong INF = 1LL << 31;
const static int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};

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

    int n;
    cin >> n;
    vector<int> p1(n), p2(n);
    rep(i, n) {
        cin >> p1[i];
        p2[i] = p1[i];
    }
    sort(all(p2));

    int diff = 0;
    rep(i, n) {
        if (p1[i] != p2[i]) ++diff;
    }
    
    if (diff == 2 || diff == 0) cout << "YES" << endl;
    else cout << "NO" << endl;

    return 0;
}

Measured memory_bytes: 256
X, Y = ARGF.gets.chomp.split.collect {|el| el.to_i}

ans = "No"
for tt in 0..X
  kk = X - tt
  if tt * 2 + kk * 4 == Y
    ans = "Yes"
    #p tt, kk
    break
  end
end

puts ans


Measured memory_bytes: 14300
#include<iostream>
using namespace std;
int main(){
    int n,m;
    cin >> n >> m;
    int a[n][m];
    int b[m];
    int s=0;
    
    for(int p=0;p<n;p++){
        for(int u=0;u<m;u++){
            a[p][u]=0;
        }
    }
    for(int i=0;i<n;i++){
        for(int j=0;j<m;j++){
            cin >> a[i][j];
            
        }
    }
    for(int k=0;k<m;k++){
        cin >> b[k];
        
    }
    for(int l=0;l<n;l++){
        for(int o=0;o<m;o++){
            s=s+a[l][o]*b[o];
        }
        cout << s <<endl;
        s=0;
    }
}


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

int main(){
  long long a,b,h;
  cin >>a >> b >> h;
  cout << (a+b)*h/2<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <ios> 
#include <vector>
#include <string>
#include <algorithm>
#include <functional>
#include <queue>
#include <stack>
#include <set>
#include <cmath>
#include <bitset>
#include <map>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define sz(c) ((int)(c).size())

using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
const int MOD=1e9+7;
const int MAX=1e5+10;


int main(){
	int N, M;
	cin>>N>>M;
	bool step[MAX];
	rep1(i,N)step[i]=true;
	rep(_,M){
		int a;
		cin>>a;
		step[a]=false;
	}
	int dp[MAX];
	dp[0]=1;
	rep1(i,N){
		if(!step[i])dp[i]=0;
		else{
			if(i==1)dp[i]=1;
			else{
				dp[i]=(dp[i-1]+dp[i-2])%MOD;
			}
		}
	}
	cout<<dp[N]<<endl;
	
}

Measured memory_bytes: 768
#!/usr/bin/env python3
import sys
from collections import deque, Counter
from heapq import heappop, heappush
from bisect import bisect_right
from itertools import accumulate

sys.setrecursionlimit(10**6)
INF = 10**12
m = 10**9 + 7

def main():
    H, W = map(int, input().split())
    a = ''
    for _ in range(H):
        a += input()
    
    nums1 = 0
    nums2 = 0
    if H % 2 != W % 2:
        nums2 -= 1
    for l in Counter(a).values():
        if l & 1:
            nums1 += 1
        if l % 4 > 1:
            nums2 += 1

    if nums1 > H*W % 2 or nums2 > (H%2) * ((W-1)//2) + (W%2) * ((H-1)//2):
        print('No')
    else:
        print('Yes')

if __name__ == "__main__":
    main()

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

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

Measured memory_bytes: 3556
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define F(i,a,b) for(long long i=a;i<=b;i++)
ll  w[1001],v[1001],f[107][100007];
main()
{
ll n,W,s=0,i,j;
cin>>n>>W;
F(i,1,n){   cin>>w[i]>>v[i]; s+=v[i]; }
F(i,1,s)f[0][i]=30000000000;
F(i,1,n)F(j,1,s)
{
   f[i][j]=f[i-1][j];
   if(j>=v[i])f[i][j]=min(f[i][j],f[i-1][j-v[i]]+w[i]);
}
for(i=s;i>=1;i--)
if(f[n][i]<=W){ cout<<i;  break;}
}


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

using namespace std;

#define YES cout << "YES" << endl;
#define NO  cout << "NO"  << endl;
#define Yes cout << "Yes" << endl;
#define No  cout << "No"  << endl;
 
#define INF INT_MAX
#define MOD 1000000007
#define PI  acos(-1)

using ll  = long long;
using ull = unsigned long long;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

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

    int N;
    int D, X;
    cin >> N >> D >> X;

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

    int ans = 0;
    for (int i = 0; i < N; i++) {
        ans += (((D-1) / A[i]) + 1);
    }

    cout << ans + X << endl;

    return 0;
}

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

int main(void) {
    int a, b;
    
    cin >> a >> b;

    //printf("%d %d %.8lf \n", a/b, a%b, (double)a/(double)b);
    
    cout << a/b << " " << a%b << " " << fixed << setprecision(8) << (double)a/(double)b << endl;
    
    return 0;
}

Measured memory_bytes: 3260
#include <bits/stdc++.h>
using namespace std;
const int N=1e5+5;
int a[N];
int cnt[N];
void fin()
{
    cout<<"Yes"<<endl;
    exit(0);
}
int main()
{
    int n;
    scanf("%d",&n);
    memset(cnt,0,sizeof(cnt));
    for(int i=1;i<=n;i++)
    {
        scanf("%d",&a[i]);
        cnt[a[i]]++;
    }
    bool posi=false;
    int idx=-1;
    int previdx=-1;
    for(int i=1;i<=n-1;i++)
    {
        if(cnt[i]==n)
        {
            posi=true;
            idx=i;
            break;
        }
        if(i>1&&(cnt[i]+cnt[i-1]==n))
        {
            posi=true;
            idx=i;
            previdx=i-1;
            break;
        }
    }
    if(!posi)
    {
        cout<<"No"<<endl;
        return 0;
    }
    if(previdx == -1)
    {
        if(idx==(n-1))
            fin();
        if(2*idx <= n)
            fin();
        cout<<"No"<<endl;
        return 0;
    }
    else
    {
        int c=cnt[previdx];
        int m=idx;
        if(c==m)
        {
            cout<<"No"<<endl;
            return 0;
        }
        if(c<=idx)
            if( (c+2*(m-c)) <= n)
                fin();
        cout<<"No"<<endl;
        return 0;
    }
    return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
double pan(long long x){
	long long sum=0,kkk=x;
	while(kkk){
		sum+=kkk%10;
		kkk/=10;
	}
	return x*1.0/(sum*1.0);
}
int main(){
	long long now=0,x=1,k;
	scanf("%lld",&k);
	while(k--){
		if((now/x)%10!=9){
			now+=x;
			printf("%lld\n",now);
		}
		else{
			if(pan(now+x)>pan(now+x*10))x*=10;
			now+=x;
			printf("%lld\n",now);
		}
	}
}

Measured memory_bytes: 3640
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<ll,ll> mp;
ll inf =  1e9;


int main(){
 ll s,w;
 cin>>s>>w;
 if( s<=w ){
  cout<<"unsafe"<<endl;
 
 }else{
  cout<<"safe"<<endl;
 }
    return 0;
}


Measured memory_bytes: 3636
#include<stdio.h>


int main()
{
    int i,j,k,n,x,a[534] ;
    scanf("%d %d %d",&n,&k,&x) ;
    int d,p ;
    double f=n*1.0/x ;

    if(f<=k*1.0)
        printf("Yes") ;
    else
        printf("No") ;
    return 0 ;
}



Measured memory_bytes: 1728
def merge_sort(arr):
 if len(arr) <= 1:
  return arr
 mid = len(arr) // 2
# ここで分割を行う
 left = arr[:mid]
 right = arr[mid:]
# 再帰的に分割を行う
 left = merge_sort(left)
 right = merge_sort(right)
# returnが返ってきたら、結合を行い、結合したものを次に渡す
 return merge(left, right)
def merge(left, right):
 merged = []
 l_i, r_i = 0, 0
# ソート済み配列をマージするため、それぞれ左から見ていくだけで良い
 while l_i < len(left) and r_i < len(right):
    # ここで=をつけることで安定性を保っている
  if left[l_i][1] <= right[r_i][1]:
   merged.append(left[l_i])
   l_i += 1
  else:
   merged.append(right[r_i])
   r_i += 1

# 上のwhile文のどちらかがFalseになった場合終了するため、あまりをextendする
 if l_i < len(left):
  merged.extend(left[l_i:])
 if r_i < len(right):
  merged.extend(right[r_i:])
 return merged
import sys
input = sys.stdin.readline
N=int(input())
lst=[0]*N
lst=[list(map(int,input().split())) for i in range(N)]
lsta=merge_sort(lst)
ans=0
t=0
for i in range(N):
 t+=lsta[i][0]
 if t>lsta[i][1]:
  ans+=1
if ans==0:
 print("Yes")
else:
 print("No")


Measured memory_bytes: 119644
#include <iostream>
#include <algorithm>
#include <utility>
#include <vector>
#include <string>

using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define REP(i, n) for (int i = 0; i < (n); i++)
#define RREP(i, n) for (int i = (n) - 1; i >= 0; i--)
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define RFOR(i, a, b) for (int i = (a); i > (b); i--)
#define ALL(a) (a).begin(), (a).end()

int main() {
    string N;
    cin >> N;
    if (N[0] == '9' || N[1] == '9') cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
// H - Grid 1
#include <bits/stdc++.h>
using namespace std;
#define rp(i,s,e) for(int i=(s);i<(e);++i)
#define MOD 1'000'000'007
#define MAX 1'000
string grid[MAX];
int dp[MAX+1][MAX+1]; // init 0

int main(){
	int H,W; cin>>H>>W;
	rp(h, 0, H) cin>>grid[h];
	rp(i, 1, H+1){ // [1,H] dp height
		rp(j, 1, W+1){ // [1,W] dp width
			if(grid[i-1][j-1] == '#') continue;
			if(i==1 && j==1){ dp[i][j] = 1; continue; }
			dp[i][j] = (dp[i][j-1] + dp[i-1][j]) % MOD;
		}
	}
	cout<< dp[H][W] <<endl;
}


Measured memory_bytes: 5248
#include<bits/stdc++.h>
//#include <boost/multiprecision/cpp_int.hpp> 
//using namespace boost::multiprecision; 

using namespace std;

//#Rohitpratap311
//#Keep Calm And Stay Happy

typedef long long ll;
typedef long double ld;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll t=1;
    //cin>>t;
    while(t--)
    {
        ll n;
        cin>>n;
        ll arr[n];
        for(ll i=0;i<n;i++)
        {
            cin>>arr[i];
        }
        ll dp[n];
        dp[0]=0;
        dp[1]=abs(arr[1]-arr[0]);
        for(ll i=2;i<n;i++)
        {
            ll a=abs(arr[i]-arr[i-1])+dp[i-1];
            ll b=abs(arr[i]-arr[i-2])+dp[i-2];
            dp[i]=min(a,b);
            //cout<<dp[i]<<endl;
        }
        cout<<dp[n-1];
    }
    return 0;
}

Measured memory_bytes: 5116
import math

n,d = map(int,input().split())
x = [list(map(int,input().split())) for i in range(n)]

cnt = 0

for i in range(n):
    for j in range(i):
        tmp = 0
        for k in range(d):
            tmp += (x[i][k]-x[j][k])**2
        if math.sqrt(tmp).is_integer():
            cnt+=1

print(cnt)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); ++i)
int main(){
  int N,cnt;
  cin >> N;
  for (int i = 0; i < (N+1); ++i){
  int X;
   X = i*1.08;
   if ( X == N ){
     cout << i << endl;
     return 0;
   }
   }
        cout << ":("<< endl;
    return 0;
}

Measured memory_bytes: 256
n=int(input())
a=list(map(lambda x:2*int(x),input().split()))

ans=[0]*n
s=int(sum(a)/2)
for i in range(1,n,2):
    s-=a[i]
ans[0]=s
for i in range(1,n):
    ans[i]=a[i-1]-ans[i-1]
print(*ans)


Measured memory_bytes: 64996
#include <iostream>
#include <cmath>
#include <cstdio>
#include <string>
#define rep(i,n) for(int (i) = 0; (i) < (n); (i)++)
using namespace std;
int ok(string S, int N, int n) {
    char my[10];
    //sprintf_s(my, "%03d", n);
    sprintf(my, "%03d", n);
    int index = 0;
    int match = 0;
    for (int i = 0; i < N - 2; i++) {
        if (S[i] == my[0]) {
            match = 1;
            index = i;
            break;
        }
    }
    if (match == 0) return 0;
    match = 0;
    for (int i = index + 1; i < N - 1; i++) {
        if (S[i] == my[1]) {
            match = 1;
            index = i;
            break;
        }
    }
    if (match == 0) return 0;
    for (int i = index + 1; i < N; i++) {
        if (S[i] == my[2]) {
            return 1;
        }
    }
    return 0;
}

int main() {
    int N;
    string S;
    int count = 0;
    cin >> N >> S;
    rep(i, 1000) {
        if (ok(S, N, i)) {
            count += 1;
        }
    }
    cout << count << endl;
    return 0;
}


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

int main() {
  int A, B, K;
  scanf("%d%d%d", &A, &B, &K);

  int ans = 0;
  int count = 0;
  for (int i = min(A, B); i > 0; i--) {
    if (A % i == 0 && B % i == 0) {
      ans = i;
      count++;
    }
    if (count == K) break;
  }

  printf("%d", ans);
  return 0;
}

Measured memory_bytes: 256