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

using namespace std;

using ll = long long;
using pii = pair<int,int>;
using pll = pair<ll,ll>;
using vi = vector<int>;
using vl = vector<ll>;

using _loop_int = int;
#define REP(i,n) for(_loop_int i=0; i<(_loop_int)(n); i++)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a); i<(_loop_int)(b); i++)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1; i>=(_loop_int)(a); i--)

#define CHMIN(a,b) (a)=min((a),(b))
#define CHMAX(a,b) (a)=max((a),(b))
#define ALL(v) (v).begin(),(v).end()

#define DEBUG(x) cerr<<#x<<": "<<(x)<<endl
#define DEBUG_VEC(v) cerr<<#v<<": ";REP(__i,(v).size())cerr<<((v)[__i])<<", ";cerr<<endl

const ll MOD = 1000000007ll;

int n;
int h[125252];

int main(){
    scanf("%d",&n);
    REP(i,n)scanf("%d",h+i);
    REP(i,n){
        if(i==0 || h[i-1] < h[i])h[i]--;
    }
    REP(i,n-1)if(h[i]>h[i+1]){
        puts("No");
        return 0;
    }
    puts("Yes");
    return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define REP(i,n) for(int i=0; i<(n); i++)
#define REP2(i,x,n) for(int i=x; i<(n); i++)
#define ALL(n) begin(n),end(n)
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
const long long INF = numeric_limits<long long>::max();
int main() {
    int S,W;
    cin >> S>>W;
    if(S<=W) cout<<"unsafe"<<endl;
    else cout << "safe" << endl;
    return 0;
}

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

typedef pair<int,int>P;
typedef pair<int,P>P2;

int main(){

  int n,m,b;
  int ans;

  while(1){
    
    cin >>n>>m>>b;
    if(n==0 && m==0 && b==0)break;
    
    vector<int> vec(n);
    
    for(int i=1 ; i <= n ; i++){
      vec[i-1]=i;  
    }
    
    P2 a[m];
    
    for(int i=0 ; i < m ; i++){
      cin >>a[i].first>>a[i].second.first>>a[i].second.second;
    }

    sort(a,a+m,greater<P2>());
    
    for(int i=0 ; i < m ; i++){
      swap(vec[a[i].second.first-1],vec[a[i].second.second-1]);
    }

    for(int i=0 ; i < n ; i++){
      if(vec[i] == b)ans=i+1;
    }

    cout <<ans<<endl;

  }

  return 0;
}

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

using namespace std;

int n,i,j,a[100005];
bool flag[100005];

int main(){
	scanf("%d", &n);
	
	for(i = 0; i < n; i++){
		scanf("%d", &a[i]);
		if(a[i] == i + 1)
		flag[i] = 1;
	}
	
	int res = 0;
	
	for(i = 0; i < n; i++){
		if(flag[i]){
			if(i + 1 < n && flag[i + 1]){
				flag[i + 1] = 0;
				flag[i] = 0;
				res++;
			}
			else{
				flag[i] = 0;
				res++;
			}
		}
	}
	
	printf("%d\n", res);
}


Measured memory_bytes: 768
/**
 *    author:  tourist
 *    created: 10.05.2020 20:13:54       
**/
#include <bits/stdc++.h>

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n, m, x;
  cin >> n >> m >> x;
  vector<int> c(n);
  vector<vector<int>> a(n, vector<int>(m));
  for (int i = 0; i < n; i++) {
    cin >> c[i];
    for (int j = 0; j < m; j++) {
      cin >> a[i][j];
    }
  }
  const int inf = (int) 1e9;
  int ans = inf;
  for (int t = 0; t < (1 << n); t++) {
    bool ok = true;
    int cost = 0;
    for (int i = 0; i < m; i++) {
      int sum = 0;
      for (int j = 0; j < n; j++) {
        if (t & (1 << j)) {
          sum += a[j][i];
        }
      }
      ok &= (sum >= x);
    }
    if (!ok) {
      continue;
    }
    for (int i = 0; i < n; i++) {
      if (t & (1 << i)) {
        cost += c[i];
      }
    }
    ans = min(ans, cost);
  }
  cout << (ans == inf ? -1 : ans) << '\n';
  return 0;
}


Measured memory_bytes: 3656
#include<stdio.h>

int main(void) {

	char S[4];

	scanf("%s", S);
  
  if(S[0] == S[1] && S[1] == S[2] && S[2] == S[3]){
    puts("No");
    return 0;
  }
    if(S[0] == S[1] && S[2] == S[3]) {
			puts("Yes");
    }
    else if(S[0] == S[2] && S[1] == S[3]){
        puts("Yes");
    }
    else if(S[0] == S[3] && S[1] == S[2]){
	puts("Yes");
    }
    else{
      puts("No");
    }
	return 0;
}


Measured memory_bytes: 128
y=list(map(int, input().split()))
N=int(input())
ans=0

if N>=2:
  tmp=min(y[0]*8, y[1]*4, y[2]*2, y[3])
  rep=N//2
  ans+=rep*tmp
  N-=rep*2

if N==1:
  ans+=min(y[0]*4, y[1]*2, y[2])

print(ans)

Measured memory_bytes: 9196
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <bitset>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <numeric>
#include <iostream>
#include <iomanip>
#include <string>
#include <chrono>
#include <random>
#include <cmath>
#include <cassert>
#include <climits>
#include <cstring>
#include <cstdlib>
#include <functional>
#include <sstream>

using namespace std;


int main(int argc, char** argv) {
    ios::sync_with_stdio(false);
    cin.tie(0);


    string s;
    cin >> s;
    int res = 0;
    for (auto c : s) {
        if (c == '+') {
            ++res;
        } else {
            --res;
        }
    }

    cout << res << '\n';

    return 0;
}

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

int main(void){
    string s;
    cin>>s;
    int num=s.size()-2;
    cout<<s[0]<<num<<s[s.size()-1]<<endl;
    return 0;
}

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


"""
input:
11
7
8
9
10
11
12
13
14
15
16
17

output:
4
"""

import sys
import math


def is_prime(x):
    if x == 2:
        return True
    elif x < 2 or not x % 2:
        return False

    i = 3
    x_sqrt = math.sqrt(x)
    while i <= x_sqrt:
        if not x % i:
            return False
        i += 2

    return True


