akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define mp make_pair
#define pb push_back
#define fi first
#define se second
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,int> pli;
const int inf=1e9;
const ll Inf=1e18;
const int N=310;
const int mod=1e9+7;
int gi() {
    int x=0,o=1;char ch=getchar();
    while((ch<'0'||ch>'9')&&ch!='-') ch=getchar();
    if(ch=='-') o=-1,ch=getchar();
    while(ch>='0'&&ch<='9') x=x*10+ch-'0',ch=getchar();
    return x*o;
}
template<typename T> bool chkmax(T &a,T b) { return a<b?a=b,1:0; };
template<typename T> bool chkmin(T &a,T b) { return a>b?a=b,1:0; };
int add(int a,int b) { return a+b>=mod?a+b-mod:a+b; }
int sub(int a,int b) { return a-b<0?a-b+mod:a-b; }
void inc(int &a,int b) { a=(a+b>=mod?a+b-mod:a+b); }
void dec(int &a,int b) { a=(a-b<0?a-b+mod:a-b); }
int n,m,f[N][N][N];
vector<pii> lim[N];
bool check(int l,int x,int a,int b) {
    if(x==1) return b<l;
    else if(x==2) return b>=l&&a<l;
    else return a>=l;
}
int main() {
    cin>>n>>m;
    for(int i=1,l,r,x;i<=m;i++) l=gi(),r=gi(),x=gi(),lim[r].pb(mp(l,x));
    f[0][0][0]=1;
    for(int i=1;i<=n;i++)
        for(int j=0;j<i;j++)
            for(int k=0;k<i;k++)
                if(f[i-1][j][k]) {
                    bool fl=1;
                    for(pii a:lim[i]) if(!check(a.fi,a.se,k,i-1)) fl=0;
                    if(fl) inc(f[i][k][i-1],f[i-1][j][k]);
                    fl=1;
                    for(pii a:lim[i]) if(!check(a.fi,a.se,j,i-1)) fl=0;
                    if(fl) inc(f[i][j][i-1],f[i-1][j][k]);
                    fl=1;
                    for(pii a:lim[i]) if(!check(a.fi,a.se,j,k)) fl=0;
                    if(fl) inc(f[i][j][k],f[i-1][j][k]);
                }
    int ans=0;
    for(int j=0;j<=n;j++)
        for(int k=0;k<=n;k++) inc(ans,f[n][j][k]);
    printf("%d\n",ans);
    return 0;
}


Measured memory_bytes: 112896
#define _LIBCPP_DEBUG 0
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
ll MOD = 1e9+7;

int main(){

    ll H,N; cin>>H>>N;
    vector<ll> A(N);
    ll sum=0;
    for (int i = 0; i < N; ++i) {
        cin>>A[i];
        sum += A[i];
    }
    if(sum>=H){
        cout<<"Yes"<<endl;
    }else{
        cout<<"No"<<endl;
    }

    return 0;
}

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

using namespace std;

int main() {
    int N = 0, tmp = 0, count = 0;
    vector<int> rabbits;

    cin >> N;

    rabbits.push_back(-1);
    for(int i = 0; i < N; i++) {
        cin >> tmp;
        rabbits.push_back(tmp);
    }
    
    for(int i = 1; i < N; i++) {
        tmp = rabbits[i];

        if(rabbits[tmp] == -1 || tmp > N || tmp == i)
            continue;

        if(rabbits[tmp] == i) {
            count++;
            rabbits[i] = -1;
            rabbits[tmp] = -1;
        }
    }

    cout << count << endl;

    return 0;
}

Measured memory_bytes: 1020
#include<iostream>
#include<math.h>

using namespace std;

int ketasusirabe(long long x);

int main(){

	long long num;
	cin >> num;

	long long a,b;
	int  ans;
	int min = 0;

    long long  sq_num = sqrt(num);

	min = ketasusirabe( num );
	min++;

	int i;
	for(i = 1; i <= sq_num; i++){
		if(num % i == 0){

			a = num / i;
			b = i;

			if( ketasusirabe( a ) < ketasusirabe( b ) ) ans = ketasusirabe(b);
			else                                        ans = ketasusirabe(a);

			if(ans < min) min = ans;

		}
	}

	cout << min << endl;

}

int ketasusirabe(long long  x){

	long long box = x;
	int cnt = 0;

	while(box / 10 != 0){

		box = box / 10;
		cnt++;
	}
	cnt++;

	return cnt;

}

Measured memory_bytes: 256
import java.util.*;

class Main{
	public static void main(String[] args){
		Scanner s=new Scanner(System.in);
		while(s.hasNext()){
			String takeshi=s.next();
			char[][] c=new char[3][3];
			for(int i=0;i<3;i++)
				for(int j=0;j<3;j++)
					c[i][j]=takeshi.charAt(i*3+j);
			
			if(c[0][0]=='o'&&c[0][1]=='o'&&c[0][2]=='o')System.out.println("o");
			else if(c[0][0]=='x'&&c[0][1]=='x'&&c[0][2]=='x')System.out.println("x");
			else if(c[1][0]=='o'&&c[1][1]=='o'&&c[1][2]=='o')System.out.println("o");
			else if(c[1][0]=='x'&&c[1][1]=='x'&&c[1][2]=='x')System.out.println("x");
			else if(c[2][0]=='o'&&c[2][1]=='o'&&c[2][2]=='o')System.out.println("o");
			else if(c[1][0]=='x'&&c[1][1]=='x'&&c[1][2]=='x')System.out.println("x");
			else if(c[0][0]=='o'&&c[1][0]=='o'&&c[2][0]=='o')System.out.println("o");
			else if(c[0][0]=='x'&&c[1][0]=='x'&&c[2][0]=='x')System.out.println("x");
			else if(c[0][1]=='o'&&c[1][1]=='o'&&c[2][1]=='o')System.out.println("o");
			else if(c[0][1]=='x'&&c[1][1]=='x'&&c[2][1]=='x')System.out.println("x");
			else if(c[0][2]=='o'&&c[1][2]=='o'&&c[2][2]=='o')System.out.println("o");
			else if(c[0][2]=='x'&&c[1][2]=='x'&&c[2][2]=='x')System.out.println("x");
			else if(c[0][0]=='o'&&c[1][1]=='o'&&c[2][2]=='o')System.out.println("o");
			else if(c[0][0]=='x'&&c[1][1]=='x'&&c[2][2]=='x')System.out.println("x");
			else if(c[0][2]=='o'&&c[1][1]=='o'&&c[2][0]=='o')System.out.println("o");
			else if(c[0][2]=='x'&&c[1][1]=='x'&&c[2][0]=='x')System.out.println("x");
			else System.out.println("d");
		}
	}
}

Measured memory_bytes: 12000
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <cassert>

