akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstdio>
#include <cstring>

using namespace std;

const int N = 2e5 + 100, p = 1e9 + 7;

typedef long long LL;
LL inv[N], fac[N], f[N][2];

LL qmi(LL a, int b) {
	LL res = 1;
	for(; b; b >>= 1) {
		if( b & 1)
			res = res * a % p;
		a = a * a % p; 
	}
	return res;
}

void Com()
{
	fac[0] = inv[0] = 1;
	for(int i = 1; i <= 2e5; i ++) {
		fac[i] = fac[i - 1] * i % p;
		inv[i] = inv[i - 1] * qmi(i, p - 2) % p;
	//	printf("int[%d] = %lld\n", i, inv[i]);
	}
}

int main()
{
	int n, m, x, y;
	scanf("%d%d%d%d", &n, &m, &x, &y);
	Com();
	for(int i = y + 1; i <= m; i ++) {
		int a = n - x + i - 2, b = n - x - 1;
		f[i][0] = fac[a] * inv[b] % p * inv[a - b] % p;
	//	printf("%lld ", f[i][0]);
	}
//	puts("");
	LL res = 0;
	for(int i = y + 1; i <= m; i ++) {
		int a = x + m - i + 1 - 2, b = x - 1;
		LL t =  fac[a] * inv[b] % p * inv[a - b] % p;
		res = (res + t * f[i][0]) % p;
	//	printf("%lld\n", t);
	} 
	printf("%lld\n", res);
	return 0;
}

Measured memory_bytes: 7896
def main():
    N,M=map(int,input().split())
    X=[[0,0] for i in range(0,N)]
    for i in range(0,N):
        X[i][0],X[i][1]=map(int,input().split())

    X.sort()
    s=0
    cost=0
    for i in range(0,N):
        if s+X[i][1]>=M:
            cost+=(M-s)*X[i][0]
            break
        else:
            s+=X[i][1]
            cost+=X[i][0]*X[i][1]
    print(cost)

if __name__ == '__main__':
    main()

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

int w,h,ans;
char c[25][25];
int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};

void dfs(int y,int x)
{
	if(c[y][x]=='#') return;
	c[y][x]='#';
	++ans;
	for (int i = 0; i < 4; ++i)
	{
		int ny=y+dy[i],nx=x+dx[i];
		if(0<=ny&&ny<h&&0<=nx&&nx<w) dfs(ny,nx);
	}
	return;
}

int main(int argc, char const *argv[])
{
	while(cin>>w>>h,w)
	{
		ans=0;
		int x,y;
		for (int i = 0; i < h; ++i)
		{
			for (int j = 0; j < w; ++j)
			{
				cin>>c[i][j];
				if(c[i][j]=='@') y=i,x=j,c[i][j]='.';
			}
		}
		dfs(y,x);
		cout<<ans<<endl;
	}
	return 0;
}



Measured memory_bytes: 3112
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return true; } return false; }
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define mp make_pair
#define si(x) int(x.size())
const int mod=1000000007,MAX=200005;
const ll INF=1LL<<60;

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

void make(){
    
    fac[0]=fac[1]=1;
    finv[0]=finv[1]=1;
    inv[1]=1;
    
    for(int i=2;i<MAX;i++){
        inv[i]=mod-inv[mod%i]*(mod/i)%mod;
        fac[i]=fac[i-1]*(ll)i%mod;
        finv[i]=finv[i-1]*inv[i]%mod;
    }
    
}

ll comb(ll a,ll b){
    if(a<b) return 0;
    return fac[a]*(finv[b]*finv[a-b]%mod)%mod;
}

ll perm(ll a,ll b){
    if(a<b) return 0;
    return fac[a]*finv[a-b]%mod;
}

ll dp[MAX];

int main(){
    
    std::ifstream in("text.txt");
    std::cin.rdbuf(in.rdbuf());
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    make();
    int H,W,N;cin>>H>>W>>N;
    H--;W--;
    
    vector<pair<int,int>> S(N);
    for(int i=0;i<N;i++){
        int a,b;cin>>a>>b;
        a--;b--;
        S[i]=mp(a,b);
    }
    
    sort(all(S));
    
    for(int i=0;i<N;i++){
        dp[i]=comb(S[i].fi+S[i].se,S[i].fi);
        for(int j=0;j<i;j++){
            if(S[j].fi<=S[i].fi&&S[j].se<=S[i].se){
                dp[i]+=mod-dp[j]*comb(S[i].fi-S[j].fi+S[i].se-S[j].se,S[i].fi-S[j].fi)%mod;
                dp[i]%=mod;
            }
        }
    }
    
    ll ans=comb(H+W,H);
    
    for(int i=0;i<N;i++){
        ans+=mod-dp[i]*comb(H-S[i].fi+W-S[i].se,H-S[i].fi)%mod;
        ans%=mod;
    }
    
    cout<<ans<<endl;
}



Measured memory_bytes: 8316
N ,A ,B ,C ,D = list(map(int,input().split()))
S = input()
 
def judgeArrive(S, x, y):
  flag = "Yes"
  for i in range(x-1 ,y-2):
    if S[i] ==  S[i+1] == "#":
        flag = "No"
  return flag

def judgeJumpOver(S, x , y):
  flag = "No"
  for i in range(x-1 ,y):
    if S[i-1] ==  S[i] ==  S[i+1] == ".":
      flag = "Yes"
      break
 
  return flag
 
result = "Yes"
if(C > D):
  result = judgeJumpOver(S, B, D)
if(result == "Yes"):
  result = judgeArrive(S, B, D)
if(result == "Yes"):
  result = judgeArrive(S, A, C)
print(result)

Measured memory_bytes: 3572
a = int(input() )
b = int(input() )
c = int(input() )
if b > a:
  tmp = a
  a = b
  b = tmp
if c > b:
  tmp = c
  c = b
  b = tmp
if b > a:
  tmp = b
  b = a
  a = tmp
for x in range(7):
  d = int(input() )
  if d > a:
    c = b
    b = a
    a = d
  elif d > b:
    c = b
    b = d
  elif d > c:
    c = d
print(a)
print(b)
print(c)
  


Measured memory_bytes: 5588
#include <iostream>
#include <fstream>
#include <vector>
#include <string>
#include <map>
#include <sstream>
#include <queue>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <iterator>
#include <stack>
#include <list>
using namespace std;
#define INF 1000000000
typedef long long int lli;
typedef pair<int,int> P;

vector<int> cg[10];
int dp[10][2001];
int value[10][2001];