def solve(_c_list):
    cnt = 0
    for ele in _c_list:
        if is_prime(ele):
            cnt += 1
    return cnt


if __name__ == '__main__':
    _input = sys.stdin.readlines()
    c_num = int(_input[0])
    c_list = list(map(int, _input[1:]))
    ans = solve(c_list)
    print(ans)

Measured memory_bytes: 8648
n,l = map(int, input().split())
ap = list(l+i-1 for i in range(1,n+1))

if ap[0]<0 and ap[n-1]<=0:
    print(sum(ap)-ap[n-1])
if ap[0]>=0 and ap[n-1]>0:
    print(sum(ap)-ap[0])
if ap[0]<0 and ap[n-1]>0:
    print(sum(ap))

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<n;i++)
#define REP1N(i,n) for(int i=1;i<=n;i++)
const double PI = acos(-1);
const double EPS = 1e-15;
long long INF=(long long)1E17;
#define i_7 (long long)(1E9+7)
using namespace std ;


int main()
{
  string s ;
  cin >> s ;
  
  char prev = s[0] ;
  for ( int i = 1 ; i < s.size() ; ++i ) {
    if ( prev == s[i] ) {
      cout << "Bad" << endl ;
      return 0 ;
    }
    prev = s[i] ;
  }
  cout << "Good" << endl ;
  
  return 0 ;
}

Measured memory_bytes: 256
A,B,C,K=map(int,input().split())
ans=0
if A>K:
    ans+=K
else:
    ans+=A
    if B>K-A:
        ans+=0
    else:
        if (K-A-B)<C:
            ans+=-(K-A-B)
        else:
            ans+=-C
print(ans)

Measured memory_bytes: 61564
#pragma once
#include<iostream>
#include<string>
#include<cmath>
#include<vector>
#include<algorithm>

#define rep(name,begin,end,up) for(long long name = begin; name < end; name += up)
#define rev(name,begin,end,down) for(long long name = begin - 1; name >= end; name -= down)

using ll = long long;
using namespace std;

void abc154c(void) {
	
	ll n; cin >> n;
	vector<int> a(n);

	rep(i, 0, n, 1) {
		cin >> a[i];
	}

	sort(a.begin(), a.end());

	rep(i, 0, n - 1, 1) {
		if (a[i] == a[i + 1]) {
			cout << "NO" << endl;
			return;
		}
	}

	cout << "YES" << endl;
}

///*
int main(void) {

	abc154c();

	return 0;
}
//*/

Measured memory_bytes: 1024
import fractions
n=int(input())
t=[int(input()) for i in range(n)]

if n==1:
    print(t[0])
else:
    x=t[0]*t[1]//fractions.gcd(t[0],t[1])
    for i in range(1,n-1):
        x=x*t[i+1]//fractions.gcd(x,t[i+1])
    print(x)


Measured memory_bytes: 5304
inputs = [int(input()) for _ in range(6)]

def check(n1, n2):
    return abs(inputs[n1] - inputs[n2]) <= inputs[5]

if check(0, 1) and check(0, 2) and check(0, 3) and check(0, 4) and check(1, 2) and check(1, 3) and check(1, 4) and check(2, 3) and check(2, 4) and check(3, 4):
    print("Yay!")
else:
    print(":(")


Measured memory_bytes: 3060
S = list(input())

l = len(S)
c1 = 0 
c2 = 0

for i in range(l):
  if i%2 ==0:
    if S[i] == "0":
      c1 += 1
    else:
      c2 += 1
  else:
    if S[i] == "0":
      c2 += 1
    else:
      c1 += 1
    
print(min(c1,c2))


Measured memory_bytes: 3956
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define all(x) (x).begin (),(x).end()
#define pb push_back
#define mp make_pair
#define vi vector<ll>
#define pii pair<ll,ll>
#define vii vector<pii>
#define mi map<ll,ll>
#define lb lower_bound
#define ub upper_bound
#define endl "\n"
#define si set<ll>
#define rep(i,a,b) for(unsigned ll i=a;i<b;i++)
#define SPEED ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define MOD 1000000007LL
#define pi 3.14159265358
ll binary_power(ll a, ll n) {
    if (n==0) return 1;
    ll k=binary_power(a,n/2);
    if (n%2==0) return (k*k)%MOD;
    else return (((k*k)%MOD)*a)%MOD;
}
bool isPrime(int num){
    bool flag=true;
    for(int i = 2; i*i <= num ; i++) {
       if(num % i == 0) {
          flag = false;
          break;
       }
    }
    return flag;
}

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

void solve()
{
   ll n; cin>>n;
   ll a[n+1];
   memset(a,0,sizeof(a));
   rep(i,2,n+1)
   {
       int b; cin>>b;
       a[b]++;
   }
   rep(i,1,n+1)
   {
       cout<<a[i]<<endl;
   }
}

int main()
{
    SPEED;
    ll t = 1;

  // cin>>t;

    while(t--) solve();

   return 0;
}


Measured memory_bytes: 5236
using System;

class Program
{
    static void Main(string[] args)
    {
        string line;
        while((line = Console.ReadLine()) != null)
        {
            var input = line.Split(' ');
            int sum = int.Parse(input[0]) + int.Parse(input[1]);
            Console.WriteLine(sum.ToString().Length);
        }
    }
}

Measured memory_bytes: 9152
import java.util.Scanner;

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

    int result = op.equals("+") ? a + b : a - b;
    System.out.println(result);
  }
}


Measured memory_bytes: 21840
//#pragma GCC optimize("Ofast")
//#pragma GCC optimize ("unroll-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
 
//Tariquzzaman Faisal
//_Faisal101_
//IUT_CSE'19
//190041101
 
#include<iostream>
#include<stdio.h>
#include<vector>
#include<deque>
#include<map>
#include<stack>
#include<queue>
#include<algorithm>
#include<cstring>
#include<climits>
#include<cmath>
#include<iterator>
#include<set>
#define fileOut freopen("out.txt","w",stdout)
#define fileIn freopen("in.txt","r",stdout)
#define testcases ll TC,T; cin >> TC; for(T=1; T<=TC; T++)
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL)
#define INFLL 9223372036854775807
#define INF 2147483647
#define pi acos(-1.0)
#define ll long long
#define endll printf("\n")
#define CASE printf("Case %lld: ",T)
#define ff first
#define ss second
#define mem(ara,n) memset(ara,n,sizeof ara)
#define ull unsigned long long
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define mid3(a,b,c) min(max(a,b),max(b,c),max(a,b))
#define max4(a,b,c,d) max(max(a,b),max(c,d))
#define min4(a,b,c,d) min(min(a,b),min(c,d))
#define endl '\n'
#define ld long double
 
 
using namespace std;


