akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int(i)=0;i<(n);i++)
#define MAX_V 100001

struct edge{
    int to,num;
};
vector<edge> G[MAX_V];

void input_graph(int E){
    int s,t;
    REP(i,E){
        cin>>s>>t;s--;t--;
        G[s].push_back({t,i});
        G[t].push_back({s,i});
    }
}

int main(){
  int V,E,k=0;cin>>V;E=V-1;
  input_graph(E);
  queue<int> q;q.push(0);
  vector<bool> used(V,false);used.at(0)=true;
  vector<int> ans(E,0),color_from(V,0);

  while(!q.empty()){
    int now=q.front(),color_now=1;q.pop();
    REP(i,G[now].size()){
      int next=G[now].at(i).to;
      if(!used.at(next)){
        used.at(next)=true;
        if(color_now==color_from.at(now)) color_now++;
        color_from.at(next)=ans.at(G[now].at(i).num)=color_now++;
        k=max(k,color_now-1);
        q.emplace(next);
      }
    }
  }
  
  cout<<k<<endl;
  REP(i,E) cout<<ans.at(i)<<endl;
}

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

int main() {
  ll N;
  cin >> N;
  ll a = 0;
  ll b = 0;
  ll c = 0;
  for (ll i = 0;i<N;i++) {
    ll x; cin >> x;
    if (x%4==0) a++;
    else if (x%2==1) b++;
    else c++;
  }
  if (a >= b) cout << "Yes" << endl;
  else if ((b-a == 1) & (c==0)) cout << "Yes" << endl;
  else cout << "No" << endl;
}



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

#define int long long

const int N = 3e3 + 10;

int n , m , k , Map[N][N] , dp[N][N][4][2];

int F(int x , int y){
	int Max = 0;
	for(int p = 0; p <= 3; p++) Max = max(Max , dp[x][y][p][0]);
	for(int p = 0; p <= 3; p++) Max = max(Max , dp[x][y][p][1]);
	return Max;
}

signed main(){
	scanf("%lld %lld %lld" , &n , &m , &k);
	for(int u , v , w , i = 1; i <= k; i++)
		scanf("%lld %lld %lld" , &u , &v , &w) , Map[u][v] = w;
	for(int i = 1; i <= n; i++)
		for(int j = 1; j <= m; j++){
			int Max = F(i - 1 , j);
			dp[i][j][0][0] = max(Max , dp[i][j - 1][0][0]);
			dp[i][j][1][1] = Max + Map[i][j];
			for(int p = 1; p <= 3; p++){
				dp[i][j][p][0] = max(dp[i][j - 1][p][0] , dp[i][j - 1][p][1]);
				dp[i][j][p][1] = max(max(dp[i][j - 1][p - 1][0] , dp[i][j - 1][p - 1][1]) + Map[i][j] , dp[i][j][p][1]);
			}
		}
	int ans = 0;
	for(int p = 1; p <= 3; p++) ans = max(ans , max(dp[n][m][p][0] , dp[n][m][p][1]));
	printf("%lld" , max(ans , dp[n][m][0][0]));
	return 0;
}

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

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep3(i,m,n) for(int (i)=m;(i)<=(n);(i)++)
#define rep3rev(i,m,n) for(int (i)=m;(i)>=(n);(i)--)
#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define eb emplace_back

using ll = long long;
using vll = vector<ll>;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using pii = pair<int, int>;

void Main(){
	string s;
	cin >> s;
  bool ok = false;
	rep(i,3) if(s[i]=='7') ok = true;
  if(ok) cout << "Yes" << endl;
  else cout << "No" << endl;
	return;
}

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

Measured memory_bytes: 3612
/*
ID: Trump
TASK: 
LANG: C++
*/
/* LANG can be C++11 or C++14 for those more recent releases */
#include <iostream>
#include <fstream>
#include <cstring>
#include <algorithm>
#include <cmath>
using namespace std;
typedef long long ll;
typedef long double lb;
//#define MARK
const ll losn=1e6+5;
const ll maxn=1e5+5;
const ll minn=1e3+5;
const ll tiny=1e2+5;
const ll inf=1e9;
const ll mod=1e9+7;
const ll hmod=4698571;

