akhauriyash/Code-Regression huggingface dataset:
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
using namespace std;
#define boost ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define rando mt19937 rng(chrono::steady_clock::now().time_since_epoch().count())
#define fi first
#define se second
#define debug(x) cerr << " - " << #x << ": " << x << endl;
#define debugs(x, y) cerr << " - " << #x << ": " << x << " " << #y << ": " << y << endl;
#define debugii(x) cerr << " - " << #x << ": " << x.fi<<","<<x.se << endl;
#define sep() cerr << "--------------------" << endl;
#define all(x) (x).begin(),(x).end()
#define sz(x) (ll)x.size()
#define ld long double
#define ll long long
//#define int ll
#define ii pair<int,int>
#define v vector<int>
#define vii vector<ii>
#define vv vector<vector<int> >
#define mp make_pair
#define INF 1000000000
#define pb push_back
#define EPS 1e-9
const int MOD = 1000000007; // 998244353
string tab[1000005];
int l[1000005],r[1000005];
int32_t main(){
	boost;
	//freopen(".in","r",stdin);
	int n;
	cin>>n;
	set<ii> e;
	int c=0,c2=0;
	for (int i = 0; i < n; ++i)
	{
		string p;
		cin>>p;
		set<int> a,b;
		for (int j = 0; j < sz(p); ++j){
			if(p[j]==')')b.insert(j);
			else a.insert(j);
		}
		for (int j = 0; j < sz(p); ++j)
		{
			if(p[j]=='('){
				auto it=b.lower_bound(j);
				if(it==b.end())continue;
				b.erase(it);
				a.erase(j);
			}
		}
		for (int j = 0; j < sz(p); ++j)
		{
			if(p[j]=='('&&(a.find(j)!=a.end()))tab[i].pb('('),l[i]++;
			else if(p[j]==')'&&(b.find(j)!=b.end()))tab[i].pb(')'),r[i]++;
		}
		if(!r[i])
			c+=l[i];
		else if(!l[i]){
			c2+=r[i];
		}
		else e.insert({r[i]-l[i],i});
	}
	while(sz(e)){
		auto it=e.begin();
		if(r[(*it).se]>c){cout<<"No\n";return 0;}
		c-=(*it).fi;
		e.erase(it);
	}
	if(!(c-c2))cout<<"Yes\n";
	else cout<<"No\n";
	return 0;
}
//long long
//array bounds
//special cases
//binary search

Measured memory_bytes: 47336
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;

namespace atcoder
{
    public class Program
    {
        public static void Main(string[] args)
        {
            var buffer = Console.ReadLine().Split();
            var N = int.Parse(buffer[0]);
            var M = int.Parse(buffer[1]);

            UnionFind uf = new UnionFind(N);
            for (int i = 0; i < M; i++)
            {
                buffer = Console.ReadLine().Split();
                var A = int.Parse(buffer[0]);
                var B = int.Parse(buffer[1]);
                A -= 1; B -= 1;
                uf.Unite(A, B);
            }

            int ans = 0;
            for (int i = 0; i < N; i++)
                ans = Math.Max(ans, uf.Size(i));

            Console.WriteLine(ans);
        }
    }

    class UnionFind
    {
        IList<int> list;

        public UnionFind(int n)
        {
            list = Enumerable.Repeat(-1, n).ToList();
        }

        public int Root(int x)
        {
            if (this.list[x] < 0) return x;
            return this.list[x] = Root(this.list[x]);
        }

        public bool Unite(int x, int y)
        {
            x = Root(x);
            y = Root(y);
            if (x == y) return false;
            if (this.list[x] > this.list[y]) Swap(ref x, ref y);
            this.list[x] += this.list[y];
            this.list[y] = x;
            return true;
        }

        public void Swap(ref int x, ref int y)
        {
            var tmp = x;
            x = y;
            y = tmp;
        }

        public int Size(int x)
        {
            return -this.list[Root(x)];
        }
    }
}


Measured memory_bytes: 47596
#include <bits/stdc++.h>
#define repp(i,l,r)for(long long i=(l);i<(r);i++)
#define rep(i,n) for (long long i = 0; i < (n); ++i)
#define per(i,n) for (long long i = (n); i >= 0; --i)
const int INF = 2147483647;//int max
const long long int MOD = 1000000007;
using namespace std;
using ll = long long;
using P = pair<int,int>;
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; }

int n,k;
vector<int> w(1e5+1,0);

bool f(int p){
    int pos = 0;
    rep(i,k){//台数文のループ
        int weight_sum = 0;
        while(pos < n && weight_sum + w[pos] <= p){
            weight_sum += w[pos];
            pos++;
        }
    }
    return n == pos;
}

//ミョ(-ω- ?)
int main() {
    cin >> n >> k;
    rep(i,n)cin >> w[i];

    int ok = INF/2, ng = 0;
    while(abs(ok-ng) > 1){
        int mid = (ok + ng)/2;
        if(f(mid))ok = mid;
        else ng = mid;
    }
    cout << ok << endl;
    return 0;
}


Measured memory_bytes: 3096
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
const ll MOD=1000000007;
const ll MOD2=998244353;
const double PI=acos(-1);
const ll INF=1e18;
typedef pair<ll,ll> P;
typedef vector<ll> vl;
typedef vector<vl> vvl;
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define rep(i,n) FOR(i,0,n)
string abc="abcdefghijklmnopqrstuvwxyz";
string ABC="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
struct edge{ll to,cost;};

int main() {
  string s;
  cin >> s;
  ll k=s.size();
  rep(i,k){
    if(s[i]=='?'){
      s[i]='D';
    }
  }
  cout << s << endl;
}

Measured memory_bytes: 3760
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

using namespace std;
 
//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
 
//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}
 
//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
 
//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
 
//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define fore(i,a) for(auto &i:a)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
 
//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))
 
//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
 

LL gcd(LL a, LL b){
    if(b == 0) return a;
    return gcd(b,a%b);
}

LL lcm(LL a, LL b){
    LL g = gcd(a,b);
    return a/g *b;
}

