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

// Type alias
using ll=long long;
using ld=double;

using pi=pair<int,int>;
using pll=pair<ll,ll>;
using pld=pair<ld,ld>;
using ti3=tuple<int, int, int>;

using vi=vector<int>;
using vll=vector<ll>;
using vld=vector<ld>;
using vpi=vector<pi>;
using vpll=vector<ll>;
using vpld=vector<ld>;
using vti3=vector<ti3>;

// Constants
const double EPS = 1e-9;
const int inf = numeric_limits<int>::max() / 2;
const ll mod = 1e9+7;

// Macro
#define rep(i,n) for(int i=0;i<int(n);++i)
#define rrep(i,n) for(int i=int(n-1);i>=0;--i)
#define REP(i,a,b) for(int i=int(a);i<int(b);++i)
#define RREP(i,a,b) for(int i=int(b-1);i>=int(a);--i)
#define SHOW(a) cout << #a << " = " << a << endl
#define ARR(a,n) for(int i=0;i<int(n);++i) cout << #a << "[" << i << "]" << " = " << a[i] << endl

#define ALL(a) a.begin(),a.end()

// Funtcions
ll pow(ll base, ll i, ll mod){
  ll a = 1;
  while(i){
    if (i & 1) {
      a *= base;
      a %= mod;
    }
    base *= base;
    base %= mod;
    i >>= 1;
  }
  return a;
}
ll gcd(ll a, ll b){
  while(b){
    ll c = a % b;
    a = b;
    b = c;
  }
  return a;
}
ll lcm(ll a, ll b){
  return a / gcd(a, b) * b;
}
template<typename T> bool chmin(T& a, const T& b) {
  if (a > b) return a = b, true; else return false;
}

template<typename T> bool chmax(T& a, const T& b) {
  if (a < b) return a = b, true; else return false;
}


void solve(){
  int N;
  int A[100000+5];

  cin >> N;
  rep(i, N) cin >> A[i];

  ll x1 = 0;
  rep(i, N){
    if(i % 2 == 0){
      x1 += A[i];
    }else{
      x1 -= A[i];
    }
  }

  x1 /= 2;

  int X[100000+5];
  X[0] = x1;
  REP(i, 1, N){
    X[i] = A[i - 1] - X[i - 1];
  }

  rep(i, N) cout << X[i] * 2 << " ";
  cout << endl;
}

int main(){
// FastIO
//ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  solve();
  return 0;
}

Measured memory_bytes: 2048
//! ----------------------------------------------
//! Framework <https://github.com/vain0x/procon>
//!
//! See the bottom of file for solution.
//! ----------------------------------------------

#![allow(unused_imports)]
#![allow(non_snake_case)]

use std::cell::RefCell;
use std::cmp::{max, min, Ordering};
use std::collections::*;
use std::fmt::{Debug, Display, Formatter, Write as FmtWrite};
use std::io::{stderr, stdin, BufRead, Write};
use std::mem::{replace, swap};
use std::ops::*;
use std::rc::Rc;

/// Print values to standard error if debug mode.
#[allow(unused_macros)]
macro_rules! debug {
    ($($e:expr),*) => {
        #[cfg(debug_assertions)]
        $({
            let (e, mut err) = (stringify!($e), stderr());
            writeln!(err, "\x1B[33m{}\x1B[0m = {:?}", e, $e).unwrap()
        })*
    };
}

/// Read from standard input and parse each word.
/// - `read!(T, U, ..)` parses a line as a tuple of words.
/// - `read![[T]]` parses a line as an array of words.
/// - `read![..; N]` parses `N` lines, using `read!(..)` repeatedly.
#[allow(unused_macros)]
macro_rules! read {
    ([$t:ty] ; $n:expr) =>
        ((0..$n).map(|_| read!([$t])).collect::<Vec<_>>());
    ($($t:ty),+ ; $n:expr) =>
        ((0..$n).map(|_| read!($($t),+)).collect::<Vec<_>>());
    ([$t:ty]) =>
        (rl().split_whitespace().map(|w| w.parse().unwrap()).collect::<Vec<$t>>());
    ($($t:ty),*) => {{
        let buf = rl();
        let mut w = buf.split_whitespace();
        ($(w.next().unwrap().parse::<$t>().unwrap()),*)
    }};
}

/// Read a line from standard input.
#[allow(dead_code)]
fn rl() -> String {
    let mut buf = String::new();
    stdin().read_line(&mut buf).unwrap();

    #[allow(deprecated)]
    buf.trim_right().to_owned()
}

// -----------------------------------------------
// Solution
// -----------------------------------------------