int main(){
//#ifdef MARK
//    freopen("input.in", "r", stdin);
//    freopen("ouput.out", "w", stdout);
//    freopen("input.in", "r", stdin);
//    freopen("ouput.out", "w", stdout);
//#endif
	ll n;
	cin>>n;
	ll ans=0;
	for(ll i=1;i<=n;i++){
		ll last=n/i;
		if(n%i==0){
			last--;
		}
		if(last*i<n){
			ans+=last;
		}
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 3632
//g++ -std=c++14 test.cpp -o test.out
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iostream>
#include <iomanip>
#include <vector>
#include <queue>
#include <map> 
#include <utility>
#include <limits.h>
using namespace std;

int N,K;
int p[200000];

double ans = 0;

double dice_expected[200000];

void solve(){
	//各サイコロについて期待値を求める
	for(int i=0;i<N;i++){
		dice_expected[i] = (p[i]+1)*p[i]/2;
		dice_expected[i] = (dice_expected[i]/(double)p[i]);
	}
	//それからどの隣接するK個のサイコロがいいかを調べる
	double expected_sum = 0;
	for(int i=0;i<K;i++){
		expected_sum += dice_expected[i];
	}
	ans = expected_sum;
	for(int i=K;i<N;i++){
		expected_sum -= dice_expected[i-K];
		expected_sum += dice_expected[i];
		if(expected_sum>ans) ans = expected_sum;
	}
}
 
int main(){
	cin >> N >> K;
	for(int i=0;i<N;i++) cin >> p[i];
 
	solve();

	cout << fixed << setprecision(10) << ans << endl;
	return 0;
}


Measured memory_bytes: 2560
import java.util.Scanner;

public class Main {
    private static final int MOD = 1_000_000_007;
    private static final String YES = "Yes";
    private static final String NO = "No";

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        int N = sc.nextInt();

        System.out.println(solve(N));
    }

    private static int solve(int N) {
        return 180* (N-2);
    }
}

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

#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
typedef long long ll;

using namespace std;


int inputValue(){
    int a;
    cin >> a;
    return a;
};

void inputArray(int * p, int a){
    rep(i, a){
        cin >> p[i];
    }
};

void inputVector(vector<int> * p, int a){
    rep(i, a){
        int input;
        cin >> input;
        p -> push_back(input);
    }
}

template <typename T>
void output(T a, int precision) {
    if(precision > 0){
        cout << setprecision(precision)  << a << "\n";
    }
    else{
        cout << a << "\n";
    }
}

int main(int argc, const char * argv[]) {
    
    // source code
  ll n;
  cin >> n;
  ll u = n*(n - 1)/2;
  cout << u;
}


Measured memory_bytes: 256
#include <algorithm>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <iostream>
#include <sstream>
#include <functional>
#include <map>
#include <string>
#include <cstring>
#include <vector>
#include <queue>
#include <stack>
#include <deque>
#include <set>
#include <list>
#include <numeric>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,ll> P;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const ll INF = 1LL<<29;
const ll mod = 1e9+7;
#define rep(i,n) for(int (i)=0;(i)<(ll)(n);++(i))
#define repd(i,n,d) for(ll (i)=0;(i)<(ll)(n);(i)+=(d))
#define all(v) (v).begin(), (v).end()
#define pb(x) push_back(x)
#define mp(x,y) make_pair((x),(y))
#define mset(m,v) memset((m),(v),sizeof(m))
#define chmin(X,Y) ((X)>(Y)?X=(Y),true:false)
#define chmax(X,Y) ((X)<(Y)?X=(Y),true:false)
#define fst first
#define snd second
#define UNIQUE(x) (x).erase(unique(all(x)),(x).end())
template<class T> ostream &operator<<(ostream &os, const vector<T> &v){int n=v.size();rep(i,n)os<<v[i]<<(i==n-1?"":" ");return os;}

#define N 100010
int n;
vector<int> g[N];

int rec(int u){
	int m = g[u].size();
	vector<int> v(m);
	rep(i, m) v[i] = rec(g[u][i]);
	sort(all(v)); reverse(all(v));
	int res = 1;
	rep(i, m) res = max(res, v[i]+i+1);
	return res;
}

int main(){
	cin>>n;
	rep(i, n-1){
		int a;
		cin>>a;
		g[a-1].push_back(i+1);
	}
	cout<<rec(0)-1<<endl;
	return 0;
}


Measured memory_bytes: 16640
N = int(input())
X = input()
pc = X.count("1")

if pc == 1:
    if X[-1] == "0":
        for i, s in enumerate(X):
            if i == N - 1:
                print(2)
            elif s == "0":
                print(1)
            else:
                print(0)
    else:
        ans = [2] * (N - 1) + [0]
        print(*ans, sep="\n")
    exit()


m01 = 0
m10 = 0
for i, s in enumerate(X[::-1]):
    if s == "1":
        m01 += pow(2, i, pc + 1)
        m01 %= pc + 1
        m10 += pow(2, i, pc - 1)
        m10 %= pc - 1


memo = [-1] * 200005


def pop_count(T):
    T = (T & 0x55555555) + ((T >> 1) & 0x55555555)
    T = (T & 0x33333333) + ((T >> 2) & 0x33333333)
    T = (T & 0x0F0F0F0F) + ((T >> 4) & 0x0F0F0F0F)
    T = (T & 0x00FF00FF) + ((T >> 8) & 0x00FF00FF)
    T = (T & 0x0000FFFF) + ((T >> 16) & 0x0000FFFF)
    return T


def F(n):
    if memo[n] != -1:
        return memo[n]
    if n == 0:
        return 0
    memo[n] = F(n % pop_count(n)) + 1
    return memo[n]


ans = [0] * N
for i, s in enumerate(X[::-1]):
    if s == "0":
        m = m01
        m += pow(2, i, pc+1)
        m %= pc + 1
    else:
        m = m10
        m -= pow(2, i, pc-1)
        m %= pc - 1
    ans[i] = F(m) + 1

print(*ans[::-1], sep="\n")


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

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 ll = long long;
using P = pair<int,int>;

const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int INF = 1<<30;
const ll mod = 1000000007LL;

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

ll pow(ll a, ll n, ll m) {
	ll ret = 1LL;
	for (; n > 0LL; n >>= 1LL, a = a * a % m) {
		if (n % 2LL == 1LL) {
			ret = ret * a % m;
		}
	}
	return ret;
}

int main(){
    int N;
    cin>>N;
    vector<int> v(N,0);
    rep(i,N){
        int x;
        cin>>x;
        v[x]++;
    }
    bool can = true;
    if(N%2==0){
        for(int i = N-1; i >= 0; i-=2){
            if(v[i]!=2) can = false;
        }
        if(!can) cout<<0<<endl;
        else cout<<pow(2LL,N/2,mod)<<endl;
    } 
    else{
        for(int i = N-1; i>=0; i-=2){
            if(i!=0){
                if(v[i]!=2) can = false;
            }
            else if(v[i]!=1) can = false;
        }
        if(!can) cout<<0<<endl;
        else cout<<pow(2LL,N/2,mod)<<endl;
    }
} 

Measured memory_bytes: 3760
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main(){
    int n;
    cin >> n;
    
    long minV = 1000000;
    long maxV = -1000000;
    long sum = 0;
    int a;
    for(int i = 0; i < n; i++){
        cin >> a;
        sum += a;
        if (a > maxV) maxV = a;
        if (a < minV) minV = a;
    }
    cout << minV << " " << maxV << " " << sum << endl;;

return 0;
}
    

Measured memory_bytes: 3100
#include<bits/stdc++.h>
using namespace std;
#define MAXN	100005
#define P	1000000007
template <typename T> void read(T &x) {
	x = 0; int f = 1;
	char c = getchar();
	for (; !isdigit(c); c = getchar()) if (c == '-') f = -f;
	for (; isdigit(c); c = getchar()) x = x * 10 + c - '0';
	x *= f;
}
int n, a[MAXN], d[MAXN], cnt[MAXN], p[MAXN], len[MAXN];
bool visited[MAXN], used[MAXN], special[MAXN];
deque <int> Q;
long long dp[MAXN];
void add(long long &x, long long y) {
	x = (x + y) % P;
}
void times(long long &x, long long y) {
	x = x * y % P;
}
int main() {
	read(n);
	for (int i = 1; i <= n; i++)
		read(a[i]), d[a[i]]++;
	for (int i = 1; i <= n; i++)
		if (d[i] == 0) {
			visited[i] = true;
			Q.push_back(i);
		}
	while (!Q.empty()) {
		int tmp = Q.front();
		Q.pop_front();
		d[a[tmp]]--;
		if (d[a[tmp]] == 0) {
			visited[a[tmp]] = true;
			Q.push_back(a[tmp]);
		}
	}
	memset(d, 0, sizeof(d));
	for (int i = 1; i <= n; i++)
		d[a[i]]++;
	for (int i = 1; i <= n; i++)
		if (visited[i] && d[i] >= 2 || !visited[i] && d[i] >= 3) {
			printf("0\n");
			return 0;
		}
	for (int i = 1; i <= n; i++)
		if (!visited[i]) {
			p[a[i]] = i;
			if (!used[i]) {
				int pos = a[i], mx = d[i], len = 1;
				used[i] = true;
				while (pos != i) {
					mx = max(mx, d[pos]);
					len++; used[pos] = true;
					pos = a[pos];
				}
				if (mx <= 1) cnt[len]++;
				else {
					pos = a[i]; special[i] = true;
					while (pos != i) {
						special[pos] = true;
						pos = a[pos];
					}
				}
			}
		}
	long long ans = 1;
	for (int i = 1; i <= n; i++) {
		if (cnt[i] == 0) continue;
		dp[0] = 1;
		for (int j = 1; j <= cnt[i]; j++) {
			dp[j] = dp[j - 1];
			if (i & 1 && i > 1) add(dp[j], dp[j - 1]);
			if (j > 1) add(dp[j], dp[j - 2] * (j - 1) % P * i);
		}
		times(ans, dp[cnt[i]]);
	}
	for (int i = 1; i <= n; i++) {
		if (d[i]) continue;
		int pos = i, l = 0;
		while (!special[pos]) {
			l++, pos = a[pos];
		}
		len[pos] = l;
	}
	for (int i = 1; i <= n; i++) {
		if (len[i] == 0) continue;
		int pos = p[i], l = 1;
		while (!len[pos]) {
			l++, pos = p[pos];
		}
		if (l > len[i]) times(ans, 2);
		else if (l < len[i]) ans = 0;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 2304
#include<stdio.h>
using namespace std;
int main()
{
  long long int n,x,t;
  scanf("%lld %lld %lld",&n,&x,&t);
  long long int p,ans;
  p=n/x;
 
  if(n%x>0)
  {
    p++;
  }
 
  ans=p*t;
  printf("%lld",ans);
  return 0;
}

Measured memory_bytes: 3228
// AOJ 1308 Awkward Lights
// 2018.3.8 bal4u

#include <stdio.h>
#include <string.h>

//#define getchar_unlocked()  getchar()
int in()
{
	int n = 0;
	int c = getchar_unlocked();
	do n = (n<<3)+(n<<1) + (c & 0xf), c = getchar_unlocked();
	while (c >= '0');
	return n;
}

#define N 630

// solve A X = C
//char A[N][N], X[N], C[N];
int B[N][N];				// working

int gauss_jordan(int n)
{
	int i, j, k, t, pivot;

//	for (i = 0; i < n; i++) for (j = 0; j < n; j++) B[i][j] = A[i][j];
//	for (i = 0; i < n; i++) B[i][n] = C[i];

	for (i = 0; i < n; i++) {
		pivot = -1, t = -1;
		for (j = i; j < n; j++) if (B[j][i] > t) pivot = j, t = B[j][i];
		if (pivot < 0 || !t) continue;

		for (j = 0; j <= n; j++) {					// swap(B[i],B[pivot]);
			t = B[i][j], B[i][j] = B[pivot][j], B[pivot][j] = t;
		}

		for (j = 0; j < n; j++) if (i != j && B[j][i]) {
	        for (k = i; k <= n; k++) B[j][k] = (B[j][k]+B[i][k]) & 1;
		}
	}

	for (i = 0; i < n; i++) {
//		X[i] = B[i][n];
		if (!B[i][i] && B[i][n]) return 0;
	}
	return 1;
}

#define ABS(a)	((a)>=0?(a):-(a))
#define ID(r,c)	((r)*m+(c))

int main()
{
	int m, n, mn, d, i, j, r, c, t;

	while (m = in()) {
		n = in(), d = in(), mn = m*n;
		memset(B, 0, sizeof(B));

		for (i = 0; i < n; i++) for (j = 0; j < m; j++) {
			if (in()) B[ID(i,j)][mn] = 1;
			for (r = 0; r < n; r++) for (c = 0; c < m; c++) {
				t = ABS(r-i)+ABS(c-j);
				if (t == d || t == 0) B[ID(i,j)][ID(r,c)] = 1;
			}
		}
		putchar('0' + gauss_jordan(m*n));
		putchar('\n');
	}
	return 0;
}


Measured memory_bytes: 3152
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define F first
#define S second
#define pii pair<int, int>
#define eb emplace_back
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep3(i, l, n) for (int i = l; i < (n); ++i)
#define sz(v) (int)v.size()
#define inf (int)(1e9+7)
#define INF (ll)(1e18)
#define abs(x) (x >= 0 ? x : -(x))
#define lb(v, x) (int)(lower_bound(all(v), x) - v.begin())
#define ub(v, x) (int)(upper_bound(all(v), x) - v.begin())
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<typename T> T gcd(T a, T b) { if (b == 0) return a; return gcd(b, a % b); }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }
template<typename T> T pow(T a, int b) { return b ? pow(a * a, b / 2) * (b % 2 ? a : 1) : 1; }


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

void solve() {
    int h, w;
    cin >> h >> w;
    char c[h][w];
    rep(i, h) rep(j, w) cin >> c[i][j];
    
    int ans = 0;
    rep(sh, h) rep(sw, w) rep(th, h) rep(tw, w) {
        if (c[sh][sw] == '#' || c[th][tw] == '#') continue;
        
        using ppi = pair<pii, int>;
        queue<ppi> q;
        q.push(ppi(pii(sh, sw), 0));
        
        vector<vector<int> > reached(h, vector<int>(w, inf));
        reached[sh][sw] = 0;
        
        while (!q.empty()) {
            ppi now = q.front();
            q.pop();
            
            rep(i, 4) {
                int ny = now.F.F + dy[i];
                int nx = now.F.S + dx[i];
                if (ny >= h || ny < 0 || nx >= w || nx < 0) continue;
                if (c[ny][nx] == '#') continue;
                if (reached[ny][nx] != inf) continue;
                reached[ny][nx] = now.S + 1;
                q.push(ppi(pii(ny, nx), now.S + 1));
            }
        }
        // if (sh == 2 && sw == 0 && th == 0 && tw == 4) cout << reached[th][tw] << endl;
        chmax(ans, reached[th][tw]);
    }
    cout << ans << endl;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    
    int T;
    // cin >> T;
    T = 1;
    
    while (T--) {
        solve();
    }
}





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

int main(){
	cin.tie(0),ios::sync_with_stdio(false);
	int n,k; cin>>n>>k;
	for(int i=0;i<n;++i){int g;cin>>g;}
	cout<<(n-2)/(k-1)+1<<"\n"s;
}

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

int main(){
    char num[1001];
    
    while(1){
        scanf("%s",num);
        if (num[0]=='0') break;
        int sum = 0;
        
        for (int i =0;i<(strlen(num));i++){
            sum += (num[i]-'0');
        }
        printf("%d\n",sum);
    }
    return 0;
}


Measured memory_bytes: 2684
int p[10000],n=2,i,j;void main(){*p=2;for(;i<10000;)for(;;){a:n++;for(j=0;p[j]*p[j]<=n;j++)if(n%p[j]==0)goto a;p[++i]=n;break;}for(i=1;i<10000;)p[i]+=p[i++-1];for(;;){scanf("%d",&n);if(!n) break;printf("%d\n",p[n-1]);}}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
int main(){
  int k,s,c=0;
  cin>>k>>s;
  for(int i=0;i<min(k+1,s+1);++i){
    if(0 <= s-i && s-i <= k){
      c += (s-i+1);
    }
    else if(k+1 <= s-i && s-i <= 2*k){
      c += 2*k-(s-i)+1;
    }
  }
  cout<<c;
}


Measured memory_bytes: 256
import java.util.Map;
import java.util.Scanner;
import java.util.TreeMap;

public class Main {
	public static void main(String[]args) {
		try(Scanner scan = new Scanner(System.in)){

			int N = scan.nextInt();
			int[]D = new int[N];
			Map<Integer,Integer>dm = new TreeMap<Integer,Integer>();
			for(int i = 0;i<N;i++) {
				D[i] = scan.nextInt();
				if(dm.containsKey(D[i]))dm.put(D[i], dm.get(D[i])+1);
				else dm.put(D[i], 1);
			}

			int M = scan.nextInt();
			int[]T = new int[M];
			Map<Integer,Integer>tm = new TreeMap<Integer,Integer>();
			for(int i = 0;i<M;i++) {
				T[i] = scan.nextInt();
				if(tm.containsKey(T[i]))tm.put(T[i], tm.get(T[i])+1);
				else tm.put(T[i], 1);
			}

			if(N<M) {
				System.out.println("NO");
				return;
			}

			int ok = 1;

			for(Integer key:tm.keySet()) {
				int val = tm.get(key);

				if(!dm.containsKey(key)) {
					ok=0;
					break;
				}else{
					int dv = dm.get(key);
					if(val>dv) {
						ok=0;
						break;
					}
				}

			}

			if(ok==1)System.out.println("YES");
			else System.out.println("NO");





		}


	}


}


Measured memory_bytes: 80916
function seach(y,x){
   if(yx[y][x]=="*"){yx[y][x]=0;return;}
   var dy=[-1,-1,0];
   var dx=[-1,0,-1];
   var min=n;
   for(var i=0;i<3;i++){
      var yy=y+dy[i];
      var xx=x+dx[i];
      if(yy<0 || yy>=n || xx<0 || xx>=n){yx[y][x]=1;return;}
      min=Math.min(min,yx[yy][xx]);
   }
   yx[y][x]=min+1;
}
 
var input = require('fs').readFileSync('/dev/stdin', 'utf8');
var Arr=(input.trim()).split("\n");
while(true){
   var n=Arr.shift()-0;
   if(n==0)break;
   var max=0;
   var yx=[];
   for(var i=0;i<n;i++){
      var str=Arr.shift();
      yx.push(str.split(""));
   }
   for(var y=0;y<n;y++){
      for(var x=0;x<n;x++){
         seach(y,x);
         max=Math.max(max,yx[y][x]);
      }
   }
   console.log(max);
}

Measured memory_bytes: 69396
#include <vector>
#include <iostream>
#include <queue>
#include <cmath>
#include <bits/stdc++.h>

using namespace std;

int getCost(int h1, int h2);

/*
 * Source: https://atcoder.jp/contests/dp/tasks/dp_a
 *
 * Description:
 *      There are N stones, numbered 1,2,...,N. For each i (1 <= i <= N), the height of stone
 *      i is h\i.
 *
 *      There is a frog who is initially on stone 1. He will repeat the following action
 *      some number of times to reach Stone N:
 *      	- If the frog is currently on stone i, jump to stone i+1 or stone i+2. Here, a
 *      	cost of |h\i - h\j| is incurred, where j is the stone to land on.
 * 
 * 		- This means the frog can only jump to i+1 or i+2
 *
 *      Find the minimum possible total cost incurred before the frog reaches stone N.
 *
 * Constraints:
 * 	- All values in input are integers
 * 	- 2 <= N <= 10^5
 * 	- 1 <= h\i <= 10^4
 * 
 */
int hopCost(int target, vector<int> heights)
{
	// cannot find path to node not in `heights`
	if (heights.size() < (size_t)target) {
		return -1;
	}

	// calculate cost of hopping from given stone to end
	vector<int> cost(target, 0);
	cost[target - 1] = 0;
	cost[target - 2] = getCost(heights[target - 1], heights[target - 2]);
	for (int i = target - 3; i >= 0; i--) {
		cost[i] = min(getCost(heights[i + 1], heights[i]) + cost[i + 1],
			      getCost(heights[i + 2], heights[i]) + cost[i + 2]);
	}

	// tells cost of getting from 0 to the end
	return cost[0];
}

int getCost(int h1, int h2)
{
	int cost = abs(h1 - h2);
	return cost;
}

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

	vector<int> arr;

	for (int i = 0; i < N; i++) {
		int input;
		cin >> input;
		arr.push_back(input);
	}

	cout << hopCost(N, arr) << endl;

	// vector<Test> tests = {
	// 	/*
	// 	 * If we follow the path 1->2->4, the total cost incurred would be
	// 	 * |10-30| + |30-20| = 30.
	// 	 */
	// 	Test(4, { 10, 30, 40, 20 }, 30),

	// 	/*
	// 	 * If we follow the path 1 → 2, the total cost incurred would be
	// 	 * |10−10|=0.
	// 	 */
	// 	Test(2, { 10, 10 }, 0),

	// 	/*
	// 	 * If we follow the path 1 → 3 → 5 → 6, the total cost incurred would be
	// 	 * |30−60|+|60−60|+|60−50|=40.
	// 	 */
	// 	Test(6, { 30, 10, 60, 10, 60, 50 }, 40),

	// 	// failure case
	// 	Test(7, { 30, 10, 60, 10, 60, 50 }, -1),
	// };

	// for (Test t : tests) {
	// 	t.Run();
	// }

	return 0;
}

Measured memory_bytes: 4584
import qualified Data.ByteString.Char8 as BS
import Data.List
import Data.Maybe

readInt = fst . fromJust . BS.readInt
readIntList = map readInt . BS.words

getIntList = readIntList <$> BS.getLine

main = do
  [n, k] <- getIntList
  ps <- getIntList
  print $ sum (take k (sort ps))


Measured memory_bytes: 4456
import collections

N, M = list(map(int, input().split()))

a = []
for i in range(N):
    tmp = list(map(int, input().split()))
    a += tmp[1:]
    
c = collections.Counter(a)

ans = 0

for val in c.values():
  if val== N:
    ans += 1

print(ans)


Measured memory_bytes: 3444
#include <iostream>
    
inline bool isRightTriangle(const u_int a, const u_int b, const u_int c){
    return (a*a == b*b + c*c || b*b == c*c + a*a || c*c == a*a + b*b);
}
    
int main(){
    u_int n;
    std::cin >> n;
       
    for (u_int i = 0; i < n; ++i){
        u_int a, b, c;
        std::cin >> a >> b >> c;
        std::cout << (isRightTriangle(a, b, c) ? "YES" : "NO") << std::endl;
    }
    
    return 0;
}


Measured memory_bytes: 3068
#include<stdio.h>

int main()
{
    int N, count=0, min, i=0;

    scanf("%d", &N);

    int P[N+5];

    while(i != N)
    {
        scanf("%d", &P[i]);
        i++;
    }

    if(P[0] <= N)
        {
            count++;
            //printf("1st count = %d\n", count);
            min = P[0];
        }

    for(i=1; i<N; i++)
    {
        if(P[i] < min)
        {
            min = P[i];
            count++;
            //printf("count = %d\nmin = %d=%d\n", count, i, min);
        }
    }

    printf("%d\n", count);

    return 0;
}


Measured memory_bytes: 2488
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <string>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <stdio.h>
using namespace std;
#define int long long
int MOD = 1000000007;
signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	string S;
	cin >> S;
	string res = "No";
	for (int i = 0; i < (int)S.size() - 1; i++) {
		if (S[i] == 'A' && S[i + 1] == 'C') {
			res = "Yes";
		}
	}
	cout << res << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
//#define DEBUG
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
template <class T>
void print_vect(std::vector<T> v){
    for(int i = 0 ; i < v .size(); i++) cout << v[i] << " ";
    cout << endl;
}
int cal_cost(vi & a, int x){
    int cost = 0;
    for( int i = 0 ; i < a.size() ; i++){
        cost += ( a[i] - x) * (a[i] - x);
    }
    return cost;
}
void solve(){
    int n;
    cin >> n;
    vi a(n);
    int sum = 0;
    for ( int i  = 0 ; i < n ; i++){
        cin >> a[i];
        sum += a[i];
    }
    int average1 = sum / n;
    int average2 = average1 + 1;
    int min_cost = min( cal_cost(a, average1), cal_cost(a, average2)); 
    cout << min_cost << "\n";
}

int main()
{
    //making data IO Fast
    std::ios_base::sync_with_stdio(false);
    std::cin.tie(NULL);
    /****************************/

    #ifdef DEBUG
    int TEST_CASES = 2;
    while(TEST_CASES--){
    #endif // DEBBUG

    solve();

    #ifdef DEBUG
    }
    #endif // DEBUG
    
    return 0;
}



Measured memory_bytes: 3568
import java.util.Stack

open class ModGroup(val mod: Long, val num: Long) {
    operator fun plus(other: ModGroup): ModGroup {
        if(this.mod != other.mod) {
            throw IllegalArgumentException("mod number has to be equal")
        }
        return ModGroup(this.mod, (this.num + other.num ) % this.mod)
    }

    operator fun minus(other: ModGroup): ModGroup {
        if(this.mod != other.mod) {
            throw IllegalArgumentException("mod number has to be equal")
        }
        return ModGroup(this.mod, (this.num - other.num ) % this.mod)
    }
}
class ModRing(mod: Long, num: Long): ModGroup(mod, num) {
    operator fun times(other: ModGroup): ModRing {
        if(this.mod != other.mod) {
            throw IllegalArgumentException("mod number has to be equal")
        }
        return ModRing(this.mod, (this.num * other.num) % this.mod)
    }
    operator fun div(other: ModGroup): ModRing {
        if(this.mod != other.mod) {
            throw IllegalArgumentException("mod number has to be equal")
        }
        return ModRing(this.mod, (this.num / other.num) % this.mod)
    }
}

fun main(args: Array<String>) {
    val (N, K) = readLine()!!.split(" ").map(String::toLong)
    (K..(N+1)).map { m -> 
        val start = m * (m - 1) / 2  
        val end = N * (N + 1) / 2 - (N - m) * (N - m + 1) / 2 
        ModGroup(1000000007, end - start + 1)
    }.fold(ModGroup(1000000007, 0)) {a, b -> a + b}.let{ it.num }.run(::println)

}

Measured memory_bytes: 58704
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
using namespace std;
int a[100],d[100],f[100];
int inf=100000,t=0,n;
int v[100][100];
void dfs(int s){
    d[s]=t++;
    a[s]=inf;
    for(int i=0;i<n;i++){
        if(v[s][i]==1&&a[i]!=inf){
            //cout<<s<<" "<<i<<endl;
            dfs(i);
        }
    }
    f[s]=t++;
}
int main(){
  cin>>n;
  for(int i=0;i<n;i++){
    int u,k;
    cin>>u>>k;
    for(int j=0;j<k;j++){
      int tmp;
      cin>>tmp;
      v[u-1][tmp-1]=1;
    }
  }
  dfs(0);
  for(int i=0;i<n;i++)
      if(!a[i])dfs(i);
  for(int i=0;i<n;i++){
        cout<<i+1<<" "<<d[i]+1<<" "<<f[i]+1<<endl;
  }
}


Measured memory_bytes: 3124
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long A = sc.nextLong();
        long B = sc.nextLong();
        System.out.println(lcm(A, B));

    }

    private static long gcd(long m, long n) {
        if(m < n) return gcd(n, m);
        if(n == 0) return m;
        return gcd(n, m % n);
    }

    private static long lcm(long m, long n) {
        return m * n / gcd(m, n);
    }
}

