akhauriyash/Code-Regression huggingface dataset:
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
#include <queue>

using namespace std;

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
typedef pair<LL, LL> PLL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

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

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
const LL INF = 1e15;

struct Edge{
  int to, cost, idx, rev, cc;

  Edge(int t, int c, int r, int cc_): to(t), cost(c), rev(r), cc(cc_)
  {}
  bool operator>(const Edge& rhs) const{
	return cost > rhs.cost;
  }
};
typedef vector< vector<Edge> > Graph;
void add_edge(Graph& G, int u, int v, int w, int cc){
  G[u].PB(Edge(v,w,SZ(G[v]),cc));
  G[v].PB(Edge(u,w,SZ(G[u])-1,cc));
}

void Dijkstra(const Graph& edges, vector<LL>& d, VI& prv, int s){
  const int V = edges.size();
  priority_queue<PLL, vector<PLL>, greater<PLL> > pq;
  fill(d.begin(), d.end(), INF);
  fill(ALL(prv), -1);
  prv[s] = -1;
  d[s] = 0;
  pq.push(MP(0,s));

  while(!pq.empty()){
	PII pii = pq.top(); pq.pop();
	int v = pii.second;
	if(d[v] < pii.first) continue;
	for(int i=0;i<edges[v].size();++i){
	  const Edge& e = edges[v][i];
	  if(d[e.to] > d[v] + e.cost){
		prv[e.to] = e.rev;
		d[e.to] = d[v] + e.cost;
		pq.push(MP(d[e.to], e.to));
	  }
	  else if(d[e.to] == d[v] + e.cost)
		if(prv[e.to] == -1 || edges[e.to][prv[e.to]].cc > e.cc)
		  prv[e.to] = e.rev;
	}
  }
}

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

  int N, M;
  while(cin>>N>>M,N){
	Graph G(N);
	REP(i,M){
	  int u, v, d, c;
	  cin >> u >> v >> d >> c;
	  --u, --v;
	  add_edge(G,u,v,d,c);
	}
	LL ans = 0;
	VI prv(N);
	vector<LL> dist(N);
	Dijkstra(G, dist, prv, 0);
	REP(i,N){
	  if(prv[i] >= 0)
		ans += G[i][prv[i]].cc;
	}
	cout << ans << endl;
  }

  return 0;
}

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

#define ll long long
#define MOD 1000000007

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

	int n;
	cin>>n;
	ll int res=0;
	for(int i=1;i<=n;i++) {
		if(i%3==0 || i%5==0) continue;
		else res+=i;
	}	
	cout<<res<<endl;
	
	return 0;
}

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

void Main()
{
    string s, t, u;
    cin >> s >> t >> u;
    cout << s[0] << t[1] << u[2] << endl;
}

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

Measured memory_bytes: 3636
#include <stdio.h>

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


Measured memory_bytes: 2044
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author Silviase
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        DWideFlip solver = new DWideFlip();
        solver.solve(1, in, out);
        out.close();
    }

    static class DWideFlip {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            String s = in.next();
            int res = s.length();
            for (int i = 0; i < s.length() - 1; i++) {
                if (s.charAt(i) != s.charAt(i + 1)) {
                    // i+1 <-> rest
                    res = Math.min(res, Math.max(i + 1, s.length() - i - 1));
                }
            }
            out.println(res);
        }

    }
}



Measured memory_bytes: 24972
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb push_back
#define mp make_pair
#define F  first
#define S  second
#define ff(i,n) for(i=0;i<n;i++)
ll bg = 1000000007;
ll power(ll x,ll y)
{
	if(y==0)
		return 1;
	ll h=power(x,y/2)%bg;	
	h=(h*h)%bg;
	if(y%2==1)
	  return (x*h)%bg;
	else
	  return h%bg;  
}
ll modinv(ll m)
{
	return power(m,bg-2)%bg;
}
vector<ll> z_func(vector<ll> a)
{
	ll n = a.size();
	vector<ll> z(n);
	ll l=0,r=0;
	for(ll i=1;i<n;i++)
	{
		if(i<=r)
			z[i] = min(r-i+1,z[i-l]);
		else
			z[i]=0;
		while(i+z[i]<n && a[z[i]]==a[i+z[i]])
		   z[i]++;
		if(i+z[i]-1>r)
		{
			l = i;
			r = i+z[i]-1;	
		}   		
	}
	return z;
}
string s;
ll arr[600000];
vector<vector<ll> >adj(600000);
int main()
{ 
	ll t;
	t=1;
	while(t--)
	{
		ll i,n;
		string f;
		cin>>f;
		n = f.length();
		ll a[n+1],b[n+1];
		a[0] = 0;
		ll c = 0;
		for(i=1;i<=n;i++)
		{
			if(f[i-1]=='<')
				c++;
			else
				c = 0;
			a[i]=c;		
		}
		c= 0;
		b[n]=0;
		for(i=n-1;i>=0;i--)
		{
			if(f[i]=='>')
			    c++;
			else
			    c = 0;
			b[i]=c;	    
		}
		ll ans = 0;
		ff(i,n+1)
			ans+=max(a[i],b[i]);
		cout<<ans;	
	}	    
	return 0;
}

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

int main() {
  
  int N; cin >> N; map<string, int> M;
  
  for (int i = 0; i < N; i++) {
    string S; cin >> S;
    M[S]++;
  }
  
  int maxV = 0;
  
  for (auto itr = M.begin(); itr != M.end(); itr++) {
    maxV = max(maxV, (*itr).second);
  }
  
  for (auto itr = M.begin(); itr != M.end(); itr++) {
    if (maxV == (*itr).second) {
      cout << (*itr).first << endl;
    }
  }
  
}

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

// Vasito
typedef long long ll;
typedef pair<int,int> pii;
#define fore(i,ii,iii)for(int i=ii;i<iii;i++)
#define rfor(i,ii,iii)for(int i=iii-1;i>=ii;i--)
#define all(s) s.begin(),s.end()
#define sz(a) ((int)a.size())
#define pb push_back
#define mset(a,b) memset(a,b,sizeof(a))
#define fst first
#define snd second
// Extra
#define OUT(a)cout<<a<<endl
#define ANS(a) OUT(res.size());for(auto i:a)cout<<i<<" ";ENDL
#define PRINT(a,init,end) FOR(i,init,end) cout<<a[i]<<" ";ENDL
#define PRINTV(a) for(auto i:a)cout<<i<<" ";ENDL

