akhauriyash/Code-Regression huggingface dataset:
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define mod 1000000007ll
#define mod1 998244353ll
#define endl '\n'
#define inf ((ll)1e18+1)
#include<chrono>
using namespace chrono;
mt19937_64 rng(high_resolution_clock::now().time_since_epoch().count());
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define ordered_set tree<ll,null_type,less_equal<ll>,rb_tree_tag,tree_order_statistics_node_update>
#define debr(x,y) {cout<<"-->  "<<#x<<" to "<<#y<<" :  "; auto itr=x; while(itr!=y) cout<<(*itr++)<<' '; cout<<endl; }
#define deba(x) {cout<<"-->  "<<#x<<" :  "; for(auto ele:(x)) cout<<ele<<"  "; cout<<endl; }
#define deb(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s);istream_iterator<string> _it(_ss); err(_it, args); }
void err(istream_iterator<string> it) {cout<<endl;}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
    cerr << *it << " = " << a <<"  ,  ";
    err(++it, args...);
}


int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	string s;
    cin>>s;
    int n=s.length();
    if(s[n-1]=='s'){
        cout<<s<<"es"<<endl;
    }else{
        cout<<s<<"s"<<endl;
    }
	return 0;

}


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

void solve() {
    int s, w;
    cin >> s >> w;

    cout << (s <= w ? "unsafe" : "safe") << endl;
}

int main() {
    solve();
    return 0;
}


Measured memory_bytes: 3584
// vvvvvvvvvvvv TEMPLATE vvvvvvvvvvvv
#include <bits/stdc++.h>
using namespace std; using ll = long long; using P = pair<ll, ll>;
const ll linf = 1e18; const double eps = 1e-12, pi = acos(-1);
#define FOR(i,a,b) for (ll i=(a),__last_##i=(b);i<__last_##i;i++)
#define RFOR(i,a,b) for (ll i=(b)-1,__last_##i=(a);i>=__last_##i;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define __GET_MACRO3(_1, _2, _3, NAME, ...) NAME
#define each(i,a) for (auto&& i : a)
#define rep(...) __GET_MACRO3(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define rrep(...) __GET_MACRO3(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)
#define pb push_back
#define eb emplace_back
#define all(a) begin(a),end(a)
#define chmin(x,v) x = min(x, v)
#define chmax(x,v) x = max(x, v)
#define min(x,y) (x < y ? x : y)
#define max(x,y) (x < y ? y : x)
template<typename Head> void out(Head h) { cout << h << endl; } template<typename Head, typename... Tail>void out(Head h, Tail... t) { cout << h << " "; out(t...); }
template<typename T> istream& operator>>(istream& is, vector<T>& v) { each(x,v) is >> x; return is; }
template<typename T> ostream& operator<<(ostream& os, const vector<T>& v) { rep(i,v.size()) { if (i) os << " "; os << v[i]; } return os; }
template<typename T> ostream& operator<<(ostream& os, const vector<string>& v) { rep(i,v.size()) { if (i) os << endl; os << v[i]; } return os; }
template<typename T> ostream& operator<<(ostream& os, const vector<vector<T>>& v) { rep(i,v.size()) { if (i) os << endl; os << v[i]; } return os; }
struct yes_no : std::numpunct<char> { string_type do_truename() const { return "Yes"; } string_type do_falsename() const { return "No"; } };
void solve(); int main() {
  ios::sync_with_stdio(false); cin.tie(0); locale loc(locale(), new yes_no); cout.imbue(loc); cout << fixed << setprecision(10) << boolalpha;
  solve();
}
// ^^^^^^^^^^^^ TEMPLATE ^^^^^^^^^^^^

class UnionFind {
  vector<ll> par, h, sz;
public:
  UnionFind(ll size) : par(size, 0), h(size, 0), sz(size, 1) {
    rep(i, size) par[i] = i;
  }
  void unite(ll u, ll v) {
    u = root(u), v = root(v);
    if (u == v) return;
    if (h[u] < h[v]) {
      par[u] = v;
      sz[v] += sz[u];
    }
    else {
      par[v] = u;
      sz[u] += sz[v];
    }
    if (h[u] == h[v]) ++h[u];
  }
  ll size(ll v) {
    return sz[root(v)];
  }
  bool isUnited(ll u, ll v) {
    return root(u) == root(v);
  }
  ll root(ll v) {
    if (par[v] == v) return v;
    return par[v] = root(par[v]);
  }
};

