akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define ll      long long int
#define MOD     1000000007
#define pb      push_back
#define mp      make_pair
#define all(v)  (v).begin(),(v).end();
#define T		int t;cin>>t;while(t--)
#define IOS     ios_base::sync_with_stdio(false);cin.tie(NULL);
const int N = 2e5 + 2;


int main() {




	int h, w;
	cin >> h >> w;

	char board[h][w];

	for (int i = 0 ; i < h ; i ++) {
		for (int j = 0 ; j < w; j ++) {
			cin >> board[i][j];
		}
	}


	ll dp[h + 1][w + 1];
	for (int i = 0 ; i < h ; i++) {
		for (int j = 0 ; j < w; j++) {
			dp[i][j] = 0;
		}
	}

	if (board[0][0] == '#')dp[0][0] = 0;
	else dp[0][0] = 1 ;

	for (int i  = 1 ; i  < h ; i ++) {
		if (board[i - 1][0] == '.' && board[i][0] != '#')dp[i][0] += dp[i - 1][0];
	}

	for (int j = 1 ; j < w; j++)
	{
		if (board[0][j - 1] == '.' && board[0][j] != '#')dp[0][j] += dp[0][j - 1];

	}


	for (int i = 1; i < h; i++) {

		for (int j = 1 ; j < w ; j ++) {

			if (board[i][j] != '#') {
				dp[i][j] = (dp[i - 1][j] + dp[i][j - 1]) % MOD;
			}

		}
	}

	cout << dp[h - 1][w - 1] << endl;


}




Measured memory_bytes: 9088
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define rep2(i, a, n) for(ll i = a; i < (ll)(n); i++)
#define memi cout << endl
#define kono(n) cout << fixed << setprecision(n)
#define all(c) (c).begin(), (c).end()
#define pb push_back
#define hina cout << ' '
#define in(n) cin >> n
#define in2(n, m) cin >> n >> m
#define in3(n, m, l) cin >> n >> m >> l
#define out(n) cout << n
const ll mei = (ll)1e9 + 7;

int main(){
  ll a, b, c, n, h;
  in2(n, c);
  vector<vector<ll>> d(c, vector<ll> (c));
  vector<vector<ll>> e(n, vector<ll> (n));
  rep(i, c){
    rep(j, c)
      in(d[i][j]);
  }
  rep(i, n){
    rep(j, n){
      in(e[i][j]);
      e[i][j]--;
    }
  }
  vector<ll> s(c, 0), t(c, 0), u(c, 0);
  rep(i, n){
    rep(j, n){
      if((i + j) % 3 == 0)
        s[e[i][j]]++;
      if((i + j) % 3 == 1)
        t[e[i][j]]++;
      if((i + j) % 3 == 2)
        u[e[i][j]]++;
    }
  }
  a = 9999999999999;
  rep(i, c){
    rep(j, c){
      rep(k, c){
        if(i != j && j != k && k != i){
          h = 0;
          rep(l, c){
            h += s[l] * d[l][i];
            h += t[l] * d[l][j];
            h += u[l] * d[l][k];
          }
          a = min(h, a);
        }
      }
    }
  }
  out(a);
  memi;
}

Measured memory_bytes: 2176
import java.util.*;

public class Main {

        public static void main(String[] args) {
                Scanner sc = new Scanner(System.in);
                try {
                        int c5 = 0;
                        int c7 = 0;
                        for (int i = 0; i<3; i++ ) {
                                int input = sc.nextInt();
                                if (input == 5) {
                                        c5++;
                                } else if (input ==7) {
                                        c7++;
                                }
                        }
                        if (c5 == 2 && c7 == 1) {
                                System.out.println("YES");
                        } else {
                                System.out.println("NO");
                        }

                } catch (Exception e) {
                //      e.printStackTrace();
                        System.out.println("入力値が不正です");
                }
        }
}

Measured memory_bytes: 21332
#include<stdio.h>
#include<cstdio>
#include<stdlib.h>
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<string>
#include<cmath>
#include<vector>
#include<stack>
#include<queue>
#include<time.h>
#include<set>
#include<map>
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define REP(i,a,b) for(int i=a;i>b;i--)
#define vint vector<int> 
#define vvint vector<vint>
#define ct(a) cout<<a<<endl
using namespace std;
typedef long long ll;
const ll INF = 1e9 + 7;
const ll mod = 1e9 + 7;

ll N;
ll a[200000];

int main() {
	

	cin >> N;
	ll sum = 0;
	FOR(i,0,N) {
		cin >> a[i];
		sum += a[i];
	}

	int flag = 1;
	ll sum1=0;
	ll cur = 1e18;
	FOR(i, 0, N-1) {
		sum1 += a[i];
		if (cur > abs(sum - 2 * sum1))cur= abs(sum - 2 * sum1);
	}
	cout << cur << endl;

	return 0;
}

Measured memory_bytes: 1792
stay = int(input())
plan_change_day =int(input())
high_price=int(input())
low_price=int(input())
 
def main():
    if stay - plan_change_day > 0:
        cost = high_price * plan_change_day + low_price * (stay - plan_change_day)
        print(int(cost))
    else:
        cost = high_price * stay
        print(int(cost))
  	    
main()


Measured memory_bytes: 2940
n,k=map(int,input().split())

