akhauriyash/Code-Regression huggingface dataset:
import sys
sys.setrecursionlimit(2147483647)
INF=float("inf")
MOD=10**9+7
input=lambda :sys.stdin.readline().rstrip()
def bisect(l,r,f,discrete=True,left=True):
    """
    l,r: l<r int if discrete else float
    f: function defined on [l,...,r] to {False,True}
    if discrete: f defined on Z; else: R
    if left: f satisfies that there uniquely exists d such that iff i<=d then f(i)
    else: iff i>=d then f(i) is True
    return d such as those above
    """
    assert r>l
    if discrete: assert isinstance(l,int) and isinstance(r,int)
    eps=1 if discrete else 10**-12
    if (not left)^f(r): return r if left else r+1
    elif left^f(l): return l-1 if left else l
    while(r-l>eps):
        h=(l+r)//2 if discrete else (l+r)/2
        if (not left)^f(h): l=h
        else: r=h
    return h if not discrete else l if left else r

class RollingHash(object):
    """
    construct: O(N)
    get_hash: O(1)
    LCP: O(logN)
    """
    def __init__(self,S,m1=10**9+9,b1=1007,m2=10**9+7,b2=2009):
        """
        S: string
        m1>m2: prime sufficiently large
        b1,b2: base 0<bi<mi
        """
        assert m1>m2 and 0<b1<m1 and 0<b2<m2
        n=len(S)
        self.__n=n
        self.__m1=m1
        self.__m2=m2
        self.__H1,self.__H2=[0]*(n+1),[0]*(n+1)
        self.__P1,self.__P2=[1]*(n+1),[1]*(n+1)
        for i,s in enumerate(S):
            self.__H1[i+1]=(self.__H1[i]*b1+ord(s))%m1
            self.__H2[i+1]=(self.__H2[i]*b2+ord(s))%m2
            self.__P1[i+1]=self.__P1[i]*b1%m1
            self.__P2[i+1]=self.__P2[i]*b2%m2

    @property
    def len(self):
        return self.__n

    def hash(self,l,r=None):
        """
        l,r: int (0<=l<=r<=n)
        return (hash1,hash2) of S[l:r]
        """
        if r is None: r=self.len
        assert 0<=l<=r<=self.len
        return ((self.__H1[r]-self.__P1[r-l]*self.__H1[l]%self.__m1)%self.__m1,(self.__H2[r]-self.__P2[r-l]*self.__H2[l]%self.__m2)%self.__m2)

    def LCP(self,l1,r1=None,rh2=None,l2=0,r2=None):
        if r1 is None: r1=self.len
        if rh2 is None: rh2=self
        if r2 is None: r2=rh2.len
        assert 0<=l1<=r1<=self.len and 0<=l2<=r2<=rh2.len
        L=0
        R=min(r1-l1,r2-l2)
        if self.hash(l1,l1+R)==rh2.hash(l2,l2+R): return R
        while(R-L>1):
            H=(L+R)//2
            if self.hash(l1,l1+H)==rh2.hash(l2,l2+H): L=H
            else: R=H
        return L

def resolve():
    n=int(input())
    S=input()
    # d=0ではtrue,d=nではfalseなので、そこでbisectする
    rh=RollingHash(S)
    def judge(d):
        # S[0:d],...,S[n-d:n]に重複があり、かつd離れているか判定
        # initialize
        J={rh.hash(i,i+d):-1 for i in range(n-d+1)}
        for i in range(n-d+1):
            h=rh.hash(i,i+d)
            if J[h]!=-1:
                if i-J[h]>=d: return True
            else: J[h]=i
        return False
    print(bisect(0,n,judge))
resolve()

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

int main() {
  string s; cin >> s;
  int idx = 0;
  while (1) {
    int pos = s.find("BC", idx);
    if (pos == string::npos) break;
    s.erase(pos, 1);
    s.at(pos) = 'Z';
    idx = pos;
  }
  long long ans = 0;
  long long cntA = 0, cntZ = 0;
  for (int i = s.size()-1; i >= 0; i--) {
    if (s.at(i) == 'Z') cntZ++;
    else if (s.at(i) == 'A' && cntZ > 0) ans += cntZ;
    else {
      cntA = 0;
      cntZ = 0;
    }
  }
  cout << ans << endl;
}


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

int main() {
    int s, flag = 0;
    cin >> s;
    vector<int> v;

    v.push_back(s);
    for (;;) {
        if (s % 2 == 0) {
            s = s / 2;
        } else {
            s = 3 * s + 1;
        }

        v.push_back(s);

        for (int i = 0, cnt = 0; i < v.size()-1; i++) {
            if (s == v.at(i) && flag) {
                cout << i + 3 << endl;
                return 0;
            }else if(s == v.at(i)){flag = 1;}
        }
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> l_l;
typedef pair<int , int> i_i;
typedef vector<ll> vl;
typedef vector<int> vi;
typedef vector<char> vec;
typedef vector<bool> veb;
typedef vector<string> ves;
typedef vector<vector<ll>> vvl;
typedef vector<vector<int>> vvi;
typedef vector<vector<char>> vvec;
typedef vector<vector<bool>> vveb;
typedef vector<vector<string>> vves;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<(int)(n);i++)
#define rep2(i,n) for(int i=2;i<(int)(n);i++)
#define repk(i,k,n) for(int i=k;i<(int)(n);i++)
#define fs first
#define sc second
#define pb push_back
#define pp pop_back
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define maxel(a) *max_element(all(a))
#define minel(a) *min_element(all(a))
#define acc accumulate
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define mod (1000000007)
typedef long long int64;
//const int64 INF = 1LL << 58;
#define dame { puts("-1"); return 0;}
#define YES { cout << "YES" << endl; return 0; }
#define NO { cout << "NO" << endl; return 0; }
#define Yes { cout << "Yes" << endl; return 0; }
#define No { cout << "No" << endl; return 0; }
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; }
int dx[] = {0, 0, -1, 1};
int dy[] = {1, -1, 0, 0};

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
    //cout << fixed << setprecision(15);

	int H,N; cin>>H>>N;
    vector<pair<ld, l_l>> AB(N); rep(i,N) cin >> AB[i].sc.fs >> AB[i].sc.sc;
    rep(i,N) {
        ld a = (ld) AB[i].sc.fs / AB[i].sc.sc;
        AB[i].fs = a;
    }
    sort(all(AB));
    ll ans = 0;
    //ans += (H / AB[0].sc.fs) * AB[0].sc.sc;
    //H -= (H / AB[0].sc.fs) * AB[0].sc.fs;

    vl dp(20005,INF);
    dp[0] = 0;
    ll res = INF;
    rep(i,N) {
        rep(j,H) {
            dp[j + AB[i].sc.fs] = min(dp[j + AB[i].sc.fs], dp[j] + AB[i].sc.sc);
        }
    }
    repk(i,H,20000) chmin(res,dp[i]);
    cout << res << endl;
    
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#define pb emplace_back
#define ff first
#define ss second
#define mid(l, r) ((l + r) >> 1)
#define assign(x,val) memset(x,val,sizeof(x))
#define all(x) (x).begin(), (x).end()
#define for0(i,n) for(int i=0;i<n;++i)
#define for1(i,n) for(int i=1;i<=n;++i)
#define ford(i,n) for(int i=n;i>=1;--i)
#define forg(i,a,b) for(int i=a;i<b;++i)
using namespace std;
int  inf = 1e9;
long long mod = 1000000007;
typedef long long ll;
const long double PI = (long double)(3.1415926535897932384626433832795);

