akhauriyash/Code-Regression huggingface dataset:
// This amazing code is by Eric Sunli Chen.
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstring>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <utility>
#include <vector>
using namespace std;
template<typename T> void get_int(T &x)
{
	char t=getchar();
	bool neg=false;
	x=0;
	for(; (t>'9'||t<'0')&&t!='-'; t=getchar());
	if(t=='-')neg=true,t=getchar();
	for(; t<='9'&&t>='0'; t=getchar())x=x*10+t-'0';
	if(neg)x=-x;
}
template<typename T> void print_int(T x)
{
	if(x<0)putchar('-'),x=-x;
	short a[20]= {},sz=0;
	while(x>0)a[sz++]=x%10,x/=10;
	if(sz==0)putchar('0');
	for(int i=sz-1; i>=0; i--)putchar('0'+a[i]);
}
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define get1(a) get_int(a)
#define get2(a,b) get1(a),get1(b)
#define get3(a,b,c) get1(a),get2(b,c)
#define printendl(a) print_int(a),puts("")
typedef long long LL;
typedef unsigned long long uLL;
typedef pair<int,int> pii;
const int inf=0x3f3f3f3f;
const LL Linf=1ll<<61;
const double pi=acos(-1.0);

string s;
int main()
{
	cin>>s;
	if(s.size()>=4&&s.substr(0,4)=="YAKI")puts("Yes");
	else puts("No");
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include <cstdlib>
#include<cctype>
#include <algorithm>    
using namespace std;
typedef long long ll;
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
#define VCOUT(num) for(auto& num:vec)
#define GET_ARRAY_SIZE(a) (sizeof(a)/sizeof(a[0]))
#define LLINF 1000000000000000000//10^18
#define INF 1000000000000 //10^12
#define MOD 1000000007 //10^9+7:合同式の法
#define MAXR 100000
#define MAX 100
#define MX 10

//int main(int argc, char const* argv[]){

int main(){ 
    vector<int>vec;
     vector<char>cvec;
      vector<string>svec;
    
   int a,b,x,y,z,count=0;
  
   char c;
   cin>>x;
   cin>>y;
  
   
    
  
  
  cout<<x*y<<" "<<2*(x+y)<<endl;
    return 0;
}




Measured memory_bytes: 3064
// http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=DPL_1_C&lang=jp
// Combinatorial - Knapsack Problem

// 個数制限なしナップサック
// References:
// https://mt-caret.github.io/blog/posts/2017-08-14-unlimited-napsack-problem.html
// https://qiita.com/drken/items/ace3142967c4f01d42e9

#define SUBMIT

#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>

using namespace std;
using ui64 = unsigned long long;
using i64 = long long;

int main() {
#ifdef SUBMIT
    int N, W;
    cin >> N >> W;
    vector<int> v(N);
    vector<int> w(N);
    for (int i = 0; i < N; ++i) {
        cin >> v[i] >> w[i];
    }
#else
    int N = 4, W = 8;
    vector<int> v{4, 5, 2, 8};
    vector<int> w{2, 2, 1, 3};
#endif

    int dp[W + 1];
    for (int j = 0; j < W + 1; ++j) {
        dp[j] = 0;
    }

    for (int i = 0; i < N; ++i) {
        for (int j = 0; j < W + 1; ++j) {
            if (j >= w[i]) {
                dp[j] = max(dp[j], dp[j - w[i]] + v[i]);
            }
        }
    }

    cout << dp[W] << endl;
    return 0;
}


Measured memory_bytes: 3140
import sys
n = int(input())
s_ls = []
t_ls = []
for i in range(n):
    s, t = [i for i in sys.stdin.readline().split()]
    t = int(t)
    s_ls.append(s)
    t_ls.append(t)
x = input()
print(sum(t_ls[s_ls.index(x)+1:]))

Measured memory_bytes: 3060
# include <iostream>
# include <algorithm>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <utility>
# include <stack>
# include <queue>
# include <list>
constexpr int MOD = 1000000000 + 7;
constexpr int INF = 2000000000;
using namespace std;

int main() {
	long long n, a, b, c, d;
	cin >> n >> a >> b >> c >> d;
	bool BOOL = false;
	for (int m = 0; m < n; m++) {
		if ((n - m - 1)*c - m*d <= abs(a - b) && abs(a - b) <= (n - m - 1)*d - m*c)BOOL = true;
	}
	cout<<(BOOL ? "YES" : "NO") << endl;
}

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

#define sqr(x)  ((x) * (x))
#define sqr2(x)  ((x) * (x) * (x))

int main(void)
{
  int n;
  int x[1001] = {0};
  int y[1001] = {0};
  int i;
  int sum1 = 0;
  int sum2 = 0;
  long double sum3 = 0;
  int summ = 0;
  double D1 = 0;
  double D2 = 0;
  double D3 = 0;
  double Dm = 0;

  scanf("%d", &n);
  
  for(i = 0; i < n; i++)
    scanf("%d", &x[i]);

  for(i = 0; i < n; i++)
    scanf("%d", &y[i]);

  for(i = 0; i < n; i++){
    if(x[i] > y[i]){
    sum1 += x[i] - y[i];
    sum2 += sqr(x[i] - y[i]);
    sum3 += (long double)(sqr2(x[i] - y[i]));
    if(summ < x[i] - y[i])
	summ = x[i] - y[i];
    }
    else{
      sum1 += y[i] - x[i];
      sum2 += sqr(y[i] - x[i]);
      sum3 += (long double)(sqr2(y[i] - x[i]));
      if(summ < y[i] - x[i])
	summ = y[i] - x[i];
    }
  }
    
  D1 = (double)(sum1);
  D2 = sqrt((double)(sum2));
  D3 = (double)(cbrtl(sum3));
  Dm = (double)(summ);

  printf("%f\n%f\n%f\n%f\n", D1, D2, D3, Dm);

  return 0;
}

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

int main() {
	ios_base::sync_with_stdio(0);cin.tie(0);
	string a[3];
	const char w[3]={'A','B','C'};
	cin>>a[0]>>a[1]>>a[2];
	for(int i=0;i<3;++i){
		reverse(a[i].begin(),a[i].end());
		transform(a[i].begin(),a[i].end(),a[i].begin(),::toupper);
	}
	int c=0;
	while(true){
		if(a[c].empty()){
			cout<<w[c]<<'\n';
			return 0;
		}
		int x=a[c].back()-'A';
		a[c].pop_back();
		c=x;
	}
}




Measured memory_bytes: 3616
#include <stdio.h>

int main(){
	
	int m,n;
	int i,j;
	int str[21][21];
	int max=-1;
	int tmp=0;
	
	scanf("%d %d",&m,&n);
	for(j=0;j<m;j++){
		for(i=0;i<n;i++){
			scanf("%d ",&str[i][j]);
		}
	}
	for(j=0;j<m;j++){
		for(i=0;i<n;i++){
			tmp += str[i][j];
		}
		if(tmp>max) max = tmp;
		tmp = 0;
	}
	printf("%d\n",max);
	
	return 0;
}

Measured memory_bytes: 604
#include <iostream>

using namespace std;

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

    int M = (N-1) * (N-1);
    M = M >> 1;

    cout << M << endl;
    for (int i=1; i <= N; ++i) {
        for (int j=i+1; j <= N; ++j) {
            if (j != N-i + !(N%2))
                cout << i << " " << j << endl;
        }        
    }

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <vector>
#include <numeric>
#define PI 3.14159265358979323846
#define MAXINF (1e18L)
#define INF (1e9L)
#define EPS (1e-9)
#define MOD (1'000'000'007)
#define REP(i, n) for(int i=0;i<int(n);++i)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define ALL(v) v.begin(),v.end()
#define FIND(v,x) (binary_search(ALL(v),(x)))
#define SORT(v) sort(ALL(v))
#define RSORT(v) sort(ALL(v));reverse(ALL(v))
#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl
#define Yes(n) cout<<((n)?"Yes":"No")<<endl
#define YES(n) cout<<((n)?"YES":"NO")<<endl
#define pb push_back
#define fi first
#define se second
using namespace std;
template<class A>void pr(A a){cout << (a) << endl;}
template<class A,class B>void pr(A a,B b){cout << a << " "  ;pr(b);}
template<class A,class B,class C>void pr(A a,B b,C c){cout << a << " " ;pr(b,c);}
template<class A,class B,class C,class D>void pr(A a,B b,C c,D d){cout << a << " " ;pr(b,c,d);}
typedef long long ll;
typedef pair<int, int> pii;

vector<vector<int>> graph;
vector<int> color;

bool dfs(int c, int p){
    color[p]=c;
    for(int cc : graph[p]){
        if(color[cc]==c) return false;
        if(color[cc]==0) if(!dfs(-c, cc)) return false;
    }    
    return true;
}

int main(void)
{
    int n,m;
    cin >> n >> m;
    graph.resize(n, vector<int>());
	color.resize(n, 0);
    REP(i, m){
        int a,b;
        cin >> a >> b;
        a--;b--;
        graph[a].pb(b);
        graph[b].pb(a);
    }

    ll ans=0;
    if(dfs(1,0)){
        ll w=0;
        REP(i, n){
            if(color[i]==1) w++;
        }
        ans = w * (n-w) - m; 
    }else{
        ans = (ll)n*(n-1)/2 - m;
    }

    pr(ans);
}

Measured memory_bytes: 6528
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
const int mod=1e9+7;

char math[55][55];
int dy[4]={0,0,1,-1};
int dx[4]={1,-1,0,0};
int h,w;

//BFS
int bfs(pair<int,int> s,pair<int,int> g){
    queue<pair<int,int>> que;
    map<pair<int,int>,int> depth;
    map<pair<int,int>,bool> seen;
    que.push(s);
    depth[s]=0;
    bool end = false;
    int ans = -1;
 
    while(!que.empty()){
        pair<int,int> nw = que.front(); que.pop();
        for(int i = 0; i < 4; i++){
            if(0 <= nw.first+dy[i] && nw.first+dy[i] < h && 0 <= nw.second+dx[i] && nw.second+dx[i] < w){
                pair<int,int> nxt = make_pair(nw.first+dy[i],nw.second+dx[i]);
                if((!seen[nxt]) && math[nxt.first][nxt.second] != '#'){
                    que.push(nxt);
                    seen[nxt] = true;
                    depth[nxt] = depth[nw]+1;
                    if(nxt == g){
                        ans = depth[nxt];
                        end = true;
                        break;
                    }
                }
            }
        }
        if(end) break;
    }
    if(ans == -1) return -1;
    return ans;
}


int main(){
    
    cin >> h >> w;
    pair<int,int> s = make_pair(0,0);
    pair<int,int> g = make_pair(h-1,w-1);
    int cnt = 0;

    for(int i = 0; i < h; i++){
        for(int j = 0; j < w; j++){
            cin >> math[i][j];
            if(math[i][j] == '#') cnt++;
        }
    }

    int time = bfs(s,g);
    if(time == -1) cout << -1 << endl;
    else cout << h*w-time-1-cnt << endl;
}

Measured memory_bytes: 512
#include <cstdio>
#include <algorithm>

using namespace std;

const int BIT_SIZE = 110000;
 
int bit[BIT_SIZE + 1];
void add(int pos, int val)
{
  for (pos += 1; pos <= BIT_SIZE; pos += pos & -pos) {
    bit[pos] += val;
  }
}
 
int get_sum(int pos)
{
  int ret = 0;
  for (pos += 1; pos; pos -= pos & -pos) {
    ret += bit[pos];
  }
  return ret;
}

pair<int, int> s[100001];
bool greater_than_or_equal_to(int m, int *a, int N)
{
  fill(bit, bit + BIT_SIZE + 1, 0);
  int tmp = 0;
  s[0] = make_pair(0, 0);
  for (int i = 1; i <= N; i++) {
    tmp += (a[i - 1] <= m ? 1 : -1);
    s[i] = make_pair(tmp, i);
  }
  sort(s, s + N + 1);
  
  long long tot = 0;
  for (int i = 0; i <= N;) {
    int j = i;
    while (j <= N && s[i].first == s[j].first) {
        tot += get_sum(s[j].second);
        j++;
    }
    while (i < j) {
        add(s[i].second, 1);
        i++;
    }
  }
  return tot >= (long long)N * (N + 1) / 4 + 1;
}

int main()
{
  int N;
  int a[100000];
  
  scanf("%d", &N);
  
  for (int i = 0; i < N; i++) {
    scanf("%d", a + i);
  }
  
  int l = 1, r = 1000000000;
  
  while (l != r) {
    int m = (l + r) / 2;
    if (greater_than_or_equal_to(m, a, N)) r = m;
    else l = m + 1;
  }
  
  printf("%d\n", l);
  
  return 0;
}

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

using namespace std;

int main() {

	// freopen("input.txt", "r", stdin);
	// freopen("output.txt", "w", stdout);

	long long x;
	cin >> x;
	for (int a = -1000; a <= 1000; ++a) {
		for (int b = -1000; b <= 1000; ++b) {
			if (powl(a, 5) - powl(b, 5) == x) {
				cout << a << ' ' << b << '\n';
				return 0;
			}
		}
	}
	return 0;
}

Measured memory_bytes: 3652
#include<iostream>
#include<vector>
#include<algorithm>
#include<functional>
#include<queue>
#include<stack>
#include<set>
#include<climits>
#include<cstdlib>
#include<cmath>
#include<string>

using namespace std;

#define INF 1 << 29
#define LL long long int

LL const MOD = 1000000007;

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

    LL N;
    LL L;
    cin >> N >> L;

    vector<LL> a(N);

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

    LL ind = 0;
    LL max = 0;

    for(int i = 1; i < N; i++){
        if(a[i]+a[i-1] > max){
            max = a[i]+a[i-1];
            ind = i;
        }
    }

    if(max >= L){
        cout << "Possible" << endl;
        for(int i = 1; i < ind; i++){
            cout << i << endl;
        }
        for(int i = N-1; i > ind; i--){
            cout << i << endl;
        }
        cout << ind << endl;
    }else{
        cout << "Impossible" << endl;
    }
    
    return 0;
}

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

