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

using ll = long long;
using ull = unsigned long long;

const double PI = acos(-1);
const int inf = 2e9;
const ll INF = 2e18;
const ll MOD = 1e9+7;

#define sz(s) (s).size()
#define pb push_back
#define fi first
#define se second
#define REP(i,n) for (int i = 0; i<n; i++)
#define ALL(a) begin(a), end(a)

int main (void) {
    int N,M,Q;
    cin>>N>>M>>Q;
    vector<vector<int>> A(N+1,vector<int>(N+1,0));
    REP(i,M) {
        int l,r;
        cin>>l>>r;
        l--;r--;
        A[l][r]++;
    }
    REP(i,N) {
        for (int j=N-1;j>=0;j--) {
            A[j][i] += A[j+1][i];
        }
    }
    REP(i,N) {
        for (int j=1;j<N;j++) {
            A[i][j] += A[i][j-1];
        }
    }
    vector<pair<int,int>> qu(Q);
    REP(i,Q) {
        int a,b;
        cin>>a>>b;
        a--;b--;
        qu[i] = make_pair(a,b);
    }
    REP(i,Q) {
        cout<<A[qu[i].fi][qu[i].se]<<endl;
    }
    return 0;
}

Measured memory_bytes: 2688
#include <stdio.h>

int main(void)
{
  int x,y;
  int re; //remainder = ??????
  
  scanf("%d%d",&x,&y);

  while(1){
    re = x%y;
    x = y;
    y = re;
    if(re == 0){
      break;
    }
  }

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

Measured memory_bytes: 592
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define USE_LLONG_AS_INT
#ifdef USE_LLONG_AS_INT
#define int long long
#define inf (1ll<<60)
#else
#define inf (1<<30)
#endif
#define rep(i,n) for(int i=0;i<(n);i++)
#define Rep(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,a,b) for(int i=(a);i<=(b);i++)
#define rev(i,n) for(int i=(n)-1;i>=0;i--)
#define vi vector<int>
#define vvi vector<vi>
#define pb push_back
#define eb emplace_back
#define pi pair<int,int>
#define vp vector<pair<int,int>>
#define mp make_pair
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define MEMSET(a) memset(a,0,sizeof(a))
#define Yes(f) cout<<(f?"Yes":"No")<<endl
#define yes(f) cout<<(f?"yes":"no")<<endl
#define YES(f) cout<<(f?"YES":"NO")<<endl
#define SORT(v) sort(all(v))
#define RSORT(v) sort(all(v), greater<int>())

using namespace std;

const int mod=1e9+7;
const string sp=" ";

void run();

void init() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout<<fixed<<setprecision(12);
}

signed main(){
    init();
    run();
    return 0;
}

void run(){
    int n;
    string s,t;
    cin>>n>>s>>t;
    rep(i,n)cout<<s[i]<<t[i];
}

Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
#include<vector>
#include<algorithm>
#include<set>
#include<string>
#include<map>
#include<string.h>
#include<complex>
#include<math.h>
#include<queue>
#include <functional>
#include<time.h>
#include <stack>
#include<iomanip>
using namespace std;
#define rep(i,a,n) for(llint i=(a);i<(n);i++)
#define ll long long
#define llint long long int
#define sort(s) sort(s.begin(),s.end())
#define reverse(v)  reverse(v.begin(), v.end());
#define Yes(ans) if(ans)cout<<"Yes"<<endl; else cout<<"No"<<endl;
#define YES(ans) if(ans)cout<<"YES"<<endl; else cout<<"NO"<<endl;
#define hei(a) vector<a>
#define whei(a) vector<vector<int>>
constexpr auto mod = 1000000007;
//辞書順はnext_permutation( begin( v ), end( v ) );やで！


//2のn乗を求めるよ！！！
int ni(int n) {
	if (n == 0)return 1;
	int x = ni(n / 2);
	x *= x;
	if (n % 2 == 1)x *= 2;
	return x;
}

//フィボナッチ数列のx番目を求めるよ！
llint f(int x, vector<llint> &s) {
	if (x == 0)return 0;
	if (x == 1)return 1;
	if (s[x] != 0)return s[x];
	return  s[x] = f(x - 1, s) + f(x - 2, s);
	
}

//aとｂの最大公約数を求めるよ！
llint gcd(llint a, llint b) {
	if (a < b)swap(a, b);
	if (b == 0)return a;
	return gcd(b, a % b);
}



// a^n mod を計算する
long long modpow(long long a, long long n, long long mod) {
	long long res = 1;
	while (n > 0) {
		if (n & 1) res = res * a % mod;
		a = a * a % mod;
		n >>= 1;
	}
	return res;
}

// mod. m での a の逆元 a^{-1} を計算するよ！
long long modinv(long long a, long long m) {
	long long b = m, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}


//aCbをmod.mで割った余りを求める
ll int c(ll int a, ll int b, ll int m) {
	ll int ans = 1;
	for (ll int i = 0; i < b; i++) {
		ans *= a - i;
		ans %= m;
	}
	for (ll int i = 1; i <= b; i++) {
		ans *= modinv(i, m);
		ans %= m;
	}
	return ans;
}

//m進数のn桁を全列挙やで
void dfs(int m, int n) {
	stack<string> st;
	st.push("");
	while (!st.empty()) {
		string now = st.top();
		st.pop();
		if (now.size() == n) {
			cout << now << endl;
		}
		else {
			for (int i = m - 1; i >= 0; i--) {
				string next = now + to_string(i);
				st.push(next);
			}
		}
	}
}
void press(vector<int>& v) { v.erase(unique((v).begin(), (v).end()), v.end()); }

llint min(llint a, llint b) {
	if (a < b)return a;
	return b;
}
llint max(llint a, llint b) {
	if (a < b)swap(a, b);
	return a;
}
llint p(int n) {
	if(n==1)return 1;
	return n * p(n - 1);
}

int main() {
	ll a, b;
	int ans = 0;
	cin >> a >> b;
	for (int i = 0;; i++) {
		if (a > b) {
			ans = i;
			break;
		}
		a *= 2;
	}
	cout << ans << endl;
	return 0;
}


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

using namespace std;

#define ll long long
ll input(){
	ll x=0,f=0;char ch=getchar();
	while(ch<'0'||ch>'9') f|=ch=='-',ch=getchar();
	while(ch>='0'&&ch<='9') x=x*10+ch-'0',ch=getchar();
	return f? -x:x;
}

const int N=3007;

int n;
double p[N];
double dp[N][N];
double Ans;

int main(){
	n=input();
	for(int i=1;i<=n;i++){
		scanf("%lf",&p[i]);
	}

	dp[0][0]=1;

	for(int i=1;i<=n;i++){
		for(int j=0;j<=i;j++){
			int x=j,y=i-j;
			if(x) dp[x][y]+=dp[x-1][y]*p[i];
			if(y) dp[x][y]+=dp[x][y-1]*(1-p[i]);
		}
	}
	int l=n,r=0;
	while(l>r){
		Ans+=dp[l][r];
		l--,r++;
	}
	printf("%.10lf\n",Ans);
}

