akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
using namespace std;
string S, T; int a[100005], b[100005];
int main() {
	cin >> S >> T;
	for (int i = 1; i <= S.size(); i++) { if (S[i - 1] == 'B')a[i] = 2; else a[i] = 1; }
	for (int i = 1; i <= T.size(); i++) { if (T[i - 1] == 'B')b[i] = 2; else b[i] = 1; }
	for (int i = 1; i <= S.size(); i++)a[i] += a[i - 1];
	for (int i = 1; i <= T.size(); i++)b[i] += b[i - 1];
	int q, a1, a2, a3, a4;
	cin >> q;
	for (int i = 0; i < q; i++) {
		cin >> a1 >> a2 >> a3 >> a4;
		if (((a[a2] - a[a1 - 1]) - (b[a4] - b[a3 - 1]) + 300000000) % 3 == 0)cout << "YES" << endl;
		else cout << "NO" << endl;
	}
	return 0;
}

Measured memory_bytes: 1664
from collections import defaultdict
n = int(input())
d = defaultdict(int)
for _ in range(n):
    s = input()
    d[s] += 1
t = max([i for i in d.values()])
res = []
for i in d:
    if d[i] == t:
        res.append(i)
res.sort()
for i in res:
    print(i)

Measured memory_bytes: 32480
h,w,a,b = map(int,input().split())
s = [['0']*w for _ in range(h)]

for i in range(b):
    for j in range(a):
        s[i][j] = '1'

for i in range(h-b):
    for j in range(w-a):
        s[i+b][j+a] = '1'

for i in range(h):
    print(''.join(s[i]))

Measured memory_bytes: 48752
#include <iostream>
#include <cmath>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;

int digits(long long N){
    int dig=0;
    while(N>0){
        N /= 10;
        dig++;
    }
    return dig;
}

