akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define IO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define EPS 1e-9
#define f first
#define s second
#define ll long long
#define read(x) scanf("%d", &x)
#define all(v) v.begin(), v.end()
const int MOD = 1e9 + 7;
using namespace std;

int main(){
    //freopen("test.txt", "r", stdin);
    IO;
    int n, K;
    cin >> n >> K;
    vector<int> v(n);
    vector<int> dp(K + 1);
    vector<int> prefix(K + 1, 1);
    for(int &a : v)
        cin >> a;
    dp[0] = 1;
    for(int child : v){
        for(int k = 1; k <= K; ++k){
            dp[k] = prefix[k];
            if(k - child - 1 < 0)
                continue;
            dp[k] -= prefix[k - child - 1];
            if(dp[k] < 0)
                dp[k] += MOD;
        }
        for(int k = 1; k <= K; ++k)
            prefix[k] = (dp[k] + prefix[k - 1]) % MOD;
    }
    cout << dp[K];
}


Measured memory_bytes: 3924
#include<bits/stdc++.h>
using namespace std;
 
#define int             long long
#define ld              long double
#define ff              first
#define ss              second
#define pb              push_back
#define mp              make_pair
#define pii             pair<int, int>
#define mk(arr,n,type)  type *arr=new type[n];
#define vi              vector<int>
#define si              set<int>
#define usi             unordered_set<int>
#define mii             map<int, int>
#define umii            unordered_map<int, int>
#define pqmax           priority_queue<int>
#define pqmin           priority_queue<int, vi, greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define trailzrobits(x) __builtin_ctzll(x)
#define leadzrobits(x)  __builtin_clzll(x)
#define paritybits(x)   __builtin_parityll(x)
#define gcd             __gcd
#define lcm(x, y)       (x * y) / gcd(x, y)
#define mod             1000000007
#define endl            '\n'
#define PI              3.14159265358979323846
#define inf             1e18
#define sp(x,y)         fixed<<setprecision(y)<<x

void __print(int x) {cout<<x;}
void __print(float x){cout<<x;}
void __print(double x){cout<<x;}
void __print(ld x) {cout<<x;}
void __print(char x){cout <<'\''<<x<<'\'';}
void __print(const char *x){cout <<'\"' <<x<<'\"';}
void __print(const string &x) {cout<<'\"'<<x<<'\"';}
void __print(bool x) {cout<<(x?"true":"false");}
template<typename T,typename V>     void __print(const pair<T,V> &x) {cout<<'{';__print(x.first);cout<<',';__print(x.second);cout<<'}';}
template<typename T>                void __print(const T &x) {int f = 0; cout << '{'; for (auto &i: x) cout << (f++ ? "," : ""), __print(i); cout << "}";}void _print() {cout << "]\n";}
template <typename T,typename... V> void _print(T t, V... v) {__print(t);if(sizeof...(v))cout<<", ";_print(v...);}
#ifndef ONLINE_JUDGE
#define dbg(x...) cout<<"["<<#x<<"]=[";_print(x)
#else 
#define dbg(x...)
#endif

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

int inv(int x, int p = mod){
    return power(x, p - 2) % p;
}

const int N = 1e6 + 6;
 
int32_t main(){

    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    
    int t = 1;
    // cin >> t;
    while(t--){
        
        int n, k; cin>>n>>k;
        mk(a, n+1, int);
        for(int i=1; i<=n; i++)
            cin>>a[i];
        
        mk(dp, n+1, int);
        fill(dp, dp+n+1LL, 0);

        dp[2] = abs(a[2] - a[1]);
        for(int i=3; i<=n; i++){
            dp[i] = inf;
            for(int j=i-1; j>=i-k; j--){
                if(j>=1)
                    dp[i] = min(dp[i], abs(a[i] - a[j]) + dp[j]);
            }
        }

        cout<<dp[n];
    }

    return 0;

}

