akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define lli long long int
#define uli unsigned long long int
#define INF 99999999999
#define rep(i,m,n) for(lli i = m;i < n;i++)
#define rrep(i,m,n) for(lli i=m;i>n;i--)
#define pb(n) push_back(n)
#define Sort(n) sort(n.begin(), n.end())
#define Rev(n) reverse(n.begin(),n.end())
#define Out(S) cout << S << endl
#define NeOut(S) cout << S
#define HpOut(S) cout << setprecision(20) << S << endl
#define Vecpr(K,L1,L2,N) vector<pair<L1,L2>> K(N)
#define Vec(K,L,N,S) vector<L> K(N,S)
#define DV(K,L,N,M,R) vector<vector<L>> K(N, vector<L>(M,R))
#define mod 1000000007
#define MAX 510000
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a)
int main(){
  lli A=INF,B=INF,C=INF,D=INF,E,F,N,M,K,sum=0,num=0,cnt=1,next=0;
  cin >> N >> K;
  if(-N<=K)A=K-(-N)+1;
  if(-N<=-K)B=(-K)-(-N)+2;
  if(N<=K)C=K-N;
  if(N<=-K)D=(-K)-N+1;
  A=min(A,B);C=min(C,D);
  Out(min(A,C));
}

Measured memory_bytes: 256
#include <stdio.h>

int main()
{
	int n;
	int case_count = 1;

	while (case_count <= 10000)
	{
		scanf("%d", &n);
		if (n == 0)
		{
			break;
		}
		else
		{
			printf("Case %d: %d\n", case_count, n);
			case_count++;
		}
	}

	return (0);
}


Measured memory_bytes: 2668
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> pll;

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N, M, Q;
    cin >> N >> M >> Q;
    vector<vector<ll>> trainLR(N + 1, vector<ll>(N + 1, 0));
    for (int i = 0; i < M; i++)
    {
        ll left, right;
        cin >> left >> right;
        trainLR.at(left).at(right)++;
    }
    vector<vector<ll>> ruisekiTrainLR(N + 1, vector<ll>(N + 1, 0)); //二次元累積
    for (int i = 1; i <= N; i++)
    {
        for (int j = 1; j <= N; j++)
        {
            ruisekiTrainLR.at(i).at(j) = ruisekiTrainLR.at(i).at(j - 1) + ruisekiTrainLR.at(i - 1).at(j) - ruisekiTrainLR.at(i - 1).at(j - 1) + trainLR.at(i).at(j);
        }
    }
    vector<pll> questions;
    for (int i = 0; i < Q; i++)
    {
        ll qLeft, qRight;
        cin >> qLeft >> qRight;
        questions.emplace_back(qLeft, qRight);
    }

    for (auto question : questions)
    {
        ll qLeft, qRight;
        tie(qLeft, qRight) = question;
        cout << ruisekiTrainLR.at(qRight).at(qRight) - ruisekiTrainLR.at(qRight).at(qLeft - 1) - ruisekiTrainLR.at(qLeft - 1).at(qRight) + ruisekiTrainLR.at(qLeft - 1).at(qLeft - 1) << "\n";
    }
    cout << endl;
    return 0;
}


Measured memory_bytes: 6640
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back
int a[200005];
void solve(){
    int k,n;
    cin>>k>>n;
    int ans = 0;
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    ans = a[n-1]-a[0];
    for(int i=1;i<n;i++){
        ans = min(ans,k-a[i]+a[i-1]);
    }
    cout<<ans<<endl;
}
int main(){
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	int t=1;
//	cin>> t;
	while(t--)solve();
	return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <algorithm>
#include <numeric>
#include <vector>
#include <map>
#include <list>
#include <queue>
#include <string>
using namespace std;
#define lli long long int
#define MAX 100000000
int main()
{
    int H, W, h, w;
    cin >> H >> W;
    cin >> h >> w;
    cout << (H - h) * (W - w) << endl;

    return 0;
}

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

using namespace std;
#define all(a)a.begin(),a.end()
using ll=long long;
const int INF = 1<<30;
const ll INFll =1LL<<62;
const int mod =(1e9)+7;
using P = pair<ll,ll>;

int main(){
    vector<string>ans;
    string s;cin >>s;
    string t;cin >>t;
    for (int i = 0; i < s.size(); ++i) {
        if(i+t.size()>s.size())break;
        bool tmp=true;
        string sub=s.substr(i,t.size());
        for (int j = 0; j < t.size(); ++j) {
            if (sub[j] != '?') {
                if (sub[j] != t[j])tmp = false;
            }
        }
        string k="";
        if(tmp){
            for (int j = 0; j < i; ++j) {
                if(s[j]=='?'){
                    k+='a';
                }
                else {
                    k += s[j];
                }
            }
            k+=t;
            for (int j = i+t.size(); j <s.size(); ++j) {
                if(j>=s.size())break;
                if(s[j]=='?'){
                    k+='a';
                }
                else {
                    k += s[j];
                }
            }
            ans.push_back(k);
        }
    }
    if(ans.empty()){
        puts("UNRESTORABLE");
    } else {
        sort(all(ans));
        cout << ans[0] << endl;
    }
    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
 
#define rep(i, n) for(int i=0; i<(n); i++)
#define FOR(i, m, n) for(int i=(m);i<(n);i++)
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define SORT(x) sort((x).begin(),(x).end())
#define RSORT(x) sort((x).rbegin(),(x).rend())
#define REVE(x) reverse((x).begin(),(x).end())
#define mp make_pair
#define pb push_back
#define chmax(x,y) x = max(x,y)

 
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<vector<int> > VVI;
typedef pair<int, int> PII;
typedef long long LL;
typedef vector<bool> VB;
typedef vector<LL> VL;
typedef vector<vector<long long>> VVLL;
typedef vector<set<int>> VSI;
const int MOD = 1e9+7;
const int INF = 1e9;
const LL LINF = 1e18;
int gcd(int a, int b)
{
   if (a%b == 0)
   {
       return(b);
   }
   else
   {
       return(gcd(b, a%b));
   }
}

int lcm(int a, int b)
{
   return a * b / gcd(a, b);
}
struct UnionFind {
    VI d;
    UnionFind(int n = 0): d(n,-1) {}
    int find(int x) {
        if(d[x] < 0) return x;
        return d[x] = find(d[x]);
    }
    bool unite(int x,int y) {
        x = find(x); y = find(y);
        if(x == y) return false;
        if(d[x] > d[y]) swap(x,y);
        d[x] += d[y];
        d[y] = x;
        return true;
    }
    bool same(int x,int y) { return find(x) == find(y); }
    int size(int x) { return -d[find(x)]; }
};
int deg[100005];
VI to[100005];

struct mint {
  LL x; // typedef long long ll;
  mint(LL x=0):x((x%MOD+MOD)%MOD){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= MOD) x -= MOD;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += MOD-a.x) >= MOD) x -= MOD;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= MOD;
    return *this;
  }
  mint operator+(const mint a) const {
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res*=a;
  }
  mint pow(LL t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }
 
  // for prime mod
  mint inv() const {
    return pow(MOD-2);
  }
  mint& operator/=(const mint a) {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const {
    mint res(*this);
    return res/=a;
  }
};

