akhauriyash/Code-Regression huggingface dataset:
//
//  atcoder.cpp
//
//
///
#include <bits/stdc++.h>
#include <boost/optional.hpp>
#include <boost/range/irange.hpp>
#include <boost/range/algorithm.hpp>
#include <boost/range/numeric.hpp>
#include <boost/bimap/bimap.hpp>
#include <boost/bimap/multiset_of.hpp>
#include <boost/multi_array.hpp>
#include <boost/math/common_factor.hpp>
#include <boost/algorithm/string.hpp>

#define REP(i, N) for(int i=0; i<(N); i++)
#define REC(f, ...) (void)0; const auto f = [&](const auto f, __VA_ARGS__)
using namespace std;
using namespace boost::math;

using ll = long long;
namespace bst = boost;
template<typename T> class in {
    T value;
public:
    in() { cin >> value; }
    operator const T&() const { return value; }
    operator T&() { return value; }
    in& operator=(T source) { value = source; return *this; }
};
template<> class in<string> : public string {
public:
    in() { cin >> *this; }
};
template<class T> class inseq : public T {
public:
    template<typename... Arg> inseq(Arg... arg) : T(forward<Arg>(arg)...) { for (auto&& i : *this) cin >> i; }
};
template<class T> using invec = inseq<vector<T>>;

auto solve() {
  in<int> N;
  map<string,int> m;
  int mx = 0;
  
  REP(i,N) {
    string a;
    cin >> a;
    m[a]++;
    mx = max(mx, m[a]);
  }

  for (auto& s : m) {
    if (s.second == mx)
      cout << s.first << endl;
  }
}

template<typename T> void plot(const T& func) { cout << func() << endl; }
template<> void plot<void()>(void(&func)()) { func(); }
template<> void plot<double()>(double(&func)()) { cout << setprecision(9) << func() << endl; }

int main() {
  plot(solve);

  return 0;
}


Measured memory_bytes: 25216
dishes = []
for i in range(5):
    dishes.append(int(input()))

wasted_times = []
for dish in dishes:
    wasted_time = (10 - (dish % 10)) % 10
    wasted_times.append(wasted_time)

wasted_times.sort()
del wasted_times[-1]

ans = sum(dishes) + sum(wasted_times)
print(ans)


Measured memory_bytes: 9140
import java.util.Arrays;
import java.util.Scanner;
import java.lang.*;
import java.io.*;

public class Main
{
	public static void main(String args[]) throws java.lang.Exception,FileNotFoundException
	{
		Scanner sc = new Scanner(System.in);

		// PrintStream obj = new PrintStream(new File("Output.txt"));
		// PrintStream console = System.out;
		// System.setOut(obj);

		int X = sc.nextInt();
		int N = sc.nextInt();

		int min = 0;
		int max = 101;

		int[] arr =  new int[N];

		for(int i = 0;i<N;i++)
		{
			arr[i] = sc.nextInt();
		}

		for(int i = 0;i<=100;i++)
		{
			int num1 = X - i;
			int num2 = X + i;

			int count1 = 0;
			int count2 = 0;

			for(int j = 0;j<N;j++)
			{
				if(arr[j] == num1)
					count1++;

				if(arr[j] == num2)
					count2++;
			}

			if(count1 == 0)
			{
				System.out.println(num1);
				break;
			}

			else if(count2 == 0)
			{
				System.out.println(num2);
				break;
			}
		}

		System.out.flush();
	}
}

Measured memory_bytes: 27076
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <cstring>
#include <sstream>
#include <cassert>
using namespace std;
static const double EPS = 1e-10;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> PI;
#define rep(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
#define mp(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define SZ(a) (int(a.size()))
#define F first
#define S second
const double pi=acos(-1);
int dx[]={0,1,0,-1},dy[]={1,0,-1,0};

vector<PI> pea;

main(){
  int n,w,d;
  while(cin>>n>>w>>d,w){
    pea.clear();
    pea.pb(mp(w,d));
    rep(i,n){
      int p,s;
      cin>>p>>s;
      --p;
      PI tp=pea[p];
      for(int i=p;i<SZ(pea)-1;i++)pea[i]=pea[i+1];
      pea.pop_back();
      s%=(tp.F+tp.S)*2;
      PI t1,t2;
      if(s<tp.F){
        t1=mp(tp.F-s,tp.S);
        t2=mp(s,tp.S);
      }else if(s<tp.F+tp.S){
        t1=mp(tp.F,tp.S+tp.F-s);
        t2=mp(tp.F,s-tp.F);
      }else if(s<tp.F*2+tp.S){
        t1=mp(tp.F*2+tp.S-s,tp.S);
        t2=mp(s-tp.S-tp.F,tp.S);
      }else{
        t1=mp(tp.F,tp.F*2+tp.S*2-s);
        t2=mp(tp.F,s-tp.F*2-tp.S);
      }
      if(t1.F*t1.S>t2.F*t2.S)swap(t1,t2);
      pea.pb(t1),pea.pb(t2);

    }
    vector<int> ans;
    rep(i,SZ(pea))ans.pb(pea[i].F*pea[i].S);
    sort(ALL(ans));
    rep(i,SZ(ans)){
      if(i)cout<<' ';
      cout<<ans[i];
    }
    cout<<endl;
  }
}

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

using namespace std;

#define FOR(i,k,n) for(int i=(k); i<(int)n; ++i)
#define REP(i,n) FOR(i,0,n)
#define FORIT(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)

template<class T> void debug(T begin, T end){ for(T i = begin; i != end; ++i) cout<<*i<<" "; cout<<endl; }

typedef long long ll;
const int INF = 100000000;
const double EPS = 1e-8;
const int MOD = 1000000007;

int main(){
  int M;
  cin>>M;
  while(M--){
    int L; cin>>L;
    string s; cin>>s;
    //cout<<s<<endl;
    int N = s.size();
    int ans = 0;
    int c[2] = {};
    REP(i, N)c[(s[i]=='B')?0:1]++;
    for(int i = 0; i < N; i++){
      int round = 0;
      int idx = 0;
      bool exist[200];
      int tc[2]; tc[0] = c[0]; tc[1] = c[1];
      REP(j, N)exist[j] = true;
      while(true){
        if(tc[0] == 0 || tc[1] == 0) break;
        int sec = (L - 1) % (N - round);
        if(round == i) sec = L % (N - round);
        //cout<<sec<<" ";
        while(sec){
          do{
            idx = (idx + 1) % N;
          }while(!exist[idx]);
          sec--;
        }
        exist[idx] = false;
        tc[(s[idx]=='B')?0:1]--;
        do{
          idx = (idx + 1) % N;
        }while(!exist[idx]);
        /*
        REP(i, N){
          if(exist[i]) cout<<s[i];
          else cout<<"*";
        }
        cout<<endl;
        */
        round ++;
      }
      //cout<<countB<<endl;
      ans = max(ans, tc[0]);
      if(i > round) break;
    }
    cout<<ans<<endl;
  }
  return 0;
}

