akhauriyash/Code-Regression huggingface dataset:
using System;
using System.IO;
using System.Collections.Generic;
using System.Linq;

namespace MinPro2019D
{
    public class Program
    {
        void Solve(StreamScanner ss, StreamWriter sw)
        {
            //---------------------------------
            var L = ss.Next(int.Parse);

            var dp = new long[5];

            for (var i = 0; i < L; i++)
            {
                var A = ss.Next(long.Parse);

                for (var t = 1; t < 5; t++)
                {
                    dp[t] = Math.Min(dp[t - 1], dp[t]);
                }

                for (var t = 0; t < 5; t++)
                {
                    if (Math.Abs(t - 2) == 0) dp[t] += (A % 2) ^ 1;
                    if (Math.Abs(t - 2) == 1) dp[t] += (A % 2) + (A == 0 ? 2 : 0);
                    if (Math.Abs(t - 2) == 2) dp[t] += A;
                }
            }

            sw.WriteLine(dp.Min());
            //---------------------------------
        }

        static void Main()
        {
            var ss = new StreamScanner(new StreamReader(Console.OpenStandardInput()));
            var sw = new StreamWriter(Console.OpenStandardOutput()) {AutoFlush = false};
            new Program().Solve(ss, sw);
            sw.Flush();
        }

        static readonly Func<string, string> String = s => s;
    }

    public class StreamScanner
    {
        static readonly char[] Sep = {' '};
        readonly Queue<string> buffer = new Queue<string>();
        readonly TextReader textReader;

        public StreamScanner(TextReader textReader)
        {
            this.textReader = textReader;
        }

        public T Next<T>(Func<string, T> parser)
        {
            if (buffer.Count != 0) return parser(buffer.Dequeue());
            var nextStrings = textReader.ReadLine().Split(Sep, StringSplitOptions.RemoveEmptyEntries);
            foreach (var nextString in nextStrings) buffer.Enqueue(nextString);
            return Next(parser);
        }

        public T[] Next<T>(Func<string, T> parser, int x)
        {
            var ret = new T[x];
            for (var i = 0; i < x; ++i) ret[i] = Next(parser);
            return ret;
        }

        public T[][] Next<T>(Func<string, T> parser, int x, int y)
        {
            var ret = new T[y][];
            for (var i = 0; i < y; ++i) ret[i] = Next(parser, x);
            return ret;
        }
    }
}

Measured memory_bytes: 17472
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>

using namespace std;

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

	string ans = "";
	if (b == "A")
	{
		ans = "T";
	}
	else if (b == "T")
	{
		ans = "A";
	}
	else if (b == "C")
	{
		ans = "G";
	}
	else
	{
		ans = "C";
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
//#pragma GCC optimize ("O3")
//#pragma GCC target ("avx")
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define Would
#define you
#define please

constexpr int bm = 2500;
ll BIT[50][bm];
int zero[50];
//priority_queue<ll> PQ;
const int AS = 50000;
class saidai_tekitou_heap {
public:
	int HS = 0;
	const ll IM = -8e18;
	ll dat[AS * 2 + 2];
	saidai_tekitou_heap() : dat() {
		dat[0] = -IM;
		rep1(i, AS * 2 + 1) dat[i] = IM;
	}
	void push(ll v) {
		int p = ++HS;
		while (v > dat[p >> 1]) dat[p] = dat[p >> 1], p >>= 1;
		dat[p] = v;
	}
	ll pop() {
		if (HS == 1) {
			HS = 0;
			return dat[1];
		}
		ll ret = dat[1];
		ll v = dat[HS];
		dat[HS--] = IM;
		int j = 2 + (dat[2] < dat[3]);
		while (v < dat[j]) {
			dat[j >> 1] = dat[j];
			j <<= 1;
			j += dat[j] < dat[j + 1];
		}
		dat[j >> 1] = v;
		return ret;
	}
} PQ;
inline ll query(int A, int gin) {
	ll kotae = 0;
	while (gin < bm) {
		kotae = max(BIT[A][gin], kotae);
		gin += gin & -gin;
	}
	return kotae;
}
inline void query2(int A, int gin, ll ti) {
	int tmp = gin;
	while (gin < bm) {
		if (BIT[A][gin] >= ti) return;
		gin += gin & -gin;
	}
	gin = tmp;
	while (gin > 0) {
		if (BIT[A][gin] >= ti) break;
		BIT[A][gin] = ti;
		gin -= gin & -gin;
	}
	PQ.push(ti << 18 | A << 12 | tmp);
}

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


	int N, M, S;
	cin >> N >> M >> S;
	if (S >= 2460) S = 2460;

	vector<ll> E[50];
	rep(i, M) {
		int u, v, a;
		ll b;
		cin >> u >> v >> a >> b;
		u--;
		v--;
		b = a << 8 | b << 16;
		E[u].pb(v | b);
		E[v].pb(u | b);
	}
	int C[50], D[50];
	rep(i, N) {
		cin >> C[i] >> D[i];
	}

	query2(0, S + 1, 4e12);
	ll zenbu = 0;
	ll owari = (1ll << N) - 1;

	while (PQ.HS) {
		auto p = PQ.pop();
		ll ti = p >> 18;
		int i = p >> 12 & 63;
		int gin = p & 4095;
		if (ti < query(i, gin)) continue;

		ll ti2 = ti - D[i];
		int gin2 = gin + C[i];
		if (gin2 > 2460) gin2 = 2460;
		query2(i, gin2, ti2);

		for (auto pp : E[i]) {
			int to = pp & 255;
			ti2 = ti - (pp >> 16);
			gin2 = gin - (pp >> 8 & 255);
			if (gin2 > 0) query2(to, gin2, ti2);
		}
		zenbu |= 1ll << i;
		if (zenbu == owari) break;
	}

	for (int i = 1; i < N; i++) {
		co(ll(4e12 - query(i, 1)));
	}



	Would you please return 0;
}

Measured memory_bytes: 5336
#if !defined(__clang__) && defined(__GNUC__)
#include <bits/stdc++.h>
#else
#include <cstdlib>
#include <climits>
#include <iostream>
#include <cstdint>
#include <vector>
#include <string>
#include <complex>
#include <bitset>
#include <queue>
#include <deque>
#include <stack>
#include <utility>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <regex>
#endif //  !defined(__clang__) && defined(__GNUG__)
#include <boost/lexical_cast.hpp>
#include <boost/algorithm/string.hpp>
#include <boost/multi_array.hpp>
#include <boost/optional.hpp>
#include <boost/math/common_factor_rt.hpp>

using namespace std;

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

    std::stack<char> stack;

    for (size_t i = 0; i < S.size(); ++i) {
        const char c = S[i];
        if (stack.empty()) {
            stack.push(S[i]);
        }
        else {
            const char top = stack.top();
            if (c == 'T' && top == 'S') {
                stack.pop();
            }
            else {
                stack.push(c);
            }
        }
    }

    std::cout << stack.size() << std::endl;

    return 0;
}