int main() {
    long long N,A,B;
    cin >> N;

    int ans=1000,cur;
    for(A=1;A<sqrt(N)+1;A++){
        if(N%A != 0) continue;

            B = N/A;
            cur = max(digits(A), digits(B));
            ans = min(ans, cur);
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
n,m = map(int,input().split())
ab = list(list(map(int,input().split())) for _ in range(n))

ab.sort()
need_energy = m
answer = 0
for i in range(n):
    if need_energy <= ab[i][1]:
        answer += ab[i][0]*need_energy
        break
    else:
        answer += ab[i][0]*ab[i][1]
        need_energy -= ab[i][1]

print(answer)


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

using namespace std;

class UnionFind {
private:
	vector<int> v;
public:
	UnionFind(int n) {
		for (int i = 0; i < n; i++) v.emplace_back(-1);
	}
	int root(int x) {
		return v[x] < 0 ? x : v[x] = root(v[x]);
	}
	void unite(int x, int y) {
		if (root(x) == root(y)) {
			return;
		}
		v[root(x)] = root(y);
	}
	bool same(int x, int y) {
		return root(x) == root(y);
	}
};

int main() {
	int n, q;
	cin >> n >> q;
	UnionFind uf(n);
	for (int i = 0; i < q; i++) {
		int com, x, y;
		cin >> com >> x >> y;
		if (!com) uf.unite(x, y);
		else cout << uf.same(x, y) << endl;
	}
	return 0;
}

Measured memory_bytes: 3248
using namespace std;

using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;
#include <iostream>
#include <string>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <cmath>
#include <climits>
#define all(x) (x).begin(),(x).end()

void solve(){

}
int main(){
    int N;
    cin >> N;
    int a[N] = {0};
    int sum = 0;
    for (int i = 0; i < N; i++){
        cin >> a[i];
        sum+=a[i];
    }
    if (sum % 2 == 0){
        cout << "YES" << endl;
    } else {
        cout << "NO" << endl;
    }
}


Measured memory_bytes: 640
#include<cstdio>

int main(void)
{
	int n;

	while(scanf("%d", &n)==1)
	{
		int ans=1;
		int h=(n+1)/2;
		char s[100+2];

		scanf("%100s", s);

		for(int i=0;i<h;i++)
		{
			if(s[i]!=s[h+i]) ans=0;
		}

		printf("%s\n", ans?"Yes":"No");
	}
}


Measured memory_bytes: 128
#include <stdio.h>
#include <iostream>

using namespace std;

int main(void){
	long long int x;
	long long int sum;
	long long int ans;

	scanf("%lld", &x);

	for(long long int i = 0 ; sum < x; i++){
		sum += i;
		ans = i;
	}
	printf("%lld\n", ans);

	return 0;
}

Measured memory_bytes: 256
public class Main {
    private static java.util.Scanner scanner = new java.util.Scanner(System.in);

    public static void main(String[] args) {
        int n = scanner.nextInt(), t = scanner.nextInt(), ans = 0;
        for (int i = 1, last = scanner.nextInt(); i < n; i++)
            ans += Math.min(t, 0 - last + (last = scanner.nextInt()));
        System.out.println(ans + t);
    }
}

Measured memory_bytes: 62620
#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 25, M = 1e6 + 25, oo = 1e9+7, mxmsk = 1 << 16;
const long long OO = 1e18+25;
    
#define f first
#define s second

int n, m;
char s[100];
int main() {
    scanf("%d%s",&n,s);
    for(int i=0; i<n; i++) 
        if(s[i]=='A' && s[i+1] == 'B' && s[i+2] == 'C')
        {
            m++;
        }
    printf("%d",m);
    return 0;
}

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

int main() {
  string s;
  cin >> s;
  string x;
  
  if((s.at(0) == s.at(1) && s.at(2) == s.at(3) && s.at(0) != s.at(2)) ||
     (s.at(0) == s.at(2) && s.at(1) == s.at(3) && s.at(0) != s.at(1)) ||
     (s.at(0) == s.at(3) && s.at(1) == s.at(2) && s.at(0) != s.at(1))) x = "Yes";
  else x = "No";
    
  cout << x << endl;
}
  
  

Measured memory_bytes: 256
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <queue>
#include <string>
using namespace std;
#define rep(i,a,n) for(ll i=a;i<n;i++)
#define rrep(i,a,n) for(ll i=n;i>=a;i--)
typedef long long ll;
typedef pair<ll,ll> P;
const ll INF = 1e+17;
const ll MODcdf = 998244353;
int main(){
    ll n,m;cin>>n>>m;
    ll x[m];
    rep(i,0,m)cin>>x[i];
    sort(x,x+m);
    ll dis[m-1];
    rep(i,0,m-1){
        dis[i]=x[i+1]-x[i];
    }
    sort(dis,dis+m-1,greater<ll>());
    ll ans=0;
    rep(i,n-1,m-1)ans+=dis[i];
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 1792
class Queue():
    def __init__(self, n):
        self.Max = n + 1
        self.Q = [0 for i in range(self.Max)]
        self.head = 0
        self.tail = 0

    def isEmpty(self):
        return self.head == self.tail

    def isFull(self):
        return self.head == (self.tail + 1) % self.Max

    def enqueue(self, x):
        self.Q[self.tail] = x
        if self.tail+1 == self.Max:
            self.tail = 0
        else:
            self.tail += 1

    def dequeue(self):
        if self.head+1 == self.Max:
            self.head = 0
            return self.Q[self.head-1]
        else:
            self.head += 1
            return self.Q[self.head-1]


n, q = map(int, input().split())
que = Queue(n)
time = 0

for i in range(n):
    name_time = list(input().split())
    name_time[1] = int(name_time[1])
    que.enqueue(name_time)

while True:
    name_time = que.dequeue()
    if name_time[1]-q > 0:
        time += q
        name_time[1] -= q
        que.enqueue(name_time)
    elif name_time[1]-q == 0:
        time += q
        name_time[1] = 0
        print(name_time[0], time)
    else:
        time += name_time[1]
        name_time[1] = 0
        print(name_time[0], time)
    if que.isEmpty():
        break



Measured memory_bytes: 14360
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define mp make_pair
#define pb push_back
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)


int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  
  ll n,k;
  cin >> n >> k;
  cout << min(n%k, k - n%k) << endl;


  return 0;
    

}


Measured memory_bytes: 764
#include <math.h>

#include <algorithm>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <string>
#include <vector>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
using ll = long long;
using P = pair<int, int>;

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

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


Measured memory_bytes: 3856
#include <bits/stdc++.h>
#define ll long long


using namespace std;

const int MAXN = (int) 50;

ll v[MAXN + 1];



int main() {
    //fstream cin("A.in");
    //ofstream cout("A.out");
    int i, n;
    ll k;
    ios::sync_with_stdio(false);
    cin >> k;
    n = 50;
    ll x = k / n;
    for(i = 1; i <= n; i++)
        v[i] = x * n - x * (n - 1) + i - 1;
    for(i = 1; i <= k - x * n; i++) {
        v[i] += n;
        for(int j = 1; j <= n; j++)
            if(i != j)
               v[j]--;
    }
    cout << n << endl;
    for(i = 1; i <= n; i++)
        cout << v[i] << " ";
    //cin.close();
    //cout.close();
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int gcd(int a,int b,int c)
{int hcf;
int st=a<b?(a<c?a:c):(b<c?b:c);
for (hcf=st;hcf>=1;hcf--)
 	{
  	  if (a%hcf==0 && b%hcf==0 && c%hcf==0)
  		 break;
 	} 
return hcf;
}
int main()
{
  long long  int n,sum=0;
    cin>>n;
    for(int i=1; i<=n; i++)
    {
       for(int j=1; j<=n; j++)
       {
            for(int k=1; k<=n; k++)
            {
                sum+=gcd(i,j,k); 
            }

        }
    }
    cout<<sum;
}

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

constexpr int inf = 1e9;
constexpr ll linf = 1e18;

constexpr double eps = 1e-8;
inline constexpr bool eq(double a, double b) { return fabs(a - b) < eps; }

//-----点-----//
struct Point
{
    double x, y;

    constexpr Point(double x = 0.0, double y = 0.0) : x(x), y(y) {}

    Point &operator+=(const Point &p) { x += p.x, y += p.y; return *this; }
    Point &operator-=(const Point &p) { x -= p.x, y -= p.y; return *this; }
    Point &operator*=(const double k) { x *= k, y *= k; return *this; }
    Point &operator/=(const double k) { x /= k, y /= k; return *this; }
};

inline Point operator+(const Point &p, const Point &q) { return Point(p) += q; }
inline Point operator-(const Point &p, const Point &q) { return Point(p) -= q; }
inline Point operator*(const Point &p, const double k) { return Point(p) *= k; }
inline Point operator/(const Point &p, const double k) { return Point(p) /= k; }

inline Point operator+(const Point &p) { return p; }
inline Point operator-(const Point &p) { return Point(-p.x, -p.y); }

inline constexpr bool operator==(const Point &p, const Point &q) { return eq(p.x, q.x) && eq(p.y, q.y); }
inline constexpr bool operator!=(const Point &p, const Point &q) { return !(p == q); }

inline double norm2(const Point &p) { return p.x * p.x + p.y * p.y; }
inline double norm(const Point &p) { return sqrt(p.x * p.x + p.y * p.y); }
inline double arg(const Point &p) { return atan2(p.y, p.x); }

inline double dot(const Point &p, const Point &q) { return p.x * q.x + p.y * q.y; }
inline double cross(const Point &p, const Point &q) { return p.x * q.y - p.y * q.x; }

istream &operator>>(istream &is, Point &p) { is >> p.x >> p.y; return is; }

//-----直線-----//
struct Line
{
    Point a, b;
    Line(Point a, Point b) : a(a), b(b) {} /* 2点a, bを通る直線 */
};

/* 
 * "射影" (直線 l に点 p から垂線を引いた交点を求める)
 * verified at: https://onlinejudge.u-aizu.ac.jp/courses/library/4/CGL/1/CGL_1_A
 */
Point projection(const Line &l, const Point &p)
{
    Point d = l.b - l.a; // 直線 l の方向ベクトル
    Point h = d * (dot(p - l.a, d) / norm2(d)); // 正射影ベクトル
    return l.a + h;
}

/* 
 * "反射" (直線 l に関して点 p と対称な点を求める)
 */
Point reflection(const Line &l, const Point &p) { return p + (projection(l, p) - p) * 2.0; }


int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);

    Point p1, p2; cin >> p1 >> p2;
    Line l(p1, p2);
    int q; cin >> q;
    while (q--) {
        Point p; cin >> p;
        Point x = reflection(l, p);
        cout << x.x << ' ' << x.y << '\n';
    }
    return 0;
}



Measured memory_bytes: 3296
#include <bits/stdc++.h>
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, srt, end) for (long long i = (srt); i < (long long)(end); i++)
#define VL vector<ll>

ll MOD=1000000007;
ll mod=998244353;
int inf=1000001000;
ll INF=1e18+5;

