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

#define rep2(x,fr,to) for(int (x)=(fr);(x)<(to);(x)++)
#define rep(x,to) for(int (x)=0;(x)<(to);(x)++)
#define repr(x,fr,to) for(int (x)=(fr);(x)>=(to);(x)--)
#define all(c) (c).begin(),(c).end()
#define sz(v) (int)(v).size()

using namespace std;
typedef long long ll; typedef vector<ll> VI; typedef pair<ll,ll> pii;
const int mod = (int)1e9+7;
void dbg(){ cerr << "\n"; }  template <typename T,typename ...T2> void dbg(const T& fst, const T2&...rst){ cerr << fst << ": "; dbg(rst...); }
template <class T> void amin(T& a,T b){ a=min(a,b);}
template <class T> void amax(T& a,T b){ a=max(a,b);}


const ll INF = 1LL<<60;
VI cal(ll p, const VI& v){
	
	VI ans = {INF, INF};
	int ps = lower_bound(all(v), p) - v.begin();
	if(ps < sz(v)) ans[1] = v[ps];
	if(ps >0)   ans[0] = v[ps-1];
	return ans;
}

ll fnc(ll x ,const VI& v1, const VI& v2){
	ll ans = INF;
	auto r= cal(x, v1);
	rep(i,2){
		if(r[i] !=INF){
			ll sm = abs(r[i] - x);
			auto r2=cal(r[i], v2);
			if(r2[1] !=INF) ans = min(ans, sm + abs(r[i] - r2[1]));
			if(r2[0] !=INF) ans = min(ans, sm + abs(r[i] - r2[0]));
		}
	}
	return ans;
}



int main()
{
	//cin.tie(0); ios_base::sync_with_stdio(false);
	int a,b,q;
	cin >>a >>b >>q;
	vector<ll> s(a+2), t(b+2);
	rep(i, a) cin >>s[i+1];
	rep(i,b)  cin >>t[i+1];
	s.front() = t.front() = -INF;
	s.back() = t.back() = INF;

	
	vector<ll> x(q);
	rep(i, q) cin >> x[i];
	

	rep(i, q){
		ll  ans = INF;
		ans = min(ans, fnc( x[i], s, t));
		ans = min(ans, fnc( x[i], t, s));
		cout << ans <<"\n";
	}
	
	
	return 0;
}



Measured memory_bytes: 3712
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
 
struct Node{
  int key;
 struct Node *right,*left,*parent;
};//構造体に入れる
 
struct Node *root,*NIL;
 
void insert(int);
void inorder(struct Node *);
void preorder(struct Node *);
struct Node* find(struct Node *,int);
 
int main(){
  int n,i,x;
  char s[20];
 
  scanf("%d",&n);
 
  for(i=0;i<n;i++){
    scanf("%s",s);
    if(strcmp(s,"find")==0){
      scanf("%d",&x);
      struct Node *t = find(root,x);
      if(t != NIL)printf("yes\n");
      else printf("no\n");
    }
    else if(strcmp(s,"insert")==0){
      scanf("%d",&x);
      insert(x);
    }
    else if(strcmp(s,"print")==0){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    }
  }
 
  return 0;
}
 
void insert(int k){
  struct Node *y = NIL,*x = root,*z;
 
  z = malloc(sizeof(struct Node));
  z->key = k;
  z->left = NIL;
  z->right = NIL;
 
  while(x != NIL){
    y = x;
    if(z->key < x->key)x = x->left;
    else x = x->right;
  }
 
  z->parent = y;
  if(y == NIL)root = z;
  else {
    if(z->key < y->key)y->left = z;
    else y->right = z;
  }
}
 
void inorder(struct Node *u){
 
  if(u == NIL)return;
  inorder(u->left);
  printf(" %d",u->key);
  inorder(u->right);
}
 
void preorder(struct Node *u){
 
  if(u == NIL)return;
  printf(" %d",u->key);
  preorder(u->left);
  preorder(u->right);
}
 
struct Node* find(struct Node *u,int k){
 
  while(u != NIL && k != u->key){
    if(k < u->key)u = u->left;
    else u = u->right;
  }
  return u;
}


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

using namespace std;

#define FOR(i, a, b) for(ll i = (a); i < (b); ++i)
#define FORR(i, a, b) for(ll i = (a); i > (b); --i)
#define REP(i, n) for(ll i = 0; i < (n); ++i)
#define REPR(i, n) for(ll i = n; i >= 0; i--)
#define FOREACH(x, a) for(auto &(x) : (a))
#define VECCIN(x)                                                              \
    for(auto &youso_ : (x)) cin >> youso_
#define mp make_pair
#define bitcnt __builtin_popcount
#define SZ(x) ((ll)(x).size())
#define All(a) (a).begin(), (a).end()
template <typename T = long long> inline T IN() {
    T x;
    cin >> x;
    return (x);
}
inline void CIN() {}
template <class Head, class... Tail>
inline void CIN(Head &&head, Tail &&... tail) {
    cin >> head;
    CIN(move(tail)...);
}
#define CINT(...)                                                              \
    int __VA_ARGS__;                                                           \
    CIN(__VA_ARGS__)
#define LCIN(...)                                                              \
    ll __VA_ARGS__;                                                            \
    CIN(__VA_ARGS__)
#define SCIN(...)                                                              \
    string __VA_ARGS__;                                                        \
    CIN(__VA_ARGS__)
#define Yes(a) cout << (a ? "Yes" : "No") << "\n"
#define YES(a) cout << (a ? "YES" : "NO") << "\n"

typedef long long ll;
typedef unsigned long long ul;
typedef vector<int> V;
typedef vector<ll> VL;
typedef pair<ll, ll> PL;
typedef priority_queue<ll> PQ;
typedef priority_queue<ll, V, greater<ll>> PQG;

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

ll M, K;

int main() {
    cin >> M >> K;
    if(K >= 1LL << M) {
        cout << -1 << "\n";
        return 0;
    }
    else if(M==0){
        cout << "0 0" << "\n";
        return 0;
    }
    else if(M==1 && K==1){
        cout << -1 << "\n";
        return 0;
    }
    else if(M==1 && K==0)
    {
        cout << "0 1 1 0" << "\n";
        return 0;
    }
    else{
        REP(i, 1LL << M) {
            if(i != K) cout << i << " ";
        }
        cout << K << " ";
        REPR(i, (1LL << M) - 1) {
            if(i != K) cout << i << " ";
        }
        cout << K << "\n";
    }
    return 0;
}


Measured memory_bytes: 1920
#include <iostream>
#include <vector>
using namespace std;
int main()
{
    vector<int> vec;
    int q, p,x,quer;
    cin >> q;
    while (q--) {
        cin >> quer;
        if (quer == 0) {
            cin >> x;
            vec.push_back(x);
        }
        if (quer == 1) {
            cin >> p;
            cout << vec[p] << endl;
        }
        if (quer == 2) {
            vec.pop_back();
        }
    }
}


