akhauriyash/Code-Regression huggingface dataset:
#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
using namespace std;
#ifndef FAST_IO
 #define IOS ios_base::sync_with_stdio(false);cin.tie(nullptr);
#endif

#define FILE_IO freopen("input.txt","r",stdin)
#define int long long
#define f first
#define s second
#define endl '\n'
#define all(c) c.begin(),c.end()
#define debug(x) cerr << #x << " = " << x << endl;

const int MOD=1e9+7;
const int INF=1<<29;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
template<typename T>void print(T t){for(auto &it:t)cout<<it<<" ";}
inline int powerexp(int a,int b,int m=MOD){int res=1;while(b){if(b&1)res=res*a%m;a=a*a%m,b>>=1;}return res%m;}
inline int modinv(int a){return powerexp(a,MOD-2,MOD);}
inline int lcm(int a,int b){int g=__gcd(a,b);return a/g*b;}

//-------------------< start here >-------------------------//
void solve(){
   
   string s;
   cin>>s;
   string ans="";
   ans+=s[0];
   ans+=to_string(s.length()-2);
   ans+=s[(int)s.length()-1];
   cout<<ans;
    
}
//-----------------------------
//comment from here for TOPCODER 
int32_t main(){
   IOS;
   solve();
   #ifdef LOCAL_DEFINE
   cerr<<"time elapsed "<<(double)clock()/CLOCKS_PER_SEC<<endl;
   #endif
}


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

  int main() {
    int N;
    string S;
    cin >> N >> S;
    int count=1;

    for(int i=0; i<N-1; i++){
      if(S.at(i)!=S.at(i+1))
        count++;
    }

    cout << count << endl;
  }


Measured memory_bytes: 512
#include <stdio.h>
#include <string.h>
#define LEN 100005

typedef struct pp{
  char name[100];
  int time;
}P;

P Q[LEN+1];
int head=0,tail,tk=0;
void enqueue(P x){
  Q[tail]=x;
  tail=(tail+1)%LEN;
}
P dequeue(){
  P x=Q[head];
  head=(head+1)%LEN;
  return x;
}

  
int main(){
  int n,q,i;
  P u;
  scanf("%d%d",&n,&q);
  for(i=0;i < n;i++){
    scanf("%s%d",Q[i].name,&Q[i].time);
  }
  tail=n;
  while(head != tail){
    u=dequeue();
    if(u.time > q){
      tk+=q;
      u.time=u.time-q;
      enqueue(u);
    }
    else{
      tk+=u.time;
      printf("%s %d\n",u.name,tk);
    }
  }
  return 0;
}



Measured memory_bytes: 11848
#n=int(input())
#n,m=list(map(int,input().split()))
#a=list(map(int,input().split()))
import sys
sys.setrecursionlimit(10**6)
import math
import itertools
from collections import defaultdict
from collections import Counter
import numpy as np

import heapq
def combinations_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))
od=998244353
n,k,x=list(map(int,input().split()))

n_c_i=[1]
for i in range(1,x+1):
    n_c_i.append((n_c_i[-1]*(n-i)*pow(i,od-2,od))%od)
#print(n_c_i)
pow_k=pow(k-1,n-1,od)
inv_k=pow(k-1,od-2,od)
ans=0
#print(ans)
for i in range(x+1):
        
    #pow_k=(pow_k*inv_k)%od
    p_k=(k*pow(k-1,n-i-1,od))%od
    #ans+=comb*k*pow_k%od
    ans+=(n_c_i[i]*p_k)%od
    ans%=od

print(ans)



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

using namespace std;

using ll = long long;

int main()
{
    vector<ll> n;

    ll N, X;


    cin >> N >> X;

    n.resize(N);
    ll ans = N;

    ll mi = 100010001000;

    for (int i = 0; i < N;i++)
    {
        cin >> n[i];
        X -= n[i];
        if(mi > n[i])
        {
            mi = n[i];
        }
    }

    cout << N + (ll)(X / mi) << endl;

    return 0;
}


Measured memory_bytes: 888
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define REP(i,m,n) for(int i=(int)(m); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define rrep(i,n) RREP(i,n-1,0)
#define all(v) v.begin(), v.end()
#define endk '\n'
const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;
const ld eps = 1e-10;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n; cin >> n;
  vector<ll> A(n), sum(n+1);
  rep(i, n) {
    cin >> A[i];
    sum[i+1] = sum[i] + A[i];
  }
  vector<ll> sumOrig(n+1);
  copy(all(sum), begin(sumOrig));
  ll ans = longinf;
  rep(j, 2) {
    copy(all(sumOrig), begin(sum));
    ll tmp = 0;
    ll diff = 0;
    int flag = j;
    rep(i, n) {
      if(flag==1 && sum[i+1]+diff<=0) {
        tmp += 1-(sum[i+1]+diff);
        diff += 1-(sum[i+1]+diff);
      } else if(flag==0 && sum[i+1]+diff>=0) {
        tmp += (sum[i+1]+diff)+1;
        diff -= (sum[i+1]+diff)+1;
      }
      flag = 1-flag;
    }
    ans = min(tmp, ans);
  }
  cout << ans << endk;
  return 0;
}


Measured memory_bytes: 5576
using System;

namespace Project
{
	class MainClass
	{
		public static void Main(string[] args)
		{
			int n = int.Parse(Console.ReadLine());
			int[,,] room = new int[4, 3, 10];
			for (int i = 0; i < n; i++)
			{
				string s = Console.ReadLine();
				string[] sar = s.Split(' ');
				int b, f, r, v;
				b = int.Parse(sar[0]);
				f = int.Parse(sar[1]);
				r = int.Parse(sar[2]);
				v = int.Parse(sar[3]);

				room[b - 1, f - 1, r - 1] += v;
			}
			for (int i = 0; i < 4; i++)
			{
				for (int j = 0; j < 3; j++)
				{
					for (int k = 0; k < 10; k++)
					{
						Console.Write(" {0}", room[i,j,k]);
					}
					Console.Write("\n");
				}
				if (i == 3) { break;}
				Console.WriteLine("####################");
			}

		}
	}
}

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

using namespace std;
using ll = long long;

template <class T> ostream &operator<<(ostream &os, vector<T> &v) {
  for (auto i = v.begin(); i != v.end(); i++) {
    os << *i << " ";
  }
  return os;
}


void solve(long long H, long long W, long long N, std::vector<long long> a){
  vector<vector<ll>>v;
  auto it = a.begin();
  ll x = *it;
  ll y = 1;
  for(ll i=0; i<H; i++) {
    vector<ll> vv;
    for(ll j=0; j<W; j++) {
      if(x>0) {
	x--;
	vv.push_back(y);
	// std::cout << "("<< i<<", "<<j<<")= "<<*it << std::endl;
      } else {
	it++;
	x = *it;
	y++;
	x--;
	vv.push_back(y);
      }
    }
    v.push_back(vv);
  }
  for(int i=0; i<H; i++) {
    if(i%2==0) {
      for(int j=0; j<W; j++) {
	std::cout << v[i][j];
	if(j!=W-1) {
	  std::cout << " ";
	}
      }
    } else {
      for(int j=W-1; j>=0; j--) {
	std::cout << v[i][j];
	if(j!=0) {
	  std::cout << " ";
	}
      }
    }
    std::cout  << std::endl;
  }
}

