akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<vector>
#include<algorithm>
#include<set>
#include<queue>
#include<stack>
#include<map>
#include<math.h>
#include<string>
#include <cctype>
#include <cstdlib>
#include<bitset>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define reps(i, s, n) for (int i = s; i < (int)(n); i++)
#define out(x) cout << x << endl;
#define INF 1ll<<60;
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; }

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

int main(){
    string s; cin >> s;
    bool a[120];
    rep(i, 120) a[i]=false;
    
    rep(i, s.size()){
        rep(j, s.size()){
            if(i==j) j++;
            if(s[i]==s[j]){
                out("no")
                return 0;
            }
        }
    }
    out("yes");
}

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

using namespace std;

#define int long long

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

typedef vector<int> VI;
typedef pair<int, int> PII;

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

int size, K;

int M;

int d[200000];

int calc(int u, int l){
    u = l - u;

    return d[l] - (u >= 0 ? d[u] : 0);
}

signed main(){

    cin >> size >> K;

    string S;
    cin >> S;

    int now_d = 0;

    int count = 0;
    bool isZero = true;

    REP(i, size){
        int y = S[i] - '0';

        if(y == 1){
            if(isZero){
                isZero = false;
                d[now_d] = count + 
                    (now_d > 0 ? d[now_d - 1] : 0);
                now_d++;
                count = 1;
            }
            else{
                count++;
            }
        }
        else{
            if(!isZero){
                isZero = true;
                d[now_d] = count +
                    (now_d > 0 ? d[now_d - 1] : 0);
                now_d++;
                count = 1;
            }
            else{
                count++;
            }
        }
    }
    d[now_d] = count +
        (now_d > 0 ? d[now_d - 1] : 0);
    now_d++;

    if(now_d % 2 == 1){
        d[now_d] = 0 +
            (now_d > 0 ? d[now_d - 1] : 0);
        now_d++;
    }

    int ans = 0;

    //cout << now_d << endl;

    //for(int i = 0; i < now_d; i++){
    //    cout << " " << d[i] << endl;
    //}

    for(int i = 1; i < now_d; i += 2){
        ans = max(calc((K * 2 + 1), i), ans);
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 1280
import sys
## io
IS = lambda: sys.stdin.readline().rstrip()
II = lambda: int(IS())
MII = lambda: list(map(int, IS().split()))
MIIZ = lambda: list(map(lambda x: x-1, MII()))
## dp
INIT_VAL = 0
DP2 = lambda d1, d2: [[INIT_VAL]*d2 for _ in range(d1)]
DP3 = lambda d1, d2, d3: [[[INIT_VAL]*d3 for _ in range(d2)] for _ in range(d1)]
## math
DIVC = lambda x, y: -(-x//y)
DIVF = lambda x, y: x//y

def main():
    a, b = IS().split()
    d = int(a+b)
    if d**(1/2) == int(d**(1/2)): print('Yes')
    else: print('No')

if __name__ == '__main__':
    main()


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

typedef long long ll;
ll gcd( ll a, ll b){
    if( a==0 ) return b;
    else if(b==0) return a;
    else if( a>b ) return gcd(a%b, b);
    else return gcd(a, b%a);
}
int main(){
    ll a,b,c,d;
    cin >> a  >> b >> c >> d;
    ll lcm=(c*d)/gcd(c, d);
    ll ent = (b/c)+(b/d)-(b/lcm);
    ll les = ((a-1)/c)+((a-1)/d)-((a-1)/lcm);

    //cerr << ent << ", " << les << endl;
    cout << (b-a+1) - (ent-les) << endl;
    return 0;
}



Measured memory_bytes: 256
import java.io._
import java.util.StringTokenizer
import scala.util.control.Breaks.{breakable,break}
import scala.collection.mutable.{Map, Stack, Queue, PriorityQueue, Set}

case class Pos(x: Long, y: Long, dir: String) {

  // calc (x, y)
  def calc(t: Double): (Double, Double) = {
    dir match {
      case "R" => (x+t, y)
      case "L" => (x-t, y)
      case "U" => (x, y+t)
      case "D" => (x, y-t)
    }
  }
}

object Main extends App {
  val in = new InputReader(System.in)
  val pw = new PrintWriter(System.out)

  val N = in.next().toInt
  val p = new Array[Pos](N+1)

  for (i <- 1 to N) {
    val x, y = in.next().toLong
    val d = in.next()

    p(i) = Pos(x, y, d)
  }


  //
  def check(n: Double): Double = {
    import Math.{max, min}

    var xmax = -2e8
    var ymax = -2e8
    var xmin = 2e8
    var ymin = 2e8

    for (i <- 1 to N) {
      val (x, y) = p(i).calc(n)

      xmax = max(xmax, x)
      ymax = max(ymax, y)
      xmin = min(xmin, x)
      ymin = min(ymin, y)
    }

    (xmax - xmin) * (ymax - ymin)
  }

  // 下に凸のグラフの最小値
  def ternarySearch(small: Double, big: Double): Double = {
    val END = 5e-3 // 5e-9
    def func(small: Double, big: Double): Double = {
      val vol = (big - small) / 3
      val midl = small + vol
      val midr = small + vol * 2
      if (big - small < END) big
      else {
        if (check(midl) >= check(midr))
          func(midl, big)
        else
          func(small, midr)
      }
    }
    func(small, big)
  }

  def timeProc(time: Double): Double = (time * 10).round / 10.0
  
  val time = ternarySearch(0, 1e8)
  val ans = check(timeProc(time))

  println(ans)
}

object Sub {
  def print2DimArray[A](mat: Array[Array[A]]): Unit = {
    mat.foreach(lin => println(lin.deep))
  }
}

class InputReader(stream: InputStream) {
  private[this] val reader = new BufferedReader(new InputStreamReader(stream))
  private[this] var tokenizer: StringTokenizer = new StringTokenizer(reader.readLine())
  def next(): String = {
    while (!tokenizer.hasMoreTokens()) {
      tokenizer = new StringTokenizer(reader.readLine())
    }
    tokenizer.nextToken()
  }
}


Measured memory_bytes: 119812
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
  ll n,ans;
  cin >> n;
  ll a[n];
  ll sum[n];
  cin >> a[0];
  sum[0] = a[0];
  for(int i = 1;i < n;i++){
    cin >> a[i];
    sum[i] = sum[i-1] + a[i];
  }
  for(int i = 0;i < n-1;i++){
    if(i == 0)ans = abs(sum[n-1]-2*sum[i]);
    else ans = min(ans,abs(sum[n-1]-2*sum[i]));
  }
  cout << ans << endl;
}
    
    
    
  


Measured memory_bytes: 3328
import java.util.Scanner;

public class Main{	
	public static void main(String[] arts){
		Scanner sc = new Scanner(System.in);
		int h,w;
		while(true){
			h=sc.nextInt();
			w=sc.nextInt();
			if(h==0&&w==0){
				break;
			}
			for(int i=0;i<h;i++){
				for(int j=0;j<w;j++){
					if(i%2==0){
						if(j%2==0)
							System.out.print("#");
						else
							System.out.print(".");
					}else{
						if(j%2==1)
							System.out.print("#");
						else
							System.out.print(".");
					}
				}
				System.out.print("\n");
			}
			System.out.print("\n");
		}
	sc.close();
}
}


Measured memory_bytes: 36332
#include <bits/stdc++.h>
#define fi first
#define se second
#define pii pair<int,int>
#define space putchar(' ')
#define enter putchar('\n')
#define mp make_pair
#define pb push_back
#define MAXN 200005
//#define ivorysi
using namespace std;
typedef long long int64;
template<class T>
void read(T &res) {
	res = 0;T f = 1;char c = getchar();
	while(c < '0' || c > '9') {
		if(c == '-') f = -1;
		c = getchar();
	}
	while(c >= '0' && c <= '9') {
		res = res * 10 + c - '0';
		c = getchar();
	}
	res *= f;
}
template<class T>
void out(T x) {
	if(x < 0){putchar('-');x = -x;}
	if(x >= 10) out(x / 10);
	putchar('0' + x % 10);
}

int N,K,cnt;
char s[25][(1 << 20) + 5];
vector<int> v[25];
int dp[42000005];
int p0[25],p1[25];
void Solve() {
	read(N);read(K);
	for(int i = 0 ; i <= N ; ++i) scanf("%s",s[i]);
	for(int i = 1 ; i <= N ; ++i) {
		v[i].resize((i + 1) * (1 << i));
		int s = v[i].size();
		for(int j = 0 ; j < s ; ++j) v[i][j] = ++cnt;
	}
	for(int i = 1 ; i <= N ; ++i) {
		for(int j = 0 ; j < (1 << i) ; ++j) {
			if(s[i][j] == '1') {
				dp[v[i][j * (i + 1) + i]]++;
			}
		}
	}
	for(int i = N ; i >= 1 ; --i) {
		for(int S = 0 ; S < (1 << i) ; ++S) {
			p0[0] = -1,p1[0] = -1;
			for(int j = 0 ; j <= i ; ++j) {
				p1[j + 1] = p1[j];p0[j + 1] = p0[j];
				if(S >> j & 1) p1[j + 1] = j;
				else p0[j + 1] = j;
			}
			for(int j = i ; j >= 0 ; --j) {
				int u = v[i][S * (i + 1) + j];
				int b = S & ((1 << j) - 1),f = S >> j;
				if(dp[u]) {
					if(p0[j] != -1) {
						int p = ((f << 1) << p0[j]) + (S & (1 << p0[j]) - 1);
						int l = p0[j] + 1 + i - j;
						dp[v[l][p * (l + 1) + p0[j]]] += dp[u];
					}
					if(p1[j] != -1) {
						int p = ((f << 1 | 1) << p1[j]) + (S & (1 << p1[j]) - 1);
						int l = p1[j] + 1 + i - j;
						dp[v[l][p * (l + 1) + p1[j]]] += dp[u];
					}
					if(j != 0 && j != i) {
						int l = i - j;
						dp[v[l][f * (l + 1)]] += dp[u];
					}
				}
			}
		}
	}
	for(int i = N ; i >= 1 ; --i) {
		for(int j = 0 ; j < (1 << i) ; ++j) {
			if(dp[v[i][j * (i + 1)]] >= K) {
				for(int k = i - 1; k >= 0 ; --k) {
					putchar('0' + ((j >> k) & 1));
				}
				enter;
				return;
			}
		}
	}
	puts("");
}
int main() {
#ifdef ivorysi
	freopen("f1.in","r",stdin);
#endif
	Solve();
}


Measured memory_bytes: 350592
from math import sqrt
N, D = map(int, input().split())
A = []
ans = 0
for i in range(N):
  A.append(list(map(int, input().split())))
for i in range(N-1):
  for j in range(i+1, N):
    d = 0
    for k in range(D):
      d += (A[i][k] - A[j][k]) ** 2
    if int(sqrt(d)) ** 2 == d:
      ans += 1
print(ans)

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

typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<double> vd;
typedef vector<ll> vl;
typedef vector<string> vs;
#define fo(i, a, b) for (int i = a; i < b; i++)
#define re(i, n) fo(i, 0, n)
#define pb push_back
#define all(s) s.begin(), s.end()
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { ll g = gcd(a, b); return a / g * b; }
int main()
{
  string s;
  cin >> s;

  if(s == "ABC") cout << "ARC" << endl;
  else cout << "ABC" << endl;

  return 0;
}


Measured memory_bytes: 3588
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#define ll long long
const int mod=1e9+7;
const int maxn=100100;
using namespace std;
int n,pl[maxn],a[maxn],p1,p2;
ll ans[maxn],jie[maxn];
ll ksm(ll a,int b)
{
	ll re=1;
	while(b)
	{
		if(b&1) re=re*a%mod;
		a=a*a%mod;
		b>>=1;
	}
	return re;
}
ll c(int n,int m)
{
	if(m>n) return 0;
	return (jie[n]*ksm(jie[m],mod-2)%mod*ksm(jie[n-m],mod-2)%mod);
}
int main()
{
	cin>>n;
	memset(pl,0,sizeof(pl));
	for(int i=1;i<=n+1;i++)
	{
		scanf("%d",&a[i]);
		if(pl[a[i]]) {p1=pl[a[i]]; p2=i;}	
		pl[a[i]]=i;
	}
	jie[0]=1;
	for(int i=1;i<=n+1;i++)
		jie[i]=jie[i-1]*i%mod;
	for(int i=1;i<=n+1;i++)
		ans[i]=(ans[i]+c(n+1,i))%mod;
	//for(int i=1;i<=n+1;i++)
	//	printf("%lld\n",ans[i]);	
	int o=p1+n-p2;
	//cout<<p1<<' '<<p2<<' '<<o<<endl;
	for(int i=0;i<=o;i++)
	{
		ans[i+1]=(ans[i+1]-c(o,i)+mod)%mod;
	}
	for(int i=1;i<=n+1;i++)
		printf("%lld\n",ans[i]);
	return 0;
} 

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

#define all(x) begin(x), end(x)
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) ((int)(x).size())
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define mp make_pair
#define input freopen("input.txt","r",stdin);
#define output freopen("output.txt","w",stdout);
#define fast_io ios::sync_with_stdio(NULL), cin.tie(NULL), cout.tie(NULL);
#define fix cout << fixed << setprecision(15);
//#define left left228
//#define right right228
//#define next next228
#define rank rank228
//#define prev prev228
#define y1 y1228
#define dout if(debug) cout
using namespace std;
using ll = long long;
using ull = unsigned long long;
using ld = long double;
using pii = pair<int, int> ;
using pll = pair<ll, ll>;
using pci = pair<char, int>;
using vi = vector<int> ;
using vll = vector<ll> ;
using vpii = vector<pii> ;
const ll infll = 1e18 + 3;
const int maxn = 1e6 + 77;
const int nmax = 1e6 + 577;
const ll basell = 1e18 + 3;
const int mod = 1e9 + 7;
const ld eps = 1e-7;
const int inf = 1009000999;
const int nv = 100505;
const int baseint = 1000200013;
const ld PI = acos(-1.0);
inline bool EQ(ld a, ld b) { return fabs(a-b) < 1e-9; }
inline bool IF(int a, int b, int c) { return (a >= b && a <= c); }
inline bool IFS(int a, int b, int c) { return (a > b && a < c); }
template<typename T> inline istream &operator>> (istream &_in, vector<T> &_v) { for (auto &_i : _v) { _in >> _i; } return _in; }
mt19937 rnd(chrono::high_resolution_clock::now().time_since_epoch().count());
//typedef pair<int, int> pt;
//#define x first
//#define y second
//ifstream cin("input.txt");
//ofstream cout("output.txt");
/*
sort(a, a + n, [&](pair<pt, int> a, pair<pt, int> b){if (a.x.x != b.x.x)
        return a.x.x < b.x.x; return a.x.y > b.x.y;});
for(int c : s)
for(int &i : a) cin >> i;
for(int c = 'a'; c <= 'z'; ++c)
vector<vector<ll>> dp(n, vector<ll>(n+2));
__int128;
char 0 = int 48;
char c = cin;
int h = (int)c - 48;
*/

/*char memory[(int)1e8];

char memorypos;

inline void * operator new(size_t n){
    char * ret = memory + memorypos;
    memorypos += n;
    return (void *)ret;
}

inline void operator delete(void *){}
*/

int inline solve() {
    //input;//,output;
    //fix;
    fast_io;
    ll k, a, b;
    cin >> k >> a >> b;
    if(a >= b || a + 1 > k || a == b - 1) return cout << k + 1, 0;
    ll ans = a;
    k = k - (a - 1);
    if(k % 2 == 0) {
        if(k > 2){
            cout << (b - a) * ((k/2) - 1) + b;
        } else cout << b;
    } else {
        if(k > 2){
            cout << (b - a) * ((k/2) - 1) + b + 1;
        } else cout << b + 1;
    }
    return 0;
}

int32_t main() {
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    solve();
    return 0;
}
/*
 * */

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<cmath>


using namespace std;

#define rep(i,N) for(int i=0;i<N;i++) //0から
#define REP(i,N) for(int j=i;j<N;j++) //iから

typedef long long ll;




ll binary_search(vector<ll> a, ll n, ll key){
    ll right = n, left = -1;
    ll md = (right + left) / 2;

    while(right - left > 1){
        if(a[md] <= key){
            right = md;
        }else{
            left = md;
        }
        md = (right + left) / 2;
    }
    if(left == -1) return -1; //無い場合
    return right;
}

vector<ll> prime;
void Prime(ll n){ //線形篩,素数列挙
    vector<ll> p(n,0);
    p[0]=1;
    p[1]=1;
    for(ll i=2;i<n;i++){
        if(p[i]==0){
            prime.push_back(i);
            p[i]=i;
        }
        ll k=prime.size();
        for(ll j=0;j<k && i*prime[j]<n && prime[j]<=p[i];j++){
            p[i*prime[j]]=prime[j];
        }
    }
}

#define MOD ((ll)1e+9 + 7)




//cout<<fixed<<setprecision(10);
int main(){
    int n,k;
    cin>>n>>k;
    int b=0;
    vector<int> cnt;
    for(int i=1;i<=n;i++){
        int tmp=i;
        int cnt2=0;
        while(tmp<k){
            tmp*=2;
            cnt2++;
        }
        cnt.push_back(cnt2);
    }
    sort(cnt.begin(),cnt.end(),greater<int>());

    rep(i,n){
        b+=pow(2,cnt[0]-cnt[i]);
    }

    double ans = (double)b/(double)(n*pow(2,cnt[0]));

    cout<<fixed<<setprecision(10);
    cout<<ans<<endl;
    

    return 0;
}



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

int main() {
  int a, b, c, d, t;
  cin >> a >> b >> c >> d;
  t = (a + b) - (c + d);
  if (t > 0) {
    cout << "Left";
  } else if (t ==0) {
    cout << "Balanced";
  } else {
    cout << "Right";
  }
  cout << endl;
  return 0;
}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline


def readstr():
    return input().strip()


def readint():
    return int(input())


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


def readstrs():
    return input().split()


def main():
    N = readint()
    A = list(readnums())
    m = A[0]
    ans = 0
    for i in range(1, N):
        if m < A[i]:
            m = A[i]
        else:
            ans += m - A[i]

    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 31568
//hinagata.cpp
//作成日
//更新日
//目的
//手段
/*includes*/
#include <bits/stdc++.h>
/*namespace*/
using namespace std;
using ll= long long;
/*define macro*/
#define REP(i,n) for(ll i=0;i<(n);i++)
#define REPi(i,a,b) for(ll i=(a);i<(b);i++)
#define REPRi(i,a,b) for(ll i=(a);i>(b);i--)
#define ALL(x) (x).begin(),(x).end()

bool comp(pair<int,int> A,pair<int,int> B){
    if(A.second!=B.second){
        return A.second<B.second;
    }else{
        return A.first<B.first;
    }
}

int main(){
    ll N,M;
    cin>>N>>M;
    vector<pair<ll,ll>> W(M);
    REP(i,M){
        cin>>W[i].first>>W[i].second;
    }
    //inputend
    sort(ALL(W),comp);
    //sort
    ll time=W[0].second;
    int count=1;
    REPi(i,1,M){
        if(W[i].first>=time){
            count+=1;
            time=W[i].second;
        }
    }
    cout<<count<<endl;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); ++i)
