akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
using namespace std;
#define MAX_N 100
#define INF 1e9

int cost[MAX_N][MAX_N];
int d[MAX_N];
bool used[MAX_N];
int n, u, k, c, v;

void dijkstra(int s){
  fill(d, d + n, INF);
  fill(used, used + n, false);
  d[s] = 0;

  while(true){
    int v = -1;

    for(int u = 0; u < n; u++){
      if(!used[u] && (v == -1 || d[u] < d[v])) v = u;
    }

    if(v == -1) break;
    used[v] = true;

    for(int u = 0; u < n; u++){
      d[u] = min(d[u], d[v] + cost[v][u]);
    }
  }
}

int main(void){
  cin >> n;
  for(int i = 0; i < n; i++){
    for(int j = 0; j < n; j++){
      cost[i][j] = INF;
    }
  }
  for(int i = 0; i < n; i++){
    cin >> u >> k;
    for(int j = 0; j < k; j++){
      cin >> v >> c;
      cost[u][v] = c;
    }
  }
  dijkstra(0);
  for(int i = 0; i < n; i++){
    cout << i << " " << d[i] << endl;
  }
  return 0;
}

Measured memory_bytes: 1200
#include<iostream>
#include<cstdio>
#include<cstring>
#include <cstdlib>  
#include <math.h>
#include <cmath>
#include<complex>
#include<cctype>
#include<string>
#include<set>
#include<iomanip>
#include <map>
#include<algorithm>
#include <functional>
#include<vector>
#include<climits>
#include<stack>
#include<queue>
#include<bitset>
#include <deque>
#include <climits>
#include <typeinfo>
#include <utility> 
#include <numeric>
using namespace std;
using Complex = complex<double>;
using ll = long long;
template<typename T>using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;
const ll inf = 1145141919810364364LL;
double PI = acos(-1.0);
#define all(x) (x).begin(),(x).end()
#define puts(x) cout << x << endl
#define rep(i,m,n) for(ll i = m;i < n;++i)
#define pb push_back
#define fore(i,a) for(auto &i:a)
#define rrep(i,m,n) for(ll i = m;i >= n;--i)

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

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

	int K;
	cin >> K;
	ll ans = 0;
	for (int a = 1; a <= K; a++) {
		for (int b = 1; b <= K; b++) {
			for (int c = 1; c <= K; c++) {
				ans += gcd(a, gcd(b, c));
			}
		}
	}
	puts(ans);

	return 0;
}

Measured memory_bytes: 3652
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0, i##_len = (n); i < i##_len; ++i)
#define rep2(i, x, n) for(int i = x, i##_len = (n); i < i##_len; ++i)
#define all(n) begin(n), end(n)
using ll = long long;
using P = pair<int, int>;
using vi = vector<int>;
using vl = vector<ll>;
using vs = vector<string>;
using vc = vector<char>;
using vb = vector<bool>;
vi dir = {-1, 0, 1, 0, -1, -1, 1, 1, -1};

int main() {
  vector<vi> a(3, vi(3, 0));
  rep(i, 3) rep(j, 3) cin >> a[i][j];
  int n;
  cin >> n;
  rep(k, n) {
    int b;
    cin >> b;
    rep(i, 3) rep(j, 3) if(a[i][j] == b) a[i][j] = -1;
  }
  bool ok = false;
  //
  rep(i, 3) {
    bool yoko = true;
    rep(j, 3) if(a[i][j] != -1) yoko = false;
    if(yoko) ok = true;
  }
  rep(i, 3) {
    bool tate = true;
    rep(j, 3) if(a[j][i] != -1) tate = false;
    if(tate) ok = true;
  }
  if(a[0][0] == -1 && a[1][1] == -1 && a[2][2] == -1) ok = true;
  if(a[0][2] == -1 && a[1][1] == -1 && a[2][0] == -1) ok = true;
  cout << (ok ? "Yes" : "No") << endl;
}

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

