akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <iostream>
#include <string>
#include <map>
#include <vector>

using namespace std;

int main() {
  for (;;) {
    int n, m;
    cin >> n;
    if (!n) return 0;
    map<string, int> ps;
    for (int i = 0; i < n; i++) {
      string s;
      cin >> s;
      cin >> ps[s];
    }
    cin >> m;
    map<string, vector<string> > rs;
    for (int i = 0; i < m; i++) {
      string s, q;
      int k;
      cin >> s >> k;
      for (int j = 0; j < k; j++) {
        cin >> q;
        rs[s].push_back(q);
      }
    }
    bool f;
    do {
      f = false;
      for (map<string, int>::iterator it = ps.begin(); it != ps.end(); ++it)
        if (!rs[it->first].empty()) {
          int s = 0;
          for (int j = 0; j < rs[it->first].size(); j++)
            s += ps[rs[it->first][j]];
          if (s < ps[it->first]) {
            f = true;
            ps[it->first] = s;
          }
        }
    } while (f);
    string s;
    cin >> s;
    cout << ps[s] << endl;
  }
}

Measured memory_bytes: 0
N,M,K = map(int,input().split())
ans = 0
mod = 998244353

def modinv(a, mod=998244353):
    return pow(a, mod-2, mod)

fac = [0]*(N+1)
fac[0] = 1
fac[1] = 1
for i in range(2,N+1):
    fac[i] = fac[i-1] * i % mod

def combi(n,r,mod=998244353):
    return( ( fac[n] * modinv(fac[r]) )%mod * modinv(fac[n-r]) % mod)

z = M*(pow(M-1,N-K-1,mod))%mod
for k in range(K,-1,-1):
    c = z*combi(N-1,k)%mod
    ans += c
    z = z*(M-1)%mod

print(ans%mod)


Measured memory_bytes: 73044
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define EPS (1e-7)
#define INF (1e9)
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
const double PI = acos(-1);
const ll MOD = 1000000007;
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;
}
///////////////////////////////////////////////////////////////

int main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
    int N,A,B,C,D; cin >> N >> A >> B >> C >> D;
    A--; B--; C--; D--;
    string S; cin >> S;

    int K = max(C,D);
    bool can = true;
    bool ch = false;
    for (int i = A; i <= K; i++) {
        if (i >= B-1 && i <= D-1) {
            if (S[i] == '.' && S[i+1] == '.' && S[i+2] == '.') ch = true;
        }
        if (i <= K-1) {
            if (S[i] == '#' && S[i+1] == '#') {
                can = false;
                if (C < B && C < i && i < B) can = true;
            }
        }
    }

    if (!ch && D < C) can = false;
    
    cout << (can ? "Yes" : "No") << endl;
}


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


#define f(i,a,b) for(int i=(int)(a);i<=(int)(b);i++)
#define char_f(i,a) for(int i=(int)(a);(char)s[i]!='\0';i++)
#define rf(i,a,b) for(int i=(int)(a);i>=(int)(b);i--)
#define llf(i,a,b) for(long long int i=(long long int)(a);i<=(long long int)(b);i++)
#define llrf(i,a,b) for(long long int i=(long long int)(a);i>=(long long int)(b);i--)



#define ll long long
#define fi first
#define se second
#define pb push_back
#define pop pop_back
#define mem(ara) memset((ara),0,sizeof(ara))
#define memn(ara) memset((ara),-1,sizeof(ara))
#define bb begin()
#define ee end()
#define em emplace
#define eb emplace_back





#define si set<int>
#define sd set<double>
#define sll set<long long int>
#define ss set<string>
#define sc set<char>

#define pii pair<int,int>
#define pli pair<long long int,int>
#define pil pair<int,long long int>
#define pll pair<long long int,long long int>
#define pci pair<char,int>
#define pic pair<int,char>
#define pcl pair<char,long long int>
#define plc pair<long long int,char>

#define pss pair<string,string>
#define pcc pair<char,char>

#define pis pair<int,string>
#define psi pair<string,int>
#define pls pair<long long int,string>
#define psl pair<string,long long int>
#define pdd pair<double,double>
#define pcs pair<char,string>
#define psc pair<string,char>



#define vi  vector<int>
#define vll vector<long long int>
#define vd vector<double>
#define vs vector<string>
#define vc vector<char>
#define vii vector<pii>



#define mod 1000000007
#define mx (1<<30)-1
#define llmx (1ll<<62)
#define n_size 100005
#define g_size 10000005
double PI=acos(-1);
#define eps 1e-9



///unsigned int uMAX=4294967295;
///unsigned ll int ullMAX=18446744073709551615;





int arr[g_size];



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

	ll int n,m,T,res;

	ll int maxi=-mx,mini=mx,count=0;

	ll int i,j,k;

	bool flag;

	string s1,s2;

	char s[100000];

	int ara[n_size],ara2[n_size];

	cin>>n;

	map<ll int,ll int>mp;
	map<ll int,ll int>::iterator it;

	f(i,0,n-1){
        cin>>m;
        mp[m]++;
	}

	for(it=mp.bb;it!=mp.ee;it++){
        if(it->fi<it->se) count+=(it->se-it->fi);
        else if(it->fi>it->se) count+=it->se;

	}

	cout<<count<<endl;

}


Measured memory_bytes: 6272
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.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; }
using namespace std;