using namespace std;
typedef long long LL;
template <typename F, typename S> std::ostream& operator<<(ostream& os, const pair<F,S>& p) {
    os << "(" << p.first << "," << p.second << ")"; return os; }
template <typename T> ostream& operator<<(ostream& os, const vector<T>& v) {
    os << "["; for(const T& a: v){ os << a << ", "; } os << "]"; return os; }
template <typename K, typename V> ostream& operator<<(ostream& os, const map<K,V>& m) {
    os << "{"; for(const auto& p: m){ os << p.first <<":"<< p.second << ", "; } os << "}"; return os; }



int main(){
    LL n;
    cin >> n;
    vector<pair<LL,LL>> p(n);
    for(LL i = 0; i < n; ++i){
        cin >> p[i].first >> p[i].second;
    }
    sort(p.begin(), p.end(), [](pair<LL,LL>& op1, pair<LL,LL>& op2){
        return atan2(op1.first, op1.second) < atan2(op2.first, op2.second);
    });
    double ans = 0;
    for(LL i = 0; i < n; ++i){
        double dx = 0, dy = 0;
        for(LL j = 0; j < n; ++j){
            dx += p[(i+j)%n].first;
            dy += p[(i+j)%n].second;
            ans = max(ans, sqrt(dx*dx + dy*dy));
        }
    }

    cout << setprecision(13) << ans << endl;
    return 0;
}



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

#define rep(i,n) for (int i = 0; i< (n); ++i)
#define vvec(m,n) vector<vector<int>> (int(m), vector<int>(n))
#define ALL(a) (a).begin(), (a).end()

using ll = long long;

int main(){
    int A, B, C , D;
    cin >> A >> B >> C >> D;
    int train = min(A, B);
    int bus = min(C, D);
    cout << train + bus << endl; 
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, s, k) for (int i = (s); i < (int)(k); i++)

int main(){
    vector<vector<int>> A(3,vector<int>(3));
    rep(a,0,3){
        rep(b,0,3){
            cin >> A.at(a).at(b);
        }
    }
    
    int n;
    cin >> n;
    
    vector<vector<bool>> C(3,vector<bool>(3,false));
    vector<int> B(n);
    rep(i,0,n){
        cin >> B.at(i);
        rep(k,0,3){
            rep(j,0,3){
                if(A.at(k).at(j)==B.at(i)){
                    C.at(k).at(j) = true;
                }
            }
        }
    }
    bool ans = false;

    rep(j,0,3){
        if(C.at(0).at(j)&&C.at(1).at(j)&&C.at(2).at(j)) ans= true;
        if(C.at(j).at(0)&&C.at(j).at(1)&&C.at(j).at(2)) ans= true;
    }
   if(C.at(0).at(0)&&C.at(1).at(1)&&C.at(2).at(2)) ans= true;
   if(C.at(2).at(0)&&C.at(1).at(1)&&C.at(0).at(2)) ans= true;

   cout << ((ans) ? "Yes" : "No" )<< endl;

}

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

const int MOD = 1000000007;

string k;
int d;
long long dp[10001][2][100];
bool sht[10001][2][100];

long long rec(int pos, int free, int csum)
{
    if (sht[pos][free][csum]) return dp[pos][free][csum];
    sht[pos][free][csum] = 1;
    
    if (pos == k.size()) return dp[pos][free][csum] = (csum == 0);
    
    if (free)
    {
        for (int i = 0; i != 10; ++i)
            dp[pos][free][csum] += rec(pos + 1, 1, (csum + i) % d);
        return dp[pos][free][csum] %= MOD;
    }
    else
    {
        for (int i = 0; i != k[pos]; ++i)
            dp[pos][free][csum] += rec(pos + 1, 1, (csum + i) % d);
        return (dp[pos][free][csum] += rec(pos + 1, 0, (csum + k[pos]) % d)) %= MOD;
    }
}

int main()
{    
    cin >> k >> d;
    for (int i = 0; i != k.size(); ++i)
        k[i] -= '0';
    
    cout << (rec(0, 0, 0) + MOD - 1) % MOD;
}

Measured memory_bytes: 18688
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    string N;
    int K;
    cin >> N >> K;
    int keta = N.size();
    vector<vector<vector<ll>>> dp(keta + 1, vector<vector<ll>>(2, vector<ll>(K + 1, 0)));//<左からN indexまで>、<境界は1、それ以外0>、<0以外の数>
    dp.at(1).at(1).at(1) = 1;
    dp.at(1).at(0).at(1) = N.at(0) - '0' - 1;
    for(int i = 2; i <= keta; i++)
    {
        dp.at(i - 1).at(0).at(0) = 1;
        int num = N.at(i - 1) - '0';
        for(int j = 1; j <= K; j++)
        {
            if(num > 0)
            {
                dp.at(i).at(1).at(j) = dp.at(i - 1).at(1).at(j - 1);
            } else {
                dp.at(i).at(1).at(j) = dp.at(i - 1).at(1).at(j);
            }
        }
        for(int j = 1; j <= K; j++)
        {
            //今回の桁が0の分
            dp.at(i).at(0).at(j) += dp.at(i - 1).at(0).at(j);
            //今回の桁が0以外の分
            dp.at(i).at(0).at(j) += dp.at(i - 1).at(0).at(j - 1) * 9;
            if(num > 0)
            {
                //境界から0の分もこちらに追加(numが0の時は境界の方に追加されているので追加しない)
                dp.at(i).at(0).at(j) += dp.at(i - 1).at(1).at(j);
                dp.at(i).at(0).at(j) += dp.at(i - 1).at(1).at(j - 1) * (num - 1);
            }
            
        }
    }
    ll answer = dp.at(keta).at(1).at(K) + dp.at(keta).at(0).at(K);
    cout << answer << endl;
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <stdlib.h>
#include <algorithm>
using namespace std;
int main()
{
	int ban;
	int i, n, k;
	int a[10] = {0};
	scanf("%d %d", &n, &k);
	for(i = 1 ; i <= k ; i++)
	{
		scanf("%d", &ban);
		a[ban] = 1;
	}
	int m, fuck;
	int vis = 1;
	for(;;)
	{
		vis = 1;
		m = n;
		while(m)
		{
			fuck = m % 10;
			if(a[fuck] == 1)
			{
				vis = 0;
			}
			m = m / 10;
		}
		if(vis == 1)
		{
			printf("%d\n",n);
			break;
		}
		n = n + 1;
	}
	return 0;
}

Measured memory_bytes: 128
import java.util.Scanner

object Main extends App  {
  val sc = new Scanner(System.in)
  val n = sc.nextInt
  val k = sc.nextInt
  val s = sc.next

  val res = s.zipWithIndex.foldLeft(""){case (sum, (c,i)) =>
    if(i != k - 1) sum + c
    else sum + c.toString.toLowerCase
  }

  println(res)

}


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

using namespace std;