ans = 0
for b in range(k+1,n+1):
    ans += max(n%b - (k-1),0) * (n//b+1) + max((b-1) - max(n%b,k-1),0) * (n//b)
    if k==0:
        ans -= 1

print(ans)


Measured memory_bytes: 3060
#include<iostream>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<utility>
#include<vector>
#include<cmath>
#include<cstdio>
#define loop(i,a,b) for(int i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define mp make_pair
#define it ::iterator
#define all(in) in.begin(),in.end()
const double PI=acos(-1);
const double ESP=1e-10;
using namespace std;
int main(){
  int ma=1e5;
  vector<bool>sosu(ma,1);
  sosu[0]=sosu[1]=0;
  for(int i=4;i<ma;i+=2)sosu[i]=0;
  for(int i=3;i<ma;i+=2)
    for(int j=i*3;j<ma;j+=i*2)sosu[j]=0;
  int in;
  while(cin>>in){
    for(int i=in-1;i>=2;i--)if(sosu[i]){cout<<i;break;}
    for(int i=in+1;i<1e6;i++)if(sosu[i]){cout<<" "<<i<<endl;break;}
  }
}

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

using namespace std;

int main() {
  string str;
  cin >> str;

  int sum = 0;
  for (int i = 0; i < str.length(); i++) {
    char c = str[i];
    sum += (c - '0');
  }

  int n = stoi(str);

  if (n % sum == 0) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
int main()
{
	char a[100];
	cin>>a;
	int b=strlen(a);
	int k=0;
	for(int i=0;i<b;i++)
	{
		if(a[i]=='C')
		{
			k=1;
		}
		if(a[i]=='F' && k==1)
		{
			k=2;
		}
	} 
	if(k==2)
	{
		cout<<"Yes"<<endl;
	}
	else
	{
		cout<<"No"<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
  os << "(" << p.first << "," << p.second << ")";
  return os;
}
#ifdef __LOCAL
#define debug(x) cerr << __LINE__ << ": " << #x << " = " << x << endl
#define debugArray(x, n)                           \
  cerr << __LINE__ << ": " << #x << " = {";        \
  for (long long hoge = 0; (hoge) < (n); ++(hoge)) \
    cerr << ((hoge) ? "," : "") << x[hoge];        \
  cerr << "}" << endl
#else
#define debug(x) (void(0))
#define debugArray(x, n) (void(0))
#endif

signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N, M;
  cin >> N >> M;
  priority_queue<int> pq;
  for (int i = 0; i < N; i++) {
    int A;
    cin >> A;
    pq.push(A);
  }
  while (M--) {
    int a = pq.top();
    pq.pop();
    pq.push(a / 2);
  }
  long long ans = 0;
  while (!pq.empty()) ans += pq.top(), pq.pop();
  cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 3868
#include<iostream>
#include<stdio.h>
using namespace std;
int main(){
    double a,b,c,d,e,f;
    double x,y;
    while(cin>>a>>b>>c>>d>>e>>f){
    x=(double)((e*c-b*f)/(a*e-b*d));
    y=(double)((-(d*c)+a*f)/(a*e-b*d));
    if(x==0){
        x=0;
    }
    if(y==0){
        y=0;
    }
    printf("%.3f %.3f\n",x,y);
    }
}

Measured memory_bytes: 3192
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0;i<static_cast<int>(n);++i)
#define per(i, n) for(int i=static_cast<int>(n)-1;i>=0;--i)
#define eee(a) (cerr<<"[@"<<__LINE__<<"] "<<(#a)<<": "<<(a)<<'\n');
#define ppp(a) (cout<<(a)<<'\n'); 
#define cop(a) for(auto x:(a)){cerr<<(x)<<'\n';}
using ll = long long;
constexpr int dx[4]={1,0,-1,0};
constexpr int dy[4]={0,1,0,-1};
constexpr ll MOD = 1e9+7;
constexpr ll Mod = 998244353;
constexpr int INF = 1e9;
constexpr ll LINF = 1e18;
constexpr double phi = (1+sqrt(5))/2;
constexpr double pi = 3.14159265358979323846264338327950288;
inline ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
inline ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
inline ll inverse(ll n,ll m=MOD){ll a=n,b=m,x=1,y=0;while(b){ll t=a/b;a-=t*b;swap(a,b);x-=t*y;swap(x,y);}return (a%m+m)%m;}
inline void Yes(){puts("Yes");}
inline void No(){puts("No");}
inline void Judge(bool b){b?Yes():No();}
inline void YES(){puts("YES");}
inline void NO(){puts("NO");}
inline void JUDGE(bool b){b?YES():NO();}
inline ll powmod(ll b, ll e, ll m=MOD){ll r=1;while(e>0){if(e&1)r=(r%m)*(b%m)%m;b=(b%m)*(b%m)%m;e>>=1;}return r;}
inline double distance(ll x1, ll y1, ll x2, ll y2){return sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2));}
inline double d2r(double d){return d*pi/180;}
inline double r2d(double r){return r*180/pi;}
template<class T>inline bool chmax(T &a, const T &b){if(a<b){a=b;return 1;}return 0;}
template<class T>inline bool chmin(T &a, const T &b){if(b<a){a=b;return 1;}return 0;}
template<typename T>inline int bs(int g,int k,T c){while(abs(k-g)>1){int m=(g+k)/2;(c(m)?k:g)=m;}return k;}
template<typename T1,typename T2>ostream& operator<<(ostream& s,const pair<T1, T2>& p){return s <<"("<<p.first<<", "<<p.second<<")";}
template<typename T> ostream& operator<<(ostream& s,const vector<T>& v){s<<'[';for(size_t i=0;i<v.size();++i){s<<v[i];if(i<v.size()-1)s<<", ";}s<<']';return s;}
template<typename T> istream& operator>>(istream& s,vector<T>& v){for(T& x:v)s>>x;return s;}

int main(){
    cin.tie(0); ios::sync_with_stdio(0); cout<<fixed<<setprecision(15);
    
    int n;
    cin >> n;
    map<ll, int> problems;
    for(int i = 0; i < n; ++i){
        ll d; cin >> d;
        problems[d]++;
    }
    int m;
    cin >> m;
    bool ok = true;
    for(int i = 0; i < m; ++i){
        ll t; cin >> t;
        if(problems[t] > 0){
            problems[t]--;
        }else{
            ok = false;
            break;
        }
    }
    JUDGE(ok);
    
    
    return 0;
}


Measured memory_bytes: 12800
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")
elif x < 2000:
    print("1")

Measured memory_bytes: 9160
/* ex 9_1
   cy_an  */

#include <stdio.h>
#include <stdlib.h>
//スタックに格納するデータの最大数
#define SIZE 10

//スタックの定義
typedef struct stack{
    int size;
    int count;
    char data[SIZE];
    char *top;
} stack;

//スタックの初期化
void initialize_stack(stack *stk){
    stk->count = 0;
    stk->size = SIZE;
    stk->top = &(stk->data[SIZE]);
}

//データの追加
void push(stack *stk, char elem){
    if(stk->count >= stk->size){
        fprintf(stderr, "Error: stack overflow. (x=%c)\n", elem);
        exit(1);
    }
    else{
        stk->top--;
        *(stk->top) = elem;
        stk->count++;
    }
}

//データの取り出し
char pop(stack *stk){
    char latest;
    if(stk->count <= 0){
        fprintf(stdout, "Error: stack underflow.\n");
        exit(1);
    }
    else{
        latest = *(stk->top);
        stk->top++;
        stk->count--;
        return latest;
    }
}

int main(void){
    stack input, output;
    char arr[SIZE];
    int i=0;
    
    //スタックを初期化
    initialize_stack(&input);
    initialize_stack(&output);

    //スタックにデータを追加
    scanf("%s", arr);
    while(arr[i] != '\0'){
        if(arr[i] == 'B'){
            if(input.count > 0){
                pop(&input);
            }
        }else{
            push(&input, arr[i]);
        }
        i++;
    }
    // スタックから別のスタックへ移して並べ替え
    while(input.count > 0){
        push(&output, pop(&input));
    }
    // スタックから要素を取り出して出力
    while(output.count > 0){
        printf("%c", pop(&output));
    }
    return 0;
}

Measured memory_bytes: 1620
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] Array = new int[n];
		// Array?????°????????£??\
		for(int i = 0; i < n; i++) {
			Array[i] = sc.nextInt();
		}
		System.out.print(Array[n-1]);
		for(int j = 0; j < n-1; j++) {
			System.out.print(" " + Array[n-2-j]);
		}
		System.out.println();
	}

}

Measured memory_bytes: 26124
#include <iostream>
#include <stdio.h>
#include <math.h>
using namespace std;
int main(){

	int a,b;
	char op;
	cin >> a >> op >> b;
	while(op!='?'){
	if(op=='+')cout << a+b << endl;
	if(op=='-')cout << a-b << endl;
	if(op=='*')cout << a*b << endl;
	if(op=='/')cout << a/b << endl;
	cin >> a >> op >> b;
	};


}
//?°???°?????\???6??????