int main() {
    int n,m,c;
    cin >> n >> m >> c;
    vector<int> b(m);
    rep(i,m) cin >> b[i];
    int ans = 0;
    rep(i,n) {
        int sum = c;
        rep(j,m) {
            int a;
            cin >> a;
            sum += a*b[j];
        }
        if(sum > 0) ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
/*  -*- coding: utf-8 -*-
 *
 * f.cc: F - Many Slimes
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
 
using namespace std;

/* constant */

const int MAX_N = 18;
const int MAX_M = 1 << MAX_N;

/* typedef */

typedef pair<int,int> pii;
typedef multiset<int> msi;

/* global variables */

int as[MAX_M], vs[MAX_M];
msi xset;

/* subroutines */

/* main */

int main() {
  int n;
  scanf("%d", &n);
  int m = 1 << n;

  for (int i = 0; i < m; i++) scanf("%d", as + i);
  sort(as, as + m);

  xset.insert(m);

  for (int i = m - 1; i >= 0;) {
    int k = 1;
    while (k <= i && as[i] == as[i - k]) k++;
    i -= k;

    if (xset.size() < k) {
      puts("No");
      return 0;
    }

    msi::iterator mit = xset.end();
    for (int j = 0; j < k; j++) vs[j] = *(--mit);
    xset.erase(mit, xset.end());

    for (int j = 0; j < k; j++)
      for (int b = 1; b < vs[j]; b <<= 1) xset.insert(b);
  }

  puts("Yes");
  return 0;
}


Measured memory_bytes: 7936
#include <bits/stdc++.h>
#define double long double
using namespace std;
const int N = 100010;
const int INF = 1LL<<55;
const int mod = (1e9)+7;
const double EPS = 1e-8;
const double PI = 6.0 * asin(0.5);
typedef pair<int,int> P;
typedef long long ll;
template<class T> T Max(T &a,T b){return a=max(a,b);}
template<class T> T Min(T &a,T b){return a=min(a,b);}
ostream& operator<<(ostream& o,P p){return o<<"("<<p.first<<","<<p.second<<")";}
istream& operator>>(istream& i,P &p){return i>>p.first>>p.second;}
ostream& operator<<(ostream& o,vector<auto> &a){int i=0;for(auto t:a)o<<(i++?" ":"")<<t;return o;}
istream& operator>>(istream& i,vector<auto> &a){for(auto &t:a)i>>t;return i;}
void prArr(auto a,string s=" "){int i=0;for(auto t:a)cout<<(i++?s:"")<<t;cout<<endl;}


signed main(){
  ll h,w,n;
  cin>>h>>w>>n;

  map<int,map<int,int> > M;
  vector<int> A(n),B(n);
  for(int i=0;i<n;i++){
    int a,b;
    cin>>a>>b; a--,b--;
    A[i] = a;
    B[i] = b;
    M[a][b] = 1;
  }
  
  map<int,map<int,int> > counted;
  auto count=[&](int y,int x){
    if(y < 0 || x < 0 || y + 2 >= h || x + 2 >= w) return 0;
    if(counted[y][x]++) return 0;

    int cnt = 0;
    for(int i=0;i<3;i++)
      for(int j=0;j<3;j++) cnt += M[y+i][x+j];
    return cnt;
  };

  
  vector<ll> ans(10);
  ans[0] = (w-2)*(h-2);
  for(int k=0;k<n;k++){
    int y = A[k];
    int x = B[k];
    for(int i=-2;i<=0;i++)
      for(int j=-2;j<=0;j++){
        int cnt = count(y+i,x+j);
        if(cnt) ans[0]--,ans[cnt]++;
      }
  }

  for(int i=0;i<10;i++) cout<<ans[i]<<endl;
  
  return 0;
}


Measured memory_bytes: 235392
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <utility>
#include <string>
#include <stack>
#include <regex>
#include <numeric>
#include <queue>
#include <set>

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

using namespace std;

typedef long long ll;

int main(int argc, char const *argv[])
{
  ll a, b;
  cin >> a >> b;
  ll tmp = 1;
  ll cnt = 0;
  while (true)
  {
    if (tmp >= b)
    {
      break;
    }
    tmp--;
    tmp += a;
    cnt++;
  }
  cout << cnt << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <cmath>
#include <iomanip>
using namespace std;
 
#define f first
#define s second
 
#define pb push_back
#define pp pop_back
#define mp make_pair
 
#define sz(x) (int)x.size()
#define sqr(x) ((x) * 1ll * (x))
#define all(x) x.begin(), x.end()
#define clr(a,v) memset(a, v, sizeof(a))
 
#define rep(i, l, r) for (int i = (l); i <= (r); i++)
#define per(i, l, r) for (int i = (l); i >= (r); i--)
#define reflex ios_base::sync_with_stdio(false)
 
#define nl '\n'
#define ioi exit(0);
 
 
#define PI 3.14159265
 
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
 
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const int N= (int)2e5 + 7;
const int inf = (int)1e9 + 7;
const int mod = (int)1e9 + 7;
//const int mod = 1000000007;
const ll linf = (ll)1e18 + 7;
const ll limit = 2e9;

const int dx[] = {-1, 0, 1, 0, 1, -1, -1, 1};
const int dy[] = {0, 1, 0, -1, 1, -1, 1, -1};
const int kx[] = {-1,1,2,2,1,-1,-2,-2};
const int ky[] = {2,2,1,-1,-2,-2,-1,1};
 
//const int mod = 998244353;
 
struct dsu{
	int parent[N];
	int cont;
	void make_set(int n){
		for(int i = 1; i <= n; i++)
			parent[i] = i;
		cont = n;
	}
	
	int find_set(int v){
		if(v == parent[v])
			return v;
		return find_set(parent[v]);
	}
	
	void union_sets(int a, int b){
		a = find_set(a);
		b = find_set(b);	
		if(a != b){
			parent[b] = a;
			cont--;
		}
	}	
};

struct nod{
	int l,r;
	nod(int l_,int r_){
		l = l_;
		r = r_;
	}
};

bool operator<(const nod& a, const nod& b)
{
   
	
	return a.r < b.r;
	
}

int maxEvents(vector<vector<int>>& events) {
	int ans = 0;
	vector<nod> v;
	for(int i = 0; i < (int)events.size(); i++){
		nod tmp(events[i][0], events[i][1]);
		v.push_back(tmp);
		sort(v.begin(), v.end());
	}
	cout<<endl;
	for(nod x: v){
		cout<<x.l<<" "<<x.r<<endl;
	}
	cout<<endl<<endl;
	
	int p = v[0].l;
	for(int i = 0; i < (int)v.size();i++){
		if(v[i].l <= p && p <= v[i].r){
			ans++;
			p++;
		}
		else if(p < v[i].l){
			p = v[i].l;
			ans++;
		}
	} 
	
	return ans;
}

int main(){
	int n; cin>> n;
	bool ok = true;
	for(int i = 0; i <n; i++){
		int x; cin>> x;			
		if(x % 2 == 0){
			if(x% 5 == 0|| x% 3 == 0)
				continue;
			else
				ok =false;		
		}		
	}	
	if(ok)
		cout<<"APPROVED";
	else
		cout<<"DENIED";
	return 0;
}












Measured memory_bytes: 256
local mmi, mma = math.min, math.max
local mod = 1000000007
local mfl = math.floor

local function badd(x, y)
  return (x + y) % mod
end
local function bmul(x, y)
  return (x * y) % mod
end

local invs = {1}
local fact = {1}
local invfact = {1}
for i = 2, 500000 do
  fact[i] = bmul(fact[i - 1], i)
  invs[i] = bmul(mfl(mod / i), mod - invs[mod % i])
  invfact[i] = bmul(invfact[i - 1], invs[i])
end

local function getComb(n, k)
  if k == 0 or n == k then return 1 end
  return bmul(fact[n], bmul(invfact[k], invfact[n - k]))
end

local n, k = io.read("*n", "*n")

k = mmi(n - 1, k)
local ret = 0
for i = 0, k do
  local v1 = getComb(n, i)
  local use = n - i
  local v2 = getComb(i + use - 1, use - 1)
  ret = badd(ret, bmul(v1, v2))
end
print(ret)


Measured memory_bytes: 25072
#include<bits/stdc++.h>
#define C getchar()
#define ll long long
#define Violet inline
//#pragma GCC optimize("O3")
using namespace std;
Violet int read()
{
	int x=0,l=1;char c=C;
	for (;c<'0'||c>'9';c=C) if (c=='-') l=-1;
	for (;c>='0'&&c<='9';c=C) x=x*10+c-48;
	return x*l;
}

int n,ans;
int a[205];

int main()
{
//	freopen(".in","r",stdin);freopen(".out","w",stdout);
	n=read();
	for (int i=1;i<=2*n;i++)
		a[i]=read();
	sort(a+1,a+2*n+1);
	for (int i=1;i<=2*n;i+=2)
		ans+=a[i];
	cout<<ans;
	return 0;
}

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

ll k, ans;

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

int main() {
  cin >> k;
  k++;
  ans = 0;
  rep (a, k) {
    rep (b, k) {
      rep (c, k) {
        ans += gcd(a, gcd(b, c));
      }
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3636
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace test
{
    class Program
    {
        static void Main(string[] args)
        {
            var input = Console.ReadLine().Split(' ').Select(s => int.Parse(s)).ToArray();
            var left = input[0] + input[1];
            var right = input[2] + input[3];
            if (left == right) Console.WriteLine("Balanced");
            else if (left > right) Console.WriteLine("Left");
            else Console.WriteLine("Right");
        }
    }
}

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

int main()
{
	int a, b;

	cin >> a >> b;

	int d = a / b;
	int r = a % b;
	double f = (double)a / (double)b;

	// fixed ??¨????????????????????°????????????????°???°?????\???????????°?????????
	cout << d << " " << r << " " << fixed << setprecision(5) << f << "\n";


	return 0;
}

Measured memory_bytes: 3268
n = int(input())

#a,bの最大公約数
def gcd(a, b):
    while b:
        a, b = b, a % b
    return a

#a,bの最小公倍数
def lcm(a, b):
    return a * b // gcd (a, b)

print(lcm(2, n))

Measured memory_bytes: 2940
N = int(input())
from  statistics import median


MIN = [0] * N
MAX = [0] * N

for i in range(N):
  A, B = map(int, input().split())
  
  MIN[i] = A
  MAX[i] = B
  
min_ = median(MIN)
max_ = median(MAX)
d = max_ - min_

if N % 2 == 0:
  print(int(d * 2) + 1)
else:
  print(int(d)+1)

Measured memory_bytes: 28828
#include <iostream>
using namespace std;
int main(){
  int h, n;
  cin >> h >> n;
  int sum = 0;
  for(int i = 0; i < n; ++i){
  	int x;
    cin >> x;
    sum += x;
  }
  cout << (sum >= h ? "Yes" : "No");
	
}

Measured memory_bytes: 256
import math


def main():
    # n = int(input())
    # n, k = map(int, input().split())
    # h = list(map(int, input().split()))
    s = input()
    # h = [int(input()) for _ in rane(n)]

    if s[len(s)-1] == "s":
        print(s+"es")
    else:
        print(s+"s")




if __name__ == '__main__':
    main()


Measured memory_bytes: 61864
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Numerics;
using System.Text;
using System.Threading.Tasks;
using static System.Console;
using static System.Math;
class Z { static void Main() => new K(); }
class K
{
	int F => int.Parse(Str);
	long FL => long.Parse(Str);
	int[] G => Strs.Select(int.Parse).ToArray();
	long[] GL => Strs.Select(long.Parse).ToArray();
	string Str => ReadLine();
	string[] Strs => Str.Split(new char[] { ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries);
	const int MOD = 1000000007;
	public K()
	{
		SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
		Solve();
		Out.Flush();
	}
	void Solve()
	{
		var N = F;
		var s = new string[3];
		for (var i = 0; i < 3; i++) s[i] = Str;
		var ans = 0;
		for (var i = 0; i < N; i++)
		{
			var c = new HashSet<char>();
			for (var j = 0; j < 3; j++) c.Add(s[j][i]);
			ans += c.Count == 1 ? 0 : c.Count == 2 ? 1 : 2;
		}
		WriteLine(ans);
	}
}


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

using namespace std;

const int mod = 1e9 + 7;

void solve() {
    int n;
    int mul[1001];
    int kmax = 0;
    cin >> n;
    for (int i =0; i <= n; ++i)
        mul[i] = 0;
    for (int i = 2; i <= n; ++i) {
        int j = i;
        int k = 2;
        while(j > 1) {
            if (j % k == 0) {
                j /= k;
                ++mul[k];
            }
            else
                ++k;
        }
        if (k > kmax)
            kmax =k;
    }
    long long ans = 1;
    for (int i = 2; i <=kmax; ++i)
        (ans *= mul[i]+1) %= mod;
    cout << ans;

}

int main() {

    solve();
    return 0;
}


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


signed main(){
	int n;cin>>n;
	vector<int> a(n);
	for(auto&& u:a)cin>>u;

	int ret=0;
	int pre=a.back();
	repr(i,n){
		int cur=a[i];
		if(cur<pre-1 || i<cur)cout<<-1<<endl,exit(0);
	if(cur>=pre){ret+=cur;}
	pre=cur; 	
	}
	cout<<ret<<endl;

}




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

#define REP(i,n) for(long long i = 0; i < (n); i++)
#define FOR(i, m, n) for(long long i = (m);i < (n); ++i)
#define ALL(obj) (obj).begin(),(obj).end()
#define SPEED cin.tie(0);ios::sync_with_stdio(false);

template<class T> using V = vector<T>;
template<class T, class U> using P = pair<T, U>;
template<class T> using PQ = priority_queue<T>;
template<class T> using PQR = priority_queue<T,vector<T>,greater<T>>;

constexpr long long MOD = (long long)1e9 + 7;
constexpr long long MOD2 = 998244353;
constexpr long long HIGHINF = (long long)1e18;
constexpr long long LOWINF = (long long)1e15;
constexpr long double PI = 3.1415926535897932384626433;

template <class T> vector<T> make_v(size_t N,T init){return vector<T>(N,init);}
template <class... T> auto make_v(size_t N,T... t){return vector<decltype(make_v(t...))>(N,make_v(t...));}
template <class T> void corner(bool flg, T hoge) {if (flg) {cout << hoge << endl; exit(0);}}
template <class T, class U>ostream &operator<<(ostream &o, const map<T, U>&obj) {o << "{"; for (auto &x : obj) o << " {" << x.first << " : " << x.second << "}" << ","; o << " }"; return o;}
template <class T>ostream &operator<<(ostream &o, const set<T>&obj) {o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr) o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;}
template <class T>ostream &operator<<(ostream &o, const multiset<T>&obj) {o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr) o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;}
template <class T>ostream &operator<<(ostream &o, const vector<T>&obj) {o << "{"; for (int i = 0; i < (int)obj.size(); ++i)o << (i > 0 ? ", " : "") << obj[i]; o << "}"; return o;}
template <class T, class U>ostream &operator<<(ostream &o, const pair<T, U>&obj) {o << "{" << obj.first << ", " << obj.second << "}"; return o;}
template <template <class tmp>  class T, class U> ostream &operator<<(ostream &o, const T<U> &obj) {o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr)o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;}
void print(void) {cout << endl;}
template <class Head> void print(Head&& head) {cout << head;print();}
template <class Head, class... Tail> void print(Head&& head, Tail&&... tail) {cout << head << " ";print(forward<Tail>(tail)...);}
template <class T> void chmax(T& a, const T b){a=max(a,b);}
template <class T> void chmin(T& a, const T b){a=min(a,b);}
void YN(bool flg) {cout << (flg ? "YES" : "NO") << endl;}
void Yn(bool flg) {cout << (flg ? "Yes" : "No") << endl;}
void yn(bool flg) {cout << (flg ? "yes" : "no") << endl;}

int main() {
    int N; cin >> N;
    vector<int> H(N);
    for(int i = 0; i < N; ++i) cin >> H[i];
    int a = H[0];
    for(int i = 1; i < N; ++i){
        if(a <= H[i] - 1){
            a = H[i] - 1;
        }
        else if(a == H[i]){
            a = H[i];
        }
        else{
            corner(1,"No");
        }
    }
    cout << "Yes" << endl;
    return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <vector>


class Heap {
private:
  std::vector<int> heap = {0};
  int left(int i);
  int right(int i);
public:
  void push_back(int v);
  int size();
  void maxHeapify(int i);
  void buildMaxHeap();
  std::vector<int> eval();
};

void Heap::push_back(int v) {
  heap.push_back(v);
}

int Heap::size() {
  return heap.size();
}

int Heap::left(int i) {
  return i*2;
}

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

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

  int largest = 0;
  if (l <= (int)heap.size() && heap[l] > heap[i])
    largest = l;
  else
    largest = i;
  if (r <= (int)heap.size() && heap[r] > heap[largest])
    largest = r;

  if (largest != i) {
    std::swap(heap[i], heap[largest]);
    maxHeapify(largest);
  }
}

void Heap::buildMaxHeap() {
  for (int i = (int)heap.size() / 2; i > 0; --i)
    maxHeapify(i);
}

std::vector<int> Heap::eval() {
  return std::vector<int>(heap.begin()+1, heap.end());
}


int main() {
  int h;
  std::cin >> h;
  Heap heap;
  for (int i = 0; i < h; ++i) {
    int v;
    std::cin >> v;
    heap.push_back(v);
  }
  heap.buildMaxHeap();
  for (int v: heap.eval())
    std::cout << " " << v;
  std::cout << std::endl;
}

Measured memory_bytes: 6748
import sys
S = input()
S = S[::-1]
substring_list = ['maerd', 'remaerd', 'esare', 'resare']
i = 0
while i < len(S):
    ok = False
    for substring in substring_list:
        if S[i:i+len(substring)] == substring:
            i += len(substring)
            ok = True
            break
    if not ok:
        print('NO')
        sys.exit()
print('YES')
        


Measured memory_bytes: 3316
h, w, a, b = map(int, input().split())

modulo = 10 ** 9 + 7

factorials = [1]
for i in range(1, h + w + 1):
    factorials.append((factorials[-1] * i) % modulo)


inverses = []
for f in factorials:
    inverses.append(pow(f, modulo - 2, modulo))

def cnk(n, k):
    return (factorials[n] * inverses[k] * inverses[n - k]) % modulo


line_before = [0] * w

for j in range(b, w):
    line_before[j] = cnk(h - a - 1 + j, h - a - 1)


s = 0
for j in range(b, w):
    s += cnk(a + w - j - 2, a - 1) * line_before[j]
    s %= modulo

print(s)


Measured memory_bytes: 105348
#include<stdio.h>

int main(void){
	int A;
	int B;
	scanf("%d %d",&A,&B);
	
	//printf("%d %d",A,B);
	if((A%3)==0 || (B%3)==0 || ((A+B)%3)==0){
		printf("Possible");
	}else{
		printf("Impossible");
	}
}

Measured memory_bytes: 128
#!/usr/bin/env python3
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
n = int(input())
a = [input() for _ in range(n)]
m = int(input())
b = [input() for _ in range(m)]
c = list(set(a))
ans = 0
for i in c:
    if a.count(i) > b.count(i): ans = max(ans,a.count(i) - b.count(i))
print(ans)

Measured memory_bytes: 3064
#include <iostream>
using namespace std;
bool solve(int i,int m,int n, int a[]){
    if (m==0){
        return true;
    }
    if (i>=n){
        return false;
    }
    bool res=solve(i+1,m,n,a)||solve(i+1,m-a[i],n,a);
    return res;
}
int main(){
    int n;
    cin >> n;
    int a[n];
    for (int i=0; i<n; i++){
        cin >> a[i];
    }
    int q;
    cin >> q;
    int m[q];
    for (int i=0; i<q; i++){
        cin >> m[i];
    }
    for (int i=0; i<q; i++){
        int M=m[i];
        if (solve(0,M,n,a)){
           cout << "yes" <<endl;
        }else {
            cout << "no" << endl;
        }
    }
}


Measured memory_bytes: 3136
#include<bits/stdc++.h>
#define ll long long
#define speed_up    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define pb push_back
#define mod 1000000007
using namespace std;
//const ll N=100005;
//ll fact[N];
//bool v[N];
ll power(ll x,ll n)
{
    ll res=1;
    while(n>0)
    {
        if(n%2) res=(x*res)%mod;
        x=(x*x)%mod;
        n/=2;
    }
    return res;
}
ll invmod(ll x)
{return power(x,mod-2);}
void solve()
{
    ll n,m,q,a,b,c,d,e,s,x;
    cin>>n;
    map<ll,ll> hm;
    for(int i=0;i<n;i++)
    {
        cin>>x;
        hm[x]++;
    }
    if(n%2 && hm[0]!=1) cout<<"0\n";
    else
    {   bool f=0;
        ll cnt=0;
        for(auto y:hm)
        {if(y.first==0) continue;
            if(y.second!=2) f=1;
            else cnt++;}
        if(f) cout<<"0\n";
        else cout<<power(2,cnt)<<"\n";
    }
}
int main()
{
 //speed_up;
 ll t=1;
/* fact[0]=1;
 for(ll i=1;i<N;i++) fact[i]=(fact[i-1]*i)%mod;*/
 //cin>>t;
 while(t--)
    solve();


}


Measured memory_bytes: 4224
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll MOD = (1e+9)+7;
const ll INF = (ll)1000000007 * 1000000007;
const double EPS = 1e-9;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef long double ld;
typedef complex<ld> Point;
const ld eps = 1e-11;
const ld pi = acos(-1.0);
typedef pair<ll, ll> LP;
typedef pair<ld, ld> LDP;
int main() {
    int a[200000], b[200000],c[200000];
	queue<int>q;
	int n; cin >> n;
	rep(i, n) {
		cin >> a[i];
	}
	rep(i, n) {
		cin >> b[i];
	}
	rep(j, 29) {
		int m = 1 << j; int d = m << 1;
		rep(i, n) {
			c[i] = b[i] % d;
		}
		sort(c, c + n);
		int sum = 0;
		rep(i, n) {
			int x = a[i] % d;
			x = m - x;
			if (x > 0) {
				int le = lower_bound(c, c + n, x) - c;
				int ri = lower_bound(c, c + n, x + m) - c;
				sum += ri - le;
			}
			else {
				int le = lower_bound(c, c + n, x + d) - c;
				int ri = lower_bound(c, c + n, x + m) - c;
				ri += n;
				sum += ri - le;
			}
			sum %= 2;
		}
		if (sum)q.push(j);
	}
	int out = 0;
	while (!q.empty()) {
		int x = q.front(); q.pop();
		out += (1 << x);
	}
	cout << out << endl;
	return 0;
}

Measured memory_bytes: 2560
flag=0
c11, c12, c13 = map(int, input().split())
b2b1 = c12-c11
b3b1 = c13-c11
c21, c22, c23 = map(int, input().split())
if c22-c21 != b2b1 or c23-c21 != b3b1:
    flag=1
a2a1 = c21-c11
if c22-c12!=a2a1 or c23-c13!=a2a1:
    flag=1
c31, c32, c33 = map(int, input().split())
if c32-c31 != b2b1 or c33-c31 != b3b1:
    flag = 1
a3a1 = c31-c11
if c32-c12 != a3a1 or c33-c13 != a3a1:
    flag = 1

if flag:
    print("No")
else:
    print("Yes")

#c11 = a1+b1 c12 = a1+b2 c13 = a1+b3
#c21 = a2+b1 C22 = a2+b2 c23 = a2+b3
#c31 = a3+b1 C22 = a3+b2 c23 = a3+b3


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
typedef long long ll;
#define ALL(v) v.begin(), v.end()
#define vmax(v) *max_element(ALL(v))
#define vmin(v) *min_element(ALL(v))
#define chmax(x, a) x = max(x, a)
#define chmin(x, a) x = min(x, a)

int main() {
    string s;
    cin >> s;
    ll N = s.length();
    ll cnt = 0;
    ll ans = 0;
    for (ll i = N-1; i >= 0; i--) {
        if (s[i] == 'B') {
            ans += N-i-1-cnt;
            cnt++;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 640
def main():
    # N=int(input())
    N,M = list(map(int,input().split()))
    a = list(map(int,input().split()))
    c = [2,5,5,4,5,6,3,7,6]
    dp = [int(-1e7) for _ in range(N+1)]
    dp[0] = 0
    for i in range(1,N+1):
        for j in a:
            if i-c[j-1]>=0:
                dp[i] = max(dp[i],dp[i-c[j-1]]+1)
    ans = ""
    now = N
    for _ in range(dp[N]):
        ag = -1
        ma = -1
        for j in a:
            if now - c[j-1] < 0:
                continue
            if dp[now]!=dp[now-c[j-1]]+1:
                continue
            if j > ma:
                ma = j
        now -= c[ma-1]
        ans += str(ma)
    print(ans)

if __name__=='__main__':
    main()

Measured memory_bytes: 3316
import java.util.Scanner;
import java.math.BigDecimal;
import java.math.RoundingMode;

class Main{

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

		double r = Double.parseDouble(sc.next());
		double area = r * r * Math.PI;
		double circ = 2 * r * Math.PI;
		/*
		double pi = 3.1415;
		double area = r * r * pi;
		double circ = 2 * r * pi;
		*/
		BigDecimal bdarea = new BigDecimal(String.valueOf(area));
		BigDecimal bdcirc = new BigDecimal(String.valueOf(circ));

		System.out.println(bdarea.setScale(6,RoundingMode.HALF_UP).toPlainString() + " " + bdcirc.setScale(6,RoundingMode.HALF_UP).toPlainString());
	}
}



Measured memory_bytes: 26484
#include<iostream>
#include<climits>
#include<math.h>
#include<vector>
#include<algorithm>
#include<cstdio>
#include<stdio.h>
#include <string>
#include <complex>
#include <functional>
using namespace std;
using ll = long long;
//typedef pair<string,string> P;
//double dat[100][100];
//int dp[6][1010];//動的計画法
//int prime[10000001];
//char str[1010][1010];
//vector<pair<int,int> > pc[100001];
//int ABS(int a){return max(a,-a);}
//long long num[100000];
int main(){
	int n,k,ans=1;
	cin>>n>>k;
	for(int i=0;i<n;i++){
		if(ans<k) ans*=2;
		else ans+=k;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cstring>
#include <fstream>
#include <cmath>
#include <iomanip>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <map>
#include <deque>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <list>
#include <unordered_map>
#include <bitset>
#include <sstream>

typedef  long long ll;
#define mop 1000000007
using namespace std;

int main() {
    
    string s;
    cin >> s;
    int flag = 0;
    for (ll i = 0;i<s.length()-2;i++){
        if(s[i] == s[i+2]){
            cout << i+1 << " " << i+3 << endl;
            flag = 1;
            break;
        }
        if(s[i] == s[i+1]){
            cout << i+1 << " " << i+2 << endl;
            flag = 1;
            break;
        }
        if(s[s.length()-2] == s[s.length()-1]){
            cout << s.length()-1 << " " << s.length() << endl;
            flag = 1;
            break;
        }

    }
    if(s.length() == 2){
        if(s[s.length()-2] == s[s.length()-1]){
            cout << s.length()-1 << " " << s.length() << endl;
            flag = 1;
        }
    }
    if(flag == 0) {
        cout << -1 << " " << -1 << endl;
    }

}

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

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

    int x;
    cin>>x;

    if(x==2)
    {
        cout<<2<<"\n";
        return 0;
    }

    if(x%2==0)x++;

    for(;;x+=2)
    {
        int max=sqrt(x);

        bool prime=true;
        for(int i=2;i<=max;i++)
        {
            if(x%i==0)
            {
                prime=false;
                break;
            }
        }
        if(prime)break;
    }

    cout<<x<<"\n";

    return 0;
}


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

def main():
    W, H, x, y = map(int, readline().rstrip().split())
    ans = W * H / 2
    if x == W / 2 and y == H / 2:
        mult = 1
    else:
        mult = 0
    print(ans, mult)


if __name__ == '__main__':
    main()

Measured memory_bytes: 2940
#include <cstdio>
#include <iostream>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <queue>
using namespace std;
typedef long long ll;
const int N=100010,mod=(int)1e9+7;
int ft[N],ift[N],a[N],s[N];
int C(int x,int y){
    if(x<y) return 0;
    else return (ll)ft[x]*ift[y]%mod*ift[x-y]%mod;
}
int ksm(int x,int y){
    int tmp=x,ans=1;
    while(y){
        if(y&1) ans=(ll)ans*tmp%mod;
        tmp=(ll)tmp*tmp%mod;
        y>>=1;
    }
    return ans;
}
int main(){
    int i,n,s1,s2;
    scanf("%d",&n);n++;
    ft[0]=1;
    for(i=1;i<=n;i++) ft[i]=(ll)ft[i-1]*i%mod;
    ift[n]=ksm(ft[n],mod-2);
    for(i=n;i>=1;i--) ift[i-1]=(ll)ift[i]*i%mod;
    for(i=1;i<=n;i++){
        scanf("%d",&a[i]);
        if(s[a[i]]) s1=s[a[i]],s2=i;
        s[a[i]]=i;
    }
    for(i=1;i<=n;i++) printf("%d\n",(C(n,i)-C(n-(s2-s1+1),i-1)+mod)%mod);
    return 0;
}


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

#define FOR(i, a, b) for(int i = a;i < b;i++)
#define For(i, a) FOR(i, 0, a)
#define REV(i, a, b) for(int i = b-1;i >= a;i--)
#define Rev(i, a) REV(i, 0, a)
#define REP(a) For(i, a)
#define DEBUG_PRINT(...) fprintf(stderr, __VA_ARGS__)

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int uint;
typedef pair<int, int> pi;
typedef vector<int> vi;
void print_pair(pi a){
  cerr<<"("<<a.first<<", "<<a.second<<") ";
}
template<int T1, int T2>
void print_2d(int a[T1][T2], int x, int y){
  For(i, x){
    For(j, y){
      cerr<<a[i][j]<<" ";
    }
    cerr<<endl;
  }
}
template<class T>
void print_array(T a[],size_t n){
  cerr<<"array:";
  REP(n-1)cerr<<a[i]<<",";
  cerr<<a[n-1]<<endl;
}

int N,M;
string ab;
vector<int> vec_map[200000];
unsigned int flag[2][200000];
bool ans[200000];
int ans2;

int main(){
  cin>>N>>M>>ab;
  fill(ans,ans+200000,true);
  ans2=N;
  REP(M){
    unsigned int a,b;
    cin>>a>>b;
    a--;b--;
    vec_map[a].push_back(b);
    vec_map[b].push_back(a);
    flag[ab[a]-'A'][b]++;
    flag[ab[b]-'A'][a]++;
  }
  deque<int> q;
  REP(N){
    if(!(flag[0][i]&&flag[1][i])){
      q.push_back(i);
      ans[i]=false;
      ans2--;
    }
  }
  while(!q.empty()&&ans2>0){
    auto tmp=q.front();q.pop_front();
    for(auto tmp2:vec_map[tmp]){
      if(ans[tmp2]==false)continue;
      flag[ab[tmp]-'A'][tmp2]--;
      if(!(flag[0][tmp2]>0&&flag[1][tmp2]>0)){
        q.push_back(tmp2);
        ans[tmp2]=false;
        ans2--;
      }
    }
  }
  if(ans2<=0){cout<<"No"<<endl;}
  else {cout<<"Yes"<<endl;}
  return 0;
}



Measured memory_bytes: 12548
#line 2 "../../library/template.hpp"
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pl = pair<ll, ll>;
using vl = vector<ll>;
#define rep(i, n) for(ll i = 0; i < (ll)n; i++)
#define rep3(i, l, r) for(ll i = l; i < (ll)r; i++)
#define per(i, n) for(ll i = (ll)n-1; i >= 0; i--)
#define per3(i, l, r) for(ll i = (ll)r-1; i >= (ll)l; i--)
#define all(v) begin(v), end(v)
template<class T, class U> inline void cmax(T& a, U b) { if (a < b) a = b; }
template<class T, class U> inline void cmin(T& a, U b) { if (a > b) a = b; }
constexpr char el = '\n';
template<class T, class U> ostream &operator<<(ostream &os, const pair<T, U>& p) { os << p.first << " " << p.second; return os; }
template<class T, class U> istream &operator>>(istream &is, pair<T, U> &p) { is >> p.first >> p.second; return is; }
template<class T> ostream &operator<<(ostream &os, const vector< T > &v) { rep(i, v.size()) os << v[i] << (i + 1 != v.size() ? " " : ""); return os; }
template<class T> istream &operator>>(istream &is, vector< T > &v) { for(T &in : v) is >> in; return is; }
struct IoSetup {
  IoSetup() { cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15); cerr << fixed << setprecision(15); }
} io_setup;
#line 2 "c.cpp"

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

  vector<vl> g(n);
  rep(i, m) {
    ll a, b;
    cin >> a >> b;

    g[a-1].push_back(b-1);
    g[b-1].push_back(a-1);
  }

  ll ans = 0;
  rep(i, n) {
    bool f = true;
    for (auto&& j : g[i]) {
      if (h[i] <= h[j]) {
        f = false;
      }
    }
    if (f) ans++;
  }

  cout << ans << el;
}


Measured memory_bytes: 9808
#include <iostream>

using namespace std;
typedef long long ll;

int main(){
    ll a, b;
    cin >> a >> b;
    if(a % 3 == 0 || b % 3 == 0 || (a + b) % 3 == 0){
        cout << "Possible" << endl;
    }else{
        cout << "Impossible" << endl;
    }
    return 0;
}

Measured memory_bytes: 888
#include<bits/stdc++.h>
using namespace std;
vector<vector<int>> edges;
void dfs(int src,vector<bool> &visited){
	visited[src]=1;
	for(auto x:edges[src]){
		if(!visited[x]){
			dfs(x,visited);
		}
	}
}
int connectedComponents(int n){
	vector<bool> visited(n+1,0);
	int count=0;
	for(int i=1;i<=n;i++){
		if(!visited[i]){
			count++;
			dfs(i,visited);
		}
	}
	return count;
}
void solve(){
	int n,m;
	cin>>n>>m;
	edges.resize(n+1);
	for(int i=0;i<m;i++){
		int a,b;
		cin>>a>>b;
		edges[a].push_back(b);
		edges[b].push_back(a);
	}
	cout<<connectedComponents(n)-1<<"\n";
}
int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	solve();
	return 0;
}


Measured memory_bytes: 9500
N = int(input())
lx = 0
ly = 0
lt = 0
good = True
for i in range(N):
    t,x,y = map(int,input().split())
    xd = abs(lx-x)
    yd = abs(ly-y)
    td = t-lt
    if td<(xd+yd) or td%2!=(xd+yd)%2:
        good = False
    lt,lx,ly = t,x,y
print({True:"Yes",False:"No"}[good])


Measured memory_bytes: 3064
#include <iostream>
#include <algorithm>
#include <set>
#include <cstring>
using namespace std;
typedef long long ll;
int n,s,e,w;
char o[1005];
int main(void){
    scanf(" %s",o);
    int l=strlen(o);
    for(int i=0;i<l;i++){
        if(o[i]=='N')n=1;
        else if(o[i]=='S')s=1;
        else if(o[i]=='E')e=1;
        else w=1;
    }
    if(n+s==1||e+w==1)printf("No\n");
    else printf("Yes\n");
}

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

int a, n;
int x[200005];

int main() {
	cin >> a >> n;
	for (int i = 1; i <= a; i++) cin >> x[i];
	sort(x + 1, x + a + 1);
	n = a - n;
	long long tot = 0;
	for (int i = 1; i <= n; i++) tot += x[i];
	printf("%lld\n", tot);
	return 0;
}


Measured memory_bytes: 1024
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <iostream>

using namespace std;
const double pi = acos(-1.0);

int main(){
    int R;
    cin>>R;
    printf("%.20f\n",2*pi*R);
    return 0;
}


Measured memory_bytes: 3724
from decimal import Decimal, ROUND_HALF_UP
nsum=0
nave=0
n=0
while 1:
    try:
        a,b=list(map(int,input().split(",")))
        nsum+=a*b
        nave+=b
        n+=1
    except:break
print(nsum)
print(Decimal(str(nave/n)).quantize(Decimal('0'), rounding=ROUND_HALF_UP))


Measured memory_bytes: 6392
#include <iostream>
#include <vector>
#include <queue>
#include <deque>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;

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

//INT_MAX	2,147,483,647 = 2*1.0e9

int L[110];

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

  for(int i = 0; i < N; i++){
    cin >> L[i];
  }

  int count = 1;
  int d = 0;
  for(int i = 0; i< N; i++){
    d += L[i];    
    if(d <= X) count++;
  }

  cout << count << endl;

  return 0;
}



Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int N = in.nextInt();
        int K = in.nextInt();
        int[] h = new int[N];
        for (int i = 0; i < N; i++) h[i] = in.nextInt();
        System.out.println(minCost(N, K, h));
    }

    public static int minCost(int N, int K, int[] h) {
        int[] dp = new int[N];
        for (int i = 1; i < N; i++) {
            int min = Integer.MAX_VALUE;
            for (int j = i - 1; j >= 0 && j >= i - K; j--) {
                min = Math.min(min, dp[j] + Math.abs(h[i] - h[j]));
            }
            dp[i] = min;
        }
        return dp[N - 1];
    }
}


Measured memory_bytes: 52120
//#include<bits/stdc++.h>
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<string>
#include<numeric>
#include<vector>
#include<set>
#include<map>
#include<queue>
using namespace std;

int main(){
  int n;
  cin >> n;
  long long a[n];
  for(int i=0;i<n;i++){
    cin >> a[i];
  }
  long long d[n];
  long long q = a[0];
  for(int i=1;i<n;i++){
    if(i%2 == 0) q += a[i];
    else q -= a[i];
  }
  d[0] = q/2;
  for(int i=1;i<n;i++){
    d[i] = a[i-1] - d[i-1];
  }

  for(int i=0;i<n;i++){
    cout << 2*d[i] << endl;
  }

  return 0;
}

Measured memory_bytes: 2816
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vi2 = vector<vector<int>>;
using vb = vector<bool>;
using vb2 = vector<vector<bool>>;
using vc = vector<char>;
using vc2 = vector<vector<char>>;
using vs = vector<string>;
using si = set<int>;
using vs2 = vector<vector<string>>;
using pii = pair<int, int>;
using mii = map<int, int>;
const int INF = 1e9;
const ll LINF = 1e18;
const long double PI = acos(-1.0);
#define MP(a,b) make_pair((a),(b))
#define MT(...) make_tuple(__VA_ARGS__)
#define sz(x) (int)(x).size()
 
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,x) for(int i=0;i<(int)(x);i++)
#define REPS(i,x) for(int i=1;i<=(int)(x);i++)
#define RREP(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define RREPS(i,x) for(int i=((int)(x));i>0;i--)
 
