akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

long long mod = 1e9 + 7;
//メモ化再帰
long long rec(long long n, vector<long long> &step, const vector<bool> &stair)
{
    if (!stair.at(n))
    {
        return step.at(n) = 0;
    }

    if (n == 0)
    {
        return step.at(n) = 1;
    }

    if (n == 1)
    {
        return step.at(n) = 1;
    }

    if (step.at(n) != -1)
    {
        return step.at(n);
    }

    return step.at(n) = (rec(n - 1, step, stair) + rec(n - 2, step, stair)) % mod;
}

int main()
{
    long long N, M;
    cin >> N >> M;
    vector<bool> stair(N + 1, true);
    // i+1段目にたどり着く方法が何通りあるか
    vector<long long> step(N + 1, -1);

    // 壊れた段をfalse
    for (int i = 0; i < M; i++)
    {
        int tmp;
        cin >> tmp;
        stair.at(tmp) = false;
    }

    /*
    rec(N, step, stair);

    for (int i = 0; i < N + 1; i++)
    {
        cout << step.at(i) << " ";
    }
    */

    cout << rec(N, step, stair) << endl;
}


Measured memory_bytes: 7296
#include <bits/stdc++.h>
#define LOOP(n) for (int _i = 0; _i < (n); _i++)
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define FOR(i, r, n) for (int i = (r); i < (n); ++i)
#define ALL(obj) begin(obj), end(obj)
using namespace std;
using ll = long long;
using ull = unsigned long long;

const int INF = 2100100100;
const int MOD = 1e9 + 7;

// 多次元 vector 生成
template <class T>
vector<T> make_vec(size_t a) {
    return vector<T>(a);
}
template <class T, class... Ts>
auto make_vec(size_t a, Ts... ts) {
    return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}
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;
}

int N;

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

    cin >> N;
    vector<string> S(N);
    REP(i, N) cin >> S.at(i);

    map<string, int> m;
    REP(i, N) { m[S[i]]++; }

    int max_num = 0;
    for (auto p : m) {
        chmax(max_num, p.second);
    }

    vector<string> ans;
    for (auto p : m) {
        if (max_num == p.second) {
            ans.push_back(p.first);
        }
    }
    sort(ALL(ans));

    REP(i, (int)ans.size()) { cout << ans[i] << endl; }

    return 0;
}


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

using namespace std;

using i64 = int_fast64_t;

deque<pair<char, int>> f(string &s)
{
    i64 n = s.size(), cur = 1;
    deque<pair<char, int>> ps;
    for (int i = 0; i < n - 1; i++)
    {
        if (s[i] == s[i + 1])
        {
            cur++;
        }
        else
        {
            ps.push_back(make_pair(s[i], cur));
            cur = 1;
        }
    }
    ps.push_back(make_pair(s.back(), cur));
    return ps;
}

void solve()
{
    string s;
    i64 k;
    cin >> s >> k;
    auto ps = f(s);
    if (ps.size() == 1)
    {
        cout << s.size() * k / 2 << endl;
        return;
    }
    i64 ans = 0;
    if (ps.front().first != ps.back().first)
    {
        for (auto &p : ps)
        {
            ans += p.second / 2;
        }
        ans *= k;
        cout << ans << endl;
        return;
    }
    i64 off = 0;
    for (auto &p : ps)
    {
        off += p.second / 2;
    }
    s += s;
    ps = f(s);
    i64 dif = 0;
    for (auto &p : ps)
    {
        dif += p.second / 2;
    }
    dif -= off;
    dif *= k - 1;
    ans = dif + off;
    cout << ans << endl;
}

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


Measured memory_bytes: 256
#include <stdio.h>
int main(){
	long int A,B,ans=-1;
	scanf("%ld%ld",&A,&B);
	if((A+B)%2==0&&(A+B)>0){
		ans=(A+B)/2;
	}
  	if(ans==-1){
    	printf("IMPOSSIBLE");
    }else{
	printf("%ld",ans);
    }
	
}

Measured memory_bytes: 128
#pragma GCC optimize("O3")
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include<bits/stdc++.h>
using namespace std;
#define ll long long
//#define d long double
#define pii pair<int,int>
#define pb push_back
#define N 200003
#define inf (ll)1e18
#define warmup ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
int mod=1e9+7; 

signed main()
{
    warmup
    
    ll a,b,k,mi;
    cin>>a>>b>>k;
    mi=min(a,k);
    a-=mi, k-=mi;
    mi=min(b,k);
    b-=mi, k-=mi;
    cout<<a<<' '<<b;
    
    
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fast ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL)
#define ll long long int
#define ld long double
using namespace std;
const int N = 1e6 + 5;
const int MOD = 1e9 + 7;


int main(){
	fast;
	ll n; cin >> n;
	string s;
	cin >> s;
	map<char, int> mp;
	for(int i = 0; i < s.size(); ++i) mp[s[i]]++;
	ll k = mp['W'], ans = 0;;
	for(int i = n - 1; i >= 0; --i){
		if(k <= 0) break;
		--k; 
		if(s[i] != 'W') ++ans;
	}
	cout << ans;
	return 0;
}


Measured memory_bytes: 3728
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); i++)
#define rng(a) a.begin(),a.end()
using namespace std;
using ll = long long;
using P = pair<int,int>;


int main() {
  int n, k;
  cin >> n >> k;
  set<int> a;
  rep(i,k) {
    int x; cin >> x;
    a.insert(x);
  }
  int ans = n;
  while(ans<100100) {
    int num = ans;
    bool ch = true;
    while(ch&&num>0) {
      if(a.count(num%10)) ch = false;
      num /= 10;
    }
    if(ch) {
      cout << ans << endl;
      return 0;
    }
    ans++;
  }
  return 0;
}

Measured memory_bytes: 3608
//set many funcs
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#define inf 1145141919
#define llinf 1145141919810364364
#define mod 1000000007