int main(){
  long long H;
  scanf("%lld",&H);
  long long W;
  scanf("%lld",&W);
  long long N;
  scanf("%lld",&N);
  std::vector<long long> a(N);
  for(int i = 0 ; i < N ; i++){
    scanf("%lld",&a[i]);
  }
  solve(H, W, N, std::move(a));
  return 0;
}


Measured memory_bytes: 512
#include <iostream>
#include <cstdio>
#include <cmath>
#include <algorithm>
#define N 1000000007
using namespace std;
long long a[1100000];
long long b[1100000];
long long n,ans;
int main()
{
	cin >> n;
	for(int i=1; i<=n; i++)
		cin >> a[i];
	for(int i=n - 1; i>=1; i--)
		b[i] = (b[i + 1] + a[i + 1]) % N;
	for(int i=1; i<=n - 1; i++)
		ans = ((ans % N) + (a[i] * b[i] % N)) % N;
	cout << ans << endl;
}

Measured memory_bytes: 6728
#include <cstdio>

using namespace std;

char s[109];

int main() {
  int n;
  scanf("%d%s", &n, s);
  if (n % 2 == 1) {
    puts("No");
    return 0;
  }
  for (int i = 0; i < n / 2; ++i) {
    if (s[i] != s[n / 2 + i]) {
      puts("No");
      return 0;
    }
  }
  puts("Yes");
}


Measured memory_bytes: 128
#include <iostream>
#include <algorithm>
#include <set>
#define int long long
using namespace std;

int arr[100010],dp[100010];

signed main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	int n,i,j,k;
	cin>>n>>k;
	for(i=0;i<n;i++)
	{
		cin>>arr[i];
		dp[i]=1e18*(!!i);
		for(j=max(0LL, i-k);j<i;j++)
		{
			dp[i]=min(dp[i], dp[j]+abs(arr[j]-arr[i]));
		}
	}
	cout<<dp[n-1]<<'\n';
	
	return 0;
}


Measured memory_bytes: 1792
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <string>
#include <queue>
#include <unordered_map>
#include <iterator>
#include <stack>
#include <unordered_set>
#include <iomanip>
#include <ctime>
#include <cstring>
#include <bitset>

#include <random>

#define all(x) (x).begin(), (x).end()
#define allp(x) (x)->begin(), (x)->end()

#define pb push_back


using namespace std;
void dout() { cerr << endl; }
typedef long long ll;
template <typename Head, typename... Tail>
void dout(Head H, Tail... T) {
    cerr << H << ' ';
    dout(T...);
}

#define debug(x) cout << #x " = " << (x) << endl


using ll = long long;
using pii = pair<ll, ll>;
using ld = long double;
using pll = pair<long long, long long>;

template <typename T>
void do_uniq(vector<T> vec){
    sort(all(vec));
    vec.resize(unique(all(vec)) - vec.begin());
}



//#define solvsh
//#define multi

#ifdef solvsh


#else

const int MAXN = 200 + 40;
const int MAXLOG = 20;


vector<int> v[10];

vector<int> t;
int n;

void init (int nn)
{
    n = nn;
    t.assign (n, 0);
}

int sum (int r)
{
    int result = 0;
    for (; r >= 0; r = (r & (r+1)) - 1)
        result += t[r];
    return result;
}

void inc (int i, int delta)
{
    for (; i < n; i = (i | (i+1)))
        t[i] += delta;
}

int sum (int l, int r)
{
    return sum (r) - sum (l-1);
}


void solve() {

    int n;
    cin >> n;

    map<string, int> cntrs;
    for (int i = 0 ;  i < n; ++ i){
        string s;
        cin >> s;
        cntrs[s]++;
    }

    cout << "AC x " <<cntrs["AC"] << "\n";
    cout << "WA x " <<cntrs["WA"] << "\n";
    cout << "TLE x " <<cntrs["TLE"] << "\n";
    cout << "RE x " <<cntrs["RE"] << "\n";
}

#endif

void multisolve() {

    int t;
    cin >> t;

    int i = 1;
    while (t--) {
//        cout << "Case #" << (i++) << ": ";
        solve();
//        cout << "\n";
    }
}


#define int int
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr), cout.tie(nullptr);
    cout << fixed << setprecision(20);


#ifdef multi
    multisolve();
#else
    solve();
//    gen();
#endif

}

Measured memory_bytes: 3632
use std::io::*;

fn main() {
    let stdin = stdin();
    let mut buf = String::new();
    let _ = stdin.read_line(&mut buf);
    // println!("{}", buf);
    let x: u64 = buf.trim().parse().unwrap();

    let mut stsf: u64 = 0;

    stsf += x / 500 * 1000;
    let xx = x % 500;
    stsf += xx / 5 * 5;

    println!("{}", stsf);
}



Measured memory_bytes: 4352
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <utility>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstdio>
using namespace std;
#define REP(i,n) for((i)=0;(i)<(int)(n);(i)++)
#define foreach(c,itr) for(__typeof((c).begin()) itr=(c).begin();itr!=(c).end();itr++)
typedef long long ll;
#define INF (1<<29)

long long int euclid(long long int a,long long int b){
	if(a%b==0)return b;
  return euclid(b, a%b);
}