Measured memory_bytes: 3884
#include<bits/stdc++.h>
using namespace std;
 int main()
 {
     string s;
     getline(cin,s);
     if(s[0]=='S')cout<<"Cloudy"<<endl;
       if(s[0]=='C')cout<<"Rainy"<<endl;
        if(s[0]=='R')cout<<"Sunny"<<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();
        int x = sc.nextInt();
        int[] m = new int[n];
        int cnt = n;

        for(int i = 0;i<n;i++){
            m[i] = sc.nextInt();
            x-=m[i];
        }

        Arrays.sort(m);

        cnt = cnt+ (x/m[0]);

        //System.out.println(x);
        System.out.println(cnt);



      
    }
}


Measured memory_bytes: 23892
#include<iostream>
#include<string>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<algorithm>
#include<vector>
#include<functional>
#include<iomanip>
#include<queue>
#include<cassert>
#include<tuple>
#include<set>
#include<map>
#include<list>
#include<bitset>
#include<utility>

#define PB push_back
#define ALL(a)  (a).begin(),(a).end()
#define all(v) begin(v), end(v)
#define DWN(a)  (a).begin(),(a).end(), greater<int>()
#define rep(i, m) for (int i = 0; i < m; i++)
#define REP(i, n, m) for (int i = n; i < m; i++)

using namespace std;

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

const int dx[4] = { 1, 0, -1, 0 };
const int dy[4] = { 0, 1, 0, -1 };
const int inf = (int)1e9;
const ll INF = (ll)1e18;
const ll MOD{ (ll)1e9 + 7 };
const long double EPS = 1e-10;

int main() {
	int n, k;
	cin >> n >> k;
	if (n % k == 0) {
		cout << 0 << endl;
	}
	else {
		cout << 1 << endl;
	}
	return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <ctime>
#include <cstring>
#include <functional>
#include <iostream>
#include <iomanip>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <regex>
#include <vector>

#define fix(n)          cout<<fixed<<setprecision(n)
#define rep(i,n)        for (int i = 0; i < (n); ++i)
#define all(a)          (a).begin(), (a).end()
#define sort(a)         sort(all(a))
#define uniq(a)         sort(a);(a).erase(unique(all(a)), (a).end())
#define reverse(a)      reverse(all(a))
#define ctos(c)         string(1, (c))
#define out(d)          cout << (d)
#define outl(d)         std::cout<<(d)<<"\n"
#define YES()           cout << "YES" << endl
#define NO()            cout << "NO" << endl
#define Yes()           cout << "Yes" << endl
#define No()            cout << "No" << endl
#define ceil(x, y)      ((x + y - 1) / (y))
#define debug(x)        cerr << #x << ": " << (x) << '\n'
#define debug2(x, y)    cerr << #x << ": " << (x) << ", " << #y << ": " << (y) << '\n'
#define debug3(x, y, z) cerr << #x << ": " << (x) << ", " << #y << ": " << (y) << ", " << #z << ": " << (z) << '\n'
#define dbg(v)          for (size_t _ = 0; _ < v.size(); ++_){ cerr << #v << "[" << _ << "] : " << v[_] << '\n'; }
#define pb              push_back
#define fst             first
#define int             long long
#define INF             __LONG_LONG_MAX__

using namespace std;
using ll = long long;
using ld = long double;
using P = pair<ll,ll>;

const ll MOD = 1000000007; // 10^9 + 7
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};

vector<P> factor(ll n) {
  vector<P> ret;
  ll q = n;
  for (ll d = 2; d * d <= n; d++) {
    if (q % d > 0) continue;
    ll cnt = 0;
    while (q % d == 0) {
      cnt++;
      q /= d;
    }
    ret.push_back(make_pair(d, cnt));
  }
  if (q > 1) ret.push_back(make_pair(q, 1));
  return ret;
}

ll mypow(ll x, ll n) {
  ll res = 1;
  while (n > 0) {
    if (n & 1) res = res * x;
    x = x * x;
    n >>= 1;
  }
  return res;
}

ll phi(ll n) {
  vector<P> v = factor(n);
  ll ret = 1;

  for (P vi : v) {
    ll p = vi.first;
    ll k = vi.second;
    ret *= mypow(p, k-1) * (p-1);
  }

  return ret;
}

void solve() {
  ll n; cin >> n;
  outl(phi(n));
}

signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  srand((unsigned)time(NULL));
  fix(12);

  solve();
}



Measured memory_bytes: 3236
#include<iostream>

using namespace std;

#define REP(i, n) for(int i=0; i<n; i++)

int n, d, x;
int p[10][10];
int dp[10][100001];

int main(){
    cin >> n >> d >> x;
    REP(i, d){
        REP(j, n){
            cin >> p[i][j];
        }
    }

    int tmp_max = x;

    REP(i, d-1){
        REP(k, tmp_max + 1) dp[i+1][k] = k;
        REP(j, n){
            REP(k, tmp_max + 1){
                if(k-p[i][j]>=0){
                    dp[i+1][k] = max(dp[i+1][k], dp[i+1][k-p[i][j]] + p[i+1][j]);
                }
            }
        }
        int c = tmp_max;
        REP(k, c+1){
            tmp_max = max(tmp_max, dp[i+1][k]);
        }
    }
    cout << tmp_max << endl;
}

Measured memory_bytes: 3164
use std::io;
use std::str::FromStr;
use std::cmp::min;

fn input_char_vec() -> Vec<char> {
    let mut line: String = String::new();
    io::stdin().read_line(&mut line);
    line.trim().chars().collect()
}

fn main() {
    let s = input_char_vec();
    let mut s1 = vec!['0'; s.len()];
    let mut s2 = vec!['0'; s.len()];
    for i in 0..s.len() {
        if i % 2 == 0 {
            s1[i] = '1';
        } else {
            s2[i] = '1';
        }
    }
    let mut c1 = 0;
    let mut c2 = 0;
    for i in 0..s.len() {
        if s[i] != s1[i] {
            c1 += 1;
        }
        if s[i] != s2[i] {
            c2 += 1;
        }
    }
    // println!("{}, {}", c1, c2);
    println!("{}", min(c1, c2));
}


Measured memory_bytes: 4352
s = list(input())
ans = 'Yes'
for i in range(len(s)):
    if i%2!=0 and not(s[i]=='L' or s[i]=='U'or s[i]=='D'):
        ans = 'No'
    elif i%2==0 and not(s[i]=='R' or s[i]=='U'or s[i]=='D'):
        ans = 'No'

print(ans)

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

using namespace std;

#define lli long long
#define ld long double
#define mod 1000000007 
#define set(n) cout << fixed << setprecision(n)    
#define fi first
#define se second
#define mp make_pair
#define pll pair<lli, lli>
#define endl '\n'

const double PI = acos(-1);
const double epsilon = 1e-7;  // floating point precision