int main(){
	int n,k;
	cin >> n >> k;
	for(int i=0; i<n; ++i){
		int a,b;
		cin >> a >> b;
		cg[b-1].push_back(a);
	}
	memset(dp,0,sizeof(dp));
	memset(value,0,sizeof(value));
	for(int i=0; i<10; ++i){
		sort(cg[i].begin(),cg[i].end(),greater<int>());
	}
	for(int i=0; i<10; ++i){
		if(!cg[i].empty()){
			value[i][1]=cg[i][0];
			for(int j=2; j<=min((int)cg[i].size(),k); ++j){
				value[i][j]=cg[i][j-1]+value[i][j-1]+2*j-2;
			}
		}
	}
	int ans=0;
	/*
	for(int i=0;i <10; ++i){
		for(int j=0; j<=min()
		cout << dp[i][9] << "\n";
	}
	*/
	for(int i=0; i<=min((int)cg[0].size(),k); ++i){
		dp[0][i]=value[0][i];
	}
	for(int i=1; i<10; ++i){
		for(int j=0; j<=min((int)cg[i].size(),k); ++j){
			for(int l=0; j+l<=k; ++l){
				dp[i][j+l]=max(dp[i][j+l],dp[i-1][l]+value[i][j]);
				ans=max(ans,dp[i][j+l]);
				//cout << ans << "\n";
			}
		}
	}
	cout << ans << "\n";	
	return 0;
}

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

#define debug(s) cout << s << endl
#define debug1(s, t) cout << s << " " << t << endl
#define debug2(s, t, u) cout << s << " " << t << " " << u << endl
#define printvec(v)       \
    for (auto &&i : v)    \
        cout << i << " "; \
    cout << endl

using namespace std;
using i64 = long long;

int main()
{
    int n;
    cin >> n;

    auto l = [](double lhs, double rhs) { return lhs > rhs; };
    priority_queue<double, vector<double>, decltype(l)> pq(l);
    for (int i=0; i<n; i++)
    {
        int v;
        cin >> v;
        pq.push(v);
    }

    while (pq.size()>=2)
    {
        double x,y;
        x = pq.top();
        pq.pop();
        y = pq.top();
        pq.pop();
        pq.push((x+y)/2);
    }
    
    cout << pq.top() << endl;

    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<algorithm>
using namespace std;
int main()
{
	int i,n,sum=0,k,a[100005];
	scanf("%d%d",&n,&k);
	for (i = 0; i <n; i++)
	{
		scanf("%d",&a[i]);
	}
	sort(a,a+n);
    if(n>k)
	{
		sum++;
		n=n-k;
		if(n%(k-1)!=0)sum=sum+1+n/(k-1);
		else sum=sum+n/(k-1);
		printf("%d\n",sum);
	}
	else printf("1\n");
	return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <stack>
#include <queue>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
using namespace std;
#define int long long

signed main(){
    int a, b, c;
    cin >> a >> b >> c;
    bool ok = false;

    for(int i = 1; i * a <= 1e5; i++){
       if((a * i) % b == c)ok = true;
    }
    cout << (ok ? "YES" : "NO") << endl;

}

Measured memory_bytes: 256
// This file is a "Hello, world!" in C++ language by GCC for wandbox.
#include <iostream>
#include <cstdlib>
#include <bitset>
using namespace std;

int main()
{ 
    unsigned int bit[10];
    unsigned int ans = 0;
    
    bit[0] = 0b0111111;
    bit[1] = 0b0000110;
    bit[2] = 0b1011011;
    bit[3] = 0b1001111;
    bit[4] = 0b1100110;
    bit[5] = 0b1101101;
    bit[6] = 0b1111101;
    bit[7] = 0b0100111;
    bit[8] = 0b1111111;
    bit[9] = 0b1101111;
    int n, i;
    while(true){
    cin >> n;
    if(n==-1)break;
    int d[n];
    for(i=0; i<n; i++)cin >> d[i];
    ans = 0;
    cout << bitset<7> (ans ^ bit[d[0]]) << endl;
    for(i=1; i<n; i++){
        ans = bit[d[i-1]] ^ bit[d[i]];
        cout << bitset<7> (ans) << endl;
    }
    }
    return 0;
}

// GCC reference:
//   https://gcc.gnu.org/

// C++ language references:
//   https://cppreference.com/
//   https://isocpp.org/
//   http://www.open-std.org/jtc1/sc22/wg21/

// Boost libraries references:
//   https://www.boost.org/doc/



Measured memory_bytes: 3112
import java.util.Scanner;

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

        String[] array = scanner.nextLine().split(" ");
        int a = Integer.parseInt(array[0]);
        int b = Integer.parseInt(array[1]);

        if (a + b == 15) {
            System.out.println("+");
        } else if (a * b == 15) {
            System.out.println("*");
        } else {
            System.out.println("x");
        }
    }
}

Measured memory_bytes: 22736
k,n=map(int,input().split())
arr=list(map(int,input().split()))
ans=10**18
for i in range(n):
  dist1=(arr[i-1]-arr[i])%k
  dist2=arr[i]+(k-arr[(i+1)%n])%k
  ans=min(ans,dist1,dist2)
print(ans)

Measured memory_bytes: 26436
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

#define ALL(v) (v).begin(),(v).end()

using namespace std ;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;




int main()
{
  int n, k ;
  cin >> n >> k ;
  string s, t ;
  cin >> s ;
  vector<char> u(n) ;
  
  t = s.at(k-1) ;
  
  transform(t.begin(),t.end(),t.begin(),::tolower) ;
  
  rep(i, n){
    if(i==k-1){
      u.at(i) = t.at(0) ;
    }
    else{
      u.at(i) = s.at(i) ;
    }
  }
  
  rep(i,n){
    cout << u.at(i) ;
  }
  cout <<endl ;
    return 0 ;
}

/*　吾輩はやれば出来る子である。 
　　　　∩∩ 
　　　（´･ω･） 
　　 ＿|　⊃／(＿＿_ 
　／　└-(＿＿＿_／ 
　￣￣￣￣￣￣￣ 
　やる気はまだない 

　　 ⊂⌒／ヽ-、＿_ 
　／⊂_/＿＿＿＿ ／ 
　￣￣￣￣￣￣￣　　*/

Measured memory_bytes: 256
import java.util.ArrayDeque;
import java.util.Queue;
import java.util.Scanner;

public class Main {
    private static class Point {
        int x, y;

        public Point(int x, int y) {
            this.x = x;
            this.y = y;
        }
    }

    public void main(Scanner sc) {
        int h = sc.nextInt();
        int w = sc.nextInt();
        int map[][] = new int[h][w];
        int white = 0;
        for (int i = 0; i < h; i++) {
            String str = sc.next();
            for (int j = 0; j < w; j++) {
                if (str.charAt(j) == '#') {
                    map[i][j] = -1;
                } else {
                    white++;
                }
            }
        }

        int minTern = solveMaze(h, w, map);
        System.out.println(minTern != -1 ? white - minTern : minTern);
    }