int main() {

    int W,H,x,y,r;
    cin>>W>>H>>x>>y>>r;

    if(x >= r && y >= r && W >= x + r && H >= y + r)
    {
        cout<<"Yes"<<endl;
    } else{
        cout<<"No"<<endl;
    }

    return 0;
}


Measured memory_bytes: 3100
#include <fstream>
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <queue>
#include <set>
#include <cmath>
#include <climits>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <numeric>
#include <math.h>

#define rep(i,n) for (int i = 0; i < (n); ++i)
#define sz(x) int(x.size())

using namespace std;
typedef long long ll;

int main() {
#ifdef RUN_LOCAL
  ifstream in("../input.txt");
  cin.rdbuf(in.rdbuf());
#endif

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

  int n;
  cin >> n;

  cout << std::setprecision(10) << 2 * n * M_PI << endl;



  return 0;
}


Measured memory_bytes: 3260
import java.util.*;

class Main {
	static Scanner sc = new Scanner(System.in);
	public static void main(String[] args) {
		
		while (true) {
			int n = sc.nextInt();
			if (n == 0) break;
			
			double[] ar = new double[n];
			double sum = 0;
			for (int i=0; i<n; i++) {
				ar[i] = sc.nextInt();
				sum += ar[i];
			}
			double avg = sum/(double)n;
			double bunsan = 0;
			for (int i=0; i<n; i++) {
				ar[i] -= avg;
				ar[i] = ar[i] * ar[i];
				bunsan += ar[i];
			}
			
			System.out.println(String.format("%.5f",Math.sqrt(bunsan/n)));
			
		}
		
	}
}


Measured memory_bytes: 31324
#pragma warning(disable:4996)


#include<iostream>
#include<algorithm>
//#include<unordered_map>
#include<fstream>
#include<iomanip>
#include<string>
#include<cmath>
#include<cstring>
#include<vector>
#include<map>
#include<set>
#include<list>
#include<queue>
#include<stack>
#include<sstream>
#include<cstdio>
#include<ctime>
#include<cstdlib>
#define INF 0x3f3f3f3f
#define inf 0x7FFFFFFF
#define MOD 1000000007
#define pii pair<ll,ll>
#define eps 1e-8
#define equals(a,b) (fabs(a-b)<eps)
#define bug puts("bug")
#define re  register
#define fi first
#define se second
const int maxn = 2e5+ 5;
const double Inf = 10000.0;
const double PI = acos(-1.0);
typedef  long long ll;
using namespace std;

int main() {
	char ch;
	cin >> ch;
	if (ch >= 'A' && ch <= 'Z') puts("A");
	else puts("a");
}

Measured memory_bytes: 3620
//#include <bits/stdc++.h>
//#include <stdio.h>
#include<iostream>
#include<cstdio>
#include<bitset>
#include<algorithm>
#include<vector>
#include<list>
#include<queue>
#include<stack>
#include<string>
#include<string.h>
#include<cmath>
#include<utility>
#include<functional>
#include<map>
#include<set>
#include<cctype>
#include<fstream>


#define FOR(i, a, b) for( int i=(a);i<=(b);i++)
#define RFOR(i, a, b) for( int i=(a);i>=(b);i--)
#define LFOR(i, a, b) for( long long int i=(a);i<=(b);i++)
#define LRFOR(i, a, b) for(long long int i=(a);i>=(b);i--)
#define MOD 1000000007
#define INF 1000000000 //2000000000
#define LLINF 1000000000000000000 //9000000000000000000
#define PI 3.14159265358979
#define MAXI 7500000

using namespace std;
typedef long long int ll;
typedef pair< long long int, long long  int> P;

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

long long int dp[51][51] = {};

int main(void) {
	vector<string> c(3);
	int count;

	cin >> c[0] >> c[1] >> c[2];

	sort(c.begin(), c.end());

	c[2] += c[1];

	count = stoi(c[0]) + stoi(c[2]);

	cout << count << endl;


	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#pragma GCC optimize("unroll-loops,no-stack-protector")
#pragma GCC target("sse,sse2,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define watch(x) cout <<(#x)<<" is "<<(x)<<endl
#define debug cout <<"hi"<<endl
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
const int MOD=1e9+7;
const int INF32=1<<30;
const ll INF64=1LL<<60;
int main(){
  int n,k; cin >>n >>k; int sum=0;
  vector<int>v(n);
  for(int i=0; i<n; i++) cin >>v[i];
  for(int i=0; i<k; i++) sum+=v[i];
  int tem=sum;
  for(int i=k; i<n; i++){
    tem+=v[i]-v[i-k];
    sum=max(sum,tem);
  }
  cout <<fixed<<setprecision(10)<<(sum+k)/2.0;
return 0;}

Measured memory_bytes: 1024
#pragma region

#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define _rep3(i, begin, end) for (register int i = (begin), i##_end = (end); i < i##_end; i++)
#define _irep3(i, begin, end) for (register int i = (end)-1, i##_begin = (begin); i >= i##_begin; i--)
#define _rep2(i, n) _rep3(i, 0, n)
#define _irep2(i, n) _irep3(i, 0, n)
#define _overload3(_1, _2, _3, name, ...) name
#define rep(...) _overload3(__VA_ARGS__, _rep3, _rep2, )(__VA_ARGS__)
#define irep(...) _overload3(__VA_ARGS__, _irep3, _irep2, )(__VA_ARGS__)
#define out(x) cout << (x) << '\n';
#define debug(x) cerr << #x << " = " << (x) << " (line: " << __LINE__ << ") " << endl;

using namespace std;
using ll = long long;
using vi = vector<int>;
using vl = vector<long long>;
using vb = vector<bool>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<long long>>;
using vvb = vector<vector<bool>>;

template <typename T>
istream &operator>>(istream &is, vector<T> &vec) {
  for (auto &v : vec) is >> v;
  return is;
}
template <typename T1, typename T2>
istream &operator>>(istream &is, pair<T1, T2> &pair) {
  cin >> pair.first >> pair.second;
  return is;
}
template <typename T>
ostream &operator<<(ostream &os, const vector<T> &vec) {
  os << "[ ";
  rep(i, vec.size()) i == 0 ? os << vec[i] : os << ", " << vec[i];
  os << " ]";
  return os;
}

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;
}

void init() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(16) << boolalpha;
}

#pragma endregion

#define MOD 1000000007
#define INF 2147483647

int main() {
  init();

  double A, B;
  cin >> A >> B;
  int ans = (int)max(ceil(A / 0.08), ceil(B / 0.1));
  double a1 = ceil(A / 0.08), b2 = ceil((B + 1) / 0.1) - 1, b1 = ceil(B / 0.1), a2 = ceil((A + 1) / 0.08) - 1;
  if (a1 <= b2 && b1 <= a2) {
    out(ans);
  } else {
    out(-1);
  }
}

Measured memory_bytes: 256
#!/usr/bin/env ruby
require 'prime'