Measured memory_bytes: 70016
#pragma GCC optimize("O3")
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
using namespace std;

using ll = long long;
using P = pair<int, int>;
using T = tuple<int, int, int>;

template <class T> inline T chmax(T &a, const T b) {return a = (a < b) ? b : a;}
template <class T> inline T chmin(T &a, const T b) {return a = (a > b) ? b : a;}

constexpr int MOD = 1e9 + 7;
constexpr int inf = 1e9;
constexpr long long INF = 1e18;

#define all(a) (a).begin(), (a).end()

int dx[] = {1, 0, -1, 0};
int dy[] = {0, 1, 0, -1};

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

    int k; cin>>k;
    string s; cin>>s;

    if(k < s.size()){
        s = s.substr(0, k) + "...";
    }

    cout << s << endl;

    return 0;
}

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

#define pb push_back
#define fi first
#define se second
typedef long long ll;

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

	int l;
	cin >> l;

	double a = (double)l / 3;
	cout << fixed << setprecision(20) << a * a * a << '\n';
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FASTIO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define LL long long 

const int N = 1e6 + 6;
vector<int> g[N];
int sub[N], p[N];
int root(int u) {
    while(p[u] != u) {
        p[u] = p[p[u]];
        u = p[u];
    }
    return u;
}
void merge(int uu, int vv) {
    int u = root(uu), v = root(vv);
    if (u == v) return;
    if (sub[u] < sub[v]) swap(u, v);
    p[v] = u;
    sub[u] += sub[v];
}
void solve() {
    int n;
    cin >> n;
    for (int i=1;i<=n;++i) {
        g[i].clear();
        p[i] = i;
        sub[i] = 1;
    }
    for (int i=1;i<n;++i) {
        int u, v;
        cin >> u >> v;
        g[u].push_back(v);
        g[v].push_back(u);
    }
    LL ans = 0, now = 0;
    for (int i=1;i<=n;++i) {
        int x = 0, pre = i, add = 1;
        sort(g[i].begin(), g[i].end());
        reverse(g[i].begin(), g[i].end());
        for (auto it : g[i]) {
            if (it > i) continue;
            now += (pre - it) * add;
            // cout << it << " at " << i << ' ' << add << '\n';
            if (root(it) != root(i)) add--;
            merge(it, i);
            pre = it;
        }
        now += pre * add;
        ans += now;
        // cout << now << ' ' << i << '\n';
    } 
    cout << ans << '\n';
}

int main() {
    FASTIO;
    int t = 1;
    // cin >> t;
    while(t--) solve();
    return 0;
}

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

int main(){
	string s1,s2;
	cin>>s1>>s2;
	int mi=1000000000;
	for(int i=0;i<=s1.size()-s2.size();i++){
		int cnt=0;
		for(int j=0;j<s2.size();j++){
			if(s1[i+j]!=s2[j]){
				cnt++;
			}
		}
		mi=min(mi,(int)(cnt));
	}
	cout<<mi<<endl;
}

Measured memory_bytes: 3596
N = int(input())
# 初期状態
T = [0]
X = [0]
Y = [0]
for i in range(N):
    t, x, y = map(int, input().split())
    T.append(t)
    X.append(x)
    Y.append(y)

# パリティに着目せよ
count = 0
for i in range(N):
    distanceSum = abs(X[i+1]-X[i]) + abs(Y[i+1]-Y[i])
    T_parity = (T[i+1]-T[i])
    Distance_parity = distanceSum
    if (T_parity-Distance_parity) % 2 == 0 and (T_parity-Distance_parity) >= 0:
        count += 1

if count == N:
    print('Yes')
else:
    print('No')


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