int main(){
    ll n, x;
    cin >> n;
    ll ara[n+5];
    for (int i = 1; i<= n; ++i)
    {
      cin >> x;
      ara[x] = i;
    }
    for (int i = 1; i <= n; ++i)
    {
      cout << ara[i] <<" ";
    }
    endll;
  return 0;
}

Measured memory_bytes: 4296
#include <stdio.h>

int main(void)
{
 long A,B,K;
 scanf("%ld%ld%ld",&A,&B,&K);

  if(A>=K){
    A=A-K;
    printf("%ld ",A);
    printf("%ld",B);
   }

  else if (A+B>=K){
           printf("0 ");
           printf("%ld\n",B-(K-A));
   }
  else {
       printf("0 ");
       printf("0\n");
  }
  return 0;
}

Measured memory_bytes: 128
n,m = map(int,input().split())
x = list(map(int,input().split()))

x.sort()
dist_l = [0] * (m-1)

for i in range(m-1):
    dist_l[i] = x[i+1] - x[i]

dist_l.sort()
print(sum(dist_l[:-(n-1)]) if n !=1 else sum(dist_l))

Measured memory_bytes: 13968
#include <bits/stdc++.h>
      
#define FOR(i,a,b) for(ll i = (a); i < (ll)(b); i++)
#define REP(i,n) FOR(i,0,n)
#define YYS(x,arr) for(auto& x:arr)
#define PW(x) (1LL<<(x))
#define SZ(x) ((ll)(x).size())

#define pb emplace_back
#define fi first
#define se second

using namespace std;

using ld = long double;
using ll = long long int;

const ll INF = (ll)1e9 + 10;
const ll INFLL = (ll)1e18 + 10;
const ll MOD = 998244353;
     
template<class T> T &chmin( T &a , const T &b ){ return a = min(a,b); }
template<class T> T &chmax( T &a , const T &b ){ return a = max(a,b); }
template<class T> void UNIQUE(vector<T> &a){ a.erase(unique(a.begin(), a.end()), a.end()); }

template<class S, class T> ostream& operator << (ostream& os, const pair<S, T> v){
  os << "(" << v.first << ", " << v.second << ")"; return os;
}
template<class T> ostream& operator << (ostream& os, const vector<T> v){
  for(int i = 0; i < v.size(); i++){if(i > 0){os << " ";} os << v[i];} return os;
}
template<class T> ostream& operator << (ostream& os, const vector<vector<T>> v){
  for(int i = 0; i < v.size(); i++){if(i > 0){os << endl;} os << v[i];} return os;
}

ll in(){long long int x; assert(scanf("%lld", &x) == 1); return x;}
ld fin(){double x; assert(scanf("%lf", &x) == 1); return x;}
char yuyushiki[1000010]; string stin(){assert(scanf("%s", yuyushiki) == 1); return yuyushiki;}

// head

int main(){

  string ans = "";
  REP(i, 3){
    string s = stin();
    ans += s[0] + 'A' - 'a';
  }
  cout << ans << endl;
  

  return 0;
}


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

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

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

void Main(){
    int n; cin >> n;
    
    if(n % 2 == 0){
        int m = n * (n-2) / 2;
        cout << m << endl;
        rep3(i, 1, n - 1){
            rep3(j, i + 1, n){
                if(i + j == n + 1) continue;
                cout << i << " " << j << endl;
            }
        }
    }else{
        int m = (n-1) * (n-1) / 2;
        cout << m << endl;
        rep3(i, 1, n - 1){
            rep3(j, i + 1, n){
                if(i + j == n) continue;
                cout << i << " " << j << endl;
            }
        }
    }

    return;
}

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

Measured memory_bytes: 3628
macro_rules! get {
    (Vec<$t:ty>) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.split_whitespace()
                .map(|t| t.parse::<$t>().unwrap())
                .collect::<Vec<_>>()
        }
    };
    ($t:ty) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.trim().parse::<$t>().unwrap()
        }
    };
    ($($t:ty),*) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            (
                $(iter.next().unwrap().parse::<$t>().unwrap(),)*
            )
        }
    };
    ($t:ty; $n:expr) => {
        (0..$n).map(|_|
            get!($t)
        ).collect::<Vec<_>>()
    };
    ($($t:ty),*; $n:expr) => {
        (0..$n).map(|_|
            get!($($t),*)
        ).collect::<Vec<_>>()
    };
}

fn main() {
    let S = get!(String).chars().collect::<Vec<_>>();

    let n = S.len();
    // RL となるマスに人は集まる
    let ans = (0..n).map(
        |i|
        {
            let a = if S[i] == 'R' && S[i + 1] == 'R' || S[i] == 'L' && S[i - 1] == 'L' {
                0
            } else if S[i] == 'R' && S[i + 1] == 'L' {
                let L = (0..i).rev().take_while(|&j| S[j] == 'R').count();
                let R = ((i + 2)..n).take_while(|&j| S[j] == 'L').count();
                1 + L / 2 + (R + 1) / 2
            } else {
                let L = (0..(i - 1)).rev().take_while(|&j| S[j] == 'R').count();
                let R = ((i + 1)..n).take_while(|&j| S[j] == 'L').count();
                1 + (L + 1) / 2 + R / 2
            };
            a.to_string()
        }
    )
    .collect::<Vec<_>>()
    .join(" ");

    println!("{}", ans);
}