n = gets.chomp.to_i

ans = 0

1.upto(n) do |i|
  counter = 0
  1.upto(i) do |j|
    counter += 1 if i % j == 0
  end
  ans += 1 if counter == 8 && i % 2 == 1
end

puts ans


Measured memory_bytes: 14292
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		
		while(true){
			int n = stdIn.nextInt();
			int m = stdIn.nextInt();
			if((n|m)==0){
				return;
			}
			int[] map = new int[n+1];
			for(int i=1;i<=n;i++){
				map[i] = stdIn.nextInt();
			}
			int[] dice = new int[m+1];
			for(int i=1;i<=m;i++){
				dice[i] = stdIn.nextInt();
			}
			int now = 1;
			int i = 1;
			for(;i<=m;i++){
				now += dice[i];
				if(now>=n){
					break;
				}
				now += map[now];
				if(now>=n){
					break;
				}
			}
			System.out.println(i);
		}
	}
}

Measured memory_bytes: 12000
#include<bits/stdc++.h>
#define _LIBCPP_DEBUG 0
using namespace std;
typedef long long int ll;
ll MOD = 1e9 + 7;
int INF = 1 << 20;

int main(void){

    int N; cin>>N;
    map<ll,ll> mp;
    map<ll,ll> mpCOM, mpHOjo;

    vector<ll> A(N);

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

    for(auto it:mp){
        ll tmp = it.second;
        ll ans = tmp * (tmp-1) / 2;
        mpCOM[it.first]+=ans;
        sum += ans;

        tmp = it.second-1;
        ans = tmp*(tmp-1)/2;
        mpHOjo[it.first]+=ans;
    }

    for (int i = 0; i < N; ++i) { //Aを回す
        ll ans=0;
        ans = sum - mpCOM[A[i]] + mpHOjo[A[i]];
        cout<<ans<<endl;
    }
    return 0;
}


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

const ll M = 1000000007;

vector<ll> fac(100005);
vector<ll> ifac(100005);

//べき乗高速化
ll mpow(ll x, ll n){
	ll ans = 1;
	while(n != 0){
		if (n&1) ans = ans * x % M;
		x = x*x % M;
		n  = n >> 1;
	}
	return ans;
}


//aCbを計算
ll comb(ll a, ll b){
	if (a == 0 && b == 0) return 1;
	if (a < b || a < 0){
		return 0;
	}
	ll temp = ifac[a-b] * ifac[b] % M;
	return temp * fac[a] % M;
}


int main(){
	ll n, k;
	cin >> n >> k;
	vector<ll> A(n);
	rep(i,n){
		cin >> A[i];
	}
	
	sort(A.begin(),A.end());
	
	fac[0] = 1;
	ifac[0] = 1;
	for(ll i = 0; i<= 100000; i++){
		fac[i+1] = fac[i]*(i+1) % M; // n!(mod M)
		ifac[i+1] = ifac[i]*mpow(i+1, M-2) % M; // k!^{M-2} (mod M) ←累乗にmpowを採用
	}
	
	vector<ll> maximum(n);
	vector<ll> minimum(n);
	
	rep(i,n){
		maximum[i] = comb(i, k-1);
		minimum[i] = comb(n-1-i, k-1);
	}
	
	ll ans = 0;
	rep(i,n){
		ans += A[i]*maximum[i];
		ans %= M;
		ans -= A[i]*minimum[i];
		ans %= M;
	}
	
	cout << ans << endl;
    return 0;
}



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

const int MAX_N = 50, MAX_X = 50, MAX_A = 50;

int main(){
    int N, A; cin >> N >> A;
    vector<int> X(N);
    vector<int> Y(N+1);
    for(int i = 0; i < N; i++) cin >> X[i];
    for(int i = 1; i <= N; i++) Y[i] = X[i-1] - A;
    Y[0] = 0;

    int MAX = max(A, *max_element(X.begin(), X.end()));
    //cout << MAX << endl;
    
    //dp[j][t] := j枚目までで0枚以上選んで合計をt - NAにするような選び方の総数
    ll dp[MAX_N+1][2 * MAX_N * MAX_A] = {0};
    for(int j = 0; j <= N; j++){
        for(int t = 0; t <= 2 * N * MAX; t++){
            if(j == 0 && t == N * MAX) dp[j][t] = 1;
            else if(j >= 1 && (t - Y[j] < 0 || t - Y[j] > 2 * N * MAX) ) dp[j][t] = dp[j-1][t];
            else if(j >= 1 && 0 <= t - Y[j] && t - Y[j] <= 2 * N * MAX) dp[j][t] = dp[j-1][t] + dp[j-1][t-Y[j]];
            else dp[j][t] = 0;
        }
    }

    /* for(int j = 0; j <= N; j++){
        cout << j;
        for(int t = 0; t <= 2 * N * MAX; t++){
            cout << " " << t << ":"<< dp[j][t];
        }
        cout <<endl;
    } */

    cout << dp[N][N * MAX] - 1 << endl;
}

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

