akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i, n)	for(int i=0;i<(int)(n);i++)
using namespace std;

int main(){
    vector<vector<int>> a(3, vector<int>(3));
    int n, b;
    rep(i, 3){
        rep(j, 3){
            cin >> a[i][j];
        }
    }
    cin >> n;
    vector<vector<int>> bingo(3,vector<int>(3));
    rep(i, n){
        cin >> b;
        rep(j, 3){
            rep(k, 3){
                if(a[j][k]==b){
                    bingo[j][k] = 1;
                }
            }
        }
    }
    vector<int> r(3,0);
    vector<int> c(3,0);
    rep(i, 3){
        rep(j,3){
            if(bingo[j][i]==1)
                c.at(i)++;
        }
    }
    rep(i, 3){
        rep(j,3){
            if(bingo[i][j]==1)
                r.at(i)++;
        }
    }
    if(bingo[1][1]==1&&bingo[2][2]==1&&bingo[0][0]==1
        || bingo[0][2]==1&&bingo[1][1]==1&&bingo[2][0]==1){
            cout << "Yes" << endl;
            return 0;
        }

    rep(i, 3){
        if(r.at(i)==3||c.at(i)==3){
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
}

Measured memory_bytes: 3564
S = list(input())
ok = ["A", "C", "G", "T"]

len_list = []
tmp = 0

for l in S:
    if l in ok:
        tmp += 1
    else:
        len_list.append(tmp)
        tmp = 0
    
len_list.append(tmp)
        
print(max(len_list))

Measured memory_bytes: 3060
/*{{{*/
#include <bits/stdc++.h>
#define st first
#define nd second
#ifdef LOCAL
int c_;
#define cout (c_?cerr:cout)
#define debug(...) {cerr<<(!c_?"\033[96;1m":"");\
++c_;__VA_ARGS__;--c_;cerr<<(!c_?"\033[0m":"");}
#else
#define debug(...) {}
#endif
#define st first
#define nd second
#define dump_range(...) debug(cerr<<#__VA_ARGS__<<": ";print_range(__VA_ARGS__))
#define all(...) (__VA_ARGS__).begin(), (__VA_ARGS__).end()
#define dump(...) debug(print(#__VA_ARGS__,'=',__VA_ARGS__))
using namespace std; using ll = long long;
template< typename... t > using V = vector< t... >;
void print(){cout << '\n';}
template< typename t, typename... v >
void print(const t& a, const v&... b)
{cout << a << (sizeof...(b)?" ":"");print(b...);}
int argc_; char** argv_;
template< typename t > 
void print_range(t a, const t& b)
{while (a != b) cout << (*a++) << ' '; cout << '\n';}
/*thread_local mt19937 gen;
inline ll arg(int v, ll def = 0)
{return v < argc_? atoll(argv_[v]) : def;}
template< typename t >
t rng(t min, t max) 
{return uniform_int_distribution< t >{min, max}(gen);}*/
/*}}}*/

int main(int argc, char** argv)
{
    argc_ = argc; argv_ = argv;
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    //gen = mt19937(arg(1));
    
    int n;
    cin >> n;
    bool fl = false;
    while (n--)
    {
        int v; cin >> v;
        fl |= (v & 1);
    }
    print(fl? "first" : "second");
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define F first
#define S second
#define pii pair<int, int>
#define pli pair<ll, int>
#define pil pair<int, ll>
#define pll pair<ll, ll>
#define eb emplace_back
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep3(i, l, n) for (int i = l; i < (n); ++i)
#define sz(v) (int)v.size()
#define endl '\n'
const int inf = 1000000007;
const ll INF = 1e18;
int mod = 998244353;
// int mod = 1000000007;
#define abs(x) (x >= 0 ? x : -(x))
#define lb(v, x) (int)(lower_bound(all(v), x) - v.begin())
#define ub(v, x) (int)(upper_bound(all(v), x) - v.begin())
template<typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { if (a < b) { a = b; return 1; } return 0; }
ll gcd(ll a, ll b) { if (b == 0) return a; return gcd(b, a % b); }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
template<typename T, typename U> T pow_(T a, U b) { return b ? pow_(a * a, b / 2) * (b % 2 ? a : 1) : 1; }
ll modpow(ll a, ll b, ll _mod) { return b ? modpow(a * a % _mod, b / 2, _mod) * (b % 2 ? a : 1) % _mod : 1; }
template<class T, class U> ostream& operator << (ostream& os, const pair<T, U>& p) { os << p.F << " " << p.S; return os; }
template<class T> ostream& operator << (ostream& os, const vector<T>& vec) { rep(i, sz(vec)) { if (i) os << " "; os << vec[i]; } return os; }
template<typename T> inline istream& operator >> (istream& is, vector<T>& v) { rep(j, sz(v)) is >> v[j]; return is; }
template<class T, class T2> inline void add(T &a, T2 b) { a += b; if (a >= mod) a -= mod; }
template<class T> void operator += (vector<T>& v, vector<T> v2) { rep(i, sz(v2)) v.eb(v2[i]); }

void solve();

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cout << fixed << setprecision(11);
  int T;
  T = 1;
  while (T--) solve();
}

const int MAX = 2000005;
ll fac[MAX], finv[MAX], inv[MAX];
// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % mod;
        inv[i] = mod - inv[mod % i] * (mod / i) % mod;
        finv[i] = finv[i - 1] * inv[i] % mod;
    }
}
// 二項係数計算
ll COM(int n, int k) {
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % mod) % mod;
}

void solve() {
  int p;
  cin >> p;
  mod = p; // debuged
  vector<int> a(p);
  cin >> a;

  COMinit();
  vector<int> b(p);
  rep(i, p) {
    if (a[i] == 0) continue;

    b[0]++;
    // (x-i)^(p-1) = (p-1)Cj x^j (-i)^(p-1-j)
    ll x = 1;
    for (int j = p - 1; j >= 0; --j) {
      (b[j] += mod - COM(p - 1, j) * x % mod) %= mod;
      x = (p + x * (-i) % p) % p;
    }
  }
  cout << b << endl;
}


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

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

  int min_value = 100000000;
  for (int i = 2; i < S.size(); ++i) {
    int A, B, C;
    A = S.at(i - 2) - '1' + 1;
    B = S.at(i - 1) - '1' + 1;
    C = S.at(i) - '1' + 1;
    int value = A * 100 + B * 10 + C * 1;
    min_value = min(min_value, abs(value - 753));
  }

  cout << min_value << endl;
  return 0;
}


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


int main(){
	int h,w;
	cin>>h>>w;
	string s[27][27];
	for(int i=0;i<h;i++){
		for(int j=0;j<w;j++){
			cin>>s[i][j];
		}
	}
	for(int i=0;i<h;i++){
		for(int j=0;j<w;j++){
			if(s[i][j]=="snuke"){
				cout<<(char)('A'+j)<<i+1<<endl;
			}
		}
	}
	return 0;
}