#define ALL(x) (x).begin(),(x).end()
#define SORT(v) sort(ALL(v));
#define IN(type,a) type a;cin >> a;
#define VIN(type,a,n) vector<type> a(n);cin >> a;
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl;
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl;
#define COUT(x) cout << (x) << endl;
#define DCOUT(x,n) cout << fixed << setprecision(n) << (x) << endl;
#define ENDL cout << endl;
#define DB(s,x) cout << (s) << " : " << x << endl;

#define HOGE COUT("HOGE")

template<typename T>inline istream& operator>>(istream&i,vector<T>&v)
{REP(j,sz(v))i>>v[j];return i;}

template<typename T> bool chmax(T& a, const T& b){if(a<b){a=b;return true;}return false;}
template<typename T> bool chmin(T& a, const T& b){if(a>b){a=b;return true;}return false;}
int main() {
    IN(int, n);
    IN(int, m);
    vector<bool> ch(n,false);
    vi pn(n,0);
    int ac = 0;
    int pen = 0;
    REP(i, m){
        IN(int, p);
        IN(string, s);
        if (s== "AC") {
            ch[p-1] = true;
        }else{
            if (!ch[p-1]) {
                pn[p-1]++;
            }
        }
    }
    REP(i, n){
        if (ch[i]) {
            ac++;
            pen += pn[i];
        }
    }
    cout << ac << " " << pen << endl;
}


