akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <math.h>
#include <stdlib.h>

#define MAX 100

double get_manhattan_dist(int n, int x[], int y[]);
double get_euclid_dist(int n, int x[], int y[]);
double get_p3_dist(int n, int x[], int y[]);
double get_chebyshev_dist(int n, int x[], int y[]);

int main(void)
{
    int i;

    int n;
    scanf("%d", &n);

    int x[MAX], y[MAX];
    for (i = 0; i < n; i++) {
        scanf("%d", &x[i]);
    }
    for (i = 0; i < n; i++) {
        scanf("%d", &y[i]);
    }

    double manhattan_dist = get_manhattan_dist(n, x, y);
    double euclid_dist = get_euclid_dist(n, x, y);
    double p3_dist = get_p3_dist(n, x, y);
    double chebyshev_dist = get_chebyshev_dist(n, x, y);

    printf("%f\n%f\n%f\n%f\n",
            manhattan_dist, euclid_dist, p3_dist, chebyshev_dist);

    return 0;
}

double get_manhattan_dist(int n, int x[], int y[])
{
    int i;

    double dist = 0;
    for (i = 0; i < n; i++) {
        dist += abs(x[i] - y[i]);
    }

    return dist;
}

double get_euclid_dist(int n, int x[], int y[])
{
    int i;

    double dist = 0;
    for (i = 0; i < n; i++) {
        dist += pow(x[i] - y[i], 2);
    }
    dist = sqrt(dist);

    return dist;
}

double get_p3_dist(int n, int x[], int y[])
{
    int i;

    double dist = 0;
    for (i = 0; i < n; i++) {
        dist += pow(abs(x[i] - y[i]), 3);
    }
    dist = cbrt(dist);

    return dist;
}

double get_chebyshev_dist(int n, int x[], int y[])
{
    int i;

    double max = abs(x[0] - y[0]);
    for (i = 1; i < n; i++) {
        int dist = abs(x[i] - y[i]);
        if (dist > max) {
            max = dist;
        }
    }

    return max;
}


Measured memory_bytes: 2128
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>
using namespace std;
namespace mp = boost::multiprecision; // int64_tは9*10^18まで

int main() {
  int n, res=0;
  cin >> n;
  int a[n], ct[100001]={0}, ct2=0;
  for(int i=0; i<n; i++){
    cin >> a[i];
    ct[a[i]]++;
  }
  for(int i=1; i<=100000; i++){
    if(ct[i]%2==0&&ct[i]>=2) ct2++;
    if(ct[i]%2==1&&ct[i]>=3){
      res+=(ct[i]-1)/2;
    }
    else if(ct[i]%2==0&&ct[i]>=4){
      res+=(ct[i]-2)/2;
    }
  }
  if(ct2%2==0) res+=ct2/2;
  else res+=ct2/2+1;
  cout << n-res*2;
  return 0;
}

Measured memory_bytes: 4436
#接地面が奇数の場合は最終的に面になる。
#接地面が奇数のカードは最終的に面になる
#角のカードアは必ず最終的に面になる（高さ１や幅n１の時は例外）

n,m = gets.chomp.split(" ")
n_i = n.to_i
m_i = m.to_i

ans = 0

if n_i == 1 && m_i == 1
    ans = 1
elsif n_i == 1
    ans = m_i - 2
elsif m_i == 1
    ans = n_i - 2
else
    ans = (n_i-2)*(m_i-2)
end

puts ans

Measured memory_bytes: 1788
#include <bits/stdc++.h>
using namespace std;
#define lld long long int
#define M 1000000007
#define fors(i,n) for(int i=0;i<n;++i)
#define fore(i,a,b) for(int i=a;i<=b;++i)
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define vv vector<int>
#define endl "\n"
#define test(i) cout<<i<<endl
#define itrt int t; cin>>t; fors(i,t)
#define itr1 int t; cin>>t;
#define ff first
#define ss second
#define pb push_back
#define vmp make_pair
#define ppb pop_back
#define sorta(a,n) sort(arr,arr+n)
#define sortv(x) sort(x.begin(),x.end())
void file(){
    #ifdef LOCAL
    freopen("demo.in","r",stdin);
    freopen("demo.out","w",stdout);
    #endif
}

int n;

void dfs(string s,char mx){
  if(s.size()==n){
    test(s);
  }
  else{
    for(char c='a';c<=mx;++c){
      if(c==mx){
        dfs(s+c,char(mx+1));
      }
      else{
        dfs(s+c,mx);
      }
    }
  }
}

int main(){ 
  fastio;
  file();
  cin>>n;
  dfs("",'a');
  return 0;
} 


Measured memory_bytes: 1536
N,M,K = map(int,input().split())
ansx = -1
ansy = -1
for k in range(N+1):
  for l in range(M+1):
    if k*(M-l)+l*(N-k) == K:
      ansx = k
      ansy = l
if ansx == -1 and ansy == -1:
  print('No')
else:
  print('Yes')

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

using namespace std;