int main(){
    LL N;
    cin >> N;
    LL count=0;
    bool exist=true;
    double u=sqrt(N);
    LL a[count];
    LL b[count];
    LL pos=0;
    LL num_A=0;
    LL num_B=0;
        for(LL i=1;i<=u;++i){
            if(N%i==0){
                num_A=i;
                num_B=N/i;
            }
    }
    
    cout << num_B+num_A-2;
}

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

using namespace std;
typedef         long long int   ll;

#define         input           freopen("input.txt","r",stdin)
#define         output          freopen("output.txt","w",stdout)
#define         si(a)           scanf("%d",&a)
#define         sii(a,b)        scanf("%d%d",&a,&b)
#define         siii(a,b,c)     scanf("%d%d%d",&a,&b,&c)
#define         pi(a)           printf("%d",a)
#define         spc             printf(" ")
#define         bl              printf("\n")
#define         here(a)         printf("#### %d ####",a)
#define         pii             pair<int,int>
#define         fr(i,n)         for(int i=0;i<n;i++)
#define         case(num)       printf("Case %d:",num)
#define         inf             1000000050
#define         MAX             100010*3
#define         MOD             1000000007


long long int sum, sqrtsum,tmp,sqr;


int main(){

    //input;
    //output;


    sum = 0; sqrtsum = 0;

    int n;

    cin>>n;

    for(int i=0;i<n;i++){
        cin>>tmp;
        sum = (sum+tmp)%MOD;            /// a+b....

        sqr = (tmp*tmp)%MOD;           /// square
        sqrtsum = (sqrtsum+sqr)%MOD;   ///square sum
    }

    tmp = sum%MOD;
    sum = (tmp*tmp)%MOD;


    tmp = (sum - sqrtsum);
    if(tmp<0) tmp += MOD;

    //int m = bigMod(2,MOD-2);
    //cout<<m<<endl;

    //tmp = (tmp*m)%MOD;

    tmp = (tmp * 500000004)%MOD;


    cout<<tmp<<endl;

    return 0;
}
/**
*/


Measured memory_bytes: 3480
#include <iostream>
#include<algorithm>
#include<sstream>
#include<cmath>
#include<vector>
#include<iomanip>
#include<map>
#include<set>
#include<queue>
#include<deque>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(i,n) for(int i = 0; i < n;i++)
#define mod 1000000007
#define c(n) cout << fixed <<setprecision(10) << n << endl
int main() {
	string s; int n; cin >> n; ll sum = 0;
	map<string, int> a;
	rep(i, n) {
		cin >> s; sort(s.begin(), s.end());
		a[s]++; sum += (a[s] - 1);
	}
	cout << sum << endl;
}

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

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

typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<long long> VL;
typedef vector<vector<long long>> VVL;
typedef vector<string> VS;
typedef pair<int, int> P;
typedef tuple<int,int,int> tpl;

#define ALL(a)  (a).begin(),(a).end()
#define SORT(c) sort((c).begin(),(c).end())
#define REVERSE(c) reverse((c).begin(),(c).end())
#define EXIST(m,v) (m).find((v)) != (m).end()
#define LB(a,x) lower_bound((a).begin(), (a).end(), x) - (a).begin()
#define UB(a,x) upper_bound((a).begin(), (a).end(), x) - (a).begin()

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define RFOR(i,a,b) for(int i=(a)-1;i>=(b);--i)
#define RREP(i,n) RFOR(i,n,0)

#define en "\n"

constexpr double EPS = 1e-9;
constexpr double PI  = 3.1415926535897932;
constexpr int INF = 2147483647;
constexpr long long LINF = 1LL<<60;
constexpr long long MOD = 1000000007; // 998244353;

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

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

void Main(){
    int n;
    cin >> n;
    VI ansv(100001, 0);
    FOR(x, 1, 101) {
        FOR(y, 1, 101) {
            FOR(z, 1, 101) {
                ansv[x*x + y*y + z*z + x*y+y*z+z*x] += 1;
            }
        }
    }
    REP(i, n) {
        cout << ansv[i+1] << en;
    }
    return;
}

int main(void){
    cin.tie(0);cout.tie(0);ios_base::sync_with_stdio(0);cout<<fixed<<setprecision(15);
    int t=1; //cin>>t;
    REP(_,t) Main();
    return 0;
}


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

using namespace std;

#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) (int)(x).size()
#define F first
#define S second
#define forn(i, n) for (int i = 0; i < (int)n; i++)
#define pb push_back
#define fastIO ios::sync_with_stdio(0), cin.tie(0)
#define endl '\n'
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
void debug_out() {
    cerr << endl;
}
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
    cerr << " " << to_string(H), debug_out(T...);
}

bool check(string s) {
    bool ok=true;
    forn(i,sz(s)/2) {
        if(s[i]!=s[sz(s)-i-1]) {
            ok=false;
            break;
        }
    }
    return ok;
}
int main() {
#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
    freopen("in.txt", "r", stdin);
    // freopen("out.txt", "w", stdout);
#else
#define debug(...) 3
    fastIO;
#endif
    string s1,s2,s3;
    cin>>s1;
    s2=s1.substr(0,sz(s1)/2);
    s3=s1.substr(sz(s1)/2+1,sz(s1)/2);
    bool ok1,ok2,ok3;
    ok1=check(s1);
    ok2=check(s2);
    ok3=check(s3);
    if(ok1&&ok2&&ok3)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    return 0;
}


Measured memory_bytes: 3652
#include <iostream>
#include <queue>
#include <climits>
using namespace std;

typedef long long ll;

ll solve(ll*, int);
int main(){
  int n; cin >> n;
  ll a[3*n+1];
  for(int i=1; i<=3*n; i++) cin >> a[i];

  ll ans = solve(a, n);

  cout << ans << endl;

  return 0;
}

