akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  string n;
  cin >> n;
  for(int i=0;i<3;i++){
    if(n.at(i)=='7'){
      cout << "Yes" << endl;
      return 0;
    }
  }
  cout << "No" << endl;
}

Measured memory_bytes: 3620
N = int ( input() )
slimes = str( input() )
list_slimes = list( slimes )
while(True):
  counter = 0
  i = 0
  while(i<len(list_slimes)-1):
    if list_slimes[i] == list_slimes[i+1]:
      del list_slimes[i]
      counter += 1
    i += 1
  if counter == 0:
    break

print( len (list_slimes) )


Measured memory_bytes: 4084
#include <iostream>
#include <string>
using namespace std;
int main(){
    int H, W, ans=0;
    cin >> H >> W;
    string S[H];
    for(int i = 0; i < H; i++) cin >> S[i];
    int L[H][W], R[H][W], U[H][W], D[H][W];
    for(int i = 0; i < H; i++){
        int cnt = 0;
        for(int j = 0; j < W; j++){
            if(S[i][j]=='#') cnt = 0;
            else cnt++;
            L[i][j] = cnt;
        }
        cnt = 0;
        for(int j = W-1; j >= 0; j--){
            if(S[i][j]=='#') cnt = 0;
            else cnt++;
            R[i][j] = cnt;
        }
    }
    for(int j = 0; j < W; j++){
        int cnt = 0;
        for(int i = 0; i < H; i++){
            if(S[i][j]=='#') cnt = 0;
            else cnt++;
            U[i][j] = cnt;
        }
        cnt = 0;
        for(int i= H-1; i >= 0; i--){
            if(S[i][j]=='#') cnt = 0;
            else cnt++;
            D[i][j] = cnt;
        }
    }
    for(int i = 0; i < H; i++){
        for(int j = 0; j < W; j++){
            if(ans < L[i][j]+R[i][j]+U[i][j]+D[i][j]-3 ) ans = L[i][j]+R[i][j]+U[i][j]+D[i][j]-3;
        }
    }
    cout << ans << endl;
    return 0;
}


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

int main(){
  int a,b;
  cin >> a >> b;
  double mean = (a+b)/2.0;
  if((mean -(a+b)/2) >= 0.5) {
    mean = (a+b)/2 + 1;
  }else{
    mean = (a+b)/2;
  }
  cout << mean << endl;
}

Measured memory_bytes: 256
n = int(input())
s = input()
v = [0] * n
for c in range(ord('a'), ord('z') + 1):
  p = -1
  for i in range(n):
    if ord(s[i]) == c:
      if p >= 0:
        v[i] -= 1
        v[p] += 1
      p = i
ans = 0
vsum = 0
for i in v:
  vsum += i
  ans = max(ans, vsum)
print(ans)


Measured memory_bytes: 3064
#include <iostream>
#include <string>
#include <utility>
#include <stack>
#include <vector>
#include <queue>
#include <algorithm>
#include <map>
#include <climits>
#include <set>
#include <cmath>

using namespace std;

int main(){
   int T;
   int K;
   cin >> K >> T;
   priority_queue <int> pq;
   for(int i = 0; i < T; i++){
       int a;
       cin >> a;
       pq.push(a);
   }

   while(pq.size() > 1){
       //cout << pq.size() << endl;
       int first = pq.top();
       pq.pop();
       int second = pq.top();
       pq.pop();
       int left = first - second;
       if(left > 0){
            pq.push(left);
       }
   }
   if(!pq.empty()){
       cout << pq.top() - 1 << endl;
   } else {
       cout << 0 << endl;
   }
   return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <cmath>
#include <algorithm>
#include <utility>
#include <functional>
#include<fstream>
#define debug(x) cout << #x << " = " << x << endl
#define FOR(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,n) for(int i = 0; i < (n); i++)
#define repr(i,n) for(int i = (n); i > -1; i--)
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const int MOD = 1000000007;
const double EPS = 1e-9;

int n;

int dfs(ll k) {
  if(k > n) return 0;
  int cnt = 0;
  int tmp = k;
  bool three = false, five = false, seven = false;
  while(tmp > 0) {
    int t = tmp % 10;
    if(t == 3) three = true;
    if(t == 5) five = true;
    if(t == 7) seven = true;
    tmp /= 10;
  }
  if(three&&five&&seven) cnt++;
  cnt += dfs(10 * k + 3); 
  cnt += dfs(10 * k + 5);
  cnt += dfs(10 * k + 7);
  return cnt;
}

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

  cin>>n;
  cout << dfs(0) << endl;

  return 0;
}


Measured memory_bytes: 256
//Created by Kira

#include<bits/stdc++.h>
using namespace std;

#define IOS cin.sync_with_stdio(0);cin.tie(0); cout.tie(0);
#define all(x) x.begin(), x.end()
#define sz(x) (int)x.size()
#define pii pair<int,int> 
#define pb push_back
#define vi vector<int> 
using ll = long long;

const int mod = 1e9 + 7;

ll pwr(ll a, ll b);
    



int main(){
   IOS

    int n; cin>>n;
    vi x(n), y(n);

    for(int i = 0; i < n; i++){
        cin>>x[i]>>y[i];
    }

    vector<int> a(n);
    iota(all(a), 0);

    double ans = 0;
    int cnt = 0;
    int x1, x2, y1, y2;
    do{
        double sum = 0;
        for(int i = 0; i < n - 1; i++){
            x1 = x[a[i]], x2 = x[a[i + 1]];
            y1 = y[a[i]], y2 = y[a[i + 1]];
            sum += (double)sqrt((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2));
        }
        ans += sum;
        cnt++;
    }while(next_permutation(all(a)));

    cout<<fixed<<setprecision(7);
    cout<<ans/(double)cnt<<"\n";
}

ll pwr(ll a, ll b){
   a %= mod;	//Remove mod if not required
   ll res = 1;
   while(b > 0){
    if(b&1) res = res * a % mod;
        a = a * a % mod;
    b >>= 1;
    }

    return res;
}



Measured memory_bytes: 3788
#include<stdio.h>

 int main(void)
{
  int a,b;

 scanf("%d%d",&a,&b);

 if(a > b){
   printf("a > b\n");

} else if(a < b){
   printf("a < b\n");

} else{
   printf("a == b\n");
}
 return 0;
}

