akhauriyash/Code-Regression huggingface dataset:
from collections import deque

h, w = map(int, input().split())
s = [input() for i in range(h)]

visited = [[0] * w for i in range(h)]

inf = 10 * w * h
dist = [[inf] * w for i in range(h)]

que = deque([(0, 0)])
visited[0][0] = 1
dist[0][0] = 0

dx = (1, -1, 0, 0)
dy = (0, 0, 1, -1)

while len(que) > 0:
    x, y = que.popleft()
    
    if x == w - 1 and y == h - 1:
        break
    
    for k in range(4):
        nx = x + dx[k]
        ny = y + dy[k]
        
        if 0 <= nx < w and 0 <= ny < h and s[ny][nx] == '.' and visited[ny][nx] == 0:
            que.append((nx, ny))
            visited[ny][nx] = 1
            dist[ny][nx] = dist[y][x] + 1

if dist[h - 1][w - 1] == inf:
    print(-1)
else:
    print(sum(s[i].count('.') for i in range(h)) - (dist[h - 1][w - 1] + 1))

Measured memory_bytes: 3440
#include<bits/stdc++.h>
using namespace std;
#define V vector
#define L long long
#define W V<L>
#define R(n) for(L i=0;i<n;i++)
W S(V<W>p,L E){if(!E){return{1,0};}V<V<W>>T(2);for(W x:p){T[x[1]&1].push_back({x[0]/2,x[1]/2});if(x[0]&1){T[(x[1]+1)&1].push_back({x[0]/2,(x[1]+1)/2});}}R(2){L c=0;for(W x:T[!i]){L Q=(2*x[0]+x[1])%3;c^=Q+1;}if(!c){W A=S(T[i],E-1);A[0]*=2;A[1]*=2;A[1]+=i;return A;}}for(W&v:p){v[0]++;}W A=S(p,E);A[0]--;return A;}
int main(){L M=2e17,n;cin>>n;V<W>p(n);R(n){L a,b;cin>>a>>b;p[i]={a+M,b+M};}cout<<S(p,70)[0]-M<<" "<<S(p,70)[1]-M;}

Measured memory_bytes: 68656
#include "bits/stdc++.h"

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define bit(n) (1LL << (n))
#define sz(x) ((int)(x).size())
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
#define en '\n'
#define pb push_back
#define mp make_pair
#define P pair<int, int>

typedef long long ll;
using namespace std;

ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { ll g = gcd(a, b); return a / g * b; }
const int dx[4] = { 1, 0, -1,  0 };
const int dy[4] = { 0, 1,  0, -1 };
const int INF = (int)1e9;
const ll  inf = (ll)1e18;
const int mod = 1000000007;

struct aaa {
	aaa() {
		cin.tie(0);
		ios::sync_with_stdio(0);
		cout << fixed << setprecision(20);
	};
}aaaaa;

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

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
int f() {
    return 0;
}

int main() {
  int N, K;
  scanf("%d", &N);
  scanf("%d", &K);
  int ans = 0;
  for(int i = 0; i < N; i++) {
    int *ptr = (int *)malloc(sizeof(int *));
    scanf("%d ", ptr);
    int tmp = (K - (*ptr));
    int a = (tmp > 0 ? tmp : (-tmp))*2;
    int b = (*ptr)*2;
    ans += (a > b ? b : a);
  }
  printf("%d\n", ans);
  return 0;
}

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

using ll = long long;
#define rep(i, n) for (long long i = 0; i < (n); ++i)
#define repr(i, a, b) for (auto i = (a); i < (b); ++i)
#define itr(x) for (auto&& v : (x))
#define updatemax(t, v) ((t) = std::max((t), (v)))
#define updatemin(t, v) ((t) = std::min((t), (v)))

int main() {
  string s;
  cin >> s;
  rep(i, s.size()) cout << 'x';
  cout << endl;
}


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

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

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

const int MAX = 1e5 + 5;
const int INF = 1001001001;
const int MOD = 1e9 + 7;

int main(){
    string S, T;
    cin >> S >> T;

    cout << T << S << endl;
}

Measured memory_bytes: 256
import java.math.BigInteger;
import java.util.*;

public class Main {
	
	private void doit(){
		Scanner sc = new Scanner(System.in);
		while(sc.hasNext()){
			int n = sc.nextInt();
			String s = sc.next();
			int b = 0;
			int r = 0;
			for(int i = 0; i < s.length(); i++){
				if(s.charAt(i) == 'R'){
					r++;
				}
				else{
					b++;
				}
			}
			
			if(r > b){
				System.out.println("Yes");
			}
			else {
				System.out.println("No");
			}
		}
	}
	
	private long gcd(long a, long b){
		if(b == 0)  return a;
		else        return gcd(b, a%b);
	}

	private void debug(Object... o) {
		System.out.println("debug = " + Arrays.deepToString(o));
	}

	public static void main(String[] args) {
		new Main().doit();
	}

}


Measured memory_bytes: 22736
n = gets.chomp.to_i
s = gets.chomp.split('')

count_b = 0
count_e = 0

s.each do |c|
  case c
  when ')'
    if count_b.zero?
      count_e += 1
    else
      count_b -= 1
    end
  when '('
    count_b += 1
  end
end
puts '(' * count_e + s.join + ')' * count_b


Measured memory_bytes: 1788
import java.util.Scanner;

public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int[] array = new int[12];
		int j, c = 0, f = 0;
		int tmp1, tmp2, tmp3;
		for(int i = 0;i < 12;++i){
			f = 0;
			tmp1 = -1;
			tmp2 = -1;
			tmp3 = -1;
			array[i] = sc.nextInt();
			for(j = 0;j < i;++j){
				if(array[j] == array[i]){
					++f;
					if(tmp1 != -1){
						if(tmp2 != -1){
							tmp3 = j;
						}else{
							tmp2 = j;
						}
					}else{
						tmp1 = j;
					}
				}
			}
			if(f >= 3){
				++c;
				array[tmp1] = -1;
				array[tmp2] = -1;
				array[tmp3] = -1;
				array[i] = -1;
			}
		}
		System.out.println(c >= 3 ? "yes" : "no");
	}
}