int main(int argc, char const *argv[])
{
	int n, m; cin >> n >> m;
	vector<int> k(m); vector<vector<int>> s(m); {
		rep(i, m) {
			cin >> k[i];
			rep(j, k[i]) {
				int d; cin >> d; d--;
				s[i].emplace_back(d);
			}
		}
	}
	vector<int> p(m); rep(i, m) cin >> p[i];

	int ans = 0;
	for (int mask = 0; mask < (1 << n); ++mask) {
		bool flag = true;
		rep(i, m) {
			int on_cnt = 0;
			for (auto sw_idx : s[i]) {
				if (mask & (1 << sw_idx)) on_cnt++;
			}
			if (on_cnt % 2 != p[i]) flag = false;
		}
		if (flag) ans++;
	}
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
N=int(input())
T=[i for i in list(map(int,input().split()))]
M=int(input())
Px=[list(map(int,input().split())) for i in range(M)]
[print(sum([m[1] if m[0]==n+1 else T[n] for n in range(N)])) for m in Px]


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

int sum_Digits(int n){
  int sum = 0;
  while(n > 0){
    sum += n % 10;
    n /= 10;
  }
  return sum;
}

int main(){
  int x, fx;
  cin >> x;
  
  fx = sum_Digits(x);
  if(x%fx == 0){
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}

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

int main() {
  int a, b, c, d;
  cin >> a >> b >> c >> d;
  int r = a+b;
  int l = c+d;
  
  if(r < l) cout << "Right" << endl;
  else if(r > l) cout << "Left" << endl;
  else cout << "Balanced" << endl;
  
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
 
int main(void)
{
    int n,i,j;
      
    scanf("%d",&n);
  
    for(i=1;i<=9;i++){
       for(j=1;j<=9;j++)
           if(i*j==n){  
           printf("Yes\n");   
           return 0;
       }         
    }
    
    printf("No\n");
  
}      

Measured memory_bytes: 128
/*For the name of God*/

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long llu;
const ll inf = 1e9;
const ll mod = 1e9 + 7;
const double eps = 1e-8;
const ll MAX = 1e7 + 20;
#define fast ios_base:: sync_with_stdio( false ); cin.tie(0); cout.tie(0);
#define eb              emplace_back
#define em              emplace
#define pb              push_back
#define Mp              make_pair
#define ff              first
#define ss              second
#define all(a)          a.begin(),a.end()
#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,a,n)     for(int i=a;i<=n;i++)
#define per(i,n,a)      for(int i=n;i>=a;i--)
#define pf(n)           printf("%lld",n)
#define pfi(n)          printf("%d",n)
#define sp              printf(" ")
#define ln              "\n"

template< class T > T gcd(T a, T b)
{
    return (b != 0 ? gcd<T>(b, a%b) : a);
}
template< class T > T lcm(T a, T b)
{
    return (a / gcd<T>(a, b) * b);
}
const int N = 200200;
pair<int,int>c[1000001];
int main()
{
    /*#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif*/
    fast

    ll a,b,d,ac=0,wa=0;
    string x,y;
    set<ll>s;
    cin>>a>>b;
    for(int i=0; i<b; i++)
    {
        cin>>d>>x;
        c[d].first=d;
        if(x!="AC" && s.find(c[d].first)==s.end())
        {
            c[d].second++;
        }
        else if(x=="AC" && s.find(c[d].first)==s.end())
        {
            ac++;
            s.insert(c[d].first);
            wa+=c[d].second;
        }
    }
    cout<<ac<<" "<<wa<<endl;
}


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

int main(){
	ll a,b,k,inp,ans=0,maks=0,temp,tmp;
	vector<ll>bukua;
	vector<ll>bukub;
	cin >> a >> b >> k;
	for(ll i=0;i<a;i++){
		cin >> inp;
		//bukua[i]=inp+bukua[i-1];
		if(i==0) bukua.push_back(inp);
		else bukua.push_back(inp+bukua[(int)bukua.size()-1]);
	}
	for(ll i=0;i<b;i++){
		cin >> inp;
		//bukub[i]=inp+bukub[i-1];
		if(i==0) bukub.push_back(inp);
		else bukub.push_back(inp+bukub[(int)bukub.size()-1]);
	}
	for(ll i=0;i<a;i++){
		temp=k-bukua[i];
		//cout << temp << "\n";
		if(temp<0) break;
		if(temp==0) {
			// cout << "hi\n";
			// cout << i+1 << "\n";
			// cout << max(maks,i+1) << "\n";
			maks=max(maks,i+1);
			break;
		}
		tmp=lower_bound(bukub.begin(),bukub.end(),temp)-bukub.begin();
		//cout << tmp << "\n";
		if(tmp==(int)bukub.size()) {
			maks=max(maks,i+1+tmp);
			continue;
		}
		else if(bukub[tmp]>temp) ans=tmp+i+1;
		else ans=tmp+i+1+1;
		maks=max(maks,ans);
	}
	for(ll i=0;i<b;i++){
		temp=k-bukub[i];
		if(temp<0) break;
		if(temp==0) {
			maks=max(maks,i+1);
			continue;
		}
		tmp=lower_bound(bukua.begin(),bukua.end(),temp)-bukua.begin();
		if(tmp==(int)bukua.size()){
			maks=max(maks,i+1+tmp);
			continue;
		}
		else if(bukua[tmp]>temp) ans=tmp+i+1;
		else ans=tmp+1+i+1;
		maks=max(ans,maks);
	}
	cout << maks << "\n";
}

Measured memory_bytes: 7960
#include <bits/stdc++.h>
#define int long long
#define uint unsigned int
#define pii pair<int, int>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define FORR(i,a,b) for(int i=(a);i>=(b);--i)
#define REP(i,n) FOR(i,0,n)
#define REPR(i,n) FORR(i,n,0)
#define ALL(c) ((c).begin(),(c).end())
#define PB(a) push_back(a)
#define EMPB(...) emplace_back(__VA_ARGS__)
#define EMP(...) emplace(__VA_ARGS__)
#define MP(a,b) make_pair(a,b)
#define MT(...) make_tuple(__VA_ARGS__)
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
#define MINF(a) memset(a,0x3f,sizeof(a))
#define PW(n) (1LL<<(n))
using namespace std;
template <class T> inline bool CHMIN(T& a, T b) { if(a>b) { a=b; return 1; } return 0; }
template <class T> inline bool CHMAX(T& a, T b) { if(a<b) { a=b; return 1; } return 0; }
template <class T> inline void SORT(T& a) { sort(ALL(a)); }
template <class T> inline void REV(T& a) { reverse(ALL(a)); }
template <class T> inline void UNI(T& a) { SORT(a); a.erase(unique(ALL(a)),a.end()); }
template <class S, class T> ostream& operator<<(ostream& os, const pair<S,T> a) {
  return os << a.first << ' ' << a.second;
}
const int MOD = 1000000007;
// const int INF = 0x3f3f3f3f3f3f3f3f;
// const double EPS = 1e-10;
/* ---------------------------------------------------------------------------------------------------- */

/* 基本要素 */
using D = double; // 座標値の型 doubleかlong double
using P = complex<D>; // Point
using L = pair<P,P>;  // Line
using VP = vector<P>;
const double EPS = 1e-8;  // 許容誤差
const double INF = 1e12;
#define X real()
#define Y imag()
#define LE(n,m) ((n)<(m)+EPS) // n <= m ?
#define GE(n,m) ((n)+EPS>(m)) // n >= m ?
#define EQ(n,m) (abs((n)-(m))<EPS)

namespace std {
  istream& operator >> (istream& is, P& p) {
    int F, S;
    is >> F >> S;
    p = P(F,S);
    return is;
  }
}

// 内積
D dot(P a, P b) {
  return (conj(a)*b).X;
}
// 外積
D cross(P a, P b) {
  return (conj(a)*b).Y;
}
// 点aから見た、点bから点cへの方向
int ccw(P a, P b, P c) {
  b -= a; c -= a;
  if (cross(b,c) > 0) return +1;  // counter clockwise
  if (cross(b,c) < 0) return -1;  // clockwise
  if (dot(b,c) < 0) return +2;  // c--a--b on line
  if (norm(b) < norm(c)) return -2; // a--b--c on line or a==b
  return 0;                     // a--c--b on line or a==c or b==c
}
// 点pの直線aへの射影点を返す
P proj(P a1, P a2, P p) {
  return a1 + dot(a2-a1,p-a1)/norm(a2-a1) * (a2-a1);
}
// 点pの直線aへの反射点を返す
P reflection(P a1, P a2, P p) {
  return 2.0*proj(a1,a2,p)-p;
}

P p1, p2;
int q;

signed main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(10);

  cin >> p1 >> p2 >> q;
  REP(i, q) {
    P p;
    cin >> p;
    P ans = reflection(p1, p2, p);
    cout << ans.X << " " << ans.Y << endl;
  }

  return 0;
}


Measured memory_bytes: 3352
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string S;
  cin >> S;
  int ans=0,count=0;
  for (int i=0;i<S.size();i++){
    if (S[i]=='A'||S[i]=='C'||S[i]=='G'||S[i]=='T'){
      count++;
    }
    else {
      ans=max(ans,count);
      count=0;
    }
    if (i==S.size()-1){
      ans=max(ans,count);
    }
  }
  cout << ans << endl;
}    

Measured memory_bytes: 256
/// In The Name Of God

#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

#include <bits/stdc++.h>

#define f first
#define s second

#define pb push_back
#define pp pop_back
#define mp make_pair

#define sz(x) (int)x.size()
#define sqr(x) ((x) * 1ll * (x))
#define all(x) x.begin(), x.end()

#define Kazakhstan ios_base :: sync_with_stdio(0), cin.tie(0), cout.tie(0);

#define nl '\n'
#define ioi exit(0);

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

const int N = (int)2e5 + 7;
const int inf = (int)1e9 + 7;
const int mod = (int)1e9 + 7;
const ll linf = (ll)1e18 + 7;

const int dx[] = {-1, 0, 1, 0, 1, -1, -1, 1};
const int dy[] = {0, 1, 0, -1, 1, -1, 1, -1};

using namespace std;

int n;
int a[N], b[N];

vector <int> st;
ll ans;
int get(int l, int r) {
	return upper_bound(all(st), r) - lower_bound(all(st), l);
}
void solve(int k) {
	int m1 = (1 << k), m2 = m1 << 1;
	for (int i = 1; i <= n; i++) {
		st[i - 1] = a[i] % m2;
	}
	sort(all(st));
	ll cnt = 0;
	for (int i = 1; i <= n; i++) {
		int cur = b[i] % m2;
		cnt += get(m1 - cur, m2 - cur - 1);
		cnt += get(m1 + m2 - cur, m2 << 1);
	}
	if (cnt & 1) ans += m1;
}
int main() {
	#ifdef IOI2018
		freopen ("in.txt", "r", stdin);
	#endif
	Kazakhstan
	cin >> n;
	for (int i = 1; i <= n; i++) {
		cin >> a[i];
	}
	for (int i = 1; i <= n; i++) {
		cin >> b[i];
	}
	st.resize(n);
	for (int i = 0; i < 29; i++) {
		solve(i);
	}
	cout << ans;
	ioi
}


Measured memory_bytes: 2560
#include "bits/stdc++.h"
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define REP(i,a,n) for(ll i=a;i<n;i++)
#define ALL(s) s.begin(),s.end()
#define P pair<ll,ll>
#define vl vector<ll>
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vvl vector<vector<ll>>
#define print(n) cout<<n<<endl
const int M=100010;
const int MOD=1000000007;
const int inf=1000000007;
const long long INF=1000000000000000007;
using ll=long long;
int dx[4]={-1,0,1,0},dy[4]={0,-1,0,1};

int main(){
	string s;cin>>s;
	int ans=0;
	rep(i,s.size())if(s[i]=='o')ans++;
	if(15-s.size()+ans>=8)cout<<"YES"<<endl;
	else cout<<"NO"<<endl;
}

Measured memory_bytes: 256
n = int(input())
s = list(input())

max_char = 0

for i in range(1, n):
    s1 = set(s[0:i])
    s2 = set(s[i:])
    num = len(s1 & s2)
    if num > max_char:
        max_char = num
print(max_char)

Measured memory_bytes: 2940
n,x,m=map(int,input().split())
r=[]
s=set()
ans=x
a=x
for i in range(n-1):
    b=a*a%m
    if b in s:
        j = r.index(b)
        N = n-1-i
        T = i-j
        S = sum(r[j:])
        ans += N//T*S
        N %= T
        ans += sum(r[j:j+N])
        break
    else:
        ans+=b
        s.add(b)
        r.append(b)
        a=b
print(ans)

Measured memory_bytes: 13112
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<bitset>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<deque>
#include<list>
#include<iomanip>
#include<cmath>
#include<cstring>
#include<functional>
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 INF 2e9
#define MOD 1000000007
//#define MOD 998244353
#define LINF (long long)4e18
#define jck 3.141592

using ll = long long;
using Pi = pair<int,int>;
using Pl = pair<ll,ll>;


int main(){
    string s; cin >> s;
    int n = s.size();
    if(s == "zyxwvutsrqponmlkjihgfedcba"){
        cout << -1 << endl;
    }
    else if(n < 26){
        for(char c = 'a'; c <= 'z'; c++){
            bool ok = true;
            rep(i,n){
                if(s[i] == c) ok = false;
            }
            if(ok){
                s += c;
                break;
            }
        }
        cout << s << endl;
    }
    else{
        for(int i = n-1; i >= 1; i--){
            if(s[i] > s[i-1]){
                char m = s[i];
                repr(j,i,n){
                    if(s[i-1] < s[j]) m = min(m,s[j]);
                }
                s[i-1] = m;
                s = s.substr(0,i);
                break;
            }
        }
        cout << s << endl;
    }

}

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

int main(){
  int n;
  cin>>n;
  vector<int>a(n);
  rep(i,n)cin>>a[i];
  vector<int>ord(n);
  rep(i,n)ord[a[i]-1]=i+1;
  rep(i,n)cout<<ord[i]<<" ";
}
  

Measured memory_bytes: 1536
#define _USE_MATH_DEFINES
#include<iostream>
#include<algorithm>
#include<cmath>
#include<string>
#include<set>
#include<map>
#include<vector>
#include<utility>
#include<queue>
#include<stdbool.h>
#include<math.h>
#include<sstream>
typedef long long ll;
#define N (1000000000+7)
#define INF (-1000000)
using namespace std;
typedef pair<int, int> P;

int dx[4] = { 1,0,-1,0 };
int dy[4] = { 0,1,0,-1 };

int d[55][55];

char board[55][55];
int h, w;

int bfs() {
	queue<P>q;
	for (int i = 1;i <= h;i++) {
		for (int j = 1;j <= w;j++) {
			d[i][j] = INF;
		}
	}
	q.push(P(1, 1));
	d[1][1] = 0;
	while (!q.empty()) {
		P p = q.front();q.pop();
		if ((p.first == h) && (p.second == w))break;
		for (int i = 0;i < 4;i++) {
			int nx = p.first + dx[i];
			int ny = p.second + dy[i];
			if ((1 <= nx) && (nx <= h) && (1 <= ny) && (ny <= w) && (board[nx][ny] != '#') && (d[nx][ny] == INF)) {
				q.push(P(nx, ny));
				d[nx][ny] = d[p.first][p.second] + 1;
			}
		}
	}
	return d[h][w];
}

int t[100010], x[100010], y[100010];

int main(void) {
	int n;
	cin >> n;
	for (int i = 0;i < n;i++) {
		cin >> t[i] >> x[i] >> y[i];
	}
	int dist = t[0];
	int manhattan = abs(x[0]) + abs(y[0]);
	int carnelx = x[0], carnely = y[0];
	if ((dist % 2) != manhattan % 2) {
		cout << "No" << endl;
		return 0;
	}
	if (dist < manhattan) {
		cout << "No" << endl;
		return 0;
	}
	for (int i = 1;i < n;i++) {
		dist = t[i] - t[i - 1];
		manhattan = abs(x[i] - carnelx) + abs(y[i] - carnely);
		if (dist < manhattan) {
			cout << "No" << endl;
			return 0;
		}
		if ((dist % 2) != (manhattan % 2)) {
			cout << "No" << endl;
			return 0;
		}
		carnelx = x[i];
		carnely = y[i];
	}
	cout << "Yes" << endl;
	return 0;
}

Measured memory_bytes: 1408
n=int(input())
s=list(input())
#print(s)
for a in [0,1]:
    for b in [0,1]:
        #0 means it's a false speaking animal
        #1 means it's a truth speaking animal
        ass=[-1]*n
        ass[0]=a
        ass[1]=b
        #we know about the assignment of first two animals
        for i in range(1,n-1):
            if ass[i]==0:#false speaking animal
                if s[i]=='o':
                    ass[i+1]=1-ass[i-1]
                else:
                    ass[i+1]=ass[i-1]
            else:#true speaking animal
                if s[i]=='o':
                    ass[i+1]=ass[i-1]
                else:
                    ass[i+1]=1-ass[i-1]
#        print(ass)
        if ass[0]==1:
            if (s[0]=='o' and ass[-1]!=ass[1]) or (s[0]=='x' and ass[-1]==ass[1]):
                continue
        else:
            if (s[0]=='o' and ass[-1]==ass[1]) or (s[0]=='x' and ass[-1]!=ass[1]):
                continue
        if ass[-1]==1:
            if (s[-1]=='o' and ass[n-2]!=ass[0]) or (s[-1]=='x' and ass[n-2]==ass[0]):
                continue
        else:
            if (s[-1]=='o' and ass[n-2]==ass[0]) or (s[-1]=='x' and ass[n-2]!=ass[0]):
                continue
        ass=['W' if i==0 else 'S' for i in ass]
        print(''.join(ass))
        exit()
print(-1)


Measured memory_bytes: 5956
#include<bits/stdc++.h>
using namespace std;
#define ALL(x) x.begin(),x.end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define debug(v) cout<<#v<<":";for(auto x:v){cout<<x<<' ';}cout<<endl;
#define INF 1000000000
#define mod 1000000007
using ll=long long;
const ll LINF=1001002003004005006ll;
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};
// ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return true;}return false;}
template<class T>bool chmin(T &a,const T &b){if(b<a){a=b;return true;}return false;}