    private int solveMaze(int h, int w, int map[][]) {
        int dx[] = { 1, 0, -1, 0 };
        int dy[] = { 0, 1, 0, -1 };
        Queue<Point> queue = new ArrayDeque<>();

        map[0][0] = 1;
        queue.add(new Point(0, 0));

        while (!queue.isEmpty()) {
            Point p = queue.poll();
            int now = map[p.y][p.x];
            for (int i = 0; i < 4; i++) {
                int nx = p.x + dx[i];
                int ny = p.y + dy[i];
                if (nx < 0 || nx >= w || ny < 0 || ny >= h || map[ny][nx] != 0) {
                    continue;
                }

                map[ny][nx] = now + 1;
                if ((nx == w - 1) && (ny == h - 1)) {
                    queue.clear();
                    return map[ny][nx];
                }
                queue.add(new Point(nx, ny));
            }
        }

        return -1;
    }

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


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

int main(){
    string str;
    // bool end_flag = false;
    rep(h,1200){
        cin >> str;
        if(cin.eof()) break;
        else if(h != 0) cout << " ";
        rep(i,str.size()){
            if(str[i] >= 'A' && str[i] <= 'Z'){
                str[i] += 0x20;
            }else if(str[i] >= 'a' && str[i] <= 'z'){
                str[i] -= 0x20;
            }
        }
        cout << str;
    }
    cout << endl;
}



Measured memory_bytes: 3224
#include<iostream>
#include<algorithm>
#include<string>
#include<functional>
#include<utility>
#include<stack>
#include<queue>
#include<cmath>
#include<list>
#include<cstdint>
#include<vector>
#include<map>
#define rep(i,rept)	for(ll i = 0; i<rept;i++)
typedef long long ll;
using namespace std;

ll nCr(ll n, ll r) {
	if (r > n) { return 0; }
	if (r * 2 > n) r = n - r;
	ll dividend = 1;
	ll divisor = 1;
	for (ll i = 1; i <= r; ++i) {
		dividend *= (n - i + 1);
		divisor *= i;
	}
	return dividend / divisor;
}
ll sumdigit(ll n) {
	ll dig = 0, sum = 0;
	while (n) {
		dig = n % 10;
		sum = sum + dig;
		n = n / 10;
	}
	return sum;
}


int main() {
	std::string s, res;
	bool find = false;
	std::cin >> s;
	for (int i = s.length() - 1; i >= 0; i--) {
		res += s[i];
	}
	int n = 0;
	while(n < res.length()){
		if (res.find("maerd", n) == n) {
			n += 5;
			find = true;
		}
		if (res.find("remaerd", n) == n &&find == false) {
			n += 7;
			find = true;
		}
		if (res.find("esare", n) == n &&find == false) {
			n += 5;
			find = true;
		}
		if (res.find("resare", n) == n &&find == false) {
			n += 6;
			find = true;
		}
		if (!find) {
			std::cout << "NO" << std::endl;
			return 0;
		}
		find = false;
	}
	std::cout << "YES" << std::endl;
	return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <cstring>
#include <cstdlib>
#include <cstdio>
#include <cmath>
#include <ctime>
#include <queue>
#include <set>
#include <map>
#include <string>
#include <bitset>
#include <vector>
#include <complex>
#include <algorithm>
using namespace std;
typedef long long ll;
typedef double db;
typedef pair<int,int> pii;
typedef vector<int> vi;
#define de(x) cout << #x << "=" << x << endl
#define rep(i,a,b) for(int i=a;i<(b);++i)
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define fi first
#define se second
int n;
vi B[1010];
map<ll,int> Mp;
vi CirA , CirB , Tmp , Block[4];
ll h[1010][4] , Min[1010];
ll C[1010][1010] = {{1}};
ll id(vi v){
    ll r = 0;
    rep(i,0,sz(v)) r = r * 1000 + v[i];
    return r;
}
ll Hash(vi v,int rot){
    Tmp = v;
    rep(i,0,4) Tmp[i] = v[(i+rot)&3];
    return id(Tmp);
}
ll solve(int a,int b,int rot){
    CirB = CirA = B[a];Tmp = B[b];
    swap(Tmp[0],Tmp[1]);swap(Tmp[2],Tmp[3]);
    rep(i,0,4) CirB[i] = Tmp[(i+rot)&3];
    ll hash[4][4] , mm[4] , cc[4] = {0};
    ll mul = 1;
    map<ll,int> Cnt;
    rep(i,0,4){
        Block[i] = vi{CirA[(i+1)&3] , CirA[i] , CirB[i] , CirB[(i+1)&3]};
        mm[i] = 1ll<<62;
        rep(j,0,4) hash[i][j] = Hash(Block[i] , j) , mm[i] = min(mm[i] , hash[i][j]);
        rep(j,0,4) cc[i] += hash[i][j] == hash[i][0];
        Cnt[mm[i]]++;
        mul *= cc[i];
    }
    static int f[10] = {1};
    rep(i,1,10) f[i] = f[i-1] * i;
    for(auto e : Cnt){
        ll x = e.fi;int y = e.se;
        if(Mp.count(x) == 0) return 0;
        int c = Mp[x];
        if(c < y) return 0;
        else mul *= C[c][y] * f[y];
    }
    return mul;
}


int main(){
    rep(i,1,1010) rep(j,0,1010) C[i][j] = j ? C[i-1][j-1] + C[i-1][j] : 1;
    scanf("%d",&n);
    rep(i,0,n){
        int x;rep(j,0,4) scanf("%d",&x) , B[i].pb(x);
    }
    rep(i,0,n) Min[i] = 1ll<<62;
    rep(i,0,n) rep(j,0,4) h[i][j] = Hash(B[i] , j) , Min[i] = min(Min[i] , h[i][j]);
    rep(i,0,n) Mp[Min[i]]++;
    ll ans = 0;
    rep(i,0,n) rep(j,i+1,n) rep(d,0,4){
        Mp[Min[i]]--;Mp[Min[j]]--;
        ans += solve(i , j , d);
        Mp[Min[i]]++;Mp[Min[j]]++;
    }
    ans /= 3;
    printf("%lld\n",ans);
    return 0;
}


Measured memory_bytes: 8448
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long ll;
typedef pair<ll,ll> P;
const ll mod=1000000007;
const ll LINF=1LL<<60;
const int INF=1<<30;

int main(){
	ll n;cin>>n;
	vector<ll> a(n);
	map<ll,ll> b;
	for(int i = 0; i < n; i++) {
		cin>>a[i];
		b[a[i]]++;
	}
	ll ans = 0;
	for(int i = 1; i <= n; i++) {
		ans += b[i] * (b[i] - 1) /2;
	}
	for(int i = 0; i < n; i++) {
		cout << ans - (b[a[i]] * (b[a[i]] - 1) / 2) + ((b[a[i]] - 1) * (b[a[i]] - 2) / 2) << endl;
	}
	return 0;
}

Measured memory_bytes: 16640
#include<iostream>
using namespace std;
typedef long long ll;
int main(){
    ll x,ans,r;
    cin>>x;
    ans=x/11;
    r=x-ans*11;
    ans*=2;
    if(r>0&&r<=6){
        ans+=1;
    }else if(r>=7){
        ans+=2;
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
while True:
    a, op, b = [i for i in input().split(' ')]
    a = int(a)
    b = int(b)
    if op == '?':
        exit()
    elif op == '+':
        print(a+b)
    elif op == '-':
        print(a-b)
    elif op == '*':
        print(a*b)
    elif op == '/':
        print(a//b)



Measured memory_bytes: 5604
N = int(input())
A = [0 for i in range(1001)]
mod = 10 ** 9 + 7
for n in range(2, N+1):
  m = n
  k = 2
  while m > 1:
    while m % k == 0:
      m //= k
      A[k] += 1
    k += 1
ans = 1
for i in range(1, 1001):
  ans = ans * (A[i] + 1) % mod
print(ans)

Measured memory_bytes: 66716
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		int h=sc.nextInt(),w=sc.nextInt();
		for(int i=0;i<h;i++) {
			String a=sc.next();
			System.out.println(a+"\n"+a);
		}
	}
}

Measured memory_bytes: 22996
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
struct edge{
	int u,v;
};
ll fa[100005],ans[100005],sz[100005];
int find(int x) {
	if(x==fa[x]) return x;
	return fa[x]=find(fa[x]);
}
int main(){
	edge e[100005];
	ll n,m;
	cin>>n>>m;
	for(int i=1;i<=m;i++){
		cin>>e[i].u;
		cin>>e[i].v;
	}
	for(int i=1;i<=n;i++){
		fa[i]=i;
		sz[i]=1;
	}
	ans[m]=(ll)n*(n-1)/2;
	for(int i=m;i>=1;i--){
		int u,v;
		u=find(e[i].u);
		v=find(e[i].v);
		if(u==v){
			ans[i-1]=ans[i];
		}
		else{
			ans[i-1]=ans[i]-sz[v]*sz[u];
			sz[v]+=sz[u];
			fa[u]=v;
		}
	}
	for(int i=1;i<=m;i++){
		cout<<ans[i]<<endl;
	}
	return 0;
}


Measured memory_bytes: 4480
n=int(input())

q=[input().split() + [i] for i in range(n)]
for i in range(n):
    q[i][1]=int(q[i][1])
p=sorted(sorted( q ,key=lambda x:x[1],reverse=1),key=lambda x:x[0])
for s,t,r in p:
    print(r+1)

Measured memory_bytes: 3060
N = int(input())

count = 0
flag = False
for _ in range(N):
  D1, D2 = map(int, input().split())
  if D1 == D2:
    count +=1
  else:
    count = 0

  if count == 3:
    flag = True


if flag:
  print("Yes")
else:
  print("No")




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

#define ALL(v) v.begin(), v.end()
#define V vector
#define P pair
using ll = long long;


int main() {
    int n, k; cin >> n >> k;
    V<ll> v(n);
    for(int i = 0; i < n; i++) cin >> v[i];

    ll ans = 1LL << 60;
    for(int bit = 0; bit < (1 << n); bit++){
        // 1がk個立っている場合のみ
        if(__builtin_popcount(bit) != k) continue;
        ll s = v[0] - 1, sum = 0;
        for(int i = 0; i < n; i++){
            if(bit & (1 << i)){
                if(v[i] <= s){
                    s++;
                    sum += s - v[i];
                }else{
                    s = v[i];
                }
            }else{
                s = max(s, v[i]);
            }
        }
        ans = min(ans, sum);
    }
    cout << ans << endl;

    return 0;
}


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

//ロスタイム計測
int lossTime(int n){
  if(n % 10 == 0){
    return 0;
  }
  else{
     return 10 - n % 10;
  }
}

//経過時間計算基幹処理
int cal(int n){
  if(n % 10 == 0){
    return n;
  }
  else{
     return n + 10 - (n % 10);
  }
}

//経過時間計算
int timeCount(int a, int b ,int c, int d, int e){
  return cal(a) + cal(b) + cal(c) + cal(d) + cal(e);
}

int main() {
  int A, B ,C, D, E;
  cin >> A >> B >> C >> D >> E;

  //次の注文までに最もロスの多いものを特定
  int ALoss = lossTime(A);
  int BLoss = lossTime(B);
  int CLoss = lossTime(C);
  int DLoss = lossTime(D);
  int ELoss = lossTime(E);
  int maxLoss = max({ALoss, BLoss, CLoss, DLoss, ELoss});

  int result = timeCount(A, B, C, D, E) - maxLoss;

  cout << result << endl;
}


Measured memory_bytes: 256
#!/usr/bin/env python3
n = int(input())
a = input()
b = input()
c = input()
cnt = 0
for i in range(n):
    if a[i] == b[i] == c[i]:
        pass
    elif a[i] == b[i] or b[i] == c[i] or c[i] == a[i]:
        cnt += 1
    else:
        cnt += 2
print(cnt)


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
 
int main(void)
{
    int N;
    cin >> N;
    vector<int> A(N);
    for (int i = 0; i < N; i++)
    {
        cin >> A[i];
    }
 
    sort(A.begin(), A.end(), greater<int>());
    priority_queue<int> queue;
 
    ll cmftblns = A[0];
    queue.push(A[1]);
    for(int i = 2; i < N; i++){
        if(i == 2){
            queue.push(A[2]);
            queue.push(A[2]);
            cmftblns += A[1];
        } else {
            int maxE = queue.top();
            cmftblns += maxE;
            queue.pop();
            
            queue.push(A[i]);
            queue.push(A[i]);
        }
    }
 
    cout << cmftblns << endl;
    
    return 0;
}


Measured memory_bytes: 5108
#include<bits/stdc++.h>
using namespace std;
int main(){
    int a,b;

    string s1,s2,s3;
    cin>>s1>>s2;
    cin>>a>>b;
    cin>>s3;
    if(s3.compare(s1)==0){
        a--;
    }
    else if(s3.compare(s2)==0){
        b--;
    }
    if(a<0){
        a=0;
    }
    if(b<0){
        b=0;
    }
    cout<<a<<" "<<b<<endl;




}









Measured memory_bytes: 256
a=b=c=ans=0
for _ in range(int(input())):
    s=input()
    ans+=s.count("AB")
    a+=s[-1]=="A"
    b+=s[0]=="B"
    c+=s[-1]+s[0]=="AB"
print(ans+min(a,b)-(0<a==b==c))


Measured memory_bytes: 9128
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define pb push_back
#define all(a) a.begin(), a.end()
#define sz(a) (int)a.size()
#define x first
#define y second
#define debug(...) cout << "[" << #__VA_ARGS__ << ": " << __VA_ARGS__ << "]\n"
#define rd() abs((int)rng())
using namespace std;
using namespace __gnu_pbds;
template<class T> using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
typedef long long ll;
typedef long double ld;
typedef pair<int, int>pii;
const int maxn = 1e5 + 100;
const int mod = 1e9 + 7;
mt19937 rng(chrono::high_resolution_clock::now().time_since_epoch().count());
int n;
vector<pair<pii, char> >pts;
ld chk(ld tim)
{
	ld xmin = 1e12, xmax = -1e12, ymin = 1e12, ymax = -1e12;
	for(auto pt : pts)
	{
		ld xval = pt.x.x, yval = pt.x.y;
		if(pt.y == 'U')
			yval += tim;
		if(pt.y == 'D')
			yval -= tim;
		if(pt.y == 'L')
			xval -= tim;
		if(pt.y == 'R')
			xval += tim;
		xmin = min(xmin, xval);
		xmax = max(xmax, xval);
		ymin = min(ymin, yval);
		ymax = max(ymax, yval);
	}
	return (xmax - xmin) * (ymax - ymin);
}
int main()
{
	ios_base::sync_with_stdio(false), cin.tie(0);
	cin >> n;
	for(int i = 0; i < n; i++)
	{
		pair<pii, char>a;
		cin >> a.x.x >> a.x.y >> a.y;
		pts.pb(a);
	}
	ld l = 0, r = 5e9;
	for(int i = 0; i < 200; i++)
	{
		ld m1 = l + (r - l) / 3, m2 = r - (r - l) / 3;
		if(chk(m1) < chk(m2))
			r = m2;
		else
			l = m1;
	}
	cout << setprecision(10) << fixed << chk(l) << "\n";
	return 0;
}

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

int main(){
    int n;
    while(cin >>n){
        if(n == 0) break;
        int i, ans = -1;
        bool fnd = false;
        for(i = 1; i <= 12; i++){
            int a, b; cin >>a >>b;
            n -= (a - b);
            if(n <= 0 && fnd == false){
                ans = i;
                fnd = true;
            }
        }
        if(fnd == false) cout <<"NA" <<endl;
        else cout <<ans <<endl;
    }
    return 0;
}

Measured memory_bytes: 1160
#include<cstdio>
#include<iostream>
using namespace std;
int main()
{
	int n;
	scanf("%d", &n);
	int tot = 0;
	while(n)
	{
		tot += n%10;
		n /= 10;
	}
	if(tot==1)
		cout<<10;
	else
		cout<<tot;
}

Measured memory_bytes: 256
import numpy as np

s = int(input())
A = list(map(int, input().split()))

A = np.array(sorted(A))
ans = A[0]
np.delete(A, 0)

while True:
    B = A % ans
    C = B[B != 0]
    if len(C) == 0:
        break
    ans = min(C)
    B = C

print(ans)

Measured memory_bytes: 23052
#include <bits/stdc++.h>
using namespace std;
using lint     = long long;
const lint inf = 1LL << 60;
const lint mod = 1000000007;

struct mint {
    lint v;
    lint _mod;
    mint() : v(0) {}
    mint(signed v, lint _mod = mod) : v(v), _mod(_mod) {}
    mint(lint t, lint _mod = mod) : _mod(_mod) {
        v = t % _mod;
        if (v < 0)
            v += _mod;
    }

    mint pow(lint k) {
        mint res(1), tmp(v);
        while (k) {
            if (k & 1)
                res *= tmp;
            tmp *= tmp;
            k >>= 1;
        }
        return res;
    }
    static mint add_identity() { return mint(0); }
    static mint mul_identity() { return mint(1); }
    mint inv() { return pow(_mod - 2); }

    mint &operator+=(mint a) {
        v += a.v;
        if (v >= _mod)
            v -= _mod;
        return *this;
    }
    mint &operator-=(mint a) {
        v += _mod - a.v;
        if (v >= _mod)
            v -= _mod;
        return *this;
    }
    mint &operator*=(mint a) {
        v = v * a.v % _mod;
        return *this;
    }
    mint &operator/=(mint a) { return (*this) *= a.inv(); }

    mint operator+(mint a) const { return mint(v) += a; };
    mint operator-(mint a) const { return mint(v) -= a; };
    mint operator*(mint a) const { return mint(v) *= a; };
    mint operator/(mint a) const { return mint(v) /= a; };

    mint operator-() const { return v ? mint(_mod - v) : mint(v); }

    bool operator==(const mint a) const { return v == a.v; }
    bool operator!=(const mint a) const { return v != a.v; }
    bool operator<(const mint a) const { return v < a.v; }
};
ostream &operator<<(ostream &os, mint m) { return os << m.v; }

struct Combination {
    vector<lint> fac, finv, inv;
    Combination(lint maxN) : fac(maxN + 100), finv(maxN + 100), inv(maxN + 100) {
        maxN += 100; // for safety
        fac[0] = fac[1] = 1;
        finv[0] = finv[1] = 1;
        inv[1]            = 1;
        for (lint i = 2; i <= maxN; ++i) {
            fac[i]  = fac[i - 1] * i % mod;
            inv[i]  = mod - inv[mod % i] * (mod / i) % mod;
            finv[i] = finv[i - 1] * inv[i] % mod;
        }
    }
    lint operator()(lint n, lint k) {
        if (n < k)
            return 0;
        if (n < 0 || k < 0)
            return 0;
        return fac[n] * (finv[k] * finv[n - k] % mod) % mod;
    }
};

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    lint r1, c1, r2, c2;
    cin >> r1 >> c1 >> r2 >> c2;
    Combination nCk(2000000);
    mint ret = 0;
    for (int r = r1 + 1; r <= r2 + 1; ++r) {
        ret += nCk(c2 + r, r);
        ret -= nCk(c1 - 1 + r, r);
    }
    cout << ret << "\n";
    return 0;
}

Measured memory_bytes: 47104
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <set>
#include <map>
#include <numeric>
#include <regex>
#include <tuple>
#include<iomanip>
using namespace std;

typedef long long ll;
typedef pair<int, int> P;
#define MOD 1000000007 // 10^9 + 7
#define INF 1000000000 // 10^9
#define LLINF 1LL<<60


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

	int N, L; cin >> N >> L;
	int s = N * (L - 1) + N * (N + 1) / 2;

	if (L + N - 1 < 0) {
		cout << s - (L + N - 1) << endl;
	}
	else if (L < 0) {
		cout << s << endl;
	}
	else { // 0 <= L < L+N-1
		cout << s - L << endl;
	}
	

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define meow(args...) fprintf(stderr, args)
template<class T1, class T2> inline bool cmin(T1 &a, const T2 &b) {return b<a?(a=b, true):false;}
template<class T1, class T2> inline bool cmax(T1 &a, const T2 &b) {return a<b?(a=b, true):false;}
template<class Type> Type read() {
	Type a;
	bool b;
	unsigned char c;
	while(c=getchar()-48, (c>9)&(c!=253));
	for(a=(b=c==253)?0:c; (c=getchar()-48)<=9; a=a*10+c);
	return b?-a:a;
}
auto rd=read<int>;
typedef unsigned u32;
typedef long long s64;
typedef unsigned long long u64;

const int N=3e5+1;
int n, p[N];
void gg() {
	puts("No");
	exit(0);
}
int main() {
	n=rd();
	for(int i=1; i<=n; ++i) p[i]=rd();
	for(int l=1, r; l<=n; l=r+1) {
		int min=n+1, max=0;
		while(l<=n&&l==p[l]) ++l;
		if(l>n) break;
		for(r=l; r+2<=n&&r+1==p[r+1]&&r+2!=p[r+2]; r+=2);
		for(int i=l; i<=r; ++i) cmin(min, p[i]), cmax(max, p[i]);
		if(min!=l||max!=r) gg();
		for(int i=l, x=0, y=0; i<=r; i+=2) if(!cmax(p[i]<i?x:y, p[i])) gg();
	}
	puts("Yes");
	return 0;
}


Measured memory_bytes: 1408
#include <iostream>
#include <vector>
#include <string>
#include <math.h>
using namespace std;
#define ll long long int

int main()
{
	int h, w, K, input = 0;
	string s;
	int ans = 0;

	cin >> h >> w >> K;
	vector<vector<int>> gyoretu(h,vector<int>(w));
	for (int i = 0; i < h; i++) {
		cin >> s;
		for (int k = 0; k < w; k++) {
			if (s[k] == '.') input = 0;
			else if (s[k] == '#') input = 1;
			else cout << "not accepted" << endl;
			gyoretu.at(i).at(k) = input;
		}			
	}

	auto count_kuro_flag = [](vector<vector<int>> input, int raw, int colum) {
		int ans = 0;
		for (int i = 0; i < input.size(); i++) {
			for (int k = 0; k < input.at(0).size(); k++) {
				if (((raw >> i) & 0b01) == 1 || ((colum >> k) & 0b01) == 1) {
					continue;
				}else {
					if (input.at(i).at(k) == 1) ans++;
				}
			}
		}
		return ans;
	};
	
	for (int i = 0; i < (int)pow(2,h); i++) {
		for (int j = 0; j < (int)pow(2,w); j++) {
			if (count_kuro_flag(gyoretu, i, j) == K) ans++;
		}
	}

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



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

int main() {
  int n=0;
  cin>>n;
  vector<vector<int>> ent(n,vector<int>(3));
  vector<vector<int>> dp(n,vector<int>(3));
  for(int i=0;i<n;i++) {
    cin>>ent[i][0]>>ent[i][1]>>ent[i][2];
  }
  dp[0]=ent[0];
  for(int i=1;i<n;i++) {
    dp[i][0]=ent[i][0]+max(dp[i-1][1],dp[i-1][2]);
    dp[i][1]=ent[i][1]+max(dp[i-1][0],dp[i-1][2]);
    dp[i][2]=ent[i][2]+max(dp[i-1][1],dp[i-1][0]);
  }
  cout<<max({dp[n-1][0],dp[n-1][1],dp[n-1][2]})<<endl;
  return 0;
}

Measured memory_bytes: 11136
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int K;
  cin >> K;
  vector<int> v = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
  cout << v.at(K-1) << endl; 
}

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

int _ceil(int a, int b) {
  int x = (a + b - 1) / b;
  return x;
}

int main() {
  int a, b;
  cin >> a >> b;

  int ans = _ceil(a + b, 2);
  cout << ans << endl;

  return 0;
}

int solve(int a, int b) {
  double x = (a + b) / 2.0;
  int ans = (int)x;
  if (x > ans) {
    ans++;
  }

  return ans;
}


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

using VS = vector<string>;    using LL = long long;
using VI = vector<int>;       using VVI = vector<VI>;
using PII = pair<int, int>;   using PLL = pair<LL, LL>;
using VL = vector<LL>;        using VVL = vector<VL>;

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))
#define FOR(i, s, e) for (int(i) = (s); (i) < (e); (i)++)
#define FORR(i, s, e) for (int(i) = (s); (i) > (e); (i)--)
//#pragma GCC optimize ("-O3") 
#ifdef YANG33
#include "mydebug.hpp"
#else
#define DD(x) 
#endif
const int INF = 1e9;                          const LL LINF = 1e16;
const LL MOD = 1000000007;                    const double PI = acos(-1.0);
int DX[8] = { 0, 0, 1, -1, 1, 1, -1, -1 };    int DY[8] = { 1, -1, 0, 0, 1, -1, 1, -1 };