int max(int a,int b){if(a>b){return a;}return b;}
int min(int a,int b){if(a<b){return a;}return b;}
int zt(int a,int b){return max(a,b)-min(a,b);}
int round(int a,int b){if((a%b)*2 >= b){return (a/b)+1;}return a/b;}
int ceil(int a,int b){if(a%b==0){return a/b;}return (a/b)+1;}
int gcd(int a,int b){int c;while(b!=0){c=a%b;a=b;b=c;}return a;}
int lcm(int a,int b){int c=gcd(a,b);a/=c;return a*b;}
int nCr(int a,int b){int i,r=1;for(i=1;i<=b;i++){r*=(a+1-i);r/=i;}return r;}
int fact(int a){int i,r=1;for(i=1;i<=a;i++){r*=i;}return r;}
int pow(int a,int b){int i,r=1;for(i=1;i<=b;i++){r*=a;}return r;}
long long llmax(long long a,long long b){if(a>b){return a;}return b;}
long long llmin(long long a,long long b){if(a<b){return a;}return b;}
long long llround(long long a,long long b){if((a%b)*2 >= b){return (a/b)+1;}return a/b;}
long long llceil(long long a,long long b){if(a%b==0){return a/b;}return (a/b)+1;}
long long llgcd(long long a,long long b){long long c;while(b!=0){c=a%b;a=b;b=c;}return a;}
long long lllcm(long long a,long long b){long long c=llgcd(a,b);a/=c;return a*b;}
long long llnCr(long long a,long long b){long long i,r=1;for(i=1;i<=b;i++){r*=(a+1-i);r/=i;}return r;}
long long llfact(long long a){long long i,r=1;for(i=1;i<=a;i++){r*=i;}return r;}
long long llpow(long long a,long long b){long long i,r=1;for(i=1;i<=b;i++){r*=a;}return r;}
double dbmax(double a,double b){if(a>b){return a;}return b;}
double dbmin(double a,double b){if(a<b){return a;}return b;}
int sortfncsj(const void *a,const void *b){if(*(int *)a>*(int *)b){return 1;}if(*(int *)a==*(int *)b){return 0;}return -1;}
int sortfnckj(const void *a,const void *b){if(*(int *)a<*(int *)b){return 1;}if(*(int *)a==*(int *)b){return 0;}return -1;}
int llsortfncsj(const void *a,const void *b){if(*(long long *)a>*(long long *)b){return 1;}if(*(long long *)a==*(long long *)b){return 0;}return -1;}
int llsortfnckj(const void *a,const void *b){if(*(long long *)a<*(long long *)b){return 1;}if(*(long long *)a==*(long long *)b){return 0;}return -1;}
int dbsortfncsj(const void *a,const void *b){if(*(double *)a>*(double *)b){return 1;}if(*(double *)a==*(double *)b){return 0;}return -1;}
int dbsortfnckj(const void *a,const void *b){if(*(double *)a<*(double *)b){return 1;}if(*(double *)a==*(double *)b){return 0;}return -1;}

int main(void){
    long long n,i,t[131072]={0},a[131072]={0},tf[131072]={0},af[131072]={0},r=1;
    scanf("%lld",&n);
    for(i = 1;i <= n;i++){scanf("%lld",&t[i]);}
    for(i = 1;i <= n;i++){scanf("%lld",&a[i]);}
    for(i=1;i<=n;i++){if(t[i-1]<t[i]){tf[i]=1;}}
    for(i=n;i>0;i--){if(a[i]>a[i+1]){af[i]=1;}}
    for(i=1;i<=n;i++){
        if(tf[i]&&t[i]>a[i]){r=0;}
        if(af[i]&&a[i]>t[i]){r=0;}
        if(tf[i]&&af[i]&&t[i]!=a[i]){r=0;}tf[i]=tf[i]+af[i];
    }
    for(i=1;i<=n;i++){
        if(tf[i]==0){r*=llmin(a[i],t[i]);}
        r%=mod;
    }
    printf("%lld\n",r);
    return 0;
}

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


int main(){


    int n, i, t, j;

    int k = 0;

    int m = 0;

 
    cin >> n;


    vector<int> h(n + 1);


    for( i = 1 ; i < n + 1 ; i = i + 1 ){

         cin >> h.at(i);

         }


    for( i = 1 ; i < n ; i = i + 1 ){

         h.at(i) = h.at(i) - h.at(i + 1);

         }


    for( i = 1 ; i < n + 1 ; i = i + 1 ){

         if( i != n && h.at(i) >= 0 ) k += 1;           

         else{ m = max(m, k);

               k = 0;

               }

          }


    cout << m << endl;
         

    return 0;


    }

Measured memory_bytes: 640
(defvar *count* 0)

(defun *3or/2 (num)
  (do ((dammy 0))
      ((= 1 (mod num 2)))
    (setf num (/ num 2))
    (incf *count*)))

(dotimes (i (read))
  (*3or/2 (read)))

(format t "~A~%" *count*)

Measured memory_bytes: 16744
#include <iostream>
#include <vector>
#include <string>
#include <set>
#include <algorithm>

#define int_inf 1000000000
#define ll_inf	100000000000000000000000

using namespace std;