int pre[1<<26];

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(0);
    
    rep(i,(1<<26)) pre[i]=-1;
    pre[0]=0;
    
    string s;cin>>s;
    int n=(int)s.size();

    int dp[n+1];
    rep(i,n+1)dp[i]=INF;
    dp[0]=0;

    int bit=0;
    rep(i,n){
        int c=s[i]-'a';
        bit^=(1<<c);
        if(__builtin_popcount(bit)<=1) dp[i+1]=0;
        else{
            if(pre[bit]>=0) chmin(dp[i+1],dp[pre[bit]]+1);
            rep(j,26){
                if(pre[bit^(1<<j)]>=0) chmin(dp[i+1],dp[pre[bit^(1<<j)]]+1);
            }        
        }
        pre[bit]=i+1;
    }
    cout<<dp[n]+1<<endl;
    return 0;
}


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

#define int long long
#define pii pair<int, int>
#define pb push_back
#define vi vector<int>

signed main() {
    ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
    int n;
    cin >> n;
    int d = 0;
    int x = 100;
    while(x < n) {
    	x = x * 1.01;
    	d ++;
    }
    cout << d << endl;
    return 0;
}



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

int main(void){

  char s[200], t[200], p[100];
  int i, ii, lens, lenp;
  int co = 0;

  scanf("%s", s);
  scanf("%s", p);
  
  strcpy(t,s);
  strcat(s,t);
  lens = strlen(s);
  lenp = strlen(p);

  for(i = 0; i < lens*2; i++){
    for(ii = 0; ii < lenp; ii++){
      if(s[i+ii] == p[ii]) co += 1;
    }
    if(co == lenp){
      printf("Yes\n");
      return 0;
    }
    co = 0;
  }
  printf("No\n");
  return 0;
}

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