int main(){
	long long int n, x, y, ans;
	cin >> n >> x;
	y=euclid(n, x);
	ans=3*(n/y-1)*y;
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
N = int(input())
D = [[int(i) for i in input().split()] for _ in range(N)]

t = 0
s = 0

for i in range(N):
    if D[i][0] == D[i][1]:
        t += 1
    else:
        t = 0
    if t >= 3:
        s = 1
        break
if s == 1:
    print("Yes")
else:
    print("No")


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

signed main(){
	string  s1, s2, s3;
	cin >> s1 >> s2 >> s3;
	if(s1[s1.size() - 1] == s2[0] && s2[s2.size() - 1] == s3[0]){
		printf("YES\n");
	}
	else{
		printf("NO\n");
	}
	return 0;
}

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

typedef long long ll;
typedef long double ld;

const int MAXN = 15, MAXM = 1007;
const int INF = (int)1e9;
int cost[1 << MAXN];
int u[MAXM], v[MAXM], w[MAXM];
int ww[MAXN][MAXN];
int dp[(1 << MAXN)][MAXN][2];
int main() {
#ifdef LOCAL
	freopen("input.txt", "r", stdin);
#endif
	int n, m;
	cin >> n >> m;
	int sumw = 0;
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < n; j++) {
			ww[i][j] = -INF;
		}
	}
	for (int i = 0; i < m; i++) {
		cin >> u[i] >> v[i] >> w[i];
		u[i]--;
		v[i]--;
		sumw += w[i];
		ww[u[i]][v[i]] = w[i];
		ww[v[i]][u[i]] = w[i];
	}
	for (int i = 0; i < (1 << n); i++) {
		for (int j = 0; j < m; j++) {
			if ((i & (1 << u[j])) && (i & (1 << v[j]))) {
				cost[i] += w[j];
			}
		}
	}
	for (int i = 0; i < (1 << MAXN); i++) {
		for (int j = 0; j < MAXN; j++) {
			for (int k = 0; k < 2; k++) {
				dp[i][j][k] = -INF;
			}
		}
	}
	dp[1][0][0] = 0;
	for (int mask = 0; mask < (1 << n); mask++) {
		for (int last = 0; last < n; last++) {
			if (!(mask & (1 << last))) continue;
			for (int k = 0; k < 2; k++) {
				if (k == 0) {
					dp[mask][last][1] = max(dp[mask][last][1], dp[mask][last][0]);
					int add = ((1 << n) - 1) ^ mask;
					for (int submask = add; submask != 0; submask = (submask - 1) & add) {
						dp[mask | submask][last][1] = max(dp[mask | submask][last][1], dp[mask][last][0] + cost[submask | (1 << last)]);
					}
				} else {
					for (int v = 0; v < n; v++) {
						if (!(mask & (1 << v))) {
							dp[mask | (1 << v)][v][0] = max(dp[mask | (1 << v)][v][0], dp[mask][last][1] + ww[last][v]);
						}
					}
				}
			}
		}
	}
	int res = sumw - dp[(1 << n) - 1][n - 1][1];
	cout << res << endl;
}