Measured memory_bytes: 1792
#include "bits/stdc++.h"
using namespace std;
#define repr(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repr(i,0,n)
#define reprrev(i,a,b) for(int i=(int)(b)-1;i>=(int)(a);i--)
#define reprev(i,n) reprrev(i,0,n)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define mp make_pair
#define mt make_tuple
#define MOD 1000000007
#define PI 3.1415926535
#define SEGMAX 131072
typedef long long ll;
typedef pair<int, int> Pi;
typedef pair<ll, ll> Pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<bool> vb;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<Pi> vPi;
typedef vector<Pll> vPll;
typedef vector<vector<int>> vvi;
typedef vector<vector<bool>> vvb;
typedef vector<vector<ll>> vvll;
typedef vector<vector<char>> vvc;
typedef vector<vector<string>> vvs;
typedef vector<vector<double>> vvd;
typedef vector<vector<Pi>> vvPi;
typedef priority_queue<int, vector<int>, greater<int>> pqli;
typedef priority_queue<ll, vector<ll>, greater<ll>> pqlll;
typedef priority_queue<Pi, vector<Pi>, greater<Pi>> pqlP;
string YN(bool y) { return (y?"YES":"NO"); }
string yn(bool y) { return (y?"Yes":"No"); }
string ON(bool y) { return (y?"OK":"NG"); }
int main(void)
{
	int a, b;

	cin>>a>>b;

	cout<<(a+b)%24<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()
#define int long long
//#define _GLIBCXX_DEBUG

signed main() {
  int N; cin >> N;
  int n = N%10;
  if(n == 3) cout << "bon" << endl;
  else if(n == 0 || n == 1 || n == 6 || n == 8) cout << "pon" << endl;
  else cout << "hon" << endl;
  

}

Measured memory_bytes: 3636
#include<bits/stdc++.h>
#define ll long long
#define IO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
using namespace std;
double PI=acos(-1);
vector<int> adj[100005];
int dp[100005];
bool vis[100005];
int solve(int node){
    if(vis[node])
        return dp[node];
    vis[node]=1;
    int ret=1;
    for(auto v:adj[node])
        ret=max(ret,solve(v)+1);
    return dp[node]=ret;
}

int main(){
    int n,m,ans=0;cin>>n>>m;
    for(int i=0;i<100005;i++) dp[i]=1;
    for(int i=0;i<m;i++){
        int x,y;cin>>x>>y;
        adj[x].push_back(y);
    }
    for(int i=1;i<=n;i++) ans=max(ans,solve(i));
    cout<<ans-1<<'\n';







    return 0;
}


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

#define int long long
#define INT int
#define MOD 1000000007

#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep1(i, n) for (int i = 1; i < (n); i++)
#define rrep(i, n) for (int i = (n)-1; i >= 0; i--)
#define all(i) (i).begin(), (i).end()
#define rall(i) (i).begin(), (i).end(), greater<int>()
#define elif else if
#define eb emplace_back
#define pb push_back
#define mp make_pair
#define fst first
#define sec second
template <typename T>
void print(T x)
{
    std::cout << x << '\n';
}
typedef long long ll;
const long long INF = 1LL << 60;

signed main()
{

    string s, t;
    cin >> s >> t;

    if (s == t)
    {
        cout << 0 << endl;
        return 0;
    }
    if (s.size() == t.size())
    {
        int temp2 = 0;
        rep(i, s.size())
        {
            if (t[i] != s[i])
            {
                temp2++;
            }
        }
        cout << temp2 << endl;
        return 0;
    }

    int ans = 1000;
    int t_len = t.size();
    rep(j, s.size() - t_len + 1)
    {
        int temp = 0;
        rep(i, t_len)
        {
            if (t[i] != s[i + j])
            {
                temp++;
            }
        }

        ans = min(ans, temp);
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
const int maxn=1e6+5,maxm=2e6+5;
long long d[maxn];
int head[maxn];
int size=0;
struct edge
{
	int to,next;
	long long val;
}e[maxn];
void addedge(int u,int v,long long w)
{
	e[++size].to=v;
	e[size].val=w;
	e[size].next=head[u];
	head[u]=size;
}
inline int read()
{
	int x=0,f=1;char ch=getchar();
	while(ch>'9'||ch<'0'){if(ch=='-')f=-1;ch=getchar();}
	while(ch<='9'&&ch>='0'){x=(x<<3)+(x<<1)+ch-'0';ch=getchar();}
	return x*f;
}
void dfs(int u,int fa)
{
	for(int i=head[u];i;i=e[i].next)
	{
		int to=e[i].to;
		if(to==fa)continue;
		d[to]=d[u]+e[i].val;
		dfs(to,u);
	}
}
int main()
{
	int n=read();
	for(int i=1;i<n;i++)
	{
		int u=read(),v=read();
		long long w=read();
		addedge(u,v,w);
		addedge(v,u,w);	
	}
	int q=read(),k=read();
	dfs(k,0);
	for(int i=1;i<=q;i++)
	{
		int x=read(),y=read();
		printf("%lld\n",d[x]+d[y]);
	}
	return 0;
}

Measured memory_bytes: 14720
#include<bits/stdc++.h>
#define ll long long 
#define ld long double
#define vl vector
#define pb push_back
#define ff first
#define ss second
using namespace std;

int main()
{
    ll n,m,i,a=0,b=0,k,t,j;
    cin>>a>>b;
    a=(a*b)/__gcd(a,b);
    cout<<a;
}

Measured memory_bytes: 3584
#include <iostream>
#include <cstdio>
#include <cmath>
using namespace std;

int main(){
    while(1){
        int n, s, total = 0;
        int S[1000];
        cin >> n;
        if(n==0)break;
        for(int i=0; i<n; i++){
            cin >> s;
            S[i] = s;
            total += s;  
        }
        double m, a, a_2 = 0;
        m = 1.0 * total / n;
        for(int i=0; i<n; i++){
            a_2 += pow(1.0 * S[i] - m, 2.0) / (double) n;
        }
        a = sqrt(a_2);
        printf("%lf\n", a); 
    }
    return 0;
}


Measured memory_bytes: 3236
use proconio::input;

fn main() {
    input! {
        n: i32,
    }

    let s = match n % 10 {
        2 | 4 | 5 | 7 | 9 => "hon",
        0 | 1 | 6 | 8 => "pon",
        3 => "bon",
        _ => panic!("error")
    };

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


Measured memory_bytes: 2056
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <cmath>
#include <iomanip>
#include <algorithm>
using namespace std;
using ll = long long;

int main(){
    int n, k;
    cin >> n >> k;
    vector<int> l;
    for(int i = 0; i < n; i++){
        int m;
        cin >> m;
        l.push_back(m);
    }
    sort(l.begin(), l.end(), greater<int>());
    int ans = 0;
    for(int i = 0 ; i < k; i++){
        ans += l[i];
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
#define poly vector<ll>
#define ll long long
using namespace std;
const int N=540000;
const int mod=924844033;
int r[N],siz[N],tong[N];
ll n,m,ni[N],js[N];
ll a[N],b[N],ans;
vector<int> g[N];
inline ll C(int x,int y){
	return js[x]*ni[y]%mod*ni[x-y]%mod;
}
inline ll qpow(ll x,ll y,ll ans=1){
	for(;y;y>>=1,x=x*x%mod) if(y&1) ans=ans*x%mod;
	return ans;
}
inline void NTT(ll *a,int len,int opt){
	for(int i=0;i<len;++i) if(i<r[i]) swap(a[i],a[r[i]]);
	for(int i=1;i<len;i<<=1){
		ll u=qpow(5,opt*(mod-1)/(i<<1)+mod-1);
		for(int j=0,w=1;j<len;j+=i<<1,w=1) for(int k=0;k<i;++k,w=w*u%mod){
			ll x=a[j+k],y=a[j+k+i]*w%mod;
			a[j+k]=(x+y)%mod,a[j+k+i]=(x-y)%mod;
		}
	}
	if(~opt) return;
	for(int i=0,inv=qpow(len,mod-2);i<len;++i) a[i]=a[i]*inv%mod;
}
inline int init(int k){
	int len=1,l=0;
	for(;len<k;len<<=1,++l);
	for(int i=0;i<len;++i) r[i]=(r[i>>1]>>1)|((i&1)<<l-1);
	return len;
}
void dfs(int x,int fa){
	siz[x]=1;
	for(int i=0;i<g[x].size();++i){
		int y=g[x][i];
		if(y^fa) dfs(y,x),siz[x]+=siz[y],tong[siz[y]]++;
	}
	tong[n-siz[x]]++;
}
int main(){
	cin>>n;
	for(int i=1,x,y;i<n;++i) cin>>x>>y,g[x].push_back(y),g[y].push_back(x);
	for(int i=js[0]=1;i<=n;++i) js[i]=js[i-1]*i%mod;
	ni[n]=qpow(js[n],mod-2);
	for(int i=n;i;--i) ni[i-1]=ni[i]*i%mod;
	dfs(1,0);
	for(int i=0;i<=n;++i) a[i]=tong[n-i]*js[n-i]%mod,b[i]=ni[i];
	int len=init(n<<1|1);
	NTT(a,len,1); NTT(b,len,1);
	for(int i=0;i<len;++i) a[i]=a[i]*b[i]%mod;
	NTT(a,len,-1);
	ll ans=0;
	for(int i=1;i<=n;++i) printf("%lld\n",((n*C(n,i)%mod-a[n-i]*ni[i])%mod+mod)%mod);
	return 0;
}

Measured memory_bytes: 50740
N, M, K = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
a, b = [0], [0]
for i in range(N):
  a.append(a[i] + A[i])
for i in range(M):
  b.append(b[i] + B[i])
ans, j = 0, M
for i in range(N + 1):
  if a[i] > K:
    break
  while b[j] > K - a[i]:
    j -= 1
  ans = max(ans, i + j)
print(ans)

Measured memory_bytes: 47672
H, W = map(int, input().split())
A = [list(map(int, input().split())) for _ in range(H)]
Ans = []
cnt = 0
for i in range(H):
    for j in range(W):
        if (i == H-1) and (j == W-1):
            continue
        if A[i][j] % 2 != 0:
            if j == W-1:
                A[i + 1][j] += 1
                Ans.append((str(i+1), str(j+1), str(i+2), str(j+1)))
            else:
                A[i][j + 1] += 1
                Ans.append((str(i+1), str(j+1), str(i+1), str(j+2)))

print(len(Ans))
for ans in Ans:
    print(' '.join(ans))



Measured memory_bytes: 98908
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <string>
#include<cmath>
#include <ctype.h>
#include <stdlib.h>
#include <vector>
#include <math.h>
#include <stack>
#define ll long long
#define endl '\n'
using namespace std;
int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	// freopen("input.txt","r",stdin);
	//freopen("output.txt","w",stdout);
	ll a, b, c, k, sum = 0;
	cin >> a >> b >> c >> k;
	if (k >= a) {
		sum += a;
		k -= a;
	}
	else {
		sum += k;
		k -= k;
	}
	if (k > 0) {
		if (k >= b) {
			k -= b;
		}
		else {
			k -= k;
		}
	}
	if (k > 0) {
		if (k >= c) {
			sum -= c;
			k -= c;
		}
		else {
			sum -= k;
			k -= k;
		}
	}
	cout << sum;
}

Measured memory_bytes: 3652
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String word = sc.next();
        int count = 0;
        while(true) {
            String str = sc.next();
            if(str.equals("END_OF_TEXT")) break;
            str = str.toLowerCase();
            if(str.equals(word)) count++;
        }

        System.out.println(count);
    }
}


Measured memory_bytes: 26024
#include<bits/stdc++.h>
#define fastIO ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
using namespace std;   
const int inf = (int) 1e9+7;
const long long INF = -1000000000000;
int main(){
	fastIO;
	int n,m;
	long long p;
	cin>>n>>m>>p;
	vector< vector< pair<int,long long> > > v1(2503);
	vector< vector<int> > v2(2503);
	for(int i=0;i<m;i++){
		int a,b;
		long long c;
		cin>>a>>b>>c;
		--a;--b;c-=p;
		v1[a].push_back(make_pair(b,c));
		v2[b].push_back(a); 	
	}        
	queue<int> q;
	bool alg[2503];
	for(int i=0;i<n;i++)alg[i]=false;                 
	q.push(n-1);
	alg[n-1]=1;
	while(!q.empty()){
		int x=q.front();
		q.pop();
		for(int i=0;i<(int)v2[x].size();i++){
			int nxt=v2[x][i];
			//cout<<nxt<<" "<<x<<'\n';
			if(alg[nxt] == 0){
				alg[nxt]=1;
				//cout<<nxt<<'\n';
				q.push(nxt);
			}
		}
	}
	
	long long d[2503];
	for(int i=0;i<n;i++)d[i]=-1000000000000;
	d[0]=0ll;              
	for(int i=0;i<n;i++){
		for(int j=0;j<n;j++){
			if(d[j] != -1000000000000){
				for(int k=0;k<(int)v1[j].size();k++){
					int nxt = v1[j][k].first;
					if(d[j] + v1[j][k].second > d[nxt]){
		      	d[nxt] = d[j] + v1[j][k].second;
					}               
				}                 			
			}		
		}
	}

	/*for(int i=0;i<n;i++){
		cout<<d[i]<<" ";
	}
	cout<<'\n';*/
	for(int i=0;i<n;i++){
		for(int j=0;j<(int)v1[i].size();j++){
			int nxt=v1[i][j].first;	
			if(d[i] == -1000000000000 || d[nxt] == -1000000000000)continue;
			if(d[i] + v1[i][j].second > d[nxt] && alg[nxt]){
				//cout<<nxt<<" "<<d[nxt]<<" "<<alg[nxt]<<'\n';
				cout<<-1<<'\n';
				return 0;
			}
		}
	}	
	cout<<max(0ll,d[n-1])<<'\n';
	return 0;
}

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

typedef long long ll;
ll MOD = 1000000007;

int main()
{
    string a;
    cin >> a;
    
    set <char> s;
    for (int i = 0; i < 4; i++) {
        s.insert(a[i]);
    }
    if (s.size() == 2) cout << "Yes" << endl;
    else cout << "No" << endl;

    return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(a) (a).begin(),(a).end()
#define pb emplace_back
#define INF (1e9+1)

int main(){
    int h,w;
    cin>>h>>w;
    int n;
    cin>>n;
    
    queue<int> que;
    rep(i,n){
        int t;
        cin>>t;
        rep(j,t)que.push(i+1);
    }
    
    vector<vector<int>> ans(h,vector<int>(w));
    
    rep(i,h){
        if(i%2){
            for(int j=w-1;j>=0;j--){
                ans[i][j] = que.front();
                que.pop();
            }
        }else{
            rep(j,w){
                ans[i][j] = que.front();
                que.pop();
            }
        }
    }
    rep(i,h){
        rep(j,w){
            if(j)cout<<" ";
            cout<<ans[i][j];
        }
        cout<<endl;
    }
}

Measured memory_bytes: 384
#include<stdio.h>
int main(){
  int a[3][6],i,j;
  
  for(i=0;i<3;i++){
    
    for(j=0;j<6;j++) scanf("%d",&a[i][j]);
    
    if(a[i][2] > a[i][5]){
      a[i][4]--;
      a[i][2] = (a[i][5]+60) - a[i][2];
    }
    else a[i][2] = a[i][5]-a[i][2];
    
    if(a[i][1] > a[i][4]){
      a[i][3]--;
      a[i][1] = (a[i][4]+60) -a[i][1];
    }
    else a[i][1] =a[i][4]-a[i][1];
    
    a[i][0] = a[i][3]-a[i][0];
  }
  
  for(i=0;i<3;i++){
    printf("%d %d %d\n",a[i][0],a[i][1],a[i][2]);
  }

  return (0);
}

Measured memory_bytes: 2676
n, m = map(int, input().split())
dp = [[float('inf')] * 2 ** n for _ in range(m + 1)]
dp[0][0] = 0
for i in range(1, m + 1):
    a, b = map(int, input().split())
    c = [int(i_) for i_ in input().split()]
    temp = 0
    for kk in c:
        temp += 1 << (kk - 1)
    for j in range(2 ** n):
        if j == 0:
            dp[i][temp | j] = a
        else:
            dp[i][temp | j] = min(dp[i - 1][j] + a, dp[i][temp | j])
        if (i > 1):
            dp[i][j] = min(dp[i - 1][j], dp[i][j])

if dp[-1][-1] < float("inf"):
    print(dp[-1][-1])
else:
    print(-1)

Measured memory_bytes: 134280
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        // int TC = Integer.parseInt(sc.next(), 10);
        
        while (true) {
            int N = sc.nextInt();
            int Q = sc.nextInt();
            if (N == 0 && Q == 0) break;
            
            int max = -999;
            int day = 999;
            int[] days = new int[100];
            
            for (int i = 0; i < N; i++) {
                int M = sc.nextInt();
                for (int j = 0; j < M; j++) {
                    int d = sc.nextInt() - 1;
                    days[d]++;
                    if (days[d] >= max) {
                        if (days[d] == max)
                            day = Math.min(d, day);
                        else
                            day = d;
                        max = days[d];
                    }
                }
            }
            
            if (max >= Q) {
                System.out.println(day + 1);
            } else {
                System.out.println(0);
            }
        }
    }
}




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

using namespace std;

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

  int n,m;
  while(true){
    cin >> n >> m;
    if(n==0) break;
    bool infected[n+1];
    for(int i=2;i<n+1;i++) infected[i]=false;
    infected[1]=true;
    int s[m+1],d[m+1];
    vector<pair<int,int>> t;
    for(int i=1;i<=m;i++){
      int tmp;
      cin >> tmp >> s[i] >> d[i];
      t.push_back(make_pair(tmp,i));
    }
    sort(t.begin(),t.end());
    for(int i=0;i<m;i++){
      int idx=t[i].second;
      if(infected[s[idx]]) infected[d[idx]]=true;
    }
    int res=0;
    for(int i=1;i<=n;i++) if(infected[i]) res++;
    cout << res<< endl;
  }
}

Measured memory_bytes: 3484
n = int(input())
l = [int(i) for i in input().split()]
cnt = 0
for i in range(n-2):
  l1 = l[i]
  for j in range(i+1, n-1):
    l2 = l[j]
    for g in range(j+1, n):
      l3 = l[g]
      l1_, l2_, l3_ = sorted([l1, l2, l3])
      if l1_ == l2_ or l2_ == l3_:
        continue
      if l3_ < l2_ + l1_:
        cnt += 1
        #print(i+1, j+1, g+1, l3_, l2_, l1_)
print(cnt)

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

void Print(const vector<string>& ss) {
  for (const auto& s : ss)
    cout << s << endl;
}

int main() {
  int H, W;
  cin >> H >> W;
  vector<string> S(H);
  for (auto& x : S) {
    cin >> x;
    x = "." + x + ".";
  }
  S.insert(S.begin(), S[0]);
  fill(S[0].begin(), S[0].end(), '.');
  S.push_back(S[0]);
  for (auto& x : S) {
    replace(x.begin(), x.end(), '.', '0');
  }
  for (int dy = -1; dy <= 1; ++dy) {
    for (int dx = -1; dx <= 1; ++dx) {
      for (int h = 0; h < H + 2; ++h) {
        for (int w = 0; w < W + 2; ++w) {
          if (S[h][w] == '#' && S[h + dy][w + dx] != '#')
            ++S[h + dy][w + dx];
        }
      }
    }
  }
  for (int h = 1; h < H + 1; ++h) {
    cout << S[h].substr(1, W) << endl;
  }
}


Measured memory_bytes: 256
N, W = map(int, input().split())
value = []
weight = []
dp = [0 for _ in range(W + 1)]
for i in range(N):
    v, w = map(int, input().split())
    for j in range(W+1):
        if j >= w:
            dp[j] = max(dp[j], dp[j - w] + v)
print(dp[W])

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

long long s[100005];


int main()
{
    
    int m, d; 
    scanf("%d%d", &m, &d);
    int cnt = 0;
    for(int i = 1; i <= m; i++){
    	for(int j = 22; j <= d; j++){
    		if(j%10>=2){
    			if((j/10)*(j%10)==i) cnt++;
			}
		}
	}
    printf("%d\n", cnt);
    return 0;
}
/*


*/

Measured memory_bytes: 256
#include <string>
#include <stdio.h>
#include <algorithm>
#include <iostream>
#include <vector>
#include <cmath>
#define rep(i,n) for(int i = 0; i < (n); i++)
using namespace std;

int main()
{
    long long x;
    cin >> x;
    long long taka = 100;
    int year = 0;
    while(taka < x){
        year++;
        taka = taka + taka / 100;
    }

    cout << year << endl;
}

Measured memory_bytes: 3636
def solve(H_list):
    max_len = 0
    prev_h = H_list[0]
    current_len = 0
    for h in H_list[1:]:
        if h > prev_h:
            max_len = max(max_len, current_len)
            current_len = 0
        else:
            current_len += 1
        prev_h = h
    max_len = max(max_len, current_len)
    return max_len


if __name__ == '__main__':
    N = int(input())
    H_list = list(map(int, input().split()))

    answer = solve(H_list)
    print(answer)


Measured memory_bytes: 14252
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		int W = sc.nextInt();
		int H = sc.nextInt();
		int x = sc.nextInt();
		int y = sc.nextInt();
		int r = sc.nextInt();

		if(y >= r && y <= H-r && x >=r && x <= W-r){
			System.out.printf("Yes\n");
		}else{
			System.out.printf("No\n");
		}
	}
}



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