int main()
{
    int inputN, inputA;
    scanf("%d", &inputN);
    int intArray[100];

    for (int i = 0; i < inputN; i++)
    {
        scanf("%d", &inputA);
        intArray[i] = inputA;
    }

    for (int i = 0; i < inputN; i++)
    {
        if (intArray[i] % 2 == 0)
        {
            if (intArray[i] % 3 == 0 || intArray[i] % 5 == 0)
            {
                continue;
            }
            else
            {
                printf("DENIED \n");
                return 0;
            }
        }
    }
    printf("APPROVED \n");

    return 0;
}


Measured memory_bytes: 128
#include <stdio.h>
int main(void){
    // Here your code !
    int d, dJ, dM;
    int L ,A, B, C, D;
    
    scanf("%d",&L); //テ・ツ?ャテ、ツシツ妥」ツ?ソ
    scanf("%d",&A); //テ・ツ崢スティツェツ榲」ツδ嘉」ツδェテ」ツδォテ」ツδ堙」ツδシテ」ツつク
    scanf("%d",&B); //テァツョツ療ヲツ閉ーテ」ツδ嘉」ツδェテ」ツδォテ」ツδ堙」ツδシテ」ツつク
    scanf("%d",&C); //1テヲツ猟・テ・ツ崢スティツェツ榲」ツδ嘉」ツδェテ」ツδォ
    scanf("%d",&D); //1テヲツ猟・テァツョツ療ヲツ閉ーテ」ツδ嘉」ツδェテ」ツδォ
    
    	dJ = A/C;
        dM = B/D;
        
        if(A%C != 0){
	        dJ++;
        }
        if(B%D != 0){
        	dM++;
        }
        
        if(dJ > dM){
        	d = dJ;
        } else if(dM > dJ){
        	d = dM;
        }
        
    printf("%d\n",L-d);
    return 0;
}

Measured memory_bytes: 596
N = int(input())
table = list(map(int,input().split()))

MAX = 2000
check = [False]*(MAX+1)

def recursive(index,tmp_sum):
    global N

    if index == N:
        check[tmp_sum] = True
        return

    recursive(index+1,tmp_sum)
    if tmp_sum+table[index] <= MAX:
        recursive(index+1,tmp_sum+table[index])

recursive(0,0)

num_query = int(input())
for num in list(map(int,input().split())):
    if check[num]:
        print("yes")
    else:
        print("no")


Measured memory_bytes: 5636
#include<stdio.h>
#include<iostream>
#include<vector>
#include<algorithm>
#define _USE_MATH_DEFINES
#include<math.h>
#include<cmath>
using namespace std;

int main(void)
{
    int A, B, H, M;
    cin >> A >> B >> H >> M;
    double ldeg = (360 / 12) * H + (M * 0.5);
    //cout << ldeg << endl;
    double mdeg = (360 / 60) * M;
    //cout << mdeg << endl;

    double deg = ldeg - mdeg;
    deg *= (deg > 0) ? 1 : -1;
    deg = (deg <= 180) ? deg : (360 - deg);
    //cout << deg << endl;
    

    double C = sqrt(pow(A, 2) + pow(B, 2) - 2*A*B*cos(deg*M_PI/180.0));
    printf("%.20lf\n", C);

    return 0;
}

