akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define rept(i,n) for(int (i)=0;(i)<=(int)(n);(i)++)
#define reps(i,s,n) for(int (i)=(s);(i)<(int)(n);(i)++)
#define repst(i,s,n) for(int (i)=(s);(i)<=(int)(n);(i)++)
#define repr(i,n) for(int (i)=(n);(i)>=0;(i)--)
#define each(itr,v) for(auto (itr):(v))
#define all(c) (c).begin(),(c).end()
#define pb push_back
#define mp(x,y) make_pair((x),(y))
#define fi first
#define se second
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define ln "\n"
#define show(x) cout << #x << " = " << x ln
#define dbg(x) cout<<#x"="<<x ln

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vector<int> > mat;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

const int inf = (int)1e9;
const ll linf = (ll)1e18;
const int mod = (int)(1e9+7);
const int dx[] = {0, 1, 0, -1};
const int dy[] = {1, 0, -1, 0};
const int ddx[] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[] = {1, 1, 0, -1, -1, -1, 0, 1};

struct oreno_initializer {
	oreno_initializer() {
		cin.tie(0);
		ios::sync_with_stdio(0);
	}
} oreno_initializer;

// ━━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…
// .｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋
// ・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・

int n, m, a[50], b[50], cnt, ans;
bool e[50][50], t[50];

void dfs(int v) {
	t[v] = true;
	cnt++;
	rep(i,n) if (e[v][i] && !t[i]) dfs(i);
}