Measured memory_bytes: 924
#include<bits/stdc++.h>
#define FOR(i,a,b) for(int i=a;i<=b;++i)
using namespace std;

const int mn=2005;
bool s[mn][mn];
int u[mn][mn],d[mn][mn],l[mn][mn],r[mn][mn];

int main()
{
	int n,m,ans=0;
	scanf("%d%d",&n,&m);
	char c;
	FOR(i,1,n) FOR(j,1,m) {c=getchar();while(c!='.'&&c!='#') c=getchar();s[i][j]=(c=='.');}
	FOR(i,1,n) FOR(j,1,m) {
		if(!s[i][j]) continue;
		if(s[i][j-1]) l[i][j]=l[i][j-1]+1,r[i][j]=r[i][j-1]-1;
		else {l[i][j]=0;FOR(k,j+1,m) {if(!s[i][k]) break;r[i][j]++;}}
		if(s[i-1][j]) u[i][j]=u[i-1][j]+1,d[i][j]=d[i-1][j]-1;
		else {u[i][j]=0;FOR(k,i+1,n) {if(!s[k][j]) break;d[i][j]++;}}
		ans=max(ans,l[i][j]+r[i][j]+u[i][j]+d[i][j]+1);
	}
	cout<<ans;
}

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

using namespace std;

int main()
{
	int A, B, K;

	cin >> A >> B >> K;

	for (int i = A; i <= B; i++)
	{
		if ((A <= i && i < A + K) || (B - K < i && i <= B))
		{
			cout << i << endl;
		}
	}

	return 0;
}

Measured memory_bytes: 256
N, K = map(int, input().split())
lst = list(map(int, input().split()))
x = 0
besttime = 10**9
while x + K - 1< N:
    if lst[x]*lst[x+K-1] < 0:
        time = min(abs(lst[x])*2+lst[x+K-1], abs(lst[x])+2*lst[x+K-1])
    else:
        time = max(abs(lst[x]), abs(lst[x+K-1]))
    if besttime > time:
        besttime = time
    x += 1
print(besttime)

Measured memory_bytes: 14384
#include <iostream>
#include <algorithm>
using namespace std;
#define INF 1000000
#define MAX_V 10

int d[MAX_V][MAX_V]; // d[u][v]は辺e=(u,v)のコスト(存在しない場合はINF.ただしd[i][i]=0とする)
int V; // 頂点数

void warshall_floyd() {
    for(int k=0;k<V;k++)
        for(int i=0;i<V;i++)
            for(int j=0;j<V;j++) d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
}

void clearD() {
    for(int i=0;i<MAX_V;i++) {
        for(int j=0;j<MAX_V;j++) {
            if(i==j) {
                d[i][j] = 0;
            } else {
                d[i][j] = INF;
            }
        }
    }
}

main() {

    int n,a, b, c;
    V = MAX_V;
    while(cin>>n,n!=0) {
        clearD();
        for(int i=0;i<n;i++) {
            cin>>a>>b>>c;
            d[a][b]=c;
            d[b][a]=c;
        }
        warshall_floyd();
        int ans = INF;
        int ans_pos = 0;
        for(int i=0;i<V;i++) {
            int sum = 0;
            for(int j=0;j<V;j++) {
                if(d[i][j] == INF) continue;
                sum += d[i][j];
            }
            if(sum != 0 && sum < ans) {
                ans = sum;
                ans_pos = i;
            }
        }
        cout << ans_pos << " " << ans << endl;
    }
}

Measured memory_bytes: 1160
#include <iostream>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <map>
#include <cmath>
#include <queue>
using namespace std;
using i64 = int64_t;
#define rep(i, j, n) for(int i = j; i < n; ++i)
constexpr i64 MOD = 1000000007;
constexpr i64 INF = 1LL << 60;



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

	int t = 0, x = 0, y = 0, tt, tx, ty;
	rep(i, 0, n) {
		cin >> tt >> tx >> ty;
		int diff = abs(tx - x) + abs(ty - y);
		if (tt - t < diff || (tt - t) % 2 != diff % 2) {
			cout << "No";
			return 0;
		}
		t = tt;
		x = tx;
		y = ty;
	}
	cout << "Yes";

	return 0;
}

Measured memory_bytes: 3600
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <queue>
#include <cstring>
#include <vector>
#include <map>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <bitset>
#include <set>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define RREP(i,n) for(int i=n-1;i>=0;i--)
#define FOR(i,k,n) for(int i=(k);i<(int)(n);i++)
#define all(i,n) (i),(i+n)

int dx4[4]={1,0,-1,0};
int dy4[4]={0,-1,0,1};
int dx8[8]={1,0,-1,1,-1,1,0,-1};
int dy8[8]={1,1,1,0,0,-1,-1,-1};

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

const int INF = 1e9;
const ll LLINF = 1e18;
const int MAX_V = 1e6+1;
const ll mod = 1000000007;

// --------------------------------------
int h, w, d, q;
struct grid_pos { int x, y; };
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);

  cin >> h >> w >> d;

  vector<grid_pos> vg(h * w + 1);

  FOR(i, 1, h + 1) FOR(j, 1, w + 1) {
    int a;
    cin >> a;
    grid_pos gp = {i, j};
    vg[a] = gp;
  }

  vector<int> memo(h * w + 1, 0);
  for(int i=h*w; (h*w-d)<i; i--) {
    grid_pos gp = vg[i];
    int sum = 0;
    for(int j=d; (i-j)>0; j+=d) {
      grid_pos n_gp = vg[i - j];
      sum += abs(gp.x - n_gp.x) + abs(gp.y - n_gp.y);
      memo[i - j] = sum;
      gp = n_gp;
    }
  }

  cin >> q;
  REP(i, q) {
    int l, r;
    cin >> l >> r;
    cout << memo[l] - memo[r] << endl;
  }
}


Measured memory_bytes: 2176
#include <iostream>
#include <iomanip>
#include <vector>
#include <string>
#include <cmath>
#include <set>
#include <map>
#include <climits>
#include <cassert>
#include <algorithm>
#include <utility>
 
using namespace std;
using Int = long long int;
using UInt = unsigned long long int;
using VI = vector<long long int>;
using VVI = vector<vector<long long int> >;
 
int main(void) {
    Int n, m;
    cin >> n >> m;
    Int a, b;
    vector<Int> h(n);
    vector<Int> max_h(n);
    vector<bool> check(n, true);
    for (Int i = 0; i < n; ++i) {
        cin >> h[i];
        max_h[i] = h[i];
    }
    vector<vector<Int> > table(n);
    for (Int i = 0; i < m; ++i) {
        cin >> a >> b;
        --a; --b;
        if (h[a] == h[b]) {
            check[a] = false;
            check[b] = false;
        } else if (h[a] < h[b]) {
            check[a] = false;
            max_h[a] = max_h[b];
        } else {
            check[b] = false;
            max_h[b] = max_h[a];
        }
    }
    Int true_cnt = 0;
    for (Int i = 0; i < n; ++i) {
        if (check[i]) {
            true_cnt++;
        }
    }
    cout << true_cnt << endl;
    return 0;
}


