akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <iostream>
#include <math.h>
#include <assert.h>
#include <vector>
#include <queue>
#include <string>
#include <map>
#include <set>

using namespace std;
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
static const double EPS = 1e-9;
static const double PI = acos(-1.0);

#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, s, n) for (int i = (s); i < (int)(n); i++)
#define FOREQ(i, s, n) for (int i = (s); i <= (int)(n); i++)
#define FORIT(it, c) for (__typeof((c).begin())it = (c).begin(); it != (c).end(); it++)
#define MEMSET(v, h) memset((v), h, sizeof(v))

struct Edge {
  int dest;
  int cost;
  Edge(int dest, int cost) : dest(dest), cost(cost) {;}
  bool operator<(const Edge &rhs) const { return cost > rhs.cost; }
};
typedef vector<Edge> Edges;
typedef vector<Edges> Graph;

Graph g;
int n;
int e, m, cap;
bool lgp[6010];
char str1[1000];
char str2[1000];
map<string, int> mapto;

bool visit[2001][6001];
//int dist[2010][6010];

int Push(const char* str) {
  if (!mapto.count(str)) {
    mapto[str] = n++;
    g.push_back(Edges());
  }
  return mapto[str];
}

int main() {
  while (scanf("%d %d %d", &e, &m, &cap), e|m|cap) {
    n = 0;
    cap *= 10;
    g.clear();
    MEMSET(lgp, false);
    mapto.clear();
    scanf("%s %s", str1, str2);
    int start = Push(str1);
    int end = Push(str2);
    REP(i, e) {
      int d;
      scanf("%s %s %d", str1, str2, &d);
      int l = Push(str1);
      int r = Push(str2);
      g[l].push_back(Edge(r, d));
      g[r].push_back(Edge(l, d));
    }
    REP(i, m) {
      scanf("%s", str1);
      int v = Push(str1);
      lgp[v] = true;
    }

    MEMSET(visit, false);
    //MEMSET(dist, 0x0f);
    priority_queue<pair<Edge, int> > que;
    que.push(make_pair(Edge(start, 0), cap));
    while (!que.empty()) {
      Edge e = que.top().first;
      int rest = que.top().second;
      que.pop();
      int from = e.dest;
      if (lgp[from]) { rest = cap; }
      if (visit[rest][from]) { continue; }
      visit[rest][from] = true;
      if (from == end) {
        printf("%d\n", e.cost);
        goto next;
      }
      FORIT(it, g[from]) {
        int to = it->dest;
        int ncost = e.cost + it->cost;
        int nrest = rest - it->cost;
        if (nrest < 0 || visit[nrest][to]/* || ncost >= dist[nrest][to]*/) { continue; }
        //dist[nrest][to] = ncost;
        que.push(make_pair(Edge(to, ncost), nrest));
      }
    }
    puts("-1");
next:;
  }
}

Measured memory_bytes: 37000
#pragma GCC optimize ("Ofast")
#include<bits/stdc++.h>
using namespace std;
template<class S, class T> inline S max_L(S a,T b){
  return a>=b?a:b;
}
inline int my_getchar_unlocked(){
  static char buf[1048576];
  static int s = 1048576;
  static int e = 1048576;
  if(s == e && e == 1048576){
    e = fread_unlocked(buf, 1, 1048576, stdin);
    s = 0;
  }
  if(s == e){
    return EOF;
  }
  return buf[s++];
}
inline void rd(int &x){
  int k;
  int m=0;
  x=0;
  for(;;){
    k = my_getchar_unlocked();
    if(k=='-'){
      m=1;
      break;
    }
    if('0'<=k&&k<='9'){
      x=k-'0';
      break;
    }
  }
  for(;;){
    k = my_getchar_unlocked();
    if(k<'0'||k>'9'){
      break;
    }
    x=x*10+k-'0';
  }
  if(m){
    x=-x;
  }
}
struct MY_WRITER{
  char buf[1048576];
  int s;
  int e;
  MY_WRITER(){
    s = 0;
    e = 1048576;
  }
  ~MY_WRITER(){
    if(s){
      fwrite_unlocked(buf, 1, s, stdout);
    }
  }
}
;
MY_WRITER MY_WRITER_VAR;
void my_putchar_unlocked(int a){
  if(MY_WRITER_VAR.s == MY_WRITER_VAR.e){
    fwrite_unlocked(MY_WRITER_VAR.buf, 1, MY_WRITER_VAR.s, stdout);
    MY_WRITER_VAR.s = 0;
  }
  MY_WRITER_VAR.buf[MY_WRITER_VAR.s++] = a;
}
inline void wt_L(char a){
  my_putchar_unlocked(a);
}
inline void wt_L(long long x){
  int s=0;
  int m=0;
  char f[20];
  if(x<0){
    m=1;
    x=-x;
  }
  while(x){
    f[s++]=x%10;
    x/=10;
  }
  if(!s){
    f[s++]=0;
  }
  if(m){
    my_putchar_unlocked('-');
  }
  while(s--){
    my_putchar_unlocked(f[s]+'0');
  }
}
template<class S, class T> inline S chmax(S &a, T b){
  if(a<b){
    a=b;
  }
  return a;
}
int N;
int A[200000];
int main(){
  int i;
  long long res = 0;
  long long mx = -1;
  rd(N);
  {
    int Lj4PdHRW;
    for(Lj4PdHRW=(0);Lj4PdHRW<(N);Lj4PdHRW++){
      rd(A[Lj4PdHRW]);
    }
  }
  for(i=(0);i<(N);i++){
    res +=max_L(mx - A[i], 0);
    chmax(mx, A[i]);
  }
  wt_L(res);
  wt_L('\n');
  return 0;
}
// cLay varsion 20200911-1

// --- original code ---
// int N, A[2d5];
// {
//   ll res = 0, mx = -1;
//   rd(N,A(N));
//   rep(i,N){
//     res += max(mx - A[i], 0);
//     mx >?= A[i];
//   }
//   wt(res);
// }


Measured memory_bytes: 5340
using System;

namespace atcoder
{
  public class iroha
  {
    public static void Main(string[] args)
    {
      int fivec=0;
      int sevenc=0;
      string[] s=Console.ReadLine().Split(' ');
      foreach(var i in s)
      {
        if(int.Parse(i)==5)fivec++;
        if(int.Parse(i)==7)sevenc++;
      }
      if(fivec==2 && sevenc==1)
      {
        Console.WriteLine("YES\n");
      }
      else
      {
        Console.WriteLine("NO\n");
      }
    }
  }
}

Measured memory_bytes: 11092
#include<bits/stdc++.h>
#define rep(i,n)for(int i=0;i<n;++i)
#include<string>
using namespace std;
typedef long long ll;
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }

