akhauriyash/Code-Regression huggingface dataset:
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();

        int i = 0;
        int x, y, z;
        if (a % 2 == 0 && b % 2 == 0 && c % 2 == 0) {
            while(true){
                if(a == b && b == c && c == a){
                    System.out.print(-1);
                    break;
                }
                else if(a % 2 != 0 || b % 2 != 0 || c % 2 != 0){
                    System.out.print(i);
                    break;
                }
                else{
                    x = a / 2;
                    y = b / 2;
                    z = c / 2;

                    a = y + z;
                    b = x + z;
                    c = x + y;

                    i++;
                }
            }
        }
        else{
            System.out.print(i);
        }
    }
}

Measured memory_bytes: 22996
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<ll,ll> pll;


int main(){
    ll n;
    cin >> n;
    vector< int64_t > ret;
    for(int64_t i = 1; i * i <= n; i++) {
        if(n % i == 0) {
        ret.push_back(i);
        if(i * i != n) ret.push_back(n / i);
        }
    }
    sort(begin(ret), end(ret));
    
    ll min = 1e+13;
    ll premin;
    for(int64_t i = 0; i < (ret.size()+1)/2; i++) {
        premin = ret.at(i)-1;
        premin += (n/ret.at(i))-1;
        if(min>premin){
            min = premin;
        }
    }

    cout << premin << endl;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
int main(void){
    long long a,b,r,x,tmp;
    cin >> a >> b;
    x = a * b;
 
  /* 自然数 a > b を確認・入替 */
  if(a<b){
    tmp = a;
    a = b;
    b = tmp;
  }
 
  /* ユークリッドの互除法 */
  r = a % b;
  while(r!=0){
    a = b;
    b = r;
    r = a % b;
  }
 
  /* 最小公倍数を出力 */
  cout << x/b;

}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <set>
#include <algorithm>
#include <array>
#include <complex>
#include <string>
#include <utility>
#include <map>
#include <queue>
#include <list>
int dx[4] = { -1,0,1,0 };
int dy[4] = { 0,1,0,-1 };
const int INF = 1 << 21;
using pii = std::pair<int, int>;
#define SORT(v) std::sort(v.begin(), v.end())
int F[100][15];
int main(void) {
	std::string A,B,C;
	int a = 0, b = 0, c = 0,turn=1;
	std::cin >> A >> B >> C;
	for (size_t i = 0; i <= A.size() + B.size() + C.size(); i++) {
		if (turn == 1) {
			if (a == A.size()) {
				std::cout << "A" << std::endl;
				return 0;
			}
			else {
				
				if (A[a] == 'b')turn = 2;
				else if(A[a] == 'c')turn = 3;
				else turn = 1;
				a++;
			}
		}else if (turn == 2) {
			if (b == B.size()) {
				std::cout << "B" << std::endl;
				return 0;
			}
			else {
				
				if (B[b] == 'b')turn = 2;
				else if (B[b] == 'c')turn = 3;
				else turn = 1;
				b++;
			}
		}else if (turn == 3) {
			if (c == C.size()) {
				std::cout << "C" << std::endl;
				return 0;
			}
			else {
				
				if (C[c] == 'b')turn = 2;
				else if (C[c] == 'c')turn = 3;
				else turn = 1;
				c++;
			}
		}
		//std::cout << a << b << c<<std::endl;
	}
	std::cout << "Yes" << std::endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using Int = long long;
typedef pair<int,int> P; typedef pair<Int,Int> Pl;
const int mod = 1e9+7;
#define END {cout<<ans<<'\n'; return 0;}
#define ALL(v) v.begin(),v.end()
#define Pr(type) priority_queue<type>
#define gPr(type) priority_queue<type,vector<type>,greater<type>>
#define V(type) vector<type>
#define rep(i,n) for(int i=0; i<n; i++)
#define rer(i,st,en) for(int i=st; i<=en; i++)
#define eb emplace_back
#define pri1(a) cout<<a<<'\n'
#define pri2(a,n) rep(i,n)cout<<a[i]<<'\n'
#define pri3(a,n) rep(i,n)cout<<a[i]<<(i!=n-1?' ':'\n')
template<class T> inline bool cmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool cmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }



Int n,m,_,x,y,q;
string s;

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

  cin>>n>>m; pri1(__gcd(n,m));
}


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

typedef long long ll;

ll a[100001]={}, b[100001]={}, c[100001]={}, a_b[100001]={}, b_c[100001]={};

int main(){
  int n; cin >> n;
  for(int i=0; i<n; i++){cin >> a[i];}
  for(int i=0; i<n; i++){cin >> b[i];}
  for(int i=0; i<n; i++){cin >> c[i];}

  sort(a,a+n);
  sort(b,b+n);
  sort(c,c+n);

  ll cnt = 0;
  for(int i=0; i<n; i++){
    while(a[cnt] < b[i] && cnt != n) cnt++;
    a_b[i] = cnt;
  }
  
  ll ans = 0;
  ll sum = 0;
  cnt = 0;
  
  for(int i=0; i<n; i++){
    while(b[cnt] < c[i] && cnt !=n) {sum += a_b[cnt]; cnt++;}
    ans += sum;
  }

  cout << ans << endl;
}

Measured memory_bytes: 3328
import sys

n1, n2 = [int(i) for i in input().split()]

na1 = []

for i1 in range(n2):
    na1.append(int(input()))

for i3 in range(n2):
    if i3 == 0:
        continue
    else:
        if na1[i3] == na1[i3 - 1] + 1:
            print("0")
            sys.exit()

n3 = 0
n4 = 0
n5 = 0
n6 = 0
n7 = 0
r1 = 1
r2 = []
f1 = False
for i2 in range(n1):
    if len(na1) > n7 and (na1[n7] == i2 + 1 ):
        n3 = 0
        n4 = 0
        n6 = 0
        n7 += 1
        r2.append(r1)
        r1 = 1
        f1 = True

    else:
        if f1 == True:
            f1 = False
            continue
        if n4 == 0 :
            n4 = 1
            r1 = 1
        elif n3 == 0 :
            n3 = 1
            n4 = 2
            r1 = 2
        else:
            n6 = n3 + n4
            r1 = n6
            n3 = n4
            n4 = n6
    if i2 == (n1 - 1) :
        r2.append(r1)

r3 = 1
for i6 in range(len(r2)):
    r3 *= r2[i6]