struct block {ll w,s,v;};
const ll N=1024,M=1e4+15,MOD=1e9+7,INF=1e18;
block a[N];
ll n,m,dp[N][M];
  
bool compare(const block &a,const block &b) {
  return (a.w+a.s)<(b.w+b.s);
}

ll solve(int i,int j) {
  if(i==n || j>=M) return 0;
  if(dp[i][j]!=-1) return dp[i][j];
  ll r = solve(i+1,j);
  if(a[i].s>=j) r=max(r,a[i].v+solve(i+1,j+a[i].w));
  return dp[i][j] = r;
}

int main() {
  ios::sync_with_stdio(false);
  mset(dp,-1);
  cin>>n;
  fore(i,0,n)cin>>a[i].w>>a[i].s>>a[i].v;
  sort(a,a+n,compare);
  //cout<<"___________"<<endl;fore(i,0,n)cout<<a[i].w<<" "<<a[i].s<<" "<<a[i].v<<endl;
  cout<<solve(0,0)<<endl;
}

Measured memory_bytes: 80512
#include<bits/stdc++.h>
using namespace std;
#define int long long
signed main(){
    int n;
    cin >> n;
    map<int,int> p;
    vector<int> a(n);
    for(int i = 0; i < n; i++){
        cin >> a[i];
        p[a[i]]++;
    }
  int sum = 0;
  vector<int> de(n,0), dd(n, 0);
    for(int i = 1; i <= n; i++){
        sum += (p[i] * (p[i] - 1)) / 2;
        de[i - 1] = (p[a[i - 1]] * (p[a[i - 1]] - 1) / 2);
        dd[i - 1] = ((p[a[i - 1]] - 2) * (p[a[i - 1]] - 1) / 2);
    }

    for(int i = 0; i < n; i++){
        cout << sum - de[i] + dd[i] << endl;
    }
}

Measured memory_bytes: 20224
#include <iostream>
#include <vector>
#include <set>
#include <queue>
#include <stack>
#include <map>
#include <limits>
#include <string>
#include <algorithm>
#include <bitset>
#include <unordered_set>
#include <unordered_map>
#include <map>
#include "math.h"
#include "assert.h"

using namespace std;

#define ll long long

#define BUFF ios::sync_with_stdio(false)
#define epsilon 1e-07
#define pi 2 * acos(0.0);
#define mod 1000000007   // 1e9+7
#define cerr if(false)cerr
#define watch(x) cerr << #x << " = " << x << endl;

#define inf std::numeric_limits<int>().max();

int main() {
	int n;
	cin >> n;
	vector<int> a(n+1), b(n+1), c(n+1);
	for(int i=1; i<=n; i++) {
		cin >> a[i];
	}
	for(int i=1; i<=n; i++) {
		cin >> b[i];
	}
	for(int i=1; i<n; i++) {
		cin >> c[i];
	}
	int ans = 0;
	int ant = -1;
	for(int i=1; i<=n; i++) {
		ans += b[a[i]];
		if (a[i] == ant + 1) ans += c[ant];
		ant = a[i];
	}
	cout << ans << endl;

}


Measured memory_bytes: 256
while true
    arr = gets.chomp.split.map(&:to_i)
    break if arr == [0, 0, 0]
    n, k, m = arr
    stones = (1..n).to_a
    stones.delete_at(m - 1)
    p = m - 1
    until stones.length == 1
        p = (p + k - 1) % stones.length
        stones.delete_at(p)
    end
    puts stones[0]
end


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

#define ll long long
#define vvi vector<vector<int>>
#define vec vector
#define pq priority_queue
#define all(v) (v).begin(), (v).end()
#define rep(i, n) for (int (i) = (0); (i) < (n); ++(i))
#define repp(i, m, n) for (int (i) = (m); (i) < (n); ++(i))
#define debug(x) cerr << #x << ": " << x << endl;
#define debug2(x, y) cerr<<"("<<#x<<", "<<#y<<") = "<<"("<<x<<", "<<y<<")"<<endl;
#define debug3(x, y, z) cerr<<"("<<#x<<", "<<#y<<", "<<#z<<") = "<<"("<<x<<", "<<y<<", "<<z<<")"<<endl;
#define debugB(x, y) cerr<<#x<<": "<<bitset<y>(x) << endl;
#define line() cerr << "---------------" << endl;

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

template<typename T>
void printA(vector<T> &printArray, char between = ' ') {
   int paSize = printArray.size();
   for (int i = 0; i < paSize; i++) { cerr << printArray[i] << between;}
   if (between != '\n') {cerr << endl;}
}

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

int W, H;
char B[30][30];
int cnt = 0;

void dfs(int y, int x) {
   cnt++;
   B[y][x] = '#';
   rep (i, 4) {
      int nx = x+dx[i], ny = y+dy[i];
      if (nx < 0 || nx >= W || ny < 0 || ny >= H || B[ny][nx] == '#') continue;
      dfs(ny, nx);
   }
}

int main() {
   while (1) {
      cin >> W >> H;
      if (W == 0 && H == 0) break;
      cnt = 0;
      rep (i, H) {
         cin >> B[i];
      }
      rep (i, H) {
         rep (j, W) {
            if (B[i][j] == '@') {
               dfs(i, j);
            }
         }
      }
      cout << cnt << endl;
   }

   return 0;
}


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

using namespace std;

int main() {
	int l, m, n, sum, i;
	bool flag;

	while (cin >> l, l) {
		sum = 0;
		flag = true;
		for (i = 1; i < 13; ++i) {
			cin >> m >> n;
			sum += m - n;
			if (flag && sum >= l) {
				l = i;
				flag = false;
			}
		}
		if (flag) {
			cout << "NA" << endl;
		}
		else {
			cout << l << endl;
		}
	}

	return 0;
}


Measured memory_bytes: 3056
import sys
sys.setrecursionlimit(2147483647)
INF=float("inf")
MOD=10**9+7
input=lambda :sys.stdin.readline().rstrip()
def resolve():
    n,q=map(int,input().split())
    S,T,X=[0]*n,[0]*n,[0]*n
    D=[0]*q
    for i in range(n):
        S[i],T[i],X[i]=map(int,input().split())
    for j in range(q):
        D[j]=int(input())

    E=[]
    E+=[(s-x,1,x) for s,x in zip(S,X)]
    E+=[(t-x,2,x) for t,x in zip(T,X)]
    E+=[(d,3,i) for i,d in enumerate(D)]
    E.sort()
    from collections import defaultdict
    cnt=defaultdict(int)
    cnt[INF]=1

    from heapq import heappop,heappush
    Q=[INF]
    ans=[-1]*q
    for a,b,c in E:
        if(b==1):
            heappush(Q,c)
            cnt[c]+=1
        elif(b==2): # 本来はここでqからcを削除したいが、できないためb==3で処理する
            cnt[c]-=1
        else:
            while(cnt[Q[0]]==0): # 本来削除されるべき通行止めをここで消す
                heappop(Q)
            x=Q[0]
            if(x!=INF): ans[c]=x
    print(*ans,sep="\n")