using namespace std;

const int maxn = 102;
const int maxk = 100010;
int N, K;
int nums[maxn];
const int mod = 1000000007;
int dp[2][maxk];

void add(int &a, int b) {
	a = (a+b)%mod;
}

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cin >> N >> K;
	for (int i = 1; i <= N; i++) {
		cin >> nums[i];
	}
	dp[0][0] = 1;
	int cur = 0;
	int prev = 1;
	for (int i = 1; i <= N; i++) {
		swap(prev, cur);
		int csum = 0;
		for (int j = 0; j <= K; j++) {
			dp[cur][j] = 0;
			add(csum, dp[prev][j]);
			if (j > nums[i]) {
				csum = csum - dp[prev][j-nums[i]-1];
				add(csum, mod);

			}
			dp[cur][j] = csum;
			// cout << i << " " << j << " : " << dp[cur][j] << endl;
		}
	}

	cout << dp[cur][K] << endl;

}

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


int main()
{
int n,x,y;
cin >> n >> x >> y;
x--;
y--;
vector <int> a(n);

for (int i=0; i<n; i++)
    for (int j=i+1; j<n; j++)
    {
        int mn = min( j-i, abs(i-x) + 1 + abs(j-y));
        a[mn-1]++;
    }
for (int i=0; i<n-1; i++)
    cout << a[i] << "\n";
}




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