print(r3 % 1000000007)

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

using namespace std;
typedef long long ll;

#define INF (long long)(1e9+7)
#define REP(i,n) for(ll i = 0; i < n; i++)
#define REP1(i,n) for(ll i = 1; i <= n; i++)

int main(void)
{
  string s;
  cin >> s;
  if(s[0] != 'A') {
    cout << "WA" << endl;
    return 0;
  }
  int cc = 0;
  for(int i = 1; i < s.size(); i++) {
    if(s[i] == 'C') {
      cc ++;
    } else {
      if(s[i] < 'a' || s[i] > 'z') {
	cout << "WA" << endl;
	return 0;
      }
    }
  }
  if(cc == 1 && s[s.size()-1] != 'C' && s[1] != 'C') {
    cout << "AC" << endl;
  } else {
    cout << "WA" << endl;
  }
}


Measured memory_bytes: 256
#include<string>
#include<vector>
#include<iostream>
#include<sstream>
#include<cstdio>
#include<cstdlib>
#include<functional>
#include<algorithm>
#include<stack>
#include<queue>
#include<deque>
#include<set>
#include<map>
#include<utility>
#include<cmath>
#include<ctime>
#include<complex>

using namespace std;

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

int a[160001];
bool f(int n){
	int p;
	REP(i,2,n){
	if(n%i==0){
	p=i;
	break;
	}
	}
	if(p==n) return true;
	else return false;
}
int main(){

	int n;
	while(true){
	cin >> n;
	if(n==0) break;

	REP(i,0,160000) a[i]=i;

	REP(i,2,400){
	if(f(i)){
	for(int j=2*i;j<=160000;j+=i)
	a[j]=0;
	}
	}

	int c=0; int s=0;
	REP(i,2,160000){
	if(a[i]!=0){
	s+=a[i];
	c++;
	}

	if(c==n) break;

	}

    cout << s << endl;

	}

	return 0;
}

Measured memory_bytes: 1784
import java.util.*;
import java.io.*;
import java.lang.*;

class Main{
    
	public static void main(String args[]){
	    
    	Scanner in = new Scanner(System.in);
      	char c = in.next().charAt(0);
		
		if((int)c > 64 && (int)c <91)
			System.out.println("A");
		else
			System.out.println("a");
		
    }
 
}

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

using namespace std;

int main(void) {
  int a, b, c; cin >> a >> b >> c;
  
  if ((a == b || b == c || c == a) && 3 * a != a + b + c) {
    cout << "Yes";
  } else {
    cout << "No";
  } cout << endl;

  return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
using ll = long long;
int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  vector<ll> b(1000005, 0);
  for(int i = 0; i < n; i++) {
    cin >> a[i];
    b[a[i]]++;
  }
  int sc = a[0];
  for(int i = 0; i < n; i++) {
    sc = gcd(sc, a[i]);
  }
  if(sc > 1) {
    cout << "not coprime\n";
  } else {
    for(int i = 2; i <= 1000000; i++) {
      int num = 0;
      for(int j = i; j <= 1000000; j += i) {
        if(b[j] != 0) {
          num++;
        }
        if(num > 1) {
          cout << "setwise coprime\n";
          return 0;
        }
      }
    }
    cout << "pairwise coprime\n";
  }
  return 0;
}

Measured memory_bytes: 14864
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
typedef unsigned long long ull;
typedef double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pdd;
 
#define X first
#define Y second

const int MAXN = 110;

int n;
int a[MAXN];

int main()
{
	
	scanf("%d", &n);
	
	for (int i = 1; i <= n; ++ i)
	{
		scanf("%d", &a[i]);
	}
	sort(a+1, a+n+1);
	printf("%d\n", a[n]-a[1]);
	
	return 0;
}


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

using namespace std;
int N, M;
typedef pair<long long, int> plli;

vector<plli> d;

bool pairCompare(const plli &firstElof, const plli &secondElof)
{
  return firstElof.first < secondElof.first;
}

long long A;
int B;
int main()
{
  cin >> N >> M;
  for (int i = 0; i < N; i++)
  {
    cin >> A >> B;
    d.push_back(make_pair(A, B));
  }

  sort(d.begin(), d.end(), pairCompare);
  int r = M;
  unsigned long long cost;
  for (int i = 0; i < N; i++)
  {
    int t = r - d[i].second;
    if (t < 0)
    {
      while (r > 0)
      {
        cost += d[i].first;
        r--;
      }
      cout << cost;
      break;
    }
    else if (t == 0)
    {
      cost += d[i].first * d[i].second;
      cout << cost;
      break;
    }
    else
    {
      r -= d[i].second;
      cost += d[i].first * d[i].second;
    }
  }

  return 0;
}

Measured memory_bytes: 2420
n, m = map(int, input().split())
a = set(int(input()) for i in range(m))
mod = 10**9+7
dp = [0]*(n+1)
dp[0], dp[1] = 1, 1
if 1 in a:
    dp[1] = 0
for i in range(2, n+1):
    if i not in a:
        dp[i] = dp[i-1] + dp[i-2]
        dp[i] %= mod
print(dp[n])

Measured memory_bytes: 58200
#include<bits/stdc++.h>
using namespace std;
const int N=200005;
string s;
int n,k,c;
int l[N],r[N];
int main()
{
	cin>>n>>k>>c>>s;
	int i=1,kk=1;
	while(kk<=k)
	{
		if(s[i-1]=='o')
		{
			l[kk++]=i;
			i+=c;
		}
		i++;
	}
	i=n,kk=k;
	while(kk)
	{
		if(s[i-1]=='o')
		{
			r[kk--]=i;
			i-=c;
		}
		i--;
	}
	for(i=1;i<=k;i++)
	{
		if(l[i]==r[i])cout<<l[i]<<endl;
	}
return 0;
}


Measured memory_bytes: 3332
#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")
#define rep(i,n) for(int i=0;i<n;i++)
const long long MOD = 1000000007;
typedef pair<int,int> P;
typedef long long ll;

int main(void){
  int x,y; cin >> x >> y;
  int a,b,c; cin >> a >> b >> c;
  ll p[a],q[b],r[c];
  rep(i,a) cin >> p[i];
  rep(i,b) cin >> q[i];
  rep(i,c) cin >> r[i];
  sort(p,p+a); sort(q,q+b); sort(r,r+c);

  vector<int> ans = {};
  rep(i,x) ans.push_back(p[a-1-i]);
  rep(i,y) ans.push_back(q[b-1-i]);
  rep(i,c) ans.push_back(r[i]);

  sort(ans.begin(), ans.end(), greater<int>());
  ll out = 0;
  rep(i,x+y){
    out += ans[i];
  }
  cout << out << "\n";
}