ll solve(ll* nums, int n){
  priority_queue<int, vector<int>, greater<int> > a;  //前半の要素を小さいものからポップ
  priority_queue<int> b;  //後半の要素を大きいものからポップ
  ll asum[n+1], bsum[n+1];
  ll atemp=0, btemp=0;

  for(int i=1; i<=n; i++) {
    //aに関しては1~nの要素を入れておく
    a.push(nums[i]);
    atemp += nums[i];

    //bに関しては2*n+1~3*nの要素を入れておく
    b.push(nums[2*n+i]);
    btemp += nums[2*n+i];
  }

  asum[0] = atemp; bsum[n] = btemp;

  //とりあえずasumの様子を更新
  for(int k=1; k<=n; k++){
    a.push(nums[n+k]);
    atemp += nums[n+k];
    atemp -= a.top(); a.pop();
    asum[k] = atemp;

    b.push(nums[2*n+1-k]);
    btemp += nums[2*n+1-k];
    btemp -= b.top(); b.pop();
    bsum[n-k] = btemp;
  }

  //次にbsumの様子を更新
  ll ans = LLONG_MIN;
  for(int k=0; k<=n; k++){
    ans = max(ans, asum[k] - bsum[k]);
  }

  return ans;
}


Measured memory_bytes: 5108
N = input()
A = [int(t)-1 for t in raw_input().split()]
B = map(int, raw_input().split())
C = map(int, raw_input().split())

ans = 0
for i in range(N):
  ans += B[A[i]]
  if i>0 and A[i]==A[i-1]+1:
    ans += C[A[i-1]]
print ans


Measured memory_bytes: 2568
from functools import reduce
import operator

N = int(input())
Ss = list(map(int, input().split()))
Ts = list(map(int, input().split()))
Us = list(map(int, input().split()))
Vs = list(map(int, input().split()))
mat = [[0] * N for _ in range(N)]
counts_r = [[0] * 64 for _ in range(N)]
counts_c = [[0] * 64 for _ in range(N)]


class NotOK(Exception):
    pass


try:
    for i in range(N):
        for j in range(N):
            x = 0
            if not Ss[i]:
                x |= Us[i]
            if not Ts[j]:
                x |= Vs[j]
            if Ss[i] and (~Us[i] & x):
                raise NotOK
            if Ts[j] and (~Vs[j] & x):
                raise NotOK
            if Ss[i] and Ts[j]:
                x |= Us[i] & Vs[j]
            mat[i][j] = x
            for k in range(64):
                if (x >> k) & 1:
                    counts_r[i][k] += 1
                    counts_c[j][k] += 1

    def corr(x, vals, ors, counts):
        for k in range(64):
            if (x >> k) & 1 == 0:
                continue
            for j in range(N):
                if ors[j]:
                    continue
                if counts[j][k] >= N - 1:
                    continue
                counts[j][k] += 1
                vals[j] += 1 << k
                x -= 1 << k
                if not x:
                    return x
                break
        return x

    for i in range(N):
        vals = mat[i]
        if Ss[i]:
            x = reduce(operator.or_, vals)
            if corr(Us[i] & ~x, vals, Ts, counts_c):
                raise NotOK
        vals = []
        for j in range(N):
            vals.append(mat[j][i])
        if Ts[i]:
            x = reduce(operator.or_, vals)
            if corr(Vs[i] & ~x, vals, Ss, counts_r):
                raise NotOK
            for j in range(N):
                mat[j][i] = vals[j]
    for i in range(N):
        vals = mat[i]
        if Ss[i]:
            x = reduce(operator.or_, vals)
        else:
            x = reduce(operator.and_, vals)
        if x != Us[i]:
            raise NotOK
        vals = []
        for j in range(N):
            vals.append(mat[j][i])
        if Ts[i]:
            x = reduce(operator.or_, vals)
        else:
            x = reduce(operator.and_, vals)
        if x != Vs[i]:
            raise NotOK
    for i in range(N):
        print(*mat[i])
except NotOK:
    print(-1)


Measured memory_bytes: 96408
#include <algorithm>
#include <cstddef>
#include <cstdint>
#include <iomanip>
#include <iostream>
#include <map>
#include <string>
#include <vector>
#define rep(i, n) for (int i = 0; i < static_cast<int>(n); i++)

using namespace std;
using ll = int64_t;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(15);
  int n;
  cin >> n;
  string x, y;
  cin >> x >> y;
  for (int i = 0; i < n; i++) {
    cout << x[i] << y[i];
  }
  cout << endl;
}


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

int f[50][26];
int n;
string s;