int main(){
	string s;
	cin >> s;
	
	for(int i=0; i<s.size()-1; i++){
		if(s[i]=='A' && s[i+1]=='C'){
			cout << "Yes" << endl;
			return 0;
		}
	}
	cout << "No" << endl;
	
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <set>
#include <map>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <functional>
#include <algorithm>
#include <climits>
#include <cmath>
#include <iomanip>
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000

int ans[41000];
int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n; cin >> n;
    int t[110], v[110];
    rep(i, n) cin >> t[i];
    rep(i, n) cin >> v[i];
    int sumT = 0;
    rep(i, n) sumT += t[i] * 2;
    int k = 0;
    int T = t[0] * 2;
    int i = 0;
    while(k < n) {
        ans[i + 1] = min(ans[i] + 1, v[k] * 2);
        i++;
        T--;
        if(T == 0) {k++; T = t[k] * 2;}
    }
    k = n - 1;
    T = t[n - 1] * 2;
    ans[i] = 0;
    while(k >= 0) {
        ans[i - 1] = min({ans[i - 1], ans[i] + 1, v[k] * 2});
        i--;
        T--;
        if(T == 0) {k--; T = t[k] * 2;}
    }
    //rep(i, 220) cout << i/2.0 << " " << ans[i]/2.0 << endl;
    int sum = 0;
    rep(i, 40001) sum += ans[i];
    cout << fixed << setprecision(12) << sum/4.0 << endl;


    return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <ios>
#include <iomanip>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <utility>
#include <typeinfo>
#include <tuple>
using namespace std;

#define MOD 1000000007
#define INF 1e9+7
#define INF_LONG 1e18
#define rep(i, n) for(int i=0; i<n; ++i)
#define rep1(i, n) for(int i=1; i<=n; ++i)
#define rrep(i, m, n) for(int i=m; i<n; ++i)
#define countof(array) (sizeof(array) / sizeof(array[0]))
typedef long long ll;

#define MAX_N 200000
#define MAX_M 100000
#define MAX_V 100
#define MAX_E 100
#define MAX_Q 100000

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

int ddx[] = {-1, 0, 1, 0, -1, 1, -1, 1};
int ddy[] = {0, -1, 0, 1, 1, 1, -1, -1};

string as = {"ABCDEFGHIJKLMNOPQRSTUVWXYZ"};
string ab = {"abcdefghijklmnopqrstuvwxyz"};

ll gcd(ll x, ll y) {
  if(y==0) return x;
  else return gcd(y, x%y);
}

ll lcm(ll x, ll y) {
  return (x*y)/gcd(x, y);
}

void yes() {
  cout << "Yes" << endl;
}

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

void print_array(int array[], int len) {

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

}

ll absolute(ll x) {
  return (x<0)? (-1)*x : x;
}

//g++ AtCoder.cpp -o AtCoder
//AtCoder

//--------------------------
int main() {

  int a, b, c;
  cin >> a >> b >> c;
  cout << c << " " << a << " " << b << endl;

  return 0;
}


Measured memory_bytes: 256
package main
import "fmt"

func deleteAryLeft(oAry []int, len int) []int{
	return oAry[len:]
}

func execMain4(num int, sAry []int) int {
	search_num := 1
	var ans_ary []int
	bcnt := 0
	for ; ; {
		isHit := false
		for i := 0; i < len(sAry); i++ {
			if sAry[i] == search_num {
				tAry := sAry[0:i+1]
				sAry = deleteAryLeft(sAry, len(tAry))
				ans_ary = append(ans_ary, tAry[i])
				if len(tAry) > 1 {
					bcnt += len(tAry) - 1
				}
				search_num++
				isHit = true
				break
			}
		}

		if !isHit {
			bcnt += len(sAry)
			break
		}
	}

	if len(ans_ary) < 1 {
		return -1
	}

	return bcnt
}

func main() {
	var num int

	fmt.Scanf("%d", &num)
	sAry := make([]int, num)
	for i := 0; i < num; i++ {
		fmt.Scan(&sAry[i])
	}

	fmt.Print(execMain4(num, sAry))
}




Measured memory_bytes: 9984
#include <iostream>
#include <algorithm>

typedef long long ll;
typedef unsigned long long ull;

ll n, a[100005], ans;
ll sum[100005];

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

	std::cin >> n;
	for (int i = 0; i < n; ++i) {
		std::cin >> a[i];
	}

	std::sort(a, a + n);

	for (int i = 0; i < n; ++i) {
		sum[i] = (i == 0) ? a[i] : sum[i - 1] + a[i];
	}

	int l = 0, r = n - 1, m = 0;

	while (r - l > 1) {
		m = (l + r) / 2;

		for (int i = m; i < n; ++i) {
			if (i == n - 1) {
				r = m;
			}
			else if (i != n - 1 && sum[i] * 2 < a[i + 1]) {
				l = m;
				break;
			}
		}
	}

	for (int i = l; i < n; ++i) {
        if (i == n - 1) {
            std::cout << n - l << std::endl;
        }
        else if (i != n - 1 && sum[i] * 2 < a[i + 1]) {
            std::cout << n - r << std::endl;
            return 0;
        }
    }

    return 0;
}


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

int cmp(const void *a, const void *b) {
    return (*(const int*)b)-(*(const int*)a);
}

int n;
int d[100];
int main() {
    cin >> n;
    for(int i = 0 ; i < n ; i++) {
        cin >> d[i];
    }

    qsort(d, n, sizeof(int), cmp);
    int cnt=1;
    for(int i = 1 ; i < n ; i++) {
        if( d[i] < d[i-1] ) cnt++;
    }
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 256
# ソートして左右からとっていくが、可能ならば同じ数字が連続しないようにする
# めんどいわ なーにが「可能ならば」じゃ
# 左右どちらを先にとるかでいいんじゃないの
# -> だめでした
# 理屈はわからんが、最後のやつを最初にもっていくやつが浮かんだがなんだこれ
n = int(input())
arr = []
for _ in range(n):
    arr.append(int(input()))
arr = sorted(arr)


def f(arr):
    ans = []
    c, l, r = 0, 0, n - 1
    while c < n:
        if c % 2 == 0:
            ans.append(arr[l])
            l += 1
        else:
            ans.append(arr[r])
            r -= 1
        c += 1
    ans = [ans[-1]] + ans[:-1]
    result, tmp = 0, ans[0]
    for i in range(1, n):
        result += abs(tmp - ans[i])
        tmp = ans[i]
    return result


a, b = f(arr), f(list(reversed(arr)))
print(max(a, b))


Measured memory_bytes: 10132
#include <iostream>
#include <vector>
using namespace std;
int gcd(int a, int b) { return b?gcd(b, a%b):a; }

int main()
{
  int N, X, D, ans=0;
  cin >> N >> X;
  vector<int> x(N);
  for(int n=0; n<N; ++n)
  {
    cin >> x[n];
    x[n] = X-x[n];
  }
  for(int n=0; n<N; ++n)
  {
    ans = gcd(ans, x[n]);
  }
  cout << abs(ans) << endl;
  return 0;
}


Measured memory_bytes: 640
// $%U%$ $%Y%$-$%M%$-$%D%$ $%h%$:$%m%$

#include <bits/stdc++.h>

using namespace std;
using ll = long long;

int main(){
	cin.tie(0);
	ios_base::sync_with_stdio(0);
	int a,b,c;
	cin>>a>>b>>c;
	if(a==b&&b==c){
		cout<<"No\n";
	} else if(a==b || a==c || b==c){
		cout<<"Yes\n";
	} else {
		cout<<"No\n";
	}
	return 0;
}



Measured memory_bytes: 256
package main

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

func readLine(sc *bufio.Scanner) string {
	sc.Scan()
	return sc.Text()
}

func lineToInts(line string) []int {
	var res []int
	for _, s := range strings.Split(line, " ") {
		i, _ := strconv.Atoi(s)
		res = append(res, i)
	}
	return res
}

func judge(as, bs []int, m, c int) bool {
	calc := 0
	for j := 0; j < m; j++ {
		calc += as[j] * bs[j]
	}
	return calc+c > 0
}

func main() {
	sc := bufio.NewScanner(os.Stdin)
	line1 := lineToInts(readLine(sc))
	n, m, c := line1[0], line1[1], line1[2]

	bs := lineToInts(readLine(sc))
	res := 0
	for i := 0; i < n; i++ {
		as := lineToInts(readLine(sc))
		if judge(as, bs, m, c) {
			res++
		}
	}
	fmt.Println(res)
}


Measured memory_bytes: 640
import java.util.*;
public class Main{
	public static void main(String[] args){
      	Scanner sc = new Scanner(System.in);
      	int N = sc.nextInt();
      	int[] L = new int[N];
        for(int i=0;i<N;i++){
          L[i] = sc.nextInt();
        }
        int[] check = new int[1001];
        for (int i=0;i<1001;i++){check[i]=0;}
      	long ans = 0;
        for(int i=0;i<N;i++){
          check[L[i]]++; 
        }
      	for(int i=0;i<N-1;i++){
          for(int j=i+1;j<N;j++){
            int sa = ((L[i]>L[j])?L[i]-L[j]:L[j]-L[i])+1;
            int wa = ((L[i]+L[j]>1000)?1000:L[i]+L[j]-1);
            for(int l = sa;l<=wa;l++){
              ans += check[l];
       
            }
            //自分を数えない
            if(sa <= L[i]&&L[i] <= wa){ans--;}
            if(sa <= L[j]&&L[j] <= wa){ans--;}
          }
        }
        System.out.println(ans/3);
    }
}

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

#define int long long
#define vvi vector<vector<int>>
#define vec vector
#define pq priority_queue
#define all(v) (v).begin(), (v).end()
#define uniqueV(x) sort(x.begin(), x.end()); x.erase(unique(x.begin(), x.end()), x.end());
#define rep(i, n) for (int (i) = (0); (i) < (n); ++(i))
#define repp(i, m, n) for (int (i) = (m); (i) < (n); ++(i))
#define dbg(x) cerr << #x << ": " << x << endl;
#define dbg2(x, y) cerr<<"("<<#x<<", "<<#y<<") = "<<"("<<x<<", "<<y<<")"<<endl;
#define dbg3(x, y, z) cerr<<"("<<#x<<", "<<#y<<", "<<#z<<") = "<<"("<<x<<", "<<y<<", "<<z<<")"<<endl;
#define dbgB(value, size) cerr<<#value<<": "<<bitset<size>(value) << endl;
#define line() cerr << "---------------" << endl;

const int dx[] = {1, -1, 0, 0};
const int dy[] = {0, 0, -1, 1};
const double PI = 3.14159265358979323846;

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; }