int main(){
  auto res = 0;
  int N; std::cin >> N;
  std::vector<std::pair<int, int>> r(N);
  std::vector<std::pair<int, int>> b(N);
  for(auto i=0; i<N; ++i)
    std::cin >> r[i].first >> r[i].second;
  // std::sort(r.begin(), r.end());
  // std::reverse(r.begin(), r.end());
  for(auto i=0; i<N; ++i)
    std::cin >> b[i].first >> b[i].second;
  // std::sort(b.begin(), b.end());
  for(auto nub=0; nub<N; ++nub){
    auto besti = -1;
    auto bestinb = N+1;
    for(auto i=0; i<r.size(); ++i){
      auto nbok = 0;
      for(auto j=0; j<b.size(); ++j){
	if(r[i].first <= b[j].first and r[i].second <= b[j].second)
	  ++nbok;
      }
      if(nbok and nbok < bestinb){
	besti = i;
	bestinb = nbok;
      }
    }
    if(besti == -1)
      break;
    auto bestj = -1;
    auto bestjnb = N+1;
    for(auto j=0; j<b.size(); ++j){
      auto nbok = 0;
      if(r[besti].first > b[j].first or r[besti].second > b[j].second)
	continue;
      for(auto i=0; i<r.size(); ++i)
	if(r[i].first <= b[j].first and r[i].second <= b[j].second)
	  ++nbok;
      if(nbok < bestjnb){
	bestj = j;
	bestjnb = nbok;
      }      
    }
    ++res;
    r.erase(r.begin()+besti);
    b.erase(b.begin()+bestj);
  }
  std::cout << res << '\n';
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long int
#define mk make_pair
#define pb push_back
#define INF (ll)1e18
#define pii pair<ll,ll>
#define mod 1000000007 //998244353
#define f(i,a,b) for(ll i=a;i<b;i++)
#define fb(i,a,b) for(ll i=a;i>b;i--)
#define ff first
#define ss second
#define PI 3.141592653589793238
#define pq priority_queue<ll>
#define pqr priority_queue<ll,vector<ll>,greater<ll>()>
using namespace std;
ll pow_mod(ll a,ll b)
{
	ll res=1;
	while(b!=0)
	{
		if(b&1)
		{
			res=(res*a)%mod;
		}
		a=(a*a)%mod;
		b/=2;
	}
	return res;
}
void solve()
{ 
    ll n;
    
    cin>>n;
    
    ll a[n];
    
    for(ll i=0;i<n;i++)
    cin>>a[i];
    
    ll ans=0;
    
    for(ll i=1;i<n;i++){
        if(a[i]<a[i-1]){
            ans+=(a[i-1]-a[i]);
            
            a[i]=a[i-1];
        }
    }
    cout<<ans<<endl;
    
}
int32_t main()
{    ios_base::sync_with_stdio(false);
     cin.tie(NULL);
     cout.tie(NULL);
     
//Start from Here.

  ll t;
  t=1;
  //cin>>t;
  while(t--)
  solve();
  
//Good Bye!
    return 0;
}

Measured memory_bytes: 5208
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define stoi stoll
using pii=pair<int,int>;
#define all(c) begin(c),end(c)
#define rall(c) rbegin(c),rend(c)
#define fore(x,c) for(auto &&x:c)
#define rep(i,a,n) for(int i=a,i##len=(int)(n);i<i##len;++i)
#define rrep(i, a, n) for(int i=(int)(n-1);i>=a;--i)
#define sz(c) ((int)c.size())
#define contains(c,x) (c.find(x)!=end(c))
#define inseg(l,x,r) ((l)<=(x)&&(x)<(r))
#define dump(...)
#define pb push_back
#define _ 0
const signed INF_=1001001001; const long long INF=1001001001001001001LL;
const int DX[9]={0,1,0,-1,1,1,-1,-1,0},DY[9]={-1,0,1,0,-1,1,1,-1,0};
template<class T> ostream& operator<<(ostream &os,const vector<T> &v) {
    for (auto i = begin(v); i != end(v); i++) os<<*i<<(i==end(v)-1?"":" ");return os;}
template<class T> istream& operator>>(istream &is,vector<T> &v) {
    for (auto i = begin(v); i != end(v); i++) is>>*i;return is;}
template<class T,class U> istream& operator>>(istream &is, pair<T,U> &p) {
    is>>p.first>>p.second;return is;}
template<class T, class U> bool chmax(T &a,const U &b){return a<b?a=b,1:0;}
template<class T, class U> bool chmin(T &a,const U &b){return a>b?a=b,1:0;}
template <class T> void psum(T& c) {partial_sum(begin(c), end(c), begin(c));}
template<class T> using heap=priority_queue<T,vector<T>,greater<T>>;
struct before_main_function {
    before_main_function() {
        cin.tie(0); ios::sync_with_stdio(0);
        cout << setprecision(15) << fixed;
        // #define endl "\n"
    }
} before_main_function;
//------------------8<------------------------------------8<--------------------

signed main() {
    int N;
    cin >> N;
    vector<int> A(N);
    cin >> A;
    auto L = A;
    auto R = A;
    rep(i, 1, N) {
        L[i] = __gcd(A[i], L[i - 1]);
    }
    rrep(i, 0, N - 1) {
        R[i] = __gcd(A[i], R[i + 1]);
    }
    int ans = 0;
    rep(i, 0, N) {
        int l = i > 0 ? L[i - 1] : 0;
        int r = i < N - 1 ? R[i + 1] : 0;
        chmax(ans, __gcd(l, r));
    }
    cout << ans << endl;
    return (0^_^0);
}



Measured memory_bytes: 2560
#include <iostream>
#include <vector>
#include <utility>
#include<algorithm>
#include<stack>
#include<queue>
#include<list>
using namespace std;
int main() {
	int n, m;
	cin >> n >> m;
	vector<int>v(2 * n), u(n);
	for (int i = 0; i < n; i++) {
		cin >> v.at(i);
	}
	vector<pair<int, int>> r(m);
	for (int i = 0; i < m; i++) {
		int a, b;
		cin >> a >> b;
		r.at(i) = make_pair(b, a);
	}

	sort(r.begin(), r.end());
	reverse(r.begin(), r.end());
	int i = 0;
	int j = 0;
	int at = 0;
	while (i < m) {
		while (j < r.at(i).second) {
			u.at(at) = r.at(i).first;
			at++;
			j++;
			if (at == n)
				break;
		}
		i++;
		if (at == n)
			break;
		j = 0;
	}
	for (int i = 0; i < n; i++) {
		v.at(n + i) = u.at(i);
	}
	sort(v.begin(), v.end());
	int64_t ans = 0;
	for (int i = 0; i < n; i++) {
		ans += v.at(n + i);
	}
	cout << ans << endl;
	return 0;
}

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

using namespace std;

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

	int res=0;
	for(int i=0;i<s.size();i++){
		if(s[i]!=t[i]){
			res++;
		}
	}
	cout<<res<<endl;
	return 0;
}

Measured memory_bytes: 3924
#pragma GCC optimize("O3")
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
using namespace std;

using ll = long long;
using P = pair<int, int>;
using T = tuple<int, int, int>;

template <class T> inline T chmax(T &a, const T b) {return a = (a < b) ? b : a;}
template <class T> inline T chmin(T &a, const T b) {return a = (a > b) ? b : a;}

constexpr int MOD = 1e9 + 7;
constexpr int inf = 1e9;
constexpr long long INF = 1e18;
constexpr double pi = acos(-1);
constexpr double EPS = 1e-10;

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

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

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

    // from left
    vector<int> l(n+1, 0);
    for(int i=0; i<n; i++){
        int cnt = 0;
        while(i < n && s[i] == '<'){
            l[i] = cnt, l[i+1] = cnt + 1;
            i++, cnt++;
        }
    }

    // from right
    vector<int> r(n+1, 0);
    for(int i=n-1; i>=0; i--){
        int cnt = 0;
        while(i >= 0 && s[i] == '>'){
            r[i] = cnt + 1, r[i+1] = cnt;
            i--, cnt++;
        }
    }

    vector<ll> ans(n+1);
    for(int i=0; i<=n; i++){
        ans[i] = max(l[i], r[i]);
    }

    cout << accumulate(ans.begin(), ans.end(), 0LL) << endl;

    return 0;
}

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

void fastio()
{
  ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
}

int main()
{
  fastio();
  double r;
  cin >> r;
  double c = 6.28318530717958623200 * r;
  cout << c;
  return 0;
}


Measured memory_bytes: 3260
#include <algorithm>
#include <iostream>
#include <vector>
#include <queue>
#include <set>
#include <string>
#include <map>
#include <cmath>
#include <cstring>

