akhauriyash/Code-Regression huggingface dataset:
def power_set(item_lists):

    p_sets = [[]]

    for item in item_lists:
        tmp = []
        for element in p_sets:
            tmp.append(element + [item])
        p_sets.extend(tmp)

    return p_sets

h,w,k= map(int,input().split())
a = []
for _ in range(h):
    a.append(input()) 
h1=[i for i in range(h)]
w1=[i for i in range(w)]
ans=0
for i in power_set(h1):
  for j in power_set(w1):
    cnt=0
    for x in i:
      for y in j:
        if a[x][y]=="#":
           cnt+=1
    if cnt==k:
        ans+=1
print(ans)

Measured memory_bytes: 9068
#include <bits/stdc++.h>
using namespace std;
const int MAXN = 200;
template <class T>
inline void _read(T &x)
{
	x = 0;
	char t = getchar();
	while (!isdigit(t)) t = getchar();
	while (isdigit(t))
	{
		x = x * 10 + t - '0';
		t = getchar();
	}
}
int n, x, y; 
char s[MAXN];
int main()
{
	_read(n), _read(x), _read(y);
	if (n * x > y) cout << y <<endl;
	else cout << n * x << endl;
	return 0;
}

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

int main() {
	int N;
	cin >> N;
	vector<int> A(N);
	for (int& i : A) cin >> i;
	for (int i = 0; i < N; ++i) {
		int j, tmp = A[i];
		for (j = i - 1; A[j] > tmp && j >= 0; --j) A[j + 1] = A[j];
		A[j + 1] = tmp;
		for (j = 0; j < N - 1; ++j) cout << A[j] << ' ';
		cout << A[N - 1] << endl;
	}
}


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

typedef long long ll;
typedef pair<int, int> P;
typedef tuple<int, int, int> T;

int MOD=1e9+7;
ll INF=1e18;

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