Measured memory_bytes: 4188
#include<iostream>
#include<algorithm>
#include<math.h>
#include<set>

using namespace std;

int main(){
    int x = 0;
    cin >> x;
    set<int> a;
    for (int i = 1; i < 180; i++){
        a.insert(360 * i);
    }
    int ans = 1;
    int add = x;
    while(x <= 64440){
        if (a.count(x)==1){
            cout << ans << endl;
            break;
        } else {
            ans++;
            x += add;
        }
    }
    return 0;
}


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

#define rep(i, n) for (int i = 0; i < int(n); i++)
#define rrep(i, n) for (int i = int(n) - 1; i >= 0; i--)
#define reps(i, n) for (int i = 1; i <= int(n); i++)
#define rreps(i, n) for (int i = int(n); i >= 1; i--)
#define repc(i, n) for (int i = 0; i <= int(n); i++)
#define rrepc(i, n) for (int i = int(n); i >= 0; i--)
#define repi(i, a, b) for (int i = int(a); i < int(b); i++)
#define repic(i, a, b) for (int i = int(a); i <= int(b); i++)
#define each(x, y) for (auto &x : y)
#define all(a) (a).begin(), (a).end()
#define bit(b) (1ll << (b))
#define uniq(v) (v).erase(unique(all(v)), (v).end())
#define rsort(v) sort(all(v)); reverse(all(v))

using namespace std;

using i32 = int;
using i64 = long long;
using f80 = long double;
using vi32 = vector<i32>;
using vi64 = vector<i64>;
using vf80 = vector<f80>;
using vstr = vector<string>;

inline void yes() { cout << "Yes" << '\n'; exit(0); }
inline void no() { cout << "No" << '\n'; exit(0); }
inline i64 gcd(i64 a, i64 b) { if (min(a, b) == 0) return max(a, b); if (a % b == 0) return b; return gcd(b, a % b); }
inline i64 lcm(i64 a, i64 b) { return a / gcd(a, b) * b; }
void solve(); int main() { ios::sync_with_stdio(0); cin.tie(0); cout << fixed << setprecision(16); solve(); return 0; }
template <typename T> class pqasc : public priority_queue<T, vector<T>, greater<T>> {};
template <typename T> class pqdesc : public priority_queue<T, vector<T>, less<T>> {};
template <typename T> inline void amax(T &x, T y) { if (x < y) x = y; }
template <typename T> inline void amin(T &x, T y) { if (x > y) x = y; }
template <typename T> inline T power(T x, i64 n) { T r = 1; while (n > 0) { if (n & 1) r *= x; x *= x; n >>= 1; } return r; }
template <typename T> istream& operator>>(istream &is, vector<T> &v) { for (auto &x : v) is >> x; return is; }
template <typename T> ostream& operator<<(ostream &os, const vector<T> &v) { rep(i, v.size()) { if (i) os << ' '; os << v[i]; } return os; }

void solve() {
  int n; cin >> n;
  vi32 w(n); cin >> w;
  int mn = 1e9;
  vi32 sums(n + 1);
  rep(i, n) sums[i + 1] = sums[i] + w[i];
  rep(i, n + 1) {
    int s1 = sums[i] - sums[0];
    int s2 = sums[n] - sums[i];
    amin(mn, abs(s1 - s2));
  }
  cout << mn << '\n';
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
// statics
using namespace std;
using int64 = int_fast64_t;
using PAIR = pair<int64, int64>;
constexpr int INF = 1 << 30;
constexpr int64 LINF = 1LL << 60;
constexpr int MOD = 1e9 + 7;
constexpr int MAX_N = 3e5 + 1;

// init/input
#define int int64
#define INIT ios::sync_with_stdio(false);cin.tie(0);
#define VAR(type, ...) type __VA_ARGS__;MACRO_VAR_Scan(__VA_ARGS__);
template<typename T> void MACRO_VAR_Scan(T &t) {cin>>t;}
template<typename First, typename...Rest> void MACRO_VAR_Scan(First &first, Rest&...rest) {cin>>first;MACRO_VAR_Scan(rest...);}
#define VEC(type, c, n) vector<type> c(n);for(auto &&i:c)cin>>i;

// out
#define OUT(dist) cout<<(dist);
#define FOUT(n, dist) cout<<fixed<<setprecision(n)<<(dist);
#define SP cout<<" ";
#define BR cout<<endl;
#define zero(n) cout<<setfill('0')<<right<<setw(n)
#define debug(x) cerr<<#x<<":"<< (x);BR;

// utility
#define ALL(a) (a).begin(), (a).end()
#define EACH(i, a) for(auto &&i:(a))
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define RFOR(i, a, b) for(int i=(b)-1;i>=0;--i)
#define REP(i, n) for(int i=0;i<(n);++i)
#define RREP(i, n) for(int i=(n)-1;i>=0;--i)

signed main() {
  INIT;
	VAR(int,n,m);
	map<int,int> mp;
	REP(i,n){
		VAR(int,k);
		REP(j,k){
			VAR(int,a);
			mp[a]++;
		}
	}

	int ans=0;
	EACH(mi,mp){
		if(mi.second == n)++ans;
	}
	OUT(ans)BR;
	
  return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main{
    public static void main(String[] args){
        Scanner sc=new Scanner(System.in);
        String s=sc.next();
        char[] chars=s.toCharArray();
        long k=Long.parseLong(sc.next());
        int len=s.length();
        char first=chars[0];
        char last=chars[len-1];
        char seeing=first;
        long same=0;
        long ans=0;
        if(first!=last){
            for(char c:chars){
                if(c==seeing){
                    same++;
                    
                }
                else{
                    ans+=same/2;
                    same=1;
                    seeing=c;
                }
            }
            if(same>1){
                ans+=same/2;
            }
            ans*=k;
        }
        else{
            int left_repeat=1;
            int right_repeat=1;
            boolean all_same=true;
            for(int i=1;i<len;i++){
                if(chars[i]!=first){
                    left_repeat=i;
                    all_same=false;
                    break;
                }
            }
            for(int i=1;i<len;i++){
                if(chars[len-1-i]!=last){
                    right_repeat=i;
                    all_same=false;
                    break;
                }
            }
            if(all_same){
                ans=(long) len*k/2;
            }
            else{
                seeing=chars[left_repeat];
                for(int i=left_repeat;i<len-right_repeat;i++){
                    if(chars[i]==seeing){
                        same++;
                    }
                    else{
                        ans+=same/2;
                        same=1;
                        seeing=chars[i];
                    }
                }
                if(same>1){
                    ans+=same/2;
                }
                ans*=k;
                ans+=(left_repeat/2)+(right_repeat/2)+(k-1)*((left_repeat+right_repeat)/2);
            }
        }
        System.out.println(ans);
        sc.close();
    }
}

Measured memory_bytes: 22612
a = []
for j in range(3):
    a.append([int(x) for x in input().split()])
n = int(input())
b = [int(input()) for i in range(n)]
def hasbingo(ps):
    for x, y in ps:
        if a[y][x] not in b:
            return False
    return True

def hasany():
    for i in range(3):
        if hasbingo([(i, 0),(i, 1),(i, 2)]):
            return True
        if hasbingo([(0, i), (1, i), (2, i)]):
            return True
    if hasbingo([(0,0),(1,1),(2,2)]):
        return True
    return hasbingo([(0,2),(1,1), (2,0)])

if hasany():
    print('Yes')
else:
    print('No')




Measured memory_bytes: 3064
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

using u128 = __uint128_t;

#define int long long
#define idxSet tree<int, null_type,less_equal<int>, rb_tree_tag,tree_order_statistics_node_update>
#define atIdx find_by_order
#define idxOf order_of_key
#define MOD 1000000007
#define MAX 200005
#define endl '\n'

#define v(type) vector<type>
#define p(type1, type2) pair<type1 , type2>
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;

int dp[MAX];

void solve() {
    int a , b , c;
    cin>>a>>b>>c;
    set<int> x;
    bool is = false;
    int  k = a;
    while(!is){
        if(k % b == c){
            is = true;
        }else if(x.count(k % b) == 1){
            is = false;
            break;
        }else{
            x.insert(k % b);
            k += a;
        }
    }
    if(is ){
        cout<<"YES"<<endl;
    }else cout<<"NO"<<endl;
}

int32_t main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int t = 1;
    //cin>>t;
    while (t--)
        solve();
    return 0;
}

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

using ll = long long;
using pii = pair<ll, ll>;
using vi = vector<ll>;
using vvi = vector<vi>;

template <class T>
using max_heap = priority_queue<T>;
template <class T>
using min_heap = priority_queue<T, vector<T>, greater<T>>;

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

#define rep(i, j, k) for (int i = j; i < k; i++)
#define all(obj) (obj).begin(), (obj).end()
#define rall(obj) (obj).rbegin(), (obj).rend()
#define debug(x) cerr << #x << ": " << x << endl;
#define debug2(x, y) cerr << #x << ": " << x << ", " << #y << ": " << y << endl;
#define int ll

const ll mod = 1e9 + 7;
const ll inf = (1LL << 60);

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.precision(10);
    cout << fixed;

    int N;
    cin >> N;

    vvi v(N);
    rep(i, 0, N - 1) {
        int a;
        cin >> a;
        a--;
        v[a].push_back(i + 1);
    }
    rep(i, 0, N) {
        cout << v[i].size() << endl;
    }
    return 0;
}


