akhauriyash/Code-Regression huggingface dataset:
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric;

int[10^^5*2] BS, WS;

void main()
{
    auto N = readln.chomp.to!int;
    auto S = readln.chomp;
    foreach (i, c; S) {
        if (i) {
            BS[i] = BS[i-1];
            WS[i] = WS[i-1];
        }
        if (c == '#') {
            ++BS[i];
        } else {
            ++WS[i];
        }
    }
    int r = int.max;
    foreach (i; 0..N+1) {
        auto s = WS[N-1];
        if (i) {
            s -= WS[i-1];
            s += BS[i-1];
        }
        r = min(r, s);
    }
    writeln(r);
}

Measured memory_bytes: 4092
fun main(args: Array<String>) {
    nikkei2019qual_a()
}

fun nikkei2019qual_a() {
    val (n, a, b) = readLine()!!.split(' ').map { it.toInt() }

    val answer = "${Math.min(a, b)} ${Math.max(0, a + b - n)}"

    println(answer)
}


Measured memory_bytes: 36304
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func main() {
	scanInit()

	s := nextStr()

	idxA := -1
	idxZ := -1
	for i := 0; i < len(s); i++ {
		if s[i] == 'Z' {
			idxZ = i
		}
		if s[len(s)-i-1] == 'A' {
			idxA = len(s) - i - 2
		}
	}

	fmt.Println(idxZ - idxA)

}

// ---- readfunc
func scanInit() {
	const cap = 200 * 1024 // Default=64
	var buf = make([]byte, cap)
	sc.Buffer(buf, cap)
	sc.Split(bufio.ScanWords)
	return
}
func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}
func nextStr() string {
	sc.Scan()
	return sc.Text()
}


Measured memory_bytes: 2176
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		// 入力
		int H = sc.nextInt();                
		int W = sc.nextInt();                
		
		int[][] s = new int[H][W];
		for (int i = 0; i < H; i++) {
			String str = sc.next(); 
			for (int j = 0; j < W; j++) {
				s[i][j] = str.substring(j,j+1).equals(".") ? 0 : 1;
			}
		}
		
		boolean ans = false;
		for (int i = 0; i < H; i++) {
			for (int j = 0; j < W; j++) {
				if (s[i][j] == 1) {
					if (i == 0) {
						if (j == 0) {
							if (!(s[i+1][j] == 1 || s[i][j+1] == 1)) {
								ans = true;
							}													
						} else if (j == W-1) {
							if (!(s[i+1][j] == 1 || s[i][j-1] == 1)) {
								ans = true;
							}
						} else {
							if (!(s[i+1][j] == 1 
									|| s[i][j-1] == 1 || s[i][j+1] == 1)) {
								ans = true;
							}						
						}
					} else if (i == H-1) {
						if (j == 0) {
							if (!(s[i-1][j] == 1 || s[i][j+1] == 1)) {
								ans = true;
							}													
						} else if (j == W-1) {
							if (!(s[i-1][j] == 1 || s[i][j-1] == 1)) {
								ans = true;
							}
						} else {
							if (!(s[i-1][j] == 1 
									|| s[i][j-1] == 1 || s[i][j+1] == 1)) {
								ans = true;
							}						
						}
					} else {
						if (j == 0) {
							if (!(s[i-1][j] == 1 || s[i][j+1] == 1
									|| s[i+1][j] == 1)) {
								ans = true;
							}													
						} else if (j == W-1) {
							if (!(s[i-1][j] == 1 || s[i][j-1] == 1
									|| s[i+1][j] == 1)) {
								ans = true;
							}													
						} else {
							if (!(s[i-1][j] == 1 || s[i][j-1] == 1
									|| s[i][j+1] == 1 || s[i+1][j] == 1)) {
								ans = true;
							}													
						}
					}
				}
			}
		}
		if(ans){
			System.out.println("No");			
		} else {
			System.out.println("Yes");			
		}
	}	
}


Measured memory_bytes: 21972
#include<bits/stdc++.h>
using namespace std;
const long long md=1e9+7;
const int maxn=110;
long long fac[maxn],inv[maxn];
long long powd(long long x,long long y){
	long long res=1;
	while(y){
		if(y&1) res=res*x%md;
		x=x*x%md;
		y>>=1;
	}
	return res;
}
long long dp[maxn][maxn];
void Add(long long &x,long long y){
	(x+=y)%=md;
}
void csh(){
	fac[0]=1;
	for(int i=1;i<=50;i++)
		fac[i]=fac[i-1]*i%md;
	inv[50]=powd(fac[50],md-2);
	for(int i=50;i>=1;i--)
		inv[i-1]=inv[i]*i%md;
}
int main(){
	csh();
	dp[1][50]=1,dp[1][49]=1;
	for(int i=1;i<=50;i++){
		for(int j=0;j<=100;j++){
			if(!dp[i][j]) continue;
			for(int k=0;k<=50;k++){
				for(int l=0;l+k+i<=50;l++){
					if(k+l==0) continue;
					if((j+k-l)%2==0&&(j+k+l>=50&&j-k-l<=50))
						Add(dp[i+k+l][(j+k-l-50)/2+50],dp[i][j]*inv[k]%md*inv[l]%md);
				}
			}
		}
	}
	int n;
	scanf("%d",&n);
	printf("%lld\n",dp[n][50]*fac[n]%md);
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int Q = 998244353;
const int N = 209;
ll x[N], y[N], p[N], f[N], size[N];
inline int read() {
    int s = 1, a = 0; char ch = getchar();
    while (ch < '0' || ch > '9') {if (ch == '-') s = -1; ch = getchar();}
    while (ch >= '0' && ch <= '9') {a = a * 10 + ch - '0'; ch = getchar();}
    return s * a;
}
inline int gcd(int a, int b) {
    return b == 0 ? a : gcd(b, a % b);
}
inline int findSet(int x) {
    return f[x] == x ? x : f[x] = findSet(f[x]);
}
inline void unionSet(int x, int y) {
    int fx = findSet(x), fy = findSet(y);
    if (fx != fy) {
        f[fy] = fx;
        size[fx] += size[fy];
    }
}
struct Seg {
    int p, q; ll hash;
    bool operator < (const Seg &rhs) const {
        return hash < rhs.hash;
    }
};
vector<Seg> seg;
int main() {
    p[0] = 1;
    for (int i = 1; i < N; i++) {
        p[i] = p[i - 1] << 1, p[i] %= Q;
    }
    int n = read();
    for (int i = 1; i <= n; i++) {
        x[i] = read(), y[i] = read();
    }
    ll res = (p[n] - n - 1) % Q;
    for (int i = 1; i < n; i++) {
        for (int j = i + 1; j <= n; j++) {
            int dx = x[i] - x[j], dy = y[i] - y[j], g = gcd(dx, dy);
            dx /= g, dy /= g;
            if (dx == 0) dy = 1;
            if (dy == 0) dx = 1;
            if (dx < 0) dx *= -1, dy *= -1;
            Seg s; s.p = i, s.q = j, s.hash = dx * 100000 + dy;
            seg.push_back(s);
        }
    }
    sort(seg.begin(), seg.end());
    for (int i = 0, j = 0; i < seg.size(); i = j) {
        for (int k = 1; k <= n; k++) {
            f[k] = k, size[k] = 1;
        }
        for (; j < seg.size() && seg[i].hash == seg[j].hash; j++) {
            unionSet(seg[j].p, seg[j].q);
        }
        for (int k = 1; k <= n; k++) {
            if (f[k] == k && size[k] >= 2) {
                res -= (p[ size[k] ] - size[k] - 1), res += Q, res %= Q;
            }
        }
    }
    printf("%lld\n", res);
    return 0;
}

Measured memory_bytes: 892
#include <iostream>
#include <cstdio>
#include <algorithm>
using namespace std;
int main()
{
	char sh[10];
	int f=0;
	scanf("%s",sh);
	for(int i=1;sh[i]!='\0';i++)
	if(sh[i]=='C'&&sh[i-1]=='A')
	{
		f=1;break;
	}
	if(f)printf("Yes\n");
	else printf("No\n");
	return 0;
}

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

int main() {
    int N; string S;
    cin >> N >> S;
    long long r = 0, g = 0, b = 0;
    for (auto c : S) {
        if (c == 'R') ++r;
        else if (c == 'G') ++g;
        else ++b;
    }
    long long all = r * g * b;
    long long sub = 0;
    for (int i = 0; i < N; ++i) {
        for (int j = i+1; j < N; ++j) {
            if (S[i] == S[j]) continue;
            int k = j*2-i;
            if (k >= N || S[k] == S[i] || S[k] == S[j]) continue;
            ++sub;
        }
    }
    cout << all - sub << endl;
}

Measured memory_bytes: 3596
#include<bits/stdc++.h>
#define rep(i,n)for(int i=0;i<n;++i)
#include<string>
#include<vector>
using namespace std;
typedef long long ll;
typedef pair<int, int>P;
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; }
//max=({});
//条件式が真ならwhileの中身を回し続ける
//printf("%d\n", ans);

