akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
int a[5];
int main()
{
	int n,m;
	cin>>n>>m;
	for(int i=1;i<=n;++i) a[i]=-1;
	for(int i=1;i<=m;++i)
	{
		int s,c;
		cin>>s>>c;
		if(a[s]!=-1&&a[s]!=c)
		{
			printf("-1");return 0;
		}else a[s]=c;
	}
	if(n==1)
	{
		if(a[1]==-1) printf("0");
		else printf("%d",a[1]);
	}
	else if(a[1]==0) printf("-1");
	else{
		if(a[1]==-1) printf("1");else printf("%d",a[1]);
		for(int i=2;i<=n;++i)
		{
			if(a[i]==-1) printf("0");else printf("%d",a[i]); 
		}
	} 
 } 

Measured memory_bytes: 256
/**   Created by: Marcos Portales
          Codeforces User: marcosportales
          Country: Cuba
          Copyright                    */
#include<bits/stdc++.h>
using namespace std;
/// Pragmas:
#pragma GCC optimize("Ofast","unroll-loops","omit-frame-pointer","inline") //Optimization flags
#pragma GCC option("arch=native","tune=native","no-zero-upper") //Enable AVX
#pragma GCC target("avx2") //Enable AVX
/// Macros:
#define int long long
#define f first
#define s second
#define db(x) cerr << #x << ": " << (x) << '\n';
#define pb push_back
#define lb lower_bound
#define up upper_bound
#define all(x) x.begin() , x.end()
#define rall(x) x.rbegin() , x.rend()
#define enl '\n'
#define vi vector<int>
#define sz(a) int((a).size())
#define rep(i,n) for(int i=0;i<n;i++)
#define repi(i,n) for(int i=(1);i<(n);i++)
typedef pair<int,int> ii;
typedef long double ld;
typedef unsigned long long ull;
/// Constraints:
const int maxn = 200005;
const int mod = 1000000007;
const ld eps = 1e-9;
const int inf = ((1ll<<31ll)-1ll);
const int INF = 2000000000000000000ll;
const ld pi = acos(-1);
/// Prime Numbers:
// 2, 173, 179, 181, 197, 311, 331, 737, 1009, 2011, 2027, 3079, 4001, 10037, 10079, 20011, 20089;
// 100003, 100019, 100043, 200003, 200017, 1000003, 1000033, 1000037, 1000081;
// 2000003, 2000029, 2000039, 1000000007, 1000000021, 2000000099;
/// Functions:
#define lg2(x) 31 - __builtin_clz(x)
#define lgx(x,b) ( log(x) / log(b) )
/// Red-Black Tree Test.insert(x)late ---------------------------------
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;
//typedef tree < long long ,  null_type ,  less<long long> ,  rb_tree_tag ,  tree_order_statistics_node_update > ordered_set;
/// Quick Pow------------------------------------------------
int qpow(int b,int e){
    if( !e ) return 1;
    if( e & 1 ) return qpow(b,e-1) * b % mod;
    int pwur = qpow(b,e>>1);
    return (pwur * pwur) % mod;
}
int modinv(int x){
    return qpow(x,mod-2);
}
/// My Code -------------------------------------------------

vi g[maxn];

int32_t main(){
    ios_base::sync_with_stdio(0); cin.tie(0);
    cout.setf(ios::fixed); cout.precision(0);
    srand(time(NULL));
    //freopen("a.in","r",stdin);
    //freopen("a.in","w",stdout);
    int n,m;
    cin>>n>>m;
    rep(i,m){
        int a,b;
        cin>>a>>b;
        g[a].pb(b);
        g[b].pb(a);
    }
    bool vis[n]={0};
    for(auto nod:g[1])vis[nod]=1;
    bool fl=0;
    for(auto nod:g[n]){
        if(vis[nod]){fl=1;break;}
    }
    cout<<((fl)?"POSSIBLE":"IMPOSSIBLE");

    return 0;
}


Measured memory_bytes: 15716
N, M = map(int, input().split())

lights = []

for _ in range(M):
  args = [int(x) - 1 for x in input().split()]
  args.pop(0)  # k は不要  
  switches = 0
  for i in args:
    switches |= (1 << i)
  lights.append(switches)
  
P = [int(x) for x in input().split()]

count = 0

# 2^10
for mask in range(1 << N):
  if all(bin(mask & s).count('1') % 2 == P[i] for i, s in enumerate(lights)):
    count += 1
      
print(count)

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

import itertools

N = int(input())
S = str(input())

# 暗証番号Vを000から999まで決め打ちすると、次の問題を1000回解けば良いことになる。
# SからN-3桁を消して、Vを作ることができるか。
# この問題は貪欲法で解くことができる。
# - 1. S_i = V_1であるようなiのうち、最小のiをp_1とする。そのようなiが存在しなければ、Vを作ることはできない。
# - 2. S_i = V_2であるようなiのうち、p_1より大きい、かつ最も小さいiをp_2とする。そのようなiが存在しなければ、Vを作ることはできない。
# - 3. S_i = V_3であるようなiのうち、p_2より大きい、かつ最も小さいiをp_3とする。そのようなiが存在しなければ、Vを作ることはできない。
# e.g., S = 869120, V = 812
# - V_1 = 8より、p_1 = 0
# - V_2 = 1, p_1 = 0より、p_2 = 3
# - V_3 = 2, p_2 = 3より、p_3 = 4

def can_make_pw(S, password):
    # step1
    v1 = password[0]
    p1 = S.find(v1)
    if p1 == -1:
        return False
    # step2
    v2 = password[1]
    p2 = S.find(v2, p1+1)
    if p2 == -1:
        return False
    # step3
    v3 = password[2]
    p3 = S.find(v3, p2+1)
    if p3 == -1:
        return False
    return True

passwords = []
for i in range(10):
    for j in range(10):
        for k in range(10):
            password = str(i) + str(j) + str(k)
            passwords.append(password)
# print(passwords)

count = 0
for password in passwords:
    if can_make_pw(S, password):
        # print(f"You can make {password} from {S}")
        count += 1

print(count)

# 全探索はTLE
# l_pw = []
# if N-3 == 1:
#     for i in range(N):
#         l_S = list(S)
#         l_S.pop(i)
#         l_pw.append(','.join(l_S))
# else:
#     combs = list(itertools.combinations(range(N), N-3))
#     for comb in combs:
#         l_S = list(S)
#         for i in sorted(comb, reverse=True):
#             l_S.pop(i)
#         l_pw.append(','.join(l_S))
# print(len(set(l_pw)))