int main() {
	// your code goes here
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cin >> n;
	for(int i = 0; i < n; i++) {
	    cin >> s;
	    for(int j = 0; j < s.length(); j++) {
	        f[i][s[j]-'a']++;
	    }
	}
	for(int j = 0; j < 26; j++) {
	    bool can = true;
	    int val = 51;
    	for(int i = 0; i < n; i++) {
    	    can &= (f[i][j] >= 1);
    	    val = min(val,f[i][j]);
    	}
    	if(can) for(int i = 0; i < val; i++) cout << ((char) (j + 'a'));
	}
	cout << endl;
	return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
/*第二引数で第一引数を割ったときの切り上げの計算*/
long long int maxtime(long long int x, long long int y) {
	return(x + y - 1) / y;

}
/*最大公約数*/
long long int lcm(long long int number1, long long int number2) {
	long long int m = number1;
	long long int n = number2;

	if (number2 > number1) {
		m = number2;
		n = number1;
	}
	long long int s = -1;
	while (s != 0) {
		s = m % n;
		m = n;
		n = s;
	}
	return m;
}
/*最大公倍数*/
long long int gcd(long long int number1, long long int number2) {
	long long int m = number1;
	long long int n = number2;
	return m / lcm(m, n) * n;
}
int main() {
	double a, b, x;
	cin >> a >> b >> x;
	double sum = x;
	double ans = 0;
	double s = 180;
	if (sum >= a * a * b / 2) {
		ans = 90-atan((a*a*a)/(2*(a*a*b-x))) / 3.141592653589793238 * s;
	}
	else {
		ans = atan(b * b * a / 2 / x) / 3.141592653589793238 * s;
	}
	cout << fixed <<setprecision(10)<< ans;
}

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

const int obracket	=-1;
const int sum		=0;
const int diff		=1;
const int multi		=2;
const int divide	=3;

stack<double> operands;
stack<int> operators;

int evaluate(string& expression);
int calc(int a,int b,int op);

int main()
{
	string str;
	int i,n;

	cin>>n;
	for(i=0;i<n;i++)
	{
		cin>>str;
		cout<<evaluate(str)<<endl;
	}
	return 0;
}

int evaluate(string& expression)
{
	int i,n,numstart;
	bool innum=false;
	int a,b;
	char temp;

	while(!operands.empty())operands.pop();
	while(!operators.empty())operators.pop();

	for(i=0;expression[i]!='=';i++)
	{
		temp=expression[i];
		if(isdigit(temp)||temp=='.')
		{
			if(!innum)
			{
				innum=true;
				numstart=i;
			}
		}
		else
		{
			if(innum)
			{
				innum=false;
				operands.push(atof(expression.substr(numstart,i-numstart).c_str()));
			}
			switch(temp)
			{
				case '(':
					operators.push(obracket);
					break;
				case ')':
					while(operators.top()!=obracket)
					{
						b=operands.top();
						operands.pop();
						a=operands.top();
						operands.pop();
						operands.push(calc(a,b,operators.top()));
						operators.pop();
					}
					operators.pop();
					break;
				case '+':
					while(!operators.empty() && operators.top()!=obracket)
					{
						b=operands.top();
						operands.pop();
						a=operands.top();
						operands.pop();
						operands.push(calc(a,b,operators.top()));
						operators.pop();
					}
					operators.push(sum);
					break;
				case '-':
					if(i==0||expression.at(i-1)=='(')
					{
						operands.push(0);
					}
					else
					{
						while(!operators.empty() && operators.top()!=obracket)
						{
							b=operands.top();
							operands.pop();
							a=operands.top();
							operands.pop();
							operands.push(calc(a,b,operators.top()));
							operators.pop();
						}
					}
					operators.push(diff);
					break;
				case '*':
					while(!operators.empty() && operators.top()>=multi)
					{
						b=operands.top();
						operands.pop();
						a=operands.top();
						operands.pop();
						operands.push(calc(a,b,operators.top()));
						operators.pop();
					}
					operators.push(multi);
					break;
				case '/':
					while(!operators.empty() && operators.top()>=multi)
					{
						b=operands.top();
						operands.pop();
						a=operands.top();
						operands.pop();
						operands.push(calc(a,b,operators.top()));
						operators.pop();
					}
					operators.push(divide);
					break;
			}
		}
	}
	if(innum)operands.push(atof(expression.substr(numstart,i-numstart).c_str()));
	while(!operators.empty())
	{
		b=operands.top();
		operands.pop();
		a=operands.top();
		operands.pop();
		operands.push(calc(a,b,operators.top()));
		operators.pop();
	}
	return operands.top();
}

int calc(int a,int b,int op)
{
	switch(op)
	{
		case sum:
			return a+b;
			break;
		case diff:
			return a-b;
			break;
		case multi:
			return a*b;
			break;
		case divide:
			return a/b;
			break;
		default:
			return 0;
			break;
	}
}

Measured memory_bytes: 0
import bisect
n=int(input())
al=list(map(int,input().split()))
bl=list(map(int,input().split()))
cl=list(map(int,input().split()))

al.sort()
bl.sort()
cl.sort()

ans=0
for b in bl:
    ac=bisect.bisect_right(al,b-1)
    cc=n-bisect.bisect_left(cl,b+1)
    ans+=ac*cc
print(ans)



Measured memory_bytes: 22720
import sys

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline

in_n = lambda: int(readline())
in_nn = lambda: map(int, readline().split())
in_nl = lambda: list(map(int, readline().split()))
in_na = lambda: map(int, read().split())
in_s = lambda: readline().rstrip().decode('utf-8')


def main():

    a = in_n()
    print(a + a**2 + a**3)


if __name__ == '__main__':
    main()


Measured memory_bytes: 9168
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        while (sc.hasNextInt()) {
            int N = sc.nextInt();
            int total = 0;
            int[] arr = new int[N];
            for (int i = 0; i < N; i++) {
                arr[i] = sc.nextInt();
            }
            Arrays.sort(arr);
            for (int i = 0; i < N; i++) {
                total += arr[i] * (N-i);
            }
            System.out.println(total);
        }
    }
}



Measured memory_bytes: 38780
#include <stdio.h>

int main(void) {

	int n;
	int i;
	int x = 0;

	scanf("%d", &n);

	for (i = 1; i <= n; i++) {

		x = i;

		if(x % 3 == 0)
			printf(" %d", i);
		else {
			while (x != 0) {
				if (x % 10 == 3) {
					printf(" %d", i);
					x = 0;
				}
				x /= 10;
			}
		}
	}

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

Measured memory_bytes: 600
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		StringBuilder sb = new StringBuilder();
		while (in.hasNext()) {
			double val = in.nextDouble();
			if (val < 0) {
				break;
			}
			String ans;
			if (val >= 256) {
				ans = "NA";
			} else {
				int seisu = (int) val;
				int syosu = (int) ((val - seisu) * 16);
				if ((val - seisu) * 16 - syosu != 0) {
					ans = "NA";
				} else {
					sb.replace(0, 13, "00000000.0000");
					String seisuB = Integer.toBinaryString(seisu);
					sb.replace(8 - seisuB.length(), 8, seisuB);
					String syosuB = Integer.toBinaryString(syosu);
					sb.replace(13 - syosuB.length(), 13, syosuB);
					ans = sb.toString();
				}
			}
			System.out.println(ans);
		}
	}
}

Measured memory_bytes: 27936
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

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

    static class TaskB
    {
        public void solve(int testNumber, Scanner in, PrintWriter out)
        {
            int T = 1;
            while (T-- > 0)
            {
                solveOne(in, out);
            }
        }

        private void solveOne(Scanner in, PrintWriter out)
        {
            long A = in.nextInt();
            long B = in.nextInt();
            long C = in.nextInt();
            long D = in.nextInt();

            long AC = A * C;
            long AD = A * D;
            long BC = B * C;
            long BD = B * D;

            out.println(Math.max(Math.max(Math.max(AC, AD), BC), BD));
        }

    }
}