#define rep2(i,n) for(int i=1; i<=(n); ++i)
#define all(x) (x).begin(),(x).end()
#define Sort(x) sort((x).begin(),(x).end())
#define Sort2(x) sort((x).begin(),(x).end(), greater<int>())
#define pb push_back
using namespace std;
using ll = long long;
using P = pair<int,int>;
using Graph = vector<vector<int>>;

int main()
{
    int n,k; cin >> n >> k;
    vector<int> p(n); rep(i, n) cin >> p[i];
    double ans = 0;
    ll mx_sum = 0;
    ll sum = 0;

    rep(i,k){
        sum += p[i]+1;
    }
    mx_sum = max(sum, mx_sum);

    for(int i=1; i<n-k+1; i++){
        sum = sum+p[i-1+k]-p[i-1];
        mx_sum = max(sum, mx_sum);
    }

    cout << fixed << setprecision(10);
    cout << (double)mx_sum / 2 << endl;

    
}

/*
Ctrl+@ でコンソールを開け、以下で実行。
g++ d.cpp
./a.out

サンプルのダウンロードは oj d URL
テストは oj t
*/

Measured memory_bytes: 1152
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <tuple>
#include <vector>

using namespace std;
typedef long long ll;

#define rep(i, n) for (ll i = 0; i < (n); i++)
#define reps(i, f, n) for (ll i = (f); i < (n); i++)
#define repr(i, n) for (ll i = n; i >= 0; i--)
#define repv(v) for (auto it = (v).begin(); it != (v).end(); it++)
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())
#define pb push_back
#define INIT    \
    cin.tie(0); \
    ios::sync_with_stdio(false);

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

