akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <bitset>
#include <map>
#include <tuple>
#include <unordered_map>
#include <list>
#include <numeric>
#include <utility>
#include <iterator>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <ctime>
#include <cassert>
#include <random>
#define INF 1000000000
#define LINF 9000000000000000000
#define mod  1000000007

#define rep(i,n) for(int i=0;i<int(n);i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define REP(i,a,b) for(int i=(a);i<int(b);i++)
#define all(x) (x).begin(),x.end()
#define pb push_back
#define mp make_pair

using namespace std;

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

int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
int ddx[8]={-1,-1,0,1,1,1,0,-1};
int ddy[8]={0,1,1,1,0,-1,-1,-1};
bool debug=false;

/*---------------------------------------------------*/

int main(){
  int A, B;
  cin >> A >> B;
  cout << A*B/2<<endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int MAXN=100005;
char s[MAXN];
int main(){
	scanf("%s",s);
	int len=strlen(s);
	int a=-1,b=-1;
	for(int i=1;i<len;i++){
		if(s[i]==s[i-1]){
			a=i-1,b=i;
			break;
		}
	}
	if(a==-1){
		for(int i=2;i<len;i++){
			if(s[i]==s[i-2]){
				a=i-2,b=i;
				break;
			}
		}
	}
	if(a==-1){
		printf("-1 -1\n");
	}
	else{
		printf("%d %d\n",a+1,b+1);
	}
	return 0;
}//

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

int main(){
  int d;
  cin>>d;
  if(d==22){
    cout<<"Christmas Eve Eve Eve"<<endl;
  }else if(d==23){
    cout<<"Christmas Eve Eve"<<endl;
  }else if(d==24){
    cout<<"Christmas Eve"<<endl;
  }else{
    cout<<"Christmas"<<endl;
  }
}

Measured memory_bytes: 764
#include <iostream>
using namespace std;
int main(void){
    int n,k,x,y,d,r1,r2;
    cin >> n >> k >> x >> y;
    if(n>=10001||k>=10001||y>x||x>=10001){
        exit(0);
    }
    if(n<k){
        cout<<n*x;
        exit(0);
    }
    d=n-k;
    r1=k*x;
    r2=d*y;
    cout << r1+r2;
    return 0;
}


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

using namespace std;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(),v.end()
#define _GLIBCXX_DEBUG
#define fi first
#define se second

using ll = long long;
using vi = vector<int>;
using vll = vector<ll>;
using vd = vector<double>;
using vvi = vector<vi>;
using vvll = vector<vll>;
using vvd = vector<vd>;
using vvvi = vector<vvi>;
using vvvll = vector<vvll>;
using vvvd = vector<vvd>;

const double pi=acos(-1);
const ll MOD=1e9+7;
const ll INF=(1LL<<60);

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



    return 0;
}

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

int a[1010], vis[1000010];
long long sum[1010];
long long all[1000010];

int main()
{
	int n, k;
	scanf("%d%d", &n, &k);
	for(int i=1;i<=n;i++)
	{
		scanf("%d", &a[i]);
		sum[i]=sum[i-1]+ a[i];
	}
	int tot=0;
	for(int i=1;i<=n;i++)
		for(int j=i;j<=n;j++)
			all[tot++]=sum[j]-sum[i-1];
	long long ans=0;
	for(int p=40;p>=0;p--)
	{
		int cnt=0;
		for(int i=0;i<tot;i++)
		{
			if (vis[i]) continue;
			cnt+=all[i]>>p & 1;
		}
		if(cnt<k) 
			continue;
		ans |=1ll<<p;
		for(int i=0;i<tot;i++)
			if(!(all[i]>>p & 1)) 
				vis[i]=1;
	}
	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 8448
#include <stdio.h>
#include <math.h>

int main(void){
    int ans=-1,i,K,a[1000001];

    scanf("%d",&K);

    a[1]=7%K;
    for(i=2;i<=K;i++){
        a[i] = (a[i-1]*10 + 7) % K;
    }

    for(i=1;i<=K;i++){
        if(a[i]==0){
            ans = i;
            break;
        }
    }

    printf("%d\n",ans);

    return 0;
}

Measured memory_bytes: 5596
#include <iostream>
#include <vector>
#include <climits>
#include <algorithm>
#include <queue>
#include <cmath>
#define F first
#define S second
#define PB push_back
#define MP(x, y) make_pair(x, y)
#define FOR(i, a, b) for (int i = a; i <= b; i++)
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> pi;
template <typename T>
T max(T x, T y)
{
    return (x > y) ? x : y;
}
template <typename T>
T min(T x, T y)
{
    return (x < y) ? x : y;
}
const int M = 1e9 + 7;
void solve()
{
    int N, X, T;
    cin >> N >> X >> T;
    int ans = 0;
    while(N >= X)
    {
        ans += 1;
        N -= X;
    }
    if(N < X && N != 0)
        ans += 1;
    cout << ans * T << endl;
}
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    solve();
    return 0;
}

Measured memory_bytes: 3640
#include<stdio.h>
bool ck[110];
int main()
{
int a,b,c,ans=0;
scanf("%d%d%d",&a,&b,&c);

ck[a]=1;ck[b]=1;ck[c]=1;
for(int i=1;i<=110;i++)ans+=ck[i];
printf("%d",ans);
}

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

int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	string s;
    cin >> s;
  	int idx = 0;
  	//白から始まるパターン
    //黒から始まるパターンと比較して差が小さな方にすればよい
  	int start_black = 0;//偶数は黒　奇数は白
  	int start_white = 0;//偶数は白　奇数は黒
  	while(idx != s.length())
    {
      if(idx % 2 == 0)//偶数
      {
        if(s[idx] == '0')//黒
        {
          start_white++;
        }else//白
        {
          start_black++;
        }
      }else//奇数
      {
        if(s[idx] == '0')//黒
        {
          start_black++;
        }else
        {
          start_white++;
        }
      }
          
      idx++;
    }
  	if(start_black > start_white) cout << start_white << endl;
  	else cout << start_black << endl;
  	return 0;
}

Measured memory_bytes: 512
def main():
    n = int(input())
    a_list = list(map(int, input().split()))

    current = a_list[0]
    answer = 0
    for a in a_list:
        if a < current:
            answer += current - a
        current = max(a, current)
    print(answer)


if __name__ == '__main__':
    main()


Measured memory_bytes: 32212
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;

typedef long long ll;
typedef pair<int,int> ii;
typedef tree<ii,null_type,less<ii>,rb_tree_tag,tree_order_statistics_node_update> indexed_set;

int main() {
	cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);
	int x,a; cin>>x>>a;
	if (a>x) cout<<"0";
	else cout<<"10"<<endl;
	return 0;
}


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

using namespace std;
using ll = long long;
using indx = size_t;
#define endl '\n'

ll f(ll a, ll b) {
    return pow(a, 5) - pow(b, 5);
}

