akhauriyash/Code-Regression huggingface dataset:
// 2014/09/11 Tazoe

#include <iostream>
using namespace std;

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

		if(n==0)
			break;

		int i[1000], p[1000], q[1000], r[1000];
		for(int j=0; j<n; j++){
			cin >> i[j] >> p[j] >> q[j] >> r[j];
		}

		int P, Q, R, C;
		cin >> P >> Q >> R >> C;

		bool flg = false;

		for(int j=0; j<n; j++){
			if(p[j]<=P && q[j]<=Q && r[j]<=R && 4*p[j]+9*q[j]+4*r[j]<=C){
				cout << i[j] << endl;
				flg = true;
			}
		}

		if(!flg){
			cout << "NA" << endl;
		}
	}

	return 0;
}

Measured memory_bytes: 1176
#include <bits/stdc++.h>
using namespace std;
#define rep(i,j,k) for(int i = (int)j;i <= (int)k;i ++)
#define debug(x) cerr<<#x<<":"<<x<<endl
const int maxn=(int)1e6+5;
typedef long long ll;
ll MOD=(ll)1e9+7;
ll qpow(ll a,ll b){return b?((b&1)?a*qpow(a*a%MOD,b>>1)%MOD:qpow(a*a%MOD,b>>1))%MOD:1;}
ll c(ll n,ll m){
    ll ret=1;
    if(n<m)return 0;
    rep(i,1,m){
        ret*=qpow(i,MOD-2);
        ret%=MOD;
        ret*=n-i+1;
        ret%=MOD;
    }
    return ret;
}
ll p(ll n,ll m){
    ll ret=1;
    if(n<m)return 0;
    rep(i,1,m){
        /* ret*=qpow(i,MOD-2);
        ret%=MOD; */
        ret*=n-i+1;
        ret%=MOD;
    }
    return ret;
}
int main(){
    ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    int n,k;
    cin>>n>>k;
    cout<<c(n+k-1,k-1)<<endl;
}


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

const ll mx = 1e18;

int main(){
	int n;
	cin >> n; 	
  	ll ans = 1;
  	bool over = false;
  
   	rep(i, n){
    	ll a;
      	cin >> a;
      
      	if(a == 0){
        	cout << 0 << endl;
          	return 0;
        }
      
      	if(over || (mx+1)/ans < a || a*ans > mx){
			over = true;
        }
      
      	ans *= a;
    }
  
  	if(over) ans = -1;
  	cout << ans << endl;
}

Measured memory_bytes: 3640
//============================================================================
// Name        : TopCoderCompetition.cpp
// Author      : taguchi
// Version     :
// Copyright   : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================

#include <iostream>
#include <bitset>
#include <algorithm>
#include <map>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <string>
#include <vector>
#include <numeric>
#include <list>
#include <sstream>
using namespace std;
//#define P pair<int,int>
//#define max 999999
typedef unsigned int uint;
typedef unsigned long ul;
typedef long long ll;
typedef unsigned long long ull;
#define rep(i,n) for(ull i = 0;i<n;i++)
#define pb(n) push_back(n)
#define clear(n) memset(n,0,sizeof(n))

typedef vector<int> vi;
typedef vector<string> vs;
struct edge{int cost,to;};

vector<string> split(string &in,char delimiter){
	vector<string> re; uint cur = 0,next;
	while((next = in.find_first_of(delimiter,cur)) != string::npos){
		re.pb(string(in,cur,next-cur));
		cur = next + 1;
	}
	re.pb(string(in,cur,in.size()-cur));
	return re;
}
vector<int> split_int(string &in, char delimiter){
	vector<string> str = split(in,delimiter);
	vector<int> re;
	rep(i,str.size()){
		re.pb(strtol(str[i].c_str(),NULL,10));
	}
	return re;
}

class Range{
public:
	int a,b;
	Range(int an,int bn) : a(an),b(bn){}

	bool operator()(int n){
		return a<=n&&n<=b;
	}
	bool isCross(Range x){
		return x(a) || x(b);
	}
	bool contains(Range x){
		return this->a <= x.a && x.b <= this->b;
	}
};