Measured memory_bytes: 640
from typing import List, Any


def read_int() -> int:
    return int(input().strip())


def read_ints() -> List[int]:
    return list(map(int, input().strip().split(' ')))


def solve() -> Any:
    x = read_int()
    if x == 0:
        return 1
    return 0


if __name__ == '__main__':
    print(solve())


Measured memory_bytes: 75160
#include<bits/stdc++.h>
using namespace std;
#define flb(i,a,b) for(int i=a;i<b;i++)
#define ll long long int
#define mp make_pair
#define pb push_back
#define inf (long long)(1e18+1e15)
typedef pair<int,int> ii;
typedef vector <ll> vi;
typedef vector <pair<int,int> > vii;
typedef vector <vector <int> > vvi;
vector <int> v(100001);
int n;
int calculated[100001][2];
ll solve(int i,int st)
{
    if(i==n-1)
        return 0;
    if(i==n-2&&st==1)
        {
            st=0;
        }
    if(calculated[i][st]!=-1)
        return calculated[i][st];
    ll temp;
    if(st==0)
        temp=abs(v[i+1]-v[i]);
    else if(st==1)
        temp=abs(v[i+2]-v[i]);
    calculated[i][st]=min(temp+solve(i+1+st,0),temp+solve(i+1+st,1));

    return calculated[i][st];
}
int main()
{
    cin>>n;
    memset(calculated,-1,sizeof(calculated));
    for(int i=0;i<n;i++)
        cin>>v[i];
    ll ans=min(solve(0,0),solve(0,1));
    cout<<ans;
}