Measured memory_bytes: 7208
parseInt(x::String) = parse(Int, x)
parseInt(x::SubString{String}) = parse(Int, x)
parseInt(x::Char) = parse(Int, x)
parseInt(x::Float64) = trunc(Int, x)
parseFloat(x::String) = parse(Float64, x)
parseFloat(x::Int) = trunc(Float64, x)
parseFloat(x::SubString{String}) = parse(Float64, x)
parseFloat(x::Char) = parse(Float64, x)
parseMap(x::Array{SubString{String},1}) = map(parseInt, x)

function main()
    n=parseInt(readline())
    one,two=parseMap(split(readline()))
    one,two=BigInt(one),BigInt(two)
    for i in 2:n
        t,a=parseMap(split(readline()))
        m=BigInt(max(ceil(one/t),ceil(two/a)))
        one,two=m*t,m*a
    end
    println(one+two)
end
main()

Measured memory_bytes: 122648
package main

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

func main() {
	a := readi()
	b := readi()
	fmt.Println(a * b)
}

/*-------------------utilities-------------------*/

func abs(x int) int {
	if x < 0 {
		return -x
	}
	return x
}

func min(x, y int) int {
	if x < y {
		return x
	}
	return y
}

func max(x, y int) int {
	if x > y {
		return x
	}
	return y
}

func chmin(x *int, y int) bool {
	if *x > y {
		*x = y
		return true
	}
	return false
}

func chmax(x *int, y int) bool {
	if *x < y {
		*x = y
		return true
	}
	return false
}

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

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

func permutations(arr []int) [][]int {
	var helper func([]int, int)
	res := [][]int{}

	helper = func(arr []int, n int) {
		if n == 1 {
			tmp := make([]int, len(arr))
			copy(tmp, arr)
			res = append(res, tmp)
		} else {
			for i := 0; i < n; i++ {
				helper(arr, n-1)
				if n%2 == 1 {
					tmp := arr[i]
					arr[i] = arr[n-1]
					arr[n-1] = tmp
				} else {
					tmp := arr[0]
					arr[0] = arr[n-1]
					arr[n-1] = tmp
				}
			}
		}
	}
	helper(arr, len(arr))
	return res
}

func isPrime(n int) bool {
	if n == 1 {
		return false
	}
	for i := 2; i*i <= n; i++ {
		if n%i == 0 {
			return false
		}
	}
	return true
}

func divisor(n int) (res []int) {
	for i := 1; i*i <= n; i++ {
		if n%i == 0 {
			res = append(res, i)
			if i*i != n {
				res = append(res, n/i)
			}
		}
	}
	sort.Ints(res)
	return
}

/*-------------------init-------------------*/

const (
	INF = 1000000000000000000
	MOD = 1e9 + 7
)

var (
	readString func() string
)

func init() {
	readString = newReadString(os.Stdin)
}

/*-------------------inputs-------------------*/

func readi() int {
	return int(readi64())
}

func readi64() int64 {
	i, err := strconv.ParseInt(readString(), 0, 64)
	if err != nil {
		panic(err.Error())
	}
	return i
}

func readf() float64 {
	f, err := strconv.ParseFloat(readString(), 64)
	if err != nil {
		panic(err.Error())
	}
	return f
}

func newReadString(ior io.Reader) func() string {
	r := bufio.NewScanner(ior)
	r.Buffer(make([]byte, 1024), int(1e+11))
	r.Split(bufio.ScanWords)

	return func() string {
		if !r.Scan() {
			panic("Scan failed")
		}
		return r.Text()
	}
}


Measured memory_bytes: 1756
#include <stdio.h>
int main()
{
	int i, n;
	long int a, min = 1000000, max = -1000000, sum = 0;
	 scanf("%d", &n);
	 for (i = 1;i <= n;i++) {
	  scanf("%ld", &a);
	  if (a <= min) {
		  min = a;
		}
	  if (a >= max) {
		  max = a;
		}
	  sum = sum + a;
	}
	printf("%ld %ld %ld\n", min, max, sum);
	return 0;
}

Measured memory_bytes: 2744
p=d=2019
z=[0]*p
for i,j in enumerate(input()[::-1]):
	d=(d+int(j)*pow(10,i,p))%p
	z[d]+=1
r=z[0]
for i in range(p):
	r+=z[i]*(z[i]-1)//2
print(r)

Measured memory_bytes: 9332
x, k, d = gets.strip.split.map(&:to_i)
x = x.abs

# 全力で近づくパターン
if x > (k * d)
  puts(x - (k * d))

# 反復横飛びするパターン
else
  div = x / d
  if (k - div).even?
    puts(x - (div * d))
  else
    puts((x - ((div + 1) * d)).abs)
  end
end


Measured memory_bytes: 14308
//ABC077A
#include <bits/stdc++.h>
#include <iostream>
#include <iomanip>
#include <numeric>
#include <math.h>
#include <stdio.h>
#include <climits>
#include <cfloat>
#include <string>
using namespace std;