Measured memory_bytes: 26228
loop do
	data = gets.to_i 
	break if data == 0
	under = Array.new(data+1){0}
	data.times do
		sum = 0
		num = gets.split(" ").map!(&:to_i)
		num.each_with_index do |x,i|
			printf "%5d",x
			sum = sum + x
			under[i] += x
		end
		under[data] += sum
		printf "%5d",sum
		puts ""
	end
	under.each do |x|
		printf "%5d",x
	end
	puts ""
end

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


using namespace std;

using ull = unsigned long long;


int main(void) {
    ull N;
    cin >> N;
    ull ans = 0;
    for (ull i = 1; i <= N; i++) {
        ull n = N / i;
        ans += ((1 + n) * i) * n / 2;
    }
    cout << ans << endl;
}


Measured memory_bytes: 3608
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>

using namespace std;

typedef long long LL;

const int inf = 1 << 26;

int n;
string s[105];
int each[1005];
int t[105][1005];

inline void quick_IO() { ios::sync_with_stdio(false); cout.tie(0); cin.tie(0); }

int main(){
	scanf("%d", &n);
	for ( int i = 0; i < n; i ++ ) cin >> s[i];
	for ( int i = 0; i < n; i ++ ) {
		for ( int j = 0; j < s[i].size(); j ++ ) {
			t[i][s[i][j]] ++;
		} 
	} 
	
	string ans = "";
	for ( int i = 0; i < 26; i ++ ) {
		int cnt = (1<<26);
		for ( int j = 0; j < n; j ++ ) {
			cnt = min(cnt, t[j][i+'a']);
		}
		for ( int j = 0; j < cnt; j ++ ) ans += (i+'a');
	}
	cout << ans << endl;
		
	return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  int N;
  cin >> N;
  vector<int64_t> A(N);
  for (int i = 0; i < N; ++i){
    cin >> A.at(i);
  }
  int64_t ans=0;
  sort(A.begin(), A.end());
  
  if(N%2==0){
  for (int i = (N/2); i <N-1 ; ++i)
    {
      ans=ans+2*A.at(i);
    }
    ans+=A.at(N-1);
  }else{
    for (int i = ((N-1)/2+1); i <N-1 ; ++i)
    {
      ans=ans+2*A.at(i);
    }
    ans=ans+A.at(N-1)+A.at((N-1)/2);
  }

  cout << ans << endl;
}




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

const int N = 1e5 + 5;