/* -----  2018/10/23  Problem: ABC 088 C / Link: http://abc088.contest.atcoder.jp/tasks/abc088_c  ----- */
/* ------問題------



-----問題ここまで----- */
/* -----解説等-----



----解説ここまで---- */

LL ans = 0LL;

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

	VVI c(3, VI(3));
	FOR(i, 0, 3) {
		FOR(j, 0, 3) {
			cin >> c[i][j];
		}
	}

	FOR(a1, -400, 401) {
		VI b(3);
		FOR(i, 0, 3) {
			b[i] = c[0][i] - a1;
		}
		VI a(3);
		FOR(i, 0, 3) {
			a[i] = c[i][0] - b[0];
		}
		bool ok = 1;
		FOR(i, 0, 3) {
			FOR(j, 0, 3) {
				ok &= (a[i] + b[j] == c[i][j]);
			}
		}
		if (ok) {
			cout << "Yes" << endl; return 0;
		}
	}
	cout << "No" << endl;

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  int x1,y1,x2,y2;
  cin >> x1 >> y1 >> x2 >> y2;
  int x3 = (y1-y2)+x2;
  int y3 = (x2-x1)+y2;
  int x4 = (y2-y3)+x3;
  int y4 = (x3-x2)+y3;
  cout << x3 << " " << y3 << " " << x4 << " " << y4 << endl;
}