Measured memory_bytes: 580
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define rep(i, n) FOR(i, 0, n)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; --i)
#define whole(x) (x).begin(),(x).end()
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
using P = pair<int, int>;
#define debug(var) cerr << "[" << #var << "] " << var << endl
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
const ll mod = 1000000007;
const int dx[] = {-1,0,1,0};
const int dy[] = {0,-1,0,1};


int main(){
    int n;
    cin >> n;
    int a;
    cin >> a;
    int ans = n*n-a;
    
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3596
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
typedef pair<ll, ll> pl;
typedef queue<ll> ql;
typedef set<ll> sl;
typedef vector<ll> vl;
#define rep(i, n) for(ll i = 0; i < ll(n); i++)
#define rep2(i, n) for(ll i = 1; i <= ll(n); i++)
//#define rep(i, k, n) for(ll i = k-1; i < ll(n); i++)
//#define rep2(i, k, n) for(ll i = k; i <= ll(n); i++)
#define all(v) (v).begin(), (v).end()
bool chmin(ll &a, ll &b) {if(b < a) {a = b; return 1;} return 0;}
bool chmax(ll &a, ll &b) {if(b > a) {a = b; return 1;} return 0;}
const ll INF = 1LL << 60;
const ll MOD = 1e9 + 7;
//const ll mod = 998244353;
const ll NMAX = 1000000;

ll adic2(ll num) {
  ll count=0;
  
  while(num%2 == 0) {
    num /= 2;
    count++;
  }
  
  return count;
}

ll solve(ll N, vl a, vl BCadic2) {
  ll count=0;
  rep(i, N) if(a[i]==2 && BCadic2[i]==0) count++;
  return count%2;
}

int main() {
  ll N;
  cin >> N;  
  string str;
  cin >> str;
  vl a(N);
  rep(i, N) a[i] = str[i]-'0';
  
  bool exist_2=0;
  rep(i, N) if(a[i] == 2) exist_2=1;
  
  vl BCadic2(N);
  rep2(i, N-1) BCadic2[i] = BCadic2[i-1] + adic2(N-i) - adic2(i);
  
  if(!exist_2) {
    rep(i, N) if(a[i] == 3) a[i] = 2;
    cout << solve(N, a, BCadic2)*2 << endl;
  }
  
  else {
    rep(i, N) if(a[i] == 3) a[i] = 1;
    cout << solve(N, a, BCadic2) << endl;
  }
  
  return 0;
}

Measured memory_bytes: 32644
#include<iostream>
#include<string>
#include<algorithm>
#include<bits/stdc++.h>
#include<vector>
#include<cstdio>
 
using namespace std;
int MOD=1000000007;

int main(){
	long long N,M; cin >> N >> M;
	vector<long long> P(M+10),Y(M+10);
	vector<vector<long long>> d(N+10);
	for(long long i=0; i<M; i++){
		cin >> P[i] >> Y[i];
		d[P[i]].push_back(Y[i]);
	}
	for(long long i=0; i<N; i++){
		sort(d[i+1].begin(),d[i+1].end());
	}
	for(long long i=0; i<M; i++){
		long long x=lower_bound(d[P[i]].begin(),d[P[i]].end(),Y[i])-d[P[i]].begin()+1;
		printf("%06lld%06lld\n",P[i],x);
	}
	return 0;
	}

Measured memory_bytes: 8576
#include <iostream>
#include <cstdio>
#include <vector>
using namespace std;

typedef long long int lli;

int main(void)
{
	lli n, q, h, s, d;
	scanf("%lld%lld%lld%lld%lld", &q, &h, &s, &d, &n);

	h = min(h, 2*q);
	s = min(s, 2*h);
	d = min(d, 2*s);
	lli res = (n/2)*d+(n%2)*s;
	printf("%lld\n", res);
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <array>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
using namespace  std;
#define ND -100
#define pb push_back
#define ins inset
#define g2(i,j,arr) arr[i][j]
#define g3(i,j,k,arr) arr[i][j][k]
#define g4(i,j,k,l,arr) arr[i][j][k][l]
#define g5(i,j,k,l,m,arr) arr[i][j][k][l][m]
#define g6(i,j,k,l,m,n,arr) arr[i][j][k][l][m][n]
#define var auto
//typedef int i;
typedef long l;
typedef long long ll;
typedef string s;
typedef char c;
typedef pair<int, int> pii;

typedef vector<int> vi;
typedef vector<pii> vpii;
typedef set<int> si;
typedef set<pii> spii;

const int Max = 1e6;

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

	for (char c : str)
	{
		int i = int(c) - int('A');
		int shiftedIndex = (i + n) % 26;
		cout << char(shiftedIndex + int('A'));
	}
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define pi 3.1415926536
#define pb push_back
#define N 1000000007
#define M 998244353
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define nrep(i,a,b) for(int i=a;i>=b;i--)

int main(){
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    ll t,i,j,k,q,x,y,l,r,z,n,flag =0,ans;
//    cin>>t;
//    while(t--){
      cin>>n;
      string s;
      cin>>s;
      if(s.length() <= n) cout<<s;
      else{
      	rep(i,0,n-1) cout<<s[i];
      	cout<<"...";
	  }
//	}
}

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

int n;
int a[200000];
int main() {
  cin >> n;
  for (int i = 0; i < n; ++i) {
    cin >> a[i];
  }
  
  long cnt = 0;
  long xr = 0;
  long sm = 0;
  int r = 0;
  for (int l = 0; l < n; ++l) {
    while (r < n && (sm + a[r]) == (xr ^ a[r])) {
      xr ^= a[r];
      sm += a[r];
      ++r;
    }
    cnt += r - l;
    
    xr ^= a[l];
    sm -= a[l];
  }
  cout << cnt << endl;
}

Measured memory_bytes: 1024
import sys
readline = sys.stdin.readline
sys.setrecursionlimit(10**8)
mod = 10**9+7
#mod = 998244353
INF = 10**18
eps = 10**-7

n=int(input())
cnt=0
for i in range(1,n+1):
  for j in range(i+1,n+1):
    if i*j<n:
      cnt+=2
    else:
      break
      
for j in range(1,n+1):
  if j*j<n:
    cnt+=1

print(cnt)

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


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

  vector<int> v({A, B, C});
  sort(v.begin(), v.end());

  int ans = v[0] + v[1] + (v[2] * pow(2, K));
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#include <string>
#include <vector>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <map>
#include <list>
#include <set>
#include <numeric>
#include <queue>
#include <stack>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <cstring>
#include <climits>
#include <cfloat>
#include <ctime>
#include <complex>
#include <cassert>
#include <array>
#include <bitset> 
#include <unordered_map>

using namespace std;
typedef long long LL;
typedef pair<int,int> P;

const int L=2e5+1;
LL  A[L];
int main() {
	int N;
	cin >> N;
	for(int i=0;i<N;i++){
		cin >> A[i];
	}
	if(A[0]>0){
		cout << -1 << endl;
		return 0;
	}
	for(int i=1;i<N;i++){
		if(A[i-1]+1<A[i]){
			cout << -1 << endl;
			return 0;
		}
	}
	LL ret=0;
	for(int i=N-1;i>=0;i--){
		if(A[i]==A[i+1]-1)continue;
		ret+=A[i];
	}
	cout << ret << endl;


	return 0;
}



Measured memory_bytes: 1792
#include<iostream>
#include<string>
#include<iomanip>
#include<cmath>
#include<vector>
#include<algorithm>

using namespace std;

#define int long long
#define rep(i,n) for(int i = 0; i < (n); i++)
#define INF ((long long)1e18)
#define MOD ((int)1e9+7)
#define endl "\n"

#define yn(f) ((f)?"Yes":"No")
#define YN(f) ((f)?"YES":"NO")




signed main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout<<fixed<<setprecision(10);
	
	int ans = 0, N;
	int dp[4][4] = {};
	
	cin>>N;
	
	for(int i = 0; i < 4; i++) dp[i][0] = 1;
	
	for(int i = 0; i < N; i++){
		for(int k = 0; k < 4; k++){
			dp[k][(i+1)%4] = 0;
			for(int j = 0; j < 4; j++){
					dp[k][(i+1)%4] += dp[j][i%4];
					dp[k][(i+1)%4] %= MOD;
			}
		}
			dp[1][(i+1)%4] = (dp[1][(i+1)%4]+MOD-dp[0][(i+3)%4])%MOD;
			dp[2][(i+1)%4] = (dp[2][(i+1)%4]+MOD-dp[0][(i+3)%4])%MOD;
			dp[1][(i+1)%4] = (dp[1][(i+1)%4]+MOD-dp[2][(i+3)%4])%MOD;
			dp[1][(i+1)%4] = (dp[1][(i+1)%4]+MOD-dp[0][(i+2)%4]*3%MOD)%MOD;
			dp[2][(i+1)%4] = (dp[2][(i+1)%4]+MOD+dp[2][(i+2)%4])%MOD;
		
	}
	
	for(int i = 0; i < 4; i++) ans += dp[i][(N+3)%4];
	
	cout<<ans%MOD<<endl;
	
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>

using namespace std;

int main()
{
	string s, t;
	cin >> s >> t;

	int mn = 1010101010;
	for (int i = 0; i <= s.length() - t.length(); i++) {
		int u = 0;
		for (int j = 0; j < t.length(); j++) {
			if (s[i + j] != t[j]) {
				u++;
			}
		}
		mn = min(mn, u);
	}
	cout << mn << endl;

	return 0;
}

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

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

	int m = max(max(A,B),C);
	if (m == A){
		cout << 10 * A + B + C << endl; 
	}
	else if (m == B){
		cout << 10 * B + A + C << endl; 
	}
	else{
		cout << 10 * C + B + A << endl; 
	}
	return 0;
}

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

int main() {
  string S, T;
  cin >> S >> T;
  for (int i = S.size() - T.size(); i >= 0; i--) {
    for (int j = 0; j < T.size(); j++) {
      if (!(S[i + j] == '?' || S[i + j] == T[j])) {
        break;
      }
      if (j == T.size() - 1) {
        for (int k = 0; k < S.size(); k++) {
          if (i <= k && k < i + T.size())
            cout << T[k - i];
          else
            cout << (S[k] == '?' ? 'a' : S[k]);
        }
        cout << endl;
        return 0;
      }
    }
  }
  cout << "UNRESTORABLE" << endl;
}

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

#define MP make_pair
#define PB push_back
#define ALL(x)      (x).begin(),(x).end()
#define REP(i,n)    for(int i=0;i<(n);i++)
#define REP1(i,n)   for(int i=1;i<(n);i++)
#define REP2(i,d,n) for(int i=(d);i<(n);i++)
#define RREP(i,n)   for(int i=(n);i>=0;i--)
#define CLR(a)      memset((a),0,sizeof(a))
#define MCLR(a)     memset((a),-1,sizeof(a))
#define RANGE(x,y,maxX,maxY) (0 <= (x) && 0 <= (y) && (x) < (maxX) && (y) < (maxY))
 
typedef long long LL;
typedef unsigned long long ULL;
typedef vector<int> VI;
typedef vector<VI > VVI;
typedef vector<string> VS;
typedef vector<LL> VLL;
typedef pair<int,int> PII;
 
const int INF = 0x3f3f3f3f;
const LL INFL = 0x3f3f3f3f3f3f3f3fLL;
const double EPS = 1e-9;
 
const int DX[]={1,0,-1,0},DY[]={0,-1,0,1};



int main(){
    int H, W;
    cin >> H >> W;
    vector<string> a(H);
    REP(i, H) cin >> a[i];

    set<int> skipH, skipW;
    REP(i, H) {
        bool flag = true;
        REP(j, W) {
            if(a[i][j] == '#') flag = false;
        }

        if(flag) skipH.insert(i);
    }

    REP(i, W) {
        bool flag = true;
        REP(j, H) {
            if(a[j][i] == '#') flag = false;
        }

        if(flag) skipW.insert(i);
    }

    REP(i, H) {
        if(skipH.count(i) == 1) continue;
        REP(j, W) {
            if(skipW.count(j) == 1) continue;
            cout << a[i][j];
        }
        cout << endl;
    }

    return 0;
}


Measured memory_bytes: 764
#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <queue>
#include <set>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;

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


int main(){
    ll N;
    cin >> N;

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

    ll ans = 0;
    if(N == 1){
        ans = 0;
    }else if(N == 2){
        ans = A[0];
    }else{
        ans += A[0];
        rep(i, (N - 2) / 2){
            ans += 2 * A[i + 1];
        }
        if((N - 2) % 2 == 1){
            ans += A[(N - 2) / 2 + 1];
        }
    }

    cout << ans << endl;

    return 0;
}


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

typedef long long ll;
typedef long double lld;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef set<int> si;
typedef map<string, int> msi;
typedef pair<ll, ll> pll;
typedef pair<ll, pair<ll, ll>> plll;

void solve()
{
  int n;
  cin >> n;
  if (n >= 30)
  {
    cout << "Yes\n";
    return;
  }
  cout << "No\n";
  return;
}
int main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);

  // int t;
  // cin >> t;
  // for (int i = 0; i < t; i++)
  // {
  //   solve();
  // }
  solve();
}