int main() {
    ll x;
    cin >> x;
    int a, b;
    bool flag = false;
    for (a = -118; a < 120; a++) {
        if (flag) break;
        for (b = -119; b < 119; b++) {
            if (f(a, b) == x) {
                cout << a << " " << b << endl;
                flag = true;
                break;
            }
        }
    }
}


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

using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define ll long long int
#define INF 1000000007
// cin.eof() 入力個数の問題
int main(){
int v, e, r;
    cin >> v >> e >> r;
    vector<pair<pair<int,int>,int>> G;
    rep(i, e) {
        int a, b, c;
        cin >> a >> b >> c;
        G.push_back(make_pair(make_pair(a,b),c));
    }
    vector<int> ans;
    rep(i, v) {
        ans.push_back(INF);
    }
    ans[r]=0;

    int count=0;
    rep(i,v){
      rep(k,e){
        int u=G[k].first.first,V=G[k].first.second,cost=G[k].second;
        //cout<<"u=="<<u<<" v=="<<V<<" cost=="<<cost<<" i=="<<i<<endl;
        //cout<<"ans[u]+cost=="<<ans[u]+cost<<" ans[V]=="<<ans[V]<<endl;
        if(ans[u]+cost<ans[V]&&ans[u]!=INF){
          //cout<<"change"<<endl;
          ans[V]=ans[u]+cost;
          if(i==v-1){
            cout<<"NEGATIVE CYCLE"<<endl;
            return 0;
          }
        }
      }
    }
    
rep(i,v){
  if(ans[i]==INF){
    cout<<"INF"<<endl;
  }else
  {
    cout<<ans[i]<<endl;
  }
  
}

  return 0;
}



Measured memory_bytes: 3212
#include "bits/stdc++.h"

#pragma warning(disable:4996)
using namespace std;
using ld = long double;

int S=203;

vector<pair<int,int>> dfs(const vector<vector<int>>&field, vector<vector<int>>&used, int y, int x) {
	if(used[y][x])return vector<pair<int,int>>(0);
	else {
		vector<pair<int,int>>anss(1,make_pair(x,y));
		used[y][x]=true;
		int dx[] = { -1,0,1,0 };
		int dy[] = { 0,1,0,-1 };

		for (int way = 0; way < 4; ++way) {
			int nexty=y+dy[way];
			int nextx=x+dx[way];

			if (field[nexty][nextx]) {
				auto p=dfs(field,used,nexty,nextx);
				anss.insert(anss.end(),p.begin(),p.end());
			}
		}
		return anss;
	}
}

char check(vector<pair<int, int>>v) {
	int sz=v.size();
	int xsum=0;
	int ysum=0;
	sort(v.begin(),v.end());
	for (auto p : v) {
		xsum+=p.first;
		ysum+=p.second;
	}
	if (sz == 1) {
		return '*';
	}
	else if (sz == 3) {
		return '-';
	}
	else if (sz == 5) {
		if(xsum==0)return '1';
		else return '+';
	}
	else if (sz == 7) {
		return '7';
	}
	else if (sz == 9) {
		return '4';
	}
	else if (sz == 11) {
		if (xsum == 13) {
			return '3';
		}else {
			assert(xsum==11);
			auto it=find(v.begin(),v.end(),make_pair(0,1));
			if(it==v.end())return '2';
			else return '5';
		}

	}
	else if (sz == 12) {
		if (xsum == 11)return '6';
		if (xsum == 12)return '0';
		{
			assert(xsum == 13);
			return '9';
		}
	}
	else {
		assert(xsum==13);
		return '8';
	}

}

string st;
int a=0;

int num() {
	assert(isdigit(st[a]));
	int num=0;
	while (st.size() != a&&isdigit(st[a])) {
		num*=10;
		num+=st[a]-'0';
		a++;
	}
	return num;
}
int mul() {
	int k=num();
	while (st.size() != a&&st[a] == '*') {
		a++;
		int x=num();
		k*=x;
	}
	return k;
}