Measured memory_bytes: 644
#include<bits/stdc++.h>
#include<algorithm>
using namespace std;
int main(){
  int n;
  cin>>n;
  int a[200005];
  for(int i=0;i<n;i++)cin>>a[i];
  sort(a,a+n);
  int ans=unique(a,a+n)-a;
  if(ans==n)
  {
  	cout<<"YES"<<endl;
   }
   else
   cout<<"NO"<<endl; 
  } 

Measured memory_bytes: 4296
#include <stdio.h>
#include <algorithm>
using namespace std;

typedef long long int ll;
constexpr ll kInf = ll(1E18 + 10);

ll extgcd(ll a, ll b, ll &x, ll &y) { // a * x - b * y = gcd
	if (b == 0) {
		x = 1;
		y = 0;
		return a;
	}
	else {
		ll tx, ty;
		ll gcd = extgcd(b, a % b, tx, ty);
		// b * tx - (a % b) * ty = gcd
		// b * tx - (a - a / b * b) * ty = gcd
		// b * tx - a * ty + a / b * b * ty = gcd
		// a * -ty + b * (tx + a / b * ty) = gcd
		x = -ty;
		y = -(tx + a / b * ty);
		
		y %= a;
		x = (gcd + b * y) / a;
		if (y <= 0) {
			x += b;
			y += a;
		}
		return gcd;
	}
}

ll check(ll p, ll q) {
	//p * x - q * y = 1
	ll x, y;
	if (extgcd(p, q, x, y) > 1) return kInf;
	else {
		return q * y;
	}
}

int main() {
	ll n, ans;
	scanf("%lld", &n);
	n <<= 1;
	ans = n;
	for (ll i = 1; i * i <= n; i++) if (n % i == 0) 
		ans = min(ans, min(check(i, n / i), check(n / i, i)));
	printf("%lld\n", ans);
}


Measured memory_bytes: 1732
#include <bits/stdc++.h>
using namespace std;
#define lint long long
#define P pair<int, int>

int main(){
    vector<int> cnt = {0, 0, 0, 0};
    
    for(int i = 0; i < 3; ++i){
        int a, b;
        cin >> a >> b;
        cnt[a - 1]++;
        cnt[b - 1]++;
    }
    
    sort(cnt.begin(), cnt.end());
    
    if(cnt == (vector<int>){1, 1, 2, 2}){
        cout << "YES" << endl;
    } else {
        cout << "NO" << endl;
    }
    
}

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