ll const INF = 1LL << 60;
ll const MOD = 1000000007;

int main() {
    INIT;
    ll N, X;
    cin >> N >> X;

    ll npow;
    vector<ll> cnt(5, 0);

    ll ans = 0;

    for (ll i = N; i >= 0; i--) {
        // cout << "---" << i << "---" << endl;
        if (X == 0) break;

        if (i == 0) {
            ans += 1;
            break;
        } else if (i == 1) {
            if (X == 2) {
                ans += 1;
            } else if (X == 3) {
                ans += 2;
            } else if (X == 4 || X == 5) {
                ans += 3;
            }
            break;
        }

        npow = 2 * pow(2LL, i - 1);
        cnt[0] = 1;
        cnt[1] = 2 * npow - 2;
        cnt[2] = 2 * npow - 1;
        cnt[3] = 4 * npow - 4;
        cnt[4] = 4 * npow - 3;

        // repv(cnt) cout << *it << " ";
        // cout << endl;

        auto it = upper_bound(ALL(cnt), X);
        ll idx = it - cnt.begin() - 1;
        // cout << X << "-> " << cnt[idx] << ", ";

        if (idx == 1) {
            ans += pow(2LL, i) - 1;
            // cout << "ans += " << pow(2LL, i) - 1 << endl;
        } else if (idx == 2) {
            ans += pow(2LL, i);
            // cout << "ans += " << pow(2LL, i) << endl;
        } else if (idx == 3 || idx == 4) {
            ans += 2 * pow(2LL, i) - 1;
            // cout << "ans += " << 2 * pow(2LL, i) - 1 << endl;
        }

        X -= cnt[idx];
        // cout << X << endl;
        // cout << "ans : " << ans << endl;
    }

    cout << ans << endl;

    return 0;
}

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