Measured memory_bytes: 27136
#include<vector>
#include<iostream>
#include<bits/stdc++.h> 
using namespace std;
int main(){
    int n;
    string a;
    vector<string> v;
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>a;
        sort(a.begin(), a.end());
        v.push_back(a);
    }
    sort(v.begin(), v.end()); 
   
    long long total=0,can=0;
    int j=0;
    int k=0;
        for(auto x: v)
        {
           if(v[k]==x)
           {
               can=can+1;
           }
           else
           {
               total =total+can*(can-1)/2;
               k=j;
               can=1;
           }
            j+=1;
        }
        total =total+can*(can-1)/2;
        cout<<total;
}

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

#define int long long

#define rep(i, n) for (signed i = 0; i < signed(n); i++)
#define REP(i, s, n) for (signed i = signed(s); i < signed(n); i++)
#define rrep(i, n) for (signed i = signed(s) - 1; i >= 0; i--)

#define all(c) begin(c), end(c)
template<typename T>bool maxup(T& a, const T&& b) { if (a < b) { a = b; return true; }; }
template<typename T>bool maxup(T& a, const T& b) { if (a < b) { a = b; return true; }; }
template<typename T>bool minup(T& a, const T&& b) { if (a > b) { a = b; return true; }; }
template<typename T>bool minup(T& a, const T& b) { if (a > b) { a = b; return true; }; }

#define X first
#define Y second

using VV = vector<vector<int>>;
using V = vector<int>;
using P = pair<int, int>;
using IP = pair<int, P>;

template<typename T>
inline void input(vector<T>& v) { for (auto& x : v) cin >> x; }

void calc() {
	int n, m; cin >> n >> m;
	int mod = 1e9 + 7;
	int ans = 0;
	int a = 1;
	rep(i, n) a = (a * (i + 1)) % mod;
	int b = 1;
	rep(i, m) b = (b * (i + 1)) % mod;
	if (abs(n - m) >= 2) ans = 0;
	else if (n != m) ans = a * b % mod;
	else ans = (a *  b * 2) % mod;
	cout << ans << endl;
}

signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	calc();
#ifdef _MSC_VER
	system("pause");
#endif
}

Measured memory_bytes: 256
// #define _GLIBCXX_DEBUG // for STL debug (optional)
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
using namespace std;
using ll = long long int;
using int64 = long long int;
 
template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}
 
int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
const int INF = 1LL << 29;
const ll LONGINF = 1LL << 60;
const ll MOD = 1000000007LL;
 
int main() {
    int N; cin >> N;
    vector< pair<ll, ll> > segs;
    for(int i=0; i<N; i++) {
        ll l, r; scanf("%lld%lld", &l, &r);
        segs.emplace_back(l, r);
    }
    sort(segs.begin(), segs.end());

    vector<ll> max1(N), max2(N);
    vector<ll> min1(N), min2(N);
    max1[0] = segs[0].first, min1[0] = segs[0].second;
    max2[N-1] = segs[N-1].first, min2[N-1] = segs[N-1].second;
    for(int i=1; i<N; i++) {
        max1[i] = max(max1[i-1], segs[i].first);
        min1[i] = min(min1[i-1], segs[i].second);
    }
    for(int i=N-2; i>=0; i--) {
        max2[i] = max(max2[i+1], segs[i].first);
        min2[i] = min(min2[i+1], segs[i].second);
    }

    ll ans = 0;
    for(int i=0; i+1<N; i++) {
        ll l1 = max1[i], r1 = min1[i];
        ll l2 = max2[i+1], r2 = min2[i+1];
        // fprintf(stderr, "[%lld, %lld], [%lld, %lld]\n", l1, r1, l2, r2);
        ll sum = max(0LL, r1 - l1 + 1) + max(0LL, r2 - l2 + 1);
        chmax(ans, sum);
    }
    for(int i=0; i<N; i++) {
        ll l1, r1; tie(l1, r1) = segs[i];
        ll l2 = -LONGINF, r2 = LONGINF;
        if(i > 0) chmax(l2, max1[i-1]), chmin(r2, min1[i-1]);
        if(i + 1 < N) chmax(l2, max2[i+1]), chmin(r2, min2[i+1]);
        ll sum = max(0LL, r1 - l1 + 1) + max(0LL, r2 - l2 + 1);
        chmax(ans, sum);
    }
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 4976
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
using namespace std;
typedef long long ll;
const long long MOD = 1000000007;

int n;
ll a[310][310];

ll solve() {
    ll ans = 0;

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

    ans /= 2;

    for (int i = 0; i < n; i++) {
        for (int j = i + 1; j < n; j++) {
            for (int k = 0; k < n; k++) {
                if (k == i || k == j) {
                    continue;
                }
                if (a[i][j] > a[i][k] + a[k][j]) {
                    return -1;
                } else if (a[i][j] == a[i][k] + a[k][j]) {
                    ans -= a[i][j];
                    break;
                }
            }
        }
    }

    return ans;
}

int main() {
    cout << solve() << endl;
    return 0;
}

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

using namespace std;
typedef long long ll;

const ll mod=1000000007;
const int oo=1000000000;
int dx[8]={1,-1,0,0,1,-1,1,-1};
int dy[8]={0,0,1,-1,1,-1,-1,1};
const int N=100050;


int main(){
    int n;
    scanf("%d",&n);
    int a[n];
    bool ok=true;
    ll ans=0;
    for(int i=0;i<n;i++){
        scanf("%d",&a[i]);
        if(a[i]!=0)
            ans++;
    }
    if(a[0]!=0){
        puts("-1");
        return 0;
    }
    for(int i=0;i<n-1;i++){

        if(a[i]+1<a[i+1]){
            puts("-1");
            return 0;
        }
        if(a[i]>=a[i+1]&&a[i+1]>0)
            ans+=a[i+1]-1;

    }
    cout<<ans<<endl;

    return 0;
}


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

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)   FOR(i,0,n)
#define ALL(obj) (obj).begin(), (obj).end()