Measured memory_bytes: 3712
#include<bits/stdc++.h>
using namespace std;
int main(){
int dp[222222] = {},p,n;
int mx = 0;
cin>>n;
for (int i=0;i<n;i++) {
cin>>p;
  dp[p]=dp[p-1]+1;
mx=max(mx,dp[p]);
}
cout<<n-mx<<endl;
}

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

typedef long long Int;
int asc(const void *a, const void *b) {
    return (int)(*((Int *)a) - *((Int *)b));
}

int main() {
    int a,b;
    scanf("%d %d", &a, &b);
    printf("%d\n", a <= 9 && b <= 9 ? a * b : -1);
}


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

int main()
{
  int N, count=0;
  vector<int> search(81);
  cin >> N;
  for(int i=0;i<9;i++)
  {
    for(int j=0;j<9;j++)
    {
      search.at(i*9+j)=(i+1)*(j+1);
      if(N==search.at(i*9+j))
        count++;
    }
  }
  if(count>0)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}

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

int main(void)
{
	int n, an[100], cnt = 0;

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

	for(int i = 0; i < n; i++) {
		int mini = i;
		int tmp = an[i];

		for(int j = i; j < n; j++) {
			if(an[j] < an[mini]) {
				mini = j;
			}
		}

		if(i != mini) {
			an[i] = an[mini];
			an[mini] = tmp;
			cnt++;
		}
	}

	for(int i = 0; i < n; i++)
		cout << an[i] << (i == n - 1 ? "\n" : " ");
	cout << cnt << endl;

	return 0;
}

