akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define int long long
using namespace std;

int n;
int x[8], y[8];

signed main(){
  
  cin>>n;
  
  for(int i=0;i<n;i++) cin>>x[i]>>y[i];
  
  vector<int> a;
  
  for(int i=0;i<n;i++) a.push_back( i );
  
  double ans = 0;
  double cnt = 0;
  
  do{
    
    cnt++;
    
    for(int i=0;i<n-1;i++){
      
      double X = x[a[i]] - x[a[i+1]];
      double Y = y[a[i]] - y[a[i+1]];
      
      ans += sqrt( X * X + Y * Y );
      
    }
        
  }while( next_permutation( a.begin(), a.end() ) );
  
  printf("%.8f\n", ans / cnt );
  
  return 0;
}


Measured memory_bytes: 256
import java.io.*;
import java.util.*;

public class Main {
    PrintWriter out = new PrintWriter(System.out);
    // no self-loop or multiple edges
    public static void main(String[] args) throws Exception {
        Main main = new Main();
//        main.solve();
        System.out.println(main.solve());
    }
    long solve(){
        Scanner sc = new Scanner(System.in);
        long H = sc.nextLong();
        sc.close();
        long n = 1;
        long ans = 0;
        while(H>0){
            ans += n;
            H /= 2;
            n *= 2;
        }
        return ans;
    }
}