//pairの入力
//vector<pair<ll, ll>>work(n);
//rep(i, n) {
//	ll a, b;
//	cin >> a >> b;
//	work[i] = make_pair(a, b);
//for(auto p:mp)(mapの探索)
//printf("%.10f\n",なんちゃら)

int g[15][15];
const int INF = 1001001001;
const int dx[4] = { -1,0,1,0 };
const int dy[4] = { 0,-1,0,1 };

//最大公約数
ll gcd(ll x, ll y) {
	return y ? gcd(y, x % y) : x;
}

ll lcm(ll x, ll y) {
	if (x == 0 || y == 0)return 0;
	return (x / gcd(x, y) * y);
}

//素因数分解
vector<pair<ll, int>>factorize(ll n) {
	vector<pair<ll, int>>res;
	for (ll i = 2;i * i <= n;++i) {
		if (n % i)continue;
		res.emplace_back(i, 0);
		while (n % i == 0) {
			n /= i;
			res.back().second++;
		}
	}
	if (n != 1)res.emplace_back(n, 1);
	return res;
}

int bingo[3][3];
bool flag[3][3];
int cnt[2][105];
int h, w;
int choco[1010][1010];
int s[11][11];

int main() {
	int x, y, z;
	cin >> x >> y >> z;
	int ans = (x - z) / (y + z);
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <vector>
using std::vector;

int min(int a, int b){return (a<b)?a:b;}
int abs(int x){return (x>0)?x:-x;}

int N, M;
int count[2];
vector<int> pos[2];
vector<int> am[2];

int main(){
    scanf("%d %d", &N, &M);
    for(int i=1;i<=N;i++){
        int an;
        scanf("%d", &an);
        pos[an].push_back(i);
    }
    int j=1;
    for(int i=1;i<=M;i++){
        int m;
        scanf("%d", &m);
        for(int k=1;k<=m;k++){
            am[(i%2)].push_back(j);
            j++;
        }
    }
    int diff = 100;
    if(pos[0].size()==am[0].size()){
        int tmp = 0;
        for(int i=0;i<pos[0].size();i++){
            tmp += abs( pos[0][i] - am[0][i] );
        }
        diff = min(diff, tmp);
    }
    if(pos[0].size()==am[1].size()){
        int tmp = 0;
        for(int i=0;i<pos[0].size();i++){
            tmp += abs( pos[0][i] - am[1][i] );
        }
        diff = min(diff, tmp);
    }
    printf("%d\n", diff);
    return 0;
}

Measured memory_bytes: 1056
import sys
N=int(raw_input())
S=[]
for n in xrange(2):
    S.append(raw_input().strip())

M=1000000007
if N==1:
    cnt = 3
else:
    if S[0][0]==S[1][0]:
        cnt = 3
        i=1
        ant=1
    else:
        cnt = 6
        i = 2
        ant = 0
    while i<N:
        if S[0][i]==S[1][i]:
            if ant==1:
                cnt = (cnt +cnt)%M
            else:
                ant=1
            i += 1
        else:
            if ant==0:
                cnt = (cnt *3)%M
            else:
                cnt = (cnt + cnt)%M
                ant = 0
            i += 2
print cnt

Measured memory_bytes: 2696
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define f(i,a,b) for(int i=a;i<b;i++)
#define fin for(int i=0;i<n;i++)
#define pi pair<int,int>
#define pb push_back
#define mp make_pair
#define endl '\n'

void solve(){
   int n;
   cin>>n;
   map<pi,int>m;
   int smin = 1e9,smax = INT_MIN,amin = 1e9,amax = INT_MIN;
   f(i,0,n){
       int x,y;
       cin>>x>>y;
       if(m.count({x,y})<=0){
           m[{x,y}]++;
           amax = max(amax,x+y);
           amin = min(amin,x+y);
           smax = max(smax,x-y);
           smin = min(smin,x-y);
       }
   }
   int ans = INT_MIN;
   ans = max(ans,amax-amin);
   ans = max(ans,smax-smin);
   cout<<ans;

}

signed main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    int t = 1;
    while(t--) solve();
}


Measured memory_bytes: 16100
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <queue>
#include <map>
#include <numeric>
#include <unordered_map>
#include <iomanip>
#include <functional>
#include <bitset>
#include <complex>
#include <stack>



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

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

typedef long long ll;

using namespace std;