Measured memory_bytes: 1160
#include<cstdio>
#include<iostream>
#include<cstring>
#include<algorithm>
#include<vector>
typedef long long ll;
typedef unsigned un;
typedef std::string str;
typedef std::pair<ll,ll> pll;
typedef std::pair<int,int> pii;
ll read(){ll x=0,f=1;char c=getchar();while(c<'0'||c>'9'){if(c=='-')f=-1;c=getchar();}while(c>='0'&&c<='9'){x=x*10+c-'0';c=getchar();}return f*x;}
ll max(ll a,ll b){return a>b?a:b;}
ll min(ll a,ll b){return a<b?a:b;}
void umax(ll& a,ll t){if(t>a)a=t;}
bool umin(ll& a,ll t){if(t<a)return a=t,1;return 0;}
#define MAXN 200011
#define MAXV 4011
const int mod=ll(1e9)+7;
ll f[MAXV][MAXV],a[MAXN],b[MAXN];
int D=2001;
ll fac[MAXV*2],inv[MAXV*2];
ll Qpow(ll a,ll p)
{
    ll res=1;
    while(p)
    {
        if(p&1)res=res*a%mod;
        a=a*a%mod,p>>=1;
    }
    return res;
}
void init()
{
    fac[0]=inv[0]=1;
    for(ll i=1;i<MAXV*2;++i)fac[i]=fac[i-1]*i%mod,inv[i]=Qpow(fac[i],mod-2);
}
ll C(ll n,ll m){return fac[n]*inv[m]%mod*inv[n-m]%mod;}
int main()
{
    init();
    ll n=read();
    for(ll i=1;i<=n;++i)a[i]=read(),b[i]=read(),++f[D-a[i]][D-b[i]];
    for(ll i=1;i<MAXV;++i)
        for(ll j=1;j<MAXV;++j)f[i][j]=(f[i][j]+f[i][j-1]+f[i-1][j])%mod;
    ll ans=0;
    for(ll i=1;i<=n;++i)ans=(ans+f[D+a[i]][D+b[i]]-C(2*a[i]+2*b[i],2*a[i]))%mod;
    printf("%lld",(ans*inv[2]%mod+mod)%mod);
    return 0;
}

Measured memory_bytes: 132584
_N, k = map(int, input().split())
a = [int(input()) for _i in range(_N)]

n = 300002

def init_max(init_max_val):
    #set_val
    for i in range(n):
        seg_max[i+num_max-1]=init_max_val[i]    
    #built
    for i in range(num_max-2,-1,-1) :
        seg_max[i]=max(seg_max[2*i+1],seg_max[2*i+2]) 
    
def update_max(k,x):
    k += num_max-1
    seg_max[k] = x
    while k:
        k = (k-1)//2
        seg_max[k] = max(seg_max[k*2+1],seg_max[k*2+2])
    
def query_max(p,q):
    if q<=p:
        return ide_ele_max
    p += num_max-1
    q += num_max-2
    res=ide_ele_max
    while q-p>1:
        if p&1 == 0:
            res = max(res,seg_max[p])
        if q&1 == 1:
            res = max(res,seg_max[q])
            q -= 1
        p = p//2
        q = (q-1)//2
    if p == q:
        res = max(res,seg_max[p])
    else:
        res = max(max(res,seg_max[p]),seg_max[q])
    return res

#####単位元######
ide_ele_max = -1

#num_max:n以上の最小の2のべき乗
num_max =2**(n-1).bit_length()
seg_max=[ide_ele_max]*2*num_max

A = [0]*300002
init_max(A)

for i in range(_N):
    update_max(a[i], query_max(max(0, a[i]-k), min(300001, a[i]+k+1))+1)

print(query_max(0,300001))

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

int main()
{
  int n;
  cin >> n;
  vector<int> p(n);
  for (int &x : p)
    cin >> x;

  int min = n + 1;
  int count = 0;
  for (int i = 0; i < n; i++)
  {
    if (p.at(i) < min)
    {
      min = p.at(i);
      count++;
    }
  }
  cout << count << endl;
}

Measured memory_bytes: 1024
#include <stdio.h>

int main()
{
	int A, B, K;
	scanf("%d %d %d", &A, &B, &K);

	int i=A;
	for(int k=0; k<K; i--){
		if((A%i==0) && (B%i==0)){
			k++;
		}
	}
	printf("%d\n", i+1);
	return 0;
}


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



int main() {
    int n;
    cin >> n;
    
    vector<int> h(n);
    rep(i,n) {
        cin >> h[i];
    }
    
    int ans, cnt;
    ans = cnt = 0;
    rep(i,n-1) {
        if(h[i] >= h[i+1]) {
            //cout << i << endl;
            cnt++;
        }
        else {
            ans = max(ans,cnt);
            cnt = 0;
        }
    }
    ans = max(ans,cnt);
    
    cout << ans << endl;
    
    
    return 0;
}


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

ll N, A[500000], rui[500000], sum[500000], ans;
vector<int> G[1048576];