int calc() {
	int k=mul();
	while (st.size() != a&&(st[a] == '+'||st[a]=='-')) {
		char ch = st[a];
		a++;
		
		int x=mul();
		if(ch=='-')k-=x;
		else {
			assert(ch=='+');
			k+=x;
		}
		
	}
	return k;
}
int main() {
	int N;cin>>N;
	vector<int>v(N);
	for(int i=0;i<N;++i)cin>>v[i];
	sort(v.begin(),v.end());

	int ans=0;
	if(N==1)ans=v[0];
	else if(N==2)ans=v[1];
	else if(N==3)ans=v[0]+v[1]+v[2];
	else {
		ans=accumulate(v.begin(),v.end(),0);
		ans+=v[0]*(v.size()-3);
		for (int k = N - 2; k >= 2; k -= 2) {
			if (v[0] + v[k] > v[1] * 2) {
				ans-=v[0]+v[k];
				ans+=v[1]+v[1];
			}
		}
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 3228
import std.stdio, std.string, std.conv, std.range;
import std.algorithm, std.array, std.typecons, std.container;
import std.math, std.numeric, std.random, core.bitop;

enum inf = 1_001_001_001;
enum infl = 1_001_001_001_001_001_001L;


void main() {
    long N;
    scan(N);
    auto a = iota(5).map!(i => readln.chomp.to!long).array;
    auto am = a.reduce!min;
    auto ans = (N + am - 1) / am + 4;
    writeln(ans);
}



void scan(T...)(ref T args) {
    auto line = readln.split;
    foreach (ref arg; args) {
        arg = line.front.to!(typeof(arg));
        line.popFront;
    }
    assert(line.empty);
}

void fillAll(R, T)(ref R arr, T value) {
    static if (is(typeof(arr[] = value))) {
        arr[] = value;
    }
    else {
        foreach (ref e; arr) {
            fillAll(e, value);
        }
    }
}

bool chmin(T, U...)(ref T x, U args) {
    bool isChanged;
    foreach (arg; args) if (x > arg) {
        x = arg;
        isChanged = true;
    }
    return isChanged;
}

bool chmax(T, U...)(ref T x, U args) {
    bool isChanged;
    foreach (arg; args) if (x < arg) {
        x = arg;
        isChanged = true;
    }
    return isChanged;
}

void yes(bool ok, string y = "Yes", string n = "No") {
    return writeln(ok ? y : n);
}


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

using namespace std;

const int MAX = 1e5+2;

vector<vector<int>> g;
int seen[MAX];
deque<int> path;

void go(int u, int id) {
    seen[u] = true;
    if(id == 0) path.push_back(u);
    else path.push_front(u);
    for(int i = 0; i < g[u].size(); i++) {
        if(!seen[ g[u][i] ]) {
            go( g[u][i], id );
            return;
        }
    }
}

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

    #ifdef FUN
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #else
        #define endl '\n'
    #endif // FUN

    int n, m; cin >> n >> m;
    g.assign(n+1, vector<int>());
    for(int i = 0; i < m; i++) {
        int a, b; cin >> a >> b;
        g[a].push_back(b);
        g[b].push_back(a);
    }

    go(1, 0);
    path.pop_front();
    go(1, 1);

    cout << path.size() << endl;
    for(int i = 0; i < path.size(); i++) {
        if(i) cout << " ";
        cout << path[i];
    }
    cout << endl;


}




Measured memory_bytes: 7168
#include <iostream>
#include <algorithm>
using namespace std;
 
int main(){
  int N,K,l[60];
  cin >> N >> K;
  for(int i=0 ; i<N ; i++) cin >> l[i];
 
  sort(l,l+N,greater<int>()); 
 
  int total=0;
  for(int i=0 ; i < K ; i++) total += l[i];
 
  cout << total;
}

Measured memory_bytes: 256
# include <iostream>
# include <algorithm>
#include <array>
# include <cassert>
#include <cctype>
#include <climits>
#include <numeric>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <tuple>
# include <utility>
# include <stack>
# include <queue>
# include <list>
# include <bitset>
# include <complex>
# include <chrono>
# include <random>
# include <limits.h>
# include <unordered_map>
# include <unordered_set>
# include <deque>
# include <cstdio>
# include <cstring>
#include <stdio.h>
#include <stdlib.h>
#include <cstdint>
#include <cfenv>
//#include <bits/stdc++.h>
using namespace std;
using LL = long long;
using ULL = unsigned long long;
constexpr long long MOD = 1000000000 + 7;
constexpr long long INF = std::numeric_limits<long long>::max();
const double PI = acos(-1);
#define fir first
#define sec second
#define thi third
#define debug(x) cerr<<#x<<": "<<x<<'\n'
typedef pair<LL, LL> Pll;
typedef pair<LL, pair<LL, LL>> Ppll;
typedef pair<LL, pair<LL, bitset<100001>>> Pbll;
typedef pair<LL, pair<LL, vector<LL>>> Pvll;
typedef pair<LL, LL> Vec2;
struct Tll { LL first, second, third; };
typedef pair<LL, Tll> Ptll;
#define rep(i,rept) for(LL i=0;i<rept;i++)
#define Mfor(i,mf) for(LL i=mf-1;i>=0;i--)
LL h, w, n, m, k, s, t, q, sum[100], last, cnt, ans=INF, a[100],dp[100][100000];
string str, ss;
bool f;
char c;
int d[4][2] = { {1,0},{-1,0} ,{0,1},{0,-1} };
struct Edge { LL to,cost; };
LL vec[1000][1000];
void YN(bool f) {
	if (f)
		cout << "YES" << endl;
	else
		cout << "NO" << endl;
}
void yn(bool f) {
	if (f)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
}
int main() {
	cin >> n;
	sum[0] = 0;
	rep(i, n) {
		cin >> a[i];
		sum[i + 1] = sum[i] + a[i];
	}
	rep(i, n+1)
		rep(j, sum[n])dp[i][j] = -1;
	dp[0][0] = INF;
	rep(i, n)
		rep(j, sum[n]+100) {	
		if (dp[i][j] != -1) {
		for (int k = i; k < n; k++) {
			if (i == 0 && k == n-1) continue;
				LL l = min(dp[i][j], sum[k + 1] - sum[i]), r = max(sum[k + 1] - sum[i], j);
				dp[k + 1][r] = max(l, dp[k + 1][r]);
			}
		}
	}
	rep(i, sum[n]) {
		if(dp[n][i]!=-1)
		ans = min(ans, i - dp[n][i]);
	}
	cout << ans << endl;
	return 0;
}


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

long long dp[90];

int main()
{
    long long x, y, z;
    cin >> x >> y >> z;
    long long ans = 0;
    x -= z;
    while (y + z <= x)
    {
        ans++;
        x -= (y + z);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <cstdio>
#include <map>
#include <numeric>
#include <cmath>
#include <set>
#include <sstream>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <complex>
#include <string.h>
#include <unordered_set>
#include <unordered_map>
#include <bitset>
#include <iomanip>
#include <sys/time.h>
#include <tuple>
#include <random>
using namespace std;

#define endl '\n'
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define UNIQ(v) (v).erase(unique((v).begin(), (v).end()), (v).end())

typedef long long ll;
typedef long double ld;
typedef pair<int, int> P;
typedef complex<double> comp;
typedef vector< vector<ld> > matrix;
struct pairhash {
public:
    template<typename T, typename U>
    size_t operator()(const pair<T, U> &x) const {
	size_t seed = hash<T>()(x.first);
	return hash<U>()(x.second) + 0x9e3779b9 + (seed<<6) + (seed>>2);
    }
};
const int inf = 1e9 + 9;
const ll mod = 1e9 + 7;
const double eps = 1e-8;
const double pi = acos(-1);

ll n, a, b;

ll solve() {
    if (a > b || (n == 1 && a != b)) return 0;
    return (b * (n-1) + a) - (a * (n-1) + b) + 1;
}

void input() {
    cin >> n >> a >> b;
}

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

    input();
    cout << solve() << endl;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000


int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    string S, T;
    cin >> S >> T;
    sort(S.begin(), S.end());
    sort(T.begin(), T.end(), greater<char>());
    //cout << S << " " << T << endl;
    if (S < T) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin>>n;
    map<char,int>m1;
    char s[27],k='A';
    for(int i=25;i>=0;i--){
        m1[k]=i;
        s[i]=k;
        k=k+1;
    }
   
    string b;
    cin>>b;
    if(n==0) cout<<b;
    else{
        int len = b.length();
        int crc = n%26;
        for(int i=0;i<len;i++){
            if(m1[b[i]]>=crc){
                cout<<s[m1[b[i]]-crc];
            }
            else{
                cout<<s[25-(crc-m1[b[i]])+1];
            }
        }
    }
    return 0;
}


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

using namespace std;

int main (void) {
    int N, K;
    cin >> N >> K;
    vector<int> x(N);
    for ( int i=0; i<N; i++ ) {
        cin >> x.at(i);
    }

    int ans = INT_MAX;
    int candle_dist, first_move;
    for ( int i=0; i<N-(K-1); i++ ) {
        candle_dist = x.at(i+(K-1)) - x.at(i);
        first_move = min(abs(x.at(i)), abs(x.at(i+(K-1))));
        ans = min(ans, candle_dist + first_move);
    }

    cout << ans << endl;
}


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

int main() {
    int a, b, c;
    scanf("%d%d%d", &a, &b, &c);
    int nokori = a - b;
    if (nokori >= c) {
        printf("%d", 0);
    } else {
        printf("%d", c - nokori);
    }
    return 0;
}

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

using i32 = int_fast32_t;
using i64 = int_fast64_t;

int main() {
    string n;
    cin >> n;
    cout << (n[0] == '7' || n[1] == '7' || n[2] == '7' ? "Yes" : "No") << endl;
}


Measured memory_bytes: 3628
#pragma GCC optimize("O3")
#include<bits/stdc++.h> 
using namespace std;
using ll=long long;
using P=pair<ll,ll>;
template<class T> using V=vector<T>; 
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
const ll inf=(1e18);
//const ll mod=998244353;
const ll mod=1000000007;
ll GCD(ll a,ll b) {return b ? GCD(b,a%b):a;}
ll LCM(ll c,ll d){return c/GCD(c,d)*d;}
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;
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 main(){
	ll l,r;
	cin>>l>>r;
	ll cnt=0;
	ll d;cin>>d;
	for(ll i=l;i<=r;i++)if(i%d==0)cnt++;
	cout<<cnt<<"\n";
}


Measured memory_bytes: 3604
#include <cstdio>
#include <iostream>
#include <string>
using namespace std;
int main()
{
	string c;
	char d[2][6]={"dream","erase"};
	long long i,l,n,m,o;
	cin >> c;
	l=c.length();
	for(i=0;i<l;)
	{
		if(c[i]=='d')
		{
			for(o=1;o<5;o++)
			{
				if(d[0][o]==c[i+o])continue;
				else break;
			}
			if(o<5)break;
			if(c[i+5]=='e'&&c[i+6]=='r')
			{
				if(c[i+7]=='a'){
					i=i+5;
				}
				else i=i+7;
			}
			else i=i+5;
		}
		else if(c[i]=='e')
		{
		for(o=1;o<5;o++)
			{
				if(d[1][o]==c[i+o])continue;
				else break;
			}
			if(o<5)break;
			if(c[i+5]=='r') i=i+6;
			else i=i+5;
		}
		else break;
	}
	if(i==l)printf("YES");
	else printf("NO");
}


Measured memory_bytes: 512
import heapq

N = int(input())
a_list = list(map(int,input().split()))
a_list.sort(reverse=True)

ans = 0

conf_heap = []
heapq.heapify(conf_heap)
heapq.heappush(conf_heap,-1*a_list[0])

for i in range(1,N):
    ans += -1 * heapq.heappop(conf_heap)
    heapq.heappush(conf_heap,-1*a_list[i])
    heapq.heappush(conf_heap,-1*a_list[i])
print(ans)


Measured memory_bytes: 31772
package main

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

var stdInScanner = bufio.NewScanner(os.Stdin)

func nextInt() int {
	stdInScanner.Scan()
	i, _ := strconv.Atoi(stdInScanner.Text())
	return i
}

func nextString() string {
	stdInScanner.Scan()
	return stdInScanner.Text()
}

func main() {
	stdInScanner.Split(bufio.ScanWords)

	N := nextInt()
	counter := map[string]int{}

	var key string
	max := 1
	for i := 0; i < N; i++ {
		key = nextString()
		_, ok := counter[key]
		if ok {
			counter[key]++
			if max < counter[key] {
				max = counter[key]
			}
		} else {
			counter[key] = 1
		}
	}
	keysList := make([]string, 0)
	for k, v := range counter {
		if v == max {
			keysList = append(keysList, k)
		}
	}
	sort.Strings(keysList)
	for _, v := range keysList {
		fmt.Println(v)
	}
}


Measured memory_bytes: 30848
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <utility>
#include <cstring>
#include <iomanip>
#include <numeric>
#include <cmath>
#include <queue>
#include <map>
using namespace std;
typedef long long ll;
const int INF = 1<<30; 
const int MOD = 1e9 + 7;
const int dy[] = {1, 0, -1, 0};
const int dx[] = {0, 1, 0, -1};
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, l; cin >> n >> l;
    vector<int> v(n);
    for(int i = 0; i < n; i++) cin >> v[i];
    vector<ll> res;
    int right = 0;
    map<ll, int> mp;
    for(int left = 0; left + l <= n; left++)
    {
        while(right - left < l)
        {
            mp[v[right]]++;
            right++;
        }
        res.push_back(mp.begin()->first);
        mp[v[left]]--;
        if(mp[v[left]] == 0) mp.erase(v[left]);
    }
    for(int i = 0; i < res.size(); i++)
    {
        if(i) cout << " ";
        cout << res[i];
    }
    cout << endl;
    return 0;
}




Measured memory_bytes: 21272
/*   --------------------
    |       LOSER        |
    |     ~NOOBOSS~      |
     --------------------
*/
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define      inl(x)              scanf("%lld",&x)
#define      in(x)               scanf("%d",&x)
#define      mxx                 10000000000000
#define      mnn                 -10000000000000
#define      Y()                 cout<< "YES" <<endl
#define      N()                 cout << "NO"<<endl
#define      endl                "\n"
#define      max_3(a,b,c)        max(a, max(b,c))
#define      max_4(a,b,c,d)      max(a,max(b,max(c,d)))
#define      min_3(a,b,c)        min(a, min(b,c))
#define      min_4(a,b,c,d)      min(a,min(b,min(c,d)))
#define      gcd(a,b)            __gcd(a,b)
#define      lcm(a,b)           (a*b)/gcd(a,b)
#define      loser               return 0
#define      ll                  long long
#define      PI                  acos(-1)
#define      mem(a,v)            memset(a,v,sizeof(a))
#define      SORT(v)             sort(v.begin(),v.end())
#define      REV(v)              reverse(v.begin(),v.end())
#define      O(x)                cout<<x<<endl
#define      B                   begin()
#define      E                   end()
#define      V                   vector
#define      F                   first
#define      S                   second
#define      PSB                 push_back
#define      EMB                 emplace_back
#define      MP                  make_pair
#define      PII                 pair<int,int>
#define      MII                 map<int,int>
#define      InTheNameOfGod      ios::sync_with_stdio(0);cin.tie(0); cout.tie(0);
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;//*(x.find_by_order(i)),x.order_of_key(k)
//const ll MOD = 998244353;
constexpr ll mod = 1e9  + 7;
//auto it=std:: unique(v.B,v.E);
//v.resize(std::distance(v.B,it));
int dx[] = {0,0,1,-1};
int dy[] = {1,-1,0,0};
/*-----*/
#define bug1(a)  cout<<a<<endl;
#define bug2(a,b)  cout<<a<<" "<<b<<endl;
#define bug3(a,b,c)  cout<<a<<" "<<b<<" "<<c<<endl;
/*----*/
ll power(ll n,ll p){if(p==0) return 1;if(p==1)return n;if(p%2)return power(n,p-1)*n;else{ll x=power(n,p/2);return x*x;}}
ll modpow(ll a,ll b,ll m){ll ans=1;while(b){if(b&1)ans=(ans*a)%m;b/=2;a=(a*a)%m;}return ans;}
ll binpow(ll a, ll b){ll res = 1;while (b > 0) {if (b & 1)res*=a;a*=a;b>>=1;}return res;}
ll fact(ll num){ll fac=1;while(num!=1){fac=fac*num;num--;}return fac;}
string to_binary(int x) {string s;while(x > 0) {s += (x % 2 ? '1' : '0');x /= 2;}reverse(s.begin(), s.end());return s;}
ll nsum(ll num){return (num*(num+1))/2;}
/*-----*/
const int N=2e5+5;

/*-----*/
//vector<int> v[202];

/*-----*/
int main(){
   InTheNameOfGod

   ll test=1;
   //cin>>test;
   while(test--){
     ll n,l,r,d;
     string s;
     cin>>l>>r>>d;
     ll ans=(r/d)-(l-1)/d;
     cout<<ans<<endl;

    }
  loser;
}
///////LeArN MoRe AnD Wait FoR ThE Result///////


Measured memory_bytes: 3580
package main

import (
	"bufio"
	"fmt"
	"io"
	"math"
	"os"
	"strconv"
	"strings"

)


func main() {
	solve(os.Stdin, os.Stdout)
}

type ReaderEx struct {
	baseScanner *bufio.Scanner
	words       []string
	nextWordIdx func() int
	initWordIdx func(int)
}

func NewScannerEx(stdin io.Reader) *ReaderEx {
	var this ReaderEx
	var idx int
	var wordsCnt int
	this.baseScanner = bufio.NewScanner(stdin)
	this.baseScanner.Buffer(make([]byte, 0), 1E+11)
	this.nextWordIdx = func() int {
		cur := idx
		idx = (idx + 1) % wordsCnt
		return cur
	}
	this.initWordIdx = func(wc int) {
		idx = 0
		wordsCnt = wc
	}
	return &this
}

func (me *ReaderEx) Scan(doSplit bool) (isScanned bool) {
	isScanned = me.baseScanner.Scan()
	if doSplit {
		me.words = strings.Fields(me.baseScanner.Text())
	} else {
		me.words = []string{me.baseScanner.Text()}
	}
	me.initWordIdx(len(me.words))
	return
}

func (me *ReaderEx) nextBytes() []byte {
	return []byte(me.words[me.nextWordIdx()])
}
func (me *ReaderEx) nextString() string {
	return me.words[me.nextWordIdx()]
}

type StringArray []string

func (me *ReaderEx) nextStringArray() StringArray {
	return me.words[me.nextWordIdx():]
}

func (me StringArray) toStrings() []string {
	return me
}

func (me StringArray) toInts() []int {
	strValues := me.toStrings()
	values := make([]int, len(strValues))
	for i, v := range strValues {
		n, err := strconv.Atoi(v)
		if err != nil {
			panic(err)
		}
		values[i] = n
	}
	return values
}
func (me *ReaderEx) nextInt() int {
	n, err := strconv.Atoi(me.words[me.nextWordIdx()])

	defer func() {
		if err != nil {
			panic(fmt.Sprintf("getInt(%d)", n))
		}
	}()
	return n
}

func pow(x, y, mod int) (ans int) {

	ans = 1
	for bit := 1 << uint(math.Floor(math.Log2(float64(y)))); ; bit >>= 1 {
		if y&bit != 0 {
			ans *= x
			if mod > 0 {
				ans %= mod
			}
		}
		if bit <= 1 {
			return
		}
		ans *= ans
		if mod > 0 {
			ans %= mod
		}
	}
}

type factType struct {
	prime int
	count int
}

func fact(n int) (facts []*factType) {

	for i := 2; i*i <= n; i++ {
		if n%i == 0 {
			fa := factType{prime: i}
			for n%fa.prime == 0 {
				n /= fa.prime
				fa.count++
			}
			facts = append(facts, &fa)
		}
	}
	if n > 1 {
		facts = append(facts, &factType{prime: n, count: 1})
	}
	return facts
}
func dec2bin(n int) (ret []bool) {
	for bit := 1 << uint(math.Floor(math.Log2(float64(n)))); ; bit >>= 1 {
		ret = append(ret, n&bit != 0)

		if bit <= 1 {
			return
		}
	}

}

func abs(v int) int {
	if v < 0 {
		v = -v
	}
	return v
}

func b2i(b bool) (i int) {
	if b {
		i = 1
	} else {
		i = 0
	}
	return
}

func solve(stdin io.Reader, stdout io.Writer) {

	r := NewScannerEx(stdin)
	r.Scan(true)
	//n := r.nextInt()
	r.Scan(true)
	s := r.nextString()

	c := '_'
	ans := 0
	for _, nc := range s {
		if nc != c {
			ans++
			c = nc
		}
	}
	fmt.Fprintln(stdout, ans)
}


Measured memory_bytes: 896
#include<bits/stdc++.h>
#define LL long long
#define MOD 1000000007
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define print(a, n) for(LL e=0; e<n; e++) cout<<a[e]<<" "; cout<<endl
#define read(a, n) for(LL e=0; e<n; e++) cin>>a[e];
using namespace std;
  
int main()
{
	fastio;
	string s, t;
	cin>>s>>t;
	if(s==t.substr(0, t.size()-1))
		cout<<"Yes"<<"\n";
	else
		cout<<"No"<<"\n";

	return 0;
}


Measured memory_bytes: 3600
import sys
readline = sys.stdin.readline
sys.setrecursionlimit(10**8)
mod = 10**9+7
#mod = 998244353
INF = 10**18
eps = 10**-7

n=int(input())
cnt=0
d=False
for i in range(n):
  x,y=map(int,input().split())
  if x==y:
    cnt+=1
  else:
    cnt=0
  if cnt==3:
    d=True
    break
if d:
  print('Yes')
else:
  print('No')

Measured memory_bytes: 9380
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N,M; cin>> N >>M;
  vector <pair<int,int>>gakusei;
  for(int i = 0; i < N; i++){
    int a,b; cin >> a >>b;
    gakusei.push_back(make_pair(a,b));
  }
  vector <pair<int,int>>point;
  for(int i = 0; i < M; i++){
    int a,b; cin >> a >>b;
    point.push_back(make_pair(a,b));
  }
  int min_distance = 9999999999999;
  int min_check;
  for(int i = 0; i < N; i++){
    for(int j = 0; j < M; j++){
      int tmp = abs(gakusei.at(i).first - point.at(j).first) + abs(gakusei.at(i).second - point.at(j).second); 
      if(min_distance > tmp){
        min_check = j + 1;
        min_distance = tmp;
      }
    }
   	cout << min_check << endl;
    min_distance = 9999999999999;
  }
}
  
  

