akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <algorithm>

namespace ABC178
{

  class B
  {
  public:
    B() = default;
    ~B() = default;


    void Run()
    {
      long long a,b,c,d = {};
      std::cin >> a;
      std::cin >> b;
      std::cin >> c;
      std::cin >> d;

      long long A = 0;

      std::vector<long long> list = {};
      list.push_back(a*c);
      list.push_back(a*d);
      list.push_back(b*c);
      list.push_back(b*d);

      std::sort(list.begin(), list.end());
      std::reverse(list.begin(), list.end());
      A = list[0];
      std::cout << A << std::endl;
    }
  };

}

int main()
{

  ABC178::B prob;
  prob.Run();

  return 0;
}



Measured memory_bytes: 3196
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
using namespace std;
int main() {
    int A, B, C, X, cnt = 0; cin >> A >> B >> C >> X;
    for (int i = 0; i * 500 <= X && i <= A; ++i) {
        for (int j = 0; j * 100 + i * 500 <= X && j <= B; ++j) {
            int k = (X - (500 * i + 100 * j)) / 50;
            if (C >= k) cnt++;
        }
    }
    printf("%d\n", cnt);
}


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

vector<int> solve(int N, int L, vector<int> lengths)
{
    auto last_move = -1;
    for (auto i = 0; i+1 < N; i++)
        if (lengths[i] + lengths[i+1] >= L)
            last_move = i;
    if (last_move == -1) return {};

    auto order = vector<int>();
    order.push_back(last_move);
    for (auto i = last_move+1; i < N-1; i++)
        order.push_back(i);
    for (auto i = last_move-1; i >= 0; i--)
        order.push_back(i);
    reverse(begin(order), end(order));
    return order;
}

int main()
{
    int N, L; scanf("%d %d", &N, &L);

    auto lengths = vector<int>(N);
    for (auto& x : lengths) scanf("%d", &x);

    auto answer = solve(N, L, lengths);
    if (answer.empty()) puts("Impossible");
    else
    {
        puts("Possible");
        for (auto x : answer)
            printf("%d\n", x+1);
    }
}


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

namespace Differential
{
    class Program
    {
        static void Main(string[] args)
        {
            List<double> h = new List<double>();

            while (true)
            {
                string input = Console.ReadLine();
                if (string.IsNullOrEmpty(input)) break;
                h.Add(double.Parse(input));
            }
            h.Sort();
            Console.WriteLine(h[h.Count - 1] - h[0]);
        }
    }
}



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

char F[10][10];