int main(){
	string s, t;
	cin >> s >> t;
	reverse(s.begin(),s.end());
	if(s == t){
		cout << "YES" << endl;
	}else{
		cout << "NO" << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n)    for(long long i = 0; i < (n) ; ++i)
#define orep(i,n)   for(long long i = 1; i <= (n); ++i)   // one rep
#define drep(i,n)   for(long long i = (n)-1; i >= 0; --i) // down rep
#define srep(i,s,t) for(long long i = (s); i < (t); ++i)  // set rep
#define rng(x)  (x).begin(),(x).end()

  // range
#define rrng(a) (a).rbegin(),(a).rend() // reverse range
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define ru(x,y) (((x)+(y)-1)/(y)) // round up
#define fi first
#define se second
#define eb emplace_back
#define fcout cout << fixed << setprecision(15)


using namespace std;
using ll  = long long;
using P   = pair<int,int>;
using vi  = vector<int>;
using vvi = vector<vi>;
using vp  = vector<P>;
using vl  = vector<ll>;

template<typename T> void Yes(T flag) {
  cout << (flag ? "Yes" : "No") << endl;
}

template<typename T> void pv(vector<T> vec) {
  cout << "[";
  for(auto& v : vec) { cout << v << ","; }
  cout << "]" << endl;
}

template<>
void pv(vector<P> vec) {
  cout << "[";
  for(auto& v : vec) {
    cout << "<" << v.fi << ","<< v.se << ">" << ",";
  }
  cout << "]" << endl;
}

template<typename T> void pv2(vector<vector<T>> vec) {
  for(auto& v : vec) pv(v);
}

int main() {
  int n;
  cin >> n;
  if(n%1000==0) {
    cout << 0 << endl;
    return 0;
  }
  cout << 1000 - n % 1000 << endl;

  return 0;
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define fi first
#define se second
#define pb push_back
using namespace std;

ll k,x;

int main()
{

    ios_base::sync_with_stdio(false);
    cin.tie(0);

    cin >> k >> x;

    for(ll i=max(-1000000LL,x-k+1); i<x; i++) cout << i << " ";
    cout << x << " ";
    for(ll i=x+1; i<min(1000000LL,x+k); i++) cout << i << " ";

    return 0;
}


Measured memory_bytes: 256
import math
import fractions
import sys
import itertools
import numpy as np
from collections import Counter
#入力:N(int:整数)
def input1():
	return int(input())

#入力:N,M(int:整数)
def input2():
	return map(int,input().split())

#入力:[n1,n2,...nk](int:整数配列)
def input_array():
	return list(map(int,input().split()))

def keta(N):
	return len(str(N))



a,b=input2()

if len(str(a))==1 and len(str(b))==1:
	print(a*b)
else:
	print(-1)









Measured memory_bytes: 22692
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <math.h>
using namespace std;

typedef vector<bool> vb;
typedef vector<char> vc;
typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<vector<bool>> vvb;
typedef vector<vector<int>> vvi;

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

int main() {
	int n, m;
	cin >> n >> m;
	cout << (100 * n + 1800 * m) * pow(2, m) << endl;
	return 0;
}

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

int main(){
  int n,k,i;
  long long int x,y,z,a[8][1000],sum=0,ans=0;
  cin>>n>>k;
  for(i=0;i<n;i++){
    cin>>x>>y>>z;
    a[0][i]=x+y+z;
    a[1][i]=x+y-z;
    a[2][i]=x-y+z;
    a[3][i]=x-y-z;
    a[4][i]=-x+y+z;
    a[5][i]=-x+y-z;
    a[6][i]=-x-y+z;
    a[7][i]=-x-y-z;
  }
  for(i=0;i<8;i++){
    sort(a[i],a[i]+n);
    sum=0;
    for(int j=n-1;j>=n-k;j--)
      sum+=a[i][j];
    if(ans<sum)
      ans=sum;
  }
  cout << ans<<endl;
}

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

class Main {
	public static void main(String[] args) throws Exception {
		new Main().run();
	}
	
	void run() {
		Scanner sc=new Scanner(System.in);
		int[][] a= {{1,3,5,7,8,10,12},{4,6,9,11},{2}};
		int x=sc.nextInt();
		int y=sc.nextInt();
		for(int i=0;i<3;++i) {
			for(int v:a[i]) {
				if(v==x)x=i;
				if(v==y)y=i;
			}
		}
		System.out.println(x==y?"Yes":"No");
	}
	
	static void tr(Object... objects) {
		System.out.println(Arrays.deepToString(objects));
	}
	
}


Measured memory_bytes: 21844
#include<iostream>
#include<cmath>
#include<string.h>
#include<stdio.h>
#include<algorithm>
#include<vector>
using namespace std;


struct enode
{
    int num;
    int id;
    int f;
    enode(){}
    enode(int nn,int ii,int ff)
    {
        num=nn;
        id=ii;
        f=ff;
    }
};

vector<vector<enode> >edge;
vector<vector<bool> >r;

vector<bool>cover;

int n,m;

void dfs(int now ,int st)
{
    int i;
    r[st][now]=1;
    for(i=0;i<edge[now].size();i++)
    {
        if(r[st][edge[now][i].num]==0)
        {
            dfs(edge[now][i].num,st);
        }
    }
    return ;
}

void dfs2(int now,int x)
{
   int i;
   cover[now]=1;
   for(i=0;i<edge[now].size();i++)
   {
       if(edge[now][i].num==x)continue;
       if(cover[edge[now][i].num]==0)
       {
           dfs2(edge[now][i].num,x);
       }
   }
}


void gao()
{
    int i,j;
    for(i=1;i<=n;i++)
    {
        cover=vector<bool>(n+1,0);
        for(j=0;j<edge[i].size();j++)
        {
             //cout<<i<<' '<<j<<" ^^^"<<endl;
             if(cover[edge[i][j].num]==1)
             {
                  edge[i][j].f=1;
                  //cout<<i<<' '<<j<<"   &&&"<<endl;
                  continue;
             }
             
             dfs2(edge[i][j].num,i);
        }
    }
}

int ans[200011];
int main()
{
    int i,j,k;
    int xx,yy;
    
    scanf("%d %d",&n,&m);
    
    edge=vector<vector<enode> >(n+1,vector<enode>());
    r=vector<vector<bool> >(n+1,vector<bool>(m+1,0));
    
    for(i=1;i<=m;i++)
    {
        scanf("%d %d",&xx,&yy);
        edge[xx].push_back(enode(yy,i,0));
    }
    
    for(i=1;i<=n;i++)
    {
        dfs(i,i);
    }
    
    /*
    for(i=1;i<=n;i++)
    {
        for(j=1;j<=n;j++)
        {
            cout<<r[i][j]<<' ';
        }
        cout<<endl;
    }
    */
    //system("pause");
    gao();
    //system("pause");
    for(i=1;i<=n;i++)
    {
        reverse(edge[i].begin(),edge[i].end());
    }
    gao();
    
    //system("pause");
    for(i=1;i<=n;i++)
    {
        for(j=0;j<edge[i].size();j++)
        {
            
            ans[edge[i][j].id]=(edge[i][j].f^r[edge[i][j].num][i]);
        }
    }
    
    for(i=1;i<=m;i++)
    {
        if(ans[i]==0)
        {
            printf("same\n");
        }
        else
        {
            printf("diff\n");
        }
    }
    return 0;
}


Measured memory_bytes: 31104
#include <bits/stdc++.h>
#define FOR(i, a, b) for(int i=(a); i<(b); i++)
#define REP(i, n) FOR(i, 0, n)
#define all(x) (x).begin(), (x).end()
#define bit(x) (1L << (x))
using ll = long long;
using namespace std;

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

  set<string> st;
  int n = static_cast<int>(s.length());

  for(int i=0; i<n; i++){
    for(int j=1; j<=min(n-i, 5); j++){
      st.insert(s.substr(i, j));
    }
  }

  auto it = st.begin();
  for(int i=1; ; i++, it++){
    if(i == k){
      cout << *it << endl;
      return 0;
    }
  }
  return 0;
}


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

using namespace std;

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

    int n, m;
    cin >> n;
    int arr[n], med[n];

    for (int i = 0; i < n; i++)
        cin >> arr[i], med[i] = arr[i];

    sort(med, med + n);
    m = med[n / 2];

    for (int i = 0; i < n; i++)
        if (arr[i] < m)
            cout << m << '\n';
        else
            cout << med[n / 2 - 1] << '\n';

    return 0;
}

Measured memory_bytes: 3712
import java.math.BigDecimal;
import java.util.Scanner;

public class Main {
	static Scanner sc = new Scanner(System.in);