int main(){
	cin >> N;
	rep(i, N) cin >> A[i];
	rui[0] = A[0];
	rep(i, N-1) rui[i+1] = rui[i] ^ A[i+1];
	rep(i, N){
		G[rui[i]].push_back(i);
		if(i == 0) sum[i] = (rui[i])?0:1;
		else sum[i] = sum[i-1] + ((rui[i])?0:1);
	}
	if(rui[N-1] == 0){
		ll s = 1;
		rep(i, sum[N-1] - 1) s = (s * 2) % mod;
		ans = s;
	}
	for(int i=1; i<1048576; i++){
		int p = G[i].size();
		if(!p) continue;
		if(rui[N-1] && i != rui[N-1]) continue;
		ll dp[p], su = 1;
		dp[p-1] = 1;
		for(int j=p-2; j>=0; j--){
			int num = sum[G[i][j+1]] - sum[G[i][j]];
			if(rui[N-1] != 0 && j == p-2){
				dp[j] = num;
				su += num;
				continue;
			}
			dp[j] = (su * num + dp[j+1]) % mod;
			su = (su + dp[j]) % mod;
		}
		ans = (ans + su) % mod;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 46196
package main

import "fmt"

func main() {
	var N, T int
	fmt.Scan(&N, &T)

	var c, t int
	ans := 999999
	for i := 0; i < N; i++ {
		fmt.Scan(&c, &t)
		if t <= T && c < ans {
			ans = c
		}
	}
	if ans == 999999 {
		fmt.Println("TLE")
		return
	}

	fmt.Println(ans)
}


Measured memory_bytes: 512
#include<iostream>
#include<string>
#include<algorithm>	
#include<cmath>
#include<map>
#include<vector>
#define int long long
using namespace std;
int test[51];
signed main() {
    int n, a, b; cin >> n;
    for (int h = 0; h < n; h++) {
        int sum = 0, num = 0, c = 0;
        for (int i = 0; i < 10; i++) {
            cin >> a;
            if (c == 0) {
                if (sum < a) { sum = a; }
                else if (num < a) { num = a; }
                else { cout << "NO" << endl; c++; }
            }
        }
        if (c == 0) { cout << "YES" << endl; }
    }
}


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

const int mod = 1e9+7;
const int INF = 200000000;

int N,M,X;
ll ans = INF;
int A[15][15],C[15];

void dfs(int n, int m) {
    if(n == N) {
        vector<int> g(M,0);
        ll tmp = 0;
        for(int i=0;i<N;++i) {
            if(m & (1<<i)) {
                tmp += C[i];
                for(int j=0;j<M;++j) g[j] += A[i][j];
            }
        }
        for(int s:g) {
            if(s < X) return;
        }
        ans = min(ans, tmp);
        return;
    }
    dfs(n+1, m*10+0);
    dfs(n+1, m*10+1);
}

int main() {
    cin >> N >> M >> X;
    int a;
    for (int i = 0; i < N; i++)
    {
        cin >> C[i];
        for (int j = 0; j < M; ++j)
        {
            cin >> A[i][j];
        }
    }
    dfs(0,0);
    if(ans == INF) cout << -1 << endl;
    else cout << ans << endl;
}


Measured memory_bytes: 3632
#include <iostream>
// #include <string>
 
using namespace std;
 
int main(){
  	int a, b;
  	cin >> a >> b;
	
	int c, d;
    c=1;
    for (int i=0; i<20; i=i+1 ){
		c = c + (a-1);
        if (c >= b) {
          d=i+1;
          break;
        }
    }	

  	if (b == 1){
    	d = 0;
    }
  
  	cout << d << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;
import java.util.Spliterator;
import java.util.Spliterators;
import java.util.concurrent.ThreadLocalRandom;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.stream.IntStream;
import java.util.stream.Stream;
import java.util.stream.StreamSupport;

public class Main{
	static final Scanner s=new Scanner(System.in);
	static final long[] fal_rnd(int size){
		AtomicInteger l=new AtomicInteger(-1),r=new AtomicInteger(size);
		long[] res=new long[size];
		INS(size).unordered().parallel().mapToLong(Long::parseLong).forEach(v->res[ThreadLocalRandom.current().nextBoolean()?l.incrementAndGet():r.decrementAndGet()]=v);
		return res;
	}
	static final IntStream REPS(int v){
		return IntStream.range(0,v);
	}
	static final Stream<String> INS(long size){
		return StreamSupport.stream(Spliterators.spliterator(s,size,Spliterator.NONNULL&Spliterator.IMMUTABLE),false).limit(size);
	}
	public static void main(String[]__){
		int a=s.nextInt(),b=s.nextInt(),c=s.nextInt();
		System.out.println(a<=c&&c<=b?"Yes":"No");
	}
}


Measured memory_bytes: 21844
#include<iostream>
#include<queue>
#include<algorithm>
#include<string>
#include<vector>
#include<cstdio>
using namespace std;
#define N 100000
#define M 300000
#define HT 1000000000
#define INF 2e18
#define int long long
#define MP(i, j) make_pair((i), (j))
typedef pair<int, int> P;
int n, m, x, ans = INF, tree[N + 1];
vector<P> g[N + 1];
int flag[N + 1] = {};


struct S {
	int to, ti, nh;
	S(int i_to, int i_ti, int i_nh) : to(i_to), ti(i_ti), nh(i_nh) {}
	bool operator < (const S & s)const {
	  if(ti != s.ti)
		return ti > s.ti;
	}
};
priority_queue<S> pq;
void dijkstra(int sta) {
	for (int i = 0; i < g[1].size(); i++) {
		if (tree[1] >= g[1][i].second) {
			if (sta >= g[1][i].second) {
				if (sta > g[1][i].second + tree[g[1][i].first]) {
					pq.push({g[1][i].first, sta - tree[g[1][i].first],  tree[g[1][i].first] });
				}
				else {
					pq.push({g[1][i].first, g[1][i].second, sta - g[1][i].second });
				}
			}
			else {
				if (g[1][i].second - sta <= tree[1])
					pq.push({g[1][i].first, g[1][i].second - sta + g[1][i].second, 0 });
			}
		}
	}
	while (!pq.empty()) {
		S s = pq.top();
		pq.pop();
		if (flag[s.to] && flag[s.to] <= s.ti) continue;
		flag[s.to] = s.ti;
		if (s.to == n) {
			ans = min(ans, tree[n] - s.nh + flag[s.to]);
			break;
		}
		for (int i = 0; i < g[s.to].size(); i++) {
			if (tree[s.to] >= g[s.to][i].second) {
			  if (s.nh >= g[s.to][i].second) {
					if (s.nh > g[s.to][i].second + tree[g[s.to][i].first]) {
						pq.push({g[s.to][i].first, s.nh - tree[g[s.to][i].first] + s.ti,  tree[g[s.to][i].first] });
					}
					else {
						pq.push({g[s.to][i].first, g[s.to][i].second + s.ti, s.nh - g[s.to][i].second });
					}
				}
				else {
					if (g[s.to][i].second - s.nh <= tree[s.to])
						pq.push({g[s.to][i].first, g[s.to][i].second - s.nh+ g[s.to][i].second + s.ti, 0 });
				}
			}
		}
	}
}
signed main() {
  scanf("%lld%lld%lld", &n, &m, &x);
	for (int i = 1; i <= n; i++)
		scanf("%lld", tree + i);
	for (int i = 0; i < m; i++) {
		int a, b, c;
		scanf("%lld%lld%lld", &a, &b, &c);
		g[a].push_back(MP(b, c));
		g[b].push_back(MP(a, c));
	}
		dijkstra(x);
	if (ans != INF)
		cout << ans << endl;
	else
		cout << -1 << endl;
}

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

int main(){
    int a, b;
    long long ab;
    cin >> a >> b;
    ab = atoi((to_string(a) + to_string(b)).c_str());
    
    for(int i = 1; i < ab/2 + 1; i++){
        if(i*i == ab){
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>

using namespace std;

int n;
vector<vector<int>> edge;//edge[from][i] = to_i;
int tree[100000];

void bfs() {
	queue<pair<int, int>> q;//owner node
	q.push(make_pair(1, 0)), q.push(make_pair(2, n - 1));
	tree[0] = 1, tree[n - 1] = 2;
	while (q.size()) {
		auto tmp = q.front(); q.pop();
		for (int i = 0; i < edge[tmp.second].size(); i++) {
			if (tree[edge[tmp.second][i]] == 0) {
				tree[edge[tmp.second][i]] = tmp.first;
				q.push(make_pair(tmp.first, edge[tmp.second][i]));
			}
		}
	}
}

int main() {
	cin >> n;
	edge.resize(n);
	for (int i = 0; i < n - 1; i++) {
		int a, b;
		cin >> a >> b;
		a--, b--;
		edge[a].push_back(b);
		edge[b].push_back(a);
	}
	bfs();
	int ans = 0;
	for (int i = 0; i < n; i++) {
		if (tree[i] == 1)ans++;
	}
	if (ans > n - ans) {
		cout << "Fennec" << endl;
	}
	else cout << "Snuke" << endl;
	return 0;
}

Measured memory_bytes: 6272
//pragma
//#pragma GCC optimize("Ofast")
//#pragma GCC optimize("unroll-loops")

#include <bits/stdc++.h>

#define YOU using
#define DONT namespace
#define SAY std

YOU DONT SAY;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<ll,int> pli;
typedef pair<int,ll> pil;
typedef vector<int> vi;
typedef vector<pii> vii;
typedef vector<pll> vll;

#define REPP(i,a,b,d) for(int i=a;i<=b;i+=d)
#define REP(i,a,b) REPP(i,a,b,1)
#define REVV(i,a,b,d) for(int i=a;i>=b;i-=d)
#define REV(i,a,b) REVV(i,a,b,1)

#define FOR(i,a) for(int i=0; i<a; i++)
#define FORD(i,a) for(int i=(int)a-1; i>=0; i--)

#define pb push_back
#define F first
#define S second

const int OO = 1e9;
const ll INF = 1e18;

const int irand(int lo,int hi){
	return ((double)rand()/(RAND_MAX + 1.0)) * (hi-lo+1) + lo;
}

const ll lrand(ll lo,ll hi){
	return ((double)rand()/(RAND_MAX + 1.0)) * (hi-lo+1) + lo;
}

#define getc getchar
template<typename T>
T getnum(){
	int sign = 1;
	T ret = 0;
	char c;

	do{
		c = getc();
	}while(c == ' ' || c == '\n');
	if(c == '-')sign = -1;
	else ret = c-'0';
	while(1){
		c = getc();
		if(c < '0' || c > '9')break;
		ret = 10*ret + c-'0';
	}
	return sign * ret;
}

inline void ini(int& x){
	x = getnum<int>();
}

inline void scani(int& x){
	scanf("%d",&x);
}

//end of macro

int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    #define endl '\n'
    cout.setf(ios::fixed);
    cout.setf(ios::showpoint);
    cout.precision(10);
    
    string str;
    cin>>str;
    int ans = 0;
    for(int i=0, j=(int)str.size()-1; i<j; i++, j--){
    	if(str[i] != str[j])ans++;
	}
	cout << ans << endl;
    
    return 0;
}

Measured memory_bytes: 256
#include <iostream>

 

using namespace std;

 

int main()
{
   int a, b, ans1, ans2;
   cin >> a >> b;
   ans1=a*b;
   ans2=2*a+2*b;
   cout << ans1 << " " << ans2 << endl; 
   
   return 0;
}


Measured memory_bytes: 3076
from collections import defaultdict
from collections import deque
from string import ascii_uppercase
import sys, bisect, math, heapq

stdin = sys.stdin
read_int = lambda : list(map(int,stdin.readline().split()))
read_str = lambda : stdin.readline().rstrip()

N = read_int()[0]
A = read_int()

m = defaultdict(lambda: int())
def solve():
    for a in A:
        if m[a] != 0:
            return 'NO'
        else:
            m[a] += 1
    return 'YES'

if __name__ == "__main__":
    print(solve())

Measured memory_bytes: 33324
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int Y = sc.nextInt();
        int ansMan = -1;
        int ansGosen = -1;
        int ansSen = -1;

        for (int man = 0; man <= N; man++) {
            for (int gosen = 0; gosen <= N - man; gosen++) {
                for (int sen = 0; sen <= N - man - gosen; sen++) {
                    if (man * 10000 + gosen * 5000 + sen * 1000 == Y && man + gosen + sen == N) {
                        ansMan = man;
                        ansGosen = gosen;
                        ansSen = sen;
                    }
                }
            }
        }
        System.out.println(ansMan);
        System.out.println(ansGosen);
        System.out.println(ansSen);
        sc.close();
    }

}

Measured memory_bytes: 21972
V, E = map(int, input().split())
Edge = [[] for _ in range(V)]

for _ in range(E): #??£????????????
    u, v = map(int, input().split())
    Edge[u].append(v)
    Edge[v].append(u)
    
Group = [-1] * V #Group???????????????????????°?????????????±????????????????????????°?????????????????°??????????????????????????????
Cnt = 0 # Group???????????????????±????????????????

for i in range(V):
    if Group[i] == -1:
        Group[i] = Cnt
        Stack = [i]
        while Stack:
            v = Stack.pop()
            for c in Edge[v]:
                if Group[c] == -1:
                    Group[c] = Cnt
                    Stack.append(c)
        Cnt += 1

q = int(input())
for _ in range(q):
    s, t = map(int, input().split())
    print('yes' if Group[s] == Group[t] else 'no')

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

using namespace std;

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

  int N;
  cin >> N;
  vector<int> X(N, 0);
  for (int i = 0; i < N; ++i) {
    cin >> X.at(i);
  }

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

  int min = X.at(0);
  int max = X.at(N-1);

  int a = 0;
  for (int i = 0; i < N; ++i) {
    a += X.at(i) * X.at(i);
  }

  int min_sum = 100000000;
  for (int p = min; p <= max; ++p) {
    int sum = a;
    for (int k = 0; k < N; ++k) {
      sum += p * p - 2 * p * X.at(k);
    }
    if (min_sum > sum) {
      min_sum = sum;
    }
  }
  cout << min_sum << endl;
}


Measured memory_bytes: 3608
#include <iostream>
#include <stdio.h>
#include <math.h>
#include <string.h>
#include <algorithm>

using namespace std;

int main() {
	
	long a,b,c,d;
	long ac, ad, bc, bd,max;

	cin >> a >> b >> c >> d;
	ac = a * c;
	ad = a * d;
	bc = b * c;
	bd = b * d;

	max = ac;
	if (ad > max) max = ad;
	if (bc > max) max = bc;
	if (bd > max) max = bd;

	cout << max;



	return 0;
}

Measured memory_bytes: 3620
use proconio::input;
use std::collections::HashMap;

fn main() {
    input! {
        n: usize,
        a: [usize; n],
    }

    let m = 1000000007;
    let mut map = HashMap::new();

    for &na in &a {
        let tmp = prime_factorize(na);
        for &t in &tmp {
            let count = map.entry(t.0).or_insert(0);
            if *count < t.1 {
                *count = t.1;
            }
        }
    }

    let mut lcm = 1usize;
    for (key, value) in &map {
        let mut tmp = 1;
        for _ in 0..*value {
            tmp = tmp * key % m;
        }
        lcm = lcm * tmp % m;
    }

    let mut ans = 0usize;
    for &na in &a {
        ans = ans + lcm * modinv(na as isize, m as isize) as usize % m;
        ans %= m;
    }

    println!("{}", ans);
}

fn prime_factorize(mut n: usize) -> Vec<(usize, usize)> {
    let mut res = vec![];
    let mut a = 2;
    while a * a <= n {
        if n % a != 0 {
            a+=1;
            continue;
        }
        let mut ex = 0;

        while n % a == 0 {
            ex += 1;
            n /= a;
        }

        res.push((a, ex));
        a += 1;
    }
    if n != 1 {
        res.push((n, 1));
    }

    res
}

use std::mem;

fn modinv(mut a: isize, m: isize) -> isize {
    let mut b: isize = m;
    let mut u: isize = 1;
    let mut v = 0;

    while b != 0 {
        let t = a / b;
        a -= t * b;
        mem::swap(&mut a, &mut b);
        u -= t * v;
        mem::swap(&mut u, &mut v);
    }

    u %= m;

    if u < 0 {
        u += m;
    }
    u
}


Measured memory_bytes: 2756
#include <iostream>
#include <array>
#include <string>

using namespace std;

#define Rep(i, n) for(int i = 0; i < (int)(n); ++i)
#define For(i, s, n) for(int i = s; i < (int)(n); ++i)

int main() {
  array<int, 4001> sum_r;
  array<int, 4001> sum_g;
  array<int, 4001> sum_b;
  sum_r.fill(0);
  sum_g.fill(0);
  sum_b.fill(0);

  int n;
  cin >> n;

  string s;
  cin >> s;

  Rep(i, n) {
    int index = i + 1; // sum index
    sum_r[index] = sum_r[index - 1];
    sum_g[index] = sum_g[index - 1];
    sum_b[index] = sum_b[index - 1];
    
    auto c = s[i];
    if (c == 'R') {
      sum_r[index]++;
    } else if (c == 'G') {
      sum_g[index]++;
    } else if (c == 'B') {
      sum_b[index]++;
    }
  }

  unsigned long long answer = 0;
  Rep(i, n - 2) {
    For(j, i + 1, n - 1) {
      if (s[i] == s[j]) continue;

      // R
      if (
        (s[i] == 'G' && s[j] == 'B') ||
        (s[i] == 'B' && s[j] == 'G')
      ) {
        answer += sum_r[n] - sum_r[j + 1];
        int index = j + j - i;
        if (index < s.size() && s[j + j - i] == 'R') answer--;
      }

      // G
      if (
        (s[i] == 'R' && s[j] == 'B') ||
        (s[i] == 'B' && s[j] == 'R')
      ) {
        answer += sum_g[n] - sum_g[j + 1];
        int index = j + j - i;
        if (index < s.size() && s[j + j - i] == 'G') answer--;
      }

      // B
      if (
        (s[i] == 'R' && s[j] == 'G') ||
        (s[i] == 'G' && s[j] == 'R')
      ) {
        answer += sum_b[n] - sum_b[j + 1];
        int index = j + j - i;
        if (index < s.size() && s[j + j - i] == 'B') answer--;
      }
    }
  }

  cout << answer << endl;

  return 0;
}


Measured memory_bytes: 3672
#include <bits/stdc++.h>
using namespace std;
 
#define M 1000000007
 
#define mp make_pair
#define pb push_back
#define tri pair<int, pair<int, int> >
#define TRI(a,b,c) (make_pair(a,make_pair(b,c)))
 
typedef long long ll;
typedef long double ld;

int main() 
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    string s; cin>>s;
    int cnt=0;
    for(int i=0; i<3; i++)
    {
    	cnt+=(s[i]=='o');
    	
    }
    cout<<700+100*cnt<<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 rep2(i, x, n) for (int i = x; i < (n); i++)
#define all(n) begin(n), end(n)
struct cww
{
    cww()
    {
        ios::sync_with_stdio(false);
        cin.tie(0);
    }
} star;
const long long INF = numeric_limits<long long>::max();
typedef long long ll;
typedef vector<int> vint;
typedef vector<char> vchar;
typedef vector<vector<int>> vvint;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef unsigned long long ull;
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 (b < a)
    {
        a = b;
        return 1;
    }
    return 0;
}
int main()
{
    long double N, K;
    cin >> N >> K;
    vector<long double> p(N), s(N);
    rep(i, N)
    {
        cin >> p[i];
        if (i == 0)
            s[i] = p[i];
        else
        {
            s[i] = s[i - 1] + p[i];
        }
    }
    long double maxSum = 0;
    rep(i, N - K)
    {
        maxSum = max(maxSum, s[i + K] - s[i]);
    }
    if (N == K)
    {
        maxSum = s[N - 1];
    }
    cout << setprecision(10) << K / 2.0 + (maxSum) / 2.0;
    return 0;
}

Measured memory_bytes: 6528
#include<bits/stdc++.h>
#define rep(i,N) for(int i=0;i<(N);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
using namespace std;
const long long MOD = 1e9 + 7;
const long long INF = 1e12;
const int inf = 1e9;
typedef long long ll;
typedef pair<ll,int> P;
typedef set<int> S;
ll n;
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};
int maze[50][50];
void init(){
    for(int i=0;i<50;i++){
        for(int j=0;j<50;j++){
            maze[i][j]=inf;
        }
    }
}
int main(){
    int h,w;
    cin>>h>>w;
    int ans=0;
    string s[h];
    rep(i,h) cin>>s[i];
    for(int i = 0;i < h; i++){
        for(int j = 0;j < w; j++){
            if(s[i][j]=='#') continue;
            queue<pair<int,int>> qii;
            init();
            auto solve=[&](int i, int j,int count){
                //cout<<"aaa"<<endl;
                if(maze[i][j]!=inf) return ;//初めて行く地点ならば更新する
                //cout<<"bbb"<<endl;
                maze[i][j]=count;
                qii.push(pair<int,int> (i,j));
            };
            solve(i,j,0);
            while(!qii.empty()){
                int now_i=qii.front().first;
                int now_j=qii.front().second;
                qii.pop();
                for(int k=0;k<4;k++){
                    int new_i=now_i+dy[k];
                    int new_j=now_j+dx[k];
                    if(new_i<0 || new_j<0 || new_i>=h || new_j>=w) continue;
                    if(s[new_i][new_j]=='#') continue;
                    solve(new_i,new_j,maze[now_i][now_j]+1);
                }
            }
            for(int si=0;si<h;si++){
                for(int sj=0;sj<w;sj++){
                    if(maze[si][sj]==inf) continue;
                
                    ans=max(ans,maze[si][sj]);
                }
            }
        }
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
parseInt(x)=parse(Int,x)
parseMap(x::Array{SubString{String},1})=map(parseInt,x)

function main()
	n = readline() |> parseInt
	l = readline() |> split |> parseMap
	l = sort(l)
	t = 0
	for i in 1:2:2*n
		t += l[i]
	end
	println(t)
end
main()


Measured memory_bytes: 165864
N, A, B, C = gets.chomp.split.map(&:to_i)
L = N.times.map { gets.chomp.to_i }

def rec(i, a, b, c)
  if i == N
    return [a, b, c].min > 0 ? (A-a).abs + (B-b).abs + (C-c).abs : 100000
  end

  x = rec(i+1, a, b, c)
  y = rec(i+1, a+L[i], b, c) + (a.zero? ? 0 : 10)
  z = rec(i+1, a, b+L[i], c) + (b.zero? ? 0 : 10)
  w = rec(i+1, a, b, c+L[i]) + (c.zero? ? 0 : 10)

  return [x, y, z, w].min
end

puts rec(0, 0, 0, 0)


Measured memory_bytes: 1788
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdlib>
#include <map>
#include <iomanip>
#include <set>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define int long long
#define pie 3.141592653589793238462643383279
#define mod 1000000007
#define INF 1145141919364364
#define all(vec) vec.begin(),vec.end()
#define P pair<int,int>
#define S second
#define F first
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x%y);
}
int lcm(int x, int y) {
	return x / gcd(x, y)*y;
}
bool prime(int x) {
	for (int i = 2; i <= sqrt(x); i++) {
		if (x%i == 0)return false;
	}
	return true;
}