signed main(void) {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int x;
    cin >> x;
    if(x >= 30) {
        cout << "Yes" << endl;
    }
    else {
        cout << "No" << endl;
    }
    return 0;
}


Measured memory_bytes: 3644
n = input()
l = []
for i in range(n):
	a, b = map(int, raw_input().split())
	l.append((b, -a))
curtime = 0
l.sort()
for i in l:
	if curtime - i[1] > i[0]:
		print "No"
		exit(0)
	else:
		curtime -= i[1]
print "Yes"

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

using ll = long long;
#define countof(a) (sizeof(a)/sizeof((a)[0]))
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i < (n); i++)
#define all(a) begin(a),end(a)
template<class T> istream& operator >> (istream& s, vector<T>& v)
{ for (T& x: v) { s >> x; } return s;}
template<class T> void cout_v(const vector<T>& c)
{ for (int i = 0; i < c.size(); i++) cout << c[i] << endl; }
template<class T> void cout_h(const vector<T>& c)
{ for (int i = 0; i < c.size(); i++) cout << c[i] << (i==c.size()-1?"\n":" "); }
template<class T> inline bool chmin(T& a, T b) {return a>b?a=b,true:false;}
template<class T> inline bool chmax(T& a, T b) {return a<b?a=b,true:false;}
template<class T> void sort3a(T& a,T& b,T& c) {if (a>b) swap(a,b); if (b>c) swap(b,c); if (a>b) swap(a,b);}
#define SP << " " <<
#define FMT(a) #a<<":"<<a 
#define FMT2(a,b) #a<<":"<<a<<", "<<#b<<":"<<b 
#define FMT3(a,b,c) #a<<":"<<a<<", "<<#b<<":"<<b<<", "<<#c<<":"<<c 
#define FMT4(a,b,c,d) #a<<":"<<a<<", "<<#b<<":"<<b<<", "<<#c<<":"<<c<<", "<<#d<<":"<<d 

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

    ll A, B, C; cin >> A>>B>>C;

    ll ans = 0;
    if (A%2 && B%2 && C%2) {
        sort3a(A,B,C);
        ans = A*B;
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#line 2 "/Users/kaage/Desktop/ProgrammingWorkspace/library/other/template.hpp"
#define _CRT_SECURE_NO_WARNINGS
#pragma target("avx")
#pragma optimize("O3")
#pragma optimize("unroll-loops")
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#define rep(i,n) for(int i=0;i<(lint)(n);i++)
#define REP(i,n) for(int i=1;i<=(lint)(n);i++)
#define all(V) V.begin(),V.end()
typedef long long lint;
typedef unsigned long long ulint;
typedef std::pair<int, int> P;
typedef std::pair<lint, lint> LP;
constexpr int INF = INT_MAX/2;
constexpr lint LINF = LLONG_MAX/2;
constexpr double eps = DBL_EPSILON;
constexpr double PI=3.141592653589793238462643383279;
template<class T>
class prique :public std::priority_queue<T, std::vector<T>, std::greater<T>> {};
template <class T, class U>
inline bool chmax(T& lhs, const U& rhs) {
	if (lhs < rhs) {
		lhs = rhs;
		return 1;
	}
	return 0;
}
template <class T, class U>
inline bool chmin(T& lhs, const U& rhs) {
	if (lhs > rhs) {
		lhs = rhs;
		return 1;
	}
	return 0;
}
inline lint gcd(lint a, lint b) {
	while (b) {
		lint c = a;
		a = b; b = c % b;
	}
	return a;
}
inline lint lcm(lint a, lint b) {
	return a / gcd(a, b) * b;
}
bool isprime(lint n) {
	if (n == 1)return false;
	for (int i = 2; i * i <= n; i++) {
		if (n % i == 0)return false;
	}
	return true;
}
template<typename T>
T mypow(T a, unsigned int b) {
	if (!b)return T(1);
	if (b & 1)return mypow(a, b - 1) * a;
	T memo = mypow(a, b >> 1);
	return memo * memo;
}
lint modpow(lint a, lint b, lint m) {
	if (!b)return 1;
	if (b & 1)return modpow(a, b - 1, m) * a % m;
	lint memo = modpow(a, b >> 1, m);
	return memo * memo % m;
}
template<typename T>
void printArray(std::vector<T>& vec) {
	rep(i, vec.size() - 1)std::cout << vec[i] << " ";
	std::cout << vec.back() << std::endl;
}
template<typename T>
void printArray(T l, T r) {
	T rprev = r;
	rprev--;
	for (T i = l; i != rprev; i++) {
		std::cout << *i << " ";
	}
	std::cout << *rprev << std::endl;
}
#line 2 "main.cpp"
int n,k,a[200010];
int main(){
	std::cin>>n>>k;
	rep(i,n)std::cin>>a[i];
	for(int i=k;i<n;i++){
		if(a[i-k]<a[i])puts("Yes");
		else puts("No");
	}
	return 0;
}


Measured memory_bytes: 4400
#include <cmath>
#include <string>
#include <vector>
#include <cassert>
#include <iomanip>
#include <iostream>
#include <algorithm>
#include <functional>
#pragma warning(disable : 4996)
using namespace std;
int N, K, a[5009]; bool dp[5009];
bool solve(int x) {
	if (x < 0) return false;
	if (x >= N) return true;
	fill(dp, dp + K, false); dp[0] = true;
	for (int i = 0; i < N; i++) {
		if (i == x) continue;
		for (int j = K - 1; j >= a[i]; j--) {
			if (dp[j - a[i]]) dp[j] = true;
		}
	}
	for (int i = max(K - a[x], 0); i < K; i++) {
		if (dp[i]) return true;
	}
	return false;
}
int main() {
	scanf("%d %d", &N, &K);
	for (int i = 0; i < N; i++) scanf("%d", &a[i]);
	sort(a, a + N);
	int l = 0, r = N;
	while (r - l > 1) {
		int m = (l + r) >> 1;
		if (solve(m)) r = m;
		else l = m;
	}
	for (int i = l - 3; i <= l + 3; i++) {
		if (solve(i)) {
			cout << i << endl;
			break;
		}
	}
	return 0;
}

Measured memory_bytes: 384
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <array>
#include <algorithm>
#include <utility>
#include <numeric>
#include <deque>
#include <stack>
#include <queue>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <cmath>
#include <limits>
#include <cassert>
#include <bitset>
#include <list>
#include <iomanip>
#include <cctype>

#define for0(i, N)    for (long long i = 0  ; i <  (N); ++i)
#define for1n(i, N)   for (long long i = 1  ; i <= (N); ++i)
#define for1(i, N)    for (long long i = 1  ; i <  (N); ++i)
#define forn(i, N)    for (long long i = 0  ; i <= (N); ++i)
#define forx(i, N, x) for (long long i = (x); i <  (N); ++i)
#define forl(i, N, x, a) for (long long i = (x), a = 0; a < (N);    \
                              i = (i + 1) % (N), ++a)