int main(){
    ll n;
    ll ans=INF; 
    cin >> n;
    VL a(n,0),sum(n+1,0);
    rep(i,0,n){
        cin >> a[i];
        sum[i+1] = sum[i] + a[i];
    }
    
    rep(i,0,n){
        ans = min(abs(sum[i+1]-(sum[n]-sum[i+1])),ans);
    }
    cout << ans << endl;
}


Measured memory_bytes: 3328
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
using namespace std;
int n,a,b,c,d;
string s;
int ch(int i, int j)
{
    for(int x=i;x<j;x++)
        if(s[x]=='#'&&s[x+1]=='#')return 0;
    return 1;
}
int main()
{
        cin>>n>>a>>b>>c>>d>>s;
        //cout<<s;
        a--; b--; c--; d--;
        int g=ch(a,c)*ch(b,d);
        if(c>d){
            int fl=0;
            for(int i = b-1; i<d;i++)
                if(s[i]==s[i+1]&&s[i+1]=='.'&&s[i]==s[i+2])fl=1;
            
                if(fl&&g){
                    cout<<"Yes";return 0;
                }
                else cout<<"No";return 0;
        }
       // cout<<g;
        if(g){cout<<"Yes";}
        else {cout<<"No";}
      return 0;
}


Measured memory_bytes: 640
#include "bits/stdc++.h"

using namespace std;
typedef long long ll;
typedef pair<ll, ll> pii;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef vector<pii> vpii;

struct pair_hash {
  size_t operator() (const pair<int, int> &p) const {
    return hash<int>()(p.first) ^ hash<int>()(p.second);
  }
};

