akhauriyash/Code-Regression huggingface dataset:
// cities to vapori-
// corner cases // int vs ll // cin vs scanf // clear structures // statement // doublesz // math is your friend
#include <bits/stdc++.h>
#define pb push_back
#define fst first
#define snd second
#define sz(x) int(x.size())
#define fill(x,v) memset(x,v,sizeof(x))
#define REP(i,a,b) for(int i = int(a); i < int(b); ++i)
#define trace(x) cout << #x << " = " << x << endl
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
using namespace std;
typedef long long ll;
typedef pair<int,int> ii;

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

	ll ans = n/(a+b)*a + min(n%(a+b),a);
	cout << ans << endl;

	return 0;
}


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

using namespace std;
int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  for (int i = 0; i < n; i++) {
    cin >> a.at(i);
  }
  int ma = a.at(0);
  long long sum = 0;
  for (int i = 1; i < n; i++) {
    if (a.at(i) < ma) {
      sum += ma - a.at(i);
    } else {
      ma = a.at(i);
    }
  }
  cout << sum;
}


Measured memory_bytes: 4036
#include <stdio.h>
#include<string.h>
int main()
{
long int a[100000],b[100000],c=0,d=0,w=0,i,str1=0,str2=0,flag,j,count=0,k,n,sum=0;
scanf("%ld",&n);
for(i=0;i<n;i++)
{
    scanf("%ld",&a[i]);
    sum+=a[i];
    
}
scanf("%ld",&k);
for(i=0;i<k;i++)
{
    scanf("%ld%ld",&c,&d);
    b[i]=sum-a[c-1]+d;
    
}
for(i=0;i<k;i++)
{
    printf("%ld\n",b[i]);
}
 return 0;
}

Measured memory_bytes: 128
from collections import Counter
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**9)

def solve():
    MOD = 10**9 + 7

    N = int(input())
    ABs = [tuple(map(int, input().split())) for _ in range(N)]

    def gcd(a, b):
        while b:
            a, b = b, a%b
        return a

    cntPos = Counter()
    cntNeg = Counter()
    num00 = 0
    for A, B in ABs:
        if A == B == 0:
            num00 += 1
            continue
        if A == 0:
            cntNeg[(0, 1)] += 1
        elif B == 0:
            cntPos[(0, 1)] += 1
        else:
            isPN = A*B < 0
            A, B = abs(A), abs(B)
            g = gcd(A, B)
            A, B = A//g, B//g
            if isPN:
                cntNeg[(B, A)] += 1
            else:
                cntPos[(A, B)] += 1

    numPoss = []
    numNegs = []

    numIso = 0
    for key in set(cntPos.keys()) | set(cntNeg.keys()):
        if cntPos[key] > 0 and cntNeg[key] > 0:
            numPoss.append(cntPos[key])
            numNegs.append(cntNeg[key])
        else:
            numIso += cntPos[key] + cntNeg[key]

    M = len(numPoss)
    numAlls = [0] * M
    numOKs = [0] * M
    numNGs = [0] * M
    for i in range(M):
        numPos = numPoss[i]
        numNeg = numNegs[i]
        numAll = pow(2, numPos+numNeg, MOD)
        numOK = pow(2, numPos, MOD) + pow(2, numNeg, MOD) - 1
        numNG = numAll - numOK
        numAlls[i] = numAll
        numOKs[i] = numOK
        numNGs[i] = numNG

    acc = pow(2, numIso, MOD)
    accNumAlls = [acc]
    for i in reversed(range(M)):
        acc *= numAlls[i]
        acc %= MOD
        accNumAlls.append(acc)
    accNumAlls.reverse()

    N -= num00
    ans = pow(2, N, MOD) - 1
    accOK = 1
    for i in range(M):
        num = accOK * numNGs[i] * accNumAlls[i+1] % MOD
        ans -= num
        ans %= MOD
        accOK *= numOKs[i]

    print(ans + num00)


solve()


Measured memory_bytes: 95068
#include<bits/stdc++.h>
using namespace std;
int n,m,res;
bool on[110];
int main(){
	scanf("%d%d",&n,&m);
	for(int i=1,x,y;i<=m;i++){
		scanf("%d",&x);
		while(x--)scanf("%d",&y),on[y]=true;
	}
	for(int i=1;i<=n;i++)res+=!on[i];
	printf("%d\n",res);
	return 0;
}

Measured memory_bytes: 3828
import std.algorithm;
import std.array;
import std.conv;
import std.math;
import std.range;
import std.stdio;
import std.string;

void main() {
  int n;
  readf (" %d", &n);
  //3 -> 1 + 2
  //4 -> 1 + 3
  //5 -> (2 + 3, 1 + 4)
  writeln ( (n - 1) / 2);
}



Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <numeric>
#include <queue>
#include <map> 
#include <set>
#include <string>
#include <functional>
#include <list>
#include <random>
#include <time.h>
#include <iomanip>
#include <assert.h>
#define int long long
#define double long double
#define oku7 1000000007
#define MAXN (int)1e+5 * 2+1
#define LL_MAX 9223372036854775807	//ない環境用
#define LL_HALFMAX 9223372036854775807 / 2	//ない環境用

using namespace std;
std::mt19937 mt((int)time(0));

int dx[4] = { 0, 1, 0, -1 }; // x軸方向への変位
int dy[4] = { 1, 0, -1, 0 }; // y軸方向への変位

int nC2(int n) {
	return n * (n - 1) / 2;
}

int DP[502][502];	//DP[l][r]:[l,r]に含まれる
int L[200000], R[200000], p[100000], q[100000];

signed main() {
	int N, K;
	bool zero = false;
	cin >> N >> K;
	vector<int> plus, minus;
	for (int i = 0; i < N; i++) {
		int inp;
		cin >> inp;
		if (inp == 0) {
			zero = true;
			plus.push_back(inp);
		}
		else if (inp < 0) minus.push_back(-inp);
		else plus.push_back(inp);
	}

	reverse(minus.begin(), minus.end());
	//i本だけ負側にいって戻ってくる
	int ans = LL_HALFMAX;
	for (int i = 0; i <= K; i++) {
		if (i == 0) {
			if (plus.size() <= K - 1) continue;
			ans = min(ans, plus[K - 1]);
		}
		else if (i == K) {
			if (minus.size() <= K - 1) continue;
			ans = min(ans, minus[K - 1]);
		}
		else {
			if (minus.size() <= i - 1 || plus.size() <= K - i - 1) continue;
			ans = min(ans, minus[i - 1] * 2 + plus[K - i - 1]);
		}
	}

	//i本だけ正側にいって戻ってくる
	for (int i = 0; i <= K; i++) {
		if (i == 0) {
			if (minus.size() <= K - 1) continue;
			ans = min(ans, minus[K - 1]);
		}
		else if (i == K) {
			if (plus.size() <= K - 1) continue;
			ans = min(ans, plus[K - 1]);
		}
		else {
			if (plus.size() <= i - 1 || minus.size() <= K - i - 1) continue;
			ans = min(ans, plus[i - 1] * 2 + minus[K - i - 1]);
		}
	}
	cout << ans << "\n";

	return 0;
}