#define int long long

template<size_t i>
std::bitset<i> operator++(std::bitset<i> b, signed){
    static_assert(i <= 64, "Cannot cast 64bit int.");
    return b = (unsigned long long)b + 1;
}

template<size_t i>
std::bitset<i> operator++(std::bitset<i> b){
    static_assert(i <= 64, "Cannot cast 64bit int.");
    auto temp = b;
    b++;
    return temp;
}

template<size_t i>
std::bitset<i> operator--(std::bitset<i> b, signed){
    static_assert(i <= 64, "Cannot cast 64bit int.");
    return b = (unsigned long long)b - 1;
}

template<size_t i>
std::bitset<i> operator--(std::bitset<i> b){
    static_assert(i <= 64, "Cannot cast 64bit int.");
    auto temp = b;
    b--;
    return temp;
}

long long constexpr inf = std::numeric_limits<long long>::max();

using namespace std;

typedef long long ll;
typedef long double ld;
typedef priority_queue<ll> pq;
typedef priority_queue<ll,vector<ll>, greater<ll>> pql;
typedef stack<ll> stk;
typedef queue<ll> qu;
typedef pair<ll, ll> pll;
typedef map<ll, ll> mll;
typedef unordered_map<ll, ll> umll;
typedef set<ll> sll;
typedef unordered_set<ll> usll;
typedef vector<ll> vll;
typedef vector<ld> vld;
typedef vector<vector<ll>> vvll;


signed main(void){
    cin.tie(0); ios::sync_with_stdio(false);cout<<fixed<<setprecision(10);

    int n;
    string s;

    cin >> n >> s;

    // ll result = n;
    // ll rev = 0;

    vll r, g, b;
    for0(i, n){
        switch (s[i]) {
        case 'R': {
            r.emplace_back(i);
            break;
        }
        case 'G': {
            g.emplace_back(i);
            break;
        }
        case 'B': {
            b.emplace_back(i);
            break;
        }
        }
    }

    ll result = r.size() * b.size() * g.size();

    for1(j, n - 1){
        for1n(t, min(j, n - j - 1)){
            if (s[j - t] != s[j] && s[j + t] != s[j] && s[j - t] != s[j + t]) {
                --result;
            }
        }
    }

    cout << result;

    return 0;
}


Measured memory_bytes: 3736
A = [[0 for _ in range(3)] for _ in range(3)]

for i in range(3):
    Arow = list(map(int, input().split()))
    A[i] = Arow

N = int(input())
B = []
for _ in range(N):
    B.append(int(input()))


flag = [[False for _ in range(3)] for _ in range(3)]

f = False
for b in B:
    for row in range(3):
        for col in range(3):
            if A[row][col] == b:
                flag[row][col] = True
                f = True
if not f:
    print("No")
    exit(0)
    
# check (--)
for row in range(3):
    f = True
    for col in range(3):
        if not flag[row][col]:
            f = False
            break
    if f:
        print("Yes")
        exit(0)

# check (|)
for row in range(3):
    f = True
    for col in range(3):
        if not flag[col][row]:
            f = False
            break
    if f:
        print("Yes")
        exit(0)

# check (diag)
if flag[0][0] and flag[1][1] and flag[2][2]:
    print("Yes")
elif flag[0][2] and flag[1][1] and flag[2][0]:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 38256
import qualified Data.ByteString.Char8 as BS
import Control.Monad
import Data.Char
import Data.List

getVals::IO [Int]
getVals = unfoldr (BS.readInt . BS.dropWhile isSpace) <$> BS.getLine

main::IO()
main = do
    n:_ <- getVals
    let (a,_,_,_) = genList !! (n-1)
    print a

modnum::Int
modnum = 10^9 + 7

mSum::Int->Int->Int
mSum a b = mod (a+b) modnum

mpro::Int->Int->Int
mpro a b = mod (a*b) modnum

genList::[(Int,Int,Int,Int)]
genList = (0,1,1,8):[
    (foldl mSum 0 [(mpro have09 10),only0,only9],
    mSum (mpro only0 9) no09,
    mSum (mpro only9 9) no09,
    mpro no09 8
    )
    |(have09,only0,only9,no09)<-genList]

Measured memory_bytes: 282076
#include <iostream>
#define INF 1e9
using namespace std;


int n, m;

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

    int l_max = -INF;
    int r_min = INF;

    for(int i = 0; i < m; i++) {
        int l, r;
        cin >> l >> r;
        l_max = max(l, l_max);
        r_min = min(r, r_min);
    }

    if(r_min >= l_max)
        cout << (r_min - l_max + 1) << endl;
    else
        cout << 0 << endl;
}

Measured memory_bytes: 256
#include<stdio.h>

int main()
{
	int a, b, ans;
	char c;
	while (1)
	{
		scanf("%d %c %d", &a, &c, &b);
		if (c == '+')
		{
			ans = a + b;
		}
		else if (c == '-')
		{
			ans = a - b;
		}
		else if (c == '*')
		{
			ans = a * b;
		}
		else if (c == '/')
		{
			ans = a / b;
		}
		else if (c == '?')
			break;
		printf("%d\n", ans);
	}
	return 0;
}

Measured memory_bytes: 600
from collections import deque

H, W = map(int, input().split())
Map = [list(-1 if s=='.' else -2 for s in input()) for _ in range(H)]
ttl=H*W*2
for i in range(H):
  ttl += sum(Map[i])

Map[0][0]=0
sy, sx = 0, 0
  
dq = deque()
dq.append([sy, sx])
d = [[1,0],[0,1],[-1,0],[0,-1]]

ans=-1
while(len(dq)>0):
  y, x = dq.popleft()
  cnt = Map[y][x]+1
  for i in range(4):
    ytmp, xtmp = y+d[i][0], x+d[i][1]
    if ytmp<0 or ytmp>=H or xtmp<0 or xtmp>=W:
      continue
    elif Map[ytmp][xtmp]==-1:
      Map[ytmp][xtmp]=cnt
      dq.append([ytmp, xtmp])
      if ytmp==H-1 and xtmp==W-1:
        ans=cnt
        dq.clear()
        break
if ans==-1:
  print(ans)
else:
  print(ttl-ans-1)

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

int main(){

int n,m,l;
cin >> n >> m >> l;

vector<vector<long long>> A(n,vector<long long>(m));
vector<vector<long long>> B(m,vector<long long>(l));
vector<vector<long long>> C(n,vector<long long>(l,0));

rep(i, n){
    rep(j, m){
        cin >> A.at(i).at(j);
    }
}

rep(i, m){
    rep(j, l){
        cin >> B.at(i).at(j);
    }
}

rep(i, n){
    rep(j, l){
        rep(k, m){
            C.at(i).at(j) += A.at(i).at(k) * B.at(k).at(j);
        }
    }
}

rep(i, n){
    rep(j, l){
        cout << C.at(i).at(j);
        if (j != l-1) cout << ' ';
    }
    cout << endl;
}
}