resolve()


Measured memory_bytes: 125192
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define pb push_back
#define mp make_pair
#define vi vector<int>
#define inf 1e10
#define mod 1000000007
#define mii map<int,int>
#define pii pair<int,int>
#define setbits(x) __builtin_popcountll(x)
#define lcm(x,y)  (x*y)/__gcd(x,y)
void c_p_c()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
#ifndef  ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
}
int  fact(int n)
{
	if (n == 0 || n == 1)
		return 1;
	else
		return n * fact(n - 1);
}
int nCr(int n, int r)
{
	if (r == 0)
		return 1;
	else
		return fact(n) / (fact(n - r) * fact(r));
}
int floorRoot5(int n)
{
	// Base cases
	if (n == 0 || n == 1)
		return n;

	// Initialize result
	int res = 0;

	// Keep incrementing res while res^5 is
	// smaller than or equal to n
	while (res * res * res * res * res <= n)
		res++;

	// Return floor of 5'th root
	return res - 1;
}

int32_t main()
{
	//c_p_c();
	int ans = 0;
	int x;
	cin >> x;
	int p = 100;
	while (p < x)
	{
		p += p / 100;
		ans++;
	}
	cout << ans;
}



Measured memory_bytes: 3604
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}

fn read_vec2<T: std::str::FromStr>(n: u32) -> Vec<Vec<T>> {
    (0..n).map(|_| read_vec()).collect()
}

fn main() {
    let i : Vec<i32> = read_vec();
    let l = i[0] + i[1];
    let r = i[2] + i[3];
    let diff = l -r ;
    if diff == 0 {
        println!("Balanced");
    } else if diff < 0 {
        println!("Right");
    } else  {
        println!("Left");
    }

}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define rep(i,b) FOR(i,0,b)
#define INF mugen
#define dump(x) cerr<<#x<<"="<<x<<endl
#define all(a) (a).begin(),(a).end()
typedef vector<int> vi;
typedef vector<vi> vii;
typedef vector<vii> viii;
typedef pair<int,int> P;
template <class T> void chmin(T & a, T const & b) { if (b < a) a = b; }
template <typename T>
string to_string(const T &n){ostringstream stm;stm << n;return stm.str();}
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }
using ll = long long;
const ll mod = LLONG_MAX;
 

int n;

struct edge{
    int to,cost;
    edge(int to,int cost){
        this->to=to;this->cost=cost;
    }
};
vector<edge> vec[112345];
int color[112345];
void init(){
    rep(i,112345)color[i]=-1;
}
//odd==0 かつevenで1 odd==1でodd2まで待機 odd==2でぐう
void dfs(int now,int odd){
    int x=odd;
    // dump(now);
    // dump(odd);

    // rep(i,n){
    //     dump(color[i]);
    // }
    
    rep(i,vec[now].size()){
        x=odd;
        edge next=vec[now][i];
        if(color[next.to]!=-1)continue;
        
        if(next.cost%2!=0){
            x++;
            if(x==1){
                color[next.to]=0;
                dfs(next.to,x);
            }else if(x==2){
                x=0;

                color[next.to]=1;
                dfs(next.to,x);
            }else {
                cerr<<"ERR"<<endl;
            }
        }else{
            if(x==0){
                color[next.to]=1;
                dfs(next.to,x);
            }else{
                color[next.to]=0;
                dfs(next.to,x);
            }
        }

    }
}

signed main(){
    cin>>n;

    init();
    rep(i,n-1){
        int u,v,w;
        cin>>u>>v>>w;
        u--;v--;
        vec[u].push_back(edge(v,w));
        vec[v].push_back(edge(u,w));
    }
    color[0]=1;
    dfs(0,0);

    rep(i,n){
        cout<<color[i]<<endl;
    }


    

    
 
}

/*
5
2 5 1
2 3 1
1 3 8
3 4 1
*/

Measured memory_bytes: 8704
#include <stdio.h>

int main()
{
  int a,b,c,count;

  while( scanf("%d %d",&a,&b) != EOF ){

    c = a + b;

    for( count = 0 ; c > 0 ; count++ ){

      c /= 10;

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

  return 0;
}

Measured memory_bytes: 600
#include <iostream>
using namespace std;
int main()
{
  long long r ,d,x;
  cin>> r >> d>>x;
  long long m = x;
  for (int i = 0 ; i <10 ;i++){
      m=r*m-d;
      cout<< m <<endl;
  }
    return 0;
}


Measured memory_bytes: 3600
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] a = new int[n];
		for (int i = 0; i < n; i++) {
			a[i] = sc.nextInt() - i;
		}
		sc.close();

		Arrays.sort(a);
		int b = a[n / 2];
		long ans = 0;
		for (int i = 0; i < n; i++) {
			ans += Math.abs(a[i] - b);
		}
		System.out.println(ans);
	}
}


Measured memory_bytes: 66920
#include <iostream>
#include <utility>
#include <vector>
#include <algorithm>
#include <string>

using namespace std;