Measured memory_bytes: 1656
#include<iostream>

using namespace std;

int main()
{
    int a,b,t;
    while(scanf("%d %d %d",&a,&b,&t)==3)
    {
        int c,m;
        c = t/a;
        m = c*b;
        cout<<m<<endl;

    }
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <math.h>
#include <cstdint>

#include <map>
 
using namespace std;
typedef long long ll;



ll ans,mx,sum,mn=1e8;
int main(){
	ll n,m;
	cin>>n>>m;
	if(n==m) cout<<"Yes";
	else cout<<"No";
}


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

int subtree_size(const vector<vector<int>> &G, vector<int> &S, int v, int p){
  ++S[v];
  for(auto v_ : G[v]){
    if(v_ == p) continue;
    S[v] += subtree_size(G,S,v_,v);
  }
  return S[v];
}

void dfs(const vector<vector<int>> &G, const vector<int>& C, const vector<int> &S,
         vector<int>& D, vector<int>& P, vector<long long>& T, int v, int p){
  int c = C[v];
  int t = P[c];
  for(auto v_ : G[v]){
    if(v_ == p) continue;
    P[c] = v_;
    dfs(G,C,S,D,P,T,v_,v);
    T[c] -= ((long long)(S[v_]-D[v_]))*(S[v_]-D[v_]+1)/2;
  }
  if(t >= 0) D[t] += S[v];
  P[c] = t;
}

void dfs2(const vector<vector<int>> &G, const vector<int> &C, const vector<int> &S,
          vector<int> &cnt, vector<int> &SZ, int v, int p){
  int c = C[v];
  if(!cnt[c]) SZ[c] -= S[v];
  ++cnt[c];
  for(auto v_ : G[v]){
    if(v_ == p) continue;
    dfs2(G,C,S,cnt,SZ,v_,v);
  }
  --cnt[c];
}

int main(){
  long long N;
  cin >> N;
  vector<int> C(N);
  for(int i = 0; i < N; ++i) cin >> C[i], --C[i];
  vector<vector<int>> G(N);
  for(int i = 1; i < N; ++i){
    int a, b;
    cin >> a >> b;
    --a,--b;
    G[a].push_back(b);
    G[b].push_back(a);
  }
  vector<int> S(N,0);
  subtree_size(G,S,0,0);
  vector<long long> T(N,N*(N+1)/2);
  vector<int> D(N), P(N,-1);
  dfs(G,C,S,D,P,T,0,-1);
  vector<int> SZ(N,N), cnt(N);
  dfs2(G,C,S,cnt,SZ,0,-1);
  for(int i = 0; i < N; ++i){
    T[i] -= ((long long)SZ[i])*(SZ[i]+1)/2;
  }
  for(auto e : T)
    cout << e << endl;
}


Measured memory_bytes: 48604
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<utility>
#include<tuple>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>

using namespace std;

using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

#define BIL ((ll)1e9)
#define MOD ((ll)1e9+7)
#define INF (1LL<<60)           //1LL<<63でオーバーフロー
#define inf (1<<29)             //1<<29でオーバーフロー

int main(int argc,char* argv[]){
    ll a,b;
    int k;
    cin >> a >> b >> k;

    for(ll i=a;i<min(a+k,b);i++){
        cout << i << endl;
    }

    for(int i=b-k+1;i<=b;i++){
        if(i<min(a+k,b))continue;
        cout << i << endl;
    }

    return 0;
}


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

#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;

typedef long long ll;

const int INF = 1 << 30;
const ll LLINF = 1LL << 62;

int mod = 1000000007;

int main(void){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int A, B, T; cin >> A >> B >> T;
    int now = 0;
    int ans = 0;
    while(now + A <= T){
        ans += B;
        now += A;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
/*
 * wafuIroha.cpp
 *
 *  Created on: 2020/02/23
 *      Author: black
 */
#include <iostream>
using namespace std;

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


	if (a*b > c*d){
		cout << a*b << endl;
	}
	else{
		cout << c*d << endl;
	}

	return 0;
}


Measured memory_bytes: 256
import java.math.BigDecimal;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		BigDecimal a = sc.nextBigDecimal();
		BigDecimal b = sc.nextBigDecimal();

		if (a.compareTo(b) > 0){
			System.out.println("GREATER");
		} else if (a.compareTo(b) < 0){
			System.out.println("LESS");
		} else {
			System.out.println("EQUAL");
		}

	}

}


Measured memory_bytes: 23252
#include <iostream>
#include<vector>
#include <math.h>