Measured memory_bytes: 3580
#include <limits.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <algorithm>
#include <cassert>
#include <cfloat>
#include <complex>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef vector<ll> vll;
typedef deque<ll> dqll;

#define MOD 1000000007

int main() {
  ll N;

  cin >> N;

  int sum = 0;
  int i = 0;
  while(sum < N){
    i++;
    sum += i;
  }

  cout << i << endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//#include <boost/multiprecision/cpp_ll.hpp>
//typedef boost::multiprecision::cpp_ll ll;
typedef long double dd;
#define i_7 (ll)(1E9+7)
//#define i_7 998244353
#define i_5 i_7-2
ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
typedef pair<ll,ll> l_l;
ll inf=(ll)1E18;
#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define pb push_back
ll max(ll a,ll b){if(a<b)return b;else return a;}
ll min(ll a,ll b){if(a>b)return b;else return a;}
void Max(ll &pos,ll val){pos=max(pos,val);}//Max(dp[n],dp[n-1]);
void Min(ll &pos,ll val){pos=min(pos,val);}
void Add(ll &pos,ll val){pos=mod(pos+val);}
dd EPS=1E-9;
//#define endl "\n"
#define fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);


int main(){fastio
    ll n;cin>>n;
    ll a[n+1];rep(i,0,n)cin>>a[i];
    ll l[n+1],r[n+1];
    for(ll i=n;i>=0;i--){
        if(i==n){
            l[i]=a[i];
            r[i]=a[i];
        }else{
            l[i]=(1+l[i+1])/2;
            r[i]=r[i+1];
            l[i]=l[i]+a[i];
            r[i]=r[i]+a[i];
        }
    }
    ll m[n+1],ho[n+1];
    rep(i,0,n){
        if(i==0){
            m[i]=1;
            ho[i]=1-a[i];
        }else{
            m[i]=2*ho[i-1];
            ho[i]=m[i]-a[i];
            if(m[i]>powl(10,15)){
                rep(j,i+1,n){
                    m[j]=inf;
                    ho[j]=inf;
                }
                break;
            }
        }
    }
    ll ans=0;
    rep(i,0,n){
        if(l[i]>m[i]){
            cout<<-1<<endl;
            return 0;
        }else{
            ans+=min(m[i],r[i]);
        }
    }
    cout<<ans<<endl;
    
    return 0;
}





Measured memory_bytes: 7512
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
int main(void){
    // Your code here!
    int h,w,syo=0,nx,ny,x,y;
    cin>>h>>w;
    char maze[h][w];
    int t[h][w];
    memset(t,-1,sizeof(t));
    t[0][0]=0;
    int dx[4]={1,0,-1,0};
    int dy[4]={0,1,0,-1};
    for(int i=0;i<h;i++){
        string s;
        cin>>s;
        for(int j=0;j<w;j++){
            maze[i][j]=s[j];
            if(s[j]=='#')syo++;
        }
    }
    queue<P> que;
    que.push(P(0,0));
    while (que.size()){
        auto xx=que.front();
        que.pop();
        x=xx.first;
        y=xx.second;
        for(int i=0;i<4;i++){
            nx=x+dx[i];
            ny=y+dy[i];
            if(nx>=0 && nx<h && ny>=0 && ny<w && t[nx][ny]==-1 && maze[nx][ny]=='.'){
                t[nx][ny]=t[x][y]+1;
                que.push(P(nx,ny));
            }
        }
    }
    if(t[h-1][w-1]!=-1){
        cout<<h*w-syo-t[h-1][w-1]-1<<endl;
    }
    else cout<<-1<<endl;
}


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

int main()
{
    int n;

    scanf("%d",&n);

    int maxn = 0;
    int ans = 1;

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

        while (tmp % 2 == 0)
        {
            tmp /= 2;
            cnt++;
        }

        if (cnt > maxn)
        {
            maxn = cnt;
            ans = i;
        }
    }

    printf("%d",ans);

    return 0;
}