bool isprime[1000010];
uint table[246914];
int main(){
	for(int i = 2;i<1000010;i++){
		if(!isprime[i]){
			for(int j = 2;i*j<1000010;j++){
				isprime[i*j] = true;
			}
		}
	}
	isprime[0] = true;isprime[1] = true;
	rep(i,246914){
		table[i] = !isprime[i];
	}
	partial_sum(table,table+246914,table);
	while(1){
		int n;
		cin >> n;
		if(!n)break;
		cout << table[2*n] - table[n] << endl;
	}

	return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <string>
#include <vector>
#include <queue>
#include <cassert>
using namespace std;
typedef long long ll;
const int INF = 1<<30;
const ll MOD = 1e9+7;
const double EPS = 1e-9;


int main(int argc, const char * argv[]) {
  ll N, K; cin >> N >> K;
  vector<int> A(N);
  for(int i=0; i<N; i++)
    cin >> A[i];
  
  vector<vector<int>> jump(300000);
  for(int i=0; i<N; i++)
    jump[A[i]].push_back(i);
  
  vector<ll> log;
  ll len, period, diff;
  int Xi, indexA;
  len = 0;
  log.push_back(len);
  indexA = (int)(len%N);
  Xi = A[indexA];
  while(true){
    auto it = upper_bound(jump[Xi].begin(), jump[Xi].end(), indexA);
    if(it != jump[Xi].end()){
      diff = (ll) (*it) - indexA;
    }else {
      diff = (ll) (N - indexA - 1) + (jump[Xi][0] + 1);
    }
    len += diff + 1;
    log.push_back(len);
    indexA = (int)(len%N);
    Xi = A[indexA];
    if(indexA == 0){
      period = len/N;
      break;
    }
  }
  
  K %= period;
  vector<int> ans;
  if (period != 1){
    auto it = lower_bound(log.begin(), log.end(), K*N);
    it--;
    int start = (int)((*it)%N);
    for(int i=start; i<N; i++){
      Xi = A[i];
      auto it2 = upper_bound(jump[Xi].begin(), jump[Xi].end(), i);
      if(it2 != jump[Xi].end()){
        i = *it2;
      }else {
        ans.push_back(Xi);
      }
    }
  }
  
  for(auto a: ans){
    cout << a << " ";
  }
  cout << endl;
  
  return 0;
}

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

int main()
{
    int a, b, c;

    cin >> a >> b >> c;

    if ( c == 1 || a == 1 && b == 1 ) {
        cout << "Open" << endl;
    } else {
        cout << "Close" << endl;
    }

    return ( 0 );
}



Measured memory_bytes: 3076
#include<iostream>
using namespace std;
int main(){
  int n,k,s;
  int i,j,l,o=0,sum;
  int a[10];
  cin >> n >> k >> s;
  while(n!=0){
    o=0;
    for(a[0]=n;a[0]>0;a[0]--){
      if(k==1){
	sum=0;
	for(i=0;i<1;i++) sum+=a[i];
	if(sum==s) o++;
      }else{
	for(a[1]=a[0]-1;a[1]>0;a[1]--){
	  if(k==2){
	    sum=0;
	    for(i=0;i<2;i++) sum+=a[i];
	    if(sum==s) o++;
	  }else{
	    for(a[2]=a[1]-1;a[2]>0;a[2]--){
	      if(k==3){
		sum=0;
		for(i=0;i<3;i++) sum+=a[i];
		if(sum==s) o++;
	      }else{
		for(a[3]=a[2]-1;a[3]>0;a[3]--){
		  if(k==4){
		    sum=0;
		    for(i=0;i<4;i++) sum+=a[i];
		    if(sum==s) o++;
		  }else{
		    for(a[4]=a[3]-1;a[4]>0;a[4]--){
		      if(k==5){
			sum=0;
			for(i=0;i<5;i++) sum+=a[i];
			if(sum==s) o++;
		      }else{
			for(a[5]=a[4]-1;a[5]>0;a[5]--){
			  if(k==6){
			    sum=0;
			    for(i=0;i<6;i++) sum+=a[i];
			    if(sum==s) o++;
			  }else{
			    for(a[6]=a[5]-1;a[6]>0;a[6]--){
			      if(k==7){
				sum=0;
				for(i=0;i<7;i++) sum+=a[i];
				if(sum==s) o++;
			      }else{
				for(a[7]=a[6]-1;a[7]>0;a[7]--){
				  if(k==8){
				    sum=0;
				    for(i=0;i<8;i++) sum+=a[i];
				    if(sum==s) o++;
				  }else{
				    for(a[8]=a[7]-1;a[8]>0;a[8]--){
				      if(k==9){
					sum=0;
					for(i=0;i<9;i++) sum+=a[i];
					if(sum==s) o++;
				      }else{
					for(a[9]=a[8]-1;a[9]>0;a[9]--){
					  sum=0;
					  for(i=0;i<10;i++) sum+=a[i];
					  if(sum==s) o++;
					}
				      }
				    }
				  }
				}
			      }
			    }
			  }
			}
		      }
		    }
		  }
		}
	      }
	    }
	  }
	}
      }
    }
	   
    cout << o << endl;
    cin >> n >> k >> s;
  }
}

Measured memory_bytes: 1160
#include <limits.h>
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

#define int long long
#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define REPS(i, n) for (int i = 1, i##_len = (n); i <= i##_len; ++i)
#define FOR(i, a, b) for (int i = (a), i##_len = (b); i <= i##_len; ++i)
#define REV(i, a, b) for (int i = (a); i >= (b); --i)
#define CLR(a, b) memset((a), (b), sizeof(a))
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define INF 1001001001001001001ll
#define fcout cout << fixed << setprecision(10)

using namespace std;

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

    int N, K;
    cin >> N >> K;
    vector<int> h(N);
    REP(i, N) {
        cin >> h[i];
    }
    sort(h.begin(), h.end());
    int ans = INF;
    REP(l, N) {
        int r = l + K - 1;
        if (r >= N) break;
        ans = min(ans, h[r] - h[l]);
    }
    cout << ans << endl;
    return 0;
}


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

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

  int s1 = s / 100;
  int s2 = (s % 100) / 10;
  int s3 = (s % 100) % 10;

  cout << s1+s2+s3 << endl;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;

namespace ConsoleApp
{
    class Program
    {
        static void Main(string[] args)
        {
            var input = Console.ReadLine().Split().Select(int.Parse).ToArray();
            var H = input[0];
            var W = input[1];
            var M = input[2];
            var bomList = new List<(int, int)>();
            var hArray = new int[H];
            var wArray = new int[W];
            for (int _ = 0; _ < M; _++)
            {
                var hw = Console.ReadLine().Split().Select(int.Parse).ToArray();
                var h = hw[0] - 1;
                var w = hw[1] - 1;
                bomList.Add((h, w));
                hArray[h]++;
                wArray[w]++;
            }

            var hMax = hArray.Max();
            long hMaxCount = hArray.Count(i => i == hMax);
            var wMax = wArray.Max();
            long wMaxCount = wArray.Count(i => i == wMax);

            var bomCount = bomList.Count(t => hArray[t.Item1] == hMax && wArray[t.Item2] == wMax);

            Console.WriteLine(bomCount < hMaxCount * wMaxCount ? hMax + wMax : hMax + wMax - 1);
        }
    }
}


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

int main(){
    int N,T,A;
    cin>>N>>T>>A;
    double min = 100000;
    int index;
    rep(i, N){
        int H;
        cin>>H;
        double t = T-H*0.006;
        if(min > abs(A-t)){
            min = abs(A-t);
            index = i+1;
        }
    }

    cout << index << endl;
}


Measured memory_bytes: 256
import java.util.*;

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

    String title = sc.next();

    switch (title) {
      case "ABC":
        System.out.println("ARC");
        break;
      case "ARC":
        System.out.println("ABC");
        break;
    }
    sc.close();
  }
}

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

int main(){
    long long a, b, c;
    cin >> a >> b >> c;
    if(a-c >= 0){
        cout << a - c <<" " << b << endl;
    }else if(a + b - c >= 0){
        cout << 0 <<" " <<  a + b - c << endl;
    }else{
        cout << 0 << " " << 0 << endl;
    }
    return 0;
}

Measured memory_bytes: 256
diagonal = Array.new(150){Array.new(150)}

for i in 1..150
  for j in (i+1)..150
    diagonal[i][j] = i*i + j*j
  end
end

while true
  h, w = gets.split(/ /).map(&:to_i)
  
  if h == 0 && w == 0
    break
  end

  length = h*h + w*w
  min_length = (150*150)*2
  min_h = h
  min_w = 150
  
  for i in 1..150
    for j in (i+1)..150
      if diagonal[i][j] == h*h + w*w
        if i > h
          if min_length != length || min_h > i
            min_length = length
            min_h = i
            min_w = j
          end
        end
      elsif diagonal[i][j] > length
        if min_length > diagonal[i][j]
          min_length = diagonal[i][j]
          min_h = i
          min_w = j
        elsif min_length == diagonal[i][j] && min_h > i
          min_h = i
          min_w = j
        end
      end
    end
  end
  puts min_h.to_s + " " + min_w.to_s
end


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

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

  vector<vector<int>> cnt(10,vector<int>(10));
  for (int i = 0; i < 10; i++)
  {
    cnt[i][i] = 1;
  }
  if(n<=9){
    cout << n << endl;
    return 0;
  }

  int ans = 9;
  int d = 10;
  for (int i = 10; i <= n; i++)
  {
    if(i/d >= 10) {
      d*=10;
    }
    int h = i/d;
    int t = i%10;
    if(t==0) continue;
    ans+=cnt[t][h] * 2;
    cnt[h][t]++;
    if(h==t) ans++;
  }
  cout << ans << endl;
  
}

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