void solve() {
  ll n, m; cin >> n >> m;
  vector<ll> p(n); cin >> p;
  UnionFind uf(n);
  rep(i, m) {
    ll x, y; cin >> x >> y; --x, --y;
    uf.unite(x, y);
  }
  vector<set<ll>> a(n), b(n);
  rep(i, n) {
    ll id = uf.root(i);
    a[id].insert(i);
    b[id].insert(p[i]-1);
  }
  ll ans = 0;
  rep(i, n) {
    each(x, a[i]) {
      if (b[i].count(x) > 0) {
        ++ans;
      }
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 22144
import numpy as np
import copy

def main():
    N, M  = list(map(int, input().split()))
    H     = list(map(int, input().split()))
    maxH  = np.zeros(N)

    for itr in range(M):
        A, B = list(map(int, input().split()))
        if H[A- 1] == H[B- 1] :
            maxH[A- 1] = copy.copy(H[A- 1]) + 1
            maxH[B- 1] = copy.copy(H[A- 1]) + 1
        elif H[A- 1] > H[B- 1] :
            if maxH[A- 1] < H[A- 1] :
                maxH[A- 1] = copy.copy(H[A- 1])
            if maxH[B- 1] < H[A- 1] :
                maxH[B- 1] = copy.copy(H[A- 1])
        elif H[A- 1] < H[B- 1] :
            if maxH[A- 1] < H[B- 1] :
                maxH[A- 1] = copy.copy(H[B- 1])
            if maxH[B- 1] < H[B- 1] :
                maxH[B- 1] = copy.copy(H[B- 1])
    
    result = 0
    for itr in range(N):
        if H[itr] == maxH[itr] or maxH[itr] == 0:
            result += 1
    #print(maxH)
    print(result)

if __name__ == "__main__":
    main()




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

int main()
{
	int x[5];
	for (int i = 0; i < 5; ++i)
	{
		cin >> x[i];
	}
	
	for (int i = 0; i < 5; ++i)
	{
		if (x[i] == 0)
		{
			cout << i+1 << endl;
			return 0;
		}
	}
	
	return 0;
}


Measured memory_bytes: 3552
Scanf.scanf "%d %d" (fun n m ->
    let ab = Array.init m (fun _ -> Scanf.scanf " %d %d" (fun a b -> a, b)) in
    let rec loop exc acc =
        if exc = m then acc else (
            let par = Array.init n (fun i -> i) in
            let rec root x =
                if par.(x) = x then x else
                    let r = root par.(x) in
                    let () = par.(x) <- r in
                    r
            in
            let merge a b =
                if root a <> root b then par.(par.(b)) <- par.(a)
            in
            Array.iteri (fun i (a, b) -> if i <> exc then merge (a - 1) (b - 1)) ab;
            let rec loop2 i prev =
                if i = n then true else
                    if root i <> prev then false else loop2 (i + 1) prev
            in
            let acc = if loop2 1 (root 0) then acc else acc + 1 in
            loop (exc + 1) acc
        )
    in
    loop 0 0 |> Printf.printf "%d\n"
)

Measured memory_bytes: 512
import java.util.*;
public class Main {
   public static void main(String[] args) {  
      Scanner sc = new Scanner(System.in);
      
      int n = sc.nextInt();
      int[] a = new int[n+1];
      for(int i = 0; i < n; i++) {
         a[sc.nextInt()] = i + 1;
      }
      for(int x  = 1; x < a.length; x++) {
         System.out.print(a[x] + " ");
      }
   }
}

Measured memory_bytes: 62692
import numpy as np 
N,M,Q=map(int, input().split())
a=np.array([[0]*N for i in range(N)])

for i in range(M):
  l,r=map(int, input().split())
  a[l-1][r-1]+=1
a=a.cumsum(axis=0).cumsum(axis=1)

for i in range(Q):
  p,q=map(int, input().split())
  if p==1:
    ans=a[q-1][q-1]
  else:
    ans=a[q-1][q-1]-a[p-2][q-1]
  print(ans)

Measured memory_bytes: 32912
from collections import deque
n = input()
a = [int(i) for i in list(n)]
k = int(input())
n = len(n)
ans = 0

if k > n:
    ans = 0
elif k == 1:
    # n 桁目に非負整数
    ans += a[0]
    # n 桁目以外に非負整数
    ans += (n - 1)*9
elif k == 2:
    # 上と同様
    for i in range(1, n):
        if a[i] != 0:
            j = i
            break
    else:
        j = n - 1
    ans += a[j] + (n - j - 1)*9
    # n 桁目の最大ではない非負整数と n-1 桁目以降に 1 つ非負整数
    ans += (a[0] - 1)*(n - 1)*9
    # n-1 桁目以降の中から 2 つ非負整数
    ans += (n - 1)*(n - 2)*9*9//2
else:
    # 上と同様
    j, l= -1, n - 1
    for i in range(1, n):
        if a[i] != 0:
            if j == -1:
                j = i
            else:
                l = i
                break
    if j != -1 and j != n - 1:
        ans += a[l] + (n - l - 1)*9 + (a[j] - 1)*(n - j - 1)*9 + (n - j - 1)*(n - j - 2)*9*9//2
    # n 桁目の最大でない非負整数と n-1 桁目以降に 2 つ非負整数
    ans += (a[0] - 1)*(n - 1)*(n - 2)*9*9//2
    # n-1 桁目以降から 3 つ非負整数
    ans += (n - 1)*(n - 2)*(n - 3)*9*9*9//6
print(ans)

Measured memory_bytes: 3316
#include <iostream>
#include <string>
#include <map>
#include <algorithm>

typedef long long ll;
using namespace std;
typedef pair<string, string> PSS;

PSS split(const string& s, int n) {
  string s1;
  string s2;

  for (int i = 0; i < s.length(); i++) {
    if (((n >> i) & 1)) {
      s1 += s[i];
    } else {
      s2 += s[i];
    }
  }

  return make_pair(s1, s2);
}

int main() {
  int N;
  string s;
  cin >> N >> s;
  string left = s.substr(0, N);
  string right = s.substr(N, 2*N);
  reverse(right.begin(), right.end());

  int n = 1 << N;
  ll cnt = 0;
  map<PSS, ll> m;
  for (int n = 0; n < (1 << N); n++) {
    PSS p = split(right, n);
    m[p] += 1;
  }
  for (int n = 0; n < (1 << N); n++) {
    PSS p = split(left, n);
    cnt += m[p];
  }

  cout << cnt << endl;

  return 0;
}


Measured memory_bytes: 91904
s=input()

if s[0] == s[1] and s[0] == s[2] and s[0] == s[3]:
  print("No")

elif s[0] == s[1] or s[0] == s[2] or s[0] == s[3]:
  if s[0] == s[1]:
    if s[2] == s[3]:
      print("Yes")
    else:
     print("No")
  elif  s[0] != s[1]:
    if s[1] == s[2]:
      print("Yes")
    elif  s[1] == s[3]:
      print("Yes")
    else:
     print("No")
  else:
     print("No")

else:
  print("No")

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
 
#define ll long long int
#define rep(i, n) for(int i = 0; i < n; i++)
#define repp(i, n) for(int i = 1; i <= n; i++)
#define sort(v) sort((v).begin(), (v).end())
#define pb push_back
#define mp make_pair
#define all(a) (a).begin(),(a).end()
#define riverse(v) reverse((v).begin(), (v).end())
using vi = vector<int>;
using vs = vector<string>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vb = vector<bool>;
using vvb = vector<vb>;
const ll MOD = 1e9+7;
vi alphabet = {'a','b','c','d','e','f','g','h','i','j','k','l','m',
               'n','o','p','q','r','s','t','u','v','w','x','y','z'};

int main() {
    string S, T;
    cin >> S >> T;
    bool frag = true;
    int n = S.size();
    int i = 0;
    vvi ansS(26, vi(n));
    vvi ansT(26, vi(n));
    for (char x : alphabet) {
        rep(j, n) {
            if (S[j] == x)ansS[i][j] = 1;
            if (T[j] == x)ansT[i][j] = 1;
        }
        i++;
    }
    rep(j, 26) {
        rep(k,ansT.size()) {
            if (ansS[j] == ansT[k]) {
                ansT.erase(ansT.begin()+k);
                break;
            }
        }
    }
    if (!ansT.empty())frag = false;
    if (frag) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 42104
local mfl = math.floor
local mod = 1000000007
local function badd(x, y) return (x + y) % mod end
local function bmul(x, y)
  local x1, y1 = mfl(x / 31623), mfl(y / 31623)
  local x0, y0 = x - x1 * 31623, y - y1 * 31623
  return (x1 * y1 * 14122 + (x1 * y0 + x0 * y1) * 31623 + x0 * y0) % mod
end
local function lltonumber(str)
  local ret = 0LL
  for i = 1, #str do
    ret = ret * 10LL + str:sub(i, i):byte() - 48
  end
  return ret
end

local s = io.read()
local n, k = s:match("(%d+) (%d+)")
n = tonumber(n)
k = lltonumber(k)
local t = {}
for i = 1, n do
  t[i] = {}
  for j = 1, n do
    t[i][j] = io.read("*n")
  end
end
local cpy = {}
for i = 1, n do
  cpy[i] = {}
  for j = 1, n do
    cpy[i][j] = 0
  end
end
local function update()
  for i = 1, n do
    for j = 1, n do
      cpy[i][j] = 0
    end
  end
  for i = 1, n do
    for j = 1, n do
      for k = 1, n do
        cpy[i][k] = badd(cpy[i][k], bmul(t[i][j], t[j][k]))
      end
    end
  end
  for i = 1, n do
    for j = 1, n do
      t[i][j] = cpy[i][j]
    end
  end
end
local src, dst = {}, {}
for i = 1, n do
  src[i] = 1
  dst[i] = 0
end
while 0LL < k do
  if k % 2LL == 1LL then
    for i = 1, n do
      dst[i] = 0
    end
    for i = 1, n do
      for j = 1, n do
        dst[j] = badd(dst[j], bmul(t[i][j], src[i]))
      end
    end
    for i = 1, n do
      src[i] = dst[i]
    end
  end
  update()
  k = k / 2LL
end
local ret = 0
for i = 1, n do
  ret = badd(ret, src[i])
end
print(ret)


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
#define rep(i,n) for(ll i=0;i<n;++i)
#define ocut cout
#define ouct cout
#define itn int

struct Union{
  vector<ll> par;
  Union(ll a){
  par=vector<ll>(a,-1);
  }
  ll find(ll a){
    if(par[a]<0){
      return a;
    }
    else{
      return par[a]=find(par[a]);
    }
  }
  bool same(ll a,ll b){
    return (find(a)==find(b));
  }
  ll size(ll a){
    return -par[find(a)];
  }
  void unite(ll a,ll b){
    ll c=find(a),d=find(b);
    if(c==d)
      return;
    if(size(c)<size(d)){
      swap(c,d);
    }
    par[c]+=par[d];
    par[d]=c;
  }
};
ll euclidean_gcd(ll a, ll b) {
  if(a < b) return euclidean_gcd(b, a);
  ll r;
  while ((r=a%b)) {
    a = b;
    b = r;
  }
  return b;
}
ll euclidean_lcm(ll a, ll b) {
  return a/euclidean_gcd(a,b)*b;
}

ll binary(ll bina){
    ll ans = 0;
    for (ll i = 0; bina>0 ; i++)
    {
        ans += bina%2;
        bina = bina/2;
    }
    return ans;
}
void revStr(char* str){
	int size = strlen(str);
	int i,j;
	char tmp = {0};
	
	for(i = 0, j = size - 1; i < size / 2; i++, j--){
		tmp = str[i];
		str[i] = str[j];
		str[j] = tmp;
	}
	return;	
}
int main(void){
  string s;
  cin >> s;
  int n=0;
  rep(i,s.size()){
    n+=(s[i]-'0');
  }
  if(n%9==0)cout << "Yes";
  else cout << "No";
}

Measured memory_bytes: 3724
L, R = map(int, input().split())
M = (L+2019-1)//2019*2019

if M<=R:
    print(0)
    exit()

ans = 10**18

for i in range(L, R):
    for j in range(i+1, R+1):
        ans = min(ans, i*j%2019)

print(ans)

Measured memory_bytes: 40812
#include<bits/stdc++.h>
using namespace std;
#define ll long long
const ll inf=1e16;
int n,k,w[110],v[110];
ll f[100010];
int main()
{
	scanf("%d%d",&n,&k);
	for (int i=1;i<=n;i++)
	{
		scanf("%d%d",&w[i],&v[i]);
	}
	for (int i=1;i<=100000;i++)
	{
		f[i]=inf;
	}
	for (int i=1;i<=n;i++)
	{
		for (int j=100000;j>=v[i];j--)
		{
			f[j]=min(f[j],f[j-v[i]]+w[i]);
		}
	}
	for (int i=100000;i>=0;i--)
	{
		if (f[i]<=k)
		{
			cout<<i<<endl;
			return 0;
		}
	}
	return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define MOD 1000000007
using Graph=vector<vector<int>>;

int main(){
  string S;
  cin>>S;
  bool flag=true;
  int N=S.size();
  for(int i=0;i<N/2;i++){
    if(S.at(i)!=S.at(N-1-i)){
      flag=false;
    }
  }
  int n=(N-1)/2;
  for(int i=0;i<n/2;i++){
    if(S.at(i)!=S.at(n-1-i)){
      flag=false;
    }
  }
  for(int i=0;i<n/2;i++){
    if(S.at(n+1+i)!=S.at(N-1-i)){
      flag=false;
    }
  }
  if(flag){
    cout<<"Yes"<<endl;
  }else{
    cout<<"No"<<endl;
  }
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (n); ++i)
typedef long long ll;
 int main(){
     int n;
     cin >> n;
     vector <int> p(n);
     rep(i,n) cin >> p[i];
     int ans = 0;
     for(int i = 1; i <= n-2; i++){
         if((p[i]- p[i+1])*(p[i] - p[i-1]) < 0) ans++;
     }
     cout << ans << endl;
     return 0;
 }

Measured memory_bytes: 256
#include <iostream>
#include <math.h>
#include <algorithm>
#include <string>
#include <map>
#include <vector>
#include <cmath>

using namespace std;

void c_train_ticket(void) {
	string abcd;
	int a, b, c, d;
	cin >> abcd;
	a = abcd[0] - '0';
	b = abcd[1] - '0';
	c = abcd[2] - '0';
	d = abcd[3] - '0';
	char op[2] = { '+','-' };


	for (int j = 0; j < 2; j++) {
		int ab = 0;
		if (j == 0) ab = a + b;
		else        ab = a - b;
		for (int i = 0; i < 2; i++) {
			int abc = 0;
			if (i == 0) abc = ab + c;
			else        abc = ab - c;
			for (int k = 0; k < 2; k++) {
				int abcd = 0;
				if (k == 0) abcd = abc + d;
				else        abcd = abc - d;

				if (abcd == 7) {
					cout << a << op[j] << b << op[i] << c << op[k] << d << "=7" << endl;
					return;
				}
			}
		}
	}

	
}

int main()
{
    c_train_ticket();
    return 0;
}

Measured memory_bytes: 3608
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <string>
#include <cstring>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <cmath>
#include <iomanip>
#include <cassert>
#include <bitset>
using namespace std;

typedef pair<int, int> P;
#define rep(i, n) for (int i=0; i<(n); i++)
#define all(c) (c).begin(), (c).end()
#define uniq(c) c.erase(unique(all(c)), (c).end())
#define index(xs, x) (int)(lower_bound(all(xs), x) - xs.begin())
#define _1 first
#define _2 second
#define pb push_back
#define INF 1145141919
#define MOD 1000000007

int N, M;
vector<int> G[50];

int K;
bool used[50];
int ord[50], low[50];
int ans;
void dfs(int x, int p) {
  used[x] = true;
  low[x] = ord[x] = K++;
  for (int t : G[x]) {
    if (t == p) continue;
    if (used[t]) {
      low[x] = min(low[x], low[t]);
      continue;
    }
    dfs(t, x);
    low[x] = min(low[x], low[t]);
    if (ord[x] < low[t]) ans++;
  }
}
signed main() {
  ios::sync_with_stdio(false); cin.tie(0);
  cin >> N >> M;
  rep(i, M) {
    int a, b;
    cin >> a >> b;
    a--, b--;
    G[a].pb(b);
    G[b].pb(a);
  }
  rep(i, N) if (!used[i]) dfs(i, -1);
  cout<<ans<<"\n";
  return 0;
}


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

using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define MIN(a,b) ((a)>(b)? (b): (a))
#define MAX(a,b) ((a)<(b)? (b): (a))

const long long INF = 1LL << 60;

typedef unsigned long long ll;

const long long MOD = 1000000000 + 7;

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;
}


//Union-Find tree
struct UnionFind{
    vector<int> par; // par[i]:iの親の番号 (例) par[3] = 2 : 3の親が2
    vector<int> tree_size;  // treeの大きさ

    UnionFind(int N) : par(N),tree_size(N) { //最初は全てが根であるとして初期化
        for(int i = 0; i < N;  i++) par[i] = i;
        for(int i = 0; i < N;  i++) tree_size[i] = 1;
    }  

    int root(int x) { // データxが属する木の根を再帰で得る : root(x) = {xの木の根}
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }
    
    void unite(int x, int y) { //xとyの木を併合
        int rx = root(x); //xの木の根をrx
        int ry = root(y); //yの木の根をyx
        if (rx == ry) return; //xとyの根が同じ(=同じ木にある)ときはそのまま
        par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時 : xの根rxをyの根ryにつける
        tree_size[ry] += 1; //根をつけた場合はtree sizeを1上げる
        tree_size[rx] = -1; // 同じ木になったため、xの根は-1
        //tree_size[x] = -1;  //子になった木はtree_sizeを持たない
    }

    bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }

    int size(int x){ // データxが属する木のサイズを返す
        int rx = root(x); //xの木の根をrx
        return tree_size[rx];
    }
};


int main(){
    int N,K,L;
    cin >> N >> K >> L;
    int p,q;
    UnionFind road(N+1);
    UnionFind line(N+1);
    rep(i,K){
        cin >> p >> q;
        road.unite(p,q);
    }
    rep(i,L){
        cin >> p >> q;
        line.unite(p,q);
    }
    vector<set<int>> road_set(N+1);
    vector<set<int>> line_set(N+1);
    set<int> parent;
    for(int i=1; i<N+1; i++){
        road_set[road.root(i)].insert(i);
        line_set[line.root(i)].insert(i);
        parent.insert(road.root(i));
    }

    map<pair<int,int>,int> pairs;
    
    int town[N+1];
    rep(i,N+1) town[i] = 1;
    for(int i = 1; i<N+1; i++){
        pair<int,int> npair = make_pair(road.root(i),line.root(i));
        if(pairs.find(npair) != pairs.end()){
            pairs[npair] += 1;
        }else{
            pairs.emplace(npair,1);
        }
    }
    for(int i = 1;i<N+1;i++){
        pair<int,int>npair = make_pair(road.root(i),line.root(i));
        cout << pairs[npair] << " ";
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 60416
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using static System.Console;
using static System.Math;

namespace At
{
    class Program
    {
        static void Main(string[] args)
        {
            var x = Read();
            WriteLine(x.Replace("2017", "2018"));
        }

        private static string Read() { return ReadLine(); }
        private static string[] Reads() { return (Read().Split()); }
        private static int ReadInt() { return int.Parse(Read()); }
        private static long ReadLong() { return long.Parse(Read()); }
        private static double ReadDouble() { return double.Parse(Read()); }
        private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
        private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
        private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }
    }
}


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

// clang-format off
#define forn(i, x, y) for(int i = x; i < y; i++)
#define IOS ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(NULL)
#define printVector(a) for(auto it = a.begin() ; it != a.end(); it++) {cout << *it << endl;}
// clang-format on

using VD = vector<double>;

int main()
{
  IOS;

  int N;
  cin >> N;
  double p;

  VD dp(N + 1);
  dp[0] = 1.0;
  for (int i = 0; i < N; i++)
  {
    cin >> p;
    for (int j = i + 1; j >= 0; j--)
    {
      dp[j] *= (1 - p);
      if (j > 0)
        dp[j] += dp[j - 1] * p;
    }
  }

  double res = 0;
  for (int i = N / 2 + 1; i <= N; i++)
    res += dp[i];
  cout << fixed << setprecision(10) << res << endl;

  return 0;
}


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

int main(){
  string s,t;
  cin>>s>>t;
  rep(i,s.size()){
    if(s[i]!=t[i]){
      cout<<"No"<<endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
}

Measured memory_bytes: 3636
# coding: utf-8

l = list(input())
counter = 0
atcorder = []


for i in range(len(l)):
    if(l[i] == "A" or l[i] == "T" or l[i] == "G" or l[i] == "C"):
        counter += 1
        atcorder.append(counter)
        continue

    counter = 0


if(len(atcorder) != 0):
    print(max(atcorder))
else:
    print("0")


Measured memory_bytes: 3060
#include<stdio.h>
int main(){
    char s[100001];
    int i=0,j=0,k=0,rcnt=0,lcnt=0,rnum[50001],lnum[50001],sumnum[50001],res[100001],harf;
    scanf("%s",s);
    while(1){
        if(s[i]=='R'){
            if(lcnt>0){
                lnum[j]=lcnt;
                lcnt=0;
                sumnum[j]=lnum[j]+rnum[j];
                j++;
            }
            rcnt++;
            i++;
        }else if(s[i]=='L'){
            if(rcnt>0){
                rnum[j]=rcnt;
                rcnt=0;
            }
            lcnt++;
            i++;
        }else{
            lnum[j]=lcnt;
            sumnum[j]=lnum[j]+rnum[j];
            j++;
            break;
        }
    }
    
    i=0;
    while(sumnum[i]>0){
        harf=sumnum[i]/2;
        if(sumnum[i]%2==0){
            for(j=0;j<rnum[i]-1;j++){
                res[k]=0;
                k++;
            }
            res[k]=harf;
            k++;
            res[k]=harf;
            k++;
            for(j=0;j<lnum[i]-1;j++){
                res[k]=0;
                k++;
            }
        }else{
            for(j=0;j<rnum[i]-1;j++){
                res[k]=0;
                k++;
            }
            if(rnum[i]%2==0){
                res[k]=harf;
                k++;
                res[k]=harf+1;
                k++;
            }else{
                res[k]=harf+1;
                k++;
                res[k]=harf;
                k++;
            }
            for(j=0;j<lnum[i]-1;j++){
                res[k]=0;
                k++;
            }
        }
        i++;
    }
    for(i=0;i<k;i++){
        printf("%d ",res[i]);
    }
    printf("\n");
}

Measured memory_bytes: 1408
#include <vector>
#include <algorithm>
#include <math.h>
#include <iostream>
#include <map>
using namespace std;
const int MAXN = 2 * (int)1e5 + 5;

class DSU {
private:
  std::vector<int> rank, p, size;
public:
  DSU(int n): rank(n, 0), p(n), size(n, 1) {
    for (int i = 0; i < n; ++i) p[i] = i;
  }

  int findRep(int x) {
    if (p[x] != x) {
      p[x] = findRep(p[x]);
    }
    return p[x];
  }

  void unite(int x, int y) {
    int p1 = findRep(x), p2 = findRep(y);
    if (p1 == p2) return;
    if (rank[p1] < rank[p2]) std::swap(p1, p2);
    
    if (rank[p1] == rank[p2]) rank[p1]++;
    p[p2] = p1;
    size[p1] += size[p2];
  }

  int getSize(int x) {
    int xRep = findRep(x);
    return size[xRep];
  }

  bool isSame(int x, int y) {
    return findRep(x) == findRep(y);
  }
};

int main() {
  int n, k, l;
  cin >> n >> k >> l;
  DSU dsu1(n); DSU dsu2(n);
  for (int i = 0; i < k; ++i) {
    int p, q;
    cin >> p >> q;
    p--; q--;
    dsu1.unite(p, q);
  }

  for (int i = 0; i < l; ++i) {
    int r, s;
    cin >> r >> s;
    r--; s--;
    dsu2.unite(r, s);
  }

  map<pair<int, int>, int> m;
  for (int i = 0; i < n; ++i) {
    int x = dsu1.findRep(i), y = dsu2.findRep(i);
    m[pair<int, int>(x, y)]++;
  }

  for (int i = 0; i < n; ++i) {
    int x = dsu1.findRep(i), y = dsu2.findRep(i);
    int ans = m[pair<int, int>(x, y)];
    cout << ans << " ";
  }
  puts("");
  return 0;
}


Measured memory_bytes: 16640
#include "bits/stdc++.h"
using namespace std;
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

using ll = long long;
using ii = pair<int,int>;
using vi = vector<int>;
using vii = vector<ii>;

const int oo = 1e8+7;
const int mod = 1e9+7;

int n;
vector<vi> AdjList;

ll mul(ll a, ll b) {
    a *= b;
    a %= mod;
    return a;
}

// {black, white}
pair<ll,ll> dfs(int a, int prev) {
    
    ll all_white = 1; //so my vertex can be black
    ll sth_black = 0; //my vertex must be white
    
    for(int b : AdjList[a]) {
        if(b == prev) continue;
        
        pair<ll,ll> p = dfs(b, a);
        
        int memo_white = all_white;
        all_white = mul(all_white, p.second);
        sth_black = (mul(sth_black, p.first+p.second) + mul(memo_white,
                    p.first)) % mod;
    }
    
    debug() << imie(a) imie(all_white) imie(sth_black);
    return make_pair(all_white, sth_black+all_white);
}

int main() {
    
    // dp[v][0] - in how many ways can we paint v and descendants
    //            if vertex v is black / white (BOOL)
    
    scanf("%d",&n);
    
    AdjList.resize(n);
    
    for(int i = 0; i < n-1; ++i) {
        int c1, c2;
        scanf("%d%d",&c1,&c2);
        c1--; c2--;
        AdjList[c1].push_back(c2);
        AdjList[c2].push_back(c1);
    }
    
    pair<ll,ll> ans = dfs(0, -1);
    
    printf("%lld\n", (ans.first+ans.second)%mod);
    
    return 0;
}




Measured memory_bytes: 12672
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <unordered_map>
#include <queue>
#include <algorithm>

#include <bits/stdc++.h>
#include <cmath>
#include <limits>

using namespace std;

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

	int N, Q;
	string S;
	long long AC[100002] = {0};

	
	cin >> N >> Q;
	cin >> S;
	const char* s = S.c_str();
	// N = strlen(s)
	AC[0] = 0;
	for(int i=0; i < N - 1; i++){
		if(strncmp(s+i, "AC", 2) == 0){
			AC[i + 1] = AC[i];
			AC[i + 2] = AC[i + 1] + 1;
			i++;
		}
		else{
			AC[i + 1] = AC[i];
			if(i == N - 2){
				AC[N] = AC[N - 1];
				break;
			}
		}
	}
	if(strncmp(s+N-2, "AC", 2) != 0){
		AC[N] = AC[N-1];
	}

	for(int i = 1; i <= Q; i++){
		int l, r;
		cin >> l >> r;
		long long ans;
		ans = AC[r] - AC[l - 1];
		if(AC[l] != AC[l - 1]){
			ans--;
		}
		cout << ans << endl ;
	}
	return 0;
}

Measured memory_bytes: 1872
#include <iostream>
#include <cmath>
#include <vector>
#include <map>
#include <stack>
#include <queue>
#include <set>
#include <algorithm>
#include <iomanip>
#include <string.h>

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

typedef long long lint;

using namespace std;

int main(){
  int A,B;
  cin>>A>>B;
  int ans=A+B;
  ans=max(ans,A-B);
  ans=max(ans,A*B);
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10**8)
def ii(): return int(sys.stdin.readline())
def mi(): return map(int, sys.stdin.readline().split())
def li(): return list(map(int, sys.stdin.readline().split()))
def li2(N): return [list(map(int, sys.stdin.readline().split())) for _ in range(N)]
def dp2(ini, i, j): return [[ini]*i for _ in range(j)]
#import bisect #bisect.bisect_left(B, a)
#from collections import defaultdict #d = defaultdict(int) d[key] += value
#from collections import Counter # a = Counter(A).most_common()
#from itertools import accumulate #list(accumulate(A))

A = sorted([ii() for _ in range(5)])

K = ii()

if A[-1] - A[0] > K:
    print(':(')
else:
    print('Yay!')


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

int main()
{
	char x;
	cin >> x;
	if (x == 'A') {
		cout << 'T';
	}else if(x == 'T'){
		cout << 'A';
	}else if(x == 'G'){
		cout << 'C';
	}else if(x == 'C'){
		cout << 'G';
	}
	cin >> x;
}

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

using namespace std;

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

    map<int, int> f;
    int s = 0;
    f[0] = 1;
    long long int r = 0;
    for (int i = 0; i < n; i++) {
        int a;
        cin >> a;
        s = (s + a) % m;
        r += f[s];
        f[s]++;
    }

    cout << r << endl;
    
    return 0;
}

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

#define INF 1.1e9
#define LINF 1.1e18
#define FOR(i,a,b) for (int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
#define pb push_back
#define pf push_front
#define fi first
#define se second
#define BIT(x,n) bitset<n>(x)
#define PI 3.14159265358979323846

typedef long long ll;
typedef pair<int,int> P;
typedef pair<ll,P> PP;

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

int a,b,c;

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

	cin>>a>>b>>c;
	if(a+b>=c) cout<<"Yes"<<endl;
	else cout<<"No"<<endl;

	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int search (int n, int x) {
  int  i, j, k, ans = 0;
  if( x <= n + 2 ) i = x - 3;
  /* else if ( x > n + 2 ) i = x - 2; */
  else  i = n;
  j = x - i - 1;
  if ( j >= n ) j = i - 1 ;
  k = x - i - j;
  while( k < j && j < i ) {
    while(0 < j ) {
      ans++;
      j--;
      k++;
      if( j <= k) break;
    }
    i--;
    j = x - i - 1;
    /* if ( j > n ) j = i - 1 ; */
    if ( j >= i ) j = i - 1;
    k = x - i - j;
    if ( k > n) break;
  }
  return ans;
}

int main (void) {
  int  n, x, ans = 0;
  while ( 1 ){
    scanf("%d %d\n", &n, &x);
    if (n==0 && x == 0) break;
    ans = search(n, x);
    printf("%d\n", ans);
  }
  return 0;
}



Measured memory_bytes: 2056
import java.util.*;
public class Main {
 public static void main(String[] args){
	Scanner sc = new Scanner(System.in);
	int n=sc.nextInt();
	int[] a=new int[n];
	int[] c=new int[n];
	int r=0;
    for(int i=0;i<n;i++)a[i]=sc.nextInt()-1;
    for(int i=0;i<n;i++)r+=sc.nextInt();
    for(int i=0;i<n-1;i++)c[i]=sc.nextInt();
    for(int i=1;i<n;i++)if(a[i-1]==a[i]-1)r+=c[a[i-1]];
	System.out.println(r);
 }
}

Measured memory_bytes: 23892
n = int(input())
s = input()
s += s[0]
d = {'S':'W', 'W':'S'}
flag = True
for sw in ['SS', 'WW', 'SW', 'WS']:
    l = sw
    for i in range(1, n+1):
        if l[i] == 'S' and s[i] == 'o' or l[i] == 'W' and s[i] == 'x':
            l += l[i-1]
        else:
            l += d[l[i-1]]
    if l[0] == l[-2] and l[1] == l[-1] :
        print(l[:-2])
        flag = False
        break
if flag:
    print(-1)



Measured memory_bytes: 3444
#include <bits/stdc++.h>
using namespace std;
constexpr double EPS = 1e-14;

struct vec2 {
    double x, y;
    vec2 operator+(const vec2 rhs) {
        return {x + rhs.x, y + rhs.y};
    }
    vec2 operator-(const vec2 rhs) {
        return {x - rhs.x, y - rhs.y};
    }
    vec2 operator*(const double k) {
        return {x * k, y * k};
    }
    vec2 operator/(const double k) {
        return {x / k, y / k};
    }
};

double dot(vec2 a, vec2 b) {
    return a.x * b.x + a.y * b.y;
};

double norm2(vec2 a) {
    return dot(a, a);
}

struct line {
    vec2 p, l;
};

line make_line(vec2 a, vec2 b) {
    return {a, b - a};
}

double cross(vec2 a, vec2 b) {
    return a.x * b.y - a.y * b.x;
}

bool is_parallel(vec2 a, vec2 b) {
    return abs(cross(a, b)) < EPS;
}

bool is_parallel(line a, line b) {
    return is_parallel(a.l, b.l);
}

double operator/(vec2 a, vec2 b) {
    assert(is_parallel(a, b));
    return a.x / b.x;
}

void printvec2(vec2 p, int precision) {
    cout << setprecision(precision) << fixed << p.x << " " << p.y << endl;
}

vec2 intersection(line l1, line l2) {
    assert(!is_parallel(l1, l2));
    double a = l1.p.x, b = l1.p.y, c = l1.l.x, d = l1.l.y;
    double e = l2.p.x, f = l2.p.y, g = l2.l.x, h = l2.l.y;
    double k = (h * (a - e) - g * (b - f)) / (g * d - c * h);
    return {
        a + k * c,
        b + k * d
    };
}

vec2 get_normal(vec2 p) {
    return {-p.y, p.x};
}

vec2 foot(vec2 p, line l) {
    line normal = {p, get_normal(l.l)};
    return intersection(normal, l);
}

vec2 reflect(vec2 p, line l) {
    vec2 f = foot(p, l);
    return {2 * f.x - p.x, 2 * f.y - p.y};
}

double dist(vec2 p, line l) {
    return sqrt(norm2(foot(p, l) - p));
}

int sgn(double a) {
    if (a < -EPS) return -1;
    if (a > EPS) return 1;
    return 0;
}

int main() {
    int q;
    cin >> q;
    while (q--) {
        double x0, y0, x1, y1, x2, y2, x3, y3;
        cin >> x0 >> y0 >> x1 >> y1 >> x2 >> y2 >> x3 >> y3;
        line a = make_line({x0, y0}, {x1, y1}), b = make_line({x2, y2}, {x3, y3});
        if (is_parallel(a, b)) {
            cout << 2 << endl;
            continue;
        }
        if (is_parallel(a.l, get_normal(b.l))) {
            cout << 1 << endl;
            continue;
        }
        cout << 0 << endl;
    }
}



Measured memory_bytes: 3224
import math
N = int(input())
a = [[math.gcd(i, j) for j in range(1, N+1)] for i in range(1, N+1)]
s = [sum(a[i]) for i in range(N)]
ans = 0
for i in range(N):
  for j in range(N):
    ans = ans + s[a[i][j]-1]
print(ans)

Measured memory_bytes: 9472
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<algorithm>
using namespace std;

int main()
{
    int k,x;
    cin>>k>>x;

    for(int i=x-k+1;i<=x+k-1;i++){
        if(i!=x-k+1) cout<<" ";
        cout<<i;
    }
    cout<<endl;

	return 0;
}


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

vector<vector<char>> c(3, vector<char>(3));
int main() {
	for (int i = 0; i < 3; i++) {
		for (int j = 0; j < 3; j++) {
			cin >> c.at(i).at(j);
		}
	}

	for (int i = 0; i < 3; i++) {
		for (int j = 0; j < 3; j++) {
			if (i == j) {
				cout << c.at(i).at(j);
			}
		}
	}

	cout << endl;
	return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    double[] a = new double[n];
    double sum = 0;
    for(int i = 0; i < n; i++) {
      a[i] = sc.nextDouble();
      sum += a[i];
    }
    double av = sum / (double)n;
    double t = 1000;
    for(int i = 0; i < n; i++) {
      t = Math.min(t, Math.abs(av - a[i]));
    }
    for(int i = 0; i < n; i++) {
      if(Math.abs(av - a[i]) == t) {
        System.out.println(i);
        break;
      }
    }
  }
}

Measured memory_bytes: 23252
N,M,S=map(int,input().split())
from heapq import heappop,heappush 

inf = 10**18
cost=[[] for _ in range(N)]
exc=[]


for _ in range(M):
    u,v,a,b=map(int,input().split())
    u,v=u-1,v-1
    cost[u].append((v,a,b))
    cost[v].append((u,a,b))
for _ in range(N):
    c,d=map(int,input().split())
    exc.append((c,d))

di=[inf]*2451*N
if S>2450:
    S=2450
di[S]=0
hq=[(0,S)] #時間,都市名*2451+銀貨

while hq:
    t,v=heappop(hq)
    u=v//2451 #都市名
    s=v%2451 #所持金

    for x,a,b in cost[u]:
        if s>=a:
            v_new=x*2451+s-a
            t_new=t+b
            if t_new<di[v_new]:
                di[v_new]=t_new
                heappush(hq,(t_new,v_new))
    
    c,d=exc[u]
    if s+c>2450:
        c=2450-s
    v_new=v+c
    t_new=t+d
    if t_new<di[v_new]:
        di[v_new]=t_new
        heappush(hq,(t_new,v_new))

for i in range(1,N):
    m=di[i*2451]
    for j in range(1,2451):
        m=min(m,di[i*2451+j])
    print(m)

Measured memory_bytes: 23880
#include<iostream>
#include<cmath>
#include<iomanip>
#include<string>

using namespace std;

int main(){
  double x1, y1, x2, y2;
  cin >> x1 >> y1 >> x2 >> y2;
  double ans = sqrt((x2-x1)*(x2-x1) + (y2-y1)*(y2-y1));
  cout << fixed << setprecision(8) << ans << endl;
}


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

int main(){
	ios::sync_with_stdio(false);
	int x1,y1,x2,y2; cin>>x1>>y1>>x2>>y2;

	int x3,y3,x4,y4;
	x3 = -(y2-y1) + x2;
	y3 = (x2-x1) + y2;
	x4 = -(y2-y1) + x1;
	y4 = (x2-x1) + y1;

	cout << x3 << " " << y3 << " " << x4 << " " << y4 <<endl;
}


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

using namespace std;
typedef long long ll;
int main(){
  string S1,T;
  cin >> S1 >> T;
  int sizeS = S1.size() - 1;
  int sizeT = T.size() - 1;
  bool A = false;
  //後ろから見てってTが入れれそうなら入れる 全部入れきったら残りをaにする
  for(int i = sizeS; i >= sizeT; i--){
    string S = S1;
    for(int j = 0; j <= sizeT; j++){
      if(S[i - j] == '?' || S[i - j] == T[sizeT - j]){
        S[i - j] = T[sizeT - j];
      }
      else{
        break;
      }
      if(j == sizeT){
        A = true;
      }
    }
    if(A){
      for(int i = 0; i <= sizeS; i++){
        if(S[i] == '?'){
          S[i] = 'a';
        }
        S1 = S;
      }
      break;
    }
  }
  if(A){
  cout << S1 <<endl;
  }
  else{
    cout << "UNRESTORABLE" <<endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
  string S,fw,bw;
  cin>>S;
  fw.push_back(S.at(0));
  fw.push_back(S.at(1));
  bw.push_back(S.at(2));
  bw.push_back(S.at(3));
  if(fw>="01"&&fw<="12"&&bw>="01"&&bw<="12"){cout<<"AMBIGUOUS"<<endl;}
  else if(fw<="12"&&fw!="00"){cout<<"MMYY"<<endl;}
  else if(bw<="12"&&bw!="00"){cout<<"YYMM"<<endl;}
  else{cout<<"NA"<<endl;}
}

Measured memory_bytes: 256
// BEGINNING WITH THE NAME OF ALMIGHTY GOD ALLAH
// AUTHOR:: MOHAMMAD FAISAL
#include<bits/stdc++.h>
using namespace std;
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.flush();
    int n,a;
    cin >> n >> a;
    cout<<(n*n)-a;
	return 0;
	// BYE BYE 
}


Measured memory_bytes: 256
import numpy as np

n=10**6
nsq=10**3
mod=10**9+7
fact=np.arange(n,dtype=np.int64).reshape(nsq,nsq); fact[0,0]=1
for n in range(1,nsq):
    fact[:,n]*=fact[:,n-1]; fact[:,n]%=mod
for n in range(1,nsq):
    fact[n]*=fact[n-1,-1];fact[n]%=mod
fact=fact.ravel()

n,m=map(int,input().split())
p=fact[n]
q=fact[m]
if abs(n-m)>=2:
    print(0)
elif abs(n-m)==1:
    print((p*q)%(10**9+7))
else:
    print(2*(p*q)%(10**9+7))


Measured memory_bytes: 20284
// Best practice

#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file 
#include <ext/pb_ds/tree_policy.hpp> 
#include <ext/pb_ds/detail/standard_policies.hpp>
#include <functional> // for less 

#define int         long long
#define pb          emplace_back
#define pf          emplace_front
#define all(a)      (a).begin(),(a).end()
#define rall(a)     (a).rbegin(),(a).rend()
#define x           first
#define y           second
#define endl        '\n'
#define tezz        ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
using namespace std;
using namespace __gnu_pbds; 
 
typedef tree<pair<int,int>, null_type, less<pair<int,int>>, rb_tree_tag, tree_order_statistics_node_update> pbds; 

#define fbo find_by_order
#define ook order_of_key

signed main() {
   tezz
   
   string s,ss;
   cin >> s >> ss;
   int n=s.length();
   int k=ss.length();
   int dp[n+1][k+1];
   for(int i=0; i<=n; i++){
       for(int j=0; j<=k; j++){
           if(i==0 || j==0)dp[i][j]=0;
           else{
               if(s[i-1]==ss[j-1])dp[i][j]=dp[i-1][j-1]+1;
               else dp[i][j]=max({ dp[i-1][j] , dp[i][j-1]});
           }
       }
   }
   string ans="";
   int i=n,j=k;
   while(i>0 && j>0){
           if(dp[i][j]==dp[i-1][j])i--;
           else if(dp[i][j]==dp[i][j-1])j--;
            else{
                ans+=ss[j-1];
                i--;
                j--;
            }
       
   }
   reverse(all(ans));
   cout << ans << endl;
   
   return 0;
}


Measured memory_bytes: 70656
#include <iostream>
#include<string>
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<vector>
using namespace std;
int main(){
    int T,H,S,t3,h3,s3,a,b,c,d,e;
    while(cin>>T>>H>>S){
        if(T==-1&&H==-1&&S==-1)break;
        a=T*3600+H*60+S;
        b=7200-a;
        c=b/3600;
        d=b%3600/60;
        e=b%3600%60;
        t3=3*b/3600;
        h3=3*b%3600/60;
        s3=3*b%3600%60;
        printf("%02d:%02d:%02d",c,d,e);
        cout<<endl;
        printf("%02d:%02d:%02d",t3,h3,s3);
        cout<<endl;
    }
          return 0;
}

Measured memory_bytes: 3204
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <utility>
#include <cmath>
#include <tuple>
#include <queue>
#include <bitset>
#include <set>
#include <map>
#include <list>

using ll = long long;
using ld = long double;
using namespace std;
const int INF = 1e9+100;
const ll INF64 = 7e18l;
const int mod = 1000000007;
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define ALL(a) (a).begin(), (a).end()
#define FIN ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);


int main(){
    FIN;
    ll n;  cin >> n;
    vector<char> rgb(n);
    deque<int> R,B,G;
    ll r,g,b; r = g = b = 0;
    for(int i=0;i<n;i++){
        cin >> rgb[i];
        if(rgb[i] == 'R') r++;
        if(rgb[i] == 'G') g++;
        if(rgb[i] == 'B') b++;
    }

    ll ans = r*g*b;
    for(ll i=0;i<n-2;i++){
        for(ll j=i+1;j<n-1;j++){
            if(rgb[i] == rgb[j]) continue;
            ll k = 2*j - i;
            if(k>=n or rgb[k]==rgb[i] or rgb[k]==rgb[j]) continue;
            ans--;
        }
    }

    cout << ans << endl;
    return 0;
}

/*
    ll ans = 0;
    for(int i=0;i<n-2;i++){
        for(int j=i+1;j<n-1;j++){
            for(int k=j+1;k<n;k++){
                if(rgb[i]!=rgb[j] and rgb[j]!=rgb[k] and rgb[k]!=rgb[i] and (i+k)!=(2*j))
                    ans ++;
            }
        }
    }

    cout << ans << endl;
*/

Measured memory_bytes: 3660
#include <iostream>
#include <algorithm>
#define REP(i,n) for(int i = 0; i < n ; i++)
using namespace std;

int abs(int num){
    if(num < 0){
        return - num;
    }
    return num;
}

int main(void){
    // Your code here!
    int n, m;
    cin >> n >> m;
    int candle[n];
    REP(i,n){
        cin >> candle[i];
    }
    int result = (candle[n-1] - candle[0]) * 2;
    REP(i, n - m + 1){
        int r = min(abs(candle[i]),abs(candle[i + m - 1])) + abs(candle[i] - candle[i + m - 1]);
        result = min(result,r);
    }
    cout << result;
}

Measured memory_bytes: 640
#include <stdio.h>
#include <string.h>
int main()
{
	int h,w;
	char c[10];
	scanf("%d %d",&h,&w);
	for(int i=0;i<h;i++){
		for(int j=0;j<w;j++){
			scanf("%s",c);
			if(c[0]=='s'&&c[1]=='n'&&c[2]=='u'&&c[3]=='k'&&c[4]=='e'){
				printf("%c%d",'A'+j,i+1);
				return 0;
			}
		}
	}
}

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

typedef long long int ll;
typedef double d;

#define tt int t; cin>>t; while(t--)
#define lo(i, a, b) for(int i=a; i<b; i++)
#define rlo(i, a) for(int i=a; i>0; i--)

#define be(a) a.begin(),a.end()
#define sz(x) x.size()

#define nl cout<<"\n";
#define sp cout<<" ";

#define su ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define file() freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);

int main()
{
    su;
    string s;
    cin>>s;
    if(s.find('7')!=string::npos)
        cout<<"Yes";
    else
        cout<<"No";
    nl;
    return 0;
}


Measured memory_bytes: 3596
#include <stdio.h>

int main(void) {
	char c;
	int sum = 0;
    while ((c=getc(stdin))!=EOF) {
    	if('0'<=c && c<='9') {
    		sum += (c-'0');
    		if(sum == 0)
    			break;
    	} else {
    		printf("%d\n", sum);
   			sum = 0;
    	}
    }
	return 0;
}

Measured memory_bytes: 524
#include <stdio.h>
#include <limits.h>
#define H 200000
int v[H+1];
int main(void){
    int h, w, n, x, y;
    scanf("%d %d %d\n", &h, &w, &n);
    for(int i=1; i<h+1; i++){ v[i] = i+1; }
    for(int i=0; i<n; i++){
        scanf("%d %d\n", &x, &y);
        v[x] = y<v[x] ? y : v[x];
    }
    int right = 1;
    for(int x=1; x<h; x++){
        if(v[x+1]<right+1){
            printf("%d\n", x);
            return 0;
        }else if(v[x+1]>right+1){
            right++;
        }
    }
    printf("%d\n", h);
    return 0;
}


Measured memory_bytes: 896
import numpy as np

N, A, B = map(int, input().split())
H = np.zeros(shape=N, dtype='int64')
for _ in range(N):
    h = int(input())
    H[_] = h


def calc(num, a):
    a -= num * B
    a = (a - 1)//(A - B) + 1
    if sum(a[a > 0]) <= num:
        return True
    else:
        return False


start = 0
end = 10 ** 10

while end - start > 1:
    mid = (start + end) // 2
    if calc(mid, H.copy()):
        end = mid
    else:
        start = mid

print(end)


Measured memory_bytes: 30508
n = int(input())
A = list(map(int, input().split()))
q = int(input())
M = list(map(int, input().split()))

cand_list = []
for i in range(1, 2**n):
    cum_num=0
    for j in range(n):
        if i&1<<j:
            cum_num += A[j]
    cand_list.append(cum_num)
    
for m in M:
    if m in set(cand_list):
        print('yes')
    else:
        print('no')


Measured memory_bytes: 43076
#include<bits/stdc++.h>
#define inf 0x3f3f3f3f
using namespace std;
typedef long long ll;
const int N=2e4+5;
int h,n;
ll dp[N];
int main()
{
    memset(dp,inf,sizeof(dp));
    dp[0]=0;
    scanf("%d%d",&h,&n);
    for(int i=1;i<=n;i++)
    {
        int a,b;
        scanf("%d%d",&a,&b);
        for(int j=0;j<=10000;j++)
            dp[j+a]=min(dp[j+a],dp[j]+b);
    }
    ll ans=1e18;
    for(int i=h;i<=20000;i++)
        ans=min(ans,dp[i]);
    printf("%lld\n",ans);
}


Measured memory_bytes: 512
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);

		int n = scan.nextInt();
		String s = scan.next();

		char[] c = s.toCharArray();

		for(int i = 0; i < c.length; i++) {
			for(int j = 0; j < n; j++) {
				c[i]++;
				if(c[i] > 'Z') {
					c[i] -= 26;
				}
			}
		}

		System.out.println(c);

	}

}

Measured memory_bytes: 21844