akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
 
#define int long long
#define pb push_back
#define ub upper_bound
#define lb upper_bound
#define mp make_pair
#define F first
#define S second
#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 RALL(a) (a).rbegin(),(a).rend()
#define SORT(c) sort((c).begin(),(c).end())
#define ve vector
#define vi vector<int>
#define vp vector<pair<int,int>>
#define vvi vector<vector<int>>
 
using ll = long long;
const ll INF = LLONG_MAX - 100;
ll mod = 1e9 + 7;
int dx[] = {-1,0,1,0}, dy[] = {0,1,0,-1};
vector<ll> prime;

class fact {
public:
	int fmod = 1e9+7;
	vector<int> fac, inv;
	fact (int n, int Mod = 1e9+7) {
		fmod = Mod;
		fac = vector<int>(n,0);
		inv = vector<int>(n,0);
		fac[0] = 1; for (int i = 1; i < n; i++) fac[i] = fac[i-1] * i % fmod;
		for (int i = 0;i < n;i++) inv[i] = fact::POW(fac[i],fmod-2);
	}
	ll nCr(ll n, ll r) {return (fac[n] * inv[r] % fmod) * inv[n-r] % fmod;}
	ll POW(ll a, ll b) {ll c = 1; while (b > 0) {if (b & 1) {c = a * c%fmod;}a = a * a%fmod; b >>= 1;}return c;}
};
 
template <class T = ll> T in() {T x; cin >> x; return (x);}
void DEBUG(vector<int> a) {for(int i=0;i<a.size();i++)cout<<a[i]<<" ";cout<<endl;}
void EMP(int x) {cout<<"!!!"<<x<<"!!!"<<endl;}
ll GCD(ll a, ll b) {ll c; while (b != 0) {c = a % b; a = b; b = c;}return a;}
ll LCM(ll a, ll b) {return a * b / GCD(a, b);}
ll POW(ll a, ll b) {ll c = 1; while (b > 0) {if (b & 1) {c = a * c%mod;}a = a * a%mod; b >>= 1;}return c;}
void PRI(ll n) {bool a[n + 1LL]; for (int i = 0; i < n + 1LL; i++) {a[i] = 1LL;}for (int i = 2; i < n + 1LL; i++) {if (a[i]) {prime.pb(i); ll b = i; while (b <= n) {a[b] = 0; b += i;}}}}
template <typename T> T chmin(T& a, T b) {if(a>b)a=b;return a;}
template <typename T> T chmax(T& a, T b) {if(a<b)a=b;return b;}
bool isSqrt(ll a) {return pow(sqrt(a),2) == a ? 1 : 0;}
void YesNo(bool a) {if (a) cout << "Yes"; else cout << "No"; cout << endl;}
void yesno(bool a) {if (a) cout << "yes"; else cout << "no"; cout << endl;}
void YESNO(bool a) {if (a) cout << "YES"; else cout << "NO"; cout << endl;}