int main(){
    int n; cin>>n;
    ll sum=0;
    for(int i=0; i<n; i++){
        int a; cin>>a;
        sum+=(a-1);
    }
    cout << sum << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
    #include <ext/pb_ds/assoc_container.hpp> 
  #include <ext/pb_ds/tree_policy.hpp>
  #pragma comment(linker, "/stack:200000000")
  #pragma GCC optimize("O3")
  #pragma GCC optimize("Ofast")
  #pragma GCC optimize("unroll-loops")
    using namespace std;
  using namespace __gnu_pbds;
    #define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
    #define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    #define endl "\n"
    #define int long long
    #define all(v) v.begin(),v.end()
    #define rep(i,a,b) for(int i = a; i <=b; i++)
    #define rep2(i,a,b) for(int i = a; i>=b; i--)
    #define PB push_back
    #define MP make_pair
    #define db long double
    #define trace1(x)                cerr<<#x<<": "<<x<<endl
    #define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
    #define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
    #define trace3race4(a, b, c, d)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
    #define trace5(a, b, c, d, e)    cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
    #define trace6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl
    #define cases int testcases;cin>>testcases; while(testcases--)
    #define INF 2000000000
    const double PI = acos(-1);
    const int N = 100005;
    int lcm(int a,int b)
    {
    	return ((a/__gcd(a,b))  * b);
    }
  int32_t main() 
  {
    IOS



       
     	int n,m;
     	cin >> n >> m;

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

     	int ans = arr[1]/2;
     	for(int i = 2; i <= n; i++)
     	{
     		ans = lcm(ans,arr[i]/2);
     	}

     	if(ans > m)
     	{
     		cout << 0;
     		return 0;
     	}

     	for(int i = 1; i <= n; i++)
     	{
     		if((ans* 2)/arr[i] %2 == 0)
     		{
     			cout << 0;
     			return 0;
     		}
     	}


     		int ans1 =  (m - ans ) /(2 * ans) + 1;


     		cout << ans1;




     	




    return 0;
      }

Measured memory_bytes: 1024
#include<iostream>
#include <algorithm>
#include <string>
#include<math.h>
#define rep(i,n)for(int i=0;i<n;i++)
using namespace std;
int main() {
    string s;
    cin >> s;
    if (s[0] == '1') {
        s[0] = '9';
    }
    else if (s[0] == '9') {
        s[0] = '1';
    }
    if (s[1] == '1') {
        s[1] = '9';
    }
    else if (s[1] == '9') {
        s[1] = '1';
    }
    if (s[2] == '1') {
        s[2] = '9';
    }
    else if (s[2] == '9') {
        s[2] = '1';
    }
    cout << s << endl;
    return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
const ll MOD = 1e9 + 7;
const double PI = 3.141592653589793238;
const double EPS = 1e-10;
int a[100];
int main() {
	int N;
	cin >> N;
	double ave = 0;
	for (int i = 0; i < N; i++) {
		cin >> a[i];
		ave += a[i];
	}
	ave /= N;
	double d = abs(a[0] - ave);
	int ans = 0;
	for (int i = 1; i < N; i++) {
		if (d > abs(a[i] - ave)) {
			d = abs(a[i] - ave);
			ans = i;
		}
	}
	cout << ans << endl;
}


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

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



    cin.tie(0);
    ios::sync_with_stdio(false);

    /////////////////////
    // Write code below /
    /////////////////////
    char S[3],T[3];int cnt=0;

    rep(i,3){
        cin>>S[i];
    }
    rep(i,3){
        cin>>T[i];
        if(S[i]==T[i])cnt++;
    }

    cout<<cnt<<endl;

    return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize(2)
#include<bits/stdc++.h>
#define ll long long
#define maxn 705
#define inf 1e9
#define eps 1e-10
using namespace std;

inline int read()
{
	int x=0,w=1; char c=getchar();
	while(c<'0'||c>'9') {if(c=='-') w=-1; c=getchar();}
	while(c<='9'&&c>='0') {x=(x<<1)+(x<<3)+c-'0'; c=getchar();}
	return w==1?x:-x;
}

int n,m,mp[maxn][maxn],cnt,vis[maxn],col[maxn],f;
int t[maxn][2],dp[maxn][maxn*2];

inline void dfs(int u)
{
	t[cnt][col[u]]++; vis[u]=1; //cout<<cnt<<" "<<u<<endl;
	for(int i=1;i<=n;i++)
	{
		if(i==u) continue;
		if(mp[u][i]==0&&vis[i]==0) col[i]=col[u]^1,dfs(i);
		else if(mp[u][i]==0&&col[i]==col[u]) {f=1; return;}
	}
}

inline int cal(int x,int y){return x*(x-1)/2+y*(y-1)/2;}

int main()
{
	n=read(); m=read();
	for(int i=1;i<=m;i++) {int u=read(),v=read(); mp[u][v]=mp[v][u]=1;}
	for(int i=1;i<=n;i++) if(!vis[i]) cnt++,dfs(i); dp[0][0]=1;
	//cout<<cnt<<endl;
	for(int i=1;i<=cnt;i++)
	{
		for(int j=0;j<=n;j++)
		{
			dp[i][j+t[i][0]]|=dp[i-1][j];
			dp[i][j+t[i][1]]|=dp[i-1][j];
		}
	}
	int ans=inf;
	for(int i=1;i<=n;i++) if(dp[cnt][i]) ans=min(ans,cal(i,n-i));
	if(f==1) puts("-1"); else cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 6016
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int k=scan.nextInt();
		int s=scan.nextInt();
		scan.close();

		int cnt=0;
		for(int i=0;i<=k;i++) {
			for(int j=0;j<=k;j++) {
				//もしZ (s-i-j)が0より大きくて、ZがKよりも小さいなら
				//s=2 i=1 j=1 z=0 〇
				//s=2 i=1 j=2 z=-1 ×
				//s=2 i=1 j=1 z=2 ×
				if(s - i - j >= 0 && s - i - j <= k){
		            cnt++;
		        }
			}
		}

		System.out.println(cnt);

	}
}

Measured memory_bytes: 23252
#include <bits/stdc++.h>
using namespace std;
using namespace std::chrono;
#define idfc ios_base::sync_with_stdio(false),cin.tie(nullptr),cout.tie(nullptr)
//:/
#define pb emplace_back
#define mp make_pair
#define nt _ll128
#define ld long double
long double PI =3.14159265358979323846;
using ll = long long;



const ll modo=998244353;
const ll inf=1e17;
const ll ms=(2e6)+5;



int go(ll a,ll b)
{
    int x=0;
    int y=0;

    while(a)
    {
        x++;
        a/=10;
    }
    while(b)
    {
        y++;
        b/=10;
    }
    return max(x,y);
}



int main()
{
    idfc;


    ll n;
    cin>>n;

    int ans=INT_MAX;


    for(ll i=1;i*i<=n;i++)
    {
        if(!(n%i))
        {
            ans=min(ans,go(i,n/i));
        }
    }

    cout<<ans;


    return 0;
}

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

int a[101]={0};

int main(){
	int n, x;
	cin >> n;
	
	for (int i=1; i<=n; i++){
		cin >> x;
		a[x]=1;
	}
	
	int s=0;
	for(int i=1; i<=100; i++){
		if (a[i]==1) s++;
	}
	
	cout << s;
	return 0;
}

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

#define reps(i,s,n) for(int (i) = (s); (i) < (n); (i)++)
#define rep(i,n) reps(i,0,n)
using namespace std;
using ll = long long;
using pii = pair<int,int>;
using vi = vector<int> ;
using vl = vector<ll>;

int main(){
    int n,m;
    cin >> n >> m;
    
    vector<bool> vec(n,false);
    vector<int> ball(n,1);
    int x,y;

    vec[0] = true;
    rep(i,m){
        cin >> x >> y;
        x--; y--;
        if(vec[x]){        
            vec[y] = true;
        }
        if(vec[x] && ball[x] == 1){
            vec[x] = false;
        }
        ball[x]--;
        ball[y]++;
        
    }
    int cnt = 0;
    rep(i,n){
        if(vec[i]) cnt++;
    }
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 3700
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n, cnt=0;
    cin>>n;
    int a[n];
    for(int i=0; i<n; i++) cin>>a[i];
    sort(a, a+n);
    for(int i=0; i<n-2; i++){
        for(int j=i+1; j<n-1; j++){
            for(int k=j+1; k<n; k++){
                if(a[i]!=a[j] && a[j]!=a[k]){
                    if(a[i]+a[j]>a[k]) cnt++;
                }
            }
        }
    }
    cout<<cnt;
}

Measured memory_bytes: 3636
#include <iostream>
#include <vector>
#include <cmath>
#include <string>
#include <algorithm>
#include <iomanip>
#include <map>
#include <bitset>
#include <cstdio>
#include <set>
#include <stack>
#include <queue>
#include <cassert>
#include <numeric>
using namespace std;
typedef long long ll;
#define FOR(i,a,b) for (ll i=(a),__last_##i=(b);i<__last_##i;i++)
#define RFOR(i,a,b) for (ll i=(b)-1,__last_##i=(a);i>=__last_##i;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define __GET_MACRO3(_1, _2, _3, NAME, ...) NAME
#define rep(...) __GET_MACRO3(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define rrep(...) __GET_MACRO3(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)
template<typename T> istream &operator>>(istream &is, vector<T> &v){ for (auto &x : v) is >> x; return is; }
template<typename T> ostream& operator<<(ostream& os, const vector<T>& v) {
    REP(i,v.size()){if(i)os<<" ";os<<v[i];}return os;}
template<typename T> ostream& operator<<(ostream& os, const vector<vector<T>>& v) {
    REP(i,v.size()){if(i)os<<endl;os<<v[i];}return os;}
#define vi vector<int>
#define vii vector<vector<int>>
#define mii map<int,int>
#define Sort(v) sort(v.begin(),v.end())
#define Reverse(v) reverse(v.begin(),v.end())
#define ALL(a)  (a).begin(),(a).end()
#define pb push_back
#define mp make_pair
//#define int ll

const int md = 1000000007;
const int INF = 1<<30;



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

    rep(i, k-(n-1), k+n){
        cout << i << " ";
    }
    cout << endl;
}


Measured memory_bytes: 256
N = int(input())
a = [int(i) for i in input().split()]
cnt = 0
s = 0
smallest = 10000000000
for i in range(len(a)):
    if a[i] < 0:
        cnt += 1

    smallest = min(abs(a[i]), smallest)
    s += abs(a[i])

if cnt % 2 == 0:
    print(s)
else:
    print(s - 2 * smallest)

Measured memory_bytes: 14284
#include <iostream>
#include <string>
#include <vector>

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

using std::cin;
using std::cout;
using std::endl;
using std::string;
using std::vector;

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

  bool buy = false;
  for (int i = 0; i <= N / 4; i++)
  {
    int n = N - i * 4;
    if (n % 7 == 0)
    {
      buy = true;
      break;
    }
  }

  if (buy)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;

  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;
class Main{
	public static void main(String[] args) {
		int x,i=0;
		Scanner kbd = new Scanner(System.in);
		x = kbd.nextInt();
		while(x != 0){
			System.out.println("Case " + (++i) +": " + x);
			x = kbd.nextInt();
		}
	}
}

Measured memory_bytes: 42660
import java.util.*;

class Main{
	public static void main(String[] $){
		final Scanner s=new Scanner(System.in);
		final int n=s.nextInt();
		var l=new ArrayList<ArrayList<Integer>>(n-1);
		l.add(new ArrayList<>());
		for(int i=1;i<n;++i){
			l.add(new ArrayList<>());
			l.get(s.nextInt()-1).add(i+1);
		}
		l.forEach(o->System.out.println(o.size()));
	}
}