int main() {
	cin >> n >> m;
	rep(i,m) {
		cin >> a[i] >> b[i];
		a[i]--, b[i]--;
		e[a[i]][b[i]] = e[b[i]][a[i]] = true;
	}
	
	// i番目の道をeで通行止めにしてからdfsして、全頂点通れなかったらans++し、eを元に戻す
	rep(i,m) {
		cnt = 0;
		fill(t, t+n, false);
		e[a[i]][b[i]] = e[b[i]][a[i]] = false;
		dfs(0);
		if (cnt!=n) ans++;
		e[a[i]][b[i]] = e[b[i]][a[i]] = true;
	}
	cout << ans << ln;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define MOD 1000000007
#define md 998244353
#define INF LLONG_MAX
#define F first
#define S second
#define sz(x) (long long)x.size()
#define vi vector<int>
#define vll vector<long long>
#define vpl vector<pair<long long,long long> >
#define vpi vector<pair<int,int> >
#define pb push_back
#define debug(x) cerr<<#x<<"= "<<x<<endl
#define all(v) v.begin(),v.end()
#define TT ll test;cin>>test; while(test--)
#define rep(i,a,n) for(ll i=a;i<(long long)n;++i)
#define repr(i,n,a) for(ll i=n;i>(long long)a;--i)
#define endl '\n'
#define MAXN 100005
typedef long long ll;
typedef long double ld;
using namespace std;
#define int long long

signed main(){
    ios_base::sync_with_stdio(false);cin.tie(NULL);
    
    ll h,w;
    cin>>h>>w;
    string s[h];
    for(int i=0;i<h;i++){
    	cin>>s[i];
	}
	ll ans=0;
	ll dp[h+1][w+1]={};
	dp[0][1] = 1;
	for(int i=1;i<=h;i++){
		for(int j=1;j<=w;j++){
			if(s[i-1][j-1] == '#'){
				dp[i][j] = 0;
			}else{
				dp[i][j] = (dp[i-1][j] + dp[i][j-1]) % MOD;
			}
		}
	}
	cout << dp[h][w];

    return 0;
}

Measured memory_bytes: 12404
import heapq

N = int(input())
edges = {i: [] for i in range(N)}
for i in range(N - 1):
    a, b, c = map(int, input().split(" "))
    edges[a - 1].append((b - 1, c))
    edges[b - 1].append((a - 1, c))
Q, K = map(int, input().split(" "))

# Kからの最短距離を計算
dist = [-1 for i in range(N)]
que = []
heapq.heappush(que, (0, K - 1, -1)) # (distance, index, parent)
while len(que) > 0:
    d, ind, par = heapq.heappop(que)
    if dist[ind] != -1:
        continue
    dist[ind] = d
    for edge in edges[ind]:
        if edge[0] == par:
            continue
        heapq.heappush(que, (d + edge[1], edge[0], ind))

for _ in range(Q):
    x, y = map(int, input().split(" "))
    print(dist[x - 1] + dist[y - 1])

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

ll mod = 1000000007;

signed main(){
    int n,k;
    cin >> n>> k;
    int mmin=0;
    int mmax=0;
    int ans[n+2];
    ans[1]=n+1;
    for(int i=2;i<=n+1;i++){
        ans[i]=ans[i-1]+(n-(i-1))-(i-1);
    }
    int res=0;
    for(int i=k;i<=n+1;i++){
        res+=(ans[i]%mod);
        res%=mod;
    }
    cout << res << endl;
}

Measured memory_bytes: 5188
#import <stdio.h>
typedef long long INT;

int main() {
    INT N, K;
    scanf("%lld %lld", &N, &K);
    INT m = N/K;
    INT count = m*m*m;
    if (K%2==0) {
        INT l = (2*N+K)/(2*K);
        count += l*l*l;
    }
    printf("%lld",count);
}


Measured memory_bytes: 2164
//token = require('fs').readFileSync('tmp', 'ascii').toLowerCase()
//	.split(/[ \r\n]/); // win
token = require('fs').readFileSync('/dev/stdin', 'ascii').toLowerCase()
	.split(/[ \n]/); // linux

W = token.shift();
count = 0;
for (i in token) {
	word = token[i];
	if (word === 'END_OF_TEXT') break;
	if (word === W) count++;
}

console.log(count);

Measured memory_bytes: 15520
#include<iostream>
#include<vector>
#include<algorithm>
#include<iomanip>
#include<stack>
#include<queue>
#include<string>
#include<set>
#include<map>
#include<cmath>
#include<cstring>
using namespace std;
#define rep(i,n) for(int i=0;(i)<(n);(i)++)
#define FOR(i,m,n) for(int i=(m);(i)<(n);(i)++)
typedef long long ll;

int main(){
    int N;
    cin >> N;
    vector<int> a(N),b(N),c(N);
    rep(i,N)cin >> a[i];
    rep(i,N)cin >> b[i];
    rep(i,N-1)cin >> c[i];
    ll res = 0;
    rep(i,N){
        res +=b[a[i]-1];
        if(i>0)if(a[i-1]+1==a[i])res+=c[a[i-1]-1];
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

char island[12][13];
int island_number[12][12];

void DFS(int i, int j)
{	
	if (i >= 0 && i + 1 <= 11 && j >= 0 && j <= 11){
		if (island[i + 1][j] == '1' && island_number[i][j] != island_number[i + 1][j]){
			island_number[i + 1][j] = island_number[i][j];
			DFS(i + 1, j);
		}
	}
		
	if (i - 1 >= 0 && i <= 11 && j >= 0 && j <= 11){
		if (island[i - 1][j] == '1' && island_number[i][j] != island_number[i - 1][j]){
			island_number[i - 1][j] = island_number[i][j];
			DFS(i - 1, j);
		}
	}

	if (i >= 0 && i <= 11 && j >= 0 && j + 1 <= 11){
		if (island[i][j + 1] == '1' && island_number[i][j] != island_number[i][j + 1]){
			island_number[i][j + 1] = island_number[i][j];
			DFS(i, j + 1);
		}
	}

	if (i >= 0 && i <= 11 && j - 1 >= 0 && j <= 11){
		if (island[i][j - 1] == '1' && island_number[i][j] != island_number[i][j - 1]){
			island_number[i][j - 1] = island_number[i][j];
			DFS(i, j - 1);
		}
	}
}

int main(void)
{
	int i, j, num[12 * 12], cnt;
	
	while (scanf("%s", island[0]) != EOF){		
		for (i = 1; i < 12; i++){
			scanf("%s", island[i]);
		}
		
		for (i = 0; i < 12; i++){
			for (j = 0; j < 12; j++){
				island_number[i][j] = i * 12 + j + 1;
				num[i * 12 + j] = 0;
			}
		}
		
		for (i = 0; i < 12; i++){
			for (j = 0; j < 12; j++){
				if (island[i][j] == '1'){
					DFS(i, j);
				}
				else {
					island_number[i][j] = 0;
				}
			}
		}
		
		for (i = 0; i < 12; i++){
			for (j = 0; j < 12; j++){
				if (island_number[i][j] > 0){
					num[island_number[i][j] - 1] = 1;
				}
			}
		}
		
		for (i = 0, cnt = 0; i < 12 * 12; i++){
			if (num[i] == 1){
				cnt++;
			}
		}
		
		printf("%d\n", cnt);
	}
	
	return (0);
}

Measured memory_bytes: 552
#include <iostream>
using namespace std;
int main(void){
    unsigned int A, B, ret=0;
    
    std::cin >> A >> B;
    if(A < B) {
        ret = B;
        B--;
    }else{
        ret = A;
        A--;
    }
    
    if(A < B) {
        ret += B;
    }else{
        ret += A;
    }
        
    std::cout << ret << std::endl;
    
    return 0;
    
}


Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <iostream>
#include <math.h>
#include <assert.h>
#include <vector>
#include <queue>
#include <string>
#include <map>
#include <set>

using namespace std;
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
static const double EPS = 1e-9;
static const double PI = acos(-1.0);

#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++)
#define FOREQ(i, s, n) for (int i = (s); i <= (int)(n); i++)
#define FORIT(it, c) for (__typeof((c).begin())it = (c).begin(); it != (c).end(); it++)
#define MEMSET(v, h) memset((v), h, sizeof(v))

int len;
char A[40];
char B[40];

ll calc(string A, string B, int borrow, int depth, int rest);
ll NextState(string A, string B, int borrow, int depth, int rest) {
  int nborrow = 0;
  int c = A[depth] - B[depth] + '0' - borrow;
  if (c < '0') {
    c += 10;
    nborrow = 1;
  }
  A[depth] = c;
  return calc(A, B, nborrow, depth - 1, rest);
}
ll calc(string A, string B, int borrow, int depth, int rest) {
  if (depth == -1) { return atoi(A.c_str()); }
  ll ret = 0;
  if (rest != 0 && borrow) {
    ret = max(ret, NextState(A, B, 0, depth, rest - 1));
  }
  ret = max(ret, NextState(A, B, borrow, depth, rest));
  return ret;
}

int main() {
  MEMSET(A, '0');
  MEMSET(B, '0');
  int k;
  while (scanf("%s %s %d", A + 20, B + 20, &k) > 0) {
    len = strlen(A + 20);
    printf("%lld\n", calc(A + 20, B + 20 - (len - strlen(B + 20)), 0, len - 1, k));
    MEMSET(A, '0');
    MEMSET(B, '0');
  }
}

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

using namespace std;

#define YES cout << "YES" << endl;
#define NO  cout << "NO"  << endl;
#define Yes cout << "Yes" << endl;
#define No  cout << "No"  << endl;
 
#define INF INT_MAX
#define MOD 1000000007
#define PI  acos(-1)

using ll  = long long;
using ull = unsigned long long;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

#define rep(i, n) for (ll i = 0; i < (n); i++)
#define rrep(i, n) for (ll i = (n)-1; i >= 0; i--)

int main(int argc, char *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);

    ll N;
    cin >> N;

    vector<ll> A(N);
    rep (i, N) {
        cin >> A[i];
    }

    ll memo = 0;
    rep (i, N) {
        memo = max(memo, A[i]);
    }

    bool flag = false;
    ll cnt = 0;
    ll second = 0;
    rep (i, N) {
        if (memo != A[i]) {
            second = max(second, A[i]);
        } else {
            cnt++;
        }
    }

    if (cnt >= 2) {
        flag = true;
    }

    rep (i, N) {
        if (flag) {
            cout << memo << endl;
        } else {
            if (A[i] == memo) {
                cout << second << endl;
            } else {
                cout << memo << endl;
            }
        }
    }
    return 0;
}

Measured memory_bytes: 3200
input1 = input()
input2 = input()

N = int(input1)
h = list(map(int,input2.split()))

c = [0,abs(h[1]-h[0])]

for i in range(2,N):
  c.append(min(c[i-1]+abs(h[i]-h[i-1]),c[i-2]+abs(h[i]-h[i-2])))

print(c.pop())

Measured memory_bytes: 21084
x = int(input())
num = 100200
arr = list(range(2,num))
arr = set(arr)
primes = {2}
floor = int(num**0.5)+2

prime = min(arr)
while prime < floor:
    prime = min(arr)
    primes.add(prime)
    nonprime = {prime * i for i in range(1,num//prime + 2)}
    arr = arr.difference(nonprime)

primes = primes.union(arr)

sol = {i for i in primes if i >= x}

print(min(sol))

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

int v[50];
int min(int a, int b) { return a < b ? a : b; }
int max(int a, int b) { return a > b ? a : b; }

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

    int ans = 0;
    for(int l = 0; l < n; l++) {
        for(int r = l; r <= n; r++) {
            vector<int> g;
            for(int i = 0; i < l; i++) g.push_back(v[i]);
            for(int i = r; i < n; i++) g.push_back(v[i]);
            if(g.size() > k) continue;

            sort(g.begin(), g.end());
            int p = 0;
            for(p = 0; p < min(g.size(), k - g.size()); p++) {
                if(g[p] >= 0) break;
            }

            int s = 0;
            for(int i = p; i < g.size(); i++) s += g[i];
            ans = max(ans, s);
        }
    }

    printf("%d\n", ans);
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <iomanip>
using namespace std;
#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define fi first
#define se second
#define mp make_pair
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;

ll N,M,H,W,K,Q,A,B,L,R;
string S,T;
const ll MOD = (1e+9) + 7;
const ll INF = 1LL << 60;
typedef pair<ll,ll> P;

typedef vector<P> vp;
typedef vector<vp> matP;

const ll MAX_N = 1LL << 19;
mat bit(20,vec(MAX_N,0));//1-indexed
ll k = 0;
ll sum(ll i){
    ll s = 0;
    while(i > 0){
        s += bit[k][i];
        i -= i & -i;
    }
    return s;
}
void add(ll i, ll x){
    while(i < MAX_N){
        bit[k][i] += x;
        i += i & -i;
    }
}

bool simu(ll x, vec a) {
    vec s(N+1,0);
    reps(i,1,N+1){
        s[i] = s[i-1] + (a[i-1] >= x) - (a[i-1] < x);
    }
    //bit[i]への代入をbit[i+100010]に(個数保存用)
    ll ans = 0;
    reps(i,1,N+1){
        ans += (s[i] - s[0]) >= 0;
        ans += sum(s[i] + 100010);
        add(s[i] + 100010, 1);
        //cout<<x<<' '<<i<<' '<<ans<<endl;
    }
    return (ans >= ((N+1)*N/2 + 1LL)/2);
}

int main() {
    cin>>N;
    vec a(N);
    rep(i,N) cin>>a[i];
    vec sorted(N);
    rep(i,N) sorted[i] = a[i];
    sort(sorted.begin(),sorted.end());
    ll lb = 0, ub = N;
    while(ub - lb > 1){
        ll cen = (ub + lb)/2;
        (simu(sorted[cen], a) ? lb : ub) = cen;
        ++k;
    }
    cout<<sorted[lb]<<endl;
}


Measured memory_bytes: 86272
n = int(input())
als = list(map(int,input().split()))
a1 = 0
a2 = 0
als.sort(reverse=1)
# print(als)
i = 0
while i < n-1:
    # print(i)
    if als[i] == als[i+1] and a1 == 0:
        a1 = als[i]
        i += 2
        continue
    if als[i] == als[i+1] and a1 != 0:
        a2 = als[i]
        break
    i += 1
print(a1*a2)



Measured memory_bytes: 14252
#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <string>
#include <vector>

using namespace std;
using LLONG = long long;
const LLONG MOD = 1000000007;

int main()
{
    int N, M; cin >> N >> M;
    if (M % 2 == 0)
    {
        for (int i = 0; i < M / 2; ++i)
        {
            cout << i + 1 << ' ' << M + 1 - i << endl;
        }
        for (int i = 0; i < M / 2; ++i)
        {
            cout << M + 2 + i << ' ' << 2 * M + 1 - i << endl;
        }
    }
    else
    {
        for (int i = 0; i < (M - 1) / 2; ++i)
        {
            cout << i + 1 << ' ' << M - i << endl;
        }
        for (int i = 0; i < (M + 1) / 2; ++i)
        {
            cout << M + i + 1 << ' ' << 2 * M + 1 - i << endl;
        }
    }
}

Measured memory_bytes: 3660
A,B,C,X,Y = map(int,input().split())
if A+B <= 2*C:
    print(A*X+B*Y)
else:
    if X < Y:
        if B <= 2*C:
            print(X*2*C+(Y-X)*B)
        else:
            print(2*Y*C)
    elif X == Y:
        print(2*X*C)
    else:
        if A <= 2*C:
            print(Y*2*C+(X-Y)*A)
        else:
            print(2*X*C)

Measured memory_bytes: 3064
//khodaya khodet komak kon
#include <bits/stdc++.h>

#define F first
#define S second
#define pb push_back
#define all(x) x.begin(), x.end()
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math")


using namespace std;

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

const int N = 500 + 10;
const ll MOD = 1000000000 + 7;
const ll INF = 1000000010;
const ll LOG = 25;

int H, W;
int mark[N][N];
int mark2[N][N];

int32_t main(){
	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	cin >> H >> W;
	for (int i = 1; i <= H; i++){
		for (int j = 1; j <= W; j++){
			char c;
			cin >> c;
			if (c == '#') mark[i][j] = 1;
		}
	}
	for (int i = 1; i <= H; i += 2){
		mark2[i + 1][1] = '#';
		for (int j = 1; j < W; j++) mark2[i][j] = 1;
	}
	for (int i = 1; i <= H; i++){
		for (int j = 1; j <= W; j++) cout << (mark[i][j] + mark2[i][j] > 0?'#':'.');
		cout << '\n';
	}
	cout << '\n';
	memset(mark2, 0, sizeof mark2);
	mark2[1][W] = 1;
	for (int i = 2; i <= H; i += 2){
		mark2[i + 1][W] = 1;
		for (int j = 2; j <= W; j++) mark2[i][j] = 1;
	}
	for (int i = 1; i <= H; i++){
		for (int j = 1; j <= W; j++) cout << (mark[i][j] + mark2[i][j] > 0?'#':'.');
		cout << '\n';
	}






	return 0;
}


Measured memory_bytes: 5640
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<string>
#include<vector>
#include<deque>
#include<queue>

using std::cout;
using std::cin;
using std::setw;
using std::setfill;
using std::string;
using std::pair;
using std::make_pair;
using std::vector;
using std::queue;
using std::deque;
using std::priority_queue;
using std::next_permutation;
//using std::iota;
using std::sort;
using std::greater;
using std::max;
using std::min;

using lli = long long int;
using ulli = unsigned long long int;

#define INF 999999999;

#define EVEL 1

#ifndef EVEL
#define dbug(X) std::cout << #X << ":" <<X<<" " ;
#define dbugf(s) std::cout << s << " ";
#define dbugln std::cout<<"\n";
#else
#define dbug(X) {}
#define dbugf(s) {}
#define dbugln {}
#endif

int N, Q;
string S;
int Sp[100010];
int l, r;
//pair<int, int> lr[100010];

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

    cin >> N >> Q;
    cin >> S;
    for(int i = 1; i < N; i++){
        if(S[i-1] == 'A' && S[i] == 'C'){
            Sp[i] = 1;
        }
        Sp[i] = Sp[i]+Sp[i-1];
    }
    for(int i = 0; i < Q; i++){
        cin >> l >> r;
        cout << Sp[r-1] - Sp[l-1] << "\n";
    }
	return 0;
}



Measured memory_bytes: 1488
#include <iostream>
#include <string>
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <stdio.h>
#include <queue>
#include <deque>
#include <cstdio>
#include <set>
#include <map>
#include <bitset>
#include <stack>
#include <cctype>
using namespace std;
vector<int> a, b;
int main() {
	string s;
	cin >> s;
	sort(s.begin(), s.end());
	if (s[0] == s[1] && s[2] == s[3] && s[0] != s[2]) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
	return 0;
}


Measured memory_bytes: 3632
#include <iostream>
using namespace std;
int a,b,c,k;
int main(){
	cin>>a>>b>>c>>k;
	int ans=0;
	ans+=min(a,k);
	if(k>=a) k-=a;
	else{
		cout<<ans<<endl;
		return 0;
	}
	if(k>=b) k-=b;
	else{
		cout<<ans<<endl;
		return 0;
	}
	ans-=k;
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
#include<math.h>
using namespace std;
#define LL long long


int main(){
	// sengen
	double a,b,x;
	// nyuryoku
	cin >> a >> b >> x;
	// keisan
	if(x <= a*a*b/2){
		double kodo = atan(2*x/a/b/b);
		kodo = kodo*180/M_PI;
		printf("%.8lf\n",90-kodo);
	}else{
		double kodo = atan(a*a*a/2/(a*a*b - x));
		kodo = kodo*180/M_PI;
		printf("%.8lf\n",90-kodo);
	}
	// syutsuryoku
}

Measured memory_bytes: 4040
import java.util.*;

public class Main
{
	public static void main(String args[])
	{
		String a;
		Scanner s1=new Scanner(System.in);
		a=s1.nextLine();
		int b=a.length();
		if(b==6)
		{
			if(a.charAt(2)==a.charAt(3))
			{
				if(a.charAt(4)==a.charAt(5))
				{
					System.out.println("Yes");
				}
				else
				{System.out.println("No");}
			}
			else
			{System.out.println("No");}
		}
		else
		{System.out.println("No");}
	}
}

Measured memory_bytes: 23764
#include<iostream>
#include<vector>
#include<queue>
#include<cctype>
using namespace std;

#define inRange(x,a,b) (a <= x && x < b)
int di[4] = {-1, 0, 1, 0};
int dj[4] = { 0, 1, 0,-1};

// memory, row, column, direction
bool visit[16][20][20][4] = {};

struct data{
    int m, i, j, d;
};

int main(){
    int h, w;
    cin >> h >> w;
    char mat[h][w];
    for(int i = 0; i < h; i++){
        for(int j = 0; j < w; j++){
            cin >> mat[i][j];
        }
    }
    queue<data> q;
    q.push(data({0, 0, 0, 1}));
    while(!q.empty()){
        data x = q.front(); q.pop();
        int m = x.m, i = x.i, j = x.j, d = x.d;
        if(mat[i][j] == '@'){
            cout << "YES" << endl;
            return 0;
        }
        if(mat[i][j] == '<')    d = 3;
        if(mat[i][j] == 'v')    d = 2;
        if(mat[i][j] == '>')    d = 1;
        if(mat[i][j] == '^')    d = 0;
        if(mat[i][j] == '_')    if(m == 0)  d = 1; else d = 3;
        if(mat[i][j] == '|')    if(m == 0)  d = 2; else d = 0;
        if(isdigit(mat[i][j]))  m = mat[i][j]-'0';
        if(mat[i][j] == '+')    m = (m+1)%16;
        if(mat[i][j] == '-')    m = (m+15)%16;

        if(mat[i][j] == '?'){
            for(int dir = 0; dir < 4; dir++){
                int ni = (i+di[dir]+h)%h, nj = (j+dj[dir]+w)%w;
                if(!visit[m][ni][nj][dir]){
                    visit[m][ni][nj][dir] = true;
                    q.push(data({m,ni,nj,dir}));
                }
            }
        }else{
            int ni = (i+di[d]+h)%h, nj = (j+dj[d]+w)%w;
            if(!visit[m][ni][nj][d]){
                visit[m][ni][nj][d] = true;
                q.push(data({m,ni,nj,d}));
            }
        }
    }
    cout << "NO" << endl;
    return 0;
}


Measured memory_bytes: 3164
#include<iostream>
using namespace std;
using ll = long long;

ll fun(ll n, ll x){
	if (x > n)return 0;
	bool i3 = false, i5 = false, i7 = false;
	for (ll i = x; i > 0; i /= 10){
		if (i % 10 == 3)i3 = true;
		if (i % 10 == 5)i5 = true;
		if (i % 10 == 7)i7 = true;
	}
	ll res = fun(n, x * 10 + 3) + fun(n, x * 10 + 5) + fun(n, x * 10 + 7);
	if (i3 && i5 && i7)res++;
	return res;
}

int main(){
	ll n, ans = 0;
	cin >> n;
	cout << fun(n,0) << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=2e5+20;
const ll inf=1e16+1000;
ll a[N];
int n;
int main()
{
	while(cin>>n)
	{
		ll sum=0;
		for(int i=1;i<=n;i++)
			cin>>a[i],sum+=a[i];
		ll l=sum-n*(n-1),r=sum;
		for(ll k=l;k<=r;k++)
		{
			if(k<0)	continue;
			ll res=0;
			bool ok=true;
			for(int i=1;i<=n;i++)
			{
				ll x=(a[i]+k+1)/(n+1),y=(a[i]+k)/(n+1);
			//	if(x<=y)
					res+=x;
			//	else
			//		ok=false;
			}
			if(ok&&res==k)
			{
				cout<<res<<endl;
				break;
			}
		}
	}
	return 0;
}
//25720164523
//154320986863
//500000000000000000

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define uint unsigned
#define ull unsigned ll
#define pii pair<int,int>
#define pll pair<ll,ll>
#define PB push_back
#define fi first
#define se second
#define For(i,j,k) for (int i=(int)(j);i<=(int)(k);i++)
#define Rep(i,j,k) for (int i=(int)(j);i>=(int)(k);i--)
#define CLR(a,v) memset(a,v,sizeof(a))
#define CPY(a,b) memcpy(a,b,sizeof(a))
using namespace std;
const int mo=1000000007;
const int N=1000005;
int n,k,ans,f[N][2];
int fac[N],inv[N],Inv[N];
int C(int x,int y){
	return 1ll*fac[x]*inv[y]%mo*inv[x-y]%mo;
}
int main(){
	scanf("%d",&n);
	fac[0]=inv[0]=Inv[0]=Inv[1]=1;
	For(i,2,N-1) Inv[i]=1ll*Inv[mo%i]*(mo-mo/i)%mo;
	For(i,1,N-1){
		fac[i]=1ll*fac[i-1]*i%mo;
		inv[i]=1ll*inv[i-1]*Inv[i]%mo;
	}
	f[0][0]=1;
	For(i,1,n){
		f[i][1]=(2ll*f[i-1][0]+f[i-1][1])%mo;
		f[i][0]=f[i-1][1];
	}
	For(i,1,n){
		int ways=1ll*f[i][1]*Inv[2]%mo*C(n,i)%mo;
		ans=(ans+1ll*ways*Inv[i])%mo; 
	}
	For(i,1,n) ans=1ll*ans*Inv[3]%mo;
	ans=1ll*ans*Inv[n]%mo;
	printf("%d\n",ans);
} 

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

#include <fstream>
using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout << setprecision(20) << fixed;
  /*
  ifstream in("input.txt");
  cin.rdbuf(in.rdbuf());
  //*/
  int K;
  cin >> K;
  cout << K / 2 * (K - K / 2) <<endl;
}


Measured memory_bytes: 3632
# https://atcoder.jp/contests/ddcc2020-qual/tasks/ddcc2020_qual_b

import sys
sys.setrecursionlimit(12345678)
import itertools
from collections import Counter
from collections import defaultdict
from collections import deque
import bisect
from heapq import heappush, heappop


def main():
    n = int(input())
    al = list(map(int, input().split()))

    cum_len = [0] * len(al)
    cum_len[0] = al[0]
    for i in range(1, len(al)):
        cum_len[i] = cum_len[i-1] + al[i]

    # print(sum(al))
    ans = 10**10
    for i in range(len(al)):
        left = cum_len[i]
        right = cum_len[-1] - cum_len[i]
        # print(left, right)
        ans = min(ans, abs(left - right))

    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 89036
#include "bits/stdc++.h"
#include "sstream"
#define EPS 1e-9
using namespace std;
const int N=1e3+5,OO=0x3f3f3f3f;
typedef long long ll;
const int mod=1e9+7;
int main() {
     int a,b,c,k; cin>>a>>b>>c>>k; ll ans=0;
     if(a<=k)
         ans+=a,k-=a;
     else
         return cout<<k,0;
     if(k>=b)
         k-=b;
     else
         return   cout<<ans,0;
     if(c<=k)
        ans-=c;
     else
         ans-=k;
     cout<<ans;

}

Measured memory_bytes: 3620
#include <iostream>
#include <algorithm>

int main(){
  int n, a[101];
  std::cin>>n;
  for(int i=0;i<n;++i)std::cin>>a[i];
  int ans=0;
  for(int i=0;i<n;++i){
    for(int j=0;j<n;++j){
      if(i==j)continue;
      ans=std::max(ans,a[i]-a[j]);
    }
  }
  std::cout<<ans<<std::endl;
  return 0;
}


Measured memory_bytes: 256
n, m = map(int, input().split())
q = list(map(lambda x: -int(x), input().split()))

from heapq import *

heapify(q)

while m:
    a = heappop(q)
    a = -(-a // 2)
    heappush(q, a)
    m -= 1

ans = 0
for i in q:
    ans += i
print(-ans)


Measured memory_bytes: 72216
#include<stdio.h>

int check(int height[],int n){
	for(int i=1; i<n; i++){
		if(height[i] < height[i-1]){
			height[i]++;
			if(height[i] < height[i-1]){
				return -1;
			}
		}
	}
	return 1;
}


int main(){
	int n;
	scanf("%d",&n);
	int height[n];
	for(int i=0; i<n; i++){
		scanf("%d", &height[i]);
	}
	if(check(height, n) == 1) printf("Yes");
	else printf("No");
	
	return 0;
}

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

typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<long long> vll;
typedef vector<vector<long long>> vvll;
typedef pair<int,int> pii;
typedef pair<long long, int> pli;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()

ll mod = 998244353;

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

  int n;cin >> n;
  ll k; cin >> k;
  vi a(n);
  rep(i,n){cin >> a[i];a[i]--;}

  vi rt;
  int cur = 0;
  map<int,int> stamp;
  while(stamp[cur] == 0){
    rt.push_back(cur);
    stamp[cur] = rt.size();
    cur = a[cur];
  }

  int pre = stamp[cur] - 1;
  int loop = rt.size() - stamp[cur] + 1;

  if(k < pre){
    cout << rt[k]+1 << endl;
  }else{
    int md = (k-pre)%loop;
    cout << rt[pre+md]+1 << endl;
  }
}

Measured memory_bytes: 13868
#include <bits/stdc++.h>
#include <numeric>
#define rep(i,n) for (int i = 0; i < n; ++i)
#define rep1(i,n) for (int i = 1; i <= n; ++i)
template<typename T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<typename T> inline T intceil(T a, T b) { return (a + (b - 1)) / b; }
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
const long long MOD = 1e9+7;
#define precout(val) cout << std::fixed << std::setprecision(20) << val;
const string alphabet = "abcdefghijklmnopqrstuvwxyz";
const int dy[4] = { 0, 1, 0, -1 };
const int dx[4] = { 1, 0, -1, 0 };
static const double pi = 3.141592653589793;

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

  string x; cin >> x;
  int n = x.size();
  int s = 0;
  int ans = n;

  rep(i, n) {
    if(x[i] == 'T') {
      if(s > 0) {
        --s;
        ans -= 2;
      }
    } else {
      ++s;
    }
  }

  cout << ans << endl;
}


Measured memory_bytes: 720
n,k=map(int,input().split())
A=list(map(int,input().split()))

time=0
color=["white" for _ in range(n+1)]
D=[-1 for _ in range(n+1)]
C,s=[],A[0]
point=0
while 1:
    if color[s]=="white":
        color[s]="gray"
        C.append(s)
        D[s]=time
        time +=1
        s=A[s-1]
    else:
        point=D[s]
        break

loop=C[point:]
if k>len(C):
    k -=point+1
    print(loop[k%len(loop)])
else:print(C[k-1])

Measured memory_bytes: 120836
package main

import (
	"bufio"
	"container/heap"
	"fmt"
	"math"
	"os"
	"strconv"
)

const pi = math.Pi

var mod int = pow(10, 9) + 7
var Umod uint64 = 1000000007
var ans, cnt, sum int = 0, 0, 0

func main() {
	reader.Split(bufio.ScanWords)
	N, _ := strconv.Atoi(read())
	M, _ := strconv.Atoi(read())
	A := make([]int, N)

	pq := &PriorityQueue{}
	heap.Init(pq)

	for i := 0; i < N; i++ {
		A[i], _ = strconv.Atoi(read())
		heap.Push(pq, A[i])
	}
	for i := 0; i < M; i++ {
		a := heap.Pop(pq).(int) / 2
		heap.Push(pq, a)
	}
	l := pq.Len()
	for i := 0; i < l; i++ {
		sum += heap.Pop(pq).(int)
	}
	fmt.Println(sum)
}

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

var reader = bufio.NewScanner(os.Stdin)

func read() string {
	reader.Scan()
	return reader.Text()
}

func lcm(x, y int) int {
	return (x / gcd(x, y)) * y
}

func gcd(x, y int) int {
	if x%y == 0 {
		return y
	} else {
		r := x % y
		return gcd(y, r)
	}
}

var fac [1000000]int
var finv [1000000]int
var inv [1000000]int

func combination_init() {
	fac[0], fac[1] = 1, 1
	finv[0], finv[1] = 1, 1
	inv[1] = 1

	// invは a^(-1) mod p
	// pをaで割ることを考える

	// p/a*(a) + p%a = p
	// p/a*(a) + p%a = 0          (mod p)
	// -p%a = p/a*(a)             (mod p)
	// -p%a *a^(-1)= p/a          (mod p)
	// a^(-1)= p/a * (-p%a)^(-1)  (mod p)
	// a^(-1) =

	for i := 2; i < 1000000; 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
	}
}

func combination(x, y int) int {
	if x < y {
		return 0
	}
	if fac[0] != 1 {
		combination_init()
	}
	return fac[x] * (finv[y] * finv[x-y] % mod) % mod
	//return fac[x] / (fac[y] * fac[x-y])
}

func permutation(x, y int) int {
	if x < y {
		return 0
	}
	if fac[0] != 1 {
		combination_init()
	}
	return fac[x] * (finv[x-y] % mod) % mod
	//return fac[x] / fac[x-y]
}

func max(x ...int) int {
	var res int = x[0]
	for i := 1; i < len(x); i++ {
		res = int(math.Max(float64(x[i]), float64(res)))
	}
	return res
}

func min(x ...int) int {
	var res int = x[0]
	for i := 1; i < len(x); i++ {
		res = int(math.Min(float64(x[i]), float64(res)))
	}
	return res
}
func pow(x, y int) int { return int(math.Pow(float64(x), float64(y))) }
func abs(x int) int    { return int(math.Abs(float64(x))) }
func floor(x int) int  { return int(math.Floor(float64(x))) }
func ceil(x int) int   { return int(math.Ceil(float64(x))) }

type SortBy []int

func (a SortBy) Len() int           { return len(a) }
func (a SortBy) Swap(i, j int)      { a[i], a[j] = a[j], a[i] }
func (a SortBy) Less(i, j int) bool { return a[i] < a[j] }

type PriorityQueue []int

func (h PriorityQueue) Len() int            { return len(h) }
func (h PriorityQueue) Less(i, j int) bool  { return h[i] > h[j] }
func (h PriorityQueue) Swap(i, j int)       { h[i], h[j] = h[j], h[i] }
func (h *PriorityQueue) Push(x interface{}) { *h = append(*h, x.(int)) }
func (h *PriorityQueue) Pop() interface{} {
	old := *h
	n := len(old)
	x := old[n-1]
	*h = old[0 : n-1]
	return x
}


Measured memory_bytes: 7680
import collections

def main():
    N, X, Y = [int(x) for x in input().split()]
    dist = collections.defaultdict(int)

    for i in range(1, N+1):
        for j in range(i+1, N+1):
            d = min(
                abs(i-j) ,
                abs(i-X) + 1 + abs(j-Y)
            )
            dist[d] += 1
    for i in range(1, N):
        print(dist[i])


if __name__ == '__main__':
    main()

Measured memory_bytes: 3956
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <vector>
using namespace std;
int main() {
	int n, q, a1;
	vector<int> a;
	int ans[100000] = { 0 };
	int l, r;
	int max, min = 0;
	cin >> n >> q;
	max = n;
	for (int i = 0; i < n; i++) {
		cin >> a1;
		a.emplace_back(a1);
	}
	sort(a.begin(), a.end());
	for (int j = 0; j < q; j++) {
		cin >> l >> r;
		auto ans1 = lower_bound((a).begin(), (a).end(), l);
		auto ans2 = upper_bound((a).begin(), (a).end(), r);
		cout << ans2 - ans1 << endl;
	}
}


Measured memory_bytes: 3536
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<int,int> pii;
 
#define mem(dp,a)       memset(dp,a,sizeof dp)
#define ninja           ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define pb(x)           push_back(x)
#define mp(x,y)         make_pair(x,y)
#define all(c)          c.begin(), c.end()
#define ff              first
#define ss              second
#define nl              '\n'
#define inf             1e9+7
 
int main()
{
	ninja
	int t; 
	int n,x;
	cin>>n>>x;
	int y;
	int cur=0;
	int res=1;
	for(int i=0;i<n;i++){
		cin>>y;
		cur = cur+y;
		if(cur<=x)res++;
	}
	cout<<res;
}



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

typedef long long int ll;

int gcd(int a, int b) 
{ 
    if (a == 0) 
        return b; 
    return gcd(b % a, a); 
} 

int main()
{
  ll n,count=0;cin>>n;
  for(int i=1;i<=n;i++)
    for(int j=1;j<=n;j++)
      for(int k=1;k<=n;k++)
      {
        count+=gcd(i,gcd(j,k));
      }
  cout<<count<<"\n";
}

Measured memory_bytes: 3644
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int main(){
  while(1){
    int n;
    int mi=1000001;
    cin >> n;
    if(n==0)break;
    vector<int>a(n,0);
    for(int i=0;i<n;i++){
      cin >> a[i];
    }
    sort(a.begin(),a.end());
    for(int i=1;i<n;i++){
      mi=min(mi,a[i]-a[i-1]);
    }
    cout << mi << endl;
  }
  return 0;
}

Measured memory_bytes: 3096
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,N) for(int i=0;i<int(N);++i)
#define rep1(i,N) for(int i=1;i<int(N);++i)
#define all(a) (a).begin(),(a).end()
#define bit(k) (1LL<<(k))
#define SUM(v) accumulate(all(v), 0LL)

typedef pair<int, int> i_i;
typedef pair<ll, ll> l_l;
template <class T> using vec = vector<T>;
template <class T> using vvec = vector<vec<T>>;
struct fast_ios{ fast_ios(){ cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; }fast_ios_;

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

#define TOSTRING(x) string(#x)
template <typename T> istream &operator>>(istream &is, vector<T> &vec) { for (T &x : vec) is >> x; return is; }
template <typename T> ostream &operator<<(ostream &os, const vector<T> &v) { os  << "["; for(auto _: v) os << _ << ", "; os << "]"; return os; };
template <typename T> ostream &operator<<(ostream &os, set<T> &st) { os << "("; for(auto _: st) { os << _ << ", "; } os << ")";return os;}
template <typename T, typename U> ostream &operator<<(ostream &os, const pair< T, U >& p){os << "{" <<p.first << ", " << p.second << "}";return os; }
template <typename T, typename U> ostream &operator<<(ostream &os, const map<T, U> &mp){ os << "["; for(auto _: mp){ os << _ << ", "; } os << "]" << endl; return os; }

#define DUMPOUT cerr
void dump_func(){ DUMPOUT << endl; }
template <class Head, class... Tail> void dump_func(Head &&head, Tail &&... tail) { DUMPOUT << head; if (sizeof...(Tail) > 0) { DUMPOUT << ", "; } dump_func(std::move(tail)...); }

#ifdef DEBUG
#define dbg(...) dump_func(__VA_ARGS__)
#define dump(...) DUMPOUT << string(#__VA_ARGS__) << ": "; dump_func(__VA_ARGS__)
#else
#define dbg(...)
#define dump(...)
#endif

const int INF = (ll)1e9;
const ll INFLL = (ll)1e18+1;
const ll MOD = 1000000007;
// const ll MOD = 998244353;
const long double PI = acos(-1.0);

/*
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
const string dir = "DRUL";
*/
#include <atcoder/modint>
#include <atcoder/lazysegtree>
using mint = atcoder::modint998244353;
const mint inv9 = mint(1)/9;
struct S{
    mint x, w;
    S(mint x = 0, mint w = 1): x(x), w(w) {}; // デフォルト引数は単位元にしておく
};

S op(S a, S b){
    return S(a.x * b.w + b.x, a.w * b.w);
}
S e(){
    return S();
}

S mapping(int f, S a){
    if(f == 0)return a;
    return S((a.w - 1) * inv9 * f ,a.w);
}
int composision(int f, int g){
    if(f == 0)return g;
    return f;
}
int id(){
    return 0;
}
int main() {
    int N, Q;
    cin >> N >> Q;
    atcoder::lazy_segtree<S, op, e, int, mapping, composision, id> t(N);
    rep(i,N){
        t.set(i, S(1, 10));
    }
    rep(qi, Q){
        int l, r, d;
        cin >> l >> r >> d;
        l--;
        t.apply(l, r, d);
        S ans = t.prod(0,N);
        cout << ans.x.val() << endl;
    }
}


Measured memory_bytes: 9804
#include <iostream>
#include <algorithm>
#include <vector>

using namespace std;

using LL = long long;
const int B = 61;

signed main() {
    ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);

    int T;
    cin >> T;
    while (T--) {
        int n;
        cin >> n;
        vector<LL> a(n);
        for (auto &x : a) cin >> x;
        string s;
        cin >> s;
        vector<LL> b(B + 1);
        int ans = 0;
        for (int i = n - 1; ~i; i--) {
            LL now = a[i];
            for (int j = B; ~j; j--) {
                if (((now >> j) & 1) == 0) continue;
                if (!b[j]) {
                    b[j] = now;
                    break;
                }
                now ^= b[j];
            }
            if (s[i] == '1') {
                if (now) {
                    ans = 1;
                    break;
                }
            }
        }
        cout << ans << endl;
    }

    return 0;
}

Measured memory_bytes: 3596
import java.util.*;

public class Main{

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		int n = sc.nextInt();
		String s = sc.next();
		
		int cnt  = 1;
		char p = s.charAt(0);
		
		for(int i=1;i<s.length();i++){
			if(s.charAt(i) != p){
				cnt++;
				p = s.charAt(i);
			}
		}
		System.out.println(cnt);
	}

}