template<typename T>
void print1(T begin, T end) {
	while (begin != end) {
		cerr << (*begin) << " ";
		*begin++;
	}
	cerr << endl;
}

template<typename T>
void print2(T Array, int height, int width) {
	for (int i = 0; i < height; i++) {
		for (int j = 0; j < width; j++) {
			cerr << " " << Array[i][j];
		}
		cerr << endl;
	}
}

void print() { std::cerr << endl; }
template <class Head, class... Tail>
void print(Head&& head, Tail&&... tail) {
	std::cerr << head << " ";
	print(std::forward<Tail>(tail)...);
}

template<class T>
void Add(T &a, const T &b, const T &mod=1000000007) {
	int val = ((a % mod) + (b % mod)) % mod;
	if (val < 0) { val += mod; }
	a = val;
}

template <typename X, typename T> auto vectors(X x, T a) { return vector<T>(x, a); }
template <typename X, typename Y, typename Z, typename... Zs> auto vectors(X x, Y y, Z z, Zs... zs) { auto cont = vectors(y, z, zs...); return vector<decltype(cont)>(x, cont); }

// ------------------------------------------------------------------------------------------

int A[3][3];
int N;

void fff(int b) {
	rep (i, 3) {
		rep (j, 3) {
			if (A[i][j] == b) {
				A[i][j] = -1;
			}
		}
	}
}

bool check() {
	// 縦
	rep (i, 3) {
		int tCnt = 0;
		int yCnt = 0;
		rep (j, 3) {
			yCnt += A[i][j] == -1;
			tCnt += A[j][i] == -1;
		}
		if (tCnt == 3 or yCnt == 3) {
			return true;
		}
	}

	// 斜め
	int nCnt = 0;
	rep (i, 3) {
		nCnt += A[i][i] == -1;
	}
	if (nCnt == 3) {
		return true;
	}

	if (A[0][2] == -1 and A[1][1] == -1 and A[2][0] == -1) {
		return true;
	}

	return false;
}

signed main() {
	rep (i, 3) {
		rep (j, 3) {
			cin >> A[i][j];
		}
	}
	cin >> N;

	rep (i, N) {
		int b;
		cin >> b;
		fff(b);
	}

	puts(check() ? "Yes" : "No");

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i< (int)(n); i++)
#define rep2(i,x,n) for(int i = (int)x; i < (int)(n); i++)
#define repit(itr,x) for(auto itr = x.begin(); itr != x.end(); itr++)
#define repitr(ritr,x) for(auto ritr = x.rbegin(); ritr != x.rend(); ritr++)
#define ALL(n) begin(n), end(n)
using ll = long long;
using namespace std;

int main(){
	int n, in;
	cin >> n;
	vector<int> p(n);
	rep(i, n){
		cin >> in;
		in--;
		p.at(in) = i;
	}
	int ans = 0, temp = -1;
	rep(i, n){
		if(i != n-1 && p.at(i) > p.at(i+1)){
			ans = max(ans, i - temp);
			temp = i;
		}else if(i == n - 1){
			ans = max(ans, i - temp);
		}
	}
	cout << n - ans << endl;
	return 0;
}

Measured memory_bytes: 1024
#define _GLIBCXX_DEBUG
#include <iostream>
#include <vector>
using namespace std;

int main(){
  int N, W;
  cin >> N >> W;
  vector<int> ans(N+1, 0);
  ans[0] = W;
  for(int i = 1; i <= W/2; ++i){
    ++ans[i+1];
  }
  for(int i = W/2+1; i < W; ++i){
    for(int j = 3; j*i <= N; ++j){
      ++ans[j*i-W+1];
      --ans[j*i+1-i];
    }
  }
  for(int i = 1; i <= N-W+1; ++i){
    ans[i] += ans[i-1];
  }
  cout << ans[1];
  for(int i = 2; i <= N-W+1; ++i) cout << " " << ans[i];
  cout << endl;
  return 0;
}



Measured memory_bytes: 3096
#![allow(non_snake_case, unused_imports)]