Measured memory_bytes: 82432
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <map>
#include <cmath>
#include <bitset>
#include <iomanip>
#include <climits>

using namespace std;

long long takeAfter(const vector<long long>& a, size_t prevIndex, size_t currIndex, size_t chosenNbSoFar, size_t outstandingNb, long long minimum, vector<vector<bool> >& done, vector<vector<long long> >& cache) {
    if (outstandingNb == 0) {
        return 0ll;
    }
    bool cond = currIndex < a.size();
    cond &= (a.size() - currIndex + 1) / 2 >= outstandingNb;
    if (!cond) {
        return minimum;
    }
    size_t idx = (outstandingNb == (a.size() - currIndex + 1) / 2 ? 0 : 1);
    if (done[currIndex][idx]) {
        return cache[currIndex][idx];
    }
    if (currIndex - prevIndex == 1) {
        return takeAfter(a, prevIndex, currIndex + 1, chosenNbSoFar, outstandingNb, minimum, done, cache);
    }
    long long ret = max(
        takeAfter(a, currIndex, currIndex + 1, chosenNbSoFar + 1, outstandingNb - 1, minimum, done, cache) + a[currIndex]
        , takeAfter(a, prevIndex, currIndex + 1, chosenNbSoFar, outstandingNb, minimum, done, cache)
    );
    done[currIndex][idx] = true;
    cache[currIndex][idx] = ret;
    return ret;
}

int main() {
    int N;
    cin >> N;
    vector<long long> A(N, 0ll);
    for (int i = 0; i < N; ++i) {
        cin >> A[i];
    }

    long long minimum = 0;
    for (int i = 0; i < N; ++i) {
        if (A[i] < 0) {
            minimum += A[i];
        }
    }

    vector<vector<bool> > done(N, vector<bool>(2, false));
    vector<vector<long long> > cache(N, vector<long long>(2, minimum));

    long long ans = takeAfter(A, -2, 0, 0, N / 2, minimum, done, cache);
    cout << ans << endl;
    //cout << setprecision(15) << endl;
    return 0;
}


Measured memory_bytes: 42312
def c_best_of_2n_minus_1(N, A, B, C, MOD=10**9 + 7):
    class Combination(object):
        """
        組み合わせ
        参考: https://harigami.net/contents?id=5f169f85-5707-4137-87a5-f0068749d9bb
        """
        __slots__ = ["mod", "factorial", "inverse"]

        def __init__(self, max_n: int = 10**6, mod: int = 10**9 + 7):
            fac, inv = [1], []
            fac_append, inv_append = fac.append, inv.append

            for i in range(1, max_n + 1):
                fac_append(fac[-1] * i % mod)

            inv_append(pow(fac[-1], mod - 2, mod))

            for i in range(max_n, 0, -1):
                inv_append(inv[-1] * i % mod)

            self.mod, self.factorial, self.inverse = mod, fac, inv[::-1]

        def combination(self, n, r):
            if r == n or r == 0:
                return 1
            if r > n:
                return 0
            return self.factorial[n] * self.inverse[r] * self.inverse[n - r] % self.mod

    inverse_100 = pow(100, MOD - 2, MOD)
    a = (A * inverse_100) % MOD
    b = (B * inverse_100) % MOD
    c = (C * inverse_100) % MOD

    inverse_a_plus_b = pow(a + b, MOD - 2, MOD)
    a = (a * inverse_a_plus_b) % MOD
    b = (b * inverse_a_plus_b) % MOD

    pow_a = [1]
    pow_b = [1]
    for _ in range(2 * N):
        pow_a.append((pow_a[-1] * a) % MOD)
        pow_b.append((pow_b[-1] * b) % MOD)

    comb = Combination(2 * N, MOD)
    ans = 0
    for m in range(N, 2 * N):
        ans += (comb.combination(m - 1, N - 1)
                * (pow_a[N] * pow_b[m - N] + pow_a[m - N] * pow_b[N])
                * m)
        ans %= MOD
    ans *= pow(1 - c, MOD - 2, MOD)
    return ans % MOD
    # 参考: https://atcoder.jp/contests/m-solutions2019/submissions/5745509

N, A, B, C = [int(i) for i in input().split()]
print(c_best_of_2n_minus_1(N, A, B, C))

Measured memory_bytes: 36372
#include<bits/stdc++.h>
using namespace std;
#define int long long
template <class Q>
void clearQueue(Q & q) {
    q = Q();
}
int dp[100005];
vector<int>adj[100005];
bool visited[100005];
void visit(int vertex){
	dp[vertex]=0;
	visited[vertex]=1;
	for(auto edge:adj[vertex]){
		if(!visited[edge]){
			visit(edge);
		}
		dp[vertex]=max(dp[vertex],1+dp[edge]);
	}
}
void solve(){
	memset(visited,false,sizeof(visited));
	memset(dp,0,sizeof(dp));
	int n,m;cin>>n>>m;
	int x,y;
	for(int i=0;i<m;i++){
		cin>>x>>y;
		adj[x].push_back(y);
	}
	for(int i=1;i<=n;i++){
		if(!visited[i]){
			visit(i);
		}
	}
	int maxx=-1;
	for(int i=1;i<=n;i++){
		maxx=max(maxx,dp[i]);
	}
	cout<<maxx;
}
int32_t main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);cout.tie(NULL); 
	int T=1;
	// cin>>T;
	while(T--){
		solve();
	}
	return 0;
}

Measured memory_bytes: 12600
#include <iostream>
#include <algorithm>
#include <string>
#include <list>
#include<vector>
#include <sstream>
#include <stdio.h>
#include <valarray>
#include <iomanip>
#include <unordered_set>
#include <set>
using namespace std;

int main(void)
{
	long long Number;
	long long OffsetNum;
	std::string OutString;
	std::string Alphabet = "abcdefghijklmnopqrstuvwxyz";
	int OutNumber = 0;
	cin >> Number;

	int Offset =0;

	do
	{
		Number -= 1;
		Offset = (Number % 26);

		OutString = OutString + Alphabet[Offset];

		Number /= 26;
	} while (Number != 0);

	std::reverse(OutString.begin(), OutString.end());
	cout << OutString << endl;

	return 0;
}

Measured memory_bytes: 3100
#include <stdio.h>
int main(){
	int P,Q,R;
	int min; 
	scanf("%d %d %d",&P,&Q,&R);
	if(P+Q>=P+R&&Q+R>=P+R){
		min=P+R;
	}else if(P+R>=P+Q&&Q+R>=P+Q){
		min=P+Q;
	}else{
		min=Q+R;
	}	
	printf("%d",min);
	return 0;
}

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

using namespace std;