Measured memory_bytes: 3644
#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <tuple>
#include <vector>
using namespace std;
typedef long long ll;
ll const INF = 1LL << 60;

int main() {
  string S;
  cin >> S;
  set<char> odd = {'R', 'U', 'D'};
  set<char> even = {'L', 'U', 'D'};
  bool succ = true;
  for (int i = 0; i < S.length(); i++) {
    if (i % 2 == 0 && odd.find(S[i]) == odd.end()) {
      succ = false;
      break;
    } else if (i % 2 == 1 && even.find(S[i]) == even.end()) {
      succ = false;
      break;
    }
  }
  string ans = (succ) ? "Yes" : "No";
  cout << ans << endl;
  return 0;
}

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

using namespace std;

const int MX = 100;

char s[MX][MX + 1];
int dp[MX][MX];

int main() {
	int n, m;
	ignore = scanf("%d %d", &n, &m);
	for (int i = 0; i < n; i++) ignore = scanf("%s", s[i]);
	
	dp[0][0] = (s[0][0] == '.' ? 0 : 1);
	for (int i = 0; i < n; i++)
		for (int j = 0; j < m; j++) {
			if (i == 0 && j == 0) continue;
			
			dp[i][j] = n * m;
			
			if (i > 0) {
				dp[i][j] = min(dp[i][j], dp[i - 1][j] + (s[i][j] != s[i - 1][j] ? 1 : 0));
			}
			
			if (j > 0) {
				dp[i][j] = min(dp[i][j], dp[i][j - 1] + (s[i][j] != s[i][j - 1] ? 1 : 0));
			}
		}
	
	int ans = (dp[n - 1][m - 1] + 1) / 2;
	printf("%d\n", ans);
	
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <valarray>
#include <map>
#include <set>
#include <list>
#include <queue>
#include <stack>
#include <bitset>
#include <utility>
#include <numeric>
#include <algorithm>
#include <functional>
#include <complex>
#include <string>
#include <sstream>

#include <cstdio>
#include <cstdlib>
#include <cctype>
#include <cstring>
#include <cmath>

using namespace std;

#define all(c) c.begin(),c.end()
#define repeat(i,n) for(int i=0;i<static_cast<int>(n);i++)
#define debug(x) #x << "=" << (x)
#define dump(x) cerr << debug(x) << " (L:" << __LINE__ << ")"<< endl

typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int> > vvi;
typedef vector<string> vs;

template<typename T>
ostream& operator<<(ostream& os, const vector<T>& vec){
    os << "[";
    for(int i = 0; i < vec.size(); i++){
        os << vec[i] << ",";
    }
    os << "]";
    return os;
}

template<typename T>
T input(){
    T t;
    cin >> t;
    return t;
}

template<typename T>
vector<T> input(const int N){
    vector<T> v(N);
    repeat(i,N) cin >> v[i];
    return v;
}

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

long long lcm(long long a, long long b){
    return (a / gcd(a, b)) * b;
}

long long mul(const long long& a, const long long& b, const long long& mod) {
    return ((a % mod) * (b % mod)) % mod;
}

long long power(const long long& x, const long long& y, const long long& mod) {
    if (y == 0) {
        return 1;
    } else if (y == 1) {
        return x % mod;
    } else {
        long long value = power(x, y / 2, mod);
        if (y % 2 == 0) {
            return mul(value, value, mod);
        } else {
            return mul(value, value, mod) * x % mod;
        }
    }
}

long long div(const long long& a, const long long& b, const long long& mod) {
    return mul(a, power(b, mod - 2, mod), mod);
}

map<long long, long long> factorials;
long long factorial(const long long& n, const long long& mod) {
    if (n == 0 || n == 1) {
        return 1;
    }
    if (factorials[n] != 0) {
        return factorials[n];
    }
    factorials[n] = n * factorial(n - 1, mod) % mod;
    return factorials[n] % mod;
}

long long combination(const long long& n, const long long& x, const long long& mod) {
    long long numerator = 1;
    long long denominator = 1;
    repeat(i, x) {
        numerator *= (n - i) % mod;
        numerator %= mod;
        denominator *= (i + 1) % mod;
        denominator %= mod;
    }
    return div(numerator, denominator, mod);
}

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

    set<int> remainders;
    for (int n = 1; ; ++n) {
        int remainder = (n * A - C) % B;
        if (remainders.find(remainder) != remainders.end()) {
            cout << "NO" << endl;
            break;
        }
        if (remainder == 0) {
            cout << "YES" << endl;
            break;
        }
        remainders.insert(remainder);
    }
    return 0;
}