bool solve() {
    char ch[3]; REP (i,3) cin >> ch[i];
    sort(ch,ch+3);
    if (ch[0] == 'a' && ch[1] == 'b' && ch[2] == 'c') {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}

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


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define _ ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define int long long
#define pb push_back
#define sz(i) (int)(i.size())
#define F first
#define S second
#define L long double
#define P pair<int, int>
const int inf = 0x3f3f3f3f3f3f3f3LL;
const int mod = (int)1e9 + 7;
using namespace std;
#if LOCAL
#include "../../tr.h"
#else
#define tr(...)
#define endl '\n'
#endif
template<class T> void smin(T& a, T val) {if (a > val) a = val;}template<class T> void smax(T& a, T val) {if (a < val) a = val;}
const int N = (int)1e5 + 10;


#define ll int
ll power(ll a, ll b, ll m = mod){if(b < 0)b += m-1; ll r = 1; while(b){if(b&1)r=(r*a)%m; a = (a*a)%m; b>>=1;}return r;}

int fact[N+10], ifact[N+10];
void pre(int N){
   fact[0] = 1;
   for (int i = 1; i <= N; ++i)
   {
      fact[i] = (i*fact[i-1])%mod;
   }
   ifact[N] = power(fact[N], -1);
   for (int i = N-1; i >= 0; --i)
   {
      ifact[i] = ((i+1)*ifact[i+1])%mod;
   }
}

int nCr(int n, int r){
   if(n < r)return 0;
   return ((fact[n]*ifact[r])%mod * ifact[n-r])%mod;
}

int nPr(int n, int r){
   if(n < r)return 0;
   return (nCr(n, r) * fact[r]) % mod;   
}

int deg[N], ans = 1;
int n, k;
vector<int> v[N];

void dfs(int s, int p){
   int cnt = 0;
   for(auto i: v[s]){
      if(i != p){
         dfs(i, s);
         cnt++;
      }
   }

   if(s == 1){
      ans = (ans * (k * nPr(k-1, cnt)%mod) % mod);
   }
   else{
      ans = (ans * nPr(k-2, cnt)) % mod;
   }
}

int32_t main(){_

   cin>>n>>k;   
   pre(N);

   for (int i = 0; i < n-1; ++i)
   {
      int x, y;
      cin>>x>>y;
      v[x].pb(y);
      v[y].pb(x);
   }

   dfs(1, -1);
   cout<<ans;

   return 0;
}

Measured memory_bytes: 11648
#include<iostream>

using namespace std;

int main()
{
	int x, y;
	cin >> x >> y;
	if (x == 1)
		x = 1;
	else if (x == 3)
		x = 1;
	else if (x == 5)
		x = 1;
	else if (x == 7)
		x = 1;
	else if (x == 8)
		x = 1;
	else if (x == 10)
		x = 1;
	else if (x == 12)
		x = 1;
	else if (x == 4)
		x = 2;
	else if (x == 6)
		x = 2;
	else if (x == 9)
		x = 2;
	else if (x == 11)
		x = 2;
	else if (x == 2)
		x = 3;

	if (y == 1)
		y = 1;
	else if (y== 3)
		y = 1;
	else if (y == 5)
		y = 1;
	else if (y == 7)
		y = 1;
	else if (y == 8)
		y = 1;
	else if (y == 10)
		y = 1;
	else if (y == 12)
		y = 1;
	else if (y == 4)
		y = 2;
	else if (y == 6)
		y = 2;
	else if (y == 9)
		y = 2;
	else if (y == 11)
		y = 2;
	else if (y == 2)
		y = 3;

	if (x == y)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;

	return 0;
}

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

using namespace std;
const int N = 20010;
const int M = 45000;
int _w;

int n, a[N], b[N], p[N];

int main() {
	cin >> n;
	for( int i = 1; i <= n; ++i )
		cin >> p[i];
	a[1] = 1;
	for( int i = 2; i <= n; ++i )
		a[i] = a[i-1] + M;
	for( int i = 1; i <= n; ++i )
		b[i] = a[n-i+1];
	for( int i = 1; i <= n; ++i )
		a[p[i]] += i;
	for( int i = 1; i <= n; ++i )
		cout << a[i] << " ";
	cout << endl;
	for( int i = 1; i <= n; ++i )
		cout << b[i] << " ";
	cout << endl;
	return 0;
}


Measured memory_bytes: 896
#include <bits/stdc++.h>
using namespace std;
#define endl '\n' 
#define IO ios::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define lowbit(x) ((x)&(-x))
typedef long long ll;
typedef double db;
typedef pair<int,int> PII;
const int N = 1e5 + 10;
const int mod = 1e9 + 7;
const int INF = 0x3f3f3f3f;
const db EXP = 1e-9;
int main() {
    IO;
    int a,b,c;
    cin >> a >> b >> c;
    cout << c << ' ' << a <<' ' << b << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
 
string s;
typedef pair<int,string> P;
 
bool is_palindrome(const string &str){
    int size = str.size();
    for(int i = 0 ; i < size/2 ; i++){
	if(str[i] != str[size-i-1]) return false;
    }
    return true;
}
 
bool check(string a,string b){
    int alen = a.size(),blen = b.size();
    if(alen % 2 && blen % 2 == 0) return true;
    if(alen % 2 == 0 && blen % 2) return true;
    if(alen == blen) return true;
    if(alen > blen) swap(a,b),swap(alen,blen);
    int p = 0;
    while(true){
	if(p*2+alen == blen) break;
	p++;
    }
    for(int i = p ; i < p+alen ; i++){
	if(a[i-p] != b[i]) return true;
    }
    return false;
}
 
int main(){
    string in;
    while(getline(cin,in)){
	int size;
	set<P> st;
	set<string> ans;
	s.clear();
     
	for(int i = 0 ; i < (int)in.size() ; i++){
	    if(isalpha(in[i])){
		s += toupper(in[i]);
	    }
	}
	size = s.size();
	for(int i = 0 ; i < size ; i++){
	    for(int j = size ; j > i ; j--){
		string str = s.substr(i,j-i);
		if(is_palindrome(str) && j-i >= 3){
		    st.insert(P(str.size(),str));
		}
	    }
	}
	bool ok[1145] = {false};
	int ii,jj;
	set<P>::iterator i,j;
	for(ii = 0,i = st.begin() ; i != st.end() ; ++i,++ii){
	    for(jj = 0,j = st.begin() ; j != st.end() ; ++j,++jj){
		if(i == j) continue;
		if(!check(i->second,j->second)){
		    if(i->first > j->first){
			ok[jj] = true;
		    }else{
			ok[ii] = true;
		    }
		}
	    }
	}
	for(ii = 0,i = st.begin() ; i != st.end() ; ++i,++ii){
	    if(ok[ii]) continue;
	    ans.insert(i->second);
	}
	bool flg = false;
	set<string>::iterator k;
	for(k = ans.begin() ; k != ans.end() ; ++k){
	    if(flg) cout << " ";
	    flg = true;
	    cout << *k;
	}
	cout << endl;
    }
    return 0;
}

Measured memory_bytes: 3212
#include <bits/stdc++.h>
using namespace std;
#define iinf 2000000000
#define linf 1000000000000000000LL
#define ulinf 10000000000000000000ull
#define MOD1 1000000007LL
#define mpr make_pair
typedef long long LL;
typedef unsigned long long ULL;
typedef unsigned long UL;
typedef unsigned short US;
typedef pair < int , int > pii;
clock_t __stt;
inline void TStart(){__stt=clock();}
inline void TReport(){printf("\nTaken Time : %.3lf sec\n",(double)(clock()-__stt)/CLOCKS_PER_SEC);}
template < typename T > T MIN(T a,T b){return a<b?a:b;}
template < typename T > T MAX(T a,T b){return a>b?a:b;}
template < typename T > T ABS(T a){return a>0?a:(-a);}
template < typename T > void UMIN(T &a,T b){if(b<a) a=b;}
template < typename T > void UMAX(T &a,T b){if(b>a) a=b;}
int n,a[200005];
bool check(int val){
	int i,prevR=-1,prevV=-1;
	//printf("check %")
	for(i=0;i<n*2-1;++i){
		if((a[i]>=val)!=(a[i+1]>=val) || i==n*2-2){
			
			if(!i || (a[i]>=val)!=(a[i-1]>=val)) continue;
			int L,R=i,nL,cur=(a[i]>=val);
			for(L=i;L && (a[L-1]>=val)==cur;--L);
			nL=L-n+1;
			
			if(prevR+n-1<nL){
				if(n-1<=prevR+n-1) return prevV;
				if(n-1>prevR+n-1 && n-1<nL) return (cur+nL-n+1)%2;
				if(n-1>=nL && n-1<=R) return cur;
			}
			else if(prevV==cur){
				if(n-1<=R) return cur;
			}
			else{
				int M=(prevR+L)/2;
				if(n-1<=M) return prevV;
				if(n-1>M && n-1<=R) return cur;
			}
			prevR=R;
			prevV=cur;
		}
	}
	return a[0]>=val;
}
int main(){
    // inputting start
    // 数据结构记得初始化！ n，m别写反！
	int i,j,k;
	scanf("%d",&n);
	for(i=0;i<n*2-1;++i) scanf("%d",a+i);
    #ifdef LOCAL
        TStart();
    #endif
    // calculation start
    // 数据结构记得初始化！ n，m别写反！
    int low=1,high=n*2-1,mid;
	while(low<high){
		mid=((low+high+1)>>1);
		if(check(mid))
			low=mid;
		else
			high=mid-1;
	}
	printf("%d\n",low);
    #ifdef LOCAL
        TReport();
    #endif
    return 0;
}

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

int n, a[105], d[80]={0,1};
int main() {
	int i, j, k;
	cin>>n;
	for(i=2; i<=n; i++) for(j=2, k=i; k>1; ) {
		if(k%j==0) a[j]++, k/=j;
		else j++;
	}
	for(i=2; i<=n; i++) for(j=75; j; j--) for(k=a[i]; k; k--) {
		if(j*(k+1) <= 75) d[j*(k+1)] += d[j];
	}
	cout<<d[75];
	return 0;
}

Measured memory_bytes: 384
let () =
  Scanf.scanf "%d %d %d" @@ fun n d x ->
  let a = Array.init n @@ fun _ -> Scanf.scanf " %d" (fun x -> x) in
  Array.map (fun e -> (d+e-1) / e) a
  |> Array.fold_left (+) x |> Printf.printf "%d\n"

Measured memory_bytes: 2432
#include<stdio.h>
int main(void)
{
	int x;
	scanf("%d\n",&x);
	if(x==4||x==11||x==18||x==25){
		printf("mon\n");
	}
	else if(x==5||x==12||x==19||x==26){
		printf("tue\n");
	}
	else if(x==6||x==13||x==20||x==27){
		printf("wed\n");
	}
	else if(x==7||x==14||x==21||x==28){
		printf("thu\n");
	}
	else if(x==1||x==8||x==15||x==22||x==29){
		printf("fri\n");
	}
	else if(x==2||x==9||x==16||x==23||x==30){
		printf("sat\n");
	}
	else{
		printf("sun\n");
	}
return 0;
}

	
	


Measured memory_bytes: 2620
/**
 * @author      : Luis Miguel Baez <es.luismiguelbaez@gmail.com>
 * @created     : August 22, 2020
 */

#include <bits/stdc++.h>

using namespace std;

#define endl '\n'
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define ms(arr, value) memset(arr, value, sizeof(arr))
#define finally(value) {cout << value << '\n'; return;}
#define ll    int64_t

const int oo = int(1e9);
const ll lloo  = (ll)(1e18);
const int MAXN = int(1e5) + 10;

class Task {
public:
    int n, k;
    vector<int> A;

    bool dp[MAXN][3];

    int minimum = oo;

    bool go(int K, bool player) {
        if(K < minimum) return false;
        if(dp[K][int(player)]) return dp[K][int(player)];
        bool &ans = dp[K][int(player)];
        ans = false;
        for(int i = 1; i <= n; ++i){
            if(K < A[i]) continue;
            ans = !go(K-A[i], !player);
            if(ans) break;
        }
        return ans;
    }

    void solveOne(istream &in, ostream &out) {
        in >> n >> k;
        A.resize(n+1);
        for(int i = 1; i <= n; ++i){
            in >> A[i];
            minimum = min(minimum, A[i]);
        }
        ms(dp, false);
        bool ans = go(k, true);
        finally( (ans?"First":"Second") );
    }
    
    void solve(istream &in, ostream &out) {
        int t=1;
        while(t--) solveOne(in, out);
    }
};

auto main() -> int {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    
    Task solver;
    istream &in(cin);
    ostream &out(cout);
    solver.solve(in, out);
    return 0;
}


Measured memory_bytes: 11736
/**
 *	author: abhiy13
 *	created: 07.01.2019 12:16:03
**/
#include <bits/stdc++.h>

using namespace std;

const long long inf = (long long)(1e15);

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int N, K;
  cin >> N >> K;
  vector<int> ar(N);
  for(int &x : ar) {
    cin >> x;
  }
  vector<long long> dp(N, inf);
  dp[0] = 0;
  for(int i = 0; i < N; ++i) {
    for(int j = 1; j <= K; ++j) {
      if(i - j >= 0) {
        dp[i] = min(dp[i], dp[i - j] + abs(ar[i - j] - ar[i]));
      }
    }
  }
  cout << dp[N - 1] << '\n';
  return 0;
}

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

int main(void){
    int n,ans=0;
    cin>>n;
    vector<int> skewer;
    skewer.resize(n*2);
    for(int i=0;i<n*2;i++){
        cin>>skewer[i];
    }
    sort(skewer.begin(),skewer.end());
    for(int i=0;i<n*2;i+=2){
        ans+=skewer[i];
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
import sys
from collections import deque
sys.setrecursionlimit(10 ** 7)

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

# 2部グラフ
# 二部グラフ

N = int(readline())

E = [[] for _ in range(N+1)]
for _ in range(N-1):
    a, b = map(int, readline().split())
    E[a].append(b)
    E[b].append(a)

DIST = [-1] * (N+1)
STACK = [1]
DIST[1] = 0

'''
距離を求めて、2で割る
木ならこれでOK

while STACK:
    v = STACK.pop()

    for w in E[v]:
        if DIST[w] == -1:
            DIST[w] = DIST[v] + 1
            STACK.append(w)
'''

COLOR = [None] * (N + 1)


def setColor(v, c):
    COLOR[v] = c
    for w in E[v]:
        if COLOR[w] == None:
            setColor(w, -c)


setColor(1, 1)

EVEN = [i for i, x in enumerate(COLOR) if x == 1 and i > 0]
ODD = [i for i, x in enumerate(COLOR) if x == -1 and i > 0]

listN = list(range(1, N + 1))
mod1 = deque(listN[0::3])
mod2 = deque(listN[1::3])
mod0 = deque(listN[2::3])

ANS = [-1] * (N+1)


def assign(target, arr1, arr2=[], arr3=[]):
    source = [arr1, arr2, arr3]
    idx = 0
    for e in target:
        if len(source[idx]) == 0:
            idx += 1

        ANS[e] = source[idx].pop()
    return 0


if len(EVEN) <= len(mod0):
    assign(EVEN, mod0)
    assign(ODD, mod0, mod1, mod2)
elif len(ODD) <= len(mod0):
    assign(ODD, mod0)
    assign(EVEN, mod0, mod1, mod2)
else:
    assign(EVEN, mod1, mod0)
    assign(ODD, mod2, mod0)

ANS = ANS[1:]
print(' '.join(map(str, ANS)))


Measured memory_bytes: 168512
import java.util.*;

public class Main {
    public static void main(String args[]) {
        Scanner sc = new Scanner(System.in);
        int[] a = new int[3];
        for(int i = 0; i < 3; i++) {
            a[i] = sc.nextInt();
        }
        System.out.println((a[0] * a[1]) / 2);
    }
}



Measured memory_bytes: 21844
#include<bits/stdc++.h>
using namespace std;
int d[99][99][99];
int dp(int A,int B,int C){
	if(A == B && A == C)return 0;
	if(A > 98 || B > 98 || C > 98)return 99999;
	int&tmp = d[A][B][C];
	if(tmp != -1)return tmp;
	tmp = 99999;
	tmp = min(tmp, dp(A+2,B,C));
	tmp = min(tmp, dp(A,B+2,C));
	tmp = min(tmp, dp(A,B,C+2));
	tmp = min(tmp, dp(A+1,B+1,C));
	tmp = min(tmp, dp(A+1,B,C+1));
	tmp = min(tmp, dp(A,B+1,C+1));
	++tmp;
	return tmp;
}
int main(){
	int A,B,C;
	memset(d,-1,sizeof(d));
	scanf("%d%d%d",&A,&B,&C);
	printf("%d\n",dp(A,B,C));
	return 0;
}


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

using ul=unsigned long long;
int s[500],t[500],tmp[500][500],S[500],T[500],n,bit=-1,IN;
ul ans[500][500],u[500],v[500];

template<typename T>
void fin(T a){
  cout<<a<<endl;
  exit(0);
}

struct P{int va,idx,ve,ne,al;};
bool operator <(const P &a,const P &b){return a.va<b.va;};
priority_queue<P> que;

#define REP(i,n) for(int i=0;i<n;i++)
#define F(va) {\
  if(!~tmp[i][j]){\
    ans[i][j]+=((ul)1<<bit)*(tmp[i][j]=va);\
    S[i]++,T[j]++;\
    if(IN){\
      if(S[i]<n)que.push({S[i],i,'S',s[i]});\
      if(T[j]<n)que.push({T[j],j,'T',t[j]});\
    }\
  }\
}
void AL(){
  bool KO=1;
  while(KO){
    KO=0;
    REP(i,n)
      if(s[i]==((u[i]>>bit)&1)){
        bool f=0;
        REP(j,n)f|=tmp[i][j]==s[i];
        if(f)REP(j,n){KO|=tmp[i][j]<0;F(s[i]^1);}
      }
    REP(j,n)
      if(t[j]==((v[j]>>bit)&1)){
        bool f=0;
        REP(i,n)f|=tmp[i][j]==t[j];
        if(f)REP(i,n){KO|=tmp[i][j]<0;F(t[j]^1);}
      }
  }
}
bool same(int a,int b,int c,int d){return a==b&&b==c&&c==d;}

int main(){
  cin>>n;
  REP(i,n)cin>>s[i];
  REP(i,n)cin>>t[i];
  REP(i,n)cin>>u[i];
  REP(i,n)cin>>v[i];
  while(++bit<64){
    memset(tmp,-1,sizeof(tmp));
    memset(S,0,sizeof(S));
    memset(T,0,sizeof(T));
    IN=0;
    REP(i,n)if(s[i]^((u[i]>>bit)&1))REP(j,n)F(s[i]^1);
    REP(j,n)if(t[j]^((v[j]>>bit)&1))REP(i,n)F(t[j]^1);
    REP(i,n)REP(j,n)if(same(s[i],(u[i]>>bit)&1,t[j],(v[j]>>bit)&1))F(s[i]);
    AL();
    IN=1;
    REP(i,n)if(S[i]<n)que.push({S[i],i,'S',s[i],1});
    REP(j,n)if(T[j]<n)que.push({T[j],j,'T',t[j],1});
    while(que.size()){
      P p=que.top();que.pop();
      if(p.ve=='S'){
        int i=p.idx;
        if(p.va<S[i])continue;
        REP(j,n)
          if(!~tmp[i][j]){
            F(p.ne);
            p.ne^=p.al;p.al=0;
          }
        AL();
      }
      else{
        int j=p.idx;
        if(p.va<T[j])continue;
        REP(i,n)
          if(!~tmp[i][j]){
            F(p.ne);
            p.ne^=p.al;p.al=0;
          }
        AL();
      }
    }
  }

  REP(i,n){
    ul A=ans[i][0];
    REP(j,n)
      if(s[i])A|=ans[i][j];
      else A&=ans[i][j];
    if(A!=u[i])fin(-1);
  }
  REP(j,n){
    ul A=ans[0][j];
    REP(i,n)
      if(t[j])A|=ans[i][j];
      else A&=ans[i][j];
    if(A!=v[j])fin(-1);
  }

  REP(i,n){
    REP(j,n)cout<<ans[i][j]<<" ";cout<<endl;
  }
}


Measured memory_bytes: 18336
#include<set>
#include<map>
#include<ctime>
#include<queue>
#include<cmath>
#include<climits>
#include<cstdio>
#include<vector>
#include<cstring>
#include<iostream>
#include<algorithm>
#define LL long long
using namespace std;
int read(){
    int f=1,x=0;char s=getchar();   
    while(s<'0'||s>'9'){if(s=='-')f=-1;s=getchar();}  
    while(s>='0'&&s<='9'){x=x*10+s-'0';s=getchar();}
    return x*f;
}
#define MAXN 1000
#define INF 0x3f3f3f3f
int n,len,x[MAXN+5],y[MAXN+5],d[35];
void Print(int X,int Y){
	for(int i=1;i<=len;i++){
		if(abs(X)>abs(Y)){
			if(X>0) putchar('R'),X-=d[i];
			else putchar('L'),X+=d[i];
		}
		else{
			if(Y>0) putchar('U'),Y-=d[i];
			else putchar('D'),Y+=d[i];
		}
	}
	puts("");
	return ;
}
int main(){
	bool f[2]={0};
	n=read();
	for(int i=1;i<=n;i++)
		x[i]=read(),y[i]=read(),f[(x[i]+y[i])%2]=1;
	if(f[0]&&f[1]){
		puts("-1");
		return 0;
	}
	for(int i=30;i+1;i--)
		d[++len]=(1<<i);
	if(f[0]) d[++len]=1;
	printf("%d\n",len);
	for(int i=1;i<len;i++)
		printf("%d ",d[i]);
	printf("%d\n",d[len]);
	for(int i=1;i<=n;i++)
		Print(x[i],y[i]);
	return 0;
}/**/

Measured memory_bytes: 256
def main():
    N = int(input())
    B = [int(i) for i in input().split()]
    A = [0] * N
    A[0] = B[0]
    for i in range(1,N-1):
        A[i] = min(B[i-1],B[i])
    A[N-1] = B[N-2]
    print(sum(A))

if __name__ == '__main__':
    main()

Measured memory_bytes: 38512
#include <iostream>
#include <string>
#include <vector>

using namespace std;
typedef long long ll;

int main(){
    ll h, w;
    cin >> h >> w;
    vector<string> map(h);
    for(int i = 0; i < h; ++i){
        cin >> map.at(i);
    }
    for(int i = 0; i < h; ++i){
        for(int j = 0; j < w; ++j){
            if(map.at(i).at(j) == '#'){ continue; }
            char count = 0;
            for(int dh = -1; dh <= 1; ++dh){
                if(i + dh < 0 || i + dh >= h){ continue; }
                for(int dw = -1; dw <= 1; ++dw){
                    if(j + dw < 0 || j + dw >= w){ continue; }
                    count += map.at(i + dh).at(j + dw) == '#';
                }
            }
            map.at(i).at(j) = '0' + count;
        }
    }

    for(const string& s : map){
        cout << s << endl;
    }
    return 0;
}


Measured memory_bytes: 632
import java.util.*;
public class Main {
    public static void main(String[] args){
    
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int a = N%1000;

    if(a!=0){
	System.out.println(1000-a);
    }else{
	System.out.println("0");        
    }
      }
}



Measured memory_bytes: 35856
/*

 Remember, Hope is a good thing... May be the best of things... and No Good thing ever Dies !!!

*/
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define IOS ios::sync_with_stdio(0); cout.tie(0);
#define endl "\n"
#define MOD 1000000007
const ll inf=(1LL<<60)-1;
int dx[]= {-1,1,0,0};
int dy[]= {0,0,-1,1};
void solve()
{
    //freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);
    ll a,b;
    cin>>a>>b;
    if(a<=8 && b<=8)
        cout<<"Yay!"<<endl;
    else
        cout<<":("<<endl;
}
int main()
{
    IOS;
    //ll t;
     //cin>>t;
     //while(t--)
    solve();
    return 0;
}


Measured memory_bytes: 3612
#include <stdio.h>
#include <iostream>
#include <climits>
#define MAX 1000000000000000000

bool is_product_overflow(long long a, long long b) {
	return (LLONG_MAX / b < a);
}

int main() {

	int  N;
	std::cin >> N;

	long long* A;
	A = new long long[N];
	long long mul = 1;

	for (int i = 0;i < N;i++) {
		std::cin >> A[i];
		if (A[i] == 0) {
			std::cout << "0" << std::endl;
			return 0;
		}
	}

	for (int i = 0;i < N;i++) {
		if (is_product_overflow(mul, A[i]) || A[i] > MAX) {
			std::cout << "-1" << std::endl;
			return 0;
		}
		else {
			mul = mul * A[i];
		}
	}

	if (mul <= MAX) {
		std::cout << mul << std::endl;
	}
	else {
		std::cout << "-1" << std::endl;
	}
	

	return 0;
}

Measured memory_bytes: 4416
N = int(input())
D = [int(d) for d in input().split()]
maxD = max(D)
length = [0 for _ in range(maxD+1)]
mod = 998244353
for d in D:
    length[d] += 1
if D[0] != 0 or length[0] > 1:
    print(0)
else:
    ans = 1
    for i in range(1, maxD + 1):
        if length[i] == 0:
            print(0)
            break
        else:
            ans *= (length[i-1] ** length[i]) % mod
            ans %= mod
    else:
        print(ans)



Measured memory_bytes: 14396
#include<bits/stdc++.h>
using namespace std;
int main()
{
  char c1,c2,c3;
  int num=3;
  cin>>c1>>c2>>c3;
  if(c1=='7'||c2=='7'||c3=='7')
    cout<<"Yes";
  else
    cout<<"No";
  return 0;
}


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

int main() {
  int n;
  cin >> n;
  vector<int> vec(n);
  int j;
  int v;
  for (int i = 0; i < vec.size(); i++) {
    cin >> vec.at(i);
    if (i > 0) cout << " ";
    cout << vec.at(i);
  }
  cout << endl;
  for (int i = 1; i < n; i++) {
    v = vec.at(i);
    j = i - 1;
    while (j >= 0 && vec.at(j) > v) {
      vec.at(j + 1) = vec.at(j);
      j--;
    }
    vec.at(j + 1) = v;
    for (int i = 0; i < vec.size(); i++) {
      if (i > 0) cout << " ";
      cout << vec.at(i);
    }
    cout << endl;
  }
}



Measured memory_bytes: 3096
#include<iostream>
#define rep(i, start, end) for (int i = (int)start; i < (int)end; ++i)
#define rrep(i, start, end) for (int i = (int)start - 1; i >= end; --i)
#define arep(i, c) for (auto i = (c).begin(); i != (c).end(); ++i)
#define all(x) (x).begin(), (x).end()
using namespace std;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int A, B;
    cin >> A >> B;
    cout << max(A - 2 * B, 0) << endl;
    return 0;
}

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

typedef long long ll;
typedef long double ld;

#define MOD 1000000007
#define all(x) (x).begin(),(x).end()
#define rep(i, n) for(int i = 0; i < (int)(n); i++)

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

int main(){

    ll a, b, c, d;

    cin >> a >> b >> c >> d;

    cout << ((abs(a - b) <= d && abs(b - c) <= d) || (abs(a - c) <= d) ? "Yes" : "No") << endl;

    return 0;
}

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


int main(int argc, const char * argv[]) {
  int n;
  cin >> n;

  vector<int> v(n);
  vector<int> c(n);
  for(int i = 0; i < n; i++){
    cin >> v.at(i);
  }
  for(int i = 0; i < n; i++){
    cin >> c.at(i);
  }
  
  int result = 0;
  for(int i = 0; i < (1 << n); i++){
    int sum = 0;
    for(int j = 0; j < n; j++){
      if(i & (1 << j)){
        sum += v.at(j) - c.at(j);
      }
    }
    result = max(result, sum);
  }
  cout << result << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <utility>
#include <map>
#include <list>
#include <climits>
#include <set>
#include <deque>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <iomanip>
#include <bitset>

#define DEBUG(x) cout << "> " << #x << ": " << x << "\n";

using namespace std;

template <typename T>
std::ostream &operator <<(std::ostream &out, vector<T> &v) {
	for (typename vector<T>::size_type i = 0; i < v.size(); ++i)
		out << v[i] << " ";
	out << "\n";
    return out;
}
template <typename T>
std::ostream &operator <<(std::ostream &out, vector<pair<T, T> > &v) {
	for (size_t i = 0; i < v.size(); ++i)
		out << "(" << v[i].first << ", " << v[i].second << ") ";
	out << "\n";
    return out;
}
template <typename T>
std::ostream &operator <<(std::ostream &out, vector<vector<T> > &v) {
	for (size_t i = 0; i < v.size(); ++i) {
		for (size_t j = 0; j < v[i].size(); ++j) {
			out << v[i][j] << " ";
		}
		out << "\n";
	}
   	return out;
}

int main() {

	std::ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);

	int n;
	cin >> n;

	vector<int> boss(n);
	vector<int> subordinates(n + 1);
	for (int i = 0; i < n; ++i) {
		cin >> boss[i];
		++subordinates[boss[i]];
	}

	for (int i = 1; i <= n; ++i) {
		cout << subordinates[i] << "\n";
	}

	return 0;

}

Measured memory_bytes: 4768
import itertools, math

def calcDistance(town_a, town_b):
    distance = math.sqrt((town_a[0] - town_b[0]) ** 2 + (town_a[1] - town_b[1]) ** 2)
    return distance

N = int(input())

towns =[]
for i in range(N):
    town = [int(s) for s in input().split()]
    towns.append(town)
    
loute_patterns = [v for v in itertools.permutations(towns)]

pattern_distances = []

for i in range(len(loute_patterns)):
    pattern_distance = 0
    for j in range(len(loute_patterns[i])-1):
        distance = calcDistance(loute_patterns[i][j], loute_patterns[i][j+1])
        pattern_distance += distance
    pattern_distances.append(pattern_distance)
    
output = sum(pattern_distances) / len(pattern_distances)
print(output)

Measured memory_bytes: 10876
import java.util.ArrayList;
import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;

public class Main {
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int N = in.nextInt();
		ArrayList<String> w =new ArrayList<String>();
		for(int i=0;i<N;i++) {
			w.add(in.next());
		}
		boolean flag= true;
		
		for(int i=0;i<N-1;i++) {
			char wend=w.get(i).charAt(w.get(i).length()-1);
			char wbstart=w.get(i+1).charAt(0)	;
			if(wend!=wbstart) {
				flag=false;
			}
		}

		Set<String> w2 =new HashSet<String>();
		for(int i=0;i<N;i++) {
			w2.add(w.get(i));
		}
		if(w2.size()!=N) {
			flag=false;
		}
		
		
		if(flag) {
			System.out.println("Yes");
		}else {
			System.out.println("No");
		}
		
	}
}