Measured memory_bytes: 3260
import sys
## io ##
def IS(): return sys.stdin.readline().rstrip()
def II(): return int(IS())
def MII(): return list(map(int, IS().split()))
def MIIZ(): return list(map(lambda x: x-1, MII()))
## dp ##
INIT_VAL = 0
def DD2(d1,d2): return [[INIT_VAL]*d2 for _ in range(d1)]
def DD3(d1,d2,d3): return [DD2(d2,d3) for _ in range(d1)]
## math ##
MOD=10**9+7
def divc(x,y): return -(-x//y)
def divf(x,y): return x//y
def gcd(x,y):
    while y: x,y = y,x%y
    return x
def lcm(x,y): return x*y//gcd(x,y)
def get_primes(MAX_NUM=10**3):
    """Return a list of prime numbers"""
    is_prime = [True] * MAX_NUM
    is_prime[0] = False
    is_prime[1] = False
    primes = []
    for i in range(MAX_NUM):
        if is_prime[i]:
            primes.append(i)
            for j in range(2*i, MAX_NUM, i):
                is_prime[j] = False
    return primes
## libs ##
from itertools import accumulate as acc
from collections import deque, Counter
from heapq import heapify, heappop, heappush
from bisect import bisect_left

#======================================================#

def main():
    n = II()
    aa = MII()
    c = Counter(aa)
    keys = sorted(c.keys())
    cnt = 0
    for k in keys:
        if c[k] > k:
            cnt += c[k] - k
        elif c[k] < k:
            cnt += c[k]
    print(cnt)

if __name__ == '__main__':
    main()

Measured memory_bytes: 18300
class Dice():
    def __init__(self, ls = [0 for i in range(6)]):
        self.ls = ls
        
    def now(self):
        return ls
    
    def S_act(self):
        ls = self.ls
        n_ls = [0 for i in range(6)]
        n_ls[0] = ls[4]
        n_ls[1] = ls[0]
        n_ls[2] = ls[2]
        n_ls[3] = ls[3]
        n_ls[4] = ls[5]
        n_ls[5] = ls[1]
        
        return Dice(n_ls)
    
    def N_act(self):
        ls = self.S_act().S_act().S_act().ls
        return Dice(ls)
        
    def E_act(self):
        ls = self.ls
        n_ls = [0 for i in range(6)]
        n_ls[0] = ls[3]
        n_ls[1] = ls[1]
        n_ls[2] = ls[0]
        n_ls[3] = ls[5]
        n_ls[4] = ls[4]
        n_ls[5] = ls[2]
        return Dice(n_ls)
    
    
    def W_act(self):
        ls = self.E_act().E_act().E_act().ls
        return Dice(ls)

        
ls = list(map(int, input().split()))
a = Dice(ls)


act = input()

for i in act:
    func = {'S':a.S_act(), 'E':a.E_act(), 'W': a.W_act(), 'N':a.N_act()}
    a = func[i]
    
    
print(a.ls[0])
    



Measured memory_bytes: 5612
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	ll a, b, c, d;
	cin >> a >> b >> c >> d;
	vector<ll>v1, v2;
	v1.push_back(a);
	v1.push_back(b);
	v2.push_back(c);
	v2.push_back(d);
	ll nax = -2 * 1e18;
	for (ll i = 0; i < 2; i++) {
		for (ll j = 0; j < 2; j++) {
			nax = max(nax, v1[i] * v2[j]);
		}
	}
	cout << nax << endl;
}


Measured memory_bytes: 3612
import sys
import heapq, math
from itertools import zip_longest, permutations, combinations, combinations_with_replacement
from itertools import accumulate, dropwhile, takewhile, groupby
from functools import lru_cache
from copy import deepcopy

N = int(input())
S = input()

x = 0
ans = 0
for s in S:
    x += 1 if s == 'I' else -1
    ans = max(ans, x)

print(ans)

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

#define fr first
#define sc second
#define mk make_pair
#define pb push_back

using namespace std;

typedef long long ll;
const int N = 1e6 + 5;
const int inf = 1e9 + 7;

int main() {
	int a, b, c;
	cin >> a >> b >> c;
	
	if (c < a) swap(c, a);
	if (c < b) swap(c, b);
	
	if (a == 5 && b == 5 && c == 7) {
		cout << "YES" << endl;
	} else cout << "NO" << endl;
	
	return 0;
}

Measured memory_bytes: 256
def isPrime(n):
    if n==2 or n==3:
        return True
    elif n%2==0:
        return False
    else:
        i = 2
        while i**2 <= n:
            if n%i == 0:
                return False
            i += 1
    return True
    
r = []
n = int(input())
for i in range(n):
    p = int(input())
    if isPrime(p):
        if p not in r:
            r.append(p)

print(len(r))

Measured memory_bytes: 7704
#include <iostream>
#include <vector>
#include <algorithm>
#include <bits/stdc++.h>
#include <stdlib.h>
#include <stdio.h>
using namespace std;

int main() {
   int N;
   cin >> N;
   vector<int> vec(N);
   vector<int> bottom(N);
   for(int i = 0; i<N ;i++){
       cin >> bottom.at(i);
   }
   
   
   int count = -1,a = 1;
   
   while(true){
       count++;
       if(a == 2){
           cout << count << endl;
           break;
       }
       else if(vec.at(a-1) == 0){
           vec.at(a-1)++;
           a = bottom.at(a-1);
       }
       else{
           cout << -1 << endl;
           break;
       }
   }
   
   
   
   
}


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

using namespace std;
using LL = long long;

const int maxn = 1111;
LL x;
set<LL> f;

signed main() {
  // freopen("in", "r", stdin);
  cin >> x;
  for (int i = -1000; i <= 1000; i++) {
    f.emplace(i);
  }
  LL ra, rb;
  for (auto a : f) {
    for (auto b : f) {
      if (a*a*a*a*a - b*b*b*b*b == x) {
        ra = a, rb = b;
        break;
      }
    }
  }
  cout<< ra <<" " << rb << endl;
  return 0;
}


Measured memory_bytes: 3732
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n;cin>>n;
  vector<vector<int > >coins(2,vector<int >(n,0)),final(2,vector<int >(n,0));
  for(int i=0;i<2;i++){
  	for(int j=0;j<n;j++)cin>>coins[i][j];
  }
  for(int i=0;i<2;i++){
  	for(int j=0,maxi=0;j<n;j++){
      for(int k=-1;k<=0;k++)
        for(int l=-1;l<=0;l++){
          if(k==l)continue;
        	if(i+k>=0 && j+l>=0)maxi = max(maxi,final[i+k][j+l]);
        }
    
    final[i][j]=maxi+coins[i][j];
    }
  }
   cout<<final[1][n-1];                                        
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
  int N,i,j,x,A[200000]={0},check[200000]={0},move[200000]={0};
  long long K;
  i=scanf("%d %lld",&N,&K);
  for(i=0;i<N;i++)check[i]=-scanf("%d",&A[i]);
  for(i=0,j=0;;i=A[i]-1,j++)if(check[i]<0)check[i]=j,move[j]=i;else{x=check[i];break;}
  if(K>=j)K=(K-x)%(x-j)+x;
  return printf("%d\n",move[K]+1),0;
}