Measured memory_bytes: 4724
#include <bits/stdc++.h>
#define itn int
#define gI gi

using namespace std;

typedef long long ll;

inline int gi()
{
	int f = 1, x = 0; char c = getchar();
	while (c < '0' || c > '9') {if (c == '-') f = -1; c = getchar();}
	while (c >= '0' && c <= '9') x = x * 10 + (c ^ 48), c = getchar();
	return f * x;
}

inline ll gl()
{
	ll f = 1, x = 0; char c = getchar();
	while (c < '0' || c > '9') {if (c == '-') f = -1; c = getchar();}
	while (c >= '0' && c <= '9') x = x * 10 + (c ^ 48), c = getchar();
	return f * x;
}

int n, m, gn, gw, a, b;
char s[100003];

int main()
{
	//freopen(".in", "r", stdin);
	//freopen(".out", "w", stdout);
	n = gi(), a = gi(), b = gi();
	scanf("%s", s + 1);
	for (int i = 1; i <= n; i+=1)
	{
		if (s[i] == 'c') puts("No");
		else if (s[i] == 'a')
		{
			if (gn < a + b) puts("Yes"), ++gn;
			else puts("No");
		}
		else
		{
			if (gn < a + b && gw < b) puts("Yes"), ++gw, ++gn;
			else puts("No");
		}
	}
	return 0;
}


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

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> pi;

#define F first
#define S second
#define PB push_back
#define MP make_pair
#define REP(i, a, b) for(int i = a; i < b; i++)
#define fastio ios::sync_with_stdio(0); cin.tie(0);

int main() {
	fastio;
	string s;
	int num1, num2;
	cin >> s;
	num1 = (s[0] - '0')*10 + (s[1] - '0');
	num2 = (s[2] - '0')*10 + (s[3] - '0');
	//cout << num1 << " " << num2;
	if(num1 >= 1 && num1 <= 12 && (num2 > 12 || num2 == 0))
		cout << "MMYY" << endl;
	else if(num1 >= 1 && num1 <= 12 && (num2 < 12 && num2 != 0))
		cout << "AMBIGUOUS" << endl;
	else if(num2 >= 1 && num2 <= 12 && (num1 > 12 || num1 == 0))
		cout << "YYMM" << endl;
	else if(num2 >= 1 && num2 <= 12 && (num1 < 12 && num1 != 0))
		cout << "AMBIGUOUS" << endl;
	else
		cout << "NA" << endl;
	return 0;
}

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

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {
    public static void main(String[] args) {
        Main main = new Main();
        main.solve(args);
    }

    public void solve(String[] args) {
        MyScanner scanner = new MyScanner();
        int a = scanner.nextInt();
        int b = scanner.nextInt();
        if(a%2==0||b%2==0) {
        	System.out.println("No");
        }else {
        	System.out.println("Yes");
        }


    }

    private class MyScanner {
        String[] s;
        int i;
        BufferedReader br;
        String reg = " ";
        MyScanner () {
            s = new String[0];
            i = 0;
            br = new BufferedReader(new InputStreamReader(System.in));
        }
        public String next() {
            try {
                if (i < s.length) return s[i++];
                String line = br.readLine();
                while (line.equals("")) {line = br.readLine();}
                s = line.split(reg, 0);
                i = 0;return s[i++];
            } catch (Exception e) {e.printStackTrace();}
            return null;
        }
        public int nextInt() {
            try {return Integer.parseInt(next());} catch (Exception e) {e.printStackTrace();}
            return -1;
        }
        public double nextDouble() {
            try {return Double.parseDouble(next());} catch (Exception e) {e.printStackTrace();}
            return -1;
        }
        public long nextLong()  {
            try {return Long.parseLong(next());} catch (Exception e) {e.printStackTrace();}
            return -1;
        }
    }
}

Measured memory_bytes: 23252
#!/usr/bin/env python
# -*- coding: utf-8 -*-

MOD = 998244353


def inv(x, m):
  y, u, v = m, 1, 0

  while y != 0:
    t = x // y
    x -= t * y
    u -= t * v
    x, y = y, x
    u, v = v, u

  return u % m


def main():
  N, M, K = map(int, input().split())
  color = M
  division = 1
  count = 0

  if K == N - 1:
    count += color * division

  for i in range(N - 2, -1, -1):
    color = (color * (M - 1)) % MOD
    division = division * (i + 1) * inv(N - 1 - i, MOD) % MOD

    if i <= K:
      count = (count + color * division) % MOD

  print(count)


if __name__ == '__main__':
  main()


Measured memory_bytes: 68000
#include <stdio.h>
#define INFTY 2000000000
int count=0;

int mergeSort(int x[ ], int left, int right);
int merge(int x[ ], int left, int mid, int right);

int mergeSort(int x[ ], int left, int right){
   int mid;
   if (left+1 < right){
      mid = (left + right) / 2;
      mergeSort(x, left, mid);
      mergeSort(x, mid, right);
      merge(x, left, mid, right);
   }
}

int merge(int A[ ], int left, int mid, int right){
  int n1, n2, i, j, k;
   n1 = mid - left;
   n2 = right - mid;
   int L[n1+1], R[n2+1];
   for(i=0;i<n1;i++) L[i] = A[left + i];
   for(i=0;i<n2;i++) R[i] = A[mid + i];
   L[n1]=INFTY;
   R[n2]=INFTY;
   i = 0;
   j = 0;
   for(k=left;k<right;k++){
      if(L[i] <= R[j]){
         A[k] = L[i];
         i = i + 1;
      }
      else{
         A[k] = R[j];
         j = j + 1;
      }
      count++;
   }
}

int main(void){
int n, i, left, right;
    scanf("%d", &n);
    int x[n];
    for(i=0;i<n;i++)scanf("%d", &x[i]);

    mergeSort(x, 0, n);

    for(i=0;i<n-1;i++)printf("%d ", x[i]);
    printf("%d", x[i]);
    printf("\n");
    printf("%d\n", count);
    return 0;
}