mint f(int n) {
    if(n == 0) return 1;
    mint x = f(n/2);
    x *= x;
    if(n%2 == 1) x *= 2;
    return x;
}

mint choose(int n,int a) {
    mint x = 1, y = 1;
    rep(i,a) {
        x *= n-i;
        y *= i+1;
    }
    return x/y;
}

int main() {
    LL n,k;
    cin >> n >> k;
    LL a = n % k;
    LL b = abs(a-k);
    cout << min(a,b) << endl; 
}


Measured memory_bytes: 2560
#include<bits/stdc++.h>
using namespace std;
const double pi = acos(-1);

int32_t main () {
	int n, m; cin >> n >> m;
	vector<int> arr(m, 0);
	for(int i = 0; i < m; i ++) cin >> arr[i];
	int sum = accumulate(arr.begin(), arr.end(), 0);
	if(n >= sum)
	cout << n - sum << endl;
	else
	cout << -1 << endl;
	return 0;
}

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

#define n_l '\n'
template <typename T, size_t N> int SIZE(const T (&t)[N]) { return N; } template<typename T> int SIZE(const T &t) { return t.size(); } string to_string(const string s, int x1 = 0, int x2 = 1e9) { return '"' + ((x1 < s.size()) ? s.substr(x1, x2 - x1 + 1) : "") + '"'; } string to_string(const char* s) { return to_string((string) s); } string to_string(const bool b) { return (b ? "true" : "false"); } string to_string(const char c) { return string({c}); } template<size_t N> string to_string(const bitset<N> &b, int x1 = 0, int x2 = 1e9) { string t = ""; for (int __iii__ = min(x1, SIZE(b)),  __jjj__ = min(x2, SIZE(b) - 1); __iii__ <= __jjj__; ++__iii__) { t += b[__iii__] + '0'; } return '"' + t + '"'; } template <typename A, typename... C> string to_string(const A (&v), int x1 = 0, int x2 = 1e9, C... coords); int l_v_l_v_l = 0, t_a_b_s = 0; template <typename A, typename B> string to_string(const pair<A, B> &p) { l_v_l_v_l++; string res = "(" + to_string(p.first) + ", " + to_string(p.second) + ")"; l_v_l_v_l--; return res; } template <typename A, typename... C> string to_string(const A (&v), int x1, int x2, C... coords) { int rnk = rank<A>::value; string tab(t_a_b_s, ' '); string res = ""; bool first = true; if (l_v_l_v_l == 0) res += n_l; res += tab + "["; x1 = min(x1, SIZE(v)), x2 = min(x2, SIZE(v)); auto l = begin(v); advance(l, x1); auto r = l; advance(r, (x2 - x1) + (x2 < SIZE(v))); for (auto e = l; e != r; e = next(e)) { if (!first) { res += ", "; } first = false; l_v_l_v_l++; if (e != l) { if (rnk > 1) { res += n_l; t_a_b_s = l_v_l_v_l; }; } else { t_a_b_s = 0; } res += to_string(*e, coords...); l_v_l_v_l--; } res += "]"; if (l_v_l_v_l == 0) res += n_l; return res; } void dbgm() {;} template<typename Heads, typename... Tails> void dbgm(Heads H, Tails... T) { cout << to_string(H) << " | "; dbgm(T...); }
#define dbg(...) cout << "[" << #__VA_ARGS__ << "]: "; dbgm(__VA_ARGS__); cout << endl


int32_t main() {
   ios::sync_with_stdio(false);   cin.tie(NULL);   cout.tie(NULL);

   int n, sum = 0;
   cin >> n;
   vector <int> a(n + 1);
   for (int i = 1; i <= n; i++)
      cin >> a[i];
   vector <vector <int>> dp(n + 1, vector <int> (n + 1));

   for (int i = 1; i <= n; i++) {
      dp[i][i] = a[i];
      sum += a[i];
   }
   for (int len = 2; len <= n; len++) {
      for (int i = 1; i <= n - len + 1; i++) {
         int j = i + len - 1;
         dp[i][j] = max(a[i] - dp[i + 1][j], a[j] - dp[i][j - 1]);
      }
   }

   cout << dp[1][n] << '\n';

   return 0;
}

Measured memory_bytes: 70784
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int a,b,i,j;
    cin>>a>>b;
    if(a<b)
    {
        for(i=1;i<=b;i++)
        {
            cout<<a;
        }
        cout<<endl;
    }
    else
    {
        for(i=1;i<=a;i++)
        {
            cout<<b;
        }
        cout<<endl;
    }
}


Measured memory_bytes: 3560
def main():
    n = int(input())
    A = [int(i) for i in input().split()]
    cul_sum = [0] * (n + 1)

    for i in range(1, n + 1):
        cul_sum[i] = cul_sum[i - 1] + A[i - 1]

    ans = float("inf")

    for i in range(1, n):
        ans = min(abs(cul_sum[i] - (cul_sum[n] - cul_sum[i])), ans)

    print(ans)


if __name__ == "__main__":
    main()


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

using namespace std;

#define dump(x)  cerr << #x << " = " << (x) << endl;
#define PB push_back
#define MP make_pair
#define ll long long

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();}