Measured memory_bytes: 128
#include<iostream>

using namespace std;

int main(){
    int n,k,d,x;
    int ans=0;
    int sukenu[101];
    cin >> n >> k;
    for(int i=0;i<101;i++){
        sukenu[i]=0;
    }
    for(int i=0;i<k;i++){
        cin >> d;
        for(int k=0;k<d;k++){
            cin >> x;
            sukenu[x-1]=1;
        }
    }
    for(int i=0;i<n;i++){
        if(sukenu[i] == 0){
            ans +=1;
        }
    }
    cout <<ans<< endl;
    return 0;
}


Measured memory_bytes: 3624
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <queue>

using namespace std;

vector< vector< int > > grid_bfs(vector< string > &s, char start, const string &wall = "#") {
    const int vx[] = {0, 1, 0, -1}, vy[] = {1, 0, -1, 0};
    vector< vector< int > > min_cost(s.size(), vector< int >(s[0].size(), -1));
    queue< pair< int, int > > que;
    for(int i = 0; i < s.size(); i++) {
        for(int j = 0; j < s[i].size(); j++) {
        if(s[i][j] == start) {
            que.emplace(i, j);
            min_cost[i][j] = 0;
        }
        }
    }
    while(!que.empty()) {
        auto p = que.front();
        que.pop();
        for(int i = 0; i < 4; i++) {
        int ny = p.first + vy[i], nx = p.second + vx[i];
        if(nx < 0 || ny < 0 || nx >= s[0].size() || ny >= s.size()) continue;
        if(min_cost[ny][nx] != -1) continue;
        if(wall.find(s[ny][nx]) != string::npos) continue;
        min_cost[ny][nx] = min_cost[p.first][p.second] + 1;
        que.emplace(ny, nx);
        }
    }
    return min_cost;
}