Measured memory_bytes: 38512
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
    ll x;
    scanf("%lld",&x);
    printf("0 0 1 1000000000 %lld %lld",(x-1)/1000000000+1,(1000000000-x%1000000000)%1000000000);
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
char a[19];
int main()
{
    for(int i=0;i<19;i++){
        cin>>a[i];
        if(a[i]==',')
            a[i]=' ';
    }
    for(int i=0;i<19;i++){
        cout<<a[i];
    }
}


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

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

#define REP(i,n) for(int i=0;i<n;++i)
#define ALL(name) name.begin(),name.end()
#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;
#define MAX_N 100010

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

    string S;
    cin >> S;

    if(S == "AAA" || S == "BBB") {
        printf("No\n");
        return 0;
    }

    printf("Yes\n");
    return 0;
}


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

class Main{
    public static void main(String args[]){
        Scanner in = new Scanner(System.in);
        int[] a = new int[10];
        for(int i=0;i<10;i++){
            a[i] = in.nextInt();
        }
        Arrays.sort(a);
        for(int i=9;i>6;i--){
            System.out.println(a[i]);
        }
    }
}

Measured memory_bytes: 12000
#!/usr/bin/env ruby
# encoding: utf-8

def gcd ( a, b )
	tmp = []
	if a > b
		tmp << a << b << 0
	else
		tmp << b << a << 0
	end
	n = 0
	while true
		i = 1
		while true
			tmp[( n + 2 ) % 3 ] = tmp[ n % 3 ] - tmp[( n + 1 ) % 3 ] * i
			if tmp[( n + 2 ) % 3 ] == 0
				return tmp[( n + 1 ) % 3 ]
			elsif tmp[( n + 2 ) % 3 ] < tmp [( n + 1 ) % 3 ]
				break
			end
			i += 1
		end
		n += 1
	end
end

while line = gets do
	c, d = line.split.map(&:to_i)
	g = gcd c, d
	l = ( c / g ) * d
	puts "#{g} #{l}"
end

Measured memory_bytes: 6112
/*
  Motto - try hard to become an expert
*/
#include <bits/stdc++.h>
#include <map>
#include <algorithm>
#include <vector>
#include <string.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <chrono>
#include <thread>
#include <iomanip>
 
//define
#define rep(i,n)    for(int i=0;i<n;i++)
#define repu(i,k,n) for(int i=k;i<=n;i++)
#define repd(i,k,n) for(int i=k;i>=n;i--)
#define se second
#define fi first
#define pb push_back
#define mp make_pair
#define INF (int)INT_MAX
#define all(v)  v.begin(), v.end()
#define endl "\n"
 
//typedef
typedef long long int ll;
typedef long double ld;
typedef std::pair<int, int> pii;
typedef std::vector<int> vi;
typedef std::vector< pii > vii;
typedef std::vector< ll > vll;
typedef std::vector< std::pair < pii, int > > vpp;
 
const int N = 3*1e5 +5 ;
const long long MOD = 1e9 + 7;
const long long inf = 1e18;
 
using namespace std;
 

ll modpow(ll x,ll n){
    ll res=1;
    while(n>0){
        if(n&1) res=res*x%MOD;
        x=x*x%MOD;
        n>>=1;
    }
    return res;
}
 
ll modFact(ll n, ll p) 
{ 
    if (n >= p) 
        return 0; 
  
    ll result = 1; 
    for (ll i = 1; i <= n; i++) 
        result = (result * i) % p; 
  
    return result;  
} 
 
bool isPrime(int x)
{
    if(x%2==0)
        return 0;
    for(int i=3;i<=sqrt(x);i+=2)
    {
        if(x%i==0)
            return 0;
    }
    return 1;
}
 
ll binomialCoeff(ll n, ll k) 
{ 
    ll C[n + 1][k + 1]; 
    ll i, j; 


    for (i = 0; i <= n; i++) 
    { 
        for (j = 0; j <= min(i, k); j++) 
        { 
            
            if (j == 0 || j == i) 
                C[i][j] = 1; 

            else
                C[i][j] = (C[i - 1][j - 1] + 
                                        C[i - 1][j])%MOD; 
        } 
    } 

    return C[n][k]; 
}
bool compare(const string &a , const string&b){
    //set<pair<int,int> , decltype(&compare)>s(&compare) ;
}

// struct compare{
//     // for priority_queue
//     bool operator()(const int &a , const int&b){
//         return a<b ;
//     }
// };

void solve()
{
    int a, b; 
    cin>>a>>b;
    if(a<=5){
        cout<<0<<endl;
    }
    else if(a>=6 && a<=12){
        cout<<b/2<<endl;
    }
    else{
        cout<<b<<endl;
    }
}
 
int main() {
    #ifndef ONLINE_JUDGE
        // for getting input from input.txt
        freopen("input.txt", "r", stdin);
        // for writing output to output.txt
        freopen("output.txt", "w", stdout);
    #endif
    
    ios_base::sync_with_stdio(0);
    cin.tie(NULL);
    int t = 1;
    //cin>>t;
    while(t--)
    {
        solve();
    } 
    cerr << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC << "ms\n";
}

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

int main(void)
{
    string s; cin >> s;
    int n = s.size();
    vector<int> mod(n + 1, 0);
    int d = 0;
    int m10 = 1;
    for (int i = n; i > 0; i--)
    {
        d = d + m10 * (s[i-1] - '0');
        d = d % 2019;
        mod[i-1] = d;
        m10 = (m10 * 10) % 2019;
    }

    vector<int> cnt(2019, 0);
    for (int m:mod) cnt[m]++;
    int ans = 0;
    for (int c:cnt) ans += c * (c - 1) / 2;
    cout << ans << endl;
}


Measured memory_bytes: 4368
#include <iostream>
#include <algorithm>
#include <math.h>
#include <string.h>
#include <vector>

typedef long long ll;
using namespace std;