Measured memory_bytes: 8444
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <cassert>
#include <climits>
#include <string>
#include <bitset>
#include <cfloat>
#include <unordered_set>
#pragma GCC optimize("Ofast")
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef vector<pair<int, int>> vpii;
typedef vector<vector<int>> vvi;
typedef vector<vector<char>> vvc;
typedef vector<vector<string>> vvs;
typedef vector<vector<ll>> vvll;

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, n) for (int i = 1; i <= (n); ++i)
#define irep(it, stl) for (auto it = stl.begin(); it != stl.end(); it++)
#define drep(i, n) for (int i = (n)-1; i >= 0; --i)
#define mes(a) cout << (a) << endl
#define dmes(a, b) cout << (a) << " " << (b) << endl
#define rt0 return 0;
#define mp(p, q) make_pair(p, q)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define Sort(a) sort(a.begin(), a.end())
#define rSort(a) sort(a.rbegin(), a.rend())
#define MATHPI acos(-1)
#define itn int;
int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
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;
}
struct io
{
    io()
    {
        ios::sync_with_stdio(false);
        cin.tie(0);
    }
};
const int INF = INT_MAX;
const ll LLINF = 1LL << 60;
const ll MOD = 1000000007;
const double EPS = 1e-9;

signed main(){
    ll n;
    cin >> n;

    mes(n*n);
    
    
}


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

using namespace std;

typedef long long llong;
typedef unsigned long long ullong;
#define inf 1ll<<60
#define pqueue priority_queue
#define mp make_pair
#define pb push_back
#define fn fill_n
#define int llong
#define be(x) x.begin(), x.end()
typedef pair<int, int> P;


signed main(){
	int n, k, check = 0, ans = 0, many[50] = {}, beki[50] = {};
	vector<int> a;
	for(int i = 0; i < 50; i++){
		if(i)
			beki[i] = beki[i-1] * 2;
		else
			beki[i] = 1;
	}
	cin >> n >> k;
	a.resize(n);
	for(int i = 0; i < n; i++){
		cin >> a[i];
		int cp = a[i];
		int j = 0;
		while(cp){
			many[j] += cp&1;
			cp >>= 1;
			j++;
		}
	}

	for(int i = 49; i >= 0; i--){
		if(many[i] < n - many[i]){
			if(check + beki[i] <= k)
				check += beki[i];
		}
	}

	for(int i = 0; i < n; i++){
		ans += check^a[i];
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
#define LL long long
#define ULL unsigned long long
#define mp make_pair
#define pb push_back
#define pii pair<int,int>
#define pll pair<LL,LL>
#define x first
#define y second
#define pi acos(-1)
#define sqr(x) ((x)*(x))
#define pdd pair<double,double>
#define MEMS(x) memset(x,-1,sizeof(x))
#define MEM(x) memset(x,0,sizeof(x))
#define less Less
#define EPS 1e-4
#define arg ARG
#define cpdd const pdd
#define rank Rank
#define KK 500
#define MXN 200005
vector<int> v[3005];
int degree[3005];
int ans[3005];
int a[3005];
int main(){
    int n;
    scanf("%d",&n);
    for(int i = 1;i<=n;i++){
        scanf("%d",&a[i]);
    }
    for(int i = 1;i<n;i++){
        int x,y;
        scanf("%d %d",&x,&y);
        if(a[x]<a[y]){
            v[x].pb(y);
            degree[y]++;
        }
        if(a[y]<a[x]){
            v[y].pb(x);
            degree[x]++;
        }
    }
    for(int i = 1;i<=n;i++){
        for(int j=1;j<=n;j++){
            a[j]++;
        }
    }
    queue<int> q;
    for(int i = 1;i<=n;i++){
        if(degree[i]==0){
            q.push(i);
        }
    }
    while(!q.empty()){
        int x=q.front();
        q.pop();
        for(auto it:v[x]){
            if(!ans[x]){
                ans[it]=1;
            }
            if(--degree[it]==0)
                q.push(it);
        }
    }
    for(int i = 1;i<=n;i++){
        if(ans[i])printf("%d ",i);
    }
    printf("\n");
}


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

using namespace std;

#define sp(x) cout<<setprecision(x);
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
#define all(a) (a).begin(), (a).end()
#define inf 10000000
#define linf INT64_MAX*0.99
#define print(s) cout<<(s)<<endl
#define lint long long
#define yes "Yes"
#define no "No"

typedef pair<int, int> P;
 
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int a,b,c; cin>>a>>b>>c;
    if(c>a&&c>b) print("No");
    else if(c<a&&c<b) print("No");
    else print("Yes");
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <cmath>
#include <tuple>
#include <cstdio>
#include <bitset>
#include <sstream>
#include <iterator>
#include <numeric>
#include <map>
#include <cstring>
#include <set>
#include <functional>
#include <iomanip>

using namespace std;

#define DEBUG_ //!!提出時にコメントアウト!!
#ifdef DEBUG_
	#define dump(x)  cerr << #x << " = " << (x) << endl;
#else
	#define dump(x)  ;
#endif

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define SZ(x) ((int)(x).size())
#define pb push_back
#define eb emplace_back

//#define int long long

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

template <typename T>
std::string printVector(const std::vector<T> &data)
{
    std::stringstream ss;
    std::ostream_iterator<T> out_it(ss, ", ");
    ss << "[";
    std::copy(data.begin(), data.end() - 1, out_it);
    ss << data.back() << "]";
    return ss.str();
}

const int MOD = 1e9+7;
const LL LINF = 1001002003004005006ll;
const int INF = 1001001001;

signed main(int argc, char const *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    string S; cin >> S;

    REP(i,4){
        cout << S[i];
    }
    cout << " ";
    FOR(i,4,12){
        cout << S[i];
    }
    cout << endl;

}

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

N = int(readline())
S = readline().rstrip()

dp = [[0] * (N + 1) for i in range(N + 1)]

ans = 0
for i in range(N - 1, -1, -1):
  for j in range(N - 1, i, -1):
    if S[i] == S[j]:
      dp[i][j] = dp[i + 1][j + 1] + 1
      if dp[i][j] > j - i:
        dp[i][j] = j - i
      if ans < dp[i][j]:
        ans = dp[i][j]
print(ans)

Measured memory_bytes: 270152
#include <stdio.h>
 
using namespace std;
 
void output(int H[3][10]){
    for(int i = 0; i < 3; i++){
        for(int j = 0; j < 10; j++){
            printf(" %d",H[i][j]);
        }
        printf("\n");
    }
}
 
 
int main(){
    int H1[3][10],H2[3][10],H3[3][10],H4[3][10],n,h_num,f_num,r_num,div_num;
    for(int i = 0; i < 3; i++){
        for(int j = 0; j < 10; j++){
            H1[i][j] = H2[i][j] = H3[i][j] = H4[i][j] = 0;
        }
    }
    scanf("%d",&n);
    for(int i = 0; i < n; i++){
        scanf("%d %d %d %d",&h_num,&f_num,&r_num,&div_num);
        switch(h_num){
        case 1:
            H1[f_num-1][r_num-1] += div_num;
            break;
        case 2:
            H2[f_num-1][r_num-1] += div_num;
            break;
        case 3:
            H3[f_num-1][r_num-1] += div_num;
            break;
        case 4:
            H4[f_num-1][r_num-1] += div_num;
            break;
        }
    }
 
    output(H1);
    printf("####################\n");
    output(H2);
    printf("####################\n");
    output(H3);
    printf("####################\n");
    output(H4);
 
}




Measured memory_bytes: 2728
#include <iostream>
#include <cstdio>
#include <vector>
#include <string>
#include <algorithm>
#include <set>
#include <map>

#define rep(i,n) for(int i=0; i<(n); i++)
#define reps(i,x,n) for(int i=x; i<(n); i++)
#define rrep(i,n) for(int i=(n)-1; i>=0; i--)
#define all(X) (X).begin(),(X).end()
#define X first
#define Y second
#define pb push_back
#define eb emplace_back

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

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 (a>b) { a=b; return 1; } return 0; }

template<class A, size_t N, class T> void Fill(A (&a)[N], const T &v){ fill( (T*)a, (T*)(a+N), v ); }

const ll INF = 0x3fffffff;


int main(){
	//ios_base::sync_with_stdio(0);
	ll x, y, ans=INF;

	cin >> x >> y;

	chmin( ans, ( y>= x) ?  y-x : INF );
	chmin( ans, (-y>= x) ? -y-x + 1 : INF );
	chmin( ans, ( y>=-x) ?  y+x + 1 : INF );
	chmin( ans, (-y>=-x) ? -y+x + 2 : INF );

	cout << ans << endl;

	return 0;
}


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

a = [0] * N

count = 0
for i in range(1, N):
    if S[i-1:i+1] == "AC":
        count += 1
    a[i] = count


for q in range(Q):
    l, r = list(map(int, input().split()))
    print(a[r-1] - a[l-1])


Measured memory_bytes: 6164
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
const ll INF = 100000000;
#define rep1(i, n) for (ll i=0; i<(n); i++) 
#define rep2(i, k, n) for (ll i=k; i<(n); i++)
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; }