Measured memory_bytes: 5600
#include<bits/stdc++.h>
using namespace std;
#define ll long long                                    // long long省略
#define pb push_back                                    // push_back省略
#define mp make_pair                                    // make_pair省略
#define fi first                                        // first省略
#define se second                                       // second省略
#define itn int                                         // int誤字保険
#define count cout                                      // cout誤字保険
#define vecotr vector                                   // vector誤字保険
#define ednl endl                                       // endl誤字保険
#define opt() cin.tie(0); ios::sync_with_stdio(false)   // 入出力速度改善

#define rep(i,l,r) for(ll i=(l);i<(r);i++)               // 範囲[l, r)で刻み1のfor文(順方向)
#define repp(i,l,r,k) for(ll i=(l);i<(r);i+=(k))         // 範囲[l, r)で刻みkのfor文(順方向)
#define rrep(i,l,r) for(ll i=(r-1);i>=(l);i--)           // 範囲[l, r)で刻み1のfor文(逆方向)
#define rrepp(i,l,r,k) for(ll i=(r-1);i>=(l);i-=(k))     // 範囲[l, r)で刻みkのfor文(逆方向)
#define all(x) (x).begin(), (x).end()                   // vectorのポインタ位置指定用
#define max(p,q)((p)>(q)?(p):(q))                       // max拡張
#define min(p,q)((p)<(q)?(p):(q))                       // min拡張
#define bit(n,m)(((n)>>(m))&1)                          // 変数nのm番目のbitを取り出す

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 dy[]={0, 1, 0, -1};                                 // 4方向近傍
int dx[]={1, 0, -1, 0};                                 // 4方向近傍

int main(){
    ll a,b,c; cin>>a>>b>>c;
    vector<ll> v={a,b,c};
  	sort(all(v));
    cout << min(abs(v[0]-v[1]),abs(v[0]-v[2])) + abs(v[1]-v[2]) << ednl;
}


Measured memory_bytes: 256
from sys import stdin
from itertools import accumulate


def main():
    input = lambda: stdin.readline()[:-1]
    N, K = map(int, input().split())
    P = map(int, input().split())

    num = [0] * (N + 1)
    for i, j in enumerate(P, start=1):
        num[i] = ((j * (j + 1)) // 2) / j
    num = list(accumulate(num))
    ans = 0
    for i in range(K, N + 1):
        ans = max(ans, num[i] - num[i-K])
    print(ans)


main()


Measured memory_bytes: 23612
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>

int N;
int M;
int X;

int check(int **arr, int x)
{
    int *sum;
    int c;
    int d;
    int ans = 1;
    sum = (int *)malloc(sizeof(int) * M);
    for (d = 0; d < M; ++d)
    {
        sum[d] = 0;
        for (c = 0; c < N; ++c)
        {
            sum[d] += abs((x / (int)pow(2, c)) % 2 - 1) * arr[c][d];
        }
        if (sum[d] < X)
        {
            ans *= 0;
        }
    }
    free(sum);
    return ans;
}

int sum(int *C, int x)
{
    int ans = 0;
    int c;
    for (c = 0; c < N; ++c)
    {
        ans += abs((x / (int)pow(2, c)) % 2 - 1) * C[c];
    }
    return ans;
}

int main(void) //code is too dirty
{
    int *C;
    int *a;
    int **A;
    int c;
    int d;
    int temp;
    int x;
    int ans;
    scanf("%d", &N);
    scanf("%d", &M);
    scanf("%d", &X);
    C = (int *)malloc(sizeof(int) * N);
    a = (int *)malloc(sizeof(int) * N * M);
    A = (int **)malloc(sizeof(int *) * N); //sizeof(int*)
    for (c = 0; c < N; ++c)
    {
        A[c] = &a[M * c];
    }
    for (c = 0; c < N; ++c)
    {
        scanf("%d", &C[c]);
        for (d = 0; d < M; ++d)
        {
            scanf("%d", &A[c][d]);
        }
    }
    if (check(A, 0) == 0)
    {
        printf("-1");
        free(C);
        free(a);
        free(A);
        return 0;
    }
    ans = sum(C, 0);
    for (x = 1; x < (int)pow(2, N); ++x)
    {
        if (check(A, x) == 1)
        {
            temp = sum(C, x);
            if (temp < ans)
            {
                ans = temp;
            }
        }
    }
    printf("%d", ans);
    free(C);
    free(a);
    free(A);
    return 0;
}

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

int main()
{
  	string N;
  	cin >> N;
	if(((N[0] == N[1]) and (N[1]== N[2])) or ((N[1] == N[2]) and (N[2] == N[3])))
      cout << "Yes";
  	else
      cout << "No";
}

Measured memory_bytes: 256
#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<P> VP;
typedef vector<vector<ll>> VV;
typedef vector<vector<int>> VVi;
typedef vector<vector<vector<ll>>> VVV;
typedef vector<vector<vector<vector<ll>>>> VVVV;

#define REP(i, a, b) for(ll i=(a); i<(b); i++)
#define PER(i, a, b) for(ll i=(a); i>=(b); i--)
#define rep(i, n) REP(i, 0, n)
#define per(i, n) PER(i, n, 0)
const ll INF=1e18+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 rALL(v) v.rbegin(), v.rend()
#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)
#ifdef LOCAL
#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 dbgmint(n,arr) rep(i,n){cerr<<arr[i].x<<" ";}cerr<<endl;
#define dbgarrmint(n,m,arr) rep(i,n){rep(j,m){cerr<<arr[i][j].x<<" ";}cerr<<endl;}
#else
#define dbg(...)
#define dbgmap(...)
#define dbgarr(...)
#define dbgdp(...)
#define dbgmint(...)
#define dbgarrmint(...)
#endif
#define out(a) cout<<a<<endl
#define out2(a,b) cout<<a<<" "<<b<<endl
#define vout(v) rep(i,v.size()){cout<<v[i]<<" ";}cout<<endl
#define Uniq(v) v.erase(unique(v.begin(), v.end()), v.end())
#define fi first
#define se second


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

    ll n,m;
    cin>>n>>m;

    VP vp;
    rep(i,n){
        ll a,b;
        cin>>a>>b;
        vp.emplace_back(a,b);
    }
    sort(ALL(vp));
    ll cnt = 0;
    priority_queue<ll> q;
    ll ans = 0;
    REP(i,1,m+1){
        while(cnt<n && vp[cnt].fi<=i){
            q.push(vp[cnt].se);
            cnt++;
        }
        if(!q.empty()){
            ans += q.top();
            q.pop();
        }
    }
    out(ans);
    return  0;
}

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