int main() {
	int a, b, c, x, y;

	scanf("%d %d %d %d %d", &a, &b, &c, &x, &y);

	a = std::min(a, c * 2);
	b = std::min(b, c * 2);

	if (a + b > c * 2) {
		if (x > y)
			printf("%d", y * 2 * c + (x - y) * a);
		else
			printf("%d", x * 2 * c + (y - x) * b);
	}
	else {
		printf("%d", x * a + y * b);
	}

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define show(x) for(auto i: x){cout << i << " ";}
typedef long long ll;

/* 数列aの任意の二つの和に対して、xより大きい物の数を返す*/
ll query(ll x, vector<ll> &a){
    ll cnt = 0;
    rep(i, a.size()){
        cnt += a.end() - lower_bound(a.begin(), a.end(), x - a[i]);
    }
    return cnt;
}

ll sumans(ll x, ll m, vector<ll> &a){
    vector<ll> sum;
    ll s = 0;
    rep(i, a.size()){ sum.push_back(s); s += a[i]; }
    sum.push_back(s);

    ll ans = 0;
    ll shake_cnt = 0;
    rep(i, a.size()){
        ll itr = lower_bound(a.begin(), a.end(), x - a[i]) - a.begin();
        ans += sum[a.size()] - sum[itr] + (a[i] * (a.size() - itr));
        shake_cnt += a.size() - itr;
    }
    if (shake_cnt > m) ans -= x*(shake_cnt - m);
    return ans;
}

int main()
{
    ll n, m;
    cin >> n >> m;
    vector<ll> a;
    rep(i, n){ ll tmp; cin >> tmp; a.push_back(tmp);}
    sort(a.begin(), a.end());
    //show(a);
    //cout << endl;
    //rep(i, 10) cout << i*10 << " " << query(i*10, a) << endl;

    ll left = -1;
    ll right = 200001;
    //入力mに対して、選ばれる数の下限を導出する
    //閾値を大きくすればmは減る
    while (abs(right - left) > 1){
        ll mid = (left + right) / 2;
        if (m <= query(mid, a)){
            left = mid;
        } else {
            right = mid;
        }
    }
    //left以上の和がmパターン持つ事を補償している。
    //right以上の和がmパータン持たない事を補償している。
    //std::cout << "left:"<<left << endl;
    //std::cout << right << endl;

    std::cout << sumans(left, m, a) << endl;
}



Measured memory_bytes: 2676
#include <bits/stdc++.h>
#define FOR(i, a, b) for (int i = (a); i <= (b); i++)
#define RFOR(i, a, b) for (int i = (a); i >= (b); i--)
#define LFOR(i, a, b) for (long long int i = (a); i <= (b); i++)
#define LRFOR(i, a, b) for (long long int i = (a); i >= (b); i--)
#define MOD 1000000007
#define INF 1000000000           // 2000000000
#define LINF 1000000000000000000 // 9000000000000000000
#define DINF 1000000000000000.0
#define PI 3.14159265358979

//.size()はunsigned int　0-1をするとオーバーフローする

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

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

int main(void) {
    int n,d;
    int count=0;

    cin>>n>>d;

    vector<vector<int> > x(n,vector<int>(d));

    FOR(i,0,n-1){
        FOR(j,0,d-1){
            cin>>x[i][j];
        }
    }

    FOR(i,0,n-2){
       double p;
        FOR(j,i+1,n-1){
       int total=0; 
            FOR(k,0,d-1){
                total+=(x[i][k]-x[j][k])*(x[i][k]-x[j][k]);
            }
            p=sqrt((double)total);
            if(ceil(p)==floor(p)){
                count++;
            }
        }
    }

    cout<<count<<endl;
}


Measured memory_bytes: 256
"""
NTC here
"""
import sys
inp = sys.stdin.readline


def input(): return inp().strip()


flush = sys.stdout.flush
# import threading
# sys.setrecursionlimit(10**6)
# threading.stack_size(2**25)


def iin(): return int(input())


def lin(): return list(map(int, input().split()))

# range = xrange
# input = raw_input


def main():
    def cnt_ones(n):
        ch = 0
        x = n
        ans = []
        while x:
            if x&1:
                ans.append(ch)
            x>>=1
            ch+=1
        return ans
    ans = []
    h, w, K = lin()
    a = [list(map(int, list(input()))) for _ in range(h)]
    h1 = 2**(h-1)
    for i in range(h1):
        ch = cnt_ones(i)+[h-1]
        l1 = len(ch)
        a1 = [0]*(l1)
        ch2 = 0
        for j in range(w):
            ch1 = 0
            a2 = [0]*(l1)
            for k in range(h):
                a2[ch1]+=a[k][j]
                if ch[ch1]==k:
                    ch1+=1
            for k in range(l1):
                if a1[k]+a2[k]>K:
                    ch2 += 1
                    a1 = a2[:]
                    break
            else:
                for k in range(l1):
                    a1[k]+=a2[k]
            #check
            for i in a1:
                if i>K:
                    ch2 = w*10
                    break
            else:
                continue
            break
        ans.append(l1-1+ch2)
    # print(ans)
    print(min(ans))

"""
TEST-
4 4 1
1111
1111
1111
1111
"""


main()
# threading.Thread(target=main).start()


Measured memory_bytes: 47708
use std::io::*;
use std::str::FromStr;

fn main(){
    let n = read();
    let x:u32 = read();
    let mut m: Vec<u32> = (0..n).map(|_| read::<u32>()).collect();
    
    let min = m.iter().cloned().min().unwrap();
    let sum: u32 = m.iter().sum();
    let remain = x - sum;
    let ans = (remain / min) + n;
    
    println!("{}", ans);
} 

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char) 
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