	public static void main(String[] args) {
		double a;
		double b;
		double c;
		double d;
		double e;
		double f;

		while(sc.hasNext()) {
			//??\??????????????°????????£??\
			a = sc.nextInt();
			b = sc.nextInt();
			c = sc.nextInt();
			d = sc.nextInt();
			e = sc.nextInt();
			f = sc.nextInt();

			BigDecimal x = new BigDecimal(mathX(a, b, c, d, e, f));
			BigDecimal y = new BigDecimal(mathY(a, b, c, d, e, f));

			x = x.setScale(4, BigDecimal.ROUND_HALF_UP);
			y = y.setScale(4, BigDecimal.ROUND_HALF_UP);

			String xy = String.format("%.3f", x) + " " + String.format("%.3f", y);
			System.out.println(xy);

		}



	}

	public static double mathX(double a, double b, double c,
			double d, double e, double f) {
		return ((c * e) - (b * f)) / ((a * e) - (b * d));
	}

	public static double mathY(double a, double b, double c,
			double d, double e, double f) {
		return ((c * d) - (a * f)) / ((b * d) - (a * e));
	}
}

Measured memory_bytes: 26516
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <set>

using namespace std;

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

#define M 998244353

vector<long long int> fact(300010);

long long int extgcd(long long int a, long long int b, long long int& x, long long int& y) {
	long long int d = a;
	if (b != 0) {
		d = extgcd(b, a%b, y, x);
		y -= (a / b)*x;
	}
	else {
		x = 1; y = 0;
	}
	return d;
}

long long int mod_inverse(long long int a, long long int m) {
	long long int x, y;
	extgcd(a, m, x, y);
	return (m + x % m) % m;
}

long long int mod_fact(long long int n, long long int p, long long int& e) {
	e = 0;
	if (n == 0) return 1;

	long long int res = mod_fact(n / p, p, e);
	e += n / p;

	if (n / p % 2 != 0) return res * (p - fact[n%p]) % p;
	return res * fact[n%p] % p;
}

long long int mod_comb(long long int n, long long int k, long long int p) {
	if (n < 0 || k < 0 || n < k) return 0;
	long long int e1, e2, e3;
	long long int a1 = mod_fact(n, p, e1), a2 = mod_fact(k, p, e2), a3 = mod_fact(n - k, p, e3);
	if (e1 > e2 + e3) return 0;
	return a1 * mod_inverse(a2 * a3 % p, p) % p;
}