int main(){
    std::ios::sync_with_stdio(false);
    string s;
    cin >> s;
    if(s == "Sunny")
    {
        cout << "Cloudy" << endl;
    }else if(s == "Cloudy")
    {
        cout << "Rainy" << endl;
    }
    else
    {
        cout << "Sunny" << endl;
    }
    
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define ld long double
#define pb push_back
#define mp make_pair
#define F first
#define S second
const ll bg = 1000000007;
#define ff(i,n) for(i=0;i<n;i++)
#define vv vector<vector<ll> >
vector<vector<ll> >master [31]; 
int main() 
{
	ll t;
	t=1;
	while(t--)
	{
		ll x,i,n,d;
		cin>>x;
		ll a = 1,ans=0,c=0;
		if(x%2==0 || x%5==0)
		{
			cout<<"-1"<<endl;
			return 0;
		}
		while(1)
		{
			ans = (ans+(7*a)%x)%x;
			a = (a*10)%x;
			c++;
			if(ans==0)
			{
				cout<<c;
				return 0;
			}
		}
	}
    return 0;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
int main() {
    #ifdef DEBUG
    std::ifstream in("/home/share/inputf.in");
    std::cin.rdbuf(in.rdbuf());
    #endif
    int64_t r, d, x;
    cin >> r >> d >> x;
    for(int i = 0; i < 10; i++) {
        x = r * x - d;
        cout << x << endl;
    }
    return 0;
}

Measured memory_bytes: 256
package main

import "fmt"

func main() {

	var n int
	fmt.Scan(&n)
	n = n - n/10*10
	shouldReadHonNums := []int{2, 4, 5, 7, 9}
	shouldReadPonNums := []int{0, 1, 6, 8}
	shouldReadBonNums := []int{3}
	howReadMap := make(map[int]string)
	for _, v := range shouldReadBonNums {
		howReadMap[v] = "bon"
	}
	for _, v := range shouldReadHonNums {
		howReadMap[v] = "hon"
	}
	for _, v := range shouldReadPonNums {
		howReadMap[v] = "pon"
	}

	fmt.Println(howReadMap[n])

}


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

#define REP(i,n) for(int i=0;i<(n);i++)
#define REAP(i,a,n) for(int i=(a);i<(n);i++)
#define YES cout<<"Yes"<<endl
#define NO cout<<"No"<<endl
#define fr first
#define sc second
#define pb push_back
#define All(v) v.begin(),v.end()
typedef long long ll;

int main(){
    ios::sync_with_stdio(false);

    vector<int> a(3);
    REP(i,3)cin >> a[i];
    sort(All(a));

    int ans = a[2]-a[0];
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
using namespace std;
typedef long long int ll;
 
int main(){    
    ll N;
    string s;
    cin>>N;
    vector<ll> v(5);
    
    for(ll i=0;i<N;i++){
        cin>>s;
        if(s[0]=='M') v[0]++;
        else if(s[0]=='A') v[1]++;
        else if(s[0]=='R') v[2]++;
        else if(s[0]=='C') v[3]++;
        else if(s[0]=='H') v[4]++;
    }
  
    cout<<v[0]*(v[1]*(v[2]+v[3]+v[4])+v[2]*(v[3]+v[4])+v[3]*v[4])+v[1]*(v[2]*(v[3]+v[4])+v[3]*v[4])+v[2]*v[3]*v[4]<<endl;
    
    return 0;}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i,n) for (int i = 0; i < (n); i++)
#define RREP(i, s, n) for (int i = s; i < (n); i++)
#define ALL(a) a.begin(), a.end()
#define RALL(a) a.rbegin(), a.rend()
#define maxs(x,y) x = max(x, y)
#define mins(x,y) x = min(x, y)
using namespace std;
using ll = long long;
typedef pair<int, int> pint;
typedef pair<ll, ll> pll;
const ll MOD = 1000000007;
const ll INF = MOD * MOD;
const int inf = (1<<29);

ll a[1010];

int main() {

    ll N;
    cin >> N;
    
    ll ans = 1;

    for(ll i = 1; i <= N; i++) {
        int p = i;
        for (int j = 2; j <= N; j++) {
            while (p%j == 0) {
                p /= j;
                a[j]++;
            }
        }        
    }

    for(int i = 1; i <= N; i++) {
        ans *= a[i] + 1;
        ans %= MOD;
    }

    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <string>
#include <queue>
#include <fstream>
#include <string>
#include <math.h>
#include <set>
#include <string>
#include <bitset>
#include <fstream>
#include <stack>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef pair<ll, P> T;

#define rep(i, n) for (ll i = 0; i < (n); i++)
#define revrep(i, n) for (ll i = (n) - 1; i >= 0; i--)
#define f first
#define s second
#define pb push_back

ll mod = 1000000007;
//const ll INF = 100000000000010000;
//const ull B = 998244353;
//ll kai[3010];

//void pres(double A, ll x = 20) { printf("%.20f\n", x); }

vector<ll> dx = { 0, 1, 0, -1, 1, -1, 1, -1, 0};
vector<ll> dy = { 1, 0, -1, 0, 1, 1, -1, -1, 0};

void chmin(ll& x, ll y) {
	x = min(x, y);
}

void chmax(ll& x, ll y) {
	x = max(x, y);
}

ll pow_long(ll x, ll y) {
	ll res = 1;
	while (y > 0) {
		if (y % 2 == 1) res *= x;
		x *= x;
		y /= 2;
	}
	return res;
}

void test() {
	cout << "888888888888888888888888" << endl;
}

ll gcd(ll x, ll y) {
	if (y == 0) return x;
	return gcd(y, x % y);
}

ll pow_mod(ll x, ll k) {
	x %= mod;
	ll res = 1;
	while (k > 0) {
		if (k % 2) {
			res *= x; res %= mod;
		}
		x *= x; x %= mod;
		k /= 2;
	}
	return res;
}

ll div_mod(ll x) {
	return pow_mod(x, mod - 2);
}

//コンビネーション
const int MAXcomb = 1000010;
ll fac[MAXcomb], finv[MAXcomb], inv[MAXcomb];
//facはn!,finvは1/n!
//invは逆元
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAXcomb; 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;
	}
}
ll comb(int n, int k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * finv[k] % mod * finv[n - k] % mod;
}

ll ans, x;

void solve() {
	cin >> x;
	ans = 100;
	//cout << pow(ans, 10000) << endl;
	rep(i, 10000) {
		double u = ans * 1.01;
		ans = u;
		if (ans >= x) {
			cout << i + 1 << endl;
			break;
		}
	}
}

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll T = 1;
	//cin >> T;
	rep(i, T) solve();
}


Measured memory_bytes: 3200
#include <bits/stdc++.h>
#define int long long
using namespace std;

class RollingHash{
public:
  typedef long long ll;
  ll B, mod;  //B: ハッシュ基数
  int n;
  string s;
  vector<ll> hash;
  vector<ll> k;

  RollingHash():n(-1){};
  RollingHash(string s,ll B = 1777771,ll mod = 1e9 + 3):
    B(B),mod(mod),n(s.size()),s(s),hash(n+1),k(n+1)
  {
    for(int i=0;i<n;i++) hash[i+1] = (hash[i] * B % mod + s[i]) % mod;
    k[0] = 1;
    for(int i=1;i<=n;i++) k[i] = (k[i-1] * B) % mod;
  }