ll Mod = 1e9 + 7;
int main()
{
    ll N, x;
    ll isodd = 0, is4 = 0, iseven = 0;
    cin >> N;
    for (int i = 0; i < N; i++) {
        cin >> x;
        if (x % 4 == 0) is4++;
        else if (x % 2 == 1) isodd++;
        else iseven++;
    }
    if (iseven) {
        if (is4 >= isodd) cout << "Yes" << endl;
        else cout << "No" << endl;
    } else {
        if (is4 >= isodd - 1) cout << "Yes" << endl;
        else cout << "No" << endl;
    }
 
        
    return 0;
}

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

#define LL long long
#define pii pair<int,int>
using namespace std;
const int inf = 2147483647;
const int N = 20001;

int _max(int x, int y) {return x > y ? x : y;}
int _min(int x, int y) {return x < y ? x : y;}
inline int read() {
    int x = 0, f = 1; char ch = getchar();
    while(ch < '0' || ch > '9') {if(ch == '-') f = -1; ch = getchar();}
    while(ch >= '0' && ch <= '9') x = (x << 3) + (x << 1) + (ch ^ 48), ch = getchar();
    return x * f;
}
void put(int x) {
	if(x < 0) putchar('-'), x = -x;
	if(x >= 10) put(x / 10);
	putchar(x % 10 + '0');
}

int n, k;
char ss[N], hh[N];

bool cmp(int x, int y) {
	for(int i = 1; i <= n; i++) {
		if(ss[x + i - 1] > ss[y + i - 1]) return 1;
		else if(ss[x + i - 1] < ss[y + i - 1]) return 0;
	} return 0;
}

int main() {
	n = read(), k = read();
	scanf("%s", ss + 1);
	int gg = 'z';
	for(int i = 1; i <= n; i++) gg = _min(gg, ss[i]);
	if(k > 30) {
		for(int i = 1; i <= n; i++) putchar(gg);
		return 0;
	} else {
		for(int i = n + 1; i <= 2 * n; i++) ss[i] = ss[n - (i - n) + 1];
		int now = 1;
		for(int i = 2; i <= n + 1; i++) {
			if(cmp(now, i)) now = i;
		} for(int i = now; i <= now + n - 1; i++) hh[i - now + 1] = ss[i];
		k--;
		int s = 0;
		while(hh[s + 1] == hh[1]) s++;
		while(k--) {
			for(int i = 1; i <= n; i++) ss[i] = hh[i];
			for(int i = 1; i <= _min(n, s * 2); i++) hh[i] = ss[1];
			for(int i = _min(n, s * 2) + 1, t = 1; i <= n; i++, ++t) hh[i] = ss[s + t];
			s = _min(s * 2, n);
			if(s == n) break;
		} printf("%s", hh + 1);
	}
	return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;
import java.util.stream.IntStream;

public class Main{
	static final Scanner s=new Scanner(System.in);
	static int getInt(){
		return Integer.parseInt(s.next());
	}
	static IntStream REPS(int r){
		return IntStream.range(0,r);
	}
	static IntStream REPS(int l,int r){
		return IntStream.rangeClosed(l,r);
	}
	static IntStream INTS(int l){
		return REPS(l).map(i->getInt());
	}
	public static void main(String[] __){
		StringBuilder sb=new StringBuilder();
		
		s.next();
		String in=s.next();
		
		int addL=0,addR=0;
		for(int i=in.length()-1;i>=0;i--) {
			char c=in.charAt(i);
			if(c=='('){
				if(addL>0)
					addL--;
			}else{
				addL++;
			}
		}
		for(int i=0;i<in.length();i++) {
			char c=in.charAt(i);
			if(c==')'){
				if(addR>0)
					addR--;
			}else{
				addR++;
			}
		}
		for(int i=addL;i>0;i--)
			sb.append("(");
		sb.append(in);
		for(int i=addR;i>0;i--)
			sb.append(")");
		
		System.out.println(sb.toString());
	}
}


Measured memory_bytes: 21972
#include<iostream>
#include<algorithm>

using namespace std;

#define fi(a,b) for(int i=a;i<b;++i)
#define fj(a,b) for(int j=a;j<b;++j)
///////////////////

int const N = 3e3 + 41;

int a, b, c, d, e, f;
int w[N], s[N];
int answ, anss;

void solve(){
	fi(0, N){
		fj(0, N){
			int sw = a * 100 * i + b * 100 * j;
			if(sw >= N) break;
			w[sw] = 1;
		}
	}
	fi(0, N){
		fj(0, N){
			int ss = c * i + d * j;
			if(ss >= N) break;
			s[ss] = 1;
		}
	}
	fi(0, N){
		if(!w[i]) continue;
		fj(0, N){
			if(i + j > f) break;
			if(!s[j]) continue;
			if(j * 100 - e * i > 0) continue;
			if(anss * (i + j) - j * (anss + answ) <= 0){
				answ = i;
				anss = j;
			}
		}
	}
}

int main(){
#ifdef _DEBUG
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
#endif

	scanf("%d %d %d %d %d %d",&a,&b,&c,&d,&e,&f);

	solve();

	printf("%d %d\n",answ + anss,anss);

	return 0;
}

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

#define uni(x)      (x).resize(unique(all(x)) - (x).begin())
#define fprint(v)   for(auto x : v) cout << x << ' '
#define ALL(x)      (x).begin(), (x).end()
#define MP(x, y)    make_pair(x, y)
#define PII         pair<int, int>
#define SZ(x)       int((x).size())
#define PB(x)       push_back(x)
#define ll          long long
#define S           second 
#define F           first
#define nl          '\n'

using namespace std;
void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif
mt19937_64 rnd;

const int N = 1e5 + 5;
ll gc(ll a, ll b){
    if(b == 0) return a;
    return gc(b, a % b);
}
int main() {
    ios_base::sync_with_stdio(0);cin.tie(0);
    int n;
    cin >> n;
    vector<ll> a(n);
    ll lcm = 1;
    ll mx = 1;
    for(auto &x : a){
        cin >> x;
    }
    ll ans = 0;
    for(auto &x : a){
        ans += x - 1;
    } 
    cout << ans;
    return 0;
}
/*
    *** Most Impo.. -> check base case always
    1. Overflow Check (*, +)
    2. Index check (0 - based or 1 - based)
    3. Check for n = 1, 2, 3, 4....
    4. Corner Cases
*/

Measured memory_bytes: 256
#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 rep2(i,s,n) for (int i = s; i < n; ++i)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define tmax(a,b,c) max(a,max(b,c))
#define tmin(a,b,c) min(a,min(b,c))
#define pb push_back
using namespace std;
using ll = long long;
using P = pair<int,int>;
using LP = pair<ll,ll>;
template<class T> inline bool chmin(T& a,T b) {if(a > b){a = b; return true;} return false;}
template<class T> inline bool chmax(T& a,T b) {if(a < b){a = b; return true;} return false;}
const int inf = 1001001001;
const ll linf = 1001001001001001001;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int n,m;
    cin >> n >> m;
    rrep(i,m/n+1) {
        if(m%i == 0) {
            cout << i << endl;
            return 0;
        }
    }
}


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