Measured memory_bytes: 4224
class Aba
  def initialize
    @a = []
    @a[0]="* = ****".split(//)
    @a[1]="* =* ***".split(//)
    @a[2]="* =** **".split(//)
    @a[3]="* =*** *".split(//)
    @a[4]="* =**** ".split(//)
    @a[5]=" *= ****".split(//)
    @a[6]=" *=* ***".split(//)
    @a[7]=" *=** **".split(//)
    @a[8]=" *=*** *".split(//)
    @a[9]=" *=**** ".split(//)
  end
  def transpose(p)  # p: m(rows) x n(columns)
    m = p.length
    n = p[0].length
    q = Array.new(n).map{Array.new(m)}

    0.upto(m-1){|i|
      0.upto(n-1){|j|
        q[j][i]=p[i][j]
      }
    }
    return q
  end

  def conv(n)
    s = sprintf("%.5d", n).split(//).map{|x|x.to_i}
    m = [@a[s[0]],@a[s[1]],@a[s[2]],@a[s[3]],@a[s[4]]]
    t=m.transpose.map{|x| x.join}
    return t
  end

end

def main
  if true then
    fh=STDIN
  else
    fh=open("in1_0128.txt")
  end

  ab = Aba.new
  glyph = []
  while fh.gets do
    n=$_.chomp.to_i
    glyph.push(ab.conv(n))
  end

  0.upto(glyph.length-1){|i|
    puts glyph[i]
    puts if i != glyph.length-1
  }

end

if $0 == __FILE__ then
  main
end

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

int main(){
	char s[14];int i=0;
	scanf("%s", s);
	for(i=12;i>4;i--){
		s[i]=s[i-1];
	}
	s[4]=' ';
	printf("%s\n",s);
	return 0;
}


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

LL gcd(LL a, LL b) {
  return b ? gcd(b, a % b) : a;
}

int main() {
  LL a, b;
  cin >> a >> b;
  cout << a * b / gcd(a, b) << endl;
}

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

#define _GLIBCXX_DEBUG
#define all(v) (v).begin(),(v).end()

using ll=long long;
using pii=pair<int, int>;
using vi=vector<int>;
using vii=vector<vector<int>>;

const ll LINF=1LL<<60;
const int INF=1<<29;
const ll MOD=1e9+7;

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


int main(){
    int N; cin >> N;
    vi A(N), cnt(1000001, 0);
    for(auto &x : A){
        cin >> x;
        cnt[x]++;
    }

    int g=A[0];
    for(int i=1; i<N; i++){
        g=__gcd(g, A[i]);
    }
    for(int i=2; i<=1000000; i++){
        int a=0;
        for(int j=i; j<=1000000; j+=i){
            a+=cnt[j];
        }
        if(a > 1){
            if(g == 1) cout << "setwise coprime" << endl;
            else cout << "not coprime" << endl;
            return 0;
        }
    }
    cout << "pairwise coprime" << endl;
    return 0;
}

Measured memory_bytes: 11068
program main
  implicit none
  integer, parameter :: A = 1, C = 2, G = 3, T = 4
  integer(8) :: dp(4, 4, 4, 0:100)  ! dp(i, j, k, l) は l 文字目までの3文字が (i, j, k) である場合の数
  integer :: itr, i, j, k, l, n
  integer(8), parameter :: m = 10 ** 9 + 7

  read (*, *) n

  dp(:, :, :, :) = 0
  dp(T, T, T, 0) = 1
  do itr = 1, n
    do i = 1, 4
      do j = 1, 4
        do k = 1, 4
          do l = 1, 4
            if (is_ok(i, j, k, l)) then
              dp(j, k, l, itr) = dp(j, k, l, itr) + dp(i, j, k, itr - 1)
              dp(j, k, l, itr) = modulo(dp(j, k, l, itr), m)
            end if
          end do
        end do
      end do
    end do
  end do

  write (*, "(i0)") modulo(sum(dp(:, :, :, n)), m)

  contains

  pure function is_ok(i, j, k, l)
    integer, intent(in) :: i, j, k, l
    logical :: is_ok
    is_ok = .true.
    if (all([j, k, l] == [A, G, C])) is_ok = .false.
    if (all([j, k, l] == [G, A, C])) is_ok = .false.
    if (all([j, k, l] == [A, C, G])) is_ok = .false.
    if (all([i, k, l] == [A, G, C])) is_ok = .false.
    if (all([i, j, l] == [A, G, C])) is_ok = .false.
  end function is_ok
end program main


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

#include <cstdlib>  // abs() for integer 絶対値求めやつ

#include <cmath>    // abs() for float, and fabs()

#include <algorithm>
#include <vector>
#define rep(i,n) for(int i = 0; i< (n);i++)

#define sort(a) sort((a).begin(),(a).end());

#define che(a,string) cout<<string<<":"<<(a)<<endl;

#define ch(a,string) cout<<string<<":"<<(a)<<" ";

using namespace std;

typedef pair<int,int> p;

int main(){
	int n,m;
	cin>>n>>m;
	cout<<(n-1)*(m-1)<<endl;
}

Measured memory_bytes: 256
x,y,a,b,c=gets.split.map(&:to_i)
l=[]
p=gets.split.map(&:to_i)
q=gets.split.map(&:to_i)
r=gets.split.map(&:to_i)
p.each do |pp|
  l << [pp,0]
end
q.each do |pp|
  l << [pp,1]
end
r.each do |pp|
  l << [pp,2]
end
l.sort!.reverse!
cnt=[0,0,0]
ans=0
l.each do |d,co|
  if cnt[0]+cnt[1]+cnt[2]==x+y
    break
  end
  if co==0&&cnt[0]==x
    next
  elsif co==1&&cnt[1]==y
    next
  end
  ans+=d
  cnt[co]+=1
end
puts ans


Measured memory_bytes: 37812
N,A,B = [int(i) for i in raw_input().split(' ')]
X = [int(i) for i in raw_input().split(' ')]
x_old = X[0]
h = 0
for x in X:
  d = x - x_old
  if d*A>B:
    h += B
  else:
    h += d*A
  x_old = x
print h


Measured memory_bytes: 11808
import sys

def f(d):
    num = 3
    p = [2]
    c = 0
    while num <= 10**5:
        m = int(num**0.5)
        while m > 1 and num % m != 0:
            m -= 1
        if m == 1:
            p.append(num)
            if (num+1)//2 in p:
                c += 1
        d[num] = c
        num += 2
    return d


def main():
    input = sys.stdin.readline
    Q = int(input())
    d = {1: 0, 2: 0}
    d = f(d)
    for _ in range(Q):
        l, r = map(int, input().split())
        l = max(l - 2, 1)
        print(d[r] - d[l])


if __name__ == '__main__':
    main()


Measured memory_bytes: 9524
n = int(input())
people_restriction = [0]*5
for i in range(5):
    people_restriction[i] = int(input())
min_restriction = min(people_restriction)
city = people_restriction.index(min_restriction)

if n % min_restriction == 0:
    count = n//min_restriction
else:
    count = n//min_restriction + 1
ans = count + 4
print(ans)

Measured memory_bytes: 38468
#include <bits/stdc++.h>
#define FOR(i, m, n) for (int i = m; i < (n); i++)
#define RFOR(i, m, n) for (int i = (m - 1); i >= 0; i--)
#define REP(i, n) FOR(i, 0, n)
#define RREP(i, n) RFOR(i, n, 0)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
using namespace std;
typedef long long ll;
const int mod = 1e9 + 7;
const ll INF = 1000000000000000000LL;

ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }

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

ll factorial(ll n) {
  ll answer = 1;
  while (n > 1) {
    answer *= n;
    answer %= mod;
    n--;
  }
  return answer;
}

ll combination(ll n, ll r) {
  return factorial(n) / (factorial(r) * factorial(n - r));
}

ll permutation(ll n, ll r) { return factorial(n) / factorial(n - r); }

template <typename T>
void remove(std::vector<T>& vector, unsigned int index) {
  vector.erase(vector.begin() + index);
}

map<ll, ll> prime_factor(ll n) {
  map<ll, ll> ret;
  for (ll i = 2; i * i <= n; i++) {
    while (n % i == 0) {
      ret[i]++;
      n /= i;
    }
  }
  if (n != 1) ret[n] = 1;
  return ret;
}
// for (auto p : prime_factor(n)) {
//	while (p.second--) {
//		cout << p.first << endl;
//	}
//}

vector<ll> divisor(ll n) {
  vector<ll> ret;
  for (ll i = 1; i * i <= n; i++) {
    if (n % i == 0) {
      ret.push_back(i);
      if (i * i != n) ret.push_back(n / i);
    }
  }
  sort(begin(ret), end(ret));
  return (ret);
}

bool compare_by_b(pair<ll, ll> a, pair<ll, ll> b) {
  if (a.second != b.second) {
    return a.second < b.second;
  } else {
    return a.first < b.first;
  }
}

vector<ll> Eratosthenes(const ll N) {
  bool is_prime[1000000 + 1];
  vector<ll> P;
  for (ll i = 0; i <= N; i++) {
    is_prime[i] = true;
  }
  for (ll i = 2; i <= N; i++) {
    if (is_prime[i]) {
      for (ll j = 2 * i; j <= N; j += i) {
        is_prime[j] = false;
      }
      P.emplace_back(i);
    }
  }
  return P;
}

typedef vector<int> ivec;
typedef vector<string> svec;
typedef vector<ll> lvec;

int main() {
  int n, m;
  cin >> n >> m;
  n--;
  m--;
  cout << n * m << endl;
  return 0;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
H,W,D = map(int,readline().split())
X = [(0,0) for _ in range(H*W)]
Y = [0 for _ in range(H*W)]

for i in range(H):
    A = [int(x)-1 for x in readline().split()]
    for j in range(W):
        X[A[j]] = (i,j)

for i in range(0,H*W-D):
    Y[i+D] = Y[i] + abs(X[i+D][0] - X[i][0]) + abs(X[i+D][1] - X[i][1])

Q = int(readline())
for _ in range(Q):
    L,R = map(int,readline().split())
    print(Y[R-1]-Y[L-1])

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

int main(){
  int A,B;
  cin >> A >> B;
  
  if(A - B > 1){
    cout << 2 * A - 1 << endl;
  }
  
  else if(B - A > 1){
    cout << 2 * B - 1 << endl;
  }
  
  else if(A - B == 1 || B - A == 1){
    cout << A + B << endl;
  }
  
  else if(A == B) {
    cout << 2 * A << endl;
  }
  
}

Measured memory_bytes: 256
/* ---------- STL Libraries ---------- */
// IO library
#include <cstdio>

#include <fstream>
#include <iomanip>
#include <ios>
#include <iostream>

// algorithm library
#include <algorithm>

#include <cmath>
#include <numeric>
#include <random>
#include <cstring>
#include <cassert>

// container library
#include <array>
#include <bitset>
#include <deque>
#include <map>
#include <unordered_map>
#include <queue>
#include <set>
#include <string>
#include <tuple>
#include <vector>
#include <stack>

// type
#include <cstdint>
#include <functional>

/* ---------- Namespace ---------- */
using namespace std;

/* ---------- Type ---------- */
using ll = long long;
#define int ll
template <class T> using MaxHeap = priority_queue<T>;
template <class T> using MinHeap = priority_queue<T, vector<T>, greater<T>>;
#define P pair<ll, ll>

/* ---------- Constants  */
const double PI = 3.141592653589793238462643383279;
const ll MOD = 1e9 + 7;
const int INF = 1LL << 55;

/* ---------- Functions */
template<class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (a > b) { a = b; return true; } return false; }

/* v-v-v-v-v-v-v-v-v Main Part v-v-v-v-v-v-v-v-v */
signed main() {
    cin.sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

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

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

    if (N %2 == 0) {
        int idx1 = N/2 - 1;
        int idx2 = N/2;
        cout << B[idx1] + B[idx2] - A[idx1] - A[idx2] + 1 << endl;
    } else {
        int idx = N/2;
        cout << B[idx] - A[idx] + 1 << endl;
    }

    return 0;
}

Measured memory_bytes: 6340
#!/usr/bin/env python
from collections import defaultdict, deque
import math
from math import factorial
import fractions
import re

BIGNUM = 10 ** 9 + 7

def main():
    N = int(input())
    As = list(map(int, input().split()))
    Bs = list(map(int, input().split()))

    num = 0
    for i in range(N):
        idx = (N - 1) - i
        B = Bs[idx]
        A_prev = As[idx+1]
        A = As[idx]
        num_prev_monster = min([A_prev, B])
        B -= num_prev_monster
        num_monster = min([A, B])
        As[idx] -= num_monster
        num += num_prev_monster + num_monster

    print(num)

if __name__ == '__main__':
    main()


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

ll X, K, D;

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

  // Xが負の場合には正負を逆転する
  if (X < 0) X *= -1;

  // X < Dの場合は最初から両端にいる
  // Kのパリティを考える
  if (X < D && K%2==1) cout << abs(X-D) << endl;
  else if (X < D && K%2==0) cout << X << endl;

  // 左側に突き進んでも原点の右側の候補地点にたどり着けない場合
  else if ((X/D) >= K) cout << X - (K * D) << endl;

  // 十分に移動回数が多い場合
  else {
    // 右側の候補地点にたどり着いたあとに残っている移動回数のパリティを考える
    if ((K-(X/D))%2==0) cout << X%D << endl;
    else cout << abs((X%D)-D) << endl;
  }
}

Measured memory_bytes: 3604
#pragma comment(linker, "/stack:20000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx")

#include<bits/stdc++.h>
/*#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#include<ext/pb_ds/detail/standard_policies.hpp>*/

#define sz(s) (int)(s.size())
#define all(s) s.begin(), s.end()
#define rep(a, b, c) for(int a = b; a <= c; ++a)
#define per(a, b, c) for(int a = b; a >= c; --a)
#define _ ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

using namespace std;
//using namespace __gnu_pbds;

typedef unsigned long long ull;
typedef long long ll;
/*typedef tree<pair<int, int>, 
null_type, less<pair<int, int>>, 
rb_tree_tag, tree_order_statistics_node_update>
ordered_set;*/
//find_by_order() order_of_key()

const double eps = 1e-7;
const int mod = 1e9+7, MXN = 5e5+17;
const int dx[] = {0,0,1,-1}, dy[] = {1,-1,0,0};

template<typename T>inline bool updmin(T &a, const T &b) {return a > b ? a = b,1 : 0;}
template<typename T>inline bool updmax(T &a, const T &b) {return a < b ? a = b,1 : 0;}

int32_t main() { _
#ifdef DanQQQQQ
	freopen(".in","r",stdin);
	freopen(".out","w",stdout);
#endif
	int n, k, x, y; cin >> n >> k >> x >> y;
	cout << x*min(n,k)+y*(n-min(n,k)) << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
const int INF = 1e9;
const int MOD = 1e9+7;
const long long LINF = 1e18;
#define dump(x)  cout << 'x' << ' = ' << (x) << ` `;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)
#define FOREACH(x,a) for(auto& (x) : (a) )
typedef long long ll;
using namespace std;
int main(int argc, char const *argv[]) {
    int n;
    cin >> n;
    int x = 0;
    int c = 0;
    while(x < n){
        c++;
        x += c;
    }
    int y = x-n;

    for (int i = 1; i <= c; ++i) {
        if (i == y) continue;
        cout << i << std::endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ul;
typedef signed long long ll;
ul over = 1000000007;

// step, x, y
typedef tuple< int, int, int > node;

int main(void)
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed;
  int h, w;
  cin >> h >> w;
  char maze[h][w];
  int score = 0;
  for (int i=0; i<h; ++i) {
    for (int j=0; j<w; ++j) {
      cin >> maze[i][j];
      if (maze[i][j] == '.') score++;
    }
  }
  priority_queue< node, vector< node >, greater< node > > q;
  node r = make_tuple(0, 0, 0);
  q.push(r);
  vector< int > dx = {-1, 1, 0, 0};
  vector< int > dy = {0, 0, -1, 1};
  while (!q.empty()) {
    auto t = q.top();
    q.pop();
    int nscore = get<0>(t), nx = get<1>(t), ny = get<2>(t);
    if (nx==h-1 && ny==w-1) {
      cout << score - (nscore+1) << endl;
      return 0;
    }
    for (int d=0; d<4; ++d) {
      int x = nx+dx[d], y = ny+dy[d];
      if (maze[x][y] == '#') continue;
      if (x < 0 || h <= x || y < 0 || w <= y) continue;
      node next = make_tuple(nscore+1, x, y);
      q.push(next);
      maze[x][y] = '#';
    }
  }
  cout << -1 << endl;
  return 0;
}


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

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int b[] = new int[n - 1];
		int c[] = new int[n];
		for(int i = 0 ; i < n - 1 ; i++) {
			b[i] = sc.nextInt();
		}
		for(int i = 0 ; i < n - 1 ; i++) {
			if(i == 0) {
				c[i] = b[i];
			} else {
				c[i] = Math.min(b[i - 1], b[i]);
			}
		}
		c[n - 1] = b[n - 2];
		int ans = Arrays.stream(c).sum();
		System.out.println(ans);
		sc.close();

	}

}


Measured memory_bytes: 27728
#include <sstream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <iostream>
#include <utility>
#include <set>
#include <cctype>
#include <queue>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>

using namespace std;

int main() {
	int n;
	vector <int> a;
	vector <int> b;
	vector <int> c;
	cin >> n;
	for (int i = 0; i < n; i++) {
		int tmp;
		cin >> tmp;
		a.push_back(tmp);
	}
	for (int i = 0; i < n; i++) {
		int tmp;
		cin >> tmp;
		b.push_back(tmp);
	}
	for (int i = 0; i < n; i++) {
		int tmp;
		cin >> tmp;
		c.push_back(tmp);
	}

	vector <long long> ab(n);
	vector <long long> bc(n);
	sort(a.begin(), a.end());
	sort(b.begin(), b.end());
	sort(c.begin(), c.end());
	int j = 0;
	for (int i = 0; i < n; i++) {
		if (i > 0) {
			ab[i] = ab[i - 1];
		}
		while (b[i] > a[j] && j < n) {
			ab[i]++;
			j++;
		}
	}
	j = 0;
	for (int i = 0; i < n; i++) {
		if (i > 0) {
			bc[i] = bc[i - 1];
		}
		while (c[i] > b[j] && j < n) {
			bc[i] += ab[j];
			j++;
		}
	}
	long long ret = 0;
	for (int i = 0; i < n; i++) {
		ret += bc[i];
	}

	cout << ret << endl;
	return 0;
}



Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
int main() {
string S; 
cin >> S; 
  int A = -1, B = -1; 
for(int i = 0; i < S.size()-1; i++){
if(S.at(i) == S.at(i+1)){
A = i + 1, B = i + 2;
break; 
}
}
if(S.size() > 2){
for(int i = 0; i < S.size()-2; i++){
if(S.at(i) == S.at(i+2)){
A = i + 1, B = i + 3;
break; 
}
}
}
  cout << A << " " << B << endl; 
}

Measured memory_bytes: 512
#include <stdio.h>
#include <math.h>

long long int ans[110] ;

void init ( ) ;

int main ( )
{
	int N ;
	init ( ) ;
	while ( scanf ( "%d" , &N ) == 1 ) {
		printf ( "%lld\n" , ans[N] ) ;
	}
	return 0 ;
}

void init ( )
{
	ans[0] = 100000 ; 
	for ( int i = 1 ; i < 101 ; i++ ) {
		long long int tmp = ans[i-1] * 105 / 100 ;
		if ( tmp % 1000 > 0 ) {
			long long int s = tmp % 1000 ;
			tmp = tmp + 1000 - s ;
		}
		ans[i] = tmp ;
	}
}

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

int main(){
  int maxa, maxb, m;
  cin >> maxa >> maxb >> m;
  
  vector<int> pa(maxa), pb(maxb);
  
  int mpa=1000000, mpb=1000000;
  
  for(int i=0; i<maxa; i++){
    cin >> pa[i];
    mpa = min(mpa, pa[i]);
  }
  
  for(int i=0; i<maxb; i++){
    cin >> pb[i];
    mpb = min(mpb, pb[i]);
  }
  
  int minp = mpa + mpb;
  
  int x,y,c;
  for(int i=0; i<m; i++){
    cin >> x >> y >> c;
    minp = min( minp, pa[x-1] + pb[y-1] - c);
  }
  
  cout << minp << endl;
  
  return 0;
}

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

int main(){
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    if(abs(a - c) <= d)cout << "Yes" << endl;
    else if(abs(a - b) <= d && abs(b - c) <= d)cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 3580
/* ANTHOR KUMAR DAS
KUET ECE 2K18*/
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define sc(a) scanf("%d",&a)
#define sc1(n) scanf("%lld",&n)
#define sc2(b,c) scanf("%lld%lld",&b,&c)
#define f(a,b) for(a=0;a<b;a++)
#define pb(a) push_back(a)
#define br break
int main()
{
    ll int n,a=1,b,c,k,i;
    cin>>n;
    k=sqrt(n);
    for(i=2;i<=k;i++)
    {
        if(n%i==0)
        {
            a=i;
        }
    }
    b=n/a;
    c=a+b-2;
    cout<<c<<endl;

    return 0;

}



Measured memory_bytes: 256
x, y = map(int, input().split())
ans = 0
if abs(x) > abs(y):
    if y > 0:
        if x > 0:
            ans += 2
        elif x < 0:
            ans += 1
        ans += abs(x) - y
        print(ans)
        exit()
    else:
        if x > 0:
            ans += 1
        ans += abs(x) - abs(y)
        print(ans)
        exit()
else:
    if y > 0:
        if x < 0:
            ans += 1
        ans += y - abs(x)
        print(ans)
        exit()
    else:
        if x >= 0:
            ans += 1
        elif x < 0:
            ans += 2
        ans += abs(y) - abs(x)
        print(ans)
        exit()

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

int H[200005];
long long BIT[200005];

void update(int i, long long val)
{
    for(; i<=200000; i+= (i&(-i)))
        BIT[i] = max(BIT[i], val);
}

long long query(int i)
{
    long long ans = 0;
    
    for(; i>0; i-= (i&(-i)))
        ans = max(ans, BIT[i]);
    
    return ans;
}

int main() {

    ios::sync_with_stdio(0);
    cin.tie(NULL), cout.tie(NULL);
    
    int N;
    cin >> N;
    
    for(int i=1; i<=N; i++)
        cin >> H[i];
    
    long long ans = 0;
    
    for(int i=1; i<=N; i++)
    {
        int x;
        cin >> x;
        
        long long currAns = query(H[i]) + x;
        update(H[i], currAns);
        
        ans = max(ans, currAns);
    }
    
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 2560
#include <stdio.h>

int main(void) {
  FILE *fp;
  //fp = fopen("input/rgb_cards_01.txt", "r");
  fp = stdin;
  char line[1024];
  int num1, num2, num3;
  int flag = 0;
  if(!fgets(line, 1024, fp)) return 0;
  sscanf(line, "%d %d %d", &num1, &num2, &num3);
  if((num2&1 && ((num3&3)==2)) || 
      ((!(num1&3)) && (!(num3&3)))
      ) {
    flag = 1;
  } else {
    flag = 0;
  }
  printf("%s\n", flag ? "YES" : "NO");
  return 0;
}

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

#define rep(i, x, n) for (int i = x; i < n; i++)
typedef long long ll;

const int INF = 1e9 + 7;

using namespace std;

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

  int n;
  cin >> n;

  vector<int> h(n);
  rep (i, 0, n)
    cin >> h[i];

  int res = 0;
  int tmp = 0;
  rep (i, 0, n-1) {
    if (h[i+1] <= h[i]) {
      tmp++;
    } else {
      res = max(res, tmp);
      tmp = 0;
    }
  }

  res = max(res, tmp);
  cout << res << endl;
	return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define rep(i,ini,n) for(int i=ini;i<n;i++)
#define _rep(i,ini,n) for(int i=ini;i>=n;i--)
#define ToEnd(a) a.begin(),a.end()
uint64_t MOD=1000000007;

int main(){
    int N,K; cin>>N>>K;
    string S; cin>>S;
    
    vector<int> V(N,0);
    int idx=0,vIdx=0;
    rep(i,1,N){
        if(S.at(i-1)!=S.at(i)){
            V.at(vIdx)=pow(-1,S.at(i-1)-'0'+1)*(i-idx);

            idx=i;
            vIdx++;
        }
    }
    V.at(vIdx)=pow(-1,S.at(N-1)-'0'+1)*(N-idx);

    vector<int> sumV{0};
    rep(i,1,N+1){
        if(V.at(i-1)==0) break;
        sumV.push_back(sumV.at(i-1)+abs(V.at(i-1)));
    }
    int ans=0;
    for(int i=0;i<sumV.size();i+=2){
        if(V.front()>0){
            ans=max(ans,sumV.at(min((int)sumV.size()-1,2*K+1+i))-sumV.at(i));
        }else{
            ans=max(ans,sumV.at(min((int)sumV.size()-1,2*K+i))-sumV.at(max(0,i-1)));
        }
    }
    cout<<ans<<endl;

}

Measured memory_bytes: 1404
from collections import deque
H, W = map(int, input().split())  # 迷路の縦、横の長さ
maze = []
for _ in range(H):
    maze.append(input())
# print(maze)
dist = [[-1] * W for iii in range(H)]  # スタートからの距離
check_que = deque()

d = 0

for i in range(H):
    for j in range(W):
        if maze[i][j] == "#":
            dist[i][j] = 0
            check_que.append((i, j))
# print(dist)


def bfs(initial_d):  # distを編集する関数
    dis = 0
    #print("{},{}".format(tate, yoko))
    while len(check_que) != 0:

        h, w = check_que.popleft()
        d = dist[h][w]
        for dh, dw in ((0, 1), (0, -1), (1, 0), (-1, 0)):
            h_prime, w_prime = h + dh, w + dw

            if 0 <= h_prime <= H - 1 and 0 <= w_prime <= W - 1:
                if dist[h_prime][w_prime] == -1:
                    dist[h_prime][w_prime] = d + 1
                    check_que.append((h_prime, w_prime))
                    if d + 1 > dis:
                        dis = d+1
    return dis


dis = bfs(0)
# print(dist)
print(dis)


Measured memory_bytes: 86876
using System;
using System.Collections;
using System.Collections.Generic;

class Program {
    static void Main (string[] args) {
        var tempstr = Console.ReadLine ().Split (' ');
        int H = int.Parse (tempstr[0]);
        int W = int.Parse (tempstr[1]);
        int K = int.Parse (tempstr[2]);
        ulong table = 0;
        for (int i = 0; i < H; i++) {
            var tempstr2 = Console.ReadLine ().ToCharArray ();
            for (int j = 0; j < W; j++) {
                if (tempstr2[j] == '#') {
                    table += ((ulong) 1 << (W * i + j));
                }
            }
        }
        int ans = 0;
        for (int bit = 0; bit < (1 << (H + W)); bit++) {
            ulong tabledash = ~table;
            for (int i = 0; i < H + W; i++) {
                if ((1 & (bit >> i)) == 1) {
                    if (i < H) {
                        for (int k = 0; k < W; k++) {
                            tabledash |= ((ulong) 1 << (W * i + k));
                        }
                    } else {
                        for (int k = 0; k < H; k++) {
                            tabledash |= ((ulong) 1 << (i - H + W * k));

                        }
                    }
                }
            }
            tabledash = ~tabledash;
            int num = 0;
            for (int i = 0; i < H * W; i++) {
                if (((ulong) 1 & (tabledash >> i)) == 1) {
                    num++;
                }
            }
            if (num == K) {
                ans++;
            }
        }
        Console.WriteLine (ans);
    }

}

//dotnet run --project test

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

int main(){
while(1){
	int n,m;
	vector<int> p,q;
	scanf("%d%d",&n,&m);
if(n==0&&m==0)break;
	q.push_back(0);
	for(int i=0;i<n;i++){
		int a;
		scanf("%d",&a);
		p.push_back(a);
		q.push_back(a);
	}
	for(int i=0;i<n;i++){
		for(int j=i;j<n;j++){
			q.push_back(p[i]+p[j]);
		}
	}
	sort(q.begin(),q.end());
	int ans=0;
	int f=0,s=q.size()-1;
	while(1){
		if(q[f]+q[s]>ans&&q[f]+q[s]<=m)ans=q[f]+q[s];
		if(q[f]+q[s]<=m)f++;
		if(q[f]+q[s]>m)s--;
		if(f>s)break;
	}
	printf("%d\n",ans);
}
}

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

int main() {
    double a, b, h, m;
    cin >> a >> b >> h >> m;
    double angle_h = h/12.0*360 + 0.5*m, angle_m = m/60.0*360;
    double angle = min(abs(angle_h - angle_m), 360.0 - abs(angle_h - angle_m));
    double ans = a*a + b*b - 2.0*a*b*cos(angle*3.14159265358979/180.0);
    ans = pow(ans, 0.5);
    printf("%.15f\n", ans);

    return 0;
}


Measured memory_bytes: 4372
#include <iostream>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <queue>
#include <vector>
#include <algorithm>
#include <map>

int main(){

  int N, W;
  scanf("%d", &N);
  scanf("%d", &W);
  std::vector<int > v(N), w(N);
  std::vector< std::vector<int > > dp(N, std::vector<int > (W+1, 0));
  for (int i=0; i<N; i++){
    scanf("%d",&v[i]);
    scanf("%d",&w[i]);
  }

  for (int i=0; i<N; i++){
    for (int j=0; j<=W; j++){
      if (j<w[i]){
        dp[i][j] = dp[std::max(i-1, 0)][j];
      } else {
        dp[i][j] = std::max(dp[std::max(i-1,0)][j], dp[i][j-w[i]]+v[i]);
      }
    }
  }
  printf("%d\n", dp[N-1][W]);
  return 0;
}



Measured memory_bytes: 6828
#include <iostream>
using namespace std;
int main(void){
   int A[5];
   cin>>A[0]>>A[1]>>A[2]>>A[3]>>A[4];
 for(int i=0;i<5;i++){
     if(A[i]==0){
         cout<<i+1<<endl;
     }
 }
    
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll n,a[2010];
ll dp[2010][2010];//残りピース数、開始位置
int main(){
	cin>>n;
	for(int i=0;i<n;i++)	cin>>a[i];
	memset(dp,-1,sizeof(dp));
	for(int i=0;i<n;i++)	dp[n-1][(i+1)%n]=a[i];//最初の１ピースの処理
	for(int i=n-1;i>0;i--){//ケーキの残り個数
		for(int j=0;j<n;j++){//ケーキの開始位置
			int k=(i+j-1)%n;//ケーキの終了位置
			if((n-i)&1){//IOIのターン
				if(a[j]<a[k])	dp[i-1][j]=max(dp[i-1][j],dp[i][j]);
				else 	dp[i-1][(j+1)%n]=max(dp[i-1][(j+1)%n],dp[i][j]);
			}
			else{//JOIのターン
				dp[i-1][j]=max(dp[i-1][j],dp[i][j]+a[k]);
				dp[i-1][(j+1)%n]=max(dp[i-1][(j+1)%n],dp[i][j]+a[j]);
			}
		}
	}
	ll ans=0;
	for(int i=0;i<n;i++){
		ans=max(ans,dp[0][i]);
	}
	cout<<ans<<endl;
	return 0;
}

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

int main() {
  int N;
  cin >> N;
  int a[N];
  for (int i = 0; i < N; i++) cin >> a[i];

  int multi_4 = 0, even = 0, odd = 0;
  for (int i = 0; i < N; i++) {
    if (a[i] % 4 == 0) multi_4++;
    else if (!(a[i] & 1)) even++;
    else odd++;
  }
  N -= (even % 2 == 0 ? even : even - 1);

  // 解答
  cout << (multi_4 >= N / 2 ? "Yes" : "No") << endl;

  return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int> >;
#define rep(i, n)         for(int i = 0; i < (int)(n); i++)
#define brep(n)           for(int bit=0;bit<(1<<n);bit++)
#define erep(i,container) for (auto i : container)
#define irep(i, n)        for(int i = n-1; i >= (int)0; i--)
#define rrep(i,m,n) for(int i = m; i < (int)(n); i++)
#define reprep(i,j,h,w) rep(i,h)rep(j,w)
#define all(x) (x).begin(),(x).end()
#define aall(x,n) (x).begin(),(x).begin()+(n)
#define VEC(type,name,n) std::vector<type> name(n);rep(i,n)std::cin >> name[i];
#define pb push_back
#define pf push_front
#define lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#define itn int
#define mp make_pair
#define sum accumulate
#define keta fixed<<setprecision
#define vvector(name,typ,m,n,a)vector<vector<typ> > name(m,vector<typ> (n,a))
#define vvvector(name,t,l,m,n,a) vector<vector<vector<t> > > name(l, vector<vector<t> >(m, vector<t>(n,a)));
#define vvvvector(name,t,k,l,m,n,a) vector<vector<vector<vector<t> > > > name(k,vector<vector<vector<t> > >(l, vector<vector<t> >(m, vector<t>(n,a)) ));
typedef long long ll;
const int INF = 2000000000;
const ll INF64 = 9223372036854775806ll;
const int mod = 1000000007ll;
const ll  MOD = 1000000007LL;
/*メモ 
*/
int main(){
    int a,s,d;
    std::cin >> a>>s>>d;
    std::cout << min(a*s,d) << std::endl;
}

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

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

typedef long long ll;

#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
//定数
#define INF 1000000000 //10^9:極めて大きい値,∞
//略記
#define PB push_back //vectorヘの挿入
#define MP make_pair //pairのコンストラクタ
#define F first //pairの一つ目の要素
#define S second //pairの二つ目の要素

vector<int> c(26);
vector<vector<int>> s(365 ,vector<int>(26));
vector<vector<int>> last(365 ,vector<int>(26));

int calc(int d){
    int k=10;
    int ret=1;
    ll maxv=-INF;
    rep(j,26){
        ll v=s[d][j]+c[j]*(d+1-last[d][j]);
        rep(i,k) v-=c[j]*k;
        if(v>maxv){
            maxv=v;
            ret=j+1;
        }
    }
    return ret;
}

int main(){
    int D;
    cin>>D;
    rep(i,26){ 
        cin>>c[i];
    }
    rep(d,D) rep(j,26) cin>>s[d][j];
    int t;
    int v=0;
    vector<int> kaisai_bi(26);
    int ans=18398+s[1][16];
    rep(j,26){
        if(j==16)continue;
        else if(j==0)ans-=c[j]*(2-1);
        else ans-=c[j]*(2-0);
    }
    rep(d,D) {
//        cin>>t;
        t=calc(d);
        cout<<t<<endl;
        t--;
        v+=s[d][t];
        kaisai_bi[t]=d+1;
        rep(j,26) last[d][j]=kaisai_bi[j];
        rep(j,26){ 
            v-=c[j]*(d+1-last[d][j]);
            }
    }
//    cout<<v<<endl;

    int m;
//    cin>>m;
m=0;
    rep(i,m){
        int dd,q;
        cin>>dd>>q;
        q--;
        int j=0;
        while(last[dd-1][j]!=dd || j>=26) j++;
        if(j==26){ 
            cout<<"error"<<endl;
            return 0;
        }
        v-=s[dd-1][j];
        for(int d=dd-1;d<D;d++){ 
            if(last[d][j]==dd){
                v+=c[j]*(d+1-last[d][j]);
                last[d][j]=(d==0? 0 : last[d-1][j]);
                v-=c[j]*(d+1-last[d][j]);
            }
            else{ 
                break;
            }
        }
        
        v+=s[dd-1][q];
        int before=last[dd-1][q];
        for(int d=dd-1;d<D;d++){ 
            if(last[d][q]==before){ 
                v+=c[q]*(d+1-last[d][q]);
                last[d][q]=dd;
                v-=c[q]*(d+1-last[d][q]);
            }
            else{ 
                break;
            }
        }
        cout<<v<<endl;
    }
    return 0;
}


Measured memory_bytes: 3704
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n,m;
    cin >> n >> m;
    vector<set<int>> path(n);
    for(int i=0; i<m; i++){
        int a,b;
        cin >> a >> b;
        path.at(a-1).insert(b-1);
        path.at(b-1).insert(a-1);
    }
    queue<int> q;
    vector<int> depth(n,-1);
    vector<int> done(n,0);
    vector<int> parent(n,0);
    q.push(0);
    done.at(0) = 1;
    depth.at(0) = 0;
    while(! q.empty()){
        int front = q.front();
        done.at(front) = 1;
        for(auto value : path.at(front)){
            if(done.at(value)==0){
                q.push(value);
                done.at(value) = 1;
                depth.at(value) = depth.at(front)+1;
                parent.at(value) = front;
            }
        }
        q.pop();
    }
    
    for(int i=0; i<n; i++){
        if(depth.at(i) == -1){
            cout << "No" << endl;
            return 0;
        }
    }
    
    cout << "Yes" << endl;
    for(int i=1; i<n; i++){
        cout << parent.at(i) + 1 << endl;
        //cout << depth.at(i)  << endl;
    }
}


Measured memory_bytes: 28232
#include<iostream>
#include<map>
#include<string>
#include<algorithm>
using namespace std;

int main(){
  string s;
  cin >> s;
  int num = s.substr(1,s.length()-2).length();
  cout << s[0] << num << s[s.length()-1] << endl;

  return 0;
}

Measured memory_bytes: 256
/**
 *    author:  FromDihPout
 *    created: 2020-08-10
**/

#include <bits/stdc++.h>
using namespace std;

#define f first
#define s second
#define all(x) (x).begin(), (x).end()

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int n, c;
    cin >> n >> c;
    vector<pair<pair<int,int>, int>> a(n);
    for (int i = 0; i < n; i++) {
        int s, t, c;
        cin >> s >> t >> c;
        a[i] = {{s, t}, c};
    }
    sort(all(a));
    
    vector<pair<int,int>> r(c, {-1, -1});
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < c; j++) {
            if (a[i].s == r[j].s && a[i].f.f >= r[j].f) {
                r[j].f = a[i].f.s;
                break;
            }
            else if (a[i].f.f - 0.5 >= r[j].f) {
                r[j].f = a[i].f.s;
                r[j].s = a[i].s;
                break;
            }
        }
    }
    
    int ans = 0;
    for (int i = 0; i < c; i++) {
        if (r[i].f != -1) {
            ans++;
        }
    }
    cout << ans << '\n';
    return 0;
}

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

using namespace std;

int main(){
  	int r = 0, b = 0, n;
  	string s;
  	cin >> n;
  	cin >> s;
  	for (int i = 0; i < n; i++){
  	    if (s[i] == 'R'){
  	        r++;
  	    }
  	    else{
  	        b++;
  	    }
  	}
  	if (r > b){
  	    cout << "Yes";
  	}
  	else {
  	    cout << "No";
  	}
 	return 0; 
}

Measured memory_bytes: 256
#k = int(input())
#s = input()
#a, b = map(int, input().split())
#s, t = map(str, input().split())
#l = list(map(int, input().split()))
#l = [list(map(int,input().split())) for i in range(n)]
#a = [list(input()) for _ in range(n)]
#a = [int(input()) for _ in range(n)]


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

print( min(n*a, b) )



Measured memory_bytes: 9048