int main()
{
    int N;
    int a[2][105];
    int dp1[105]={0};
    int dp2[105]={0};
    cin>>N;
    for(int i=1;i<=N;i++)
    {
        cin>>a[0][i];
    }
    for(int i=1;i<=N;i++)
    {
        cin>>a[1][i];
    }
    for(int i=1;i<=N;i++)
    {
        dp1[i]=dp1[i-1]+a[0][i];
    }
    for(int i=N;i>=1;i--)
    {
        dp2[i]=dp2[i+1]+a[1][i];
    }
    long long res=0,sum=0;
    for(int i=1;i<=N;i++)
    {
        for(int j=1;j<=N;j++)
        {
            sum=dp1[j]+dp2[j];
            res=max(res,sum);
        }
    }
    cout<<res<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i=0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
using ll = long long;
using VI = vector<int>;
using VVI = vector<vector<int>>;

int main(){
  int n;
  string s;
  cin >> n >> s;
  
  int cnt=1;
  rep(i,n-1){
    if(s[i] != s[i+1]) cnt++;
  }
  
  cout << cnt << endl;
  
  return 0;
}

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

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

int n, w, d;
P v[1002];


int main() {
    cin >> n >> w >> d;
    int l = 2 * d + 2 * w; 

    for (int i = 0; i < n; ++i) {
        int x, y;
        char f;
        cin >> x >> y >> f;
        int c, b;
        switch (f) {
            case 'N':
                c = x;
                b = d - y;
            break;
            case 'E':
                c = d - y + w;
                b = w - x;
            break;
            case 'S':
                c = w - x + w + d;
                b = y;
            break;
            case 'W':
                c = y + 2 * w + d;
                b = x;
            break;
        }
        
        // v[i] = (left end of view, right end of view)

        v[i] = P ((c - b + l) % l, (c + b + l) % l);
    } 

    // sort by the left end of view

    sort(v, v + n);

    int minc = 10000;
    for (int i = 0; i < n; ++i) {
        
        // Put a clock at the left end of i-th member's view

        int c = 1;
        int tmp = v[i].first;
        for (int j = 1; j < n; ++ j) {
            int k = (i - j + n) % n;

            int left = v[k].first;
            int right = v[k].second;
            if (left > right) right += l;
            if (left <= tmp && tmp <= right) continue;
            if (left - l <= tmp && tmp <= right - l) continue;

            c++;
            tmp = left;
        }
        
        if (c < minc) minc = c;
    }
    cout << minc << endl;
}

Measured memory_bytes: 3128
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <cmath>
#include <iostream>
#include <sstream>
#include <iomanip>
#include <string>
#include <algorithm>
#include <complex>
#include <map>
#include <vector>
#include <queue>
#include <stack>
#include <deque>
#include <list>
#include <unordered_map>

using namespace std;

bool canTalk(int a, int b, int c, int d) {
	// Check if a and c can communicate directly
	if (std::abs(a - c) <= d) {
		return true;
	}
	// Check if they can communicate through b
	if (std::abs(a - b) <= d && std::abs(b - c) <= d) {
		return true;
	}
	return false;
}

int main() {
	int a, b, c, d;
	std::cin >> a >> b >> c >> d;
	std::cout << (canTalk(a, b, c, d) ? "Yes" : "No") << std::endl;
}

Measured memory_bytes: 256
#include<iostream>

using namespace std;

int main(){
  char a;
  cin >> a;
  if(a == 'A') cout<<"T" <<endl;
  if(a == 'C') cout<<"G" <<endl;
  if(a == 'G') cout<<"C" <<endl;
  if(a == 'T') cout<<"A" <<endl;
}

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

#define rep(a,b) for(int a = 0;a < b;a++)
#define REP(i, x, n) for(int i = x; i < n; i++)
#define P(a) cout << a << endl
#define pb(a) push_back(a)
#define mp(a,b) make_pair(a,b)
#define ssort(v) sort(v.begin(),v.end())
#define rev(v) reverse(v.begin(),v.end())
#define vP(v) for(int i = 0;i < v.size();i++){cout << v[i];if(i != v.size()-1)cout << endl;}
#define vcin(v,n) rep(i,n){int a;cin >> a;v.pb(a);}

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
int dx[] = { 1, -1 , 0 , 0 };
int dy[] = { 0,  0,  1, -1 };
ll MOD = 1000000007;
long long stint(string str) {
	long long ret;
	stringstream ss; ss << str;
	ss >> ret;
	return ret;
}

void solve() {
	int n, k;
	cin >> n >> k;
	int ans = k;
	ans *= pow(k-1, n - 1);
	P(ans);
}

int main() {
	solve();
	return 0;
}


Measured memory_bytes: 256
s = str(input())
s = list(s)
cnt = 0
for i in range(len(s)-1):
    if s[i] == s[i+1]:
        cnt += 1
        if s[i] == "0":
            s[i+1] = "1"
        else:
            s[i+1] = "0"

print(cnt)

Measured memory_bytes: 4008
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  int N, K;
  int KEIJI = 1;
  cin >> N >> K;
  for (int i = 0; i < N; i++){
    if (KEIJI > K){
      KEIJI = K + KEIJI;
    }
    else {
      KEIJI = 2 * KEIJI;
    }
  }
  cout << KEIJI << endl;
}

Measured memory_bytes: 256
N = int(input())
W = list(map(int, input().split()))
s1 = 0
s2 = sum(W)
m = 10000
for w in W:
    s1 += w
    s2 -= w
    if m > abs(s1-s2):
        m = abs(s1-s2)
print(m)


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

const int MAX=2000000;
const int INFTY=(1<<30);

int H, A[MAX];

void maxHeapify(int i){
    int l,r,largest;
    l=2*i;
    r=2*i+1;

    if(l<=H && A[l]>A[i]) largest=l;
    else largest=i;
    if(r<=H && A[r]>A[largest]) largest=r;

    if(i!=largest){
        swap(A[i],A[largest]);
        maxHeapify(largest);
    }
}

int extract(){
    int maxv;
    if(H<1) return -INFTY;
    maxv=A[1];
    A[1]=A[H--];
    maxHeapify(1);
    return maxv;
}

void increaseKey(int i, int key){
    if(key<A[i]) return;
    A[i]=key;
    while(i>1 && A[i/2]<A[i]){
        swap(A[i],A[i/2]);
        i=i/2;
    }
}

void insert(int key){
    H++;
    A[H]=-INFTY;
    increaseKey(H,key);
}

int main(){
    H=0;
    while(true){
        string s; cin >> s;
        if(s=="end") break;
        if(s=="insert"){
            int key; cin >> key;
            insert(key);
        }
        if(s=="extract"){
            printf("%d\n", extract());
        }
    }
}


Measured memory_bytes: 7120
#define _USE_MATH_DEFINES
#define _CRT_SECURE_NO_WARNINGS
#include <bits/stdc++.h>
using namespace std;

//
#define int long long
#define pb(x) push_back(x)
#define m0(x) memset((x), 0, sizeof(x))
#define mm(x) memset((x), -1, sizeof(x))