Measured memory_bytes: 256
import sys
import heapq
sys.setrecursionlimit(10 ** 7)
input = sys.stdin.readline
f_inf = float('inf')
mod = 10 ** 9 + 7


def resolve():
    n, m = map(int, input().split())
    edge = [[] for _ in range(n)]
    k = []
    for _ in range(m):
        a, b, c = map(int, input().split())
        edge[a - 1].append([c, b - 1])
        edge[b - 1].append([c, a - 1])
        k.append([c, a - 1, b - 1])

    def dijkstra_heap(s):
        d = [f_inf] * n
        used = [True] * n
        d[s] = 0
        used[s] = False
        edgelist = []
        for e in edge[s]:
            heapq.heappush(edgelist, e)
        while len(edgelist):
            minedge = heapq.heappop(edgelist)
            if not used[minedge[1]]:
                continue
            v = minedge[1]
            d[v] = minedge[0]
            used[v] = False
            for e in edge[v]:
                if used[e[1]]:
                    heapq.heappush(edgelist, [e[0] + d[v], e[1]])
        return d

    used = set()
    for i in range(n):
        dist = dijkstra_heap(i)
        for d, to, fr in k:
            if dist[to] + d == dist[fr]:
                used.add((to, fr))

    print(len(k) - len(used))

if __name__ == '__main__':
    resolve()


Measured memory_bytes: 3572
#include <iostream>
#include <cmath>
using namespace std;
 
