akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end())
#define VRSORT(v) sort(v.rbegin(), v.rend())
#define ll int64_t
#define pb(a) push_back(a)
#define INF 1000000000
#define MOD 1000000007
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

typedef vector<unsigned int>vec;
typedef vector<vec> mat;

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; }
template<class T> inline void add(T &a, T b){a = ((a+b) % MOD + MOD) % MOD;};

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

int dp[202][101];
int t[202],a[202],b[202],c[202];

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n,d;
    cin>>n>>d;
    REP(i,n) cin>>t[i];
    REP(i,d) cin>>a[i]>>b[i]>>c[i];
    REP(i,n) REP(j,101) dp[i][j] = -INF;
    REP(i,d) if(a[i]<=t[0] && t[0]<= b[i]) dp[0][c[i]]=0;
    REP(i,n-1){
        REP(j,101){
            if(dp[i][j]>=0){
                REP(k,d){
                    if(a[k]<=t[i+1] && t[i+1] <= b[k]) chmax(dp[i+1][c[k]],dp[i][j]+abs(j-c[k]));
                }
            }
        }
    }
    int ans = 0;
    REP(i,101) chmax(ans,dp[n-1][i]);
    cout<<ans<<endl;
}




Measured memory_bytes: 3160
from itertools import permutations
N = int(input())

xy = []
for i in range(N):
    xy.append(list(map(int,input().split())))

n = [i for i in range(N)]
sum = 0
for i in permutations(n):
    i = list(i)
    for j in range(N-1):
        sum += ((xy[i[j]][0]-xy[i[j+1]][0])**2 + (xy[i[j]][1]-xy[i[j+1]][1])**2)**(0.5)

fct = 1
for i in range(1,N+1):
    fct *= i

print(sum/fct)

Measured memory_bytes: 9372
#include <bits/stdc++.h>
using namespace std;
using pint = pair<int, int>;
using ll = long long;
using ull = unsigned long long;
using vll = vector<long long>;
using pll = pair<ll, ll>;
#define FOR(i, begin, end) for (int i = (begin), i##_end_ = (end); i < i##_end_; i++)
#define IFOR(i, begin, end) for (int i = (end)-1, i##_begin_ = (begin); i >= i##_begin_; i--)
#define REP(i, n) FOR(i, 0, n)
#define IREP(i, n) IFOR(i, 0, n)
#define VREP(s, ite) for (auto ite = s.begin(); ite != s.end(); ++ite)
#define FI first
#define SE second
#define ALL(v) v.begin(),v.end()
//#define endl "\n"
#define ciosup  \
    cin.tie(0); \
    ios::sync_with_stdio(false);
#define eb emplace_back
#define vint vector<int>
constexpr ll INF = 1e15 + 7LL;
constexpr ll MOD = 998244353;

template <typename T>
istream &operator>>(istream &is, vector<T> &v)
{
    for (int i = 0; i < v.size(); ++i)
    {
        is >> v[i];
    }
    return is;
}
template <typename T>
ostream &operator<<(ostream &os, const vector<T> &v)
{
    for (int i = 0; i < v.size() - 1; ++i)
    {
        os << v[i] << " ";
    }
    if (v.size() > 0)
    {
        os << v[v.size() - 1] << endl;
    }
    return os;
}


int main()
{
    int n;
    cin >> n;
    vll x(n), y(n);
    REP(i,n){
        cin >> x[i] >> y[i];
    }
    double ans = 0.;
    int perm[n];
    REP(i, n)
    {
        perm[i] = i;
    }
    ll count = 0;
    do
    {
        ++count;
        REP(i,n-1){
            ans += sqrt(pow(x[perm[i]] - x[perm[i + 1]], 2) + pow(y[perm[i]] - y[perm[i + 1]], 2));
        }
    } while (next_permutation(perm, perm + n));
    ans /= count;
    cout.precision(20);
    cout << ans << endl;
}

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

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

using namespace std;
const int INF = 1 << 30;

void DFS(vector<vector<bool>> &bit, vector<bool> vec, int N) {
	if (vec.size() == N)bit.push_back(vec);
	else {
		vector<bool> bt = vec;
		bt.push_back(true);
		DFS(bit, bt, N);
		vector<bool> bf = vec;
		bf.push_back(false);
		DFS(bit, bf, N);
	}
}

int calcScore(int N, int M, int X, vector<vector<bool>> bit, vector<int> C, vector<vector<int>> A) {
	int ans = INF;
	int score = 0;
	rep(i, bit.size()) {
		score = 0;
		vector<int> rikai(M);
		rep(j, N) {
			if (bit[i][j]) {
				score += C[j];
				rep(k, M)rikai[k] += A[j][k];
			}
		}
		/*cout << "score" << endl;
		cout << score << endl;*/

		int flag = 1;
		rep(j, M) {
			//cout << rikai[j] << endl;
			if (rikai[j] < X)flag=0;
		}
		if ((flag==1) && (ans > score)) {
			/*cout << "kousinn" << endl;
			cout << ans << endl;
			cout << score << endl;*/
			ans = score;
		}
	}

	return ans;
}

int main() {
	int N, M, X;
	cin >> N >> M >> X;

	vector<int> C(N);
	vector<vector<int>> A(N, vector<int>(M));

	rep(i, N) {
		cin >> C[i];
		rep(j, M)cin >> A[i][j];
	}
	/*rep(i, N) {
		rep(j, M)cout << A[i][j];
		cout << endl;
	}*/
	vector<int> score;

	vector<vector<bool>> bit;
	vector<bool> vec;

	DFS(bit, vec, N);
	//cout << bit.size() << endl;
	int ans = calcScore(N, M, X, bit, C, A);
	if (ans == INF)cout << -1;
	else cout << ans;



}

Measured memory_bytes: 3920
#include <iostream>
#include <vector>
#include <cmath>
#include <iomanip>//cout << fixed << setprecision() <<
#include <set>
#include <map>
using ll = long long;
using namespace std;

double Mcos(double k){return cos(k*atan(1.0)*4/180);}
double Msin(double k){return sin(k*atan(1.0)*4/180);}