#define fi first
#define se second
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rrep(i,n) for (int i = 1; i < (n); ++i)
#define drep(i,n) for (int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define all(x) (x).begin(), (x).end()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define pb push_back
#define sz(x) (int)(x).size()
#define PQ(T) priority_queue<T, v(T), greater<T> >

using namespace std;
using ll = long long;
using uint = unsigned;
using ull = unsigned long long;
using P = pair<int,int>;

const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;

const int mod = 1000000007;

int main() {
    int k; cin >> k;
    vector<ll> a;
    for (int i=1; i<10; ++i) a.push_back(i);
    
    while (1) {
        if (k<=a.size()) {
            cout << a[k-1] << endl;
            return 0;
        }
        k-=a.size();
        vector<ll> old;
        swap(a,old);
        for (ll ai: old){
            for (int i=-1; i<=1; ++i) {
                int j = ai%10+i;
                if (j<0||j>9) continue;
                a.push_back(ai*10+j);
            }
        }
    
    }
    return 0;
}









Measured memory_bytes: 1712
n, k, q = map(int, input().split())
score = [k] * n
for i in range(q):
    a = int(input())
    score[a-1] += 1
score = [x-q for x in score]
for i in score:
    if i > 0:
        print('Yes')
    else:
        print('No')


Measured memory_bytes: 9776
using static System.Math;
using System.Linq;
using System.Collections.Generic;
using System;

public class Hello
{
    public static void Main()
    {
        var n = int.Parse(Console.ReadLine().Trim());
        string[] line = Console.ReadLine().Trim().Split(' ');
        var a = Array.ConvertAll(line, int.Parse);
        if (n == 2) { Console.WriteLine(a.Max()); goto exit; }
        var L = new int[n - 1];
        var r = new int[n - 1];
        L[0] = gcd(a[0], a[1]);
        r[0] = gcd(a[n - 1], a[n - 2]);
        for (int i = 1; i < n - 1; i++)
        {
            L[i] = gcd(L[i - 1], a[i + 1]);
            r[i] = gcd(r[i - 1], a[n - 2 - i]);
        }
        var ans = getAns(a, L, r, n);
        Console.WriteLine(ans);
    exit:;
    }
    static int getAns(int[] a, int[] L, int[] r, int n)
    {
        var ans = 0;
        if (n == 3) 
        {
            ans = Max(L[0], r[0]);
            return Max(ans, gcd(a[0], a[2]));
        }
        for (int i = 2; i < n - 2; i++)
        {
            ans = Max(ans, gcd(L[i - 2], r[n - i - 3]));
        }
        ans = Max(ans, r[n - 3]);
        ans = Max(ans, L[n - 3]);
        if (n - 4 >= 0)
        {
            ans = Max(ans, gcd(a[0], r[n - 4]));
            ans = Max(ans, gcd(a[n - 1], L[n - 4]));
        }
        return ans;
    }
    static int gcd(int a, int b)
    {
        if (a < b) return gcd(b, a);
        while (b != 0)
        {
            var w = a % b;
            a = b;
            b = w;
        }
        return a;
    }
}

Measured memory_bytes: 27868
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int h = sc.nextInt();
		int n = sc.nextInt();
		int sum = 0;
		for(int i = 0; i < n; i++) {
			sum += sc.nextInt();
			if(sum >= h) {
				System.out.println("Yes");
				System.exit(0);
			}
		}
		System.out.println("No");
		sc.close();
	}
}

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

#define fec(i, x, y) (int i = head[x], y = g[i].to; i; i = g[i].ne, y = g[i].to)
#define dbg(...) fprintf(stderr, __VA_ARGS__)
#define File(x) freopen(#x".in", "r", stdin), freopen(#x".out", "w", stdout)
#define fi first
#define se second
#define pb push_back

template<typename A, typename B> inline char SMAX(A &a, const B &b) {return a < b ? a = b , 1 : 0;}
template<typename A, typename B> inline char SMIN(A &a, const B &b) {return b < a ? a = b , 1 : 0;}

typedef long long ll; typedef unsigned long long ull; typedef std::pair<int, int> pii;

template<typename I>
inline void read(I &x) {
	int f = 0, c;
	while (!isdigit(c = getchar())) c == '-' ? f = 1 : 0;
	x = c & 15;
	while (isdigit(c = getchar())) x = (x << 1) + (x << 3) + (c & 15);
	f ? x = -x : 0;
}

const int N = 2000 + 7;
const int P = 998244353;

int n, cntb[N << 1], dp[N << 1][N << 1];
char s[N];

inline void Inc(int &x, int y) {x += y; x >= P ? x -= P : 0;}

int main() {
	#ifdef hzhkk
	freopen("hkk.in", "r", stdin);
	#endif
	scanf("%s", s + 1); n = strlen(s + 1);
	for (int i = 1; i <= n; ++i) cntb[i] = cntb[i - 1] + s[i] - '0';
	for (int i = n + 1; i <= (n << 1); ++i) cntb[i] = cntb[i - 1];
	dp[0][0] = 1;
	for (int i = 1; i <= (n << 1); ++i) {
		for (int j = std::max(cntb[i] - i, 0); j <= std::min(cntb[i], i); ++j) {
			if (j) dp[i][j] = dp[i - 1][j - 1];
			if (i > j) Inc(dp[i][j], dp[i - 1][j]);
			//  dbg("dp[%d][%d] = %d\n", i, j, dp[i][j]);
		}
	}
	printf("%d\n", dp[n << 1][cntb[n]]);
}

Measured memory_bytes: 61440
#include <iostream>
#include <vector>
#include <algorithm>
#define rep(i, n) for(int i = 0; i < (int)(n); ++i)
#define REP(i, n) for(int i = 1; i < (int)(n); ++i)
using namespace std;