#define REP(i,s,n) for(int i=s;i<n;++i)
#define rep(i,n) REP(i,0,n)
#define ALL(x) x.begin(),x.end()
#define EPS (1e-8)
#define equals(a,b) (fabs((a)-(b))<EPS)

using namespace std;

typedef long long ll;
typedef pair<int,int> ii;

inline bool LT(double a,double b) { return !equals(a,b) && a < b; }
inline bool LTE(double a,double b) { return equals(a,b) || a < b; }

void compute() {

}

bool ok(string &s,int sp,int dir) {
  while( ( 0 <= sp && sp < (int)s.size()) && s[sp] != '.' ) {
    if( s[sp] == 'B') return false;
    sp += dir;
  }
  return true;
}

int main() {
  int n;
  cin >> n;
  string s;
  cin >> s;
  int maxi = 0;
  REP(i,1,n) {
    if( s[i] == 'B' ) {
      int j = i;
      while( j < n && s[j] == 'B' ) {
	++j;
      }
      int len = j - i;
      if( s[i-1] == 'W' || ( j < n && s[j] == 'W' ) ) {
	if( s[i-1] == 'W' ) {
	  if( !ok(s,i-1,-1) ) goto Skip;
	  if( j < n && s[j] == 'W' ) {
	    if( ok(s,j,+1) ) {
	      maxi = max(maxi,len);
	    }
	  } else if( j < n && s[j] == '.' ) {
	    if( j + 1 >= n || s[j + 1] != 'B' ) {
	      if( ok(s,j+1,+1) ) {
		maxi = max(maxi,len);
	      }
	    }
	  }
	} else {
	  if( !ok(s,j,+1) ) goto Skip;
	  if( s[i-1] == 'W' ) {
	    if( ok(s,i-1,-1) ) {
	      maxi = max(maxi,len);
	    }
	  } else if( s[i-1] == '.' ) {
	    if( i - 2 < 0 || s[i - 2] != 'B' ) {
	      if( ok(s,i-2,-1) ) {
		maxi = max(maxi,len);
	      }
	    }
	  }
	}
      }
    Skip:;
      i = j - 1;
    }
  }
  cout << maxi << endl;
  compute();
  return 0;
}



Measured memory_bytes: 3212
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<map>
#include<set>
#include<unordered_map>
#include<unordered_set>
#include<list>
#include<queue>
#include<functional>
#include<limits.h>
#include<string.h>
#include<algorithm>
using namespace std;

signed main() {
	string a; cin >> a;
	if (a[0] == 'A') {
		for (int i = 2; i < a.length() - 1; i++) {
			if (a[i] == 'C')break;
			if (i == a.length() - 2)goto l;
		}
		sort(a.begin(), a.end());
		if (a[2] >= 'a') { puts("AC"); return 0; }
	l:;
	}
	puts("WA");
}

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