int main(void){
    ll n,a,b;
    ll c1,c2,c3;
    cin>>n>>a>>b;
    c1=a+b;
    c2=n/c1;
    c3=n%c1;
    if(a==0)c3=0;
    if(c3>=a)c3=a;
    cout<<a*c2+c3;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int main(void){
  int H,W,i,j;
  char str[50],s[60][60],*p;
  
  fgets(str,sizeof(str),stdin);
  p=strtok(str," \n");
  H=atoi(p);
  p=strtok(NULL," \n");
  W=atoi(p);
  
  for(i=0;i<H;i++){
    fgets(s[i],sizeof(s[i]),stdin);
  }
  
  for(i=0;i<H;i++){
   for(j=0;j<W;j++){
    if(i==0 && j==0 && s[i][j]=='#'){
      if(s[i+1][j]=='.' && s[i][j+1]=='.'){
       printf("No\n");
        return 0;
      }
    }else if(i==0 && j==W-1 && s[i][j]=='#'){
      if(s[i+1][j]=='.' && s[i][j-1]=='.'){
       printf("No\n");
        return 0;
      }
    }else if(i==0 && s[i][j]=='#'){
      if(s[i+1][j]=='.' && s[i][j-1]=='.' && s[i][j+1]=='.'){
        printf("No\n");
        return 0;
      }
    }else if(i==H-1 && j==0 && s[i][j]=='#'){
      if(s[i-1][j]=='.' && s[i][j+1]=='.'){
       printf("No\n");
        return 0;
      }
    }else if(i==H-1 && j==W-1 && s[i][j]=='#'){
      if(s[i-1][j]=='.' && s[i][j-1]=='.'){
       printf("No\n");
        return 0;
      }
    }else if(i==H-1 && s[i][j]=='#'){
      if(s[i-1][j]=='.' && s[i][j-1]=='.' && s[i][j+1]=='.'){
        printf("No\n");
        return 0;
      }
    }else if(j==0 && i!=0 && i!=H-1  && s[i][j]=='#'){
       if(s[i-1][j]=='.' && s[i+1][j]=='.' && s[i][j+1]=='.'){
         printf("No\n");
         return 0;
       }
    }else if(j==W-1 && i!=0 && i!=H-1  && s[i][j]=='#'){
       if(s[i-1][j]=='.' && s[i+1][j]=='.' && s[i][j-1]=='.'){
         printf("No\n");
         return 0;
       }
    }else if(s[i][j]=='#'){
        if(s[i-1][j]=='.' && s[i+1][j]=='.' && s[i][j-1]=='.' 
          && s[i][j+1]=='.'){
          printf("No\n");
          return 0;
        }
         
       }
     
   }
  }
    
  printf("Yes\n");
  
 return 0; 
}

Measured memory_bytes: 128
#include <iostream>
#include <sstream>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <set>
#include <queue>
#include <map>
#include <numeric>
#include <functional>
#include <math.h>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;

#define INF ((int)1e9)
#define INFLL ((ll)1e18)
#define MOD (1000000007LL)

#define NMAX 20
ll DP[2*NMAX][2*NMAX][2*NMAX];

int main(int argc, const char * argv[]) {
    ios_base::sync_with_stdio(false);
    int N;
    cin >> N;
    vector<string> A(2*N);
    for (int n = 0; n < 2*N; ++n) cin >> A[n];
    
    for (int n = 0; n < 2*N; ++n) DP[n][n][n] = 1;
        
    for (int d = 2; d < 2*N; ++d) {
        for (int s = 0; s < 2*N-d; ++s) {
            int t = s+d;
            if (d%2 == 1) continue;
            for (int p = s+1; p < t; ++p) {
                for (int a = s; a < p; ++a) {
                    for (int b = p+1; b <= t; ++b) {
                        if (A[a][b] == '0') continue;
                        for (int c = a; c < p; ++c) {
                            for (int d = p; d < b; ++d) {
                                DP[s][p][t] += DP[s][a][c] * DP[c+1][p][d] * DP[d+1][b][t];
                            }
                        }
                    }
                }
            }
        }
    }
    
    ll Res = 0;
    for (int n = 1; n < 2*N; ++n) {
        if (A[0][n] == '1') Res += DP[1][n][2*N-1];
    }
    cout << Res << endl;

    return 0;
}


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

#define	MOD 1000000007;
#define PI 3.14159265358979323846;
#define rep(i,n) for(ll i = 0;i<(ll)n;i++)
using namespace std;
typedef long long ll;
static const int MAX = 50;
static const long long INFTYL = 9223372036854775807;
static const int INFTY = 2147483647;
ll mod = 1000000007;
int N, A, B;

ll h[100000];
bool C(double x) {
	ll P[100000];
	rep(i, N) {
		P[i] = h[i];
	}
	rep(i, N) P[i] -= B * x;

	int count = 0;
	ll mx = 0;

	rep(i, N) {
		if (P[i] > 0) {
			bool just = ((P[i] % (A - B)) == 0);
			int centerCount = (P[i] / (A - B)) + (just ? 0 : 1);
			P[i] -= centerCount * (A - B);
			count += centerCount;
			if (count > x) {
				return false;
			}
		}
	}

	bool allNegative = true;
	rep(i, N) {
		if (P[i] > 0) {
			allNegative = false;
			break;
		}
	}

	return allNegative;
}

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

	rep(i, N) cin >> h[i];

	int lb = 0, ub = INFTY;

	rep(i, 100) {
		int mid = (lb + ub) / 2;
		if (ub == 95) {
			int t = 0;
		}
		if (C(mid))
		{
			ub = mid;
		}
		else {
			lb = mid;
		}
		//printf("%d %d\n", lb, ub);
	}
	printf("%d\n", ub);
	return 0;
}

Measured memory_bytes: 1792
import java.util.Scanner;

public class Main{
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        String input = sc.nextLine();
        byte count = 0;

        if(input.charAt(0) == '1'){
            count++;
        }
        if(input.charAt(1) == '1'){
            count++;
        }
        if(input.charAt(2) == '1'){
            count++;
        }

        System.out.println(count);

    }
}

Measured memory_bytes: 23124
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (i = 0; i < n; i++)
//const long long INF = 1LL << 60;

long long V[3001][3001];
long long dp[3001][3001][5];