int main() {
	int n, t;
	cin >> n >> t;
	vector<int>C(n);
	vector<int>T(n);
	rep(i, n) {
		cin >> C[i] >> T[i];
	}
	int ans = 10000;
	rep(i, n) {
		if (T[i] <= t)ans = min(ans, C[i]);
	}
	if (ans == 10000)puts("TLE");
	else cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<queue>
#include<stack>
#include<string>
#include<cmath>
#include<algorithm>
#include<bitset>
#include<map>
#include<functional>
#include<set>
#include<numeric>

#pragma region
using namespace std;
#define FOR(i,r,n) for(ll i = (ll)(r); i < (ll)(n); i++)
#define rep(i,n) FOR(i,0,n)
#define RFOR(i,r,n) for(ll i=(ll)(n-1);i>=r;i--)
#define rrep(i,n) RFOR(i,0,n)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define COUNT(a,x)  upper_bound(all(a), x) - lower_bound(all(a), x)
#define MCOUNT(a,x,y) upper_bound(all(a), y) - lower_bound(all(a), x)
#define UNIQUE(a) sort(all(a)); a.erase(unique(all(a)), a.end())
#define SUM(a) accumulate(all(a),0)
#define scan(x) scanf("%lld",&x)
#define pb push_back
typedef long long int ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<ll, ll> pll;
typedef vector<pll> vpll;
typedef vector<string> vs;
typedef map<ll, ll> MAP;
typedef set<ll> SET;
typedef double D;
const ll inf = 2222222222222222222;
const ll mod = 1000000007;
const D pi = acos(-1);
const D eps = 1e-10;

ll n = 0, m = 0, ans = 0, cnt = 0, tmp = 0, ma = -inf, mi = inf;
string s;
bool ok, flag;
ll dx[5] = { 1,-1,0,0,0 }, dy[5] = { 0,0,1,-1,0 };
ll ddx[9] = { 1,-1,0,0,1,1,-1,-1,0 }, ddy[9] = { 0,0,1,-1,1,-1,1,-1,0 };
#pragma endregion
#define MAX 111111


int main(void) {
  cin >> s;
  cin >> m;
  rep(i, s.length()) {
	if (i %m == 0) cout << s[i];
  }
  cout << endl;

  return 0;
}

Measured memory_bytes: 256
N = int(input())

x = [0] * N
y = [0] * N
h = [0] * N

for k in range(N):
    x[k],y[k],h[k] = map(int,input().split())

for i in range(101):
    for j in range(101):
        det = 0
        H = 0
        for k in range(N):
            if H == 0 and h[k] > 0:
                H = h[k] + abs(x[k]-i) + abs(y[k]-j)
            elif h[k] != max(0,H - abs(x[k]-i) - abs(y[k]-j)):
                det = -1
                break
        if det == 0:
            ans = [i,j,H]

print(" ".join(map(str,ans)))

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

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

struct Point { double x, y; };

void koch(int n, Point a, Point b){
  if(n == 0)return;

  Point s, t, u;
  double th = M_PI * 60.0 / 180.0;

  s.x = (2.0 * a.x + 1.0 * b.x) / 3.0;
  s.y = (2.0 * a.y + 1.0 * b.y) / 3.0;
  t.x = (1.0 * a.x + 2.0 * b.x) / 3.0;
  t.y = (1.0 * a.y + 2.0 * b.y) / 3.0;
  u.x = (t.x - s.x) * cos(th) - (t.y - s.y) * sin(th) + s.x;
  u.y = (t.x - s.x) * sin(th) + (t.y - s.y) * cos(th) + s.y;

  koch(n - 1, a, s);
  printf("%.8f %.8f\n",s.x, s.y);
  koch(n - 1, s, u);
  printf("%.8f %.8f\n",u.x, u.y);
  koch(n - 1, u, t);
  printf("%.8f %.8f\n",t.x, t.y);
  koch(n - 1, t, b);
}

int main(){
  Point a, b;
  int n;

  scanf("%d",&n);

  a.x = 0;
  a.y = 0;
  b.x = 100;
  b.y = 0;

  printf("%.8f %.8f\n",a.x, a.y);
  koch(n, a, b);
  printf("%.8f %.8f\n",b.x, b.y);

  return 0;
}



Measured memory_bytes: 2708
#include<stdio.h>
int main()
{
int W,H,x,y,r;
scanf("%d %d %d %d %d",&W,&H,&x,&y,&r);
if(x-r>=0&&x+r<=W&&y-r>=0&&y+r<=H)
{
printf("Yes\n");
}
else
{
printf("No\n");
}
return 0;
}

Measured memory_bytes: 584
#include <iostream>
#include <sstream>
#include <vector>
#include <numeric>
#include <algorithm>
#include <cmath>
#include <string>
#include <map>
#include <iomanip>
#include <string>
using namespace std;

//関数getinputdata宣言
vector<vector<string>> getinputdata();
vector<vector<int>> getinputdata2();
vector<vector<double>> getinputdata3();

void nikkei2019_qual_a(vector<vector<int>> v) {

    int n = v[0][0];
    int a = v[0][1];
    int b = v[0][2];

    int maxdata = min(a, b);
    int min_max = max(a, b);
    int min_min = min(a, b);


    int half_data = n / 2;

    int mindata = 0;

    if (min_max + min_min > n) {
        mindata=min_max + min_min - n;
    }



    cout << maxdata << " " << mindata << endl;
}

int main() {

    //    vector<vector < string>> vec_arr_result;
    //    vector<vector<int>> vec_arr_result;
    vector<vector<int>> vec_arr_result;
    vec_arr_result = getinputdata2();

    nikkei2019_qual_a(vec_arr_result);

    return 0;
}

//関数getinputdata実装

vector<vector<double>> getinputdata3() {

    string str;
    string ret;
    stringstream ss;
    vector<string> v1;
    vector<vector<double>> vec_arr;

    //標準入力から入力がある間ループ処理でvector配列にデータ格納
    while (getline(cin, str)) {

        v1.push_back(str);

    }

    //stringstreamを利用してvector配列v1をスペースで分解処理
    for (string s : v1) {

        vector<double> array_data;
        ss << s;

        while (!ss.eof()) {

            ss >> ret;

            array_data.push_back(atof(ret.c_str()));
        }

        //vector配列に追加
        vec_arr.push_back(array_data);

        //バッファクリア
        ss.str("");
        //ストリームクリア
        ss.clear(stringstream::goodbit);

    }

    return vec_arr;
}

//関数getinputdata実装

vector<vector<int>> getinputdata2() {

    string str;
    string ret;
    stringstream ss;
    vector<string> v1;
    vector<vector<int>> vec_arr;

    //標準入力から入力がある間ループ処理でvector配列にデータ格納
    while (getline(cin, str)) {

        v1.push_back(str);

    }

    //stringstreamを利用してvector配列v1をスペースで分解処理
    for (string s : v1) {

        vector<int> array_data;
        ss << s;

        while (!ss.eof()) {

            ss >> ret;

            array_data.push_back(atoi(ret.c_str()));
        }

        //vector配列に追加
        vec_arr.push_back(array_data);

        //バッファクリア
        ss.str("");
        //ストリームクリア
        ss.clear(stringstream::goodbit);

    }

    return vec_arr;


}

//関数getinputdata実装

vector<vector < string >> getinputdata() {

    string str;
    string ret;
    stringstream ss;
    vector<string> v1;
    vector<vector < string>> vec_arr;

    //標準入力から入力がある間ループ処理でvector配列にデータ格納
    while (getline(cin, str)) {

        v1.push_back(str);

    }

    //stringstreamを利用してvector配列v1をスペースで分解処理
    for (string s : v1) {

        vector<string> array_data;
        ss << s;

        while (!ss.eof()) {

            ss >> ret;

            array_data.push_back(ret);
        }

        //vector配列に追加
        vec_arr.push_back(array_data);

        //バッファクリア
        ss.str("");
        //ストリームクリア
        ss.clear(stringstream::goodbit);

    }

    return vec_arr;

}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int area = a * b;
        int length = 2 * a + 2 * b;
        System.out.println(area + " " + length);
        sc.close();
    }
}