int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.precision(3);
    cout << fixed;
    int n;cin>>n;
    vector<pair<int, int>>v;
    for(int i=0;i<n;++i){
        int temp;cin>>temp;
        v.push_back({temp, i});
    }
    sort(v.begin(), v.end());
    for(int i=0;i<n;++i){
      cout<<v[i].ss+1<<" ";
    }

}

Measured memory_bytes: 1780
#include <bits/stdc++.h>
#define MOD %1000000007
//#define md %998244353
#define INF 2e9
#define INFI 1e9 + 7
#define EPS 1e-9
#define MAX LLONG_MAX
#define MIN LLONG_MIN
#define F first
#define S second
#define MP make_pair
#define PB push_back
#define EB emplace_back
#define endl "\n"
#define FOR(i,a,b) for (long long i = a; i < b; i++)
#define REV(i,a,b) for (long long i = a; i > b; i--)
#define mset(a, v) memset(a, v, sizeof(a))
#define fd(n) fixed<<setprecision(n)
typedef std::pair<int, int> pii;
typedef std::vector<long long> vi;
typedef std::vector<vi> vvi;
typedef long long ll;
typedef unsigned long long ull;
using namespace std;

ll solve(ll x,ull y,ll p) {
    ll res = 1;
    x = x % p;
    while (y > 0) {
        if (y & 1)
            res = (res*x) % p;
        y = y>>1;
        x = (x*x) % p;
    }
    return res;
}


const ll md = 998244353;

// void add(int &a, int b) {
//  a += b;
//  if (a >= md) a -= md;
//}
// void sub(int &a, int b) {
//  a -= b;
//  if (a < 0) a += md;
//}

ll  mul(ll a, ll b) {
  return (ll) ((long long) a * b % md);
}

ll  power(ll a, ll b) {
  ll res = 1;
  while (b > 0) {
    if (b & 1) {
      res = mul(res, a);
    }
    a = mul(a, a);
    b >>= 1;
  }
  return res;
}

ll inv(ll a) {
  return power(a, md - 2);
}


int main() {
    ios::sync_with_stdio(false);
    cin.tie(NULL);
 
   
  ll n,i,j,k,flag=0,m,ans=0,x,c=0,sum=0;
  
  cin>>n>>m;
  ll a[n];
  for(i=0;i<n;i++)cin>>a[i];
  sort(a,a+n);
  
  reverse(a,a+n);
  
  
  for(i=0;i<n;i++)
   sum=sum+a[i];
   
  // x=(double)sum/(4*m);
   
   for(i=0;i<n;i++)
   {
      if(a[i]>=(double)sum/(4*m))	
      c++;
      
   }
   
    if(c>=m)
	 cout<<"Yes";
	else
	 cout<<"No";  


}

Measured memory_bytes: 256
//A.cpp
#include <iostream>
#include <string>
#include <algorithm>
#include <set>
#include <vector>
using namespace std;

int main(){
  int N;
  cin >> N;
  int Ans;
  bool flag = true;
  while(flag){
    string S = to_string(N);
    if(S[0]==S[1]&&S[1]==S[2]){
      Ans = N;
      flag = false;
    }else{
      ++N;
    }
  }
  printf("%d\n", Ans);
  return 0;
}


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

struct Element{
    int value;
    bool isIdentity;
};
Element Identity = {0 , true};
Element Operation(const Element &A, const Element &B){
    if(A.isIdentity) return B;
    if(B.isIdentity) return A;
    return {A.value | B.value, false};
}

// Don't forget initial_build
struct SegmentTree{
    int size; // number of leaves: power of two
    vector<Element> cbt; // complete binary tree

    // Initialize with Identity Element
    SegmentTree(int N){
        size = 1;
        while (size < N) size *= 2;
        cbt.resize(size * 2 - 1, Identity);
    }

    // Initial Input
    void initial_set(int i, const Element &A) {
        i += size - 1;
        cbt[i] = A;
    }

    void initial_build() {
        for (int i = size - 2; i >= 0; --i) {
            cbt[i] = Operation(cbt[i*2+1], cbt[i*2+2]);
        }
    }

    Element get(int i){
        i += size - 1;
        return cbt[i];
    }

    // Update i-th Leaf (0-indexed) to A
    void update(int i, const Element &A){
        i += size - 1;
        cbt[i] = A;
        while (i > 0){
            i = (i - 1) / 2;
            cbt[i] = Operation(cbt[i*2+1], cbt[i*2+2]);
        }
    }

    // Product of Interval [a, b) (0-indexed)
    Element query(int a, int b) {
        return query_rec(a, b, 0, 0, size);
    }

    Element query_rec(int a, int b, int k, int l, int r){
        // k is root of subtree [l, r)
        if(r <= a || b <= l) return Identity; // outside [a, b)
        if(a <= l && r <= b) return cbt[k]; // interior of [a, b)
        Element vl = query_rec(a, b, k*2+1, l, (l+r)/2);
        Element vr = query_rec(a, b, k*2+2, (l+r)/2, r);
        return Operation(vl, vr);
    }
};

int main() {
    int N, Q;
    string S;
    cin >> N >> S >> Q;
    SegmentTree tree(N);
    for (int i = 0; i < N; ++i) {
        tree.initial_set(i, {1 << (S[i] - 'a')});
    }
    tree.initial_build();
    for (int i = 0; i < Q; ++i) {
        int k;
        cin >> k;
        if (k == 1) {
            int a; char b;
            cin >> a >> b;
            tree.update(a-1, {1 << (b - 'a')});
        } else {
            int a, b; cin >> a >> b;
            int ans = tree.query(a-1, b).value;
            ans = __builtin_popcount(ans);
            cout << ans << "\n";
        }
    }

    return 0;
}

Measured memory_bytes: 9092
#include "bits/stdc++.h"
using namespace std;
const int MAX = 700000;
const int MOD = 1000000007;

long long  fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX; i++) {
		fac[i] = fac[i - 1] * i % MOD;
		inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
		finv[i] = finv[i - 1] * inv[i] % MOD;
	}
}