int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  int a,b,c,d,e,f;
  cin>>a>>b>>c>>d>>e>>f;
  vector<int>dp(3050);
  dp[0]=1;
  rep(i,3000)
  {
    if(dp[i]==1)
    {
      dp[i+c]=1;
      dp[i+d]=1;
    }
  }
  vector<int>can;
  rep(i,3010)
  {
    if(dp[i])can.push_back(i);
  }
  dp.clear();
  dp.resize(100,0);
  dp[0]=1;
  rep(i,30)
  {
    if(dp[i]==1)
    {
      dp[i+a]=1;
      dp[i+b]=1;
    }
  }
  vector<int>can2;
  rep(i,35)
  {
    if(dp[i])can2.push_back(i);
  }
  int res[2]={a*100,0};
  double de=0;
  for(auto i:can2)
  {
    int ma=min(e*i,max(0,f-i*100));
    auto itr=upper_bound(all(can),ma);
    if(itr==can.begin())continue;
    itr--;
    if(chmax(de,(double)(*itr)/((*itr)+i*100)))
    {
      res[0]=i*100+(*itr);
      res[1]=(*itr);
    }
  }
  cout<<res[0]<<" "<<res[1]<<endl;

  return 0;

}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cmath>
#include<vector>
#include<queue>
#include<map>
#include<algorithm>
#include<complex>
#include<string>
#include<cstring>

using namespace std;
#define rep2(x,from,to) for(int x=(from);(x)<(to);(x)++)
#define rep(x,to) rep2(x,0,to)
#define INF 100000000
#define all(x) x.begin(),x.end()
typedef pair<int,int> P;
typedef pair<int,P> PP;
int m,a,b;
int ans_sa;
int ans;
vector<int> stu;
int main()
{
	while(1)
	{
		stu.clear();
		int input;
		cin>>m>>a>>b;
		if(m==0)break;
		rep(i,m)
		{
			cin>>input;
			stu.push_back(input);
		}
		sort(all(stu),greater<int>());
		ans_sa=-1;
		for(int i=a-1;i<b;i++)
		{
			if(stu[i]-stu[i+1]>=ans_sa)
			{
				ans_sa=stu[i]-stu[i+1];
				ans=i+1;
			}
		}
		cout<<ans<<endl;
	}
	return 0;
}

Measured memory_bytes: 1224
#include <bits/stdc++.h>
#include <boost/range/algorithm.hpp>
#include <boost/range/numeric.hpp>
#include <boost/integer/common_factor.hpp>
#include <boost/integer/common_factor_rt.hpp>
#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/multiprecision/cpp_int.hpp>

using std::string;
using std::vector;
using std::set;
using std::multiset;
using std::unordered_set;
using std::map;
using std::multimap;
using std::unordered_map;
using std::pair;
using std::cin;
using std::cout;

using boost::multiprecision::cpp_int;
using cpp_dec_float_1000 = boost::multiprecision::number<boost::multiprecision::cpp_dec_float<1000, boost::int128_type>>;

typedef uintmax_t    ull;
typedef intmax_t     ll;
typedef uint64_t     ul;
typedef uint32_t     ui;
typedef uint8_t      uc;

constexpr char CRLF  = '\n';
constexpr char SPACE = ' ';
constexpr char VECTOR_COUT_SEPARATOR = SPACE;
constexpr ll INF = 1000'000'007;
constexpr int MOD = 1000'000'007;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> std::ostream& operator<< (std::ostream& os, const std::vector<T>& vc) { for(auto it = vc.begin(); it != vc.end(); ++it) { if (std::next(it) == vc.end()) os << *it; else os << *it << VECTOR_COUT_SEPARATOR; } return os; }
template<class T1, class T2> inline std::ostream & operator<< (std::ostream & os, const std::pair<T1, T2> & p) { return os << p.first << ' ' << p.second; }
template<class T> T modinv(T a, T m) { T b = m, u = 1, v = 0; while (b) { T t = a / b; a -= t * b; boost::swap(a, b); u -= t * v; boost::swap(u, v); } u %= m; if (u < 0) u += m; return u; }
template<class T> inline bool isSosuu(const T& n) { if (n == T(1)) { return false; } for (T i = 2; i*i <= n; ++i) { if (n % i == 0) { return false; } } return true; }
template<class T> vector<vector<T>> split (const vector<T>& S, T delim) { vector<vector<T>> ret{}; vector<T> buff{}; for (auto c : S) { if (c == delim) { if (!buff.empty()) ret.push_back(buff); buff.clear(); } else { buff.push_back(c); } } if (!buff.empty()) ret.push_back(buff); return ret; }
template<class T> inline void printYesNo(const T& t) { cout << (t ? "Yes" : "No") << CRLF; }
template<class T = int64_t> T modpow(T N, T P, T M) { T ret{1}; N %= M; while (P) { if (P & 0x01) { ret *= N; ret %= M; } P >>= 1; N *= N; N %= M; } return ret; }

/** code for assert debug begin */
int gErr = 0;
#define ASSERT(p) if(!(p)){ gErr = 1; }else{ ; }
/** code for assert debug end */

struct Tmp
{
public:
  int N;
  Tmp(int N)
  : N(N)
  {}
};

void solve(void)
{
  int N; cin >> N;
  auto ans = 800*N - (N / 15)*200;
  cout << ans << CRLF;
  return;
}

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

  solve();

  return 0;
}


Measured memory_bytes: 256
import bisect
N = int(input())
L = list(map(int, input().split()))
L.sort()

ans = 0
for i in range(N-2):
    for j in range(i+1, N-1):
        ans += bisect.bisect_left(L, L[i] + L[j]) - (j+1)
print(ans)

Measured memory_bytes: 3188
#include<iostream>
#include<vector>
#include<map>
#include<algorithm>

using namespace std;