Measured memory_bytes: 25044
main = do
  n <- readLn
  let l = length $ show n
  print $ f n l
  
f :: Int -> Int -> Int
f n 1 = length [1..n]
f n 2 = 9 
f n 3 = length [100..n] + 9 
f n 4 = 909 
f n 5 = 909 + length [10000..n]
f _ 6 = 90909 

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

public class AtCoderA
{
    static void Main()
    {
        var sc = new Scanner();

        int k = sc.NextInt();
        int a = sc.NextInt();
        int b = sc.NextInt();

        bool ok = false;
        for (int i = a; i <= b; i++)
        {
            if (i % k == 0)
            {
                ok = true;
            }
        }

        string answer = ok ? "OK" : "NG";

        Console.WriteLine(answer);
    }

    class Scanner
    {
        private string[] _line;
        private int _index;
        private const char Separator = ' ';

        public Scanner()
        {
            _line = new string[0];
            _index = 0;
        }

        public string Next()
        {
            while (_index >= _line.Length)
            {
                _line = Console.ReadLine().Split(Separator);
                _index = 0;
            }

            return _line[_index++];
        }

        public int NextInt() => int.Parse(Next());
        public long NextLong() => long.Parse(Next());
        public double NextDouble() => double.Parse(Next());
        public decimal NextDecimal() => decimal.Parse(Next());
        public char NextChar() => Next()[0];
        public char[] NextCharArray() => Next().ToCharArray();