Measured memory_bytes: 14148
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <functional>
#include <cstdlib>
#include <sstream>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <complex>
#include <vector>
#include <cstdio>
#include <math.h>
#include <cmath>
#include <time.h>
#define all(c) ((c).begin(),(c).end())
#define rall(c) (c).rbegin(),(c).rend()
#define sort(v,n) sort(v,v+n)
#define vsort(v) sort(v.begin(),v.end())
#define vvsort(v) sort(v.begin(),v.end(),greater<int>())
#define ll long long
#define pb(a) push_back(a)
#define fi first
#define se second
#define inf 999999999
using namespace std;
const ll MOD = 1e9 + 7;
const double PI = acos(-1.0);
//---------------------------------------------------------------------------------------------//
int w, h;
bool c[55][55];
int ans=0;

void dfs(int nowy, int nowx) {
	c[nowy][nowx] = 0;
	for (int i = -1; i < 2; i++) {
		for (int j = -1; j < 2; j++) {
			if (nowy == 0 && i == -1)continue;
			if (nowx == 0 && j == -1)continue;
			if (nowy == h - 1 && i == 1)continue;
			if (nowx == w - 1 && j == 1)continue;
			if (c[nowy + i][nowx + j] == 1) {
				dfs(nowy + i, nowx + j);
			}
		}
	}
}



int main() {
	while (cin >> w >> h, w) {
		ans = 0;
		for (int i = 0; i < h; i++) {
			for (int j = 0; j < w; j++) {
				cin >> c[i][j];
			}
		}
		for (int i = 0; i < h; i++) {
			for (int j = 0; j < w; j++) {
				if (c[i][j] == 1) {
					dfs(i, j);
					ans++;
				}
			}
		}
		cout << ans << endl;
	}
}

Measured memory_bytes: 3228
#include <iostream>
#include <vector>
#include <numeric>
#include <string>
#include <complex>
#include <iomanip>
using namespace std;
typedef complex<double> P;
const double EPS = 1e-10;

namespace std
{
bool operator<(P &a, P &b)
{
    return real(a) != real(b) ? real(a) < real(b) : imag(a) < imag(b);
}
} // namespace std

double dot(P a, P b)
{
    return real(a) * real(b) + imag(a) * imag(b);
}

double cross(P a, P b)
{
    return real(a) * imag(b) - imag(a) * real(b);
}

int ccw(P a, P b, P c)
{
    b -= a;
    c -= a;
    if (cross(b, c) > 0)
        return 1;
    if (cross(b, c) < 0)
        return -1;
    if (dot(b, c) < 0)
        return 2;
    if (norm(b) < norm(c))
        return -2;
    return 0;
}
int main(void)
{

    double a, b, c, d;
    cin >> a >> b >> c >> d;

    P p1(a, b);
    P p2(c, d);
    int q;
    cin >> q;
    for (int i = 0; i < q; ++i)
    {
        double x, y;
        cin >> x >> y;
        P p(x, y);

        switch (ccw(p1, p2, p))
        {
        case (1):
            cout << "COUNTER_CLOCKWISE" << endl;
            break;
        case (-1):
            cout << "CLOCKWISE" << endl;
            break;
        case (2):
            cout << "ONLINE_BACK" << endl;
            break;
        case (-2):
            cout << "ONLINE_FRONT" << endl;
            break;
        case (0):
            cout << "ON_SEGMENT" << endl;
            break;
        default:
            break;
        }
    }
}


Measured memory_bytes: 3292
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <cfloat>
#include <stack>
#include <queue>
#include <vector>
#include <string>
#include <iostream>
#include <set>
#include <map>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_SIZE 2000000000
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;


#define SIZE 100000

vector<int> G[SIZE];
int N;
bool visited[SIZE];
int visited_order[SIZE],parent[SIZE],lowest[SIZE],number;


void dfs(int current_node,int pre_node){
	visited_order[current_node] = lowest[current_node] = number;
	number++;

	visited[current_node] = true;

	int next;

	for(int i = 0; i < G[current_node].size(); i++){
		next = G[current_node][i];
		if(!visited[next]){
			parent[next] = current_node;
			dfs(next,current_node);
			lowest[current_node] = min(lowest[current_node],lowest[next]);
		}else if(visited[next] == true && next != pre_node){
			lowest[current_node] = min(lowest[current_node],visited_order[next]);
		}
	}
}