int main(){
	int n,m;
	cin >> n >> m;
	
	int a[301][301];
	for(int i = 0;i < n;i++){
		for(int j = 0;j < m;j++){
			cin >> a[i][j];
		}
	}
	
	vector<int> erased;
	int ans = 1e9;
	for(int k = 0;k < m;k++){
		map<int,int> p;
		for(int i = 1;i <= m;i++) p[i] = 0;
		
		for(int i = 0;i < n;i++){
			for(int j = 0;j < m;j++){
				if(find(erased.begin(),erased.end(),a[i][j]) == erased.end()){
					p[a[i][j]]++;
					break;
				}
			}
		}
		
		int mp = 0;
		int num = 0;
		for(int i=1;i <= m;i++){
			if(mp < p[i]){
				mp = p[i];
				num = i;
			}
		}
		ans = min(ans,mp);
		erased.push_back(num);
	}
	
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 640
#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;
vector<string> a;
void search(int n,int c){
	if (c < 10){
		stringstream ss;
		ss << static_cast<bitset<10> > (n);
		string x1 = ss.str();
		a.pb(x1);
		// cout << x1 << endl;
		int m = n; 
		search(n,c+1);
		ss << static_cast<bitset<10> > (m+int(pow(10,c)));
		string x2 = ss.str();
		// cout << x2 << endl;
		search(m+int(pow(10,c)),c+1);
		a.pb(x2);
	}
}

int main(){
	int n,l;
	ll z;
	cin >> n;
	vector<vector<int>> f(n,vector<int>(10));
	vector<vector<ll>> p(n,vector<ll>(11));
	for(int i = 0; i < n; i++) {
		for(int j = 0; j < 10; j++) {
			cin >> l;
			f[i][j] = l;
		}
	}
	for(int i = 0; i < n; i++) {
		for(int j = 0; j < 11; j++) {
			cin >> z;
			p[i][j] = z;
		}
	}
	for(int i = 0; i < 1024; i++) {
		std::stringstream ss;
		ss << std::bitset<10>(i);
		std::string s = ss.str();
		a.pb(s);
	}
	ll ans = -10000000000;

	for(int i = 1; i < 1024; i++) {//営業の仕方
		ll tmp = 0;
		for(int j = 0; j < n; j++) {//店のインデックス
			int counter = 0;
			for(int k = 0; k < 10; k++) {//それぞれの時間帯についてチェック
				if (a[i][9 - k] == '1' && a[i][9 - k] - '0' == f[j][k]){
					counter++;
				}
			}
			tmp += p[j][counter];
		}
		ans = max(ans,tmp);
	}
	cout<< ans <<endl;
	return 0;
}

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

int l[100000], r[100000];
int main() {
  string s;
  int n;
  cin >> s;
  n = s.length();
  for (int i = 0; i < n; i++) {
    if (s[i] == 'R') {
      r[i + 1] = r[i] + 1;
      r[i] = 0;
    }
  }
  for (int i = n - 1; i >= 0; i--) {
    if (s[i] == 'L') {
      l[i - 1] = l[i] + 1;
      l[i] = 0;
    }
  }
  for (int i = 0; i < n; i++) {
    int ans = 0;
    if (s[i] == 'R') {
      ans += (l[i]) / 2 + (r[i + 1] + 1) / 2;
    } else {
      ans += (r[i]) / 2 + (l[i - 1] + 1) / 2;
    }
    cout << ans << " ";
  }
  cout << endl;
}

Measured memory_bytes: 1408
#include <stdio.h>

int main() {
    int a;
    int b;
    int d,r;
    double f;
    scanf("%d%d",&a,&b);
    d = a/b;
    r = a%b;
    f = (double)a/b;
    
    printf("%d %d %.5lf\n",d,r,f);
    return 0;
}

Measured memory_bytes: 1068
# import bisect
# # import heapq
# # from copy import deepcopy
from collections import deque
# # from collections import Counter
# # from itertools import accumulate
# # from itertools import permutations
# import numpy as np
# # import math

n, m, k = map(int, input().split())
# a = list(map(int, input().split()))
# n = int(input())

class UnionFind:
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def size(self, x):
        return -self.parents[self.find(x)]

uf = UnionFind(n)
friend =[[] for _ in range(n)]
block = [[] for _ in range(n)]
for i in range(m):
    a,b = map(int, input().split())
    a,b = a-1,b-1
    uf.union(a,b)
    friend[a].append(b); friend[b].append(a)

for i in range(k):
    c,d = map(int, input().split())
    c,d = c-1,d-1
    if uf.same(c,d):
        block[c].append(d); block[d].append(c)

w = [0] * n
for i in range(n):
    w[i] = uf.size(i) - len(friend[i]) - len(block[i]) - 1

print(*w)

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

int pow(int a, int n) {
  int res = 1;
  for (; n; n >>= 1) {
    if (n & 1) res *= a;
    a *= a;
  }
  return res;
}

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

  int A, B, C, K; cin >> A >> B >> C >> K;
  if (B < C) swap(B, C);
  if (A < B) swap(A, B);
  cout << pow(2, K) * A + B + C << "\n";
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ALL(a) (a).begin(),(a).end()

int main() {
  int n,m;
  cin>>n>>m;
  vector<vector<long>> v(m,{(long)0,(long)0});
  for (size_t i = 0; i < m; i++) {
    cin>>v[i][0]>>v[i][1];
    v[i].push_back(i);
  }
  sort(ALL(v));
  int j;
  for (size_t i = 0; i < v.size(); i++) {
    if(i==0||v[i][0]!=v[i-1][0]) j=1;
    v[i][1]=j;
    j++;
  }
  for (size_t i = 0; i < v.size(); i++) {
    v[i][0]*=1000000;
    v[i][0]+=v[i][1];
    swap(v[i][0],v[i][2]);
  }
  sort(ALL(v));
  for (size_t i = 0; i < v.size(); i++) {
    cout << setfill('0') << right << setw(12)<<v[i][2]<<endl;
  }
  
}

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

#ifdef LOCAL
#include <debug.hpp>
#else
#define debug(...) void()
#endif

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  int c2 = 0, c4 = 0;
  for (int i = 0, a; i < n; i++) {
    cin >> a;
    if (a % 4 == 0) {
      c4++;
    } else if (a % 2 == 0) {
      c2++;
    }
  }
  debug(c2, c4);
  if (c4 * 2 + c2 / 2 * 2 + 1 >= n) {
    cout << "Yes" << '\n';
  } else {
    cout << "No" << '\n';
  }
  return 0;
}

Measured memory_bytes: 3616
def count_char(array)
  answers = {
            "a" => 0,
            "b" => 0,
            "c" => 0,
            "d" => 0,
            "e" => 0,
            "f" => 0,
            "g" => 0,
            "h" => 0,
            "i" => 0,
            "j" => 0,
            "k" => 0,
            "l" => 0,
            "m" => 0,
            "n" => 0,
            "o" => 0,
            "p" => 0,
            "q" => 0,
            "r" => 0,
            "s" => 0,
            "t" => 0,
            "u" => 0,
            "v" => 0,
            "w" => 0,
            "x" => 0,
            "y" => 0,
            "z" => 0
            }
  length = array.length
    for i in 0..(length-1)
      if answers[array[i].downcase] == nil
        next
      else
        answers[array[i].downcase] += 1
     end
   end
     return answers
end

sum_hash = {}

while str_array = gets
  # str_array = input_values.chars.map(&:to_s)
answer = count_char(str_array)
sum_hash.merge!(answer){|key, v0, v1|v0 + v1}

end
 sum_hash.each {|key, value|
   print(key + " : ", value.to_s + "\n")
 }