int main(){
  int H, W, K;
  cin >> H >> W >> K;
  rep(i, H){
    rep(j, W){
      cin >> F[i][j];
    }
  }

  int ans = 0;

  rep(bits_H, 1<<H){
    bool flag_H[H];
    rep(h, H){
      if (bits_H & (1<<h)) flag_H[h] = true;
      else flag_H[h] = false;
    }
    rep(bits_W, 1<<W){
        char G[10][10];
        rep(h, H){
          rep(w, W){
            G[h][w] = F[h][w];
          }
        }

        bool flag_W[W];
        rep(w, W){
          if (bits_W & (1<<w)) flag_W[w] = true;
          else flag_W[w] = false;
        }

      rep(h, H){
        if (flag_H[h]==true)
        rep(w, W){
          G[h][w] = '-';
        }
      }

      rep(w, W){
        if (flag_W[w]==true)
        rep(h, H){
          G[h][w] = '-';
        }
      }

      int check = 0;

      rep(h, H){
        rep(w, W){
          if (G[h][w] == '#') check++;
        }
      }

      // rep(h, H){
      //   rep(w, W){
      //     cout << G[h][w];
      //   }
      //   cout << endl;
      // }
      // cout << "~~~~~~" << endl;
      if (check==K) ans++;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 3664
#include<bits/stdc++.h>
using namespace std;
int a[200005],n,k;
bool check(int x){
    int now=0;
    for(int i=0;i<n;i++){
        now+=(a[i]-1)/x;
    }
    return now<=k;
}
int main(){
    cin>>n>>k;
    int maxn=0;
    for(int i=0;i<n;i++){
        scanf("%d",&a[i]);
        if(a[i]>maxn)   maxn=a[i];
    }
    int l=0,r=maxn;//答案上下界
    while(r-l>1){
        int mid=(l+r)>>1;
        if(check(mid))
            r=mid;
        else
            l=mid;
    }
    cout<<r<<endl;
    return 0;
}

Measured memory_bytes: 4436
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <math.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using ll = long long;
using namespace std;
int main()
{
	int n, m, x;
	cin >> n >> m >> x;
	vector<vector<int>> book(n, vector<int>(m + 1, 0));
	rep(i, n) {
		rep(j, m + 1) {
			cin >> book[i][j];
		}
	}

	int min_price, price;
	min_price = 1e+9;
	vector<int> alg(m);
	bool ok = true;
	rep(i, 1 << n) {
		price = 0;
		ok = true;
		rep(j, m)	alg[j] = 0;
		rep(j, n) {
			if (i >> j & 1) {
				rep(k, m) {
					alg[k] += book[j][k + 1];
				}
				price += book[j][0];
			}
		}
		rep(j, m) {
			if (alg[j] < x)	ok = false;
		}
		if (ok && (price < min_price))	min_price = price;
	}
	if (min_price == 1e+9)	cout << -1 << endl;
	else {
		cout << min_price << endl;
	}
	return 0;
}

Measured memory_bytes: 3116
N=int(input())
H=list(map(int,input().split()))

if N==1:print('Yes')
else:
  MAX=H[0]
  ok=1
  for i in range(1,N):
    if H[i]>MAX:MAX=H[i]
    if H[i]<=MAX-2:
      ok=0
      break
  if ok==1:print('Yes')
  else:print('No')

Measured memory_bytes: 20664
#include <bits/stdc++.h>
using namespace std;
struct Fast {
    Fast() {
        cin.tie(0);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(20);
    }
} fast;

long long mod = 1000000007;

long long div(long long a, long long b, long long c) { return b / c - (a - 1) / c; }

void print_binary(long long a) {
    for (int i = 31; i >= 0; i--) {
        cout << (a >> i & 1);
    }
    cout << endl;
}
long long modpow(long long m, long long n) {
    if (n == 0) return 1;
    if (n % 2 == 0) {
        long long t = modpow(m, n / 2);
        return t * t;
    } else {
        return modpow(m, n - 1) * m;
    }
}
void yes() {
    cout << "Yes" << endl;
    exit(0);
}
void no() {
    cout << "No" << endl;
    exit(0);
}
#define REP(i, n) for (long long i = 0; i < (n); i++)

int main() {
    string s;
    cin >> s;
    char min = 'z' + 1;
    for (char i = 'a'; i <= 'z'; i++) {
        int x = 0;
        for (int j = 0; j < s.size(); j++) {
            if (s[j] == i) {
                x++;
            }
        }
        if (x == 0) {
            if (i < min) {
                min = i;
            }
        }
    }
    if (min == 'z' + 1) {
        cout << "None" << endl;
        return 0;
    }
    cout << min << endl;
}

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

using namespace std;

typedef long long ll;
typedef long double ld;

signed main()
{
#ifdef POSPELOV
    freopen("in", "r", stdin);
    freopen("out", "w", stdout);
#endif
    ios_base::sync_with_stdio(0);
    int n, a, b;
    cin >> n >> a >> b;
    cout << (((b - a) & 1) ? "Borys" : "Alice");

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int M=1e9+7,N=1<<20;
int n,i,ans,x,f[N],g[N],now,la[N];
inline char gc(){
	static char buf[100000],*p1=buf,*p2=buf;
	return p1==p2&&(p2=(p1=buf)+fread(buf,1,100000,stdin),p1==p2)?EOF:*p1++;
}
inline int rd(){
	int x=0,fl=1;char ch=gc();
	for(;ch<48||ch>57;ch=gc())if(ch=='-')fl=-1;
	for(;48<=ch&&ch<=57;ch=gc())x=(x<<3)+(x<<1)+(ch^48);
	return x*fl;
}
void inc(int &x,int y){x+=y;if(x>=M)x-=M;}
int main(){
	n=rd();
	for (i=1;i<N;i++) f[i]=1;
	for (i=ans=1;i<=n;i++){
		x^=rd();
		if (x) inc(f[x],1ll*(now-la[x])*g[x]%M),inc(g[x],f[x]),la[x]=now;
		else inc(ans,ans),now++;
	}
	if (x) return printf("%d",f[x]),0;
	ans=1ll*ans*(M+1>>1)%M;
	for (i=1;i<N;i++) inc(ans,g[i]);
	printf("%d",ans);
}

Measured memory_bytes: 12672
#include <bits/stdc++.h>
#define fastio() ios_base::sync_with_stdio(false);
using namespace std;
typedef long long ll;
typedef long double ld;

const int maxn = 2e5+5;
pair<int,int> a[maxn];
int main(){
	int n; scanf("%d", &n);
	for(int i = 0; i<n; i++) scanf("%d %d", &a[i].second, &a[i].first);
	sort(a, a+n);
	int curt = 0;
	for(int i = 0; i<n; i++){
		curt+= a[i].second;
		if(curt>a[i].first) {puts("No"); return 0;}
	}
	puts("Yes");	
	return 0;
}


Measured memory_bytes: 1792
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define cinf(n,x) for(int i=0;i<(n);i++)cin>>x[i];
#define max3(a,b,c) max(max(a,b),c)
#define min3(a,b,c) min(min(a,b),c)
#define ft first
#define sc second
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define all(v) (v).begin(),(v).end()
#define mod 1000000007
using namespace std;
using Graph = vector<vector<int>>;
typedef long long lint;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ldouble;
typedef vector<int> vec;
typedef vector<ll> lvec;
typedef vector<ull> ulvec;
typedef vector<double> dvec;
typedef vector<pair<int,int>> pvec;
typedef vector<pair<ll,ll>> plvec;
typedef vector<tuple<ll,ll,ll>> tvec;
typedef vector<string> svec;
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; }

const ll INF=10000000010;

int main(){
    ll h,w;
    cin>>h>>w;
    ll ans=INF;
    for(ll i=1;i<h;i++){
        ll a=i*w;
        ll b=w/2;
        ll c=w-b;
        b*=h-i;
        c*=h-i;
        ll s=max3(a,b,c);
        ll t=min3(a,b,c);
        ll u=s-t;
        if(u<ans)ans=u;
        b=(h-i)/2;
        c=h-i-b;
        b*=w;
        c*=w;
        s=max3(a,b,c);
        t=min3(a,b,c);
        u=s-t;
        if(u<ans)ans=u;
    }
    for(ll i=1;i<w;i++){
        ll a=i*h;
        ll b=h/2;
        ll c=h-b;
        b*=w-i;
        c*=w-i;
        ll s=max3(a,b,c);
        ll t=min3(a,b,c);
        ll u=s-t;
        if(u<ans)ans=u;
        b=(w-i)/2;
        c=w-i-b;
        b*=h;
        c*=h;
        s=max3(a,b,c);
        t=min3(a,b,c);
        u=s-t;
        if(u<ans)ans=u;
    }
    cout<<ans<<endl;
}

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

using namespace std;

#define REP(i,n) for(ll (i) = (0);(i) < (n);++i)
#define REV(i,n) for(ll (i) = (n) - 1;(i) >= 0;--i)
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define SHOW1d(v,n) {REP(WW,n)cerr << v[WW] << ' ';cerr << endl << endl;}
#define SHOW2d(v,WW,HH) {REP(W_,WW){REP(H_,HH)cerr << v[W_][H_] << ' ';cerr << endl;}cerr << endl;}
#define ALL(v) v.begin(),v.end()
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL
#define MOD 998244353

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

char mp[1111][1111];
char san[3][3] = {
{'a','.','.'},
{'a','.','.'},
{'.','b','b'}};

char san2[3][3] = {
{'z','w','w'},
{'z','.','x'},
{'y','y','x'}};

char four[4][4] = {
{'a','a','c','d'},
{'b','b','c','d'},
{'c','d','a','a'},
{'c','d','b','b'}};

char five[5][5] = {
{'a','h','h','g','g'},
{'a','i','.','.','f'},
{'b','i','.','.','f'},
{'b','.','j','j','e'},
{'c','c','d','d','e'}};
char seven[7][7] = {
{'a','b','c','.','.','.','.'},
{'a','b','c','.','.','.','.'},
{'.','.','.','d','e','f','f'},
{'.','.','.','d','e','g','g'},
{'k','k','l','.','.','c','c'},
{'m','.','l','a','a','.','.'},
{'m','n','n','b','b','.','.'}};

void yon(int a, int b){
	REP(i, 4){
		REP(j, 4){
			mp[i+a][j+b] = four[i][j];
		}
	}
}

void roku(int a, int b){
	REP(i, 6){
		REP(j, 6){
			if(((i / 3) + (j / 3)) % 2)mp[i+a][j+b] = san[i%3][j%3];
			else mp[i+a][j+b] = san2[i%3][j%3];
		}
	}
}

void kyuu(int a, int b){
	REP(i, 9){
		REP(j, 9){
			mp[i+a][j+b] = san[i%3][j%3];
		}
	}
}

void go(int a, int b){
	REP(i, 5){
		REP(j, 5){
			mp[i+a][j+b] = five[i][j];
		}
	}
}

void seica(int n, int cou){
	for(int i = 0;;i++){
		int j = (n - cou) - i * 6;
		if(j < 0)continue;
		if(j % 9 == 0){
			j /= 9;
			REP(ii, i){
				roku(cou, cou);
				cou +=6;
			}
			REP(jj, j){
				kyuu(cou, cou);
				cou +=9;
			}
			return;
		}
	}
}

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

	REP(i, 1111)REP(j, 1111)mp[i][j] = '.';

	ll n;cin >> n;
	if(n % 3 == 0){
		REP(i, n){
			REP(j, n){
				cout << san[i%3][j%3];
			}
			cout << endl;
		}
	}
	else if(n % 5 == 0){
		REP(i, n){
			REP(j, n){
				cout << five[i%5][j%5];
			}
			cout << endl;
		}
	}
	else if(n % 7 == 0){
		REP(i, n){
			REP(j, n){
				cout << seven[i%7][j%7];
			}
			cout << endl;
		}
	}
	else if(n % 4 == 0){
		REP(i, n){
			REP(j, n){
				cout << four[i%4][j%4];
			}
			cout << endl;
		}
	}
	else if(n > 5 && n % 3 == 2) {
		int cou = 0;
		go(cou, cou);
		cou += 5;
		seica(n, cou);
		REP(i, n){
			REP(j, n){
				cout << mp[i][j];
			}
			cout << endl;
		}
	}
	else if(n > 8 && n % 3 == 1){
		int cou = 0;
		yon(cou, cou);
		cou += 4;
		seica(n, cou);
		REP(i, n){
			REP(j, n){
				cout << mp[i][j];
			}
			cout << endl;
		}
	}
	else {
		cout << -1 << endl;
	}

	return 0;
}


Measured memory_bytes: 2432
#!/usr/bin/env python3

# from numba import njit

# from collections import Counter
# from itertools import accumulate
# import numpy as np
# from heapq import heappop,heappush
# from bisect import bisect_left

# @njit
def solve(n,m,c,a,b):
  res = 0
  for i in range(n):
    res += sum(a[i][j]*b[j] for j in range(m)) + c > 0
  return res



def main():
  N,M,C = map(int,input().split())
  B = list(map(int,input().split()))
  A = [list(map(int,input().split())) for _ in range(N)]
  print(solve(N,M,C,A,B))
  return

if __name__ == '__main__':
  main()


Measured memory_bytes: 9064
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define ALL(v) v.begin(),v.end()
using ll = long long;
using pii = pair<int,int>;
using vi = vector<int>;
using vs = vector<string>;
using vb = vector<bool>;
using vll = vector<long long>;
using vpii = vector<pair<int,int>>;
using vivi = vector<vector<int>>;
using vbvb = vector<vector<bool>>;
const int dx[4] = {1,0,-1,0};
const int dy[4] = {0,1,0,-1};
const int mod = 1000000007;
const int inf = 1001001001;

int main(void) {
  int n;
  cin >> n;
  vi a(n);
  rep(i,n) cin >> a[i];
  sort(ALL(a));
  int sa = inf;
  int p;
  rep(i,n-1){
    int s = sa;
    sa = min({sa,abs(a[i]-a[n-1]/2),abs(a[i]-a[n-1]/2-1)});
    if(sa!=s) p = i;
  }
      
  cout << a[n-1] << " " << a[p] << endl;
    
}




Measured memory_bytes: 640
import fractions
N,M = map(int,input().split())
S = input()
T = input()
g = fractions.gcd(N,M)
lcm = N*M // g

for i in range(g):
    a = S[N//g * i]
    b = T[M//g * i]
    if a != b:
        print(-1)
        exit()
print(lcm)

Measured memory_bytes: 5688
#include<bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < n; ++i)
#define rrep(i,n) for (int i = n-1; i >= 0; i--)
#define rep2(i,s,n) for (int i = s; i < n; ++i)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define tmax(a,b,c) max(a,max(b,c))
#define tmin(a,b,c) min(a,min(b,c))
#define pb push_back
#define eb emplace_back
#define vi vector<int>
#define vvi vector<vector<int>>
#define vl vector<ll>
#define vs vector<string>
#define vc vector<char>
using namespace std;
using ll = long long;
using P = pair<int,int>;
using LP = pair<ll,ll>;
template<class T> inline bool chmin(T& a,T b) {if(a > b){a = b; return true;} return false;}
template<class T> inline bool chmax(T& a,T b) {if(a < b){a = b; return true;} return false;}
const int inf = 1001001001;
const ll linf = 1001001001001001001;

void solve(int n,int a,int b,int l,vi& v) {
    if(a == 0 || b == 0) {
        cout << -1 << endl;
        exit(0);
    }
    if(a+b-1 >= n) {
        a = max(0,a-(a+b-1-n));
        b = n-a+1;
        rep2(i,n-a+1+l,n+1+l) v.pb(i);
        for(int i = b-1+l; i >= 1+l; i--) v.pb(i);
        return;
    }
    rep2(i,n-a+1+l,n+1+l) v.pb(i);
    for(int i = b-1+l; i >= 1+l; i--) v.pb(i);
    solve(n-(a+b-1),a-1,b-1,l+b-1,v);
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int n,a,b;
    cin >> n >> a >> b;
    if(a+b-1 > n) {
        cout << -1 << endl;
        return 0;
    }
    vi v;
    rep2(i,n-a+1,n+1) v.pb(i);
    for(int i = b-1; i >= 1; i--) v.pb(i);
    if(n == a+b-1) {
        assert(v.size() == n);
        rep(i,n) cout << v[i] << " ";
        cout << endl;
        return 0;
    }
    solve(n-(a+b-1),a-1,b-1,b-1,v);
    assert(v.size() == n);
    rep(i,n) cout << v[i] << " ";
    cout << endl;
}


Measured memory_bytes: 3568
package main

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

func getScanner(fp *os.File) *bufio.Scanner {
	scanner := bufio.NewScanner(fp)
	scanner.Split(bufio.ScanWords)
	scanner.Buffer(make([]byte, 500001), 500000)
	return scanner
}

func getNextString(scanner *bufio.Scanner) string {
	scanner.Scan()
	return scanner.Text()
}

func getNextInt(scanner *bufio.Scanner) int {
	i, _ := strconv.Atoi(getNextString(scanner))
	return i
}

func getNextInt64(scanner *bufio.Scanner) int64 {
	i, _ := strconv.ParseInt(getNextString(scanner), 10, 64)
	return i
}

func getNextUint64(scanner *bufio.Scanner) uint64 {
	i, _ := strconv.ParseUint(getNextString(scanner), 10, 64)
	return i
}

func getNextFloat64(scanner *bufio.Scanner) float64 {
	i, _ := strconv.ParseFloat(getNextString(scanner), 64)
	return i
}

func main() {
	fp := os.Stdin
	wfp := os.Stdout

	if os.Getenv("MASPY") == "ますピ" {
		fp, _ = os.Open(os.Getenv("BEET_THE_HARMONY_OF_PERFECT"))
	}
	if os.Getenv("MASPYPY") == "ますピッピ" {
		wfp, _ = os.Create(os.Getenv("NGTKANA_IS_GENIUS10"))
	}

	scanner := getScanner(fp)
	writer := bufio.NewWriter(wfp)

	x := getNextInt(scanner)
	y := getNextInt(scanner)

	if x > y {
		x, y = y, x
	}
	if x*2 < y || (x+y)%3 != 0 {
		fmt.Println(0)
		return
	}

	c := (x + y) / 3
	cm := Com{}
	cm.init(c)

	fmt.Fprintln(writer, cm.calc(c, x-c))
	writer.Flush()
}

// Com ...
type Com struct {
	facs, invs []int64
	mod        int64
}

func (cm *Com) init(n int) {
	cm.facs = make([]int64, n+1)
	cm.invs = make([]int64, n+1)

	cm.facs[0] = 1
	cm.mod = int64(1e9 + 7)
	cm.invs[0] = cm.inv(cm.facs[0])
	for i := 1; i <= n; i++ {
		cm.facs[i] = (cm.facs[i-1] * int64(i)) % cm.mod
		cm.invs[i] = cm.inv(cm.facs[i])
	}
}

func (cm *Com) inv(n int64) int64 {
	var ii [32]int64
	ii[0] = n
	for i := 1; i < 31; i++ {
		ii[i] = (ii[i-1] * ii[i-1]) % cm.mod
	}
	var ans int64
	ans = 1
	m := cm.mod - 2
	for i := 30; i >= 0; i-- {
		for m >= 1<<uint(i) {
			ans = (ans * ii[i]) % cm.mod
			m -= 1 << uint(i)
		}
	}

	return ans
}

func (cm *Com) calc(n, k int) int64 {
	ans := cm.facs[n] * cm.invs[k]
	ans %= cm.mod
	ans = ans * cm.invs[n-k]
	ans %= cm.mod
	return ans
}


Measured memory_bytes: 11392
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <vector>

#define ll long long
#define ull unsigned long long

using namespace std;

int main() {
	int H, A;
	cin >> H >> A;

	int cnt = 0;
	while (H >= 0) {
		H -= A;
		cnt++;
		if (H <= 0){
			break;
		}
	}

	cout << cnt << endl;

	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<math.h>

int main() {
    int a[3][3], n, b[20];
    int i, j, k;
    int flag = 0;
    int mark[3][3] = {
        {0, 0, 0},
        {0, 0, 0},
        {0, 0, 0}
    };

    for (i=0; i<3; i++) {
        for (j=0; j<3; j++) {
            scanf("%d", &a[i][j]);
        }
    }
    scanf("%d", &n);
    for (k=0; k<n; k++) {
        scanf("%d", &b[k]);
        for (i=0; i<3; i++) {
            for (j=0; j<3; j++) {
                if (a[i][j] == b[k]) mark[i][j] = 1;
            }
        }
    }

    
    if (mark[0][0] && mark[0][1] && mark[0][2]) flag = 1;
    if (mark[0][0] && mark[1][0] && mark[2][0]) flag = 1;
    if (mark[0][0] && mark[1][1] && mark[2][2]) flag = 1;
    if (mark[0][1] && mark[1][1] && mark[2][1]) flag = 1;
    if (mark[0][2] && mark[1][1] && mark[2][0]) flag = 1;
    if (mark[0][2] && mark[1][2] && mark[2][2]) flag = 1;
    if (mark[1][0] && mark[1][1] && mark[1][2]) flag = 1;
    if (mark[2][0] && mark[2][1] && mark[2][2]) flag = 1;


    if (flag) printf("Yes\n");
    else printf("No\n");

    return 0;
}

Measured memory_bytes: 128
N,K=map(int,input().split())

A_list=[]
for i in range(K):
  d=int(input())
  A=list(map(int,input().split()))
  for l in A:
    A_list.append(l)
  

A_set=list(set(A_list))

n=N-len(A_set)
print(n)

Measured memory_bytes: 9124
#include <iostream>

using namespace std;

int main(){
    string s;
    cin >> s;
    char a = s[0];
    bool b = false;
    for(int i = 1; i < 3; i++){
        if(s[i] != a) b = true;
    }
    if(b){
        cout << "Yes";
    } else {
        cout << "No";
    }
}


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

int main(){
    int N; cin >> N;
    vector<double> A(N);
    for(int i=0; i<N; ++i) cin >> A[i];

    double x;
    for(int i=0; i<N; ++i) x+=1.0/A[i];

    double ans;

    ans = 1.0/x;

    printf("%.10lf\n", ans);
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<iomanip>
#include<cmath>
#include<vector>
#include<algorithm>
#include<utility>

using namespace std;

#define int long long
#define endl "\n"

constexpr long long INF = (long long)1e18;
constexpr long long MOD = 1'000'000'007; 

struct fast_io {
	fast_io(){
		std::cin.tie(nullptr);
		std::ios::sync_with_stdio(false);
	};
} fio;

signed main(){
	cout<<fixed<<setprecision(10);
	
	int N;
	int Xor = 0;
	vector<int> a;
	
	cin>>N;
	
	a.resize(N);
	
	for(int i = 0; i < N; i++){
		cin>>a[i];
		Xor ^= a[i];
	}
	
	
	for(int i = 0; i < N; i++){
		if(i) cout<<" ";
		cout<<(Xor^a[i]);
	}
	cout<<endl;
	
	return 0;
}

Measured memory_bytes: 4780
S = input()

if S[0] != "A":
    print("WA")
    exit()
if S[2:-1].count("C") != 1:
    print("WA")
    exit()

cnt = 0
for s in S:
    if s.isupper():
        cnt += 1
if cnt == 2:
    print("AC")
else:
    print("WA")

Measured memory_bytes: 9116
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0;i < (n);i++)
#define rrep(i,n) for (int i = (n - 1);i >= 0;i--)
#define all(v) v.begin(),v.end()
using namespace std;
using ll = long long;
using P = pair<int,int>;
using vi = vector<int>;
using vvi = vector<vi>;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n,k;
    cin >> n >> k;
    vi l(n);
    rep(i,n) cin >> l[i];
    sort(all(l),greater<int>());
    int ans = 0;
    rep(i,k){
        ans += l[i];
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
using namespace std;
const int N=1e5+100;
int n,l,t,ans[N],wa,wb;
struct node
{
    int x,w,id;
}a[N];
node b[N],sh[N];
deque <int> s;
signed main()
{
    scanf("%lld%lld%lld",&n,&l,&t);
    for (int i=1;i<=n;i++)
    {
        int x,w;
        scanf("%lld%lld",&x,&w);
        sh[i].x=x,sh[i].w=w;
        if (w==1) a[++wa].x=x,a[wa].w=w,a[wa].id=i;
        else b[++wb].x=x,b[wb].w=w,b[wb].id=i;
    }
    if (wa==0 || wb==0)
    {
        for (int i=1;i<=n;i++)
        {
            if (sh[i].w==2) printf("%lld\n",(sh[i].x-t+l)%l);
            else printf("%lld\n",(sh[i].x+t)%l);
        }
        return 0;
    }
    for (int i=1;i<=wb;i++) s.push_back(b[i].x);
    for (int i=1;i<=wa;i++)
    {
        while (s.front()<a[i].x)
        {
            int x=s.front();
            s.pop_front();
            s.push_back(x+l);
        }
        int now=2ll*t,cnt=0;
        cnt=(now/l)*wb,now%=l;
        cnt+=upper_bound(s.begin(),s.end(),a[i].x+now)-s.begin();
        cnt%=n;
        if (a[i].id+cnt>n) sh[a[i].id].id=a[i].id+cnt-n;
        else sh[a[i].id].id=a[i].id+cnt;
    }
    s.clear();
    for (int i=1;i<=wa;i++) s.push_back(a[i].x);
    for (int i=wb;i>=1;i--)
    {
        while (s.back()>b[i].x)
        {
            int x=s.back();
            s.pop_back();
            s.push_front(x-l);
        }
        int now=2ll*t,cnt=0;
        cnt=(now/l)*wa,now%=l;
        cnt+=wa-(lower_bound(s.begin(),s.end(),b[i].x-now)-s.begin());
        cnt%=n;
        if (b[i].id-cnt<1) sh[b[i].id].id=n+b[i].id-cnt;
        else sh[b[i].id].id=b[i].id-cnt;
    }
    t%=l;
    for (int i=1;i<=n;i++)
    {
        if (sh[i].w==2) ans[sh[i].id]=(sh[i].x-t+l)%l;
        else ans[sh[i].id]=(sh[i].x+t)%l;
    }
    for (int i=1;i<=n;i++) printf("%lld\n",ans[i]);
}

Measured memory_bytes: 9540
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {

	public static void main(String[] args) throws IOException {
		Main mainObj = new Main();
		mainObj.solve();
	}

	public void solve() throws IOException {
		FastScanner fs = new FastScanner();
		int n = fs.nextInt();
		int m = fs.nextInt();
		
		int sum = 0;
		for(int i = 0; i < m; i++) {
			sum += fs.nextInt();
		}
		
		if(n >= sum) {
			System.out.println(n - sum);
		}else {
			System.out.println(-1);
		}
	}

	

	public class FastScanner {

		BufferedReader reader;
		private StringTokenizer st;

		public FastScanner() {
			st = null;
			reader = new BufferedReader(new InputStreamReader(System.in));
		}

		public String next() throws IOException {
			if (st == null || !st.hasMoreElements()) {
				st = new StringTokenizer(reader.readLine());
			}
			return st.nextToken();
		}

		public String nextLine() throws IOException {
			st = null;
			String readLine = null;
			readLine = reader.readLine();
			return readLine;
		}

		public int nextInt() throws NumberFormatException, IOException {
			return Integer.parseInt(next());
		}

		public long nextLong() throws NumberFormatException, IOException {
			return Long.parseLong(next());
		}

		public int[] nextIntArr(int n) throws NumberFormatException, IOException {
			int[] retArr = new int[n];
			for (int i = 0; i < n; i++) {
				retArr[i] = nextInt();
			}
			return retArr;
		}

		public long[] nextLongArr(int n) throws NumberFormatException, IOException {
			long[] retArr = new long[n];
			for (int i = 0; i < n; i++) {
				retArr[i] = nextLong();
			}
			return retArr;
		}

		public void close() throws IOException {
			reader.close();
		}
	}

}


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

using namespace std;

const int Mod = 1e9+7, Nmax = 1e5+5;

int i, p, n, p1=1, p2=1, d[Nmax][2], is_good[Nmax];
long long A, B, a[Nmax];

void get(int p)
{
    while(a[p1] + A <= a[p]) ++p1;
    while(a[p2] + B <= a[p]) ++p2;
}

int main()
{
    // freopen("input", "r", stdin);
  //  freopen("output", "w", stdout);

    scanf("%d%lld%lld", &n, &A, &B);

    if(A>B) swap(A, B);

    for(i=1; i<=n; ++i) scanf("%lld", &a[i]);

    is_good[1] = 1;
    for(i=2; i<=n; ++i)
        if(a[i] - a[i-1] >= A) is_good[i] = is_good[i-1];
        else is_good[i] = i;


    d[1][0] = d[1][1] = 1;

    for(i=2; i<=n; ++i)
    {
        if(a[i] - a[i-1] < A)
            d[i][0] = d[i-1][1] * (a[i] - a[i-2] >= A || i==2);
        else d[i][0] = d[i-1][0] + d[i-1][1];

        get(i);

        if(a[i] - a[i-1] < B)
            d[i][1] = d[p2][0] * (is_good[i-1] <= p2);
        else d[i][1] = d[i-1][1] + d[i-1][0];

        d[i][0] %= Mod;
        d[i][1] %= Mod;
    }

    printf("%d\n", (d[n][0] + d[n][1]) % Mod);

    return 0;
}


Measured memory_bytes: 2176
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define All(V) v.begin(), v.end()
typedef long long int ll;
typedef pair<int, int> P;
const ll MOD = 1e9+7, INF = 1e9;

int main() 
{
  char a, b; cin >> a >> b;
  if((a == 'H' && b == 'H') || (a == 'D' && b == 'D')){
    cout << "H" << endl;
  }
  else cout << "D" << endl;
  system("pause");
}

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

int main(){
        int a,b,c;
        scanf("%d %d %d",&a,&b,&c);
        int res = b/a;
        if(res>c){
                printf("%d\n",c);
        }else{
                printf("%d\n",res);
        }
        return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<cstring>
#include<algorithm>
#define ll long long
using namespace std;

const int N=100005;

int n,l,r,mid,mx,ans;
ll now,last;
int a[N];
ll s[N];

int main(){
	int i;
	scanf("%d",&n);
	for (i=1;i<=n;i++) scanf("%d",&a[i]);
	sort(a+1,a+1+n); mx=a[n];
	for (i=1;i<=n;i++) s[i]=s[i-1]+1ll*a[i];
	for (i=1;i<=n;i++){
		now=a[i]; last=now;
		while (now<1ll*mx){
			l=1; r=n;
			while (l<r){
				mid=(l+r+1)>>1;
				if (1ll*a[mid]<=2ll*now) l=mid;
				else r=mid-1;
			}
			now=s[l];
			if (now==last) break;
			last=now;
		}
		if (2ll*now>=1ll*mx) ans++;
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 1408
package main

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

var sc = bufio.NewScanner(os.Stdin)

func nextString() string {
	if !sc.Scan() {
		panic("failed scan string")
	}
	return sc.Text()
}

func nextInt() int {
	if !sc.Scan() {
		panic("failed scan int")
	}
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func main() {
	sc.Split(bufio.ScanWords)
	a := nextInt()
	b := nextInt()
	c := nextInt()
	d := nextInt()

	d2 := a - c
	if d2 < 0 {
		d2 = -d2
	}

	if d2 <= d {
		fmt.Println("Yes")
		return
	}

	d2 = a - b
	if d2 < 0 {
		d2 = -d2
	}

	if d2 > d {
		fmt.Println("No")
		return
	}

	d2 = b - c
	if d2 < 0 {
		d2 = -d2
	}

	if d2 > d {
		fmt.Println("No")
		return
	}

	fmt.Println("Yes")
}


Measured memory_bytes: 640
#include <cstdio>
using namespace std;

int main()
{
	long long a , b , c ;
	scanf("%lld %lld %lld", &a, &b, &c) ;
	long long d = c - a - b ;
	if(d < 0) 
	puts("No") ;
	else 
	puts((d * d > 4LL * a * b) ? "Yes" : "No") ;
	return 0 ;
}

Measured memory_bytes: 128
#include <iostream>
using namespace std;
int main()
{
    int a, b, c;
    cin >> a >> b >> c;

    if (a > c && c > b)
        cout << "Yes\n";
    else if (b > c && c > a)
        cout << "Yes\n";
    else
        cout << "No\n";
    
    return (0);
}

Measured memory_bytes: 256
import sys

sys.setrecursionlimit(2147483647)

n, m = list(map(int, input().split()))

def solve(n, m):
    graph = dict()
    table = [None]*n

    for _ in range(m):
        x, y = map(int, input().split())
        graph.setdefault(x-1, [])
        graph[x-1].append(y-1)

    # print(graph)

    # 頂点iからの先のグラフの、最大pathの大きさを返す
    def dp(i):
        # print('b', i, table)
        if table[i]:
            return table[i]

        childs = graph.get(i)
        if not childs:
            table[i] = 0
        else:
            table[i] = max([dp(y) for y in childs]) + 1

        # print('a', i, table)
        return table[i]

    for i in range(n):
        dp(i)

    return max(filter(lambda x: x, table))

print(solve(n, m))

"""
"""


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

YES = "Yes"  # type: str
NO = "No"  # type: str

def solve(N: int, a: "List[int]"):
    count = [0] * 3
    for v in a:
        if v % 4 == 0:
            count[2] += 1
        elif v % 2 == 0:
            count[1] += 1
        else:
            count[0] += 1
    if count[0] == count[2] + 1 and count[1] == 0:
        ret = YES
    elif count[0] > count[2]:
        ret = NO
    else:
        ret = YES
    print(ret)
    return


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    a = [ int(next(tokens)) for _ in range(N) ]  # type: "List[int]"
    solve(N, a)

if __name__ == '__main__':
    main()


Measured memory_bytes: 15140
#include<cstdio>
#include<iostream>
#include<string>
#include<algorithm>
#include<cstdlib>
using namespace std;

char x,y;

int main()
{
	cin>>x>>y;
	if('A' < x <'F' && 'A' < y <'F' && x < y)	cout<<"<"<<endl;
	else if('A' < x <'F' && 'A' < y <'F' && x > y)	cout<<">"<<endl;
	else if('A' < x <'F' && 'A' < y <'F' && x == y) cout<<"="<<endl;
	return 0;
}

Measured memory_bytes: 256
#%%
import numpy as np
n = int(input())
u, v, w = [0] * (n-1), [0] * (n-1), [0] * (n-1)

app = [[[] for _ in range(2)]for _ in range(n+1)]
for i in range(n-1):
    u[i], v[i], w[i] = map(int, input().split())
    if w[i] % 2 == 1:
        app[u[i]][0].append(v[i])
        app[v[i]][0].append(u[i])
    elif w[i] % 2 == 0:
        app[u[i]][1].append(v[i])
        app[v[i]][1].append(u[i])

#print(app)

que = [1]
ans = [2] * (n+1)
check = [0] * (n+1)

while len(que) > 0:
    tmp = que.pop(0)
    tmp_color = ans[tmp]
    tmp_list = app[tmp]
    check[tmp] = 1
    for i in range(2):
        for j in range(len(tmp_list[i])):
            if tmp_color == 0:
                if i == 0:
                    ans[tmp_list[i][j]] = 1
                else:
                    ans[tmp_list[i][j]] = 0
            else:
                if i == 0:
                    ans[tmp_list[i][j]] = 0
                else:
                    ans[tmp_list[i][j]] = 1
            if check[tmp_list[i][j]] == 0:
                que.append(tmp_list[i][j])

for i in range(1, n+1):
    print(ans[i])



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

using namespace std;
typedef long long ll;

void Solve()
{
    double n,pi=3.14159265358979323846;
    cin>>n;
    cout<<2.0*pi*n;
}

int main()
{
    ll t=1;
    // cin>>t;
    while(t--)
        Solve();
    return 0;
}

Measured memory_bytes: 3776
h,w = map(int, input().split())
a = [input() for i in range(h)]
a = [i for i in a if i!="."*w]
import numpy as np
flag = [[int(j) for j in i.replace(".","0").replace("#","1")] for i in a]
flagx = np.sum(flag,axis=0) > 0
d = {0:".",1:"#"}
for i in a:
  for j,b in zip(i,flagx):
    if b:
      print(j, end="")
  print()

Measured memory_bytes: 13804
#include<iostream>
using namespace std;
int main(){
int D,N,de=1;
  cin>>D>>N;
  if(D==0){
    de=1;
  }
  else{
    for(int i=0;i<D;i++) de*=100;
  }
   if(N<=99){
    		cout << de * N << endl;
    	}
    	else{
    		cout << de * 101 << endl;
    	}
}

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

using namespace std;

void solve(){
	int n;
	cin >> n;
	int ar[110];
	for(int i=0;i<n;i++){
		cin >> ar[i];
	}
	sort(ar,ar+n);
	
	int count=0;
	for(int i=0;i<=n;i++){
		for(int j=i+1;j<n;j++){
			if(ar[i]==ar[j]){
				continue;
			}
			for(int k=j+1;k<n;k++){
				if(ar[j]== ar[k]){
					continue;
				}
				count += ar[i] + ar[j] > ar[k];
			}
		}
	}
	cout << count << endl;
}


int main(){
/*#ifndef ONLINE_JUDGE
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
#endif*/
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	solve();
	return 0;
}

Measured memory_bytes: 3612
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
int main(){
  const ll INF=1e18;
  int n,m,l,i,j,k;
  cin >> n >> m >> l;
  ll dp[310][310],dp1[310][310];
  for(i=0;i<n;i++){
    for(j=0;j<n;j++){
      dp[i][j]=INF,dp1[i][j]=INF;
    }
  }
  for(i=0;i<m;i++){
    int a,b,c;
    cin >> a >> b >> c;
    a--,b--;
    dp[a][b]=c,dp[b][a]=c;
  }
  for(k=0;k<n;k++){
    for(i=0;i<n;i++){
      for(j=0;j<n;j++){
        dp[i][j]=min(dp[i][j],dp[i][k]+dp[k][j]);
      }
    }
  }
  for(i=0;i<n;i++){
    for(j=0;j<n;j++){
      if(dp[i][j]<=l){
        dp1[i][j]=1;
      }
    }
  }
  for(k=0;k<n;k++){
    for(i=0;i<n;i++){
      for(j=0;j<n;j++){
        dp1[i][j]=min(dp1[i][j],dp1[i][k]+dp1[k][j]);
      }
    }
  }
  int q;
  cin >> q;
  for(i=0;i<q;i++){
    int s,t;
    cin >> s >> t;
    s--,t--;
    if(dp1[s][t]==INF){
      cout << -1 << endl;
    }
    else{
      cout << dp1[s][t]-1 << endl;
    }
  }
}

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

int main() {
	int N, Q;
	string S;
	cin >> N >> S >> Q;
	vector<set<int>> al(26);

	// 前処理
	for(int i=0;i<N;i++) {
		char c = S[i];
		al[c-'a'].insert(i);
	}

	for(int q=0;q<Q;q++) {
		int tmp;
		cin >> tmp;
		if(tmp == 1) {
			int i;
			char c;
			cin >> i >> c;
			i--;
			al[S[i]-'a'].erase(i);
			S[i] = c;
			al[c-'a'].insert(i);
		} else {
			int l, r;
			cin >> l >> r;
			l--, r--;
			int cnt = 0;
			for(int i=0;i<26;i++) {
				// l番目以上, r番目以下の数に'a'+iが存在するかどうか確かめる
				auto lb = al[i].lower_bound(l);
				auto ub = al[i].upper_bound(r);
				if(ub != lb) {
					cnt++;
				}
			}
			cout << cnt << endl;
		}
	}
}

Measured memory_bytes: 25604
import sys

sys.setrecursionlimit(10 ** 7)
f_inf = float('inf')
mod = 10 ** 9 + 7


def gcd(a, b):
    while b != 0:
        a, b = b, a % b
    return a


def resolve():
    a, b, c = map(int, input().split())

    g = gcd(a, b)
    if c % g == 0:
        print("YES")
    else:
        print("NO")

if __name__ == '__main__':
    resolve()


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define int         long long
#define endl        "\n"
#define pii         pair<int, int>
#define dint        long double

// tourist

bool cmp(pii a, pii b) {
    return (a.first + a.second < b.first + b.second);
}

const int inf = 1e18;

void solve() {
    int n; cin >> n;
    pii a[n+1];
    for(int i=1; i<=n; i++) {
        cin >> a[i].first >> a[i].second;
    }  
     // First -> Strenght, Second -> Weight
    sort(a+1, a+n+1, cmp);
    int dp[n+1][n+1];
    for(int i=0; i<=n; i++) for(int j=0; j<=n; j++) dp[i][j] = inf;
    dp[0][0] = 0;
    for(int i=0; i<n; i++) {
        for(int j=0; j<=i; j++) {
            int wt = dp[i][j];
            if(wt == inf) continue;
            dp[i+1][j] = min(dp[i+1][j], wt);
            if(wt <= a[i+1].first) {
                dp[i+1][j+1] = min(dp[i+1][j+1], wt + a[i+1].second);
            }
        }
    }
    int ans = 0;
    for(int i=0; i<=n; i++) {
        if(dp[n][i] != inf) {
            ans = i;
        }
    }
    cout << ans << endl;
}

signed main() {

    ios_base::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
    cout << fixed << setprecision(12);

    int T = 1;
    //cin >> T;
    for(int i=1; i<=T; i++) {
        solve();
    }
    return 0;

}



Measured memory_bytes: 195712
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define loop(__x, __start, __end) for(int __x = __start; __x < __end; __x++)

template<int MOD>
struct ModInt {
  ll x;
  ModInt():x(0){}
  ModInt(ll x):x((x%MOD+MOD)%MOD){}
  int getMod() { return MOD; }
  ModInt operator-() const { return ModInt(0) - *this;}
  ModInt& operator+=(const ModInt& a){ if((x+=a.x)>=MOD) x-=MOD; return *this;}
  ModInt& operator-=(const ModInt& a){ if((x+=MOD-a.x)>=MOD) x-=MOD; return *this;}
  ModInt& operator*=(const ModInt& a){ (x*=a.x)%=MOD; return *this;}
  ModInt operator+(const ModInt& a)const{ return ModInt(*this) += a;}
  ModInt operator-(const ModInt& a)const{ return ModInt(*this) -= a;}
  ModInt operator*(const ModInt& a)const{ return ModInt(*this) *= a;}
  bool operator<(const ModInt& a)const{ return x < a.x;}
  bool operator==(const ModInt& a)const{ return x == a.x;}
  ModInt pow(ll t) const {
    if (!t) return 1;
    ModInt a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }
  friend istream & operator >> (istream & in, ModInt & v) {
    ll x;
    in >> x;
    v.x = x;
    return in;
  }
  friend ostream & operator << (ostream & out, ModInt<MOD> const & v) {
    out << v.x;
    return out;
  }
};
const int MOD = 1000000007;
using mint = ModInt<MOD>;

template<class T> struct BiCoef {
  vector<T> fact_, inv_, finv_;
  constexpr BiCoef() {}
  constexpr BiCoef(int n) noexcept : fact_(n, 1), inv_(n, 1), finv_(n, 1) {
    init(n);
  }
  constexpr void init(int n) noexcept {
    int MOD = fact_[0].getMod();
    fact_.assign(n, 1), inv_.assign(n, 1), finv_.assign(n, 1);
    for(int i = 2; i < n; i++){
      fact_[i] = fact_[i-1] * i;
      inv_[i] = -inv_[MOD%i] * (MOD/i);
      finv_[i] = finv_[i-1] * inv_[i];
    }
  }
  constexpr T perm(int n, int k) const noexcept {
    if (n < k || n < 0 || k < 0) return 0;
    return com(n, k) * fact(k);
  }
  constexpr T com(int n, int k) const noexcept {
    if (n < k || n < 0 || k < 0) return 0;
    return fact_[n] * finv_[k] * finv_[n-k];
  }
  constexpr T fact(int n) const noexcept {
    if (n < 0) return 0;
    return fact_[n];
  }
  constexpr T inv(int n) const noexcept {
    if (n < 0) return 0;
    return inv_[n];
  }
  constexpr T finv(int n) const noexcept {
    if (n < 0) return 0;
    return finv_[n];
  }
};


int main() {
  ll s; cin >> s;
  BiCoef<mint> bc(10*s);
  mint ans = 0;
  loop(k,1,s+1) {
    if (s - 3 * k < 0) break;
    ans += bc.com(k + (s-3*k) -1, s-3*k);
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3920
/*
 *  Author : Jun_SH
 *  Solution for ABC 140 B
 */
#include<bits/stdc++.h>
#define int long long
#define sd(a) scanf("%lld",&a)
using namespace std;
const int inf=0x3f3f3f3f;
int a[30],b[30],c[30];
main(){
    int n;
    cin>>n;
    a[0]=-1;
    for(int i=1;i<=n;++i)cin>>a[i];
    for(int i=1;i<=n;++i)cin>>b[i];
    for(int i=1;i<=n-1;++i)cin>>c[i];
    int sum=0;
    for(int i=1;i<=n;++i){
        if(a[i]==a[i-1]+1)
            sum+=c[a[i-1]];
        sum+=b[a[i]];
    }
    cout<<sum<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repr(i, n) for (int i = (n); i >= 0; --i)
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define FORR(i, m, n) for (int i = (m); i >= (n); --i)
#define equals(a, b) (fabs((a) - (b)) < EPS)
using namespace std;
typedef long long ll;
const ll mod = 1000000007;
const ll mod2 = 998244353;
const ll INF = 1e18;
const long double EPS = 1e-10;

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

  int n = s.size();
  int ans = 0;
  rep(i, n / 2) {
    if (s[i] != s[n - 1 - i]) ans++;
  }
  cout << ans << endl;

  
  return 0;
}

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

#define int long long int

int combination(int n) {
    return (n * (n - 1)) / 2;
}

signed main(void){
    int n;
    cin >> n;
    
    vector<string> s(n);
    for (int i=0;i<n;++i) {
        cin >> s[i];
        sort(s[i].begin(), s[i].end());
    }
    sort(s.begin(), s.end());
    // for (int i=0;i<n;++i) cout << s[i] << endl;
    
    int count = 1;
    int ans = 0;
    for (int i=0;i<n-1;i++) {
        if(s[i+1] == s[i]) count++;
        else {
            // nC2
            ans += combination(count);
            count = 1;
        }
    }
    if(count != 1) ans += combination(count);
    cout << ans;
    
    return 0;
}


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

#include<ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;

template <typename T> using oset = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
const int mod = (int)1e7+9;
#define REP0(i,n) for(int i=0;i<n;i++)
#define REP(i,a,n) for(int i=a;i<=n;i++)
#define F first
#define S second
#define endl "\n"
#define ll long long
#define pii pair<int,int>
#define vi vector<int>
#define vb vector<bool>
#define maxpq priority_queue<int>
#define minpq priority_queue<int, vector<int>, greater<int> >
#define setbits(x) __builtin_popcountll(x)
#define inf (int)(1e18)
#define prec(x) fixed<<setprecision(x)<<x
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define all(x) x.begin(),x.end()

const int d4i[4]={-1, 0, 1, 0}, d4j[4]={0, 1, 0, -1};
const int d8i[8]={-1, -1, 0, 1, 1, 1, 0, -1}, d8j[8]={0, 1, 1, 1, 0, -1, -1, -1};

void dfs(int node,vi adj[],vi &dp,vb &vis){
    vis[node] = true;
    REP0(i,adj[node].size()){
        if(!vis[adj[node][i]]){
            dfs(adj[node][i],adj,dp,vis);
        }
        dp[node] = max(dp[node],1+dp[adj[node][i]]);
    }
}

int findLongestPath(vi adj[],int n){
    vi dp(n+1,0);
    vb vis(n+1,false);
    for(int i=1;i<=n;i++){
        if(!vis[i]){
            dfs(i,adj,dp,vis);
        }
    }
    return *max_element(all(dp));
}

void solve(){
   int n,m;
   cin>>n>>m;
   vi  adj[n+1];
   REP0(i,m){
       int u,v;
       cin>>u>>v;
       adj[u].push_back(v);
   }
   cout<<findLongestPath(adj,n);
}


int main(){
    fastio;
    #ifndef ONLINE_JUDGE
        //freopen("input.txt", "r", stdin);
        //freopen("output.txt", "w", stdout);
    #endif
    int tc = 1;
    // cin>>tc;
    for(int i=1;i<=tc;i++){
        solve();
    }
    return 0;
}


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

using namespace std;

int main() {
	int N;
	cin >> N;
	vector<int>A(N + 1), B(N);
	for (int i = 0; i <= N; i++)
	{
		cin >> A[i];
	}
	for (int i = 0; i < N; i++)
	{
		cin >> B[i];
	}

	long long ans = 0;

	for (int i = 0; i < N ; i++)
	{
		int leftattack = min(A[i], B[i]);
		ans += leftattack;
		A[i] -= leftattack;
		B[i] -= leftattack;

		int rightattack = min(A[i + 1], B[i]);
		ans += rightattack;
		A[i+1] -= rightattack;
		B[i] -= rightattack;
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 1024
n=int(input())
A=sorted(list(map(float,input().split())))
a=A[-1]
b=a/2
c=a
for i in range(n):
  d=abs(A[i]-b)
  if d<c:
    c=d
    e=A[i]
print(int(a),end=" ")
print(int(e))

Measured memory_bytes: 13284
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <sstream>
#include <string>
#define _repargs(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _repargs(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define mod 1000000007
#define inf 2000000007
#define mp make_pair
#define pb push_back
typedef long long ll;
using namespace std;
template <typename T>
inline void output(T a, int p = 0) {
    if(p) cout << fixed << setprecision(p)  << a << "\n";
    else cout << a << "\n";
}
// end of template

int main() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    // source code
    int N;
    cin >> N;
    
    vector<int> C(13, 0);
    C[0] = 1;
    rep(i, N){
        int a;
        cin >> a;
        C[a]++;
    }
    
    if(C[0] >= 2 || C[12] >= 2){
        output(0);
        return 0;
    }
    rep(i, 1, 12){
        if(C[i] >= 3){
            output(0);
            return 0;
        }
    }
    
    
    vector<int> tmp(24, 0);
    tmp[0] = 1;
    int mask1 = 1;
    rep(i, 1, 12){
        if(C[i] == 2){
            mask1 |= (1 << i);
            mask1 |= (1 << (24 - i));
            tmp[i] = tmp[24 - i] = 1;
        }
    }
    if(C[12]){
        mask1 |= 1 << 12;
        tmp[12] = 1;
    }
    
    
    int mask2 = (1 << 24) - 1;
    rep(i, 1, 12){
        if(C[i] == 0){
            mask2 -= (1 << i);
            mask2 -= (1 << (24 - i));
            tmp[i] = tmp[24 - i] = -1;
        }
    }
    if(C[12] == 0){
        mask2 -= (1 << 12);
        tmp[12] = -1;
    }
    
    
    
    int ans = 0;
    rep(i, (1 << 11)){
        vector<int> B = tmp;
        rep(j, 11){
            if(B[j + 1] == 0){
                if((i >> j) & 1){
                    B[j + 1] = 1;
                }
                else {
                    B[23 - j] = 1;
                }
            }
        }
        
        
        vector<int> C;
        rep(j, 24){
            if(B[j] == 1){
                C.pb(j);
            }
        }
        int m = 12;
        rep(k, 1, C.size()){
            m = min(m, C[k] - C[k - 1]);
        }
        m = min(m, 24 - C.back());
        ans = max(ans, m);
    }
    
    output(ans);
    
    
    
    return 0;
}


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

int main() {
  int n = 0, a, b;
  string s, t;
  //cin >> n >> a >> b;
  cin >> s >> t;
  for(int i = 0; i < 3; i++) {
    if(s.at(i) == t.at(i)) n++;
  }
  cout << n << endl;
}

Measured memory_bytes: 256
def main():    
    n = int(input())
    a = list(map(int,input().split()))
    b = list(map(int,input().split()))
    c = list(map(int,input().split()))
    ans = sum(b)
    for i in range(n-1):
        if a[i]+1 == a[i+1]:
            ans += c[a[i]-1]
    print(ans)
    
if __name__ == '__main__':
    main()

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef long double ld;
const int inf=1e9+7;
const ll longinf=1LL<<60;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define F first
#define S second

const int mx=100010;
const ll mod=1e9+7;

int main(){
  int n,m; cin >> n >> m;
  ll ans=0;
  if(n>=13){ans=m;}else if(n>=6){ans=m/2;}
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256