int main(void) {
    int H, W;
    cin >> H >> W;
    vector<string> grid(H);
    for(int i=0; i<H; i++) {
        cin >> grid[i];
    }

    int ans = 0;
    for(int i=0; i<H; i++) {
        for(int j=0; j<W; j++) {
            if(grid[i][j] == '.') {
                grid[i][j] ='s';
                auto tmp = grid_bfs(grid, 's');
                for(int k=0; k<H; k++) {
                    for(int l=0; l<W; l++) {
                        if(tmp[k][l] != -1) {
                            ans = max(ans, tmp[k][l]);
                        }
                    }
                }
                grid[i][j] = '.';
            }
        }
    }

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


Measured memory_bytes: 256
using System;
using System.Linq;
using System.Collections.Generic;
using System.IO;

namespace atcorder2
{
    class Program
    {
        public static long Read()
        {
            return long.Parse(Console.ReadLine());
        }

        public static long[] Reads()
        {
            return Console.ReadLine().Split().Select(long.Parse).ToArray();
        }
        

        static void Main(string[] args)
        {
            var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);


            var s = Console.ReadLine().ToCharArray();
            var anwer = new List<char>();
            for (int i = 0; i < s.Length; i++)
            {
                if (s[i] == '0')
                {
                    anwer.Add('0');
                }
                if (s[i] == '1')
                {
                    anwer.Add('1');
                }
                if (s[i] == 'B'&&anwer.Count!=0)
                {
                    anwer.RemoveAt(anwer.Count - 1);
                }
            }
            var str = anwer.Aggregate("",(str1, a) => str1 += a);
            Console.WriteLine(str);
                   
        

            Console.Out.Flush();
        }
    }
}

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