Measured memory_bytes: 1164
a = "zabcdefghijklmnopqrstuvwxy"
number = int(input())
result = ""
for i in range(13):
    result += a[int(number % 26)]
    if number % 26 == 0:
        number -= 26
    if number // 26  == 0:
        break
    number = number // 26
result = result[::-1]
print(result)

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

int main(){
  string S,T;
  cin>>S>>T;
  T.pop_back();
  if(S==T){
    cout<<"Yes"<<endl;
  }else{
    cout<<"No"<<endl;
  }
}


Measured memory_bytes: 3600
inf = 9999999999
N, Ma, Mb = map(int, input().split())
d = [{} for i in range(N + 1)]
for i in range(N):
    a, b, c = map(int, input().split())
    for (j, k) in d[i]:
        d[i + 1][j, k] = d[i][j, k]
    d[i + 1][a, b] = min(c, d[i].get((a, b), inf))
    for (j, k) in d[i]:
        d[i + 1][j + a, k + b] = min(d[i][j, k] + c, d[i].get((j + a, k + b), inf))
ans = inf
for (j, k) in d[N]:
    if j * Mb == k * Ma:
        ans = min(ans, d[N][j, k])
if ans == inf:
    ans = -1
print(ans)

Measured memory_bytes: 71388
use std::io::prelude::*;