fn main() {
    let N = rl().chars().collect::<Vec<char>>();
    let K = read!(usize);

    let h = N.len();

    let mut dp = vec![vec![vec![0; 2]; K + 2]; h + 1];
    dp[0][0][1] = 1;

    for i in 0..h {
        for k in 0..K + 1 {
            let d = (N[i] as u8 - b'0') as usize;

            // 1 以上を立てる
            dp[i + 1][k + 1][0] += 9 * dp[i][k][0];

            // 0 を立てる
            dp[i + 1][k][0] += dp[i][k][0];

            if d == 0 {
                // d=0 を立てる
                dp[i + 1][k][1] += dp[i][k][1];
            } else {
                // d を立てる
                dp[i + 1][k + 1][1] += dp[i][k][1];

                // 1 以上 d 未満を立てる
                dp[i + 1][k + 1][0] += (d - 1) * dp[i][k][1];

                // 0 を立てる
                dp[i + 1][k][0] += dp[i][k][1];
            }
        }
    }

    println!("{}", dp[h][K][1] + dp[h][K][0])
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long ll;
typedef pair<int, int> P;
int main() {
  int N;
  cin >> N;
  vector<ll> a(N), b(N);
  ll suma = 0, sumb = 0;
  REP(i, N) cin >> a[i], suma += a[i];
  REP(i, N) cin >> b[i], sumb += b[i];
  if (sumb < suma) {
    cout << "No" << endl;
    return 0;
  }
  queue<int> smalla{}, smallb{};
  REP(i, N) {
    if (a[i] == b[i]) {
      continue;
    }
    if (a[i] < b[i]) {
      smalla.push(i);
    } else {
      smallb.push(i);
    }
  }
  ll loopcnt = sumb - suma;
  REP(i, N) {
    if (a[i] < b[i]) {
      loopcnt -= (b[i] - a[i] + 1) / 2;
    }
  }
  if(loopcnt>=0){
      cout<<"Yes"<<endl;
  }else{
      cout<<"No"<<endl;
  }
}

Measured memory_bytes: 3812
#include<iostream>
#include<cstring>
#include<cstdio>

using namespace std;

int n , m;

inline int read(){
	int s = 0 , w = 1;
	char ch = getchar();
	while( (ch < '0') || (ch > '9') ){
		if(ch == '-'){
			w = -1;
		}
		ch = getchar();
    }
   	while( (ch >= '0') && (ch <= '9') ){
   		s = s * 10 + ch - '0';
		ch = getchar();
	}
   	return s * w;
}

int main(){
	
	n = read();
	m = read();
	
	for(int i = n / 2 , j = i + 1 , k = 1 ; k <= m ; k++ , i-- , j++ ){
		if(n % 2 == 0 && (j - i == n / 2 || j - i == n / 2 + 1)){
			j++;
		}
		cout << i << " " << j << endl;
	}

	return 0;
}

Measured memory_bytes: 3604
#include <stdio.h>

int isprime(int n) {
  int i;
  for(i = 2; i * i <= n; i++) {
    if(n % i == 0) return 0;
  }
return 1;
}

int main(){
  int n, i;
  while(1){
    scanf("%d", &n);
    if(n == 0) break;
    for(i=n ; i >= 5 ; i--){
      if(isprime(i) && isprime(i-2)) break;
    }
    printf("%d %d\n", i - 2, i);
  }
  return 0;
}

Measured memory_bytes: 1728
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <cassert>
#include <fstream>
#define popcount __builtin_popcount
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
const ll MOD=998244353;
int n, k;
vector<int> g[100010];
vector<ll> dp[2][100010];
bool used[100010];
void dfs(int x){
    used[x]=1;
    dp[0][x].resize(1);
    dp[1][x].resize(2);
    dp[0][x][0]=dp[1][x][1]=1;
    for(auto y:g[x]){
        if(used[y]) continue;
        dfs(y);
        vector<ll> v(2*k+1), w(2*k+1);
        for(int i=0; i<dp[0][x].size(); i++){
            for(int j=0; j<dp[0][y].size(); j++){
                (v[i+j]+=dp[0][x][i]*dp[0][y][j])%=MOD;
            }
            for(int j=1; j<dp[1][y].size(); j++){
                (v[i+j]+=dp[0][x][i]*dp[1][y][j])%=MOD;
            }
        }
        for(int i=1; i<dp[1][x].size(); i++){
            for(int j=0; j<dp[0][y].size(); j++){
                (w[i+j]+=dp[1][x][i]*dp[0][y][j])%=MOD;
            }
            for(int j=1; j<dp[1][y].size(); j++){
                (w[i+j]+=dp[1][x][i]*dp[1][y][j])%=MOD;
                (w[i+j-1]+=dp[1][x][i]*dp[1][y][j])%=MOD;
            }
        }
        while(v.size()>k+1 || v.back()==0) v.pop_back();
        while(w.size()>k+1 || w.back()==0) w.pop_back();
        dp[0][x]=v;
        dp[1][x]=w;
    }
}
int main()
{
    cin>>n>>k;
    for(int i=0; i<n-1; i++){
        int x, y; cin>>x>>y;
        x--; y--;
        g[x].push_back(y);
        g[y].push_back(x);
    }
    dfs(0);
    ll ans=dp[1][0][k];
    if(dp[0][0].size()>=k+1) (ans+=dp[0][0][k])%=MOD;
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 498760
#include <algorithm>
#include <bits/stdc++.h>
#include<iostream>
#include<string>
using namespace std;
#define rep(i, n) for (int i = 0; i <(int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define ll long long
const ll MOD=1000000007;
int main(){
    int n,m;cin>>n>>m;
    int a[m];
    vector<int> ok(n+1,1);
    rep(i,m){
        cin>>a[i];
        ok[a[i]]=false;
    }
	int dp[100010] = {0};
	dp[0] = 1;
	for(int i = 0; i < n; i++){
		for(int j=i+1;j<=min(n,i+2);j++){
            if(ok[j]){
                dp[j]+=dp[i];
                dp[j]%=MOD;
            }
        }
	}
    cout<<dp[n]<<endl;
}

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

int main() {
	long long M;
	long long COUNT = 0, DIGIT = 0;
	cin >> M;
	for (int i = 0; i < M; i++) {
		long long D, C;
		cin >> D >> C;
		COUNT += D * C;
		DIGIT += C;
	}
	long long ANS = 0;
	if (COUNT % 9 == 0) ANS = COUNT / 9 - 1;
	else ANS = COUNT / 9;
	cout << ANS + DIGIT - 1 << endl;
}

Measured memory_bytes: 384
nn=int(input())
n=10**5+100
ar=[0]*(n)
ar[1]=0
ans=0
pre=1
for i in range(2,n):
    if ar[i]==0:

        for j in range(2*i,n,i):
            ar[j]=1
ans=1
if ar[nn]==0:
    print(nn)
else:
        
    for i in range(nn,n):
        if ar[i]==0:
            print(i)
            break
        

        

Measured memory_bytes: 40176
N, K, C = map(int, raw_input().split())
S = raw_input()

T1 = [0]*N
T1[-1] = int(S[-1]=="o")
for i in range(N-1)[::-1]:
  if S[i]=="o":
    T1[i] = max(T1[i+1], 1+(T1[i+C+1] if i+C+1<N else 0))
  else:
    T1[i] = T1[i+1]

c = 0
p = -1
for i in range(N):
  if S[i]=="o":
    if c+(T1[i+1] if i+1<N else 0)<K:
      print i+1
    if p==-1 or p+C<i:
      c += 1
      p = i


Measured memory_bytes: 16816
n, s = map(int, input().split())
A = list(map(int, input().split()))
mod = 998244353

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

for i in range(n):
    a = A[i]
    for j in range(s+1):
        if j < s:
            dp[i+1][j] = (dp[i+1][j] + 2*dp[i][j])%mod
        if j+a<s+1:
            dp[i+1][j+a] = (dp[i+1][j+a] + dp[i][j])%mod

ans = 0
for i in range(1, n+1):
    ans = (ans + dp[i][s] * pow(2, n-i, mod)) % mod
print(ans)




Measured memory_bytes: 135396
/*input
8 5 22
100 3 7 5 3 1
164 4 5 2 7 8
334 7 2 7 2 9
234 4 7 2 8 2
541 5 4 3 3 6
235 4 8 6 9 7
394 3 6 1 6 2
872 8 4 3 7 2
*/
/*

**************************
*						 *
* AUTHOR :: knight_coder *
*						 *
**************************

*/
#include<bits/stdc++.h>
#define lld          long long int
#define pb          push_back
#define ppb         pop_back
#define	endl		'\n'
#define mii         map<lld,lld>
#define msi         map<string,lld>
#define mis         map<lld, string>
#define mpi         map<pair<lld ,lld >,lld >
#define pii         pair<lld,lld>
#define vi          vector<lld>
#define vpi 		vector<pii>
#define vs          vector<string>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (lld)x.size()
#define hell        1000000007
#define rrep(i,m,n)	for(lld i=m;i>=n;i--)
#define rep(i,m,n)	for(lld i=m;i<n;i++)
#define lbnd        lower_bound
#define ubnd        upper_bound
#define bs          binary_search
#define mp          make_pair
#define what_is(x)  cerr << #x << " is " << x << endl;
#define pr(x) 		cout<< x << " ";
#define pre(x)		cout<< x << endl ;
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
std::mt19937_64 rng(std::chrono::steady_clock::now().time_since_epoch().count());
template<typename T>
using ordered_set = tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update>; 
//change null_type to get ordered_map
#define N  100005
#define DEC(N)	cout << std::fixed; cout << setprecision(N);
void solve()
{
	lld n,m,X;
	cin >> n >> m  >> X;
	vi c;
	c.resize(n);
	vector <vi> a;
	a.resize(n);
	rep(i,0,n){
		a[i].resize(m);
		cin >> c[i];
		rep(j,0,m){
			cin >> a[i][j];
		}
	}
	lld x=(1LL<<n)-1;
	lld ans=1e18;
	rep(i,0,x+1){
		lld cst=0;
		vi lev(m,0);
		rep(j,0,n){
			if(i&(1LL<<j)){
				cst+=c[j];
				rep(k,0,m){
					lev[k]+=a[j][k];
				}
			}
		}
		bool f=1;
		rep(j,0,m){
			if(lev[j]<X){
				f=0;
				break;
			}
		}
		if(f){
			ans=min(ans,cst);
		}
	} 
	if(ans!=1e18)
		cout << ans << endl;
	else
		cout << -1 << endl;
}
signed main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int tests=1;
	//cin>>tests;
	while(tests--)
	{
		solve();
	}
}

Measured memory_bytes: 3596
# code-festival-2017-qualbB - Problem Set
from collections import Counter


def main():
    n = int(input())
    D = Counter(map(int, input().split()))
    m = int(input())
    T = list(map(int, input().rstrip().split()))
    for i in T:
        if i not in D or D[i] == 0:
            print("NO")
            return
        D[i] -= 1
    print("YES")


if __name__ == "__main__":
    main()

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

int main() {
  int a,b,h,m;
  cin>>a>>b>>h>>m;
  cout << fixed << setprecision(11);
  double s,t;
  s=1.0*a*sin(2*3.1415926535*(h*60+m)/720)-1.0*b*sin(2*3.1415926535*m/60);
  t=1.0*a*cos(2*3.1415926535*(h*60+m)/720)-1.0*b*cos(2*3.1415926535*m/60);
  cout<<1.0*sqrt(1.0*s*s+1.0*t*t)<<endl;
}

Measured memory_bytes: 4100
#include <iostream>
#include <cstdio>
#include<math.h>
#include <cstring>
#include <algorithm>
using namespace std;

int a[200][200],dp[200][200]={0};
int main()
{	int n;
	scanf("%d",&n);
	for(int i=1;i<=2;i++)
	for(int j=1;j<=n;j++)
		scanf("%d",&a[i][j]);
	for(int i=1;i<=2;i++)
	for(int j=1;j<=n;j++)
		if(i==1) dp[i][j]=dp[i][j-1]+a[i][j];
		else dp[i][j]=max(dp[i-1][j]+a[i][j],dp[i][j-1]+a[i][j]);
	printf("%d\n",dp[2][n]);
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <set>
#include <string>
#include <vector>

int main(void){
    int n;
    std::cin >> n;

    int counter = 0;
    for(int i = 0; i*i <= n; i++){
        counter++;
        }
    std::cout << (counter-1)*(counter-1);
    return 0;
    
}




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

// #define int long long
#define rep(i, n) for (long long i = (long long)(0); i < (long long)(n); ++i)
#define reps(i, n) for (long long i = (long long)(1); i <= (long long)(n); ++i)
#define rrep(i, n) for (long long i = ((long long)(n)-1); i >= 0; i--)
#define rreps(i, n) for (long long i = ((long long)(n)); i > 0; i--)
#define irep(i, m, n) for (long long i = (long long)(m); i < (long long)(n); ++i)
#define ireps(i, m, n) for (long long i = (long long)(m); i <= (long long)(n); ++i)
#define SORT(v, n) sort(v, v + n);
#define REVERSE(v, n) reverse(v, v+n);
#define vsort(v) sort(v.begin(), v.end());
#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 PI (acos(-1))
#define FILL(v, n, x) fill(v, v + n, x);
#define sz(x) long long(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 pll = pair<ll, ll>;
using vs = vector<string>;
using vpll = vector<pair<ll, ll>>;
using vtp = vector<tuple<ll,ll,ll>>;
using vb = vector<bool>;

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

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



signed main()
{
  cin.tie( 0 ); ios::sync_with_stdio( false );
  
  ll n; cin>>n;
  ll ans, max=-1;
  
  reps(i,n){
    ll cnt=0, tmp=i;
    while(tmp%2==0){
      cnt++;
      tmp/=2;
    }
    if(chmax(max,cnt)){
      ans=i;
    }
  }
  cout<<ans<<endl;
 }

Measured memory_bytes: 256
#include <algorithm>
#include <boost/optional.hpp>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <functional>
#include <iostream>
#include <limits>
#include <list>
#include <numeric>
#include <queue>
#include <sstream>
#include <string>
#include <tuple>
#include <type_traits>
#include <utility>
#include <vector>

#define REP(i, n) for(int i = 0, i##_MACRO = (n); i < i##_MACRO; i++)
#define RANGE(i, a, b) for(int i = (a), i##_MACRO = (b); i < i##_MACRO; i++)
#define EACH(e, a) for(auto&& e : a)
#define ALL(a) (a).begin(), (a).end()
#define AALL(a, n) (a), ((a) + (n))
#define FILL(a, n) memset((a), n, sizeof(a))
#define FILLZ(a) FILL(a, 0)
#define MODNUM (static_cast<int>(1e9 + 7))
#define MOD(x) ((x) % MODNUM)

using namespace std;

using ll = long long;
using VI = vector<int>;
using VI2D = vector<vector<int>>;

const int INF = 2e9;
const double EPS = 1e-10;
const double PI = acos(-1.0);

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

inline int toInt(string s) {
	int v;
	istringstream sin(s);
	sin >> v;
	return v;
}

template <typename T = int>
class WeightedUnionFind {
	std::vector<size_t> parents;
	std::vector<size_t> rank;
	std::vector<T> diff_weight;
	T identity;

	public:
	WeightedUnionFind(size_t size, T id = static_cast<T>(0))
		: parents(size), rank(size, 0), diff_weight(size, id), identity(id) {
		std::iota(this->parents.begin(), this->parents.end(), 0);
	}

	bool merge(size_t a, size_t b, T w) {
		size_t ar = this->root(a);
		size_t br = this->root(b);
		T dw = w + weight(a) - weight(b);
		if(ar == br) {
			return false;
		}
		if(this->rank[ar] < this->rank[br]) {
			std::swap(ar, br);
			dw = -dw;
		}
		if(this->rank[ar] == this->rank[br]) {
			this->rank[ar]++;
		}
		this->diff_weight[br] = dw;
		this->parents[br] = ar;
		return true;
	}
	bool unite(size_t a, size_t b, T w) { return this->merge(a, b, w); }

	bool is_same(size_t a, size_t b) { return this->root(a) == this->root(b); }
	bool is_union(size_t a, size_t b) { return this->is_same(a, b); }

	boost::optional<T> diff(size_t a, size_t b) {
		if(!this->is_same(a, b)) {
			return boost::none;
		}
		return boost::optional<T>(this->weight(b) - this->weight(a));
	}

	private:
	size_t root(int n) {
		if(this->parents[n] == n) {
			return n;
		}

		size_t r = this->root(this->parents[n]);
		this->diff_weight[n] += this->diff_weight[this->parents[n]];
		this->parents[n] = r;
		return r;
	}

	T weight(size_t n) {
		root(n);
		return this->diff_weight[n];
	}
};

int main() {
	int n, q;
	scanf("%d %d", &n, &q);
	VI s(n);
	VI com(q);
	VI x(q);
	VI y(q);
	VI z(q);
	REP(i, q) {
		scanf("%d", &com[i]);
		scanf("%d %d", &x[i], &y[i]);
		if(!com[i]) {
			scanf("%d", &z[i]);
		}
	}

	WeightedUnionFind<int> wuf(n);
	REP(i, q) {
		if(com[i]) {
			if(const boost::optional<int> d = wuf.diff(x[i], y[i])) {
				printf("%d\n", *d);
			} else {
				puts("?");
			}
		} else {
			wuf.merge(x[i], y[i], z[i]);
		}
	}
	return 0;
}


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

using namespace std;

int main(void)
{
  string s;
  int b;
  int a;

  cin>>s;

  b=stoi(s.substr(0,2));
  a=stoi(s.substr(2));

  if(0<b && b<13)
  {
    if(0<a && a<13)
    {
      cout<<"AMBIGUOUS"<<endl;
      return 0;
    }
    else
    {
      cout<<"MMYY"<<endl;
      return 0;
    }
  }
  else
  {
    if(0<a && a<13)
    {
      cout<<"YYMM"<<endl;
      return 0;
    }
    else
    {
      cout<<"NA"<<endl;
      return 0;
    }
  }
  
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<utility>
using namespace std;
typedef long long ll;
const ll mod = 1000000007;
const ll INF = mod * mod;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef vector<int> vec;
#define rep(i,n) for(int i=0;i<n;i++)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define stop char nyaa;cin>>nyaa;

struct cors {
	int a, k, t;
};
void solve() {
	int n, m, l; cin >> n >> m >> l;
	vector<vector<cors>> v(5);
	rep(i, m) {
		int d, a, k, t; cin >> d >> a >> k >> t; a--;
		v[d].push_back({ a,k,t });
	}
	vector<vector<int>> memo(5);
	rep(i, 5) {
		memo[i].resize(n + 1, -mod);
	}
	rep(i, 5) {
		vector<vector<int>> dp(1 << n);
		rep(j, (1 << n)) {
			dp[j].resize(n + 1, -mod);
		}
		dp[0][0] = 0;
		rep(j, v[i].size()) {
			cors &c = v[i][j];
			int s = 0;
			Rep(k, c.a, c.a + c.k) {
				s += (1 << k);
			}
			rep(k, (1 << n)) {
				if (k&s)continue;
				rep(x, n) {
					dp[k | s][x + 1] = max(dp[k | s][x + 1], dp[k][x] + c.t);
				}
			}
		}
		rep(j, (1 << n)) {
			rep(k, n + 1) {
				memo[i][k] = max(memo[i][k], dp[j][k]);
			}
		}
		//cout << "hello " << i << endl;
		//rep(k, n + 1)cout << memo[i][k] << endl;
	}
	vector<int> dp(41,-mod);
	dp[0] = 0;
	rep(i, 5) {
		vector<int> cop(41, -mod);
		rep(j, 41) {
			rep(k, memo[i].size()) {
				if (j + k > 40)break;
				cop[j + k] = max(cop[j + k], dp[j] + memo[i][k]);
			}
		}
		dp = cop;
	}
	int ans = 0;
	rep(i, l + 1) {
		ans = max(ans, dp[i]);
	}
	cout << ans << endl;
}
signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	solve();
	//stop
		return 0;
}



Measured memory_bytes: 3244
/*jai_ganeshdeva*/

#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define pu push  //  adds the value to the last of the queue 
#define lld long long int
#define ins insert /// used in set to insert the values 
#define adv advance  /// used to increment the iterator
#define mp make_pair
#define fi first
#define se second
#define all(c) c.begin(),c.end()
#define PI 3.1415926
#define INF (lld)1e18
#define vl  vector<long long int >
#define vpll vector< pair<lld ,lld> >
#define vvl vector<vector<lld> > 
#define pll pair <lld,lld>
#define modA(cccc,bbbb ,p) (((cccc+bbbb)%p+p)%p)
#define modS(cccc,bbbb ,p) (((cccc-bbbb)%p+p)%p)
#define modM(cccc,bbbb ,p) ((((cccc%p)*(bbbb%p))%p+p)%p)

long long int modp(lld a,lld p,lld n)
{
    lld d[100];
    lld i,j,k,l;
    if(n==0) return 1;
    for(i=0;n>=1;i++)
    {
        d[i]=n%2;
        n/=2;
    }
    l=i;
    long long int e=1;
    if(d[0]==1) e*=(a%p);
    for(i=1;i<l;i++)
    {
        a*=a;
        a=a%p;
        if(d[i]==1) 
        {
            e*=a;
            e=e%p;
        }
    }
    return e%p;
}
lld modInverse(lld n, lld p) 
{ 
    return modp(n, p, p-2); 
}

/*lld fac[100001]; 

void getfac(lld p)
{
    fac[0] = 1; 
    for (lld i=1 ; i<=100000; i++) 
        fac[i] = fac[i-1]*i%p; 
}    

long long int nCrmodp(lld n, lld r,lld p) 
{ 
   // Base case 
   if (r==0) 
      return 1; 
     
    return (fac[n]* modInverse(fac[r], p) % p * 
            modInverse(fac[n-r], p) % p) % p; 
}*/


lld gcd(lld a,lld b)
{
    if(a>b) return gcd(b,a);
    if(b%a==0) return a;
    else return gcd(b%a,a);
}

lld p1=1e9 + 7,p2=998244353;
lld l,r,mid,ans;
lld n,i,j,k,g,m;
lld x,y,n1,n2,h,z,c;
lld aa=1;



void solve()
{
    cin>>n;
    vector<lld> v;
    x=0;
    for(i=0;i<n;i++)
    {
        cin>>l;
        v.pb(l);
        x= x^l;
    }
    for(i=0;i<n;i++)
    {
        cout<<(x^v[i])<<" ";
    }
}


int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    lld t=1;
    
    //cin>>t;
    //cout<<t;
   //  getfac(p2);
    //check the value by which modulo is to be taken
    lld ans=0;
    for(int i=0;i<t;i++)
    {
   //     cout<<"Case #"<<i+1<<": ";
                  solve();
     //  cout<<"\n";
    }
    return 0;
}


Measured memory_bytes: 5328
N,M = map(int,input().split())
G1 = [[] for _ in range(N)]
G2 = [[] for _ in range(N)]
for i in range(M):
  a,b=map(int,input().split())
  if a == b:continue
  G1[a].append(b)
  G2[b].append(a)

def dfs(a0):
    global order
    todo = [~a0, a0]
    while todo:
        a = todo.pop()
        if a >= 0:
            seen[a] = 1
            for b in G1[a]:
                if seen[b]: continue
                todo.append(~b)
                todo.append(b)
        else:
          if postorder[~a] == -1:
            postorder[~a] = order
            order += 1
    return
  
def dfs2(v):
    todo = [v]
    seen[v] = 1
    cc = [v]
    while todo:
        v = todo.pop()
        for next_v in G2[v]:
            if seen[next_v]: continue
            seen[next_v] = 1
            todo.append(next_v)
            cc.append(next_v)
    return cc
  
seen = [0]*N
postorder=[-1]*N
order = 0
for i in range(N):
  if seen[i]:continue
  dfs(i)

seen = [0]*N
scc = []
for i,_ in sorted(enumerate(postorder),key=lambda x:x[1],reverse=True):
  if seen[i]:continue
  cc = dfs2(i)
  scc.append(cc)
  
print(len(scc))
for cc in scc:
  print(len(cc),*cc)

Measured memory_bytes: 254532
n, d = map(int, input().split())

xy = []
for i in range(n):
    xy.append(list(map(int, input().split())))

#print(xy)
a = []

for i in range(n):
  if xy[i][0]**2 + xy[i][1]**2 <= d**2:
    a.append(xy[i])

print(len(a))



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

/* vector */
using vi = vector<int>;
using vvi = vector<vi>;
#define pb push_back
#define all(v) (v).begin(), (v).end()
using vb = vector<bool>;

int main(){
  int N,M;
  cin>>N>>M;

  vvi cango(N);//それぞれの部屋からいける部屋のリスト
  int a,b;
  for(int i=0; i<M; i++){
    cin>>a>>b;
    a--;b--;
    cango[a].pb(b);
    cango[b].pb(a);
  }

  vi sirube(N, -1);//置くみちしるべ-1は無記入
  sirube[0] = 0;//最初の部屋にはなんかかいとけ

  queue<int> unchecked;//調査したい
  unchecked.push(0);

  while(!unchecked.empty()){
    int current = unchecked.front();
    unchecked.pop();

    for(int next: cango[current]){
      if(sirube[next]==-1){
        //しるべなし
        sirube[next] = current+1;//しるべは1始まり
        
        unchecked.push(next);
      }
    }
  }

  cout<<"Yes\n";//Noってナニ？
  for(int i=1; i<N; i++){
    cout<<sirube[i]<<endl;
  }
}

Measured memory_bytes: 10260
#include <iostream>
#include <bits/stdc++.h>
#include <vector>
#include <algorithm>
#include <cctype>
#include <string>
#include <map>
#include <set>
#include <math.h>
#include <cmath>
#define ll long long

using namespace std;

int main(){

  int N, A;
  cin >> N;

  map<int,int>m;
  for (int i = 1; i <= N; i++) {
    m[i] = 0;
  }
  for (int i = 0; i < N-1; i++) {
    cin >> A;
    m[A] += 1;
  }

  for(auto i = m.begin(); i != m.end(); i++) {
    cout << i->second << endl;
  }

  return 0;
}

Measured memory_bytes: 12996
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define REPS(i, a, b) for (int i = (a); i < (b); ++i)
using namespace std;
using ll = long long;




int main() {
  int h,w,k;
  cin >> h >> w >> k;
 
  vector<string> s(h);
  
  REP(i,h) cin >> s[i];
  
  int ans = 0;
  
  
  REP(is,1<<h) REP(js,1<<w){
      
    int cnt = 0;
    REP(i,h) REP(j,w){
        
      if(is>>i&1) continue;
      if(js>>j&1) continue;
      if(s[i][j] == '#') cnt++;
        
      }
     if(cnt == k) ans++;
      
  }
	
  cout << ans << endl;
  
}

Measured memory_bytes: 3624
class UnionFind:
    def __init__(self, n):
        self.parent = [ -1 for _ in range(n) ]
        self._size = n

    def unite(self, x, y):
        x, y = self.root(x), self.root(y)
        if x != y:
            if self.parent[y] < self.parent[x]:
                x, y = y, x
            self.parent[x] += self.parent[y]
            self.parent[y] = x
            self._size -= 1

    def same(self, x, y):
        return self.root(x) == self.root(y)

    def root(self, x):
        if self.parent[x] < 0:
            return x
        else:
            self.parent[x] = self.root(self.parent[x])
            return self.root(self.parent[x])

    def size(self, x):
        return -self.parent[self.root(x)]


N, M, K = map(int, input().split())

uf_tree = UnionFind(N)

friends = [ [] for _ in range(N) ]
blocks = [ [] for _ in range(N) ]

for _ in range(M):
    a, b = map(int, input().split())
    a -= 1; b -= 1;
    uf_tree.unite(a, b)
    friends[a].append(b)
    friends[b].append(a)

for _ in range(K):
    c, d = map(int, input().split())
    c -= 1; d -= 1;
    blocks[c].append(d)
    blocks[d].append(c)

for i in range(N):
    ans = uf_tree.size(i) - 1
    cand = set()
    for f in friends[i]:
        cand.add(f)
    for b in blocks[i]:
        if uf_tree.same(i, b):
            cand.add(b)
    ans -= len(cand)
    print(ans, end = "")
    print("\n" if i == N-1 else " ", end = "")

Measured memory_bytes: 47288
#include <algorithm>
#include <iostream>
#include <cstring>
#include <vector>
using namespace std;

typedef long long ll;

const int MAX_N = 1e12 + 12;
ll n;
vector <int> vec, t;

int main() {
    ios::sync_with_stdio(false), cin.tie(0);
    cin >> n;
    int l = 1, r = 100;

    while (n) {
        n--;
        if (n & 1)
            vec.push_back(r--);
        else {
            n >>= 1;
            vec.push_back(l++);
        }
    }

    cout << vec.size() * 2 << "\n";
    t = vec;
    sort(t.begin(), t.end());
    for (int a: t)
        cout << a << " ";
    for (int a: vec)
        cout << a << " ";
    return 0;
}


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

int main()
{
  int N, M;
  cin >> N >> M;
  vector<int> xs, ys;
  vector<pair<int,int> > v(N);
  for (int i = 0; i < N; i++) {
    cin >> v[i].first >> v[i].second;
    xs.push_back(v[i].first);
    ys.push_back(v[i].second);
  }
  sort(xs.begin(), xs.end());
  xs.erase(unique(xs.begin(), xs.end()), xs.end());
  sort(ys.begin(), ys.end());
  ys.erase(unique(ys.begin(), ys.end()), ys.end());

  static const int MAXN = 5000;
  static int grid[MAXN][MAXN];
  for (vector<pair<int,int> >::const_iterator it = v.begin(); it != v.end(); ++it) {
    const int xi = distance(xs.begin(), lower_bound(xs.begin(), xs.end(), it->first));
    const int yi = distance(ys.begin(), lower_bound(ys.begin(), ys.end(), it->second));
    ++grid[xi][yi];
  }
  static int sums[MAXN+1][MAXN+1];
  for (int i = 0; i < N; i++) {
    for (int j = 0; j < N; j++) {
      sums[i+1][j+1] = sums[i][j+1] + sums[i+1][j] - sums[i][j] + grid[i][j];
    }
  }

  for (int i = 0; i < M; i++) {
    int x1, y1, x2, y2;
    cin >> x1 >> y1 >> x2 >> y2;
    const int xi1 = distance(xs.begin(), lower_bound(xs.begin(), xs.end(), x1));
    const int yi1 = distance(ys.begin(), lower_bound(ys.begin(), ys.end(), y1));
    const int xi2 = distance(xs.begin(), lower_bound(xs.begin(), xs.end(), x2+1));
    const int yi2 = distance(ys.begin(), lower_bound(ys.begin(), ys.end(), y2+1));
    cout << sums[xi2][yi2] - sums[xi2][yi1] - sums[xi1][yi2] + sums[xi1][yi1] << endl;
  }
  return 0;
}

Measured memory_bytes: 195068
#include<bits/stdc++.h>
#define mp make_pair
#define fi first
#define se second
#define INF 10000000000000000LL
#define ll  long long 
const int inf =INT_MAX;
const int MAX=3e5+9;
const ll MOD=1e9+7;
const int TOT_PRIMES=1e6+9;
const int MAX_A=71;
const int LN=20;
using namespace std;

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int N; cin>>N;
    vector<ll> a(N);
    for(int i = 0; i < N; ++i){
        cin>>a[i];
    }
    ll ans = 0;
    for(int i = 0; i < N; ++i){
        if(a[i] % 2 == 1)
            continue;
        int res = 0;
        while(res != 1){
            res = a[i] % 2;
            a[i] /= 2;
            if(!res)
                ans++;
        }
    }
    cout<<ans<<"\n";
    return 0;
}