int main() {
	long long int n, a, b, k;
	cin >> n >> a >> b >> k;

	fact[0] = 1;

	for (long long int i = 1; i <= n; i++) {
		fact[i] = fact[i - 1] * i;
		fact[i] %= M;
	}

	long long int ans = 0;

	for (long long int i = 0; 0 <= k-a*i; i++) {
		long long int k2 = k - a*i;
		if (k2 % b == 0 && k2 / b <= n) {
			long long int rr, bb;
			rr = i;
			bb = k2 / b;
			
			long long int ans2 = (mod_comb(n, rr, M) * mod_comb(n, bb, M)) % M;
			ans += ans2;
			ans %= M;
		}
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 2560
import sys
from math import factorial

sys.setrecursionlimit(10 ** 7)
rl = sys.stdin.readline
MOD = 10 ** 9 + 7


def solve():
    N = int(rl())
    S = rl().rstrip()
    
    if S[0] == 'W' or S[-1] == 'W':
        print(0)
        return
    
    flip = [0] * (2 * N)
    cntl, cntr = 1, 0
    ans = 1
    for i in range(1, 2 * N):
        if S[i] == S[i - 1]:
            flip[i] = flip[i - 1] ^ 1
        else:
            flip[i] = flip[i - 1]
        if flip[i] == 0:
            cntl += 1
        else:
            ans = ans * (cntl - cntr) % MOD
            cntr += 1
    
    if cntl != cntr:
        print(0)
    else:
        ans = ans * factorial(N) % MOD
        print(ans)


if __name__ == '__main__':
    solve()


Measured memory_bytes: 46596
from sys import stdin
a = stdin.readline().strip()
b = ['dream', 'dreamer', 'erase' , 'eraser']
c = []
for i in b:
    c.append(len(i))
n = len(a)
dp = [0] * (n+1)
dp[0] = 1
for i in xrange(1,n+1):
    ind = i-1
    for jj in xrange(4):
        j = b[jj]
        l = c[jj]
        pr = i - l 
        if pr >=0:
            if dp[pr] and j==a[pr:i]:
                dp[i] = 1
if dp[-1]:
    print 'YES'
else:
    print 'NO'
        

Measured memory_bytes: 3588
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <climits>
#include <sstream>

using namespace std;

int main(){

    long long X, Y;
    cin >> X >> Y;

    long long ans = 0, num = X;

    while(num <= Y){
        ans++;
        num *= 2;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<stdbool.h>
#include<math.h>
#include<limits.h>
int main(){
    int X,N;
    (void)scanf("%d %d",&X,&N);
    int p[102];
    int f[102];
    memset(f,0,sizeof(f));
    for(int i=0;i<N;i++){
        (void)scanf("%d",p+i);
        f[p[i]] = 1;
    }
    int def = 0;
    for(;;){
        if(X-def<1){(void)printf("%d",X-def); return 0;}
        else if(X+def>100 && f[X-def]==0){printf("%d",X-def); return 0;}
        else if(X+def>100){(void)printf("%d",X+def); return 0;}
        else if(f[X-def]==0){(void)printf("%d",X-def);return 0;}
        else if(f[X+def]==0){(void)printf("%d",X+def);return 0;}
        else def++;
    }
}


Measured memory_bytes: 1692
N=int(input())
A=list(map(int,input().split()))
max_result=10**18

result=1

for i in A:
    if i == 0:
        result=0
        break

if result != 0:
    for i in A:
        result = result * i
        if result > max_result:
            result = -1
            break
    
print(result)

Measured memory_bytes: 21784
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <cctype>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <functional>
using namespace std; 
typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<pair<int, int>> vii;
typedef pair<int, int> ii;
/////////////////////////////////////////////////////////////////////
int main()
{
  int n, m;
  cin >> n >> m;
  vi a(m);
  for (int i = 0; i < m; ++i) cin >> a[i];
  int sum = 0;
  for (auto& c : a) sum += c;
  n -= sum;
  if (n < 0) cout << -1 << endl;
  else cout << n << endl;
  return 0;
}

Measured memory_bytes: 3668
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<climits>
#include<iostream>
#include<string>
#include<stack>
#include<queue>
#include<vector>
#include<map>
#include<set>
#include<algorithm>
#include<numeric>

#define rep(n) for(int i=0;i<n;i++)
#define repp(j, n) for(int j=0;j<n;j++)
#define reppp(i, m, n) for(int i=m;i<=n;i++)
#define all(c) c.begin(), c.end()
#define rall(c) c.rbegin(), c.rend()
#define MOD 1000000007
#define MAX 1000000001
#define INF 1410065408
#define EPS 1e-9
#define DEBUG 0
#define ll long long
#define Pll pair<ll, ll>
#define Pii pair<int, int>
 
using namespace std;
struct edge{int from, to; ll cost;};

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

    string s;
    cin >> s;

    vector<int> count(3, 0);
    rep((int)s.length()){
        count[(int)(s[i] - 'a')]++;
    }

    if(*max_element(all(count)) - *min_element(all(count)) <= 1){
        cout << "YES";
    }else{
        cout << "NO";
    }

    return 0;
}

Measured memory_bytes: 512
// 2013/11/08 Tazoe

#include <iostream>
#include <string>
using namespace std;

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

	string S;
	cin >> S;

	int cnt = 0;

	for(int i=0; i<N; i++){
		string T;
		cin >> T;

		for(int j=0; j<T.size(); j++){
			if(T[j]!=S[0])
				continue;

			bool flg = false;
			int L = T.size()-1-j;
			for(int d=1; d<=L/(S.size()-1); d++){
				flg = true;
				for(int k=1; k<S.size(); k++){
					if(S[k]!=T[j+d*k]){
						flg = false;
						break;
					}
				}

				if(flg)
					break;
			}

			if(flg){
				cnt++;
				break;
			}
		}
	}

	cout << cnt << endl;

	return 0;
}

Measured memory_bytes: 1208
#include<iostream>
#include<vector>
#include<algorithm>
#include<cmath>
#include<ctime>

using namespace std;
using ll = long long;

int h, w, k;
vector<vector<char>> choco;
vector<vector<int>> sums;

#define INF 1000000;

int solve(int hori){
  int ret = 0;
  int c = 0;
  int t = hori;
  vector<int> sh_h;
  while(t){
    c++;
    if(t&1){
      ret++;
      sh_h.push_back(c);
    }
    t /= 2;
  }
  sh_h.push_back(h);

  int last_v = 0;
  for(int j = 1; j <= w; j++){
    int last_h = 0;
    for(int i = 0; i < sh_h.size(); i++){
      int s = sums[sh_h[i]][j] - sums[sh_h[i]][last_v] - sums[last_h][j] + sums[last_h][last_v];
      if(s > k){
        if(j - last_v == 1){
          return INF;
        }
        last_v = j-1;
        ret++;
        j--;
        break;
      }
      last_h = sh_h[i];
    }
  }
  return ret;
}

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int ti = clock();
  // start-----------------------------------------------
  cin >> h >> w >> k;
  int ans = INF;
  choco = vector<vector<char>>(h, vector<char>(w));
  sums = vector<vector<int>>(h+1, vector<int>(w+1, 0));
  for(int i = 0; i < h; i++){
    string s; cin >> s;
    for(int j = 0; j < w; j++){
      choco[i][j] = s[j];
      sums[i+1][j+1] = sums[i+1][j];
      if(s[j] == '1') sums[i+1][j+1]++;
    }
  }
  for(int j = 0; j < w; j++){
    for(int i = 0; i < h; i++){
      sums[i+1][j+1] += sums[i][j+1];
    }
  }

  for(int i = 0; i < pow(2, h-1); i++){
    ans = min(ans, solve(i));
  }
  cout << ans << endl;

  // end-----------------------------------------------
  // cerr << 1.0 * (clock() - ti) / CLOCKS_PER_SEC << endl;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
#define int long long
#define ALL(v) (v).begin(),(v).end()
#define Vi vector<int>
#define pb push_back
#define rep(i,a,b) for(int i=a;i<b;i++)
#define repeq(i,a,b) for(int i=a;i<=b;i++)
#define repr(i,a,b) for(int i=a;i>b;i--)
#define repreq(i,a,b) for(int i=a;i>=b;i--)
#define leng(n) (int)(log10(n)+1)
#define INF 9000000000000000000  //  9.0 * 10^18
#define MOD 1000000007  //  10^9 + 7
#define PAI 3.14159265358979
// ver1.7
using namespace std;

int gcd(int a,int b){return b?gcd(b,a%b):a;}  //  最大公約数gcd
int lcm(int a,int b){return a/gcd(a,b)*b;}  //  最小公倍数lcm

signed main() {
  cout << fixed << setprecision(14);
  int n;
  cin >> n;
  if(n%11==0) cout << 2*(n/11) << endl;
  else if(n%11<=6) cout << 2*(n/11) + 1 << endl;
  else cout << 2*(n/11) + 2 << endl;
  return 0;
}


Measured memory_bytes: 256
/*input
10
5 9 5 9 8 9 3 5 4 3
*/
#include <bits/stdc++.h>
#pragma GCC optimize("unroll-loops,no-stack-protector")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<double,double> pdd;
#define IOS ios_base::sync_with_stdio(0); cin.tie(0)
#define ALL(a) a.begin(),a.end()
#define SZ(a) ((int)a.size())
#define F first
#define S second
#define REP(i,n) for(int i=0;i<((int)n);i++)
#define pb push_back
#define MP(a,b) make_pair(a,b)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#ifdef leowang
#define debug(...) do{\
	fprintf(stderr,"%s - %d : (%s) = ",__PRETTY_FUNCTION__,__LINE__,#__VA_ARGS__);\
	_DO(__VA_ARGS__);\
}while(0)
template<typename I> void _DO(I&&x){cerr<<x<<endl;}
template<typename I,typename...T> void _DO(I&&x,T&&...tail){cerr<<x<<", ";_DO(tail...);}
#else
#define debug(...)
#endif
template<typename T1,typename T2>
ostream& operator<<(ostream& out,pair<T1,T2> P){
	out<<'('<<P.F<<','<<P.S<<')';
	return out;
}

//}}}
const ll maxn=300005;
const ll maxlg=__lg(maxn)+2;
const ll INF64=8000000000000000000LL;
const int INF=0x3f3f3f3f;
const ll MOD=ll(1e9+7);
const double PI=acos(-1);
//const ll p=880301;
//const ll P=31;

ll mypow(ll a,ll b){
	ll res=1LL;
	while(b){
		if(b&1) res=res*a%MOD;
		a=a*a%MOD;
		
		b>>=1;
	}
	return res;
}
ll a[maxn];

vector<ll> v;
vector<ll> pre;
vector<ll> _;

ll BIT[maxn];
int low(int i){return i&-i;}
void add(int n,int d){
	for(int i=n;i<maxn;i+=low(i)) BIT[i]+=d;
}
ll query(int n){
	ll ret=0;
	for(int i=n;i>0;i-=low(i)) ret+=BIT[i];
	return ret;
}

ll check(){ //return # of contiguous interval that its sum \ge 0
	pre.clear();
	pre.pb(0);
	for(ll i:v) pre.pb(pre.back()+i);
	_.clear();
	for(ll i:pre) _.pb(i);
	SORT_UNIQUE(_);
	REP(i,SZ(pre)) pre[i]=1+GET_POS(_,pre[i]);

	ll ret=0;
	REP(i,SZ(pre)){
		ret+=query(pre[i]);
		add(pre[i],1);
	}
	REP(i,SZ(pre)) add(pre[i],-1);
	return ret;
}


int main()
{
	IOS;
	ll n;
	cin>>n;
	REP(i,n) cin>>a[i];

	ll l=0,r=2e9;

	while(l!=r-1){
		ll mid=(l+r)/2;

		v.clear();
		REP(i,n){
			if(a[i]>=mid) v.pb(1);
			else v.pb(-1);
		}
		ll cnt=check();

		if(cnt>=n*(n+1)/2-cnt) l=mid;
		else r=mid;
	}
	cout<<l<<'\n';

	return 0;
}


Measured memory_bytes: 5620
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi=vector<int>;
using vvi=vector<vi>;
using vd=vector<double>;
using vvd=vector<vd>;
using vl=vector<ll>;
using vvl=vector<vl>;
using pii=pair<int,int>;
using vs=vector<string>;
#define rep(i,n) range(i,0,n)
#define range(i,a,n) for(int i=a;i<n;i++)
#define all(a) a.begin(),a.end()
#define LINF    	((ll)1ll<<60)
#define INF     	((int)1<<30)
#define EPS     	(1e-9)
#define MOD     	(1000000007)
#define fcout(a)	cout<<setprecision(a)<<fixed
#define fs 			first
#define sc			second
#define PI			3.141592653589793

template<class S,class T>ostream& operator<<(ostream&os,pair<S,T>p){os<<"["<<p.first<<", "<<p.second<<"]";return os;};
template<class S>auto&operator<<(ostream&os,vector<S>t){bool a=1; for(auto s:t){os<<(a?"":" ")<<s; a=0;} return os;}

int main(){
	cin.tie(0);
   	ios::sync_with_stdio(false);
	
	int l,k;
	cin>>l>>k;
	vvl dp(l,vl(2,0));
	dp[0][0]=1;
	if(k<=l)dp[k-1][0]=1;
	ll ans=0;
	rep(i,l){
	    ans+=dp[i][0];
	    if(i+k<=l-1 and dp[i][1]!=0)dp[i+k][0]+=dp[i][1];
	    if(i+1<=l-1 and dp[i][1]!=0)dp[i+1][0]+=dp[i][1];
	    if(i+1<=l-1 and dp[i][0]!=0)dp[i+1][1]+=dp[i][0];
    }
    cout<<ans<<endl;
	return 0;
}



Measured memory_bytes: 3216
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <map>
#include <queue>
#include <iomanip>
#include <set>
#define MOD 1000000007
#define mkp make_pair
typedef long long ll;
using namespace std;

int N,Q;
vector<int> S,T,X;
vector<int> D;

int main(){
  cin>>N>>Q;
  S.resize(N);
  T.resize(N);
  X.resize(N);
  D.resize(Q);
  for(int i=0;i<N;i++) cin>>S[i]>>T[i]>>X[i];
  for(int i=0;i<Q;i++) cin>>D[i];

  vector<pair<int,int>> v;
  for(int i=0;i<N;i++) v.push_back(mkp(X[i],i));
  sort(v.begin(),v.end());

  set<int> se;
  map<int,int> mp;
  for(int i=0;i<Q;i++) mp[D[i]]=i;

  for(int i=0;i<Q;i++) se.insert(D[i]);

  vector<int> ans(Q+1,-1);
  ll res=0;
  for(int i=0;i<v.size();i++){
    int now=v[i].second;
    res=X[now];

    auto itr=se.lower_bound(S[now]-X[now]);
    vector<int> p;
    for(;itr!=se.end();itr++){
      if(*itr<T[now]-X[now]) p.push_back(*itr);
      else break;
    }

    for(int j=0;j<p.size();j++){
      ans[mp[p[j]]]=res;
      se.erase(p[j]);
    }
  }

  for(int i=0;i<Q;i++) cout<<ans[i]<<endl;

  return 0;
}


Measured memory_bytes: 27632
N, K = gets.split.map(&:to_i)
S = Array.new(1 << 20,0)
N.times do
  a,b = gets.split.map(&:to_i)
  S[a] += b
end

count = 0
ans = (1 .. 10 ** 5).find do |i|
  S[i] += S[i - 1]
  S[i] >= K
end
puts ans

  

Measured memory_bytes: 12028
import java.io.*;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) throws IOException {
		// TODO Auto-generated method stub
		int answer = 0;
		int mawari = 0;
		Scanner scan = new Scanner(System.in);
        String s = scan.next();
        int a = Integer.parseInt(s);
        String k = scan.next();
        int b = Integer.parseInt(k);      
        
        answer = a*b;
        mawari = a+a+b+b;
        System.out.print(answer + " ");
        System.out.println(mawari);
		
	}
}

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


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