//container
#define ALL(x) (x).begin(), (x).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define EACH(i, c) for (typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i)
#define EXIST(s, e) ((s).find(e) != (s).end())
#define UNIQUE(v) (v).erase(unique((v).begin(), (v).end()), (v).end());
#define PERM(c) \
  sort(ALL(c)); \
  for (bool c##p = 1; c##p; c##p = next_permutation(ALL(c)))

// debug
#define GET_VAR_NAME(variable) #variable
#define test(x) cout << GET_VAR_NAME(x) << " = " << x << endl;

// bit_macro
#define bit(n) (1LL << (n))
#define bitset(a, b) (a) |= (1 << (b))
#define bitunset(a, b) (a) |= ~(1 << (b))
#define bitcheck(a, b) ((((a) >> (b)) & 1) == 1)
#define bitcount(a) __builtin_popcountll((a))

//typedef
typedef long long lint;
typedef unsigned long long ull;
typedef complex<long double> Complex;
typedef pair<int, int> P;
typedef tuple<int, int, int> TP;
typedef vector<int> vec;
typedef vector<vec> mat;

//constant
const int INF = (int)1e18;
const int MOD = (int)1e9 + 7;
const double EPS = (double)1e-10;
const int dx[] = {-1, 0, 0, 1, 0, -1, -1, 1, 1};
const int dy[] = {0, -1, 1, 0, 0, 1, -1, 1, -1};

//
template <typename T>
void chmax(T &a, T b) { a = max(a, b); }
template <typename T>
void chmin(T &a, T b) { a = min(a, b); }
//
inline int toInt(string s) {
  int v;
  istringstream sin(s);
  sin >> v;
  return v;
}
template <class T>
inline string toString(T x) {
  ostringstream sout;
  sout << x;
  return sout.str();
}

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

signed main() {
  int N;
  cin >> N;
  double p[3030];
  for (int i = 1; i <= N; i++) cin >> p[i];

  static double dp[3030][3030]; //dp[n][i]:=n枚目までで表がi枚出る確率。
  m0(dp);
  dp[0][0] = 1.0;

  for (int i = 0; i < N; i++) {
    for (int j = 0; j <= i + 1; j++) {
      dp[i + 1][j] = dp[i][j] * (1.0 - p[i + 1]);
      if (j >= 1) dp[i + 1][j] += dp[i][j - 1] * p[i + 1];
    }
  }

  double ans = 0.0;
  for (int i = (N - 1) / 2 + 1; i <= N; i++) {
    ans += dp[N][i];
  }

  cout << fixed << setprecision(12) << ans << endl;
  return 0;
}


Measured memory_bytes: 72064
#include <iostream>
#include <cstdio>
#include <vector>
#include <string>
#include <cmath>

int main () {
  int a, b, h, m;
  std::cin >> a >> b >> h >> m;
  double t1 = 1.0 * m / 60.0 * 360;
  double t2 = 1.0 * h / 12.0 * 360 + 1.0 * m / 60.0 * 30;
  double t = std::fabs(t1-t2);
  if (t >= 180.0) t = 360.0 - t;
//  std::cout << t1 << " " << t2 << "\n";
//  std::cout << t << "\n";
  double ans = std::sqrt (a * a + b * b - 2 * a * b * cos(t/180.0*acos(-1)));
  printf ("%.10lf\n",ans);
}

Measured memory_bytes: 4164
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n) for(int i=s;i<n;i++)
typedef long long ll;
const int INF = 1e9;
int main(){
    int n; cin >> n;
    vector<int> a(n), b(n);
    rep(i,n)cin >> a[i];
    rep(i,n)cin >> b[i];
    int ca = 0, cb = 0;
    while(prev_permutation(a.begin(), a.end()))ca++;
    while(prev_permutation(b.begin(), b.end()))cb++;
    cout << abs(ca - cb) << endl;
    return 0;
}

Measured memory_bytes: 256
N = int(input())
A = [int(input()) for _ in range(N)]
INF = 10**6

reached = []
pos = 0#indexで指定
c = 0
while c <= INF:
    reached.append(pos)
    if pos == 1:
        break
    pos = A[pos]-1
    c += 1

if 1 in reached:
    print(reached.index(1))
else:
    print(-1)

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

typedef long long ll;
using namespace std;

#define FALSE printf("false\n");
#define TRUE printf("true\n");
#define all(x) (x).begin(),(x).end()
#define print(x) cout<<x<<endl
#define rep(i,n) for(int i = 0;i < ((int)(n));++i)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define SUM(vec) accumulate(all(vec),0)
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
#define test(a) cout<<#a<<':'<<a<<endl

const ll INF = 1e9+7;

template<typename T>inline T digit(T num){T sum = 0;while(num){sum+=num%10;num/=10;}return sum;} // 各桁の和
template<typename T>inline T gcd(T a,T b){if(b == 0)return a;return gcd(b,a%b);}
template<typename T>inline T lcm(T a, T b){T g = gcd(a,b);return a/g*b;}
template<typename T>inline T power(T a,T b){T tmp=1;rep(i,b){tmp*=a;}return tmp;}


int main() {
  cin.tie(0); ios::sync_with_stdio(0);
  int n;cin>>n;
  string s;cin>>s;
  UNIQUE(s);
  print(s.size());
  return 0;
} 

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

using namespace std;

typedef unsigned long long ull;
typedef long long ll;

int main()
{
    ios_base::sync_with_stdio(false);cin.tie(NULL);
    int n;
    cin>>n;
    ll arr[n];
    for (int i=0;i<n;i++){
        cin>>arr[i];
    }ll opt[n];
    opt[0]=0;
    opt[1]=abs(arr[0]-arr[1]);
    for (int i=2;i<n;i++){
        opt[i]=min(opt[i-2]+abs(arr[i-2]-arr[i]),opt[i-1]+abs(arr[i-1]-arr[i]));
    }cout<<opt[n-1];
    return 0;
}


Measured memory_bytes: 1792
#include <iostream>

int sum_numbers(int n);

using namespace std;

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

    int sum = 0;
    for (int i = 1; i <= n; ++i) {
        int tmp = sum_numbers(i);
        if (tmp >= a && tmp <= b)
            sum += i;
    }
    cout << sum << '\n';
}

int sum_numbers(int n)
{
    int sum = 0;
    while (n > 0) {
        sum += n % 10;
        n /= 10;
    }
    return sum;
}


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