int main() {
    ll a;
    cin >> a;
    ll ans = a + a*a + a*a*a; 
    cout << ans << endl;
}

Measured memory_bytes: 3592
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define perl(i,r,l) for(ll i=r-1;i>=l;i--)
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define ins insert
#define pqueue(x) priority_queue<x,vector<x>,greater<x>>
#define all(x) (x).begin(),(x).end()
#define CST(x) cout<<fixed<<setprecision(x)
#define vtpl(x,y,z) vector<tuple<x,y,z>>
#define rev(x) reverse(x);
using ll=long long;
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
using pl=pair<ll,ll>;
using vpl=vector<pl>;
using vvpl=vector<vpl>;
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9+10;
const ll INF=4e18;
const ll dy[8]={1,0,-1,0,1,1,-1,-1};
const ll dx[8]={0,-1,0,1,1,-1,1,-1};
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;
}
int main(){
    ll n,m,v,p;cin >> n >>m >>v >>p;
    vl a(n);rep(i,n)cin >> a[i];sort(all(a));
    ll ok=n-1,ng=-1;
    while(abs(ok-ng)>1){
        ll mid=(ok+ng)/2;
        ll vote=max((ll)0,v-(p-1)-(mid+1));
        ll limit=a[mid]+m;
        if(limit<a[n-p]){
            ng=mid;
            continue;
        }
        ll tmp=0;
        repl(i,mid+1,n+1-p){
            tmp+=limit-a[i];
        }
        //cout << mid <<" "  <<tmp  << " " << vote<<endl;
        if(tmp>=vote*m)ok=mid;
        else ng=mid;
    }
    cout << n-ok <<endl;
}

Measured memory_bytes: 1024
#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#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>

#define int long long
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(a) (a).begin(), (a).end()
#define PB push_back
#define MP make_pair
#define FST first
#define SND second
#define SZ(a) (signed)((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())

using namespace std;

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;

const int MOD = 1000000007;
const char ENDL = '\n';

#define dump(x) cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")"  << " " << __FILE__ << endl;

signed main(void) {
    ios::sync_with_stdio(false);
    cout.setf(ios::fixed, ios::floatfield);
    cout.precision(10);
    cin.tie(0);

    string x;
    cin >> x;

    int s=0,a=0;
    REP(i,x.length()){
        if(x[i]=='S'){
            s++;
        }else{
            if(s>0){
                s--;
                a++;

            }
        }
    }

    cout << x.length()-2*a << ENDL;

    
    return 0;
}

Measured memory_bytes: 848
#include <stdio.h>
#include <iostream>
using namespace std;

int A,B,X;
int main (){
	cin >> A >> B >> X;
	if ((A+B)<X){
		cout << "NO";
	}else if (A>X){
		cout << "NO";
	}else{
		cout << "YES";
	}
}

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

using namespace std;

const int N = 2e5 + 5;

int a[N];

int main() {
  int n;
  scanf("%d", &n);
  long long ans = 0;
  int now = 0;
  for (int i = 0, j = 0; i < n; ++i) {
    scanf("%d", a+i);
    while (j < i && (now & a[i]) > 0) {
      now ^= a[j++];
    }
    now ^= a[i];
    ans += i-j+1;
  }
  printf("%lld\n", ans);
  return 0;
}

Measured memory_bytes: 1024
#pragma GCC optimize ("O3")

#include <bits/stdc++.h>

using namespace std;

#ifdef LOCAL
#include <prettyprint.hpp>
#define debug(...)  cerr << "[" << #__VA_ARGS__ << "]: ", d_err(__VA_ARGS__);
#else
#define debug(...) 83;
#endif

void d_err() {
    cerr << endl;
}

template <typename H, typename... T>
void d_err(H h, T... t) {
    cerr << h << " ";
    d_err(t...);
}

#define ALL(x) (x).begin(), (x).end()
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define REP(i, n) FOR(i, 0, n)
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define bcnt __builtin_popcountll

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<ll,ll> Pll;
typedef pair<int,int> Pin;