// 二項係数計算
long long COM(int n, int k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
/*第二引数で第一引数を割ったときの切り上げの計算*/
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;
}
/*逆元計算*/
long long int  modinv(long long a, long long m) {
	long long int b = m, u = 1, v = 0;
	while (b) {
		long long int t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}
// index が条件を満たすかどうか
vector<long long int >meguru;
bool isOK(int index, int key) {
	if (meguru[index] >= key) return true;
	else return false;
}
// 汎用的な二分探索のテンプレ
int binary_search(int key) {
	int left = -1; //「index = 0」が条件を満たすこともあるので、初期値は -1
	int right = (int)meguru.size(); // 「index = a.size()-1」が条件を満たさないこともあるので、初期値は a.size()
	/* どんな二分探索でもここの書き方を変えずにできる！ */
	while (right - left > 1) {
		int mid = left + (right - left) / 2;

		if (isOK(mid, key)) right = mid;
		else left = mid;
	}
	/* left は条件を満たさない最大の値、right は条件を満たす最小の値になっている */
	return right;
}
int main() {
	int h, w;
	cin >> h >> w;
	vector<string>s;
	vector<int>pulusx = { 0,1,1,1,0,-1,-1,-1 };
	vector<int>pulusy = { 1,1,0,-1,-1,-1,0,1 };
	for (int i = 0; i < h; i++) {
		string a;
		cin >> a;
		s.push_back(a);
	}
	for (int i = 0; i < h; i++) {
		for (int j = 0; j < w; j++) {
			int sum = 0;
			for (int k = 0; k < pulusx.size(); k++) {
				if (j + pulusx[k] >= 0 && j + pulusx[k] < w && i + pulusy[k] >= 0 && i + pulusy[k] < h) {
					if (s[i + pulusy[k]][j + pulusx[k]] == '#') {
						sum++;
					}
				}
			}
			if (s[i][j] != '#') {
				s[i][j] = '0' + sum;
			}
		}
	}
	for (int i = 0; i < h; i++) {
		for (int j = 0; j < w; j++) {
			cout << s[i][j];
		}
		cout << endl;
	}
}


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

int main() {
  //数の入力
  int N;
  cin >> N;
  vector<int> diameter(N);
  for (int i = 0; i < N; i++) {
    cin >> diameter.at(i);
  }
  
  //小さい順に並べ替える
  sort(diameter.begin(), diameter.end());
  
   //種類数を数える
  int count = 1;
  for (int i = 0; i < (N-1); i++) {
    if (diameter.at(i + 1) - diameter.at(i) > 0) {
      count ++;
    }
    else {
      continue;
    }
  }
  
  cout << count << endl;
}



Measured memory_bytes: 256
#include <stdio.h>
int main()
{
    int a, b, c, t;
    scanf("%d %d %d",&a,&b,&c);
    if(a<=10000 && a>=0 && b<=10000 && b>=0 && c<=10000 && c>=0)
    {
        if(a>b)
        {
        int t = a;
             a = b;
             b = t;
        }

        if(b>c)
        {
        int t = b;
             b = c;
             c = t;
        }

        if(a>b)
        {
        int t = a;
             a = b;
             b = t;
        }
        printf("%d\n",a+b);

    }
        return 0;
}


Measured memory_bytes: 128
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
using namespace std;
const int N=3e3+5;
double dp[N][N];
double p[N];
int main(){
    int n;scanf("%d",&n);
    for(int i=1;i<=n;i++){
        scanf("%lf",p+i);
    }
    dp[0][0]=1;
    for(int i=1;i<=n;i++){
        dp[i][0]=dp[i-1][0]*p[i];
        for(int j=1;j<=i;j++){
            dp[i][j]=dp[i-1][j-1]*(1-p[i])+dp[i-1][j]*p[i];
        }
    }
    double ans=0;
    for(int i=n/2;i>=0;i--) ans+=dp[n][i];
    printf("%.10lf",ans);
}


Measured memory_bytes: 68992
#include<iostream>
using namespace std;
int main(){
    int n;cin >> n ;
    int ans  =0;
    int b[n];
    for(int i=0;i<n-1;i++){
        cin >> b[i];
    }
    ans += b[0];
    for(int i=0;i<n-2;i++){
        ans += min(b[i],b[i+1]);
    }
    ans += b[n-2];
    cout << ans << endl;
    return 0;
}

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

using namespace std;

int N, M, msk[15], dp[1 << 15], nrb[1 << 15];
bool ok[1 << 15];
const int mod = 1e9 + 7;
const int long long mod2 = 1LL * mod * mod;
void mul (int &x, int y) {x = (1LL * x * y) % mod;}
void adto (int &x, int y) {x += y; if (x >= mod) x -= mod;}

int main ()
{
//freopen ("input", "r", stdin);
//freopen ("output", "w", stdout);

scanf ("%d %d", &N, &M);
int ans = 1;
while (M --)
{
    int x, y;
    scanf ("%d %d", &x, &y), x --, y --;
    msk[x] |= 1 << y, ans += ans;
    if (ans >= mod) ans -= mod;
}
for (int i=0; i<1 << N; i++)
{
    nrb[i] = nrb[i >> 1] + (i & 1);
    ok[i] = (i & 1) ^ ((i >> 1) & 1) ^ 1;
}
for (int i=0; i<1 << N; i++)
if (ok[i])
{
    dp[i] = 1;
    for (int j=(i - 1) & i; j != 0; j = (j - 1) & i)
    if (ok[j] && ok[j ^ i])
    {
        int cnt = dp[j], j0 = j ^ i;
        for (int k=0; k<N; k++)
            if ((j >> k) & 1)
                mul (cnt, (1 << nrb[msk[k] & j0]) - 1);
        for (int k=0; k<N; k++)
            if ((j0 >> k) & 1)
                mul (cnt, 1 << nrb[msk[k] & j]);
        dp[i] += cnt;
        if (dp[i] >= mod)
            dp[i] -= mod;
    }
}
ans -= dp[(1 << N) - 1];
if (ans < 0) ans += mod;
printf ("%d\n", ans);

return 0;
}


Measured memory_bytes: 512
while 1:
    try:
        q = float(input())
        if q == -1:
            break
        x = q/2
        while abs(x ** 3 - q) >= 0.00001 * q:
            x = x - (x ** 3 - q) / (3 * x ** 2)
        print(x)

    except:
        break



Measured memory_bytes: 5640
#include <iostream>
#include <string>

using namespace std;

int main(int argc, char const *argv[])
{
    //input 
    int N, M;
    cin>>N>>M;

    int p[M];
    string S[M];
    for (int i = 0; i < M; i++)
    {
        cin>>p[i]>>S[i];
    }

    //output
    bool ac[N] = {false};
    int wa[N] = {0};
    int penalty=0;
    int correct_ans=0;

    for (int i = 0; i < M; i++)
    {
        if(ac[p[i]-1] == false){
            if (S[i] == "WA"){
                wa[p[i]-1] ++;
            }
            else {
                penalty += wa[p[i]-1];
                correct_ans ++;
                ac[p[i]-1] = true;
            }
        }
    }
    
    cout<<correct_ans<<" "<<penalty<<endl;

    return 0;
}

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

int main()
{
    int h1, h2, m1, m2, k;
    cin >> h1 >> m1 >> h2 >> m2 >> k;
    int ans;
    ans = (60 * h2 + m2) - (60 * h1 + m1) - k;
    cout << ans << endl;
    return 0 ;
}

Measured memory_bytes: 3636
#include <iostream>

using namespace std;

typedef long long ll;

ll mod = 1e9 + 7;
ll dp[61][2][2][2];
int main(int argc, char *argv[])
{
	ll L, R;

	cin >> L >> R;

	dp[60][0][0][0] = 1;

	for (int i = 59; i >= 0; i--) {
		int lb = L >> i & 1;
		int rb = R >> i & 1;
		for (int j = 0; j < 2; j++) {
			for (int k = 0; k < 2; k++) {
				for (int s = 0; s < 2; s++) {
					ll pre = dp[i + 1][j][k][s] % mod;
					for (int x = 0; x < 2; x++) {
						for (int y = 0; y < 2; y++) {
							if (x && !y) {
								continue;
							}
							int nj = j, nk = k, ns = s;
							if (!s && x != y) {
								continue;
							}
							if (x && y) {
								ns = 1;
							}
							if (!j && !x && lb) {
								continue;
							}
							if (x && !lb) {
								nj = 1;
							}
							if (!k && y && !rb) {
								continue;
							}
							if (!y && rb) {
								nk = 1;
							}
							dp[i][nj][nk][ns] += pre % mod;
							dp[i][nj][nk][ns] %= mod;
						}
					}
				}
			}
		}
	}

	ll ans = 0;
	for (int j = 0; j < 2; j++) {
		for (int k = 0; k < 2; k++) {
			for (int s = 0; s < 2; s++) {
				ans += dp[0][j][k][s] % mod;
				ans %= mod;
			}
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
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<bool> VB;
typedef vector<double> VD;
typedef vector<string> VS;
typedef vector<char> VC;
typedef vector<VC> VVC;
typedef vector<VB> VVB;
typedef pair<int, int> PII;
typedef long long LL;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;
typedef pair<LL,LL> PLL;
typedef vector<PII> VPII;

//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 SQ(a) ((a)*(a))
#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())
#define LB lower_bound
#define UB upper_bound
#define SORTR(c) sort((c).begin(), (c).end(), greater<int>())

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

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
const LL INF = INT_MAX;
const LL LINF = LLONG_MAX;
const LL MOD = 1e9+7;

//other
//-------------------------------------------
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define FI first
#define SE second

//memo
// setprecision()

VI dx = {1,0,-1,0};
VI dy = {0,1,0,-1};

LL Gcd(LL a, LL b) {
  return __gcd(a,b);
}

LL Lcm(LL a, LL b) {
  LL abd = Gcd(a,b);
  LL x = a / abd, y = b / abd;
  
  return x*y*abd;
}


LL RepSqu(LL N, LL P, LL M) {
  if(P == 0) {
    return 1;
  }
  if(P%2 == 0) {
    LL t = RepSqu(N, P/2, M);
    return t*t % M;
  }
  return (N * RepSqu(N, P-1, M)) % M;
}


int main() {
  
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  int H,W;
  cin >> H >> W;
  VVB s(H,VB(W,false));
  REP(i,H){
    REP(j,W){
      char c;
      cin >> c;
      if(c == '.')s.at(i).at(j) = true;
    }
  }
  
  VVI a(H,VI(W,0));
  
  if(!s.at(0).at(0)) a.at(0).at(0)++;
  
  FOR(i,1,H){
    if(s.at(i-1).at(0) && !s.at(i).at(0)) a.at(i).at(0) = a.at(i-1).at(0)+1;
    else a.at(i).at(0) = a.at(i-1).at(0);
  }
  FOR(i,1,W){
    if(s.at(0).at(i-1) && !s.at(0).at(i)) a.at(0).at(i) = a.at(0).at(i-1)+1;
    else a.at(0).at(i) = a.at(0).at(i-1);
  }
  
  FOR(i,1,H){
    FOR(j,1,W){
      int u = a.at(i-1).at(j), l = a.at(i).at(j-1);
      if(s.at(i-1).at(j) && !s.at(i).at(j)) u++;
      if(s.at(i).at(j-1) && !s.at(i).at(j)) l++;
      a.at(i).at(j) = min(u,l);
    }
  }
  
  cout << a.at(H-1).at(W-1) << endl;
  
  return 0;
}

Measured memory_bytes: 256
//============================================================================
// Name        : aaa.cpp
// Author      : 
// Version     :
// Copyright   : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================

#include <iostream>
#include <vector>
#include <algorithm>
#include <map>

using namespace std;
int main() {
	int N, M;
	cin >> N >> M;

	vector<vector<long long>> p;
	map<long long, int> g;
	p.resize(M);
	;
	for (int m = 0; m < M; ++m) {
		long long k1, k2;
		cin >> k1 >> k2;
		p[m].resize(3);

		p[m][0] = k1;
		p[m][1] = k2;
		p[m][2] = m;
	}
	vector<pair<int, int>> s;
	s.resize(M);

	sort(p.begin(), p.end());


	for (int m = 0; m < M; ++m) {
		s[p[m][2]] = make_pair(p[m][0], g[p[m][0]] + 1);
		++g[p[m][0]];
	}

	for (int m = 0; m < M; ++m) {
		printf("%06d%06d\n", s[m].first, s[m].second);
	}

	return 0;
}


Measured memory_bytes: 13952
#include <stdio.h>
#include <iostream>
#include <vector>
#include <string>
#include <cstdio>
#include <limits>
using namespace std;

//static const int MAX = 1000;
int main(){
    int N;
    cin >> N;
    int A[100];
    for (int i=0;i<N;i++) cin >> A[i];
    
    bool loop = true;
    int count = 0;
    while (loop) {
        loop = false;
        for (int i=N-1;i>=1;i--){
            int v = A[i];
            if (v < A[i-1]) {
                A[i] = A[i-1];
                A[i-1] = v;
                count++;
                loop = true;
            }
        }
    }
    cout << A[0];
    for (int i=1;i<N;i++) cout << " " << A[i];
    cout << endl;
    cout << count << endl;
}



Measured memory_bytes: 3104
import copy
(H,W,K) = map(int,input().split())
l = [[0 for i in range(W)] for j in range(H)]
ans = 0
for i in range(H):
    a = input()
    for j in range(W):
        l[i][j]=a[j]

t = [0 for i in range(W)]
y = [0 for i in range(H)]

for i in range(H):
    for j in range(W):
        if l[i][j]=='#':
            t[j]+=1
            y[i]+=1

sum = 0

for i in range(H):
    sum += y[i]

for i in range(1<<H):
    for j in range(1<<W):
        S = sum
        Y = copy.deepcopy(y)
        T = copy.deepcopy(t)
        for k in range(H):
            if i>>k&1:
                S-=Y[k]
                for q in range(W):
                    if l[k][q]=='#':
                        T[q]-=1
        for p in range(W):
            if j>>p&1:
                S-=T[p]
        if S == K:
            ans += 1
            #print(str(i)+"-"+str(j))
            #print(sum)
        
#print(T)
#print(Y)
#print(S)
print(ans)


Measured memory_bytes: 9344
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cstring>
#include<cmath>
using namespace std;
typedef long long LL;
const int MaxN = 1e5 + 5;
int n;
char s[MaxN];
int ans[MaxN];
bool flag;
void search(int x, int y){
	int p = 0;
	ans[++p] = x;
	ans[++p] = y;
	for(int i = 2; i <= n; i++){
		if(ans[i] == 1){
			if(s[i] == 'o')
				ans[i + 1] = ans[i - 1];
			else if(s[i] == 'x')
				ans[i + 1] = -ans[i - 1];
		}
		else if(ans[i] == -1){
			if(s[i] == 'o')
				ans[i + 1] = -ans[i - 1];
			else if(s[i] == 'x')
				ans[i + 1] = ans[i - 1];
		}
	}
	if(ans[1] == ans[1 + n]){
		if(ans[1] == 1){
			if(s[1] == 'o' && ans[2] == ans[n]) flag = true;
			else if(s[1] == 'x' && ans[2] != ans[n]) flag = true;
		}
		else if(ans[1] == -1){
			if(s[1] == 'o' && ans[2] != ans[n]) flag = true;
			else if(s[1] == 'x' && ans[2] == ans[n]) flag  = true;
		}
	}	
}
int main(){
	while(~scanf("%d", &n)){
		scanf("%s", s + 1);
		for(int i = -1; i <= 1; i++){
			for(int j = -1; j <= 1; j++){
				if(i == 0 || j == 0) continue;
				if(!flag) search(i, j);
			}
		}
		if(!flag) printf("-1\n");
		else{
			for(int i = 1; i <= n; i++)
				if(ans[i] == 1) printf("S");
				else if(ans[i] == -1) printf("W");
			printf("\n");
		}
	memset(ans, 0, sizeof(ans));
	memset(s, 0, sizeof(s));
	flag = false;
	}
	return 0;
}

Measured memory_bytes: 768
#include <iostream>
#include <numeric>
#include <stdio.h>
#include <iomanip>
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
using namespace std;
#define rep(i, n) for (long long i = 0; i < (long long)(n); i++)






int main() {
	int s;
	cin >>s ;
	
	string g = "No";
	if ((s%1000)%111==0||(s/10)%111==0) {
		g = "Yes";
	}
	cout <<g<< endl;
}


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

inline long long read(){
    long long s = 0, w = 1;
    char ch = getchar();
    while (ch < '0' || ch > '9'){
        if (ch == '-') w = -1;
        ch = getchar();
    }
    while (ch >= '0' && ch <= '9'){
        s = s * 10 + ch - '0';
        ch = getchar();
    }
    return s * w;
}

int main(){
    int n = read();
    for (int i = 1; i <= n; i++){
        cout << "ACL";
    }
    puts("");
    return 0;
}

Measured memory_bytes: 3624
#include<stdio.h>
int main(){
  int r,c,i,j,ans=0;
  scanf("%d %d",&r,&c);
  int a[r+1][c+1];
  for(i=0;i<=r;i++)a[i][c]=0;
  for(j=0;j<=c;j++)a[r][j]=0;
  for(i=0;i<r;i++){
    for(j=0;j<c;j++){
      scanf("%d",&a[i][j]);
    }
  }
  for(i=0;i<r;i++){
    for(j=0;j<c;j++){
      a[i][c]+=a[i][j];
      a[r][j]+=a[i][j];
      ans+=a[i][j];
    }
  }
  a[r][c]=ans;
  for(i=0;i<r+1;i++){
    for(j=0;j<c+1;j++){
      if(j==c)printf("%d\n",a[i][j]);
      else printf("%d ",a[i][j]);
    }
  }
  return 0;
}

Measured memory_bytes: 640
from collections import deque

def slide_max(A, K):
    N = len(A)
    max_idx = [0] * N
    d = deque()
    for i in range(N):
        while d and d[0] <= i-K:
            d.popleft()
        while d and A[d[-1]] < A[i]:
            d.pop()
        d.append(i)
        max_idx[i] = d[0]
    return max_idx


def slide_min(A, K):
    N = len(A)
    min_idx = [0] * N
    d = deque()
    for i in range(N):
        while d and d[0] <= i-K:
            d.popleft()
        while d and A[d[-1]] > A[i]:
            d.pop()
        d.append(i)
        min_idx[i] = d[0]
    return min_idx

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

larger_than_left = [1] * N
for i in range(1, N):
  if A[i] < A[i-1]:
    larger_than_left[i] = 0

sorted_idx = set()
num = sum(larger_than_left[1:K])
if num == K-1:
  sorted_idx.add(0)
for i in range(1, N-K+1):
  num += larger_than_left[i+K-1] - larger_than_left[i]
  if num == K-1:
    sorted_idx.add(i)

max_idx = slide_max(A, K-1)
min_idx = slide_min(A, K-1)
ans = [] if 0 in sorted_idx else [0]
for i in range(1, N-K+1):
  if i in sorted_idx:
    continue
  left = A[i-1]
  right = A[i+K-1]
  M = A[max_idx[i+K-2]]
  m = A[min_idx[i+K-2]]
  if m < left or right < M:
    ans.append(i)

print(len(ans) + (len(sorted_idx)>0))

Measured memory_bytes: 43096
#include<stdio.h>
int main(void)
{
	int y[2],m[2],d[2],y1,m1,d1;
	
	scanf("%d %d %d",&y[0],&m[0],&d[0]);
	scanf("%d %d %d",&y[1],&m[1],&d[1]);
	
	if(y[0]>y[1])	y1=y[0],y[0]=y[1],y[1]=y1,
					m1=m[0],m[0]=m[1],m[1]=m1,
					d1=d[0],d[0]=d[1],d[1]=d1;
			
	if(y[0]==y[1]&&m[0]==m[1]&&d[0]==d[1]) printf("0\n");
	
	else if(y[0]==y[1]&&m[0]<=m[1]&&d[0]>d[1]||
			y[0]==y[1]&&m[0]>m[1])
		printf("1\n");
		
	else if(y[0]<y[1]&&m[0]<m[1]&&d[0]<d[1])
		printf("%d\n",y[1]);
		
	else if(y[0]<y[1]&&m[0]<m[1])
		printf("%d\n",y[1]-y[0]+1);
		
	else if(y[0]<y[1]&&m[0]>=m[1])
		printf("%d\n",y[1]-y[0]);
}	


Measured memory_bytes: 2744
package main

import (
  "fmt"
  "sort"
)
func main() {
  var vec []int
  for i := 0; i < 3; i++ {
    var temp int
    fmt.Scanf("%d", &temp)
    vec = append(vec, temp)
  }
  sort.Ints(vec)
  var ret int
  if vec[0] == vec[1] {
    ret = vec[2]
  } else {
    ret = vec[0]
  }

  fmt.Println(ret)
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int i,c=0,n;
    cin>>n;
    char a[n+2];
    for(i=0; i<n; i++)
    {
        cin>>a[i];
    }
    for(i=0; i<n; i++)
    {
        if(a[i]=='A'&& a[i+1]=='B'&& a[i+2]=='C')
        {
            c++;

        }
    }
cout<<c<<endl;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main( )
{
	int i,j,k,q,n,p;
	cin>>k>>n;
	int a[n],b[n],c[n]; 
	 for(i=0;i<n;i++)
	 {
		cin>>a[i];
	 }
	 b[0]=a[n-1]-a[0];
	 for(i=1;i<n;i++)
	{
	 	b[i]=k-a[i]+a[i-1];
	} 
	  p=b[0];
	  /* for(i=0;i<n;i++)
	   {
	   		cout<<b[i]<<" ";
	   }*/
	  for(i=0;i<n;i++)
	  {
	  	if(p>b[i])
	  	{
	  		p=b[i];
		}
	  }
	  c[n-1]=a[n-1]-a[0];
	  for(i=0;i<n-1;i++)
	  {
	  	c[i]=a[i]+k-a[i+1];
	  }
	  q=c[0];
	  /* for(i=0;i<n;i++)
	   {
	   	cout<<c[i]<<" ";
	   }*/
	  for(i=0;i<n;i++)
	  {
	  	if(q>c[i])
	  	{
	  	q=c[i];
		}
	  }
	  if(p>=q)
	  {
	  	cout<<q;
	  }
	  if(q>p)
	  {
	  	cout<<p;
	  }
	  return 0;
}

Measured memory_bytes: 2560
a, b, c = gets.split.map(&:to_i)

count = 0

max = [a, b, c].max

d_1, d_2 = [max - a, max - b, max - c].max(2)

count += d_1 / 2 + d_2 / 2

if d_1 % 2 == 0 && d_2 % 2 == 0
  # do nothing
elsif d_1 % 2 == 1 && d_2 % 2 == 1
  count += 1
else
  count += 2
end

puts count


Measured memory_bytes: 1788
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
#define mod ((int)1e9+7)
#define lim 1000000000000000007
#define lim1 18446744073709551615  //Unsigned
#define sq(a) ((a)*(a))
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define mms(v,i) memset(v,i,sizeof(v))
#define pb push_back
#define pf push_front
#define ppb pop_back
#define ppf pop_front
#define REP(i,a,b) for (int i = a; i <= b; i++)
#define REPN(i,a,b) for (int i = a; i >= b; i--)
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;
typedef pair<int,int> pi;
typedef pair<ll,ll> PL;
typedef pair<ll,int> PLI;
typedef pair<int,ll> PIL;
typedef pair<int,pair<int,int> > pii;
typedef pair<double,double> pdd;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> indexed_set;
typedef tree<pi,null_type,less<pi>,rb_tree_tag,tree_order_statistics_node_update> indexed_set_pair;
ll power(ll a,ll b) {
   ll res=1;
   while(b){
      if(b%2==1) res=(res*a)%mod;
      a=(a*a)%mod;
      b>>=1;
   }
   return res;
}
ll gcdll(ll a,ll b) {
    if (b==0) return a;
    return gcdll(b,a%b);
}
int gcd(int a,int b) {
    if (b==0) return a;
    return gcd(b,a%b);
}

struct custom_hash {
    static uint64_t splitmix64(uint64_t x) {
        // http://xorshift.di.unimi.it/splitmix64.c
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }

    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};

const int N = (int)2e5+5;
const int M = (int)3e3+5;
const int Q = 102;
const int logN = 19;

const double pie = acos(-1);

void solve() {
  int d,t,s;
  cin>>d>>t>>s;
  if(t*s >= d) {
    cout << "Yes";
  }
  else {
    cout << "No";
  }
}

int main() {
    //freopen("./sort/b2.in","r",stdin);
    //freopen("output.txt","w",stdout);

    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    int T=1;
    //cin>>T;
    REP(TC,1,T) {
        //cout<<"Case #"<<TC<<": ";
        solve();
        cout<<"\n";
    }
}


Measured memory_bytes: 3644
import math
import numpy as np

n = int(input())
li = [[int(i) for i in input().split()] for _ in range(n)]
arr = np.array(li)

route = math.factorial(n)
div = route * 2 // n

tmp_index = np.arange(arr.shape[0])
xx, yy = np.meshgrid(tmp_index, tmp_index)
distances = np.linalg.norm(arr[xx]-arr[yy], axis=2)
print(np.sum(distances) / n)

Measured memory_bytes: 12440
use proconio::input;
#[allow(unused_imports)]
use proconio::marker::*;
use rand::prelude::*;
#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;
#[allow(unused_imports)]
use std::f64::consts::*;
use std::time::*;

#[allow(unused)]
const INF: usize = std::usize::MAX / 4;
#[allow(unused)]
const M: usize = 1000000007;

fn ss(n: usize) -> isize {
    (n * (n + 1) / 2) as isize
}

fn calc_score(t: &Vec<usize>, c: &Vec<isize>, s: &Vec<Vec<isize>>) -> isize {
    let n = c.len();
    let d = t.len();
    let mut last = vec![0; n];
    let mut score = 0;
    for i in 0..d {
        let ti = t[i];
        score += s[i][ti];
        last[ti] = i + 1;
        for j in 0..n {
            score -= c[j] * (i + 1 - last[j]) as isize;
        }
    }
    score
}

fn initial_guess(c: &Vec<isize>, s: &Vec<Vec<isize>>) -> Vec<usize> {
    let n = c.len();
    let d = s.len();
    let mut t = vec![0; d];
    let mut last = vec![0; n];
    for i in 0..d {
        t[i] = (0..n)
            .max_by_key(|&j| {
                s[i][j]
                    - (0..n)
                        .map(|k| c[k] * (i + 1 - last[k]) as isize)
                        .sum::<isize>()
            })
            .unwrap();
        last[t[i]] = i + 1;
    }
    t
}

fn improve(
    t: &mut Vec<usize>,
    score: isize,
    c: &Vec<isize>,
    s: &Vec<Vec<isize>>,
    di: usize,
) -> isize {
    let n = c.len();
    let d = s.len();

    let mut last = vec![0; n];
    for i in 0..di {
        last[t[i]] = i + 1;
    }
    let mut next = vec![d + 1; n];
    for i in (di + 1..d).rev() {
        next[t[i]] = i + 1;
    }

    let f =
        |j| s[di][j] - c[j] * (ss(di - last[j]) + ss(next[j] - di - 2) - ss(next[j] - last[j] - 1));
    let remove_score = f(t[di]);

    t[di] = (0..n).max_by_key(|&j| f(j)).unwrap();
    score + f(t[di]) - remove_score
}

fn main() {
    let start = SystemTime::now();
    let limit = Duration::from_millis(1950);
    let n = 26;
    input! {
        d: usize,
        c: [isize; n],
        s: [[isize; n]; d],
    }
    let mut t = initial_guess(&c, &s);
    let mut rng = thread_rng();
    let mut score = calc_score(&t, &c, &s);
    let mut best_score = score;
    let mut best_t = t.clone();
    eprintln!("{}", score);
    let mut iter = 0;
    loop {
        let prev_score = score;
        for di in 0..d {
            score = improve(&mut t, score, &c, &s, di);
        }
        if prev_score == score {
            if score > best_score {
                best_score = score;
                best_t = t.clone()
            } else {
                score = best_score;
                t = best_t.clone();
            }
            let di = rng.gen_range(0, d);
            let qi = rng.gen_range(0, n);
            t[di] = qi;
        }
        iter += 1;
        if start.elapsed().unwrap() >= limit {
            break;
        }
    }
    eprintln!("{}", iter);
    eprintln!("{}", best_score);
    for &ti in &best_t {
        println!("{}", ti + 1);
    }
}


Measured memory_bytes: 2772
#define _USE_MATH_DEFINES
#include <array>
#include <cassert>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <sstream>
#include <vector>
#include <queue>
#include <stack>
#include <list>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <complex>
#include <cmath>
#include <numeric>
#include <bitset>
#include <functional>
#include <random>
#include <ctime>

using namespace std;

#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << ": " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ',');
  cerr.write(names, comma - names) << ": " << arg1 << " |";
  __f(comma + 1, args...);
}

typedef long long int64;
typedef pair<int, int> ii;
const int INF = 1 << 29;
const int MOD = 1e9 + 7;
mt19937 mrand(random_device{}());
int rnd(int x) { return mrand() % x; }

int main() {
  char s[10];
  scanf("%s", s);
  s[0] += 1;
  puts(s);
  return 0;
}


Measured memory_bytes: 764
#include<stdio.h>

int main (void)
{
  int a,b;
  scanf("%d %d",&a,&b);

  if(a<b){
    printf("a < b\n");
  }
  if(a>b){
    printf("a > b\n");
  }
  if(a==b){
    printf("a == b\n");
  }
  return 0;
}

Measured memory_bytes: 580
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define f first
#define s second
#define mp make_pair
#define pb push_back
#define vll vector<ll>
#define endl "\n"
#define pll pair<ll,ll>
#define all(x) (x).begin() , (x).end()

using namespace std;

const ll N =(1e5+5);
const ll MOD = 998244353;
const ll INF = 1e16;
const ll LOG = 25;

 
long long binpow(long long a, long long b) {
     a %= MOD;
    long long res = 1;
    while (b > 0) {
        if (b & 1)
            res = (res * a)%MOD ;
        a = (a * a)%MOD ;
        b >>= 1;
    }
    res%=MOD;
    return res;
}
bool pali(string s){
    string t = s;reverse(all(t));
    if(s==t) return true;
    return false;
}
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(NULL);
    

    string s;
    cin >> s;
    ll n = 1ll*s.size();
    if(s[0]==s[n-1]){
        if(n%2 )
            cout<<"Second\n";
        else
            cout<<"First\n";
            }
            else{
                if(n%2)cout<<"First\n";
                else cout<<"Second\n";
            }
    return 0;   
        
}




Measured memory_bytes: 512
#include <bits/stdc++.h>
#define REP(i,n) for(ll i = 0; i < (ll)n; i++)
#define FOR(i,a,b) for (ll i=(a);i<(ll)b; i++)
#define ALL(obj) (obj).begin(),(obj).end()
#define INF 1LL << 60
using namespace std;
typedef long long ll;
typedef double db;
typedef string str;
typedef pair<ll,ll> p;
const long long MOD=1000000007;

// vector<p> cut(M);
// cut[i].second
// cut[i].first;
// REP(i,M){
//     int a,b;cin>>a>>b;
//     cut[i] = make_pair(b,a);//last first の順番
// }
// for(int i=0; i<N;i++){
// }
// sort(cut.begin(),cut.end()); //sort
// char '' str ""
int main(void)
{
    int N,M;cin>>N>>M;
    ll ans = ((N-M)*100 + M*1900) * pow(2, M);
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(void) {
	int a[3];
	int sum = 0;
	for (int i = 0; i < 3; i++) {
		scanf("%d", &a[i]);
		sum += a[i];
	}
	if (sum >= 22) {
		printf("bust\n");
	}
	else {
		printf("win\n");
	}
	return 0;
}

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

using namespace std;
using P = pair<long, long>;

typedef long long int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

#define fillInt(xs, x)        \
  for (int i = 0; i < (x); i++) \
    scanf("%d", &xs[i]);
#define fillLong(xs, x)       \
  for (int i = 0; i < (x); i++) \
    scanf("%ld", &xs[i]);
#define fillString(xs, x)       \
  for (int i = 0; i < (x); i++) \
    cin >> xs[i];
#define sortv(xs) sort(xs.begin(), xs.end())
#define sortvinv(xs) sort(xs.begin(), xs.end(), std::greater<long>())
#define lbv(xs, x) lower_bound(xs.begin(), xs.end(), x) - xs.begin()
#define ubv(xs, x) upper_bound(xs.begin(), xs.end(), x) - xs.begin()
#define bs(xs, x) binary_search(xs.begin(), xs.end(), x)
#define index_of(as, x) \
  distance(as.begin(), lower_bound(as.begin(), as.end(), x))
#define rad_to_deg(rad) (((rad)/2/M_PI)*360)
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define concat(xs, ys) (xs).insert((xs).end(), (ys).begin(), (ys).end())

const int mod = 1000000007;

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

  long n, k;
  cin >> n >> k;

  vector<long> a(n);
  vector<long> f(n);

  fillLong(a, n);
  fillLong(f, n);
  sortv(a);
  sortvinv(f);
  
  long mx = 0;
  rep(i, n) {
    mx = max(mx, a[i] * f[i]);
  }

  long ub = mx;
  long lb = 0;
  
  while (ub - lb > 1) {
    long next = (ub+lb)/2;
    long sm = 0;
    rep(i, n) {
      sm += max(0L, a[i] - next/f[i]);
    }
    if (sm <= k) {
      ub = next;
    } else {
      lb = next;
    }
  }
  long next = (ub+lb)/2;
  long sm = 0;
  rep(i, n) {
    sm += max(0L, a[i] - next/f[i]);
  }
  if (sm <= k) {
    ub = next;
  } else {
    lb = next;
  }

  cout << ub << endl;
}

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

int main() {
  int N;
  cin >> N;
  
  vector<int> light(N);
  for (int i = 0; i < N; i++) {
    cin >> light.at(i);
  }
  
  int number = 0;
  int now = light.at(0);
  
  for (int j = 0; j < N; j++) {
    if (now == 2) {
      number++;
      break;
    }
    else {
      now = light.at(now-1);
      number++;
    }
  }
 
  if (now == 2) {
    cout << number << endl;
  }
  else {
    cout << -1 << endl;
  }
}

Measured memory_bytes: 640
#include <stdio.h>

int main(void) {
	int m,n,l, i, c, k;
        int a[100][100], b[100][100];
	
	scanf("%d%d%d", &n, &m, &l);
	for(i = 0; n > i; i++){
	for(c = 0; m > c; c++){
		scanf("%d", &a[i][c]);
	}	
	}
	for(i = 0; m > i; i++){
	for(c = 0; l > c; c++){
		scanf("%d", &b[i][c]);
	}	
	}
	
	
	for(i = 0; n > i; i++){
	for(c = 0; l > c; c++){
		long long int buf = 0;
	for(k = 0; m > k; k++){
		buf += a[i][k] * b[k][c];
	}	
	printf("%lld", buf);
	if(c != l-1) printf(" ");
	}
	printf("\n");
	}
	return 0;
}

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

pub 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")
}

fn main() {
    let n: usize = read();
    let mut ans: i64 = 0;
    for _ in 0..n {
        let a: usize = read();
        let b: usize = read();
        ans += (b - a + 1) as i64;
    }
    println!("{}", ans);
}


Measured memory_bytes: 4352
#include<iostream>
#include <bits/stdc++.h>
#include<algorithm>
#include <cstring>
#define endl "\n"
#define SRK ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define EPS 1e-6
typedef long long ll;
using namespace std;


int main()
{
    SRK;
    ll n,i,j;
    cin >> n;
    ll sum = 0,x;
    vector <ll> arr;
    ll arr1[n];
    for (i = 0; i < n; i++)
    {
        cin >> x;
        arr1[i] = x;
        arr.push_back(x);
    }
    reverse(arr.begin(),arr.end());
    for (i = 1; i < n; i++)
    {
        arr[i] += arr[i-1];
    }
    for (i = n - 2,j = 0; j < n - 1; i--,j++)
    {
        sum += ((arr1[j] % (1000000000+7)) * (arr[i] % (1000000000+7)) )% (1000000000+7);
    }
    cout << sum % (1000000000+7) << endl;

}


Measured memory_bytes: 6588
fun main(args: Array<String>) {
    val (N, X) = readLine()!!.split(" ").map(String::toInt)
    val x = readLine()!!.split(" ").map(String::toInt)

    fun gcd(a: Int, b: Int): Int {
        return if (b > 0) gcd(b, a % b) else a
    }

    x.map { Math.abs(X - it) }.reduce { acc, e -> gcd(acc, e) }.let(::println)
}

Measured memory_bytes: 51800
/** e==m*pow(c,2) **/
#include <bits/stdc++.h>
using namespace std;
#define DEBUG 0
#define LL long long
#define int long long
//#define OFFLINE 2585
#define pii pair<int, int>
#define SQR(n) (n*n)
#define pb push_back
//#define endl '\n'
#define yes cout << "YES" << endl
#define no cout << "NO" << endl
#define INF 100000000000
#define PI (acos(0.0) * 2.0)
#define time_start clock_t tStart = clock()
#define time_end (double)(clock() - tStart)/CLOCKS_PER_SEC
#define maxn 100009
//#pragma GCC diagnostic warning "-std=c++11"
#define check(n, i) (int)(bool(!((n)&(1<<(i)))))
#define set(n, i) (((n)|(1<<(i))))
#define mod 100000007
 
#define dbg(a) cout << #a << " = " << a << endl;

 
void faster(void)
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
}
 
int lcm(int a, int b)
{
    return (a*b) / __gcd(a, b);
} 
 

int32_t main()
{
    #ifdef ONPC
      freopen("in.txt", "r", stdin);
      freopen("out.txt", "w", stdout);
    #endif
    faster();
	bool dp[100009];
	memset(dp, 0, sizeof(dp));
    int n, k, i, j, ara[105]; 
    cin >> n >> k;
    for(i=0;i<n;i++) cin>>ara[i];
    for(i=0;i<=k;i++)
    {
    	for(j=0;j<n;j++)
    	{
    		//cout<<i<<' '<<dp[i]<<' '<<j<<' '<<ara[j]<<endl;
    		//if(dp[i+ara[j]]==1) continue;
    		//else if(dp[i]==0) dp[i+ara[j]]=1;
    		if(i+ara[j]<=k) dp[i+ara[j]]=max((int)dp[i]^1, (int)dp[i+ara[j]]);
    	}
    }
    if(DEBUG) for(i=0;i<=k;i++) cout<<i<<' '<<dp[i]<<endl;
    cout<<(dp[k]?"First":"Second")<<endl;
    return 0;
}



Measured memory_bytes: 512
from itertools import product
import numpy as np

H, W, K = map(int, input().split())
C = np.array([list(input()) for _ in range(H)])

ans = 0
hw_bits = product([False, True], repeat=H+W)
for hw_ in hw_bits:
    h_ = list(hw_[:H])
    w_ = list(hw_[H:])
    if sum(list(h_))!=0 and sum(list(w_))!=0:
        x = np.sum(C[h_].T[w_] == '#')
        if x == K:
            ans += 1
print(ans)


Measured memory_bytes: 27300
#include<iostream>
#include<vector>
using namespace std;
int main() {
	int a, b; cin >> a >> b;
	int num = 1;
	int i = 1;
	while(num<b) {
		num += a - 1;
		if (num >= b) {
			break;
		}
		i++;
	}
	if (b == 1) {
		i = 0;
	}
	cout << i << endl;
	return 0;
}

Measured memory_bytes: 256