Measured memory_bytes: 22612
#include<iostream>
#include<cmath>
#include<iomanip>

using namespace std;

int main(){
  int n,p;
  cin>>n;
  double x[n],y[n];
  double sumr;
  cout<<fixed<<setprecision(6);
  for(int i=0;i<n;i++){
    cin>>x[i];
  }
  for(int i=0;i<n;i++){
    cin>>y[i];
  }
  for(p=1;p<=3;p++){
    sumr=0;
    for(int i=0;i<n;i++){
      int s=fabs(x[i]-y[i]);
      sumr+=pow(s,p);
    }
    // cout<<sumr<<endl;//can delete
    cout<<pow(sumr,1.0/p)<<endl;
  }
  //p=∞のとき
  double max=fabs(x[0]-y[0]);
  for(int i=1;i<n;i++){
    if(max<fabs(x[i]-y[i]))max=fabs(x[i]-y[i]);
  }
  cout<<max<<endl;
  return 0;
}



Measured memory_bytes: 3476
#include<iostream>
#include <algorithm>
using namespace std;
static const int MAX = 200000;
int main(){
    int R[MAX],n;

    cin>>n;
    for(int i =0;i<n;i++) cin>>R[i];

    int maxv = -2000000000;
    int minv = R[0];
    for (int i =1; i<n;i++){
        maxv = max(maxv,R[i]-minv);
        minv = min(minv,R[i]);
    }
    cout<<maxv<<endl;
    return 0;
}