Measured memory_bytes: 4352
import java.util.Scanner;

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

		int w = sc.nextInt();
		int n = sc.nextInt();

		int[] values = new int[w];

		for (int i = 0; i < values.length; i++) {

			values[i] = i + 1;

		}

		for (int i = 0; i < n; i++) {
			String str = sc.next();
			String[] ab = str.split(",");
			int a = Integer.parseInt(ab[0]) - 1;
			int b = Integer.parseInt(ab[1]) - 1;

			int temp;

			temp = values[a];
			values[a] = values[b];
			values[b] = temp;

		}

		for (int i = 0; i < values.length; i++) {

			System.out.println(values[i]);

		}

	}

}

Measured memory_bytes: 26092
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, j) for(int i = 0; i < (int)(j); i++)
constexpr int INF = 1 << 28;
struct Edge {
    int to;
    ll capacity, cost, rev;
};
constexpr ll INFL = 1LL << 60;
struct Flow {
    int N;
    vector<vector<Edge>> E;
    Flow(int n) : N(n) {
        E.resize(N);
    }
    void add_arc(int from, int to, ll cap, ll cost = 0) {
        E[from].push_back(Edge{to, cap, cost, (ll)E[to].size()}); // E[to].size() ????????§??????????????????
        E[to].push_back(Edge{from, 0, -cost, (ll)E[from].size() - 1}); // ??????
    }
    // s -> t ??? f ??????????????????????°??????¨????¨?????????????????????? - 1
    // O(F|V||E|)
    // ????????¨??°??????????£???????
    ll min_cost_flow(int s, int t, ll f) {
        vector<int> prev_v(N), prev_e(N);
        
        auto bellmanford = [&] (int s) {
            vector<ll> dist(N, INFL);
            dist[s] = 0;
            bool updated = true;
            while(updated) {
                updated = false;
                rep(v, N) {
                    if(dist[v] >= INFL) continue;
                    rep(i, E[v].size()) {
                        auto &e = E[v][i];
                        if(e.capacity > 0 and dist[e.to] > dist[v] + e.cost) {
                            dist[e.to] = dist[v] + e.cost;
                            prev_v[e.to] = v;
                            prev_e[e.to] = i;
                            updated = true;
                        }
                    }
                }
            }            
            return dist;
        };
        
        ll res = 0;
        while(f > 0) {
            auto dist = bellmanford(s);
            if(dist[t] == INFL) return -1;
            ll d = f;
            // s -> t ???????°?????????????????????????????°??????? d ????±???????
            for(int v = t; v != s; v = prev_v[v]) {
                d = min(d, E[prev_v[v]][prev_e[v]].capacity);
            }
            // d ????????????            
            for(int v = t; v != s; v = prev_v[v]) {
                auto &e = E[prev_v[v]][prev_e[v]];
                e.capacity -= d;
                E[v][e.rev].capacity += d;
            }
            f -= d;
            res += d * dist[t]; // ??????????????¨
        }
        return res;
    }
};
int main() {
    int V, E, F; cin >> V >> E >> F;
    Flow f(V);
    rep(i, E) {
        int u, v, c, d; cin >> u >> v >> c >> d;
        f.add_arc(u, v, c, d);                
    }
    cout << f.min_cost_flow(0, V - 1, F) << endl;
    return 0;
}

Measured memory_bytes: 3248
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <utility>
#include <iomanip>
using namespace std;
#define REP(i,n) for (int i=0;i<(n);++i)
#define rep(i,a,b) for(int i=a;i<(b);++i)
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;}
using ll = long long;
constexpr ll INF = 1LL << 60;
constexpr ll MOD = 1e9 + 7;
 
long a[101010];
int main()
{
  ios::sync_with_stdio(false);
  long n; cin >> n;
  REP(i,n) cin >> a[i];

  bool ok = true;
  for(int i = n-2; i >= 0; --i) {
      if(a[i] == a[i+1] + 1) --a[i];
      else if(a[i] > a[i+1] + 1) ok = false;
  }
  cout << (ok ? "Yes" : "No") << endl;
  return 0;
}

Measured memory_bytes: 1024
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define dump(x) cout << x << endl
typedef int64_t Int;

using namespace std;
using Graph = vector<vector<Int>>;

const double pi = M_PI;
const Int MOD = 1000000007;