int main() {
    int n;
    cin >> n;
    while (n--) {
        string a[2];
        cin >> a[0] >> a[1];
        if (a[0].length() > 80 || a[1].length() > 80) {
            cout << "overflow" << endl;
            continue;
        }
        while (a[0].length() < a[1].length()) {
            a[0].insert(0, 1, '0');
        }
        while (a[0].length() > a[1].length()) {
            a[1].insert(0, 1, '0');
        }
        int carry = 0;
        string sum;
        string::reverse_iterator rit[2];
        for (rit[0] = a[0].rbegin(), rit[1] = a[1].rbegin(); rit[0] != a[0].rend(); rit[0]++, rit[1]++) {
            int s = *rit[0] - '0' + *rit[1] - '0' + carry;
            carry = s / 10;
            s %= 10;
            sum.insert(0, 1, s + '0');
        }
        if (carry > 0) {
            sum.insert(0, 1, carry + '0');
        }
        if (sum.length() > 80) {
            cout << "overflow" << endl;
        } else {
            cout << sum << endl;
        }
    }
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#define Int int64_t

using namespace std;

int main() {
	long double PI = acos(-1);
	long double A, B, H, M;
	cin >> A >> B >> H >> M;

	long double x = 0.5 * (60 * H + M);
	while (x >= 360) { x -= 360; }
	long double y = 6 * M;
	long double z = abs(x - y);
	if (z > 180) { z = 360 - z; }
	z = z / 180.0 * PI;

	long double ans2 = A*A + B*B - 2.0*A*B*cos(z);
	cout.precision(15);
	cout << sqrt(ans2) << endl;

	return 0;
}


Measured memory_bytes: 4168
#include<cstring>
#include<string>
#include<vector>
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<stack>
#include<queue>
#include<cmath>
#include<algorithm>
#include<list>
#include<set>
#include<map>
#include<complex>
#include<sstream>
#include<climits>

#define rep(X,Y) for (int (X) = 0;(X) < (Y);++(X))
#define all(X) (X).begin(),(X).end()
#define fi first
#define sc second
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

string s, t;

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

  for (int i = 0; i < s.length(); ++i) {
    string test = s.substr(i, s.length()-i) + s.substr(0, i);
    if (test == t) {
      cout << "Yes" << endl;
      return 0;
    }
  }

  cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <map>
#include <queue>
#include <iomanip>
#include <set>
#include <tuple>
#define mkp make_pair
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
const ll MOD=1e9+7;

int main(){
  int M,D;
  cin>>M>>D;

  int ans=0;
  for(int i=1;i<=M;i++){
    for(int j=1;j<=D;j++){
      int d1=j/10;
      int d2=j%10;
      if(d1>=2&&d2>=2&&d1*d2==i) ans++;
    }
  }

  cout<<ans<<endl;

  return 0;
}


Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
template<typename T> bool chmax(T &a,T b){if(a<b){a=b;return true;}return false;}
template<typename T> bool chmin(T &a,T b){if(a>b){a=b;return true;}return false;}
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(vec) vec.begin(),vec.end()
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> pll;
typedef pair<int,int> pii;
typedef tuple<ll,ll,ll> tlll;
typedef tuple<int,int,int> tiii;
const ll mod=1e9+7;
const int inf=1<<30;

int main(){
  int n,k; cin >> n >> k;
  vector<int> p(n);
  rep(i,n) cin >> p[i];
  sort(all(p));
  ll ans=0;
  rep(i,k){
    ans+=p[i];
  }
  cout << ans << endl;
  
}

Measured memory_bytes: 3692
#include <iostream> // cin, cout, cerr
#include <algorithm> // minmax, sort, swap
#include <numeric> // iota
#include <cstdio> // printf, scanf
#include <string> // string, stoi, to_string
#include <vector> // vector
#include <queue> // queue, priority_queue
#include <deque> // deque
#include <map> // key-value pairs sorted by keys
#include <set> // set
#include <iomanip> // cout<<setprecision(n)
#include <functional> // function<void(int)>

#ifdef DEBUG
#include "debug.hpp"
#else
#define dump(...)
#endif

#define rep(i,n) for(int i = 0; i < (n); i++)
#define ENDL '\n'
#define print(i) std::cout << (i) << '\n'

#define int long long // at least int64 > 9*10^18
#define all(v) (v).begin(), (v).end()
/* libraries */

signed main() {
	int n;
	std::cin >> n;
	std::vector<int> a(3*n);
	rep(i,3*n) std::cin >> a[i];
	std::vector<int> ldp(n+1);
	int lsum = 0;
	{
		std::priority_queue<int,std::vector<int>, std::greater<int>> que;
		rep(i,n) {
			lsum+=a[i];
			que.emplace(a[i]);
		}
		ldp[0] = lsum;
		for(int i=1;i<=n;i++) {
			que.emplace(a[n-1+i]);
			lsum += a[n-1+i];
			lsum -= que.top();
			que.pop();
			ldp[i] = lsum;
		}
	}

	std::vector<int> rdp(n+1);
	int rsum = 0;
	{
		std::priority_queue<int> que;
		rep(i,n) {
			rsum+=a[2*n+i];
			que.emplace(a[2*n+i]);
		}
		rdp[n] = rsum;
		for(int i=1;i<=n;i++) {
			que.emplace(a[2*n-i]);
			rsum += a[2*n-i];
			rsum -= que.top();
			que.pop();
			rdp[n-i] = rsum;
		}
	}

	dump(ldp,rdp);
	const int INF = 1e15;
	int max = -INF;
	rep(i,n+1) {
		max = std::max(max,ldp[i]-rdp[i]);
	}
	print(max);
	return 0;
}


Measured memory_bytes: 5992
#include <bits/stdc++.h>
#include<iostream>
#include <ctype.h>
#include <sstream>
using namespace std;
using Graph = vector<vector<int>>;
#define  itn int
using ll=int64_t;
#define rep(i,n) for (int i = 0; i < (int) (n); i++)
using vi = vector<int>;
using vll = vector<ll>;
//GCD
long long gcd(long long a, long long b)
{if(a<b) swap(a,b);
   if (a%b == 0){return(b);}
   else{return(gcd(b, a%b));}
}
//lcm
long long lcm(long long a, long long b)
{return a * b / gcd(a, b);}

long long bikkuri(long long k){
    long long sum = 1;
    for (long long i = 1; i <= k; ++i)
    {
        sum *= i;
    }
    return sum;
}
int main() {
ll n;
cin>>n;
string ans = "";
while(n>0){n--;ans+=char('a'+n%26);n/=26;}
reverse(ans.begin(),ans.end());
cout<<ans;

}


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

string S;

bool canGo(int start, int goal) {
  bool rock = false;
  for (int i = start; i < goal; i++)
  {
    if (rock and S[i] == '#') return false;
    if (S[i] == '#') rock = true;
    else rock = false;
  }
  return true;
}

bool canJump(int start, int goal) {
  for (int i = start - 1; i < goal; i++)
  {
    if (S[i] == '.' and S[i + 1] == '.' and S[i + 2] == '.') return true;
  }
  return false;
}

int main()
{
  int N, A, B, C, D; cin >> N >> A >> B >> C >> D;
  A--; B--; C--; D--;
  cin >> S;
  bool ans;

  if (!canGo(A, C) or !canGo(B, D)) ans = false;
  else if (A < B and D < C) ans = canJump(B, D);
  else if (B < A and C < D) ans = canJump(A, C);
  else ans = true;

  if (ans) cout << "Yes" << endl;
  else cout << "No" << endl;
}

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

#define REP(i,num) for(int i=0;i<(num);++i)
#define ALL(c) c.begin(),c.end()
#define PRINTALL(c) for(auto& x:c){cout<<x<<' ';}cout<<endl;
#define PAIRCOMP(c,comp) [](const pair<ll,ll>& lhs,const pair<ll,ll>& rhs){return lhs.c comp rhs.c;}

constexpr int atcoder_mod = 1e9+7;

using namespace std;
using ll = long long;

template<typename T=int>
T in(){T x; cin >> x; return (x);}
template<typename T=int,typename C=vector<T>>
C vecin(int N){C x(N);REP(i,N){x[i]=in<T>();}return move(x);}

void vout(){cout << endl;}
template<typename Head,typename... Tail>
void vout(Head&& h,Tail&&... t){cout << ' ' << h;vout(forward<Tail>(t)...);}
void out(){cout << endl;}
template<typename Head,typename... Tail>
void out(Head&& h,Tail&&... t){cout << h;vout(forward<Tail>(t)...);}

class Dice{
public:
	array<int,6> F;
	void Roll(char ch){
		int temp;
		switch(ch){
		case 'W':
			temp = F[0];
			F[0] = F[2];
			F[2] = F[5];
			F[5] = F[3];
			F[3] = temp;
			break;
		case 'E':
			temp = F[0];
			F[0] = F[3];
			F[3] = F[5];
			F[5] = F[2];
			F[2] = temp;
			break;
		case 'N':
			temp = F[0];
			F[0] = F[1];
			F[1] = F[5];
			F[5] = F[4];
			F[4] = temp;
			break;
		default:
			temp = F[0];
			F[0] = F[4];
			F[4] = F[5];
			F[5] = F[1];
			F[1] = temp;
		}
	}
};

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

	auto X=vecin(6);
	Dice D;
	REP(i,6){
		D.F[i] = X[i];
	}
	string S=in<string>();
	REP(i,S.size()){
		D.Roll(S[i]);
	}
	out(D.F[0]);

	return 0;
}