int main(void){
    int n;
    vector<int> h;
    
    cin >> n;

    for(int i = 0; i < n; i++){
      int a;
      cin >> a;
      h.push_back(a);
    }

    int max = 0;
    int ans = 0;
    for(int i = 0; i < n; i++){
      if(h[i] >= max){
        max = h[i];
        ans++;
      }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
int N, M, p, d[10000], ld[10000], rd[10000], ans = INT_MAX;

int right(int now, int I)
{
	if(now <= d[I])
		return d[I] - now;
	else
		return N - (now - d[I]);
}
int left(int now, int I)
{
	if(now >= d[I])
		return now - d[I];
	else
		return N - (d[I] - now);	
}
int main()
{
	cin >> N >> M >> p;
	for(int i = 0; i < M; i++)
		cin >> d[i];
	sort(d, d + M);
	for(int i = 0; i < M; i++)
	{
		rd[i] = right(p, i);
		ld[i] = left(p, i);
	}
	for(int i = 0; i < M; i++)
	{
		if(i != M - 1)
		 	ans = min(ans, left(d[i], i + 1) + rd[i]);
		else
			ans = min(ans, left(d[i], 0) + rd[i]);
		if(i != 0)
		 	ans = min(ans, right(d[i], i - 1) + ld[i]);
		else
			ans = min(ans, right(d[i], M - 1) + ld[i]);
	}

	int temp = 0, temp2 = 0;
	for(int i = 0; i < M; i++)
	{
		temp = max(temp, rd[i]);
		temp2 = max(temp2, ld[i]);
	}
	temp = min(temp, temp2);
	ans = min(ans, temp);
	cout << ans * 100 << endl;
}

Measured memory_bytes: 3180
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<n;i++)
#define ll unsigned long long
using namespace std;
int main(){
    int N,M,ans=0;
    cin>>N>>M;
    cout<<N*(N-1)/2+M*(M-1)/2<<endl;
}

Measured memory_bytes: 636
import java.util.*;
import static java.lang.Integer.*;
//import static java.lang.Long.*;
//import static java.lang.Math.*;
import static java.lang.System.*;

public class Main {
	public static void main(String[] args) {
		int i,j;
		Scanner sc = new Scanner(in);
		int x = parseInt(sc.next());
		int y = parseInt(sc.next());
		sc.close();
		int[] xy = {0, 1, 3, 1, 2, 1, 2, 1, 1, 2, 1, 2, 1};
		out.println(xy[x]==xy[y]?"Yes":"No");
	}
}


Measured memory_bytes: 19412
#include<stdio.h>
#define MAX 100005
#define NIL -1
struct Node_struct{int p, l, r;}; /*p: 親(parent), l: 一番左の子(left child), r:右の兄弟(right sibling)*/
typedef struct Node_struct Node;
Node T[MAX];
int D[MAX];

void print(int u){
 int i, c;
 printf("node %d: parent = %d, depth = %d, ", u, T[u].p, D[u]);

 if( T[u].p == NIL /*ここを埋める (fill this blank)*/) printf("root, ");
 else if( T[u].l == NIL /*ここを埋める(fill this blank)*/) printf("leaf, ");
 else printf("internal node, ");

 printf("[");
 for (i=0, c = T[u].l; c != NIL; i++, c = T[c].r){
   if(i) printf(", ");
   printf("%d", c);
 }
 printf("]\n");

}

void calcDepth(int u, int p){
 D[u] = p;
 if(T[u].r != NIL /*ここを埋める(fill this blank)*/) calcDepth(T[u].r, p /*ここを埋める(fill this blank)*/);
 if(T[u].l != NIL /*ここを埋める(fill this blank)*/) calcDepth(T[u].l, p+1 /*ここを埋める(fill this blank)*/);
}

int main(){
 int i, j, k;
 int n;
 int id, sib, child;
 int root = NIL;
 scanf("%d", &n);
 for(i=0; i<n; i++) T[i].p = T[i].l = T[i].r = NIL;

 for(i=0; i<n; i++){
   scanf("%d %d", &id, &k);
   for(j = 0, sib = NIL; j<k; j++){ //子を入力する (input children)
     scanf("%d", &child);
     T[child].p = id;
     if(j == 0) T[id].l = child; //idの一番左の子 (the most left child of id)
     else T[sib].r = child; //左の兄弟に繋げる (connect to left sibling)
     sib = child;//次の子供の左の兄弟 (the left sibling of the next child)
   }
 }

 //根を求める (find the root)
 for(i=0; i<n; i++){
   if(T[i].p == -1) root = i;
 }

 //それぞれのノードの深さを求める (find depth of each node)
 calcDepth(root, 0);

 //出力 (output)
 for(i=0; i<n; i++) print(i);

 return 0;
}



Measured memory_bytes: 6380
#include <cstdio>
    #include <cstring>
    #include <algorithm>
    #include <deque>
    #define MAXN 300010
    #define y1 zjtsb_y1
    using namespace std;
     
    int w,h,n,w0;
    pair<int,int> a[MAXN];
    deque<int> S1,S2,S3;
     
    bool cmp2(pair<int,int> x,pair<int,int> y){
    	return x.second<y.second;
    }
     
    int gao(int l,int r,int y0,int y1){
    	if(l==r) return max(max(w+a[l].second-y0,w+y1-a[l].second),max(y1-y0+a[l].first,y1-y0+w-a[l].first));
    	int mid=(l+r)>>1;
    	int ymid=a[mid].second;
    	int res1=gao(l,mid,y0,a[mid].second);
    	int res2=gao(mid+1,r,a[mid+1].second,y1);
    	sort(a+l,a+r+1);
    	int mid2=l-1;
    	while(mid2<r && a[mid2+1].first<=w0) mid2++;
    	static int s1[MAXN][3],s2[MAXN][3];
    	int ls1=0,ls2=0;
    	int t0=y0,t1=y1;
    	for(int i=mid2;i>=l;i--){
    		s1[++ls1][0]=t0;
    		s1[ls1][1]=t1;
    		s1[ls1][2]=a[i].first;
    		if(a[i].second<=ymid && a[i].second>t0) t0=a[i].second;
    		if(a[i].second>ymid && a[i].second<t1) t1=a[i].second;
    	}
    	s1[++ls1][0]=t0;
    	s1[ls1][1]=t1;
    	s1[ls1][2]=0;
    	t0=y0; t1=y1;
    	for(int i=mid2+1;i<=r;i++){
    		s2[++ls2][0]=t0;
    		s2[ls2][1]=t1;
    		s2[ls2][2]=a[i].first;
    		if(a[i].second<=ymid && a[i].second>t0) t0=a[i].second;
    		if(a[i].second>ymid && a[i].second<t1) t1=a[i].second;
    	}
    	s2[++ls2][0]=t0;
    	s2[ls2][1]=t1;
    	s2[ls2][2]=w;
    	S1.clear();
    	S2.clear();
    	S3.clear();
    	int now1=1,now2=1;
    	for(int i=1;i<=ls2;i++){
    		while(!S3.empty() && s2[S3.front()][1]-s2[S3.front()][0]+s2[S3.front()][2]<s2[i][1]-s2[i][0]+s2[i][2])
    			S3.pop_front();
    		S3.push_front(i);
    	}
    	int res=0;
    	for(int i=1;i<=ls1;i++){
    		while(now1<=ls2 && s2[now1][0]<=s1[i][0]){
    			while(!S1.empty() && s2[S1.front()][1]+s2[S1.front()][2]<s2[now1][1]+s2[now1][2])
    				S1.pop_front();
    			S1.push_front(now1++);
    		}
    		while(now2<=ls2 && s2[now2][1]>=s1[i][1]){
    			while(!S2.empty() && s2[S2.front()][2]-s2[S2.front()][0]<s2[now2][2]-s2[now2][0])
    				S2.pop_front();
    			S2.push_front(now2++);
    		}
    		while(!S1.empty() && s2[S1.back()][1]>=s1[i][1]) S1.pop_back();
    		while(!S2.empty() && s2[S2.back()][0]<=s1[i][0]) S2.pop_back();
    		while(!S3.empty() && (s2[S3.back()][0]<=s1[i][0] || s2[S3.back()][1]>=s1[i][1])) S3.pop_back();
    		res=max(res,s1[i][1]-s1[i][0]+s2[min(now1-1,now2-1)][2]-s1[i][2]);
    		if(!S1.empty()) res=max(res,s2[S1.back()][1]-s1[i][0]+s2[S1.back()][2]-s1[i][2]);
    		if(!S2.empty()) res=max(res,s1[i][1]-s2[S2.back()][0]+s2[S2.back()][2]-s1[i][2]);
    		if(!S3.empty()) res=max(res,s2[S3.back()][1]-s2[S3.back()][0]+s2[S3.back()][2]-s1[i][2]);
    	}
    	res=max(res,max(res1,res2));
    	return res;
    }
     
    int solve(){
    	w0=w/2;
    	sort(a+1,a+n+1,cmp2);
    	return gao(1,n,0,h);
    }
     
    int main(){
    	scanf("%d%d%d",&w,&h,&n);
    	for(int i=1;i<=n;i++) scanf("%d%d",&a[i].first,&a[i].second);
    	int ans1=solve()*2;
    	swap(w,h);
    	for(int i=1;i<=n;i++) swap(a[i].first,a[i].second);
    	int ans2=solve()*2;
    	printf("%d\n",max(ans1,ans2));
    	return 0;
    }

Measured memory_bytes: 9088
#include<stdio.h>
int main (void){
 int a[9];
 int n,i,s;
 for(i=0;i<9;i++){
  a[i]=0;
 }
 scanf("%d",&n);
 for(i=0;i<n;i++){
  scanf("%d",&s);
  if(400>s){
   a[0]++;
  }else if(800>s){
   a[1]++;
  }else if(1200>s){
   a[2]++;
  }else if(1600>s){
   a[3]++;
  }else if(2000>s){
   a[4]++;
  }else if(2400>s){
   a[5]++;
  }else if(2800>s){
   a[6]++;
  }else if(3200>s){
   a[7]++;
  }else{
   a[8]++;
  }
 }
 s=0;
 for(i=0;i<8;i++){
  if(a[i]){
   s++;
  }
 }
 printf("%d %d\n",(!s&&a[8])?1:s,s+a[8]);
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < (int)n; i++)
#define all(x) x.begin(), x.end()
#define MOD 1000000007//1e9+7
typedef long long ll;
using namespace std;
int main()
{
  int a;
  cin >> a;
  string ans;
  if(a < 1200){ans = "ABC";
  }else if(a < 2800){
    ans = "ARC";
  }else{ans = "AGC";}
  cout << ans << endl;

}


Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
	int a,b;
	scanf("%d %d",&a,&b);
	if(a+b<24){
		printf("%d\n",a+b);
	}
	else if(a+b==24){
		printf("0\n");
	}
	else{
		printf("%d\n",(a+b)-24);
	}
	return 0;
}


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