#define MOD 1000000007
#define debug(x) cout<<"x :"<<x<<endl;
//#define case(t,ans) cout<<"Case #"<<t<<": "<<ans<<endl;
#define REP(i,a,b) for (int i = a; i <= b; i++)
#define for_it(it,s) for (auto it = s.begin(); it != s.end(); it++)
#define for_each(r,s) for(auto r:s)

#define all(s) s.begin(),s.end()
#define rall(s) s.end(),s.begin()
#define F first
#define S second
#define PB push_back
#define pb pop_back
#define EB emplace_back
#define pf push_front

#define fill0(arr) memset(arr,0,sizeof(arr))
#define filln(arr) memset(arr,-1,sizeof(arr))
#define MP make_pair
#define vi vector<int>
#define vll vector<ll>
#define vf vector<float>
#define vd vector<ld>
#define precision(x) cout<<fixed<<setprecision((x));
 


#define pi pair<int,int> 
#define ll long long 
#define ld long double
#define endl "\n"
//typedef long long ll;
//typedef vector<int> vi;
//typedef pair<int,int> pi;
//sort(a, a+n);
//reverse(a, a+n);
//random_shuffle(a, a+n);

const ll mod=1e9 + 7;




# define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
# define trace1(x)                cerr << #x << ": " << x << "\n";
# define trace2(x, y)             cerr << #x << ": " << x << " | " << #y << ": " << y << "\n";
# define trace3(x, y, z)          cerr << #x << ": " << x << " | " << #y << ": " << y << " | " << #z << ": " << z << "\n";
# define trace4(a, b, c, d)       cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << "\n";


#define case(i) cout<<"Case "<<i<<": ";
using namespace std;


template<typename T>
T gcd(T u, T v)
{
    return u%v==0?v:gcd(v,u%v);
}




void solve();
int main(){
  //  #ifndef ONLINE_JUDGE
   // freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
   // freopen("error.txt", "w", stderr);
   // #endif
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll t=1;
    //cin>>t;
    clock_t launch=clock();
    for(ll i=1;i<=t;i++)
    {
       // case(i);
        solve();
    }
  
  
     clog<<((long double)(clock()-launch)/CLOCKS_PER_SEC)<<"\n";
    // cerr<<"error is good"<<endl;
    return 0;
}

void solve()
{
   //code
	string s,t;
	cin>>s>>t;

	int a,b;
	cin>>a>>b;

	string u;
	cin>>u;

	if((s.compare(u))==0)
	{
		cout<<a-1<<" "<<b<<endl;
	}
	else
	{
		cout<<a<<" "<<b-1<<endl;
	}
}




Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args){
 
		Scanner sc = new Scanner(System.in);
 
		String S = sc.next();
 
		if (S.equals("Sunny")) {
			System.out.println("Cloudy");
		} else if (S.equals("Cloudy")) {
			System.out.println("Rainy");
		} else {
			System.out.println("Sunny");
		}
 
 
	}}

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

#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
#define REP(i, n) for(int i = 0; i < (n); ++i)
#define REPr(i, n) for(int i = (n)-1; i >= 0; --i)
#define FORq(i, m, n) for(int i = (m); i <= (n); ++i)
#define FORqr(i, m, n) for(int i = (n); i >= (m); --i)
#define MP make_pair
#define SIN(x, S) (S.count(x) != 0)
#define M0(x) memset(x, 0, sizeof(x))
#define FILL(x, y) memset(x, y, sizeof(x))
#define MM(x) memset(x, -1, sizeof(x))
#define ALL(x) (x).begin(), (x).end()
#define DB(x) cerr << #x << " = " << x << endl
#define DB2(x, y)                                                              \
    cerr << "(" << #x << ", " << #y << ") = (" << x << ", " << y << ")\n";
#define DEBUG                                                                  \
    int x12345;                                                                \
    cin >> x12345;
typedef pair<int, int> PII;
typedef pair<long long, long long> PLL;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<long long> VL;
typedef long long ll;
typedef long long integer;
const long long MOD = 1e9 + 7;
///////////////////////////////////////////////
// for template
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;
}
///////////////////////////////////////////////
/// 🍈( '-' 🍈 |AC|
int main() {
    string S,T; cin >> S >> T;
    int lenS = S.length();
    int lenT = T.length();
    int ans, nans;
    ans = 10000; nans = 0;

    REP(i, lenS - lenT + 1){
        nans = 0;
        REP(j, lenT){
            if (S[i + j] != T[j]) nans++;
        }
        chmin(ans, nans);        
    }
    cout << ans << endl;
}

Measured memory_bytes: 3596
//-----------------------
// author : xyqkoala
// time : 2020-08-03
//-----------------------

#include<iostream>
#include<vector>
#include<string>
#include<deque>
#include<unordered_map>
#include<unordered_set>
#include<queue>
#include<algorithm>
#include<cmath>
#include<numeric>
using namespace std;

typedef long long LL;
const int MOD = 1e9+7;

void solve();


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


void solve(){
	int n;
	cin>>n;
	cout<<(n>=30?"Yes":"No")<<endl;
}


Measured memory_bytes: 3636
///   Journey to the End of earth   ///
/// Gunjan Kumar ///
#include<bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp> 
// #include <ext/pb_ds/tree_policy.hpp> 
// #include <functional> // for less 
// using namespace __gnu_pbds; 
using namespace std;
#define ll  long long
#define s(n) scanf("%d",&n)
#define ls(n) scanf("%lld",&n)
#define p(n) printf("%d",n)
// #define ln() printf("\n")
#define pln(n) printf("%d\n",n)
#define lpln(n) printf("%lld\n",n)
#define rep(i,a,n) for(int i=a;i<n;i++)
#define rev(i,a,n) for(int i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define gcd __gcd
#define tc           ll t1; cin>>t1; while(t1--)
#define inp         ll n; cin>>n; ll arr[n]; rep(i,0,n) cin>>arr[i];
#define vect vector<ll>
#define sortv(v)       sort(v.begin(),v.end())
#define lower(v,n)    lower_bound(v.begin(),v.end(),n)-v.begin()
#define upper(v,n)    upper_bound(v.begin(),v.end(),n)-v.begin()
#define bitcount(n) __builtin_popcount(n)
#define ln <<endl
#define inf          LONG_MAX
#define ninf         LONG_MIN
#define fast         ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
const   ll mod=1e9+7;
const ll N=1e5+5;