Measured memory_bytes: 3196
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define int long long
using namespace std;
string s;
int a[26];
signed main(){
	cin>>s;
	rep(i,s.size()){
		a[s[i]-'a']++;
	}
	rep(i,26){
		if(a[i]%2){
			puts("No");
			return 0;
		}
	}
	puts("Yes");
}


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

ll powll(ll a,ll n){
  if(n==0)
  {
    return 1;
  }
  return powll(a,n-1)*a;
}

int main() {
   ll i,j,k;
    ll a,b;
    cin >> a>>b;
    for(i=1; i<=1250; i++)
    {
      if(ll(i*0.08)==a && ll(i*0.10)==b)
      {
        cout << i << endl;
        return 0;
      }
      // cout<<i<<' '<<ll(i*0.08)<<' '<<ll(i*0.10)<<endl;
    }
  cout << -1 << endl;
}


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

int main() {
  int h, w;
  cin >> h >> w;

  vector<string> board(h);
  rep(i, h)
  {
    cin >> board.at(i);
  }

  vector<bool> row(h, false);
  vector<bool> col(w, false);

  rep(i, h)
  {
    rep(j, w)
    {
      if(board.at(i).at(j) == '#')
      {
        row.at(i) = true;
        col.at(j) = true;
      }
    }
  }

  rep(i, h)
  {
    if(row.at(i))
    {
      rep(j, w)
      {
        if(col.at(j))
        {
          cout << board.at(i).at(j);
        }
      }
      cout << endl;
    }
  }

}


Measured memory_bytes: 3616
#include<bits/stdc++.h>
#include<iostream>
#include<cstdio>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
using namespace std;
#define rep(i,x) for(int i = 0; i < x; i++)
#define pb push_back
#define mp make_pair
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<ll,ll> Pll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<vector<vector<int>>> vvvi;
const ll MOD = 1e9+7;
const int n_max = 1e5+10;

int main(){
    ld a;cin >> a;
    cout <<fixed << setprecision(15)<< ceil(a/2)/a << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll INF = ll(1e9) + 1;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define reps(i, n) for(int i = 1; i <= (int)(n); i++)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

int main()
{
  int A, B;
  cin >> A >> B;

  int ans = -1;
  for (int i = 1; i <= 1000; ++i) {
    if (floor(i * 0.08) == A && floor(i * 0.1) == B) {
      ans = i;
      break;
    }
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
N = int(input())
X = input()
X = X[::-1]

def count(n):
    if n==0:
        return 0
    m = 0
    for i in range(18):
        if n&2**i:
            m += 1
    n %= m
    return 1+count(n)



p1 = [1]*(N+1)
p2 = [1]*(N+1)
m = 0
for i in range(N):
    if X[i]=='1':
        m += 1

for n in range(N):
    p1[n+1] = 2*p1[n]%(m+1)
    if m!=1:
        p2[n+1] = 2*p2[n]%(m-1)

num = [0]*N
base1 = 0
base2 = 0
for i in range(N):
    if X[i]=='1':
        base1 += p1[i]
        base2 += p2[i]

ans = [0]*N
for i in range(N):
    if X[i]=='0':
        num[i] = (base1+p1[i])%(m+1)
        ans[i] += 1
    else:
        if m!=1:
            num[i] = (base2-p2[i])%(m-1)
            ans[i] += 1
        else:
            num[i] = 0



for i in range(N-1,-1,-1):
    ans[i] += count(num[i])
    print(ans[i])

Measured memory_bytes: 87028
#include <iostream>
#include <cmath>
#include <vector>
#include <map>
#include <string>
#include <iomanip>
#include <queue>
#include <algorithm>

using namespace std;
using ll = long long int;
using dd = long double;
const ll MOD = 1e9 + 7;
const dd PI = 3.1415926535;

ll fast(ll n, ll k) {
	if (k == 0) {
		return 1;
	}
	if (k == 1) {
		return n;
	}
	if (k % 2 == 0) {
		ll tmp = fast(n, k / 2);
		return tmp * tmp % MOD;
	}
	else {
		ll tmp = fast(n, k / 2);
		tmp = tmp * tmp % MOD;
		return n * tmp % MOD;
	}
}

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

	if (s == "ABC") {
		cout << "ARC" << endl;
	}
	else {
		cout << "ABC" << endl;
	}
}

Measured memory_bytes: 3628
#include<bits/stdc++.h>
using namespace std;
#define ll long long
ll dp[101][100001];
int main()
{
    ios_base::sync_with_stdio(false);cin.tie(NULL);
    ll n,w;
    cin>>n>>w;
    ll a[n+1],b[n+1];
    for(int i=1;i<=n;i++)
    {
        cin>>a[i]>>b[i];
    }
    for(int i=0;i<=n;i++)
    {
        for(int j=0;j<=100000;j++)
        {
            if(j==0)
                dp[i][j]=0;
            else
                dp[i][j]=1e18;
        }
    }
    for(int i=1;i<=n;i++)
    {
        for(int j=b[i];j<=100000;j++)
        {
            dp[i][j]=min(dp[i-1][j],a[i]+dp[i-1][j-b[i]]);
        }
        for(int j=0;j<b[i]-1;j++)
            dp[i][j]=dp[i-1][j];
    }

    ll ans=0;
    for(int i=1;i<=100000;i++)
    {
        if(dp[n][i]<=w)
            ans=i;
    }
    //cout<<dp[3][90]<<" ";
    cout<<ans;

    return 0;
}

Measured memory_bytes: 79232
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define ff first
#define ss second
#define quick                    \
    ios::sync_with_stdio(false); \
    cin.tie(0);
#define time cerr << (0.1 * clock()) / CLOCKS_PER_SEC << endl;
#define mod 1000000007
typedef long long ll;
typedef pair<ll, ll> pl;
#define forn(n) for (ll i = 0; i < ll(n); i++)

void solve() {
    string s, t;
    cin >> s;
    cin >> t;
    int n = s.length(), m = t.length();
    vector<vector<int>> v(n, vector<int>(m));
    for (int i = 0; i < n; ++i) {
        for (int j = 0; j < m; ++j) {
            v[i][j] = (s[i] == t[j]);
            if (i and j) {
                v[i][j] = (s[i] == t[j]) + v[i - 1][j - 1];
            }
            if (i) {
                v[i][j] = max(v[i][j], v[i - 1][j]);
            }
            if (j) {
                v[i][j] = max(v[i][j], v[i][j - 1]);
            }
        }
    }
    int in = n - 1, jn = m - 1;
    bool pr = true;
    string ans = "";
    // for (auto i : v) {
    //     for (auto j : i) {
    //         cout << j << " ";
    //     }
    //     cout << '\n';
    // }
    while (in >= 0 and jn >= 0) {
        // cout << in << " "/ << jn << '\n';
        if (jn) {
            if (v[in][jn] == v[in][jn - 1]) {
                jn--;
                continue;
            }
        }
        if (in) {
            if (v[in][jn] == v[in - 1][jn]) {
                in--;
                continue;
            }
        }
        if (s[in] == t[jn]) {
            ans += s[in];
            in--;
            jn--;
        } else {
            break;
        }
    }
    reverse(ans.begin(), ans.end());
    cout << ans << '\n';
}

int main() {
    quick;
    solve();
    // ll t;
    // cin >> t;
    // while (t--) {
    //     solve();
    // }
}

Measured memory_bytes: 35584
//Created by Kira

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

#define IOS cin.sync_with_stdio(0);cin.tie(0); cout.tie(0);
#define all(x) x.begin(), x.end()
#define sz(x) (int)x.size()
#define pii pair<int,int> 
#define pb push_back
#define vi vector<int> 
using ll = long long;

const int mod = 1e9 + 7;

ll pwr(ll a, ll b);
    
ll a, b, c, d; 
map<ll, ll> dp;

ll solve(ll n){
    if(n == 0)return 0;
    if(n == 1)return d;

    if(dp.count(n))return dp[n];

    ll l2 = (n/2) * 2;
    ll r2 = ((n + 1)/2) * 2;
    ll l3 = (n/3) * 3;
    ll r3 = ((n + 2)/3) * 3;
    ll l5 = (n/5) * 5;
    ll r5 = ((n + 4)/5) * 5;

    ll res = 1e18;

    if(n < res/d)res = n * d;
    res = min(res, llabs(l2 - n) * d + a + solve(l2/2));
    res = min(res, llabs(r2 - n) * d + a + solve(r2/2));

    res = min(res, llabs(l3 - n) * d + b + solve(l3/3));
    res = min(res, llabs(r3 - n) * d + b + solve(r3/3));

    res = min(res, llabs(l5 - n) * d + c + solve(l5/5));
    res = min(res, llabs(r5 - n) * d + c + solve(r5/5));

    dp[n] = res;
    return res;
}


int main(){
   IOS

   int T; cin>>T;

   while(T--){
       dp.clear();
       ll N; cin>>N;
       cin>>a>>b>>c>>d;
       cout<<solve(N)<<"\n";
   }
}

ll pwr(ll a, ll b){
   a %= mod;	//Remove mod if not required
   ll res = 1;
   while(b > 0){
    if(b&1)
        res = res * a % mod;
        a = a * a % mod;
    b >>= 1;
    }

    return res;
}



Measured memory_bytes: 4448
#include<iostream>
using namespace std;
class DigitNumber{ 
    public:
        void solve(int a,int b){
            string sum=to_string(a+b);
            if(sum=="0")cout<<0<<endl;
            else cout<<sum.length()<<endl;
        }
};
int main(){
    DigitNumber inst;
    int a,b;
    while(cin>>a>>b){ 
        inst.solve(a,b);
    }
}

Measured memory_bytes: 3180
#!/usr/bin/env python3

import sys
import math
from bisect import bisect_right as br
from bisect import bisect_left as bl
sys.setrecursionlimit(2147483647)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))