Measured memory_bytes: 256
using System;

namespace ABC116_C___Grand_Garden
{
    class Program
    {
        static int[] garden;
        static void Main(string[] args)
        {
            Console.ReadLine();
            garden = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
            Console.WriteLine(watering(0, garden.Length - 1, 0));
        }

        static int watering(int left, int right, int bottom)
        {
            if (left == right) return garden[left] - bottom;

            int min = int.MaxValue;
            int minIndex = 0;
            for (int i = left; i <= right; i++)
            {
                if (garden[i] < min)
                {
                    min = garden[i];
                    minIndex = i;
                }
            }

            if (minIndex == left)
            {
                return watering(left + 1, right, min) + min - bottom;
            }
            else if (minIndex == right)
            {
                return watering(left, right - 1, min) + min - bottom;
            }
            else
            {
                return watering(left, minIndex - 1, min) + watering(minIndex + 1, right, min) + min - bottom;
            }
        }
    }
}


Measured memory_bytes: 11092
#include<stdio.h>

int main(){
  int W, H, x, y, r;
  scanf("%d %d %d %d %d", &W, &H, &x, &y, &r);

  if(x - r >= 0 && x + r <= W && y - r >= 0 && y + r <= H){
    printf("Yes\n");
  }
  else{
    printf("No\n");
  }
  
  return 0;
}