void art_points(){

	for(int i = 0; i < N; i++)visited[i] = false;

	number = 1;
	dfs(0,-1);

	int tmp_parent,root_num = 0;

	vector<int> V;

	for(int i = 1; i < N; i++){
		tmp_parent = parent[i];
		if(tmp_parent == 0){
			root_num++;
		}else if(visited_order[tmp_parent] <= lowest[i]){
			V.push_back(tmp_parent);
		}
	}
	if(root_num >= 2){
		V.push_back(0);
	}
	sort(V.begin(),V.end());
	V.erase(unique(V.begin(),V.end()),V.end());

	for(int i = 0; i < V.size(); i++){
		printf("%d\n",V[i]);
	}
}


int main(){
	int E;

	scanf("%d %d",&N,&E);

	int from,to;

	for(int i = 0; i < E; i++){
		scanf("%d %d",&from,&to);
		G[from].push_back(to);
		G[to].push_back(from);
	}

	art_points();

	return 0;
}



Measured memory_bytes: 7016
#include <cstdio>
#include <iostream>
#include <vector>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <string>
#include <cstring>
#include <sstream>
#include <algorithm>
#include <functional>
#include <queue>
#include <stack>
#include <cmath>
#include <iomanip>
#include <list>
#include <tuple>
#include <bitset>
#include <ciso646>
#include <cassert>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> T;
typedef vector<ll> vec;

inline bool check(ll x, ll y, ll xMax, ll yMax) { return x >= 0 && y >= 0 && xMax > x && yMax > y; }
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(); }
template<class T> inline T sqr(T x) { return x*x; }
template<class T> inline T mypow(T x, ll n) { T res = 1; while (n > 0) { if (n & 1)res = res * x;	x = x * x;	n >>= 1; }return res; }
inline ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
inline ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }

#define For(i,a,b)	for(ll (i) = (a);i < (b);(i)++)
#define rep(i,n)	For(i,0,n)
#define rFor(i,a,b)	for(ll (i) = (a-1);i >= (b);(i)--)
#define rrep(i,n)	rFor(i,n,0)
#define each(i,n)	for(auto &i : n)
#define clr(a)		memset((a), 0 ,sizeof(a))
#define mclr(a)		memset((a), -1 ,sizeof(a))
#define all(a)		(a).begin(),(a).end()
#define sz(a)		(sizeof(a))
#define tostr(a)	tostring(a)
#define dump(val) 	cerr << #val " = " << val << endl;
#define Fill(a,v)	fill((int*)a,(int*)(a+(sz(a)/sz(*(a)))),v)

const ll dx[8] = { 1, 0, -1, 0, 1, 1, -1, -1 }, dy[8] = { 0, -1, 0, 1, -1, 1, -1, 1 };

const ll mod = 1e9 + 7;
const ll INF = 1e17 + 9;

#define int ll
#define double ld

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

	int T;
	cin >> T;
	rep(_, T) {
		int n, d;
		cin >> n >> d;
		
		int ans = 0;
		rep(i, 7) {
			if (d & (1 << i)) {
				if (n % 2 == 0) {
					ans += (1 << i) * (n - 1);
				}
				else {
					ans += (1 << i) * n;
				}
			}else{
				if (n % 2 == 0) {
					ans += (1 << i) * n;
				}
				else {
					ans += (1 << i) * (n - 1);
				}
			}
		}
		cout << ans << endl;
	}

	return 0;
}

Measured memory_bytes: 256
#!python3

import sys
iim = lambda: map(int, sys.stdin.readline().rstrip().split())

def resolve():
    AN, BN, M = iim()
    A = list(iim())
    B = list(iim())

    ans = min(A) + min(B)

    for i in range(M):
        ai, bi, ci = iim()

        xi = A[ai-1] + B[bi-1] -ci
        ans = min(ans, xi)
    print(ans)

if __name__ == "__main__":
    resolve()


Measured memory_bytes: 18736
A,B,K = map(int,input().split())
for i in range(1,K+1):
  if i % 2 == 1:
    if A % 2 == 1:
      A -= 1
    B += A/2
    A -= A/2
  if i % 2 == 0:
    if B % 2 == 1:
      B -= 1
    A += B/2
    B -= B/2
print(int(A),int(B))

Measured memory_bytes: 3060
#include<stdio.h>
int main(){
  int a,b,c,tmp;
  scanf("%d %d %d",&a,&b,&c);
  if(a>b){
    tmp=a;
    a=b;
    b=tmp;
  }
  if(b>c){
    tmp=b;
    b=c;
    c=tmp;
  }
  if(a>b){
    tmp=a;
    a=b;
    b=tmp;
  }
  printf("%d %d %d\n",a,b,c);
    
  return 0;
      }

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

int main(){
  int n, x;
  while(1){
    cin >> n >> x;
    int ans = 0;
    if(n+x==0) break;
    x -= 3;
    for(int i = 0;i<n;i++){
      for(int j=i+1;j<n;j++){
        for(int k=j+1;k<n;k++){
          if(i+j+k==x){
            ans++;
            break;
          }
        }
      }
    }
    cout << ans << endl;
  }


  return 0;
}



Measured memory_bytes: 3080
#include<bits/stdc++.h>
#define int int64_t
using namespace std;
constexpr int MOD=1'000'000'007;
constexpr int MAX=200'000;
int factorial[MAX+1];
void initFactorial(){
  factorial[0]=1;
  for(int i=1;i<=MAX;++i)factorial[i]=factorial[i-1]*i%MOD;
}
int getPower(int base,int exp){
  int result=1;
  while(exp>0){
    if((exp&1)==1)result=result*base%MOD;
    base=base*base%MOD;
    exp>>=1;
  }
  return result;
}
int inverse[MAX+1];
void initInverse(){
  inverse[0]=1;
  for(int i=1;i<=MAX;++i)inverse[i]=getPower(factorial[i],MOD-2);
}
int combination(int n,int k){
  const int x=factorial[n]*inverse[k]%MOD*inverse[n-k]%MOD;
  // printf("(%ld,%ld)=%ld\n",n,k,x);
  return x;
}
int H,W,A,B;
main(){
  initFactorial();
  initInverse();
  cin>>H>>W>>A>>B;
  int result=0;
  for(int i=0;i<H-A;++i){
    const int x0=combination(B+i-1,i);
    const int x1=combination((W-B-1)+(H-i-1),H-i-1);
    // printf("%ld,%ld,%ld\n",i,x0,x1);
    result+=x0*x1;
    result%=MOD;
  }
  cout<<result<<endl;
}


Measured memory_bytes: 3328