vector<int> adj[N];
int V,E;

void topologicalsort(int v,bool visited[],stack<int>& Stack)
{
  visited[v]=true;

  for(int i=0;i<adj[v].size();i++)
  {
    int vertex=adj[v][i];
    if(!visited[vertex])
    topologicalsort(vertex,visited,Stack);
  }
  Stack.push(v);

}

void longestpath()
{
  stack<int> Stack;
  bool* visited=new bool[V+1];
  for(int i=0;i<=V;i++)
    visited[i]=false;

  for (int i = 1; i <= V; i++) 
    if (visited[i] == false) 
      topologicalsort(i, visited, Stack); 
    int dist[V+1]={0};
    int maxi=0;

    while (Stack.empty() == false) { 
    int u = Stack.top(); 
    Stack.pop(); 
    for(int i=0;i<adj[u].size();i++)
    {
       dist[adj[u][i]]=max(dist[adj[u][i]],dist[u]+1);
    }
  }
  for(int i=1;i<=V;i++)
    if(maxi<dist[i])
      maxi=dist[i];
    cout<<maxi;
}


int main()
{

        
         cin >> V >> E;
         rep(i,0,E)
         {
          int x,y;
          cin >> x >> y;
          adj[x].pb(y);
         }

         longestpath();
         
     return 0;
}



Measured memory_bytes: 8320
use proconio::input;
#[allow(unused_imports)]
use proconio::marker::*;
#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;
#[allow(unused_imports)]
use std::f64::consts::*;
use superslice::*;

#[allow(unused)]
const INF: usize = std::usize::MAX / 4;
#[allow(unused)]
const M: usize = 1000000007;

fn main() {
    input! {
        n: usize,
        x: usize,
        mut a: [usize; n],
    }
    a.sort();
    let a = a.into_iter().enumerate().collect::<Vec<(usize, usize)>>();
    let result = a.upper_bound_by(|&(k, ak)| {
        if ak >= x {
            return Ordering::Greater;
        }
        let mut dp = vec![vec![false; x + 1]; n + 1];
        for i in 0..=n {
            dp[i][0] = true;
        }
        for i in 0..n {
            let ai = a[i].1;
            if i == k || ai > x {
                for j in 0..=x {
                    dp[i + 1][j] = dp[i][j];
                }
            } else {
                for j in 0..ai {
                    dp[i + 1][j] = dp[i][j];
                }
                for j in ai..=x {
                    dp[i + 1][j] = dp[i][j] || dp[i][j - ai];
                }
            }
        }
        if (x - ak..x).any(|j| dp[n][j]) {
            Ordering::Greater
        } else {
            Ordering::Less
        }
    });
    println!("{}", result);
}


Measured memory_bytes: 26748
N,Q = map(int, input().split())
S = input()

LR = [ list(map(int, input().split())) for _ in range(Q)]

acdet = [0] * N

for i in range(N-1):
    if S[i] == "A" and S[i+1] == "C":
        acdet[i] =   1
        acdet[i+1] = 2

acdet_flag = [0] * N
for i in range(N):
    if acdet[i] == 2:
        acdet_flag[i] = 1

ruiseki = [0]
for i in range(N):
    ruiseki.append( ruiseki[-1] + acdet_flag[i] )

for l,r in LR:
    # l,r = l-1, r-1
    print( ruiseki[ r] - ruiseki[l] )
    # print("ruiseki[r:", r, "], l-1: ", l-1)
    # print(ruiseki)




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

const int MAXN = 1e6+5;

int x;

int main() {
    ios::sync_with_stdio(false); cin.tie(0);
    cin >> x;
    if (x) cout << 0 << "\n";
    else cout << 1 << "\n";
    return 0;
}


Measured memory_bytes: 3580
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.HashMap;
import java.util.InputMismatchException;
import java.util.Map;
import java.util.StringTokenizer;

public class Main {