Measured memory_bytes: 3864
import java.util.Scanner;
public class Main
 {
    public static void main(String[] args) {
        int a, b, cal;
        String op;
        
        Scanner sc = new Scanner(System.in);
        while(true){
        a = sc.nextInt();
        op = sc.next();
        b = sc.nextInt();
        if(op.compareTo("?")==0){
        break;
        }
        else{
        if(op.compareTo("+")==0){
        cal = a + b;
        }
        else if (op.compareTo("-")==0){
        cal = a-b;
        }
        else if (op.compareTo("*")==0){
        cal = a * b;
        }
        else {
        cal = a / b;
        }
        System.out.println(cal);
        }
        }
       
    }
}


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

struct bit {
    vector<long> t;
    bit(int n) : t(n + 1) {}
    void upd(int a, long n) {
        for(a++; a < t.size(); a += a & -a)
            t[a] += n;
    }
    long get(int a) const {
        long r = 0;
        for(; a; a &= a - 1)
            r += t[a];
        return r;
    }
};
int c[555555], d[555555], x[555555];
tuple<int, int, int> p[555555];
int main() {
    int n, q;
    cin >> n >> q;
    for(int i = 0; i < n; i++)
        cin >> c[i], c[i]--;
    for(int i = 0; i < q; i++) {
        int l, r;
        cin >> l >> r;
        p[i] = {r, l - 1, i};
    }
    sort(p, p + q);
    fill(d, d + n, -1);
    bit b(n);
    int j = 0;
    for(int i = 0; i < n; i++) {
        if(d[c[i]] >= 0)
            b.upd(d[c[i]], -1);
        b.upd(d[c[i]] = i, 1);
        for(; j < q; j++) {
            auto [r, l, m] = p[j];
            if(r != i + 1)
                break;
            x[m] = b.get(r) - b.get(l);
        }
    }
    for(int i = 0; i < q; i++)
        cout << x[i] << '\n';
    return 0;
}