        public string[] Array()
        {
            _line = Console.ReadLine().Split(Separator);
            _index = _line.Length;
            return _line;
        }

        public int[] IntArray() => Array().Select(int.Parse).ToArray();
        public long[] LongArray() => Array().Select(long.Parse).ToArray();
        public double[] DoubleArray() => Array().Select(double.Parse).ToArray();
        public decimal[] DecimalArray() => Array().Select(decimal.Parse).ToArray();
    }
}

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

const int INF = 2e9;

int main(){
    double d,t,s;
    cin >> d >> t >> s;
    double a = d/s;
    if(t < a)cout << "No" << endl;
    else cout << "Yes" << endl;
}

Measured memory_bytes: 3716
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <map>
#include <set>
#include <math.h>
#define rep(i,a,b) for(int i=(a); i<(b); ++i)
typedef long long ll;
using namespace std;

int main() {
    ll n, k;
    cin >> n >> k;
    vector<ll> a(n),c;
    rep(i,0,n) cin >> a[i];
    set<ll> b(a.begin(),a.end());
    if (b.size()<=k) {
        cout << "0" << endl;
        return 0;
    }
    sort(a.begin(),a.end());
    map<ll,ll> m;
    rep(i,0,n) m[a[i]]++;
    int x=0,ans=0;
    vector<ll> cnt(m.size());
    int i=0;
    for(auto p:m) {
        cnt[i]=p.second;
        i++;
    }
    sort(cnt.begin(),cnt.end());
    while (b.size()-k-x) {
        ans+=cnt[x];
        x++;
    }
    cout << ans << endl;
}


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