#define all(a) a.begin(), a.end()
#define forn(l, r) for(int i = l; i < (r); ++i)
#define F first
#define S second
#define $ ios::sync_with_stdio(0);
///#define int long long int

using namespace std;
using namespace __gnu_pbds;
using ll = long long int;
using ii = pair<int, int>;
using li = pair<ll, int>;
using vi = vector<int>;
using graph = vector<vi>;
using ordered_set = tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

const ll mod =  1000000007;
const int INF = 0x3f3f3f3f;
const int MAXN = 212345;
// const double pi = 3.14159265359;
const double eps = 0.00000001;

int arr[212345];
int pre[MAXN], suf[MAXN];

int32_t main() {
    $
    int n;
    cin >> n;
    if (n == 1) {
        return cout << (int)1e9 << '\n', 0;
    }
    forn (1, n + 1) {
        cin >> arr[i]; 
        if (i == 1) pre[i - 1] = arr[i];
        pre[i] = __gcd(pre[i - 1], arr[i]);
    }
    suf[n + 1] = arr[n];
    for (int i = n; i >= 0; --i) {
        suf[i] = __gcd(suf[i + 1], arr[i]);
    }
    int ans = max(suf[2], pre[n - 1]), x;
    forn (2, n) {
        ans = max(ans, __gcd(pre[i - 1], suf[i + 1]));
    }
    if (n == 1) ans = 1e9;
    cout << ans << '\n';
}   



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

int N, M;
int road[100] = {0};

int main() {
    cin >> N >> M;
    for(int i = 0; i < M; ++i) {
        int a, b;
        cin >> a >> b;
        road[a]++;road[b]++;
    }
    for(int i = 1; i <= N; ++i) {
        cout << road[i] << endl;
    }

}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef pair<double, double> P;
int main() {
	long long N;
	cin >> N;
	vector<long long>A(N);
	for (long long i = 0; i < N; i++) {
		cin >> A.at(i);
	}
	long long ans = 0;
	for (long long i = 1; i < (1 << N); i++) {
		long long num = 1;
		queue<long long>Even;
		for (long long j = 0; j < N; j++) {
			if (i & (1 << j)) Even.push(j);
		}
		for (long long j = 0; j < N; j++) {
			if (!Even.empty()) {
				if (j == Even.front()) {
					if (A.at(j) % 2 != 0) num *= 2;
					else num *= 1;
					Even.pop();
				}
				else {
					if (A.at(j) % 2 != 0) num *= 1;
					else num *= 2;
				}
			}
			else {
				if (A.at(j) % 2 != 0) num *= 1;
				else num *= 2;
			}
		}
		ans += num;
	}
	cout << ans << endl;
}

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

#include <atcoder/all>
using namespace atcoder;
using namespace std;
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long ll;
typedef pair<ll, ll> P;
const ll INF = (ll)1e18;
const ll MOD = 1000000007;
ll op(ll a, ll b) { return max(a, b); }
ll e() { return 0; }
int main() {
  ll N, K;
  cin >> N >> K;
  segtree<ll, op, e> seg(300000 + 100);
  REP(i, N) {
    ll a;
    cin >> a;
    ll mx = seg.prod(max<ll>(0, a - K), min<ll>(a + K + 1, 300000 + 20));
    seg.set(a, mx + 1);
  }
  cout << seg.prod(0, 300000) << endl;
}

Measured memory_bytes: 13848
#include<bits/stdc++.h>
#define ll long long int
#define M 1000000007
#define mod 998244353
#define mp(x,y) make_pair(x,y)
#define pb(x) push_back(x)
#define pi pair<ll,ll>
using namespace std;
const ll N=300010;

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

	//freopen("input.txt","r",stdin);
	//freopen("output.txt","w",stdout);

	ll w,h,x,y;
	cin>>w>>h>>x>>y;
	long double area=(w*h*1.0)/2;
	cout<<std::fixed;
	cout<<setprecision(9)<<area<<" ";
	int t=0;
	if(w%2==0&&h%2==0)
    {
        if(x==w/2&&y==h/2){t=1;}
    }
    cout<<t;

	return(0);
}


Measured memory_bytes: 256
n = int(input())
t,a = map(float,input().split(" "))
l=[]
l=input().split(" ")
indx=0
min=1000000.0
for i in range(0,n):
	val = t-int(l[i])*(0.006)
	if(val>a):
		val=val-a
	else:
		val=a-val
	if(val<min):
		min=val
		indx=i+1
print(indx)



Measured memory_bytes: 3060
#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 pair<ll,ll> pll;

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 DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

#define CHMIN(a,b) a=min((a),(b))
#define CHMAX(a,b) a=max((a),(b))

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

// floating
typedef double Real;
const Real EPS = 1e-11;
#define EQ0(x) (abs(x)<EPS)
#define EQ(a,b) (abs(a-b)<EPS)
typedef complex<Real> P;

int main(){
  int a,b,c,d;
  cin>>a>>b>>c>>d;
  cout<<max(a*b,c*d)<<endl;
  return 0;
}


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

using namespace std;