int main(){

	long long int a,b;
	cin>>a>>b;

	long long int c;
	if(a>b){
		c=a;
		a=b;
		b=c;
	}
	long long int share = 1;
	for(int i=1;i<a+1;i++){
		if((a%i==0)&&(b%i==0)){
			a/=i;
			b/=i;
			share*=i;
			i=1;
		}
	}
	cout<<a*b*share;

	cout<<endl;

	return 0;
}


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

#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define SORT(v, n) sort(v, v+n)
#define pb(a) push_back(a)
#define eb(a) emplace_back(a)
#define vi vector<int>
#define ddvi vector<vector<int>>

using namespace std;
typedef long long ll;
typedef pair<int, int> P;

int main(){
cin.tie(0);
ios::sync_with_stdio(false);
// ここに処理を記述

    int N;
    cin >> N;

    cout << (N + 1)/2 << endl;

return 0;
}

Measured memory_bytes: 256
#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;
}

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

int main(){
    VL a(3);
    rep(i,3) cin >> a[i];
    sort(a.begin(), a.end());
    cout << a[2]*10 + a[1] + a[0] << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <map>
#include <stack>
#include <queue>
using namespace std;
using ll = long long;
using P = pair<int, int>;

int main()
{
    ll a, b, x;
    scanf("%lld %lld %lld", &a, &b, &x);
    ll ra = a % x;
    ll rb = b % x;
    ll m = ra == 0 ? a / x : a / x + 1;
    ll n = b / x;
    ll ans = n - m >= 0 ? n - m + 1 : 0;
    printf("%lld\n", ans);
    return 0;
}


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

int main() {
  int N;
  cin >> N;
  vector<int> vec(N);
  for (int i = 0; i < N; i++) {
    cin >> vec.at(i);
  }
  sort(vec.begin(), vec.end());
  reverse(vec.begin(), vec.end());
  int A = 0;
  int B = 0;
  for (int i = 0; i < N; i += 2) {
    A += vec.at(i);
  }
  for (int i = 1; i < N; i += 2) {
    B += vec.at(i);
  }
  cout << A - B << endl;
}


Measured memory_bytes: 256
#include<cstdio>
#include<cmath>
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
    int A,B,C,D,P;
    cin>>A>>B>>C>>D>>P;
    cout<<min(A*P,B+max(P-C,0)*D)<<endl;
    return 0;
}

Measured memory_bytes: 1160
import heapq
n = int(input())
src = list(map(int, input().split()))
sorted_src = sorted(src)
heapq.heapify(sorted_src)
count = 0
for i in range(n):
    a = heapq.heappop(sorted_src)
    heapq.heappop(sorted_src)
    count += a
print(count)

Measured memory_bytes: 3060
// Code for A - Nickname
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define FOR(i,x,y) for(ll i=x;i<(ll)(y);i++)

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

  cout << s.substr(0, 3) << endl;
  return 0;
}


Measured memory_bytes: 3596
#include<iostream>
#include<cstdio>
#include<math.h>
#include<string>
#include<algorithm>
#include<functional>
#include<vector>
#include<set>
#include<map>
#define INF 999999
#define EPS 1.0e-6

using namespace std;

typedef long long ll;
typedef pair<int, int> P;
typedef pair<int, P> PP;

int n, k, l;
vector<int> road[210000];
vector<int> train[210000];
int flag[210000];
P memo[210000];

void dfs_r(int s,int c)
{
	flag[s] = 1;
	memo[s].first = c;
	for (int i = 0; i < road[s].size(); i++) {
		if (flag[road[s][i]] == 0) {
			dfs_r(road[s][i],c);
		}
	}
}

void dfs_t(int s, int c)
{
	flag[s] = 1;
	memo[s].second = c;
	for (int i = 0; i < train[s].size(); i++) {
		if (flag[train[s][i]] == 0) {
			dfs_t(train[s][i], c);
		}
	}
}

void scc() {
	fill(flag, flag + n, 0);
	int c = 0;
	for (int i = 0; i < n; i++) {
		if (flag[i] == 0) {
			dfs_r(i, c);
			c++;
		}
	}
	c = 0;
	fill(flag, flag + n, 0);
	for (int i = 0; i < n; i++) {
		if (flag[i] == 0) {
			dfs_t(i, c);
			c++;
		}
	}
}


int main()
{
	cin >> n >> k >> l;
	int a,b;
	for (int i = 0; i < k; i++) {
		cin >> a >> b;
		a--; b--;
		road[a].push_back(b);
		road[b].push_back(a);
	}
	for (int i = 0; i < l; i++) {
		cin >> a >> b;
		a--; b--;
		train[a].push_back(b);
		train[b].push_back(a);
	}
	scc();
	map<P,int> mp;
	for (int i = 0; i < n; i++) {
		//cout << memo[i].first << " "<<memo[i].second << endl;
		if (mp[memo[i]] != 0)mp[memo[i]]++;
		else mp[memo[i]] = 1;
	}
	for (int i = 0; i < n-1; i++) {
		cout << mp[memo[i]] << " ";
	}
	cout << mp[memo[n - 1]] << endl;

	return 0;
}

Measured memory_bytes: 29184
import numpy as np

import sys
input = sys.stdin.buffer.readline

N, K = map(int, input().split())
A = np.array(input().split(), np.int64)
F = np.array(input().split(), np.int64)

A.sort()
F.sort()

F= F[::-1]

left = -1
right = (A * F).sum()
while left + 1 < right:
  middle = (left + right) // 2
  right_arr = np.maximum(0, A - middle // F).sum() <= K
  if right_arr:
    right = middle
  else:
    left = middle
print(right) 


Measured memory_bytes: 26092
from heapq import heappush, heappop, heapify
from collections import deque, defaultdict, Counter
import itertools
from itertools import permutations, combinations, accumulate
import sys
import bisect
import string
import math
import time


def I(): return int(input())


def S(): return input()


def MI(): return map(int, input().split())


def MS(): return map(str, input().split())


def LI(): return [int(i) for i in input().split()]


def LI_(): return [int(i)-1 for i in input().split()]


def StoI(): return [ord(i)-97 for i in input()]


def ItoS(nn): return chr(nn+97)


def input(): return sys.stdin.readline().rstrip()


def show(*inp, end='\n'):
    if show_flg:
        print(*inp, end=end)


YN = ['No', 'Yes']
MOD = 10**9+7
inf = float('inf')
IINF = 10**10
l_alp = string.ascii_lowercase
u_alp = string.ascii_uppercase
ts = time.time()
sys.setrecursionlimit(10**6)
nums = ['1', '2', '3', '4', '5', '6', '7', '8', '9', '10']

show_flg = False
# show_flg = True


def erase_overlap_intervals(intervals):
        """
        :type intervals: List[Interval]
        :rtype: int
        """
        result, prev = 0, 0
        for i in range(1, len(intervals)):
            if intervals[i][0] < intervals[prev][1]:
                if intervals[i][1] < intervals[prev][1]:
                    prev = i
                result += 1
            else:
                prev = i
        return result


def main():
    N = I()
    XL = [None] * N

    for i in range(N):
        X, L_ = MI()
        XL[i] = (X, L_, i)

    arr = [None] * N
    for i in range(N):
        arr[i] = (XL[i][0] - XL[i][1], XL[i][0] + XL[i][1])

    arr = sorted(arr, key=lambda a: a[1])
    print(N - erase_overlap_intervals(arr))


if __name__ == '__main__':
    main()


Measured memory_bytes: 61912
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;

class TEST{
	static void Main(){
		Sol mySol =new Sol();
		mySol.Solve();
	}
}

class Sol{
	public void Solve(){
		Array.Sort(A);
		Array.Reverse(A);
		long diff = 0;
		for(int i=0;i<N;i++) diff += (i % 2 == 0 ? A[i] : -A[i]);
		Console.WriteLine(diff);
	}
	int N;
	long[] A;
	public Sol(){
		N = ri();
		A = rla();
	}

	static String rs(){return Console.ReadLine();}
	static int ri(){return int.Parse(Console.ReadLine());}
	static long rl(){return long.Parse(Console.ReadLine());}
	static double rd(){return double.Parse(Console.ReadLine());}
	static String[] rsa(char sep=' '){return Console.ReadLine().Split(sep);}
	static int[] ria(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>int.Parse(e));}
	static long[] rla(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>long.Parse(e));}
	static double[] rda(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>double.Parse(e));}
}


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