using namespace std;

#define int long long

main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int n;
    cin >> n;
    cout << n * (n - 1) / 2 << '\n';
    return 0;
}



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

#define ll long long
#define vecll vector<long long>
#define vec2ll vector<vector<long long>>
#define vecbool vector<bool>
#define vecpairll vector<pair<long long,long long>>
#define forll(s,a,b) for(long long s = a;s < b;s++)
#define forllde(s,a) for(long long s = a;s > 0;s--)


int main()
{
  ll s, w;
  cin >> s >> w;
  if (s <= w)
	cout << "unsafe" << endl;
  else
	cout << "safe" << endl;
}


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

const string YES = "Yes";
const string NO = "No";
const int dx[4] = {-1, 0, 0, 1};
const int dy[4] = {0, 1, -1, 0};

int solve(long long H, long long W, std::vector<std::string> S)
{
    for (int i = 0; i < H; i++) //y
    {
        for (int j = 0; j < W; j++)
        {
            for (int k = 0; k < 4; k++)
            {
                long long x = j + dx[k];
                long long y = i + dy[k];

                if (x < 0 || x >= W)
                    continue;
                if (y < 0 || y >= H)
                    continue;

                if (S[i][j] == '#' && S[y][x] == '#')
                {
                    break;
                }
                else if (S[i][j] == '#' && k == 3)
                {
                    cout << "No" << endl;
                    return 0;
                }
            }
        }
    }
    cout << "Yes" << endl;
    return 0;
}

// Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main()
{
    long long H;
    scanf("%lld", &H);
    long long W;
    scanf("%lld", &W);
    std::vector<std::string> S(H);
    for (int i = 0; i < H; i++)
    {
        std::cin >> S[i];
    }
    solve(H, W, std::move(S));
    return 0;
}


Measured memory_bytes: 256
N, M = map(int, input().split())
X = sorted(list(map(int, input().split())))

if N < M:
    cost = []
    for i in range(M-1):
        cost.append(abs(X[i] - X[i+1]))
    cost = sorted(cost, reverse=True)
    del cost[:N-1]
    
    print(sum(cost))
else:
    print(0)

Measured memory_bytes: 13968
#include<bits/stdc++.h>
using namespace std;
 
#define rep(i, a, n) for(int i=a; i<n; i++)
#define ll long long
#define all(x) begin(x), end(x)
#define toInt(x) (x - '0')
#define pll pair<ll, ll>
#define pli pair<ll, int>
// #define int long long
const int inf = 1 << 30;
#define INF 1e+9
#define MAX_V 100008


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

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


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

// chmin, chmax関数
template<typename T, typename U, typename Comp=less<>>
bool chmax(T& xmax, const U& x, Comp comp={}) {
    if(comp(xmax, x)) {
        xmax = x;
        return true;
    }
    return false;
}
template<typename T, typename U, typename Comp=less<>>
bool chmin(T& xmin, const U& x, Comp comp={}) {
    if(comp(x, xmin)) {
        xmin = x;
        return true;
    }
    return false;
}

// Yes-Noを出力する問題で楽をする
void Ans(bool f){
    if(f) cout << "Yes" << endl;
    else cout << "No" << endl;
}

//---------------------------

int main(){
    int f=0, s=0;
    rep(i,3){
        int a; cin >> a;
        if(a==5) f++;
        else if(a==7) s++;
    }
    if(f==2 && s==1) cout << "YES" << endl;
    else cout << "NO" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long int
#define pb push_back
#define vec vector<int>
#define fo(i, n) for (int i = 0; i < n; i++)
#define foo(i, a, b) for (int i = a; i < b; i++)
#define mp make_pair
#define deb(x) cout << #x << "-->" << x << endl;
#define deb1a(v)                  \
    cout << #v << "--->" << endl; \
    for (auto it : v)             \
    {                             \
        cout << it << " ";        \
    }                             \
    cout << endl;
#define deb2a(v)                  \
    cout << #v << "--->" << endl; \
    for (auto it : v)             \
    {                             \
        for (auto it1 : it)       \
        {                         \
            cout << it1 << " ";   \
        }                         \
        cout << endl;             \
    }
    #define mod 998244353
 
#define fi first
#define se second

int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n;
    cin >> n;
    vec v(n);
    fo(i, n) cin >> v[i];
    sort(v.begin(), v.end());
    foo(i,1,n)
    {
        if(v[i]==v[i-1]){
            cout << "NO";
            return 0;
        }
    }
    cout << "YES";
}

Measured memory_bytes: 1792
MOD = 10**9 + 7
n = int(input())
s = input().rstrip()

if s[0] == "W" or s[-1] == "W":
    print(0)
    exit()
front = 0
ans = 1
for i, item in enumerate(s):
    if item == "B":
        if front % 2 == 0:
            front += 1
        else:
            ans *= front
            ans %= MOD
            front -= 1
    else:
        if front % 2 == 1:
            front += 1
        else:
            ans *= front
            ans %= MOD
            front -= 1
    if front < 0:
        print(0)
        exit()
if front != 0:
    print(0)
    exit()
for i in range(1, n+1):
    ans *= i
    ans %= MOD

print(ans)

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

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

int main( int argc, char *argv[] ) {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	ll x;
	cin >> x;
	std::cout << (1000 * (x / 500) + int(x % 500 / 5) * 5) << std::endl;

	return 0;
}


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

#define NREP() for(ll i = 0; i < n; i++)
#define REP(i, n) for(ll i = 0; i < n; i++)
#define ALL(x) (x).begin(),(x).end()
#define MSG(x) cout << x << endl;
#define YN(x) x ? cout << "YES" << endl : cout << "NO" << endl;
#define Yn(x) x ? cout << "Yes" << endl : cout << "No" << endl;
#define yn(x) x ? cout << "yes" << endl : cout << "no" << endl;