int kai(int x) {
	if (x == 1)return 1;
	return kai(x - 1)*x%mod;
}

int mod_pow(int x, int y, int moder) {
	int res = 1;
	while (y > 0) {
		if (y & 1)res = res * x%moder;
		x = x * x%moder;
		y >>= 1;
	}
	return res;
}

int comb(int x, int y) {
	if (y > x)return 0;
	if (x == y)return 1;
	return kai(x)* mod_pow(kai(x - y), mod - 2, mod) % mod * mod_pow(kai(y), mod - 2, mod) % mod;
}

int n, a, b;
vector<int> ta[114514];
queue<int> que;
int cnt1[114514], cnt2[114514];


signed main() {
	cin >> n;
	rep(i, n - 1) {
		cin >> a >> b;
		a--;
		b--;
		ta[a].push_back(b);
		ta[b].push_back(a);
	}
	que.push(0);
	fill(cnt1, cnt1 + n, INF);
	fill(cnt2, cnt2 + n, INF);
	cnt1[0] = 0;
	cnt2[n - 1] = 0;
	while (que.size()) {
		int p = que.front(); que.pop();
		rep(i, ta[p].size()) {
			int x = ta[p][i];
			if (cnt1[x] > cnt1[p] + 1) {
				cnt1[x] = cnt1[p] + 1;
				que.push(x);
			}
		}
	}
	que.push(n - 1);
	while (que.size()) {
		int p = que.front(); que.pop();
		rep(i, ta[p].size()) {
			int x = ta[p][i];
			if (cnt2[x] > cnt2[p] + 1) {
				cnt2[x] = cnt2[p] + 1;
				que.push(x);
			}
		}
	}
	int cnt3 = 0;
	rep(i, n) {
		if (cnt1[i] <= cnt2[i])cnt3++;
	}
	if (cnt3 > n - cnt3)cout << "Fennec" << endl;
	else cout << "Snuke" << endl;
}