int main(void)
{
    using namespace std;
    int n;
    scanf("%d", &n);
    int num[n];
    int min, max;
    long long int total;

    for (int i = 0; i < n; i++) {
        scanf("%d", &num[i]);
        if ( i == 0) {
            min = num[i];
            max = num[i];
            total = 0;
        }
        if (min > num[i]) {
            min = num[i];
        }
        if (max < num[i]) {
            max = num[i];
        }
        total += num[i];
    }
    printf("%d %d %lld\n", min, max, total);
}


Measured memory_bytes: 3228
#include<stdio.h>
int main(){
	int a,b,c;
	scanf("%d %d %d",&a,&b,&c);
	if(c>a&&b>c||a==b&&b==c&&a==c){
		printf("Yes\n");
	}
	else{
		printf("No\n");
	}
	return 0;
}


Measured memory_bytes: 128
#include <algorithm>
#include <climits>
#include <iostream>
#include <vector>

using namespace std;

int calc_time(vector<int>& dishes) {
    int time = 0;
    int size = dishes.size();
    for (int i = 0; i < size; ++i) {
        time += dishes[i];

        if (i < size - 1) {
            while (time % 10 != 0)
                ++time;
        }
    }
    return time;
}

int min_time(vector<int>& dishes) {
    int min_time = INT_MAX;
    do {
        min_time = min(min_time, calc_time(dishes));
    } while (next_permutation(dishes.begin(), dishes.end()));
    return min_time;
}