int main() {
    int x, y;
    cin >> x >> y;
    for(int i = 1; i <= x; i++) {
        int j = x - i;
        if(y == (i * 2 + j * 4)) {
            cout << "Yes" << endl;
            return 0;
        }
        if(y == (i * 4 + j * 2)) {
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 3596
#include<cstdio>
#include<algorithm>
using namespace std;
int main()
{
	long long a,b,c;
	scanf("%lld%lld%lld",&a,&b,&c);
	if(!(a&1) || !(b&1) || !(c&1))
	{
		puts("0");
	}
	else
	{
		printf("%lld\n",min(min(a*b,b*c),a*c));
	}
	return 0;
}
/*
3 3 3
*/
/*
2 2 4
*/
/*
5 3 5
*/


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

const ll MOD = 1e9+7;

ll dp[100010][4];

int main(){
    string s ; cin >> s;
    int n=s.size();
    for(int i=n;i>=0;i--){
        for(int j=3;j>=0;j--){
            if(i==n){
                if(j==3) dp[i][j] = 1;
                else dp[i][j] = 0;
            }else{
                if(s[i]=='?') dp[i][j] = 3 * dp[i+1][j];
                else dp[i][j] = dp[i+1][j];
                if(j < 3 && (s[i]=='?'|| s[i] == "ABC"[j]) ){
                    dp[i][j] += dp[i+1][j+1];
                }
            }
            dp[i][j] %= MOD;
        }
    }
    cout << dp[0][0] << endl;
}

Measured memory_bytes: 6856
#include <bits/stdc++.h>
using namespace std;
struct Fast {Fast(){std::cin.tie(0);ios::sync_with_stdio(false);cout.precision(20);}} fast;

/* define */
#define FOR(I,X,Y) for(long long (I)=(X);(I)<(Y);(I)++)
#define REP(I,X,Y) for(long long (I)=(Y)-1;(I)>=(X);(I)--)
#define ALL(X) (X).begin(),(X).end()
#define pb push_back
#define COUNT(V,X) (upper_bound((V).begin(),(V).end(),X)-lower_bound((V).begin(),(V).end(),X))
#define debug(x) cerr<<#x<<':'<<x<<endl;
#define DEBUG(v) cerr<<#v<<':';for(auto xXx:v)cerr<<xXx<<' ';cerr<<endl;
#define Yes(X) if(X){cout<<"Yes"<<endl;}else{cout<<"No"<<endl;}
#define YES(X) if(X){cout<<"YES"<<endl;}else{cout<<"NO"<<endl;}
#define ctoi(C) (C-'0')
#define pow2(x) ((long long)((long long)1<<x))

/* alias */
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vii = vector<vector<int>>;
using vl = vector<long long>;
using vll = vector<vector<long long>>;
using pi = pair<int,int>;
using pl = pair<long long,long long>;
template<typename T> using PQ = priority_queue<T>;
template<typename T> using minPQ = priority_queue<T, vector<T>, greater<T>>;

/* const */
const long long dx[] = {1,0,-1,0};
const long long dy[] = {0,1,0,-1};
const long long dx8[] = {1,1,0,-1,-1,-1,0,1};
const long long dy8[] = {0,1,1,1,0,-1,-1,-1};
const long long dx9[] = {1,1,0,-1,-1,-1,0,1,0};
const long long dy9[] = {0,1,1,1,0,-1,-1,-1,0};
const int INF = 1000000007;
const long long LINF = 1000000000000000007;

/* func */
template <typename T> inline bool chmin(T& a, const T& b) {if (a > b) a = b; return a > b;}
template <typename T> inline bool chmax(T& a, const T& b) {if (a < b) a = b; return a < b;}
long long max(long long x,int y){return max(x,(long long)y);}
long long max(int x,long long y){return max((long long)x,y);}
long long min(long long x,int y){return min(x,(long long)y);}
long long min(int x,long long y){return min((long long)x,y);}

/* liblary */



/* main */

signed main(){
	string S;
	cin >> S;
	map<char,bool> m;
	FOR(i,0,S.size()){
		m[S[i]] = 1;
	}
	Yes(!(m['N']^m['S']||m['W']^m['E']));
}

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

long long int k,a[2*100002],n,first,last,mini=1000008,dis;
main(){

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

for(int i=0;i<n;i++){
     if(i<(n-1)){
        first=a[i],last=a[i+1];
        dis=k-(last-first);
        if(dis<mini) mini=dis;

    }
    else  {
        first=a[i],last=a[0];
        if(a[1]<first){
        dis=(first-last);
        if(dis<mini) mini=dis;}
        else {
            dis=k-(first-last);
            if(dis<mini) mini=dis;
        }


        }
    }




cout<<mini<<endl;







}

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

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

  int n;
  string ans = "";
  std::cin >> n;

  if(n==0){
    std::cout << "0" << endl;
    return 0;
  }

  while(n!=0){
    if(n%2){
      ans="1"+ans;
      n--;
    }
    else ans="0"+ans;
    n /=-2;
  }

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


Measured memory_bytes: 1016
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int a,b,c[3],k=-1001,i;
	scanf("%d%d",&a,&b);
	c[0]=a+b;
	c[1]=a-b;
	c[2]=a*b;
	for(i=0;i<3;i++)
	{
		if(c[i]>=k)
		{
			k=c[i];
		}
	}
	printf("%d",k);
	return 0;	
 } 

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <deque>
#include <queue>
#include <array>
#include <set>
#include <map>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <utility>
#include <tuple>
#include <functional>
#include <bitset>
#include <cstdint>
#include <cassert>
#include <random>

using namespace std;
using i64 = int64_t;
using i32 = int32_t;
template<class T, class U> void init_n(vector<T>& v, size_t n, U x) 
{ v = vector<T>(n, x); }
template<class T> void init_n(vector<T>& v, size_t n) { init_n(v, n, T()); }
template<class T> void read_n(vector<T>& v, size_t n, size_t o = 0) 
{ v = vector<T>(n+o); for (size_t i=o; i<n+o; ++i) cin >> v[i]; }
template<class T> void read_n(T a[], size_t n, size_t o = 0)
{ for (size_t i=o; i<n+o; ++i) cin >> a[i]; }
template<class T> T iabs(const T& x) { return max(x, -x); }
// #define abs gabs

int main() {
    i64 h;
    cin >> h;
    i64 k = 1, ans = 0;
    while (h > 0) {
        ans += k;
        k *= 2;
        h /= 2;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
N=int(input())
S=input()
R=S.count('R')
G=S.count('G')
B=S.count('B')
ans=R*G*B
for d in range(N):
    if 2*d>=N:
        break
    for i in range(N):
        if i+2*d>=N:
            break
        if S[i]!=S[i+d] and S[i+d]!=S[i+2*d] and S[i]!=S[i+2*d]:
            ans-=1
print(ans)

Measured memory_bytes: 9124
import math
a,b,x = [int(x) for x in input().split()]
if a*a*b/2>=x:
    z = a*b*b/2/x
    s = math.atan(z)
    print(math.degrees(s))
else:
    z = 2 * (a**2*b-x) / a**3
    s = math.atan(z)
    print(math.degrees(s))

Measured memory_bytes: 38640
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] h = new int[n + 1];
        for (int i = 0; i < n; i++) {
            h[i] = sc.nextInt();
        }
        h[n] = 0;
        
        int count = 0;
        for (int i = 0; i < n; i++) {
            if (h[i] == 0) continue;
            int min = h[i];
            
            for (int j = i + 1; j <= n; j++) {
                if (h[j] != 0) {
                    min = Math.min(min, h[j]);
                } else {
                    for (int k = i; k <= j - 1; k++) {
                        h[k] -= min;
                    }
                    count += min;
                    if (h[i] != 0) {
                        i--;
                    }
                    break;
                }
            }
        }
        
        System.out.println(count);
    }
}


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

using i64 = int64_t;

int main(){
    int n;
    cin >> n;
    string s;
    cin >> s;
    int ans = 1;
    for(int i=1;i<s.size();++i){
        if(s[i] != s[i-1])ans++;
    }
    cout << ans << endl;

    return 0;
}


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

double a, b, c, d, e, f;
int main()
{
	while(std::cin>>a>>b>>c>>d>>e>>f)
	{
		double x = (e*c-b*f)/(a*e-b*d);
		double y = (-d*c+a*f)/(a*e-b*d);
		printf("%.3lf %.3lf\n",x+(1e-10),y+(1e-10));
	}
	return 0;
}

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

#define rep(i, n) for(int i = 0; i<(n); i++)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;

const int MOD = 1000000007;

int main() {
    int N, T;
    cin >> N >> T;
    int ans = 100100;
    int c, t;
    rep(i, N) {
        cin >> c >> t;
        if (t <= T) {
            chmin(ans, c);
        }
    }

    if (ans == 100100) {
        cout << "TLE" << endl;
    } else {
        cout << ans << endl;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
	int n,k;
	cin>>n>>k;
	int f[200]={0};
	for(int i=1;i<=k;i++){
		int t;
		cin>>t;
		int d;
		while(t--){
			cin>>d;
			f[d]=1;
		}
	}
	int cnt=0;
	for(int i=1;i<=n;i++){
		if(f[i]==0)cnt++;
	}
	printf("%d\n",cnt);
	return 0;
}

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

using namespace std;
#define all(a)a.begin(),a.end()
using ll=long long;
const int INF = 1<<30;
const ll INFll =1LL<<62;
const int mod= int(1e9)+7;
using P = pair<ll,ll>;
using ld=long double;

int main(){
   ll h,w;
   cin >>h>>w;
   vector<string>s(h);
    for (int i = 0; i < h; ++i) {
        cin >>s[i];
    }
   ll white=0;
    for (int i = 0; i < h; ++i) {
        for (int j = 0; j < w; ++j) {
            if(s[i][j]=='.')white++;
        }
    }
   vector<vector<ll>>d(h,vector<ll>(w,INF));
   queue<P>que;
   d[0][0]=0;
   ll dx[4]={0,0,1,-1};
   ll dy[4]={1,-1,0,0};
   que.push({0,0});
   while(!que.empty()){
       P pos=que.front();
       que.pop();
       ll x=pos.first;
       ll y=pos.second;
       for (int i = 0; i < 4; ++i) {
           if(x+dx[i]<0||x+dx[i]>=w)continue;
           if(y+dy[i]<0||y+dy[i]>=h)continue;
           ll tox=x+dx[i];
           ll toy=y+dy[i];
           ll pre=d[y][x];
           if(s[toy][tox]=='#')continue;
           if(d[toy][tox]>pre+1){
               que.push({tox,toy});
               d[toy][tox]=pre+1;
           }
       }
   }
   h--;w--;
   if(d[h][w]==INF)cout <<-1<<endl;
   else {
    cout <<white-d[h][w]-1<<endl;
   }
   return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
using namespace std;
typedef long long ll;
const int N=510;
ll a[N][N],qz[N][N],f[N][N],qz2[N][N];
ll mymin(ll x,ll y) {return x<y?x:y;}
int main()
{
	int n;scanf("%d",&n);
	for(int i=1;i<=n;i++)
		for(int j=1;j<=n;j++){
			if(i==j) continue;
			scanf("%d",&a[i][j]);
		}
	for(int i=1;i<=n;i++)
		for(int j=1;j<=n;j++){
			qz[i][j]=qz[i-1][j]+qz[i][j-1]-qz[i-1][j-1]+a[i][j];
			qz2[i][j]=qz2[i-1][j]+qz2[i][j-1]-qz2[i-1][j-1]+(i<j?a[i][j]:0);
		}
	memset(f,60,sizeof(f));
	f[0][1]=0;
	for(int i=0;i<=n-1;i++)
		for(int j=i+1;j<=n;j++)
			for(int k=j+1;k<=n+1;k++){
				ll t1=qz[n][j-1]-qz[k-1][j-1]-qz[n][(i>0?i-1:0)]+qz[k-1][(i>0?i-1:0)];
				ll t2=qz2[k-1][k-1]-qz2[j-1][k-1]-qz2[k-1][j-1]+qz2[j-1][j-1];
				f[j][k]=mymin(f[j][k],f[i][j]+t1+t2);
			}
	ll Ans=1e18;
	for(int i=0;i<=n;i++) Ans=mymin(Ans,f[i][n+1]);
	printf("%lld\n",Ans);
	return 0;
}

Measured memory_bytes: 9728
import math
import sys
import random
from operator import itemgetter
input = sys.stdin.readline

# a = int(input().rstrip())
# a, b = map(int, input().rstrip().split())
# D = list(map(int, input().rstrip().split()))
# H = [int(input().rstrip()) for _ in range(L)]
# DD = [[0 for j in range(100)] for i in range(200)]
# dict = {} ## dictionary

# a = sorted(a, key=lambda x: x[1]))
# if __name__ == '__main__':


a, b = map(int, input().rstrip().split())

if b % a == 0:
	print(a+b)
else:
	print(b-a)

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

#define REP(i,n) for(ll i=0; i<(ll)(n); i++)
#define FOR(i,n,m) for (ll i=n; i<(ll)(m); i++)
#define pb push_back
#define INF 1000000007LL
#define all(a) (a).begin(),(a).end()

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

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

#define MAX_N 100000

int N, x;
int main(){
    ios::sync_with_stdio(false);
    cin >> N >> x;
    int n = 2 * N - 1;
    if ( !(2<=x && x<=n-1) ) {
        cout << "No" << endl;
        return 0;
    }
    cout << "Yes" << endl;
    if(N==2) {
        cout << "1" << endl;
        cout << "2" << endl;
        cout << "3" << endl;
        return 0;
    }
    map<int,int> a;
    vector<int> b;
    if(x==2) {
        a[3]=1;
        a[2]=1;
        a[1]=1;
        a[4]=1;
        b = {3,2,1,4};
    }
    else {
        a[x-1]=1;
        a[x]=1;
        a[x+1]=1;
        a[x-2]=1;
        b = {x-1,x,x+1,x-2};
    }
    vector<int> per;
    FOR(i,1,2*N) {
        per.pb(i);
    }
    int cur = 0;
    FOR(i,1,2*N) {
        while(a[per[cur]]){
            cur++;
        }
        if (N-1<= i && i <=N+2) {
            cout << b[i-N+1] << endl;
        }
        else {
            cout << per[cur] << endl;
            cur++;
        }
    }
    
    return 0;
}

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

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

  vector<int> house(N); // N個の家のデータ

  // 家の北端からの距離のデータを受け取る
  for (int i = 0; i < N; i++) {
    cin >> house.at(i);
  }
  
  int X = house.at(N-1)-house.at(0);;
  int Z = 0;

  // 最初の家と最後の家の距離が全周の半分より小さい場合はそれがX
  
  if ( X <= (K/2) ){
    X = house.at(N-1)-house.at(0);
  }
  
  else{
  // 全ての隣あう家と家の距離のうち最も大きい部分がとるべき値の最初と最後
    
  for (int i = 0; i < N-1; i++) {
    if((house.at(i+1)-house.at(i))>=Z){
      Z = house.at(i+1)-house.at(i);
      X = K-house.at(i+1)+house.at(i);
    }
  }
    if((K-house.at(N-1)+house.at(0))>=Z){
      Z = house.at(N-1)-house.at(N-2);
      X = house.at(N-1)-house.at(0);
    }
  }
  
  
  cout << X << endl;

}

Measured memory_bytes: 1152
using System;
using System.Collections.Generic;
using System.Collections;
using System.Collections.Specialized;
using System.Linq;
using System.Text;
using System.IO;
using System.Reflection;
using static System.Math;
using System.Numerics;
static class Program{
	const int mod=(int)1e9+7;
	static void Main(){
		Sc sc=new Sc();
		var s=sc.Ia;
		var c=new int[s[1]];
		var b=new int[s[1]];
		for(int i = 0;i<s[1];i++) {
			var e=sc.Ia;
			c[i]=e[0];
			var h=sc.Ia;
			for(int j = 0;j<e[1];j++) {
				b[i]|=1<<(h[j]-1);
			}
		}
		int m=1<<s[0];
		var dp=new long[m];
		long inf=long.MaxValue/2;
		for(int i = 1;i<m;i++) {
			dp[i]=inf;
			for(int j = 0;j<s[1];j++) {
				if((i&b[j])!=0){
					dp[i]=Min(dp[i],dp[i^(i&b[j])]+c[j]);
				}
			}
		}
		Console.WriteLine("{0}",inf==dp[m-1]?-1:dp[m-1]);
	}
}

public class Sc{
	public int I{get{return int.Parse(Console.ReadLine());}}
	public long L{get{return long.Parse(Console.ReadLine());}}
	public double D{get{return double.Parse(Console.ReadLine());}}
	public string S{get{return Console.ReadLine();}}
	public int[] Ia{get{return Array.ConvertAll(Console.ReadLine().Split(),int.Parse);}}
	public long[] La{get{return Array.ConvertAll(Console.ReadLine().Split(),long.Parse);}}
	public double[] Da{get{return Array.ConvertAll(Console.ReadLine().Split(),double.Parse);}}
	public string[] Sa{get{return Console.ReadLine().Split();}}
	public object[] Oa{get{return Console.ReadLine().Split();}}
	public int[] Ia2{get{return Array.ConvertAll(("0 "+Console.ReadLine()+" 0").Split(),int.Parse);}}
	public int[] Ia3(int a){return Array.ConvertAll((a.ToString()+" "+Console.ReadLine()).Split(),int.Parse);}
	public int[] Ia3(bool a,int b,bool c,int d){return Array.ConvertAll(((a?b.ToString()+" ":"")+Console.ReadLine()+(c?" "+d.ToString():"")).Split(),int.Parse);}
	public long[] La2{get{return Array.ConvertAll(("0 "+Console.ReadLine()+" 0").Split(),long.Parse);}}
	public long[] La3(int a){return Array.ConvertAll((a.ToString()+" "+Console.ReadLine()).Split(),long.Parse);}
	public long[] La3(bool a,int b,bool c,int d){return Array.ConvertAll(((a?b.ToString()+" ":"")+Console.ReadLine()+(c?" "+d.ToString():"")).Split(),long.Parse);}
	public T[] Arr<T>(int n,Func<T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f();}return a;}
	public T[] Arr<T>(int n,Func<int,T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f(i);}return a;}
	public T[] Arr<T>(int n,Func<string[],T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f(Console.ReadLine().Split());}return a;}
	public T[] Arr<T>(int n,Func<int,string[],T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f(i,Console.ReadLine().Split());}return a;}
}