using namespace std;
using ll = long long;
const static ll MOD = 1e9 + 7;

int main(int argc, char *argv[]) {
    string s;
    cin >> s;

    map<char, ll> m;
    for (char c : s) {
        m[c] += 1;
    }

    for (auto itr = m.begin(); itr != m.end(); itr++) {
        if (itr->second % 2 != 0) {
            MSG("No")
            exit(EXIT_SUCCESS);
        }

    }

    MSG("Yes")
}

Measured memory_bytes: 256
#pragma GCC optimize("O3") //コンパイラ最適化用

#define _GLIBCXX_DEBUG //配列に[]でアクセス時のエラー表示
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
// forループ関係
#define REP(i, n) for (ll i = 0; i < ll(n); i++)
#define REPD(i, n) for (ll i = n - 1; i >= 0; i--)
#define FOR(i, a, b) for (ll i = a; i < ll(b); i++)
#define FORD(i, a, b) for (ll i = a; i > ll(b); i--)
// xにはvectorなどのコンテナ
#define ALL(x) x.begin(), x.end() // sortなどの引数を省略したい
#define SIZE(x) ll(x.size())      // sizeをsize_tからllに直しておく
//定数
#define INF 1000000000000 // 10^12:極めて大きい値,∞
#define MOD 1000000007    // 10^9+7:合同式の法
long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1)
            res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

int main() {

    ll n, k;
    cin >> n >> k;
    cout << modpow(k, n, MOD) << endl;
}



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

#define INF 1e+16
#define MAX_V 100005

struct edge {
    int to;
    long long int cost;
};

// <最短距離, 頂点の番号>
using P = pair<long long int, int>;

int V;
vector<edge> G[MAX_V];
vector<edge> rG[MAX_V];
long long int d[MAX_V];
long long int rd[MAX_V];

void dijkstra(int s) {
    priority_queue<P, vector<P>, greater<P> > que;
    fill(d, d+V, INF);
    d[s] = 0;
    que.push(P(0, s));

    while (!que.empty()) {
        P p = que.top();
        que.pop();
        int v = p.second;
        if (d[v] < p.first) continue;

        for (int i=0; i<G[v].size(); ++i) {
            edge e = G[v][i];
            if (d[e.to] > d[v] + e.cost) {
                d[e.to] = d[v] + e.cost;
                que.push(P(d[e.to], e.to));
            }
        }
    }
}

void rdijkstra(int s) {
    priority_queue<P, vector<P>, greater<P> > que;
    fill(rd, rd+V, INF);
    rd[s] = 0;
    que.push(P(0, s));

    while (!que.empty()) {
        P p = que.top();
        que.pop();
        int v = p.second;
        if (rd[v] < p.first) continue;

        for (int i=0; i<rG[v].size(); ++i) {
            edge e = rG[v][i];
            if (rd[e.to] > rd[v] + e.cost) {
                rd[e.to] = rd[v] + e.cost;
                que.push(P(rd[e.to], e.to));
            }
        }
    }
}

int main() {
    cin >> V;
    int E,s,t;
    cin >> E >> s >> t;
    for (int i=0; i<E; ++i) {
        int a, b;
      	long long int c, d;
        cin >> a >> b >> c >> d;
        edge e1 = {b-1, c};
      	edge e2 = {a-1, c};
      	edge re1 = {b-1, d};
      	edge re2 = {a-1, d};
      	rG[b-1].push_back(re2);
      	rG[a-1].push_back(re1);
        G[a-1].push_back(e1);
      	G[b-1].push_back(e2);
    }
    dijkstra(s-1);
  	rdijkstra(t-1);
  	priority_queue<long long int, vector<long long int>, greater<long long int>> q;
  	vector<long long int> ans(V);
  	long long int pt = 1e15;
	for(int i=0;i<V;i++){
    	q.push(d[V-i-1]+rd[V-i-1]);
      	ans[V-i-1] = pt - q.top();
    }
  	for(auto x: ans) cout << x << endl;
  	return 0;
}


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

using namespace std;

#define int long long

#ifndef bhupixb
    #define var(...)
    #define stl(...)
#endif

#define single_test

void solve() {
    int n;
    cin >> n;
    vector<pair<int,int>> a(n);
    for (auto &[x, y]: a) {
        cin >> x >> y;
    }
    int f = 0;
    for (int i = 2; i < n; ++i) {
        bool f2 = 1;
        f2 &= (a[i].first == a[i].second);
        f2 &= (a[i - 1].first == a[i - 1].second);
        f2 &= (a[i - 2].first == a[i - 2].second);
        f |= f2;
    }
    cout << (f ? "Yes" : "No") << '\n';
}

signed main() {
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    int t = 1;
    #ifndef single_test
        cin >> t;
    #endif
    for (int i = 1; i <= t; ++i) {
        // cout << "Case #" << i << ": ";
        solve();
    }

    return 0;
}

Measured memory_bytes: 3608
#include <cstdio>
 

int a,b;
int d;
 
void solve() {
  if (b % a == 0) {
    d = a + b;
  } else {
    d = b - a;
    }
}
 
int main() {
  scanf("%d", &a);
  scanf("%d", &b);
  solve();
  printf("%d\n", d);
 
  return 0;
}


Measured memory_bytes: 128
from itertools import accumulate

N = 100000
prime = [True]*(N+1)

prime[0] = prime[1] = False

for i in range(N+1):
    if prime[i]:
        for j in range(2*i, N+1, i):
            prime[j] = False

prime2 = [0] * (N+1)