#define pb push_back
#define ff first
#define ss second
#define all(x) (x).begin(), (x).end()
#define ll long long
#define ii pair<int,int>
#define vi vector<int>
#define vll vector<ll>
#define vii vector<ii>

using namespace std;

int32_t main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int n,m,pen=0;
	cin>>n>>m;
	set<int> st;
	map<int,int> totp;
	for(int i=0;i<m;++i){
		int x;
		string ver;
		cin>>x>>ver;
		if(ver=="AC"&&!st.count(x)){
			st.insert(x);
			pen+=totp[x];
		}
		else if(ver=="WA")
			totp[x]++;
	}
	cout<<st.size()<<" "<<pen<<endl;
	return 0;
}

Measured memory_bytes: 9600
from bisect import bisect_left

n = int(input())
A = [0] + list(map(int, input().split()))
graph = [[] for _ in range(n + 1)]
for _ in range(n - 1):
    u, v = map(int, input().split())
    graph[v].append(u)
    graph[u].append(v)

start = 1

stack = [1]
par = [-1] * (n + 1)
ans = [0] * (n + 1)
used = [False] * (n + 1)
infi = 10 ** 20
LIS = [infi] * (n + 1)
LIS[0] = -infi
position = [(-1, -1)] * (n + 1)


def hantei(val, L):
    pos = bisect_left(L, val)
    pre = L[pos]
    L[pos] = val
    cnt = bisect_left(L, infi)
    return L, pos, pre, cnt


while stack:
    v = stack[-1]
    if not used[v]:
        LIS, pos, pre, cnt = hantei(A[v], LIS)
        position[v] = (pos, pre)
        ans[v] = cnt - 1
    used[v] = True
    if not graph[v]:
        _ = stack.pop()
        basho, atai = position[v]
        LIS[basho] = atai
        continue
    u = graph[v].pop()
    if u == par[v]:
        continue
    par[u] = v
    stack.append(u)

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


Measured memory_bytes: 89736
#include<stdio.h>
int main(){
	int n,k=0,m=0,i;
	for(i=0;i<4;i++){
		scanf("%d",&n);
		k+=n;
		if(m==0 || m>n)m=n;
	}
	k-=m;
	scanf("%d %d",&n,&m);
	if(m>n)n=m;
	printf("%d\n",n+k);
	return 0;
}


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

int dfs(int node, vector<int> adj[], vector<int>&vis, vector<int>&dp){
    if(vis[node])return dp[node];
    vis[node]=1;
    int ans = 0;
    for(auto i : adj[node]){
        ans = max(ans, 1+dfs(i, adj, vis, dp));
    }
    dp[node]=ans;
    return ans;
}