int main() {
  int N, M;
  cin >> N >> M;
  vi a(M), b(M);
  for (int i = 0; i < M; i++) {
    cin >> a[i] >> b[i];
    a[i] -= 1;
    b[i] -= 1;
  }

  vvi G(N);
  for (int i = 0; i < M; i++) {
    G[a[i]].push_back(b[i]);
    G[b[i]].push_back(a[i]);
  }

  vvi d(N, vi(1 << N));
  queue<pair<int, int>> q;
  d[0][1] = 1;
  q.push({0, 1});

  while(q.size()) {
    pair<int, int> from = q.front();
    q.pop();

    for (int to: G[from.first]) {
      if (((1 << to) & from.second) == 0) {
        if (d[to][(1 << to) | from.second] == 0) q.push({to, (1 << to) | from.second});
        d[to][(1 << to) | from.second] += d[from.first][from.second];
      }
    }
  }

  int ans = 0;
  for (int i = 0; i < N; i++) {
    ans += d[i][(1 << N) - 1];
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	static int[][] stones = new int[21][21];
	
	public static void main(String[] args) {
	    Scanner sc = new Scanner(System.in);
	    while(true){
	        int n = sc.nextInt();
	        if(n==0) break;
	        for(int i=0;i<21;i++) {
	        	for(int j=0;j<21;j++) {
	        		stones[i][j] = 0;
	        	}
	        }
	        for(int i=0;i<n;i++){
	        	int a = sc.nextInt();
	        	int b = sc.nextInt();
	        	stones[b][a] = 1;
	        }
	        /*for(int i=0;i<21;i++){
	        	for(int j=0;j<21;j++) {
	        		System.err.print(stones[i][j]);
	        	}
	        	System.err.println();
	        }
	    	System.err.println(); */
	        
	        
	        int m = sc.nextInt();
	        int x = 10;
	        int y = 10;
	        for(int i=0;i<m;i++){
	        	String or1 = sc.next();
	        	int or2 = sc.nextInt();
	        	switch(or1){
	        	case "N":{
	        		for(int j=1;j<=or2;j++) {
	        			stones[y+j][x] = 0;
	        		}
	        		y += or2;
	        		//System.err.println(x+" "+y);
	        		break;
	        	}
	        	case "E":{
	        		for(int j=1;j<=or2;j++) {
	        			stones[y][x+j] = 0;
	        		}
	        		x += or2;
	        		//System.err.println(x+" "+y);
	        		break;
	        	}
	        	case "S":{
	        		for(int j=1;j<=or2;j++) {
	        			stones[y-j][x] = 0;
	        		}
	        		y -= or2;
	        		//System.err.println(x+" "+y);
	        		break;
	        	}
	        	case "W":{
	        		for(int j=1;j<=or2;j++) {
	        			stones[y][x-j] = 0;
	        		}
	        		x -= or2;
	        		//System.err.println(x+" "+y);
	        		break;
	        	}
	        	}
	        }
	        /*for(int i=0;i<21;i++){
	        	for(int j=0;j<21;j++) {
	        		System.err.print(stones[i][j]);
	        	}
	        	System.err.println();
	        }
	    	System.err.println(); */
	        
	        boolean flag = true;
	        for(int i=0;i<21;i++){
	        	for(int j=0;j<21;j++) {
	        		if(stones[i][j]!=0) {
	        			flag = false;
	        		}
	        	}
	        }
	        if(flag == true) {
	        	System.out.println("Yes");
	        }else {
	        	System.out.println("No");
	        }  
	    }
	}
}



Measured memory_bytes: 42668
#include <stdio.h>

int main(void)
{
 int N;
 int i, j, k;
 int v;

 scanf("%d", &N);

 int A[N];
 
 for (i = 1; i < N; i++){
  scanf("%d", &A[i-1]);
  printf("%d ", A[i-1]);
  }
  scanf("%d", &A[N-1]);
  printf("%d\n", A[N-1]);

 for (i = 1; i < N; i++){
  v = A[i];
  j = i -1;
  while (j >= 0 && A[j] > v){
   A[j+1] = A[j];
   j = j--;
   }
  A[j+1] = v;
 
  for (k = 1; k < N; k++){
   printf("%d ", A[k-1]);
   }
  printf("%d\n", A[N-1]);

  }

 return 0;
 
}

Measured memory_bytes: 596
#include<iostream>
#include<string>
using namespace std;
int d[101];
char f(char c,int x){
	if(x==52)return c;
	int dif=x%26;
	if(c>='a'){
		c-=dif;
		if(c<'a'){
			c-=('a'-'Z'-1);
		}
	}
	else{
		c-=dif;
		if(c<'A'){
			c-=('A'-'z'-1);
		}
	}
	if(x/26==1){
		if(c>='a')c-=('a'-'A');
		else c+=('a'-'A');
	}
	return c;
}
int main(){
	int n;
	while(cin>>n && n){
		for(int i=0;i<n;i++){
			cin>>d[i];
		}
		string str;
		cin>>str;
		for(int i=0;i<str.size();i++){
			str[i]=f(str[i],d[i%n]);
		}
		cout<<str<<endl;
	}
}

Measured memory_bytes: 3140
#include<bits/stdc++.h>
#define endl '\n';
using namespace std;
using ll = long long;
using P = pair<int,int>;
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("Ofast")
constexpr ll INF = 9e18;
constexpr int inf = 1e9;
constexpr double INFD = 1e100;
constexpr ll mod = 1000000007;
const double PI = 3.1415926535897932384626433832795028841971;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
// ios::sync_with_stdio(false);
// cin.tie(nullptr);
// ---------------------------------------------------------------------------

int main(){
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  ll t1,t2;
  cin >> t1 >> t2;
  ll A1,A2,B1,B2;
  cin >> A1 >> A2 >> B1 >> B2;
  ll P,Q;
  P = (A1 - B1)*t1;
  Q = (A2 - B2)*t2;
  if(P > 0){
    P *= -1;
    Q *= -1;
  }
  if(P+Q < 0){
    cout << 0 << endl;
  }else if(P+Q == 0){
    cout << "infinity" << endl;
  }else{
    ll ans = P/(P+Q);
    ans *= 2;
    ans *= -1;
    ans += 1;
    if(P%(P+Q) == 0) ans--;
    cout << ans << endl;
  }
  return 0;
}


Measured memory_bytes: 384
//2019.12.29
//DP.
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#define REP(i,n) for(int i=0;i<(n);++i)
#define ALL(v)   (v).begin(),(v).end()
using namespace std;
typedef long long   llong;
typedef vector<int> vi;
typedef vector<vi > vvi;

int main(){
	int n,k;
	int a[3];
	string t;
	
	cin>>n>>k;
	REP(i,3) cin>>a[i];
	cin>>t;
	
	vi v(n);
	char hoge[]="spr";//point!
	REP(i,n){
		REP(j,3) if(t[i]==hoge[j]) v[i]=j;
	}
	
	vvi dp(n,vi(3));
	REP(i,n){
		if(i<k){
			REP(j,3){
				if(j==v[i]) dp[i][j]=a[v[i]];
				else dp[i][j]=0;
			}
		}else{
			REP(j,3){
				int tmp=0;
				REP(l,3) if(l!=j) tmp=max(tmp,dp[i-k][l]);
				
				if(j==v[i]) dp[i][j]=tmp+a[v[i]];
				else dp[i][j]=tmp;
			}
		}
	}
	
	int ans=0;
	for(int i=n-1,j=k;i>=0 and j>0;--i,--j){
		ans+=max({dp[i][0],dp[i][1],dp[i][2]});
	}
	
	cout<<ans<<endl;
}


Measured memory_bytes: 6272
import sys

t1, t2 = map(int, input().split())
a1, a2 = map(int, input().split())
b1, b2 = map(int, input().split())

a = a1 * t1 + a2 * t2
b = b1 * t1 + b2 * t2
ha = a1 * t1
hb = b1 * t1
if a == b or ha == hb:
  print ("infinity")
  sys.exit(0)

if a > b:
  a, b = b, a
  ha, hb = hb, ha

gap = b - a
hgap = ha - hb

if hgap < 0:
  print (0)
  sys.exit(0)

ans = 2 * (hgap // gap) + (1 if hgap % gap > 0 else 0)
print (ans)




Measured memory_bytes: 3064
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <cassert>
#include <iostream>
#include <iomanip>
#include <sstream>
#include <algorithm>
#include <numeric>
#include <complex>
#include <stack>
#include <queue>
#include <list>
#include <set>
#include <map>
#include <bitset>
#include <functional>
#include <iterator>

using namespace std;

#define dump(n) cout<<"# "<<#n<<'='<<(n)<<endl
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define peri(i,a,b) for(int i=int(b);i-->int(a);)
#define rep(i,n) repi(i,0,n)
#define per(i,n) peri(i,0,n)
#define iter(c) __typeof__((c).begin())
#define foreach(i,c) for(iter(c) i=(c).begin();i!=(c).end();++i)
#define all(c) (c).begin(),(c).end()
#define mp make_pair

typedef unsigned int uint;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<string> vs;
typedef pair<int,int> pii;

const int INFTY=1<<29;
const double EPS=1e-9;

template<typename T1,typename T2>
ostream& operator<<(ostream& os,const pair<T1,T2>& p){
	return os<<'('<<p.first<<','<<p.second<<')';
}
template<typename T>
ostream& operator<<(ostream& os,const vector<T>& a){
	os<<'[';
	rep(i,a.size()) os<<(i?" ":"")<<a[i];
	return os<<']';
}

int main()
{
	for(int n,m;cin>>n>>m,n|m;){
		vvi g(n);
		rep(i,m){
			int s,t; cin>>s>>t; s--,t--;
			g[s].push_back(t);
			g[t].push_back(s);
		}
		int initial=0;
		rep(i,n){
			int x; cin>>x;
			initial|=x<<i;
		}
		vvi ss(n);
		rep(i,n){
			int k; cin>>k;
			rep(j,k){
				int x; cin>>x;
				ss[i].push_back(x-1);
			}
			sort(all(ss[i]));
		}
		
		if(!(initial&1)){
			puts("Help me!");
			continue;
		}
		
		vector<vector<pii>> prev(n,vector<pii>(1<<n,mp(-1,-1)));
		prev[0][initial]=mp(-2,-2);
		queue<pii> q; q.emplace(0,initial);
		while(!q.empty()){
			pii cur=q.front(); q.pop();
			int ci=cur.first,cs=cur.second;
			rep(i,ss[ci].size()) if(ss[ci][i]!=ci){
				int ns=cs^1<<ss[ci][i];
				if(prev[ci][ns]==mp(-1,-1)){
					prev[ci][ns]=mp(ci,cs);
					q.emplace(ci,ns);
				}
			}
			for(int ni:g[ci]){
				if((cs&1<<ni) && prev[ni][cs]==mp(-1,-1)){
					prev[ni][cs]=mp(ci,cs);
					q.emplace(ni,cs);
				}
			}
		}
		
		if(prev[n-1][1<<n-1]!=mp(-1,-1)){
			deque<pii> res;
			for(pii x=mp(n-1,1<<n-1);x!=mp(-2,-2);x=prev[x.first][x.second])
				res.push_front(x);
			printf("You can go home in %d steps.\n",res.size()-1);
			repi(i,1,res.size()){
				if(res[i-1].first!=res[i].first)
					printf("Move to room %d.\n",res[i].first+1);
				else{
					int x=__builtin_ctz(res[i-1].second^res[i].second);
					if(res[i].second&1<<x)
						printf("Switch on room %d.\n",x+1);
					else
						printf("Switch off room %d.\n",x+1);
				}
			}
		}
		else if(count(all(prev[n-1]),mp(-1,-1))<(1<<n))
			puts("You can not switch off all lights.");
		else
			puts("Help me!");
	}
	
	return 0;
}

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

#define ff first
#define ss second
#define mp(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define boost ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define track(x) cout << #x << " : " << (x) << endl
#define all(v) v.begin(),v.end() 
#define allr(v) v.rbegin(),v.rend() 
//#define endl '\n'  
typedef  long long ll; 
typedef  unsigned long long ull; 
typedef vector< ll > edge; 
typedef pair< ll , ll > mypair;
typedef priority_queue <ll> max_heap;
typedef priority_queue <ll, vector<ll>, greater<ll> > min_heap;
const ll mod=1000000007;
const ll inf=1e15;
const ll N=1e5+10;



int main()
{
	boost;
	ll n;
	cin>>n;
	std::map<string, set<pair<ll,ll> > > ma;
	for(ll i=1;i<=n;i++)
	{
		string s;
		ll k;
		cin>>s;
		cin>>k;
		ma[s].insert(mp(-k,i));
	}
	for(auto &i:ma)
	{
		for(auto &j :i.ss)
		{
			cout<<j.ss<<endl;
		}
	}
  	return 0;
}

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

namespace ConsoleApp2
{
    class Program
    {
        static void Main(string[] args)
        {
            var K = GetLongNum();
            var S = GetString();

            if (S.Length > K)
            {
                Console.WriteLine(S.Substring(0, (int)K) + "...");
                return;
            }

            Console.WriteLine(S);
        }

        private static long[] GetLongNumArray()
        {
            var input = Console.ReadLine().Split(' ');
            return input.Select(x => long.Parse(x)).ToArray();
        }

        private static long GetLongNum()
        {
            return long.Parse(Console.ReadLine());
        }

        private static string[] GetStringArray()
        {
            return Console.ReadLine().Split(' ');
        }

        private static string GetString()
        {
            return Console.ReadLine();
        }
    }
}


Measured memory_bytes: 27548
using System;
using System.Text;
using System.Linq;
using System.Collections.Generic;

namespace abc042.b
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] inputIntArray = Console.ReadLine().Split(' ').Select(i => int.Parse(i)).ToArray();

            List<string> list = new List<string>();

            for (int c = 0; c < inputIntArray[0]; c++)
            {
                list.Add(Console.ReadLine());
            }
            list.Sort();

            string answer = "";
            foreach (string item in list)
            {
                answer += item;
            }
            Console.WriteLine(answer);
        }
    }
}


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