int main() {
  int input_a;
  int input_b;
  cin >> input_a;
  cin >> input_b;
  float output_float = ((float)input_a + (float)input_b) / (float) 2;
  //cout << output_float << endl;
  int output_int = (int)ceil(output_float);
  cout << output_int << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <unordered_map>

using namespace std;
using ll = long long;

void _cin(){} template <class Head, class... Tail> void _cin(Head&& head, Tail&&... tail){ cin >> head; _cin(forward<Tail>(tail)...); }
void _cout(){ cout << "\n"; } template <class Head, class... Tail> void _cout(Head&& head, Tail&&... tail){ cout << head; _cout(forward<Tail>(tail)...); }
int gcd(int a, int b){ return (b == 0) ? a : gcd(b, a % b); }
template<typename S, typename T> ostream& operator<<(ostream &os, const pair<S, T> &p){ cout << "[" << p.first << ", " << p.second << "]"; return os; }

#define Sq(x) (x)*(x)
#define For(i, n) for(int i = 0; i < (n); i ++)
#define Rep(n) For(_, n)
#define Range(c) c.begin(), c.end()
#define RevRange(c) c.rbegin(), c.rend()
#define Contains(c, x) (find(Range(c), x) != c.end())
#define Search(rb, re, x) distance(rb, find(rb, re, x))
#define Sort(a) sort(Range(a))
#define DeSort(a) sort(RevRange(a))
#define Reverse(c) reverse(Range(c))
#define Unique(a) a.erase(unique(Range(a)), a.end())
#define Cusum(T, xs, sxs) vector<T> sxs(xs.size()+1); For(i, (int)xs.size()) sxs[i+1] = sxs[i] + xs[i]
#define Cin(T, ...) T __VA_ARGS__; _cin(__VA_ARGS__)
#define Cins(T, n, xs) vector<T> xs(n); For(i, n) cin >> xs[i]
#define Cins2(T, n, xs, ys) vector<T> xs(n), ys(n); For(i, n) cin >> xs[i] >> ys[i]
#define Cins3(T, n, xs, ys, zs) vector<T> xs(n), ys(n), zs(n); For(i, n) cin >> xs[i] >> ys[i] >> zs[i]
#define Cinss(T, n, m, xs) Vec2(T, n, m, xs); For(i, n) For(j, m) cin >> xs[i][j]
#define Cinm(T, n, map) unordered_map<T, int> map; Rep(n){ Cin(T, x); map[x] ++; }
#define Cout(...) _cout(__VA_ARGS__)
#define Couts(xs) { for(const auto &e : xs) cout << e << " "; cout << "\n"; }
#define Coutyn(cond) Cout((cond) ? "yes" : "no")
#define CoutYn(cond) Cout((cond) ? "Yes" : "No")
#define CoutYN(cond) Cout((cond) ? "YES" : "NO")
#define Return(expr) { Cout(expr); return 0; }
#define vc vector
#define Mini(a, x) a = min(a, x)
#define Maxi(a, x) a = max(a, x)

// constexpr int MOD = 1e9+7;

int main(void){
    Cin(ll, a, b, n);
    Cout(a * min(n, b-1) / b);
    
}





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

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

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










int main(){
    int D, T, S; std::cin >> D >> T >> S;
    std::cout << (S*T >= D ? "Yes" : "No") << std::endl;
    return 0;
}


Measured memory_bytes: 3632
#include "bits/stdc++.h"
using namespace std;
#define FOR(i,a,b) for(int i =(a);i<(b);i++)
#define REP(i,n) for(int i=0;i<(n);i++)
#define REPm(i,n) for(int i=(n)-1;i>=0;i--)
#define REP1(i,n) for(int i=1;i<=(n);i++)
#define mp make_pair
typedef long long ll;
int main(){
    string s;
    cin >> s;
    cout << s.substr(0,s.length()-8) << endl;
    return 0;
}


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

int main() {
	int n, max = 0, sum = 0;

	cin >> n;

	for (int i = 0; i < n; i++) {
		int a;
		cin >> a;
		if (a > max) max = a;
		sum += a;
	}

	sum -= max;

	if (max < sum) cout << "Yes"; else cout << "No";

	getchar(); getchar();
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(void){
    int i, j, f, map[8][8];

    while(1){
        f = 0;
        for(i = 0; i < 8; i++){
            for(j = 0; j < 8; j++){
                if(scanf("%1d", &map[i][j]) == EOF){
                    f = 1;
                    break;
                }
            }
        }

        if(f == 1) break;

        for (i = 0; i < 8; i++){
            for(j = 0; j < 8; j++){
                if(map[i][j] == 1){
                    if(i == 7) { printf("C\n"); i = 8; break; }
                    if(i < 5){
                        if(map[i+3][j] == 1) { printf("B\n"); i = 8; break; }
                    }
                    if(i < 6){
                        if(map[i+2][j-1] == 1) { printf("D\n"); i = 8; break; }
                        else if(map[i+2][j+1] == 1) { printf("F\n"); i = 8; break; }
                    }
                    if(map[i+1][j-1] == 1) { printf("G\n"); i = 8; break; }
                    else if(map[i+1][j+2] == 1) { printf("E\n"); i = 8; break; }
                    else if(map[i+1][j+1] == 1) { printf("A\n"); i = 8; break; }
                    else { printf("C\n"); i = 8; break; }
                }
            }
        }
    }
    return 0;
}

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

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

  int b[n-1];
  rep (i, n-1) cin >> b[i];

  int ans = b[0] + b[n-2];
  for (int i = 1; i < n-1; i++) {
    if (b[i] > b[i-1])
      ans += b[i-1];
    else ans += b[i];
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
//AUTHOR - NAVEEN KUMAR(@naveen19991124)
#include<bits/stdc++.h>
//#include<boost/multiprecision/cpp_int.hpp>
//#inlcude<boost/multiprecision/cpp_dec_float.hpp>
#define ll long long
#define ld long double
#define F first
#define S second
#define mem(v) memset(v,0,sizeof(v))
#define all(v) v.begin(), v.end()
#define srt(v) sort(all(v))
#define rsrt(v) sort(v.rbegin(),v.rend())
#define pb push_back
#define f(a) for(ll i = 0;i<a;i++)
#define rep(i,a,b) for(ll i = a;i<b;i++)
#define rrep(i,a,b) for(ll i = a;i>b;i--)
#define vll vector<ll>
#define mp make_pair
#define fir first
#define sec second
#define dbg1(a) cout<<a<<"\n";
#define dbg2(a,b) cout<<a<<" "<<b<<"\n";
#define hell 1000000007
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using namespace std;
using namespace std:: chrono;
//using boost :: multiprecision :: cpp_int;
//using boost :: multiprecision :: cpp_dec_float_50;
//using boost :: multiprecision :: cpp_dec_float_100;
ll power(ll a, ll n) {ll p = 1;while (n > 0) {if(n%2) {p = p * a;} n >>= 1; a *= a;} return p;}
ll power(ll a, ll n, ll mod) {ll p = 1;while (n > 0) {if(n%2) {p = p * a; p %= mod;} n >>= 1;
a *= a; a %= mod;} return p % mod;}
ll modInverse(ll a, ll m) { ll m0 = m; ll y = 0, x = 1; 
if (m == 1) {return 0;} 
while (a > 1) { ll q = a / m; ll t = m;  m = a % m, a = t; t = y; y = x - q * y; x = t; } 
if (x < 0) {x += m0;} return x; } 
inline ll add(ll a, ll b) { return (((a >= hell) ? a % hell : a) + ((b >= hell) ? b % hell : b) + hell) % hell; }
inline ll subt(ll a, ll b) { return (a - b + hell) % hell; }
inline ll mult(ll a, ll b) { return (1ll * ((a >= hell) ? a % hell : a) * ((b >= hell) ? b % hell : b)) % hell; }
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a * (b / gcd(a, b)); }
ll mylog(ll n,ll b)
{ll i = 1;ll ans = 0;
while(1)
{if(i>n/b){break;} i = i*b;ans++;}return ans;
}
bool compare(const pair<ll,ll> &a,const pair<ll,ll> &b){
if (a.first == b.first)
{return a.second<b.second;} 
return a.first<b.first;
}
bool comparerev(const pair<ll,ll> &a,const pair<ll,ll> &b){
if(a.first == b.first)
{return a.second>b.second;}
return a.first>b.first;
}
#define pi 3.1415926535897932384626433832
int main()
{
    fast
    ll t = 1;
   // cin>>t;
    while(t--){
    ll n;
    cin>>n;
    ld ans = 2*pi*n;
    cout<<ans<<"\n";
    } 
    return 0;
}

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

int main()
{
    int n, m, x; cin >> n >> m >> x;
    vector<int> a(m);
    for (int i = 0; i < m; i++) cin >> a[i];
    
    int left = 0, right = 0;
    for (int i = 0; i < m; i++) {
        (a[i] < x ? left : right)++;
    }
    cout << min(left, right) << endl;
    return 0;
}

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

struct Linked_List{
  int key;
  struct Linked_List *prev;
  struct Linked_List *next;
};

typedef struct Linked_List Link;

//関数のプロトタイプ宣言
void insert(int);
void delete(int);
void deleteFirst(void);
void deleteLast(void);
void delete_ALL(void);
void Show(void);

Link *nill;

int main(void){
  int n,key;
  int i;
  char input[12];

  scanf("%d",&n);

  //先頭へのポインタをnillに格納
  nill=malloc(sizeof(Link));
  nill->prev=nill;
  nill->next=nill;

  for(i=0;i<n;i++){
    scanf("%s",input);
    
    if(strcmp("insert",input)==0){
      scanf("%d",&key);
      insert(key);
    }
    else if(strcmp("delete",input)==0){
      scanf("%d",&key);
      delete(key);
    }
    else if(strcmp("deleteFirst",input)==0){
      deleteFirst();
    }
    else if(strcmp("deleteLast",input)==0){
      deleteLast();
    }
    else{
      printf("Error\n");
      exit(1);
    }
    
    
  }

  //出力
  Show();

  //解放
  delete_ALL();
  free(nill);

  return 0;
}


//insert関数
void insert(int num){
  Link *data;

  data=malloc(sizeof(Link));
  data->key=num;
  nill->next->prev=data;
  data->next=nill->next;
  nill->next=data;
  data->prev=nill;
}

//delete関数
void delete(int num){
  Link *work;
  int flag=0;

  work=nill->next;
  while(work->key!=num){
    work=work->next;
    if(work==nill){
      flag=1;
      break;
    }
  }
  if(flag==0){
    work->next->prev=work->prev;
    work->prev->next=work->next;
    free(work);
  }
}

//deleteFirst
void deleteFirst(void){
  Link *work;

  work=nill->next;
  work->next->prev=nill;
  nill->next=work->next;
  free(work);
}

//deleteLast
void deleteLast(void){
  Link *work;

  work=nill->prev;
  work->prev->next=nill;
  nill->prev=work->prev;
  free(work);
}

//delete_ALL関数
void delete_ALL(void){
  while(nill->next!=nill){
    deleteLast();
  }
}


//Show関数
void Show(void){
  Link *work;

  work=nill->next;
  while(work!=nill){
    if(work==nill->next) printf("%d",work->key);
    else printf(" %d",work->key);
    work=work->next;
  }
  printf("\n");
}

Measured memory_bytes: 31788
N = int(input())

D = []
for _ in range(N):
    a, b = map(int, input().split())
    if a == b:
        D.append('1')
    else:
        D.append('0')
D = ''.join(D)
ans = False
if '1'*3 in D:
    ans = True
print('Yes' if ans else 'No')

Measured memory_bytes: 9116
#include<bits/stdc++.h>
#define ll long long 
using namespace std;
const ll int INF = 1e18+5;
const int mod=1e9 + 7;
int main()
{
    int h,w;
    cin >> h >> w;
    vector<vector<char>>in(h+1,vector<char>(w+1));
    for(int i=0;i<h;i++)
    {
        for(int j=0;j<w;j++)
        {
            cin >> in[i][j];
        }
    }
    vector<vector<int>>paths(h+1,vector<int>(w+1,0));
    paths[0][0]=1;
    for(int i=0;i<h;i++)
    {
        for(int j=0;j<w;j++)
        {
            for(int r2:{i,i+1})
            {
                int c2=j;
                if(r2==i)
                    c2=j+1;
                if(r2<h && c2<w && in[r2][c2]=='.')
                    paths[r2][c2] += paths[i][j];
                paths[r2][c2] %=mod;
            }
        }
    }
    cout << paths[h-1][w-1];
    
}


Measured memory_bytes: 5248
from collections import namedtuple

Point = namedtuple('Point', ['x', 'y'])
# Edge = namedtuple('Edge', ['from', 'to'])

N = int(input())

R = []
for _ in range(N):
    x, y = map(int, input().split())
    R.append(Point(x, y))

B = []
for _ in range(N):
    x, y = map(int, input().split())
    B.append(Point(x, y))

E = [[] for _ in range(N)]
for i, r in enumerate(R):
    for j, b in enumerate(B):
        if r.x < b.x and r.y < b.y:
            E[i].append(j)

match = [-1 for _ in range(N)]


def dfs(v: int, visited: set) -> bool:
    for u in E[v]:
        if u in visited:
            continue
        visited.add(u)

        if match[u] == -1 or dfs(match[u], visited):
            match[u] = v
            return True
    return False


def bipartite_matching():
    return sum(dfs(i, set()) for i in range(N))


print(bipartite_matching())


Measured memory_bytes: 3436
#include <iostream>
#include <vector>
#include <utility>
#include <map>
#include <algorithm>
#include <queue>
#include <cmath>

using namespace std;

int main() {
	int n;
	cin >> n;
	int ans = 0;
	vector<int> h(n);

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

	int cnt = 0;
	for (int i=1; i<n; i++){
		if (h[i] <= h[i-1]){
			cnt++;
			ans = max(cnt, ans);
		}else{
			cnt = 0;
		}
	}

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

Measured memory_bytes: 640
#include <bits/stdc++.h>
 
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,n) for(int i=1;i<=(n);i++)
#define lol long long
#define SUM(n) ((n)+1)*(n)/2　//1〜nまでの総和を求める式
#define mp make_pair
#define fi first
#define se second
#define pu push_back
#define SYOU(x) fixed<<setprecision(x+1) //小数点桁数を指定する
#define abs(x,y) max(x,y)-min(x,y)
#define all(v) v.begin(),v.end()
#define UPDight(a,b) (a+b-1)/b //小数点切り上げ 
const int INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3fLL;
const int MOD=int(1e9)+7; 
using namespace std;
using pii = pair<int, int>;
typedef vector<int> vit;

lol gcd(lol x, lol y){
  if(x < y) swap(x, y);
  lol r = x % y;
  while(r != 0){
    x = y;
    y = r;
    r = x % y;
  }
  return y;
}

signed main(void){
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  lol n, x, X;
  cin >> n >> X >> x;
  lol ans = abs(X, x);
  reps(i, n - 1){
    cin >> x;
    ans = gcd(ans, abs(X, x));
  }
  cout << ans << '\n';
  
  return 0;
}


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

int main(){
  char s;
  cin >> s;
  if(s == 'a' || s == 'i' || s == 'u' || s == 'e' || s == 'o'){
    cout << "vowel" << endl;
  }
  else{
    cout << "consonant" << endl;
  }
  return 0;
}


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

int main() {

	string s, t; cin >> s >> t;
	int p = s.size();
	bool can = false;
	string tmp = s;
	string y;
	string z;
	while (p--) {
		if (tmp == t) {
			can = true;
		}
		y = tmp.substr(0, tmp.size() - 1);
		z = tmp.back();
		tmp = "";
		tmp += z;
		tmp += y;
	}
	if (can) cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 3564
#include <algorithm>
#include <iostream>
#include <vector>

using namespace std;

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

#define MOD 1000000007
#define REP(i, N) for (int i = 0; i < N; ++i)
#define REP1(i, N) for (int i = 1; i <= N; ++i)
#define RREP(i, N) for (int i = N - 1; i >= 0; --i)
#define ALL(a) a.begin(), a.end()

int main() {
  int h, w;
  while (cin >> h >> w) {
    if (h == 0 && w == 0) break;
    REP(i, h) {
      REP(j, w) cout << '#';
      cout << "\n";
    }
    cout << "\n";
  }
  return 0;
}


Measured memory_bytes: 3104
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <bitset>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <numeric>
#include <iostream>
#include <iomanip>
#include <string>
#include <chrono>
#include <random>
#include <cmath>
#include <cassert>
#include <climits>
#include <cstring>
#include <cstdlib>
#include <functional>
#include <sstream>

using namespace std;

class Solution {
public:
    long long solve(string& N, int K) {
        int n = N.length();

        vector<vector<long long>> dp(2, vector<long long>(K + 1, 0));
        dp[0][0] = 1;
        auto ndp = dp;
        for (int i = 0; i < n; ++i) {
            for (auto& V : ndp) {
                for (auto& x :V) {
                    x = 0;
                }
            }
            int d = N[i] - '0';

            for (int j = 0; j < 2; ++j) {
                for (int k = 0; k <= K; ++k) {
                    int l = 0;
                    int r = 9;
                    if (j == 0) {
                        r = min(r, d);
                    }
                    for (int dd = l; dd <= r; ++dd) {
                        int nj = j;
                        if (dd < d) {
                            nj = 1;
                        }
                        int nk = k;
                        if (dd != 0) {
                            ++nk;
                        }
                        if (nk <= K) {
                            ndp[nj][nk] += dp[j][k];
                        }
                    }
                }
            }

            swap(ndp, dp);
        }


        long long res = 0;
        res += dp[0][K];
        res += dp[1][K];

        return res;
    };
};

int main(int argc, char** argv) {
    ios::sync_with_stdio(false);
    cin.tie(0);
    string N;
    cin >> N;
    int K;
    cin >> K;
    Solution sol;
    cout << sol.solve(N, K) << "\n";

    return 0;
}

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

int main()
{
    string s; cin >> s;
    if (s[1] == 'B'){
        cout << "ARC" << endl;
    }else{
        cout << "ABC" << endl;
    }
    
    return 0;
}


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

int main() {
    int H, N;
    cin >> H >> N;
    int A[N], B[N];
    rep(i, N) cin >> A[i] >> B[i];
    int ans = 1e9;
    int dp[H];
    rep(i, H) dp[i] = 1e9;
    dp[0] = 0;
    rep(i, H) {
        rep(j, N) {
            int next = i + A[j];
            if (next >= H) {
                ans = min(ans, dp[i] + B[j]);
            } else {
                dp[next] = min(dp[next], dp[i] + B[j]);
            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define endl '\n'
#define SPEED ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define M 998244353
#define MOD 1000000007
signed main()
{
    SPEED;
    int n;
    cin>>n;
    int freq[n+1]={0},a;
    for(int i=1;i<n;i++)
    {
        cin>>a;
        ++freq[a];
    }
    for(int i=1;i<=n;i++)
    {
        cout<<freq[i]<<endl;
    }
}

Measured memory_bytes: 5184
#include<iostream>
#include<string>
using namespace std;
int main() {
	int a, b;
	string s, t, u;
	cin >> s >> t;
	cin >> a >> b;
	cin >> u;
	if (u == s)a--;
	else if (u == t)b--;
	cout << a << " " << b << endl;
	return 0;
}

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

int main()
{
	string str;
	getline(cin, str);
	for(int i = 0; i < str.length(); ++i)
	{
		if('a' <= str[i] && str[i] <= 'z')
		{
			str[i] = str[i] - 'a' + 'A';
		}
		else if('A' <= str[i] && str[i] <= 'Z')
		{
			str[i] = str[i] - 'A' + 'a';
		}
	}
	cout << str << endl;

    return 0;
}



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

int main(){
  int N; cin >> N;
  string s; cin >> s;
  
  REP(i,s.size()){
    char c = s[i]+N;
    if(c>'Z'){
      c = ('A'-1) + (c-'Z');
    }
    cout << c;
  }
  cout << '\n';
}
  

Measured memory_bytes: 256
/*
このコード、と～おれ!
Be accepted!
∧＿∧　
（｡･ω･｡)つ━☆・*。
⊂　　 ノ 　　　・゜+.
　しーＪ　　　°。+ *´¨)
 　　　　　　　　　.· ´¸.·*´¨) ¸.·*¨)
		  　　　　　　　　　　(¸.·´ (¸.·'* ☆
					*/

#include <stdio.h>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstring>
#include <vector>
#include <numeric>
#include <iostream>
#include <random>
#include <map>
#include <unordered_map>
#include <queue>
#include <regex>
#include <functional>
#include <complex>
#include <list>
#include <cassert>
#include <iomanip>
#include <set>

#define rep(i, n) for(int i = 0; i < (n); ++i)
#define rep1(i, n) for(int i = 1; i <= (n); ++i)
#define rep2(i, n) for(int i = 2; i < (n); ++i)
#define repr(i, n) for(int i = n; i >= 0; --i)
#define reprm(i, n) for(int i = n - 1; i >= 0; --i)
#define printynl(a) printf(a ? "yes\n" : "no\n")
#define printyn(a) printf(a ? "Yes\n" : "No\n")
#define printYN(a) printf(a ? "YES\n" : "NO\n")
#define printim(a) printf(a ? "possible\n" : "imposible\n")
#define printdb(a) printf("%.50lf\n", a)//少数出力
#define printdbd(a) printf("%.16lf\n", a)//少数出力(桁少なめ)
#define prints(s) printf("%s\n", s.c_str())//string出力
#define all(x) (x).begin(), (x).end()
#define allsum(a, b, c) ((a + b) * c / 2)//等差数列の和、初項,末項,項数
#define pb push_back
#define priq priority_queue
#define rpriq priq<int, vector<int>, greater<int>>
#define deg_to_rad(deg) (((deg)/360.0)*2.0*PI)
#define rad_to_deg(rad) (((rad)/2.0/PI)*360.0)
#define Please return
#define AC 0
#define addf(T) [](T a, T b){return (a + b);}
#define minf(T) [](T a, T b){return min(a, b);}
#define maxf(T) [](T a, T b){return max(a, b);}


using ll = long long;

constexpr int INF = 1073741823;
constexpr int MINF = -1073741823;
constexpr ll LINF = ll(4661686018427387903);
constexpr ll MOD = 1000000007;
const long double PI = acos(-1.0L);

using namespace std;

void scans(string& str) {
	char c;
	str = "";
	scanf("%c", &c);
	if (c == '\n')scanf("%c", &c);
	while (c != '\n' && c != -1) {
		str += c;
		scanf("%c", &c);
	}
}

void scanc(char& str) {
	char c;
	scanf("%c", &c);
	if (c == -1)return;
	while (c == '\n') {
		scanf("%c", &c);
	}
	str = c;
}

double acot(double x) {
	return PI / 2 - atan(x);
}

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

ll lcm(ll number1, ll number2) {
	return number1 / gcd(number1, number2) * number2;
}

ll LSB(ll n) { return (n & (-n)); }

/*-----------------------------------------ここからコード-----------------------------------------*/


int main() {

	int n;
	scanf("%d", &n);
	vector<int> a(n);
	rep(i, n)scanf("%d", &a[i]);
	sort(all(a));
	int d = distance(unique(all(a)), a.end());
	printf("%d\n", a.size() - d - d % 2);
	
	Please AC;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int n,p,x,t0,t1;
int main(){
	scanf("%d%d",&n,&p);
	for(int i = 0;i<n;i++){
		scanf("%d",&x);
		if(x%2==0) t0++;
		else t1++;
	}
	ll ans = 0;
	if(p==0) {
		if(t1==0) ans = 1ll<<t0;
		else ans = 1ll<<t0+t1-1;
	} else {
		if(t1==0) ans = 0;
		else ans = 1ll<<t0+t1-1;
	}
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 256
n,k = map(int,input().split())

ans = 0
for i in range(k, n+2):
    max_i = ((n + (n - i + 1)) * i) // 2
    min_i = ((i - 1) *  i) // 2
    ans += max_i - min_i + 1
    ans %= 10**9 + 7

print(ans)

Measured memory_bytes: 9180
#pragma GCC optimize ("Ofast")
#include<bits/stdc++.h>
using namespace std;
inline void rd(char &c){
  int i;
  for(;;){
    i = getchar_unlocked();
    if(i!=' '&&i!='\n'&&i!='\r'&&i!='\t'&&i!=EOF){
      break;
    }
  }
  c = i;
}
inline int rd(char c[]){
  int i, sz=0;
  for(;;){
    i = getchar_unlocked();
    if(i!=' '&&i!='\n'&&i!='\r'&&i!='\t'&&i!=EOF){
      break;
    }
  }
  c[sz++] = i;
  for(;;){
    i = getchar_unlocked();
    if(i==' '||i=='\n'||i=='\r'||i=='\t'||i==EOF){
      break;
    }
    c[sz++] = i;
  }
  c[sz]='\0';
  return sz;
}
inline void wt_L(char a){
  putchar_unlocked(a);
}
inline void wt_L(int x){
  char f[10];
  int m=0, s=0;
  if(x<0){
    m=1;
    x=-x;
  }
  while(x){
    f[s++]=x%10;
    x/=10;
  }
  if(!s){
    f[s++]=0;
  }
  if(m){
    putchar_unlocked('-');
  }
  while(s--){
    putchar_unlocked(f[s]+'0');
  }
}
char S[5];
char T[5];
int main(){
  int i, res=0;
  rd(S);
  rd(T);
  for(i=0;i<(3);i++){
    if(S[i]==T[i]){
      res++;
    }
  }
  wt_L(res);
  wt_L('\n');
  return 0;
}
// cLay varsion 20190902-1

// --- original code ---
// char S[5], T[5];
// {
//   int res = 0;
//   rd(S,T);
//   rep(i,3) if(S[i]==T[i]) res++;
//   wt(res);
// }


Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#include <vector>
#include <deque>
#include <utility>
#include <algorithm>
#include <map>

using namespace std;

typedef pair<int, char> ip;

class pp {
public:
	int num, idx;
	pp(int num, int idx)
		:num(num), idx(idx)
	{}
};

bool cmp(const pp &i, const pp &j) {
	return i.num > j.num;
}

char s[200001], p[200001];
int l;

vector<int> pos[26];
vector<ip> v;
map<ip, int> d;
int bt[1 << 19];

void upd(int k) {
	while (k) {
		bt[k]++;
		k >>= 1;
	}
}

int qry(int l, int r) {
	int ret = 0;
	while (l <= r) {
		if (l & 1) ret += bt[l++];
		if (!(r & 1)) ret += bt[r--];
		l >>= 1; r >>= 1;
	}
	return ret;
}

int main() {
	scanf("%s", &s);
	l = strlen(s);
	for (int i = 0; i < l; i++)
		pos[s[i] - 'a'].push_back(i);
	int c = 0;
	for (int i = 0; i < 26; i++) {
		if (pos[i].size() % 2) c++;
	}
	if (l % 2 == 0) {
		if (c) {
			puts("-1");
			return 0;
		}
	}
	else {
		if (c != 1) {
			puts("-1");
			return 0;
		}
	}
	for (int i = 0; i < 26; i++) {
		for (int j = 0; j < pos[i].size() / 2; j++) {
			v.push_back(ip(pos[i][j], i + 'a'));
		}
	}
	for (int i = 0; i < 26; i++) if (pos[i].size() % 2) {
		v.push_back(ip((1 << 30), i + 'a'));
		break;
	}
	sort(v.begin(), v.end());
	for (int i = 0; i < v.size(); i++)
		p[i] = p[l - 1 - i] = v[i].second;
	int cnt[26] = { 0 };
	for (int i = 0; i < l; i++) {
		d[ip(cnt[s[i] - 'a'], s[i])] = i;
		cnt[s[i] - 'a']++;
	}
	vector<pp> q;
	memset(cnt, 0, sizeof(cnt));
	for (int i = 0; i < l; i++) {
		q.push_back(pp(d[ip(cnt[p[i] - 'a'], p[i])], i));
		cnt[p[i] - 'a']++;
	}
	sort(q.begin(), q.end(), cmp);
	long long res = 0;
	int sz = 1;
	while (sz < l) sz *= 2;
	for (int i = 0; i < q.size(); i++) {
		int idx = q[i].idx;
		res += qry(sz, sz + idx);
		upd(sz + idx);
	}
	printf("%lld\n", res);
	return 0;
}

Measured memory_bytes: 18032
/* Aditya0412 */
#include <bits/stdc++.h>
using namespace std; 
typedef long long int ll;
#define pb push_back 
//#define pop pop_back
#define mp make_pair
#define ve vector
#define vii vector < int >
#define vll vector < ll > 
#define pii pair < int , int >
#define pll pair < ll , ll >
#define vpl vector < pll >
#define fi first
#define sz size 
#define len length 
#define se second 
//const ll mod=998244353;
const ll mod = 1000000000+7;
const ll N=1000000+6;
#define M_PI           3.14159265358979323846 
vector< ll > tree[N];

int main() 
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    // #ifndef ONLINE_JUDGE
    //   freopen ("INPUT.txt" , "r" , stdin);
    //   freopen ("OUTPUT.txt", "w" , stdout);
    // #endif 
      string s;
      cin>>s;
      if(s[2]==s[3] and s[4]==s[5])
        cout<<"Yes\n";
      else
        cout<<"No\n";
}

Measured memory_bytes: 23808
package main

import (
	"fmt"
)

func main() {
	var a, b int
	fmt.Scan(&a, &b)

	if !(a >= 1 && a <= 9) || !(b >= 1 && b <= 9) {
		fmt.Println("-1")
	} else {
		fmt.Println(a * b)
	}
}

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

const int N = 100010;

typedef long long ll;

ll x[N], p[N];

int main(){
    int n, s;
    scanf("%d%d", &n, &s);
    for (int i = 0; i < n; ++ i){
        scanf("%lld%lld", &x[i], &p[i]);
    }
    int sit = std::lower_bound(x, x + n, s) - x;
    int left = 0, right = n - 1;
    ll ans = 0;
    int previouschoice = -1;
    while (true){
        if (left == sit){
            ans += x[right] - s;
            break;
        }
        if (right == sit - 1){
            ans += s - x[left];
            break;
        }
        if ((p[left] >= p[right]) != previouschoice){
            ans += x[right] - x[left];
            previouschoice = p[left] >= p[right];
        }
        if (p[left] >= p[right]){
            p[left] += p[right];
            -- right;
        }
        else{
            p[right] += p[left];
            ++ left;
        }
    }
    printf("%lld\n", ans);
    return 0;
}

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

void fnInput(int64_t& nNumN, int64_t& nNumK)
{
  cin >> nNumN >> nNumK;
}
  
int64_t fnMinRepNum(int64_t nNumN, int64_t nNumK)
{
  if (nNumN < nNumK)
  {
    int64_t n1stRepNum = nNumK - nNumN;
    return min(nNumN, n1stRepNum);
  }
  else
  {
    int64_t n1stRepNum = nNumN % nNumK;

    int64_t n2ndRepNum = n1stRepNum;
    if (n1stRepNum)
      n2ndRepNum = nNumK % n1stRepNum;

    return min(n1stRepNum, n2ndRepNum);
  }
}
  
int main()
{
  int64_t nNumN, nNumK;

  fnInput(nNumN, nNumK);
  cout << fnMinRepNum(nNumN, nNumK) << endl;

  return 0;
}

Measured memory_bytes: 3588
#include <bits/stdc++.h>
using namespace std;
struct P
{
    //string r;
    int x,y,z;
    //string r;
    bool operator<(const P &a)const{
       // if(y!=a.y)
       // return y>a.y;
       return x>a.x;
//        return z>a.z;
    }
};
struct S
{
    int x,y;
};
vector<P> v[100333];
//bitset<4001000> bit;
int a,c,i,b,k,d,n,m,e;//dy[15]={0,1,0,-1,-1,1,-1,1},dx[15]={1,0,-1,0,1,1,-1,-1};//
int l[200][200];
long long o[1005522];
long long j[200100];
int dx[10]={0,1,0,-1},dy[10]={1,0,-1,0},dz[10]={0,0,0,0,1,-1};

long long x,y,z,mod=1000000007;
P u[122222][333];
//int j[31][11111];

stack<S> s;
queue<int> q;
queue<int> q1;

//deque<int> de;
//'1'==49;
//'A'==65;
//'a'==97;
//unordered_
map<string,string > p;
//list<int> l;
string r,r1,r2,r3;
//char r[33][33];

bool as(int a,int b)
{
    return a>b;
}

int f(int a)
{
    int i=0;
    for(;a;a/=10,i++);
    return i;
}
long long g(int a)
{
    if(a==0) return 1;
    long long x=g(a/2);
    x*=x;
    x*=mod;
    if(a&1) x*=10,x%=mod;
    return x;
}
int main()
{
    scanf("%d",&a);
    n=1;
    m=1;
    c=10;
    d=10;
    e=1;
    b=1;
    i=1;
    for(;n<10000000;)
    {
        if(i>=a)
        {
            if(i==a)
            {
                //printf("@%d %d\n",n,m);
                x++;
            }
            i-=e;
            n++;
            if(n==c) c*=10,e++;

        }
        else
        {
            m++;
            if(m==d) d*=10,b++;
            i+=b;
        }
        x%=mod;
    }

    //for(int t=2;t<=a;t++)
      //  g[t]=z[t-1]*10%mod;
      y=90000000;
      //z=10000000;
    for(int t=7;t<a;t++)
    {
        //printf("%d %lld\n",t,x);
        int q=a%(t+1),p=a/(t+1);
        if(q)
        {
            if(p>q)
            {
            x+=(p-q)/(t+2)+1;
            if(!(a%(t+2))) x--;
            }
        }
        else
        {
            x+=y-p+1+p/(t+2);
            if(!(a%(t+2))) x--;
        }
        y=y*10%mod;
        if(x<0) x+=mod;
        if(x>=mod) x-=mod;
    }
    printf("%lld",x);
}


Measured memory_bytes: 5888
##### 解けた #####

import numpy as np

N=int(input())
S=np.full((N,),".",dtype=object)

# プラスの方
for n in range(N):
    S[n]=input()

M=int(input())
T=np.full((M,),".",dtype=object)

# マイナスの方
for m in range(M):
    T[m]=input()

ust=np.unique(np.append(S,T)) # プラスマイナスについてのユニーク
maxy=0 # これから更新する最大値

# 各ユニークについて
for u in ust:
    y=(len(np.where(S==u)[0])-len(np.where(T==u)[0]))
    maxy=max(maxy,y)

print(maxy)

Measured memory_bytes: 12508
#include "bits/stdc++.h"
using namespace std;
bool dp[2][16001];
int main() {
	string s;
	cin >> s;
	int x, y;
	cin >> x >> y;
	vector<int> X, Y;
	int pos = 0;
	while (pos < s.size() && s[pos] == 'F') pos++, x--;
	bool moveX = 1;
	int d = 0;
	while (pos < s.size()) {
		if (s[pos] == 'F') {
			d++;
		}
		else {
			if (moveX) X.push_back(d);
			else Y.push_back(d);
			moveX ^= 1;
			d = 0;
		}
		pos++;
	}
	if (moveX) X.push_back(d);
	else Y.push_back(d);
	dp[0][s.size()] = 1;
	for (int i = 0; i < X.size(); i++) {
		for (int j = 0; j <= 2 * s.size(); j++) {
			if (!dp[i & 1][j]) continue;
			if (j + X[i] <= 2 * s.size()) dp[(i + 1) & 1][j + X[i]] = 1;
			if (0 <= j - X[i]) dp[(i + 1) & 1][j - X[i]] = 1;
			dp[i & 1][j] = 0;
		}
	}
	if (!dp[X.size() & 1][x + s.size()]) {
		cout << "No" << endl;
		return 0;
	}
	memset(dp, 0, sizeof(dp));
	dp[0][s.size()] = 1;
	for (int i = 0; i < Y.size(); i++) {
		for (int j = 0; j <= 2 * s.size(); j++) {
			if (!dp[i & 1][j]) continue;
			if (j + Y[i] <= 2 * s.size()) dp[(i + 1) & 1][j + Y[i]] = 1;
			if (0 <= j - Y[i]) dp[(i + 1) & 1][j - Y[i]] = 1;
			dp[i & 1][j] = 0;
		}
	}
	if (!dp[Y.size() & 1][y + s.size()]) {
		cout << "No" << endl;
		return 0;
	}
	cout << "Yes" << endl;
}

Measured memory_bytes: 384
#include <iostream>

using namespace std;


int main(void) {
    
    int n;
    int a[100001];
    
    cin >> n;
    
    for (int i = 1; i <= n; ++i) {
        
        cin >> a[i];
    
    }
    
    int now = a[1];
    int c = 1;
    
    for (;;) {
        
        if (now == 2) {
            
            cout << c << endl;
            break;
            
        }
        else if (c >= n) {
            
            cout << - 1 << endl;
            break;
            
        }
        
        now = a[now];
        ++c;
        
    }
    
    return 0;
    
}



























Measured memory_bytes: 640
#define _USE_MATH_DEFINES

#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cmath>
#include <bitset>
using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef tuple<ll, ll, ll> tl3;



const int BIG_NUM = 1e9;
const ll INF = 1000000000000000000;
const ll MOD = 1e9 + 7;
//const ll MOD = 998244353;

const int MAX = 18;

int main() {
	int n;
	cin >> n;
	ll ans = 0;

	vector<vector<ll>> c(MAX + 1, vector<ll>(MAX + 1));
	for (int i = 0; i < n; i++) {
		string s;
		cin >> s;


		ll a = 0;

		bool isD = false;
		int cnt = 0;
		for (int i = 0; i < s.length(); i++) {
			if (isD) {
				cnt++;
			}
			if (s[i] == '.') {
				isD = true;
				continue;
			}

			
			a = a * 10 + s[i] - '0';
		}

		while (cnt < 9) {
			a *= 10;
			cnt++;
		}

		
		//cout << a << endl;
		int cnt2 = 0;
		int cnt5 = 0;
		while (a % 2 == 0) {
			cnt2++;
			a /= 2;
		}

		cnt2 = min(cnt2, MAX);

		while (a % 5 == 0) {
			cnt5++;
			a /= 5;
		}


		cnt5 = min(cnt5, MAX);




		for (int i = 0; i <= MAX; i++) {
			if (i + cnt2 < MAX) {
				continue;
			}
			for (int j = 0; j <= MAX; j++) {
				if (j + cnt5 < MAX) {
					continue;
				}
				ans += c[i][j];
			}
		}
		




		
		c[cnt2][cnt5]++;

	}
	cout << ans << endl;
	
	/*
	cout.fill(' ');
	cout << "   ";
	for (int i = 0; i <= MAX; i++) {
		cout << setw(2) << i << " ";
	}
	cout << endl;
	for (int i = 0; i <= MAX; i++) {
		cout << setw(2) << i << " ";
		for (int j = 0; j <= MAX; j++) {
			cout << setw(2) << c[i][j] << " ";
		}
		cout << setw(2) << endl;
	}
	*/

}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
#define ALL(a) (a).begin(),(a).end()
#define rALL(a) (a).rbegin(),(a).rend()
typedef pair<int, int> Pint;
typedef pair<int64_t, int64_t> Pll;


int main() {
    int ans = 0;
    string S;
    cin >> S;
    for(int i = 0; i < S.size(); i++){
        if (S.at(i) == '1'){
            ans++;
        }
    }
    cout << ans << endl;
}




Measured memory_bytes: 256
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#define pb push_back
using namespace std;
using ll = long long;
const char E = '\n';
const int N = 2005;
const ll mod = 1e9+7;

int main()
{
    ios_base::sync_with_stdio(0); cin.tie(); cout.tie(0);
    int n, x, y, ans[N] = {0};
    cin >> n >> x >> y;
    for (int i=1; i<=n; i++) {
        for (int j=i+1; j<=n; j++) {
            if (j <= x || i >= y) ans[j-i] ++;
            else {
                if (i <= x && j >= y) ans[1+j-y+x-i] ++;
                else {
                    int dist = j-i;
                    if (i <= x && j >= x) {
                        dist = min(dist, x-i+1+y-j);
                        ans[dist] ++;
                        continue;
                    }
                    if (i >= x && j >= y) {
                        dist = min(dist, i-x+1+j-y);
                        ans[dist] ++;
                        continue;
                    }
                    dist = min(dist, i-x+1+y-j);
                    ans[dist] ++;
                }
            }
        }
    }
    for (int i=1; i<=n-1; i++) {
        cout << ans[i] << E;
    }
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <queue>
#include <tuple>
#include <cstring>

#define INF 100000000

using namespace std;

int main()
{
    int a,b;
    cin >> a >> b;
    cout << 2*b-a << endl;

    return 0;

}


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

int h, w;
vector<string> v;
bool a[101], b[101];

int main(){
//	cin.tie(0);
//	ios::sync_with_stdio(false);
	cin >> h >> w;
	for(int i=0; i<h; ++i){
		string s;
		cin >> s;
		v.push_back(s);
	}
	for(int i=0; i<h; ++i){
		bool f = true;
		for(int j=0; j<w; ++j)
			if(v[i][j] == '#'){
				f = false;
				break;
			}
		if(f) a[i] = true;
	}
//	for(int i=0; i<h; ++i)
//		if(a[i]) cout << i << "\n";
	for(int i=0; i<w; ++i){
		bool f = true;
		for(int j=0; j<h; ++j)
			if(v[j][i] == '#'){
				f = false;
				break;
			}
		if(f) b[i] = true;
	}
//	for(int i=0; i<w; ++i)
//		if(b[i]) cout << i << "\n";
	for(int i=0; i<h; ++i){
		if(a[i]) continue;
		for(int j=0; j<w; ++j){
			if(b[j]) continue;
			cout << v[i][j];
		}
		cout << "\n";
	}
}

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

int main() {

  int cnt = 0;
  int N;
  cin >> N;

  for (int i = 0; i < N; i++) {
    int l, r;
    cin >> l >> r;
    cnt += r - l + 1;
  }
  cout << cnt << endl;
}

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

using namespace std;
using int64 = long long int;

constexpr int MaxN = 100000 + 10;
int n, m, k;
vector<int> friends[MaxN];
vector<int> blocks[MaxN];
int trueBlocks[MaxN];
int trueFriends[MaxN];
vector<int> clusters[MaxN];
int nos[MaxN];

void AssignID(int index, int id)
{
	nos[index] = id;
	clusters[id].push_back(index);

	for (auto f : friends[index])
	{
		if (nos[f] == -1)
		{
			AssignID(f, id);
		}
	}
}

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

	for (int i = 0; i < m; i++)
	{
		int a, b;
		cin >> a >> b;
		a--; b--;

		friends[a].push_back(b);
		friends[b].push_back(a);
	}

	for (int i = 0; i < k; i++)
	{
		int c, d;
		cin >> c >> d;
		c--; d--;

		blocks[c].push_back(d);
		blocks[d].push_back(c);
	}

	memset(nos, -1, sizeof(nos));

	int nextID = 0;
	for (int i = 0; i < n; i++)
	{
		if (nos[i] == -1)
		{
			AssignID(i, nextID++);
		}
	}

	for (int i = 0; i < n; i++)
	{
		for (auto b : blocks[i])
		{
			if (nos[b] == nos[i])
			{
				trueBlocks[i]++;
			}
		}

		for (auto f : friends[i])
		{
			if (nos[f] == nos[i])
			{
				trueFriends[i]++;
			}
		}
	}

	for (int i = 0; i < n; i++)
	{
		int count = clusters[nos[i]].size();
		count--;
		count -= trueBlocks[i] + trueFriends[i];
		cout << count << " ";
	}

	cout << endl;
}

Measured memory_bytes: 16636
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <numeric>
#include <queue>
#include <vector>
#include <cmath>
#include <cctype>
#include <cstring>
#include <cstdio>
#include <set>
#include <map>
#include <stack>

using namespace std;

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

typedef long long LL;
typedef pair<int, int> PII;
typedef vector<int> VI;

#define all(x) (x).begin(), (x).end()
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repl(i, n) for(LL i = 0; i < (LL)(n); i++)

int main(void){
  int N, rem;
  cin >> N;
  rem = N % 10;
  if (rem == 3) {
    cout << "bon" << endl;
  } else if (rem == 0 || rem == 1 || rem == 6 || rem == 8) {
    cout << "pon" << endl;
  } else {
    cout << "hon" << endl;
  }
  return 0;
};

Measured memory_bytes: 3624
h, n = list(map(int,input().split()))
mahou = []
for i in range(n):
    a, b = list(map(int,input().split()))
    mahou.append([a,b])
dp=[100000000000]*(h+100000)
dp[h] = 0
for i in range(h):
    for j in range(n):
        damage = mahou[j][0]
        mp = mahou[j][1]
        hp = h-i
        if dp[hp - damage] > dp[hp] + mp:
            dp[hp - damage] = dp[hp] + mp
dp.append(dp[0])
dp = dp[h+1:]

print(min(dp))

Measured memory_bytes: 44508