#define int long long
const int N = 1e5 + 10 ;
int32_t main(){
	int vis[N] = {} ;
	int cnt = 0 ;
	int n , x , m ;
	cin >> n >> x >> m ;
	int mod = m ;
	int sum = 0 ;
	while(!vis[x] && cnt < n){
		vis[x] = cnt ;
		sum += x ;
		x = (x*x) % mod ;
		cnt++ ;
	}
	if(cnt == n){
		cout << sum ;
	} else {
		n -= cnt ;
		int t = cnt - vis[x] ;
		int cur = 0 ;
		for(int i = 0 , cx = x ; i < t ; i++){
			cur += cx ;
			cx = (cx * cx ) % mod ;
		}
		sum += (n / t)*cur ;
		n %= t ;
		cnt = 0 ;
		while(cnt < n){
			sum += x ;
			x = (x*x) % mod ;
			cnt++ ;
		}
		cout << sum ;
	}
	return 0 ;
}



Measured memory_bytes: 4412
#include <iostream>

using namespace std;

int main(void){
    string S;
    long long K;; 
    cin >> S >> K; // 入力
    string s = S + S; // 入力を2つ繋げる
    long long c1 = 0;  
    long long c2 = 0;  
    long long n = S.length(); // 長さ
    long long t = 1; // 全部同じかどうか
    for (long long i = 0; i < n - 1; i++) {
        if (S[i] != S[i + 1]) {
            t = 0;
        }   
    }   
    long long ans;
    if (t) { //文字列が全部同じ場合
        ans = (n * K) / 2;
        cout << ans << endl;
        return 0;
    }   
    for (long long i = 0; i < n - 1; i++) {
        if(S[i] == S[i + 1]) { // まずS(大文字)で一巡 つまり最初の部分
            c1++;
            S[i + 1] = '0'; // 全部0にしていいんかな->大丈夫
        }   
    }   
    for (long long i = 0; i < n * 2 - 1; i++) {
        if (s[i] == s[i + 1]) { // 後半だけ操作したいというモチベで2つ繋がってる文字列について操作する それはs = S + S
            c2++;
            s[i + 1] = '0';
        }   
    }   
    c2 = c2 - c1; // 後半の数だけ取り出す
    //cout << c1 << endl;
    //cout << c2 << endl;
    ans = c1 + c2 * (K - 1); // 最初を除いてc2の数 + 最初のc1
    cout << ans << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cmath>

using namespace std;

main(){

	int n, A[1000];


	while (1){

		cin >> n;

		if ( n == 0 ) break;


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

		int sum = 0;

		for ( int i = 0; i < n; i++ ) sum += A[i];

		double avg = 1.0 * sum/n;

		double dist = 0.0;

		for ( int i = 0; i < n; i++ ){

			dist += ( avg - A[i]) * ( avg - A[i]);

		}

		printf( "%1f\n", sqrt(dist/n));

	}

}

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

#define pb push_back

using ll=long long;
using vll=vector<ll>;
using vvll=vector<vll>;
using vi=vector<int>;
using vvi=vector<vi>;
using pii=pair<int,int>;
using vpii=vector<pii>;
using vvpii=vector<vpii>;


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

    int n, m;
    cin >> n >> m;
    vpii jobs(n);
    for (int i=0; i<n; ++i)
        cin >> jobs[i].first >> jobs[i].second;
    sort(jobs.begin(), jobs.end());
    int endj = 0;
    multiset<int> eligval;
    ll totval = 0;
    for (int len=1; len<=m; ++len) {
        while (endj < n && jobs[endj].first <= len) {
            eligval.insert(jobs[endj].second);
            ++endj;
        }
        if (eligval.size() > 0) {
            auto maxit = prev(eligval.end());
            //cerr << "DBG " << len << " " << *maxit << endl;
            totval += *maxit;
            eligval.erase(maxit);
        }
    }
    cout << totval << endl;
}


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

typedef long long ll;

#define REP(i, n) for(int i=0; i<(n); i++)
#define REPS(i, n) for(int i=0; i<=(n); i++)
#define FOR(i, a, b) for(int i=a; i<(b); i++)
#define FORS(i, a, b) for(int i=a; i<=(b); i++)
// for container x
#define ALL(v) (v).begin(),(v).end()
#define RALL(v) (v).rbegin(),(v).rend()
#define SIZE(v) ((ll)(v).size())
#define MAX(v) *max_element(ALL(v))
#define MIN(v) *min_element(ALL(v))
#define UNIQUE(v) v.erase(unique(ALL(v)), v.end())

struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;

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

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

int main() {
  int N;
  cin >> N;
  vector<int> A(N), B(N);
  for (int i = 0; i < N; i++) cin >> A[i] >> B[i];
  sort(A.begin(), A.end());
  sort(B.begin(), B.end());
  int A_mid, B_mid;
  if (N % 2 == 1) {
    A_mid = A[N/2];
    B_mid = B[N/2];
    cout << B_mid - A_mid + 1 << endl;
  }
  else {
    A_mid = (A[N/2-1] + A[N/2])/2;
    B_mid = (B[N/2-1] + B[N/2])/2;
    int tmp = 0;
    if (2*A_mid != A[N/2-1] + A[N/2]) tmp--;
    if (2*B_mid != B[N/2-1] + B[N/2]) tmp++;
    cout << 2*(B_mid - A_mid) + 1 + tmp << endl;
  }
}


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