ll INF = 1e16;
int inf = 1e9;
ll MOD = 1e9+7;

ll ans = 0;
vector<ll> a(55), b(55), c(55), d(55);

int N, M, Q;

void rec(vector<int> &cur) {
    if (cur.size() == N) {
        ll tmp = 0;
        REP(i, Q) {
            if (cur[b[i]] - cur[a[i]] == c[i]) tmp += d[i];
        }

        ans = max(ans, tmp);
    } else {
        int st = 1;
        if (!cur.empty()) st = cur.back();
        for (int i = st; i <= M; ++i) {
            cur.pb(i);
            rec(cur);
            cur.pop_back();
        }
    }
}

int main(){
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(20);

    cin >> N >> M >> Q;

    REP(i, Q) {
        cin >> a[i] >> b[i] >> c[i] >> d[i];
        a[i]--; b[i]--;
    }

    vector<int> v;
    rec(v);

    cout << ans << endl;

    
}


Measured memory_bytes: 3664
#include <string.h>
#include <stdio.h>

int main(void) 
{
	int i ;
	int counter=0;	
	char eitango[100]={0}; 
	char shouryaku[5]={0};

	scanf("%s",eitango);

	counter = strlen(eitango);

	
	sprintf (shouryaku,"%c%d%c",eitango[0],counter-2,eitango[counter-1]);
	printf ("%s\n",shouryaku);



	return 0;
}


Measured memory_bytes: 128
#include <iostream>

using namespace std;

int main(){
  int N,M,re = 0;
  int *former,**latter;
  //1次元配列の取得
  cin >> N;
  former = new int[N];
  for (int i = 0 ; i < N ; i++) {
    cin >> former[i];
    re += former[i]; //normalの総時間  
  }
  //二次元配列の取得
  cin >> M;
  latter = new int*[M];
  for (int i = 0 ; i < M ; i++) {
  latter[i] = new int[2] ;
  cin >> latter[i][1] >> latter[i][2] ;
  cout << re - former[latter[i][1] - 1] + latter[i][2] << endl;
  }
  return 0;
}


Measured memory_bytes: 3144
#include <iostream>
#include <list>
#include<vector>
#include <utility>
using namespace std;

#define A

#ifdef A
void fucPri(list<int> &ori) {
	list<int>::iterator iend = ori.end();
	list<int>::iterator i = ori.begin();
	cout << *i++;
	for (; i != iend; ++i)
	{
		cout << " "<< *i;
	}
	cout << endl;
}
int main(void)
{
	int n;
	cin >> n;
	list<int> ori(n);
	for (auto &a : ori)
	{
		cin >> a;
	}
	for (size_t i = 0; i < n; i++)
	{
		list<int>::iterator it = ori.begin();
		advance(it, i);
		int v = *(it);
		ori.erase(it);
		it = ori.begin();
		for (size_t j = 0; j < i; ++j,advance(it, 1))
		{
			if (*it > v)
				break;
		}

		ori.insert(it, v);
		fucPri(ori);

	}
	

	return 0;
}
#endif // A

Measured memory_bytes: 3080
using System;
namespace DynammicProgramming {
	class Frog2 {
    	public static void Main(String[] args) {
          string[] input1 = Console.ReadLine().Split(' ');
          int N = Int32.Parse(input1[0]);
          int K = Math.Min(Int32.Parse(input1[1]), N-1);
          int[] stones = new int[N];
          int[] dp = new int[N];
          string[] input2 = Console.ReadLine().Split(' ');
          for(int i = 0; i < stones.Length; i++) {
            stones[i] = Int32.Parse(input2[i]);
          }
          dp[0] = 0;
          dp[1] = Math.Abs(stones[0]-stones[1]);
          // Init K spaces
          for(int i = 2; i < K; i++) {
            int min = Int32.MaxValue;
            for(int j = i-1; j >= 0; j--) {
              int cost = Math.Abs(stones[j]-stones[i])+dp[j];
              min = Math.Min(min, cost);
            }
            dp[i] = min;
          }
          for(int i = K; i < N; i++) {
            int min = Int32.MaxValue;
            for(int j = 1; j <= K; j++) {
              int cost = Math.Abs(stones[i-j]-stones[i])+dp[i-j];
              min = Math.Min(min, cost);
            }
            dp[i] = min;
          }
          Console.WriteLine(dp[N-1]);
        }
    }
}

Measured memory_bytes: 18912
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n,a[102]={0},A=0,B=0;
	cin>>n;
	for(int i=0;i<n;i++)
	{
		cin>>a[i];
	}
	sort(a,a+n);
	if(n%2==0)
	{
		for(int i=0;i<n;i++)
		{
			if(i%2==0)	B+=a[i];
			else
				A+=a[i];
		}
	}
	else
	{
		for(int i=0;i<n;i++)
		{
			if(i%2==0)	A+=a[i];
			else	B+=a[i]; 
		}
	}
	if(A>=B)
	{
		cout<<A-B<<endl;
	}
	else
	{
		cout<<B-A<<endl;
	}
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(int argc, char** argv) {
    int S, h, m = 0;
    
    cin >> S;
    
    m = S/60;
    S %= 60;
    h = m/60;
    m %= 60;
    
    cout << h << ":" << m << ":" << S <<endl;
    
    return 0;
}

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

#define ll long long

using namespace std;

int main(void) {
	while (true) {
		ll n;
		cin >> n;
		if (n == 0)break;
		vector<ll> s(n);
		for (int i = 0; i < n; i++) {
			cin >> s[i];
		}
		sort(s.begin(), s.end());
		ll ans = 0;
		for (int i = 1; i < n - 1; i++) {
			ans += s[i];
		}
		ans /= (n - 2);
		cout << ans << endl;
	}
	return 0;
}


Measured memory_bytes: 3008
from collections import Counter
n = int(input())
V = list(map(int,input().split()))
V_odd = []
V_even = []
for i in range(n):
    if i % 2 == 0:
        V_odd += [V[i]]
    else:
        V_even += [V[i]]
V_odd = list(Counter(V_odd).most_common()) + [(-1,0)]
V_even = list(Counter(V_even).most_common()) + [(-2,0)]
if V_odd[0][0] != V_even[0][0]:
    print(len(V)-V_odd[0][1]-V_even[0][1])