int main(){
    int n, m;
    cin>>n>>m;
    vector<int> adj[n+1];
    vector<int>vis(n+1, 0);
    vector<int>dp(n+1, 0);
    for(int i = 0 ;i < m ;i++){
        int a, b;
        cin>>a>>b;
        adj[a].push_back(b);
    }
    for(int i = 1; i <= n ;i++){
        if(!vis[i]){
            dfs(i, adj, vis, dp);
        }
    }
    int ans =0;
    for(int i =1 ; i <= n;i++){
        ans= max(ans,dp[i]);
    }
    cout<<ans;
}

Measured memory_bytes: 9856
#include<bits/stdc++.h>
using namespace std;
int a,b;
int main(void)
{
	cin>>a;
	if(a==25)cout<<"Christmas"<<endl;
	if(a==24)cout<<"Christmas Eve"<<endl;
	if(a==23)cout<<"Christmas Eve Eve"<<endl;
	if(a==22)cout<<"Christmas Eve Eve Eve"<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <queue>
#include <array>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <cassert>
#include <utility>
#include <functional>

using namespace std;
using lli = long long int;
using ll = long long;

int main() {
    int A, B;
    cin >> A >> B;

    if (A - 2 * B > 0) {
        cout << A - 2 * B << endl;
    }else {
        cout << 0 << endl;
    }

    return 0;
}


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

using namespace std;

int getans(){
	string str;
	cin >> str;
	if(str == "Male")return 0;
	if(str == "Female")return 1;
	exit(0);
	return 2;
}

int main(){
	int n;
	cin >> n;
	cout << 0 << endl;
	int ls = getans();
	int rs = ls;
	int l = 0,r = n;
	while(true){
		int mid = (l + r) / 2;
		cout << mid << endl;
		int ms = getans();
		if((r - mid) % 2 != (rs^ms)){
			l = mid;
			ls = ms;
		}
		else{
			r = mid;
			rs = ms;
		}
	}
	return 0;
}

/*
0M
1F
2M
3F
4M
5
6F
7M
8F*/

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

int n, m, b;
int a[1000], d[1000];
int dp[1001][4096];
const int INF = (1 << 30) - 1;

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

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

		d[i] = 0;

		for (int j = 0; j < b; j++) {
			int c;

			cin >> c;
			d[i] += (1 << (c - 1));
		}
	}

	for(int i = 0; i < m; i++)
		dp[i][0] = 0;

	int w = 1 << n;

	for (int j = 1; j < w; j++) {
		if ((j & d[0]) == j)
			dp[0][j] = a[0];
		else
			dp[0][j] = INF;
	}

	for (int i = 1; i < m; i++) {
		for (int j = 1; j < w; j++) {
			int jd = j - (j & d[i]);
			dp[i][j] = min(dp[i - 1][j], dp[i - 1][jd] + a[i]);
		}
	}

	if (dp[m - 1][w - 1] == INF)
		cout << -1 << endl;
	else
		cout << dp[m - 1][w - 1] << endl;

	return 0;
}


Measured memory_bytes: 16256
import java.util.*;
public class Main {
    public static void main(String args[]) {
        Scanner s = new Scanner(System.in);
        int k = s.nextInt();
        int n = s.nextInt();

        int arr[] = new int[n];
        Arrays.sort(arr);

        for(int i = 0 ; i < n ; i++)
        arr[i] = s.nextInt();

        int max = 0;

        for(int i = 1 ; i < n ; i++){
            max = Math.max(arr[i]-arr[i-1],max);
        }
        int last = k - arr[n-1] + arr[0] - 0;
        max = Math.max(last, max);

        System.out.println(k-max);
    }
}

Measured memory_bytes: 65456
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cstring>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <numeric>
#include <utility>
#include <iomanip>
#include <algorithm>
#include <functional>
#include <unordered_map>
using namespace std;

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

template<class T> vector<T> make_vec(size_t a) { return vector<T>(a); }
template<class T, class... Ts> auto make_vec(size_t a, Ts... ts) {
  return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}
template<class T, class V>
typename enable_if<is_class<T>::value == 0>::type fill(T &t, const V &v) {
    t = v;
}
template<class T, class V>
typename enable_if<is_class<T>::value != 0>::type fill(T &t, const V &v){
    for (auto &e : t) fill(e, v);
}

#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }

#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)
template<class T> ostream& operator << (ostream &s, set<T> P)
{ EACH(it, P) { s << "<" << *it << "> "; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P)
{ EACH(it, P) { s << "<" << it->first << "->" << it->second << "> "; } return s << endl; }


int N;
vector<long long> L;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    while (cin >> N) {
        L.resize(N);
        for (int i = 0; i < N; ++i) cin >> L[i];

        long long res = 0;
        sort(L.begin(), L.end());
        for (int i = 0; i < N; ++i) {
            for (int j = i+1; j < N; ++j) {
                long s = L[i] + L[j];
                int it = lower_bound(L.begin(), L.end(), s) - L.begin();
                res += max(it - j - 1, 0);

                //cout << i << ", " << j << ": " << s << ": " << it << endl;
            }
        }
        cout << res << endl;
    }
}


















Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
using namespace std;
long long n, di, ans;
int main()
{
    cin >> n;
    for(long long i = 10; ; i *= 10){
        if(n % i == n){
            di = i / 10;
            break;
        }
    }
    if(di == 1){
        cout << n;
    }else if(di == 10){
        cout << 9;
    }else if(di == 100){
        cout << 9 + n + 1 - 100;
    }else if(di == 1000){
        cout << 909;
    }else if(di == 10000){
        cout << 909 + n + 1 - 10000;
    }else if(di == 100000){
        cout << 90909;
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,m,n) for(int i=m;i<n;i++)
ll mod=1e9+7;

int main() {
  int n,m;
  cin>>n>>m;
  vector<int> a[n];
  rep(i,0,m){
    int f,t;
    cin>>f>>t;
    a[f-1].push_back(t-1);
  }
  int s,t;
  cin>>s>>t;
  int d[n];
  rep(i,0,n){
    d[i]=-1;
  }
  bool used[n][3];
  rep(i,0,n){
    rep(j,0,3){
      used[i][j]=false;
    }
  }
  queue<int> q;
  q.push(s-1);
  d[s-1]=0;
  used[s-1][0]=true;
  int cur=0;
  while(q.size()){
    int c=q.size();
    rep(i,0,c){
      int p=q.front();
      q.pop();
      rep(i,0,a[p].size()){
        if(!used[a[p][i]][(cur+1)%3]){
          q.push(a[p][i]);
          used[a[p][i]][(cur+1)%3]=true;
          if((cur+1)%3==0){
            d[a[p][i]]=(cur+1)/3;
          }
        }
      }
    }
    cur++;
  }
  cout<<d[t-1]<<endl;
}


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

int main(){
  int n,m; cin>>n>>m;
  vector<int> a(m),b(m);
  REP(i,m) cin>>a[i]>>b[i];
  
  vector<int> order(n);
  REP(i,n) order[i]=i+1;

  int cnt=0;
  do{
    vector<int> chk(n-1,0);
	REP(i,n-1){
      REP(j,m){
        if((min(order[i],order[i+1])==min(a[j],b[j]))
           &&(max(order[i],order[i+1])==max(a[j],b[j]))){
          chk[i]=1;
        }
      }
    }
    int flag=1;
    REP(i,n-1){
      flag*=chk[i];
    }
    if(flag==1) cnt++;
  } while (next_permutation(order.begin()+1, order.end()));
  
  cout << cnt << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i,s,e) for(int i=(s); i<(e);i++)
#define rep(i,n) REP(i,0,n)
#define rep1(i,n) REP(i,1,n)
#define repe(i,n) for(auto &&i:n)
#define all(v) (v).begin(),(v).end()
#define decimal fixed<<setprecision(20)
#define fastcin() cin.tie(0);ios::sync_with_stdio(false)
using namespace std;
using LL = long long;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const int INF = 1e9;
const LL LLINF = 1e16;

int main(){
    fastcin();

    int n, m;
    cin >> n >> m;
    while(n > 0){
        vector<int> a(n), b(m);
        rep(i, n) cin >> a[i];
        rep(i, m) cin >> b[i];
        int ans = 0;
        vector<int> un(n, 0), um(m, 0);
        rep(i, n){
            rep(j, m)if(a[i]==b[j]){
                if(!un[i] && !um[j]){
                    un[i] = 1;
                    um[j] = 1;
                    ans += a[i];
                    break;
                }
            }
        }
        rep(i, n)if(!un[i]) ans += a[i];
        rep(i, m)if(!um[i]) ans += b[i];
        cout << ans << endl;
        cin >> n >> m;
    }

}


Measured memory_bytes: 3116
#include <ext/pb_ds/assoc_container.hpp>
#include <bits/stdc++.h>
using namespace std;
using namespace __gnu_pbds;
template <class c, class cmp = less<c> > using ordered_set = tree<c, null_type, cmp, rb_tree_tag, tree_order_statistics_node_update>;
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...) 
#endif
template<class T> ostream& operator<<(ostream &os, vector<T> V) {os << "[ "; for(auto v : V) os << v << " "; return os << "]";}
template<class L, class R> ostream& operator<<(ostream &os, pair<L,R> P) {return os << "(" << P.first << "," << P.second << ")";}
template <typename T,typename U>pair<T,U> operator+(const pair<T,U> & l,const std::pair<T,U> & r) { return {l.first+r.first,l.second+r.second};}
typedef long long int ll;
const ll mod =998244353;
const int maxn = 300005;
#define endl '\n'
#define ld long double
#define int ll
#define all(x) (x).begin(),(x).end()
int32_t main()
{ 
  IOS


  string s, t;
  cin >> s >> t;
  int fin = 1e9;
  int n = s.size(), m = t.size();
  for(int i = 0;i<=n - m;i++){
    int temp= 0;
    for(int j = 0;j<m;j++){
      temp += (s[i+j]!=t[j]);
    }
    fin= min(fin,temp);
  }
  cout << fin << endl;
  

  










  
    
} 



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

int main() {
  int N, M;
  cin >> N >> M;
  string A[60], B[60];
  for (int i = 0; i < N; i++) cin >> A[i];
  for (int i = 0; i < M; i++) cin >> B[i];

  bool ans = false;
  for (int i = 0; i <= N - M; i++) {
    for (int j = 0; j <= N - M; j++) {
      bool check = true;
      for (int k = 0; k < M; k++) {
        if (A[i + k].substr(j, M) != B[k]) {
          check = false;
          break;
        }
      }
      if (check) ans = check;
    }
  }

  cout << (ans ? "Yes" : "No") << endl;
}

Measured memory_bytes: 256
import java.util.*;
import java.io.*;
 
public class Main {
    static boolean[][] used;
    static int[] ans;
    public static void main(String[] args) throws Exception {
        long max = (long)Math.pow(10,18);
        FastScanner sc = new FastScanner(System.in);
        PrintWriter out = new PrintWriter(System.out);
        long a = sc.nextLong();
        String[] s = sc.next().split("\\.");
        long b = Long.parseLong(s[0]+s[1]);
        out.println(a*b/100L);
        out.close();
    }
    
     static HashMap<Long,Integer> getPrimeFactorizationMap(long x) {
        HashMap<Long,Integer> result = new HashMap<Long,Integer>();
        int cnt = 0;
        while (x >= 2L && x % 2L == 0) {
            cnt++;
            x /= 2;
        }
        if(cnt > 0){
            result.put(2L,cnt);
            cnt = 0;
        }
        long d = 3;
        long q = x / d;
        while (q >= d) {
            cnt = 0;
            while (x % d == 0) {
                cnt++;
                x /= d;
            }
            if(cnt > 0){
                result.put(d,cnt);
            }
            d += 2;
            q = x / d;
        }
        if(x != 1) result.put(x,1);
        
        return result;
    }
}

class FastScanner {
    private BufferedReader reader = null;
    private StringTokenizer tokenizer = null;
    public FastScanner(InputStream in) {
        reader = new BufferedReader(new InputStreamReader(in));
        tokenizer = null;
    }