for i in range(N+1):
    if prime[i] and prime[(i+1)//2]:
        prime2[i] = 1

acc = list(accumulate(prime2))

Q = int(input())
for _ in range(Q):
    l, r = map(int, input().split())
    print(acc[r]-acc[l-1])


Measured memory_bytes: 54452
def check(l):
    for i in l:
        if i%2==0:
            if i%3 and i%5:
                return False
    return True
def solve():
    n = int(input())
    a = tuple(map(int,input().split()))
    if check(a):
        print('APPROVED')
    else:
        print('DENIED')
if __name__ == "__main__":
    solve()

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

int a, b, q;
long long s[100010];
long long t[100010];

long long solve1(long long x) {
  auto it = upper_bound(s, s + a, x);
  long long dist1;
  {
    long long y = *it;
    int idx = upper_bound(t, t + b, y) - t;
    dist1 = y - x + min(t[idx] - y, y - t[idx-1]);
  }
  --it;
  long long y = *it;
  int idx = upper_bound(t, t + b, y) - t;
  long long dist2 = x - y + min(t[idx] - y, y - t[idx-1]);
  return min(dist1, dist2);
}
long long solve2(long long x) {
  auto it = upper_bound(t, t + b, x);
  long long dist1;
  {
    long long y = *it;
    int idx = upper_bound(s, s + a, y) - s;
    dist1 = y - x + min(s[idx] - y, y - s[idx-1]);
  }
  --it;
  long long y = *it;
  int idx = upper_bound(s, s + a, y) - s;
  long long dist2 = x - y + min(s[idx] - y, y - s[idx-1]);
  return min(dist1, dist2);
}
void solve(long long x) {
  cout<<min(solve1(x), solve2(x))<<endl;
}

int main() {
  cin>>a>>b>>q;
  s[0] = -1e13;
  s[1] = -1e12;
  t[0] = -1e13;
  t[1] = -1e12;
  for (int i=0; i<a; i++) cin>>s[i+2];
  for (int i=0; i<b; i++) cin>>t[i+2];
  s[a+2] = 1e12;
  s[a+3] = 1e13;
  t[b+2] = 1e12;
  t[b+3] = 1e13;
  a += 4;
  b += 4;
  for (int i=0; i<q; i++) {
    long long x;
    cin>>x;
    solve(x);
  }
}

Measured memory_bytes: 2816
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define vv(T) std::vector<std::vector<T>>
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

using namespace std;
using ll = long long;

int		main(void)
{
	int a, b;
	cin >> a >> b;
	cout << a * b << endl;
}



Measured memory_bytes: 3596
#include <iostream>
#include <algorithm>
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    
    int n;
	cin>>n;
	ll mod = 1e9+7;
	ll ans1=1,ans2=1,ans3=1;
	for(int i=1;i<=n;i++){
		ans1=(ans1*10)%mod;
		ans2=(ans2*9)%mod;
		ans3=(ans3*8)%mod;
	}   
	ans2 =  (ans2*2)%mod;
	ll ans = (ans1 + mod - ans2)%mod;
	ans = (ans + ans3)%mod;
	cout<<ans;  
	return 0;
}

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

using namespace std;
using llong = long long;
using ldbl = long double;
using lpair = pair<llong, llong>;

#define ALL(x) x.begin(), x.end()

template<typename T>
constexpr T inf = static_cast<T>(pow(10, static_cast<int>(log10(numeric_limits<T>::max())))) + 7;
constexpr llong mod = 1e9+7;

int main() {
	llong N, K;
	llong R, S, P;
	string T;

	cin >> N >> K;
	cin >> R >> S >> P;
	cin >> T;

	llong ans = 0;
	for (int i = 0; i < N; ++i) {
		if (i < K || T[i] != T[i - K]) {
			if (T[i] == 'r') {
				ans += P;
			}
			else if (T[i] == 's') {
				ans += R;
			}
			else {
				ans += S;
			}
		}
		else {
			T[i] = 'a';
		}
	}

	cout << ans << endl;

	return 0;
}

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

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author anand.oza
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        CGoToSchool solver = new CGoToSchool();
        solver.solve(1, in, out);
        out.close();
    }

    static class CGoToSchool {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int n = in.nextInt();
            int[] a = new int[n];
            for (int i = 0; i < n; i++) {
                a[i] = in.nextInt() - 1;
            }

            int[] answer = Permutations.inverse(a);
            for (int i = 0; i < n; i++) {
                answer[i]++;
            }

            out.println(Util.join(answer));
        }

    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

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

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

    }

    static class Permutations {
        public static int[] inverse(int[] permutation) {
            int n = permutation.length;
            int[] inverse = new int[n];
            for (int i = 0; i < n; i++) {
                inverse[permutation[i]] = i;
            }
            return inverse;
        }

    }

    static class Util {
        public static String join(int... i) {
            StringBuilder sb = new StringBuilder();
            for (int o : i) {
                sb.append(o);
                sb.append(" ");
            }
            if (sb.length() > 0) {
                sb.deleteCharAt(sb.length() - 1);
            }
            return sb.toString();
        }

    }
}



Measured memory_bytes: 42464
#include <cstdio>
int main() {
    int n, k, c, l[200005], r[200005], t = 0;
    char s[200005];
    scanf("%d %d %d\n%s", &n, &k, &c, s);
    int i = 0, j = n - 1;
    while (t < k) {
        while (s[i] == 'x') {
            i++;
        }
        l[t++] = i;
        i += c + 1;
    }
    t = k - 1;
    while (t >= 0) {
        while (s[j] == 'x') {
            j--;
        }
        r[t--] = j;
        j -= c + 1;
    }
    for (int i = 0; i < k; i++) {
        if (l[i] == r[i]) {
            printf("%d\n", l[i] + 1);
        }
    }
    return 0;
}

Measured memory_bytes: 3200
from collections import Counter

N = int(input())
A = list(map(int, input().split()))

cA = Counter(A)

allS = 0
for key in cA:
    allS += cA[key] * (cA[key] - 1) / 2

for i in range(N):
    if A[i] in cA.keys():
        print(int(allS - (cA[A[i]] - 1)))
    else:
        print(int(allS))

Measured memory_bytes: 33952
#include <iostream>
#include <cstdio>
#include <cctype>
using namespace std;

int main() {
	char ch;
	int count[26]{};
	while (cin >> ch) {
		ch = tolower(ch);
		if (isalpha(ch)) {
			count[ch - 'a']++;
		}
		else break;
	}
	for (int i = 0; i < 26; i++) {
		if (count[i] == 0) {
			printf("%c", i + 'a');
			return 0;
		}
	}
	cout << "None" << endl;
	return 0;
}

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

int main() {
    int N; cin >> N;
    vector<ll> l(N), r(N);
    vector<ll> A(N);
    for (int i = 0; i < N; i++) cin >> A[i];
    for (int i = 0; i < N; i++)
    {
        if(i==0){
            l[0] = A[0];
            r[N-1] = A[N-1];
        } else {
            l[i] = __gcd(A[i],l[i-1]);
            r[N-1-i] = __gcd(A[N-1-i], r[N-1-i+1]);
        }
    }

    ll ans = 0;
    for (int i = 0; i < N; i++)
    {
        if(i==0) ans = max(ans, r[1]);
        else if(i==N-1) ans = max(ans, l[N-2]);
        else ans = max(ans, __gcd(l[i-1], r[i+1]));
    }
    
    cout << ans << endl;
}