int main()
{
    int i, j, k, R, C, K;
    cin >> R >> C >> K;
    memset(V, 0, sizeof(V));
    memset(dp, 0, sizeof(dp));
    int r, c, v;
    rep(i, K){
        cin >> r >> c >> v;
        V[r-1][c-1]=v;
    }

    dp[0][0][1] = V[0][0];

    rep(i, R){ rep(j, C) { rep(k, 4){
        // to right
        dp[i][j+1][k+1]=max(dp[i][j+1][k+1],dp[i][j][k]+V[i][j+1]);
        dp[i][j+1][k]=max(dp[i][j+1][k],dp[i][j][k]);
        // to down
        dp[i+1][j][1]=max(dp[i+1][j][1],dp[i][j][k]+V[i+1][j]);
        dp[i+1][j][0]=max(dp[i+1][j][0],dp[i][j][k]);
    }}}

    long long int ans=0;
    rep(i,4) ans=max(ans,dp[R-1][C-1][i]);

    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 425788
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<utility>
#include<set>
#include<stack>
#include<list>
#include<deque>
#include<bitset>
#include<iomanip>
#include<cstring>
#include<sstream>
#include<cstdio>
#include<cstdlib>
#include<climits>
#include<cmath>
#include<cctype>


#define pb push_back
#define mp make_pair
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define ren(i,a,b) for(int i=a;i>=b;i--)
#define ff first
#define ss second
#define pll pair<long long int,long long int>
#define pii pair<int,int>
#define vll vector<long long int>
#define vii vector<int>
#define gi(n) scanf("%d",&n)
#define gll(n) scanf("%lld",&n)
#define gstr(n) scanf("%s",n)
#define gl(n) cin >> n
#define oi(n) printf("%d",n)
#define oll(n) printf("%lld",n)
#define ostr(n) printf("%s",n)
#define ol(n) cout << n
#define os cout<<" "
#define on cout<<"\n"
#define o2(a,b) cout<<a<<" "<<b
#define all(n) n.begin(),n.end()
#define present(s,x) (s.find(x) != s.end())
#define cpresent(s,x) (find(all(s),x) != s.end())
#define tr(container, it) for(__typeof(container.begin()) it = container.begin(); it != container.end(); it++)
using namespace std;

typedef unsigned long long int ull;
typedef long long int ll;
typedef long double ld;
typedef vector<vector<ll> > mat;

int n;
vii v[300005];

int main()
{ios_base::sync_with_stdio(false);
cin>>n;
rep(i,1,n)
{
	int x;
	cin>>x;
	v[x].pb(i);
}
int ans=0,lst=0;
rep(i,1,n)
{
	int id=lower_bound(all(v[i]),lst)-v[i].begin();
	if(id==v[i].size())break;
	lst=v[i][id];
	ans++;
}
ans=n-ans;
if(ans>=n)ol("-1");
else ol(ans);
return 0;
}



Measured memory_bytes: 13568
#include <stdio.h>

int main(void)
{
    int N,L,j=0;
    int sum=0;
    scanf("%d%d",&N,&L);
    int taste[N],abso[N];
    int min=100;
    
    for(int i=0;i<N;i++){
        sum+=L+i;
    }
    
    for(int i=0;i<N;i++){
        taste[i]=L+i;
        if(taste[i]<0)
            abso[i]=-taste[i];
        else
            abso[i]=taste[i];
        if(min>abso[i]){
            min=abso[i];
            j=i;
        }
    }
    printf("%d\n",sum-taste[j]);
    
    return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
#define ri register int
using namespace std;
inline int read(){
	#define gc getchar
	bool f=1;
	int ans=0;
	char ch=gc();
	while(!isdigit(ch))f^=ch==gc(),ch=gc();
	while(isdigit(ch))ans=((ans<<2)+ans<<1)+(ch^48),ch=gc();
	return f?ans:-ans;
	#undef gc
}
const int mod=998244353;
typedef long long ll;
inline int add(int a,int b){return (a+=b)<mod?a:a-mod;}
inline int dec(int a,int b){return (a-=b)<0?a+mod:a;}
inline int mul(int a,int b){return (ll)a*b%mod;}
inline void Add(int&a,int b){(a+=b)<mod?a:a-=mod;}
inline void Dec(int&a,int b){(a-=b)<0?a+=mod:a;}
inline void Mul(int&a,int b){a=(ll)a*b%mod;}
inline int ksm(int a,int p){int ret=1;for(;p;p>>=1,Mul(a,a))if(p&1)Mul(ret,a);return ret;}
int n;
int main(){
	int k,x;
	cin>>k>>x;
	for(ri i=-k+1;i<=k-1;++i)cout<<i+x<<' ';
	return 0;
}

Measured memory_bytes: 256
// AOJ 1173 The Balance of the world
#include <iostream>
#include <string>
#include <stack>
using namespace std;

int main(){
	bool f;
	string s;
	while(getline(cin, s)){
		if(s == ".") break;
		stack<char> st;
		f = true;
		string::const_iterator it = s.begin();
		for(;it != s.end();++it){
			if(*it == '(' || *it == '['){
				st.push(*it);
			}
			else if(*it == ')'){
				if(st.size() && st.top() == '('){
					st.pop();
				}
				else{
					f = false;
					break;
				}
			}
			else if(*it == ']'){
				if(st.size() && st.top() == '['){
					st.pop();
				}
				else{
					f = false;
					break;
				}
			}
		}
		if(f){
			if(!st.size()) cout << "yes" << endl;
			else cout << "no" << endl;
		}
		else{
			cout << "no" << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 1176
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef vector<ll> vl;
typedef pair<ll, ll> PP;
#define rep(i, n) for(ll i = 0; i < ll(n); i++)
#define all(v) v.begin(), v.end()
bool chmin(ll & a, ll  b) { if (b < a) { a = b; return 1; } return 0; }
bool chmax(ll & a, ll b) { if (b > a) { a = b; return 1; } return 0; }
const ll INF = 999999999999999;
const ll MOD = 1000000007;
const ll MAX_N=500010;
ll a, b, c, d, e, f, p, t, x, y, z, q, m, n, r, h, k, w, l, ans;
int main() {
    cin>>n;
    vl A;
    rep(i,n){
        cin>>x;
        A.push_back(x);
    }

    vector<PP> B,C;

    rep(i,200000){
        B.push_back({0,i});
        C.push_back({0,i});
    }

    rep(i,n/2){
        B[A[i*2]].first++;
        C[A[i*2+1]].first++;
    }

    sort(all(B));
    reverse(all(B));

    sort(all(C));
    reverse(all(C));
    
    if(B[0].second!=C[0].second)ans=n-B[0].first-C[0].first;
    else ans=min(n-B[0].first-C[1].first,n-B[1].first-C[0].first);

    cout<<ans<<endl;
}


Measured memory_bytes: 11152
#define _CRT_SECURE_NO_WARNINGS
#include <cstdio>
#include <vector>
#include <string>
#include <iostream>
#include <algorithm>
#include <map>
#include <iterator>
#include <functional>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <fstream>
#include <iomanip>
#include <unordered_map>
#include <unordered_set>
#include <numeric>
#include <cmath>
#include <list>
#include <sstream>
#include <tuple>
#include <complex>
#include <stdio.h>
using namespace std;
#pragma GCC optimize("O3")
#pragma GCC target("sse4")

typedef double LD;
typedef long long LL;
typedef pair<int, int> PII;
typedef pair<LD, LD> PDD;
typedef pair<LL, LL> PLL;
typedef vector<int> VI;
typedef vector<LL> VLL;
typedef vector<char> VCH;
typedef vector<LD> VLD;
typedef vector<VI> VVI;
typedef vector<VLL> VVLL;
typedef vector<VCH> VVCH;
typedef vector<PII> VPII;
typedef vector<PLL> VPLL;
typedef vector<PDD> VPDD;
#define MP make_pair
#define PB push_back
#define X first
#define Y second
#define next fake_next
#define prev fake_prev
#define left fake_left
#define right fake_right

#define FOR(i,a,b) for(int i = (a); i < (b); ++i)
#define RFOR(i,b,a) for(int i = (b) - 1; i >= (a); --i)
#define REP(i, t) FOR(i,0,t)
#define ALL(a) a.begin(), a.end()
#define SZ(a) (int)((a).size())

const LD PI = acos(-1.0);
const LL mod = 1000000007;
const LL INF = 1e9;
const LL MAXN = 100001;

int main()
{
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	//freopen("In.txt", "r", stdin);

	int n, x;
	cin >> n >> x;
	if (x == 1 || x == n*2 - 1)
	{
		cout << "No";
		return 0;
	}
	cout << "Yes" << endl;

	if (n == 2)
	{
		FOR(i, 1, 4)
			cout << i << endl;
		return 0;
	}

	if (x == 2*n - 2)
	{
		VI a(2 * n - 1, 0);

		a[n - 2] = x - 1;
		a[n - 1] = x;
		a[n] = x + 1;
		a[n + 1] = x - 2;

		set<int> c;
		FOR(i, 1, x - 2)
			c.insert(i);

		FOR(i, x + 2, 2 * n)
			c.insert(i);

		FOR(i, 0, SZ(a))
			if (a[i] == 0)
			{
				a[i] = *c.begin();
				c.erase(a[i]);
			}

		FOR(i, 0, SZ(a))
			cout << a[i] << endl;
	}
	else
	{
		VI a(2 * n - 1, 0);

		a[n - 2] = x + 1;
		a[n - 1] = x;
		a[n] = x - 1;
		a[n + 1] = x + 2;

		set<int> c;
		FOR(i, 1, x - 1)
			c.insert(i);

		FOR(i, x + 3, 2 * n)
			c.insert(i);

		FOR(i, 0, SZ(a))
			if (a[i] == 0)
			{
				a[i] = *c.begin();
				c.erase(a[i]);
			}

		FOR(i, 0, SZ(a))
			cout << a[i] << endl;
	}

	return 0;
}

Measured memory_bytes: 11648
# 写経AC

from heapq import heappop,heappush

INF = 10 ** 18

N, K = map(int, input().split())
# S[i]: 種類iの美味しさの集合
S = [[] for _ in range(N)]
for _ in range(N):
    t,d = map(int, input().split())
    S[t-1].append(d)

# 各種類について、美味しい順に並べる
for i in range(N):
    S[i].sort(reverse = True)
    if not S[i]: S[i].append(-INF) # 番兵

# 「美味しさの最大値」の降順でソート
S.sort(reverse = True)

uma = 0 # おいしさ基礎ポイント
que = [] # 選ばれていない寿司の美味しさリスト
for i in range(K):
    # ある種類の一番美味しい寿司を選ぶ
    uma += S[i][0]
    for j in range(1, len(S[i])):
        heappush(que, (-1) * S[i][j])

# 残りの寿司もリストに追加
for i in range(K, N):
    for j in range(len(S[i])):
        heappush(que, (-1) * S[i][j])

ans = uma + K * K
# 種類を減らしていく
for x in range(K - 1, 0, -1):
    v = S[x][0] # 選ばれている最小の「おいしさ」
    w = (-1) * que[0] # 選ばれていない最大の「おいしさ」
    if v < w:
        heappop(que)
        heappush(que, (-1) * v)
        uma -= v; uma += w
    ans = max(ans, uma + x * x)

print(ans)

Measured memory_bytes: 28732
#include<bits/stdc++.h>
//#include<boost/multiprecision/cpp_int.hpp>
#define fl(i,a,n) for(int i=a;i<=n;i++)
#define pb push_back
#define pob pop_back
#define int long long int
#define ff first
#define ss second
#define pi 3.1415926535898
#define vi vector<int>
#define mi map<int,int>
#define umi unordered_map<int,int>
#define endl "\n"
#define w(x) int x; cin>>x; while(x--)
#define db(x) cout<<(#x)<<" "<<(x)<<"\n";
#define ios ios_base::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL);
using namespace std;
//using namespace boost::multiprecision;
int mod=1000000007;
int gcd(int a,int b){
     return (b == 0) ? a :gcd(b, a % b);
}
int lcm(int a,int b){
    return (a*b)/gcd(a,b);
}
// void c_p_c(){
//     ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
//     #ifndef ONLINE_JUDGE
//     freopen("input.txt", "r", stdin);
//     freopen("output.txt", "w", stdout);
//     #endif
// }
int32_t main(){
    
    ios
    //c_p_c();
    //w(t)
    {   int arr[3];
        cin>>arr[0]>>arr[1]>>arr[2];
        sort(arr,arr+3);
        if((arr[0]==arr[1] or arr[1]==arr[2]) and !(arr[0]==arr[1] and arr[1]==arr[2])){
            cout<<"Yes\n";
        }
        else{
            cout<<"No\n";
        }
    }

    return 0;
}



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

typedef long long ll;
typedef unsigned long long ull;

template <typename T>
T gcd( T m, T n ){
    if ( ( 0 == m ) || ( 0 == n ) ) return 0;

    while( m != n ){
        if ( m > n ) m %= n;
        else         n %= m;

        if(m == 0) return n;
        if(n == 0) return m;
    }
    return m;
}

template <typename T>
T lcm( T m, T n ){
    if ( ( 0 == m ) || ( 0 == n ) ) return 0;
    return ((m / gcd(m, n)) * n);
}

int main()
{
    ll N, M;
    cin >> N >> M;
    ll X = 1;
    vector<ll> A(N);
    for(int i=0;i<N;i++){
        cin >> A[i];
        A[i] /= 2;
        if(X <= M){
            X = lcm(X, A[i]);
        }else{
            X = M + 1;
        }
    }
    for(int i=0;i<N;i++){
        if((X / A[i]) % 2 == 0){
            X = M + 1;
            break;
        }
    }
    if(X>M){
        cout << 0 << endl;
    }else{
        cout<<(1 + (M - X) / (2 * X))<<endl;
    }

    return 0;
}


Measured memory_bytes: 1024
# C - Multiple Clocks
import functools
import math
N = int(input())
T = [int(input()) for _ in range(N)]

def lcm(a,b):
    LCM = a*b//math.gcd(a,b)
    return LCM

def all_lcm(A):
    ans = functools.reduce(lcm,A,1)
    return ans

print(all_lcm(T))

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

int parent(int);
int left(int);
int right(int);
void maxHeapify(int*,int);
void insert(int*,int);
void extract(int*);
void increase(int*,int);

int h=0;

int main(){
  int i,k,*A;
  char s[10];

  A = (int *)malloc(sizeof(int)*2000000);

  while(1){
    scanf("%s",s);
    if(s[0]=='e'){
      if(s[1]=='n') break;
      else if(s[1]=='x') extract(A);
    }
    else if(s[0]=='i'){
      scanf("%d",&k);
      insert(A,k);
    }
    
  }


  return 0;
}

int parent(int i){
  return i/2;
}

int left(int i){
  return i*2;
}

int right(int i){
  return i*2+1;
}

void maxHeapify(int* A,int i){
  int l,r,largest,tmp;
  
  l = left(i);
  r = right(i);

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

  if(r<=h && A[r]>A[largest]) largest = r;
  
  if(largest != i){
    tmp = A[i];
    A[i] = A[largest];
    A[largest] = tmp;
    maxHeapify(A,largest);
  }

  return;
}

void insert(int* A,int k){
  h++;
  A[h]=k;
  increase(A,k);
  return;
}

void extract(int* A){
  printf("%d\n",A[1]);
  A[1]=A[h];
  h--;
  maxHeapify(A,1);
  
  return;
}

void increase(int* A,int k){
  int tmp,i;
  i=h;
  if(k<A[i]) return;
  A[i] = k;
  while(i>1 && A[parent(i)]<A[i]){
    tmp = A[i];
    A[i]=A[parent(i)];
    A[parent(i)]=tmp;
    i=parent(i);
  }
  
  return;
  
}

Measured memory_bytes: 4848
#include<stdio.h>
#include<string.h>

int main(){
  char s[11];
  scanf("%s",s);

  int j=0;
  char array[11]={'\0'};
  int len=strlen(s);
  for(int i=0;i<len;i++){
    if(s[i]=='0'){
      array[j]='0';
      j++;
    }else if(s[i]=='1'){
      array[j]='1';
      j++;
    }else if(s[i]=='B'){
      if(j!=0){
        j--;
        array[j]='\0';
      }
    }
  }
  printf("%s",array);
  return 0;
}

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

#define rep(i,n) for(int i = 0; i<n; ++i)
#define REP(i,n) for(int i = 1; i<=n; ++i)
#define all(x) begin(x),end(x)
#define showall(obj) for(auto x:obj)cout<<x<<endl;
typedef long long ll;
typedef pair<int,int> ip;
typedef pair<ll,ll> lp;
typedef vector<int> vint;
typedef vector<ll> vll;
const int inf = 100100100;
const ll INF = 1LL<<60;
const int MOD = (int)1e9 + 7;

int main(){
	string s;
	cin>>s;
	int b_cnt = 0, r_cnt = 0;
	rep(i,s.size()){
		if(s[i] == '0')r_cnt++;
		else b_cnt++;
	}
	cout<<min(r_cnt, b_cnt)*2<<endl;
	return 0;
}

Measured memory_bytes: 512
n,m = map(int,input().split())

a = []
b = []
c = []
d = []

for i in range(n):
    x,y = map(int,input().split())
    a.append(x)
    b.append(y)
for i in range(m):
    x,y = map(int,input().split())
    c.append(x)
    d.append(y)



for i in range(n):
    distance = abs(a[i] - c[0]) + abs(b[i] - d[0])
    check = 0
    for j in range(1,m):
        temp = abs(a[i] - c[j]) + abs(b[i] - d[j])
        if distance > temp:
            distance = temp 
            check = j
    print(check + 1)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int main(){
    ll N;
    cin>>N;
    vector<ll> vt(N,0);
    ll b=0;
    for(ll i=0;i<N;i++){
        cin>>vt[i];
        b^=vt[i];
    }
    //cout<<xr<<endl;
    ll s=0;
	for(int i=60;i>=0;i--){
		ll u=1ll<<i;
		if(b&u)continue;
		//cerr << "aaa" << endl;
		for(int j=0;j<vt.size();j++){
			if(vt[j]&u){
				//cerr << i << ", " << j << ": " << A[j] << endl;
				if(!(s&u)){
					s^=vt[j];
				}
				for(int k=j+1;k<vt.size();k++){
					if(vt[k]&u){
						vt[k]^=vt[j];
					}
				}
				vt[j]=0;
				break;
			}
		}
	}
	cout << (b^s)+s << endl;
    //for(int i=0;i<vt.size();i++){
    //    cout<<vt[i]<<endl;
    //}
    return 0;
}

Measured memory_bytes: 1024
#include<stdio.h>
int main()
{
    int a,b,c,temp1,temp2;
    scanf("%d %d %d",&a,&b,&c);
    temp1=a;
    a=b;
    b=temp1;

    temp2=a;
    a=c;
    c=temp2;

    printf("%d %d %d\n",a,b,c);
    return 0;
}


Measured memory_bytes: 128
#! /usr/bin/env ruby

loop do
  n = gets.chomp.to_i
  break if n.zero?

  array = []
  n.times do
    array.push(gets.chomp.to_i)
  end

  dp = nil
  res = []
  array.each do |ele|
    if dp.nil?
      # 初回
      dp = ele
      res.push(ele)
      next
    end

    res.push([dp, dp + ele, ele].max)
    dp = [dp + ele, ele].max
  end

  puts res.max
end



Measured memory_bytes: 6956
// SeeAlso: https://atcoder.jp/contests/abc156/tasks/abc156_c

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

#define MAX 900000000
#define NIL -1
#define MOD 1000000007

typedef int _loop_int;
#define rep(i,n) for(int i = 0; i < n; i++)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1;i>=(_loop_int)(a);--i)

#define debug(x) cout<<#x<<": "<<x<<endl
#define debig_vec(v) cout<<#v<<":";rep(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

// 最大公約数
inline constexpr ll gcd(ll a,ll b){if(!a||!b)return 0;while(b){ll c=b;b=a%b;a=c;}return a;}
// 最小公倍数
inline constexpr ll lcm(ll a,ll b){if(!a||!b)return 0;return a*b/gcd(a,b);}

#define print2D(h, w, arr) rep(i, h) { rep(j, w) cout << arr[i][j] << " "; cout << endl; }
template<class T> void print(const T& x){cout << setprecision(12) << x << endl;}
template<class T, class... A> void print(const T& first, const A&... rest) { cout << first << " "; print(rest...); }

int main() {
    int n;
    cin >> n;
    int x[n];
    int mm = 0;
    rep(i,n) {
        cin >> x[i];
        mm = max(mm, x[i]);
    }

    ll minm = MAX;
    FOR(i, -100, mm+100) {
        ll tsum=0;
        rep(j, n) {
            tsum += (x[j]-i) * (x[j]-i);
        }
        minm = min(minm, tsum);
    }
    print(minm);
    return 0;
}


Measured memory_bytes: 256
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.io.IOException;
import java.io.InputStream;

/**
 * Built using CHelper plug-in Actual solution is at the top
 * 
 * @author daltao
 */
public class Main {
    public static void main(String[] args) throws Exception {
        Thread thread = new Thread(null, new TaskAdapter(), "daltao", 1 << 27);
        thread.start();
        thread.join();
    }

    static class TaskAdapter implements Runnable {
        @Override
        public void run() {
            InputStream inputStream = System.in;
            OutputStream outputStream = System.out;
            FastInput in = new FastInput(inputStream);
            PrintWriter out = new PrintWriter(outputStream);
            TaskB solver = new TaskB();
            solver.solve(1, in, out);
            out.close();
        }
    }
    static class TaskB {
        public void solve(int testNumber, FastInput in, PrintWriter out) {
            int n = in.readInt();
            int[] like = new int[n + 1];
            for (int i = 1; i <= n; i++) {
                like[i] = in.readInt();
            }

            int cnt = 0;
            for (int i = 1; i <= n; i++) {
                if (like[like[i]] == i) {
                    cnt++;
                }
            }

            out.println(cnt / 2);
        }

    }
    static class FastInput {
        private final InputStream is;
        private byte[] buf = new byte[1 << 13];
        private int bufLen;
        private int bufOffset;
        private int next;

        public FastInput(InputStream is) {
            this.is = is;
        }

        private int read() {
            while (bufLen == bufOffset) {
                bufOffset = 0;
                try {
                    bufLen = is.read(buf);
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
                if (bufLen == -1) {
                    return -1;
                }
            }
            return buf[bufOffset++];
        }

        public void skipBlank() {
            while (next >= 0 && next <= 32) {
                next = read();
            }
        }

        public int readInt() {
            int sign = 1;

            skipBlank();
            if (next == '+' || next == '-') {
                sign = next == '+' ? 1 : -1;
                next = read();
            }

            int val = 0;
            if (sign == 1) {
                while (next >= '0' && next <= '9') {
                    val = val * 10 + next - '0';
                    next = read();
                }
            } else {
                while (next >= '0' && next <= '9') {
                    val = val * 10 - next + '0';
                    next = read();
                }
            }

            return val;
        }

    }
}



Measured memory_bytes: 25300
#include <iostream>
#include <cmath>
#include <string.h>
#include <iomanip>
#include <math.h>
#include <algorithm>
#include <vector>
#include <map>
#include <tuple>
#include <queue>
using namespace std;

typedef long long ll;

#define INF 100000000;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repl(i, n) for (ll i = 0; i < (ll)(n); i++)
#define rrep(i, n) for (ll i = n - 1; i >= 0; i--)
#define eps 1.0e-14;

queue<pair<int,int>> que;
string s[1005];
ll ans = 0;

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

int main(){
	string s; cin >> s;
	if(s == "ABC") s = "ARC";
	else s = "ABC";
	cout << s << endl;
	return 0;
}


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

using LL = long long;

#define ALL(a) begin((a)), end((a))
#define FOR(i, a, b) for (int(i) = (a); (i) < (b); (i)++)
#define RFOR(i, a, b) for (int(i) = (a); (i) > (b); (i)--)
#define debug(x) cerr << #x << " : " << x << '\n'

const int INF = 1e9;
const int MOD = 1e9 + 7;
const LL LINF = 1e16;

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

  LL ans;
  LL X, t;
  cin >> X >> t;

  ans = X - t;
  if (ans < 0) {
    ans = 0;
  }

  cout << ans << '\n';

  return 0;
}

Measured memory_bytes: 256
import java.util.*;
public class Main {
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int[] a = new int[N];
		int ans = Integer.MAX_VALUE;
		for(int i = 0; i < N; i++)
			a[i] = sc.nextInt();
		for(int x = -100; x <= 100; x++) {
			int total = 0;
			for(int i = 0; i < N; i++)
				total += Math.pow(a[i]-x, 2);
			ans = Math.min(ans, total);
		}
		System.out.println(ans);

	}

}


Measured memory_bytes: 21844
n, k = map(int, input().split())
s = input()

nums = []
if s[0] == '0':
    nums.append(0)
i = 0
while i < n:
    j = i
    while j < n and s[j] == s[i]:
        j += 1
    nums.append(j-i)
    i = j
if s[-1] == '0':
    nums.append(0)

sums = [0]
for i in range(len(nums)):
    sums.append(sums[-1]+nums[i])

res = 0
for left in range(0, len(sums), 2):
    right = left + k*2+1
    if right >= len(sums):
        right = len(sums) - 1
    res = max(res, sums[right]-sums[left])
print(res)

Measured memory_bytes: 13776
#include <bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
 
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;
}
 
const ll INF = 1e18;
const ll MOD = 998244353;
const ll MX = 1000001;
 
ll N, M;
 
void solve() {
    cin >> N >> M;
    if (N % 2) {
        for (int i = 0; i < M; i++) {
            cout << i + 1 << " " << N - i << "\n";
        }
    } else {
        bool extra = false;
        for (int i = 0; i < M; i++) {
            if (N - i - (i + 1) <= N / 2) {
                extra = true;
            }
            
            if (!extra) cout << i + 1 << " " << N - i << "\n";
            else cout << i + 1 << " " << N - (i + 1)<< "\n";
        }
    }
}
 
int main() {
	cin.sync_with_stdio(0); cin.tie(0);
    ll T = 1; // cin >> T;
    while (T--) solve();
    return 0;
    // You should actually read the stuff at the bottom
}
 
/* Stuff to Look For
 * -----------------
 * Int overflow, array bounds
 * Initializing all variables, avoid weird behavior
 * Edge cases(n = 0, n = 1)
 * Just return 0 after result
 */


Measured memory_bytes: 3608
#include <stdio.h>
#include <algorithm>
#include <assert.h>
#include <bitset>
#include <cmath>
#include <complex>
#include <deque>
#include <functional>
#include <iostream>
#include <limits.h>
#include <map>
#include <math.h>
#include <queue>
#include <deque>
#include <set>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <time.h>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <chrono>
#include <random>
#include <time.h>
#include <fstream>
#define ll long long
#define rep2(i,a,b) for(ll i=a;i<=b;++i)
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep3(i,a,b) for(ll i=a;i>=b;i--)
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pq priority_queue<int>
#define pqg priority_queue<int,vector<int>,greater<int>>
#define pb emplace_back
#define vec vector<int>
#define vecll vector<ll>
#define vecpii vector<pii>
#define endl "\n"
#define all(c) begin(c),end(c)
using namespace std;
int in() {int x;scanf("%d",&x);return x;}
ll lin() {ll x;scanf("%lld",&x);return x;}
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;}
void print(vec v){for(auto e:v)cout<<e<<" ";cout<<endl;}
void print(vecll v){for(auto e:v)cout<<e<<" ";cout<<endl;}
void print(vector<vec> v){for(auto e:v){for(auto ee:e)cout<<ee<<" ";cout<<endl;}}
void print(map<int,int> mp){for(auto e:mp)cout<<e.first<<" "<<e.second<<endl;cout<<endl;}
const int INF=1e6;
const ll int MOD=998244353;

main(){
    int n=in(),k=in();
    int x=in(),y=in();
    int ans=0;
    rep(i,n){
        if(i<k)ans+=x;
        else ans+=y;
    }
    cout<<ans;
}

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

string tolower(string s) {
    for (int i=0; i<(int)s.size(); ++i) {
        s[i] = tolower(s[i]);
    }
    return s;
}

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

    string W, T;
    cin >> W;

    int cnt = 0;
    while (cin >> T, T != "END_OF_TEXT") {
        stringstream ss(T);
        string t;
        while (getline(ss, t, ' ')) {
            cnt += W == tolower(t) ? 1 : 0;
        }
    }

    cout << cnt << endl;

    return 0;
}


Measured memory_bytes: 3228
//----------BHAVIK DIWANI(PICT_COMP)---------------
#include<bits/stdc++.h>
#include<stdlib.h>
#include<stdio.h>
#define test ll t; cin>>t; while(t--)
#define FOR(p,n) for(ll i=p;i<(ll)n;i++)
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define mod 1000000007
#define ll long long
#define int long long
#define ull unsigned long long
#define MAX 1000005
#define pb push_back
#define mkp make_pair
#define vi vector<int>
#define pii pair<int,int>
#define endl '\n'
#define vs vector<string>
#define mii map<int,int>
#define msi map<string,int>
#define vpii vector< pair<int, int > >
#define vpsi vector< pair< string ,int > >
#define forci(p,q) for(int i=p;i<q;i++)
ll gcd(ll a,ll b){ if(b==0) return a;    return gcd(b,a%b);}
ll lcm(ll a,ll b) { return (a/gcd(a,b)*b);}
ull power(ull a, ull b) {a %= mod;  ull res = 1;  while (b > 0) { if (b & 1) res = res * a % mod;  a = a * a % mod;  b >>= 1; }  return res%mod; }
ll modmul(ll x, ll y){return (x*y)%mod;}
ll modadd(ll x, ll y){return (x+y)%mod;}
ll modsub(ll x, ll y){return (x-y+mod)%mod;}
ll fact[1000007]={0};
void facto() {fact[0]=1;fact[1]=1;for(int i=2;i<100007;i++)fact[i]=(fact[i-1]*i)%mod;}
ll ncr(ll n,ll r) {ll res=1; res=fact[n]; res=(res*(power(fact[r],mod-2)))%mod; res=(res*(power(fact[n-r],mod-2)))%mod; return res;}
ll npr(ll n,ll r) {ll res=1; res=fact[n]; res=(res*(power(fact[n-r],mod-2)))%mod; return res;}
inline long long toint(const std::string &s) {std::stringstream ss; ss << s; long long x; ss >> x; return x;}
inline std::string tostring(long long number) {std::stringstream ss; ss << number; return ss.str();}
inline std::string tobin(long long x) {return std::bitset<63>(x).to_string();}
/*bool prime[MAX];
ull sieve(){memset(prime,true,sizeof(prime));for(ull p=2;p*p<MAX;p++){if(prime[p]==true){for(ull i=2*p;i<MAX;i+=p){prime[i]=false;}}}prime[0]=0;prime[1]=0;
}
int inv[1000001]={0};
void findinverse(){inv[1] = 1;for(int i = 2; i <=1e6 ; ++i)	inv[i] = (mod - (mod/i) * inv[mod%i] % mod) % mod;}
*/
using namespace std;
int solve()
{
	int n;	cin>>n;
	int a[n+1],b[n+1],c[n+1];
	forci(1,n+1)	cin>>a[i];
	forci(1,n+1)	cin>>b[i];
	forci(1,n)	cin>>c[i];
	int prev=-1;
	int sat=0;
	for(int i=1;i<=n;i++)
	{
		sat+=b[a[i]];
		if(prev==a[i]-1)
			sat+=c[a[i]-1];
		prev=a[i];
	}
	cout<<sat<<endl;


}
signed main()
{
	fastio;
//	test
		solve();
}




Measured memory_bytes: 256
#include<bits/stdc++.h>
#define M 100008
using namespace std;
int f[M],sum[M],st[M],ne[M];
int zm(int x)
{
	return f[x]==x?x:f[x]=zm(f[x]);
}
void jiebai (int x,int y)
{
	int f1=zm(f[x]),f2=zm(f[y]);
	if(f1!=f2)f[f1]=f2;
	return;
}
int main()
{
	int n,m,k;
	cin>>n>>m>>k;
	for(int i=1;i<=n;++i)f[i]=i;
	for(int i=1;i<=m;++i)
	{
		int a,b;
		cin>>a>>b;
		st[a]++;
		st[b]++;
		jiebai(a,b);
	}
	for(int i=1;i<=n;++i)
	{
		f[i]=zm(i);
		sum[f[i]]++;
	}
	for(int i=1;i<=k;++i)
	{
		int a,b;
		cin>>a>>b;
		if(f[a]==f[b])
		{
			ne[a]++;
			ne[b]++;
		}
	}
	for(int i=1;i<=n;++i)
	{
		int ans=sum[f[i]]-st[i]-ne[i]-1;
		cout<<ans<<" ";
	}
}

Measured memory_bytes: 2688
s = int(input())
if 1 <= s // 100 <= 12:
    if 1 <= s % 100 <= 12:
        print("AMBIGUOUS")
    else:
        print("MMYY")
else:
    if 1 <= s % 100 <= 12:
        print("YYMM")
    else:
        print("NA")


Measured memory_bytes: 38384
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author
 */

#include <iostream>
#include <fstream>

#include "bits/stdc++.h"

#define REP(i,x,y) for(int i=(x);i<(y);i++)
#define RREP(i,x,y) for(int i=(y)-1;i>=(x);i--)
#define all(x) (x).begin(),(x).end()
//#define int long long

using namespace std;

// conversion
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

#define dump(x)  cout << #x << " = " << (x) << endl
#define debug(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl

typedef long long ll;

const ll MOD = 1e9 + 7;

class DTwoSequences {
public:
    void solve(std::istream& in, std::ostream& out) {
        ll N;
        in >> N;
        vector<ll> a(N), b(N);
        REP(i,0,N) in >> a[i];
        REP(i,0,N) in >> b[i];

        ll answer = 0;
        REP(i,0,29) {
            const ll T = 1LL << i;
            vector<ll> modB(N);
            REP(j,0,N) modB[j] = b[j] % (2 * T);
            sort(all(modB));
            ll cnt = 0;
            REP(j,0,N) { // fix a = a[j]
                const ll modA = a[j] % (2 * T);
                // [T, 2T)
                cnt += distance(lower_bound(all(modB), T-modA), lower_bound(all(modB), 2*T-modA));
                // [3T, 4T)
                cnt += distance(lower_bound(all(modB), 3*T-modA), lower_bound(all(modB), 4*T-modA));
            }
            if (cnt % 2 == 1) {
                answer += T;
            }
        }
        out << answer << "\n";
    }
};


signed main() {
    DTwoSequences solver;
    std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 4992
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<bool> vb;
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define INT(str) stoi((str), 0)
#define INTB(str) stoi((str), 0, 2) // 2進数の文字列を int に
 
int main() {
  string s;
  cin >> s;
  cout << (s == "AAA" || s == "BBB" ? "No" : "Yes") << endl;
}

Measured memory_bytes: 256
integer x_1, y_1, x_2, y_2, a, b, x_3, y_3, x_4, y_4
    read *, x_1, y_1, x_2, y_2
    a = x_2 - x_1
    b = y_2 - y_1
    x_3 = x_2 - b
    y_3 = y_2 + a
    x_4 = x_3 - a
    y_4 = y_3 - b
    print *, x_3, y_3, x_4, y_4
END

Measured memory_bytes: 768
using System;

namespace _4_B
{
    class Program
    {
        static void Main(string[] args)
        {
            double x = double.Parse(Console.ReadLine());
            double cir = 2 * x * Math.PI;
            double area = Math.Pow(x, 2) * Math.PI;
            Console.WriteLine("{0:F6} {1:F6}", area, cir);
        }
    }
}



Measured memory_bytes: 19984
import java.util.Scanner;
import java.util.Random;
import java.util.Arrays;
import java.util.Comparator;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

class Main {
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		int n = sc.nextInt();
		int a = sc.nextInt();
		int sum = 0;
		int[] x = new int[n];
		
		for (int i = 0; i < n; i++) {
			x[i] = sc.nextInt();
			if (a - x[i] <= x[i]) {
				sum += (a - x[i])*2;
			} else {
				sum += x[i]*2;
			}
		}
		
		System.out.println(sum);
		
	}
}

Measured memory_bytes: 21844
x,k,d = map(int,input().split())

if x < 0:
    x = -x
if x - k*d > 0:
    print(x-k*d)
    exit()
else:
    l = x//d
    x -= d*l
    k -= l
    if k%2:
        print(abs(x-d))
    else:
        print(abs(x))

Measured memory_bytes: 9176
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
using namespace std;

int main() {
	int n;
	string s;
	cin >> n;
	map<string, int> mp;
	
	for(int i=0; i<n; i++){
		cin >> s;
		if(mp.find(s) == mp.end()){
			mp[s] = 1;
		}else{
			mp[s]++;
		}
	}
	
	int vmax = 0;
	for(auto it=mp.begin(); it!=mp.end(); it++){
		vmax = max(vmax, it->second);
	}
	//cout << vmax << endl;
	for(auto it=mp.begin(); it!=mp.end(); it++){
		if(vmax == it->second){
			cout << it->first << endl;
		}
	}
	return 0;


}

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

int main(){
	
  	long long int X;
  	long long int m = 100;
  	int i = 0;
  
  	cin >> X;
  
  	while(m < X){
    	m *= 1.01;
    	i++;
    }
  
  	cout << i << endl;
  	
  	
  	return 0;
}

Measured memory_bytes: 3632
#define _USE_MATH_DEFINES

#include <iostream>	//cin, cout
#include <vector>	//vector
#include <algorithm> //sort,min,max,count
#include <string>	//string,getline
#include <ios>		//fixed
#include <iomanip>	//setprecision
#include <utility> //swap, pair
#include <cstdlib>	//abs(int)
#include <cmath>	//sqrt,ceil,M_PI, pow, sin
#include <sstream>	//stringstream,getline
#include <numeric>	//gcd, accumlate
#include <deque>	//deque
#include <random>	//randam_device

using namespace std;

int main() {

	int X, A;
	cin >> X >> A;

	if (X < A) {
		cout << 0 << endl;
	}
	else {
		cout << 10 << endl;
	}

	return 0;

}

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

using namespace std;
int n;
int giv[200005];

int main()
{
    scanf("%d",&n);
    int i,j,a=-1,b;
    for(i=1;i<=n;i++)scanf("%d",&giv[i]);
    sort(giv+1,giv+1+n);
    for(i=1;i<n;i++){
        if(abs(giv[n]-2*giv[i])<abs(giv[n]-2*a))a = giv[i];
    }
    printf("%d %d",giv[n],a);
    return 0;
}


Measured memory_bytes: 640
if isfile("mystdin.txt");mystdin=open("mystdin.txt","r");redirect_stdin(mystdin);end
pI(x)=parse(Int,x)
pM(x::Array{SubString{String},1})=map(pI,x)
function main()
  a,b,c,k=parse.(Int,split(readline()))
  ans=iseven(k) ? a-b : b-a
  println(ans)
  # println(ans>10^18 ? "Unfair" : ans)
end
main()
if isdefined(Base, :mystdin);close(mystdin);end

Measured memory_bytes: 171964
#include<iostream>
#define Max 201
using namespace std;

int Gcd[Max][Max];

int gcd(int x,int y){
    if(y>x){
        swap(x,y);
    }

    if(Gcd[x][y]!=0){
        //cout << Gcd[x][y] <<endl;
        return Gcd[x][y];
    }else{
        int x1=x,y1=y,r;
        while(y>0){
            r = x%y;
            x = y;
            y = r;
        }
        //cout << x <<endl;
        Gcd[x1][y1] = x;
        return x;
    }

}
int main(){
    int k,ans=0,g;
    cin >> k;
    for(int i=0;i<=k;i++){
        for(int j=0;j<=k;j++){
            Gcd[i][j] = 0;
        }
    }

    for(int i=1;i<=k;i++){
        for(int j=1;j<=k;j++){
            for(int l=1;l<=k;l++){
                g = gcd(j,l);
                ans += gcd(g,i);
            }
        }
    }
    cout << ans << endl;
}

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

typedef long long ll;
const int N(409);
const ll inf(1e15);

int n, m;
int a[N];
ll f[N][N], sum[N];

ll dfs(int l, int r)
{
	if (l >= r) return 0;
	//if (l == r) return a[l];
	if (f[l][r] < inf) return f[l][r];
	for (int k = l; k < r; k++)
	{
		f[l][r] = min(f[l][r], dfs(l, k) + dfs(k + 1, r) + sum[r] - sum[l - 1]);
	}
	return f[l][r];
}
int main()
{
	cin>>n;
	for (int i = 1; i <= n; i++)
	{
		cin>>a[i];
		sum[i] = sum[i - 1] + a[i];
	}
	for (int i = 1; i <= n; i++)
	{
		for (int j = 1; j <= n; j++)
		{
			f[i][j] = inf;
		}
	}
	cout<<dfs(1, n)<<endl;
	return 0;
}

Measured memory_bytes: 1536
#include <algorithm>
#include <cmath>
#include <iostream>
#include <string>
#include <vector>
typedef long long ll;
#define all(x) (x).begin(), (x).end()  // sortなどの引数を省略
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define max3(x, y, z) max(x, max(y, z))

#ifdef _MSC_FULL_VER  //デバッグ出力
#define dout cout
#define debug() if (true)
#define check(x) std::cout << "★" << #x << "の値:" << (x) << endl
#define pass(x) std::cout << "☆" << x << endl
#else
#define dout \
  if (false) cout
#define debug() if (false)
#define check(x) \
  if (false) cout << "★" << #x << "の値:" << (x) << endl
#define pass(x) \
  if (false) cout << "☆" << x << endl
#endif
using namespace std;
int main() {
  double a,b;
  cin  >> a >> b;
  cout << a/b;
}
  /*
//よく使うやつ
int N;
cin >> N;
vector<int> list(N);
for (int i = 0; i < N; i++) {
cin >> list[i];
}
// for文
for (int i = 0; i < N; i++) {
}
//配列
vector<int> list;
list.at(i)
vector<vector<int>> list(10, vector<int>(10));
sort(all(list));
sort(all(list), greater<int>());
  //配列の内容表示
dout << "====listの内容====\n";
for (int i = 0; i < N; i++) dout << list[i] << endl;
dout << "====ここまで====\n";
*/


Measured memory_bytes: 256