elif V_odd[1][1] >= V_even[1][1]:
    print(len(V)-V_odd[1][1]-V_even[0][1])
else:
    print(len(V)-V_odd[0][1]-V_even[1][1])

Measured memory_bytes: 21084
def segfunc(x, y): return max(x, y)

class SegmentTree:
    def __init__(self, arr):
        size = len(arr)
        n = 2 ** (size - 1).bit_length()
        self.n = n
        self.node = [0] * (2*n)
        for i in range(size):
            self.node[i+n-1] = arr[i]
        for i in reversed(range(n-2)):
            self.node[i] = segfunc(self.node[2*i+1], self.node[2*i+2])

    def update(self, i, x):
        i += self.n - 1
        self.node[i] = x
        while i > 0:
            i = (i - 1) // 2
            self.node[i] = segfunc(self.node[i * 2 + 1], self.node[i * 2 + 2])

    def update(self, x, val):
        x += (self.n - 1)
        self.node[x] = val
        while x > 0:
            x = (x - 1) // 2
            self.node[x] = segfunc(self.node[2 * x + 1], self.node[2 * x + 2])

    def query(self, a, b):
        res = 0
        l = self.n - 1 + a
        r = self.n - 1 + (b - 1)

        while l <= r:
            if l == r:
                res = segfunc(res, self.node[l])
                break

            if l % 2 == 0:
                res = segfunc(res, self.node[l])
            if r % 2 == 1:
                res = segfunc(res, self.node[r])
            l = l // 2
            r = r // 2 - 1

        return res

N, K = map(int, input().split())
INF = 0
seg = SegmentTree([0] * 300005)
for i in range(N):
    a = int(input())
    tmp = seg.query(max(a - K, 0), min(a + K, 300000) + 1) + 1
    seg.update(a, tmp)
print(seg.query(0, 300005))


Measured memory_bytes: 120000
N,M,C = map(int,input().split())
B = list(map(int,input().split()))
A = [list(map(int,input().split())) for i in range(N)]

ans = 0
for row in A:
    t = C
    for a,b in zip(row,B):
        t += a*b
    if t > 0:
        ans += 1
print(ans)


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
using ll=long long;
ll mo=7+1e9;
main(){
ll n,m; cin>>n>>m;
ll a[n],b[m]; rep(i,n) cin>>a[i];rep(j,m)cin>>b[j];
vector<vector<ll>>s(1e4,vector<ll>(1e4,1));
rep(i,n)rep(j,m)s[i+1][j+1]=(s[i+1][j]+mo+s[i][j+1]+(a[i]==b[j]?0:-s[i][j]))%mo;
cout<<s[n][m];
}

Measured memory_bytes: 784000
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cassert>
#include <string>
#include <cstring>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <algorithm>

using namespace std;

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

// debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

// ---------------------
#define INF 922337203685477580
#define IINF (1<<21)
typedef long long ll;

ll power(ll x, ll y) {  // return x^y
  if (y == 0) return 1;
  if (y == 1) return x;

  return (power(x * x % 1000000007, y / 2) % 1000000007) * (power(x, y % 2) % 1000000007);
}

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

  cout << power(m, n) % 1000000007 << endl;
  return 0;
}

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

int main() {
	int i, j, k, n, x, sum;
	while (1) {
		cin >> n >> x;
		if (n == 0 && x == 0)break;
		sum = 0;
		for (i = 1; i < n; i++) {
			for (j = i + 1; j < n; j++) {
				for (k = j + 1; k <= n; k++) {
					if (i + j + k == x)sum++;
				}
			}
		}
		cout << sum << endl;
	}



	return 0;
}

Measured memory_bytes: 3092
import bisect, collections, copy, heapq, itertools, math, string, sys
input = lambda: sys.stdin.readline().rstrip() 
sys.setrecursionlimit(10**7)
INF = float('inf')
def I(): return int(input())
def F(): return float(input())
def SS(): return input()
def LI(): return [int(x) for x in input().split()]
def LI_(): return [int(x)-1 for x in input().split()]
def LF(): return [float(x) for x in input().split()]
def LSS(): return input().split()

def resolve():
    N, M = LI()
    A = [SS() for _ in range(N)]
    B = [SS() for _ in range(M)]

    is_ok = False
    for i, j in itertools.product(range(N - M + 1), repeat=2):
        tmp = True
        for k in range(M):
            if B[k] != A[i+k][j:j+M]:
                tmp = False
                break
        if tmp:
            is_ok = True
            break

    if is_ok:
        print('Yes')
    else:
        print('No')

if __name__ == '__main__':
    resolve()


Measured memory_bytes: 10068
#include<iostream>
using namespace std;
using lint = long long int;

int main(){
  lint A,B,C,K;
  cin>>A>>B>>C>>K;
  lint ans=A-B;
  if(abs(A-B)>1000000000000000000) cout<<"Unfair"<<endl;
  else {
    if(K%2==1) ans*=-1;
    cout<<ans<<endl;
  }
  return 0;
}
    

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<string>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
using namespace std;
typedef long long ll;
const ll MOD = 1000000007;
const ll INF = (ll)1000000007 * 1000000007;
const double EPS = 1e-9;
typedef pair<int, int> P;
typedef unsigned int ui;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef long double ld;
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
struct edge { int to, cost; };
int V;
vector<edge> G[100000];
int d[100000];
void dijkstra(int s) {
	priority_queue<P, vector<P>, greater<P>>que;
	fill(d, d + V, (int)MOD);
	d[s] = 0;
	que.push(P(0, s));
	while (!que.empty()) {
		P p = que.top(); que.pop();
		int v = p.second;
		if (d[v] < p.first)continue;
		for (int i = 0; i < (int)G[v].size(); i++) {
			edge e = G[v][i];
			if (d[e.to] > d[v] + e.cost) {
				d[e.to] = d[v] + e.cost;
				que.push(P(d[e.to], e.to));
			}
		}
	}
}
int main() {
	int n, m, k; cin >> n >> m >> k; V = (1 << m);
	int light[100] = {}; int dark[16];
	rep(i, m) {
		int x; cin >> x; x--; light[x] = i + 1; dark[i] = x;
	}
	int trans[100][100];
	rep(i, n) {
		rep(j, k) {
			cin >> trans[i][j]; trans[i][j]--;
		}
	}
	rep(i, (1 << m)-1) {
		map<int, int> used;
		rep(j, k) {
			int nex = (1<<m)-1;
			rep(l, m) {
				if (i&(1 << l))continue;
				if (light[trans[dark[l]][j]] > 0) {
					if ((nex >> light[trans[dark[l]][j]] - 1) & 1) {
						nex = nex ^ (1 << (light[trans[dark[l]][j]] - 1));
					}
				}
			}
			if (used[nex] != 1&&i!=nex) {
				used[nex] = 1;
				G[i].push_back({ nex, 1 });
			}
		}
	}
	dijkstra(0);
	cout << d[(1 << m)-1] << endl;
	return 0;
}