  ll get(int l,int r){ //[l, r)
    assert(0<=l && r<=n && l<=r);
    return (mod + hash[r] - hash[l] * k[r-l] % mod) % mod;
  }
  
  //hash[a]とB.hash[b]からみて何文字一致してるか。
  int count(int a, RollingHash &B, int b){
    int L = 0, R = min( n - a, B.n - b ) + 1;
    while( L + 1 < R ){
      int M = ( L + R ) / 2;
      get( a, a + M ) != B.get( b, b + M ) ? R = M : L = M;
    }
    return L;
  }
};

int N;
string T;

signed main(){
  
  cin>>N>>T;
  
  RollingHash rh(T);
  
  string rT = T;

  reverse( rT.begin(), rT.end() );
  
  RollingHash rrh(rT);
    
  int ans = N;
  
  int flg = 1;
  
  for(int i=0;i<N;i++){
    if( T[0] != T[i] ) flg = 0;
  }
  
  if( flg ){
    cout<<2<<endl;
    return 0;
  }
  
  for(int i=1;i<N;i++){
    
    int len = i + 1;
    
    int L = len + len - 2;
    
    if( L <= N ){
      
      int L1 = i + 1, R1 = i + 1 + len - 2;
      
      int L2 = N - 1 - ( i - 1 ), R2 = N - 1;// - ( i - 1 - ( len - 2 ) );
      if( rh.get( L1, R1 ) != rrh.get( L2, R2 ) ) continue;
      
      if( rh.get( 0, N - L  ) == rh.get( L, N ) ) ans = min( ans, len );
      
    }
    else{
      
      int L1 = i + 1, R1 = i + 1 + N - ( i + 1 );
      int L2 = N - 1 - ( i - 1 ), R2 = N - 1 - ( i - 1 - ( N - ( i + 1 ) ) );
      if( rh.get( L1, R1 ) != rrh.get( L2, R2 ) ) continue;
      ans = min( ans, len );
      
    }
    
  }
  
  cout<<ans<<endl;
  
  return 0;
}



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

typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef vector<pii> vii;


#define F first
#define S second

#define ERR 1e-9

#if !ONLINE_JUDGE && !EVAL
    #define dbg_var(x) cerr << #x << ": " << x << "\n";
    #define dbg_iter(x, y) cerr  << #x << ": " << print_iterable(x, y) << "\n";
#else
    #define dbg_var(x)
    #define dbg_iter(x, y)
#endif // ONLINE_JUDGE

template <typename T1, typename T2>
string print_iterable( T1 begin_iter, T2 end_iter){
    bool first = true;
    stringstream res;
    res << "[ ";
    for(; begin_iter != end_iter; ++begin_iter){
        if(!first) res << ", ";
        first = false;
        res << *begin_iter;
    }
    res << " ]";
    return res.str();
}

void aggMax(int & res, int x){ if(x > res)res = x; }
void aggMin(int & res, int x){ if(x < res)res = x; }

int II(){ int i; cin >> i; return i; }
void OI(int i){ cout << i; }

// constraints
#define MAXN 1000000

int main() {
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    ios::sync_with_stdio(false);
    cin.tie(0);

    int N = II(), M = II(), C = II();
    vi B(M);
    for(int & x : B) x = II();
    int res = 0;
    for(int i=0; i<N; i++){
        int tmp = C;
        for(int j=0; j<M; j++){
            int A = II();
            tmp += A*B[j];
        }
        if(tmp > 0) res++;
    }
    OI(res);
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>

#define INIT_CAP 10
#define INF 1000000000

#define min(a, b) (((a) < (b)) ? (a) : (b))

int di[4] = {-1, 0, 1, 0}, dj[4] = {0, 1, 0, -1};

typedef struct {int to, w;} Edge;
typedef struct {Edge *elem; int cap, size;} VecEdge;
typedef struct {int num, d;} PNumDis;

VecEdge adj[3600];
PNumDis heap[14400];
int hsize;
int d[3600];

void init(int n) {
	while (n--)
		adj[n] = (VecEdge){malloc(sizeof(Edge) * INIT_CAP), INIT_CAP, 0};
}

inline void add(int from, int to, int w) {
	if (adj[from].size == adj[from].cap) {
		adj[from].cap <<= 1;
		adj[from].elem = realloc(adj[from].elem, sizeof(Edge) * adj[from].cap);
	}
	adj[from].elem[adj[from].size++] = (Edge){to, w};
}

void freeAll(int n) {
	while (n--)
		free(adj[n].elem);
}

inline void insert(int num, int d) {
	int i;
	for (i = hsize++; i > 0 && d < heap[i - 1 >> 1].d; i = i - 1 >> 1)
		heap[i] = heap[i - 1 >> 1];
	heap[i] = (PNumDis){num, d};
}

inline int calcNextIdx(int i) {
	return i * 2 + 1 + (i * 2 + 2 < hsize && heap[i * 2 + 1].d > heap[i * 2 + 2].d);
}

inline PNumDis delete(void) {
	int i;
	int nextIdx;
	PNumDis root = heap[0], last = heap[--hsize];

	for (i = 0; i * 2 + 1 < hsize && last.d > heap[nextIdx = calcNextIdx(i)].d; i = nextIdx)
		heap[i] = heap[nextIdx];
	heap[i] = last;

	return root;
}

void dijkstra(int n, int s) {
	int i;

	for (i = 0; i < n; i++)
		d[i] = INF;

	d[s] = 0;
	insert(s, 0);
	while (hsize > 0) {
		PNumDis fromP = delete();

		if (fromP.d > d[fromP.num])
			continue;

		for (i = 0; i < adj[fromP.num].size; i++) {
			Edge e = adj[fromP.num].elem[i];
			if (fromP.d + e.w < d[e.to]) {
				d[e.to] = fromP.d + e.w;
				insert(e.to, d[e.to]);
			}
		}
	}
}

int main(void) {
	int i, j, k, l;
	int w, h;

	while (scanf("%d %d", &w, &h), w) {
		int s[30][30];
		int c[4];

		for (i = 0; i < h; i++)
			for (j = 0; j < w; j++)
				scanf("%d", s[i] + j);

		for (i = 0; i < 4; i++)
			scanf("%d", c + i);

		init(h * w * 4);
		for (i = 0; i < h; i++)
			for (j = 0; j < w; j++)
				for (k = 0; k < 4; k++)
					for (l = 0; l < 4; l++) {
						int nd = k + l & 3;
						int ni = i + di[nd], nj = j + dj[nd];
						if (ni >= 0 && ni < h && nj >= 0 && nj < w)
							add(i * w * 4 + j * 4 + k, ni * w * 4 + nj * 4 + nd, l == s[i][j] ? 0 : c[l]);
					}

		dijkstra(h * w * 4, 1);
		printf("%d\n", min(d[(h - 1) * w * 4 + (w - 1) * 4 + 1], d[(h - 1) * w * 4 + (w - 1) * 4 + 2]));
		freeAll(h * w * 4);
	}

	return 0;
}

Measured memory_bytes: 1036
import sys
input = sys.stdin.readline
sys.setrecursionlimit(1000000)

N,Q = map(int,input().split())
to = [[] for _ in range(N+1)]
ans = [0 for _ in range(N+1)]

for _ in range(N-1):
    a,b=map(int,input().split())
    to[a].append(b)
    to[b].append(a)
for _ in range(Q):
    p,x = map(int,input().split())
    ans[p] += x

def dfs(v, p):
    for u in to[v]:
        if u == p:
            continue
        ans[u] += ans[v]
        dfs(u, v)
dfs(1, -1)
print(*ans[1:])


Measured memory_bytes: 230932
S = list(input())

notX = []
for s in S:
    if not s == 'x':
        notX.append(s)

if not notX[::-1] == notX:
    print(-1)
    exit()

i = 0
Xcnt = []
cnt = 0
N = len(notX)
for s in S:
    if i < N:
        if s == notX[i]:
            i += 1
            Xcnt.append(cnt)
            cnt = 0
        else:
            cnt += 1

    else:
        cnt += 1

Xcnt.append(cnt)
before = sum(Xcnt)
Xcnt2 = []
N = len(Xcnt)
for i in range(N):
    Xcnt2.append(max(Xcnt[i],Xcnt[N-1-i]))

after = sum(Xcnt2)

print(after-before)


Measured memory_bytes: 6172
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i=0;i < (int)(n);i++)