int main() {
  string O, E;
  cin >> O >> E;
  int os = O.size(), es = E.size();
  for (int i=0; i<os; i++) {
    cout << O[i];
    if (i<es)
      cout << E[i];
  }
  cout << endl;
  return 0;
}

Measured memory_bytes: 256
#include <map>
#include <cmath>
#include <string>
#include <vector>
#include <iomanip>
#include <iostream>
#include <algorithm>
#include <functional>
#pragma warning(disable : 4996)
using namespace std;

// A002487: Stern-Brocot Sequence
// a[0] = 0, a[1] = 1, a[2n] = a[n], a[2n + 1] = a[n] + a[n + 1]
// s[x] = a[0] + a[1] + ... + a[x]
// s[0] = 0, s[1] = 1
// s[2n] = (a[0] + a[2] + ... + a[2n]) + (a[1] + a[3] + ... + a[2n - 1])
//       = (a[0] + a[1] + ... + a[n]) + (1 + a[1] + 2a[2] + 2a[3] + 2a[4] + ... + 2a[n - 1] + a[n]
//       = s[n] + {(s[n] - a[1] - a[0] + 1) + (s[n - 1] - a[0])}
//       = 2s[n] + s[n - 1]
// s[2n + 1] = (s[0] + a[2] + ... + a[2n]) + (a[1] + a[3] + ... + a[2n + 1])
//           = (a[0] + a[1] + ... + a[n]) + (1 + a[1] + 2a[2] + 2a[3] + 2a[4] + ... + 2a[n] + a[n + 1])
//           = s[n] + {(s[n + 1] - a[1] - a[0] + 1) + (s[n] - a[0])}
//           = s[n + 1] + 2s[n]
//
// Similar Problem: ProjectEuler 463 A weird recurrence relation

const int mod = 1000000007;
map<long long, long long> dp;
long long solve(long long x) {
	if (x <= 1) return x;
	if (dp[x]) return dp[x];
	long long ret;
	if (x % 2 == 0) ret = 2 * solve(x / 2) + solve(x / 2 - 1);
	else ret = solve(x / 2 + 1) + 2 * solve(x / 2);
	return dp[x] = ret % mod;
}
long long n;
int main() {
	cin >> n;
	cout << solve(n + 1) << endl;
	return 0;
}

Measured memory_bytes: 384
#include "bits/stdc++.h"
#define int long long
#define range(i, a, b) for(int i = a; i < b; i++)
#define rep(i, a) range(i, 0, a)
#define all(a) (a).begin(),(a).end()
using namespace std;
const int MOD = 1e9 + 7, INF = 1e9;
using vi = vector <int>;
using vvi = vector <vi>;
//g++ -std==c++14


vi tate, yoko;
int x, y;
bool tateha = false, yokoha = false;

void dfsx(int n, set <int> va){
	if(n == yoko.size()){
		if(va.find(x) != va.end())
			yokoha = true;
		return;
	}
	set <int> add;
	for(auto itr = va.begin(); itr != va.end(); itr++){
		add.insert(*itr + yoko[n]);
		add.insert(*itr - yoko[n]);
	}
	dfsx(n + 1, add);
}

void dfsy(int n, set <int> va){
	if(n == tate.size()){
		if(va.find(y) != va.end())
			tateha = true;
		return;
	}
	set <int> add;
	for(auto itr = va.begin(); itr != va.end(); itr++){
		add.insert(*itr + tate[n]);
		add.insert(*itr - tate[n]);
	}
	dfsy(n + 1, add);
}

signed main(){
	string s;
	cin >> s >> x >> y;

	int va = 0;
	bool yokoka = true;

	rep(i, s.size()){
		if(s[i] == 'F' && i != s.size() - 1){
			va++;
		}
		else{
			if(s[i] == 'F' && i == s.size() - 1)
				va++;
			if(yokoka){
				yoko.push_back(va);
				va = 0;
				yokoka = false;
			}
			else{
				tate.push_back(va);
				va = 0;
				yokoka = true;
			}
		}
	}

	set <int> a;
	if(yoko.size() != 0){
		a.insert(yoko[0]);
		dfsx(1, a);
	}
	else
		if(x == 0)yokoha = true;
	a.clear();
	if(tate.size() != 0){
		a.insert(tate[0]);
		a.insert(-1 * tate[0]);
		dfsy(1, a);
	}
	else
		if(y == 0)tateha = true;

	if(tateha && yokoha)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
}


Measured memory_bytes: 381184
#include<bits/stdc++.h>
using namespace std;
#define ll long long
const int mod=1e9+7;
ll power(ll a,ll b){
    ll res=1;
    while(b){
        if(b&1)res=res*a%mod;
        b>>=1;
        a=a*a%mod;
    }
    return res;
}
ll inv(ll x){
    return power(x,mod-2);
}
ll gcd(ll a,ll b){
    if(a%b==0)return b;
    return gcd(b,a%b);
}
ll dp[5111][3][6];
int main(){
    ll n,i,j,k,sum=0;
    string s;
    cin>>n>>s;
    string t[6]={"RGB","RBG","BGR","BRG","GBR","GRB"};
    for(j=0;j<6;j++)
        for(i=0;i<n;i++){
            if(i>0)dp[i][0][j]=dp[i-1][0][j],dp[i][1][j]=dp[i-1][1][j],dp[i][2][j]=dp[i-1][2][j];
            if(s[i]==t[j][0])dp[i][0][j]++;
            if(s[i]==t[j][1]&&i>0)dp[i][1][j]+=dp[i-1][0][j];
            if(s[i]==t[j][2]&&i>0)dp[i][2][j]+=dp[i-1][1][j];
        }
    for(i=1;i<=n/2;i++){
        for(j=i;j<=n-1-i;j++){
            if(s[j-i]!=s[j]&&s[j+i]!=s[j]&&s[j-i]!=s[j+i])sum++;
        }
    }
   // cout<<sum<<endl;
    ll res=0;
    for(i=0;i<6;i++)res+=dp[n-1][2][i];
    cout<<res-sum;
}


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

#define ll long long
#define ld long double
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define eb emplace_back
//#define gcd __gcd
//#define lcm(a, b) ((a) * (b) / gcd((a), b))
#define all(x) x.begin(), x.end()
#define rep(i, x, n) for (ll i = x; i < n; i++)
#define fastio() ios_base::sync_with_stdio(NULL); cin.tie(0); cout.tie(0)
#define endl '\n'

typedef vector<int> vi;
typedef vector<vector<int> > vvi;
typedef pair<int, int> ii;
typedef vector<pair<int, int> > vii;

template <class T> inline T RD(T &a) {T x; cin >> x; return a = x;}

//OJ freopen Template

const ll mod = 1e9 + 7, maxn = 2*1e5 + 10;

ll n, k;