Measured memory_bytes: 8628
#include<iostream>
#include<vector>
#include<algorithm>
#include<iomanip>
#include<set>
#include<string>
#include<bitset>
#include<queue>
#include<map>
using namespace std;

int gcd_2(int a, int b) {
	int r = a % b;
	if (r == 0) {
		return b;
	}
	else {
		return(gcd_2(b, r));
	}
}
int gcd_3(int a, int b, int c) {
	return gcd_2(gcd_2(a, b), c);
}

int main() {
	int K;
	cin >> K;
	int ans = 0;
	for (int a = 1; a <= K; a++) {
		for (int b = 1; b <= K; b++) {
			for (int c = 1; c <= K; c++) {
				ans += gcd_3(a, b, c);
			}
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3120
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
int main(){
  string S;
  cin>>S;
  int c1=0,c0=0;
  rep(i,S.size()){
    if(S[i]=='1') c1++;
    else c0++;
  }
  cout<<2*min(c1,c0)<<endl;
}

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

int main() {
  int d, n;
  cin >> d >> n;
  int handred = 1;
  for (int k = 0; k < d; k++) {
    handred *= 100;
  }
  int ans = handred * n;
  if (n == 100) cout << ans + handred << endl;
  else cout << ans << endl;
}

Measured memory_bytes: 256
S = input()[::-1]

modCount = [0]*2019
modCount[0] = 1
mod = 0
dig = 1
result = 0

for i in range(len(S)):
  mod = (int(S[i:i+1])*dig+mod)%2019
  dig = (dig*10)%2019
  result += modCount[mod]
  modCount[mod] += 1

print(result)

Measured memory_bytes: 9312
#include <iostream>
using namespace std;
int main(){
  string s;
  cin >> s;
  for(int i=0; i<s.size()-1; i++){
    if(s[i]=='A'&&s[i+1]=='C'){
      puts("Yes");
      return 0;
    }
  }
  puts("No");
  return 0;
}

Measured memory_bytes: 3588
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define REP(i,m,n) for(int i=(int)(m); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define rrep(i,n) RREP(i,(n)-1,0)
#define all(v) v.begin(), v.end()
#define endk '\n'
const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;
const ld eps = 1e-10;
template<typename T1, typename T2> inline void chmin(T1 &a, T2 b){if(a>b) a=b;}
template<typename T1, typename T2> inline void chmax(T1 &a, T2 b){if(a<b) a=b;}

bool is_prime(const unsigned n) {
  switch(n) {
  case 0: // fall-through
  case 1: return false;
  case 2: // fall-through
  case 3: return true;
  } // n > 3 が保証された
  if(n % 2 == 0) return false;
  if(n % 3 == 0) return false;
  if(n % 6 != 1 && n % 6 != 5) return false;
  for(unsigned i=5; i*i<=n; i+=6) {
    if(n % i     == 0) return false; // 6n-1
    if(n % (i+2) == 0) return false; // 6n+1
  }
  return true;
}
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int x; cin >> x;
  while(true) {
    if(is_prime(x)) {
      cout << x << endk;
      break;
    }
    x++;
  }
  return 0;
}


Measured memory_bytes: 3640
import itertools
import math

n, q = map(int, input().split())
s = input()
lr = []
for i in range(q):
    li , ri = list(map(int, input().split()))
    lr.append([li-1,ri-1])

his = [0]*n
count = 0
for i in range(1,n):
    if s[i-1] == 'A' and s[i] == 'C':
        count += 1
        his[i] = count
    else:
        his[i] = his[i-1]

for i in range(q):
    print(his[lr[i][1]] - his[lr[i][0]])

Measured memory_bytes: 67288
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
 
int main() {
cout<<fixed<<setprecision(10);

string S;
  cin >> S;
  if (S.at(2)==S.at(3) && S.at(4)==S.at(5)) cout << "Yes" <<endl;
  else cout << "No" << endl;
	
}

Measured memory_bytes: 256
// Contest No.: ABC175
// Problem No.: A
// Solver:      Jinmin Goh
// Date:        20200815

#include <cstring>
#include <iostream>
#include <cstdlib>
#include <list>
#include <array>
#include <atomic>
#include <algorithm>
#include <deque>
#include <iterator>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <valarray>
#include <vector>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
using namespace std;

int main() {
    int cnt = 0;
    char w[3];
    scanf("%s", w);

    if(w[0] == 'R' && w[1] == 'R' && w[2] == 'R') {
        printf("3");
    }
    else if((w[0] == 'R' && w[1] == 'R') || (w[1] == 'R' && w[2] == 'R')) {
        printf("2");
    }
    else if(w[0] == 'S' && w[1] == 'S' && w[2] == 'S') {
        printf("0");
    }
    else {
        printf("1");
    }

    return 0;
}

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


string N;
int K, n;
ll ans;
vector<int> p9;


void input() {
    cin >> N >> K;
}


const int MOD = 1e9 + 7;
const int MAX = 100;
ll fac[MAX], finv[MAX], inv[MAX];


void comb_init() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}


ll comb(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}


ll solve(int i, int j) {
    if (n - i < j) return 0;
    if (j == 0) return 1;
    ll x = 0;
    if (N[i] == '0') x += solve(i+1, j);
    else {
        x += p9[j] * comb(n - i - 1, j);
        x += (N[i] - '1') * p9[j-1] * comb(n - i - 1, j - 1);
        x += solve(i + 1, j - 1);
    }
    return x;
}


int main() {
    comb_init();
    input();
    p9 = vector<int>(4);
    p9[0] = 1;
    rep(i, 3) p9[i+1] = p9[i] * 9;
    n = N.size();
    vector<vector<ll>> dp(n, vector<ll>(K+1, 0));
    ans = 0;
    for (int i = 1; i < n; i++) {
        ans += p9[K] * comb(i - 1, K - 1);
    }
    ans += (N[0] - '1') * p9[K-1] * comb(n - 1, K - 1);
    ans += solve(1, K - 1);
    cout << ans << endl;
}


Measured memory_bytes: 256
import sys
from pprint import pprint

def solve(n, h):
    ans = 0

    start = -1
    pre_h = -1
    for i in range(n):
        if pre_h < h[i]:
            # print(pre_h,h[i], i -1 - start)
            ans = max(ans, i - 1 - start)
            start = i
        pre_h = h[i]
    if start != i:
        ans = max(ans, i - start)

    print(ans)

if __name__ == '__main__':
    n = int(sys.stdin.readline().strip())
    h = list(map(int, sys.stdin.readline().strip().split(" ")))
    solve(n, h)

Measured memory_bytes: 59424
#include <cstdio>
#include <vector>
#include <functional>
#define repeat(i,n) for (int i = 0; (i) < int(n); ++(i))
using ll = long long;
using namespace std;

vector<pair<int, int> > complete_matching_of_tree(vector<vector<int> > const & g) {
    int n = g.size();
    vector<pair<int, int> > result;
    vector<bool> used(n);
    function<bool (int, int)> dfs = [&](int i, int p) {
        int unused = -1;
        for (int j : g[i]) if (j != p) {
            if (not dfs(j, i)) return false;
            if (not used[j]) {
                if (unused != -1) {
                    return false;
                }
                unused = j;
            }
        }
        if (unused != -1) {
            result.emplace_back(i, unused);
            used[i] = true;
            used[unused] = true;
        }
        return true;
    };
    const int root = 0;
    if (not dfs(root, -1) or not used[root]) {
        result.clear();
    }
    return result;
}

int main() {
    int n; scanf("%d", &n);
    vector<vector<int> > g(n);
    repeat (i,n-1) {
        int a, b; scanf("%d%d", &a, &b); -- a; -- b;
        g[a].push_back(b);
        g[b].push_back(a);
    }
    vector<pair<int, int> > result = complete_matching_of_tree(g);
    printf("%s\n", result.empty() ? "First" : "Second");
    return 0;
}


Measured memory_bytes: 6400
# -*- coding: utf-8 -*-
"""
B - Exactly N points
https://atcoder.jp/contests/cf16-final/tasks/codefestival_2016_final_b

"""
import sys


def solve(N):
    def is_big_enough(n):
        x = n*(n+1) // 2
        if x >= N:
            return True
        return False

    ub, lb = 5000, 1
    while ub - lb > 0:
        mid = (ub + lb) // 2
        if is_big_enough(mid):
            ub = mid
        else:
            lb = mid + 1

    x, ans = lb, []
    while N:
        if N <= x:
            ans.append(N)
            N = 0
        else:
            ans.append(x)
            N -= x
            x -= 1
    return ans


def main(args):
    N = int(input())
    ans = solve(N)
    print(*ans, sep='\n')


if __name__ == '__main__':
    main(sys.argv[1:])


Measured memory_bytes: 3572
N, T = map(int, input().split())
t = [int(i) for i in input().split()]
ans = 0
now = 0

for i in range(N):
    if t[i] >= now:
        ans += T
    else:
        ans += t[i] - t[i-1]
    
    now = t[i]+T
    
print(ans)

Measured memory_bytes: 25200
use std::io::Read;

pub fn read_stdin() -> String {
    let mut s = String::new();
    ::std::io::stdin().read_to_string(&mut s).unwrap();
    s
}

pub trait Parse {
    fn to<T>(&mut self) -> T
    where
        T: std::str::FromStr;
}

impl<'a> Parse for std::str::SplitWhitespace<'a> {
    fn to<T>(&mut self) -> T
    where
        T: std::str::FromStr,
    {
        let word = self.next().unwrap();
        word.parse().ok().unwrap()
    }
}

fn dfs(curr: usize, parent: Option<usize>, adj: &Vec<Vec<usize>>, ans: &mut Vec<u64>) {
    for &child in &adj[curr] {
        if let Some(p) = parent {
            if child == p {
                continue;
            }
        }
        ans[child] += ans[curr];
        dfs(child, Some(curr), adj, ans);
    }
}

fn main() {
    let source = read_stdin();
    let mut iter = source.split_whitespace();
    let n = iter.to();
    let q_n = iter.to();
    let v = (0..(n - 1))
        .map(|_| (iter.to::<usize>() - 1, iter.to::<usize>() - 1))
        .collect::<Vec<_>>();
    let qs = (0..q_n)
        .map(|_| (iter.to::<usize>() - 1, iter.to()))
        .collect::<Vec<_>>();

    let mut adj = vec![Vec::new(); n];
    for (a, b) in v {
        adj[a].push(b);
        adj[b].push(a);
    }

    let mut ki = vec![0; n];
    for q in qs {
        ki[q.0] += q.1;
    }

    let mut ans = (0..n).map(|i| ki[i]).collect::<Vec<_>>();

    dfs(0, None, &adj, &mut ans);

    println!(
        "{}",
        ans.into_iter()
            .map(|x| x.to_string())
            .collect::<Vec<_>>()
            .join(" ")
    );
}

Measured memory_bytes: 54904
#include <iostream>
#include <math.h>
#include <string.h>

using namespace std;

int n, s, ans = 0;

bool isPrime(int a) {
    if(a <= 1 || (a % 2 == 0 && a != 2)) return false;
    if(a == 2) return true;

    for(int i = 3; i <= (int) sqrt(a); i += 2) {
        if(a % i == 0) return false;
    }
    return true;
}

int main(void) {
    cin >> n;
    for(int i = 0; i < n; i++) {
        cin >> s;
        if(isPrime(s)) {
            ans += 1;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 824
/*------------------------------------
........Bismillahir Rahmanir Rahim....
..........created by Abdul Aziz.......
------------------------------------*/
#include <iostream>
#include <algorithm>
#include <stdio.h>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <cstring>
#include <unordered_map>
#include <queue>
#define   mod  998244353
#define   int  long long 
#define   ld   long double
#define   pb   push_back
#define   vi  vector<int> 
#define   dbg(x)  cerr << #x << " = " << x << '\n'
#define   sz(x)  (int)x.size()
#define   ff   first
#define   ss   second
#define   pii  pair<int,int>
using namespace std;

int fun(int a,int b,int c){
    int d = (max(a,max(b,c)) - min(a,min(b,c))); 
    return  d; 
}

int solve(int w,int h){
    int  ans = min(w,h) ; 
    for (int i=1,j=w-1;i<=j;i++,j--){
        int a = i*h;
        int b = (h/2) * j; 
        int c = (h * w) - a - b ; 
        ans = min(ans,fun(a,b,c));
    }
    return ans ;
}

signed main()
{
    int w,h;
    cin>>w>>h;
    if (w%3==0 or h%3==0) {
      cout << 0 << endl;
      return 0;
    }
    int ans1= solve(w,h);
    int ans2= solve(h,w);
    cout << min(ans1,ans2) << endl; 
    return 0;
}


Measured memory_bytes: 3636
N = int(input())
P = [[int(c) for c in input().split()] for _ in range(N)]
current = [0, 0, 0]
accept = True

for t, x, y in P:
    dt = t - current[0]
    d = abs(current[1] - x) + abs(current[2] - y)
    if d > dt:
        accept = False
        break
    elif d % 2 != dt % 2:
        accept = False
        break
    else:
        current = [t, x, y]

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

Measured memory_bytes: 21108
import java.util.*;
 
public class Main {
  public static void main (String[] arg) {
    Scanner scan = new Scanner(System.in);
    int N = scan.nextInt();
    long A[] = new long[N+1];
    long B[] = new long[N];
    long Kc = 0;

    for (int i = 0; i < N+1; i++){
      A[i] = scan.nextLong();
    }

    for (int i = 0; i < N; i++){
      B[i] = scan.nextLong();
    }
    
    for(int i = 0; i < N; i++){
      if(B[i] > A[i]){
        B[i] -= A[i];
        Kc += A[i];
        if(B[i] > A[i+1]){
          Kc += A[i+1];
          A[i+1] = 0;
        } else {
          Kc += B[i];
          A[i+1] -= B[i];
        }
      } else {
        Kc += B[i];
      }
    }
    System.out.println(Kc);
  }
}

Measured memory_bytes: 87004
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cstring>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <numeric>
#include <utility>
#include <iomanip>
#include <algorithm>
#include <functional>
using namespace std;

typedef long long ll;
typedef vector<int> vint;
typedef vector<long long> vll;
typedef pair<int,int> pint;
typedef pair<long long, long long> pll;

#define MP make_pair
#define PB push_back
#define ALL(s) (s).begin(),(s).end()
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl

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; }
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P) 
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P) 
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P) 
{ EACH(it, P) { s << "<" << it->first << "->" << it->second << "> "; } return s; }


int L, A, B, C, D;


int main() {
    while (cin >> L >> A >> B >> C >> D) {
        int d = max( (A+C-1)/C, (B+D-1)/D );
        cout << L - d << endl;
    }
    return 0;
}


Measured memory_bytes: 1160
# -*- coding: utf-8 -*-
"""
Created on Mon Apr 30 11:33:59 2018
ALDS1-4a_r  simple implementation without sets
@author: maezawa
"""

n = int(input())
s = list(map(int, input().split())) # in演算子を使うためにはsはlistである必要がある。
q = int(input())
t = map(int, input().split())

cnt = 0

for i in t:
    if i in s:
        cnt += 1

print(cnt)


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

int main(){
while(1){
	int n,m,k=0,ans=0;
	string s;
	cin>>n;
	if(n==0)break;
	cin>>m;
	cin>>s;
	for(int i=0;i<m;i++){
		if(k==0){
			if(s[i]=='I')k=1;
		}
		else {
			if(s[i]!=s[i-1])k++;
			else {
				int c=(k-1)/2;
				if(c>=n)ans+=c-n+1;
				k=0;
				if(s[i]=='I')k=1;
			}
		}
	}
	printf("%d\n",ans);
}
}

Measured memory_bytes: 2100
import java.util.*;

public class Main{
	public static void main(String[] args){
		Scanner scan = new Scanner(System.in);
		long x = scan.nextLong();
		long smile = 0;

		if(x >= 500){
			smile += (x / 500) * 1000;
			x = x % 500;
		}
		if(x >= 5){
			smile += (x /5) *5;
		}

		System.out.println(smile);
	}
}

Measured memory_bytes: 21972
#include <bits/stdc++.h>
using namespace std;
#define int long long
const int MOD=998244353;

int N,ans,cnt;int X;
string x;
struct p{int n,s;};
vector<p> v;

int pw(int n,int k){
  if(k<0)return pw(n,k+MOD-1);
  int res=1;
  while(k){
    if(k&1)res*=n;res%=MOD;
    n*=n;n%=MOD;
    k>>=1;
  }
  return res;
}

int f(int a){//長さaのループがX以下に何種類存在するか
  int res=0;
  for(int i=0;i<a;i++)if(x[i]=='1')res+=pw(2,a-i-1),res%=MOD;//桁DPっぽいところ
  {//最初a文字がXと完全に一致しているやつがx以下かどうかの判定
    string A=x.substr(0,a),s;
    while(s.size()<N)s+=A;
    for(int i=0;i<s.size();i++)if((i/a)&1)s[i]=(s[i]-'0')^1+'0';
    //sがx以下かどうか判定する
    for(int i=a;i<N;i++){
      if(x[i]=='1'&&s[i]=='0'){res++;break;}
      if(x[i]=='0'&&s[i]=='1')break;
      if(i==N-1)res++;
    }
  }
  return res;
}

int INT(string x){//xを数字に変換する
  int res=0;
  for(char p:x){
    res*=2;
    res+=(p=='1');
    res%=MOD;
  }
  return res;
}

signed main(){
  cin>>N>>x;
  for(int i=1;i<N;i++) if(N%i==0&&(N/i)&1) v.push_back({i,f(i)});
  for(int i=0;i<v.size();i++){
    for(int j=i+1;j<v.size();j++) if(v[j].n%v[i].n==0) v[j].s-=v[i].s;
    ans+=v[i].s*2*v[i].n;ans%=MOD;
    cnt+=v[i].s;cnt%=MOD;
  }
  int nomal=(INT(x)+1-cnt)%MOD;//2*Nでループするやつの個数
  ans+=nomal*N*2%MOD;ans%=MOD;if(ans<0)ans+=MOD;
  cout<<ans<<endl;
}


Measured memory_bytes: 1040
#include <iostream>
#include <string>
#include <cmath>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include<iomanip>
#define _USE_MATH_DEFINES
#include <math.h>
#include <functional>
using namespace std;

#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)

typedef long long ll;
const ll INF = 1e17;
const ll MOD = 1000000007;
const ll MAX = 1000000;

int main() {

	
	int N,M;
	cin >> N >> M;

	int p = pow(2, N);

	ll a[1100];
	int b[1100];
	int c[1100] = {};

	repn(i, M) {
		cin >> a[i] >> b[i];
		rep(j,b[i]){

			int k;
			cin >> k;
			
			c[i] += pow(2, k - 1);
		}
	}

	ll dp[1100][4100];

	rep(i, N+1) {
		rep(j, p) {
			dp[i][j] = INF;
		}
	}

	dp[0][0] = 0;

	repn(i, M) {

		rep(j, p) {
			dp[i][j] = dp[i - 1][j];
		}

	

		rep(j, p) {
			int x = c[i] | j;
			dp[i][x] = min(dp[i - 1][j]+a[i],dp[i][x]);
			

		}
	}

	
	if (dp[M][p - 1] == INF) { cout << -1; }
	else { cout << dp[M][p - 1]; }



	system("PAUSE");

}

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

int main(){
	int rabbit[55];
	int flg[55]={0};
	int n,k,r;
	cin >> n >> k;
	for(int i=0;i<k;i++){
		int m; cin >> m;
		for(int j=0;j<m;j++){
			int num; cin >> num;
			rabbit[num] = i;
		}
	}
	cin >> r;
	int ans = 0;
	for(int i=0;i<r;i++){
		int a,b; cin >> a >> b;
		//cout << rabbit[a] << " " << rabbit[b] << endl;
		if(rabbit[a] == rabbit[b]){
			if(flg[a]==0) {
				ans++;
				flg[a] = 1;
			}
			if(flg[b]==0) {
				ans++;
				flg[b] = 1;
			}
		}
	}
	cout << ans << endl;
}

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

#define rep(i, a, n)  for(int i=a; i<n; i++)
#define per(i, a, n)  for(int i=n-1; i>=a; i--)
#define all(x)  (x).begin(), (x).end()
#define MAX 1000000007
using namespace std;
typedef long long ll;

int main(){
  ll a, b, x; cin >> a >> b >> x;
  ll ans = a==0 ? b/x+1 : b/x - (a-1)/x;

  cout << ans << endl;
}

Measured memory_bytes: 256
#!/usr/bin/env python

from collections import deque
import itertools as it
import sys

sys.setrecursionlimit(1000000)

def check(c):
    return (ord(c) >= ord('0') and ord(c) <= ord('9'))

def check2(c):
    return (ord(c) >= ord('A') and ord(c) <= ord('Z'))

while True:
    S1, S2 = raw_input().split()
    if S1 == '0':
        break
    N = int(S2)
    SS = ''
    flag = False
    for i in range(len(S1) - 1):
        SS += S1[i]
        if check(S1[i]) and not check(S1[i + 1]) and S1[i + 1] != '(':
            SS += '('
            flag = True
        elif flag:
            SS += ')'
            flag = False
    SS += S1[len(S1) - 1]
    if flag:
        SS += ')'
    S1 = '(' + SS + ')'
    for i in range(26):
        c = chr(ord('A') + i)
        S1 = S1.replace('(' + c, '("' + c)
        S1 = S1.replace(c + ')', c + '")')
        S1 = S1.replace(')' + c, ')"' + c)
        S1 = S1.replace(c + '(', c + '"(')
        for j in range(10):
            c2 = str(j)
            S1 = S1.replace(c + c2, c + '"' + c2)
    S1 = S1[1 : -1]
    S1 = S1.replace('(', ',')
    SS = ''
    for i in range(len(S1) - 1):
        SS += S1[i]
        if not check(S1[i]) and check(S1[i + 1]):
            SS += '('
    SS += S1[len(S1) - 1]
    if check(S1[0]):
        SS = '(' + SS
    S1 = '(1, ' + SS + ')'
    S1 = S1.replace(')(', '),(')
    S1 = S1.replace(')"', '),"')
    S1 = S1.replace('"(', '",(')
    hoge = eval(S1)
    ans = 0
    m = {}
    def func(obj):
        if type(obj) == type("hoge"):
            m[obj] = len(obj)
            return len(obj)
        num = obj[0]
        ret = 0
        for i in range(1, len(obj)):
            ret += num * func(obj[i])
        m[obj] = ret
        return ret

    def func2(obj, index):
        if type(obj) == type("hoge"):
            return obj[index]
        num = obj[0]
        S = m[obj]
        index %= S / num
        ret = 0
        for i in range(1, len(obj)):
            ret += m[obj[i]]
            if ret > index:
                ret -= m[obj[i]]
                return func2(obj[i], index - ret)
        return '0'
    
    func(hoge)
    #print m
    if N >= m[hoge]:
        print '0'
    else:
        print func2(hoge, N)



Measured memory_bytes: 5164
while True:
    n = int(input())
    m = int(input())
    if n==0: break
    tab = [[] for _ in range(n)]
    for _ in range(m):
        a,b = map(int,input().split())
        a -= 1
        b -= 1
        tab[a].append(b)
        tab[b].append(a)
    ans = set(tab[0])
    foff = set()
    for i in ans:
        foff = foff | set(tab[i])
    print(len((ans|foff)-{0}))

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

int main(){
  int n, m, key, tmp;
  char u[260][16], t[16];
  int i, j;

  scanf("%d", &n);

  for(i=0; i<n; i++){
    scanf("%s", u[i]);
  }

  scanf("%d", &m);

  key=0;
  for(i=0; i<m; i++){
    tmp=0;
    scanf("%s", t);
    for(j=0; j<n; j++){
      if(strcmp(t, u[j])==0){
	key++;
	tmp=1;
	break;
      }
    }
    if(tmp==1){
      if(key%2==1){
	printf("Opened by %s\n", t);
      }else if(key%2==0){
	printf("Closed by %s\n", t);
      }
    }else{
      printf("Unknown %s\n", t);
    }
  } 
  
  return 0;
}

Measured memory_bytes: 604
#include <stdio.h>
int main(void){
    int i,goal,n,s[24]={},f[24]={},sum;
    
    while(1){
        scanf("%d",&goal);
        if(goal==0)break;
        scanf("%d",&n);
        
        sum=0;
        for(i=0;i<n;i++){
            scanf("%d %d",&s[i],&f[i]);
            sum+=f[i]-s[i];
        }
        
        if(sum<goal) printf("%d\n",goal-sum);
        else puts("OK");
    }
    
    return 0;
}

Measured memory_bytes: 612
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ll long long
int main(){
    int n;
    cin >> n;
    rep(i,n+1){
        int rest = n-i*100;
        if(0<= rest && rest <= 5*i ){
            puts("1");
            return 0;
        }
        if(rest <0) break;
    }
    puts("0");
    return 0;
}

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

using namespace std;

int main(){
    int n; cin >> n;
    vector<int> vs(n), diffs(n);
    for(int i=0; i<n; ++i){
        cin >> vs[i];
    }
    for(int i=0; i<n; ++i){
        int c; cin >> c;
        diffs[i]=vs[i]-c;
    }
    int ans=0;
    for(int i=0; i<n; ++i){
        if(diffs[i]<0) continue;
        ans+=diffs[i];
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<utility>
#include<algorithm>
#include<map>
#include<cmath>
typedef long long ll;
#define PB	push_back
#define FOR(n)			for(int i = 0; i < n; ++i)
#define RFOR(n)			for(int i = n; i >= 0; --i)
#define FORR(start,end) for(int i = start; i < end; ++i)
#define COUT(n)			cout << n << " " << flush
#define vi(v)			vector<int> v
#define vii(v)			vector<pair<int,int>> v
#define mii(m)			map<int, int> m
#define msi(m)			map<string, int, less<>> m
#define mmsi(m)			multimap<string, int, less<>> m
#define mkp(a,b)		make_pair(a,b)
#define ALL(obj)		obj.begin(), obj.end()
#define PI 3.141592
#define MOD 1e9+7
using namespace std;

void solve() {
	int a, b, c;
	cin >> a >> b >> c;
	if (a + b + c >= 22)
		cout << "bust" << endl;
	else
		cout << "win" << endl;
}

int main() {
	solve();
	return 0;
}

Measured memory_bytes: 256