Measured memory_bytes: 26096
#include<stdio.h>

void inserttionSort(int numbers[],int array_size){
  int i,j;
  for(i=1;i<array_size;i++){
    j=i;

    while((j>0)&&(numbers[j-1]>numbers[j])){
      int tmp;
      tmp =numbers[j-1];
      numbers[j-1]=numbers[j];
      numbers[j]=tmp;
      j--;

    }
    for(int k=0;k<array_size;k++){
    if(k!=array_size-1)printf("%d ",numbers[k]);
    else{printf("%d",numbers[k]);}
  }
  printf("\n");
  }

}
int main(void){
  int n;
  int A[100];
  scanf("%d",&n);
  for(int i=0;i<n;i++){
    scanf("%d",&A[i]);
  }
  for(int p=0;p<n;p++){
    if(p!=n-1)printf("%d ",A[p]);
    else{printf("%d",A[p]);}
  }
  printf("\n");
  inserttionSort(A,n);


  return 0;
}



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

#define max 1000000

int main()
{
	int a;
	int x,y,z;
	int r[max];
	for(x=3;x<=max;x+=2){
			r[x]=1;
	}
	for(z=3;z<=1000;z+=2)
			if(r[z]==1){
			for(x=3;x<=max/z;x+=2){
					r[x*z]=0;
			}
			}
	while((scanf("%d",&a))!=EOF){
		
		if(a==1){
			printf("%d\n",0);
		continue;
		}
		int t;
		t=1;
		
			for(x=3;x<=a;x+=2){
			if(r[x]==1)
				t++;
			}
			printf("%d\n",t);
	}
	return 0;
}

Measured memory_bytes: 4500
#include <iostream>
#include <cstring>
#include <stdlib.h>
#include <vector>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <math.h>
#include <string>
#include <map>
#include <cstdlib>
using namespace std;

typedef long long ll;

int main()
{
    int N;
    cin >> N;
    vector<int> d(N);
    for(int i=0; i<N; i++){
        cin >> d[i];
    }
    sort(d.begin(), d.end());
    if(d[N/2-1]==d[N/2]) cout << 0;
    else{
        int ans=0;
        while(true){
            if(d[N/2-1]+1+ans==d[N/2]) break;
            ans++;
        }
        ans++;
        cout << ans << endl;
    }



    return 0;
}

Measured memory_bytes: 640
//#include <algorithm>
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <unordered_map>
//#include <math.h>

using namespace std;

using ll = long long;
using ld = long double;
using ull = unsigned long long;

template<class T> using vec = vector<T>;
template<class T> using vvec = vector<vector<T>>;

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

ll calc(ll n)
{
    if (n < 2) return 0;

    ll c = 1;
    for (ll i = n; i > n - 2; --i)
    {
        c *= i;
    }

    return c / 2;
}

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

    ll N, M; cin >> N >> M;

    ll c = 0;
    c += calc(N);
    c += calc(M);

    cout << c << endl;

    return 0;
}


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

int q[8] = {0, 1, 2, 3, 5, 7, 8, 9 };

int main(){
	int n;
	while (std::cin >> n, n){
		std::string v;

		while (n != 0){
			char a;
			a = n % 8 + '0';
			v += a;
			n /= 8;
		}
		for (int i = v.size() - 1; i >= 0; i--){
			int j = v[i] - '0';
			v[i] = q[j] + '0';
			std::cout << v[i];
		}
		std::cout << std::endl;
	}
	return 0;
}

Measured memory_bytes: 1192
#include <iostream>

int main()
{
	int K, S, c123 = 0, c112 = 0, c122 = 0, c111 = 0;
	std::cin >> K >> S;
	for (int x = 0; x <= K; x++)
	{
		// if (x + 0 + 0 > S) break;
		// if (x + K + K < S) continue;
		for (int y = 0; y < x; y++)
		{
			// if (x + y + 0 > S) break;
			// if (x + y + K < S) continue;
			for (int z = 0; z < y; z++)
			{
				// if (x + y + z > S) break;
				if (x + y + z == S) c123++;
			}
		}
	}
	for (int x = 0; x <= K; x++)
	{
		// if (x + x + 0 > S) break;
		// if (x + x + K < S) continue;
		for (int z = 0; z < x; z++)
		{
			// if (x + x + z > S) break;
			if (x + x + z == S) c112++;
		}
	}
	for (int x = 0; x <= K; x++)
	{
		// if (x + 0 + 0 > S) break;
		// if (x + K + K < S) continue;
		for (int z = 0; z < x; z++)
		{
			// if (x + z + z > S) break;
			if (x + z + z == S) c122++;
		}
	}
	for (int x = 0; x <= K; x++)
	{
		// if (x + x + x > S) break;
		if (x + x + x == S) c111++;
	}
	std::cout << c123 * 6 + c112 * 3 + c122 * 3 + c111 << std::endl;
	return 0;
}


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

typedef long long LL;

LL ans[15], d[10000000], tot = 0;

LL chuli(LL a, LL b)
{
    LL mod = 20000222ll;
    a *= mod;
    b *= 521ll;
    b ++;
    return a + b;
}

int main()
{
    LL h, w, n, a, b;
    cin >> h >> w >> n;
    LL sy = (h-2)*(w-2);
    while (n--)
    {
        scanf("%lld%lld", &a, &b);
        for (LL i = 0; i < 3; i++)
        {
            for (LL j = 0; j < 3; j++)
            {
                if (a - i >= 1 && a - i <= h - 2 && b - j >= 1 && b - j <= w - 2)
                {
                    d[++tot] = chuli((a-i), (b-j));
                }
            }
        }
    }
    sort(d+1, d+tot+1);
    int ls = 1;
    for (int i = 1; i <= tot; i++)
    {
        if (d[i] == d[i+1])
        {
            ls++;
        }
        else
        {
            ans[ls]++;
            ls = 1;
            sy--;
        }
    }
    cout << sy << endl;
    for (int i = 1; i <= 9; i++)
    {
        cout << ans[i] << endl;
    }
    return 0;
}


Measured memory_bytes: 8448
import sys
from collections import Counter
input=sys.stdin.readline

n,k,q=map(int,input().split())
a=Counter([int(input()) for _ in range(q)])

ans=[False]*n
for key,v in a.items():
    if k-(q-v)>0:
        ans[key-1]=True

ss=set(a.keys())

for i in range(n):
    if i+1 in ss:continue
    if k-q>0:
        ans[i]=True
    


for e in ans:
    if e:
        print('Yes')
    else:
        print('No')