Measured memory_bytes: 2144
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <cstring>
#include <map>
#include <queue>
#include <cmath>
#include <complex> // complex<double> a(1.2 , 2.3);// real(): 1.2, imag()2.3
using namespace std;

#define MOD 1000000007
#define ll long long
#define ld long double
#define FOR(i,a,b) for(ll i=(ll)a;i<(ll)b;i++)
#define rep(i,n) FOR(i,0,n)
#define pb push_back
#define mp make_pair
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rmsame(a) sort(all(a)),a.erase(unique(all(a)), a.end())
#define rmvector(a,b) rep(i,a.size())rep(j,b.size())if(a[i]==b[j]){a.erase(a.begin()+i);i--;break;}
#define pq_pair_tB priority_queue <pair<ll,ll>, vector<pair<ll,ll> > , greater<pair<ll,ll> > >
#define pq_pair_ts priority_queue <pair<ll,ll> > //第二成分の大きさが関係ない
template<typename X> bool exist(vector<X> vec, X item){return find(all(vec), item)!=vec.end();}
ll gcd(ll a, ll b){if(b==0)return a;return gcd(b,a%b);}
ll lcm(ll a, ll b){return a/gcd(a,b)*b;}
ll power(ll x, ll n){if(n == 0) return 1;return  (n%2)? x*power(x, n-1)%MOD : power(x*x%MOD, n/2);}

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

    ll A, B, X;
    cin >> A >> B >> X;

    if(A <= X && X <= A+B) cout << "YES" << endl;
    else cout <<"NO" << endl;

    //cout << fixed << setprecision(16) << ans << endl;
    return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ABC_061A
{
    class Program
    {
        static void Main(string[] args)
        {
            int A, B, C;

            var word = Console.ReadLine().Split(' ');

            A = int.Parse(word[0]);
            B = int.Parse(word[1]);
            C = int.Parse(word[2]);

            if (C <= B && C >= A)
            Console.WriteLine("Yes");
            else
            Console.WriteLine("No");

            Console.ReadKey();
           
        }
    }
}