int main() {
    int n;
    cin >> n;
    vector<int> a(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }
    vector<int> tem(a);
    sort(tem.begin(), tem.end(), greater<int>());

    for (int i = 0; i < n; i++) {
        if (a[i] == tem[0]) {
            cout << tem[1] << endl;
        } else {
            cout << tem[0] << endl;
        }
    }

    return 0;
}


Measured memory_bytes: 3200
#pragma GCC optimize ("Ofast")
#include <bits/stdc++.h>
#define FOR(i, a, b) for (int i=(a); i<(int)(b); i++)
#define FORD(i, a, b) for (int i=a; i>(int)(b); i--)
#define PPC(x) __builtin_popcount(x)
#define pb push_back
#define ALL(x) (x).begin(), (x).end()
#define ft first
#define sd second
#ifdef DEBUG
#include "debug.h"
#else
#define dbg(...)
#endif
using namespace std;
 
const int maxN = 1 << 19;

int T[maxN];
int n, m, v, p;

priority_queue <int> H;

bool check(int i)
{
	long long x = 1ll * m * v;
	int j, y = T[i] + m;
	
	if (i <= p)
		return true;
	if (y < T[p])
		return false;
		
	for (j=n; T[j] <= T[i]; j--)	
		x -= m;
		
	for (j=1; T[j] > y; j++)
		x -= m;
		
	int r = j;
	while (T[j] > T[i])
	{
		int d = y-T[j++];
		x -= d;
		H.push(m-d);
	}
	
	while (!H.empty() and x > 0ll)
	{
		x -= H.top();
		H.pop();
		r++;
	}
	
	while (!H.empty())
		H.pop();
	assert(x <= 0);
		
	return r <= p;
}
 
int main()
{
	scanf ("%d%d%d%d", &n, &m, &v, &p);
	FOR(i, 1,n+1)
		scanf ("%d", T+i);
	sort(T+1, T+n+1);
	reverse(T+1, T+n+1);
	T[n+1] = -1;
	
	int a = 1, b = n+1;
	while (b-a > 1)
	{
		int c = (a + b) / 2;
		check(c) ? a = c : b = c;
	}
	
	printf("%d\n", a);	
	return 0;
}


Measured memory_bytes: 1276
#include<cstdio>
#include<vector>
#include<cstring>
#include<cmath>
#include<iostream>
#include<algorithm>
using namespace std;
const int MAXN=100000;
vector<int> d[MAXN+5];
int n;
int dfs(int u,int fa)
{
	int res=0,v;
	for(int i=0;i<d[u].size();i++)
	{
		v=d[u][i];
		if(v!=fa)
			res+=dfs(v,u);
	}
	if(res>=2)
	{
		printf("First");
		exit(0);
	}
	else if(res==0)
		return 1;
	return 0;
}
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n-1;i++)
	{
		int u,v;
		scanf("%d%d",&u,&v);
		d[u].push_back(v);
		d[v].push_back(u);
	}
	if(dfs(1,0))
		printf("First");
	else
		printf("Second");
	return 0;
}


Measured memory_bytes: 5888
from sys import stdin
import sys

A, B, C, D = [int(x) for x in stdin.readline().rstrip().split()]
# N, M = [int(x) for x in stdin.readline().rstrip().split()]
# U = input().split()
# A, B = [str(x) for x in stdin.readline().rstrip().split()]
while True:
    C = C-B
    if C <= 0:
        print("Yes")
        sys.exit()
    A = A-D
    if A <= 0:
        print("No")
        sys.exit()


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

int N, M, ans, cnt, a, b;

vector<vector<int>> G;
vector<bool> visited;

void dfs(int now)
{
    visited[now] = true, cnt++;
    ans += cnt == N;
    for (int i = 0; i < G[now].size(); i++)
    {
        int next = G[now][i];
        if (visited[next] == false)
            dfs(next);
    }
    visited[now] = false, cnt--;
}

int main()
{
    cin >> N >> M;
    G = vector<vector<int>>(N);
    visited = vector<bool>(N, false);
    for (int i = 0; i < M; i++)
    {
        cin >> a >> b;
        a--, b--;
        G[a].push_back(b);
        G[b].push_back(a);
    }
    dfs(0);
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <stdio.h>

#define MAX_PLACE_NUM 3
#define PUT_ON 1


int main(void)
{
    char plc[MAX_PLACE_NUM];
    int placed_cnt;
    int i;

    //Initialize
    placed_cnt = 0;
    //Input
    scanf("%s", plc);

    for(i=0; i<MAX_PLACE_NUM; i++){
        if(plc[i]=='1'){
            placed_cnt++;
        }
    }
    printf("%d\n", placed_cnt);
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
 
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)
 
using namespace std;
 
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vpi;
typedef vector<vi> vvi;
typedef long long i64;
typedef vector<i64> vi64;
typedef vector<vi64> vvi64;
typedef pair<i64, i64> pi64;
typedef double ld;
 
template<class T> bool uin(T &a, T b) { return a > b ? (a = b, true) : false; }
template<class T> bool uax(T &a, T b) { return a < b ? (a = b, true) : false; }


int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.precision(10);
    cout << fixed;
  
	int n;
	cin >> n;
	int a[n];
	for(int i = 0; i < n; i++)cin >> a[i];
	int q;
	cin >> q;
	while(q--){
		int el;
		cin >> el;
		auto pos = equal_range(a, a + n, el);
		cout << pos.first - a << ' ' << pos.second - a <<  '\n';
	}
    return 0;
}



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

using namespace std;

int main(void){

  vector<int> N;

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

  int tmp;
  cin >> tmp;

  N.push_back(tmp);

}

int five_count=0;
int seven_count=0;

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


  if(N.at(i) == 5){
    five_count++;
  }

  if(N.at(i) == 7){
    seven_count++;
  }

}

  if(seven_count == 1 && five_count == 2){
    cout << "YES" << endl;
  }else {
    cout << "NO" << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
    ios_base::sync_with_stdio(false);cin.tie(NULL);
    ll n,k;
    cin>>n>>k;
    ll a[n+1];
    for(int i=1;i<=n;i++)
        cin>>a[i];
    ll dp[n+1];
    for(int i=1;i<=n;i++)
        dp[i]=1e18;
    dp[1]=0;
    dp[2]=abs(a[2]-a[2-1]);
    for(int i=3;i<=n;i++)
    {
        for(ll j=max((ll)1,i-k);j<i;j++)
            dp[i]=min(dp[i],dp[j]+max(a[i],a[j])-min(a[i],a[j]));
    }
    cout<<dp[n];
    return 0;
}

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

using namespace std;