int main() {
    int H, W;
    cin >> H >> W;
    vector<vector<int>> C(10, vector<int>(10));
    for (int i = 0; i < 10; i++) {
        for (int j = 0; j < 10; j++) {
            cin >> C[i][j];
        }
    }
    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];
        }
    }

    for (int k = 0; k < 10; k++) {
        for (int i = 0; i < 10; i++) {
            for (int j = 0; j < 10; j++) {
                C[i][j] = min(C[i][j], C[i][k] + C[k][j]);
            }
        }
    }

    int res = 0;
    for (int i = 0; i < H; i++) {
        for (int j = 0; j < W; j++) {
            if (A[i][j] != 1 && A[i][j] != -1) {
                res += C[A[i][j]][1];
            }
        }
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
int a,b,c=0,d,e,f,g,h,k,n,m,t,pre=0,ans=0;
int main(){
    ios_base::sync_with_stdio(false);
    vector<int>vec1;
    vector<int>vec0;
    cin>>n>>k;
    string s;
    cin>>s;
    for(int i=0;i<n;i++){
        c=i;
        while(i!=n&&s[i]=='1')i++;
        if(c!=i){
            vec1.push_back(i-1-c+1);
        }
    }
    for(int i=0;i<n;i++){
        c=i;
        while(i!=n&&s[i]=='0')i++;
        if(c!=i){
            vec0.push_back(i-1-c+1);
        }
    }
    if(vec0.size()<=k){
        cout<<n<<endl;
        return 0;
    }
    ans=0;
    if(s[0]=='0'){
        for(int i=0;i<k;i++){
            ans+=vec0[i];
            if(vec1.size()-1>=i)ans+=vec1[i];
        }
        m=ans;
        a=0;b=k-1;
        a++;b++;
        for(int i=b;i<=vec0.size()-1;i++){
            d=i-(k-1);
            ans-=vec0[d-1];
            if(i!=b)
            ans-=vec1[d-1-1];
            ans+=vec0[i];
            if(vec1.size()-1>=i)ans+=vec1[i];
            m=max(m,ans);
        }
    }
    if(s[0]=='1'){
        for(int i=0;i<k;i++){
            ans+=vec0[i];
            if(i==0)
            ans+=vec1[i];
            if(vec1.size()-1>=i+1)ans+=vec1[i+1];
        }
        m=ans;
        a=0;b=k-1;
        a++;b++;
        for(int i=b;i<=vec0.size()-1;i++){
            d=i-(k-1);
            ans-=vec0[d-1];
            ans-=vec1[d-1];
            ans+=vec0[i];
            if(vec1.size()-1>=i+1)ans+=vec1[i+1];
            m=max(m,ans);
        }
    }

    cout<<m<<endl;
}

Measured memory_bytes: 972
#include<iostream>
#include<cstdio>
#include<cstring>
#include<queue>
#include<algorithm>
using namespace std;
#define inf 0x3f3f3f3f
#define ll long long
#define met(a,b) memset(a,b,sizeof(a))
int a[100005];
int even[100005],odd[100005];//  偶数    奇数
bool cmp(int a,int b)
{
    return a>b;
}
int main()
{
    int n,x=0,y=0,Maxe=-1,Maxo=-1,ei=-1,oi=-1;
    scanf("%d",&n);
    for(int i=0;i<n;i++){
        scanf("%d",&a[i]);
        if(i&1){
            even[a[i]]++;
            if(Maxe<even[a[i]]){
                Maxe=max(Maxe,even[a[i]]);
                ei=i;
            }
        }
        else{
            odd[a[i]]++;
            if(Maxo<odd[a[i]]){
                Maxo=max(Maxo,odd[a[i]]);
                oi=i;
            }
        }
    }
    if(a[oi]!=a[ei])
    {
        printf("%d\n",n-odd[a[oi]]-even[a[ei]]);
    }
    else{
        sort(odd,odd+100005,cmp);
        sort(even,even+100005,cmp);
        printf("%d\n",min(n-odd[0]-even[1],n-odd[1]-even[0]));
    }
    return 0;
}


Measured memory_bytes: 1408
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <numeric>
#include <vector>
#include <queue>
#include <map>
typedef unsigned long long ull;
typedef long long ll;
#define MAX 105
#define __TRUE "YES"
#define __FALSE "NO"
#define cout(x) cout << (x) << endl
#define reps(i,s,n) for(i=s;i<n;i++)
#define rep(i,n) for(i=0;i<n;i++)
using namespace std;
char S[MAX][MAX];
int main() {
  int a,b,c,d;
  cin >> a >> b >> c >> d;
  int x,y;
  x=min(a,b);
  y=min(c,d);
  cout << x+y << endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define db double
#define ld long double
#define rep(i,n) for(int i=0;i<n;i++)
#define rev(i,n) for(ll i=n;i>=0;i--)
#define rep_a(i,a,n) for(ll i=a;i<n;i++)
#define pb push_back
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define sz(v) ((int)(v).size())
#define all(v) (v).begin(), (v).end()
const long long mod = 1000000007;
const long long INF = mod*mod;
int ansi = 1;
int solve()
{
	
	int a,b,c;
	cin>>a>>b>>c;
	swap(a,b);
	swap(a,c);
	cout<<a<<" "<<b<<" "<<c;
	return 0;
}
int main()
{
	/* #ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
	#else
	#endif */
	int tt = 1;
	while(tt--)
	{
	   
	    solve();
	    if (ansi = 0)
	    return 0;
	}
	/* #ifndef ONLINE_JUDGE
	cout<<"\nTime Elapsed: "<<1.0*clock()/ CLOCKS_PER_SEC<<" Sec\n";
	#endif */
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
///////////////////////////////////////////
const long long int INF = 1LL<<60;
const long long int Mod = 1000000007;
using ll = long long int; using ci = const int;
using vi = vector<int>;  using Vi = vector<long long int>;
using P = pair<int, int>;  using PLL = pair<ll, ll>;
using matrix = vector<vector<ll>>;
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
#define all(x) (x).begin(),(x).end()
#define rp(i,N) for(ll i = 0; i < (ll)N; i++)
#define repi(i,a,b) for(ll i = ll(a); i < ll(b); ++i)
template<class T>bool chmax(T &former, const T &b) { if (former<b) { former=b; return true; } return false; }
template<class T>bool chmin(T &former, const T &b) { if (b<former) { former=b; return true; } return false; }
template<class T>T sqar(T x){ return x*x; }//sqrt(x)は平方根;
#define Sort(v) std::sort(v.begin(), v.end(), std::greater<decltype(v[0])>()) //降順でVをソート
#define p_queue(v) priority_queue<v, vector<v>, greater<v> >
template<class T> inline void princ(T x){cout<<x<<" ";}; 
template<class T> inline void print(T x){cout<<x<<"\n";};
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T> inline void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
///////////////////////////////////////////////////////////////////////////////////

void solve(){
    int n;
    cin >> n;
    Vi a(n);
    rp(i,n) cin >> a.at(i);
    sort(all(a));
    if(a[0]==0){
        print(0);
        return;
    }
    ll ans=1;
    rp(i,n){
        if(1000000000000000000/ans<a.at(i)){
            print(-1);
            return;
        }
        ans*=a.at(i);
    }
    print(ans);
    return;
}
int main(){
    cin.tie(0);ios::sync_with_stdio(false);
    std::cout<<std::fixed<<std::setprecision(30);
    solve();
    return 0;
}

Measured memory_bytes: 3976
#include <bits/stdc++.h>
#include <ext/pb_ds/detail/standard_policies.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
typedef long long int ll;
typedef unsigned long long int ull;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> o_set;

#define     int                 ll
#define     pb                  push_back
#define     mp                  make_pair
#define     xx                  first
#define     yy                  second    
#define     all(a)              a.begin(),a.end()
#define     vi                  vector<int>
#define     vpi                 vector<pii>
#define     pii                 pair<int, int>
#define     present(DT, val)    (DT.find(val) != DT.end()) //for set and map
#define     cpresent(DT, val)   (find(all(DT),val) != DT.end()) //vectors
#define     input               "/home/pollution/Desktop/WorkSpace/C++/Files/input.txt"
#define     output              "/home/pollution/Desktop/WorkSpace/C++/Files/output1.txt"
#define     error               "/home/pollution/Desktop/WorkSpace/C++/Files/error.txt"
#define     IO()                ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define     INF                 2e18
#define     MOD                 1000000007
#define     clr(x)              memset(x, 0, sizeof(x))
#define     init(x, a)          memset(x, a, sizeof(x))
#define     out(a)              for (auto i: a) cout<<i<<' '; cout<<'\n'
#define     cpy(a,b)            memcpy(a,b,sizeof(b))
#define     is(a)               to_string(a)
#define     ci(a,c)             a-c
#define     db(i)               cout<<"point :"<<i<<'\n';
#define     setd(val,n)         cout<<fixed<<setprecision(n)<<val<<'\n'

void solve(){
    int a,b,c,k; cin>>a>>b>>c>>k;
    if(a+b>=k){
    	cout<<min(a,k)<<'\n';
    }
    else{
    	k-=a+b;
    	cout<<a-k<<'\n';
    }
}

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

Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
int main(){
  int a,b,c,k;
  cin >> a >> b >> c >> k;
  for(;0 < k;k--){
    if(a >= b)b*= 2;
    else break;
  }

  for(;0 < k;k--){
    if(b >= c)c*= 2;
    else break;
  }
  if(a < b && b < c)cout << "Yes" << endl;
  else cout << "No" << endl;

  }

Measured memory_bytes: 3636
#include<stdio.h>
#include<stdlib.h>
 
int main(){
  int i,n,R[200000],min,max;
 
  scanf("%d",&n);
  
  for(i=0;i<n;i++){
    scanf("%d",&R[i]);
    if(R[i]<1 || R[i]>1000000000){
      exit(8);
    }
  }
 
  max=R[1]-R[0];
  min=R[0];
 
  for(i=1;i<n;i++){
    if(max<R[i]-min){
      max=R[i]-min;
    }
    if(min>R[i]){
      min=R[i];
    }
  } 
 
  printf("%d\n",max);
 
  return 0;
}

Measured memory_bytes: 1376
def s():
 def b(M,x,y,n=1):
  M[x][y]=0;a=n
  if M[x-1][y]:a=max(a,b(M,x-1,y,n+1))
  if M[x][y-1]:a=max(a,b(M,x,y-1,n+1))
  if M[x+1][y]:a=max(a,b(M,x+1,y,n+1))
  if M[x][y+1]:a=max(a,b(M,x,y+1,n+1))
  M[x][y]=1
  return a
 for e in iter(input,'0'):
  n,m=int(e),int(input())
  P=[[0]*(n+2)for _ in[0]*(m+2)]
  for i in range(m):P[i+1][1:-1]=map(int,input().split())
  print(max(b(P,i,j)for i in range(1,m+1)for j in range(1,n+1)if P[i][j]))
if'__main__'==__name__:s()


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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
template<class T> inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template<class T> inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
int64_t abs(int64_t n) {
  if (n < 0) {
    n = -n;
  }
  return n;
}
int ctoi(char c) {
  if (c >= '0' && c <= '9') {
    return c - '0';
  }
  return 0;
}
int64_t factorial(int64_t n) {
  if (n == 1) {
    return 1;
  }
  int64_t ans = factorial(n-1);
  return ans*n;
}

int main() {
  string s;
  cin >> s;
  vector <int> v(26, 0);
  rep(i, s.size()) {
    int n = s.at(i) - 'a';
    v.at(n)++;
  }
  int tmp = 0;
  rep(i, v.size()) {
    if (v.at(i)%2 != 0) {
      tmp++;
    }
  }
  if (tmp == 0) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
using namespace std;
int main () {
  string S;
  cin >> S;
  int k = 0;
  for (int i = 0; i < S.size(); i ++) {
    if (S[i] == 'x') k ++;
  }
  if (k <= 7) cout << "YES" << endl;
  else cout << "NO" << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)  
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
#define INF 999999999
using namespace std;
typedef pair<int, int> P;
typedef pair<llong, llong> LP;
typedef pair<int, P> PP;
typedef pair<llong, LP> LPP;

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


int kuraiSum(int a){
  int ans = 0;
  while(1){
    ans += a%10;
    a/=10;
    if(a==0)break;
  }
  return ans;
}

int main(){

  int n;
  cin>>n;
  int ans = INF;
  for(int i=1;i<=(n+1)/2;i++){
    ans = min(ans,kuraiSum(i)+kuraiSum(n-i));
  }

  cout<<ans<<endl;

 

  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
//C++ as C#
#define var auto
#define Max std::max
#define Min std::min

#ifdef _MSC_VER
#define getchar_unlocked getchar
#define putchar_unlocked putchar
#define fseek_unlocked fseek
#endif

inline uint32_t read()
{
	uint32_t x = 0;
	int k;
	while (true)
	{
		k = getchar_unlocked();
		if (k < '0') break;
		x = x * 10 + k - '0';
	}
	return x;
}

void writeline(uint32_t x) {
	int s = 0;
	char f[8];
	while (x) {
		f[s++] = x % 10;
		x /= 10;
	}
	while (s--)
		putchar_unlocked(f[s] + '0');
	putchar_unlocked('\n');
}

int main()
{
	int h = read(), w = read();
	vector<int> rowMax(w, 0);
	vector<int> columnAccum(w, 0);
	int max = 0;
	for (size_t i = 0; i < h; i++)
	{
		int currentChain = 0;
		for (size_t j = 0; j < w; j++)
		{
			if (getchar_unlocked() & 1) 
			{
				max = Max(max, columnAccum[j] + rowMax[j]);
				if (currentChain)
					for (size_t k = j - currentChain; k < j; k++)
						rowMax[k] = Max(rowMax[k], currentChain);
				currentChain = 0;
				rowMax[j] = 0;
				columnAccum[j] = 0;
			}
			else
			{
				currentChain++;
				columnAccum[j]++;
			}
		}
		if (currentChain)
			for (size_t j = w - currentChain; j < w; j++)
				rowMax[j] = Max(rowMax[j], currentChain);
		getchar_unlocked();
	}
	for (size_t i = 0; i < w; i++)
		max = Max(max, columnAccum[i] + rowMax[i]);
	writeline(max - 1);
	return 0;
}


Measured memory_bytes: 256
#!/usr/bin python3
# -*- coding: utf-8 -*-

import sys

def main():
    N, K = map(int, input().split())
    A = list(map(int, input().split()))

    nw = 1
    lp0 = [1]
    lpl = {1}
    for i in range(N):
        nw = A[nw-1]
        if nw in lpl:
            break
        else:
            lp0.append(nw)
            lpl.add(nw)
    lpc = i+1 - lp0.index(nw)
    lp = lp0[-lpc:]

    if K<=len(lp0)-1:
        print(lp0[K])
    else:
        K-= len(lp0)-1
        K=K%lpc - 1
        print(lp[K])

if __name__ == '__main__':
    main()

Measured memory_bytes: 32404
#include <bits/stdc++.h>
#define rep(i, x, N) for (int i = x; i < (N); i++)
using namespace std;
int main()
{
    long long inf = 1e+18;
    int A, B, Q;
    cin >> A >> B >> Q;
    vector<long long> s(A + 2), t(B + 2), x(Q);
    s[0] = (-1) * inf;
    t[0] = (-1) * inf;
    s[A + 1] = inf;
    t[B + 1] = inf;
    rep(i, 1, A + 1) cin >> s[i];
    rep(i, 1, B + 1) cin >> t[i];
    rep(i, 0, Q) cin >> x[i];

    rep(i, 0, Q)
    {
        long long ans;
        int b = lower_bound(s.begin(), s.end(), x[i]) - s.begin();
        int c = lower_bound(t.begin(), t.end(), x[i]) - t.begin();
        ans = min(max(s[b], t[c]) - x[i], x[i] - min(s[b - 1], t[c - 1]));
        ans = min(ans, min(2 * (x[i] - s[b - 1]) + t[c] - x[i], 2 * (x[i] - t[c - 1]) + s[b] - x[i]));
        ans = min(ans, min(2 * (s[b] - x[i]) + x[i] - t[c - 1], 2 * (t[c] - x[i]) + x[i] - s[b - 1]));
        cout << ans << endl;
    }
}


Measured memory_bytes: 3712
#include<bits/stdc++.h>
 
#define ll          long long
#define pb          push_back
#define ppb         pop_back
#define int         ll int
#define float       double
#define	endl		'\n'
#define maxpq       priority_queue<ll>
#define minpq       priority_queue<ll, vector<ll>, greater<ll> >
#define mii         map<int,int>
#define msi         map<string,int>
#define mis         map< int, string>
#define mpi         map<pair< int, int>, int>
#define pii         pair< int, int>
#define vi          vector< int>
#define vs          vector<string>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (ll int)x.size()
#define hell        1000000007
#define lbnd        lower_bound
#define ubnd        upper_bound
#define bs          binary_search
#define mp          make_pair
#define EPS         1e-9
#define INF         1e18
#define PI          3.14159265358979323846
#define MAXI        1000000
#define what_is(x)  cerr << #x << " is " << x << endl;
#define fast ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
using namespace std;
#define N 100005

signed main()
{
	fast;
	int t=1;
	//cin>>t;
	while(t--)
	{
		int n;
		cin>>n;
		int arr[n];
		int i,j,k;
		for(i=0;i<=n-1;i++)
		{
			cin>>arr[i];
		}
		int dp[n+1];
		dp[1]=0;
		dp[2]=abs(arr[0]-arr[1]);
		for(i=3;i<=n;i++)
		{
			dp[i]=INT_MAX;
			for(j=i-2;j<i;j++)
			{
				dp[i]=min(dp[i],dp[j]+abs(arr[j-1]-arr[i-1]));
			}
		}
//		for(i=1;i<=n;i++) cout<<dp[i]<<" ";
//		cout<<endl;
		cout<<dp[n]<<endl;
	}
}

Measured memory_bytes: 5168
#include<stdio.h>

int main(void) {

    int a, b;

    for (scanf("%d %d", &a, &b); a != 0 || b != 0; scanf("%d %d", &a, &b))
    {
        printf("%d %d\n", (a < b) ? a : b, (b < a) ? a : b);
    }

    return 0;
}



Measured memory_bytes: 2608
#include <bits/stdc++.h>
#include <vector>
#include <algorithm>
#include <iostream>
using namespace std;

int main() {
  int A, B;
  cin >> A >> B;
  if (A<6) {
    cout << 0 << endl;
  }
  else {
    if (A<13) {
      cout << B/2 << endl;
    }
    else {
      cout << B << endl;
    }
  }
}

Measured memory_bytes: 3528
import heapq

N = int(input())
v = list(map(int, input().split(' ')))

def nabe(v):
    
    if len(v) == 1:
        return v[0]

    smallests = heapq.nsmallest(2, v)

    for s in smallests:
        v.remove(s)
    v.append(sum(smallests) / 2)

    return nabe(v)

print(nabe(v))

Measured memory_bytes: 3060
package main
 
import (
	"fmt"
)
 
func main() {
  const THRESH = 1000000000000000000 
  var N uint64
  fmt.Scanf("%d", &N)
  A := make([]uint64, N)
  for i := range A{
    fmt.Scan(&A[i])
    if A[i] == 0 {
      fmt.Print(0)
      return
    }
  }  
  
  retval := uint64(1)
  retval_tmp := uint64(1)
  for i := range A{
    retval_tmp = retval * A[i]
    if (retval_tmp < retval) {
      fmt.Print(-1)
      return
    }
    retval *= A[i]
    if retval > THRESH {
      fmt.Print(-1)
      return
    }
  }
  fmt.Print(retval)
}

Measured memory_bytes: 6320
#include "bits/stdc++.h"
using namespace std;
///////////////////////////////////////////
const long long int INF = 1LL<<60;
const long long int Mod = 1000000007;
using ll = long long int; using ci = const int;
using vi = vector<int>;  using Vi = vector<long long int>;
using P = pair<int, int>;  using PLL = pair<ll, ll>;
using matrix = vector<vector<ll>>;
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
#define all(x) (x).begin(),(x).end()
#define rep(i,N) for(ll i = 0; i < (ll)N; i++)
#define repi(i,a,b) for(ll i = ll(a); i < ll(b); ++i)
template<class T>bool chmax(T &former, const T &b) { if (former<b) { former=b; return true; } return false; }
template<class T>bool chmin(T &former, const T &b) { if (b<former) { former=b; return true; } return false; }
template<class T>T sqar(T x){ return x*x; }//sqrt(x)は平方根;
#define Sort(v) std::sort(v.begin(), v.end(), std::greater<decltype(v[0])>()) //降順でVをソート
#define p_queue(v) priority_queue<v, vector<v>, greater<v> >
template<class T> inline void princ(T x){cout<<x<<" ";}; 
template<class T> inline void print(T x){cout<<x<<"\n";};
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T> inline void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
///////////////////////////////////////////////////////////////////////////////////

ll n;
Vi a;
Vi dif;
Vi sum;


int main(){
    cin.tie(0);ios::sync_with_stdio(false);
    std::cout<<std::fixed<<std::setprecision(30);
    cin>>n;
    a.resize(n);
    rep(i,n){
        cin>>a[i];
    }
    dif.resize(n);
    sum.resize(n);
    map<ll,ll> ds;
    map<ll,ll> df;
    rep(i,n){
        dif[i] = i-a[i];
        sum[i] = i+a[i];
        ds[sum[i]]++;
        df[dif[i]]++;
    }
    ll ans = 0;
    rep(i,n){
        if(sum[i]==dif[i]){
            ans += df[sum[i]];
            ans += ds[dif[i]];
            ans -= 2;
        }else{
            ans += df[sum[i]];
            ans += ds[dif[i]];
        }
    }
    
    print(ans/2);
    return 0;
}

Measured memory_bytes: 53192
#include<bits/stdc++.h>
#define rep(i,f,n) for(ll i=(f); (i) < (n); i++)
#define repe(i,f,n) for(ll i=(f); (i) <= (n); i++)
using namespace std;
using ll = long long;
#define MOD (ll)1000000007
#define PI 3.14159265359
//#define P pair<ll, ll>
//printf("%.10f\n")
//cout << fixed << setprecision(10);
template<class T> inline bool chmax(T& a, T b){if (a < b) { a = b; return true; } return false;}
template<class T> inline bool chmin(T& a, T b){if (a > b) { a = b; return true; } return false;}
ll INF = 1e+18;
int iINF = 1e9;

int
main()
{

  int N, K; cin >> N >> K;
  int R, S, P; cin >> R >> S >> P;
  string s; cin >> s;
  vector<char> t;
  for(auto x: s){
    if(x == 'r'){
      t.push_back('p');
    } else if(x == 'p'){
      t.push_back('s');
    } else {
      t.push_back('r');
    }
  }

  vector<char> pre;
  ll ans = 0;
  ll cnt = 0;
  for(auto x: t){
    if(cnt != 0 && cnt >= K){
      if(pre[cnt - K] == x){
        pre.push_back('n');
        ++cnt;
        continue;
      }
    }
    if(x == 'r'){
      ans += R;
      pre.push_back('r');
    } else if(x == 'p'){
      ans += P;
      pre.push_back('p');
    } else {
      ans += S;
      pre.push_back('s');
    }
    ++cnt;
  }

  cout << ans << endl;


}


Measured memory_bytes: 3736
#!/usr/bin/env python3
n = int(input())
s = input()
R = []
G = []
B = []
for i in range(n):
    if s[i] == "R":
        R.append(i)
    elif s[i] == "G":
        G.append(i)
    else:
        B.append(i)
# 全体R*G*Bからi,jを固定してk = 2*i-jが全部違う数字になるものを引けばいい
ans = len(R) * len(G) * len(B)
for i in range(n):
    for j in range(i + 1, n):
        if 0 <= 2 * j - i and 2 * j - i < n:
            if s[2 * j - i] != s[i] and s[2 * j - i] != s[j] and s[i] != s[j]:
                ans -= 1
print(ans)


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

int main(){
  int n,i;
  scanf("%d\n",&n);
  int man[n];
  
  for(i=1;i<=n;i++){
  man[i]=0;
  scanf("%d ",&man[i]);
  }
  //ok
  
  int point;
  int sum=0;
  int ans=0;
  for(point=0;point<=100;point++){
    
  if(sum<=ans){
  ans=sum;
  }
  sum=0;
  for(i=1;i<=n;i++){
  sum=sum+pow((man[i]-point),2);
  }
  if(point==0){
  ans=sum;
  }
  }
 
  printf("%d\n",ans);
  
  return 0;
}



Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define INF 0x7fffffff
#define N 300001
typedef long long ll;
typedef long double ld;
 
#define fastIO ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound

#define sz(x) (int)x.size()
#define beg(x) x.begin()
#define en(x) x.end()

int div(int k)
{
	int ans = 1, temp = 7;
	set<int> s;

	while(temp % k)
	{
		if(s.count(temp % k)) return -1;
		else s.insert(temp % k);
		temp = temp % k * 10 + 7;
		ans++;
	}
	return ans;
}

int main()
{
	fastIO;
	
	int k;
	cin >> k;
	cout << div(k) << endl;


	return 0;
}

Measured memory_bytes: 50428
#include <iostream>

using namespace std;

int a, b, c, d;

int main() {
  cin >> a >> b >> c >> d;
  
  while (true) {
    c -= b;
    if (c <= 0)
      return cout << "Yes", 0;
    a -= d;
    if (a <= 0)
      return cout << "No", 0;
  }
}


Measured memory_bytes: 3624
import java.util.Scanner;

/**
 * Created by ??\??? on 2016/12/6.
 */
public class Main {
    static int si(String s) {
        return Integer.parseInt(s);
    }
    static int run(String[] args){
        Scanner scan = new Scanner(System.in);
        while(scan.hasNext()) {
            int T = Integer.parseInt(scan.nextLine());
            String[] lines = scan.nextLine().split(" ");
            int sum = 0;
            for(int i = 0;i<lines.length-1;i++){
                for(int j = lines.length - 1;j>=i+1;j--){
                    if(si(lines[j])<si(lines[j-1])){
                        String s = lines[j];
                        lines[j] = lines[j-1];
                        lines[j-1] = s;
                        sum++;
                    }
                }
            }
            for(int i = 0;i<lines.length;i++){
                if(i==0)
                    System.out.print(lines[0]);
                else
                    System.out.print(" "+lines[i]);
            }
            System.out.println();
            System.out.println(sum);

        }
        return 1;
    }

    public static void main(String[] args) {
        run(args);
    }
}

Measured memory_bytes: 26916
function Main(input) {
    var array = input.replace(/\r?\n+$/, '').split(/\r?\n/).map(Number);
    console.log((array[0] + array[1]) * array[2] / 2);
}

var character = "";
process.stdin.on('data', function(char){ character += char });
process.stdin.on('end', function(){ Main(character); });
process.on('SIGINT', function() { Main(character); process.exit(0); });

Measured memory_bytes: 29804
#include<bits/stdc++.h>
using namespace std; 
long long n,ans1,ans2;                          
int main(){
    cin>>n;
    if(n%2==1) {cout<<0;return 0;}
    for(long long i=2;i<=n;i*=2)
        ans1+=n/i;
    for(long long i=10;i<=n;i*=5)
        ans2+=n/i;
    cout<<min(ans1,ans2);
	return 0;
}

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

#define itn int
#define vi vector<int>
#define pb push_back
#define srt sort(v.begin(), v.end())
#define retunr return
#define No cout<<"No"
#define Yes cout<<"Yes"

//int infiint = std::numeric_limits<int>::max();
//float infiflt = std::numeric_limits<float>::infinity();


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

#ifdef _DEBUG
//  			freopen("input.txt", "r", stdin);
//        freopen("output", "w", stdout);
#endif
    
    int n;
    cin >> n;
    double x = n/(double)3;
    printf("%.12f", x*x*x);
	return 0;
}


Measured memory_bytes: 256
#ifndef DEBUG
#    pragma GCC optimize("O3,no-stack-protector")
#    pragma GCC optimize("unroll-loops")

#    if __cplusplus < 201703L
#        pragma GCC target("avx")
#    else
#        pragma GCC target("avx2")
#    endif

#endif

#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define dump(x) cout << x << endl
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define REP(i, n) for (int i = 0, i##_len = (n); i <= i##_len; ++i)
#define rep3(i, l, r) for (int i = l, i##_len = (r); i < i##_len; ++i)
#define REP3(i, l, r) for (int i = l, i##_len = (r); i <= i##_len; ++i)
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end());
typedef int64_t Int;
typedef long double Ld;

using namespace std;
template <class T>
using Graph = vector<vector<T>>;

const Ld pi = M_PI;
const Int MOD = 1000000007;
const Int INF = 1LL << 62;

Int Floor(Int a, Int b) {
    return (a - (a % b)) / b;
}

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

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

template <typename T>
inline T Gcd(T a, T b) {
    T c;
    while (b) {
        c = b;
        b = a % b;
        a = c;
    }
    return a;
}

Int Lcm(Int a, Int b) {
    if (a < b) {
        swap(a, b);
    }

    return a / Gcd(a, b) * b;
}

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

    int n;
    cin >> n;
    int d = 0, k = 0;
    for (int i = 0; i < n; i++) {
        if (n <= i * (i + 1) / 2) {
            d = i;
            k = i * (i + 1) / 2;
            break;
        }
    }

    if (n == 1 || n == 2) {
        cout << n << endl;
    } else {
        for (int i = 1; i <= d; i++) {
            if (i == (k - n)) {
                continue;
            } else {
                cout << i << endl;
            }
        }
    }

    return 0;
}


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


def main():
    from fractions import gcd

    n = int(input())
    a = list(map(int, input().split()))
    mod = 10 ** 9 + 7
    lcm = 1
    ans = 0

    # 同じコードがPython3だとギリギリ通るが、PyPy3だとTLE
    for ai in a:
        lcm = lcm * ai // gcd(lcm, ai)

    for ai in a:
        ans += lcm // ai

    print(ans % mod)


if __name__ == '__main__':
    main()


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

using namespace std;

#define all(x) x.begin(), x.end()
#define rep(i, n) for (int i = 0; i < n; ++i)
#define reps(i, m, n) for (int i = m; i <= n; ++i)

using i64 = long long;
using pii = pair<i64, i64>;

template<class A, class B>inline bool chmax(A &a, const B &b){return b > a ? a = b,1 : 0;}
template<class A, class B>inline bool chmin(A &a, const B &b){return b < a ? a = b,1 : 0;}

constexpr int INF = 0x3f3f3f3f;
constexpr i64 LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr int MOD = int(1e9) + 7;

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

  int n;
  cin >> n;

  map<string, int> cnt;
  string s[128];
  rep(i, n) {
    cin >> s[i];
    ++cnt[s[i]];
  }

  int m;
  cin >> m;
  string t[128];
  rep(i, m) {
    cin >> t[i];
    --cnt[t[i]];
  }

  int maxv = 0;
  rep(i, n) chmax(maxv, cnt[s[i]]);
  rep(i, m) chmax(maxv, cnt[t[i]]);

  cout << maxv << "\n";

  return 0;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES

#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <list>

long long int INF = 1e18;
using namespace std;

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

int main(){
	
	int n, q;
	cin >> n;
	
	map<long long int, int> m;
	map<long long int, int>::iterator ite;
	
	for(int i = 0; i < n; i++){
		long long int num;
		cin >> num;
		m[num] = 1;
	}
	
	cin >> q;
	
	int ans = 0;
	
	for(int i = 0; i < q; i++){
		long long int T;
		cin >> T;
		ite = m.find(T);
		if(ite != m.end()){
			ans++;
		}
	}
	
	cout << ans << endl;
	
	return 0;
}


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

int main() {
    int ans = 0;
    int H, W;
    cin >> H >> W;
    vector<vector<char>> S(H, vector<char>(W));
    for(int i = 0; i < H; i++) {
        for(int j = 0; j < W; j++) {
            cin >> S.at(i).at(j);
        }
    }

    for(int i = 0; i < H; i++) {
        for(int j = 0; j < W; j++) {
            if(S.at(i).at(j) != '#') {
                vector<vector<int>> move(H, vector<int>(W, pow(10, 6)));
                for(int r = 0; r < H; r++) {
                    for(int s = 0; s < W; s++) {
                        if(S.at(r).at(s) == '#')
                            move.at(r).at(s) = -1;
                    }
                }
                move.at(i).at(j) = 0;
                queue<vector<int>> Que;
                Que.push({i, j});
                while(Que.size() > 0) {
                    int r = Que.front().at(0), s = Que.front().at(1);
                    Que.pop();
                    if(r < H - 1) {
                        if(move.at(r + 1).at(s) > 1 + move.at(r).at(s)) {
                            move.at(r + 1).at(s) = 1 + move.at(r).at(s);
                            Que.push({r + 1, s});
                        }
                    }
                    if(s < W - 1) {
                        if(move.at(r).at(s + 1) > 1 + move.at(r).at(s)) {
                            move.at(r).at(s + 1) = 1 + move.at(r).at(s);
                            Que.push({r, s + 1});
                        }
                    }
                    if(0 < r) {
                        if(move.at(r - 1).at(s) > 1 + move.at(r).at(s)) {
                            move.at(r - 1).at(s) = 1 + move.at(r).at(s);
                            Que.push({r - 1, s});
                        }
                    }
                    if(0 < s) {
                        if(move.at(r).at(s - 1) > 1 + move.at(r).at(s)) {
                            move.at(r).at(s - 1) = 1 + move.at(r).at(s);
                            Que.push({r, s - 1});
                        }
                    }
                }
                for(int p = 0; p < H; p++) {
                    int x = *max_element(move.at(p).begin(), move.at(p).end());
                    ans = max(ans, x);
                }
            }
        }
    }

    cout << ans << endl;
}

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

using namespace std;

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

    long cnt = 0, ans = 0;
    for (auto x : s) {
        if (x == 'B') {
            cnt++;
        } else {
            ans += cnt;
        }
    }
    cout << ans;
    return 0;
}

Measured memory_bytes: 640