int n[51][51];
char maze[51][51];

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

int main(){
   int h,w;
   string s;
   cin >> h >> w;
   rep(i,h) rep(j,w) cin >> maze[i][j];

   rep(i,h){ 
      rep(j,w){
      if (maze[i][j] == '#'){
         n[i][j] = -1;
         continue;
      }
      int cnt = 0;
      for(int e = 0;e < 8;e++){
         if (i+dx[e] < h && j+dy[e] < w && 0 <= i+dx[e] && 0 <= j+dy[e] && maze[i+dx[e]][j+dy[e]] == '#'){
            cnt++;
         }
      }
      n[i][j] = cnt;
      }
   }

   rep(i,h){
      rep(j,w){
         if (n[i][j] == -1) cout << "#";
         else cout << n[i][j];
      }
      cout << endl;
    }
   
   
  
   
   
   return 0;
   
}



Measured memory_bytes: 256
def main():
    n = int(input())
    a = list(map(int, input().split()))
    a_sort = sorted(a, reverse=True)
    alice = 0
    bob = 0
    for i in range(n):
        if i % 2 == 0:
            alice += a_sort[i]
        else:
            bob += a_sort[i]
    res = alice - bob
    print(res)
if __name__ == '__main__':
    main()

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

using namespace std;

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

	int n,x,t;

	cin >> n >> x >> t;

	cout << (int)(ceil((n*1.0)/x)*t) << '\n';

	return 0;
}

Measured memory_bytes: 3648
#include <bits/stdc++.h>
#define rep(i,m,n) for(int i=m; i<n; i++)
#define co(n) cout << n << endl
using namespace std;
int main(){
  int n;
  cin >> n;
  string s="Christmas", e=" Eve";
  rep(i,0,25-n) s+=e;
  co(s);
  
  return 0;
}


Measured memory_bytes: 256
/* ex 9_2
   Stuartyg */

#include <stdio.h>
#include <stdlib.h>

//リストのノード（スタック内の各データ）の定義
typedef struct node{
    char elem;
    struct node *next;
} node;
//プロトタイプ宣言
void push(node **first, char elem);
char pop(node **first);


int main(void){
    //最初のノードの指す先
    node *first = NULL;
    char cube;
    int ans = 0;
    //1文字ずつ読み込み
    while((cube = getchar()) != EOF && (cube != '\n')){
        push(&first,cube);
    
        //00，01でないから先頭とその次を削除
        if((first->next != NULL) && (first->elem != first->next->elem)){
            pop(&first);
            pop(&first);
            ans += 2;
        }
    }
    printf("%d\n",ans);
    return 0;
}

//スタックにデータを追加
void push(node **first, char elem){
    //追加する分の領域を確保
    node *new = calloc(1, sizeof(node));
    if(new == NULL) exit(1); //確保失敗
    new->elem = elem;
    new->next = *first; //先頭に追加
    *first = new;
}

//スタックからデータを取り出す
char pop(node **first){
    char elem;
    node *tmp = *first;
    if(tmp == NULL) exit(1); //空リスト
    elem = tmp->elem;
    *first = tmp->next; //2個目を先頭に
    //取り出したノードのメモリを解放
    free(tmp);
    return elem;
}



Measured memory_bytes: 4652
#include <bits/stdc++.h>
//#include <atcoder/all>
using namespace std;
#define rep(i,n) for(int i=0; i<n; i++)
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define fi first
#define se second
long long mo = 1000000007;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
typedef pair<ll,Pll> PlP;
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
template<class A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}cout << "\n";}
ld PI=3.14159265358979323846;
//using namespace atcoder;

struct UnionFind {
    vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2
    vector<int> size;
    UnionFind(int N): par(N),size(N) {

         //最初は全てが根であるとして初期化
        for(int i = 0; i < N; i++){
            par[i] = i;
            size[i] = -1;
        }
            
    }
    int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }

    void unite(int x, int y) { // xとyの木を併合
        int rx = root(x); //xの根をrx
        int ry = root(y); //yの根をry
        if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
        par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
        size[ry] += size[rx];
    }

    bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
    int getsize(int x){
        return -size[root(x)];
    }
    int getNunion(){//これちょっと遅い sameと組み合わせて順次数えていけば早くなりそう。
        map<int,int> m;
        rep(i,par.size()){
            m[this->root(i)]++;
        }
        return int(m.size());
    }
};