Measured memory_bytes: 19424
n,k=map(int,input().split())
V = list(map(int,input().split()))

ans = 0

for i in range(1,min(n,k)+1): # 取り出す回数
    tu = k-i # 詰める最大回数
    g = i - (k-i) #得る最小宝石数
    for j in range(i+1): #左から取り出す回数
        A = []
        r = i-j
        for L in range(j):
            A.append(V[L])
        for R in range(r):
            A.append(V[-(R+1)])
        A=sorted(A,reverse=1)
        B=[]
        B.append(A[0])
        for kk in range(1,len(A)):
            B.append(B[kk-1]+A[kk])
        pt=0
        #print(A)
        #print(B,g-1,i)
        if max(0,g-1) < min((i),len(B)) :
            pt = max(B[max(0,g-1):min((i),len(B))])
        
        #print(pt)
        ans = max(ans,pt)
print(ans)


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

const int MAX_N = 100;

int main() {
	int N, cnt[8] = {}, free = 0;

	std::cin >> N;
	for(int i = 0; i < N; ++i) {
		int a;
		std::cin >> a;
		if(a <= 399) ++cnt[0];
		else if(a <= 799) ++cnt[1];
		else if(a <= 1199) ++cnt[2];
		else if(a <= 1599) ++cnt[3];
		else if(a <= 1999) ++cnt[4];
		else if(a <= 2399) ++cnt[5];
		else if(a <= 2799) ++cnt[6];
		else if(a <= 3199) ++cnt[7];
		else ++free;
	}
	std::sort(cnt, cnt + 8);

	int zero = (int) (std::upper_bound(cnt, cnt + 8, 0) - cnt);

	int ans_min = std::max(8 - zero, 1);
	int ans_max = 8 - zero + free;

	std::cout << ans_min << " " << ans_max << std::endl;
}

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