int main(){
    int zero,len,ans;
    string S;
    cin >> S;
    len = S.length();

    for(int i=0;i<len;i++){
        if(S[i]=='0')zero++;
    }

    if(zero > len/2){
        ans = (len - zero)*2;
    }else{
        ans = zero*2;
    }

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

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
#define LL long long int
#define MAXN 100005
LL que[MAXN];
int n,k,head,tail;
int main()
{
    scanf("%d",&k);
    if(k<10)
    printf("%d",k);
    else
    {
    for(int i=1;i<=9;i++)
        que[tail++]=i;
    while(head<tail)
    {
        LL tmp=que[head++];
        if(tmp%10>0)
        que[tail++]=tmp*10+tmp%10-1;
        que[tail++]=tmp*10+tmp%10;
        if(tmp%10<9)
        que[tail++]=tmp*10+tmp%10+1;
        if(tail>=k)
        {
            printf("%lld\n",que[k-1]);
            break;
        }
    }
    }
    return 0;
}

Measured memory_bytes: 1024
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		long H = sc.nextLong();
		int N = sc.nextInt();
		int A[] = new int[N];
		long S = 0;
		for(int i = 0 ; i < N ; ++i){
			A[i] = sc.nextInt();
			S += A[i];
		}
		if(H <= S){
			System.out.println("Yes");
		}else{
			System.out.println("No");			
		}
	}
}


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