Measured memory_bytes: 256
import java.util.*;
 
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.next());
        int m = Integer.parseInt(sc.next());
        int[] p = new int[m];
        int[] y = new int[m];
        Map<Integer, Integer> map = new TreeMap<>();
        for(int i=0; i<m; i++) {
            p[i] = Integer.parseInt(sc.next());
            y[i] = Integer.parseInt(sc.next());
            map.put(y[i], i);
        }

        int[] num = new int[m];
        int[] parr = new int[n];
        for(int key : map.keySet()) {
            int pre = p[map.get(key)];
            parr[pre-1]++;
            num[map.get(key)] = parr[pre-1];
        }
        
        for(int i=0; i<m; i++) {
            String s = String.format("%06d", p[i])+String.format("%06d", num[i]);
            System.out.println(s);
        }
    }
}

Measured memory_bytes: 126204
#include <iostream>

int main(){
	int n;
	int cand1 = 0;
	int cand2 = 1;

	std::cin >> n;

	for(int i = 1; i <= n; ++i){
		int m = i;
		int count = 0;
		while(m % 2 == 0){
			m /= 2;
			++count;
		}
		if(count > cand1){
			cand1 = count;
			cand2 = i;
		}
	}

	std::cout << cand2 << std::endl;

	return 0;
}


Measured memory_bytes: 256
MOD = 10**9 + 7

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

Cs.sort(reverse=True)

pow2 = pow(2, 2*N-2, MOD)

ans = 0
for i, C in enumerate(Cs, start=1):
    ans += C*(i+1)*pow2
    ans %= MOD