int32_t main()
{
	IOS;
	int x;
	cin >> x;
	int taken = x / 100;
	x %= 100;
	if(x <= taken * 5)
		cout << 1;
	else
		cout << 0;
	return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
#define rep(i, begin, n) for (int i = begin; i < n; i++)
#define repe(i, begin, n) for (int i = begin; i <= n; i++)
#define repr(i, begin, n) for (int i = begin; i > begin - n; i--)
#define repre(i, begin, end) for (int i = begin; i >= end; i--)

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

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

const int inf = 1000000007;
const int MOD = 1000000007;
const long long INF = 1000000000000000007;

// -------------------------------------------------------
ll N, K;
ll A[201010];
map<ll, ll> m;

ll simulate(ll n) {
  ll cur = 1;
  for (ll i = 1; i <= n; ++i) {
    cur = A[cur];
  }
  return cur;
}

int main() {
  cin >> N >> K;
  repe(i, 1, N) { cin >> A[i]; }

  repe(i, 0, N) { m[i] = INF; }

  m[1] = 0;
  ll cur = 1;
  ll firstvisit = INF;
  ll secondvisit = INF;

  for (ll i = 1; i <= 201010; ++i) {
    ll next = A[cur];
    if (m[next] == INF) {
      m[next] = i;
      cur = next;
    } else {
      firstvisit = m[next];
      secondvisit = i;
      break;
    }
  }

  ll rooplen = secondvisit - firstvisit;
  ll nonrooplen = firstvisit;

  if (K <= nonrooplen) {
    cout << simulate(K) << endl;
    return 0;
  }

  ll tK = nonrooplen + ((K - nonrooplen) % rooplen);
  cout << simulate(tK) << endl;
}


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

using namespace std;

int main()
{
  string se, so;
  cin >> so >> se;
  for(int i = 0; i < so.size(); ++i){
    cout << so[i];
    if (i == se.size())
      break;
    cout << se[i];
  }
  cout << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(i, n) for (ll i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define m1(x) memset(x,-1,sizeof(x))
const int INF = 1e9;
const int MOD = 1e9 + 7;
const double PI = 3.141592653589;

int main(){
  int n;
  cin >> n;
  map<int, int> mp;
  rep(i, n){
    mp[i + 1] = 0;
  }
    
  rep(i, n-1){
    int tmp;
    cin >> tmp;
    if(mp.count(tmp)) mp.at(tmp) ++;
  }
  rep(i, n){
    cout << mp.at(i+1) <<endl;
  }
}

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

int main(){
  int n;
  string s;
  cin >> n >> s;
  int ans=0;
  for(int i=0;i<n;i++){
    int m=0;
    map<char,int>a;
    map<char,int>b;
    for(int j=0;j<i;j++)
      a[s.at(j)]=1;
    for(int j=i;j<n;j++)
      b[s.at(j)]=1;
    for(auto j:a){
      if(j.second==1&&b[j.first]==1)
        m++;
    }
    ans=max(ans,m);
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3596
@n = gets.chomp.to_i

@dp = Array.new(100_100).map{ Array.new(3, 0) }

@a = []
@n.times do
  @a << gets.chomp.split.map(&:to_i)
end
# @a[][0] => a, @a[][1] => b, @a[][2] => c

@n.times do |i|
  @dp[i+1][0] = [
    @dp[i+1][0],
    @dp[i][1] + @a[i][0],
    @dp[i][2] + @a[i][0]
  ].max
  @dp[i+1][1] = [
    @dp[i+1][1],
    @dp[i][0] + @a[i][1],
    @dp[i][2] + @a[i][1]
  ].max
  @dp[i+1][2] = [
    @dp[i+1][2],
    @dp[i][0] + @a[i][2],
    @dp[i][1] + @a[i][2]
  ].max
end

puts [@dp[@n][0], @dp[@n][1], @dp[@n][2]].max

Measured memory_bytes: 16636
//#include <tourist>
#include <bits/stdc++.h>
#include <atcoder/all>
using namespace std;
using namespace atcoder;
typedef long long ll;
typedef unsigned int  uint;
typedef unsigned long long ull;
typedef pair<ll, ll> p;
const int INF = 1e9;
const ll LINF = ll(1e18);
const int MOD = 1000000007;
const int dx[4] = {0, 1, 0, -1}, dy[4] = {-1, 0, 1, 0};
const int Dx[8] = {0, 1, 1, 1, 0, -1, -1, -1}, Dy[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl
#define rep(i, n) for (int i = 0; i < n; i++)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ALL(v) v.begin(), v.end()
#define debug(v)          \
    cout << #v << ":";    \
    for (auto x : v)      \
    {                     \
        cout << x << ' '; \
    }                     \
    cout << endl;
template <class T>
bool chmax(T &a, const T &b)
{
    if (a < b)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T &a, const T &b)
{
    if (b < a)
    {
        a = b;
        return 1;
    }
    return 0;
}
//cout<<fixed<<setprecision(15);有効数字15桁
//-std=c++14
//-std=gnu++17
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, q;
    cin >> n >> q;
    dsu d(n);
    rep(_q, q)
    {
        int t, u, v;
        cin >> t >> u >> v;
        if (t == 0)
            d.merge(u, v);
        else
            cout << d.same(u, v) << endl;
    }
}

Measured memory_bytes: 3848
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <climits>
#include <string>
#include <bitset>
#include <cfloat>
#include <unordered_set>
#pragma GCC optimize("Ofast")
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<ll> > vvll;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define irep(it, stl) for(auto it = stl.begin(); it != stl.end(); it++)
#define drep(i,n) for(int i = (n) - 1; i >= 0; --i)
#define fin(ans) cout << (ans) << '\n'
#define STI(s) atoi(s.c_str())
#define mp(p,q) make_pair(p, q)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define Sort(a) sort(a.begin(), a.end())
#define Rort(a) sort(a.rbegin(), a.rend())
#define MATHPI acos(-1)
#define itn int;
template <class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;} return 0;}
template <class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;} return 0;}
struct io{io(){ios::sync_with_stdio(false);cin.tie(0);}};
const int INF = INT_MAX;
const ll LLINF = 1LL<<60;
const ll MOD = 1000000007;
const double EPS = 1e-9;

string question1(int m) {
    cout<<m<<endl;
    string s;
    cin>>s;
    return s;
}

// int question2(int l, int r) {
//     cout<<l<<endl;
//     string s,t;
//     cin>>s;
//     if(s=="Vacant")return 2;
//     if(l==r)return 0;
//     cout<<r<<endl;
//     cin>>t;
//     if(t=="Vacant")return 2;
//     if((r-l)%2==1&&s==t)return 1;
//     if((r-l)%2==0&&s!=t)return 1;
//     return 0;
// }

int main(void) {
    
    int n;
    cin>>n;
    string s=question1(n-1);
    if(s=="Vacant")return 0;

    s=question1(0);
    if(s=="Vacant")return 0;
    int l=0,r=n-1;
    while(1){
        int m=(l+r)/2;
        string res=question1(m);
        if(res=="Vacant")return 0;

        if (res == s) {
            if (m%2 == 0) {
                l = m;
            } else {
                r= m;
            }
        } else {
            if (m%2 == 1) l = m;
            else r = m;
        }
    }
}

Measured memory_bytes: 852
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define rrep(i, n) for (int i = (int)(n)-1; i >= 0; --i)
#define debug(x) cerr << #x << " = " << x << "\n"
#define debugv(x) rep(i, x.size()) cerr << x[i] << (i == x.size() - 1 ? "\n" : " ")
#define int long long
#define all(x) x.begin(),x.end()
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int INF = ((1LL << 30) + (1LL << 29));
const int MOD = 1000000007;

//=============================
int N, M, K;
string S, T;
vector<int> A;
vector<int> B;
vector<int> C;
//=============================
void input()
{
    cin>>N;
    A.resize(N);
    B.resize(N);
    C.resize(N);

    rep(i,N)cin>>A[i];
    rep(i,N)cin>>B[i];
    rep(i,N)cin>>C[i];

}
//=============================
void func() {}

int BC[100005];
//=============================
void solve()
{
    sort(A.begin(),A.end());
    sort(B.begin(),B.end());
    sort(C.begin(),C.end());

    vector<int> BC(N);
    vector<pii> AB(N);

    vector<int> BCs(N+1);
    rep(i,N){
        // B[i] < C[j] となるjの個数
        auto it = upper_bound(all(C), B[i]);
        BC[i] = C.end() - it;
    }
    rrep(i,N){
        if (i==N-1) {
            BCs[i] = BC[i];
        }
        else {
            BCs[i] = BCs[i+1] + BC[i];
        }
    }

    



    rep(i,N){
        // A[i] < B[j] となるjの個数
        auto it = upper_bound(all(B),A[i]);
        AB[i] = make_pair(B.end()-it, it-B.begin());
    }

    int ans= 0;
    rep(i,N){
        debug(AB[i].first);
        debug(BCs[AB[i].second]);
        ans += (BCs[AB[i].second]);
    }
    cout<<ans<<endl;

}
//=============================
signed main()
{
    input();
    solve();
    return 0;
}

Measured memory_bytes: 7808
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<n;i++)
#define LOOP(i,x,n) for(int i=x;i<n;i++)
#define ALL(v) (v).begin(),(v).end()
#define PB push_back
#define MP make_pair
#define FR first
#define SC second
#define int long long
using namespace std;
const int MOD=1000000007;
const int INF=1000000009;


signed main(){
  int n;
  while(cin>>n){
    vector<int> x={1,2,4,8,16,32,64,128,256,512};
    vector<int> ans;
    while(n){
      int tmp;
      for(int i=0;i<10;i++){
        if(n>=x[i])tmp=x[i];
      }
      n-=tmp;
      ans.PB(tmp);
    }
    for(int i=ans.size()-1;i>=0;i--){
      cout<<ans[i];
      if(i!=0)cout<<' ';
    }
    cout<<endl;
  }
  return 0;
}



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

using namespace std;

static const int INF = 1e9 + 7;