struct Solution {
    int N;
    vector<int> A;

    void Solve() {
        scanf("%d", &N);
        A.resize(N + N);
        for (int i = 0; i < A.size(); ++i) scanf("%d", &A[i]);
        sort(A.begin(), A.end());
        int answer = 0;
        for (int i = 0; i < A.size(); i += 2) answer += A[i];
        printf("%d\n", answer);
    }
};

int main() {
    Solution().Solve();
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define SORT(x) sort((x).begin(),(x).end())
#define ALL(x) (x).begin(),(x).end()
#define rep(i, n) for(int i = 0; i < n; i++)
#define reps(i, m, n) for(int i = m; i < n; i++)
#define repr(i, m, n) for(int i = m; i >= n; i--)
template<class T>bool maxi(T &a,const T &b){if(a<b){ a=b; return 1;} return 0;}
template<class T>bool mini(T &a,const T &b){if(b<a){ a=b; return 1;} return 0;}
#define y0 y3487465 //j0
#define y1 y1347829 //j1
#define INF2 4000000000000000037
#define INF 1000000007
#define PI (acos(-1))
#define MOD 1000000007
using namespace std;
typedef long long ll;

struct edge{ll to, cap, rev;}; //to, capacity, 反対エッジ
struct graph{
  ll N; //ノードの個数
  vector<vector<edge> > G; //G[辺の元]((.to辺の先,.costコスト),...)
  vector<ll> depth; // d[ノード] ノードの深さ

  graph(ll n){ //グラフ生成時
    N = n;
    G.resize(N); //Edge情報
    depth.resize(N); //Node情報,深さ
    rep(i,N) depth[i] = -1;
  }
  void add_edge(ll s, ll t, ll cap){
    G[s].emplace_back((edge){t, cap, (ll)G[t].size()});
    G[t].emplace_back((edge){s, 0, (ll)G[s].size()-1});
  }

  ll dfs(ll v, ll goal, ll water, ll d=1){
    if(v == goal) return water;
    depth[v] = d;
    for(auto& E : G[v]){ // E つなぐエッジ
      if(depth[E.to] == -1 && E.cap > 0){
        ll o_flow = dfs(E.to, goal, min(water, E.cap), d+1);
        if(o_flow > 0){
          E.cap -= o_flow;
          G[E.to][E.rev].cap += o_flow;
          return o_flow;
        }
      }
    }
    return 0;
  }

  ll max_flow(ll s, ll g){
    ll flow = 0;
    while(true){
      rep(i,N) depth[i] = -1;
      ll o_flow = dfs(s, g, INF, 1);
      if (o_flow==0) return flow; //更新がなかったら終了
      flow += o_flow;
    }
  }
};


void Main(){
  int N;
  cin>>N;

  graph g(2*N+2);

  rep(i,N){
    g.add_edge(0,i+1,1);
    g.add_edge(N+1+i,2*N+1,1);
  }

  vector<pair<int,int>> red;
  vector<pair<int,int>> blue;
  rep(i,N){
    int a,b; cin>>a>>b;
    red.emplace_back(a,b);
  }
  rep(i,N){
    int a,b; cin>>a>>b;
    blue.emplace_back(a,b);
  }

  rep(i,N){
    rep(j,N){
      if(red[i].first<blue[j].first and red[i].second <blue[j].second) g.add_edge(i+1,j+N+1,1);
    }
  }

  cout<< g.max_flow(0,2*N+1)<<"\n";

}

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


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    int n;
    cin>>n;
    string s;
    long long int cou=1;
    long long int ans=0;
    vector<string>v(n);
    for(int i=0; i<n; i++){
        cin>>s;
        sort(s.begin(),s.end());
        v.at(i)=s;
    }
    sort(v.begin(),v.end());
    for(int j=0; j<n-1; j++){
        if(v.at(j)==v.at(j+1)){
            cou++;
        }else{
            ans+=cou*(cou-1)/2;
            cou=1;
        }
    }
    ans+=cou*(cou-1)/2;
    cout<<ans<<endl;
}


Measured memory_bytes: 6368
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <cmath>
#include <fstream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
using namespace std;
typedef long long ll;

int main(void){
    int x,n;
    cin>>x>>n;
    int min=100;
    int ans=0;
    vector<int> p(n);
    rep(i,n){
        cin>>p[i];
    }
    for(int i=-100;i<=101;i++){
        int f=1;
        rep(j,n){
            if(i==p[j])f=0;
                
        }
        if(f){
            if(min>abs(x-i)){
                min=abs(x-i);
                ans=i;
            }
        }
        
    }cout<<ans<<endl;

}

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