Measured memory_bytes: 8320
##########
#import math
#import numpy as np
#import re
from operator import itemgetter #ex. sorted(l,key=itemgetter(0))
#from itertools import product as prod
#from itertools import permutations as perm
#from itertools import combinations as comb
#from itertools import combinations_with_replacement as combr
#from collections import Counter as counter

ii = lambda:int(input())
mi = lambda:list(map(int,input().split()))
ix = lambda x:list(input() for _ in range(x))
mix = lambda x:list(mi() for _ in range(x))
iix = lambda x:list(int(input()) for _ in range(x))
##########
def main(n,m,l):
    res = 0
    count = 0
    l = sorted(l,key=itemgetter(0))
    for a,b in l:
        if count + b < m:
            res += a * b
            count += b
            continue
        else:
            res += a * (m-count)
            count += (m-count)
    return res

n,m = mi()
l = mix(n)
print(main(n,m,l))

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

int64_t MOD = 1e9+7;
void add(int64_t& a, int64_t b){
    a = (a+b) % MOD;
}

int main(){
    string L;
    cin >> L;
    int N = L.size();
    static int64_t dp[100010][2];
    dp[0][0] = 1;
    for(int i=0; i<N; i++){
        add(dp[i+1][1], 3*dp[i][1]);
        if(L[i] == '1'){
            add(dp[i+1][0], 2*dp[i][0]);
            add(dp[i+1][1], dp[i][0]);
        }else{
            add(dp[i+1][0], dp[i][0]);
        }
    }

    int64_t ans = (dp[N][0] + dp[N][1]) % MOD;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 2048
#include<iostream>
#include<string>
using namespace std;
int main(){
	int a,b;
	while(cin>>a>>b){
		int h=a+b;
		int i=1;
		while(true){
			if(h<10)
				break;
			h/=10;
			i++;
		}
		cout<<i<<endl;
	}
	return 0;
}

Measured memory_bytes: 1160
#include <stdio.h>
char c[10]; const char d[3] = "ox";
int main() {
	while (~scanf("%s", &c)) {
		bool ok = false;
		for (int i = 0; i < 2; i++) {
			bool flag = false;
			if (c[0] == d[i] && c[1] == d[i] && c[2] == d[i]) flag = true;
			if (c[3] == d[i] && c[4] == d[i] && c[5] == d[i]) flag = true;
			if (c[6] == d[i] && c[7] == d[i] && c[8] == d[i]) flag = true;
			if (c[0] == d[i] && c[3] == d[i] && c[6] == d[i]) flag = true;
			if (c[1] == d[i] && c[4] == d[i] && c[7] == d[i]) flag = true;
			if (c[2] == d[i] && c[5] == d[i] && c[8] == d[i]) flag = true;
			if (c[0] == d[i] && c[4] == d[i] && c[8] == d[i]) flag = true;
			if (c[2] == d[i] && c[4] == d[i] && c[6] == d[i]) flag = true;
			if (flag) {
				ok = true; printf("%c\n", d[i]);
			}
		}
		if (!ok) {
			printf("d\n");
		}
	}
	return 0;
}

Measured memory_bytes: 2588
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<queue>
#include<stack>
#include<vector>
#include<map>
#define int long long
using namespace std;
const int maxn = 3e6+10;
const int mod = 1e9+7;

int read(){
	int x=0,f=1;
	char c=getchar();
	while(!isdigit(c)){if(c=='-')f=-1;c=getchar();}
	while(isdigit(c)){x=(x<<3)+(x<<1)+c-48;c=getchar();}
	return x*f;
}

int k,m,n;
int x,y,xx,yy;
int fac[maxn],inv[maxn],num=3e6;
int fpm(int x,int y){
	int sum=1;
	while(y){
		if(y&1)sum=1ll*sum*x%mod;
		x=1ll*x*x%mod;
		y>>=1;
	}
	return sum;
}
inline void init(){
	fac[0]=inv[0]=1;
	for(register int i=1;i<=num;i++)fac[i]=fac[i-1]*i%mod;
	inv[num]=fpm(fac[num],mod-2);
	for(register int i=num-1;i>=1;i--)inv[i]=inv[i+1]*(i+1)%mod;
	return;
}

int C(int x,int y){
	return fac[y]*inv[x]%mod*inv[y-x]%mod;
}

int A(int x,int y){
	return fac[y]*inv[x]%mod;
}

int solve(int n,int m){
	int sum=0;
	for(register int i=1;i<=n;i++){
		(sum+=C(i+1,i+m+1))%=mod;
	}
	return sum;
}

signed main(){
	init();
	x=read();y=read();
	xx=read();yy=read();
	int ans=0;
	for(register int i=x;i<=xx;i++){
		(ans+=C(i+1,yy+i+1)-C(i+1,y+i)+mod)%=mod;
	}
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 47104
#define _GLIBCXX_DEBUG//TLEの原因になるので注意！！！！！！！！！！！
#include<cmath>
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
vector<int> arr;
stack<int> st;
queue<int> qu;
queue<pair<int,int> > qu2;
priority_queue<int> pq;
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define rep2(i,n) for(int i=1; i<=(int)(n); i++)
#define mins(x,y) x=min(x,y)
#define maxs(x,y) x=max(x,y)
typedef set<int> set_t;
typedef set<string> set_g;
typedef complex<double> xy_t;
static const int NIL = -1;
static const int INF = 1000000007;
#define mp make_pair
#define sz(x) int(x.sise())
#define mod 1000000007
#define reps(i,s,n) for(int i = s; i < n; i++)
#define Rreps(i,n,e) for(int i = n - 1; i >= e; --i)
#define Rrep(i,n) Rreps(i,n,0)
deque<int> deq;
#define fi first
#define se second
//#define int long long

//cerrはコメントアウトしなくても通る//ただしTLEを引き起こすことがある

//const ll MOD = 998244353;
const ll MOD = (1e+9) + 7;
//const ll INF = 1LL << 60;
//typedef pair<ll,ll> P;
typedef pair<int, int> P;
bool chmx(int &a, int b) {
	if (b > a) {
		a = b;
		return true;
	}
	return false;
}

bool chmn(int &a, int b) {
	if (b < a) {
		a = b;
		return true;
	}
	return false;
}

int main(){
    int n,k;
    cin >> n>> k;
    int S[n];
    rep(i,n){
        S[i]=0;
    }
    rep(i,k){
        int d;
        cin >> d;
        rep(j,d){
            int a;
            cin >> a;
            a--;
            S[a]++;
        }
    }
    int ans=0;
    rep(i,n){
        if(S[i]==0){
            ans++;
        }
    }
    cout<<ans<<endl;
    return 0;
}



Measured memory_bytes: 3640
import sys
from collections import deque
sys.setrecursionlimit(10000000)
readline = sys.stdin.readline

def solve():
    H, W, K = map(int, readline().split())
    x1, y1, x2, y2 = map(int,readline().split())
    x1, y1, x2, y2 = (v - 1 for v in (x1, y1, x2, y2))
    C = [readline().rstrip() for i in range(H)]

    INF = 10 ** 10
    visited = [[INF] * W for i in range(H)]
    dist = [[0] * W for i in range(H)]

    dirs = [(1, 0), (0, 1), (-1, 0), (0, -1)]

    q = deque()

    q.append((x1, y1, 0))
    visited[x1][y1] = 0
    dist[x1][y1] = 0

    def aa(_i, _j, y, x, d):
        i, j = _i, _j
        for k in range(K):
            i += y
            j += x
            if not (0 <= i < H and 0 <= j < W):
                break
            if C[i][j] == '@':
                break
            if d > visited[i][j]:
                break
            if d == visited[i][j]:
                continue
            visited[i][j] = d
            dist[i][j] = d
            q.append((i, j, d))

    while q:
        i, j, d = q.popleft()
        for y,x in dirs:
            aa(i, j, y, x, d+1)
    
    if visited[x2][y2] == INF:
        print(-1)
    else:
        print(dist[x2][y2])
    
solve()


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

int main()
{
    string s;

    cin>>s;
    int n=s.size();
    for(int i=0;i<n;i++)
    {
        if(i%2==0)
        {
            if(s[i]=='L') return cout<<"No",0;
        }
        if(i%2==1)
        {
            if(s[i]=='R') return cout<<"No",0;
        }
    }
    cout<<"Yes";
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  string X;
  cin >>X;
  int a=X.size();
  for(int i=0; i<a-1; i++){
    if(X[i]=='S' && X[i+1]=='T'){
      X.erase(X.begin()+i, X.begin()+i+2);
      i-=2;
      a-=2;
    }
  }
  cout <<X.size()<<endl;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
int main(){
	int n,m; cin >> n >> m;
	int l=0, r=n;
	for(int i=0;i<m;i++){
		int li,ri; cin >> li >> ri;
		if(l<li)	l = li;
		if(ri<r)	r = ri;
	}
	if(l>r)		cout << 0 << endl;
	else		cout << r-l+1 << endl;
	return 0;
}

Measured memory_bytes: 256
N,*aa = map(int, open(0).read().split())

ans = [None]*(N//2) + aa[N//2:]

for i in range(N//2,0,-1):
    ans[i-1] = (sum(ans[2*i-1::i])%2)^aa[i-1]

p = sum(ans)
print(p)
if p:
    print(*(i+1 for i,v in enumerate(ans) if v))

Measured memory_bytes: 18448
#include<bits/stdc++.h>
using namespace std;
const int mod=998244353;
const int N=402;
void add(int &x,int y){
	x+=y;
	if(x>=mod){
		x-=mod;
	}
}
void sub(int &x,int y){
	x-=y;
	if(x<0){
		x+=mod;
	}
}
int mul(int x,int y){
	return (1ll*x*y)%mod;
}
int binpow(int x,int y){
	int tich=1;
	while(y){
		if(y&1){
			tich=mul(tich,x);
		}
		x=mul(x,x);
		y>>=1;
	}
	return tich;
}
int fact[N],inv[N],dp[2][N][N],a[N],b[N],ndp[2][N][N],sum=0;
signed main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	int n,i,j,k,l,z;
	cin>>n;
	for(i=1;i<=n;i++){
		cin>>a[i]>>b[i];
		sum+=a[i];
	}
	dp[0][0][0]=1; fact[0]=1;
	for(i=1;i<N;i++){
		fact[i]=mul(fact[i-1],i);
	}
	inv[N-1]=binpow(fact[N-1],mod-2);
	for(i=N-1;i>0;i--){
		inv[i-1]=mul(inv[i],i);
	}
	int temp=0;
	for(i=1;i<=n;i++){
		for(j=0;j<b[i];j++){
			temp=mul(temp,a[i]);
			if(j==0){
				temp=1;
			}
			for(k=0;k<N-a[i];k++){
				for(l=0;l<N-j;l++){
					for(z=0;z<2;z++){
						add(ndp[1-z][k+a[i]][l+j],mul(temp,mul(dp[z][k][l],inv[j])));
					}
				}
			}
		}
		for(k=0;k<N;k++){
			for(l=0;l<N;l++){
				for(z=0;z<2;z++){
					add(dp[z][k][l],ndp[z][k][l]);  ndp[z][k][l]=0;
				}
			}
		}
	}
	int ans=0;
	for(i=1;i<N;i++){
		for(j=0;j<N;j++){
			add(ans,mul(mul(mul(dp[1][i][j],fact[j]),binpow(i,mod-1-j)),mul(sum,binpow(i,mod-2))));
			sub(ans,mul(mul(mul(dp[0][i][j],fact[j]),binpow(i,mod-1-j)),mul(sum,binpow(i,mod-2))));
		}
	}
	cout<<ans;
}
/*
2
1 2
1 2
*/

Measured memory_bytes: 6184