Measured memory_bytes: 72656
#!/usr/bin/python3
# -*- coding: utf-8 -*-
def gcd(a,b):
    if b == 0:
        return a
    else:
        return gcd(b,a%b)

n = int(input())
a_list = list(map(int, input().split()))
a_list.sort()
ans2 = a_list[0]
for i in range(1, n):
    ans2 = gcd(ans2, a_list[i])
    if ans2 == 1:
        break

if ans2 != 1:
    print("not coprime")
else:
    flag = 1
    max_a = a_list[n - 1] + 1
    num_flag_list = [True] * max_a
    d_list = list(range(0, max_a))
    d_list[0] = 1
    num_flag_list[0] = num_flag_list[1] = False
    for i in range(2, int(max_a**0.5) + 1):
        if num_flag_list[i]:
            for j in range(i**2, max_a, i):
                if num_flag_list[j] == True:
                    num_flag_list[j] = False
                    d_list[j] = i
    p_set = set()
    for a in a_list:
        if a == 1:
            continue
        temp_p_set = set()
        while True:
            p = d_list[a]
            if p not in temp_p_set:
                if p in p_set:
                    flag = 0
                    break
            temp_p_set.add(p)
            p_set.add(p)
            a = a // p
            if a == 1:
                break
        if flag == 0:
            break
        
    if flag == 1:
        print("pairwise coprime")
    else:
        print("setwise coprime")

Measured memory_bytes: 126500
import sys
 
stdin = sys.stdin

mod = 1000000007
inf = 1 << 60
 
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
nan = lambda x: [na() for _ in range(x)]
ns = lambda: stdin.readline().rstrip()
nas = lambda: stdin.readline().split()

n, k = na()
l = na()

l.sort()
l.reverse()
ans = 0
for i in range(k):
    ans += l[i]

print(ans)

Measured memory_bytes: 3064
def C():
    kn=list(map(int,input().split()))
    A=list(map(int,input().split()))
    d=[]
    sum_ans=[]
   
    for i in range(kn[1]):
        
        if i==kn[1]-1:
            d.append(kn[0]-A[i])
        else:
            d.append(A[i+1]-A[i])
        
        
    sum_ans.append(A[kn[1]-1]-A[0])
    for i in range(1,kn[1]):
        sum_ans.append(min(kn[0]-d[i],kn[0]-d[i-1]))
    
    print(min(sum_ans))    
        
    
if __name__=='__main__':
    C()

Measured memory_bytes: 26444
#include <iostream>

using namespace std;

int main()
{
    int k, x;
    cin >> k >> x;
    bool isFirst = true;
    for (int y = x - k + 1; y < x + k; y++)
    {
        if (!isFirst)
        {
            cout << " ";
        }
        if (y >= -1000000 && y <= 1000000)
        {
            cout << y;
            isFirst = false;
        }
    }
    cout << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep1(i,n) for(ll i=1;i<=n;i++)
#define repk(i,m,n) for(int i=m;i<n;i++)
#define OKawaiiKoto ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define F first
#define S second
#define pb push_back
#define mp make_pair
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
using namespace std;
const int MOD1=1e9+7;
const int MOD2=998244353;
const ll INF=2*1e18;
const ld PI=3.14159265358979323846;
int main()
{
    //freopen("running_on_fumes_chapter_1_input.txt","r",stdin);
    //freopen("sol.txt","w",stdout);
    OKawaiiKoto
    ll a,b,c,k;
    cin>>a>>b>>c>>k;
    while(a>=b)
    {
        b*=2;
        k--;
    }
    while(b>=c)
    {
        c*=2;
        k--;
    }
    if(k>=0) cout<<"Yes";
    else cout<<"No";
}


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

using namespace std;

int main(void) {
    string s;
    cin >> s;
    cin >> s;

    char c = 0;
    long r = 0;
    for(int i=0; i<s.size(); i++)
        r += c!=s[i], c=s[i];
    cout << r << endl;
}


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

#define REP(i, e) for(int (i) = 0; (i) < (e); ++(i))
#define FOR(i, b, e) for(int (i) = (b); (i) < (e); ++(i))
#define ALL(c) (c).begin(), (c).end()
#define ACC(c) (accumulate(ALL(c), 0LL))
#define PRINT(x) cout << (x) << "\n"

using namespace std;
using ll = long long;
using pint = pair<int, int>;
using pll = pair<ll, ll>;

inline int in(int& a) {return scanf("%d", &a);}
auto pint_compare = [](pint x, pint y) -> bool{return (x.first < y.first);};


int N, K;
vector<int> d;

void getdiv(int n){
    for(int i = 1; i * i <= n; i++){
        if(n % i == 0){
            d.push_back(i);
            if(i * i != n) d.push_back(n / i);
        }
    }
    sort(ALL(d), greater<int>());
}

signed main(){
    cin >> N >> K;
    vector<int> A(N);
    REP(i, N) cin >> A[i];
    sort(ALL(A));
    getdiv(ACC(A));
    vector<int> mod(N);
    for(auto m : d){
        REP(i, N) mod[i] = A[i] % m;
        sort(ALL(mod));
        int left = 0, right = 0;
        REP(i, N) right += m - mod[i];
        REP(i, N){
            left += mod[i]; right -= m - mod[i];
            if(left == right && left <= K){
                PRINT(m);
                return 0;
            }
        }
    }
    PRINT("1");
    return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
class Program
{
	static void Main(string[] args)
	{
		long N = long.Parse(Console.ReadLine());
		while(true){
			if(N % 111 == 0){
				break;
			} else {
				N += 1;
			}
		}
		Console.WriteLine(N);
	}
}

Measured memory_bytes: 11092