Measured memory_bytes: 13268
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i, n) for(int i=0;i<(int)n;i++)
struct edge{int from, to;};

int main(){
    int n,k;
    cin>>n>>k;
    int i=0, ans=1;
    while(i<n){
        if(ans<k) ans*=2;
        else ans+=k;
        ++i;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;

public class Main {
	public static void main(String[] args) {
		FastScanner sc = new FastScanner(System.in);
		PrintWriter pw = new PrintWriter(System.out);
		char[] s = sc.next().toCharArray();
		boolean ch = true;
		for(int i = 0; i < s.length; i++) {
			if(s.length %2 != 0) {
				ch = false;
				break;
			}
			char c = s[i];
			if((i%2 == 1 && c != 'i')||(i%2 == 0 && c != 'h')) {
				ch = false;
				break;
			}
			
		}
		
		if(ch) pw.print("Yes");
		else pw.print("No");
		
		pw.close();
	}
	
	static class FastScanner {
		private BufferedReader reader = null;
	    private StringTokenizer tokenizer = null;
	    public FastScanner(InputStream in) {
	        reader = new BufferedReader(new InputStreamReader(in));
	        tokenizer = null;
	    }

	    public String next() {
	        if (tokenizer == null || !tokenizer.hasMoreTokens()) {
	            try {
	                tokenizer = new StringTokenizer(reader.readLine());
	            } catch (IOException e) {
	                throw new RuntimeException(e);
	            }
	        }
	        return tokenizer.nextToken();
	    }

	    public String nextLine() {
	        if (tokenizer == null || !tokenizer.hasMoreTokens()) {
	            try {
	                return reader.readLine();
	            } catch (IOException e) {
	                throw new RuntimeException(e);
	            }
	        }

	        return tokenizer.nextToken("\n");
	    }

	    public long nextLong() {
	        return Long.parseLong(next());
	    }

	    public int nextInt() {
	        return Integer.parseInt(next());
	    }

	    public double nextDouble() {
	         return Double.parseDouble(next());
	     }

	    public int[] nextIntArray(int n) {
	        int[] a = new int[n];
	        for (int i = 0; i < n; i++)
	            a[i] = nextInt();
	        return a;
	    }

	    public long[] nextLongArray(int n) {
	        long[] a = new long[n];
	        for (int i = 0; i < n; i++)
	            a[i] = nextLong();
	        return a;
	    }
	}
}

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

int main(){
  ll N;
  cin >> N;
  
  vector<ll> F0(N), F1(N);
  for (int i = 0; i < N; i++){
    ll x, y;
    cin >> x >> y;
    F0.at(i) = x - y;
    F1.at(i) = x + y;
  }
  
  sort(F0.begin(), F0.end());
  sort(F1.begin(), F1.end());
  
  ll F0_ans = F0.at(N - 1) - F0.at(0);
  ll F1_ans = F1.at(N - 1) - F1.at(0);
  
  ll ans = max(F0_ans, F1_ans);
  cout << ans << endl;
}

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

#define rep(i, a, b) for (ll i = (a); i < (b); i++)
typedef uint64_t ull;
typedef int64_t ll;
typedef std::pair<ll, ll> PLL;

using namespace std;

signed main() {
  struct r {
    ll deli,id;
    string city;
  };
  ll n;
  cin>>n;
  vector<r> v(n);
  rep(i,0,n){
    cin>>v[i].city>>v[i].deli;
    v[i].id = i+1;
  }
  sort(begin(v),end(v),[](const r &x, const r &y){
        if (x.city != y.city)
          return x.city < y.city;
        else
          return x.deli > y.deli;
      });
  rep(i,0,n){
    cout<<v[i].id<<endl;
  }
  return 0;
}


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

using namespace std;
typedef long long ll;
#define int ll

template<typename T1,typename T2> inline void chmin(T1 &a, T2 b){ if(a > b) a = b; }
template<typename T1,typename T2> inline void chmax(T1 &a, T2 b){ if(a < b) a = b; }

#define REP(i,n) for(int i=0;i<n;++i)
#define SORT(name) sort(name.begin(), name.end())
#define ZERO(p) memset(p, 0, sizeof(p))
#define MINUS(p) memset(p, -1, sizeof(p))
#if 1
#  define DBG(fmt, ...) printf(fmt, ##__VA_ARGS__)
#else
#  define DBG(fmt, ...)
#endif

const ll LLINF = (1LL<<60);
const int INF = (1LL<<30);
const double DINF = std::numeric_limits<double>::infinity();
const int MOD = 1000000007;
const int MAX_N = 100010;

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

    int X;
    cin >> X;

    if(X >= 30) {
        printf("Yes\n");
    }
    else {
        printf("No\n");
    }

    return 0;
}


Measured memory_bytes: 3608
#include <bits/stdc++.h>
/*
#include<algorithm>
#include<array>
#include<cassert>
#include<cmath>
#include<cstdlib>
#include<functional>
#include<iomanip>
#include<iostream>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<stack>
#include<string>
#include<typeinfo>
#include<utility>
#include<vector>
*/
#define int long long int
#define double long double
using namespace std;
#define MOD 1000000007
#define INF 1000000000000000007
const int MAX_N = 1 << 17;
#define rep(i, n) for (int(i) = 0, i##_len = (n); (i) < i##_len; (i)++)
#define reps(i, x) for (int(i) = 1; (i) <= (int)(x); (i)++)
#define rrep(i, x) for (int(i) = ((int)(x)-1); (i) >= 0; (i)--)
#define rreps(i, x) for (int(i) = ((int)(x)); (i) > 0; (i)--)
#define FOR(i, a, b) for (int(i) = (a); (i) < (b); (i)++)
#define pb push_back
#define mp make_pair
#define bit(n) ((int)(1) << (n))
#define all(x) (x).begin(), (x).end()
#define debug(x) std::cout << #x << ": " << (x) << std::endl
#define nint int
using namespace std;

int dy[] = {0, 0, 1, -1, 0};
int dx[] = {1, -1, 0, 0, 0};
typedef pair<int, int> pii;
typedef pair<double, double> dop;
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 gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
struct aaa {
    aaa()
    {
        cin.tie(0);
        ios::sync_with_stdio(0);
        cout << fixed << setprecision(20);
    };
} aaaaaaa;

struct node{
    int count = 0;
    std::vector<int> nextnode;
};

int pusher(std::vector<node> &nodelist, int now, int prev, int sum){
    if(nodelist[now].nextnode.size() == 0){
        return 0; 
    } else {
        nodelist[now].count += sum;
        int nowsum = nodelist[now].count;
        for(int i = 0; i < nodelist[now].nextnode.size(); i++){
            int next = nodelist[now].nextnode[i];
            if(prev == next){
                continue;
            }
            pusher(nodelist, next, now, nowsum);
        }
    }
    return 0;
}


signed main()
{
    int n,q;
    cin >> n >> q;
    std::vector<node> nodelist(n);
    for(int i = 0; i < n - 1; i++){
        int a,b;
        cin >> a >> b;
        a--;
        b--;
        nodelist[a].nextnode.pb(b);
        nodelist[b].nextnode.pb(a);
    }
    for(int i = 0; i < q; i++){
        int p,x;
        cin >> p >> x;
        p--;
        nodelist[p].count += x;
    }
    pusher(nodelist,0,-1,0);
    for(int i = 0; i < n; i++){
        cout << nodelist[i].count << " ";
    }
    cout << endl;
    return 0;
}

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

using namespace std;

const int N = 100'000;

vector<int> g[N];

bool visited[N];
int dp[N];
int ans = 0;

void dfs(int u) {
    visited[u] = true;
    for (int v : g[u]) {
        if (!visited[v]) dfs(v);
        dp[u] = max(dp[u], dp[v] + 1);
    }
    ans = max(ans, dp[u]);
}

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

    int n, m;
    cin >> n >> m;
    for (int i = 0; i < m; ++i) {
        int x, y;
        cin >> x >> y;
        --x, --y;
        g[x].push_back(y);
    }

    for (int u = 0; u < n; ++u) {
        if (!visited[u]) dfs(u);
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 8320
#include <iostream>
#include <utility>
#include <vector>
#include <iomanip>
#include <cmath>
using namespace std;

#define ll long long

int main() {
	ll xs, ys, xt, yt;
	cin >> xs >> ys >> xt >> yt;
	int N; cin >> N;
	vector<pair<pair<ll, ll>, ll>> mp;
	mp.push_back(make_pair(make_pair(xs, ys), 0));
	for(int i=1; i<=N; ++i){
	    ll x, y, r;
	    cin >> x >> y >> r;
	    mp.push_back(make_pair(make_pair(x, y), r));
	}
	mp.push_back(make_pair(make_pair(xt, yt), 0));
	vector<double> dist(N+2, 1e20);
	vector<bool> used(N+2, false);
	used[0]=true;
	int now=0;
	dist[0]=0.0;
	while(now<=N){
	    int mn=-1;
	    for(int i=1; i<=N+1; ++i){
	        if(!used[i]){
	            ll p=mp[i].first.first-mp[now].first.first, q=mp[i].first.second-mp[now].first.second;
	            dist[i]=min(dist[i], dist[now]+max(0.0, sqrt(p*p+q*q)-(mp[i].second+mp[now].second)));
	            if(mn<0) mn=i;
	            else if(dist[mn]>dist[i]) mn=i;
	        }
	    }
	    used[mn]=true;
	    now=mn;
	}
	cout << setprecision(15) << dist[N+1] << endl;
	return 0;
}


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

using DD = double;
const DD INF = 1LL<<60;      // to be set appropriately
const DD EPS = 1e-10;        // to be set appropriately
const DD PI = acosl(-1.0);
DD torad(int deg) {return (DD)(deg) * PI / 180;}
DD todeg(DD ang) {return ang * 180 / PI;}

/* Point */
struct Point {
    DD x, y;
    Point(DD x = 0.0, DD y = 0.0) : x(x), y(y) {}
    friend ostream& operator << (ostream &s, const Point &p) {return s << '(' << p.x << ", " << p.y << ')';}
};
inline Point operator + (const Point &p, const Point &q) {return Point(p.x + q.x, p.y + q.y);}
inline Point operator - (const Point &p, const Point &q) {return Point(p.x - q.x, p.y - q.y);}
inline Point operator * (const Point &p, DD a) {return Point(p.x * a, p.y * a);}
inline Point operator * (DD a, const Point &p) {return Point(a * p.x, a * p.y);}
inline Point operator * (const Point &p, const Point &q) {return Point(p.x * q.x - p.y * q.y, p.x * q.y + p.y * q.x);}
inline Point operator / (const Point &p, DD a) {return Point(p.x / a, p.y / a);}
inline Point conj(const Point &p) {return Point(p.x, -p.y);}
inline Point rot(const Point &p, DD ang) {return Point(cos(ang) * p.x - sin(ang) * p.y, sin(ang) * p.x + cos(ang) * p.y);}
inline Point rot90(const Point &p) {return Point(-p.y, p.x);}
inline DD cross(const Point &p, const Point &q) {return p.x * q.y - p.y * q.x;}
inline DD dot(const Point &p, const Point &q) {return p.x * q.x + p.y * q.y;}
inline DD norm(const Point &p) {return dot(p, p);}
inline DD abs(const Point &p) {return sqrt(dot(p, p));}
inline DD amp(const Point &p) {DD res = atan2(p.y, p.x); if (res < 0) res += PI*2; return res;}
inline bool eq(const Point &p, const Point &q) {return abs(p - q) < EPS;}
inline bool operator < (const Point &p, const Point &q) {return (abs(p.x - q.x) > EPS ? p.x < q.x : p.y < q.y);}
inline bool operator > (const Point &p, const Point &q) {return (abs(p.x - q.x) > EPS ? p.x > q.x : p.y > q.y);}
inline Point operator / (const Point &p, const Point &q) {return p * conj(q) / norm(q);}


const int ITER = 100;

int N;
vector<Point> v;

DD f(DD x, DD y) {
    DD res = 0;
    for (int i = 0; i < N; ++i) res = max(res, abs(v[i] - Point(x, y)));
    return res;
}

DD g(DD x) {
    DD left = -1000, right = 1000;
    for (int _ = 0; _ < ITER; ++_) {
        DD m1 = (left * 2 + right) / 3;
        DD m2 = (left + right * 2) / 3;
        if (f(x, m1) > f(x, m2)) left = m1;
        else right = m2;
    }
    return f(x, left);
}

DD solve() {
    DD left = -1000, right = 1000;
    for (int _ = 0; _ < ITER; ++_) {
        DD m1 = (left * 2 + right) / 3;
        DD m2 = (left + right * 2) / 3;
        if (g(m1) > g(m2)) left = m1;
        else right = m2;
    }
    return g(left);
}

int main() {
    cin >> N;
    v.resize(N);
    for (int i = 0; i < N; ++i) cin >> v[i].x >> v[i].y;
    cout << fixed << setprecision(10) << solve() << endl;
}

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

int main() {
    int n;
    cin >> n;
    for (int i = 0; i <= n; i++) {
        for (int j = 0; j <= n - i; j++) {
            if (i * 4 + j * 7 == n) {
                cout << "Yes" << endl;
                return 0;
            }
        }
    }
    cout << "No" << endl;
}


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

int main() {
	int K,i;
	char S[101];
	scanf("%d", &K);
	scanf("%s", S);
	if (K >= strlen(S)) {
		for (i = 0; i < strlen(S); i++) {
			printf("%c", S[i]);
		}
	}
	else {
		for (i = 0; i < K; i++) {
			printf("%c", S[i]);
		}printf("...");
	}
	return 0;
}

Measured memory_bytes: 1732
#[allow(unused_macros)]
macro_rules! parse_line {
    ( $t:ty ) => (
        {
            let mut line = String::new();
            ::std::io::stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            iter.next().unwrap().parse::<$t>().unwrap()
        }
    );

    ( $( $t:ty), +) => (
        {
            let mut line = String::new();
            ::std::io::stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            ( $(iter.next().unwrap().parse::<$t>().unwrap()),* )
        }
    );
}

#[allow(unused_macros)]
macro_rules! read_line {
    () => {{
        let mut line = String::new();
        ::std::io::stdin().read_line(&mut line).unwrap();
        line.trim_right().to_string()
    }};
}

#[allow(unused_macros)]
macro_rules! parse_vec {
    ( $t:ty ) => {{
        let mut line = String::new();
        ::std::io::stdin().read_line(&mut line).unwrap();
        let iter = line.split_whitespace();
        iter.map(|v| v.parse::<$t>().unwrap()).collect::<Vec<_>>()
    }};
}

fn main() {
    let n = read_line!();

    for c in n.chars() {
        if c == '7' {
            println!("Yes");
            return;
        }
    }

    println!("No");
}


Measured memory_bytes: 2132
#include <bits/stdc++.h>
#include <iomanip>
using namespace std;
#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define Rreps(i,n,e) for(int i = n - 1; i >= e; --i)
#define Rrep(i,n) Rreps(i,n,0)
#define ALL(a) a.begin(), a.end()
#define fi first
#define se second
#define mp make_pair
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;

ll N,M,H,W,K,Q,A,B;
string S, T;
const ll MOD = 998244353;
//const ll MOD = (1e+9) + 7;
const ll INF = 1LL << 60;
typedef pair<int, int> P;

int main() {
    cin>>N;
    vec a(N);
    rep(i,N) cin>>a[i];
    vector<mat> dp(2, mat(N, vec(16, 0)));
    rep(rp, 2) {
        Rrep(i, N) {
            rep(j, 16) dp[rp][i][j] = j;
            if (i < N - 1) {
                ll temp = 0;
                if (a[i] < a[i + 1]) {
                    while ((a[i] << (2 - temp * 2)) <= a[i + 1]) --temp;
                    rep(j, 16) dp[rp][i][j] += dp[rp][i + 1][max(0LL, j + temp)];
                } else {
                    while (a[i] > (a[i + 1] << (temp * 2))) ++temp;
                    rep(j, 16 - temp) dp[rp][i][j] += dp[rp][i + 1][j + temp];
                    reps(j, 16 - temp, 16) {
                        dp[rp][i][j] += dp[rp][i + 1][15] + (j + temp - 15) * (N - i - 1);
                    }
                }
            }
        }
        reverse(ALL(a));
    }
    ll ans = dp[0][0][0] * 2;
    /*rep(i,2){
        rep(j,N) {
            rep(k, 5) cout << dp[i][j][k] << ' ';
            cout<<endl;
        }
        cout<<endl;
    }*/
    rep(i, N - 1){
        ans = min(ans, (dp[1][N - 1 - i][0] + dp[0][i + 1][0]) * 2 + i + 1);
        /*if((dp[1][N - 1 - i][0] + dp[0][i + 1][0]) * 2 + i + 1 == 10) {
            cout<<i<<endl;
            cout<<dp[1][i][0]<<' '<<dp[0][i + 1][0]<<endl;
        }*/
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 100224
//c++ テンプレ
#include<bits/stdc++.h>
using namespace std;

typedef long long llint;
typedef long double ld;

#define inf 1e18
#define mod 1000000007
priority_queue<llint,vector<llint>,greater<llint> > que;
priority_queue<llint> Que;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int n;
vector<int>a;
vector<int>l;
vector<int>r;
void solve(){
    cin >> n;
    a.resize(n+2,0);
    l.resize(n+2,0);
    r.resize(n+2,0);
    for(int i=1;i<=n;i++)cin >> a[i];
    for(int i=1;i<=n;i++)l[i]=l[i-1]^a[i];
    for(int i=n;i>=1;i--)r[i]=r[i+1]^a[i];

    for(int i = 1; i <= n; i++) cout << (l[i-1]^r[i+1]) << " ";
    cout << endl;
   
}

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




Measured memory_bytes: 5428
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;++i)
#define rrep(i,n) for(int i=n-1;i>=0;--i)
#define REP(i,a,b) for(int i=a;i<b;i++)
#define yesno(flg) if(flg){cout<<"YES"<<endl;}else{cout<<"NO"<<endl;}
#define vi vector<int>
#define pb push_back
#define i197 1000000007
#define MAX_N 200002
using namespace std;

typedef long long ll;
typedef pair<int,int> Pii;
typedef pair<Pii,int> Piii;
const int inf=1000000000;
struct edge{
	int myc,to,c,cost;
};
struct pos{
	int to,cost,color;
};
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};
int f[MAX_N]={};
int dp[5001][5001]={};

int n;
string s;

int calc(int a,int b){
	if(dp[a][b]>=0)return dp[a][b];
	if(b>=n)return 0;
	int res=0;
	if(s[a]==s[b]){
		res=1+calc(a+1,b+1);
		if(res>b-a)res--;
	}
	dp[a][b]=res;
	return res;

}
int main() {
	int t=0;
	cin>>n>>s;

	rep(i,5001){
		rep(j,5001){
			dp[i][j]=-1;
		}
	}
	rep(i,n-1){
		for(int j=i+1;j<n;++j){
			t=max(t,calc(i,j));
		}
	}
	cout<<t<<endl;
	return 0;
}


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

int main() {
  int N,t;
  double s,M;
  t=0;
  cin >>N >>M;
  vector<int> A(N);
  for(int i=0; i<N; i++){
    cin >>A.at(i);
  }
  for(int j=0; j<N; j++){
    s = s+A.at(j);
  }
  for(int k=0; k<N; k++){
    if(A.at(k)>=(s/(4*M))){
      t = t+1;
    }
  }
  cout <<(t>=M?"Yes":"No") <<endl;
}

Measured memory_bytes: 256
a, v = map(int, input().split())
b, w = map(int, input().split())
t = int(input())

dis = abs(b-a)
ss = v - w
if ss <= 0:
    print('NO')
    exit()
ti = dis // ss
if dis % ss != 0:
    ti += 1
if ti <= t:
    print('YES')
else:
    print('NO')

Measured memory_bytes: 61664
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N,i;
  i = 1000;
  cin >> N;
  if( N%i == 0){
     i = i*(N/i);
  }else if (N%i > 0){
      i = i*(N/i+1);
  }
  cout << i-N << endl;
}

Measured memory_bytes: 3524
N,K=map(int,input().split())
A=list(map(int,input().split()))

ans=0
L= (K*(K+1)//2) % 1000000007

for i in range(N):
    for j in range(N):
        if i==j:
            continue
        if A[i] > A[j]:
            if i < j:
                ans = (ans + L) % 1000000007
            else:
                ans = (ans + L-K) % 1000000007

print(int(ans))

Measured memory_bytes: 41836
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll>pi;
const int MAXN=100005;
const int MOD=1000000007;

#define FOR(i,a,b) for(int i=(a);i<=(b);i++)
#define DEC(i,a,b) for(int i=(a);i>=(b);i--)
#define fst first
#define snd second
#define pb push_back
#define sz(v) ((int)(v).size())
#define all(v) (v).begin(),(v).end()
#define db(x) cerr<<#x<<" = "<<x<<"\n"
#define LOW(v,x) (lower_bound(all(v),(x))-(v).begin())
#define UP(v,x) (upper_bound(all(v),(x))-(v).begin())

main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	string S; cin >> S;
	if (S=="ABC") cout<<"ARC";
	else cout<<"ABC";
}


Measured memory_bytes: 3612
object Main {
  def main(args: Array[String]): Unit = {
    val s = new Main()
    s.solve()
    s.out.flush()
  }
}

class Main {
  import java.io._
  import java.util.StringTokenizer

  import scala.collection.mutable
  import scala.util.Sorting
  import math.{abs, max, min}
  import mutable.{ArrayBuffer, ListBuffer}
  import scala.reflect.ClassTag

  val MOD = 1000000007
  val out = new PrintWriter(System.out)

  def solve(): Unit = {
    val H, W, h, w = ni()
    val ans = H * W - h * W - w * H + w * h
    out.println(ans)
  }


  def debug(as: Array[Boolean]): Unit = {
    System.err.println(as.map(x => if(x) "1" else "0").mkString)
  }

  def debug(as: Array[Int]): Unit = {
    System.err.println(as.mkString(" "))
  }

  def debug(as: Array[Long]): Unit = {
    System.err.println(as.mkString(" "))
  }

  def debug(s: String): Unit = {
    System.err.println(s)
  }

  def debug(num: Long): Unit = {
    System.err.println(num)
  }

  class InputReader(val stream: InputStream) {
    private val reader = new BufferedReader(new InputStreamReader(stream), 32768)
    private var tokenizer: StringTokenizer = _

    def next(): String = {
      while (tokenizer == null || !tokenizer.hasMoreTokens)
        tokenizer = new StringTokenizer(reader.readLine)
      tokenizer.nextToken
    }

    def nextInt(): Int = next().toInt
    def nextLong(): Long = next().toLong
    def nextChar(): Char = next().charAt(0)
  }
  val sc = new InputReader(System.in)
  def ni(): Int = sc.nextInt()
  def nl(): Long = sc.nextLong()
  def nc(): Char = sc.nextChar()
  def ns(): String = sc.next()
  def ns(n: Int): Array[Char] = ns().toCharArray
  def na(n: Int, offset: Int = 0): Array[Int] = map(n)(_ => ni() + offset)
  def na2(n: Int, offset: Int = 0): (Array[Int], Array[Int]) = {
    val A1, A2 = Array.ofDim[Int](n)
    REP(n) { i =>
      A1(i) = ni() + offset
      A2(i) = ni() + offset
    }
    (A1, A2)
  }
  def nm(n: Int, m: Int): Array[Array[Int]] = {
    val A = Array.ofDim[Int](n, m)
    REP(n) { i =>
      REP(m) { j =>
        A(i)(j) = ni()
      }
    }
    A
  }
  def nal(n: Int): Array[Long] = map(n)(_ => nl())
  def nm_c(n: Int, m: Int): Array[Array[Char]] = map(n) (_ => ns(m))
  def REP(n: Int, offset: Int = 0)(f: Int => Unit): Unit = {
    var i = offset
    val N = n + offset
    while(i < N) { f(i); i += 1 }
  }
  def REP_r(n: Int, offset: Int = 0)(f: Int => Unit): Unit = {
    var i = n - 1 + offset
    while(i >= offset) { f(i); i -= 1 }
  }

  def map[@specialized A: ClassTag](n: Int, offset: Int = 0)(f: Int => A): Array[A] = {
    val res = Array.ofDim[A](n)
    REP(n)(i => res(i) = f(i + offset))
    res
  }


  def sumL(as: Array[Int]): Long = {
    var s = 0L
    REP(as.length)(i => s += as(i))
    s
  }

  def cumSum(as: Array[Int]) = {
    val cum = Array.ofDim[Long](as.length + 1)
    REP(as.length) { i =>
      cum(i + 1) = cum(i) + as(i)
    }
    cum
  }
}


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

using namespace std;


int main (void) 
{

  /* Variable_Proclamation */
  int N;    // input  (棒の数)
  int K;    // input  (選択する数)
  int sum;  // output

  int i;    // subscript


  /* Input, Array_Proclamation */
  cin >> N >> K;
  vector<int> l(N);


  for(i=0; i<N; i++)
  {
    cin >> l.at(i);
  }


  /* Initialize */
  sum = 0;




  /* Calculation */
  sort   ( l.begin(), l.end() );
  reverse( l.begin(), l.end() );

  for(i=0; i<K; i++)
  {
    sum += l.at(i);
  }
  

  /* Output */
  cout << sum << endl;


  return 0;

}


Measured memory_bytes: 256
from collections import Counter, OrderedDict

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

ac = Counter(a)
# sort of Disctionary
# https://qiita.com/ysk24ok/items/b546471c37b2f443f4c7

ac.most_common()

tac = list(ac.values())
tac.sort()
v = len(tac)
if(k < v):
    print(sum(tac[:v-k]))
else:
    print(0)


Measured memory_bytes: 39296
#include <iostream>
#include <cmath>
#include <climits>
using namespace std;
int main(){
	int n,k;
	cin>>n>>k;
	int h[n],dp[n];
	
	for(int i=0;i<n;i++){
		cin>>h[i];
	}
	
	dp[0]=0;

	for(int i=1;i<n;i++){
		dp[i]=INT_MAX;
		for(int j=1; j<=k && j<=i ;j++){
			dp[i] = min(dp[i],dp[i-j]+abs(h[i]-h[i-j]));
		}
	}

	cout<<dp[n-1];


}


Measured memory_bytes: 1024