int main() {
    int N;
    string S;
    cin >> N >> S;
    
    int red = 0;
    int blue = 0;
    rep(i, N) {
        if (S[i] == 'R') ++red;
        if (S[i] == 'B') ++blue;
    }
    
    if (red > blue) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define For(i, a, b) for(int (i)=(a); (i)<(b); ++(i))
#define rFor(i, a, b) for(int (i)=(a)-1; (i)>=(b); --(i))
#define rep(i, n) For((i), 0, (n))
#define rrep(i, n) rFor((i), (n), 0)
#define fi first
#define se second
using namespace std;
typedef long long lint;
typedef pair<int, int> pii;
typedef complex<double> xy_t;

const lint mod = 1e9 + 7;

typedef struct SegTree{
    int n = 1;
    vector<int> node;
    
    SegTree(int n_){
        while(n < n_) n *= 2;
        node.resize(n*2-1, 0);
    }
    
    void update(int i, int x){
        i += n-1;
        node[i] = x;
        while(i){
            i = (i-1)/2;
            node[i] = max(node[i*2+1], node[i*2+2]);
        }
    }
    
    int query(int a, int b, int i, int l, int r){
        if(r<=a || b<=l) return 0;
        if(a<=l && r<=b) return node[i];
        int vl = query(a, b, i*2+1, l, (l+r)/2);
        int vr = query(a, b, i*2+2, (l+r)/2, r);
        return max(vl, vr);
    }
}SegTree;

int fl(int i, int low, int high, int k, SegTree &st){
    if(st.query(high, i+1, 0, 0, st.n) > k) return high;
    while(high - low > 1){
        int mid = (high + low) / 2;
        if(st.query(mid, i+1, 0, 0, st.n) > k) low = mid;
        else high = mid;
    }
    return low;
}

int fr(int i, int low, int high, int k, SegTree &st){
    if(st.query(i, low+1, 0, 0, st.n) > k) return low;
    while(high - low > 1){
        int mid = (high + low) / 2;
        if(st.query(i, mid+1, 0, 0, st.n) > k) high = mid;
        else low = mid;
    }
    return high;
}

int main(){
    int n;
    scanf("%d", &n);
    SegTree st(n+2);
    st.update(0, n+1);
    st.update(n+1, n+1);
    int p[n+2];
    rep(i, n){
        scanf("%d", &p[i+1]);
        st.update(i+1, p[i+1]);
    }
    
    lint ans = 0;
    For(i, 1, n+1){
        int l1 = fl(i, 0, i, p[i], st);
        int l2 = fl(l1-1, 0, l1-1, p[i], st);
        int r1 = fr(i, i, n+1, p[i], st);
        int r2 = fr(r1+1, r1+1, n+1, p[i], st);
        ans += 1LL* p[i] * ((l1-l2)*(r1-i) + (r2-r1)*(i-l1));
    }
    
    printf("%lld\n", ans);
}

Measured memory_bytes: 1664
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<long long,long long> pll;
#define ep emplace_back
#define pb push_back
#define mp make_pair
#define rep(i,n) for(int i=0;i<(n);++i)
constexpr int mod=1000000007;
constexpr int mod1=998244353;
vector<int> dx={0,1,0,-1},dy={-1,0,1,0};
bool inside(int y,int x,int h,int w){
	if(y<h && y>=0 && x<w && x>=0) return true;
	return false;
}


struct edge{
	int a,b,c;
};

const int inf = 1e9;


int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n,m;cin >> n >> m;
	vector<edge> a(m);
	vector<vector<int>> dist(n,vector<int>(n,inf));
	rep(i,m){
		cin >> a.at(i).a >> a.at(i).b >> a.at(i).c;
		a.at(i).a--;
		a.at(i).b--;
		dist[a.at(i).a][a.at(i).b] = min(dist[a.at(i).a][a.at(i).b], a.at(i).c);
		dist[a.at(i).b][a.at(i).a] = min(dist[a.at(i).b][a.at(i).a], a.at(i).c);
	}
	rep(i,n) dist[i][i] = 0;
	rep(k,n){
		rep(i,n){
			rep(j,n){
				dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j]);
			}
		}
	}
	int ans = 0;
	rep(i,m){
		bool flg = true;
		rep(j,n){
			rep(k,n){
				if(j == k) continue;
				if(dist[j][k] == dist[j][a.at(i).a] + dist[a.at(i).b][k] + a.at(i).c || dist[j][k] == dist[j][a.at(i).b] + dist[a.at(i).a][k] + a.at(i).c) flg = false;
			}
		}
		if(flg) ans++;
	}
	cout << ans << endl;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rep2(i, m, n) for(int i = (int)(m); i < (int)(n); i++)
#define rep_inv(i, n, m) for(int i = (int)(n); i > (int)(m); i--)
using namespace std;
using ll = long long;
using vl = vector<ll>;
using vc = vector<char>;
using vvl = vector<vl>;
using vvc = vector<vc>;
using pll = pair<ll, ll>;
using vpii = vector<pll>;

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

  ll N = S.size();
  ll left = 0, right = N - 1;
  while(left < right){
    if(S[left] != S[right]){
      cout << "No" << endl;
      return 0;
    }
    left++;
    right--;
  }
  
  left = 0;
  right = (N - 1) / 2 - 1;

  while(left < right){
    if(S[left] != S[right]){
      cout << "No" << endl;
      return 0;
    }
    left++;
    right--;
  }

  left = (N + 3) / 2 - 1;
  right = N - 1;

  while(left < right){
    if(S[left] != S[right]){
      cout << "No" << endl;
      return 0;
    }
    left++;
    right--;
  }
  
  cout << "Yes" << endl;
  
  return 0;
}

Measured memory_bytes: 256
//
//  main.c
//  aoj_03
//
//  Created by k16031kk on 2018/05/17.
//  Copyright © 2018年 AIT. All rights reserved.
//

#include <stdio.h>

int main(int argc, const char * argv[]) {
    // insert code here...
    int a, b;
    scanf("%d %d",&a, &b);
    int area=a*b;
    int track=a*2+b*2;
    printf("%d %d\n",area, track);
    return 0;
}



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

int main()
{
  int n,ans;
  cin>>n;
  ans=0;
  vector<int> a(n);
  for(int i=0;i<n;i++)
  {
    cin>>a.at(i);
  }
  for(int i=0;i<n;i+=2)
  {
    if(a.at(i)%2!=0)
      ans++;
  }
  cout<<ans<<endl;
}

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

int main() {
    string S, T; cin >> S >> T;
    long long ans = 10000;
    for (long long i = 0; i < S.size(); i++) {
        long long num = 0;
        for (long long j = 0; j < T.size(); j++) {
            if (i + j >= S.size()) num = 100000;
            else if (S.at(i + j) != T.at(j)) num++;
        }
        ans = min(ans, num);
    }
    cout << ans << endl;
}

Measured memory_bytes: 3616
#include <algorithm>
#include <bits/stdc++.h>
#include <bitset>
#include <cassert>
#include <cstring>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <math.h>
#include <memory>
#include <queue>
#include <set>
#include <stack>
#include <utility>
#include <vector>
using namespace std;
#define REP(i, n) for (int64_t i = 0; i < (int64_t)n; i++)
#define REP_FOR(i, a, b) for (int64_t i = (int64_t)a; i < (int64_t)b; i++)
#define REP_REV(i, a, b) for (int64_t i = (int64_t)a; i > (int64_t)b; i--)
#define FORALL(v) (v).begin(), (v).end()
#define mp(a, b) make_pair(a, b)
#define eb(x) emplace_back(x)
#define F first
#define S second
typedef long long ll;
typedef long double ld;
typedef pair<int64_t, int64_t> pii;
typedef pair<ll, ll> pll;
typedef pair<ld, ld> pdd;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<int64_t> vii;
typedef vector<vii> vvii;
const ll mod = 1e9 + 7;
const int64_t infi = 1147483600;
const ll infl = 4e18 + 5;
const char EOL = '\n';
//cout << fixed << setprecision(17) << res << endl;
const ll MOD = 1000000007;