int main(void) {
	int biru_kai;
	int biru[2][102];
	int biru_jump[2][102];
	int i,j,k;
	int now_min;
	while(1) {
		scanf("%d",&biru_kai);
		if(biru_kai==0)break;
		memset(biru,0,sizeof(biru));
		for(i=1;i<=biru_kai;i++)scanf("%d",&biru[0][i]);
		for(i=1;i<=biru_kai;i++)scanf("%d",&biru[1][i]);
		memset(biru_jump,0xFF,sizeof(biru_jump));
		for(i=1;biru[0][i]==1 && biru[0][i+1]==1;i++);
		biru_jump[0][i]=0;
		for(i=1;biru[1][i]==1 && biru[1][i+1]==1;i++);
		biru_jump[1][i]=0;
		for(k=0;k<100;k++) {
			for(i=2;i<=biru_kai;i++) {
				now_min=0x7fffffff;
				if(biru_jump[0][i-2]>=0 && now_min>biru_jump[0][i-2]+1) {
					now_min=biru_jump[0][i-2]+1;
				}
				if(biru_jump[0][i-1]>=0 && now_min>biru_jump[0][i-1]+1) {
					now_min=biru_jump[0][i-1]+1;
				}
				if(now_min<0x7fffffff) {
					if(biru[1][i]==1) {
						for(j=i;biru[1][j]==1 && biru[1][j+1]==1;j++);
					} else if(biru[1][i]==2) {
						for(j=i;biru[1][j]==2;j--);
					} else {
						j=i;
					}
					if(biru_jump[1][j]<0 || biru_jump[1][j]>now_min) {
						biru_jump[1][j]=now_min;
					}
				}
				now_min=0x7fffffff;
				if(biru_jump[1][i-2]>=0 && now_min>biru_jump[1][i-2]+1) {
					now_min=biru_jump[1][i-2]+1;
				}
				if(biru_jump[1][i-1]>=0 && now_min>biru_jump[1][i-1]+1) {
					now_min=biru_jump[1][i-1]+1;
				}
				if(now_min<0x7fffffff) {
					if(biru[0][i]==1) {
						for(j=i;biru[0][j]==1 && biru[0][j+1]==1;j++);
					} else if(biru[0][i]==2) {
						for(j=i;biru[0][j]==2;j--);
					} else {
						j=i;
					}
					if(biru_jump[0][j]<0 || biru_jump[0][j]>now_min) {
						biru_jump[0][j]=now_min;
					}
				}
			}
		}
		now_min=0x7fffffff;
		if(biru_jump[0][biru_kai]>=0 && now_min>biru_jump[0][biru_kai]) {
			now_min=biru_jump[0][biru_kai];
		}
		if(biru_jump[1][biru_kai]>=0 && now_min>biru_jump[1][biru_kai]) {
			now_min=biru_jump[1][biru_kai];
		}
		if(now_min==0x7fffffff)puts("NA");
		else printf("%d\n",now_min);
	}
	return 0;
}

Measured memory_bytes: 0
import java.util.ArrayList;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner s = new Scanner(System.in);
        int t =s.nextInt();
        int [] arr = new int[t];
        int [] minpatharr = new int[t];
        for(int i=0;i<t;i++)
            arr[i]=s.nextInt();
        minpatharr[0]=0;
        minpatharr[1]=Math.abs(arr[1]-arr[0]);
        for(int i=2;i<t;i++){
            minpatharr[i]=Math.min(Math.abs(arr[i]-arr[i-1])+minpatharr[i-1],Math.abs(arr[i]-arr[i-2])+minpatharr[i-2]);
        }
        System.out.println(minpatharr[t-1]);
    }
}


Measured memory_bytes: 49176
#include<stdio.h>

int main() {
   int X;
   int happy = 0;

   scanf("%d", &X);

   while(X >= 5) {
      if(X >= 500) {
         happy += 1000;
         X -= 500;
      }else {
         happy += 5;
         X -= 5;
      }
   }

   printf("%d\n", happy);
   return 0;

}


Measured memory_bytes: 1736
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
typedef long long LL;
int N;

int main(){
	int K,A,B;
	cin>>K>>A>>B;
	bool check=false;
	for(int i=A;i<=B;i++){
		if(i%K==0)check=true;
	}
	if(check){
		cout<<"OK"<<endl;
	}else{
		cout<<"NG"<<endl;
	}
}

Measured memory_bytes: 3644
#include<iostream>
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<vector>
#include<cstdlib>
#include<map>
#include<fstream>
#include<string>
#include<sstream>
#include<iomanip>
#include<stdio.h>
#include<iostream>
#include<numeric>
using namespace std;

int main() {
	int x, a;
	cin >> x >> a;
	if (a > x)
		cout << 0 << endl;
	else
		cout << 10 << endl;
}


Measured memory_bytes: 256
from collections import Counter

X, N = map(int, input().split())
P = list(map(int, input().split()))
c = Counter(P)

if not(X in c):
    print(X)
    exit(0)

for i in range(200):
    tmp1 = X-i
    if not(tmp1 in c):
        print(tmp1)
        exit(0)

    tmp2 = X+i
    if not(tmp2 in c):
        print(tmp2)
        exit(0)


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

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

    vector <int> x(m);
    rep(i,m) cin >> x[i];

    sort(all(x));

    if(n >= m){
        cout << 0 << endl;
        return 0;
    }

    vector <int> dec(m-1);
    rep(i,m-1) dec[i] = x[i+1] - x[i];

    sort(all(dec));
    reverse(all(dec));
    dec.erase(dec.begin(), dec.begin()+(n-1));

    int ans=0;
    for(int i=0; i<dec.size();i++){
        ans += dec[i];
    }

    cout << ans << endl;

}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#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 fs first
#define sc second
typedef pair<ll, ll> l_l;
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