s = input()
if s[-1] != 's':
    print(s+'s')
else:
    print(s+'es')

Measured memory_bytes: 65296
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define forx(i, a, b) for (int i = (a); i < (b); i++)
#define rep(i, n) for (int i = 0; i < (n); i++)
#define caseout(i, x) cout << "Case #" << i << ": " << x << endl;

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int n;
    cin>>n;
    vector<int>b(n+1),a;
    rep(i,n)cin>>b[i+1];
    
    rep(j,n){
        int k=b.size();
        int i=k-1;
        for (; i >=0; i--){
            if(b[i]==i){
                a.push_back(i);
                b.erase(b.begin() + i);
                break;
            }
        }
        if(b[0]!=0){
            cout<<-1<<endl;
            return 0;
        }
    }
    reverse(a.begin(),a.end());
    for(auto x:a)cout<<x<<endl;

    return 0;
}

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

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
		String s = sc.next(), t = sc.next();
		
		int ans = 0;
		for (int i = 0; i < s.length(); i++) {
			if (s.charAt(i) != t.charAt(i)) ans++;
		}
		
		System.out.println(ans);
	}
}

Measured memory_bytes: 40980
#include<bits/stdc++.h>
using namespace std;
#define repeat(i, n) for(int i = 0; i < (n); i++)

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

	int itti = 0;

	repeat(i, S.length()) {
		string ugokasu;
		ugokasu = S.substr(0, 1);
		S.erase(0, 1);
		S += ugokasu; 
		if (S == T) itti = 1;
	}

	if (itti == 1) cout << "Yes" << endl;
	else cout << "No" << endl;

	return 0;
}


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

string s;

int main() {
    cin >> s;
    int n = (int)s.size();

    int a_count = 0;
    long long res = 0;
    for(int i = 0; i+1 < n; i++) {
        if(s.substr(i, 2) == "BC") {
            res += a_count;
            i++;
        }
        else if(s[i] == 'A')
            a_count++;
        else
            a_count = 0;
    }
    cout << res << endl;
}


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

int main(){
    int n, k, b;
    while(cin >> n >> k){
        if(n + k == 0)  break;

        int s[k];
        for(int i = 0; i < k; i++)  cin >> s[i];

        for(int i = 0; i < n; i++){
            for(int j = 0; j < k; j++){
                cin >> b;
                s[j] -= b;
            }
        }

        bool judge = true;
        for(int i = 0; i < k; i++)  if(s[i] < 0)    judge = false;

        if(judge)   cout << "Yes" << endl;
        else        cout << "No" << endl;
    }
    return 0;
}


Measured memory_bytes: 3052
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <limits>
#include <numeric>
#include <type_traits>

using namespace std;

int main(){
    int N,M;
    int tmp,tmp_abs;
    int gcd_max = 0;
  
    cin >> N >> M;
    for(int i = N; i <= M/2; i++){
        if(M % i == 0){
            gcd_max = M / i;
            break;
        }
    }
    if(gcd_max == 0){
        gcd_max = 1;
    }

    cout << gcd_max << endl;
}

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