Measured memory_bytes: 3740
n = int(input())
s = input()
inv_s = s[::-1]
lst_e =[]
lst_w =[]
e = w = 0
for i in range(n):
  if s[i] == 'W':
    w += 1
  if inv_s[i] == 'E':
    e += 1
  lst_e.append(e)
  lst_w.append(w)
lst_w.reverse()


ans = [lst_e[i]+lst_w[i] for i in range(n)]
print(min(ans)-1)

Measured memory_bytes: 30028
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <vector>
#include <algorithm>
#include <string>
#include <utility>
#include <map>
#include <cmath>
#include <bitset>
#include <deque>
#define MAX_N 100
#define MAX_T 200
#define INF (1LL<<31)
#define fst first
#define snd second
typedef long long ll;
typedef std::pair<int,int> ii;
using namespace std;
 
int main(){
  string str;
  cin>>str;
  if(str[0]==str[2])cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
signed main(){
    long long n;
    scanf("%lld",&n);
    long long i;
    long long sum=0;
    for(i=1;i<=n;i++){
        if(i%5!=0&&i%3!=0){
            sum+=i;
        }
    }
    printf("%lld\n",sum);
    return(0);
}

Measured memory_bytes: 1732
s = input()

s = list(s)
s1=s[0::2]
s2=s[1::2]

flag = "Yes"

for a in s1:
  if (a != 'R') and (a != 'U') and (a != 'D'):
    flag = "No"
for a in s2:
  if (a != 'L') and (a != 'U') and (a != 'D'):
    flag = "No"

print(flag)

Measured memory_bytes: 3064
#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;
int main(){
    int n;
    string s;
    cin>>n>>s;
    for(int i=0;i<s.length();i++){
        s[i]+=n;
        if(s[i]>'Z')s[i]-=26;
    }
    cout<<s<<endl;
    return 0;
}

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

#include<stdio.h>
#include<math.h>
#include <stdlib.h>
#include <ctype.h>
#include <string.h>

using namespace std;

int main(){

  string x;
  int total=0;
  int i=0;
  while(1){
    cin >> x;
    if(x=="0") break;

    else{
      total=0;
      i=0;
      while(i<x.size()){
	total+=x[i]-'0';
	i++;
      }
      cout <<total <<endl;
    }
  }
  return 0;
}

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

int main()
{
    string s,t1,t2;
    cin>>s;
    ll half=s.size()/2;
    t1=s.substr(0,half);
    t2=s.substr(half+1,s.size());
    string rev=t1;
    reverse(rev.begin(),rev.end());
    if(t1==rev && t1==t2) cout<<"Yes";
    else cout<<"No";
}

Measured memory_bytes: 256
/*
ID: anonymo14
TASK: wormhole
LANG: C++                 
*/
#include<bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<pair<int,int>> vpii;

#define F first
#define S second
#define PU push
#define PUF push_front
#define PUB push_back
#define PO pop
#define POF pop_front
#define POB pop_back

#define REP(i,a,b) for(int i=a; i<=b; i++)

#define MOD 1000000007

void solve(int test_case) {
	int n;
	cin>>n;
	vector<ll> arr(n);
	double sum = 0;
	for(auto &i:arr)cin>>i,sum+=i;
	sum=round(sum/n);//cout<<sum<<"\n";
	ll ans = 0;
	for(auto i:arr)ans+=(i-sum)*(i-sum);
	cout<<ans;
}

int main() {
	
	////// FILE BASED IO////
	//freopen("wormhole.in", "r", stdin);
	//freopen("wormhole.out", "w", stdout);
	///////////////
	
	ios::sync_with_stdio(0);
	cin.tie(0);
	int t=1;
	//cin>>t;
	REP(i,1,t) {
		solve(i);
	}
	return 0;
}	


Measured memory_bytes: 3644
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef string S;
#define endl '\n'
#define rep(i, n) for(ll i=0;i<n;++i)
#define rep2(i,a,b) for(ll i=a;i<=b;++i)
#define rep3(i,a,b) for(ll i=a;i>=a;--i)

int main(){
    ll n;
    cin >> n;
    string c;
    cin >> c;
    ll red = 0;
    for(ll i=0;i<n;i++){
        if(c[i] == 'R')red++;
    }
    ll ans = 0;
    for(ll i=0;i<red;i++){
        if(c[i] != 'R')ans++;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3700
#float型を許すな
#numpyはpythonで
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)
from collections import Counter, deque
from collections import defaultdict
from itertools import combinations, permutations, accumulate, groupby, product
from bisect import bisect_left,bisect_right
from heapq import heapify, heappop, heappush
from math import floor, ceil,pi,factorial
from operator import itemgetter
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
def LI2(): return [int(input()) for i in range(n)]
def MXI(): return [[LI()]for i in range(n)]
def SI(): return input().rstrip()
def printns(x): print('\n'.join(x))
def printni(x): print('\n'.join(list(map(str,x))))
inf = 10**17
mod = 10**9 + 7

a,b,q=MI()
lis1=[-inf]
lis2=[-inf]
for i in range(a):
    lis1.append(I())
for i in range(b):
    lis2.append(I())
lis1.append(inf)
lis2.append(inf)
#print(lis1)
#print(lis2)
for i in range(q):
    u=I()
    x=bisect_left(lis1,u)
    y=bisect_left(lis2,u)
    #print(u,x,y)
    Lll=u-min(lis1[x-1],lis2[y-1])
    Lrr=max(lis1[x],lis2[y])-u
    Llr1=2*(u-lis1[x-1])+(lis2[y]-u)
    Llr2=2*(lis2[y]-u)+u-lis1[x-1]
    Lrl1=2*(u-lis2[y-1])+lis1[x]-u
    Lrl2=2*(lis1[x]-u)+u-lis2[y-1]
    #print(Lll,Lrr,Lrl1,Lrl2,Llr1,Llr2)
    print(min(Lll,Lrr,Lrl1,Lrl2,Llr1,Llr2))
    
    
    
    



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

using namespace std;

const int N = (1<<19) , mod = 1e9 +7;

int mat[11][11];

int fd(int x)
{
    int fr = 0;
    while(x)
    {
        fr = x%10;
        x/=10;
    }
    return fr;
}

int ld(int x)
{
    return x%10;
}

int main()
{
    int n ;
    cin>> n ;
    long long ans = 0;
    for(int i = 1;i<=n;i++)
    {
        mat[fd(i)][ld(i)]++;
    }
    for(int i = 1;i<=n;i++)
    {
       ans+=mat[ld(i)][fd(i)];
    }
    cout<<ans;
    return 0;
}


Measured memory_bytes: 256
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author
 */

#include <iostream>
#include <fstream>

#include <iostream>
#include <fstream>

#include <string>
#include <vector>
#include <math.h>
#include <map>
#include <set>
#include <algorithm>
#include <numeric>
#include <bitset>
using namespace std;
using ll = long long;
//constexpr ll INF = 1010000000000000017LL;
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define all(v) v.begin(), v.end()

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

ll LCM(ll a, ll b) {
    return a/GCD(a,b)*b;
}

class BMultiplication2 {
public:
	void solve(std::istream& in, std::ostream& out) {
	        ll mx = 1e18;
            ll n;
            in>>n;
            ll res=1;
            vector<ll> v(n);
            rep(i,n) in>>v[i];
            sort(all(v));
            rep(i,n){
                ll tmp = v[i];
                if(tmp==0){
                    out<<0<<endl;
                    return;
                }
                if(mx/res<tmp){
                    out<<-1<<endl;
                    return;
                }
                res*=tmp;
            }
            out<<res<<endl;

	}
};


int main() {
	BMultiplication2 solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


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

int N, K;
int E[110][110];

void add_edge(int a, int b)
{
    E[a][b] = E[b][a] = 1;
    return;
}

int main()
{
    cin >> N >> K;

    if(K > N * (N - 1) / 2 - (N - 1))
    {
        cout << -1 << endl;
        return 0;
    }

    int edge = N - 1;

    for(int i = 2; i <= N; i++)add_edge(1, i);

    int num = (N - 2) * (N - 1) / 2 - K;
    for(int i = 2; i <= N; i++)
    {
        for(int j = i + 1; j <= N; j++)
        {
            if(num > 0)
            {
                add_edge(i, j);
                edge++;
                num--;
            }
        }
    }

    cout << edge << endl;
    for(int i = 1; i <= N; i++)
    {
        for(int j = i + 1; j <= N; j++)
        {
            if(E[i][j])
            {
                cout << i << " " << j << endl;
            }
        }
    }

    return 0;
}




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

int main() {
    using namespace std;

    int N, M, X;
    int A[100] = {0,};

    cin >> N >> M >> X;
    for (int i=0; i<M; i++) {
        int a;
        cin >> a;
        A[a] = 1;
    }

    int s = 0;
    for (int i=X; 0<i; i--) {
        s += A[i];
    }
    int t = 0;
    for (int i=X; i<N; i++) {
        t += A[i];
    }

    cout << std::min({s, t}) << endl;

    return 0;
}

Measured memory_bytes: 256
// CPP program for finding number of divisor 
#include<iostream>
// #include <bits/stdc++.h> 
using namespace std; 
#define ll long long 


// driver program 
int main() 
{ 
    ll int n;
    cin >> n;
    if(n%1000!=0)
    cout << 1000 - n%1000;
    else
    cout << "0";
    // for(i=1;i<=n;i++)
    // {
    //     ans += (i*divCount(i));
    // }
    // cout << a*b;
	return 0; 
} 


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

using namespace std;

#define ll long long
#define pb push_back
#define mp make_pair
#define fst first
#define snd second

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

    for(int i = 0; i < s.size(); i++)
    {
        if(s[i] + n > 90)
            cout << (char)(64 + (s[i] + n - 90));
        else
            cout << (char)(s[i] + n);
    }

    return 0;
}


Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
	"reflect"
	"strconv"
)

const (
	maxBufSize = 1024 * 1024
)

var (
	sc = func() *bufio.Scanner {
		sc := bufio.NewScanner(os.Stdin)
		buf := make([]byte, 1)
		sc.Buffer(buf, maxBufSize)
		sc.Split(bufio.ScanWords)
		return sc
	}()
	out = bufio.NewWriter(os.Stdout)
)

func solve(o string, e string) string {
	ret := []byte(o + e)
	for i, c := range(o) {
		ret[i * 2] = byte(c)
	}
	for i, c := range(e) {
		ret[i * 2 + 1] = byte(c)
	}
	return string(ret)
}

func main() {
	defer out.Flush()

	o := next()
	e := next()
	res := solve(o, e)
	fmt.Fprintln(out, res)
}

func next() string {
	sc.Scan()
	return sc.Text()
}

func nextStringAsBytes() []byte {
	sc.Scan()
	return []byte(sc.Text())
}

func nextInt() int64 {
	a, _ := strconv.ParseInt(next(), 10, 64)
	return a
}

func nextFloat() float64 {
	a, _ := strconv.ParseFloat(next(), 64)
	return a
}

func nextInts(n int64) []int64 {
	ret := make([]int64, n)
	for i := int64(0); i < n; i++ {
		ret[i] = nextInt()
	}
	return ret
}

func nextFloats(n int64) []float64 {
	ret := make([]float64, n)
	for i := int64(0); i < n; i++ {
		ret[i] = nextFloat()
	}
	return ret
}
func nextStrings(n int64) []string {
	ret := make([]string, n)
	for i := int64(0); i < n; i++ {
		ret[i] = next()
	}
	return ret
}

func containStr(arr []string, target string) bool {
	for _, v := range arr {
		if v == target {
			return true
		}
	}
	return false
}

func PrintOut(src interface{}, joinner string) {
	switch reflect.TypeOf(src).Kind() {
	case reflect.Slice:
		s := reflect.ValueOf(src)
		for idx := 0; idx < s.Len(); idx++ {
			fmt.Fprintf(out, "%v", s.Index(idx))
			if idx < s.Len()-1 {
				fmt.Fprintf(out, "%s", joinner)
			} else {
				fmt.Fprintln(out)
			}
		}
	default:
		fmt.Fprintln(out, "orz")
	}
}

// mapからkeysとvaluesを返す
func splitKeyValue(m map[interface{}]interface{}) (keys, values []interface{}) {
	switch reflect.TypeOf(m).Kind() {
	case reflect.Map:
		s := reflect.ValueOf(m)
		for _, v := range s.MapKeys() {
			keys = append(keys, v)
			values = append(values, s.MapIndex(v))
		}
	default:
		fmt.Fprintln(out, "orz")
	}
	return
}


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

int cnt;
int m;
vector<int> G;

void insertionSort(vector<int>& vec, int g)
{
  for(int i=g; i<vec.size(); i++) {
    int v = vec[i];
    int j = i-g;
    while(j >= 0 && vec[j] > v) {
      vec[j+g] = vec[j];
      j = j - g;
      cnt ++;
    }
    vec[j+g] = v;
  }
}

void shellSort(vector<int>& vec)
{
  cnt = 0;

  G.push_back(1);
  for(int i=1; 3*G[i-1]+1 < vec.size() && G.size()<=100; i++) {
    G.push_back(3*G[i-1]+1);
  }
  m = G.size();
  reverse(G.begin(), G.end());
  
  for(int i=0; i<m; i++) insertionSort(vec, G[i]);
}

int main()
{
  int N; cin >> N;
  vector<int> vec(N);
  for(int i=0; i<N; i++) cin >> vec[i];
  
  cnt = 0;
  shellSort(vec);
  
  cout << m << endl;
  for(int i=0; i<m; i++) {
    if(i) cout << " ";
    cout << G[i];
  }
  cout << endl;
  cout << cnt << endl;
  
  for(int i=0; i<N; i++) {
    cout << vec[i] << endl;
  }

  return 0;
}


Measured memory_bytes: 6784
#include<iostream>

using namespace std;

const int MAX = 12;

char data[MAX][MAX];

void solve(int i, int j){
  data[i][j] = '0';
  if(i+1 < MAX && data[i+1][j] == '1') solve(i+1,j);
  if(i-1 >= 0 && data[i-1][j] == '1') solve(i-1,j);
  if(j+1 < MAX && data[i][j+1] == '1') solve(i,j+1);
  if(j-1 >= 0 && data[i][j-1] == '1') solve(i,j-1);
  return;
}

int main(){
  int status = 0;
  while(1){
    // if(!getline(cin,data[0])) break;
    //for(int i = 1; i < MAX; i++) getline(cin,data[i]);
    for(int i = 0; i < MAX; i++)
      for(int j = 0; j < MAX; j++)
	if(!(cin >> data[i][j])){
	  status = 1;
	  break;
	}
    if(status) break;
    int sum = 0;
    for(int i = 0; i < MAX; i++){
      for(int j = 0; j < MAX; j++){
	if(data[i][j] == '1'){
	  sum++;
	  solve(i,j);
	}
      }
    }
    cout << sum << endl;
  }
  return 0;
}

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


int main() {

  int n;
  cin>>n;

  vector<int> p(n);
  for(int i=0;i<n;i++){
    cin>>p.at(i);
  }

  vector<int> p_org(n);
  copy(p.begin(),p.end(),p_org.begin());

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

  //差分を出す
  int cnt=0;
  int pos1=0,pos2=0;
  for(int i=0;i<n;i++){
    if(p.at(i)!=p_org.at(i)){
      if(cnt==0)
        pos1=i;
      else
        pos2=i;
      
      cnt++;
    }
  }

  //pos1とpos2を交換
  iter_swap(p.begin()+pos1,p.begin()+pos2);

  if(cnt==0||p==p_org)
    cout<<"YES"<<endl;
  else
    cout<<"NO"<<endl;

  return 0;
}


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

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;

#define rep(i, j, k) for (int i = j; i < k; i++)
#define pb push_back
#define all(x) x.begin(), x.end()
#define mt make_tuple

#define iv inline void
#define ii inline int
#define ill inline ll

template <typename S, typename T>
inline bool smin(S &l, T r) {
  return r < l ? l = r, 1 : 0;
}
template <typename S, typename T>
inline bool smax(S &l, T r) {
  return l < r ? l = r, 1 : 0;
}

constexpr int MOD = 1e9 + 7;  // 998244353;

template <typename S>
inline S mod(S &l) {
  return l = (l % MOD + MOD) % MOD;
}
template <typename S, typename T>
inline S add(S &l, T r) {
  return mod(l += r);
}
ill po(ll v, ll u) {
  return u ? po(v * v % MOD, u >> 1) * (u & 1 ? v : 1) % MOD : 1;
}

void fileIO(string s) {
  freopen((s + ".in").c_str(), "r", stdin);
  freopen((s + ".out").c_str(), "w", stdout);
}

constexpr int N = 1e6 + 10;

int n, a[N];
bitset<N> b, dead;

inline bool check(int limit) {
  rep(i, 0, n) b[i] = a[i] >= limit;
  dead.set();
  rep(i, 0, n) if ((i && b[i] == b[i - 1]) || i < n - 1 && b[i] == b[i + 1])
      dead[i] = false;
  if (!dead[n / 2]) return b[n / 2];
  int lptr = n / 2;
  int rptr = lptr;
  while (~lptr && dead[lptr]) lptr--;
  while (rptr < n && dead[rptr]) rptr++;
  if (lptr == -1 && rptr == n) return b[0];
  if ((rptr - lptr - 1 & 1) == 0)
    return (n / 2 - lptr) > (rptr - n / 2) ? b[lptr + 1] : b[rptr - 1];
  return !b[lptr + 1];
}

// 4
// 1 6 3 7 4 5 2

int main() {
#ifndef LOCAL
  // fileIO("");
#endif

  cin >> n;
  n = 2 * n - 1;
  rep(i, 0, n) cin >> a[i];

  int lo = 1, hi = n + 1;
  while (lo != hi - 1) {
    int mid = lo + hi >> 1;
    if (check(mid))
      lo = mid;
    else
      hi = mid;
  }

  cout << lo << endl;

  return 0;
}


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

int main() {
  string S, T;
  cin >> S >> T;

  int ans = 0;
  for (int i = 0; i < 3; ++i) {
    if (S[i] == T[i]) ++ans;
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
#include<cstring>
using namespace std;
char st[55],st1[55];
int num,len;
int main()
{
	scanf("%s",st);
	st1[0]='A';st1[1]='K';st1[2]='I';
	st1[3]='H';st1[4]='A';st1[5]='B';
	st1[6]='A';st1[7]='R';st1[8]='A';
	num=0;
	bool flag=1;
	len=strlen(st)-1;
	for (int i=0;i<9;i++)
	{
		if (st1[i]==st[num]) 
		{
			num++;
			if (num>len) 
		    {
		    	for (int j=i+1;j<9;j++)
		    	if (st1[j]!='A') flag=0;
		    	break;
			}
		}
		else if (st1[i]!='A') flag=0; 
	}
	if (num<=len) flag=0;
	if (flag==1) printf("YES\n");
	else printf("NO\n");
	return 0;
}

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

int main(){
  int A,B,C,X,Y;
  cin >>A>>B>>C>>X>>Y;
  int N;
  if(X>Y){
    N = X;
  }else{
    N = Y;
  }
  int min = 9999999999;
  for(int i=0;i<=N;i++){
    int amount=0;
    amount+=i*C*2;
    if(i<=Y&&i<=X){
      amount+=(X-i)*A+(Y-i)*B;
    }else if(i>=Y&&i<=X){
      amount+=(X-i)*A;
    }else{
      amount+=(Y-i)*B;
    }
    if(amount < min){
      min = amount;
    }
  }
  cout<<min<<endl;
}
      
     

Measured memory_bytes: 256