using namespace std;
using vi = vector<int>;

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define IN(v) int v;cin>>v;
#define OUT(v) cout<<v<<"\n"

const int MAX_N = 1e5+1;

int parent[MAX_N];
int root(int x) {
  if (parent[x] == x)
    return x;
  return parent[x] = root(parent[x]);
}
void unite(int x, int y) {
  if (root(x) == root(y))
    return;
  x = root(x);
  y = root(y);
  parent[x] = y;
  return;
}
bool same(int x, int y) {
  return root(x) == root(y);
}


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

  REP(i, MAX_N) parent[i] = i;

  vi P(N);
  REP(i, N) cin >> P[i];
  REP(i, M) {
    IN(x); IN(y);
    unite(x, y);
  }

  int ans = 0;
  REP(i, N) if (same(i+1, P[i])) ++ans;
  OUT(ans);

  return 0;
}


Measured memory_bytes: 1024
BIG_NUM = 2000000000


N = int(input())
x = 0

for i in range(1,N+1):

    if i%3 == 0:
            print(" %d"%i,end = "");
    else:
        x = i
        while (x):
            if x%10 == 3:
                print(" %d"%i,end = "")
                break
            x //= 10
print()


Measured memory_bytes: 5868
N = gets.chomp.to_i

words = {}
N.times do
  word = gets.chomp.chars.sort.join
  words[word] = words.key?(word) ? words[word] + 1 : 1
end

puts words.values.reduce(0) { |sum, count| count == 2 ? sum + 1 : count == 1 ? sum : sum + count*(count-1)/2 }


Measured memory_bytes: 19708
x,k,d=map(int,input().split())
x=abs(x)

if k%2==0:ans=0 #偶数
else:ans=1 #奇数

semin=x//d #最小に行くための個数
if semin%2==0:minb=0 #最小に行くための個数が偶数
else:minb=1 #最小に行くための個数が奇数

if semin>k:print(abs(x-k*d))
else:
  if ans==minb:
    print(abs(x-d*semin))
  else:
    print(abs((x-(d*semin))-d))

Measured memory_bytes: 8908
import sys, math
def input():
    return sys.stdin.readline()[:-1]
from itertools import permutations, combinations
from collections import defaultdict, Counter
from math import factorial
from bisect import bisect_left # bisect_left(list, value)
#from fractions import gcd
enu = enumerate

sys.setrecursionlimit(10**7)
n, a, b = map(int, input().split())
mod = 10**9 + 7

def cmb(n, r, p):
    r = min(n - r, r)
    if r == 0:
        return 1
    over = 1
    for i in range(n, n - r, -1):
        over = over * i % p
    under = 1
    for i in range(1, r + 1):
        under = under * i % p
    inv = pow(under, p - 2, p)
    return over * inv % p

cnt = pow(2, n, mod)
ng1 = cmb(n, a, mod)
ng2 = cmb(n, b, mod)

res = (cnt - ng1 - ng2 - 1) % mod

print(res)