Measured memory_bytes: 11092
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);
        long N = sc.nextLong();
        long[] a = new long[(int) N];
        for (long i = 0 ; i < N ; i++) {
            a[(int) i] = sc.nextInt();
        }

        long count = 0;
        long r = 0;
        long add = 0;
        long xor = 0;

        for (int i = 0 ; i < N ; i ++) {
            while (r < N) {
                if (add + a[(int) r] == (xor ^ a[(int) r])) {
                    add += a[(int) r];
                    xor = (int) (xor ^ a[(int) r]);
                    r++;
                } else {
                    break;
                }

            }
            count = count + r - i;
            add -= a[i];
            xor -= a[i];
        }
        System.out.println(count);
    }




}

Measured memory_bytes: 73244
#include <bits/stdc++.h>
using namespace std;
 
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
 
const int N = 1e5 + 5;
 
int n, m, k;
int x11, y11, x2, y2;
int dx[4]={-1, +1, 0, 0};
int dy[4]={0, 0, +1, -1};
vector<vector<char> > a;
vector<vector<int> > vis, ways, dist;
 
void bfs(int x, int y)
{
	queue<pair<int, int> > q;
	q.push({x, y});
	vis[x][y] = 1;
	dist[x][y] = 0;
	while(!q.empty())
	{
		int x=q.front().first;
		int y=q.front().second;
		q.pop();
		for(int dir=0;dir<4;dir++)
		{
			for(int len = 1; len <= k; len++)
			{
				int nx=x+dx[dir] * len;
				int ny=y+dy[dir] * len;
				if(nx<1 || ny<1 || nx>n || ny>m)
					break;
				if(vis[nx][ny] && dist[x][y] + 1 > dist[nx][ny])
					break;
				if(a[nx][ny] == '@')
					break;
				if(vis[nx][ny])
					continue;
				dist[nx][ny]=dist[x][y]+1;
				vis[nx][ny]=1;
				q.push({nx, ny});
			}
		}
	}
}
 
int32_t main()
{
	IOS;
	cin >> n >> m >> k;
	cin >> x11 >> y11 >> x2 >> y2;
	a = vector<vector<char> > (n + 1, vector<char> (m + 1));
	vis = ways = dist = vector<vector<int> > (n + 1, vector<int> (m + 1, 0));
	for(int i = 1; i <= n; i++)
		for(int j = 1; j <= m; j++)
			cin >> a[i][j];
	bfs(x11, y11);
	if(!vis[x2][y2])
		cout << -1;
	else
		cout << dist[x2][y2];
	return 0;
}


Measured memory_bytes: 32516
#include <bits/stdc++.h>
#define INF 1e9
using namespace std;

#define REPR(i,n) for(int i=(n); i >= 0; --i)
#define FOR(i, m, n) for(int i = (m); i < (n); ++i)
#define REP(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define ALL(a)  (a).begin(),(a).end()
#define endl "\n"

template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return true; } return false; }
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
typedef long long ll;

void solve() {
    int R,G,B,N;
    cin >> R >> G >> B >> N;
    int cnt = 0;
    REP(r,3001) REP(g,3001) {
        int rest_balls = N - ((R*r) + (g*G));
        if (rest_balls < 0) continue;
        if (rest_balls%B == 0) cnt++;
    }
    cout << cnt << endl;
}

int main() {
    solve();
    return 0;
}

Measured memory_bytes: 3568
#include <bits/stdc++.h>
//#include <boost/multiprecision/cpp_int.hpp>
#define rep(i,m,n) for(int i=m;i<n;i++)
#define co(n) cout<<n<<endl
#define all(n) (n).begin(),(n).end()
#define pb(n,m) n.push_back(m)
#define pi(n,m) n.insert(n.begin(),m);
#define ee(n) n.erase(n.end()-1)
#define eb(n) n.erase(n.begin())
using namespace std;
//using bint=boost::multiprecision::cpp_int;
typedef long long ll;
typedef unsigned long long ull;

int main(){
  ll a,b,c,x,y;
  cin>>a>>b>>c>>x>>y;
  ll ans=10000000000000;
  ans=min(ans,a*x+b*y);
  ll z=min(x,y),s=abs(x-y),d;
  if(x>=y) d=a;
  else d=b;
  ans=min(ans,c*2*z+s*d);
  ans=min(ans,c*2*max(x,y));
  co(ans);
  
  return 0;
}

Measured memory_bytes: 3584
#include <iostream>
#include <vector>

using namespace std;

int main() {
	int n; cin >> n;
	vector<int> a(n + 1);
	for (int i = 1; i <= n; ++i)
		cin >> a[i];
	int cnt = 0;
	for (int i = n; i > 0; --i) {
		for (int j = 2 * i; j <= n; j += i) {
			a[i] = (a[i] + a[j]) % 2;
		}
		if (a[i]) cnt++;
	}
	cout << cnt << endl;
	for (int i = 1; i <= n; ++i) {
		if (a[i]) cout << i << " ";
	}
	cout << endl;

	return 0;
}