Measured memory_bytes: 13548
#include<bits/stdc++.h>
using namespace std;
inline int read(){
    int f=1,x=0;
    char ch;
    do{
        ch=getchar();
        if(ch=='-'){
            f=-1;
        }
    }while(ch<'0'||ch>'9');
    do{
        x=x*10+ch-48;
        ch=getchar();
    }while(ch>='0'&&ch<='9');
    return f*x;
}
int main(){
    string s;
    ios::sync_with_stdio(0);
    cin>>s;
    for(register int i=0;i<s.length();++i){
        if(s[i]=='9'){
            cout<<"Yes"<<endl;
            return 0;
        }
    }
    cout<<"No"<<endl;
    return 0;
}

Measured memory_bytes: 256
n = int(input())
h = list(map(int, input().split()))
val1 = [0 for _ in range(n)]
val2 = [0 for _ in range(n)]
val = [0 for _ in range(n)]
for i in range(n):
	if i + 1 <= n - 1:
		val1[i] = abs(h[i] - h[i + 1])
	if i + 2 <= n - 1:
		val2[i] = abs(h[i] - h[i + 2])
for i in range(n):
	if i-2 >= 0:
		val[i] = min([val[i-1]+val1[i-1], val[i-2]+val2[i-2]])
	elif i-1 >= 0:
		val[i] = val[i-1]+val1[i-1]
print(val[n-1])

Measured memory_bytes: 19116
#include<bits/stdc++.h>
using namespace std;
 
#define ll long long int
 
#define pb push_back
#define pf push_front
#define pob pop_back
#define pof pop_front
#define mp make_pair
#define xx first
#define yy second
 
#define pii pair <int, int >
#define pll pair < ll, ll >
#define xx first
#define yy second
#define vi vector < int >
#define vl vector < ll >
#define vp vector < pii >
 
#define inf  100000000
 
#define f(i, c, n) for(int i = c; i < n; i++)
#define fe(i, c, n) for(int i = c; i <= n; i++)
#define fr(i, n, c) for(int i = n - 1; i >= c; i--)
 
#define be(a) a.begin(), a.end()
#define vsort(a) sort(a.begin(), a.end())
#define mem(a) memset(a, 0, sizeof(a))
#define memn(a) memset(a, -1, sizeof(a))
#define srti(a, n) sort(a, a + n)
#define srtd(a, n) sort(a, a + n, greater<int>())
#define LB(a, x) (lower_bound(vbe(a), x) - a.begin())
#define UB(a, x) (upper_bound(vbe(a), x) - a.begin())
#define S " "
#define N "\n"

//cout << "Case " << ++cs << ": " <<
#define fast ios_base :: sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define FILE freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);


void solve() {
	int a, b, c, d;
	cin >> a >> b >> c >> d;
	int mn = min(a, b);
	mn += min(c, d);
	cout << mn << N;
}

int main() {
    // FILE;
    fast;
    // int t; cin >> t; while(t--)
    solve();
}

Measured memory_bytes: 3660
import sys
H,W=map(int,input().split())

mat=[]
mat.append([False]*(W+2))
for i in range(H):
  array=[False]+[x=="." for x in input()]+[False]
  mat.append(array)
mat.append([False]*(W+2))
#print(mat)

true_num=0
for i in range(1,H+1):
  for j in range(1,W+1):
    if mat[i][j]:
      true_num+=1

if not mat[1][1] or not mat[H][W]:
  print(-1)
  sys.exit(0)

visited_dic={}
dist=0
queue={(1,1)}
while(len(queue)>0):
  new_queue=set()
  
  for q in queue:
    visited_dic[q]=dist
    if q==(H,W):
      break
    
    x,y=q
    if mat[x-1][y] and not (x-1,y) in visited_dic:
      new_queue.add((x-1,y))
    if mat[x+1][y] and not (x+1,y) in visited_dic:
      new_queue.add((x+1,y))
    if mat[x][y-1] and not (x,y-1) in visited_dic:
      new_queue.add((x,y-1))
    if mat[x][y+1] and not (x,y+1) in visited_dic:
      new_queue.add((x,y+1))
      
  queue=new_queue
  dist+=1
  
if not (H,W) in visited_dic:
  print(-1)
else:
  #print(visited_dic)
  print(true_num-visited_dic[(H,W)]-1)

Measured memory_bytes: 3316
#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 n;
	cin >> n;
	vector<vector<int>> g(n);
	rep(i, n-1) {
		int a, b;
		cin >> a >> b;
		a--; b--;
		g[a].push_back(b);
		g[b].push_back(a);
	}
	vector<int> color(n, -1);
	color[0] = 0; // 黒 (Fennec)
	color[n-1] = 1; // 白 (Sunuke)
	
	// bfs
	int start = 0;
	vector<int> dist(n, -1);	//startからの距離を格納。未訪問は-1
	queue<int> que;
	dist[start] = 0;
	que.push(start);
	while(!que.empty()) {
		int v = que.front();
		que.pop();
		for(int nv: g[v]) {
			if(dist[nv] != -1) continue;
			dist[nv] = dist[v] + 1;
			que.push(nv);
		}
	}
	// 黒から白までの経路を復元
	int now = n-1;
	while(1) {
		bool finish = false;
		for(int v: g[now]) {
			if(dist[v] == dist[now]-1) {
				color[v] = (dist[n-1]/2 >= dist[v]) ? 0 : 1;
				now = v;
				if(now == 0) {
					finish = true;
				}
				break;
			}
		}
		if(finish) break;
	}
	// rep(i, n) cout << color[i] << " ";
	// cout << endl;
	{
		// 黒を塗ります。
		int start = 0;
		vector<int> dist(n, -1);	//startからの距離を格納。未訪問は-1
		queue<int> que;
		dist[start] = 0;
		que.push(start);
		while(!que.empty()) {
			int v = que.front();
			que.pop();
			for(int nv: g[v]) {
				if(dist[nv] != -1) continue;
				if(color[nv] == 1) continue;
				dist[nv] = dist[v] + 1;
				color[nv] = 0;
				que.push(nv);
			}
		}
	}
	// rep(i, n) cout << color[i] << " ";
	// cout << endl;
	{
		// 白を塗ります。
		int start = n-1;
		vector<int> dist(n, -1);	//startからの距離を格納。未訪問は-1
		queue<int> que;
		dist[start] = 0;
		que.push(start);
		while(!que.empty()) {
			int v = que.front();
			que.pop();
			for(int nv: g[v]) {
				if(dist[nv] != -1) continue;
				if(color[nv] == 0) continue;
				dist[nv] = dist[v] + 1;
				color[nv] = 1;
				que.push(nv);
			}
		}
	}
	int cnt = 0;
	rep(i, n) {
		if(color[i] == 0) cnt++;
	}
	// rep(i, n) cout << color[i] << " ";
	// cout << endl;
	if(cnt > n/2) cout << "Fennec" << endl;
	else cout << "Snuke" << endl;
	return 0;
}

Measured memory_bytes: 6924
import java.io.*;
import java.util.*;