cin>>a>>b>>c;


// rt(a)+rt(b)<rt(c)
// a+b+2rt(ab)<c
// 2rt(ab)<c-a-b
// 2ab<(c-a-b)^2 and a+b-c>0
if((a+b-c)*(a+b-c)-4*a*b>0 && a+b-c<0){
  cout<<"Yes"<<endl;
}
else cout<<"No"<<endl;


}


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

#define _USE_MATH_DEFINES
#include<cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <deque>
#include <algorithm>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <iterator>
#include<iomanip>
#include<unordered_set>
#include<bitset>
#include<complex>

using namespace std;

#define rep(i,a,b) for(int i=(a), i##_len=(b);i<i##_len;i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)

#define int ll
#define SZ(x) ((int)(x).size())
#define pb push_back
#define mp make_pair

//typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<double, double> pdd;
typedef vector< vector<int> > mat;

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 (b < a) { a = b; return true; } return false; }

const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD =  (int)1e9 + 7;
const double EPS = 1e-9;

int N;
int A[10010];
map<int, int> VMAP;
map<int, int> vmap[10010];

vector<int> smallest_prime_factors(int n) {

	vector<int> spf(n + 1);
	for (int i = 0; i <= n; i++) spf[i] = i;


	for (int i = 2; i * i <= n; i++) {

		// 素数だったら  
		if (spf[i] == i) {

			for (int j = i * i; j <= n; j += i) {

				// iを持つ整数かつまだ素数が決まっていないなら  
				if (spf[j] == j) {
					spf[j] = i;
				}
			}
		}
	}

	return spf;
}

void factolization(int k,int x, vector<int> &spf) {
	while (x != 1) {
		vmap[k][spf[x]]++;
		x /= spf[x];
	}
}

long long modpow(long long a, long long n) {
	long long res = 1;
	while (n > 0) {
		if (n & 1) res = res * a % MOD;
		a = a * a % MOD;
		n >>= 1;
	}
	return res;
}