    public String next() {
        if (tokenizer == null || !tokenizer.hasMoreTokens()) {
            try {
                tokenizer = new StringTokenizer(reader.readLine());
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return tokenizer.nextToken();
    }

    public String nextLine() {
        if (tokenizer == null || !tokenizer.hasMoreTokens()) {
            try {
                return reader.readLine();
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return tokenizer.nextToken("\n");
    }

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

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

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

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

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

Measured memory_bytes: 25420
#include<bits/stdc++.h>
#define int long long
using namespace std;
struct abcd{int x,h;}b[200001];
bool cmp(abcd i,abcd j){return i.x<j.x;}
int n,d,a,qn[200001],qx[200001],q1,q2,qs,ans;
signed main()
{
 scanf("%lld%lld%lld",&n,&d,&a);
 for(int i=1;i<=n;i++)
 {
  scanf("%lld%lld",&b[i].x,&b[i].h);
  b[i].h=(b[i].h-1)/a+1;
 }
 sort(b+1,b+n+1,cmp);
 for(int i=1;i<=n;i++)
 {
  while(qx[q1]<b[i].x&&q1<q2)qs-=qn[q1++];
  if(b[i].h>qs)
  {
   ans+=(qn[q2]=b[i].h-qs);
   qx[q2++]=b[i].x+2*d;
   qs=b[i].h;
  }
 }
 printf("%lld",ans);
 return 0;
}

Measured memory_bytes: 9964
#include<iostream>
#include<algorithm>
#include<cstring>

unsigned int dp[51];

const int a[3]={2,3,5},b[3]={380,550,850},c[3]={5,4,3};
const double d[3]={0.8,0.85,0.88};

int main(){
	memset(dp,-1,sizeof(dp));
	
	dp[0]=0;

	for(int k=0;k<51;k++){
		if(dp[k]!=-1){
			for(int i=0;i<3;i++){
				for(int j=0;j<51/a[i];j++){
					int cost=b[i]*j;
					if(j%c[i]==0)cost*=d[i];

					dp[k+a[i]*j]=std::min(dp[k+a[i]*j],dp[k]+cost);
				}
			}
		}
	}
	
	int n;
	while(std::cin>>n,n){
		std::cout<<dp[n/100]<<std::endl;
	}

	return 0;
}

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

//////////////////
// Union-Find木 //
//////////////////

// 0-indexed
class UnionFind {
private:
	std::vector<int> parent_, size_;
public:
	UnionFind(const int size)
		:parent_(size), size_(size, 1)
	{
		for (int i{}; i < size; i++) parent_[i] = i;
	}
	int calcRoot(const int index)
	{
		int &parent{parent_[index]};
		if (parent == index) return index;

		parent = calcRoot(parent);
		return parent;
	}
	bool areConnected(const int index1, const int index2)
	{
		return calcRoot(index1) == calcRoot(index2);
	}
	void unite(const int index1, const int index2)
	{
		const int root1{calcRoot(index1)}, root2{calcRoot(index2)};
		if (root1 == root2) return;
		if (size_[root1] <= size_[root2])
		{
			size_[root2] += size_[root1];
			parent_[root1] = root2;
		}
		else
		{
			size_[root1] += size_[root2];
			parent_[root2] = root1;
		}
		return;
	}
	int calcSize(const int index)
	{
		return size_[calcRoot(index)];
	}
};

bool solve();

int main()
{
	if (solve()) puts("YES");
	else puts("NO");

	return 0;
}

bool solve()
{
	int N, M;
	scanf("%d%d", &N, &M);

	UnionFind uf(N + M);
	for (int i{}; i < N; i++)
	{
		int K;
		scanf("%d", &K);
		for (int j{}; j < K; j++)
		{
			int L;
			scanf("%d", &L);
			L--;
			uf.unite(i, N + L);
		}
	}
	for (int i{1}; i < N; i++)
		if (!uf.areConnected(0, i))
			return false;
	return true;
}

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

int main()
{
	int r,g,b,n;
	cin>>r>>g>>b>>n;
	int ans=0;
	for (int i=0;i<=n;i++) 
		for (int j=0;j<=n;j++) {
			int t=r*i+g*j;
			if (n-t<0 || (n-t)%b) continue;
			ans++;
		}
	cout<<ans<<endl;	
	return 0;
}

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

const int DIV = 350;

int N, M;
vector<long long> A, B;

int main() {
    cin >> N >> M;
    A.resize(M); B.resize(M);
    for (int i = 0; i < M; ++i) scanf("%lld %lld", &A[i], &B[i]);

    vector<vector<long long> > sb(DIV, vector<long long>(DIV, 0));
    vector<long long> imos(N+1, 0);
    long long geta = 0;
    for (int i = 0; i < M; ++i) {
        if (B[i] < DIV) {
            for (int j = 0; j < B[i]; ++j) {
                long long q = (A[i] + j + 1) % B[i];
                sb[B[i]][j] += q;
            }
        }
        else {
            ++geta;
            imos[0] += A[i];
            imos[N] += -1 - (A[i]+N)%B[i];
            for (int q = B[i]-A[i]-1; q < N; q += B[i]) {
                imos[q] -= B[i];
            }
        }
    }
    for (int i = 0; i <= N; ++i) imos[i] += geta;
    for (int i = 0; i <= N; ++i) imos[i+1] += imos[i];
    
    vector<long long> res = imos;
    for (int b = 1; b < DIV; ++b) {
        for (int i = 0; i < N; ++i) {
            int r = i % b;
            res[i] += sb[b][r];
        }
    }
    
    for (int i = 0; i < N; ++i) printf("%lld\n", res[i]);
}


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

using namespace std;

#define st first
#define nd second
#define ALL(x) (x).begin(), (x).end()

template <class T>
void mini(T& l, T r) {
  l = min(l, r);
}
template <class T>
void maxi(T& l, T r) {
  l = max(l, r);
}

using LL = long long;
using LD = long double;
using ULL = unsigned long long;
const int dx[] = {0, 1, 0, -1, -1, -1, 1, 1},
          dy[] = {1, 0, -1, 0, -1, 1, -1, 1};
const int INF = 1e9;
const LL MOD = 1e9 + 7;

LL Quickpower(LL a, LL b) {
  LL res = 1;
  while (b != 0) {
    if (b & 1) res = (res * a) % MOD;
    a = (a * a) % MOD;
    b /= 2;
  }
  return res;
}

void Solve() {
  int n;
  cin >> n;
  LL res = 0, x;
  vector<LL> a(60, 0);
  for (int i = 0; i < n; i++) {
    cin >> x;
    int j = 0;
    while (x != 0) {
      if (x % 2 == 1) a[j]++;
      j++;
      x /= 2;
    }
  }
  for (int i = 59; i >= 0; i--) {
    if (a[i] == 0) continue;
    res = (res + (Quickpower(2LL, i) * a[i]) % MOD * (n - a[i]) % MOD) % MOD;
  }
  cout << res << '\n';
}

void Prepare() {
  // TODO
  return;
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  Prepare();
  // int t, T;
  // cin >> T;
  // for (t = 1; t <= T; t++) {
  Solve();
  // }
  return 0;
}

Measured memory_bytes: 256