public class Main {
    static PrintWriter out = new PrintWriter(System.out);
    static Scanner sc = new Scanner(System.in);
    static BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
    int maxn;
    long[] frac,inv;
    long mod = 1000000000+7;
    public static void main(String[] args) throws IOException {
        Main main = new Main();
//        main.solve();
        System.out.println(main.solve());
    }
    String solve() throws IOException {
        int n = sc.nextInt(),  m = sc.nextInt();
        TreeSet<Integer>[] rec = new TreeSet[n+1];
        for(int i=0;i<=n;i++) rec[i] = new TreeSet<>();
        for(int t=0;t<m;t++){
            int s = sc.nextInt(), c = sc.nextInt();
            rec[s].add(c);
        }
        if(m==0){
            if(n==1) return "0";
        }
        StringBuilder sb = new StringBuilder();
        for(int d=1;d<=n;d++){
            if(rec[d].size()>1) return "-1";
            int now;
            if(rec[d].size()==0){
                now = d==1?1:0;
            } else{
                now = rec[d].first();
            }
            sb.append(now);
        }
        String ans = sb.toString();
        if(ans.length()>1&&ans.charAt(0)=='0') return "-1";
        return sb.toString();
    }
}



Measured memory_bytes: 22996
#include <bits/stdc++.h>
 
#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)
 
#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=(int)(a)-1;i>=(int)(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)
 
#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define getidx(ary,key) lower_bound(_all(ary),key)-begin(ary)
#define clr(a,b) memset((a),(b),sizeof(a))
#define bit(n) (1LL<<(n))
 
// #define DEBUG
 
#ifdef DEBUG
    #define dump(...) fprintf(stderr, __VA_ARGS__)
#else
    #define dump(...)
#endif
 
template<class T>bool chmax(T &a, const T &b) { return (a<b)?(a=b,1):0;}
template<class T>bool chmin(T &a, const T &b) { return (b<a)?(a=b,1):0;}
 
using namespace std;
using ll=long long;
using vi=vector<int>;
using vll=vector<ll>;
 
const double EPS = 1e-10;
const double PI = acos(-1.0);
const int inf =1LL << 30;
const ll mod=1000000007LL;
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
 
 
ll extgcd(ll a,ll b,ll& x,ll& y){x=1,y=0;ll g=a;if(b!=0) g=extgcd(b,a%b,y,x),y-=a/b*x;return g;}
ll ADD(const ll &a, const ll &b,const ll &mod) { return (a+b)%mod;}
ll SUB(const ll &a, const ll &b,const ll &mod) { return (a-b+mod)%mod;}
ll MUL(const ll &a, const ll &b,const ll &mod) { return (1LL*a*b)%mod;}
ll DIV(const ll &a, const ll &b,const ll &mod) {ll x,y; extgcd(b,mod,x,y);return MUL(a,(x+mod)%mod,mod);}
 
random_device rd;
mt19937 mt(rd());
uniform_int_distribution<int> dice(1,6);
uniform_real_distribution<double> score(0.0,10.0);
 
int n, res;
using vvi = vector<vi>;
vvi costs;
vi invited, used;

void dfs(int v){
    if(v == n){
        int cost = 0;
        rep(i, n){
            if(not invited[i]) continue;

            int diff = inf;
            rep(j, n){
                if(i != j and invited[j]){
                    chmin(diff, costs[i][j]);
                }
            }
            if(diff == inf) continue;

            cost += diff;
        }
        chmax(res, cost);

        return;
    }

    // not use v
    dfs(v + 1);

    if(used[v]) return;

    // use v
    invited[v] = true;
    vi idxs;
    rep(u, v + 1, n){
        if(costs[v][u] == 0 and not used[u]){
            used[u] = true;
            idxs.push_back(u);
        }
    }
    dfs(v + 1);
    for(auto & u : idxs){
        used[u] = false;
    }
    invited[v] = false;
}

int main(void){
    int m; cin >> n >> m;
    costs = vvi(n, vi(n));

    rep(loop, m){
        int a, b, c; cin >> a >> b >> c;
        a--, b--;
        costs[a][b] = costs[b][a] = c;
    }

    invited = used = vi(n);
    res = 0;
    dfs(0);

    cout << res << endl;

    return 0;
}