Measured memory_bytes: 21972
#include <bits/stdc++.h>
#include <chrono>
#include <random>
#define ll long long int
#define ull unsigned long long int
#define pb push_back
#define mp make_pair
#define mod 1000000007
#define rep(i,n) for(ll i=0;i<n;i++)
#define loop(i,a,b) for(ll i=a;i<=b;i++)
#define vi vector <int>
#define vs vector <string>
#define vc vector <char>
#define vl vector <ll>
#define all(c) (c).begin(),(c).end()
#define max3(a,b,c) max(max(a,b),c)
#define min3(a,b,c) min(min(a,b),c)
using namespace std;
ll power(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll modInverse(ll a){return power(a,mod-2);}
const int N=100001;
bool vis[N];
vector <int> adj[N];
ll gcd(ll a, ll b) { if (a == 0) return b; return gcd(b % a, a); } 
ll lcm(ll a, ll b){return a*b/gcd(a, b);}
#define pi 3.14159265358979323846264338

void solve()
{
    int a, b;
    cin>>a>>b;

    cout<<a*b<<endl;
}

int main()
{
    #ifndef ONLINE_JUDGE
        // for getting input from input.txt
        freopen("input.txt", "r", stdin);
        // for writing output to output.txt
        freopen("output.txt", "w", stdout);
    #endif

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int T=1;
    // cin>>T;
    int t=0;
    while(t++<T)
    {
        // cout<<"Case #"<<t<<":"<<' ';
        solve();
        //cout<<'\n';
    }
    cerr << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC << "ms\n";
}

Measured memory_bytes: 6168
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define Max(a, b) (a > b ? a : b)
#define Min(a, b) (a < b ? a : b)
#define ii pair<int, int>
#define fi first
#define se second
const int MAX = 200000; //2 * 10^5
const int MOD = 1000000007; //10^9 + 7
const int OO = 0x3f3f3f3f; // 0x3f3f3f3f;

int degree[MAX];

int32_t main()
{
	int n;
	cin >> n;
	for(int i = 1; i < n; i++)
	{
		int x;
		cin >> x; x--;
		degree[x]++;
	}
	for(int i = 0; i < n; i++)
		cout << degree[i] << '\n';
	puts("");

	return 0;
}

Measured memory_bytes: 5184
#pragma comment(linker, "/stack:247474112")
#pragma GCC optimize("Ofast")
#include"bits/stdc++.h"
using namespace std;
#define IOS ios::sync_with_stdio(0), cin.tie(0), cout.tie(0)
#define int long long
#define ends ' '
#define endl '\n'
#define pb emplace_back
#define x first
#define y second
#define pii pair<int, int>
#define sz(x) (int)(x).size()

int32_t main()
{
	// #ifndef ONLINE_JUDGE
	// 	freopen("input.txt", "r", stdin);
	// 	freopen("output.txt", "w", stdout);
	// #endif
	IOS;

	int n, d;
	cin >> n >> d;

	d = 2*d+1;

	cout << n/d + (n%d > 0);

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i=0; i<(int)(n); i++)
#define all(v) v.begin(), v.end()
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
const ll MOD = 1000000007;
const ll INF = 10000000000000000;
vector<int> x4 = {0, 1, 0, -1};
vector<int> y4 = {1, 0, -1, 0};
vector<int> x8 = {0, 1, 1, 1, 0, -1, -1, -1};
vector<int> y8 = {1, 1, 0, -1, -1, -1, 0, 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;}
template<class T> inline T powerM(T a,T b){if (b==0) return 1;
  T tmp = powerM(a,b/2); if (b%2==0) return tmp*tmp%MOD; else return tmp*tmp%MOD*a%MOD; }


struct UnionFind{
  vector<int> par;  // 親ノードを格納
  vector<int> rank; // 木の深さを格納

  UnionFind(int N = 1) : par(N), rank(N, 0) { // N要素で初期化する
    for (int i=0; i<N; i++) par[i] = i;
  }

  int root(int x){ // 木の根を求める。自分じゃなかったら親の根を調べていき調べたノードの親はすべて根に
    return par[x] == x ? x : par[x] = root(par[x]); // 経路圧縮も行う
  }

  bool same(int x, int y){ // x,yの木が同じかどうか
    return root(x) == root(y);
  }

  bool unite(int x, int y){ // xとyの木を併合
    x = root(x); y = root(y); // ここでx,yのroot同士の扱いにする
    if (x == y) return false; // 元々同じならそのまま
    if (rank[x] < rank[y]) swap(x, y); // rank[x] >= rank[y]になるようにswap
    if (rank[x] == rank[y]) rank[x]++; // 元のrankが同じなら親になる方のrankは1増える
    par[y] = x;
    return true;
  }
};

template<class T> struct edge {int from, to; T cost;};

template<class T> bool comp(const edge<T> &e1, const edge<T> &e2) {return e1.cost < e2.cost;}

int N,M; // 頂点数と辺数
const int MAX_M = 200000;
edge<ll> es[MAX_M];           // llにするときはここもllにしてくれ

template<class T> T kruskal(){
  sort(es, es+M, comp<T>); // edge.costが小さい順にソート
  UnionFind uf(N);
  T res = 0;
  rep(i, M){
    edge<T> e = es[i];
    if (!uf.same(e.from, e.to)){
      uf.unite(e.from, e.to);
      res += e.cost;
    }
  }
  return res;
}

int main() {
  cin >>N;
  vector<pair<ll,int>> x(N),y(N);
  rep(i, N){
    cin >>x.at(i).first >>y.at(i).first;
    x.at(i).second = i; y.at(i).second = i;
  }
  sort(all(x)); sort(all(y));
  M = 2 * (N-1);
  int tmp = 0;
  rep(i, N-1){
    es[tmp] = {x[i].second, x[i+1].second, x[i+1].first-x[i].first}; tmp++;
    es[tmp] = {y[i].second, y[i+1].second, y[i+1].first-y[i].first}; tmp++;
  }
  cout <<kruskal<ll>() <<endl;
}


Measured memory_bytes: 7296
S = input()
var = 0
for i in range(len(S)):
  if (i+1)%2 == 1:
    if S[i] == 'L':
      print('No')
      var = 1
      break
  elif (i+1)%2 == 0:
    if S[i] == 'R':
      print('No')
      var = 1
      break
if var == 0:
  print('Yes')


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

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n, m, c;
    cin >> n >> m >> c;
    vector<int> bs(m);
    for(int i=0; i<m; i++) cin >> bs.at(i);
    int ans = 0;
    for(int i=0; i<n; i++)
    {
        int sun = c;
        for(int j=0; j<m; j++)
        {
            int a;
            cin >> a;
            sun += a*bs.at(j);
        }
        if(sun > 0) ans++;
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
a,b,c,x,y=map(int,input().split())
ans=10000000000
for i in range(0,max(x,y)*2+1,1):
    if x-i/2<=0 and y-i/2<=0:
        aa=0
        bb=0
    elif x-i/2<=0 and y-i/2>0:
        aa=0
        bb=y-i/2
    elif y-i/2<=0 and x-i/2>0:
        aa=x-i/2
        bb=0
    else:
        aa=x-i/2
        bb=y-i/2
    ab=aa*a+bb*b+i*c
    ans=min(ans,ab)
print(int(ans))

Measured memory_bytes: 3064
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
ll n, a[3005], sum;
int main() {
   cin >> n;
   for (int i=0; i<n; i++) {
       cin >> a[i]; sum+=a[i];
   }
   
   cout << sum-n;
   
}

Measured memory_bytes: 3616
use std::io::*;

fn read(s: &mut StdinLock) -> usize {
    s.by_ref().bytes().map(|c| c.unwrap() as char)
        .take_while(|c| !c.is_whitespace())
        .skip_while(|c| c.is_whitespace())
        .fold(0, |a, x| (x as u8 - b'0') as usize + a * 10)
}
fn read_line_char(s: &mut StdinLock) -> Vec<char> {
    s.by_ref().bytes().map(|c| c.unwrap() as char)
        .take_while(|c| !c.is_whitespace())
        .skip_while(|c| c.is_whitespace())
        .collect()
}
fn read_char(s: &mut StdinLock) -> char {
    s.by_ref().bytes().map(|c| c.unwrap() as char)
        .take_while(|c| !c.is_whitespace())
        .skip_while(|c| c.is_whitespace())
        .collect::<Vec<char>>()[0]
}

fn main() {
    let s = stdin();
    let mut s = s.lock();
    let mut answer = read_line_char(&mut s);
    let mut left: Vec<char> = Vec::new();
    let q = read(&mut s);
    let mut sw = false;
    for _ in 0..q {
        if read_char(&mut s) == '1' {
            sw = !sw;
        } else {
            let key = read_char(&mut s);
            if (key == '1' && !sw) || (key =='2' && sw) {
                left.push(read_char(&mut s));
            } else {
                answer.push(read_char(&mut s));
            }
        }
    }
    if sw {
        answer = answer.iter().rev().map(|x| *x).collect::<Vec<char>>();
        answer.append(&mut left);
        println!("{}", answer.iter().map(|x| *x).collect::<String>());
    } else {
        left = left.iter().rev().map(|x| *x).collect::<Vec<char>>();
        left.append(&mut answer);
        println!("{}", left.iter().map(|x| *x).collect::<String>());
    }
}

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

using namespace std;

typedef long long ll;
typedef pair<int, int> ii;
typedef pair<ll, ll> pll;
typedef vector<ii> vii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
typedef vector<vll> vvll;

#define getBit(x,i) (x&(1<<i))
#define setBit(x,i) (x|(1<<i))
#define mem(A,N) memset(A,N,sizeof(A))
#define pb push_back
#define pf push_front
#define ppb pop_back
#define ppf pop_front
#define mp make_pair
#define rep(i, x, y)  for(int i = x; i < y; ++i)
#define Rep(i, x, y)  for(int i = x; i <= y; ++i)
#define srep(i, x, y) for(int i = x; i > y; --i)
#define sRep(i, x, y) for(int i = x; i >= y; --i)
#define all(v) v.begin(),v.end()
#define Sort(x) sort(x.begin(), x.end())
#define f1(i,n) for (int i=1; i<=n; i++)
#define f0(i,n) for (int i=0; i<n; i++)
#define sz(x) ((int)(x).size())
#define len(x) ((int)(x).length())
#define fi first
#define se second

#define linf 0x7FFFFFFFFFFFFFFF
#define inf 0x7FFFFFFF
#define mod 1000000007
#define eps 1e-9
#define Pi 3.14159265358979323846

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define write(x) cerr << #x << " = " << (x) << ", ";
#define writeI0 cerr << "i = " << 0 << ", ";
#define dumpI0 cerr << "i = " << 0 << endl;
#define printSet(s) for(auto it = s.begin(); it!=s.end(); it++) (it==s.begin())? cout << *it : cout << ' ' << *it; cout << endl;
#define printPairSet(s) for(auto it = s.begin(); it!=s.end(); it++) (it==s.begin())? cout << '(' << it->first << ", " << it->second << ')' : cout << " (" << it->first << ", " << it->second << ')'; cout << endl;
#define printVector(x) for(auto it = x.begin(); it!=x.end(); it++) (it==x.begin())? cout << *it : cout << ' ' << *it; cout << endl;
#define printArray(a,x,y) for(auto it = a+x; it != a+y; it++) (it==a+x)? cout << *it : cout << ' ' << *it; cout << endl;
#define PrintArray(a,x,y) for(auto it = a+x; it != a+y+1; it++) (it==a+x)? cout << *it : cout << ' ' << *it; cout << endl;

// ***************** End Of Template ********************

ll n, m, k;

int main() {
    ios_base::sync_with_stdio(false); cin.tie(NULL);
    ll t1;
    cin >> n >> m >> k;

    if (n) {
        t1 = min(k, n);
        k -= t1;
        n -= t1;
    }

    if (m) {
        t1 = min(k, m);
        k -= t1;
        m -= t1;
    }

    cout << n << ' ' << m;
    return 0;
}


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

int main() {
    int N, i;
    int dp[100001];
    cin >> N;
    dp[0] = 0;
    for (i = 1; i <= N; i++) {
        dp[i] = dp[i - 1] + 1;
        for (int j = 6; j <= i; j *= 6) {
            dp[i] = min(dp[i], dp[i - j] + 1);
        }
        for (int j = 9; j <= i; j *= 9) {
            dp[i] = min(dp[i], dp[i - j] + 1);
        }
    }
    cout << dp[N] << endl;

    return 0;
}


Measured memory_bytes: 640
#include<stdio.h>
#include<iostream>
#include<vector>
#include<math.h>
#include<queue>
#include<map>
#include<algorithm>
#include<string.h>
#include<functional>
#include<limits.h>
#include<stdlib.h>
#include<cmath>
#include<cstring>
#include<set>
#include<climits>
using namespace std;

#define intmax INT_MAX
#define lmax LONG_MAX
#define uintmax UINT_MAX
#define ulmax ULONG_MAX
#define llmax LLONG_MAX
#define ll long long
#define rep(i,a,N) for((i)=(a);(i)<(N);(i)++)
#define rrp(i,N,a) for((i)=(N)-1;(i)>=(a);(i)--)
#define llfor ll i,j
#define sc(a) cin>>a
#define pr(a) cout<<a<<endl
#define pY puts("YES")
#define pN puts("NO")
#define py puts("Yes")
#define pn puts("No")
#define pnn printf("\n")
#define sort(a) sort(a.begin(),a.end())
#define push(a,b) (a).push_back(b)
#define llvec vector<vector<ll>>
#define charvec vector<vector<char>>
#define size(a,b) (a,vector<ll>(b))
#define llpvec vector<pair<ll,ll>>
/*繰り上げ除算*/ll inc(ll x,ll y){ll ans=x/y;if(x%y!=0)ans++;return ans;}
/*最大公約数*/ll gcd(ll x,ll y){return y?gcd(y,x%y):x;}
/*最小公倍数*/ll lcm(ll x,ll y){return x/gcd(x,y)*y;}
/*n乗*/ll llpow(ll x,ll n){ll i,ans=1;rep(i,0,n)ans*=x;return ans;}
/*階乗*/ll fact(ll x){ll i,ans=1;rep(i,0,x)ans*=(x-i);return ans;}
/*nCr*/ll ncr(ll n,ll r){return fact(n)/fact(r)/fact(n-r);}
/*nPr*/ll npr(ll n,ll r){return fact(n)/fact(n-r);}
/*primejudge*/bool prime(ll a){if(a<=1)return false;ll i;for(i=2;i*i<=a;i++){if(a%i==0)return false;}return true;}
llfor;///////////////////////////////////////////////////////////
int main(){
 ll k,n;
 sc(n);sc(k);
 vector<ll> h(n+1);ll a,ans=0;
 rep(i,0,n){sc(a);h[i]=a;}
 sort(h);
 rrp(i,n+1,0){
  //cout<<i<<" "<<ans<<" "<<h[i]<<" "<<k<<endl;
  if(k>0){k--;continue;}
  else ans+=h[i];
 }
 pr(ans);
return 0;}

Measured memory_bytes: 4800
import math

h,w,k = map(int,input().split())
s = [str(input()) for i in range(h)]
ans = h * w

if h == 1:
    print(math.ceil("1".count(s[0])/k))
    exit()

for i in range(2 ** (h-1)):
    ss = str(format(i,"b").zfill(h-1))
    cnt = 0
    zerocnt = 0
    key = 1
    for j in range(len(ss)):
        if ss[j] == "0":
            zerocnt += 1
    now = [0 for i in range(zerocnt+1)]

    for j in range(w):
        next = []
        num = 0
        for n in range(h):
            if s[n][j] == "1":
                num += 1
            if num > k:
                key = 0
            if n < h-1 and ss[n] == "0":
                next.append(num)
                num = 0
        next.append(num)
  #        print(next,now)
        keykey = 1
        for n in range(zerocnt+1):
            if keykey:
                if now[n] + next[n] > k:
                    now = next
                    cnt += 1
                    keykey = 0
                else:
                    now[n] += next[n]
  #    print(now)
  #    print(ans,cnt,zerocnt)
    if key:ans = min(ans,cnt+zerocnt)
print(ans)

Measured memory_bytes: 50268
n = int(input())
numList  = [int(input()) for _ in range(n)]
maxVal = max(numList)
workList = numList[:]
workList.remove(maxVal)
secondVal = max(workList)
for num in numList:
  if num != maxVal:
    print(maxVal)
  else:
    print(secondVal)

Measured memory_bytes: 14164
#include <iostream>
#include <cmath>

using namespace std;

int main(int argc, char const *argv[]) {
	int x,a,b;
	std::cin >> x >> a >> b;
	if (abs(x-a) < abs(x-b)) {
		std::cout << "A" << '\n';
	}
	else {
		std::cout << "B" << '\n';
	}
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string>
#include<queue>
#include<stack>
#include<vector>
#include<list>
#include<math.h>
using namespace std;

#define ll long long

int main(){
  ll x;
  cin >> x;
  ll ans = x/11*2;
  if(x%11>6){
    ans+=2;
  }else if(x%11!=0){
    ans++;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#[allow(unused_imports)]
use itertools::Itertools;
use proconio::input;
#[allow(unused_imports)]
use proconio::marker::*;

fn main() {
    input! {
        n: usize,
        m: usize,
        ab: [(Usize1, Usize1); n - 1 + m],
    }
    let mut t = vec![vec![]; n];
    let mut p = vec![std::collections::BTreeSet::new(); n];
    let mut res = vec![0; n];
    for (a, b) in ab {
        t[a].push(b);
        p[b].insert(a);
    }
    let r = p
        .iter()
        .enumerate()
        .filter(|(_, p)| p.is_empty())
        .map(|(i, _)| i)
        .next()
        .unwrap();

    let mut q = std::collections::VecDeque::new();
    q.push_back(r);
    while let Some(u) = q.pop_front() {
        for &v in &t[u] {
            if p[v].len() == 1 {
                res[v] = u + 1;
                q.push_back(v);
            } else {
                p[v].remove(&u);
            }
        }
    }

    for res in res {
        println!("{}", res);
    }
}


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

#define MAX 2000000
#define INFTY (1 << 30)

int H,A[MAX+1];

int left(int i){return 2 * i;};
int right(int i){return 2 * i + 1;};

void maxHeapify(int i){
    int l = left(i);
    int r = right(i);
    int largest;

    if(l <= H && A[l] > A[i]){
        largest = l;
    } else{
        largest = i;
    }
    if(r <= H && A[r] > A[largest]){
        largest = r;
    }

    if(largest != i){
        swap(A[i],A[largest]);
        maxHeapify(largest);
    }
}

int extract(){
    int maxv;
    if(H < 1)return -INFTY;
    maxv = A[1];
    A[1] = A[H--];
    maxHeapify(1);
    return maxv;
}

void increaseKey(int i, int key){
    if(key < A[i]) return;
    A[i] = key;
    while(i > 1 && A[i/2] < A[i]){
        swap(A[i],A[i/2]);
        i = i/2;
    }
}

void insert(int key){
    H++;
    A[H] = -INFTY;
    increaseKey(H, key);
}

int main(){
    int key;
    char com[10];

    while(1){
        scanf("%s",com);
        if(com[0] == 'e' && com[1] == 'n') break;
        if(com[0] == 'i'){
            scanf("%d",&key);
            insert(key);
        } else{
            printf("%d\n",extract());
        }
    }

    return 0;
}


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

int main()
{
    int n, q, t;
    string name;
    queue<pair<string,int> > Q;
    cin >> n >> q;

    for(int i=0; i<n; i++)
    {
        cin >> name >> t;
        Q.push(make_pair(name,t));
    }
    pair<string,int> u;
    int elaps = 0, a;

    while(!Q.empty())
    {
        u = Q.front();Q.pop();
        a = min(u.second,q);
        u.second -= a;
        elaps += a;
        if(u.second > 0)
            Q.push(u);
        else
            cout << u.first << " " << elaps << endl;
    }
    return 0;
}

Measured memory_bytes: 6372
#include<bits/stdc++.h>
using namespace std;
#define ll long long
ll arr[200009];
int main()
{
    ll n,t,m,x,i,j,k,maxi = INT_MIN,mini = INT_MAX,flag =0,sum=0;
    vector<ll>vi;
    cin>>n;
    for(i= 0 ;i<n ;i++)
    {
        cin>>j>>k;
        sum+=k-j+1;
    }
    cout<<sum<<endl;
    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
#define rep(i, n) for (int i = (int)(0); i < (int)(n); ++i)
#define reps(i, n) for (int i = (int)(1); i <= (int)(n); ++i)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rreps(i, n) for (int i = ((int)(n)); i > 0; i--)
#define irep(i, m, n) for (int i = (int)(m); i < (int)(n); ++i)
#define ireps(i, m, n) for (int i = (int)(m); i <= (int)(n); ++i)
#define FOR(e, c) for (auto &e : c)
#define SORT(v, n) sort(v, v + n);
#define vsort(v) sort(v.begin(), v.end());
#define rvisort(v) sort(v.begin(), v.end(), greater<int>());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
#define replace_all(s, b, a) replace(s.begin(),s.end(), b, a);
// #define int long long
#define PI (acos(-1))
#define FILL(v, n, x) fill(v, v + n, x);
#define sz(x) int(x.size())
 
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using ul = unsigned long;
 
 
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
 
int GCD(int a, int b) { return b ? GCD(b, a%b) : a; }
int LCM(int a, int b) { return a * b / GCD(a, b); }

const int MOD = 1e9+7;
const int INF = 1e9;
const ll LINF = 1e18;

// dp[i][j][k][l]:= i文字目までで、最後から3文字目までの文字列を見た時に条件を満たすものの数
int dp[101][4][4][4];

signed main()
{
  int n;
  cin>>n;
  dp[0][3][3][3]=1;
  
  rep(len,n){
    rep(c1,4){
      rep(c2,4){
        rep(c3,4){
          if(dp[len][c1][c2][c3]==0) continue;
          
          rep(a,4){
            if(a==2&&c1==1&&c2==0) continue;
            if(a==2&&c1==0&&c2==1) continue;
            if(a==1&&c1==2&&c2==0) continue;
            if(a==2&&c1==1&&c3==0) continue;
            if(a==2&&c2==1&&c3==0) continue;
            
            dp[len+1][a][c1][c2]+=dp[len][c1][c2][c3];
            dp[len+1][a][c1][c2]%=MOD;
          }
          
        }
      }
    }
  }
  
  int ans=0;
  rep(c1,4){
    rep(c2,4){
      rep(c3,4){
        ans+=dp[n][c1][c2][c3];
        ans%=MOD;
      }
    }
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0;i<(n);i++)
#define REP2(i,a,b) for(int i=(a);i<(b);i++)
#define ALL(v) (v).begin(),(v).end()
#define INF 2e9
typedef long long ll;

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

  REP2(i,1,n+1){
    if(i*1.08>=n && i*1.08<n+1){
      cout<<i<<endl;
      return 0;
    }
  }

  cout<<":("<<endl;

  return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdint.h>
#include <tuple>
#include <utility>
#include <vector>

using namespace std;

typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
static const double EPS = 1e-12;
static const double PI = acos(-1.0);
static const ll MOD = 1000000007;

#define FOR(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define ALL(a) (a).begin(), (a).end()
#define DEBUG(x) cout << #x << ": " << x << endl

void solve(long long S, long long W) {
  if (S <= W) {
    cout << "unsafe" << endl;
  } else {
    cout << "safe" << endl;
  }
}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You
// use the default template now. You can remove this line by using your custom
// template)
int main() {
  long long S;
  scanf("%lld", &S);
  long long W;
  scanf("%lld", &W);
  solve(S, W);
  return 0;
}


Measured memory_bytes: 3168
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <climits>
#include <vector>
#include <map>
#include <set>
#include <list>
#include <stack>
#include <queue>
#include <algorithm>
#include <iostream>
#include <string>

#define REP(i,n) for(long long i=0;i<n;++i)
#define REPR(i,n) for(long long i=n;i>=0;--i)
#define REPI(itr,v) for(auto itr=v.begin();itr!=v.end();++itr)
#define REPIR(itr,v) for(auto itr=v.rbegin();itr!=v.rend();++itr)
#define FOR(i,a,b) for(long long i=a;i<b;++i)
#define SORT(v,n) sort(v, v+n)
#define SORTV(v) sort(v.begin(), v.end())
#define ALL(v) v.begin(),v.end()
#define llong long long
#define INF 999999999
#define MOD 1000000007
#define pb push_back
#define pf push_front
#define MP make_pair
#define SV(v) {for(long long sitr=0;sitr<v.size();++sitr){cin>>v[sitr];}}

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

using namespace std;

typedef pair<int,int> pii;

int main(){

  string s;
  cin >> s;

  bool yymm = true;
  bool mmyy = true;
  if(stoi(s.substr(2,2)) == 0 || stoi(s.substr(2,2)) > 12 ){
    yymm = false;
  }
  if(stoi(s.substr(0,2)) == 0 || stoi(s.substr(0,2)) > 12){
    mmyy = false;
  }

  if(yymm && mmyy){
    cout << "AMBIGUOUS\n";
  }else if(yymm){
    cout << "YYMM\n";
  }else if(mmyy){
    cout << "MMYY\n";
  }else{
    cout << "NA\n";
  }

  return 0;
}



Measured memory_bytes: 384
#!usr/bin/env python3
from collections import defaultdict, deque, Counter, OrderedDict
from bisect import bisect_left, bisect_right
from functools import reduce, lru_cache
from heapq import heappush, heappop, heapify

import itertools
import math, fractions
import sys, copy

def L(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline().rstrip())
def SL(): return list(sys.stdin.readline().rstrip())
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI1(): return [int(x) - 1 for x in sys.stdin.readline().split()]
def LS(): return [list(x) for x in sys.stdin.readline().split()]
def R(n): return [sys.stdin.readline().strip() for _ in range(n)]
def LR(n): return [L() for _ in range(n)]
def IR(n): return [I() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def LIR1(n): return [LI1() for _ in range(n)]
def SR(n): return [SL() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]

def perm(n, r): return math.factorial(n) // math.factorial(r)
def comb(n, r): return math.factorial(n) // (math.factorial(r) * math.factorial(n-r))

def make_list(n, *args, default=0): return [make_list(*args, default=default) for _ in range(n)] if len(args) > 0 else [default for _ in range(n)]

dire = [[1, 0], [0, 1], [-1, 0], [0, -1]]
dire8 = [[1, 0], [1, 1], [0, 1], [-1, 1], [-1, 0], [-1, -1], [0, -1], [1, -1]]
alphabets = "abcdefghijklmnopqrstuvwxyz"
ALPHABETS = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
MOD = 1000000007
INF = float("inf")

sys.setrecursionlimit(1000000)

class UnionFind:
    def __init__(self, n):
        self._parent, self._rank, self._group_size = [i for i in range(n)], [0 for _ in range(n)], [1 for _ in range(n)]
        self.num_of_groups = n

    def find(self, x):
        vs = []
        while self._parent[x] != x:
            vs.append(x)
            x = self._parent[x]
        for v in vs: self._parent[v] = x
        return x

    def union(self, x, y):
        px, py = self.find(x), self.find(y)
        if px == py: return
        if self._rank[px] < self._rank[py]:
            self._parent[px] = py
            self._group_size[py] += self._group_size[px]
        else:
            self._parent[py] = px
            self._group_size[px] += self._group_size[py]
        if self._rank[px] == self._rank[py]: self._rank[py] += 1
        self.num_of_groups -= 1

    def is_same(self, x, y): return self.find(x) == self.find(y)
    def group_size(self, x): return self._group_size[self.find(x)]


def main():
    N, Q = LI()
    TUV = LIR(Q)

    uf = UnionFind(N+1)

    for t, u, v in TUV:
        if t == 0:
            uf.union(u, v)
        else:
            print(int(uf.is_same(u, v)))

if __name__ == '__main__':
    main()

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

int main() {
  ll N;
  cin>>N;
  vector<vector<pair<ll,ll>>> list(N);
  for(ll i=0;i<N;i++){
    ll A;
    cin>>A;
    for(ll j=0;j<A;j++){
      ll x,y;
      cin>>x>>y;
      list.at(i).push_back({x-1,y});
    }
  }
  
  ll ans=0;
  
  for(ll tmp=0;tmp<(1<<15);tmp++){
    bitset<15> s(tmp);
    bool judge=true;
    ll count=0;
    for(ll i=0;i<N;i++){
      if(s.test(i)==1){//iは正直
        count++;
        for(ll j=0;j<list.at(i).size();j++){
          if(s.test(list.at(i).at(j).first) != list.at(i).at(j).second){
            judge=false;
            break;
          }
        }
      }
      
    }
    if(judge){ans=max(count,ans);}
  }
  cout<<ans<<endl;
}





Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
#include <cmath>
#include <bitset>
#include <iomanip>
#include <stack>
#include <list>
#include <map>
#include <unordered_map>
#include <chrono>
#include <numeric>
using namespace std;
using ll = long long;
const ll INF = (ll)1e18+1;
const ll DIV = 1000000007;
//#define TEST
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
#ifdef TEST
    chrono::system_clock::time_point start, end;
    start = chrono::system_clock::now();
#endif
    long AB, BC, CA;
    cin >> AB >> BC >> CA;
    cout << AB * BC /2 << endl;
#ifdef TEST
    end = chrono::system_clock::now();
    cerr << static_cast<double>(chrono::duration_cast<chrono::microseconds>(end - start).count() / 1000.0) << "[ms]" << endl;
#endif
    return 0;
}

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

int main(){
  int n;
  cin >> n;
  double k=0;
  
  for(int i=0;i<n;i++){
    double x;  string y;
    cin >> x >> y;
    if(y=="BTC")
      x*=380000;
    k+=x;
  }
  printf("%.10f",k);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
struct fast_ios { fast_ios(){ cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;
#define FOR(i, begin, end) for(int i=(begin);i<(end);i++)
#define REP(i, n) FOR(i,0,n)
#define IFOR(i, begin, end) for(int i=(end)-1;i>=(begin);i--)
#define IREP(i, n) IFOR(i,0,n)
#define Sort(v) sort(v.begin(), v.end())
#define Reverse(v) reverse(v.begin(), v.end())
#define all(v) v.begin(),v.end()
#define SZ(v) ((int)v.size())
#define Lower_bound(v, x) distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) distance(v.begin(), upper_bound(v.begin(), v.end(), x))
#define chmax(a, b) a = max(a, b)
#define chmin(a, b) a = min(a, b)
#define bit(n) (1LL<<(n))
#define debug(x) cout << #x << "=" << x << endl;
#define vdebug(v) { cout << #v << "=" << endl; REP(i_debug, v.size()){ cout << v[i_debug] << ","; } cout << endl; }
#define mdebug(m) { cout << #m << "=" << endl; REP(i_debug, m.size()){ REP(j_debug, m[i_debug].size()){ cout << m[i_debug][j_debug] << ","; } cout << endl;} }
#define pb push_back
#define fi first
#define se second
#define int long long
#define INF 1000000000000000000
template<typename T> istream &operator>>(istream &is, vector<T> &v){ for (auto &x : v) is >> x; return is; }
template<typename T> ostream &operator<<(ostream &os, vector<T> &v){ for(int i = 0; i < v.size(); i++) { cout << v[i]; if(i != v.size() - 1) cout << endl; }; return os; }
template<typename T1, typename T2> ostream &operator<<(ostream &os, pair<T1, T2> p){ cout << '(' << p.first << ',' << p.second << ')'; return os; }
template<typename T> void Out(T x) { cout << x << endl; }
template<typename T1, typename T2> void chOut(bool f, T1 y, T2 n) { if(f) Out(y); else Out(n); }

using vec = vector<int>;
using mat = vector<vec>;
using Pii = pair<int, int>;
using v_bool = vector<bool>;
using v_Pii = vector<Pii>;

//int dx[4] = {1,0,-1,0};
//int dy[4] = {0,1,0,-1};
//char d[4] = {'D','R','U','L'};

const int mod = 1000000007;
//const int mod = 998244353;



signed main(){

    int N, D; cin >> N >> D;
    int ans = 0;
    REP(i, N){
        int x, y; cin >> x >> y;
        if(x * x + y * y <= D * D) ans++;
    }
    Out(ans);

    return 0;
}


Measured memory_bytes: 3656
#include "bits/stdc++.h"
// Custom Header {{{
#define ALL(x) x.begin(), x.end()
#define rep(i, s, n)      for(int i(s); i < int(n); ++i)
#define endl '\n'
#ifndef YDK
#define eprintf(...)
#endif
using namespace std;
using i64 = long long;
using pii = pair<i64, i64>;
template<class A, class B>inline bool chmax(A &a, const B &b){return b>a ? a=b,1 : 0;}
template<class A, class B>inline bool chmin(A &a, const B &b){return b<a ? a=b,1 : 0;}
constexpr const int INF  = 0x3f3f3f3f;
constexpr const i64 LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr const int MOD  = int(1e9) + 7;
// }}}

// Library {{{
// ユークリッドの互除法により |a| と |b| の最大公約数を求める。
// (a == 0)なら b, (b == 0)なら a を返す。
i64 GCD(i64 a, i64 b)
{
    a = abs(a); b = abs(b);
    if (a > b) swap(a, b);
    while(b > 0) {
        i64 r = a % b;
        a = b;
        b = r;
    }
    return a;
}
// |a| と |b| の最小公倍数を求める。
i64 LCM(i64 a, i64 b)
{
    return abs(a) / GCD(a,b) * abs(b);
}
// }}}


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

    i64 lcm = 1;
    rep(i, 0, n) {
        int a; cin >> a;
        lcm = LCM(lcm, a);
    }

    cout << (lcm) << endl;
    return 0;
}



Measured memory_bytes: 3092
#define _USE_MATH_DEFIMES
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cctype>
#include <climits>
#include <clocale>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <regex>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

const int MOD = 1'000'000'007;
const int INF = 1'000'000'000; //1e9
const int NIL = -1;
const long long LINF = 1'000'000'000'000'000'000; // 1e18
const long double EPS = 1E-10;

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







long long floor_sum(long long n, long long m, long long a, long long b) {
    long long ans(0);
    if(a >= m){
        ans += (n - 1) * n / 2 * (a / m);
        a %= m;
    }
    if(b >= m){
        ans += n * (b / m);
        b %= m;
    }

    long long y_max((a * n + b) / m), x_max((y_max * m - b));
    if (y_max == 0) return ans;
    ans += (n - (x_max + a - 1) / a) * y_max;
    ans += floor_sum(y_max, a, m, (a - x_max % a) % a);
    return ans;
}

int main(){
    int T; std::cin >> T;
    {
        int N, M, A, B;
        for(int i(0); i < T; ++i){
            std::cin >> N >> M >> A >> B;
            std::cout << floor_sum(N, M, A, B) << "\n";
        }
    }
    return 0;
}


Measured memory_bytes: 3604
h, w = map(int, input().split())
s = []
for i in range(h):
    inp = input()
    s.append(list(inp))

for i in range(h):
    for j in range(w):
        if s[i][j] == '#':
            chk = False
            # UP
            if not i == 0:
                if s[i-1][j] == '#':
                    chk = True
            # DOWN
            if not i == h-1:
                if s[i+1][j] == '#':
                    chk = True
            # LEFT
            if not j == 0:
                if s[i][j-1] == '#':
                    chk = True
            # RIGHT
            if not j == w-1:
                if s[i][j+1] == '#':
                    chk = True
            if chk:
                pass
            else:
                print('No')
                exit()

print('Yes')

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
#define ALL(x) x.begin(),x.end()
#define rep(i,n) for(int i=0;i<n;i++)
#define debug(v) cout<<#v<<":";for(auto x:v){cout<<x<<' ';}cout<<endl; 
#define INF 1000000000
#define mod 1000000007
typedef long long ll;
const ll LINF = 1001002003004005006ll;
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
struct UnionFind{
    vector<ll> par;
    vector<ll> siz;

    void init(ll n){
        for(ll i=0;i<n;i++){
            par.push_back(i);
            siz.push_back(1);
        }
    }
    ll root(ll x){
        //根を返す
        if(par[x]==x){
            return x;
        }
        else{
            return (par[x]=root(par[x]));
        }
    }
    bool sameParent(ll x,ll y){
        return(root(x)==root(y));
    }
    void unite(ll x, ll y){
        x=root(x);y=root(y);
        if(x==y)    return;
        //データ構造->小を大にくっつける
        if(siz[x]<siz[y]) swap(x,y);
        siz[x] += siz[y];
        par[y]=x;
    }

    ll size(ll x){
        return siz[root(x)];
    }
};
int main(){
    int n,m;cin>>n>>m;
    vector<vector<int>> lang(m);
    rep(i,n){
        int k;cin>>k;
        while(k--){
            int L;cin>>L;L--;
            lang[L].push_back(i);
        }
    }
    UnionFind uf;
    uf.init(n);
    rep(i,m){
        if(lang[i].size()>=2)for(int j=1;j<lang[i].size();j++){
            uf.unite(lang[i][0],lang[i][j]);
        }
    }
    int cnt=0;
    rep(i,n){
        if(i==uf.par[i]) cnt++;
    }
    cout<<(cnt==1?"YES":"NO")<<endl;
    return 0;
}


Measured memory_bytes: 5364
#include <bits/stdc++.h>
using namespace std;
string s[50];
int main()
{
	int n;
	cin>>n;
	vector<int> cnt(26,1e9);
	for(int i=0;i<n;i++)
	{
		cin>>s[i];
		vector<int> v(26,0);
		for(int j=0;j<s[i].size();j++)
		{
			v[s[i][j]-'a']++;
		}
		for(int j=0;j<26;j++)
		{
			cnt[j]=min(cnt[j],v[j]);
		}
	}
	for(int i=0;i<26;i++)
	{
		cout<<string(cnt[i],i+'a');
	}
	cout<<endl;
	return 0;
}

Measured memory_bytes: 256
//  Created by conan1024hao in 2019.
//  Copyright © 2019 conan1024hao. All rights reserved.
//  専用ライブラリです、自由にコピーして構いません。
//  感谢看我的代码！Wechat:conan1024hao QQ:810396815
#pragma GCC optimize ("O3")
#include <iostream>
#include <iomanip>
#include <istream>
#include <ostream>
#include <sstream>
#include <iterator>
#include <vector>
#include <algorithm>
#include <queue>
#include <deque>
#include <list>
#include <stack>
#include <map>
#include <set>
#include <utility>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <string>
#include <ctime>
#include <cctype>
#include <cstdlib>
#define INF 10e16
#define MOD 1000000007
#define rep(i, a, n) for (ll i = a; i < (ll)(n); i++)
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define mmax(x,y)(x>y?x:y)
#define mmin(x,y)(x<y?x:y)
#define chmax(x,y) x=mmax(x,y)
#define chmin(x,y) x=mmin(x,y)
#define all(x) (x).begin(),(x).end()
#define siz(x) (ll)(x).size()
#define PI acos(-1.0)
using namespace std;
typedef long long int ll;
typedef pair<ll,ll>P;
long long GCD(long long a, long long b) { return b ? GCD(b, a%b) : a; }
long long LCM(long long a, long long b)  {return a/GCD(a,b)*b;}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
ll cmp(pair<ll,string>a,pair<ll,string> b){
        if(a.fi!=b.fi)
        return a.fi<b.fi;
        else
        return a.se<b.se;
}

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

//---------------------------------------------------------------------------
int main(){//問題をちゃんと見ろ!!!!!!!!!!!!!!!!!      llか??????????
    cin.tie(0);
    ios::sync_with_stdio(false);
    //-------------------------------
    int a,b,x;cin>>a>>b>>x;
    if(a+b>=x&&a<=x)
        cout<<"YES"<<endl;
    else
        cout<<"NO"<<endl;
    
    
    //-------------------------------
    return 0;
}
//---------------------------------------------------------------------------


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

#define pb  push_back
#define mp  make_pair
#define ll  long long
#define itr iterator

typedef pair<ll,ll> pii;

const ll MAX=2e5+9;
const ll INF=1e12;

ll N,l,r,arr[MAX];

ll nxt(ll X)
{
	ll res=(l/X)*X;
	while(res<l)
		res+=X;
	return res;
}

ll pre(ll X)
{
	ll res=(r/X)*X;
	while(res>r)
		res-=X;
	return res;
}

signed main()
{
	ios_base::sync_with_stdio(false);

	cin>>N;
	for(int A=1;A<=N;A++)
		cin>>arr[A];
	if(arr[N]==2)
		l=2,r=3;
	else if(arr[N]==1)
		l=2,r=2;
	else
		return cout<<-1,0;
	for(int A=N-1;A>=1;A--)
	{
		l=nxt(arr[A]);
		r=pre(arr[A]);
		r+=arr[A]-1;
		if(l>r)
			return cout<<-1,0;
	}
	cout<<l<<" "<<r;
	return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define mod 26
using namespace std;
string str;
 
string solve(){
  string res;
  stack <int> st;
  for(int i=0;i<str.size();i++){
    int cnt=0;
    while(str[i]=='+'||str[i]=='-')cnt+=(str[i]=='+')-(str[i]=='-'),i++;
    
    if(cnt) res+=((str[i]-'A')+cnt%mod+mod)%mod+'A';
    else if(str[i]!='['&&str[i]!=']')res += str[i];
    if(str[i]=='?')res[res.size()-1]='A';

    if(str[i]=='[')st.push(res.size());
    if(str[i]==']'){
      reverse(res.begin()+st.top(),res.end());
      st.pop();
    }
  }
  return res;
}
 
 
int main(){
  while(1){
    cin>>str;
    if(str==".")break;
    cout <<solve()<<endl;
  }
  return 0;
}

Measured memory_bytes: 1192
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
using namespace std;
using ll = long long;

#define rep(i,n) for(ll i=0;i<ll(n);i++)
#define YESNO(T) if(T){cout<<"YES"<<endl;}else{cout<<"NO"<<endl;}
#define yesno(T) if(T){cout<<"yes"<<endl;}else{cout<<"no"<<endl;}
#define YesNo(T) if(T){cout<<"Yes"<<endl;}else{cout<<"No"<<endl;}

const ll INF = 1LL << 60;
const ll MOD = 1e9 + 7;
const double pi = 3.14159265358979;



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

    ll n,m;
    cin >> n >> m;
    vector<vector<char>> a(n, vector<char>(n));
    for (ll i = 0;i < n;i++){
        for (ll j = 0;j < n;j++){
            cin >> a[i][j];
        }
    }
    vector<vector<char>> b(m, vector<char>(m));
    for (ll i = 0;i < m;i++){
        for (ll j = 0;j < m;j++){
            cin >> b[i][j];
        }
    }

    bool ans = false;
    bool t = true;

    for (ll x = 0; x <= n-m; x++){
        for (ll y = 0; y <= n-m; y++){
            for (ll i = 0; i < m; i++){
                for (ll j = 0; j < m; j++){
                    if (a[i+x][j+y] != b[i][j]){
                        t = false;
                        goto out1;
                    }
                }
            }
            out1:
            if (t){
                ans = true;
                goto out2;
            }
            t = true;
        }
    }
    out2:

    YesNo(ans);
}

Measured memory_bytes: 3612
#include <vector>
#include <iostream>
#include <algorithm>
#include <functional>
#include <string>
#include <limits.h>
#include <cmath>
#include <queue>
#include <map>
#include <iomanip>
#include <random>
#include <fstream>
#define rep(i, n) for (int i = 0; i < n; i++)
#define PI 3.14159265358979323846
#define MOD 1000000007
using namespace std;
using ll = long long;

const int MAX = 1000000;

ll fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
  fac[0] = fac[1] = 1;
  finv[0] = finv[1] = 1;
  inv[1] = 1;
  for (int i = 2; i < MAX; i++){
    fac[i] = fac[i - 1] * i % MOD;
    inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
    finv[i] = finv[i - 1] * inv[i] % MOD;
  }
}

// 二項係数計算
long long COM(int n, int k){
  if (n < k) return 0;
  if (n < 0 || k < 0) return 0;
  return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

ll gcd(ll a, ll b)
{
  ll r;
  while ((r = a % b))
  {
    a = b;
    b = r;
  }
  return b;
}

template <class T> struct cord{
  T x,y;
};

template <class T> double dist(cord<T> a, cord<T> b){
  T dx=a.x-b.x;
  T dy=a.y-b.y;
  return sqrt(dx*dx+dy*dy);
}

int main()
{

  //cout << fixed << setprecision(10);

  string temp,s;cin >> temp >> s;
  cout << "A";
  cout << s[0];
  cout << "C";


  return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
#define rep(i,n) for(int i=0;i<(n);i++)

using namespace std;

#define ll longlong

int main(){
   int h,w,a,b;
   cin>>h>>w>>a>>b;
   rep(i,h){
       rep(j,w){
           if(i<b^j<a) cout<<0;//xorを取る
           else cout<<1;
       }
       cout<<endl;
   }
}

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

constexpr int N=1000;

int lcs(string x, string y){
   int m=x.size();
   int n=y.size();
   int c[N+1][N+1];
   
   for(int i=0; i<N; i++)
      for(int j=0; j<N; j++)
         c[i][j]=0;
   int ans=0;
   for(int i=1; i<=m; i++){
      for(int j=1; j<=n; j++){
         if(x[i-1]==y[j-1]) c[i][j]=c[i-1][j-1]+1;
         else c[i][j]=max(c[i-1][j], c[i][j-1]);
         ans=c[i][j];
      }
   }
   return ans;
}

int main(){
   string x, y;
   int n;
   cin >> n;
   for(int i=0; i<n; i++){
      cin >> x >> y;
      cout << lcs(x, y) << endl;
   }

   return 0;
}
   


Measured memory_bytes: 7120
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define mp make_pair
#define pb push_back
#define ff first
#define ss second
#define deb(x) cout<<x<<"\n";
#define deb(x,y) cout<<x<<" "<<y<<"\n";
#define deb(x,y,z) cout<<x<<" "<<y<<" "<<z<<"\n";
#define ok cout<<"OK";
int main()
{
    ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
    ll j,n,x,y;
    cin>>n>>x>>y;
    ll a[n+1]={};
    ll i=1;
    while(i<n)
    {
        j=i+1;
        while(j<=n)
        {
            a[min(j-i,1+abs(j-y)+abs(x-i))]++;
            j++;
        }
        i++;
    }
    i=1;
    while(i<n)
    {
        cout<<a[i]<<"\n";
        i++;
    }
}


Measured memory_bytes: 256
N,K=gets.split(/ /).map{|s| s.to_i}
A = []
1.upto(K) do |i|
    d = gets.to_i
    gets.split(/ /).map{|s| s.to_i }.each do |n|
        A[n] = (A[n] || 0) + 1
    end
end

ret = 0
1.upto(N) do |i|
    ret += 1 unless A[i]
end
puts ret


Measured memory_bytes: 14344
#define ENABLE_DEBUG 0
// Kana's kitchen {{{
#include<bits/stdc++.h>
#define ALL(v) std::begin(v),std::end(v)
#define LOOP(k) for(i64 ngtkana_is_a_genius=0; ngtkana_is_a_genius<(i64)k; ngtkana_is_a_genius++)

using i32 = std::int_least32_t;
using i64 = std::int_least64_t;
using u32 = std::uint_least32_t;
using u64 = std::uint_least64_t;
using usize = std::size_t;

template <class T> using vec = std::vector<T>;
template <class T> using numr = std::numeric_limits<T>;

#ifdef NGTKANA
#include<debug.hpp>
#else
#define DEBUG(...)(void)0
#endif
/*}}}*/
template <
    usize N, class T, class... Args,
    std::enable_if_t<N==0, int> = 0
>
auto mkvec(Args... args) {
    return T(args...);
}

template <
    usize N, class T, class... Args,
    std::enable_if_t<N!=0, int> = 0
>
auto mkvec(usize sz, Args... args) {
    using value_type = std::decay_t<decltype(mkvec<N-1, T>(args...))>;
    return vec<value_type>(sz, value_type(args...));
}
int main(){
    std::cin.tie(nullptr);
    std::ios::sync_with_stdio(false);
    std::cout << std::setprecision(15) << std::fixed;

    usize H, W, h, w;
    std::cin >> H >> W >> h >> w;

    if (H%h==0 & W%w==0) {
        std::cout << "No" << '\n';
        return 0;
    }
    DEBUG(H,h,W,w);

    bool flipped = false;
    if (H%h==0) {
        flipped = true;
        std::swap(H, W);
        std::swap(h, w);
    }
    DEBUG(flipped,H,h,W,w);

    auto ans = mkvec<2, i64>(H, W);
    i64 r = H % h;
    i64 x = r * H;
    i64 y = (h-r) * H + 1;
    for (usize i=0; i<H; i++) for (usize j=0; j<W; j++) {
        ans.at(i).at(j) = i%h<h-r ? x : -y;
    }

    if (flipped) {
        auto swp = mkvec<2, i64>(W, H);
        for (usize i=0; i<H; i++) for (usize j=0; j<W; j++) {
            swp.at(j).at(i) = ans.at(i).at(j);
        }
        swp.swap(ans);
        std::swap(H, W);
        std::swap(h, w);
    }

    std::cout << "Yes" << '\n';
    for (usize i=0; i<H; i++) {
        for (usize j=0; j<W; j++) {
            std::cout << (j? " ":"") << ans.at(i).at(j);
        }
        std::cout << '\n';
    }
}


Measured memory_bytes: 5376
#include <algorithm>
#include <bitset>
#include <cctype>
#include <chrono>
#include <cmath>
#include <cstdio>
#include <ctime>
#include <deque>
#include <iostream>
#include <map>
#include <queue>
#include <random>
#include <string>
#include <tuple>
#include <unordered_map>
#include <vector>
using namespace std;

#define FOR(i,m,n) for(int i=(m);i<(n);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()

const int INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3fLL;
/*----------------------------------------*/

int main() {
  cin.tie(0); ios::sync_with_stdio(false);
  // freopen("input.txt", "r", stdin);

  int d; cin >> d;
  if (d == 22) cout << "Christmas Eve Eve Eve";
  else if (d == 23) cout << "Christmas Eve Eve";
  else if (d == 24) cout << "Christmas Eve";
  else if (d == 25) cout << "Christmas";
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
using namespace std;
signed main() {
    ios_base::sync_with_stdio(false);
    int n;
    cin >> n;
    int t=0, x=0, y=0;
    for (int i=0; i < n; i++){
        int T, X, Y;
        cin >> T >> X >> Y;
        int D = abs(X-x) + abs(Y-y) - abs(T-t);
        if (D %2 != 0 || D > 0){
            cout << "No" << endl;
            return 0;
        }
        t = T, x = X, y = Y;
    }
    cout << "Yes" << endl;
    return 0;
}





Measured memory_bytes: 256