print(ans)


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

int digit(ll x) {
    if (x / 10 == 0) return 1;
    return digit(x / 10) + 1;
}

ll gcd(long long a,long long b) {
    if (a < b) swap(a,b);
    if (b == 0) return a;
    
    return gcd(b,a%b);
}

ll lcm(ll a,ll b){
    a / gcd(a,b) * b;
}

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


/////////////////////////////////////////////////////////////////////////////////////////
#define MAX 10000100

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

ll beki(ll a,ll b){
    a %= mod;
    if (b == 0){
        return 1;
    }
    ll ans = beki(a,b / 2);
    ans = ans * ans % mod;
    if (b % 2 == 1){
        ans = ans * a % mod;
    }
    return ans;
}

void cominit(){
    const int MA = 10000002;
    fac[0] = 1;
    inv[0] = 1;
    for (int i = 1;i <= MA;i++){
        fac[i] = fac[i-1] * i % mod;
    }
    finv[MA] = beki(fac[MA],mod - 2);
    for (ll i = MAX - 1;i >= 0;i--){
        finv[i] = finv[i+1] * (i + 1) % mod;
    }
    for (int i = 1;i <= MA;i++){
        inv[i] = finv[i] * fac[i - 1] % mod;
    }
}

ll com(ll a,ll b){
    if ((a == b) or (b == 0)){
        return 1;
    }
    if (a < b) return 0;
    ll ret = 1;
    for (ll i = 0;i < b;i++){
        ret *= (a - i);
        ret %= mod;
        ret *= beki(i + 1,mod - 2);
        ret %= mod;
    }
    return ret;
}

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

    ll ans = beki(2,n);
    ans -= 1;
    ans -= com(n,a);
    ans -= com(n,b);
    ans += 2 * mod;
    ans %= mod;

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
use std::io;
use std::str::FromStr;

fn input<T:FromStr>() -> T {
    let mut line: String = String::new();
    io::stdin().read_line(&mut line);
    line.trim().parse().ok().unwrap()
}

fn input_vec() -> Vec<u64> {
    let mut line: String = String::new();
    io::stdin().read_line(&mut line);
    line.split_whitespace().map(|s| s.parse().unwrap()).collect()
}

fn main() {
    let n: usize = input();
    let a_vec = input_vec();
    let mut dp = vec![vec![vec![0f64; n+1]; n+1]; n+1];
    let mut one = 0usize;
    let mut two = 0usize;
    let mut three = 0usize;
    for a in a_vec {
        if a == 1 {
            one += 1;
        } else if a == 2 {
            two += 1;
        } else {
            three += 1;            
        }
    }    
    for k in 0..(n+1) {
        for j in 0..(n+1) {
            for i in 0..(n+1) {
                if i == 0 && j == 0 && k == 0 {
                    continue;
                }
                let mut sum = 0f64;
                if i != 0 {
                    sum += dp[i-1][j][k] * i as f64;
                }
                if j != 0 && i != n {
                    sum += dp[i+1][j-1][k] * j as f64;
                }
                if k != 0 && j != n {
                    sum += dp[i][j+1][k-1] * k as f64;
                }
                dp[i][j][k] = (sum + n as f64) / (i + j + k) as f64;
                // println!("{}", (sum + n as f64));
                // println!("({}, {}, {}) -> {}", i, j, k, dp[i][j][k]);
                if i == one && j == two && k == three {
                    println!("{}", dp[i][j][k]);
                    return;
                }
            }
        }
    }
}


Measured memory_bytes: 237948
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i = (a); i <= (b); i++)
#define rng(a) a.begin(), a.end()
#define ina(n,a) cin >> n; for(int i = 1; i <= n; i++) cin >> a[i]
#define sz(x) (int)(x).size()
#define se second
#define fi first
#define prev            coyhhhhhhyoc    
#define next          sdNNNmNNNNNNNmds  
#define y0           hNNNNy_yNNNNNN_sNh
#define y1          mNNNNNdtdNNNNNNtsNNm
#define yn          mNNNNNNNNy___smNNNms
#define tm            oooooosyysooooot 
#define read               tyhyt        
#define rank              ytmNmo         
#define index              yyy
#define pb push_back
#define pcnt __builtin_popcountll
#define rrep(i,a,b) for(int i = (b); i >= (a); i--)
#define rall(x,a) for(auto x : a)
#define MOD 1000000007
typedef long long ll;
using namespace std;

const int N = 111111;
int a[N];
tuple<int, int, int> dp[N];
int n, m;

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    string s;
    cin >> n >> m >> s;
    rep(i, 0, n) {
        a[i] = s[i] == '1';
    }
    set<tuple<int, int, int> > st;
    fill(dp, dp + n + 1, make_tuple(1e9, 0, 0));
    dp[n] = tuple<int, int, int>{0, 0, n};
    st.insert(dp[n]);
    rrep(i, 0, n - 1) {
        if(i + m < n) {
            st.erase(dp[i + m + 1]);
        }
        if(st.size() && !a[i]) {
            tuple<int, int, int> mini = *(st.begin());
            int nj = get<0>(mini), np = get<2>(mini);
            dp[i] = tuple<int, int, int>{get<0>(mini) + 1, -(np - i), i};
            st.insert(dp[i]);
        }
    }
    if(get<0>(dp[0]) == 1e9) {
        cout << -1 << endl;
        return 0;
    }
    vector<int> ans;
    int i = 0;
    while(i < n) {
        ans.pb(-get<1>(dp[i]));
        i -= get<1>(dp[i]);
    }
    rall(x, ans) {
        cout << x << " ";
    }
    cout << endl;
    return 0;
}


Measured memory_bytes: 5376
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define repone(i,n) for(int i=1;i<(int)(n);++i)
#define repo(i,o,n) for(int i=o;i<(int)(n);++i)
#define Rep(j,n) for(int j=0;j<(int)(n);++j)
#define Repo(j,o,n) for(int j=o;j<(int)(n);++j)
#define Repone(j,n) for(int j=1;j<(int)(n);++j)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define int long long
#define pb(a) push_back(a)
#define eraser(v,i) (v).erase(v.begin()+(i))
#define pbpair(a,b) push_back(make_pair(a,b))
#define MOD 1000000007
const long long INF = 1LL<<60;
#define pairint pair<int,int>
signed main(){
  int x=0,y=0,z=0,n=0,m=0;
  std::vector<int> v(n);
  std::cin >> n>>x>>y;
  rep(i,n){
    std::cin >> z;
    if(z!=1)m+=((x-1)/z)+1;
    else m+=x/z;
  }
  std::cout << m+y << '\n';
}


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