int main()
{
  int N, M;
  cin >> N >> M;
  vector<int> bit[2];
  for(int i = 0; i < N; i++){
    int b; cin >> b;
    bit[0].push_back(b);
    bit[1].push_back(b);
  }
  vector<int> run[2];
  for(int i = 0; i < M; i++){
    int p; cin >> p;
    for(int j = 0; j < p; j++)
      run[0].push_back(i%2), run[1].push_back(!(i%2));    
  }
  int ans = 100;
  for(int i = 0; i < 2; i++){
    int cnt = 0;
    for(int j = 0; j < N; j++){
      if(bit[i][j] == run[i][j]) continue;
      int pos = j;
      while(pos < N && bit[i][j] == bit[i][pos]) pos++;
      if(pos == N){ cnt = 100; break; }
      for(int k = pos; k > j; k--) swap(bit[i][k], bit[i][k-1]), cnt++;      
    }
    ans = min(ans, cnt);
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 1216
#include <stdio.h>
int main (void){
int a;
int b[10000];
int c=1;
for(a=1; a<=10000;a++ ){
        scanf("%d",&b[a]);
if (b[a]==0)break;
c++;
          }
for(a=1; a<=10000;a++ ){
printf ("Case %d: %d\n",a,b[a]);
if (a==c-1)break;                  }
return 0 ;
}

Measured memory_bytes: 632
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <algorithm>
#include <cmath>

using namespace std;

#define mp make_pair
#define pb push_back
#define ll long long

const int maxN = 300011;

int n, i, ans;
char s[maxN];
int  le[maxN], ri[maxN];

int main()
{
    //freopen("test.in","r",stdin);

    scanf("%d\n%s", &n, s + 1);

    for (i = 1; i <= n; i++)
        le[i] = le[i - 1] + (s[i] == 'E' ? 0 : 1);

    for (i = n; i >= 1; i--)
        ri[i] = ri[i + 1] + (s[i] == 'W' ? 0 : 1);
    
    ans = n;
    for (i = 1; i <= n; i++)
        ans = min(ans, le[i - 1] + ri[i + 1]);

    printf("%d", ans);


    return 0;
}


Measured memory_bytes: 2944
#include <stdio.h>
#include <string.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdlib.h>
#include <limits.h>
#include <math.h>
int acs(const void *a, const void *b) { return *(int *)a - *(int *)b; }                            /* 1,2,3,4.. */
int des(const void *a, const void *b) { return *(int *)b - *(int *)a; }                            /* 8,7,6,5.. */
int cmp_char(const void *a, const void *b) { return *(char *)a - *(char *)b; }                     /* a,b,c,d.. */
int cmp_str(const void *a, const void *b) { return strcmp(*(const char **)a, *(const char **)b); } /* aaa,aab.. */
#define min(a, b) (a < b ? a : b)
#define max(a, b) (a > b ? a : b)
#define rep(i, l, r) for (int i = l; i < r; i++)
#define MAX 100001
#define MOD 1000000007

typedef long long int lli;

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

  long double x, ans = 0;
  char u[5];
  rep(i, 0, n)
  {
    scanf("%Lf %s", &x, u);
    if (strcmp(u, "JPY") == 0)
      ans += x;
    else
      ans += 380000.0 * x;
  }
  printf("%.5Lf\n", ans);
  return 0;
}


Measured memory_bytes: 256
h,w=map(int,input().split())
grid=[[1 if s=='#' else 0 for s in list(input())] for i in range(h)]
#print(grid)
maxi=10**5
from collections import deque
visited=[[maxi]*w for _ in range(h)]
def bfs(s):
    q=deque()
    q.append(s)
    visited[s[0]][s[1]]=grid[s[0]][s[1]]
    for r in range(h):
        for c in range(w):
            if r>=1:
                visited[r][c]=min(visited[r][c],visited[r-1][c]+grid[r][c])
                if grid[r-1][c]==1:
                    visited[r][c]=min(visited[r][c],visited[r-1][c])
            if c>=1:
                visited[r][c]=min(visited[r][c],visited[r][c-1]+grid[r][c])
                if grid[r][c-1]==1:
                    visited[r][c]=min(visited[r][c],visited[r][c-1])
            

bfs([0,0])
print(visited[-1][-1])

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

int gcd(int p, int q){
  if(p%q==0)return q;
  return gcd(q, p%q);
}

int main(){
  int k, sum=0;
  cin >> k;
  rep(i, k){
    rep(j, k){
      rep(l, k){
        sum+=gcd(gcd(i+1, j+1), l+1);
      }
    }
  }

  cout << sum << endl;

  return 0;
}

Measured memory_bytes: 3624
s=input()
a_count=[0]
c_count=[0]
q_lcount=[0]
q_rcount=[0]
n=len(s)
for i in range(n):
    if s[i]=='A':
        a_count.append(a_count[i]+1)
        q_lcount.append(q_lcount[i])
    elif s[i]=='?':
        a_count.append(a_count[i])
        q_lcount.append(q_lcount[i]+1)
    else:
        a_count.append(a_count[i])
        q_lcount.append(q_lcount[i])
    if s[n-1-i]=='C':
        c_count.append(c_count[i]+1)
        q_rcount.append(q_rcount[i])
    elif s[n-1-i]=='?':
        c_count.append(c_count[i])
        q_rcount.append(q_rcount[i]+1)
    else:
        c_count.append(c_count[i])
        q_rcount.append(q_rcount[i])
q=q_lcount[n]
ans=0
INF=10**9+7
a=3**q
b=a//3
c=b//3
d=c//3
a=a%INF
b=b%INF
c=c%INF
d=d%INF
for i in range(n):
    if s[i]=='B':
        x=a_count[i]*c_count[n-1-i]*a
        y=a_count[i]*q_rcount[n-1-i]*b
        z=q_lcount[i]*c_count[n-1-i]*b
        w=q_lcount[i]*q_rcount[n-1-i]*c
        ans=(ans+x+y+z+w)%INF
    elif s[i]=='?':
        x=a_count[i]*c_count[n-1-i]*b
        y=a_count[i]*q_rcount[n-1-i]*c
        z=q_lcount[i]*c_count[n-1-i]*c
        w=q_lcount[i]*q_rcount[n-1-i]*d
        ans=(ans+x+y+z+w)%INF
print(int(ans))


Measured memory_bytes: 69360
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repp(i, a, b) for (int i = a; i <= (b); ++i)
#define repr(i, a, b) for (int i = a; i >= (b); --i)
typedef long long ll;
const int INF = 1001001001;
const ll LINF = 1001001001001001001ll;
const int MOD = 1e9 + 7;

int main() {
  int A, B, T;
  cin >> A >> B >> T;
  cout << T/A*B << endl;
  
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <bitset>
#include <math.h>
#include <iomanip>
#include <queue>
#define inp(X) cin >> X
#define out(X) cout << X << endl
#define out16(X) cout << setprecision(16) << X << endl
#define rep(i,n) for(int i=0;i<n;i++ )
#define rep2(i,f,n) for(int i=f;i<n;i++ )
#define MAX(A) *max_element(A.begin(),A.end())
#define MIN(A) *min_element(A.begin(),A.end())
#define SORT(A) sort(A.begin(),A.end())
#define REV(A) reverse(A.begin(),A.end())
typedef long long int ll;
using vi = std::vector<int>;
using vvi = std::vector<std::vector<int>>;
using vd = std::vector<double>;
using vvd = std::vector<std::vector<double>>;
using vll = std::vector<ll>;
using vvll = std::vector<std::vector<ll>>;
using namespace std;
#define MOD 1000000007
#define INF 1000000001
#define LL_INF 1001001001001001001

ll gcd(ll x, ll y){
	if(y==0) return x;
	return gcd(y,x%y);
}

bool bfs(vector<vector<int>> g, vector<int> &dist, int sv){
	queue<int> q;
	q.push(sv);
	dist[sv]=0;
	while(!q.empty()){
		int now = q.front(); q.pop();
		for(auto v : g[now]){
			if(dist[v]!=-1) continue;
			dist[v] = dist[now]+1;
			q.push(v);
		}
	}
}

int main(void) {
	string s; cin >> s;
	int n = int(s.size());

	int ans = 0;
	rep(i,n/2){
		if(s[i]!=s[n-i-1]) ans++;
	}
	out(ans);
}




Measured memory_bytes: 256
#include <bits/stdc++.h>
#define endl "\n"
#define ll long long int
#define mod 1000000007
#define mem(a,val) memset(a,val,sizeof(a))

using namespace std;
int main()
{
	std::ios::sync_with_stdio(false);
	int n;
	cin>>n;
	string s;
	cin>>s;
	vector<int> r,g,b;
	map<int,int> m;
	for(int i=0;i<n;i++){
		if(s[i] == 'R'){
			r.push_back(i);
		}else
		if(s[i] == 'G'){
			g.push_back(i);
		}else{
			b.push_back(i);
			m[i]++;
		}
	}
	ll ans = r.size()*g.size()*b.size();
	
	for(int i=0;i<r.size();i++){
		for(int j=0;j<g.size();j++){
			int mn = min(r[i],g[j]);
			int mx = max(r[i],g[j]);
			int num = mx-mn;
			if(num%2 == 0){
				if(m[mn+(num/2)]>0)ans--;
			}
			if(m[mx+num]>0)ans--;
			if(m[mn-num]>0)ans--;
		}
	}
	cout<<ans;
	return 0;
}


Measured memory_bytes: 4168
#include<iostream>
#include<math.h>
#include<algorithm>
#include<stdint.h>
#include<vector>
#include<deque>
#include<stack>
#include<functional>
#include<string>
#include<cstring>
#include<time.h>
#include<array>
#include<iomanip>
#include<list>
#include<set>
#include<map>
#include<random>
#include<unordered_map>
#include<unordered_set>
#include<bitset>
#include <queue>


using namespace std;
using ll = long long;
using ull = unsigned long long;
using uint = unsigned int;
using ldouble = long double;


//BDD,ZDD,kdtree, bdtree,bicalc, bolonoy, doloney, tree, chinesemod,segmenttree,daikusutora, saidairyuu, 2bugurahu, heirokenshutu, topologicalsort, kyourenketuseibun

#define REP(i,a,b) for(int i = a; i < b; ++i)
#define PRI(s) cout << s << endl
#define PRIY PRI("Yes")
#define PRIN PRI("No")


ll N,M;
vector<ll> A;
vector<ll> S;

pair<ll,ll> f(ll x) {
	ll ans = 0, tot = 0;
	for (ll a : A) {
		auto itr = lower_bound(A.begin(), A.end(), x - a);
		ll d = distance(A.begin(), itr);
		ll c = A.size() - d;
		tot += S[A.size()] - S[d];
		tot += a * c;
		ans += c;
	}
	return pair<ll, ll>(tot, ans);
}

ll bins(ll m) {
	ll l = 0;
	ll r = 10000000;
	while (r - l > 1) {
		ll mid = (r + l) / 2;
		ll tmp = f(mid).second;
		if (tmp >= m) l = mid;
		else r = mid;
	}
	return l;
}

ll solve(ll L) {
	auto p = f(L);
	ll ans = p.first;
	ans -= (p.second - M) * L;
	return ans;
}

int main() {
	cin >> N >> M;
	A.resize(N);
	REP(i, 0, N)cin >> A[i];
	sort(A.begin(), A.end());
	S.resize(N + 1);
	S[0] = 0;
	REP(i, 0, N) S[i + 1] = S[i] + A[i];

	PRI(solve(bins(M)));
	return 0;
}




Measured memory_bytes: 4816
#include <bits/stdc++.h>
using namespace std;
int main(){
	string a;
	cin>>a;
	int longest=0,cnt=0;
	for(int i=0;i<a.size();i++){
		if(i==a.size()-1 and (a[i]=='A' or a[i]=='C' or a[i]=='G' or a[i]=='T')){
			cnt++;
			longest=max(cnt,longest);
		}
		if(a[i]=='A' or a[i]=='C' or a[i]=='G' or a[i]=='T'){
			cnt++;
		}
		else{
			longest=max(cnt,longest);
			cnt=0;
		}
	}
	cout<<longest;
}
//FELAROSSO

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


void solve()
{int a,b;
 cin>>a>>b;
 int ans=a*b;
 cout<<ans<<endl;
}

int main()
{
 int t=1;
  //  cin>>t; 
    
    while(t--)
     solve();   
    
}

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

#define MOD 1000000007

int dp[305][305][305];
vector<pair<int, int>> q[305];
bool isValid[305][305][305];

int main(){
    int N, M;
    scanf("%d%d", &N, &M);
    for(int i=0; i<M; i++){
        int l, r, x;
        scanf("%d%d%d", &l, &r, &x);
        q[r].push_back({l, x});
    }

    // Check Validity
    for(int r=0; r<=N; r++){
        for(int g=0; g<=N; g++){
            if(r == g && r) continue;
            for(int b=0; b<=N; b++){
                if(b && (b == r || b == g)) continue;
                int mx = max(r, max(g, b));
                isValid[r][g][b] = true;
                for(auto p : q[mx]){
                    int cnt = 0;
                    cnt += (r >= p.first);
                    cnt += (g >= p.first);
                    cnt += (b >= p.first);
                    if(cnt != p.second){
                        isValid[r][g][b] = false;
                        break;
                    }
                }

            }
        }
    }

    // Run DP
    int res = 0;
    dp[0][0][0] = 1;
    for(int r=0; r<=N; r++){
        for(int g=0; g<=N; g++){
            for(int b=0; b<=N; b++){
                if(!isValid[r][g][b]) dp[r][g][b] = 0;
                int mx = max(r, max(g, b));
                if(mx == N){
                    res += dp[r][g][b];
                    res %= MOD;
                    continue;
                }
                dp[mx+1][g][b] += dp[r][g][b], dp[mx+1][g][b] %= MOD;
                dp[r][mx+1][b] += dp[r][g][b], dp[r][mx+1][b] %= MOD;
                dp[r][g][mx+1] += dp[r][g][b], dp[r][g][mx+1] %= MOD;
            }
        }
    }

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


Measured memory_bytes: 137472
c,d;
long s,t,u;
main()
{
	c=getchar_unlocked();
	while(c-10)
	{
		t+=1;
		d=getchar_unlocked();
		if(c-d)
		{
			s+=t*(t+1)/2;
			if(c=='>')s-=t<u?t:u;
			u=t;
			t=0;
			c=d;
		}
	}
	printf("%ld",s);
}

Measured memory_bytes: 128
#include<iostream>
#include<algorithm>
#include<cstring>
using namespace std;
#define INF 1000000000;
int n,h[1000005],mem[100005];
int dp(int i){
  if(i==1) return 0;
  if(i<1) return INF;
  if(mem[i]!=-1) return mem[i];
  int a1=dp(i-1)+abs(h[i-1]-h[i]);
  int a2=dp(i-2)+abs(h[i-2]-h[i]);
  return mem[i]=min(a1,a2);
}
int main(){
  int n;
  cin >>n;
  memset(mem,-1,sizeof(mem));
  for(int i=1; i<=n; i++){
    cin>>h[i];
  }
  cout<<dp(n)<<'\n';
  return(0);
}


Measured memory_bytes: 4224
#include <bits/stdc++.h>
using namespace std;
#define lp(i,n) for(int i=0;i<n;i++)
#define fordebug int hoge;cin>>hoge;
int main(){
  int n;
  cin>>n;
  long long a=3,count=1;
  while(1){
    if(a>=n) break;
    a*=3;
    count++;
  }
  cout<<count<<endl;
  
  return 0;
}



Measured memory_bytes: 3104
#include<bits/stdc++.h>
#include<boost/range/irange.hpp>
#include<boost/multiprecision/cpp_int.hpp>
#include<boost/algorithm/string/classification.hpp>
#include<boost/algorithm/string/split.hpp>
#include<boost/algorithm/string/join.hpp>
#include<boost/algorithm/string/replace.hpp>
#include<boost/math/tools/minima.hpp>
#include<boost/pending/disjoint_sets.hpp>
using namespace std;
using boost::irange;
using boost::multiprecision::cpp_int;
using boost::algorithm::split;
using boost::is_any_of;
using boost::algorithm::join;
using boost::algorithm::replace_all;
using boost::math::tools::brent_find_minima;
typedef long long ll;
ll max(ll a, ll b){ 
	if(a >= b) return a;
	else if(a < b) return b;
}
int main(){
    vector<ll>a(1e6+10, 0);
    int n; cin >> n;
    for(int i = 0; i < n; i++){
        ll temp; cin >> temp;
        a[temp] += 1;
    }
    int flg = 0;
    if(n%2 != 0){
        if(a[0] != 1)flg = 1; 
        for(int i = 2; i <= 2*(n/2); i+=2){
            if(a[i] != 2) flg  = 1;
        }
    }else{
        for(int i = 1; i <= n/2 - 1; i+= 2){
            if(a[i] != 2) flg  = 1;
        }
    }

    ll ans = 0;
   // cout << "flg "<< flg << endl;
    if(flg != 1){
        ans = 1;
        for(int i = 0; i < n/2; i++){
            ans *= 2;
            ans %= (ll)(1e9+7);
            //cout << "flg "<< flg << endl;
        }
    }
    cout << ans << endl;
}   



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

#define rep(i,n) for(int i=0;i<n;i++)
#define r_rep(i,n) for(int i=n-1;i>=0;i--)
#define ll long long

int main(){
    int n,h[100010],x[100010];
    cin>>n;
    rep(i,n) cin>>h[i];
    x[0]=0;
    rep(i,n-1){
        if(h[i]<h[i+1]) x[i+1]=0;
        else x[i+1]=x[i]+1;
    }
    int m=0;
    rep(i,n) m=max(m,x[i]);
    cout<<m<<endl;
}

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

int main() {
  int A,B,N;
  cin >>N;
  vector<long long>a(N);
  for(int i=0;i<N;i++){
    cin>>a[i];
  }
  sort(a.begin(),a.end());
  for(int i=1;i<N;i++){
    if(a[i-1]==a[i]){
      cout<<"NO"<<endl;
      return 0;
    }
  }
  cout <<"YES"<< endl;
}


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

int n, t;
vector<pair<int, int>> AB;
vector<int> dp;

void input() {
    cin >> n >> t;
    AB = vector<pair<int, int>>(n);
    rep(i, n) cin >> AB[i].first >> AB[i].second;
}

int main() {
    input();
    sort(AB.begin(), AB.end());
    dp = vector<int>(t+1);
    int best = 0;
    rep(i, n) {
        best = max(best, dp[t-1] + AB[i].second);
        for (int j = t - 1; j >= AB[i].first; j--) {
            dp[j] = max(dp[j], dp[j-AB[i].first] + AB[i].second);
        }
    }
    cout << best << endl;
}


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

using namespace std;
using ll =long long;
using vi = vector<int>; 
using vvi = vector<vi>; 
using vl = vector<ll>; 
using vvl = vector<vl>; 
using vs = vector<string>;
using vvs = vector<vs>; 
using vc = vector<char>;
using vvc = vector<vc>; 
using vb = vector<bool>;
using vvb = vector<vb>; 

template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
const long long INF = 1LL << 60;

#define rep(i,n) ;for( int i =0; i < n ; i ++)
#define all(a) a.begin(),a.end()
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define fr(i,a,b) for(int i=a;i<b;i++)
#define pri(a)  printf("%.14lf\n",a);
#define MOD 1000000007
bool is_int_lround(double x){
  return std::lround(x)==x;
}
ll keta(ll x){
  ll n=0;
  while(x>0){
    x /=10 ;
    n ++;
  }
  return n;
}

ll conbi(int n,int m){
  
  cin>>n>>m;
  vector<ll> a(100);
  a[0] =1;
  for(int i=0;i<14;i++){
    a[i+1]=a[i]*(i+1);
  }
  return a[n] /(a[m] *a[n-m]);
}

long long modpow(long long a, long long n, long long mod) {
    long long res = 1;//繰り返し二乗法
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
ll kaijo(ll x){
  ll z=1;
  if(x==0){
    return 1;
  }
  while(x>0){
    z *=x;
    z %=MOD;
    x--;
  }
  return z;
}
ll yakusu_num(ll n){
  vl yakusu(n+1,1);
  for(ll i=2;i*i<=n;i++){ 
    while(n%i==0){
      n /=i;
      yakusu[i]++;
    }
  }
  if(n!=1)yakusu[n]++;
  ll num=1;
  for(ll i=0;i <=n;i++){
    num*=yakusu[i];
  }
  return num;
}


//cout<<""<<endl;
int main(){
  ll N;cin>>N;vl A(N);
  ll ans=0;
  rep(i,N)cin>>A[i];
  rep(i,N-1){
    if(A[i+1]<A[i]){
      ans+=A[i]-A[i+1];
      A[i+1]=A[i];
    }
  }
cout<<ans<<endl;  
}





Measured memory_bytes: 4748
N = int(input())
S = str(input())
K = int(input())
target_char = S[K-1]
ans = []
for i in range(N):
    if S[i] != target_char:
        ans.append("*")
    else:
        ans.append(target_char)
ans2 = ""
for i in range(N):
    ans2 += ans[i]
print(ans2)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
int a[11];
bool isvalid(int x){
    while(x>0){
    int dig=x%10;
    if(a[dig])
        return false;
    x/=10;
  }
  return true;
}
int main()
{
    //freopen("i.txt","r",stdin);
    int b,n,k;
    cin>>n>>k;
    for(int i=0;i<k;i++){
        cin>>b;
        a[b]++;
    }
    int j=n,f=0;
    while(1){
        if(isvalid(j)){
            break;
        }
        j++;
    }
    cout<<j<<endl;
    return 0;
}


Measured memory_bytes: 3548
#include <stdio.h>
  
int main(void){
    int d[26]={0};
    char w[101];
    scanf("%s",w);

    for(int i=0;w[i];i++){
        d[w[i]-'a']++;
    }
    int result=1;
    for(int i=0;i<26;i++){
        if(d[i]%2){result=0;}
    }
    printf("%s\n",(result)?"Yes":"No");
    return 0;
}

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

#define _p(...) (void)printf(__VA_ARGS__)
#define forr(x,arr) for(auto&& x:arr)
#define _overload3(_1,_2,_3,name,...) name
#define _rep2(i,n) _rep3(i,0,n)
#define _rep3(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,_rep3,_rep2,)(__VA_ARGS__)
#define _rrep2(i,n) _rrep3(i,0,n)
#define _rrep3(i,a,b) for(int i=int(b)-1;i>=int(a);i--)
#define rrep(...) _overload3(__VA_ARGS__,_rrep3,_rrep2,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define bit(n) (1LL<<(n))
#define sz(x) ((int)(x).size())
#define ten(n) ((int)1e##n)
#define fst first
#define snd second
using ll=long long;
using pii=pair<int,int>;using pll=pair<ll,ll>;using pil=pair<int,ll>;using pli=pair<ll,int>;
using vs=vector<string>;using vvs=vector<vs>;using vvvs=vector<vvs>;
using vb=vector<bool>;using vvb=vector<vb>;using vvvb=vector<vvb>;
using vi=vector<int>;using vvi=vector<vi>;using vvvi=vector<vvi>;
using vl=vector<ll>;using vvl=vector<vl>;using vvvl=vector<vvl>;
using vd=vector<double>;using vvd=vector<vd>;using vvvd=vector<vvd>;
using vpii=vector<pii>;using vvpii=vector<vpii>;using vvvpii=vector<vvpii>;
template<class T> bool amax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> bool amin(T &a, const T &b) { if (b < a) { a = b; return 1; } return 0; }
ll ri(){ll l;cin>>l;return l;} string rs(){string s;cin>>s;return s;}
template<class T>T read(){T t;cin>>t;return t;}
template<class T,class U>ostream&operator<<(ostream&o,const pair<T,U>&p){return o<<'('<<p.fst<<", "<<p.snd<<')';}
ostream&operator<<(ostream&o,const vb&t){forr(e,t)o<<"#."[e];return o;}
template<class T>ostream&operator<<(ostream&o,const vector<T>&t){o<<"{";forr(e,t)o<<e<<",";o<<"}"<<endl;return o;}
#ifdef LOCAL
vs s_p_l_i_t(const string&s,char c){vs v;stringstream ss(s);string x;while(getline(ss,x,c))v.emplace_back(x);return move(v);}
void e_r_r(vs::iterator it){cerr<<endl;}
template<class T,class... Args>void e_r_r(vs::iterator it,T a,Args... args){cerr<<it->substr((*it)[0]==' ',it->length())<<" = "<<a<<", ";e_r_r(++it,args...);}
#define out(args...){vs a_r_g_s=s_p_l_i_t(#args,',');e_r_r(a_r_g_s.begin(),args);}
#else
#define out(args...)
#endif

ll solve() {
  int n = ri();
  ll k = ri();
  vpii A(n);

  rep(i, n) {
    A[i].fst = ri();
    A[i].snd = ri();
  }

  sort(all(A));

  ll s = 0;
  forr(a, A) {
    int x = a.fst;
    int c = a.snd;
    s += c;
    if (k <= s) {
      return x;
    }
  }
  assert(false);
}

void Main() {
  cout << solve() << endl;
}

int main() { cin.tie(nullptr); ios::sync_with_stdio(false); Main(); return 0; }


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

int main(){
  long long N,h,l;
  cin>>N;
  long long A[N];
  for(int i=0;i<N;i++){
    cin>>A[i];
  }
  h=A[0],l=A[0];
  for(int i=1;i<N;i++){
    h=max(h,A[i]);
    l=min(l,A[i]);
  }
  cout<<h-l<<endl;
}

Measured memory_bytes: 256
package main

import (
	"fmt"
	"math"
)

func main() {
	var n, d int
	fmt.Scan(&n, &d)
	cordinates := ScanCordinates(n, d)
	ans := 0
	for i := 0; i < len(cordinates)-1; i++ {
		for j := i + 1; j < len(cordinates); j++ {
			n := 0.0
			for k := 0; k < d; k++ {
				n += math.Pow(math.Abs(float64(cordinates[i][k]-cordinates[j][k])), 2)
			}
			if math.Sqrt(n) == math.Trunc(math.Sqrt(n)) {
				ans++
			}
		}
	}
	fmt.Println(ans)
}

func ScanCordinates(n int, d int) (cordinates [][]int) {
	for i := 0; i < n; i++ {
		cordinates = append(cordinates, ScanNums(d))
	}
	return cordinates
}

func ScanNums(len int) (nums []int) {
	var num int
	for i := 0; i < len; i++ {
		fmt.Scan(&num)
		nums = append(nums, num)
	}
	return
}


Measured memory_bytes: 1848
#include<bits/stdc++.h>
using namespace std;
const long long mod=1000000000+7;
const long long INF=-mod;

//マクロ
//型エイリアス
using ll = long long;
using P=pair<long long,long long>;
using vl=vector<long long>;
//ショートカット
#define rep(i,n) for(int i=0;i<n;i++)
#define rep2(i,k,n) for(int i=k;i<n;i++) //半開区間
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(),v.rend()
#define pb push_back
//入力
#define vin(v,N) for(long long i=0;i<N;i++) cin>>v.at(i)
#define lin(n) long long n;cin>>n
#define vlin(v,N) vector<long long>v(N);for(long long i=0;i<N;i++)cin>>v.at(i)

#define max(a,b) max((ll)a,(ll)b)
#define min(a,b) min((ll)a,(ll)b)

//関数
//最大公約数
long long gcd(long long m, long long n){
  long long a=max(m,n);
  long long b=min(m,n);
  long long r=a%b;
  while(r!=0){
    a=b; b=r; r=a%b;
  }
  return b;
}
// 最小公倍数
long long lcd(long long m, long long n){
  return m*n/gcd(m,n);
}
//xのn乗
long long power(long long x, long long N){
  long long ret=1;
  for(long long i=0;i<N;i++)   
    ret*=x;
  return ret;
}
//nCr
long long Comb (long long n, long long r);
//nCr (mod)
long long modC(long long n, long long r) {
    vector<long long> f(n+1),inv(n+1),invf(n+1);
    f[0]=f[1]=1;
    invf[0]=invf[1]=1;
    inv[1]=1;
    for (long long i=2;i<n+1;i++) {
        f[i]=(i*f[i-1])%mod;
        inv[i]=mod-((mod/i)*inv[mod%i])%mod;
        invf[i]=(inv[i]*invf[i-1])%mod;
    }
    long long cmb=f[n]*(invf[r]*invf[n-r]%mod)%mod;
    if (n>=r) return cmb;
    else return 0;
}
//素因数分解(mapで返す)
map<long long,long long> factor(long long p){
  ll p1=p;
  map<long long,long long>ret;
  for(long long i=2;i*i<=p1;i++){
     while(p%i==0){
      ret[i]++;
      p/=i;
    }
  }
  if(p!=1)
  ret[p]++;
  return ret;
}
//素数判定
bool is_prime(long long N){
  for(long long i=2;i*i<=N;i++){
    if(N%i==0)
      return false;
  }
  return true;
}
//最大値更新
void chmax(long long &a,long long b){
  a=max(a,b);
}
//最小値更新
void chmin(long long &a,long long b){
  a=min(a,b);
}

//メイン関数
int main(){
  //doubleの桁数
  cout<<fixed<<setprecision(10);
  
  lin(H);
  ll res=0;

  ll  i=0;
  while(H!=0){
    H/=2;
    i++;
  }
  
  cout<<power((ll)2,i)-1;
}

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

//#define endl '\n'
#define fi first
#define se second
#define MOD(n,k) ( ( ((n) % (k)) + (k) ) % (k))
#define forn(i,n) for (int i = 0; i < n; i++)
#define forr(i,a,b) for (int i = a; i <= b; i++)
#define all(v) v.begin(), v.end()
#define pb(x) push_back(x)

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ii> vii;

const int MX = 200005;
int n, a[MX];
ll mem[MX][5];

ll dp (int i, int k) {
	if (k < 0) return -1e18;
	if (i >= n) {
		if (k == 2) return -1e18;
		return 0;
	}

	ll &res = mem[i][k];
	if (res != -1) return res;

	return res = max(
		dp(i + 1, k - 1),
		dp(i + 2, k) + a[i]
	);
}

int main () {
	ios_base::sync_with_stdio(0); cin.tie(0);
	memset(mem, -1, sizeof(mem));

	cin >> n;
	forn (i, n) cin >> a[i];
	cout << dp(0, 1 + n % 2) << endl;

	return 0;
}

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

using namespace std;

int main() {
  int N;
  cin >> N;
  vector<int> cs(N + 1);
  vector<int> ss(N + 1);
  vector<int> fs(N + 1);

  for(int i = 1; i < N; ++i) {
    cin >> cs[i] >> ss[i] >> fs[i];
  }
  vector<int> ans(N + 1);
  for(int i = 1; i < N; ++i) {
    int time = 0;
    for(int j = i; j < N; ++j) {
      if(time <= ss[j]) { // 出発前だったら出発前まで待つ
        time = ss[j];
      } else {
        if(time % fs[j] != 0) {
          time = (time / fs[j] + 1) * fs[j];
        }
      }
      time += cs[j];
    }
    ans[i] = time;
  }
  for(int i = 1; i < N; ++i) {
    cout << ans[i] << endl;
  }
  cout << 0 << endl;
  return 0;
}

Measured memory_bytes: 256
h,w=map(int,input().split())
n=int(input())
a=[int(i) for i in input().split()]
f=0
d=[]
for i in range(n):
  for j in range(a[i]):
    d.append(i+1)
    if len(d)==w and f:
      print(*d[::-1])
      f=0
      d=[]
    elif len(d)==w:
      print(*d)
      f=1
      d=[]

Measured memory_bytes: 42096
import numpy as np

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

ans=0

if x>=a*a*b/2:
	ans=np.arctan((2*b)/a-(2*x)/(a**3))
	
else:
	ans=np.arctan((a*b*b)/(2*x))

	
	
print(np.rad2deg(ans))

Measured memory_bytes: 12484
from sys import stdin


def main():
    A, B = [int(x) for x in stdin.readline().rstrip().split()]
    ans = A
    sum_ = 1

    while True:
        if B == 1:
            sum_ = 0
            break

        if ans >= B:
            break

        sum_ += 1

        ans = ans - 1 + A

    print(sum_)


if __name__ == "__main__":
    main()


Measured memory_bytes: 2940
#include <iostream>

using namespace std;
int main(void){
	int n;
	cin >> n;
	int count=0;
	for(int i=9; count<2 && i>1; i--){
		while(count <2 && n%i==0){
			n/=i;
			count++;
		}
	}
	if(n==1)cout << "Yes" << endl;
	else cout << "No" << endl;
}

Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
#define rep(i,a) for(int i = 0; i < (a); i++)
bool prime[10002];
int field[256][256];
int dx[] = {1,1,1,0}, dy[] = {-1,1,0,1};
int n;
int func(int x, int y, int k) {
	int cnt = 0;
	while(1) {
		if(x < 0 || x >= n || y < 0 || y >= n) break;
		if(field[y][x] == 0) break;
		x += dx[k], y+= dy[k];
		cnt += 1;
	}
	return cnt;
}
int main() {
	while(cin >> n,n) {
		rep(i,n){
			string str;
			cin >> str;
			rep(j, str.size()){
				field[i][j] = str[j] - '0';
			}
		}
		int ans = 0;
		rep(i, n) {
			rep(j, n) {
				if(field[i][j] == 0) continue;
				rep(k, 4) {
					ans = max(func(j,i,k),ans);
				}
			}
		}
		cout << ans << endl;
	}

	return 0;
}

Measured memory_bytes: 1464
def main():
    H, N = map(int, input().split())
    AB = [list(map(int, input().split())) for _ in range(N)]

    dp = [[100000000]*(10000*2)]*(N+1)
    dp[0][0] = 0

    for i in range(0, N):
        for h in range(0, H+1):
            dp[i+1][h] = min(dp[i+1][h], dp[i][h])
            dp[i+1][min(h+AB[i][0], H)] = min(dp[i+1][min(h+AB[i][0], H)], dp[i+1][h]+AB[i][1])

    ans = {}
    for i in range(N):
        ans[i] = dp[i][H]
    print(min(ans.values()))
    
if __name__ == "__main__":
    main()

Measured memory_bytes: 41328
n = int(input())
prev = [0, [0, 0]]  # [t, [x, y]]
for i in range(n):
    # print(prev)
    t, x, y = [int(i) for i in input().split()]
    left = (t - prev[0]) - (abs(x - prev[1][0]) + abs(y - prev[1][1]))
    # print("left:{}".format(left))
    if left >= 0 and left % 2 == 0:
        prev = [t, [x, y]]
    else:
        print("No")
        exit()
print("Yes")


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define pp pair<int,int>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ll long long
#define ld long double
#define all(a) (a).begin(),(a).end()
#define mk make_pair
ll MOD=1000000007;
ll mod=998244353;
int inf=1000001000;
ll INF=1e18+5;

int main() {
    int a,b;
    cin >> a >> b;
    if (a!=1 && b!=1) cout << 1 << endl;
    if (a!=2 && b!=2) cout << 2 << endl;
    if (a!=3 && b!=3) cout << 3 << endl;
}


Measured memory_bytes: 256