void hawawa()
{
  int n;
  cin >> n;
  int cnt = 0;
  for (int i = 0; i < n; i++) {
    int num;
    cin >> num;
    cnt += num % 2;
  }
  if (cnt % 2 && n != 1) {
    cout << "NO\n";
  } else {
    cout << "YES\n";
  }
}
int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  hawawa();
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ll long long
#define pii std::pair<int,int>
#define pli std::pair<ll,int>
#define pil std::pair<int,ll>
#define psi std::pair<string,int>
#define pll std::pair<ll,ll>
#define pci std::pair<char,int>
#define sll(x) scanf("%lld",&x)
#define prll(x) printf("%lld ",x)
#define pri(x) printf("%d ",x)
#define si(x) scanf("%d",&x)
#define pb push_back
#define vll std::vector<ll>
#define vpi std::vector<std::pair<int,int>>
#define vi std::vector<int>
#define vvi std::vector<std::vector<int>>
#define vvpil std::vector<std::vector<std::pair<int,ll>>>
#define vlpii std::vector<std::list<pii>>
#define vlpil std::vector<std::list<pil>>
#define li std::list<int>
#define lpil std::list<pil>
#define Endl printf("\n")
#define vli vector<list<int>>
#define vvll vector<vector<ll>>
#define mp make_pair
#define x first
#define y second
#define ull uint64_t
#define ma 100000000
#define imie(...) "[" << #__VA_ARGS__": " << (__VA_ARGS__) << "] "
const ll  INF=10000000000000;
const ll mod =  1e9 + 7;
using namespace std;
void add(ll& a , ll b){
	a += b;
	if(a >= mod) a -= mod;
}
ll mul(ll a , ll b){
	return (a * b) % mod;
}
ull Pow(ull a , ull b){
	if(b == 0) return 1 ;
	ull c = Pow(a , b / 2) ;
	if(b % 2) return (a * ((c * c) % mod)) % mod;
	return (c * c) % mod ;
}
ll countDivisibles(ll A, ll B, ll M) 
{ 
    // Add 1 explicitly as A is divisible by M 
    if (A % M == 0) 
        return (B / M) - (A / M) + 1; 
  
    // A is not divisible by M 
    return (B / M) - (A / M); 
} 
int main(){
	IOS;
	cout.precision(30) ;
	int n , m ; cin >> n >> m ;
	vector<pll> v(n);ll a , b ;
	for(int i = 0 ; i < n ; i++) {cin >> a >> b ; v[i] = mp(a , b) ;}
	sort(v.begin() , v.end()) ;
	ll nb = m ;
	ll ans = 0 ;
	for(int i = 0 ; i < n ; i++){
		if(v[i].y >= m){
			ans += m * v[i].x ;
			m = 0 ;
		}
		else{
			ans += v[i].y * v[i].x ;
			m -= v[i].y ;
		}
	}
	cout << ans << endl; 
	return 0;
}


Measured memory_bytes: 1792
#include <iostream>
#include <algorithm>
#include <string>
#include <string.h>
#include <math.h>
#include <cmath>
#include <tuple>
#include <vector>
#include <bitset>
#include <stack>
#include <iomanip>
#include <set>
#include <queue>
#include <map>


typedef long long ll;
typedef unsigned long long ull;
#define mk make_pair
#define mkt make_tuple
#define fi first
#define se second


using namespace std;
int const N = 100000;
int ans[N];

int main()
{
	string s;
	cin >> s;
	int n = s.length(); int k = 0;
	for (int i = 0; i < n - 1; i++) {
		if (s[i] == 'R') k++;
		if (s[i + 1] == 'L') {
			ans[i] += k / 2 + k % 2;
			ans[i + 1] += k / 2;
			k = 0;
		}
	}
	k = 0;
	for (int i = n-1; i; i--) {
		if (s[i] == 'L') k++;
		if (s[i - 1] == 'R') {
			ans[i] += k / 2 + k % 2;
			ans[i - 1] += k / 2;
			k = 0;
		}
	}
	
	for (int i = 0; i < n; i++)
		cout << ans[i] << ' ';
}


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