// Input
macro_rules! input { (source = $s:expr, $($r:tt)*) => { let mut iter = $s.split_whitespace(); let mut next = || { iter.next().unwrap() }; input_inner!{next, $($r)*} }; ($($r:tt)*) => { let stdin = std::io::stdin(); let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock())); let mut next = move || -> String{ bytes.by_ref().map(|r|r.unwrap() as char).skip_while(|c|c.is_whitespace()).take_while(|c|!c.is_whitespace()).collect() }; input_inner!{next, $($r)*} }; }
macro_rules! input_inner { ($next:expr) => {}; ($next:expr, ) => {}; ($next:expr, $var:ident : $t:tt $($r:tt)*) => { let $var = read_value!($next, $t); input_inner!{$next $($r)*} }; ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => { let mut $var = read_value!($next, $t); input_inner!{$next $($r)*} }; }
macro_rules! read_value { ($next:expr, ( $($t:tt),* )) => { ( $(read_value!($next, $t)),* ) }; ($next:expr, [ $t:tt ; $len:expr ]) => { (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>() }; ($next:expr, [ $t:tt ]) => { { let len = read_value!($next, usize); (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>() } }; ($next:expr, chars) => { read_value!($next, String).chars().collect::<Vec<char>>() }; ($next:expr, bytes) => { read_value!($next, String).into_bytes() }; ($next:expr, usize1) => { read_value!($next, usize) - 1 }; ($next:expr, $t:ty) => { $next().parse::<$t>().expect("Parse error") }; }

// Module
use std::cmp::{min,max};
use std::collections::{HashSet,HashMap,BTreeMap,VecDeque};

// Functions

// Main
fn main(){
    input!{
        _N: usize,
        S: chars,
    }
    let mut cnt = 0;
    for s in S{
        if s=='R'{
            cnt += 1;
        }else{
            cnt -= 1;
        }
    }
    println!("{}",if cnt>0{"Yes"}else{"No"});
}

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

int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  int64_t sum = 0;
  for(int i = 0; i < n; i++) {
    int ai;
    cin >> ai;
    sum += ai;
    a[i] = ai;
  }
  sort(a.begin(), a.end());
  cout << a[0] << ' ' << a[n - 1] << ' ' << sum << "\n";
}


Measured memory_bytes: 3160
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll cnt[2020],a[2020],cnt2[2020];
int main(){
	ll n,k,mod=1e9+7;
	cin>>n>>k;
	ll ans=0;
	for(int i=0;i<n;i++)cin>>a[i];
	for(int i=0;i<n;i++)for(int j=0;j<n;j++){
		if(a[i]>a[j])cnt[i]++;
		if(i<j&&a[i]>a[j])cnt2[i]++;
	}
	ll x=k*(k-1)/2;
	x%=mod;
	for(int i=0;i<n;i++){
		ans+=x*cnt[i];
		ans%=mod;
		ll num=k*cnt2[i];
		num%=mod;
		ans+=num;
		ans%=mod;
	}
	cout<<ans;
	return 0;
}


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

int main() {
    int D, N;
    cin >> D >> N;

    if(D==0){
        if(N==100) {
            cout << 101 << endl;
            return 0;
        }
        else{
            cout << N << endl;
            return 0;
        }
    }
    if(D==1){
        if(N==100){
            cout << 10100 << endl;
            return 0;
        }
        else{
            cout << N*100 << endl;
            return 0;
        }
    }
    else{
        if(N==100){
            cout << 1010000 << endl;
            return 0;
        }
        else{
            cout << N*10000 << endl;
            return 0;
        }
    }
}

Measured memory_bytes: 256
b = input()

if b == 'A':
    answer = 'T'
elif b == 'T':
    answer = 'A'
elif b == 'C':
    answer = 'G'
elif b == 'G':
    answer = 'C'
else:
    answer = '入力間違い【A】【T】【C】【G】を入力'

print(answer)

Measured memory_bytes: 9004
def dfs(i, f, sum):
    if i == 3:
        if sum == 7:
            print(f + "=7")
            exit()
    else:
        dfs(i + 1, f + "+" + a[i + 1], sum + int(a[i + 1]))
        dfs(i+1, f + "-" + a[i+1], sum-int(a[i+1]))


a = input()
dfs(0, a[0], int(a[0]))

Measured memory_bytes: 3060
#include <bits/stdc++.h>
int n;
char s[501];
int ch[51][51];
main(){
	scanf("%d",&n);
	for(int i=1;i<=n;++i){
		scanf("%s",s+1);
		int kk=strlen(s+1);
		for(int j=1;j<=kk;++j)
		  ++ch[i][s[j]-96];
//		for(int j=1;j<=26;++j)
//		  printf("%d\n",ch[i][j]);
	}
	for(int j=1;j<=26;++j){
		int min=0x3f3f3f3f;
		for(int i=1;i<=n;++i){
			min=std::min(min,ch[i][j]);
		}
		for(int i=1;i<=min;++i)
		  printf("%c",j+96);
	}
}

Measured memory_bytes: 256
#include <algorithm>
#include <bits/stdc++.h>
#include <bitset>
#include <cassert>
#include <cstring>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <cmath>
#include <memory>
#include <queue>
#include <set>
#include <stack>
#include <utility>
#include <vector>
using namespace std;
#define REP(i, n) for (int64_t i = 0; i < (int64_t)n; i++)
#define REP_FOR(i, a, b) for (int64_t i = (int64_t)a; i < (int64_t)b; i++)
#define REP_REV(i, a, b) for (int64_t i = (int64_t)a; i > (int64_t)b; i--)
#define FORALL(v) (v).begin(), (v).end()
#define mp(a, b) make_pair(a, b)
#define eb(x) emplace_back(x)
#define F first
#define S second
typedef long long ll;
typedef long double ld;
typedef pair<int64_t, int64_t> pii;
typedef pair<ll, ll> pll;
typedef pair<ld, ld> pdd;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<int64_t> vii;
typedef vector<vii> vvii;
const ll mod = 1e9 + 7;
const int64_t infi = 1147483600;
const ll infl = 4e18 + 5;
const char EOL = '\n';
const ll MOD = 998244353;

int main() {
    ll n, m;
    cin >> n >> m;
    vector<ll> S(m), C(m);
    for (ll i = 0 ; i < m; ++i) {
        cin >> S[i] >> C[i];
    }
    ll minv = 1;
    ll maxv = 10;
    for (ll i = 1; i < n; ++i) {
        minv *= 10;
        maxv *= 10;
    }
    if (minv == 1) minv = 0;

    for (ll i = minv; i < maxv; ++i) {
        bool b = true;
        for (ll j = 0; j < m; ++j) {
            auto tmp = i;
            for (ll k = S[j]; k < n; ++k) {
                tmp /= 10;
            }
            tmp %= 10;
            if (tmp != C[j]) {
                b = false;
                break;
            }
        }
        if (b) {
            cout << i << endl;
            return 0;
        }
    }
    cout << -1 << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <string>
#include <sstream>
#include <complex>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cmath>
#include <cassert>
#include <fstream>
#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define SSTR( x ) static_cast< std::ostringstream & >( \
        ( std::ostringstream() << std::dec << x ) ).str()
#define ALL(s) (s).begin(), (s).end()
using namespace std;
typedef long long unsigned int llu;
typedef long long ll;


int main (){
  int N;
  while (cin >> N){
    vector<int> a;
    REP(i,N){
      int ia;
      cin >> ia;
      a.push_back(ia);
    }

    bool flag = true;
    int cnt = 0;
    while(flag){
      flag = false;
      for(int j = N-1; j > 0; j--){
	if(a[j] < a[j-1]){
	  swap(a[j],a[j-1]);
	  cnt++;
	  flag = true;
	}
      }
    }
    
    REP(i,N-1){
      cout << a[i] << " ";
    }
    cout << a[N-1] << endl;
    cout << cnt << endl;
    a.clear();
  }
  return 0;
}



Measured memory_bytes: 3136
#include <bits/stdc++.h>
#define pb push_back
#define fs first
#define sc second
#define all(x) (x).begin(), (x).end()
#define sz(x) (int)(x).size()
using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<double> vd;
typedef pair<int, int> pii;
typedef vector<pii> vpii;

const int N=330000;
ll x[N];

int main() {
    ll i, n, s=0;
    scanf("%lld", &n);
    for(i=0; i<3*n; i++) scanf("%lld", &x[i]);
    sort(x, x+3*n);
    for(i=1; i<=n; i++) s+=x[3*n-2*i];
    printf("%lld\n", s);
    return 0;
}

Measured memory_bytes: 2560
from collections import deque


H,W = map(int,input().split())
Ch,Cw = map(int,input().split())
Dh,Dw = map(int,input().split())
S = [input() for i in range(H)]

dist = [[10**9+7] * W for _ in range(H)]
Ch = Ch-1
Cw = Cw-1
Dh = Dh-1
Dw = Dw-1

queue = deque()
queue.append((Ch,Cw))
queue2 = deque()
dist[Ch][Cw] = 0

walk = [[0,1],[1,0],[0,-1],[-1,0]]
    
while len(queue) > 0:
    while len(queue) > 0:
        h, w = queue.popleft()
        d = dist[h][w]
        flag = 0
        for vh,vw in walk:
            nh = h + vh
            nw = w + vw
            if 0 <= nh and nh < H and 0 <= nw and nw < W:
                if S[nh][nw] == '.':
                    if dist[nh][nw] > d:
                        dist[nh][nw] = d
                        queue.append([nh,nw])
                else:
                        flag += 1
        if flag:
            queue2.append([h,w])
            
    while len(queue2) > 0:
        h, w = queue2.popleft()
        for vh in range(-2,3):
            for vw in range(-2,3):
                nh = h + vh
                nw = w + vw
                if 0 <= nh and nh < H and 0 <= nw and nw < W:
                    if S[nh][nw] == '.' and dist[nh][nw] == 10**9+7:
                        dist[nh][nw] = dist[h][w] + 1
                        queue.append([nh,nw])
                
if dist[Dh][Dw] != 10**9+7:
    print(dist[Dh][Dw])
else:
    print(-1)


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

using namespace std;
#define all(a)a.begin(),a.end()
using ll=long long;
const int INF = 1<<30;
const ll INFll =1LL<<62;
const int mod= int(1e9)+7;
using P = pair<ll,ll>;
using ld=long double;

int main(){
    ll n;cin >>n;
    vector<ll>d(n);
    for (int i = 0; i < n; ++i) {
        cin >>d[i];
    }
    ll ans=0;
    for (int i = 0; i < n-1; ++i) {
        for (int j = i+1; j <n; ++j) {
            ans+=d[i]*d[j];
        }
    }
    cout <<ans <<endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.*;
import java.text.DecimalFormat;

// Warning: Printing unwanted or ill-formatted data to output will cause the test cases to fail


public class Main {
    public static void main(String args[] ) throws Exception {
        Scanner in = new Scanner(System.in);
        
        DecimalFormat numberFormat = new DecimalFormat("0.00000");
        int n = in.nextInt();
        float[] A = new float[n];
        for(int i=0;i<n;i++) {
        	A[i] = in.nextFloat();
        }
        
        double inv = 0;
        for(int i=0;i<n;i++) {
        	inv += 1/A[i];
        }
        
        inv = 1/inv;
        
        System.out.println(numberFormat.format(inv));
        		
    }
            
        


    
    
   
}


Measured memory_bytes: 24268
#include <bits/stdc++.h>
#define rep(i, a) for (int i = (int)0; i < (int)a; ++i)
#define rrep(i, a) for (int i = (int)a - 1; i >= 0; --i)
#define REP(i, a, b) for (int i = (int)a; i < (int)b; ++i)
#define RREP(i, a, b) for (int i = (int)a - 1; i >= b; --i)
#define pb push_back
#define eb emplace_back
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define popcount __builtin_popcount
using ll = long long;
constexpr ll mod = 1e9 + 7;
constexpr ll INF = 1LL << 60;

template <class T>
inline bool chmin(T &a, T b)
{
	if (a > b)
	{
		a = b;
		return true;
	}
	return false;
}
template <class T>
inline bool chmax(T &a, T b)
{
	if (a < b)
	{
		a = b;
		return true;
	}
	return false;
}

ll gcd(ll n, ll m)
{
	ll tmp;
	while (m != 0)
	{
		tmp = n % m;
		n = m;
		m = tmp;
	}
	return n;
}

ll lcm(ll n, ll m)
{
	return abs(n) / gcd(n, m) * abs(m); //gl=xy
}

using namespace std;

void solve()
{
	ll n,d;
	cin>>n>>d;
	ll ans=0;
	rep(i,n){
		ll x,y;
		cin>>x>>y;
		if(x*x+y*y<=d*d)
		++ans;
	}
	cout<<ans;
}

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


Measured memory_bytes: 3636
#include<bits/stdc++.h>
#define pi 3.141592653897932384626
//freopen("in.txt","r",stdin);freopen("out.txt","w",stdout);
using namespace std;
char a[315][315];
int main()
{
    long n;
    cin>>n;
    fgets(a[0],3000,stdin);
    for(long i=0;i<n;i++)fgets(a[i],3000,stdin);
    long s=0;
    for(long x=0;x<n;++x){
        long flag=1;
        for(long i=0;i<n;++i){
            for(long j=0;j<n;++j){
                if(a[(x+i)%n][j]!=a[(j+x)%n][i])
                    {flag=0;}
            }
        }
        s+=flag;
    }
    printf("%ld\n",s*n);
    return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <map>
#include <iterator>
#include <iomanip>
using namespace std;

int main()
{
    double w,h,x,y ;
    int poss=0 ;
    cin >>w>>h>>x>>y ;
    if ((x==w/2)&&(y==h/2)) {poss=1 ;}
    cout << fixed << setprecision(10) <<double ((w*h)/2.0) << " "<<  poss ;
}

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

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;
typedef vector<ll> vl;
typedef vector<vl> vvl;
template<typename T> using pq = priority_queue<T>;
template<typename T> using minpq = priority_queue<T, vector<T>, greater<T>>;
template<typename T, typename K> using ump = unordered_map<T, K>;
const ll dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
const ll mod = 1000000007;
const ll inf = ll(1e9);
const ll e5 = ll(1e5);
const ll ll_inf = ll(1e9) * ll(1e9);

#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define repr(i, n) for(ll i = n - 1; i >= 0; i--)
#define repone(i, n) for(ll i = 1; i <= (ll)(n); i++)
#define each(i, mp) for(auto& i:mp)
#define eb emplace_back
#define F first
#define S second
#define all(obj) (obj).begin(), (obj).end()

template<class T>
void dump_debug(T list) {
#ifdef MY_DEBUG
    each(e, list) cout << e << " ";
    printf("\n");
#endif
}

/* ------------- ANSWER ------------- */
/* ---------------------------------- */

int main() {
#ifdef MY_DEBUG
    while (true) {
#endif
        ll n, m;
        cin >> n >> m;

        pq<pair<ll, ll>> que;
        rep(i, n) {
            ll a, b;
            cin >> a >> b;
            if (a > m) continue;
            que.push(make_pair(-a, b));
        }

        ll ans = 0;

        pq<pair<ll, ll>> candidates;
        for (ll i = 0; i <= m; ++i) {
            while (!que.empty() && -que.top().first <= i) {
                P now = que.top();
                candidates.push(make_pair(now.second, now.first));
                que.pop();
            }

            if (!candidates.empty()) {
                ans += candidates.top().first;
                candidates.pop();
            }
        }

        cout << ans << endl;


#ifdef MY_DEBUG
    }
#endif
    return 0;
}

Measured memory_bytes: 4848
import fractions

def calc_lcm(a):
    ans = a[0]
    N = len(a)
    for i in range(1, N):
        ans = ans * a[i] // fractions.gcd(ans, a[i])
    return ans

N = int(raw_input())
a = map(int, raw_input().split())

LCM = calc_lcm(a)

ans = 0
for i in range(N):
    ans = ans + LCM/a[i]

print ans%(10**9+7)


Measured memory_bytes: 4776
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define mod 1000000007
#define pb push_back
#define mp make_pair
#define PI 3.14159265358979323846264338327950288
#define mt make_tuple


void love() {
	int n;
	cin>>n;

	double ans = 0.0;
	if(n&1) {
		ans = 1.0 * (n+1)/(2*n);
	}
	else ans = 1.0 * n / (2 * n);
	cout<<ans<<endl;
}

int main() {
	ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
	love();
	return 0;
}

Measured memory_bytes: 256
N = int(input())
H = list(map(int, input().split()))

movable = [0]*N
i = 0
while i < N-1:
    j = i
    while j < N-1 and H[j] >= H[j+1]:
        movable[i] += 1
        j += 1
    i = i + movable[i] + 1

print(max(movable))

Measured memory_bytes: 14252
def main():
    N, K = map( int, input().split())
    ANS = [1]*N
    for _ in range(K):
        d = int( input())
        A = list( map( lambda x: int(x)-1, input().split()))
        for a in A:
            ANS[a] = 0
    print( sum(ANS))
if __name__ == '__main__':
    main()


Measured memory_bytes: 9120
#include <bits/stdc++.h>
using namespace std;
#define PI 3.14159265358979323
#define ll long long int
#define vi vector <int>
#define vl vector <ll>
#define all(v) (v).begin(),(v).end()
#define pb push_back
#define ff first
#define ss second
#define MOD 1000000007

const ll mod = 1e9 + 7;

ll power(ll a, ll b) { //a^b
	ll res = 1;
	a = a % MOD;
	while (b > 0) {
		if (b & 1) {res = (res * a) % MOD; b--;}
		a = (a * a) % MOD;
		b >>= 1;
	}
	return res;
}

ll gcd(ll a, ll b) {return (b == 0) ? a : gcd(b, a % b);}

int main() {
#ifndef ONLINE_JUDGE
	// for getting input from input.txt
	freopen("input.txt", "r", stdin);
	// for writing output to output.txt
	freopen("output.txt", "w", stdout);
#endif
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	ll n;
	cin >> n;
	if (n < 2) {
		cout << "0";
		return 0;
	}
	if (n == 2)
		cout << 2 << "\n";
	else {
		ll ans = power(10, n);
		ans = (ans - 2LL * power(9, n) % mod + power(8, n) % mod + mod) % mod;
		cout << ans << "\n";
	}
}


Measured memory_bytes: 3620
N = int(input())
src = list(map(int, input().split()))
MAX = 10**5

counts = [0 for i in range(MAX+1)]
for a in src:
    if a > 0: counts[a-1] += 1
    counts[a] += 1
    counts[a+1] += 1

print(max(counts))


Measured memory_bytes: 14092
#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 blocks[][7] =
  {
   {0, 1, 2, 4, 6, 7, 9},
   {1, 3, 4, 6, 8, 9, 11},
   {2, 4, 5, 7, 9, 10, 12},
   {6, 8, 9, 11, 13, 14, 16},
   {7, 9, 10, 12, 14, 15, 17},
   {9, 11, 12, 14, 16, 17, 18},
   {4, 6, 7, 9, 11, 12, 14},
  };

bool solve() {
  char S[256];

  scanf("%s", S);

  if (S[0] == '#') return false;

  bool isChange[256];

  for (int i=0; i<(1<<7); i++) {
    isChange[i] = !!(i & (1<<3)) ^ (S[i] == '1');
  }

  for (int i=0; i<(1<<19); i++) {
    int x = i, prevx;

    for (int _=0; _<2; _++) {
      prevx = x;
      for (int j=0; j<7; j++) {
        int r = 0;
        for (int k=0; k<7; k++) {
          r += !!(prevx & (1 << blocks[j][k])) << k;
        }
        if (isChange[r]) x ^= 1 << blocks[j][3];
      }
    }

    if ((prevx & (1<<9)) != (x & (1<<9))) {
      debug(prevx); debug(x);
      puts("no");
      return true;
    }
  }

  puts("yes");

  return true;
}

int main(){

  while(solve());


  return 0;
}



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

#define INF_LL (int64)1e18
#define INF (int32)1e9
#define REP(i, n) for(int64 i = 0;i < (n);i++)
#define FOR(i, a, b) for(int64 i = (a);i < (b);i++)
#define all(x) x.begin(),x.end()
#define fs first
#define sc second

using int32 = int_fast32_t;
using uint32 = uint_fast32_t;
using int64 = int_fast64_t;
using uint64 = uint_fast64_t;
using PII = pair<int32, int32>;
using PLL = pair<int64, int64>;

const double eps = 1e-10;

template<typename A, typename B>inline void chmin(A &a, B b){if(a > b) a = b;}
template<typename A, typename B>inline void chmax(A &a, B b){if(a < b) a = b;}

template<typename T>
vector<T> make_v(size_t a){return vector<T>(a);}

template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
  return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}

template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value!=0>::type
fill_v(U &u,const V... v){u=U(v...);}

template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value==0>::type
fill_v(U &u,const V... v){
  for(auto &e:u) fill_v<T>(e,v...);
}

int main(void){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int64 n;
	cin >> n;
	REP(_, n) {
		string op, s;
		cin >> op >> s;
		reverse(all(op));
		REP(i, op.size()) {
			if (op[i] == 'C') {
				s = s.substr(1, s.size()-1) + s[0];
			} else if (op[i] == 'J') {
				s = s.back() + s.substr(0, s.size()-1);
			} else if (op[i] == 'E') {
				if (s.size() % 2) {
					s = s.substr(s.size()/2+1, s.size()/2) + s[s.size()/2] + s.substr(0, s.size()/2);
				} else {
					s = s.substr(s.size()/2, s.size()/2) + s.substr(0, s.size()/2);
				}
			} else if (op[i] == 'A') {
				reverse(all(s));
			} else if (op[i] == 'M') {
				REP(j, s.size()) {
					if ('0' <= s[j] && s[j] <= '9') {
						s[j] = (char)((s[j]-'0'+1)%10+'0');
					}
				}
			} else {
				REP(j, s.size()) {
					if ('0' <= s[j] && s[j] <= '9') {
						s[j] = (char)((s[j]-'0'+9)%10+'0');
					}
				}
			}
		}
		cout << s << endl;
	}
}



Measured memory_bytes: 3124
#include <cstdlib>
#include <iostream>
#include <stack>
#include <vector>
#include <algorithm>

using namespace std;

int main(int argc, char *argv[])
{
    int i, j, sum, a;
    char ch;
    stack<int> S1;
    stack<pair<int, int> > S2;
    vector<int> V;
    
    sum = 0;
    for (i = 0; cin >> ch; i++) {
        if (ch == '\\') {
               S1.push(i);
        } else if (ch == '/' && S1.size() > 0) {
               j = S1.top(); S1.pop();
               sum += (i - j);
               a = i - j;
               while (S2.size() > 0 && S2.top().first > j) {
                     a += S2.top().second; S2.pop();
               }
               S2.push(make_pair(j, a));
        }
    }
    
    while (S2.size() > 0) {
          V.push_back(S2.top().second); S2.pop();     
    } 
    reverse(V.begin(), V.end());
    cout << sum << endl;
    cout << V.size();
    for (i = 0; i < V.size(); i++) {
        cout << " ";
        cout << V[i];
    }
    cout << endl;
    
    return EXIT_SUCCESS;
}



Measured memory_bytes: 3176
#include <iostream>
#include <fstream>
#include <cstdlib>
#include <math.h>
#include <utility>
#include <algorithm>
#include <functional>
#include <vector>
#include <numeric>
#include <bits/stdc++.h>

#define int long long

struct edge {
    int to;
    int cost;
};

using namespace std;
using vi = vector<int>;
using vii = vector<vector<int>>;
using vb = vector<bool>;
using qi = queue<int>;
using P = pair<int, int>;
// using graph = vector<vector<edge>>;
using graph = vector<vector<int>>;

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

const int inf = 1LL << 60;
// const int inf = 100000000;
const int mod = 1000000007;

char s[3];

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

    cin >> s[0] >> s[1] >> s[2];

    int cnt = 0;
    REP(i, 3) {
        if (s[i] == 'R') cnt++;
    }
    if (s[0] == 'R' && s[2] == 'R' && s[1] == 'S') cnt--;
    cout << cnt << "\n";
}


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

string t;
int a[7];

void move(int i){
int b[7];
for(int n=1;n<7;n++){b[n]=a[n];}
        if(t[i] == 'S'){
            a[1] = b[5];
            a[5] = b[6];
            a[6] = b[2];
            a[2] = b[1];
        }
        if(t[i] == 'W'){
            a[1] = b[3];
            a[3] = b[6];
            a[6] = b[4];
            a[4] = b[1];
        }
        if(t[i] == 'N'){
            a[1] = b[2];
            a[2] = b[6];
            a[6] = b[5];
            a[5] = b[1];
        }
        if(t[i] == 'E'){
            a[1] = b[4];
            a[4] = b[6];
            a[6] = b[3];
            a[3] = b[1];
        }}

int main(){
for(int n=1;n<7;n++){cin>>a[n];}
cin>>t;
for(int g=0;g<(int)t.size();g++){move(g);}

cout<<a[1]<<endl;

return 0;
}


Measured memory_bytes: 3156
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cassert>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <functional>
#include <iostream>
#include <map>
#include <set>
#include <cassert>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define fi first
#define sc second
#define rep(i,x) for(int i=0;i<x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
int n;
ll a[100005],b[100005];
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++){
		scanf("%lld%lld",&a[i],&b[i]);
	}
	ll zen = 0;
	for(int i=n;i>=1;i--){
		if( (a[i]+zen)%b[i] != 0){
			ll x = (a[i]+zen)%b[i];
			zen += (b[i]-x);
		}
	}
	cout << zen << endl;
}

Measured memory_bytes: 1792
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
int n,m,l,k;
double s=0;
int main()
{
	scanf("%d",&n);
	for(int i=0;i<n;i++)
	{
		scanf("%d",&k);
		s+=1.0/k;
	}
	printf("%f",1.0/s);
	return 0;
}

Measured memory_bytes: 128
#include<stdio.h>
int main(void)
{
	int i,a,c,T[10];
	while(1){
		c=0;
	scanf("%d",&a);
	if(a == -1)
		break;
	while(1){
		if(a >= 4){
			T[c] = a%4;
			a = a / 4;
			c++;
		}
		else if(a < 4){
			T[c] = a;
			c++;
			break;
		}
	}
	for(i = c-1;i >= 0; i--)
		printf("%d",T[i]);
	printf("\n");
	}
	return 0;
}

Measured memory_bytes: 604