int main(){
    ll N;
    cin >> N;
    vector<ll> x(N), y(N), id(N);
    vector<Pll> p(N);
    rep(i,N){
        cin >> x[i] >> y[i];
        p[i] = {x[i],y[i]};
        id[i] = x[i]-1;
    }
    sort(p.begin(), p.end());
    UnionFind tr(N);
    set<Pll> my;
    /*Pll my = p[0];
    rep(i,N){
        ll yy = p[i].se;
        if(my.fi < yy){
            tr.unite(my.se,i);
        }
        cmin(my,Pll(yy,i));
    }*/
    rep(i,N){
        //ll xx = p[i].fi;
        ll yy = p[i].se;
        bool flag = 0;
        //Pll abc = *my.begin();
        for(auto& pp:my){
            if(pp.fi < yy){
                tr.unite(i,pp.se);
                //my.erase(pp);
                flag = 1;
                //break;
            }else{
                break;
            }
        }
        //my.insert(abc);
        if(!flag){
            my.insert({yy,i});
        }else{
            Pll tmp = *my.begin();
            for(auto& e:my){
                if(e.fi < yy){
                    my.erase(e);
                }else{
                    break;
                }
            }
            //auto itr = lower_bound(my.begin(),my.end(),Pll(yy,-1));
            //my.erase(my.begin(), itr);
            my.insert(tmp);
        }
    }
    rep(i,N){
        cout << tr.getsize(id[i]) << endl;
    }
}

Measured memory_bytes: 18820
typedef long long ll;
typedef long double ld;
#include <bits/stdc++.h>
using namespace std;

int main() { 
    ll n;
    std::cin >> n;
    ll ans = 0;
    for (ll i = 1; i <= n; i++) {
        ll e = n/i;
        ans += i*(e*(e+1)/2);
    }
    std::cout << ans << std::endl;
}

Measured memory_bytes: 3632
#include <stdio.h>

int main()
{
  int num, flag;
  
  num = flag = 0;
  
  while(num<100 || num > 999)
    scanf("%d", &num);
  
  if(num>=700)
  {
    num-=700;
    if(num<100)
      flag=1;
  }
  
  while(num>=100)
    num-=100;
  
  if(flag!=1)
  {
    if (num>=70)
    {
      num-=70;
      if (num<10)
        flag=1;
    }
    
    while(num>=10)
      num-=10;
    
    if (flag!=1)
    {
      if (num==7)
        flag=1;
    }
  }
  
  if (flag==1)
    printf("Yes \n");
  else
    printf("No \n");
  
  return 0;
}


Measured memory_bytes: 1616
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
public class MainClass
{
	public const long Giri = 1000000007;
	public const long DpInf = 99999999999999;
	
	public static void Main(string[] args)
	{
		var p = Input().ToInt();
		var h = p[0]; 
		var w = p[1]; 
		for(int i = 0; i < w+2; i++)
			Console.Write("#");
		Console.WriteLine();
			
		for(int i = 0; i < h; i++)
		{
			var s = Console.ReadLine();
			Console.WriteLine("#{0}#", s);
		}
		for(int i = 0; i < w+2; i++)
			Console.Write("#");
		
		Console.WriteLine();

	}

	
	static long GCD(long a, long b)
	{
		var v = new[] { a, b };
		while (v[1] != 0) { v = new[] { v[1], v[0] % v[1] }; }
		return v[0];
	}
	public static string[] Input() { return Console.ReadLine().Split(); }
}

public static class Smarter
{
	public static int ToInt(this string str) { return int.Parse(str); }
	public static long ToLong(this string str) { return long.Parse(str); }
	public static int[] ToInt(this string[] str, int offset = 0)
	{
		var r = new int[str.Length];
		for(int i = 0; i < str.Length; i++) r[i] = str[i].ToInt() + offset;
		return r;
	}
}

Measured memory_bytes: 27368
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define mp make_pair
#define pb push_back
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)


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

  int H,W,h,w;
  cin >> H >> W >> h >> w;
  int ele=1e3;
  if(H%h==0 && W%w==0){
    cout << "No" << endl;
    return 0;
  }
  cout << "Yes" << endl;
  rep(i,H){
    rep(j,W){
      if(i%h==h-1 && j%w==w-1){
	cout << -(ele*(h*w-1)+1) << " ";
      }
      else {
	cout << ele << " ";
      }
    }
    cout << "" << endl;
  }






    
  return 0;
    

}


Measured memory_bytes: 1664
import sys
read = sys.stdin.buffer.read
input = sys.stdin.readline
input = sys.stdin.buffer.readline


#sys.setrecursionlimit(10**9)
#from functools import lru_cache

def RD(): return sys.stdin.read()
def II(): return int(input())
def MI(): return map(int,input().split())
def MF(): return map(float,input().split())
def LI(): return list(map(int,input().split()))
def LF(): return list(map(float,input().split()))
def TI(): return tuple(map(int,input().split()))
# rstrip().decode('utf-8')


def main():
	n=II()
	A=LI()
	A.sort()
	A.append(10**7)
	li=[0]*(10**6+10)

	ans=0
	f=0
	for k in range(n):
		i=A[k]
		if i==A[k+1]:
			f=1
			continue
		if li[i]==0:
			if f==0:
				ans+=1
			j=1
			while i*j<10**6+5:
				li[i*j]=1
				j+=1
		f=0

	print(ans)
















if __name__ == "__main__":
	main()


Measured memory_bytes: 95428
n = gets.to_i
x,y,t = 0,0,0
flag = true
n.times do
  ti,xi,yi = gets.split.map(&:to_i)
  d = (xi-x).abs + (yi-y).abs
  flag = false unless (ti-t) >= d && (ti-t) % 2 == d % 2
  x,y,t = xi,yi,ti
end
puts flag ? "Yes" : "No"


Measured memory_bytes: 1788
#include <bits/stdc++.h>
#define endl '\n';

typedef long long ll;

using namespace std;

const string YES = "";
const string NO  = "";

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

    int H, W;
    int h, w;

    cin >> H >> W;
    cin >> h >> w;

    cout << (H - h) * (W - w) << endl;

    return 0;
}



Measured memory_bytes: 256
#include <iostream>

long a[101][101];
long b[101][101];
long c[101][101];
using namespace std;
int main(){
	int n,m,l; cin >> n >> m >> l ;
	for(int i=0;i<n;++i) for(int j=0;j<m;++j) cin >> a[i][j];
	for(int j=0;j<m;++j) for(int k=0;k<l;++k) cin >> b[j][k];
	for(int i=0;i<n;++i){
		for(int j=0;j<l;++j){
			long sum=0;
			for(int k=0;k<m;++k) sum+=a[i][k]*b[k][j];
			c[i][j]=sum;
		}
	}
	for(int i=0;i<n;++i){
		for(int j=0;j<l;++j){
			if(j!=0) cout << ' ' ;
			cout << c[i][j];
		}
		cout << '\n' ;
	}
}