Measured memory_bytes: 1792
#include <algorithm>
#include <bitset>
#include <cstdio>
#include <cstdlib>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#define REP(i, b, n) for (Int i = b; i < Int(n); i++)
#define rep(i, n) REP(i, 0, n)
using namespace std;
using Int = long long;
Int inf = 1000000000000000001LL;
using vi = vector<Int>;
using vvi = vector<vi>;
using pii = pair<Int,Int>;
using mapis = unordered_map<Int,string>;
using mapii = unordered_map<Int,Int>;

Int GCD(Int a, Int b){
    if(b==0) return a;
    if(a < b) return GCD(b, a);
    unsigned r;
    while ((r=a%b)) {
        a = b;
        b = r;
    }
    return b;
}

Int LCM(Int a, Int b){
    return a*b/GCD(a,b);
}


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

    cin >> a >> b >> c;

    //cout <<std::fixed<< setprecision(10) <<  ans << endl;

    if(a+b+c>21){
        cout << "bust" << endl;
    }else{
        cout << "win" << endl;
    }





    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <math.h>
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rrep(i, n) for(int i = (n-1); i >= 0; i--)
using namespace std;
typedef long long ll;
const int MOD = 1000000007;
const ll INF = 1LL<<60;
const int IINF = 1000000000;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

struct mint {
    ll x;
    mint(ll x=0):x((x%MOD+MOD)%MOD){}
    mint operator-() const { return mint(-x);}
    mint& operator+=(const mint a) {
        if ((x += a.x) >= MOD) x -= MOD;
        return *this;
    }
    mint& operator-=(const mint a) {
        if ((x += MOD-a.x) >= MOD) x -= MOD;
        return *this;
    }
    mint& operator*=(const mint a) {
        (x *= a.x) %= MOD;
        return *this;
    }
    bool operator==(const mint a){
        return (x == a.x);
    }
    mint operator+(const mint a) const {
        mint res(*this);
        return res+=a;
    }
    mint operator-(const mint a) const {
        mint res(*this);
        return res-=a;
    }
    mint operator*(const mint a) const {
        mint res(*this);
        return res*=a;
    }
    mint pow(ll t) const {
        if (!t) return 1;
        mint a = pow(t>>1);
        a *= a;
        if (t&1) a *= *this;
        return a;
    }
    // for prime MOD
    mint inv() const {
        return pow(MOD-2);
    }
    mint& operator/=(const mint a) {
        return (*this) *= a.inv();
    }
    mint operator/(const mint a) const {
        mint res(*this);
        return res/=a;
    }
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}
// 2項係数を求める
struct combination {
    vector<mint> fact, ifact;
    combination(int n):fact(n+1),ifact(n+1) {
        assert(n < MOD);
        fact[0] = 1;
        for (int i = 1; i <= n; ++i) fact[i] = fact[i-1]*i;
        ifact[n] = fact[n].inv();
        for (int i = n; i >= 1; --i) ifact[i-1] = ifact[i]*i;
    }
    mint operator()(int n, int k) {
        if (k < 0 || k > n) return 0;
        return fact[n]*ifact[k]*ifact[n-k];
    }
};

//nが非常に大きく、aが小さい場合
mint choose(int n, int a){
    mint x = 1, y = 1;
    rep(i,a){
        x *= n-i;
        y *= i+1;
    }
    return x/y;
}

int main(){

    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    int N, K; cin >> N >> K;

    combination c(N+1);
    mint ans = 0;
    auto f2 = [&](ll n, ll k){
        return c(n+k-1, k-1);
    };
    auto f = [&](ll n, ll k){
        //if (n < k) return (mint)0;
        if (n == 0 && k == 0) return (mint)1;
        //if (k < 1) return (mint)0;
        return f2(n-k, k);
    };
    for(int i = 1; i <= K; i++){
        mint blue = f(K, i);
        mint red = f(N-K, i-1);
        red += f(N-K,i);
        red += f(N-K,i);
        red += f(N-K,i+1);
        mint ans = blue*red;
        cout << ans << endl;
    }
}

Measured memory_bytes: 3568
n = int(input())
a = input().split( )

b = []
j = 0
k = 1

for i in range(n):
  if k == int(a[i]):
    b.append(int(a[i]))
    j += 1
    k += 1

if 0 == len(b):
  print(-1)
else:
  print(int(n)-len(b))

Measured memory_bytes: 25768
S = gets.chomp
T = gets.chomp
idx = {}
S.chars.each_with_index{ |c,i|
  idx[c] ||= []
  idx[c] << i
}
idx.values.each{ |xs| xs << xs[0] + S.size }
ans = 0
j = 0
T.chars.each{ |c|
  xs = idx[c]
  if !xs
    p -1; exit
  end
  x = xs.bsearch{ |k| k >= j } + 1
  ans += x - j
  j = x % S.size
}
p ans


Measured memory_bytes: 15008
#include <iostream>

using namespace std;

int h, w; //縦,横
string mat[100];
bool a[100], b[100];

int main(){
    cin >> h >> w;
    for(int i = 0; i < h; i++){
        cin >> mat[i];
    }
    for(int i = 0; i < h; i++){
        bool flag = true;
        for (int j = 0; j < w; j++) {
            if(mat[i][j]=='#'){
                flag = false; 
            }
        }
        a[i] = flag;
    }
    for(int j = 0; j < w; j++){
        bool flag = true;
        for (int i = 0; i < h; i++) {
            if(mat[i][j]=='#'){
                flag = false;
            }
        }
        b[j] = flag;
    }
    for (int i = 0; i < h; i++) {
        if(a[i]){
            continue;
        }
        for (int j = 0; j < w; j++) {
            if(!b[j]){
                cout << mat[i][j];
            }
        }
        cout << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define repl(i, l, r) for (ll i = (l); i < (r); i++)
#define rep(i, n) repl(i, 0, n)
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()
#define CST(x) cout << fixed << setprecision(x)
using ll = long long;
const ll MOD = 1000000007;
const int inf = 1e9 + 10;
const ll INF = 4e18 + 10;
const int dx[9] = {1, 0, -1, 0, 1, -1, -1, 1, 0};
const int dy[9] = {0, 1, 0, -1, 1, 1, -1, -1, 0};
int main() {
	cin.tie(0);
	cout.tie(0);
	ios::sync_with_stdio(false);

	ll n;
	cin >> n;
	if (n % 2) {
		cout << 0 << endl;
	} else {
		n /= 2;
		ll cnt = 0;
		while (n) {
			cnt += n / 5;
			n /= 5;
		}
		cout << cnt << endl;
	}
	return 0;
}

Measured memory_bytes: 3616