Measured memory_bytes: 4080
#include <bits/stdc++.h>
using namespace std;
int main(){
	long long n,a[1000]={},cnt=0;
	while(cin >> n){
		if(n==0){
			cout << a[cnt-1] << endl;
			cnt--;
		}else{
			a[cnt]=n;
			cnt++;
		}
	}
	return 0;
}



Measured memory_bytes: 3104
import std.stdio;
import std.conv;
import std.string;
import std.typecons;
import std.algorithm;
import std.array;
import std.range;
import std.math;
import std.regex : regex;
import std.container;

void main()
{
	int n;
	auto coin = [500, 100, 50, 10, 5, 1];
	while (n = readln.chomp.to!int, n) {
		auto cng = 1000 - n;
		int cnt;
		foreach (c; coin) {
			cnt += cng / c;
			cng %= c;
		}
		cnt.writeln;
	}
}

Measured memory_bytes: 1040
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cmath>

using namespace std;

int main(){
    int q;
    cin >> q;
    for(int i = 0; i < q; i++){
        long long a, b;
        cin >> a >> b;
        long long c = (long long)sqrt(a * b);
        if(c * (c + 1) < a * b){
            cout << 2 * c - 1 << endl;
        }else if(c * c == a * b && a != b){
            cout << 2 * (c - 1) - 1 << endl;
        }else{
            cout << 2 * (c - 1) << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {

    public static void main(String[] args) {
        // write your code here
        Scanner scanner = new Scanner(System.in);
        int h = scanner.nextInt();
        int w = scanner.nextInt();

        char[][] array = new char[h][];
        Arrays.setAll(array, i -> scanner.next().toCharArray());

        int[][] l = new int[h][w];
        int[][] r = new int[h][w];
        int[][] u = new int[h][w];
        int[][] d = new int[h][w];

        // 左メモ
        for (int i = 0; i < h; i++) {
            for (int j = 0; j < w; j++) {
                if (array[i][j] == '#') {
                    l[i][j] = 0;
                } else if (j == 0) {
                    l[i][j] = 1;
                } else {
                    l[i][j] = l[i][j - 1] + 1;
                }
            }
        }

        // 右メモ
        for (int i = 0; i < h; i++) {
            for (int j = w - 1; j >= 0; j--) {
                if (array[i][j] == '#') {
                    r[i][j] = 0;
                } else if (j == w - 1) {
                    r[i][j] = 1;
                } else {
                    r[i][j] = r[i][j + 1] + 1;
                }
            }
        }

        // 上メモ
        for (int i = 0; i < w; i++) {
            for (int j = 0; j < h; j++) {
                if (array[j][i] == '#') {
                    u[j][i] = 0;
                } else if (j == 0) {
                    u[j][i] = 1;
                } else {
                    u[j][i] = u[j - 1][i] + 1;
                }
            }
        }

        // 下メモ
        for (int i = 0; i < w; i++) {
            for (int j = h - 1; j >= 0; j--) {
                if (array[j][i] == '#') {
                    d[j][i] = 0;
                } else if (j == h - 1) {
                    d[j][i] = 1;
                } else {
                    d[j][i] = d[j + 1][i] + 1;
                }
            }
        }

        int ans = 0;

        for (int i = 0; i < h; i++) {
            for (int j = 0; j < w; j++) {
                ans = Math.max(ans, u[i][j] + d[i][j] + l[i][j] + r[i][j] - 3);
            }
        }

        System.out.println(ans);
    }
}

Measured memory_bytes: 110988
#include <iostream>

using namespace std;

int main(){
  int L,N;
  cin >> L >> N;
  int x,w;
  int count =0;
  for(int i=0;i<N;i++){
    cin >> x >> w;
    count += x*w;
  }
  if(count!=0){
    cout << 1 <<endl;
    if(count <0){
      cout << 1 << " " << count*-1<<endl;
    }else{
      cout << -1 << " " <<count<<endl;
    }
  }else{
    cout << 0 << endl;
  }
}

Measured memory_bytes: 3060
N = int(input())
L = []
for _ in range(N):
    l = list(map(int,input().split()))
    L.append(l)
L = sorted(L,key=lambda x:(x[1],x[0]))
time = 0
for x in L:
    time += x[0]
    if time > x[1]:
        print("No")
        quit()
print("Yes")


Measured memory_bytes: 92120
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
#define int ll
typedef pair<int,int> pii;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(a) (a).begin(),(a).end()
#define pb emplace_back

int dfa[51]={};
int fa(int n){
    if(dfa[n]!=0)return dfa[n];
    if(n==0)return 1;
    else return dfa[n] = fa(n-1)*2+3;
}

int dfp[51]={};
int fp(int n){
    if(dfp[n]!=0)return dfp[n];
    if(n==0)return 1;
    else return dfp[n] = fp(n-1)*2+1;
}

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

    int ans = 0;
    while(x>0){
      //今見てるパウンドがLevel N
        for(int i=n;i>=0;i--){  
            if(x>=fa(i)){ //Level　i のバーガーを食べきれるか
                x-=fa(i);
                ans+=fp(i);

                if(x>0){  //Level i を食べた後に間のパウンドを食べる
                    x--;
                    ans++;
                }

                n = i;  //今見てるパウンドを更新(?)
                break;
            }else{  //無理ならLevel i のパンズを食べてLevel i-1に移行
                x--;
            }
        }
    }

    cout<<ans<<endl;
}


Measured memory_bytes: 256
#!/usr/bin/env python3
import sys


def solve(S: str):
    count = 0
    last = ""
    current = ""
    for c in S:
        current +=c
        if current != last:
            last = current
            current = ""
            count+=1
    print(count)
    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    S = next(tokens)  # type: str
    solve(S)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3508
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define FOR(i,s,n) for(int i = s; i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(n) (n).begin(), (n).end()
#define RALL(n) (n).rbegin(), (n).rend()
#define ATYN(n) cout << ( (n) ? "Yes":"No") << endl;
#define CFYN(n) cout << ( (n) ? "YES":"NO") << endl;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;

int main(void)
{
    IOS
    int n; cin >> n;
    string s; cin >> s;
    vector<vector<int>> v(10);
    REP(i,s.size()) v[s[i]-'0'].push_back(i);

    int ans = 0;
    REP(i,10) {
        auto it1 = lower_bound(ALL(v[i]),0);
        if (it1 == v[i].end()) continue;
        REP(j,10) {
            auto it2 = lower_bound(ALL(v[j]),*it1+1);
            if (it2 == v[j].end()) continue;
            REP(k,10) {
                auto it3 = lower_bound(ALL(v[k]),*it2+1);
                if (it3 != v[k].end()) ans++;
            }
        }
    }

    cout << ans << endl;

    return 0;
}

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

#define endl "\n"
#define all(x) x.begin(),x.end()
#define pb push_back
#define ff first 
#define ss second 
#define pii pair<int,int>
#define vi vector<int>
#define vc vector<char>
#define vii vector<pii>
#define vvi vector<vi>
#define fori(i,n) for(int i=1;i<=n;++i)
#define forn(i,n) for(int i=0;i<n;++i)
#define sz(x) int(x.size())
#define error(x) cout<<#x<<" "<<x<<endl
#define IOS  ios::sync_with_stdio(0);cin.tie(0);cout.tie(0)

const int N=100*1000;
const int mod=1e9+7;

int min3(int a,int b,int c){return min(a,min(b,c));}
int max3(int a,int b,int c){return max(a,max(b,c));}
int min4(int a,int b,int c,int d){return min(min(a,b),min(c,d));}
int max4(int a,int b,int c,int d){return max(max(a,b),max(c,d));}

//#define int int64_t
//int a[N+2];

int32_t  main(){
	IOS;
  int ans=0;
  int r,g,b,n;cin>>r>>g>>b>>n;
  for(int i=0;i<=n;++i){
    for(int j=0;j<=n;++j){
      int val=n-(r*i+j*g);
      if(val>=0 && val%b==0)ans++;
    }

  }
  cout<<ans<<endl;

  return 0;
}



Measured memory_bytes: 256
#include<stdio.h>

int main(void){
	
	int num,k;
	
	num = 0;
	
	char st[100];
	
	scanf("%s",&st);
	
	for(k=0;st[k]!='\0';k++){
		num++;
	}
	
	printf("%c%d%c\n",st[0],num-2,st[num-1]);
	
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define dbg(x) cerr<<#x<<" = "<<x<<endl;
#define dbg_v(v,n) {cerr<<#v<<" = [";for(int III=0;III<=n;III++)cerr<<v[III]<<(III!=n?",":"]\n");}
#define ll long long
#define ld long double
#define ull unsigned long long
#define pii pair<int,int>
#define MOD 1000000007
#define zeros(x) x&(x-1)^x
#define fi first
#define se second
#define Nmax 1005
using namespace std;

int n,m,a,b,s[Nmax],mat[Nmax][Nmax], ok;

int main(){
    ios::sync_with_stdio(false);
    cin >> n >> m >> a >> b;
    
    for (int i=1;i<=n-b;i++){
    	for (int j=1;j<=m-a;j++){
    		mat[i][j] = 1;
    	}
    }
    for (int i=n-b+1;i<=n;i++)
    	for (int j=m-a+1;j<=m;j++)
    		mat[i][j] = 1;

    for (int i=1;i<=n;i++,cout << '\n')
    	for (int j=1;j<=m;j++){
    		cout << mat[i][j];
    	}
    
    return 0;
}

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

int main(){
    int n;
    int A[1000];
    int y,j;
    cin >> n;
    
    for(int i = 0; i < n; i++){
        cin >> A[i];
        //cout << A[i];
    }
    for(int i = 1; i < n ; i++){
        y = A[i];
        j = i- 1;
        for(int k = 0; k < n; k++){
            if (k != 0){
                cout << " ";
            }
            cout << A[k];
        }
        cout << endl;
        while(j >= 0 && A[j] > y){
            A[j + 1] = A[j];
            j = j - 1;
        }
        //A[i] = A[j + 1];
        A[j + 1] = y;
        
        
    }
    for(int k = 0; k < n; k++){
            if (k != 0){
                cout << " ";
            }
            cout << A[k];
        }
        cout << endl;
    
    return 0;
}


Measured memory_bytes: 3104
n, k = map(int, input().split())
h_list = list(map(int, input().split()))
costs = [0] * n
costs[1] = abs(h_list[0] - h_list[1])
start = 0
for i in range(2, n):
    tmp = []
    v = h_list[i]
    start = max(0, i-k)
    costs[i] = min(abs(v - h_j) + c for h_j, c in zip(h_list[start:i], costs[start:i]))
    # for l in range(start, i):
    #     tmp.append(abs(v - h_list[l])+costs[l])
    #     if abs(v - h_list[l]) == 0:
    #         break
    # costs[i] = min(tmp)
print(costs[-1])


Measured memory_bytes: 13928
#include <cstdio>
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
#include <map>
#include <set>

#define ll long long
#define pll pair<ll, ll>

#define reps(i, f, n) for (int i = (f); i < (int)(n); i++)
#define rep(i, n) reps(i, 0, n)

const int INF = 1111111111;
const double EPS = 1e-9;

using namespace std;

void init()
{
}

void solve()
{
	string s;
	cin >> s;
	cout << s.substr(0, 3) << endl;
}

int main()
{
	init();
	solve();
}


Measured memory_bytes: 3136
/**
 * Created by hiramekun at 20:51 on 2019-08-24.
 */
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;
typedef vector<ll> vl;
typedef vector<vl> vvl;
template<typename T> using pq = priority_queue<T>;
template<typename T> using minpq = priority_queue<T, vector<T>, greater<T>>;
template<typename T, typename K> using ump = unordered_map<T, K>;
const ll dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
const ll mod = 1000000007;
const ll inf = ll(1e9);
const ll e5 = ll(1e5);
const ll ll_inf = ll(1e9) * ll(1e9);

#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define each(i, mp) for(auto& i:mp)
#define eb emplace_back
#define F first
#define S second
#define all(obj) (obj).begin(), (obj).end()

template<class T>
ostream &operator<<(ostream &out, const vector<T> &list) {
    ll n = list.size();
    rep(i, n) out << list[i] << ' ';
    return out;
}


template<class T>
istream &operator>>(istream &in, vector<T> &list) {
    ll n = list.size();
    rep(i, n) in >> list[i];
    return in;
}

/* ------------- ANSWER ------------- */
/* ---------------------------------- */

void solve() {
    ll m, d;
    cin >> m >> d;

    ll ans = 0;
    for (ll i = 1; i <= m; ++i) {
        for (ll j = 2; j <= d; ++j) {
            if (j / 10 < 2 || j % 10 < 2) continue;
            if (j % 10 * (j / 10) == i) ans++;
        }
    }
    cout << ans << '\n';
}

int main() {
#ifdef MY_DEBUG
    while (true) {
#endif
        solve();
#ifdef MY_DEBUG
    }
#endif
    return 0;
}

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

int main(){
	int a,b;
	int x;
	int total=0;
	cin>>a>>b;
	for(int i=1;i<=b;i++){
		cin>>x;
		total+=x;
	}
	total=a-total;
	if(total<0){
		cout<<"-1"<<endl;
	}
	else
	{
		cout<<total<<endl;
	}
}


Measured memory_bytes: 3592
n, y = map(int,input().split())
a, b, c = -1, -1, -1

for i in range(n+1):
    for j in range(n+1-i):
        k = n - i - j
        if k >= 0 and 10000 * i + 5000 * j + 1000 * k == y:
            a,b,c = i,j,k
            break
    if a != -1:
        break

print(a, b, c)


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

int main(){
	
	long long int N, res = 0;
	vector<long long int> L;
	
	cin >> N;

	rep(i, N){
		long long int tmp;
		cin >> tmp;
		L.push_back(tmp);
	}

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

	if(L.size() < 3){
		cout << res;
		return 0;
	}

	rep(i, N){
		for(int j = i+1; j<N; j++){
			for(int k = j+1; k<N; k++){
				if(L[i] == L[j] || L[j] == L[k] || L[k] == L[i]){
					continue;
				}
				if(L[i] + L[j] > L[k]){
					res++;
				}
			}
		}
	}

	cout << res;

	return 0;
}

Measured memory_bytes: 3628
package main

import (
  "fmt"
)

var comb = make(map[[2]int]int)
func choose(n, r int) int {
  if r > n || r < 0 {return 0}
  if r == 0 {return 1}
  k := [2]int{n, r}
  if v, ok := comb[k]; ok {return v}
  comb[k] = choose(n-1, r) + choose(n-1, r-1)
  return comb[k]
}


func main() {
  var n, m int 
  fmt.Scan(&n, &m)
  fmt.Println(choose(n, 2) + choose(m, 2))
}

Measured memory_bytes: 640
#include <iostream>

using namespace std;

int main()
{
	int n, temp, sum = 0, minN, min10;
	cin >> n;
	for (int i = 0;i < n;i++)
	{
		cin >> temp;
		sum += temp;
		if (i == 0)
		{
			if (temp % 10)min10 = temp;
			else min10 = 100;
			minN = temp;
		}
		else
		{
			if (temp < minN)minN = temp;
			if (temp < min10 && temp % 10)min10 = temp;
		}
	}

	if (sum % 10)
		cout << sum << endl;
	else
	{
		if (minN % 10)
			cout << sum - minN << endl;
		else if(min10 % 10) cout << sum - min10 << endl;
		else cout << "0\n";
	}

    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define f first
#define s second
#define pb push_back
#define mp make_pair
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
using namespace std;

// #define int long long
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;

ll mod = (1000000007LL);

inline ll poww(ll a, ll b)
{
    ll res = 1;
    while (b > 0)
    {
        if(b & 1) res = (res * a)%mod;
        a = (a * a)%mod;
        b >>= 1;
    }
    return res;
}
inline pii operator+(pii A, pii B){
	return pii(A.f + B.f, A.s + B.s);
}
inline pii operator-(pii A, pii B){
	return pii(A.f - B.f, A.s - B.s);
}
inline ll mult(ll a, ll b){
	return (a * b) % mod;
}

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

/*
	>Colocar (>DEFINE INT LONG LONG<) no inicio do template
	>mod = (1e9 + 7), por padrao (NAO ESQUECER DE ALTERAR)
	>NAO ESQUECER DEFINE INT LONG LONG
	> N = 1 ? 
*/

///CUIDADO COM MAXN
#define N 300050

int n, m, q, k, v[N], ans;

pii TT, w[N];

string s;
vector<int> caras;
int32_t main()
{
	ios::sync_with_stdio(false); cin.tie(0);
    cin>>s;
    n = sz(s);
    for(int i = 0; i < n; i++){
        if(s[i] == '1') caras.pb(i+1);
    }
    if(s[0] != '1'){
        cout<<"-1\n";
        return 0;
    }
    for(auto i: caras){
        if(!binary_search(all(caras), n-i)){
            cout<<"-1\n";
            return 0;
        }
    }
    vector<vector<int> > grafo;
    grafo.resize(n+1);
    int cnt = 1;
    for(int i = 1; i <= sz(caras); i++){
        grafo[cnt].pb(cnt + 1);
        grafo[cnt + 1].pb(cnt);
        ++cnt;
    }
    cnt++;
    int curr = 0;
    for(int i = 1, j = 0; j < sz(caras); j++,i++){
        curr ++;
        // cout<<i<<" "<<caras[j]<<" "<<curr<<"\n";
        while(curr != caras[j]){
            grafo[i].pb(cnt);
            grafo[cnt].pb(i);
            ++cnt;
            curr ++;
        }
    }
    // cout<<"\n";
    for(int i = 1; i <= n; i++){
        for(auto u: grafo[i]){
            if(i<u)
            cout<<i<<" "<<u<<"\n";
        }
    }
}

Measured memory_bytes: 7368
#include<bits/stdc++.h>
using namespace std;
#define INF 1e9
struct edge{
	//行先、容量、コスト、逆辺
	int to,cap,cost,rev;	
};	
void add_edge(int from,int to,int cap ,int cost,vector<vector<edge> > &g){
	g[from].push_back( (edge) { to,cap,cost,(int)g[to].size() } );
	g[to].push_back( (edge){from,0, -cost,(int)g[from].size()-1});
}
// s to t minmun flow 
// can't reach -1
int min_cost_flow(int s,int t,int f,vector<vector<edge> > &g){
	int res = 0;
	int v = (int)g.size();
	vector<int> prevv(v),preve(v);
	while( f > 0 ){
		//bellmanford s-t周辺最短路を求める
		vector<int> dist(v,INF);
		dist[s] = 0;
		bool update = true;
		while(update){
			update = false;
			for(int j= 0;j<v;j++){
				if(dist[j] == INF) continue;
				for(int i= 0;i<g[j].size();i++){
					edge &e = g[j][i];
					if(e.cap > 0 && dist[e.to] > dist[j] + e.cost){
						dist[e.to] = dist[j]  + e.cost;
						prevv[e.to] = j;
						preve[e.to] = i;
						update = true;
					}
				}
			}
		}
		if(dist[t] == INF ) return -1; //can't reach 
		//s-t周辺に目いっぱい流す
		int d = f;
		for(int i = t; i!= s; i = prevv[i]) d = min(d,g[prevv[i]][preve[i]].cap);
		f -= d;
		res += d*dist[t];
		for(int i = t; i!= s; i = prevv[i]){
			edge &e = g[prevv[i]][preve[i]];
			e.cap  -= d;
			g[i][e.rev].cap  += d;
		}
	}
	return res;
}


int main(){
	int v,e,f;
	cin>>v>>e>>f;
	vector<vector<edge> > g(v);
	for(int i=0;i<e;i++){
	int c,d,u,v;
	cin>>u>>v>>c>>d;
	add_edge(u,v,c,d,g);
	}
	cout<<min_cost_flow(0,v-1,f,g)<<endl;
	return 0;
}



Measured memory_bytes: 3192