Measured memory_bytes: 1400
x = int(input())
if x < 600:
    print(8)
elif x < 800:
    print(7)
elif x < 1000:
    print(6)
elif x < 1200:
    print(5)
elif x < 1400:
    print(4)
elif x < 1600:
    print(3)
elif x < 1800:
    print(2)
else:
    print(1)

Measured memory_bytes: 9196
#include<iostream>
#include<queue>
using namespace std;
#define P pair<int,int>
int a[100010]={1,1};
int like[100010];

int main(void){

  for(int i=2;i*i<100000;i++){
    if(!a[i])
      for(int j=2;i*j<=100000;j++)
        a[i*j]=1;
  }
  for(int i=1;i<=100000;i++){
    like[i]+=like[i-1]+(!a[i]&&!a[(i+1)/2]);
  }

  int n;
  queue<P> q;

  cin>>n;
  for(int i=0;i<n;i++){
    int l,r;
    cin>>l>>r;
    P p(l,r);
    q.push(p);
  }
  queue<int> ans;
  while(!q.empty()){
    P p = q.front();
    q.pop();
    ans.push(like[p.second]-like[p.first-1]);
  }

  while(!ans.empty()){
    cout<<ans.front()<<endl;
    ans.pop();
  }

  return 0;
}



Measured memory_bytes: 2304
using System;

namespace B___Maximum_Difference
{
    class Program
    {
        static void Main(string[] args)
        {
            var n =int.Parse( Console.ReadLine());
            var input = Console.ReadLine().Split(' ');
            var a = new int[n];
            var b = 0;
            for (var i = 0; i < n; i++)
            {
                a[i] = int.Parse(input[i]);
            }
            for(var i=0; i<n-1; i++)
            {
                for(var j=1; j<n; j++)
                {
                   if(b< Math.Abs(a[i]-a[j]))
                    {
                        b = Math.Abs(a[i] -a[j]);
                    }
                }
            }
            Console.WriteLine(b);
           
        }
    }
}

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

int maxHappiness(int n,int** arr)
{
    int dp[n][3];
    dp[0][0] = arr[0][0];
    dp[0][1] = arr[0][1];
    dp[0][2] = arr[0][2];
    for(int i=1;i<n;i++){
        dp[i][0] = arr[i][0] + max(dp[i-1][1],dp[i-1][2]);
        dp[i][1] = arr[i][1] + max(dp[i-1][0],dp[i-1][2]);
        dp[i][2] = arr[i][2] + max(dp[i-1][0],dp[i-1][1]);
    }
    int ans = max(dp[n-1][0],max(dp[n-1][1],dp[n-1][2]));
    return ans;
}

int main() 
{
    int n;
    cin>>n;
    int** arr = new int*[n];
    for(int i=0;i<n;i++){
        arr[i] = new int[3];
        for(int j=0;j<3;j++)
        {
            cin>>arr[i][j];
        }
    }
    cout<<maxHappiness(n,arr);
    return 0;
}


Measured memory_bytes: 5376
class UnionFind:
    def __init__(self, n=1):
        self.parent = [i for i in range(n)]
        self.rank = [0] * n
    
    def find(self, x):
        if self.parent[x] == x:
            return x
        else:
            self.parent[x] = self.find(self.parent[x])
            return self.parent[x]
    
    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if x != y:
            if self.rank[x] < self.rank[y]:
                x, y = y, x
            if self.rank[x] == self.rank[y]:
                self.rank[x] += 1
            self.parent[y] = x
    
    def is_same(self, x, y):
        return self.find(x) == self.find(y)


N, Q = map(int, input().split())
uf = UnionFind(N+1)
ans = []
for _ in range(Q):
    t, u, v = map(int, input().split())
    if t:
        ans.append(int(uf.is_same(u, v)))
    else:
        uf.union(u, v)

print(*ans, sep='\n')

Measured memory_bytes: 19584
def main():
    w, a, b = map(int, input().split())

    if a <= b <= a + w or a <= b + w <= a + w:
        print(0)
    elif b <= a <= b + w or b <= a + w <= b + w:
        print(0)
    else:
        print(min(abs(a + w - b), abs(b + w - a)))


if __name__ == "__main__":
    main()


Measured memory_bytes: 79812
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;

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

class Sol{
	public void Solve(){
		
		var ST = new SegTreeMin((int)2e5 + 10);
		ST.Update(N, 0);
		for(int i=N-1;i>=0;i--){
			if(S[i] == '1') continue;
			var v = ST.QueryMin(i, i + M + 1);
			if(v != ST.Inf){
				ST.Update(i, v + 1);
			}
		}
		
		long[] dp = new long[N + 1];
		for(int i=0;i<N;i++) dp[i] = ST.At(i);
		if(dp[0] == ST.Inf){
			Console.WriteLine(-1);
			return;
		}
		//Console.WriteLine(String.Join(" ",dp));
		
		List<int> L = new List<int>();
		long cnt = dp[0];
		int last = 0;
		for(int i=1;i<=N;i++){
			if(cnt - 1 == dp[i]){
				L.Add(i - last);
				cnt--;
				last = i;
			}
		}
		Console.WriteLine(String.Join(" ",L));
		
		
		
		
	}
	
	int N,M;
	String S;
	public Sol(){
		var d = ria();
		N = d[0]; M = d[1];
		S = rs();
	}

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


class SegTreeMin{
	//segment Tree 
	// 0-origin
	protected long[] Data;	
	public long Inf;	
	protected int N;		
	protected int n;		
	
	public SegTreeMin(int n_){
		N = n_; Inf = (long)1e18;
		n = 1;
		while(n < n_) n *= 2;
		Data = new long[2 * n - 1];
		for(int i=0; i < 2 * n - 1; i++) Data[i] = Inf;
	}
	
	//	   0
	//	 1   2
	//	3 4 5 6
	public void Update(int k,long a){
		k+=n-1;	
		Data[k]=a;
		while(k>0){
			k=(k-1)/2;
			Data[k]=Math.Min(Data[k*2+1],Data[k*2+2]);
		}
	}
	
	public void SetInf(int k){
		Update(k, Inf);
	}
	public long At(int k){
		return Data[k + n - 1];
	}
	