struct node{
  struct node *right;
  struct node *left;
  struct node *parent;
  int key;
};
typedef struct node *Node;
#define NIL NULL

Node root;
Node treeMinimum(Node);
Node treeMaximum(Node);
Node treeSearch(Node,int);
Node treeSuccessor(Node);
void treeDelete(Node);
void insert(int);
void inorder(Node);
void preorder(Node);

int main(){
  int n,i,x;
  char com[7];
  scanf("%d",&n);

  for ( i = 0; i < n; i++ ){
    scanf("%s", com);
    if ( com[0] == 'f' ){
      scanf("%d", &x);
      Node t = treeSearch(root, x);
      if ( t != NIL ) printf("yes\n");
      else printf("no\n");
    } else if ( com[0] == 'i' ){
      scanf("%d", &x);
      insert(x);
    } else if ( com[0] == 'p' ){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    } else if ( com[0] == 'd' ){
      scanf("%d", &x);
      treeDelete(treeSearch(root, x));
    }
  }
  return 0;
}

Node treeMinimum(Node x){
  while(x->left !=  NIL){
    x = x->left;
  }
  return x;
}

Node treeMaximum(Node x){
  while(x->right != NIL){
    x = x->right;
  }
  return x;
}

Node treeSearch(Node x,int k){
  if(x==NIL || k == x->key){
    return x;
  }
  if(k < x->key){
    return treeSearch(x->left,k);
  }
  else{
    return treeSearch(x->right,k);
  }
}

Node treeSuccessor(Node x){
  Node y;
  if(x->right != NIL){
    return treeMinimum(x->right);
  }
  y = x->parent;
  while(y!=NIL && x==y->right){
    x=y;
    y=y->parent;
  }
  return y;
}

void treeDelete(Node z){
  Node y;
  Node x;
  if(z->left == NIL || z->right ==NIL){
    y = z;
  }
  else{
    y=treeSuccessor(z);
  }
  if(y->left != NIL){
    x = y->left;
  }
  if(x != NIL){
    x->parent = y->parent;
  }
  if(y->parent == NIL){
    x = root;
  }
  else if(y==y->parent->left){
    y->parent->left = x;
  }
  else{
    y->parent->right =x;
  }
  if(y != z){
    z->key = y->key;
  }
}

void insert(int k){
  Node y = NIL;
  Node x = root;
  Node z;

  z = malloc(sizeof(struct node));
  z->key = k;
  z->left = NIL;
  z->right = NIL;

  while(x!=NIL){
    y=x;
    if(z->key < x->key){
      x = x->left;
    }
    else{
      x = x->right;
    }
  }
  z->parent = y;
  if(y == NIL){
    root = z;
  }
  else if(z->key < y->key){
    y->left = z;
  }
  else{
    y->right = z;
  }
}

void inorder(Node x){
  if(x!=NIL){
    inorder(x->left);
    printf(" %d",x->key);
    inorder(x->right);
  }
}
void preorder(Node x){
  if(x != NIL){
    printf(" %d",x->key);
    preorder(x->left);
    preorder(x->right);
  }
}



Measured memory_bytes: 25140
#include <stdio.h>
#define N 3
#define MAX 362880
#define FALSE 0
#define TRUE 1

typedef struct {
  int num[9];
  int space;
  int moves;
} PUZZLE;

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

int V[MAX];

PUZZLE Q[MAX];
int head,tail;

int emp(){
  if(head == tail) return TRUE;
  return FALSE;
}

void push(PUZZLE p){
  Q[tail] = p;
  tail = (tail+1)%MAX; //Ring Buffer
}

PUZZLE pop(){
  PUZZLE p;
  p = Q[head];
  head = (head+1)%MAX;
  return p;
}

void swap(int *x,int *y){
  int tmp;
  tmp = *x;
  *x = *y;
  *y = tmp;
}

int count(PUZZLE p){
  int i, j, fac, cnt, result = 0;
  for(i = 0, fac = 1; i < 9; fac*= ++i){
    for(j = 0, cnt = 0; j < i; j++){
      if(p.num[j] < p.num[i]) cnt++;
    }
    result += cnt*fac;
  }
  
  return result;
}
  

int check_goal(PUZZLE p){
  int i;
  for(i  = 0; i < 9; i++){
    if(p.num[i] != (i + 1)) return FALSE;
  }
  return TRUE;
}

int BFS(PUZZLE s){
  int sx,sy,tx,ty,r;
  PUZZLE u,v;

  s.moves = 0;

  push(s);

  V[count(s)] = 1;

  while(emp() != TRUE){
    u = pop();
    if(check_goal(u) == TRUE) return u.moves;
    sx = u.space/N;
    sy = u.space%N;

    for(r = 0; r < 4; r++){
      tx = sx + dx[r];
      ty = sy + dy[r];
      if(tx < 0 || ty < 0 || tx >= N || ty >= N) continue;
      v = u;

      swap(&v.num[u.space], &v.num[tx*N + ty]);
      v.space = tx*N + ty;

      if(V[count(v)] != TRUE){
	V[count(v)] = 1;
	v.moves++;
	push(v);
      }
    }
  }

  return -1;
}

int main(){
  int i;
  PUZZLE in;

  for(i = 0; i < 9; i++){
    scanf("%d",&in.num[i]);
    if(in.num[i] == 0){
      in.num[i] = 9;
      in.space = i;
    }
  }

  printf("%d\n",BFS(in));

  return 0;
}



Measured memory_bytes: 11004
#include <iostream>
#include <vector>
#include <algorithm>
#define REP(i, n) for(int i=0;i<n;++i)