long long modinv(long long a, long long m) {
	long long b = m, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}

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

	auto spf = smallest_prime_factors(1000010);

	cin >> N;
	rep(k, 0, N)
	{
		cin >> A[k];
		factolization(k,A[k], spf);

		for (auto p : vmap[k])
		{
			chmax(VMAP[p.first], p.second);
		}
	}

	int mul = 1;
	for (auto p : VMAP)
	{
		mul *= modpow(p.first, p.second);
		mul %= MOD;
	}

	int ans = 0;
	rep(i, 0, N)
	{
		int res = mul;
		for (auto p : vmap[i])
		{
			rep(k, 0, p.second)
			{
				res *= modinv(p.first, MOD);
				res %= MOD;
			}
		}
		ans += res;
		ans %= MOD;
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 11776
#!/usr/bin/env python
# coding: utf-8

# In[19]:


N = int(input())
P = list(map(int, input().split()))
Q = list(map(int, input().split()))


# In[20]:


import itertools


# In[21]:


mylist = list(itertools.permutations(range(1,N+1)))
mylist = list(map(list, mylist))
print(abs(mylist.index(P) - mylist.index(Q)))


# In[ ]:






Measured memory_bytes: 15092
n,d = (int(i) for i in input().split())
x = [[int(i) for i in input().split()] for i in range(n)]

cnt=0
for k in range(n):
    for j in range(k+1,n):
        dist=0
        for i in range(d):
            dist+=(x[k][i]-x[j][i])**2
        val=dist**0.5-dist**0.5//1
        if val==0:
            cnt+=1
print(cnt)

Measured memory_bytes: 38384
N = int(input())
W = [int(i) for i in input().split()]
dif_W = 10000
under_sum = 0
for i in range(N-1):
    under_sum += W[i]
    dif_W = min(dif_W, abs(sum(W) - 2*under_sum))
print(dif_W)


Measured memory_bytes: 2940
#%%
import itertools
n, m, x = map(int, input().split())
refs = [list(map(int, input().split())) for _ in range(n)]

#%%
# n個のbit組み合わせ
flag = True
for bits in itertools.product([1, 0], repeat=n):
    skill = [0] * m # スキルは毎回初期化して良い
    cost = 0
    if all(bits):
        for r in refs:
            skill = [x + y for (x, y) in zip(skill, r[1:])]
            cost += r[0]
        if any([i < x for i in skill]): # 全部足してもだめなとき
            flag = False
            break
        else:
            ans = cost # 最大のコスト

    else:
        for i, b in enumerate(bits):
            if b == 1:
                skill = [x + y for (x, y) in zip(skill, refs[i][1:])]
                cost += refs[i][0]
        if all([i >= x for i in skill]):
            ans = min(ans, cost)

if flag:
    print(ans)
else:
    print(-1)

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

#define rep(i, n) for (int i = 0; i < n; i++)
#define repr(i, n) for (int i = n-1; i >= 0; i--)
#define ALL(x) x.begin(),x.end()

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

const int mod = 1e9+7;
const ll INF = 1e18;
const int MAX = 1e6;
const double pi = 3.14159265358979;

// int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};

struct edge {int to, cost;}; // 辺
// vector<edge> graph[MAX]; // 隣接リスト
// bool visit[MAX]; // 訪問状況

int a, b; // 変数
double h, m;

int main() {
// input
    cin >> a >> b;
    cin >> h >> m;
// solve
    double longer = h * pi / 6 + m * pi / 360;
    double shorter = m * pi / 30;
    double x = abs(longer - shorter);
    double c = sqrt(a * a + b * b - 2 * a * b * cos(x));
// output
    printf("%.10f\n", c);
}

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

int ar[1000];

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a, b;
    cin >> a >> b;

    for (int i = 1; i <= 999; i++) {
        ar[i] = i*(i+1)/2;
    }

    int t;

    for (int i = 1; i <= 999; i++) {
         if (ar[i] - a == ar[i+1] - b) {
            cout << ar[i] - a << endl;
            return 0;
        }
    }


    return 0;
}





Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
int main(void){
    int h,w; cin>>h>>w;
    vector <vector<int>> a(h ,vector <int>(w));
    for(int i=0;i<h;i++){
    for(int j=0;j<w;j++){
        cin>>a[i][j];
        }
    }
    bool have = false;
    vector <string> ans ;
    for(int i=0;i<h;i++){
        if(have) {a[i-1][w-1]++; have=false;}
        pair <int,int> now = make_pair(-1,-1);
        for(int j=0;j<w;j++){
            if(have){
                if(a[i][j]%2 != 0){
                    a[i][j]++; have = false;
                    string s = to_string(now.F+1)+' '+to_string(now.S+1)+' '+to_string(i+1)+' '+to_string(j+1);
                    ans.push_back(s); continue;
                }else{
                    string s = to_string(now.F+1)+' '+to_string(now.S+1)+' '+to_string(i+1)+' '+to_string(j+1);
                    now = make_pair(i,j);
                    ans.push_back(s); continue;
                }
                
            }
            if(have==false){
                if(a[i][j]%2!=0) {
                    a[i][j]--; have= true;
                    now = make_pair(i,j);
                }
                continue;
            }
        }
    }
    if(have) a[h-1][w-1]++;
    /*for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            cout<<a[i][j]<< ' ';
        }
        cout<<endl;
    }*/
    have = false;
    pair <int,int> now = make_pair(-1,-1);
    for(int i=0;i<h;i++){
        if(have){
            if(a[i][w-1]%2==0){
                string s = to_string(now.F+1)+' '+to_string(now.S+1)+' '+to_string(i+1)+' '+to_string(w);
                    now = make_pair(i,w-1);
                    ans.push_back(s); continue;
            }
            else{
                string s = to_string(now.F+1)+' '+to_string(now.S+1)+' '+to_string(i+1)+' '+to_string(w);
                ans.push_back(s);
                have = false;
                continue;
            }
        }
        else if(!have){
            if(a[i][w-1]%2==0) continue;
            else {
                now = make_pair(i,w-1);
                have = true;
                continue;
            }
        }
    }
    cout<<ans.size()<<endl;
    for(int i=0;i<
    ans.size();i++){
        cout<<ans[i]<<endl;
    }
}


Measured memory_bytes: 11892
function main()
  
  N = parse(Int,readline())
  
  A = map(x -> parse(Int,x), split(readline()))
  B = map(x -> parse(Int,x), split(readline()))
  C = map(x -> parse(Int,x), split(readline()))
  
  ans = 0
  check = -10
  
  for i in 1:N
    
    ans += B[A[i]]
    
    if A[i] - check == 1
      ans += C[A[i]-1]
    end
    
    check = A[i]
    
  end
  
  println(ans)
  
end

main()

Measured memory_bytes: 112652
N, a, b, c, d = gets.split.map(&:to_f)
n = N.to_i
b -= a
n -= 1
n.times do |i|
  axis = (c + d) / 2.0 * i
  b < axis ? b = 2 * axis - b : b
end
puts (c * n <= b && b <= d * n ? 'YES' : 'NO')


Measured memory_bytes: 1916