int main() {
  long long t1,t2;
  cin >> t1 >> t2;
  long long a1,a2,b1,b2;
  cin >> a1 >> a2 >> b1 >> b2;
  long long p,q;
  if(a1>b1) {
    p=t1*(a1-b1);
    q=t2*(a2-b2);
  }
  else {
    p=t1*(b1-a1);
    q=t2*(b2-a2);
  }
  if(p+q==0) {
    cout << "infinity" << endl;
  }
  else if(p+q>0) {
    cout << 0 << endl;
  }
  else {
    long long ans=2*(p/(-(p+q)));
    if(p%(-(p+q))!=0) {
      ans++;
    }
    cout << ans << endl;
  }
}

Measured memory_bytes: 256
"""
B - Ruined Square
各点を複素数として管理する
点間の差のベクトルを jかけて 回転させる
"""

x1, y1, x2, y2 = map(int, input().split())

square = []
for i in range(4):
    square.append(complex(0, 0))

square[0] = complex(x1, y1)
square[1] = complex(x2, y2)

dist = square[1] - square[0]

out = ""
for i in range(2, 4):
    dist = dist * complex(0, 1)
    square[i] = square[i - 1] + dist
    out += ("%d %d " % (square[i].real, square[i].imag)) 

print(out)

Measured memory_bytes: 3064
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
using namespace std;
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define MOD 1000000007
#define INF (1<<30)
#define LINF (lint)(1LL<<56)
#define endl "\n"
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define reprev(i,n) for(int (i)=(n-1);(i)>=0;(i)--)
#define Flag(x) (1<<(x))
#define Flagcount(x) __builtin_popcount(x)
#define pint pair<int,int>
#define pdouble pair<double,double>
#define plint pair<lint,lint>
typedef unsigned long long int ull;
typedef long long lint;