Measured memory_bytes: 3316
#include <bits/stdc++.h>
using namespace std;
using ll =long long;
using vl=vector<ll>;
using vb=vector<bool>;
using vs=vector<string>;
using vvl=vector<vl>;
using pll=pair<ll,ll>;
const ll oo =0x3f3f3f3f3f3f3f3fLL;
const double eps=1e-9;
#define sz(c) ll((c).size())
#define all(c) begin(c),end(c)
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define eb emplace_back
#define xx first
#define yy second
#define FOR(i,a,b) for(ll i=(a); i<(b); i++)
#define FORD(i,a,b) for(ll i=ll(b)-1;i>=(a);i--)
#define TR(X) ({if(1) cerr << "TR: " << (#X) << " = " << (X) << endl; })
int main(){ cin.sync_with_stdio(0);
        ll N; cin >> N;

        vvl adj(N, vl(N));
        FOR(i, 0, N) FOR(j, 0, N) cin >> adj[i][j];

        ll ans = 0;
        FOR(a, 0, N) FOR(b, a+1, N) {
                bool needed = true;
                FOR(c, 0, N) {
                        if (a == c || b == c) continue;

                        if (adj[a][c] + adj[c][b] < adj[a][b]) {
                                cout << -1 << endl;
                                return 0;
                        } else if (adj[a][c] + adj[c][b] == adj[a][b]) {
                                needed = false;
                        }
                }
                if (needed) ans += adj[a][b];
        }
        cout << ans << endl;
} //cin.tie(0) bei schnellem Wechseln


Measured memory_bytes: 1152
import java.util.*
import java.math.*
import kotlin.math.*

fun readLn()=readLine()!!
fun readInt()=readLn().toInt()
fun readInts()=readLn().split(" ").map{it.toInt()}
fun readLong()=readLn().toLong()
fun readLongs()=readLn().split(" ").map{it.toLong()}

val out=mutableListOf<String>()
fun printLine(s:String){out.add(s)}
fun output(){println(out.joinToString("\n"))}

fun main(){
    val t=1
    repeat(t){
        var k=readInt()
        var (a,b)=readInts()
        var ans=true
        if((a-1)/k==b/k)ans=false
        if(ans)printLine("OK")
        else printLine("NG")
    }
    output()
}

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

#define ll long long int
#define mp make_pair
#define ff first
#define ss second
#define fr(i,l,r) for (long long int i = l; i < r; ++i)
#define frr(i,l,r) for (long long int i = r; i >= l; --i) 
#define sortarr sort(arr,arr+n) //sorts array in asc order
#define sortarr_r sort(arr, arr+n, greater<long long int>()) //sorts array in desc order
#define make_set set<long long int>s //Set arranges in asc order
#define make_set_r set<long long int, greater <long long int>>s ////Set arranges in desc order
#define make_vector vector<long long int>v; 
#define pb push_back


// string size = str.size()

// stack <int> s; 
// queue <int> gquiz; 
// __gcd(m, n) 

// ll arr[10e5 + 5];
// char arr[10e5 + 5];


bool compare(string &s1,string &s2) 
{ 
    return s1.size() < s2.size(); 
} 
void yes()
{
    cout << "YES" << endl;
}
void no()
{
    cout << "NO" << endl;
}


int main(void)
{
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    ll n,k;
    cin >> n >> k;
    ll freq[107] = {0};
    ll d,x;
    for (ll i = 1; i<=k; i++)
    {
        cin >> d;
        for(ll i = 1; i<=d; i++)
        {
            cin >> x;
            freq[x] ++;
        } 
    }
    ll c = 0;
    for(ll i = 1; i<=n; i++)
    {
        if(freq[i] == 0)
        {
            ++c;
        }
    }
    cout << c << endl;
    return 0;
}   

Measured memory_bytes: 3560
#include <bits/stdc++.h>
using namespace std;
 
int main()
{
int n;
cin >> n;
int a[n+1],cnt=0;
for (int i=1; i<=n;++i) cin >> a[i];
for (int i=1;i<=n;++i)
{
if (a[a[i]] == i) ++cnt;
}
cout << cnt/2 << endl;
return 0;
}

Measured memory_bytes: 640
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            var swr = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(swr);
            var n = int.Parse(Console.ReadLine());
            var a = new int[n];
            for (int i = 0; i < n; i++)
            {
                a[i] = int.Parse(Console.ReadLine());
            }

            int[] aa = a.OrderByDescending(x => x).ToArray();

            for (int i = 0; i < n; i++)
            {
                if(aa[0]==a[i])
                {
                    Console.WriteLine(aa[1]);
                }
                else
                {
                    Console.WriteLine(aa[0]);
                }
            }
            Console.Out.Flush();
        }
    }
}

Measured memory_bytes: 22484
#include<stdio.h>

int main(void){

int A,B;
scanf("%d %d",&A,&B);
if(A>=13){
  B = B;}
  else if(13>A&&A>=6){
  B = B/2;
    }
    else{
      B = 0;
    }

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

}


Measured memory_bytes: 128
import java.util.*;
import java.io.*;

public class Main{
	final static int MOD = 1000000007;
	final static int INF = 1000000000;

	
	
	static int n, k;
	static int[] w;
	public static void main(String[] args) throws IOException{
		NScanner sc = new NScanner(System.in);
		n = sc.nextInt(); k = sc.nextInt();
		int maxw = 0;
		w = new int[n];
		for(int i = 0; i < n; ++i){
			w[i] = sc.nextInt(); maxw = Math.max(maxw, w[i]);
		}
		long lt = 0, rt = (long)maxw * n;
		while(rt > lt + 1){//最後はlt:できないギリギリ rt: ギリギリ積める
	        long mid = (lt+rt)/2;
	        int pos = checknum(mid);
	        if(pos >= n) rt = mid;
	        else lt = mid;
	    }
		System.out.println(rt);
	}
	
	static int checknum(long P){
		int i = 0;
		for(int j = 0; j < k; ++j){
			long s = 0;
			while(s + w[i] <= P){
				s += w[i];
				++i;
				if(i == n) return n;
			}
		}
		return i;
	}

}


class NScanner{

	private BufferedReader br;
	private StringTokenizer tok;

	public NScanner(InputStream is) throws IOException{
		br = new BufferedReader(new InputStreamReader(is));
		getLine();
	}

	private void getLine() throws IOException{
		while(tok == null || !hasNext()){
			tok = new StringTokenizer(br.readLine());
		}
	}

	public boolean hasNext(){
		return tok.hasMoreTokens();
	}

	public String next() throws IOException{
		if(hasNext()){
			return tok.nextToken();
		}else{
			getLine();
			return tok.nextToken();
		}
	}

	public int nextInt() throws IOException{
		if(hasNext()){
			return Integer.parseInt(tok.nextToken());
		}else{
			getLine();
			return Integer.parseInt(tok.nextToken());
		}
	}