using namespace std;
int main(void) {
    int a, b, c, d;
    scanf("%d %d %d %d", &a, &b, &c, &d);
    if (abs(c - a) <= d) {
        cout << "Yes" << endl;
        return 0;
    }
    if (abs(c - b) <= d && abs(b - a) <= d) {
        cout << "Yes" << endl;
        return 0;
    }
    cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define For(i,a,b) for(int i=(a),i##_=(b);i<=i##_;i++)
#define Ror(i,a,b) for(int i=(a),i##_=(b);i>=i##_;i--)
#define Dor(i,x) for(int i=head[x];i;i=nxt[i])
#define PI pair<int,int> 
#define se second
#define M 500005
using namespace std;
map<int,int>mp[M];
map<int,int>::iterator it;
int n,m,tta;
int head[M*3],nxt[M*6],to[M*6],v[M*6],tot;
int X[M],Y[M];
int dis[M*3];
inline void Add(int x,int y,int z){
    nxt[++tot]=head[x];
    head[x]=tot;
    to[tot]=y,v[tot]=z;
}
inline void read(int &res){
    res=0;char p;
    while(p=getchar(),p<48);
    do res=(res<<1)+(res<<3)+(p^48);
    while(p=getchar(),p>47);
}
inline int Id(int x,int c){
    int &res=mp[x][c];
    if(!res){
		res=++tta;
    	Add(x,tta,1);
    	Add(tta,x,0);
	}
	return res;
}
int Q[M<<3],L,R;
int bfs(int st){
    L=R=M*3;
    memset(dis,63,sizeof dis);
    dis[st]=0;
    Q[++R]=st;
    while(L<=R){
        int x=Q[++L];
        if(x==n)return dis[x];
		Dor(i,x){
            int y=to[i];
            if(dis[y]>dis[x]+v[i]){
                dis[y]=dis[x]+v[i];
                if(!v[i])Q[L--]=y;
                else Q[++R]=y;
            }
        }
    }
    return -1;
}
int main(){
//  freopen("subway.in","r",stdin);
//  freopen("subway.out","w",stdout);
    int x,y,c;
    read(n),read(m);tta=n;
    For(i,1,m){
        read(x),read(y),read(c);
        x=Id(x,c),y=Id(y,c);
        Add(x,y,0),Add(y,x,0);
    }
    printf("%d\n",bfs(1));
    return 0;
}

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

using namespace std;

int main(){
//    freopen("date.in", "r", stdin);
//    freopen("date.out", "w", stdout);
    char s[10]; cin >> s;
    if (s[2]==s[3] && s[4]==s[5]) cout << "Yes";
    else cout << "No";
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define lvector vector<ll>
#define cvector vector<char>
#define svector vector<string>
#define lque queue<ll>
#define lpque priority_queue<ll>
#define dlpque priority_queue<ll,lvector,greater<ll>>
#define P pair<ll,ll>
#define ALL(a) a.begin(),a.end()
#define RALL(a) a.rbegin(),a.rend()
#define rep(i,n) for(ll i=0; i<n; ++i)
#define print(a) cout << (a) << endl

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll r;cin>>r;print(3*r*r);
  return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>

#include <iostream>
#include <complex>
#include <string>
#include <algorithm>
#include <numeric>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>

#include <functional>
#include <cassert>

typedef long long ll;
using namespace std;

#ifndef LOCAL
#define debug(x) ;
#else
#define debug(x) cerr << __LINE__ << " : " << #x << " = " << (x) << endl;

template <typename T1, typename T2>
ostream &operator<<(ostream &out, const pair<T1, T2> &p) {
  out << "{" << p.first << ", " << p.second << "}";
  return out;
}

template <typename T>
ostream &operator<<(ostream &out, const vector<T> &v) {
  out << '{';
  for (const T &item : v) out << item << ", ";
  out << "\b\b}";
  return out;
}
#endif

#define mod 1000000007 //1e9+7(prime number)
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define SIZE 200010


int main(){
  string s;

  cin >> s;

  stack<int> st;

  for(int i=0;i<s.size();i++){
    st.push(s[i] - '0');

    while(st.size() >= 2) {
      int p = st.top(); st.pop();
      int q = st.top(); st.pop();

      if (p == q) {
        st.push(q);
        st.push(p);
        break;
      }
    }
  }

  cout << s.size() - st.size() << endl;

  return 0;
}


Measured memory_bytes: 768
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define rep2(i,n) for(int i=0;i<=n;i++)
#define repr(i,a,n) for(int i=a;i<n;i++)
#define all(a) a.begin(),a.end()
#define P pair<long long,long long>
#define double long double
#define vector2(a,b,c) vector<vector<int>> a(b/*縦！w*/,vector<int>(c/*横！w*/))
#define INF 1e10
#define MOD 1e9+7
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; }
using Graph = vector<vector<int>>;
signed main(){
  int a,b;
  cin>>a>>b;
  if(a<10)
    cout<<b+100*(10-a)<<endl;
    else
      cout<<b<<endl;
}

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

int main(){
	int x;
	cin>>x;
	bool f=0, b=0;
	int a=1;
	vector<int> v;
	v.push_back(2);
	while(f==0){
		a+=2;
		b=0;
		rep(i, v.size()){
			if(a%v[i]==0)
				b=1;
		}
		if(b==0){
			v.push_back(a);
			if(x<=a){
				f=1;
			}
		}
	}
	if(x<=2){
		cout<<2<<endl;
		return 0;
	}
	cout<<v[v.size()-1]<<endl;
	return 0;
}

Measured memory_bytes: 384
#include<algorithm>//sort,二分探索,など
#include<bitset>//固定長bit集合
#include<cmath>//pow,logなど
#include<complex>//複素数
#include<deque>//両端アクセスのキュー
#include<functional>//sortのgreater
#include<iomanip>//setprecision(浮動小数点の出力の誤差)
#include<iostream>//入出力
#include<iterator>//集合演算(積集合,和集合,差集合など)
#include<map>//map(辞書)
#include<numeric>//iota(整数列の生成),gcdとlcm(c++17)
#include<queue>//キュー
#include<set>//集合
#include<stack>//スタック
#include<string>//文字列
#include<unordered_map>//イテレータあるけど順序保持しないmap
#include<unordered_set>//イテレータあるけど順序保持しないset
#include<utility>//pair
#include<vector>//可変長配列

using namespace std;
typedef long long ll;

//マクロ
//forループ関係
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
//Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
//xにはvectorなどのコンテナ
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x)) //最大値を求める
#define MIN(x) *min_element(ALL(x)) //最小値を求める
//定数
#define INF 9000000000000000000 //9e18:極めて大きい値
#define MOD 1000000007 //10^9+7:合同式の法
#define MAXR 100000 //10^5:配列の最大のrange(素数列挙などで使用)
#define LOGMAXR 18 // floor(log2(10^5)) + 1: 配列の最大のrangeのlog
//略記
//#define PB push_back //vectorヘの挿入
//#define MP make_pair //pairのコンストラクタ
//#define F first //pairの一つ目の要素
//#define S second //pairの二つ目の要素

int main(){
  ll N;
  cin >> N;
  char S[N];
  REP(i, N) cin >> S[i];
  ll nR, nG, nB;
  nR = 0;
  nG = 0;
  nB = 0;
  for(auto& c : S){
    if(c == 'R') nR += 1;
    if(c == 'G') nG += 1;
    if(c == 'B') nB += 1;
  }
  ll nM = 0;
  REP(i, N){
    FOR(j, 1, N){
      if(i + j * 2 >= N) break;
      auto& a = S[i];
      auto& b = S[i + j];
      auto& c = S[i + j * 2];
      if(a == b) continue;
      if(b == c) continue;
      if(c == a) continue;
      nM += 1;
    }
  }
  cout << (nR * nG * nB - nM) << endl;

  return 0;
}


Measured memory_bytes: 3152
n=int(input())
if n%2==1 or n==0 or n==1:
  print(0)
else:
  l=n//2
  k=0
  while l>=5:
    l/=5
    k+=1
  c=0
  for i in range(1,k+1):
    c+=n//(2*5**i)
  print(c)

Measured memory_bytes: 3060
#include <iostream>
#include <algorithm>
#include <string> 
#include <vector>
#include <iomanip>
#include <math.h>
using namespace std;