int main(void){
    string S;
    cin >> S;
    int ans=0;
    int L=S.length();
    int half=L/2;
    rep(i,half){
        if(S[i]!=S[L-1-i]) ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<ll,ll>;
using vl = vector<ll>;
using Map = map<ll,ll>;
using Tup = tuple<ll,ll,ll>;
using vvl = vector<vector<ll>>;
#define all(v) v.begin(), v.end()
#define prt(v) cout<<(v)<<"\n";
#define fl cout<<flush;
#define fi(v) get<0>(v)
#define se(v) get<1>(v)
#define th(v) get<2>(v)
#define endl "\n"
template <typename T> bool chmax(T &a, const T &b){if (a<b){a=b;return 1;}return 0;}
template <typename T> bool chmin(T &a, const T &b){if (a>b){a=b;return 1;}return 0;}
const ll INF=1LL<<60;
const ll MOD=1000000007;

signed main(void){
    cin.tie(0);cout.tie(0);ios::sync_with_stdio(false);
    ll N;
    cin >> N;
    ll M;
    cin >> M;
    vector<vector<char>> A(N, vector<char>(N));
    vector<vector<char>> B(M, vector<char>(M));
    for(ll i=0;i<N;++i)
        for(ll j=0;j<N;++j)cin>>A[i][j];
    for(ll i=0;i<M;++i)
        for(ll j=0;j<M;++j)cin>>B[i][j];
    for(ll i=0;i<N-M+1;++i){
        for(ll j=0;j<N-M+1;++j){
            bool ok=1;
            for(ll k=0;k<M;++k){
                for(ll l=0;l<M;++l){
                    if(A[k+i][l+j]!=B[k][l]){
                        ok=0;break;
                    }
                }
            }
            if(ok){prt("Yes")return 0;}
        }
    }
    prt("No")

    return 0;
}


Measured memory_bytes: 256
#include <vector>
#include <iostream>
#include <utility>
#include <algorithm>
#include <string>
#include <deque>
#include <queue>
#include <tuple>
#include <queue>
#include <functional>
#include <cmath>
#include <iomanip>
#include <map>
#include <set>
#include <numeric>
#include <unordered_map>
#include <unordered_set>
#include <complex>
#include <iterator>
#include <array>
#include <memory>
#include <stack>
using ll = long long;
//#define int ll
#define ld long double
#define INF 1e9
#define EPS 0.0000000001
#define rep(i,n) for(int i=0;i<n;i++)
#define loop(i,s,n) for(int i=s;i<n;i++)
#define all(in) in.begin(), in.end()
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
#define MAX 9999999
using namespace std;
typedef pair<int, int> pii;
typedef pair<double,double>pdd;
signed main(){
    int n;
    cin>>n;
    vector<int>v(n);
    map<int,int>mp;
    rep(i,n){
        cin>>v[i];
        mp[v[i]]++;
    }
    int ans=(int)v.size();
    int temp=0;
    for(auto itr:mp){
        if(itr.second<itr.first)temp+=itr.second;
        else if(itr.second>itr.first)temp+=itr.second-itr.first;
    }
    cout<<temp<<endl;
}


Measured memory_bytes: 5120
use std::io::{self, Read};

fn main() {
    let mut buffer = String::new();
    io::stdin().read_line(&mut buffer).unwrap();
    buffer.clear();
    io::stdin().read_line(&mut buffer).unwrap();
    let mut xs: Vec<i32> = buffer
        .split_whitespace()
        .map(|x| x.parse().unwrap())
        .collect();
    
    xs.sort();
    let mut counts = [0; 100001];
    for x in xs.iter() {
        count(*x as usize, &mut counts);
    }

    let result = counts.iter().max().unwrap();
    println!("{}", result);
}

fn count(x: usize, xs: &mut [i32]) {
    if x == 0 {
        xs[x] += 1;
        xs[x+1] += 1;
    } else if x == 100000 {
        xs[x-1] += 1;
        xs[x] += 1;
    }
    else {
        xs[x] += 1;
        xs[x-1] += 1;
        xs[x+1] += 1;
    }
}

Measured memory_bytes: 6780
import java.util.Scanner;

// *** at 2018/**/**

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

    private void solveA() {
        Scanner sc = new Scanner(System.in);
        int A = sc.nextInt();
        int B = sc.nextInt();
        if (A + B < 10) {
            System.out.println(A + B);
        } else {
            System.out.println("error");
        }
    }

    private void solveB() {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        System.out.println(N);
    }

    private void solveC() {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        System.out.println(N);
    }

    private void solveD() {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        System.out.println(N);
    }

    private void solveE() {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        System.out.println(N);
    }

    private void solveF() {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        System.out.println(N);
    }

}

Measured memory_bytes: 21844
#include<cstdio>

int a[10];

bool is_ok(int n){
  int right = 0;
  int left = 0;
  for(int i=0;i<10;i++){
    if(n%2==1&&right<a[i]) right = a[i];
    else if(n%2==0&&left<a[i]) left = a[i];
    else return false;
    n/=2;
  }
  return true;
}

void solve(){
  for(int i=0;i<10;i++) scanf("%d",a+i);
  for(int i=0;i<1024;i++){
    if(is_ok(i)){
      printf("YES\n");
      return;
    }
  }
  printf("NO\n");
}


int main(){
  int n;
  scanf("%d",&n);
  for(int i=0;i<n;i++) solve();
  return 0;
}

Measured memory_bytes: 1008
#include<bits/stdc++.h>
using namespace std;
int n,m;
int a[10010];
int dp[30][50050];
int main(){
	cin>>n>>m;
	for(int i=1;i<=m;i++){
		cin>>a[i];
	}
	for(int i=1;i<=m;i++){
		dp[i][0]=0;
	}
	for(int j=1;j<=n;j++){
		dp[0][j]=1<<30;
	}
	dp[0][0]=0;
	int temp;
	for(int i=1;i<=m;i++){
		for(int j=0;j<=n;j++){
			if(j-a[i]<0){
				temp=1<<30;
			}
			else{
				temp=dp[i][j-a[i]];
			}
			dp[i][j]=min(temp+1,dp[i-1][j]);
			//cout<<"i: "<<i<<" j: "<<j<<" dp:"<<dp[i][j]<<endl;
		}
	}
	cout<<dp[m][n]<<endl;
	return 0;
} 



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

using namespace std;

int main(){
	int n; cin >> n;
	map<int,int> d;
	for(int i = 0; i < n; i++){
		int t; cin >> t;
		d[t] = 1;
	}
	int ans = 0;
	for(map<int,int>::iterator itr = d.begin(); itr != d.end(); itr++){
		ans++;
	}
	cout << ans << endl;

	return 0;
}



Measured memory_bytes: 256
#include <boost/multiprecision/cpp_int.hpp>
#include <boost/multiprecision/cpp_dec_float.hpp>
namespace mp = boost::multiprecision;
using Bint = mp::cpp_int;                        // 任意長整数
using Real = mp::number<mp::cpp_dec_float<1024>>;// 仮数部が1024bitの浮動小数点数
#include<bits/stdc++.h>

using namespace std;
using ll = long long;


int main()
{
    ll n; cin >> n;
    Bint t = 1;
    vector<ll> b(n);
    for(int i = 0; i < n; i++)cin >> b[i];
    if(count(b.begin(), b.end(), 0)) {
        cout << 0 << endl;
        return 0;
    }
    for(int i = 0; i < n; i++) {
        ll a = b[i];
        t *= a;
        if(t > 1000000000000000000) {
            cout << -1 << endl;
            return 0;
        }
    }
    cout << t << endl;
}

Measured memory_bytes: 4096
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define Fast_IO ios::sync_with_stdio(false);
#define int long long
#define mod 1000000007
inline int read()
{
	char ch=getchar(); int nega=1; while(!isdigit(ch)) {if(ch=='-') nega=-1; ch=getchar();}
	int ans=0; while(isdigit(ch)) {ans=ans*10+ch-48;ch=getchar();}
	if(nega==-1) return -ans;
	return ans;
}
#define N 200005
int a[N];
char s[N];
int n;
signed main()
{
#ifdef __LOCAL__
	freopen("in.txt","r",stdin);
#endif
	n=read();
	scanf("%s",s+1);
	for(int i=1;i<=n*2;i++)
	{
		a[i]=(s[i]=='B');
	}
	int cur=0,ans=1;
	for(int i=1;i<=n*2;i++)
	{
		if((cur&1)==a[i])
		{
			ans=ans*cur%mod;
			cur--;
		}
		else cur++;
	}
	if(cur!=0) return cout<<"0\n",0;
	for(int i=1;i<=n;i++)
	{
		ans=ans*i%mod;
	}
	cout<<ans<<endl;
#ifdef __LOCAL__
	printf("Time Used : %d\n",clock());
#endif
	return 0;
}



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

int main() {
  int n;
  cin>>n;
  vector<int> h(n);
  for (int i=0;i<n;++i) {
    cin>>h[i];
  }
  reverse(h.begin(), h.end());
  int flg=1;
  for (int i=0;i<n;++i) {
    if (h[i+1]>(h[i]+1)) {
      flg=0;
      break;
    } else {
      if (h[i+1]==(h[i]+1)) {
        h[i+1]=h[i];
      }
    }
  }
  if (flg==1) {
    cout<<"Yes"<<endl;
  } else {
    cout<<"No"<<endl;
  }
}

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

#define FOR(i,l,r) for(int i = (int) (l);i < (int) (r);i++)
#define ALL(x) x.begin(),x.end()
template<typename T> bool chmax(T& a,const T& b){ return a < b ? (a = b,true) : false; }
template<typename T> bool chmin(T& a,const T& b){ return b < a ? (a = b,true) : false; }
typedef long long ll;

const int BUCKET = 300,SIZE = 400;
int N,Q;
ll bucketMin [BUCKET];
ll A [100000];
const ll INF = (1ll << 31) - 1;

void update(int idx,ll val)
{
	A [idx] = val;
	int bucket_l = idx / SIZE * SIZE,bucket_r = (idx / SIZE + 1) * SIZE;
	ll mn = INF;
	FOR(i,bucket_l,bucket_r){
		chmin(mn,A [i]);
	}
	bucketMin [idx / SIZE] = mn;
}

ll getMin(int l,int r)
{
	ll res = INF;
	FOR(i,0,BUCKET){
		int bucket_l = i * SIZE,bucket_r = (i + 1) * SIZE;
		if(r <= bucket_l || bucket_r <= l) continue;
		if(l <= bucket_l && bucket_r <= r){
			chmin(res,bucketMin [i]);
			continue;
		}
		FOR(j,bucket_l,bucket_r){
			if(l <= j && j < r){
				chmin(res,A [j]);
			}
		}
	}
	return res;
}

int main()
{
	scanf("%d%d",&N,&Q);
	fill(A,A + N,INF);
	fill(bucketMin,bucketMin + BUCKET,INF);
	vector<ll> ans;
	FOR(i,0,Q){
		int com,x,y;
		scanf("%d%d%d",&com,&x,&y);
		if(com == 0){
			update(x,y);
		}
		else{
			ans.push_back(getMin(x,y + 1));
		}
	}

	FOR(i,0,ans.size()){
		printf("%lld\n",ans [i]);
	}

	return 0;
}

Measured memory_bytes: 4240
#include<stdio.h>
#include<string.h> 
int main(){
	int la,lb,lc,i;
	la=lb=lc=0;
	char a[12],b[12],c[12];
	scanf("%s",a);
	scanf("%s",b);
	scanf("%s",c);
//	printf("%s\n%s\n%s\n",a,b,c);
	la=strlen(a);
	lb=strlen(b);
	lc=strlen(c);
	
	if(a[la-1]==b[0] && b[lb-1]==c[0]){
		printf("YES");
	}
	else{
		printf("NO");
	}
	return 0;
}

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

long long mod = 1000000007;
long long modpow(long long a, long long n)
{
    long long res = 1;
    while (n > 0) {
        if (n & 1)
            res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

int main()
{
    long long n, m;
    cin >> n >> m;
    vector< long long > a(m);
    for (long long i = 0; i < m; i++) {
        cin >> a[i];
    }
    vector< long long > sum(2 * n);
    sum[0] = 0;
    sum[1] = sum[2] = 1;
    for (long long i = 3; i < 2 * n; i++) {
        sum[i] = (sum[i - 1] + sum[i - 2]) % mod;
    }
    if (m == 0) {
        cout << sum[n + 1] << endl;
        return 0;
    }
    long long ans = sum[a[0]] % mod;
    // cout << ans << endl;
    for (long long i = 1; i < m; i++) {
        ans = (ans * sum[a[i] - a[i - 1] - 1]) % mod;
    }
    ans = (ans * (sum[n - a[m - 1]])) % mod;
    cout << ans % mod << endl;
    return 0;
}

Measured memory_bytes: 2560