Measured memory_bytes: 2560
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(a) (a).begin(), (a).end()
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<int> vi;
typedef pair<ll,ll> pll;

struct FenwickTree{
  int n;
  vi bit;
  FenwickTree(int x = 0):n(x){bit = vi(x+1,0);}

  inline void add(int i, int x){
    i++;
    while(i <= n){
      bit[i] += x;
      i += i & -i;
    }
  }

  inline int sum(int i){
    i++;
    int res = 0;
    while(i > 0){
      res += bit[i];
      i -= i & -i;
    }
    return res;
  }
};

void dijk(int s, const vector< vector<pll> > &g, vl &d){
  d[s] = 0;
  priority_queue< pll, vector<pll>, greater<pll> > q;
  q.push(pll(0,s));

  while(q.size()){
    ll cd = q.top().first;
    int v = q.top().second; q.pop();
    if(d[v]<cd)continue;

    for(pll e : g[v]){
      ll nd = cd + e.first;
      int u = e.second;
      if(d[u] > nd){
	d[u] = nd;
	q.push(pll(nd,u));
      }
    }
  }
}

int main(){
  int n,m;
  scanf("%d%d",&n,&m);

  vector< vector<pll> > g(n);
  rep(i,m){
    int a,b,c;
    scanf("%d%d%d",&a,&b,&c);
    g[a].push_back(pll(c,b));
    g[b].push_back(pll(c,a));
  }

  vl ds(n,1e18), dg(n,1e18);
  dijk(0,g,ds); dijk(n-1,g,dg);
  
  vl vs;
  vector< vl > query;

  int q;
  scanf("%d",&q);
  rep(i,q){
    vl tmp(3); tmp[1] = i;
    scanf("%lld%lld",&tmp[2],&tmp[0]);
    query.push_back(tmp);
    vs.push_back(tmp[2]);
  }

  rep(i,n){
    vl tmp(3);
    tmp[0] = dg[i]; tmp[1] = q; tmp[2] = ds[i];
    query.push_back(tmp);
    vs.push_back(tmp[2]);
  }

  sort(all(query));
  reverse(all(query));
  sort(all(vs));
  vs.erase(unique(all(vs)),vs.end());

  vi ans(q);
  FenwickTree bit(vs.size());
  rep(i,query.size()){
    if(query[i][1] == q){
      int pos = lower_bound(all(vs),query[i][2]) - vs.begin();
      bit.add(pos,1);
    }else{
      int pos = lower_bound(all(vs),query[i][2]) - vs.begin();
      ans[query[i][1]] = bit.sum(pos);
    }
  }

  rep(i,q)printf("%d\n",ans[i]);
}

Measured memory_bytes: 24180
h,w = map(int,input().split())
shortest = [[0 for i in range(10)] for j in range(10)]
path = []
for i in range(10):
    c = list(map(int,input().split()))
    for j in range(10):
        shortest[i][j] = c[j]
for i in range(10):
    for j in range(10):
        for k in range(10):
            shortest[j][k] = min(shortest[j][k],shortest[j][i]+shortest[i][k])

# print(shortest)

ans = 0
for i in range(h):
    q = list(map(int,input().split()))
    for j in range(w):
        if q[j] != -1:
            ans += shortest[q[j]][1]

print(ans)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define mp make_pair
#define pb push_back
#define F first
#define S second
#define mod 1000000007
#define PI 3.141592653589793238
#define dbg(n) cout<<#n<<' '<<n<<endl;
#define dbg_v(v) cout<<#v<<":";for(int i=0;i<(int)v.size();i++) cout<<" "<<v[i]; cout<<endl;
int power(ll x,ll y){ll res = 1;while(y>0){if(y&1)res = (res*x)%mod;y=y>>1;x=(x*x)%mod;}return res;}
int main(){ 
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);	
	int t=1;
	//cin>>t;
	while(t--){
		int k,n;
		cin>>k>>n;
		int a[n];
		for(int i=0;i<n;i++)cin>>a[i];
		int mx=0;
		for(int i=0;i<n;i++){
			mx=max(mx,(k+a[(i+1)%n]-a[i])%k);
		}
		cout<<k-mx<<endl;
	}
}


Measured memory_bytes: 4316
#include <bits/stdc++.h>
using namespace std;
using LL = long long;
#define REP(i, n) for (LL i = 0; i < (LL)(n); i++)
#define FOR(i, m, n) for (LL i = m; i < n; i++)
#define SORT(x) sort(x.begin(), x.end())
#define REVE(x) reverse(x.begin(), x.end())
#define ALL(x) (x).begin(), (x).end()
#define SUM(x) accumulate(x.begin(), x.end(),0)
#define vLL(v,n) vector<LL> v(n); REP(i,n)cin>>v[i];
#define vstr(v,n) vector<string> v(n); REP(i,n)REP(i,n)cin>>v[i];
#define mina(a,b) a=min(a,b);
LL INF = 1e9 + 1;
LL MOD = 1e9+7;
  LL a,b,c,d,e,n,m,l,r,ans=1000,x,y;
string s,S,t;
int main() {
ios_base::sync_with_stdio(false);
  cin >> a>>b>>c>>d;
   x=c-a;y=d-b;
     
  cout << c-y<< " "<<d+x<< " "<<a-y<<" "<<b+x<<endl;
}

Measured memory_bytes: 3612
#include<iostream>
using namespace std;
int main(){
  int a,b,c,d;
  cin>>a>>b>>c>>d;
  if(a+b>c+d){
	cout<<"Left"<<endl;
  }else if(a+b==c+d){
    cout<<"Balanced"<<endl;
  }else{
    cout<<"Right"<<endl;
  }
}