int main(){
  string s;
  cin>>s;
  string ans;
  rep(i,s.size()){
    if(s[i]=='B'){
      if(ans.size())ans=ans.substr(0,ans.size()-1);
      
    }
    else ans+=s[i];
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 256
from collections import deque
x=int(input())
y=list(map(int, input().split()))

d = deque()
e=[]
for i in range (x):
	if i%2==0:
		d.append(y[i])
	else:
		d.appendleft(y[i])
if i%2==0:
	for i in range(x):
		e.append(d[((-i)-1)])
	print(*(list(e)))
else:
	print(*(list(d)))

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


//defines...
#define ll long long
#define boost ios_base::sync_with_stdio(false);cin.tie(NULL);
#define pb push_back
#define mp make_pair
#define in insert
#define pi 2*acos(0.0)1
#define srt(s) sort(s.begin(),s.end())
#define rsrt(s) sort(s.rbegin(),s.rend())
#define all(x) x.begin(),x.end()
#define mem(a, b) memset(a, b, sizeof(a))

const ll mod=1e9+7;
const ll MX=2e5+5;

//code goes from here...



int main()
{
#ifndef ONLINE_JUDGE
    //freopen("input.txt", "r", stdin);

    freopen("output.txt", "w", stdout);
#endif

    boost
    //---------------------------------
    ll n;
    cin >> n;

    vector <ll > a;

    a.pb(n);
    ll t;
    
    if(n%2) t=3*n+1;
    else t=n/2;
    ll cnt=1;
    while(find(all(a),t)==a.end())
    {
        a.pb(t);
        if(t%2) t=3*t+1;
        else t=t/2;
        cnt++;

    }
    cout << cnt+1 << endl;
    
    
    //---------------------------------
    
    return 0;
}


Measured memory_bytes: 3656
#include <bits/stdc++.h>
#define pii pair<int, int>
using namespace std;

map<int, pii> pos;
bool vis[5][5];
int A[5][5];
int N;

int main() {
  for(int i = 1; i<= 3; i++) {
    for(int j = 1; j <= 3; j++) {
      cin >> A[i][j];
      pos[A[i][j]] = make_pair(i, j);
    }
  }
  cin >> N;
  int now;
  for(int i = 1; i <= N; i++) {
    cin >> now;
    if(pos.count(now)) {
      vis[pos[now].first][pos[now].second] = 1;
    }
  }
  int hor[5], ver[5];
  bool ok = 0;
  for(int i = 1; i <= 3; i++) {
    ok |= vis[i][1] & vis[i][2] & vis[i][3];
    ok |= vis[1][i] & vis[2][i] & vis[3][i];
  }
  ok |= vis[1][1] & vis[2][2] & vis[3][3];
  ok |= vis[1][3] & vis[2][2] & vis[3][1];
  if(ok) cout << "Yes\n";
  else cout << "No\n";
}

Measured memory_bytes: 256
# include <iostream>
using namespace std;
int main()
{
  int N,sum=0;
  cin>>N;
  const int n=N;
  int d[n];
 for(int i=0;i<N;i++){
   cin>>d[i];
 }
 for(int i=0;i<N;i++){
   for(int j=i+1;j<N;j++){
     sum+=d[i]*d[j];
   }
 }
  cout<<sum<<endl;
  return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <queue>

using namespace std;

int main()
{
  int n, m;
  priority_queue<int64_t> a;
  cin >> n >> m;

  for (int i = 0; i < n; i++) {
    int64_t a1;
    cin >> a1;
    a.push(a1);
  }

  for (int i = 0; i < m; i++) {
    int64_t a1 = a.top();
    a.pop();
    a.push(a1 >> 1);
  }

  int64_t acc = 0;
  for (int i = 0; i < n; i++) {
    acc += a.top();
    a.pop();
  }

  cout << acc << endl;
  return 0;
}


Measured memory_bytes: 1400
#include<bits/stdc++.h>
#define ll long long
#define pll pair<long long,long long>
#define pii pair<int,int>
#define mp make_pair
#define pb push_back
#define F first
#define S second
#define forn(i, n) for(int i=0; i<int(n); i++)
#define Forn(i, n) for(int i=1; i<=int(n); i++)
using namespace std;

int a[5];

int main()
{
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    forn(i, 6)
    {
        int x;
        cin >> x;
        a[x]++;
    }
    if(*max_element(a+1, a+5) == 3)
    {
        cout << "NO" << endl;
    }
    else cout << "YES" << endl;
}


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

using namespace std;

#define INF 1001000100010001000
#define MOD 1000000007
#define EPS 1e-10
#define int long long
#define rep(i, N) for (int i = 0; i < N; i++)
#define Rep(i, N) for (int i = 1; i < N; i++)
#define For(i, a, b) for (int i = (a); i < (b); i++)
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define pii pair<int, int>
#define vi vector<int>
#define vvi vector<vi >
#define vb vector<bool>
#define vvb vector<vb >
#define vp vector< pii >
#define all(a) (a).begin(), (a).end()
#define Int(x) int x; cin >> x;
#define int2(x, y) Int(x); Int(y);
#define int3(x, y, z) Int(x); int2(y, z);
#define in(x, a, b) ((a) <= (x) && (x) < (b))
#define fir first
#define sec second
#define ffir first.first
#define fsec first.second
#define sfir second.first
#define ssec second.second
#define Decimal fixed << setprecision(10)

//int dxy[5] = {0, 1, 0, -1, 0};
// cmd

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

    int3(x, y, z);
    Int(k);
    vector<int> a(x);
    for (int i = 0; i < x; i++) {
        cin >> a[i];
    }
    vector<int> b(y);
    for (int i = 0; i < y; i++) {
        cin >> b[i];
    }
    vector<int> c(z);
    for (int i = 0; i < z; i++) {
        cin >> c[i];
    }
    vector<int> ab(x * y);
    rep(i, x) {
        rep(j, y) {
            ab[i * y + j] = a[i] + b[j];
        }
    }

    sort(all(ab));
    reverse(all(ab));

    vi ans(min(k, (int)ab.size()) * z);
    rep(i, min(k, (int)ab.size())) {
        rep(j, z) {
            ans[i * z + j] = ab[i] + c[j];
        }
    }

    sort(all(ans));
    reverse(all(ans));

    rep(i, k) {
        std::cout << ans[i] << std::endl;
    }

    return 0;
}


Measured memory_bytes: 31616
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) throws NumberFormatException, IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		char input[] = br.readLine().toCharArray();
		
		int n = input.length;
		int result[] = new int[n];
		
		//find RL
		for(int i = 0; i < n - 1; i++){
			if(input[i] == 'R' && input[i + 1] == 'L'){
				//leftside
				for(int j = i; j >= 0 && input[j] == 'R' ; j--){
					if((i - j) % 2 == 0){
						result[i]++;
					}
					else {
						result[i + 1]++;
					}
				}
				
				//rightside
				for(int j = i + 1; j < n && input[j] == 'L'; j++){
					if((j - i + 1) % 2 == 0){
						result[i + 1]++;
					}
					else {
						result[i] ++;
					}
				}
			}
		}
		//output
		StringBuffer sb = new StringBuffer();
		for(int i = 0; i < n; i++){
			if(i != 0){
				sb.append(" ");
			}
			sb.append(result[i]);
		}
		
		System.out.println(sb);
	}

}


Measured memory_bytes: 26280
#include<set>
#include<map>
#include<cmath>
#include<ctime>
#include<queue>
#include<cstdio>
#include<string>
#include<vector>
#include<cstdlib>
#include<cstring>
#include<iomanip>
#include<iostream>
#include<algorithm>
#define fi first
#define se second
#define pb push_back
#define lowbit(x) x&(-x)
#define PII  pair<int, int> 
#define all(x) x.begin(), x.end()
#define FAST ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
typedef long long ll;
const int inf = 0x3f3f3f3f;
const int mod = (int)1e9 + 7;
const int maxn = (int)1e6 + 5;
using namespace std;