int main() {
    int x, y;
    while(1) {
        cin >> x >> y;
        if ( x==0 & y==0 ) break;
        if (x>y) cout << y << " " << x << endl;
        else cout << x << " " << y << endl;
    }
    return 0;
}


Measured memory_bytes: 3072
#include <iostream>
#include <stdlib.h>
using namespace std;

int main()
{
	int a, b;
	cin>>a>>b;
	if(a >= 0 && b <= 0 || a <= 0 && b >= 0) cout<<"Zero"<<endl;
	else if(a > 0 && b > 0) cout<<"Positive"<<endl;
	else
	{
		if(abs(a - b) % 2 == 0) cout<<"Negative"<<endl;
		else cout<<"Positive"<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int M = 998244353;

#ifdef LOCAL 
#include "/home/gokul/Codes/lib/prettyprint.hpp"
#else
#define debug(...) 2
#endif
template <typename T>
struct segtree {

  vector<T> seg, lazy;

  segtree(int n = 1e5) {
    n += 5;
    seg.assign(4*n, 0);
    lazy.assign(4*n, 0);
  }

  T join(T x, T y) {
    return max(x, y);
  }

  void lazy_update(int x, int s, int e) {
    if (!lazy[x])  return ;
    seg[x] = max(seg[x], lazy[x]);

    if( s != e )
      lazy[2*x] = max(lazy[2*x], lazy[x]), lazy[2*x+1] = max(lazy[2*x+1], lazy[x]);
    lazy[x] = 0;
  }

  void build(int x, int s, int e) {
    if (s == e) {
      seg[x] = 0;
      return; 
    }

    int mid = (s + e) >> 1;
    build(2 * x, s, mid);
    build(2 * x + 1, mid + 1, e);

    seg[x] = join(seg[2*x], seg[2*x+1]);
  }

  void update(int x ,int s ,int e ,int l ,int r ,T val) {
    lazy_update(x ,s ,e);
    if (s > r || e < l)  return ;

    if (s >= l && e <= r) {
      lazy[x] += val;
      lazy_update(x, s, e);
      return;
    }

    int mid = (s + e) >> 1;
    update(2 * x ,s ,mid ,l ,r ,val);
    update(2 * x + 1, mid + 1, e, l, r, val);

    seg[x] = join(seg[2 * x], seg[2 * x + 1]);
  }

  T query(int x, int s, int e, int l, int r) {
    lazy_update(x, s, e);
    if (e < l || s > r)  return 0;
    if (s >= l && e <= r){
      return seg[x];
    }

    int mid = (s + e) >> 1;
    return join(query(2 * x ,s ,mid ,l ,r), query(2 * x + 1, mid + 1, e, l, r));
  }
};

int main() {

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

  int n;
  cin >> n;

  vector<pair<int, int>> r(n);
  for (int i = 0; i < n; ++i) {
    cin >> r[i].first >> r[i].second;
  }

  sort(r.begin(), r.end());
  vector<int> nxt(n + 5);
  vector<long long> dp(n + 5, 0); 
  dp[0] = 1;
  segtree<int> seg(n);

  for (int i = n-1; i >= 0; --i) {
    int x = r[i].first, d = r[i].second;
    int j = lower_bound(r.begin(), r.end(), make_pair(x+d, 0)) - r.begin();
    int mx = seg.query(1, 0, n, i, j-1);
    nxt[i] = max(mx, i+1);
    seg.update(1, 0, n, i, i, nxt[i]);
  }
    debug(nxt);

  for (int i = 0; i < n; ++i) {
    int j = nxt[i];
    dp[j] = (dp[j] + dp[i]) % M;
    dp[i+1] = (dp[i+1] + dp[i]) % M;  
  }

  debug(dp);
  cout << dp[n] << '\n';
}

Measured memory_bytes: 10368
#include <bits/stdc++.h>
#define INF LLONG_MAX
#define ll  long long
#define ull unsigned long long
#define rep(i,n) for(int i=0; i<n; ++i)
#define MOD 1000000007
using namespace std;
template<class T> inline bool chmin(T& a, T b) { if(a>b) {a=b; return true;} return false;}
template<class T> inline bool chmax(T& a, T b) { if(a<b) {a=b; return true;} return false;}

int main() {
  int N; cin >> N;
  vector<int> t(N), x(N), y(N);
  rep(i,N) cin >> t[i] >> x[i] >> y[i];
  bool ans = true;
  rep(i, N) {
    int tmp = x[i]+y[i];
    if(tmp%2) {
      if(t[i]%2 && t[i] >= tmp) continue;
      ans = false;
      break;
    } else {
      if(t[i]%2 == 0 && t[i] >= tmp) continue;
      ans = false;
      break;
    }
  }
  printf("%s\n", ans?"Yes":"No");
}


Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define FOR(i,s,n) for(int i = (s); i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) for(int i = (n); i >= 0; i--)
#define ALL(n) (n).begin(), (n).end()
#define RALL(n) (n).rbegin(), (n).rend()
#define ATYN(n) cout << ( (n) ? "Yes":"No") << '\n';
#define CFYN(n) cout << ( (n) ? "YES":"NO") << '\n';
#define OUT(n) cout << (n) << '\n';
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;
using pll = pair<ll,ll>;

int main(void)
{
    IOS
    int n, m;
    cin >> n >> m;
    vector<pii> k(m);
    REP(i,m) {
        int b;
        cin >> k[i].first >> b;
        int key = 0,c;
        REP(i,b) {
            cin >> c;
            key += 1 << (c-1);
        }
        k[i].second = key;
    }

    int inf = 1 << 30;
    int p = pow(2,n);
    vector<int> dp(p,inf);

    REP(i,m) {
        dp[k[i].second] = min(dp[k[i].second],k[i].first);
        REP(j,p) {
            //cerr << dp[j] << " " << (j | k[i].second) <<endl;
            dp[j | k[i].second] = min(dp[j | k[i].second],dp[j] + k[i].first);
        }
        //cerr << dp[p-1] << endl;
    }

    if (dp[p-1] == inf) OUT(-1)
    else OUT(dp[p-1])


    return 0;
}

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


int main(int argc, const char * argv[]) {
    
    while(true){
        int m;
        cin >> m;
        if(m == 0){
            break;
        }
        
        int a[7] = {0}, b[7] = {0};
        
        for(int i=0;i<m;i++){
            cin >> a[i] >> b[i];
        }
        
        int g;
        cin >> g;
        
        for(int i=0;i<g;i++){
            int n;
            cin >> n;
            int count[8] = {0};
            int win =0;
            while(true){
                count[0]++;
                
                for(int j=0;j<m;j++){
                    if(count[j] > b[j]){
                        count[j] = 0;
                        count[j+1]++;
                        continue;
                    }
                    else{
                        break;
                    }
                }
                
                if(count[m] > 0){
                    break;
                }
                
                int sum = 0;
                for(int j=0;j<m;j++){
                    sum += count[j] * a[j];
                }
                
                if(sum == n) win++;
                
            }
            
            cout << win << endl;
            
        }
        
        
    }
    
    return 0;
}

Measured memory_bytes: 1160
<?php

$is_honban = 1;

if ($is_honban) {
  //----------------------------------------------------------------------------------
  // Input for honban
  //----------------------------------------------------------------------------------
  $sc = new Scanner();
  $n = $sc->nextInt();
  $s = $sc->next();

//  $h = array();
//  for ($i = 0; $i < $n; $i++) {
//    $h[] = $sc->nextInt();
//  }


} else {
  //----------------------------------------------------------------------------------
  // Input for test
  //----------------------------------------------------------------------------------
  error_reporting(E_ERROR | E_WARNING | E_PARSE);

  $n = 5;
  $a = 2;
  $b = 1;
  $h = array(90000,90000,100000,100000,100000);



}
//----------------------------------------------------------------------------------
// Main
//----------------------------------------------------------------------------------

$ans = 0;

$r = 0;
for ($i = 0; $i < $n; $i++) {
  if ($s[$i] == 'R') { $r++; }
}

$ans = ($r > $n/2) ? 'Yes' : 'No';

//----------------------------------------------------------------------------------
// Output
//----------------------------------------------------------------------------------
out::println($ans);



//----------------------------------------------------------------------------------
// Ref: https://qiita.com/yoshikyoto/items/6924478283dbdd549e4b
//----------------------------------------------------------------------------------
class Scanner {
  private $arr = array();
  private $count = 0;
  private $pointer = 0;
  public function next() {
    if($this->pointer >= $this->count) {
      $str = trim(fgets(STDIN));
      $this->arr = explode(' ', $str);
      $this->count = count($this->arr);
      $this->pointer = 0;
    }
    $result = $this->arr[$this->pointer];
    $this->pointer++;
    return $result;
  }
  public function hasNext() {
    return $this->pointer < $this->count;
  }
  public function nextInt() {
    return (int)$this->next();
  }
  public function nextDouble() {
    return (double)$this->next();
  }
}

class out {
  public static function println($str = "") {
    echo $str . PHP_EOL;
  }
}

?>


Measured memory_bytes: 3828
#include <iostream>

using namespace std;
int main(){
  int n, a, b;
  cin >> n;
  cin >> a >> b;
  int *p = (int *)calloc(n, sizeof(int));
  for(int i=0;i<n;i++){
    cin >> p[i];
  }

  int ar[3]={};
  for(int i=0;i<n;i++){
    if(p[i]<=a){
      ar[0]++;
    } else if (a<p[i] && p[i]<=b) {
      ar[1]++;
    } else {
      ar[2]++;
    }
  }

  int buf = ar[0];
  for(int i=1;i<3;i++){
    if(ar[i]<buf)buf = ar[i];
  }

  cout << buf << endl;

  return 0;
}


Measured memory_bytes: 256
using System;

public class UnionFind
{
	int[] uni;

	public UnionFind(int N)
	{
		uni = new int[N];
		for(int i=0; i < N; i++)
		{
			uni[i] = -1;
		}
	}

	public int Root(int a)
	{
		if (uni[a] < 0) return a;
		else return uni[a] = Root(uni[a]);
	}

	public bool Connect(int a, int b)
	{
		a = Root(a);
		b = Root(b);
		if (a == b) return false;
		if (uni[a] > uni[b]) swap(ref a, ref b);
		uni[a] += uni[b];
		uni[b] = a;
		return true;
	}

	void swap<T>(ref T a, ref T b)
	{
		T c = a;
		a = b;
		b = c;
	}
}

class CF2016FC
{
	static public void Main(string[] args)
	{
		int N, M;
		string[] vals = Console.ReadLine().Split(' ');

		N = int.Parse(vals[0]);
		M = int.Parse(vals[1]);

		UnionFind uf = new UnionFind(N+1);
		int[] repre = new int[M+1];
		for(int i=1; i<=M; i++)
		{
			repre[i] = -1;
		}

		int K, L;
		for(int i=1; i<=N; i++)
		{
			vals = Console.ReadLine().Split(' ');
			K = int.Parse(vals[0]);
			for(int j=1; j<=K; j++)
			{
				L = int.Parse(vals[j]);
				if(repre[L] == -1)
				{
					repre[L] = i;
				}
				else
				{
					uf.Connect(repre[L], i);
				}
			}
		}

		int root = -1;
		for(int i=1; i<=M; i++)
		{
			if(repre[i] == -1)
				continue;

			if(root == -1)
			{
				root = uf.Root(repre[i]);
			}
			else
			{
				if(uf.Root(repre[i]) != root)
				{
					Console.WriteLine("NO");
					return;
				}
			}
		}
		Console.WriteLine("YES");
	}

}


Measured memory_bytes: 21208
n,m=map(int,input().split())
graph = [[] for i in range(n)]
x=[None for _ in range(n)]
for _ in range(m):
    a,b,c=map(int,input().split())
    graph[b-1].append([a-1, -c])
    graph[a-1].append([b-1, c])
def fuck():
    for i in range(n):
        if x[i]==None:
            x[i]=0
            q=[i]
        while q:
            j=q.pop()
            for  d, e in graph[j]:
                if x[d]==None:
                    q.append(d)
                    x[d]=x[j]+e
                elif x[d]!=x[j]+e:
                    return False
    return True
if fuck():
    print("Yes")
else:
    print("No")



Measured memory_bytes: 76980
import java.util.*;
 
public class Main{
  public static void main(String args[]){
    Scanner sc = new Scanner(System.in);
	String str = sc.nextLine();
    String[] ln = str.split(" ");
    int n = Integer.parseInt(ln[0]);
    int l = Integer.parseInt(ln[1]);
 
    List<String> strList = new ArrayList<String>(); 

    for(int i = 0; i < n; i++){
  		    strList.add(sc.nextLine());
	}
 
    Collections.sort(strList);
    
    for(String str2 :strList){
	    System.out.print(str2);
    }
  }	
}

Measured memory_bytes: 22100
#include<stdio.h>

static const int N = 1000;

void trace(int A[], int n){
  int i;
  for ( i = 1; i <= n; i++ ){
    if ( i > 1 ) printf(" ");
    printf("%d", A[i]);
  }
  printf("\n");
}

int main(){
  int n, i, j,key;
  int A[N+1];
  scanf("%d", &n);

  for ( i = 1; i <= n; i++ ) scanf("%d", &A[i]);

  trace(A, n);

  for(i = 2;i <= n;i++){
    key = A[i];
    j = i - 1;
    while(j >= 0 && A[j] > key){
      A[j+1] = A[j];
      j--;
      A[j+1] = key;
    }
    trace(A,n);
  }

  return 0;
}



Measured memory_bytes: 2084
#include <bits/stdc++.h>
using namespace std;
#define inf 0x3f3f3f3f
const int maxn = 10000+5;
int N,M,dis[maxn],vis[maxn],cost[maxn];
struct edge
{
    int v,d,c;
    edge(int A,int B,int C):v(A),d(B),c(C) {}
};
vector<edge> G[maxn];
queue<int> que;

void spfa()
{
    memset(dis, inf, sizeof(dis));
    memset(vis, 0, sizeof(vis));
    memset(cost, inf, sizeof(cost));
    vis[1] = 1;
    dis[1] = 0;
    cost[1] = 0;
    que.push(1);
    while(!que.empty())
    {
        int u = que.front();
        que.pop();
        for(int i = 0; i < G[u].size(); i++)
        {
            edge &e = G[u][i];
            if(dis[e.v] > dis[u] + e.d)
            {
                dis[e.v] = dis[u] + e.d;
                cost[e.v] = e.c;
                if(!vis[e.v])
                {
                    vis[e.v] = 1;
                    que.push(e.v);
                }
            }
            else if(dis[e.v] == dis[u] + e.d && cost[e.v] > e.c)
            {
                cost[e.v] = e.c;
                if(!vis[e.v])
                {
                    vis[e.v] = 1;
                    que.push(e.v);
                }
            }
        }
        vis[u] = 0;
    }
    int ans = 0;
    for(int i = 1; i <= N; i++)
    ans += cost[i];
    cout << ans << endl;
}


//void spfa()
//{
//    memset(dis, inf, sizeof(dis));
//    memset(vis, 0, sizeof(vis));
//    memset(cost, inf, sizeof(cost));
//    vis[1] = 1;
//    dis[1] = 0;
//    cost[1] = 0;
//    que.push(1);
//    while(!que.empty())
//    {
//        int u = que.front();
//        que.pop();
//        for(int i=0; i<G[u].size(); ++i)
//            {
//            edge &e = G[u][i];
//            if(dis[e.v] > dis[u] + e.d)
//            {
//                dis[e.v] = dis[u] + e.d;
//                cost[e.v] = e.c;
//                if(!vis[e.v])
//                {
//                    vis[e.v] = 1;
//                    que.push(e.v);
//                }
//            }
//            else if(dis[e.v] == dis[u] + e.d && cost[e.v] > e.c)
//            {
//                cost[e.v] = e.c;
//                if(!vis[e.v])
//                {
//                    vis[e.v] = 1;
//                    que.push(e.v);
//                }
//            }
//        }
//        vis[u]=0;
//    }
//    int ans = 0;
//    for(int i=1; i<=N; ++i)
//        ans+=cost[i];
//    cout<<ans<<endl;
//}

int main()
{
    while(cin>>N>>M)
    {
        if(N==0&&M==0)
            break;
        int u,v,d,c;
        for(int i=1; i<=M; ++i)
        {
            cin>>u>>v>>d>>c;
            G[u].push_back(edge(v,d,c));
            G[v].push_back(edge(u,d,c));
        }
        spfa();
//        /// clear
        for(int i=1; i<=N; ++i)
            G[i].clear();
    }
    return 0;
}

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

int main() {
  int n,m;
  cin >> n >> m;
  vector<int> dp(n+5);
  rep(i,m) {
    int a,b;
    cin >> a >> b;
    dp[a]++;
    dp[b]++;
  }
  for (int i = 1; i <= n; i++){
    cout << dp[i] << endl;
  }
  return 0;

}

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

int main() {
  int N, a, b, c, d;
  cin >> N;

  d = N % 10;
  c = (N % 100 - d) / 10;
  b = (N % 1000 - N % 100) / 100;
  a = N / 1000;

  if (a == b && b == c){
    cout << "Yes" << endl;
  }
  else if (b == c && c == d){
    cout << "Yes" << endl;
  }
  else if (a == b && b == c && c == d){
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
 }

Measured memory_bytes: 256
map = ["a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z"]
s = gets.chomp
len = s.length
if len == 26
  i = 25
  while s[i-1] > s[i] && i > 0
    i -= 1
  end
  if i == 0
    puts -1
    exit
  end
  min = 25
  for j in i..25
    if map.find_index(s[i-1]) < map.find_index(s[j])
      min = [min,map.find_index(s[j])].min
    end
  end
  if i == 1
    puts map[min]
  else
    puts s[0..i-2] + map[min]
  end
else
  i = 0
  while s.include?(map[i])
    i += 1
  end
  puts s + map[i]
end

Measured memory_bytes: 14328
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
    char a[3], b[3];
    scanf("%s%s", a, b);
    int ans = 0;
    for (int i = 0; i < 3; i++)
    {
        if (a[i] == b[i])
        {
            ans++;
        }
    }
    printf("%d\n", ans);
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxx = 1e6 + 7;
const int Inf = 1 << 30;
const ll INF = 1ll << 60;
#define mst(x) memset(x, 0, sizeof(x))
priority_queue <int> qua;
ll a[maxx];
vector <ll> vec;
int n, k;
ll ans;

void Init() {
	cin >> n >> k;
	for(int i = 1; i <= n; i++) cin >> a[i];
	for(int i = 1; i <= n; i++) {
		ll sum = 0;
		for(int j = i; j <= n; j++) {
			sum += a[j];
			vec.push_back(sum);
		}
	}
}

void solve() {
	for(int bit = 59; bit >= 0; bit--) {
		int t = 0;
		int sz = vec.size();
		for(int i = 0; i < sz; i++) {
			ll dd = 1ll << bit;
			if(vec[i] & dd) t++;
		}
		if(t < k) continue;
		vector <ll> tmp;
		tmp.clear();
		for(int i = 0; i < sz; i++) {
			ll dd = 1ll << bit;
			if(vec[i] & dd) tmp.push_back(vec[i]);
		}
		vec = tmp;
		ans += 1ll << bit;
	}
}

int main() {
	Init();
	solve();
	cout << ans << endl;
}

Measured memory_bytes: 6252
#include<iostream>
#include<string>
#include<algorithm>
#include<bits/stdc++.h>
#include<vector>
 
using namespace std;
 
int main() {
  string S;
  cin >> S;
  int w;
  cin >> w;
  for(int i=0; i<S.size(); i+=w) cout << S[i];
  cout << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define double long double
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,n) for(int i=1;i<=(n);i++)
#define mod (ll)(1e9+7)
#define inf (ll)(3e18+7)
#define pi (double) acos(-1)
#define P pair<int,int>
#define PiP pair<int,pair<int,int>>
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
using namespace std;

int main() {
    int n;
    cin >> n;
    bool ans = false;
    for(int i = 0; i * 4 <= n; i++){
        if((n-i*4) % 7 == 0)ans = true;
    }
    cout << (ans ? "Yes" : "No");
}  

Measured memory_bytes: 256
import sys


def input():
    return sys.stdin.readline().strip()


N = int(input())
P = list(map(int, input().split()))

ans = 0
for i in range(N - 1):
    if i + 1 == P[i]:
        P[i], P[i + 1] = P[i + 1], P[i] 
        ans += 1
if P[N-1] == N:
    ans += 1
print(ans)


Measured memory_bytes: 14008
#include<bits/stdc++.h>
 
typedef long long int lli;
typedef unsigned long long int ulli;
typedef long double ldb;
 
#define pb push_back
#define popb pop_back
#define popf pop_front
#define pf push_front
#define si size()
#define mp make_pair 
#define mt make_tuple
#define F first
#define S second
#define lb lower_bound
#define ub upper_bound

#define ask(i,m,n) for(lli i=m;i<n;i++)
#define anket ios::sync_with_stdio(0), cin.tie(0),cout.tie(0)
 
#define endl "\n"
#define o0(a) cout<<a<<" "
#define o1(a) cout<<a<<"\n"
#define o2(a,b) cout<<a<<" "<<b<<"\n"
#define o3(a,b,c) cout<<a<<" "<<b<<" "<<c<<"\n"
#define o4(a,b,c,d) cout<<a<<" "<<b<<" "<<c<<" "<<d<<"\n"
using namespace std;

#define prime1 1000000007
#define prime2 998244353

lli modadd(lli n,lli m , lli mod){
    lli sum = ((n+m)%mod+mod)%mod;
    return sum;
}

lli modsub(lli n,lli m,lli mod){
    lli diff = ((n-m+mod)%mod+mod)%mod;
    return diff;
}

lli modpro(lli n,lli m, lli mod){
    lli pro = ((n*m)%mod+mod)%mod;
    return pro;
}

lli powmod(lli x,lli y,lli mod){
    x %= mod;
    y %= mod;
    lli res = 1;
    while (y > 0) {
        if (y & 1)
            res = modpro(res , x,mod);
        y = y >> 1;
        x = modpro(x , x,mod);
    }
    return res;
}

lli moddiv(lli n,lli m,lli mod){
    //return n/m mod (mod) or n*(m)^-1 mod (mod)
    lli a = powmod(m,mod-2,mod);
    //this is because of fermats thm i.e. a^-1 = a^p-2 mod(p) check
    //multiplying p on both sides
    lli res = modpro(a,n,mod);
    return res;
}

vector<lli> prefix_function(string s) {
    lli n = (lli)s.length();
    vector<lli> pi(n);
    for (lli i = 1; i < n; i++) {
        lli j = pi[i-1];
        while (j > 0 && s[i] != s[j])
            j = pi[j-1];
        if (s[i] == s[j])
            j++;
        pi[i] = j;
    }
    return pi;
}


int main() {
	anket;
	lli n;
	cin>>n;
	string s;
	cin>>s;
	lli a=0,b=0,c=0;
	ask(i,0,n){
	    if(s[i]=='R'){
	        a++;
	    }
	    else if(s[i] == 'G'){
	        b++;
	    }
	    else{
	        c++;
	    }
	}
	lli ans = a*b*c;
	for(lli i=n-1;i>=0;i--){
	    for(lli j=i-1;j>=0 && 2*j-i>=0;j--){
	        if(s[i]!= s[j] && s[j] != s[2*j-i] && s[i] != s[2*j-i]){
	            ans--;
	        }
	    }
	}
	o1(ans);
	return 0;
}




Measured memory_bytes: 3664
import math

N = int(input())
points = []
for i in range(N):
    point = list(map(int, input().split()))
    points.append(point)

# 合計距離の計算
distance_sum = 0
for i in range(N):
    for j in range(N):
        distance_sum += math.sqrt((points[i][0] - points[j][0]) ** 2 + (points[i][1] - points[j][1]) ** 2)
distance_sum /= 2

# result = distance_sum
# if N > 2:
#     routes_num = math.factorial(N)
#     two_points_combi_num = math.factorial(N) / math.factorial(N - 2) / math.factorial(2)
#     duplicate_count = (two_points_combi_num - (N - 1)) / two_points_combi_num * routes_num
#     result = distance_sum * (routes_num - duplicate_count) / routes_num
routes_num = math.factorial(N)
two_points_combi_num = math.factorial(N) / math.factorial(N - 2) / math.factorial(2)
duplicate_count = (two_points_combi_num - (N - 1)) / two_points_combi_num * routes_num
result = distance_sum * (routes_num - duplicate_count) / routes_num
print(result)


Measured memory_bytes: 3064
list=input().split(" ")
n=int(list[0])
m=int(list[1])

denkyu=[]

for i in range(m):
    info=input().split(" ")
    for j in range(len(info)):
        info[j]=int(info[j])
    list=[]
    for i in range(n):
        list.append(0)
    
    #print(info)
    for j in range(len(info)-1):
        list[info[j+1]-1]=1
    denkyu.append(list)

#print(denkyu)

shogo=[]

for x in range(2**n):
    shinsu=[]
    for y in range(n):
        if x%2==1:
            shinsu.append(1)
            x=int((x-1)/2)
        else:
            shinsu.append(0)
            x=int((x)/2)
    shogo.append(shinsu)

#print(shogo)

plist=input().split(" ")
for j in range(len(plist)):
    plist[j]=int(plist[j])

#print(plist)

#print("")
kosu=0
for s in shogo:
    switch=1
    now=0
    complete=0
    while switch==1:
        match=0
        for i in range(n):
            if s[i]==denkyu[now][i] and s[i]==1:
                #print("X", s[i], denkyu[now][i], s, denkyu[now])
                match+=1
        if match%2==plist[now]:
            now+=1
        else:
            switch=0
        if now==(m):
            if switch==1:
                complete=1
                switch=0
                #print(s)
    if complete==1:
        kosu+=1
        #print("y", s)
print(kosu)


Measured memory_bytes: 3188
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <algorithm>
#define mod 998244353

using namespace std;
typedef long long ll;
const int MAXN = 400005;
int n,a[MAXN],b[MAXN];
char str[MAXN];
ll f[MAXN];
inline void solve(int x)
{
	ll res = 0;
	for(int i = 1; i<=x/2; i++)
		res = (res*2+a[i])%mod;
	res = (res+1)%mod;
	for(int i = 1, j = 0; i<=n; i += x/2, j++)
		for(int k = i; k<=i+x/2-1; k++)
			b[k] = a[k-i+1]^(j&1);
	bool flag = true;
	for(int i = 1; i<=n; i++)
	{
		if(b[i]>a[i])
			flag = false;
	    else if(b[i]<a[i])
	    	break;
	}
	if(!flag)
		res = (res+mod-1)%mod;
	f[x] = res;
}

int main()
{
	cin >> n >> str+1;
	for(int i = 1; i<=n; i++)
		a[i] = str[i]-'0';
	for(int i = 1; i<=2*n; i++)
		if(2*n%i==0&&n%i!=0)
			solve(i);
	for(int i = 1; i<=2*n; i++)
		if(2*n%i==0&&n%i!=0)
			for(int j = 2*i; j<=2*n; j += i)
				if(2*n%j==0&&n%j!=0)
					f[j] = (f[j]-f[i]+mod)%mod;
	ll ans = 0;
	for(int i = 1; i<=2*n; i++)
		ans = (ans+f[i]*i)%mod;
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 4480