int main(){
    int N,A;
    cin>>N;
    
    vector<vector<pair<int,int>>> data;
    data.resize(N);
    rep(i,N){
        cin>>A;
        data[i].resize(A);
        rep(j,A){
            cin>>data[i][j].first>>data[i][j].second;
            data[i][j].first--;
        }
    }
    
    int ans=0;
    for (int bit=0;bit<(1<<N);bit++){
        int cnt=0;
        bool ok=true;
        rep(i,N){
             if(!(bit & (1<<i))){
                    continue;
                }
            for (auto xy:data[i]){
                int x=xy.first;
                int y=xy.second;
               
                if((bit & (1 << x))&&y==0){
                    ok=false;
                    
                }
                else if(!(bit & (1 << x))&&y==1){
                    ok=false;
                    
                }
                
            }
            
        }
        if(ok==true){
            rep(i,N){
                if(bit&(1<<i)){
                    cnt++;
                }
            }
            ans=max(ans,cnt);
        }
        
    }
    cout<<ans<<endl;
    
    }
    
    
    
    
    
  
 
 




Measured memory_bytes: 3528
x = int(input())
# 要するに6+5+6+5...>=xとなる最小数
count = 0
div = int(x/11)
count += div * 2
if x == div * 11:
    print(count)
elif x <= div * 11 + 6:
    print(count + 1)
else:
    print(count + 2)

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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define reps(i, n, m) for (int i = (int)(n); i <= (int)(m); i++)
#define all(obj) (obj).begin(), (obj).end()
#define rall(obj) (obj).rbegin(), (obj).rend()
#define collect(arr, size) rep(i,size) cin >> arr[i];
#define int long long