bool check(int n){
	int cnt = 0;
	for(int i = 1; i <= n; i++){
		if(n % i == 0) cnt++;
	}
	if(cnt == 8) return true;
	else return false;
}

int main()
{
	int n; cin >> n;
	int ans = 0;
	for(int i = 1; i <= n; i++) if(check(i) && (i & 1)) ans++;
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
using namespace std;
#define ll long long
#define rep2(x,from,to) for(int x=(from);x<(to);++(x))
#define rep(x,to) rep2(x,0,to)
ll gcd(ll a, ll b) {
	if(a < b) swap(a, b);
	while(b) {
		ll m = a / b;
		swap(a-=m*b, b);
	}
	return a;
}
ll lcm(ll a, ll b) {
	ll g = gcd(a, b);
	return a / g * b ;
}
int main() {
	int a1, m1, a2, m2, a3, m3;
	while(cin >> a1 >> m1 >> a2 >> m2 >> a3 >> m3 && (a1 || m1 || a2 || m2 || a3 || m3)) {
		ll a = 0, b = 0, c = 0;
		int x = 1, y = 1, z = 1;
		ll i = 1;
		while(1) {
			if(a == 0) x = (a1 * x) % m1;
			if(a == 0 && x == 1) a = i;
			if(b == 0) y = (a2 * y) % m2;
			if(b == 0 && y == 1) b = i;
			if(c == 0) z = (a3 * z) % m3;
			if(c == 0 && z == 1) c = i;
			i++;
			if(a != 0 && b != 0 && c != 0) {
				cout << lcm(a, lcm(b, c)) << endl;
				break;
			}
		}
	}
	return 0;
}

Measured memory_bytes: 1156
#include <iostream>
#include <vector>
#include <string>

using namespace std;


int main()
{
  int a, b;
  cin >> a >> b;

  if (a >= 13)
	cout << b << endl;
  else if (a >= 6 && a <= 12)
	cout << b/2 << endl;
  else
	cout << 0 << endl;

	
  return 0;
}


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

using namespace std;

void hawawa()
{
  int n;
  cin >> n;
  vector<int> a(n);
  for (auto&& i : a) {
    cin >> i;
  }
  sort(rbegin(a), rend(a));
  auto ans1 = a[0];
  swap(a[0], a[n - 1]);
  auto ans2 = 0;
  for (int i = 0; i < n - 1; i++) {
    if (min(ans2, ans1 - ans2) < min(ans1 - a[i], a[i])) {
      ans2 = a[i];
    }
  }
  cout << ans1 << " " << ans2 << "\n";
}

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

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

int main() {
  int K, S;
  cin >> K >> S;
  int kind = 0;
  for (int a = 0; a <= K; a++) {
    for (int b = 0; b <= K; b++) {
      if (a+b <= S && a+b >= S-K) kind++;
    }
  }
  cout << kind << endl;
}


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

int main() {
    ll a, b, x;
    cin >> a >> b >> x;
    ll aa = a + (x - (a % x));
    ll bb = b + (x - (b % x));
    cout << (bb - aa) / x + (a % x == 0 ? 1 : 0) << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<vector>
#include<string>
#include<functional>
#include<queue>
#include <iomanip>
#include<map>
#include<limits>
#include<cmath>
#include<algorithm>
#include<bitset>
#include<utility>
#include<complex>
#include<cstdlib>
#include<set>
#include<cctype>

#define DBG cerr << '!' << endl;
#define REP(i,n) for(int (i) = (0);(i) < (n);++i)
#define rep(i,s,g) for(int (i) = (s);(i) < (g);++i)
#define rrep(i,s,g) for(int (i) = (s);i >= (g);--(i))
#define PB push_back
#define MP make_pair
#define FI first
#define SE second
#define SHOW1d(v,n) {for(int i = 0;i < (n);i++)cerr << v[i] << ' ';cerr << endl << endl;}
#define SHOW2d(v,i,j) {for(int aaa = 0;aaa < i;aaa++){for(int bbb = 0;bbb < j;bbb++)cerr << v[aaa][bbb] << ' ';cerr << endl;}cerr << endl;}
#define ALL(v) v.begin(),v.end()

using namespace std;

typedef long long ll;
typedef vector<int> iv;
typedef vector<iv> iiv;
typedef vector<string> sv;

int main()
{
	ll w,a,b;
	cin >> w >> a >> b;
	
	if(abs(a-b) <= w)
	{
		cout << 0 << endl;
	}
	else
	{
		cout << abs(a-b) - w << endl;
	}
	
	
	return 0;
}

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

const int MAXN = 3005;
vector< vector <vector<P>> > dp (MAXN, vector<vector<P>>(MAXN, vector<P>(2)) );
vector<int> a(MAXN);
bool visited[MAXN][MAXN][2];

P q(int i, int j, int k) { //k=1太郎, a_i...a_jでkが操作
    if (visited[i][j][k]) return dp[i][j][k];
    else if (i > j) return P (0,0);
    P front, back;
    if (k == 0) { //太郎
        front = q(i+1, j, k+1);
        front.first += a[i];
        back = q(i, j-1, k+1);
        back.first += a[j];
        if (front.first-front.second >= back.first-back.second) dp[i][j][k] = front;
        else dp[i][j][k] = back;
    }
    else if (k == 1) {                
        front = q(i+1, j, k-1);
        front.second += a[i];
        back = q(i, j-1, k-1);
        back.second += a[j];
        if (front.first-front.second <= back.first-back.second) dp[i][j][k] = front;
        else dp[i][j][k] = back;
    }
    visited[i][j][k] = true;
    return dp[i][j][k];
}

int main() {
    int N;
    cin >> N;
    rep(i,N) cin >> a[i];
    P result = q(0, N-1, 0);
    cout << (result.first-result.second) << endl;
    return 0;
}

Measured memory_bytes: 652928
{-# LANGUAGE BangPatterns #-}
import Control.Arrow
import Control.Monad.Fix
import Data.Char
import Data.Int
import Data.Foldable
import qualified Data.Vector as V
import qualified Data.Vector.Unboxed as VU
import qualified Data.ByteString.Char8 as B

solve :: Int -> Int -> Int
solve !a !b | a >= 13           = b
            | 6 <= a && a <= 12 = b `div` 2
            | otherwise         = 0

main = do
  let readInt :: Integral a => B.ByteString -> Maybe (a, B.ByteString)
      readInt = fmap (first fromIntegral . second B.tail) . B.readInt

  (a, b) <-
    (\vec -> (vec VU.! 0, vec VU.! 1)) . VU.unfoldrN 2 readInt <$> B.getLine
  print $ solve a b


Measured memory_bytes: 380