#define PI 3.14159265359

using namespace std;
typedef long long unsigned int ll;

int main() {
	int n;
	cin >> n;
	vector<int> x(n);
	REP(i, n) {
		int tmp;
		cin >> tmp;
		x[tmp - 1] = i + 1;
	}
	REP(i, n) {
		cout << x[i] << " ";
	}
}

Measured memory_bytes: 1152
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<unordered_set>
#include<unordered_map>
#include<bitset>
#include<iomanip>
#include<list>
#include<deque>
using namespace std;
//#define MODE 1
#ifdef MODE
#define DEB(X) cout<< #X <<": "<<X<<" ";
#define END cout<<endl;
#else
#define DEB(X) {}
#define END {}
#endif
typedef long long ll;
#define int ll
#define uset unordered_set
#define umap unordered_map
typedef std::pair<int,int> P;
struct edge{int to,cost;};
const int INF=100000000000000000;
const int INF2=9223372036854775807;
const int MOD=1000000007;
#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define min(X,Y) (((int)(X)<(int)(Y))?(X):(Y))
#define max(X,Y) (((int)(X)>(int)(Y))?(X):(Y))
#define MAX(X,Y) (*max_element(X,Y))
#define MIN(X,Y) (*min_element(X,Y))
#define NP(X,Y) next_permutation(X,Y)
#define setp(X,Y) cout<<fixed<<setprecision(Y)<<X;
int ceil2(int a,int b){if(a%b==0){return a/b;}else{return a/b+1;}}
int pow2(int a,int b){int r=1;for(int i=1;i<=b;i++){r*=a;}return r;}
int Log2(int a){int t=0;while(1){if(a==0||a==1){break;}a/=2;t++;}return t;}

string S;
int N;
int dp[100010][13];

signed main(){
	cin>>S;
	N=S.size();
	dp[0][0]=1;
	REP(i,N){
		int c;
		if(S[i]=='?'){
			c=-1;
		}
		else{
			c=S[i]-'0';
		}
		for(int j=0;j<=9;j++){
			if(c!=-1&&c!=j)continue;
			for(int k=0;k<13;k++){
				dp[i+1][(k*10+j)%13]+=dp[i][k];
			}
		}
		for(int j=0;j<13;j++){
			dp[i+1][j]%=MOD;
		}
	}
	int ans=dp[N][5];
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 10624
#include <bits/stdc++.h>
// #include "ane.cpp"

const int INF  = 1e9;
const long long INFLL = 1e18;
const int NMAX = 100005;
const int MMAX = 100005;
const int KMAX = 1005;
const int MOD  = 1e9 + 7;
using namespace std;

// comment to disable debug functions
#define DEBUG

// frequently used macros

#if __cplusplus >= 201103L
#define ALL(v) begin(v),end(v)
#define SORT(v) sort(begin(v), end(v))
#define FIND(v,x) find(begin(v), end(v), (x))
#else
#define ALL(v) (v).begin(),(v).end()
#define SORT(v) sort(v.begin(), v.end())
#define FIND(v,x) find(v.begin(), v.end(), (x))
#endif

#define fi first
#define se second

#define MEMNEXT(from, to) do{ memmove((to), (from), sizeof(from)); \
memset((from), 0, sizeof(from)); } while(0)
#ifdef DEBUG
#define DUMP(x) do{ std::cerr << (#x) << ": " << x << std::endl; }while(0)
#else
#define DUMP(x) do{}while(0)
#endif

// frequent used aliases
typedef long long ll;
typedef pair<int, int> p;
typedef pair<ll, int> lp;
typedef pair<ll, ll> llp;
typedef vector<int> vec;
typedef vector<ll> vecll;
typedef vector<vec> mat;
typedef vector<vecll> matll;

// frequently used constants
static const int di[] = {-1, 0, 1, -1, 1, -1, 0, 1};
static const int dj[] = {-1, -1, -1, 0, 0, 1, 1, 1};

// frequently used structs
struct edge{
  int to,cost;
};

// printf for debug
#ifndef DEBUG
void debug(const char* format, ...){}
#else
void debug(const char* format, ...){
  va_list arg;
  va_start(arg, format);
  vprintf(format, arg);
  va_end(arg);
}
#endif

// dump vector
#ifdef DEBUG
#define DUMPV(v, c) do{       \
  printf("%s: ", #v);         \
  for (int i = 0; i < (c); ++i) \
  {                           \
  cout << (v)[i] << " ";      \
  }                           \
  cout << endl;               \
} while(0)
#else
#define DUMPV(v,c)
#endif

// std::fill of multi dimensions
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
  std::fill( (T*)array, (T*)(array+N), val );
}

// binary search
ll BSearch(ll _begin, ll _end, bool (*f)(ll)){
  ll mid;
  while(_end - _begin > 1LL) {
  mid = _begin + (_end - _begin) / 2LL;
  if(f(mid)) {
    debug("BSearch: f(%d) == true\n", mid);
    _end = mid;
  }
  else
  {
    debug("BSearch: f(%d) == false\n", mid);
    _begin = mid;
  }
  }
  return _end;
}


ll N,M,K,A,B,C,D,E;
int dp[NMAX] = {};

string S;
vec v;

ll ans = {};