#define FAST_IO ios_base::sync_with_stdio(false); cin.tie(nullptr)
#define push_back pb

typedef long long ll;

const int N = 200001;

vector <int> adj[N];

int main()
{
    FAST_IO;
    int a, b;
    cin >> a >> b;
    ll sk1 = a-b;
    ll sk2 = a+b;
    ll sk3 = a*b;
    ll ans = max(max(sk1, sk2), sk3);
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 4992
mod=10**9+7
n,k=map(int,input().split())
ans=0
comb1=1 #初期値はNC0=1
comb2=1 #初期値は(N-1)C0=1
for i in range(min(k+1,n)): #0人の部屋は高々N-1個しか
 # 存在しないので操作回数は高々min(K,N-1)回となる
 ans+=comb1*comb2 #0人の部屋がi個のときの場合の数は
 # NCi*(N-1)Ci
 ans%=mod
 comb1*=(n-i)*pow(i+1,mod-2,mod) #NC(i+1)はNC
 # i*(N-i)/(i+1)で求められる
 comb1%=mod
 comb2*=(n-1-i)*pow(i+1,mod-2,mod) #(N-1)C(i+1
 # )は(N-1)Ci*((N-1)-i)/(i+1)で求められる
 comb2%=mod
print(ans)

Measured memory_bytes: 40428
import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Scanner;

class Main {
	public static void main(String[] args) throws IOException {
     BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
	
	
		//BufferedReader br=new BufferedReader(new FileReader("sample.txt"));
		String str=br.readLine();
		String[] st=str.split(" ");
		str=br.readLine();
		Dice dice1 =new Dice(st);
		dice1.roll(str);
		System.out.println(dice1.getd1());
	}
	}
class Dice{

String d1,d2,d3,d4,d5,d6;

	Dice(String[] s){
		d1=s[0];
		d2=s[1];
		d3=s[2];
		d4=s[3];
		d5=s[4];
		d6=s[5];
	}
		
	void roll(String s){
		String top,bot,back,front,left,right;
		for(int i=0;i<s.length();i++){
			char c=s.charAt(i);
		top=d1;
		bot=d6;
		front=d2;
		back=d5;
		left=d4;
		right=d3;
		switch(c){
		case 'N':
			top=d2;
			bot=d5;
			front=d6;
			back=d1;
			break;
		
		case 'S':
			top=d5;
			bot=d2;
			front=d1;
			back=d6;
			break;
		case 'W':
			top=d3;
			bot=d4;
			right=d6;
			left=d1;break;
		
		case 'E':
			top=d4;
			bot=d3;
			right=d1;
			left=d6;
			break;
		}
		d1=top;
		d2=front;
		d3=right;
		d4=left;
		d5=back;
		d6=bot;
		
	}}
	String getd1(){return d1;}
}

Measured memory_bytes: 17064
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

struct object
{
    int weight, value;

    object(){};

    int operator<(const object &O)
    {
        if (value == O.value)
        {
            return (weight < O.weight);
        }

        return (value > O.value);
    }
};

const int MAX_N = 1e3 + 5, MAX_VALUE = 55, oo = 1e9;
int minimum_weight[MAX_N][MAX_VALUE];

int main()
{
    int no_of_objects, capacity;
    cin >> no_of_objects >> capacity;

    vector<object> O(no_of_objects + 1);
    for (int i = 1; i <= no_of_objects; i++)
    {
        cin >> O[i].weight >> O[i].value;
    }

    long long total_value = 0;
    for (int i = 1; i <= no_of_objects; i++)
    {
        total_value += O[i].value;
    }

    int answer = 0;
    vector<long long> minimum_weight(total_value + 1, -1);
    total_value = 0;
    minimum_weight[0] = 0;

    for (int i = 1; i <= no_of_objects; i++)
    {
        total_value += O[i].value;

        for (int v = total_value; v >= O[i].value; v--)
        {
            if (minimum_weight[v - O[i].value] != -1)
            {
                long long weight_required = minimum_weight[v - O[i].value] + O[i].weight;

                if (weight_required <= capacity)
                {
                    answer = max(answer, v);
                }

                if (minimum_weight[v] == -1 || minimum_weight[v] > weight_required)
                {
                    minimum_weight[v] = weight_required;
                }
            }
        }
    }

    cout << answer;

    return 0;
}


Measured memory_bytes: 1024
#include<iostream>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<iomanip>
#include<map>
#define ll long long
#define MM(arr,x) memset(arr,x,sizeof(arr))
#define INF 10000000
using namespace std;
int main()
{
	int n;
	cin>>n;
	if(n%1000==0) cout<<0;
	else cout<<1000-n%1000; 
	return 0;
}

Measured memory_bytes: 3612
//解説AC
//https://atcoder.jp/contests/abc142/submissions/7794118
//#include <bits/stdc++.h>
#include <iostream>
#include <complex>
#include <sstream>
#include <string>
#include <algorithm>
#include <deque>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <vector>
#include <set>
#include <limits>
#include <cstdio>
#include <cctype>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <ctime>
#include <climits>
#include <iomanip>

#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define FOR(i, j, k) for(int i = (int)(j); i < (int)(k); ++i)
#define ROF(i, j, k) for(int i = (int)(j); i >= (int)(k); --i)
#define FORLL(i, n, m) for(long long i = n; i < (long long)(m); i++)
#define SORT(v, n) sort(v, v+n)
#define REVERSE(v) reverse((v).begin(), (v).end())

using namespace std;
using ll = long long;
const int MOD=1e9+7;
typedef pair<int, int> P;

ll ADD(ll x, ll y) { return (x+y) % MOD; }
ll SUB(ll x, ll y) { return (x-y+MOD) % MOD; }
ll MUL(ll x, ll y) { return x*y % MOD; }
ll POW(ll x, ll e) { ll v=1; for(; e; x=MUL(x,x), e>>=1) if (e&1) v = MUL(v,x); return v; }
ll DIV(ll x, ll y) { /*assert(y%MOD!=0);*/ return MUL(x, POW(y, MOD-2)); }

template<class T> bool chmax(T &a,const T &b){if(a<b){a=b;return 1;}return 0;}
template<class T> bool chmin(T &a,const T &b){if(a>b){a=b;return 1;}return 0;}

const int N = 1010;

struct edge {
    int to;
    int cost;
};
vector<int> G[N];
int n, m;
const int INF = 1e8;
deque<int> path;
int Next[N];
bool vis[N];

int dfs(int u, int start, int sz) {
  int min_sz = INF;
  for (int v: G[u]) {
    if (!vis[v]) {
      if (v == start) {
        Next[u] = v;
        return sz + 1;
      }
      vis[v] = true;
      int tmp = dfs(v, start, sz + 1);
      if (tmp < min_sz) {
        min_sz = tmp;
        Next[u] = v;
      }
    }
  }
  return min_sz;
}
 
void cycleRec(int start) {
  path.clear();
  path.emplace_back(start);
  int v = Next[start];
  while (v != start) {
    path.emplace_back(v);
    v = Next[v];
  }
}

int
main(void){  
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cin >> n >> m;
  for(int i=0; i<m; ++i){
      int a, b;
      cin >> a >> b;
      a--, b--;
      G[a].push_back(b);
  }    
  int start = -1, min_sz = INF;
  REP(i, n) {
    REP(j, n) {
      vis[j] = false;
      Next[j] = -1;
    }
    int sz = dfs(i, i, 0);
    if (sz < min_sz) {
      start = i;
      min_sz = sz;
    }
  }
  if (start == -1) {
    printf("-1\n");
  } else {
    REP(i, n){
      vis[i] = false;
      Next[i] = -1;
    }
    dfs(start, start, 0);
    cycleRec(start);
    printf("%d\n", (int) path.size());
    for (int i = 0; i < (int) path.size(); ++i) {
      printf("%d\n", path[i] + 1);
    }
  }

  return 0;
}


Measured memory_bytes: 384
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func init() {
	const maxWord = (1 << 30)
	buf := []byte{}
	sc.Buffer(buf, maxWord)
	sc.Split(bufio.ScanWords)
}

func input() string {
	sc.Scan()
	return sc.Text()
}

func main() {
	n, _ := strconv.Atoi(input())
	s := make([]string, n)
	for i := 0; i < n; i++ {
		s[i] = input()
	}

	m := map[string]bool{}
	for _, v := range s {
		m[v] = true
	}
	fmt.Println(len(m))
}


Measured memory_bytes: 20120
<?php
fscanf(STDIN,'%d',$N);
$Na=str_split($N);
if ($Na[0]==$Na[1]&&$Na[1]==$Na[2]) {
  // code...
  echo 'Yes';
}elseif ($Na[1]==$Na[2]&&$Na[2]==$Na[3]) {
  // code...
  echo 'Yes';
}else{
  echo 'No';
}
 ?>


Measured memory_bytes: 3828
#!/usr/bin/env python
from __future__ import division, print_function

import os
import sys
from io import BytesIO, IOBase

if sys.version_info[0] < 3:
    from __builtin__ import xrange as range
    from future_builtins import ascii, filter, hex, map, oct, zip


def memodict(f):
    """ Memoization decorator for a function taking a single argument. """
    class memodict(dict):
        def __missing__(self, key):
            ret = self[key] = f(key)
            return ret

    return memodict().__getitem__


@memodict
def solve(x):
    if x == 1:
        return 1
    return 2 * solve(x // 2) + 1


def main():
    h = int(input())
    print(solve(h))


# region fastio

BUFSIZE = 8192


class FastIO(IOBase):
    newlines = 0

    def __init__(self, file):
        self._fd = file.fileno()
        self.buffer = BytesIO()
        self.writable = "x" in file.mode or "r" not in file.mode
        self.write = self.buffer.write if self.writable else None

    def read(self):
        while True:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            if not b:
                break
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines = 0
        return self.buffer.read()

    def readline(self):
        while self.newlines == 0:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            self.newlines = b.count(b"\n") + (not b)
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines -= 1
        return self.buffer.readline()

    def flush(self):
        if self.writable:
            os.write(self._fd, self.buffer.getvalue())
            self.buffer.truncate(0), self.buffer.seek(0)


class IOWrapper(IOBase):
    def __init__(self, file):
        self.buffer = FastIO(file)
        self.flush = self.buffer.flush
        self.writable = self.buffer.writable
        self.write = lambda s: self.buffer.write(s.encode("ascii"))
        self.read = lambda: self.buffer.read().decode("ascii")
        self.readline = lambda: self.buffer.readline().decode("ascii")


def print(*args, **kwargs):
    """Prints the values to a stream, or to sys.stdout by default."""
    sep, file = kwargs.pop("sep", " "), kwargs.pop("file", sys.stdout)
    at_start = True
    for x in args:
        if not at_start:
            file.write(sep)
        file.write(str(x))
        at_start = False
    file.write(kwargs.pop("end", "\n"))
    if kwargs.pop("flush", False):
        file.flush()


if sys.version_info[0] < 3:
    sys.stdin, sys.stdout = FastIO(sys.stdin), FastIO(sys.stdout)
else:
    sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)

input = lambda: sys.stdin.readline().rstrip("\r\n")

# endregion

if __name__ == "__main__":
    main()


Measured memory_bytes: 38460
#include <iostream>
unsigned long long ans(0);

int main() {
  	std::ios_base::sync_with_stdio(false), std::cin.tie(0), std::cout.tie(0);
	std::string S;
	std::getline(std::cin,S);
	unsigned long long offset = 0;
	unsigned long long addnum = 0;
	for (auto itr : S) {
		if(itr == 'W'){
			ans += offset;
			ans += addnum;
			offset += addnum;
			addnum = 0;
		}
		if(itr == 'B'){
			addnum ++;
		}
	}
	std::cout << ans << '\n';
	return 0;
}


Measured memory_bytes: 720
#include<bits/stdc++.h>
using namespace std;
long long ans;
const int mod = 1e9+7;
const int maxN = 100010;
long long fac[maxN] = {1, 1}, facInv[maxN] = {1, 1}, inv[maxN] = {0, 1};
void initComb() {
    for (int i = 2; i < maxN; ++i) {
        fac[i] = fac[i - 1] * i % mod;
        inv[i] = mod - inv[mod % i] * (mod / i) % mod;
        facInv[i] = facInv[i - 1] * inv[i] % mod;
    }
}
long long comb(int n, int k) {
    if (n < k || n < 0 || k < 0) return 0;
    return fac[n] * facInv[k] % mod * facInv[n - k] % mod;
}
int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int N, K;
    cin >> N >> K;
    vector<int> A(N);
    for (auto & a : A) cin >> a;
    sort(A.begin(), A.end());
    initComb();
    long long tmp;
    for (int i = K-1; i < N; ++i) {
        tmp = 0;
        if ((tmp += A[i]) < 0) tmp += mod;
        if ((tmp -= A[N-i-1]) < 0) tmp += mod;
        tmp %= mod;
        if ((ans += comb(i, K-1) * tmp % mod) >= mod) ans -= mod;
    }
    printf("%lld\n", ans);
    return 0;
}


Measured memory_bytes: 3580