int main(){
    int n;
    cin >> n;
    vector<int> v(n);
    vector<int> t(n);

    rep(i, n){
        cin >> v[i];
        t[i] = v[i];
    }

    sort(rall(t));
    UNIQUE(t);
    int f = t[0];
    int s = t[1];

    int fcnt = 0;
    int scnt = 0;
    rep(i, n){
        if(v[i] == f) fcnt++;
        else if(v[i] == s) scnt++;
    }

    if(fcnt >= 2){
        rep(i, n) cout << f << endl;
    }
    else {
        rep(i, n){
            if(v[i] == f) cout << s << endl;
            else cout << f << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 3200
n, h = gets.split.map(&:to_i)
a_arr = []
b_arr = []
n.times.each do
  l = gets.split.map(&:to_i)
  a_arr << l[0]
  b_arr << l[1]
end

a_max = a_arr.max
b_arr.sort!
count = 0
b_arr.reverse_each do |b|
  if b >= a_max
    h -= b
    count += 1
    if h <= 0
      break
    end
  else
    break
  end
end

if h <= 0
  puts count
else
  count += (h + (a_max - 1)) / a_max
  puts count
end


Measured memory_bytes: 4484
s = input()
a = z = -1
for i, v in enumerate(s):
    if a == -1:
        if v == 'A':
            a = i
    if z == -1:
        if s[len(s) - i -1] == 'Z':
            z = len(s) - i
            
    if a >= 0 and z >= 0:
        print(z - a)
        exit()

Measured memory_bytes: 3516
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <algorithm>
using namespace std;
const int Maxx = 2e5 + 7;
const int Inf = 1e9 + 7;
int n;
int a[Maxx];
int t[Maxx];

int main() {
	while(~scanf("%d", &n)) {
		for(int i = 1; i <= n; i++) scanf("%d", &a[i]);
		for(int i = 1; i <= n; i++) t[i] = a[i];
		sort(a + 1, a + n + 1);
		int p1 = a[n / 2], p2 = a[n / 2 + 1];
		for(int i = 1; i <= n; i++) {
			if(t[i] <= p1) printf("%d\n", p2);
			else if(t[i] >= p2) printf("%d\n", p1);
		}
	}
	return 0;
}

Measured memory_bytes: 3712
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define REPLL(i, n) for (ll i = 0; i < (ll)(n); i++)
using namespace std;
template<class T>inline bool chmax(T &a, const T &b){if(a < b){a = b; return 1;}return 0;}
template<class T>inline bool chmin(T &a, const T &b){if(a > b){a = b; return 1;}return 0;}
typedef long long ll;

int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  string T; cin >> T;
  int N = T.size();
  string ans = T;
  REP(i, N){
    if(T[i] == '?') ans[i] = 'D';
  }
  cout << ans << endl;
}

Measured memory_bytes: 3756
#include <bits/stdc++.h> 
 
#define mp make_pair
#define mt make_tuple
#define eb emplace_back
#define fi first
#define se second
#define ff first
#define ss second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)
using namespace std;
typedef long long ll;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef pair<ll, ll> pii;
typedef long double ld;
typedef string st;
const double PI=3.14159265358979323846264338327950288419716939937510582097494459230;
const ll MOD = 1e9 + 7 ;
const ll INF=1e14;        
template<class T> bool uin(T &a, T b) { return a > b ? (a = b, true) : false; }
template<class T> bool uax(T &a, T b) { return a < b ? (a = b, true) : false; }                                                                                   
ll mpow(ll a,ll b,ll p=MOD){a=a%p;ll res=1;while(b>0){if(b&1)res=(res*a)%p;a=(a*a)%p;b=b>>1;}return res%p;}             
const ll N=10;

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

  st s;
  cin>>s;
  ll ans=1e13;
  for(ll i=0;i<s.length()-2;i++)
  {
    ll num=(s[i]-'0')*100+(s[i+1]-'0')*10+(s[i+2]-'0');
    ans=min(ans,abs(num-753));
  }
  cout<<ans;
}
//nothing is impossible

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

const int _ = 5e5 + 7 , MOD = 998244353; int fac[_] , ifac[_] , N , K;
int poww(long long a , int b){int tms = 1; while(b){if(b & 1) tms = tms * a % MOD; a = a * a % MOD; b >>= 1;} return tms;}
int binom(int a , int b){return a < b || b < 0 ? 0 : 1ll * fac[a] * ifac[b] % MOD * ifac[a - b] % MOD;}

int main(){
	cin >> N >> K; fac[0] = 1; for(int i = 1 ; i <= K ; ++i) fac[i] = 1ll * fac[i - 1] * i % MOD;
	ifac[K] = poww(fac[K] , MOD - 2); for(int i = K - 1 ; ~i ; --i) ifac[i] = ifac[i + 1] * (i + 1ll) % MOD;
	int sum = 0;
	for(int i = 0 ; K - 2 * i >= 0 ; ++i)
		if(K - N - i >= 0) sum = (0ll + sum + binom(K - (K == 2 * i) , i - (K == 2 * i)) - binom(K - (K == 2 * i) , 2 * i + N - K - 1 - (K == 2 * i)) + MOD) % MOD;
	
	cout << sum; return 0;
}


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

int main(){
  int N;
  cin >> N;
  int A[30],B[30],C[30];
  int res =0;
  for (size_t i = 0; i < N; i++) {
    cin >> A[i];
  }
  for (size_t i = 0; i < N; i++) {
    cin >> B[i];
    res += B[i];
  }
  for (size_t i = 0; i < N; i++) {
    cin >> C[i];
  }

  for (size_t i = 0; i < N - 1; i++) {
    if (A[i + 1] - A[i] == 1) {
      res += C[A[i] - 1];
    }
  }
    cout << res << '\n';
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<functional>
#include<fstream>
#include<utility>
#include<bitset>
#include<map>
#include<deque>
#include<cmath>
#include<random>
#include<string.h>
#define FOR(i, a, b) for (int i = a; i < b; ++i)
#define rep(N) for (int i = 0; i < N; ++i)
#define Rep(a, b) for (int i = a; i < b; ++i)
#define For(i, N) for (int i = 0; i < N; ++i)
#define all(v) v.begin(), v.end()
#define rev(v) v.rbegin(), v.rend()
#define makei(N) int N; cin >> N;
#define makel(N) ll N; cin >> N;
#define makes(s) string s; cin >> s;
#define maked(d) double d; cin >> d;
#define makev(v, N) vi v(N); rep(N)cin >> v[i];
#define mod 1000000007
#define re return 0

using namespace std;
using ll = long long int;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vll = vector<ll>;
using vb = vector<bool>;
using vvb = vector<vector<bool>>;
using vs = vector<string>;
using pii = pair<int, int>;
using pis = pair<int, string>;
using msi = map<string, int>;

template<typename T>
void say(T s) {
	cout << s << "\n";
}

template<typename T>
void say(vector<T> s) {
	auto itr = s.begin();
	cout << *(itr++);
	while (itr != s.end()) {
		cout << " " << *(itr++);
	}
	cout << "\n";
}

void yn(bool b) {
	if (b)say("Yes");
	else say("No");
}

int main() {
	makei(N);
	makei(M);
	if (abs(N - M) > 1) {
		say(0);
		re;
	}
	ll ans = 1;
	if (N == M)ans = 2;
	Rep(2, N + 1) {
		ans *= i;
		ans %= mod;
	}
	Rep(2, M + 1) {
		ans *= i;
		ans %= mod;
	}
	say(ans);
}

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

using namespace std;

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

int main(void){
    unsigned long long N = 0, K = 0;
    cin >> N >> K;
    long long x = N % K;
    long long y = K - x;

    if(x <= y){
        cout << x << endl;
    }else{
        cout << y << endl;
    }

    return 0;
}

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

#define all(v) v.begin(), v.end()
#define mp make_pair
#define EPS (int)1e-9
#define PI acos(-1)
#define endl '\n'
#define pb push_back
#define fi first
#define se second

using namespace std;
using ld = long double;
using ll = long long;
using vi = vector<int>;
using pii = pair<int, int>;

const int mod = 1000000007;


int main()
{
	ios_base::sync_with_stdio(0); cin.tie(0);
	int n;
	cin >> n;

	vi a(n);
	for(int i = 0; i < n; i++)
		cin >> a[i];

	sort(all(a));

	int ans = 0;
	for(int i = 1; i < n; i++)
		ans += a[i]-a[i-1];

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

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

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

    vector<int> a(m),b(m);
    for(int i=0; i<m; i++){
        cin>>a[i]>>b[i];
    }

    vector<int> count(n);
    for(int i=0; i<m; i++){
        count[a[i]-1]++;
        count[b[i]-1]++;
    }

    for(int i=0; i<n; i++){
        cout<<count[i]<<endl;
    }
}

Measured memory_bytes: 256
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.io.IOException;
import java.io.InputStream;

/**
 * Built using CHelper plug-in Actual solution is at the top
 * 
 * @author daltao
 */
public class Main {
    public static void main(String[] args) throws Exception {
        Thread thread = new Thread(null, new TaskAdapter(), "daltao", 1 << 27);
        thread.start();
        thread.join();
    }

    static class TaskAdapter implements Runnable {
        @Override
        public void run() {
            InputStream inputStream = System.in;
            OutputStream outputStream = System.out;
            FastInput in = new FastInput(inputStream);
            PrintWriter out = new PrintWriter(outputStream);
            TaskA solver = new TaskA();
            solver.solve(1, in, out);
            out.close();
        }
    }
    static class TaskA {
        public void solve(int testNumber, FastInput in, PrintWriter out) {
            String s = in.readString();
            s = s.substring(0, 4) + " " + s.substring(4);
            out.println(s);
        }

    }
    static class FastInput {
        private final InputStream is;
        private StringBuilder defaultStringBuf = new StringBuilder(1 << 13);
        private byte[] buf = new byte[1 << 13];
        private int bufLen;
        private int bufOffset;
        private int next;

        public FastInput(InputStream is) {
            this.is = is;
        }

        private int read() {
            while (bufLen == bufOffset) {
                bufOffset = 0;
                try {
                    bufLen = is.read(buf);
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
                if (bufLen == -1) {
                    return -1;
                }
            }
            return buf[bufOffset++];
        }

        public void skipBlank() {
            while (next >= 0 && next <= 32) {
                next = read();
            }
        }

        public String readString(StringBuilder builder) {
            skipBlank();

            while (next > 32) {
                builder.append((char) next);
                next = read();
            }

            return builder.toString();
        }

        public String readString() {
            defaultStringBuf.setLength(0);
            return readString(defaultStringBuf);
        }

    }
}



Measured memory_bytes: 25556
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Set;
import java.util.TreeSet;

public class Main {

	public static void main(String[] args) throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int size = Integer.parseInt(br.readLine());
		Set<String> dictionary = new TreeSet<String>();
		String[] commands;
		StringBuilder sb = new StringBuilder();
		for (int i = 0; i < size; i++) {
			commands = br.readLine().split(" ");
			if (commands[0].startsWith("i")) {
				dictionary.add(commands[1]);
			} else {
				if (dictionary.contains(commands[1])) {
					sb.append("yes").append("\n");
				} else {
					sb.append("no").append("\n");
				}
			}
		}
		System.out.print(sb);
	}
}

Measured memory_bytes: 198640
from collections import Counter as cnt

n = int(input())
c = cnt(input())

for _ in range(n-1):
    s = cnt(input())
    for key in c.keys():
        c[key] = min(c[key], s[key]) 
else:
    print("".join(sorted([key * c[key] for key in c.keys()])))

Measured memory_bytes: 3316
#include<bits/stdc++.h>
using namespace std;
const int mxn=1e5+5;

vector<int>g[mxn];

void dfs(int r, int p, vector<int>&dist, int cnt){
     dist[r]=cnt;
     for(int i=0;i<g[r].size();i++){
          int ch=g[r][i];
          if(ch==p)continue;
          dfs(ch, r, dist, cnt+1);
     }
}

int main(){
     int n, u, v; cin>>n>>u>>v;

     for(int i=0;i<n-1;i++){
          int a, b; cin>>a>>b;
          g[a].push_back(b);
          g[b].push_back(a);
     }

     vector<int>dist1(mxn), dist2(mxn);

     dfs(u, -1, dist1, 0);
     dfs(v, -1, dist2, 0);

     int ans=0;
     for(int i=1;i<=n;i++){
          if(dist1[i]<dist2[i])ans=max(ans, dist2[i]);
     }
     cout<<ans-1;
}

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

int main(){
    int n;
    cin >> n;
    vector<int> a(n),b(n),c(n);
    for(int i=0;i<n;i++) cin >> a[i];
    for(int i=0;i<n;i++) cin >> b[i];
    for(int i=0;i<n-1;i++) cin >> c[i];
    int total=b[a[0]-1];
    for(int i=1;i<n;i++){
        total+=b[a[i]-1];
        //cout << "満足度:" << b[a[i]-1] << endl;
        if(a[i]==a[i-1]+1) total+=c[a[i-1]-1];
    }
    cout << total << endl;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i, m, n) for (int i = m; i < (n); i++)
#define RFOR(i, m, n) for (int i = (m - 1); i >= 0; i--)
#define REP(i, n) FOR(i, 0, n)
#define RREP(i, n) RFOR(i, n, 0)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
using namespace std;
typedef long long ll;
const int mod = 1e9 + 7;
const ll INF = 1000000000000000000LL;

ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }

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

ll factorial(ll n) {
  ll answer = 1;
  while (n > 1) {
    answer *= n;
    answer %= mod;
    n--;
  }
  return answer;
}

ll combination(ll n, ll r) {
  return factorial(n) / (factorial(r) * factorial(n - r));
}

ll permutation(ll n, ll r) { return factorial(n) / factorial(n - r); }

template <typename T>
void remove(std::vector<T>& vector, unsigned int index) {
  vector.erase(vector.begin() + index);
}

map<ll, ll> prime_factor(ll n) {
  map<ll, ll> ret;
  for (ll i = 2; i * i <= n; i++) {
    while (n % i == 0) {
      ret[i]++;
      n /= i;
    }
  }
  if (n != 1) ret[n] = 1;
  return ret;
}
// for (auto p : prime_factor(n)) {
//	while (p.second--) {
//		cout << p.first << endl;
//	}
//}

vector<ll> divisor(ll n) {
  vector<ll> ret;
  for (ll i = 1; i * i <= n; i++) {
    if (n % i == 0) {
      ret.push_back(i);
      if (i * i != n) ret.push_back(n / i);
    }
  }
  sort(begin(ret), end(ret));
  return (ret);
}

bool compare_by_b(pair<ll, ll> a, pair<ll, ll> b) {
  if (a.second != b.second) {
    return a.second < b.second;
  } else {
    return a.first < b.first;
  }
}

vector<ll> Eratosthenes(const ll N) {
  bool is_prime[1000000 + 1];
  vector<ll> P;
  for (ll i = 0; i <= N; i++) {
    is_prime[i] = true;
  }
  for (ll i = 2; i <= N; i++) {
    if (is_prime[i]) {
      for (ll j = 2 * i; j <= N; j += i) {
        is_prime[j] = false;
      }
      P.emplace_back(i);
    }
  }
  return P;
}

typedef vector<int> ivec;
typedef vector<string> svec;
typedef vector<ll> lvec;

ll f(ll x, ll c, ll d) {
  ll res = x;
  res -= x / c;
  res -= x / d;
  res += x / lcm(c, d);
  return res;
}

int main() {
  ll A, B, C, D;
  cin >> A >> B >> C >> D;
  ll ans = f(B, C, D) - f(A - 1, C, D);
  cout << ans << endl;
  return 0;
}

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

using i64 = long long;

int n, k;

int main() {
#ifdef HOME
	freopen("agc17a.in", "r", stdin);
	freopen("agc17a.out", "w", stdout);
#endif
	ios::sync_with_stdio(false);
	cin.tie(0), cout.tie(0);
	i64 ant(1);
	int p, x, y;

	x = y = 0;

	cin >> n >> p;
	for (int t, i = 0; i < n; ++i) {
		cin >> t;
		t % 2 ? ++x : ++y; }

	if (p && !x)
		cout << 0 << endl;
	else
		cout << (1LL << max(0, x - 1)) * (1LL << y) << endl;

	return 0; }


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

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

void fastStream(){cin.tie(0);std::ios_base::sync_with_stdio(0);}

const int mod = 1000000000 + 7;

int N;
int A[17][17];
ll dp[1 << 16];
ll score_each_mask[1 << 16];

ll rec(int mask){
    if(dp[mask] >= 0) return dp[mask];
    ll res = 0;
    int sub_mask = mask;
    do{
        if(sub_mask != 0){
            // sub_maskの価値は予め計算しておく
            res = max(res, rec(mask ^ sub_mask) + score_each_mask[sub_mask]);
        }
        sub_mask=(sub_mask-1)&mask;
    }while(sub_mask != mask);
    return dp[mask] = res;
}

int main() {

    cin >> N;
    for(int i = 0; i < N; i++)
        for(int j = 0; j < N; j++)
            cin >> A[i][j];
    for(int mask = 0; mask < (1 << N); mask++){
        ll sum = 0;
        for(int i = 0; i < N; i++){
            if((mask >> i) & 1){
                for(int j = i + 1; j < N; j++){
                    if((mask >> j) & 1){
                        sum += A[i][j];
                    }
                }
            }
        }
        score_each_mask[mask] = sum;
    }

    memset(dp, -1, sizeof(dp));
    cout << rec((1 << N) - 1) << endl;

    return 0;
}


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

#define rep(i,n) for(int i=0;i<(n);++i)
#define rrep(i,n) for(int i=(n);i>=0;--i)
#define in(v) cin>>v;
#define out(v) cout<<v<<"\n"

int main() {
  cin.tie(0); ios::sync_with_stdio(false);
  int A, B, K;
  cin >> A >> B >> K;
  int count = 0;
  rrep(i, A) {
    if (A % i == 0 && B % i == 0)
      ++count;
    if (count == K) {
      out(i);
      return 0;
    }
  }

  return 0;
}


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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
using P = pair<ll, ll>;
using V = vector<ll>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep1(i, n) for(ll i=1;i<=(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
#define ALL(obj) (obj).begin(), (obj).end()
#define MOD 1000000007
#define INF 1000000000

// auto mod int
// https://youtu.be/L8grWxBlIZ4?t=9858
// https://youtu.be/ERZuLAxZffQ?t=4807 : optimize
// https://youtu.be/8uowVvQ_-Mo?t=1329 : division
const int mod = 1000000007;
struct mint {
	ll x; // typedef long long ll;
	mint(ll x = 0) :x((x% mod + mod) % mod) {}
	mint operator-() const { return mint(-x); }
	mint& operator+=(const mint a) {
		if ((x += a.x) >= mod) x -= mod;
		return *this;
	}
	mint& operator-=(const mint a) {
		if ((x += mod - a.x) >= mod) x -= mod;
		return *this;
	}
	mint& operator*=(const mint a) {
		(x *= a.x) %= mod;
		return *this;
	}
	mint operator+(const mint a) const {
		mint res(*this);
		return res += a;
	}
	mint operator-(const mint a) const {
		mint res(*this);
		return res -= a;
	}
	mint operator*(const mint a) const {
		mint res(*this);
		return res *= a;
	}
	mint pow(ll t) const {
		if (!t) return 1;
		mint a = pow(t >> 1);
		a *= a;
		if (t & 1) a *= *this;
		return a;
	}

	// for prime mod
	mint inv() const {
		return pow(mod - 2);
	}
	mint& operator/=(const mint a) {
		return (*this) *= a.inv();
	}
	mint operator/(const mint a) const {
		mint res(*this);
		return res /= a;
	}
};

// nCr
// combination mod prime
// https://www.youtube.com/watch?v=8uowVvQ_-Mo&feature=youtu.be&t=1619
// usage:
//   combination comb(n+5);
//   ans = comb(n,r);
struct combination {
	vector<mint> fact, ifact;
	combination(int n) :fact(n + 1), ifact(n + 1) {
		assert(n < mod);
		fact[0] = 1;
		for (int i = 1; i <= n; ++i) fact[i] = fact[i - 1] * i;
		ifact[n] = fact[n].inv();
		for (int i = n; i >= 1; --i) ifact[i - 1] = ifact[i] * i;
	}
	mint operator()(int n, int k) {
		if (k < 0 || k > n) return 0;
		return fact[n] * ifact[k] * ifact[n - k];
	}
};

void solve_abc_d() {
	ll n;
	char s[2][53];

	cin >> n;

	string s1, s2;
	cin >> s1;
	cin >> s2;

	rep(i, n) {
		s[0][i] = s1[i];
		s[1][i] = s2[i];
	}

	mint ans = 1;
	string type = "init";
	rep(i, n) {
		if (s[0][i] == s[1][i]) {
			if (type == "tate") {
				ans *= 2;
			}
			else if (type == "init"){
				ans *= 3;
			}
			else {
				ans *= 1;
			}
			type = "tate";
		}
		else {
			if (type == "tate") {
				ans *= 2;
			}
			else if (type == "init") {
				ans *= 6;
			}
			else {
				ans *= 3;
			}
			type = "yoko";
			i += 1;
		}
	}	

	cout << ans.x << "\n";
}

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

	solve_abc_d();

	return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;
public class Main{

	public static void main (String arg[]) {
		int Math = 0;
		Scanner scan = new Scanner(System.in);
		int a = scan.nextInt();
		int b = scan.nextInt();
		int c = scan.nextInt();
		for (int x = a; x <= b ; x++) {
			if (c % x == 0) {
				Math += 1;
			}
			
		}
		System.out.println(Math);
		scan.close();

	}
}


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

using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
using pint = pair<int, int>;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
const int MOD = 1000000007;
const long long INF = 1LL << 60;
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; }

ll powmod(ll x, ll y) {
    ll res = 1;
    for (ll i = 0; i < y; ++i) {
        res = res * x % MOD;
    }
    return res;
}

int main() {
    ll N;
    cin >> N;
    ll res = powmod(10, N) - powmod(9, N) - powmod(9, N) + powmod(8, N);
    res %= MOD;
    res = (res + MOD) % MOD;
    cout << res << endl;
}

Measured memory_bytes: 3572
#include<iostream>
using namespace std;
unsigned int a,n;
int IsPrime(int n)
{
    int i;
  
    if (n < 2)
        return 0;
    else if (n == 2)
        return 1;
  
    if (n % 2 == 0)
        return 0;
  
    for (i = 3; i <= n / i; i += 2)
        if (n % i == 0)
            return 0;
    return 1;
}
int main() {
    int temp=0,flag=0;
    cin >> n;
    for (int i = 0; i < n; i++) {
        cin >> a;
        if (IsPrime(a) == 1)temp++;
    }
    cout << temp << endl;
}

Measured memory_bytes: 3120
//%std
#include<bits/stdc++.h>
#define endl '\n'
using namespace std;
typedef long long ll;
inline int read()
{
	int out=0,fh=1;
	char jp=getchar();
	while ((jp>'9'||jp<'0')&&jp!='-')
		jp=getchar();
	if (jp=='-')
		fh=-1,jp=getchar();
	while (jp>='0'&&jp<='9')
		out=out*10+jp-'0',jp=getchar();
	return out*fh;
}
const int MAXN=3e4+10,K=10;
int n,cur[K],nxt[MAXN][K];
char s[MAXN];
int ans=0;
int check(int a,int b,int c)
{
	int x=0;
	x=nxt[x][a];
	if(!x)
		return 0;
	x=nxt[x][b];
	if(!x)
		return 0;
	x=nxt[x][c];
	if(!x)
		return 0;
	return 1;
}
int main()
{
	n=read();
	scanf("%s",s+1);
	for(int i=n;i>=1;--i)
	{
		memcpy(nxt[i],cur,sizeof cur);
		cur[s[i]-'0']=i;	
	}	
	memcpy(nxt[0],cur,sizeof cur);
	for(int i=0;i<K;++i)
		for(int j=0;j<K;++j)
			for(int k=0;k<K;++k)
				if(check(i,j,k))
					++ans;
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 1408
#include<iostream>
using namespace std;
int main(){
  int a,b,c;
  cin >> a >> b >> c;
  if(a==b){
    if(a==c){
      cout << "No" << endl;
    }
    else{
      cout << "Yes" << endl;
    }
  }
  else if(b==c){
    if(a==b){
      cout << "No" << endl;
    }
    else{
      cout << "Yes" << endl;
    }
  }
  else if(a==c){
    if(a==b){
      cout << "No" << endl;
    }
    else{
      cout << "Yes" << endl;
    }
  }
  else{
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
#include <stdio.h>
#include <algorithm>
 
using namespace std;
 
const int MAX_N = 105;
 
struct item {
    int v , m;
};
 
long long F[MAX_N][100005];
int n , M;
item save[MAX_N];
 
int main () {
    scanf("%d %d" , &n , &M);
 
    for (int i = 1; i <= n; i++) scanf("%d %d" , &save[i].m , &save[i].v);
 
    for (int i = 1; i <= n; i++)
        for (int j = 1; j <= M; j++)
            if (save[i].m > j) F[i][j] = F[i - 1][j];
            else F[i][j] = max(F[i - 1][j] , F[i - 1][j - save[i].m] + save[i].v);
 
    printf("%lld" , F[n][M]);
    return 0;
}

Measured memory_bytes: 79232
#include <cstdio>
int gcd(int a,int b){
	if(b==0){
		return a;
	}
	return gcd(b,a%b);
}
const int Maxn=1000000;
int num[Maxn+5];
int n;
int a[Maxn+5];
int main(){
	scanf("%d",&n);
	for(int i=1;i<=n;i++){
		scanf("%d",&a[i]);
		num[a[i]]++;
	}
	bool flag=1;
	for(int i=2;i<=Maxn;i++){
		int sum=0;
		for(int j=i;j<=Maxn;j+=i){
			sum+=num[j];
		}
		if(sum>1){
			flag=0;
			break;
		}
	}
	if(flag){
		puts("pairwise coprime");
		return 0;
	}
	int sum=a[1];
	for(int i=2;i<=n;i++){
		sum=gcd(sum,a[i]);
	}
	if(sum==1){
		puts("setwise coprime");
	}
	else{
		puts("not coprime");
	}
	return 0;
}


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

int main()
{
  int N, D;
  cin >> N >> D;
  int result = (N <= 2 * D)? 1 : ceil((double)(N / (2.0 * D + 1.0)));
  cout << result << endl;
  return 0;
}

Measured memory_bytes: 256
import sys

input = sys.stdin.readline


def main():
    MOD = 1000000007
    N = int(input())
    S1 = input().strip()
    S2 = input().strip()

    ans = 1
    now = 0
    i = 0
    while i < N:
        if S1[i] != S2[i]:
            if now == 0:
                ans *= 6
            elif now == 1:
                ans *= 2
            else:
                ans *= 3
            now = 2
            i += 2
        else:
            if now == 0:
                ans *= 3
            elif now == 1:
                ans *= 2
            else:
                ans *= 1
            now = 1
            i += 1

    print(ans % MOD)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
def main():
    n = int(input())
    ai = map(int, input().split(' '))
    count = 0

    for i, a in enumerate(ai):
        # print(i+1, a)
        if (i + 1) % 2 == 1 and a % 2 == 1:
            count += 1
    print(count)

if __name__ == '__main__':
    main()

Measured memory_bytes: 9172
#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 5 ;
vector < int > adj[N];
int n , m , u , v ;
int mem[N] ;
bool vis[N];
int dfs(int s){
    if(adj[s].empty()) {
        return 0 ;
    }
    vis[s] = 1 ;
    int &ret = mem[s] ;
    if(~ret)
        return ret ;
    for(int i = 0 ; i < adj[s].size() ; ++i){
        int to = adj[s][i] ;
        ret = max(ret , 1 + dfs(to));
    }
    return ret ;

}
int main()
{
    ios_base::sync_with_stdio(0) ; 
    cin.tie(0) ; 
    cout.tie(0) ; 
    cin >> n >> m ;
    for(int i = 0 ; i < m ; ++i){
        cin >> u >> v ;
        adj[u].push_back(v);

    }
    int ans = 0 ;
    memset(mem , -1 , sizeof mem);
    for(int i = 1 ; i<=n ; ++i){
        if(!vis[i]){
            ans = max(ans ,dfs(i));
        }
    }
    cout << ans ;
}


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

int main() {
	int n;
	cin >> n;
	int* w = new int[n];
	for (int i = 0; i < n; i++) {
		cin >> w[i];
	}
	int s1 = 0, s2 = 0;
	s1 += w[0];
	int step1 = 0, step2 = 1;
	for (int i = 1; i < n; i++) {
		if (s1 > s2) {
			s2 += w[n - 1 - step1];
			step1++;
		}
		else {
			s1 += w[step2];
			step2++;
		}
	}
	cout << abs(s1 - s2) << endl;
}

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

//諸機能
#pragma region MACRO 
#define putans(x)  cerr << "answer: " ; cout << (x) << endl
#define dputans(x) cerr << "answer: "; cout << setprecision(10) << (double)(x) << endl
#define REP(i,a,n) for(int i=(a); i<(int)(n); i++)
#define RREP(i,a,n) for(int i=(int)(n-1); i>= a; i--)
#define rep(i,n) REP(i,0,n)
#define rrep(i,n) RREP(i,0,n)
#define all(a) begin((a)),end((a))
#define mp make_pair
#define exist(container, n) ((container).find((n)) != (container).end())
#define substr(s,i,l) string((s), (i), (l))
#define tos(x) (to_string((x)))
#ifdef _DEBUG //ファイルからテストデータを読み込む
std::ifstream ifs("data.txt");
#define input ifs >>
#else //いい感じにやる
#define input cin >>
#endif
#pragma endregion
//デバッグなどの支援
#pragma region CODING_SUPPORT
#define dbg(var0) { std::cerr << ( #var0 ) << "=" << ( var0 ) << endl; }
#define dbg2(var0, var1) { std::cerr << ( #var0 ) << "=" << ( var0 ) << ", "; dbg(var1); }
#define dbg3(var0, var1, var2) { std::cerr << ( #var0 ) << "=" << ( var0 ) << ", "; dbg2(var1, var2); }
#define dbgArray(a,n) {std::cerr << (#a) << "=";  rep(i,n){std::cerr <<(a[i])<<",";} cerr<<endl;} 
#ifndef _DEBUG
#define dbg1 {}
#define dbg2 {}
#define dbg3 {}
#define dbgArray {}
#endif 
#pragma endregion 
//typedef（書き換える、書き足す可能性ある）
#pragma region TYPE_DEF
typedef long long ll;
typedef pair<int, int> pii; typedef pair<string, string> pss; typedef pair<int, string>pis;
typedef vector<string> vs; typedef vector<int> vi;
#pragma endregion
//諸々の定数(書き換える可能性ある)
#pragma region CONST_VAL
#define PI (2*acos(0.0))
#define EPS (1e-9)
#define MOD (ll)(1e9 + 7)
#define INF (ll)(1e9)
#pragma endregion

int main() {
	int n; input n;
	vi a;
	vector<pii> b;
	rep(i, n) {
		int k; input k;
		a.push_back(k);
		b.push_back(mp(k,i+1));
	}
	sort(all(b));
	int oezure = 0;
	rep(i, n) {
		if (b[i].second % 2 != ( i + 1 ) % 2) oezure++;
	}
	putans(oezure/2);
	return 0;
}


Measured memory_bytes: 1780
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
#define SIZE 200005
#define INF 1000000005LL
#define MOD 1000000007

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

int N;
int A[SIZE];
ll K;
bool ip[55555]; //is_prime

int main()
{
	cin >> N;
	int n = 55555;
	for(int i=0;i<=n;i++)ip[i] = true;
	ip[0] = ip[1] = false;
	vector<int> prime;
	rep(i,2,n+1){
		if(ip[i]){
			if(i%5==1)prime.push_back(i);
			for(int j=2*i;j<=n;j+=i) ip[j] = false;
		}
	}
	rep(i,0,N) {
		if(i!=0)cout << " ";
		cout << prime[i];
	}
	cout << endl;

	return 0;
}


Measured memory_bytes: 256
if __name__ == '__main__':

    n = int(input())
    B = [0]*(10**5+1)
    A = list(map(int,input().split()))
    for a in A:
        B[a] += 1
    #合計
    sm = sum(A)
    m = int(input())

    for j in range(m):
        b,c = map(int,input().split())
        #bの個数の増減をチェック
        cnt_b = B[b]
        cnt_c = B[c]
        if cnt_b == 0:
            #変換できないので何もしない
            print(sm)
        else:
            B[b] = 0
            B[c] += cnt_b
            sm = sm + c*cnt_b - b*cnt_b
            print(sm)


Measured memory_bytes: 21908
#include<bits/stdc++.h>
using namespace std;
bool D[10],used[10];
int kei[10],m,an;
void dfs(int x,int sum){
  if(x==m){
    if(sum==0)an++;
    return;
  }
  for(int i=0;i<10;i++){
    if((i==0&&D[x])||used[i])continue;
    used[i]=1;
    dfs(x+1,sum+kei[x]*i);
    used[i]=0;
  }
}
 
int main(){
  int n;
  while(cin>>n&&n){
    m=0,an=0;
    memset(D,0,sizeof(D));
    string s;
    map<char,int> c;
    vector<char> v;
    for(int i=0;i<n;i++){
      cin>>s;
      int l=1;
      if(i==n-1)l=-1;
      for(int j=s.size()-1,k=1;j>=0;j--,k*=10){
    if(j==0&&s.size()!=1)v.push_back(s[j]);
    if(c.find(s[j])==c.end())c[s[j]]=l*k;
    else c[s[j]]+=l*k;
      }
    }
    map<char,int>::iterator it;
    for(it=c.begin();it!=c.end();it++){
      for(int i=0;i<v.size();i++)
    if((*it).first==v[i])D[m]=1;
      kei[m++]=(*it).second;
    }
    dfs(0,0);
    cout<<an<<endl;
  }
  return 0;
}

Measured memory_bytes: 1228
/**
 *    author:  N_O_E_l
 *        
**/
#include <bits/stdc++.h>

using namespace std;

#define fRead(x) freopen(x, "r", stdin);
#define fWrite(x) freopen(x, "w", stdout);

#define ll long long
#define ull unsigned long long
#define vi vector<int>
#define vll vector<long long>
#define si set<int>
#define sll set<long long>
#define pb push_back
#define pop pob_back()
#define eb emplace_back
#define PI acos(-1.0)
#define mp make_pair
#define pii pair<int, int>
#define pll pair<long, long>
#define Min(a, b, c)  min(a, min(b, c))
#define all(x) x.begin(), x.end()
#define aall(x, n) x, x+n
#define fast_input ios_base :: sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);

/** -------------------------------- TEMPLATE---------------------------------- **/

void solve(void)
{
	int N;

	cin >> N;

	string k;

	map<string, int> mp;

	while(N--){
		cin >> k;
		mp[k]++;
	}

	cout << "AC x " << mp["AC"] << endl; 
	cout << "WA x " << mp["WA"] << endl; 
	cout << "TLE x " << mp["TLE"] << endl; 
	cout << "RE x " << mp["RE"] << endl; 
}

int main(void)
{
	fast_input

    int t;

    t = 1;

    while(t--){
    	solve();
    }

	return 0;
}


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

# define REP(i,n) for(int i=0; i<n;i++)

using namespace std;

int main(){
	
	int n;
	cin >> n;
	
	vector<long long int> a;
	long long int po;
	REP(i,n){
		cin >> po;
		a.push_back(po);
	}
	
	sort(a.begin(), a.end() );
	/*
	REP(i,n) cout << a[i] << " ";
	cout << endl;
	*/
	int ans = 0;
	
	po = a.front();
	int count=1;
	
	for (int i=1; i<n; i++){
		if(po!=a[i]){
			if(count%2!=0) ans++;
			po = a[i];
			count = 1;
		}else{
			count++;
		}
	}
	
	if(count%2!=0) ans++;
	
	cout << ans << endl;
}


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

bool to_purpose[200005];
bool from_start[200005];

int main() {
    int N, M, a, b;
    cin >> N >> M;
    for (int i = 0; i < N; i++) {
        to_purpose[i] = false;
        from_start[i] = false;
    }
    for (int i = 0; i < M; i++) {
        cin >> a >> b;
        if (a == 1) from_start[--b] = true;
        else if (b == N) to_purpose[--a] = true;
    }
    for (int i = 0; i < N; i++) {
        if (from_start[i] && to_purpose[i]) {
            cout << "POSSIBLE" << endl;
            return 0;
        }
    }
    cout << "IMPOSSIBLE" << endl;
    return 0;
}

Measured memory_bytes: 640
s = input()
count = 0
flag = 0

for i in range(len(s)):
    if s[i].isupper():
        count += 1
#print(count)

if s[0] == 'A':
    for i in range(2 , len(s)-1):
        #print(s[i])
        if s[i] == "C" and count == 2:
            flag = 1
if flag == 1:
    print("AC")
else:
    print("WA")


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

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

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

  int k;
  cin >> k;

  if (k % 2 == 0) {
    cout << (k / 2) * (k / 2) << endl;
  } else {
    cout << (k / 2 + 1) * (k / 2) << endl;
  }

  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>

using namespace std;

int ans,table[41],n;

struct Info{
	Info(int arg_start,int arg_grade,int arg_tmp){
		start = arg_start;
		grade = arg_grade;
		tmp = arg_tmp;
	}
	Info(){
		start = grade = tmp = 0;
	}
	int grade,tmp,start;
};

void recursive(int index,Info info){

	if(info.grade == 5){
		ans = min(ans,info.start);
		return;
	}

	if(index == n+1)return;

	switch(info.grade){
	case 0: //5
		if(table[index]+info.tmp < 5){
			recursive(index+1,Info(info.start,0,info.tmp+table[index]));
		}else if(table[index]+info.tmp == 5){
			recursive(index+1,Info(info.start,1,0));
		}else{
			return;
		}
		break;
	case 1: //7
		if(table[index]+info.tmp < 7){
			recursive(index+1,Info(info.start,1,info.tmp+table[index]));
		}else if(table[index]+info.tmp == 7){
			recursive(index+1,Info(info.start,2,0));
		}else{
			return;
		}
		break;
	case 2: //5
		if(table[index]+info.tmp < 5){
			recursive(index+1,Info(info.start,2,info.tmp+table[index]));
		}else if(table[index]+info.tmp == 5){
			recursive(index+1,Info(info.start,3,0));
		}else{
			return;
		}
		break;
	case 3: //7
		if(table[index]+info.tmp < 7){
			recursive(index+1,Info(info.start,3,info.tmp+table[index]));
		}else if(table[index]+info.tmp == 7){
			recursive(index+1,Info(info.start,4,0));
		}else{
			return;
		}
		break;
	case 4: //7
		if(table[index]+info.tmp < 7){
			recursive(index+1,Info(info.start,4,info.tmp+table[index]));
		}else if(table[index]+info.tmp == 7){
			recursive(index+1,Info(info.start,5,0));
		}else{
			return;
		}
		break;
	}
}


void func(){
	int length;
	char tmp[11];

	for(int loop = 1; loop <= n; loop++){
		scanf("%s",tmp);

		for(length = 0; tmp[length] != '\0'; length++);

		table[loop] = length;
	}

	for(int i = 1; i <= n-4; i++){
		recursive(i,Info(i,0,0));
	}

	printf("%d\n",ans);
}


int main(){

	while(true){
		scanf("%d",&n);
		if(n == 0)break;

		ans = 1000000;
		func();
	}
    return 0;
}



Measured memory_bytes: 2752
#include<iostream>
using namespace std;
int main(){
 	int i,h,n,num=0;
  	scanf("%d %d",&h,&n);
  	int ar[n];
  	for(i=0;i<n;i++){
     scanf("%d",&ar[i]);
      num+=ar[i];
    }
  	if(num>=h)cout<<"Yes";
  	else cout<<"No";
  return 0;
}

Measured memory_bytes: 640
using System;
using System.Collections.Generic;
class Program{
  public static void Main(){
    var line = Console.ReadLine().Split(' ');
    int K = int.Parse(line[0]);
    int S = int.Parse(line[1]);
    int X = (S + 1) * (S + 2);
    if (S - K - 1 >= 0){
      X -= 3 * (S - K + 1) * (S - K);
    }
    if (S - 2 * K - 2 >= 0){
      X += 3 * (S - 2 * K) * (S - 2 * K - 1);
    }
    Console.WriteLine(X/2);
  }
}

Measured memory_bytes: 13140
#include <bits/stdc++.h>
using namespace std; 
typedef long long ll;
#pragma GCC optimize("O3")
#define pb push_back
int32_t main()  {
        ios::sync_with_stdio(false);
        cin.tie(0);
        int n;
        cin >> n;
        int a[n+1] , b[n+1] , c[n+1];
        for(int i = 1; i<=n; i++) {
            cin >> a[i] >> b[i] >> c[i];
        }
        int dp[n+1][3];
        dp[0][0] = dp[0][1] = dp[0][2] = 0 ;
        for(int i = 1 ; i<=n;i++) {
            dp[i][0] = max ( dp[i-1][1], dp[i-1][2]) + a[i];
            dp[i][1] = max( dp[i-1][0] , dp[i-1][2]) + b[i];
            dp[i][2] = max( dp[i-1][0] , dp[i-1][1]) + c[i];
          //  cerr << dp[i][0] << "  " <<  dp[i][1] << "  " << dp[i][2] << endl;
        }
        cout <<max( dp[n][0], max( dp[n][1], dp[n][2]));
}
      


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

typedef long long int lli;
typedef long double lld;
typedef long long ll;
//Datatype
#define vi vector<int>
#define vlli vector<long long int>
#define vvi vector<vector<int>>
#define vvlli vector<vector<long long int>>
#define ppi pair<int, int>
#define rppi pair<int, pair<int, int>>
#define lppi pair<pair<int, int>, int>
#define vppi vector<pair<int, int>>
#define sppi stack<pair<int int>>
#define qppi queue<pair<int, int>>
//function
#define f first
#define s second
#define pb(x) push_back(x)
#define mkp(i, j) make_pair(i, j)
#define lmkp(i,j,k) make_pair(make_pair(i,j),k)
#define rmkp(i,j,k) make_pair(i,make_pair(j,k))
//loop
#define loop(i,n) for (i = 0; i < n; ++i)
#define loops(i,k,n) for (i = k; i <= n; ++i)
#define looprev(i,k,n) for (i = k; i >= n; --i)
//Const
#define inf (int)1e9
#define eps 1e-9
#define PI 3.1415926535897932384626433832795
#define MOD 1000000007
//Print
#define prd(n) printf("%d", n)
#define prl(n) printf("%lld", n)
#define prdn(n) printf("%d\n", n)
#define prln(n) printf("%lld\n", n)
#define prf(n) printf("%f", n)
//Scan
#define scd(n) scanf("%d", &n)
#define scd2(a, b) scanf("%d %d", &a, &b)
#define scd3(a, b, c) scanf("%d %d %d", &a, &b, &c)
#define scl(n) scanf("%lld", &n)
#define scl2(a, b) scanf("%lld %lld", &a, &b)
#define scl3(a, b, c) scanf("%lld %lld %lld", &a, &b, &c)
#define scf(n) scanf("%f", &n)

using namespace std;

void longest_path(int i, vector<int> A[], vector<int> &dp, vector<bool> &visit){
    int j, N = A[i].size();
    visit[i] = true;
    loop(j, N){
        if(!visit[A[i][j]]){
            longest_path(A[i][j], A, dp, visit);
        }
        dp[i] = max(dp[i], (1+dp[A[i][j]]));
    }
}
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    lli i, j, k, N, M;
    cin>>N>>M;
    vector<int> A[N+1];
    loop(i, M){
        int x, y;
        cin>>x>>y;
        A[x].push_back(y);
    }

    vector<int> dp(N+2, 0);
    vector<bool> visit(N+2, false);

    int res = INT_MIN;
    loop(i, N+1){
        if(!visit[i])
            longest_path(i, A, dp, visit);
    }
    loop(i, N+1){
       res = max(res, dp[i]);
    }
    cout<<res<<endl;
    return 0;
}

Measured memory_bytes: 12476
//#include "gap.h"
#include <iostream>
#include <vector>
#include <algorithm>
#include <stdio.h>
#include <sstream>
#include <string>
#include <map>
#include <set>
#include <stdlib.h>
#include <cmath>
#include <math.h>
#include <fstream>
#include <bitset>
#include <time.h>
#include <queue>
#define int long long
using namespace std;
int lb(int number, vector<int> &v){
    int left = -1;
    int right = v.size();
    while (right - left > 1){
        int mid = (left + right) / 2;
        if (v[mid] >= number) right = mid;
        else left = mid;
    }
    return right;
}
int32_t main(){
    int n;
    cin >> n;
    vector <int> a(n), b(n), c(n);
    for (int i=0; i < n; i++) cin >> a[i];
    for (int i=0; i < n; i++) cin >> b[i];
    for (int i=0; i < n; i++) cin >> c[i];
    sort(a.begin(), a.end());
    sort(b.begin(), b.end());
    sort(c.begin(), c.end());
    int ans = 0;
    for (int i=0; i < n; i++){
        int n1 = lb(b[i], a);
        int n2 = n - lb(b[i]+1, c);
        ans +=n1*n2;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 2560
// Example program
#include <iostream>
#include <vector>
#include<algorithm>
using namespace std;
int main()
{
  int a;
 int b;
 int c;
 cin >> a;
 cin >> b;
 cin >> c;
 
 vector<int>v{a,b,c};
 sort(v.begin(),v.end());
 cout << v[0] << " " << v[1] << " " << v[2] << endl;
}

Measured memory_bytes: 3128
#include "bits/stdc++.h"
#define Rep(i,n) for(int i=0;i<(int)(n);i++)
#define For(i,n1,n2) for(int i=(int)(n1);i<(int)(n2);i++)
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define RREP(i,n) for(ll i=((ll)(n)-1);i>=0;i--)
#define FOR(i,n1,n2) for(ll i=(ll)(n1);i<(ll)(n2);i++)
#define RFOR(i,n1,n2) for(ll i=((ll)(n1)-1);i>=(ll)(n2);i--)
#define all(a)  (a).begin(),(a).end()
#define SORT(a) sort((a).begin(),(a).end())
#define oorret 0
#define oor(x) [&](){try{x;} catch(const out_of_range& oor){return oorret;} return x;}()
#define IOS std::cin.tie(0),std::ios::sync_with_stdio(false)

namespace idaten{

using namespace std;
using ll = int_fast64_t;
using ull = uint_fast64_t;
using P = std::pair<int64_t, int64_t>;
template<typename T1, typename T2> inline bool chmin(T1& a, T2 b) { if (a > b) { a = b; return 1; }return 0; }
template<typename T1, typename T2> inline bool chmax(T1& a, T2 b) { if (a < b) { a = b; return 1; }return 0; }
template<class Type>struct is_vector : std::false_type {};
template<class ValueType, class Alloc>struct is_vector<std::vector<ValueType, Alloc>> : std::true_type {};
template <typename T> inline std::ostream& operator << (std::ostream& out, const std::vector<T>& v) {
    if (v.empty())return out;
    constexpr bool is_vector_v = is_vector<T>::value;
    if (is_vector_v)for (auto itr = v.begin(); itr != v.end();)out << (*itr), out << ((++itr != v.end()) ? "\n" : "");
    else for (auto itr = v.begin(); itr != v.end();)out << (*itr), out << ((++itr != v.end()) ? " " : "");
    return out;
}
inline void put() {}
template<class T> inline void put(const T& first) { std::cout << first << "\n"; }
template<class T, class... N> inline void put(const T& first, const N& ... rest) { std::cout << first << " "; put(rest...); }
inline void putn() {}
template<class T, class... N> inline void putn(const T& first, const N& ... rest) { std::cout << first << "\n"; putn(rest...); }


void solve(){
    IOS;
    int a,b;
    cin >> a >> b;
    REP(i,100000){
        int t1 = i*8/100;
        int t2 = i*10/100;
        if(t1==a&&t2==b){
            put(i);
            return;
        }
    }
    put(-1);
}
} // namespace idaten

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


Measured memory_bytes: 256