#define M 1000000007

std::vector<ll> fac(400003); //n!(mod M)
std::vector<ll> ifac(400003); //k!^{M-2} (mod M)

//x^n(mod M)d
ll
mpow(ll x, ll n)
{
    ll ans = 1;
    while (n > 0){
        if (n & 1) ans = ans*x % M;
        x = x*x % M;
        n = n >> 1;
    }
    return ans;
}

void
cominit()
{
    fac[0] = 1;
    ifac[0] = 1;
    for (ll i = 0; i < 400003; i++){
        fac[i+1] = fac[i] * (i+1) % M; // n! mod M
        ifac[i+1] = ifac[i] * mpow(i+1, M-2) % M; // k!^{M-2} mod M
    }
}


ll
comb(ll a, ll b)  // aCb mod M
{
    if (a == 0 && b == 0) return 1;
    if (a < b || a < 0) return 0;
    ll tmp = ifac[a-b] * ifac[b] % M;
    return tmp * fac[a] % M;
}

inline ll Mcomb(ll n, ll r){ return comb(n + r - 1, n - 1); } // r個をn部屋に分ける

int main() {
    cominit();
    ll n, k;
    cin >> n >> k;
    ll res;
    k = min(n-1, k);
    res = 0;
    for (ll i = 0; i <= k ; ++i) {
        if (i == 0 && k == 1) continue;
        res += (Mcomb(n-i, i) * comb(n, i)) % M;
        res %= M;
    }
    res = (res + M)%M;
    cout << res << endl;
}


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

using namespace std;

long len(long N) {
  if (N == 0) return 1;
  return 3 + 2 * len(N-1);
}

long pat(long N) {
  if (N == 0) return 1;
  return 1 + 2 * pat(N-1);
}

long calc(long N, long X, vector<long> len_vec, vector<long> pat_vec) {
  if (X == 0) return 0;
  if (X == len_vec[N]) {
    return pat_vec[N];
  }
  if (X <= len_vec[N-1] + 1) {
    return calc(N-1, X-1, len_vec, pat_vec);
  }
  X = X - 1 - len_vec[N-1] - 1;
  long ans = pat_vec[N-1] + 1;
  if (X == 0) {
    return ans;
  }
  return ans + calc(N-1, X, len_vec, pat_vec);
}

int main(void) {
  long N, X;
  cin >> N >> X;

  vector<long> len_vec;
  vector<long> pat_vec;

  for (long i = 0; i <= 50; i++) {
    len_vec.push_back(len(i));
    pat_vec.push_back(pat(i));
  }

  long ans = calc(N, X, len_vec, pat_vec);

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
from itertools import permutations
def main():
    n = int(input())
    p = tuple(map(int, input().split()))
    q = tuple(map(int, input().split()))
    n_num = [i for i in range(1, n+1)]
    n_list = list(permutations(n_num, n))
    n_list.sort()
    p_pos = n_list.index(p)
    q_pos = n_list.index(q)
    print(abs(p_pos - q_pos))

if __name__ == '__main__':
    main()


Measured memory_bytes: 8052
import math

def range_prod(lo,hi):
    if lo+1 < hi:
        mid = (hi+lo)//2
        return range_prod(lo,mid) * range_prod(mid+1,hi)
    if lo == hi:
        return lo
    return lo*hi

def treefactorial(n):
    if n < 2:
        return 1
    return range_prod(1,n)
n = int(input())
m = 10**9+7
print(treefactorial(n%m)%m)


Measured memory_bytes: 4140
/*input
8 6
*/
#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;
}
int main()
{
	IOS;
	int n;
	cin>>n;
	cout<<n/2*((n+1)/2);
	return 0;
}


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

using namespace std;

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

int cst(string a, string b) {
    int c = 0;
    for (int i = 0; i < a.size(); i++)
        if (a[i] != b[i]) c++;
    return c;
}

void solve(long long N, std::string A, std::string B, std::string C) {

    long long ans = 0;
    for(int i = 0 ; i < N ; i++){
        int c[128] = {};
        c[A[i]]++;
        c[B[i]]++;
        c[C[i]]++;
        int sub = 1e9;
        for(int j = 0 ; j < 26 ; j++){
            sub = min(3 - c['a'+j], sub);
        }
        ans += sub;
    }
    cout << ans << endl;
}


int main() {
    long long N;
    scanf("%lld", &N);
    std::string A;
    std::cin >> A;
    std::string B;
    std::cin >> B;
    std::string C;
    std::cin >> C;
    solve(N, A, B, C);
    return 0;
}


Measured memory_bytes: 256
N,K=map(int,input().split())
S=input()
#Aは0の左端、Bは0の右端
A=[]
B=[]
for i in range(N-1):
  if S[i]=='0'and S[i+1]=='1':
    B.append(i)
if S[-1]=='0':
  B.append(N-1)
if S[0]=='0':
  A.append(0)
for i in range(N-1):
  if S[i]=='1'and S[i+1]=='0':
    A.append(i+1)

if len(A)<=K:
  print(N)
else:
  y=A[K]
  z=N-B[-1*(K+1)]-1
  l=0
  ans=0
  for i in range(len(A)-K-1):
    l=A[i+K+1]-B[i]-1
    ans=max(l,ans)
  print(max(ans,y,z))

Measured memory_bytes: 7108
s = input()
t = input()
li = []

if t in s:
    if "?" in s:
        print(s.replace("?", "a"))
        exit()
    else:
        print(s)
        exit()

for i in range(len(s) - len(t) + 1):
    target = s[i:i+len(t)]
    flag = True
    for j in range(len(t)):
        if target[j] != "?" and target[j] != t[j]:
            flag = False
    if flag:
        li.append(s[:i] + t + s[i+len(t):])

if len(li) == 0:
    print("UNRESTORABLE")
    exit()

li = sorted(li)
print(li[0].replace("?", "a"))

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

int main() {
	
	int abcd;
	cin >> abcd;
	int d[4] = {0};
	int i = 3;
	while(abcd){
		d[i] = abcd % 10;
		abcd /= 10;
		i--;
	}
	rep(op1, 2) rep(op2, 2) rep(op3, 2){
		int cal = d[0];
		if(op1) cal += d[1];
		else cal -= d[1];
		if(op2) cal += d[2];
		else cal -= d[2];
		if(op3) cal += d[3];
		else cal -= d[3];
		if(cal == 7){
			string op[4];
			op[0] = (op1) ? "+" : "-";
			op[1] = (op2) ? "+" : "-";
			op[2] = (op3) ? "+" : "-";
			op[3] = "=7";
			rep(i, 4){
				cout << d[i] << op[i];
			}
			cout << endl;
			return 0;
		}
	}
	return 0;
}

Measured memory_bytes: 256