Measured memory_bytes: 24840
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#define BUF_SIZE 100010
int main(void) {
  char line[BUF_SIZE];
  FILE *fp = stdin;
  if(!fgets(line, BUF_SIZE, fp)) return 0;
  int num;
  sscanf(line, "%d", &num);


  if(!fgets(line, BUF_SIZE, fp)) return 0;
  int i;
  int cnt = 0;
  for(i = 0; i < num;) {
    int j = i;
    while(line[j] == line[i] && i < num) i++;
    cnt++;
  }
  printf("%d\n", cnt);
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll =long long;
#define SORT(i) sort((i).begin(),(i).end())
#define INF 2000000000
constexpr ll mod = 1000000007;

int main() {
	int N, X;
	cin >> N >> X;
	vector<int>m(N);
	int sum = 0;
	for (int i = 0;i < N;++i) {
		cin >> m[i];
		sum += m[i];
	}
	X -= sum;
	SORT(m);
	int ans = m.size();
	ans = ans + X / m[0];
	cout << ans << "\n";


	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define mk make_pair
#define fs first
#define sc second
using namespace std;
typedef long long ll;
typedef long double ld;
int a[333][333];
const ll mod=998244353;
long long fact[333], pr[333];
void pre(){
    fact[0]=1;
    for(long long i=1; i<333; ++i){
        fact[i]=(fact[i-1]*i)%mod;
    }
    pr[0]=1;
    for(long long i=1; i<333; ++i){
        pr[i]=(pr[i-1]*2)%mod;
    }
}
long long pwr(long long x, long long e){
    if(e==0)
        return 1;
    long long tmp=pwr(x,e/2);
    tmp=(tmp*tmp)%mod;
    if(e%2)
        tmp=(tmp*x)%mod;
    return tmp;
}
long long cmp(long long x, long long y){
    long long res, tmp;
    tmp=pwr(fact[x-y], mod-2);
    res=(fact[x]*tmp)%mod;
    tmp=pwr(fact[y],mod-2);
    res=(res*tmp)%mod;
    return res;
}
bool l[333];
int n, m;
ll gauss(){
    int tmp=0;
    for(int i=0; i<m; ++i){
        for(int j=0; j<n; ++j){
            if(l[j]){
                continue;
            }
            if(a[j][i]){
                for(int k=j+1; k<n; ++k){
                    if(l[k])
                        continue;
                    if(a[k][i]){
                        for(int f=0; f<m; ++f){
                            a[k][f]^=a[j][f];
                        }
                    }
                }
                ++tmp;
                l[j]=1;
                break;
            }
        }
    }
    return tmp;
}

int main(){
    while(cin>>n>>m){
        ll ans=0;
        for(int i=0; i<n; ++i){
            for(int j=0; j<m; ++j){
                scanf("%d",&a[i][j]);
            }
        }
        pre();
        ll tmp=gauss(), tmp1;
        for(int i=1; i<=tmp; ++i){
            tmp1=0;
            for(int j=1; j<=i; j+=2){
                tmp1+=cmp(i, j)*pr[tmp-i];
                tmp1%=mod;
            }
            ans+=cmp(tmp, i)*tmp1;
            ans%=mod;
        }
        ans*=pr[n-tmp];
        ans%=mod;
        ans*=pr[m-tmp];
        ans%=mod;
        cout<<ans<<endl;
    }
  return 0;
}




Measured memory_bytes: 640
#include<cstdio>
#include<cstring>
#include<string>
#include<iostream>
#include<cmath>
#include<algorithm>
#include<queue>
#include<map>
#include<ctime>

using namespace std;

template <typename T>

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

#define lint long long int
#define ulint unsigned lint

const int inf=1e9+1e7;
const int MAXN=1e5+1e1;

int R[MAXN];
int G[MAXN];
int B[MAXN];

string s;
int n,l;
lint ans=0;

int main(void)
{

	// freopen("testdata.in","r",stdin);
	// freopen("testdata.out","w",stdout);

	scanf("%d",&n);

	cin>>s;

	l=s.length();

	for(int i=0;i<l;i++)
	{
		R[i+1]=R[i];
		G[i+1]=G[i];
		B[i+1]=B[i];
		if(s[i]=='R') ++R[i+1];
		if(s[i]=='G') ++G[i+1];
		if(s[i]=='B') ++B[i+1];
	}

	for(int i=l;i>0;i--)
		for(int j=i;j>0;j--)
		{
			if(s[i-1]==s[j-1]) continue;
			int tmp='R'+'G'+'B'-s[i-1]-s[j-1];
			if(tmp=='R') ans+=R[j-1];
			if(tmp=='G') ans+=G[j-1];
			if(tmp=='B') ans+=B[j-1];
			if(j+j-i-1<0) continue;
			if(s[j+j-i-1]==tmp) --ans;
		}

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

	return 0;

}

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

int h[100002];
long long f[100002];

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
 
    int n, k;
    cin>>n>>k;
    for (int i=1;i<=n;i++) cin>>h[i];
    f[1] = 0;
    for (int i=2;i<=n;i++){

        f[i] = 1e9;
        for (int j=max(1, i-k);j<i;j++){
            f[i] = min(f[i], f[j] + abs(h[i] - h[j]));
        }
    }
    cout<<f[n];

}


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

int main(){
	int X,t;
	scanf("%d %d",&X,&t);
	int ans;

	if (t>=X){
		ans=0;
	}

	else{
		ans=X-t;
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#include <cstdio>
#include <cstdlib>
 
#ifdef _MSC_VER
#include <Windows.h>
#else
#include <unistd.h>
#endif
 
using namespace std;
 
//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
 
//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}
 
//typedef
//------------------------------------------
typedef pair<int, int> PII;
typedef pair<long, long> PLL;
typedef long long LL;
//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB emplace_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SORT(c) sort((c).begin(),(c).end())
 
//repetition
//------------------------------------------
#define FOR(i,a,b) for(LL i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
 
//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
const LL MOD=(LL)1e9+7;
//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))
 
#define INF 1LL << 50
 

int main(){
    int N;cin>>N;
    vector<LL>a(N);
    REP(i,N)cin>>a[i];
    int cnt1=0,cnt2=0;
    REP(i,N){
        if(a[i]%4==0)cnt1++;
        else if(a[i]%2==0)cnt2++;
    }
    if(cnt2==0){
        if(N/2<=cnt1)cout<<"Yes"<<endl;
        else cout<<"No"<<endl;
        return 0;
    }
    if((N-cnt2)/2+(N-cnt2)%2<=cnt1)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    return 0;
}

Measured memory_bytes: 1024
N = int(input())
char_dict = {}
s_li = []
ans = ''
for i in range(N):
    s_li.append(input())
for s in s_li:
    for c in [chr(ord('a') + i) for i in range(26)]:
        cnt = s.count(c)
        if c not in char_dict:
            char_dict[c] = cnt
        else:
            char_dict[c] = min(cnt, char_dict[c])
for k, v in char_dict.items():
    ans += k * v
print(ans)


Measured memory_bytes: 66084
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <utility>
#include <algorithm>
#include <cstdio>
#include <iomanip>
#include <queue>
#include <deque>
#include <stack>
#include <fstream>
#include <cmath>
#include <random>
#include <complex>
#include <functional>

#define ll int64_t
#define Rep(i, n) for (ll i = 0; i < n; i++)
using namespace std;
typedef vector<ll> vec;
typedef vector<vec> mat;

const ll inf = 1LL << 60;

template<class T> inline void chmin(T& a, T b) {
    if (a > b) {
        a = b;
    }
}
template<class T> inline void chmax(T& a, T b) {
    if (a < b) {
        a = b;
    }
}

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

    ll N;
    cin >> N;
    cout << (N+1) / 2 << endl;
}

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

int main(void) {
	int a, b, c, d, e;
	cin >> a >> b >> c >> d >> e;
	int k;
	cin >> k;
	int l = e - a;
	if (l > k) cout << ":(" << endl;
	else cout << "Yay!" << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define int long long
using namespace std;
main()
{
    int n;
    cin>>n;
    vector<vector<int>>edges(n);
    for(int i=0;i<n;i++){
        string s;
        cin>>s;
        for(int j=0;j<n;j++)
        {
            if(s[j]=='1')   edges[i].push_back(j);
        }
    }
    int ans=-1;
    for(int i=0;i<n;i++){
        queue<int>q;
        q.push(i);
        vector<int>d(n,-1),parent(n,-1);
        d[i]=0;
        parent[i]=-1;
        while(!q.empty())
        {
            int v=q.front();
            q.pop();
            for(auto x:edges[v]){
                if(d[x]==-1){
                    d[x]=d[v]+1;
                    parent[x]=v;
                    q.push(x);
                }else if(parent[v]!=x && abs(d[x]-d[v])!=1){
                    cout<<-1<<"\n";
                    return 0;
                }   
            }
        }
        ans=max(ans,*max_element(d.begin(),d.end())+1);
    }
    cout<<ans<<"\n";
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define ok() puts(ok?"Yes":"No");
#define chmax(x,y) x = max(x,y)
#define chmin(x,y) x = min(x,y)
using namespace std;
using ll = long long;
using vi = vector<int>;
using ii = pair<int, int>;
using vvi = vector<vi>;
using vii = vector<ii>;
using gt = greater<int>;
using minq = priority_queue<int, vector<int>, gt>;
using P = pair<ll,ll>;
const ll LINF = 1e18L + 1;
const int INF = 1e9 + 1;
//clang++ -std=c++11 -stdlib=libc++ 

int main() {
  string s,t;cin>>s>>t;
  int ans=0;
  rep(i,s.length()) {
    if (s[i] != t[i]) ans++;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3916
#include <iostream>
#include <string>
#include <vector>
#include <list>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <fstream>
#include <sstream>
#include <iomanip>

using namespace std;

long long MOD = 1000000007;

int main(){
    string S;
    cin >> S;
    map<string, string> mp;
    mp["Sunny"]="Cloudy";
    mp["Cloudy"]="Rainy";
    mp["Rainy"]="Sunny";

    cout << mp[S] << endl;
}

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


int main()
{
    ll n;
    cin>>n;
    ll arr[n];
    for(int i=0;i<n;i++)
        cin>>arr[i];
    int ans=0;

    sort(arr,arr+n);

    for(int i=0;i<n-2;i++)
        {for(int j=i+1;j<n-1;j++)
          {for(int k=j+1;k<n;k++)
    {
        if(arr[i]+arr[j]>arr[k]&&arr[i]!=arr[j]&&arr[j]!=arr[k])
            ans++;
    }
          }
        }
    cout<<ans<<endl;
}



Measured memory_bytes: 3544
R,G,B,N = map(int, input().split())

maxr=N//R
maxg=N//G

ans=0
for r in range(maxr,-1,-1):
  for g in range(maxg,-1,-1):
    if N-(r*R+g*G)>=0:
      if (N-(r*R+g*G))%B==0:
        ans+=1
print(ans)

Measured memory_bytes: 40940