ll p[maxn];

void calc() {
    p[0] = 1;
    for (ll i = 1; i <= n; i++) {
        p[i] = p[i - 1] * i;
        p[i] %= mod;
    }
}

signed main()
{
	fastio();

	cin >> n >> k; n++;

    calc();

    ll ans = 0, l = 0, r = 0;

    for (int i = 1; i < k; i++) {
        l += i;
        r += n - i + 1;
    }

    for (int i = k; i <= n; i++) {
        l += i;
        r += n - i + 1;
        ans += abs(l - r) + 1;
        ans %= mod;
    }

    cout << ans;
}


Measured memory_bytes: 5168
n,a,b = map(int, input().split())

mod = 10**9 + 7

ans = pow(2, n, mod) - 1
for i in [a,b]:
    child = 1
    mother = 1
    for j in range(1,i+1):
        child = child * (n-j + 1) % mod
        mother = mother * j % mod
    mother = pow(mother, mod-2, mod)
    ans -= (child * mother)%mod


ans = ans % mod

print(ans)


Measured memory_bytes: 38768
#include <stdio.h>
int main()
{
	int a[102], N, i, j, cop, Alice = 0 , Bob = 0;
	scanf("%d", &N);
	for (i = 0; i < N; i++) {
		scanf("%d", &a[i]);
	}
	for (i = 0; i < N; i++) {
		for (j = i + 1; j < N; j++) {
			if (a[i] < a[j]) {
				cop = a[i];
				a[i] = a[j];
				a[j] = cop;
			}
		}
	}
	for (i = 0; i < N; i++) {
		if (i % 2 == 0) {
			Alice += a[i];
		}
		else {
			Bob += a[i];
		}
	}
	printf("%d", Alice - Bob);
}

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
#define REP(i, n) for(int i=0; i<n; i++)

ll B[100100];
int main(){
    int N;
    cin >> N;
    ll H;
    cin >> H;
    ll maxa = -1;
    REP(i,N){
        ll a, b;
        cin >> a >> b;
        B[i] = b;
        maxa = max(maxa, a);
    }

    sort(B, B+N);
    int idx = upper_bound(B, B+N, maxa) - B;
    ll ans = 0;
    for(int i = N-1; i >= idx; i--){
        ans += 1;
        H -= B[i];
        if(H <= 0) goto fin;
    }
    ans += H/maxa + (H%maxa != 0);

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


Measured memory_bytes: 1024
#include<iostream>

void call(size_t n){
    for(size_t i = 1; i <= n; i++){
        if(i % 3 == 0){
            std::cout << ' ' << i;
        }else if(i % 10 == 3){
            std::cout << ' ' << i;
        }else if(i / 10){
            int x = i / 10;
            while(x){
                if(x % 10 == 3){
                    std::cout << ' ' << i;
                    break;
                }
                x /= 10;
            }
        }
    }std::cout << std::endl;
}

int main(){

    size_t n;
    std::cin >> n;

    call(n);
    
    return 0;
}



Measured memory_bytes: 3088
function Main(input){

  var inp = input.split(' ');
  var A = parseInt(inp[0]); // 水の量
  var B = parseInt(inp[1]); // 水の量
  var C = parseInt(inp[2]); // 砂糖の量
  var D = parseInt(inp[3]); // 砂糖の量
  var E = parseInt(inp[4]); // 水100gあたりの溶ける砂糖の量
  var F = parseInt(inp[5]); // 砂糖水の総量
  
  var waterTotal = []; // とりうる水の量
  var sugarTotal = []; // とりうる砂糖の量
  
  var sugarWater = []; // とりうる砂糖水の量
  var sugarWeight = []; // とりうる砂糖の量
  
  // とりうる水と砂糖の量を列挙
  for(var i = 0; i <= F; i++){
    for(var j = 0; j <= F; j++){
      var water = ((A * i) + (B * j)) * 100; // 水の量
      if(water <= F ) waterTotal.push(water); 
  
      var sugar = (C * i + D * j); // 砂糖の量
      if(sugar <= F) sugarTotal.push(sugar);
    }
  }  
  
  // とりうる砂糖水と砂糖の量を列挙
  for(var i = 0; i <= F; i++){
    for(var j = 0; j <= F; j++){
      var sw = waterTotal[i] + sugarTotal[j]; // 砂糖水の量
      var meltSugar = 100 * sugarTotal[j] / waterTotal[i]; // 水に溶ける砂糖の量
      if( sw <= F && meltSugar <= E){
        sugarWater.push(sw); 
        sugarWeight.push(sugarTotal[j]);
      }
    }
  }
  
  // 各砂糖水と砂糖の量から、濃度を求める
  var noudo = 0;
  var noudoIndex = 0;
  for(var i = 0; i < sugarWater.length; i++){
    var noudoTmp = (100 * sugarWeight[i]) / sugarWater[i]; // 砂糖水の濃度
    if(noudoTmp > noudo){
      noudo = noudoTmp;
      noudoIndex = i;
    }
  }
  
  console.log(sugarWater[noudoIndex] + ' ' + sugarWeight[noudoIndex]);
}
Main(require('fs').readFileSync('/dev/stdin', 'utf8'));


Measured memory_bytes: 13004
def calculate(h, w, arr):
    L = [[0]*w for i in range(h)]
    U = [[0]*w for i in range(h)]
    D = [[0]*w for i in range(h)]
    R = [[0]*w for i in range(h)]

    for ih in range(h):
        for iw in range(w):
            if ih == 0:
                U[ih][iw] = 1
            if iw == 0:
                L[ih][iw] = 1

            if arr[ih][iw] == 1:
                L[ih][iw] = 0
                U[ih][iw] = 0

            else:
                if iw > 0:
                    L[ih][iw] = L[ih][iw - 1] + 1
                if ih > 0:
                    U[ih][iw] = U[ih - 1][iw] + 1

            rih = h - 1 - ih
            riw = w - 1 - iw

            if rih == h - 1:
                D[rih][riw] = 1
            if riw == w - 1:
                R[rih][riw] = 1

            if arr[rih][riw] == 1:
                D[rih][riw] = 0
                R[rih][riw] = 0
            else:
                if riw < w - 1:
                    R[rih][riw] = R[rih][riw + 1] + 1
                if rih < h - 1:
                    D[rih][riw] = D[rih + 1][riw] + 1

    max = 0
    for ih in range(h):
        for iw in range(w):
            value = L[ih][iw] + R[ih][iw] + U[ih][iw] + D[ih][iw] - 3
            if value > max:
                max = value
    print(int(max))


S = input().split(" ")
H = int(S[0])
W = int(S[1])

arr = []
for i in range(H):
    q = input()
    tmp = []
    for qs in q:
        if qs == "#":
            tmp.append(1)
        if qs == ".":
            tmp.append(0)
    arr.append(tmp)

calculate(H, W, arr)

Measured memory_bytes: 197128