int main()
{
	string s;
	cin >> s;
	if (s[0] == s[2]) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n - 1; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
using namespace std;

int main(){
  int x;
  cin >> x;
  int ans = -1;
  bool flag;
  
  FOR(i,x,100010){
    flag = true;
    FOR(j,2,floor(sqrt(i))+1){
      if(i%j == 0){
        flag = false;
        break;
      }
    }
    if(flag){
      ans = i;
      break;
    }
  }
  
  cout << ans;
  return 0;
}

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

using ll = long long;
#define rep(inc, bgn, end) for (int inc = bgn; inc < end; ++inc)
#define repe(inc, bgn, end) for (int inc = bgn; inc <= end; ++inc)

using namespace std;

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

int main() {
    int n, x;
    cin >> n >> x;

    int ans = -1;
    rep(i, 0, n) {
        int pos;
        cin >> pos;
        int len = abs(x - pos);
        if (ans < 0) {
            ans = len;
        } else {
            ans = gcd(ans, len);
        }
    }

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


Measured memory_bytes: 256
a = int(input())
c = 0

for i in range(1,10):
  j = 10-i
  if a%j == 0:
    a = a/j
    c += 1
  if c == 2:
    break
  if a%j == 0:
    a = a/j
    c += 1
  if c == 2:
    break
if a == 1 and c <= 2:
  print('Yes')
else:
  print('No')


Measured memory_bytes: 3060
#define HAVE_STRUCT_TIMESPEC
#include<bits/stdc++.h>
using namespace std;
int vis[100007],tim[100007];
int main(){
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int n,m;
    cin>>n>>m;
    int sum=0,num=0;
    for(int i=1;i<=m;++i){
        int x;
        string s;
        cin>>x>>s;
        if(s[0]=='A'){
            if(!vis[x]){
                ++num;
                sum+=tim[x];
            }
            vis[x]=1;
        }
        else{
            if(!vis[x])
                ++tim[x];
        }
    }
    cout<<num<<" "<<sum;
    return 0;
}


Measured memory_bytes: 1152
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int d[200001];
int main(void){
    int n;
    cin>>n;
    for(int i=0;i<n;i++){
        int a;
        cin>>a;
        d[a]=i;
    }
    ll ans=0;
    set<ll> s; 
    s.insert(-1),s.insert(n);
    for(int i=0;i<n;i++){
        auto cnt=s.lower_bound(d[i+1]);
        ll l=*cnt;
        cnt--;
        ll r=*cnt;
        ans+=(i+1)*(l-d[i+1])*(d[i+1]-r);
        s.insert(d[i+1]);
        
        
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 10368
#include <stdio.h>

int main(void) {
    double m, f, b, c;
    
    scanf("%lf %lf %lf", &m, &f, &b);
    
    c = b - m;
    
    if(c > 0){
        if(f - c >= 0){
            printf("%.0f\n", c);
        } else {
            printf("NA\n");
        }
    } else {
        printf("0\n");
    }
    
    return 0;
}



Measured memory_bytes: 2104
import Data.List
main = do
  n <- getLine
  xs <- map read . words <$> getLine
  putStrLn . show $ solve xs
 
solve :: [Int] -> Int
solve xs =  snd $ foldl calc (0,0) (reverse . sort  $ xs)

calc (i,r) x
 | i `mod` 2 == 0 = (i+1, r+x)
 | otherwise      = (i+1, r-x)

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

const int V = 10;
int d[V][V];
void warshall_floyde(){
    for(int k = 0; k < V; k++){
        for(int i = 0; i < V; i++){
            for(int j = 0; j < V; j++) d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
        }
    }
}

int main(){
    int H, W; cin >> H >> W;
    rep(i, 0, 10){
        rep(j, 0, 10){
            cin >> d[i][j];
        }
    }
    warshall_floyde();
    map<int,int> mp;
    rep(i, 0, H) rep(j, 0, W){
        int a; cin >> a;
        mp[a]++;
    }
    ll ans = 0;
    for(auto e: mp){
        if(e.first == -1) continue;
        ans += e.second * d[e.first][1];
    }
    cout << ans << endl;

}

Measured memory_bytes: 256
#include<iostream>
#include<sstream>
#include<vector>
#include<map>
#include<queue>
#include<complex>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cassert>
using namespace std;

#define rep(i,n) for(int i=0;i<(int)n;i++)
#define fr(i,c) for(__typeof(c.begin()) i=c.begin();i!=c.end();i++)
#define pb push_back
#define mp make_pair
#define all(c) c.begin(),c.end()

typedef vector<int> vi;
typedef pair<int,int> pi;
typedef long long ll;
const int inf=(int)1e9;
const double EPS=1e-9, INF=1e12;

int n,m,w;
int wi[15], nw;
int bit[10000],sum[1<<15];
int dp[1<<15];
int main(){
	cin>>n>>m>>w;
	rep(i,n){
		int k; cin>>k;
		rep(j,k){
			cin>>wi[nw];
			bit[i]|=1<<nw++;
		}
	}
	rep(i,1<<nw)rep(j,nw)if(i&1<<j)sum[i]+=wi[j];
	rep(i,1<<nw)dp[i]=inf;
	dp[0]=0;
	rep(i,1<<nw)for(int j=i;j;j=j-1&i){
		if(sum[j]<=w)dp[i]=min(dp[i],dp[i-j]+1);
	}
	int top=0;
	rep(i,n)if(bit[i])top=i;
	if(top==0){
		cout<<0<<endl; return 0;
	}
	int ans=abs(m-1-top), h=0;
	for(int i=top;i>0;i--){
		h+=bit[i];
		ans+=dp[h]*2-1;
	}
	cout<<ans<<endl;
	
	return 0;
	
}

Measured memory_bytes: 1088
#[macro_use]
mod input {

use std;
use std::io;

const SPLIT_DELIMITER: char = ' ';

#[macro_export]
#[allow(unused_macros)]
macro_rules! input {
    ( $($x:expr ),*) => {
        {
            let temp_str = input_line_str();
            let mut split_result_iter = temp_str.split_whitespace();
                $(
                let buf_split_result = split_result_iter.next();
                let buf_split_result = buf_split_result.unwrap();
                    ($x) = buf_split_result.parse().unwrap();
                )*
        }
    };
}

#[allow(dead_code)]
pub fn input_line_str() -> String {
    let mut s = String::new();
    io::stdin().read_line(&mut s).unwrap();
    s.trim().to_string()
}

#[allow(dead_code)]
pub fn p<T>(t: T)
where
    T: std::fmt::Display,
{
    println!("{}", t);
}

#[allow(dead_code)]
pub fn input_vector2d<T>(line: usize) -> Vec<Vec<T>>
where
    T: std::str::FromStr,
{
    let mut v: Vec<Vec<T>> = Vec::new();

    for _ in 0..line {
        let vec_line = input_vector();
        v.push(vec_line);
    }
    v
}

#[allow(dead_code)]
pub fn input_vector<T>() -> Vec<T>
where
    T: std::str::FromStr,
{
    let mut v: Vec<T> = Vec::new();

    let s = input_line_str();
    let split_result = s.split(SPLIT_DELIMITER);
    for z in split_result {
        let buf = match z.parse() {
            Ok(r) => r,
            Err(_) => panic!("Parse Error"),
        };
        v.push(buf);
    }
    v
}

#[allow(dead_code)]
pub fn str2vec(s: &str) -> Vec<char> {
    let mut v: Vec<char> = Vec::new();
    for c in s.chars() {
        v.push(c);
    }
    v
}

}

use input::*;
use std::cmp;

fn main() {
    let (n, k): (usize, isize);
    input!(n);
    input!(k);
    let x = input_vector::<isize>();
    let mut ans = 0;
    for xi in x {
        ans += 2 * cmp::min(xi, (k - xi).abs());
    }
    p(ans);
}

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

/* メモリ食い過ぎ注意 */
#define int long long

typedef long long ll;

ll gcd(ll a, ll b)
{
    if (a < b)
        gcd(b, a);
    if (b == 0)
        return a;
    int r;
    while ((r = a % b))
    {
        a = b;
        b = r;
    }
    return b;
}

/* define const */
const ll INF = (1ll << 60);
const ll MOD = (ll)1e9 + 7;
/* end defineing */

signed main()
{
    double r, g;
    cin >> r >> g;

    cout << (g - r) * 2 + r << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <algorithm>
using namespace std;
int n,a[200000],ans;
int main()
{    int i,j,Max,Min;
     scanf("%d",&n);
     a[1]=1;
     if(n<10){printf("%d",n);return 0;}
     int stand=n/10*10;
        a[n/10*10]=(n/10)*(n/10)+8;
    for(i=stand+1;i<=n;i++)
    {   int ans=0;
        int wei=i%10;
        int shou=i;
        while(shou/10!=0)shou=shou/10;
       for(j=1;j<=i;j++)
       {  if(j%10!=shou)continue;
          int k=j;
          while(k/10!=0)k=k/10;
          if(k==wei)
          {  if(j!=i)ans+=2;
             else ans++;
          }
       }
        a[i]=a[i-1]+ans;
    }

   printf("%d",a[n]);

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <stdio.h>
#include <vector>
#include <string>
#include <algorithm>
#include <numeric>
#include <iomanip>
using ll = long long;
using namespace std;
//#define int long long

#define rep(i, n) for (int i = 0; i < (n); i++)
#define irep(i, n) for (int i = 0; i <= (n); i++)
#define rrep(i, n) for (int i = (n)-1; i >= 0; i--)
#define rirep(i, n) for (int i = n; i >= 0; i--)
int factorical(int n) {
	int sum = 1;
	for (int i = 1; i <= n; ++i)
	{
		sum *= i;
	}
	return sum;
}

vector<int> divisors(int n) {
	vector<int> res;
	for (int i = 1; i * i <= n; ++i) {
		if (n % i != 0) continue;
		res.push_back(i);
		if (n / i == i) continue; // 上の行で追加済み。
		res.push_back(n / i);
	}
	return res;
}
vector<ll> divisors_ll(ll n) {
	vector<ll> res;
	for (ll i = 1; i * i <= n; ++i) {
		if (n % i != 0) continue;
		res.push_back(i);
		if (n / i == i) continue; // 上の行で追加済み。
		res.push_back(n / i);
	}
	return res;
}


void printVector(const vector<int>& vec) {
	for (int value : vec) {
		cout << value << " ";
	}
	cout << endl;
}



int main() {
	ll n, a, b, ab, ans, mod;
	cin >> n >> a >> b;
	ab = n / (a+b);
	mod = n % (a+b);
	(mod > a) ? mod = a : mod = mod;
	ans = a * ab + mod;
	cout << ans << endl;
	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 = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();
        int d = sc.nextInt();

        while (true) {
            c-=b;
            if (c<=0) {
                System.out.println("Yes");
                return;
            }
            a-=d;
            if (a<=0) {
                System.out.println("No");
                return;
            }
        }
    }
}


Measured memory_bytes: 35724
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 100 + 10;
const int M = 1000000007;
const double eps = 1e-9;
const double PI = acos(-1);
const ll oo = 10000000000000000;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, ll> ii;
#define pb push_back 
#define all(c) (c).begin(),(c).end()
int n,v[N],level[N],vis[N],vs;
vi g[N];
vector<ii> E;
bool bfs(){
	vis[0]=++vs;
	queue<int> q;
	q.push(0);
	while(!q.empty()){
		int u=q.front();
		q.pop();
		for(int i=0; i<g[u].size(); ++i){
			int e=g[u][i];
			int d=E[e].first;
			ll c=E[e].second;
			if(!c || vis[d]==vs)continue;
			vis[d]=vs;
			level[d]=level[u]+1;
			q.push(d);
		}
	}
	return vis[101]==vs;
}
int adj[N];
ll dfs(int u, ll fl){
	if(u==101)
		return fl;
	for(int &i=adj[u]; i<g[u].size(); ++i){
		int e=g[u][i];
		int d=E[e].first;
		ll c=E[e].second;
		if(c && level[d]==level[u]+1){
			ll cc=dfs(d, min(fl, (ll)c));
			if(cc){
				E[e].second-=cc;
				E[e^1].second+=cc;
				return cc;
			}
		}
	}
	return 0;
}
ll dinic(){
	ll flow=0;
	while(bfs()){
		memset(adj, 0, sizeof(adj));
		while(ll cc=dfs(0, oo))
			flow+=cc;
	}
	return flow;
}
void addEdge(int a, int b, ll c){
	g[a].pb(E.size());
	E.pb(ii(b,c));
	g[b].pb(E.size());
	E.pb(ii(a,0));
}
int main(){
	cin>>n;
	for(int i=1; i<=n; ++i){
		cin>>v[i];
		v[i]*=-1;
	}
	for(int i=1; i<=n; ++i)
		for(int j=i+i; j<=n; j+=i)
			addEdge(i,j,oo);
	ll allpos=0;
	for(int i=1; i<=n; ++i)
		if(v[i]>=0)
			addEdge(0,i,v[i]);
		else
			addEdge(i,101,-v[i]),allpos-=v[i];
	cout<<allpos-dinic()<<endl;
	return 0;
}

Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, a, b) for (int i = a; i < b; i++)
using namespace std;

#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <tuple>
#include <map>
#include <unordered_map>
#include <queue>
#include <set>
#include <stack>
#include <bitset>

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

	vector<uint64_t> L(87);
	L.at(0) = 2;
	L.at(1) = 1;

	for (uint64_t i = 2; i <= 86; i++) {
		L.at(i) = L.at(i - 1) + L.at(i - 2);	
	}

	cout << L.at(N) << endl;
}

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

using namespace std;
int main (){
    int h,w;
    cin >> h >> w;
    bool pic[h][w];
    string tmp;
    for (int i = 0; i < h; i++){
        cin >> tmp ;
        for (int j = 0; j < w; j++){
            if(tmp[j]=='*') pic[i][j]=1;
            else            pic[i][j]=0;
        }
    }

    for (int i = 0; i < h; i++){
        for (int j = 0; j < w; j++){
            if(pic[i][j]) cout << "*";
            else          cout << ".";
        }
        cout << "\n";
        for (int j = 0; j < w; j++){
            if(pic[i][j]) cout << "*";
            else          cout << ".";
        }
        cout << "\n";
    }
}

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

int main() {
    cin.tie(0)->sync_with_stdio(false);

	int n; cin >> n;
	ll maxP, minP, maxS, minS;
	maxP = maxS = INT_MIN;
	minP = minS = INT_MAX;
	REP(i, n) {
		ll x, y; cin >> x >> y;
		maxP = max(maxP, x + y);
		minP = min(minP, x + y);
		maxS = max(maxS, x - y);
		minS = min(minS, x - y);
	}
	cout << max(maxP - minP, maxS - minS) << '\n';
    return 0;
}


Measured memory_bytes: 3644
#include <algorithm>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <iomanip>
#include <iostream>
#include <string>
#include <vector>

using namespace std;

int main() {
    int n = 0;
    cin >> n;
    int a = 0, b = 0, c = 0;
    cin >> b >> c;
    n -= 2;
    int count = 0;
    while (n > 0) {
        a = b;
        b = c;
        cin >> c;
        if ((b >= a && b <= c) || (b >= c && b <= a)) count++;
        n--;
    }
    cout << count << endl;
    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
 #include <cstdlib>
 #include <iostream>
 #include <fstream>
 #include <sstream>
 #include <set>
 #include <map>
 #include <vector>
 #include <list>
 #include <algorithm>
 #include <cstring>
 #include <cmath>
 #include <string>
 #include <stack>
 #include <queue>
 #include <bitset>     //UWAGA - w czasie kompilacji musi byc znany rozmiar wektora - nie mozna go zmienic
 #include <cassert>
 #include <iomanip>        //do setprecision
 #include <ctime>
 #include <complex>
 using namespace std;

 #define FOR(i,b,e) for(int i=(b);i<(e);++i)
 #define FORQ(i,b,e) for(int i=(b);i<=(e);++i)
 #define FORD(i,b,e) for(int i=(b)-1;i>=(e);--i)
 #define REP(x, n) for(int x = 0; x < (n); ++x)

 #define ST first
 #define ND second
 #define PB push_back
 #define PF push_front
 #define MP make_pair
 #define LL long long
 #define ULL unsigned LL
 #define LD long double
 #define pii pair<int,int>
 #define pll pair<LL,LL>

 const double pi = 3.14159265358979323846264;
 const int mod=1000000007;
 LL lg;
 LL sub(LL a,LL b){
	if(a>=b){
		return a-b;
	}else{
		return a+lg-b;
	}
	return 0;
 }

int main(){
	LL ln,n;
	cin>>ln>>n;
	lg=ln;
	vector<LL> a(n+3,0),b(n+3,0),c(n+3,0);
	FOR(i,0,n)cin>>a[i];
	FOR(i,0,n){
		b[i+1]=a[i];
		b[i+1]+=b[i];
	}
	FORD(i,n,0){
		c[n-i]=ln-a[i];
		c[n-i]+=c[n-1-i];
	}
	/*
	FOR(i,0,n+1){
		cerr<<a[i]<<" "<<b[i]<<" "<<c[i]<<endl;
	}//*/

	LL ans=0;
	FOR(i,0,n){
		FOR(t,0,2){
			int l=i-1,r=i+1,d=0;
			LL mx=0;
			if(t==0){
				d=0;
				mx=a[i];
				if(l+1>=n-1-r+1){
					mx+=2*(b[l+1]-b[l+1-(n-1-r+1)])+2*c[n-1-r+1];//n=4,i=2->l=1,r=3->mx+=2*(c[2]-c[1])+2*b[1]
				}else{
					mx+=2*b[l+1]+2*(c[n-1-r+1]-c[n-1-r+1-(l+1+1)]);//n=4,i=1->l=0,r=2->mx+=2*b[1]+2*(c[2]-c[0])
				}
			}else{
				d=1;
				mx=ln-a[i];
				if(l+1<=n-1-r+1){
					mx+=2*b[l+1]+2*(c[n-1-r+1]-c[n-1-r+1-(l+1)]);//n=2,i=0->l=-1,r=1
				}else{
					mx+=2*(b[l+1]-b[l+1-(n-1-r+1+1)])+2*c[n-1-r+1];//n=4,i=2->l=1,r=3
				}
			}
			//cerr<<"t:"<<t<<" i:"<<i<<" mx:"<<mx<<endl;
			ans=max(mx,ans);
		}
	}

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


Measured memory_bytes: 4992
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
    public static void main(String[] args) {
        try {
            // 標準入力
            InputStreamReader isr = new InputStreamReader(System.in);
            BufferedReader br = new BufferedReader(isr);
            String str[] = br.readLine().split(" ");
            int a = Integer.parseInt(str[0]);
            int b = Integer.parseInt(str[1]);
            int c = Integer.parseInt(str[2]);
            if (a == b) {
                System.out.println(c);
            } else if (a == c) {
                System.out.println(b);
            } else {
                System.out.println(a);
            }
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}


Measured memory_bytes: 21076
import java.util.Scanner;
public class Main {
	public static void main(String[] args){
		Scanner sc=new Scanner(System.in);
        int count=1;
        while(true){
            int a=sc.nextInt();
            if(a==0)
                break;
            System.out.println("Case "+count+": "+a);
            count++;
        }
    }
}


Measured memory_bytes: 41520
#include <stdio.h>
#include <algorithm>
#include <cmath>
#include <queue>
#include <vector>
#include <map>
#include <set>

using namespace std;

typedef long long LL;
typedef pair<int , int> P2;
typedef pair<pair<int , int> , int> P3;
typedef pair<pair<int , int> , pair<int , int> > P4;
#define Fst first
#define Snd second
#define MP(a , b) make_pair((a) , (b))
#define M3P(a , b , c) make_pair(make_pair((a) , (b)) , (c))
#define M4P(a , b , c , d) make_pair(make_pair((a) , (b)) , make_pair((c) , (d)));
#define Mx(a , b) ((a) > (b) ? (a) : (b))
#define Mn(a , b) ((a) < (b) ? (a) : (b))

const double EPS = 1e-10;
const int INF = 2147483647;

int N , K;
int d , x;

int main(){
	scanf("%d%d" , &N , &K);
	for(int i = 0 ; i < K ; ++i){
		scanf("%d" , &x);
		d += (1 << x);
	}
	int z = 0;
	for(int a = N ; a > 0 ; a /= 10){
		if(d / (1 << (a % 10)) % 2 == 1){
			++a;
			for(int i = 0 ; i < z ; ++i){
				a *= 10;
			}
			N = a;
			z = 0;
			a = N * 10;
			continue;
		}
		++z;
	}
	printf("%d\n" , N);
	return 0;
}


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

int n;
vector<int> G[110];
int d[110];

void bfs(){
  queue<int> que;
  for(int i=0; i<n; i++){
    d[i] = -1;
  }
  d[0] = 0;
  que.push(0);
  while(!que.empty()){
    int v = que.front(); que.pop();
    for(int i=0; i<G[v].size(); i++){
      int nv = G[v][i];
      if(d[nv] < 0){
        que.push(nv);
        d[nv] = d[v] + 1;
      }
    }
  }
}

int main(){
  cin >> n;
  for(int i=0; i<n; i++){
    int u, k; cin >> u >> k;
    for(int i=0; i<k; i++){
      int c; cin >> c;
      G[u-1].push_back(c-1);
    }
  }
  bfs();
  for(int i=0; i<n; i++){
    cout << i+1 << " " << d[i] << endl;
  }
}


Measured memory_bytes: 3160
#include <iostream>
#include <algorithm>
#include <cmath>
#include <map>
#include <vector>
#include <queue>
#include <functional>
#include <string>
#include <stack>
#include <set>
#include <sstream>
#include <iomanip>
#include <limits>
#include <cstring>

using namespace std;
using ll = long long;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef pair<string, string> sP;
typedef pair<ll, pair<ll, ll>> PP;

const ll mod = 1e4;
const ll MOD = 1e9 + 7;
const ll MOD2 = 998244353;
const ll INF = 1 << 30;
const ll INF2 = 9e18;
const double INF3 = 9e14;
const int dx[4] = { 1,0,-1,0 }, dy[4] = { 0,1,0,-1 };
const int tx[8] = { -1,0,1,-1,1,-1,0,1 }, ty[8] = { -1,-1,-1,0,0,1,1,1 };
#define ALL(x) (x).begin(),(x).end()
#define ALLR(x) (x).rbegin(),(x).rend()
#define pb push_back
#define eb emplace_back
#define fr first
#define sc second

ll bit[1000010];
ll n, k, a[200010], sum[200010], t[200010], ans;

void add(ll a, ll w) {
	for (int x = a; x <= n + 2; x += x & -x) bit[x] += w;
}
int SUM(ll a) {
	ll ret = 0;
	for (int x = a; x > 0; x -= x & -x) ret += bit[x];
	return ret;
}

int main() {
	cin >> n >> k;
	for (int i = 0;i < n;i++) {
		cin >> a[i];
		a[i] -= k;
		sum[i + 1] = t[i + 1] = sum[i] + a[i];
	}
	sort(t, t + n + 1);
	ll p = unique(t, t + n + 1) - t;
	for (int i = 0;i <= n;i++) {
		sum[i] = lower_bound(t, t + p + 1, sum[i]) - t + 1;
	}
	for (int i = 0;i <= n;i++) {
		ans += SUM(sum[i]);
		add(sum[i], 1);
	}
	cout << ans << endl;
	return 0;
}

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

int main(){
  int N;
  cin >> N;
  map<int,int> m;
  for (int i=0;i<N;i++){
    int x;
    cin >> x;
    m[x]++;
    m[x-1]++;
    m[x+1]++;
  }
  int ans=0;
  for (auto x : m){
    int y=x.second;
    ans=max(ans,y);
  }
  cout << ans << endl;
}

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

int main() {
  int n;
  while(cin >> n && n) {
    string s[5];
    for(int i=0; i<5; i++) cin >> s[i];
    int r=0;
    for(int i=0; i<5; i++) {
      for(int j=0; j<n; j++) {
        for(int k=j+1; k<n; k++) {
          if(s[i][j]=='X'&&s[i][k]=='X') r|=1<<(k-j-1);
        }
      }
    }
    int mod=1<<n,dp[1<<n][11];
    for(int i=0; i<(1<<n); i++)for(int j=0; j<11; j++)dp[i][j]=1<<29;
    dp[0][0]=0;
    for(int i=0; i<10; i++) {
      for(int k=0; k<3; k++) {
        for(int t=0; t<(1<<n); t++) {
          if(dp[t][i]==1<<29) continue;
          dp[t*2%mod][i]=min(dp[t*2%mod][i],dp[t][i]+1);
          bool f=1;
          for(int j=0; j<n; j++) {
            if((t&(1<<j))&&(r&(1<<j))) f=0;
          }
          if(f) dp[(t*2|1)%mod][i+1]=min(dp[(t*2|1)%mod][i+1],dp[t][i]+1);
        }
      }
    }
    int ans=1<<29;
    for(int t=0; t<(1<<n); t++) ans=min(ans,dp[t][10]+n-1);
    cout << ans << endl;
  }
  return 0;
}

Measured memory_bytes: 3140
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;

class A {
    static StreamWriter Out = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
    static void Main(string[] args) {
        string S, T;
        int A, B;
        string U;
        Input(out S, out T);
        Input(out A, out B);
        Input(out U);
        if(U.Equals(S)) {
            Print(A - 1, B);
        } else {
            Print(A, B - 1);
        }
        Out.Flush();
    }
    static T ChangeT<T>(string s) => (T)Convert.ChangeType(s, typeof(T));
    static void Input<A>(out A a) {
        var words = Console.ReadLine().Split(new[] { ' ' }, options: StringSplitOptions.RemoveEmptyEntries);
        a = ChangeT<A>(words[0]);
    }
    static void Input<A, B>(out A a, out B b) {
        var words = Console.ReadLine().Split(new[] { ' ' }, options: StringSplitOptions.RemoveEmptyEntries);
        a = ChangeT<A>(words[0]);
        b = ChangeT<B>(words[1]);
    }
    static void Input<A, B, C>(out A a, out B b, out C c) {
        var words = Console.ReadLine().Split(new[] { ' ' }, options: StringSplitOptions.RemoveEmptyEntries);
        a = ChangeT<A>(words[0]);
        b = ChangeT<B>(words[1]);
        c = ChangeT<C>(words[2]);
    }
    static void Input<A, B, C, D>(out A a, out B b, out C c, out D d) {
        var words = Console.ReadLine().Split(new[] { ' ' }, options: StringSplitOptions.RemoveEmptyEntries);
        a = ChangeT<A>(words[0]);
        b = ChangeT<B>(words[1]);
        c = ChangeT<C>(words[2]);
        d = ChangeT<D>(words[3]);
    }
    static void Input<A, B, C, D, E>(out A a, out B b, out C c, out D d, out E e) {
        var words = Console.ReadLine().Split(new[] { ' ' }, options: StringSplitOptions.RemoveEmptyEntries);
        a = ChangeT<A>(words[0]);
        b = ChangeT<B>(words[1]);
        c = ChangeT<C>(words[2]);
        d = ChangeT<D>(words[3]);
        e = ChangeT<E>(words[4]);
    }
    static void Input<A, B, C, D, E, F>(out A a, out B b, out C c, out D d, out E e, out F f) {
        var words = Console.ReadLine().Split(new[] { ' ' }, options: StringSplitOptions.RemoveEmptyEntries);
        a = ChangeT<A>(words[0]);
        b = ChangeT<B>(words[1]);
        c = ChangeT<C>(words[2]);
        d = ChangeT<D>(words[3]);
        e = ChangeT<E>(words[4]);
        f = ChangeT<F>(words[5]);
    }
    static void InputArray<T>(out T[] array) {
        array = Console.ReadLine().Split(new[] { ' ' }, options: StringSplitOptions.RemoveEmptyEntries).Select(s => ChangeT<T>(s)).ToArray();
    }
    static void Print<T>(T s) => Out.WriteLine(s);
    static void Print<T>(params T[] s) => Out.WriteLine(string.Join(" ", s));
    static void Print<T>(IEnumerable<T> e) => Out.WriteLine(string.Join(" ", e));
}

Measured memory_bytes: 13396
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define ALL(x) (x).begin(), (x).end()
typedef long long ll;
typedef pair<int, int> pii;
const int INF = 1e9;
const ll LINF = 1e15;
const int MOD = 1000000007;
const double PI = acos(-1);
int dx[4] = {0,1,0,-1};
int dy[4] = {1,0,-1,0};

const int NUM = 10;

int main() {
	int n;
	cin >> n;
	vector<vector<int>> f(n, vector<int>(NUM)), p(n, vector<int>(NUM+1));
	rep(i,n) rep(j,NUM) cin >> f[i][j];
	rep(i,n) rep(j,NUM+1) cin >> p[i][j];
	ll ans = -LINF;
	for (int bit = 1; bit < (1 << NUM); bit++) {
		ll t = 0;
		for (int k = 0; k < n; k++) {
			int c = 0;
			for (int i = 0; i < NUM; i++) {
				if ((bit & (1 << i)) && f[k][i]) c++;
			}
			t += p[k][c];
		}
		ans = max(ans, t);
	}
	cout << ans << endl;
}

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

int main(){
    char ch;
    int alphabet[26] = {0};
    while( scanf("%c",&ch) != EOF){
        
        if(isalpha(ch)){
            if(isupper(ch)){
                ch = tolower(ch);
            }
            alphabet[(int)(ch - 'a')]++;
        }
    }
    
    for(int i = 0; i < 26; i++){
        char c = 'a' + i;
        printf("%c : %d\n",c,alphabet[i]);
    }
    return 0;
}


Measured memory_bytes: 3212
#include <bits/stdc++.h>
#define SZ(v) int((v).size())
#define ALL(vec) begin(vec), end(vec)
using namespace std;
typedef long long i64;
template<typename T> inline bool uax(T &x, T y) {return (y > x) ? x = y, true : false;}
template<typename T> inline bool uin(T &x, T y) {return (y < x) ? x = y, true : false;}
#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); \
  stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
string to_string(char c) { return "'" + string(1, c) + "'";}
string to_string(string s) { return '"' + s + '"';}
string to_string(const char* s) { return to_string((string) s);}
template<typename A> string to_string(A);
template<typename A, typename B> string to_string(pair<A, B> p){
  return "(" + to_string(p.first) + ": " + to_string(p.second) + ")";}
template<typename A> string to_string(A v) {bool f = false; string r = "{"; 
  for (auto x: v) {if (f) r += ", "; r += to_string(x); f = true;} return r += "}";}
template<typename A> string to_string(vector<vector<A>> v) {string r; 
  for (auto x: v) r += "\n" + to_string(x); return r;}
void err(istream_iterator<string>) { cerr << endl; }
template<typename T,typename... Args> void err(istream_iterator<string> it, T a, Args... args) {
  cerr << *it << " =: " << to_string(a) << "; "; err(++it, args...); }
template<typename T> void kek(T ans) {cout << ans << endl; exit(0);}
int const MOD = 1e9 + 7;
long long const INF = 1e18 + 42;
/*************************************/

int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  
  int n, p, m;
  cin >> n >> p;
  cin >> m >> p;
  kek(n == m ? 0 : 1);
  
  
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
signed main(){
    int n;
    cin >> n;
    int a = sqrt(n);
    int b = 1e16;
    int c = 0;
    for(int i = 1; i <= a; i++){
       if(n % i == 0)
        c = n / i;
       if(i + c - 2 < b)
       b = i + c - 2;

       
    }
    cout << b << endl;
}

Measured memory_bytes: 256
//in the name of god
#include <bits/stdc++.h>
using namespace std;
#define MAX_N (int)2e5+20
#define INF 2e9+20
#define pb push_back
#define F first
#define S second
typedef long long LL;
#define int LL
typedef pair<int,int> pii;
const int delta=(int)1e9+7;
int  n,l,r=(1<<30)-1,a,b[MAX_N],h,mx,m;
bool can(int x){
	if(x==0) return 0;
	int y=0;
	for(int i=0;i<n;++i){
		if(b[i]<=mx) break;
		y+=b[i];
		--x;
		if(x==0) return y>=h;
	}
	y+=x*mx;
	return y>=h;
}
main(){
	ios_base::sync_with_stdio(false); cin.tie(0);
	cin>>n>>h;
	for(int i=0;i<n;++i){
		cin>>a>>b[i]; mx=max(a,mx);
	}
	sort(b,b+n);
	reverse(b,b+n);
	while(l<r){
		m=(l+r)>>1;
		if(can(m)) r=m;
		else l=m+1;
	}
	cout<<l;
	return cout<<endl,0;
}

Measured memory_bytes: 1024