fn input<T>() -> T
where
    T: std::str::FromStr,
{
    let stdin = std::io::stdin();
    let token = stdin
        .lock()
        .bytes()
        .map(|c| c.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect::<String>();
    token.parse().ok().unwrap()
}

fn main() {
    let d = input::<i64>();

    let mut ans = "Christmas".to_string();
    for _ in 0..25 - d {
        ans.push_str(" Eve");
    }
    println!("{}", ans);
}


Measured memory_bytes: 4352
#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <algorithm>
typedef long long ll;
using namespace std;

int main()
{
	int A, B;
	cin >> A;
	cin >> B;
	if (B%A==0)
	{
		cout << A + B << endl;
		return 0;
	}
	else
	{
		cout << B - A << endl;
		return 0;
	}
}

Measured memory_bytes: 256
def find_all(start_node)
  # Node => min dist
  node_to_min_dist_hash = Hash.new(-1)

  open_list   = [[start_node, 0]]
  closed_list = []

  while open_list.size != 0
    node, dist = open_list.shift

    if closed_list.include?(node)
      next
    end

    if !node_to_min_dist_hash.has_key?(node)
      node_to_min_dist_hash[node] = dist
    end

    nodes = $adj_lists[node]
    nodes.each{|n|
      open_list.push([n, dist+1])
    }
    closed_list.push(node)
  end

  return node_to_min_dist_hash
end


# NOTE: 1-origin (not 0-origin)
$adj_lists = []

$cache= {}

_ = gets


while (line = gets)
  i, _, *nodes= line.split(' ').map(&:to_i)
  $adj_lists[i] = nodes
end

node_to_min_dist_hash = find_all(1)

# Print
(1...$adj_lists.size).each{|target_node|
  min_dist = node_to_min_dist_hash[target_node]
  puts("#{target_node} #{min_dist}")
}




Measured memory_bytes: 8912
open Scanf
open Printf
 
let input_array n = Array.init n (fun _ -> scanf "%d " (fun x -> x))

let n = scanf "%d\n" (fun x -> x)
let a_ = input_array n
let b_ = input_array n
let c_ = input_array n

let rec lower_bound' arr (first, last) n =
    let mid = (first+last)/2
    in if last - first <= 1
        then if (arr.(first) < n) then last else first
        else if (arr.(mid) < n) 
            then lower_bound' arr (mid, last)  n
            else lower_bound' arr (first, mid) n

let lower_bound arr n = if arr.(Array.length arr - 1) < n
    then Array.length arr
    else lower_bound' arr (0, Array.length arr - 1) n

let upper_bound arr n = lower_bound arr (n+1)

let _ = Array.sort Pervasives.compare a_; Array.sort Pervasives.compare c_;
    Array.fold_left (fun s x -> s + lower_bound a_ x * (n - upper_bound c_ x)) 0 b_
    |> print_int
    |> print_newline


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

int main(){
  int a,b,c,d,e,k;
  cin >> a >> b >> c >> d >> e >> k;
  int flag = 0;
  
  if(b-a > k){
    flag=1;
  }
  if(c-a > k){
    flag=1;
  }
  if(d-a > k){
    flag=1;
  }
  if(e-a > k){
    flag=1;
  }
  if(c-b > k){
    flag=1;
  }
  if(d-b > k){
    flag=1;
  }
  if(e-b > k){
    flag=1;
  }
  if(d-c > k){
    flag=1;
  }
  if(e-c > k){
    flag=1;
  }
  if(e-d > k){
    flag=1;
  }
  
  if(flag==1){
    cout << ":(" << endl;
  }else{
	cout << "Yay!" << endl;
  }
    
}

Measured memory_bytes: 256