Measured memory_bytes: 256
#pragma region header
#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i <= (int)(n); i++)
#define rev(i, n) for(int i = (int)(n - 1); i >= 0; i--)
#define rev1(i, n) for(int i = (int)(n); i > 0; i--)
#define pb push_back
#define all(v) (v).begin(), (v).end()
#define resort(v) sort((v).rbegin(), (v).rend())
#define vi vector<int>
#define vvi vector<vector<int>>
#define vc vector<char>
#define vvc vector<vector<char>>
#define vb vector<bool>
#define vvb vector<vector<bool>>
using ll = long long;
using P = pair<int, int>;
/* ----------------よく使う数字や配列----------------- */
int dx[] = {1,0,-1,0};
int dy[] = {0,1,0,-1};
constexpr ll mod = 1e9+7;
constexpr ll inf = INT32_MAX/2;
constexpr ll INF = LLONG_MAX/2;
constexpr long double eps = DBL_EPSILON;
constexpr long double pi = 3.141592653589793238462643383279;
/* ----------------------end----------------------- */

/* --------------------テンプレート------------------ */
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
/* ----------------------end----------------------- */

/* --------------------ライブラリ-------------------- */
ll fact(int i) {       //階乗
    if (i == 0) return 1;
    return (fact(i - 1)) * i % mod;
}
ll gcd(ll a, ll b) {        //最大公約数
    if(b == 0) return a;
    return gcd(b, a % b); 
}
ll lcm(ll a, ll b) {      //最小公倍数
    return a * b / gcd(a, b);
}
int keta(ll n) {        //桁数を求める
    if(n == 0) return 1;
    int count = 0;
    while(n != 0) {
        n /= 10;
        count++;
    }
    return count;
}
ll ketasum(ll n) {    //各桁の和
    ll sum = 0;
    while(n != 0) {
        sum += n % 10;
        n /= 10;
    }
    return sum;
}
bool isprime(int n) { //素数判定
    if(n==1)return false;
    if(n==2)return true;
    for(int i = 2;i<=sqrt(n);i++) {
        if(n%i==0) return false;
    }
    return true;
}
/* ----------------------end----------------------- */
#pragma endregion
int mod_pow(int x,int y) {
    int res = 1;
    while(y > 0) {
        if(y%2) {
            res = res*x%mod;
        }
        x = x*x%mod;
        y/=2;
    }
    return res;
}
int fac[2500], finv[2500], inv[2500];
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < 2500; i++){
        fac[i] = fac[i - 1] * i % mod;
        inv[i] = mod - inv[mod%i] * (mod / i) % mod;
        finv[i] = finv[i - 1] * inv[i] % mod;
    }
}
int COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % mod) % mod;
}
signed main() {
    int n;cin >> n;
    cout << (mod_pow(10,n) + mod_pow(8,n) - mod_pow(9,n)*2 +10*mod)%mod << endl;
    return 0;
}

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

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

  int a = N / 1000;
  int b = (N / 100) % 10;
  int c = (N / 10) % 10;
  int d = N % 10;

  if (b == c && (a == b || c == d)) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }

  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define Size 100005
#define Mod 1000000007LL
typedef unsigned long long ll;
int main(){
    int x,y;
    cin>>x>>y;
    vector<ll> vv,vv1;
    ll ara[100000];
    if(x==y){
        cout<<"0"<<"\n";
        return 0;
    }
    for(ll i=1; i<=100000; i++){

        vv.push_back((ll)x * (ll)i);
    }
    for(ll i=1; i<=100000; i++){
        vv1.push_back((ll)y * (ll)i);
    }
    ll mini2 = 10000000000;
    vector<ll> :: iterator it;
    for(int i=0; i<100000; i++){
            if(binary_search(vv.begin(),vv.end(),vv1[i])){
                it = lower_bound(vv.begin(),vv.end(),vv1[i]);
                mini2 = min(vv[it - vv.begin()],mini2);

            }
    }
    cout<<mini2<<"\n";

}


Measured memory_bytes: 2548
//(|||.()(||||||)
 //.(|||.()(||||||)
      #include<bits/stdc++.h>
    #define FiO ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
    #define PB push_back

    //using ll = long long;

    using namespace std;
    int main()
    {
        int n; cin>>n;
        char s[n+1]; cin>>s;
        int d =strlen(s);
        int cnt=0;
        for(int i=0;i<d;i++){
            if(s[i]!=s[i+1]){
                cnt++;
            }
        }
        cout<<cnt<<endl;
    }



Measured memory_bytes: 384
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <climits>
#include <cfloat>
#include <functional>

using namespace std;

int main()
{
	int H, W;
	while(true){
		cin >> H >> W;
		if(H == 0 && W == 0)
			break;
		else {
			for(int i = 0; i < H;++i) {
				for(int j = 0; j < W;++j) {
					cout << '#';
				}
				cout << endl;
			}
		}
		cout << endl;
	}
	return 0;
}

Measured memory_bytes: 1152
#include<bits/stdc++.h>
using namespace std;
#define int long long
signed main(){
    int n;
    cin >> n;
    vector<int> a(n);
    for(int i = 0; i < n; i++)
    cin >> a[i];
    int sum = 1e16;
    for(int i = 1; i <= 100; i++){
        int k = 0;
        for(int j = 0; j < n; j++){
            k += (i - a[j]) * (i - a[j]);
        }
        if(k < sum)
        sum = k;
    }
    cout << sum << endl;
}

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

vector<int> sgt;
int sz{1};

void g() {
	while (sz < 3e5) sz *= 2;
	sgt.resize(2*sz);
}

int f(int l, int r) {
	int ans{};
	l += sz, r += sz;
	while (l <= r) {
		if (l&1) ans = max(ans, sgt[l++]);
		if (!(r&1)) ans = max(ans, sgt[r--]);
		l /= 2, r /= 2;
	}
	return ans;
}

int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0), cout.tie(0);
	
	g();
	int n, k;
	cin >> n >> k;
	vector<int> a(n);
	for (int i = 0; i < n; i++) cin >> a[i];
	
	for (int i = 0; i < n; i++) {
		int z = f(max(0, a[i] - k), min(300000, a[i] + k));
	//	cout << z << endl;
		a[i] += sz;
		sgt[a[i]] = z + 1;
		a[i] /= 2;
		while (a[i]) {
			sgt[a[i]] = max(sgt[2*a[i]], sgt[2*a[i] + 1]);
			a[i] /= 2;
		}
	}
	cout << sgt[1];
}

Measured memory_bytes: 8476
#include<bits/stdc++.h>
using namespace std;
string a,b;
int main(){
    cin>>a;
    cin>>b;
    for(int i=0;i<max(a.length(),b.length());i++){
        cout<<a[i];
        if(b[i] != 0) cout<<b[i];
    }
    cout<<endl;
}

Measured memory_bytes: 256