typedef long long ll;
using namespace std;
int main(){
    int n;
    cin >> n;
    string s;
    cin >> s;
    const int NUM = 26;
    for(int i=0;i<s.length();i++){
        int x = s[i]+n-'A';
        x %= NUM;
        printf("%c", x+'A');
    }
    cout << "\n";

    return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#include<string>
#include<algorithm>

using namespace std;

void kensaku(string, string, int);
int main(){
  int n, i , j, a;
  string s;
  while(cin >> s){
    kensaku(s, "JOI", s.length()); 
    kensaku(s, "IOI", s.length()); 
  }
	return 0;
}

void kensaku(string s, string t, int n){
  int i, j, a = 0;
  for(i = 0; i < n - 2; i++){
    bool f = true;
    for(j = 0; j < 3; j++){
      f = f && (s[i + j] == t[j]);
    } 
    //printf("t:%s %c%c%c\n", t.c_str(), s[i], s[i + 1], s[i + 2]);
    if(f)
      a++;
  }
  printf("%d\n", a);
}

Measured memory_bytes: 1204
import sys


def main():
    input = sys.stdin.buffer.readline
    n = int(input())
    cnt = [0] * (n + 1)
    for i in range(1, n + 1):
        for j in range(i, n + 1, i):
            cnt[j] += 1
    ans = len([i for i in range(1, n + 1, 2) if cnt[i] == 8])
    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 9116
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using static System.Math;

namespace AtCoderProject
{
    class Program
    {
        static void Main(string[] args)
        {
            var input = ReadLineIntArray();
            int A = input[0];
            int B = input[1];
            int C = input[2];

            int max;
            int count = 0;

            if (A % 2 == 1 && B % 2 == 1 && C % 2 == 1) { }
            else
            if (A % 2 == 0 && B % 2 == 0 && C % 2 == 0) { }
            else
            if (A % 2 == 1 && B % 2 == 0 && C % 2 == 0) { ++B; ++C; ++count; }
            else
            if (A % 2 == 0 && B % 2 == 1 && C % 2 == 1) { ++B; ++C; ++count; }
            else
            if (A % 2 == 1 && B % 2 == 0 && C % 2 == 1) { ++A; ++C; ++count; }
            else
            if (A % 2 == 0 && B % 2 == 1 && C % 2 == 0) { ++A; ++C; ++count; }
            else
            if (A % 2 == 1 && B % 2 == 1 && C % 2 == 0) { ++A; ++B; ++count; }
            else
            if (A % 2 == 0 && B % 2 == 0 && C % 2 == 1) { ++A; ++B; ++count; }

            max = Max(Max(A, B), C);

            count += ((max - A) + (max - B) + (max - C)) / 2;

            Console.WriteLine(count);
        }


        #region READER
        static int ReadLineInt() => int.Parse(Console.ReadLine());
        static int[] ReadLineIntArray() => Console.ReadLine().Split(' ').Select(s => int.Parse(s)).ToArray();

        static IEnumerable<string> ReadInputEnumruble(int count = int.MaxValue)
        {
            for (int i = 0; i < count; i++)
            {
                yield return Console.ReadLine();
            }
        }
        static int[] ReadInputInt(int count = int.MaxValue)
        {
            return ReadInputEnumruble(count).Select(s => int.Parse(s)).ToArray();
        }
        #endregion
    }
}


Measured memory_bytes: 13268
import sys
input = sys.stdin.readline

N,K=map(int,input().split())
mod=10**9+7

L=[i for i in range(K+1)]

for i in range(1,K):
    for j in range(i*2,K+1,i):
        L[j]-=L[i]

ANS=0
for i in range(1,K+1):
    ANS=(ANS+pow(K//i,N,mod)*L[i])%mod

print(ANS)


Measured memory_bytes: 13020
#include<bits/stdc++.h>
using namespace std;
struct node
{
    int x,y;
    node(int x,int y):x(x),y(y) {}
};
vector<node>a[20];
int v[20],n,ans,num;
int check()
{
    num=0;
    for(int i=1; i<=n; i++)
    {
        if(v[i])
        {
            num++;
            for(int j=0; j<a[i].size(); j++)
                if(v[a[i][j].x]!=a[i][j].y)
                    return -1;
        }
    }
    return num;
}
void dfs(int x)
{
    if(x==n+1)
    {
        if(check()!=-1)
            ans=max(ans,num);
        return ;
    }
    for(int i=0; i<=1; i++)
    {
        v[x]=i;
        dfs(x+1);
    }
}
int main()
{
    scanf("%d",&n);
    for(int i=1; i<=n; i++)
    {
        int k;
        scanf("%d",&k);
        for(int j=1; j<=k; j++)
        {
            int x,y;
            scanf("%d%d",&x,&y);
            a[i].push_back(node(x,y));
        }
    }
    dfs(1);
    printf("%d",ans);
}


Measured memory_bytes: 256
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner scan=new Scanner(System.in);
		int d=scan.nextInt(),n=scan.nextInt();
		if	(n==100)	++n;
		for (int i=1;i<=d;++i)
			n*=100;
		System.out.println(n);
	}
}


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

int main() {
  string N;
  cin >> N;
  int sum_digit = 0;
  for (size_t i = 0; i < N.size(); ++i) {
    sum_digit += N[i] - '0';
  }
  if (sum_digit % 9 == 0) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}


Measured memory_bytes: 3728
S = input()
L = len(S)
SS = ""
cnt = 0

if S[0] == "0":
    while len(SS) < L:
        SS += "0"
        SS += "1"

else:
    while len(SS) < L:
        SS += "1"
        SS += "0"

for i in range(L):
    if S[i] != SS[i]:
        cnt += 1

print(cnt)

Measured memory_bytes: 9316
n = int(input())
a = list(map(int, input().split()))

def solve():
    if max(a)-min(a) > 1:
        return False
    if all(i==a[0] for i in a):
        if a[0] == n-1 or a[0] <= n//2:
            return True
        else:
            return False
    color = [0]*n
    unique = min(a)
    for i, ai in enumerate(a):
        if ai == unique:
            color[i] = 1
    s = sum(color)
    can = (n-s)//2

    for i, ai in enumerate(a):
        if ai == unique:
            if not (s <= ai <= s-1+can):
                return False
        else:
            if not (s+1 <= ai <= s+can):
                return False
    return True

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

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

int main(void)
{
    long a, b, x;
    cin >> a >> b >> x;
    if(a%x==0)
        cout << (b/x) - (a/x)+1 << endl;
    else
        cout << b/x - a/x << endl;

}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <map>
#include <queue>
#include <iomanip>
#include <set>
#include <tuple>
#define mkp make_pair
#define mkt make_tuple
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
const ll MOD=1e9+7;

int N;
string S[202];

int color[202];

void dfs(int now,int col){
  color[now]=col;
  for(int i=0;i<N;i++){
    if(S[now][i]=='0') continue;
    if(color[i]!=0){
      if(color[i]==color[now]){
        cout<<-1<<endl;
        exit(0);
      }
    }else dfs(i,-col);
  }
}

int dist[202][202];
const int INF=1e9;

int main(){
  cin>>N;
  for(int i=0;i<N;i++) cin>>S[i];

  dfs(0,1);

  for(int i=0;i<N;i++){
    for(int j=0;j<N;j++){
      dist[i][j]=INF;
    }
  }

  for(int i=0;i<N;i++){
    for(int j=0;j<N;j++){
      if(S[i][j]=='1') dist[i][j]=1;
      if(i==j) dist[i][j]=0;
    }
  }

  for(int k=0;k<N;k++){
    for(int i=0;i<N;i++){
      for(int j=0;j<N;j++){
        if(dist[i][j]>dist[i][k]+dist[k][j]) dist[i][j]=dist[i][k]+dist[k][j];
      }
    }
  }

  int ma=0;
  for(int i=0;i<N;i++){
    for(int j=0;j<N;j++){
      ma=max(ma,dist[i][j]);
    }
  }

  cout<<ma+1<<endl;

  return 0;
}


Measured memory_bytes: 512
n, x = map(int, input().split())
while n != 0 or x != 0:
	m = 0
	for i in range(1, n + 1):
		for j in range(i + 1, n + 1):
			for k in range(j + 1, n + 1):
				if i + j + k == x:
					m += 1
	print(m)
	n, x = map(int, input().split())


Measured memory_bytes: 5596
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define pb push_back
#define mp make_pair
#define rep(i,n) for(int i=0;i<(n);++i)
const int mod=1000000007;

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;cin >> n;
	string s;cin >> s;
	vector<ll> a(26);
	rep(i,n) a.at(s.at(i)-'a')++;
	ll ans=1;
	rep(i,26){
		ans*=a.at(i)+1;
		ans%=mod;
	}
	ans--;
	cout << ans%mod << endl;
}