	public static void main(String[] args) throws IOException {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		InputReader in = new InputReader(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		TaskX solver = new TaskX();
		solver.solve(1, in, out);
		out.close();
	}

	static int INF = 1 << 30;
	static int modP = 1000000007;

	static P[] p;
	static Map<Long, Long> memo = new HashMap<>();
	static int N, W;
	static class TaskX {
		public void solve(int testNumber, InputReader in, PrintWriter out) {

			N = in.nextInt();
			W = in.nextInt();
			p = new P[N];
			for (int i = 0; i < N; i++) {
				int w = in.nextInt(), v = in.nextInt();
				p[i] = new P(w, v);
			}

			out.println(func(0, 0));

		}
	}

	static long func(int d, int j) {
		long key = (long)d << 32 | j;
		if (d == N) {
			memo.put(key, 0L);
			return 0;
		}
		if (memo.containsKey(key)) {
			return memo.get(key);
		}

		long ret = 0;

		if (j + p[d].w <= W) {
			ret = Math.max(func(d + 1, j), func(d + 1, j + p[d].w) + p[d].v);
		} else {
			ret = func(d + 1, j);
		}
		memo.put(key, ret);
		return ret;
	}

	static class P {
		int w,v;
		P (int w, int v) {
			this.w = w;
			this.v = v;
		}
	}

	static class InputReader {
		BufferedReader in;
		StringTokenizer tok;

		public String nextString() {
			while (!tok.hasMoreTokens()) {
				try {
					tok = new StringTokenizer(in.readLine(), " ");
				} catch (IOException e) {
					throw new InputMismatchException();
				}
			}
			return tok.nextToken();
		}

		public int nextInt() {
			return Integer.parseInt(nextString());
		}

		public long nextLong() {
			return Long.parseLong(nextString());
		}

		public double nextDouble() {
			return Double.parseDouble(nextString());
		}

		public int[] nextIntArray(int n) {
			int[] res = new int[n];
			for (int i = 0; i < n; i++) {
				res[i] = nextInt();
			}
			return res;
		}

		public long[] nextLongArray(int n) {
			long[] res = new long[n];
			for (int i = 0; i < n; i++) {
				res[i] = nextLong();
			}
			return res;
		}

		public InputReader(InputStream inputStream) {
			in = new BufferedReader(new InputStreamReader(inputStream));
			tok = new StringTokenizer("");
		}

	}

}


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

int main() {
    char op;
    int a, b;
    while(1) {
        cin >> a >> op >> b;
        if(op == '?') break;
        else if(op == '+') cout << a+b << endl;
        else if(op == '-') cout << a-b << endl;
        else if(op == '*') cout << a*b << endl;
        else if(op == '/') cout << a/b << endl;
    }
}


Measured memory_bytes: 3084
#include <iostream>
#include <vector>
#include <queue>
#include <utility>
#define INF 9999999
int main(){
    int N,M;
    std::cin >> N >> M;
    std::vector<int> cost(N+1,INF);
    std::priority_queue<std::pair<int,int>,std::vector<std::pair<int,int>>,std::greater<std::pair<int,int>>> NodeCost;
    std::vector<int> prevNode(N+1,0);
    std::vector<bool> visit(N+1,false);
    std::vector<int> unvisitNode(0);
    std::vector<std::vector<int>> neighbor(N+1,std::vector<int>(0));

    for(int i=0;i<M;i++){
        int A,B;
        std::cin >> A >> B;
        neighbor[A].push_back(B);
        neighbor[B].push_back(A);
    }
    for(int i=1;i<N+1;i++){
        unvisitNode.push_back(i);
    }

    std::pair<int,int> curPair;
    curPair.first = 0;
    curPair.second = 1;
    cost[1] = 0;
    NodeCost.push(curPair);
    int h= 0;
    while(h<N+1) {
        //curNodeを訪問済みに
        visit[curPair.second] = true;

        //curNode隣接ノードのコスト更新
        for (int i = 0; i < neighbor[curPair.second].size(); i++) {
            std::pair<int,int> targetNode;
            targetNode.second = neighbor[curPair.second][i];
            if (visit[targetNode.second] == false  && cost[targetNode.second] > cost[curPair.second] + 1) {
                cost[targetNode.second] = cost[curPair.second] + 1;
                prevNode[targetNode.second] = curPair.second;
                targetNode.first = cost[targetNode.second];
                NodeCost.push(targetNode);
            }
        }

        //次の訪問ノードの決定
        curPair = NodeCost.top();
        NodeCost.pop();
        h++;

    }
    //完了チェック
    bool complete = true;
    for(int i=1;i<N+1;i++){
        if(visit[i] == false){
            complete = false;
            break;
        }
    }

    if(!complete){
        std::cout << "No";
    }else {
        std::cout << "Yes" << std::endl;
        for (int i = 2; i < N + 1; i++) {
            std::cout << prevNode[i] << std::endl;
        }
    }
    return 0;
}


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


int main(){
    int n,m;
    cin >> n >> m;
    vector<int> a(n);
    vector<vector<int>> G;
    a.assign(n,0);
    G.assign(n,vector<int>());

    rep(i,m){
        int a,b;
        cin >> a >> b;
        --a;--b;
        G[a].push_back(b);
        G[b].push_back(a);
    }
    
    queue<int> q;
    q.push(0);
    while(q.size()){
        int v = q.front();
        q.pop();
        for(auto nextv : G[v]){
            if(a[nextv] != 0) continue;
            a[nextv] = v+1;
            q.push(nextv);
        }
    }
    cout << "Yes" << endl;
    for(int i = 1;i<=n-1;i++) cout << a[i] << endl;
}

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

int main(){
    long long int n;
    cin >> n;
    vector<long long int> d(n);
    for(int i=0;i<n;i++){
        cin >> d.at(i);
    }
    sort(d.begin(),d.end());
    if(d.at(n/2)==d.at(n/2-1)){
        cout << 0 << endl;
        return 0;
    }else{
        cout << d.at(n/2)-d.at(n/2-1) << endl;
        return 0;
    }
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define sc scanf
#define pr printf
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define MAX 1000007
#define MOD 1000000007
#define MODL 1000000007LL
#define sz(x) ((int)(x).size())

typedef long long ll;
typedef long double ld;
typedef pair<int, int> ii;

// Trace dinâmico
template<typename T>
void trace(T a) { cout << a << "\n"; }
template<typename T, typename... Args>
void trace(T a, Args... args) { cout << a << " "; trace(args...); }

// Debugador de recursão
int recNum = 0;
void prTabs() { for (int ii = 0; ii < recNum; ++ii) cout << "    "; }
template<typename... Args>
void recInit(Args... args) { prTabs(); trace("rec(", args..., ")"); recNum++; }
template<typename T>
void recEnd(T a) { prTabs(); trace("->", a); recNum--;}

int MD(int x) {
	if(x < 0) return x+MOD;
	if(x >= MOD) return x-MOD;
	return x;
}

ll MDL(ll x) {
	return (x%MODL+MODL)%MODL;
}

ll modpow(ll a, ll b, ll m) {
	if (!b) return 1LL;
	if (b&1LL) return a*modpow(a, b-1, m)%m;
	ll r = modpow(a, b>>1, m);
	return r*r%m;
}

//m prime
ll invmod(ll a , ll m) {
	return modpow(a, m-2, m);
}

int achou[MAX];

int n, t, a, b, c;
int main(){
	sc("%d\n", &n);
	int x = 1;
	int r = 7 % n;
	while(1) {
		achou[r]++;
		if (r == 0) break;
		x++;
		r = (10*r+7)%n;
		if (achou[r]) {
			break;
		}
	}
	if (r == 0) pr("%d\n", x);
	else pr("-1\n");
 	return 0;
}


Measured memory_bytes: 7612
import random as rng
import itertools as it
import collections as col
import heapq as hq
import sys
import copy as cp
sys.setrecursionlimit(10**9)


def dump_impl(*objects):
    print(*objects, file=sys.stderr)


def dump_dummy(*objects):
    pass


dump = dump_impl if "DEBUG" in sys.argv else dump_dummy

S = input()
w = int(input())
ans = []
for i in range((len(S)+w-1)//w):
    ans.append(S[i*w])
print("".join(ans))


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

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

using namespace std;

vector<string> spl(string s) {
  vector<string> res;
  int old = 1;
  while(1) {
    int p = s.find("/", old);
    if (p == string::npos) break;
    res.push_back(s.substr(old, p-old));
    old = p + 1;
  }
  res.push_back(s.substr(old));
  return res;
}

pair<bool, vector<string>> ff(vector<vector<string>>& lst, vector<string>& file) {
  vector<string> path;
  bool isdir = true;
  int n = lst.size();
  bool added = false;
  for (string name:file) {
    if (name == ".") continue;
    if (name == "..") {
      if (path.empty() || !isdir) return make_pair(false, path);
      else {
        path.pop_back();
        continue;
      }
    }
    bool fnd = false;
    REP(i,n){
      bool ok = lst[i].size() > path.size();
      REP(j,path.size()) {
        if (lst[i].size() <= j || path[j] != lst[i][j]) {
          ok = false;
          break;
        }
      }
      if (ok) {
        if (name == lst[i][path.size()]) {
          path.push_back(name);
          isdir = (path.size() != lst[i].size());
          fnd = true;
          break;
        } else if (name == "" && lst[i].size() == path.size() + 1 && lst[i][path.size()] == "index.html") {
          path.push_back("index.html");
          fnd = true;
          added = true;
          break;
        }
      }
    }
    if (!fnd) return make_pair(false, path);
  }
  REP(i,n) {
    if (path == lst[i]) return make_pair(true, path);
    if (path.size() + 1 != lst[i].size()) continue;
    bool ok = true;
    REP(j,path.size()) {
      if (path[j] != lst[i][j]) {
        ok = false;
        break;
      }
    }
    if (! added && ok && lst[i].back() == "index.html") {
      return make_pair(true, lst[i]);
    }
  }
  return make_pair(false, path);
}

int main() {
  while(1){
    int n,m;
    cin>>n>>m;
    if(!n)break;
    vector<vector<string>> f(n);
    REP(i,n) {
      string fp;
      cin>>fp;
      f[i] = spl(fp);
    }
    REP(i,m) {
      string a,b;
      cin>>a>>b;
      auto fa = spl(a);
      auto fb = spl(b);
      auto pa = ff(f, fa);
      auto pb = ff(f, fb);
      if (pa.first && pb.first) {
        if (pa.second == pb.second) {
          cout << "yes" << endl;
        } else {
          cout << "no" << endl;
        }
      } else {
        cout << "not found" << endl;
      }
    }
  }
  return 0;
}

Measured memory_bytes: 1232
#include <stdio.h>
int main(void){
    int n,m,win[1000],i,j,sum=0,k;
    char a[1000][9],b[9];
    while(1){
        scanf("%d%d",&n,&m);
        if(n==0)break;
        for(i=0;i<n;i++){
            scanf("%s%d",a[i],&win[i]);
            a[i][8]=0;
        }
        
        sum=0;
        for(k=0;k<m;k++){
            scanf("%s",b);
            for(i=0;i<n;i++){
                for(j=7;j>=0;j--){
                    if(a[i][j]=='*'){
                        sum+=win[i];
                        break;
                    }
                    if(a[i][j]!=b[j])
                        break;
                    else if(j==0)
                        sum+=win[i];
                }
            }
        }
        printf("%d\n",sum);
    }
    
    
    return 0;
}

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

int main(){
  int y,x; cin>>y>>x;
  char a[y][x];
  for(int i=0;i<y;i++){
    for(int j=0;j<x;j++){
      cin>>a[i][j];
    }
  }
  
  int tmpY=0,tmpX=0;
  while(true){
    a[tmpY][tmpX]='.';
    if(a[tmpY+1][tmpX]=='#') tmpY=tmpY+1;
    else if(a[tmpY][tmpX+1]=='#') tmpX=tmpX+1;
    else break;
  }

  string ans="Possible";
  for(int i=0;i<y;i++){
    for(int j=0;j<x;j++){
      if(a[i][j]=='#') ans="Impossible";
    }
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 256
// ProblemURL : https://atcoder.jp/contests/abc097/tasks/arc097_a
// ---------------------------------------------
package main

import (
	"fmt"
	"sort"
)

func main() {
	var s string
	var k int
	fmt.Scan(&s, &k)
	n := len(s)

	substrs := make([]string, 0, n*n)
	m := make(map[string]bool, n*n)
	for i := 0; i < n; i++ {
		for j := i + 1; j < i+6 && j < n+1; j++ {
			substr := s[i:j]

			_, alreadyExists := m[substr]
			if alreadyExists {
				continue
			}

			substrs = append(substrs, substr)
			m[substr] = true
		}
	}

	sort.Strings(substrs)
	fmt.Println(substrs[k-1])
}


Measured memory_bytes: 313472
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
string s,t;
int S[3001][3001];
vector<char> V;
int main(){
    cin>>s>>t;
    for(int i=0 ; i<s.size() ; i++){
        for(int j=0 ; j<t.size() ; j++){
            if(s[i]==t[j])S[i+1][j+1] = S[i][j]+1;
            else{
                S[i+1][j+1] = max(S[i+1][j],S[i][j+1]);
            }
        }
    }
    int k = S[s.size()][t.size()];
    int i = s.size();
    int j = t.size();
    while(k){
        while(i&&S[i][j]==k)i--;
        i++;
        while(j&&S[i][j]==k)j--;
        j++;
        V.push_back(s[i-1]);
        i--;
        j--;
        k--;
    }
    for(int i=V.size()-1 ; i>=0 ; i--){
        cout<<V[i];
    }
}

Measured memory_bytes: 35456
#include <iostream>
#include <string>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <cmath>
#include <array>
#include <queue>
#include <map>
#include <set>
#include <stack>
#include <cstdint>
#include <unordered_set>
#include <ctime>
typedef long long int llint;

int main(void){

  std::set<llint> s;
  int n;
  std::cin >> n;
  for(int i=0; i<n; i++){
    llint tmp;
    std::cin >> tmp;


    if(s.find(tmp) != s.end()){
      std::cout << "NO" << std::endl;
      return 0;
    }
    s.insert(tmp);
  }
  std::cout << "YES" << std::endl;
  return 0;
}


Measured memory_bytes: 9600
#include<bits/stdc++.h>
using namespace std;
//B - Can you solve this?
int main(void){
    int n,m,c;
    std::cin >> n >> m >> c;
    int b[m];
    for(int i=0;i<m;i++){
        std::cin >> b[i];
    }
    int ans=0;
    int a,sum;
    for(int i=0;i<n;i++){
        sum=0;
        for(int j=0;j<m;j++){
            std::cin >> a;
            sum+=a*b[j];
        }
        sum+=c;
        if(sum>0){
            ans++;
        }
    }
    std::cout << ans << std::endl;
    
}


Measured memory_bytes: 256