int main() {
    const int size = 5;
    vector<int> dishes(size);
    for (int i = 0; i < size; ++i)
        cin >> dishes[i];

    cout << min_time(dishes) << '\n';
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1LL<<62
#define inf 1000000007


int main() {
	ll n,m;
	cin>>n>>m;
	if(m<=n*2){
		cout << m/2;
		return 0;
	}
	cout << n+(m-2*n)/4;
	// your code goes here
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FI first
#define SE second
#define PB push_back
#define ll long long
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define ROF(i,a,b) for(int i=b-1;i>=a;i--)
#define YES(i) cout<<(i?"YES":"NO")<<endl
#define Yes(i) cout<<(i?"Yes":"No")<<endl
#define co(i) cout<<(i)<<endl
#define fcout cout<<fixed<<setprecision(10)
#define uni(i) i.erase(unique(i.begin(), i.end()), i.end());
#define all(i) i.begin(),i.end()
#define pint pair<int, int>
#define vint vector<int>
using namespace std;

const int INF=1e9+7;
const int MOD=1e9+7;
//const int MOD=998244353;

// R - Walk
int main(){
	int n;
	ll k;
	cin>>n>>k;
	ll mat[51][51][2],ans[51][51][2];
	int ida=0,idm=0;
	FOR(i,0,n) FOR(j,0,n){
		cin>>mat[i][j][0];
		ans[i][j][0]=(i==j);
	}
	while(k){
		if(k&1){
			FOR(i,0,n){
				FOR(j,0,n){
					ans[i][j][!ida]=0;
					FOR(k,0,n){
						(ans[i][j][!ida]+=mat[i][k][idm]*ans[k][j][ida])%=MOD;
					}
					ans[i][j][!ida]%=MOD;
				}
			}
			ida=!ida;
		}
		FOR(i,0,n){
			FOR(j,0,n){
				mat[i][j][!idm]=0;
				FOR(k,0,n){
					(mat[i][j][!idm]+=mat[i][k][idm]*mat[k][j][idm])%=MOD;
				}
				mat[i][j][!idm]%=MOD;
			}
		}
		idm=!idm;
		k>>=1;
	}
	ll sum=0;
	FOR(i,0,n) FOR(j,0,n){
		(sum+=ans[i][j][ida])%=MOD;
	}
	co(sum);
}


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

int N, C, K;
vector<int> T;

void solver() {
    sort(T.begin(), T.end());

    int ans = 0;
    int i = 0;
    while (i < N) {
        int angry = T[i++];
        int cap = 1;
        while (i < N && cap++ < C && T[i] - angry <= K) i++;

        ans++;
    }

    cout << ans << endl;
}


int main() {
    cin >> N >> C >> K;
    for (int i = 0; i < N; i++) {
        int tmp;
        cin >> tmp;
        T.push_back(tmp);
    }

    solver();
}


Measured memory_bytes: 892
def resolve():
    '''
    code here
    '''
    H, W = [int(item) for item in input().split()]
    grid = [[item for item in input()] for _ in range(H)]

    def chk(i,j):
        if grid[i][j] == '#':
            if 0 <= i-1:
                if grid[i-1][j] == '#':
                    return True
            if i +1 < H:
                if grid[i+1][j] == '#':
                    return True
            if 0 <= j -1:
                if grid[i][j-1] == '#':
                    return True
            
            if j + 1 < W:
                if grid[i][j+1] == '#':
                    return True
            
            return False
        else:
            return False

    for i in range(H):
        end_flag = False
        for j in range(W):
            # print(chk(i,j), grid[i][j])
            if grid[i][j] == '#':
                if chk(i,j) == True:
                    pass
                else:
                    print('No')
                    end_flag = True
                    break
        if end_flag:
            break
    else:
        print('Yes')

if __name__ == "__main__":
    resolve()


Measured memory_bytes: 3064
S = input()

result = 0
for i in range(len(S) + 1):
    for j in range(i, len(S) + 1):
        for ti in S[i:j]:
            if ti not in ['A', 'C', 'G', 'T']:
                break
        else:
            result = max(result, len(S[i:j]))
print(result)

Measured memory_bytes: 3060
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <cstdio>
#include <cmath>
#include <tuple>
#include <iomanip>
#include <numeric>
#include <unordered_map>
#include <sstream>   
#include<limits.h>
#include<list>
using namespace std;
#define i64  long long
#define int  long long
 
#define I32_MAX 2147483647
#define I64_MAX 9223372036854775807
#define MOD 1000000007


void solve()
{
  int N,D;
  cin>>N>>D;
  int area = 1 + 2*D;
  int ANS;
  for (int i = 0; i <= N; i++)
  {
    if(N - area*i <= 0)
    {
    ANS = i;
    break;
    }
  }

  cout<<ANS;
  
  return;  
}

int32_t main(int32_t argc, const char *argv[])
{
  // std::ios::sync_with_stdio(false);
  // std::cin.tie(0);

  // std::cout << std::fixed;
  // std::cout << std::setprecision(8);

  solve();

 
  return 0;
}

Measured memory_bytes: 256
import sys
readline = sys.stdin.readline

from heapq import heappop as hpp, heappush as hp
def dijkstra(N, s, Edge):
    inf = geta
    dist = [inf] * N
    dist[s] = 0
    Q = [(0, s)]
    dp = [0]*N
    dp[s] = 1
    while Q:
        dn, vn = hpp(Q)
        if dn > dist[vn]:
            continue
        for df, vf in Edge[vn]:
            if dist[vn] + df < dist[vf]:
                dist[vf] = dist[vn] + df
                dp[vf] = dp[vn]
                hp(Q, (dn + df,vf))
            elif dist[vn] + df == dist[vf]:
                dp[vf] = (dp[vf] + dp[vn]) % MOD
    return dist, dp

MOD = 10**9+7
N, M = map(int, readline().split())
S, T = map(int, readline().split())
S -= 1
T -= 1

geta = 10**15
Edge = [[] for _ in range(N)]
for _ in range(M):
    u, v, d = map(int, readline().split())
    u -= 1
    v -= 1
    Edge[u].append((d, v))
    Edge[v].append((d, u))
    

dists, dps = dijkstra(N, S, Edge)
distt, dpt = dijkstra(N, T, Edge)
st = dists[T]

onpath = [i for i in range(N) if dists[i] + distt[i] == st]

ans = dps[T]**2%MOD
for i in onpath:
    if 2*dists[i] == 2*distt[i] == st:
        ans = (ans - pow(dps[i]*dpt[i], 2, MOD))%MOD
    
    for cost, vf in Edge[i]:
        if dists[i] + cost + distt[vf] == st:
            if 2*dists[i] < st < 2*dists[vf]:
                ans = (ans - pow(dps[i]*dpt[vf], 2, MOD))%MOD
print(ans)

Measured memory_bytes: 121520
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<bitset>
#include<cctype>
#include<climits>
#include<cmath>
#include<cstdio>
#include<cstring>
#include<deque>
#include<list>
#include<map>
#include<set>
#include<stack>
#include<string>
#include<sstream>
#include<queue>
#include<vector>
using namespace std;






int main() {
	int n; cin >> n;
	int S[100001];
	for (int i = 0; i < n; i++)cin >> S[i];
	int q; cin >> q;
	int T[50001];
	for (int i = 0; i < q; i++)cin >> T[i];

	int cnt = 0;
	for (int i = 0; i < q; i++) {
		//binary search
		int L = 0, R = n;
		while (L < R) {
			int M = (L + R) / 2;
			//cout << i << " " << M << " " << L << " " << R << " " << S[M] << " " << T[i] << endl;
			if (S[M] == T[i]) {
				cnt++;
				break;
			}
			else if (S[M] > T[i])
				R = M;
			else
				L = M + 1;
		}
	}
	cout << cnt << endl;

	return 0;
}

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

int main() {
  int N; cin >> N;
  vector<long> H(N);
  for (int i =0; i<N; i++) {
    long a; cin >> a; 
    H.at(i) = a;
  }
  
  int maxMove =0;
  int move =0;
  for (int i =1; i<N; i++) {
    if (H.at(i) <= H.at(i-1)) {
      move++;
    } else {
      maxMove = max(move,maxMove);
      move =0;
    }
  }     
  maxMove = max(move,maxMove);    
  cout << maxMove << endl;
}

Measured memory_bytes: 4048
#include <iostream>
#include <queue>
#include <stack>
#include <vector>
#include <stdio.h>
#include <algorithm>
#include <string>
#include <cstring>
#include <cmath>
#include <complex>
#include <map>
#include <climits>
using namespace std;

#define reep(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) reep((i),0,(n))
#define ALL(v) (v).begin(),(v).end()
#define PB push_back
#define EPS 1e-8
#define F first
#define S second
#define mkp make_pair

static const double PI=6*asin(0.5);
typedef long long ll;
typedef complex<double> CP;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vint;
static const int INF=1<<24;


int main(){
	
	string s;
	while(getline(cin,s),s!="."){
		bool f=true;
		stringstream ss;
		rep(i,s.size()){
			if(s[i]=='('||s[i]==')'||s[i]=='['||s[i]==']'){
				ss<<s[i];
			}
		}
		string s2;
		ss>>s2;
		//cout<<s2<<endl;
		string tmp=s2;
		while(1){
			//cout<<"s2 "<<s2<<endl;
			stringstream ss2;
			bool ff=false;
			rep(i,s2.size()){
				if(i==s2.size()-1){
					ss2<<s2[i];
					ff=true;
				}
				else if(s2[i]=='('&&s2[i+1]==')'){
					i++;
				}
				else if(s2[i]=='['&&s2[i+1]==']'){
					i++;
				}
				else{
					ss2<<s2[i];
					ff=true;
				}
			}
			if(ff) ss2>>tmp;
			else break;
			//cout<<"tmp "<<tmp<<endl;
			if(tmp==s2){
				f=false;
				break;
			}
			if(tmp.size()==0) break;
			s2=tmp;
		}
		if(f) cout<<"yes"<<endl;
		else cout<<"no"<<endl;
				
	}
	return 0;
}

Measured memory_bytes: 1212
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <climits>
#include <cstring>
#include <cassert>


using namespace std;
#define SZ(x) (int)(x.size())
#define REP(i, n) for(int i=0;i<n;++i)
#define FOR(i, a, b) for(int i=a;i<b;++i)
#define RREP(i, n) for(int i=n-1;i>=0;--i)
#define RFOR(i, a, b) for(int i=b-1;i>=a;--i)

#define all(x) begin(x),end(x)
#define dump(x) cerr<<#x<<" = "<<(x)<<endl
#define debug(x) cerr<<#x<<" = "<<(x)<<" (L"<<__LINE__<<")"<< endl;

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using P = pair<int, int>;
const double eps = 1e-8;
const ll MOD = 1000000007;
const int INF = INT_MAX / 2;
const ll LINF = LLONG_MAX / 2;

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

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


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

template<class T>
ostream &operator<<(ostream &os, const vector<T> &v) {
    os << "[";
    REP(i, SZ(v)) {
        if (i) os << ", ";
        os << v[i];
    }
    return os << "]";
}

// edit
vector<int> primes;

bool solve(int N) {
    if(N == 0) return false;
    
    int x = *(upper_bound(all(primes), N) - 1);
    int y = *lower_bound(all(primes), N);
    int ans = y - x;
    cout << ans << endl;

    return true;
}


int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
//    std::ifstream in("input.txt");
//    std::cin.rdbuf(in.rdbuf());

//    solve();
    vector<bool> is_prime(1299710, true);
    for(int i = 2; i < is_prime.size(); ++i){
        if(is_prime[i]){
            for(int j = i * 2; j < is_prime.size(); j += i){
                is_prime[j] = false;
            }
        }
    }

    for(int i = 1; i < is_prime.size(); ++i){
        if(is_prime[i]){
            primes.push_back(i);
        }
    }

    
    while(true){
        int N;
        cin >> N;
        if(!solve(N)){
            break;
        }
    }


    return 0;
}



Measured memory_bytes: 3540
#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;
#define rep(i,n) for(int i = 0; i < ((int)(n)); i++)   // 0-indexed昇順

#define MAXK 100000
vector<vector<int>> M;

int main() {
    int K; cin >> K;
    M.assign(K, vector<int>(10, 0));
    using pii = pair<int,int>;
    deque<pii> D;
    M[1][1] = 1;
    D.push_back({1,1});

    while (!D.empty()) {
        auto [modk, low] = D.front(); D.pop_front();
        int x10 = modk * 10 % K;
        if (M[x10][low] == 0) {
            M[x10][low] = M[modk][low];
            D.push_front({x10, low});
        }

        int p1 = (modk + 1) % K;
        int sec = (low + 1) % 10;
        if (M[p1][sec] == 0) {
            M[p1][sec] = M[modk][low] + 1;
            D.push_back({p1,sec});
        }
    }

    int mi = INT32_MAX;
    rep(i, 10) if (M[0][i] < mi) mi = M[0][i];
    cout << mi << endl;
}


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

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<int, int> Pi;
typedef vector<ll> Vec;
typedef vector<int> Vi;
typedef vector<string> Vs;
typedef vector<vector<ll>> VV;
typedef vector<vector<int>> VVi;

#define REP(i, a, b) for(int i=(a); i<(b); i++)
#define PER(i, a, b) for(int i=(a); i>=(b); i--)
#define rep(i, n) REP(i, 0, n)
#define per(i, n) PER(i, n, 0)
const ll INF=1e16+18;
const ll MAX=100005;
const ll MOD=1000000007;
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl;
#define YES(n) cout << ((n) ? "YES" : "NO") << endl;
#define ALL(v) v.begin(), v.end()
#define pb(x) push_back(x)
#define mp(a, b) make_pair(a,b)
#define Each(a,b) for(auto &a :b)
#define REPM(i, mp) for (auto i = mp.begin(); i != mp.end(); ++i)
#define dbg(x_) cerr << #x_ << ":" << x_ << endl;
#define dbgmap(mp) cerr << #mp << ":"<<endl; for (auto i = mp.begin(); i != mp.end(); ++i) { cerr << i->first <<":"<<i->second << endl;}
#define dbgarr(n,m,arr) rep(i,n){rep(j,m){cerr<<arr[i][j]<<" ";}cerr<<endl;}
#define dbgdp(n,arr) rep(i,n){cerr<<arr[i]<<" ";}cerr<<endl;
#define sum(v) accumulate(ALL(v),0)
#define fi first
#define se second

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

// vector
template<typename T>
ostream &operator<<(ostream &s, const vector<T> &v) {
    int len=v.size();
    for(int i=0; i<len; ++i) {
        s<<v[i];
        if(i<len-1) s<<"	";
    }
    return s;
}

// 2 dimentional vector
template<typename T>
ostream &operator<<(ostream &s, const vector<vector<T> > &vv) {
    int len=vv.size();
    for(int i=0; i<len; ++i) {
        s<<vv[i]<<endl;
    }
    return s;
}

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

    int h,w,k;
    cin>>h>>w>>k;

    VVi grid(h,Vi(w,0));
    VVi col(h,Vi(w,0));

    rep(i,h){
        string s;
        cin>>s;
        rep(j,w){
            if(s[j]=='#'){
                grid[i][j]=1;
            }else{
                grid[i][j]=0;
            }
        }
    }


    int c = 0;
    rep(i,h){
        bool discovery=false;
        per(j,w-1){
            if(grid[i][j]==0){
                if(discovery){
                    col[i][j] = c;
                }
            }else{
                //発見
                c++;
                if(!discovery){
                    REP(x,j,w){
                        col[i][x]=c;
                    }
                }
                discovery = true;
                col[i][j] = c;
            }
        }
    }

    //下うめ
    rep(i,h){
        if(i==0)continue;
        if(col[i][0]==0){
            rep(j,w){
                col[i][j]=col[i-1][j];
            }
        }
    }
    //上うめ
    per(i,h-1){
        if(i==h-1)continue;
        if(col[i][0]==0){
            rep(j,w){
                col[i][j]=col[i+1][j];
            }
        }
    }

    //dbg(col)

    rep(i,h){
        rep(j,w){
            cout<<col[i][j]<<" ";
        }
        cout<<endl;
    }


   // dbg(col);
    return  0;
}


Measured memory_bytes: 1536