Measured memory_bytes: 512
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<unordered_set>
#include<unordered_map>
#include<bitset>
using namespace std;
#define INF 1000000007
#define LINF 100000000000000007
#define MOD 1000000007
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define MODE 1
#ifdef MODE
#define DEB(X) cout<< #X <<": "<<X<<" ";
#define ARDEB(i,X) cout<< #X <<"["<<i<<"]: "<<X[i]<<" ";
#define END cout<<endl;
#else
#define DEB(X) {}
#define ARDEB(i,X) {}
#define END {}
#endif
typedef long long  ll;
typedef pair<int,int> P;
struct edge{int to,cost;};

//�ő����
ll gcd(ll a,ll b){
    
    if(a==0 || b==0)return 0;
    if(a<b){
        ll sw;
        sw=a;
        a=b;
        b=sw;
    }
    
    ll r;
    while((r=a%b)!=0){
        a=b;
        b=r;
    }
    return b;
}
//�ŏ����{��
ll lcm(ll a,ll b){


    if(a==0 || b==0)return 0;

    return a/gcd(a,b)*b;

}

int ans;

signed main(){
	
	int n;
	double a[111];
	cin>>n;
	rep(i,n)cin>>a[i];
	sort(a,a+n);
	double ans2=(a[0]+a[1])/2;
	for(int i=2;i<n;i++){
		ans2=(ans2+a[i])/2;
	}
	printf("%.6lf",ans2);
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <numeric>
#include <iomanip>
#include <map>
#include <set>
#include <deque>
#include <utility>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < n; i++)
#define repk(i, k, n) for (int i = k; i < n; i++)
#define all(vec) vec.begin(), vec.end()
#define MOD 1e9 + 7
#define INF 1e9
#define SENTINEsL 2e9
#define PIE 3.1415a926535

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;}
template <class T>
inline T GCD(T a, T b){if (b == 0) return a; else return GCD(b, a % b);}
template <class T>
inline T LCM(T a, T b) {return (a * b) / GCD(a, b);}

int main(){
    int x, y, z;
    cin >> x >> y >> z;
    cout << z << ' ' << x << ' ' << y << endl;
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include<set>
#include<map>
#include<list>
#include<iomanip>
#include<cmath>
#include<string>
#include<vector>
#include<queue>
#include<stack>
#include<complex>
#include<sstream>
#include<iostream>
#include<fstream>
#include<algorithm>
#include<numeric>
#include<utility>
#include<functional>
#include<stdio.h>
#include<assert.h>
#include<memory.h>
#include<bitset>
using namespace std;

#define all(v)				((v).begin()), ((v).end())
#define sz(v)				((int)((v).size()))
#define clr(v, d)			memset(v, d, sizeof(v))
#define rep(i, v)		for(int i=0;i<sz(v);++i)
#define lp(i, n)		for(int i=0;i<(int)(n);++i)
#define lpi(i, j, n)	for(int i=(j);i<(int)(n);++i)
#define lpd(i, j, n)	for(int i=(j);i>=(int)(n);--i)
#define pb					push_back
#define MP					make_pair
#define P(x)				cout<<#x<<" = { "<<x<<" }\n"
typedef long long         ll;
typedef long double   	  ld;
typedef vector<int>       vi;
typedef vector<double>    vd;
typedef vector< vi >      vvi;
typedef vector< vd >      vvd;
typedef vector<string>    vs;
typedef vector<ll>		  vll;


const ll OO = 1e16;

const double EPS = (1e-7);
int dcmp(double x, double y) { return fabs(x - y) <= EPS ? 0 : x < y ? -1 : 1; }


void fast(){
	std::ios_base::sync_with_stdio(0);
	cin.tie(NULL); cout.tie(NULL);
}
int n;
string s;
ll a[100];
bool rec(int i , int sum){
	if (i == 4){
		return (sum == 7);
	}
	bool ret = 0;
	ret |=rec(i + 1, sum + a[i]) ||	rec(i + 1, sum - a[i]);
	return ret;
}

void build(int i, int sum){
	if (i == 4){
		return ;
	}
	bool ret = 0 , ret1 = 0;
	ret = rec(i + 1, sum + a[i]);
	ret1 = rec(i + 1, sum - a[i]);
	if (ret == 1){
		if (i == 0)
			cout << a[i];
		else cout << "+" << a[i];
		build(i + 1, sum + a[i]);
	}
	else if (ret1 == 1){
		cout << "-" << a[i];
		build(i + 1, sum - a[i]);
	}
}
int main(){
	fast();
	cin >> s;
	for (int i = 0; i < 4; i++) a[i] = (s[i] -'0');
	rec(0, 0);
	build(0, 0);
	cout << "=7" << endl;
	return 0;
}
//mosta7il_

Measured memory_bytes: 256