void solve(){
  // main algorithm
  if(K == 0){
    ans = N * N;
    return;
  }
  for (ll b = K + 1; b <= N; ++b)
  {
    ans += (N / b) * (b - K) + max(0LL, N - b * (N / b) + 1 - K);
  }
}
void debug(){
  // output debug information

}
void answer(){
  // output answer
  cout << ans << endl;
}
int main(int argc, char const *argv[])
{
  // operate inputs

  // Fill(dp, -1);
  cin >> N >> K;
  solve();
  #ifdef DEBUG
  debug();
  #endif
  answer();

  return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repr(i, n) for (int i = (n); i >= 0; --i)
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define FORR(i, m, n) for (int i = (m); i >= (n); --i)
#define ifaxb(a, x, b) if (a < x && x < b)  // 比較は昇順
#define toInt(x) (x - '0')
#define vi vector<int>
#define vii vector<vi>
#define vs vector<string>
#define vss vector<vs>
#define all(x) x.begin(), x.end()
#define ff first
#define ss second
#define pq priority_queue
#define ipair pair<int, int>
#define spair pair<string, string>
#define lpair pair<LL, LL>
#define MP make_pair
#define MM multimap
#define PB push_back
#define INF 2147483647
#define _INF -2147483647
#define pi 3.1415926536
#define MAXN 100004
using namespace std;
typedef long long ll;

int main() {
  int x, y;
  cin >> x >> y;
  cout << x + (y / 2) << endl;
  return 0;
}


Measured memory_bytes: 256
A, B, K = map(int, input().split())

def maxDivider(divider, divided):
    while(True):
        rest = divided % divider
        if rest == 0:
            return divider
        else:
            divided = divider
            divider = rest

def dividers(x):
    dividers = []
    divider = 1
    while(divider <= x / divider):
        if x % divider == 0:
            dividers.append(divider)
            if divider == int(x / divider):
                pass
            else:
                dividers.append(int(x / divider))
        else:
            pass
        divider += 1
    return sorted(dividers)

# set A <= B
if A > B:
    A, B = B, A
else:
    pass

ans = dividers(maxDivider(A, B))[-K]
print(ans)


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

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pi;

#define F first
#define S second
#define PB push_back
#define MK make_pair
#define REP(i, a, b) for (int i=a; i < b; i++)


bool sort_by(pi c, pi d){
	return c.S < d.S;
}

int main() {
	ll n, t;
	cin >> n >> t;
	ll prev = -1, now, ans = 0;
	REP(i, 0, n){
		cin >> now;
		if(prev == -1){
			ans = 0;
			prev = 0;
		}
		else{
			if(now-prev > t) ans+=t;
			else ans += now-prev;
		}
		prev = now;
	}
	cout << ans +t;
		
		
		

}


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

int x[500001];
int tmp[500001];
int cnt = 0;

void MergeSort(int left, int right){
  int mid, i, j, k;

  if(left >= right) return;

  mid = (left+right)/2;
  MergeSort(left, mid);
  MergeSort(mid+1, right);
  // x[left]~x[mid]???????\??????????
  for(i = left; i <= mid; i++) tmp[i] = x[i];
  // x[mid+1]~x[right]??????????????????
  for(i = mid+1, j = right; i <= right; i++, j--) tmp[i] = x[j];

  i = left;
  j = right;
  for(k = left; k <= right; k++){
    cnt++;
    if(tmp[i] <= tmp[j]){
      x[k] = tmp[i++];
    }else{
      x[k] = tmp[j--];
    }
  }
}

int main(){
  int n;
  cin >> n;
  for(int i = 0; i < n; i++) cin >> x[i];
  MergeSort(0, n-1);
  for(int i = 0; i < n; i++){
    cout << x[i] << (i != n-1 ? " " : "\n");
  }
  cout << cnt << endl;
  return 0;
}


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

using namespace std;
typedef long long ll;

#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep2(i, a, b) for (int i = (a); i < (b); ++i)
#define all(a) (a).begin(), (a).end()

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

    cout << ((n % 2 == 0) ? n : n * 2) << '\n';
    return (0);
}


Measured memory_bytes: 3596
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
using namespace std;
int main(){
  int n;cin>>n;
  vector<int> a;
  for(int i = 0; n > i; i++){
    int tmp;cin>>tmp;
    a.push_back(tmp);
  }
  sort(a.begin(),a.end());
  int o1 = a[a.size()-1];
  int o2 = -1;
  //5 2 3
  for(int i = 0; n > i; i++){
    if(o1%2==1){
      if(min(abs(a[i]-o1/2),abs(a[i]-(o1/2+1))) < min(abs(o2-o1/2),abs(o2-(o1/2+1)))){
        o2 = a[i];
      }
    }else{
      if(abs(a[i]-o1/2) < abs(o2-o1/2)){
        o2 = a[i];
      }
    }
  }
  cout << o1 << " " << o2 << endl;
}

Measured memory_bytes: 892
#include<bits/stdc++.h>
#define ll long long
#define rep(i,n) for(int i=0;i<n;i++)
#define rrep(i,n) for(int i=n;i>=0;i++)
using namespace std;
signed main(){
  ll n,a=0,b;
  cin>>n;
  for(int i=1;i<=n;i+=2){
    b = 0;
    for(int j=1;j<=i;j++){
      if(i%j==0){
        b++;
      }
    }
    if(b == 8){
      a++;
    }
  }
  cout<<a<<"\n";
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
main(){
  int W,a,b;
  cin>>W>>a>>b;
  const int distance=[W,a,b](){
    int distance;
    if(a+W<b)
      distance=b-(a+W);
    else if(b+W<a)
      distance=a-(b+W);
    else
      distance=0;
    return distance;
  }();
  cout<<distance<<endl;
}


Measured memory_bytes: 256
import numpy as np
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10**8)
INF = float('inf')
MOD = 10**9+7


def main():
  K, X = map(int, readline().split())
  left = max(-1000000, X-K+1)
  right = min(X+K-1, 1000000)
  
  print(' '.join(map(str, range(left, right+1))))
  
  
if __name__ == '__main__':
  main()

Measured memory_bytes: 12380
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        while (sc.hasNext()) {
            int m = sc.nextInt();
            int n = sc.nextInt();
            System.out.printf("%d %d\n", gcd(m, n), lcm(m, n));
        }

    }
    public static int gcd(int m, int n) {
        if (m % n == 0) {
            return n;
        } else {
            return gcd(n, m % n);
        }
    }

    public static int lcm(int m, int n) {
        return m / gcd(m, n) * n;
    }
}