	public long nextLong() throws IOException{
		if(hasNext()){
			return Long.parseLong(tok.nextToken());
		}else{
			getLine();
			return Long.parseLong(tok.nextToken());
		}
	}

	public double nextDouble() throws IOException{
		if(hasNext()){
			return Double.parseDouble(tok.nextToken());
		}else{
			getLine();
			return Double.parseDouble(tok.nextToken());
		}
	}
}


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

using namespace std;

#define FOR(i, N) for (int i = 0; i < (int)N; i++)
#define FORIN(i, a, b) for (int i = a; i < (int)b; i++)
#define ALL(x) (x).begin(), (x).end()
#define MOD 1000000007
#define INF (1 << 29)
#define LLINF (1LL << 60)
#define DEBUG(...) debug(__LINE__, ":" __VA_ARGS__)

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

string to_string(string s) { return s; }
template <class S>
string to_string(unordered_set<S> s);
template <class S>
string to_string(set<S> s);
template <class S, class T>
string to_string(map<S, T> m);
template <class T>
string to_string(vector<T> v);

template <class S, class T>
string to_string(pair<S, T> p) {
  return "{" + to_string(p.first) + "," + to_string(p.second) + "}";
}

template <class S>
string to_string(unordered_set<S> s) {
  string ret = "{";
  for (S x : s) ret += to_string(x) + ",";
  return ret + "}";
}

template <class S>
string to_string(set<S> s) {
  string ret = "{";
  for (S x : s) ret += to_string(x) + ",";
  return ret + "}";
}

template <class S, class T>
string to_string(map<S, T> m) {
  string ret = "{";
  for (pair<S, T> x : m) ret += to_string(x) + ",";
  return ret + "}";
}

template <class T>
string to_string(vector<T> v) {
  string ret = "{";
  for (int i = 0; i < (int)v.size() - 1; ++i) {
    ret += to_string(v[i]) + ",";
  }
  if (v.size() > 0) {
    ret += to_string(v.back());
  }
  ret += "}";
  return ret;
}

void debug() { cerr << endl; }

template <class Head, class... Tail>
void debug(Head head, Tail... tail) {
  cerr << to_string(head) << " ";
  debug(tail...);
}

void print() { cout << endl; }

template <class Head, class... Tail>
void print(Head head, Tail... tail) {
  cout << to_string(head);
  print(tail...);
}

int main() {
  cin.tie(0);
  int N;
  cin >> N;
  string S;
  cin >> S;
  for (char c : S) {
    cout << (char)((c - 'A' + N) % 26 + 'A');
  }
  cout << endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<(n);++i)
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
int gcd(int a,int b) { return b ? gcd(b,a%b) : a;}
int lcm(int a,int b) { return a/gcd(a,b)*b;}
void printb(unsigned int v) {
  unsigned int mask = (int)1 << (sizeof(v) * CHAR_BIT - 1);
  do putchar(mask & v ? '1' : '0');
  while (mask >>= 1);
}
void putb(unsigned int v) {putchar('0'), putchar('b'), printb(v), putchar('\n');}
#define ALL(W) (W).begin(),(W).end()

signed main(){
  int A,B,K;
  cin >> A >> B >> K;
  int i=min(A,B),c=0;
  while(1){
    if(A%i==0 && B%i==0) c++;
    if(c==K){
      cout << i << endl;
      return 0;
    }
    i--;
  }
  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

  public static void main(String[] args) {

    Scanner sc = new Scanner(System.in);

    int A = Integer.parseInt(sc.next());
    int B = Integer.parseInt(sc.next());
    int C = Integer.parseInt(sc.next());

    long ans = 0;
    if(A+B>=C-1) {
      ans = B+C;
    }else  {
      ans = 2*B+A+1;
    }

    System.out.println(ans);
  }
}

Measured memory_bytes: 23764
#include<stdio.h>


int main(){
	long long n,t,beftn=0,output=0,nokori=0,tn=0;
	scanf("%lld %lld",&n,&t);
	for(int i=0;i<n;i++){
		beftn=tn;
		scanf("%lld",&tn);
		if(i>0&&t>=tn-beftn){
			output+=(tn-beftn);	
		}
		else if(i>0&&t<tn-beftn){
			output+=t;
		}
	}
	output+=t;
	printf("%d",output);
	return 0;
}

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

typedef long long int ll;
typedef string str;

int main ()
{
	// ios::sync_with_stdio(0);
 //    cin.tie(0);
 //    cout.tie(0);
	ll t,n,m,k,i,a,b,j;
	ll h[100004]={0};
	cin >> n;
	b=0;
	for(i=0;i<n;i++)
	{
		cin >> a;
		h[a]++;
		b+=a;
	}
	cin >> t;
	while(t--)
	{
		cin >> m >> k;
		b+= h[m]*(k-m);
		h[k]+=h[m];
		h[m]=0;
		cout << b << "\n";
	}
	return 0;
}

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

int main(){
    string s,s1 = "ACGT";
    getline(cin,s);
    int max = 0,cnt, i = 0;
    while(i<s.length()){
        cnt = 0;
        int j = i;
        while(j<s.length() && (int)s1.find(s[j]) != -1){
            j++;
            cnt++;
        }
        i = (i == j) ? i+1 : j;
        max = (cnt>max)? cnt : max;
    }
    cout<<max;
    return 0;
}

Measured memory_bytes: 3576
read N M C
read -a B
ANS=0

for ((j=0; j<N; j++)); do
    read -a A
    SUM=$C
    for ((i=0; i<M; i++)); do
        ((SUM+=A[i]*B[i]))
    done
    if ((SUM > 0 )); then
        ((ANS++))
    fi
done

echo $ANS


Measured memory_bytes: 376
# ANSHUL GAUTAM
# IIIT-D

from math import *
from copy import *
from string import *				# alpha = ascii_lowercase
from random import *				# l.sort(key=lambda l1:l1[0]-l1[1]) => ex: sort on the basis difference
from sys import stdin
from sys import maxsize
from operator import *				# d = sorted(d.items(), key=itemgetter(1))
from itertools import *
from collections import Counter		# d = dict(Counter(l))
from collections import defaultdict # d = defaultdict(list)

'''
6
30 10 60 10 60 50
'''

def solve(l):
	n = len(l)
	dp = [0]*n
	dp[1] = abs(l[0] - l[1])
	for i in range(2,n):
		dp[i] = min(dp[i-1] + abs(l[i]-l[i-1]) , abs(dp[i-2] + abs(l[i]-l[i-2])))
	return dp[-1]
	