	public long QueryMin(int a, int b){
		return Query(a, b, 0, 0, n);
	}
	//RMQ; [a,b)
	public long Query(int a,int b,int k,int l,int r){
		if(r <= a || b <= l) return Inf;
		if(a <= l && r <= b) return Data[k];
		
		var vl = Query(a, b, k * 2 + 1, l, (l + r) / 2);
		var vr = Query(a ,b, k * 2 + 2, (l + r) / 2, r);
		return Math.Min(vl, vr);
	}
	
	
	public long Min{
		get{ return Data[0];}
	}
	
	
	public void Dump(){
		Console.WriteLine();
		int h = 0;
		int cnt = 0;
		for(int i=0;i<Data.Length;i++){
			Console.Write("{0} ", Data[i]);
			cnt++;
			if(cnt == 1 << h){
				cnt = 0;
				h++;
				Console.WriteLine();
			}
		}
	}
	
}


Measured memory_bytes: 20704
#include <iostream>
#include<sstream>
#include<string>
#include<vector>
#include <cmath>
#include <limits>
#include <queue>
#include<algorithm>
#include<cstring>
#include <cstdlib>
#include <cstdio>
#include <set>
#include <iomanip>
#include <map>
#include <stack>
#include <memory>
#include <numeric>
#include <type_traits>
 
using namespace std;
 
#define rep(i,n) for (int (i)=0;(i)<(n);i++)
typedef long long ll;

 
int main() {
    int n; ll h;
    cin >> n >> h;
    vector<ll> a(n), b(n);
    rep(i,n){
        cin >> a[i] >> b[i];
    }
    sort(a.begin(), a.end(), greater<ll>()); sort(b.begin(), b.end(), greater<ll>() );
    
    ll bmax = 1e9;
    ll count = 0;
    int j = 0;
    while(a[0] <= bmax){
        bmax = b[j];
        if (a[0] <= bmax){
            h -= bmax; ++count;
        }
        if (h <= 0) break;
        ++j;
    }
    if (h <= 0) count = count;
    else if (h%a[0] == 0) {
        count += h/a[0];
    }
    else{
        count += h/a[0]+1;
    }

    cout << count << endl;

    return 0;
}

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

int main(){
  int h,w; cin>>h>>w;
  vector<string> a(h);
  for (int i=0; i<h; i++) cin>>a[i];
  
  vector<bool> row(h,false);
  vector<bool> col(h,false);
  
  for (int i; i<h; i++){
    for (int j=0; j<w; j++){
      if (a[i][j]=='#'){
        row[i]=true;
        col[j]=true;
      }
    }
  }
  
  for (int i; i<h; i++){
    int check=0;
    for (int j=0; j<w; j++){
      if (row[i]==true && col[j]==true){
        check=1;
        cout<<a[i][j];
      }
    }
    if (check==1) cout<<endl;
  }
}

Measured memory_bytes: 256
import sys
mod=10**9+7
x,y=map(int,input().split())

a=(-x+2*y)//3
b=(2*x-y)//3

if a<0 or b<0:
  print(0)
  sys.exit()
  
f=[1]
for i in range(1,a+b+1):
    f.append(f[-1]*i%mod)

if a+2*b==x and 2*a+b==y:
    print(f[a+b]*pow(f[a],mod-2,mod)*pow(f[b],mod-2,mod)%mod)
else:
    print(0)

Measured memory_bytes: 29484
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        d: usize,
        g: i32,
        v: [(i32, i32); d],
    }
    let mut ans = i32::max_value();
    for bit in 0..(1 << d) {
        // println!("{:?}", bit);
        let mut sum = 0;
        let mut num = 0;
        let mut rest_max = usize::max_value();
        for i in 0..d {
            if bit & 1 << i != 0 {
                sum += 100 * (i as i32 + 1) * v[i].0 + v[i].1;
                num += v[i].0;
            // print!("{} ", 1);
            } else {
                // print!("{} ", 0);
                rest_max = i;
            }
        }
        if sum < g {
            let s1 = 100 * (rest_max + 1) as i32;
            let need = (g - sum + s1 - 1) / s1;
            // println!("need = {}", need);
            if need >= v[rest_max].0 {
                continue;
            }
            num += need;
        }
        // println!("end sum = {}, num = {}, rest_max = {}", sum, num, rest_max);
        ans = std::cmp::min(ans, num);
    }
    println!("{}", ans);
}

Measured memory_bytes: 4352
import qualified Data.Vector.Unboxed as VU
import qualified Data.ByteString.Char8 as B
import qualified Data.Map as MP
import Data.Char

step m x =
    case MP.lookup x m of
        Just _ -> MP.adjust (+1) x m
        Nothing -> MP.insert x 1 m

step' acc k v
    | k == v = acc
    | k > v = acc + v
    | otherwise = acc + (v - k)

main = do
    n <- readLn :: IO Int
    as <- VU.unfoldrN n (B.readInt . B.dropWhile isSpace) <$> B.getLine
    print $ MP.foldlWithKey step' 0 $ VU.foldl' step MP.empty as


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

#pragma GCC optimize("O2,no-stack-protector,unroll-loops,fast-math")

#define F first
#define S second
#define pb push_back
#define SZ(x) (ll)(x.size())
#define all(x) x.begin(),x.end()
#define MP make_pair

typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> pll;

//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

const ll maxn=2e3+10, maxm=5e4+10, lg=21, mod=1e9+7, inf=1e18;

ll n,k,dp[maxn][maxn],fac[maxn*maxn],inv[maxn*maxn];
ll pwm(ll a,ll b){
	if(b==0) return 1;
	if(b%2) return a*pwm(a,b-1)%mod;
	ll ret=pwm(a,b/2);
	return ret*ret%mod;
}
ll C(ll n,ll r){return fac[n]*inv[r]%mod*inv[n-r]%mod;}
void add(ll &x,ll y){x+=y;if(x>=mod)x-=mod;}

int main(){
	ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
	
	cin>>n>>k;
	if(k==1) return cout<<1,0;
	fac[0]=inv[0]=1; for(int i=1;i<maxn*maxn;i++) fac[i]=fac[i-1]*i%mod, inv[i]=pwm(fac[i],mod-2);
	dp[0][0]=1;
	for(int i=0;i<=n;i++)for(int j=0;j<=i;j++){
		add(dp[i+1][j],dp[i][j]);
		if(j<i) add(dp[i][j+1],dp[i][j]*C(n*k-i-j*(k-1)-1,k-2)%mod);
	}
	cout<<dp[n][n]*fac[n]%mod;
	
	return 0;
}






Measured memory_bytes: 89320
s = input()

ch = 1

for i in range(len(s)):
    if(s[i]=='R'):
        if(i%2!=0):
            ch = 0
    elif(s[i]=='L'):
        if(i%2==0):
            ch = 0
            
if(ch==0):
    print('No')
else:
    print('Yes')

Measured memory_bytes: 38384