Measured memory_bytes: 26296
#include <cstdio>

#include <algorithm>

using namespace std;

int n, ans;

void dfs(long long x, int s) {
  if (x > n)
    return;
  if (s == 7)
    ++ans;
  dfs(x * 10 + 3, s | 1);
  dfs(x * 10 + 5, s | 2);
  dfs(x * 10 + 7, s | 4);
}

int main() {
  scanf("%d", &n);
  dfs(0, 0);
  printf("%d\n", ans);
  return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
int main(){
  ll n, k, mod;
  cin >> n >> k;
  if(n > k){
  	mod = n % k;
    n = mod;
  }else if(n == k){
    mod = 0;
  }else{
   	mod = n;
  }  
//  cout << mod << endl;
  ll ans;
  if(mod > abs(n - k)) ans = abs(n - k);
  else ans = mod;

  cout << ans << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

/**
 * ABC051B_Sum_of_Three_Integers
 */
public class Main {
    private static Scanner sc;

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

        int K = sc.nextInt();
        int S = sc.nextInt();

        // 1つずつ組み合わせを探し、Sに一致する場合のみカウント
        int answer = 0;

        // 最終ループは答えが1つあるかないかで判定可能
        for (int i = 0; i <= K; i++) {
            for (int j = 0; j <= K; j++) {
                if (0 <= S - (i + j) && S - (i + j) <= K) {
                    // forループの0から、Kまでの2つの条件から設定。合致すれば1つカウント
                    answer++;
                }
            }
        }

        System.out.println(answer);

        sc.close();
    }
}

Measured memory_bytes: 22996
#include<bits/stdc++.h>
using namespace std;
int main() {
  int n,x,l,d=0,c=1,i;
  cin>>n>>x;
  for(i=0;i<n;i++){
    cin>>l;
    d+=l;
    if(d>x) break;
    c++;
  }
  cout<<c<<endl;
}

Measured memory_bytes: 256
#pragma GCC optimize("O3")
#include<bits/stdc++.h>
#define rc(x) return cout<<x<<endl,0
#define pb push_back
#define in insert
#define er erase
#define fr first
#define sc second
typedef long long ll;
const long long llnrm=LLONG_MAX;
const int nrm=INT_MAX;
const int nrn=INT_MIN;
const int nmax=1e5+5;
const int mod=1e9+7;
using namespace std;
int n,ans,i,j;
char x,y;
int main()
{
    ios_base::sync_with_stdio(false);cin.tie(0);cerr.tie(0);cout.tie(0);
    cin>>x>>y;
    if(x>y) cout<<'>'<<endl; else if(x<y )cout<<'<'<<endl; else cout<<'='<<endl;
    return 0;
}


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

#define ld long double
#define sf scanf
#define pf printf
#define pb push_back
#define PI ( acos(-1.0) )
#define IN freopen("input.txt","r",stdin)
#define OUT freopen("output.txt","w",stdout)
#define FOR(i,a,b) for(int i=a ; i<=b ; i++)
#define FORD(i,a,b) for(int i=a ; i>=b ; i--)
#define INF 1000000000
#define ll long long int
#define eps (1e-8)
#define sq(x) ( (x)*(x) )
#define all(x) x.begin(),x.end()
#define flog2(n) 64 - __builtin_clzll(n) - 1
#define popcnt(n) __builtin_popcountll(n)

using namespace std;

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

ll a[100005];

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(NULL);
    int n, m, v, p;
    cin >> n >> m >> v >> p;

    FOR (i, 1, n) {
        cin >> a[i];
    }

    sort(a + 1, a + n + 1);
    reverse(a + 1, a + n + 1);

    int res = p;
    v -= p;

    ll sum = a[p];

    FOR (i, p + 1, n) {
        ll u = a[i] + m;
        ll v1 = v - n + i;
        // cout << i << " " << v1 << endl;
        if (v1 <= 0 && u >= a[p]) {
            res++;
        }
        else if (u < a[p]) {

        }
        else {
            ll sum1 = u * 1ll * (i - p) - sum;
            ll sum2 = u * 1ll * (i - p - 1) - sum + a[i - 1];

            if (v1 > 1) sum1 = min(sum1, sum2 + sum2 / (v1 - 1));

            // cout << sum1 << endl;
            if (sum1 >= v1 * 1ll * m) {
                res++;
            }
        }
        sum += a[i];
    }

    cout << res << endl;

    return 0;
}

Measured memory_bytes: 1152
S = input()

evenChecker = 'Yes'
oddChecker = 'Yes'

for i, s in enumerate(S):
    if (i%2==0) and (s=='L') and (evenChecker=='Yes'):
        evenChecker = 'No'
    if (i%2==1) and (s=='R') and (oddChecker=='Yes'):
        oddChecker = 'No'
if (evenChecker=='Yes') and (oddChecker=='Yes'):
    print('Yes')
else: print('No')

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

int main(){
    string S;
    cin >> S;
    if(S == "MON"){
        cout << 6;
    }else if (S == "TUE")
    {
        cout << 5;
    }else if (S == "WED")
    {
        cout << 4;
    }else if (S == "THU")
    {
        cout << 3;
    }else if (S == "FRI")
    {
        cout << 2;
    }else if (S == "SAT")
    {
        cout << 1;
    }else if (S == "SUN")
    {
        cout << 7;
    }
    
}

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

int selectionSort(int a[], int n) {
    int swapNum = 0;
    int minj;
    for (int i = 0; i < n - 1; i++) {
        minj = i;
        for (int j = i; j < n; j++) {
            if (a[j] < a[minj]) {
                minj = j;
            }
        }
        swap(a[i], a[minj]);
        if (i != minj) {
            swapNum++;
        }
    }
    return swapNum;
}

int main() {
    int a[100], n;

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

    int swapNum = selectionSort(a, n);

    for (int i = 0; i < n; i++) {
        if (i > 0) {
            cout << " ";
        }
        cout << a[i];
    }
    cout << endl;
    cout << swapNum << endl;
}



Measured memory_bytes: 3108