N = int(stdin.readline())
l = list(map(int, stdin.readline().rstrip().split()))
ans = solve(l)
print(ans)


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

typedef long long   signed int LL;
typedef long long unsigned int LU;

#define incID(i, l, r) for(int i = (l)    ; i <  (r); i++)
#define incII(i, l, r) for(int i = (l)    ; i <= (r); i++)
#define decID(i, l, r) for(int i = (r) - 1; i >= (l); i--)
#define decII(i, l, r) for(int i = (r)    ; i >= (l); i--)
#define  inc(i, n) incID(i, 0, n)
#define inc1(i, n) incII(i, 1, n)
#define  dec(i, n) decID(i, 0, n)
#define dec1(i, n) decII(i, 1, n)

#define inII(v, l, r) ((l) <= (v) && (v) <= (r))
#define inID(v, l, r) ((l) <= (v) && (v) <  (r))

#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define PQ priority_queue

#define  ALL(v)  v.begin(),  v.end()
#define RALL(v) v.rbegin(), v.rend()
#define  FOR(it, v) for(auto it =  v.begin(); it !=  v.end(); ++it)
#define RFOR(it, v) for(auto it = v.rbegin(); it != v.rend(); ++it)

template<typename T> bool   setmin(T & a, T b) { if(b <  a) { a = b; return true; } else { return false; } }
template<typename T> bool   setmax(T & a, T b) { if(b >  a) { a = b; return true; } else { return false; } }
template<typename T> bool setmineq(T & a, T b) { if(b <= a) { a = b; return true; } else { return false; } }
template<typename T> bool setmaxeq(T & a, T b) { if(b >= a) { a = b; return true; } else { return false; } }
template<typename T> T gcd(T a, T b) { return (b == 0 ? a : gcd(b, a % b)); }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }

// ---- ----

int n, a, b, ans[200000];
string s;

void no() {
	cout << "No" << endl;
	exit(0);
}

int cnt = 1;
void paint(int x, int y) {
	x %= 2 * n;
	y %= 2 * n;
	assert((ans[x] == 0) == (ans[y] == 0));
	if(ans[x] != 0) { return; }
	ans[x] = cnt;
	ans[y] = cnt;
	cnt++;
}

int main() {
	cin >> n >> s;
	assert(s.size() == 2 * n - 1);
	
	s = "1" + s + "1" + s;
	
	inc(i, 2 * n) {
		if(s.substr(i, 2) == "11") { a++; }
		if(s.substr(i, 2) == "10") { b++; }
	}
	if(a % 2 != 0) { no(); }
	
	if(a % 4 != 0 && b == 0) { no(); }
	
	if(b == 0) {
		assert(a % 4 == 0);
		inc(i, a / 4) {
			paint(i * 4 + 0, i * 4 + 2);
			paint(i * 4 + 1, i * 4 + 3);
		}
	} else {
		int p = 0;
		inc(i, 2 * n) {
			if(s.substr(i, 2) == "10") { p = i; break; }
		}
		
		vector<pair<int, int>> v[2];
		int x = -1;
		incID(i, p, p + 2 * n) {
			if(s.substr(i, 2) == "10") { x = i; }
			if(s.substr(i, 2) == "01") { v[s.substr(i + 1, 2) == "11" ? 1 : 0].EB(x, i); }
		}
		
		if(a % 4 != 0) {
			if(v[1].size() < 2) { no(); }
			paint(v[1][0].FI,     v[1][1].SE);
			paint(v[1][0].SE,     v[1][1].FI);
			paint(v[1][0].SE + 1, v[1][1].SE + 1);
		}
		
		inc(k, 2) {
		inc(i, v[k].size()) {
			paint(v[k][i].FI, v[k][i].SE);
		}
		}
		
		vector<int> w;
		incID(i, p, p + 2 * n) { if(s.substr(i, 2) == "11" && ans[i % (2 * n)] == 0) { w.PB(i); } }
		incID(i, p, p + 2 * n) { if(s.substr(i, 2) == "00") { w.PB(i); } }
		inc(i, w.size() / 4) { swap(w[i * 4 + 1], w[i * 4 + 2]); }
		
		inc(i, w.size() / 2) { paint(w[i * 2], w[i * 2 + 1]); }
	}
	
	cout << "Yes" << endl;
	inc(i, 2 * n) { cout << (i == 0 ? "" : " ") << ans[i]; }
	cout << endl;
	
	return 0;
}


Measured memory_bytes: 3120
#include<iostream>
#include<vector>
#include<string>
#include<bitset>
#include<algorithm>
#include<map>
#include<queue>
#include<cmath>
#include<set>
#define rep(i,n) for(int i=0;i<n;i++)

using namespace std;

int main() {
	long long a;
	double b;
	cin >> a >> b;
	b = b * 100 + 0.5;
	long long b_dash = b;
	cout << (a * b_dash) / 100 << endl;
	return 0;
}

Measured memory_bytes: 3728
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        n: i32,
        x: i32,
        l: [i32; n]
    }
    let mut p = 0;
    let mut ans = 0;
    for v in l {
        p += v;
        if p <= x {
            ans += 1;
        }
    }
    println!("{}", ans + 1);
}

Measured memory_bytes: 4352
#include <iostream>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <iomanip>
#include <functional>
using namespace std;
#define int long long
#define All(v) (v).begin(),(v).end()
int dy[4] = {-1,0,1,0};
int dx[4] = {0,1,0,-1};
int Dy[8] = {-1,-1,0,1,1,1,0,-1};
int Dx[8] = {0,1,1,1,0,-1,-1,-1};
const int mod = 1000000007;
const int inf = mod*mod;
const int d5 = 100100;
set<int> ass;
void divisor(int n){
    for(int i=1;i*i<=n;i++){
        if(n%i==0){
            ass.insert(i);
            ass.insert(n/i);
        }
    }
}
signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n,m;
    cin>>n>>m;
    divisor(m);
    vector<int> v;
    for(auto it:ass)v.push_back(it);
    sort(All(v),greater<int>());
    for(auto it:v){
        if(it*n<=m){
            cout<<it<<endl;
            return 0;
        }
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> ii;
typedef vector<vi> vvi;
typedef vector<ii> vii;
typedef set<int> si;
typedef map<string, int> msi;
typedef long long ll;

int main()
{
  int a, b, c;
  cin >> a >> b >> c;
  puts(a + b + c >= 22 ? "bust" : "win");
  return 0;
}

Measured memory_bytes: 256