Measured memory_bytes: 3268
#include <iostream>
using namespace std;
int main(){
    string N;
    cin >> N;
    if(N == "Sunny"){
        cout << "Cloudy" << endl;
    }else if(N == "Cloudy"){
        cout << "Rainy" << endl;
    }else{
        if(N == "Rainy"){
            cout << "Sunny" << endl;
        }
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <limits>
#include <string>
#include <boost/range/irange.hpp>
#include <boost/range/adaptors.hpp>


using namespace std;
using namespace boost;
using uint = unsigned int;
using ll = long long int;
using ull = unsigned long long int;

int main() {
    string s;
    cin >> s;
    cout << *s.begin() << s.size()-2 << *s.rbegin();
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
double a,b,h,m;
double i,j;
double ans;
double pi=3.141592653589793238;
int main(void){
    cin>>a>>b>>h>>m;
    i=2*pi*h/12;
    j=2*pi*m/60;
    i=i+pi/6*m/60;
    //cout<<cos(i-j)<<endl;
    ans=a*a+b*b-2*a*b*cos(i-j);
    ans=sqrt(ans);
    cout<<setprecision(100)<<ans<<endl;
    
}


Measured memory_bytes: 4228
#include <iostream>
#include <algorithm>
using namespace std;
int main(void) {
	int N, A[101];
	cin >> N;
	for (int i = 0; i < N; i++) cin >> A[i];

	int temp;
	int cnt = 0;
	for (int i = 0; i < N; i++) {
		int idx = i;
		for (int j = i; j < N; j++) {
			if (A[idx] > A[j]) {
				idx = j;
			}
		}
		if (idx != i) {
			temp = A[i];
			A[i] = A[idx];
			A[idx] = temp;
			cnt++;
		}
	}
	for (int j = 0; j < N-1; j++) cout << A[j] << " ";
	cout << A[N-1]<< endl;
	cout << cnt << endl;
	return 0;
}


Measured memory_bytes: 3124
/*
 *  author : Atul Anand   
 *  created on : Wed Apr 01 2020
 */

import java.io.*;
import java.util.*;

public class Main{

    public static void main(String[] args) throws IOException {
        String S = in.next();
        String T = in.next();
        print(T+S);
        in.close();
        out.close();
    }

    static int MIN = Integer.MIN_VALUE;
    static int MAX = Integer.MAX_VALUE;
    static Reader in = new Reader();
    static PrintWriter out = new PrintWriter(System.out);

    static void read(int arr[], int N) throws IOException { 
    	for(int i = 0; i < N; i++){ 
    		arr[i] = in.nextInt(); 
    	} 
    }
    
    static void read(long arr[], int N) throws IOException { 
    	for(int i = 0; i < N; i++){ 
    		arr[i] = in.nextLong(); 
    	} 
    }
    
    static void read(String arr[], int N) throws IOException { 
    	for(int i = 0; i < N; i++){ 
    		arr[i] = in.next(); 
    	} 
    }
    
    static void print(Object O) {  
    	out.print(O); 
    }
    
    static void println(Object O) { 
    	out.println(O); 
    }
    
    static void println(int arr[]) { 
    	for(int i = 0; i < arr.length; i++){ 
    		print(arr[i]+" "); 
    	} 
    	println(""); 
    }

    static void println(int arr[][]) { 
    	for(int i = 0; i < arr.length; i++){ 
    		println(arr[i]); 
    	}
    }
    
    static void debug(Object O) { 
    	System.out.println(O); 
    }
}

class Reader {
    BufferedReader reader;
    StringTokenizer tokenizer;

    Reader() {
        reader = new BufferedReader(new InputStreamReader(System.in));
        tokenizer = new StringTokenizer("");
    }

    String next() throws IOException {
        while (!tokenizer.hasMoreTokens() ) { 
            tokenizer = new StringTokenizer(reader.readLine()); 
        }
        return tokenizer.nextToken();
    }

    int nextInt() throws IOException { 
        return Integer.parseInt(next()); 
    }
    
    double nextDouble() throws IOException { 
        return Double.parseDouble(next());
    }
    
    long nextLong() throws IOException { 
        return Long.parseLong(next()); 
    }
    
    String nextLine() throws IOException { 
        return reader.readLine(); 
    }
    
    void close() throws IOException { 
        reader.close(); 
    }
}

Measured memory_bytes: 20052
#include <bits/stdc++.h>
using namespace std;
#define REP(i,x,n) for(int i=x;i<(int)n;i++)
#define rep(i,n) REP(i,0,n)
#define sp(p) cout<<setprecision(16)<<fixed<<p<<endl;
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define SORT(a) sort(all(a))
#define RSORT(a) sort(rall(a))
#define UNIQ(a) unique(all(a))
#define UNIQNUM(a) UNIQ(a)-a.begin()
#define UNIQIT(a) a.erase(UNIQ(a), a.end());
#define VOUT(v,i) rep(i,v.size())cout<<v[i]<<(i==v.size()-1?"\n":" ");
#define vout(v) VOUT(v,z);
#define vdbg(v,i) cout<<#v<<": ";for(int i=0;i<(int)v.size();i++){cout<<v[i]<<" ";}cout<<"\n";
#define vmin(v) *min_element(all(v))
#define vmax(v) *max_element(all(v))
#define vsum(v) accumulate(all(v), 0LL)
#define MOUT(m,r,c) rep(i,r){rep(j,c){cout<<m[i][j]<<" ";}cout<<endl;}
#define mout(m) MOUT(m,m.size(),m[0].size())
#define debg(a) cout<<#a<<": "<<a<<endl;
#define show(a) for(cont &y:a){for(cont &x:y){cout<<x<<" ";}cout<<endl;}
#define digit(a) to_string(a).length();
template<class T>inline int out(const T &t){ print(t); putchar('\n'); return 0; }
// template<class T>inline T gcd(T a,T b){if(b==0)return a; return(gcd(b,a%b));}
// template<class T>inline T lcm(T a,T b){return a/gcd(a,b)*b;}
bool is_palindrome(string s){return s == string(s.rbegin(),s.rend());}
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> P;
typedef vector<ll> V;
typedef vector<vector<ll>> VV;
// const long long MOD=1000000007;
const long long INF = 1e18;
#define EPS (1e-7)
#define PI (acos(-1))
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;
}


// bool check(ll mid){

// }

int main(){
    long long A;
    scanf("%lld",&A);
    long long B;
    scanf("%lld",&B);
    long long N;
    scanf("%lld",&N);
    //solve(A, B, N);

    // ll ng=-1, ok=N;
    // while(abs(ok-ng)>1){
    //     int mid=(ok+ng)/2;
    //     if(check(mid)){
    //         ok=mid;
    //     }else{
    //         ng=mid;
    //     }
    // }

    ll ma=0;

    if(B-1<=N){
        ll b = B-1;
        cout << floor(A*b*1.0/B) - A*floor(b*1.0/B) << endl;
        return 0;
    }

    if(N<=10e7){
        for (long long i = 0; i <= N; i++) {
            ll v=floor(A*i*1.0/B) - A*floor(i*1.0/B);
            // cout << v << endl;
            ma=max(ma, v);
        }
    }else{
        for (long long i = N; N - i <= 10e7; i--) {
            ll v=floor(A*i*1.0/B) - A*floor(i*1.0/B);
            // cout << v << endl;
            ma=max(ma, v);
        }
    }

    // ll b = B-1;
    // ma = floor(A*b*1.0/B) - A*floor(b*1.0/B);

    cout << ma << endl;

    return 0;
}


Measured memory_bytes: 3848
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <cassert>
#include <climits>
#include <string>
#include <bitset>
#include <cfloat>
#include <random>
#include <unordered_set>
#pragma GCC optimize("Ofast")
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<ll> > vvll;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define irep(it, stl) for(auto it = stl.begin(); it != stl.end(); it++)
#define drep(i,n) for(int i = (n) - 1; i >= 0; --i)
#define fin(ans) cout << (ans) << '\n'
#define STLL(s) strtoll(s.c_str(), NULL, 10)
#define mp(p,q) make_pair(p, q)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define Sort(a) sort(a.begin(), a.end())
#define Rort(a) sort(a.rbegin(), a.rend())
#define MATHPI acos(-1)
#define itn int;
#define endl '\n';
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
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;}
inline string getline(){string s; getline(cin,s); return s;}
inline void yn(const bool b){b?fin("yes"):fin("no");}
inline void Yn(const bool b){b?fin("Yes"):fin("No");}
inline void YN(const bool b){b?fin("YES"):fin("NO");}
struct io{io(){ios::sync_with_stdio(false);cin.tie(0);}};
const int INF = INT_MAX;
const ll LLINF = 1LL<<60;
const ll MOD = 1000000007;
const double EPS = 1e-9;


// vector vの中のn以下の数で最大のものを返す
ll bs(vector<ll> &v, ll x){
    ll ok = -1; //これがx以下 
    ll ng = v.size(); //x以上 
    // 問題によってokとngを入れ替える
    while(abs(ok - ng) > 1){
        ll mid = (ok + ng)/2;
        if(v[mid] <= x) ok = mid;
        else ng = mid;
    }
    return ok;
}

int main() {
    
    ll n;
    cin>>n;
    vll a(n),b(n),c(n),v(n);
    rep(i,n)cin>>a[i];
    rep(i,n)cin>>b[i];
    rep(i,n)cin>>c[i];
    Sort(a);
    Sort(b);
    Sort(c);
    ll ans=0;
    rep(i,n){
        v[i]=n-bs(c, b[i])-1;
    }
    vll csum(1,0);
    rep(i,n)csum.pb(csum[i]+v[n-i-1]);
    reverse(all(csum));
    rep(i,n){
        ll pos=bs(b, a[i])+1;
        // cout<<i<<" "<<pos<<" "<<csum[pos]<<endl;
        ans+=csum[pos];
    }
    fin(ans);
}



Measured memory_bytes: 4472
#include <iostream>
#include <vector>
#include <map>
#include <cmath>
#include <algorithm>
#define endl "\n"
#define ll long long int
using namespace std;

int main()
{
    ll n, k;
    cin >> n >> k;

    map <ll, ll> mp;

    for(ll i = 0; i < n; i ++)
    {
    	ll a, b;
    	cin >> a >> b;
    	mp[a] = mp[a] + b;
    }

    for(auto it = mp.begin(); it != mp.end(); it ++)
    {
    	if(it -> second < k)
    		k = k - it->second;
    	else
    	{
    		cout << it -> first;		
    		break;
    	}
    }
}


Measured memory_bytes: 4224
#include <iostream>

void dump(int* A, int n)
{
  for (int i = 0; i < n; ++i)
  {
    if (i > 0) std::cout << " ";
    std::cout << A[i];
  }
  std::cout << std::endl;
}

int main()
{
  int A[110];
  int N;
  std::cin >> N;
  for (int i = 0; i < N; ++i)
  {
    std::cin >> A[i];
  }

  dump(A, N);

  for (int i = 1; i < N; ++i)
  {
    int val = A[i];
    int j = i - 1;
    while (j >= 0 && A[j] > val)
    {
      A[j + 1] = A[j];
      --j;
    }
    A[j + 1] = val;
    dump(A, N);
  }

  return 0;
}



Measured memory_bytes: 3124
#include <bits/stdc++.h>
using namespace std;
#define ALL(a) (a).begin(),(a).end()
#define rALL(a) (a).rbegin(),(a).rend()
typedef pair<int, int> Pint;
typedef pair<int64_t, int64_t> Pll;

int main() {
    string S;
    cin >> S;
    for (int i = 0; i < S.size(); i++){
        cout << "x";
    }
    cout << endl;
}


Measured memory_bytes: 256
N,x = map(int,input().split(' '))
a = list(map(int,input().split(' ')))

a=sorted(a)
cnt=0
ans=0
for i in range(N): 
    cnt+=a[i]
    if i == N-1 and cnt < x:
        break
    if cnt > x:
        break
    else:
        ans+=1

print(ans)


Measured memory_bytes: 3060
#include <iostream>
#include <cmath>
#include <set>
#include <string>
using std::cin;
using std::cout;
using std::endl;
using std::string;

int main() {
    
    int A,B,C,X,Y;
    cin >> A >> B >> C >> X >> Y;
    if ((A + B) / 2 < C) {
        cout << X * A + Y * B << endl;
    } else {
        int countPrice = std::min(X, Y) * 2 * C;

        int pizzaP = 0;
        if (X > Y) {
            pizzaP = A;
        } else {
            pizzaP = B;
        }
        if (pizzaP > C * 2) {
            countPrice += C*2*std::abs(X-Y);
        } else {
            countPrice += pizzaP*std::abs(X-Y);
        }

        cout << countPrice << endl;
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <stdio.h>
#include <cmath>
#include <cctype>
#include <map>

const int INT_INF = 1000000000;                 // 10^9
const long long LONG_INF = 1000000000000000000; // 10^18

using namespace std;

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

    vector<int> p(n), q(n), a(n);
    for (int i = 0; i < n; i++)
        cin >> p[i];
    for (int i = 0; i < n; i++)
        cin >> q[i];
    for (int i = 0; i < n; i++)
        a[i] = i + 1;

    int count = 1;
    map<vector<int>, int> m;
    while (next_permutation(a.begin(), a.end()))
    {
        m[a] = count;
        count++;
    }

    int ans = abs(m[p] - m[q]);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 5248
#include<iostream>
using namespace std;
int abs(int a){if(a<0)return -a;else return a;}
int main(){
	int ans,pre,N,L,minValue=1000000,res;
	cin>>N>>L;
	ans=N*(L-1)+N*(N+1)/2;
	for(int i=1;i<=N;i++){
		if(minValue>abs(L+i-1)){
			minValue=abs(L+i-1);
			res = ans-(L+i-1);
		}
		
	}
	cout<<res;
	return 0;
}

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

namespace AtCorder
{
	public class Program
	{
		static void Main(string[] args)
		{
			var cin = new Scanner2();
			int a = cin.Int();
			int b = cin.Int();
			Console.WriteLine(6 - a - b);
		}
	}

	public class Scanner2
	{
		private readonly char[] delimiter_ = new char[] { ' ' };
		private readonly string filePath_;
		private readonly Func<string> reader_;
		private string[] buf_;
		private int index_;

		public Scanner2(string file = "")
		{
			if (string.IsNullOrWhiteSpace(file)) {
				reader_ = Console.ReadLine;
			} else {
				filePath_ = file;
				var fs = new StreamReader(file);
				reader_ = fs.ReadLine;
			}
			buf_ = new string[0];
			index_ = 0;
		}

		public string Next()
		{
			if (index_ < buf_.Length) {
				return buf_[index_++];
			}

			string st = reader_();
			while (st == "") {
				st = reader_();
			}

			buf_ = st.Split(delimiter_, StringSplitOptions.RemoveEmptyEntries);
			if (buf_.Length == 0) {
				return Next();
			}

			index_ = 0;
			return buf_[index_++];
		}

		public int Int() => int.Parse(Next());
		public long Long() => long.Parse(Next());
		public double Double() => double.Parse(Next());

		public int[] ArrayInt(int N, int add = 0)
		{
			int[] Array = new int[N];
			for (int i = 0; i < N; i++) {
				Array[i] = Int() + add;
			}
			return Array;
		}

		public long[] ArrayLong(int N, long add = 0)
		{
			long[] Array = new long[N];
			for (int i = 0; i < N; i++) {
				Array[i] = Long() + add;
			}
			return Array;
		}

		public double[] ArrayDouble(int N, double add = 0)
		{
			double[] Array = new double[N];
			for (int i = 0; i < N; i++) {
				Array[i] = Double() + add;
			}
			return Array;
		}

		public void Save(string text)
		{
			if (string.IsNullOrWhiteSpace(filePath_)) {
				return;
			}

			File.WriteAllText(filePath_ + "_output.txt", text);
		}
	}
}

Measured memory_bytes: 13268
#include <bits/stdc++.h>
using namespace std;
int main() {
	double i = 0;
	double l;
	int flg=0;
	string S;
	cin >> S;
	l = S.size();
        while((i + 4) < l) {
		flg = 0;
		if (S.at(i) == 'd') {
			if (S.at(i+1) != 'r') break;
			if (S.at(i+2) != 'e') break;
			if (S.at(i+3) != 'a') break;
			if (S.at(i+4) != 'm') break;
			flg = 1;
			if((i + 6) < l) {
				if(S.at(i+5) == 'e' && S.at(i+6) == 'r') {
					if((i + 9) < l) {
						if (S.at(i+7) == 'a' && S.at(i+8) == 's'&& S.at(i+9) == 'e') {
							i+=5;
						}
						else {
							i+=7;
						}
					}
					else {
						i+=7;
					}
				}
				else {
					i+=5;
				}
			}
			else {
				i+=5;
			}
		}
		else if (S.at(i) == 'e') {
			if (S.at(i+1) != 'r') break;
			if (S.at(i+2) != 'a') break;
			if (S.at(i+3) != 's') break;
			if (S.at(i+4) != 'e') break;
			flg = 1;
			if((i + 5) < l) {
				if(S.at(i+5) == 'r') {
					i+=6;
				}
				else {
					i+=5;
				}
			}
			else {
				i+=5;
			}
		}
		else {
			break;
		}
	}
	if(i == l && flg == 1) {
		cout << "YES" << endl;
	}
	else {
		cout << "NO" << endl;
	}
	return 0;
}


Measured memory_bytes: 512
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
using namespace std;
typedef long long int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

int N, K;
string S;

int a[100010] = {};
int b[100010] = {};

int c = 0, d = 0;

bool last;

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

	if (S[0] == '1')
	{
		a[0]++;
	}

	if (S[0] == '0')
	{
		c++;

		b[0]++;
	}

	for (int i = 1; i < N; i++)
	{
		if (S[i] == '1')
		{
			if (S[i - 1] == '0')
			{
				d++;
			}
			a[c]++;
		}

		if (S[i] == '0')
		{
			if (S[i - 1] == '1')
			{
				c++;
			}
			b[d]++;
		}
	}

	int cnt1 = 0, cnt0 = 0;

	if (S[0] == '1')
	{
		cnt1++;
	}
	if (S[0] == '0')
	{
		cnt1++;
		cnt0++;
	}

	for (int i = 1; i < N; i++)
	{
		if (S[i] != S[i - 1])
		{
			if (S[i] == '1')
			{
				cnt1++;
			}
			else
			{
				cnt0++;
			}
		}
	}

	if (S[N - 1] == '0')
	{
		cnt1++;
	}

	//終わったときcは

	int ans = 0, tmp = 0;

	for (int j = 0; j < cnt1 - K; j++)
	{
		tmp = 0;
		//K回繰り返す
		for (int i = 0; i < K; i++)
		{
			tmp += a[i + j] + b[i + j];
		}
		tmp += a[K + j];
		//ここまでで数測る
		ans = max(ans, tmp);
	}

	if (N == 1)
	{
		if (S[0] == '0')
		{
			cout << 0 << endl;
			return 0;
		}
		else
		{
			cout << 1 << endl;
			return 0;
		}
	}

	if (cnt0 <= K)
	{
		cout << N << endl;
		return 0;
	}

	cout << ans << endl;
}

Measured memory_bytes: 896
#include <bits/stdc++.h>
using namespace std;
 
#define ll long long 
#define inf 0x3f3f3f3f
#define infll 0x3f3f3f3f3f3f3f3f
#define all(x) (x).begin(),(x).end()
#define pb push_back

#define F_OR(i, a, b, s) for (int i=(a); (s)>0?i<(b):i>(b); i+=(s))
#define F_OR1(e) F_OR(i, 0, e, 1)
#define F_OR2(i, e) F_OR(i, 0, e, 1)
#define F_OR3(i, b, e) F_OR(i, b, e, 1)
#define F_OR4(i, b, e, s) F_OR(i, b, e, s)
#define GET5(a, b, c, d, e, ...) e
#define F_ORC(...) GET5(__VA_ARGS__, F_OR4, F_OR3, F_OR2, F_OR1)
#define FOR(...) F_ORC(__VA_ARGS__)(__VA_ARGS__)
#define EACH(x, a) for (auto& x: a)
 
// debug templates 
#define debug(x)       cerr<< #x <<" : "<< x << endl;
#define debuga(A,N)    cerr<< #A <<" : [";for(int i = 0; i<N;i++) cerr<<A[i]<<" "; cerr<<"]\n";
#define debuga2(A,N,M) cerr<< #A << " : \n"; for(int i=0;i<N;i++){cerr<<"[";for(int j=0;j<M;++j) cerr<<A[i][j]<<" ";cerr<<"]\n";}
#define debugp(p)      cerr<< #p <<" : "<<"("<<(p).first<<","<<(p).second<<")\n";
#define debugv(v)      cerr<< #v <<" : "<<"[";for(int i = 0; i< (v).size(); i++) cerr<<v[i]<<" "; cerr<<"]\n";
#define debugv2(v)     cerr<< #v << " : \n"; for(int i=0;i<v.size();i++){cerr<<"[";for(int j=0;j<(v[0].size());++j) cerr<<v[i][j]<<" ";cerr<<"]\n";}
#define debugs(m)      cerr<< #m <<" : [ "; for(auto itr = m.begin(); itr!=m.end();itr++) cerr<<*itr<<" "; cerr<<"]\n";
#define debugm(m)      cerr<< #m <<" : [ "; for(auto itr = m.begin();itr!=m.end(); itr++) cerr<<"("<<itr->first<<","<<itr->second<<") ";cerr<<"]\n";
 

void solve(){
	int l,r,d, ans = 0; cin >> l >> r >> d;
	FOR(i,l,r+1) if(i%d==0) ++ans;
	cout << ans;
}
 
int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	
	solve();
	return 0;
}
 


Measured memory_bytes: 3616
#include <stdio.h>
#define MIN -1e9

int Maxmum(int a,int b){
    return ( (a>b) ? a : b );
}

int Minimum(int a,int b){
    return ((a<b) ? a : b); 
}
int main(){
    int t;
    scanf("%d",&t);
    int maxtmp,mintmp;
    int r[t];
    for(int i=0; i<t; i++) scanf("%d",&r[i]);

    mintmp = r[0];
    maxtmp = MIN;

    for(int i=1; i<t; i++){
        maxtmp = Maxmum(maxtmp,r[i]-mintmp);
        mintmp = Minimum(mintmp,r[i]);
    }

    printf("%d\n",maxtmp);

    return 0;
}


Measured memory_bytes: 3516
s = list(x for x in input())
if s[0] != 'A':
  print('WA')
else:
  if 'C' not in s[2:-1]:
    print('WA')
  else:
    count = 0
    for i in range(len(s)):
      if s[i].isupper():
        count += 1
    if count != 2:
      print('WA')
    else:
      print('AC')

Measured memory_bytes: 3060
#include <iostream>
#include <stdio.h>
using namespace std;

int main(void)
{
	int N, K;
	cin >> N >> K;
	double pro_time_N = 0.0;
	for (int i = 1; i <= N; i++) {
		double tmp_pro = 1.0;
		int dice = i;
		while (dice < K) {
			tmp_pro /= 2;
			dice *= 2;
		}
		pro_time_N += tmp_pro;
	}
	double ans_pro = pro_time_N / N;
	printf("%.10f\n",ans_pro);

	return 0;
}

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

int main() {
    int N;
    cin >>N;
    vector<string>s(110);
    for(int i=0;i<N;i++)
      cin>>s[i];
    int M;
    cin>>M;
    vector<string>t(110);
    for(int i=0;i<M;i++)
      cin>>t[i];
  
    int maxi=max(N,M);
    int ans=0;
  
    for(int i=0;i<N;i++){
      int cnt=0;
      for(int j=0;j<maxi;j++){
        if(s[i]==s[j])
          cnt++;
        if(s[i]==t[j])
          cnt--;
      }
      ans=max(ans,cnt);
    }
      
    cout<<ans<<endl;         
}


Measured memory_bytes: 256