signed main(){
    int A, B; cin >> A >> B;
    int ans = -1;
    for(int p=1; p<=2000; p++){
        if(floor(p*0.08)==A && floor(p*0.1)==B){
            ans = p;
            break;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define endl '\n'
#define SPEED ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define MOD 1000000007
#define M 998244353
int pwr(int x,int p)
{
    int temp=1;
    while(p>0)
    {
        if(p%2==1)
        {
            temp*=x;
            temp%=M;
            --p;
        }
        else
        {
            x*=x;
            x%=M;
            p/=2;
        }
    }
    return temp;
}
signed main()
{
   SPEED;
   int n,m,k,res=0;
   cin>>n>>m>>k;
   int fact[n+1],inv[n+1];
   fact[0]=1;
   inv[0]=1;
   for(int i=1;i<=n;i++)
   {
       fact[i]=fact[i-1]*i;
       fact[i]%=M;
   }
   for(int i=1;i<=n;i++)
   {
       inv[i]=pwr(fact[i],M-2);
   }
   for(int i=0;i<=k;i++)
   {
       int sum=fact[n-1]*inv[i];
       sum%=M;
       sum*=inv[n-1-i];
       sum%=M;
       sum*=m;
       sum%=M;
       sum*=pwr(m-1,n-1-i);
       sum%=M;
       res+=sum;
       res%=M;
   }
   cout<<res;
}

Measured memory_bytes: 6708
#include<iostream>
#include<cstring>
#include<cstdio>
#include<algorithm>
#include<cmath>
using namespace std;
#define ll long long int
#define INF 0x3f3f3f3f
const int maxn = 1e5 + 10;
//2019-1-12 atcoder 20:00
int a[maxn];
int main()
{  
	int n;
	int A, B;
	int xx=0, yy=0, zz=0;
	scanf("%d %d %d", &n, &A, &B);
	for (int i = 1; i <= n; i++) {
		scanf("%d", &a[i]);
		if (a[i] <= A) xx++;
		else if (a[i] > B) zz++;
		else yy++;
	}
	int Min = maxn;
	Min = min(xx, yy);
	Min = min(Min, zz);
	cout << Min << endl;
	return 0;
}
//碳烤小松鼠,油炸老蜈蚣

Measured memory_bytes: 256
fn read1<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

pub fn readn<T: std::str::FromStr>(delimiter: &str) -> Vec<T> {
    let s = read1::<String>();
    s.split(delimiter).map(|e| e.parse().ok().unwrap()).collect::<Vec<T>>()
}

fn f(a: usize, b: usize) -> usize {
    let x;
    let y;
    if a < b {
        x = a;
        y = b;
    } else {
        y = a;
        x = b;
    } 
    if x == 0 {
        return 0;
    }
    if y % x == 0 {
        return 2 * y - x;
    }
    2 * x * (y / x) + f(y % x, x)
}

fn main() {
    let nx = readn::<usize>(" ");
    let n = nx[0];
    let x = nx[1];

    println!("{}", n + f(n - x, x));
}

Measured memory_bytes: 4352
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
#include <string>
#include <set>
#include <map>
#include <iterator>
#include <utility>
#include <iomanip>
#include <stack>
#include<bitset>
#include <cmath>
using namespace std;
#define ll long long
#define ld long double
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 
#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update> 
priority_queue<pair<ll,ll>,vector<pair<ll,ll> >,greater<pair<ll,ll> > >pq;
vector<ll>adj[1000005];
ld expo(ld b,ll n,ll m)
{
 ll r;
 ld p;
	p=1;
	while(n>0)
	{ 
		r=n%2;
		if(r==1)
		   p=((p)*(b));
		b=((b)*(b)); 
		n=n/2;		
	}
 return p;
}
ll divide1(ll a,ll b,ll m)
	{ ll r,p,n;
			p=a%m;
				n=m-2;
				while(n>0){
						 r=n%2;
						if(r==1)
							p=((p%m)*(b%m))%m;
						b=((b%m)*(b%m))%m; 
						n=n/2;	
					}
	return (p%m); }
int main(int argc, char const *argv[])
{	ios_base::sync_with_stdio(false);
	cin.tie(NULL),cout.tie(NULL);
	ll x1;
	cin>>x1;
	ll x=100;
	ll t=0;
	for (; t < 10000&&x<x1; t+=1)
	{
		x+=x/100;
	}
	cout<<t<<endl;
	return 0;
}


Measured memory_bytes: 27084
#include <stdio.h>
#include <stdlib.h>


int main()
{
	int n;
	int **box, *_box;
	int vertex;
	int kazu, num;
	int i, j;


	scanf("%d", &n);

	_box = (int *)malloc(sizeof(int) * n * n);
	box = (int **)malloc(sizeof(int *) * n);
	for(i = 0; i < n; i++)
		box[i] = _box + (i * n);

	for(i = 0; i < n; i++)
		for(j = 0; j < n; j++)
			box[i][j] = 0;

	for(i = 0; i < n; i++){
		scanf("%d", &vertex);
		scanf("%d", &kazu);

		for(j = 0; j < kazu; j++){
			scanf("%d", &num);
			box[vertex - 1][num - 1] = 1;
		}
	}


	// 表示
	for(i = 0; i < n; i++){
		for(j = 0; j < n; j++){
			printf("%d", box[i][j]);
			if(j != n - 1)
				printf(" ");
		}
		printf("\n");
	}

	return 0;
}


Measured memory_bytes: 2064
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define Yes                \
    cout << "Yes" << endl; \
    return 0;
#define No                \
    cout << "No" << endl; \
    return 0;
using namespace std;
using ll = long long;
const int INF = 1001001001;
const int MOD = 1000000007;
typedef long long ll;

template <typename T>
void print(const T &v);

int main()
{
    ll N;
    cin >> N;
    ll m = 0;
    ll zero = 0;
    ll total = 0;
    ll mini = INF;
    rep(i, N)
    {
        ll tmp;
        cin >> tmp;
        total += abs(tmp);
        mini = min(mini, abs(tmp));
        if (tmp < 0)
        {
            m++;
        }
        if (tmp == 0 && zero == 0)
        {
            zero = 1;
        }
    }
    if (zero || (m % 2 == 0))
    {
        cout << total << endl;
        return 0;
    }
    else
    {
        cout << total - mini - mini << endl;
        return 0;
    }
}

// Use For Debug
template <typename T>
void print(T const &v)
{
    for (int i = 0; i < v.size(); i++)
    {
        if (i)
            cout << " ";
        cout << v[i];
    }
    cout << endl;
}


Measured memory_bytes: 256
// vvvvvvvvvvvv TEMPLATE vvvvvvvvvvvv
#include <bits/stdc++.h>
using namespace std; using ll = long long; using P = pair<ll, ll>;
const ll linf = 1e18; const double eps = 1e-12, pi = acos(-1);
#define FOR(i,a,b) for (ll i=(a),__last_##i=(b);i<__last_##i;i++)
#define RFOR(i,a,b) for (ll i=(b)-1,__last_##i=(a);i>=__last_##i;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define __GET_MACRO3(_1, _2, _3, NAME, ...) NAME
#define each(i,a) for (auto&& i : a)
#define rep(...) __GET_MACRO3(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define rrep(...) __GET_MACRO3(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)
#define pb push_back
#define eb emplace_back
#define all(a) begin(a),end(a)
#define chmin(x,v) x = min(x, v)
#define chmax(x,v) x = max(x, v)
#define min(x,y) (x < y ? x : y)
#define max(x,y) (x < y ? y : x)
template<typename Head> void out(Head h) { cout << h << endl; } template<typename Head, typename... Tail>void out(Head h, Tail... t) { cout << h << " "; out(t...); }
template<typename T> istream& operator>>(istream& is, vector<T>& v) { each(x,v) is >> x; return is; }
template<typename T> ostream& operator<<(ostream& os, const vector<T>& v) { rep(i,v.size()) { if (i) os << " "; os << v[i]; } return os; }
template<typename T> ostream& operator<<(ostream& os, const vector<string>& v) { rep(i,v.size()) { if (i) os << endl; os << v[i]; } return os; }
template<typename T> ostream& operator<<(ostream& os, const vector<vector<T>>& v) { rep(i,v.size()) { if (i) os << endl; os << v[i]; } return os; }
struct yes_no : std::numpunct<char> { string_type do_truename() const { return "Yes"; } string_type do_falsename() const { return "No"; } };
void solve(); int main() {
  ios::sync_with_stdio(false); cin.tie(0); locale loc(locale(), new yes_no); cout.imbue(loc); cout << fixed << setprecision(10) << boolalpha;
  solve();
}
// ^^^^^^^^^^^^ TEMPLATE ^^^^^^^^^^^^

void solve() {
  ll x, y; cin >> x >> y;
  ll ans = (max(0, 4 - x) + max(0, 4 - y)) * 100000;
  if (x == 1 && y == 1) {
    ans += 400000;
  }
  cout << ans << endl;
}


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

const int D=365;
int csum;
int c[26];
int s[D][26];
int last[26];

int ans[D];

int score(){
	memset(last,-1,sizeof(last));
	int sum=0;
	int diff=0;
	rep(i,D){
		sum+=s[i][ans[i]];
		diff+=csum;
		diff-=(i-last[ans[i]])*c[ans[i]];
		sum-=diff;
		last[ans[i]]=i;
	}
	return sum;
}

int main(){
	//~ memset(last,-1,sizeof(last));
	scanf("%*d");
	rep(i,26)scanf("%d",&c[i]),csum+=c[i];
	rep(i,D)rep(j,26)scanf("%d",&s[i][j]);
	rep(i,D){
		ans[i]=max_element(s[i],s[i]+26)-s[i];
	}
	random_device rnd;
	mt19937 mt(rnd());
	uniform_real_distribution<double>Real(0,1);
	int Max=score();
	double stmp=10000,etmp=0;
	int update=0;
	int LOOP=3000000;
	rep(loop,LOOP){
		int pos=mt()%D;
		int sum=0;
		rep(i,26)sum+=s[pos][i];
		int ch=mt()%sum;
		int d=-1;
		rep(i,26){
			ch-=s[pos][i];
			if(ch<0){d=i;break;}
		}
		assert(d!=-1);
		int old=ans[pos];
		ans[pos]=d;
		int nx=score();
		double tmp=stmp+(etmp-stmp)/LOOP*loop;
		double p=exp(-double(abs(Max-nx))/tmp);
		if(Max<nx||Real(mt)<p){
			Max=nx;update++;
		}
		else{
			ans[pos]=old;
		}
	}
	cerr<<update<<endl;
	rep(i,D){
		cout<<ans[i]+1<<endl;
	}
	cerr<<"score: "<<Max<<' '<<score()<<endl;
}

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

int main()
{

    int N,W;
    cin>>N>>W;
    vector<long long > wt;
    vector<long long > val;
    long long  a,b;
    for(int i=0; i<N; i++)
    {
        cin>>a>>b;
        wt.push_back(a);
        val.push_back(b);
    }

    vector<vector<long long > > K(N+1, vector<long long> (W+1));

    for(int i=0; i<=N; i++)
        for(int j=0; j<=W; j++)
    {
        if(i==0 || j==0)
           K[i][j]=0;
        else if (wt[i-1] <= j)
          K[i][j] = max(val[i-1] + K[i-1][j - wt[i-1]], K[i-1][j]);
        else
            K[i][j] = K[i-1][j];


    }
    cout<<K[N][W];

    return 0;


}


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

int main(void) {
    int n, k;
    cin >> n >> k;
    vector<int> p(n);
    vector<double> expected_value(n);
    vector<double> expected_sum(n + 1, 0.0);
    double ans = 0.0;

    for(int i = 0; i < n; ++i){
        cin >> p[i];
    }

    for(int i = 0; i < n; ++i){
        expected_value[i] = (1 + p[i]) / 2.0;
    }

    for(int i = 0; i < n; ++i){
        expected_sum[i + 1] = expected_sum[i] + expected_value[i];
    }

    for(int i = 0; i + k <= n; ++i){
        ans = max(ans, (double)(expected_sum[i + k] - expected_sum[i]));
    }
    printf("%.6lf\n", ans);

    return 0;
}

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

typedef long long ll;
ll N, K;
string S;
ll D;

int main() {
  cin >> N >> K >> S;
  for (ll i = 1; i < S.size(); ++i) {
    if (S[i - 1] != S[i]) ++D;
  }
  D = max(D - 2 * K, 0ll);
  cout << N - 1 - D << endl;
  return 0;
}


Measured memory_bytes: 512