int main()
{
 int n,q,l;
 while(cin>>n)
 {if(n%2==0)
  {cout<<setiosflags(ios::fixed)<<setprecision(10);
   cout<<(n/2.0)/n<<endl;
  }
  else if(n%2==1)
  {cout<<setiosflags(ios::fixed)<<setprecision(10);
   cout<<((n+1)/2.0)/n<<endl;
  }
  
 }
 return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Windows;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Atcoder
{
    public class Program
    {
        static void Main(string[] args)
        {
            var r = ReadSplit();
            var n = r[0].Int();
            var k = r[1].Int();
            var sum = new long[n + 1];
            for (int i = 0; i <= n; i++)
            {
                if (i - 1 < 0) continue;
                sum[i] += sum[i - 1] + i;
            }
            long count = 0;
            var mod = 1000000007;
            for (int i = k - 1; i <= n; i++)
            {
                var min = sum[i];
                if (n - (i + 1) < 0)
                {
                    count++;
                    break;
                }
                var max = sum[n] - sum[n - (i + 1)];
                count += max - min + 1 % mod;
            }
            WriteRead(count % mod);
        }

        public static string Read()
        {
            return Console.ReadLine();
        }

        public static string[] ReadSplit()
        {
            return Console.ReadLine().Split(' ');
        }

        public static void WriteRead(object str)
        {
            Console.WriteLine(str);
            Read();
        }

        public static void Write(object str)
        {
            Console.WriteLine(str);
        }

        private static bool ChangeMin<T>(ref T a, T b) where T : IComparable
        {
            if (a.CompareTo(b) > 0)
            {
                a = b;
                return true;
            }
            return false;
        }

        private static bool ChangekMax<T>(ref T a, T b) where T : IComparable
        {
            if (b.CompareTo(a) > 0)
            {
                a = b;
                return true;
            }
            return false;
        }
    }
}


public static class Extentions
{
    public static int Int(this object obj)
    {
        return int.Parse(obj.ToString());
    }

    public static long Long(this object obj)
    {
        return long.Parse(obj.ToString());
    }

    public static decimal Decimal(this object obj)
    {
        return decimal.Parse(obj.ToString());
    }

    public static double Double(this object obj)
    {
        return double.Parse(obj.ToString());
    }

    public static T2 GetValueZero<T1, T2>(this Dictionary<T1, T2> d, T1 key) where T2 : struct
    {
        T2 value;
        if (d.TryGetValue(key, out value))
        {
            return value;
        }
        return new T2();
    }
}



Measured memory_bytes: 18480
#include <stdio.h>

int main(void)
{
	int a,b,c,y,i;
	double x=1000000,d[1010],z;
	scanf("%d %d %d",&a,&b,&c);
	for(i=0;i<a;i++){
		scanf("%lf",&d[i]);
		if(c-(b-d[i]*0.006)<0){
			z=(b-d[i]*0.006)-c;
		}else{
			z=c-(b-d[i]*0.006);
		}
		if(x>z){
			y=i+1;
			x=z;
		}
	}
	printf("%d",y);
	return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<sstream>
#include<fstream>
#include<string>
#include<vector>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<functional>
#include<algorithm>
#include<bitset>
#include<utility>
#include<cmath>
#include<cstdio>
#include<cstdlib>
#include<cstring>
using namespace std;
int sum=0,n,x,k,ans=0;
int a[1000001];
map<int,int> m; 
int main()
{
    cin>>n>>k;
    for(int i=1;i<=n;i++)
    {
        scanf("%d",&x);
        m[x]++;
    }
    int q=m.size();
    map<int,int>::iterator it=m.begin();
    for(it;it!=m.end();it++)
        a[++sum]=(*it).second;
    sort(a+1,a+sum+1);
    for(int i=1;i<=q-k;i++)
        ans+=a[i];
    cout<<ans;
    return 0;
}

Measured memory_bytes: 10368
#include<bits/stdc++.h>
#define ll long long 
#define ld long double
#define X first
#define Y second
#define pb push_back
#define max_el(x) max_element(x.begin(),x.end())-x.begin()
#define min_el(x) min_element(x.begin(),x.end())-x.begin()
#define mp make_pair
#define endl '\n'
#define fastread ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using namespace std;

int n,k;
vector<int> a;
int dp[500001];

int f(int i){
	if(i==n-1){
		return 0;
	}
	if(dp[i]!=-1) return dp[i];

	dp[i] = INT_MAX;
	for(int j=1;j<=k;j++){
		if(i+j < n){
			dp[i] = min(dp[i],f(i+j)+abs(a[i+j]-a[i]));
		}
	}
	return dp[i];
}

int main(){
	cin>>n>>k;
	memset(dp,-1,sizeof(dp));
	a.resize(n);
	for(int i=0;i<n;i++){
		cin>>a[i];
	}
	cout<<f(0)<<endl;
}

Measured memory_bytes: 7296
/**
 *    author: gxfireball       
**/
#include <bits/stdc++.h>
#define ll long long
#define endl '\n'
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL); 
using namespace std;

void solve(){
   ll x;
   cin >> x;
   ll score = 0;
   
  if(x / 500 != 0){
	   score += (x/500)*1000;
	   x = x % 500;
   }
   if(x!=0){
	   score += (x/5)*5;
	   x = x%5;
   }
   cout << score ;
}

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



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

using namespace std;

#define ll long long

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

	ll ans = 0;

	for (int i = 1; i <= K; i++) {
		for (int j = 1; j <= K; j++) {
			for (int k = 1; k <= K; k++) {
				ans += __gcd(__gcd(i, j), k);
			}
		}
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 3624
#include <iostream>
#include <string>
#include <algorithm>
#include <set>
#include <cmath>
#include <vector>
#include <numeric>
#include <unordered_map>
#include <unordered_set>
#include <queue>

typedef long long ll;
const ll LL_MAX (1LL<<60);

#define rep(i,s,e) for(ll i=(s); i<(e); i++) 

using namespace std;

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

    string s;
    cin >> s;

    char prev(s[0]);
    for (auto i: s)
    {
        if (prev != i)
        {
            cout << "Yes" << endl;
            return 0;
        }
        prev = i;
    }

    cout << "No" << endl;

    return 0;
}


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

typedef long long ll;

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

    int n; cin >> n;
    vector<int> a(n);
    for(int i=0;i<n;i++) cin >> a[i];
    int decide;
    ll ans = 1,ret = 1LL<<60;
    for(int cnt=0;cnt<2;cnt++){
        if(cnt==0) decide = -1;
        else decide = 1;
        for(int i=0;i<n-1;i++){
            if(decide==0){
                if(a[i]<a[i+1]) decide = 1;
                if(a[i]>a[i+1]) decide = -1;
            }
            else if(decide==1 && a[i]>a[i+1]){
                ans++;
                decide = 0;
            }
            else if(decide==-1 && a[i]<a[i+1]){
                ans++;
                decide = 0;
            }
        }
        ret = min(ans,ret);
        ans = 1;
    }
    cout << ret << endl;
    return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const  ll INF = 1e9;
const  ll MOD = 1e9 + 7;
#define all(v) v.begin(), v.end()
#define repi(i,n,init) for(ll i=init;i<(n);i++)
#define repd(i,n,init) for(ll i=(n);i>=init;i--)
#define repm(i,m) for(auto i=m.begin();i!=m.end();i++)
#define repb(bit,n,init) for(ll bit=init;bit<(1<<n);++bit)

vector<ll> fact, invfact;
ll modpower(ll x, ll n, ll mod){
    ll res = 1;
    while(n){
        if(n&1)res = res * x % mod;
        x = x * x % mod;
        n >>= 1;
    }
    return res;
}
ll inv(ll n){
    return modpower(n,MOD-2,MOD);
}
void COMinit(ll k){ //空っぽの配列を二つ
   k++;
   fact.resize(k, 0);
   invfact.resize(k, 0);
   fact[0] = 1;
   repi(i, k, 1)
   {
       fact[i] = fact[i - 1] * i % MOD;
   }
   invfact[k - 1] = inv(fact[k - 1]);
   repd(i, k - 2, 0)
   {
       invfact[i] = invfact[i + 1] * (i + 1) % MOD;
   }
   return;
}
ll nCk(vector<ll> &fact,vector<ll> &invfact,ll n, ll k){ //この関数を使う前にCOMinit
   if (k < 0 || n < k)
       return 0LL;
   return fact[n] * invfact[k] % MOD * invfact[n - k] % MOD;
}
// ll com(ll n, ll k)
// {
//     ll inv = 1;
//     ll invfact = 1;
//     repi(i, k, 0)
//     {
//         fact *= (n - i);
//         fact %= MOD;
//     }
//     repi(i, k + 1, 1)
//     {
//         invfact *= modinv(i);
//         invfact %= MOD;
//     }
//     return fact * inv % MOD;
// }

//---------main function----------

int main()
{
    int h1,m1,h2,m2,k;
    cin >> h1 >> m1 >> h2 >> m2 >> k;
    cout << (h2 - h1) * 60 + (m2 - m1) - k << endl;
   return 0;
}

Measured memory_bytes: 3632
//Written by Rhitwik Saha//
#include <bits/stdc++.h>
using namespace std;
#define int         long long
#define mp          make_pair
#define pb          push_back
#define pii         pair<int,int>
#define vi          vector<int>
#define vb          vector<bool>
#define vc          vector<char>
#define vii         vector<pii>
//#define mi          map<int,int>
//#define mii         map<pii,int>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (int)x.size()
#define ub(x)       upper_bound(x)
#define lb(x)       lower_bound(x)
#define endl        '\n'
#define file        freopen("input.txt","r",stdin);freopen("output.txt","w",stdout)
#define fastio      ios::sync_with_stdio(false),cin.tie(0),cout.tie(0);
// #define N 			1e5+5
#define M           1000000007
#define MAX         100005
#define mem0(a)     memset(a,0,sizeof(a))
#define prec        cout<<std::setprecision(9)<<std::fixed
#define forn(i,a,b)  for(int i=a;i<b;i++)
int i,j,k;

void Anon_mouS(){
	int a[32]={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
	// a[32]={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
	// for(i=0;i<32;i++)cin>>a[i]
	int k;
	cin>>k;
	cout<<a[k-1];
}
int32_t main(){
    fastio;
    // file;
    // sieve();
    int q=1;
    // cin>>q;
    while(q--)Anon_mouS();
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main() {
	int N;

	cin >> N;
	vector<int> A(N), B(N), C(N);
	for(int i = 0; i < N; i++) cin >> A[i];
	for(int i = 0; i < N; i++) cin >> B[i];
	for(int i = 0; i < N; i++) cin >> C[i];

	sort(A.begin(), A.end());
	sort(C.begin(), C.end());

	long long ans = 0;
	for(int i = 0; i < N; i++) {
		long atmp, ctmp;
		
		atmp = lower_bound(A.begin(), A.end(), B[i]) - A.begin();
		ctmp = N - (upper_bound(C.begin(), C.end(), B[i]) - C.begin());

		ans += atmp * ctmp;
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 1408
#include <iostream>
#include <cstdio>
#include <algorithm>

using namespace std;

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

bool card[4][14];

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

    for (int i = 0; i < N; i++) {
        char ch;
        int x;
        cin >> ch >> x;
        if (ch == 'S')ch = 0;
        else if (ch == 'H')ch = 1;
        else if (ch == 'C')ch = 2;
        else if (ch == 'D')ch = 3;
        card[ch][x] = true;
    }

    rep(i, 4) {
        for (int j = 1; j <= 13; j++) {
            if (card[i][j] == false) {
                char r;
                if (i == 0)r = 'S';
                else if (i == 1)r = 'H';
                else if (i == 2)r = 'C';
                else if (i == 3)r = 'D';
                cout << r << ' ' << j << endl;
            }
        }
    }
}


Measured memory_bytes: 3096
#include <stdio.h>

int main(void){
  int n;
  scanf("%d",&n);
  unsigned long long int a[87];
  a[0]=2;
  a[1]=1;
  for(int i=2;i<=n;i++){
    a[i]=a[i-1]+a[i-2];
  }
  printf("%ld",a[n]);
  return 0;
}

Measured memory_bytes: 128
import bisect
def main():
	while True:
		n,m=map(int,input().split())
		if n==0 and m==0:
			break
		p=[0]+sorted([int(input()) for i in range(n)])
		s=list()
		for i in range(n+1):
			for j in p[i:]:
				if p[i]+j>m:
					break
				s+=[p[i]+j]
		s.sort()
		print(max(i+s[bisect.bisect_right(s,m-i)-1] for i in s))

if __name__=="__main__":
	main()



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

using namespace std;

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

template<typename A, typename B> bool chmin(A &a, const B &b){ return b < a && (a = b, true); }
template<typename A, typename B> bool chmax(A &a, const B &b){ return a < b && (a = b, true); }

int main() {
  char x,y;
  cin >> x >> y;
  if (x < y){
    cout << "<\n";
    return 0;
  }
  if (x == y){
    cout << "=\n";
    return 0;
  }
  if (x > y){
    cout << ">\n";
    return 0;
  }
  return 0;
}

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

typedef long long ll;

const int N = 1 * 1e5 + 10;

ll res;
ll a[N];
ll dp[N];

ll go(ll idx, ll n){
	if(idx == n)	return 0;
	if(dp[idx] != -1)return dp[idx];
	ll xx = INT_MAX, yy = INT_MAX;
	xx = abs(a[idx] - a[idx + 1]) + go(idx + 1, n);
	if(idx <= n - 2)
	yy = abs(a[idx] - a[idx + 2]) + go(idx + 2, n);
	return dp[idx] = min(xx, yy);
}

void solve() {
	ll n;
	cin >> n;
	for (int i = 1; i <= n ; ++i){
		cin >> a[i];
	}
	memset(dp, -1, sizeof(dp));
	cout << go(1, n);
}

int main(int argc, char const *argv[]){
  ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
  ll t = 1;
  //cin >> t;
  while(t--){
    solve();
  }
    return 0;
}

Measured memory_bytes: 6528
#include <iostream>
#include<string>
#include<cmath>
#include<algorithm>
#include<cctype>
#include<queue>
#include<deque>
#include<regex>
#include<stack>
#include<stdio.h>
#include<vector>
#include<set>
#include<map>
#include<iomanip>

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

typedef int long long ll;
using namespace std;
typedef pair<int, int> P;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
const ll MOD = 1e9 + 7;
static const int MAX = 100;
static const int INF = (1 << 23);

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

    double i = x;

    if(x%2==1){

        printf("%f",(x/2+1.0)/i);

    }else{
        printf("%f",(x/2)/i);
    }





    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <map>
#include <queue>
#include <iomanip>
#include <set>
#include <tuple>
#define mkp make_pair
#define mkt make_tuple
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
const ll MOD=1e9+7;
template<class T> void chmin(T &a,const T &b){if(a>b) a=b;}
template<class T> void chmax(T &a,const T &b){if(a<b) a=b;}

int mostBit(int val){
    for(int i=20;i>=0;i--){
        if((1<<i)&val) return i;
    }
    return -1;
}

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

  int N;
  cin>>N;

  for(int i=0;i<20;i++){
      if((1<<i)==N){
          cout<<"No"<<endl;
          return 0;
      }
  }

  vector<pair<int,int>> ans;
  for(int i=3;i<=N;i+=2){
      ans.push_back(mkp(i-1,1));
      ans.push_back(mkp(i-1,i));
      ans.push_back(mkp(N+i,1));
      ans.push_back(mkp(N+i,N+i-1));
  }
  ans.push_back(mkp(N+1,3));

  if(N%2==0){
      int a=(1<<mostBit(N))+1;
      int b=N+1-a;
      ans.push_back(mkp(N,b));
      ans.push_back(mkp(N+N,N+a));
  }

  cout<<"Yes"<<endl;
  for(auto v:ans) cout<<v.first<<" "<<v.second<<endl;

  return 0;
}


Measured memory_bytes: 4080
#include <iostream>

using namespace std;

int main()
{
	int A, B, C, D = 0;

	cin >> A >> B >> C >> D;

	int rectA = A * B;
	int rectB = C * D;

	if (rectA >= rectB)
	{
		cout << rectA;
	}
	else
	{
		cout << rectB;
	}

}

Measured memory_bytes: 256
import sys
import os
import bisect, collections, copy, itertools, math, string
def I(): return int(input())
def S(): return input()
def LI(): return list(map(int, input().split()))
def LS(): return list(input().split())

def solve():
	s = S()
	if s[2]==s[3] and s[4]==s[5]:
		print('Yes')
		return
	print('No')
	return
	
if __name__ == '__main__':
	solve()


Measured memory_bytes: 4076
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> lpair;
const ll MOD = 1e9 + 7;
const ll INF = 1e18;
#define rep(i,m,n) for(ll i = (m); i < (n); i++)
#define rrep(i,m,n) for(ll i = (m); i >= (n); i--)
#define print(x) cout << (x) << endl;
#define print2(x,y) cout << (x) << " " << (y) << endl;
#define printa(x,n) for(ll i = 0; i < n; i++){ cout << (x[i]) << " \n"[i==n-1];};
struct Combination{
private:
    ll N;
    vector<ll> fac, facinv;

public:
    Combination(ll n){
        N = n;
        fac.push_back(1); fac.push_back(1);
        rep(i,2,N+1) fac.push_back(fac[i-1] * i % MOD);
        rep(i,0,N+1) facinv.push_back(power(fac[i], MOD-2));
    }
    ll power(ll x, ll n){
        if(n == 0) return 1LL;
        ll res = power(x * x % 13, n/2);
        if(n % 2 == 1) res = res * x % 13;
        return res;
    }
    ll nck(ll n, ll k){
        if(k == 0 || n == k) return 1LL;
        return fac[n] * facinv[k] % MOD * facinv[n-k] % MOD;
    }
    ll npk(ll n, ll k){
        if(k == 0 || n == k) return 1LL;
        return fac[n] * facinv[n-k] % MOD;
    }
    ll get(ll x){return fac[x];};
    ll getinv(ll x){return facinv[x];};
};
ll dp[100010][15] = {};
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    string S;
    cin >> S;
    ll N = S.size();
    dp[0][0] = 1;
    Combination cb(100010);
    reverse(S.begin(), S.end());
    rep(i,0,N){
        rep(j,0,13){
            if(S[i] == '?'){
                rep(k,0,10){
                    ll amari = k * cb.power(10, i) % 13;
                    dp[i+1][(j+amari) % 13] += dp[i][j] % MOD;
                    dp[i+1][(j+amari) % 13] %= MOD;
                }
            }else{
                ll v = S[i] - '0';
                ll amari = v * cb.power(10, i) % 13;
                dp[i+1][(j+amari) % 13] += dp[i][j] % MOD;
                dp[i+1][(j+amari) % 13] %= MOD;
            }

        }
    }
    print(dp[N][5]);
    
}

Measured memory_bytes: 13764
#include <iostream>
#include <numeric>
#include <math.h>
#include <algorithm>
#include <float.h>
#include <limits>
#include <vector> 
#include <string.h>

#define rep(i,a,n) for(ll int (i) = (a);(i) < (n);(i)++)
#define urep(i,a,n) for(ll int (i) = (a);(i) > (n);(i)--)
#define MOD 1000000007
#define ll long long
#define asort(a) sort(a.begin(),a.end());

using namespace::std;

int jo(ll int jxo, ll int jyo){//累乗
	ll int jhogeo = 1;
	rep(jinto,0,jyo) jhogeo=jhogeo*jxo;
	return jhogeo;
}
char tobig(char toxbig){//char大文字化
  return (toxbig-0x20);
}
char tolow(char toxlow){//char小文字化
  return (toxlow+0x20);
}
int ctoi(char cctoi){//char->int
  if('0' <= cctoi && cctoi <= '9') return (cctoi-'0');
  return -1;
}
int gcd(int gcad, int gcbd) {//最大公約数
  if(gcad < gcbd) return gcd(gcbd, gcad);
  int gcrd;
  while ((gcrd=gcad%gcbd)) {
    gcad = gcbd;
    gcbd = gcrd;
  }
  return gcbd;
}
int lcm(int lcam, int lcbm){//最小公倍数
 return (lcam*lcbm)/gcd(lcam,lcbm);
}


int main(){
  vector<string> a(26);
  a['S'-'A']="Cloudy";
  a['C'-'A']="Rainy";
  a['R'-'A']="Sunny";
  string hoge;
  cin>>hoge;
  cout<<a[hoge[0]-'A'];
}
// int *p = new int[N];

//  vector<int> 変数名(要素数);
//  sort(変数名.begin(),変数名.end());//昇順ソート

// vector<vector<int>> 変数名(左の個数, vector<int>(右の個数));

//


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

Measured memory_bytes: 1024
package main

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

var scanner = bufio.NewScanner(os.Stdin)

func init() {
	scanner.Split(bufio.ScanWords)
}

func main() {
	Count, SAttack := readInt(), readInt()
	Enemies := make([]int, Count)
	Loop(0, Count, func(i int) {
		Enemies[i] = readInt()
	})

	sort.Sort(sort.Reverse(sort.IntSlice(Enemies)))

	Sum := 0
	Loop(SAttack, Count, func(i int) {
		Sum += Enemies[i]
	})

	fmt.Println(Sum)
}

func Loop(start, end int, f func(i int)) {
	for i := start; i < end; i++ {
		f(i)
	}
}

func readInt() int {
	scanner.Scan()
	t, _ := strconv.Atoi(scanner.Text())
	return t
}

Measured memory_bytes: 5120
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>

using namespace std;

int main(){
    int n;
    cin>>n;
    vector<int> t(n),x(n),y(n);
    for(int i=0;i<n;++i) cin>>t[i]>>x[i]>>y[i];

    int sx=0;
    int sy=0;
    int ct=0;
    bool flag=true;

    for(int i=0;i<n;++i){
        int dx=x[i]-sx;
        int dy=y[i]-sy;
        dx=dx>0?dx:-dx;
        dy=dy>0?dy:-dy;
        if(t[i]-ct<dx+dy){
            flag=false;
            break;
        }
        else if((t[i]-ct-dx-dy)%2!=0){
            flag=false;
            break;
        }
        sx=x[i];
        sy=y[i];
        ct=t[i];
    }

    string ans=flag?"Yes":"No";
    cout<<ans<<endl;
}

Measured memory_bytes: 1408
# -*- coding: utf-8 -*-

import sys

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def list4d(a, b, c, d, e): return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(N=None): return list(MAP()) if N is None else [INT() for i in range(N)]
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = 10 ** 18
MOD = 998244353

class ModTools:
    """ 階乗たくさん使う時用のテーブル準備 """

    def __init__(self, MAX, MOD):
        """ MAX：階乗に使う数値の最大以上まで作る """
        
        MAX += 1
        self.MAX = MAX
        self.MOD = MOD
        # 階乗テーブル
        factorial = [1] * MAX
        factorial[0] = factorial[1] = 1
        for i in range(2, MAX):
            factorial[i] = factorial[i-1] * i % MOD
        # 階乗の逆元テーブル
        inverse = [1] * MAX
        # powに第三引数入れると冪乗のmod付計算を高速にやってくれる
        inverse[MAX-1] = pow(factorial[MAX-1], MOD-2, MOD)
        for i in range(MAX-2, 0, -1):
            # 最後から戻っていくこのループならMAX回powするより処理が速い
            inverse[i] = inverse[i+1] * (i+1) % MOD
        self.fact = factorial
        self.inv = inverse
    
    def nCr(self, n, r):
        """ 組み合わせの数 (必要な階乗と逆元のテーブルを事前に作っておく) """

        if n < r: return 0
        # 10C7 = 10C3
        r = min(r, n-r)
        # 分子の計算
        numerator = self.fact[n]
        # 分母の計算
        denominator = self.inv[r] * self.inv[n-r] % self.MOD
        return numerator * denominator % self.MOD

N, A, B, K = MAP()

ans = 0
mt = ModTools(N, MOD)
for x in range(N+1):
    # 式変形：A * x + B * y = K → y = (K -  A * x) / B
    y = (K -  A * x) / B
    if y < 0 or not y.is_integer():
        continue
    y = int(y)
    ans += mt.nCr(N, x) * mt.nCr(N, y)
    ans %= MOD
print(ans)


Measured memory_bytes: 28788
#define _USE_MATH_DEFIMES
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cctype>
#include <climits>
#include <clocale>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <regex>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

const int MOD = 1'000'000'007;
const int INF = 1'000'000'000; //1e9
const int NIL = -1;
const long long LINF = 1'000'000'000'000'000'000; // 1e18
const long double EPS = 1E-10;

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








int main(){
    int a; std::cin >> a;
    std::cout << a + a*a + a*a*a << std::endl;
    return 0;
}


Measured memory_bytes: 3620
from sys import stdin
input = stdin.buffer.readline
from collections import defaultdict

def gcd(a, b):
    while b:
        a, b = b, a % b
    return a

MOD = 10 ** 9 + 7

N = int(input())
AB = [list(map(int, input().split())) for _ in range(N)]

rest = N
zero = 0
zero_left, zero_right = 0, 0
tmp = []
for a, b in AB:
    if a == b == 0:
        zero += 1
        rest -= 1
    elif a == 0:
        zero_left += 1
    elif b == 0:
        zero_right += 1
    else:
        gcd_ab = gcd(abs(a), abs(b))
        a, b = a // gcd_ab,  b // gcd_ab
        if a < 0: a, b = -a, -b
        tmp.append([a, b])
AB = tmp

cnt = defaultdict(int)
for a, b in AB:
    cnt[(a, b)] += 1

answer = 1
answer *= pow(2, zero_left + zero_right, MOD) - (pow(2, zero_left, MOD) - 1) * (pow(2, zero_right, MOD) - 1)
answer %= MOD
rest -= zero_right + zero_left
#print("answer:", answer)

check = defaultdict(int)
for a, b in AB:
    if b > 0 and check[(a, b)] == 0:
        check[(a, b)] = 1
        answer *= pow(2, cnt[(a, b)] + cnt[(b, -a)], MOD) - (pow(2, cnt[(a, b)], MOD) - 1) * (pow(2, cnt[(b, -a)], MOD) - 1) 
        answer %= MOD
        rest -= cnt[(a, b)] + cnt[(b, -a)]

answer *= pow(2, rest, MOD)
answer += zero - 1
answer %= MOD
print(answer)

Measured memory_bytes: 188828
object Main extends App {

  val s = io.StdIn.readLine

  var diff1 = 0
  var diff2 = 0

  for (i <- 0 until s.size) {
    val p1 = if (i % 2 == 0) '0' else '1'
    val p2 = if (i % 2 == 0) '1' else '0'

    // println(s"$p1 $p2 ${s(i)}")

    if (s(i) != p1)
      diff1 += 1

    if (s(i) != p2)
      diff2 += 1
  }

  println(math.min(diff1,diff2))

}

Measured memory_bytes: 27344
N = int(input())
balls = sorted(tuple(sorted(map(int,input().split()))) for i in range(N))

# Rmin=MIN, Bmax=MAX
maxmin = balls[-1][0]
minmin = balls[0][0]
maxmax = max(b[1] for b in balls)
minmax = min(b[1] for b in balls)

v1 = (maxmin-minmin)*(maxmax-minmax)

# Rmin=MIN, Rmax=MAX
best = float('inf')
cur_max = maxmin
for b in balls:
  if b[0] > minmax:
    best = min(best, cur_max-minmax)
    break
  best = min(best, cur_max-b[0])
  cur_max = max(cur_max, b[1])
 
v2 = (maxmax-minmin)*best

print(min(v1,v2))

Measured memory_bytes: 30956